@rjsf/utils 6.7.1 → 6.10.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 (477) hide show
  1. package/dist/index.cjs +521 -425
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/utils.esm.js +520 -424
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +579 -333
  6. package/lib/ErrorSchemaBuilder.d.ts +8 -7
  7. package/lib/ErrorSchemaBuilder.d.ts.map +1 -0
  8. package/lib/ErrorSchemaBuilder.js +29 -27
  9. package/lib/ErrorSchemaBuilder.js.map +1 -1
  10. package/lib/SelectedOptionDescription.d.ts +2 -1
  11. package/lib/SelectedOptionDescription.d.ts.map +1 -0
  12. package/lib/SelectedOptionDescription.js +6 -7
  13. package/lib/SelectedOptionDescription.js.map +1 -1
  14. package/lib/allowAdditionalItems.d.ts +2 -1
  15. package/lib/allowAdditionalItems.d.ts.map +1 -0
  16. package/lib/allowAdditionalItems.js +1 -1
  17. package/lib/allowAdditionalItems.js.map +1 -1
  18. package/lib/asNumber.d.ts +1 -0
  19. package/lib/asNumber.d.ts.map +1 -0
  20. package/lib/asNumber.js +1 -1
  21. package/lib/asNumber.js.map +1 -1
  22. package/lib/canExpand.d.ts +2 -1
  23. package/lib/canExpand.d.ts.map +1 -0
  24. package/lib/canExpand.js +1 -1
  25. package/lib/canExpand.js.map +1 -1
  26. package/lib/constIsAjvDataReference.d.ts +2 -1
  27. package/lib/constIsAjvDataReference.d.ts.map +1 -0
  28. package/lib/constIsAjvDataReference.js +2 -3
  29. package/lib/constIsAjvDataReference.js.map +1 -1
  30. package/lib/constants.d.ts +1 -0
  31. package/lib/constants.d.ts.map +1 -0
  32. package/lib/createErrorHandler.d.ts +2 -1
  33. package/lib/createErrorHandler.d.ts.map +1 -0
  34. package/lib/createErrorHandler.js +3 -4
  35. package/lib/createErrorHandler.js.map +1 -1
  36. package/lib/createSchemaUtils.d.ts +2 -1
  37. package/lib/createSchemaUtils.d.ts.map +1 -0
  38. package/lib/createSchemaUtils.js +10 -7
  39. package/lib/createSchemaUtils.js.map +1 -1
  40. package/lib/dataURItoBlob.d.ts +1 -0
  41. package/lib/dataURItoBlob.d.ts.map +1 -0
  42. package/lib/dataURItoBlob.js +1 -2
  43. package/lib/dataURItoBlob.js.map +1 -1
  44. package/lib/dateRangeOptions.d.ts +2 -1
  45. package/lib/dateRangeOptions.d.ts.map +1 -0
  46. package/lib/dateRangeOptions.js +1 -1
  47. package/lib/dateRangeOptions.js.map +1 -1
  48. package/lib/deepEquals.d.ts +1 -0
  49. package/lib/deepEquals.d.ts.map +1 -0
  50. package/lib/englishStringTranslator.d.ts +2 -1
  51. package/lib/englishStringTranslator.d.ts.map +1 -0
  52. package/lib/englishStringTranslator.js +1 -1
  53. package/lib/englishStringTranslator.js.map +1 -1
  54. package/lib/enumOptionSelectedValue.d.ts +2 -1
  55. package/lib/enumOptionSelectedValue.d.ts.map +1 -0
  56. package/lib/enumOptionSelectedValue.js +1 -1
  57. package/lib/enumOptionSelectedValue.js.map +1 -1
  58. package/lib/enumOptionValueDecoder.d.ts +2 -1
  59. package/lib/enumOptionValueDecoder.d.ts.map +1 -0
  60. package/lib/enumOptionValueDecoder.js +1 -1
  61. package/lib/enumOptionValueDecoder.js.map +1 -1
  62. package/lib/enumOptionValueEncoder.d.ts +2 -1
  63. package/lib/enumOptionValueEncoder.d.ts.map +1 -0
  64. package/lib/enumOptionValueEncoder.js +1 -2
  65. package/lib/enumOptionValueEncoder.js.map +1 -1
  66. package/lib/enumOptionsDeselectValue.d.ts +2 -1
  67. package/lib/enumOptionsDeselectValue.d.ts.map +1 -0
  68. package/lib/enumOptionsDeselectValue.js +2 -2
  69. package/lib/enumOptionsDeselectValue.js.map +1 -1
  70. package/lib/enumOptionsIndexForValue.d.ts +2 -1
  71. package/lib/enumOptionsIndexForValue.d.ts.map +1 -0
  72. package/lib/enumOptionsIndexForValue.js +1 -1
  73. package/lib/enumOptionsIndexForValue.js.map +1 -1
  74. package/lib/enumOptionsIsSelected.d.ts +2 -1
  75. package/lib/enumOptionsIsSelected.d.ts.map +1 -0
  76. package/lib/enumOptionsIsSelected.js +1 -1
  77. package/lib/enumOptionsIsSelected.js.map +1 -1
  78. package/lib/enumOptionsSelectValue.d.ts +2 -1
  79. package/lib/enumOptionsSelectValue.d.ts.map +1 -0
  80. package/lib/enumOptionsSelectValue.js +2 -3
  81. package/lib/enumOptionsSelectValue.js.map +1 -1
  82. package/lib/enumOptionsValueForIndex.d.ts +2 -1
  83. package/lib/enumOptionsValueForIndex.d.ts.map +1 -0
  84. package/lib/enums.d.ts +1 -0
  85. package/lib/enums.d.ts.map +1 -0
  86. package/lib/findSchemaDefinition.d.ts +2 -1
  87. package/lib/findSchemaDefinition.d.ts.map +1 -0
  88. package/lib/findSchemaDefinition.js +7 -11
  89. package/lib/findSchemaDefinition.js.map +1 -1
  90. package/lib/getChangedFields.d.ts +11 -2
  91. package/lib/getChangedFields.d.ts.map +1 -0
  92. package/lib/getChangedFields.js +57 -18
  93. package/lib/getChangedFields.js.map +1 -1
  94. package/lib/getDateElementProps.d.ts +2 -1
  95. package/lib/getDateElementProps.d.ts.map +1 -0
  96. package/lib/getDecimalSeparator.d.ts +1 -0
  97. package/lib/getDecimalSeparator.d.ts.map +1 -0
  98. package/lib/getDecimalSeparator.js +1 -2
  99. package/lib/getDecimalSeparator.js.map +1 -1
  100. package/lib/getDiscriminatorFieldFromSchema.d.ts +2 -1
  101. package/lib/getDiscriminatorFieldFromSchema.d.ts.map +1 -0
  102. package/lib/getDiscriminatorFieldFromSchema.js +4 -5
  103. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  104. package/lib/getInputProps.d.ts +2 -1
  105. package/lib/getInputProps.d.ts.map +1 -0
  106. package/lib/getInputProps.js +4 -1
  107. package/lib/getInputProps.js.map +1 -1
  108. package/lib/getOptionMatchingSimpleDiscriminator.d.ts +2 -1
  109. package/lib/getOptionMatchingSimpleDiscriminator.d.ts.map +1 -0
  110. package/lib/getOptionMatchingSimpleDiscriminator.js +6 -6
  111. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  112. package/lib/getOptionValueFormat.d.ts +2 -1
  113. package/lib/getOptionValueFormat.d.ts.map +1 -0
  114. package/lib/getOptionValueFormat.js +1 -2
  115. package/lib/getOptionValueFormat.js.map +1 -1
  116. package/lib/getPropertySchema.d.ts +12 -0
  117. package/lib/getPropertySchema.d.ts.map +1 -0
  118. package/lib/getPropertySchema.js +14 -0
  119. package/lib/getPropertySchema.js.map +1 -0
  120. package/lib/getSchemaType.d.ts +2 -1
  121. package/lib/getSchemaType.d.ts.map +1 -0
  122. package/lib/getSchemaType.js +1 -1
  123. package/lib/getSchemaType.js.map +1 -1
  124. package/lib/getSubmitButtonOptions.d.ts +2 -1
  125. package/lib/getSubmitButtonOptions.d.ts.map +1 -0
  126. package/lib/getSubmitButtonOptions.js +3 -3
  127. package/lib/getSubmitButtonOptions.js.map +1 -1
  128. package/lib/getTemplate.d.ts +2 -1
  129. package/lib/getTemplate.d.ts.map +1 -0
  130. package/lib/getTestIds.d.ts +2 -1
  131. package/lib/getTestIds.d.ts.map +1 -0
  132. package/lib/getTestIds.js +6 -5
  133. package/lib/getTestIds.js.map +1 -1
  134. package/lib/getUiOptions.d.ts +2 -1
  135. package/lib/getUiOptions.d.ts.map +1 -0
  136. package/lib/getUiOptions.js +2 -2
  137. package/lib/getUiOptions.js.map +1 -1
  138. package/lib/getWidget.d.ts +2 -1
  139. package/lib/getWidget.d.ts.map +1 -0
  140. package/lib/getWidget.js +6 -7
  141. package/lib/getWidget.js.map +1 -1
  142. package/lib/guessType.d.ts +2 -1
  143. package/lib/guessType.d.ts.map +1 -0
  144. package/lib/hasWidget.d.ts +2 -1
  145. package/lib/hasWidget.d.ts.map +1 -0
  146. package/lib/hasWidget.js +1 -1
  147. package/lib/hasWidget.js.map +1 -1
  148. package/lib/hashForSchema.d.ts +4 -2
  149. package/lib/hashForSchema.d.ts.map +1 -0
  150. package/lib/hashForSchema.js +17 -8
  151. package/lib/hashForSchema.js.map +1 -1
  152. package/lib/idGenerators.d.ts +2 -1
  153. package/lib/idGenerators.d.ts.map +1 -0
  154. package/lib/idGenerators.js +2 -3
  155. package/lib/idGenerators.js.map +1 -1
  156. package/lib/index.d.ts +93 -87
  157. package/lib/index.d.ts.map +1 -0
  158. package/lib/index.js +85 -81
  159. package/lib/index.js.map +1 -1
  160. package/lib/isConstant.d.ts +2 -1
  161. package/lib/isConstant.d.ts.map +1 -0
  162. package/lib/isConstant.js +1 -1
  163. package/lib/isConstant.js.map +1 -1
  164. package/lib/isCustomWidget.d.ts +2 -1
  165. package/lib/isCustomWidget.d.ts.map +1 -0
  166. package/lib/isCustomWidget.js +1 -1
  167. package/lib/isCustomWidget.js.map +1 -1
  168. package/lib/isFixedItems.d.ts +2 -1
  169. package/lib/isFixedItems.d.ts.map +1 -0
  170. package/lib/isFixedItems.js +1 -1
  171. package/lib/isFixedItems.js.map +1 -1
  172. package/lib/isFormDataAvailable.d.ts +1 -0
  173. package/lib/isFormDataAvailable.d.ts.map +1 -0
  174. package/lib/isFormDataAvailable.js +7 -4
  175. package/lib/isFormDataAvailable.js.map +1 -1
  176. package/lib/isObject.d.ts +3 -1
  177. package/lib/isObject.d.ts.map +1 -0
  178. package/lib/isObject.js +8 -2
  179. package/lib/isObject.js.map +1 -1
  180. package/lib/isPlainObject.d.ts +9 -0
  181. package/lib/isPlainObject.d.ts.map +1 -0
  182. package/lib/isPlainObject.js +15 -0
  183. package/lib/isPlainObject.js.map +1 -0
  184. package/lib/isRootSchema.d.ts +2 -1
  185. package/lib/isRootSchema.d.ts.map +1 -0
  186. package/lib/isRootSchema.js +2 -2
  187. package/lib/isRootSchema.js.map +1 -1
  188. package/lib/jsonSchemaAugmentation.d.ts +1 -0
  189. package/lib/jsonSchemaAugmentation.d.ts.map +1 -0
  190. package/lib/labelValue.d.ts +1 -0
  191. package/lib/labelValue.d.ts.map +1 -0
  192. package/lib/localToUTC.d.ts +1 -0
  193. package/lib/localToUTC.d.ts.map +1 -0
  194. package/lib/logUnsupportedDefaultForEnum.d.ts +2 -1
  195. package/lib/logUnsupportedDefaultForEnum.d.ts.map +1 -0
  196. package/lib/logUnsupportedDefaultForEnum.js +1 -1
  197. package/lib/logUnsupportedDefaultForEnum.js.map +1 -1
  198. package/lib/lookupFromFormContext.d.ts +3 -2
  199. package/lib/lookupFromFormContext.d.ts.map +1 -0
  200. package/lib/lookupFromFormContext.js +4 -5
  201. package/lib/lookupFromFormContext.js.map +1 -1
  202. package/lib/mergeDefaultsWithFormData.d.ts +1 -0
  203. package/lib/mergeDefaultsWithFormData.d.ts.map +1 -0
  204. package/lib/mergeDefaultsWithFormData.js +20 -16
  205. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  206. package/lib/mergeObjects.d.ts +2 -1
  207. package/lib/mergeObjects.d.ts.map +1 -0
  208. package/lib/mergeObjects.js +1 -1
  209. package/lib/mergeObjects.js.map +1 -1
  210. package/lib/mergeSchemas.d.ts +2 -1
  211. package/lib/mergeSchemas.d.ts.map +1 -0
  212. package/lib/mergeSchemas.js +4 -5
  213. package/lib/mergeSchemas.js.map +1 -1
  214. package/lib/nameGenerators.d.ts +2 -1
  215. package/lib/nameGenerators.d.ts.map +1 -0
  216. package/lib/noop.d.ts +5 -0
  217. package/lib/noop.d.ts.map +1 -0
  218. package/lib/noop.js +5 -0
  219. package/lib/noop.js.map +1 -0
  220. package/lib/optionsList.d.ts +2 -1
  221. package/lib/optionsList.d.ts.map +1 -0
  222. package/lib/optionsList.js +15 -15
  223. package/lib/optionsList.js.map +1 -1
  224. package/lib/orderProperties.d.ts +1 -0
  225. package/lib/orderProperties.d.ts.map +1 -0
  226. package/lib/pad.d.ts +1 -0
  227. package/lib/pad.d.ts.map +1 -0
  228. package/lib/parseDateString.d.ts +2 -1
  229. package/lib/parseDateString.d.ts.map +1 -0
  230. package/lib/parser/ParserValidator.d.ts +2 -1
  231. package/lib/parser/ParserValidator.d.ts.map +1 -0
  232. package/lib/parser/ParserValidator.js +8 -7
  233. package/lib/parser/ParserValidator.js.map +1 -1
  234. package/lib/parser/index.d.ts +3 -2
  235. package/lib/parser/index.d.ts.map +1 -0
  236. package/lib/parser/index.js +1 -1
  237. package/lib/parser/index.js.map +1 -1
  238. package/lib/parser/schemaParser.d.ts +3 -2
  239. package/lib/parser/schemaParser.d.ts.map +1 -0
  240. package/lib/parser/schemaParser.js +6 -7
  241. package/lib/parser/schemaParser.js.map +1 -1
  242. package/lib/pathUtils.d.ts +77 -0
  243. package/lib/pathUtils.d.ts.map +1 -0
  244. package/lib/pathUtils.js +192 -0
  245. package/lib/pathUtils.js.map +1 -0
  246. package/lib/rangeSpec.d.ts +2 -1
  247. package/lib/rangeSpec.d.ts.map +1 -0
  248. package/lib/removeOptionalEmptyObjects.d.ts +2 -1
  249. package/lib/removeOptionalEmptyObjects.d.ts.map +1 -0
  250. package/lib/removeOptionalEmptyObjects.js +2 -2
  251. package/lib/removeOptionalEmptyObjects.js.map +1 -1
  252. package/lib/replaceStringParameters.d.ts +1 -0
  253. package/lib/replaceStringParameters.d.ts.map +1 -0
  254. package/lib/resolveUiSchema.d.ts +2 -1
  255. package/lib/resolveUiSchema.d.ts.map +1 -0
  256. package/lib/resolveUiSchema.js +6 -8
  257. package/lib/resolveUiSchema.js.map +1 -1
  258. package/lib/schema/findFieldInSchema.d.ts +2 -1
  259. package/lib/schema/findFieldInSchema.d.ts.map +1 -0
  260. package/lib/schema/findFieldInSchema.js +10 -11
  261. package/lib/schema/findFieldInSchema.js.map +1 -1
  262. package/lib/schema/findSelectedOptionInXxxOf.d.ts +2 -1
  263. package/lib/schema/findSelectedOptionInXxxOf.d.ts.map +1 -0
  264. package/lib/schema/findSelectedOptionInXxxOf.js +7 -7
  265. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
  266. package/lib/schema/getClosestMatchingOption.d.ts +2 -1
  267. package/lib/schema/getClosestMatchingOption.d.ts.map +1 -0
  268. package/lib/schema/getClosestMatchingOption.js +18 -23
  269. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  270. package/lib/schema/getDefaultFormState.d.ts +2 -1
  271. package/lib/schema/getDefaultFormState.d.ts.map +1 -0
  272. package/lib/schema/getDefaultFormState.js +78 -56
  273. package/lib/schema/getDefaultFormState.js.map +1 -1
  274. package/lib/schema/getDisplayLabel.d.ts +2 -1
  275. package/lib/schema/getDisplayLabel.d.ts.map +1 -0
  276. package/lib/schema/getDisplayLabel.js +7 -7
  277. package/lib/schema/getDisplayLabel.js.map +1 -1
  278. package/lib/schema/getFirstMatchingOption.d.ts +2 -1
  279. package/lib/schema/getFirstMatchingOption.d.ts.map +1 -0
  280. package/lib/schema/getFirstMatchingOption.js +9 -9
  281. package/lib/schema/getFirstMatchingOption.js.map +1 -1
  282. package/lib/schema/getFromSchema.d.ts +3 -2
  283. package/lib/schema/getFromSchema.d.ts.map +1 -0
  284. package/lib/schema/getFromSchema.js +10 -11
  285. package/lib/schema/getFromSchema.js.map +1 -1
  286. package/lib/schema/index.d.ts +15 -14
  287. package/lib/schema/index.d.ts.map +1 -0
  288. package/lib/schema/index.js +14 -14
  289. package/lib/schema/index.js.map +1 -1
  290. package/lib/schema/isFilesArray.d.ts +2 -1
  291. package/lib/schema/isFilesArray.d.ts.map +1 -0
  292. package/lib/schema/isFilesArray.js +2 -2
  293. package/lib/schema/isFilesArray.js.map +1 -1
  294. package/lib/schema/isMultiSelect.d.ts +2 -1
  295. package/lib/schema/isMultiSelect.d.ts.map +1 -0
  296. package/lib/schema/isMultiSelect.js +1 -1
  297. package/lib/schema/isMultiSelect.js.map +1 -1
  298. package/lib/schema/isSelect.d.ts +2 -1
  299. package/lib/schema/isSelect.d.ts.map +1 -0
  300. package/lib/schema/isSelect.js +2 -2
  301. package/lib/schema/isSelect.js.map +1 -1
  302. package/lib/schema/omitExtraData.d.ts +2 -1
  303. package/lib/schema/omitExtraData.d.ts.map +1 -0
  304. package/lib/schema/omitExtraData.js +100 -64
  305. package/lib/schema/omitExtraData.js.map +1 -1
  306. package/lib/schema/retrieveSchema.d.ts +2 -1
  307. package/lib/schema/retrieveSchema.d.ts.map +1 -0
  308. package/lib/schema/retrieveSchema.js +32 -40
  309. package/lib/schema/retrieveSchema.js.map +1 -1
  310. package/lib/schema/sanitizeDataForNewSchema.d.ts +4 -3
  311. package/lib/schema/sanitizeDataForNewSchema.d.ts.map +1 -0
  312. package/lib/schema/sanitizeDataForNewSchema.js +41 -39
  313. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  314. package/lib/schema/shallowAllOfMerge.d.ts +1 -0
  315. package/lib/schema/shallowAllOfMerge.d.ts.map +1 -0
  316. package/lib/schema/toPathSchema.d.ts +2 -1
  317. package/lib/schema/toPathSchema.d.ts.map +1 -0
  318. package/lib/schema/toPathSchema.js +14 -14
  319. package/lib/schema/toPathSchema.js.map +1 -1
  320. package/lib/schemaRequiresTrueValue.d.ts +2 -1
  321. package/lib/schemaRequiresTrueValue.d.ts.map +1 -0
  322. package/lib/schemaRequiresTrueValue.js +3 -4
  323. package/lib/schemaRequiresTrueValue.js.map +1 -1
  324. package/lib/shallowEquals.d.ts +1 -0
  325. package/lib/shallowEquals.d.ts.map +1 -0
  326. package/lib/shouldRender.d.ts +2 -1
  327. package/lib/shouldRender.d.ts.map +1 -0
  328. package/lib/shouldRender.js +2 -2
  329. package/lib/shouldRender.js.map +1 -1
  330. package/lib/shouldRenderOptionalField.d.ts +2 -1
  331. package/lib/shouldRenderOptionalField.d.ts.map +1 -0
  332. package/lib/shouldRenderOptionalField.js +11 -10
  333. package/lib/shouldRenderOptionalField.js.map +1 -1
  334. package/lib/toConstant.d.ts +2 -1
  335. package/lib/toConstant.d.ts.map +1 -0
  336. package/lib/toConstant.js +1 -1
  337. package/lib/toConstant.js.map +1 -1
  338. package/lib/toDateString.d.ts +2 -1
  339. package/lib/toDateString.d.ts.map +1 -0
  340. package/lib/toErrorList.d.ts +2 -1
  341. package/lib/toErrorList.d.ts.map +1 -0
  342. package/lib/toErrorList.js +20 -21
  343. package/lib/toErrorList.js.map +1 -1
  344. package/lib/toErrorSchema.d.ts +2 -1
  345. package/lib/toErrorSchema.d.ts.map +1 -0
  346. package/lib/toErrorSchema.js +4 -9
  347. package/lib/toErrorSchema.js.map +1 -1
  348. package/lib/toFieldPathId.d.ts +2 -1
  349. package/lib/toFieldPathId.d.ts.map +1 -0
  350. package/lib/toFieldPathId.js +2 -2
  351. package/lib/toFieldPathId.js.map +1 -1
  352. package/lib/types.d.ts +15 -5
  353. package/lib/types.d.ts.map +1 -0
  354. package/lib/types.js +1 -1
  355. package/lib/types.js.map +1 -1
  356. package/lib/unwrapErrorHandler.d.ts +2 -1
  357. package/lib/unwrapErrorHandler.d.ts.map +1 -0
  358. package/lib/unwrapErrorHandler.js +13 -4
  359. package/lib/unwrapErrorHandler.js.map +1 -1
  360. package/lib/useAltDateWidgetProps.d.ts +3 -2
  361. package/lib/useAltDateWidgetProps.d.ts.map +1 -0
  362. package/lib/useAltDateWidgetProps.js +5 -5
  363. package/lib/useAltDateWidgetProps.js.map +1 -1
  364. package/lib/useDeepCompareMemo.d.ts +1 -0
  365. package/lib/useDeepCompareMemo.d.ts.map +1 -0
  366. package/lib/useDeepCompareMemo.js +1 -1
  367. package/lib/useDeepCompareMemo.js.map +1 -1
  368. package/lib/useFileWidgetProps.d.ts +1 -0
  369. package/lib/useFileWidgetProps.d.ts.map +1 -0
  370. package/lib/useFileWidgetProps.js +3 -4
  371. package/lib/useFileWidgetProps.js.map +1 -1
  372. package/lib/utcToLocal.d.ts +1 -0
  373. package/lib/utcToLocal.d.ts.map +1 -0
  374. package/lib/utcToLocal.js +1 -1
  375. package/lib/utcToLocal.js.map +1 -1
  376. package/lib/validationDataMerge.d.ts +2 -1
  377. package/lib/validationDataMerge.d.ts.map +1 -0
  378. package/lib/validationDataMerge.js +3 -4
  379. package/lib/validationDataMerge.js.map +1 -1
  380. package/lib/withIdRefPrefix.d.ts +2 -1
  381. package/lib/withIdRefPrefix.d.ts.map +1 -0
  382. package/lib/withIdRefPrefix.js +2 -2
  383. package/lib/withIdRefPrefix.js.map +1 -1
  384. package/package.json +5 -6
  385. package/src/ErrorSchemaBuilder.ts +25 -24
  386. package/src/SelectedOptionDescription.tsx +5 -5
  387. package/src/allowAdditionalItems.ts +2 -2
  388. package/src/asNumber.ts +1 -1
  389. package/src/canExpand.ts +2 -2
  390. package/src/constIsAjvDataReference.ts +5 -4
  391. package/src/createErrorHandler.ts +5 -7
  392. package/src/createSchemaUtils.ts +8 -10
  393. package/src/dateRangeOptions.ts +2 -2
  394. package/src/englishStringTranslator.ts +2 -2
  395. package/src/enumOptionSelectedValue.ts +2 -2
  396. package/src/enumOptionValueDecoder.ts +2 -2
  397. package/src/enumOptionValueEncoder.ts +2 -4
  398. package/src/enumOptionsDeselectValue.ts +3 -3
  399. package/src/enumOptionsIndexForValue.ts +2 -2
  400. package/src/enumOptionsIsSelected.ts +2 -2
  401. package/src/enumOptionsSelectValue.ts +3 -5
  402. package/src/enumOptionsValueForIndex.ts +1 -1
  403. package/src/findSchemaDefinition.ts +8 -12
  404. package/src/getChangedFields.ts +57 -18
  405. package/src/getDateElementProps.ts +1 -1
  406. package/src/getDiscriminatorFieldFromSchema.ts +5 -7
  407. package/src/getInputProps.ts +6 -2
  408. package/src/getOptionMatchingSimpleDiscriminator.ts +7 -7
  409. package/src/getOptionValueFormat.ts +1 -1
  410. package/src/getPropertySchema.ts +18 -0
  411. package/src/getSchemaType.ts +2 -2
  412. package/src/getSubmitButtonOptions.ts +3 -3
  413. package/src/getTemplate.ts +1 -1
  414. package/src/getTestIds.ts +7 -6
  415. package/src/getUiOptions.ts +3 -3
  416. package/src/getWidget.tsx +6 -6
  417. package/src/hasWidget.ts +2 -2
  418. package/src/hashForSchema.ts +20 -9
  419. package/src/idGenerators.ts +3 -5
  420. package/src/index.ts +99 -85
  421. package/src/isConstant.ts +2 -2
  422. package/src/isCustomWidget.ts +2 -2
  423. package/src/isFixedItems.ts +2 -2
  424. package/src/isFormDataAvailable.ts +7 -5
  425. package/src/isObject.ts +15 -3
  426. package/src/isPlainObject.ts +14 -0
  427. package/src/isRootSchema.ts +3 -3
  428. package/src/logUnsupportedDefaultForEnum.ts +2 -2
  429. package/src/lookupFromFormContext.ts +7 -8
  430. package/src/mergeDefaultsWithFormData.ts +22 -18
  431. package/src/mergeObjects.ts +2 -2
  432. package/src/mergeSchemas.ts +5 -7
  433. package/src/nameGenerators.ts +1 -1
  434. package/src/noop.ts +4 -0
  435. package/src/optionsList.ts +9 -9
  436. package/src/orderProperties.ts +1 -1
  437. package/src/parseDateString.ts +1 -1
  438. package/src/parser/ParserValidator.ts +5 -7
  439. package/src/parser/index.ts +2 -2
  440. package/src/parser/schemaParser.ts +8 -10
  441. package/src/pathUtils.ts +203 -0
  442. package/src/rangeSpec.ts +1 -1
  443. package/src/removeOptionalEmptyObjects.ts +3 -3
  444. package/src/resolveUiSchema.ts +5 -7
  445. package/src/schema/findFieldInSchema.ts +11 -13
  446. package/src/schema/findSelectedOptionInXxxOf.ts +9 -10
  447. package/src/schema/getClosestMatchingOption.ts +73 -83
  448. package/src/schema/getDefaultFormState.ts +62 -34
  449. package/src/schema/getDisplayLabel.ts +7 -7
  450. package/src/schema/getFirstMatchingOption.ts +10 -11
  451. package/src/schema/getFromSchema.ts +12 -14
  452. package/src/schema/index.ts +14 -14
  453. package/src/schema/isFilesArray.ts +3 -3
  454. package/src/schema/isMultiSelect.ts +2 -2
  455. package/src/schema/isSelect.ts +3 -3
  456. package/src/schema/omitExtraData.ts +104 -68
  457. package/src/schema/retrieveSchema.ts +47 -60
  458. package/src/schema/sanitizeDataForNewSchema.ts +42 -41
  459. package/src/schema/toPathSchema.ts +14 -14
  460. package/src/schemaRequiresTrueValue.ts +1 -1
  461. package/src/shouldRender.ts +3 -3
  462. package/src/shouldRenderOptionalField.ts +14 -14
  463. package/src/toConstant.ts +2 -2
  464. package/src/toDateString.ts +1 -1
  465. package/src/toErrorList.ts +22 -25
  466. package/src/toErrorSchema.ts +5 -11
  467. package/src/toFieldPathId.ts +2 -2
  468. package/src/types.ts +14 -5
  469. package/src/unwrapErrorHandler.ts +15 -6
  470. package/src/useAltDateWidgetProps.tsx +7 -7
  471. package/src/useDeepCompareMemo.ts +1 -1
  472. package/src/useFileWidgetProps.ts +1 -1
  473. package/src/utcToLocal.ts +1 -1
  474. package/src/validationDataMerge.ts +4 -6
  475. package/src/withIdRefPrefix.ts +3 -4
  476. package/lib/tsconfig.tsbuildinfo +0 -1
  477. package/src/tsconfig.json +0 -9
