@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
@@ -0,0 +1,17 @@
1
+ import { TestIdShape } from './types.js';
2
+ /** Returns an object of test IDs that can only be used in test mode. If the function is called in a test environment
3
+ * (`NODE_ENV === 'test'`, this is set by jest) then a Proxy object will be returned. If a key within the returned
4
+ * object is accessed, if the value already exists the object will return that value, otherwise it will create that key
5
+ * with a generated `uuid` value and return the generated ID. If it is called outside of a test environment, the
6
+ * function will return an empty object, therefore returning `undefined` for any property within the object and
7
+ * excluding the prop from the rendered output of the component in which it is used.
8
+ * This implementation was adapted from the following blog post: https://www.matthewsessions.com/blog/react-test-id/
9
+ * To use this helper, you will want to generate a separate object for each component to avoid potential overlapping of
10
+ * ID names. You will also want to export the object for use in tests, because the keys will be generated in the
11
+ * component file, and used in the test file. Within the component file, add:
12
+ * `export const TEST_IDS = getTestIds();`
13
+ * Then pass `TEST_IDS.examplePropertyName` as the value of the test ID attribute of the intended component. This will
14
+ * allow you to use `TEST_IDS.examplePropertyName` within your tests, while keeping the test IDs out of your rendered
15
+ * output.
16
+ */
17
+ export default function getTestIds(): TestIdShape;
@@ -0,0 +1,34 @@
1
+ import { nanoid } from 'nanoid';
2
+ import get from 'lodash-es/get.js';
3
+ /** Returns an object of test IDs that can only be used in test mode. If the function is called in a test environment
4
+ * (`NODE_ENV === 'test'`, this is set by jest) then a Proxy object will be returned. If a key within the returned
5
+ * object is accessed, if the value already exists the object will return that value, otherwise it will create that key
6
+ * with a generated `uuid` value and return the generated ID. If it is called outside of a test environment, the
7
+ * function will return an empty object, therefore returning `undefined` for any property within the object and
8
+ * excluding the prop from the rendered output of the component in which it is used.
9
+ * This implementation was adapted from the following blog post: https://www.matthewsessions.com/blog/react-test-id/
10
+ * To use this helper, you will want to generate a separate object for each component to avoid potential overlapping of
11
+ * ID names. You will also want to export the object for use in tests, because the keys will be generated in the
12
+ * component file, and used in the test file. Within the component file, add:
13
+ * `export const TEST_IDS = getTestIds();`
14
+ * Then pass `TEST_IDS.examplePropertyName` as the value of the test ID attribute of the intended component. This will
15
+ * allow you to use `TEST_IDS.examplePropertyName` within your tests, while keeping the test IDs out of your rendered
16
+ * output.
17
+ */
18
+ export default function getTestIds() {
19
+ // For some reason, even though process.env contains the value of `test` for NODE_ENV, accessing it directly returns
20
+ // 'development'. Using `get()` does, in fact, return test so sticking with it
21
+ if (typeof process === 'undefined' || get(process, 'env.NODE_ENV') !== 'test') {
22
+ return {};
23
+ }
24
+ const ids = new Map();
25
+ return new Proxy({}, {
26
+ get(_obj, prop) {
27
+ if (!ids.has(prop)) {
28
+ ids.set(prop, nanoid());
29
+ }
30
+ return ids.get(prop);
31
+ },
32
+ });
33
+ }
34
+ //# sourceMappingURL=getTestIds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTestIds.js","sourceRoot":"","sources":["../src/getTestIds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,GAAG,MAAM,YAAY,CAAC;AAI7B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU;IAChC,oHAAoH;IACpH,8EAA8E;IAC9E,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,MAAM,EAAE,CAAC;QAC9E,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACtB,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,CAAC,IAAI,EAAE,IAAI;YACZ,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAC1B,CAAC;YACD,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FormContextType, GlobalUISchemaOptions, RJSFSchema, StrictRJSFSchema, UIOptionsType, UiSchema } from './types';
1
+ import { FormContextType, GlobalUISchemaOptions, RJSFSchema, StrictRJSFSchema, UIOptionsType, UiSchema } from './types.js';
2
2
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
3
3
  * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { UI_OPTIONS_KEY, UI_WIDGET_KEY } from './constants';
