@rjsf/utils 6.8.0 → 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 (475) hide show
  1. package/dist/index.cjs +509 -419
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/utils.esm.js +508 -418
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +567 -327
  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 +2 -1
  149. package/lib/hashForSchema.d.ts.map +1 -0
  150. package/lib/idGenerators.d.ts +2 -1
  151. package/lib/idGenerators.d.ts.map +1 -0
  152. package/lib/idGenerators.js +2 -3
  153. package/lib/idGenerators.js.map +1 -1
  154. package/lib/index.d.ts +93 -87
  155. package/lib/index.d.ts.map +1 -0
  156. package/lib/index.js +85 -81
  157. package/lib/index.js.map +1 -1
  158. package/lib/isConstant.d.ts +2 -1
  159. package/lib/isConstant.d.ts.map +1 -0
  160. package/lib/isConstant.js +1 -1
  161. package/lib/isConstant.js.map +1 -1
  162. package/lib/isCustomWidget.d.ts +2 -1
  163. package/lib/isCustomWidget.d.ts.map +1 -0
  164. package/lib/isCustomWidget.js +1 -1
  165. package/lib/isCustomWidget.js.map +1 -1
  166. package/lib/isFixedItems.d.ts +2 -1
  167. package/lib/isFixedItems.d.ts.map +1 -0
  168. package/lib/isFixedItems.js +1 -1
  169. package/lib/isFixedItems.js.map +1 -1
  170. package/lib/isFormDataAvailable.d.ts +1 -0
  171. package/lib/isFormDataAvailable.d.ts.map +1 -0
  172. package/lib/isFormDataAvailable.js +7 -4
  173. package/lib/isFormDataAvailable.js.map +1 -1
  174. package/lib/isObject.d.ts +3 -1
  175. package/lib/isObject.d.ts.map +1 -0
  176. package/lib/isObject.js +8 -2
  177. package/lib/isObject.js.map +1 -1
  178. package/lib/isPlainObject.d.ts +9 -0
  179. package/lib/isPlainObject.d.ts.map +1 -0
  180. package/lib/isPlainObject.js +15 -0
  181. package/lib/isPlainObject.js.map +1 -0
  182. package/lib/isRootSchema.d.ts +2 -1
  183. package/lib/isRootSchema.d.ts.map +1 -0
  184. package/lib/isRootSchema.js +2 -2
  185. package/lib/isRootSchema.js.map +1 -1
  186. package/lib/jsonSchemaAugmentation.d.ts +1 -0
  187. package/lib/jsonSchemaAugmentation.d.ts.map +1 -0
  188. package/lib/labelValue.d.ts +1 -0
  189. package/lib/labelValue.d.ts.map +1 -0
  190. package/lib/localToUTC.d.ts +1 -0
  191. package/lib/localToUTC.d.ts.map +1 -0
  192. package/lib/logUnsupportedDefaultForEnum.d.ts +2 -1
  193. package/lib/logUnsupportedDefaultForEnum.d.ts.map +1 -0
  194. package/lib/logUnsupportedDefaultForEnum.js +1 -1
  195. package/lib/logUnsupportedDefaultForEnum.js.map +1 -1
  196. package/lib/lookupFromFormContext.d.ts +3 -2
  197. package/lib/lookupFromFormContext.d.ts.map +1 -0
  198. package/lib/lookupFromFormContext.js +4 -5
  199. package/lib/lookupFromFormContext.js.map +1 -1
  200. package/lib/mergeDefaultsWithFormData.d.ts +1 -0
  201. package/lib/mergeDefaultsWithFormData.d.ts.map +1 -0
  202. package/lib/mergeDefaultsWithFormData.js +20 -16
  203. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  204. package/lib/mergeObjects.d.ts +2 -1
  205. package/lib/mergeObjects.d.ts.map +1 -0
  206. package/lib/mergeObjects.js +1 -1
  207. package/lib/mergeObjects.js.map +1 -1
  208. package/lib/mergeSchemas.d.ts +2 -1
  209. package/lib/mergeSchemas.d.ts.map +1 -0
  210. package/lib/mergeSchemas.js +4 -5
  211. package/lib/mergeSchemas.js.map +1 -1
  212. package/lib/nameGenerators.d.ts +2 -1
  213. package/lib/nameGenerators.d.ts.map +1 -0
  214. package/lib/noop.d.ts +5 -0
  215. package/lib/noop.d.ts.map +1 -0
  216. package/lib/noop.js +5 -0
  217. package/lib/noop.js.map +1 -0
  218. package/lib/optionsList.d.ts +2 -1
  219. package/lib/optionsList.d.ts.map +1 -0
  220. package/lib/optionsList.js +15 -15
  221. package/lib/optionsList.js.map +1 -1
  222. package/lib/orderProperties.d.ts +1 -0
  223. package/lib/orderProperties.d.ts.map +1 -0
  224. package/lib/pad.d.ts +1 -0
  225. package/lib/pad.d.ts.map +1 -0
  226. package/lib/parseDateString.d.ts +2 -1
  227. package/lib/parseDateString.d.ts.map +1 -0
  228. package/lib/parser/ParserValidator.d.ts +2 -1
  229. package/lib/parser/ParserValidator.d.ts.map +1 -0
  230. package/lib/parser/ParserValidator.js +8 -7
  231. package/lib/parser/ParserValidator.js.map +1 -1
  232. package/lib/parser/index.d.ts +3 -2
  233. package/lib/parser/index.d.ts.map +1 -0
  234. package/lib/parser/index.js +1 -1
  235. package/lib/parser/index.js.map +1 -1
  236. package/lib/parser/schemaParser.d.ts +3 -2
  237. package/lib/parser/schemaParser.d.ts.map +1 -0
  238. package/lib/parser/schemaParser.js +6 -7
  239. package/lib/parser/schemaParser.js.map +1 -1
  240. package/lib/pathUtils.d.ts +77 -0
  241. package/lib/pathUtils.d.ts.map +1 -0
  242. package/lib/pathUtils.js +192 -0
  243. package/lib/pathUtils.js.map +1 -0
  244. package/lib/rangeSpec.d.ts +2 -1
  245. package/lib/rangeSpec.d.ts.map +1 -0
  246. package/lib/removeOptionalEmptyObjects.d.ts +2 -1
  247. package/lib/removeOptionalEmptyObjects.d.ts.map +1 -0
  248. package/lib/removeOptionalEmptyObjects.js +2 -2
  249. package/lib/removeOptionalEmptyObjects.js.map +1 -1
  250. package/lib/replaceStringParameters.d.ts +1 -0
  251. package/lib/replaceStringParameters.d.ts.map +1 -0
  252. package/lib/resolveUiSchema.d.ts +2 -1
  253. package/lib/resolveUiSchema.d.ts.map +1 -0
  254. package/lib/resolveUiSchema.js +6 -8
  255. package/lib/resolveUiSchema.js.map +1 -1
  256. package/lib/schema/findFieldInSchema.d.ts +2 -1
  257. package/lib/schema/findFieldInSchema.d.ts.map +1 -0
  258. package/lib/schema/findFieldInSchema.js +10 -11
  259. package/lib/schema/findFieldInSchema.js.map +1 -1
  260. package/lib/schema/findSelectedOptionInXxxOf.d.ts +2 -1
  261. package/lib/schema/findSelectedOptionInXxxOf.d.ts.map +1 -0
  262. package/lib/schema/findSelectedOptionInXxxOf.js +7 -7
  263. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
  264. package/lib/schema/getClosestMatchingOption.d.ts +2 -1
  265. package/lib/schema/getClosestMatchingOption.d.ts.map +1 -0
  266. package/lib/schema/getClosestMatchingOption.js +18 -23
  267. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  268. package/lib/schema/getDefaultFormState.d.ts +2 -1
  269. package/lib/schema/getDefaultFormState.d.ts.map +1 -0
  270. package/lib/schema/getDefaultFormState.js +78 -56
  271. package/lib/schema/getDefaultFormState.js.map +1 -1
  272. package/lib/schema/getDisplayLabel.d.ts +2 -1
  273. package/lib/schema/getDisplayLabel.d.ts.map +1 -0
  274. package/lib/schema/getDisplayLabel.js +7 -7
  275. package/lib/schema/getDisplayLabel.js.map +1 -1
  276. package/lib/schema/getFirstMatchingOption.d.ts +2 -1
  277. package/lib/schema/getFirstMatchingOption.d.ts.map +1 -0
  278. package/lib/schema/getFirstMatchingOption.js +9 -9
  279. package/lib/schema/getFirstMatchingOption.js.map +1 -1
  280. package/lib/schema/getFromSchema.d.ts +3 -2
  281. package/lib/schema/getFromSchema.d.ts.map +1 -0
  282. package/lib/schema/getFromSchema.js +10 -11
  283. package/lib/schema/getFromSchema.js.map +1 -1
  284. package/lib/schema/index.d.ts +15 -14
  285. package/lib/schema/index.d.ts.map +1 -0
  286. package/lib/schema/index.js +14 -14
  287. package/lib/schema/index.js.map +1 -1
  288. package/lib/schema/isFilesArray.d.ts +2 -1
  289. package/lib/schema/isFilesArray.d.ts.map +1 -0
  290. package/lib/schema/isFilesArray.js +2 -2
  291. package/lib/schema/isFilesArray.js.map +1 -1
  292. package/lib/schema/isMultiSelect.d.ts +2 -1
  293. package/lib/schema/isMultiSelect.d.ts.map +1 -0
  294. package/lib/schema/isMultiSelect.js +1 -1
  295. package/lib/schema/isMultiSelect.js.map +1 -1
  296. package/lib/schema/isSelect.d.ts +2 -1
  297. package/lib/schema/isSelect.d.ts.map +1 -0
  298. package/lib/schema/isSelect.js +2 -2
  299. package/lib/schema/isSelect.js.map +1 -1
  300. package/lib/schema/omitExtraData.d.ts +2 -1
  301. package/lib/schema/omitExtraData.d.ts.map +1 -0
  302. package/lib/schema/omitExtraData.js +100 -64
  303. package/lib/schema/omitExtraData.js.map +1 -1
  304. package/lib/schema/retrieveSchema.d.ts +2 -1
  305. package/lib/schema/retrieveSchema.d.ts.map +1 -0
  306. package/lib/schema/retrieveSchema.js +32 -40
  307. package/lib/schema/retrieveSchema.js.map +1 -1
  308. package/lib/schema/sanitizeDataForNewSchema.d.ts +4 -3
  309. package/lib/schema/sanitizeDataForNewSchema.d.ts.map +1 -0
  310. package/lib/schema/sanitizeDataForNewSchema.js +41 -39
  311. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  312. package/lib/schema/shallowAllOfMerge.d.ts +1 -0
  313. package/lib/schema/shallowAllOfMerge.d.ts.map +1 -0
  314. package/lib/schema/toPathSchema.d.ts +2 -1
  315. package/lib/schema/toPathSchema.d.ts.map +1 -0
  316. package/lib/schema/toPathSchema.js +14 -14
  317. package/lib/schema/toPathSchema.js.map +1 -1
  318. package/lib/schemaRequiresTrueValue.d.ts +2 -1
  319. package/lib/schemaRequiresTrueValue.d.ts.map +1 -0
  320. package/lib/schemaRequiresTrueValue.js +3 -4
  321. package/lib/schemaRequiresTrueValue.js.map +1 -1
  322. package/lib/shallowEquals.d.ts +1 -0
  323. package/lib/shallowEquals.d.ts.map +1 -0
  324. package/lib/shouldRender.d.ts +2 -1
  325. package/lib/shouldRender.d.ts.map +1 -0
  326. package/lib/shouldRender.js +2 -2
  327. package/lib/shouldRender.js.map +1 -1
  328. package/lib/shouldRenderOptionalField.d.ts +2 -1
  329. package/lib/shouldRenderOptionalField.d.ts.map +1 -0
  330. package/lib/shouldRenderOptionalField.js +11 -10
  331. package/lib/shouldRenderOptionalField.js.map +1 -1
  332. package/lib/toConstant.d.ts +2 -1
  333. package/lib/toConstant.d.ts.map +1 -0
  334. package/lib/toConstant.js +1 -1
  335. package/lib/toConstant.js.map +1 -1
  336. package/lib/toDateString.d.ts +2 -1
  337. package/lib/toDateString.d.ts.map +1 -0
  338. package/lib/toErrorList.d.ts +2 -1
  339. package/lib/toErrorList.d.ts.map +1 -0
  340. package/lib/toErrorList.js +20 -21
  341. package/lib/toErrorList.js.map +1 -1
  342. package/lib/toErrorSchema.d.ts +2 -1
  343. package/lib/toErrorSchema.d.ts.map +1 -0
  344. package/lib/toErrorSchema.js +4 -9
  345. package/lib/toErrorSchema.js.map +1 -1
  346. package/lib/toFieldPathId.d.ts +2 -1
  347. package/lib/toFieldPathId.d.ts.map +1 -0
  348. package/lib/toFieldPathId.js +2 -2
  349. package/lib/toFieldPathId.js.map +1 -1
  350. package/lib/types.d.ts +15 -5
  351. package/lib/types.d.ts.map +1 -0
  352. package/lib/types.js +1 -1
  353. package/lib/types.js.map +1 -1
  354. package/lib/unwrapErrorHandler.d.ts +2 -1
  355. package/lib/unwrapErrorHandler.d.ts.map +1 -0
  356. package/lib/unwrapErrorHandler.js +13 -4
  357. package/lib/unwrapErrorHandler.js.map +1 -1
  358. package/lib/useAltDateWidgetProps.d.ts +3 -2
  359. package/lib/useAltDateWidgetProps.d.ts.map +1 -0
  360. package/lib/useAltDateWidgetProps.js +5 -5
  361. package/lib/useAltDateWidgetProps.js.map +1 -1
  362. package/lib/useDeepCompareMemo.d.ts +1 -0
  363. package/lib/useDeepCompareMemo.d.ts.map +1 -0
  364. package/lib/useDeepCompareMemo.js +1 -1
  365. package/lib/useDeepCompareMemo.js.map +1 -1
  366. package/lib/useFileWidgetProps.d.ts +1 -0
  367. package/lib/useFileWidgetProps.d.ts.map +1 -0
  368. package/lib/useFileWidgetProps.js +3 -4
  369. package/lib/useFileWidgetProps.js.map +1 -1
  370. package/lib/utcToLocal.d.ts +1 -0
  371. package/lib/utcToLocal.d.ts.map +1 -0
  372. package/lib/utcToLocal.js +1 -1
  373. package/lib/utcToLocal.js.map +1 -1
  374. package/lib/validationDataMerge.d.ts +2 -1
  375. package/lib/validationDataMerge.d.ts.map +1 -0
  376. package/lib/validationDataMerge.js +3 -4
  377. package/lib/validationDataMerge.js.map +1 -1
  378. package/lib/withIdRefPrefix.d.ts +2 -1
  379. package/lib/withIdRefPrefix.d.ts.map +1 -0
  380. package/lib/withIdRefPrefix.js +2 -2
  381. package/lib/withIdRefPrefix.js.map +1 -1
  382. package/package.json +5 -6
  383. package/src/ErrorSchemaBuilder.ts +25 -24
  384. package/src/SelectedOptionDescription.tsx +5 -5
  385. package/src/allowAdditionalItems.ts +2 -2
  386. package/src/asNumber.ts +1 -1
  387. package/src/canExpand.ts +2 -2
  388. package/src/constIsAjvDataReference.ts +5 -4
  389. package/src/createErrorHandler.ts +5 -7
  390. package/src/createSchemaUtils.ts +8 -10
  391. package/src/dateRangeOptions.ts +2 -2
  392. package/src/englishStringTranslator.ts +2 -2
  393. package/src/enumOptionSelectedValue.ts +2 -2
  394. package/src/enumOptionValueDecoder.ts +2 -2
  395. package/src/enumOptionValueEncoder.ts +2 -4
  396. package/src/enumOptionsDeselectValue.ts +3 -3
  397. package/src/enumOptionsIndexForValue.ts +2 -2
  398. package/src/enumOptionsIsSelected.ts +2 -2
  399. package/src/enumOptionsSelectValue.ts +3 -5
  400. package/src/enumOptionsValueForIndex.ts +1 -1
  401. package/src/findSchemaDefinition.ts +8 -12
  402. package/src/getChangedFields.ts +57 -18
  403. package/src/getDateElementProps.ts +1 -1
  404. package/src/getDiscriminatorFieldFromSchema.ts +5 -7
  405. package/src/getInputProps.ts +6 -2
  406. package/src/getOptionMatchingSimpleDiscriminator.ts +7 -7
  407. package/src/getOptionValueFormat.ts +1 -1
  408. package/src/getPropertySchema.ts +18 -0
  409. package/src/getSchemaType.ts +2 -2
  410. package/src/getSubmitButtonOptions.ts +3 -3
  411. package/src/getTemplate.ts +1 -1
  412. package/src/getTestIds.ts +7 -6
  413. package/src/getUiOptions.ts +3 -3
  414. package/src/getWidget.tsx +6 -6
  415. package/src/hasWidget.ts +2 -2
  416. package/src/hashForSchema.ts +1 -1
  417. package/src/idGenerators.ts +3 -5
  418. package/src/index.ts +99 -85
  419. package/src/isConstant.ts +2 -2
  420. package/src/isCustomWidget.ts +2 -2
  421. package/src/isFixedItems.ts +2 -2
  422. package/src/isFormDataAvailable.ts +7 -5
  423. package/src/isObject.ts +15 -3
  424. package/src/isPlainObject.ts +14 -0
  425. package/src/isRootSchema.ts +3 -3
  426. package/src/logUnsupportedDefaultForEnum.ts +2 -2
  427. package/src/lookupFromFormContext.ts +7 -8
  428. package/src/mergeDefaultsWithFormData.ts +22 -18
  429. package/src/mergeObjects.ts +2 -2
  430. package/src/mergeSchemas.ts +5 -7
  431. package/src/nameGenerators.ts +1 -1
  432. package/src/noop.ts +4 -0
  433. package/src/optionsList.ts +9 -9
  434. package/src/orderProperties.ts +1 -1
  435. package/src/parseDateString.ts +1 -1
  436. package/src/parser/ParserValidator.ts +5 -7
  437. package/src/parser/index.ts +2 -2
  438. package/src/parser/schemaParser.ts +8 -10
  439. package/src/pathUtils.ts +203 -0
  440. package/src/rangeSpec.ts +1 -1
  441. package/src/removeOptionalEmptyObjects.ts +3 -3
  442. package/src/resolveUiSchema.ts +5 -7
  443. package/src/schema/findFieldInSchema.ts +11 -13
  444. package/src/schema/findSelectedOptionInXxxOf.ts +9 -10
  445. package/src/schema/getClosestMatchingOption.ts +73 -83
  446. package/src/schema/getDefaultFormState.ts +62 -34
  447. package/src/schema/getDisplayLabel.ts +7 -7
  448. package/src/schema/getFirstMatchingOption.ts +10 -11
  449. package/src/schema/getFromSchema.ts +12 -14
  450. package/src/schema/index.ts +14 -14
  451. package/src/schema/isFilesArray.ts +3 -3
  452. package/src/schema/isMultiSelect.ts +2 -2
  453. package/src/schema/isSelect.ts +3 -3
  454. package/src/schema/omitExtraData.ts +104 -68
  455. package/src/schema/retrieveSchema.ts +47 -60
  456. package/src/schema/sanitizeDataForNewSchema.ts +42 -41
  457. package/src/schema/toPathSchema.ts +14 -14
  458. package/src/schemaRequiresTrueValue.ts +1 -1
  459. package/src/shouldRender.ts +3 -3
  460. package/src/shouldRenderOptionalField.ts +14 -14
  461. package/src/toConstant.ts +2 -2
  462. package/src/toDateString.ts +1 -1
  463. package/src/toErrorList.ts +22 -25
  464. package/src/toErrorSchema.ts +5 -11
  465. package/src/toFieldPathId.ts +2 -2
  466. package/src/types.ts +14 -5
  467. package/src/unwrapErrorHandler.ts +15 -6
  468. package/src/useAltDateWidgetProps.tsx +7 -7
  469. package/src/useDeepCompareMemo.ts +1 -1
  470. package/src/useFileWidgetProps.ts +1 -1
  471. package/src/utcToLocal.ts +1 -1
  472. package/src/validationDataMerge.ts +4 -6
  473. package/src/withIdRefPrefix.ts +3 -4
  474. package/lib/tsconfig.tsbuildinfo +0 -1
  475. package/src/tsconfig.json +0 -9
