@rjsf/mantine 6.0.0-beta.20 → 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/dist/index.cjs +117 -65
- package/dist/index.cjs.map +4 -4
- package/dist/mantine.esm.js +119 -67
- package/dist/mantine.esm.js.map +4 -4
- package/dist/mantine.umd.js +56 -7
- package/lib/templates/ArrayFieldTemplate.js +4 -4
- package/lib/templates/ArrayFieldTemplate.js.map +1 -1
- package/lib/templates/ObjectFieldTemplate.js +5 -4
- package/lib/templates/ObjectFieldTemplate.js.map +1 -1
- package/lib/templates/OptionalDataControlsTemplate.d.ts +10 -0
- package/lib/templates/OptionalDataControlsTemplate.js +22 -0
- package/lib/templates/OptionalDataControlsTemplate.js.map +1 -0
- package/lib/templates/TitleField.js +8 -4
- package/lib/templates/TitleField.js.map +1 -1
- package/lib/templates/index.js +2 -0
- package/lib/templates/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/templates/ArrayFieldTemplate.tsx +7 -6
- package/src/templates/ObjectFieldTemplate.tsx +4 -1
- package/src/templates/OptionalDataControlsTemplate.tsx +44 -0
- package/src/templates/TitleField.tsx +12 -3
- package/src/templates/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/mantine",
|
|
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",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"@mantine/core": ">=8",
|
|
65
65
|
"@mantine/dates": ">=8",
|
|
66
66
|
"@mantine/hooks": ">=8",
|
|
67
|
-
"@rjsf/core": "^6.0.0-beta.
|
|
68
|
-
"@rjsf/utils": "^6.0.0-beta.
|
|
67
|
+
"@rjsf/core": "^6.0.0-beta.21",
|
|
68
|
+
"@rjsf/utils": "^6.0.0-beta.21",
|
|
69
69
|
"react": ">=18"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
"@mantine/hooks": "^8.3.1",
|
|
75
75
|
"@restart/hooks": "^0.6.2",
|
|
76
76
|
"@restart/ui": "^1.9.4",
|
|
77
|
-
"@rjsf/core": "^6.0.0-beta.
|
|
78
|
-
"@rjsf/snapshot-tests": "^6.0.0-beta.
|
|
79
|
-
"@rjsf/utils": "^6.0.0-beta.
|
|
80
|
-
"@rjsf/validator-ajv8": "^6.0.0-beta.
|
|
77
|
+
"@rjsf/core": "^6.0.0-beta.21",
|
|
78
|
+
"@rjsf/snapshot-tests": "^6.0.0-beta.21",
|
|
79
|
+
"@rjsf/utils": "^6.0.0-beta.21",
|
|
80
|
+
"@rjsf/validator-ajv8": "^6.0.0-beta.21",
|
|
81
81
|
"eslint": "^8.57.1",
|
|
82
82
|
"uncontrollable": "^9.0.0"
|
|
83
83
|
},
|
|
@@ -25,6 +25,7 @@ export default function ArrayFieldTemplate<
|
|
|
25
25
|
disabled,
|
|
26
26
|
fieldPathId,
|
|
27
27
|
items,
|
|
28
|
+
optionalDataControl,
|
|
28
29
|
onAddClick,
|
|
29
30
|
readonly,
|
|
30
31
|
required,
|
|
@@ -50,6 +51,7 @@ export default function ArrayFieldTemplate<
|
|
|
50
51
|
registry,
|
|
51
52
|
uiOptions,
|
|
52
53
|
);
|
|
54
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
53
55
|
// Button templates are not overridden in the uiSchema
|
|
54
56
|
const {
|
|
55
57
|
ButtonTemplates: { AddButton },
|
|
@@ -63,6 +65,7 @@ export default function ArrayFieldTemplate<
|
|
|
63
65
|
schema={schema}
|
|
64
66
|
uiSchema={uiSchema}
|
|
65
67
|
registry={registry}
|
|
68
|
+
optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
|
|
66
69
|
/>
|
|
67
70
|
);
|
|
68
71
|
|
|
@@ -77,14 +80,12 @@ export default function ArrayFieldTemplate<
|
|
|
77
80
|
registry={registry}
|
|
78
81
|
/>
|
|
79
82
|
)}
|
|
80
|
-
|
|
81
83
|
<Box className='row rjsf-array-item-list'>
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
{!showOptionalDataControlInTitle ? optionalDataControl : undefined}
|
|
85
|
+
{items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
|
|
86
|
+
<ArrayFieldItemTemplate key={key} {...itemProps} />
|
|
87
|
+
))}
|
|
86
88
|
</Box>
|
|
87
|
-
|
|
88
89
|
{canAdd && (
|
|
89
90
|
<Group justify='flex-end'>
|
|
90
91
|
<AddButton
|
|
@@ -29,6 +29,7 @@ export default function ObjectFieldTemplate<
|
|
|
29
29
|
description,
|
|
30
30
|
disabled,
|
|
31
31
|
properties,
|
|
32
|
+
optionalDataControl,
|
|
32
33
|
onAddClick,
|
|
33
34
|
readonly,
|
|
34
35
|
required,
|
|
@@ -45,6 +46,7 @@ export default function ObjectFieldTemplate<
|
|
|
45
46
|
registry,
|
|
46
47
|
uiOptions,
|
|
47
48
|
);
|
|
49
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
48
50
|
// Button templates are not overridden in the uiSchema
|
|
49
51
|
const {
|
|
50
52
|
ButtonTemplates: { AddButton },
|
|
@@ -63,6 +65,7 @@ export default function ObjectFieldTemplate<
|
|
|
63
65
|
schema={schema}
|
|
64
66
|
uiSchema={uiSchema}
|
|
65
67
|
registry={registry}
|
|
68
|
+
optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
|
|
66
69
|
/>
|
|
67
70
|
)}
|
|
68
71
|
{description && (
|
|
@@ -80,13 +83,13 @@ export default function ObjectFieldTemplate<
|
|
|
80
83
|
verticalSpacing={gridVerticalSpacing as MantineSpacing | undefined}
|
|
81
84
|
mb='sm'
|
|
82
85
|
>
|
|
86
|
+
{!showOptionalDataControlInTitle ? optionalDataControl : undefined}
|
|
83
87
|
{properties
|
|
84
88
|
.filter((e) => !e.hidden)
|
|
85
89
|
.map((element: ObjectFieldTemplatePropertyType) => (
|
|
86
90
|
<Box key={element.name}>{element.content}</Box>
|
|
87
91
|
))}
|
|
88
92
|
</SimpleGrid>
|
|
89
|
-
|
|
90
93
|
{canExpand(schema, uiSchema, formData) && (
|
|
91
94
|
<Group mt='xs' justify='flex-end'>
|
|
92
95
|
<AddButton
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
|
|
3
|
+
import AddButton from './ButtonTemplates/AddButton';
|
|
4
|
+
import { RemoveButton } from './ButtonTemplates/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
|
+
<AddButton
|
|
23
|
+
id={id}
|
|
24
|
+
registry={registry}
|
|
25
|
+
icon='plus'
|
|
26
|
+
className='rjsf-add-optional-data'
|
|
27
|
+
onClick={onAddClick}
|
|
28
|
+
title={label}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
} else if (onRemoveClick) {
|
|
32
|
+
return (
|
|
33
|
+
<RemoveButton
|
|
34
|
+
id={id}
|
|
35
|
+
registry={registry}
|
|
36
|
+
icon='remove'
|
|
37
|
+
className='rjsf-remove-optional-data'
|
|
38
|
+
onClick={onRemoveClick}
|
|
39
|
+
title={label}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return <em id={id}>{label}</em>;
|
|
44
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
-
import { Title } from '@mantine/core';
|
|
2
|
+
import { Grid, Title } from '@mantine/core';
|
|
3
3
|
|
|
4
4
|
/** The `TitleField` is the template to use to render the title of a field
|
|
5
5
|
*
|
|
@@ -8,10 +8,19 @@ import { Title } from '@mantine/core';
|
|
|
8
8
|
export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
9
9
|
props: TitleFieldProps<T, S, F>,
|
|
10
10
|
) {
|
|
11
|
-
const { id, title } = props;
|
|
12
|
-
|
|
11
|
+
const { id, title, optionalDataControl } = props;
|
|
12
|
+
let heading = title ? (
|
|
13
13
|
<Title id={id} order={3} fw='normal'>
|
|
14
14
|
{title}
|
|
15
15
|
</Title>
|
|
16
16
|
) : null;
|
|
17
|
+
if (optionalDataControl) {
|
|
18
|
+
heading = (
|
|
19
|
+
<Grid>
|
|
20
|
+
<Grid.Col span='auto'>{heading}</Grid.Col>
|
|
21
|
+
<Grid.Col span='content'>{optionalDataControl}</Grid.Col>
|
|
22
|
+
</Grid>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return heading;
|
|
17
26
|
}
|
package/src/templates/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import FieldTemplate from './FieldTemplate';
|
|
|
12
12
|
import FieldHelpTemplate from './FieldHelpTemplate';
|
|
13
13
|
import GridTemplate from './GridTemplate';
|
|
14
14
|
import ObjectFieldTemplate from './ObjectFieldTemplate';
|
|
15
|
+
import OptionalDataControlsTemplate from './OptionalDataControlsTemplate';
|
|
15
16
|
import TitleField from './TitleField';
|
|
16
17
|
import WrapIfAdditionalTemplate from './WrapIfAdditionalTemplate';
|
|
17
18
|
import MultiSchemaFieldTemplate from './MultiSchemaFieldTemplate';
|
|
@@ -34,6 +35,7 @@ export function generateTemplates<
|
|
|
34
35
|
FieldHelpTemplate,
|
|
35
36
|
GridTemplate,
|
|
36
37
|
ObjectFieldTemplate,
|
|
38
|
+
OptionalDataControlsTemplate,
|
|
37
39
|
TitleFieldTemplate: TitleField,
|
|
38
40
|
WrapIfAdditionalTemplate,
|
|
39
41
|
MultiSchemaFieldTemplate,
|