@rjsf/core 6.6.1 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/LICENSE.md +201 -0
  2. package/dist/core.umd.js +694 -584
  3. package/dist/index.cjs +1191 -1071
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.esm.js +1030 -984
  6. package/dist/index.esm.js.map +4 -4
  7. package/lib/components/Form.d.ts +16 -13
  8. package/lib/components/Form.d.ts.map +1 -1
  9. package/lib/components/Form.js +126 -76
  10. package/lib/components/RichDescription.d.ts +3 -3
  11. package/lib/components/RichDescription.d.ts.map +1 -1
  12. package/lib/components/RichDescription.js +1 -1
  13. package/lib/components/RichHelp.d.ts +3 -3
  14. package/lib/components/RichHelp.d.ts.map +1 -1
  15. package/lib/components/RichHelp.js +1 -1
  16. package/lib/components/SchemaExamples.d.ts +2 -2
  17. package/lib/components/SchemaExamples.d.ts.map +1 -1
  18. package/lib/components/SchemaExamples.js +1 -3
  19. package/lib/components/fields/ArrayField.d.ts +2 -2
  20. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  21. package/lib/components/fields/ArrayField.js +87 -88
  22. package/lib/components/fields/BooleanField.d.ts +2 -2
  23. package/lib/components/fields/BooleanField.d.ts.map +1 -1
  24. package/lib/components/fields/BooleanField.js +2 -5
  25. package/lib/components/fields/CyclicSchemaField.d.ts +8 -0
  26. package/lib/components/fields/CyclicSchemaField.d.ts.map +1 -0
  27. package/lib/components/fields/CyclicSchemaField.js +21 -0
  28. package/lib/components/fields/FallbackField.d.ts +2 -2
  29. package/lib/components/fields/FallbackField.d.ts.map +1 -1
  30. package/lib/components/fields/FallbackField.js +2 -2
  31. package/lib/components/fields/LayoutGridField.d.ts +8 -10
  32. package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
  33. package/lib/components/fields/LayoutGridField.js +5 -4
  34. package/lib/components/fields/LayoutHeaderField.d.ts +2 -2
  35. package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
  36. package/lib/components/fields/LayoutHeaderField.js +1 -1
  37. package/lib/components/fields/LayoutMultiSchemaField.d.ts +2 -2
  38. package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
  39. package/lib/components/fields/LayoutMultiSchemaField.js +4 -1
  40. package/lib/components/fields/MultiSchemaField.d.ts +2 -41
  41. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
  42. package/lib/components/fields/MultiSchemaField.js +116 -122
  43. package/lib/components/fields/NullField.d.ts +1 -1
  44. package/lib/components/fields/NullField.d.ts.map +1 -1
  45. package/lib/components/fields/NumberField.d.ts +2 -2
  46. package/lib/components/fields/NumberField.d.ts.map +1 -1
  47. package/lib/components/fields/NumberField.js +7 -9
  48. package/lib/components/fields/ObjectField.d.ts +2 -2
  49. package/lib/components/fields/ObjectField.d.ts.map +1 -1
  50. package/lib/components/fields/ObjectField.js +28 -26
  51. package/lib/components/fields/OptionalDataControlsField.d.ts +2 -2
  52. package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
  53. package/lib/components/fields/SchemaField.d.ts +14 -8
  54. package/lib/components/fields/SchemaField.d.ts.map +1 -1
  55. package/lib/components/fields/SchemaField.js +43 -30
  56. package/lib/components/fields/StringField.d.ts +2 -2
  57. package/lib/components/fields/StringField.d.ts.map +1 -1
  58. package/lib/components/fields/StringField.js +2 -5
  59. package/lib/components/fields/index.d.ts +1 -1
  60. package/lib/components/fields/index.d.ts.map +1 -1
  61. package/lib/components/fields/index.js +2 -0
  62. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +2 -2
  63. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
  64. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +1 -1
  65. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +2 -2
  66. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
  67. package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +1 -1
  68. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +2 -2
  69. package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
  70. package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
  71. package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -2
  72. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
  73. package/lib/components/templates/ArrayFieldTemplate.js +1 -1
  74. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +2 -2
  75. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
  76. package/lib/components/templates/ArrayFieldTitleTemplate.js +1 -1
  77. package/lib/components/templates/BaseInputTemplate.d.ts +2 -2
  78. package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
  79. package/lib/components/templates/BaseInputTemplate.js +7 -6
  80. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +2 -2
  81. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
  82. package/lib/components/templates/ButtonTemplates/IconButton.d.ts +14 -7
  83. package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
  84. package/lib/components/templates/ButtonTemplates/IconButton.js +14 -6
  85. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +2 -2
  86. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
  87. package/lib/components/templates/ButtonTemplates/index.d.ts +1 -1
  88. package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -1
  89. package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts +7 -0
  90. package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts.map +1 -0
  91. package/lib/components/templates/CyclicSchemaExpandTemplate.js +12 -0
  92. package/lib/components/templates/DescriptionField.d.ts +2 -2
  93. package/lib/components/templates/DescriptionField.d.ts.map +1 -1
  94. package/lib/components/templates/ErrorList.d.ts +2 -2
  95. package/lib/components/templates/ErrorList.d.ts.map +1 -1
  96. package/lib/components/templates/ErrorList.js +2 -4
  97. package/lib/components/templates/FallbackFieldTemplate.d.ts +2 -2
  98. package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
  99. package/lib/components/templates/FieldErrorTemplate.d.ts +2 -2
  100. package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
  101. package/lib/components/templates/FieldErrorTemplate.js +1 -3
  102. package/lib/components/templates/FieldHelpTemplate.d.ts +2 -2
  103. package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
  104. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +2 -2
  105. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
  106. package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -1
  107. package/lib/components/templates/FieldTemplate/Label.d.ts +3 -3
  108. package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
  109. package/lib/components/templates/GridTemplate.d.ts +2 -2
  110. package/lib/components/templates/GridTemplate.d.ts.map +1 -1
  111. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +2 -2
  112. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
  113. package/lib/components/templates/ObjectFieldTemplate.d.ts +2 -2
  114. package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
  115. package/lib/components/templates/ObjectFieldTemplate.js +1 -1
  116. package/lib/components/templates/OptionalDataControlsTemplate.d.ts +2 -2
  117. package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
  118. package/lib/components/templates/OptionalDataControlsTemplate.js +1 -1
  119. package/lib/components/templates/TitleField.d.ts +2 -2
  120. package/lib/components/templates/TitleField.d.ts.map +1 -1
  121. package/lib/components/templates/UnsupportedField.d.ts +2 -2
  122. package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
  123. package/lib/components/templates/UnsupportedField.js +2 -2
  124. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +2 -2
  125. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
  126. package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -1
  127. package/lib/components/templates/index.d.ts +1 -1
  128. package/lib/components/templates/index.d.ts.map +1 -1
  129. package/lib/components/templates/index.js +2 -0
  130. package/lib/components/widgets/AltDateTimeWidget.d.ts +2 -2
  131. package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
  132. package/lib/components/widgets/AltDateWidget.d.ts +2 -2
  133. package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
  134. package/lib/components/widgets/AltDateWidget.js +2 -2
  135. package/lib/components/widgets/CheckboxWidget.d.ts +2 -2
  136. package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
  137. package/lib/components/widgets/CheckboxesWidget.d.ts +2 -2
  138. package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
  139. package/lib/components/widgets/CheckboxesWidget.js +4 -4
  140. package/lib/components/widgets/ColorWidget.d.ts +2 -2
  141. package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
  142. package/lib/components/widgets/DateTimeWidget.d.ts +2 -2
  143. package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
  144. package/lib/components/widgets/DateTimeWidget.js +2 -2
  145. package/lib/components/widgets/DateWidget.d.ts +2 -2
  146. package/lib/components/widgets/DateWidget.d.ts.map +1 -1
  147. package/lib/components/widgets/EmailWidget.d.ts +2 -2
  148. package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
  149. package/lib/components/widgets/FileWidget.d.ts +2 -2
  150. package/lib/components/widgets/FileWidget.d.ts.map +1 -1
  151. package/lib/components/widgets/FileWidget.js +6 -4
  152. package/lib/components/widgets/HiddenWidget.d.ts +2 -2
  153. package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
  154. package/lib/components/widgets/PasswordWidget.d.ts +2 -2
  155. package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
  156. package/lib/components/widgets/RadioWidget.d.ts +2 -2
  157. package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
  158. package/lib/components/widgets/RadioWidget.js +4 -4
  159. package/lib/components/widgets/RangeWidget.d.ts +2 -2
  160. package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
  161. package/lib/components/widgets/RatingWidget.d.ts +2 -2
  162. package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
  163. package/lib/components/widgets/RatingWidget.js +15 -15
  164. package/lib/components/widgets/SelectWidget.d.ts +2 -2
  165. package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
  166. package/lib/components/widgets/SelectWidget.js +9 -8
  167. package/lib/components/widgets/TextWidget.d.ts +2 -2
  168. package/lib/components/widgets/TextWidget.d.ts.map +1 -1
  169. package/lib/components/widgets/TextareaWidget.d.ts +2 -2
  170. package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
  171. package/lib/components/widgets/TextareaWidget.js +5 -5
  172. package/lib/components/widgets/TimeWidget.d.ts +2 -2
  173. package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
  174. package/lib/components/widgets/URLWidget.d.ts +2 -2
  175. package/lib/components/widgets/URLWidget.d.ts.map +1 -1
  176. package/lib/components/widgets/UpDownWidget.d.ts +2 -2
  177. package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
  178. package/lib/components/widgets/index.d.ts +1 -1
  179. package/lib/components/widgets/index.d.ts.map +1 -1
  180. package/lib/getDefaultRegistry.d.ts +1 -1
  181. package/lib/getDefaultRegistry.d.ts.map +1 -1
  182. package/lib/getDefaultRegistry.js +1 -1
  183. package/lib/getTestRegistry.d.ts +1 -1
  184. package/lib/getTestRegistry.d.ts.map +1 -1
  185. package/lib/getTestRegistry.js +1 -1
  186. package/lib/index.d.ts +10 -5
  187. package/lib/index.d.ts.map +1 -1
  188. package/lib/tsconfig.tsbuildinfo +1 -1
  189. package/lib/withTheme.d.ts +3 -3
  190. package/lib/withTheme.d.ts.map +1 -1
  191. package/lib/withTheme.js +6 -6
  192. package/package.json +28 -28
  193. package/src/components/Form.tsx +197 -111
  194. package/src/components/RichDescription.tsx +3 -10
  195. package/src/components/RichHelp.tsx +3 -10
  196. package/src/components/SchemaExamples.tsx +6 -4
  197. package/src/components/fields/ArrayField.tsx +122 -108
  198. package/src/components/fields/BooleanField.tsx +4 -9
  199. package/src/components/fields/CyclicSchemaField.tsx +40 -0
  200. package/src/components/fields/FallbackField.tsx +4 -8
  201. package/src/components/fields/LayoutGridField.tsx +21 -19
  202. package/src/components/fields/LayoutHeaderField.tsx +2 -10
  203. package/src/components/fields/LayoutMultiSchemaField.tsx +15 -10
  204. package/src/components/fields/MultiSchemaField.tsx +202 -218
  205. package/src/components/fields/NullField.tsx +1 -1
  206. package/src/components/fields/NumberField.tsx +8 -10
  207. package/src/components/fields/ObjectField.tsx +52 -40
  208. package/src/components/fields/OptionalDataControlsField.tsx +6 -4
  209. package/src/components/fields/SchemaField.tsx +66 -51
  210. package/src/components/fields/StringField.tsx +4 -15
  211. package/src/components/fields/index.ts +3 -1
  212. package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -9
  213. package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +2 -7
  214. package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -9
  215. package/src/components/templates/ArrayFieldTemplate.tsx +2 -9
  216. package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -10
  217. package/src/components/templates/BaseInputTemplate.tsx +16 -23
  218. package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -1
  219. package/src/components/templates/ButtonTemplates/IconButton.tsx +16 -7
  220. package/src/components/templates/ButtonTemplates/SubmitButton.tsx +2 -1
  221. package/src/components/templates/ButtonTemplates/index.ts +1 -1
  222. package/src/components/templates/CyclicSchemaExpandTemplate.tsx +31 -0
  223. package/src/components/templates/DescriptionField.tsx +1 -1
  224. package/src/components/templates/ErrorList.tsx +8 -15
  225. package/src/components/templates/FallbackFieldTemplate.tsx +2 -1
  226. package/src/components/templates/FieldErrorTemplate.tsx +8 -8
  227. package/src/components/templates/FieldHelpTemplate.tsx +2 -1
  228. package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -8
  229. package/src/components/templates/FieldTemplate/Label.tsx +2 -2
  230. package/src/components/templates/GridTemplate.tsx +1 -1
  231. package/src/components/templates/MultiSchemaFieldTemplate.tsx +1 -1
  232. package/src/components/templates/ObjectFieldTemplate.tsx +2 -7
  233. package/src/components/templates/OptionalDataControlsTemplate.tsx +3 -2
  234. package/src/components/templates/TitleField.tsx +1 -1
  235. package/src/components/templates/UnsupportedField.tsx +4 -3
  236. package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
  237. package/src/components/templates/index.ts +3 -1
  238. package/src/components/widgets/AltDateTimeWidget.tsx +1 -1
  239. package/src/components/widgets/AltDateWidget.tsx +7 -13
  240. package/src/components/widgets/CheckboxWidget.tsx +3 -5
  241. package/src/components/widgets/CheckboxesWidget.tsx +8 -10
  242. package/src/components/widgets/ColorWidget.tsx +2 -1
  243. package/src/components/widgets/DateTimeWidget.tsx +3 -10
  244. package/src/components/widgets/DateWidget.tsx +2 -1
  245. package/src/components/widgets/EmailWidget.tsx +2 -1
  246. package/src/components/widgets/FileWidget.tsx +9 -8
  247. package/src/components/widgets/HiddenWidget.tsx +1 -1
  248. package/src/components/widgets/PasswordWidget.tsx +2 -1
  249. package/src/components/widgets/RadioWidget.tsx +8 -10
  250. package/src/components/widgets/RangeWidget.tsx +1 -1
  251. package/src/components/widgets/RatingWidget.tsx +48 -47
  252. package/src/components/widgets/SelectWidget.tsx +48 -31
  253. package/src/components/widgets/TextWidget.tsx +2 -1
  254. package/src/components/widgets/TextareaWidget.tsx +10 -7
  255. package/src/components/widgets/TimeWidget.tsx +2 -1
  256. package/src/components/widgets/URLWidget.tsx +2 -1
  257. package/src/components/widgets/UpDownWidget.tsx +2 -1
  258. package/src/components/widgets/index.ts +1 -1
  259. package/src/getDefaultRegistry.ts +2 -9
  260. package/src/getTestRegistry.tsx +2 -7
  261. package/src/index.ts +10 -5
  262. package/src/withTheme.tsx +14 -9
