@rjsf/core 6.6.1 → 6.6.2

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 (251) hide show
  1. package/dist/core.umd.js +454 -373
  2. package/dist/index.cjs +416 -334
  3. package/dist/index.cjs.map +3 -3
  4. package/dist/index.esm.js +418 -415
  5. package/dist/index.esm.js.map +3 -3
  6. package/lib/components/Form.d.ts +14 -11
  7. package/lib/components/Form.d.ts.map +1 -1
  8. package/lib/components/Form.js +97 -62
  9. package/lib/components/RichDescription.d.ts +2 -2
  10. package/lib/components/RichDescription.d.ts.map +1 -1
  11. package/lib/components/RichDescription.js +1 -1
  12. package/lib/components/RichHelp.d.ts +2 -2
  13. package/lib/components/RichHelp.d.ts.map +1 -1
  14. package/lib/components/RichHelp.js +1 -1
  15. package/lib/components/SchemaExamples.d.ts +1 -1
  16. package/lib/components/SchemaExamples.d.ts.map +1 -1
  17. package/lib/components/SchemaExamples.js +1 -3
  18. package/lib/components/fields/ArrayField.d.ts +1 -1
  19. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  20. package/lib/components/fields/ArrayField.js +87 -88
  21. package/lib/components/fields/BooleanField.d.ts +1 -1
  22. package/lib/components/fields/BooleanField.d.ts.map +1 -1
  23. package/lib/components/fields/BooleanField.js +2 -5
  24. package/lib/components/fields/FallbackField.d.ts +1 -1
  25. package/lib/components/fields/FallbackField.d.ts.map +1 -1
  26. package/lib/components/fields/FallbackField.js +2 -2
  27. package/lib/components/fields/LayoutGridField.d.ts +7 -9
  28. package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
  29. package/lib/components/fields/LayoutGridField.js +5 -4
  30. package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
  31. package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
  32. package/lib/components/fields/LayoutHeaderField.js +1 -1
  33. package/lib/components/fields/LayoutMultiSchemaField.d.ts +1 -1
  34. package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
  35. package/lib/components/fields/LayoutMultiSchemaField.js +4 -1
  36. package/lib/components/fields/MultiSchemaField.d.ts +9 -3
  37. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
  38. package/lib/components/fields/MultiSchemaField.js +27 -9
  39. package/lib/components/fields/NullField.d.ts +1 -1
  40. package/lib/components/fields/NullField.d.ts.map +1 -1
  41. package/lib/components/fields/NumberField.d.ts +1 -1
  42. package/lib/components/fields/NumberField.d.ts.map +1 -1
  43. package/lib/components/fields/NumberField.js +7 -9
  44. package/lib/components/fields/ObjectField.d.ts +1 -1
  45. package/lib/components/fields/ObjectField.d.ts.map +1 -1
  46. package/lib/components/fields/ObjectField.js +27 -25
  47. package/lib/components/fields/OptionalDataControlsField.d.ts +1 -1
  48. package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
  49. package/lib/components/fields/SchemaField.d.ts +1 -1
  50. package/lib/components/fields/SchemaField.d.ts.map +1 -1
  51. package/lib/components/fields/SchemaField.js +7 -7
  52. package/lib/components/fields/StringField.d.ts +1 -1
  53. package/lib/components/fields/StringField.d.ts.map +1 -1
  54. package/lib/components/fields/StringField.js +2 -5
  55. package/lib/components/fields/index.d.ts +1 -1
  56. package/lib/components/fields/index.d.ts.map +1 -1
  57. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
  58. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
  59. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +1 -1
  60. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +1 -1
  61. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
  62. package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +1 -1
  63. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +1 -1
  64. package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
  65. package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
  66. package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
  67. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
  68. package/lib/components/templates/ArrayFieldTemplate.js +1 -1
  69. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
  70. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
  71. package/lib/components/templates/ArrayFieldTitleTemplate.js +1 -1
  72. package/lib/components/templates/BaseInputTemplate.d.ts +1 -1
  73. package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
  74. package/lib/components/templates/BaseInputTemplate.js +7 -6
  75. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
  76. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
  77. package/lib/components/templates/ButtonTemplates/IconButton.d.ts +14 -7
  78. package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
  79. package/lib/components/templates/ButtonTemplates/IconButton.js +14 -6
  80. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -1
  81. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
  82. package/lib/components/templates/ButtonTemplates/index.d.ts +1 -1
  83. package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -1
  84. package/lib/components/templates/DescriptionField.d.ts +1 -1
  85. package/lib/components/templates/DescriptionField.d.ts.map +1 -1
  86. package/lib/components/templates/ErrorList.d.ts +1 -1
  87. package/lib/components/templates/ErrorList.d.ts.map +1 -1
  88. package/lib/components/templates/ErrorList.js +2 -4
  89. package/lib/components/templates/FallbackFieldTemplate.d.ts +1 -1
  90. package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
  91. package/lib/components/templates/FieldErrorTemplate.d.ts +1 -1
  92. package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
  93. package/lib/components/templates/FieldErrorTemplate.js +1 -3
  94. package/lib/components/templates/FieldHelpTemplate.d.ts +1 -1
  95. package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
  96. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -1
  97. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
  98. package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -1
  99. package/lib/components/templates/FieldTemplate/Label.d.ts +2 -2
  100. package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
  101. package/lib/components/templates/GridTemplate.d.ts +1 -1
  102. package/lib/components/templates/GridTemplate.d.ts.map +1 -1
  103. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +1 -1
  104. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
  105. package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -1
  106. package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
  107. package/lib/components/templates/ObjectFieldTemplate.js +1 -1
  108. package/lib/components/templates/OptionalDataControlsTemplate.d.ts +1 -1
  109. package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
  110. package/lib/components/templates/OptionalDataControlsTemplate.js +1 -1
  111. package/lib/components/templates/TitleField.d.ts +1 -1
  112. package/lib/components/templates/TitleField.d.ts.map +1 -1
  113. package/lib/components/templates/UnsupportedField.d.ts +1 -1
  114. package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
  115. package/lib/components/templates/UnsupportedField.js +1 -1
  116. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -1
  117. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
  118. package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -1
  119. package/lib/components/templates/index.d.ts +1 -1
  120. package/lib/components/templates/index.d.ts.map +1 -1
  121. package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -1
  122. package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
  123. package/lib/components/widgets/AltDateWidget.d.ts +1 -1
  124. package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
  125. package/lib/components/widgets/AltDateWidget.js +2 -2
  126. package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
  127. package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
  128. package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
  129. package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
  130. package/lib/components/widgets/CheckboxesWidget.js +2 -2
  131. package/lib/components/widgets/ColorWidget.d.ts +1 -1
  132. package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
  133. package/lib/components/widgets/DateTimeWidget.d.ts +1 -1
  134. package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
  135. package/lib/components/widgets/DateTimeWidget.js +2 -2
  136. package/lib/components/widgets/DateWidget.d.ts +1 -1
  137. package/lib/components/widgets/DateWidget.d.ts.map +1 -1
  138. package/lib/components/widgets/EmailWidget.d.ts +1 -1
  139. package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
  140. package/lib/components/widgets/FileWidget.d.ts +1 -1
  141. package/lib/components/widgets/FileWidget.d.ts.map +1 -1
  142. package/lib/components/widgets/FileWidget.js +6 -4
  143. package/lib/components/widgets/HiddenWidget.d.ts +1 -1
  144. package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
  145. package/lib/components/widgets/PasswordWidget.d.ts +1 -1
  146. package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
  147. package/lib/components/widgets/RadioWidget.d.ts +1 -1
  148. package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
  149. package/lib/components/widgets/RadioWidget.js +2 -2
  150. package/lib/components/widgets/RangeWidget.d.ts +1 -1
  151. package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
  152. package/lib/components/widgets/RatingWidget.d.ts +1 -1
  153. package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
  154. package/lib/components/widgets/RatingWidget.js +15 -15
  155. package/lib/components/widgets/SelectWidget.d.ts +1 -1
  156. package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
  157. package/lib/components/widgets/SelectWidget.js +4 -4
  158. package/lib/components/widgets/TextWidget.d.ts +1 -1
  159. package/lib/components/widgets/TextWidget.d.ts.map +1 -1
  160. package/lib/components/widgets/TextareaWidget.d.ts +1 -1
  161. package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
  162. package/lib/components/widgets/TextareaWidget.js +2 -2
  163. package/lib/components/widgets/TimeWidget.d.ts +1 -1
  164. package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
  165. package/lib/components/widgets/URLWidget.d.ts +1 -1
  166. package/lib/components/widgets/URLWidget.d.ts.map +1 -1
  167. package/lib/components/widgets/UpDownWidget.d.ts +1 -1
  168. package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
  169. package/lib/components/widgets/index.d.ts +1 -1
  170. package/lib/components/widgets/index.d.ts.map +1 -1
  171. package/lib/getDefaultRegistry.d.ts +1 -1
  172. package/lib/getDefaultRegistry.d.ts.map +1 -1
  173. package/lib/getDefaultRegistry.js +1 -1
  174. package/lib/getTestRegistry.d.ts +1 -1
  175. package/lib/getTestRegistry.d.ts.map +1 -1
  176. package/lib/getTestRegistry.js +1 -1
  177. package/lib/index.d.ts +10 -5
  178. package/lib/index.d.ts.map +1 -1
  179. package/lib/tsconfig.tsbuildinfo +1 -1
  180. package/lib/withTheme.d.ts +3 -3
  181. package/lib/withTheme.d.ts.map +1 -1
  182. package/lib/withTheme.js +6 -6
  183. package/package.json +5 -6
  184. package/src/components/Form.tsx +164 -97
  185. package/src/components/RichDescription.tsx +3 -10
  186. package/src/components/RichHelp.tsx +3 -10
  187. package/src/components/SchemaExamples.tsx +6 -4
  188. package/src/components/fields/ArrayField.tsx +122 -108
  189. package/src/components/fields/BooleanField.tsx +4 -9
  190. package/src/components/fields/FallbackField.tsx +4 -8
  191. package/src/components/fields/LayoutGridField.tsx +21 -19
  192. package/src/components/fields/LayoutHeaderField.tsx +2 -10
  193. package/src/components/fields/LayoutMultiSchemaField.tsx +15 -10
  194. package/src/components/fields/MultiSchemaField.tsx +29 -16
  195. package/src/components/fields/NullField.tsx +1 -1
  196. package/src/components/fields/NumberField.tsx +8 -10
  197. package/src/components/fields/ObjectField.tsx +48 -39
  198. package/src/components/fields/OptionalDataControlsField.tsx +6 -4
  199. package/src/components/fields/SchemaField.tsx +22 -19
  200. package/src/components/fields/StringField.tsx +4 -15
  201. package/src/components/fields/index.ts +1 -1
  202. package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -9
  203. package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +2 -7
  204. package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -9
  205. package/src/components/templates/ArrayFieldTemplate.tsx +2 -9
  206. package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -10
  207. package/src/components/templates/BaseInputTemplate.tsx +15 -19
  208. package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -1
  209. package/src/components/templates/ButtonTemplates/IconButton.tsx +16 -7
  210. package/src/components/templates/ButtonTemplates/SubmitButton.tsx +2 -1
  211. package/src/components/templates/ButtonTemplates/index.ts +1 -1
  212. package/src/components/templates/DescriptionField.tsx +1 -1
  213. package/src/components/templates/ErrorList.tsx +8 -15
  214. package/src/components/templates/FallbackFieldTemplate.tsx +2 -1
  215. package/src/components/templates/FieldErrorTemplate.tsx +8 -8
  216. package/src/components/templates/FieldHelpTemplate.tsx +2 -1
  217. package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -8
  218. package/src/components/templates/FieldTemplate/Label.tsx +2 -2
  219. package/src/components/templates/GridTemplate.tsx +1 -1
  220. package/src/components/templates/MultiSchemaFieldTemplate.tsx +1 -1
  221. package/src/components/templates/ObjectFieldTemplate.tsx +2 -7
  222. package/src/components/templates/OptionalDataControlsTemplate.tsx +3 -2
  223. package/src/components/templates/TitleField.tsx +1 -1
  224. package/src/components/templates/UnsupportedField.tsx +3 -2
  225. package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
  226. package/src/components/templates/index.ts +1 -1
  227. package/src/components/widgets/AltDateTimeWidget.tsx +1 -1
  228. package/src/components/widgets/AltDateWidget.tsx +7 -13
  229. package/src/components/widgets/CheckboxWidget.tsx +3 -5
  230. package/src/components/widgets/CheckboxesWidget.tsx +6 -8
  231. package/src/components/widgets/ColorWidget.tsx +2 -1
  232. package/src/components/widgets/DateTimeWidget.tsx +3 -10
  233. package/src/components/widgets/DateWidget.tsx +2 -1
  234. package/src/components/widgets/EmailWidget.tsx +2 -1
  235. package/src/components/widgets/FileWidget.tsx +9 -8
  236. package/src/components/widgets/HiddenWidget.tsx +1 -1
  237. package/src/components/widgets/PasswordWidget.tsx +2 -1
  238. package/src/components/widgets/RadioWidget.tsx +6 -8
  239. package/src/components/widgets/RangeWidget.tsx +1 -1
  240. package/src/components/widgets/RatingWidget.tsx +48 -47
  241. package/src/components/widgets/SelectWidget.tsx +12 -10
  242. package/src/components/widgets/TextWidget.tsx +2 -1
  243. package/src/components/widgets/TextareaWidget.tsx +7 -4
  244. package/src/components/widgets/TimeWidget.tsx +2 -1
  245. package/src/components/widgets/URLWidget.tsx +2 -1
  246. package/src/components/widgets/UpDownWidget.tsx +2 -1
  247. package/src/components/widgets/index.ts +1 -1
  248. package/src/getDefaultRegistry.ts +2 -9
  249. package/src/getTestRegistry.tsx +2 -7
  250. package/src/index.ts +10 -5
  251. package/src/withTheme.tsx +14 -9