@@ -1,13 +1,9 @@
1
- import get from 'lodash/get';
2
- import isEmpty from 'lodash/isEmpty';
3
- import isNil from 'lodash/isNil';
4
- import pick from 'lodash/pick';
5
-
6
- import { NAME_KEY, RJSF_ADDITIONAL_PROPERTIES_FLAG } from '../constants';
7
- import findSchemaDefinition from '../findSchemaDefinition';
8
- import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
9
- import getSchemaType from '../getSchemaType';
10
- import isObject from '../isObject';
1
+ import { NAME_KEY, RJSF_ADDITIONAL_PROPERTIES_FLAG } from '../constants.ts';
2
+ import findSchemaDefinition from '../findSchemaDefinition.ts';
3
+ import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema.ts';
4
+ import getSchemaType from '../getSchemaType.ts';
5
+ import isObject from '../isObject.ts';
6
+ import { getByPath, hasByPath, setByPath, toPath } from '../pathUtils.ts';
11
7
  import type {
12
8
  Experimental_CustomMergeAllOf,
13
9
  FormContextType,
@@ -16,11 +12,11 @@ import type {
16
12
  RJSFSchema,
17
13
  StrictRJSFSchema,
18
14
  ValidatorType,
19
- } from '../types';
20
- import getClosestMatchingOption from './getClosestMatchingOption';
21
- import isSelect from './isSelect';
22
- import { relaxOptionsForScoring, resolveAllReferences } from './retrieveSchema';
23
- import shallowAllOfMerge from './shallowAllOfMerge';
15
+ } from '../types.ts';
16
+ import getClosestMatchingOption from './getClosestMatchingOption.ts';
17
+ import isSelect from './isSelect.ts';
18
+ import { relaxOptionsForScoring, resolveAllReferences } from './retrieveSchema.ts';
19
+ import shallowAllOfMerge from './shallowAllOfMerge.ts';
24
20
 