package/dist/core.umd.js CHANGED
@@ -1,20 +1,18 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/cloneDeep'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/set'), require('lodash/toPath'), require('lodash/unset'), require('lodash/isObject'), require('lodash/uniqueId'), require('react/jsx-runtime'), require('lodash/each'), require('lodash/flatten'), require('lodash/has'), require('lodash/includes'), require('lodash/intersection'), require('lodash/isEqual'), require('lodash/isFunction'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx'), require('markdown-to-jsx/react'), require('@rjsf/validator-ajv8')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/unset', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isEqual', 'lodash/isFunction', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx', 'markdown-to-jsx/react', '@rjsf/validator-ajv8'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react$1, global.utils, global._cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global._unset, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isEqual, global.isFunction, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.markdownToJsx, global.react, global.validator));
5
- })(this, (function (exports, react$1, utils, _cloneDeep, get, isEmpty, _pick, set, _toPath, _unset, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isEqual, isFunction, isPlainObject, isString, isUndefined, last, noop, omit3, markdownToJsx, react, validator) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/cloneDeep'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/set'), require('lodash/toPath'), require('lodash/unset'), require('lodash/isObject'), require('lodash/uniqueId'), require('react/jsx-runtime'), require('lodash/each'), require('lodash/flatten'), require('lodash/has'), require('lodash/includes'), require('lodash/intersection'), require('lodash/isEqual'), require('lodash/isFunction'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx/react'), require('@rjsf/validator-ajv8')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/unset', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isEqual', 'lodash/isFunction', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx/react', '@rjsf/validator-ajv8'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global._cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global._unset, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isEqual, global.isFunction, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.react$1, global.validator));
5
+ })(this, (function (exports, react, utils, _cloneDeep, get, isEmpty, _pick, set, _toPath, _unset, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isEqual, isFunction, isPlainObject, isString, isUndefined, last, noop, omit3, react$1, validator) { 'use strict';
6
6
 
7
7
  // src/components/Form.tsx
8
8
  function generateRowId() {
9
9
  return uniqueId("rjsf-array-item-");
10
10
  }
11
11
  function generateKeyedFormData(formData) {
12
- return !Array.isArray(formData) ? [] : formData.map((item) => {
13
- return {
14
- key: generateRowId(),
15
- item
16
- };
17
- });
12
+ return !Array.isArray(formData) ? [] : formData.map((item) => ({
13
+ key: generateRowId(),
14
+ item
15
+ }));
18
16
  }
19
17
  function keyedToPlainFormData(keyedFormData) {
20
18
  if (Array.isArray(keyedFormData)) {
@@ -215,7 +213,7 @@
215
213
  }
216
214
  );
217
215
  }
218
- function ArrayFieldItem(props) {
216
+ function ArrayFieldItemInner(props) {
219
217
  const {
220
218
  itemKey,
221
219
  index,
@@ -230,10 +228,10 @@
230
228
  canRemove = true,
231
229
  canMoveUp,
232
230
  canMoveDown,
233
- itemSchema,
231
+ rawItemSchema,
234
232
  itemData,
235
233
  itemUiSchema,
236
- itemFieldPathId,
234
+ parentFieldPathId,
237
235
  itemErrorSchema,
238
236
  autofocus,
239
237
  onBlur,
@@ -250,9 +248,17 @@
250
248
  const {
251
249
  schemaUtils,
252
250
  fields: { ArraySchemaField, SchemaField: SchemaField2 },
253
- globalUiOptions
251
+ globalUiOptions,
252
+ globalFormOptions
254
253
  } = registry;
255
- const fieldPathId = utils.useDeepCompareMemo(itemFieldPathId);
254
+ const itemSchema = react.useMemo(
255
+ () => schemaUtils.retrieveSchema(rawItemSchema, itemData),
256
+ [schemaUtils, rawItemSchema, itemData]
257
+ );
258
+ const fieldPathId = react.useMemo(
259
+ () => utils.toFieldPathId(index, globalFormOptions, parentFieldPathId),
260
+ [index, globalFormOptions, parentFieldPathId]
261
+ );
256
262
  const ItemSchemaField = ArraySchemaField || SchemaField2;
257
263
  const ArrayFieldItemTemplate2 = utils.getTemplate(
258
264
  "ArrayFieldItemTemplate",
@@ -271,31 +277,31 @@
271
277
  toolbar: false
272
278
  };
273
279
  has4.toolbar = Object.keys(has4).some((key) => has4[key]);
274
- const onAddItem = react$1.useCallback(
280
+ const onAddItem = react.useCallback(
275
281
  (event) => {
276
282
  handleAddItem(event, index + 1);
277
283
  },
278
284
  [handleAddItem, index]
279
285
  );
280
- const onCopyItem = react$1.useCallback(
286
+ const onCopyItem = react.useCallback(
281
287
  (event) => {
282
288
  handleCopyItem(event, index);
283
289
  },
284
290
  [handleCopyItem, index]
285
291
  );
286
- const onRemoveItem = react$1.useCallback(
292
+ const onRemoveItem = react.useCallback(
287
293
  (event) => {
288
294
  handleRemoveItem(event, index);
289
295
  },
290
296
  [handleRemoveItem, index]
291
297
  );
292
- const onMoveUpItem = react$1.useCallback(
298
+ const onMoveUpItem = react.useCallback(
293
299
  (event) => {
294
300
  handleReorderItems(event, index, index - 1);
295
301
  },
296
302
  [handleReorderItems, index]
297
303
  );
298
- const onMoveDownItem = react$1.useCallback(
304
+ const onMoveDownItem = react.useCallback(
299
305
  (event) => {
300
306
  handleReorderItems(event, index, index + 1);
301
307
  },
@@ -361,6 +367,7 @@
361
367
  };
362
368
  return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...templateProps });
363
369
  }
370
+ var ArrayFieldItem = react.memo(ArrayFieldItemInner);
364
371
  function NormalArray(props) {
365
372
  const {
366
373
  schema,
@@ -387,15 +394,18 @@
387
394
  handleReorderItems
388
395
  } = props;
389
396
  const fieldTitle = schema.title || title || name;
390
- const { schemaUtils, fields: fields2, formContext, globalFormOptions, globalUiOptions } = registry;
397
+ const { schemaUtils, fields: fields2, formContext, globalUiOptions } = registry;
391
398
  const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
392
- const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
393
- const _schemaItems = isObject(schema.items) ? schema.items : {};
394
- const itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
395
- const formData = keyedToPlainFormData(keyedFormData);
399
+ const uiOptions = react.useMemo(() => utils.getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
400
+ const schemaItems = react.useMemo(() => isObject(schema.items) ? schema.items : {}, [schema.items]);
401
+ const itemsSchema = react.useMemo(() => schemaUtils.retrieveSchema(schemaItems), [schemaUtils, schemaItems]);
402
+ const formData = react.useMemo(() => keyedToPlainFormData(keyedFormData), [keyedFormData]);
396
403
  const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
397
404
  const hasFormData = utils.isFormDataAvailable(formDataFromProps);
398
- const canAdd = canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData);
405
+ const canAdd = react.useMemo(
406
+ () => canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData),
407
+ [registry, schema, formData, uiSchema, renderOptionalField, hasFormData]
408
+ );
399
409
  const actualFormData = hasFormData ? keyedFormData : [];
400
410
  const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
401
411
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
@@ -405,9 +415,7 @@
405
415
  items: actualFormData.map((keyedItem, index) => {
406
416
  const { key, item } = keyedItem;
407
417
  const itemCast = item;
408
- const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
409
418
  const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
410
- const itemFieldPathId = utils.toFieldPathId(index, globalFormOptions, childFieldPathId);
411
419
  const itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
412
420
  const itemProps = {
413
421
  itemKey: key,
@@ -424,8 +432,8 @@
424
432
  canAdd,
425
433
  canMoveUp: index > 0,
426
434
  canMoveDown: index < formData.length - 1,
427
- itemSchema,
428
- itemFieldPathId,
435
+ rawItemSchema: schemaItems,
436
+ parentFieldPathId: childFieldPathId,
429
437
  itemErrorSchema,
430
438
  itemData: itemCast,
431
439
  itemUiSchema,
@@ -486,24 +494,24 @@
486
494
  } = props;
487
495
  let { formData: items = [] } = props;
488
496
  const fieldTitle = schema.title || title || name;
489
- const { schemaUtils, fields: fields2, formContext, globalFormOptions, globalUiOptions } = registry;
490
- const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
497
+ const { fields: fields2, formContext, globalUiOptions } = registry;
498
+ const uiOptions = react.useMemo(() => utils.getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
491
499
  const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
492
500
  const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
493
501
  const hasFormData = utils.isFormDataAvailable(formData);
494
- const _schemaItems = isObject(schema.items) ? schema.items : [];
495
- const itemSchemas = _schemaItems.map(
496
- (item, index) => schemaUtils.retrieveSchema(item, items[index])
502
+ const schemaItems = react.useMemo(
503
+ () => isObject(schema.items) ? schema.items : [],
504
+ [schema.items]
497
505
  );
498
- const additionalSchema = isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, formData) : null;
506
+ const hasAdditionalItems = isObject(schema.additionalItems);
499
507
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
500
- if (items.length < itemSchemas.length) {
501
- items = items.concat(new Array(itemSchemas.length - items.length));
508
+ if (items.length < schemaItems.length) {
509
+ items = items.concat(new Array(schemaItems.length - items.length));
502
510
  }
503
511
  const actualFormData = hasFormData ? keyedFormData : [];
504
512
  const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
505
513
  const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsxRuntime.jsx(OptionalDataControlsField2, { ...props, fieldPathId: childFieldPathId }) : void 0;
506
- const canAdd = canAddItem(registry, schema, items, uiSchema) && !!additionalSchema && (!renderOptionalField || hasFormData);
514
+ const canAdd = canAddItem(registry, schema, items, uiSchema) && hasAdditionalItems && (!renderOptionalField || hasFormData);
507
515
  const arrayProps = {
508
516
  canAdd,
509
517
  className: `rjsf-field rjsf-field-array rjsf-field-array-fixed-items${extraClass}`,
@@ -513,18 +521,15 @@
513
521
  items: actualFormData.map((keyedItem, index) => {
514
522
  const { key, item } = keyedItem;
515
523
  const itemCast = item;
516
- const additional = index >= itemSchemas.length;
517
- const itemSchema = (additional && isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, itemCast) : itemSchemas[index]) || {};
518
- const itemFieldPathId = utils.toFieldPathId(index, globalFormOptions, childFieldPathId);
524
+ const additional = index >= schemaItems.length;
525
+ const rawItemSchema = (additional && isObject(schema.additionalItems) ? schema.additionalItems : schemaItems[index]) || {};
519
526
  let itemUiSchema;
520
527
  if (additional) {
521
528
  itemUiSchema = uiSchema.additionalItems;
529
+ } else if (Array.isArray(uiSchema.items)) {
530
+ itemUiSchema = uiSchema.items[index];
522
531
  } else {
523
- if (Array.isArray(uiSchema.items)) {
524
- itemUiSchema = uiSchema.items[index];
525
- } else {
526
- itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
527
- }
532
+ itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
528
533
  }
529
534
  const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
530
535
  const itemProps = {
@@ -541,12 +546,12 @@
541
546
  title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
542
547
  canAdd,
543
548
  canRemove: additional,
544
- canMoveUp: index >= itemSchemas.length + 1,
549
+ canMoveUp: index >= schemaItems.length + 1,
545
550
  canMoveDown: additional && index < items.length - 1,
546
- itemSchema,
551
+ rawItemSchema,
547
552
  itemData: itemCast,
548
553
  itemUiSchema,
549
- itemFieldPathId,
554
+ parentFieldPathId: childFieldPathId,
550
555
  itemErrorSchema,
551
556
  autofocus: autofocus && index === 0,
552
557
  onBlur,
@@ -576,8 +581,8 @@
576
581
  return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...arrayProps });
577
582
  }
578
583
  function useKeyedFormData(formData = []) {
579
- const newHash = react$1.useMemo(() => utils.hashObject(formData), [formData]);
580
- const [state, setState] = react$1.useState(() => ({
584
+ const newHash = react.useMemo(() => utils.hashObject(formData), [formData]);
585
+ const [state, setState] = react.useState(() => ({
581
586
  formDataHash: newHash,
582
587
  keyedFormData: generateKeyedFormData(formData)
583
588
  }));
@@ -592,10 +597,10 @@
592
597
  formDataHash = newHash;
593
598
  setState({ formDataHash, keyedFormData });
594
599
  }
595
- const updateKeyedFormData = react$1.useCallback((newData) => {
600
+ const updateKeyedFormData = react.useCallback((newData) => {
596
601
  const plainFormData = keyedToPlainFormData(newData);
597
- const newHash2 = utils.hashObject(plainFormData);
598
- setState({ formDataHash: newHash2, keyedFormData: newData });
602
+ const updatedHash = utils.hashObject(plainFormData);
603
+ setState({ formDataHash: updatedHash, keyedFormData: newData });
599
604
  return plainFormData;
600
605
  }, []);
601
606
  return { keyedFormData, updateKeyedFormData };
@@ -604,21 +609,25 @@
604
609
  const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
605
610
  const { globalFormOptions, schemaUtils, translateString } = registry;
606
611
  const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
612
+ const keyedFormDataRef = react.useRef(keyedFormData);
613
+ keyedFormDataRef.current = keyedFormData;
614
+ const errorSchemaRef = react.useRef(errorSchema);
615
+ errorSchemaRef.current = errorSchema;
607
616
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
608
- const handleAddItem = react$1.useCallback(
617
+ const handleAddItem = react.useCallback(
609
618
  (event, index) => {
610
619
  if (event) {
611
620
  event.preventDefault();
612
621
  }
613
622
  let newErrorSchema;
614
- if (errorSchema) {
623
+ if (errorSchemaRef.current) {
615
624
  newErrorSchema = {};
616
- for (const idx in errorSchema) {
617
- const i = parseInt(idx);
625
+ for (const idx of Object.keys(errorSchemaRef.current)) {
626
+ const i = parseInt(idx, 10);
618
627
  if (index === void 0 || i < index) {
619
- set(newErrorSchema, [i], errorSchema[idx]);
628
+ set(newErrorSchema, [i], errorSchemaRef.current[i]);
620
629
  } else if (i >= index) {
621
- set(newErrorSchema, [i + 1], errorSchema[idx]);
630
+ set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
622
631
  }
623
632
  }
624
633
  }
@@ -626,7 +635,7 @@
626
635
  key: generateRowId(),
627
636
  item: getNewFormDataRow(registry, schema)
628
637
  };
629
- const newKeyedFormData = [...keyedFormData];
638
+ const newKeyedFormData = [...keyedFormDataRef.current];
630
639
  if (index !== void 0) {
631
640
  newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
632
641
  } else {
@@ -634,30 +643,30 @@
634
643
  }
635
644
  onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
636
645
  },
637
- [keyedFormData, registry, schema, onChange, updateKeyedFormData, errorSchema, childFieldPathId]
646
+ [registry, schema, onChange, updateKeyedFormData, childFieldPathId]
638
647
  );
639
- const handleCopyItem = react$1.useCallback(
648
+ const handleCopyItem = react.useCallback(
640
649
  (event, index) => {
641
650
  if (event) {
642
651
  event.preventDefault();
643
652
  }
644
653
  let newErrorSchema;
645
- if (errorSchema) {
654
+ if (errorSchemaRef.current) {
646
655
  newErrorSchema = {};
647
- for (const idx in errorSchema) {
648
- const i = parseInt(idx);
656
+ for (const idx of Object.keys(errorSchemaRef.current)) {
657
+ const i = parseInt(idx, 10);
649
658
  if (i <= index) {
650
- set(newErrorSchema, [i], errorSchema[idx]);
659
+ set(newErrorSchema, [i], errorSchemaRef.current[i]);
651
660
  } else if (i > index) {
652
- set(newErrorSchema, [i + 1], errorSchema[idx]);
661
+ set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
653
662
  }
654
663
  }
655
664
  }
656
665
  const newKeyedFormDataRow = {
657
666
  key: generateRowId(),
658
- item: _cloneDeep(keyedFormData[index].item)
667
+ item: _cloneDeep(keyedFormDataRef.current[index].item)
659
668
  };
660
- const newKeyedFormData = [...keyedFormData];
669
+ const newKeyedFormData = [...keyedFormDataRef.current];
661
670
  if (index !== void 0) {
662
671
  newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
663
672
  } else {
@@ -665,62 +674,62 @@
665
674
  }
666
675
  onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
667
676
  },
668
- [keyedFormData, onChange, updateKeyedFormData, errorSchema, childFieldPathId]
677
+ [onChange, updateKeyedFormData, childFieldPathId]
669
678
  );
670
- const handleRemoveItem = react$1.useCallback(
679
+ const handleRemoveItem = react.useCallback(
671
680
  (event, index) => {
672
681
  if (event) {
673
682
  event.preventDefault();
674
683
  }
675
684
  let newErrorSchema;
676
- if (errorSchema) {
685
+ if (errorSchemaRef.current) {
677
686
  newErrorSchema = {};
678
- for (const idx in errorSchema) {
679
- const i = parseInt(idx);
687
+ for (const idx of Object.keys(errorSchemaRef.current)) {
688
+ const i = parseInt(idx, 10);
680
689
  if (i < index) {
681
- set(newErrorSchema, [i], errorSchema[idx]);
690
+ set(newErrorSchema, [i], errorSchemaRef.current[i]);
682
691
  } else if (i > index) {
683
- set(newErrorSchema, [i - 1], errorSchema[idx]);
692
+ set(newErrorSchema, [i - 1], errorSchemaRef.current[i]);
684
693
  }
685
694
  }
686
695
  }
687
- const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
696
+ const newKeyedFormData = keyedFormDataRef.current.filter((_, i) => i !== index);
688
697
  onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
689
698
  },
690
- [keyedFormData, onChange, updateKeyedFormData, errorSchema, childFieldPathId]
699
+ [onChange, updateKeyedFormData, childFieldPathId]
691
700
  );
692
- const handleReorderItems = react$1.useCallback(
701
+ const handleReorderItems = react.useCallback(
693
702
  (event, index, newIndex) => {
694
703
  if (event) {
695
704
  event.preventDefault();
696
705
  event.currentTarget.blur();
697
706
  }
698
707
  let newErrorSchema;
699
- if (errorSchema) {
708
+ if (errorSchemaRef.current) {
700
709
  newErrorSchema = {};
701
- for (const idx in errorSchema) {
702
- const i = parseInt(idx);
703
- if (i == index) {
704
- set(newErrorSchema, [newIndex], errorSchema[index]);
705
- } else if (i == newIndex) {
706
- set(newErrorSchema, [index], errorSchema[newIndex]);
710
+ for (const idx of Object.keys(errorSchemaRef.current)) {
711
+ const i = parseInt(idx, 10);
712
+ if (i === index) {
713
+ set(newErrorSchema, [newIndex], errorSchemaRef.current[index]);
714
+ } else if (i === newIndex) {
715
+ set(newErrorSchema, [index], errorSchemaRef.current[newIndex]);
707
716
  } else {
708
- set(newErrorSchema, [idx], errorSchema[i]);
717
+ set(newErrorSchema, [idx], errorSchemaRef.current[i]);
709
718
  }
710
719
  }
711
720
  }
712
721
  function reOrderArray() {
713
- const _newKeyedFormData = keyedFormData.slice();
714
- _newKeyedFormData.splice(index, 1);
715
- _newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
716
- return _newKeyedFormData;
722
+ const newKeyedFormData2 = keyedFormDataRef.current.slice();
723
+ newKeyedFormData2.splice(index, 1);
724
+ newKeyedFormData2.splice(newIndex, 0, keyedFormDataRef.current[index]);
725
+ return newKeyedFormData2;
717
726
  }
718
727
  const newKeyedFormData = reOrderArray();
719
728
  onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
720
729
  },
721
- [keyedFormData, onChange, updateKeyedFormData, errorSchema, childFieldPathId]
730
+ [onChange, updateKeyedFormData, childFieldPathId]
722
731
  );
723
- const handleChange = react$1.useCallback(
732
+ const handleChange = react.useCallback(
724
733
  (value, path, newErrorSchema, id) => {
725
734
  const lastPathIsItemIndex = typeof path.at(-1) === "number";
726
735
  onChange(
@@ -735,7 +744,7 @@
735
744
  },
736
745
  [onChange]
737
746
  );
738
- const onSelectChange = react$1.useCallback(
747
+ const onSelectChange = react.useCallback(
739
748
  (value) => {
740
749
  onChange(value, childFieldPathId.path, void 0, childFieldPathId?.[utils.ID_KEY]);
741
750
  },
@@ -859,10 +868,8 @@
859
868
  enumOptions = utils.optionsList({ enum: enums }, uiSchema);
860
869
  }
861
870
  }
862
- const onWidgetChange = react$1.useCallback(
863
- (value, errorSchema, id) => {
864
- return onChange(value, fieldPathId.path, errorSchema, id);
865
- },
871
+ const onWidgetChange = react.useCallback(
872
+ (value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
866
873
  [onChange, fieldPathId]
867
874
  );
868
875
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -891,6 +898,33 @@
891
898
  );
892
899
  }
893
900
  var BooleanField_default = BooleanField;
901
+ function CyclicSchemaField(props) {
902
+ const [expanded, setExpanded] = react.useState(false);
903
+ const { name, registry, schema, uiSchema, fieldPathId } = props;
904
+ const { globalUiOptions } = registry;
905
+ const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
906
+ const CyclicSchemaExpandTemplate2 = utils.getTemplate(
907
+ "CyclicSchemaExpandTemplate",
908
+ registry,
909
+ uiOptions
910
+ );
911
+ if (!expanded) {
912
+ return /* @__PURE__ */ jsxRuntime.jsx(
913
+ CyclicSchemaExpandTemplate2,
914
+ {
915
+ registry,
916
+ schema,
917
+ uiSchema,
918
+ name,
919
+ fieldPathId,
920
+ onExpand: () => setExpanded(true)
921
+ }
922
+ );
923
+ }
924
+ const { fields: fields2 } = registry;
925
+ const { SchemaField: SchemaField2 } = fields2;
926
+ return /* @__PURE__ */ jsxRuntime.jsx(SchemaField2, { ...props, schema: { ...schema, [utils.RJSF_REF_CYCLE_KEY]: false } });
927
+ }
894
928
  function getFallbackTypeSelectionSchema(title) {
895
929
  return {
896
930
  type: "string",
@@ -915,7 +949,7 @@
915
949
  return String(formData);
916
950
  case "number": {
917
951
  const castedNumber = Number(formData);
918
- return isNaN(castedNumber) ? 0 : castedNumber;
952
+ return Number.isNaN(castedNumber) ? 0 : castedNumber;
919
953
  }
920
954
  case "boolean":
921
955
  return Boolean(formData);
@@ -942,13 +976,13 @@
942
976
  errorSchema
943
977
  } = props;
944
978
  const { translateString, fields: fields2, globalFormOptions } = registry;
945
- const [type, setType] = react$1.useState(getTypeOfFormData(formData));
979
+ const [type, setType] = react.useState(getTypeOfFormData(formData));
946
980
  const uiOptions = utils.getUiOptions(uiSchema);
947
981
  const typeSelectorInnerFieldPathId = utils.useDeepCompareMemo(
948
982
  utils.toFieldPathId("__internal_type_selector", globalFormOptions, fieldPathId)
949
983
  );
950
984
  const schemaTitle = translateString(utils.TranslatableString.Type);
951
- const typesOptionSchema = react$1.useMemo(() => getFallbackTypeSelectionSchema(schemaTitle), [schemaTitle]);
985
+ const typesOptionSchema = react.useMemo(() => getFallbackTypeSelectionSchema(schemaTitle), [schemaTitle]);
952
986
  const onTypeChange = (newType) => {
953
987
  if (newType != null) {
954
988
  setType(newType);
@@ -1073,6 +1107,7 @@
1073
1107
  }
1074
1108
  function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
1075
1109
  let rawSchema;
1110
+ let resultPathId = fieldPathId;
1076
1111
  if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && has(schema, utils.ITEMS_KEY)) {
1077
1112
  const index = Number(potentialIndex);
1078
1113
  const items = schema[utils.ITEMS_KEY];
@@ -1085,12 +1120,12 @@
1085
1120
  } else {
1086
1121
  rawSchema = items;
1087
1122
  }
1088
- fieldPathId = {
1123
+ resultPathId = {
1089
1124
  [utils.ID_KEY]: fieldPathId[utils.ID_KEY],
1090
1125
  path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
1091
1126
  };
1092
1127
  }
1093
- return { rawSchema, fieldPathId };
1128
+ return { rawSchema, fieldPathId: resultPathId };
1094
1129
  }
1095
1130
  function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
1096
1131
  const { schemaUtils, globalFormOptions } = registry;
@@ -1173,8 +1208,8 @@
1173
1208
  if (isString(prop)) {
1174
1209
  const match = LOOKUP_REGEX.exec(prop);
1175
1210
  if (Array.isArray(match) && match.length > 1) {
1176
- const name2 = match[1];
1177
- uiProps[key] = utils.lookupFromFormContext(registry, name2, name2);
1211
+ const lookupName = match[1];
1212
+ uiProps[key] = utils.lookupFromFormContext(registry, lookupName, lookupName);
1178
1213
  }
1179
1214
  }
1180
1215
  });
@@ -1191,7 +1226,7 @@
1191
1226
  const { registry, schema: rawSchema, formData } = layoutGridFieldProps;
1192
1227
  const { schemaUtils } = registry;
1193
1228
  const schema = schemaUtils.retrieveSchema(rawSchema, formData);
1194
- return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ react$1.createElement(
1229
+ return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ react.createElement(
1195
1230
  LayoutGridField,
1196
1231
  {
1197
1232
  ...layoutGridFieldProps,
@@ -1278,10 +1313,10 @@
1278
1313
  return uiComponentProps.rendered;
1279
1314
  }
1280
1315
  if (schema) {
1281
- const Field2 = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
1316
+ const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
1282
1317
  const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
1283
1318
  return /* @__PURE__ */ jsxRuntime.jsx(
1284
- Field2,
1319
+ Field,
1285
1320
  {
1286
1321
  "data-testid": optionsInfo?.hasDiscriminator ? LAYOUT_GRID_FIELD_TEST_IDS.layoutMultiSchemaField : LAYOUT_GRID_FIELD_TEST_IDS.field,
1287
1322
  ...otherProps,
@@ -1418,7 +1453,7 @@
1418
1453
  hideError = false
1419
1454
  } = props;
1420
1455
  const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
1421
- const [enumOptions, setEnumOptions] = react$1.useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
1456
+ const [enumOptions, setEnumOptions] = react.useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
1422
1457
  const id = get(fieldPathId, utils.ID_KEY);
1423
1458
  const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
1424
1459
  const FieldErrorTemplate2 = utils.getTemplate("FieldErrorTemplate", registry, options);
@@ -1427,7 +1462,7 @@
1427
1462
  const optionsHash = utils.hashObject(options);
1428
1463
  const uiSchemaHash = uiSchema ? utils.hashObject(uiSchema) : "";
1429
1464
  const formDataHash = formData ? utils.hashObject(formData) : "";
1430
- react$1.useEffect(() => {
1465
+ react.useEffect(() => {
1431
1466
  setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
1432
1467
  }, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
1433
1468
  const {
@@ -1451,6 +1486,9 @@
1451
1486
  const fieldErrorSchema = omit3(errorSchema, [utils.ERRORS_KEY]);
1452
1487
  const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1453
1488
  const onOptionChange = (opt) => {
1489
+ if (disabled || readonly) {
1490
+ return;
1491
+ }
1454
1492
  const newOption = getSelectedOption(enumOptions, selectorField, opt);
1455
1493
  const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
1456
1494
  let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
@@ -1512,207 +1550,183 @@
1512
1550
  }
1513
1551
  );
1514
1552
  }
1515
- var AnyOfField = class extends react$1.Component {
1516
- /** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
1517
- *
1518
- * @param props - The `FieldProps` for this template
1519
- */
1520
- constructor(props) {
1521
- super(props);
1522
- const {
1523
- formData,
1524
- options,
1525
- registry: { schemaUtils }
1526
- } = this.props;
1527
- const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
1528
- this.state = {
1529
- retrievedOptions,
1530
- selectedOption: this.getMatchingOption(0, formData, retrievedOptions)
1531
- };
1532
- }
1533
- /** React lifecycle method that is called when the props and/or state for this component is updated. It recomputes the
1534
- * currently selected option based on the overall `formData`
1535
- *
1536
- * @param prevProps - The previous `FieldProps` for this template
1537
- * @param prevState - The previous `AnyOfFieldState` for this template
1538
- */
1539
- componentDidUpdate(prevProps, prevState) {
1540
- const { formData, options, fieldPathId } = this.props;
1541
- const { selectedOption } = this.state;
1542
- let newState = this.state;
1543
- if (!utils.deepEquals(prevProps.options, options)) {
1544
- const {
1545
- registry: { schemaUtils }
1546
- } = this.props;
1547
- const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
1548
- newState = { selectedOption, retrievedOptions };
1553
+ function AnyOfField(props) {
1554
+ const {
1555
+ name,
1556
+ disabled = false,
1557
+ errorSchema = {},
1558
+ formData,
1559
+ fieldPathId,
1560
+ onBlur,
1561
+ onChange,
1562
+ onFocus,
1563
+ options,
1564
+ readonly,
1565
+ registry,
1566
+ required = false,
1567
+ schema,
1568
+ uiSchema
1569
+ } = props;
1570
+ const { schemaUtils } = registry;
1571
+ const formDataHash = utils.hashObject(formData ?? null);
1572
+ const retrievedOptions = react.useMemo(
1573
+ () => options.map((opt) => schemaUtils.retrieveSchema(opt, formData)),
1574
+ // oxlint-disable-next-line react-hooks/exhaustive-deps -- formDataHash is the value-stable proxy for formData
1575
+ [options, schemaUtils, formDataHash]
1576
+ );
1577
+ const [selectedOption, setSelectedOption] = react.useState(() => {
1578
+ const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
1579
+ return schemaUtils.getClosestMatchingOption(formData, retrievedOptions, 0, discriminator);
1580
+ });
1581
+ const skipNextOptionRecalculation = react.useRef(false);
1582
+ const prevFormDataRef = react.useRef(formData);
1583
+ const prevFieldIdRef = react.useRef(fieldPathId.$id);
1584
+ react.useEffect(() => {
1585
+ const prevFormData = prevFormDataRef.current;
1586
+ const prevFieldId = prevFieldIdRef.current;
1587
+ prevFormDataRef.current = formData;
1588
+ prevFieldIdRef.current = fieldPathId.$id;
1589
+ if (!utils.deepEquals(formData, prevFormData) && fieldPathId.$id === prevFieldId) {
1590
+ if (skipNextOptionRecalculation.current) {
1591
+ skipNextOptionRecalculation.current = false;
1592
+ return;
1593
+ }
1594
+ const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
1595
+ const matchingOption = schemaUtils.getClosestMatchingOption(
1596
+ formData,
1597
+ retrievedOptions,
1598
+ selectedOption,
1599
+ discriminator
1600
+ );
1601
+ if (matchingOption !== selectedOption) {
1602
+ setSelectedOption(matchingOption);
1603
+ }
1549
1604
  }
1550
- if (!utils.deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
1551
- const { retrievedOptions } = newState;
1552
- const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
1553
- if (prevState && matchingOption !== selectedOption) {
1554
- newState = { selectedOption: matchingOption, retrievedOptions };
1605
+ });
1606
+ const fieldId = `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
1607
+ const onOptionChange = react.useCallback(
1608
+ (option2) => {
1609
+ if (disabled || readonly) {
1610
+ return;
1555
1611
  }
1612
+ const intOption = option2 !== void 0 ? parseInt(option2, 10) : -1;
1613
+ if (intOption === selectedOption) {
1614
+ return;
1615
+ }
1616
+ const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
1617
+ const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
1618
+ let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
1619
+ if (newOption) {
1620
+ newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
1621
+ }
1622
+ setSelectedOption(intOption);
1623
+ skipNextOptionRecalculation.current = true;
1624
+ onChange(newFormData, fieldPathId.path, void 0, fieldId);
1625
+ },
1626
+ // setSelectedOption is stable (guaranteed by useState); skipNextOptionRecalculation is a ref
1627
+ [selectedOption, retrievedOptions, disabled, readonly, schemaUtils, formData, fieldPathId, onChange, fieldId]
1628
+ );
1629
+ const { widgets: widgets2, fields: fields2, translateString, globalUiOptions } = registry;
1630
+ const { SchemaField: SchemaFieldComponent } = fields2;
1631
+ const MultiSchemaFieldTemplate2 = utils.getTemplate(
1632
+ "MultiSchemaFieldTemplate",
1633
+ registry,
1634
+ globalUiOptions
1635
+ );
1636
+ const isOptionalRender = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
1637
+ const hasFormData = utils.isFormDataAvailable(formData);
1638
+ const {
1639
+ widget = "select",
1640
+ placeholder,
1641
+ autofocus,
1642
+ autocomplete,
1643
+ title = schema.title,
1644
+ ...uiOptions
1645
+ } = utils.getUiOptions(uiSchema, globalUiOptions);
1646
+ const Widget = utils.getWidget({ type: "number" }, widget, widgets2);
1647
+ const rawErrors = get(errorSchema, utils.ERRORS_KEY, []);
1648
+ const fieldErrorSchema = omit3(errorSchema, [utils.ERRORS_KEY]);
1649
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1650
+ const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1651
+ let optionSchema;
1652
+ if (option) {
1653
+ const { required: schemaRequired, type: schemaType } = schema;
1654
+ const parentProps = {};
1655
+ if (schemaRequired) {
1656
+ parentProps.required = schemaRequired;
1556
1657
  }
1557
- if (newState !== this.state) {
1558
- this.setState(newState);
1658
+ if (schemaType !== void 0 && !("type" in option)) {
1659
+ parentProps.type = schemaType;
1559
1660
  }
1661
+ optionSchema = Object.keys(parentProps).length > 0 ? utils.mergeSchemas(parentProps, option) : option;
1560
1662
  }
1561
- /** Determines the best matching option for the given `formData` and `options`.
1562
- *
1563
- * @param formData - The new formData
1564
- * @param options - The list of options to choose from
1565
- * @return - The index of the `option` that best matches the `formData`
1566
- */
1567
- getMatchingOption(selectedOption, formData, options) {
1568
- const {
1569
- schema,
1570
- registry: { schemaUtils }
1571
- } = this.props;
1572
- const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
1573
- const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
1574
- return option;
1575
- }
1576
- /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
1577
- * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
1578
- * the `onChange` handler.
1579
- *
1580
- * @param option - The new option value being selected
1581
- */
1582
- onOptionChange = (option) => {
1583
- const { selectedOption, retrievedOptions } = this.state;
1584
- const { formData, onChange, registry, fieldPathId } = this.props;
1585
- const { schemaUtils } = registry;
1586
- const intOption = option !== void 0 ? parseInt(option, 10) : -1;
1587
- if (intOption === selectedOption) {
1588
- return;
1663
+ let optionsUiSchema = [];
1664
+ if (utils.ONE_OF_KEY in schema && uiSchema && utils.ONE_OF_KEY in uiSchema) {
1665
+ if (Array.isArray(uiSchema[utils.ONE_OF_KEY])) {
1666
+ optionsUiSchema = uiSchema[utils.ONE_OF_KEY];
1667
+ } else {
1668
+ console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
1589
1669
  }
1590
- const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
1591
- const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
1592
- let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
1593
- if (newOption) {
1594
- newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
1670
+ } else if (utils.ANY_OF_KEY in schema && uiSchema && utils.ANY_OF_KEY in uiSchema) {
1671
+ if (Array.isArray(uiSchema[utils.ANY_OF_KEY])) {
1672
+ optionsUiSchema = uiSchema[utils.ANY_OF_KEY];
1673
+ } else {
1674
+ console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
1595
1675
  }
1596
- this.setState({ selectedOption: intOption }, () => {
1597
- onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
1598
- });
1599
- };
1600
- getFieldId() {
1601
- const { fieldPathId, schema } = this.props;
1602
- return `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
1603
1676
  }
1604
- /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
1605
- */
1606
- render() {
1607
- const {
1608
- name,
1609
- disabled = false,
1610
- errorSchema = {},
1611
- formData,
1677
+ let optionUiSchema = uiSchema;
1678
+ if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
1679
+ optionUiSchema = optionsUiSchema[selectedOption];
1680
+ }
1681
+ const translateEnum = title ? utils.TranslatableString.TitleOptionPrefix : utils.TranslatableString.OptionPrefix;
1682
+ const translateParams = title ? [title] : [];
1683
+ const enumOptions = retrievedOptions.map((opt, index) => {
1684
+ const { title: uiTitle = opt.title } = utils.getUiOptions(optionsUiSchema[index]);
1685
+ return {
1686
+ label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
1687
+ value: index
1688
+ };
1689
+ });
1690
+ const selector = !isOptionalRender || hasFormData ? /* @__PURE__ */ jsxRuntime.jsx(
1691
+ Widget,
1692
+ {
1693
+ id: fieldId,
1694
+ name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
1695
+ schema: { type: "number", default: 0 },
1696
+ onChange: onOptionChange,
1612
1697
  onBlur,
1613
1698
  onFocus,
1614
- readonly,
1615
- required = false,
1616
- registry,
1617
- schema,
1618
- uiSchema
1619
- } = this.props;
1620
- const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
1621
- const { SchemaField: _SchemaField } = fields2;
1622
- const MultiSchemaFieldTemplate2 = utils.getTemplate(
1623
- "MultiSchemaFieldTemplate",
1699
+ disabled: disabled || isEmpty(enumOptions),
1700
+ multiple: false,
1701
+ rawErrors,
1702
+ errorSchema: fieldErrorSchema,
1703
+ value: selectedOption >= 0 ? selectedOption : void 0,
1704
+ options: { enumOptions, ...uiOptions },
1624
1705
  registry,
1625
- globalUiOptions
1626
- );
1627
- const isOptionalRender = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
1628
- const hasFormData = utils.isFormDataAvailable(formData);
1629
- const { selectedOption, retrievedOptions } = this.state;
1630
- const {
1631
- widget = "select",
1632
1706
  placeholder,
1633
- autofocus,
1634
1707
  autocomplete,
1635
- title = schema.title,
1636
- ...uiOptions
1637
- } = utils.getUiOptions(uiSchema, globalUiOptions);
1638
- const Widget = utils.getWidget({ type: "number" }, widget, widgets2);
1639
- const rawErrors = get(errorSchema, utils.ERRORS_KEY, []);
1640
- const fieldErrorSchema = omit3(errorSchema, [utils.ERRORS_KEY]);
1641
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1642
- const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1643
- let optionSchema;
1644
- if (option) {
1645
- const { required: required2 } = schema;
1646
- optionSchema = required2 ? utils.mergeSchemas({ required: required2 }, option) : option;
1647
- }
1648
- let optionsUiSchema = [];
1649
- if (utils.ONE_OF_KEY in schema && uiSchema && utils.ONE_OF_KEY in uiSchema) {
1650
- if (Array.isArray(uiSchema[utils.ONE_OF_KEY])) {
1651
- optionsUiSchema = uiSchema[utils.ONE_OF_KEY];
1652
- } else {
1653
- console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
1654
- }
1655
- } else if (utils.ANY_OF_KEY in schema && uiSchema && utils.ANY_OF_KEY in uiSchema) {
1656
- if (Array.isArray(uiSchema[utils.ANY_OF_KEY])) {
1657
- optionsUiSchema = uiSchema[utils.ANY_OF_KEY];
1658
- } else {
1659
- console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
1660
- }
1708
+ autofocus,
1709
+ label: title ?? name,
1710
+ hideLabel: !displayLabel,
1711
+ readonly
1661
1712
  }
1662
- let optionUiSchema = uiSchema;
1663
- if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
1664
- optionUiSchema = optionsUiSchema[selectedOption];
1713
+ ) : void 0;
1714
+ const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsxRuntime.jsx(SchemaFieldComponent, { ...props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
1715
+ return /* @__PURE__ */ jsxRuntime.jsx(
1716
+ MultiSchemaFieldTemplate2,
1717
+ {
1718
+ schema,
1719
+ registry,
1720
+ uiSchema,
1721
+ selector,
1722
+ optionSchemaField: optionsSchemaField
1665
1723
  }
1666
- const translateEnum = title ? utils.TranslatableString.TitleOptionPrefix : utils.TranslatableString.OptionPrefix;
1667
- const translateParams = title ? [title] : [];
1668
- const enumOptions = retrievedOptions.map((opt, index) => {
1669
- const { title: uiTitle = opt.title } = utils.getUiOptions(optionsUiSchema[index]);
1670
- return {
1671
- label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
1672
- value: index
1673
- };
1674
- });
1675
- const selector = !isOptionalRender || hasFormData ? /* @__PURE__ */ jsxRuntime.jsx(
1676
- Widget,
1677
- {
1678
- id: this.getFieldId(),
1679
- name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
1680
- schema: { type: "number", default: 0 },
1681
- onChange: this.onOptionChange,
1682
- onBlur,
1683
- onFocus,
1684
- disabled: disabled || isEmpty(enumOptions),
1685
- multiple: false,
1686
- rawErrors,
1687
- errorSchema: fieldErrorSchema,
1688
- value: selectedOption >= 0 ? selectedOption : void 0,
1689
- options: { enumOptions, ...uiOptions },
1690
- registry,
1691
- placeholder,
1692
- autocomplete,
1693
- autofocus,
1694
- label: title ?? name,
1695
- hideLabel: !displayLabel,
1696
- readonly
1697
- }
1698
- ) : void 0;
1699
- const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsxRuntime.jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
1700
- return /* @__PURE__ */ jsxRuntime.jsx(
1701
- MultiSchemaFieldTemplate2,
1702
- {
1703
- schema,
1704
- registry,
1705
- uiSchema,
1706
- selector,
1707
- optionSchemaField: optionsSchemaField
1708
- }
1709
- );
1710
- }
1711
- };
1724
+ );
1725
+ }
1712
1726
  var MultiSchemaField_default = AnyOfField;
1713
1727
  function NullField(props) {
1714
1728
  const { formData, onChange, fieldPathId } = props;
1715
- react$1.useEffect(() => {
1729
+ react.useEffect(() => {
1716
1730
  if (formData === void 0) {
1717
1731
  onChange(null, fieldPathId.path);
1718
1732
  }
@@ -1724,16 +1738,14 @@
1724
1738
  var trailingCharMatcher = /[0.]0*$/;
1725
1739
  function NumberField(props) {
1726
1740
  const { registry, onChange, formData, value: initialValue } = props;
1727
- const [lastValue, setLastValue] = react$1.useState(initialValue);
1741
+ const [lastValue, setLastValue] = react.useState(initialValue);
1728
1742
  const { StringField: StringField2 } = registry.fields;
1729
1743
  let value = formData;
1730
- const handleChange = react$1.useCallback(
1731
- (value2, path, errorSchema, id) => {
1732
- setLastValue(value2);
1733
- if (`${value2}`.charAt(0) === ".") {
1734
- value2 = `0${value2}`;
1735
- }
1736
- const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? utils.asNumber(value2.replace(trailingCharMatcher, "")) : utils.asNumber(value2);
1744
+ const handleChange = react.useCallback(
1745
+ (newValue, path, errorSchema, id) => {
1746
+ setLastValue(newValue);
1747
+ const normalizedValue = `${newValue}`.startsWith(".") ? `0${newValue}` : newValue;
1748
+ const processed = typeof normalizedValue === "string" && trailingCharMatcherWithPrefix.exec(normalizedValue) ? utils.asNumber(normalizedValue.replace(trailingCharMatcher, "")) : utils.asNumber(normalizedValue);
1737
1749
  onChange(processed, path, errorSchema, id);
1738
1750
  },
1739
1751
  [onChange]
@@ -1752,7 +1764,7 @@
1752
1764
  var ADDITIONAL_PROPERTY_KEY_REMOVE = /* @__PURE__ */ Symbol("remove-this-key");
1753
1765
  var IS_RESET = /* @__PURE__ */ Symbol("reset");
1754
1766
  function isRequired(schema, name) {
1755
- return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
1767
+ return Array.isArray(schema.required) && schema.required.includes(name);
1756
1768
  }
1757
1769
  function getDefaultValue(translateString, type) {
1758
1770
  switch (type) {
@@ -1771,7 +1783,7 @@
1771
1783
  return translateString(utils.TranslatableString.NewStringDefault);
1772
1784
  }
1773
1785
  }
1774
- function ObjectFieldProperty(props) {
1786
+ function ObjectFieldPropertyFn(props) {
1775
1787
  const {
1776
1788
  fieldPathId,
1777
1789
  schema,
@@ -1791,22 +1803,23 @@
1791
1803
  handleRemoveProperty,
1792
1804
  addedByAdditionalProperties
1793
1805
  } = props;
1794
- const [wasPropertyKeyModified, setWasPropertyKeyModified] = react$1.useState(false);
1806
+ const [wasPropertyKeyModified, setWasPropertyKeyModified] = react.useState(false);
1795
1807
  const { globalFormOptions, fields: fields2 } = registry;
1796
1808
  const { SchemaField: SchemaField2 } = fields2;
1797
1809
  const innerFieldIdPathId = utils.useDeepCompareMemo(
1798
1810
  utils.toFieldPathId(propertyName, globalFormOptions, fieldPathId.path)
1799
1811
  );
1800
- const onPropertyChange = react$1.useCallback(
1812
+ const onPropertyChange = react.useCallback(
1801
1813
  (value, path, newErrorSchema, id) => {
1814
+ let normalizedValue = value;
1802
1815
  if (value === void 0 && addedByAdditionalProperties) {
1803
- value = "";
1816
+ normalizedValue = "";
1804
1817
  }
1805
- onChange(value, path, newErrorSchema, id);
1818
+ onChange(normalizedValue, path, newErrorSchema, id);
1806
1819
  },
1807
1820
  [onChange, addedByAdditionalProperties]
1808
1821
  );
1809
- const onKeyRename = react$1.useCallback(
1822
+ const onKeyRename = react.useCallback(
1810
1823
  (value) => {
1811
1824
  if (propertyName !== value) {
1812
1825
  setWasPropertyKeyModified(true);
@@ -1815,7 +1828,7 @@
1815
1828
  },
1816
1829
  [propertyName, handleKeyRename]
1817
1830
  );
1818
- const onKeyRenameBlur = react$1.useCallback(
1831
+ const onKeyRenameBlur = react.useCallback(
1819
1832
  (event) => {
1820
1833
  const {
1821
1834
  target: { value }
@@ -1824,7 +1837,7 @@
1824
1837
  },
1825
1838
  [onKeyRename]
1826
1839
  );
1827
- const onRemoveProperty = react$1.useCallback(() => {
1840
+ const onRemoveProperty = react.useCallback(() => {
1828
1841
  handleRemoveProperty(propertyName);
1829
1842
  }, [propertyName, handleRemoveProperty]);
1830
1843
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -1851,6 +1864,7 @@
1851
1864
  }
1852
1865
  );
1853
1866
  }
1867
+ var ObjectFieldProperty = react.memo(ObjectFieldPropertyFn);
1854
1868
  function ObjectField(props) {
1855
1869
  const {
1856
1870
  schema: rawSchema,
@@ -1871,35 +1885,38 @@
1871
1885
  } = props;
1872
1886
  const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
1873
1887
  const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
1874
- const formDataRef = react$1.useRef(formData);
1888
+ const formDataRef = react.useRef(formData);
1875
1889
  formDataRef.current = formData;
1876
- const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
1877
- const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
1890
+ const schema = react.useMemo(
1891
+ () => schemaUtils.retrieveSchema(rawSchema, formData, true),
1892
+ [schemaUtils, rawSchema, formData]
1893
+ );
1894
+ const uiOptions = react.useMemo(() => utils.getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
1878
1895
  const { properties: schemaProperties = {} } = schema;
1879
1896
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
1880
- const lastRenamedProperty = react$1.useRef({ previousKey: "", currentKey: void 0 });
1897
+ const lastRenamedProperty = react.useRef({ previousKey: "", currentKey: void 0 });
1881
1898
  const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
1882
1899
  const description = uiOptions.description ?? schema.description;
1883
1900
  const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
1884
1901
  const hasFormData = utils.isFormDataAvailable(formData);
1885
1902
  let orderedProperties = [];
1886
- const getAvailableKey = react$1.useCallback(
1887
- (preferredKey, formData2) => {
1903
+ const getAvailableKey = react.useCallback(
1904
+ (preferredKey, existingFormData) => {
1888
1905
  const { duplicateKeySuffixSeparator = "-" } = utils.getUiOptions(uiSchema, globalUiOptions);
1889
1906
  let index = 0;
1890
1907
  let newKey = preferredKey;
1891
- while (has(formData2, newKey)) {
1892
- newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
1908
+ while (has(existingFormData, newKey)) {
1909
+ index += 1;
1910
+ newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
1893
1911
  }
1894
1912
  return newKey;
1895
1913
  },
1896
1914
  [uiSchema, globalUiOptions]
1897
1915
  );
1898
- const onAddProperty = react$1.useCallback(() => {
1916
+ const onAddProperty = react.useCallback(() => {
1899
1917
  if (!(schema.additionalProperties || schema.patternProperties)) {
1900
1918
  return;
1901
1919
  }
1902
- const { translateString: translateString2 } = registry;
1903
1920
  const newFormData = { ...formData };
1904
1921
  const newKey = getAvailableKey("newKey", newFormData);
1905
1922
  if (schema.patternProperties) {
@@ -1914,17 +1931,16 @@
1914
1931
  defaultValue = schema.additionalProperties.default;
1915
1932
  let apSchema = schema.additionalProperties;
1916
1933
  if (utils.REF_KEY in apSchema) {
1917
- const { schemaUtils: schemaUtils2 } = registry;
1918
- apSchema = schemaUtils2.retrieveSchema({ [utils.REF_KEY]: apSchema[utils.REF_KEY] }, formData);
1934
+ apSchema = schemaUtils.retrieveSchema({ [utils.REF_KEY]: apSchema[utils.REF_KEY] }, formData);
1919
1935
  type = apSchema.type;
1920
1936
  constValue = apSchema.const;
1921
- defaultValue = apSchema.default;
1937
+ defaultValue = schemaUtils.getDefaultFormState(apSchema, defaultValue);
1922
1938
  }
1923
1939
  if (!type && (utils.ANY_OF_KEY in apSchema || utils.ONE_OF_KEY in apSchema)) {
1924
1940
  type = "object";
1925
1941
  }
1926
1942
  }
1927
- const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString2, type);
1943
+ const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString, type);
1928
1944
  set(newFormData, newKey, newValue);
1929
1945
  }
1930
1946
  if (lastRenamedProperty.current.previousKey === newKey) {
@@ -1932,8 +1948,8 @@
1932
1948
  lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
1933
1949
  }
1934
1950
  onChange(newFormData, childFieldPathId.path);
1935
- }, [formData, onChange, registry, childFieldPathId, getAvailableKey, schema]);
1936
- const handleKeyRename = react$1.useCallback(
1951
+ }, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
1952
+ const handleKeyRename = react.useCallback(
1937
1953
  (oldKey, newKey) => {
1938
1954
  if (oldKey !== newKey) {
1939
1955
  const currentFormData = formDataRef.current;
@@ -1943,8 +1959,8 @@
1943
1959
  };
1944
1960
  const newKeys = { [oldKey]: actualNewKey };
1945
1961
  const keyValues = Object.keys(newFormData).map((key) => {
1946
- const newKey2 = newKeys[key] || key;
1947
- return { [newKey2]: newFormData[key] };
1962
+ const mappedKey = Object.hasOwn(newKeys, key) ? newKeys[key] : key;
1963
+ return { [mappedKey]: newFormData[key] };
1948
1964
  });
1949
1965
  const renamedObj = Object.assign({}, ...keyValues);
1950
1966
  formDataRef.current = renamedObj;
@@ -1957,13 +1973,13 @@
1957
1973
  },
1958
1974
  [onChange, childFieldPathId, getAvailableKey]
1959
1975
  );
1960
- const handleRemoveProperty = react$1.useCallback(
1976
+ const handleRemoveProperty = react.useCallback(
1961
1977
  (key) => {
1962
1978
  onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
1963
1979
  },
1964
1980
  [onChange, childFieldPathId]
1965
1981
  );
1966
- const getStableKey = react$1.useCallback((property) => {
1982
+ const getStableKey = react.useCallback((property) => {
1967
1983
  if (lastRenamedProperty.current.currentKey === property) {
1968
1984
  return lastRenamedProperty.current.previousKey;
1969
1985
  }
@@ -1975,7 +1991,7 @@
1975
1991
  orderedProperties = utils.orderProperties(properties, uiOptions.order);
1976
1992
  } catch (err) {
1977
1993
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1978
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(markdownToJsx.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
1994
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
1979
1995
  /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema) })
1980
1996
  ] });
1981
1997
  }
@@ -1986,20 +2002,22 @@
1986
2002
  // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
1987
2003
  title: uiOptions.label === false ? "" : templateTitle,
1988
2004
  description: uiOptions.label === false ? void 0 : description,
1989
- properties: orderedProperties.map((name2) => {
1990
- const addedByAdditionalProperties = has(schema, [utils.PROPERTIES_KEY, name2, utils.ADDITIONAL_PROPERTY_FLAG]);
1991
- const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
2005
+ properties: orderedProperties.map((propertyName) => {
2006
+ const addedByAdditionalProperties = Boolean(
2007
+ schema.properties?.[propertyName]?.[utils.ADDITIONAL_PROPERTY_FLAG]
2008
+ );
2009
+ const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
1992
2010
  const hidden = utils.getUiOptions(fieldUiSchema).widget === "hidden";
1993
2011
  const content = /* @__PURE__ */ jsxRuntime.jsx(
1994
2012
  ObjectFieldProperty,
1995
2013
  {
1996
- propertyName: name2,
1997
- required: isRequired(schema, name2),
1998
- schema: get(schema, [utils.PROPERTIES_KEY, name2], {}),
2014
+ propertyName,
2015
+ required: isRequired(schema, propertyName),
2016
+ schema: get(schema, [utils.PROPERTIES_KEY, propertyName], {}),
1999
2017
  uiSchema: fieldUiSchema,
2000
- errorSchema: get(errorSchema, [name2]),
2018
+ errorSchema: get(errorSchema, [propertyName]),
2001
2019
  fieldPathId: childFieldPathId,
2002
- formData: get(formData, [name2]),
2020
+ formData: get(formData, [propertyName]),
2003
2021
  handleKeyRename,
2004
2022
  handleRemoveProperty,
2005
2023
  addedByAdditionalProperties,
@@ -2011,11 +2029,11 @@
2011
2029
  readonly,
2012
2030
  hideError
2013
2031
  },
2014
- getStableKey(name2)
2032
+ getStableKey(propertyName)
2015
2033
  );
2016
2034
  return {
2017
2035
  content,
2018
- name: name2,
2036
+ name: propertyName,
2019
2037
  readonly,
2020
2038
  disabled,
2021
2039
  required,
@@ -2103,8 +2121,8 @@
2103
2121
  null: "NullField"
2104
2122
  };
2105
2123
  function getFieldComponent(schema, uiOptions, registry) {
2106
- const field = uiOptions.field;
2107
- const { fields: fields2 } = registry;
2124
+ const { field } = uiOptions;
2125
+ const { fields: fields2, schemaUtils } = registry;
2108
2126
  if (typeof field === "function") {
2109
2127
  return field;
2110
2128
  }
@@ -2118,10 +2136,10 @@
2118
2136
  if (schemaId && schemaId in fields2) {
2119
2137
  componentName = schemaId;
2120
2138
  }
2121
- if (!componentName && (schema.anyOf || schema.oneOf)) {
2139
+ if ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) && componentName !== "ObjectField") {
2122
2140
  return () => null;
2123
2141
  }
2124
- return componentName in fields2 ? fields2[componentName] : fields2["FallbackField"];
2142
+ return componentName in fields2 ? fields2[componentName] : fields2.FallbackField;
2125
2143
  }
2126
2144
  function SchemaFieldRender(props) {
2127
2145
  const {
@@ -2140,7 +2158,18 @@
2140
2158
  wasPropertyKeyModified = false
2141
2159
  } = props;
2142
2160
  const { schemaUtils, globalFormOptions, globalUiOptions, fields: fields2 } = registry;
2143
- const { AnyOfField: _AnyOfField, OneOfField: _OneOfField } = fields2;
2161
+ const { AnyOfField: _AnyOfField, OneOfField: _OneOfField, CyclicSchemaField: CyclicSchemaField2 } = fields2;
2162
+ const fieldId = fieldPathId[utils.ID_KEY];
2163
+ const handleFieldComponentChange = react.useCallback(
2164
+ (newFormData, path, newErrorSchema, id2) => {
2165
+ const theId = id2 || fieldId;
2166
+ return onChange(newFormData, path, newErrorSchema, theId);
2167
+ },
2168
+ [fieldId, onChange]
2169
+ );
2170
+ if (_schema[utils.RJSF_REF_CYCLE_KEY]) {
2171
+ return /* @__PURE__ */ jsxRuntime.jsx(CyclicSchemaField2, { ...props });
2172
+ }
2144
2173
  const uiSchema = utils.resolveUiSchema(_schema, _uiSchema, registry);
2145
2174
  const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
2146
2175
  const FieldTemplate2 = utils.getTemplate("FieldTemplate", registry, uiOptions);
@@ -2152,14 +2181,6 @@
2152
2181
  const FieldHelpTemplate2 = utils.getTemplate("FieldHelpTemplate", registry, uiOptions);
2153
2182
  const FieldErrorTemplate2 = utils.getTemplate("FieldErrorTemplate", registry, uiOptions);
2154
2183
  const schema = schemaUtils.retrieveSchema(_schema, formData);
2155
- const fieldId = fieldPathId[utils.ID_KEY];
2156
- const handleFieldComponentChange = react$1.useCallback(
2157
- (formData2, path, newErrorSchema, id2) => {
2158
- const theId = id2 || fieldId;
2159
- return onChange(formData2, path, newErrorSchema, theId);
2160
- },
2161
- [fieldId, onChange]
2162
- );
2163
2184
  const FieldComponent = getFieldComponent(schema, uiOptions, registry);
2164
2185
  const isDeprecated = Boolean(schema.deprecated);
2165
2186
  const deprecatedHandling = isDeprecated ? uiOptions.deprecatedHandling ?? "label" : void 0;
@@ -2180,12 +2201,12 @@
2180
2201
  if (schema[utils.ANY_OF_KEY]) {
2181
2202
  XxxOfField = _AnyOfField;
2182
2203
  XxxOfOptions = schema[utils.ANY_OF_KEY].map(
2183
- (_schema2) => schemaUtils.retrieveSchema(isObject(_schema2) ? _schema2 : {}, formData)
2204
+ (xxxOfSchema) => schemaUtils.retrieveSchema(isObject(xxxOfSchema) ? xxxOfSchema : {}, formData)
2184
2205
  );
2185
2206
  } else if (schema[utils.ONE_OF_KEY]) {
2186
2207
  XxxOfField = _OneOfField;
2187
2208
  XxxOfOptions = schema[utils.ONE_OF_KEY].map(
2188
- (_schema2) => schemaUtils.retrieveSchema(isObject(_schema2) ? _schema2 : {}, formData)
2209
+ (xxxOfSchema) => schemaUtils.retrieveSchema(isObject(xxxOfSchema) ? xxxOfSchema : {}, formData)
2189
2210
  );
2190
2211
  }
2191
2212
  const isOptionalRender = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
@@ -2230,7 +2251,7 @@
2230
2251
  label = registry.translateString(utils.TranslatableString.DeprecatedLabel, [label]);
2231
2252
  }
2232
2253
  const description = uiOptions.description || props.schema.description || schema.description || "";
2233
- const help = uiOptions.help;
2254
+ const { help } = uiOptions;
2234
2255
  const hidden = uiOptions.widget === "hidden" || deprecatedHandling === "hide";
2235
2256
  const classNames = ["rjsf-field", `rjsf-field-${utils.getSchemaType(schema)}`];
2236
2257
  if (!hideError && __errors && __errors.length > 0) {
@@ -2321,18 +2342,16 @@
2321
2342
  )
2322
2343
  ] }) });
2323
2344
  }
2324
- var SchemaField = class extends react$1.Component {
2325
- shouldComponentUpdate(nextProps) {
2326
- const {
2327
- registry: { globalFormOptions }
2328
- } = this.props;
2329
- const { experimental_componentUpdateStrategy = "customDeep" } = globalFormOptions;
2330
- return utils.shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
2345
+ var SchemaField = react.memo(SchemaFieldRender, (prevProps, nextProps) => {
2346
+ const { experimental_componentUpdateStrategy = "customDeep" } = nextProps.registry.globalFormOptions;
2347
+ if (experimental_componentUpdateStrategy === "always") {
2348
+ return false;
2331
2349
  }
2332
- render() {
2333
- return /* @__PURE__ */ jsxRuntime.jsx(SchemaFieldRender, { ...this.props });
2350
+ if (experimental_componentUpdateStrategy === "shallow") {
2351
+ return utils.shallowEquals(prevProps, nextProps);
2334
2352
  }
2335
- };
2353
+ return utils.deepEquals(prevProps, nextProps);
2354
+ });
2336
2355
  var SchemaField_default = SchemaField;
2337
2356
  function StringField(props) {
2338
2357
  const {
@@ -2364,10 +2383,8 @@
2364
2383
  const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
2365
2384
  const label = uiTitle ?? title ?? schemaTitle ?? name;
2366
2385
  const Widget = utils.getWidget(schema, widget, widgets2);
2367
- const onWidgetChange = react$1.useCallback(
2368
- (value, errorSchema, id) => {
2369
- return onChange(value, fieldPathId.path, errorSchema, id);
2370
- },
2386
+ const onWidgetChange = react.useCallback(
2387
+ (value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
2371
2388
  [onChange, fieldPathId]
2372
2389
  );
2373
2390
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2405,6 +2422,7 @@
2405
2422
  ArrayField,
2406
2423
  // ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
2407
2424
  BooleanField: BooleanField_default,
2425
+ CyclicSchemaField,
2408
2426
  FallbackField,
2409
2427
  LayoutGridField,
2410
2428
  LayoutHeaderField,
@@ -2630,9 +2648,10 @@
2630
2648
  }
2631
2649
  return /* @__PURE__ */ jsxRuntime.jsx("datalist", { id: utils.examplesId(id), children: examples.concat(
2632
2650
  schemaDefault !== void 0 && !examples.map(String).includes(String(schemaDefault)) ? [schemaDefault] : []
2633
- ).map((example) => {
2634
- return /* @__PURE__ */ jsxRuntime.jsx("option", { value: example }, String(example));
2635
- }) }, `datalist_${id}`);
2651
+ ).map((example) => (
2652
+ // oxlint-disable-next-line jsx-a11y/control-has-associated-label
2653
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: example }, String(example))
2654
+ )) }, `datalist_${id}`);
2636
2655
  }
2637
2656
  function BaseInputTemplate(props) {
2638
2657
  const {
@@ -2675,19 +2694,16 @@
2675
2694
  } else {
2676
2695
  inputValue = value == null ? "" : value;
2677
2696
  }
2678
- const _onChange = react$1.useCallback(
2679
- ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
2697
+ const handleChange = react.useCallback(
2698
+ ({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
2680
2699
  [onChange, options]
2681
2700
  );
2682
- const _onBlur = react$1.useCallback(
2683
- ({ target }) => onBlur(id, target && target.value),
2684
- [onBlur, id]
2685
- );
2686
- const _onFocus = react$1.useCallback(
2687
- ({ target }) => onFocus(id, target && target.value),
2701
+ const handleBlur = react.useCallback(({ target }) => onBlur(id, target?.value), [onBlur, id]);
2702
+ const handleFocus = react.useCallback(
2703
+ ({ target }) => onFocus(id, target?.value),
2688
2704
  [onFocus, id]
2689
2705
  );
2690
- const _onClear = react$1.useCallback(
2706
+ const handleClear = react.useCallback(
2691
2707
  (e) => {
2692
2708
  e.preventDefault();
2693
2709
  e.stopPropagation();
@@ -2708,45 +2724,51 @@
2708
2724
  value: inputValue,
2709
2725
  ...inputProps,
2710
2726
  list: schema.examples ? utils.examplesId(id) : void 0,
2711
- onChange: onChangeOverride || _onChange,
2712
- onBlur: _onBlur,
2713
- onFocus: _onFocus,
2727
+ onChange: onChangeOverride || handleChange,
2728
+ onBlur: handleBlur,
2729
+ onFocus: handleFocus,
2714
2730
  "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
2715
2731
  }
2716
2732
  ),
2717
- options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ jsxRuntime.jsx(ClearButton2, { registry, onClick: _onClear }),
2733
+ options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ jsxRuntime.jsx(ClearButton2, { registry, onClick: handleClear }),
2718
2734
  /* @__PURE__ */ jsxRuntime.jsx(SchemaExamples, { id, schema })
2719
2735
  ] });
2720
2736
  }
2721
- function IconButton(props) {
2737
+ function IconButtonFn(props) {
2722
2738
  const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
2723
2739
  return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsxRuntime.jsx("i", { className: `glyphicon glyphicon-${icon}` }) });
2724
2740
  }
2725
- function CopyButton(props) {
2741
+ var IconButton = react.memo(IconButtonFn);
2742
+ var IconButton_default = IconButton;
2743
+ function CopyButtonFn(props) {
2726
2744
  const {
2727
2745
  registry: { translateString }
2728
2746
  } = props;
2729
2747
  return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.CopyButton), ...props, icon: "copy" });
2730
2748
  }
2731
- function MoveDownButton(props) {
2749
+ var CopyButton = react.memo(CopyButtonFn);
2750
+ function MoveDownButtonFn(props) {
2732
2751
  const {
2733
2752
  registry: { translateString }
2734
2753
  } = props;
2735
2754
  return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.MoveDownButton), ...props, icon: "arrow-down" });
2736
2755
  }
2737
- function MoveUpButton(props) {
2756
+ var MoveDownButton = react.memo(MoveDownButtonFn);
2757
+ function MoveUpButtonFn(props) {
2738
2758
  const {
2739
2759
  registry: { translateString }
2740
2760
  } = props;
2741
2761
  return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.MoveUpButton), ...props, icon: "arrow-up" });
2742
2762
  }
2743
- function RemoveButton(props) {
2763
+ var MoveUpButton = react.memo(MoveUpButtonFn);
2764
+ function RemoveButtonFn(props) {
2744
2765
  const {
2745
2766
  registry: { translateString }
2746
2767
  } = props;
2747
2768
  return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.RemoveButton), ...props, iconType: "danger", icon: "remove" });
2748
2769
  }
2749
- function ClearButton({
2770
+ var RemoveButton = react.memo(RemoveButtonFn);
2771
+ function ClearButtonFn({
2750
2772
  id,
2751
2773
  className,
2752
2774
  onClick,
@@ -2770,6 +2792,7 @@
2770
2792
  }
2771
2793
  );
2772
2794
  }
2795
+ var ClearButton = react.memo(ClearButtonFn);
2773
2796
  function AddButton({
2774
2797
  id,
2775
2798
  className,
@@ -2783,7 +2806,7 @@
2783
2806
  {
2784
2807
  className: `col-xs-4 col-sm-2 col-lg-1 col-xs-offset-8 col-sm-offset-10 col-lg-offset-11 text-right ${className}`,
2785
2808
  children: /* @__PURE__ */ jsxRuntime.jsx(
2786
- IconButton,
2809
+ IconButton_default,
2787
2810
  {
2788
2811
  id,
2789
2812
  iconType: "info",
@@ -2819,12 +2842,33 @@
2819
2842
  };
2820
2843
  }
2821
2844
  var ButtonTemplates_default = buttonTemplates;
2845
+ function CyclicSchemaExpandTemplate(props) {
2846
+ const { name, fieldPathId, registry, onExpand } = props;
2847
+ const { translateString } = registry;
2848
+ const buttonId5 = `${fieldPathId[utils.ID_KEY]}-button`;
2849
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "1rem" }, children: [
2850
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-danger", children: translateString(utils.TranslatableString.CycleDetected, [name]) }),
2851
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2852
+ /* @__PURE__ */ jsxRuntime.jsx(
2853
+ "button",
2854
+ {
2855
+ id: buttonId5,
2856
+ type: "button",
2857
+ className: "btn btn-sm btn-warning",
2858
+ onClick: () => onExpand(fieldPathId[utils.ID_KEY]),
2859
+ children: translateString(utils.TranslatableString.ExpandButton)
2860
+ }
2861
+ ),
2862
+ " "
2863
+ ] })
2864
+ ] });
2865
+ }
2822
2866
  var TEST_IDS = utils.getTestIds();
2823
2867
  function RichDescription({ description, registry, uiSchema = {} }) {
2824
2868
  const { globalUiOptions } = registry;
2825
2869
  const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
2826
2870
  if (uiOptions.enableMarkdownInDescription && typeof description === "string") {
2827
- return /* @__PURE__ */ jsxRuntime.jsx(react.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
2871
+ return /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
2828
2872
  }
2829
2873
  return description;
2830
2874
  }
@@ -2843,9 +2887,10 @@
2843
2887
  const { translateString } = registry;
2844
2888
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "panel panel-danger errors", children: [
2845
2889
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "panel-heading", children: /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "panel-title", children: translateString(utils.TranslatableString.ErrorsLabel) }) }),
2846
- /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-group", children: errors.map((error, i) => {
2847
- return /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-group-item text-danger", children: error.stack }, i);
2848
- }) })
2890
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-group", children: errors.map((error, i) => (
2891
+ // oxlint-disable-next-line react/no-array-index-key
2892
+ /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-group-item text-danger", children: error.stack }, i)
2893
+ )) })
2849
2894
  ] });
2850
2895
  }
2851
2896
  function FallbackFieldTemplate(props) {
@@ -2870,9 +2915,10 @@
2870
2915
  return null;
2871
2916
  }
2872
2917
  const id = utils.errorId(fieldPathId);
2873
- return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
2874
- return /* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-danger", children: error }, index);
2875
- }) }) });
2918
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => (
2919
+ // oxlint-disable-next-line react/no-array-index-key
2920
+ /* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-danger", children: error }, index)
2921
+ )) }) });
2876
2922
  }
2877
2923
  var TEST_IDS2 = utils.getTestIds();
2878
2924
  function RichHelp({
@@ -2883,7 +2929,7 @@
2883
2929
  const { globalUiOptions } = registry;
2884
2930
  const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
2885
2931
  if (uiOptions.enableMarkdownInHelp && typeof help === "string") {
2886
- return /* @__PURE__ */ jsxRuntime.jsx(react.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
2932
+ return /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
2887
2933
  }
2888
2934
  return help;
2889
2935
  }
@@ -3014,7 +3060,7 @@
3014
3060
  const { id, registry, label, onAddClick, onRemoveClick } = props;
3015
3061
  if (onAddClick) {
3016
3062
  return /* @__PURE__ */ jsxRuntime.jsx(
3017
- IconButton,
3063
+ IconButton_default,
3018
3064
  {
3019
3065
  id,
3020
3066
  registry,
@@ -3024,9 +3070,10 @@
3024
3070
  title: label
3025
3071
  }
3026
3072
  );
3027
- } else if (onRemoveClick) {
3073
+ }
3074
+ if (onRemoveClick) {
3028
3075
  return /* @__PURE__ */ jsxRuntime.jsx(
3029
- IconButton,
3076
+ IconButton_default,
3030
3077
  {
3031
3078
  id,
3032
3079
  registry,
@@ -3053,7 +3100,7 @@
3053
3100
  const { translateString } = registry;
3054
3101
  let translateEnum = utils.TranslatableString.UnsupportedField;
3055
3102
  const translateParams = [];
3056
- if (fieldPathId && fieldPathId.$id) {
3103
+ if (fieldPathId?.$id) {
3057
3104
  translateEnum = utils.TranslatableString.UnsupportedFieldWithId;
3058
3105
  translateParams.push(fieldPathId.$id);
3059
3106
  }
@@ -3062,7 +3109,7 @@
3062
3109
  translateParams.push(reason);
3063
3110
  }
3064
3111
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "unsupported-field", children: [
3065
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(markdownToJsx.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
3112
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
3066
3113
  schema && /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema, null, 2) })
3067
3114
  ] });
3068
3115
  }
@@ -3143,6 +3190,7 @@
3143
3190
  ArrayFieldTitleTemplate,
3144
3191
  ButtonTemplates: ButtonTemplates_default(),
3145
3192
  BaseInputTemplate,
3193
+ CyclicSchemaExpandTemplate,
3146
3194
  DescriptionFieldTemplate: DescriptionField,
3147
3195
  ErrorListTemplate: ErrorList,
3148
3196
  FallbackFieldTemplate,
@@ -3172,23 +3220,26 @@
3172
3220
  const { translateString } = registry;
3173
3221
  const { elements, handleChange, handleClear, handleSetNow } = utils.useAltDateWidgetProps(props);
3174
3222
  return /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "list-inline", children: [
3175
- elements.map((elemProps, i) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx(
3176
- utils.DateElement,
3177
- {
3178
- rootId: id,
3179
- name,
3180
- select: handleChange,
3181
- ...elemProps,
3182
- disabled,
3183
- readonly,
3184
- registry,
3185
- onBlur,
3186
- onFocus,
3187
- autofocus: autofocus && i === 0
3188
- }
3189
- ) }, i)),
3190
- (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(utils.TranslatableString.NowLabel) }) }),
3191
- (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(utils.TranslatableString.ClearLabel) }) })
3223
+ elements.map((elemProps, i) => (
3224
+ // oxlint-disable-next-line react/no-array-index-key
3225
+ /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx(
3226
+ utils.DateElement,
3227
+ {
3228
+ rootId: id,
3229
+ name,
3230
+ select: handleChange,
3231
+ ...elemProps,
3232
+ disabled,
3233
+ readonly,
3234
+ registry,
3235
+ onBlur,
3236
+ onFocus,
3237
+ autofocus: autofocus && i === 0
3238
+ }
3239
+ ) }, i)
3240
+ )),
3241
+ (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(utils.TranslatableString.NowLabel) }) }),
3242
+ (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(utils.TranslatableString.ClearLabel) }) })
3192
3243
  ] });
3193
3244
  }
3194
3245
  var AltDateWidget_default = AltDateWidget;
@@ -3207,17 +3258,17 @@
3207
3258
  const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
3208
3259
  const optionValueFormat = utils.getOptionValueFormat(options);
3209
3260
  const checkboxesValues = Array.isArray(value) ? value : [value];
3210
- const handleBlur = react$1.useCallback(
3211
- ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
3261
+ const handleBlur = react.useCallback(
3262
+ ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)),
3212
3263
  [onBlur, id, enumOptions, emptyValue, optionValueFormat]
3213
3264
  );
3214
- const handleFocus = react$1.useCallback(
3215
- ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
3265
+ const handleFocus = react.useCallback(
3266
+ ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)),
3216
3267
  [onFocus, id, enumOptions, emptyValue, optionValueFormat]
3217
3268
  );
3218
3269
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
3219
3270
  const checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
3220
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
3271
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
3221
3272
  const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
3222
3273
  const handleChange = (event) => {
3223
3274
  if (event.target.checked) {
@@ -3245,7 +3296,7 @@
3245
3296
  ),
3246
3297
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label })
3247
3298
  ] });
3248
- return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsxRuntime.jsx("label", { children: checkbox }) }, index);
3299
+ return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, String(option.value)) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsxRuntime.jsx("label", { children: checkbox }) }, String(option.value));
3249
3300
  }) });
