@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
package/src/index.ts CHANGED
@@ -1,39 +1,40 @@
1
- import allowAdditionalItems from './allowAdditionalItems';
2
- import asNumber from './asNumber';
3
- import canExpand from './canExpand';
4
- import createErrorHandler from './createErrorHandler';
5
- import createSchemaUtils from './createSchemaUtils';
6
- import dataURItoBlob from './dataURItoBlob';
7
- import dateRangeOptions from './dateRangeOptions';
8
- import deepEquals from './deepEquals';
9
- import englishStringTranslator from './englishStringTranslator';
10
- import enumOptionsDeselectValue from './enumOptionsDeselectValue';
11
- import enumOptionSelectedValue from './enumOptionSelectedValue';
12
- import enumOptionsIndexForValue from './enumOptionsIndexForValue';
13
- import enumOptionsIsSelected from './enumOptionsIsSelected';
14
- import enumOptionsSelectValue from './enumOptionsSelectValue';
15
- import enumOptionsValueForIndex from './enumOptionsValueForIndex';
16
- import enumOptionValueDecoder from './enumOptionValueDecoder';
17
- import enumOptionValueEncoder from './enumOptionValueEncoder';
18
- import ErrorSchemaBuilder from './ErrorSchemaBuilder';
19
- import findSchemaDefinition from './findSchemaDefinition';
20
- import getChangedFields from './getChangedFields';
21
- import type { DateElementFormat, DateElementProp } from './getDateElementProps';
22
- import getDateElementProps from './getDateElementProps';
23
- import getDecimalSeparator from './getDecimalSeparator';
24
- import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';
25
- import getInputProps from './getInputProps';
26
- import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator';
27
- import getOptionValueFormat from './getOptionValueFormat';
28
- import getSchemaType from './getSchemaType';
29
- import getSubmitButtonOptions from './getSubmitButtonOptions';
30
- import getTemplate from './getTemplate';
31
- import getTestIds from './getTestIds';
32
- import getUiOptions from './getUiOptions';
33
- import getWidget from './getWidget';
34
- import guessType from './guessType';
35
- import hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema';
36
- import hasWidget from './hasWidget';
1
+ import allowAdditionalItems from './allowAdditionalItems.ts';
2
+ import asNumber from './asNumber.ts';
3
+ import canExpand from './canExpand.ts';
4
+ import createErrorHandler from './createErrorHandler.ts';
5
+ import createSchemaUtils from './createSchemaUtils.ts';
6
+ import dataURItoBlob from './dataURItoBlob.ts';
7
+ import dateRangeOptions from './dateRangeOptions.ts';
8
+ import deepEquals from './deepEquals.ts';
9
+ import englishStringTranslator from './englishStringTranslator.ts';
10
+ import enumOptionsDeselectValue from './enumOptionsDeselectValue.ts';
11
+ import enumOptionSelectedValue from './enumOptionSelectedValue.ts';
12
+ import enumOptionsIndexForValue from './enumOptionsIndexForValue.ts';
13
+ import enumOptionsIsSelected from './enumOptionsIsSelected.ts';
14
+ import enumOptionsSelectValue from './enumOptionsSelectValue.ts';
15
+ import enumOptionsValueForIndex from './enumOptionsValueForIndex.ts';
16
+ import enumOptionValueDecoder from './enumOptionValueDecoder.ts';
17
+ import enumOptionValueEncoder from './enumOptionValueEncoder.ts';
18
+ import ErrorSchemaBuilder from './ErrorSchemaBuilder.ts';
19
+ import findSchemaDefinition from './findSchemaDefinition.ts';
20
+ import getChangedFields from './getChangedFields.ts';
21
+ import type { DateElementFormat, DateElementProp } from './getDateElementProps.ts';
22
+ import getDateElementProps from './getDateElementProps.ts';
23
+ import getDecimalSeparator from './getDecimalSeparator.ts';
24
+ import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema.ts';
25
+ import getInputProps from './getInputProps.ts';
26
+ import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator.ts';
27
+ import getOptionValueFormat from './getOptionValueFormat.ts';
28
+ import getPropertySchema from './getPropertySchema.ts';
29
+ import getSchemaType from './getSchemaType.ts';
30
+ import getSubmitButtonOptions from './getSubmitButtonOptions.ts';
31
+ import getTemplate from './getTemplate.ts';
32
+ import getTestIds from './getTestIds.ts';
33
+ import getUiOptions from './getUiOptions.ts';
34
+ import getWidget from './getWidget.tsx';
35
+ import guessType from './guessType.ts';
36
+ import hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema.ts';
37
+ import hasWidget from './hasWidget.ts';
37
38
  import {
38
39
  ariaDescribedByIds,
39
40
  buttonId,
@@ -44,57 +45,61 @@ import {
44
45
  optionalControlsId,
45
46
  optionId,
46
47
  titleId,
47
- } from './idGenerators';
48
- import isConstant from './isConstant';
49
- import isCustomWidget from './isCustomWidget';
50
- import isFixedItems from './isFixedItems';
51
- import isFormDataAvailable from './isFormDataAvailable';
52
- import isObject from './isObject';
53
- import isRootSchema from './isRootSchema';
54
- import labelValue from './labelValue';
55
- import localToUTC from './localToUTC';
56
- import logUnsupportedDefaultForEnum from './logUnsupportedDefaultForEnum';
57
- import lookupFromFormContext from './lookupFromFormContext';
58
- import mergeDefaultsWithFormData from './mergeDefaultsWithFormData';
59
- import mergeObjects from './mergeObjects';
60
- import mergeSchemas from './mergeSchemas';
61
- import { bracketNameGenerator, dotNotationNameGenerator } from './nameGenerators';
62
- import optionsList from './optionsList';
63
- import orderProperties from './orderProperties';
64
- import pad from './pad';
65
- import parseDateString from './parseDateString';
66
- import rangeSpec from './rangeSpec';
67
- import removeOptionalEmptyObjects from './removeOptionalEmptyObjects';
68
- import replaceStringParameters from './replaceStringParameters';
69
- import resolveUiSchema from './resolveUiSchema';
70
- import schemaRequiresTrueValue from './schemaRequiresTrueValue';
71
- import SelectedOptionDescription from './SelectedOptionDescription';
72
- import type { SelectedOptionDescriptionProps } from './SelectedOptionDescription';
73
- import shallowEquals from './shallowEquals';
74
- import type { ComponentUpdateStrategy } from './shouldRender';
75
- import shouldRender from './shouldRender';
76
- import shouldRenderOptionalField from './shouldRenderOptionalField';
77
- import toConstant from './toConstant';
78
- import toDateString from './toDateString';
79
- import toErrorList from './toErrorList';
80
- import toErrorSchema from './toErrorSchema';
81
- import toFieldPathId from './toFieldPathId';
82
- import unwrapErrorHandler from './unwrapErrorHandler';
83
- import type { DateElementProps, UseAltDateWidgetResult } from './useAltDateWidgetProps';
84
- import useAltDateWidgetProps, { DateElement } from './useAltDateWidgetProps';
85
- import useDeepCompareMemo from './useDeepCompareMemo';
86
- import type { FileInfoType, UseFileWidgetPropsResult } from './useFileWidgetProps';
87
- import useFileWidgetProps from './useFileWidgetProps';
88
- import utcToLocal from './utcToLocal';
89
- import validationDataMerge from './validationDataMerge';
90
- import withIdRefPrefix from './withIdRefPrefix';
48
+ } from './idGenerators.ts';
49
+ import isConstant from './isConstant.ts';
50
+ import isCustomWidget from './isCustomWidget.ts';
51
+ import isFixedItems from './isFixedItems.ts';
52
+ import isFormDataAvailable from './isFormDataAvailable.ts';
53
+ import isObject from './isObject.ts';
54
+ import isPlainObject from './isPlainObject.ts';
55
+ import isRootSchema from './isRootSchema.ts';
56
+ import labelValue from './labelValue.ts';
57
+ import localToUTC from './localToUTC.ts';
58
+ import logUnsupportedDefaultForEnum from './logUnsupportedDefaultForEnum.ts';
59
+ import lookupFromFormContext from './lookupFromFormContext.ts';
60
+ import mergeDefaultsWithFormData from './mergeDefaultsWithFormData.ts';
61
+ import mergeObjects from './mergeObjects.ts';
62
+ import mergeSchemas from './mergeSchemas.ts';
63
+ import { bracketNameGenerator, dotNotationNameGenerator } from './nameGenerators.ts';
64
+ import noop from './noop.ts';
65
+ import optionsList from './optionsList.ts';
66
+ import orderProperties from './orderProperties.ts';
67
+ import pad from './pad.ts';
68
+ import parseDateString from './parseDateString.ts';
69
+ import { getByPath, hasByPath, setByPath, toPath, unsetByPath } from './pathUtils.ts';
70
+ import type { ObjectPath } from './pathUtils.ts';
71
+ import rangeSpec from './rangeSpec.ts';
72
+ import removeOptionalEmptyObjects from './removeOptionalEmptyObjects.ts';
73
+ import replaceStringParameters from './replaceStringParameters.ts';
74
+ import resolveUiSchema from './resolveUiSchema.ts';
75
+ import schemaRequiresTrueValue from './schemaRequiresTrueValue.ts';
76
+ import SelectedOptionDescription from './SelectedOptionDescription.tsx';
77
+ import type { SelectedOptionDescriptionProps } from './SelectedOptionDescription.tsx';
78
+ import shallowEquals from './shallowEquals.ts';
79
+ import type { ComponentUpdateStrategy } from './shouldRender.ts';
80
+ import shouldRender from './shouldRender.ts';
81
+ import shouldRenderOptionalField from './shouldRenderOptionalField.ts';
82
+ import toConstant from './toConstant.ts';
83
+ import toDateString from './toDateString.ts';
84
+ import toErrorList from './toErrorList.ts';
85
+ import toErrorSchema from './toErrorSchema.ts';
86
+ import toFieldPathId from './toFieldPathId.ts';
87
+ import unwrapErrorHandler from './unwrapErrorHandler.ts';
88
+ import type { DateElementProps, UseAltDateWidgetResult } from './useAltDateWidgetProps.tsx';
89
+ import useAltDateWidgetProps, { DateElement } from './useAltDateWidgetProps.tsx';
90
+ import useDeepCompareMemo from './useDeepCompareMemo.ts';
91
+ import type { FileInfoType, UseFileWidgetPropsResult } from './useFileWidgetProps.ts';
92
+ import useFileWidgetProps from './useFileWidgetProps.ts';
93
+ import utcToLocal from './utcToLocal.ts';
94
+ import validationDataMerge from './validationDataMerge.ts';
95
+ import withIdRefPrefix from './withIdRefPrefix.ts';
91
96
 
