@rjsf/utils 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 (289) hide show
  1. package/LICENSE.md +201 -0
  2. package/dist/index.cjs +534 -376
  3. package/dist/index.cjs.map +4 -4
  4. package/dist/utils.esm.js +534 -376
  5. package/dist/utils.esm.js.map +4 -4
  6. package/dist/utils.umd.js +561 -400
  7. package/lib/ErrorSchemaBuilder.d.ts +1 -1
  8. package/lib/SelectedOptionDescription.d.ts +4 -0
  9. package/lib/SelectedOptionDescription.js +24 -0
  10. package/lib/SelectedOptionDescription.js.map +1 -0
  11. package/lib/allowAdditionalItems.d.ts +1 -1
  12. package/lib/allowAdditionalItems.js +1 -0
  13. package/lib/allowAdditionalItems.js.map +1 -1
  14. package/lib/asNumber.js +2 -0
  15. package/lib/asNumber.js.map +1 -1
  16. package/lib/canExpand.d.ts +1 -1
  17. package/lib/constIsAjvDataReference.d.ts +1 -1
  18. package/lib/constants.d.ts +8 -5
  19. package/lib/constants.js +10 -7
  20. package/lib/constants.js.map +1 -1
  21. package/lib/createErrorHandler.d.ts +1 -1
  22. package/lib/createErrorHandler.js +2 -6
  23. package/lib/createErrorHandler.js.map +1 -1
  24. package/lib/createSchemaUtils.d.ts +1 -1
  25. package/lib/createSchemaUtils.js +3 -1
  26. package/lib/createSchemaUtils.js.map +1 -1
  27. package/lib/dataURItoBlob.js +3 -3
  28. package/lib/dataURItoBlob.js.map +1 -1
  29. package/lib/dateRangeOptions.d.ts +1 -1
  30. package/lib/dateRangeOptions.js +8 -7
  31. package/lib/dateRangeOptions.js.map +1 -1
  32. package/lib/englishStringTranslator.d.ts +1 -1
  33. package/lib/enumOptionSelectedValue.d.ts +1 -1
  34. package/lib/enumOptionValueDecoder.d.ts +1 -1
  35. package/lib/enumOptionValueDecoder.js +1 -1
  36. package/lib/enumOptionValueDecoder.js.map +1 -1
  37. package/lib/enumOptionValueEncoder.d.ts +1 -1
  38. package/lib/enumOptionsDeselectValue.d.ts +1 -1
  39. package/lib/enumOptionsIndexForValue.d.ts +1 -1
  40. package/lib/enumOptionsIndexForValue.js.map +1 -1
  41. package/lib/enumOptionsIsSelected.d.ts +1 -1
  42. package/lib/enumOptionsSelectValue.d.ts +1 -1
  43. package/lib/enumOptionsValueForIndex.d.ts +2 -2
  44. package/lib/enumOptionsValueForIndex.js.map +1 -1
  45. package/lib/enums.d.ts +4 -0
  46. package/lib/enums.js +4 -0
  47. package/lib/enums.js.map +1 -1
  48. package/lib/findSchemaDefinition.d.ts +1 -1
  49. package/lib/findSchemaDefinition.js +15 -15
  50. package/lib/findSchemaDefinition.js.map +1 -1
  51. package/lib/getChangedFields.js +4 -6
  52. package/lib/getChangedFields.js.map +1 -1
  53. package/lib/getDateElementProps.d.ts +3 -3
  54. package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
  55. package/lib/getDiscriminatorFieldFromSchema.js +1 -0
  56. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  57. package/lib/getInputProps.d.ts +1 -1
  58. package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
  59. package/lib/getOptionMatchingSimpleDiscriminator.js +10 -11
  60. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  61. package/lib/getOptionValueFormat.d.ts +1 -1
  62. package/lib/getSchemaType.d.ts +1 -1
  63. package/lib/getSchemaType.js +2 -1
  64. package/lib/getSchemaType.js.map +1 -1
  65. package/lib/getSubmitButtonOptions.d.ts +1 -1
  66. package/lib/getSubmitButtonOptions.js +1 -1
  67. package/lib/getSubmitButtonOptions.js.map +1 -1
  68. package/lib/getTemplate.d.ts +1 -1
  69. package/lib/getTestIds.d.ts +1 -1
  70. package/lib/getUiOptions.d.ts +1 -1
  71. package/lib/getUiOptions.js +2 -1
  72. package/lib/getUiOptions.js.map +1 -1
  73. package/lib/getWidget.d.ts +1 -1
  74. package/lib/getWidget.js +4 -4
  75. package/lib/getWidget.js.map +1 -1
  76. package/lib/guessType.js +1 -1
  77. package/lib/guessType.js.map +1 -1
  78. package/lib/hasWidget.d.ts +1 -1
  79. package/lib/hashForSchema.d.ts +3 -1
  80. package/lib/hashForSchema.js +11 -4
  81. package/lib/hashForSchema.js.map +1 -1
  82. package/lib/idGenerators.d.ts +1 -1
  83. package/lib/index.d.ts +14 -7
  84. package/lib/index.js +5 -2
  85. package/lib/index.js.map +1 -1
  86. package/lib/isConstant.d.ts +1 -1
  87. package/lib/isCustomWidget.d.ts +1 -1
  88. package/lib/isCustomWidget.js +1 -1
  89. package/lib/isCustomWidget.js.map +1 -1
  90. package/lib/isFixedItems.d.ts +3 -3
  91. package/lib/isFixedItems.js +3 -3
  92. package/lib/isFixedItems.js.map +1 -1
  93. package/lib/isRootSchema.d.ts +1 -1
  94. package/lib/isRootSchema.js +2 -3
  95. package/lib/isRootSchema.js.map +1 -1
  96. package/lib/labelValue.d.ts +1 -1
  97. package/lib/logUnsupportedDefaultForEnum.d.ts +9 -0
  98. package/lib/logUnsupportedDefaultForEnum.js +18 -0
  99. package/lib/logUnsupportedDefaultForEnum.js.map +1 -0
  100. package/lib/lookupFromFormContext.d.ts +1 -1
  101. package/lib/mergeDefaultsWithFormData.js +6 -5
  102. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  103. package/lib/mergeObjects.d.ts +4 -2
  104. package/lib/mergeObjects.js +1 -1
  105. package/lib/mergeObjects.js.map +1 -1
  106. package/lib/mergeSchemas.d.ts +4 -2
  107. package/lib/mergeSchemas.js +13 -6
  108. package/lib/mergeSchemas.js.map +1 -1
  109. package/lib/nameGenerators.d.ts +1 -1
  110. package/lib/optionsList.d.ts +1 -1
  111. package/lib/optionsList.js +22 -21
  112. package/lib/optionsList.js.map +1 -1
  113. package/lib/orderProperties.js +3 -3
  114. package/lib/orderProperties.js.map +1 -1
  115. package/lib/pad.js +1 -1
  116. package/lib/pad.js.map +1 -1
  117. package/lib/parseDateString.d.ts +1 -1
  118. package/lib/parseDateString.js +1 -1
  119. package/lib/parseDateString.js.map +1 -1
  120. package/lib/parser/ParserValidator.d.ts +2 -4
  121. package/lib/parser/ParserValidator.js +2 -0
  122. package/lib/parser/ParserValidator.js.map +1 -1
  123. package/lib/parser/index.d.ts +1 -1
  124. package/lib/parser/schemaParser.d.ts +2 -2
  125. package/lib/parser/schemaParser.js +7 -7
  126. package/lib/parser/schemaParser.js.map +1 -1
  127. package/lib/rangeSpec.d.ts +1 -2
  128. package/lib/rangeSpec.js.map +1 -1
  129. package/lib/removeOptionalEmptyObjects.d.ts +1 -1
  130. package/lib/removeOptionalEmptyObjects.js +6 -8
  131. package/lib/removeOptionalEmptyObjects.js.map +1 -1
  132. package/lib/resolveUiSchema.d.ts +1 -1
  133. package/lib/resolveUiSchema.js +16 -16
  134. package/lib/resolveUiSchema.js.map +1 -1
  135. package/lib/schema/findFieldInSchema.d.ts +1 -1
  136. package/lib/schema/findSelectedOptionInXxxOf.d.ts +1 -1
  137. package/lib/schema/findSelectedOptionInXxxOf.js +1 -3
  138. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
  139. package/lib/schema/getClosestMatchingOption.d.ts +1 -1
  140. package/lib/schema/getClosestMatchingOption.js +6 -9
  141. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  142. package/lib/schema/getDefaultFormState.d.ts +4 -4
  143. package/lib/schema/getDefaultFormState.js +81 -43
  144. package/lib/schema/getDefaultFormState.js.map +1 -1
  145. package/lib/schema/getDisplayLabel.d.ts +1 -1
  146. package/lib/schema/getDisplayLabel.js +2 -3
  147. package/lib/schema/getDisplayLabel.js.map +1 -1
  148. package/lib/schema/getFirstMatchingOption.d.ts +1 -1
  149. package/lib/schema/getFirstMatchingOption.js +2 -2
  150. package/lib/schema/getFirstMatchingOption.js.map +1 -1
  151. package/lib/schema/getFromSchema.d.ts +1 -1
  152. package/lib/schema/index.js +9 -3
  153. package/lib/schema/index.js.map +1 -1
  154. package/lib/schema/isFilesArray.d.ts +1 -1
  155. package/lib/schema/isMultiSelect.d.ts +1 -1
  156. package/lib/schema/isMultiSelect.js.map +1 -1
  157. package/lib/schema/isSelect.d.ts +1 -1
  158. package/lib/schema/isSelect.js +1 -1
  159. package/lib/schema/isSelect.js.map +1 -1
  160. package/lib/schema/omitExtraData.d.ts +1 -1
  161. package/lib/schema/omitExtraData.js +66 -52
  162. package/lib/schema/omitExtraData.js.map +1 -1
  163. package/lib/schema/retrieveSchema.d.ts +7 -3
  164. package/lib/schema/retrieveSchema.js +83 -56
  165. package/lib/schema/retrieveSchema.js.map +1 -1
  166. package/lib/schema/sanitizeDataForNewSchema.d.ts +1 -1
  167. package/lib/schema/sanitizeDataForNewSchema.js +48 -7
  168. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  169. package/lib/schema/toPathSchema.d.ts +1 -1
  170. package/lib/schema/toPathSchema.js +9 -5
  171. package/lib/schema/toPathSchema.js.map +1 -1
  172. package/lib/schemaRequiresTrueValue.d.ts +1 -1
  173. package/lib/schemaRequiresTrueValue.js +4 -3
  174. package/lib/schemaRequiresTrueValue.js.map +1 -1
  175. package/lib/shallowEquals.js +2 -2
  176. package/lib/shallowEquals.js.map +1 -1
  177. package/lib/shouldRenderOptionalField.d.ts +1 -1
  178. package/lib/toConstant.d.ts +1 -1
  179. package/lib/toDateString.d.ts +1 -1
  180. package/lib/toErrorList.d.ts +1 -1
  181. package/lib/toErrorList.js +3 -3
  182. package/lib/toErrorList.js.map +1 -1
  183. package/lib/toErrorSchema.d.ts +1 -1
  184. package/lib/toFieldPathId.d.ts +1 -1
  185. package/lib/tsconfig.tsbuildinfo +1 -1
  186. package/lib/types.d.ts +63 -57
  187. package/lib/unwrapErrorHandler.d.ts +1 -1
  188. package/lib/unwrapErrorHandler.js +7 -9
  189. package/lib/unwrapErrorHandler.js.map +1 -1
  190. package/lib/useAltDateWidgetProps.d.ts +6 -6
  191. package/lib/useAltDateWidgetProps.js +3 -3
  192. package/lib/useAltDateWidgetProps.js.map +1 -1
  193. package/lib/useFileWidgetProps.d.ts +2 -2
  194. package/lib/useFileWidgetProps.js +3 -3
  195. package/lib/useFileWidgetProps.js.map +1 -1
  196. package/lib/validationDataMerge.d.ts +1 -1
  197. package/lib/withIdRefPrefix.d.ts +1 -1
  198. package/lib/withIdRefPrefix.js +12 -12
  199. package/lib/withIdRefPrefix.js.map +1 -1
  200. package/package.json +19 -19
  201. package/src/ErrorSchemaBuilder.ts +1 -1
  202. package/src/SelectedOptionDescription.tsx +48 -0
  203. package/src/allowAdditionalItems.ts +2 -1
  204. package/src/asNumber.ts +2 -0
  205. package/src/canExpand.ts +1 -1
  206. package/src/constIsAjvDataReference.ts +2 -2
  207. package/src/constants.ts +10 -7
  208. package/src/createErrorHandler.ts +6 -7
  209. package/src/createSchemaUtils.ts +4 -2
  210. package/src/dataURItoBlob.ts +3 -3
  211. package/src/dateRangeOptions.ts +9 -7
  212. package/src/englishStringTranslator.ts +1 -1
  213. package/src/enumOptionSelectedValue.ts +1 -1
  214. package/src/enumOptionValueDecoder.ts +2 -2
  215. package/src/enumOptionValueEncoder.ts +1 -1
  216. package/src/enumOptionsDeselectValue.ts +1 -1
  217. package/src/enumOptionsIndexForValue.ts +2 -2
  218. package/src/enumOptionsIsSelected.ts +1 -1
  219. package/src/enumOptionsSelectValue.ts +1 -1
  220. package/src/enumOptionsValueForIndex.ts +2 -2
  221. package/src/enums.ts +4 -0
  222. package/src/findSchemaDefinition.ts +18 -17
  223. package/src/getChangedFields.ts +5 -5
  224. package/src/getDateElementProps.ts +3 -3
  225. package/src/getDiscriminatorFieldFromSchema.ts +2 -1
  226. package/src/getInputProps.ts +1 -1
  227. package/src/getOptionMatchingSimpleDiscriminator.ts +11 -15
  228. package/src/getOptionValueFormat.ts +1 -1
  229. package/src/getSchemaType.ts +3 -2
  230. package/src/getSubmitButtonOptions.ts +3 -3
  231. package/src/getTemplate.ts +1 -1
  232. package/src/getTestIds.ts +1 -1
  233. package/src/getUiOptions.ts +10 -2
  234. package/src/getWidget.tsx +5 -6
  235. package/src/guessType.ts +1 -1
  236. package/src/hasWidget.ts +1 -1
  237. package/src/hashForSchema.ts +12 -5
  238. package/src/idGenerators.ts +1 -1
  239. package/src/index.ts +16 -5
  240. package/src/isConstant.ts +1 -1
  241. package/src/isCustomWidget.ts +2 -2
  242. package/src/isFixedItems.ts +4 -4
  243. package/src/isRootSchema.ts +3 -5
  244. package/src/labelValue.ts +1 -1
  245. package/src/logUnsupportedDefaultForEnum.ts +28 -0
  246. package/src/lookupFromFormContext.ts +1 -1
  247. package/src/mergeDefaultsWithFormData.ts +8 -7
  248. package/src/mergeObjects.ts +2 -2
  249. package/src/mergeSchemas.ts +14 -7
  250. package/src/nameGenerators.ts +1 -1
  251. package/src/optionsList.ts +21 -23
  252. package/src/orderProperties.ts +4 -4
  253. package/src/pad.ts +1 -1
  254. package/src/parseDateString.ts +2 -2
  255. package/src/parser/ParserValidator.ts +4 -4
  256. package/src/parser/index.ts +1 -1
  257. package/src/parser/schemaParser.ts +10 -9
  258. package/src/rangeSpec.ts +1 -2
  259. package/src/removeOptionalEmptyObjects.ts +8 -11
  260. package/src/resolveUiSchema.ts +32 -25
  261. package/src/schema/findFieldInSchema.ts +1 -1
  262. package/src/schema/findSelectedOptionInXxxOf.ts +17 -7
  263. package/src/schema/getClosestMatchingOption.ts +17 -11
  264. package/src/schema/getDefaultFormState.ts +104 -43
  265. package/src/schema/getDisplayLabel.ts +4 -5
  266. package/src/schema/getFirstMatchingOption.ts +3 -3
  267. package/src/schema/getFromSchema.ts +1 -1
  268. package/src/schema/index.ts +3 -0
  269. package/src/schema/isFilesArray.ts +1 -1
  270. package/src/schema/isMultiSelect.ts +7 -1
  271. package/src/schema/isSelect.ts +8 -2
  272. package/src/schema/omitExtraData.ts +73 -60
  273. package/src/schema/retrieveSchema.ts +131 -83
  274. package/src/schema/sanitizeDataForNewSchema.ts +57 -8
  275. package/src/schema/toPathSchema.ts +11 -7
  276. package/src/schemaRequiresTrueValue.ts +4 -4
  277. package/src/shallowEquals.ts +2 -2
  278. package/src/shouldRenderOptionalField.ts +1 -1
  279. package/src/toConstant.ts +1 -1
  280. package/src/toDateString.ts +1 -1
  281. package/src/toErrorList.ts +4 -4
  282. package/src/toErrorSchema.ts +1 -1
  283. package/src/toFieldPathId.ts +1 -1
  284. package/src/types.ts +92 -63
  285. package/src/unwrapErrorHandler.ts +11 -12
  286. package/src/useAltDateWidgetProps.tsx +10 -8
  287. package/src/useFileWidgetProps.ts +7 -7
  288. package/src/validationDataMerge.ts +1 -1
  289. package/src/withIdRefPrefix.ts +12 -12
