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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/dist/core.umd.js +1664 -799
  2. package/dist/index.esm.js +2158 -1203
  3. package/dist/index.esm.js.map +4 -4
  4. package/dist/index.js +2208 -1296
  5. package/dist/index.js.map +4 -4
  6. package/lib/components/Form.d.ts +22 -9
  7. package/lib/components/Form.d.ts.map +1 -0
  8. package/lib/components/Form.js +368 -312
  9. package/lib/components/fields/ArrayField.d.ts +20 -9
  10. package/lib/components/fields/ArrayField.d.ts.map +1 -0
  11. package/lib/components/fields/ArrayField.js +212 -206
  12. package/lib/components/fields/BooleanField.d.ts +1 -0
  13. package/lib/components/fields/BooleanField.d.ts.map +1 -0
  14. package/lib/components/fields/BooleanField.js +6 -14
  15. package/lib/components/fields/LayoutGridField.d.ts +480 -0
  16. package/lib/components/fields/LayoutGridField.d.ts.map +1 -0
  17. package/lib/components/fields/LayoutGridField.js +711 -0
  18. package/lib/components/fields/LayoutHeaderField.d.ts +12 -0
  19. package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -0
  20. package/lib/components/fields/LayoutHeaderField.js +23 -0
  21. package/lib/components/fields/LayoutMultiSchemaField.d.ts +28 -0
  22. package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -0
  23. package/lib/components/fields/LayoutMultiSchemaField.js +114 -0
  24. package/lib/components/fields/MultiSchemaField.d.ts +1 -0
  25. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -0
  26. package/lib/components/fields/MultiSchemaField.js +31 -31
  27. package/lib/components/fields/NullField.d.ts +1 -0
  28. package/lib/components/fields/NullField.d.ts.map +1 -0
  29. package/lib/components/fields/NullField.js +0 -1
  30. package/lib/components/fields/NumberField.d.ts +1 -0
  31. package/lib/components/fields/NumberField.d.ts.map +1 -0
  32. package/lib/components/fields/NumberField.js +2 -3
  33. package/lib/components/fields/ObjectField.d.ts +1 -0
  34. package/lib/components/fields/ObjectField.d.ts.map +1 -0
  35. package/lib/components/fields/ObjectField.js +146 -141
  36. package/lib/components/fields/SchemaField.d.ts +1 -0
  37. package/lib/components/fields/SchemaField.d.ts.map +1 -0
  38. package/lib/components/fields/SchemaField.js +9 -17
  39. package/lib/components/fields/StringField.d.ts +1 -0
  40. package/lib/components/fields/StringField.d.ts.map +1 -0
  41. package/lib/components/fields/StringField.js +1 -3
  42. package/lib/components/fields/index.d.ts +1 -0
  43. package/lib/components/fields/index.d.ts.map +1 -0
  44. package/lib/components/fields/index.js +14 -9
  45. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -0
  46. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -0
  47. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +0 -1
  48. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +8 -0
  49. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -0
  50. package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +17 -0
  51. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +4 -3
  52. package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -0
  53. package/lib/components/templates/ArrayFieldItemTemplate.js +7 -6
  54. package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -1
  55. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -0
  56. package/lib/components/templates/ArrayFieldTemplate.js +3 -4
  57. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -0
  58. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -0
  59. package/lib/components/templates/ArrayFieldTitleTemplate.js +0 -1
  60. package/lib/components/templates/BaseInputTemplate.d.ts +1 -0
  61. package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -0
  62. package/lib/components/templates/BaseInputTemplate.js +0 -1
  63. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -0
  64. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -0
  65. package/lib/components/templates/ButtonTemplates/AddButton.js +1 -2
  66. package/lib/components/templates/ButtonTemplates/IconButton.d.ts +1 -0
  67. package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -0
  68. package/lib/components/templates/ButtonTemplates/IconButton.js +4 -5
  69. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -0
  70. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -0
  71. package/lib/components/templates/ButtonTemplates/SubmitButton.js +0 -1
  72. package/lib/components/templates/ButtonTemplates/index.d.ts +1 -0
  73. package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -0
  74. package/lib/components/templates/ButtonTemplates/index.js +3 -4
  75. package/lib/components/templates/DescriptionField.d.ts +1 -0
  76. package/lib/components/templates/DescriptionField.d.ts.map +1 -0
  77. package/lib/components/templates/DescriptionField.js +0 -1
  78. package/lib/components/templates/ErrorList.d.ts +1 -0
  79. package/lib/components/templates/ErrorList.d.ts.map +1 -0
  80. package/lib/components/templates/ErrorList.js +0 -1
  81. package/lib/components/templates/FieldErrorTemplate.d.ts +1 -0
  82. package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -0
  83. package/lib/components/templates/FieldErrorTemplate.js +0 -1
  84. package/lib/components/templates/FieldHelpTemplate.d.ts +1 -0
  85. package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -0
  86. package/lib/components/templates/FieldHelpTemplate.js +0 -1
  87. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -0
  88. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -0
  89. package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -2
  90. package/lib/components/templates/FieldTemplate/Label.d.ts +1 -0
  91. package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -0
  92. package/lib/components/templates/FieldTemplate/Label.js +0 -1
  93. package/lib/components/templates/FieldTemplate/index.d.ts +2 -1
  94. package/lib/components/templates/FieldTemplate/index.d.ts.map +1 -0
  95. package/lib/components/templates/FieldTemplate/index.js +1 -2
  96. package/lib/components/templates/GridTemplate.d.ts +8 -0
  97. package/lib/components/templates/GridTemplate.d.ts.map +1 -0
  98. package/lib/components/templates/GridTemplate.js +10 -0
  99. package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -0
  100. package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -0
  101. package/lib/components/templates/ObjectFieldTemplate.js +2 -3
  102. package/lib/components/templates/TitleField.d.ts +1 -0
  103. package/lib/components/templates/TitleField.d.ts.map +1 -0
  104. package/lib/components/templates/TitleField.js +0 -1
  105. package/lib/components/templates/UnsupportedField.d.ts +1 -0
  106. package/lib/components/templates/UnsupportedField.d.ts.map +1 -0
  107. package/lib/components/templates/UnsupportedField.js +0 -1
  108. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -0
  109. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -0
  110. package/lib/components/templates/WrapIfAdditionalTemplate.js +10 -6
  111. package/lib/components/templates/index.d.ts +1 -0
  112. package/lib/components/templates/index.d.ts.map +1 -0
  113. package/lib/components/templates/index.js +19 -16
  114. package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -0
  115. package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -0
  116. package/lib/components/widgets/AltDateTimeWidget.js +0 -1
  117. package/lib/components/widgets/AltDateWidget.d.ts +1 -0
  118. package/lib/components/widgets/AltDateWidget.d.ts.map +1 -0
  119. package/lib/components/widgets/AltDateWidget.js +0 -1
  120. package/lib/components/widgets/CheckboxWidget.d.ts +1 -0
  121. package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -0
  122. package/lib/components/widgets/CheckboxWidget.js +1 -3
  123. package/lib/components/widgets/CheckboxesWidget.d.ts +1 -0
  124. package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -0
  125. package/lib/components/widgets/CheckboxesWidget.js +0 -1
  126. package/lib/components/widgets/ColorWidget.d.ts +1 -0
  127. package/lib/components/widgets/ColorWidget.d.ts.map +1 -0
  128. package/lib/components/widgets/ColorWidget.js +0 -1
  129. package/lib/components/widgets/DateTimeWidget.d.ts +1 -0
  130. package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -0
  131. package/lib/components/widgets/DateTimeWidget.js +0 -1
  132. package/lib/components/widgets/DateWidget.d.ts +1 -0
  133. package/lib/components/widgets/DateWidget.d.ts.map +1 -0
  134. package/lib/components/widgets/DateWidget.js +0 -1
  135. package/lib/components/widgets/EmailWidget.d.ts +1 -0
  136. package/lib/components/widgets/EmailWidget.d.ts.map +1 -0
  137. package/lib/components/widgets/EmailWidget.js +0 -1
  138. package/lib/components/widgets/FileWidget.d.ts +1 -0
  139. package/lib/components/widgets/FileWidget.d.ts.map +1 -0
  140. package/lib/components/widgets/FileWidget.js +3 -5
  141. package/lib/components/widgets/HiddenWidget.d.ts +1 -0
  142. package/lib/components/widgets/HiddenWidget.d.ts.map +1 -0
  143. package/lib/components/widgets/HiddenWidget.js +0 -1
  144. package/lib/components/widgets/PasswordWidget.d.ts +1 -0
  145. package/lib/components/widgets/PasswordWidget.d.ts.map +1 -0
  146. package/lib/components/widgets/PasswordWidget.js +0 -1
  147. package/lib/components/widgets/RadioWidget.d.ts +1 -0
  148. package/lib/components/widgets/RadioWidget.d.ts.map +1 -0
  149. package/lib/components/widgets/RadioWidget.js +3 -4
  150. package/lib/components/widgets/RangeWidget.d.ts +1 -0
  151. package/lib/components/widgets/RangeWidget.d.ts.map +1 -0
  152. package/lib/components/widgets/RangeWidget.js +0 -1
  153. package/lib/components/widgets/RatingWidget.d.ts +15 -0
  154. package/lib/components/widgets/RatingWidget.d.ts.map +1 -0
  155. package/lib/components/widgets/RatingWidget.js +63 -0
  156. package/lib/components/widgets/SelectWidget.d.ts +1 -0
  157. package/lib/components/widgets/SelectWidget.d.ts.map +1 -0
  158. package/lib/components/widgets/SelectWidget.js +4 -5
  159. package/lib/components/widgets/TextWidget.d.ts +1 -0
  160. package/lib/components/widgets/TextWidget.d.ts.map +1 -0
  161. package/lib/components/widgets/TextWidget.js +0 -1
  162. package/lib/components/widgets/TextareaWidget.d.ts +1 -0
  163. package/lib/components/widgets/TextareaWidget.d.ts.map +1 -0
  164. package/lib/components/widgets/TextareaWidget.js +0 -1
  165. package/lib/components/widgets/TimeWidget.d.ts +1 -0
  166. package/lib/components/widgets/TimeWidget.d.ts.map +1 -0
  167. package/lib/components/widgets/TimeWidget.js +0 -1
  168. package/lib/components/widgets/URLWidget.d.ts +1 -0
  169. package/lib/components/widgets/URLWidget.d.ts.map +1 -0
  170. package/lib/components/widgets/URLWidget.js +0 -1
  171. package/lib/components/widgets/UpDownWidget.d.ts +1 -0
  172. package/lib/components/widgets/UpDownWidget.d.ts.map +1 -0
  173. package/lib/components/widgets/UpDownWidget.js +0 -1
  174. package/lib/components/widgets/index.d.ts +1 -0
  175. package/lib/components/widgets/index.d.ts.map +1 -0
  176. package/lib/components/widgets/index.js +21 -20
  177. package/lib/getDefaultRegistry.d.ts +1 -0
  178. package/lib/getDefaultRegistry.d.ts.map +1 -0
  179. package/lib/getDefaultRegistry.js +3 -4
  180. package/lib/index.d.ts +4 -3
  181. package/lib/index.d.ts.map +1 -0
  182. package/lib/index.js +3 -4
  183. package/lib/tsconfig.tsbuildinfo +1 -1
  184. package/lib/withTheme.d.ts +2 -1
  185. package/lib/withTheme.d.ts.map +1 -0
  186. package/lib/withTheme.js +7 -8
  187. package/package.json +46 -37
  188. package/src/components/Form.tsx +127 -41
  189. package/src/components/fields/ArrayField.tsx +34 -24
  190. package/src/components/fields/BooleanField.tsx +6 -14
  191. package/src/components/fields/LayoutGridField.tsx +967 -0
  192. package/src/components/fields/LayoutHeaderField.tsx +49 -0
  193. package/src/components/fields/LayoutMultiSchemaField.tsx +228 -0
  194. package/src/components/fields/MultiSchemaField.tsx +9 -4
  195. package/src/components/fields/NullField.tsx +1 -1
  196. package/src/components/fields/NumberField.tsx +5 -5
  197. package/src/components/fields/ObjectField.tsx +32 -24
  198. package/src/components/fields/SchemaField.tsx +16 -22
  199. package/src/components/fields/StringField.tsx +2 -2
  200. package/src/components/fields/index.ts +7 -1
  201. package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -2
  202. package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +85 -0
  203. package/src/components/templates/ArrayFieldItemTemplate.tsx +18 -57
  204. package/src/components/templates/ArrayFieldTemplate.tsx +10 -8
  205. package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -2
  206. package/src/components/templates/BaseInputTemplate.tsx +4 -4
  207. package/src/components/templates/ButtonTemplates/IconButton.tsx +9 -36
  208. package/src/components/templates/ButtonTemplates/SubmitButton.tsx +1 -1
  209. package/src/components/templates/ButtonTemplates/index.ts +1 -1
  210. package/src/components/templates/DescriptionField.tsx +1 -1
  211. package/src/components/templates/FieldErrorTemplate.tsx +1 -1
  212. package/src/components/templates/FieldHelpTemplate.tsx +1 -1
  213. package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -2
  214. package/src/components/templates/GridTemplate.tsx +15 -0
  215. package/src/components/templates/ObjectFieldTemplate.tsx +5 -3
  216. package/src/components/templates/TitleField.tsx +1 -1
  217. package/src/components/templates/UnsupportedField.tsx +1 -1
  218. package/src/components/templates/WrapIfAdditionalTemplate.tsx +14 -4
  219. package/src/components/templates/index.ts +4 -0
  220. package/src/components/widgets/AltDateWidget.tsx +9 -6
  221. package/src/components/widgets/CheckboxWidget.tsx +4 -4
  222. package/src/components/widgets/CheckboxesWidget.tsx +2 -2
  223. package/src/components/widgets/ColorWidget.tsx +1 -1
  224. package/src/components/widgets/DateTimeWidget.tsx +1 -1
  225. package/src/components/widgets/DateWidget.tsx +1 -1
  226. package/src/components/widgets/EmailWidget.tsx +1 -1
  227. package/src/components/widgets/FileWidget.tsx +5 -5
  228. package/src/components/widgets/PasswordWidget.tsx +1 -1
  229. package/src/components/widgets/RadioWidget.tsx +3 -3
  230. package/src/components/widgets/RangeWidget.tsx +1 -1
  231. package/src/components/widgets/RatingWidget.tsx +129 -0
  232. package/src/components/widgets/SelectWidget.tsx +4 -3
  233. package/src/components/widgets/TextWidget.tsx +1 -1
  234. package/src/components/widgets/TextareaWidget.tsx +3 -3
  235. package/src/components/widgets/TimeWidget.tsx +1 -1
  236. package/src/components/widgets/URLWidget.tsx +1 -1
  237. package/src/components/widgets/UpDownWidget.tsx +1 -1
  238. package/src/components/widgets/index.ts +3 -1
  239. package/src/getDefaultRegistry.ts +1 -1
  240. package/src/tsconfig.json +14 -6
  241. package/src/withTheme.tsx +4 -3
  242. package/LICENSE.md +0 -201
  243. package/lib/components/Form.js.map +0 -1
  244. package/lib/components/fields/ArrayField.js.map +0 -1
  245. package/lib/components/fields/BooleanField.js.map +0 -1
  246. package/lib/components/fields/MultiSchemaField.js.map +0 -1
  247. package/lib/components/fields/NullField.js.map +0 -1
  248. package/lib/components/fields/NumberField.js.map +0 -1
  249. package/lib/components/fields/ObjectField.js.map +0 -1
  250. package/lib/components/fields/SchemaField.js.map +0 -1
  251. package/lib/components/fields/StringField.js.map +0 -1
  252. package/lib/components/fields/index.js.map +0 -1
  253. package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +0 -1
  254. package/lib/components/templates/ArrayFieldItemTemplate.js.map +0 -1
  255. package/lib/components/templates/ArrayFieldTemplate.js.map +0 -1
  256. package/lib/components/templates/ArrayFieldTitleTemplate.js.map +0 -1
  257. package/lib/components/templates/BaseInputTemplate.js.map +0 -1
  258. package/lib/components/templates/ButtonTemplates/AddButton.js.map +0 -1
  259. package/lib/components/templates/ButtonTemplates/IconButton.js.map +0 -1
  260. package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +0 -1
  261. package/lib/components/templates/ButtonTemplates/index.js.map +0 -1
  262. package/lib/components/templates/DescriptionField.js.map +0 -1
  263. package/lib/components/templates/ErrorList.js.map +0 -1
  264. package/lib/components/templates/FieldErrorTemplate.js.map +0 -1
  265. package/lib/components/templates/FieldHelpTemplate.js.map +0 -1
  266. package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +0 -1
  267. package/lib/components/templates/FieldTemplate/Label.js.map +0 -1
  268. package/lib/components/templates/FieldTemplate/index.js.map +0 -1
  269. package/lib/components/templates/ObjectFieldTemplate.js.map +0 -1
  270. package/lib/components/templates/TitleField.js.map +0 -1
  271. package/lib/components/templates/UnsupportedField.js.map +0 -1
  272. package/lib/components/templates/WrapIfAdditionalTemplate.js.map +0 -1
  273. package/lib/components/templates/index.js.map +0 -1
  274. package/lib/components/widgets/AltDateTimeWidget.js.map +0 -1
  275. package/lib/components/widgets/AltDateWidget.js.map +0 -1
  276. package/lib/components/widgets/CheckboxWidget.js.map +0 -1
  277. package/lib/components/widgets/CheckboxesWidget.js.map +0 -1
  278. package/lib/components/widgets/ColorWidget.js.map +0 -1
  279. package/lib/components/widgets/DateTimeWidget.js.map +0 -1
  280. package/lib/components/widgets/DateWidget.js.map +0 -1
  281. package/lib/components/widgets/EmailWidget.js.map +0 -1
  282. package/lib/components/widgets/FileWidget.js.map +0 -1
  283. package/lib/components/widgets/HiddenWidget.js.map +0 -1
  284. package/lib/components/widgets/PasswordWidget.js.map +0 -1
  285. package/lib/components/widgets/RadioWidget.js.map +0 -1
  286. package/lib/components/widgets/RangeWidget.js.map +0 -1
  287. package/lib/components/widgets/SelectWidget.js.map +0 -1
  288. package/lib/components/widgets/TextWidget.js.map +0 -1
  289. package/lib/components/widgets/TextareaWidget.js.map +0 -1
  290. package/lib/components/widgets/TimeWidget.js.map +0 -1
  291. package/lib/components/widgets/URLWidget.js.map +0 -1
  292. package/lib/components/widgets/UpDownWidget.js.map +0 -1
  293. package/lib/components/widgets/index.js.map +0 -1
  294. package/lib/getDefaultRegistry.js.map +0 -1
  295. package/lib/index.js.map +0 -1
  296. package/lib/withTheme.js.map +0 -1
package/dist/index.esm.js CHANGED
@@ -3,22 +3,26 @@ import { Component as Component5, createRef } from "react";
3
3
  import {
4
4
  createSchemaUtils,
5
5
  deepEquals as deepEquals3,
6
- getTemplate as getTemplate20,
7
- getUiOptions as getUiOptions12,
8
- isObject as isObject5,
9
- mergeObjects as mergeObjects2,
6
+ getChangedFields,
7
+ getTemplate as getTemplate24,
8
+ getUiOptions as getUiOptions16,
9
+ isObject as isObject6,
10
+ mergeObjects as mergeObjects3,
10
11
  NAME_KEY,
11
12
  RJSF_ADDITIONAL_PROPERTIES_FLAG,
12
13
  shouldRender,
13
14
  SUBMIT_BTN_OPTIONS_KEY,
14
15
  toErrorList,
15
16
  UI_GLOBAL_OPTIONS_KEY,
16
- UI_OPTIONS_KEY as UI_OPTIONS_KEY2,
17
- validationDataMerge
17
+ UI_OPTIONS_KEY as UI_OPTIONS_KEY3,
18
+ validationDataMerge,
19
+ createErrorHandler,
20
+ unwrapErrorHandler
18
21
  } from "@rjsf/utils";
19
22
  import _forEach from "lodash/forEach";
20
23
  import _get from "lodash/get";
21
24
  import _isEmpty from "lodash/isEmpty";
25
+ import _isNil from "lodash/isNil";
22
26
  import _pick from "lodash/pick";
23
27
  import _toPath from "lodash/toPath";
24
28
 
@@ -68,189 +72,6 @@ var ArrayField = class extends Component {
68
72
  */
69
73
  constructor(props) {
70
74
  super(props);
71
- /** Returns the default form information for an item based on the schema for that item. Deals with the possibility
72
- * that the schema is fixed and allows additional items.
73
- */
74
- this._getNewFormDataRow = () => {
75
- const { schema, registry } = this.props;
76
- const { schemaUtils } = registry;
77
- let itemSchema = schema.items;
78
- if (isFixedItems(schema) && allowAdditionalItems(schema)) {
79
- itemSchema = schema.additionalItems;
80
- }
81
- return schemaUtils.getDefaultFormState(itemSchema);
82
- };
83
- /** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
84
- * the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
85
- * keyed data
86
- *
87
- * @param event - The event for the click
88
- */
89
- this.onAddClick = (event) => {
90
- this._handleAddClick(event);
91
- };
92
- /** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
93
- * keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
94
- * form data converted from the keyed data
95
- *
96
- * @param index - The index at which the add button is clicked
97
- */
98
- this.onAddIndexClick = (index) => {
99
- return (event) => {
100
- this._handleAddClick(event, index);
101
- };
102
- };
103
- /** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
104
- * keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
105
- * form data converted from the keyed data
106
- *
107
- * @param index - The index at which the copy button is clicked
108
- */
109
- this.onCopyIndexClick = (index) => {
110
- return (event) => {
111
- if (event) {
112
- event.preventDefault();
113
- }
114
- const { onChange, errorSchema } = this.props;
115
- const { keyedFormData } = this.state;
116
- let newErrorSchema;
117
- if (errorSchema) {
118
- newErrorSchema = {};
119
- for (const idx in errorSchema) {
120
- const i = parseInt(idx);
121
- if (i <= index) {
122
- set(newErrorSchema, [i], errorSchema[idx]);
123
- } else if (i > index) {
124
- set(newErrorSchema, [i + 1], errorSchema[idx]);
125
- }
126
- }
127
- }
128
- const newKeyedFormDataRow = {
129
- key: generateRowId(),
130
- item: cloneDeep(keyedFormData[index].item)
131
- };
132
- const newKeyedFormData = [...keyedFormData];
133
- if (index !== void 0) {
134
- newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
135
- } else {
136
- newKeyedFormData.push(newKeyedFormDataRow);
137
- }
138
- this.setState(
139
- {
140
- keyedFormData: newKeyedFormData,
141
- updatedKeyedFormData: true
142
- },
143
- () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
144
- );
145
- };
146
- };
147
- /** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
148
- * keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
149
- * from the keyed data
150
- *
151
- * @param index - The index at which the remove button is clicked
152
- */
153
- this.onDropIndexClick = (index) => {
154
- return (event) => {
155
- if (event) {
156
- event.preventDefault();
157
- }
158
- const { onChange, errorSchema } = this.props;
159
- const { keyedFormData } = this.state;
160
- let newErrorSchema;
161
- if (errorSchema) {
162
- newErrorSchema = {};
163
- for (const idx in errorSchema) {
164
- const i = parseInt(idx);
165
- if (i < index) {
166
- set(newErrorSchema, [i], errorSchema[idx]);
167
- } else if (i > index) {
168
- set(newErrorSchema, [i - 1], errorSchema[idx]);
169
- }
170
- }
171
- }
172
- const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
173
- this.setState(
174
- {
175
- keyedFormData: newKeyedFormData,
176
- updatedKeyedFormData: true
177
- },
178
- () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
179
- );
180
- };
181
- };
182
- /** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
183
- * row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
184
- * plain form data converted from the keyed data
185
- *
186
- * @param index - The index of the item to move
187
- * @param newIndex - The index to where the item is to be moved
188
- */
189
- this.onReorderClick = (index, newIndex) => {
190
- return (event) => {
191
- if (event) {
192
- event.preventDefault();
193
- event.currentTarget.blur();
194
- }
195
- const { onChange, errorSchema } = this.props;
196
- let newErrorSchema;
197
- if (errorSchema) {
198
- newErrorSchema = {};
199
- for (const idx in errorSchema) {
200
- const i = parseInt(idx);
201
- if (i == index) {
202
- set(newErrorSchema, [newIndex], errorSchema[index]);
203
- } else if (i == newIndex) {
204
- set(newErrorSchema, [index], errorSchema[newIndex]);
205
- } else {
206
- set(newErrorSchema, [idx], errorSchema[i]);
207
- }
208
- }
209
- }
210
- const { keyedFormData } = this.state;
211
- function reOrderArray() {
212
- const _newKeyedFormData = keyedFormData.slice();
213
- _newKeyedFormData.splice(index, 1);
214
- _newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
215
- return _newKeyedFormData;
216
- }
217
- const newKeyedFormData = reOrderArray();
218
- this.setState(
219
- {
220
- keyedFormData: newKeyedFormData
221
- },
222
- () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
223
- );
224
- };
225
- };
226
- /** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
227
- * `onChange` callback with the updated form data
228
- *
229
- * @param index - The index of the item being changed
230
- */
231
- this.onChangeForIndex = (index) => {
232
- return (value, newErrorSchema, id) => {
233
- const { formData, onChange, errorSchema } = this.props;
234
- const arrayData = Array.isArray(formData) ? formData : [];
235
- const newFormData = arrayData.map((item, i) => {
236
- const jsonValue = typeof value === "undefined" ? null : value;
237
- return index === i ? jsonValue : item;
238
- });
239
- onChange(
240
- newFormData,
241
- errorSchema && errorSchema && {
242
- ...errorSchema,
243
- [index]: newErrorSchema
244
- },
245
- id
246
- );
247
- };
248
- };
249
- /** Callback handler used to change the value for a checkbox */
250
- this.onSelectChange = (value) => {
251
- const { onChange, idSchema } = this.props;
252
- onChange(value, void 0, idSchema && idSchema.$id);
253
- };
254
75
  const { formData = [] } = props;
255
76
  const keyedFormData = generateKeyedFormData(formData);
256
77
  this.state = {
@@ -325,6 +146,18 @@ var ArrayField = class extends Component {
325
146
  }
326
147
  return addable;
327
148
  }
149
+ /** Returns the default form information for an item based on the schema for that item. Deals with the possibility
150
+ * that the schema is fixed and allows additional items.
151
+ */
152
+ _getNewFormDataRow = () => {
153
+ const { schema, registry } = this.props;
154
+ const { schemaUtils } = registry;
155
+ let itemSchema = schema.items;
156
+ if (isFixedItems(schema) && allowAdditionalItems(schema)) {
157
+ itemSchema = schema.additionalItems;
158
+ }
159
+ return schemaUtils.getDefaultFormState(itemSchema);
160
+ };
328
161
  /** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
329
162
  * either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
330
163
  * the state, and then returning `onChange()` with the plain form data converted from the keyed data
@@ -368,6 +201,177 @@ var ArrayField = class extends Component {
368
201
  () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
369
202
  );
370
203
  }
204
+ /** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
205
+ * the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
206
+ * keyed data
207
+ *
208
+ * @param event - The event for the click
209
+ */
210
+ onAddClick = (event) => {
211
+ this._handleAddClick(event);
212
+ };
213
+ /** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
214
+ * keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
215
+ * form data converted from the keyed data
216
+ *
217
+ * @param index - The index at which the add button is clicked
218
+ */
219
+ onAddIndexClick = (index) => {
220
+ return (event) => {
221
+ this._handleAddClick(event, index);
222
+ };
223
+ };
224
+ /** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
225
+ * keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
226
+ * form data converted from the keyed data
227
+ *
228
+ * @param index - The index at which the copy button is clicked
229
+ */
230
+ onCopyIndexClick = (index) => {
231
+ return (event) => {
232
+ if (event) {
233
+ event.preventDefault();
234
+ }
235
+ const { onChange, errorSchema } = this.props;
236
+ const { keyedFormData } = this.state;
237
+ let newErrorSchema;
238
+ if (errorSchema) {
239
+ newErrorSchema = {};
240
+ for (const idx in errorSchema) {
241
+ const i = parseInt(idx);
242
+ if (i <= index) {
243
+ set(newErrorSchema, [i], errorSchema[idx]);
244
+ } else if (i > index) {
245
+ set(newErrorSchema, [i + 1], errorSchema[idx]);
246
+ }
247
+ }
248
+ }
249
+ const newKeyedFormDataRow = {
250
+ key: generateRowId(),
251
+ item: cloneDeep(keyedFormData[index].item)
252
+ };
253
+ const newKeyedFormData = [...keyedFormData];
254
+ if (index !== void 0) {
255
+ newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
256
+ } else {
257
+ newKeyedFormData.push(newKeyedFormDataRow);
258
+ }
259
+ this.setState(
260
+ {
261
+ keyedFormData: newKeyedFormData,
262
+ updatedKeyedFormData: true
263
+ },
264
+ () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
265
+ );
266
+ };
267
+ };
268
+ /** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
269
+ * keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
270
+ * from the keyed data
271
+ *
272
+ * @param index - The index at which the remove button is clicked
273
+ */
274
+ onDropIndexClick = (index) => {
275
+ return (event) => {
276
+ if (event) {
277
+ event.preventDefault();
278
+ }
279
+ const { onChange, errorSchema } = this.props;
280
+ const { keyedFormData } = this.state;
281
+ let newErrorSchema;
282
+ if (errorSchema) {
283
+ newErrorSchema = {};
284
+ for (const idx in errorSchema) {
285
+ const i = parseInt(idx);
286
+ if (i < index) {
287
+ set(newErrorSchema, [i], errorSchema[idx]);
288
+ } else if (i > index) {
289
+ set(newErrorSchema, [i - 1], errorSchema[idx]);
290
+ }
291
+ }
292
+ }
293
+ const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
294
+ this.setState(
295
+ {
296
+ keyedFormData: newKeyedFormData,
297
+ updatedKeyedFormData: true
298
+ },
299
+ () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
300
+ );
301
+ };
302
+ };
303
+ /** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
304
+ * row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
305
+ * plain form data converted from the keyed data
306
+ *
307
+ * @param index - The index of the item to move
308
+ * @param newIndex - The index to where the item is to be moved
309
+ */
310
+ onReorderClick = (index, newIndex) => {
311
+ return (event) => {
312
+ if (event) {
313
+ event.preventDefault();
314
+ event.currentTarget.blur();
315
+ }
316
+ const { onChange, errorSchema } = this.props;
317
+ let newErrorSchema;
318
+ if (errorSchema) {
319
+ newErrorSchema = {};
320
+ for (const idx in errorSchema) {
321
+ const i = parseInt(idx);
322
+ if (i == index) {
323
+ set(newErrorSchema, [newIndex], errorSchema[index]);
324
+ } else if (i == newIndex) {
325
+ set(newErrorSchema, [index], errorSchema[newIndex]);
326
+ } else {
327
+ set(newErrorSchema, [idx], errorSchema[i]);
328
+ }
329
+ }
330
+ }
331
+ const { keyedFormData } = this.state;
332
+ function reOrderArray() {
333
+ const _newKeyedFormData = keyedFormData.slice();
334
+ _newKeyedFormData.splice(index, 1);
335
+ _newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
336
+ return _newKeyedFormData;
337
+ }
338
+ const newKeyedFormData = reOrderArray();
339
+ this.setState(
340
+ {
341
+ keyedFormData: newKeyedFormData
342
+ },
343
+ () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
344
+ );
345
+ };
346
+ };
347
+ /** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
348
+ * `onChange` callback with the updated form data
349
+ *
350
+ * @param index - The index of the item being changed
351
+ */
352
+ onChangeForIndex = (index) => {
353
+ return (value, newErrorSchema, id) => {
354
+ const { formData, onChange, errorSchema } = this.props;
355
+ const arrayData = Array.isArray(formData) ? formData : [];
356
+ const newFormData = arrayData.map((item, i) => {
357
+ const jsonValue = typeof value === "undefined" ? null : value;
358
+ return index === i ? jsonValue : item;
359
+ });
360
+ onChange(
361
+ newFormData,
362
+ errorSchema && errorSchema && {
363
+ ...errorSchema,
364
+ [index]: newErrorSchema
365
+ },
366
+ id
367
+ );
368
+ };
369
+ };
370
+ /** Callback handler used to change the value for a checkbox */
371
+ onSelectChange = (value) => {
372
+ const { onChange, idSchema } = this.props;
373
+ onChange(value, void 0, idSchema && idSchema.$id);
374
+ };
371
375
  /** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
372
376
  */
373
377
  render() {
@@ -462,7 +466,7 @@ var ArrayField = class extends Component {
462
466
  totalItems: keyedFormData.length
463
467
  });
464
468
  }),
