@jsonforms/material-renderers 3.1.0-alpha.0 → 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 +731 -572
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +648 -517
- 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 +6 -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 +6 -1
- package/lib/mui-controls/index.d.ts +3 -1
- package/lib/util/layout.d.ts +2 -3
- package/package.json +33 -15
- package/src/additional/ListWithDetailMasterItem.tsx +32 -24
- package/src/additional/MaterialLabelRenderer.tsx +8 -15
- package/src/additional/MaterialListWithDetailRenderer.tsx +8 -5
- package/src/additional/index.ts +12 -4
- package/{example/index.ts → src/additional/unwrapped.ts} +7 -6
- 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/{test/renderers/MatchMediaMock.ts → src/complex/unwrapped.ts} +19 -16
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +19 -11
- package/src/controls/MaterialBooleanControl.tsx +90 -23
- package/src/controls/MaterialBooleanToggleControl.tsx +90 -23
- 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/{test/renderers/util.ts → src/layouts/unwrapped.ts} +19 -28
- package/src/mui-controls/MuiAutocomplete.tsx +51 -35
- package/src/mui-controls/MuiCheckbox.tsx +14 -5
- 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 +14 -5
- 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
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/combinatorproperties.html +0 -957
- package/docs/classes/materialanyofstringorenumcontrol.html +0 -822
- package/docs/classes/materialtablecontrol.html +0 -999
- package/docs/globals.html +0 -4492
- package/docs/index.html +0 -753
- package/docs/interfaces/ajvprops.html +0 -162
- package/docs/interfaces/arraylayouttoolbarprops.html +0 -253
- package/docs/interfaces/categorizationstate.html +0 -154
- package/docs/interfaces/categorizationstepperstate.html +0 -154
- package/docs/interfaces/combinatorpropertiesprops.html +0 -182
- package/docs/interfaces/deletedialogprops.html +0 -225
- package/docs/interfaces/dispatchpropsofexpandpanel.html +0 -296
- package/docs/interfaces/emptytableprops.html +0 -154
- package/docs/interfaces/expandpanelprops.html +0 -594
- package/docs/interfaces/inputref.html +0 -168
- package/docs/interfaces/jsonformstheme.html +0 -352
- package/docs/interfaces/materialcategorizationlayoutrendererprops.html +0 -460
- package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +0 -394
- package/docs/interfaces/materiallabelablelayoutrendererprops.html +0 -328
- package/docs/interfaces/materiallayoutrendererprops.html +0 -317
- package/docs/interfaces/materialtabletoolbarprops.html +0 -302
- package/docs/interfaces/muitextinputprops.html +0 -168
- package/docs/interfaces/nonemptycellcomponentprops.html +0 -266
- package/docs/interfaces/nonemptycellprops.html +0 -277
- package/docs/interfaces/nonemptyrowprops.html +0 -366
- package/docs/interfaces/ownoneofprops.html +0 -308
- package/docs/interfaces/ownpropsofexpandpanel.html +0 -397
- package/docs/interfaces/ownpropsofnonemptycell.html +0 -229
- package/docs/interfaces/statepropsofexpandpanel.html +0 -445
- package/docs/interfaces/tableheadercellprops.html +0 -154
- package/docs/interfaces/tablerowsprop.html +0 -330
- package/docs/interfaces/validationprops.html +0 -168
- package/docs/interfaces/withdeletedialogsupport.html +0 -170
- package/docs/interfaces/withinput.html +0 -154
- package/docs/interfaces/withoptionlabel.html +0 -230
- package/example/index.html +0 -16
- package/rollup.config.js +0 -51
- package/stats.html +0 -3279
- package/test/renderers/MaterialAllOfRenderer.test.tsx +0 -114
- package/test/renderers/MaterialAnyOfRenderer.test.tsx +0 -310
- package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +0 -126
- package/test/renderers/MaterialArrayControl.test.tsx +0 -633
- package/test/renderers/MaterialArrayLayout.test.tsx +0 -528
- package/test/renderers/MaterialBooleanCell.test.tsx +0 -374
- package/test/renderers/MaterialBooleanToggleCell.test.tsx +0 -466
- package/test/renderers/MaterialBooleanToggleControl.test.tsx +0 -469
- package/test/renderers/MaterialCategorizationLayout.test.tsx +0 -458
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +0 -647
- package/test/renderers/MaterialDateCell.test.tsx +0 -303
- package/test/renderers/MaterialDateControl.test.tsx +0 -411
- package/test/renderers/MaterialDateTimeControl.test.tsx +0 -417
- package/test/renderers/MaterialEnumArrayRenderer.test.tsx +0 -207
- package/test/renderers/MaterialEnumCell.test.tsx +0 -88
- package/test/renderers/MaterialEnumControl.test.tsx +0 -75
- package/test/renderers/MaterialGroupLayout.test.tsx +0 -90
- package/test/renderers/MaterialInputControl.test.tsx +0 -370
- package/test/renderers/MaterialIntegerCell.test.tsx +0 -333
- package/test/renderers/MaterialLabelRenderer.test.tsx +0 -114
- package/test/renderers/MaterialLayouts.test.tsx +0 -542
- package/test/renderers/MaterialListWithDetailRenderer.test.tsx +0 -279
- package/test/renderers/MaterialNativeControl.test.tsx +0 -81
- package/test/renderers/MaterialNumberCell.test.tsx +0 -382
- package/test/renderers/MaterialObjectControl.test.tsx +0 -186
- package/test/renderers/MaterialOneOfEnumCell.test.tsx +0 -94
- package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +0 -108
- package/test/renderers/MaterialOneOfRenderer.test.tsx +0 -603
- package/test/renderers/MaterialRadioGroupControl.test.tsx +0 -125
- package/test/renderers/MaterialSliderControl.test.tsx +0 -438
- package/test/renderers/MaterialTextCell.test.tsx +0 -541
- package/test/renderers/MaterialTextControl.test.tsx +0 -115
- package/test/renderers/MaterialTimeCell.test.tsx +0 -331
- package/test/renderers/MaterialTimeControl.test.tsx +0 -411
- package/tsconfig.json +0 -13
- package/tsconfig.test.json +0 -7
- package/webpack/webpack.dev.js +0 -11
|
@@ -28,19 +28,29 @@ import {
|
|
|
28
28
|
isOneOfEnumControl,
|
|
29
29
|
RankedTester,
|
|
30
30
|
rankWith,
|
|
31
|
-
WithClassname
|
|
31
|
+
WithClassname,
|
|
32
32
|
} from '@jsonforms/core';
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
TranslateProps,
|
|
35
|
+
withJsonFormsOneOfEnumCellProps,
|
|
36
|
+
withTranslateProps,
|
|
37
|
+
} from '@jsonforms/react';
|
|
34
38
|
import { MuiSelect } from '../mui-controls/MuiSelect';
|
|
35
39
|
|
|
36
|
-
export const MaterialOneOfEnumCell = (
|
|
37
|
-
|
|
38
|
-
)
|
|
40
|
+
export const MaterialOneOfEnumCell = (
|
|
41
|
+
props: EnumCellProps & WithClassname & TranslateProps
|
|
42
|
+
) => <MuiSelect {...props} />;
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
45
|
* Default tester for oneOf enum controls.
|
|
42
46
|
* @type {RankedTester}
|
|
43
47
|
*/
|
|
44
|
-
export const materialOneOfEnumCellTester: RankedTester = rankWith(
|
|
48
|
+
export const materialOneOfEnumCellTester: RankedTester = rankWith(
|
|
49
|
+
2,
|
|
50
|
+
isOneOfEnumControl
|
|
51
|
+
);
|
|
45
52
|
|
|
46
|
-
export default withJsonFormsOneOfEnumCellProps(
|
|
53
|
+
export default withJsonFormsOneOfEnumCellProps(
|
|
54
|
+
withTranslateProps(React.memo(MaterialOneOfEnumCell)),
|
|
55
|
+
false
|
|
56
|
+
);
|
package/src/cells/index.ts
CHANGED
|
@@ -23,24 +23,24 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import MaterialBooleanCell, {
|
|
26
|
-
materialBooleanCellTester
|
|
26
|
+
materialBooleanCellTester,
|
|
27
27
|
} from './MaterialBooleanCell';
|
|
28
28
|
import MaterialBooleanToggleCell, {
|
|
29
|
-
materialBooleanToggleCellTester
|
|
29
|
+
materialBooleanToggleCellTester,
|
|
30
30
|
} from './MaterialBooleanToggleCell';
|
|
31
31
|
import MaterialDateCell, { materialDateCellTester } from './MaterialDateCell';
|
|
32
32
|
import MaterialEnumCell, { materialEnumCellTester } from './MaterialEnumCell';
|
|
33
33
|
import MaterialIntegerCell, {
|
|
34
|
-
materialIntegerCellTester
|
|
34
|
+
materialIntegerCellTester,
|
|
35
35
|
} from './MaterialIntegerCell';
|
|
36
36
|
import MaterialNumberCell, {
|
|
37
|
-
materialNumberCellTester
|
|
37
|
+
materialNumberCellTester,
|
|
38
38
|
} from './MaterialNumberCell';
|
|
39
39
|
import MaterialNumberFormatCell, {
|
|
40
|
-
materialNumberFormatCellTester
|
|
40
|
+
materialNumberFormatCellTester,
|
|
41
41
|
} from './MaterialNumberFormatCell';
|
|
42
42
|
import MaterialOneOfEnumCell, {
|
|
43
|
-
materialOneOfEnumCellTester
|
|
43
|
+
materialOneOfEnumCellTester,
|
|
44
44
|
} from './MaterialOneOfEnumCell';
|
|
45
45
|
import MaterialTextCell, { materialTextCellTester } from './MaterialTextCell';
|
|
46
46
|
import MaterialTimeCell, { materialTimeCellTester } from './MaterialTimeCell';
|
|
@@ -65,7 +65,7 @@ export {
|
|
|
65
65
|
MaterialTextCell,
|
|
66
66
|
materialTextCellTester,
|
|
67
67
|
MaterialTimeCell,
|
|
68
|
-
materialTimeCellTester
|
|
68
|
+
materialTimeCellTester,
|
|
69
69
|
};
|
|
70
70
|
import * as Customizable from './CustomizableCells';
|
|
71
71
|
export { Customizable };
|
|
@@ -23,7 +23,12 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
Generate,
|
|
28
|
+
JsonSchema,
|
|
29
|
+
UISchemaElement,
|
|
30
|
+
isLayout,
|
|
31
|
+
} from '@jsonforms/core';
|
|
27
32
|
import { JsonFormsDispatch } from '@jsonforms/react';
|
|
28
33
|
import omit from 'lodash/omit';
|
|
29
34
|
|
|
@@ -33,17 +38,23 @@ interface CombinatorPropertiesProps {
|
|
|
33
38
|
path: string;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
export class CombinatorProperties extends React.Component<
|
|
42
|
+
CombinatorPropertiesProps,
|
|
43
|
+
// TODO fix @typescript-eslint/ban-types
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
45
|
+
{}
|
|
46
|
+
> {
|
|
41
47
|
render() {
|
|
42
|
-
|
|
43
48
|
const { schema, combinatorKeyword, path } = this.props;
|
|
44
49
|
|
|
45
|
-
const otherProps: JsonSchema = omit(
|
|
46
|
-
|
|
50
|
+
const otherProps: JsonSchema = omit(
|
|
51
|
+
schema,
|
|
52
|
+
combinatorKeyword
|
|
53
|
+
) as JsonSchema;
|
|
54
|
+
const foundUISchema: UISchemaElement = Generate.uiSchema(
|
|
55
|
+
otherProps,
|
|
56
|
+
'VerticalLayout'
|
|
57
|
+
);
|
|
47
58
|
let isLayoutWithElements = false;
|
|
48
59
|
if (foundUISchema !== null && isLayout(foundUISchema)) {
|
|
49
60
|
isLayoutWithElements = foundUISchema.elements.length > 0;
|
|
@@ -24,50 +24,61 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
Button,
|
|
28
|
+
Dialog,
|
|
29
|
+
DialogActions,
|
|
30
|
+
DialogContent,
|
|
31
|
+
DialogContentText,
|
|
32
|
+
DialogTitle,
|
|
33
33
|
} from '@mui/material';
|
|
34
34
|
|
|
35
35
|
export interface DeleteDialogProps {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
open: boolean;
|
|
37
|
+
onClose(): void;
|
|
38
|
+
onConfirm(): void;
|
|
39
|
+
onCancel(): void;
|
|
40
|
+
title: string;
|
|
41
|
+
message: string;
|
|
42
|
+
acceptText: string;
|
|
43
|
+
declineText: string;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
export interface WithDeleteDialogSupport {
|
|
43
47
|
openDeleteDialog(path: string, data: number): void;
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
export const DeleteDialog = React.memo(({
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
50
|
+
export const DeleteDialog = React.memo(function DeleteDialog({
|
|
51
|
+
open,
|
|
52
|
+
onClose,
|
|
53
|
+
onConfirm,
|
|
54
|
+
onCancel,
|
|
55
|
+
title,
|
|
56
|
+
message,
|
|
57
|
+
acceptText,
|
|
58
|
+
declineText,
|
|
59
|
+
}: DeleteDialogProps) {
|
|
60
|
+
return (
|
|
61
|
+
<Dialog
|
|
62
|
+
open={open}
|
|
63
|
+
keepMounted
|
|
64
|
+
onClose={onClose}
|
|
65
|
+
aria-labelledby='alert-dialog-confirmdelete-title'
|
|
66
|
+
aria-describedby='alert-dialog-confirmdelete-description'
|
|
67
|
+
>
|
|
68
|
+
<DialogTitle id='alert-dialog-confirmdelete-title'>{title}</DialogTitle>
|
|
69
|
+
<DialogContent>
|
|
70
|
+
<DialogContentText id='alert-dialog-confirmdelete-description'>
|
|
71
|
+
{message}
|
|
72
|
+
</DialogContentText>
|
|
73
|
+
</DialogContent>
|
|
74
|
+
<DialogActions>
|
|
75
|
+
<Button onClick={onCancel} color='primary'>
|
|
76
|
+
{declineText}
|
|
77
|
+
</Button>
|
|
78
|
+
<Button onClick={onConfirm} color='primary'>
|
|
79
|
+
{acceptText}
|
|
80
|
+
</Button>
|
|
81
|
+
</DialogActions>
|
|
82
|
+
</Dialog>
|
|
83
|
+
);
|
|
73
84
|
});
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
JsonSchema,
|
|
33
33
|
RankedTester,
|
|
34
34
|
rankWith,
|
|
35
|
-
StatePropsOfCombinator
|
|
35
|
+
StatePropsOfCombinator,
|
|
36
36
|
} from '@jsonforms/core';
|
|
37
37
|
import { JsonFormsDispatch, withJsonFormsAllOfProps } from '@jsonforms/react';
|
|
38
38
|
|
|
@@ -44,7 +44,7 @@ export const MaterialAllOfRenderer = ({
|
|
|
44
44
|
cells,
|
|
45
45
|
path,
|
|
46
46
|
uischemas,
|
|
47
|
-
uischema
|
|
47
|
+
uischema,
|
|
48
48
|
}: StatePropsOfCombinator) => {
|
|
49
49
|
const delegateUISchema = findMatchingUISchema(uischemas)(
|
|
50
50
|
schema,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
JsonSchema,
|
|
31
31
|
RankedTester,
|
|
32
32
|
rankWith,
|
|
33
|
-
StatePropsOfCombinator
|
|
33
|
+
StatePropsOfCombinator,
|
|
34
34
|
} from '@jsonforms/core';
|
|
35
35
|
import { JsonFormsDispatch, withJsonFormsAnyOfProps } from '@jsonforms/react';
|
|
36
36
|
import { Hidden, Tab, Tabs } from '@mui/material';
|
|
@@ -45,7 +45,7 @@ export const MaterialAnyOfRenderer = ({
|
|
|
45
45
|
renderers,
|
|
46
46
|
cells,
|
|
47
47
|
uischema,
|
|
48
|
-
uischemas
|
|
48
|
+
uischemas,
|
|
49
49
|
}: StatePropsOfCombinator) => {
|
|
50
50
|
const [selectedAnyOf, setSelectedAnyOf] = useState(indexOfFittingSchema || 0);
|
|
51
51
|
const handleChange = useCallback(
|
|
@@ -70,7 +70,7 @@ export const MaterialAnyOfRenderer = ({
|
|
|
70
70
|
path={path}
|
|
71
71
|
/>
|
|
72
72
|
<Tabs value={selectedAnyOf} onChange={handleChange}>
|
|
73
|
-
{anyOfRenderInfos.map(anyOfRenderInfo => (
|
|
73
|
+
{anyOfRenderInfos.map((anyOfRenderInfo) => (
|
|
74
74
|
<Tab key={anyOfRenderInfo.label} label={anyOfRenderInfo.label} />
|
|
75
75
|
))}
|
|
76
76
|
</Tabs>
|
|
@@ -23,7 +23,14 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import React, { useCallback, useState } from 'react';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
ArrayLayoutProps,
|
|
28
|
+
RankedTester,
|
|
29
|
+
isObjectArrayControl,
|
|
30
|
+
isPrimitiveArrayControl,
|
|
31
|
+
or,
|
|
32
|
+
rankWith,
|
|
33
|
+
} from '@jsonforms/core';
|
|
27
34
|
import { withJsonFormsArrayLayoutProps } from '@jsonforms/react';
|
|
28
35
|
import { MaterialTableControl } from './MaterialTableControl';
|
|
29
36
|
import { Hidden } from '@mui/material';
|
|
@@ -35,14 +42,17 @@ export const MaterialArrayControlRenderer = (props: ArrayLayoutProps) => {
|
|
|
35
42
|
const [rowData, setRowData] = useState(undefined);
|
|
36
43
|
const { removeItems, visible } = props;
|
|
37
44
|
|
|
38
|
-
const openDeleteDialog = useCallback(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
const openDeleteDialog = useCallback(
|
|
46
|
+
(p: string, rowIndex: number) => {
|
|
47
|
+
setOpen(true);
|
|
48
|
+
setPath(p);
|
|
49
|
+
setRowData(rowIndex);
|
|
50
|
+
},
|
|
51
|
+
[setOpen, setPath, setRowData]
|
|
52
|
+
);
|
|
43
53
|
const deleteCancel = useCallback(() => setOpen(false), [setOpen]);
|
|
44
54
|
const deleteConfirm = useCallback(() => {
|
|
45
|
-
const p = path.substring(0, path.lastIndexOf(
|
|
55
|
+
const p = path.substring(0, path.lastIndexOf('.'));
|
|
46
56
|
removeItems(p, [rowData])();
|
|
47
57
|
setOpen(false);
|
|
48
58
|
}, [setOpen, path, rowData]);
|
|
@@ -50,18 +60,24 @@ export const MaterialArrayControlRenderer = (props: ArrayLayoutProps) => {
|
|
|
50
60
|
|
|
51
61
|
return (
|
|
52
62
|
<Hidden xsUp={!visible}>
|
|
53
|
-
<MaterialTableControl
|
|
54
|
-
{...props}
|
|
55
|
-
openDeleteDialog={openDeleteDialog}
|
|
56
|
-
/>
|
|
63
|
+
<MaterialTableControl {...props} openDeleteDialog={openDeleteDialog} />
|
|
57
64
|
<DeleteDialog
|
|
58
65
|
open={open}
|
|
59
66
|
onCancel={deleteCancel}
|
|
60
67
|
onConfirm={deleteConfirm}
|
|
61
68
|
onClose={deleteClose}
|
|
69
|
+
acceptText={props.translations.deleteDialogAccept}
|
|
70
|
+
declineText={props.translations.deleteDialogDecline}
|
|
71
|
+
title={props.translations.deleteDialogTitle}
|
|
72
|
+
message={props.translations.deleteDialogMessage}
|
|
62
73
|
/>
|
|
63
74
|
</Hidden>
|
|
64
75
|
);
|
|
65
76
|
};
|
|
66
77
|
|
|
78
|
+
export const materialArrayControlTester: RankedTester = rankWith(
|
|
79
|
+
3,
|
|
80
|
+
or(isObjectArrayControl, isPrimitiveArrayControl)
|
|
81
|
+
);
|
|
82
|
+
|
|
67
83
|
export default withJsonFormsArrayLayoutProps(MaterialArrayControlRenderer);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
rankWith,
|
|
11
11
|
schemaMatches,
|
|
12
12
|
schemaSubPathMatches,
|
|
13
|
-
uiTypeIs
|
|
13
|
+
uiTypeIs,
|
|
14
14
|
} from '@jsonforms/core';
|
|
15
15
|
|
|
16
16
|
import { withJsonFormsMultiEnumProps } from '@jsonforms/react';
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
FormControlLabel,
|
|
21
21
|
FormGroup,
|
|
22
22
|
FormHelperText,
|
|
23
|
-
Hidden
|
|
23
|
+
Hidden,
|
|
24
24
|
} from '@mui/material';
|
|
25
25
|
import isEmpty from 'lodash/isEmpty';
|
|
26
26
|
import React from 'react';
|
|
@@ -34,7 +34,7 @@ export const MaterialEnumArrayRenderer = ({
|
|
|
34
34
|
data,
|
|
35
35
|
addItem,
|
|
36
36
|
removeItem,
|
|
37
|
-
handleChange,
|
|
37
|
+
handleChange: _handleChange,
|
|
38
38
|
...otherProps
|
|
39
39
|
}: ControlProps & OwnPropsOfEnum & DispatchPropsOfMultiEnumControl) => {
|
|
40
40
|
return (
|
|
@@ -72,9 +72,7 @@ export const MaterialEnumArrayRenderer = ({
|
|
|
72
72
|
);
|
|
73
73
|
})}
|
|
74
74
|
</FormGroup>
|
|
75
|
-
<FormHelperText error>
|
|
76
|
-
{errors}
|
|
77
|
-
</FormHelperText>
|
|
75
|
+
<FormHelperText error>{errors}</FormHelperText>
|
|
78
76
|
</FormControl>
|
|
79
77
|
</Hidden>
|
|
80
78
|
);
|
|
@@ -96,12 +94,12 @@ export const materialEnumArrayRendererTester: RankedTester = rankWith(
|
|
|
96
94
|
uiTypeIs('Control'),
|
|
97
95
|
and(
|
|
98
96
|
schemaMatches(
|
|
99
|
-
schema =>
|
|
97
|
+
(schema) =>
|
|
100
98
|
hasType(schema, 'array') &&
|
|
101
99
|
!Array.isArray(schema.items) &&
|
|
102
100
|
schema.uniqueItems === true
|
|
103
101
|
),
|
|
104
|
-
schemaSubPathMatches('items', schema => {
|
|
102
|
+
schemaSubPathMatches('items', (schema) => {
|
|
105
103
|
return hasOneOfItems(schema) || hasEnumItems(schema);
|
|
106
104
|
})
|
|
107
105
|
)
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
isObjectControl,
|
|
30
30
|
RankedTester,
|
|
31
31
|
rankWith,
|
|
32
|
-
StatePropsOfControlWithDetail
|
|
32
|
+
StatePropsOfControlWithDetail,
|
|
33
33
|
} from '@jsonforms/core';
|
|
34
34
|
import { JsonFormsDispatch, withJsonFormsDetailProps } from '@jsonforms/react';
|
|
35
35
|
import { Hidden } from '@mui/material';
|
|
@@ -45,7 +45,7 @@ export const MaterialObjectRenderer = ({
|
|
|
45
45
|
visible,
|
|
46
46
|
enabled,
|
|
47
47
|
uischema,
|
|
48
|
-
rootSchema
|
|
48
|
+
rootSchema,
|
|
49
49
|
}: StatePropsOfControlWithDetail) => {
|
|
50
50
|
const detailUiSchema = useMemo(
|
|
51
51
|
() =>
|
|
@@ -54,7 +54,10 @@ export const MaterialObjectRenderer = ({
|
|
|
54
54
|
schema,
|
|
55
55
|
uischema.scope,
|
|
56
56
|
path,
|
|
57
|
-
() =>
|
|
57
|
+
() =>
|
|
58
|
+
isEmpty(path)
|
|
59
|
+
? Generate.uiSchema(schema, 'VerticalLayout')
|
|
60
|
+
: { ...Generate.uiSchema(schema, 'Group'), label },
|
|
58
61
|
uischema,
|
|
59
62
|
rootSchema
|
|
60
63
|
),
|
|
@@ -44,108 +44,125 @@ import {
|
|
|
44
44
|
DialogTitle,
|
|
45
45
|
Hidden,
|
|
46
46
|
Tab,
|
|
47
|
-
Tabs
|
|
47
|
+
Tabs,
|
|
48
48
|
} from '@mui/material';
|
|
49
|
-
import {
|
|
50
|
-
JsonFormsDispatch,
|
|
51
|
-
withJsonFormsOneOfProps
|
|
52
|
-
} from '@jsonforms/react';
|
|
49
|
+
import { JsonFormsDispatch, withJsonFormsOneOfProps } from '@jsonforms/react';
|
|
53
50
|
import CombinatorProperties from './CombinatorProperties';
|
|
54
51
|
|
|
55
52
|
export interface OwnOneOfProps extends OwnPropsOfControl {
|
|
56
53
|
indexOfFittingSchema?: number;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
export const MaterialOneOfRenderer =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
56
|
+
export const MaterialOneOfRenderer = ({
|
|
57
|
+
handleChange,
|
|
58
|
+
schema,
|
|
59
|
+
path,
|
|
60
|
+
renderers,
|
|
61
|
+
cells,
|
|
62
|
+
rootSchema,
|
|
63
|
+
id,
|
|
64
|
+
visible,
|
|
65
|
+
indexOfFittingSchema,
|
|
66
|
+
uischema,
|
|
67
|
+
uischemas,
|
|
68
|
+
data,
|
|
69
|
+
}: CombinatorRendererProps) => {
|
|
70
|
+
const [open, setOpen] = useState(false);
|
|
71
|
+
const [selectedIndex, setSelectedIndex] = useState(indexOfFittingSchema || 0);
|
|
72
|
+
const [newSelectedIndex, setNewSelectedIndex] = useState(0);
|
|
73
|
+
const handleClose = useCallback(() => setOpen(false), [setOpen]);
|
|
74
|
+
const cancel = useCallback(() => {
|
|
75
|
+
setOpen(false);
|
|
76
|
+
}, [setOpen]);
|
|
77
|
+
const oneOfRenderInfos = createCombinatorRenderInfos(
|
|
78
|
+
(schema as JsonSchema).oneOf,
|
|
79
|
+
rootSchema,
|
|
80
|
+
'oneOf',
|
|
81
|
+
uischema,
|
|
82
|
+
path,
|
|
83
|
+
uischemas
|
|
84
|
+
);
|
|
76
85
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
82
|
-
setSelectedIndex(newIndex);
|
|
83
|
-
}
|
|
86
|
+
const openNewTab = (newIndex: number) => {
|
|
87
|
+
handleChange(path, createDefaultValue(oneOfRenderInfos[newIndex].schema));
|
|
88
|
+
setSelectedIndex(newIndex);
|
|
89
|
+
};
|
|
84
90
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
const confirm = useCallback(() => {
|
|
92
|
+
openNewTab(newSelectedIndex);
|
|
93
|
+
setOpen(false);
|
|
94
|
+
}, [handleChange, createDefaultValue, newSelectedIndex]);
|
|
95
|
+
const handleTabChange = useCallback(
|
|
96
|
+
(_event: any, newOneOfIndex: number) => {
|
|
90
97
|
setNewSelectedIndex(newOneOfIndex);
|
|
91
|
-
if(isEmpty(data)) {
|
|
92
|
-
openNewTab(newOneOfIndex)
|
|
98
|
+
if (isEmpty(data)) {
|
|
99
|
+
openNewTab(newOneOfIndex);
|
|
93
100
|
} else {
|
|
94
101
|
setOpen(true);
|
|
95
102
|
}
|
|
103
|
+
},
|
|
104
|
+
[setOpen, setSelectedIndex, data]
|
|
105
|
+
);
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
>
|
|
129
|
-
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
107
|
+
return (
|
|
108
|
+
<Hidden xsUp={!visible}>
|
|
109
|
+
<CombinatorProperties
|
|
110
|
+
schema={schema}
|
|
111
|
+
combinatorKeyword={'oneOf'}
|
|
112
|
+
path={path}
|
|
113
|
+
/>
|
|
114
|
+
<Tabs value={selectedIndex} onChange={handleTabChange}>
|
|
115
|
+
{oneOfRenderInfos.map((oneOfRenderInfo) => (
|
|
116
|
+
<Tab key={oneOfRenderInfo.label} label={oneOfRenderInfo.label} />
|
|
117
|
+
))}
|
|
118
|
+
</Tabs>
|
|
119
|
+
{oneOfRenderInfos.map(
|
|
120
|
+
(oneOfRenderInfo, oneOfIndex) =>
|
|
121
|
+
selectedIndex === oneOfIndex && (
|
|
122
|
+
<JsonFormsDispatch
|
|
123
|
+
key={oneOfIndex}
|
|
124
|
+
schema={oneOfRenderInfo.schema}
|
|
125
|
+
uischema={oneOfRenderInfo.uischema}
|
|
126
|
+
path={path}
|
|
127
|
+
renderers={renderers}
|
|
128
|
+
cells={cells}
|
|
129
|
+
/>
|
|
130
|
+
)
|
|
131
|
+
)}
|
|
132
|
+
<Dialog
|
|
133
|
+
open={open}
|
|
134
|
+
onClose={handleClose}
|
|
135
|
+
aria-labelledby='alert-dialog-title'
|
|
136
|
+
aria-describedby='alert-dialog-description'
|
|
137
|
+
>
|
|
138
|
+
<DialogTitle id='alert-dialog-title'>{'Clear form?'}</DialogTitle>
|
|
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>
|
|
159
|
+
</Hidden>
|
|
160
|
+
);
|
|
161
|
+
};
|
|
148
162
|
|
|
149
|
-
export const materialOneOfControlTester: RankedTester = rankWith(
|
|
163
|
+
export const materialOneOfControlTester: RankedTester = rankWith(
|
|
164
|
+
3,
|
|
165
|
+
isOneOfControl
|
|
166
|
+
);
|
|
150
167
|
|
|
151
168
|
export default withJsonFormsOneOfProps(MaterialOneOfRenderer);
|