@rjsf/core 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.
- package/LICENSE.md +201 -0
- package/dist/core.umd.js +694 -584
- package/dist/index.cjs +1191 -1071
- package/dist/index.cjs.map +4 -4
- package/dist/index.esm.js +1030 -984
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +16 -13
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +126 -76
- package/lib/components/RichDescription.d.ts +3 -3
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichDescription.js +1 -1
- package/lib/components/RichHelp.d.ts +3 -3
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/RichHelp.js +1 -1
- package/lib/components/SchemaExamples.d.ts +2 -2
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/SchemaExamples.js +1 -3
- package/lib/components/fields/ArrayField.d.ts +2 -2
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +87 -88
- package/lib/components/fields/BooleanField.d.ts +2 -2
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -5
- package/lib/components/fields/CyclicSchemaField.d.ts +8 -0
- package/lib/components/fields/CyclicSchemaField.d.ts.map +1 -0
- package/lib/components/fields/CyclicSchemaField.js +21 -0
- package/lib/components/fields/FallbackField.d.ts +2 -2
- package/lib/components/fields/FallbackField.d.ts.map +1 -1
- package/lib/components/fields/FallbackField.js +2 -2
- package/lib/components/fields/LayoutGridField.d.ts +8 -10
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +5 -4
- package/lib/components/fields/LayoutHeaderField.d.ts +2 -2
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
- package/lib/components/fields/LayoutHeaderField.js +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +2 -2
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +4 -1
- package/lib/components/fields/MultiSchemaField.d.ts +2 -41
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +116 -122
- package/lib/components/fields/NullField.d.ts +1 -1
- package/lib/components/fields/NullField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.d.ts +2 -2
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +7 -9
- package/lib/components/fields/ObjectField.d.ts +2 -2
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +28 -26
- package/lib/components/fields/OptionalDataControlsField.d.ts +2 -2
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.d.ts +14 -8
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +43 -30
- package/lib/components/fields/StringField.d.ts +2 -2
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +2 -5
- package/lib/components/fields/index.d.ts +1 -1
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/fields/index.js +2 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +2 -2
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +7 -6
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +2 -2
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +14 -7
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js +14 -6
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +2 -2
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -1
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts +7 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts.map +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js +12 -0
- package/lib/components/templates/DescriptionField.d.ts +2 -2
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.d.ts +2 -2
- package/lib/components/templates/ErrorList.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.js +2 -4
- package/lib/components/templates/FallbackFieldTemplate.d.ts +2 -2
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +2 -2
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.js +1 -3
- package/lib/components/templates/FieldHelpTemplate.d.ts +2 -2
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +2 -2
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts +3 -3
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
- package/lib/components/templates/GridTemplate.d.ts +2 -2
- package/lib/components/templates/GridTemplate.d.ts.map +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +2 -2
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +2 -2
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.js +1 -1
- package/lib/components/templates/TitleField.d.ts +2 -2
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.d.ts +2 -2
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +2 -2
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +2 -2
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -1
- package/lib/components/templates/index.d.ts +1 -1
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +2 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts +2 -2
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts +2 -2
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +2 -2
- package/lib/components/widgets/CheckboxWidget.d.ts +2 -2
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts +2 -2
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +4 -4
- package/lib/components/widgets/ColorWidget.d.ts +2 -2
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +2 -2
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.js +2 -2
- package/lib/components/widgets/DateWidget.d.ts +2 -2
- package/lib/components/widgets/DateWidget.d.ts.map +1 -1
- package/lib/components/widgets/EmailWidget.d.ts +2 -2
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.d.ts +2 -2
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.js +6 -4
- package/lib/components/widgets/HiddenWidget.d.ts +2 -2
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts +2 -2
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.d.ts +2 -2
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +4 -4
- package/lib/components/widgets/RangeWidget.d.ts +2 -2
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.d.ts +2 -2
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.js +15 -15
- package/lib/components/widgets/SelectWidget.d.ts +2 -2
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +9 -8
- package/lib/components/widgets/TextWidget.d.ts +2 -2
- package/lib/components/widgets/TextWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts +2 -2
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +5 -5
- package/lib/components/widgets/TimeWidget.d.ts +2 -2
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/URLWidget.d.ts +2 -2
- package/lib/components/widgets/URLWidget.d.ts.map +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts +2 -2
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
- package/lib/components/widgets/index.d.ts +1 -1
- package/lib/components/widgets/index.d.ts.map +1 -1
- package/lib/getDefaultRegistry.d.ts +1 -1
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +1 -1
- package/lib/getTestRegistry.d.ts +1 -1
- package/lib/getTestRegistry.d.ts.map +1 -1
- package/lib/getTestRegistry.js +1 -1
- package/lib/index.d.ts +10 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +3 -3
- package/lib/withTheme.d.ts.map +1 -1
- package/lib/withTheme.js +6 -6
- package/package.json +28 -28
- package/src/components/Form.tsx +197 -111
- package/src/components/RichDescription.tsx +3 -10
- package/src/components/RichHelp.tsx +3 -10
- package/src/components/SchemaExamples.tsx +6 -4
- package/src/components/fields/ArrayField.tsx +122 -108
- package/src/components/fields/BooleanField.tsx +4 -9
- package/src/components/fields/CyclicSchemaField.tsx +40 -0
- package/src/components/fields/FallbackField.tsx +4 -8
- package/src/components/fields/LayoutGridField.tsx +21 -19
- package/src/components/fields/LayoutHeaderField.tsx +2 -10
- package/src/components/fields/LayoutMultiSchemaField.tsx +15 -10
- package/src/components/fields/MultiSchemaField.tsx +202 -218
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +8 -10
- package/src/components/fields/ObjectField.tsx +52 -40
- package/src/components/fields/OptionalDataControlsField.tsx +6 -4
- package/src/components/fields/SchemaField.tsx +66 -51
- package/src/components/fields/StringField.tsx +4 -15
- package/src/components/fields/index.ts +3 -1
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +2 -7
- package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -9
- package/src/components/templates/ArrayFieldTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -10
- package/src/components/templates/BaseInputTemplate.tsx +16 -23
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/IconButton.tsx +16 -7
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/CyclicSchemaExpandTemplate.tsx +31 -0
- package/src/components/templates/DescriptionField.tsx +1 -1
- package/src/components/templates/ErrorList.tsx +8 -15
- package/src/components/templates/FallbackFieldTemplate.tsx +2 -1
- package/src/components/templates/FieldErrorTemplate.tsx +8 -8
- package/src/components/templates/FieldHelpTemplate.tsx +2 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/components/templates/FieldTemplate/Label.tsx +2 -2
- package/src/components/templates/GridTemplate.tsx +1 -1
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/components/templates/ObjectFieldTemplate.tsx +2 -7
- package/src/components/templates/OptionalDataControlsTemplate.tsx +3 -2
- package/src/components/templates/TitleField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +4 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/templates/index.ts +3 -1
- package/src/components/widgets/AltDateTimeWidget.tsx +1 -1
- package/src/components/widgets/AltDateWidget.tsx +7 -13
- package/src/components/widgets/CheckboxWidget.tsx +3 -5
- package/src/components/widgets/CheckboxesWidget.tsx +8 -10
- package/src/components/widgets/ColorWidget.tsx +2 -1
- package/src/components/widgets/DateTimeWidget.tsx +3 -10
- package/src/components/widgets/DateWidget.tsx +2 -1
- package/src/components/widgets/EmailWidget.tsx +2 -1
- package/src/components/widgets/FileWidget.tsx +9 -8
- package/src/components/widgets/HiddenWidget.tsx +1 -1
- package/src/components/widgets/PasswordWidget.tsx +2 -1
- package/src/components/widgets/RadioWidget.tsx +8 -10
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +48 -47
- package/src/components/widgets/SelectWidget.tsx +48 -31
- package/src/components/widgets/TextWidget.tsx +2 -1
- package/src/components/widgets/TextareaWidget.tsx +10 -7
- package/src/components/widgets/TimeWidget.tsx +2 -1
- package/src/components/widgets/URLWidget.tsx +2 -1
- package/src/components/widgets/UpDownWidget.tsx +2 -1
- package/src/components/widgets/index.ts +1 -1
- package/src/getDefaultRegistry.ts +2 -9
- package/src/getTestRegistry.tsx +2 -7
- package/src/index.ts +10 -5
- package/src/withTheme.tsx +14 -9
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
function IconButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
4
6
|
props: IconButtonProps<T, S, F>,
|
|
5
7
|
) {
|
|
6
8
|
const { iconType = 'default', icon, className, uiSchema, registry, ...otherProps } = props;
|
|
@@ -10,8 +12,10 @@ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
10
12
|
</button>
|
|
11
13
|
);
|
|
12
14
|
}
|
|
15
|
+
const IconButton = memo(IconButtonFn) as typeof IconButtonFn;
|
|
16
|
+
export default IconButton;
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
function CopyButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
15
19
|
props: IconButtonProps<T, S, F>,
|
|
16
20
|
) {
|
|
17
21
|
const {
|
|
@@ -19,8 +23,9 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
19
23
|
} = props;
|
|
20
24
|
return <IconButton title={translateString(TranslatableString.CopyButton)} {...props} icon='copy' />;
|
|
21
25
|
}
|
|
26
|
+
export const CopyButton = memo(CopyButtonFn) as typeof CopyButtonFn;
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
function MoveDownButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
24
29
|
props: IconButtonProps<T, S, F>,
|
|
25
30
|
) {
|
|
26
31
|
const {
|
|
@@ -28,8 +33,9 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
28
33
|
} = props;
|
|
29
34
|
return <IconButton title={translateString(TranslatableString.MoveDownButton)} {...props} icon='arrow-down' />;
|
|
30
35
|
}
|
|
36
|
+
export const MoveDownButton = memo(MoveDownButtonFn) as typeof MoveDownButtonFn;
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
function MoveUpButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
33
39
|
props: IconButtonProps<T, S, F>,
|
|
34
40
|
) {
|
|
35
41
|
const {
|
|
@@ -37,8 +43,9 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
37
43
|
} = props;
|
|
38
44
|
return <IconButton title={translateString(TranslatableString.MoveUpButton)} {...props} icon='arrow-up' />;
|
|
39
45
|
}
|
|
46
|
+
export const MoveUpButton = memo(MoveUpButtonFn) as typeof MoveUpButtonFn;
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
function RemoveButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
42
49
|
props: IconButtonProps<T, S, F>,
|
|
43
50
|
) {
|
|
44
51
|
const {
|
|
@@ -48,8 +55,9 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
48
55
|
<IconButton title={translateString(TranslatableString.RemoveButton)} {...props} iconType='danger' icon='remove' />
|
|
49
56
|
);
|
|
50
57
|
}
|
|
58
|
+
export const RemoveButton = memo(RemoveButtonFn) as typeof RemoveButtonFn;
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
function ClearButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
53
61
|
id,
|
|
54
62
|
className,
|
|
55
63
|
onClick,
|
|
@@ -72,3 +80,4 @@ export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
72
80
|
/>
|
|
73
81
|
);
|
|
74
82
|
}
|
|
83
|
+
export const ClearButton = memo(ClearButtonFn) as typeof ClearButtonFn;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';
|
|
2
|
+
import { getSubmitButtonOptions } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
4
5
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import AddButton from './AddButton';
|
|
4
4
|
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from './IconButton';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CyclicSchemaExpandProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { ID_KEY, TranslatableString } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
/** The `CyclicSchemaExpandTemplate` is the template to use to render the cyclic schema expand message and controls
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `DescriptionFieldProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function CyclicSchemaExpandTemplate<
|
|
9
|
+
T = any,
|
|
10
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
|
+
F extends FormContextType = any,
|
|
12
|
+
>(props: CyclicSchemaExpandProps<T, S, F>) {
|
|
13
|
+
const { name, fieldPathId, registry, onExpand } = props;
|
|
14
|
+
const { translateString } = registry;
|
|
15
|
+
const buttonId = `${fieldPathId[ID_KEY]}-button`;
|
|
16
|
+
return (
|
|
17
|
+
<div style={{ marginTop: '1rem' }}>
|
|
18
|
+
<div className='text-danger'>{translateString(TranslatableString.CycleDetected, [name])}</div>
|
|
19
|
+
<div>
|
|
20
|
+
<button
|
|
21
|
+
id={buttonId}
|
|
22
|
+
type='button'
|
|
23
|
+
className='btn btn-sm btn-warning'
|
|
24
|
+
onClick={() => onExpand(fieldPathId[ID_KEY])}
|
|
25
|
+
>
|
|
26
|
+
{translateString(TranslatableString.ExpandButton)}
|
|
27
|
+
</button>{' '}
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
FormContextType,
|
|
4
|
-
RJSFValidationError,
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
TranslatableString,
|
|
8
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { ErrorListProps, FormContextType, RJSFValidationError, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
9
3
|
|
|
10
4
|
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
11
5
|
*
|
|
@@ -22,13 +16,12 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
22
16
|
<h3 className='panel-title'>{translateString(TranslatableString.ErrorsLabel)}</h3>
|
|
23
17
|
</div>
|
|
24
18
|
<ul className='list-group'>
|
|
25
|
-
{errors.map((error: RJSFValidationError, i: number) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})}
|
|
19
|
+
{errors.map((error: RJSFValidationError, i: number) => (
|
|
20
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
21
|
+
<li key={i} className='list-group-item text-danger'>
|
|
22
|
+
{error.stack}
|
|
23
|
+
</li>
|
|
24
|
+
))}
|
|
32
25
|
</ul>
|
|
33
26
|
</div>
|
|
34
27
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FallbackFieldTemplateProps, FormContextType,
|
|
1
|
+
import type { FallbackFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The `FallbackFieldTemplate` is used to render a field when no field matches. The field renders a type selector and
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { errorId } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
4
5
|
*
|
|
@@ -20,13 +21,12 @@ export default function FieldErrorTemplate<
|
|
|
20
21
|
<ul id={id} className='error-detail bs-callout bs-callout-info'>
|
|
21
22
|
{errors
|
|
22
23
|
.filter((elem) => !!elem)
|
|
23
|
-
.map((error, index: number) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})}
|
|
24
|
+
.map((error, index: number) => (
|
|
25
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
26
|
+
<li className='text-danger' key={index}>
|
|
27
|
+
{error}
|
|
28
|
+
</li>
|
|
29
|
+
))}
|
|
30
30
|
</ul>
|
|
31
31
|
</div>
|
|
32
32
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { helpId } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
import RichHelp from '../RichHelp';
|
|
4
5
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
FormContextType,
|
|
4
|
-
RJSFSchema,
|
|
5
|
-
StrictRJSFSchema,
|
|
6
|
-
getTemplate,
|
|
7
|
-
getUiOptions,
|
|
8
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate, getUiOptions } from '@rjsf/utils';
|
|
9
3
|
|
|
10
4
|
import Label from './Label';
|
|
11
5
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const REQUIRED_FIELD_SYMBOL = '*';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface LabelProps {
|
|
4
4
|
/** The label for the field */
|
|
5
5
|
label?: string;
|
|
6
6
|
/** A boolean value stating if the field is required */
|
|
7
7
|
required?: boolean;
|
|
8
8
|
/** The id of the input field being labeled */
|
|
9
9
|
id?: string;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
|
|
12
12
|
/** Renders a label for a field
|
|
13
13
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridTemplateProps } from '@rjsf/utils';
|
|
1
|
+
import type { GridTemplateProps } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
/** Renders a `GridTemplate` for bootstrap 3, which is expecting the column information coming in via the `className`
|
|
4
4
|
* prop. Also spreads all the other props provided by the user directly on the div.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
/** The `MultiSchemaFieldTemplate` component renders the layout for the MultiSchemaField, which supports choosing
|
|
4
4
|
* a schema from a list of schemas defined using `anyOf` or `oneOf`.
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
FormContextType,
|
|
3
3
|
ObjectFieldTemplatePropertyType,
|
|
4
4
|
ObjectFieldTemplateProps,
|
|
5
5
|
RJSFSchema,
|
|
6
6
|
StrictRJSFSchema,
|
|
7
|
-
canExpand,
|
|
8
|
-
descriptionId,
|
|
9
|
-
getTemplate,
|
|
10
|
-
getUiOptions,
|
|
11
|
-
titleId,
|
|
12
|
-
buttonId,
|
|
13
7
|
} from '@rjsf/utils';
|
|
8
|
+
import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, buttonId } from '@rjsf/utils';
|
|
14
9
|
|
|
15
10
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
16
11
|
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import IconButton from './ButtonTemplates/IconButton';
|
|
4
4
|
|
|
@@ -27,7 +27,8 @@ export default function OptionalDataControlsTemplate<
|
|
|
27
27
|
title={label}
|
|
28
28
|
/>
|
|
29
29
|
);
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
|
+
if (onRemoveClick) {
|
|
31
32
|
return (
|
|
32
33
|
<IconButton
|
|
33
34
|
id={id}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema,
|
|
2
|
-
import {
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, UnsupportedFieldProps } from '@rjsf/utils';
|
|
2
|
+
import { TranslatableString } from '@rjsf/utils';
|
|
3
|
+
import { Markdown } from 'markdown-to-jsx/react';
|
|
3
4
|
|
|
4
5
|
/** The `UnsupportedField` component is used to render a field in the schema is one that is not supported by
|
|
5
6
|
* react-jsonschema-form.
|
|
@@ -13,7 +14,7 @@ function UnsupportedField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
13
14
|
const { translateString } = registry;
|
|
14
15
|
let translateEnum: TranslatableString = TranslatableString.UnsupportedField;
|
|
15
16
|
const translateParams: string[] = [];
|
|
16
|
-
if (fieldPathId
|
|
17
|
+
if (fieldPathId?.$id) {
|
|
17
18
|
translateEnum = TranslatableString.UnsupportedFieldWithId;
|
|
18
19
|
translateParams.push(fieldPathId.$id);
|
|
19
20
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
buttonId,
|
|
4
|
-
FormContextType,
|
|
5
|
-
RJSFSchema,
|
|
6
|
-
StrictRJSFSchema,
|
|
7
|
-
TranslatableString,
|
|
8
|
-
WrapIfAdditionalTemplateProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';
|
|
2
|
+
import { ADDITIONAL_PROPERTY_FLAG, buttonId, TranslatableString } from '@rjsf/utils';
|
|
10
3
|
|
|
11
4
|
import Label from './FieldTemplate/Label';
|
|
12
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import ArrayFieldDescriptionTemplate from './ArrayFieldDescriptionTemplate';
|
|
4
4
|
import ArrayFieldItemButtonsTemplate from './ArrayFieldItemButtonsTemplate';
|
|
@@ -7,6 +7,7 @@ import ArrayFieldTemplate from './ArrayFieldTemplate';
|
|
|
7
7
|
import ArrayFieldTitleTemplate from './ArrayFieldTitleTemplate';
|
|
8
8
|
import BaseInputTemplate from './BaseInputTemplate';
|
|
9
9
|
import ButtonTemplates from './ButtonTemplates';
|
|
10
|
+
import CyclicSchemaExpandTemplate from './CyclicSchemaExpandTemplate';
|
|
10
11
|
import DescriptionField from './DescriptionField';
|
|
11
12
|
import ErrorList from './ErrorList';
|
|
12
13
|
import FallbackFieldTemplate from './FallbackFieldTemplate';
|
|
@@ -34,6 +35,7 @@ function templates<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
34
35
|
ArrayFieldTitleTemplate,
|
|
35
36
|
ButtonTemplates: ButtonTemplates<T, S, F>(),
|
|
36
37
|
BaseInputTemplate,
|
|
38
|
+
CyclicSchemaExpandTemplate,
|
|
37
39
|
DescriptionFieldTemplate: DescriptionField,
|
|
38
40
|
ErrorListTemplate: ErrorList,
|
|
39
41
|
FallbackFieldTemplate,
|
|
@@ -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 `AltDateTimeWidget` is an alternative widget for rendering datetime properties.
|
|
4
4
|
* It uses the AltDateWidget for rendering, with the `time` prop set to true by default.
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
FormContextType,
|
|
4
|
-
RJSFSchema,
|
|
5
|
-
StrictRJSFSchema,
|
|
6
|
-
TranslatableString,
|
|
7
|
-
WidgetProps,
|
|
8
|
-
useAltDateWidgetProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
import { DateElement, TranslatableString, useAltDateWidgetProps } from '@rjsf/utils';
|
|
10
3
|
|
|
11
4
|
/** The `AltDateWidget` is an alternative widget for rendering date properties.
|
|
12
5
|
* @param props - The `WidgetProps` for this component
|
|
@@ -21,6 +14,7 @@ function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
21
14
|
return (
|
|
22
15
|
<ul className='list-inline'>
|
|
23
16
|
{elements.map((elemProps, i) => (
|
|
17
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
24
18
|
<li className='list-inline-item' key={i}>
|
|
25
19
|
<DateElement
|
|
26
20
|
rootId={id}
|
|
@@ -38,16 +32,16 @@ function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
38
32
|
))}
|
|
39
33
|
{(options.hideNowButton !== 'undefined' ? !options.hideNowButton : true) && (
|
|
40
34
|
<li className='list-inline-item'>
|
|
41
|
-
<
|
|
35
|
+
<button type='button' className='btn btn-info btn-now' onClick={handleSetNow}>
|
|
42
36
|
{translateString(TranslatableString.NowLabel)}
|
|
43
|
-
</
|
|
37
|
+
</button>
|
|
44
38
|
</li>
|
|
45
39
|
)}
|
|
46
40
|
{(options.hideClearButton !== 'undefined' ? !options.hideClearButton : true) && (
|
|
47
41
|
<li className='list-inline-item'>
|
|
48
|
-
<
|
|
42
|
+
<button type='button' className='btn btn-warning btn-clear' onClick={handleClear}>
|
|
49
43
|
{translateString(TranslatableString.ClearLabel)}
|
|
50
|
-
</
|
|
44
|
+
</button>
|
|
51
45
|
</li>
|
|
52
46
|
)}
|
|
53
47
|
</ul>
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent
|
|
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
|
|
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.
|
|
@@ -37,13 +35,13 @@ function CheckboxesWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
37
35
|
|
|
38
36
|
const handleBlur = useCallback(
|
|
39
37
|
({ target }: FocusEvent<HTMLInputElement>) =>
|
|
40
|
-
onBlur(id, enumOptionValueDecoder<S>(target
|
|
38
|
+
onBlur(id, enumOptionValueDecoder<S>(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
41
39
|
[onBlur, id, enumOptions, emptyValue, optionValueFormat],
|
|
42
40
|
);
|
|
43
41
|
|
|
44
42
|
const handleFocus = useCallback(
|
|
45
43
|
({ target }: FocusEvent<HTMLInputElement>) =>
|
|
46
|
-
onFocus(id, enumOptionValueDecoder<S>(target
|
|
44
|
+
onFocus(id, enumOptionValueDecoder<S>(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
47
45
|
[onFocus, id, enumOptions, emptyValue, optionValueFormat],
|
|
48
46
|
);
|
|
49
47
|
|
|
@@ -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.
|
|
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={
|
|
83
|
+
<label key={String(option.value)} className={`checkbox-inline ${disabledCls}`}>
|
|
86
84
|
{checkbox}
|
|
87
85
|
</label>
|
|
88
86
|
) : (
|
|
89
|
-
<div key={
|
|
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 {
|
|
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
|
-
|
|
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={(
|
|
21
|
+
onChange={(newValue) => onChange(localToUTC(newValue))}
|
|
29
22
|
/>
|
|
30
23
|
);
|
|
31
24
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import {
|
|
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 {
|
|
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 {
|
|
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
|
-
{
|
|
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 {
|
|
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
|
*
|