@rjsf/utils 6.0.0-alpha.0 → 6.0.0-beta.1

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 (279) hide show
  1. package/dist/index.js +1281 -625
  2. package/dist/index.js.map +4 -4
  3. package/dist/utils.esm.js +1254 -598
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +1201 -570
  6. package/lib/ErrorSchemaBuilder.d.ts +8 -4
  7. package/lib/ErrorSchemaBuilder.js +10 -8
  8. package/lib/ErrorSchemaBuilder.js.map +1 -1
  9. package/lib/allowAdditionalItems.d.ts +1 -1
  10. package/lib/allowAdditionalItems.js +1 -1
  11. package/lib/allowAdditionalItems.js.map +1 -1
  12. package/lib/asNumber.js.map +1 -1
  13. package/lib/canExpand.d.ts +1 -1
  14. package/lib/canExpand.js +2 -2
  15. package/lib/canExpand.js.map +1 -1
  16. package/lib/constIsAjvDataReference.d.ts +9 -0
  17. package/lib/constIsAjvDataReference.js +15 -0
  18. package/lib/constIsAjvDataReference.js.map +1 -0
  19. package/lib/constants.d.ts +11 -3
  20. package/lib/constants.js +11 -3
  21. package/lib/constants.js.map +1 -1
  22. package/lib/createErrorHandler.d.ts +1 -1
  23. package/lib/createErrorHandler.js +2 -2
  24. package/lib/createErrorHandler.js.map +1 -1
  25. package/lib/createSchemaUtils.d.ts +3 -2
  26. package/lib/createSchemaUtils.js +56 -46
  27. package/lib/createSchemaUtils.js.map +1 -1
  28. package/lib/dataURItoBlob.js.map +1 -1
  29. package/lib/dateRangeOptions.d.ts +1 -1
  30. package/lib/dateRangeOptions.js +1 -1
  31. package/lib/dateRangeOptions.js.map +1 -1
  32. package/lib/deepEquals.js +1 -1
  33. package/lib/deepEquals.js.map +1 -1
  34. package/lib/englishStringTranslator.d.ts +1 -1
  35. package/lib/englishStringTranslator.js +1 -1
  36. package/lib/enumOptionsDeselectValue.d.ts +1 -1
  37. package/lib/enumOptionsDeselectValue.js +4 -4
  38. package/lib/enumOptionsDeselectValue.js.map +1 -1
  39. package/lib/enumOptionsIndexForValue.d.ts +1 -1
  40. package/lib/enumOptionsIndexForValue.js +1 -1
  41. package/lib/enumOptionsIndexForValue.js.map +1 -1
  42. package/lib/enumOptionsIsSelected.d.ts +1 -1
  43. package/lib/enumOptionsIsSelected.js +3 -3
  44. package/lib/enumOptionsIsSelected.js.map +1 -1
  45. package/lib/enumOptionsSelectValue.d.ts +1 -1
  46. package/lib/enumOptionsSelectValue.js +2 -2
  47. package/lib/enumOptionsSelectValue.js.map +1 -1
  48. package/lib/enumOptionsValueForIndex.d.ts +1 -1
  49. package/lib/enumOptionsValueForIndex.js.map +1 -1
  50. package/lib/enums.d.ts +2 -0
  51. package/lib/enums.js +2 -0
  52. package/lib/enums.js.map +1 -1
  53. package/lib/findSchemaDefinition.d.ts +1 -1
  54. package/lib/findSchemaDefinition.js +2 -2
  55. package/lib/findSchemaDefinition.js.map +1 -1
  56. package/lib/getChangedFields.d.ts +17 -0
  57. package/lib/getChangedFields.js +42 -0
  58. package/lib/getChangedFields.js.map +1 -0
  59. package/lib/getDateElementProps.d.ts +1 -1
  60. package/lib/getDateElementProps.js.map +1 -1
  61. package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
  62. package/lib/getDiscriminatorFieldFromSchema.js +4 -3
  63. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  64. package/lib/getInputProps.d.ts +1 -1
  65. package/lib/getInputProps.js +4 -1
  66. package/lib/getInputProps.js.map +1 -1
  67. package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
  68. package/lib/getOptionMatchingSimpleDiscriminator.js +2 -2
  69. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  70. package/lib/getSchemaType.d.ts +2 -1
  71. package/lib/getSchemaType.js +3 -2
  72. package/lib/getSchemaType.js.map +1 -1
  73. package/lib/getSubmitButtonOptions.d.ts +1 -1
  74. package/lib/getSubmitButtonOptions.js +2 -2
  75. package/lib/getSubmitButtonOptions.js.map +1 -1
  76. package/lib/getTemplate.d.ts +1 -1
  77. package/lib/getTemplate.js +9 -0
  78. package/lib/getTemplate.js.map +1 -1
  79. package/lib/getTestIds.d.ts +17 -0
  80. package/lib/getTestIds.js +34 -0
  81. package/lib/getTestIds.js.map +1 -0
  82. package/lib/getUiOptions.d.ts +1 -1
  83. package/lib/getUiOptions.js +2 -2
  84. package/lib/getUiOptions.js.map +1 -1
  85. package/lib/getWidget.d.ts +1 -1
  86. package/lib/getWidget.js +3 -3
  87. package/lib/getWidget.js.map +1 -1
  88. package/lib/guessType.d.ts +1 -1
  89. package/lib/guessType.js.map +1 -1
  90. package/lib/hasWidget.d.ts +1 -1
  91. package/lib/hasWidget.js +1 -1
  92. package/lib/hasWidget.js.map +1 -1
  93. package/lib/hashForSchema.d.ts +23 -1
  94. package/lib/hashForSchema.js +24 -6
  95. package/lib/hashForSchema.js.map +1 -1
  96. package/lib/idGenerators.d.ts +8 -1
  97. package/lib/idGenerators.js +11 -2
  98. package/lib/idGenerators.js.map +1 -1
  99. package/lib/index.d.ts +63 -60
  100. package/lib/index.js +63 -60
  101. package/lib/index.js.map +1 -1
  102. package/lib/isConstant.d.ts +1 -1
  103. package/lib/isConstant.js +1 -1
  104. package/lib/isCustomWidget.d.ts +1 -1
  105. package/lib/isCustomWidget.js +1 -1
  106. package/lib/isFixedItems.d.ts +1 -1
  107. package/lib/isFixedItems.js +1 -1
  108. package/lib/isObject.d.ts +2 -2
  109. package/lib/isObject.js +11 -4
  110. package/lib/isObject.js.map +1 -1
  111. package/lib/lookupFromFormContext.d.ts +11 -0
  112. package/lib/lookupFromFormContext.js +20 -0
  113. package/lib/lookupFromFormContext.js.map +1 -0
  114. package/lib/mergeDefaultsWithFormData.d.ts +8 -2
  115. package/lib/mergeDefaultsWithFormData.js +39 -10
  116. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  117. package/lib/mergeObjects.d.ts +1 -1
  118. package/lib/mergeObjects.js +1 -1
  119. package/lib/mergeObjects.js.map +1 -1
  120. package/lib/mergeSchemas.d.ts +1 -1
  121. package/lib/mergeSchemas.js +4 -4
  122. package/lib/mergeSchemas.js.map +1 -1
  123. package/lib/optionsList.d.ts +9 -7
  124. package/lib/optionsList.js +30 -19
  125. package/lib/optionsList.js.map +1 -1
  126. package/lib/orderProperties.js.map +1 -1
  127. package/lib/pad.js.map +1 -1
  128. package/lib/parseDateString.d.ts +1 -1
  129. package/lib/parseDateString.js +1 -1
  130. package/lib/parseDateString.js.map +1 -1
  131. package/lib/parser/ParserValidator.d.ts +1 -1
  132. package/lib/parser/ParserValidator.js +6 -6
  133. package/lib/parser/ParserValidator.js.map +1 -1
  134. package/lib/parser/index.d.ts +2 -2
  135. package/lib/parser/index.js +1 -1
  136. package/lib/parser/schemaParser.d.ts +2 -2
  137. package/lib/parser/schemaParser.js +6 -6
  138. package/lib/parser/schemaParser.js.map +1 -1
  139. package/lib/rangeSpec.d.ts +2 -2
  140. package/lib/rangeSpec.js.map +1 -1
  141. package/lib/replaceStringParameters.js.map +1 -1
  142. package/lib/schema/findFieldInSchema.d.ts +19 -0
  143. package/lib/schema/findFieldInSchema.js +61 -0
  144. package/lib/schema/findFieldInSchema.js.map +1 -0
  145. package/lib/schema/findSelectedOptionInXxxOf.d.ts +16 -0
  146. package/lib/schema/findSelectedOptionInXxxOf.js +34 -0
  147. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -0
  148. package/lib/schema/getClosestMatchingOption.d.ts +5 -3
  149. package/lib/schema/getClosestMatchingOption.js +28 -20
  150. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  151. package/lib/schema/getDefaultFormState.d.ts +60 -13
  152. package/lib/schema/getDefaultFormState.js +304 -166
  153. package/lib/schema/getDefaultFormState.js.map +1 -1
  154. package/lib/schema/getDisplayLabel.d.ts +3 -2
  155. package/lib/schema/getDisplayLabel.js +10 -9
  156. package/lib/schema/getDisplayLabel.js.map +1 -1
  157. package/lib/schema/getFirstMatchingOption.d.ts +1 -1
  158. package/lib/schema/getFirstMatchingOption.js +70 -2
  159. package/lib/schema/getFirstMatchingOption.js.map +1 -1
  160. package/lib/schema/getFromSchema.d.ts +14 -0
  161. package/lib/schema/getFromSchema.js +39 -0
  162. package/lib/schema/getFromSchema.js.map +1 -0
  163. package/lib/schema/index.d.ts +15 -14
  164. package/lib/schema/index.js +15 -14
  165. package/lib/schema/index.js.map +1 -1
  166. package/lib/schema/isFilesArray.d.ts +3 -2
  167. package/lib/schema/isFilesArray.js +5 -4
  168. package/lib/schema/isFilesArray.js.map +1 -1
  169. package/lib/schema/isMultiSelect.d.ts +3 -2
  170. package/lib/schema/isMultiSelect.js +4 -3
  171. package/lib/schema/isMultiSelect.js.map +1 -1
  172. package/lib/schema/isSelect.d.ts +3 -2
  173. package/lib/schema/isSelect.js +5 -4
  174. package/lib/schema/isSelect.js.map +1 -1
  175. package/lib/schema/retrieveSchema.d.ts +28 -11
  176. package/lib/schema/retrieveSchema.js +142 -66
  177. package/lib/schema/retrieveSchema.js.map +1 -1
  178. package/lib/schema/sanitizeDataForNewSchema.d.ts +3 -2
  179. package/lib/schema/sanitizeDataForNewSchema.js +12 -11
  180. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  181. package/lib/schema/toIdSchema.d.ts +3 -2
  182. package/lib/schema/toIdSchema.js +30 -27
  183. package/lib/schema/toIdSchema.js.map +1 -1
  184. package/lib/schema/toPathSchema.d.ts +3 -2
  185. package/lib/schema/toPathSchema.js +22 -20
  186. package/lib/schema/toPathSchema.js.map +1 -1
  187. package/lib/schemaRequiresTrueValue.d.ts +1 -1
  188. package/lib/schemaRequiresTrueValue.js.map +1 -1
  189. package/lib/shouldRender.js +1 -1
  190. package/lib/toConstant.d.ts +1 -1
  191. package/lib/toConstant.js +1 -1
  192. package/lib/toConstant.js.map +1 -1
  193. package/lib/toDateString.d.ts +1 -1
  194. package/lib/toErrorList.d.ts +1 -1
  195. package/lib/toErrorList.js +2 -2
  196. package/lib/toErrorList.js.map +1 -1
  197. package/lib/toErrorSchema.d.ts +1 -1
  198. package/lib/toErrorSchema.js +2 -2
  199. package/lib/toErrorSchema.js.map +1 -1
  200. package/lib/tsconfig.tsbuildinfo +1 -1
  201. package/lib/types.d.ts +160 -131
  202. package/lib/unwrapErrorHandler.d.ts +1 -1
  203. package/lib/unwrapErrorHandler.js +1 -1
  204. package/lib/unwrapErrorHandler.js.map +1 -1
  205. package/lib/utcToLocal.js +1 -1
  206. package/lib/utcToLocal.js.map +1 -1
  207. package/lib/validationDataMerge.d.ts +1 -1
  208. package/lib/validationDataMerge.js +3 -3
  209. package/lib/validationDataMerge.js.map +1 -1
  210. package/lib/withIdRefPrefix.d.ts +1 -1
  211. package/lib/withIdRefPrefix.js +2 -2
  212. package/lib/withIdRefPrefix.js.map +1 -1
  213. package/package.json +36 -26
  214. package/src/ErrorSchemaBuilder.ts +15 -8
  215. package/src/canExpand.ts +2 -2
  216. package/src/constIsAjvDataReference.ts +17 -0
  217. package/src/constants.ts +12 -3
  218. package/src/createSchemaUtils.ts +140 -50
  219. package/src/dataURItoBlob.ts +1 -1
  220. package/src/dateRangeOptions.ts +1 -1
  221. package/src/enumOptionsDeselectValue.ts +4 -5
  222. package/src/enumOptionsIndexForValue.ts +1 -1
  223. package/src/enumOptionsIsSelected.ts +4 -5
  224. package/src/enumOptionsSelectValue.ts +1 -1
  225. package/src/enumOptionsValueForIndex.ts +1 -1
  226. package/src/enums.ts +2 -0
  227. package/src/findSchemaDefinition.ts +2 -2
  228. package/src/getChangedFields.ts +40 -0
  229. package/src/getDateElementProps.ts +2 -2
  230. package/src/getDiscriminatorFieldFromSchema.ts +2 -1
  231. package/src/getInputProps.ts +6 -2
  232. package/src/getOptionMatchingSimpleDiscriminator.ts +2 -2
  233. package/src/getSchemaType.ts +3 -2
  234. package/src/getSubmitButtonOptions.ts +1 -1
  235. package/src/getTemplate.ts +12 -1
  236. package/src/getTestIds.ts +40 -0
  237. package/src/getUiOptions.ts +2 -2
  238. package/src/getWidget.tsx +2 -2
  239. package/src/hasWidget.ts +1 -1
  240. package/src/hashForSchema.ts +26 -6
  241. package/src/idGenerators.ts +10 -0
  242. package/src/index.ts +21 -2
  243. package/src/isCustomWidget.ts +1 -1
  244. package/src/isObject.ts +12 -5
  245. package/src/labelValue.ts +2 -2
  246. package/src/lookupFromFormContext.ts +26 -0
  247. package/src/mergeDefaultsWithFormData.ts +54 -9
  248. package/src/mergeObjects.ts +24 -21
  249. package/src/optionsList.ts +31 -22
  250. package/src/parser/ParserValidator.ts +5 -5
  251. package/src/parser/schemaParser.ts +6 -6
  252. package/src/schema/findFieldInSchema.ts +138 -0
  253. package/src/schema/findSelectedOptionInXxxOf.ts +53 -0
  254. package/src/schema/getClosestMatchingOption.ts +38 -11
  255. package/src/schema/getDefaultFormState.ts +447 -191
  256. package/src/schema/getDisplayLabel.ts +7 -4
  257. package/src/schema/getFirstMatchingOption.ts +79 -4
  258. package/src/schema/getFromSchema.ts +100 -0
  259. package/src/schema/index.ts +6 -4
  260. package/src/schema/isFilesArray.ts +18 -3
  261. package/src/schema/isMultiSelect.ts +10 -4
  262. package/src/schema/isSelect.ts +5 -3
  263. package/src/schema/retrieveSchema.ts +256 -75
  264. package/src/schema/sanitizeDataForNewSchema.ts +52 -11
  265. package/src/schema/toIdSchema.ts +69 -43
  266. package/src/schema/toPathSchema.ts +49 -16
  267. package/src/toErrorList.ts +2 -2
  268. package/src/types.ts +266 -174
  269. package/src/validationDataMerge.ts +1 -1
  270. package/src/withIdRefPrefix.ts +1 -1
  271. package/LICENSE.md +0 -201
  272. package/lib/schema/getMatchingOption.d.ts +0 -14
  273. package/lib/schema/getMatchingOption.js +0 -85
  274. package/lib/schema/getMatchingOption.js.map +0 -1
  275. package/lib/schema/mergeValidationData.d.ts +0 -14
  276. package/lib/schema/mergeValidationData.js +0 -28
  277. package/lib/schema/mergeValidationData.js.map +0 -1
  278. package/src/schema/getMatchingOption.ts +0 -103
  279. package/src/schema/mergeValidationData.ts +0 -38