465
- className: `field field-array field-array-of-${itemsSchema.type}`,
469
+ className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}`,
466
470
  disabled,
467
471
  idSchema,
468
472
  uiSchema,
@@ -670,7 +674,7 @@ var ArrayField = class extends Component {
670
674
  const canAdd = this.canAddItem(items) && !!additionalSchema;
671
675
  const arrayProps = {
672
676
  canAdd,
673
- className: "field field-array field-array-fixed-items",
677
+ className: "rjsf-field rjsf-field-array rjsf-field-array-fixed-items",
674
678
  disabled,
675
679
  idSchema,
676
680
  formData,
@@ -751,14 +755,14 @@ var ArrayField = class extends Component {
751
755
  } = registry;
752
756
  const ItemSchemaField = ArraySchemaField || SchemaField2;
753
757
  const { orderable = true, removable = true, copyable = false } = getUiOptions(uiSchema, globalUiOptions);
754
- const has2 = {
758
+ const has4 = {
755
759
  moveUp: orderable && canMoveUp,
756
760
  moveDown: orderable && canMoveDown,
757
761
  copy: copyable && canAdd,
758
762
  remove: removable && canRemove,
759
763
  toolbar: false
760
764
  };
761
- has2.toolbar = Object.keys(has2).some((key2) => has2[key2]);
765
+ has4.toolbar = Object.keys(has4).some((key2) => has4[key2]);
762
766
  return {
763
767
  children: /* @__PURE__ */ jsx(
764
768
  ItemSchemaField,
@@ -786,21 +790,31 @@ var ArrayField = class extends Component {
786
790
  rawErrors
787
791
  }
788
792
  ),
789
- className: "array-item",
793
+ buttonsProps: {
794
+ idSchema: itemIdSchema,
795
+ disabled,
796
+ readonly,
797
+ canAdd,
798
+ hasCopy: has4.copy,
799
+ hasMoveUp: has4.moveUp,
800
+ hasMoveDown: has4.moveDown,
801
+ hasRemove: has4.remove,
802
+ index,
803
+ totalItems,
804
+ onAddIndexClick: this.onAddIndexClick,
805
+ onCopyIndexClick: this.onCopyIndexClick,
806
+ onDropIndexClick: this.onDropIndexClick,
807
+ onReorderClick: this.onReorderClick,
808
+ registry,
809
+ schema: itemSchema,
810
+ uiSchema: itemUiSchema
811
+ },
812
+ className: "rjsf-array-item",
790
813
  disabled,
791
- canAdd,
792
- hasCopy: has2.copy,
793
- hasToolbar: has2.toolbar,
794
- hasMoveUp: has2.moveUp,
795
- hasMoveDown: has2.moveDown,
796
- hasRemove: has2.remove,
814
+ hasToolbar: has4.toolbar,
797
815
  index,
798
816
  totalItems,
799
817
  key,
800
- onAddIndexClick: this.onAddIndexClick,
801
- onCopyIndexClick: this.onCopyIndexClick,
802
- onDropIndexClick: this.onDropIndexClick,
803
- onReorderClick: this.onReorderClick,
804
818
  readonly,
805
819
  registry,
806
820
  schema: itemSchema,
@@ -845,6 +859,7 @@ function BooleanField(props) {
845
859
  title: uiTitle,
846
860
  // Unlike the other fields, don't use `getDisplayLabel()` since it always returns false for the boolean type
847
861
  label: displayLabel = true,
862
+ enumNames,
848
863
  ...options
849
864
  } = getUiOptions2(uiSchema, globalUiOptions);
850
865
  const Widget = getWidget2(schema, widget, widgets2);
@@ -869,9 +884,8 @@ function BooleanField(props) {
869
884
  uiSchema
870
885
  );
871
886
  } else {
872
- const schemaWithEnumNames = schema;
873
887
  const enums = schema.enum ?? [true, false];
874
- if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every((v) => typeof v === "boolean")) {
888
+ if (!enumNames && enums.length === 2 && enums.every((v) => typeof v === "boolean")) {
875
889
  enumOptions = [
876
890
  {
877
891
  value: enums[0],
@@ -883,14 +897,7 @@ function BooleanField(props) {
883
897
  }
884
898
  ];
885
899
  } else {
886
- enumOptions = optionsList2(
887
- {
888
- enum: enums,
889
- // NOTE: enumNames is deprecated, but still supported for now.
890
- enumNames: schemaWithEnumNames.enumNames
891
- },
892
- uiSchema
893
- );
900
+ enumOptions = optionsList2({ enum: enums }, uiSchema);
894
901
  }
895
902
  }
896
903
  return /* @__PURE__ */ jsx2(
@@ -920,184 +927,937 @@ function BooleanField(props) {
920
927
  }
921
928
  var BooleanField_default = BooleanField;
922
929
 
923
- // src/components/fields/MultiSchemaField.tsx
924
- import { Component as Component2 } from "react";
925
- import get2 from "lodash/get";
926
- import isEmpty from "lodash/isEmpty";
927
- import omit from "lodash/omit";
930
+ // src/components/fields/LayoutGridField.tsx
931
+ import { PureComponent } from "react";
928
932
  import {
929
933
  ANY_OF_KEY,
930
- deepEquals,
931
- ERRORS_KEY,
932
934
  getDiscriminatorFieldFromSchema,
935
+ getTemplate as getTemplate2,
936
+ getTestIds,
933
937
  getUiOptions as getUiOptions3,
934
- getWidget as getWidget3,
935
- mergeSchemas,
938
+ hashObject,
939
+ ID_KEY,
940
+ lookupFromFormContext,
941
+ mergeObjects,
936
942
  ONE_OF_KEY,
937
- TranslatableString as TranslatableString3
943
+ PROPERTIES_KEY,
944
+ READONLY_KEY,
945
+ UI_OPTIONS_KEY
938
946
  } from "@rjsf/utils";
939
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
940
- var AnyOfField = class extends Component2 {
941
- /** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
947
+ import cloneDeep2 from "lodash/cloneDeep";
948
+ import each from "lodash/each";
949
+ import flatten from "lodash/flatten";
950
+ import get2 from "lodash/get";
951
+ import has from "lodash/has";
952
+ import includes from "lodash/includes";
953
+ import intersection from "lodash/intersection";
954
+ import isEmpty from "lodash/isEmpty";
955
+ import isFunction from "lodash/isFunction";
956
+ import isEqual from "lodash/isEqual";
957
+ import isObject3 from "lodash/isObject";
958
+ import isPlainObject from "lodash/isPlainObject";
959
+ import isString from "lodash/isString";
960
+ import isUndefined from "lodash/isUndefined";
961
+ import set2 from "lodash/set";
962
+ import { jsx as jsx3 } from "react/jsx-runtime";
963
+ import { createElement } from "react";
964
+ var LOOKUP_REGEX = /^\$lookup=(.+)/;
965
+ var LAYOUT_GRID_UI_OPTION = "layoutGrid";
966
+ var LAYOUT_GRID_OPTION = `ui:${LAYOUT_GRID_UI_OPTION}`;
967
+ var UI_GLOBAL_OPTIONS = "ui:global_options";
968
+ function getNonNullishValue(value, fallback) {
969
+ return value ?? fallback;
970
+ }
971
+ var LayoutGridField = class _LayoutGridField extends PureComponent {
972
+ static defaultProps = {
973
+ layoutGridSchema: void 0
974
+ };
975
+ static TEST_IDS = getTestIds();
976
+ /** Computes the uiSchema for the field with `name` from the `uiProps` and `uiSchema` provided. The field UI Schema
977
+ * will always contain a copy of the global options from the `uiSchema` (so they can be passed down) as well as
978
+ * copying them into the local ui options. When the `forceReadonly` flag is true, then the field UI Schema is
979
+ * updated to make "readonly" be true. When the `schemaReadonly` flag is true AND the field UI Schema does NOT have
980
+ * the flag already provided, then we also make "readonly" true. We always make sure to return the final value of the
981
+ * field UI Schema's "readonly" flag as `uiReadonly` along with the `fieldUiSchema` in the return value.
942
982
  *
943
- * @param props - The `FieldProps` for this template
983
+ * @param field - The name of the field to pull the existing UI Schema for
984
+ * @param uiProps - Any props that should be put into the field's uiSchema
985
+ * @param [uiSchema] - The optional UI Schema from which to get the UI schema for the field
986
+ * @param [schemaReadonly] - Optional flag indicating whether the schema indicates the field is readonly
987
+ * @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode
944
988
  */
945
- constructor(props) {
946
- super(props);
947
- /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
948
- * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
949
- * the `onChange` handler.
950
- *
951
- * @param option - The new option value being selected
952
- */
953
- this.onOptionChange = (option) => {
954
- const { selectedOption, retrievedOptions } = this.state;
955
- const { formData, onChange, registry } = this.props;
956
- const { schemaUtils } = registry;
957
- const intOption = option !== void 0 ? parseInt(option, 10) : -1;
958
- if (intOption === selectedOption) {
959
- return;
960
- }
961
- const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
962
- const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
963
- let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
964
- if (newFormData && newOption) {
965
- newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
989
+ static computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
990
+ const globalUiOptions = get2(uiSchema, [UI_GLOBAL_OPTIONS], {});
991
+ const localUiSchema = get2(uiSchema, field);
992
+ const localUiOptions = { ...get2(localUiSchema, [UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
993
+ const fieldUiSchema = { ...localUiSchema };
994
+ if (!isEmpty(localUiOptions)) {
995
+ set2(fieldUiSchema, [UI_OPTIONS_KEY], localUiOptions);
996
+ }
997
+ if (!isEmpty(globalUiOptions)) {
998
+ set2(fieldUiSchema, [UI_GLOBAL_OPTIONS], globalUiOptions);
999
+ }
1000
+ let { readonly: uiReadonly } = getUiOptions3(fieldUiSchema);
1001
+ if (forceReadonly === true || isUndefined(uiReadonly) && schemaReadonly === true) {
1002
+ uiReadonly = true;
1003
+ if (has(localUiOptions, READONLY_KEY)) {
1004
+ set2(fieldUiSchema, [UI_OPTIONS_KEY, READONLY_KEY], true);
1005
+ } else {
1006
+ set2(fieldUiSchema, `ui:${READONLY_KEY}`, true);
966
1007
  }
967
- onChange(newFormData, void 0, this.getFieldId());
968
- this.setState({ selectedOption: intOption });
969
- };
970
- const {
971
- formData,
972
- options,
973
- registry: { schemaUtils }
974
- } = this.props;
975
- const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
976
- this.state = {
977
- retrievedOptions,
978
- selectedOption: this.getMatchingOption(0, formData, retrievedOptions)
979
- };
1008
+ }
1009
+ return { fieldUiSchema, uiReadonly };
980
1010
  }
981
- /** React lifecycle method that is called when the props and/or state for this component is updated. It recomputes the
982
- * currently selected option based on the overall `formData`
1011
+ /** Given an `operator`, `datum` and `value` determines whether this condition is considered matching. Matching
1012
+ * depends on the `operator`. The `datum` and `value` are converted into arrays if they aren't already and then the
1013
+ * contents of the two arrays are compared using the `operator`. When `operator` is All, then the two arrays must be
1014
+ * equal to match. When `operator` is SOME then the intersection of the two arrays must have at least one value in
1015
+ * common to match. When `operator` is NONE then the intersection of the two arrays must not have any values in common
1016
+ * to match.
983
1017
  *
984
- * @param prevProps - The previous `FieldProps` for this template
985
- * @param prevState - The previous `AnyOfFieldState` for this template
1018
+ * @param [operator] - The optional operator for the condition
1019
+ * @param [datum] - The optional datum for the condition, this can be an item or a list of items of type unknown
1020
+ * @param [value='$0m3tH1nG Un3xP3cT3d'] The optional value for the condition, defaulting to a highly unlikely value
1021
+ * to avoid comparing two undefined elements when `value` was forgotten in the condition definition.
1022
+ * This can be an item or a list of items of type unknown
1023
+ * @returns - True if the condition matches, false otherwise
986
1024
  */
987
- componentDidUpdate(prevProps, prevState) {
988
- const { formData, options, idSchema } = this.props;
989
- const { selectedOption } = this.state;
990
- let newState = this.state;
991
- if (!deepEquals(prevProps.options, options)) {
992
- const {
993
- registry: { schemaUtils }
994
- } = this.props;
995
- const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
996
- newState = { selectedOption, retrievedOptions };
1025
+ static conditionMatches(operator, datum, value = "$0m3tH1nG Un3xP3cT3d") {
1026
+ const data = flatten([datum]).sort();
1027
+ const values = flatten([value]).sort();
1028
+ switch (operator) {
1029
+ case "all" /* ALL */:
1030
+ return isEqual(data, values);
1031
+ case "some" /* SOME */:
1032
+ return intersection(data, values).length > 0;
1033
+ case "none" /* NONE */:
1034
+ return intersection(data, values).length === 0;
1035
+ default:
1036
+ return false;
997
1037
  }
998
- if (!deepEquals(formData, prevProps.formData) && idSchema.$id === prevProps.idSchema.$id) {
999
- const { retrievedOptions } = newState;
1000
- const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
1001
- if (prevState && matchingOption !== selectedOption) {
1002
- newState = { selectedOption: matchingOption, retrievedOptions };
1038
+ }
1039
+ /** From within the `layoutGridSchema` finds the `children` and any extra `gridProps` from the object keyed by
1040
+ * `schemaKey`. If the `children` contains extra `gridProps` and those props contain a `className` string, try to
1041
+ * lookup whether that `className` has a replacement value in the `registry` using the `FORM_CONTEXT_LOOKUP_BASE`.
1042
+ * When the `className` value contains multiple classNames separated by a space, the lookup will look for a
1043
+ * replacement value for each `className` and combine them into one.
1044
+ *
1045
+ * @param layoutGridSchema - The GridSchemaType instance from which to obtain the `schemaKey` children and extra props
1046
+ * @param schemaKey - A `GridType` value, used to get the children and extra props from within the `layoutGridSchema`
1047
+ * @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
1048
+ * @returns - An object containing the list of `LayoutGridSchemaType` `children` and any extra `gridProps`
1049
+ * @throws - A `TypeError` when the `children` is not an array
1050
+ */
1051
+ static findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
1052
+ let gridProps = {};
1053
+ let children = layoutGridSchema[schemaKey];
1054
+ if (isPlainObject(children)) {
1055
+ const { children: elements, className: toMapClassNames, ...otherProps } = children;
1056
+ children = elements;
1057
+ if (toMapClassNames) {
1058
+ const classes = toMapClassNames.split(" ");
1059
+ const className = classes.map((ele) => lookupFromFormContext(registry, ele, ele)).join(" ");
1060
+ gridProps = { ...otherProps, className };
1061
+ } else {
1062
+ gridProps = otherProps;
1003
1063
  }
1004
1064
  }
1005
- if (newState !== this.state) {
1006
- this.setState(newState);
1065
+ if (!Array.isArray(children)) {
1066
+ throw new TypeError(`Expected array for "${schemaKey}" in ${JSON.stringify(layoutGridSchema)}`);
1007
1067
  }
1068
+ return { children, gridProps };
1008
1069
  }
1009
- /** Determines the best matching option for the given `formData` and `options`.
1070
+ /** Generates an idSchema for the `schema` using `@rjsf`'s `toIdSchema` util, passing the `baseIdSchema`'s `$id` value
1071
+ * as the id prefix.
1010
1072
  *
1011
- * @param formData - The new formData
1012
- * @param options - The list of options to choose from
1013
- * @return - The index of the `option` that best matches the `formData`
1073
+ * @param schemaUtils - The `SchemaUtilsType` used to call `toIdSchema`
1074
+ * @param schema - The schema to generate the idSchema for
1075
+ * @param baseIdSchema - The IdSchema for the base
1076
+ * @param formData - The formData to pass the `toIdSchema`
1077
+ * @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
1078
+ * @returns - The generated `idSchema` for the `schema`
1014
1079
  */
1015
- getMatchingOption(selectedOption, formData, options) {
1016
- const {
1017
- schema,
1018
- registry: { schemaUtils }
1019
- } = this.props;
1020
- const discriminator = getDiscriminatorFieldFromSchema(schema);
1021
- const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
1022
- return option;
1023
- }
1024
- getFieldId() {
1025
- const { idSchema, schema } = this.props;
1026
- return `${idSchema.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
1080
+ static getIdSchema(schemaUtils, baseIdSchema, formData, schema = {}, idSeparator) {
1081
+ const baseId = get2(baseIdSchema, ID_KEY);
1082
+ return schemaUtils.toIdSchema(schema, baseId, formData, baseId, idSeparator);
1027
1083
  }
1028
- /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
1084
+ /** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
1085
+ * the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
1086
+ * element in the path. If the leaf schema element happens to be a oneOf/anyOf then also return the oneOf/anyOf as
1087
+ * `options`.
1088
+ *
1089
+ * @param schemaUtils - The `SchemaUtilsType` used to call `retrieveSchema`
1090
+ * @param dottedPath - The dotted-path to the field for which to get the schema
1091
+ * @param initialSchema - The initial schema to start the search from
1092
+ * @param formData - The formData, useful for resolving a oneOf/anyOf selection in the path hierarchy
1093
+ * @param initialIdSchema - The initial idSchema to start the search from
1094
+ * @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
1095
+ * @returns - An object containing the destination schema, isRequired and isReadonly flags for the field and options
1096
+ * info if a oneOf/anyOf
1029
1097
  */
1030
- render() {
1031
- const {
1032
- name,
1033
- disabled = false,
1034
- errorSchema = {},
1035
- formContext,
1036
- onBlur,
1037
- onFocus,
1038
- registry,
1039
- schema,
1040
- uiSchema
1041
- } = this.props;
1042
- const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
1043
- const { SchemaField: _SchemaField } = fields2;
1044
- const { selectedOption, retrievedOptions } = this.state;
1045
- const {
1046
- widget = "select",
1047
- placeholder,
1048
- autofocus,
1049
- autocomplete,
1050
- title = schema.title,
1051
- ...uiOptions
1052
- } = getUiOptions3(uiSchema, globalUiOptions);
1053
- const Widget = getWidget3({ type: "number" }, widget, widgets2);
1054
- const rawErrors = get2(errorSchema, ERRORS_KEY, []);
1055
- const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
1056
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1057
- const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1058
- let optionSchema;
1059
- if (option) {
1060
- const { required } = schema;
1061
- optionSchema = required ? mergeSchemas({ required }, option) : option;
1062
- }
1063
- let optionsUiSchema = [];
1064
- if (ONE_OF_KEY in schema && uiSchema && ONE_OF_KEY in uiSchema) {
1065
- if (Array.isArray(uiSchema[ONE_OF_KEY])) {
1066
- optionsUiSchema = uiSchema[ONE_OF_KEY];
1098
+ static getSchemaDetailsForField(schemaUtils, dottedPath, initialSchema, formData, initialIdSchema, idSeparator) {
1099
+ let rawSchema = initialSchema;
1100
+ let idSchema = initialIdSchema;
1101
+ const parts = dottedPath.split(".");
1102
+ const leafPath = parts.pop();
1103
+ let schema = schemaUtils.retrieveSchema(rawSchema, formData);
1104
+ let innerData = formData;
1105
+ let isReadonly = schema.readOnly;
1106
+ parts.forEach((part) => {
1107
+ if (has(schema, PROPERTIES_KEY)) {
1108
+ rawSchema = get2(schema, [PROPERTIES_KEY, part], {});
1109
+ idSchema = get2(idSchema, part, {});
1110
+ } else if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
1111
+ const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
1112
+ const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
1113
+ const selectedIdSchema = _LayoutGridField.getIdSchema(
1114
+ schemaUtils,
1115
+ idSchema,
1116
+ formData,
1117
+ selectedSchema,
1118
+ idSeparator
1119
+ );
1120
+ rawSchema = get2(selectedSchema, [PROPERTIES_KEY, part], {});
1121
+ idSchema = get2(selectedIdSchema, part, {});
1067
1122
  } else {
1068
- console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
1123
+ rawSchema = {};
1069
1124
  }
1070
- } else if (ANY_OF_KEY in schema && uiSchema && ANY_OF_KEY in uiSchema) {
1071
- if (Array.isArray(uiSchema[ANY_OF_KEY])) {
1072
- optionsUiSchema = uiSchema[ANY_OF_KEY];
1073
- } else {
1074
- console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
1125
+ innerData = get2(innerData, part, {});
1126
+ schema = schemaUtils.retrieveSchema(rawSchema, innerData);
1127
+ isReadonly = getNonNullishValue(schema.readOnly, isReadonly);
1128
+ });
1129
+ let optionsInfo;
1130
+ let isRequired = false;
1131
+ if (isEmpty(schema)) {
1132
+ schema = void 0;
1133
+ }
1134
+ if (schema && leafPath) {
1135
+ if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
1136
+ const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
1137
+ schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
1138
+ const rawIdSchema = _LayoutGridField.getIdSchema(schemaUtils, idSchema, formData, schema, idSeparator);
1139
+ idSchema = mergeObjects(rawIdSchema, idSchema);
1140
+ }
1141
+ isRequired = schema !== void 0 && Array.isArray(schema.required) && includes(schema.required, leafPath);
1142
+ schema = get2(schema, [PROPERTIES_KEY, leafPath]);
1143
+ schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
1144
+ idSchema = get2(idSchema, leafPath, {});
1145
+ isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
1146
+ if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
1147
+ const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
1148
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
1149
+ optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
1075
1150
  }
1076
1151
  }
1077
- let optionUiSchema = uiSchema;
1078
- if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
1079
- optionUiSchema = optionsUiSchema[selectedOption];
1152
+ return { schema, isRequired, isReadonly, optionsInfo, idSchema };
1153
+ }
1154
+ /** Gets the custom render component from the `render`, by either determining that it is either already a function or
1155
+ * it is a non-function value that can be used to look up the function in the registry. If no function can be found,
1156
+ * null is returned.
1157
+ *
1158
+ * @param render - The potential render function or lookup name to one
1159
+ * @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
1160
+ * @returns - Either a render function if available, or null if not
1161
+ */
1162
+ static getCustomRenderComponent(render, registry) {
1163
+ let customRenderer = render;
1164
+ if (isString(customRenderer)) {
1165
+ customRenderer = lookupFromFormContext(registry, customRenderer);
1080
1166
  }
1081
- const translateEnum = title ? TranslatableString3.TitleOptionPrefix : TranslatableString3.OptionPrefix;
1082
- const translateParams = title ? [title] : [];
1083
- const enumOptions = retrievedOptions.map((opt, index) => {
1084
- const { title: uiTitle = opt.title } = getUiOptions3(optionsUiSchema[index]);
1085
- return {
1086
- label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
1087
- value: index
1088
- };
1089
- });
1090
- return /* @__PURE__ */ jsxs("div", { className: "panel panel-default panel-body", children: [
1091
- /* @__PURE__ */ jsx3("div", { className: "form-group", children: /* @__PURE__ */ jsx3(
1092
- Widget,
1093
- {
1167
+ if (isFunction(customRenderer)) {
1168
+ return customRenderer;
1169
+ }
1170
+ return null;
1171
+ }
1172
+ /** Extract the `name`, and optional `render` and all other props from the `gridSchema`. We look up the `render` to
1173
+ * see if can be resolved to a UIComponent. If `name` does not exist and there is an optional `render` UIComponent, we
1174
+ * set the `rendered` component with only specified props for that component in the object.
1175
+ *
1176
+ * @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
1177
+ * @param gridSchema - The string or object that represents the configuration for the grid field
1178
+ * @returns - The UIComponentPropsType computed from the gridSchema
1179
+ */
1180
+ static computeUIComponentPropsFromGridSchema(registry, gridSchema) {
1181
+ let name;
1182
+ let UIComponent = null;
1183
+ let uiProps = {};
1184
+ let rendered;
1185
+ if (isString(gridSchema) || isUndefined(gridSchema)) {
1186
+ name = gridSchema ?? "";
1187
+ } else {
1188
+ const { name: innerName, render, ...innerProps } = gridSchema;
1189
+ name = innerName;
1190
+ uiProps = innerProps;
1191
+ if (!isEmpty(uiProps)) {
1192
+ each(uiProps, (prop, key) => {
1193
+ if (isString(prop)) {
1194
+ const match = LOOKUP_REGEX.exec(prop);
1195
+ if (Array.isArray(match) && match.length > 1) {
1196
+ const name2 = match[1];
1197
+ uiProps[key] = lookupFromFormContext(registry, name2, name2);
1198
+ }
1199
+ }
1200
+ });
1201
+ }
1202
+ UIComponent = _LayoutGridField.getCustomRenderComponent(render, registry);
1203
+ if (!innerName && UIComponent) {
1204
+ rendered = /* @__PURE__ */ jsx3(UIComponent, { ...innerProps, "data-testid": _LayoutGridField.TEST_IDS.uiComponent });
1205
+ }
1206
+ }
1207
+ return { name, UIComponent, uiProps, rendered };
1208
+ }
1209
+ /** Constructs an `LayoutGridField` with the given `props`
1210
+ *
1211
+ * @param props - The `LayoutGridField` for this template
1212
+ */
1213
+ constructor(props) {
1214
+ super(props);
1215
+ }
1216
+ /** Generates an `onChange` handler for the field associated with the `dottedPath`. This handler will clone and update
1217
+ * the `formData` with the new `value` and the `errorSchema` if an `errSchema` is provided. After updating those two
1218
+ * elements, they will then be passed on to the `onChange` handler of the `LayoutFieldGrid`.
1219
+ *
1220
+ * @param dottedPath - The dotted-path to the field for which to generate the onChange handler
1221
+ * @returns - The `onChange` handling function for the `dottedPath` field
1222
+ */
1223
+ onFieldChange = (dottedPath) => {
1224
+ return (value, errSchema, id) => {
1225
+ const { onChange, errorSchema, formData } = this.props;
1226
+ const newFormData = cloneDeep2(formData || {});
1227
+ let newErrorSchema = errorSchema;
1228
+ if (errSchema && errorSchema) {
1229
+ newErrorSchema = cloneDeep2(errorSchema);
1230
+ set2(newErrorSchema, dottedPath, errSchema);
1231
+ }
1232
+ set2(newFormData, dottedPath, value);
1233
+ onChange(newFormData, newErrorSchema, id);
1234
+ };
1235
+ };
1236
+ /** Renders the `children` of the `GridType.CONDITION` if it passes. The `layoutGridSchema` for the
1237
+ * `GridType.CONDITION` is separated into the `children` and other `gridProps`. The `gridProps` are used to extract
1238
+ * the `operator`, `field` and `value` of the condition. If the condition matches, then all of the `children` are
1239
+ * rendered, otherwise null is returned.
1240
+ *
1241
+ * @param layoutGridSchema - The string or object that represents the configuration for the grid field
1242
+ * @returns - The rendered the children for the `GridType.CONDITION` or null
1243
+ */
1244
+ renderCondition(layoutGridSchema) {
1245
+ const { formData, registry } = this.props;
1246
+ const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
1247
+ layoutGridSchema,
1248
+ "ui:condition" /* CONDITION */,
1249
+ registry
1250
+ );
1251
+ const { operator, field = "", value } = gridProps;
1252
+ const fieldData = get2(formData, field, null);
1253
+ if (_LayoutGridField.conditionMatches(operator, fieldData, value)) {
1254
+ return this.renderChildren(children);
1255
+ }
1256
+ return null;
1257
+ }
1258
+ /** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMN` is separated
1259
+ * into the `children` and other `gridProps`. The `gridProps` will be spread onto the outer `GridTemplate`. Inside
1260
+ * the `GridTemplate` all the `children` are rendered.
1261
+ *
1262
+ * @param layoutGridSchema - The string or object that represents the configuration for the grid field
1263
+ * @returns - The rendered `GridTemplate` containing the children for the `GridType.COLUMN`
1264
+ */
1265
+ renderCol(layoutGridSchema) {
1266
+ const { registry, uiSchema } = this.props;
1267
+ const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
1268
+ layoutGridSchema,
1269
+ "ui:col" /* COLUMN */,
1270
+ registry
1271
+ );
1272
+ const uiOptions = getUiOptions3(uiSchema);
1273
+ const GridTemplate2 = getTemplate2("GridTemplate", registry, uiOptions);
1274
+ return /* @__PURE__ */ jsx3(GridTemplate2, { column: true, "data-testid": _LayoutGridField.TEST_IDS.col, ...gridProps, children: this.renderChildren(children) });
1275
+ }
1276
+ /** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMNS` is separated
1277
+ * into the `children` and other `gridProps`. The `children` is iterated on and `gridProps` will be spread onto the
1278
+ * outer `GridTemplate`. Each child will have their own rendered `GridTemplate`.
1279
+ *
1280
+ * @param layoutGridSchema - The string or object that represents the configuration for the grid field
1281
+ * @returns - The rendered `GridTemplate` containing the children for the `GridType.COLUMNS`
1282
+ */
1283
+ renderColumns(layoutGridSchema) {
1284
+ const { registry, uiSchema } = this.props;
1285
+ const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
1286
+ layoutGridSchema,
1287
+ "ui:columns" /* COLUMNS */,
1288
+ registry
1289
+ );
1290
+ const uiOptions = getUiOptions3(uiSchema);
1291
+ const GridTemplate2 = getTemplate2("GridTemplate", registry, uiOptions);
1292
+ return children.map((child) => /* @__PURE__ */ jsx3(
1293
+ GridTemplate2,
1294
+ {
1295
+ column: true,
1296
+ "data-testid": _LayoutGridField.TEST_IDS.col,
1297
+ ...gridProps,
1298
+ children: this.renderChildren([child])
1299
+ },
1300
+ `column-${hashObject(child)}`
1301
+ ));
1302
+ }
1303
+ /** Renders a material-ui `GridTemplate` as a container. The
1304
+ * `layoutGridSchema` for the `GridType.ROW` is separated into the `children` and other `gridProps`. The `gridProps`
1305
+ * will be spread onto the outer `GridTemplate`. Inside of the `GridTemplate` all of the `children` are rendered.
1306
+ *
1307
+ * @param layoutGridSchema - The string or object that represents the configuration for the grid field
1308
+ * @returns - The rendered `GridTemplate` containing the children for the `GridType.ROW`
1309
+ */
1310
+ renderRow(layoutGridSchema) {
1311
+ const { registry, uiSchema } = this.props;
1312
+ const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
1313
+ layoutGridSchema,
1314
+ "ui:row" /* ROW */,
1315
+ registry
1316
+ );
1317
+ const uiOptions = getUiOptions3(uiSchema);
1318
+ const GridTemplate2 = getTemplate2("GridTemplate", registry, uiOptions);
1319
+ return /* @__PURE__ */ jsx3(GridTemplate2, { ...gridProps, "data-testid": _LayoutGridField.TEST_IDS.row, children: this.renderChildren(children) });
1320
+ }
1321
+ /** Iterates through all the `childrenLayoutGridSchema`, rendering a nested `LayoutGridField` for each item in the
1322
+ * list, passing all the props for the current `LayoutGridField` along, updating the `schema` by calling
1323
+ * `retrieveSchema()` on it to resolve any `$ref`s. In addition to the updated `schema`, each item in
1324
+ * `childrenLayoutGridSchema` is passed as `layoutGridSchema`.
1325
+ *
1326
+ * @param childrenLayoutGridSchema - The list of strings or objects that represents the configurations for the
1327
+ * children fields
1328
+ * @returns - The nested `LayoutGridField`s
1329
+ */
1330
+ renderChildren(childrenLayoutGridSchema) {
1331
+ const { registry, schema: rawSchema, formData } = this.props;
1332
+ const { schemaUtils } = registry;
1333
+ const schema = schemaUtils.retrieveSchema(rawSchema, formData);
1334
+ return childrenLayoutGridSchema.map((layoutGridSchema) => /* @__PURE__ */ createElement(
1335
+ _LayoutGridField,
1336
+ {
1337
+ ...this.props,
1338
+ key: `layoutGrid-${hashObject(layoutGridSchema)}`,
1339
+ schema,
1340
+ layoutGridSchema
1341
+ }
1342
+ ));
1343
+ }
1344
+ /** Renders the field described by `gridSchema`. If `gridSchema` is not an object, then is will be assumed
1345
+ * to be the dotted-path to the field in the schema. Otherwise, we extract the `name`, and optional `render` and all
1346
+ * other props. If `name` does not exist and there is an optional `render`, we return the `render` component with only
1347
+ * specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
1348
+ * and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
1349
+ * schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
1350
+ * `uiSchema`, `errorSchema`, `idSchema` and `formData` drilled down to the dotted-path field, spreading any other
1351
+ * props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
1352
+ * then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
1353
+ * schema was located, but a custom render component was found, then it will be rendered with many of the non-event
1354
+ * handling props. If none of the previous render paths are valid, then a null is returned.
1355
+ *
1356
+ * @param gridSchema - The string or object that represents the configuration for the grid field
1357
+ * @returns - One of `LayoutMultiSchemaField`, `SchemaField`, a custom render component or null, depending
1358
+ */
1359
+ renderField(gridSchema) {
1360
+ const {
1361
+ schema: initialSchema,
1362
+ uiSchema,
1363
+ errorSchema,
1364
+ idSchema,
1365
+ onBlur,
1366
+ onFocus,
1367
+ formData,
1368
+ readonly,
1369
+ registry,
1370
+ idSeparator,
1371
+ layoutGridSchema,
1372
+ // Used to pull this out of otherProps since we don't want to pass it through
1373
+ ...otherProps
1374
+ } = this.props;
1375
+ const { fields: fields2, schemaUtils } = registry;
1376
+ const { SchemaField: SchemaField2, LayoutMultiSchemaField: LayoutMultiSchemaField2 } = fields2;
1377
+ const uiComponentProps = _LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema);
1378
+ if (uiComponentProps.rendered) {
1379
+ return uiComponentProps.rendered;
1380
+ }
1381
+ const { name, UIComponent, uiProps } = uiComponentProps;
1382
+ const {
1383
+ schema,
1384
+ isRequired,
1385
+ isReadonly,
1386
+ optionsInfo,
1387
+ idSchema: fieldIdSchema
1388
+ } = _LayoutGridField.getSchemaDetailsForField(
1389
+ schemaUtils,
1390
+ name,
1391
+ initialSchema,
1392
+ formData,
1393
+ idSchema,
1394
+ idSeparator
1395
+ );
1396
+ if (schema) {
1397
+ const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
1398
+ const { fieldUiSchema, uiReadonly } = _LayoutGridField.computeFieldUiSchema(
1399
+ name,
1400
+ uiProps,
1401
+ uiSchema,
1402
+ isReadonly,
1403
+ readonly
1404
+ );
1405
+ return /* @__PURE__ */ jsx3(
1406
+ Field,
1407
+ {
1408
+ "data-testid": optionsInfo?.hasDiscriminator ? _LayoutGridField.TEST_IDS.layoutMultiSchemaField : _LayoutGridField.TEST_IDS.field,
1409
+ ...otherProps,
1410
+ name,
1411
+ required: isRequired,
1412
+ readonly: uiReadonly,
1413
+ schema,
1414
+ uiSchema: fieldUiSchema,
1415
+ errorSchema: get2(errorSchema, name),
1416
+ idSchema: fieldIdSchema,
1417
+ idSeparator,
1418
+ formData: get2(formData, name),
1419
+ onChange: this.onFieldChange(name),
1420
+ onBlur,
1421
+ onFocus,
1422
+ options: optionsInfo?.options,
1423
+ registry
1424
+ }
1425
+ );
1426
+ }
1427
+ if (UIComponent) {
1428
+ return /* @__PURE__ */ jsx3(
1429
+ UIComponent,
1430
+ {
1431
+ "data-testid": _LayoutGridField.TEST_IDS.uiComponent,
1432
+ ...otherProps,
1433
+ name,
1434
+ required: isRequired,
1435
+ formData,
1436
+ readOnly: !!isReadonly || readonly,
1437
+ errorSchema,
1438
+ uiSchema,
1439
+ schema: initialSchema,
1440
+ idSchema,
1441
+ idSeparator,
1442
+ onBlur,
1443
+ onFocus,
1444
+ registry,
1445
+ ...uiProps
1446
+ }
1447
+ );
1448
+ }
1449
+ return null;
1450
+ }
1451
+ /** Renders the `LayoutGridField`. If there isn't a `layoutGridSchema` prop defined, then try pulling it out of the
1452
+ * `uiSchema` via `ui:LayoutGridField`. If `layoutGridSchema` is an object, then check to see if any of the properties
1453
+ * match one of the `GridType`s. If so, call the appropriate render function for the type. Otherwise, just call the
1454
+ * generic `renderField()` function with the `layoutGridSchema`.
1455
+ *
1456
+ * @returns - the rendered `LayoutGridField`
1457
+ */
1458
+ render() {
1459
+ const { uiSchema } = this.props;
1460
+ let { layoutGridSchema } = this.props;
1461
+ const uiOptions = getUiOptions3(uiSchema);
1462
+ if (!layoutGridSchema && LAYOUT_GRID_UI_OPTION in uiOptions && isObject3(uiOptions[LAYOUT_GRID_UI_OPTION])) {
1463
+ layoutGridSchema = uiOptions[LAYOUT_GRID_UI_OPTION];
1464
+ }
1465
+ if (isObject3(layoutGridSchema)) {
1466
+ if ("ui:row" /* ROW */ in layoutGridSchema) {
1467
+ return this.renderRow(layoutGridSchema);
1468
+ }
1469
+ if ("ui:col" /* COLUMN */ in layoutGridSchema) {
1470
+ return this.renderCol(layoutGridSchema);
1471
+ }
1472
+ if ("ui:columns" /* COLUMNS */ in layoutGridSchema) {
1473
+ return this.renderColumns(layoutGridSchema);
1474
+ }
1475
+ if ("ui:condition" /* CONDITION */ in layoutGridSchema) {
1476
+ return this.renderCondition(layoutGridSchema);
1477
+ }
1478
+ }
1479
+ return this.renderField(layoutGridSchema);
1480
+ }
1481
+ };
1482
+
1483
+ // src/components/fields/LayoutHeaderField.tsx
1484
+ import {
1485
+ getTemplate as getTemplate3,
1486
+ getUiOptions as getUiOptions4,
1487
+ titleId
1488
+ } from "@rjsf/utils";
1489
+ import { jsx as jsx4 } from "react/jsx-runtime";
1490
+ function LayoutHeaderField(props) {
1491
+ const { idSchema, title, schema, uiSchema, required, registry, name } = props;
1492
+ const options = getUiOptions4(uiSchema, registry.globalUiOptions);
1493
+ const { title: uiTitle } = options;
1494
+ const { title: schemaTitle } = schema;
1495
+ const fieldTitle = uiTitle || title || schemaTitle || name;
1496
+ if (!fieldTitle) {
1497
+ return null;
1498
+ }
1499
+ const TitleFieldTemplate = getTemplate3(
1500
+ "TitleFieldTemplate",
1501
+ registry,
1502
+ options
1503
+ );
1504
+ return /* @__PURE__ */ jsx4(
1505
+ TitleFieldTemplate,
1506
+ {
1507
+ id: titleId(idSchema),
1508
+ title: fieldTitle,
1509
+ required,
1510
+ schema,
1511
+ uiSchema,
1512
+ registry
1513
+ }
1514
+ );
1515
+ }
1516
+
1517
+ // src/components/fields/LayoutMultiSchemaField.tsx
1518
+ import { useState, useEffect } from "react";
1519
+ import {
1520
+ ANY_OF_KEY as ANY_OF_KEY2,
1521
+ CONST_KEY,
1522
+ DEFAULT_KEY,
1523
+ ERRORS_KEY,
1524
+ getDiscriminatorFieldFromSchema as getDiscriminatorFieldFromSchema2,
1525
+ hashObject as hashObject2,
1526
+ ID_KEY as ID_KEY2,
1527
+ ONE_OF_KEY as ONE_OF_KEY2,
1528
+ optionsList as optionsList3,
1529
+ PROPERTIES_KEY as PROPERTIES_KEY2,
1530
+ getTemplate as getTemplate4,
1531
+ getUiOptions as getUiOptions5,
1532
+ getWidget as getWidget3
1533
+ } from "@rjsf/utils";
1534
+ import get3 from "lodash/get";
1535
+ import has2 from "lodash/has";
1536
+ import isEmpty2 from "lodash/isEmpty";
1537
+ import noop from "lodash/noop";
1538
+ import omit from "lodash/omit";
1539
+ import set3 from "lodash/set";
1540
+ import { jsx as jsx5 } from "react/jsx-runtime";
1541
+ function getSelectedOption(options, selectorField, value) {
1542
+ const defaultValue = "!@#!@$@#$!@$#";
1543
+ const schemaOptions = options.map(({ schema }) => schema);
1544
+ return schemaOptions.find((option) => {
1545
+ const selector = get3(option, [PROPERTIES_KEY2, selectorField]);
1546
+ const result = get3(selector, DEFAULT_KEY, get3(selector, CONST_KEY, defaultValue));
1547
+ return result === value;
1548
+ });
1549
+ }
1550
+ function computeEnumOptions(schema, options, schemaUtils, uiSchema, formData) {
1551
+ const realOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
1552
+ let tempSchema = schema;
1553
+ if (has2(schema, ONE_OF_KEY2)) {
1554
+ tempSchema = { ...schema, [ONE_OF_KEY2]: realOptions };
1555
+ } else if (has2(schema, ANY_OF_KEY2)) {
1556
+ tempSchema = { ...schema, [ANY_OF_KEY2]: realOptions };
1557
+ }
1558
+ const enumOptions = optionsList3(tempSchema, uiSchema);
1559
+ if (!enumOptions) {
1560
+ throw new Error(`No enumOptions were computed from the schema ${JSON.stringify(tempSchema)}`);
1561
+ }
1562
+ return enumOptions;
1563
+ }
1564
+ function LayoutMultiSchemaField(props) {
1565
+ const {
1566
+ name,
1567
+ baseType,
1568
+ disabled = false,
1569
+ formData,
1570
+ idSchema,
1571
+ onBlur,
1572
+ onChange,
1573
+ options,
1574
+ onFocus,
1575
+ registry,
1576
+ uiSchema,
1577
+ schema,
1578
+ formContext,
1579
+ autofocus,
1580
+ readonly,
1581
+ required,
1582
+ errorSchema,
1583
+ hideError = false
1584
+ } = props;
1585
+ const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
1586
+ const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
1587
+ const id = get3(idSchema, ID_KEY2);
1588
+ const discriminator = getDiscriminatorFieldFromSchema2(schema);
1589
+ const FieldErrorTemplate2 = getTemplate4("FieldErrorTemplate", registry, options);
1590
+ const FieldTemplate2 = getTemplate4("FieldTemplate", registry, options);
1591
+ const schemaHash = hashObject2(schema);
1592
+ const optionsHash = hashObject2(options);
1593
+ const uiSchemaHash = uiSchema ? hashObject2(uiSchema) : "";
1594
+ const formDataHash = formData ? hashObject2(formData) : "";
1595
+ useEffect(() => {
1596
+ setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
1597
+ }, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
1598
+ const {
1599
+ widget = discriminator ? "radio" : "select",
1600
+ title = "",
1601
+ placeholder = "",
1602
+ optionsSchemaSelector: selectorField = discriminator,
1603
+ hideError: uiSchemaHideError,
1604
+ ...uiOptions
1605
+ } = getUiOptions5(uiSchema);
1606
+ if (!selectorField) {
1607
+ throw new Error("No selector field provided for the LayoutMultiSchemaField");
1608
+ }
1609
+ const selectedOption = get3(formData, selectorField);
1610
+ let optionSchema = get3(enumOptions[0]?.schema, [PROPERTIES_KEY2, selectorField], {});
1611
+ const option = getSelectedOption(enumOptions, selectorField, selectedOption);
1612
+ optionSchema = optionSchema?.type ? optionSchema : { ...optionSchema, type: option?.type || baseType };
1613
+ const Widget = getWidget3(optionSchema, widget, widgets2);
1614
+ const hideFieldError = uiSchemaHideError === void 0 ? hideError : Boolean(uiSchemaHideError);
1615
+ const rawErrors = get3(errorSchema, [ERRORS_KEY], []);
1616
+ const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
1617
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1618
+ const onOptionChange = (opt) => {
1619
+ const newOption = getSelectedOption(enumOptions, selectorField, opt);
1620
+ const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
1621
+ let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
1622
+ if (newFormData && newOption) {
1623
+ newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
1624
+ }
1625
+ if (newFormData) {
1626
+ set3(newFormData, selectorField, opt);
1627
+ }
1628
+ onChange(newFormData, void 0, id);
1629
+ };
1630
+ const widgetOptions = { enumOptions, ...uiOptions };
1631
+ const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ jsx5(FieldErrorTemplate2, { idSchema, schema, errors: rawErrors, registry }) : void 0;
1632
+ const ignored = (value) => noop;
1633
+ return /* @__PURE__ */ jsx5(
1634
+ FieldTemplate2,
1635
+ {
1636
+ id,
1637
+ schema,
1638
+ label: (title || schema.title) ?? "",
1639
+ disabled: disabled || Array.isArray(enumOptions) && isEmpty2(enumOptions),
1640
+ uiSchema,
1641
+ formContext,
1642
+ required,
1643
+ readonly: !!readonly,
1644
+ registry,
1645
+ displayLabel,
1646
+ errors,
1647
+ onChange,
1648
+ onDropPropertyClick: ignored,
1649
+ onKeyChange: ignored,
1650
+ children: /* @__PURE__ */ jsx5(
1651
+ Widget,
1652
+ {
1653
+ id,
1654
+ name,
1655
+ schema,
1656
+ label: (title || schema.title) ?? "",
1657
+ disabled: disabled || Array.isArray(enumOptions) && isEmpty2(enumOptions),
1658
+ uiSchema,
1659
+ formContext,
1660
+ autofocus,
1661
+ readonly,
1662
+ required,
1663
+ registry,
1664
+ multiple: false,
1665
+ rawErrors,
1666
+ hideError: hideFieldError,
1667
+ hideLabel: !displayLabel,
1668
+ errorSchema: fieldErrorSchema,
1669
+ placeholder,
1670
+ onChange: onOptionChange,
1671
+ onBlur,
1672
+ onFocus,
1673
+ value: selectedOption,
1674
+ options: widgetOptions
1675
+ }
1676
+ )
1677
+ }
1678
+ );
1679
+ }
1680
+
1681
+ // src/components/fields/MultiSchemaField.tsx
1682
+ import { Component as Component2 } from "react";
1683
+ import get4 from "lodash/get";
1684
+ import isEmpty3 from "lodash/isEmpty";
1685
+ import omit2 from "lodash/omit";
1686
+ import {
1687
+ ANY_OF_KEY as ANY_OF_KEY3,
1688
+ deepEquals,
1689
+ ERRORS_KEY as ERRORS_KEY2,
1690
+ getDiscriminatorFieldFromSchema as getDiscriminatorFieldFromSchema3,
1691
+ getUiOptions as getUiOptions6,
1692
+ getWidget as getWidget4,
1693
+ mergeSchemas,
1694
+ ONE_OF_KEY as ONE_OF_KEY3,
1695
+ TranslatableString as TranslatableString3
1696
+ } from "@rjsf/utils";
1697
+ import { jsx as jsx6, jsxs } from "react/jsx-runtime";
1698
+ var AnyOfField = class extends Component2 {
1699
+ /** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
1700
+ *
1701
+ * @param props - The `FieldProps` for this template
1702
+ */
1703
+ constructor(props) {
1704
+ super(props);
1705
+ const {
1706
+ formData,
1707
+ options,
1708
+ registry: { schemaUtils }
1709
+ } = this.props;
1710
+ const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
1711
+ this.state = {
1712
+ retrievedOptions,
1713
+ selectedOption: this.getMatchingOption(0, formData, retrievedOptions)
1714
+ };
1715
+ }
1716
+ /** React lifecycle method that is called when the props and/or state for this component is updated. It recomputes the
1717
+ * currently selected option based on the overall `formData`
1718
+ *
1719
+ * @param prevProps - The previous `FieldProps` for this template
1720
+ * @param prevState - The previous `AnyOfFieldState` for this template
1721
+ */
1722
+ componentDidUpdate(prevProps, prevState) {
1723
+ const { formData, options, idSchema } = this.props;
1724
+ const { selectedOption } = this.state;
1725
+ let newState = this.state;
1726
+ if (!deepEquals(prevProps.options, options)) {
1727
+ const {
1728
+ registry: { schemaUtils }
1729
+ } = this.props;
1730
+ const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
1731
+ newState = { selectedOption, retrievedOptions };
1732
+ }
1733
+ if (!deepEquals(formData, prevProps.formData) && idSchema.$id === prevProps.idSchema.$id) {
1734
+ const { retrievedOptions } = newState;
1735
+ const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
1736
+ if (prevState && matchingOption !== selectedOption) {
1737
+ newState = { selectedOption: matchingOption, retrievedOptions };
1738
+ }
1739
+ }
1740
+ if (newState !== this.state) {
1741
+ this.setState(newState);
1742
+ }
1743
+ }
1744
+ /** Determines the best matching option for the given `formData` and `options`.
1745
+ *
1746
+ * @param formData - The new formData
1747
+ * @param options - The list of options to choose from
1748
+ * @return - The index of the `option` that best matches the `formData`
1749
+ */
1750
+ getMatchingOption(selectedOption, formData, options) {
1751
+ const {
1752
+ schema,
1753
+ registry: { schemaUtils }
1754
+ } = this.props;
1755
+ const discriminator = getDiscriminatorFieldFromSchema3(schema);
1756
+ const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
1757
+ return option;
1758
+ }
1759
+ /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
1760
+ * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
1761
+ * the `onChange` handler.
1762
+ *
1763
+ * @param option - The new option value being selected
1764
+ */
1765
+ onOptionChange = (option) => {
1766
+ const { selectedOption, retrievedOptions } = this.state;
1767
+ const { formData, onChange, registry } = this.props;
1768
+ const { schemaUtils } = registry;
1769
+ const intOption = option !== void 0 ? parseInt(option, 10) : -1;
1770
+ if (intOption === selectedOption) {
1771
+ return;
1772
+ }
1773
+ const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
1774
+ const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
1775
+ let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
1776
+ if (newOption) {
1777
+ newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
1778
+ }
1779
+ this.setState({ selectedOption: intOption }, () => {
1780
+ onChange(newFormData, void 0, this.getFieldId());
1781
+ });
1782
+ };
1783
+ getFieldId() {
1784
+ const { idSchema, schema } = this.props;
1785
+ return `${idSchema.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
1786
+ }
1787
+ /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
1788
+ */
1789
+ render() {
1790
+ const {
1791
+ name,
1792
+ disabled = false,
1793
+ errorSchema = {},
1794
+ formContext,
1795
+ onBlur,
1796
+ onFocus,
1797
+ readonly,
1798
+ registry,
1799
+ schema,
1800
+ uiSchema
1801
+ } = this.props;
1802
+ const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
1803
+ const { SchemaField: _SchemaField } = fields2;
1804
+ const { selectedOption, retrievedOptions } = this.state;
1805
+ const {
1806
+ widget = "select",
1807
+ placeholder,
1808
+ autofocus,
1809
+ autocomplete,
1810
+ title = schema.title,
1811
+ ...uiOptions
1812
+ } = getUiOptions6(uiSchema, globalUiOptions);
1813
+ const Widget = getWidget4({ type: "number" }, widget, widgets2);
1814
+ const rawErrors = get4(errorSchema, ERRORS_KEY2, []);
1815
+ const fieldErrorSchema = omit2(errorSchema, [ERRORS_KEY2]);
1816
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1817
+ const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1818
+ let optionSchema;
1819
+ if (option) {
1820
+ const { required } = schema;
1821
+ optionSchema = required ? mergeSchemas({ required }, option) : option;
1822
+ }
1823
+ let optionsUiSchema = [];
1824
+ if (ONE_OF_KEY3 in schema && uiSchema && ONE_OF_KEY3 in uiSchema) {
1825
+ if (Array.isArray(uiSchema[ONE_OF_KEY3])) {
1826
+ optionsUiSchema = uiSchema[ONE_OF_KEY3];
1827
+ } else {
1828
+ console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
1829
+ }
1830
+ } else if (ANY_OF_KEY3 in schema && uiSchema && ANY_OF_KEY3 in uiSchema) {
1831
+ if (Array.isArray(uiSchema[ANY_OF_KEY3])) {
1832
+ optionsUiSchema = uiSchema[ANY_OF_KEY3];
1833
+ } else {
1834
+ console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
1835
+ }
1836
+ }
1837
+ let optionUiSchema = uiSchema;
1838
+ if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
1839
+ optionUiSchema = optionsUiSchema[selectedOption];
1840
+ }
1841
+ const translateEnum = title ? TranslatableString3.TitleOptionPrefix : TranslatableString3.OptionPrefix;
1842
+ const translateParams = title ? [title] : [];
1843
+ const enumOptions = retrievedOptions.map((opt, index) => {
1844
+ const { title: uiTitle = opt.title } = getUiOptions6(optionsUiSchema[index]);
1845
+ return {
1846
+ label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
1847
+ value: index
1848
+ };
1849
+ });
1850
+ return /* @__PURE__ */ jsxs("div", { className: "panel panel-default panel-body", children: [
1851
+ /* @__PURE__ */ jsx6("div", { className: "form-group", children: /* @__PURE__ */ jsx6(
1852
+ Widget,
1853
+ {
1094
1854
  id: this.getFieldId(),
1095
1855
  name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
1096
1856
  schema: { type: "number", default: 0 },
1097
1857
  onChange: this.onOptionChange,
1098
1858
  onBlur,
1099
1859
  onFocus,
1100
- disabled: disabled || isEmpty(enumOptions),
1860
+ disabled: disabled || isEmpty3(enumOptions),
1101
1861
  multiple: false,
1102
1862
  rawErrors,
1103
1863
  errorSchema: fieldErrorSchema,
@@ -1109,196 +1869,74 @@ var AnyOfField = class extends Component2 {
1109
1869
  autocomplete,
1110
1870
  autofocus,
1111
1871
  label: title ?? name,
1112
- hideLabel: !displayLabel
1872
+ hideLabel: !displayLabel,
1873
+ readonly
1113
1874
  }
1114
1875
  ) }),
1115
- optionSchema && /* @__PURE__ */ jsx3(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema })
1876
+ optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsx6(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema })
1116
1877
  ] });
1117
1878
  }
1118
1879
  };
1119
1880
  var MultiSchemaField_default = AnyOfField;
1120
1881
 
1121
1882
  // src/components/fields/NumberField.tsx
1122
- import { useState, useCallback } from "react";
1883
+ import { useState as useState2, useCallback } from "react";
1123
1884
  import { asNumber } from "@rjsf/utils";
1124
- import { jsx as jsx4 } from "react/jsx-runtime";
1885
+ import { jsx as jsx7 } from "react/jsx-runtime";
1125
1886
  var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
1126
1887
  var trailingCharMatcher = /[0.]0*$/;
1127
- function NumberField(props) {
1128
- const { registry, onChange, formData, value: initialValue } = props;
1129
- const [lastValue, setLastValue] = useState(initialValue);
1130
- const { StringField: StringField2 } = registry.fields;
1131
- let value = formData;
1132
- const handleChange = useCallback(
1133
- (value2) => {
1134
- setLastValue(value2);
1135
- if (`${value2}`.charAt(0) === ".") {
1136
- value2 = `0${value2}`;
1137
- }
1138
- const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? asNumber(value2.replace(trailingCharMatcher, "")) : asNumber(value2);
1139
- onChange(processed);
1140
- },
1141
- [onChange]
1142
- );
1143
- if (typeof lastValue === "string" && typeof value === "number") {
1144
- const re = new RegExp(`^(${String(value).replace(".", "\\.")})?\\.?0*$`);
1145
- if (lastValue.match(re)) {
1146
- value = lastValue;
1147
- }
1148
- }
1149
- return /* @__PURE__ */ jsx4(StringField2, { ...props, formData: value, onChange: handleChange });
1150
- }
1151
- var NumberField_default = NumberField;
1152
-
1153
- // src/components/fields/ObjectField.tsx
1154
- import { Component as Component3 } from "react";
1155
- import {
1156
- getTemplate as getTemplate2,
1157
- getUiOptions as getUiOptions4,
1158
- orderProperties,
1159
- TranslatableString as TranslatableString4,
1160
- ADDITIONAL_PROPERTY_FLAG,
1161
- PROPERTIES_KEY,
1162
- REF_KEY,
1163
- ANY_OF_KEY as ANY_OF_KEY2,
1164
- ONE_OF_KEY as ONE_OF_KEY2
1165
- } from "@rjsf/utils";
1166
- import Markdown from "markdown-to-jsx";
1167
- import get3 from "lodash/get";
1168
- import has from "lodash/has";
1169
- import isObject3 from "lodash/isObject";
1170
- import set2 from "lodash/set";
1171
- import unset from "lodash/unset";
1172
- import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
1173
- var ObjectField = class extends Component3 {
1174
- constructor() {
1175
- super(...arguments);
1176
- /** Set up the initial state */
1177
- this.state = {
1178
- wasPropertyKeyModified: false,
1179
- additionalProperties: {}
1180
- };
1181
- /** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
1182
- * to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
1183
- * formData.
1184
- *
1185
- * @param name - The name of the property
1186
- * @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
1187
- * @returns - The onPropertyChange callback for the `name` property
1188
- */
1189
- this.onPropertyChange = (name, addedByAdditionalProperties = false) => {
1190
- return (value, newErrorSchema, id) => {
1191
- const { formData, onChange, errorSchema } = this.props;
1192
- if (value === void 0 && addedByAdditionalProperties) {
1193
- value = "";
1194
- }
1195
- const newFormData = { ...formData, [name]: value };
1196
- onChange(
1197
- newFormData,
1198
- errorSchema && errorSchema && {
1199
- ...errorSchema,
1200
- [name]: newErrorSchema
1201
- },
1202
- id
1203
- );
1204
- };
1205
- };
1206
- /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
1207
- * and calls the `onChange` callback with it
1208
- *
1209
- * @param key - The key for which the drop callback is desired
1210
- * @returns - The drop property click callback
1211
- */
1212
- this.onDropPropertyClick = (key) => {
1213
- return (event) => {
1214
- event.preventDefault();
1215
- const { onChange, formData } = this.props;
1216
- const copiedFormData = { ...formData };
1217
- unset(copiedFormData, key);
1218
- onChange(copiedFormData);
1219
- };
1220
- };
1221
- /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
1222
- * that is already not assigned is found.
1223
- *
1224
- * @param preferredKey - The preferred name of a new key
1225
- * @param [formData] - The form data in which to check if the desired key already exists
1226
- * @returns - The name of the next available key from `preferredKey`
1227
- */
1228
- this.getAvailableKey = (preferredKey, formData) => {
1229
- const { uiSchema, registry } = this.props;
1230
- const { duplicateKeySuffixSeparator = "-" } = getUiOptions4(uiSchema, registry.globalUiOptions);
1231
- let index = 0;
1232
- let newKey = preferredKey;
1233
- while (has(formData, newKey)) {
1234
- newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
1235
- }
1236
- return newKey;
1237
- };
1238
- /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
1239
- * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
1240
- *
1241
- * @param oldValue - The old value of a field
1242
- * @returns - The key change callback function
1243
- */
1244
- this.onKeyChange = (oldValue) => {
1245
- return (value, newErrorSchema) => {
1246
- if (oldValue === value) {
1247
- return;
1248
- }
1249
- const { formData, onChange, errorSchema } = this.props;
1250
- value = this.getAvailableKey(value, formData);
1251
- const newFormData = {
1252
- ...formData
1253
- };
1254
- const newKeys = { [oldValue]: value };
1255
- const keyValues = Object.keys(newFormData).map((key) => {
1256
- const newKey = newKeys[key] || key;
1257
- return { [newKey]: newFormData[key] };
1258
- });
1259
- const renamedObj = Object.assign({}, ...keyValues);
1260
- this.setState({ wasPropertyKeyModified: true });
1261
- onChange(
1262
- renamedObj,
1263
- errorSchema && errorSchema && {
1264
- ...errorSchema,
1265
- [value]: newErrorSchema
1266
- }
1267
- );
1268
- };
1269
- };
1270
- /** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
1271
- * default data for that field has been added to the formData.
1272
- *
1273
- * @param schema - The schema element to which the new property is being added
1274
- */
1275
- this.handleAddClick = (schema) => () => {
1276
- if (!schema.additionalProperties) {
1277
- return;
1278
- }
1279
- const { formData, onChange, registry } = this.props;
1280
- const newFormData = { ...formData };
1281
- let type = void 0;
1282
- let defaultValue = void 0;
1283
- if (isObject3(schema.additionalProperties)) {
1284
- type = schema.additionalProperties.type;
1285
- defaultValue = schema.additionalProperties.default;
1286
- let apSchema = schema.additionalProperties;
1287
- if (REF_KEY in apSchema) {
1288
- const { schemaUtils } = registry;
1289
- apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
1290
- type = apSchema.type;
1291
- defaultValue = apSchema.default;
1292
- }
1293
- if (!type && (ANY_OF_KEY2 in apSchema || ONE_OF_KEY2 in apSchema)) {
1294
- type = "object";
1295
- }
1888
+ function NumberField(props) {
1889
+ const { registry, onChange, formData, value: initialValue } = props;
1890
+ const [lastValue, setLastValue] = useState2(initialValue);
1891
+ const { StringField: StringField2 } = registry.fields;
1892
+ let value = formData;
1893
+ const handleChange = useCallback(
1894
+ (value2, errorSchema, id) => {
1895
+ setLastValue(value2);
1896
+ if (`${value2}`.charAt(0) === ".") {
1897
+ value2 = `0${value2}`;
1296
1898
  }
1297
- const newKey = this.getAvailableKey("newKey", newFormData);
1298
- set2(newFormData, newKey, defaultValue ?? this.getDefaultValue(type));
1299
- onChange(newFormData);
1300
- };
1899
+ const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? asNumber(value2.replace(trailingCharMatcher, "")) : asNumber(value2);
1900
+ onChange(processed, errorSchema, id);
1901
+ },
1902
+ [onChange]
1903
+ );
1904
+ if (typeof lastValue === "string" && typeof value === "number") {
1905
+ const re = new RegExp(`^(${String(value).replace(".", "\\.")})?\\.?0*$`);
1906
+ if (lastValue.match(re)) {
1907
+ value = lastValue;
1908
+ }
1301
1909
  }
1910
+ return /* @__PURE__ */ jsx7(StringField2, { ...props, formData: value, onChange: handleChange });
1911
+ }
1912
+ var NumberField_default = NumberField;
1913
+
1914
+ // src/components/fields/ObjectField.tsx
1915
+ import { Component as Component3 } from "react";
1916
+ import {
1917
+ getTemplate as getTemplate5,
1918
+ getUiOptions as getUiOptions7,
1919
+ orderProperties,
1920
+ TranslatableString as TranslatableString4,
1921
+ ADDITIONAL_PROPERTY_FLAG,
1922
+ PROPERTIES_KEY as PROPERTIES_KEY3,
1923
+ REF_KEY,
1924
+ ANY_OF_KEY as ANY_OF_KEY4,
1925
+ ONE_OF_KEY as ONE_OF_KEY4
1926
+ } from "@rjsf/utils";
1927
+ import Markdown from "markdown-to-jsx";
1928
+ import get5 from "lodash/get";
1929
+ import has3 from "lodash/has";
1930
+ import isObject4 from "lodash/isObject";
1931
+ import set4 from "lodash/set";
1932
+ import unset from "lodash/unset";
1933
+ import { jsx as jsx8, jsxs as jsxs2 } from "react/jsx-runtime";
1934
+ var ObjectField = class extends Component3 {
1935
+ /** Set up the initial state */
1936
+ state = {
1937
+ wasPropertyKeyModified: false,
1938
+ additionalProperties: {}
1939
+ };
1302
1940
  /** Returns a flag indicating whether the `name` field is required in the object schema
1303
1941
  *
1304
1942
  * @param name - The name of the field to check for required-ness
@@ -1308,6 +1946,95 @@ var ObjectField = class extends Component3 {
1308
1946
  const { schema } = this.props;
1309
1947
  return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
1310
1948
  }
1949
+ /** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
1950
+ * to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
1951
+ * formData.
1952
+ *
1953
+ * @param name - The name of the property
1954
+ * @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
1955
+ * @returns - The onPropertyChange callback for the `name` property
1956
+ */
1957
+ onPropertyChange = (name, addedByAdditionalProperties = false) => {
1958
+ return (value, newErrorSchema, id) => {
1959
+ const { formData, onChange, errorSchema } = this.props;
1960
+ if (value === void 0 && addedByAdditionalProperties) {
1961
+ value = "";
1962
+ }
1963
+ const newFormData = { ...formData, [name]: value };
1964
+ onChange(
1965
+ newFormData,
1966
+ errorSchema && errorSchema && {
1967
+ ...errorSchema,
1968
+ [name]: newErrorSchema
1969
+ },
1970
+ id
1971
+ );
1972
+ };
1973
+ };
1974
+ /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
1975
+ * and calls the `onChange` callback with it
1976
+ *
1977
+ * @param key - The key for which the drop callback is desired
1978
+ * @returns - The drop property click callback
1979
+ */
1980
+ onDropPropertyClick = (key) => {
1981
+ return (event) => {
1982
+ event.preventDefault();
1983
+ const { onChange, formData } = this.props;
1984
+ const copiedFormData = { ...formData };
1985
+ unset(copiedFormData, key);
1986
+ onChange(copiedFormData);
1987
+ };
1988
+ };
1989
+ /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
1990
+ * that is already not assigned is found.
1991
+ *
1992
+ * @param preferredKey - The preferred name of a new key
1993
+ * @param [formData] - The form data in which to check if the desired key already exists
1994
+ * @returns - The name of the next available key from `preferredKey`
1995
+ */
1996
+ getAvailableKey = (preferredKey, formData) => {
1997
+ const { uiSchema, registry } = this.props;
1998
+ const { duplicateKeySuffixSeparator = "-" } = getUiOptions7(uiSchema, registry.globalUiOptions);
1999
+ let index = 0;
2000
+ let newKey = preferredKey;
2001
+ while (has3(formData, newKey)) {
2002
+ newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
2003
+ }
2004
+ return newKey;
2005
+ };
2006
+ /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
2007
+ * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
2008
+ *
2009
+ * @param oldValue - The old value of a field
2010
+ * @returns - The key change callback function
2011
+ */
2012
+ onKeyChange = (oldValue) => {
2013
+ return (value, newErrorSchema) => {
2014
+ if (oldValue === value) {
2015
+ return;
2016
+ }
2017
+ const { formData, onChange, errorSchema } = this.props;
2018
+ value = this.getAvailableKey(value, formData);
2019
+ const newFormData = {
2020
+ ...formData
2021
+ };
2022
+ const newKeys = { [oldValue]: value };
2023
+ const keyValues = Object.keys(newFormData).map((key) => {
2024
+ const newKey = newKeys[key] || key;
2025
+ return { [newKey]: newFormData[key] };
2026
+ });
2027
+ const renamedObj = Object.assign({}, ...keyValues);
2028
+ this.setState({ wasPropertyKeyModified: true });
2029
+ onChange(
2030
+ renamedObj,
2031
+ errorSchema && errorSchema && {
2032
+ ...errorSchema,
2033
+ [value]: newErrorSchema
2034
+ }
2035
+ );
2036
+ };
2037
+ };
1311
2038
  /** Returns a default value to be used for a new additional schema property of the given `type`
1312
2039
  *
1313
2040
  * @param type - The type of the new additional schema property
@@ -1332,6 +2059,45 @@ var ObjectField = class extends Component3 {
1332
2059
  return translateString(TranslatableString4.NewStringDefault);
1333
2060
  }
1334
2061
  }
2062
+ /** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
2063
+ * default data for that field has been added to the formData.
2064
+ *
2065
+ * @param schema - The schema element to which the new property is being added
2066
+ */
2067
+ handleAddClick = (schema) => () => {
2068
+ if (!(schema.additionalProperties || schema.patternProperties)) {
2069
+ return;
2070
+ }
2071
+ const { formData, onChange, registry } = this.props;
2072
+ const newFormData = { ...formData };
2073
+ const newKey = this.getAvailableKey("newKey", newFormData);
2074
+ if (schema.patternProperties) {
2075
+ set4(newFormData, newKey, null);
2076
+ } else {
2077
+ let type = void 0;
2078
+ let constValue = void 0;
2079
+ let defaultValue = void 0;
2080
+ if (isObject4(schema.additionalProperties)) {
2081
+ type = schema.additionalProperties.type;
2082
+ constValue = schema.additionalProperties.const;
2083
+ defaultValue = schema.additionalProperties.default;
2084
+ let apSchema = schema.additionalProperties;
2085
+ if (REF_KEY in apSchema) {
2086
+ const { schemaUtils } = registry;
2087
+ apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
2088
+ type = apSchema.type;
2089
+ constValue = apSchema.const;
2090
+ defaultValue = apSchema.default;
2091
+ }
2092
+ if (!type && (ANY_OF_KEY4 in apSchema || ONE_OF_KEY4 in apSchema)) {
2093
+ type = "object";
2094
+ }
2095
+ }
2096
+ const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
2097
+ set4(newFormData, newKey, newValue);
2098
+ }
2099
+ onChange(newFormData);
2100
+ };
1335
2101
  /** Renders the `ObjectField` from the given props
1336
2102
  */
1337
2103
  render() {
@@ -1356,7 +2122,7 @@ var ObjectField = class extends Component3 {
1356
2122
  const { fields: fields2, formContext, schemaUtils, translateString, globalUiOptions } = registry;
1357
2123
  const { SchemaField: SchemaField2 } = fields2;
1358
2124
  const schema = schemaUtils.retrieveSchema(rawSchema, formData);
1359
- const uiOptions = getUiOptions4(uiSchema, globalUiOptions);
2125
+ const uiOptions = getUiOptions7(uiSchema, globalUiOptions);
1360
2126
  const { properties: schemaProperties = {} } = schema;
1361
2127
  const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
1362
2128
  const description = uiOptions.description ?? schema.description;
@@ -1366,33 +2132,33 @@ var ObjectField = class extends Component3 {
1366
2132
  orderedProperties = orderProperties(properties, uiOptions.order);
1367
2133
  } catch (err) {
1368
2134
  return /* @__PURE__ */ jsxs2("div", { children: [
1369
- /* @__PURE__ */ jsx5("p", { className: "config-error", style: { color: "red" }, children: /* @__PURE__ */ jsx5(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString4.InvalidObjectField, [name || "root", err.message]) }) }),
1370
- /* @__PURE__ */ jsx5("pre", { children: JSON.stringify(schema) })
2135
+ /* @__PURE__ */ jsx8("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsx8(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString4.InvalidObjectField, [name || "root", err.message]) }) }),
2136
+ /* @__PURE__ */ jsx8("pre", { children: JSON.stringify(schema) })
1371
2137
  ] });
1372
2138
  }
1373
- const Template = getTemplate2("ObjectFieldTemplate", registry, uiOptions);
2139
+ const Template = getTemplate5("ObjectFieldTemplate", registry, uiOptions);
1374
2140
  const templateProps = {
1375
2141
  // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
1376
2142
  title: uiOptions.label === false ? "" : templateTitle,
1377
2143
  description: uiOptions.label === false ? void 0 : description,
1378
2144
  properties: orderedProperties.map((name2) => {
1379
- const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name2, ADDITIONAL_PROPERTY_FLAG]);
2145
+ const addedByAdditionalProperties = has3(schema, [PROPERTIES_KEY3, name2, ADDITIONAL_PROPERTY_FLAG]);
1380
2146
  const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
1381
- const hidden = getUiOptions4(fieldUiSchema).widget === "hidden";
1382
- const fieldIdSchema = get3(idSchema, [name2], {});
2147
+ const hidden = getUiOptions7(fieldUiSchema).widget === "hidden";
2148
+ const fieldIdSchema = get5(idSchema, [name2], {});
1383
2149
  return {
1384
- content: /* @__PURE__ */ jsx5(
2150
+ content: /* @__PURE__ */ jsx8(
1385
2151
  SchemaField2,
1386
2152
  {
1387
2153
  name: name2,
1388
2154
  required: this.isRequired(name2),
1389
- schema: get3(schema, [PROPERTIES_KEY, name2], {}),
2155
+ schema: get5(schema, [PROPERTIES_KEY3, name2], {}),
1390
2156
  uiSchema: fieldUiSchema,
1391
- errorSchema: get3(errorSchema, name2),
2157
+ errorSchema: get5(errorSchema, name2),
1392
2158
  idSchema: fieldIdSchema,
1393
2159
  idPrefix,
1394
2160
  idSeparator,
1395
- formData: get3(formData, name2),
2161
+ formData: get5(formData, name2),
1396
2162
  formContext,
1397
2163
  wasPropertyKeyModified: this.state.wasPropertyKeyModified,
1398
2164
  onKeyChange: this.onKeyChange(name2),
@@ -1425,7 +2191,7 @@ var ObjectField = class extends Component3 {
1425
2191
  formContext,
1426
2192
  registry
1427
2193
  };
1428
- return /* @__PURE__ */ jsx5(Template, { ...templateProps, onAddClick: this.handleAddClick });
2194
+ return /* @__PURE__ */ jsx8(Template, { ...templateProps, onAddClick: this.handleAddClick });
1429
2195
  }
1430
2196
  };
1431
2197
  var ObjectField_default = ObjectField;
@@ -1437,17 +2203,17 @@ import {
1437
2203
  deepEquals as deepEquals2,
1438
2204
  descriptionId,
1439
2205
  getSchemaType,
1440
- getTemplate as getTemplate3,
1441
- getUiOptions as getUiOptions5,
1442
- ID_KEY,
1443
- mergeObjects,
2206
+ getTemplate as getTemplate6,
2207
+ getUiOptions as getUiOptions8,
2208
+ ID_KEY as ID_KEY3,
2209
+ mergeObjects as mergeObjects2,
1444
2210
  TranslatableString as TranslatableString5,
1445
- UI_OPTIONS_KEY
2211
+ UI_OPTIONS_KEY as UI_OPTIONS_KEY2
1446
2212
  } from "@rjsf/utils";
1447
- import isObject4 from "lodash/isObject";
1448
- import omit2 from "lodash/omit";
2213
+ import isObject5 from "lodash/isObject";
2214
+ import omit3 from "lodash/omit";
1449
2215
  import Markdown2 from "markdown-to-jsx";
1450
- import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
2216
+ import { Fragment, jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
1451
2217
  var COMPONENT_TYPES = {
1452
2218
  array: "ArrayField",
1453
2219
  boolean: "BooleanField",
@@ -1477,12 +2243,12 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
1477
2243
  return () => null;
1478
2244
  }
1479
2245
  return componentName in fields2 ? fields2[componentName] : () => {
1480
- const UnsupportedFieldTemplate = getTemplate3(
2246
+ const UnsupportedFieldTemplate = getTemplate6(
1481
2247
  "UnsupportedFieldTemplate",
1482
2248
  registry,
1483
2249
  uiOptions
1484
2250
  );
1485
- return /* @__PURE__ */ jsx6(
2251
+ return /* @__PURE__ */ jsx9(
1486
2252
  UnsupportedFieldTemplate,
1487
2253
  {
1488
2254
  schema,
@@ -1511,18 +2277,18 @@ function SchemaFieldRender(props) {
1511
2277
  wasPropertyKeyModified = false
1512
2278
  } = props;
1513
2279
  const { formContext, schemaUtils, globalUiOptions } = registry;
1514
- const uiOptions = getUiOptions5(uiSchema, globalUiOptions);
1515
- const FieldTemplate2 = getTemplate3("FieldTemplate", registry, uiOptions);
1516
- const DescriptionFieldTemplate = getTemplate3(
2280
+ const uiOptions = getUiOptions8(uiSchema, globalUiOptions);
2281
+ const FieldTemplate2 = getTemplate6("FieldTemplate", registry, uiOptions);
2282
+ const DescriptionFieldTemplate = getTemplate6(
1517
2283
  "DescriptionFieldTemplate",
1518
2284
  registry,
1519
2285
  uiOptions
1520
2286
  );
1521
- const FieldHelpTemplate2 = getTemplate3("FieldHelpTemplate", registry, uiOptions);
1522
- const FieldErrorTemplate2 = getTemplate3("FieldErrorTemplate", registry, uiOptions);
2287
+ const FieldHelpTemplate2 = getTemplate6("FieldHelpTemplate", registry, uiOptions);
2288
+ const FieldErrorTemplate2 = getTemplate6("FieldErrorTemplate", registry, uiOptions);
1523
2289
  const schema = schemaUtils.retrieveSchema(_schema, formData);
1524
- const fieldId = _idSchema[ID_KEY];
1525
- const idSchema = mergeObjects(
2290
+ const fieldId = _idSchema[ID_KEY3];
2291
+ const idSchema = mergeObjects2(
1526
2292
  schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator),
1527
2293
  _idSchema
1528
2294
  );
@@ -1544,11 +2310,11 @@ function SchemaFieldRender(props) {
1544
2310
  }
1545
2311
  const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1546
2312
  const { __errors, ...fieldErrorSchema } = errorSchema || {};
1547
- const fieldUiSchema = omit2(uiSchema, ["ui:classNames", "classNames", "ui:style"]);
1548
- if (UI_OPTIONS_KEY in fieldUiSchema) {
1549
- fieldUiSchema[UI_OPTIONS_KEY] = omit2(fieldUiSchema[UI_OPTIONS_KEY], ["classNames", "style"]);
2313
+ const fieldUiSchema = omit3(uiSchema, ["ui:classNames", "classNames", "ui:style"]);
2314
+ if (UI_OPTIONS_KEY2 in fieldUiSchema) {
2315
+ fieldUiSchema[UI_OPTIONS_KEY2] = omit3(fieldUiSchema[UI_OPTIONS_KEY2], ["classNames", "style"]);
1550
2316
  }
1551
- const field = /* @__PURE__ */ jsx6(
2317
+ const field = /* @__PURE__ */ jsx9(
1552
2318
  FieldComponent,
1553
2319
  {
1554
2320
  ...props,
@@ -1565,7 +2331,7 @@ function SchemaFieldRender(props) {
1565
2331
  rawErrors: __errors
1566
2332
  }
1567
2333
  );
1568
- const id = idSchema[ID_KEY];
2334
+ const id = idSchema[ID_KEY3];
1569
2335
  let label;
1570
2336
  if (wasPropertyKeyModified) {
1571
2337
  label = name;
@@ -1573,25 +2339,17 @@ function SchemaFieldRender(props) {
1573
2339
  label = ADDITIONAL_PROPERTY_FLAG2 in schema ? name : uiOptions.title || props.schema.title || schema.title || props.title || name;
1574
2340
  }
1575
2341
  const description = uiOptions.description || props.schema.description || schema.description || "";
1576
- const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ jsx6(Markdown2, { options: { disableParsingRawHTML: true }, children: description }) : description;
2342
+ const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ jsx9(Markdown2, { options: { disableParsingRawHTML: true }, children: description }) : description;
1577
2343
  const help = uiOptions.help;
1578
2344
  const hidden = uiOptions.widget === "hidden";
1579
- const classNames = ["form-group", "field", `field-${getSchemaType(schema)}`];
2345
+ const classNames = ["rjsf-field", `rjsf-field-${getSchemaType(schema)}`];
1580
2346
  if (!hideError && __errors && __errors.length > 0) {
1581
- classNames.push("field-error has-error has-danger");
1582
- }
1583
- if (uiSchema?.classNames) {
1584
- if (true) {
1585
- console.warn(
1586
- "'uiSchema.classNames' is deprecated and may be removed in a major release; Use 'ui:classNames' instead."
1587
- );
1588
- }
1589
- classNames.push(uiSchema.classNames);
2347
+ classNames.push("rjsf-field-error");
1590
2348
  }
1591
2349
  if (uiOptions.classNames) {
1592
2350
  classNames.push(uiOptions.classNames);
1593
2351
  }
1594
- const helpComponent = /* @__PURE__ */ jsx6(
2352
+ const helpComponent = /* @__PURE__ */ jsx9(
1595
2353
  FieldHelpTemplate2,
1596
2354
  {
1597
2355
  help,
@@ -1602,7 +2360,7 @@ function SchemaFieldRender(props) {
1602
2360
  registry
1603
2361
  }
1604
2362
  );
1605
- const errorsComponent = hideError || (schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ jsx6(
2363
+ const errorsComponent = hideError || (schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ jsx9(
1606
2364
  FieldErrorTemplate2,
1607
2365
  {
1608
2366
  errors: __errors,
@@ -1614,7 +2372,7 @@ function SchemaFieldRender(props) {
1614
2372
  }
1615
2373
  );
1616
2374
  const fieldProps = {
1617
- description: /* @__PURE__ */ jsx6(
2375
+ description: /* @__PURE__ */ jsx9(
1618
2376
  DescriptionFieldTemplate,
1619
2377
  {
1620
2378
  id: descriptionId(id),
@@ -1651,9 +2409,9 @@ function SchemaFieldRender(props) {
1651
2409
  const _AnyOfField = registry.fields.AnyOfField;
1652
2410
  const _OneOfField = registry.fields.OneOfField;
1653
2411
  const isReplacingAnyOrOneOf = uiSchema?.["ui:field"] && uiSchema?.["ui:fieldReplacesAnyOrOneOf"] === true;
1654
- return /* @__PURE__ */ jsx6(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ jsxs3(Fragment, { children: [
2412
+ return /* @__PURE__ */ jsx9(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ jsxs3(Fragment, { children: [
1655
2413
  field,
1656
- schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx6(
2414
+ schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx9(
1657
2415
  _AnyOfField,
1658
2416
  {
1659
2417
  name,
@@ -1670,14 +2428,15 @@ function SchemaFieldRender(props) {
1670
2428
  onChange: props.onChange,
1671
2429
  onFocus: props.onFocus,
1672
2430
  options: schema.anyOf.map(
1673
- (_schema2) => schemaUtils.retrieveSchema(isObject4(_schema2) ? _schema2 : {}, formData)
2431
+ (_schema2) => schemaUtils.retrieveSchema(isObject5(_schema2) ? _schema2 : {}, formData)
1674
2432
  ),
1675
2433
  registry,
2434
+ required,
1676
2435
  schema,
1677
2436
  uiSchema
1678
2437
  }
1679
2438
  ),
1680
- schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx6(
2439
+ schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx9(
1681
2440
  _OneOfField,
1682
2441
  {
1683
2442
  name,
@@ -1694,9 +2453,10 @@ function SchemaFieldRender(props) {
1694
2453
  onChange: props.onChange,
1695
2454
  onFocus: props.onFocus,
1696
2455
  options: schema.oneOf.map(
1697
- (_schema2) => schemaUtils.retrieveSchema(isObject4(_schema2) ? _schema2 : {}, formData)
2456
+ (_schema2) => schemaUtils.retrieveSchema(isObject5(_schema2) ? _schema2 : {}, formData)
1698
2457
  ),
1699
2458
  registry,
2459
+ required,
1700
2460
  schema,
1701
2461
  uiSchema
1702
2462
  }
@@ -1708,19 +2468,19 @@ var SchemaField = class extends Component4 {
1708
2468
  return !deepEquals2(this.props, nextProps);
1709
2469
  }
1710
2470
  render() {
1711
- return /* @__PURE__ */ jsx6(SchemaFieldRender, { ...this.props });
2471
+ return /* @__PURE__ */ jsx9(SchemaFieldRender, { ...this.props });
1712
2472
  }
1713
2473
  };
1714
2474
  var SchemaField_default = SchemaField;
1715
2475
 
1716
2476
  // src/components/fields/StringField.tsx
1717
2477
  import {
1718
- getWidget as getWidget4,
1719
- getUiOptions as getUiOptions6,
1720
- optionsList as optionsList3,
2478
+ getWidget as getWidget5,
2479
+ getUiOptions as getUiOptions9,
2480
+ optionsList as optionsList4,
1721
2481
  hasWidget
1722
2482
  } from "@rjsf/utils";
1723
- import { jsx as jsx7 } from "react/jsx-runtime";
2483
+ import { jsx as jsx10 } from "react/jsx-runtime";
1724
2484
  function StringField(props) {
1725
2485
  const {
1726
2486
  schema,
@@ -1741,16 +2501,16 @@ function StringField(props) {
1741
2501
  } = props;
1742
2502
  const { title, format } = schema;
1743
2503
  const { widgets: widgets2, formContext, schemaUtils, globalUiOptions } = registry;
1744
- const enumOptions = schemaUtils.isSelect(schema) ? optionsList3(schema, uiSchema) : void 0;
2504
+ const enumOptions = schemaUtils.isSelect(schema) ? optionsList4(schema, uiSchema) : void 0;
1745
2505
  let defaultWidget = enumOptions ? "select" : "text";
1746
2506
  if (format && hasWidget(schema, format, widgets2)) {
1747
2507
  defaultWidget = format;
1748
2508
  }
1749
- const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = getUiOptions6(uiSchema);
2509
+ const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = getUiOptions9(uiSchema);
1750
2510
  const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1751
2511
  const label = uiTitle ?? title ?? name;
1752
- const Widget = getWidget4(schema, widget, widgets2);
1753
- return /* @__PURE__ */ jsx7(
2512
+ const Widget = getWidget5(schema, widget, widgets2);
2513
+ return /* @__PURE__ */ jsx10(
1754
2514
  Widget,
1755
2515
  {
1756
2516
  options: { ...options, enumOptions },
@@ -1779,10 +2539,10 @@ function StringField(props) {
1779
2539
  var StringField_default = StringField;
1780
2540
 
1781
2541
  // src/components/fields/NullField.tsx
1782
- import { useEffect } from "react";
2542
+ import { useEffect as useEffect2 } from "react";
1783
2543
  function NullField(props) {
1784
2544
  const { formData, onChange } = props;
1785
- useEffect(() => {
2545
+ useEffect2(() => {
1786
2546
  if (formData === void 0) {
1787
2547
  onChange(null);
1788
2548
  }
@@ -1798,6 +2558,9 @@ function fields() {
1798
2558
  ArrayField: ArrayField_default,
1799
2559
  // ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
1800
2560
  BooleanField: BooleanField_default,
2561
+ LayoutGridField,
2562
+ LayoutHeaderField,
2563
+ LayoutMultiSchemaField,
1801
2564
  NumberField: NumberField_default,
1802
2565
  ObjectField: ObjectField_default,
1803
2566
  OneOfField: MultiSchemaField_default,
@@ -1811,23 +2574,23 @@ var fields_default = fields;
1811
2574
  // src/components/templates/ArrayFieldDescriptionTemplate.tsx
1812
2575
  import {
1813
2576
  descriptionId as descriptionId2,
1814
- getTemplate as getTemplate4,
1815
- getUiOptions as getUiOptions7
2577
+ getTemplate as getTemplate7,
2578
+ getUiOptions as getUiOptions10
1816
2579
  } from "@rjsf/utils";
1817
- import { jsx as jsx8 } from "react/jsx-runtime";
2580
+ import { jsx as jsx11 } from "react/jsx-runtime";
1818
2581
  function ArrayFieldDescriptionTemplate(props) {
1819
2582
  const { idSchema, description, registry, schema, uiSchema } = props;
1820
- const options = getUiOptions7(uiSchema, registry.globalUiOptions);
2583
+ const options = getUiOptions10(uiSchema, registry.globalUiOptions);
1821
2584
  const { label: displayLabel = true } = options;
1822
2585
  if (!description || !displayLabel) {
1823
2586
  return null;
1824
2587
  }
1825
- const DescriptionFieldTemplate = getTemplate4(
2588
+ const DescriptionFieldTemplate = getTemplate7(
1826
2589
  "DescriptionFieldTemplate",
1827
2590
  registry,
1828
2591
  options
1829
2592
  );
1830
- return /* @__PURE__ */ jsx8(
2593
+ return /* @__PURE__ */ jsx11(
1831
2594
  DescriptionFieldTemplate,
1832
2595
  {
1833
2596
  id: descriptionId2(idSchema),
@@ -1840,26 +2603,19 @@ function ArrayFieldDescriptionTemplate(props) {
1840
2603
  }
1841
2604
 
1842
2605
  // src/components/templates/ArrayFieldItemTemplate.tsx
1843
- import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
2606
+ import {
2607
+ getTemplate as getTemplate8,
2608
+ getUiOptions as getUiOptions11
2609
+ } from "@rjsf/utils";
2610
+ import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
1844
2611
  function ArrayFieldItemTemplate(props) {
1845
- const {
1846
- children,
1847
- className,
1848
- disabled,
1849
- hasToolbar,
1850
- hasMoveDown,
1851
- hasMoveUp,
1852
- hasRemove,
1853
- hasCopy,
1854
- index,
1855
- onCopyIndexClick,
1856
- onDropIndexClick,
1857
- onReorderClick,
1858
- readonly,
2612
+ const { children, className, buttonsProps, hasToolbar, registry, uiSchema } = props;
2613
+ const uiOptions = getUiOptions11(uiSchema);
2614
+ const ArrayFieldItemButtonsTemplate2 = getTemplate8(
2615
+ "ArrayFieldItemButtonsTemplate",
1859
2616
  registry,
1860
- uiSchema
1861
- } = props;
1862
- const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
2617
+ uiOptions
2618
+ );
1863
2619
  const btnStyle = {
1864
2620
  flex: 1,
1865
2621
  paddingLeft: 6,
@@ -1867,8 +2623,8 @@ function ArrayFieldItemTemplate(props) {
1867
2623
  fontWeight: "bold"
1868
2624
  };
1869
2625
  return /* @__PURE__ */ jsxs4("div", { className, children: [
1870
- /* @__PURE__ */ jsx9("div", { className: hasToolbar ? "col-xs-9" : "col-xs-12", children }),
1871
- hasToolbar && /* @__PURE__ */ jsx9("div", { className: "col-xs-3 array-item-toolbox", children: /* @__PURE__ */ jsxs4(
2626
+ /* @__PURE__ */ jsx12("div", { className: hasToolbar ? "col-xs-9" : "col-xs-12", children }),
2627
+ hasToolbar && /* @__PURE__ */ jsx12("div", { className: "col-xs-3 array-item-toolbox", children: /* @__PURE__ */ jsx12(
1872
2628
  "div",
1873
2629
  {
1874
2630
  className: "btn-group",
@@ -1876,59 +2632,94 @@ function ArrayFieldItemTemplate(props) {
1876
2632
  display: "flex",
1877
2633
  justifyContent: "space-around"
1878
2634
  },
1879
- children: [
1880
- (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx9(
1881
- MoveUpButton2,
1882
- {
1883
- style: btnStyle,
1884
- disabled: disabled || readonly || !hasMoveUp,
1885
- onClick: onReorderClick(index, index - 1),
1886
- uiSchema,
1887
- registry
1888
- }
1889
- ),
1890
- (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx9(
1891
- MoveDownButton2,
1892
- {
1893
- style: btnStyle,
1894
- disabled: disabled || readonly || !hasMoveDown,
1895
- onClick: onReorderClick(index, index + 1),
1896
- uiSchema,
1897
- registry
1898
- }
1899
- ),
1900
- hasCopy && /* @__PURE__ */ jsx9(
1901
- CopyButton2,
1902
- {
1903
- style: btnStyle,
1904
- disabled: disabled || readonly,
1905
- onClick: onCopyIndexClick(index),
1906
- uiSchema,
1907
- registry
1908
- }
1909
- ),
1910
- hasRemove && /* @__PURE__ */ jsx9(
1911
- RemoveButton2,
1912
- {
1913
- style: btnStyle,
1914
- disabled: disabled || readonly,
1915
- onClick: onDropIndexClick(index),
1916
- uiSchema,
1917
- registry
1918
- }
1919
- )
1920
- ]
2635
+ children: /* @__PURE__ */ jsx12(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle })
1921
2636
  }
1922
2637
  ) })
1923
2638
  ] });
1924
2639
  }
1925
2640
 
2641
+ // src/components/templates/ArrayFieldItemButtonsTemplate.tsx
2642
+ import { useMemo } from "react";
2643
+ import {
2644
+ buttonId
2645
+ } from "@rjsf/utils";
2646
+ import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
2647
+ function ArrayFieldItemButtonsTemplate(props) {
2648
+ const {
2649
+ disabled,
2650
+ hasCopy,
2651
+ hasMoveDown,
2652
+ hasMoveUp,
2653
+ hasRemove,
2654
+ idSchema,
2655
+ index,
2656
+ onCopyIndexClick,
2657
+ onDropIndexClick,
2658
+ onReorderClick,
2659
+ readonly,
2660
+ registry,
2661
+ uiSchema
2662
+ } = props;
2663
+ const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
2664
+ const onCopyClick = useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
2665
+ const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
2666
+ const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
2667
+ const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
2668
+ return /* @__PURE__ */ jsxs5(Fragment2, { children: [
2669
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx13(
2670
+ MoveUpButton2,
2671
+ {
2672
+ id: buttonId(idSchema, "moveUp"),
2673
+ className: "rjsf-array-item-move-up",
2674
+ disabled: disabled || readonly || !hasMoveUp,
2675
+ onClick: onArrowUpClick,
2676
+ uiSchema,
2677
+ registry
2678
+ }
2679
+ ),
2680
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx13(
2681
+ MoveDownButton2,
2682
+ {
2683
+ id: buttonId(idSchema, "moveDown"),
2684
+ className: "rjsf-array-item-move-down",
2685
+ disabled: disabled || readonly || !hasMoveDown,
2686
+ onClick: onArrowDownClick,
2687
+ uiSchema,
2688
+ registry
2689
+ }
2690
+ ),
2691
+ hasCopy && /* @__PURE__ */ jsx13(
2692
+ CopyButton2,
2693
+ {
2694
+ id: buttonId(idSchema, "copy"),
2695
+ className: "rjsf-array-item-copy",
2696
+ disabled: disabled || readonly,
2697
+ onClick: onCopyClick,
2698
+ uiSchema,
2699
+ registry
2700
+ }
2701
+ ),
2702
+ hasRemove && /* @__PURE__ */ jsx13(
2703
+ RemoveButton2,
2704
+ {
2705
+ id: buttonId(idSchema, "remove"),
2706
+ className: "rjsf-array-item-remove",
2707
+ disabled: disabled || readonly,
2708
+ onClick: onRemoveClick,
2709
+ uiSchema,
2710
+ registry
2711
+ }
2712
+ )
2713
+ ] });
2714
+ }
2715
+
1926
2716
  // src/components/templates/ArrayFieldTemplate.tsx
1927
2717
  import {
1928
- getTemplate as getTemplate5,
1929
- getUiOptions as getUiOptions8
2718
+ getTemplate as getTemplate9,
2719
+ getUiOptions as getUiOptions12,
2720
+ buttonId as buttonId2
1930
2721
  } from "@rjsf/utils";
1931
- import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
2722
+ import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
1932
2723
  function ArrayFieldTemplate(props) {
1933
2724
  const {
1934
2725
  canAdd,
@@ -1944,18 +2735,18 @@ function ArrayFieldTemplate(props) {
1944
2735
  schema,
1945
2736
  title
1946
2737
  } = props;
1947
- const uiOptions = getUiOptions8(uiSchema);
1948
- const ArrayFieldDescriptionTemplate2 = getTemplate5(
2738
+ const uiOptions = getUiOptions12(uiSchema);
2739
+ const ArrayFieldDescriptionTemplate2 = getTemplate9(
1949
2740
  "ArrayFieldDescriptionTemplate",
1950
2741
  registry,
1951
2742
  uiOptions
1952
2743
  );
1953
- const ArrayFieldItemTemplate2 = getTemplate5(
2744
+ const ArrayFieldItemTemplate2 = getTemplate9(
1954
2745
  "ArrayFieldItemTemplate",
1955
2746
  registry,
1956
2747
  uiOptions
1957
2748
  );
1958
- const ArrayFieldTitleTemplate2 = getTemplate5(
2749
+ const ArrayFieldTitleTemplate2 = getTemplate9(
1959
2750
  "ArrayFieldTitleTemplate",
1960
2751
  registry,
1961
2752
  uiOptions
@@ -1963,8 +2754,8 @@ function ArrayFieldTemplate(props) {
1963
2754
  const {
1964
2755
  ButtonTemplates: { AddButton: AddButton2 }
1965
2756
  } = registry.templates;
1966
- return /* @__PURE__ */ jsxs5("fieldset", { className, id: idSchema.$id, children: [
1967
- /* @__PURE__ */ jsx10(
2757
+ return /* @__PURE__ */ jsxs6("fieldset", { className, id: idSchema.$id, children: [
2758
+ /* @__PURE__ */ jsx14(
1968
2759
  ArrayFieldTitleTemplate2,
1969
2760
  {
1970
2761
  idSchema,
@@ -1975,7 +2766,7 @@ function ArrayFieldTemplate(props) {
1975
2766
  registry
1976
2767
  }
1977
2768
  ),
1978
- /* @__PURE__ */ jsx10(
2769
+ /* @__PURE__ */ jsx14(
1979
2770
  ArrayFieldDescriptionTemplate2,
1980
2771
  {
1981
2772
  idSchema,
@@ -1985,11 +2776,12 @@ function ArrayFieldTemplate(props) {
1985
2776
  registry
1986
2777
  }
1987
2778
  ),
1988
- /* @__PURE__ */ jsx10("div", { className: "row array-item-list", children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsx10(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
1989
- canAdd && /* @__PURE__ */ jsx10(
2779
+ /* @__PURE__ */ jsx14("div", { className: "row array-item-list", children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsx14(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
2780
+ canAdd && /* @__PURE__ */ jsx14(
1990
2781
  AddButton2,
1991
2782
  {
1992
- className: "array-item-add",
2783
+ id: buttonId2(idSchema, "add"),
2784
+ className: "rjsf-array-item-add",
1993
2785
  onClick: onAddClick,
1994
2786
  disabled: disabled || readonly,
1995
2787
  uiSchema,
@@ -2001,27 +2793,27 @@ function ArrayFieldTemplate(props) {
2001
2793
 
2002
2794
  // src/components/templates/ArrayFieldTitleTemplate.tsx
2003
2795
  import {
2004
- getTemplate as getTemplate6,
2005
- getUiOptions as getUiOptions9,
2006
- titleId
2796
+ getTemplate as getTemplate10,
2797
+ getUiOptions as getUiOptions13,
2798
+ titleId as titleId2
2007
2799
  } from "@rjsf/utils";
2008
- import { jsx as jsx11 } from "react/jsx-runtime";
2800
+ import { jsx as jsx15 } from "react/jsx-runtime";
2009
2801
  function ArrayFieldTitleTemplate(props) {
2010
2802
  const { idSchema, title, schema, uiSchema, required, registry } = props;
2011
- const options = getUiOptions9(uiSchema, registry.globalUiOptions);
2803
+ const options = getUiOptions13(uiSchema, registry.globalUiOptions);
2012
2804
  const { label: displayLabel = true } = options;
2013
2805
  if (!title || !displayLabel) {
2014
2806
  return null;
2015
2807
  }
2016
- const TitleFieldTemplate = getTemplate6(
2808
+ const TitleFieldTemplate = getTemplate10(
2017
2809
  "TitleFieldTemplate",
2018
2810
  registry,
2019
2811
  options
2020
2812
  );
2021
- return /* @__PURE__ */ jsx11(
2813
+ return /* @__PURE__ */ jsx15(
2022
2814
  TitleFieldTemplate,
2023
2815
  {
2024
- id: titleId(idSchema),
2816
+ id: titleId2(idSchema),
2025
2817
  title,
2026
2818
  required,
2027
2819
  schema,
@@ -2038,7 +2830,7 @@ import {
2038
2830
  examplesId,
2039
2831
  getInputProps
2040
2832
  } from "@rjsf/utils";
2041
- import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
2833
+ import { Fragment as Fragment3, jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
2042
2834
  function BaseInputTemplate(props) {
2043
2835
  const {
2044
2836
  id,
@@ -2091,8 +2883,8 @@ function BaseInputTemplate(props) {
2091
2883
  ({ target }) => onFocus(id, target && target.value),
2092
2884
  [onFocus, id]
2093
2885
  );
2094
- return /* @__PURE__ */ jsxs6(Fragment2, { children: [
2095
- /* @__PURE__ */ jsx12(
2886
+ return /* @__PURE__ */ jsxs7(Fragment3, { children: [
2887
+ /* @__PURE__ */ jsx16(
2096
2888
  "input",
2097
2889
  {
2098
2890
  id,
@@ -2110,21 +2902,21 @@ function BaseInputTemplate(props) {
2110
2902
  "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
2111
2903
  }
2112
2904
  ),
2113
- Array.isArray(schema.examples) && /* @__PURE__ */ jsx12("datalist", { id: examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
2114
- return /* @__PURE__ */ jsx12("option", { value: example }, example);
2905
+ Array.isArray(schema.examples) && /* @__PURE__ */ jsx16("datalist", { id: examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
2906
+ return /* @__PURE__ */ jsx16("option", { value: example }, example);
2115
2907
  }) }, `datalist_${id}`)
2116
2908
  ] });
2117
2909
  }
2118
2910
 
2119
2911
  // src/components/templates/ButtonTemplates/SubmitButton.tsx
2120
2912
  import { getSubmitButtonOptions } from "@rjsf/utils";
2121
- import { jsx as jsx13 } from "react/jsx-runtime";
2913
+ import { jsx as jsx17 } from "react/jsx-runtime";
2122
2914
  function SubmitButton({ uiSchema }) {
2123
2915
  const { submitText, norender, props: submitButtonProps = {} } = getSubmitButtonOptions(uiSchema);
2124
2916
  if (norender) {
2125
2917
  return null;
2126
2918
  }
2127
- return /* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsx13("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
2919
+ return /* @__PURE__ */ jsx17("div", { children: /* @__PURE__ */ jsx17("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
2128
2920
  }
2129
2921
 
2130
2922
  // src/components/templates/ButtonTemplates/AddButton.tsx
@@ -2132,71 +2924,38 @@ import { TranslatableString as TranslatableString7 } from "@rjsf/utils";
2132
2924
 
2133
2925
  // src/components/templates/ButtonTemplates/IconButton.tsx
2134
2926
  import { TranslatableString as TranslatableString6 } from "@rjsf/utils";
2135
- import { jsx as jsx14 } from "react/jsx-runtime";
2927
+ import { jsx as jsx18 } from "react/jsx-runtime";
2136
2928
  function IconButton(props) {
2137
2929
  const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
2138
- return /* @__PURE__ */ jsx14("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsx14("i", { className: `glyphicon glyphicon-${icon}` }) });
2930
+ return /* @__PURE__ */ jsx18("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsx18("i", { className: `glyphicon glyphicon-${icon}` }) });
2139
2931
  }
2140
2932
  function CopyButton(props) {
2141
2933
  const {
2142
2934
  registry: { translateString }
2143
2935
  } = props;
2144
- return /* @__PURE__ */ jsx14(
2145
- IconButton,
2146
- {
2147
- title: translateString(TranslatableString6.CopyButton),
2148
- className: "array-item-copy",
2149
- ...props,
2150
- icon: "copy"
2151
- }
2152
- );
2936
+ return /* @__PURE__ */ jsx18(IconButton, { title: translateString(TranslatableString6.CopyButton), ...props, icon: "copy" });
2153
2937
  }
2154
2938
  function MoveDownButton(props) {
2155
2939
  const {
2156
2940
  registry: { translateString }
2157
2941
  } = props;
2158
- return /* @__PURE__ */ jsx14(
2159
- IconButton,
2160
- {
2161
- title: translateString(TranslatableString6.MoveDownButton),
2162
- className: "array-item-move-down",
2163
- ...props,
2164
- icon: "arrow-down"
2165
- }
2166
- );
2942
+ return /* @__PURE__ */ jsx18(IconButton, { title: translateString(TranslatableString6.MoveDownButton), ...props, icon: "arrow-down" });
2167
2943
  }
2168
2944
  function MoveUpButton(props) {
2169
2945
  const {
2170
2946
  registry: { translateString }
2171
2947
  } = props;
2172
- return /* @__PURE__ */ jsx14(
2173
- IconButton,
2174
- {
2175
- title: translateString(TranslatableString6.MoveUpButton),
2176
- className: "array-item-move-up",
2177
- ...props,
2178
- icon: "arrow-up"
2179
- }
2180
- );
2948
+ return /* @__PURE__ */ jsx18(IconButton, { title: translateString(TranslatableString6.MoveUpButton), ...props, icon: "arrow-up" });
2181
2949
  }
2182
2950
  function RemoveButton(props) {
2183
2951
  const {
2184
2952
  registry: { translateString }
2185
2953
  } = props;
2186
- return /* @__PURE__ */ jsx14(
2187
- IconButton,
2188
- {
2189
- title: translateString(TranslatableString6.RemoveButton),
2190
- className: "array-item-remove",
2191
- ...props,
2192
- iconType: "danger",
2193
- icon: "remove"
2194
- }
2195
- );
2954
+ return /* @__PURE__ */ jsx18(IconButton, { title: translateString(TranslatableString6.RemoveButton), ...props, iconType: "danger", icon: "remove" });
2196
2955
  }
2197
2956
 
2198
2957
  // src/components/templates/ButtonTemplates/AddButton.tsx
2199
- import { jsx as jsx15 } from "react/jsx-runtime";
2958
+ import { jsx as jsx19 } from "react/jsx-runtime";
2200
2959
  function AddButton({
2201
2960
  className,
2202
2961
  onClick,
@@ -2204,7 +2963,7 @@ function AddButton({
2204
2963
  registry
2205
2964
  }) {
2206
2965
  const { translateString } = registry;
2207
- return /* @__PURE__ */ jsx15("div", { className: "row", children: /* @__PURE__ */ jsx15("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ jsx15(
2966
+ return /* @__PURE__ */ jsx19("div", { className: "row", children: /* @__PURE__ */ jsx19("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ jsx19(
2208
2967
  IconButton,
2209
2968
  {
2210
2969
  iconType: "info",
@@ -2232,16 +2991,16 @@ function buttonTemplates() {
2232
2991
  var ButtonTemplates_default = buttonTemplates;
2233
2992
 
2234
2993
  // src/components/templates/DescriptionField.tsx
2235
- import { jsx as jsx16 } from "react/jsx-runtime";
2994
+ import { jsx as jsx20 } from "react/jsx-runtime";
2236
2995
  function DescriptionField(props) {
2237
2996
  const { id, description } = props;
2238
2997
  if (!description) {
2239
2998
  return null;
2240
2999
  }
2241
3000
  if (typeof description === "string") {
2242
- return /* @__PURE__ */ jsx16("p", { id, className: "field-description", children: description });
3001
+ return /* @__PURE__ */ jsx20("p", { id, className: "field-description", children: description });
2243
3002
  } else {
2244
- return /* @__PURE__ */ jsx16("div", { id, className: "field-description", children: description });
3003
+ return /* @__PURE__ */ jsx20("div", { id, className: "field-description", children: description });
2245
3004
  }
2246
3005
  }
2247
3006
 
@@ -2249,55 +3008,55 @@ function DescriptionField(props) {
2249
3008
  import {
2250
3009
  TranslatableString as TranslatableString8
2251
3010
  } from "@rjsf/utils";
2252
- import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
3011
+ import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
2253
3012
  function ErrorList({
2254
3013
  errors,
2255
3014
  registry
2256
3015
  }) {
2257
3016
  const { translateString } = registry;
2258
- return /* @__PURE__ */ jsxs7("div", { className: "panel panel-danger errors", children: [
2259
- /* @__PURE__ */ jsx17("div", { className: "panel-heading", children: /* @__PURE__ */ jsx17("h3", { className: "panel-title", children: translateString(TranslatableString8.ErrorsLabel) }) }),
2260
- /* @__PURE__ */ jsx17("ul", { className: "list-group", children: errors.map((error, i) => {
2261
- return /* @__PURE__ */ jsx17("li", { className: "list-group-item text-danger", children: error.stack }, i);
3017
+ return /* @__PURE__ */ jsxs8("div", { className: "panel panel-danger errors", children: [
3018
+ /* @__PURE__ */ jsx21("div", { className: "panel-heading", children: /* @__PURE__ */ jsx21("h3", { className: "panel-title", children: translateString(TranslatableString8.ErrorsLabel) }) }),
3019
+ /* @__PURE__ */ jsx21("ul", { className: "list-group", children: errors.map((error, i) => {
3020
+ return /* @__PURE__ */ jsx21("li", { className: "list-group-item text-danger", children: error.stack }, i);
2262
3021
  }) })
2263
3022
  ] });
2264
3023
  }
2265
3024
 
2266
3025
  // src/components/templates/FieldTemplate/FieldTemplate.tsx
2267
3026
  import {
2268
- getTemplate as getTemplate7,
2269
- getUiOptions as getUiOptions10
3027
+ getTemplate as getTemplate11,
3028
+ getUiOptions as getUiOptions14
2270
3029
  } from "@rjsf/utils";
2271
3030
 
2272
3031
  // src/components/templates/FieldTemplate/Label.tsx
2273
- import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
3032
+ import { jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
2274
3033
  var REQUIRED_FIELD_SYMBOL = "*";
2275
3034
  function Label(props) {
2276
3035
  const { label, required, id } = props;
2277
3036
  if (!label) {
2278
3037
  return null;
2279
3038
  }
2280
- return /* @__PURE__ */ jsxs8("label", { className: "control-label", htmlFor: id, children: [
3039
+ return /* @__PURE__ */ jsxs9("label", { className: "control-label", htmlFor: id, children: [
2281
3040
  label,
2282
- required && /* @__PURE__ */ jsx18("span", { className: "required", children: REQUIRED_FIELD_SYMBOL })
3041
+ required && /* @__PURE__ */ jsx22("span", { className: "required", children: REQUIRED_FIELD_SYMBOL })
2283
3042
  ] });
2284
3043
  }
2285
3044
 
2286
3045
  // src/components/templates/FieldTemplate/FieldTemplate.tsx
2287
- import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
3046
+ import { jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
2288
3047
  function FieldTemplate(props) {
2289
3048
  const { id, label, children, errors, help, description, hidden, required, displayLabel, registry, uiSchema } = props;
2290
- const uiOptions = getUiOptions10(uiSchema);
2291
- const WrapIfAdditionalTemplate2 = getTemplate7(
3049
+ const uiOptions = getUiOptions14(uiSchema);
3050
+ const WrapIfAdditionalTemplate2 = getTemplate11(
2292
3051
  "WrapIfAdditionalTemplate",
2293
3052
  registry,
2294
3053
  uiOptions
2295
3054
  );
2296
3055
  if (hidden) {
2297
- return /* @__PURE__ */ jsx19("div", { className: "hidden", children });
3056
+ return /* @__PURE__ */ jsx23("div", { className: "hidden", children });
2298
3057
  }
2299
- return /* @__PURE__ */ jsxs9(WrapIfAdditionalTemplate2, { ...props, children: [
2300
- displayLabel && /* @__PURE__ */ jsx19(Label, { label, required, id }),
3058
+ return /* @__PURE__ */ jsxs10(WrapIfAdditionalTemplate2, { ...props, children: [
3059
+ displayLabel && /* @__PURE__ */ jsx23(Label, { label, required, id }),
2301
3060
  displayLabel && description ? description : null,
2302
3061
  children,
2303
3062
  errors,
@@ -2310,21 +3069,21 @@ var FieldTemplate_default = FieldTemplate;
2310
3069
 
2311
3070
  // src/components/templates/FieldErrorTemplate.tsx
2312
3071
  import { errorId } from "@rjsf/utils";
2313
- import { jsx as jsx20 } from "react/jsx-runtime";
3072
+ import { jsx as jsx24 } from "react/jsx-runtime";
2314
3073
  function FieldErrorTemplate(props) {
2315
3074
  const { errors = [], idSchema } = props;
2316
3075
  if (errors.length === 0) {
2317
3076
  return null;
2318
3077
  }
2319
3078
  const id = errorId(idSchema);
2320
- return /* @__PURE__ */ jsx20("div", { children: /* @__PURE__ */ jsx20("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
2321
- return /* @__PURE__ */ jsx20("li", { className: "text-danger", children: error }, index);
3079
+ return /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsx24("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
3080
+ return /* @__PURE__ */ jsx24("li", { className: "text-danger", children: error }, index);
2322
3081
  }) }) });
2323
3082
  }
2324
3083
 
2325
3084
  // src/components/templates/FieldHelpTemplate.tsx
2326
3085
  import { helpId } from "@rjsf/utils";
2327
- import { jsx as jsx21 } from "react/jsx-runtime";
3086
+ import { jsx as jsx25 } from "react/jsx-runtime";
2328
3087
  function FieldHelpTemplate(props) {
2329
3088
  const { idSchema, help } = props;
2330
3089
  if (!help) {
@@ -2332,20 +3091,28 @@ function FieldHelpTemplate(props) {
2332
3091
  }
2333
3092
  const id = helpId(idSchema);
2334
3093
  if (typeof help === "string") {
2335
- return /* @__PURE__ */ jsx21("p", { id, className: "help-block", children: help });
3094
+ return /* @__PURE__ */ jsx25("p", { id, className: "help-block", children: help });
2336
3095
  }
2337
- return /* @__PURE__ */ jsx21("div", { id, className: "help-block", children: help });
3096
+ return /* @__PURE__ */ jsx25("div", { id, className: "help-block", children: help });
3097
+ }
3098
+
3099
+ // src/components/templates/GridTemplate.tsx
3100
+ import { jsx as jsx26 } from "react/jsx-runtime";
3101
+ function GridTemplate(props) {
3102
+ const { children, column, className, ...rest } = props;
3103
+ return /* @__PURE__ */ jsx26("div", { className, ...rest, children });
2338
3104
  }
2339
3105
 
2340
3106
  // src/components/templates/ObjectFieldTemplate.tsx
2341
3107
  import {
2342
3108
  canExpand,
2343
3109
  descriptionId as descriptionId3,
2344
- getTemplate as getTemplate8,
2345
- getUiOptions as getUiOptions11,
2346
- titleId as titleId2
3110
+ getTemplate as getTemplate12,
3111
+ getUiOptions as getUiOptions15,
3112
+ titleId as titleId3,
3113
+ buttonId as buttonId3
2347
3114
  } from "@rjsf/utils";
2348
- import { jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
3115
+ import { jsx as jsx27, jsxs as jsxs11 } from "react/jsx-runtime";
2349
3116
  function ObjectFieldTemplate(props) {
2350
3117
  const {
2351
3118
  description,
@@ -2361,9 +3128,9 @@ function ObjectFieldTemplate(props) {
2361
3128
  title,
2362
3129
  uiSchema
2363
3130
  } = props;
2364
- const options = getUiOptions11(uiSchema);
2365
- const TitleFieldTemplate = getTemplate8("TitleFieldTemplate", registry, options);
2366
- const DescriptionFieldTemplate = getTemplate8(
3131
+ const options = getUiOptions15(uiSchema);
3132
+ const TitleFieldTemplate = getTemplate12("TitleFieldTemplate", registry, options);
3133
+ const DescriptionFieldTemplate = getTemplate12(
2367
3134
  "DescriptionFieldTemplate",
2368
3135
  registry,
2369
3136
  options
@@ -2371,11 +3138,11 @@ function ObjectFieldTemplate(props) {
2371
3138
  const {
2372
3139
  ButtonTemplates: { AddButton: AddButton2 }
2373
3140
  } = registry.templates;
2374
- return /* @__PURE__ */ jsxs10("fieldset", { id: idSchema.$id, children: [
2375
- title && /* @__PURE__ */ jsx22(
3141
+ return /* @__PURE__ */ jsxs11("fieldset", { id: idSchema.$id, children: [
3142
+ title && /* @__PURE__ */ jsx27(
2376
3143
  TitleFieldTemplate,
2377
3144
  {
2378
- id: titleId2(idSchema),
3145
+ id: titleId3(idSchema),
2379
3146
  title,
2380
3147
  required,
2381
3148
  schema,
@@ -2383,7 +3150,7 @@ function ObjectFieldTemplate(props) {
2383
3150
  registry
2384
3151
  }
2385
3152
  ),
2386
- description && /* @__PURE__ */ jsx22(
3153
+ description && /* @__PURE__ */ jsx27(
2387
3154
  DescriptionFieldTemplate,
2388
3155
  {
2389
3156
  id: descriptionId3(idSchema),
@@ -2394,10 +3161,11 @@ function ObjectFieldTemplate(props) {
2394
3161
  }
2395
3162
  ),
2396
3163
  properties.map((prop) => prop.content),
2397
- canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx22(
3164
+ canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx27(
2398
3165
  AddButton2,
2399
3166
  {
2400
- className: "object-property-expand",
3167
+ id: buttonId3(idSchema, "add"),
3168
+ className: "rjsf-object-property-expand",
2401
3169
  onClick: onAddClick(schema),
2402
3170
  disabled: disabled || readonly,
2403
3171
  uiSchema,
@@ -2408,20 +3176,20 @@ function ObjectFieldTemplate(props) {
2408
3176
  }
2409
3177
 
2410
3178
  // src/components/templates/TitleField.tsx
2411
- import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
3179
+ import { jsx as jsx28, jsxs as jsxs12 } from "react/jsx-runtime";
2412
3180
  var REQUIRED_FIELD_SYMBOL2 = "*";
2413
3181
  function TitleField(props) {
2414
3182
  const { id, title, required } = props;
2415
- return /* @__PURE__ */ jsxs11("legend", { id, children: [
3183
+ return /* @__PURE__ */ jsxs12("legend", { id, children: [
2416
3184
  title,
2417
- required && /* @__PURE__ */ jsx23("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 })
3185
+ required && /* @__PURE__ */ jsx28("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 })
2418
3186
  ] });
2419
3187
  }
2420
3188
 
2421
3189
  // src/components/templates/UnsupportedField.tsx
2422
3190
  import { TranslatableString as TranslatableString9 } from "@rjsf/utils";
2423
3191
  import Markdown3 from "markdown-to-jsx";
2424
- import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
3192
+ import { jsx as jsx29, jsxs as jsxs13 } from "react/jsx-runtime";
2425
3193
  function UnsupportedField(props) {
2426
3194
  const { schema, idSchema, reason, registry } = props;
2427
3195
  const { translateString } = registry;
@@ -2435,9 +3203,9 @@ function UnsupportedField(props) {
2435
3203
  translateEnum = translateEnum === TranslatableString9.UnsupportedField ? TranslatableString9.UnsupportedFieldWithReason : TranslatableString9.UnsupportedFieldWithIdAndReason;
2436
3204
  translateParams.push(reason);
2437
3205
  }
2438
- return /* @__PURE__ */ jsxs12("div", { className: "unsupported-field", children: [
2439
- /* @__PURE__ */ jsx24("p", { children: /* @__PURE__ */ jsx24(Markdown3, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
2440
- schema && /* @__PURE__ */ jsx24("pre", { children: JSON.stringify(schema, null, 2) })
3206
+ return /* @__PURE__ */ jsxs13("div", { className: "unsupported-field", children: [
3207
+ /* @__PURE__ */ jsx29("p", { children: /* @__PURE__ */ jsx29(Markdown3, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
3208
+ schema && /* @__PURE__ */ jsx29("pre", { children: JSON.stringify(schema, null, 2) })
2441
3209
  ] });
2442
3210
  }
2443
3211
  var UnsupportedField_default = UnsupportedField;
@@ -2445,9 +3213,10 @@ var UnsupportedField_default = UnsupportedField;
2445
3213
  // src/components/templates/WrapIfAdditionalTemplate.tsx
2446
3214
  import {
2447
3215
  ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG3,
3216
+ buttonId as buttonId4,
2448
3217
  TranslatableString as TranslatableString10
2449
3218
  } from "@rjsf/utils";
2450
- import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
3219
+ import { jsx as jsx30, jsxs as jsxs14 } from "react/jsx-runtime";
2451
3220
  function WrapIfAdditionalTemplate(props) {
2452
3221
  const {
2453
3222
  id,
@@ -2460,6 +3229,8 @@ function WrapIfAdditionalTemplate(props) {
2460
3229
  readonly,
2461
3230
  required,
2462
3231
  schema,
3232
+ hideError,
3233
+ rawErrors,
2463
3234
  children,
2464
3235
  uiSchema,
2465
3236
  registry
@@ -2468,13 +3239,18 @@ function WrapIfAdditionalTemplate(props) {
2468
3239
  const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
2469
3240
  const keyLabel = translateString(TranslatableString10.KeyLabel, [label]);
2470
3241
  const additional = ADDITIONAL_PROPERTY_FLAG3 in schema;
3242
+ const classNamesList = ["form-group", classNames];
3243
+ if (!hideError && rawErrors && rawErrors.length > 0) {
3244
+ classNamesList.push("has-error has-danger");
3245
+ }
3246
+ const uiClassNames = classNamesList.join(" ").trim();
2471
3247
  if (!additional) {
2472
- return /* @__PURE__ */ jsx25("div", { className: classNames, style, children });
3248
+ return /* @__PURE__ */ jsx30("div", { className: uiClassNames, style, children });
2473
3249
  }
2474
- return /* @__PURE__ */ jsx25("div", { className: classNames, style, children: /* @__PURE__ */ jsxs13("div", { className: "row", children: [
2475
- /* @__PURE__ */ jsx25("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ jsxs13("div", { className: "form-group", children: [
2476
- /* @__PURE__ */ jsx25(Label, { label: keyLabel, required, id: `${id}-key` }),
2477
- /* @__PURE__ */ jsx25(
3250
+ return /* @__PURE__ */ jsx30("div", { className: uiClassNames, style, children: /* @__PURE__ */ jsxs14("div", { className: "row", children: [
3251
+ /* @__PURE__ */ jsx30("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ jsxs14("div", { className: "form-group", children: [
3252
+ /* @__PURE__ */ jsx30(Label, { label: keyLabel, required, id: `${id}-key` }),
3253
+ /* @__PURE__ */ jsx30(
2478
3254
  "input",
2479
3255
  {
2480
3256
  className: "form-control",
@@ -2485,11 +3261,12 @@ function WrapIfAdditionalTemplate(props) {
2485
3261
  }
2486
3262
  )
2487
3263
  ] }) }),
2488
- /* @__PURE__ */ jsx25("div", { className: "form-additional form-group col-xs-5", children }),
2489
- /* @__PURE__ */ jsx25("div", { className: "col-xs-2", children: /* @__PURE__ */ jsx25(
3264
+ /* @__PURE__ */ jsx30("div", { className: "form-additional form-group col-xs-5", children }),
3265
+ /* @__PURE__ */ jsx30("div", { className: "col-xs-2", children: /* @__PURE__ */ jsx30(
2490
3266
  RemoveButton2,
2491
3267
  {
2492
- className: "array-item-remove btn-block",
3268
+ id: buttonId4(id, "remove"),
3269
+ className: "rjsf-object-property-remove btn-block",
2493
3270
  style: { border: "0" },
2494
3271
  disabled: disabled || readonly,
2495
3272
  onClick: onDropPropertyClick(label),
@@ -2505,6 +3282,7 @@ function templates() {
2505
3282
  return {
2506
3283
  ArrayFieldDescriptionTemplate,
2507
3284
  ArrayFieldItemTemplate,
3285
+ ArrayFieldItemButtonsTemplate,
2508
3286
  ArrayFieldTemplate,
2509
3287
  ArrayFieldTitleTemplate,
2510
3288
  ButtonTemplates: ButtonTemplates_default(),
@@ -2514,6 +3292,7 @@ function templates() {
2514
3292
  FieldTemplate: FieldTemplate_default,
2515
3293
  FieldErrorTemplate,
2516
3294
  FieldHelpTemplate,
3295
+ GridTemplate,
2517
3296
  ObjectFieldTemplate,
2518
3297
  TitleFieldTemplate: TitleField,
2519
3298
  UnsupportedFieldTemplate: UnsupportedField_default,
@@ -2523,7 +3302,7 @@ function templates() {
2523
3302
  var templates_default = templates;
2524
3303
 
2525
3304
  // src/components/widgets/AltDateWidget.tsx
2526
- import { useCallback as useCallback4, useEffect as useEffect2, useReducer, useState as useState2 } from "react";
3305
+ import { useCallback as useCallback4, useEffect as useEffect3, useReducer, useState as useState3 } from "react";
2527
3306
  import {
2528
3307
  ariaDescribedByIds as ariaDescribedByIds2,
2529
3308
  dateRangeOptions,
@@ -2532,7 +3311,7 @@ import {
2532
3311
  TranslatableString as TranslatableString11,
2533
3312
  getDateElementProps
2534
3313
  } from "@rjsf/utils";
2535
- import { jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
3314
+ import { jsx as jsx31, jsxs as jsxs15 } from "react/jsx-runtime";
2536
3315
  function readyForChange(state) {
2537
3316
  return Object.values(state).every((value) => value !== -1);
2538
3317
  }
@@ -2552,7 +3331,7 @@ function DateElement({
2552
3331
  }) {
2553
3332
  const id = rootId + "_" + type;
2554
3333
  const { SelectWidget: SelectWidget2 } = registry.widgets;
2555
- return /* @__PURE__ */ jsx26(
3334
+ return /* @__PURE__ */ jsx31(
2556
3335
  SelectWidget2,
2557
3336
  {
2558
3337
  schema: { type: "integer" },
@@ -2589,11 +3368,14 @@ function AltDateWidget({
2589
3368
  value
2590
3369
  }) {
2591
3370
  const { translateString } = registry;
2592
- const [lastValue, setLastValue] = useState2(value);
2593
- const [state, setState] = useReducer((state2, action) => {
2594
- return { ...state2, ...action };
2595
- }, parseDateString(value, time));
2596
- useEffect2(() => {
3371
+ const [lastValue, setLastValue] = useState3(value);
3372
+ const [state, setState] = useReducer(
3373
+ (state2, action) => {
3374
+ return { ...state2, ...action };
3375
+ },
3376
+ parseDateString(value, time)
3377
+ );
3378
+ useEffect3(() => {
2597
3379
  const stateValue = toDateString(state, time);
2598
3380
  if (readyForChange(state) && stateValue !== value) {
2599
3381
  onChange(stateValue);
@@ -2626,13 +3408,13 @@ function AltDateWidget({
2626
3408
  },
2627
3409
  [disabled, readonly, onChange]
2628
3410
  );
2629
- return /* @__PURE__ */ jsxs14("ul", { className: "list-inline", children: [
3411
+ return /* @__PURE__ */ jsxs15("ul", { className: "list-inline", children: [
2630
3412
  getDateElementProps(
2631
3413
  state,
2632
3414
  time,
2633
3415
  options.yearsRange,
2634
3416
  options.format
2635
- ).map((elemProps, i) => /* @__PURE__ */ jsx26("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx26(
3417
+ ).map((elemProps, i) => /* @__PURE__ */ jsx31("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx31(
2636
3418
  DateElement,
2637
3419
  {
2638
3420
  rootId: id,
@@ -2647,20 +3429,20 @@ function AltDateWidget({
2647
3429
  autofocus: autofocus && i === 0
2648
3430
  }
2649
3431
  ) }, i)),
2650
- (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx26("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx26("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(TranslatableString11.NowLabel) }) }),
2651
- (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx26("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx26("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(TranslatableString11.ClearLabel) }) })
3432
+ (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx31("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx31("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(TranslatableString11.NowLabel) }) }),
3433
+ (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx31("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx31("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(TranslatableString11.ClearLabel) }) })
2652
3434
  ] });
2653
3435
  }
2654
3436
  var AltDateWidget_default = AltDateWidget;
2655
3437
 
2656
3438
  // src/components/widgets/AltDateTimeWidget.tsx
2657
- import { jsx as jsx27 } from "react/jsx-runtime";
3439
+ import { jsx as jsx32 } from "react/jsx-runtime";
2658
3440
  function AltDateTimeWidget({
2659
3441
  time = true,
2660
3442
  ...props
2661
3443
  }) {
2662
3444
  const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
2663
- return /* @__PURE__ */ jsx27(AltDateWidget2, { time, ...props });
3445
+ return /* @__PURE__ */ jsx32(AltDateWidget2, { time, ...props });
2664
3446
  }
2665
3447
  var AltDateTimeWidget_default = AltDateTimeWidget;
2666
3448
 
@@ -2669,11 +3451,11 @@ import { useCallback as useCallback5 } from "react";
2669
3451
  import {
2670
3452
  ariaDescribedByIds as ariaDescribedByIds3,
2671
3453
  descriptionId as descriptionId4,
2672
- getTemplate as getTemplate9,
3454
+ getTemplate as getTemplate13,
2673
3455
  labelValue,
2674
3456
  schemaRequiresTrueValue
2675
3457
  } from "@rjsf/utils";
2676
- import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
3458
+ import { jsx as jsx33, jsxs as jsxs16 } from "react/jsx-runtime";
2677
3459
  function CheckboxWidget({
2678
3460
  schema,
2679
3461
  uiSchema,
@@ -2690,7 +3472,7 @@ function CheckboxWidget({
2690
3472
  onChange,
2691
3473
  registry
2692
3474
  }) {
2693
- const DescriptionFieldTemplate = getTemplate9(
3475
+ const DescriptionFieldTemplate = getTemplate13(
2694
3476
  "DescriptionFieldTemplate",
2695
3477
  registry,
2696
3478
  options
@@ -2709,8 +3491,8 @@ function CheckboxWidget({
2709
3491
  [onFocus, id]
2710
3492
  );
2711
3493
  const description = options.description ?? schema.description;
2712
- return /* @__PURE__ */ jsxs15("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
2713
- !hideLabel && !!description && /* @__PURE__ */ jsx28(
3494
+ return /* @__PURE__ */ jsxs16("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
3495
+ !hideLabel && !!description && /* @__PURE__ */ jsx33(
2714
3496
  DescriptionFieldTemplate,
2715
3497
  {
2716
3498
  id: descriptionId4(id),
@@ -2720,8 +3502,8 @@ function CheckboxWidget({
2720
3502
  registry
2721
3503
  }
2722
3504
  ),
2723
- /* @__PURE__ */ jsxs15("label", { children: [
2724
- /* @__PURE__ */ jsx28(
3505
+ /* @__PURE__ */ jsxs16("label", { children: [
3506
+ /* @__PURE__ */ jsx33(
2725
3507
  "input",
2726
3508
  {
2727
3509
  type: "checkbox",
@@ -2737,7 +3519,7 @@ function CheckboxWidget({
2737
3519
  "aria-describedby": ariaDescribedByIds3(id)
2738
3520
  }
2739
3521
  ),
2740
- labelValue(/* @__PURE__ */ jsx28("span", { children: label }), hideLabel)
3522
+ labelValue(/* @__PURE__ */ jsx33("span", { children: label }), hideLabel)
2741
3523
  ] })
2742
3524
  ] });
2743
3525
  }
@@ -2753,7 +3535,7 @@ import {
2753
3535
  enumOptionsValueForIndex,
2754
3536
  optionId
2755
3537
  } from "@rjsf/utils";
2756
- import { jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
3538
+ import { jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
2757
3539
  function CheckboxesWidget({
2758
3540
  id,
2759
3541
  disabled,
@@ -2774,7 +3556,7 @@ function CheckboxesWidget({
2774
3556
  ({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
2775
3557
  [onFocus, id]
2776
3558
  );
2777
- return /* @__PURE__ */ jsx29("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
3559
+ return /* @__PURE__ */ jsx34("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
2778
3560
  const checked = enumOptionsIsSelected(option.value, checkboxesValues);
2779
3561
  const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
2780
3562
  const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
@@ -2785,8 +3567,8 @@ function CheckboxesWidget({
2785
3567
  onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
2786
3568
  }
2787
3569
  };
2788
- const checkbox = /* @__PURE__ */ jsxs16("span", { children: [
2789
- /* @__PURE__ */ jsx29(
3570
+ const checkbox = /* @__PURE__ */ jsxs17("span", { children: [
3571
+ /* @__PURE__ */ jsx34(
2790
3572
  "input",
2791
3573
  {
2792
3574
  type: "checkbox",
@@ -2802,44 +3584,44 @@ function CheckboxesWidget({
2802
3584
  "aria-describedby": ariaDescribedByIds4(id)
2803
3585
  }
2804
3586
  ),
2805
- /* @__PURE__ */ jsx29("span", { children: option.label })
3587
+ /* @__PURE__ */ jsx34("span", { children: option.label })
2806
3588
  ] });
2807
- return inline ? /* @__PURE__ */ jsx29("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ jsx29("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsx29("label", { children: checkbox }) }, index);
3589
+ return inline ? /* @__PURE__ */ jsx34("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ jsx34("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsx34("label", { children: checkbox }) }, index);
2808
3590
  }) });
2809
3591
  }
2810
3592
  var CheckboxesWidget_default = CheckboxesWidget;
2811
3593
 
2812
3594
  // src/components/widgets/ColorWidget.tsx
2813
- import { getTemplate as getTemplate10 } from "@rjsf/utils";
2814
- import { jsx as jsx30 } from "react/jsx-runtime";
3595
+ import { getTemplate as getTemplate14 } from "@rjsf/utils";
3596
+ import { jsx as jsx35 } from "react/jsx-runtime";
2815
3597
  function ColorWidget(props) {
2816
3598
  const { disabled, readonly, options, registry } = props;
2817
- const BaseInputTemplate2 = getTemplate10("BaseInputTemplate", registry, options);
2818
- return /* @__PURE__ */ jsx30(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
3599
+ const BaseInputTemplate2 = getTemplate14("BaseInputTemplate", registry, options);
3600
+ return /* @__PURE__ */ jsx35(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
2819
3601
  }
2820
3602
 
2821
3603
  // src/components/widgets/DateWidget.tsx
2822
3604
  import { useCallback as useCallback7 } from "react";
2823
- import { getTemplate as getTemplate11 } from "@rjsf/utils";
2824
- import { jsx as jsx31 } from "react/jsx-runtime";
3605
+ import { getTemplate as getTemplate15 } from "@rjsf/utils";
3606
+ import { jsx as jsx36 } from "react/jsx-runtime";
2825
3607
  function DateWidget(props) {
2826
3608
  const { onChange, options, registry } = props;
2827
- const BaseInputTemplate2 = getTemplate11("BaseInputTemplate", registry, options);
3609
+ const BaseInputTemplate2 = getTemplate15("BaseInputTemplate", registry, options);
2828
3610
  const handleChange = useCallback7((value) => onChange(value || void 0), [onChange]);
2829
- return /* @__PURE__ */ jsx31(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
3611
+ return /* @__PURE__ */ jsx36(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
2830
3612
  }
2831
3613
 
2832
3614
  // src/components/widgets/DateTimeWidget.tsx
2833
3615
  import {
2834
- getTemplate as getTemplate12,
3616
+ getTemplate as getTemplate16,
2835
3617
  localToUTC,
2836
3618
  utcToLocal
2837
3619
  } from "@rjsf/utils";
2838
- import { jsx as jsx32 } from "react/jsx-runtime";
3620
+ import { jsx as jsx37 } from "react/jsx-runtime";
2839
3621
  function DateTimeWidget(props) {
2840
3622
  const { onChange, value, options, registry } = props;
2841
- const BaseInputTemplate2 = getTemplate12("BaseInputTemplate", registry, options);
2842
- return /* @__PURE__ */ jsx32(
3623
+ const BaseInputTemplate2 = getTemplate16("BaseInputTemplate", registry, options);
3624
+ return /* @__PURE__ */ jsx37(
2843
3625
  BaseInputTemplate2,
2844
3626
  {
2845
3627
  type: "datetime-local",
@@ -2851,23 +3633,23 @@ function DateTimeWidget(props) {
2851
3633
  }
2852
3634
 
2853
3635
  // src/components/widgets/EmailWidget.tsx
2854
- import { getTemplate as getTemplate13 } from "@rjsf/utils";
2855
- import { jsx as jsx33 } from "react/jsx-runtime";
3636
+ import { getTemplate as getTemplate17 } from "@rjsf/utils";
3637
+ import { jsx as jsx38 } from "react/jsx-runtime";
2856
3638
  function EmailWidget(props) {
2857
3639
  const { options, registry } = props;
2858
- const BaseInputTemplate2 = getTemplate13("BaseInputTemplate", registry, options);
2859
- return /* @__PURE__ */ jsx33(BaseInputTemplate2, { type: "email", ...props });
3640
+ const BaseInputTemplate2 = getTemplate17("BaseInputTemplate", registry, options);
3641
+ return /* @__PURE__ */ jsx38(BaseInputTemplate2, { type: "email", ...props });
2860
3642
  }
2861
3643
 
2862
3644
  // src/components/widgets/FileWidget.tsx
2863
- import { useCallback as useCallback8, useMemo } from "react";
3645
+ import { useCallback as useCallback8, useMemo as useMemo2 } from "react";
2864
3646
  import {
2865
3647
  dataURItoBlob,
2866
- getTemplate as getTemplate14,
3648
+ getTemplate as getTemplate18,
2867
3649
  TranslatableString as TranslatableString12
2868
3650
  } from "@rjsf/utils";
2869
3651
  import Markdown4 from "markdown-to-jsx";
2870
- import { Fragment as Fragment3, jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
3652
+ import { Fragment as Fragment4, jsx as jsx39, jsxs as jsxs18 } from "react/jsx-runtime";
2871
3653
  function addNameToDataURL(dataURL, name) {
2872
3654
  if (dataURL === null) {
2873
3655
  return null;
@@ -2912,11 +3694,11 @@ function FileInfoPreview({
2912
3694
  return null;
2913
3695
  }
2914
3696
  if (["image/jpeg", "image/png"].includes(type)) {
2915
- return /* @__PURE__ */ jsx34("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
3697
+ return /* @__PURE__ */ jsx39("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
2916
3698
  }
2917
- return /* @__PURE__ */ jsxs17(Fragment3, { children: [
3699
+ return /* @__PURE__ */ jsxs18(Fragment4, { children: [
2918
3700
  " ",
2919
- /* @__PURE__ */ jsx34("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(TranslatableString12.PreviewLabel) })
3701
+ /* @__PURE__ */ jsx39("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(TranslatableString12.PreviewLabel) })
2920
3702
  ] });
2921
3703
  }
2922
3704
  function FilesInfo({
@@ -2930,14 +3712,14 @@ function FilesInfo({
2930
3712
  return null;
2931
3713
  }
2932
3714
  const { translateString } = registry;
2933
- const { RemoveButton: RemoveButton2 } = getTemplate14("ButtonTemplates", registry, options);
2934
- return /* @__PURE__ */ jsx34("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
3715
+ const { RemoveButton: RemoveButton2 } = getTemplate18("ButtonTemplates", registry, options);
3716
+ return /* @__PURE__ */ jsx39("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
2935
3717
  const { name, size, type } = fileInfo;
2936
3718
  const handleRemove = () => onRemove(key);
2937
- return /* @__PURE__ */ jsxs17("li", { children: [
2938
- /* @__PURE__ */ jsx34(Markdown4, { children: translateString(TranslatableString12.FilesInfo, [name, type, String(size)]) }),
2939
- preview && /* @__PURE__ */ jsx34(FileInfoPreview, { fileInfo, registry }),
2940
- /* @__PURE__ */ jsx34(RemoveButton2, { onClick: handleRemove, registry })
3719
+ return /* @__PURE__ */ jsxs18("li", { children: [
3720
+ /* @__PURE__ */ jsx39(Markdown4, { children: translateString(TranslatableString12.FilesInfo, [name, type, String(size)]) }),
3721
+ preview && /* @__PURE__ */ jsx39(FileInfoPreview, { fileInfo, registry }),
3722
+ /* @__PURE__ */ jsx39(RemoveButton2, { onClick: handleRemove, registry })
2941
3723
  ] }, key);
2942
3724
  }) });
2943
3725
  }
@@ -2957,14 +3739,14 @@ function extractFileInfo(dataURLs) {
2957
3739
  type: blob.type
2958
3740
  }
2959
3741
  ];
2960
- } catch (e) {
3742
+ } catch {
2961
3743
  return acc;
2962
3744
  }
2963
3745
  }, []);
2964
3746
  }
2965
3747
  function FileWidget(props) {
2966
3748
  const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
2967
- const BaseInputTemplate2 = getTemplate14("BaseInputTemplate", registry, options);
3749
+ const BaseInputTemplate2 = getTemplate18("BaseInputTemplate", registry, options);
2968
3750
  const handleChange = useCallback8(
2969
3751
  (event) => {
2970
3752
  if (!event.target.files) {
@@ -2973,7 +3755,7 @@ function FileWidget(props) {
2973
3755
  processFiles(event.target.files).then((filesInfoEvent) => {
2974
3756
  const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
2975
3757
  if (multiple) {
2976
- onChange(value.concat(newValue[0]));
3758
+ onChange(value.concat(newValue));
2977
3759
  } else {
2978
3760
  onChange(newValue[0]);
2979
3761
  }
@@ -2981,7 +3763,7 @@ function FileWidget(props) {
2981
3763
  },
2982
3764
  [multiple, value, onChange]
2983
3765
  );
2984
- const filesInfo = useMemo(() => extractFileInfo(Array.isArray(value) ? value : [value]), [value]);
3766
+ const filesInfo = useMemo2(() => extractFileInfo(Array.isArray(value) ? value : [value]), [value]);
2985
3767
  const rmFile = useCallback8(
2986
3768
  (index) => {
2987
3769
  if (multiple) {
@@ -2993,8 +3775,8 @@ function FileWidget(props) {
2993
3775
  },
2994
3776
  [multiple, value, onChange]
2995
3777
  );
2996
- return /* @__PURE__ */ jsxs17("div", { children: [
2997
- /* @__PURE__ */ jsx34(
3778
+ return /* @__PURE__ */ jsxs18("div", { children: [
3779
+ /* @__PURE__ */ jsx39(
2998
3780
  BaseInputTemplate2,
2999
3781
  {
3000
3782
  ...props,
@@ -3006,7 +3788,7 @@ function FileWidget(props) {
3006
3788
  accept: options.accept ? String(options.accept) : void 0
3007
3789
  }
3008
3790
  ),
3009
- /* @__PURE__ */ jsx34(
3791
+ /* @__PURE__ */ jsx39(
3010
3792
  FilesInfo,
3011
3793
  {
3012
3794
  filesInfo,
@@ -3021,22 +3803,22 @@ function FileWidget(props) {
3021
3803
  var FileWidget_default = FileWidget;
3022
3804
 
3023
3805
  // src/components/widgets/HiddenWidget.tsx
3024
- import { jsx as jsx35 } from "react/jsx-runtime";
3806
+ import { jsx as jsx40 } from "react/jsx-runtime";
3025
3807
  function HiddenWidget({
3026
3808
  id,
3027
3809
  value
3028
3810
  }) {
3029
- return /* @__PURE__ */ jsx35("input", { type: "hidden", id, name: id, value: typeof value === "undefined" ? "" : value });
3811
+ return /* @__PURE__ */ jsx40("input", { type: "hidden", id, name: id, value: typeof value === "undefined" ? "" : value });
3030
3812
  }
3031
3813
  var HiddenWidget_default = HiddenWidget;
3032
3814
 
3033
3815
  // src/components/widgets/PasswordWidget.tsx
3034
- import { getTemplate as getTemplate15 } from "@rjsf/utils";
3035
- import { jsx as jsx36 } from "react/jsx-runtime";
3816
+ import { getTemplate as getTemplate19 } from "@rjsf/utils";
3817
+ import { jsx as jsx41 } from "react/jsx-runtime";
3036
3818
  function PasswordWidget(props) {
3037
3819
  const { options, registry } = props;
3038
- const BaseInputTemplate2 = getTemplate15("BaseInputTemplate", registry, options);
3039
- return /* @__PURE__ */ jsx36(BaseInputTemplate2, { type: "password", ...props });
3820
+ const BaseInputTemplate2 = getTemplate19("BaseInputTemplate", registry, options);
3821
+ return /* @__PURE__ */ jsx41(BaseInputTemplate2, { type: "password", ...props });
3040
3822
  }
3041
3823
 
3042
3824
  // src/components/widgets/RadioWidget.tsx
@@ -3047,7 +3829,7 @@ import {
3047
3829
  enumOptionsValueForIndex as enumOptionsValueForIndex2,
3048
3830
  optionId as optionId2
3049
3831
  } from "@rjsf/utils";
3050
- import { jsx as jsx37, jsxs as jsxs18 } from "react/jsx-runtime";
3832
+ import { jsx as jsx42, jsxs as jsxs19 } from "react/jsx-runtime";
3051
3833
  function RadioWidget({
3052
3834
  options,
3053
3835
  value,
@@ -3063,19 +3845,19 @@ function RadioWidget({
3063
3845
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
3064
3846
  const handleBlur = useCallback9(
3065
3847
  ({ target }) => onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue)),
3066
- [onBlur, id]
3848
+ [onBlur, enumOptions, emptyValue, id]
3067
3849
  );
3068
3850
  const handleFocus = useCallback9(
3069
3851
  ({ target }) => onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue)),
3070
- [onFocus, id]
3852
+ [onFocus, enumOptions, emptyValue, id]
3071
3853
  );
3072
- return /* @__PURE__ */ jsx37("div", { className: "field-radio-group", id, children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
3854
+ return /* @__PURE__ */ jsx42("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
3073
3855
  const checked = enumOptionsIsSelected2(option.value, value);
3074
3856
  const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
3075
3857
  const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
3076
3858
  const handleChange = () => onChange(option.value);
3077
- const radio = /* @__PURE__ */ jsxs18("span", { children: [
3078
- /* @__PURE__ */ jsx37(
3859
+ const radio = /* @__PURE__ */ jsxs19("span", { children: [
3860
+ /* @__PURE__ */ jsx42(
3079
3861
  "input",
3080
3862
  {
3081
3863
  type: "radio",
@@ -3092,15 +3874,15 @@ function RadioWidget({
3092
3874
  "aria-describedby": ariaDescribedByIds5(id)
3093
3875
  }
3094
3876
  ),
3095
- /* @__PURE__ */ jsx37("span", { children: option.label })
3877
+ /* @__PURE__ */ jsx42("span", { children: option.label })
3096
3878
  ] });
3097
- return inline ? /* @__PURE__ */ jsx37("label", { className: `radio-inline ${disabledCls}`, children: radio }, i) : /* @__PURE__ */ jsx37("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsx37("label", { children: radio }) }, i);
3879
+ return inline ? /* @__PURE__ */ jsx42("label", { className: `radio-inline ${disabledCls}`, children: radio }, i) : /* @__PURE__ */ jsx42("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsx42("label", { children: radio }) }, i);
3098
3880
  }) });
3099
3881
  }
3100
3882
  var RadioWidget_default = RadioWidget;
3101
3883
 
3102
3884
  // src/components/widgets/RangeWidget.tsx
3103
- import { jsx as jsx38, jsxs as jsxs19 } from "react/jsx-runtime";
3885
+ import { jsx as jsx43, jsxs as jsxs20 } from "react/jsx-runtime";
3104
3886
  function RangeWidget(props) {
3105
3887
  const {
3106
3888
  value,
@@ -3108,20 +3890,123 @@ function RangeWidget(props) {
3108
3890
  templates: { BaseInputTemplate: BaseInputTemplate2 }
3109
3891
  }
3110
3892
  } = props;
3111
- return /* @__PURE__ */ jsxs19("div", { className: "field-range-wrapper", children: [
3112
- /* @__PURE__ */ jsx38(BaseInputTemplate2, { type: "range", ...props }),
3113
- /* @__PURE__ */ jsx38("span", { className: "range-view", children: value })
3893
+ return /* @__PURE__ */ jsxs20("div", { className: "field-range-wrapper", children: [
3894
+ /* @__PURE__ */ jsx43(BaseInputTemplate2, { type: "range", ...props }),
3895
+ /* @__PURE__ */ jsx43("span", { className: "range-view", children: value })
3114
3896
  ] });
3115
3897
  }
3116
3898
 
3117
- // src/components/widgets/SelectWidget.tsx
3899
+ // src/components/widgets/RatingWidget.tsx
3118
3900
  import { useCallback as useCallback10 } from "react";
3901
+ import { Fragment as Fragment5, jsx as jsx44, jsxs as jsxs21 } from "react/jsx-runtime";
3902
+ function RatingWidget({
3903
+ id,
3904
+ value,
3905
+ required,
3906
+ disabled,
3907
+ readonly,
3908
+ autofocus,
3909
+ onChange,
3910
+ onFocus,
3911
+ onBlur,
3912
+ schema,
3913
+ options
3914
+ }) {
3915
+ const { stars = 5, shape = "star" } = options;
3916
+ const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
3917
+ const min = schema.minimum || 0;
3918
+ const handleStarClick = useCallback10(
3919
+ (starValue) => {
3920
+ if (!disabled && !readonly) {
3921
+ onChange(starValue);
3922
+ }
3923
+ },
3924
+ [onChange, disabled, readonly]
3925
+ );
3926
+ const handleFocus = useCallback10(
3927
+ (event) => {
3928
+ if (onFocus) {
3929
+ const starValue = Number(event.target.dataset.value);
3930
+ onFocus(id, starValue);
3931
+ }
3932
+ },
3933
+ [onFocus, id]
3934
+ );
3935
+ const handleBlur = useCallback10(
3936
+ (event) => {
3937
+ if (onBlur) {
3938
+ const starValue = Number(event.target.dataset.value);
3939
+ onBlur(id, starValue);
3940
+ }
3941
+ },
3942
+ [onBlur, id]
3943
+ );
3944
+ const getSymbol = (isFilled) => {
3945
+ if (shape === "heart") {
3946
+ return isFilled ? "\u2665" : "\u2661";
3947
+ }
3948
+ return isFilled ? "\u2605" : "\u2606";
3949
+ };
3950
+ return /* @__PURE__ */ jsx44(Fragment5, { children: /* @__PURE__ */ jsxs21(
3951
+ "div",
3952
+ {
3953
+ className: "rating-widget",
3954
+ style: {
3955
+ display: "inline-flex",
3956
+ fontSize: "1.5rem",
3957
+ cursor: disabled || readonly ? "default" : "pointer"
3958
+ },
3959
+ children: [
3960
+ [...Array(numStars)].map((_, index) => {
3961
+ const starValue = min + index;
3962
+ const isFilled = starValue <= value;
3963
+ return /* @__PURE__ */ jsx44(
3964
+ "span",
3965
+ {
3966
+ onClick: () => handleStarClick(starValue),
3967
+ onFocus: handleFocus,
3968
+ onBlur: handleBlur,
3969
+ "data-value": starValue,
3970
+ tabIndex: disabled || readonly ? -1 : 0,
3971
+ role: "radio",
3972
+ "aria-checked": starValue === value,
3973
+ "aria-label": `${starValue} ${shape === "heart" ? "heart" : "star"}${starValue === 1 ? "" : "s"}`,
3974
+ style: {
3975
+ color: isFilled ? "#FFD700" : "#ccc",
3976
+ padding: "0 0.2rem",
3977
+ transition: "color 0.2s",
3978
+ userSelect: "none"
3979
+ },
3980
+ children: getSymbol(isFilled)
3981
+ },
3982
+ index
3983
+ );
3984
+ }),
3985
+ /* @__PURE__ */ jsx44(
3986
+ "input",
3987
+ {
3988
+ type: "hidden",
3989
+ id,
3990
+ name: id,
3991
+ value: value || "",
3992
+ required,
3993
+ disabled: disabled || readonly,
3994
+ "aria-hidden": "true"
3995
+ }
3996
+ )
3997
+ ]
3998
+ }
3999
+ ) });
4000
+ }
4001
+
4002
+ // src/components/widgets/SelectWidget.tsx
4003
+ import { useCallback as useCallback11 } from "react";
3119
4004
  import {
3120
4005
  ariaDescribedByIds as ariaDescribedByIds6,
3121
4006
  enumOptionsIndexForValue,
3122
4007
  enumOptionsValueForIndex as enumOptionsValueForIndex3
3123
4008
  } from "@rjsf/utils";
3124
- import { jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
4009
+ import { jsx as jsx45, jsxs as jsxs22 } from "react/jsx-runtime";
3125
4010
  function getValue(event, multiple) {
3126
4011
  if (multiple) {
3127
4012
  return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
@@ -3145,35 +4030,36 @@ function SelectWidget({
3145
4030
  }) {
3146
4031
  const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
3147
4032
  const emptyValue = multiple ? [] : "";
3148
- const handleFocus = useCallback10(
4033
+ const handleFocus = useCallback11(
3149
4034
  (event) => {
3150
4035
  const newValue = getValue(event, multiple);
3151
4036
  return onFocus(id, enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
3152
4037
  },
3153
- [onFocus, id, schema, multiple, enumOptions, optEmptyVal]
4038
+ [onFocus, id, multiple, enumOptions, optEmptyVal]
3154
4039
  );
3155
- const handleBlur = useCallback10(
4040
+ const handleBlur = useCallback11(
3156
4041
  (event) => {
3157
4042
  const newValue = getValue(event, multiple);
3158
4043
  return onBlur(id, enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
3159
4044
  },
3160
- [onBlur, id, schema, multiple, enumOptions, optEmptyVal]
4045
+ [onBlur, id, multiple, enumOptions, optEmptyVal]
3161
4046
  );
3162
- const handleChange = useCallback10(
4047
+ const handleChange = useCallback11(
3163
4048
  (event) => {
3164
4049
  const newValue = getValue(event, multiple);
3165
4050
  return onChange(enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
3166
4051
  },
3167
- [onChange, schema, multiple, enumOptions, optEmptyVal]
4052
+ [onChange, multiple, enumOptions, optEmptyVal]
3168
4053
  );
3169
4054
  const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
3170
4055
  const showPlaceholderOption = !multiple && schema.default === void 0;
3171
- return /* @__PURE__ */ jsxs20(
4056
+ return /* @__PURE__ */ jsxs22(
3172
4057
  "select",
3173
4058
  {
3174
4059
  id,
3175
4060
  name: id,
3176
4061
  multiple,
4062
+ role: "combobox",
3177
4063
  className: "form-control",
3178
4064
  value: typeof selectedIndexes === "undefined" ? emptyValue : selectedIndexes,
3179
4065
  required,
@@ -3184,10 +4070,10 @@ function SelectWidget({
3184
4070
  onChange: handleChange,
3185
4071
  "aria-describedby": ariaDescribedByIds6(id),
3186
4072
  children: [
3187
- showPlaceholderOption && /* @__PURE__ */ jsx39("option", { value: "", children: placeholder }),
4073
+ showPlaceholderOption && /* @__PURE__ */ jsx45("option", { value: "", children: placeholder }),
3188
4074
  Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label }, i) => {
3189
4075
  const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
3190
- return /* @__PURE__ */ jsx39("option", { value: String(i), disabled: disabled2, children: label }, i);
4076
+ return /* @__PURE__ */ jsx45("option", { value: String(i), disabled: disabled2, children: label }, i);
3191
4077
  })
3192
4078
  ]
3193
4079
  }
@@ -3196,9 +4082,9 @@ function SelectWidget({
3196
4082
  var SelectWidget_default = SelectWidget;
3197
4083
 
3198
4084
  // src/components/widgets/TextareaWidget.tsx
3199
- import { useCallback as useCallback11 } from "react";
4085
+ import { useCallback as useCallback12 } from "react";
3200
4086
  import { ariaDescribedByIds as ariaDescribedByIds7 } from "@rjsf/utils";
3201
- import { jsx as jsx40 } from "react/jsx-runtime";
4087
+ import { jsx as jsx46 } from "react/jsx-runtime";
3202
4088
  function TextareaWidget({
3203
4089
  id,
3204
4090
  options = {},
@@ -3212,19 +4098,19 @@ function TextareaWidget({
3212
4098
  onBlur,
3213
4099
  onFocus
3214
4100
  }) {
3215
- const handleChange = useCallback11(
4101
+ const handleChange = useCallback12(
3216
4102
  ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
3217
4103
  [onChange, options.emptyValue]
3218
4104
  );
3219
- const handleBlur = useCallback11(
4105
+ const handleBlur = useCallback12(
3220
4106
  ({ target }) => onBlur(id, target && target.value),
3221
4107
  [onBlur, id]
3222
4108
  );
3223
- const handleFocus = useCallback11(
4109
+ const handleFocus = useCallback12(
3224
4110
  ({ target }) => onFocus(id, target && target.value),
3225
4111
  [id, onFocus]
3226
4112
  );
3227
- return /* @__PURE__ */ jsx40(
4113
+ return /* @__PURE__ */ jsx46(
3228
4114
  "textarea",
3229
4115
  {
3230
4116
  id,
@@ -3251,41 +4137,41 @@ TextareaWidget.defaultProps = {
3251
4137
  var TextareaWidget_default = TextareaWidget;
3252
4138
 
3253
4139
  // src/components/widgets/TextWidget.tsx
3254
- import { getTemplate as getTemplate16 } from "@rjsf/utils";
3255
- import { jsx as jsx41 } from "react/jsx-runtime";
4140
+ import { getTemplate as getTemplate20 } from "@rjsf/utils";
4141
+ import { jsx as jsx47 } from "react/jsx-runtime";
3256
4142
  function TextWidget(props) {
3257
4143
  const { options, registry } = props;
3258
- const BaseInputTemplate2 = getTemplate16("BaseInputTemplate", registry, options);
3259
- return /* @__PURE__ */ jsx41(BaseInputTemplate2, { ...props });
4144
+ const BaseInputTemplate2 = getTemplate20("BaseInputTemplate", registry, options);
4145
+ return /* @__PURE__ */ jsx47(BaseInputTemplate2, { ...props });
3260
4146
  }
3261
4147
 
3262
4148
  // src/components/widgets/TimeWidget.tsx
3263
- import { useCallback as useCallback12 } from "react";
3264
- import { getTemplate as getTemplate17 } from "@rjsf/utils";
3265
- import { jsx as jsx42 } from "react/jsx-runtime";
4149
+ import { useCallback as useCallback13 } from "react";
4150
+ import { getTemplate as getTemplate21 } from "@rjsf/utils";
4151
+ import { jsx as jsx48 } from "react/jsx-runtime";
3266
4152
  function TimeWidget(props) {
3267
4153
  const { onChange, options, registry } = props;
3268
- const BaseInputTemplate2 = getTemplate17("BaseInputTemplate", registry, options);
3269
- const handleChange = useCallback12((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
3270
- return /* @__PURE__ */ jsx42(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
4154
+ const BaseInputTemplate2 = getTemplate21("BaseInputTemplate", registry, options);
4155
+ const handleChange = useCallback13((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
4156
+ return /* @__PURE__ */ jsx48(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
3271
4157
  }
3272
4158
 
3273
4159
  // src/components/widgets/URLWidget.tsx
3274
- import { getTemplate as getTemplate18 } from "@rjsf/utils";
3275
- import { jsx as jsx43 } from "react/jsx-runtime";
4160
+ import { getTemplate as getTemplate22 } from "@rjsf/utils";
4161
+ import { jsx as jsx49 } from "react/jsx-runtime";
3276
4162
  function URLWidget(props) {
3277
4163
  const { options, registry } = props;
3278
- const BaseInputTemplate2 = getTemplate18("BaseInputTemplate", registry, options);
3279
- return /* @__PURE__ */ jsx43(BaseInputTemplate2, { type: "url", ...props });
4164
+ const BaseInputTemplate2 = getTemplate22("BaseInputTemplate", registry, options);
4165
+ return /* @__PURE__ */ jsx49(BaseInputTemplate2, { type: "url", ...props });
3280
4166
  }
3281
4167
 
3282
4168
  // src/components/widgets/UpDownWidget.tsx
3283
- import { getTemplate as getTemplate19 } from "@rjsf/utils";
3284
- import { jsx as jsx44 } from "react/jsx-runtime";
4169
+ import { getTemplate as getTemplate23 } from "@rjsf/utils";
4170
+ import { jsx as jsx50 } from "react/jsx-runtime";
3285
4171
  function UpDownWidget(props) {
3286
4172
  const { options, registry } = props;
3287
- const BaseInputTemplate2 = getTemplate19("BaseInputTemplate", registry, options);
3288
- return /* @__PURE__ */ jsx44(BaseInputTemplate2, { type: "number", ...props });
4173
+ const BaseInputTemplate2 = getTemplate23("BaseInputTemplate", registry, options);
4174
+ return /* @__PURE__ */ jsx50(BaseInputTemplate2, { type: "number", ...props });
3289
4175
  }
3290
4176
 
3291
4177
  // src/components/widgets/index.ts
@@ -3304,6 +4190,7 @@ function widgets() {
3304
4190
  PasswordWidget,
3305
4191
  RadioWidget: RadioWidget_default,
3306
4192
  RangeWidget,
4193
+ RatingWidget,
3307
4194
  SelectWidget: SelectWidget_default,
3308
4195
  TextWidget,
3309
4196
  TextareaWidget: TextareaWidget_default,
@@ -3327,8 +4214,12 @@ function getDefaultRegistry() {
3327
4214
  }
3328
4215
 
3329
4216
  // src/components/Form.tsx
3330
- import { jsx as jsx45, jsxs as jsxs21 } from "react/jsx-runtime";
4217
+ import { jsx as jsx51, jsxs as jsxs23 } from "react/jsx-runtime";
3331
4218
  var Form = class extends Component5 {
4219
+ /** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
4220
+ * provide any possible type here
4221
+ */
4222
+ formElement;
3332
4223
  /** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
3333
4224
  * `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
3334
4225
  * state construction.
@@ -3337,270 +4228,6 @@ var Form = class extends Component5 {
3337
4228
  */
3338
4229
  constructor(props) {
3339
4230
  super(props);
3340
- /** Returns the `formData` with only the elements specified in the `fields` list
3341
- *
3342
- * @param formData - The data for the `Form`
3343
- * @param fields - The fields to keep while filtering
3344
- */
3345
- this.getUsedFormData = (formData, fields2) => {
3346
- if (fields2.length === 0 && typeof formData !== "object") {
3347
- return formData;
3348
- }
3349
- const data = _pick(formData, fields2);
3350
- if (Array.isArray(formData)) {
3351
- return Object.keys(data).map((key) => data[key]);
3352
- }
3353
- return data;
3354
- };
3355
- /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
3356
- *
3357
- * @param pathSchema - The `PathSchema` object for the form
3358
- * @param [formData] - The form data to use while checking for empty objects/arrays
3359
- */
3360
- this.getFieldNames = (pathSchema, formData) => {
3361
- const getAllPaths = (_obj, acc = [], paths = [[]]) => {
3362
- Object.keys(_obj).forEach((key) => {
3363
- if (typeof _obj[key] === "object") {
3364
- const newPaths = paths.map((path) => [...path, key]);
3365
- if (_obj[key][RJSF_ADDITIONAL_PROPERTIES_FLAG] && _obj[key][NAME_KEY] !== "") {
3366
- acc.push(_obj[key][NAME_KEY]);
3367
- } else {
3368
- getAllPaths(_obj[key], acc, newPaths);
3369
- }
3370
- } else if (key === NAME_KEY && _obj[key] !== "") {
3371
- paths.forEach((path) => {
3372
- const formValue = _get(formData, path);
3373
- if (typeof formValue !== "object" || _isEmpty(formValue) || Array.isArray(formValue) && formValue.every((val) => typeof val !== "object")) {
3374
- acc.push(path);
3375
- }
3376
- });
3377
- }
3378
- });
3379
- return acc;
3380
- };
3381
- return getAllPaths(pathSchema);
3382
- };
3383
- /** Returns the `formData` after filtering to remove any extra data not in a form field
3384
- *
3385
- * @param formData - The data for the `Form`
3386
- * @returns The `formData` after omitting extra data
3387
- */
3388
- this.omitExtraData = (formData) => {
3389
- const { schema, schemaUtils } = this.state;
3390
- const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
3391
- const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
3392
- const fieldNames = this.getFieldNames(pathSchema, formData);
3393
- const newFormData = this.getUsedFormData(formData, fieldNames);
3394
- return newFormData;
3395
- };
3396
- /** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
3397
- * `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
3398
- * then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
3399
- * in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
3400
- * updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
3401
- * callback will be called if specified with the updated state.
3402
- *
3403
- * @param formData - The new form data from a change to a field
3404
- * @param newErrorSchema - The new `ErrorSchema` based on the field change
3405
- * @param id - The id of the field that caused the change
3406
- */
3407
- this.onChange = (formData, newErrorSchema, id) => {
3408
- const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
3409
- const { schemaUtils, schema, retrievedSchema } = this.state;
3410
- if (isObject5(formData) || Array.isArray(formData)) {
3411
- const newState = this.getStateFromProps(this.props, formData, retrievedSchema);
3412
- formData = newState.formData;
3413
- }
3414
- const mustValidate = !noValidate && liveValidate;
3415
- let state = { formData, schema };
3416
- let newFormData = formData;
3417
- let _retrievedSchema;
3418
- if (omitExtraData === true && liveOmit === true) {
3419
- newFormData = this.omitExtraData(formData);
3420
- state = {
3421
- formData: newFormData
3422
- };
3423
- }
3424
- if (mustValidate) {
3425
- const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
3426
- let errors = schemaValidation.errors;
3427
- let errorSchema = schemaValidation.errorSchema;
3428
- const schemaValidationErrors = errors;
3429
- const schemaValidationErrorSchema = errorSchema;
3430
- if (extraErrors) {
3431
- const merged = validationDataMerge(schemaValidation, extraErrors);
3432
- errorSchema = merged.errorSchema;
3433
- errors = merged.errors;
3434
- }
3435
- if (newErrorSchema) {
3436
- const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
3437
- errorSchema = mergeObjects2(errorSchema, filteredErrors, "preventDuplicates");
3438
- }
3439
- state = {
3440
- formData: newFormData,
3441
- errors,
3442
- errorSchema,
3443
- schemaValidationErrors,
3444
- schemaValidationErrorSchema
3445
- };
3446
- } else if (!noValidate && newErrorSchema) {
3447
- const errorSchema = extraErrors ? mergeObjects2(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
3448
- state = {
3449
- formData: newFormData,
3450
- errorSchema,
3451
- errors: toErrorList(errorSchema)
3452
- };
3453
- }
3454
- if (_retrievedSchema) {
3455
- state.retrievedSchema = _retrievedSchema;
3456
- }
3457
- this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
3458
- };
3459
- /**
3460
- * Callback function to handle reset form data.
3461
- * - Reset all fields with default values.
3462
- * - Reset validations and errors
3463
- *
3464
- */
3465
- this.reset = () => {
3466
- const { onChange } = this.props;
3467
- const newState = this.getStateFromProps(this.props, void 0);
3468
- const newFormData = newState.formData;
3469
- const state = {
3470
- formData: newFormData,
3471
- errorSchema: {},
3472
- errors: [],
3473
- schemaValidationErrors: [],
3474
- schemaValidationErrorSchema: {}
3475
- };
3476
- this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
3477
- };
3478
- /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
3479
- * was provided.
3480
- *
3481
- * @param id - The unique `id` of the field that was blurred
3482
- * @param data - The data associated with the field that was blurred
3483
- */
3484
- this.onBlur = (id, data) => {
3485
- const { onBlur } = this.props;
3486
- if (onBlur) {
3487
- onBlur(id, data);
3488
- }
3489
- };
3490
- /** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
3491
- * was provided.
3492
- *
3493
- * @param id - The unique `id` of the field that was focused
3494
- * @param data - The data associated with the field that was focused
3495
- */
3496
- this.onFocus = (id, data) => {
3497
- const { onFocus } = this.props;
3498
- if (onFocus) {
3499
- onFocus(id, data);
3500
- }
3501
- };
3502
- /** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
3503
- * happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
3504
- * `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
3505
- * via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
3506
- * back the `onSubmit` callback if it was provided.
3507
- *
3508
- * @param event - The submit HTML form event
3509
- */
3510
- this.onSubmit = (event) => {
3511
- event.preventDefault();
3512
- if (event.target !== event.currentTarget) {
3513
- return;
3514
- }
3515
- event.persist();
3516
- const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
3517
- let { formData: newFormData } = this.state;
3518
- if (omitExtraData === true) {
3519
- newFormData = this.omitExtraData(newFormData);
3520
- }
3521
- if (noValidate || this.validateFormWithFormData(newFormData)) {
3522
- const errorSchema = extraErrors || {};
3523
- const errors = extraErrors ? toErrorList(extraErrors) : [];
3524
- this.setState(
3525
- {
3526
- formData: newFormData,
3527
- errors,
3528
- errorSchema,
3529
- schemaValidationErrors: [],
3530
- schemaValidationErrorSchema: {}
3531
- },
3532
- () => {
3533
- if (onSubmit) {
3534
- onSubmit({ ...this.state, formData: newFormData, status: "submitted" }, event);
3535
- }
3536
- }
3537
- );
3538
- }
3539
- };
3540
- /** Provides a function that can be used to programmatically submit the `Form` */
3541
- this.submit = () => {
3542
- if (this.formElement.current) {
3543
- const submitCustomEvent = new CustomEvent("submit", {
3544
- cancelable: true
3545
- });
3546
- submitCustomEvent.preventDefault();
3547
- this.formElement.current.dispatchEvent(submitCustomEvent);
3548
- this.formElement.current.requestSubmit();
3549
- }
3550
- };
3551
- /** Validates the form using the given `formData`. For use on form submission or on programmatic validation.
3552
- * If `onError` is provided, then it will be called with the list of errors.
3553
- *
3554
- * @param formData - The form data to validate
3555
- * @returns - True if the form is valid, false otherwise.
3556
- */
3557
- this.validateFormWithFormData = (formData) => {
3558
- const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
3559
- const { errors: prevErrors } = this.state;
3560
- const schemaValidation = this.validate(formData);
3561
- let errors = schemaValidation.errors;
3562
- let errorSchema = schemaValidation.errorSchema;
3563
- const schemaValidationErrors = errors;
3564
- const schemaValidationErrorSchema = errorSchema;
3565
- const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
3566
- if (hasError) {
3567
- if (extraErrors) {
3568
- const merged = validationDataMerge(schemaValidation, extraErrors);
3569
- errorSchema = merged.errorSchema;
3570
- errors = merged.errors;
3571
- }
3572
- if (focusOnFirstError) {
3573
- if (typeof focusOnFirstError === "function") {
3574
- focusOnFirstError(errors[0]);
3575
- } else {
3576
- this.focusOnError(errors[0]);
3577
- }
3578
- }
3579
- this.setState(
3580
- {
3581
- errors,
3582
- errorSchema,
3583
- schemaValidationErrors,
3584
- schemaValidationErrorSchema
3585
- },
3586
- () => {
3587
- if (onError) {
3588
- onError(errors);
3589
- } else {
3590
- console.error("Form validation failed", errors);
3591
- }
3592
- }
3593
- );
3594
- } else if (prevErrors.length > 0) {
3595
- this.setState({
3596
- errors: [],
3597
- errorSchema: {},
3598
- schemaValidationErrors: [],
3599
- schemaValidationErrorSchema: {}
3600
- });
3601
- }
3602
- return !hasError;
3603
- };
3604
4231
  if (!props.validator) {
3605
4232
  throw new Error("A validator is required for Form functionality to work");
3606
4233
  }
@@ -3630,8 +4257,9 @@ var Form = class extends Component5 {
3630
4257
  */
3631
4258
  getSnapshotBeforeUpdate(prevProps, prevState) {
3632
4259
  if (!deepEquals3(this.props, prevProps)) {
4260
+ const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
3633
4261
  const isSchemaChanged = !deepEquals3(prevProps.schema, this.props.schema);
3634
- const isFormDataChanged = !deepEquals3(prevProps.formData, this.props.formData);
4262
+ const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals3(prevProps.formData, this.props.formData);
3635
4263
  const nextState = this.getStateFromProps(
3636
4264
  this.props,
3637
4265
  this.props.formData,
@@ -3639,7 +4267,8 @@ var Form = class extends Component5 {
3639
4267
  // Or if the `formData` changes, for example in the case of a schema with dependencies that need to
3640
4268
  // match one of the subSchemas, the retrieved schema must be updated.
3641
4269
  isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
3642
- isSchemaChanged
4270
+ isSchemaChanged,
4271
+ formDataChangedFields
3643
4272
  );
3644
4273
  const shouldUpdate = !deepEquals3(nextState, prevState);
3645
4274
  return { nextState, shouldUpdate };
@@ -3654,9 +4283,6 @@ var Form = class extends Component5 {
3654
4283
  * If an update is required, it applies the next state and, if needed, triggers the `onChange` handler to inform about
3655
4284
  * changes.
3656
4285
  *
3657
- * This method effectively replaces the deprecated `UNSAFE_componentWillReceiveProps`, providing a safer alternative
3658
- * to handle prop changes and state updates.
3659
- *
3660
4286
  * @param _ - The previous set of props.
3661
4287
  * @param prevState - The previous state of the component before the update.
3662
4288
  * @param snapshot - The value returned from `getSnapshotBeforeUpdate`.
@@ -3678,9 +4304,10 @@ var Form = class extends Component5 {
3678
4304
  * @param inputFormData - The new or current data for the `Form`
3679
4305
  * @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
3680
4306
  * @param isSchemaChanged - A flag indicating whether the schema has changed.
4307
+ * @param formDataChangedFields - The changed fields of `formData`
3681
4308
  * @returns - The new state for the `Form`
3682
4309
  */
3683
- getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false) {
4310
+ getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
3684
4311
  const state = this.state || {};
3685
4312
  const schema = "schema" in props ? props.schema : this.props.schema;
3686
4313
  const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
@@ -3689,12 +4316,25 @@ var Form = class extends Component5 {
3689
4316
  const mustValidate = edit && !props.noValidate && liveValidate;
3690
4317
  const rootSchema = schema;
3691
4318
  const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
4319
+ const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
3692
4320
  let schemaUtils = state.schemaUtils;
3693
- if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(props.validator, rootSchema, experimental_defaultFormStateBehavior)) {
3694
- schemaUtils = createSchemaUtils(props.validator, rootSchema, experimental_defaultFormStateBehavior);
4321
+ if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
4322
+ props.validator,
4323
+ rootSchema,
4324
+ experimental_defaultFormStateBehavior,
4325
+ experimental_customMergeAllOf
4326
+ )) {
4327
+ schemaUtils = createSchemaUtils(
4328
+ props.validator,
4329
+ rootSchema,
4330
+ experimental_defaultFormStateBehavior,
4331
+ experimental_customMergeAllOf
4332
+ );
3695
4333
  }
3696
4334
  const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
3697
- const _retrievedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
4335
+ const _retrievedSchema = this.updateRetrievedSchema(
4336
+ retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData)
4337
+ );
3698
4338
  const getCurrentErrors = () => {
3699
4339
  if (props.noValidate || isSchemaChanged) {
3700
4340
  return { errors: [], errorSchema: {} };
@@ -3716,10 +4356,10 @@ var Form = class extends Component5 {
3716
4356
  if (mustValidate) {
3717
4357
  const schemaValidation = this.validate(formData, schema, schemaUtils, _retrievedSchema);
3718
4358
  errors = schemaValidation.errors;
3719
- if (isSchemaChanged) {
4359
+ if (retrievedSchema === void 0) {
3720
4360
  errorSchema = schemaValidation.errorSchema;
3721
4361
  } else {
3722
- errorSchema = mergeObjects2(
4362
+ errorSchema = mergeObjects3(
3723
4363
  this.state?.errorSchema,
3724
4364
  schemaValidation.errorSchema,
3725
4365
  "preventDuplicates"
@@ -3731,6 +4371,20 @@ var Form = class extends Component5 {
3731
4371
  const currentErrors = getCurrentErrors();
3732
4372
  errors = currentErrors.errors;
3733
4373
  errorSchema = currentErrors.errorSchema;
4374
+ if (formDataChangedFields.length > 0) {
4375
+ const newErrorSchema = formDataChangedFields.reduce(
4376
+ (acc, key) => {
4377
+ acc[key] = void 0;
4378
+ return acc;
4379
+ },
4380
+ {}
4381
+ );
4382
+ errorSchema = schemaValidationErrorSchema = mergeObjects3(
4383
+ currentErrors.errorSchema,
4384
+ newErrorSchema,
4385
+ "preventDuplicates"
4386
+ );
4387
+ }
3734
4388
  }
3735
4389
  if (props.extraErrors) {
3736
4390
  const merged = validationDataMerge({ errorSchema, errors }, props.extraErrors);
@@ -3768,6 +4422,21 @@ var Form = class extends Component5 {
3768
4422
  shouldComponentUpdate(nextProps, nextState) {
3769
4423
  return shouldRender(this, nextProps, nextState);
3770
4424
  }
4425
+ /** Gets the previously raised customValidate errors.
4426
+ *
4427
+ * @returns the previous customValidate errors
4428
+ */
4429
+ getPreviousCustomValidateErrors() {
4430
+ const { customValidate, uiSchema } = this.props;
4431
+ const prevFormData = this.state.formData;
4432
+ let customValidateErrors = {};
4433
+ if (typeof customValidate === "function") {
4434
+ const errorHandler = customValidate(prevFormData, createErrorHandler(prevFormData), uiSchema);
4435
+ const userErrorSchema = unwrapErrorHandler(errorHandler);
4436
+ customValidateErrors = userErrorSchema;
4437
+ }
4438
+ return customValidateErrors;
4439
+ }
3771
4440
  /** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
3772
4441
  * `schemaUtils` in the state), returning the results.
3773
4442
  *
@@ -3785,10 +4454,10 @@ var Form = class extends Component5 {
3785
4454
  renderErrors(registry) {
3786
4455
  const { errors, errorSchema, schema, uiSchema } = this.state;
3787
4456
  const { formContext } = this.props;
3788
- const options = getUiOptions12(uiSchema);
3789
- const ErrorListTemplate = getTemplate20("ErrorListTemplate", registry, options);
4457
+ const options = getUiOptions16(uiSchema);
4458
+ const ErrorListTemplate = getTemplate24("ErrorListTemplate", registry, options);
3790
4459
  if (errors && errors.length) {
3791
- return /* @__PURE__ */ jsx45(
4460
+ return /* @__PURE__ */ jsx51(
3792
4461
  ErrorListTemplate,
3793
4462
  {
3794
4463
  errors,
@@ -3802,6 +4471,62 @@ var Form = class extends Component5 {
3802
4471
  }
3803
4472
  return null;
3804
4473
  }
4474
+ /** Returns the `formData` with only the elements specified in the `fields` list
4475
+ *
4476
+ * @param formData - The data for the `Form`
4477
+ * @param fields - The fields to keep while filtering
4478
+ */
4479
+ getUsedFormData = (formData, fields2) => {
4480
+ if (fields2.length === 0 && typeof formData !== "object") {
4481
+ return formData;
4482
+ }
4483
+ const data = _pick(formData, fields2);
4484
+ if (Array.isArray(formData)) {
4485
+ return Object.keys(data).map((key) => data[key]);
4486
+ }
4487
+ return data;
4488
+ };
4489
+ /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
4490
+ *
4491
+ * @param pathSchema - The `PathSchema` object for the form
4492
+ * @param [formData] - The form data to use while checking for empty objects/arrays
4493
+ */
4494
+ getFieldNames = (pathSchema, formData) => {
4495
+ const getAllPaths = (_obj, acc = [], paths = [[]]) => {
4496
+ Object.keys(_obj).forEach((key) => {
4497
+ if (typeof _obj[key] === "object") {
4498
+ const newPaths = paths.map((path) => [...path, key]);
4499
+ if (_obj[key][RJSF_ADDITIONAL_PROPERTIES_FLAG] && _obj[key][NAME_KEY] !== "") {
4500
+ acc.push(_obj[key][NAME_KEY]);
4501
+ } else {
4502
+ getAllPaths(_obj[key], acc, newPaths);
4503
+ }
4504
+ } else if (key === NAME_KEY && _obj[key] !== "") {
4505
+ paths.forEach((path) => {
4506
+ const formValue = _get(formData, path);
4507
+ if (typeof formValue !== "object" || _isEmpty(formValue) || Array.isArray(formValue) && formValue.every((val) => typeof val !== "object")) {
4508
+ acc.push(path);
4509
+ }
4510
+ });
4511
+ }
4512
+ });
4513
+ return acc;
4514
+ };
4515
+ return getAllPaths(pathSchema);
4516
+ };
4517
+ /** Returns the `formData` after filtering to remove any extra data not in a form field
4518
+ *
4519
+ * @param formData - The data for the `Form`
4520
+ * @returns The `formData` after omitting extra data
4521
+ */
4522
+ omitExtraData = (formData) => {
4523
+ const { schema, schemaUtils } = this.state;
4524
+ const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
4525
+ const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
4526
+ const fieldNames = this.getFieldNames(pathSchema, formData);
4527
+ const newFormData = this.getUsedFormData(formData, fieldNames);
4528
+ return newFormData;
4529
+ };
3805
4530
  // Filtering errors based on your retrieved schema to only show errors for properties in the selected branch.
3806
4531
  filterErrorsBasedOnSchema(schemaErrors, resolvedSchema, formData) {
3807
4532
  const { retrievedSchema, schemaUtils } = this.state;
@@ -3812,18 +4537,185 @@ var Form = class extends Component5 {
3812
4537
  if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
3813
4538
  filteredErrors.__errors = schemaErrors.__errors;
3814
4539
  }
3815
- const filterUndefinedErrors = (errors) => {
4540
+ const prevCustomValidateErrors = this.getPreviousCustomValidateErrors();
4541
+ const filterPreviousCustomErrors = (errors = [], prevCustomErrors) => {
4542
+ if (errors.length === 0) {
4543
+ return errors;
4544
+ }
4545
+ return errors.filter((error) => {
4546
+ return !prevCustomErrors.includes(error);
4547
+ });
4548
+ };
4549
+ const filterNilOrEmptyErrors = (errors, previousCustomValidateErrors = {}) => {
3816
4550
  _forEach(errors, (errorAtKey, errorKey) => {
3817
- if (errorAtKey === void 0) {
4551
+ const prevCustomValidateErrorAtKey = previousCustomValidateErrors[errorKey];
4552
+ if (_isNil(errorAtKey) || Array.isArray(errorAtKey) && errorAtKey.length === 0) {
3818
4553
  delete errors[errorKey];
4554
+ } else if (isObject6(errorAtKey) && isObject6(prevCustomValidateErrorAtKey) && Array.isArray(prevCustomValidateErrorAtKey?.__errors)) {
4555
+ errors[errorKey] = filterPreviousCustomErrors(errorAtKey.__errors, prevCustomValidateErrorAtKey.__errors);
3819
4556
  } else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey.__errors)) {
3820
- filterUndefinedErrors(errorAtKey);
4557
+ filterNilOrEmptyErrors(errorAtKey, previousCustomValidateErrors[errorKey]);
3821
4558
  }
3822
4559
  });
3823
4560
  return errors;
3824
4561
  };
3825
- return filterUndefinedErrors(filteredErrors);
4562
+ return filterNilOrEmptyErrors(filteredErrors, prevCustomValidateErrors);
4563
+ }
4564
+ /** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
4565
+ * `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
4566
+ * then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
4567
+ * in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
4568
+ * updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
4569
+ * callback will be called if specified with the updated state.
4570
+ *
4571
+ * @param formData - The new form data from a change to a field
4572
+ * @param newErrorSchema - The new `ErrorSchema` based on the field change
4573
+ * @param id - The id of the field that caused the change
4574
+ */
4575
+ onChange = (formData, newErrorSchema, id) => {
4576
+ const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
4577
+ const { schemaUtils, schema } = this.state;
4578
+ let retrievedSchema = this.state.retrievedSchema;
4579
+ if (isObject6(formData) || Array.isArray(formData)) {
4580
+ const newState = this.getStateFromProps(this.props, formData);
4581
+ formData = newState.formData;
4582
+ retrievedSchema = newState.retrievedSchema;
4583
+ }
4584
+ const mustValidate = !noValidate && liveValidate;
4585
+ let state = { formData, schema };
4586
+ let newFormData = formData;
4587
+ if (omitExtraData === true && liveOmit === true) {
4588
+ newFormData = this.omitExtraData(formData);
4589
+ state = {
4590
+ formData: newFormData
4591
+ };
4592
+ }
4593
+ if (mustValidate) {
4594
+ const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
4595
+ let errors = schemaValidation.errors;
4596
+ let errorSchema = schemaValidation.errorSchema;
4597
+ const schemaValidationErrors = errors;
4598
+ const schemaValidationErrorSchema = errorSchema;
4599
+ if (extraErrors) {
4600
+ const merged = validationDataMerge(schemaValidation, extraErrors);
4601
+ errorSchema = merged.errorSchema;
4602
+ errors = merged.errors;
4603
+ }
4604
+ if (newErrorSchema) {
4605
+ const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
4606
+ errorSchema = mergeObjects3(errorSchema, filteredErrors, "preventDuplicates");
4607
+ }
4608
+ state = {
4609
+ formData: newFormData,
4610
+ errors,
4611
+ errorSchema,
4612
+ schemaValidationErrors,
4613
+ schemaValidationErrorSchema
4614
+ };
4615
+ } else if (!noValidate && newErrorSchema) {
4616
+ const errorSchema = extraErrors ? mergeObjects3(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
4617
+ state = {
4618
+ formData: newFormData,
4619
+ errorSchema,
4620
+ errors: toErrorList(errorSchema)
4621
+ };
4622
+ }
4623
+ this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
4624
+ };
4625
+ /**
4626
+ * If the retrievedSchema has changed the new retrievedSchema is returned.
4627
+ * Otherwise, the old retrievedSchema is returned to persist reference.
4628
+ * - This ensures that AJV retrieves the schema from the cache when it has not changed,
4629
+ * avoiding the performance cost of recompiling the schema.
4630
+ *
4631
+ * @param retrievedSchema The new retrieved schema.
4632
+ * @returns The new retrieved schema if it has changed, else the old retrieved schema.
4633
+ */
4634
+ updateRetrievedSchema(retrievedSchema) {
4635
+ const isTheSame = deepEquals3(retrievedSchema, this.state?.retrievedSchema);
4636
+ return isTheSame ? this.state.retrievedSchema : retrievedSchema;
3826
4637
  }
4638
+ /**
4639
+ * Callback function to handle reset form data.
4640
+ * - Reset all fields with default values.
4641
+ * - Reset validations and errors
4642
+ *
4643
+ */
4644
+ reset = () => {
4645
+ const { onChange } = this.props;
4646
+ const newState = this.getStateFromProps(this.props, void 0);
4647
+ const newFormData = newState.formData;
4648
+ const state = {
4649
+ formData: newFormData,
4650
+ errorSchema: {},
4651
+ errors: [],
4652
+ schemaValidationErrors: [],
4653
+ schemaValidationErrorSchema: {}
4654
+ };
4655
+ this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
4656
+ };
4657
+ /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
4658
+ * was provided.
4659
+ *
4660
+ * @param id - The unique `id` of the field that was blurred
4661
+ * @param data - The data associated with the field that was blurred
4662
+ */
4663
+ onBlur = (id, data) => {
4664
+ const { onBlur } = this.props;
4665
+ if (onBlur) {
4666
+ onBlur(id, data);
4667
+ }
4668
+ };
4669
+ /** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
4670
+ * was provided.
4671
+ *
4672
+ * @param id - The unique `id` of the field that was focused
4673
+ * @param data - The data associated with the field that was focused
4674
+ */
4675
+ onFocus = (id, data) => {
4676
+ const { onFocus } = this.props;
4677
+ if (onFocus) {
4678
+ onFocus(id, data);
4679
+ }
4680
+ };
4681
+ /** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
4682
+ * happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
4683
+ * `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
4684
+ * via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
4685
+ * back the `onSubmit` callback if it was provided.
4686
+ *
4687
+ * @param event - The submit HTML form event
4688
+ */
4689
+ onSubmit = (event) => {
4690
+ event.preventDefault();
4691
+ if (event.target !== event.currentTarget) {
4692
+ return;
4693
+ }
4694
+ event.persist();
4695
+ const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
4696
+ let { formData: newFormData } = this.state;
4697
+ if (omitExtraData === true) {
4698
+ newFormData = this.omitExtraData(newFormData);
4699
+ }
4700
+ if (noValidate || this.validateFormWithFormData(newFormData)) {
4701
+ const errorSchema = extraErrors || {};
4702
+ const errors = extraErrors ? toErrorList(extraErrors) : [];
4703
+ this.setState(
4704
+ {
4705
+ formData: newFormData,
4706
+ errors,
4707
+ errorSchema,
4708
+ schemaValidationErrors: [],
4709
+ schemaValidationErrorSchema: {}
4710
+ },
4711
+ () => {
4712
+ if (onSubmit) {
4713
+ onSubmit({ ...this.state, formData: newFormData, status: "submitted" }, event);
4714
+ }
4715
+ }
4716
+ );
4717
+ }
4718
+ };
3827
4719
  /** Returns the registry for the form */
3828
4720
  getRegistry() {
3829
4721
  const { translateString: customTranslateString, uiSchema = {} } = this.props;
@@ -3847,6 +4739,17 @@ var Form = class extends Component5 {
3847
4739
  globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY]
3848
4740
  };
3849
4741
  }
4742
+ /** Provides a function that can be used to programmatically submit the `Form` */
4743
+ submit = () => {
4744
+ if (this.formElement.current) {
4745
+ const submitCustomEvent = new CustomEvent("submit", {
4746
+ cancelable: true
4747
+ });
4748
+ submitCustomEvent.preventDefault();
4749
+ this.formElement.current.dispatchEvent(submitCustomEvent);
4750
+ this.formElement.current.requestSubmit();
4751
+ }
4752
+ };
3850
4753
  /** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
3851
4754
  * field, then, using the `idPrefix` and `idSeparator` converts that path into an id. Then the input element with that
3852
4755
  * id is attempted to be found using the `formElement` ref. If it is located, then it is focused.
@@ -3865,7 +4768,7 @@ var Form = class extends Component5 {
3865
4768
  const elementId = path.join(idSeparator);
3866
4769
  let field = this.formElement.current.elements[elementId];
3867
4770
  if (!field) {
3868
- field = this.formElement.current.querySelector(`input[id^=${elementId}`);
4771
+ field = this.formElement.current.querySelector(`input[id^="${elementId}"`);
3869
4772
  }
3870
4773
  if (field && field.length) {
3871
4774
  field = field[0];
@@ -3874,6 +4777,59 @@ var Form = class extends Component5 {
3874
4777
  field.focus();
3875
4778
  }
3876
4779
  }
4780
+ /** Validates the form using the given `formData`. For use on form submission or on programmatic validation.
4781
+ * If `onError` is provided, then it will be called with the list of errors.
4782
+ *
4783
+ * @param formData - The form data to validate
4784
+ * @returns - True if the form is valid, false otherwise.
4785
+ */
4786
+ validateFormWithFormData = (formData) => {
4787
+ const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
4788
+ const { errors: prevErrors } = this.state;
4789
+ const schemaValidation = this.validate(formData);
4790
+ let errors = schemaValidation.errors;
4791
+ let errorSchema = schemaValidation.errorSchema;
4792
+ const schemaValidationErrors = errors;
4793
+ const schemaValidationErrorSchema = errorSchema;
4794
+ const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
4795
+ if (hasError) {
4796
+ if (extraErrors) {
4797
+ const merged = validationDataMerge(schemaValidation, extraErrors);
4798
+ errorSchema = merged.errorSchema;
4799
+ errors = merged.errors;
4800
+ }
4801
+ if (focusOnFirstError) {
4802
+ if (typeof focusOnFirstError === "function") {
4803
+ focusOnFirstError(errors[0]);
4804
+ } else {
4805
+ this.focusOnError(errors[0]);
4806
+ }
4807
+ }
4808
+ this.setState(
4809
+ {
4810
+ errors,
4811
+ errorSchema,
4812
+ schemaValidationErrors,
4813
+ schemaValidationErrorSchema
4814
+ },
4815
+ () => {
4816
+ if (onError) {
4817
+ onError(errors);
4818
+ } else {
4819
+ console.error("Form validation failed", errors);
4820
+ }
4821
+ }
4822
+ );
4823
+ } else if (prevErrors.length > 0) {
4824
+ this.setState({
4825
+ errors: [],
4826
+ errorSchema: {},
4827
+ schemaValidationErrors: [],
4828
+ schemaValidationErrorSchema: {}
4829
+ });
4830
+ }
4831
+ return !hasError;
4832
+ };
3877
4833
  /** Programmatically validate the form. If `omitExtraData` is true, the `formData` will first be filtered to remove
3878
4834
  * any extra data not in a form field. If `onError` is provided, then it will be called with the list of errors the
3879
4835
  * same way as would happen on form submission.
@@ -3905,7 +4861,6 @@ var Form = class extends Component5 {
3905
4861
  action,
3906
4862
  autoComplete,
3907
4863
  enctype,
3908
- acceptcharset,
3909
4864
  acceptCharset,
3910
4865
  noHtml5Validate = false,
3911
4866
  disabled,
@@ -3920,12 +4875,12 @@ var Form = class extends Component5 {
3920
4875
  const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
3921
4876
  const as = _internalFormWrapper ? tagName : void 0;
3922
4877
  const FormTag = _internalFormWrapper || tagName || "form";
3923
- let { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } = getUiOptions12(uiSchema);
4878
+ let { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } = getUiOptions16(uiSchema);
3924
4879
  if (disabled) {
3925
4880
  submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
3926
4881
  }
3927
- const submitUiSchema = { [UI_OPTIONS_KEY2]: { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
3928
- return /* @__PURE__ */ jsxs21(
4882
+ const submitUiSchema = { [UI_OPTIONS_KEY3]: { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
4883
+ return /* @__PURE__ */ jsxs23(
3929
4884
  FormTag,
3930
4885
  {
3931
4886
  className: className ? className : "rjsf",
@@ -3936,14 +4891,14 @@ var Form = class extends Component5 {
3936
4891
  action,
3937
4892
  autoComplete,
3938
4893
  encType: enctype,
3939
- acceptCharset: acceptCharset || acceptcharset,
4894
+ acceptCharset,
3940
4895
  noValidate: noHtml5Validate,
3941
4896
  onSubmit: this.onSubmit,
3942
4897
  as,
3943
4898
  ref: this.formElement,
3944
4899
  children: [
3945
4900
  showErrorList === "top" && this.renderErrors(registry),
3946
- /* @__PURE__ */ jsx45(
4901
+ /* @__PURE__ */ jsx51(
3947
4902
  _SchemaField,
3948
4903
  {
3949
4904
  name: "",
@@ -3963,7 +4918,7 @@ var Form = class extends Component5 {
3963
4918
  readonly
3964
4919
  }
3965
4920
  ),
3966
- children ? children : /* @__PURE__ */ jsx45(SubmitButton2, { uiSchema: submitUiSchema, registry }),
4921
+ children ? children : /* @__PURE__ */ jsx51(SubmitButton2, { uiSchema: submitUiSchema, registry }),
3967
4922
  showErrorList === "bottom" && this.renderErrors(registry)
3968
4923
  ]
3969
4924
  }
@@ -3973,7 +4928,7 @@ var Form = class extends Component5 {
3973
4928
 
3974
4929
  // src/withTheme.tsx
3975
4930
  import { forwardRef } from "react";
3976
- import { jsx as jsx46 } from "react/jsx-runtime";
4931
+ import { jsx as jsx52 } from "react/jsx-runtime";
3977
4932
  function withTheme(themeProps) {
3978
4933
  return forwardRef(
3979
4934
  ({ fields: fields2, widgets: widgets2, templates: templates2, ...directProps }, ref) => {
@@ -3987,7 +4942,7 @@ function withTheme(themeProps) {
3987
4942
  ...templates2?.ButtonTemplates
3988
4943
  }
3989
4944
  };
3990
- return /* @__PURE__ */ jsx46(
4945
+ return /* @__PURE__ */ jsx52(
3991
4946
  Form,
3992
4947
  {
3993
4948
  ...themeProps,
@@ -4003,9 +4958,9 @@ function withTheme(themeProps) {
4003
4958
  }
4004
4959
 
4005
4960
  // src/index.ts
4006
- var src_default = Form;
4961
+ var index_default = Form;
4007
4962
  export {
4008
- src_default as default,
4963
+ index_default as default,
4009
4964
  getDefaultRegistry,
4010
4965
  withTheme
4011
4966
  };