@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
@@ -1,4 +1,4 @@
1
- import { EnumOptionsType, FieldProps, FormContextType, RJSFSchema, SchemaUtilsType, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
1
+ import type { EnumOptionsType, FieldProps, FormContextType, RJSFSchema, SchemaUtilsType, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
2
2
  /** Gets the selected option from the list of `options`, using the `selectorField` to search inside each `option` for
3
3
  * the `properties[selectorField].default(or const)` that matches the given `value`.
4
4
  *
@@ -24,5 +24,5 @@ export declare function computeEnumOptions<T = any, S extends StrictRJSFSchema =
24
24
  * field or indirectly via `ui:optionsSchemaSelector` in the `uiSchema`) to help determine which `anyOf`/`oneOf` schema
25
25
  * is active. If no `selectorField` is specified, then an error is thrown.
26
26
  */
27
- export default function LayoutMultiSchemaField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
27
+ export default function LayoutMultiSchemaField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react").JSX.Element;
28
28
  //# sourceMappingURL=LayoutMultiSchemaField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LayoutMultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutMultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,eAAe,EAEf,UAAU,EACV,eAAe,EAOf,UAAU,EAIV,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,aAAa,CAAC;AAQrB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,GACb,CAAC,GAAG,SAAS,CAQf;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EAAE,EACZ,WAAW,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,GACX,eAAe,CAAC,CAAC,CAAC,EAAE,CAatB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAuI3B"}
1
+ {"version":3,"file":"LayoutMultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutMultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,aAAa,CAAC;AAuBrB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,GACb,CAAC,GAAG,SAAS,CAQf;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EAAE,EACZ,WAAW,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,GACX,eAAe,CAAC,CAAC,CAAC,EAAE,CAatB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,+BA0I3B"}
@@ -69,7 +69,7 @@ export default function LayoutMultiSchemaField(props) {
69
69
  useEffect(() => {
70
70
  setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
71
71
  // We are using hashes in place of the dependencies
72
- // eslint-disable-next-line react-hooks/exhaustive-deps
72
+ // oxlint-disable-next-line react-hooks/exhaustive-deps
73
73
  }, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
74
74
  const { widget = discriminator ? 'radio' : 'select', title = '', placeholder = '', optionsSchemaSelector: selectorField = discriminator, hideError: uiSchemaHideError, ...uiOptions } = getUiOptions(uiSchema);
75
75
  if (!selectorField) {
@@ -94,6 +94,9 @@ export default function LayoutMultiSchemaField(props) {
94
94
  * will use it as the index of the new option to select
95
95
  */
96
96
  const onOptionChange = (opt) => {
97
+ if (disabled || readonly) {
98
+ return;
99
+ }
97
100
  const newOption = getSelectedOption(enumOptions, selectorField, opt);
98
101
  const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
99
102
  let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
@@ -1,48 +1,9 @@
1
- import { Component } from 'react';
2
- import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
- /** Type used for the state of the `AnyOfField` component */
4
- type AnyOfFieldState<S extends StrictRJSFSchema = RJSFSchema> = {
5
- /** The currently selected option */
6
- selectedOption: number;
7
- /** The option schemas after retrieving all $refs */
8
- retrievedOptions: S[];
9
- };
1
+ import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
10
2
  /** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
11
3
  * the currently selected option and cleans up any irrelevant data in `formData`.
12
4
  *
13
5
  * @param props - The `FieldProps` for this template
14
6
  */
15
- declare class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Component<FieldProps<T, S, F>, AnyOfFieldState<S>> {
16
- /** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
17
- *
18
- * @param props - The `FieldProps` for this template
19
- */
20
- constructor(props: FieldProps<T, S, F>);
21
- /** React lifecycle method that is called when the props and/or state for this component is updated. It recomputes the
22
- * currently selected option based on the overall `formData`
23
- *
24
- * @param prevProps - The previous `FieldProps` for this template
25
- * @param prevState - The previous `AnyOfFieldState` for this template
26
- */
27
- componentDidUpdate(prevProps: Readonly<FieldProps<T, S, F>>, prevState: Readonly<AnyOfFieldState>): void;
28
- /** Determines the best matching option for the given `formData` and `options`.
29
- *
30
- * @param formData - The new formData
31
- * @param options - The list of options to choose from
32
- * @return - The index of the `option` that best matches the `formData`
33
- */
34
- getMatchingOption(selectedOption: number, formData: T | undefined, options: S[]): number;
35
- /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
36
- * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
37
- * the `onChange` handler.
38
- *
39
- * @param option - The new option value being selected
40
- */
41
- onOptionChange: (option?: string) => void;
42
- getFieldId(): string;
43
- /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
44
- */
45
- render(): import("react/jsx-runtime").JSX.Element;
46
- }
7
+ declare function AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react").JSX.Element;
47
8
  export default AnyOfField;
48
9
  //# sourceMappingURL=MultiSchemaField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAIL,UAAU,EACV,eAAe,EAQf,UAAU,EAEV,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAKrB,4DAA4D;AAC5D,KAAK,eAAe,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,IAAI;IAC9D,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,gBAAgB,EAAE,CAAC,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,cAAM,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACnH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnB,eAAe,CAAC,CAAC,CAAC,CACnB;IACC;;;OAGG;gBACS,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAiBtC;;;;;OAKG;IACH,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC;IAyBjG;;;;;OAKG;IACH,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;IAW/E;;;;;OAKG;IACH,cAAc,GAAI,SAAS,MAAM,UAqB/B;IAEF,UAAU;IAKV;OACG;IACH,MAAM;CA4HP;AAED,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAY,MAAM,aAAa,CAAC;AAoBvG;;;;GAIG;AACH,iBAAS,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACnG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,+BAmO3B;AAED,eAAe,UAAU,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Component } from 'react';
3
- import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getTemplate, getUiOptions, getWidget, isFormDataAvailable, mergeSchemas, ONE_OF_KEY, shouldRenderOptionalField, TranslatableString, } from '@rjsf/utils';
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
+ import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getTemplate, getUiOptions, getWidget, hashObject, isFormDataAvailable, mergeSchemas, ONE_OF_KEY, shouldRenderOptionalField, TranslatableString, } from '@rjsf/utils';
4
4
  import get from 'lodash-es/get.js';
5
5
  import isEmpty from 'lodash-es/isEmpty.js';
6
6
  import omit from 'lodash-es/omit.js';
@@ -9,70 +9,60 @@ import omit from 'lodash-es/omit.js';
9
9
  *
10
10
  * @param props - The `FieldProps` for this template
11
11
  */
12
- class AnyOfField extends Component {
13
- /** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
14
- *
15
- * @param props - The `FieldProps` for this template
16
- */
17
- constructor(props) {
18
- super(props);
19
- const { formData, options, registry: { schemaUtils }, } = this.props;
20
- // cache the retrieved options in state in case they have $refs to save doing it later
21
- const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
22
- this.state = {
23
- retrievedOptions,
24
- selectedOption: this.getMatchingOption(0, formData, retrievedOptions),
25
- };
26
- }
27
- /** React lifecycle method that is called when the props and/or state for this component is updated. It recomputes the
28
- * currently selected option based on the overall `formData`
29
- *
30
- * @param prevProps - The previous `FieldProps` for this template
31
- * @param prevState - The previous `AnyOfFieldState` for this template
12
+ function AnyOfField(props) {
13
+ const { name, disabled = false, errorSchema = {}, formData, fieldPathId, onBlur, onChange, onFocus, options, readonly, registry, required = false, schema, uiSchema, } = props;
14
+ const { schemaUtils } = registry;
15
+ // Hash formData by value so the memo only invalidates when data actually changes, not on every
16
+ // new object reference. hashObject(undefined) throws, so null is used as the fallback.
17
+ const formDataHash = hashObject(formData ?? null);
18
+ // retrievedOptions is purely derived from options — useMemo handles re-derivation automatically
19
+ // when options, schemaUtils, or formData's value changes, with no render-phase dispatch needed.
20
+ const retrievedOptions = useMemo(() => options.map((opt) => schemaUtils.retrieveSchema(opt, formData)),
21
+ // oxlint-disable-next-line react-hooks/exhaustive-deps -- formDataHash is the value-stable proxy for formData
22
+ [options, schemaUtils, formDataHash]);
23
+ const [selectedOption, setSelectedOption] = useState(() => {
24
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
25
+ return schemaUtils.getClosestMatchingOption(formData, retrievedOptions, 0, discriminator);
26
+ });
27
+ /** Flag to skip the formData-change-driven option recalculation when the user just selected an option.
28
+ * Set to true in onOptionChange (before onChange is called), consumed and reset in the update effect.
29
+ * This prevents the matching-option recalculation from overriding a user's explicit choice when
30
+ * getDefaultFormState populates undefined properties that make deepEquals see a false formData change.
32
31
  */
33
- componentDidUpdate(prevProps, prevState) {
34
- const { formData, options, fieldPathId } = this.props;
35
- const { selectedOption } = this.state;
36
- let newState = this.state;
37
- if (!deepEquals(prevProps.options, options)) {
38
- const { registry: { schemaUtils }, } = this.props;
39
- // re-cache the retrieved options in state in case they have $refs to save doing it later
40
- const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
41
- newState = { selectedOption, retrievedOptions };
42
- }
43
- if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
44
- const { retrievedOptions } = newState;
45
- const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
46
- if (prevState && matchingOption !== selectedOption) {
47
- newState = { selectedOption: matchingOption, retrievedOptions };
32
+ const skipNextOptionRecalculation = useRef(false);
33
+ const prevFormDataRef = useRef(formData);
34
+ const prevFieldIdRef = useRef(fieldPathId.$id);
35
+ // Mirrors componentDidUpdate: re-match selectedOption when formData changes on the same field.
36
+ // Runs after every render (no deps array) to compare against prev values stored in refs.
37
+ // oxlint-disable-next-line react-hooks/exhaustive-deps
38
+ useEffect(() => {
39
+ const prevFormData = prevFormDataRef.current;
40
+ const prevFieldId = prevFieldIdRef.current;
41
+ prevFormDataRef.current = formData;
42
+ prevFieldIdRef.current = fieldPathId.$id;
43
+ if (!deepEquals(formData, prevFormData) && fieldPathId.$id === prevFieldId) {
44
+ if (skipNextOptionRecalculation.current) {
45
+ skipNextOptionRecalculation.current = false;
46
+ return;
47
+ }
48
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
49
+ const matchingOption = schemaUtils.getClosestMatchingOption(formData, retrievedOptions, selectedOption, discriminator);
50
+ if (matchingOption !== selectedOption) {
51
+ setSelectedOption(matchingOption);
48
52
  }
49
53
  }
50
- if (newState !== this.state) {
51
- this.setState(newState);
52
- }
53
- }
54
- /** Determines the best matching option for the given `formData` and `options`.
55
- *
56
- * @param formData - The new formData
57
- * @param options - The list of options to choose from
58
- * @return - The index of the `option` that best matches the `formData`
59
- */
60
- getMatchingOption(selectedOption, formData, options) {
61
- const { schema, registry: { schemaUtils }, } = this.props;
62
- const discriminator = getDiscriminatorFieldFromSchema(schema);
63
- const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
64
- return option;
65
- }
54
+ });
55
+ const fieldId = `${fieldPathId.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
66
56
  /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
67
57
  * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
68
58
  * the `onChange` handler.
69
59
  *
70
60
  * @param option - The new option value being selected
71
61
  */
72
- onOptionChange = (option) => {
73
- const { selectedOption, retrievedOptions } = this.state;
74
- const { formData, onChange, registry, fieldPathId } = this.props;
75
- const { schemaUtils } = registry;
62
+ const onOptionChange = useCallback((option) => {
63
+ if (disabled || readonly) {
64
+ return;
65
+ }
76
66
  const intOption = option !== undefined ? parseInt(option, 10) : -1;
77
67
  if (intOption === selectedOption) {
78
68
  return;
@@ -85,76 +75,80 @@ class AnyOfField extends Component {
85
75
  // so that only the root objects themselves are created without adding undefined children properties
86
76
  newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
87
77
  }
88
- this.setState({ selectedOption: intOption }, () => {
89
- onChange(newFormData, fieldPathId.path, undefined, this.getFieldId());
90
- });
91
- };
92
- getFieldId() {
93
- const { fieldPathId, schema } = this.props;
94
- return `${fieldPathId.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
78
+ setSelectedOption(intOption);
79
+ skipNextOptionRecalculation.current = true;
80
+ onChange(newFormData, fieldPathId.path, undefined, fieldId);
81
+ },
82
+ // setSelectedOption is stable (guaranteed by useState); skipNextOptionRecalculation is a ref
83
+ [selectedOption, retrievedOptions, disabled, readonly, schemaUtils, formData, fieldPathId, onChange, fieldId]);
84
+ const { widgets, fields, translateString, globalUiOptions } = registry;
85
+ const { SchemaField: SchemaFieldComponent } = fields;
86
+ const MultiSchemaFieldTemplate = getTemplate('MultiSchemaFieldTemplate', registry, globalUiOptions);
87
+ const isOptionalRender = shouldRenderOptionalField(registry, schema, required, uiSchema);
88
+ const hasFormData = isFormDataAvailable(formData);
89
+ const { widget = 'select', placeholder, autofocus, autocomplete, title = schema.title, ...uiOptions } = getUiOptions(uiSchema, globalUiOptions);
90
+ const Widget = getWidget({ type: 'number' }, widget, widgets);
91
+ const rawErrors = get(errorSchema, ERRORS_KEY, []);
92
+ const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
93
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
94
+ const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
95
+ let optionSchema;
96
+ if (option) {
97
+ const { required: schemaRequired, type: schemaType } = schema;
98
+ const parentProps = {};
99
+ if (schemaRequired) {
100
+ parentProps.required = schemaRequired;
101
+ }
102
+ // Propagate the parent schema type to options that don't define their own.
103
+ // This is necessary when the parent constrains the type (e.g. { type: 'string',
104
+ // oneOf: [{ pattern: '...' }, { pattern: '...' }] }) but the option sub-schemas
105
+ // omit the type — without it, getSchemaType returns undefined and the option
106
+ // renders as FallbackField instead of the correct widget (e.g. StringField).
107
+ if (schemaType !== undefined && !('type' in option)) {
108
+ parentProps.type = schemaType;
109
+ }
110
+ // Merge in all the non-oneOf/anyOf properties and also skip the special ADDITIONAL_PROPERTY_FLAG property
111
+ optionSchema = Object.keys(parentProps).length > 0 ? mergeSchemas(parentProps, option) : option;
95
112
  }
96
- /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
97
- */
98
- render() {
99
- const { name, disabled = false, errorSchema = {}, formData, onBlur, onFocus, readonly, required = false, registry, schema, uiSchema, } = this.props;
100
- const { widgets, fields, translateString, globalUiOptions, schemaUtils } = registry;
101
- const { SchemaField: _SchemaField } = fields;
102
- const MultiSchemaFieldTemplate = getTemplate('MultiSchemaFieldTemplate', registry, globalUiOptions);
103
- const isOptionalRender = shouldRenderOptionalField(registry, schema, required, uiSchema);
104
- const hasFormData = isFormDataAvailable(formData);
105
- const { selectedOption, retrievedOptions } = this.state;
106
- const { widget = 'select', placeholder, autofocus, autocomplete, title = schema.title, ...uiOptions } = getUiOptions(uiSchema, globalUiOptions);
107
- const Widget = getWidget({ type: 'number' }, widget, widgets);
108
- const rawErrors = get(errorSchema, ERRORS_KEY, []);
109
- const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
110
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
111
- const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
112
- let optionSchema;
113
- if (option) {
114
- // merge top level required field
115
- const { required } = schema;
116
- // Merge in all the non-oneOf/anyOf properties and also skip the special ADDITIONAL_PROPERTY_FLAG property
117
- optionSchema = required ? mergeSchemas({ required }, option) : option;
113
+ // First we will check to see if there is an anyOf/oneOf override for the UI schema
114
+ let optionsUiSchema = [];
115
+ if (ONE_OF_KEY in schema && uiSchema && ONE_OF_KEY in uiSchema) {
116
+ if (Array.isArray(uiSchema[ONE_OF_KEY])) {
117
+ optionsUiSchema = uiSchema[ONE_OF_KEY];
118
118
  }
119
- // First we will check to see if there is an anyOf/oneOf override for the UI schema
120
- let optionsUiSchema = [];
121
- if (ONE_OF_KEY in schema && uiSchema && ONE_OF_KEY in uiSchema) {
122
- if (Array.isArray(uiSchema[ONE_OF_KEY])) {
123
- optionsUiSchema = uiSchema[ONE_OF_KEY];
124
- }
125
- else {
126
- console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
127
- }
119
+ else {
120
+ // oxlint-disable-next-line no-console
121
+ console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
128
122
  }
129
- else if (ANY_OF_KEY in schema && uiSchema && ANY_OF_KEY in uiSchema) {
130
- if (Array.isArray(uiSchema[ANY_OF_KEY])) {
131
- optionsUiSchema = uiSchema[ANY_OF_KEY];
132
- }
133
- else {
134
- console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
135
- }
123
+ }
124
+ else if (ANY_OF_KEY in schema && uiSchema && ANY_OF_KEY in uiSchema) {
125
+ if (Array.isArray(uiSchema[ANY_OF_KEY])) {
126
+ optionsUiSchema = uiSchema[ANY_OF_KEY];
136
127
  }
137
- // Then we pick the one that matches the selected option index, if one exists otherwise default to the main uiSchema
138
- let optionUiSchema = uiSchema;
139
- if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
140
- optionUiSchema = optionsUiSchema[selectedOption];
128
+ else {
129
+ // oxlint-disable-next-line no-console
130
+ console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
141
131
  }
142
- const translateEnum = title
143
- ? TranslatableString.TitleOptionPrefix
144
- : TranslatableString.OptionPrefix;
145
- const translateParams = title ? [title] : [];
146
- const enumOptions = retrievedOptions.map((opt, index) => {
147
- // Also see if there is an override title in the uiSchema for each option, otherwise use the title from the option
148
- const { title: uiTitle = opt.title } = getUiOptions(optionsUiSchema[index]);
149
- return {
150
- label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
151
- value: index,
152
- };
153
- });
154
- const selector = !isOptionalRender || hasFormData ? (_jsx(Widget, { id: this.getFieldId(), name: `${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`, schema: { type: 'number', default: 0 }, onChange: this.onOptionChange, onBlur: onBlur, onFocus: onFocus, disabled: disabled || isEmpty(enumOptions), multiple: false, rawErrors: rawErrors, errorSchema: fieldErrorSchema, value: selectedOption >= 0 ? selectedOption : undefined, options: { enumOptions, ...uiOptions }, registry: registry, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly })) : undefined;
155
- const optionsSchemaField = (optionSchema && optionSchema.type !== 'null' && (_jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }))) ||
156
- null;
157
- return (_jsx(MultiSchemaFieldTemplate, { schema: schema, registry: registry, uiSchema: uiSchema, selector: selector, optionSchemaField: optionsSchemaField }));
158
132
  }
133
+ // Then we pick the one that matches the selected option index, if one exists otherwise default to the main uiSchema
134
+ let optionUiSchema = uiSchema;
135
+ if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
136
+ optionUiSchema = optionsUiSchema[selectedOption];
137
+ }
138
+ const translateEnum = title
139
+ ? TranslatableString.TitleOptionPrefix
140
+ : TranslatableString.OptionPrefix;
141
+ const translateParams = title ? [title] : [];
142
+ const enumOptions = retrievedOptions.map((opt, index) => {
143
+ const { title: uiTitle = opt.title } = getUiOptions(optionsUiSchema[index]);
144
+ return {
145
+ label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
146
+ value: index,
147
+ };
148
+ });
149
+ const selector = !isOptionalRender || hasFormData ? (_jsx(Widget, { id: fieldId, name: `${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`, schema: { type: 'number', default: 0 }, onChange: onOptionChange, onBlur: onBlur, onFocus: onFocus, disabled: disabled || isEmpty(enumOptions), multiple: false, rawErrors: rawErrors, errorSchema: fieldErrorSchema, value: selectedOption >= 0 ? selectedOption : undefined, options: { enumOptions, ...uiOptions }, registry: registry, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly })) : undefined;
150
+ const optionsSchemaField = (optionSchema && optionSchema.type !== 'null' && (_jsx(SchemaFieldComponent, { ...props, schema: optionSchema, uiSchema: optionUiSchema }))) ||
151
+ null;
152
+ return (_jsx(MultiSchemaFieldTemplate, { schema: schema, registry: registry, uiSchema: uiSchema, selector: selector, optionSchemaField: optionsSchemaField }));
159
153
  }
160
154
  export default AnyOfField;
@@ -1,4 +1,4 @@
1
- import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
  /** The `NullField` component is used to render a field in the schema is null. It also ensures that the `formData` is
3
3
  * also set to null if it has no value.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NullField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NullField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExF;;;;GAIG;AACH,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,QAU3B;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"NullField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NullField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE7F;;;;GAIG;AACH,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,QAU3B;AAED,eAAe,SAAS,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
  /**
3
3
  * The NumberField class has some special handling for dealing with trailing
4
4
  * decimal points and/or zeroes. This logic is designed to allow trailing values
@@ -16,6 +16,6 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
16
16
  * value cached in the state. If it matches the cached value, the cached
17
17
  * value is passed to the input instead of the formData value
18
18
  */
19
- declare function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
19
+ declare function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react").JSX.Element;
20
20
  export default NumberField;
21
21
  //# sourceMappingURL=NumberField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAcrB;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACpG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkD3B;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAerB;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACpG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,+BAgD3B;AAED,eAAe,WAAW,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState, useCallback } from 'react';
3
- import { asNumber, } from '@rjsf/utils';
3
+ import { asNumber } from '@rjsf/utils';
4
4
  // Matches a string that ends in a . character, optionally followed by a sequence of
5
5
  // digits followed by any number of 0 characters up until the end of the line.
6
6
  // Ensuring that there is at least one prefixed character is important so that
@@ -37,20 +37,18 @@ function NumberField(props) {
37
37
  *
38
38
  * @param value - The current value for the change occurring
39
39
  */
40
- const handleChange = useCallback((value, path, errorSchema, id) => {
40
+ const handleChange = useCallback((newValue, path, errorSchema, id) => {
41
41
  // Cache the original value in component state
42
- setLastValue(value);
42
+ setLastValue(newValue);
43
43
  // Normalize decimals that don't start with a zero character in advance so
44
44
  // that the rest of the normalization logic is simpler
45
- if (`${value}`.charAt(0) === '.') {
46
- value = `0${value}`;
47
- }
45
+ const normalizedValue = `${newValue}`.startsWith('.') ? `0${newValue}` : newValue;
48
46
  // Check that the value is a string (this can happen if the widget used is a
49
47
  // <select>, due to an enum declaration etc) then, if the value ends in a
50
48
  // trailing decimal point or multiple zeroes, strip the trailing values
51
- const processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix)
52
- ? asNumber(value.replace(trailingCharMatcher, ''))
53
- : asNumber(value);
49
+ const processed = typeof normalizedValue === 'string' && trailingCharMatcherWithPrefix.exec(normalizedValue)
50
+ ? asNumber(normalizedValue.replace(trailingCharMatcher, ''))
51
+ : asNumber(normalizedValue);
54
52
  onChange(processed, path, errorSchema, id);
55
53
  }, [onChange]);
56
54
  if (typeof lastValue === 'string' && typeof value === 'number') {
@@ -1,8 +1,8 @@
1
- import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
  /** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an
3
3
  * additional property key was modified and what it was modified to
4
4
  *
5
5
  * @param props - The `FieldProps` for this template
6
6
  */
7
- export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
7
+ export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react").JSX.Element;
8
8
  //# sourceMappingURL=ObjectField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"AACA,OAAO,EAaL,UAAU,EACV,eAAe,EAMf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AA2KrB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACnH,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAyO3B"}
1
+ {"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,UAAU,EACV,eAAe,EAIf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AA6LrB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACnH,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,+BA8O3B"}
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useRef, useState } from 'react';
2
+ import { memo, useCallback, useMemo, useRef, useState } from 'react';
3
3
  import { ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, getTemplate, getUiOptions, isFormDataAvailable, orderProperties, shouldRenderOptionalField, toFieldPathId, useDeepCompareMemo, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, TranslatableString, } from '@rjsf/utils';
4
4
  import get from 'lodash-es/get.js';
5
5
  import has from 'lodash-es/has.js';
6
6
  import isObject from 'lodash-es/isObject.js';
7
7
  import set from 'lodash-es/set.js';
8
- import { Markdown } from 'markdown-to-jsx';
8
+ import { Markdown } from 'markdown-to-jsx/react';
9
9
  import { ADDITIONAL_PROPERTY_KEY_REMOVE } from '../constants.js';
10
10
  /** Returns a flag indicating whether the `name` field is required in the object schema
11
11
  *
@@ -14,7 +14,7 @@ import { ADDITIONAL_PROPERTY_KEY_REMOVE } from '../constants.js';
14
14
  * @returns - True if the field `name` is required, false otherwise
15
15
  */
16
16
  function isRequired(schema, name) {
17
- return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
17
+ return Array.isArray(schema.required) && schema.required.includes(name);
18
18
  }
19
19
  /** Returns a default value to be used for a new additional schema property of the given `type`
20
20
  *
@@ -41,7 +41,7 @@ function getDefaultValue(translateString, type) {
41
41
  }
42
42
  /** The `ObjectFieldProperty` component is used to render the `SchemaField` for a child property of an object
43
43
  */
44
- function ObjectFieldProperty(props) {
44
+ function ObjectFieldPropertyFn(props) {
45
45
  const { fieldPathId, schema, registry, uiSchema, errorSchema, formData, onChange, onBlur, onFocus, disabled, readonly, required, hideError, propertyName, handleKeyRename, handleRemoveProperty, addedByAdditionalProperties, } = props;
46
46
  const [wasPropertyKeyModified, setWasPropertyKeyModified] = useState(false);
47
47
  const { globalFormOptions, fields } = registry;
@@ -56,14 +56,15 @@ function ObjectFieldProperty(props) {
56
56
  * @returns - The onPropertyChange callback for the `name` property
57
57
  */
58
58
  const onPropertyChange = useCallback((value, path, newErrorSchema, id) => {
59
+ // Don't set value = undefined for fields added by additionalProperties. Doing so removes them from the
60
+ // formData, which causes them to completely disappear (including the input field for the property name). Unlike
61
+ // fields which are "mandated" by the schema, these fields can be set to undefined by clicking a "delete field"
62
+ // button, so set empty values to the empty string.
63
+ let normalizedValue = value;
59
64
  if (value === undefined && addedByAdditionalProperties) {
60
- // Don't set value = undefined for fields added by additionalProperties. Doing so removes them from the
61
- // formData, which causes them to completely disappear (including the input field for the property name). Unlike
62
- // fields which are "mandated" by the schema, these fields can be set to undefined by clicking a "delete field"
63
- // button, so set empty values to the empty string.
64
- value = '';
65
+ normalizedValue = '';
65
66
  }
66
- onChange(value, path, newErrorSchema, id);
67
+ onChange(normalizedValue, path, newErrorSchema, id);
67
68
  }, [onChange, addedByAdditionalProperties]);
68
69
  /** The key change event handler; Called when the key associated with a field is changed for an additionalProperty.
69
70
  * simply returns a function that call the `handleKeyChange()` event with the value
@@ -88,6 +89,7 @@ function ObjectFieldProperty(props) {
88
89
  }, [propertyName, handleRemoveProperty]);
89
90
  return (_jsx(SchemaField, { name: propertyName, required: required, schema: schema, uiSchema: uiSchema, errorSchema: errorSchema, fieldPathId: innerFieldIdPathId, formData: formData, wasPropertyKeyModified: wasPropertyKeyModified, onKeyRename: onKeyRename, onKeyRenameBlur: onKeyRenameBlur, onRemoveProperty: onRemoveProperty, onChange: onPropertyChange, onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError }));
90
91
  }
92
+ const ObjectFieldProperty = memo(ObjectFieldPropertyFn);
91
93
  /** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an
92
94
  * additional property key was modified and what it was modified to
93
95
  *
@@ -99,8 +101,8 @@ export default function ObjectField(props) {
99
101
  const { OptionalDataControlsField } = fields;
100
102
  const formDataRef = useRef(formData);
101
103
  formDataRef.current = formData;
102
- const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
103
- const uiOptions = getUiOptions(uiSchema, globalUiOptions);
104
+ const schema = useMemo(() => schemaUtils.retrieveSchema(rawSchema, formData, true), [schemaUtils, rawSchema, formData]);
105
+ const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
104
106
  const { properties: schemaProperties = {} } = schema;
105
107
  // All the children will use childFieldPathId if present in the props, falling back to the fieldPathId
106
108
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
@@ -117,12 +119,13 @@ export default function ObjectField(props) {
117
119
  * @param [formData] - The form data in which to check if the desired key already exists
118
120
  * @returns - The name of the next available key from `preferredKey`
119
121
  */
120
- const getAvailableKey = useCallback((preferredKey, formData) => {
122
+ const getAvailableKey = useCallback((preferredKey, existingFormData) => {
121
123
  const { duplicateKeySuffixSeparator = '-' } = getUiOptions(uiSchema, globalUiOptions);
122
124
  let index = 0;
123
125
  let newKey = preferredKey;
124
- while (has(formData, newKey)) {
125
- newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
126
+ while (has(existingFormData, newKey)) {
127
+ index += 1;
128
+ newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
126
129
  }
127
130
  return newKey;
128
131
  }, [uiSchema, globalUiOptions]);
@@ -133,7 +136,6 @@ export default function ObjectField(props) {
133
136
  if (!(schema.additionalProperties || schema.patternProperties)) {
134
137
  return;
135
138
  }
136
- const { translateString } = registry;
137
139
  const newFormData = { ...formData };
138
140
  const newKey = getAvailableKey('newKey', newFormData);
139
141
  if (schema.patternProperties) {
@@ -150,11 +152,10 @@ export default function ObjectField(props) {
150
152
  defaultValue = schema.additionalProperties.default;
151
153
  let apSchema = schema.additionalProperties;
152
154
  if (REF_KEY in apSchema) {
153
- const { schemaUtils } = registry;
154
155
  apSchema = schemaUtils.retrieveSchema({ [REF_KEY]: apSchema[REF_KEY] }, formData);
155
156
  type = apSchema.type;
156
157
  constValue = apSchema.const;
157
- defaultValue = apSchema.default;
158
+ defaultValue = schemaUtils.getDefaultFormState(apSchema, defaultValue);
158
159
  }
159
160
  if (!type && (ANY_OF_KEY in apSchema || ONE_OF_KEY in apSchema)) {
160
161
  type = 'object';
@@ -169,7 +170,7 @@ export default function ObjectField(props) {
169
170
  lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
170
171
  }
171
172
  onChange(newFormData, childFieldPathId.path);
172
- }, [formData, onChange, registry, childFieldPathId, getAvailableKey, schema]);
173
+ }, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
173
174
  /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
174
175
  * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
175
176
  *
@@ -186,8 +187,9 @@ export default function ObjectField(props) {
186
187
  };
187
188
  const newKeys = { [oldKey]: actualNewKey };
188
189
  const keyValues = Object.keys(newFormData).map((key) => {
189
- const newKey = newKeys[key] || key;
190
- return { [newKey]: newFormData[key] };
190
+ // `Object.hasOwn` so a falsy rename target (e.g. `""`) isn't dropped.
191
+ const mappedKey = Object.hasOwn(newKeys, key) ? newKeys[key] : key;
192
+ return { [mappedKey]: newFormData[key] };
191
193
  });
192
194
  const renamedObj = Object.assign({}, ...keyValues);
193
195
  formDataRef.current = renamedObj;
@@ -230,14 +232,14 @@ export default function ObjectField(props) {
230
232
  // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
231
233
  title: uiOptions.label === false ? '' : templateTitle,
232
234
  description: uiOptions.label === false ? undefined : description,
233
- properties: orderedProperties.map((name) => {
234
- const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
235
- const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
235
+ properties: orderedProperties.map((propertyName) => {
236
+ const addedByAdditionalProperties = Boolean(schema.properties?.[propertyName]?.[ADDITIONAL_PROPERTY_FLAG]);
237
+ const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
236
238
  const hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
237
- const content = (_jsx(ObjectFieldProperty, { propertyName: name, required: isRequired(schema, name), schema: get(schema, [PROPERTIES_KEY, name], {}), uiSchema: fieldUiSchema, errorSchema: get(errorSchema, [name]), fieldPathId: childFieldPathId, formData: get(formData, [name]), handleKeyRename: handleKeyRename, handleRemoveProperty: handleRemoveProperty, addedByAdditionalProperties: addedByAdditionalProperties, onChange: onChange, onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError }, getStableKey(name)));
239
+ const content = (_jsx(ObjectFieldProperty, { propertyName: propertyName, required: isRequired(schema, propertyName), schema: get(schema, [PROPERTIES_KEY, propertyName], {}), uiSchema: fieldUiSchema, errorSchema: get(errorSchema, [propertyName]), fieldPathId: childFieldPathId, formData: get(formData, [propertyName]), handleKeyRename: handleKeyRename, handleRemoveProperty: handleRemoveProperty, addedByAdditionalProperties: addedByAdditionalProperties, onChange: onChange, onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError }, getStableKey(propertyName)));
238
240
  return {
239
241
  content,
240
- name,
242
+ name: propertyName,
241
243
  readonly,
242
244
  disabled,
243
245
  required,