package/dist/utils.esm.js CHANGED
@@ -43,7 +43,7 @@ function asNumber(value) {
43
43
  }
44
44
 
45
45
  // src/constants.ts
46
- var ADDITIONAL_PROPERTY_FLAG = "__additional_property";
46
+ var ADDITIONAL_PROPERTY_FLAG = /* @__PURE__ */ Symbol("__additional_property");
47
47
  var ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
48
48
  var ALL_OF_KEY = "allOf";
49
49
  var ANY_OF_KEY = "anyOf";
@@ -65,15 +65,17 @@ var READONLY_KEY = "readonly";
65
65
  var REQUIRED_KEY = "required";
66
66
  var SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
67
67
  var REF_KEY = "$ref";
68
- var RJSF_REF_KEY = "__rjsf_ref";
68
+ var RJSF_REF_KEY = /* @__PURE__ */ Symbol("__rjsf_ref");
69
+ var RJSF_REF_CYCLE_KEY = /* @__PURE__ */ Symbol("__rjsf_ref_cycle");
69
70
  var SCHEMA_KEY = "$schema";
70
71
  var DEFAULT_ID_PREFIX = "root";
71
72
  var DEFAULT_ID_SEPARATOR = "_";
72
73
  var DISCRIMINATOR_PATH = ["discriminator", "propertyName"];
73
74
  var FORM_CONTEXT_NAME = "formContext";
74
75
  var LOOKUP_MAP_NAME = "layoutGridLookupMap";
75
- var RJSF_ADDITIONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
76
- var ROOT_SCHEMA_PREFIX = "__rjsf_rootSchema";
76
+ var RJSF_PREFIX_KEY = "__rjsf";
77
+ var RJSF_ADDITIONAL_PROPERTIES_FLAG = `${RJSF_PREFIX_KEY}_additionalProperties`;
78
+ var ROOT_SCHEMA_PREFIX = `${RJSF_PREFIX_KEY}_rootSchema`;
77
79
  var UI_FIELD_KEY = "ui:field";
78
80
  var UI_WIDGET_KEY = "ui:widget";
79
81
  var UI_OPTIONS_KEY = "ui:options";