25
21
  /** Returns the `formData` with only the elements specified in the `fields` list
26
22
  *
@@ -34,7 +30,15 @@ export function getUsedFormData<T = any>(formData: T | undefined, fields: string
34
30
  return formData;
35
31
  }
36
32
 
37
- const data: GenericObjectType = pick(formData, fields);
33
+ // Keep only the values at the given field paths; `fields` contains either dotted strings or the
34
+ // deep path lists produced by `getFieldNames()`
35
+ const data: GenericObjectType = {};
36
+ fields.forEach((field) => {
37
+ const path = Array.isArray(field) ? field : toPath(field);
38
+ if (hasByPath(formData, path)) {
39
+ setByPath(data, path, getByPath(formData, path));
40
+ }
41
+ });
38
42
  if (Array.isArray(formData)) {
39
43
  return Object.keys(data).map((key: string) => data[key]) as unknown as T;
40
44
  }
@@ -50,8 +54,13 @@ export function getUsedFormData<T = any>(formData: T | undefined, fields: string
50
54
  */
51
55
  // oxlint-disable-next-line typescript/no-deprecated
52
56
  export function getFieldNames<T = any>(pathSchema: PathSchema<T>, formData?: T): string[][] {
53
- const formValueHasData = (value: T, isLeaf: boolean) =>
54
- typeof value !== 'object' || isEmpty(value) || (isLeaf && !isEmpty(value));
57
+ const formValueHasData = (value: unknown, isLeaf: boolean) => {
58
+ if (typeof value !== 'object' || value === null) {
59
+ return true;
60
+ }
61
+ const isEmptyValue = Array.isArray(value) ? value.length === 0 : Object.keys(value).length === 0;
62
+ return isEmptyValue || isLeaf;
63
+ };
55
64
  const getAllPaths = (_obj: GenericObjectType, acc: string[][] = [], paths: string[][] = [[]]) => {
56
65
  const objKeys = Object.keys(_obj);
57
66
  objKeys.forEach((key: string) => {
@@ -66,12 +75,12 @@ export function getFieldNames<T = any>(pathSchema: PathSchema<T>, formData?: T):
66
75
  }
67
76
  } else if (key === NAME_KEY && data !== '') {
68
77
  paths.forEach((path) => {
69
- const formValue = get(formData, path);
78
+ const formValue = getByPath(formData, path);
70
79
  const isLeaf = objKeys.length === 1;
71
80
  // adds path to fieldNames if it points to a value or an empty object/array which is not a leaf
72
81
  if (
73
82
  formValueHasData(formValue, isLeaf) ||
74
- (Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf)))
83
+ (Array.isArray(formValue) && formValue.every((val: unknown) => formValueHasData(val, isLeaf)))
75
84
  ) {
76
85
  acc.push(path);
77
86
  }
@@ -91,14 +100,14 @@ export function getFieldNames<T = any>(pathSchema: PathSchema<T>, formData?: T):
91
100
  * @returns - True if the value is considered empty, false otherwise
92
101
  */
93
102
  export function isValueEmpty(value: unknown): boolean {
94
- if (isNil(value) || value === '') {
103
+ if (value == null || value === '') {
95
104
  return true;
96
105
  }
97
106
  if (Array.isArray(value)) {
98
107
  return value.length === 0;
99
108
  }
100
109
  if (isObject(value)) {
101
- return Object.values(value as GenericObjectType).every(isValueEmpty);
110
+ return Object.values(value).every(isValueEmpty);
102
111
  }
103
112
  return false;
104
113
  }
@@ -163,7 +172,7 @@ export default function omitExtraData<
163
172
  }
164
173
 
165
174
  /** Copies schema-defined properties from `source` into `target`, applying `omit` recursively for
166
- * each value. Handles `properties`, `patternProperties`, `additionalProperties`, and `propertyNames`.
175
+ * each value. Handles `properties`, `patternProperties`, and `additionalProperties`.
167
176
  * Optional object-valued properties are pruned when every key in the filtered result is both
168
177
  * optional (per the inner schema's `required`) and empty (per `isValueEmpty`). This preserves
169
178
  * optional objects whose required children have empty values, while still dropping objects whose
@@ -177,7 +186,7 @@ export default function omitExtraData<
177
186
  * @returns - `target` after all schema-defined properties have been processed
178
187
  */
179
188
  function handleObject(childSchema: S, source: GenericObjectType, target: GenericObjectType): GenericObjectType {
180
- const { properties, additionalProperties, patternProperties, propertyNames } = childSchema;
189
+ const { properties, additionalProperties, patternProperties } = childSchema;
181
190
  const requiredSet = new Set(childSchema.required ?? []);
182
191
 
183
192
  /** Recursively omits extra data from `value` via `omit`, then conditionally writes the result to
@@ -204,9 +213,7 @@ export default function omitExtraData<
204
213
  const innerRequired = new Set(sd.required ?? []);
205
214
  // Drop this optional object when every key in v is both optional in the inner schema
206
215
  // and has an empty value. Vacuously true for {} so empty objects are always dropped.
207
- const shouldDrop = Object.entries(v as GenericObjectType).every(
208
- ([k, val]) => !innerRequired.has(k) && isValueEmpty(val),
209
- );
216
+ const shouldDrop = Object.entries(v).every(([k, val]) => !innerRequired.has(k) && isValueEmpty(val));
210
217
  if (shouldDrop) {
211
218
  return;
212
219
  }
@@ -262,46 +269,51 @@ export default function omitExtraData<
262
269
  }
263
270
  }
264
271
 
265
- // When propertyNames is present, the schema only constrains key names — all source keys are valid.
266
- if (propertyNames !== undefined) {
267
- for (const [key, value] of Object.entries(source)) {
268
- // oxlint-disable-next-line no-param-reassign
269
- target[key] = value;
270
- }
271
- }
272
-
273
272
  return target;
274
273
  }
275
274
 
276
275
  /** Filters array elements from `source` into `target` according to `schema.items` and
277
- * `schema.additionalItems`. For tuple schemas (`items` is an array) each element is filtered by its
278
- * per-index schema; elements beyond the tuple length are covered by `additionalItems` when present.
279
- * For list schemas (`items` is a single schema) every element is filtered by that schema.
276
+ * `schema.additionalItems`. Only called when `items` is defined (guarded in `omit`). Uses index
277
+ * assignment (not push) so a pre-populated `target` from a prior branch is overwritten rather than
278
+ * appended to, preventing item duplication. For tuple schemas (`items` is an array) elements up to
279
+ * `min(items.length, source.length)` are filtered by their per-index schema; elements beyond the
280
+ * tuple are covered by `additionalItems` when present, or the target is truncated when absent.
281
+ * For list schemas (`items` is a single schema) every source element is filtered and `target.length`
282
+ * is set to `source.length`.
280
283
  *
281
284
  * @param childSchema - The array schema describing `items` and optionally `additionalItems`
282
285
  * @param source - The source array to read elements from
283
- * @param target - The accumulator array to push filtered elements into
284
- * @returns - `target` after all applicable source elements have been pushed
286
+ * @param target - The accumulator array to write filtered elements into
287
+ * @returns - `target` after all applicable source elements have been written
285
288
  */
286
289
  function handleArray(childSchema: S, source: unknown[], target: unknown[]): unknown[] {
287
290
  const { items, additionalItems } = childSchema;
288
- if (items !== undefined) {
289
- if (Array.isArray(items)) {
290
- for (let i = 0; i < items.length; i += 1) {
291
- target.push(omit(items[i] as S | boolean, source[i]));
292
- }
293
- } else {
294
- for (let i = 0; i < source.length; i += 1) {
295
- target.push(omit(items as S | boolean, source[i]));
296
- }
291
+ if (Array.isArray(items)) {
292
+ const tupleLength = Math.min(items.length, source.length);
293
+ let i = 0;
294
+ for (; i < tupleLength; i += 1) {
295
+ // oxlint-disable-next-line no-param-reassign
296
+ target[i] = omit(items[i] as S | boolean, source[i]);
297
297
  }
298
- }
299
- // additionalItems covers tuple items beyond the items array length.
300
- if (additionalItems) {
301
- for (let i = target.length; i < source.length; i += 1) {
302
- target.push(omit(additionalItems as S | boolean, source[i]));
298
+ // Without additionalItems, truncate at the tuple boundary to drop any pre-existing items.
299
+ if (!additionalItems) {
300
+ // oxlint-disable-next-line no-param-reassign
301
+ target.length = tupleLength;
302
+ return target;
303
+ }
304
+ for (; i < source.length; i += 1) {
305
+ // oxlint-disable-next-line no-param-reassign
306
+ target[i] = omit(additionalItems as S | boolean, source[i]);
307
+ }
308
+ } else {
309
+ for (let i = 0; i < source.length; i += 1) {
310
+ // oxlint-disable-next-line no-param-reassign
311
+ target[i] = omit(items as S | boolean, source[i]);
303
312
  }
304
313
  }
314
+ // Truncate any pre-existing items beyond the source length.
315
+ // oxlint-disable-next-line no-param-reassign
316
+ target.length = source.length;
305
317
  return target;
306
318
  }
307
319
 
@@ -326,7 +338,7 @@ export default function omitExtraData<
326
338
  ? validator.isValid(condition as S, source as T, rootSchema)
327
339
  : condition;
328
340
  const branch = isThenBranch ? then : otherwise;
329
- return branch === undefined ? target : omit(branch as S | boolean, source, target);
341
+ return branch === undefined ? target : omit(branch as S | boolean, source, target, false);
330
342
  }
331
343
 
332
344
  /** Applies the best-matching `oneOf` option to `source`, merging the result into `target`. When
@@ -364,7 +376,7 @@ export default function omitExtraData<
364
376
  const resolved: S = isObject(winning)
365
377
  ? resolveAllReferences<S>(winning, rootSchema, [])
366
378
  : scoringOptions[bestIndex];
367
- return omit(resolved, source, target);
379
+ return omit(resolved, source, target, false);
368
380
  }
369
381
 
370
382
  /** Applies `anyOf` branches from `schema` to `source`, merging results into `target`. When `anyOf`
@@ -390,7 +402,7 @@ export default function omitExtraData<
390
402
  ) {
391
403
  let result = target;
392
404
  for (const branch of anyOf as (S | boolean)[]) {
393
- result = omit(branch, source, result);
405
+ result = omit(branch, source, result, false);
394
406
  }
395
407
  return result;
396
408
  }
@@ -416,7 +428,7 @@ export default function omitExtraData<
416
428
  for (const [key, deps] of Object.entries(dependencies)) {
417
429
  // Skip property dependencies (string arrays); only process schema dependencies.
418
430
  if (key in source && !Array.isArray(deps)) {
419
- result = omit(deps as S | boolean, source, result);
431
+ result = omit(deps as S | boolean, source, result, false);
420
432
  }
421
433
  }
422
434
  return result;
@@ -425,26 +437,30 @@ export default function omitExtraData<
425
437
  /** Core recursive filter. Resolves `$ref`s, merges `allOf`, then delegates to the type-specific
426
438
  * handlers (`handleObject`, `handleArray`) and keyword handlers (`handleAnyOf`, `handleOneOf`,
427
439
  * `handleConditions`, `handleDependencies`). Returns `undefined` when `source` is undefined or
428
- * `schemaDef` is `false`; returns `source` unchanged when `schemaDef` is `true` or empty.
440
+ * `schemaDef` is `false`; when `schemaDef` is `true` or empty returns `target ?? source` (when
441
+ * `useSourceAsFallback` is true) or `target` (when false) to avoid aliasing `source` as the
442
+ * accumulator across multiple compositional branches.
429
443
  *
430
444
  * @param schemaDef - The schema (or boolean shorthand) to filter `source` against
431
445
  * @param source - The raw form data value to filter
432
446
  * @param [target] - An optional accumulator carrying results from prior oneOf/anyOf processing
447
+ * @param [useSourceAsFallback=true] - When false a permissive schema (`true`/`{}`) returns `target`
448
+ * rather than `source`, preventing compositional branches from aliasing the accumulator to `source`
433
449
  * @returns - The filtered value, or `undefined` when the schema rejects the value
434
450
  */
435
- function omit(schemaDef: S | boolean, source: unknown, target?: unknown): unknown {
451
+ function omit(schemaDef: S | boolean, source: unknown, target?: unknown, useSourceAsFallback = true): unknown {
436
452
  if (source === undefined || schemaDef === false) {
437
453
  return undefined;
438
454
  }
439
- if (schemaDef === true || isEmpty(schemaDef as object)) {
440
- return source;
455
+ if (schemaDef === true || !schemaDef || Object.keys(schemaDef).length === 0) {
456
+ return target ?? (useSourceAsFallback ? source : undefined);
441
457
  }
442
458
 
443
459
  let localSchema = schemaDef;
444
460
  const { $ref: ref, allOf } = localSchema;
445
461
 
446
462
  if (ref !== undefined) {
447
- return omit(findSchemaDefinition<S>(ref, rootSchema), source, target);
463
+ return omit(findSchemaDefinition<S>(ref, rootSchema), source, target, useSourceAsFallback);
448
464
  }
449
465
  if (allOf) {
450
466
  localSchema = doMergeAllOf<S>(localSchema, experimental_customMergeAllOf);
@@ -456,7 +472,7 @@ export default function omitExtraData<
456
472
  if (remainingAllOf) {
457
473
  for (let i = 0; i < remainingAllOf.length; i++) {
458
474
  // oxlint-disable-next-line no-param-reassign
459
- target = omit(remainingAllOf[i] as S | boolean, source, target);
475
+ target = omit(remainingAllOf[i] as S | boolean, source, target, false);
460
476
  }
461
477
  }
462
478
  }
@@ -473,12 +489,32 @@ export default function omitExtraData<
473
489
  if (!Array.isArray(source)) {
474
490
  return undefined;
475
491
  }
476
- filtered = handleArray(localSchema, source, Array.isArray(filtered) ? filtered : []);
477
- } else if (filtered === undefined) {
478
- filtered = source;
492
+ if (localSchema.items !== undefined) {
493
+ filtered = handleArray(localSchema, source, Array.isArray(filtered) ? filtered : []);
494
+ }
479
495
  }
480
496
 
481
- return handleDependencies(localSchema, source, handleConditions(localSchema, source, filtered));
497
+ // Post-prune after conditions (oneOf/anyOf/if-then) but BEFORE dependencies: keys added by
498
+ // dependency sub-schemas are legitimate extensions of the allowed property set and must not be
499
+ // pruned. Keys added only by winning conditional branches are still removed here so the result
500
+ // honours additionalProperties:false.
501
+ const afterConditions = handleConditions(localSchema, source, filtered);
502
+ if (localSchema.additionalProperties === false && isObjectValue(afterConditions)) {
503
+ const knownKeys = new Set(Object.keys(localSchema.properties ?? {}));
504
+ const patterns = localSchema.patternProperties
505
+ ? Object.keys(localSchema.patternProperties).map((p) => new RegExp(p))
506
+ : [];
507
+ for (const key of Object.keys(afterConditions)) {
508
+ if (!knownKeys.has(key) && !patterns.some((re) => re.test(key))) {
509
+ // oxlint-disable-next-line no-param-reassign
510
+ delete afterConditions[key];
511
+ }
512
+ }
513
+ }
514
+
515
+ const result = handleDependencies(localSchema, source, afterConditions);
516
+
517
+ return result ?? (useSourceAsFallback ? source : undefined);
482
518
  }
483
519
 
484
520
  return omit(schema, formData) as T | undefined;
@@ -1,12 +1,3 @@
1
- import flattenDeep from 'lodash/flattenDeep';
2
- import get from 'lodash/get';
3
- import isEmpty from 'lodash/isEmpty';
4
- import merge from 'lodash/merge';
5
- import set from 'lodash/set';
6
- import times from 'lodash/times';
7
- import transform from 'lodash/transform';
8
- import uniq from 'lodash/uniq';
9
-
10
1
  import {
11
2
  ADDITIONAL_PROPERTIES_KEY,
12
3
  ADDITIONAL_PROPERTY_FLAG,
@@ -22,13 +13,14 @@ import {
22
13
  REF_KEY,
23
14
  RJSF_REF_CYCLE_KEY,
24
15
  RJSF_REF_KEY,
25
- } from '../constants';
26
- import deepEquals from '../deepEquals';
27
- import findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition';
28
- import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
29
- import guessType from '../guessType';
30
- import isObject from '../isObject';
31
- import mergeSchemas from '../mergeSchemas';
16
+ } from '../constants.ts';
17
+ import deepEquals from '../deepEquals.ts';
18
+ import findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition.ts';
19
+ import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema.ts';
20
+ import guessType from '../guessType.ts';
21
+ import isObject from '../isObject.ts';
22
+ import mergeSchemas from '../mergeSchemas.ts';
23
+ import { getByPath } from '../pathUtils.ts';
32
24
  import type {
33
25
  Experimental_CustomMergeAllOf,
34
26
  FormContextType,
@@ -37,9 +29,9 @@ import type {
37
29
  RJSFSchema,
38
30
  StrictRJSFSchema,
39
31
  ValidatorType,
40
- } from '../types';
41
- import getFirstMatchingOption from './getFirstMatchingOption';
42
- import shallowAllOfMerge from './shallowAllOfMerge';
32
+ } from '../types.ts';
33
+ import getFirstMatchingOption from './getFirstMatchingOption.ts';
34
+ import shallowAllOfMerge from './shallowAllOfMerge.ts';
43
35
 
44
36
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
45
37
  * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
@@ -198,7 +190,7 @@ export function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchem
198
190
  (permutations, list) => {
199
191
  // When there are more than one set of schemas for a row, duplicate the set of permutations and add in the values
200
192
  if (list.length > 1) {
201
- return list.flatMap((element) => times(permutations.length, (i) => [...permutations[i]].concat(element)));
193
+ return list.flatMap((element) => permutations.map((permutation) => [...permutation, element]));
202
194
  }
203
195
  // Otherwise just push in the single value into the current set of permutations
204
196
  permutations.forEach((permutation) => permutation.push(list[0]));
@@ -220,16 +212,10 @@ export function getMatchingPatternProperties<S extends StrictRJSFSchema = RJSFSc
220
212
  schema: S,
221
213
  key: string,
222
214
  ): Required<S['patternProperties']> {
223
- return Object.keys(schema.patternProperties!)
224
- .filter((pattern: string) => RegExp(pattern).test(key))
225
- .reduce(
226
- (obj, pattern) => {
227
- // Pass the pattern using the `[]` index notation so that any `.` in the pattern are not used as a dotted path
228
- set(obj, [pattern], schema.patternProperties![pattern]);
229
- return obj;
230
- },
231
- {} as Required<S['patternProperties']>,
232
- );
215
+ const patternProperties = schema.patternProperties ?? {};
216
+ return Object.fromEntries(
217
+ Object.entries(patternProperties).filter(([pattern]) => RegExp(pattern).test(key)),
218
+ ) as Required<S['patternProperties']>;
233
219
  }
234
220
 
235
221
  /** Resolves references and dependencies within a schema and its 'allOf' children. Passes the `expandAllBranches` flag
@@ -402,27 +388,28 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
402
388
 
403
389
  if (PROPERTIES_KEY in resolvedSchema) {
404
390
  const childrenLists: string[][] = [];
405
- const updatedProps = transform(
406
- resolvedSchema[PROPERTIES_KEY]!,
407
- (acc, value, key: string) => {
408
- const childList: string[] = [...recurseList];
409
- // Mark cycles only when NOT in resolveAnyOfOrOneOfRefs mode. When resolveAnyOfOrOneOfRefs=true
410
- // (e.g. from ObjectField), options are resolved against a shared recurseList that accumulates
411
- // refs across branches, causing false positives. In simple (non-anyOf) resolution, a $ref cycle
412
- // in an object property always causes an infinite render loop and must be caught.
413
- acc[key] = resolveAllReferences(
414
- value as S,
415
- rootSchema,
416
- childList,
417
- currentBaseURI,
418
- resolveAnyOfOrOneOfRefs,
419
- !resolveAnyOfOrOneOfRefs,
420
- );
421
- childrenLists.push(childList);
422
- },
423
- {} as RJSFSchema,
424
- );
425
- merge(recurseList, uniq(flattenDeep(childrenLists)));
391
+ const updatedProps: RJSFSchema = {};
392
+ for (const [key, value] of Object.entries(resolvedSchema[PROPERTIES_KEY] ?? {})) {
393
+ const childList: string[] = [...recurseList];
394
+ // Mark cycles only when NOT in resolveAnyOfOrOneOfRefs mode. When resolveAnyOfOrOneOfRefs=true
395
+ // (e.g. from ObjectField), options are resolved against a shared recurseList that accumulates
396
+ // refs across branches, causing false positives. In simple (non-anyOf) resolution, a $ref cycle
397
+ // in an object property always causes an infinite render loop and must be caught.
398
+ updatedProps[key] = resolveAllReferences(
399
+ value as S,
400
+ rootSchema,
401
+ childList,
402
+ currentBaseURI,
403
+ resolveAnyOfOrOneOfRefs,
404
+ !resolveAnyOfOrOneOfRefs,
405
+ );
406
+ childrenLists.push(childList);
407
+ }
408
+ for (const ref of new Set(childrenLists.flat())) {
409
+ if (!recurseList.includes(ref)) {
410
+ recurseList.push(ref);
411
+ }
412
+ }
426
413
  resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };
427
414
  }
428
415
 
@@ -502,12 +489,12 @@ export function stubExistingAdditionalProperties<
502
489
  }
503
490
  if (PATTERN_PROPERTIES_KEY in schema) {
504
491
  const matchingProperties = getMatchingPatternProperties(schema, key);
505
- if (!isEmpty(matchingProperties)) {
492
+ if (Object.keys(matchingProperties).length > 0) {
506
493
  schema.properties[key] = retrieveSchema<T, S, F>(
507
494
  validator,
508
495
  { [ALL_OF_KEY]: Object.values(matchingProperties) } as S,
509
496
  rootSchema,
510
- get(formData, [key]) as T,
497
+ formData[key],
511
498
  experimental_customMergeAllOf,
512
499
  );
513
500
  (schema.properties[key] as RJSFMarkedSchema)[ADDITIONAL_PROPERTY_FLAG] = true;
@@ -520,9 +507,9 @@ export function stubExistingAdditionalProperties<
520
507
  if (REF_KEY in schema.additionalProperties!) {
521
508
  additionalProperties = retrieveSchema<T, S, F>(
522
509
  validator,
523
- { [REF_KEY]: get(schema.additionalProperties, [REF_KEY]) } as S,
510
+ { [REF_KEY]: (schema.additionalProperties as S)[REF_KEY] } as S,
524
511
  rootSchema,
525
- get(formData, [key]) as T,
512
+ formData[key],
526
513
  experimental_customMergeAllOf,
527
514
  );
528
515
  } else if ('type' in schema.additionalProperties!) {
@@ -533,10 +520,10 @@ export function stubExistingAdditionalProperties<
533
520
  ...schema.additionalProperties,
534
521
  };
535
522
  } else {
536
- additionalProperties = { type: guessType(get(formData, [key])) };
523
+ additionalProperties = { type: guessType(formData[key]) };
537
524
  }
538
525
  } else {
539
- additionalProperties = { type: guessType(get(formData, [key])) };
526
+ additionalProperties = { type: guessType(formData[key]) };
540
527
  }
541
528
 
542
529
  // The type of our new key should match the additionalProperties value;
@@ -668,12 +655,12 @@ export function retrieveSchemaInternal<
668
655
  resolvedSchema = Object.keys(resolvedSchema.properties!).reduce(
669
656
  (acc, key) => {
670
657
  const matchingProperties = getMatchingPatternProperties(acc, key);
671
- if (!isEmpty(matchingProperties)) {
658
+ if (Object.keys(matchingProperties).length > 0) {
672
659
  acc.properties[key] = retrieveSchema<T, S, F>(
673
660
  validator,
674
661
  { allOf: [acc.properties[key], ...Object.values(matchingProperties)] } as S,
675
662
  rootSchema,
676
- get(rawFormData, [key]) as T,
663
+ getByPath<T>(rawFormData, key),
677
664
  experimental_customMergeAllOf,
678
665
  );
679
666
  }
@@ -850,7 +837,7 @@ export function processDependencies<T = any, S extends StrictRJSFSchema = RJSFSc
850
837
  // Process dependencies updating the local schema properties as appropriate.
851
838
  for (const dependencyKey in dependencies) {
852
839
  if (
853
- (expandAllBranches || get(formData, [dependencyKey]) !== undefined) &&
840
+ (expandAllBranches || getByPath(formData, dependencyKey) !== undefined) &&
854
841
  (!resolvedSchema.properties || dependencyKey in resolvedSchema.properties)
855
842
  ) {
856
843
  const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(