@rjsf/utils 6.6.1 → 6.7.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 (289) hide show
  1. package/LICENSE.md +201 -0
  2. package/dist/index.cjs +534 -376
  3. package/dist/index.cjs.map +4 -4
  4. package/dist/utils.esm.js +534 -376
  5. package/dist/utils.esm.js.map +4 -4
  6. package/dist/utils.umd.js +561 -400
  7. package/lib/ErrorSchemaBuilder.d.ts +1 -1
  8. package/lib/SelectedOptionDescription.d.ts +4 -0
  9. package/lib/SelectedOptionDescription.js +24 -0
  10. package/lib/SelectedOptionDescription.js.map +1 -0
  11. package/lib/allowAdditionalItems.d.ts +1 -1
  12. package/lib/allowAdditionalItems.js +1 -0
  13. package/lib/allowAdditionalItems.js.map +1 -1
  14. package/lib/asNumber.js +2 -0
  15. package/lib/asNumber.js.map +1 -1
  16. package/lib/canExpand.d.ts +1 -1
  17. package/lib/constIsAjvDataReference.d.ts +1 -1
  18. package/lib/constants.d.ts +8 -5
  19. package/lib/constants.js +10 -7
  20. package/lib/constants.js.map +1 -1
  21. package/lib/createErrorHandler.d.ts +1 -1
  22. package/lib/createErrorHandler.js +2 -6
  23. package/lib/createErrorHandler.js.map +1 -1
  24. package/lib/createSchemaUtils.d.ts +1 -1
  25. package/lib/createSchemaUtils.js +3 -1
  26. package/lib/createSchemaUtils.js.map +1 -1
  27. package/lib/dataURItoBlob.js +3 -3
  28. package/lib/dataURItoBlob.js.map +1 -1
  29. package/lib/dateRangeOptions.d.ts +1 -1
  30. package/lib/dateRangeOptions.js +8 -7
  31. package/lib/dateRangeOptions.js.map +1 -1
  32. package/lib/englishStringTranslator.d.ts +1 -1
  33. package/lib/enumOptionSelectedValue.d.ts +1 -1
  34. package/lib/enumOptionValueDecoder.d.ts +1 -1
  35. package/lib/enumOptionValueDecoder.js +1 -1
  36. package/lib/enumOptionValueDecoder.js.map +1 -1
  37. package/lib/enumOptionValueEncoder.d.ts +1 -1
  38. package/lib/enumOptionsDeselectValue.d.ts +1 -1
  39. package/lib/enumOptionsIndexForValue.d.ts +1 -1
  40. package/lib/enumOptionsIndexForValue.js.map +1 -1
  41. package/lib/enumOptionsIsSelected.d.ts +1 -1
  42. package/lib/enumOptionsSelectValue.d.ts +1 -1
  43. package/lib/enumOptionsValueForIndex.d.ts +2 -2
  44. package/lib/enumOptionsValueForIndex.js.map +1 -1
  45. package/lib/enums.d.ts +4 -0
  46. package/lib/enums.js +4 -0
  47. package/lib/enums.js.map +1 -1
  48. package/lib/findSchemaDefinition.d.ts +1 -1
  49. package/lib/findSchemaDefinition.js +15 -15
  50. package/lib/findSchemaDefinition.js.map +1 -1
  51. package/lib/getChangedFields.js +4 -6
  52. package/lib/getChangedFields.js.map +1 -1
  53. package/lib/getDateElementProps.d.ts +3 -3
  54. package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
  55. package/lib/getDiscriminatorFieldFromSchema.js +1 -0
  56. package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
  57. package/lib/getInputProps.d.ts +1 -1
  58. package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
  59. package/lib/getOptionMatchingSimpleDiscriminator.js +10 -11
  60. package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
  61. package/lib/getOptionValueFormat.d.ts +1 -1
  62. package/lib/getSchemaType.d.ts +1 -1
  63. package/lib/getSchemaType.js +2 -1
  64. package/lib/getSchemaType.js.map +1 -1
  65. package/lib/getSubmitButtonOptions.d.ts +1 -1
  66. package/lib/getSubmitButtonOptions.js +1 -1
  67. package/lib/getSubmitButtonOptions.js.map +1 -1
  68. package/lib/getTemplate.d.ts +1 -1
  69. package/lib/getTestIds.d.ts +1 -1
  70. package/lib/getUiOptions.d.ts +1 -1
  71. package/lib/getUiOptions.js +2 -1
  72. package/lib/getUiOptions.js.map +1 -1
  73. package/lib/getWidget.d.ts +1 -1
  74. package/lib/getWidget.js +4 -4
  75. package/lib/getWidget.js.map +1 -1
  76. package/lib/guessType.js +1 -1
  77. package/lib/guessType.js.map +1 -1
  78. package/lib/hasWidget.d.ts +1 -1
  79. package/lib/hashForSchema.d.ts +3 -1
  80. package/lib/hashForSchema.js +11 -4
  81. package/lib/hashForSchema.js.map +1 -1
  82. package/lib/idGenerators.d.ts +1 -1
  83. package/lib/index.d.ts +14 -7
  84. package/lib/index.js +5 -2
  85. package/lib/index.js.map +1 -1
  86. package/lib/isConstant.d.ts +1 -1
  87. package/lib/isCustomWidget.d.ts +1 -1
  88. package/lib/isCustomWidget.js +1 -1
  89. package/lib/isCustomWidget.js.map +1 -1
  90. package/lib/isFixedItems.d.ts +3 -3
  91. package/lib/isFixedItems.js +3 -3
  92. package/lib/isFixedItems.js.map +1 -1
  93. package/lib/isRootSchema.d.ts +1 -1
  94. package/lib/isRootSchema.js +2 -3
  95. package/lib/isRootSchema.js.map +1 -1
  96. package/lib/labelValue.d.ts +1 -1
  97. package/lib/logUnsupportedDefaultForEnum.d.ts +9 -0
  98. package/lib/logUnsupportedDefaultForEnum.js +18 -0
  99. package/lib/logUnsupportedDefaultForEnum.js.map +1 -0
  100. package/lib/lookupFromFormContext.d.ts +1 -1
  101. package/lib/mergeDefaultsWithFormData.js +6 -5
  102. package/lib/mergeDefaultsWithFormData.js.map +1 -1
  103. package/lib/mergeObjects.d.ts +4 -2
  104. package/lib/mergeObjects.js +1 -1
  105. package/lib/mergeObjects.js.map +1 -1
  106. package/lib/mergeSchemas.d.ts +4 -2
  107. package/lib/mergeSchemas.js +13 -6
  108. package/lib/mergeSchemas.js.map +1 -1
  109. package/lib/nameGenerators.d.ts +1 -1
  110. package/lib/optionsList.d.ts +1 -1
  111. package/lib/optionsList.js +22 -21
  112. package/lib/optionsList.js.map +1 -1
  113. package/lib/orderProperties.js +3 -3
  114. package/lib/orderProperties.js.map +1 -1
  115. package/lib/pad.js +1 -1
  116. package/lib/pad.js.map +1 -1
  117. package/lib/parseDateString.d.ts +1 -1
  118. package/lib/parseDateString.js +1 -1
  119. package/lib/parseDateString.js.map +1 -1
  120. package/lib/parser/ParserValidator.d.ts +2 -4
  121. package/lib/parser/ParserValidator.js +2 -0
  122. package/lib/parser/ParserValidator.js.map +1 -1
  123. package/lib/parser/index.d.ts +1 -1
  124. package/lib/parser/schemaParser.d.ts +2 -2
  125. package/lib/parser/schemaParser.js +7 -7
  126. package/lib/parser/schemaParser.js.map +1 -1
  127. package/lib/rangeSpec.d.ts +1 -2
  128. package/lib/rangeSpec.js.map +1 -1
  129. package/lib/removeOptionalEmptyObjects.d.ts +1 -1
  130. package/lib/removeOptionalEmptyObjects.js +6 -8
  131. package/lib/removeOptionalEmptyObjects.js.map +1 -1
  132. package/lib/resolveUiSchema.d.ts +1 -1
  133. package/lib/resolveUiSchema.js +16 -16
  134. package/lib/resolveUiSchema.js.map +1 -1
  135. package/lib/schema/findFieldInSchema.d.ts +1 -1
  136. package/lib/schema/findSelectedOptionInXxxOf.d.ts +1 -1
  137. package/lib/schema/findSelectedOptionInXxxOf.js +1 -3
  138. package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
  139. package/lib/schema/getClosestMatchingOption.d.ts +1 -1
  140. package/lib/schema/getClosestMatchingOption.js +6 -9
  141. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  142. package/lib/schema/getDefaultFormState.d.ts +4 -4
  143. package/lib/schema/getDefaultFormState.js +81 -43
  144. package/lib/schema/getDefaultFormState.js.map +1 -1
  145. package/lib/schema/getDisplayLabel.d.ts +1 -1
  146. package/lib/schema/getDisplayLabel.js +2 -3
  147. package/lib/schema/getDisplayLabel.js.map +1 -1
  148. package/lib/schema/getFirstMatchingOption.d.ts +1 -1
  149. package/lib/schema/getFirstMatchingOption.js +2 -2
  150. package/lib/schema/getFirstMatchingOption.js.map +1 -1
  151. package/lib/schema/getFromSchema.d.ts +1 -1
  152. package/lib/schema/index.js +9 -3
  153. package/lib/schema/index.js.map +1 -1
  154. package/lib/schema/isFilesArray.d.ts +1 -1
  155. package/lib/schema/isMultiSelect.d.ts +1 -1
  156. package/lib/schema/isMultiSelect.js.map +1 -1
  157. package/lib/schema/isSelect.d.ts +1 -1
  158. package/lib/schema/isSelect.js +1 -1
  159. package/lib/schema/isSelect.js.map +1 -1
  160. package/lib/schema/omitExtraData.d.ts +1 -1
  161. package/lib/schema/omitExtraData.js +66 -52
  162. package/lib/schema/omitExtraData.js.map +1 -1
  163. package/lib/schema/retrieveSchema.d.ts +7 -3
  164. package/lib/schema/retrieveSchema.js +83 -56
  165. package/lib/schema/retrieveSchema.js.map +1 -1
  166. package/lib/schema/sanitizeDataForNewSchema.d.ts +1 -1
  167. package/lib/schema/sanitizeDataForNewSchema.js +48 -7
  168. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  169. package/lib/schema/toPathSchema.d.ts +1 -1
  170. package/lib/schema/toPathSchema.js +9 -5
  171. package/lib/schema/toPathSchema.js.map +1 -1
  172. package/lib/schemaRequiresTrueValue.d.ts +1 -1
  173. package/lib/schemaRequiresTrueValue.js +4 -3
  174. package/lib/schemaRequiresTrueValue.js.map +1 -1
  175. package/lib/shallowEquals.js +2 -2
  176. package/lib/shallowEquals.js.map +1 -1
  177. package/lib/shouldRenderOptionalField.d.ts +1 -1
  178. package/lib/toConstant.d.ts +1 -1
  179. package/lib/toDateString.d.ts +1 -1
  180. package/lib/toErrorList.d.ts +1 -1
  181. package/lib/toErrorList.js +3 -3
  182. package/lib/toErrorList.js.map +1 -1
  183. package/lib/toErrorSchema.d.ts +1 -1
  184. package/lib/toFieldPathId.d.ts +1 -1
  185. package/lib/tsconfig.tsbuildinfo +1 -1
  186. package/lib/types.d.ts +63 -57
  187. package/lib/unwrapErrorHandler.d.ts +1 -1
  188. package/lib/unwrapErrorHandler.js +7 -9
  189. package/lib/unwrapErrorHandler.js.map +1 -1
  190. package/lib/useAltDateWidgetProps.d.ts +6 -6
  191. package/lib/useAltDateWidgetProps.js +3 -3
  192. package/lib/useAltDateWidgetProps.js.map +1 -1
  193. package/lib/useFileWidgetProps.d.ts +2 -2
  194. package/lib/useFileWidgetProps.js +3 -3
  195. package/lib/useFileWidgetProps.js.map +1 -1
  196. package/lib/validationDataMerge.d.ts +1 -1
  197. package/lib/withIdRefPrefix.d.ts +1 -1
  198. package/lib/withIdRefPrefix.js +12 -12
  199. package/lib/withIdRefPrefix.js.map +1 -1
  200. package/package.json +19 -19
  201. package/src/ErrorSchemaBuilder.ts +1 -1
  202. package/src/SelectedOptionDescription.tsx +48 -0
  203. package/src/allowAdditionalItems.ts +2 -1
  204. package/src/asNumber.ts +2 -0
  205. package/src/canExpand.ts +1 -1
  206. package/src/constIsAjvDataReference.ts +2 -2
  207. package/src/constants.ts +10 -7
  208. package/src/createErrorHandler.ts +6 -7
  209. package/src/createSchemaUtils.ts +4 -2
  210. package/src/dataURItoBlob.ts +3 -3
  211. package/src/dateRangeOptions.ts +9 -7
  212. package/src/englishStringTranslator.ts +1 -1
  213. package/src/enumOptionSelectedValue.ts +1 -1
  214. package/src/enumOptionValueDecoder.ts +2 -2
  215. package/src/enumOptionValueEncoder.ts +1 -1
  216. package/src/enumOptionsDeselectValue.ts +1 -1
  217. package/src/enumOptionsIndexForValue.ts +2 -2
  218. package/src/enumOptionsIsSelected.ts +1 -1
  219. package/src/enumOptionsSelectValue.ts +1 -1
  220. package/src/enumOptionsValueForIndex.ts +2 -2
  221. package/src/enums.ts +4 -0
  222. package/src/findSchemaDefinition.ts +18 -17
  223. package/src/getChangedFields.ts +5 -5
  224. package/src/getDateElementProps.ts +3 -3
  225. package/src/getDiscriminatorFieldFromSchema.ts +2 -1
  226. package/src/getInputProps.ts +1 -1
  227. package/src/getOptionMatchingSimpleDiscriminator.ts +11 -15
  228. package/src/getOptionValueFormat.ts +1 -1
  229. package/src/getSchemaType.ts +3 -2
  230. package/src/getSubmitButtonOptions.ts +3 -3
  231. package/src/getTemplate.ts +1 -1
  232. package/src/getTestIds.ts +1 -1
  233. package/src/getUiOptions.ts +10 -2
  234. package/src/getWidget.tsx +5 -6
  235. package/src/guessType.ts +1 -1
  236. package/src/hasWidget.ts +1 -1
  237. package/src/hashForSchema.ts +12 -5
  238. package/src/idGenerators.ts +1 -1
  239. package/src/index.ts +16 -5
  240. package/src/isConstant.ts +1 -1
  241. package/src/isCustomWidget.ts +2 -2
  242. package/src/isFixedItems.ts +4 -4
  243. package/src/isRootSchema.ts +3 -5
  244. package/src/labelValue.ts +1 -1
  245. package/src/logUnsupportedDefaultForEnum.ts +28 -0
  246. package/src/lookupFromFormContext.ts +1 -1
  247. package/src/mergeDefaultsWithFormData.ts +8 -7
  248. package/src/mergeObjects.ts +2 -2
  249. package/src/mergeSchemas.ts +14 -7
  250. package/src/nameGenerators.ts +1 -1
  251. package/src/optionsList.ts +21 -23
  252. package/src/orderProperties.ts +4 -4
  253. package/src/pad.ts +1 -1
  254. package/src/parseDateString.ts +2 -2
  255. package/src/parser/ParserValidator.ts +4 -4
  256. package/src/parser/index.ts +1 -1
  257. package/src/parser/schemaParser.ts +10 -9
  258. package/src/rangeSpec.ts +1 -2
  259. package/src/removeOptionalEmptyObjects.ts +8 -11
  260. package/src/resolveUiSchema.ts +32 -25
  261. package/src/schema/findFieldInSchema.ts +1 -1
  262. package/src/schema/findSelectedOptionInXxxOf.ts +17 -7
  263. package/src/schema/getClosestMatchingOption.ts +17 -11
  264. package/src/schema/getDefaultFormState.ts +104 -43
  265. package/src/schema/getDisplayLabel.ts +4 -5
  266. package/src/schema/getFirstMatchingOption.ts +3 -3
  267. package/src/schema/getFromSchema.ts +1 -1
  268. package/src/schema/index.ts +3 -0
  269. package/src/schema/isFilesArray.ts +1 -1
  270. package/src/schema/isMultiSelect.ts +7 -1
  271. package/src/schema/isSelect.ts +8 -2
  272. package/src/schema/omitExtraData.ts +73 -60
  273. package/src/schema/retrieveSchema.ts +131 -83
  274. package/src/schema/sanitizeDataForNewSchema.ts +57 -8
  275. package/src/schema/toPathSchema.ts +11 -7
  276. package/src/schemaRequiresTrueValue.ts +4 -4
  277. package/src/shallowEquals.ts +2 -2
  278. package/src/shouldRenderOptionalField.ts +1 -1
  279. package/src/toConstant.ts +1 -1
  280. package/src/toDateString.ts +1 -1
  281. package/src/toErrorList.ts +4 -4
  282. package/src/toErrorSchema.ts +1 -1
  283. package/src/toFieldPathId.ts +1 -1
  284. package/src/types.ts +92 -63
  285. package/src/unwrapErrorHandler.ts +11 -12
  286. package/src/useAltDateWidgetProps.tsx +10 -8
  287. package/src/useFileWidgetProps.ts +7 -7
  288. package/src/validationDataMerge.ts +1 -1
  289. package/src/withIdRefPrefix.ts +12 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/utils",