@@ -87,7 +89,7 @@ function getUiOptions(uiSchema = {}, globalOptions = {}) {
87
89
  if (!uiSchema) {
88
90
  return { ...globalOptions };
89
91
  }
90
- return Object.keys(uiSchema).filter((key) => key.indexOf("ui:") === 0).reduce(
92
+ return Object.keys(uiSchema).filter((key) => key.startsWith("ui:")).reduce(
91
93
  (options, key) => {
92
94
  const value = uiSchema[key];
93
95
  if (key === UI_WIDGET_KEY && isObject(value)) {
@@ -131,21 +133,20 @@ function createErrorHandler(formData) {
131
133
  }
132
134
  };
133
135
  if (Array.isArray(formData)) {
134
- return formData.reduce((acc, value, key) => {
135
- return { ...acc, [key]: createErrorHandler(value) };
136
- }, handler);
136
+ return formData.reduce((acc, value, key) => ({ ...acc, [key]: createErrorHandler(value) }), handler);
137
137
  }
138
138
  if (isPlainObject(formData)) {
139
139
  const formObject = formData;
140
- return Object.keys(formObject).reduce((acc, key) => {
141
- return { ...acc, [key]: createErrorHandler(formObject[key]) };
142
- }, handler);
140
+ return Object.keys(formObject).reduce(
141
+ (acc, key) => ({ ...acc, [key]: createErrorHandler(formObject[key]) }),
142
+ handler
143
+ );
143
144
  }
144
145
  return handler;
145
146
  }
146
147
 
147
148
  // src/createSchemaUtils.ts
148
- import get17 from "lodash/get";
149
+ import get16 from "lodash/get";
149
150
 
150
151
  // src/deepEquals.ts
151
152
  import { createCustomEqual } from "fast-equals";
@@ -191,20 +192,21 @@ function findEmbeddedSchemaRecursive(schema, ref) {
191
192
  }
192
193
  function makeAllReferencesAbsolute(schema, baseURI) {
193
194
  const currentURI = get(schema, ID_KEY, baseURI);
194
- if (REF_KEY in schema) {
195
- schema = { ...schema, [REF_KEY]: UriResolver.resolve(currentURI, schema[REF_KEY]) };
195
+ let result = schema;
196
+ if (REF_KEY in result) {
197
+ result = { ...result, [REF_KEY]: UriResolver.resolve(currentURI, result[REF_KEY]) };
196
198
  }
197
- for (const [key, subSchema] of Object.entries(schema)) {
199
+ for (const [key, subSchema] of Object.entries(result)) {
198
200
  if (Array.isArray(subSchema)) {
199
- schema = {
200
- ...schema,
201
+ result = {
202
+ ...result,
201
203
  [key]: subSchema.map((item) => isObject2(item) ? makeAllReferencesAbsolute(item, currentURI) : item)
202
204
  };
203
205
  } else if (isObject2(subSchema)) {
204
- schema = { ...schema, [key]: makeAllReferencesAbsolute(subSchema, currentURI) };
206
+ result = { ...result, [key]: makeAllReferencesAbsolute(subSchema, currentURI) };
205
207
  }
206
208
  }
207
- return schema;
209
+ return result;
208
210
  }
209
211
  function splitKeyElementFromObject(key, object) {
210
212
  const value = object[key];
@@ -214,22 +216,23 @@ function splitKeyElementFromObject(key, object) {
214
216
  function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI = get(rootSchema, [ID_KEY])) {
215
217
  const ref = $ref || "";
216
218
  let current = void 0;
219
+ let currentBaseURI = baseURI;
217
220
  if (ref.startsWith("#")) {
218
221
  const decodedRef = decodeURIComponent(ref.substring(1));
219
- if (baseURI === void 0 || ID_KEY in rootSchema && rootSchema[ID_KEY] === baseURI) {
222
+ if (currentBaseURI === void 0 || ID_KEY in rootSchema && rootSchema[ID_KEY] === currentBaseURI) {
220
223
  current = jsonpointer.get(rootSchema, decodedRef);
221
224
  } else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
222
- current = findEmbeddedSchemaRecursive(rootSchema, baseURI.replace(/\/$/, ""));
225
+ current = findEmbeddedSchemaRecursive(rootSchema, currentBaseURI.replace(/\/$/, ""));
223
226
  if (current !== void 0) {
224
227
  current = jsonpointer.get(current, decodedRef);
225
228
  }
226
229
  }
227
230
  } else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
228
- const resolvedRef = baseURI ? UriResolver.resolve(baseURI, ref) : ref;
231
+ const resolvedRef = currentBaseURI ? UriResolver.resolve(currentBaseURI, ref) : ref;
229
232
  const [refId, ...refAnchor] = resolvedRef.replace(/#\/?$/, "").split("#");
230
233
  current = findEmbeddedSchemaRecursive(rootSchema, refId.replace(/\/$/, ""));
231
234
  if (current !== void 0) {
232
- baseURI = current[ID_KEY];
235
+ currentBaseURI = current[ID_KEY];
233
236
  if (!isEmpty(refAnchor)) {
234
237
  current = jsonpointer.get(current, decodeURIComponent(refAnchor.join("#")));
235
238
  }
@@ -249,13 +252,12 @@ function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [],
249
252
  throw new Error(`Definition for ${firstRef} contains a circular reference through ${circularPath}`);
250
253
  }
251
254
  const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
252
- const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref], baseURI);
255
+ const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref], currentBaseURI);
253
256
  if (Object.keys(remaining).length > 0) {
254
257
  if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2019_09 || rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
255
258
  return { [ALL_OF_KEY]: [remaining, subSchema] };
256
- } else {
257
- return { ...remaining, ...subSchema };
258
259
  }
260
+ return { ...remaining, ...subSchema };
259
261
  }
260
262
  return subSchema;
261
263
  }
@@ -311,7 +313,7 @@ function guessType(value) {
311
313
  if (typeof value === "boolean") {
312
314
  return "boolean";
313
315
  }
314
- if (!isNaN(value)) {
316
+ if (typeof value === "number" && !Number.isNaN(value)) {
315
317
  return "number";
316
318
  }
317
319
  if (typeof value === "object") {
@@ -337,7 +339,7 @@ function getSchemaType(schema) {
337
339
  }
338
340
  if (Array.isArray(type)) {
339
341
  if (type.length === 2 && type.includes("null")) {
340
- type = type.find((type2) => type2 !== "null");
342
+ type = type.find((t) => t !== "null");
341
343
  } else {
342
344
  type = type[0];
343
345
  }
@@ -347,18 +349,22 @@ function getSchemaType(schema) {
347
349
 
348
350
  // src/mergeSchemas.ts
349
351
  function mergeSchemas(obj1, obj2) {
350
- const acc = Object.assign({}, obj1);
351
- return Object.keys(obj2).reduce((acc2, key) => {
352
+ const acc = { ...obj1 };
353
+ const result = Object.keys(obj2).reduce((accumulator, key) => {
352
354
  const left = obj1 ? obj1[key] : {}, right = obj2[key];
353
355
  if (obj1 && key in obj1 && isObject(right)) {
354
- acc2[key] = mergeSchemas(left, right);
356
+ accumulator[key] = mergeSchemas(left, right);
355
357
  } else if (obj1 && obj2 && (getSchemaType(obj1) === "object" || getSchemaType(obj2) === "object") && key === REQUIRED_KEY && Array.isArray(left) && Array.isArray(right)) {
356
- acc2[key] = union(left, right);
358
+ accumulator[key] = union(left, right);
357
359
  } else {
358
- acc2[key] = right;
360
+ accumulator[key] = right;
359
361
  }
360
- return acc2;
362
+ return accumulator;
361
363
  }, acc);
364
+ for (const sym of Object.getOwnPropertySymbols(obj2)) {
365
+ result[sym] = obj2[sym];
366
+ }
367
+ return result;
362
368
  }
363
369
 
364
370
  // src/schema/getFirstMatchingOption.ts
@@ -372,23 +378,22 @@ function getOptionMatchingSimpleDiscriminator(formData, options, discriminatorFi
372
378
  if (formData && discriminatorField) {
373
379
  const value = get3(formData, discriminatorField);
374
380
  if (value === void 0) {
375
- return;
381
+ return void 0;
376
382
  }
377
- for (let i = 0; i < options.length; i++) {
383
+ for (let i = 0; i < options.length; i += 1) {
378
384
  const option = options[i];
379
385
  const discriminator = get3(option, [PROPERTIES_KEY, discriminatorField], {});
380
- if (discriminator.type === "object" || discriminator.type === "array") {
381
- continue;
382
- }
383
- if (discriminator.const === value) {
384
- return i;
385
- }
386
- if (discriminator.enum?.includes(value)) {
387
- return i;
386
+ if (discriminator.type !== "object" && discriminator.type !== "array") {
387
+ if (discriminator.const === value) {
388
+ return i;
389
+ }
390
+ if (discriminator.enum?.includes(value)) {
391
+ return i;
392
+ }
388
393
  }
389
394
  }
390
395
  }
391
- return;
396
+ return void 0;
392
397
  }
393
398
 
394
399
  // src/schema/getFirstMatchingOption.ts
@@ -400,7 +405,7 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
400
405
  if (isNumber(simpleDiscriminatorMatch)) {
401
406
  return simpleDiscriminatorMatch;
402
407
  }
403
- for (let i = 0; i < options.length; i++) {
408
+ for (let i = 0; i < options.length; i += 1) {
404
409
  const option = options[i];
405
410
  if (discriminatorField && has(option, [PROPERTIES_KEY, discriminatorField])) {
406
411
  const value = get4(formData, discriminatorField);
@@ -425,7 +430,7 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
425
430
  shallowClone.allOf.push(requiresAnyOf);
426
431
  augmentedSchema = shallowClone;
427
432
  } else {
428
- augmentedSchema = Object.assign({}, option, requiresAnyOf);
433
+ augmentedSchema = { ...option, ...requiresAnyOf };
429
434
  }
430
435
  delete augmentedSchema.required;
431
436
  if (validator.isValid(augmentedSchema, formData, rootSchema)) {
@@ -461,6 +466,12 @@ function retrieveSchema(validator, schema, rootSchema = {}, rawFormData, experim
461
466
  resolveAnyOfOrOneOfRefs
462
467
  )[0];
463
468
  }
469
+ function normalizeBooleanSchema(schema) {
470
+ if (typeof schema !== "boolean") {
471
+ return schema;
472
+ }
473
+ return schema ? {} : { not: {} };
474
+ }
464
475
  function resolveCondition(validator, schema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
465
476
  const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;
466
477
  const conditionValue = validator.isValid(expression, formData || {}, rootSchema);
@@ -468,10 +479,11 @@ function resolveCondition(validator, schema, rootSchema, expandAllBranches, recu
468
479
  let schemas = [];
469
480
  if (expandAllBranches) {
470
481
  if (then && typeof then !== "boolean") {
482
+ const thenSchema = then;
471
483
  schemas = schemas.concat(
472
484
  retrieveSchemaInternal(
473
485
  validator,
474
- then,
486
+ thenSchema,
475
487
  rootSchema,
476
488
  formData,
477
489
  expandAllBranches,
@@ -481,10 +493,11 @@ function resolveCondition(validator, schema, rootSchema, expandAllBranches, recu
481
493
  );
482
494
  }
483
495
  if (otherwise && typeof otherwise !== "boolean") {
496
+ const otherwiseSchema = otherwise;
484
497
  schemas = schemas.concat(
485
498
  retrieveSchemaInternal(
486
499
  validator,
487
- otherwise,
500
+ otherwiseSchema,
488
501
  rootSchema,
489
502
  formData,
490
503
  expandAllBranches,
@@ -494,8 +507,9 @@ function resolveCondition(validator, schema, rootSchema, expandAllBranches, recu
494
507
  );
495
508
  }
496
509
  } else {
497
- const conditionalSchema = conditionValue ? then : otherwise;
498
- if (conditionalSchema && typeof conditionalSchema !== "boolean") {
510
+ const conditionalBranch = conditionValue ? then : otherwise;
511
+ if (conditionalBranch !== void 0) {
512
+ const conditionalSchema = normalizeBooleanSchema(conditionalBranch);
499
513
  schemas = schemas.concat(
500
514
  retrieveSchemaInternal(
501
515
  validator,
@@ -571,8 +585,8 @@ function resolveSchema(validator, schema, rootSchema, expandAllBranches, recurse
571
585
  formData,
572
586
  experimental_customMergeAllOf
573
587
  );
574
- return resolvedSchemas.flatMap((s) => {
575
- return retrieveSchemaInternal(
588
+ return resolvedSchemas.flatMap(
589
+ (s) => retrieveSchemaInternal(
576
590
  validator,
577
591
  s,
578
592
  rootSchema,
@@ -580,8 +594,8 @@ function resolveSchema(validator, schema, rootSchema, expandAllBranches, recurse
580
594
  expandAllBranches,
581
595
  recurseList,
582
596
  experimental_customMergeAllOf
583
- );
584
- });
597
+ )
598
+ );
585
599
  }
586
600
  if (ALL_OF_KEY in schema && Array.isArray(schema[ALL_OF_KEY])) {
587
601
  const allOfSchemaElements = schema.allOf.map(
@@ -619,30 +633,38 @@ function resolveReference(validator, schema, rootSchema, expandAllBranches, recu
619
633
  }
620
634
  return [schema];
621
635
  }
622
- function resolveAllReferences(schema, rootSchema, recurseList, baseURI, resolveAnyOfOrOneOfRefs) {
636
+ function resolveAllReferences(schema, rootSchema, recurseList, baseURI, resolveAnyOfOrOneOfRefs, markCycleOnDetection = false) {
623
637
  if (!isObject(schema)) {
624
638
  return schema;
625
639
  }
626
640
  let resolvedSchema = schema;
641
+ let currentBaseURI = baseURI;
627
642
  if (REF_KEY in resolvedSchema) {
628
643
  const { $ref, ...localSchema } = resolvedSchema;
629
644
  if (recurseList.includes($ref)) {
630
- return resolvedSchema;
645
+ return markCycleOnDetection ? { ...resolvedSchema, [RJSF_REF_CYCLE_KEY]: true } : resolvedSchema;
631
646
  }
632
647
  recurseList.push($ref);
633
- const refSchema = findSchemaDefinition($ref, rootSchema, baseURI);
648
+ const refSchema = findSchemaDefinition($ref, rootSchema, currentBaseURI);
634
649
  resolvedSchema = { ...refSchema, ...localSchema, [RJSF_REF_KEY]: $ref };
635
650
  if (ID_KEY in resolvedSchema) {
636
- baseURI = resolvedSchema[ID_KEY];
651
+ currentBaseURI = resolvedSchema[ID_KEY];
637
652
  }
638
653
  }
639
654
  if (PROPERTIES_KEY in resolvedSchema) {
640
655
  const childrenLists = [];
641
656
  const updatedProps = transform(
642
657
  resolvedSchema[PROPERTIES_KEY],
643
- (result, value, key) => {
658
+ (acc, value, key) => {
644
659
  const childList = [...recurseList];
645
- result[key] = resolveAllReferences(value, rootSchema, childList, baseURI, resolveAnyOfOrOneOfRefs);
660
+ acc[key] = resolveAllReferences(
661
+ value,
662
+ rootSchema,
663
+ childList,
664
+ currentBaseURI,
665
+ resolveAnyOfOrOneOfRefs,
666
+ !resolveAnyOfOrOneOfRefs
667
+ );
646
668
  childrenLists.push(childList);
647
669
  },
648
670
  {}
@@ -653,7 +675,14 @@ function resolveAllReferences(schema, rootSchema, recurseList, baseURI, resolveA
653
675
  if (ITEMS_KEY in resolvedSchema && !Array.isArray(resolvedSchema.items) && typeof resolvedSchema.items !== "boolean") {
654
676
  resolvedSchema = {
655
677
  ...resolvedSchema,
656
- items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList, baseURI, resolveAnyOfOrOneOfRefs)
678
+ // Array items are only rendered when data exists, so a $ref cycle here does NOT cause an infinite render.
679
+ items: resolveAllReferences(
680
+ resolvedSchema.items,
681
+ rootSchema,
682
+ recurseList,
683
+ currentBaseURI,
684
+ resolveAnyOfOrOneOfRefs
685
+ )
657
686
  };
658
687
  }
659
688
  if (resolveAnyOfOrOneOfRefs) {
@@ -670,7 +699,7 @@ function resolveAllReferences(schema, rootSchema, recurseList, baseURI, resolveA
670
699
  resolvedSchema = {
671
700
  ...resolvedSchema,
672
701
  [key]: schemas.map(
673
- (s) => resolveAllReferences(s, rootSchema, recurseList, baseURI, resolveAnyOfOrOneOfRefs)
702
+ (s) => resolveAllReferences(s, rootSchema, recurseList, currentBaseURI, resolveAnyOfOrOneOfRefs)
674
703
  )
675
704
  };
676
705
  }
@@ -697,7 +726,7 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
697
726
  get5(formData, [key]),
698
727
  experimental_customMergeAllOf
699
728
  );
700
- set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
729
+ schema.properties[key][ADDITIONAL_PROPERTY_FLAG] = true;
701
730
  return;
702
731
  }
703
732
  }
@@ -709,7 +738,7 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
709
738
  validator,
710
739
  { [REF_KEY]: get5(schema.additionalProperties, [REF_KEY]) },
711
740
  rootSchema,
712
- formData,
741
+ get5(formData, [key]),
713
742
  experimental_customMergeAllOf
714
743
  );
715
744
  } else if ("type" in schema.additionalProperties) {
@@ -726,10 +755,10 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
726
755
  additionalProperties = { type: guessType(get5(formData, [key])) };
727
756
  }
728
757
  schema.properties[key] = additionalProperties;
729
- set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
758
+ schema.properties[key][ADDITIONAL_PROPERTY_FLAG] = true;
730
759
  } else {
731
760
  schema.properties[key] = { type: "null" };
732
- set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
761
+ schema.properties[key][ADDITIONAL_PROPERTY_FLAG] = true;
733
762
  }
734
763
  });
735
764
  return schema;
@@ -772,17 +801,26 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
772
801
  try {
773
802
  const withContainsSchemas = [];
774
803
  const withoutContainsSchemas = [];
775
- resolvedSchema.allOf?.forEach((s2) => {
776
- if (typeof s2 === "object" && s2.contains) {
777
- withContainsSchemas.push(s2);
804
+ const allOfSymbols = {};
805
+ resolvedSchema.allOf?.forEach((allOfItem) => {
806
+ if (typeof allOfItem === "object" && allOfItem.contains) {
807
+ withContainsSchemas.push(allOfItem);
778
808
  } else {
779
- withoutContainsSchemas.push(s2);
809
+ withoutContainsSchemas.push(allOfItem);
810
+ for (const sym of Object.getOwnPropertySymbols(allOfItem)) {
811
+ if (!(sym in allOfSymbols)) {
812
+ allOfSymbols[sym] = allOfItem[sym];
813
+ }
814
+ }
780
815
  }
781
816
  });
782
817
  if (withContainsSchemas.length) {
783
818
  resolvedSchema = { ...resolvedSchema, allOf: withoutContainsSchemas };
784
819
  }
785
820
  resolvedSchema = experimental_customMergeAllOf ? experimental_customMergeAllOf(resolvedSchema) : mergeAllOf(resolvedSchema);
821
+ for (const sym of Object.getOwnPropertySymbols(allOfSymbols)) {
822
+ resolvedSchema[sym] = allOfSymbols[sym];
823
+ }
786
824
  if (withContainsSchemas.length) {
787
825
  resolvedSchema.allOf = withContainsSchemas;
788
826
  }
@@ -794,18 +832,18 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
794
832
  }
795
833
  if (PROPERTIES_KEY in resolvedSchema && PATTERN_PROPERTIES_KEY in resolvedSchema) {
796
834
  resolvedSchema = Object.keys(resolvedSchema.properties).reduce(
797
- (schema2, key) => {
798
- const matchingProperties = getMatchingPatternProperties(schema2, key);
835
+ (acc, key) => {
836
+ const matchingProperties = getMatchingPatternProperties(acc, key);
799
837
  if (!isEmpty2(matchingProperties)) {
800
- schema2.properties[key] = retrieveSchema(
838
+ acc.properties[key] = retrieveSchema(
801
839
  validator,
802
- { allOf: [schema2.properties[key], ...Object.values(matchingProperties)] },
840
+ { allOf: [acc.properties[key], ...Object.values(matchingProperties)] },
803
841
  rootSchema,
804
842
  get5(rawFormData, [key]),
805
843
  experimental_customMergeAllOf
806
844
  );
807
845
  }
808
- return schema2;
846
+ return acc;
809
847
  },
810
848
  {
811
849
  ...resolvedSchema,
@@ -837,23 +875,21 @@ function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranch
837
875
  if (anyOrOneOf) {
838
876
  const formData = rawFormData === void 0 && expandAllBranches ? {} : rawFormData;
839
877
  const discriminator = getDiscriminatorFieldFromSchema(schema);
840
- anyOrOneOf = anyOrOneOf.map((s) => {
841
- return resolveAllReferences(s, rootSchema, []);
842
- });
878
+ anyOrOneOf = anyOrOneOf.map((s) => resolveAllReferences(s, rootSchema, []));
843
879
  const option = getFirstMatchingOption(validator, formData, anyOrOneOf, rootSchema, discriminator);
844
880
  if (expandAllBranches) {
845
881
  const relaxed = relaxOptionsForScoring(anyOrOneOf, false, rootSchema);
846
882
  getFirstMatchingOption(validator, formData, relaxed, rootSchema, discriminator);
847
883
  return anyOrOneOf.map((item) => mergeSchemas(remaining, item));
848
884
  }
849
- schema = mergeSchemas(remaining, anyOrOneOf[option]);
885
+ return [mergeSchemas(remaining, anyOrOneOf[option])];
850
886
  }
851
887
  return [schema];
852
888
  }
853
889
  function relaxOptionsForScoring(options, resolveRefs = false, rootSchema) {
854
890
  return options.map((d) => {
855
891
  if (!isObject(d)) {
856
- return d ? {} : { not: {} };
892
+ return normalizeBooleanSchema(d);
857
893
  }
858
894
  const schema = resolveRefs && rootSchema ? resolveAllReferences(d, rootSchema, []) : d;
859
895
  return schema.additionalProperties === false ? { ...schema, additionalProperties: true } : schema;
@@ -884,43 +920,39 @@ function resolveDependencies(validator, schema, rootSchema, expandAllBranches, r
884
920
  function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
885
921
  let schemas = [resolvedSchema];
886
922
  for (const dependencyKey in dependencies) {
887
- if (!expandAllBranches && get5(formData, [dependencyKey]) === void 0) {
888
- continue;
889
- }
890
- if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
891
- continue;
892
- }
893
- const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(
894
- dependencyKey,
895
- dependencies
896
- );
897
- if (Array.isArray(dependencyValue)) {
898
- schemas[0] = withDependentProperties(resolvedSchema, dependencyValue);
899
- } else if (isObject(dependencyValue)) {
900
- schemas = withDependentSchema(
901
- validator,
902
- resolvedSchema,
903
- rootSchema,
923
+ if ((expandAllBranches || get5(formData, [dependencyKey]) !== void 0) && (!resolvedSchema.properties || dependencyKey in resolvedSchema.properties)) {
924
+ const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(
904
925
  dependencyKey,
905
- dependencyValue,
906
- expandAllBranches,
907
- recurseList,
908
- formData,
909
- experimental_customMergeAllOf
926
+ dependencies
927
+ );
928
+ if (Array.isArray(dependencyValue)) {
929
+ schemas[0] = withDependentProperties(resolvedSchema, dependencyValue);
930
+ } else if (isObject(dependencyValue)) {
931
+ schemas = withDependentSchema(
932
+ validator,
933
+ resolvedSchema,
934
+ rootSchema,
935
+ dependencyKey,
936
+ dependencyValue,
937
+ expandAllBranches,
938
+ recurseList,
939
+ formData,
940
+ experimental_customMergeAllOf
941
+ );
942
+ }
943
+ return schemas.flatMap(
944
+ (schema) => processDependencies(
945
+ validator,
946
+ remainingDependencies,
947
+ schema,
948
+ rootSchema,
949
+ expandAllBranches,
950
+ recurseList,
951
+ formData,
952
+ experimental_customMergeAllOf
953
+ )
910
954
  );
911
955
  }
912
- return schemas.flatMap(
913
- (schema) => processDependencies(
914
- validator,
915
- remainingDependencies,
916
- schema,
917
- rootSchema,
918
- expandAllBranches,
919
- recurseList,
920
- formData,
921
- experimental_customMergeAllOf
922
- )
923
- );
924
956
  }
925
957
  return schemas;
926
958
  }
@@ -943,9 +975,9 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
943
975
  );
944
976
  return dependentSchemas.flatMap((dependent) => {
945
977
  const { oneOf, ...dependentSchema } = dependent;
946
- schema = mergeSchemas(schema, dependentSchema);
978
+ const mergedSchema = mergeSchemas(schema, dependentSchema);
947
979
  if (oneOf === void 0) {
948
- return schema;
980
+ return mergedSchema;
949
981
  }
950
982
  const resolvedOneOfs = oneOf.map((subschema) => {
951
983
  if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
@@ -957,7 +989,7 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
957
989
  return allPermutations.flatMap(
958
990
  (resolvedOneOf) => withExactlyOneSubschema(
959
991
  validator,
960
- schema,
992
+ mergedSchema,
961
993
  rootSchema,
962
994
  dependencyKey,
963
995
  resolvedOneOf,
@@ -971,7 +1003,7 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
971
1003
  }
972
1004
  function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
973
1005
  const validSubschemas = oneOf.filter((subschema) => {
974
- if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
1006
+ if (typeof subschema === "boolean" || !subschema?.properties) {
975
1007
  return false;
976
1008
  }
977
1009
  const { [dependencyKey]: conditionPropertySchema } = subschema.properties;
@@ -1003,7 +1035,7 @@ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, o
1003
1035
  recurseList,
1004
1036
  experimental_customMergeAllOf
1005
1037
  );
1006
- return schemas.map((s2) => mergeSchemas(schema, s2));
1038
+ return schemas.map((resolvedSubschema) => mergeSchemas(schema, resolvedSubschema));
1007
1039
  });
1008
1040
  }
1009
1041
 
@@ -1017,12 +1049,16 @@ function findSelectedOptionInXxxOf(validator, rootSchema, schema, fallbackField,
1017
1049
  );
1018
1050
  const data = get6(formData, selectorField);
1019
1051
  if (data !== void 0) {
1020
- return xxxOfs.find((xxx2) => {
1021
- return deepEquals_default(
1022
- get6(xxx2, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get6(xxx2, [PROPERTIES_KEY, selectorField, CONST_KEY])),
1052
+ return xxxOfs.find(
1053
+ (xxxOfOption) => deepEquals_default(
1054
+ get6(
1055
+ xxxOfOption,
1056
+ [PROPERTIES_KEY, selectorField, DEFAULT_KEY],
1057
+ get6(xxxOfOption, [PROPERTIES_KEY, selectorField, CONST_KEY])
1058
+ ),
1023
1059
  data
1024
- );
1025
- });
1060
+ )
1061
+ );
1026
1062
  }
1027
1063
  }
1028
1064
  return void 0;
@@ -1194,23 +1230,21 @@ function calculateIndexScore(validator, rootSchema, schema, formData, experiment
1194
1230
  );
1195
1231
  }
1196
1232
  if ((has4(value, ONE_OF_KEY) || has4(value, ANY_OF_KEY)) && formValue) {
1197
- const key2 = has4(value, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
1233
+ const xxxOfKey = has4(value, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
1198
1234
  const discriminator = getDiscriminatorFieldFromSchema(value);
1199
1235
  return score + getClosestMatchingOption(
1200
1236
  validator,
1201
1237
  rootSchema,
1202
1238
  formValue,
1203
- get9(value, key2),
1239
+ get9(value, xxxOfKey),
1204
1240
  -1,
1205
1241
  discriminator,
1206
1242
  experimental_customMergeAllOf
1207
1243
  );
1208
1244
  }
1209
1245
  if (value.type === "object") {
1210
- if (isObject3(formValue)) {
1211
- score += 1;
1212
- }
1213
- return score + calculateIndexScore(validator, rootSchema, value, formValue, experimental_customMergeAllOf);
1246
+ const structureBoost = isObject3(formValue) ? 1 : 0;
1247
+ return score + structureBoost + calculateIndexScore(validator, rootSchema, value, formValue, experimental_customMergeAllOf);
1214
1248
  }
1215
1249
  if (value.type === guessType(formValue)) {
1216
1250
  let newScore = score + 1;
@@ -1232,9 +1266,7 @@ function calculateIndexScore(validator, rootSchema, schema, formData, experiment
1232
1266
  return totalScore;
1233
1267
  }
1234
1268
  function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption = -1, discriminatorField, experimental_customMergeAllOf) {
1235
- const resolvedOptions = options.map((option) => {
1236
- return resolveAllReferences(option, rootSchema, []);
1237
- });
1269
+ const resolvedOptions = options.map((option) => resolveAllReferences(option, rootSchema, []));
1238
1270
  const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);
1239
1271
  if (isNumber2(simpleDiscriminatorMatch)) {
1240
1272
  return simpleDiscriminatorMatch;
@@ -1292,7 +1324,7 @@ function isConstant(schema) {
1292
1324
 
1293
1325
  // src/isFixedItems.ts
1294
1326
  function isFixedItems(schema) {
1295
- return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every((item) => isObject(item));
1327
+ return Array.isArray(schema.items) && schema.items.every((item) => isObject(item));
1296
1328
  }
1297
1329
 
1298
1330
  // src/mergeDefaultsWithFormData.ts
@@ -1322,7 +1354,7 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults =
1322
1354
  }
1323
1355
  if (isObject(formData)) {
1324
1356
  const acc = Object.assign({}, defaults);
1325
- return Object.keys(formData).reduce((acc2, key) => {
1357
+ return Object.keys(formData).reduce((accumulator, key) => {
1326
1358
  const keyValue = get10(formData, key);
1327
1359
  const keyExistsInDefaults = isObject(defaults) && key in defaults;
1328
1360
  const keyExistsInFormData = key in formData;
@@ -1331,13 +1363,13 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults =
1331
1363
  const keyDefaultIsObject = keyExistsInDefaults && isObject(get10(defaults, key));
1332
1364
  const keyHasFormDataObject = keyExistsInFormData && isObject(keyValue);
1333
1365
  if (keyDefaultIsObject && keyHasFormDataObject && !defaultValueIsNestedObject) {
1334
- acc2[key] = {
1366
+ accumulator[key] = {
1335
1367
  ...get10(defaults, key),
1336
1368
  ...keyValue
1337
1369
  };
1338
- return acc2;
1370
+ return accumulator;
1339
1371
  }
1340
- acc2[key] = mergeDefaultsWithFormData(
1372
+ accumulator[key] = mergeDefaultsWithFormData(
1341
1373
  get10(defaults, key),
1342
1374
  keyValue,
1343
1375
  mergeExtraArrayDefaults,
@@ -1346,10 +1378,10 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults =
1346
1378
  // Or if the key value doesn't exist in formData
1347
1379
  overrideFormDataWithDefaults && (keyExistsInDefaults || !keyExistsInFormData)
1348
1380
  );
1349
- return acc2;
1381
+ return acc;
1350
1382
  }, acc);
1351
1383
  }
1352
- if (defaultSupercedesUndefined && (!(defaults === void 0) && isNil(formData) || typeof formData === "number" && isNaN(formData)) || overrideFormDataWithDefaults && !isNil(formData)) {
1384
+ if (defaultSupercedesUndefined && (!(defaults === void 0) && isNil(formData) || typeof formData === "number" && Number.isNaN(formData)) || overrideFormDataWithDefaults && !isNil(formData)) {
1353
1385
  return defaults;
1354
1386
  }
1355
1387
  return formData;
@@ -1378,7 +1410,7 @@ function mergeObjects(obj1, obj2, concatArrays = false) {
1378
1410
  }
1379
1411
  return acc;
1380
1412
  },
1381
- Object.assign({}, obj1)
1413
+ { ...obj1 }
1382
1414
  );
1383
1415
  }
1384
1416
 
@@ -1441,7 +1473,7 @@ function optionsList(schema, uiSchema) {
1441
1473
  const { optionsSchemaSelector = selectorField } = getUiOptions(uiSchema);
1442
1474
  selectorField = optionsSchemaSelector;
1443
1475
  }
1444
- return altSchemas && altSchemas.map((aSchemaDef, index) => {
1476
+ return altSchemas?.map((aSchemaDef, index) => {
1445
1477
  const { title } = getUiOptions(altUiSchemas?.[index]);
1446
1478
  const aSchema = aSchemaDef;
1447
1479
  let value;
@@ -1449,10 +1481,10 @@ function optionsList(schema, uiSchema) {
1449
1481
  if (selectorField) {
1450
1482
  const innerSchema = get11(aSchema, [PROPERTIES_KEY, selectorField], {});
1451
1483
  value = get11(innerSchema, DEFAULT_KEY, get11(innerSchema, CONST_KEY));
1452
- label = label || innerSchema?.title || aSchema.title || String(value);
1484
+ label = label ?? innerSchema?.title ?? aSchema.title ?? String(value);
1453
1485
  } else {
1454
1486
  value = toConstant(aSchema);
1455
- label = label || aSchema.title || String(value);
1487
+ label = label ?? aSchema.title ?? String(value);
1456
1488
  }
1457
1489
  return {
1458
1490
  schema: aSchema,
@@ -1470,7 +1502,7 @@ function isSelect(validator, theSchema, rootSchema = {}, experimental_customMerg
1470
1502
  return true;
1471
1503
  }
1472
1504
  if (Array.isArray(altSchemas)) {
1473
- return altSchemas.every((altSchemas2) => typeof altSchemas2 !== "boolean" && isConstant(altSchemas2));
1505
+ return altSchemas.every((altSchema) => typeof altSchema !== "boolean" && isConstant(altSchema));
1474
1506
  }
1475
1507
  return false;
1476
1508
  }
@@ -1506,23 +1538,23 @@ function computeDefaultBasedOnSchemaTypeAndDefaults(schema, computedDefault) {
1506
1538
  const shouldReturnNullAsDefault = Array.isArray(type) && type.includes("null") && isEmpty4(computedDefault) && schemaDefault === null;
1507
1539
  return shouldReturnNullAsDefault ? null : computedDefault;
1508
1540
  }
1509
- function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false, isNullType = false) {
1541
+ function maybeAddDefaultToObject(acc, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false, isNullType = false) {
1510
1542
  const { emptyObjectFields = "populateAllDefaults" } = experimental_defaultFormStateBehavior;
1511
1543
  if (includeUndefinedValues === true || isConst) {
1512
- obj[key] = computedDefault;
1544
+ acc[key] = computedDefault;
1513
1545
  } else if (includeUndefinedValues === "excludeObjectChildren") {
1514
1546
  if (isNullType && computedDefault !== void 0 || !isObject(computedDefault) || !isEmpty4(computedDefault)) {
1515
- obj[key] = computedDefault;
1547
+ acc[key] = computedDefault;
1516
1548
  }
1517
1549
  } else if (emptyObjectFields !== "skipDefaults") {
1518
1550
  const isSelfOrParentRequired = isParentRequired === void 0 ? requiredFields.includes(key) : isParentRequired;
1519
1551
  if (isObject(computedDefault)) {
1520
1552
  if (emptyObjectFields === "skipEmptyDefaults") {
1521
1553
  if (!isEmpty4(computedDefault)) {
1522
- obj[key] = computedDefault;
1554
+ acc[key] = computedDefault;
1523
1555
  }
1524
1556
  } else if ((!isEmpty4(computedDefault) || requiredFields.includes(key)) && (isSelfOrParentRequired || emptyObjectFields !== "populateRequiredDefaults")) {
1525
- obj[key] = computedDefault;
1557
+ acc[key] = computedDefault;
1526
1558
  }
1527
1559
  } else if (
1528
1560
  // Store computedDefault if it's a defined primitive (e.g., true) and satisfies certain conditions
@@ -1531,7 +1563,7 @@ function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValu
1531
1563
  // Or if isSelfOrParentRequired is 'true' and the key is a required field
1532
1564
  computedDefault !== void 0 && (emptyObjectFields === "populateAllDefaults" || emptyObjectFields === "skipEmptyDefaults" || isSelfOrParentRequired && requiredFields.includes(key))
1533
1565
  ) {
1534
- obj[key] = computedDefault;
1566
+ acc[key] = computedDefault;
1535
1567
  }
1536
1568
  }
1537
1569
  }
@@ -1542,8 +1574,8 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1542
1574
  rootSchema = {},
1543
1575
  includeUndefinedValues = false,
1544
1576
  _recurseList = [],
1545
- experimental_defaultFormStateBehavior = void 0,
1546
- experimental_customMergeAllOf = void 0,
1577
+ experimental_defaultFormStateBehavior,
1578
+ experimental_customMergeAllOf,
1547
1579
  required,
1548
1580
  shouldMergeDefaultsIntoFormData = false,
1549
1581
  initialDefaultsGenerated
@@ -1551,14 +1583,19 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1551
1583
  let formData = isObject(rawFormData) ? rawFormData : {};
1552
1584
  const schema = isObject(rawSchema) ? rawSchema : {};
1553
1585
  let defaults = parentDefaults;
1586
+ const preferParentDefaults = defaults && experimental_defaultFormStateBehavior?.nestedDefaultsPrecedence === "ancestorWins";
1554
1587
  let schemaToCompute = null;
1555
1588
  let experimental_dfsb_to_compute = experimental_defaultFormStateBehavior;
1556
1589
  let updatedRecurseList = _recurseList;
1557
1590
  if (schema[CONST_KEY] !== void 0 && experimental_defaultFormStateBehavior?.constAsDefaults !== "never" && !constIsAjvDataReference(schema)) {
1558
1591
  defaults = schema[CONST_KEY];
1559
1592
  } else if (isObject(defaults) && isObject(schema.default) && !schema[ANY_OF_KEY] && !schema[ONE_OF_KEY] && !schema[REF_KEY]) {
1560
- defaults = mergeObjects(defaults, schema.default);
1561
- } else if (DEFAULT_KEY in schema && !schema[ANY_OF_KEY] && !schema[ONE_OF_KEY] && !schema[REF_KEY]) {
1593
+ if (preferParentDefaults) {
1594
+ defaults = mergeObjects(schema.default, defaults);
1595
+ } else {
1596
+ defaults = mergeObjects(defaults, schema.default);
1597
+ }
1598
+ } else if (DEFAULT_KEY in schema && !preferParentDefaults && !schema[ANY_OF_KEY] && !schema[ONE_OF_KEY] && !schema[REF_KEY]) {
1562
1599
  defaults = schema.default;
1563
1600
  } else if (REF_KEY in schema) {
1564
1601
  const refName = schema[REF_KEY];
@@ -1587,8 +1624,8 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1587
1624
  defaultFormData,
1588
1625
  experimental_customMergeAllOf
1589
1626
  );
1590
- schemaToCompute = resolvedSchema[0];
1591
- } else if (isFixedItems(schema)) {
1627
+ [schemaToCompute] = resolvedSchema;
1628
+ } else if (isFixedItems(schema) && !preferParentDefaults) {
1592
1629
  defaults = schema.items.map(
1593
1630
  (itemSchema, idx) => computeDefaults(validator, itemSchema, {
1594
1631
  rootSchema,
@@ -1684,16 +1721,36 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1684
1721
  return defaultsWithFormData;
1685
1722
  }
1686
1723
  function ensureFormDataMatchingSchema(validator, schema, rootSchema, formData, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
1687
- const isSelectField = !isConstant(schema) && isSelect(validator, schema, rootSchema, experimental_customMergeAllOf);
1724
+ const shouldRetrieveAllOf = experimental_defaultFormStateBehavior?.allOf === "populateDefaults" && ALL_OF_KEY in schema;
1725
+ const schemaToMatch = shouldRetrieveAllOf ? retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf) : schema;
1726
+ const isSelectField = !isConstant(schemaToMatch) && isSelect(validator, schemaToMatch, rootSchema, experimental_customMergeAllOf);
1688
1727
  let validFormData = formData;
1689
1728
  if (isSelectField) {
1690
- const getOptionsList = optionsList(schema);
1729
+ const getOptionsList = optionsList(schemaToMatch);
1691
1730
  const isValid = getOptionsList?.some((option) => deepEquals_default(option.value, formData));
1692
1731
  validFormData = isValid ? formData : void 0;
1693
1732
  }
1694
- const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
1733
+ const constTakesPrecedence = schemaToMatch[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
1695
1734
  if (constTakesPrecedence) {
1696
- validFormData = schema.const;
1735
+ validFormData = schemaToMatch.const;
1736
+ } else if (isObject(validFormData) && isObject(schemaToMatch.properties)) {
1737
+ validFormData = Object.keys(schemaToMatch.properties).reduce(
1738
+ (acc, key) => {
1739
+ const propertySchema = get12(schemaToMatch, [PROPERTIES_KEY, key], {});
1740
+ if (key in acc && (shouldRetrieveAllOf || isObject(propertySchema) && ALL_OF_KEY in propertySchema)) {
1741
+ acc[key] = ensureFormDataMatchingSchema(
1742
+ validator,
1743
+ propertySchema,
1744
+ rootSchema,
1745
+ get12(acc, key),
1746
+ experimental_defaultFormStateBehavior,
1747
+ experimental_customMergeAllOf
1748
+ );
1749
+ }
1750
+ return acc;
1751
+ },
1752
+ { ...validFormData }
1753
+ );
1697
1754
  }
1698
1755
  return validFormData;
1699
1756
  }
@@ -1702,8 +1759,8 @@ function getObjectDefaults(validator, rawSchema, {
1702
1759
  rootSchema = {},
1703
1760
  includeUndefinedValues = false,
1704
1761
  _recurseList = [],
1705
- experimental_defaultFormStateBehavior = void 0,
1706
- experimental_customMergeAllOf = void 0,
1762
+ experimental_defaultFormStateBehavior,
1763
+ experimental_customMergeAllOf,
1707
1764
  required,
1708
1765
  shouldMergeDefaultsIntoFormData,
1709
1766
  initialDefaultsGenerated
@@ -1787,13 +1844,14 @@ function getArrayDefaults(validator, rawSchema, {
1787
1844
  rawFormData,
1788
1845
  rootSchema = {},
1789
1846
  _recurseList = [],
1790
- experimental_defaultFormStateBehavior = void 0,
1791
- experimental_customMergeAllOf = void 0,
1847
+ experimental_defaultFormStateBehavior,
1848
+ experimental_customMergeAllOf,
1792
1849
  required,
1793
1850
  requiredAsRoot = false,
1794
1851
  shouldMergeDefaultsIntoFormData,
1795
1852
  initialDefaultsGenerated
1796
- } = {}, defaults) {
1853
+ } = {}, initialDefaults) {
1854
+ let defaults = initialDefaults;
1797
1855
  const schema = rawSchema;
1798
1856
  const arrayMinItemsStateBehavior = experimental_defaultFormStateBehavior?.arrayMinItems ?? {};
1799
1857
  const { populate: arrayMinItemsPopulate, mergeExtraDefaults: arrayMergeExtraDefaults } = arrayMinItemsStateBehavior;
@@ -1825,8 +1883,8 @@ function getArrayDefaults(validator, rawSchema, {
1825
1883
  if (neverPopulate) {
1826
1884
  defaults = rawFormData;
1827
1885
  } else {
1828
- const itemDefaults = rawFormData.map((item, idx) => {
1829
- return computeDefaults(validator, schemaItem, {
1886
+ const itemDefaults = rawFormData.map(
1887
+ (item, idx) => computeDefaults(validator, schemaItem, {
1830
1888
  rootSchema,
1831
1889
  _recurseList,
1832
1890
  experimental_defaultFormStateBehavior,
@@ -1836,20 +1894,27 @@ function getArrayDefaults(validator, rawSchema, {
1836
1894
  required,
1837
1895
  shouldMergeDefaultsIntoFormData,
1838
1896
  initialDefaultsGenerated
1839
- });
1840
- });
1897
+ })
1898
+ );
1841
1899
  const mergeExtraDefaults = (ignoreMinItemsFlagSet && required || isPopulateAll) && arrayMergeExtraDefaults;
1842
1900
  defaults = mergeDefaultsWithFormData(defaults, itemDefaults, mergeExtraDefaults);
1843
1901
  }
1844
1902
  }
1903
+ const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1845
1904
  if (neverPopulate) {
1905
+ if (shouldMergeDefaultsIntoFormData) {
1906
+ if (schema.minItems && schema.minItems > defaultsLength) {
1907
+ const fillerEntries = Array.from({ length: schema.minItems - defaultsLength }, () => null);
1908
+ return (defaults ?? []).concat(fillerEntries);
1909
+ }
1910
+ return defaults;
1911
+ }
1846
1912
  return defaults ?? emptyDefault;
1847
1913
  }
1848
1914
  if (ignoreMinItemsFlagSet && !required) {
1849
- return defaults ? defaults : void 0;
1915
+ return defaults || void 0;
1850
1916
  }
1851
1917
  let arrayDefault;
1852
- const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1853
1918
  if (!schema.minItems || isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) || computeSkipPopulate(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
1854
1919
  arrayDefault = defaults || !required && !requiredAsRoot ? defaults : emptyDefault;
1855
1920
  } else {
@@ -1881,11 +1946,13 @@ function getDefaultBasedOnSchemaType(validator, rawSchema, computeDefaultsProps
1881
1946
  case "array": {
1882
1947
  return getArrayDefaults(validator, rawSchema, computeDefaultsProps, defaults);
1883
1948
  }
1949
+ default:
1950
+ return void 0;
1884
1951
  }
1885
1952
  }
1886
1953
  function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues = false, experimental_defaultFormStateBehavior, experimental_customMergeAllOf, initialDefaultsGenerated) {
1887
1954
  if (!isObject(theSchema)) {
1888
- throw new Error("Invalid schema: " + theSchema);
1955
+ throw new Error(`Invalid schema: ${theSchema}`);
1889
1956
  }
1890
1957
  const schema = retrieveSchema(validator, theSchema, rootSchema, formData, experimental_customMergeAllOf);
1891
1958
  const defaults = computeDefaults(validator, schema, {
@@ -1907,9 +1974,17 @@ function getDefaultFormState(validator, theSchema, formData, rootSchema, include
1907
1974
  if (isObject(formData) || Array.isArray(formData)) {
1908
1975
  const { mergeDefaultsIntoFormData } = experimental_defaultFormStateBehavior || {};
1909
1976
  const defaultSupercedesUndefined = mergeDefaultsIntoFormData === "useDefaultIfFormDataUndefined";
1977
+ const matchingFormData = ensureFormDataMatchingSchema(
1978
+ validator,
1979
+ schema,
1980
+ rootSchema ?? schema,
1981
+ formData,
1982
+ experimental_defaultFormStateBehavior,
1983
+ experimental_customMergeAllOf
1984
+ );
1910
1985
  const result = mergeDefaultsWithFormData(
1911
1986
  defaults,
1912
- formData,
1987
+ matchingFormData,
1913
1988
  true,
1914
1989
  // set to true to add any additional default array entries.
1915
1990
  defaultSupercedesUndefined,
@@ -1921,15 +1996,12 @@ function getDefaultFormState(validator, theSchema, formData, rootSchema, include
1921
1996
  return defaults;
1922
1997
  }
1923
1998
 
1924
- // src/schema/getDisplayLabel.ts
1925
- import get13 from "lodash/get";
1926
-
1927
1999
  // src/isCustomWidget.ts
1928
2000
  function isCustomWidget(uiSchema = {}) {
1929
2001
  return (
1930
2002
  // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1931
2003
  // https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets
1932
- "widget" in getUiOptions(uiSchema) && getUiOptions(uiSchema)["widget"] !== "hidden"
2004
+ "widget" in getUiOptions(uiSchema) && getUiOptions(uiSchema).widget !== "hidden"
1933
2005
  );
1934
2006
  }
1935
2007
 
@@ -1958,7 +2030,7 @@ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOpt
1958
2030
  let displayLabel = Boolean(label);
1959
2031
  if (displayLabel) {
1960
2032
  const schemaType = getSchemaType(schema);
1961
- const addedByAdditionalProperty = get13(schema, ADDITIONAL_PROPERTY_FLAG, false);
2033
+ const addedByAdditionalProperty = Boolean(schema[ADDITIONAL_PROPERTY_FLAG]);
1962
2034
  if (schemaType === "array") {
1963
2035
  displayLabel = addedByAdditionalProperty || isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) || isFilesArray(validator, schema, uiSchema, rootSchema, experimental_customMergeAllOf) || isCustomWidget(uiSchema);
1964
2036
  }
@@ -1968,7 +2040,7 @@ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOpt
1968
2040
  if (schemaType === "boolean" && uiSchema && !uiSchema[UI_WIDGET_KEY]) {
1969
2041
  displayLabel = false;
1970
2042
  }
1971
- if (uiSchema && uiSchema[UI_FIELD_KEY]) {
2043
+ if (uiSchema?.[UI_FIELD_KEY]) {
1972
2044
  displayLabel = false;
1973
2045
  }
1974
2046
  }
@@ -1976,7 +2048,7 @@ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOpt
1976
2048
  }
1977
2049
 
1978
2050
  // src/schema/omitExtraData.ts
1979
- import get14 from "lodash/get";
2051
+ import get13 from "lodash/get";
1980
2052
  import isEmpty5 from "lodash/isEmpty";
1981
2053
  import isNil2 from "lodash/isNil";
1982
2054
  import pick from "lodash/pick";
@@ -2005,7 +2077,7 @@ function getFieldNames(pathSchema, formData) {
2005
2077
  }
2006
2078
  } else if (key === NAME_KEY && data !== "") {
2007
2079
  paths.forEach((path) => {
2008
- const formValue = get14(formData, path);
2080
+ const formValue = get13(formData, path);
2009
2081
  const isLeaf = objKeys.length === 1;
2010
2082
  if (formValueHasData(formValue, isLeaf) || Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf))) {
2011
2083
  acc.push(path);
@@ -2039,11 +2111,11 @@ function omitExtraData(validator, schema, rootSchema = {}, formData, experimenta
2039
2111
  function isSchemaObj(schemaDef) {
2040
2112
  return isObject(schemaDef);
2041
2113
  }
2042
- function handleObject(schema2, source, target) {
2043
- const { properties, additionalProperties, patternProperties, propertyNames } = schema2;
2044
- const requiredSet = new Set(schema2.required ?? []);
2114
+ function handleObject(childSchema, source, target) {
2115
+ const { properties, additionalProperties, patternProperties, propertyNames } = childSchema;
2116
+ const requiredSet = new Set(childSchema.required ?? []);
2045
2117
  function setProperty(key, schemaDef, value, required = false) {
2046
- const v = omit3(schemaDef, value, target[key]);
2118
+ const v = omit2(schemaDef, value, target[key]);
2047
2119
  if (!required && isObject(v)) {
2048
2120
  let sd = isSchemaObj(schemaDef) ? schemaDef : {};
2049
2121
  if (sd.$ref !== void 0) {
@@ -2075,15 +2147,14 @@ function omitExtraData(validator, schema, rootSchema = {}, formData, experimenta
2075
2147
  ]);
2076
2148
  const knownProperties = new Set(Object.keys(properties ?? {}));
2077
2149
  for (const [key, value] of Object.entries(source)) {
2078
- if (knownProperties.has(key)) {
2079
- continue;
2080
- }
2081
- const matched = patterns.find(([re]) => re.test(key));
2082
- if (matched === void 0) {
2083
- patternPropertiesRest.push(key);
2084
- continue;
2150
+ if (!knownProperties.has(key)) {
2151
+ const matched = patterns.find(([re]) => re.test(key));
2152
+ if (matched === void 0) {
2153
+ patternPropertiesRest.push(key);
2154
+ } else {
2155
+ setProperty(key, matched[1], value);
2156
+ }
2085
2157
  }
2086
- setProperty(key, matched[1], value);
2087
2158
  }
2088
2159
  }
2089
2160
  if (additionalProperties !== void 0 && additionalProperties !== false) {
@@ -2095,10 +2166,9 @@ function omitExtraData(validator, schema, rootSchema = {}, formData, experimenta
2095
2166
  } else {
2096
2167
  const knownProperties = new Set(Object.keys(properties ?? {}));
2097
2168
  for (const [key, value] of Object.entries(source)) {
2098
- if (knownProperties.has(key)) {
2099
- continue;
2169
+ if (!knownProperties.has(key)) {
2170
+ setProperty(key, addlSchema, value);
2100
2171
  }
2101
- setProperty(key, addlSchema, value);
2102
2172
  }
2103
2173
  }
2104
2174
  }
@@ -2109,37 +2179,37 @@ function omitExtraData(validator, schema, rootSchema = {}, formData, experimenta
2109
2179
  }
2110
2180
  return target;
2111
2181
  }
2112
- function handleArray(schema2, source, target) {
2113
- const { items, additionalItems } = schema2;
2182
+ function handleArray(childSchema, source, target) {
2183
+ const { items, additionalItems } = childSchema;
2114
2184
  if (items !== void 0) {
2115
2185
  if (Array.isArray(items)) {
2116
- for (let i = 0; i < items.length; i++) {
2117
- target.push(omit3(items[i], source[i]));
2186
+ for (let i = 0; i < items.length; i += 1) {
2187
+ target.push(omit2(items[i], source[i]));
2118
2188
  }
2119
2189
  } else {
2120
- for (let i = 0; i < source.length; i++) {
2121
- target.push(omit3(items, source[i]));
2190
+ for (let i = 0; i < source.length; i += 1) {
2191
+ target.push(omit2(items, source[i]));
2122
2192
  }
2123
2193
  }
2124
2194
  }
2125
2195
  if (additionalItems) {
2126
- for (let i = target.length; i < source.length; i++) {
2127
- target.push(omit3(additionalItems, source[i]));
2196
+ for (let i = target.length; i < source.length; i += 1) {
2197
+ target.push(omit2(additionalItems, source[i]));
2128
2198
  }
2129
2199
  }
2130
2200
  return target;
2131
2201
  }
2132
- function handleConditions(schema2, source, target) {
2133
- const { if: condition, then, else: otherwise } = schema2;
2202
+ function handleConditions(childSchema, source, target) {
2203
+ const { if: condition, then, else: otherwise } = childSchema;
2134
2204
  if (condition === void 0) {
2135
2205
  return target;
2136
2206
  }
2137
2207
  const isThenBranch = isSchemaObj(condition) ? validator.isValid(condition, source, rootSchema) : condition;
2138
2208
  const branch = isThenBranch ? then : otherwise;
2139
- return branch === void 0 ? target : omit3(branch, source, target);
2209
+ return branch === void 0 ? target : omit2(branch, source, target);
2140
2210
  }
2141
- function handleOneOf(oneOf, schema2, source, target) {
2142
- if (!Array.isArray(oneOf) || isSelect(validator, schema2, rootSchema, experimental_customMergeAllOf)) {
2211
+ function handleOneOf(oneOf, childSchema, source, target) {
2212
+ if (!Array.isArray(oneOf) || isSelect(validator, childSchema, rootSchema, experimental_customMergeAllOf)) {
2143
2213
  return target;
2144
2214
  }
2145
2215
  const scoringOptions = relaxOptionsForScoring(oneOf, true, rootSchema);
@@ -2149,96 +2219,130 @@ function omitExtraData(validator, schema, rootSchema = {}, formData, experimenta
2149
2219
  source,
2150
2220
  scoringOptions,
2151
2221
  0,
2152
- getDiscriminatorFieldFromSchema(schema2),
2222
+ getDiscriminatorFieldFromSchema(childSchema),
2153
2223
  experimental_customMergeAllOf
2154
2224
  );
2155
2225
  const winning = oneOf[bestIndex];
2156
2226
  const resolved = isObject(winning) ? resolveAllReferences(winning, rootSchema, []) : scoringOptions[bestIndex];
2157
- return omit3(resolved, source, target);
2227
+ return omit2(resolved, source, target);
2158
2228
  }
2159
- function handleAnyOf(schema2, source, target) {
2160
- const { anyOf } = schema2;
2229
+ function handleAnyOf(childSchema, source, target) {
2230
+ const { anyOf } = childSchema;
2161
2231
  if (!Array.isArray(anyOf)) {
2162
2232
  return target;
2163
2233
  }
2164
2234
  if (source === void 0 || Array.isArray(source) && source.length === 0 || isObject(source) && Object.keys(source).length === 0) {
2235
+ let result = target;
2165
2236
  for (const branch of anyOf) {
2166
- target = omit3(branch, source, target);
2237
+ result = omit2(branch, source, result);
2167
2238
  }
2168
- return target;
2239
+ return result;
2169
2240
  }
2170
- return handleOneOf(anyOf, schema2, source, target);
2241
+ return handleOneOf(anyOf, childSchema, source, target);
2171
2242
  }
2172
- function handleDependencies(schema2, source, target) {
2173
- const { dependencies } = schema2;
2243
+ function handleDependencies(childSchema, source, target) {
2244
+ const { dependencies } = childSchema;
2174
2245
  if (dependencies === void 0 || !isObjectValue(source)) {
2175
2246
  return target;
2176
2247
  }
2248
+ let result = target;
2177
2249
  for (const [key, deps] of Object.entries(dependencies)) {
2178
- if (!(key in source) || Array.isArray(deps)) {
2179
- continue;
2250
+ if (key in source && !Array.isArray(deps)) {
2251
+ result = omit2(deps, source, result);
2180
2252
  }
2181
- target = omit3(deps, source, target);
2182
2253
  }
2183
- return target;
2254
+ return result;
2184
2255
  }
2185
- function omit3(schemaDef, source, target) {
2256
+ function omit2(schemaDef, source, target) {
2186
2257
  if (source === void 0 || schemaDef === false) {
2187
2258
  return void 0;
2188
2259
  }
2189
2260
  if (schemaDef === true || isEmpty5(schemaDef)) {
2190
2261
  return source;
2191
2262
  }
2192
- let schema2 = schemaDef;
2193
- const { $ref: ref, allOf } = schema2;
2263
+ let localSchema = schemaDef;
2264
+ const { $ref: ref, allOf } = localSchema;
2194
2265
  if (ref !== void 0) {
2195
- return omit3(findSchemaDefinition(ref, rootSchema), source, target);
2266
+ return omit2(findSchemaDefinition(ref, rootSchema), source, target);
2196
2267
  }
2197
2268
  if (allOf) {
2198
- schema2 = doMergeAllOf(schema2, experimental_customMergeAllOf);
2269
+ localSchema = doMergeAllOf(localSchema, experimental_customMergeAllOf);
2270
+ const remainingAllOf = localSchema.allOf;
2271
+ if (remainingAllOf) {
2272
+ for (let i = 0; i < remainingAllOf.length; i++) {
2273
+ target = omit2(remainingAllOf[i], source, target);
2274
+ }
2275
+ }
2199
2276
  }
2200
- target = handleAnyOf(schema2, source, handleOneOf(schema2.oneOf, schema2, source, target));
2201
- const type = getSchemaType(schema2);
2277
+ let filtered = handleAnyOf(localSchema, source, handleOneOf(localSchema.oneOf, localSchema, source, target));
2278
+ const type = getSchemaType(localSchema);
2202
2279
  if (type === "object") {
2203
2280
  if (!isObjectValue(source)) {
2204
2281
  return void 0;
2205
2282
  }
2206
- target = handleObject(schema2, source, isObjectValue(target) ? target : {});
2283
+ filtered = handleObject(localSchema, source, isObjectValue(filtered) ? filtered : {});
2207
2284
  } else if (type === "array") {
2208
2285
  if (!Array.isArray(source)) {
2209
2286
  return void 0;
2210
2287
  }
2211
- target = handleArray(schema2, source, Array.isArray(target) ? target : []);
2212
- } else if (target === void 0) {
2213
- target = source;
2288
+ filtered = handleArray(localSchema, source, Array.isArray(filtered) ? filtered : []);
2289
+ } else if (filtered === void 0) {
2290
+ filtered = source;
2214
2291
  }
2215
- return handleDependencies(schema2, source, handleConditions(schema2, source, target));
2292
+ return handleDependencies(localSchema, source, handleConditions(localSchema, source, filtered));
2216
2293
  }
2217
- return omit3(schema, formData);
2294
+ return omit2(schema, formData);
2218
2295
  }
2219
2296
 
2220
2297
  // src/schema/sanitizeDataForNewSchema.ts
2221
- import get15 from "lodash/get";
2298
+ import get14 from "lodash/get";
2222
2299
  import has5 from "lodash/has";
2223
2300
  var NO_VALUE = /* @__PURE__ */ Symbol("no Value");
2301
+ function enumValuesForSchema(schema) {
2302
+ if (Array.isArray(schema.enum)) {
2303
+ return schema.enum;
2304
+ }
2305
+ const options = schema.oneOf || schema.anyOf;
2306
+ if (!Array.isArray(options)) {
2307
+ return void 0;
2308
+ }
2309
+ const values = options.map((option) => {
2310
+ if (CONST_KEY in option) {
2311
+ return option[CONST_KEY];
2312
+ }
2313
+ return Array.isArray(option.enum) && option.enum.length === 1 ? option.enum[0] : NO_VALUE;
2314
+ }).filter((value) => value !== NO_VALUE);
2315
+ return values.length > 0 ? values : void 0;
2316
+ }
2317
+ function replacementForInvalidEnumValue(schema, formValue) {
2318
+ const enumValues = enumValuesForSchema(schema);
2319
+ if (!enumValues || enumValues.some((value) => deepEquals_default(value, formValue))) {
2320
+ return NO_VALUE;
2321
+ }
2322
+ const defaultValue = get14(schema, DEFAULT_KEY, NO_VALUE);
2323
+ if (defaultValue !== NO_VALUE && enumValues.some((value) => deepEquals_default(value, defaultValue))) {
2324
+ return defaultValue;
2325
+ }
2326
+ return enumValues.length === 1 ? enumValues[0] : void 0;
2327
+ }
2224
2328
  function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}, experimental_customMergeAllOf) {
2225
2329
  let newFormData;
2226
2330
  if (has5(newSchema, PROPERTIES_KEY)) {
2227
2331
  const removeOldSchemaData = {};
2228
2332
  if (has5(oldSchema, PROPERTIES_KEY)) {
2229
- const properties = get15(oldSchema, PROPERTIES_KEY, {});
2333
+ const properties = get14(oldSchema, PROPERTIES_KEY, {});
2230
2334
  Object.keys(properties).forEach((key) => {
2231
2335
  if (has5(data, key)) {
2232
2336
  removeOldSchemaData[key] = void 0;
2233
2337
  }
2234
2338
  });
2235
2339
  }
2236
- const keys2 = Object.keys(get15(newSchema, PROPERTIES_KEY, {}));
2340
+ const keys2 = Object.keys(get14(newSchema, PROPERTIES_KEY, {}));
2237
2341
  const nestedData = {};
2238
2342
  keys2.forEach((key) => {
2239
- const formValue = get15(data, key);
2240
- let oldKeyedSchema = get15(oldSchema, [PROPERTIES_KEY, key], {});
2241
- let newKeyedSchema = get15(newSchema, [PROPERTIES_KEY, key], {});
2343
+ const formValue = get14(data, key);
2344
+ let oldKeyedSchema = get14(oldSchema, [PROPERTIES_KEY, key], {});
2345
+ let newKeyedSchema = get14(newSchema, [PROPERTIES_KEY, key], {});
2242
2346
  if (has5(oldKeyedSchema, REF_KEY)) {
2243
2347
  oldKeyedSchema = retrieveSchema(
2244
2348
  validator,
@@ -2257,8 +2361,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
2257
2361
  experimental_customMergeAllOf
2258
2362
  );
2259
2363
  }
2260
- const oldSchemaTypeForKey = get15(oldKeyedSchema, "type");
2261
- const newSchemaTypeForKey = get15(newKeyedSchema, "type");
2364
+ const oldSchemaTypeForKey = get14(oldKeyedSchema, "type");
2365
+ const newSchemaTypeForKey = get14(newKeyedSchema, "type");
2262
2366
  if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
2263
2367
  if (has5(removeOldSchemaData, key)) {
2264
2368
  delete removeOldSchemaData[key];
@@ -2276,31 +2380,37 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
2276
2380
  nestedData[key] = itemData;
2277
2381
  }
2278
2382
  } else {
2279
- const newOptionDefault = get15(newKeyedSchema, "default", NO_VALUE);
2280
- const oldOptionDefault = get15(oldKeyedSchema, "default", NO_VALUE);
2383
+ const newOptionDefault = get14(newKeyedSchema, DEFAULT_KEY, NO_VALUE);
2384
+ const oldOptionDefault = get14(oldKeyedSchema, DEFAULT_KEY, NO_VALUE);
2281
2385
  if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
2282
2386
  if (oldOptionDefault === formValue) {
2283
2387
  removeOldSchemaData[key] = newOptionDefault;
2284
- } else if (get15(newKeyedSchema, "readOnly") === true) {
2388
+ } else if (get14(newKeyedSchema, "readOnly") === true) {
2285
2389
  removeOldSchemaData[key] = void 0;
2286
2390
  }
2287
2391
  }
2288
- const newOptionConst = get15(newKeyedSchema, "const", NO_VALUE);
2289
- const oldOptionConst = get15(oldKeyedSchema, "const", NO_VALUE);
2392
+ const newOptionConst = get14(newKeyedSchema, CONST_KEY, NO_VALUE);
2393
+ const oldOptionConst = get14(oldKeyedSchema, CONST_KEY, NO_VALUE);
2290
2394
  if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
2291
2395
  removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : void 0;
2292
2396
  }
2397
+ if (has5(data, key)) {
2398
+ const enumReplacement = replacementForInvalidEnumValue(newKeyedSchema, formValue);
2399
+ if (enumReplacement !== NO_VALUE) {
2400
+ removeOldSchemaData[key] = enumReplacement;
2401
+ }
2402
+ }
2293
2403
  }
2294
2404
  }
2295
2405
  });
2296
2406
  newFormData = {
2297
- ...typeof data == "string" || Array.isArray(data) ? void 0 : data,
2407
+ ...typeof data === "string" || Array.isArray(data) ? void 0 : data,
2298
2408
  ...removeOldSchemaData,
2299
2409
  ...nestedData
2300
2410
  };
2301
- } else if (get15(oldSchema, "type") === "array" && get15(newSchema, "type") === "array" && Array.isArray(data)) {
2302
- let oldSchemaItems = get15(oldSchema, "items");
2303
- let newSchemaItems = get15(newSchema, "items");
2411
+ } else if (get14(oldSchema, "type") === "array" && get14(newSchema, "type") === "array" && Array.isArray(data)) {
2412
+ let oldSchemaItems = get14(oldSchema, "items");
2413
+ let newSchemaItems = get14(newSchema, "items");
2304
2414
  if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
2305
2415
  if (has5(oldSchemaItems, REF_KEY)) {
2306
2416
  oldSchemaItems = retrieveSchema(
@@ -2320,10 +2430,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
2320
2430
  experimental_customMergeAllOf
2321
2431
  );
2322
2432
  }
2323
- const oldSchemaType = get15(oldSchemaItems, "type");
2324
- const newSchemaType = get15(newSchemaItems, "type");
2433
+ const oldSchemaType = get14(oldSchemaItems, "type");
2434
+ const newSchemaType = get14(newSchemaItems, "type");
2325
2435
  if (!oldSchemaType || oldSchemaType === newSchemaType) {
2326
- const maxItems = get15(newSchema, "maxItems", -1);
2436
+ const maxItems = get14(newSchema, "maxItems", -1);
2327
2437
  if (newSchemaType === "object") {
2328
2438
  newFormData = data.reduce((newValue, aValue) => {
2329
2439
  const itemValue = sanitizeDataForNewSchema(
@@ -2340,7 +2450,9 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
2340
2450
  return newValue;
2341
2451
  }, []);
2342
2452
  } else {
2343
- newFormData = maxItems > 0 && data.length > maxItems ? data.slice(0, maxItems) : data;
2453
+ const newItemEnumValues = enumValuesForSchema(newSchemaItems);
2454
+ const filteredData = newItemEnumValues ? data.filter((item) => newItemEnumValues.some((v) => deepEquals_default(v, item))) : data;
2455
+ newFormData = maxItems > 0 && filteredData.length > maxItems ? filteredData.slice(0, maxItems) : filteredData;
2344
2456
  }
2345
2457
  }
2346
2458
  } else if (typeof oldSchemaItems === "boolean" && typeof newSchemaItems === "boolean" && oldSchemaItems === newSchemaItems) {
@@ -2351,21 +2463,21 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
2351
2463
  }
2352
2464
 
2353
2465
  // src/schema/toPathSchema.ts
2354
- import get16 from "lodash/get";
2466
+ import get15 from "lodash/get";
2355
2467
  import isObject4 from "lodash/isObject";
2356
2468
  import set2 from "lodash/set";
2357
2469
  function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
2358
2470
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema || IF_KEY in schema) {
2359
- const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
2360
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
2471
+ const innerSchema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
2472
+ const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, innerSchema));
2361
2473
  if (sameSchemaIndex === -1) {
2362
2474
  return toPathSchemaInternal(
2363
2475
  validator,
2364
- _schema,
2476
+ innerSchema,
2365
2477
  name,
2366
2478
  rootSchema,
2367
2479
  formData,
2368
- _recurseList.concat(_schema),
2480
+ _recurseList.concat(innerSchema),
2369
2481
  experimental_customMergeAllOf
2370
2482
  );
2371
2483
  }
@@ -2385,12 +2497,12 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
2385
2497
  discriminator,
2386
2498
  experimental_customMergeAllOf
2387
2499
  );
2388
- const _schema = xxxOf[index];
2500
+ const innerSchema = xxxOf[index];
2389
2501
  pathSchema = {
2390
2502
  ...pathSchema,
2391
2503
  ...toPathSchemaInternal(
2392
2504
  validator,
2393
- _schema,
2505
+ innerSchema,
2394
2506
  name,
2395
2507
  rootSchema,
2396
2508
  formData,
@@ -2402,7 +2514,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
2402
2514
  if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
2403
2515
  set2(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);
2404
2516
  const additionalSchema = isObject4(schema[ADDITIONAL_PROPERTIES_KEY]) ? schema[ADDITIONAL_PROPERTIES_KEY] : {};
2405
- const definedProperties = get16(schema, PROPERTIES_KEY, {});
2517
+ const definedProperties = get15(schema, PROPERTIES_KEY, {});
2406
2518
  for (const key of Object.keys(formData ?? {})) {
2407
2519
  if (!(key in definedProperties)) {
2408
2520
  pathSchema[key] = toPathSchemaInternal(
@@ -2410,7 +2522,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
2410
2522
  additionalSchema,
2411
2523
  `${name}.${key}`,
2412
2524
  rootSchema,
2413
- get16(formData, [key]),
2525
+ get15(formData, [key]),
2414
2526
  _recurseList,
2415
2527
  experimental_customMergeAllOf
2416
2528
  );
@@ -2460,7 +2572,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
2460
2572
  }
2461
2573
  } else if (PROPERTIES_KEY in schema) {
2462
2574
  for (const property in schema.properties) {
2463
- const field = get16(schema, [PROPERTIES_KEY, property], {});
2575
+ const field = get15(schema, [PROPERTIES_KEY, property], {});
2464
2576
  pathSchema[property] = toPathSchemaInternal(
2465
2577
  validator,
2466
2578
  field,
@@ -2468,7 +2580,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
2468
2580
  rootSchema,
2469
2581
  // It's possible that formData is not an object -- this can happen if an
2470
2582
  // array item has just been added, but not populated with data yet
2471
- get16(formData, [property]),
2583
+ get15(formData, [property]),
2472
2584
  _recurseList,
2473
2585
  experimental_customMergeAllOf
2474
2586
  );
@@ -2490,8 +2602,8 @@ var SchemaUtils = class {
2490
2602
  * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
2491
2603
  */
2492
2604
  constructor(validator, rootSchema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
2493
- if (rootSchema && rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
2494
- this.rootSchema = makeAllReferencesAbsolute(rootSchema, get17(rootSchema, ID_KEY, "#"));
2605
+ if (rootSchema?.[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
2606
+ this.rootSchema = makeAllReferencesAbsolute(rootSchema, get16(rootSchema, ID_KEY, "#"));
2495
2607
  } else {
2496
2608
  this.rootSchema = rootSchema;
2497
2609
  }
@@ -2742,6 +2854,7 @@ var SchemaUtils = class {
2742
2854
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
2743
2855
  * @returns - The `PathSchema` object for the `schema`
2744
2856
  */
2857
+ // oxlint-disable-next-line typescript/no-deprecated
2745
2858
  toPathSchema(schema, name, formData) {
2746
2859
  return toPathSchema(
2747
2860
  this.validator,
@@ -2764,7 +2877,7 @@ function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateB
2764
2877
 
2765
2878
  // src/dataURItoBlob.ts
2766
2879
  function dataURItoBlob(dataURILike) {
2767
- if (dataURILike.indexOf("data:") === -1) {
2880
+ if (!dataURILike.includes("data:")) {
2768
2881
  throw new Error("File is invalid: URI must be a dataURI");
2769
2882
  }
2770
2883
  const dataURI = dataURILike.slice(5);
@@ -2783,13 +2896,13 @@ function dataURItoBlob(dataURILike) {
2783
2896
  try {
2784
2897
  const binary = atob(base64);
2785
2898
  const array = new Array(binary.length);
2786
- for (let i = 0; i < binary.length; i++) {
2899
+ for (let i = 0; i < binary.length; i += 1) {
2787
2900
  array[i] = binary.charCodeAt(i);
2788
2901
  }
2789
2902
  const blob = new window.Blob([new Uint8Array(array)], { type });
2790
2903
  return { blob, name };
2791
2904
  } catch (error) {
2792
- throw new Error("File is invalid: " + error.message);
2905
+ throw new Error(`File is invalid: ${error.message}`);
2793
2906
  }
2794
2907
  }
2795
2908
 
@@ -2797,24 +2910,26 @@ function dataURItoBlob(dataURILike) {
2797
2910
  function pad(num, width) {
2798
2911
  let s = String(num);
2799
2912
  while (s.length < width) {
2800
- s = "0" + s;
2913
+ s = `0${s}`;
2801
2914
  }
2802
2915
  return s;
2803
2916
  }
2804
2917
 
2805
2918
  // src/dateRangeOptions.ts
2806
2919
  function dateRangeOptions(start, stop) {
2807
- if (start <= 0 && stop <= 0) {
2808
- start = (/* @__PURE__ */ new Date()).getFullYear() + start;
2809
- stop = (/* @__PURE__ */ new Date()).getFullYear() + stop;
2810
- } else if (start < 0 || stop < 0) {
2920
+ const bothRelative = start <= 0 && stop <= 0;
2921
+ const eitherNegative = start < 0 || stop < 0;
2922
+ if (!bothRelative && eitherNegative) {
2811
2923
  throw new Error(`Both start (${start}) and stop (${stop}) must both be <= 0 or > 0, got one of each`);
2812
2924
  }
2813
- if (start > stop) {
2925
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
2926
+ const resolvedStart = bothRelative ? currentYear + start : start;
2927
+ const resolvedStop = bothRelative ? currentYear + stop : stop;
2928
+ if (resolvedStart > resolvedStop) {
2814
2929
  return dateRangeOptions(stop, start).reverse();
2815
2930
  }
2816
2931
  const options = [];
2817
- for (let i = start; i <= stop; i++) {
2932
+ for (let i = resolvedStart; i <= resolvedStop; i += 1) {
2818
2933
  options.push({ value: i, label: pad(i, 2) });
2819
2934
  }
2820
2935
  return options;
@@ -2913,7 +3028,7 @@ function decodeSingle(value, enumOptions, emptyValue) {
2913
3028
  return match.value;
2914
3029
  }
2915
3030
  const index = Number(value);
2916
- if (!isNaN(index) && index >= 0 && index < enumOptions.length) {
3031
+ if (!Number.isNaN(index) && index >= 0 && index < enumOptions.length) {
2917
3032
  return enumOptions[index].value;
2918
3033
  }
2919
3034
  return emptyValue;
@@ -2945,7 +3060,7 @@ function enumOptionValueEncoder(value, index, format = "indexed") {
2945
3060
 
2946
3061
  // src/ErrorSchemaBuilder.ts
2947
3062
  import cloneDeep from "lodash/cloneDeep";
2948
- import get18 from "lodash/get";
3063
+ import get17 from "lodash/get";
2949
3064
  import set3 from "lodash/set";
2950
3065
  import setWith from "lodash/setWith";
2951
3066
  var ErrorSchemaBuilder = class {
@@ -2974,7 +3089,7 @@ var ErrorSchemaBuilder = class {
2974
3089
  */
2975
3090
  getOrCreateErrorBlock(pathOfError) {
2976
3091
  const hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
2977
- let errorBlock = hasPath ? get18(this.errorSchema, pathOfError) : this.errorSchema;
3092
+ let errorBlock = hasPath ? get17(this.errorSchema, pathOfError) : this.errorSchema;
2978
3093
  if (!errorBlock && pathOfError) {
2979
3094
  errorBlock = {};
2980
3095
  setWith(this.errorSchema, pathOfError, errorBlock, Object);
@@ -3000,7 +3115,7 @@ var ErrorSchemaBuilder = class {
3000
3115
  */
3001
3116
  addErrors(errorOrList, pathOfError) {
3002
3117
  const errorBlock = this.getOrCreateErrorBlock(pathOfError);
3003
- let errorsList = get18(errorBlock, ERRORS_KEY);
3118
+ let errorsList = get17(errorBlock, ERRORS_KEY);
3004
3119
  if (!Array.isArray(errorsList)) {
3005
3120
  errorsList = [];
3006
3121
  errorBlock[ERRORS_KEY] = errorsList;
@@ -3042,7 +3157,7 @@ var ErrorSchemaBuilder = class {
3042
3157
 
3043
3158
  // src/getChangedFields.ts
3044
3159
  import difference from "lodash/difference";
3045
- import get19 from "lodash/get";
3160
+ import get18 from "lodash/get";
3046
3161
  import isPlainObject2 from "lodash/isPlainObject";
3047
3162
  import keys from "lodash/keys";
3048
3163
  import pickBy from "lodash/pickBy";
@@ -3054,13 +3169,13 @@ function getChangedFields(a, b) {
3054
3169
  }
3055
3170
  if (aIsPlainObject && !bIsPlainObject) {
3056
3171
  return keys(a);
3057
- } else if (!aIsPlainObject && bIsPlainObject) {
3172
+ }
3173
+ if (!aIsPlainObject && bIsPlainObject) {
3058
3174
  return keys(b);
3059
- } else {
3060
- const unequalFields = keys(pickBy(a, (value, key) => !deepEquals_default(value, get19(b, key))));
3061
- const diffFields = difference(keys(b), keys(a));
3062
- return [...unequalFields, ...diffFields];
3063
3175
  }
3176
+ const unequalFields = keys(pickBy(a, (value, key) => !deepEquals_default(value, get18(b, key))));
3177
+ const diffFields = difference(keys(b), keys(a));
3178
+ return [...unequalFields, ...diffFields];
3064
3179
  }
3065
3180
 
3066
3181
  // src/getDateElementProps.ts
@@ -3159,7 +3274,7 @@ var DEFAULT_OPTIONS = {
3159
3274
  };
3160
3275
  function getSubmitButtonOptions(uiSchema = {}) {
3161
3276
  const uiOptions = getUiOptions(uiSchema);
3162
- if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {
3277
+ if (uiOptions?.[SUBMIT_BTN_OPTIONS_KEY]) {
3163
3278
  const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
3164
3279
  return { ...DEFAULT_OPTIONS, ...options };
3165
3280
  }
@@ -3184,10 +3299,10 @@ function getTemplate(name, registry, uiOptions = {}) {
3184
3299
  }
3185
3300
 
3186
3301
  // src/getTestIds.ts
3187
- import get20 from "lodash/get";
3302
+ import get19 from "lodash/get";
3188
3303
  import uniqueId from "lodash/uniqueId";
3189
3304
  function getTestIds() {
3190
- if (get20(globalThis, "process.env.NODE_ENV") !== "test") {
3305
+ if (get19(globalThis, "process.env.NODE_ENV") !== "test") {
3191
3306
  return {};
3192
3307
  }
3193
3308
  const ids = /* @__PURE__ */ new Map();
@@ -3206,7 +3321,7 @@ function getTestIds() {
3206
3321
 
3207
3322
  // src/getWidget.tsx
3208
3323
  import { createElement } from "react";
3209
- import get21 from "lodash/get";
3324
+ import get20 from "lodash/get";
3210
3325
  import set4 from "lodash/set";
3211
3326
  import ReactIs from "react-is";
3212
3327
  import { jsx } from "react/jsx-runtime";
@@ -3263,12 +3378,10 @@ var widgetMap = {
3263
3378
  }
3264
3379
  };
3265
3380
  function mergeWidgetOptions(AWidget) {
3266
- let MergedWidget = get21(AWidget, "MergedWidget");
3381
+ let MergedWidget = get20(AWidget, "MergedWidget");
3267
3382
  if (!MergedWidget) {
3268
- const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
3269
- MergedWidget = ({ options, ...props }) => {
3270
- return /* @__PURE__ */ jsx(AWidget, { options: { ...defaultOptions, ...options }, ...props });
3271
- };
3383
+ const defaultOptions = AWidget.defaultProps?.options || {};
3384
+ MergedWidget = ({ options, ...props }) => /* @__PURE__ */ jsx(AWidget, { options: { ...defaultOptions, ...options }, ...props });
3272
3385
  set4(AWidget, "MergedWidget", MergedWidget);
3273
3386
  }
3274
3387
  return MergedWidget;
@@ -3300,23 +3413,26 @@ function getWidget(schema, widget, registeredWidgets = {}) {
3300
3413
  // src/hashForSchema.ts
3301
3414
  function hashString(string) {
3302
3415
  let hash = 0;
3303
- for (let i = 0; i < string.length; i += 1) {
3416
+ for (let i = 0; i < string.length; i++) {
3304
3417
  const chr = string.charCodeAt(i);
3305
3418
  hash = (hash << 5) - hash + chr;
3306
- hash = hash & hash;
3419
+ hash &= hash;
3307
3420
  }
3308
3421
  return hash.toString(16);
3309
3422
  }
3310
3423
  function sortedJSONStringify(object) {
3311
3424
  const allKeys = /* @__PURE__ */ new Set();
3312
- JSON.stringify(object, (key, value) => (allKeys.add(key), value));
3425
+ JSON.stringify(object, (key, value) => {
3426
+ allKeys.add(key);
3427
+ return value;
3428
+ });
3313
3429
  return JSON.stringify(object, Array.from(allKeys).sort());
3314
3430
  }
3315
3431
  function hashObject(object) {
3316
3432
  return hashString(sortedJSONStringify(object));
3317
3433
  }
3318
3434
  function hashForSchema(schema) {
3319
- return hashObject(schema);
3435
+ return hashString(sortedJSONStringify(schema));
3320
3436
  }
3321
3437
 
3322
3438
  // src/hasWidget.ts
@@ -3377,7 +3493,6 @@ function isFormDataAvailable(formData) {
3377
3493
  }
3378
3494
 
3379
3495
  // src/isRootSchema.ts
3380
- import omit2 from "lodash/omit";
3381
3496
  function isRootSchema(registry, schemaToCompare) {
3382
3497
  const { rootSchema, schemaUtils } = registry;
3383
3498
  if (deepEquals_default(schemaToCompare, rootSchema)) {
@@ -3385,7 +3500,7 @@ function isRootSchema(registry, schemaToCompare) {
3385
3500
  }
3386
3501
  if (REF_KEY in rootSchema) {
3387
3502
  const resolvedSchema = schemaUtils.retrieveSchema(rootSchema);
3388
- return deepEquals_default(schemaToCompare, omit2(resolvedSchema, RJSF_REF_KEY));
3503
+ return deepEquals_default(schemaToCompare, resolvedSchema);
3389
3504
  }
3390
3505
  return false;
3391
3506
  }
@@ -3400,15 +3515,24 @@ function localToUTC(dateString) {
3400
3515
  return dateString ? new Date(dateString).toJSON() : void 0;
3401
3516
  }
3402
3517
 
3518
+ // src/logUnsupportedDefaultForEnum.ts
3519
+ function logUnsupportedDefaultForEnum(id, schema, enumOptions, multiple = false) {
3520
+ if (!multiple && Array.isArray(enumOptions) && schema.default !== void 0 && enumOptionsIndexForValue(schema.default, enumOptions, multiple) === void 0) {
3521
+ console.error(
3522
+ `The schema default value "${schema.default}" is not one of the values in the enum options for "${id}"`
3523
+ );
3524
+ }
3525
+ }
3526
+
3403
3527
  // src/lookupFromFormContext.ts
3404
- import get22 from "lodash/get";
3528
+ import get21 from "lodash/get";
3405
3529
  import has6 from "lodash/has";
3406
3530
  function lookupFromFormContext(regOrFc, toLookup, fallback) {
3407
3531
  const lookupPath = [LOOKUP_MAP_NAME];
3408
3532
  if (has6(regOrFc, FORM_CONTEXT_NAME)) {
3409
3533
  lookupPath.unshift(FORM_CONTEXT_NAME);
3410
3534
  }
3411
- return get22(regOrFc, [...lookupPath, toLookup], fallback);
3535
+ return get21(regOrFc, [...lookupPath, toLookup], fallback);
3412
3536
  }
3413
3537
 
3414
3538
  // src/nameGenerators.ts
@@ -3436,9 +3560,9 @@ function orderProperties(properties, order) {
3436
3560
  if (!Array.isArray(order)) {
3437
3561
  return properties;
3438
3562
  }
3439
- const arrayToHash = (arr) => arr.reduce((prev, curr) => {
3440
- prev[curr] = true;
3441
- return prev;
3563
+ const arrayToHash = (arr) => arr.reduce((acc, curr) => {
3564
+ acc[curr] = true;
3565
+ return acc;
3442
3566
  }, {});
3443
3567
  const errorPropList = (arr) => arr.length > 1 ? `properties '${arr.join("', '")}'` : `property '${arr[0]}'`;
3444
3568
  const propertyHash = arrayToHash(properties);
@@ -3474,7 +3598,7 @@ function parseDateString(dateString, includeTime = true) {
3474
3598
  }
3475
3599
  const date = new Date(dateString);
3476
3600
  if (Number.isNaN(date.getTime())) {
3477
- throw new Error("Unable to parse date " + dateString);
3601
+ throw new Error(`Unable to parse date ${dateString}`);
3478
3602
  }
3479
3603
  return {
3480
3604
  year: date.getUTCFullYear(),
@@ -3527,11 +3651,10 @@ function removeOptionalEmptyObjects(validator, schema, rootSchema, formData) {
3527
3651
  const isArr = Array.isArray(value);
3528
3652
  if ((isObj || isArr) && properties[key]) {
3529
3653
  const cleaned = removeOptionalEmptyObjects(validator, propertySchema, rootSchema, value);
3530
- if (!isRequired && isValueEmpty(cleaned)) {
3531
- continue;
3654
+ if (isRequired || !isValueEmpty(cleaned)) {
3655
+ result[key] = cleaned;
3656
+ hasAnyValue = true;
3532
3657
  }
3533
- result[key] = cleaned;
3534
- hasAnyValue = true;
3535
3658
  } else if (isRequired || !isValueEmpty(value) || !properties[key]) {
3536
3659
  result[key] = value;
3537
3660
  if (!isValueEmpty(value)) {
@@ -3571,23 +3694,22 @@ function resolveUiSchema(schema, localUiSchema, registry) {
3571
3694
  }
3572
3695
  for (const keyword of [ONE_OF_KEY, ANY_OF_KEY]) {
3573
3696
  const schemaOptions = resolvedSchema[keyword];
3574
- if (!Array.isArray(schemaOptions) || schemaOptions.length === 0) {
3575
- continue;
3576
- }
3577
- const currentUiSchemaArray = result[keyword];
3578
- const uiSchemaArray = Array.isArray(currentUiSchemaArray) ? [...currentUiSchemaArray] : [];
3579
- let hasExpanded = false;
3580
- for (let i = 0; i < schemaOptions.length; i++) {
3581
- const option = schemaOptions[i];
3582
- const optionRef = option?.[RJSF_REF_KEY] ?? option?.[REF_KEY];
3583
- if (optionRef && optionRef in definitions) {
3584
- const optionUiSchema = uiSchemaArray[i] || {};
3585
- uiSchemaArray[i] = mergeObjects(definitions[optionRef], optionUiSchema);
3586
- hasExpanded = true;
3697
+ if (Array.isArray(schemaOptions) && schemaOptions.length > 0) {
3698
+ const currentUiSchemaArray = result[keyword];
3699
+ const uiSchemaArray = Array.isArray(currentUiSchemaArray) ? [...currentUiSchemaArray] : [];
3700
+ let hasExpanded = false;
3701
+ for (let i = 0; i < schemaOptions.length; i++) {
3702
+ const option = schemaOptions[i];
3703
+ const optionRef = option?.[RJSF_REF_KEY] ?? option?.[REF_KEY];
3704
+ if (optionRef && optionRef in definitions) {
3705
+ const optionUiSchema = uiSchemaArray[i] || {};
3706
+ uiSchemaArray[i] = mergeObjects(definitions[optionRef], optionUiSchema);
3707
+ hasExpanded = true;
3708
+ }
3709
+ }
3710
+ if (hasExpanded) {
3711
+ result[keyword] = uiSchemaArray;
3587
3712
  }
3588
- }
3589
- if (hasExpanded) {
3590
- result[keyword] = uiSchemaArray;
3591
3713
  }
3592
3714
  }
3593
3715
  }
@@ -3599,13 +3721,13 @@ function schemaRequiresTrueValue(schema) {
3599
3721
  if (schema.const) {
3600
3722
  return true;
3601
3723
  }
3602
- if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
3724
+ if (schema.enum?.length === 1 && schema.enum[0] === true) {
3603
3725
  return true;
3604
3726
  }
3605
- if (schema.anyOf && schema.anyOf.length === 1) {
3727
+ if (schema.anyOf?.length === 1) {
3606
3728
  return schemaRequiresTrueValue(schema.anyOf[0]);
3607
3729
  }
3608
- if (schema.oneOf && schema.oneOf.length === 1) {
3730
+ if (schema.oneOf?.length === 1) {
3609
3731
  return schemaRequiresTrueValue(schema.oneOf[0]);
3610
3732
  }
3611
3733
  if (schema.allOf) {
@@ -3615,6 +3737,38 @@ function schemaRequiresTrueValue(schema) {
3615
3737
  return false;
3616
3738
  }
3617
3739
 
3740
+ // src/SelectedOptionDescription.tsx
3741
+ import { jsx as jsx2 } from "react/jsx-runtime";
3742
+ function SelectedOptionDescription({ hideLabel, id, multiple, options, registry, uiSchema, value }) {
3743
+ if (multiple || hideLabel) {
3744
+ return null;
3745
+ }
3746
+ const { label = true } = getUiOptions(uiSchema, registry.globalUiOptions);
3747
+ if (!label) {
3748
+ return null;
3749
+ }
3750
+ const option = options.enumOptions?.find(({ value: enumValue }) => enumOptionsIsSelected(enumValue, value));
3751
+ const description = option?.schema?.description;
3752
+ if (!description) {
3753
+ return null;
3754
+ }
3755
+ const DescriptionFieldTemplate = getTemplate(
3756
+ "DescriptionFieldTemplate",
3757
+ registry,
3758
+ options
3759
+ );
3760
+ return /* @__PURE__ */ jsx2(
3761
+ DescriptionFieldTemplate,
3762
+ {
3763
+ id: descriptionId(id),
3764
+ description,
3765
+ schema: option.schema,
3766
+ uiSchema,
3767
+ registry
3768
+ }
3769
+ );
3770
+ }
3771
+
3618
3772
  // src/shallowEquals.ts
3619
3773
  function shallowEquals(a, b) {
3620
3774
  if (Object.is(a, b)) {
@@ -3631,9 +3785,9 @@ function shallowEquals(a, b) {
3631
3785
  if (keysA.length !== keysB.length) {
3632
3786
  return false;
3633
3787
  }
3634
- for (let i = 0; i < keysA.length; i++) {
3788
+ for (let i = 0; i < keysA.length; i += 1) {
3635
3789
  const key = keysA[i];
3636
- if (!Object.prototype.hasOwnProperty.call(b, key) || !Object.is(a[key], b[key])) {
3790
+ if (!Object.hasOwn(b, key) || !Object.is(a[key], b[key])) {
3637
3791
  return false;
3638
3792
  }
3639
3793
  }
@@ -3702,14 +3856,14 @@ function toErrorList(errorSchema, fieldPath = []) {
3702
3856
  })
3703
3857
  );
3704
3858
  }
3705
- return Object.keys(errorSchema).reduce((acc, key) => {
3859
+ return Object.keys(errorSchema).reduce((currentList, key) => {
3706
3860
  if (key !== ERRORS_KEY) {
3707
3861
  const childSchema = errorSchema[key];
3708
3862
  if (isPlainObject3(childSchema)) {
3709
- acc = acc.concat(toErrorList(childSchema, [...fieldPath, key]));
3863
+ return currentList.concat(toErrorList(childSchema, [...fieldPath, key]));
3710
3864
  }
3711
3865
  }
3712
- return acc;
3866
+ return currentList;
3713
3867
  }, errorList);
3714
3868
  }
3715
3869
 
@@ -3751,22 +3905,21 @@ function unwrapErrorHandler(errorHandler) {
3751
3905
  return Object.keys(errorHandler).reduce((acc, key) => {
3752
3906
  if (key === "addError") {
3753
3907
  return acc;
3754
- } else {
3755
- const childSchema = errorHandler[key];
3756
- if (isPlainObject4(childSchema)) {
3757
- return {
3758
- ...acc,
3759
- [key]: unwrapErrorHandler(childSchema)
3760
- };
3761
- }
3762
- return { ...acc, [key]: childSchema };
3763
3908
  }
3909
+ const childSchema = errorHandler[key];
3910
+ if (isPlainObject4(childSchema)) {
3911
+ return {
3912
+ ...acc,
3913
+ [key]: unwrapErrorHandler(childSchema)
3914
+ };
3915
+ }
3916
+ return { ...acc, [key]: childSchema };
3764
3917
  }, {});
3765
3918
  }
3766
3919
 
3767
3920
  // src/useAltDateWidgetProps.tsx
3768
3921
  import { useCallback, useEffect, useMemo, useState } from "react";
3769
- import { jsx as jsx2 } from "react/jsx-runtime";
3922
+ import { jsx as jsx3 } from "react/jsx-runtime";
3770
3923
  function readyForChange(state) {
3771
3924
  return Object.values(state).every((value) => value !== -1);
3772
3925
  }
@@ -3788,8 +3941,8 @@ function DateElement(props) {
3788
3941
  } = props;
3789
3942
  const id = `${rootId}_${type}`;
3790
3943
  const { SelectWidget } = registry.widgets;
3791
- const onChange = useCallback((value2) => select(type, value2), [select, type]);
3792
- return /* @__PURE__ */ jsx2(
3944
+ const onChange = useCallback((newValue) => select(type, newValue), [select, type]);
3945
+ return /* @__PURE__ */ jsx3(
3793
3946
  SelectWidget,
3794
3947
  {
3795
3948
  schema: { type: "integer" },
@@ -3818,10 +3971,10 @@ function useAltDateWidgetProps(props) {
3818
3971
  setState(parseDateString(value, time));
3819
3972
  }, [time, value]);
3820
3973
  const handleChange = useCallback(
3821
- (property, value2) => {
3974
+ (property, newValue) => {
3822
3975
  const nextState = {
3823
3976
  ...state,
3824
- [property]: typeof value2 === "undefined" ? -1 : value2
3977
+ [property]: typeof newValue === "undefined" ? -1 : newValue
3825
3978
  };
3826
3979
  if (readyForChange(nextState)) {
3827
3980
  onChange(toDateString(nextState, time));
@@ -3879,7 +4032,7 @@ import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
3879
4032
  function addNameToDataURL(dataURL, name) {
3880
4033
  return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
3881
4034
  }
3882
- function processFile(file) {
4035
+ async function processFile(file) {
3883
4036
  const { name, size, type } = file;
3884
4037
  return new Promise((resolve, reject) => {
3885
4038
  const reader = new window.FileReader();
@@ -3904,7 +4057,7 @@ function processFile(file) {
3904
4057
  reader.readAsDataURL(file);
3905
4058
  });
3906
4059
  }
3907
- function processFiles(files) {
4060
+ async function processFiles(files) {
3908
4061
  return Promise.all(Array.from(files).map(processFile));
3909
4062
  }
3910
4063
  function extractFileInfo(dataURLs) {
@@ -4004,22 +4157,21 @@ function validationDataMerge(validationData, additionalErrorSchema, preventDupli
4004
4157
  // src/withIdRefPrefix.ts
4005
4158
  import isObject7 from "lodash/isObject";
4006
4159
  function withIdRefPrefixObject(node) {
4007
- for (const key in node) {
4008
- const realObj = node;
4009
- const value = realObj[key];
4010
- if (key === REF_KEY && typeof value === "string" && value.startsWith("#")) {
4011
- realObj[key] = ROOT_SCHEMA_PREFIX + value;
4012
- } else {
4013
- realObj[key] = withIdRefPrefix(value);
4160
+ const realObj = node;
4161
+ for (const key in realObj) {
4162
+ if (Object.hasOwn(realObj, key)) {
4163
+ const value = realObj[key];
4164
+ if (key === REF_KEY && typeof value === "string" && value.startsWith("#")) {
4165
+ realObj[key] = ROOT_SCHEMA_PREFIX + value;
4166
+ } else {
4167
+ realObj[key] = withIdRefPrefix(value);
4168
+ }
4014
4169
  }
4015
4170
  }
4016
4171
  return node;
4017
4172
  }
4018
4173
  function withIdRefPrefixArray(node) {
4019
- for (let i = 0; i < node.length; i++) {
4020
- node[i] = withIdRefPrefix(node[i]);
4021
- }
4022
- return node;
4174
+ return node.map((item) => withIdRefPrefix(item));
4023
4175
  }
4024
4176
  function withIdRefPrefix(schemaNode) {
4025
4177
  if (Array.isArray(schemaNode)) {
@@ -4044,6 +4196,7 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
4044
4196
  TranslatableString2["AddButton"] = "Add";
4045
4197
  TranslatableString2["AddItemButton"] = "Add Item";
4046
4198
  TranslatableString2["CopyButton"] = "Copy";
4199
+ TranslatableString2["ExpandButton"] = "Expand Cycle";
4047
4200
  TranslatableString2["MoveDownButton"] = "Move down";
4048
4201
  TranslatableString2["MoveUpButton"] = "Move up";
4049
4202
  TranslatableString2["RemoveButton"] = "Remove";
@@ -4064,6 +4217,7 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
4064
4217
  TranslatableString2["TitleOptionPrefix"] = "%1 option %2";
4065
4218
  TranslatableString2["KeyLabel"] = "%1 Key";
4066
4219
  TranslatableString2["DeprecatedLabel"] = "%1 (deprecated)";
4220
+ TranslatableString2["CycleDetected"] = 'Circular reference ($ref cycle) detected for field "%1". You may choose to expand to the next cycle break';
4067
4221
  TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration: _%2_.';
4068
4222
  TranslatableString2["UnsupportedField"] = "Unsupported field schema.";
4069
4223
  TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
@@ -4077,7 +4231,7 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
4077
4231
  import forEach from "lodash/forEach";
4078
4232
 
4079
4233
  // src/parser/ParserValidator.ts
4080
- import get23 from "lodash/get";
4234
+ import get22 from "lodash/get";
4081
4235
  var ParserValidator = class {
4082
4236
  /** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`
4083
4237
  * first.
@@ -4103,7 +4257,7 @@ var ParserValidator = class {
4103
4257
  * @param hash - The hash value at which to map the schema
4104
4258
  */
4105
4259
  addSchema(schema, hash) {
4106
- const key = get23(schema, ID_KEY, hash);
4260
+ const key = get22(schema, ID_KEY, hash);
4107
4261
  const identifiedSchema = { ...schema, [ID_KEY]: key };
4108
4262
  const existing = this.schemaMap[key];
4109
4263
  if (!existing) {
@@ -4169,20 +4323,20 @@ var ParserValidator = class {
4169
4323
  // src/parser/schemaParser.ts
4170
4324
  function parseSchema(validator, recurseList, rootSchema, schema) {
4171
4325
  const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
4172
- schemas.forEach((schema2) => {
4173
- const sameSchemaIndex = recurseList.findIndex((item) => deepEquals_default(item, schema2));
4326
+ schemas.forEach((localSchema) => {
4327
+ const sameSchemaIndex = recurseList.findIndex((item) => deepEquals_default(item, localSchema));
4174
4328
  if (sameSchemaIndex === -1) {
4175
- recurseList.push(schema2);
4176
- const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
4329
+ recurseList.push(localSchema);
4330
+ const allOptions = resolveAnyOrOneOfSchemas(validator, localSchema, rootSchema, true);
4177
4331
  allOptions.forEach((s) => {
4178
4332
  if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {
4179
- forEach(schema2[PROPERTIES_KEY], (value) => {
4333
+ forEach(localSchema[PROPERTIES_KEY], (value) => {
4180
4334
  parseSchema(validator, recurseList, rootSchema, value);
4181
4335
  });
4182
4336
  }
4183
4337
  });
4184
- if (ITEMS_KEY in schema2 && !Array.isArray(schema2.items) && typeof schema2.items !== "boolean") {
4185
- parseSchema(validator, recurseList, rootSchema, schema2.items);
4338
+ if (ITEMS_KEY in localSchema && !Array.isArray(localSchema.items) && typeof localSchema.items !== "boolean") {
4339
+ parseSchema(validator, recurseList, rootSchema, localSchema.items);
4186
4340
  }
4187
4341
  }
4188
4342
  });
@@ -4225,10 +4379,13 @@ export {
4225
4379
  REF_KEY,
4226
4380
  REQUIRED_KEY,
4227
4381
  RJSF_ADDITIONAL_PROPERTIES_FLAG,
4382
+ RJSF_PREFIX_KEY,
4383
+ RJSF_REF_CYCLE_KEY,
4228
4384
  RJSF_REF_KEY,
4229
4385
  ROOT_SCHEMA_PREFIX,
4230
4386
  SCHEMA_KEY,
4231
4387
  SUBMIT_BTN_OPTIONS_KEY,
4388
+ SelectedOptionDescription,
4232
4389
  TranslatableString,
4233
4390
  UI_DEFINITIONS_KEY,
4234
4391
  UI_FIELD_KEY,
@@ -4299,6 +4456,7 @@ export {
4299
4456
  isValueEmpty,
4300
4457
  labelValue,
4301
4458
  localToUTC,
4459
+ logUnsupportedDefaultForEnum,
4302
4460
  lookupFromFormContext,
4303
4461
  mergeDefaultsWithFormData,
4304
4462
  mergeObjects,