3250
3301
  }
3251
3302
  var CheckboxesWidget_default = CheckboxesWidget;
@@ -3272,15 +3323,15 @@
3272
3323
  options
3273
3324
  );
3274
3325
  const required = utils.schemaRequiresTrueValue(schema);
3275
- const handleChange = react$1.useCallback(
3326
+ const handleChange = react.useCallback(
3276
3327
  (event) => onChange(event.target.checked),
3277
3328
  [onChange]
3278
3329
  );
3279
- const handleBlur = react$1.useCallback(
3330
+ const handleBlur = react.useCallback(
3280
3331
  (event) => onBlur(id, event.target.checked),
3281
3332
  [onBlur, id]
3282
3333
  );
3283
- const handleFocus = react$1.useCallback(
3334
+ const handleFocus = react.useCallback(
3284
3335
  (event) => onFocus(id, event.target.checked),
3285
3336
  [onFocus, id]
3286
3337
  );
@@ -3334,14 +3385,14 @@
3334
3385
  type: "datetime-local",
3335
3386
  ...props,
3336
3387
  value: utils.utcToLocal(value),
3337
- onChange: (value2) => onChange(utils.localToUTC(value2))
3388
+ onChange: (newValue) => onChange(utils.localToUTC(newValue))
3338
3389
  }
3339
3390
  );
3340
3391
  }