3
- "version": "6.6.1",
3
+ "version": "6.7.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -42,20 +42,6 @@
42
42
  "engines": {
43
43
  "node": ">=20"
44
44
  },
45
- "scripts": {
46
- "compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
47
- "build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
48
- "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
49
- "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm",
50
- "build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils",
51
- "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
52
- "cs-check": "oxfmt --check \"{src,test}/**/*.{ts,tsx}\"",
53
- "cs-format": "oxfmt \"{src,test}/**/*.{ts,tsx}\"",
54
- "lint": "oxlint src test",
55
- "precommit": "lint-staged",
56
- "test": "vitest run",
57
- "test:debug": "node --inspect-brk ../../node_modules/.bin/vitest --pool=forks"
58
- },
59
45
  "lint-staged": {
60
46
  "{src,test}/**/*.{ts,tsx}": [
61
47
  "oxlint --fix",
@@ -68,7 +54,7 @@
68
54
  "dependencies": {
69
55
  "@x0k/json-schema-merge": "^1.0.3",
70
56
  "fast-equals": "^6.0.0",
71
- "fast-uri": "^3.1.2",
57
+ "fast-uri": "^4.0.0",
72
58
  "jsonpointer": "^5.0.1",
73
59
  "lodash": "^4.18.1",
74
60
  "lodash-es": "^4.18.1",
@@ -77,7 +63,7 @@
77
63
  "devDependencies": {
78
64
  "@types/json-schema": "^7.0.15",
79
65
  "@types/react-is": "^18.3.1",
80
- "deep-freeze-es6": "^4.0.1"
66
+ "deep-freeze-es6": "^5.0.0"
81
67
  },
82
68
  "publishConfig": {
83
69
  "access": "public"
@@ -96,5 +82,19 @@
96
82
  "type": "git",
97
83
  "url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
98
84
  },
99
- "license": "Apache-2.0"
100
- }
85
+ "license": "Apache-2.0",
86
+ "scripts": {
87
+ "compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
88
+ "build:ts": "pnpm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
89
+ "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
90
+ "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm",
91
+ "build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils",
92
+ "build": "pnpm run build:ts && pnpm run build:cjs && pnpm run build:esm && pnpm run build:umd",
93
+ "cs-check": "oxfmt --check \"{src,test}/**/*.{ts,tsx}\"",
94
+ "cs-format": "oxfmt \"{src,test}/**/*.{ts,tsx}\"",
95
+ "lint": "oxlint src test",
96
+ "precommit": "lint-staged",
97
+ "test": "vitest run",
98
+ "test:debug": "node --inspect-brk ../../node_modules/.bin/vitest --pool=forks"
99
+ }
100
+ }
@@ -4,7 +4,7 @@ import set from 'lodash/set';
4
4
  import setWith from 'lodash/setWith';
5
5
 
6
6
  import { ERRORS_KEY } from './constants';
7
- import { ErrorSchema, FieldPathList } from './types';
7
+ import type { ErrorSchema, FieldPathList } from './types';
8
8
 
9
9
  /** Represents the type of the path which can be a string of dotted path values or a list of string or numbers where
10
10
  * numbers represent array indexes/
@@ -0,0 +1,48 @@
1
+ import enumOptionsIsSelected from './enumOptionsIsSelected';
2
+ import getTemplate from './getTemplate';
3
+ import getUiOptions from './getUiOptions';
4
+ import { descriptionId } from './idGenerators';
5
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from './types';
6
+
7
+ export type SelectedOptionDescriptionProps<
8
+ T = any,
9
+ S extends StrictRJSFSchema = RJSFSchema,
10
+ F extends FormContextType = any,
11
+ > = Pick<WidgetProps<T, S, F>, 'id' | 'multiple' | 'options' | 'registry' | 'uiSchema' | 'value' | 'hideLabel'>;
12
+
13
+ /** Renders the description associated with the selected oneOf or anyOf option in a single-select widget. */
14
+ export default function SelectedOptionDescription<
15
+ T = any,
16
+ S extends StrictRJSFSchema = RJSFSchema,
17
+ F extends FormContextType = any,
18
+ >({ hideLabel, id, multiple, options, registry, uiSchema, value }: SelectedOptionDescriptionProps<T, S, F>) {
19
+ if (multiple || hideLabel) {
20
+ return null;
21
+ }
22
+
23
+ const { label = true } = getUiOptions<T, S, F>(uiSchema, registry.globalUiOptions);
24
+ if (!label) {
25
+ return null;
26
+ }
27
+
28
+ const option = options.enumOptions?.find(({ value: enumValue }) => enumOptionsIsSelected(enumValue, value));
29
+ const description = option?.schema?.description;
30
+ if (!description) {
31
+ return null;
32
+ }
33
+
34
+ const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>(
35
+ 'DescriptionFieldTemplate',
36
+ registry,
37
+ options,
38
+ );
39
+ return (
40
+ <DescriptionFieldTemplate
41
+ id={descriptionId(id)}
42
+ description={description}
43
+ schema={option.schema!}
44
+ uiSchema={uiSchema}
45
+ registry={registry}
46
+ />
47
+ );
48
+ }
@@ -1,5 +1,5 @@
1
1
  import isObject from './isObject';
2
- import { RJSFSchema, StrictRJSFSchema } from './types';
2
+ import type { RJSFSchema, StrictRJSFSchema } from './types';
3
3
 
4
4
  /** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an
5
5
  * object. The user is warned in the console if `schema.additionalItems` has the value `true`.
@@ -9,6 +9,7 @@ import { RJSFSchema, StrictRJSFSchema } from './types';
9
9
  */
10
10
  export default function allowAdditionalItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {
11
11
  if (schema.additionalItems === true) {
12
+ // oxlint-disable-next-line no-console
12
13
  console.warn('additionalItems=true is currently not supported');
13
14
  }
14
15
  return isObject(schema.additionalItems);
package/src/asNumber.ts CHANGED
@@ -14,11 +14,13 @@ export default function asNumber(value: string | null) {
14
14
  if (value === null) {
15
15
  return null;
16
16
  }
17
+ // oxlint-disable-next-line typescript/prefer-string-starts-ends-with -- regex test() coerces undefined to "undefined" safely; endsWith() throws on undefined values passed at runtime
17
18
  if (/\.$/.test(value)) {
18
19
  // '3.' can't really be considered a number even if it parses in js. The
19
20
  // user is most likely entering a float.
20
21
  return value;
21
22
  }
23
+ // oxlint-disable-next-line typescript/prefer-string-starts-ends-with -- same as above
22
24
  if (/\.0$/.test(value)) {
23
25
  // we need to return this as a string here, to allow for input like 3.07
24
26
  return value;
package/src/canExpand.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import getUiOptions from './getUiOptions';
2
- import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
3
3
 
4
4
  /** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
5
5
  * the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the
@@ -1,8 +1,8 @@
1
- import { JSONSchema7Type } from 'json-schema';
1
+ import type { JSONSchema7Type } from 'json-schema';
2
2
  import isString from 'lodash/isString';
3
3
 
4
4
  import { CONST_KEY, getSchemaType, isObject } from './';
5
- import { RJSFSchema, StrictRJSFSchema } from './types';
5
+ import type { RJSFSchema, StrictRJSFSchema } from './types';
6
6
 
7
7
  /**
8
8
  * Checks if the schema const property value is an AJV $data reference
package/src/constants.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
2
- * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
3
- * `RJSF_ADDITIONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
4
- * utility.
2
+ * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG`,
3
+ * `RJSF_REF_KEY`, and `RJSF_REF_CYCLE_KEY` Symbols that are added to a schema under certain conditions by the
4
+ * `retrieveSchema()` utility. Using Symbols keeps these internal markers invisible to JSON serialisation and
5
+ * JSON Schema validators (AJV, ATA, etc.), which only enumerate string-keyed properties.
5
6
  */
6
- export const ADDITIONAL_PROPERTY_FLAG = '__additional_property';
7
+ export const ADDITIONAL_PROPERTY_FLAG = Symbol('__additional_property');
7
8
  export const ADDITIONAL_PROPERTIES_KEY = 'additionalProperties';
8
9
  export const ALL_OF_KEY = 'allOf';
9
10
  export const ANY_OF_KEY = 'anyOf';
@@ -25,7 +26,8 @@ export const READONLY_KEY = 'readonly';
25
26
  export const REQUIRED_KEY = 'required';
26
27
  export const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';
27
28
  export const REF_KEY = '$ref';
28
- export const RJSF_REF_KEY = '__rjsf_ref';
29
+ export const RJSF_REF_KEY = Symbol('__rjsf_ref');
30
+ export const RJSF_REF_CYCLE_KEY = Symbol('__rjsf_ref_cycle');
29
31
  export const SCHEMA_KEY = '$schema';
30
32
  export const DEFAULT_ID_PREFIX = 'root';
31
33
  export const DEFAULT_ID_SEPARATOR = '_';
@@ -40,8 +42,9 @@ export const FORM_CONTEXT_NAME = 'formContext';
40
42
  /** The name of the `layoutGridLookupMap` attribute in the form context
41
43
  */
42
44
  export const LOOKUP_MAP_NAME = 'layoutGridLookupMap';
43
- export const RJSF_ADDITIONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
44
- export const ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';
45
+ export const RJSF_PREFIX_KEY = '__rjsf';
46
+ export const RJSF_ADDITIONAL_PROPERTIES_FLAG = `${RJSF_PREFIX_KEY}_additionalProperties`;
47
+ export const ROOT_SCHEMA_PREFIX = `${RJSF_PREFIX_KEY}_rootSchema`;
45
48
  export const UI_FIELD_KEY = 'ui:field';
46
49
  export const UI_WIDGET_KEY = 'ui:widget';
47
50
  export const UI_OPTIONS_KEY = 'ui:options';
@@ -1,7 +1,7 @@
1
1
  import isPlainObject from 'lodash/isPlainObject';
2
2
 
3
3
  import { ERRORS_KEY } from './constants';
4
- import { FieldValidation, FormValidation, GenericObjectType } from './types';
4
+ import type { FieldValidation, FormValidation, GenericObjectType } from './types';
5
5
 
6
6
  /** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it
7
7
  *
@@ -19,15 +19,14 @@ export default function createErrorHandler<T = any>(formData: T): FormValidation
19
19
  },
20
20
  };
21
21
  if (Array.isArray(formData)) {
22
- return formData.reduce((acc, value, key) => {
23
- return { ...acc, [key]: createErrorHandler(value) };
24
- }, handler);
22
+ return formData.reduce((acc, value, key) => ({ ...acc, [key]: createErrorHandler(value) }), handler);
25
23
  }
26
24
  if (isPlainObject(formData)) {
27
25
  const formObject: GenericObjectType = formData as GenericObjectType;
28
- return Object.keys(formObject).reduce((acc, key) => {
29
- return { ...acc, [key]: createErrorHandler(formObject[key]) };
30
- }, handler as FormValidation<T>);
26
+ return Object.keys(formObject).reduce(
27
+ (acc, key) => ({ ...acc, [key]: createErrorHandler(formObject[key]) }),
28
+ handler as FormValidation<T>,
29
+ );
31
30
  }
32
31
  return handler as FormValidation<T>;
33
32
  }
@@ -19,7 +19,7 @@ import {
19
19
  sanitizeDataForNewSchema,
20
20
  toPathSchema,
21
21
  } from './schema';
22
- import {
22
+ import type {
23
23
  Experimental_CustomMergeAllOf,
24
24
  Experimental_DefaultFormStateBehavior,
25
25
  FormContextType,
@@ -63,7 +63,7 @@ class SchemaUtils<
63
63
  experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior,
64
64
  experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,
65
65
  ) {
66
- if (rootSchema && rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
66
+ if (rootSchema?.[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
67
67
  this.rootSchema = makeAllReferencesAbsolute(rootSchema, get(rootSchema, ID_KEY, '#'));
68
68
  } else {
69
69
  this.rootSchema = rootSchema;
@@ -364,7 +364,9 @@ class SchemaUtils<
364
364
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
365
365
  * @returns - The `PathSchema` object for the `schema`
366
366
  */
367
+ // oxlint-disable-next-line typescript/no-deprecated
367
368
  toPathSchema(schema: S, name?: string, formData?: T): PathSchema<T> {
369
+ // oxlint-disable-next-line typescript/no-deprecated
368
370
  return toPathSchema<T, S, F>(
369
371
  this.validator,
370
372
  schema,
@@ -6,7 +6,7 @@
6
6
  */
7
7
  export default function dataURItoBlob(dataURILike: string) {
8
8
  // check if is dataURI
9
- if (dataURILike.indexOf('data:') === -1) {
9
+ if (!dataURILike.includes('data:')) {
10
10
  throw new Error('File is invalid: URI must be a dataURI');
11
11
  }
12
12
  const dataURI = dataURILike.slice(5);
@@ -32,7 +32,7 @@ export default function dataURItoBlob(dataURILike: string) {
32
32
  try {
33
33
  const binary = atob(base64);
34
34
  const array = new Array(binary.length);
35
- for (let i = 0; i < binary.length; i++) {
35
+ for (let i = 0; i < binary.length; i += 1) {
36
36
  array[i] = binary.charCodeAt(i);
37
37
  }
38
38
  // Create the blob object
@@ -40,6 +40,6 @@ export default function dataURItoBlob(dataURILike: string) {
40
40
 
41
41
  return { blob, name };
42
42
  } catch (error) {
43
- throw new Error('File is invalid: ' + (error as Error).message);
43
+ throw new Error(`File is invalid: ${(error as Error).message}`);
44
44
  }
45
45
  }
@@ -1,5 +1,5 @@
1
1
  import pad from './pad';
2
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
3
3
 
4
4
  /** Returns a list of options for a date range between `start` and `stop`. If the start date is greater than the end
5
5
  * date, then the date range is reversed. If `start` and `stop` are negative numbers (or zero), then they will be
@@ -14,17 +14,19 @@ export default function dateRangeOptions<S extends StrictRJSFSchema = RJSFSchema
14
14
  start: number,
15
15
  stop: number,
16
16
  ): EnumOptionsType<S>[] {
17
- if (start <= 0 && stop <= 0) {
18
- start = new Date().getFullYear() + start;
19
- stop = new Date().getFullYear() + stop;
20
- } else if (start < 0 || stop < 0) {
17
+ const bothRelative = start <= 0 && stop <= 0;
18
+ const eitherNegative = start < 0 || stop < 0;
19
+ if (!bothRelative && eitherNegative) {
21
20
  throw new Error(`Both start (${start}) and stop (${stop}) must both be <= 0 or > 0, got one of each`);
22
21
  }
23
- if (start > stop) {
22
+ const currentYear = new Date().getFullYear();
23
+ const resolvedStart = bothRelative ? currentYear + start : start;
24
+ const resolvedStop = bothRelative ? currentYear + stop : stop;
25
+ if (resolvedStart > resolvedStop) {
24
26
  return dateRangeOptions<S>(stop, start).reverse();
25
27
  }
26
28
  const options: EnumOptionsType<S>[] = [];
27
- for (let i = start; i <= stop; i++) {
29
+ for (let i = resolvedStart; i <= resolvedStop; i += 1) {
28
30
  options.push({ value: i, label: pad(i, 2) });
29
31
  }
30
32
  return options;
@@ -1,4 +1,4 @@
1
- import { TranslatableString } from './enums';
1
+ import type { TranslatableString } from './enums';
2
2
  import replaceStringParameters from './replaceStringParameters';
3
3
 
4
4
  /** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each
@@ -1,5 +1,5 @@
1
1
  import enumOptionsIndexForValue from './enumOptionsIndexForValue';
2
- import { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
2
+ import type { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
3
3
 
4
4
  /** Computes the value to pass to a select element's `value` attribute.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import enumOptionsValueForIndex from './enumOptionsValueForIndex';
2
- import { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
2
+ import type { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types';
3
3
 
4
4
  /** Resolves a single DOM value string back to its typed enum value in `'realValue'` mode.
5
5
  *
@@ -27,7 +27,7 @@ function decodeSingle<S extends StrictRJSFSchema = RJSFSchema>(
27
27
  }
28
28
  // Fallback: value might be an index (for object/array enum values)
29
29
  const index = Number(value);
30
- if (!isNaN(index) && index >= 0 && index < enumOptions.length) {
30
+ if (!Number.isNaN(index) && index >= 0 && index < enumOptions.length) {
31
31
  return enumOptions[index].value;
32
32
  }
33
33
  return emptyValue;
@@ -1,6 +1,6 @@
1
1
  import isNil from 'lodash/isNil';
2
2
 
3
- import { OptionValueFormat } from './types';
3
+ import type { OptionValueFormat } from './types';
4
4
 
5
5
  /** Encodes an enum option value into a string for a DOM value attribute.
6
6
  *
@@ -1,6 +1,6 @@
1
1
  import deepEquals from './deepEquals';
2
2
  import enumOptionsValueForIndex from './enumOptionsValueForIndex';
3
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
3
+ import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
4
4
 
5
5
  /** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
6
6
  * a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
@@ -1,5 +1,5 @@
1
1
  import enumOptionsIsSelected from './enumOptionsIsSelected';
2
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
3
3
 
4
4
  /** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
5
5
  * `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
@@ -19,7 +19,7 @@ export default function enumOptionsIndexForValue<S extends StrictRJSFSchema = RJ
19
19
  ): string | string[] | undefined {
20
20
  const selectedIndexes: string[] = allEnumOptions
21
21
  .map((opt, index) => (enumOptionsIsSelected(opt.value, value) ? String(index) : undefined))
22
- .filter((opt) => typeof opt !== 'undefined') as string[];
22
+ .filter((opt) => typeof opt !== 'undefined');
23
23
  if (!multiple) {
24
24
  return selectedIndexes[0];
25
25
  }
@@ -1,5 +1,5 @@
1
1
  import deepEquals from './deepEquals';
2
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
+ import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
3
3
 
4
4
  /** Determines whether the given `value` is (one of) the `selected` value(s).
5
5
  *
@@ -1,7 +1,7 @@
1
1
  import isNil from 'lodash/isNil';
2
2
 
3
3
  import enumOptionsValueForIndex from './enumOptionsValueForIndex';
4
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
4
+ import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
5
5
 
6
6
  /** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
7
7
  * `allEnumOptions`
@@ -1,4 +1,4 @@
1
- import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
1
+ import type { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
2
2
 
3
3
  /** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
4
4
  * array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it
@@ -12,7 +12,7 @@ import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
12
12
  * `emptyValue` or an empty list.
13
13
  */
14
14
  export default function enumOptionsValueForIndex<S extends StrictRJSFSchema = RJSFSchema>(
15
- valueIndex: string | number | Array<string | number>,
15
+ valueIndex: string | number | (string | number)[],
16
16
  allEnumOptions: EnumOptionsType<S>[] = [],
17
17
  emptyValue?: EnumOptionsType<S>['value'],
18
18
  ): EnumOptionsType<S>['value'] | EnumOptionsType<S>['value'][] | undefined {
package/src/enums.ts CHANGED
@@ -27,6 +27,8 @@ export enum TranslatableString {
27
27
  AddItemButton = 'Add Item',
28
28
  /** Copy button title, used by IconButton */
29
29
  CopyButton = 'Copy',
30
+ /** Expand cycle button title */
31
+ ExpandButton = 'Expand Cycle',
30
32
  /** Move down button title, used by IconButton */
31
33
  MoveDownButton = 'Move down',
32
34
  /** Move up button title, used by IconButton */
@@ -70,6 +72,8 @@ export enum TranslatableString {
70
72
  KeyLabel = '%1 Key',
71
73
  /** Deprecated label, where %1 will be replaced by the label as provided by SchemaField */
72
74
  DeprecatedLabel = '%1 (deprecated)',
75
+ /** Cyclic schema message */
76
+ CycleDetected = 'Circular reference ($ref cycle) detected for field "%1". You may choose to expand to the next cycle break',
73
77
  // Strings with replaceable parameters AND/OR that support markdown and html
74
78
  /** Invalid object field configuration as provided by the ObjectField.
75
79
  * NOTE: Use markdown notation rather than html tags.
@@ -13,7 +13,7 @@ import {
13
13
  REF_KEY,
14
14
  SCHEMA_KEY,
15
15
  } from './constants';
16
- import { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types';
16
+ import type { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types';
17
17
 
18
18
  /** Looks for the `$id` pointed by `ref` in the schema definitions embedded in
19
19
  * a JSON Schema bundle
@@ -32,14 +32,14 @@ function findEmbeddedSchemaRecursive<S extends StrictRJSFSchema = RJSFSchema>(sc
32
32
  if (isObject(item)) {
33
33
  const result = findEmbeddedSchemaRecursive<S>(item as S, ref);
34
34
  if (result !== undefined) {
35
- return result as S;
35
+ return result;
36
36
  }
37
37
  }
38
38
  }
39
39
  } else if (isObject(subSchema)) {
40
40
  const result = findEmbeddedSchemaRecursive<S>(subSchema as S, ref);
41
41
  if (result !== undefined) {
42
- return result as S;
42
+ return result;
43
43
  }
44
44
  }
45
45
  }
@@ -53,22 +53,23 @@ function findEmbeddedSchemaRecursive<S extends StrictRJSFSchema = RJSFSchema>(sc
53
53
  */
54
54
  export function makeAllReferencesAbsolute<S extends StrictRJSFSchema = RJSFSchema>(schema: S, baseURI: string): S {
55
55
  const currentURI = get(schema, ID_KEY, baseURI);
56
+ let result = schema;
56
57
  // Make all other references absolute
57
- if (REF_KEY in schema) {
58
- schema = { ...schema, [REF_KEY]: UriResolver.resolve(currentURI, schema[REF_KEY]!) };
58
+ if (REF_KEY in result) {
59
+ result = { ...result, [REF_KEY]: UriResolver.resolve(currentURI, result[REF_KEY]!) };
59
60
  }
60
61
  // Look for references in nested subschemas
61
- for (const [key, subSchema] of Object.entries(schema)) {
62
+ for (const [key, subSchema] of Object.entries(result)) {
62
63
  if (Array.isArray(subSchema)) {
63
- schema = {
64
- ...schema,
64
+ result = {
65
+ ...result,
65
66
  [key]: subSchema.map((item) => (isObject(item) ? makeAllReferencesAbsolute(item as S, currentURI) : item)),
66
67
  };
67
68
  } else if (isObject(subSchema)) {
68
- schema = { ...schema, [key]: makeAllReferencesAbsolute(subSchema as S, currentURI) };
69
+ result = { ...result, [key]: makeAllReferencesAbsolute(subSchema as S, currentURI) };
69
70
  }
70
71
  }
71
- return schema;
72
+ return result;
72
73
  }
73
74
 
74
75
  /** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
@@ -105,23 +106,24 @@ export function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFS
105
106
  ): S {
106
107
  const ref = $ref || '';
107
108
  let current: S | undefined = undefined;
109
+ let currentBaseURI = baseURI;
108
110
  if (ref.startsWith('#')) {
109
111
  // Decode URI fragment representation.
110
112
  const decodedRef = decodeURIComponent(ref.substring(1));
111
- if (baseURI === undefined || (ID_KEY in rootSchema && rootSchema[ID_KEY] === baseURI)) {
113
+ if (currentBaseURI === undefined || (ID_KEY in rootSchema && rootSchema[ID_KEY] === currentBaseURI)) {
112
114
  current = jsonpointer.get(rootSchema, decodedRef);
113
115
  } else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
114
- current = findEmbeddedSchemaRecursive<S>(rootSchema, baseURI.replace(/\/$/, ''));
116
+ current = findEmbeddedSchemaRecursive<S>(rootSchema, currentBaseURI.replace(/\/$/, ''));
115
117
  if (current !== undefined) {
116
118
  current = jsonpointer.get(current, decodedRef);
117
119
  }
118
120
  }
119
121
  } else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
120
- const resolvedRef = baseURI ? UriResolver.resolve(baseURI, ref) : ref;
122
+ const resolvedRef = currentBaseURI ? UriResolver.resolve(currentBaseURI, ref) : ref;
121
123
  const [refId, ...refAnchor] = resolvedRef.replace(/#\/?$/, '').split('#');
122
124
  current = findEmbeddedSchemaRecursive<S>(rootSchema, refId.replace(/\/$/, ''));
123
125
  if (current !== undefined) {
124
- baseURI = current[ID_KEY];
126
+ currentBaseURI = current[ID_KEY];
125
127
  if (!isEmpty(refAnchor)) {
126
128
  current = jsonpointer.get(current, decodeURIComponent(refAnchor.join('#')));
127
129
  }
@@ -142,16 +144,15 @@ export function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFS
142
144
  throw new Error(`Definition for ${firstRef} contains a circular reference through ${circularPath}`);
143
145
  }
144
146
  const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
145
- const subSchema = findSchemaDefinitionRecursive<S>(theRef, rootSchema, [...recurseList, ref], baseURI);
147
+ const subSchema = findSchemaDefinitionRecursive<S>(theRef, rootSchema, [...recurseList, ref], currentBaseURI);
146
148
  if (Object.keys(remaining).length > 0) {
147
149
  if (
148
150
  rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2019_09 ||
149
151
  rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12
150
152
  ) {
151
153
  return { [ALL_OF_KEY]: [remaining, subSchema] } as S;
152
- } else {
153
- return { ...remaining, ...subSchema };
154
154
  }
155
+ return { ...remaining, ...subSchema };
155
156
  }
156
157
  return subSchema;
157
158
  }
@@ -31,11 +31,11 @@ export default function getChangedFields(a: unknown, b: unknown): string[] {
31
31
  }
32
32
  if (aIsPlainObject && !bIsPlainObject) {
33
33
  return keys(a);
34
- } else if (!aIsPlainObject && bIsPlainObject) {
34
+ }
35
+ if (!aIsPlainObject && bIsPlainObject) {
35
36
  return keys(b);
36
- } else {
37
- const unequalFields = keys(pickBy(a as object, (value, key) => !deepEquals(value, get(b, key))));
38
- const diffFields = difference(keys(b), keys(a));
39
- return [...unequalFields, ...diffFields];
40
37
  }
38
+ const unequalFields = keys(pickBy(a as object, (value, key) => !deepEquals(value, get(b, key))));
39
+ const diffFields = difference(keys(b), keys(a));
40
+ return [...unequalFields, ...diffFields];
41
41
  }
@@ -1,14 +1,14 @@
1
- import { type DateObject } from './types';
1
+ import type { DateObject } from './types';
2
2
 
3
3
  /** Available options for re-ordering date input element */
4
4
  export type DateElementFormat = 'DMY' | 'MDY' | 'YMD';
5
5
 
6
6
  /** Type describing format of DateElement prop */
7
- export type DateElementProp = {
7
+ export interface DateElementProp {
8
8
  type: string;
9
9
  range: [number, number];
10
10
  value: number | undefined;
11
- };
11
+ }
12
12
 
13
13
  /** Given date & time information with optional yearRange & format, returns props for DateElement
14
14
  *
@@ -2,7 +2,7 @@ import get from 'lodash/get';
2
2
  import isString from 'lodash/isString';
3
3
 
4
4
  import { DISCRIMINATOR_PATH } from './constants';
5
- import { RJSFSchema, StrictRJSFSchema } from './types';
5
+ import type { RJSFSchema, StrictRJSFSchema } from './types';
6
6
 
7
7
  /** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when
8
8
  * it is not a string. Returns `undefined` when a valid discriminator is not present.
@@ -16,6 +16,7 @@ export default function getDiscriminatorFieldFromSchema<S extends StrictRJSFSche
16
16
  if (isString(maybeString)) {
17
17
  discriminator = maybeString;
18
18
  } else if (maybeString !== undefined) {
19
+ // oxlint-disable-next-line no-console
19
20
  console.warn(`Expecting discriminator to be a string, got "${typeof maybeString}" instead`);
20
21
  }
21
22
  return discriminator;
@@ -1,5 +1,5 @@
1
1
  import rangeSpec from './rangeSpec';
2
- import { FormContextType, InputPropsType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from './types';
2
+ import type { FormContextType, InputPropsType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from './types';
3
3
 
4
4
  /** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
5
5
  *