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

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 +1347 -642
  2. package/dist/index.js.map +4 -4
  3. package/dist/utils.esm.js +1324 -619
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +1266 -590
  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 +2 -2
  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 +15 -3
  20. package/lib/constants.js +15 -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 +5 -3
  54. package/lib/findSchemaDefinition.js +54 -11
  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 +316 -167
  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 +30 -12
  176. package/lib/schema/retrieveSchema.js +153 -70
  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 +172 -142
  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 +37 -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 +17 -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 +55 -10
  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 +461 -193
  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 +268 -78
  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 +278 -184
  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":"unwrapErrorHandler.js","sourceRoot":"","sources":["../src/unwrapErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAIjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAU,YAA+B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,UAAU,EAAE;YACtB,OAAO,GAAG,CAAC;SACZ;aAAM;YACL,MAAM,WAAW,GAAI,YAAkC,CAAC,GAAG,CAAC,CAAC;YAC7D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE;gBAC9B,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;iBACvC,CAAC;aACH;YACD,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC;SACvC;IACH,CAAC,EAAE,EAAoB,CAAC,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"unwrapErrorHandler.js","sourceRoot":"","sources":["../src/unwrapErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAIjD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAU,YAA+B;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YACvB,OAAO,GAAG,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,GAAI,YAAkC,CAAC,GAAG,CAAC,CAAC;YAC7D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/B,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;iBACvC,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC;QACxC,CAAC;IACH,CAAC,EAAE,EAAoB,CAAC,CAAC;AAC3B,CAAC"}
package/lib/utcToLocal.js CHANGED
@@ -1,4 +1,4 @@
1
- import pad from './pad';
1
+ import pad from './pad.js';
2
2
  /** Converts a UTC date string into a local Date format
3
3
  *
4
4
  * @param jsonDate - A UTC date string
@@ -1 +1 @@
1
- {"version":3,"file":"utcToLocal.js","sourceRoot":"","sources":["../src/utcToLocal.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAgB;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,EAAE,CAAC;KACX;IAED,iFAAiF;IACjF,sGAAsG;IACtG,6DAA6D;IAE7D,mEAAmE;IACnE,mCAAmC;IACnC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,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AG,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC;AACxD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ErrorSchema, ValidationData } from './types';
1
+ import { ErrorSchema, ValidationData } from './types.js';
2
2
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
3
3
  * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
4
4
  * `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
@@ -1,6 +1,6 @@
1
- import isEmpty from 'lodash/isEmpty';
2
- import mergeObjects from './mergeObjects';
3
- import toErrorList from './toErrorList';
1
+ import isEmpty from 'lodash-es/isEmpty.js';
2
+ import mergeObjects from './mergeObjects.js';
3
+ import toErrorList from './toErrorList.js';
4
4
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
5
5
  * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
6
6
  * `toErrorList()` on the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
@@ -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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,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.10",
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,23 @@
33
62
  ]
34
63
  },
35
64
  "peerDependencies": {
36
- "react": "^16.14.0 || >=17"
65
+ "react": ">=18"
37
66
  },
38
67
  "dependencies": {
68
+ "fast-uri": "^3.0.6",
39
69
  "json-schema-merge-allof": "^0.8.1",
40
70
  "jsonpointer": "^5.0.1",
41
71
  "lodash": "^4.17.21",
42
72
  "lodash-es": "^4.17.21",
73
+ "nanoid": "^5.1.5",
43
74
  "react-is": "^18.2.0"
44
75
  },
45
76
  "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
77
  "@types/json-schema": "^7.0.15",
54
78
  "@types/json-schema-merge-allof": "^0.6.5",
55
- "@types/lodash": "^4.14.202",
56
- "@types/react": "^18.2.58",
57
79
  "@types/react-is": "^18.2.4",
58
- "@types/react-test-renderer": "^18.0.7",
59
- "babel-jest": "^29.7.0",
60
80
  "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"
81
+ "eslint": "^8.56.0"
70
82
  },
71
83
  "publishConfig": {
72
84
  "access": "public"
@@ -85,6 +97,5 @@
85
97
  "type": "git",
86
98
  "url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
87
99
  },
88
- "license": "Apache-2.0",
89
- "gitHead": "f4229bf6e067d31b24de3ef9d3ca754ee52529ac"
100
+ "license": "Apache-2.0"
90
101
  }
@@ -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,17 +19,31 @@ 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
+ export const SCHEMA_KEY = '$schema';
29
+ /** The path of the discriminator value returned by the schema endpoint.
30
+ * The discriminator is the value in a `oneOf` that determines which option is selected.
28
31
  */
29
- export const RJSF_ADDITONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
32
+ export const DISCRIMINATOR_PATH = ['discriminator', 'propertyName'];
33
+ /** The name of the `formContext` attribute in the React JSON Schema Form Registry
34
+ */
35
+ export const FORM_CONTEXT_NAME = 'formContext';
36
+
37
+ /** The name of the `layoutGridLookupMap` attribute in the form context
38
+ */
39
+ export const LOOKUP_MAP_NAME = 'layoutGridLookupMap';
30
40
  export const RJSF_ADDITIONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
31
41
  export const ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';
32
42
  export const UI_FIELD_KEY = 'ui:field';
33
43
  export const UI_WIDGET_KEY = 'ui:widget';
34
44
  export const UI_OPTIONS_KEY = 'ui:options';
35
45
  export const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
46
+
47
+ /** The JSON Schema version strings
48
+ */
49
+ export const JSON_SCHEMA_DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';