@springmicro/forms 0.7.0 → 0.7.1
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/.eslintrc.cjs +22 -22
- package/README.md +11 -11
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/index.umd.cjs +0 -0
- package/package.json +3 -3
- package/src/builder/bottom-drawer.tsx +429 -429
- package/src/builder/form-builder.tsx +256 -256
- package/src/builder/modal.tsx +39 -39
- package/src/builder/nodes/node-base.tsx +94 -94
- package/src/builder/nodes/node-child-helpers.tsx +273 -273
- package/src/builder/nodes/node-parent.tsx +187 -187
- package/src/builder/nodes/node-types/array-node.tsx +134 -134
- package/src/builder/nodes/node-types/date-node.tsx +60 -60
- package/src/builder/nodes/node-types/file-node.tsx +67 -67
- package/src/builder/nodes/node-types/integer-node.tsx +60 -60
- package/src/builder/nodes/node-types/object-node.tsx +67 -67
- package/src/builder/nodes/node-types/text-node.tsx +66 -66
- package/src/fields/ArrayField.tsx +875 -875
- package/src/fields/BooleanField.tsx +110 -110
- package/src/fields/MultiSchemaField.tsx +236 -236
- package/src/fields/NullField.tsx +22 -22
- package/src/fields/NumberField.tsx +87 -87
- package/src/fields/ObjectField.tsx +338 -338
- package/src/fields/SchemaField.tsx +402 -402
- package/src/fields/StringField.tsx +67 -67
- package/src/fields/index.ts +24 -24
- package/src/index.tsx +26 -26
- package/src/interfaces/MessagesProps.interface.ts +5 -5
- package/src/interfaces/Option.interface.ts +4 -4
- package/src/styles/select.styles.ts +28 -28
- package/src/templates/ArrayFieldDescriptionTemplate.tsx +42 -42
- package/src/templates/ArrayFieldItemTemplate.tsx +78 -78
- package/src/templates/ArrayFieldTemplate.tsx +90 -90
- package/src/templates/ArrayFieldTitleTemplate.tsx +44 -44
- package/src/templates/BaseInputTemplate.tsx +94 -94
- package/src/templates/ButtonTemplates/AddButton.tsx +29 -29
- package/src/templates/ButtonTemplates/IconButton.tsx +49 -49
- package/src/templates/ButtonTemplates/SubmitButton.tsx +29 -29
- package/src/templates/ButtonTemplates/index.ts +16 -16
- package/src/templates/DescriptionField.tsx +29 -29
- package/src/templates/ErrorList.tsx +25 -25
- package/src/templates/FieldTemplate/FieldTemplate.tsx +39 -39
- package/src/templates/FieldTemplate/Label.tsx +29 -29
- package/src/templates/FieldTemplate/WrapIfAdditional.tsx +85 -85
- package/src/templates/FieldTemplate/index.ts +3 -3
- package/src/templates/ObjectFieldTemplate.tsx +79 -79
- package/src/templates/TitleField.tsx +20 -20
- package/src/templates/UnsupportedField.tsx +29 -29
- package/src/templates/index.ts +32 -32
- package/src/types/Message.type.ts +6 -6
- package/src/types/RawMessage.type.ts +15 -15
- package/src/types/form-builder.ts +135 -135
- package/src/types/utils.type.ts +1 -1
- package/src/utils/form-builder.ts +424 -424
- package/src/utils/processSelectValue.ts +50 -50
- package/src/widgets/AltDateTimeWidget.tsx +17 -17
- package/src/widgets/AltDateWidget.tsx +216 -216
- package/src/widgets/CheckboxWidget.tsx +80 -80
- package/src/widgets/CheckboxesWidget.tsx +74 -74
- package/src/widgets/ColorWidget.tsx +26 -26
- package/src/widgets/DateTimeWidget.tsx +28 -28
- package/src/widgets/DateWidget.tsx +36 -36
- package/src/widgets/EmailWidget.tsx +19 -19
- package/src/widgets/FileWidget.tsx +144 -144
- package/src/widgets/HiddenWidget.tsx +22 -22
- package/src/widgets/PasswordWidget.tsx +20 -20
- package/src/widgets/RadioWidget.tsx +87 -87
- package/src/widgets/RangeWidget.tsx +24 -24
- package/src/widgets/SelectWidget.tsx +99 -99
- package/src/widgets/TextWidget.tsx +19 -19
- package/src/widgets/TextareaWidget.tsx +64 -64
- package/src/widgets/URLWidget.tsx +19 -19
- package/src/widgets/UpDownWidget.tsx +20 -20
- package/src/widgets/index.ts +43 -43
- package/tsconfig.json +24 -24
- package/tsconfig.node.json +10 -10
- package/vite.config.ts +25 -25
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { TemplatesType } from "@rjsf/utils";
|
|
2
|
-
|
|
3
|
-
import SubmitButton from "./SubmitButton";
|
|
4
|
-
import AddButton from "./AddButton";
|
|
5
|
-
import { RemoveButton, MoveDownButton, MoveUpButton } from "./IconButton";
|
|
6
|
-
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
const buttonTemplates: TemplatesType["ButtonTemplates"] = {
|
|
9
|
-
SubmitButton,
|
|
10
|
-
AddButton,
|
|
11
|
-
MoveDownButton,
|
|
12
|
-
MoveUpButton,
|
|
13
|
-
RemoveButton,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default buttonTemplates;
|
|
1
|
+
import { TemplatesType } from "@rjsf/utils";
|
|
2
|
+
|
|
3
|
+
import SubmitButton from "./SubmitButton";
|
|
4
|
+
import AddButton from "./AddButton";
|
|
5
|
+
import { RemoveButton, MoveDownButton, MoveUpButton } from "./IconButton";
|
|
6
|
+
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const buttonTemplates: TemplatesType["ButtonTemplates"] = {
|
|
9
|
+
SubmitButton,
|
|
10
|
+
AddButton,
|
|
11
|
+
MoveDownButton,
|
|
12
|
+
MoveUpButton,
|
|
13
|
+
RemoveButton,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default buttonTemplates;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { DescriptionFieldProps, GenericObjectType } from "@rjsf/utils";
|
|
3
|
-
|
|
4
|
-
/** The `DescriptionField` is the template to use to render the description of a field
|
|
5
|
-
*
|
|
6
|
-
* @param props - The `DescriptionFieldProps` for this component
|
|
7
|
-
*/
|
|
8
|
-
export default function DescriptionField<
|
|
9
|
-
T = any,
|
|
10
|
-
F extends GenericObjectType = any
|
|
11
|
-
>(props: DescriptionFieldProps<T, F>) {
|
|
12
|
-
const { id, description } = props;
|
|
13
|
-
if (!description) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
if (typeof description === "string") {
|
|
17
|
-
return (
|
|
18
|
-
<p id={id} className="field-description">
|
|
19
|
-
{description}
|
|
20
|
-
</p>
|
|
21
|
-
);
|
|
22
|
-
} else {
|
|
23
|
-
return (
|
|
24
|
-
<div id={id} className="field-description">
|
|
25
|
-
{description}
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DescriptionFieldProps, GenericObjectType } from "@rjsf/utils";
|
|
3
|
+
|
|
4
|
+
/** The `DescriptionField` is the template to use to render the description of a field
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `DescriptionFieldProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function DescriptionField<
|
|
9
|
+
T = any,
|
|
10
|
+
F extends GenericObjectType = any
|
|
11
|
+
>(props: DescriptionFieldProps<T, F>) {
|
|
12
|
+
const { id, description } = props;
|
|
13
|
+
if (!description) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (typeof description === "string") {
|
|
17
|
+
return (
|
|
18
|
+
<p id={id} className="field-description">
|
|
19
|
+
{description}
|
|
20
|
+
</p>
|
|
21
|
+
);
|
|
22
|
+
} else {
|
|
23
|
+
return (
|
|
24
|
+
<div id={id} className="field-description">
|
|
25
|
+
{description}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ErrorListProps, RJSFValidationError } from "@rjsf/utils";
|
|
3
|
-
|
|
4
|
-
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
5
|
-
*
|
|
6
|
-
* @param props - The `ErrorListProps` for this component
|
|
7
|
-
*/
|
|
8
|
-
export default function ErrorList<T = any>({ errors }: ErrorListProps<T>) {
|
|
9
|
-
return (
|
|
10
|
-
<div className="panel panel-danger errors">
|
|
11
|
-
<div className="panel-heading">
|
|
12
|
-
<h3 className="panel-title">Errors</h3>
|
|
13
|
-
</div>
|
|
14
|
-
<ul className="list-group">
|
|
15
|
-
{errors.map((error: RJSFValidationError, i: number) => {
|
|
16
|
-
return (
|
|
17
|
-
<li key={i} className="list-group-item text-danger">
|
|
18
|
-
{error.stack}
|
|
19
|
-
</li>
|
|
20
|
-
);
|
|
21
|
-
})}
|
|
22
|
-
</ul>
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ErrorListProps, RJSFValidationError } from "@rjsf/utils";
|
|
3
|
+
|
|
4
|
+
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `ErrorListProps` for this component
|
|
7
|
+
*/
|
|
8
|
+
export default function ErrorList<T = any>({ errors }: ErrorListProps<T>) {
|
|
9
|
+
return (
|
|
10
|
+
<div className="panel panel-danger errors">
|
|
11
|
+
<div className="panel-heading">
|
|
12
|
+
<h3 className="panel-title">Errors</h3>
|
|
13
|
+
</div>
|
|
14
|
+
<ul className="list-group">
|
|
15
|
+
{errors.map((error: RJSFValidationError, i: number) => {
|
|
16
|
+
return (
|
|
17
|
+
<li key={i} className="list-group-item text-danger">
|
|
18
|
+
{error.stack}
|
|
19
|
+
</li>
|
|
20
|
+
);
|
|
21
|
+
})}
|
|
22
|
+
</ul>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { FieldTemplateProps, GenericObjectType } from "@rjsf/utils";
|
|
3
|
-
|
|
4
|
-
import Label from "./Label";
|
|
5
|
-
import WrapIfAdditional from "./WrapIfAdditional";
|
|
6
|
-
|
|
7
|
-
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
8
|
-
* content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
|
|
9
|
-
*
|
|
10
|
-
* @param props - The `FieldTemplateProps` for this component
|
|
11
|
-
*/
|
|
12
|
-
export default function FieldTemplate<
|
|
13
|
-
T = any,
|
|
14
|
-
F extends GenericObjectType = any
|
|
15
|
-
>(props: FieldTemplateProps<T, F>) {
|
|
16
|
-
const {
|
|
17
|
-
id,
|
|
18
|
-
label,
|
|
19
|
-
children,
|
|
20
|
-
errors,
|
|
21
|
-
help,
|
|
22
|
-
description,
|
|
23
|
-
hidden,
|
|
24
|
-
required,
|
|
25
|
-
displayLabel,
|
|
26
|
-
} = props;
|
|
27
|
-
if (hidden) {
|
|
28
|
-
return <div className="hidden">{children}</div>;
|
|
29
|
-
}
|
|
30
|
-
return (
|
|
31
|
-
<WrapIfAdditional<T, F> {...props}>
|
|
32
|
-
{displayLabel && <Label label={label} required={required} id={id} />}
|
|
33
|
-
{displayLabel && description ? description : null}
|
|
34
|
-
{children}
|
|
35
|
-
{errors}
|
|
36
|
-
{help}
|
|
37
|
-
</WrapIfAdditional>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FieldTemplateProps, GenericObjectType } from "@rjsf/utils";
|
|
3
|
+
|
|
4
|
+
import Label from "./Label";
|
|
5
|
+
import WrapIfAdditional from "./WrapIfAdditional";
|
|
6
|
+
|
|
7
|
+
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
8
|
+
* content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
|
|
9
|
+
*
|
|
10
|
+
* @param props - The `FieldTemplateProps` for this component
|
|
11
|
+
*/
|
|
12
|
+
export default function FieldTemplate<
|
|
13
|
+
T = any,
|
|
14
|
+
F extends GenericObjectType = any
|
|
15
|
+
>(props: FieldTemplateProps<T, F>) {
|
|
16
|
+
const {
|
|
17
|
+
id,
|
|
18
|
+
label,
|
|
19
|
+
children,
|
|
20
|
+
errors,
|
|
21
|
+
help,
|
|
22
|
+
description,
|
|
23
|
+
hidden,
|
|
24
|
+
required,
|
|
25
|
+
displayLabel,
|
|
26
|
+
} = props;
|
|
27
|
+
if (hidden) {
|
|
28
|
+
return <div className="hidden">{children}</div>;
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<WrapIfAdditional<T, F> {...props}>
|
|
32
|
+
{displayLabel && <Label label={label} required={required} id={id} />}
|
|
33
|
+
{displayLabel && description ? description : null}
|
|
34
|
+
{children}
|
|
35
|
+
{errors}
|
|
36
|
+
{help}
|
|
37
|
+
</WrapIfAdditional>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
const REQUIRED_FIELD_SYMBOL = "*";
|
|
4
|
-
|
|
5
|
-
export type LabelProps = {
|
|
6
|
-
/** The label for the field */
|
|
7
|
-
label?: string;
|
|
8
|
-
/** A boolean value stating if the field is required */
|
|
9
|
-
required?: boolean;
|
|
10
|
-
/** The id of the input field being labeled */
|
|
11
|
-
id?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/** Renders a label for a field
|
|
15
|
-
*
|
|
16
|
-
* @param props - The `LabelProps` for this component
|
|
17
|
-
*/
|
|
18
|
-
export default function Label(props: LabelProps) {
|
|
19
|
-
const { label, required, id } = props;
|
|
20
|
-
if (!label) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return (
|
|
24
|
-
<label className="justify-start gap-1 label" htmlFor={id}>
|
|
25
|
-
<span className="label-text">{label}</span>
|
|
26
|
-
{required && <span className="required">{REQUIRED_FIELD_SYMBOL}</span>}
|
|
27
|
-
</label>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
const REQUIRED_FIELD_SYMBOL = "*";
|
|
4
|
+
|
|
5
|
+
export type LabelProps = {
|
|
6
|
+
/** The label for the field */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** A boolean value stating if the field is required */
|
|
9
|
+
required?: boolean;
|
|
10
|
+
/** The id of the input field being labeled */
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Renders a label for a field
|
|
15
|
+
*
|
|
16
|
+
* @param props - The `LabelProps` for this component
|
|
17
|
+
*/
|
|
18
|
+
export default function Label(props: LabelProps) {
|
|
19
|
+
const { label, required, id } = props;
|
|
20
|
+
if (!label) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return (
|
|
24
|
+
<label className="justify-start gap-1 label" htmlFor={id}>
|
|
25
|
+
<span className="label-text">{label}</span>
|
|
26
|
+
{required && <span className="required">{REQUIRED_FIELD_SYMBOL}</span>}
|
|
27
|
+
</label>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { FieldTemplateProps, GenericObjectType } from "@rjsf/utils";
|
|
3
|
-
import { ADDITIONAL_PROPERTY_FLAG } from "@rjsf/utils";
|
|
4
|
-
|
|
5
|
-
import Label from "./Label";
|
|
6
|
-
|
|
7
|
-
/** The properties that are passed to a WrapIfAdditionalTemplate implementation */
|
|
8
|
-
export type WrapIfAdditionalProps<
|
|
9
|
-
T = any,
|
|
10
|
-
F extends GenericObjectType = any
|
|
11
|
-
> = {
|
|
12
|
-
children: React.ReactNode;
|
|
13
|
-
} & Pick<
|
|
14
|
-
FieldTemplateProps<T, F>,
|
|
15
|
-
| "classNames"
|
|
16
|
-
| "disabled"
|
|
17
|
-
| "id"
|
|
18
|
-
| "label"
|
|
19
|
-
| "onDropPropertyClick"
|
|
20
|
-
| "onKeyChange"
|
|
21
|
-
| "readonly"
|
|
22
|
-
| "required"
|
|
23
|
-
| "schema"
|
|
24
|
-
| "registry"
|
|
25
|
-
>;
|
|
26
|
-
|
|
27
|
-
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
28
|
-
* part of an `additionalProperties` part of a schema.
|
|
29
|
-
*
|
|
30
|
-
* @param props - The `WrapIfAdditionalProps` for this component
|
|
31
|
-
*/
|
|
32
|
-
export default function WrapIfAdditional<
|
|
33
|
-
T = any,
|
|
34
|
-
F extends GenericObjectType = any
|
|
35
|
-
>(props: WrapIfAdditionalProps<T, F>) {
|
|
36
|
-
const {
|
|
37
|
-
id,
|
|
38
|
-
classNames,
|
|
39
|
-
disabled,
|
|
40
|
-
label,
|
|
41
|
-
onKeyChange,
|
|
42
|
-
onDropPropertyClick,
|
|
43
|
-
readonly,
|
|
44
|
-
required,
|
|
45
|
-
schema,
|
|
46
|
-
children,
|
|
47
|
-
registry,
|
|
48
|
-
} = props;
|
|
49
|
-
const { RemoveButton } = registry.templates.ButtonTemplates;
|
|
50
|
-
const keyLabel = `${label} Key`; // i18n ?
|
|
51
|
-
const additional = ADDITIONAL_PROPERTY_FLAG in schema;
|
|
52
|
-
|
|
53
|
-
if (!additional) {
|
|
54
|
-
return <div className={classNames}>{children}</div>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<div className={classNames}>
|
|
59
|
-
<div className="row">
|
|
60
|
-
<div className="form-additional">
|
|
61
|
-
<div className="form-control">
|
|
62
|
-
<Label label={keyLabel} required={required} id={`${id}-key`} />
|
|
63
|
-
<input
|
|
64
|
-
className="form-control"
|
|
65
|
-
type="text"
|
|
66
|
-
id={`${id}-key`}
|
|
67
|
-
onBlur={(event) => onKeyChange(event.target.value)}
|
|
68
|
-
defaultValue={label}
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
<div className="form-additional form-control">{children}</div>
|
|
73
|
-
<div className="col-xs-2">
|
|
74
|
-
<RemoveButton
|
|
75
|
-
registry={registry}
|
|
76
|
-
className="array-item-remove btn-block"
|
|
77
|
-
style={{ border: "0" }}
|
|
78
|
-
disabled={disabled || readonly}
|
|
79
|
-
onClick={onDropPropertyClick(label)}
|
|
80
|
-
/>
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FieldTemplateProps, GenericObjectType } from "@rjsf/utils";
|
|
3
|
+
import { ADDITIONAL_PROPERTY_FLAG } from "@rjsf/utils";
|
|
4
|
+
|
|
5
|
+
import Label from "./Label";
|
|
6
|
+
|
|
7
|
+
/** The properties that are passed to a WrapIfAdditionalTemplate implementation */
|
|
8
|
+
export type WrapIfAdditionalProps<
|
|
9
|
+
T = any,
|
|
10
|
+
F extends GenericObjectType = any
|
|
11
|
+
> = {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
} & Pick<
|
|
14
|
+
FieldTemplateProps<T, F>,
|
|
15
|
+
| "classNames"
|
|
16
|
+
| "disabled"
|
|
17
|
+
| "id"
|
|
18
|
+
| "label"
|
|
19
|
+
| "onDropPropertyClick"
|
|
20
|
+
| "onKeyChange"
|
|
21
|
+
| "readonly"
|
|
22
|
+
| "required"
|
|
23
|
+
| "schema"
|
|
24
|
+
| "registry"
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
28
|
+
* part of an `additionalProperties` part of a schema.
|
|
29
|
+
*
|
|
30
|
+
* @param props - The `WrapIfAdditionalProps` for this component
|
|
31
|
+
*/
|
|
32
|
+
export default function WrapIfAdditional<
|
|
33
|
+
T = any,
|
|
34
|
+
F extends GenericObjectType = any
|
|
35
|
+
>(props: WrapIfAdditionalProps<T, F>) {
|
|
36
|
+
const {
|
|
37
|
+
id,
|
|
38
|
+
classNames,
|
|
39
|
+
disabled,
|
|
40
|
+
label,
|
|
41
|
+
onKeyChange,
|
|
42
|
+
onDropPropertyClick,
|
|
43
|
+
readonly,
|
|
44
|
+
required,
|
|
45
|
+
schema,
|
|
46
|
+
children,
|
|
47
|
+
registry,
|
|
48
|
+
} = props;
|
|
49
|
+
const { RemoveButton } = registry.templates.ButtonTemplates;
|
|
50
|
+
const keyLabel = `${label} Key`; // i18n ?
|
|
51
|
+
const additional = ADDITIONAL_PROPERTY_FLAG in schema;
|
|
52
|
+
|
|
53
|
+
if (!additional) {
|
|
54
|
+
return <div className={classNames}>{children}</div>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className={classNames}>
|
|
59
|
+
<div className="row">
|
|
60
|
+
<div className="form-additional">
|
|
61
|
+
<div className="form-control">
|
|
62
|
+
<Label label={keyLabel} required={required} id={`${id}-key`} />
|
|
63
|
+
<input
|
|
64
|
+
className="form-control"
|
|
65
|
+
type="text"
|
|
66
|
+
id={`${id}-key`}
|
|
67
|
+
onBlur={(event) => onKeyChange(event.target.value)}
|
|
68
|
+
defaultValue={label}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
<div className="form-additional form-control">{children}</div>
|
|
73
|
+
<div className="col-xs-2">
|
|
74
|
+
<RemoveButton
|
|
75
|
+
registry={registry}
|
|
76
|
+
className="array-item-remove btn-block"
|
|
77
|
+
style={{ border: "0" }}
|
|
78
|
+
disabled={disabled || readonly}
|
|
79
|
+
onClick={onDropPropertyClick(label)}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import FieldTemplate from "./FieldTemplate";
|
|
2
|
-
|
|
3
|
-
export default FieldTemplate;
|
|
1
|
+
import FieldTemplate from "./FieldTemplate";
|
|
2
|
+
|
|
3
|
+
export default FieldTemplate;
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
GenericObjectType,
|
|
4
|
-
ObjectFieldTemplatePropertyType,
|
|
5
|
-
ObjectFieldTemplateProps,
|
|
6
|
-
} from "@rjsf/utils";
|
|
7
|
-
import { canExpand, getTemplate, getUiOptions } from "@rjsf/utils";
|
|
8
|
-
|
|
9
|
-
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
10
|
-
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
11
|
-
* the properties.
|
|
12
|
-
*
|
|
13
|
-
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
14
|
-
*/
|
|
15
|
-
export default function ObjectFieldTemplate<
|
|
16
|
-
T = any,
|
|
17
|
-
F extends GenericObjectType = any
|
|
18
|
-
>(props: ObjectFieldTemplateProps<T, F>) {
|
|
19
|
-
const {
|
|
20
|
-
description,
|
|
21
|
-
disabled,
|
|
22
|
-
formData,
|
|
23
|
-
idSchema,
|
|
24
|
-
onAddClick,
|
|
25
|
-
properties,
|
|
26
|
-
readonly,
|
|
27
|
-
registry,
|
|
28
|
-
required,
|
|
29
|
-
schema,
|
|
30
|
-
title,
|
|
31
|
-
uiSchema,
|
|
32
|
-
} = props;
|
|
33
|
-
const options = getUiOptions<T, F>(uiSchema);
|
|
34
|
-
const TitleFieldTemplate = getTemplate<"TitleFieldTemplate", T, F>(
|
|
35
|
-
"TitleFieldTemplate",
|
|
36
|
-
registry,
|
|
37
|
-
options
|
|
38
|
-
);
|
|
39
|
-
const DescriptionFieldTemplate = getTemplate<
|
|
40
|
-
"DescriptionFieldTemplate",
|
|
41
|
-
T,
|
|
42
|
-
F
|
|
43
|
-
>("DescriptionFieldTemplate", registry, options);
|
|
44
|
-
// Button templates are not overridden in the uiSchema
|
|
45
|
-
const {
|
|
46
|
-
ButtonTemplates: { AddButton },
|
|
47
|
-
} = registry.templates;
|
|
48
|
-
return (
|
|
49
|
-
<fieldset id={idSchema.$id}>
|
|
50
|
-
{(options.title || title) && (
|
|
51
|
-
<TitleFieldTemplate
|
|
52
|
-
schema={schema}
|
|
53
|
-
id={`${idSchema.$id}__title`}
|
|
54
|
-
title={options.title || title}
|
|
55
|
-
required={required}
|
|
56
|
-
uiSchema={uiSchema}
|
|
57
|
-
registry={registry}
|
|
58
|
-
/>
|
|
59
|
-
)}
|
|
60
|
-
{(options.description || description) && (
|
|
61
|
-
<DescriptionFieldTemplate
|
|
62
|
-
schema={schema}
|
|
63
|
-
id={`${idSchema.$id}__description`}
|
|
64
|
-
description={options.description || description!}
|
|
65
|
-
registry={registry}
|
|
66
|
-
/>
|
|
67
|
-
)}
|
|
68
|
-
{properties.map((prop: ObjectFieldTemplatePropertyType) => prop.content)}
|
|
69
|
-
{canExpand(schema, uiSchema, formData) && (
|
|
70
|
-
<AddButton
|
|
71
|
-
registry={registry}
|
|
72
|
-
className="object-property-expand"
|
|
73
|
-
onClick={onAddClick(schema)}
|
|
74
|
-
disabled={disabled || readonly}
|
|
75
|
-
/>
|
|
76
|
-
)}
|
|
77
|
-
</fieldset>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
GenericObjectType,
|
|
4
|
+
ObjectFieldTemplatePropertyType,
|
|
5
|
+
ObjectFieldTemplateProps,
|
|
6
|
+
} from "@rjsf/utils";
|
|
7
|
+
import { canExpand, getTemplate, getUiOptions } from "@rjsf/utils";
|
|
8
|
+
|
|
9
|
+
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
10
|
+
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
11
|
+
* the properties.
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
14
|
+
*/
|
|
15
|
+
export default function ObjectFieldTemplate<
|
|
16
|
+
T = any,
|
|
17
|
+
F extends GenericObjectType = any
|
|
18
|
+
>(props: ObjectFieldTemplateProps<T, F>) {
|
|
19
|
+
const {
|
|
20
|
+
description,
|
|
21
|
+
disabled,
|
|
22
|
+
formData,
|
|
23
|
+
idSchema,
|
|
24
|
+
onAddClick,
|
|
25
|
+
properties,
|
|
26
|
+
readonly,
|
|
27
|
+
registry,
|
|
28
|
+
required,
|
|
29
|
+
schema,
|
|
30
|
+
title,
|
|
31
|
+
uiSchema,
|
|
32
|
+
} = props;
|
|
33
|
+
const options = getUiOptions<T, F>(uiSchema);
|
|
34
|
+
const TitleFieldTemplate = getTemplate<"TitleFieldTemplate", T, F>(
|
|
35
|
+
"TitleFieldTemplate",
|
|
36
|
+
registry,
|
|
37
|
+
options
|
|
38
|
+
);
|
|
39
|
+
const DescriptionFieldTemplate = getTemplate<
|
|
40
|
+
"DescriptionFieldTemplate",
|
|
41
|
+
T,
|
|
42
|
+
F
|
|
43
|
+
>("DescriptionFieldTemplate", registry, options);
|
|
44
|
+
// Button templates are not overridden in the uiSchema
|
|
45
|
+
const {
|
|
46
|
+
ButtonTemplates: { AddButton },
|
|
47
|
+
} = registry.templates;
|
|
48
|
+
return (
|
|
49
|
+
<fieldset id={idSchema.$id}>
|
|
50
|
+
{(options.title || title) && (
|
|
51
|
+
<TitleFieldTemplate
|
|
52
|
+
schema={schema}
|
|
53
|
+
id={`${idSchema.$id}__title`}
|
|
54
|
+
title={options.title || title}
|
|
55
|
+
required={required}
|
|
56
|
+
uiSchema={uiSchema}
|
|
57
|
+
registry={registry}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
{(options.description || description) && (
|
|
61
|
+
<DescriptionFieldTemplate
|
|
62
|
+
schema={schema}
|
|
63
|
+
id={`${idSchema.$id}__description`}
|
|
64
|
+
description={options.description || description!}
|
|
65
|
+
registry={registry}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
{properties.map((prop: ObjectFieldTemplatePropertyType) => prop.content)}
|
|
69
|
+
{canExpand(schema, uiSchema, formData) && (
|
|
70
|
+
<AddButton
|
|
71
|
+
registry={registry}
|
|
72
|
+
className="object-property-expand"
|
|
73
|
+
onClick={onAddClick(schema)}
|
|
74
|
+
disabled={disabled || readonly}
|
|
75
|
+
/>
|
|
76
|
+
)}
|
|
77
|
+
</fieldset>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { GenericObjectType, TitleFieldProps } from "@rjsf/utils";
|
|
3
|
-
|
|
4
|
-
const REQUIRED_FIELD_SYMBOL = "*";
|
|
5
|
-
|
|
6
|
-
/** The `TitleField` is the template to use to render the title of a field
|
|
7
|
-
*
|
|
8
|
-
* @param props - The `TitleFieldProps` for this component
|
|
9
|
-
*/
|
|
10
|
-
export default function TitleField<T = any, F extends GenericObjectType = any>(
|
|
11
|
-
props: TitleFieldProps<T, F>
|
|
12
|
-
) {
|
|
13
|
-
const { id, title, required } = props;
|
|
14
|
-
return (
|
|
15
|
-
<legend id={id}>
|
|
16
|
-
{title}
|
|
17
|
-
{required && <span className="required">{REQUIRED_FIELD_SYMBOL}</span>}
|
|
18
|
-
</legend>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { GenericObjectType, TitleFieldProps } from "@rjsf/utils";
|
|
3
|
+
|
|
4
|
+
const REQUIRED_FIELD_SYMBOL = "*";
|
|
5
|
+
|
|
6
|
+
/** The `TitleField` is the template to use to render the title of a field
|
|
7
|
+
*
|
|
8
|
+
* @param props - The `TitleFieldProps` for this component
|
|
9
|
+
*/
|
|
10
|
+
export default function TitleField<T = any, F extends GenericObjectType = any>(
|
|
11
|
+
props: TitleFieldProps<T, F>
|
|
12
|
+
) {
|
|
13
|
+
const { id, title, required } = props;
|
|
14
|
+
return (
|
|
15
|
+
<legend id={id}>
|
|
16
|
+
{title}
|
|
17
|
+
{required && <span className="required">{REQUIRED_FIELD_SYMBOL}</span>}
|
|
18
|
+
</legend>
|
|
19
|
+
);
|
|
20
|
+
}
|