@@ -1,8 +1,7 @@
1
- import get from 'lodash/get';
2
- import has from 'lodash/has';
3
-
4
- import { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY, REF_KEY } from '../constants';
5
- import deepEquals from '../deepEquals';
1
+ import { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY, REF_KEY } from '../constants.ts';
2
+ import deepEquals from '../deepEquals.ts';
3
+ import getPropertySchema from '../getPropertySchema.ts';
4
+ import { getByPath, hasByPath } from '../pathUtils.ts';
6
5
  import type {
7
6
  Experimental_CustomMergeAllOf,
8
7
  FormContextType,
@@ -10,8 +9,8 @@ import type {
10
9
  RJSFSchema,
11
10
  StrictRJSFSchema,
12
11
  ValidatorType,
13
- } from '../types';
14
- import retrieveSchema from './retrieveSchema';
12
+ } from '../types.ts';
13
+ import retrieveSchema from './retrieveSchema.ts';
15
14
 
16
15
  const NO_VALUE = Symbol('no Value');
17
16
 
@@ -43,7 +42,7 @@ function replacementForInvalidEnumValue<S extends StrictRJSFSchema = RJSFSchema>
43
42
  return NO_VALUE;
44
43
  }
45
44
 
46
- const defaultValue = get(schema, DEFAULT_KEY, NO_VALUE);
45
+ const defaultValue = getByPath(schema, DEFAULT_KEY, NO_VALUE);
47
46
  if (defaultValue !== NO_VALUE && enumValues.some((value) => deepEquals(value, defaultValue))) {
48
47
  return defaultValue;
49
48
  }