3341
3392
  function DateWidget(props) {
3342
3393
  const { onChange, options, registry } = props;
3343
3394
  const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
3344
- const handleChange = react$1.useCallback((value) => onChange(value || void 0), [onChange]);
3395
+ const handleChange = react.useCallback((value) => onChange(value || void 0), [onChange]);
3345
3396
  return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
3346
3397
  }
3347
3398
  function EmailWidget(props) {
@@ -3358,12 +3409,13 @@
3358
3409
  if (!dataURL) {
3359
3410
  return null;
3360
3411
  }
3412
+ const previewLabel = translateString(utils.TranslatableString.PreviewLabel);
3361
3413
  if (["image/jpeg", "image/png"].includes(type)) {
3362
- return /* @__PURE__ */ jsxRuntime.jsx("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
3414
+ return /* @__PURE__ */ jsxRuntime.jsx("img", { src: dataURL, alt: previewLabel, style: { maxWidth: "100%" }, className: "file-preview" });
3363
3415
  }
3364
3416
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3365
3417
  " ",
3366
- /* @__PURE__ */ jsxRuntime.jsx("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(utils.TranslatableString.PreviewLabel) })
3418
+ /* @__PURE__ */ jsxRuntime.jsx("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: previewLabel })
3367
3419
  ] });
3368
3420
  }