@@ -1 +1 @@
1
- {"version":3,"file":"validationDataMerge.js","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,cAAiC,EACjC,qBAAsC;IAEtC,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,cAAc,CAAC;KACvB;IACD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,cAAc,CAAC;IAC1E,IAAI,MAAM,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAChD,IAAI,WAAW,GAAG,qBAAqB,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;QAC5B,WAAW,GAAG,YAAY,CAAC,cAAc,EAAE,qBAAqB,EAAE,IAAI,CAAmB,CAAC;QAC1F,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACxC;IACD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
1
+ {"version":3,"file":"validationDataMerge.js","sourceRoot":"","sources":["../src/validationDataMerge.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,cAAiC,EACjC,qBAAsC;IAEtC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,cAAc,CAAC;IAC1E,IAAI,MAAM,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAChD,IAAI,WAAW,GAAG,qBAAqB,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7B,WAAW,GAAG,YAAY,CAAC,cAAc,EAAE,qBAAqB,EAAE,IAAI,CAAmB,CAAC;QAC1F,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import { RJSFSchema, StrictRJSFSchema } from './types.js';
2
2
  /** Recursively prefixes all `$ref`s in a schema with the value of the `ROOT_SCHEMA_PREFIX` constant.
3
3
  * This is used in isValid to make references to the rootSchema
4
4
  *
@@ -1,5 +1,5 @@
1
- import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants';
2
- import isObject from 'lodash/isObject';
1
+ import { REF_KEY, ROOT_SCHEMA_PREFIX } from './constants.js';
2
+ import isObject from 'lodash-es/isObject.js';
3
3
  /** Takes a `node` object and transforms any contained `$ref` node variables with a prefix, recursively calling
4
4
  * `withIdRefPrefix` for any other elements.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"withIdRefPrefix.js","sourceRoot":"","sources":["../src/withIdRefPrefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC;;;;GAIG;AACH,SAAS,qBAAqB,CAA0C,IAAO;IAC7E,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,MAAM,OAAO,GAAyB,IAAI,CAAC;QAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,GAAG,KAAK,OAAO,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACzE,OAAO,CAAC,GAAG,CAAC,GAAG,kBAAkB,GAAG,KAAK,CAAC;SAC3C;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAI,KAAK,CAAC,CAAC;SAC1C;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAA0C,IAAS;IAC9E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,IAAI,CAAC,CAAC,CAAC,GAAG,eAAe,CAAI,IAAI,CAAC,CAAC,CAAC,CAAM,CAAC;KAC5C;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAgC;IAEhC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,oBAAoB,CAAI,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;KACjD;IACD,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE;QACxB,OAAO,qBAAqB,CAAI,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;KACpD;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
1
+ {"version":3,"file":"withIdRefPrefix.js","sourceRoot":"","sources":["../src/withIdRefPrefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC;;;;GAIG;AACH,SAAS,qBAAqB,CAA0C,IAAO;IAC7E,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAyB,IAAI,CAAC;QAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,GAAG,KAAK,OAAO,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1E,OAAO,CAAC,GAAG,CAAC,GAAG,kBAAkB,GAAG,KAAK,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAI,KAAK,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAA0C,IAAS;IAC9E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,CAAC,CAAC,GAAG,eAAe,CAAI,IAAI,CAAC,CAAC,CAAC,CAAM,CAAC;IAC7C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAgC;IAEhC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,oBAAoB,CAAI,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACzB,OAAO,qBAAqB,CAAI,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,38 @@
1
1
  {
2
2
  "name": "@rjsf/utils",
3
- "version": "6.0.0-alpha.0",
3
+ "version": "6.0.0-beta.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
+ "type": "module",
7
8
  "description": "Utility functions for @rjsf/core",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "require": "./dist/index.js",
13
+ "import": "./lib/index.js"
14
+ },
15
+ "./lib": {
16
+ "types": "./lib/index.d.ts",
17
+ "require": "./dist/index.js",
18
+ "import": "./lib/index.js"
19
+ },
20
+ "./lib/*.js": {
21
+ "types": "./lib/*.d.ts",
22
+ "require": "./dist/*.js",
23
+ "import": "./lib/*.js"
24
+ },
25
+ "./dist": {
26
+ "types": "./lib/index.d.ts",
27
+ "require": "./dist/index.js",
28
+ "import": "./lib/index.js"
29
+ },
30
+ "./dist/*.js": {
31
+ "types": "./lib/*.d.ts",
32
+ "require": "./dist/*.js",
33
+ "import": "./lib/*.js"
34
+ }
35
+ },
8
36
  "files": [
9
37
  "dist",
10
38
  "lib",
@@ -12,10 +40,11 @@
12
40
  ],
13
41
  "engineStrict": false,
14
42
  "engines": {
15
- "node": ">=14"
43
+ "node": ">=20"
16
44
  },
17
45
  "scripts": {
18
- "build:ts": "tsc -b",
46
+ "compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
47
+ "build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
19
48
  "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
20
49
  "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm",
21
50
  "build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils",
@@ -33,40 +62,22 @@
33
62
  ]
34
63
  },
35
64
  "peerDependencies": {
36
- "react": "^16.14.0 || >=17"
65
+ "react": ">=18"
37
66
  },
38
67
  "dependencies": {
39
68
  "json-schema-merge-allof": "^0.8.1",
40
69
  "jsonpointer": "^5.0.1",
41
70
  "lodash": "^4.17.21",
42
71
  "lodash-es": "^4.17.21",
72
+ "nanoid": "^5.1.5",
43
73
  "react-is": "^18.2.0"
44
74
  },
45
75
  "devDependencies": {
46
- "@babel/core": "^7.23.9",
47
- "@babel/plugin-proposal-class-properties": "^7.18.6",
48
- "@babel/plugin-proposal-optional-chaining": "^7.21.0",
49
- "@babel/preset-env": "^7.23.9",
50
- "@babel/preset-react": "^7.23.3",
51
- "@babel/preset-typescript": "^7.23.3",
52
- "@types/jest": "^29.5.12",
53
76
  "@types/json-schema": "^7.0.15",
54
77
  "@types/json-schema-merge-allof": "^0.6.5",
55
- "@types/lodash": "^4.14.202",
56
- "@types/react": "^18.2.58",
57
78
  "@types/react-is": "^18.2.4",
58
- "@types/react-test-renderer": "^18.0.7",
59
- "babel-jest": "^29.7.0",
60
79
  "deep-freeze-es6": "^1.4.1",
61
- "esbuild": "^0.18.20",
62
- "eslint": "^8.56.0",
63
- "jest": "^29.7.0",
64
- "jest-environment-jsdom": "^29.7.0",
65
- "react": "^18.2.0",
66
- "react-test-renderer": "^18.2.0",
67
- "rimraf": "^5.0.5",
68
- "rollup": "^3.29.4",
69
- "typescript": "^4.9.5"
80
+ "eslint": "^8.56.0"
70
81
  },
71
82
  "publishConfig": {
72
83
  "access": "public"
@@ -85,6 +96,5 @@
85
96
  "type": "git",
86
97
  "url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
87
98
  },
88
- "license": "Apache-2.0",
89
- "gitHead": "f4229bf6e067d31b24de3ef9d3ca754ee52529ac"
99
+ "license": "Apache-2.0"
90
100
  }
@@ -1,10 +1,16 @@
1
1
  import cloneDeep from 'lodash/cloneDeep';
2
2
  import get from 'lodash/get';
3
3
  import set from 'lodash/set';
4
+ import setWith from 'lodash/setWith';
4
5
 
5
6
  import { ErrorSchema } from './types';
6
7
  import { ERRORS_KEY } from './constants';
7
8
 
9
+ /** Represents the type of the path which can be a string of dotted path values or a list of string or numbers where
10
+ * numbers represent array indexes/
11
+ */
12
+ export type PathType = string | (string | number)[];
13
+
8
14
  /** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
9
15
  * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
10
16
  * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can
@@ -37,12 +43,13 @@ export default class ErrorSchemaBuilder<T = any> {
37
43
  * @returns - The error block for the given `pathOfError` or the root if not provided
38
44
  * @private
39
45
  */
40
- private getOrCreateErrorBlock(pathOfError?: string | string[]) {
46
+ private getOrCreateErrorBlock(pathOfError?: PathType) {
41
47
  const hasPath = (Array.isArray(pathOfError) && pathOfError.length > 0) || typeof pathOfError === 'string';
48
+ // @ts-expect-error TS2590 to avoid "Expression produces a union type that is too complex to represent" error
42
49
  let errorBlock: ErrorSchema = hasPath ? get(this.errorSchema, pathOfError) : this.errorSchema;
43
50
  if (!errorBlock && pathOfError) {
44
51
  errorBlock = {};
45
- set(this.errorSchema, pathOfError, errorBlock);
52
+ setWith(this.errorSchema, pathOfError, errorBlock, Object);
46
53
  }
47
54
  return errorBlock;
48
55
  }
@@ -65,7 +72,7 @@ export default class ErrorSchemaBuilder<T = any> {
65
72
  * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
66
73
  * @returns - The `ErrorSchemaBuilder` object for chaining purposes
67
74
  */
68
- addErrors(errorOrList: string | string[], pathOfError?: string | string[]) {
75
+ addErrors(errorOrList: string | string[], pathOfError?: PathType) {
69
76
  const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
70
77
  let errorsList = get(errorBlock, ERRORS_KEY);
71
78
  if (!Array.isArray(errorsList)) {
@@ -74,9 +81,9 @@ export default class ErrorSchemaBuilder<T = any> {
74
81
  }
75
82
 
76
83
  if (Array.isArray(errorOrList)) {
77
- errorsList.push(...errorOrList);
84
+ set(errorBlock, ERRORS_KEY, [...new Set([...errorsList, ...errorOrList])]);
78
85
  } else {
79
- errorsList.push(errorOrList);
86
+ set(errorBlock, ERRORS_KEY, [...new Set([...errorsList, errorOrList])]);
80
87
  }
81
88
  return this;
82
89
  }
@@ -89,10 +96,10 @@ export default class ErrorSchemaBuilder<T = any> {
89
96
  * @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)
90
97
  * @returns - The `ErrorSchemaBuilder` object for chaining purposes
91
98
  */
92
- setErrors(errorOrList: string | string[], pathOfError?: string | string[]) {
99
+ setErrors(errorOrList: string | string[], pathOfError?: PathType) {
93
100
  const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
94
101
  // Effectively clone the array being given to prevent accidental outside manipulation of the given list
95
- const listToAdd = Array.isArray(errorOrList) ? [...errorOrList] : [errorOrList];
102
+ const listToAdd = Array.isArray(errorOrList) ? [...new Set([...errorOrList])] : [errorOrList];
96
103
  set(errorBlock, ERRORS_KEY, listToAdd);
97
104
  return this;
98
105
  }
@@ -104,7 +111,7 @@ export default class ErrorSchemaBuilder<T = any> {
104
111
  * @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)
105
112
  * @returns - The `ErrorSchemaBuilder` object for chaining purposes
106
113
  */
107
- clearErrors(pathOfError?: string | string[]) {
114
+ clearErrors(pathOfError?: PathType) {
108
115
  const errorBlock: ErrorSchema = this.getOrCreateErrorBlock(pathOfError);
109
116
  set(errorBlock, ERRORS_KEY, []);
110
117
  return this;
package/src/canExpand.ts CHANGED
@@ -13,9 +13,9 @@ import getUiOptions from './getUiOptions';
13
13
  export default function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
14
14
  schema: RJSFSchema,
15
15
  uiSchema: UiSchema<T, S, F> = {},
16
- formData?: T
16
+ formData?: T,
17
17
  ) {
18
- if (!schema.additionalProperties) {
18
+ if (!(schema.additionalProperties || schema.patternProperties)) {
19
19
  return false;
20
20
  }
21
21
  const { expandable = true } = getUiOptions<T, S, F>(uiSchema);
@@ -0,0 +1,17 @@
1
+ import { CONST_KEY, getSchemaType, isObject } from './';
2
+ import { RJSFSchema, StrictRJSFSchema } from './types';
3
+ import { JSONSchema7Type } from 'json-schema';
4
+ import isString from 'lodash/isString';
5
+
6
+ /**
7
+ * Checks if the schema const property value is an AJV $data reference
8
+ * and the current schema is not an object or array
9
+ *
10
+ * @param schema - The schema to check if the const is an AJV $data reference
11
+ * @returns - true if the schema const property value is an AJV $data reference otherwise false.
12
+ */
13
+ export default function constIsAjvDataReference<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean {
14
+ const schemaConst = schema[CONST_KEY] as JSONSchema7Type & { $data: string };
15
+ const schemaType = getSchemaType<S>(schema);
16
+ return isObject(schemaConst) && isString(schemaConst?.$data) && schemaType !== 'object' && schemaType !== 'array';
17
+ }
package/src/constants.ts CHANGED
@@ -19,14 +19,23 @@ export const ITEMS_KEY = 'items';
19
19
  export const JUNK_OPTION_ID = '_$junk_option_schema_id$_';
20
20
  export const NAME_KEY = '$name';
21
21
  export const ONE_OF_KEY = 'oneOf';
22
+ export const PATTERN_PROPERTIES_KEY = 'patternProperties';
22
23
  export const PROPERTIES_KEY = 'properties';
24
+ export const READONLY_KEY = 'readonly';
23
25
  export const REQUIRED_KEY = 'required';
24
26
  export const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';
25
27
  export const REF_KEY = '$ref';
26
- /**
27
- * @deprecated Replace with correctly spelled constant `RJSF_ADDITIONAL_PROPERTIES_FLAG`
28
+ /** The path of the discriminator value returned by the schema endpoint.
29
+ * The discriminator is the value in a `oneOf` that determines which option is selected.
28
30
  */
29
- export const RJSF_ADDITONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
31
+ export const DISCRIMINATOR_PATH = ['discriminator', 'propertyName'];
32
+ /** The name of the `formContext` attribute in the React JSON Schema Form Registry
33
+ */
34
+ export const FORM_CONTEXT_NAME = 'formContext';
35
+
36
+ /** The name of the `layoutGridLookupMap` attribute in the form context
37
+ */
38
+ export const LOOKUP_MAP_NAME = 'layoutGridLookupMap';
30
39
  export const RJSF_ADDITIONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
31
40
  export const ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';
32
41
  export const UI_FIELD_KEY = 'ui:field';
@@ -1,8 +1,9 @@
1
1
  import deepEquals from './deepEquals';
2
2
  import {
3
- ErrorSchema,
3
+ Experimental_CustomMergeAllOf,
4
4
  Experimental_DefaultFormStateBehavior,
5
5
  FormContextType,
6
+ FoundFieldType,
6
7
  GlobalUISchemaOptions,
7
8
  IdSchema,
8
9
  PathSchema,
@@ -10,19 +11,19 @@ import {
10
11
  SchemaUtilsType,
11
12
  StrictRJSFSchema,
12
13
  UiSchema,
13
- ValidationData,
14
14
  ValidatorType,
15
15
  } from './types';
16
16
  import {
17
+ findFieldInSchema,
18
+ findSelectedOptionInXxxOf,
17
19
  getDefaultFormState,
18
20
  getDisplayLabel,
19
21
  getClosestMatchingOption,
20
22
  getFirstMatchingOption,
21
- getMatchingOption,
23
+ getFromSchema,
22
24
  isFilesArray,
23
25
  isMultiSelect,
24
26
  isSelect,
25
- mergeValidationData,
26
27
  retrieveSchema,
27
28
  sanitizeDataForNewSchema,
28
29
  toIdSchema,
@@ -30,9 +31,10 @@ import {
30
31
  } from './schema';
31
32
 
32
33
  /** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such
33
- * that one does not have to explicitly pass the `validator`, `rootSchema`, or `experimental_defaultFormStateBehavior` to each method.
34
- * Since these generally do not change across a `Form`, this allows for providing a simplified set of APIs to the
35
- * `@rjsf/core` components and the various themes as well. This class implements the `SchemaUtilsType` interface.
34
+ * that one does not have to explicitly pass the `validator`, `rootSchema`, `experimental_defaultFormStateBehavior` or
35
+ * `experimental_customMergeAllOf` to each method. Since these generally do not change across a `Form`, this allows for
36
+ * providing a simplified set of APIs to the `@rjsf/core` components and the various themes as well. This class
37
+ * implements the `SchemaUtilsType` interface.
36
38
  */
37
39
  class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>
38
40
  implements SchemaUtilsType<T, S, F>
@@ -40,21 +42,25 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
40
42
  rootSchema: S;
41
43
  validator: ValidatorType<T, S, F>;
42
44
  experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior;
45
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>;
43
46
 
44
47
  /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
45
48
  *
46
49
  * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
47
50
  * @param rootSchema - The root schema that will be forwarded to all the APIs
48
51
  * @param experimental_defaultFormStateBehavior - Configuration flags to allow users to override default form state behavior
52
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
49
53
  */
50
54
  constructor(
51
55
  validator: ValidatorType<T, S, F>,
52
56
  rootSchema: S,
53
- experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior
57
+ experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior,
58
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
54
59
  ) {
55
60
  this.rootSchema = rootSchema;
56
61
  this.validator = validator;
57
62
  this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;
63
+ this.experimental_customMergeAllOf = experimental_customMergeAllOf;
58
64
  }
59
65
 
60
66
  /** Returns the `ValidatorType` in the `SchemaUtilsType`
@@ -72,12 +78,14 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
72
78
  * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
73
79
  * @param rootSchema - The root schema that will be compared against the current one
74
80
  * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
81
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
75
82
  * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
76
83
  */
77
84
  doesSchemaUtilsDiffer(
78
85
  validator: ValidatorType<T, S, F>,
79
86
  rootSchema: S,
80
- experimental_defaultFormStateBehavior = {}
87
+ experimental_defaultFormStateBehavior = {},
88
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
81
89
  ): boolean {
82
90
  if (!validator || !rootSchema) {
83
91
  return false;
@@ -85,7 +93,51 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
85
93
  return (
86
94
  this.validator !== validator ||
87
95
  !deepEquals(this.rootSchema, rootSchema) ||
88
- !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior)
96
+ !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) ||
97
+ this.experimental_customMergeAllOf !== experimental_customMergeAllOf
98
+ );
99
+ }
100
+
101
+ /** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
102
+ * `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
103
+ * field is in the `required` list for its parent and if so, it is marked as required on return.
104
+ *
105
+ * @param schema - The current node within the JSON schema
106
+ * @param path - The remaining keys in the path to the desired field
107
+ * @param [formData] - The form data that is used to determine which oneOf option
108
+ * @returns - An object that contains the field and its required state. If no field can be found then
109
+ * `{ field: undefined, isRequired: undefined }` is returned.
110
+ */
111
+ findFieldInSchema(schema: S, path: string | string[], formData?: T): FoundFieldType<S> {
112
+ return findFieldInSchema(
113
+ this.validator,
114
+ this.rootSchema,
115
+ schema,
116
+ path,
117
+ formData,
118
+ this.experimental_customMergeAllOf,
119
+ );
120
+ }
121
+
122
+ /** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
123
+ * matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
124
+ * `schema.discriminator.propertyName` or `fallbackField`.
125
+ *
126
+ * @param schema - The schema element in which to search for the selected oneOf option
127
+ * @param fallbackField - The field to use as a backup selector field if the schema does not have a required field
128
+ * @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought
129
+ * @param [formData={}] - The form data that is used to determine which oneOf option
130
+ * @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected
131
+ */
132
+ findSelectedOptionInXxxOf(schema: S, fallbackField: string, xxx: 'anyOf' | `oneOf`, formData: T): S | undefined {
133
+ return findSelectedOptionInXxxOf(
134
+ this.validator,
135
+ this.rootSchema,
136
+ schema,
137
+ fallbackField,
138
+ xxx,
139
+ formData,
140
+ this.experimental_customMergeAllOf,
89
141
  );
90
142
  }
91
143
 
@@ -102,7 +154,7 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
102
154
  getDefaultFormState(
103
155
  schema: S,
104
156
  formData?: T,
105
- includeUndefinedValues: boolean | 'excludeObjectChildren' = false
157
+ includeUndefinedValues: boolean | 'excludeObjectChildren' = false,
106
158
  ): T | T[] | undefined {
107
159
  return getDefaultFormState<T, S, F>(
108
160
  this.validator,
@@ -110,7 +162,8 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
110
162
  formData,
111
163
  this.rootSchema,
112
164
  includeUndefinedValues,
113
- this.experimental_defaultFormStateBehavior
165
+ this.experimental_defaultFormStateBehavior,
166
+ this.experimental_customMergeAllOf,
114
167
  );
115
168
  }
116
169
 
@@ -123,7 +176,14 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
123
176
  * @returns - True if the label should be displayed or false if it should not
124
177
  */
125
178
  getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions) {
126
- return getDisplayLabel<T, S, F>(this.validator, schema, uiSchema, this.rootSchema, globalOptions);
179
+ return getDisplayLabel<T, S, F>(
180
+ this.validator,
181
+ schema,
182
+ uiSchema,
183
+ this.rootSchema,
184
+ globalOptions,
185
+ this.experimental_customMergeAllOf,
186
+ );
127
187
  }
128
188
 
129
189
  /** Determines which of the given `options` provided most closely matches the `formData`.
@@ -143,7 +203,7 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
143
203
  formData: T | undefined,
144
204
  options: S[],
145
205
  selectedOption?: number,
146
- discriminatorField?: string
206
+ discriminatorField?: string,
147
207
  ): number {
148
208
  return getClosestMatchingOption<T, S, F>(
149
209
  this.validator,
@@ -151,7 +211,8 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
151
211
  formData,
152
212
  options,
153
213
  selectedOption,
154
- discriminatorField
214
+ discriminatorField,
215
+ this.experimental_customMergeAllOf,
155
216
  );
156
217
  }
157
218
 
@@ -168,18 +229,26 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
168
229
  return getFirstMatchingOption<T, S, F>(this.validator, formData, options, this.rootSchema, discriminatorField);
169
230
  }
170
231
 
171
- /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
172
- * Deprecated, use `getFirstMatchingOption()` instead.
232
+ /** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas
233
+ * containing potentially nested `$ref`s.
173
234
  *
174
- * @param formData - The current formData, if any, onto which to provide any missing defaults
175
- * @param options - The list of options to find a matching options from
176
- * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
177
- * determine which option is selected
178
- * @returns - The index of the matched option or 0 if none is available
179
- * @deprecated
235
+ * @param schema - The current node within the JSON schema recursion
236
+ * @param path - The remaining keys in the path to the desired property
237
+ * @param defaultValue - The value to return if a value is not found for the `pathList` path
238
+ * @returns - The internal schema from the `schema` for the given `path` or the `defaultValue` if not found
180
239
  */
181
- getMatchingOption(formData: T | undefined, options: S[], discriminatorField?: string) {
182
- return getMatchingOption<T, S, F>(this.validator, formData, options, this.rootSchema, discriminatorField);
240
+ getFromSchema(schema: S, path: string | string[], defaultValue: T): T;
241
+ getFromSchema(schema: S, path: string | string[], defaultValue: S): S;
242
+ getFromSchema(schema: S, path: string | string[], defaultValue: T | S): T | S {
243
+ return getFromSchema<T, S, F>(
244
+ this.validator,
245
+ this.rootSchema,
246
+ schema,
247
+ path,
248
+ // @ts-expect-error TS2769: No overload matches this call
249
+ defaultValue,
250
+ this.experimental_customMergeAllOf,
251
+ );
183
252
  }
184
253
 
185
254
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
@@ -189,7 +258,7 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
189
258
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
190
259
  */
191
260
  isFilesArray(schema: S, uiSchema?: UiSchema<T, S, F>) {
192
- return isFilesArray<T, S, F>(this.validator, schema, uiSchema, this.rootSchema);
261
+ return isFilesArray<T, S, F>(this.validator, schema, uiSchema, this.rootSchema, this.experimental_customMergeAllOf);
193
262
  }
194
263
 
195
264
  /** Checks to see if the `schema` combination represents a multi-select
@@ -198,7 +267,7 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
198
267
  * @returns - True if schema contains a multi-select, otherwise false
199
268
  */
200
269
  isMultiSelect(schema: S) {
201
- return isMultiSelect<T, S, F>(this.validator, schema, this.rootSchema);
270
+ return isMultiSelect<T, S, F>(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);
202
271
  }
203
272
 
204
273
  /** Checks to see if the `schema` combination represents a select
@@ -207,22 +276,7 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
207
276
  * @returns - True if schema contains a select, otherwise false
208
277
  */
209
278
  isSelect(schema: S) {
210
- return isSelect<T, S, F>(this.validator, schema, this.rootSchema);
211
- }
212
-
213
- /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
214
- * the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
215
- * `getValidator().toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed,
216
- * then `validationData` is returned.
217
- *
218
- * @param validationData - The current `ValidationData` into which to merge the additional errors
219
- * @param [additionalErrorSchema] - The additional set of errors
220
- * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
221
- * @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
222
- * removed in the next major release.
223
- */
224
- mergeValidationData(validationData: ValidationData<T>, additionalErrorSchema?: ErrorSchema<T>): ValidationData<T> {
225
- return mergeValidationData<T, S, F>(this.validator, validationData, additionalErrorSchema);
279
+ return isSelect<T, S, F>(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);
226
280
  }
227
281
 
228
282
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
@@ -234,7 +288,13 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
234
288
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
235
289
  */
236
290
  retrieveSchema(schema: S, rawFormData?: T) {
237
- return retrieveSchema<T, S, F>(this.validator, schema, this.rootSchema, rawFormData);
291
+ return retrieveSchema<T, S, F>(
292
+ this.validator,
293
+ schema,
294
+ this.rootSchema,
295
+ rawFormData,
296
+ this.experimental_customMergeAllOf,
297
+ );
238
298
  }
239
299
 
240
300
  /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the
@@ -249,7 +309,14 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
249
309
  * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
250
310
  */
251
311
  sanitizeDataForNewSchema(newSchema?: S, oldSchema?: S, data?: any): T {
252
- return sanitizeDataForNewSchema(this.validator, this.rootSchema, newSchema, oldSchema, data);
312
+ return sanitizeDataForNewSchema(
313
+ this.validator,
314
+ this.rootSchema,
315
+ newSchema,
316
+ oldSchema,
317
+ data,
318
+ this.experimental_customMergeAllOf,
319
+ );
253
320
  }
254
321
 
255
322
  /** Generates an `IdSchema` object for the `schema`, recursively
@@ -262,7 +329,16 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
262
329
  * @returns - The `IdSchema` object for the `schema`
263
330
  */
264
331
  toIdSchema(schema: S, id?: string | null, formData?: T, idPrefix = 'root', idSeparator = '_'): IdSchema<T> {
265
- return toIdSchema<T, S, F>(this.validator, schema, id, this.rootSchema, formData, idPrefix, idSeparator);
332
+ return toIdSchema<T, S, F>(
333
+ this.validator,
334
+ schema,
335
+ id,
336
+ this.rootSchema,
337
+ formData,
338
+ idPrefix,
339
+ idSeparator,
340
+ this.experimental_customMergeAllOf,
341
+ );
266
342
  }
267
343
 
268
344
  /** Generates an `PathSchema` object for the `schema`, recursively
@@ -273,7 +349,14 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
273
349
  * @returns - The `PathSchema` object for the `schema`
274
350
  */
275
351
  toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T> {
276
- return toPathSchema<T, S, F>(this.validator, schema, name, this.rootSchema, formData);
352
+ return toPathSchema<T, S, F>(
353
+ this.validator,
354
+ schema,
355
+ name,
356
+ this.rootSchema,
357
+ formData,
358
+ this.experimental_customMergeAllOf,
359
+ );
277
360
  }
278
361
  }
279
362
 
@@ -283,16 +366,23 @@ class SchemaUtils<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
283
366
  * @param validator - an implementation of the `ValidatorType` interface that will be forwarded to all the APIs
284
367
  * @param rootSchema - The root schema that will be forwarded to all the APIs
285
368
  * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
369
+ * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
286
370
  * @returns - An implementation of a `SchemaUtilsType` interface
287
371
  */
288
372
  export default function createSchemaUtils<
289
373
  T = any,
290
374
  S extends StrictRJSFSchema = RJSFSchema,
291
- F extends FormContextType = any
375
+ F extends FormContextType = any,
292
376
  >(
293
377
  validator: ValidatorType<T, S, F>,
294
378
  rootSchema: S,
295
- experimental_defaultFormStateBehavior = {}
379
+ experimental_defaultFormStateBehavior = {},
380
+ experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
296
381
  ): SchemaUtilsType<T, S, F> {
297
- return new SchemaUtils<T, S, F>(validator, rootSchema, experimental_defaultFormStateBehavior);
382
+ return new SchemaUtils<T, S, F>(
383
+ validator,
384
+ rootSchema,
385
+ experimental_defaultFormStateBehavior,
386
+ experimental_customMergeAllOf,
387
+ );
298
388
  }
@@ -25,7 +25,7 @@ export default function dataURItoBlob(dataURILike: string) {
25
25
  const name = decodeURI(
26
26
  // parse the parameters into key-value pairs, find a key, and extract a value
27
27
  // if no key is found, then the name is unknown
28
- mediaparams.map((param) => param.split('=')).find(([key]) => key === 'name')?.[1] || 'unknown'
28
+ mediaparams.map((param) => param.split('=')).find(([key]) => key === 'name')?.[1] || 'unknown',
29
29
  );
30
30
 
31
31
  // Built the Uint8Array Blob parameter from the base64 string.
@@ -12,7 +12,7 @@ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
12
12
  */
13
13
  export default function dateRangeOptions<S extends StrictRJSFSchema = RJSFSchema>(
14
14
  start: number,
15
- stop: number
15
+ stop: number,
16
16
  ): EnumOptionsType<S>[] {
17
17
  if (start <= 0 && stop <= 0) {
18
18
  start = new Date().getFullYear() + start;