@rjsf/utils 5.11.2 → 5.12.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 (303) hide show
  1. package/dist/index.js +2544 -5
  2. package/dist/index.js.map +7 -0
  3. package/dist/utils.esm.js +1228 -2113
  4. package/dist/utils.esm.js.map +7 -1
  5. package/dist/utils.umd.js +2414 -0
  6. package/lib/ErrorSchemaBuilder.d.ts +60 -0
  7. package/lib/ErrorSchemaBuilder.js +103 -0
  8. package/lib/ErrorSchemaBuilder.js.map +1 -0
  9. package/lib/allowAdditionalItems.d.ts +8 -0
  10. package/lib/allowAdditionalItems.js +14 -0
  11. package/lib/allowAdditionalItems.js.map +1 -0
  12. package/lib/asNumber.d.ts +10 -0
  13. package/lib/asNumber.js +36 -0
  14. package/lib/asNumber.js.map +1 -0
  15. package/lib/canExpand.d.ts +11 -0
  16. package/lib/canExpand.js +26 -0
  17. package/lib/canExpand.js.map +1 -0
  18. package/lib/constants.d.ts +31 -0
  19. package/lib/constants.js +32 -0
  20. package/lib/constants.js.map +1 -0
  21. package/lib/createErrorHandler.d.ts +7 -0
  22. package/lib/createErrorHandler.js +31 -0
  23. package/lib/createErrorHandler.js.map +1 -0
  24. package/lib/createSchemaUtils.d.ts +10 -0
  25. package/lib/createSchemaUtils.js +207 -0
  26. package/lib/createSchemaUtils.js.map +1 -0
  27. package/lib/dataURItoBlob.d.ts +16 -0
  28. package/lib/dataURItoBlob.js +43 -0
  29. package/lib/dataURItoBlob.js.map +1 -0
  30. package/lib/deepEquals.d.ts +8 -0
  31. package/lib/deepEquals.js +19 -0
  32. package/lib/deepEquals.js.map +1 -0
  33. package/lib/englishStringTranslator.d.ts +10 -0
  34. package/lib/englishStringTranslator.js +13 -0
  35. package/lib/englishStringTranslator.js.map +1 -0
  36. package/lib/enumOptionsDeselectValue.d.ts +14 -0
  37. package/lib/enumOptionsDeselectValue.js +22 -0
  38. package/lib/enumOptionsDeselectValue.js.map +1 -0
  39. package/lib/enumOptionsIndexForValue.d.ts +13 -0
  40. package/lib/enumOptionsIndexForValue.js +22 -0
  41. package/lib/enumOptionsIndexForValue.js.map +1 -0
  42. package/lib/enumOptionsIsSelected.d.ts +8 -0
  43. package/lib/enumOptionsIsSelected.js +14 -0
  44. package/lib/enumOptionsIsSelected.js.map +1 -0
  45. package/lib/enumOptionsSelectValue.d.ts +10 -0
  46. package/lib/enumOptionsSelectValue.js +23 -0
  47. package/lib/enumOptionsSelectValue.js.map +1 -0
  48. package/lib/enumOptionsValueForIndex.d.ts +13 -0
  49. package/lib/enumOptionsValueForIndex.js +21 -0
  50. package/lib/enumOptionsValueForIndex.js.map +1 -0
  51. package/lib/enums.d.ts +72 -0
  52. package/lib/enums.js +76 -0
  53. package/lib/enums.js.map +1 -0
  54. package/lib/findSchemaDefinition.d.ts +20 -0
  55. package/lib/findSchemaDefinition.js +49 -0
  56. package/lib/findSchemaDefinition.js.map +1 -0
  57. package/lib/getDiscriminatorFieldFromSchema.d.ts +8 -0
  58. package/lib/getDiscriminatorFieldFromSchema.js +20 -0
  59. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -0
  60. package/lib/getInputProps.d.ts +10 -0
  61. package/lib/getInputProps.js +41 -0
  62. package/lib/getInputProps.js.map +1 -0
  63. package/lib/getSchemaType.d.ts +13 -0
  64. package/lib/getSchemaType.js +29 -0
  65. package/lib/getSchemaType.js.map +1 -0
  66. package/lib/getSubmitButtonOptions.d.ts +10 -0
  67. package/lib/getSubmitButtonOptions.js +25 -0
  68. package/lib/getSubmitButtonOptions.js.map +1 -0
  69. package/lib/getTemplate.d.ts +10 -0
  70. package/lib/getTemplate.js +19 -0
  71. package/lib/getTemplate.js.map +1 -0
  72. package/lib/getUiOptions.d.ts +9 -0
  73. package/lib/getUiOptions.js +25 -0
  74. package/lib/getUiOptions.js.map +1 -0
  75. package/lib/getWidget.d.ts +13 -0
  76. package/lib/getWidget.js +118 -0
  77. package/lib/getWidget.js.map +1 -0
  78. package/lib/guessType.d.ts +7 -0
  79. package/lib/guessType.js +29 -0
  80. package/lib/guessType.js.map +1 -0
  81. package/lib/hasWidget.d.ts +10 -0
  82. package/lib/hasWidget.js +23 -0
  83. package/lib/hasWidget.js.map +1 -0
  84. package/lib/hashForSchema.d.ts +8 -0
  85. package/lib/hashForSchema.js +29 -0
  86. package/lib/hashForSchema.js.map +1 -0
  87. package/lib/idGenerators.d.ts +47 -0
  88. package/lib/idGenerators.js +73 -0
  89. package/lib/idGenerators.js.map +1 -0
  90. package/lib/index.d.ts +57 -0
  91. package/lib/index.js +58 -0
  92. package/lib/index.js.map +1 -0
  93. package/lib/isConstant.d.ts +8 -0
  94. package/lib/isConstant.js +11 -0
  95. package/lib/isConstant.js.map +1 -0
  96. package/lib/isCustomWidget.d.ts +7 -0
  97. package/lib/isCustomWidget.js +13 -0
  98. package/lib/isCustomWidget.js.map +1 -0
  99. package/lib/isFixedItems.d.ts +8 -0
  100. package/lib/isFixedItems.js +11 -0
  101. package/lib/isFixedItems.js.map +1 -0
  102. package/lib/isObject.d.ts +7 -0
  103. package/lib/isObject.js +16 -0
  104. package/lib/isObject.js.map +1 -0
  105. package/lib/labelValue.d.ts +13 -0
  106. package/lib/labelValue.js +4 -0
  107. package/lib/labelValue.js.map +1 -0
  108. package/lib/localToUTC.d.ts +6 -0
  109. package/lib/localToUTC.js +9 -0
  110. package/lib/localToUTC.js.map +1 -0
  111. package/lib/mergeDefaultsWithFormData.d.ts +17 -0
  112. package/lib/mergeDefaultsWithFormData.js +43 -0
  113. package/lib/mergeDefaultsWithFormData.js.map +1 -0
  114. package/lib/mergeObjects.d.ts +11 -0
  115. package/lib/mergeObjects.js +35 -0
  116. package/lib/mergeObjects.js.map +1 -0
  117. package/lib/mergeSchemas.d.ts +10 -0
  118. package/lib/mergeSchemas.js +35 -0
  119. package/lib/mergeSchemas.js.map +1 -0
  120. package/lib/optionsList.d.ts +10 -0
  121. package/lib/optionsList.js +36 -0
  122. package/lib/optionsList.js.map +1 -0
  123. package/lib/orderProperties.d.ts +11 -0
  124. package/lib/orderProperties.js +38 -0
  125. package/lib/orderProperties.js.map +1 -0
  126. package/lib/pad.d.ts +7 -0
  127. package/lib/pad.js +14 -0
  128. package/lib/pad.js.map +1 -0
  129. package/lib/parseDateString.d.ts +9 -0
  130. package/lib/parseDateString.js +32 -0
  131. package/lib/parseDateString.js.map +1 -0
  132. package/lib/parser/ParserValidator.d.ts +70 -0
  133. package/lib/parser/ParserValidator.js +93 -0
  134. package/lib/parser/ParserValidator.js.map +1 -0
  135. package/lib/parser/index.d.ts +4 -0
  136. package/lib/parser/index.js +3 -0
  137. package/lib/parser/index.js.map +1 -0
  138. package/lib/parser/schemaParser.d.ts +9 -0
  139. package/lib/parser/schemaParser.js +48 -0
  140. package/lib/parser/schemaParser.js.map +1 -0
  141. package/lib/rangeSpec.d.ts +9 -0
  142. package/lib/rangeSpec.js +20 -0
  143. package/lib/rangeSpec.js.map +1 -0
  144. package/lib/replaceStringParameters.d.ts +9 -0
  145. package/lib/replaceStringParameters.js +23 -0
  146. package/lib/replaceStringParameters.js.map +1 -0
  147. package/lib/schema/getClosestMatchingOption.d.ts +49 -0
  148. package/lib/schema/getClosestMatchingOption.js +154 -0
  149. package/lib/schema/getClosestMatchingOption.js.map +1 -0
  150. package/lib/schema/getDefaultFormState.d.ts +66 -0
  151. package/lib/schema/getDefaultFormState.js +351 -0
  152. package/lib/schema/getDefaultFormState.js.map +1 -0
  153. package/lib/schema/getDisplayLabel.d.ts +12 -0
  154. package/lib/schema/getDisplayLabel.js +39 -0
  155. package/lib/schema/getDisplayLabel.js.map +1 -0
  156. package/lib/schema/getFirstMatchingOption.d.ts +13 -0
  157. package/lib/schema/getFirstMatchingOption.js +16 -0
  158. package/lib/schema/getFirstMatchingOption.js.map +1 -0
  159. package/lib/schema/getMatchingOption.d.ts +14 -0
  160. package/lib/schema/getMatchingOption.js +80 -0
  161. package/lib/schema/getMatchingOption.js.map +1 -0
  162. package/lib/schema/index.d.ts +14 -0
  163. package/lib/schema/index.js +15 -0
  164. package/lib/schema/index.js.map +1 -0
  165. package/lib/schema/isFilesArray.d.ts +10 -0
  166. package/lib/schema/isFilesArray.js +21 -0
  167. package/lib/schema/isFilesArray.js.map +1 -0
  168. package/lib/schema/isMultiSelect.d.ts +9 -0
  169. package/lib/schema/isMultiSelect.js +15 -0
  170. package/lib/schema/isMultiSelect.js.map +1 -0
  171. package/lib/schema/isSelect.d.ts +9 -0
  172. package/lib/schema/isSelect.js +21 -0
  173. package/lib/schema/isSelect.js.map +1 -0
  174. package/lib/schema/mergeValidationData.d.ts +14 -0
  175. package/lib/schema/mergeValidationData.js +28 -0
  176. package/lib/schema/mergeValidationData.js.map +1 -0
  177. package/lib/schema/retrieveSchema.d.ts +170 -0
  178. package/lib/schema/retrieveSchema.js +437 -0
  179. package/lib/schema/retrieveSchema.js.map +1 -0
  180. package/lib/schema/sanitizeDataForNewSchema.d.ts +49 -0
  181. package/lib/schema/sanitizeDataForNewSchema.js +173 -0
  182. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -0
  183. package/lib/schema/toIdSchema.d.ts +13 -0
  184. package/lib/schema/toIdSchema.js +59 -0
  185. package/lib/schema/toIdSchema.js.map +1 -0
  186. package/lib/schema/toPathSchema.d.ts +11 -0
  187. package/lib/schema/toPathSchema.js +68 -0
  188. package/lib/schema/toPathSchema.js.map +1 -0
  189. package/lib/schemaRequiresTrueValue.d.ts +11 -0
  190. package/lib/schemaRequiresTrueValue.js +34 -0
  191. package/lib/schemaRequiresTrueValue.js.map +1 -0
  192. package/lib/shouldRender.d.ts +10 -0
  193. package/lib/shouldRender.js +14 -0
  194. package/lib/shouldRender.js.map +1 -0
  195. package/lib/toConstant.d.ts +9 -0
  196. package/lib/toConstant.js +18 -0
  197. package/lib/toConstant.js.map +1 -0
  198. package/lib/toDateString.d.ts +9 -0
  199. package/lib/toDateString.js +14 -0
  200. package/lib/toDateString.js.map +1 -0
  201. package/lib/toErrorList.d.ts +8 -0
  202. package/lib/toErrorList.js +34 -0
  203. package/lib/toErrorList.js.map +1 -0
  204. package/lib/toErrorSchema.d.ts +21 -0
  205. package/lib/toErrorSchema.js +41 -0
  206. package/lib/toErrorSchema.js.map +1 -0
  207. package/lib/types.d.ts +982 -0
  208. package/lib/types.js +2 -0
  209. package/lib/types.js.map +1 -0
  210. package/lib/unwrapErrorHandler.d.ts +7 -0
  211. package/lib/unwrapErrorHandler.js +21 -0
  212. package/lib/unwrapErrorHandler.js.map +1 -0
  213. package/lib/utcToLocal.d.ts +6 -0
  214. package/lib/utcToLocal.js +26 -0
  215. package/lib/utcToLocal.js.map +1 -0
  216. package/lib/validationDataMerge.d.ts +11 -0
  217. package/lib/validationDataMerge.js +26 -0
  218. package/lib/validationDataMerge.js.map +1 -0
  219. package/lib/withIdRefPrefix.d.ts +8 -0
  220. package/lib/withIdRefPrefix.js +47 -0
  221. package/lib/withIdRefPrefix.js.map +1 -0
  222. package/package.json +20 -13
  223. package/src/ErrorSchemaBuilder.ts +112 -0
  224. package/src/allowAdditionalItems.ts +15 -0
  225. package/src/asNumber.ts +38 -0
  226. package/src/canExpand.ts +31 -0
  227. package/src/constants.ts +31 -0
  228. package/src/createErrorHandler.ts +33 -0
  229. package/src/createSchemaUtils.ts +298 -0
  230. package/src/dataURItoBlob.ts +42 -0
  231. package/src/deepEquals.ts +19 -0
  232. package/src/englishStringTranslator.ts +14 -0
  233. package/src/enumOptionsDeselectValue.ts +28 -0
  234. package/src/enumOptionsIndexForValue.ts +27 -0
  235. package/src/enumOptionsIsSelected.ts +19 -0
  236. package/src/enumOptionsSelectValue.ts +28 -0
  237. package/src/enumOptionsValueForIndex.ts +26 -0
  238. package/src/enums.ts +74 -0
  239. package/src/findSchemaDefinition.ts +54 -0
  240. package/src/getDiscriminatorFieldFromSchema.ts +21 -0
  241. package/src/getInputProps.ts +55 -0
  242. package/src/getSchemaType.ts +37 -0
  243. package/src/getSubmitButtonOptions.ts +32 -0
  244. package/src/getTemplate.ts +26 -0
  245. package/src/getUiOptions.ts +32 -0
  246. package/src/getWidget.tsx +133 -0
  247. package/src/guessType.ts +28 -0
  248. package/src/hasWidget.ts +27 -0
  249. package/src/hashForSchema.ts +31 -0
  250. package/src/idGenerators.ts +81 -0
  251. package/src/index.ts +118 -0
  252. package/src/isConstant.ts +12 -0
  253. package/src/isCustomWidget.ts +19 -0
  254. package/src/isFixedItems.ts +12 -0
  255. package/src/isObject.ts +15 -0
  256. package/src/labelValue.ts +16 -0
  257. package/src/localToUTC.ts +8 -0
  258. package/src/mergeDefaultsWithFormData.ts +53 -0
  259. package/src/mergeObjects.ts +39 -0
  260. package/src/mergeSchemas.ts +38 -0
  261. package/src/optionsList.ts +41 -0
  262. package/src/orderProperties.ts +44 -0
  263. package/src/pad.ts +13 -0
  264. package/src/parseDateString.ts +33 -0
  265. package/src/parser/ParserValidator.ts +132 -0
  266. package/src/parser/index.ts +6 -0
  267. package/src/parser/schemaParser.ts +60 -0
  268. package/src/rangeSpec.ts +22 -0
  269. package/src/replaceStringParameters.ts +22 -0
  270. package/src/schema/getClosestMatchingOption.ts +191 -0
  271. package/src/schema/getDefaultFormState.ts +447 -0
  272. package/src/schema/getDisplayLabel.ts +59 -0
  273. package/src/schema/getFirstMatchingOption.ts +27 -0
  274. package/src/schema/getMatchingOption.ts +95 -0
  275. package/src/schema/index.ts +29 -0
  276. package/src/schema/isFilesArray.ts +27 -0
  277. package/src/schema/isMultiSelect.ts +21 -0
  278. package/src/schema/isSelect.ts +26 -0
  279. package/src/schema/mergeValidationData.ts +38 -0
  280. package/src/schema/retrieveSchema.ts +614 -0
  281. package/src/schema/sanitizeDataForNewSchema.ts +197 -0
  282. package/src/schema/toIdSchema.ts +105 -0
  283. package/src/schema/toPathSchema.ts +121 -0
  284. package/src/schemaRequiresTrueValue.ts +40 -0
  285. package/src/shouldRender.ts +16 -0
  286. package/src/toConstant.ts +19 -0
  287. package/src/toDateString.ts +15 -0
  288. package/src/toErrorList.ts +41 -0
  289. package/src/toErrorSchema.ts +43 -0
  290. package/src/types.ts +1139 -0
  291. package/src/unwrapErrorHandler.ts +25 -0
  292. package/src/utcToLocal.ts +30 -0
  293. package/src/validationDataMerge.ts +31 -0
  294. package/src/withIdRefPrefix.ts +49 -0
  295. package/dist/index.d.ts +0 -1911
  296. package/dist/utils.cjs.development.js +0 -3522
  297. package/dist/utils.cjs.development.js.map +0 -1
  298. package/dist/utils.cjs.production.min.js +0 -2
  299. package/dist/utils.cjs.production.min.js.map +0 -1
  300. package/dist/utils.umd.development.js +0 -3504
  301. package/dist/utils.umd.development.js.map +0 -1
  302. package/dist/utils.umd.production.min.js +0 -2
  303. package/dist/utils.umd.production.min.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSchemaUtils.js","sourceRoot":"","sources":["../src/createSchemaUtils.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ /** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name
2
+ * of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.
3
+ *
4
+ * @param dataURI - The `DataUrl` potentially containing name and raw data to be converted to a Blob
5
+ * @returns - an object containing a Blob and its name, extracted from the URI
6
+ */
7
+ export default function dataURItoBlob(dataURI: string): {
8
+ blob: Blob;
9
+ name: string;
10
+ } | {
11
+ blob: {
12
+ size: number;
13
+ type: string;
14
+ };
15
+ name: string;
16
+ };
@@ -0,0 +1,43 @@
1
+ /** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name
2
+ * of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.
3
+ *
4
+ * @param dataURI - The `DataUrl` potentially containing name and raw data to be converted to a Blob
5
+ * @returns - an object containing a Blob and its name, extracted from the URI
6
+ */
7
+ export default function dataURItoBlob(dataURI) {
8
+ // Split metadata from data
9
+ const splitted = dataURI.split(',');
10
+ // Split params
11
+ const params = splitted[0].split(';');
12
+ // Get mime-type from params
13
+ const type = params[0].replace('data:', '');
14
+ // Filter the name property from params
15
+ const properties = params.filter((param) => {
16
+ return param.split('=')[0] === 'name';
17
+ });
18
+ // Look for the name and use unknown if no name property.
19
+ let name;
20
+ if (properties.length !== 1) {
21
+ name = 'unknown';
22
+ }
23
+ else {
24
+ // Because we filtered out the other property,
25
+ // we only have the name case here, which we decode to make it human-readable
26
+ name = decodeURI(properties[0].split('=')[1]);
27
+ }
28
+ // Built the Uint8Array Blob parameter from the base64 string.
29
+ try {
30
+ const binary = atob(splitted[1]);
31
+ const array = [];
32
+ for (let i = 0; i < binary.length; i++) {
33
+ array.push(binary.charCodeAt(i));
34
+ }
35
+ // Create the blob object
36
+ const blob = new window.Blob([new Uint8Array(array)], { type });
37
+ return { blob, name };
38
+ }
39
+ catch (error) {
40
+ return { blob: { size: 0, type: error.message }, name: dataURI };
41
+ }
42
+ }
43
+ //# sourceMappingURL=dataURItoBlob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataURItoBlob.js","sourceRoot":"","sources":["../src/dataURItoBlob.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAe;IACnD,2BAA2B;IAC3B,MAAM,QAAQ,GAAa,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,eAAe;IACf,MAAM,MAAM,GAAa,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChD,4BAA4B;IAC5B,MAAM,IAAI,GAAW,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACpD,uCAAuC;IACvC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACzC,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;IACxC,CAAC,CAAC,CAAC;IACH,yDAAyD;IACzD,IAAI,IAAY,CAAC;IACjB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,IAAI,GAAG,SAAS,CAAC;KAClB;SAAM;QACL,8CAA8C;QAC9C,6EAA6E;QAC7E,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/C;IAED,8DAA8D;IAC9D,IAAI;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;QACD,yBAAyB;QACzB,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAEhE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KACvB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAG,KAAe,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAC7E;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
2
+ * assumes all functions are equivalent.
3
+ *
4
+ * @param a - The first element to compare
5
+ * @param b - The second element to compare
6
+ * @returns - True if the `a` and `b` are deeply equal, false otherwise
7
+ */
8
+ export default function deepEquals(a: any, b: any): boolean;
@@ -0,0 +1,19 @@
1
+ import isEqualWith from 'lodash/isEqualWith';
2
+ /** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
3
+ * assumes all functions are equivalent.
4
+ *
5
+ * @param a - The first element to compare
6
+ * @param b - The second element to compare
7
+ * @returns - True if the `a` and `b` are deeply equal, false otherwise
8
+ */
9
+ export default function deepEquals(a, b) {
10
+ return isEqualWith(a, b, (obj, other) => {
11
+ if (typeof obj === 'function' && typeof other === 'function') {
12
+ // Assume all functions are equivalent
13
+ // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
14
+ return true;
15
+ }
16
+ return undefined; // fallback to default isEquals behavior
17
+ });
18
+ }
19
+ //# sourceMappingURL=deepEquals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepEquals.js","sourceRoot":"","sources":["../src/deepEquals.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAM,EAAE,CAAM;IAC/C,OAAO,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAQ,EAAE,KAAU,EAAE,EAAE;QAChD,IAAI,OAAO,GAAG,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YAC5D,sCAAsC;YACtC,oEAAoE;YACpE,OAAO,IAAI,CAAC;SACb;QACD,OAAO,SAAS,CAAC,CAAC,wCAAwC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { TranslatableString } from './enums';
2
+ /** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each
3
+ * value in the array is used to replace any of the replaceable parameters in the `stringToTranslate` using the `%1`,
4
+ * `%2`, etc. replacement specifiers.
5
+ *
6
+ * @param stringToTranslate - The `TranslatableString` value to convert to english
7
+ * @param params - The optional list of replaceable parameter values to substitute into the english string
8
+ * @returns - The `stringToTranslate` itself with any replaceable parameter values substituted
9
+ */
10
+ export default function englishStringTranslator(stringToTranslate: TranslatableString, params?: string[]): string;
@@ -0,0 +1,13 @@
1
+ import replaceStringParameters from './replaceStringParameters';
2
+ /** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each
3
+ * value in the array is used to replace any of the replaceable parameters in the `stringToTranslate` using the `%1`,
4
+ * `%2`, etc. replacement specifiers.
5
+ *
6
+ * @param stringToTranslate - The `TranslatableString` value to convert to english
7
+ * @param params - The optional list of replaceable parameter values to substitute into the english string
8
+ * @returns - The `stringToTranslate` itself with any replaceable parameter values substituted
9
+ */
10
+ export default function englishStringTranslator(stringToTranslate, params) {
11
+ return replaceStringParameters(stringToTranslate, params);
12
+ }
13
+ //# sourceMappingURL=englishStringTranslator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"englishStringTranslator.js","sourceRoot":"","sources":["../src/englishStringTranslator.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,iBAAqC,EAAE,MAAiB;IACtG,OAAO,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ /** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
3
+ * a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
4
+ * a single value, then if the enum option value with the `valueIndex` in `allEnumOptions` matches `selected`, undefined
5
+ * is returned, otherwise the `selected` value is returned.
6
+ *
7
+ * @param valueIndex - The index of the value to be removed from the selected list or single value
8
+ * @param selected - The current (list of) selected value(s)
9
+ * @param [allEnumOptions=[]] - The list of all the known enumOptions
10
+ * @returns - The updated `selected` with the enum option value at `valueIndex` in `allEnumOptions` removed from it,
11
+ * unless `selected` is a single value. In that case, if the `valueIndex` value matches `selected`, returns
12
+ * undefined, otherwise `selected`.
13
+ */
14
+ export default function enumOptionsDeselectValue<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number, selected?: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[]): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined;
@@ -0,0 +1,22 @@
1
+ import isEqual from 'lodash/isEqual';
2
+ import enumOptionsValueForIndex from './enumOptionsValueForIndex';
3
+ /** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
4
+ * a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
5
+ * a single value, then if the enum option value with the `valueIndex` in `allEnumOptions` matches `selected`, undefined
6
+ * is returned, otherwise the `selected` value is returned.
7
+ *
8
+ * @param valueIndex - The index of the value to be removed from the selected list or single value
9
+ * @param selected - The current (list of) selected value(s)
10
+ * @param [allEnumOptions=[]] - The list of all the known enumOptions
11
+ * @returns - The updated `selected` with the enum option value at `valueIndex` in `allEnumOptions` removed from it,
12
+ * unless `selected` is a single value. In that case, if the `valueIndex` value matches `selected`, returns
13
+ * undefined, otherwise `selected`.
14
+ */
15
+ export default function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
16
+ const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
17
+ if (Array.isArray(selected)) {
18
+ return selected.filter((v) => !isEqual(v, value));
19
+ }
20
+ return isEqual(value, selected) ? undefined : selected;
21
+ }
22
+ //# sourceMappingURL=enumOptionsDeselectValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumOptionsDeselectValue.js","sourceRoot":"","sources":["../src/enumOptionsDeselectValue.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAGrC,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,UAA2B,EAC3B,QAAsE,EACtE,iBAAuC,EAAE;IAEzC,MAAM,KAAK,GAAG,wBAAwB,CAAI,UAAU,EAAE,cAAc,CAAC,CAAC;IACtE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;KACnD;IACD,OAAO,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AACzD,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ /** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
3
+ * `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
4
+ * stored in an array. If `multiple` is true, that array is returned, otherwise the first element in the array is
5
+ * returned.
6
+ *
7
+ * @param value - The single value or list of values for which indexes are desired
8
+ * @param [allEnumOptions=[]] - The list of all the known enumOptions
9
+ * @param [multiple=false] - Optional flag, if true will return a list of index, otherwise a single one
10
+ * @returns - A single string index for the first `value` in `allEnumOptions`, if not `multiple`. Otherwise, the list
11
+ * of indexes for (each of) the value(s) in `value`.
12
+ */
13
+ export default function enumOptionsIndexForValue<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[], multiple?: boolean): string | string[] | undefined;
@@ -0,0 +1,22 @@
1
+ import enumOptionsIsSelected from './enumOptionsIsSelected';
2
+ /** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
3
+ * `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
4
+ * stored in an array. If `multiple` is true, that array is returned, otherwise the first element in the array is
5
+ * returned.
6
+ *
7
+ * @param value - The single value or list of values for which indexes are desired
8
+ * @param [allEnumOptions=[]] - The list of all the known enumOptions
9
+ * @param [multiple=false] - Optional flag, if true will return a list of index, otherwise a single one
10
+ * @returns - A single string index for the first `value` in `allEnumOptions`, if not `multiple`. Otherwise, the list
11
+ * of indexes for (each of) the value(s) in `value`.
12
+ */
13
+ export default function enumOptionsIndexForValue(value, allEnumOptions = [], multiple = false) {
14
+ const selectedIndexes = allEnumOptions
15
+ .map((opt, index) => (enumOptionsIsSelected(opt.value, value) ? String(index) : undefined))
16
+ .filter((opt) => typeof opt !== 'undefined');
17
+ if (!multiple) {
18
+ return selectedIndexes[0];
19
+ }
20
+ return selectedIndexes;
21
+ }
22
+ //# sourceMappingURL=enumOptionsIndexForValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumOptionsIndexForValue.js","sourceRoot":"","sources":["../src/enumOptionsIndexForValue.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,KAAkE,EAClE,iBAAuC,EAAE,EACzC,QAAQ,GAAG,KAAK;IAEhB,MAAM,eAAe,GAAa,cAAc;SAC7C,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;SAC1F,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,WAAW,CAAa,CAAC;IAC3D,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;KAC3B;IACD,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ /** Determines whether the given `value` is (one of) the `selected` value(s).
3
+ *
4
+ * @param value - The value being checked to see if it is selected
5
+ * @param selected - The current selected value or list of values
6
+ * @returns - true if the `value` is one of the `selected` ones, false otherwise
7
+ */
8
+ export default function enumOptionsIsSelected<S extends StrictRJSFSchema = RJSFSchema>(value: EnumOptionsType<S>['value'], selected: EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][]): boolean;
@@ -0,0 +1,14 @@
1
+ import isEqual from 'lodash/isEqual';
2
+ /** Determines whether the given `value` is (one of) the `selected` value(s).
3
+ *
4
+ * @param value - The value being checked to see if it is selected
5
+ * @param selected - The current selected value or list of values
6
+ * @returns - true if the `value` is one of the `selected` ones, false otherwise
7
+ */
8
+ export default function enumOptionsIsSelected(value, selected) {
9
+ if (Array.isArray(selected)) {
10
+ return selected.some((sel) => isEqual(sel, value));
11
+ }
12
+ return isEqual(selected, value);
13
+ }
14
+ //# sourceMappingURL=enumOptionsIsSelected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumOptionsIsSelected.js","sourceRoot":"","sources":["../src/enumOptionsIsSelected.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAIrC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,KAAkC,EAClC,QAAqE;IAErE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;KACpD;IACD,OAAO,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ /** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
3
+ * `allEnumOptions`
4
+ *
5
+ * @param valueIndex - The index of the value that should be selected
6
+ * @param selected - The current list of selected values
7
+ * @param [allEnumOptions=[]] - The list of all the known enumOptions
8
+ * @returns - The updated list of selected enum values with enum value at the `valueIndex` added to it
9
+ */
10
+ export default function enumOptionsSelectValue<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number, selected: EnumOptionsType<S>['value'][], allEnumOptions?: EnumOptionsType<S>[]): any[];
@@ -0,0 +1,23 @@
1
+ import enumOptionsValueForIndex from './enumOptionsValueForIndex';
2
+ import { isNil } from 'lodash';
3
+ /** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
4
+ * `allEnumOptions`
5
+ *
6
+ * @param valueIndex - The index of the value that should be selected
7
+ * @param selected - The current list of selected values
8
+ * @param [allEnumOptions=[]] - The list of all the known enumOptions
9
+ * @returns - The updated list of selected enum values with enum value at the `valueIndex` added to it
10
+ */
11
+ export default function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
12
+ const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
13
+ if (!isNil(value)) {
14
+ const index = allEnumOptions.findIndex((opt) => value === opt.value);
15
+ const all = allEnumOptions.map(({ value: val }) => val);
16
+ const updated = selected.slice(0, index).concat(value, selected.slice(index));
17
+ // As inserting values at predefined index positions doesn't work with empty
18
+ // arrays, we need to reorder the updated selection to match the initial order
19
+ return updated.sort((a, b) => Number(all.indexOf(a) > all.indexOf(b)));
20
+ }
21
+ return selected;
22
+ }
23
+ //# sourceMappingURL=enumOptionsSelectValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumOptionsSelectValue.js","sourceRoot":"","sources":["../src/enumOptionsSelectValue.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,UAA2B,EAC3B,QAAuC,EACvC,iBAAuC,EAAE;IAEzC,MAAM,KAAK,GAAG,wBAAwB,CAAI,UAAU,EAAE,cAAc,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACjB,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,4EAA4E;QAC5E,8EAA8E;QAC9E,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACxE;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ /** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
3
+ * array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it
4
+ * contains an invalid index, the returned array will have the resulting undefined values filtered out, leaving only
5
+ * valid values or in the worst case, an empty array.
6
+ *
7
+ * @param valueIndex - The index(es) of the value(s) that should be returned
8
+ * @param [allEnumOptions=[]] - The list of all the known enumOptions
9
+ * @param [emptyValue] - The value to return when the non-array `valueIndex` does not refer to a real option
10
+ * @returns - The single or list of values specified by the single or list of indexes if they are valid. Otherwise,
11
+ * `emptyValue` or an empty list.
12
+ */
13
+ export default function enumOptionsValueForIndex<S extends StrictRJSFSchema = RJSFSchema>(valueIndex: string | number | Array<string | number>, allEnumOptions?: EnumOptionsType<S>[], emptyValue?: EnumOptionsType<S>['value']): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined;
@@ -0,0 +1,21 @@
1
+ /** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
2
+ * array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it
3
+ * contains an invalid index, the returned array will have the resulting undefined values filtered out, leaving only
4
+ * valid values or in the worst case, an empty array.
5
+ *
6
+ * @param valueIndex - The index(es) of the value(s) that should be returned
7
+ * @param [allEnumOptions=[]] - The list of all the known enumOptions
8
+ * @param [emptyValue] - The value to return when the non-array `valueIndex` does not refer to a real option
9
+ * @returns - The single or list of values specified by the single or list of indexes if they are valid. Otherwise,
10
+ * `emptyValue` or an empty list.
11
+ */
12
+ export default function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
13
+ if (Array.isArray(valueIndex)) {
14
+ return valueIndex.map((index) => enumOptionsValueForIndex(index, allEnumOptions)).filter((val) => val);
15
+ }
16
+ // So Number(null) and Number('') both return 0, so use emptyValue for those two values
17
+ const index = valueIndex === '' || valueIndex === null ? -1 : Number(valueIndex);
18
+ const option = allEnumOptions[index];
19
+ return option ? option.value : emptyValue;
20
+ }
21
+ //# sourceMappingURL=enumOptionsValueForIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumOptionsValueForIndex.js","sourceRoot":"","sources":["../src/enumOptionsValueForIndex.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,UAAoD,EACpD,iBAAuC,EAAE,EACzC,UAAwC;IAExC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;KACxG;IACD,uFAAuF;IACvF,MAAM,KAAK,GAAG,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjF,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;AAC5C,CAAC"}
package/lib/enums.d.ts ADDED
@@ -0,0 +1,72 @@
1
+ /** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the
2
+ * enumeration keys is expected to be the actual english string. Some strings contain replaceable parameter values
3
+ * as indicated by `%1`, `%2`, etc. The number after the `%` indicates the order of the parameter. The ordering of
4
+ * parameters is important because some languages may choose to put the second parameter before the first in its
5
+ * translation. Also, some strings are rendered using `markdown-to-jsx` and thus support markdown and inline html.
6
+ */
7
+ export declare enum TranslatableString {
8
+ /** Fallback title of an array item, used by ArrayField */
9
+ ArrayItemTitle = "Item",
10
+ /** Missing items reason, used by ArrayField */
11
+ MissingItems = "Missing items definition",
12
+ /** Yes label, used by BooleanField */
13
+ YesLabel = "Yes",
14
+ /** No label, used by BooleanField */
15
+ NoLabel = "No",
16
+ /** Close label, used by ErrorList */
17
+ CloseLabel = "Close",
18
+ /** Errors label, used by ErrorList */
19
+ ErrorsLabel = "Errors",
20
+ /** New additionalProperties string default value, used by ObjectField */
21
+ NewStringDefault = "New Value",
22
+ /** Add button title, used by AddButton */
23
+ AddButton = "Add",
24
+ /** Add button title, used by AddButton */
25
+ AddItemButton = "Add Item",
26
+ /** Copy button title, used by IconButton */
27
+ CopyButton = "Copy",
28
+ /** Move down button title, used by IconButton */
29
+ MoveDownButton = "Move down",
30
+ /** Move up button title, used by IconButton */
31
+ MoveUpButton = "Move up",
32
+ /** Remove button title, used by IconButton */
33
+ RemoveButton = "Remove",
34
+ /** Now label, used by AltDateWidget */
35
+ NowLabel = "Now",
36
+ /** Clear label, used by AltDateWidget */
37
+ ClearLabel = "Clear",
38
+ /** Aria date label, used by DateWidget */
39
+ AriaDateLabel = "Select a date",
40
+ /** File preview label, used by FileWidget */
41
+ PreviewLabel = "Preview",
42
+ /** Decrement button aria label, used by UpDownWidget */
43
+ DecrementAriaLabel = "Decrease value by 1",
44
+ /** Increment button aria label, used by UpDownWidget */
45
+ IncrementAriaLabel = "Increase value by 1",
46
+ /** Unknown field type reason, where %1 will be replaced with the type as provided by SchemaField */
47
+ UnknownFieldType = "Unknown field type %1",
48
+ /** Option prefix, where %1 will be replaced with the option index as provided by MultiSchemaField */
49
+ OptionPrefix = "Option %1",
50
+ /** Option prefix, where %1 and %2 will be replaced by the schema title and option index, respectively as provided by
51
+ * MultiSchemaField
52
+ */
53
+ TitleOptionPrefix = "%1 option %2",
54
+ /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
55
+ KeyLabel = "%1 Key",
56
+ /** Invalid object field configuration as provided by the ObjectField */
57
+ InvalidObjectField = "Invalid \"%1\" object field configuration: <em>%2</em>.",
58
+ /** Unsupported field schema, used by UnsupportedField */
59
+ UnsupportedField = "Unsupported field schema.",
60
+ /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
61
+ UnsupportedFieldWithId = "Unsupported field schema for field <code>%1</code>.",
62
+ /** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField */
63
+ UnsupportedFieldWithReason = "Unsupported field schema: <em>%1</em>.",
64
+ /** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,
65
+ * as provided by UnsupportedField
66
+ */
67
+ UnsupportedFieldWithIdAndReason = "Unsupported field schema for field <code>%1</code>: <em>%2</em>.",
68
+ /** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as
69
+ * provided by FileWidget
70
+ */
71
+ FilesInfo = "<strong>%1</strong> (%2, %3 bytes)"
72
+ }
package/lib/enums.js ADDED
@@ -0,0 +1,76 @@
1
+ /** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the
2
+ * enumeration keys is expected to be the actual english string. Some strings contain replaceable parameter values
3
+ * as indicated by `%1`, `%2`, etc. The number after the `%` indicates the order of the parameter. The ordering of
4
+ * parameters is important because some languages may choose to put the second parameter before the first in its
5
+ * translation. Also, some strings are rendered using `markdown-to-jsx` and thus support markdown and inline html.
6
+ */
7
+ export var TranslatableString;
8
+ (function (TranslatableString) {
9
+ /** Fallback title of an array item, used by ArrayField */
10
+ TranslatableString["ArrayItemTitle"] = "Item";
11
+ /** Missing items reason, used by ArrayField */
12
+ TranslatableString["MissingItems"] = "Missing items definition";
13
+ /** Yes label, used by BooleanField */
14
+ TranslatableString["YesLabel"] = "Yes";
15
+ /** No label, used by BooleanField */
16
+ TranslatableString["NoLabel"] = "No";
17
+ /** Close label, used by ErrorList */
18
+ TranslatableString["CloseLabel"] = "Close";
19
+ /** Errors label, used by ErrorList */
20
+ TranslatableString["ErrorsLabel"] = "Errors";
21
+ /** New additionalProperties string default value, used by ObjectField */
22
+ TranslatableString["NewStringDefault"] = "New Value";
23
+ /** Add button title, used by AddButton */
24
+ TranslatableString["AddButton"] = "Add";
25
+ /** Add button title, used by AddButton */
26
+ TranslatableString["AddItemButton"] = "Add Item";
27
+ /** Copy button title, used by IconButton */
28
+ TranslatableString["CopyButton"] = "Copy";
29
+ /** Move down button title, used by IconButton */
30
+ TranslatableString["MoveDownButton"] = "Move down";
31
+ /** Move up button title, used by IconButton */
32
+ TranslatableString["MoveUpButton"] = "Move up";
33
+ /** Remove button title, used by IconButton */
34
+ TranslatableString["RemoveButton"] = "Remove";
35
+ /** Now label, used by AltDateWidget */
36
+ TranslatableString["NowLabel"] = "Now";
37
+ /** Clear label, used by AltDateWidget */
38
+ TranslatableString["ClearLabel"] = "Clear";
39
+ /** Aria date label, used by DateWidget */
40
+ TranslatableString["AriaDateLabel"] = "Select a date";
41
+ /** File preview label, used by FileWidget */
42
+ TranslatableString["PreviewLabel"] = "Preview";
43
+ /** Decrement button aria label, used by UpDownWidget */
44
+ TranslatableString["DecrementAriaLabel"] = "Decrease value by 1";
45
+ /** Increment button aria label, used by UpDownWidget */
46
+ TranslatableString["IncrementAriaLabel"] = "Increase value by 1";
47
+ // Strings with replaceable parameters
48
+ /** Unknown field type reason, where %1 will be replaced with the type as provided by SchemaField */
49
+ TranslatableString["UnknownFieldType"] = "Unknown field type %1";
50
+ /** Option prefix, where %1 will be replaced with the option index as provided by MultiSchemaField */
51
+ TranslatableString["OptionPrefix"] = "Option %1";
52
+ /** Option prefix, where %1 and %2 will be replaced by the schema title and option index, respectively as provided by
53
+ * MultiSchemaField
54
+ */
55
+ TranslatableString["TitleOptionPrefix"] = "%1 option %2";
56
+ /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
57
+ TranslatableString["KeyLabel"] = "%1 Key";
58
+ // Strings with replaceable parameters AND/OR that support markdown and html
59
+ /** Invalid object field configuration as provided by the ObjectField */
60
+ TranslatableString["InvalidObjectField"] = "Invalid \"%1\" object field configuration: <em>%2</em>.";
61
+ /** Unsupported field schema, used by UnsupportedField */
62
+ TranslatableString["UnsupportedField"] = "Unsupported field schema.";
63
+ /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
64
+ TranslatableString["UnsupportedFieldWithId"] = "Unsupported field schema for field <code>%1</code>.";
65
+ /** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField */
66
+ TranslatableString["UnsupportedFieldWithReason"] = "Unsupported field schema: <em>%1</em>.";
67
+ /** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,
68
+ * as provided by UnsupportedField
69
+ */
70
+ TranslatableString["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field <code>%1</code>: <em>%2</em>.";
71
+ /** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as
72
+ * provided by FileWidget
73
+ */
74
+ TranslatableString["FilesInfo"] = "<strong>%1</strong> (%2, %3 bytes)";
75
+ })(TranslatableString || (TranslatableString = {}));
76
+ //# sourceMappingURL=enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,kBAmEX;AAnED,WAAY,kBAAkB;IAC5B,0DAA0D;IAC1D,6CAAuB,CAAA;IACvB,+CAA+C;IAC/C,+DAAyC,CAAA;IACzC,sCAAsC;IACtC,sCAAgB,CAAA;IAChB,qCAAqC;IACrC,oCAAc,CAAA;IACd,qCAAqC;IACrC,0CAAoB,CAAA;IACpB,sCAAsC;IACtC,4CAAsB,CAAA;IACtB,yEAAyE;IACzE,oDAA8B,CAAA;IAC9B,0CAA0C;IAC1C,uCAAiB,CAAA;IACjB,0CAA0C;IAC1C,gDAA0B,CAAA;IAC1B,4CAA4C;IAC5C,yCAAmB,CAAA;IACnB,iDAAiD;IACjD,kDAA4B,CAAA;IAC5B,+CAA+C;IAC/C,8CAAwB,CAAA;IACxB,8CAA8C;IAC9C,6CAAuB,CAAA;IACvB,uCAAuC;IACvC,sCAAgB,CAAA;IAChB,yCAAyC;IACzC,0CAAoB,CAAA;IACpB,0CAA0C;IAC1C,qDAA+B,CAAA;IAC/B,6CAA6C;IAC7C,8CAAwB,CAAA;IACxB,wDAAwD;IACxD,gEAA0C,CAAA;IAC1C,wDAAwD;IACxD,gEAA0C,CAAA;IAC1C,sCAAsC;IACtC,oGAAoG;IACpG,gEAA0C,CAAA;IAC1C,qGAAqG;IACrG,gDAA0B,CAAA;IAC1B;;OAEG;IACH,wDAAkC,CAAA;IAClC,gGAAgG;IAChG,yCAAmB,CAAA;IACnB,4EAA4E;IAC5E,wEAAwE;IACxE,oGAA4E,CAAA;IAC5E,yDAAyD;IACzD,oEAA8C,CAAA;IAC9C,8GAA8G;IAC9G,oGAA8E,CAAA;IAC9E,+GAA+G;IAC/G,2FAAqE,CAAA;IACrE;;OAEG;IACH,0HAAoG,CAAA;IACpG;;OAEG;IACH,sEAAgD,CAAA;AAClD,CAAC,EAnEW,kBAAkB,KAAlB,kBAAkB,QAmE7B"}
@@ -0,0 +1,20 @@
1
+ import { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ /** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
3
+ * location, the `object` minus the `key: value` and in the second location the `value`.
4
+ *
5
+ * @param key - The key from the object to extract
6
+ * @param object - The object from which to extract the element
7
+ * @returns - An array with the first value being the object minus the `key` element and the second element being the
8
+ * value from `object[key]`
9
+ */
10
+ export declare function splitKeyElementFromObject(key: string, object: GenericObjectType): any[];
11
+ /** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
12
+ * path provided by that reference. If `#` is not the first character of the reference, or the path does not exist in
13
+ * the schema, then throw an Error. Otherwise return the sub-schema. Also deals with nested `$ref`s in the sub-schema.
14
+ *
15
+ * @param $ref - The ref string for which the schema definition is desired
16
+ * @param [rootSchema={}] - The root schema in which to search for the definition
17
+ * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
18
+ * @throws - Error indicating that no schema for that reference exists
19
+ */
20
+ export default function findSchemaDefinition<S extends StrictRJSFSchema = RJSFSchema>($ref?: string, rootSchema?: S): S;
@@ -0,0 +1,49 @@
1
+ import jsonpointer from 'jsonpointer';
2
+ import omit from 'lodash/omit';
3
+ import { REF_KEY } from './constants';
4
+ /** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
5
+ * location, the `object` minus the `key: value` and in the second location the `value`.
6
+ *
7
+ * @param key - The key from the object to extract
8
+ * @param object - The object from which to extract the element
9
+ * @returns - An array with the first value being the object minus the `key` element and the second element being the
10
+ * value from `object[key]`
11
+ */
12
+ export function splitKeyElementFromObject(key, object) {
13
+ const value = object[key];
14
+ const remaining = omit(object, [key]);
15
+ return [remaining, value];
16
+ }
17
+ /** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
18
+ * path provided by that reference. If `#` is not the first character of the reference, or the path does not exist in
19
+ * the schema, then throw an Error. Otherwise return the sub-schema. Also deals with nested `$ref`s in the sub-schema.
20
+ *
21
+ * @param $ref - The ref string for which the schema definition is desired
22
+ * @param [rootSchema={}] - The root schema in which to search for the definition
23
+ * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
24
+ * @throws - Error indicating that no schema for that reference exists
25
+ */
26
+ export default function findSchemaDefinition($ref, rootSchema = {}) {
27
+ let ref = $ref || '';
28
+ if (ref.startsWith('#')) {
29
+ // Decode URI fragment representation.
30
+ ref = decodeURIComponent(ref.substring(1));
31
+ }
32
+ else {
33
+ throw new Error(`Could not find a definition for ${$ref}.`);
34
+ }
35
+ const current = jsonpointer.get(rootSchema, ref);
36
+ if (current === undefined) {
37
+ throw new Error(`Could not find a definition for ${$ref}.`);
38
+ }
39
+ if (current[REF_KEY]) {
40
+ const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
41
+ const subSchema = findSchemaDefinition(theRef, rootSchema);
42
+ if (Object.keys(remaining).length > 0) {
43
+ return Object.assign(Object.assign({}, remaining), subSchema);
44
+ }
45
+ return subSchema;
46
+ }
47
+ return current;
48
+ }
49
+ //# sourceMappingURL=findSchemaDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findSchemaDefinition.js","sourceRoot":"","sources":["../src/findSchemaDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAAW,EAAE,MAAyB;IAC9E,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,IAAa,EACb,aAAgB,EAAO;IAEvB,IAAI,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACrB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACvB,sCAAsC;QACtC,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5C;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,GAAG,CAAC,CAAC;KAC7D;IACD,MAAM,OAAO,GAAM,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACpD,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,GAAG,CAAC,CAAC;KAC7D;IACD,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QACpB,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxE,MAAM,SAAS,GAAG,oBAAoB,CAAI,MAAM,EAAE,UAAU,CAAC,CAAC;QAC9D,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACrC,uCAAY,SAAS,GAAK,SAAS,EAAG;SACvC;QACD,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { RJSFSchema, StrictRJSFSchema } from './types';
2
+ /** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when
3
+ * it is not a string. Returns `undefined` when a valid discriminator is not present.
4
+ *
5
+ * @param schema - The schema from which the discriminator is potentially obtained
6
+ * @returns - The `discriminator.propertyName` if it exists in the schema, otherwise `undefined`
7
+ */
8
+ export default function getDiscriminatorFieldFromSchema<S extends StrictRJSFSchema = RJSFSchema>(schema: S): string | undefined;
@@ -0,0 +1,20 @@
1
+ import get from 'lodash/get';
2
+ import isString from 'lodash/isString';
3
+ /** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when
4
+ * it is not a string. Returns `undefined` when a valid discriminator is not present.
5
+ *
6
+ * @param schema - The schema from which the discriminator is potentially obtained
7
+ * @returns - The `discriminator.propertyName` if it exists in the schema, otherwise `undefined`
8
+ */
9
+ export default function getDiscriminatorFieldFromSchema(schema) {
10
+ let discriminator;
11
+ const maybeString = get(schema, 'discriminator.propertyName', undefined);
12
+ if (isString(maybeString)) {
13
+ discriminator = maybeString;
14
+ }
15
+ else if (maybeString !== undefined) {
16
+ console.warn(`Expecting discriminator to be a string, got "${typeof maybeString}" instead`);
17
+ }
18
+ return discriminator;
19
+ }
20
+ //# sourceMappingURL=getDiscriminatorFieldFromSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDiscriminatorFieldFromSchema.js","sourceRoot":"","sources":["../src/getDiscriminatorFieldFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAIvC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,+BAA+B,CAA0C,MAAS;IACxG,IAAI,aAAiC,CAAC;IACtC,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,4BAA4B,EAAE,SAAS,CAAC,CAAC;IACzE,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE;QACzB,aAAa,GAAG,WAAW,CAAC;KAC7B;SAAM,IAAI,WAAW,KAAK,SAAS,EAAE;QACpC,OAAO,CAAC,IAAI,CAAC,gDAAgD,OAAO,WAAW,WAAW,CAAC,CAAC;KAC7F;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { FormContextType, InputPropsType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from './types';
2
+ /** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
3
+ *
4
+ * @param schema - The schema for the field provided by the widget
5
+ * @param [defaultType] - The default type, if any, for the field provided by the widget
6
+ * @param [options={}] - The UI Options for the field provided by the widget
7
+ * @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step
8
+ * @returns - The extracted `InputPropsType` object
9
+ */
10
+ export default function getInputProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: RJSFSchema, defaultType?: string, options?: UIOptionsType<T, S, F>, autoDefaultStepAny?: boolean): InputPropsType;