3369
3421
  function FilesInfo({
@@ -3381,11 +3433,14 @@
3381
3433
  return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
3382
3434
  const { name, size, type } = fileInfo;
3383
3435
  const handleRemove = () => onRemove(key);
3384
- return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
3385
- /* @__PURE__ */ jsxRuntime.jsx(markdownToJsx.Markdown, { children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)]) }),
3386
- preview && /* @__PURE__ */ jsxRuntime.jsx(FileInfoPreview, { fileInfo, registry }),
3387
- /* @__PURE__ */ jsxRuntime.jsx(RemoveButton2, { onClick: handleRemove, registry })
3388
- ] }, key);
3436
+ return (
3437
+ // oxlint-disable-next-line react/no-array-index-key
3438
+ /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
3439
+ /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)]) }),
3440
+ preview && /* @__PURE__ */ jsxRuntime.jsx(FileInfoPreview, { fileInfo, registry }),
3441
+ /* @__PURE__ */ jsxRuntime.jsx(RemoveButton2, { onClick: handleRemove, registry })
3442
+ ] }, key)
3443
+ );
3389
3444
  }) });
3390
3445
  }
3391
3446
  function FileWidget(props) {
@@ -3451,17 +3506,17 @@
3451
3506
  }) {
3452
3507
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
3453
3508
  const optionValueFormat = utils.getOptionValueFormat(options);
3454
- const handleBlur = react$1.useCallback(
3455
- ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
3509
+ const handleBlur = react.useCallback(
3510
+ ({ target }) => onBlur(id, utils.enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)),
3456
3511
  [onBlur, enumOptions, emptyValue, id, optionValueFormat]
3457
3512
  );
3458
- const handleFocus = react$1.useCallback(
3459
- ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
3513
+ const handleFocus = react.useCallback(
3514
+ ({ target }) => onFocus(id, utils.enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)),
3460
3515
  [onFocus, enumOptions, emptyValue, id, optionValueFormat]
3461
3516
  );
3462
3517
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
3463
3518
  const checked = utils.enumOptionsIsSelected(option.value, value);
3464
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
3519
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
3465
3520
  const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
3466
3521
  const handleChange = () => onChange(option.value);
3467
3522
  const radio = /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
@@ -3484,7 +3539,7 @@
3484
3539
  ),
