@jsonforms/material-renderers 3.1.1-alpha.0 → 3.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cells/MaterialDateCell.d.ts +2 -1
- package/lib/complex/MaterialAnyOfRenderer.d.ts +2 -2
- package/lib/complex/TabSwitchConfirmDialog.d.ts +9 -0
- package/lib/complex/unwrapped.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/jsonforms-react-material.cjs.js +102 -43
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +90 -42
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/mui-controls/MuiInputInteger.d.ts +2 -1
- package/lib/mui-controls/MuiInputNumber.d.ts +2 -1
- package/lib/mui-controls/MuiInputNumberFormat.d.ts +2 -1
- package/lib/mui-controls/MuiInputText.d.ts +2 -1
- package/lib/mui-controls/MuiInputTime.d.ts +2 -1
- package/lib/mui-controls/MuiSelect.d.ts +2 -1
- package/lib/util/theme.d.ts +8 -1
- package/package.json +8 -8
- package/src/cells/MaterialDateCell.tsx +21 -6
- package/src/complex/MaterialAnyOfRenderer.tsx +49 -6
- package/src/complex/MaterialOneOfRenderer.tsx +21 -45
- package/src/complex/TabSwitchConfirmDialog.tsx +56 -0
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +9 -4
- package/src/controls/MaterialDateControl.tsx +0 -1
- package/src/controls/MaterialDateTimeControl.tsx +0 -1
- package/src/controls/MaterialInputControl.tsx +3 -2
- package/src/controls/MaterialTimeControl.tsx +0 -1
- package/src/mui-controls/MuiAutocomplete.tsx +0 -1
- package/src/mui-controls/MuiInputInteger.tsx +16 -6
- package/src/mui-controls/MuiInputNumber.tsx +20 -10
- package/src/mui-controls/MuiInputNumberFormat.tsx +6 -4
- package/src/mui-controls/MuiInputText.tsx +11 -4
- package/src/mui-controls/MuiInputTime.tsx +20 -10
- package/src/mui-controls/MuiSelect.tsx +4 -3
- package/src/util/theme.ts +40 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
3
|
-
|
|
3
|
+
import { WithInputProps } from '../util';
|
|
4
|
+
export declare const MuiInputInteger: React.NamedExoticComponent<CellProps & WithClassname & WithInputProps>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
3
|
-
|
|
3
|
+
import { WithInputProps } from '../util';
|
|
4
|
+
export declare const MuiInputNumber: React.NamedExoticComponent<CellProps & WithClassname & WithInputProps>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CellProps, Formatted, WithClassname } from '@jsonforms/core';
|
|
3
|
-
|
|
3
|
+
import { WithInputProps } from '../util';
|
|
4
|
+
export declare const MuiInputNumberFormat: React.NamedExoticComponent<CellProps & WithClassname & Formatted<number> & WithInputProps>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
3
3
|
import { InputProps } from '@mui/material';
|
|
4
|
+
import { WithInputProps } from '../util';
|
|
4
5
|
interface MuiTextInputProps {
|
|
5
6
|
muiInputProps?: InputProps['inputProps'];
|
|
6
7
|
inputComponent?: InputProps['inputComponent'];
|
|
7
8
|
}
|
|
8
|
-
export declare const MuiInputText: React.NamedExoticComponent<CellProps & WithClassname & MuiTextInputProps>;
|
|
9
|
+
export declare const MuiInputText: React.NamedExoticComponent<CellProps & WithClassname & MuiTextInputProps & WithInputProps>;
|
|
9
10
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
3
|
-
|
|
3
|
+
import { WithInputProps } from '../util';
|
|
4
|
+
export declare const MuiInputTime: React.NamedExoticComponent<CellProps & WithClassname & WithInputProps>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EnumCellProps, WithClassname } from '@jsonforms/core';
|
|
3
3
|
import { TranslateProps } from '@jsonforms/react';
|
|
4
|
-
|
|
4
|
+
import { WithInputProps } from '../util';
|
|
5
|
+
export declare const MuiSelect: React.NamedExoticComponent<EnumCellProps & WithClassname & TranslateProps & WithInputProps>;
|
package/lib/util/theme.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Theme, TextFieldProps, InputBaseProps } from '@mui/material';
|
|
2
3
|
export interface JsonFormsTheme extends Theme {
|
|
3
4
|
jsonforms?: {
|
|
4
5
|
input?: {
|
|
@@ -8,3 +9,9 @@ export interface JsonFormsTheme extends Theme {
|
|
|
8
9
|
};
|
|
9
10
|
};
|
|
10
11
|
}
|
|
12
|
+
export interface WithInputProps {
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const defaultInputVariant: TextFieldProps['variant'];
|
|
16
|
+
export declare function useInputVariant(): TextFieldProps['variant'];
|
|
17
|
+
export declare function useInputComponent(): React.JSXElementConstructor<InputBaseProps & WithInputProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonforms/material-renderers",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-alpha.0",
|
|
4
4
|
"description": "Material Renderer Set for JSON Forms",
|
|
5
5
|
"repository": "https://github.com/eclipsesource/jsonforms",
|
|
6
6
|
"bugs": "https://github.com/eclipsesource/jsonforms/issues",
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@emotion/react": "^11.4.1",
|
|
87
87
|
"@emotion/styled": "^11.3.0",
|
|
88
|
-
"@jsonforms/core": "3.1.1-alpha.
|
|
89
|
-
"@jsonforms/react": "3.1.1-alpha.
|
|
90
|
-
"@mui/icons-material": "
|
|
88
|
+
"@jsonforms/core": "3.1.1-alpha.1",
|
|
89
|
+
"@jsonforms/react": "3.1.1-alpha.1",
|
|
90
|
+
"@mui/icons-material": "^5.11.16",
|
|
91
91
|
"@mui/material": "~5.13.0",
|
|
92
92
|
"@mui/x-date-pickers": "^6.0.0",
|
|
93
93
|
"react": "^16.12.0 || ^17.0.0 || ^18.0.0"
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@emotion/react": "^11.5.0",
|
|
97
97
|
"@emotion/styled": "^11.3.0",
|
|
98
|
-
"@jsonforms/core": "3.
|
|
99
|
-
"@jsonforms/react": "3.
|
|
98
|
+
"@jsonforms/core": "3.2.0-alpha.0",
|
|
99
|
+
"@jsonforms/react": "3.2.0-alpha.0",
|
|
100
100
|
"@mui/icons-material": "~5.11.16",
|
|
101
101
|
"@mui/material": "~5.13.0",
|
|
102
102
|
"@mui/x-date-pickers": "^6.5.0",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"rollup": "^2.78.0",
|
|
129
129
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
130
130
|
"rollup-plugin-copy": "^3.4.0",
|
|
131
|
-
"rollup-plugin-import-css": "^3.1
|
|
131
|
+
"rollup-plugin-import-css": "^3.3.1",
|
|
132
132
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
133
133
|
"rollup-plugin-visualizer": "^5.4.1",
|
|
134
134
|
"source-map-loader": "^0.2.4",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"webpack-cli": "^3.2.1",
|
|
142
142
|
"webpack-dev-server": "^3.9.0"
|
|
143
143
|
},
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "9146b0fdf5913d2251fadd5435d2c7e813db6f71"
|
|
145
145
|
}
|
|
@@ -31,22 +31,37 @@ import {
|
|
|
31
31
|
WithClassname,
|
|
32
32
|
} from '@jsonforms/core';
|
|
33
33
|
import { withJsonFormsCellProps } from '@jsonforms/react';
|
|
34
|
-
import Input from '@mui/material/Input';
|
|
35
34
|
import merge from 'lodash/merge';
|
|
35
|
+
import { useInputComponent, WithInputProps } from '../util';
|
|
36
36
|
|
|
37
|
-
export const MaterialDateCell = (
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
export const MaterialDateCell = (
|
|
38
|
+
props: CellProps & WithClassname & WithInputProps
|
|
39
|
+
) => {
|
|
40
|
+
const {
|
|
41
|
+
data,
|
|
42
|
+
className,
|
|
43
|
+
id,
|
|
44
|
+
enabled,
|
|
45
|
+
uischema,
|
|
46
|
+
path,
|
|
47
|
+
handleChange,
|
|
48
|
+
config,
|
|
49
|
+
label,
|
|
50
|
+
} = props;
|
|
40
51
|
|
|
52
|
+
const InputComponent = useInputComponent();
|
|
41
53
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
42
54
|
|
|
43
55
|
return (
|
|
44
|
-
<
|
|
56
|
+
<InputComponent
|
|
45
57
|
type='date'
|
|
46
58
|
value={data || ''}
|
|
47
|
-
onChange={(ev) =>
|
|
59
|
+
onChange={(ev: React.ChangeEvent<HTMLInputElement>) =>
|
|
60
|
+
handleChange(path, ev.target.value)
|
|
61
|
+
}
|
|
48
62
|
className={className}
|
|
49
63
|
id={id}
|
|
64
|
+
label={label}
|
|
50
65
|
disabled={!enabled}
|
|
51
66
|
autoFocus={appliedUiSchemaOptions.focus}
|
|
52
67
|
fullWidth={true}
|
|
@@ -25,18 +25,22 @@
|
|
|
25
25
|
import React, { useCallback, useState } from 'react';
|
|
26
26
|
|
|
27
27
|
import {
|
|
28
|
+
CombinatorRendererProps,
|
|
28
29
|
createCombinatorRenderInfos,
|
|
30
|
+
createDefaultValue,
|
|
29
31
|
isAnyOfControl,
|
|
30
32
|
JsonSchema,
|
|
31
33
|
RankedTester,
|
|
32
34
|
rankWith,
|
|
33
|
-
StatePropsOfCombinator,
|
|
34
35
|
} from '@jsonforms/core';
|
|
35
36
|
import { JsonFormsDispatch, withJsonFormsAnyOfProps } from '@jsonforms/react';
|
|
36
37
|
import { Hidden, Tab, Tabs } from '@mui/material';
|
|
37
38
|
import CombinatorProperties from './CombinatorProperties';
|
|
39
|
+
import isEmpty from 'lodash/isEmpty';
|
|
40
|
+
import { TabSwitchConfirmDialog } from './TabSwitchConfirmDialog';
|
|
38
41
|
|
|
39
42
|
export const MaterialAnyOfRenderer = ({
|
|
43
|
+
handleChange,
|
|
40
44
|
schema,
|
|
41
45
|
rootSchema,
|
|
42
46
|
indexOfFittingSchema,
|
|
@@ -46,12 +50,44 @@ export const MaterialAnyOfRenderer = ({
|
|
|
46
50
|
cells,
|
|
47
51
|
uischema,
|
|
48
52
|
uischemas,
|
|
49
|
-
|
|
53
|
+
id,
|
|
54
|
+
data,
|
|
55
|
+
}: CombinatorRendererProps) => {
|
|
50
56
|
const [selectedAnyOf, setSelectedAnyOf] = useState(indexOfFittingSchema || 0);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
58
|
+
const [newSelectedIndex, setNewSelectedIndex] = useState(0);
|
|
59
|
+
|
|
60
|
+
const handleClose = useCallback(
|
|
61
|
+
() => setConfirmDialogOpen(false),
|
|
62
|
+
[setConfirmDialogOpen]
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const handleTabChange = useCallback(
|
|
66
|
+
(_event: any, newIndex: number) => {
|
|
67
|
+
if (
|
|
68
|
+
isEmpty(data) ||
|
|
69
|
+
typeof data ===
|
|
70
|
+
typeof createDefaultValue(anyOfRenderInfos[newIndex].schema)
|
|
71
|
+
) {
|
|
72
|
+
setSelectedAnyOf(newIndex);
|
|
73
|
+
} else {
|
|
74
|
+
setNewSelectedIndex(newIndex);
|
|
75
|
+
setConfirmDialogOpen(true);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
[setConfirmDialogOpen, setSelectedAnyOf, data]
|
|
54
79
|
);
|
|
80
|
+
|
|
81
|
+
const openNewTab = (newIndex: number) => {
|
|
82
|
+
handleChange(path, createDefaultValue(anyOfRenderInfos[newIndex].schema));
|
|
83
|
+
setSelectedAnyOf(newIndex);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const confirm = useCallback(() => {
|
|
87
|
+
openNewTab(newSelectedIndex);
|
|
88
|
+
setConfirmDialogOpen(false);
|
|
89
|
+
}, [handleChange, createDefaultValue, newSelectedIndex]);
|
|
90
|
+
|
|
55
91
|
const anyOf = 'anyOf';
|
|
56
92
|
const anyOfRenderInfos = createCombinatorRenderInfos(
|
|
57
93
|
(schema as JsonSchema).anyOf,
|
|
@@ -69,7 +105,7 @@ export const MaterialAnyOfRenderer = ({
|
|
|
69
105
|
combinatorKeyword={anyOf}
|
|
70
106
|
path={path}
|
|
71
107
|
/>
|
|
72
|
-
<Tabs value={selectedAnyOf} onChange={
|
|
108
|
+
<Tabs value={selectedAnyOf} onChange={handleTabChange}>
|
|
73
109
|
{anyOfRenderInfos.map((anyOfRenderInfo) => (
|
|
74
110
|
<Tab key={anyOfRenderInfo.label} label={anyOfRenderInfo.label} />
|
|
75
111
|
))}
|
|
@@ -87,6 +123,13 @@ export const MaterialAnyOfRenderer = ({
|
|
|
87
123
|
/>
|
|
88
124
|
)
|
|
89
125
|
)}
|
|
126
|
+
<TabSwitchConfirmDialog
|
|
127
|
+
cancel={handleClose}
|
|
128
|
+
confirm={confirm}
|
|
129
|
+
id={'anyOf-' + id}
|
|
130
|
+
open={confirmDialogOpen}
|
|
131
|
+
handleClose={handleClose}
|
|
132
|
+
/>
|
|
90
133
|
</Hidden>
|
|
91
134
|
);
|
|
92
135
|
};
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
import React, { useCallback, useState } from 'react';
|
|
26
26
|
import isEmpty from 'lodash/isEmpty';
|
|
27
27
|
|
|
28
|
+
import { TabSwitchConfirmDialog } from './TabSwitchConfirmDialog';
|
|
29
|
+
|
|
28
30
|
import {
|
|
29
31
|
CombinatorRendererProps,
|
|
30
32
|
createCombinatorRenderInfos,
|
|
@@ -35,17 +37,7 @@ import {
|
|
|
35
37
|
RankedTester,
|
|
36
38
|
rankWith,
|
|
37
39
|
} from '@jsonforms/core';
|
|
38
|
-
import {
|
|
39
|
-
Button,
|
|
40
|
-
Dialog,
|
|
41
|
-
DialogActions,
|
|
42
|
-
DialogContent,
|
|
43
|
-
DialogContentText,
|
|
44
|
-
DialogTitle,
|
|
45
|
-
Hidden,
|
|
46
|
-
Tab,
|
|
47
|
-
Tabs,
|
|
48
|
-
} from '@mui/material';
|
|
40
|
+
import { Hidden, Tab, Tabs } from '@mui/material';
|
|
49
41
|
import { JsonFormsDispatch, withJsonFormsOneOfProps } from '@jsonforms/react';
|
|
50
42
|
import CombinatorProperties from './CombinatorProperties';
|
|
51
43
|
|
|
@@ -67,13 +59,16 @@ export const MaterialOneOfRenderer = ({
|
|
|
67
59
|
uischemas,
|
|
68
60
|
data,
|
|
69
61
|
}: CombinatorRendererProps) => {
|
|
70
|
-
const [
|
|
62
|
+
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
71
63
|
const [selectedIndex, setSelectedIndex] = useState(indexOfFittingSchema || 0);
|
|
72
64
|
const [newSelectedIndex, setNewSelectedIndex] = useState(0);
|
|
73
|
-
const handleClose = useCallback(
|
|
65
|
+
const handleClose = useCallback(
|
|
66
|
+
() => setConfirmDialogOpen(false),
|
|
67
|
+
[setConfirmDialogOpen]
|
|
68
|
+
);
|
|
74
69
|
const cancel = useCallback(() => {
|
|
75
|
-
|
|
76
|
-
}, [
|
|
70
|
+
setConfirmDialogOpen(false);
|
|
71
|
+
}, [setConfirmDialogOpen]);
|
|
77
72
|
const oneOfRenderInfos = createCombinatorRenderInfos(
|
|
78
73
|
(schema as JsonSchema).oneOf,
|
|
79
74
|
rootSchema,
|
|
@@ -90,18 +85,19 @@ export const MaterialOneOfRenderer = ({
|
|
|
90
85
|
|
|
91
86
|
const confirm = useCallback(() => {
|
|
92
87
|
openNewTab(newSelectedIndex);
|
|
93
|
-
|
|
88
|
+
setConfirmDialogOpen(false);
|
|
94
89
|
}, [handleChange, createDefaultValue, newSelectedIndex]);
|
|
90
|
+
|
|
95
91
|
const handleTabChange = useCallback(
|
|
96
92
|
(_event: any, newOneOfIndex: number) => {
|
|
97
93
|
setNewSelectedIndex(newOneOfIndex);
|
|
98
94
|
if (isEmpty(data)) {
|
|
99
95
|
openNewTab(newOneOfIndex);
|
|
100
96
|
} else {
|
|
101
|
-
|
|
97
|
+
setConfirmDialogOpen(true);
|
|
102
98
|
}
|
|
103
99
|
},
|
|
104
|
-
[
|
|
100
|
+
[setConfirmDialogOpen, setSelectedIndex, data]
|
|
105
101
|
);
|
|
106
102
|
|
|
107
103
|
return (
|
|
@@ -129,33 +125,13 @@ export const MaterialOneOfRenderer = ({
|
|
|
129
125
|
/>
|
|
130
126
|
)
|
|
131
127
|
)}
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
<DialogContent>
|
|
140
|
-
<DialogContentText id='alert-dialog-description'>
|
|
141
|
-
Your data will be cleared if you navigate away from this tab. Do you
|
|
142
|
-
want to proceed?
|
|
143
|
-
</DialogContentText>
|
|
144
|
-
</DialogContent>
|
|
145
|
-
<DialogActions>
|
|
146
|
-
<Button onClick={cancel} color='primary'>
|
|
147
|
-
No
|
|
148
|
-
</Button>
|
|
149
|
-
<Button
|
|
150
|
-
onClick={confirm}
|
|
151
|
-
color='primary'
|
|
152
|
-
autoFocus
|
|
153
|
-
id={`oneOf-${id}-confirm-yes`}
|
|
154
|
-
>
|
|
155
|
-
Yes
|
|
156
|
-
</Button>
|
|
157
|
-
</DialogActions>
|
|
158
|
-
</Dialog>
|
|
128
|
+
<TabSwitchConfirmDialog
|
|
129
|
+
cancel={cancel}
|
|
130
|
+
confirm={confirm}
|
|
131
|
+
id={'oneOf-' + id}
|
|
132
|
+
open={confirmDialogOpen}
|
|
133
|
+
handleClose={handleClose}
|
|
134
|
+
/>
|
|
159
135
|
</Hidden>
|
|
160
136
|
);
|
|
161
137
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
Dialog,
|
|
6
|
+
DialogActions,
|
|
7
|
+
DialogContent,
|
|
8
|
+
DialogContentText,
|
|
9
|
+
DialogTitle,
|
|
10
|
+
} from '@mui/material';
|
|
11
|
+
|
|
12
|
+
export interface TabSwitchConfirmDialogProps {
|
|
13
|
+
open: boolean;
|
|
14
|
+
handleClose: () => void;
|
|
15
|
+
confirm: () => void;
|
|
16
|
+
cancel: () => void;
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const TabSwitchConfirmDialog = ({
|
|
21
|
+
open,
|
|
22
|
+
handleClose,
|
|
23
|
+
confirm,
|
|
24
|
+
cancel,
|
|
25
|
+
id,
|
|
26
|
+
}: TabSwitchConfirmDialogProps) => {
|
|
27
|
+
return (
|
|
28
|
+
<Dialog
|
|
29
|
+
open={open}
|
|
30
|
+
onClose={handleClose}
|
|
31
|
+
aria-labelledby='alert-dialog-title'
|
|
32
|
+
aria-describedby='alert-dialog-description'
|
|
33
|
+
>
|
|
34
|
+
<DialogTitle id='alert-dialog-title'>{'Clear form?'}</DialogTitle>
|
|
35
|
+
<DialogContent>
|
|
36
|
+
<DialogContentText id='alert-dialog-description'>
|
|
37
|
+
Your data will be cleared if you navigate away from this tab. Do you
|
|
38
|
+
want to proceed?
|
|
39
|
+
</DialogContentText>
|
|
40
|
+
</DialogContent>
|
|
41
|
+
<DialogActions>
|
|
42
|
+
<Button onClick={cancel} color='primary'>
|
|
43
|
+
No
|
|
44
|
+
</Button>
|
|
45
|
+
<Button
|
|
46
|
+
onClick={confirm}
|
|
47
|
+
color='primary'
|
|
48
|
+
autoFocus
|
|
49
|
+
id={`${id}-confirm-yes`}
|
|
50
|
+
>
|
|
51
|
+
Yes
|
|
52
|
+
</Button>
|
|
53
|
+
</DialogActions>
|
|
54
|
+
</Dialog>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -35,10 +35,10 @@ import {
|
|
|
35
35
|
WithClassname,
|
|
36
36
|
} from '@jsonforms/core';
|
|
37
37
|
import { Control, withJsonFormsControlProps } from '@jsonforms/react';
|
|
38
|
-
import {
|
|
38
|
+
import { InputBaseComponentProps } from '@mui/material';
|
|
39
39
|
import merge from 'lodash/merge';
|
|
40
40
|
import React, { useMemo } from 'react';
|
|
41
|
-
import { useDebouncedChange } from '../util';
|
|
41
|
+
import { useDebouncedChange, useInputComponent, WithInputProps } from '../util';
|
|
42
42
|
import { MaterialInputControl } from './MaterialInputControl';
|
|
43
43
|
|
|
44
44
|
const findEnumSchema = (schemas: JsonSchema[]) =>
|
|
@@ -48,7 +48,9 @@ const findEnumSchema = (schemas: JsonSchema[]) =>
|
|
|
48
48
|
const findTextSchema = (schemas: JsonSchema[]) =>
|
|
49
49
|
schemas.find((s) => s.type === 'string' && s.enum === undefined);
|
|
50
50
|
|
|
51
|
-
const MuiAutocompleteInputText = (
|
|
51
|
+
const MuiAutocompleteInputText = (
|
|
52
|
+
props: EnumCellProps & WithClassname & WithInputProps
|
|
53
|
+
) => {
|
|
52
54
|
const {
|
|
53
55
|
data,
|
|
54
56
|
config,
|
|
@@ -60,7 +62,9 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
|
|
|
60
62
|
path,
|
|
61
63
|
handleChange,
|
|
62
64
|
schema,
|
|
65
|
+
label,
|
|
63
66
|
} = props;
|
|
67
|
+
const InputComponent = useInputComponent();
|
|
64
68
|
const enumSchema = findEnumSchema(schema.anyOf);
|
|
65
69
|
const stringSchema = findTextSchema(schema.anyOf);
|
|
66
70
|
const maxLength = stringSchema.maxLength;
|
|
@@ -94,12 +98,13 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
|
|
|
94
98
|
</datalist>
|
|
95
99
|
);
|
|
96
100
|
return (
|
|
97
|
-
<
|
|
101
|
+
<InputComponent
|
|
98
102
|
type='text'
|
|
99
103
|
value={inputText}
|
|
100
104
|
onChange={onChange}
|
|
101
105
|
className={className}
|
|
102
106
|
id={id}
|
|
107
|
+
label={label}
|
|
103
108
|
disabled={!enabled}
|
|
104
109
|
autoFocus={appliedUiSchemaOptions.focus}
|
|
105
110
|
fullWidth={!appliedUiSchemaOptions.trim || maxLength === undefined}
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
|
|
32
32
|
import { Hidden, InputLabel, FormControl, FormHelperText } from '@mui/material';
|
|
33
33
|
import merge from 'lodash/merge';
|
|
34
|
-
import { useFocus } from '../util';
|
|
34
|
+
import { useFocus, useInputVariant } from '../util';
|
|
35
35
|
|
|
36
36
|
export interface WithInput {
|
|
37
37
|
input: any;
|
|
@@ -50,6 +50,7 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
|
|
|
50
50
|
config,
|
|
51
51
|
input,
|
|
52
52
|
} = props;
|
|
53
|
+
const variant = useInputVariant();
|
|
53
54
|
const isValid = errors.length === 0;
|
|
54
55
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
55
56
|
|
|
@@ -74,8 +75,8 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
|
|
|
74
75
|
fullWidth={!appliedUiSchemaOptions.trim}
|
|
75
76
|
onFocus={onFocus}
|
|
76
77
|
onBlur={onBlur}
|
|
78
|
+
variant={variant}
|
|
77
79
|
id={id}
|
|
78
|
-
variant={'standard'}
|
|
79
80
|
>
|
|
80
81
|
<InputLabel
|
|
81
82
|
htmlFor={id + '-input'}
|
|
@@ -24,19 +24,28 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import { Input } from '@mui/material';
|
|
28
27
|
import merge from 'lodash/merge';
|
|
29
|
-
import { useDebouncedChange } from '../util';
|
|
28
|
+
import { useDebouncedChange, useInputComponent, WithInputProps } from '../util';
|
|
30
29
|
|
|
31
30
|
const toNumber = (value: string) =>
|
|
32
31
|
value === '' ? undefined : parseInt(value, 10);
|
|
33
32
|
const eventToValue = (ev: any) => toNumber(ev.target.value);
|
|
34
33
|
|
|
35
34
|
export const MuiInputInteger = React.memo(function MuiInputInteger(
|
|
36
|
-
props: CellProps & WithClassname
|
|
35
|
+
props: CellProps & WithClassname & WithInputProps
|
|
37
36
|
) {
|
|
38
|
-
const {
|
|
39
|
-
|
|
37
|
+
const {
|
|
38
|
+
data,
|
|
39
|
+
className,
|
|
40
|
+
id,
|
|
41
|
+
enabled,
|
|
42
|
+
uischema,
|
|
43
|
+
path,
|
|
44
|
+
handleChange,
|
|
45
|
+
config,
|
|
46
|
+
label,
|
|
47
|
+
} = props;
|
|
48
|
+
const InputComponent = useInputComponent();
|
|
40
49
|
const inputProps = { step: '1' };
|
|
41
50
|
|
|
42
51
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
@@ -50,7 +59,8 @@ export const MuiInputInteger = React.memo(function MuiInputInteger(
|
|
|
50
59
|
);
|
|
51
60
|
|
|
52
61
|
return (
|
|
53
|
-
<
|
|
62
|
+
<InputComponent
|
|
63
|
+
label={label}
|
|
54
64
|
type='number'
|
|
55
65
|
value={inputValue}
|
|
56
66
|
onChange={onChange}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/*
|
|
2
2
|
The MIT License
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
5
|
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
8
|
of this software and associated documentation files (the "Software"), to deal
|
|
9
9
|
in the Software without restriction, including without limitation the rights
|
|
10
10
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
11
|
copies of the Software, and to permit persons to whom the Software is
|
|
12
12
|
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
The above copyright notice and this permission notice shall be included in
|
|
15
15
|
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
18
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
19
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
@@ -24,18 +24,27 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import { Input } from '@mui/material';
|
|
28
27
|
import merge from 'lodash/merge';
|
|
29
|
-
import { useDebouncedChange } from '../util';
|
|
28
|
+
import { useDebouncedChange, useInputComponent, WithInputProps } from '../util';
|
|
30
29
|
|
|
31
30
|
const toNumber = (value: string) =>
|
|
32
31
|
value === '' ? undefined : parseFloat(value);
|
|
33
32
|
const eventToValue = (ev: any) => toNumber(ev.target.value);
|
|
34
33
|
export const MuiInputNumber = React.memo(function MuiInputNumber(
|
|
35
|
-
props: CellProps & WithClassname
|
|
34
|
+
props: CellProps & WithClassname & WithInputProps
|
|
36
35
|
) {
|
|
37
|
-
const {
|
|
38
|
-
|
|
36
|
+
const {
|
|
37
|
+
data,
|
|
38
|
+
className,
|
|
39
|
+
id,
|
|
40
|
+
enabled,
|
|
41
|
+
uischema,
|
|
42
|
+
path,
|
|
43
|
+
handleChange,
|
|
44
|
+
config,
|
|
45
|
+
label,
|
|
46
|
+
} = props;
|
|
47
|
+
const InputComponent = useInputComponent();
|
|
39
48
|
const inputProps = { step: '0.1' };
|
|
40
49
|
|
|
41
50
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
@@ -48,8 +57,9 @@ export const MuiInputNumber = React.memo(function MuiInputNumber(
|
|
|
48
57
|
);
|
|
49
58
|
|
|
50
59
|
return (
|
|
51
|
-
<
|
|
60
|
+
<InputComponent
|
|
52
61
|
type='number'
|
|
62
|
+
label={label}
|
|
53
63
|
value={inputValue}
|
|
54
64
|
onChange={onChange}
|
|
55
65
|
className={className}
|