@rjsf/core 6.0.0-alpha.0 → 6.0.0-beta.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.
- package/dist/core.umd.js +1680 -809
- package/dist/index.esm.js +2166 -1198
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +2221 -1299
- package/dist/index.js.map +4 -4
- package/lib/components/Form.d.ts +22 -9
- package/lib/components/Form.d.ts.map +1 -0
- package/lib/components/Form.js +368 -312
- package/lib/components/RichDescription.d.ts +20 -0
- package/lib/components/RichDescription.d.ts.map +1 -0
- package/lib/components/RichDescription.js +17 -0
- package/lib/components/fields/ArrayField.d.ts +20 -9
- package/lib/components/fields/ArrayField.d.ts.map +1 -0
- package/lib/components/fields/ArrayField.js +212 -206
- package/lib/components/fields/BooleanField.d.ts +1 -0
- package/lib/components/fields/BooleanField.d.ts.map +1 -0
- package/lib/components/fields/BooleanField.js +6 -14
- package/lib/components/fields/LayoutGridField.d.ts +480 -0
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -0
- package/lib/components/fields/LayoutGridField.js +711 -0
- package/lib/components/fields/LayoutHeaderField.d.ts +12 -0
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -0
- package/lib/components/fields/LayoutHeaderField.js +23 -0
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +28 -0
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -0
- package/lib/components/fields/LayoutMultiSchemaField.js +114 -0
- package/lib/components/fields/MultiSchemaField.d.ts +1 -0
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -0
- package/lib/components/fields/MultiSchemaField.js +31 -31
- package/lib/components/fields/NullField.d.ts +1 -0
- package/lib/components/fields/NullField.d.ts.map +1 -0
- package/lib/components/fields/NullField.js +0 -1
- package/lib/components/fields/NumberField.d.ts +1 -0
- package/lib/components/fields/NumberField.d.ts.map +1 -0
- package/lib/components/fields/NumberField.js +2 -3
- package/lib/components/fields/ObjectField.d.ts +1 -0
- package/lib/components/fields/ObjectField.d.ts.map +1 -0
- package/lib/components/fields/ObjectField.js +146 -141
- package/lib/components/fields/SchemaField.d.ts +1 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -0
- package/lib/components/fields/SchemaField.js +10 -20
- package/lib/components/fields/StringField.d.ts +1 -0
- package/lib/components/fields/StringField.d.ts.map +1 -0
- package/lib/components/fields/StringField.js +1 -3
- package/lib/components/fields/index.d.ts +1 -0
- package/lib/components/fields/index.d.ts.map +1 -0
- package/lib/components/fields/index.js +14 -9
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +0 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +8 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +17 -0
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +4 -3
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js +7 -6
- package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldTemplate.js +3 -4
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js +0 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +1 -0
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -0
- package/lib/components/templates/BaseInputTemplate.js +0 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.js +1 -2
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js +4 -5
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js +0 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/index.js +3 -4
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.d.ts.map +1 -0
- package/lib/components/templates/DescriptionField.js +3 -8
- package/lib/components/templates/ErrorList.d.ts +1 -0
- package/lib/components/templates/ErrorList.d.ts.map +1 -0
- package/lib/components/templates/ErrorList.js +0 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -0
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldErrorTemplate.js +0 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts +1 -0
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldHelpTemplate.js +0 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -2
- package/lib/components/templates/FieldTemplate/Label.d.ts +1 -0
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/Label.js +0 -1
- package/lib/components/templates/FieldTemplate/index.d.ts +2 -1
- package/lib/components/templates/FieldTemplate/index.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/index.js +1 -2
- package/lib/components/templates/GridTemplate.d.ts +8 -0
- package/lib/components/templates/GridTemplate.d.ts.map +1 -0
- package/lib/components/templates/GridTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/ObjectFieldTemplate.js +2 -3
- package/lib/components/templates/TitleField.d.ts +1 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -0
- package/lib/components/templates/TitleField.js +0 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -0
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -0
- package/lib/components/templates/UnsupportedField.js +0 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.js +10 -6
- package/lib/components/templates/index.d.ts +1 -0
- package/lib/components/templates/index.d.ts.map +1 -0
- package/lib/components/templates/index.js +19 -16
- package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/AltDateTimeWidget.js +0 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -0
- package/lib/components/widgets/AltDateWidget.js +0 -1
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -0
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -0
- package/lib/components/widgets/CheckboxWidget.js +2 -4
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -0
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -0
- package/lib/components/widgets/CheckboxesWidget.js +0 -1
- package/lib/components/widgets/ColorWidget.d.ts +1 -0
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -0
- package/lib/components/widgets/ColorWidget.js +0 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -0
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/DateTimeWidget.js +0 -1
- package/lib/components/widgets/DateWidget.d.ts +1 -0
- package/lib/components/widgets/DateWidget.d.ts.map +1 -0
- package/lib/components/widgets/DateWidget.js +0 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -0
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -0
- package/lib/components/widgets/EmailWidget.js +0 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -0
- package/lib/components/widgets/FileWidget.d.ts.map +1 -0
- package/lib/components/widgets/FileWidget.js +3 -5
- package/lib/components/widgets/HiddenWidget.d.ts +1 -0
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -0
- package/lib/components/widgets/HiddenWidget.js +0 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -0
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -0
- package/lib/components/widgets/PasswordWidget.js +0 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -0
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -0
- package/lib/components/widgets/RadioWidget.js +3 -4
- package/lib/components/widgets/RangeWidget.d.ts +1 -0
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -0
- package/lib/components/widgets/RangeWidget.js +0 -1
- package/lib/components/widgets/RatingWidget.d.ts +15 -0
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -0
- package/lib/components/widgets/RatingWidget.js +63 -0
- package/lib/components/widgets/SelectWidget.d.ts +1 -0
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -0
- package/lib/components/widgets/SelectWidget.js +4 -5
- package/lib/components/widgets/TextWidget.d.ts +1 -0
- package/lib/components/widgets/TextWidget.d.ts.map +1 -0
- package/lib/components/widgets/TextWidget.js +0 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -0
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -0
- package/lib/components/widgets/TextareaWidget.js +0 -1
- package/lib/components/widgets/TimeWidget.d.ts +1 -0
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/TimeWidget.js +0 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -0
- package/lib/components/widgets/URLWidget.d.ts.map +1 -0
- package/lib/components/widgets/URLWidget.js +0 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -0
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -0
- package/lib/components/widgets/UpDownWidget.js +0 -1
- package/lib/components/widgets/index.d.ts +1 -0
- package/lib/components/widgets/index.d.ts.map +1 -0
- package/lib/components/widgets/index.js +21 -20
- package/lib/getDefaultRegistry.d.ts +1 -0
- package/lib/getDefaultRegistry.d.ts.map +1 -0
- package/lib/getDefaultRegistry.js +3 -4
- package/lib/index.d.ts +7 -5
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -5
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +2 -1
- package/lib/withTheme.d.ts.map +1 -0
- package/lib/withTheme.js +7 -8
- package/package.json +46 -37
- package/src/components/Form.tsx +127 -41
- package/src/components/RichDescription.tsx +50 -0
- package/src/components/fields/ArrayField.tsx +34 -24
- package/src/components/fields/BooleanField.tsx +6 -14
- package/src/components/fields/LayoutGridField.tsx +967 -0
- package/src/components/fields/LayoutHeaderField.tsx +49 -0
- package/src/components/fields/LayoutMultiSchemaField.tsx +228 -0
- package/src/components/fields/MultiSchemaField.tsx +9 -4
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +5 -5
- package/src/components/fields/ObjectField.tsx +32 -24
- package/src/components/fields/SchemaField.tsx +17 -30
- package/src/components/fields/StringField.tsx +2 -2
- package/src/components/fields/index.ts +7 -1
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -2
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +85 -0
- package/src/components/templates/ArrayFieldItemTemplate.tsx +18 -57
- package/src/components/templates/ArrayFieldTemplate.tsx +10 -8
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -2
- package/src/components/templates/BaseInputTemplate.tsx +4 -4
- package/src/components/templates/ButtonTemplates/IconButton.tsx +9 -36
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +1 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/DescriptionField.tsx +9 -15
- package/src/components/templates/FieldErrorTemplate.tsx +1 -1
- package/src/components/templates/FieldHelpTemplate.tsx +1 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -2
- package/src/components/templates/GridTemplate.tsx +15 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +5 -3
- package/src/components/templates/TitleField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +1 -1
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +14 -4
- package/src/components/templates/index.ts +4 -0
- package/src/components/widgets/AltDateWidget.tsx +9 -6
- package/src/components/widgets/CheckboxWidget.tsx +5 -5
- package/src/components/widgets/CheckboxesWidget.tsx +2 -2
- package/src/components/widgets/ColorWidget.tsx +1 -1
- package/src/components/widgets/DateTimeWidget.tsx +1 -1
- package/src/components/widgets/DateWidget.tsx +1 -1
- package/src/components/widgets/EmailWidget.tsx +1 -1
- package/src/components/widgets/FileWidget.tsx +5 -5
- package/src/components/widgets/PasswordWidget.tsx +1 -1
- package/src/components/widgets/RadioWidget.tsx +3 -3
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +129 -0
- package/src/components/widgets/SelectWidget.tsx +4 -3
- package/src/components/widgets/TextWidget.tsx +1 -1
- package/src/components/widgets/TextareaWidget.tsx +3 -3
- package/src/components/widgets/TimeWidget.tsx +1 -1
- package/src/components/widgets/URLWidget.tsx +1 -1
- package/src/components/widgets/UpDownWidget.tsx +1 -1
- package/src/components/widgets/index.ts +3 -1
- package/src/getDefaultRegistry.ts +1 -1
- package/src/index.ts +3 -2
- package/src/tsconfig.json +14 -6
- package/src/withTheme.tsx +4 -3
- package/LICENSE.md +0 -201
- package/lib/components/Form.js.map +0 -1
- package/lib/components/fields/ArrayField.js.map +0 -1
- package/lib/components/fields/BooleanField.js.map +0 -1
- package/lib/components/fields/MultiSchemaField.js.map +0 -1
- package/lib/components/fields/NullField.js.map +0 -1
- package/lib/components/fields/NumberField.js.map +0 -1
- package/lib/components/fields/ObjectField.js.map +0 -1
- package/lib/components/fields/SchemaField.js.map +0 -1
- package/lib/components/fields/StringField.js.map +0 -1
- package/lib/components/fields/index.js.map +0 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js.map +0 -1
- package/lib/components/templates/BaseInputTemplate.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/index.js.map +0 -1
- package/lib/components/templates/DescriptionField.js.map +0 -1
- package/lib/components/templates/ErrorList.js.map +0 -1
- package/lib/components/templates/FieldErrorTemplate.js.map +0 -1
- package/lib/components/templates/FieldHelpTemplate.js.map +0 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +0 -1
- package/lib/components/templates/FieldTemplate/Label.js.map +0 -1
- package/lib/components/templates/FieldTemplate/index.js.map +0 -1
- package/lib/components/templates/ObjectFieldTemplate.js.map +0 -1
- package/lib/components/templates/TitleField.js.map +0 -1
- package/lib/components/templates/UnsupportedField.js.map +0 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +0 -1
- package/lib/components/templates/index.js.map +0 -1
- package/lib/components/widgets/AltDateTimeWidget.js.map +0 -1
- package/lib/components/widgets/AltDateWidget.js.map +0 -1
- package/lib/components/widgets/CheckboxWidget.js.map +0 -1
- package/lib/components/widgets/CheckboxesWidget.js.map +0 -1
- package/lib/components/widgets/ColorWidget.js.map +0 -1
- package/lib/components/widgets/DateTimeWidget.js.map +0 -1
- package/lib/components/widgets/DateWidget.js.map +0 -1
- package/lib/components/widgets/EmailWidget.js.map +0 -1
- package/lib/components/widgets/FileWidget.js.map +0 -1
- package/lib/components/widgets/HiddenWidget.js.map +0 -1
- package/lib/components/widgets/PasswordWidget.js.map +0 -1
- package/lib/components/widgets/RadioWidget.js.map +0 -1
- package/lib/components/widgets/RangeWidget.js.map +0 -1
- package/lib/components/widgets/SelectWidget.js.map +0 -1
- package/lib/components/widgets/TextWidget.js.map +0 -1
- package/lib/components/widgets/TextareaWidget.js.map +0 -1
- package/lib/components/widgets/TimeWidget.js.map +0 -1
- package/lib/components/widgets/URLWidget.js.map +0 -1
- package/lib/components/widgets/UpDownWidget.js.map +0 -1
- package/lib/components/widgets/index.js.map +0 -1
- package/lib/getDefaultRegistry.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/withTheme.js.map +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ArrayFieldItemButtonsTemplateType,
|
|
4
|
+
buttonId,
|
|
5
|
+
FormContextType,
|
|
6
|
+
RJSFSchema,
|
|
7
|
+
StrictRJSFSchema,
|
|
8
|
+
} from '@rjsf/utils';
|
|
9
|
+
|
|
10
|
+
/** The `ArrayFieldTemplateItemButtons` component is the template used to render the buttons associate3d with items of
|
|
11
|
+
* an array.
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `ArrayFieldItemButtonsTemplateType` props for the component
|
|
14
|
+
*/
|
|
15
|
+
export default function ArrayFieldItemButtonsTemplate<
|
|
16
|
+
T = any,
|
|
17
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
18
|
+
F extends FormContextType = any,
|
|
19
|
+
>(props: ArrayFieldItemButtonsTemplateType<T, S, F>) {
|
|
20
|
+
const {
|
|
21
|
+
disabled,
|
|
22
|
+
hasCopy,
|
|
23
|
+
hasMoveDown,
|
|
24
|
+
hasMoveUp,
|
|
25
|
+
hasRemove,
|
|
26
|
+
idSchema,
|
|
27
|
+
index,
|
|
28
|
+
onCopyIndexClick,
|
|
29
|
+
onDropIndexClick,
|
|
30
|
+
onReorderClick,
|
|
31
|
+
readonly,
|
|
32
|
+
registry,
|
|
33
|
+
uiSchema,
|
|
34
|
+
} = props;
|
|
35
|
+
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
|
|
36
|
+
const onCopyClick = useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
|
|
37
|
+
const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
|
|
38
|
+
const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
|
|
39
|
+
const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
{(hasMoveUp || hasMoveDown) && (
|
|
44
|
+
<MoveUpButton
|
|
45
|
+
id={buttonId<T>(idSchema, 'moveUp')}
|
|
46
|
+
className='rjsf-array-item-move-up'
|
|
47
|
+
disabled={disabled || readonly || !hasMoveUp}
|
|
48
|
+
onClick={onArrowUpClick}
|
|
49
|
+
uiSchema={uiSchema}
|
|
50
|
+
registry={registry}
|
|
51
|
+
/>
|
|
52
|
+
)}
|
|
53
|
+
{(hasMoveUp || hasMoveDown) && (
|
|
54
|
+
<MoveDownButton
|
|
55
|
+
id={buttonId<T>(idSchema, 'moveDown')}
|
|
56
|
+
className='rjsf-array-item-move-down'
|
|
57
|
+
disabled={disabled || readonly || !hasMoveDown}
|
|
58
|
+
onClick={onArrowDownClick}
|
|
59
|
+
uiSchema={uiSchema}
|
|
60
|
+
registry={registry}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
{hasCopy && (
|
|
64
|
+
<CopyButton
|
|
65
|
+
id={buttonId<T>(idSchema, 'copy')}
|
|
66
|
+
className='rjsf-array-item-copy'
|
|
67
|
+
disabled={disabled || readonly}
|
|
68
|
+
onClick={onCopyClick}
|
|
69
|
+
uiSchema={uiSchema}
|
|
70
|
+
registry={registry}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
{hasRemove && (
|
|
74
|
+
<RemoveButton
|
|
75
|
+
id={buttonId<T>(idSchema, 'remove')}
|
|
76
|
+
className='rjsf-array-item-remove'
|
|
77
|
+
disabled={disabled || readonly}
|
|
78
|
+
onClick={onRemoveClick}
|
|
79
|
+
uiSchema={uiSchema}
|
|
80
|
+
registry={registry}
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ArrayFieldItemTemplateType,
|
|
4
|
+
FormContextType,
|
|
5
|
+
getTemplate,
|
|
6
|
+
getUiOptions,
|
|
7
|
+
RJSFSchema,
|
|
8
|
+
StrictRJSFSchema,
|
|
9
|
+
} from '@rjsf/utils';
|
|
3
10
|
|
|
4
11
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
5
12
|
*
|
|
6
|
-
* @param props - The `
|
|
13
|
+
* @param props - The `ArrayFieldItemTemplateType` props for the component
|
|
7
14
|
*/
|
|
8
15
|
export default function ArrayFieldItemTemplate<
|
|
9
16
|
T = any,
|
|
10
17
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
|
-
F extends FormContextType = any
|
|
12
|
-
>(props:
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
hasToolbar,
|
|
18
|
-
hasMoveDown,
|
|
19
|
-
hasMoveUp,
|
|
20
|
-
hasRemove,
|
|
21
|
-
hasCopy,
|
|
22
|
-
index,
|
|
23
|
-
onCopyIndexClick,
|
|
24
|
-
onDropIndexClick,
|
|
25
|
-
onReorderClick,
|
|
26
|
-
readonly,
|
|
18
|
+
F extends FormContextType = any,
|
|
19
|
+
>(props: ArrayFieldItemTemplateType<T, S, F>) {
|
|
20
|
+
const { children, className, buttonsProps, hasToolbar, registry, uiSchema } = props;
|
|
21
|
+
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
22
|
+
const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
|
|
23
|
+
'ArrayFieldItemButtonsTemplate',
|
|
27
24
|
registry,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
|
|
25
|
+
uiOptions,
|
|
26
|
+
);
|
|
31
27
|
const btnStyle: CSSProperties = {
|
|
32
28
|
flex: 1,
|
|
33
29
|
paddingLeft: 6,
|
|
@@ -46,42 +42,7 @@ export default function ArrayFieldItemTemplate<
|
|
|
46
42
|
justifyContent: 'space-around',
|
|
47
43
|
}}
|
|
48
44
|
>
|
|
49
|
-
{
|
|
50
|
-
<MoveUpButton
|
|
51
|
-
style={btnStyle}
|
|
52
|
-
disabled={disabled || readonly || !hasMoveUp}
|
|
53
|
-
onClick={onReorderClick(index, index - 1)}
|
|
54
|
-
uiSchema={uiSchema}
|
|
55
|
-
registry={registry}
|
|
56
|
-
/>
|
|
57
|
-
)}
|
|
58
|
-
{(hasMoveUp || hasMoveDown) && (
|
|
59
|
-
<MoveDownButton
|
|
60
|
-
style={btnStyle}
|
|
61
|
-
disabled={disabled || readonly || !hasMoveDown}
|
|
62
|
-
onClick={onReorderClick(index, index + 1)}
|
|
63
|
-
uiSchema={uiSchema}
|
|
64
|
-
registry={registry}
|
|
65
|
-
/>
|
|
66
|
-
)}
|
|
67
|
-
{hasCopy && (
|
|
68
|
-
<CopyButton
|
|
69
|
-
style={btnStyle}
|
|
70
|
-
disabled={disabled || readonly}
|
|
71
|
-
onClick={onCopyIndexClick(index)}
|
|
72
|
-
uiSchema={uiSchema}
|
|
73
|
-
registry={registry}
|
|
74
|
-
/>
|
|
75
|
-
)}
|
|
76
|
-
{hasRemove && (
|
|
77
|
-
<RemoveButton
|
|
78
|
-
style={btnStyle}
|
|
79
|
-
disabled={disabled || readonly}
|
|
80
|
-
onClick={onDropIndexClick(index)}
|
|
81
|
-
uiSchema={uiSchema}
|
|
82
|
-
registry={registry}
|
|
83
|
-
/>
|
|
84
|
-
)}
|
|
45
|
+
<ArrayFieldItemButtonsTemplate {...buttonsProps} style={btnStyle} />
|
|
85
46
|
</div>
|
|
86
47
|
</div>
|
|
87
48
|
)}
|
|
@@ -2,20 +2,21 @@ import {
|
|
|
2
2
|
getTemplate,
|
|
3
3
|
getUiOptions,
|
|
4
4
|
ArrayFieldTemplateProps,
|
|
5
|
-
|
|
5
|
+
ArrayFieldItemTemplateType,
|
|
6
6
|
FormContextType,
|
|
7
7
|
RJSFSchema,
|
|
8
8
|
StrictRJSFSchema,
|
|
9
|
+
buttonId,
|
|
9
10
|
} from '@rjsf/utils';
|
|
10
11
|
|
|
11
12
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
12
13
|
*
|
|
13
|
-
* @param props - The `
|
|
14
|
+
* @param props - The `ArrayFieldItemTemplateType` props for the component
|
|
14
15
|
*/
|
|
15
16
|
export default function ArrayFieldTemplate<
|
|
16
17
|
T = any,
|
|
17
18
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
18
|
-
F extends FormContextType = any
|
|
19
|
+
F extends FormContextType = any,
|
|
19
20
|
>(props: ArrayFieldTemplateProps<T, S, F>) {
|
|
20
21
|
const {
|
|
21
22
|
canAdd,
|
|
@@ -35,17 +36,17 @@ export default function ArrayFieldTemplate<
|
|
|
35
36
|
const ArrayFieldDescriptionTemplate = getTemplate<'ArrayFieldDescriptionTemplate', T, S, F>(
|
|
36
37
|
'ArrayFieldDescriptionTemplate',
|
|
37
38
|
registry,
|
|
38
|
-
uiOptions
|
|
39
|
+
uiOptions,
|
|
39
40
|
);
|
|
40
41
|
const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
|
|
41
42
|
'ArrayFieldItemTemplate',
|
|
42
43
|
registry,
|
|
43
|
-
uiOptions
|
|
44
|
+
uiOptions,
|
|
44
45
|
);
|
|
45
46
|
const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
|
|
46
47
|
'ArrayFieldTitleTemplate',
|
|
47
48
|
registry,
|
|
48
|
-
uiOptions
|
|
49
|
+
uiOptions,
|
|
49
50
|
);
|
|
50
51
|
// Button templates are not overridden in the uiSchema
|
|
51
52
|
const {
|
|
@@ -70,13 +71,14 @@ export default function ArrayFieldTemplate<
|
|
|
70
71
|
/>
|
|
71
72
|
<div className='row array-item-list'>
|
|
72
73
|
{items &&
|
|
73
|
-
items.map(({ key, ...itemProps }:
|
|
74
|
+
items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
|
|
74
75
|
<ArrayFieldItemTemplate key={key} {...itemProps} />
|
|
75
76
|
))}
|
|
76
77
|
</div>
|
|
77
78
|
{canAdd && (
|
|
78
79
|
<AddButton
|
|
79
|
-
|
|
80
|
+
id={buttonId<T>(idSchema, 'add')}
|
|
81
|
+
className='rjsf-array-item-add'
|
|
80
82
|
onClick={onAddClick}
|
|
81
83
|
disabled={disabled || readonly}
|
|
82
84
|
uiSchema={uiSchema}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
export default function ArrayFieldTitleTemplate<
|
|
18
18
|
T = any,
|
|
19
19
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
20
|
-
F extends FormContextType = any
|
|
20
|
+
F extends FormContextType = any,
|
|
21
21
|
>(props: ArrayFieldTitleProps<T, S, F>) {
|
|
22
22
|
const { idSchema, title, schema, uiSchema, required, registry } = props;
|
|
23
23
|
const options = getUiOptions<T, S, F>(uiSchema, registry.globalUiOptions);
|
|
@@ -28,7 +28,7 @@ export default function ArrayFieldTitleTemplate<
|
|
|
28
28
|
const TitleFieldTemplate: TemplatesType<T, S, F>['TitleFieldTemplate'] = getTemplate<'TitleFieldTemplate', T, S, F>(
|
|
29
29
|
'TitleFieldTemplate',
|
|
30
30
|
registry,
|
|
31
|
-
options
|
|
31
|
+
options,
|
|
32
32
|
);
|
|
33
33
|
return (
|
|
34
34
|
<TitleFieldTemplate
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
export default function BaseInputTemplate<
|
|
19
19
|
T = any,
|
|
20
20
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
21
|
-
F extends FormContextType = any
|
|
21
|
+
F extends FormContextType = any,
|
|
22
22
|
>(props: BaseInputTemplateProps<T, S, F>) {
|
|
23
23
|
const {
|
|
24
24
|
id,
|
|
@@ -63,15 +63,15 @@ export default function BaseInputTemplate<
|
|
|
63
63
|
|
|
64
64
|
const _onChange = useCallback(
|
|
65
65
|
({ target: { value } }: ChangeEvent<HTMLInputElement>) => onChange(value === '' ? options.emptyValue : value),
|
|
66
|
-
[onChange, options]
|
|
66
|
+
[onChange, options],
|
|
67
67
|
);
|
|
68
68
|
const _onBlur = useCallback(
|
|
69
69
|
({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value),
|
|
70
|
-
[onBlur, id]
|
|
70
|
+
[onBlur, id],
|
|
71
71
|
);
|
|
72
72
|
const _onFocus = useCallback(
|
|
73
73
|
({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value),
|
|
74
|
-
[onFocus, id]
|
|
74
|
+
[onFocus, id],
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
4
|
-
props: IconButtonProps<T, S, F
|
|
4
|
+
props: IconButtonProps<T, S, F>,
|
|
5
5
|
) {
|
|
6
6
|
const { iconType = 'default', icon, className, uiSchema, registry, ...otherProps } = props;
|
|
7
7
|
return (
|
|
@@ -12,66 +12,39 @@ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
15
|
-
props: IconButtonProps<T, S, F
|
|
15
|
+
props: IconButtonProps<T, S, F>,
|
|
16
16
|
) {
|
|
17
17
|
const {
|
|
18
18
|
registry: { translateString },
|
|
19
19
|
} = props;
|
|
20
|
-
return (
|
|
21
|
-
<IconButton
|
|
22
|
-
title={translateString(TranslatableString.CopyButton)}
|
|
23
|
-
className='array-item-copy'
|
|
24
|
-
{...props}
|
|
25
|
-
icon='copy'
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
20
|
+
return <IconButton title={translateString(TranslatableString.CopyButton)} {...props} icon='copy' />;
|
|
28
21
|
}
|
|
29
22
|
|
|
30
23
|
export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
31
|
-
props: IconButtonProps<T, S, F
|
|
24
|
+
props: IconButtonProps<T, S, F>,
|
|
32
25
|
) {
|
|
33
26
|
const {
|
|
34
27
|
registry: { translateString },
|
|
35
28
|
} = props;
|
|
36
|
-
return (
|
|
37
|
-
<IconButton
|
|
38
|
-
title={translateString(TranslatableString.MoveDownButton)}
|
|
39
|
-
className='array-item-move-down'
|
|
40
|
-
{...props}
|
|
41
|
-
icon='arrow-down'
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
29
|
+
return <IconButton title={translateString(TranslatableString.MoveDownButton)} {...props} icon='arrow-down' />;
|
|
44
30
|
}
|
|
45
31
|
|
|
46
32
|
export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
47
|
-
props: IconButtonProps<T, S, F
|
|
33
|
+
props: IconButtonProps<T, S, F>,
|
|
48
34
|
) {
|
|
49
35
|
const {
|
|
50
36
|
registry: { translateString },
|
|
51
37
|
} = props;
|
|
52
|
-
return (
|
|
53
|
-
<IconButton
|
|
54
|
-
title={translateString(TranslatableString.MoveUpButton)}
|
|
55
|
-
className='array-item-move-up'
|
|
56
|
-
{...props}
|
|
57
|
-
icon='arrow-up'
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
38
|
+
return <IconButton title={translateString(TranslatableString.MoveUpButton)} {...props} icon='arrow-up' />;
|
|
60
39
|
}
|
|
61
40
|
|
|
62
41
|
export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
63
|
-
props: IconButtonProps<T, S, F
|
|
42
|
+
props: IconButtonProps<T, S, F>,
|
|
64
43
|
) {
|
|
65
44
|
const {
|
|
66
45
|
registry: { translateString },
|
|
67
46
|
} = props;
|
|
68
47
|
return (
|
|
69
|
-
<IconButton
|
|
70
|
-
title={translateString(TranslatableString.RemoveButton)}
|
|
71
|
-
className='array-item-remove'
|
|
72
|
-
{...props}
|
|
73
|
-
iconType='danger'
|
|
74
|
-
icon='remove'
|
|
75
|
-
/>
|
|
48
|
+
<IconButton title={translateString(TranslatableString.RemoveButton)} {...props} iconType='danger' icon='remove' />
|
|
76
49
|
);
|
|
77
50
|
}
|
|
@@ -5,7 +5,7 @@ import { getSubmitButtonOptions, FormContextType, RJSFSchema, StrictRJSFSchema,
|
|
|
5
5
|
export default function SubmitButton<
|
|
6
6
|
T = any,
|
|
7
7
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
8
|
-
F extends FormContextType = any
|
|
8
|
+
F extends FormContextType = any,
|
|
9
9
|
>({ uiSchema }: SubmitButtonProps<T, S, F>) {
|
|
10
10
|
const { submitText, norender, props: submitButtonProps = {} } = getSubmitButtonOptions<T, S, F>(uiSchema);
|
|
11
11
|
if (norender) {
|
|
@@ -7,7 +7,7 @@ import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from './IconBu
|
|
|
7
7
|
function buttonTemplates<
|
|
8
8
|
T = any,
|
|
9
9
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
10
|
-
F extends FormContextType = any
|
|
10
|
+
F extends FormContextType = any,
|
|
11
11
|
>(): TemplatesType<T, S, F>['ButtonTemplates'] {
|
|
12
12
|
return {
|
|
13
13
|
SubmitButton,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
|
+
import RichDescription from '../RichDescription';
|
|
4
|
+
|
|
3
5
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
4
6
|
*
|
|
5
7
|
* @param props - The `DescriptionFieldProps` for this component
|
|
@@ -7,23 +9,15 @@ import { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema }
|
|
|
7
9
|
export default function DescriptionField<
|
|
8
10
|
T = any,
|
|
9
11
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
10
|
-
F extends FormContextType = any
|
|
12
|
+
F extends FormContextType = any,
|
|
11
13
|
>(props: DescriptionFieldProps<T, S, F>) {
|
|
12
|
-
const { id, description } = props;
|
|
14
|
+
const { id, description, registry, uiSchema } = props;
|
|
13
15
|
if (!description) {
|
|
14
16
|
return null;
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
} else {
|
|
23
|
-
return (
|
|
24
|
-
<div id={id} className='field-description'>
|
|
25
|
-
{description}
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
18
|
+
return (
|
|
19
|
+
<div id={id} className='field-description'>
|
|
20
|
+
<RichDescription description={description} registry={registry} uiSchema={uiSchema} />
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
29
23
|
}
|
|
@@ -7,7 +7,7 @@ import { errorId, FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema
|
|
|
7
7
|
export default function FieldErrorTemplate<
|
|
8
8
|
T = any,
|
|
9
9
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
10
|
-
F extends FormContextType = any
|
|
10
|
+
F extends FormContextType = any,
|
|
11
11
|
>(props: FieldErrorProps<T, S, F>) {
|
|
12
12
|
const { errors = [], idSchema } = props;
|
|
13
13
|
if (errors.length === 0) {
|
|
@@ -7,7 +7,7 @@ import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema }
|
|
|
7
7
|
export default function FieldHelpTemplate<
|
|
8
8
|
T = any,
|
|
9
9
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
10
|
-
F extends FormContextType = any
|
|
10
|
+
F extends FormContextType = any,
|
|
11
11
|
>(props: FieldHelpProps<T, S, F>) {
|
|
12
12
|
const { idSchema, help } = props;
|
|
13
13
|
if (!help) {
|
|
@@ -17,14 +17,14 @@ import Label from './Label';
|
|
|
17
17
|
export default function FieldTemplate<
|
|
18
18
|
T = any,
|
|
19
19
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
20
|
-
F extends FormContextType = any
|
|
20
|
+
F extends FormContextType = any,
|
|
21
21
|
>(props: FieldTemplateProps<T, S, F>) {
|
|
22
22
|
const { id, label, children, errors, help, description, hidden, required, displayLabel, registry, uiSchema } = props;
|
|
23
23
|
const uiOptions = getUiOptions(uiSchema);
|
|
24
24
|
const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate', T, S, F>(
|
|
25
25
|
'WrapIfAdditionalTemplate',
|
|
26
26
|
registry,
|
|
27
|
-
uiOptions
|
|
27
|
+
uiOptions,
|
|
28
28
|
);
|
|
29
29
|
if (hidden) {
|
|
30
30
|
return <div className='hidden'>{children}</div>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GridTemplateProps } from '@rjsf/utils';
|
|
2
|
+
|
|
3
|
+
/** Renders a `GridTemplate` for bootstrap 3, which is expecting the column information coming in via the `className`
|
|
4
|
+
* prop. Also spreads all the other props provided by the user directly on the div.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The GridTemplateProps, including the expected className for the bootstrap 3 grid behavior
|
|
7
|
+
*/
|
|
8
|
+
export default function GridTemplate(props: GridTemplateProps) {
|
|
9
|
+
const { children, column, className, ...rest } = props;
|
|
10
|
+
return (
|
|
11
|
+
<div className={className} {...rest}>
|
|
12
|
+
{children}
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getTemplate,
|
|
10
10
|
getUiOptions,
|
|
11
11
|
titleId,
|
|
12
|
+
buttonId,
|
|
12
13
|
} from '@rjsf/utils';
|
|
13
14
|
|
|
14
15
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -20,7 +21,7 @@ import {
|
|
|
20
21
|
export default function ObjectFieldTemplate<
|
|
21
22
|
T = any,
|
|
22
23
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
23
|
-
F extends FormContextType = any
|
|
24
|
+
F extends FormContextType = any,
|
|
24
25
|
>(props: ObjectFieldTemplateProps<T, S, F>) {
|
|
25
26
|
const {
|
|
26
27
|
description,
|
|
@@ -41,7 +42,7 @@ export default function ObjectFieldTemplate<
|
|
|
41
42
|
const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>(
|
|
42
43
|
'DescriptionFieldTemplate',
|
|
43
44
|
registry,
|
|
44
|
-
options
|
|
45
|
+
options,
|
|
45
46
|
);
|
|
46
47
|
// Button templates are not overridden in the uiSchema
|
|
47
48
|
const {
|
|
@@ -71,7 +72,8 @@ export default function ObjectFieldTemplate<
|
|
|
71
72
|
{properties.map((prop: ObjectFieldTemplatePropertyType) => prop.content)}
|
|
72
73
|
{canExpand<T, S, F>(schema, uiSchema, formData) && (
|
|
73
74
|
<AddButton
|
|
74
|
-
|
|
75
|
+
id={buttonId<T>(idSchema, 'add')}
|
|
76
|
+
className='rjsf-object-property-expand'
|
|
75
77
|
onClick={onAddClick(schema)}
|
|
76
78
|
disabled={disabled || readonly}
|
|
77
79
|
uiSchema={uiSchema}
|
|
@@ -7,7 +7,7 @@ const REQUIRED_FIELD_SYMBOL = '*';
|
|
|
7
7
|
* @param props - The `TitleFieldProps` for this component
|
|
8
8
|
*/
|
|
9
9
|
export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
10
|
-
props: TitleFieldProps<T, S, F
|
|
10
|
+
props: TitleFieldProps<T, S, F>,
|
|
11
11
|
) {
|
|
12
12
|
const { id, title, required } = props;
|
|
13
13
|
return (
|
|
@@ -7,7 +7,7 @@ import Markdown from 'markdown-to-jsx';
|
|
|
7
7
|
* @param props - The `FieldProps` for this template
|
|
8
8
|
*/
|
|
9
9
|
function UnsupportedField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
10
|
-
props: UnsupportedFieldProps<T, S, F
|
|
10
|
+
props: UnsupportedFieldProps<T, S, F>,
|
|
11
11
|
) {
|
|
12
12
|
const { schema, idSchema, reason, registry } = props;
|
|
13
13
|
const { translateString } = registry;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ADDITIONAL_PROPERTY_FLAG,
|
|
3
|
+
buttonId,
|
|
3
4
|
FormContextType,
|
|
4
5
|
RJSFSchema,
|
|
5
6
|
StrictRJSFSchema,
|
|
@@ -17,7 +18,7 @@ import Label from './FieldTemplate/Label';
|
|
|
17
18
|
export default function WrapIfAdditionalTemplate<
|
|
18
19
|
T = any,
|
|
19
20
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
20
|
-
F extends FormContextType = any
|
|
21
|
+
F extends FormContextType = any,
|
|
21
22
|
>(props: WrapIfAdditionalTemplateProps<T, S, F>) {
|
|
22
23
|
const {
|
|
23
24
|
id,
|
|
@@ -30,6 +31,8 @@ export default function WrapIfAdditionalTemplate<
|
|
|
30
31
|
readonly,
|
|
31
32
|
required,
|
|
32
33
|
schema,
|
|
34
|
+
hideError,
|
|
35
|
+
rawErrors,
|
|
33
36
|
children,
|
|
34
37
|
uiSchema,
|
|
35
38
|
registry,
|
|
@@ -40,16 +43,22 @@ export default function WrapIfAdditionalTemplate<
|
|
|
40
43
|
const keyLabel = translateString(TranslatableString.KeyLabel, [label]);
|
|
41
44
|
const additional = ADDITIONAL_PROPERTY_FLAG in schema;
|
|
42
45
|
|
|
46
|
+
const classNamesList = ['form-group', classNames];
|
|
47
|
+
if (!hideError && rawErrors && rawErrors.length > 0) {
|
|
48
|
+
classNamesList.push('has-error has-danger');
|
|
49
|
+
}
|
|
50
|
+
const uiClassNames = classNamesList.join(' ').trim();
|
|
51
|
+
|
|
43
52
|
if (!additional) {
|
|
44
53
|
return (
|
|
45
|
-
<div className={
|
|
54
|
+
<div className={uiClassNames} style={style}>
|
|
46
55
|
{children}
|
|
47
56
|
</div>
|
|
48
57
|
);
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
return (
|
|
52
|
-
<div className={
|
|
61
|
+
<div className={uiClassNames} style={style}>
|
|
53
62
|
<div className='row'>
|
|
54
63
|
<div className='col-xs-5 form-additional'>
|
|
55
64
|
<div className='form-group'>
|
|
@@ -66,7 +75,8 @@ export default function WrapIfAdditionalTemplate<
|
|
|
66
75
|
<div className='form-additional form-group col-xs-5'>{children}</div>
|
|
67
76
|
<div className='col-xs-2'>
|
|
68
77
|
<RemoveButton
|
|
69
|
-
|
|
78
|
+
id={buttonId<T>(id, 'remove')}
|
|
79
|
+
className='rjsf-object-property-remove btn-block'
|
|
70
80
|
style={{ border: '0' }}
|
|
71
81
|
disabled={disabled || readonly}
|
|
72
82
|
onClick={onDropPropertyClick(label)}
|
|
@@ -2,6 +2,7 @@ import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@r
|
|
|
2
2
|
|
|
3
3
|
import ArrayFieldDescriptionTemplate from './ArrayFieldDescriptionTemplate';
|
|
4
4
|
import ArrayFieldItemTemplate from './ArrayFieldItemTemplate';
|
|
5
|
+
import ArrayFieldItemButtonsTemplate from './ArrayFieldItemButtonsTemplate';
|
|
5
6
|
import ArrayFieldTemplate from './ArrayFieldTemplate';
|
|
6
7
|
import ArrayFieldTitleTemplate from './ArrayFieldTitleTemplate';
|
|
7
8
|
import BaseInputTemplate from './BaseInputTemplate';
|
|
@@ -11,6 +12,7 @@ import ErrorList from './ErrorList';
|
|
|
11
12
|
import FieldTemplate from './FieldTemplate';
|
|
12
13
|
import FieldErrorTemplate from './FieldErrorTemplate';
|
|
13
14
|
import FieldHelpTemplate from './FieldHelpTemplate';
|
|
15
|
+
import GridTemplate from './GridTemplate';
|
|
14
16
|
import ObjectFieldTemplate from './ObjectFieldTemplate';
|
|
15
17
|
import TitleField from './TitleField';
|
|
16
18
|
import UnsupportedField from './UnsupportedField';
|
|
@@ -24,6 +26,7 @@ function templates<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
24
26
|
return {
|
|
25
27
|
ArrayFieldDescriptionTemplate,
|
|
26
28
|
ArrayFieldItemTemplate,
|
|
29
|
+
ArrayFieldItemButtonsTemplate,
|
|
27
30
|
ArrayFieldTemplate,
|
|
28
31
|
ArrayFieldTitleTemplate,
|
|
29
32
|
ButtonTemplates: ButtonTemplates<T, S, F>(),
|
|
@@ -33,6 +36,7 @@ function templates<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
33
36
|
FieldTemplate,
|
|
34
37
|
FieldErrorTemplate,
|
|
35
38
|
FieldHelpTemplate,
|
|
39
|
+
GridTemplate,
|
|
36
40
|
ObjectFieldTemplate,
|
|
37
41
|
TitleFieldTemplate: TitleField,
|
|
38
42
|
UnsupportedFieldTemplate: UnsupportedField,
|