3485
3540
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label })
3486
3541
  ] });
3487
- return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `radio-inline ${disabledCls}`, children: radio }, i) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsxRuntime.jsx("label", { children: radio }) }, i);
3542
+ return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `radio-inline ${disabledCls}`, children: radio }, String(option.value)) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsxRuntime.jsx("label", { children: radio }) }, String(option.value));
3488
3543
  }) });
3489
3544
  }
3490
3545
  var RadioWidget_default = RadioWidget;
@@ -3517,7 +3572,7 @@
3517
3572
  const { stars = 5, shape = "star" } = options;
3518
3573
  const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
3519
3574
  const min = schema.minimum || 0;
3520
- const handleStarClick = react$1.useCallback(
3575
+ const handleStarClick = react.useCallback(
3521
3576
  (starValue) => {
3522
3577
  if (!disabled && !readonly) {
3523
3578
  onChange(starValue);
@@ -3525,7 +3580,7 @@
3525
3580
  },
3526
3581
  [onChange, disabled, readonly]
3527
3582
  );
3528
- const handleFocus = react$1.useCallback(
3583
+ const handleFocus = react.useCallback(
3529
3584
  (event) => {
3530
3585
  if (onFocus) {
3531
3586
  const starValue = Number(event.target.dataset.value);
@@ -3534,7 +3589,7 @@
3534
3589
  },
3535
3590
  [onFocus, id]
3536
3591
  );
3537
- const handleBlur = react$1.useCallback(
3592
+ const handleBlur = react.useCallback(
3538
3593
  (event) => {
3539
3594
  if (onBlur) {
3540
3595
  const starValue = Number(event.target.dataset.value);
@@ -3549,7 +3604,7 @@
3549
3604
  }
3550
3605
  return isFilled ? "\u2605" : "\u2606";
3551
3606
  };
3552
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
3607
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3553
3608
  "div",
3554
3609
  {
3555
3610
  className: "rating-widget",
@@ -3566,6 +3621,7 @@
3566
3621
  "span",
3567
3622
  {
3568
3623
  onClick: () => handleStarClick(starValue),
3624
+ onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && handleStarClick(starValue),
3569
3625
  onFocus: handleFocus,
3570
3626
  onBlur: handleBlur,
3571
3627
  "data-value": starValue,
@@ -3598,7 +3654,7 @@
3598
3654
  )
3599
3655
  ]
3600
3656
  }
3601
- ) });
3657
+ );
3602
3658
  }