2
- import isObject from './isObject';
1
+ import { UI_OPTIONS_KEY, UI_WIDGET_KEY } from './constants.js';
2
+ import isObject from './isObject.js';
3
3
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
4
4
  * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"getUiOptions.js","sourceRoot":"","sources":["../src/getUiOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA8B,EAAE,EAChC,gBAAuC,EAAE;IAEzC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACzC,MAAM,CACL,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;QACf,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,GAAG,KAAK,aAAa,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC5C,OAAO,CAAC,KAAK,CAAC,qFAAqF,CAAC,CAAC;YACrG,OAAO,OAAO,CAAC;SAChB;QACD,IAAI,GAAG,KAAK,cAAc,IAAI,QAAQ,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G,aAAa,EAAE,CACrB,CAAC;AACN,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FormContextType, RJSFSchema, Widget, RegistryWidgetsType, StrictRJSFSchema } from './types';
1
+ import { FormContextType, RJSFSchema, Widget, RegistryWidgetsType, StrictRJSFSchema } from './types.js';
2
2
  /** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
3
3
  * React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped
4
4
  * with a `MergedWidget`. Otherwise an attempt is made to look up the widget inside of the `registeredWidgets` map based
package/lib/getWidget.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createElement } from 'react';
3
3
  import ReactIs from 'react-is';
4
- import get from 'lodash/get';
5
- import set from 'lodash/set';
6
- import getSchemaType from './getSchemaType';
4
+ import get from 'lodash-es/get.js';
5
+ import set from 'lodash-es/set.js';
6
+ import getSchemaType from './getSchemaType.js';
7
7
  /** The map of schema types to widget type to widget name
8
8
  */
9
9
  const widgetMap = {
@@ -1 +1 @@
1
- {"version":3,"file":"getWidget.js","sourceRoot":"","sources":["../src/getWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,GAAG,MAAM,YAAY,CAAC;AAG7B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;GACG;AACH,MAAM,SAAS,GAA6C;IAC1D,OAAO,EAAE;QACP,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,aAAa;QACpB,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,cAAc;KACvB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE,YAAY;QAClB,IA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kB,CAAU,MAAyB,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,kCAAkC,OAAO,MAAM,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,MAAM,IAAI,iBAAiB,EAAE,CAAC;QAChC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO,SAAS,CAAU,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC,CAAC,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,GAAG,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACpE,OAAO,SAAS,CAAU,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,cAAc,MAAM,eAAe,IAAI,GAAG,CAAC,CAAC;AAC9D,CAAC"}
@@ -4,4 +4,4 @@
4
4
  * @param value - The value from which to guess the type
5
5
  * @returns - The best guess for the object type
6
6
  */
7
- export default function guessType(value: any): "number" | "string" | "boolean" | "object" | "array" | "null";
7
+ export default function guessType(value: any): "string" | "object" | "number" | "boolean" | "array" | "null";
@@ -1 +1 @@
1
- {"version":3,"file":"guessType.js","sourceRoot":"","sources":["../src/guessType.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAU;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,OAAO,CAAC;KAChB;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,QAAQ,CAAC;KACjB;IACD,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,OAAO,MAAM,CAAC;KACf;IACD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QAC9B,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACjB,OAAO,QAAQ,CAAC;KACjB;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,QAAQ,CAAC;KACjB;IACD,8CAA8C;IAC9C,OAAO,QAAQ,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"guessType.js","sourceRoot":"","sources":["../src/guessType.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAU;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,8CAA8C;IAC9C,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema, Widget } from './types';
1
+ import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema, Widget } from './types.js';
2
2
  /** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
3
3
  * does, or false if it doesn't.
4
4
  *
package/lib/hasWidget.js CHANGED
@@ -1,4 +1,4 @@
1
- import getWidget from './getWidget';
1
+ import getWidget from './getWidget.js';
2
2
  /** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
3
3
  * does, or false if it doesn't.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"hasWidget.js","sourceRoot":"","sources":["../src/hasWidget.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,MAAkB,EAClB,MAAgC,EAChC,oBAAkD,EAAE;IAEpD,IAAI;QACF,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,GAAG,GAAU,CAAU,CAAC;QAC9B,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,EAAE;YACxG,OAAO,KAAK,CAAC;SACd;QACD,MAAM,CAAC,CAAC;KACT;AACH,CAAC"}
1
+ {"version":3,"file":"hasWidget.js","sourceRoot":"","sources":["../src/hasWidget.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,MAAkB,EAClB,MAAgC,EAChC,oBAAkD,EAAE;IAEpD,IAAI,CAAC;QACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,GAAG,GAAU,CAAU,CAAC;QAC9B,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC;YACzG,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
@@ -1,4 +1,26 @@
1
- import { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import { RJSFSchema, StrictRJSFSchema } from './types.js';
2
+ /** Hashes a string using the algorithm based on Java's hashing function.
3
+ * JS has no built-in hashing function, so rolling our own
4
+ * based on Java's hashing fn:
5
+ * http://www.java2s.com/example/nodejs-utility-method/string-hash/hashcode-4dc2b.html
6
+ *
7
+ * @param string - The string for which to get the hash
8
+ * @returns - The resulting hash of the string in hex format
9
+ */
10
+ export declare function hashString(string: string): string;
11
+ /** Stringifies an `object`, sorts object fields in consistent order before stringifying it.
12
+ *
13
+ * @param object - The object for which the sorted stringify is desired
14
+ * @returns - The stringified object with keys sorted in a consistent order
15
+ */
16
+ export declare function sortedJSONStringify(object: unknown): string;
17
+ /** Stringifies an `object` and returns the hash of the resulting string. Sorts object fields
18
+ * in consistent order before stringify to prevent different hash ids for the same object.
19
+ *
20
+ * @param object - The object for which the hash is desired
21
+ * @returns - The string obtained from the hash of the stringified object
22
+ */
23
+ export declare function hashObject(object: unknown): string;
2
24
  /** Stringifies the schema and returns the hash of the resulting string. Sorts schema fields
3
25
  * in consistent order before stringify to prevent different hash ids for the same schema.
4
26
  *
@@ -1,11 +1,12 @@
1
- /** JS has no built-in hashing function, so rolling our own
1
+ /** Hashes a string using the algorithm based on Java's hashing function.
2
+ * JS has no built-in hashing function, so rolling our own
2
3
  * based on Java's hashing fn:
3
4
  * http://www.java2s.com/example/nodejs-utility-method/string-hash/hashcode-4dc2b.html
4
5
  *
5
6
  * @param string - The string for which to get the hash
6
7
  * @returns - The resulting hash of the string in hex format
7
8
  */
8
- function hashString(string) {
9
+ export function hashString(string) {
9
10
  let hash = 0;
10
11
  for (let i = 0; i < string.length; i += 1) {
11
12
  const chr = string.charCodeAt(i);
@@ -14,6 +15,26 @@ function hashString(string) {
14
15
  }
15
16
  return hash.toString(16);
16
17
  }
18
+ /** Stringifies an `object`, sorts object fields in consistent order before stringifying it.
19
+ *
20
+ * @param object - The object for which the sorted stringify is desired
21
+ * @returns - The stringified object with keys sorted in a consistent order
22
+ */
23
+ export function sortedJSONStringify(object) {
24
+ const allKeys = new Set();
25
+ // solution source: https://stackoverflow.com/questions/16167581/sort-object-properties-and-json-stringify/53593328#53593328
26
+ JSON.stringify(object, (key, value) => (allKeys.add(key), value));
27
+ return JSON.stringify(object, Array.from(allKeys).sort());
28
+ }
29
+ /** Stringifies an `object` and returns the hash of the resulting string. Sorts object fields
30
+ * in consistent order before stringify to prevent different hash ids for the same object.
31
+ *
32
+ * @param object - The object for which the hash is desired
33
+ * @returns - The string obtained from the hash of the stringified object
34
+ */
35
+ export function hashObject(object) {
36
+ return hashString(sortedJSONStringify(object));
37
+ }
17
38
  /** Stringifies the schema and returns the hash of the resulting string. Sorts schema fields
18
39
  * in consistent order before stringify to prevent different hash ids for the same schema.
19
40
  *
@@ -21,9 +42,6 @@ function hashString(string) {
21
42
  * @returns - The string obtained from the hash of the stringified schema
22
43
  */
23
44
  export default function hashForSchema(schema) {
24
- const allKeys = new Set();
25
- // solution source: https://stackoverflow.com/questions/16167581/sort-object-properties-and-json-stringify/53593328#53593328
26
- JSON.stringify(schema, (key, value) => (allKeys.add(key), value));
27
- return hashString(JSON.stringify(schema, Array.from(allKeys).sort()));
45
+ return hashObject(schema);
28
46
  }
29
47
  //# sourceMappingURL=hashForSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hashForSchema.js","sourceRoot":"","sources":["../src/hashForSchema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,MAAc;IAChC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACzC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC;QAChC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,2BAA2B;KAChD;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAA0C,MAAS;IACtF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,4HAA4H;IAC5H,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IAClE,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACxE,CAAC"}
1
+ {"version":3,"file":"hashForSchema.js","sourceRoot":"","sources":["../src/hashForSchema.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC;QAChC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,2BAA2B;IACjD,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAe;IACjD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,4HAA4H;IAC5H,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IAClE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAe;IACxC,OAAO,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAA0C,MAAS;IACtF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { IdSchema } from './types';
1
+ import { IdSchema } from './types.js';
2
2
  /** Return a consistent `id` for the field description element
3
3
  *
4
4
  * @param id - Either simple string id or an IdSchema from which to extract it
@@ -45,3 +45,10 @@ export declare function ariaDescribedByIds<T = any>(id: IdSchema<T> | string, in
45
45
  * @returns - An id for the option index based on the parent `id`
46
46
  */
47
47
  export declare function optionId(id: string, optionIndex: number): string;
48
+ /** Return a consistent `id` for the `btn` button element
49
+ *
50
+ * @param id - Either simple string id or an IdSchema from which to extract it
51
+ * @param btn - The button type for which to generate the id
52
+ * @returns - The consistent id for the button from the given `id` and `btn` type
53
+ */
54
+ export declare function buttonId<T = any>(id: IdSchema<T> | string, btn: 'add' | 'copy' | 'moveDown' | 'moveUp' | 'remove'): string;
@@ -1,5 +1,5 @@
1
- import isString from 'lodash/isString';
2
- import { ID_KEY } from './constants';
1
+ import isString from 'lodash-es/isString.js';
2
+ import { ID_KEY } from './constants.js';
3
3
  /** Generates a consistent `id` pattern for a given `id` and a `suffix`
4
4
  *
5
5
  * @param id - Either simple string id or an IdSchema from which to extract it
@@ -70,4 +70,13 @@ export function ariaDescribedByIds(id, includeExamples = false) {
70
70
  export function optionId(id, optionIndex) {
71
71
  return `${id}-${optionIndex}`;
72
72
  }
73
+ /** Return a consistent `id` for the `btn` button element
74
+ *
75
+ * @param id - Either simple string id or an IdSchema from which to extract it
76
+ * @param btn - The button type for which to generate the id
77
+ * @returns - The consistent id for the button from the given `id` and `btn` type
78
+ */
79
+ export function buttonId(id, btn) {
80
+ return idGenerator(id, btn);
81
+ }
73
82
  //# sourceMappingURL=idGenerators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"idGenerators.js","sourceRoot":"","sources":["../src/idGenerators.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;GAIG;AACH,SAAS,WAAW,CAAU,EAAwB,EAAE,MAAc;IACpE,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,GAAG,KAAK,KAAK,MAAM,EAAE,CAAC;AAC/B,CAAC;AACD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAU,EAAwB;IAC7D,OAAO,WAAW,CAAI,EAAE,EAAE,aAAa,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,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E,GAAG,CAAC,CAAC;AACjC,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,60 +1,63 @@
1
- import allowAdditionalItems from './allowAdditionalItems';
2
- import asNumber from './asNumber';
3
- import canExpand from './canExpand';
4
- import createErrorHandler from './createErrorHandler';
5
- import createSchemaUtils from './createSchemaUtils';
6
- import dataURItoBlob from './dataURItoBlob';
7
- import dateRangeOptions from './dateRangeOptions';
8
- import deepEquals from './deepEquals';
9
- import englishStringTranslator from './englishStringTranslator';
10
- import enumOptionsDeselectValue from './enumOptionsDeselectValue';
11
- import enumOptionsIndexForValue from './enumOptionsIndexForValue';
12
- import enumOptionsIsSelected from './enumOptionsIsSelected';
13
- import enumOptionsSelectValue from './enumOptionsSelectValue';
14
- import enumOptionsValueForIndex from './enumOptionsValueForIndex';
15
- import ErrorSchemaBuilder from './ErrorSchemaBuilder';
16
- import findSchemaDefinition from './findSchemaDefinition';
17
- import getDateElementProps, { type DateElementFormat } from './getDateElementProps';
18
- import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';
19
- import getInputProps from './getInputProps';
20
- import getSchemaType from './getSchemaType';
21
- import getSubmitButtonOptions from './getSubmitButtonOptions';
22
- import getTemplate from './getTemplate';
23
- import getUiOptions from './getUiOptions';
24
- import getWidget from './getWidget';
25
- import guessType from './guessType';
26
- import hashForSchema from './hashForSchema';
27
- import hasWidget from './hasWidget';
28
- import { ariaDescribedByIds, descriptionId, errorId, examplesId, helpId, optionId, titleId } from './idGenerators';
29
- import isConstant from './isConstant';
30
- import isCustomWidget from './isCustomWidget';
31
- import isFixedItems from './isFixedItems';
32
- import isObject from './isObject';
33
- import labelValue from './labelValue';
34
- import localToUTC from './localToUTC';
35
- import mergeDefaultsWithFormData from './mergeDefaultsWithFormData';
36
- import mergeObjects from './mergeObjects';
37
- import mergeSchemas from './mergeSchemas';
38
- import optionsList from './optionsList';
39
- import orderProperties from './orderProperties';
40
- import pad from './pad';
41
- import parseDateString from './parseDateString';
42
- import rangeSpec from './rangeSpec';
43
- import replaceStringParameters from './replaceStringParameters';
44
- import schemaRequiresTrueValue from './schemaRequiresTrueValue';
45
- import shouldRender from './shouldRender';
46
- import toConstant from './toConstant';
47
- import toDateString from './toDateString';
48
- import toErrorList from './toErrorList';
49
- import toErrorSchema from './toErrorSchema';
50
- import unwrapErrorHandler from './unwrapErrorHandler';
51
- import utcToLocal from './utcToLocal';
52
- import validationDataMerge from './validationDataMerge';
53
- import withIdRefPrefix from './withIdRefPrefix';
54
- import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator';
55
- export * from './types';
56
- export * from './enums';
57
- export * from './constants';
58
- export * from './parser';
59
- export * from './schema';
60
- export { allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createErrorHandler, createSchemaUtils, DateElementFormat, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
1
+ import allowAdditionalItems from './allowAdditionalItems.js';
2
+ import asNumber from './asNumber.js';
3
+ import canExpand from './canExpand.js';
4
+ import createErrorHandler from './createErrorHandler.js';
5
+ import createSchemaUtils from './createSchemaUtils.js';
6
+ import dataURItoBlob from './dataURItoBlob.js';
7
+ import dateRangeOptions from './dateRangeOptions.js';
8
+ import deepEquals from './deepEquals.js';
9
+ import englishStringTranslator from './englishStringTranslator.js';
10
+ import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
11
+ import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
12
+ import enumOptionsIsSelected from './enumOptionsIsSelected.js';
13
+ import enumOptionsSelectValue from './enumOptionsSelectValue.js';
14
+ import enumOptionsValueForIndex from './enumOptionsValueForIndex.js';
15
+ import ErrorSchemaBuilder from './ErrorSchemaBuilder.js';
16
+ import findSchemaDefinition from './findSchemaDefinition.js';
17
+ import getDateElementProps, { type DateElementFormat } from './getDateElementProps.js';
18
+ import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema.js';
19
+ import getInputProps from './getInputProps.js';
20
+ import getSchemaType from './getSchemaType.js';
21
+ import getSubmitButtonOptions from './getSubmitButtonOptions.js';
22
+ import getTemplate from './getTemplate.js';
23
+ import getTestIds from './getTestIds.js';
24
+ import getUiOptions from './getUiOptions.js';
25
+ import getWidget from './getWidget.js';
26
+ import guessType from './guessType.js';
27
+ import hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema.js';
28
+ import hasWidget from './hasWidget.js';
29
+ import { ariaDescribedByIds, buttonId, descriptionId, errorId, examplesId, helpId, optionId, titleId } from './idGenerators.js';
30
+ import isConstant from './isConstant.js';
31
+ import isCustomWidget from './isCustomWidget.js';
32
+ import isFixedItems from './isFixedItems.js';
33
+ import isObject from './isObject.js';
34
+ import labelValue from './labelValue.js';
35
+ import localToUTC from './localToUTC.js';
36
+ import lookupFromFormContext from './lookupFromFormContext.js';
37
+ import mergeDefaultsWithFormData from './mergeDefaultsWithFormData.js';
38
+ import mergeObjects from './mergeObjects.js';
39
+ import mergeSchemas from './mergeSchemas.js';
40
+ import optionsList from './optionsList.js';
41
+ import orderProperties from './orderProperties.js';
42
+ import pad from './pad.js';
43
+ import parseDateString from './parseDateString.js';
44
+ import rangeSpec from './rangeSpec.js';
45
+ import replaceStringParameters from './replaceStringParameters.js';
46
+ import schemaRequiresTrueValue from './schemaRequiresTrueValue.js';
47
+ import shouldRender from './shouldRender.js';
48
+ import toConstant from './toConstant.js';
49
+ import toDateString from './toDateString.js';
50
+ import toErrorList from './toErrorList.js';
51
+ import toErrorSchema from './toErrorSchema.js';
52
+ import unwrapErrorHandler from './unwrapErrorHandler.js';
53
+ import utcToLocal from './utcToLocal.js';
54
+ import validationDataMerge from './validationDataMerge.js';
55
+ import withIdRefPrefix from './withIdRefPrefix.js';
56
+ import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator.js';
57
+ import getChangedFields from './getChangedFields.js';
58
+ export * from './types.js';
59
+ export * from './enums.js';
60
+ export * from './constants.js';
61
+ export * from './parser/index.js';
62
+ export * from './schema/index.js';
63
+ export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElementFormat, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
package/lib/index.js CHANGED
@@ -1,61 +1,64 @@
1
- import allowAdditionalItems from './allowAdditionalItems';
2
- import asNumber from './asNumber';
3
- import canExpand from './canExpand';
4
- import createErrorHandler from './createErrorHandler';
5
- import createSchemaUtils from './createSchemaUtils';
6
- import dataURItoBlob from './dataURItoBlob';
7
- import dateRangeOptions from './dateRangeOptions';
8
- import deepEquals from './deepEquals';
9
- import englishStringTranslator from './englishStringTranslator';
10
- import enumOptionsDeselectValue from './enumOptionsDeselectValue';
11
- import enumOptionsIndexForValue from './enumOptionsIndexForValue';
12
- import enumOptionsIsSelected from './enumOptionsIsSelected';
13
- import enumOptionsSelectValue from './enumOptionsSelectValue';
14
- import enumOptionsValueForIndex from './enumOptionsValueForIndex';
15
- import ErrorSchemaBuilder from './ErrorSchemaBuilder';
16
- import findSchemaDefinition from './findSchemaDefinition';
17
- import getDateElementProps from './getDateElementProps';
18
- import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';
19
- import getInputProps from './getInputProps';
20
- import getSchemaType from './getSchemaType';
21
- import getSubmitButtonOptions from './getSubmitButtonOptions';
22
- import getTemplate from './getTemplate';
23
- import getUiOptions from './getUiOptions';
24
- import getWidget from './getWidget';
25
- import guessType from './guessType';
26
- import hashForSchema from './hashForSchema';
27
- import hasWidget from './hasWidget';
28
- import { ariaDescribedByIds, descriptionId, errorId, examplesId, helpId, optionId, titleId } from './idGenerators';
29
- import isConstant from './isConstant';
30
- import isCustomWidget from './isCustomWidget';
31
- import isFixedItems from './isFixedItems';
32
- import isObject from './isObject';
33
- import labelValue from './labelValue';
34
- import localToUTC from './localToUTC';
35
- import mergeDefaultsWithFormData from './mergeDefaultsWithFormData';
36
- import mergeObjects from './mergeObjects';
37
- import mergeSchemas from './mergeSchemas';
38
- import optionsList from './optionsList';
39
- import orderProperties from './orderProperties';
40
- import pad from './pad';
41
- import parseDateString from './parseDateString';
42
- import rangeSpec from './rangeSpec';
43
- import replaceStringParameters from './replaceStringParameters';
44
- import schemaRequiresTrueValue from './schemaRequiresTrueValue';
45
- import shouldRender from './shouldRender';
46
- import toConstant from './toConstant';
47
- import toDateString from './toDateString';
48
- import toErrorList from './toErrorList';
49
- import toErrorSchema from './toErrorSchema';
50
- import unwrapErrorHandler from './unwrapErrorHandler';
51
- import utcToLocal from './utcToLocal';
52
- import validationDataMerge from './validationDataMerge';
53
- import withIdRefPrefix from './withIdRefPrefix';
54
- import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator';
55
- export * from './types';
56
- export * from './enums';
57
- export * from './constants';
58
- export * from './parser';
59
- export * from './schema';
60
- export { allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
1
+ import allowAdditionalItems from './allowAdditionalItems.js';
2
+ import asNumber from './asNumber.js';
3
+ import canExpand from './canExpand.js';
4
+ import createErrorHandler from './createErrorHandler.js';
5
+ import createSchemaUtils from './createSchemaUtils.js';
6
+ import dataURItoBlob from './dataURItoBlob.js';
7
+ import dateRangeOptions from './dateRangeOptions.js';
8
+ import deepEquals from './deepEquals.js';
9
+ import englishStringTranslator from './englishStringTranslator.js';
10
+ import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
11
+ import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
12
+ import enumOptionsIsSelected from './enumOptionsIsSelected.js';
13
+ import enumOptionsSelectValue from './enumOptionsSelectValue.js';
14
+ import enumOptionsValueForIndex from './enumOptionsValueForIndex.js';
15
+ import ErrorSchemaBuilder from './ErrorSchemaBuilder.js';
16
+ import findSchemaDefinition from './findSchemaDefinition.js';
17
+ import getDateElementProps from './getDateElementProps.js';
18
+ import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema.js';
19
+ import getInputProps from './getInputProps.js';
20
+ import getSchemaType from './getSchemaType.js';
21
+ import getSubmitButtonOptions from './getSubmitButtonOptions.js';
22
+ import getTemplate from './getTemplate.js';
23
+ import getTestIds from './getTestIds.js';
24
+ import getUiOptions from './getUiOptions.js';
25
+ import getWidget from './getWidget.js';
26
+ import guessType from './guessType.js';
27
+ import hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema.js';
28
+ import hasWidget from './hasWidget.js';
29
+ import { ariaDescribedByIds, buttonId, descriptionId, errorId, examplesId, helpId, optionId, titleId, } from './idGenerators.js';
30
+ import isConstant from './isConstant.js';
31
+ import isCustomWidget from './isCustomWidget.js';
32
+ import isFixedItems from './isFixedItems.js';
33
+ import isObject from './isObject.js';
34
+ import labelValue from './labelValue.js';
35
+ import localToUTC from './localToUTC.js';
36
+ import lookupFromFormContext from './lookupFromFormContext.js';
37
+ import mergeDefaultsWithFormData from './mergeDefaultsWithFormData.js';
38
+ import mergeObjects from './mergeObjects.js';
39
+ import mergeSchemas from './mergeSchemas.js';
40
+ import optionsList from './optionsList.js';
41
+ import orderProperties from './orderProperties.js';
42
+ import pad from './pad.js';
43
+ import parseDateString from './parseDateString.js';
44
+ import rangeSpec from './rangeSpec.js';
45
+ import replaceStringParameters from './replaceStringParameters.js';
46
+ import schemaRequiresTrueValue from './schemaRequiresTrueValue.js';
47
+ import shouldRender from './shouldRender.js';
48
+ import toConstant from './toConstant.js';
49
+ import toDateString from './toDateString.js';
50
+ import toErrorList from './toErrorList.js';
51
+ import toErrorSchema from './toErrorSchema.js';
52
+ import unwrapErrorHandler from './unwrapErrorHandler.js';
53
+ import utcToLocal from './utcToLocal.js';
54
+ import validationDataMerge from './validationDataMerge.js';
55
+ import withIdRefPrefix from './withIdRefPrefix.js';
56
+ import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator.js';
57
+ import getChangedFields from './getChangedFields.js';
58
+ export * from './types.js';
59
+ export * from './enums.js';
60
+ export * from './constants.js';
61
+ export * from './parser/index.js';
62
+ export * from './schema/index.js';
63
+ export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
61
64
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,iBAAiB,MAAM,qBAAqB,CA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AuB,EACvB,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,eAAe,GAChB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { RJSFSchema, StrictRJSFSchema } from './types';
1
+ import { RJSFSchema, StrictRJSFSchema } from './types.js';
2
2
  /** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
3
3
  * an `enum` array with a single value or there is a `const` defined.
4
4
  *
package/lib/isConstant.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CONST_KEY } from './constants';
1
+ import { CONST_KEY } from './constants.js';
2
2
  /** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
3
3
  * an `enum` array with a single value or there is a `const` defined.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
1
+ import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.js';
2
2
  /** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
3
3
  *
4
4
  * @param uiSchema - The UI Schema from which to detect if it is customized
@@ -1,4 +1,4 @@
1
- import getUiOptions from './getUiOptions';
1
+ import getUiOptions from './getUiOptions.js';
2
2
  /** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
3
3
  *
4
4
  * @param uiSchema - The UI Schema from which to detect if it is customized