@rjsf/react-bootstrap 6.0.0-beta.2 → 6.0.0-beta.21
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/README.md +4 -2
- package/dist/{index.js → index.cjs} +142 -63
- package/dist/index.cjs.map +7 -0
- package/dist/react-bootstrap.esm.js +141 -62
- package/dist/react-bootstrap.esm.js.map +4 -4
- package/dist/react-bootstrap.umd.js +89 -21
- package/lib/AddButton/AddButton.js +1 -1
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +3 -3
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +2 -2
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +2 -2
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/IconButton/IconButton.d.ts +6 -5
- package/lib/IconButton/IconButton.js +1 -1
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +2 -0
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +6 -0
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -0
- package/lib/MultiSchemaFieldTemplate/index.d.ts +2 -0
- package/lib/MultiSchemaFieldTemplate/index.js +3 -0
- package/lib/MultiSchemaFieldTemplate/index.js.map +1 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +3 -2
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +10 -0
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +22 -0
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -0
- package/lib/OptionalDataControlsTemplate/index.d.ts +2 -0
- package/lib/OptionalDataControlsTemplate/index.js +3 -0
- package/lib/OptionalDataControlsTemplate/index.js.map +1 -0
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/Templates/Templates.js +4 -0
- package/lib/Templates/Templates.js.map +1 -1
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
- package/lib/TitleField/TitleField.d.ts +1 -1
- package/lib/TitleField/TitleField.js +9 -2
- package/lib/TitleField/TitleField.js.map +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -16
- package/src/AddButton/AddButton.tsx +1 -1
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +24 -10
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +3 -3
- package/src/CheckboxWidget/CheckboxWidget.tsx +2 -2
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +1 -1
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +2 -2
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -2
- package/src/IconButton/IconButton.tsx +12 -6
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +15 -0
- package/src/MultiSchemaFieldTemplate/index.ts +2 -0
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +8 -4
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +47 -0
- package/src/OptionalDataControlsTemplate/index.ts +2 -0
- package/src/RadioWidget/RadioWidget.tsx +1 -1
- package/src/SelectWidget/SelectWidget.tsx +1 -1
- package/src/Templates/Templates.ts +4 -0
- package/src/TextareaWidget/TextareaWidget.tsx +1 -1
- package/src/TitleField/TitleField.tsx +19 -2
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +1 -1
- package/dist/index.js.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/react-bootstrap",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.21",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -9,27 +9,27 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./lib/index.d.ts",
|
|
12
|
-
"require": "./dist/index.
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
13
|
"import": "./lib/index.js"
|
|
14
14
|
},
|
|
15
15
|
"./lib": {
|
|
16
16
|
"types": "./lib/index.d.ts",
|
|
17
|
-
"require": "./dist/index.
|
|
17
|
+
"require": "./dist/index.cjs",
|
|
18
18
|
"import": "./lib/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./lib/*.js": {
|
|
21
21
|
"types": "./lib/*.d.ts",
|
|
22
|
-
"require": "./dist/*.
|
|
22
|
+
"require": "./dist/*.cjs",
|
|
23
23
|
"import": "./lib/*.js"
|
|
24
24
|
},
|
|
25
25
|
"./dist": {
|
|
26
26
|
"types": "./lib/index.d.ts",
|
|
27
|
-
"require": "./dist/index.
|
|
27
|
+
"require": "./dist/index.cjs",
|
|
28
28
|
"import": "./lib/index.js"
|
|
29
29
|
},
|
|
30
|
-
"./dist/*.
|
|
30
|
+
"./dist/*.cjs": {
|
|
31
31
|
"types": "./lib/*.d.ts",
|
|
32
|
-
"require": "./dist/*.
|
|
32
|
+
"require": "./dist/*.cjs",
|
|
33
33
|
"import": "./lib/*.js"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
47
|
-
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.
|
|
47
|
+
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
|
|
48
48
|
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/react-bootstrap.esm.js --sourcemap --packages=external --format=esm",
|
|
49
49
|
"build:umd": "rollup dist/react-bootstrap.esm.js --format=umd --file=dist/react-bootstrap.umd.js --name=@rjsf/react-bootstrap",
|
|
50
50
|
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@rjsf/core": "^6.0.0-beta.
|
|
65
|
-
"@rjsf/utils": "^6.0.0-beta.
|
|
64
|
+
"@rjsf/core": "^6.0.0-beta.21",
|
|
65
|
+
"@rjsf/utils": "^6.0.0-beta.21",
|
|
66
66
|
"react": ">=18",
|
|
67
67
|
"react-bootstrap": "^2.x"
|
|
68
68
|
},
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"node": ">=20"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@rjsf/core": "^6.0.0-beta.
|
|
75
|
-
"@rjsf/snapshot-tests": "^6.0.0-beta.
|
|
76
|
-
"@rjsf/utils": "^6.0.0-beta.
|
|
77
|
-
"@rjsf/validator-ajv8": "^6.0.0-beta.
|
|
78
|
-
"eslint": "^8.
|
|
79
|
-
"react-bootstrap": "^2.10.
|
|
74
|
+
"@rjsf/core": "^6.0.0-beta.21",
|
|
75
|
+
"@rjsf/snapshot-tests": "^6.0.0-beta.21",
|
|
76
|
+
"@rjsf/utils": "^6.0.0-beta.21",
|
|
77
|
+
"@rjsf/validator-ajv8": "^6.0.0-beta.21",
|
|
78
|
+
"eslint": "^8.57.1",
|
|
79
|
+
"react-bootstrap": "^2.10.10"
|
|
80
80
|
},
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
@@ -10,10 +10,10 @@ export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
10
10
|
const { translateString } = registry;
|
|
11
11
|
return (
|
|
12
12
|
<Button
|
|
13
|
+
title={translateString(TranslatableString.AddItemButton)}
|
|
13
14
|
{...props}
|
|
14
15
|
style={{ width: '100%' }}
|
|
15
16
|
className={`ml-1 ${props.className}`}
|
|
16
|
-
title={translateString(TranslatableString.AddItemButton)}
|
|
17
17
|
>
|
|
18
18
|
<BsPlus />
|
|
19
19
|
</Button>
|
|
@@ -17,8 +17,20 @@ export default function ArrayFieldTemplate<
|
|
|
17
17
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
18
18
|
F extends FormContextType = any,
|
|
19
19
|
>(props: ArrayFieldTemplateProps<T, S, F>) {
|
|
20
|
-
const {
|
|
21
|
-
|
|
20
|
+
const {
|
|
21
|
+
canAdd,
|
|
22
|
+
disabled,
|
|
23
|
+
fieldPathId,
|
|
24
|
+
uiSchema,
|
|
25
|
+
items,
|
|
26
|
+
optionalDataControl,
|
|
27
|
+
onAddClick,
|
|
28
|
+
readonly,
|
|
29
|
+
registry,
|
|
30
|
+
required,
|
|
31
|
+
schema,
|
|
32
|
+
title,
|
|
33
|
+
} = props;
|
|
22
34
|
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
23
35
|
const ArrayFieldDescriptionTemplate = getTemplate<'ArrayFieldDescriptionTemplate', T, S, F>(
|
|
24
36
|
'ArrayFieldDescriptionTemplate',
|
|
@@ -35,6 +47,7 @@ export default function ArrayFieldTemplate<
|
|
|
35
47
|
registry,
|
|
36
48
|
uiOptions,
|
|
37
49
|
);
|
|
50
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
38
51
|
// Button templates are not overridden in the uiSchema
|
|
39
52
|
const {
|
|
40
53
|
ButtonTemplates: { AddButton },
|
|
@@ -44,32 +57,33 @@ export default function ArrayFieldTemplate<
|
|
|
44
57
|
<Row className='p-0 m-0'>
|
|
45
58
|
<Col className='p-0 m-0'>
|
|
46
59
|
<ArrayFieldTitleTemplate
|
|
47
|
-
|
|
60
|
+
fieldPathId={fieldPathId}
|
|
48
61
|
title={uiOptions.title || title}
|
|
49
62
|
schema={schema}
|
|
50
63
|
uiSchema={uiSchema}
|
|
51
64
|
required={required}
|
|
52
65
|
registry={registry}
|
|
66
|
+
optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
|
|
53
67
|
/>
|
|
54
68
|
<ArrayFieldDescriptionTemplate
|
|
55
|
-
|
|
69
|
+
fieldPathId={fieldPathId}
|
|
56
70
|
description={uiOptions.description || schema.description}
|
|
57
71
|
schema={schema}
|
|
58
72
|
uiSchema={uiSchema}
|
|
59
73
|
registry={registry}
|
|
60
74
|
/>
|
|
61
|
-
<Container fluid key={`array-item-list-${
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
<Container fluid key={`array-item-list-${fieldPathId.$id}`} className='p-0 m-0'>
|
|
76
|
+
{!showOptionalDataControlInTitle ? optionalDataControl : undefined}
|
|
77
|
+
{items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
|
|
78
|
+
<ArrayFieldItemTemplate key={key} {...itemProps} />
|
|
79
|
+
))}
|
|
66
80
|
{canAdd && (
|
|
67
81
|
<Container className=''>
|
|
68
82
|
<Row className='mt-2'>
|
|
69
83
|
<Col xs={9}></Col>
|
|
70
84
|
<Col xs={3} className='py-4 col-lg-3 col-3'>
|
|
71
85
|
<AddButton
|
|
72
|
-
id={buttonId
|
|
86
|
+
id={buttonId(fieldPathId, 'add')}
|
|
73
87
|
className='rjsf-array-item-add'
|
|
74
88
|
onClick={onAddClick}
|
|
75
89
|
disabled={disabled || readonly}
|
|
@@ -54,17 +54,17 @@ export default function BaseInputTemplate<
|
|
|
54
54
|
disabled={disabled}
|
|
55
55
|
readOnly={readonly}
|
|
56
56
|
className={rawErrors.length > 0 ? 'is-invalid' : ''}
|
|
57
|
-
list={schema.examples ? examplesId
|
|
57
|
+
list={schema.examples ? examplesId(id) : undefined}
|
|
58
58
|
{...inputProps}
|
|
59
59
|
value={value || value === 0 ? value : ''}
|
|
60
60
|
onChange={onChangeOverride || _onChange}
|
|
61
61
|
onBlur={_onBlur}
|
|
62
62
|
onFocus={_onFocus}
|
|
63
|
-
aria-describedby={ariaDescribedByIds
|
|
63
|
+
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
64
64
|
/>
|
|
65
65
|
{children}
|
|
66
66
|
{Array.isArray(schema.examples) ? (
|
|
67
|
-
<datalist id={examplesId
|
|
67
|
+
<datalist id={examplesId(id)}>
|
|
68
68
|
{(schema.examples as string[])
|
|
69
69
|
.concat(schema.default && !schema.examples.includes(schema.default) ? ([schema.default] as string[]) : [])
|
|
70
70
|
.map((example: any) => {
|
|
@@ -49,10 +49,10 @@ export default function CheckboxWidget<
|
|
|
49
49
|
|
|
50
50
|
const description = options.description || schema.description;
|
|
51
51
|
return (
|
|
52
|
-
<Form.Group className={disabled || readonly ? 'disabled' : ''} aria-describedby={ariaDescribedByIds
|
|
52
|
+
<Form.Group className={disabled || readonly ? 'disabled' : ''} aria-describedby={ariaDescribedByIds(id)}>
|
|
53
53
|
{!hideLabel && description && (
|
|
54
54
|
<DescriptionFieldTemplate
|
|
55
|
-
id={descriptionId
|
|
55
|
+
id={descriptionId(id)}
|
|
56
56
|
description={description}
|
|
57
57
|
schema={schema}
|
|
58
58
|
uiSchema={uiSchema}
|
|
@@ -10,11 +10,11 @@ export default function FieldErrorTemplate<
|
|
|
10
10
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
11
|
F extends FormContextType = any,
|
|
12
12
|
>(props: FieldErrorProps<T, S, F>) {
|
|
13
|
-
const { errors = [],
|
|
13
|
+
const { errors = [], fieldPathId } = props;
|
|
14
14
|
if (errors.length === 0) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
-
const id = errorId
|
|
17
|
+
const id = errorId(fieldPathId);
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
20
|
<ListGroup as='ul' id={id}>
|
|
@@ -10,11 +10,11 @@ export default function FieldHelpTemplate<
|
|
|
10
10
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
11
|
F extends FormContextType = any,
|
|
12
12
|
>(props: FieldHelpProps<T, S, F>) {
|
|
13
|
-
const {
|
|
13
|
+
const { fieldPathId, help, hasErrors } = props;
|
|
14
14
|
if (!help) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
-
const id = helpId
|
|
17
|
+
const id = helpId(fieldPathId);
|
|
18
18
|
return (
|
|
19
19
|
<Form.Text className={hasErrors ? 'text-danger' : 'text-muted'} id={id}>
|
|
20
20
|
{help}
|
|
@@ -5,8 +5,14 @@ import { IoIosRemove } from '@react-icons/all-files/io/IoIosRemove';
|
|
|
5
5
|
import { AiOutlineArrowUp } from '@react-icons/all-files/ai/AiOutlineArrowUp';
|
|
6
6
|
import { AiOutlineArrowDown } from '@react-icons/all-files/ai/AiOutlineArrowDown';
|
|
7
7
|
|
|
8
|
+
export type BootstrapIconButtonProps<
|
|
9
|
+
T = any,
|
|
10
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
|
+
F extends FormContextType = any,
|
|
12
|
+
> = IconButtonProps<T, S, F> & ButtonProps;
|
|
13
|
+
|
|
8
14
|
export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
9
|
-
props:
|
|
15
|
+
props: BootstrapIconButtonProps<T, S, F>,
|
|
10
16
|
) {
|
|
11
17
|
const { icon, iconType, className, uiSchema, registry, ...otherProps } = props;
|
|
12
18
|
return (
|
|
@@ -17,7 +23,7 @@ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
20
|
-
props:
|
|
26
|
+
props: BootstrapIconButtonProps<T, S, F>,
|
|
21
27
|
) {
|
|
22
28
|
const {
|
|
23
29
|
registry: { translateString },
|
|
@@ -26,7 +32,7 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
29
|
-
props:
|
|
35
|
+
props: BootstrapIconButtonProps<T, S, F>,
|
|
30
36
|
) {
|
|
31
37
|
const {
|
|
32
38
|
registry: { translateString },
|
|
@@ -37,7 +43,7 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
40
|
-
props:
|
|
46
|
+
props: BootstrapIconButtonProps<T, S, F>,
|
|
41
47
|
) {
|
|
42
48
|
const {
|
|
43
49
|
registry: { translateString },
|
|
@@ -46,7 +52,7 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
49
|
-
props:
|
|
55
|
+
props: BootstrapIconButtonProps<T, S, F>,
|
|
50
56
|
) {
|
|
51
57
|
const {
|
|
52
58
|
registry: { translateString },
|
|
@@ -54,8 +60,8 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
54
60
|
return (
|
|
55
61
|
<IconButton
|
|
56
62
|
title={translateString(TranslatableString.RemoveButton)}
|
|
57
|
-
{...props}
|
|
58
63
|
variant='danger'
|
|
64
|
+
{...props}
|
|
59
65
|
icon={<IoIosRemove />}
|
|
60
66
|
/>
|
|
61
67
|
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import Card from 'react-bootstrap/Card';
|
|
3
|
+
|
|
4
|
+
export default function MultiSchemaFieldTemplate<
|
|
5
|
+
T = any,
|
|
6
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
7
|
+
F extends FormContextType = any,
|
|
8
|
+
>({ selector, optionSchemaField }: MultiSchemaFieldTemplateProps<T, S, F>) {
|
|
9
|
+
return (
|
|
10
|
+
<Card style={{ marginBottom: '1rem' }}>
|
|
11
|
+
<Card.Body>{selector}</Card.Body>
|
|
12
|
+
<Card.Body>{optionSchemaField}</Card.Body>
|
|
13
|
+
</Card>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -25,9 +25,10 @@ export default function ObjectFieldTemplate<
|
|
|
25
25
|
properties,
|
|
26
26
|
required,
|
|
27
27
|
uiSchema,
|
|
28
|
-
|
|
28
|
+
fieldPathId,
|
|
29
29
|
schema,
|
|
30
30
|
formData,
|
|
31
|
+
optionalDataControl,
|
|
31
32
|
onAddClick,
|
|
32
33
|
disabled,
|
|
33
34
|
readonly,
|
|
@@ -40,6 +41,7 @@ export default function ObjectFieldTemplate<
|
|
|
40
41
|
registry,
|
|
41
42
|
uiOptions,
|
|
42
43
|
);
|
|
44
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
43
45
|
// Button templates are not overridden in the uiSchema
|
|
44
46
|
const {
|
|
45
47
|
ButtonTemplates: { AddButton },
|
|
@@ -48,17 +50,18 @@ export default function ObjectFieldTemplate<
|
|
|
48
50
|
<>
|
|
49
51
|
{title && (
|
|
50
52
|
<TitleFieldTemplate
|
|
51
|
-
id={titleId
|
|
53
|
+
id={titleId(fieldPathId)}
|
|
52
54
|
title={title}
|
|
53
55
|
required={required}
|
|
54
56
|
schema={schema}
|
|
55
57
|
uiSchema={uiSchema}
|
|
56
58
|
registry={registry}
|
|
59
|
+
optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
|
|
57
60
|
/>
|
|
58
61
|
)}
|
|
59
62
|
{description && (
|
|
60
63
|
<DescriptionFieldTemplate
|
|
61
|
-
id={descriptionId
|
|
64
|
+
id={descriptionId(fieldPathId)}
|
|
62
65
|
description={description}
|
|
63
66
|
schema={schema}
|
|
64
67
|
uiSchema={uiSchema}
|
|
@@ -66,6 +69,7 @@ export default function ObjectFieldTemplate<
|
|
|
66
69
|
/>
|
|
67
70
|
)}
|
|
68
71
|
<Container fluid className='p-0'>
|
|
72
|
+
{!showOptionalDataControlInTitle ? optionalDataControl : undefined}
|
|
69
73
|
{properties.map((element: any, index: number) => (
|
|
70
74
|
<Row key={index} style={{ marginBottom: '10px' }} className={element.hidden ? 'd-none' : undefined}>
|
|
71
75
|
<Col xs={12}> {element.content}</Col>
|
|
@@ -75,7 +79,7 @@ export default function ObjectFieldTemplate<
|
|
|
75
79
|
<Row>
|
|
76
80
|
<Col xs={{ offset: 9, span: 3 }} className='py-4'>
|
|
77
81
|
<AddButton
|
|
78
|
-
id={buttonId
|
|
82
|
+
id={buttonId(fieldPathId, 'add')}
|
|
79
83
|
onClick={onAddClick(schema)}
|
|
80
84
|
disabled={disabled || readonly}
|
|
81
85
|
className='rjsf-object-property-expand'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { BsPlus } from '@react-icons/all-files/bs/BsPlus';
|
|
3
|
+
|
|
4
|
+
import IconButton, { RemoveButton } from '../IconButton';
|
|
5
|
+
|
|
6
|
+
/** The OptionalDataControlsTemplate renders one of three different states. If
|
|
7
|
+
* there is an `onAddClick()` function, it renders the "Add" button. If there is
|
|
8
|
+
* an `onRemoveClick()` function, it renders the "Remove" button. Otherwise it
|
|
9
|
+
* renders the "No data found" section. All of them use the `label` as either
|
|
10
|
+
* the `title` of buttons or simply outputting it.
|
|
11
|
+
*
|
|
12
|
+
* @param props - The `OptionalDataControlsTemplateProps` for the template
|
|
13
|
+
*/
|
|
14
|
+
export default function OptionalDataControlsTemplate<
|
|
15
|
+
T = any,
|
|
16
|
+
S extends StrictRJSFSchema = RJSFSchema,
|
|
17
|
+
F extends FormContextType = any,
|
|
18
|
+
>(props: OptionalDataControlsTemplateProps<T, S, F>) {
|
|
19
|
+
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
20
|
+
if (onAddClick) {
|
|
21
|
+
return (
|
|
22
|
+
<IconButton
|
|
23
|
+
id={id}
|
|
24
|
+
registry={registry}
|
|
25
|
+
className='rjsf-add-optional-data'
|
|
26
|
+
icon={<BsPlus />}
|
|
27
|
+
onClick={onAddClick}
|
|
28
|
+
title={label}
|
|
29
|
+
size='sm'
|
|
30
|
+
variant='secondary'
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
} else if (onRemoveClick) {
|
|
34
|
+
return (
|
|
35
|
+
<RemoveButton
|
|
36
|
+
id={id}
|
|
37
|
+
registry={registry}
|
|
38
|
+
className='rjsf-remove-optional-data'
|
|
39
|
+
onClick={onRemoveClick}
|
|
40
|
+
title={label}
|
|
41
|
+
size='sm'
|
|
42
|
+
variant='secondary'
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return <em id={id}>{label}</em>;
|
|
47
|
+
}
|
|
@@ -55,7 +55,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
55
55
|
onChange={_onChange}
|
|
56
56
|
onBlur={_onBlur}
|
|
57
57
|
onFocus={_onFocus}
|
|
58
|
-
aria-describedby={ariaDescribedByIds
|
|
58
|
+
aria-describedby={ariaDescribedByIds(id)}
|
|
59
59
|
/>
|
|
60
60
|
);
|
|
61
61
|
return radio;
|
|
@@ -75,7 +75,7 @@ export default function SelectWidget<
|
|
|
75
75
|
const newValue = getValue(event, multiple);
|
|
76
76
|
onChange(enumOptionsValueForIndex<S>(newValue, enumOptions, optEmptyValue));
|
|
77
77
|
}}
|
|
78
|
-
aria-describedby={ariaDescribedByIds
|
|
78
|
+
aria-describedby={ariaDescribedByIds(id)}
|
|
79
79
|
>
|
|
80
80
|
{showPlaceholderOption && <option value=''>{placeholder}</option>}
|
|
81
81
|
{(enumOptions as any).map(({ value, label }: any, i: number) => {
|
|
@@ -9,7 +9,9 @@ import FieldErrorTemplate from '../FieldErrorTemplate';
|
|
|
9
9
|
import FieldHelpTemplate from '../FieldHelpTemplate';
|
|
10
10
|
import FieldTemplate from '../FieldTemplate';
|
|
11
11
|
import GridTemplate from '../GridTemplate';
|
|
12
|
+
import MultiSchemaFieldTemplate from '../MultiSchemaFieldTemplate';
|
|
12
13
|
import ObjectFieldTemplate from '../ObjectFieldTemplate';
|
|
14
|
+
import OptionalDataControlsTemplate from '../OptionalDataControlsTemplate';
|
|
13
15
|
import SubmitButton from '../SubmitButton';
|
|
14
16
|
import TitleField from '../TitleField';
|
|
15
17
|
import WrapIfAdditionalTemplate from '../WrapIfAdditionalTemplate';
|
|
@@ -38,7 +40,9 @@ export function generateTemplates<
|
|
|
38
40
|
FieldHelpTemplate,
|
|
39
41
|
FieldTemplate,
|
|
40
42
|
GridTemplate,
|
|
43
|
+
MultiSchemaFieldTemplate,
|
|
41
44
|
ObjectFieldTemplate,
|
|
45
|
+
OptionalDataControlsTemplate,
|
|
42
46
|
TitleFieldTemplate: TitleField,
|
|
43
47
|
WrapIfAdditionalTemplate,
|
|
44
48
|
};
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { FormContextType, getUiOptions, RJSFSchema, StrictRJSFSchema, TitleFieldProps } from '@rjsf/utils';
|
|
2
|
+
import Row from 'react-bootstrap/Row';
|
|
3
|
+
import Col from 'react-bootstrap/Col';
|
|
4
|
+
import Container from 'react-bootstrap/Container';
|
|
2
5
|
|
|
3
6
|
export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
4
7
|
id,
|
|
5
8
|
title,
|
|
6
9
|
uiSchema,
|
|
10
|
+
optionalDataControl,
|
|
7
11
|
}: TitleFieldProps<T, S, F>) {
|
|
8
12
|
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
13
|
+
let heading = <h5>{uiOptions.title || title}</h5>;
|
|
14
|
+
if (optionalDataControl) {
|
|
15
|
+
heading = (
|
|
16
|
+
<Container fluid className='p-0'>
|
|
17
|
+
<Row>
|
|
18
|
+
<Col xs='11'>{heading}</Col>
|
|
19
|
+
<Col xs='1' style={{ marginLeft: '-5px' }}>
|
|
20
|
+
{optionalDataControl}
|
|
21
|
+
</Col>
|
|
22
|
+
</Row>
|
|
23
|
+
</Container>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
9
26
|
return (
|
|
10
27
|
<div id={id} className='my-1'>
|
|
11
|
-
|
|
12
|
-
<hr className='border-0 bg-secondary' style={{ height: '1px' }} />
|
|
28
|
+
{heading}
|
|
29
|
+
<hr className='border-0 bg-secondary mt-0' style={{ height: '1px' }} />
|
|
13
30
|
</div>
|
|
14
31
|
);
|
|
15
32
|
}
|
|
@@ -68,7 +68,7 @@ export default function WrapIfAdditionalTemplate<
|
|
|
68
68
|
<Col xs={5}>{children}</Col>
|
|
69
69
|
<Col xs={2} className='py-4 d-grid gap-2'>
|
|
70
70
|
<RemoveButton
|
|
71
|
-
id={buttonId
|
|
71
|
+
id={buttonId(id, 'remove')}
|
|
72
72
|
className='rjsf-object-property-remove w-100'
|
|
73
73
|
disabled={disabled || readonly}
|
|
74
74
|
onClick={onDropPropertyClick(label)}
|