@@ -70,7 +69,7 @@ function replacementForInvalidEnumValue<S extends StrictRJSFSchema = RJSFSchema>
70
69
  * - Otherwise, check for default or const values:
71
70
  * - Get the old and new `default` values from the schema and check:
72
71
  * - If the new `default` value does not match the form value:
73
- * - If the old `default` value DOES match the form value, then:
72
+ * - If the key is new and its form value is undefined, or the old `default` matches the form value, then:
74
73
  * - Replace `removeOldSchemaData[key]` with the new `default`
75
74
  * - Otherwise, if the new schema is `readOnly` then replace `removeOldSchemaData[key]` with undefined
76
75
  * - Get the old and new `const` values from the schema and check:
@@ -79,7 +78,7 @@ function replacementForInvalidEnumValue<S extends StrictRJSFSchema = RJSFSchema>
79
78
  * - Replace `removeOldSchemaData[key]` with the new `const`
80
79
  * - Otherwise, replace `removeOldSchemaData[key]` with undefined
81
80
  * - Once all keys have been processed, return an object built as follows:
82
- * - `{ ...removeOldSchemaData, ...nestedData, ...pick(data, keysToKeep) }`
81
+ * - `{ ...data, ...removeOldSchemaData, ...nestedData }`
83
82
  * - If the new and old schema types are array and the `data` is an array then:
84
83
  * - If the type of the old and new schema `items` are a non-array objects:
85
84
  * - Retrieve the schema for any refs within each `oldKeySchema.items` and/or `newKeySchema.items`
@@ -113,27 +112,29 @@ export default function sanitizeDataForNewSchema<
113
112
  ): T {
114
113
  // By default, we will clear the form data
115
114
  let newFormData;
115
+ const newProperties = newSchema?.[PROPERTIES_KEY];
116
116
  // If the new schema is of type object and that object contains a list of properties
117
- if (has(newSchema, PROPERTIES_KEY)) {
117
+ if (newProperties) {
118
118
  // Create an object containing root-level keys in the old schema, setting each key to undefined to remove the data
119
119
  const removeOldSchemaData: GenericObjectType = {};
120
- if (has(oldSchema, PROPERTIES_KEY)) {
121
- const properties = get(oldSchema, PROPERTIES_KEY, {});
122
- Object.keys(properties).forEach((key) => {
123
- if (has(data, key)) {
120
+ const oldProperties = oldSchema?.[PROPERTIES_KEY];
121
+ if (oldProperties) {
122
+ Object.keys(oldProperties).forEach((key) => {
123
+ if (hasByPath(data, key)) {
124
124
  removeOldSchemaData[key] = undefined;
125
125
  }
126
126
  });
127
127
  }
128
- const keys: string[] = Object.keys(get(newSchema, PROPERTIES_KEY, {}));
128
+ const keys: string[] = Object.keys(newProperties);
129
129
  // Create a place to store nested data that will be a side-effect of the filter
130
130
  const nestedData: GenericObjectType = {};
131
131
  keys.forEach((key) => {
132
- const formValue = get(data, key);
133
- let oldKeyedSchema: S = get(oldSchema, [PROPERTIES_KEY, key], {}) as S;
134
- let newKeyedSchema: S = get(newSchema, [PROPERTIES_KEY, key], {}) as S;
132
+ const formValue = data?.[key];
133
+ const isNewProperty = !hasByPath(oldSchema, [PROPERTIES_KEY, key]);
134
+ let oldKeyedSchema = getPropertySchema<S>(oldSchema, key);
135
+ let newKeyedSchema = getPropertySchema<S>(newSchema, key);
135
136
  // Resolve the refs if they exist
136
- if (has(oldKeyedSchema, REF_KEY)) {
137
+ if (hasByPath(oldKeyedSchema, REF_KEY)) {
137
138
  oldKeyedSchema = retrieveSchema<T, S, F>(
138
139
  validator,
139
140
  oldKeyedSchema,
@@ -142,7 +143,7 @@ export default function sanitizeDataForNewSchema<
142
143
  experimental_customMergeAllOf,
143
144
  );
144
145
  }
145
- if (has(newKeyedSchema, REF_KEY)) {
146
+ if (hasByPath(newKeyedSchema, REF_KEY)) {
146
147
  newKeyedSchema = retrieveSchema<T, S, F>(
147
148
  validator,
148
149
  newKeyedSchema,
@@ -152,11 +153,11 @@ export default function sanitizeDataForNewSchema<
152
153
  );
153
154
  }
154
155
  // Now get types and see if they are the same
155
- const oldSchemaTypeForKey = get(oldKeyedSchema, 'type');
156
- const newSchemaTypeForKey = get(newKeyedSchema, 'type');
156
+ const oldSchemaTypeForKey = oldKeyedSchema.type;
157
+ const newSchemaTypeForKey = newKeyedSchema.type;
157
158
  // Check if the old option has the same key with the same type
158
159
  if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
159
- if (has(removeOldSchemaData, key)) {
160
+ if (key in removeOldSchemaData) {
160
161
  // SIDE-EFFECT: remove the undefined value for a key that has the same type between the old and new schemas
161
162
  delete removeOldSchemaData[key];
162
163
  }
@@ -167,7 +168,7 @@ export default function sanitizeDataForNewSchema<
167
168
  validator,
168
169
  rootSchema,
169
170
  newKeyedSchema,
170
- oldKeyedSchema,
171
+ isNewProperty && newSchemaTypeForKey === 'array' ? newKeyedSchema : oldKeyedSchema,
171
172
  formValue,
172
173
  experimental_customMergeAllOf,
173
174
  );
@@ -179,26 +180,26 @@ export default function sanitizeDataForNewSchema<
179
180
  // Ok, the non-object types match, let's make sure that a default or a const of a different value is replaced
180
181
  // with the new default or const. This allows the case where two schemas differ that only by the default/const
181
182
  // value to be properly selected
182
- const newOptionDefault = get(newKeyedSchema, DEFAULT_KEY, NO_VALUE);
183
- const oldOptionDefault = get(oldKeyedSchema, DEFAULT_KEY, NO_VALUE);
183
+ const newOptionDefault = getByPath(newKeyedSchema, DEFAULT_KEY, NO_VALUE);
184
+ const oldOptionDefault = getByPath(oldKeyedSchema, DEFAULT_KEY, NO_VALUE);
184
185
  if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
185
- if (oldOptionDefault === formValue) {
186
- // If the old default matches the formValue, we'll update the new value to match the new default
186
+ if ((isNewProperty && formValue === undefined) || oldOptionDefault === formValue) {
187
+ // Initialize a newly entered property or replace an old default with the new default.
187
188
  removeOldSchemaData[key] = newOptionDefault;
188
- } else if (get(newKeyedSchema, 'readOnly') === true) {
189
+ } else if (newKeyedSchema.readOnly === true) {
189
190
  // If the new schema has the default set to read-only, treat it like a const and remove the value
190
191
  removeOldSchemaData[key] = undefined;
191
192
  }
192
193
  }
193
194
 
194
- const newOptionConst = get(newKeyedSchema, CONST_KEY, NO_VALUE);
195
- const oldOptionConst = get(oldKeyedSchema, CONST_KEY, NO_VALUE);
195
+ const newOptionConst = getByPath(newKeyedSchema, CONST_KEY, NO_VALUE);
196
+ const oldOptionConst = getByPath(oldKeyedSchema, CONST_KEY, NO_VALUE);
196
197
  if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
197
198
  // Since this is a const, if the old value matches, replace the value with the new const otherwise clear it
198
199
  removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : undefined;
199
200
  }
200
201
 
201
- if (has(data, key)) {
202
+ if (hasByPath(data, key)) {
202
203
  const enumReplacement = replacementForInvalidEnumValue(newKeyedSchema, formValue);
203
204
  if (enumReplacement !== NO_VALUE) {
204
205
  removeOldSchemaData[key] = enumReplacement;
@@ -214,9 +215,9 @@ export default function sanitizeDataForNewSchema<
214
215
  ...nestedData,
215
216
  };
216
217
  // First apply removing the old schema data, then apply the nested data, then apply the old data keys to keep
217
- } else if (get(oldSchema, 'type') === 'array' && get(newSchema, 'type') === 'array' && Array.isArray(data)) {
218
- let oldSchemaItems = get(oldSchema, 'items');
219
- let newSchemaItems = get(newSchema, 'items');
218
+ } else if (oldSchema?.type === 'array' && newSchema?.type === 'array' && Array.isArray(data)) {
219
+ let oldSchemaItems = oldSchema.items;
220
+ let newSchemaItems = newSchema.items;
220
221
  // If any of the array types `items` are arrays (remember arrays are objects) then we'll just drop the data
221
222
  // Eventually, we may want to deal with when either of the `items` are arrays since those tuple validations
222
223
  if (
@@ -225,7 +226,7 @@ export default function sanitizeDataForNewSchema<
225
226
  !Array.isArray(oldSchemaItems) &&
226
227
  !Array.isArray(newSchemaItems)
227
228
  ) {
228
- if (has(oldSchemaItems, REF_KEY)) {
229
+ if (hasByPath(oldSchemaItems, REF_KEY)) {
229
230
  oldSchemaItems = retrieveSchema<T, S, F>(
230
231
  validator,
231
232
  oldSchemaItems as S,
@@ -234,7 +235,7 @@ export default function sanitizeDataForNewSchema<
234
235
  experimental_customMergeAllOf,
235
236
  );
236
237
  }
237
- if (has(newSchemaItems, REF_KEY)) {
238
+ if (hasByPath(newSchemaItems, REF_KEY)) {
238
239
  newSchemaItems = retrieveSchema<T, S, F>(
239
240
  validator,
240
241
  newSchemaItems as S,
@@ -244,11 +245,11 @@ export default function sanitizeDataForNewSchema<
244
245
  );
245
246
  }
246
247
  // Now get types and see if they are the same
247
- const oldSchemaType = get(oldSchemaItems, 'type');
248
- const newSchemaType = get(newSchemaItems, 'type');
248
+ const oldSchemaType = getByPath(oldSchemaItems, 'type');
249
+ const newSchemaType = getByPath(newSchemaItems, 'type');
249
250
  // Check if the old option has the same key with the same type
250
251
  if (!oldSchemaType || oldSchemaType === newSchemaType) {
251
- const maxItems = get(newSchema, 'maxItems', -1);
252
+ const maxItems = newSchema.maxItems ?? -1;
252
253
  if (newSchemaType === 'object') {
253
254
  newFormData = data.reduce((newValue, aValue) => {
254
255
  const itemValue = sanitizeDataForNewSchema<T, S, F>(
@@ -1,7 +1,4 @@
1
1
  // oxlint-disable typescript/no-deprecated
2
- import get from 'lodash/get';
3
- import isObject from 'lodash/isObject';
4
- import set from 'lodash/set';
5
2
 
6
3
  import {
7
4
  ADDITIONAL_PROPERTIES_KEY,
@@ -15,9 +12,12 @@ import {
15
12
  PROPERTIES_KEY,
16
13
  REF_KEY,
17
14
  RJSF_ADDITIONAL_PROPERTIES_FLAG,
18
- } from '../constants';
19
- import deepEquals from '../deepEquals';
20
- import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';
15
+ } from '../constants.ts';
16
+ import deepEquals from '../deepEquals.ts';
17
+ import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema.ts';
18
+ import getPropertySchema from '../getPropertySchema.ts';
19
+ import isObject from '../isObject.ts';
20
+ import { getByPath, setByPath } from '../pathUtils.ts';
21
21
  import type {
22
22
  Experimental_CustomMergeAllOf,
23
23
  FormContextType,
@@ -26,9 +26,9 @@ import type {
26
26
  RJSFSchema,
27
27
  StrictRJSFSchema,
28
28
  ValidatorType,
29
- } from '../types';
30
- import getClosestMatchingOption from './getClosestMatchingOption';
31
- import retrieveSchema from './retrieveSchema';
29
+ } from '../types.ts';
30
+ import getClosestMatchingOption from './getClosestMatchingOption.ts';
31
+ import retrieveSchema from './retrieveSchema.ts';
32
32
 
33
33
  /** An internal helper that generates an `PathSchema` object for the `schema`, recursively with protection against
34
34
  * infinite recursion
@@ -99,11 +99,11 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
99
99
  }
100
100
 
101
101
  if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
102
- set(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);
102
+ setByPath(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);
103
103
  const additionalSchema = (
104
104
  isObject(schema[ADDITIONAL_PROPERTIES_KEY]) ? schema[ADDITIONAL_PROPERTIES_KEY] : {}
105
105
  ) as S;
106
- const definedProperties = get(schema, PROPERTIES_KEY, {});
106
+ const definedProperties = schema[PROPERTIES_KEY] ?? {};
107
107
  for (const key of Object.keys((formData ?? {}) as GenericObjectType)) {
108
108
  if (!(key in definedProperties)) {
109
109
  (pathSchema as PathSchema<GenericObjectType>)[key] = toPathSchemaInternal<T, S, F>(
@@ -111,7 +111,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
111
111
  additionalSchema,
112
112
  `${name}.${key}`,
113
113
  rootSchema,
114
- get(formData, [key]),
114
+ getByPath<T>(formData, key),
115
115
  _recurseList,
116
116
  experimental_customMergeAllOf,
117
117
  );
@@ -166,7 +166,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
166
166
  // This is a deprecated function that is no longer used by RJSF
167
167
  // oxlint-disable-next-line guard-for-in
168
168
  for (const property in schema.properties) {
169
- const field: S = get(schema, [PROPERTIES_KEY, property], {}) as S;
169
+ const field = getPropertySchema<S>(schema, property);
170
170
  (pathSchema as PathSchema<GenericObjectType>)[property] = toPathSchemaInternal<T, S, F>(
171
171
  validator,
172
172
  field,
@@ -174,7 +174,7 @@ function toPathSchemaInternal<T = any, S extends StrictRJSFSchema = RJSFSchema,
174
174
  rootSchema,
175
175
  // It's possible that formData is not an object -- this can happen if an
176
176
  // array item has just been added, but not populated with data yet
177
- get(formData, [property]),
177
+ getByPath<T>(formData, property),
178
178
  _recurseList,
179
179
  experimental_customMergeAllOf,
180
180
  );
@@ -1,4 +1,4 @@
1
- import type { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
2
2
 
3
3
  /** Check to see if a `schema` specifies that a value must be true. This happens when:
4
4
  * - `schema.const` is truthy
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ import type React from 'react';
2
2
 
3
- import deepEquals from './deepEquals';
4
- import shallowEquals from './shallowEquals';
3
+ import deepEquals from './deepEquals.ts';
4
+ import shallowEquals from './shallowEquals.ts';
5
5
 
6
6
  /** The supported component update strategies */
7
7
  export type ComponentUpdateStrategy = 'customDeep' | 'shallow' | 'always';
@@ -1,11 +1,9 @@
1
- import isObject from 'lodash/isObject';
2
- import uniq from 'lodash/uniq';
3
-
4
- import { ANY_OF_KEY, ONE_OF_KEY } from './constants';
5
- import getSchemaType from './getSchemaType';
6
- import getUiOptions from './getUiOptions';
7
- import isRootSchema from './isRootSchema';
8
- import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
1
+ import { ANY_OF_KEY, ONE_OF_KEY } from './constants.ts';
2
+ import getSchemaType from './getSchemaType.ts';
3
+ import getUiOptions from './getUiOptions.ts';
4
+ import isObject from './isObject.ts';
5
+ import isRootSchema from './isRootSchema.ts';
6
+ import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.ts';
9
7
 
10
8
  /** Returns the unique list of schema types for all of the options in a anyOf/oneOf
11
9
  *
@@ -13,12 +11,14 @@ import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema
13
11
  * @returns - All of the unique types contained within the oneOf list
14
12
  */
15
13
  export function getSchemaTypesForXxxOf<S extends StrictRJSFSchema = RJSFSchema>(schemas: S[]): string | string[] {
16
- const allTypes: string[] = uniq(
17
- schemas
18
- .map((s) => (isObject(s) ? getSchemaType(s) : undefined))
19
- .flat()
20
- .filter((t) => t !== undefined),
21
- );
14
+ const allTypes: string[] = [
15
+ ...new Set(
16
+ schemas
17
+ .map((s) => (isObject(s) ? getSchemaType(s) : undefined))
18
+ .flat()
19
+ .filter((t) => t !== undefined),
20
+ ),
21
+ ];
22
22
  return allTypes.length === 1 ? allTypes[0] : allTypes;
23
23
  }
24
24
 
package/src/toConstant.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CONST_KEY, ENUM_KEY } from './constants';
2
- import type { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import { CONST_KEY, ENUM_KEY } from './constants.ts';
2
+ import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
3
3
 
4
4
  /** Returns the constant value from the schema when it is either a single value enum or has a const key. Otherwise
5
5
  * throws an error.
@@ -1,4 +1,4 @@
1
- import type { DateObject } from './types';
1
+ import type { DateObject } from './types.ts';
2
2
 
3
3
  /** Returns a UTC date string for the given `dateObject`. If `time` is false, then the time portion of the string is
4
4
  * removed.
@@ -1,7 +1,6 @@
1
- import isPlainObject from 'lodash/isPlainObject';
2
-
3
- import { ERRORS_KEY } from './constants';
4
- import type { ErrorSchema, GenericObjectType, RJSFValidationError } from './types';
1
+ import { ERRORS_KEY } from './constants.ts';
2
+ import isPlainObject from './isPlainObject.ts';
3
+ import type { ErrorSchema, RJSFValidationError } from './types.ts';
5
4
 
6
5
  /** Converts an `errorSchema` into a list of `RJSFValidationErrors`
7
6
  *
@@ -13,28 +12,26 @@ export default function toErrorList<T = any>(
13
12
  errorSchema?: ErrorSchema<T>,
14
13
  fieldPath: string[] = [],
15
14
  ): RJSFValidationError[] {
16
- if (!errorSchema) {
17
- return [];
18
- }
19
- let errorList: RJSFValidationError[] = [];
20
- if (ERRORS_KEY in errorSchema) {
21
- errorList = errorList.concat(
22
- errorSchema[ERRORS_KEY]!.map((message: string) => {
23
- const property = `.${fieldPath.join('.')}`;
24
- return {
25
- property,
26
- message,
27
- stack: `${property} ${message}`,
28
- };
29
- }),
30
- );
31
- }
15
+ return errorSchema ? errorsFrom(errorSchema, fieldPath) : [];
16
+ }
17
+
18
+ /** Does the actual conversion, working on the plain-object shape of an `ErrorSchema` so that the recursive call for a
19
+ * nested error schema does not need an assertion back to `ErrorSchema`.
20
+ *
21
+ * @param errorSchema - The error schema, viewed as the plain object it is at runtime
22
+ * @param fieldPath - The current field path
23
+ * @returns - The list of `RJSFValidationErrors` extracted from the `errorSchema`
24
+ */
25
+ function errorsFrom(errorSchema: Record<string, unknown>, fieldPath: string[]): RJSFValidationError[] {
26
+ const errors = errorSchema[ERRORS_KEY];
27
+ const property = `.${fieldPath.join('.')}`;
28
+ const errorList: RJSFValidationError[] = Array.isArray(errors)
29
+ ? errors.map((message: string) => ({ property, message, stack: `${property} ${message}` }))
30
+ : [];
32
31
  return Object.keys(errorSchema).reduce((currentList, key) => {
33
- if (key !== ERRORS_KEY) {
34
- const childSchema = (errorSchema as GenericObjectType)[key];
35
- if (isPlainObject(childSchema)) {
36
- return currentList.concat(toErrorList(childSchema, [...fieldPath, key]));
37
- }
32
+ const childSchema = errorSchema[key];
33
+ if (key !== ERRORS_KEY && isPlainObject(childSchema)) {
34
+ return currentList.concat(errorsFrom(childSchema, [...fieldPath, key]));
38
35
  }
39
36
  return currentList;
40
37
  }, errorList);
@@ -1,7 +1,6 @@
1
- import toPath from 'lodash/toPath';
2
-
3
- import ErrorSchemaBuilder from './ErrorSchemaBuilder';
4
- import type { ErrorSchema, RJSFValidationError } from './types';
1
+ import ErrorSchemaBuilder from './ErrorSchemaBuilder.ts';
2
+ import { toPath } from './pathUtils.ts';
3
+ import type { ErrorSchema, RJSFValidationError } from './types.ts';
5
4
 
6
5
  /** Transforms a rjsf validation errors list:
7
6
  * [
@@ -27,13 +26,8 @@ export default function toErrorSchema<T = any>(errors: RJSFValidationError[]): E
27
26
  if (errors.length) {
28
27
  errors.forEach((error) => {
29
28
  const { property, message } = error;
30
- // When the property is the root element, just use an empty array for the path
31
- const path = property === '.' ? [] : toPath(property);
32
- // If the property is at the root (.level1) then toPath creates
33
- // an empty array element at the first index. Remove it.
34
- if (path.length > 0 && path[0] === '') {
35
- path.splice(0, 1);
36
- }
29
+ // When the property is missing or the root element ('.'), toPath produces an empty path
30
+ const path = property ? toPath(property) : [];
37
31
  if (message) {
38
32
  builder.addErrors(message, path);
39
33
  }
@@ -1,5 +1,5 @@
1
- import { ID_KEY } from './constants';
2
- import type { FieldPathId, FieldPathList, GlobalFormOptions } from './types';
1
+ import { ID_KEY } from './constants.ts';
2
+ import type { FieldPathId, FieldPathList, GlobalFormOptions } from './types.ts';
3
3
 
4
4
  /** Constructs the `FieldPathId` for `fieldPath`. If `parentPathId` is provided, the `fieldPath` is appended to the end
5
5
  * of the parent path. Then the `ID_KEY` of the resulting `FieldPathId` is constructed from the `idPrefix` and
package/src/types.ts CHANGED
@@ -10,8 +10,8 @@ import type {
10
10
  } from 'react';
11
11
  import type { JSONSchema7 } from 'json-schema';
12
12
 
13
- import type { TranslatableString } from './enums';
14
- import './jsonSchemaAugmentation';
13
+ import type { TranslatableString } from './enums.ts';
14
+ import './jsonSchemaAugmentation.ts';
15
15
 
16
16
  /** The representation of any generic object type, usually used as an intersection on other types to make them more
17
17
  * flexible in the properties they support (i.e. anything else)
@@ -185,6 +185,8 @@ export interface InputPropsType {
185
185
  max?: number | string;
186
186
  /** Specifies the `autoComplete` value for an <input> element */
187
187
  autoComplete?: HTMLInputElement['autocomplete'];
188
+ /** Specifies the `autoCapitalize` value for an <input> element */
189
+ autoCapitalize?: HTMLInputElement['autocapitalize'];
188
190
  /** Specifies a filter for what file types the user can upload. */
189
191
  accept?: HTMLInputElement['accept'];
190
192
  }
@@ -1025,7 +1027,12 @@ export interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F
1025
1027
  /** The definition of a React-based Widget component */
1026
1028
  export type Widget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = ComponentType<
1027
1029
  WidgetProps<T, S, F>
1028
- >;
1030
+ > & {
1031
+ /** A cached wrapper component that merges the widget's `defaultProps.options` into its props, stamped onto the
1032
+ * widget by `getWidget()` so that repeated lookups return the same component for proper React reconciliation
1033
+ */
1034
+ MergedWidget?: Widget<T, S, F>;
1035
+ };
1029
1036
 
1030
1037
  /** The properties that are passed to the BaseInputTemplate */
1031
1038
  export interface BaseInputTemplateProps<
@@ -1137,6 +1144,8 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
1137
1144
  autofocus?: boolean;
1138
1145
  /** Use to mark the field as supporting auto complete on a text input or textarea input */
1139
1146
  autocomplete?: HTMLInputElement['autocomplete'];
1147
+ /** Controls automatic capitalization for text entered on supporting virtual keyboards */
1148
+ autocapitalize?: HTMLInputElement['autocapitalize'];
1140
1149
  /** Flag, if set to `true`, will mark all child widgets from a given field as disabled */
1141
1150
  disabled?: boolean;
1142
1151
  /** The default value to use when an input for a field is empty */
@@ -1435,8 +1444,8 @@ export interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchem
1435
1444
  * @returns - The firstindex of the matched option or 0 if none is available
1436
1445
  */
1437
1446
  getFirstMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string): number;
1438
- /** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas
1439
- * containing potentially nested `$ref`s.
1447
+ /** Reads the value at `path` within a schema, additionally retrieving `$ref`s as needed to resolve
1448
+ * schemas containing potentially nested `$ref`s.
1440
1449
  *
1441
1450
  * @param schema - The current node within the JSON schema recursion
1442
1451
  * @param path - The remaining keys in the path to the desired property
@@ -1,6 +1,5 @@
1
- import isPlainObject from 'lodash/isPlainObject';
2
-
3
- import type { ErrorSchema, FormValidation, GenericObjectType } from './types';
1
+ import isPlainObject from './isPlainObject.ts';
2
+ import type { ErrorSchema, FormValidation } from './types.ts';
4
3
 
5
4
  /** Unwraps the `errorHandler` structure into the associated `ErrorSchema`, stripping the `addError()` functions from it
6
5
  *
@@ -8,15 +7,25 @@ import type { ErrorSchema, FormValidation, GenericObjectType } from './types';
8
7
  * @returns - The `ErrorSchema` resulting from the stripping of the `addError()` function
9
8
  */
10
9
  export default function unwrapErrorHandler<T = any>(errorHandler: FormValidation<T>): ErrorSchema<T> {
11
- return Object.keys(errorHandler).reduce<ErrorSchema<T>>((acc, key) => {
10
+ return unwrapErrors<T>(errorHandler);
11
+ }
12
+
13
+ /** Does the actual unwrapping, working on the plain-object shape of a `FormValidation` so that the recursive call for
14
+ * a nested error handler does not need an assertion back to `FormValidation`.
15
+ *
16
+ * @param errors - The error handling structure, viewed as the plain object it is at runtime
17
+ * @returns - The `ErrorSchema` resulting from the stripping of the `addError()` function
18
+ */
19
+ function unwrapErrors<T>(errors: Record<string, unknown>): ErrorSchema<T> {
20
+ return Object.keys(errors).reduce<ErrorSchema<T>>((acc, key) => {
12
21
  if (key === 'addError') {
13
22
  return acc;
14
23
  }
15
- const childSchema = (errorHandler as GenericObjectType)[key];
24
+ const childSchema = errors[key];
16
25
  if (isPlainObject(childSchema)) {
17
26
  return {
18
27
  ...acc,
19
- [key]: unwrapErrorHandler(childSchema),
28
+ [key]: unwrapErrors<T>(childSchema),
20
29
  };
21
30
  }
22
31
  return { ...acc, [key]: childSchema };
@@ -3,13 +3,13 @@
3
3
  import type { MouseEvent } from 'react';
4
4
  import { useCallback, useEffect, useMemo, useState } from 'react';
5
5
 
6
- import dateRangeOptions from './dateRangeOptions';
7
- import type { DateElementFormat, DateElementProp } from './getDateElementProps';
8
- import getDateElementProps from './getDateElementProps';
9
- import { ariaDescribedByIds } from './idGenerators';
10
- import parseDateString from './parseDateString';
11
- import toDateString from './toDateString';
12
- import type { DateObject, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from './types';
6
+ import dateRangeOptions from './dateRangeOptions.ts';
7
+ import type { DateElementFormat, DateElementProp } from './getDateElementProps.ts';
8
+ import getDateElementProps from './getDateElementProps.ts';
9
+ import { ariaDescribedByIds } from './idGenerators.ts';
10
+ import parseDateString from './parseDateString.ts';
11
+ import toDateString from './toDateString.ts';
12
+ import type { DateObject, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from './types.ts';
13
13
 
14
14
  /** Function that checks to see if a `DateObject` is ready for the onChange callback to be triggered
15
15
  *
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useRef } from 'react';
4
4
 
5
- import deepEquals from './deepEquals';
5
+ import deepEquals from './deepEquals.ts';
6
6
 
7
7
  /** Hook that stores and returns a `T` value. If `newValue` is the same as the stored one, then the stored one is
8
8
  * returned to avoid having a component rerender due it being a different object. Otherwise, the `newValue` is stored
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useCallback, useMemo } from 'react';
4
4
 
5
- import dataURItoBlob from './dataURItoBlob';
5
+ import dataURItoBlob from './dataURItoBlob.ts';
6
6
 
7
7
  /** The information about files used by a FileWidget */
8
8
  export interface FileInfoType {
package/src/utcToLocal.ts CHANGED
@@ -1,4 +1,4 @@
1
- import pad from './pad';
1
+ import pad from './pad.ts';
2
2
 
3
3
  /** Converts a UTC date string into a local Date format
4
4
  *
@@ -1,8 +1,6 @@
1
- import isEmpty from 'lodash/isEmpty';
2
-
3
- import mergeObjects from './mergeObjects';
4
- import toErrorList from './toErrorList';
5
- import type { ErrorSchema, ValidationData } from './types';
1
+ import mergeObjects from './mergeObjects.ts';
2
+ import toErrorList from './toErrorList.ts';
3
+ import type { ErrorSchema, ValidationData } from './types.ts';
6
4
 
7
5
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
8
6
  * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
@@ -25,7 +23,7 @@ export default function validationDataMerge<T = any>(
25
23
  const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
26
24
  let errors = toErrorList(additionalErrorSchema);
27
25
  let errorSchema = additionalErrorSchema;
28
- if (!isEmpty(oldErrorSchema)) {
26
+ if (oldErrorSchema && Object.keys(oldErrorSchema).length > 0) {
29
27
  errorSchema = mergeObjects(
30
28
  oldErrorSchema,
31
29
  additionalErrorSchema,
@@ -1,7 +1,6 @@
1
- import isObject from 'lodash/isObject';
2
-
3
- import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants';
4
- import type { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants.ts';
2
+ import isObject from './isObject.ts';
3
+ import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
5
4
 
6
5
  /** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling
7
6
  * `withIdRefPrefix` for any other elements.