3603
3659
  function getValue(event, multiple) {
3604
3660
  if (multiple) {
@@ -3620,26 +3676,28 @@
3620
3676
  onBlur,
3621
3677
  onFocus,
3622
3678
  placeholder,
3623
- htmlName
3679
+ htmlName,
3680
+ registry,
3681
+ uiSchema
3624
3682
  }) {
3625
3683
  const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
3626
3684
  const emptyValue = multiple ? [] : "";
3627
3685
  const optionValueFormat = utils.getOptionValueFormat(options);
3628
- const handleFocus = react$1.useCallback(
3686
+ const handleFocus = react.useCallback(
3629
3687
  (event) => {
3630
3688
  const newValue = getValue(event, multiple);
3631
3689
  return onFocus(id, utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
3632
3690
  },
3633
3691
  [onFocus, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
3634
3692
  );
3635
- const handleBlur = react$1.useCallback(
3693
+ const handleBlur = react.useCallback(
3636
3694
  (event) => {
3637
3695
  const newValue = getValue(event, multiple);
3638
3696
  return onBlur(id, utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
3639
3697
  },
3640
3698
  [onBlur, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
3641
3699
  );
3642
- const handleChange = react$1.useCallback(
3700
+ const handleChange = react.useCallback(
3643
3701
  (event) => {
3644
3702
  const newValue = getValue(event, multiple);
3645
3703
  return onChange(utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
@@ -3648,36 +3706,57 @@
3648
3706
  );
3649
3707
  const selectValue = utils.enumOptionSelectedValue(value, enumOptions, multiple, optionValueFormat, emptyValue);
3650
3708
  const showPlaceholderOption = !multiple && schema.default === void 0;
3651
- return /* @__PURE__ */ jsxRuntime.jsxs(
3652
- "select",
3653
- {
3654
- id,
3655
- name: htmlName || id,
3656
- multiple,
3657
- role: "combobox",
3658
- className: "form-control",
3659
- value: selectValue,
3660
- required,
3661
- disabled: disabled || readonly,
3662
- autoFocus: autofocus,
3663
- onBlur: handleBlur,
3664
- onFocus: handleFocus,
3665
- onChange: handleChange,
3666
- "aria-describedby": utils.ariaDescribedByIds(id),
3667
- children: [
3668
- showPlaceholderOption && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: placeholder }),
3669
- Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label }, i) => {
3670
- const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
3671
- return /* @__PURE__ */ jsxRuntime.jsx("option", { value: utils.enumOptionValueEncoder(value2, i, optionValueFormat), disabled: disabled2, children: label }, i);
3672
- })
3673
- ]
3674
- }
3675
- );
3709
+ utils.logUnsupportedDefaultForEnum(id, schema, enumOptions, multiple);
3710
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3711
+ /* @__PURE__ */ jsxRuntime.jsx(
3712
+ utils.SelectedOptionDescription,
3713
+ {
3714
+ id,
3715
+ multiple,
3716
+ options,
3717
+ registry,
3718
+ uiSchema,
3719
+ value
3720
+ }
3721
+ ),
3722
+ /* @__PURE__ */ jsxRuntime.jsxs(
3723
+ "select",
3724
+ {
3725
+ id,
3726
+ name: htmlName || id,
3727
+ multiple,
3728
+ className: "form-control",
3729
+ value: selectValue,
3730
+ required,
3731
+ disabled: disabled || readonly,
3732
+ autoFocus: autofocus,
3733
+ onBlur: handleBlur,
3734
+ onFocus: handleFocus,
3735
+ onChange: handleChange,
3736
+ "aria-describedby": utils.ariaDescribedByIds(id),
3737
+ children: [
3738
+ showPlaceholderOption && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: placeholder }),
3739
+ Array.isArray(enumOptions) && enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
3740
+ const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
3741
+ return /* @__PURE__ */ jsxRuntime.jsx(
3742
+ "option",
3743
+ {
3744
+ value: utils.enumOptionValueEncoder(enumValue, i, optionValueFormat),
3745
+ disabled: isDisabled,
3746
+ children: enumLabel
3747
+ },
3748
+ String(enumValue)
3749
+ );
3750
+ })
3751
+ ]
3752
+ }
3753
+ )
3754
+ ] });
3676
3755
  }
3677
3756
  var SelectWidget_default = SelectWidget;
