@jsonforms/material-renderers 3.1.0-alpha.1 → 3.1.0-alpha.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/README.md +16 -17
- package/lib/additional/ListWithDetailMasterItem.d.ts +2 -0
- package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
- package/lib/additional/index.d.ts +2 -2
- package/lib/additional/unwrapped.d.ts +5 -0
- package/lib/cells/index.d.ts +1 -1
- package/lib/complex/CombinatorProperties.d.ts +1 -2
- package/lib/complex/DeleteDialog.d.ts +5 -1
- package/lib/complex/MaterialAllOfRenderer.d.ts +1 -1
- package/lib/complex/MaterialAnyOfRenderer.d.ts +1 -1
- package/lib/complex/MaterialArrayControlRenderer.d.ts +2 -1
- package/lib/complex/MaterialEnumArrayRenderer.d.ts +1 -1
- package/lib/complex/MaterialObjectRenderer.d.ts +1 -1
- package/lib/complex/MaterialOneOfRenderer.d.ts +1 -1
- package/lib/complex/MaterialTableControl.d.ts +4 -2
- package/lib/complex/NoBorderTableCell.d.ts +2 -2
- package/lib/complex/TableToolbar.d.ts +3 -2
- package/lib/complex/index.d.ts +11 -16
- package/lib/complex/unwrapped.d.ts +9 -0
- package/lib/controls/MaterialBooleanControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
- package/lib/controls/index.d.ts +8 -26
- package/lib/controls/unwrapped.d.ts +19 -0
- package/lib/index.d.ts +34 -1
- package/lib/jsonforms-react-material.cjs.js +690 -599
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +620 -557
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/layouts/ArrayToolbar.d.ts +3 -1
- package/lib/layouts/ExpandPanelRenderer.d.ts +3 -1
- package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
- package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
- package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
- package/lib/layouts/index.d.ts +3 -1
- package/lib/layouts/unwrapped.d.ts +10 -0
- package/lib/mui-controls/MuiCheckbox.d.ts +1 -1
- package/lib/mui-controls/MuiInputInteger.d.ts +1 -1
- package/lib/mui-controls/MuiInputNumber.d.ts +1 -1
- package/lib/mui-controls/MuiInputNumberFormat.d.ts +1 -1
- package/lib/mui-controls/MuiInputText.d.ts +1 -1
- package/lib/mui-controls/MuiInputTime.d.ts +1 -1
- package/lib/mui-controls/MuiSelect.d.ts +1 -1
- package/lib/mui-controls/MuiToggle.d.ts +1 -1
- package/lib/mui-controls/index.d.ts +3 -1
- package/lib/util/layout.d.ts +2 -3
- package/package.json +16 -9
- package/src/additional/ListWithDetailMasterItem.tsx +31 -23
- package/src/additional/MaterialLabelRenderer.tsx +8 -15
- package/src/additional/MaterialListWithDetailRenderer.tsx +8 -5
- package/src/additional/index.ts +12 -4
- package/src/additional/unwrapped.ts +32 -0
- package/src/cells/MaterialBooleanCell.tsx +1 -1
- package/src/cells/MaterialBooleanToggleCell.tsx +2 -2
- package/src/cells/MaterialDateCell.tsx +4 -12
- package/src/cells/MaterialEnumCell.tsx +13 -6
- package/src/cells/MaterialIntegerCell.tsx +1 -1
- package/src/cells/MaterialNumberCell.tsx +1 -1
- package/src/cells/MaterialNumberFormatCell.tsx +1 -1
- package/src/cells/MaterialOneOfEnumCell.tsx +17 -7
- package/src/cells/MaterialTextCell.tsx +1 -1
- package/src/cells/MaterialTimeCell.tsx +1 -1
- package/src/cells/index.ts +7 -7
- package/src/complex/CombinatorProperties.tsx +20 -9
- package/src/complex/DeleteDialog.tsx +48 -37
- package/src/complex/MaterialAllOfRenderer.tsx +2 -2
- package/src/complex/MaterialAnyOfRenderer.tsx +3 -3
- package/src/complex/MaterialArrayControlRenderer.tsx +27 -11
- package/src/complex/MaterialEnumArrayRenderer.tsx +6 -8
- package/src/complex/MaterialObjectRenderer.tsx +6 -3
- package/src/complex/MaterialOneOfRenderer.tsx +105 -88
- package/src/complex/MaterialTableControl.tsx +145 -97
- package/src/complex/NoBorderTableCell.tsx +3 -5
- package/src/complex/TableToolbar.tsx +24 -25
- package/src/complex/ValidationIcon.tsx +10 -18
- package/src/complex/index.ts +35 -32
- package/src/complex/unwrapped.ts +39 -0
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +19 -11
- package/src/controls/MaterialBooleanControl.tsx +22 -16
- package/src/controls/MaterialBooleanToggleControl.tsx +22 -16
- package/src/controls/MaterialDateControl.tsx +16 -19
- package/src/controls/MaterialDateTimeControl.tsx +24 -23
- package/src/controls/MaterialEnumControl.tsx +21 -15
- package/src/controls/MaterialInputControl.tsx +7 -8
- package/src/controls/MaterialIntegerControl.tsx +1 -1
- package/src/controls/MaterialNativeControl.tsx +12 -9
- package/src/controls/MaterialNumberControl.tsx +1 -1
- package/src/controls/MaterialOneOfEnumControl.tsx +21 -15
- package/src/controls/MaterialOneOfRadioGroupControl.tsx +5 -3
- package/src/controls/MaterialRadioGroup.tsx +11 -17
- package/src/controls/MaterialRadioGroupControl.tsx +8 -3
- package/src/controls/MaterialSliderControl.tsx +17 -16
- package/src/controls/MaterialTextControl.tsx +1 -1
- package/src/controls/MaterialTimeControl.tsx +19 -22
- package/src/controls/index.ts +36 -72
- package/src/controls/unwrapped.ts +57 -0
- package/src/index.ts +41 -22
- package/src/layouts/ArrayToolbar.tsx +38 -42
- package/src/layouts/ExpandPanelRenderer.tsx +96 -67
- package/src/layouts/MaterialArrayLayout.tsx +21 -16
- package/src/layouts/MaterialArrayLayoutRenderer.tsx +6 -9
- package/src/layouts/MaterialCategorizationLayout.tsx +52 -21
- package/src/layouts/MaterialCategorizationStepperLayout.tsx +60 -44
- package/src/layouts/MaterialGroupLayout.tsx +25 -6
- package/src/layouts/MaterialHorizontalLayout.tsx +18 -4
- package/src/layouts/MaterialVerticalLayout.tsx +18 -4
- package/src/layouts/index.ts +18 -7
- package/src/layouts/unwrapped.ts +41 -0
- package/src/mui-controls/MuiAutocomplete.tsx +51 -35
- package/src/mui-controls/MuiCheckbox.tsx +5 -3
- package/src/mui-controls/MuiInputInteger.tsx +31 -32
- package/src/mui-controls/MuiInputNumber.tsx +16 -16
- package/src/mui-controls/MuiInputNumberFormat.tsx +51 -42
- package/src/mui-controls/MuiInputText.tsx +30 -19
- package/src/mui-controls/MuiInputTime.tsx +11 -12
- package/src/mui-controls/MuiSelect.tsx +15 -6
- package/src/mui-controls/MuiToggle.tsx +5 -3
- package/src/mui-controls/index.ts +3 -1
- package/src/util/datejs.tsx +41 -20
- package/src/util/debounce.ts +26 -11
- package/src/util/focus.ts +7 -7
- package/src/util/i18nDefaults.ts +2 -2
- package/src/util/layout.tsx +47 -42
- package/src/util/theme.ts +2 -2
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
import React, {useState, useMemo} from 'react';
|
|
25
|
+
import React, { useState, useMemo } from 'react';
|
|
26
26
|
import merge from 'lodash/merge';
|
|
27
27
|
import { Button, Hidden, Step, StepButton, Stepper } from '@mui/material';
|
|
28
28
|
import {
|
|
@@ -36,14 +36,18 @@ import {
|
|
|
36
36
|
RankedTester,
|
|
37
37
|
rankWith,
|
|
38
38
|
StatePropsOfLayout,
|
|
39
|
-
uiTypeIs
|
|
39
|
+
uiTypeIs,
|
|
40
40
|
} from '@jsonforms/core';
|
|
41
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
TranslateProps,
|
|
43
|
+
withJsonFormsLayoutProps,
|
|
44
|
+
withTranslateProps,
|
|
45
|
+
} from '@jsonforms/react';
|
|
42
46
|
import {
|
|
43
47
|
AjvProps,
|
|
44
48
|
MaterialLayoutRenderer,
|
|
45
49
|
MaterialLayoutRendererProps,
|
|
46
|
-
withAjvProps
|
|
50
|
+
withAjvProps,
|
|
47
51
|
} from '../util/layout';
|
|
48
52
|
|
|
49
53
|
export const materialCategorizationStepperTester: RankedTester = rankWith(
|
|
@@ -60,15 +64,19 @@ export interface CategorizationStepperState {
|
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
export interface MaterialCategorizationStepperLayoutRendererProps
|
|
63
|
-
extends StatePropsOfLayout,
|
|
64
|
-
|
|
67
|
+
extends StatePropsOfLayout,
|
|
68
|
+
AjvProps,
|
|
69
|
+
TranslateProps {
|
|
70
|
+
data: any;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
export const MaterialCategorizationStepperLayoutRenderer = (
|
|
73
|
+
export const MaterialCategorizationStepperLayoutRenderer = (
|
|
74
|
+
props: MaterialCategorizationStepperLayoutRendererProps
|
|
75
|
+
) => {
|
|
68
76
|
const [activeCategory, setActiveCategory] = useState<number>(0);
|
|
69
77
|
|
|
70
78
|
const handleStep = (step: number) => {
|
|
71
|
-
setActiveCategory(
|
|
79
|
+
setActiveCategory(step);
|
|
72
80
|
};
|
|
73
81
|
|
|
74
82
|
const {
|
|
@@ -81,24 +89,28 @@ export const MaterialCategorizationStepperLayoutRenderer = (props: MaterialCateg
|
|
|
81
89
|
cells,
|
|
82
90
|
config,
|
|
83
91
|
ajv,
|
|
84
|
-
t
|
|
92
|
+
t,
|
|
85
93
|
} = props;
|
|
86
94
|
const categorization = uischema as Categorization;
|
|
87
95
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
88
96
|
const buttonWrapperStyle = {
|
|
89
|
-
textAlign: 'right' as
|
|
97
|
+
textAlign: 'right' as const,
|
|
90
98
|
width: '100%',
|
|
91
|
-
margin: '1em auto'
|
|
99
|
+
margin: '1em auto',
|
|
92
100
|
};
|
|
93
101
|
const buttonNextStyle = {
|
|
94
|
-
float: 'right' as
|
|
102
|
+
float: 'right' as const,
|
|
95
103
|
};
|
|
96
104
|
const buttonStyle = {
|
|
97
|
-
marginRight: '1em'
|
|
105
|
+
marginRight: '1em',
|
|
98
106
|
};
|
|
99
|
-
const categories = useMemo(
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
const categories = useMemo(
|
|
108
|
+
() =>
|
|
109
|
+
categorization.elements.filter((category: Category) =>
|
|
110
|
+
isVisible(category, data, undefined, ajv)
|
|
111
|
+
),
|
|
112
|
+
[categorization, data, ajv]
|
|
113
|
+
);
|
|
102
114
|
const childProps: MaterialLayoutRendererProps = {
|
|
103
115
|
elements: categories[activeCategory].elements,
|
|
104
116
|
schema,
|
|
@@ -106,13 +118,11 @@ export const MaterialCategorizationStepperLayoutRenderer = (props: MaterialCateg
|
|
|
106
118
|
direction: 'column',
|
|
107
119
|
visible,
|
|
108
120
|
renderers,
|
|
109
|
-
cells
|
|
121
|
+
cells,
|
|
110
122
|
};
|
|
111
123
|
const tabLabels = useMemo(() => {
|
|
112
|
-
return categories.map((e: Category) =>
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
}, [categories, t])
|
|
124
|
+
return categories.map((e: Category) => deriveLabelForUISchemaElement(e, t));
|
|
125
|
+
}, [categories, t]);
|
|
116
126
|
return (
|
|
117
127
|
<Hidden xsUp={!visible}>
|
|
118
128
|
<Stepper activeStep={activeCategory} nonLinear>
|
|
@@ -127,30 +137,36 @@ export const MaterialCategorizationStepperLayoutRenderer = (props: MaterialCateg
|
|
|
127
137
|
<div>
|
|
128
138
|
<MaterialLayoutRenderer {...childProps} />
|
|
129
139
|
</div>
|
|
130
|
-
{
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
{appliedUiSchemaOptions.showNavButtons ? (
|
|
141
|
+
<div style={buttonWrapperStyle}>
|
|
142
|
+
<Button
|
|
143
|
+
style={buttonNextStyle}
|
|
144
|
+
variant='contained'
|
|
145
|
+
color='primary'
|
|
146
|
+
disabled={activeCategory >= categories.length - 1}
|
|
147
|
+
onClick={() => handleStep(activeCategory + 1)}
|
|
148
|
+
>
|
|
149
|
+
Next
|
|
150
|
+
</Button>
|
|
151
|
+
<Button
|
|
152
|
+
style={buttonStyle}
|
|
153
|
+
color='secondary'
|
|
154
|
+
variant='contained'
|
|
155
|
+
disabled={activeCategory <= 0}
|
|
156
|
+
onClick={() => handleStep(activeCategory - 1)}
|
|
157
|
+
>
|
|
158
|
+
Previous
|
|
159
|
+
</Button>
|
|
160
|
+
</div>
|
|
161
|
+
) : (
|
|
162
|
+
<></>
|
|
163
|
+
)}
|
|
150
164
|
</Hidden>
|
|
151
165
|
);
|
|
152
166
|
};
|
|
153
167
|
|
|
154
|
-
export default withAjvProps(
|
|
155
|
-
|
|
156
|
-
)
|
|
168
|
+
export default withAjvProps(
|
|
169
|
+
withTranslateProps(
|
|
170
|
+
withJsonFormsLayoutProps(MaterialCategorizationStepperLayoutRenderer)
|
|
171
|
+
)
|
|
172
|
+
);
|
|
@@ -42,23 +42,42 @@ import { withJsonFormsLayoutProps } from '@jsonforms/react';
|
|
|
42
42
|
export const groupTester: RankedTester = rankWith(1, uiTypeIs('Group'));
|
|
43
43
|
const style: { [x: string]: any } = { marginBottom: '10px' };
|
|
44
44
|
|
|
45
|
-
const GroupComponent = React.memo(({
|
|
45
|
+
const GroupComponent = React.memo(function GroupComponent({
|
|
46
|
+
visible,
|
|
47
|
+
enabled,
|
|
48
|
+
uischema,
|
|
49
|
+
label,
|
|
50
|
+
...props
|
|
51
|
+
}: MaterialLabelableLayoutRendererProps) {
|
|
46
52
|
const groupLayout = uischema as GroupLayout;
|
|
47
53
|
return (
|
|
48
54
|
<Hidden xsUp={!visible}>
|
|
49
55
|
<Card style={style}>
|
|
50
|
-
{!isEmpty(label) &&
|
|
51
|
-
<CardHeader title={label} />
|
|
52
|
-
)}
|
|
56
|
+
{!isEmpty(label) && <CardHeader title={label} />}
|
|
53
57
|
<CardContent>
|
|
54
|
-
<MaterialLayoutRenderer
|
|
58
|
+
<MaterialLayoutRenderer
|
|
59
|
+
{...props}
|
|
60
|
+
visible={visible}
|
|
61
|
+
enabled={enabled}
|
|
62
|
+
elements={groupLayout.elements}
|
|
63
|
+
/>
|
|
55
64
|
</CardContent>
|
|
56
65
|
</Card>
|
|
57
66
|
</Hidden>
|
|
58
67
|
);
|
|
59
68
|
});
|
|
60
69
|
|
|
61
|
-
export const MaterializedGroupLayoutRenderer = ({
|
|
70
|
+
export const MaterializedGroupLayoutRenderer = ({
|
|
71
|
+
uischema,
|
|
72
|
+
schema,
|
|
73
|
+
path,
|
|
74
|
+
visible,
|
|
75
|
+
enabled,
|
|
76
|
+
renderers,
|
|
77
|
+
cells,
|
|
78
|
+
direction,
|
|
79
|
+
label,
|
|
80
|
+
}: LayoutProps) => {
|
|
62
81
|
const groupLayout = uischema as GroupLayout;
|
|
63
82
|
|
|
64
83
|
return (
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
import { withJsonFormsLayoutProps } from '@jsonforms/react';
|
|
34
34
|
import {
|
|
35
35
|
MaterialLayoutRenderer,
|
|
36
|
-
MaterialLayoutRendererProps
|
|
36
|
+
MaterialLayoutRendererProps,
|
|
37
37
|
} from '../util/layout';
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -45,7 +45,15 @@ export const materialHorizontalLayoutTester: RankedTester = rankWith(
|
|
|
45
45
|
uiTypeIs('HorizontalLayout')
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
-
export const MaterialHorizontalLayoutRenderer = ({
|
|
48
|
+
export const MaterialHorizontalLayoutRenderer = ({
|
|
49
|
+
uischema,
|
|
50
|
+
renderers,
|
|
51
|
+
cells,
|
|
52
|
+
schema,
|
|
53
|
+
path,
|
|
54
|
+
enabled,
|
|
55
|
+
visible,
|
|
56
|
+
}: LayoutProps) => {
|
|
49
57
|
const layout = uischema as HorizontalLayout;
|
|
50
58
|
const childProps: MaterialLayoutRendererProps = {
|
|
51
59
|
elements: layout.elements,
|
|
@@ -53,10 +61,16 @@ export const MaterialHorizontalLayoutRenderer = ({ uischema, renderers, cells, s
|
|
|
53
61
|
path,
|
|
54
62
|
enabled,
|
|
55
63
|
direction: 'row',
|
|
56
|
-
visible
|
|
64
|
+
visible,
|
|
57
65
|
};
|
|
58
66
|
|
|
59
|
-
return
|
|
67
|
+
return (
|
|
68
|
+
<MaterialLayoutRenderer
|
|
69
|
+
{...childProps}
|
|
70
|
+
renderers={renderers}
|
|
71
|
+
cells={cells}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
60
74
|
};
|
|
61
75
|
|
|
62
76
|
export default withJsonFormsLayoutProps(MaterialHorizontalLayoutRenderer);
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
} from '@jsonforms/core';
|
|
33
33
|
import {
|
|
34
34
|
MaterialLayoutRenderer,
|
|
35
|
-
MaterialLayoutRendererProps
|
|
35
|
+
MaterialLayoutRendererProps,
|
|
36
36
|
} from '../util/layout';
|
|
37
37
|
import { withJsonFormsLayoutProps } from '@jsonforms/react';
|
|
38
38
|
|
|
@@ -45,7 +45,15 @@ export const materialVerticalLayoutTester: RankedTester = rankWith(
|
|
|
45
45
|
uiTypeIs('VerticalLayout')
|
|
46
46
|
);
|
|
47
47
|
|
|
48
|
-
export const MaterialVerticalLayoutRenderer = ({
|
|
48
|
+
export const MaterialVerticalLayoutRenderer = ({
|
|
49
|
+
uischema,
|
|
50
|
+
schema,
|
|
51
|
+
path,
|
|
52
|
+
enabled,
|
|
53
|
+
visible,
|
|
54
|
+
renderers,
|
|
55
|
+
cells,
|
|
56
|
+
}: LayoutProps) => {
|
|
49
57
|
const verticalLayout = uischema as VerticalLayout;
|
|
50
58
|
const childProps: MaterialLayoutRendererProps = {
|
|
51
59
|
elements: verticalLayout.elements,
|
|
@@ -53,10 +61,16 @@ export const MaterialVerticalLayoutRenderer = ({ uischema, schema, path, enabled
|
|
|
53
61
|
path,
|
|
54
62
|
enabled,
|
|
55
63
|
direction: 'column',
|
|
56
|
-
visible
|
|
64
|
+
visible,
|
|
57
65
|
};
|
|
58
66
|
|
|
59
|
-
return
|
|
67
|
+
return (
|
|
68
|
+
<MaterialLayoutRenderer
|
|
69
|
+
{...childProps}
|
|
70
|
+
renderers={renderers}
|
|
71
|
+
cells={cells}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
60
74
|
};
|
|
61
75
|
|
|
62
76
|
export default withJsonFormsLayoutProps(MaterialVerticalLayoutRenderer);
|
package/src/layouts/index.ts
CHANGED
|
@@ -22,25 +22,34 @@
|
|
|
22
22
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
+
import ExpandPanelRenderer, {
|
|
26
|
+
ctxDispatchToExpandPanelProps,
|
|
27
|
+
withContextToExpandPanelProps,
|
|
28
|
+
withJsonFormsExpandPanelProps,
|
|
29
|
+
} from './ExpandPanelRenderer';
|
|
25
30
|
import MaterialGroupLayout, {
|
|
26
|
-
materialGroupTester
|
|
31
|
+
materialGroupTester,
|
|
27
32
|
} from './MaterialGroupLayout';
|
|
28
33
|
import MaterialHorizontalLayout, {
|
|
29
|
-
materialHorizontalLayoutTester
|
|
34
|
+
materialHorizontalLayoutTester,
|
|
30
35
|
} from './MaterialHorizontalLayout';
|
|
31
36
|
import MaterialVerticalLayout, {
|
|
32
|
-
materialVerticalLayoutTester
|
|
37
|
+
materialVerticalLayoutTester,
|
|
33
38
|
} from './MaterialVerticalLayout';
|
|
34
39
|
import MaterialCategorizationLayout, {
|
|
35
|
-
materialCategorizationTester
|
|
40
|
+
materialCategorizationTester,
|
|
36
41
|
} from './MaterialCategorizationLayout';
|
|
37
42
|
import MaterialArrayLayout, {
|
|
38
|
-
materialArrayLayoutTester
|
|
43
|
+
materialArrayLayoutTester,
|
|
39
44
|
} from './MaterialArrayLayoutRenderer';
|
|
40
45
|
|
|
41
46
|
export {
|
|
42
|
-
|
|
47
|
+
ExpandPanelRenderer,
|
|
48
|
+
ctxDispatchToExpandPanelProps,
|
|
49
|
+
withContextToExpandPanelProps,
|
|
50
|
+
withJsonFormsExpandPanelProps,
|
|
43
51
|
MaterialArrayLayout,
|
|
52
|
+
materialArrayLayoutTester,
|
|
44
53
|
MaterialCategorizationLayout,
|
|
45
54
|
materialCategorizationTester,
|
|
46
55
|
MaterialGroupLayout,
|
|
@@ -48,5 +57,7 @@ export {
|
|
|
48
57
|
MaterialHorizontalLayout,
|
|
49
58
|
materialHorizontalLayoutTester,
|
|
50
59
|
MaterialVerticalLayout,
|
|
51
|
-
materialVerticalLayoutTester
|
|
60
|
+
materialVerticalLayoutTester,
|
|
52
61
|
};
|
|
62
|
+
|
|
63
|
+
export * from './ArrayToolbar';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
+
https://github.com/eclipsesource/jsonforms
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
import { ExpandPanelRenderer as ExpandPanelRendererUnwrapped } from './ExpandPanelRenderer';
|
|
26
|
+
import { MaterializedGroupLayoutRenderer } from './MaterialGroupLayout';
|
|
27
|
+
import { MaterialHorizontalLayoutRenderer } from './MaterialHorizontalLayout';
|
|
28
|
+
import { MaterialVerticalLayoutRenderer } from './MaterialVerticalLayout';
|
|
29
|
+
import { MaterialCategorizationLayoutRenderer } from './MaterialCategorizationLayout';
|
|
30
|
+
import { MaterialArrayLayoutRenderer } from './MaterialArrayLayoutRenderer';
|
|
31
|
+
|
|
32
|
+
export const UnwrappedLayouts = {
|
|
33
|
+
ExpandPanelRenderer: ExpandPanelRendererUnwrapped,
|
|
34
|
+
MaterialArrayLayout: MaterialArrayLayoutRenderer,
|
|
35
|
+
MaterialCategorizationLayout: MaterialCategorizationLayoutRenderer,
|
|
36
|
+
MaterialGroupLayout: MaterializedGroupLayoutRenderer,
|
|
37
|
+
MaterialHorizontalLayout: MaterialHorizontalLayoutRenderer,
|
|
38
|
+
MaterialVerticalLayout: MaterialVerticalLayoutRenderer,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export * from './ArrayToolbar';
|
|
@@ -23,7 +23,13 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import React, { ReactNode } from 'react';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
ControlProps,
|
|
28
|
+
EnumCellProps,
|
|
29
|
+
EnumOption,
|
|
30
|
+
isDescriptionHidden,
|
|
31
|
+
WithClassname,
|
|
32
|
+
} from '@jsonforms/core';
|
|
27
33
|
|
|
28
34
|
import {
|
|
29
35
|
Autocomplete,
|
|
@@ -31,18 +37,27 @@ import {
|
|
|
31
37
|
FilterOptionsState,
|
|
32
38
|
FormHelperText,
|
|
33
39
|
Hidden,
|
|
34
|
-
TextField
|
|
40
|
+
TextField,
|
|
35
41
|
} from '@mui/material';
|
|
36
42
|
import merge from 'lodash/merge';
|
|
37
43
|
import { useFocus } from '../util/focus';
|
|
38
44
|
|
|
39
45
|
export interface WithOptionLabel {
|
|
40
|
-
getOptionLabel?(option: EnumOption)
|
|
41
|
-
renderOption?(
|
|
42
|
-
|
|
46
|
+
getOptionLabel?(option: EnumOption): string;
|
|
47
|
+
renderOption?(
|
|
48
|
+
props: React.HTMLAttributes<HTMLLIElement>,
|
|
49
|
+
option: EnumOption,
|
|
50
|
+
state: AutocompleteRenderOptionState
|
|
51
|
+
): ReactNode;
|
|
52
|
+
filterOptions?(
|
|
53
|
+
options: EnumOption[],
|
|
54
|
+
state: FilterOptionsState<EnumOption>
|
|
55
|
+
): EnumOption[];
|
|
43
56
|
}
|
|
44
57
|
|
|
45
|
-
export const MuiAutocomplete = (
|
|
58
|
+
export const MuiAutocomplete = (
|
|
59
|
+
props: ControlProps & EnumCellProps & WithClassname & WithOptionLabel
|
|
60
|
+
) => {
|
|
46
61
|
const {
|
|
47
62
|
description,
|
|
48
63
|
errors,
|
|
@@ -61,21 +76,21 @@ export const MuiAutocomplete = (props: ControlProps & EnumCellProps & WithClassn
|
|
|
61
76
|
getOptionLabel,
|
|
62
77
|
renderOption,
|
|
63
78
|
filterOptions,
|
|
64
|
-
isValid
|
|
79
|
+
isValid,
|
|
65
80
|
} = props;
|
|
66
81
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
67
82
|
const [inputValue, setInputValue] = React.useState(data ?? '');
|
|
68
83
|
const [focused, onFocus, onBlur] = useFocus();
|
|
69
84
|
|
|
70
|
-
const findOption = options.find(o => o.value === data) ?? null;
|
|
71
|
-
|
|
85
|
+
const findOption = options.find((o) => o.value === data) ?? null;
|
|
86
|
+
|
|
72
87
|
const showDescription = !isDescriptionHidden(
|
|
73
88
|
visible,
|
|
74
89
|
description,
|
|
75
90
|
focused,
|
|
76
91
|
appliedUiSchemaOptions.showUnfocusedDescription
|
|
77
92
|
);
|
|
78
|
-
|
|
93
|
+
|
|
79
94
|
const firstFormHelperText = showDescription
|
|
80
95
|
? description
|
|
81
96
|
: !isValid
|
|
@@ -102,38 +117,39 @@ export const MuiAutocomplete = (props: ControlProps & EnumCellProps & WithClassn
|
|
|
102
117
|
autoComplete
|
|
103
118
|
fullWidth
|
|
104
119
|
options={options}
|
|
105
|
-
getOptionLabel={getOptionLabel || (option => option?.label)}
|
|
120
|
+
getOptionLabel={getOptionLabel || ((option) => option?.label)}
|
|
106
121
|
freeSolo={false}
|
|
107
|
-
renderInput={params => {
|
|
108
|
-
return(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
renderInput={(params) => {
|
|
123
|
+
return (
|
|
124
|
+
<TextField
|
|
125
|
+
label={label}
|
|
126
|
+
variant={'standard'}
|
|
127
|
+
type='text'
|
|
128
|
+
inputProps={params.inputProps}
|
|
129
|
+
inputRef={params.InputProps.ref}
|
|
130
|
+
autoFocus={appliedUiSchemaOptions.focus}
|
|
131
|
+
disabled={!enabled}
|
|
132
|
+
{...params}
|
|
133
|
+
id={id + '-input'}
|
|
134
|
+
required={
|
|
135
|
+
required && !appliedUiSchemaOptions.hideRequiredAsterisk
|
|
136
|
+
}
|
|
137
|
+
error={!isValid}
|
|
138
|
+
fullWidth={!appliedUiSchemaOptions.trim}
|
|
139
|
+
InputLabelProps={data ? { shrink: true } : undefined}
|
|
140
|
+
onFocus={onFocus}
|
|
141
|
+
onBlur={onBlur}
|
|
142
|
+
focused={focused}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}}
|
|
128
146
|
renderOption={renderOption}
|
|
129
147
|
filterOptions={filterOptions}
|
|
130
148
|
/>
|
|
131
149
|
<FormHelperText error={!isValid && !showDescription}>
|
|
132
150
|
{firstFormHelperText}
|
|
133
151
|
</FormHelperText>
|
|
134
|
-
<FormHelperText error={!isValid}>
|
|
135
|
-
{secondFormHelperText}
|
|
136
|
-
</FormHelperText>
|
|
152
|
+
<FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
|
|
137
153
|
</Hidden>
|
|
138
154
|
);
|
|
139
155
|
};
|
|
@@ -31,7 +31,9 @@ interface MuiCheckboxInputProps {
|
|
|
31
31
|
inputProps?: InputProps['inputProps'];
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export const MuiCheckbox = React.memo((
|
|
34
|
+
export const MuiCheckbox = React.memo(function MuiCheckbox(
|
|
35
|
+
props: CellProps & WithClassname & MuiCheckboxInputProps
|
|
36
|
+
) {
|
|
35
37
|
const {
|
|
36
38
|
data,
|
|
37
39
|
className,
|
|
@@ -41,11 +43,11 @@ export const MuiCheckbox = React.memo((props: CellProps & WithClassname & MuiChe
|
|
|
41
43
|
path,
|
|
42
44
|
handleChange,
|
|
43
45
|
config,
|
|
44
|
-
inputProps
|
|
46
|
+
inputProps,
|
|
45
47
|
} = props;
|
|
46
48
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
47
49
|
const inputPropsMerged = merge({}, inputProps, {
|
|
48
|
-
autoFocus: !!appliedUiSchemaOptions.focus
|
|
50
|
+
autoFocus: !!appliedUiSchemaOptions.focus,
|
|
49
51
|
});
|
|
50
52
|
// !! causes undefined value to be converted to false, otherwise has no effect
|
|
51
53
|
const checked = !!data;
|
|
@@ -29,38 +29,37 @@ import merge from 'lodash/merge';
|
|
|
29
29
|
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
31
|
const toNumber = (value: string) =>
|
|
32
|
-
|
|
33
|
-
const eventToValue = (ev:any) => toNumber(ev.target.value);
|
|
32
|
+
value === '' ? undefined : parseInt(value, 10);
|
|
33
|
+
const eventToValue = (ev: any) => toNumber(ev.target.value);
|
|
34
34
|
|
|
35
|
-
export const MuiInputInteger = React.memo(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
enabled,
|
|
42
|
-
uischema,
|
|
43
|
-
path,
|
|
44
|
-
handleChange,
|
|
45
|
-
config
|
|
46
|
-
} = props;
|
|
47
|
-
const inputProps = { step: '1' };
|
|
48
|
-
|
|
49
|
-
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
35
|
+
export const MuiInputInteger = React.memo(function MuiInputInteger(
|
|
36
|
+
props: CellProps & WithClassname
|
|
37
|
+
) {
|
|
38
|
+
const { data, className, id, enabled, uischema, path, handleChange, config } =
|
|
39
|
+
props;
|
|
40
|
+
const inputProps = { step: '1' };
|
|
50
41
|
|
|
51
|
-
|
|
42
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
52
43
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
const [inputValue, onChange] = useDebouncedChange(
|
|
45
|
+
handleChange,
|
|
46
|
+
'',
|
|
47
|
+
data,
|
|
48
|
+
path,
|
|
49
|
+
eventToValue
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Input
|
|
54
|
+
type='number'
|
|
55
|
+
value={inputValue}
|
|
56
|
+
onChange={onChange}
|
|
57
|
+
className={className}
|
|
58
|
+
id={id}
|
|
59
|
+
disabled={!enabled}
|
|
60
|
+
autoFocus={appliedUiSchemaOptions.focus}
|
|
61
|
+
inputProps={inputProps}
|
|
62
|
+
fullWidth={true}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
@@ -26,26 +26,26 @@ import React from 'react';
|
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
27
|
import { Input } from '@mui/material';
|
|
28
28
|
import merge from 'lodash/merge';
|
|
29
|
-
import {useDebouncedChange} from '../util';
|
|
29
|
+
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
31
|
const toNumber = (value: string) =>
|
|
32
|
-
|
|
33
|
-
const eventToValue = (ev:any) => toNumber(ev.target.value);
|
|
34
|
-
export const MuiInputNumber = React.memo((
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
enabled,
|
|
40
|
-
uischema,
|
|
41
|
-
path,
|
|
42
|
-
handleChange,
|
|
43
|
-
config
|
|
44
|
-
} = props;
|
|
32
|
+
value === '' ? undefined : parseFloat(value);
|
|
33
|
+
const eventToValue = (ev: any) => toNumber(ev.target.value);
|
|
34
|
+
export const MuiInputNumber = React.memo(function MuiInputNumber(
|
|
35
|
+
props: CellProps & WithClassname
|
|
36
|
+
) {
|
|
37
|
+
const { data, className, id, enabled, uischema, path, handleChange, config } =
|
|
38
|
+
props;
|
|
45
39
|
const inputProps = { step: '0.1' };
|
|
46
|
-
|
|
40
|
+
|
|
47
41
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
48
|
-
const [inputValue, onChange] = useDebouncedChange(
|
|
42
|
+
const [inputValue, onChange] = useDebouncedChange(
|
|
43
|
+
handleChange,
|
|
44
|
+
'',
|
|
45
|
+
data,
|
|
46
|
+
path,
|
|
47
|
+
eventToValue
|
|
48
|
+
);
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
51
|
<Input
|