@@ -1,14 +1,12 @@
1
- import { ChangeEvent, FocusEvent, useCallback } from 'react';
1
+ import type { ChangeEvent, FocusEvent } from 'react';
2
+ import { useCallback } from 'react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
4
  import {
3
5
  ariaDescribedByIds,
4
6
  descriptionId,
5
7
  getTemplate,
6
8
  labelValue,
7
9
  schemaRequiresTrueValue,
8
- FormContextType,
9
- RJSFSchema,
10
- StrictRJSFSchema,
11
- WidgetProps,
12
10
  getUiOptions,
13
11
  } from '@rjsf/utils';
14
12
 
@@ -1,4 +1,6 @@
1
- import { ChangeEvent, FocusEvent, useCallback } from 'react';
1
+ import type { ChangeEvent, FocusEvent } from 'react';
2
+ import { useCallback } from 'react';
3
+ import type { FormContextType, WidgetProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
4
  import {
3
5
  ariaDescribedByIds,
4
6
  enumOptionValueDecoder,
@@ -8,10 +10,6 @@ import {
8
10
  enumOptionsSelectValue,
9
11
  getOptionValueFormat,
10
12
  optionId,
11
- FormContextType,
12
- WidgetProps,
13
- RJSFSchema,
14
- StrictRJSFSchema,
15
13
  } from '@rjsf/utils';
16
14
 
17
15
  /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
@@ -52,7 +50,7 @@ function CheckboxesWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
52
50
  {Array.isArray(enumOptions) &&
53
51
  enumOptions.map((option, index) => {
54
52
  const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
55
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
53
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
56
54
  const disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
57
55
 
58
56
  const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
@@ -82,11 +80,11 @@ function CheckboxesWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
82
80
  </span>
83
81
  );
84
82
  return inline ? (
85
- <label key={index} className={`checkbox-inline ${disabledCls}`}>
83
+ <label key={String(option.value)} className={`checkbox-inline ${disabledCls}`}>
86
84
  {checkbox}
87
85
  </label>
88
86
  ) : (
89
- <div key={index} className={`checkbox ${disabledCls}`}>
87
+ <div key={String(option.value)} className={`checkbox ${disabledCls}`}>
90
88
  <label>{checkbox}</label>
91
89
  </div>
92
90
  );
@@ -1,4 +1,5 @@
1
- import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { getTemplate } from '@rjsf/utils';
2
3
 
3
4
  /** The `ColorWidget` component uses the `BaseInputTemplate` changing the type to `color` and disables it when it is
4
5
  * either disabled or readonly.
@@ -1,12 +1,5 @@
1
- import {
2
- getTemplate,
3
- localToUTC,
4
- utcToLocal,
5
- FormContextType,
6
- RJSFSchema,
7
- StrictRJSFSchema,
8
- WidgetProps,
9
- } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { getTemplate, localToUTC, utcToLocal } from '@rjsf/utils';
10
3
 
11
4
  /** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
12
5
  * the value to/from utc using the appropriate utility functions.
@@ -25,7 +18,7 @@ export default function DateTimeWidget<
25
18
  type='datetime-local'
26
19
  {...props}
27
20
  value={utcToLocal(value)}
28
- onChange={(value) => onChange(localToUTC(value))}
21
+ onChange={(newValue) => onChange(localToUTC(newValue))}
29
22
  />
30
23
  );
31
24
  }
@@ -1,5 +1,6 @@
1
1
  import { useCallback } from 'react';
2
- import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
+ import { getTemplate } from '@rjsf/utils';
3
4
 
4
5
  /** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
5
6
  * the value to undefined when it is falsy during the `onChange` handling.
@@ -1,4 +1,5 @@
1
- import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { getTemplate } from '@rjsf/utils';
2
3
 
3
4
  /** The `EmailWidget` component uses the `BaseInputTemplate` changing the type to `email`.
4
5
  *
@@ -1,17 +1,15 @@
1
- import { ChangeEvent } from 'react';
2
- import {
1
+ import type { ChangeEvent } from 'react';
2
+ import type {
3
3
  FileInfoType,
4
4
  FormContextType,
5
- getTemplate,
6
5
  Registry,
7
6
  RJSFSchema,
8
7
  StrictRJSFSchema,
9
- TranslatableString,
10
8
  UIOptionsType,
11
- useFileWidgetProps,
12
9
  WidgetProps,
13
10
  } from '@rjsf/utils';
14
- import { Markdown } from 'markdown-to-jsx';
11
+ import { getTemplate, TranslatableString, useFileWidgetProps } from '@rjsf/utils';
12
+ import { Markdown } from 'markdown-to-jsx/react';
15
13
 
16
14
  function FileInfoPreview<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
17
15
  fileInfo,
@@ -25,12 +23,13 @@ function FileInfoPreview<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
25
23
  if (!dataURL) {
26
24
  return null;
27
25
  }
26
+ const previewLabel = translateString(TranslatableString.PreviewLabel);
28
27
 
29
28
  // If type is JPEG or PNG then show image preview.
30
29
  // Originally, any type of image was supported, but this was changed into a whitelist
31
30
  // since SVGs and animated GIFs are also images, which are generally considered a security risk.
32
31
  if (['image/jpeg', 'image/png'].includes(type)) {
33
- return <img src={dataURL} style={{ maxWidth: '100%' }} className='file-preview' />;
32
+ return <img src={dataURL} alt={previewLabel} style={{ maxWidth: '100%' }} className='file-preview' />;
34
33
  }
35
34
 
36
35
  // otherwise, let users download file
@@ -39,7 +38,7 @@ function FileInfoPreview<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
39
38
  <>
40
39
  {' '}
41
40
  <a download={`preview-${name}`} href={dataURL} className='file-download'>
42
- {translateString(TranslatableString.PreviewLabel)}
41
+ {previewLabel}
43
42
  </a>
44
43
  </>
45
44
  );
@@ -71,6 +70,7 @@ function FilesInfo<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
71
70
  const { name, size, type } = fileInfo;
72
71
  const handleRemove = () => onRemove(key);
73
72
  return (
73
+ // oxlint-disable-next-line react/no-array-index-key
74
74
  <li key={key}>
75
75
  <Markdown>{translateString(TranslatableString.FilesInfo, [name, type, String(size)])}</Markdown>
76
76
  {preview && <FileInfoPreview<T, S, F> fileInfo={fileInfo} registry={registry} />}
@@ -96,6 +96,7 @@ function FileWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
96
96
  const handleOnChangeEvent = (event: ChangeEvent<HTMLInputElement>) => {
97
97
  if (event.target.files) {
98
98
  // handleChange is async; DOM event handlers are void-returning, so we intentionally don't await
99
+ // oxlint-disable-next-line no-floating-promises, no-void
99
100
  void handleChange(event.target.files);
100
101
  }
101
102
  };
@@ -1,4 +1,4 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
2
 
3
3
  /** The `HiddenWidget` is a widget for rendering a hidden input field.
4
4
  * It is typically used by setting type to "hidden".
@@ -1,4 +1,5 @@
1
- import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { getTemplate } from '@rjsf/utils';
2
3
 
3
4
  /** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.
4
5
  *
@@ -1,4 +1,6 @@
1
- import { FocusEvent, useCallback } from 'react';
1
+ import type { FocusEvent } from 'react';
2
+ import { useCallback } from 'react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
4
  import {
3
5
  ariaDescribedByIds,
4
6
  enumOptionValueDecoder,
@@ -6,10 +8,6 @@ import {
6
8
  enumOptionsIsSelected,
7
9
  getOptionValueFormat,
8
10
  optionId,
9
- FormContextType,
10
- RJSFSchema,
11
- StrictRJSFSchema,
12
- WidgetProps,
13
11
  } from '@rjsf/utils';
14
12
 
15
13
  /** The `RadioWidget` is a widget for rendering a radio group.
@@ -50,7 +48,7 @@ function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
50
48
  {Array.isArray(enumOptions) &&
51
49
  enumOptions.map((option, i) => {
52
50
  const checked = enumOptionsIsSelected<S>(option.value, value);
53
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
51
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
54
52
  const disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
55
53
 
56
54
  const handleChange = () => onChange(option.value);
@@ -76,11 +74,11 @@ function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
76
74
  );
77
75
 
78
76
  return inline ? (
79
- <label key={i} className={`radio-inline ${disabledCls}`}>
77
+ <label key={String(option.value)} className={`radio-inline ${disabledCls}`}>
80
78
  {radio}
81
79
  </label>
82
80
  ) : (
83
- <div key={i} className={`radio ${disabledCls}`}>
81
+ <div key={String(option.value)} className={`radio ${disabledCls}`}>
84
82
  <label>{radio}</label>
85
83
  </div>
86
84
  );
@@ -1,4 +1,4 @@
1
- import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
2
 
3
3
  /** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
4
4
  * in a div, with the value along side it.
@@ -1,5 +1,6 @@
1
- import { FocusEvent, useCallback } from 'react';
2
- import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FocusEvent } from 'react';
2
+ import { useCallback } from 'react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
4
 
4
5
  /** The `RatingWidget` component renders a star or heart rating input
5
6
  *
@@ -80,51 +81,51 @@ export default function RatingWidget<
80
81
  };
81
82
 
82
83
  return (
83
- <>
84
- <div
85
- className='rating-widget'
86
- style={{
87
- display: 'inline-flex',
88
- fontSize: '1.5rem',
89
- cursor: disabled || readonly ? 'default' : 'pointer',
90
- }}
91
- >
92
- {[...Array(numStars)].map((_, index) => {
93
- const starValue = min + index;
94
- const isFilled = starValue <= value;
84
+ <div
85
+ className='rating-widget'
86
+ style={{
87
+ display: 'inline-flex',
88
+ fontSize: '1.5rem',
89
+ cursor: disabled || readonly ? 'default' : 'pointer',
90
+ }}
91
+ >
92
+ {[...Array(numStars)].map((_, index) => {
93
+ const starValue = min + index;
94
+ const isFilled = starValue <= value;
95
95
 
96
- return (
97
- <span
98
- key={index}
99
- onClick={() => handleStarClick(starValue)}
100
- onFocus={handleFocus}
101
- onBlur={handleBlur}
102
- data-value={starValue}
103
- tabIndex={disabled || readonly ? -1 : 0}
104
- role='radio'
105
- aria-checked={starValue === value}
106
- aria-label={`${starValue} ${shape === 'heart' ? 'heart' : 'star'}${starValue === 1 ? '' : 's'}`}
107
- style={{
108
- color: isFilled ? '#FFD700' : '#ccc',
109
- padding: '0 0.2rem',
110
- transition: 'color 0.2s',
111
- userSelect: 'none',
112
- }}
113
- >
114
- {getSymbol(isFilled)}
115
- </span>
116
- );
117
- })}
118
- <input
119
- type='hidden'
120
- id={id}
121
- name={htmlName || id}
122
- value={value || ''}
123
- required={required}
124
- disabled={disabled || readonly}
125
- aria-hidden='true'
126
- />
127
- </div>
128
- </>
96
+ return (
97
+ <span
98
+ // oxlint-disable-next-line react/no-array-index-key
99
+ key={index}
100
+ onClick={() => handleStarClick(starValue)}
101
+ onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && handleStarClick(starValue)}
102
+ onFocus={handleFocus}
103
+ onBlur={handleBlur}
104
+ data-value={starValue}
105
+ tabIndex={disabled || readonly ? -1 : 0}
106
+ role='radio'
107
+ aria-checked={starValue === value}
108
+ aria-label={`${starValue} ${shape === 'heart' ? 'heart' : 'star'}${starValue === 1 ? '' : 's'}`}
109
+ style={{
110
+ color: isFilled ? '#FFD700' : '#ccc',
111
+ padding: '0 0.2rem',
112
+ transition: 'color 0.2s',
113
+ userSelect: 'none',
114
+ }}
115
+ >
116
+ {getSymbol(isFilled)}
117
+ </span>
118
+ );
119
+ })}
120
+ <input
121
+ type='hidden'
122
+ id={id}
123
+ name={htmlName || id}
124
+ value={value || ''}
125
+ required={required}
126
+ disabled={disabled || readonly}
127
+ aria-hidden='true'
128
+ />
129
+ </div>
129
130
  );
130
131
  }
@@ -1,14 +1,12 @@
1
- import { ChangeEvent, FocusEvent, SyntheticEvent, useCallback } from 'react';
1
+ import type { ChangeEvent, FocusEvent, SyntheticEvent } from 'react';
2
+ import { useCallback } from 'react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
4
  import {
3
5
  ariaDescribedByIds,
4
6
  enumOptionSelectedValue,
5
7
  enumOptionValueDecoder,
6
8
  enumOptionValueEncoder,
7
9
  getOptionValueFormat,
8
- FormContextType,
9
- RJSFSchema,
10
- StrictRJSFSchema,
11
- WidgetProps,
12
10
  } from '@rjsf/utils';
13
11
 
14
12
  function getValue(event: SyntheticEvent<HTMLSelectElement>, multiple: boolean) {
@@ -74,11 +72,11 @@ function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
74
72
  const showPlaceholderOption = !multiple && schema.default === undefined;
75
73
 
76
74
  return (
75
+ // oxlint-disable-next-line jsx-a11y/no-autofocus
77
76
  <select
78
77
  id={id}
79
78
  name={htmlName || id}
80
79
  multiple={multiple}
81
- role='combobox'
82
80
  className='form-control'
83
81
  value={selectValue}
84
82
  required={required}
@@ -91,11 +89,15 @@ function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
91
89
  >
92
90
  {showPlaceholderOption && <option value=''>{placeholder}</option>}
93
91
  {Array.isArray(enumOptions) &&
94
- enumOptions.map(({ value, label }, i) => {
95
- const disabled = enumDisabled && enumDisabled.indexOf(value) !== -1;
92
+ enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
93
+ const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
96
94
  return (
97
- <option key={i} value={enumOptionValueEncoder(value, i, optionValueFormat)} disabled={disabled}>
98
- {label}
95
+ <option
96
+ key={String(enumValue)}
97
+ value={enumOptionValueEncoder(enumValue, i, optionValueFormat)}
98
+ disabled={isDisabled}
99
+ >
100
+ {enumLabel}
99
101
  </option>
100
102
  );
101
103
  })}
@@ -1,4 +1,5 @@
1
- import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { getTemplate } from '@rjsf/utils';
2
3
 
3
4
  /** The `TextWidget` component uses the `BaseInputTemplate`.
4
5
  *
@@ -1,5 +1,7 @@
1
- import { ChangeEvent, FocusEvent, useCallback } from 'react';
2
- import { ariaDescribedByIds, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { ChangeEvent, FocusEvent } from 'react';
2
+ import { useCallback } from 'react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
4
+ import { ariaDescribedByIds } from '@rjsf/utils';
3
5
 
4
6
  /** The `TextareaWidget` is a widget for rendering input fields as textarea.
5
7
  *
@@ -20,7 +22,8 @@ function TextareaWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
20
22
  htmlName,
21
23
  }: WidgetProps<T, S, F>) {
22
24
  const handleChange = useCallback(
23
- ({ target: { value } }: ChangeEvent<HTMLTextAreaElement>) => onChange(value === '' ? options.emptyValue : value),
25
+ ({ target: { value: newValue } }: ChangeEvent<HTMLTextAreaElement>) =>
26
+ onChange(newValue === '' ? options.emptyValue : newValue),
24
27
  [onChange, options.emptyValue],
25
28
  );
26
29
 
@@ -39,7 +42,7 @@ function TextareaWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
39
42
  id={id}
40
43
  name={htmlName || id}
41
44
  className='form-control'
42
- value={value ? value : ''}
45
+ value={value || ''}
43
46
  placeholder={placeholder}
44
47
  required={required}
45
48
  disabled={disabled}
@@ -1,5 +1,6 @@
1
1
  import { useCallback } from 'react';
2
- import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
3
+ import { getTemplate } from '@rjsf/utils';
3
4
 
4
5
  /** The `TimeWidget` component uses the `BaseInputTemplate` changing the type to `time` and transforms
5
6
  * the value to undefined when it is falsy during the `onChange` handling.
@@ -1,4 +1,5 @@
1
- import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { getTemplate } from '@rjsf/utils';
2
3
 
3
4
  /** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
4
5
  *
@@ -1,4 +1,5 @@
1
- import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
1
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
2
+ import { getTemplate } from '@rjsf/utils';
2
3
 
3
4
  /** The `UpDownWidget` component uses the `BaseInputTemplate` changing the type to `number`.
4
5
  *
@@ -1,4 +1,4 @@
1
- import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
 
3
3
  import AltDateTimeWidget from './AltDateTimeWidget';
4
4
  import AltDateWidget from './AltDateWidget';
@@ -1,12 +1,5 @@
1
- import {
2
- DEFAULT_ID_PREFIX,
3
- DEFAULT_ID_SEPARATOR,
4
- englishStringTranslator,
5
- FormContextType,
6
- Registry,
7
- RJSFSchema,
8
- StrictRJSFSchema,
9
- } from '@rjsf/utils';
1
+ import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, englishStringTranslator } from '@rjsf/utils';
10
3
 
11
4
  import fields from './components/fields';
12
5
  import templates from './components/templates';
@@ -1,10 +1,5 @@
1
- import {
2
- DEFAULT_ID_PREFIX,
3
- DEFAULT_ID_SEPARATOR,
4
- createSchemaUtils,
5
- englishStringTranslator,
6
- Registry,
7
- } from '@rjsf/utils';
1
+ import type { Registry } from '@rjsf/utils';
2
+ import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, createSchemaUtils, englishStringTranslator } from '@rjsf/utils';
8
3
  import validator from '@rjsf/validator-ajv8';
9
4
 
10
5
  import getDefaultRegistry from './getDefaultRegistry';
package/src/index.ts CHANGED
@@ -1,10 +1,15 @@
1
- import Form, { FormProps, FormState, IChangeEvent } from './components/Form';
2
- import RichDescription, { RichDescriptionProps } from './components/RichDescription';
3
- import RichHelp, { RichHelpProps } from './components/RichHelp';
4
- import SchemaExamples, { SchemaExamplesProps } from './components/SchemaExamples';
1
+ import type { FormProps, FormState, IChangeEvent } from './components/Form';
2
+ import Form from './components/Form';
3
+ import type { RichDescriptionProps } from './components/RichDescription';
4
+ import RichDescription from './components/RichDescription';
5
+ import type { RichHelpProps } from './components/RichHelp';
6
+ import RichHelp from './components/RichHelp';
7
+ import type { SchemaExamplesProps } from './components/SchemaExamples';
8
+ import SchemaExamples from './components/SchemaExamples';
5
9
  import getDefaultRegistry from './getDefaultRegistry';
6
10
  import getTestRegistry from './getTestRegistry';
7
- import withTheme, { ThemeProps } from './withTheme';
11
+ import type { ThemeProps } from './withTheme';
12
+ import withTheme from './withTheme';
8
13
 
9
14
  export type {
10
15
  FormProps,
package/src/withTheme.tsx CHANGED
@@ -1,7 +1,9 @@
1
- import { ComponentType, ForwardedRef, forwardRef } from 'react';
2
- import { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1
+ import type { ComponentType, ForwardedRef } from 'react';
2
+ import { forwardRef } from 'react';
3
+ import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
4
 
4
- import Form, { FormProps } from './components/Form';
5
+ import type { FormProps } from './components/Form';
6
+ import Form from './components/Form';
5
7
 
6
8
  /** The properties for the `withTheme` function, essentially a subset of properties from the `FormProps` that can be
7
9
  * overridden while creating a theme
@@ -17,15 +19,18 @@ export default function withTheme<T = any, S extends StrictRJSFSchema = RJSFSche
17
19
  ): ComponentType<FormProps<T, S, F>> {
18
20
  // @ts-expect-error TS2322 because the latest types complain about LegacyRef's string form not working with Form
19
21
  return forwardRef<Form<T, S, F>, FormProps<T, S, F>>(
20
- ({ fields, widgets, templates, ...directProps }: FormProps<T, S, F>, ref: ForwardedRef<Form<T, S, F>>) => {
21
- fields = { ...themeProps?.fields, ...fields };
22
- widgets = { ...themeProps?.widgets, ...widgets };
23
- templates = {
22
+ (
23
+ { fields: propFields, widgets: propWidgets, templates: propTemplates, ...directProps }: FormProps<T, S, F>,
24
+ ref: ForwardedRef<Form<T, S, F>>,
25
+ ) => {
26
+ const fields = { ...themeProps?.fields, ...propFields };
27
+ const widgets = { ...themeProps?.widgets, ...propWidgets };
28
+ const templates = {
24
29
  ...themeProps?.templates,
25
- ...templates,
30
+ ...propTemplates,
26
31
  ButtonTemplates: {
27
32
  ...themeProps?.templates?.ButtonTemplates,
28
- ...templates?.ButtonTemplates,
33
+ ...propTemplates?.ButtonTemplates,
29
34
  },
30
35
  };
31
36