3678
3757
  function TextareaWidget({
3679
3758
  id,
3680
- options = {},
3759
+ options,
3681
3760
  placeholder,
3682
3761
  value,
3683
3762
  required,
@@ -3689,16 +3768,16 @@
3689
3768
  onFocus,
3690
3769
  htmlName
3691
3770
  }) {
3692
- const handleChange = react$1.useCallback(
3693
- ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
3771
+ const handleChange = react.useCallback(
3772
+ ({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
3694
3773
  [onChange, options.emptyValue]
3695
3774
  );
3696
- const handleBlur = react$1.useCallback(
3697
- ({ target }) => onBlur(id, target && target.value),
3775
+ const handleBlur = react.useCallback(
3776
+ ({ target }) => onBlur(id, target?.value),
3698
3777
  [onBlur, id]
3699
3778
  );
3700
- const handleFocus = react$1.useCallback(
3701
- ({ target }) => onFocus(id, target && target.value),
3779
+ const handleFocus = react.useCallback(
3780
+ ({ target }) => onFocus(id, target?.value),
3702
3781
  [id, onFocus]
3703
3782
  );
3704
3783
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -3707,7 +3786,7 @@
3707
3786
  id,
3708
3787
  name: htmlName || id,
3709
3788
  className: "form-control",
3710
- value: value ? value : "",
3789
+ value: value || "",
3711
3790
  placeholder,
3712
3791
  required,
3713
3792
  disabled,
@@ -3730,7 +3809,7 @@
3730
3809
  function TimeWidget(props) {
3731
3810
  const { onChange, options, registry } = props;
3732
3811
  const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
3733
- const handleChange = react$1.useCallback((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
3812
+ const handleChange = react.useCallback((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
3734
3813
  return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
3735
3814
  }
3736
3815
  function UpDownWidget(props) {
@@ -3793,7 +3872,7 @@
3793
3872
  ...status !== void 0 && { status }
3794
3873
  };
3795
3874
  }
3796
- var Form = class extends react$1.Component {
3875
+ var Form = class _Form extends react.Component {
3797
3876
  /** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
3798
3877
  * provide any possible type here
3799
3878
  */
@@ -3804,7 +3883,7 @@
3804
3883
  /** Flag to track when we're processing a user-initiated field change.
3805
3884
  * This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
3806
3885
  */
3807
- _isProcessingUserChange = false;
3886
+ isProcessingUserChange = false;
3808
3887
  /** When the `extraErrors` prop changes, re-merges `schemaValidationErrors` + `extraErrors` + `customErrors` into
3809
3888
  * state before render, ensuring the updated errors are visible immediately in a single render cycle.
3810
3889
  *
@@ -3813,7 +3892,7 @@
3813
3892
  * @returns Partial state with re-merged errors if `extraErrors` changed, or `null` if no update is needed
3814
3893
  */
3815
3894
  static getDerivedStateFromProps(props, state) {
3816
- if (props.extraErrors !== state._prevExtraErrors) {
3895
+ if (props.extraErrors !== state.prevExtraErrors) {
3817
3896
  const baseErrors = {
3818
3897
  errors: state.schemaValidationErrors || [],
3819
3898
  errorSchema: state.schemaValidationErrorSchema || {}
@@ -3829,7 +3908,7 @@
3829
3908
  true
3830
3909
  ));
3831
3910
  }
3832
- return { _prevExtraErrors: props.extraErrors, errors, errorSchema };
3911
+ return { prevExtraErrors: props.extraErrors, errors, errorSchema };
3833
3912
  }
3834
3913
  return null;
3835
3914
  }
@@ -3848,12 +3927,12 @@
3848
3927
  const formData = propsFormData ?? initialFormData;
3849
3928
  this.state = {
3850
3929
  ...this.getStateFromProps(props, formData, void 0, void 0, void 0, true),
3851
- _prevExtraErrors: props.extraErrors
3930
+ prevExtraErrors: props.extraErrors
3852
3931
  };
3853
3932
  if (onChange && !utils.deepEquals(this.state.formData, formData)) {
3854
3933
  onChange(toIChangeEvent(this.state));
3855
3934
  }
3856
- this.formElement = react$1.createRef();
3935
+ this.formElement = react.createRef();
3857
3936
  }
3858
3937
  /**
3859
3938
  * `getSnapshotBeforeUpdate` is a React lifecycle method that is invoked right before the most recently rendered
@@ -3913,8 +3992,8 @@
3913
3992
  if (snapshot.shouldUpdate) {
3914
3993
  const { nextState } = snapshot;
3915
3994
  const nextStateDiffersFromProps = !utils.deepEquals(nextState.formData, this.props.formData);
3916
- const wasProcessingUserChange = this._isProcessingUserChange;
3917
- this._isProcessingUserChange = false;
3995
+ const wasProcessingUserChange = this.isProcessingUserChange;
3996
+ this.isProcessingUserChange = false;
3918
3997
  if (wasProcessingUserChange && nextStateDiffersFromProps) {
3919
3998
  return;
3920
3999
  }
@@ -3931,12 +4010,13 @@
3931
4010
  * @param props - The props passed to the `Form`
3932
4011
  * @param inputFormData - The new or current data for the `Form`
3933
4012
  * @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
3934
- * @param isSchemaChanged - A flag indicating whether the schema has changed.
3935
- * @param formDataChangedFields - The changed fields of `formData`
3936
- * @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
4013
+ * @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
4014
+ * @param [formDataChangedFields=[]] - The changed fields of `formData`
4015
+ * @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
4016
+ * @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
3937
4017
  * @returns - The new state for the `Form`
3938
4018
  */
3939
- getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
4019
+ getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false, shouldSanitize = false) {
3940
4020
  const state = this.state || {};
3941
4021
  const schema = "schema" in props ? props.schema : this.props.schema;
3942
4022
  const validator2 = "validator" in props ? props.validator : this.props.validator;
@@ -3947,7 +4027,7 @@
3947
4027
  const mustValidate = edit && !props.noValidate && liveValidate;
3948
4028
  const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
3949
4029
  const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
3950
- let schemaUtils = state.schemaUtils;
4030
+ let { schemaUtils } = state;
3951
4031
  if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
3952
4032
  validator2,
3953
4033
  schema,
@@ -3968,19 +4048,45 @@
3968
4048
  } else if (inputFormData === void 0 && isUncontrolled) {
3969
4049
  defaultsFormData = state.formData;
3970
4050
  }
3971
- const formData = schemaUtils.getDefaultFormState(
3972
- rootSchema,
3973
- defaultsFormData,
3974
- false,
3975
- state.initialDefaultsGenerated
3976
- );
3977
- const _retrievedSchema = this.updateRetrievedSchema(
3978
- retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
3979
- );
4051
+ let formData;
4052
+ let computedRetrievedSchema;
4053
+ let wasSanitized = false;
4054
+ const preventInfiniteSanitize = [];
4055
+ do {
4056
+ formData = schemaUtils.getDefaultFormState(
4057
+ rootSchema,
4058
+ defaultsFormData,
4059
+ false,
4060
+ state.initialDefaultsGenerated
4061
+ );
4062
+ const formHash = shouldSanitize ? utils.hashObject({ formData }) : "";
4063
+ computedRetrievedSchema = this.updateRetrievedSchema(
4064
+ retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
4065
+ );
4066
+ if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !utils.deepEquals(computedRetrievedSchema, state.retrievedSchema)) {
4067
+ const sanitizedFormData = schemaUtils.sanitizeDataForNewSchema(
4068
+ computedRetrievedSchema,
4069
+ state.retrievedSchema,
4070
+ formData
4071
+ );
4072
+ wasSanitized = !utils.deepEquals(sanitizedFormData, formData);
4073
+ if (wasSanitized) {
4074
+ formData = sanitizedFormData;
4075
+ defaultsFormData = sanitizedFormData;
4076
+ const sanitizedFormHash = utils.hashObject({ formData: sanitizedFormData });
4077
+ wasSanitized = !preventInfiniteSanitize.includes(sanitizedFormHash);
4078
+ preventInfiniteSanitize.push(sanitizedFormHash);
4079
+ }
4080
+ preventInfiniteSanitize.push(formHash);
4081
+ } else {
4082
+ wasSanitized = false;
4083
+ }
4084
+ } while (wasSanitized);
3980
4085
  const getCurrentErrors = () => {
3981
4086
  if (props.noValidate || isSchemaChanged) {
3982
4087
  return { errors: [], errorSchema: {} };
3983
- } else if (!props.liveValidate) {
4088
+ }
4089
+ if (!props.liveValidate) {
3984
4090
  return {
3985
4091
  errors: state.schemaValidationErrors || [],
3986
4092
  errorSchema: state.schemaValidationErrorSchema || {}
@@ -3993,8 +4099,7 @@
3993
4099
  };
3994
4100
  let errors;
3995
4101
  let errorSchema;
3996
- let schemaValidationErrors = state.schemaValidationErrors;
3997
- let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
4102
+ let { schemaValidationErrors, schemaValidationErrorSchema } = state;
3998
4103
  if (mustValidate && !skipLiveValidate) {
3999
4104
  const liveValidation = this.liveValidate(
4000
4105
  rootSchema,
@@ -4017,24 +4122,22 @@
4017
4122
  errors = currentErrors.errors;
4018
4123
  errorSchema = currentErrors.errorSchema;
4019
4124
  if (formDataChangedFields.length > 0 && !mustValidate) {
4020
- const newErrorSchema = formDataChangedFields.reduce(
4021
- (acc, key) => {
4022
- acc[key] = void 0;
4023
- return acc;
4024
- },
4025
- {}
4026
- );
4027
- errorSchema = schemaValidationErrorSchema = utils.mergeObjects(
4125
+ const newErrorSchema = formDataChangedFields.reduce((acc, key) => {
4126
+ acc[key] = void 0;
4127
+ return acc;
4128
+ }, {});
4129
+ schemaValidationErrorSchema = utils.mergeObjects(
4028
4130
  currentErrors.errorSchema,
4029
4131
  newErrorSchema,
4030
4132
  "preventDuplicates"
4031
4133
  );
4134
+ errorSchema = schemaValidationErrorSchema;
4032
4135
  }
4033
- const mergedErrors = this.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
4136
+ const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
4034
4137
  errors = mergedErrors.errors;
4035
4138
  errorSchema = mergedErrors.errorSchema;
4036
4139
  }
4037
- const newRegistry = this.getRegistry(props, rootSchema, schemaUtils);
4140
+ const newRegistry = _Form.getRegistry(props, rootSchema, schemaUtils);
4038
4141
  const registry = utils.deepEquals(state.registry, newRegistry) ? state.registry : newRegistry;
4039
4142
  const fieldPathId = state.fieldPathId && state.fieldPathId?.[utils.ID_KEY] === registry.globalFormOptions.idPrefix ? state.fieldPathId : utils.toFieldPathId("", registry.globalFormOptions);
4040
4143
  const nextState = {
@@ -4048,7 +4151,7 @@
4048
4151
  errorSchema,
4049
4152
  schemaValidationErrors,
4050
4153
  schemaValidationErrorSchema,
4051
- retrievedSchema: _retrievedSchema,
4154
+ retrievedSchema: computedRetrievedSchema,
4052
4155
  initialDefaultsGenerated: true,
4053
4156
  registry
4054
4157
  };
@@ -4073,17 +4176,18 @@
4073
4176
  * @param [retrievedSchema] - An optionally retrieved schema for per
4074
4177
  */
4075
4178
  validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
4076
- const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
4179
+ const schemaUtils = altSchemaUtils || this.state.schemaUtils;
4077
4180
  const { customValidate, transformErrors, uiSchema } = this.props;
4078
- const resolvedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
4079
- return schemaUtils.getValidator().validateFormData(formData, resolvedSchema, customValidate, transformErrors, uiSchema);
4181
+ const validationSchema = retrievedSchema ?? schema;
4182
+ const validationFormData = formData ? JSON.parse(JSON.stringify(formData)) : void 0;
4183
+ return schemaUtils.getValidator().validateFormData(validationFormData, validationSchema, customValidate, transformErrors, uiSchema);
4080
4184
  }
4081
4185
  /** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
4082
4186
  renderErrors(registry) {
4083
4187
  const { errors, errorSchema, schema, uiSchema } = this.state;
4084
4188
  const options = utils.getUiOptions(uiSchema);
4085
4189
  const ErrorListTemplate = utils.getTemplate("ErrorListTemplate", registry, options);
4086
- if (errors && errors.length) {
4190
+ if (errors?.length) {
4087
4191
  return /* @__PURE__ */ jsxRuntime.jsx(
4088
4192
  ErrorListTemplate,
4089
4193
  {
@@ -4105,9 +4209,8 @@
4105
4209
  * @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
4106
4210
  * @private
4107
4211
  */
4108
- mergeErrors(schemaValidation, extraErrors, customErrors) {
4109
- let errorSchema = schemaValidation.errorSchema;
4110
- let errors = schemaValidation.errors;
4212
+ static mergeErrors(schemaValidation, extraErrors, customErrors) {
4213
+ let { errorSchema, errors } = schemaValidation;
4111
4214
  if (extraErrors) {
4112
4215
  const merged = utils.validationDataMerge(schemaValidation, extraErrors);
4113
4216
  errorSchema = merged.errorSchema;
@@ -4136,8 +4239,8 @@
4136
4239
  */
4137
4240
  liveValidate(rootSchema, schemaUtils, originalErrorSchema, formData, extraErrors, customErrors, retrievedSchema, mergeIntoOriginalErrorSchema = false) {
4138
4241
  const schemaValidation = this.validate(formData, rootSchema, schemaUtils, retrievedSchema);
4139
- const errors = schemaValidation.errors;
4140
- let errorSchema = schemaValidation.errorSchema;
4242
+ const { errors } = schemaValidation;
4243
+ let { errorSchema } = schemaValidation;
4141
4244
  if (mergeIntoOriginalErrorSchema) {
4142
4245
  errorSchema = utils.mergeObjects(
4143
4246
  originalErrorSchema,
@@ -4147,7 +4250,7 @@
4147
4250
  }
4148
4251
  const schemaValidationErrors = errors;
4149
4252
  const schemaValidationErrorSchema = errorSchema;
4150
- const mergedErrors = this.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
4253
+ const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
4151
4254
  return { ...mergedErrors, schemaValidationErrors, schemaValidationErrorSchema };
4152
4255
  }
4153
4256
  /** Returns the `formData` with only the elements specified in the `fields` list
@@ -4156,18 +4259,16 @@
4156
4259
  * @param fields - The fields to keep while filtering
4157
4260
  * @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
4158
4261
  */
4159
- getUsedFormData = (formData, fields2) => {
4160
- return utils.getUsedFormData(formData, fields2);
4161
- };
4262
+ // oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
4263
+ getUsedFormData = (formData, fields2) => utils.getUsedFormData(formData, fields2);
4162
4264
  /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
4163
4265
  *
4164
4266
  * @param pathSchema - The `PathSchema` object for the form
4165
4267
  * @param [formData] - The form data to use while checking for empty objects/arrays
4166
4268
  * @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
4167
4269
  */
4168
- getFieldNames = (pathSchema, formData) => {
4169
- return utils.getFieldNames(pathSchema, formData);
4170
- };
4270
+ // oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
4271
+ getFieldNames = (pathSchema, formData) => utils.getFieldNames(pathSchema, formData);
4171
4272
  /** Returns the `formData` after filtering to remove any extra data not in a form field
4172
4273
  *
4173
4274
  * @param formData - The data for the `Form`
@@ -4219,25 +4320,24 @@
4219
4320
  if (this.pendingChanges.length === 0) {
4220
4321
  return;
4221
4322
  }
4222
- this._isProcessingUserChange = true;
4323
+ this.isProcessingUserChange = true;
4223
4324
  const { newValue, path, id } = this.pendingChanges[0];
4224
4325
  const { newErrorSchema } = this.pendingChanges[0];
4225
- const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
4326
+ const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, disabled, readonly } = this.props;
4226
4327
  const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
4227
- let { customErrors } = this.state;
4328
+ let { customErrors, retrievedSchema } = this.state;
4228
4329
  let mergeBaseErrorSchema = schemaValidationErrorSchema;
4229
4330
  const rootPathId = fieldPathId.path[0] || "";
4230
4331
  const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
4231
- let retrievedSchema = this.state.retrievedSchema;
4232
4332
  let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
4233
4333
  const hasOnlyUndefinedValues = utils.isObject(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
4234
4334
  const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
4235
4335
  const inputForDefaults = hasOnlyUndefinedValues && wasPreviouslyNull ? void 0 : formData;
4236
4336
  if (utils.isObject(formData) || Array.isArray(formData)) {
4337
+ let plainLeafWasCleared = false;
4237
4338
  if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
4238
4339
  _unset(formData, path);
4239
4340
  } else if (!isRootPath) {
4240
- let unsetPath = false;
4241
4341
  let valueForPath = newValue;
4242
4342
  if (newValue === void 0) {
4243
4343
  const lastSegment = path[path.length - 1];
@@ -4248,28 +4348,38 @@
4248
4348
  const leaf = field;
4249
4349
  const isOneOfOrAnyOfLeaf = leaf && (utils.ONE_OF_KEY in leaf || utils.ANY_OF_KEY in leaf);
4250
4350
  if (!isOneOfOrAnyOfLeaf && leaf !== void 0) {
4251
- unsetPath = true;
4351
+ plainLeafWasCleared = true;
4252
4352
  }
4253
4353
  }
4254
4354
  }
4255
- if (unsetPath) {
4256
- _unset(formData, path);
4355
+ if (plainLeafWasCleared) {
4356
+ set(formData, path, void 0);
4257
4357
  } else {
4258
4358
  set(formData, path, valueForPath);
4259
4359
  }
4260
4360
  }
4261
- const newState = this.getStateFromProps(this.props, inputForDefaults, void 0, void 0, void 0, true);
4361
+ const shouldSanitize = retrievedSchema && !isRootPath && !utils.isObject(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
4362
+ const newState = this.getStateFromProps(
4363
+ this.props,
4364
+ inputForDefaults,
4365
+ void 0,
4366
+ void 0,
4367
+ void 0,
4368
+ true,
4369
+ shouldSanitize
4370
+ );
4262
4371
  formData = newState.formData;
4263
4372
  retrievedSchema = newState.retrievedSchema;
4373
+ if (plainLeafWasCleared && formData) {
4374
+ set(formData, path, void 0);
4375
+ }
4264
4376
  }
4265
4377
  const mustValidate = !noValidate && (liveValidate === true || liveValidate === "onChange");
4266
- let state = { formData, schema };
4378
+ let state = { formData, retrievedSchema };
4267
4379
  let newFormData = formData;
4268
4380
  if (omitExtraData === true && (liveOmit === true || liveOmit === "onChange")) {
4269
4381
  newFormData = this.omitExtraData(formData);
4270
- state = {
4271
- formData: newFormData
4272
- };
4382
+ state = { ...state, formData: newFormData };
4273
4383
  }
4274
4384
  if (newErrorSchema) {
4275
4385
  const oldValidationError = !isRootPath ? get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
@@ -4285,9 +4395,9 @@
4285
4395
  customErrors = new utils.ErrorSchemaBuilder();
4286
4396
  }
4287
4397
  if (isRootPath) {
4288
- const errors2 = get(newErrorSchema, utils.ERRORS_KEY);
4289
- if (errors2) {
4290
- customErrors.setErrors(errors2);
4398
+ const pathErrors = get(newErrorSchema, utils.ERRORS_KEY);
4399
+ if (pathErrors) {
4400
+ customErrors.setErrors(pathErrors);
4291
4401
  }
4292
4402
  } else {
4293
4403
  set(customErrors.ErrorSchema, path, newErrorSchema);
@@ -4306,14 +4416,14 @@
4306
4416
  customErrors,
4307
4417
  retrievedSchema
4308
4418
  );
4309
- state = { formData: newFormData, ...liveValidation, customErrors };
4419
+ state = { ...state, formData: newFormData, ...liveValidation, customErrors };
4310
4420
  } else if (!noValidate && newErrorSchema) {
4311
- const mergedErrors = this.mergeErrors({ errorSchema: mergeBaseErrorSchema, errors }, extraErrors, customErrors);
4312
- state = {
4313
- formData: newFormData,
4314
- ...mergedErrors,
4421
+ const mergedErrors = _Form.mergeErrors(
4422
+ { errorSchema: mergeBaseErrorSchema, errors },
4423
+ extraErrors,
4315
4424
  customErrors
4316
- };
4425
+ );
4426
+ state = { ...state, formData: newFormData, ...mergedErrors, customErrors };
4317
4427
  }
4318
4428
  this.setState(state, () => {
4319
4429
  if (onChange) {
@@ -4362,7 +4472,7 @@
4362
4472
  initialDefaultsGenerated: false,
4363
4473
  customErrors: void 0
4364
4474
  };
4365
- this.setState(state, () => onChange && onChange(toIChangeEvent({ ...this.state, ...state })));
4475
+ this.setState(state, () => onChange?.(toIChangeEvent({ ...this.state, ...state })));
4366
4476
  };
4367
4477
  /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
4368
4478
  * was provided. Also runs any live validation and/or live omit operations if the flags indicate they should happen
@@ -4466,7 +4576,7 @@
4466
4576
  * @returns - The `GlobalFormOptions` from the props
4467
4577
  * @private
4468
4578
  */
4469
- getGlobalFormOptions(props) {
4579
+ static getGlobalFormOptions(props) {
4470
4580
  const {
4471
4581
  uiSchema = {},
4472
4582
  experimental_componentUpdateStrategy,
@@ -4485,7 +4595,7 @@
4485
4595
  };
4486
4596
  }
4487
4597
  /** Computed the registry for the form using the given `props`, `schema` and `schemaUtils` */
4488
- getRegistry(props, schema, schemaUtils) {
4598
+ static getRegistry(props, schema, schemaUtils) {
4489
4599
  const { translateString: customTranslateString, uiSchema = {} } = props;
4490
4600
  const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
4491
4601
  return {
@@ -4504,7 +4614,7 @@
4504
4614
  schemaUtils,
4505
4615
  translateString: customTranslateString || translateString,
4506
4616
  globalUiOptions: uiSchema[utils.UI_GLOBAL_OPTIONS_KEY],
4507
- globalFormOptions: this.getGlobalFormOptions(props),
4617
+ globalFormOptions: _Form.getGlobalFormOptions(props),
4508
4618
  uiSchemaDefinitions: uiSchema[utils.UI_DEFINITIONS_KEY] ?? {}
4509
4619
  };
4510
4620
  }
@@ -4539,7 +4649,7 @@
4539
4649
  if (!field) {
4540
4650
  field = this.formElement.current.querySelector(`input[id^="${elementId}"], button[id^="${elementId}"]`);
4541
4651
  }
4542
- if (field && field.length) {
4652
+ if (field?.length) {
4543
4653
  field = field[0];
4544
4654
  }
4545
4655
  if (field) {
@@ -4556,7 +4666,7 @@
4556
4666
  const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
4557
4667
  const { errors: prevErrors } = this.state;
4558
4668
  const schemaValidation = this.validate(formData);
4559
- const { errors, errorSchema } = extraErrors ? this.mergeErrors(schemaValidation, extraErrors) : schemaValidation;
4669
+ const { errors, errorSchema } = extraErrors ? _Form.mergeErrors(schemaValidation, extraErrors) : schemaValidation;
4560
4670
  const hasError = schemaValidation.errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
4561
4671
  if (hasError) {
4562
4672
  if (focusOnFirstError) {
@@ -4635,7 +4745,7 @@
4635
4745
  _internalFormWrapper
4636
4746
  } = this.props;
4637
4747
  const { schema, uiSchema, formData, errorSchema, fieldPathId, registry } = this.state;
4638
- const { SchemaField: _SchemaField } = registry.fields;
4748
+ const { SchemaField: SchemaFieldComponent } = registry.fields;
4639
4749
  const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
4640
4750
  const as = _internalFormWrapper ? tagName : void 0;
4641
4751
  const FormTag = _internalFormWrapper || tagName || "form";
@@ -4647,7 +4757,7 @@
4647
4757
  return /* @__PURE__ */ jsxRuntime.jsxs(
4648
4758
  FormTag,
4649
4759
  {
4650
- className: className ? className : "rjsf",
4760
+ className: className || "rjsf",
4651
4761
  id,
4652
4762
  name,
4653
4763
  method,
@@ -4663,7 +4773,7 @@
4663
4773
  children: [
4664
4774
  showErrorList === "top" && this.renderErrors(registry),
4665
4775
  /* @__PURE__ */ jsxRuntime.jsx(
4666
- _SchemaField,
4776
+ SchemaFieldComponent,
4667
4777
  {
4668
4778
  name: "",
4669
4779
  schema,
@@ -4679,7 +4789,7 @@
4679
4789
  readonly
4680
4790
  }
4681
4791
  ),
4682
- children ? children : /* @__PURE__ */ jsxRuntime.jsx(SubmitButton2, { uiSchema: submitUiSchema, registry }),
4792
+ children || /* @__PURE__ */ jsxRuntime.jsx(SubmitButton2, { uiSchema: submitUiSchema, registry }),
4683
4793
  showErrorList === "bottom" && this.renderErrors(registry)
4684
4794
  ]
4685
4795
  }
@@ -4705,16 +4815,16 @@
4705
4815
  };
4706
4816
  }
4707
4817
  function withTheme(themeProps) {
4708
- return react$1.forwardRef(
4709
- ({ fields: fields2, widgets: widgets2, templates: templates2, ...directProps }, ref) => {
4710
- fields2 = { ...themeProps?.fields, ...fields2 };
4711
- widgets2 = { ...themeProps?.widgets, ...widgets2 };
4712
- templates2 = {
4818
+ return react.forwardRef(
4819
+ ({ fields: propFields, widgets: propWidgets, templates: propTemplates, ...directProps }, ref) => {
4820
+ const fields2 = { ...themeProps?.fields, ...propFields };
4821
+ const widgets2 = { ...themeProps?.widgets, ...propWidgets };
4822
+ const templates2 = {
4713
4823
  ...themeProps?.templates,
4714
- ...templates2,
4824
+ ...propTemplates,
4715
4825
  ButtonTemplates: {
4716
4826
  ...themeProps?.templates?.ButtonTemplates,
4717
- ...templates2?.ButtonTemplates
4827
+ ...propTemplates?.ButtonTemplates
4718
4828
  }
4719
4829
  };
4720
4830
  return /* @__PURE__ */ jsxRuntime.jsx(