92
- export type * from './types';
93
- export * from './enums';
97
+ export type * from './types.ts';
98
+ export * from './enums.ts';
94
99
 
95
- export * from './constants';
96
- export * from './parser';
97
- export * from './schema';
100
+ export * from './constants.ts';
101
+ export * from './parser/index.ts';
102
+ export * from './schema/index.ts';
98
103
 
99
104
  export type {
100
105
  ComponentUpdateStrategy,
@@ -102,6 +107,7 @@ export type {
102
107
  DateElementProp,
103
108
  DateElementProps,
104
109
  FileInfoType,
110
+ ObjectPath,
105
111
  SelectedOptionDescriptionProps,
106
112
  UseAltDateWidgetResult,
107
113
  UseFileWidgetPropsResult,
@@ -139,14 +145,17 @@ export {
139
145
  getDiscriminatorFieldFromSchema,
140
146
  getInputProps,
141
147
  getOptionMatchingSimpleDiscriminator,
148
+ getPropertySchema,
142
149
  getOptionValueFormat,
143
150
  getSchemaType,
151
+ getByPath,
144
152
  getSubmitButtonOptions,
145
153
  getTemplate,
146
154
  getTestIds,
147
155
  getUiOptions,
148
156
  getWidget,
149
157
  guessType,
158
+ hasByPath,
150
159
  hasWidget,
151
160
  hashForSchema,
152
161
  hashObject,
@@ -157,6 +166,7 @@ export {
157
166
  isFixedItems,
158
167
  isFormDataAvailable,
159
168
  isObject,
169
+ isPlainObject,
160
170
  isRootSchema,
161
171
  labelValue,
162
172
  localToUTC,
@@ -165,6 +175,7 @@ export {
165
175
  mergeDefaultsWithFormData,
166
176
  mergeObjects,
167
177
  mergeSchemas,
178
+ noop,
168
179
  optionalControlsId,
169
180
  optionId,
170
181
  optionsList,
@@ -177,6 +188,7 @@ export {
177
188
  replaceStringParameters,
178
189
  resolveUiSchema,
179
190
  schemaRequiresTrueValue,
191
+ setByPath,
180
192
  SelectedOptionDescription,
181
193
  shallowEquals,
182
194
  shouldRender,
@@ -188,6 +200,8 @@ export {
188
200
  toErrorList,
189
201
  toErrorSchema,
190
202
  toFieldPathId,
203
+ toPath,
204
+ unsetByPath,
191
205
  unwrapErrorHandler,
192
206
  useAltDateWidgetProps,
193
207
  useDeepCompareMemo,
package/src/isConstant.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CONST_KEY } from './constants';
2
- import type { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import { CONST_KEY } from './constants.ts';
2
+ import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
3
3
 
4
4
  /** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
5
5
  * an `enum` array with a single value or there is a `const` defined.
@@ -1,5 +1,5 @@
1
- import getUiOptions from './getUiOptions';
2
- import type { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
1
+ import getUiOptions from './getUiOptions.ts';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.ts';
3
3
 
4
4
  /** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
5
5
  *
@@ -1,5 +1,5 @@
1
- import isObject from './isObject';
2
- import type { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import isObject from './isObject.ts';
2
+ import type { RJSFSchema, StrictRJSFSchema } from './types.ts';
3
3
 
4
4
  /** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is an array that only
5
5
  * contains objects.
@@ -1,7 +1,3 @@
1
- import isEmpty from 'lodash/isEmpty';
2
- import isNil from 'lodash/isNil';
3
- import isObject from 'lodash/isObject';
4
-
5
1
  /** Determines whether the given `formData` represents valid form data, such as a primitive type, an array, or a
6
2
  * non-empty object.
7
3
  *
@@ -9,5 +5,11 @@ import isObject from 'lodash/isObject';
9
5
  * @returns - True if `formData` is not undefined, null, a primitive type or an array or an empty object
10
6
  */
11
7
  export default function isFormDataAvailable<T = any>(formData?: T): boolean {
12
- return !isNil(formData) && (!isObject(formData) || Array.isArray(formData) || !isEmpty(formData));
8
+ if (formData === undefined || formData === null) {
9
+ return false;
10
+ }
11
+ if (typeof formData !== 'object' || Array.isArray(formData)) {
12
+ return true;
13
+ }
14
+ return Object.keys(formData).length > 0;
13
15
  }
package/src/isObject.ts CHANGED
@@ -1,21 +1,33 @@
1
+ import type { GenericObjectType } from './types.ts';
2
+
1
3
  /** Determines whether a `thing` is an object for the purposes of RJSF. In this case, `thing` is an object if it has
2
4
  * the type `object` but is NOT null, an array or a File.
3
5
  *
4
6
  * @param thing - The thing to check to see whether it is an object
5
7
  * @returns - True if it is a non-null, non-array, non-File object
6
8
  */
7
- export default function isObject(thing: any): thing is object {
9
+ export default function isObject(thing: unknown): thing is GenericObjectType {
8
10
  if (typeof thing !== 'object' || thing === null) {
9
11
  return false;
10
12
  }
11
13
  // lastModified is guaranteed to be a number on a File instance
12
14
  // as per https://w3c.github.io/FileAPI/#dfn-lastModified
13
- if (typeof thing.lastModified === 'number' && typeof File !== 'undefined' && thing instanceof File) {
15
+ if (
16
+ 'lastModified' in thing &&
17
+ typeof thing.lastModified === 'number' &&
18
+ typeof File !== 'undefined' &&
19
+ thing instanceof File
20
+ ) {
14
21
  return false;
15
22
  }
16
23
  // getMonth is guaranteed to be a method on a Date instance
17
24
  // as per https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getmonth
18
- if (typeof thing.getMonth === 'function' && typeof Date !== 'undefined' && thing instanceof Date) {
25
+ if (
26
+ 'getMonth' in thing &&
27
+ typeof thing.getMonth === 'function' &&
28
+ typeof Date !== 'undefined' &&
29
+ thing instanceof Date
30
+ ) {
19
31
  return false;
20
32
  }
21
33
  return !Array.isArray(thing);
@@ -0,0 +1,14 @@
1
+ /** Determines whether `thing` is a plain object, i.e. one created by the `Object` constructor or with a `null`
2
+ * prototype. Unlike `isObject()`, class instances such as `Error` are not plain objects, which matters when
3
+ * recursively walking a structure whose nested values are expected to be plain data.
4
+ *
5
+ * @param thing - The thing to check to see whether it is a plain object
6
+ * @returns - True if it is a plain object, otherwise false
7
+ */
8
+ export default function isPlainObject(thing: unknown): thing is Record<string, unknown> {
9
+ if (typeof thing !== 'object' || thing === null) {
10
+ return false;
11
+ }
12
+ const proto = Object.getPrototypeOf(thing);
13
+ return proto === null || proto === Object.prototype;
14
+ }
@@ -1,6 +1,6 @@
1
- import { REF_KEY } from './constants';
2
- import deepEquals from './deepEquals';
3
- import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema } from './types';
1
+ import { REF_KEY } from './constants.ts';
2
+ import deepEquals from './deepEquals.ts';
3
+ import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema } from './types.ts';
4
4
 
5
5
  /** Helper to check whether a JSON schema object is the root schema. The schema is a root schema with root `properties`
6
6
  * key or a root `$ref` key. If the `schemaToCompare` has a root `oneOf` property, the function will
@@ -1,5 +1,5 @@
1
- import enumOptionsIndexForValue from './enumOptionsIndexForValue';
2
- import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
1
+ import enumOptionsIndexForValue from './enumOptionsIndexForValue.ts';
2
+ import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.ts';
3
3
 
4
4
  /** Logs a warning when a single-select enum widget has a schema default that is not one of its enum options.
5
5
  *
@@ -1,8 +1,6 @@
1
- import get from 'lodash/get';
2
- import has from 'lodash/has';
3
-
4
- import { FORM_CONTEXT_NAME, LOOKUP_MAP_NAME } from './constants';
5
- import type { FormContextType, RJSFSchema, Registry, StrictRJSFSchema } from './types';
1
+ import { FORM_CONTEXT_NAME, LOOKUP_MAP_NAME } from './constants.ts';
2
+ import { getByPath, hasByPath } from './pathUtils.ts';
3
+ import type { FormContextType, RJSFSchema, Registry, StrictRJSFSchema } from './types.ts';
6
4
 
7
5
  /** Given a React JSON Schema Form registry or formContext object, return the value associated with `toLookup`. This
8
6
  * might be contained within the lookup map in the formContext. If no such value exists, return the `fallback`
@@ -17,10 +15,11 @@ export default function lookupFromFormContext<
17
15
  T = any,
18
16
  S extends StrictRJSFSchema = RJSFSchema,
19
17
  F extends FormContextType = any,
20
- >(regOrFc: Registry<T, S, F> | Registry<T, S, F>['formContext'], toLookup: string, fallback?: unknown) {
18
+ R = unknown,
19
+ >(regOrFc: Registry<T, S, F> | Registry<T, S, F>['formContext'], toLookup: string, fallback?: R): R {
21
20
  const lookupPath = [LOOKUP_MAP_NAME];
22
- if (has(regOrFc, FORM_CONTEXT_NAME)) {
21
+ if (hasByPath(regOrFc, FORM_CONTEXT_NAME)) {
23
22
  lookupPath.unshift(FORM_CONTEXT_NAME);
24
23
  }
25
- return get(regOrFc, [...lookupPath, toLookup], fallback);
24
+ return getByPath<R>(regOrFc, [...lookupPath, toLookup], fallback);
26
25
  }
@@ -1,8 +1,5 @@
1
- import get from 'lodash/get';
2
- import isNil from 'lodash/isNil';
3
-
4
- import type { GenericObjectType } from '../src';
5
- import isObject from './isObject';
1
+ import type { GenericObjectType } from './index.ts';
2
+ import isObject from './isObject.ts';
6
3
 
7
4
  /** Merges the `defaults` object of type `T` into the `formData` of type `T`
8
5
  *
@@ -64,27 +61,34 @@ export default function mergeDefaultsWithFormData<T = any>(
64
61
  if (isObject(formData)) {
65
62
  // oxlint-disable-next-line prefer-object-spread -- spread loses T type, Object.assign preserves it
66
63
  const acc: { [key in keyof T]: any } = Object.assign({}, defaults); // Prevent mutation of source object.
67
- return Object.keys(formData as GenericObjectType).reduce((accumulator, key) => {
68
- const keyValue = get(formData, key);
69
- const keyExistsInDefaults = isObject(defaults) && key in (defaults as GenericObjectType);
70
- const keyExistsInFormData = key in (formData as GenericObjectType);
71
- const keyDefault = get(defaults, key) ?? {};
72
- const defaultValueIsNestedObject =
73
- keyExistsInDefaults && isObject(keyDefault) && Object.values(keyDefault).some((v) => isObject(v));
64
+ const formDataObj: GenericObjectType = formData;
65
+ const defaultsObj: GenericObjectType | undefined = isObject(defaults) ? defaults : undefined;
66
+ return Object.keys(formDataObj).reduce((accumulator, key) => {
67
+ const keyValue = formDataObj[key];
68
+ const keyExistsInDefaults = defaultsObj !== undefined && key in defaultsObj;
69
+ const keyExistsInFormData = key in formDataObj;
70
+ const keyDefault = defaultsObj?.[key] ?? {};
71
+ // If any direct child of this key's default is itself an object or array,
72
+ // the shallow spread below would bypass its merge rules. Route those cases
73
+ // to the recursive path; the recursive call repeats this check one level deeper.
74
+ const defaultValueNeedsDeepMerge =
75
+ keyExistsInDefaults &&
76
+ isObject(keyDefault) &&
77
+ Object.values(keyDefault).some((v) => isObject(v) || Array.isArray(v));
74
78
 
75
- const keyDefaultIsObject = keyExistsInDefaults && isObject(get(defaults, key));
79
+ const keyDefaultIsObject = keyExistsInDefaults && isObject(defaultsObj?.[key]);
76
80
  const keyHasFormDataObject = keyExistsInFormData && isObject(keyValue);
77
81
 
78
- if (keyDefaultIsObject && keyHasFormDataObject && !defaultValueIsNestedObject) {
82
+ if (keyDefaultIsObject && keyHasFormDataObject && !defaultValueNeedsDeepMerge) {
79
83
  accumulator[key as keyof T] = {
80
- ...get(defaults, key),
84
+ ...defaultsObj?.[key],
81
85
  ...keyValue,
82
86
  };
83
87
  return accumulator;
84
88
  }
85
89
 
86
90
  accumulator[key as keyof T] = mergeDefaultsWithFormData<T>(
87
- get(defaults, key),
91
+ defaultsObj?.[key],
88
92
  keyValue,
89
93
  mergeExtraArrayDefaults,
90
94
  defaultSupercedesUndefined,
@@ -104,8 +108,8 @@ export default function mergeDefaultsWithFormData<T = any>(
104
108
  */
105
109
  if (
106
110
  (defaultSupercedesUndefined &&
107
- ((!(defaults === undefined) && isNil(formData)) || (typeof formData === 'number' && Number.isNaN(formData)))) ||
108
- (overrideFormDataWithDefaults && !isNil(formData))
111
+ ((!(defaults === undefined) && formData == null) || (typeof formData === 'number' && Number.isNaN(formData)))) ||
112
+ (overrideFormDataWithDefaults && formData != null)
109
113
  ) {
110
114
  return defaults;
111
115
  }
@@ -1,5 +1,5 @@
1
- import isObject from './isObject';
2
- import type { GenericObjectType } from './types';
1
+ import isObject from './isObject.ts';
2
+ import type { GenericObjectType } from './types.ts';
3
3
 
4
4
  /** Recursively merge deeply nested objects.
5
5
  *
@@ -1,9 +1,7 @@
1
- import union from 'lodash/union';
2
-
3
- import { REQUIRED_KEY } from './constants';
4
- import getSchemaType from './getSchemaType';
5
- import isObject from './isObject';
6
- import type { GenericObjectType, GenericSymbolObjectType } from './types';
1
+ import { REQUIRED_KEY } from './constants.ts';
2
+ import getSchemaType from './getSchemaType.ts';
3
+ import isObject from './isObject.ts';
4
+ import type { GenericObjectType, GenericSymbolObjectType } from './types.ts';
7
5
 
8
6
  /** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
9
7
  * `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include
@@ -29,7 +27,7 @@ export default function mergeSchemas(obj1: GenericObjectType, obj2: GenericObjec
29
27
  Array.isArray(right)
30
28
  ) {
31
29
  // Don't include duplicate values when merging 'required' fields.
32
- accumulator[key] = union(left, right);
30
+ accumulator[key] = [...new Set([...left, ...right])];
33
31
  } else {
34
32
  accumulator[key] = right;
35
33
  }
@@ -1,4 +1,4 @@
1
- import type { NameGeneratorFunction, FieldPathList } from './types';
1
+ import type { NameGeneratorFunction, FieldPathList } from './types.ts';
2
2
 
3
3
  /**
4
4
  * Generates bracketed names
package/src/noop.ts ADDED
@@ -0,0 +1,4 @@
1
+ /** A function that does nothing and returns `undefined`, useful as a placeholder for an optional callback or as the
2
+ * implementation of a mocked function.
3
+ */
4
+ export default function noop(): void {}
@@ -1,10 +1,10 @@
1
- import get from 'lodash/get';
2
-
3
- import { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY } from './constants';
4
- import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';
5
- import getUiOptions from './getUiOptions';
6
- import toConstant from './toConstant';
7
- import type { RJSFSchema, EnumOptionsType, EnumValue, StrictRJSFSchema, FormContextType, UiSchema } from './types';
1
+ import { CONST_KEY, DEFAULT_KEY } from './constants.ts';
2
+ import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema.ts';
3
+ import getPropertySchema from './getPropertySchema.ts';
4
+ import getUiOptions from './getUiOptions.ts';
5
+ import { getByPath } from './pathUtils.ts';
6
+ import toConstant from './toConstant.ts';
7
+ import type { RJSFSchema, EnumOptionsType, EnumValue, StrictRJSFSchema, FormContextType, UiSchema } from './types.ts';
8
8
 
9
9
  /** Reorders `options` according to `order`, which may contain a `'*'` wildcard representing all
10
10
  * remaining options in their original order. Options not listed in `order` (and not covered by
@@ -85,8 +85,8 @@ export default function optionsList<T = any, S extends StrictRJSFSchema = RJSFSc
85
85
  let value: EnumOptionsType<S>['value'];
86
86
  let label = title;
87
87
  if (selectorField) {
88
- const innerSchema: S = get(aSchema, [PROPERTIES_KEY, selectorField], {}) as S;
89
- value = get(innerSchema, DEFAULT_KEY, get(innerSchema, CONST_KEY));
88
+ const innerSchema = getPropertySchema<S>(aSchema, selectorField);
89
+ value = getByPath(innerSchema, DEFAULT_KEY, getByPath(innerSchema, CONST_KEY));
90
90
  // Use nullish coalescing so that an explicitly empty string title is preserved
91
91
  label = label ?? innerSchema?.title ?? aSchema.title ?? String(value);
92
92
  } else {
@@ -1,4 +1,4 @@
1
- import type { GenericObjectType } from './types';
1
+ import type { GenericObjectType } from './types.ts';
2
2
 
3
3
  /** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.
4
4
  * If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per
@@ -1,4 +1,4 @@
1
- import type { DateObject } from './types';
1
+ import type { DateObject } from './types.ts';
2
2
 
3
3
  /** Parses the `dateString` into a `DateObject`, including the time information when `includeTime` is true
4
4
  *
@@ -1,8 +1,6 @@
1
- import get from 'lodash/get';
2
-
3
- import { ID_KEY } from '../constants';
4
- import deepEquals from '../deepEquals';
5
- import hashForSchema from '../hashForSchema';
1
+ import { ID_KEY } from '../constants.ts';
2
+ import deepEquals from '../deepEquals.ts';
3
+ import hashForSchema from '../hashForSchema.ts';
6
4
  import type {
7
5
  CustomValidator,
8
6
  ErrorSchema,
@@ -14,7 +12,7 @@ import type {
14
12
  UiSchema,
15
13
  ValidationData,
16
14
  ValidatorType,
17
- } from '../types';
15
+ } from '../types.ts';
18
16
 
19
17
  /** The type of the map of schema hash to schema
20
18
  */
@@ -62,7 +60,7 @@ export default class ParserValidator<
62
60
  * @param hash - The hash value at which to map the schema
63
61
  */
64
62
  addSchema(schema: S, hash: string) {
65
- const key = get(schema, ID_KEY, hash);
63
+ const key = schema[ID_KEY] ?? hash;
66
64
  const identifiedSchema = { ...schema, [ID_KEY]: key };
67
65
  const existing = this.schemaMap[key];
68
66
  if (!existing) {
@@ -1,5 +1,5 @@
1
- import type { SchemaMap } from './ParserValidator';
2
- import schemaParser from './schemaParser';
1
+ import type { SchemaMap } from './ParserValidator.ts';
2
+ import schemaParser from './schemaParser.ts';
3
3
 
4
4
  export type { SchemaMap };
5
5
 
@@ -1,11 +1,9 @@
1
- import forEach from 'lodash/forEach';
2
-
3
- import { ITEMS_KEY, PROPERTIES_KEY } from '../constants';
4
- import deepEquals from '../deepEquals';
5
- import { resolveAnyOrOneOfSchemas, retrieveSchemaInternal } from '../schema/retrieveSchema';
6
- import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '../types';
7
- import type { SchemaMap } from './ParserValidator';
8
- import ParserValidator from './ParserValidator';
1
+ import { ITEMS_KEY, PROPERTIES_KEY } from '../constants.ts';
2
+ import deepEquals from '../deepEquals.ts';
3
+ import { resolveAnyOrOneOfSchemas, retrieveSchemaInternal } from '../schema/retrieveSchema.ts';
4
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '../types.ts';
5
+ import type { SchemaMap } from './ParserValidator.ts';
6
+ import ParserValidator from './ParserValidator.ts';
9
7
 
10
8
  /** Recursive function used to parse the given `schema` belonging to the `rootSchema`. The `validator` is used to
11
9
  * capture the sub-schemas that the `isValid()` function is called with. For each schema returned by the
@@ -31,9 +29,9 @@ function parseSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
31
29
  const allOptions = resolveAnyOrOneOfSchemas<T, S, F>(validator, localSchema, rootSchema, true);
32
30
  allOptions.forEach((s) => {
33
31
  if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {
34
- forEach(localSchema[PROPERTIES_KEY], (value) => {
32
+ for (const value of Object.values(localSchema[PROPERTIES_KEY] ?? {})) {
35
33
  parseSchema<T, S, F>(validator, recurseList, rootSchema, value as S);
36
- });
34
+ }
37
35
  }
38
36
  });
39
37
  if (ITEMS_KEY in localSchema && !Array.isArray(localSchema.items) && typeof localSchema.items !== 'boolean') {