@jsonforms/material-renderers 2.5.2-alpha.0 → 3.0.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 +1 -1
- package/docs/assets/js/search.json +1 -1
- package/docs/classes/combinatorproperties.html +2 -5
- package/docs/classes/materialanyofstringorenumcontrol.html +6 -9
- package/docs/classes/materialtablecontrol.html +4 -7
- package/docs/globals.html +986 -274
- package/docs/index.html +78 -51
- package/docs/interfaces/ajvprops.html +1 -4
- package/docs/interfaces/arraylayouttoolbarprops.html +0 -3
- package/docs/interfaces/categorizationstate.html +0 -3
- package/docs/interfaces/categorizationstepperstate.html +0 -3
- package/docs/interfaces/combinatorpropertiesprops.html +0 -3
- package/docs/interfaces/deletedialogprops.html +0 -3
- package/docs/interfaces/dispatchpropsofexpandpanel.html +3 -6
- package/docs/interfaces/emptytableprops.html +0 -3
- package/docs/interfaces/expandpanelprops.html +19 -22
- package/docs/interfaces/jsonformstheme.html +0 -3
- package/docs/interfaces/materialcategorizationlayoutrendererprops.html +7 -10
- package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +7 -10
- package/docs/interfaces/materiallayoutrendererprops.html +0 -3
- package/docs/interfaces/materialtabletoolbarprops.html +10 -13
- package/docs/interfaces/muitextinputprops.html +2 -5
- package/docs/interfaces/nonemptycellcomponentprops.html +266 -0
- package/docs/interfaces/nonemptycellprops.html +0 -3
- package/docs/interfaces/nonemptyrowprops.html +80 -27
- package/docs/interfaces/ownoneofprops.html +0 -3
- package/docs/interfaces/ownpropsofexpandpanel.html +14 -17
- package/docs/interfaces/ownpropsofnonemptycell.html +0 -3
- package/docs/interfaces/statepropsofexpandpanel.html +16 -19
- package/docs/interfaces/tableheadercellprops.html +0 -3
- package/docs/interfaces/tablerowsprop.html +9 -12
- package/docs/interfaces/validationprops.html +0 -3
- package/docs/interfaces/withdeletedialogsupport.html +0 -3
- package/docs/interfaces/withinput.html +1 -4
- package/docs/interfaces/withoptionlabel.html +3 -6
- package/lib/additional/ListWithDetailMasterItem.d.ts +1 -1
- package/lib/additional/ListWithDetailMasterItem.js.map +1 -1
- package/lib/additional/MaterialLabelRenderer.d.ts +1 -1
- package/lib/additional/MaterialLabelRenderer.js +3 -1
- package/lib/additional/MaterialLabelRenderer.js.map +1 -1
- package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
- package/lib/additional/MaterialListWithDetailRenderer.js +5 -3
- package/lib/additional/MaterialListWithDetailRenderer.js.map +1 -1
- package/lib/additional/index.js +3 -2
- package/lib/additional/index.js.map +1 -1
- package/lib/cells/CustomizableCells.d.ts +1 -0
- package/lib/cells/CustomizableCells.js +11 -8
- package/lib/cells/CustomizableCells.js.map +1 -1
- package/lib/cells/MaterialBooleanCell.d.ts +1 -1
- package/lib/cells/MaterialBooleanCell.js +3 -1
- package/lib/cells/MaterialBooleanCell.js.map +1 -1
- package/lib/cells/MaterialBooleanToggleCell.d.ts +1 -1
- package/lib/cells/MaterialBooleanToggleCell.js +3 -1
- package/lib/cells/MaterialBooleanToggleCell.js.map +1 -1
- package/lib/cells/MaterialDateCell.d.ts +1 -1
- package/lib/cells/MaterialDateCell.js +3 -1
- package/lib/cells/MaterialDateCell.js.map +1 -1
- package/lib/cells/MaterialEnumCell.d.ts +1 -1
- package/lib/cells/MaterialEnumCell.js +3 -1
- package/lib/cells/MaterialEnumCell.js.map +1 -1
- package/lib/cells/MaterialIntegerCell.d.ts +1 -1
- package/lib/cells/MaterialIntegerCell.js +3 -1
- package/lib/cells/MaterialIntegerCell.js.map +1 -1
- package/lib/cells/MaterialNumberCell.d.ts +1 -1
- package/lib/cells/MaterialNumberCell.js +3 -1
- package/lib/cells/MaterialNumberCell.js.map +1 -1
- package/lib/cells/MaterialNumberFormatCell.d.ts +1 -1
- package/lib/cells/MaterialNumberFormatCell.js +3 -1
- package/lib/cells/MaterialNumberFormatCell.js.map +1 -1
- package/lib/cells/MaterialOneOfEnumCell.d.ts +10 -0
- package/lib/cells/MaterialOneOfEnumCell.js +41 -0
- package/lib/cells/MaterialOneOfEnumCell.js.map +1 -0
- package/lib/cells/MaterialTextCell.d.ts +1 -1
- package/lib/cells/MaterialTextCell.js +3 -1
- package/lib/cells/MaterialTextCell.js.map +1 -1
- package/lib/cells/MaterialTimeCell.d.ts +1 -1
- package/lib/cells/MaterialTimeCell.js +3 -1
- package/lib/cells/MaterialTimeCell.js.map +1 -1
- package/lib/cells/index.d.ts +2 -1
- package/lib/cells/index.js +13 -9
- package/lib/cells/index.js.map +1 -1
- package/lib/complex/CombinatorProperties.js +4 -2
- package/lib/complex/CombinatorProperties.js.map +1 -1
- package/lib/complex/DeleteDialog.js +1 -0
- package/lib/complex/DeleteDialog.js.map +1 -1
- package/lib/complex/MaterialAllOfRenderer.d.ts +3 -2
- package/lib/complex/MaterialAllOfRenderer.js +5 -3
- package/lib/complex/MaterialAllOfRenderer.js.map +1 -1
- package/lib/complex/MaterialAnyOfRenderer.d.ts +3 -2
- package/lib/complex/MaterialAnyOfRenderer.js +4 -2
- package/lib/complex/MaterialAnyOfRenderer.js.map +1 -1
- package/lib/complex/MaterialArrayControlRenderer.d.ts +1 -1
- package/lib/complex/MaterialArrayControlRenderer.js +3 -1
- package/lib/complex/MaterialArrayControlRenderer.js.map +1 -1
- package/lib/complex/MaterialEnumArrayRenderer.d.ts +2 -2
- package/lib/complex/MaterialEnumArrayRenderer.js +6 -3
- package/lib/complex/MaterialEnumArrayRenderer.js.map +1 -1
- package/lib/complex/MaterialObjectRenderer.d.ts +3 -2
- package/lib/complex/MaterialObjectRenderer.js +5 -3
- package/lib/complex/MaterialObjectRenderer.js.map +1 -1
- package/lib/complex/MaterialOneOfRenderer.d.ts +2 -1
- package/lib/complex/MaterialOneOfRenderer.js +6 -5
- package/lib/complex/MaterialOneOfRenderer.js.map +1 -1
- package/lib/complex/MaterialTableControl.d.ts +16 -1
- package/lib/complex/MaterialTableControl.js +16 -8
- package/lib/complex/MaterialTableControl.js.map +1 -1
- package/lib/complex/NoBorderTableCell.js.map +1 -1
- package/lib/complex/TableToolbar.d.ts +2 -2
- package/lib/complex/TableToolbar.js.map +1 -1
- package/lib/complex/ValidationIcon.d.ts +5 -3
- package/lib/complex/ValidationIcon.js.map +1 -1
- package/lib/complex/index.js +6 -5
- package/lib/complex/index.js.map +1 -1
- package/lib/controls/MaterialAnyOfStringOrEnumControl.d.ts +1 -1
- package/lib/controls/MaterialAnyOfStringOrEnumControl.js +17 -12
- package/lib/controls/MaterialAnyOfStringOrEnumControl.js.map +1 -1
- package/lib/controls/MaterialBooleanControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanControl.js +3 -1
- package/lib/controls/MaterialBooleanControl.js.map +1 -1
- package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanToggleControl.js +3 -1
- package/lib/controls/MaterialBooleanToggleControl.js.map +1 -1
- package/lib/controls/MaterialDateControl.d.ts +3 -15
- package/lib/controls/MaterialDateControl.js +27 -45
- package/lib/controls/MaterialDateControl.js.map +1 -1
- package/lib/controls/MaterialDateTimeControl.d.ts +3 -6
- package/lib/controls/MaterialDateTimeControl.js +27 -24
- package/lib/controls/MaterialDateTimeControl.js.map +1 -1
- package/lib/controls/MaterialEnumControl.d.ts +1 -1
- package/lib/controls/MaterialEnumControl.js +3 -1
- package/lib/controls/MaterialEnumControl.js.map +1 -1
- package/lib/controls/MaterialInputControl.d.ts +2 -5
- package/lib/controls/MaterialInputControl.js +23 -28
- package/lib/controls/MaterialInputControl.js.map +1 -1
- package/lib/controls/MaterialIntegerControl.d.ts +1 -1
- package/lib/controls/MaterialIntegerControl.js +3 -1
- package/lib/controls/MaterialIntegerControl.js.map +1 -1
- package/lib/controls/MaterialNativeControl.d.ts +3 -6
- package/lib/controls/MaterialNativeControl.js +15 -18
- package/lib/controls/MaterialNativeControl.js.map +1 -1
- package/lib/controls/MaterialNumberControl.d.ts +1 -1
- package/lib/controls/MaterialNumberControl.js +3 -1
- package/lib/controls/MaterialNumberControl.js.map +1 -1
- package/lib/controls/MaterialOneOfEnumControl.d.ts +1 -1
- package/lib/controls/MaterialOneOfEnumControl.js +3 -1
- package/lib/controls/MaterialOneOfEnumControl.js.map +1 -1
- package/lib/controls/MaterialOneOfRadioGroupControl.d.ts +1 -1
- package/lib/controls/MaterialOneOfRadioGroupControl.js +3 -1
- package/lib/controls/MaterialOneOfRadioGroupControl.js.map +1 -1
- package/lib/controls/MaterialRadioGroup.d.ts +2 -5
- package/lib/controls/MaterialRadioGroup.js +15 -20
- package/lib/controls/MaterialRadioGroup.js.map +1 -1
- package/lib/controls/MaterialRadioGroupControl.d.ts +1 -1
- package/lib/controls/MaterialRadioGroupControl.js +3 -1
- package/lib/controls/MaterialRadioGroupControl.js.map +1 -1
- package/lib/controls/MaterialSliderControl.d.ts +3 -6
- package/lib/controls/MaterialSliderControl.js +35 -39
- package/lib/controls/MaterialSliderControl.js.map +1 -1
- package/lib/controls/MaterialTextControl.d.ts +1 -1
- package/lib/controls/MaterialTextControl.js +3 -1
- package/lib/controls/MaterialTextControl.js.map +1 -1
- package/lib/controls/MaterialTimeControl.d.ts +6 -0
- package/lib/controls/MaterialTimeControl.js +62 -0
- package/lib/controls/MaterialTimeControl.js.map +1 -0
- package/lib/controls/index.d.ts +11 -9
- package/lib/controls/index.js +19 -14
- package/lib/controls/index.js.map +1 -1
- package/lib/extended/MaterialAutocompleteEnumControl.d.ts +1 -1
- package/lib/extended/MaterialAutocompleteEnumControl.js +3 -1
- package/lib/extended/MaterialAutocompleteEnumControl.js.map +1 -1
- package/lib/extended/MaterialAutocompleteOneOfEnumControl.d.ts +1 -1
- package/lib/extended/MaterialAutocompleteOneOfEnumControl.js +3 -1
- package/lib/extended/MaterialAutocompleteOneOfEnumControl.js.map +1 -1
- package/lib/extended/MuiAutocomplete.d.ts +2 -2
- package/lib/extended/MuiAutocomplete.js +4 -3
- package/lib/extended/MuiAutocomplete.js.map +1 -1
- package/lib/extended/index.d.ts +2 -2
- package/lib/extended/index.js +2 -1
- package/lib/extended/index.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/jsonforms-material.js +9 -281
- package/lib/jsonforms-material.js.map +1 -1
- package/lib/layouts/ArrayToolbar.js +1 -0
- package/lib/layouts/ArrayToolbar.js.map +1 -1
- package/lib/layouts/ExpandPanelRenderer.d.ts +2 -3
- package/lib/layouts/ExpandPanelRenderer.js +29 -22
- package/lib/layouts/ExpandPanelRenderer.js.map +1 -1
- package/lib/layouts/MaterialArrayLayout.d.ts +1 -11
- package/lib/layouts/MaterialArrayLayout.js +19 -31
- package/lib/layouts/MaterialArrayLayout.js.map +1 -1
- package/lib/layouts/MaterialArrayLayoutRenderer.d.ts +1 -1
- package/lib/layouts/MaterialArrayLayoutRenderer.js +3 -1
- package/lib/layouts/MaterialArrayLayoutRenderer.js.map +1 -1
- package/lib/layouts/MaterialCategorizationLayout.d.ts +2 -10
- package/lib/layouts/MaterialCategorizationLayout.js +31 -47
- package/lib/layouts/MaterialCategorizationLayout.js.map +1 -1
- package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +2 -9
- package/lib/layouts/MaterialCategorizationStepperLayout.js +42 -53
- package/lib/layouts/MaterialCategorizationStepperLayout.js.map +1 -1
- package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
- package/lib/layouts/MaterialGroupLayout.js +3 -1
- package/lib/layouts/MaterialGroupLayout.js.map +1 -1
- package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
- package/lib/layouts/MaterialHorizontalLayout.js +3 -1
- package/lib/layouts/MaterialHorizontalLayout.js.map +1 -1
- package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
- package/lib/layouts/MaterialVerticalLayout.js +3 -1
- package/lib/layouts/MaterialVerticalLayout.js.map +1 -1
- package/lib/layouts/index.js +6 -5
- package/lib/layouts/index.js.map +1 -1
- package/lib/mui-controls/MuiCheckbox.js +2 -2
- package/lib/mui-controls/MuiCheckbox.js.map +1 -1
- package/lib/mui-controls/MuiInputInteger.js +9 -6
- package/lib/mui-controls/MuiInputInteger.js.map +1 -1
- package/lib/mui-controls/MuiInputNumber.js +9 -6
- package/lib/mui-controls/MuiInputNumber.js.map +1 -1
- package/lib/mui-controls/MuiInputNumberFormat.js +7 -8
- package/lib/mui-controls/MuiInputNumberFormat.js.map +1 -1
- package/lib/mui-controls/MuiInputText.js +11 -7
- package/lib/mui-controls/MuiInputText.js.map +1 -1
- package/lib/mui-controls/MuiInputTime.js +5 -3
- package/lib/mui-controls/MuiInputTime.js.map +1 -1
- package/lib/mui-controls/MuiSelect.js +3 -3
- package/lib/mui-controls/MuiSelect.js.map +1 -1
- package/lib/mui-controls/MuiToggle.js +2 -2
- package/lib/mui-controls/MuiToggle.js.map +1 -1
- package/lib/util/datejs.d.ts +3 -0
- package/lib/util/datejs.js +29 -0
- package/lib/util/datejs.js.map +1 -0
- package/lib/util/debounce.d.ts +1 -0
- package/lib/util/debounce.js +48 -0
- package/lib/util/debounce.js.map +1 -0
- package/lib/util/focus.d.ts +1 -0
- package/lib/util/focus.js +36 -0
- package/lib/util/focus.js.map +1 -0
- package/lib/util/index.d.ts +3 -0
- package/lib/util/index.js +4 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/layout.d.ts +2 -1
- package/lib/util/layout.js +9 -5
- package/lib/util/layout.js.map +1 -1
- package/package.json +12 -13
- package/src/additional/MaterialListWithDetailRenderer.tsx +3 -4
- package/src/cells/CustomizableCells.ts +1 -0
- package/src/cells/MaterialOneOfEnumCell.tsx +46 -0
- package/src/cells/MaterialTimeCell.tsx +1 -0
- package/src/cells/index.ts +5 -0
- package/src/complex/CombinatorProperties.tsx +2 -2
- package/src/complex/MaterialAllOfRenderer.tsx +5 -4
- package/src/complex/MaterialAnyOfRenderer.tsx +4 -3
- package/src/complex/MaterialEnumArrayRenderer.tsx +1 -0
- package/src/complex/MaterialObjectRenderer.tsx +5 -5
- package/src/complex/MaterialOneOfRenderer.tsx +8 -8
- package/src/complex/MaterialTableControl.tsx +36 -24
- package/src/complex/TableToolbar.tsx +1 -2
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +16 -12
- package/src/controls/MaterialDateControl.tsx +82 -113
- package/src/controls/MaterialDateTimeControl.tsx +88 -70
- package/src/controls/MaterialInputControl.tsx +62 -70
- package/src/controls/MaterialNativeControl.tsx +54 -58
- package/src/controls/MaterialRadioGroup.tsx +67 -70
- package/src/controls/MaterialSliderControl.tsx +92 -88
- package/src/controls/MaterialTimeControl.tsx +128 -0
- package/src/controls/index.ts +7 -0
- package/src/extended/MuiAutocomplete.tsx +2 -3
- package/src/index.ts +6 -0
- package/src/layouts/ExpandPanelRenderer.tsx +32 -32
- package/src/layouts/MaterialArrayLayout.tsx +73 -83
- package/src/layouts/MaterialCategorizationLayout.tsx +49 -65
- package/src/layouts/MaterialCategorizationStepperLayout.tsx +79 -87
- package/src/mui-controls/MuiCheckbox.tsx +1 -2
- package/src/mui-controls/MuiInputInteger.tsx +12 -9
- package/src/mui-controls/MuiInputNumber.tsx +9 -6
- package/src/mui-controls/MuiInputNumberFormat.tsx +8 -11
- package/src/mui-controls/MuiInputText.tsx +17 -15
- package/src/mui-controls/MuiInputTime.tsx +6 -4
- package/src/mui-controls/MuiSelect.tsx +2 -3
- package/src/mui-controls/MuiToggle.tsx +1 -2
- package/src/util/datejs.ts +32 -0
- package/src/util/debounce.ts +43 -0
- package/src/util/focus.ts +32 -0
- package/src/util/index.ts +3 -0
- package/src/util/layout.tsx +6 -7
- package/test/renderers/MaterialAnyOfRenderer.test.tsx +14 -8
- package/test/renderers/MaterialArrayLayout.test.tsx +8 -8
- package/test/renderers/MaterialBooleanToggleControl.test.tsx +0 -1
- package/test/renderers/MaterialCategorizationLayout.test.tsx +73 -0
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +73 -0
- package/test/renderers/MaterialDateControl.test.tsx +42 -0
- package/test/renderers/MaterialDateTimeControl.test.tsx +54 -11
- package/test/renderers/MaterialInputControl.test.tsx +3 -3
- package/test/renderers/MaterialIntegerCell.test.tsx +41 -20
- package/test/renderers/MaterialNumberCell.test.tsx +45 -24
- package/test/renderers/MaterialOneOfEnumCell.test.tsx +93 -0
- package/test/renderers/MaterialOneOfRenderer.test.tsx +10 -7
- package/test/renderers/MaterialTextCell.test.tsx +41 -20
- package/test/renderers/MaterialTimeCell.test.tsx +41 -20
- package/test/renderers/MaterialTimeControl.test.tsx +378 -0
- package/docs/classes/materialarraylayout.html +0 -777
- package/docs/classes/materialcategorizationlayoutrenderer.html +0 -786
- package/docs/classes/materialcategorizationstepperlayoutrenderer.html +0 -762
- package/docs/classes/materialdatecontrol.html +0 -825
- package/docs/classes/materialdatetimecontrol.html +0 -825
- package/docs/classes/materialinputcontrol.html +0 -825
- package/docs/classes/materialnativecontrol.html +0 -825
- package/docs/classes/materialradiogroup.html +0 -825
- package/docs/classes/materialslidercontrol.html +0 -825
- package/docs/interfaces/datecontrol.html +0 -157
- package/docs/interfaces/materialarraylayoutstate.html +0 -157
- package/docs/interfaces/statepropsofdatecontrol.html +0 -468
|
@@ -0,0 +1,128 @@
|
|
|
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 React, { useMemo } from 'react';
|
|
26
|
+
import merge from 'lodash/merge';
|
|
27
|
+
import {
|
|
28
|
+
ControlProps,
|
|
29
|
+
isTimeControl,
|
|
30
|
+
isDescriptionHidden,
|
|
31
|
+
RankedTester,
|
|
32
|
+
rankWith
|
|
33
|
+
} from '@jsonforms/core';
|
|
34
|
+
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
35
|
+
import { FormHelperText, Hidden } from '@material-ui/core';
|
|
36
|
+
import {
|
|
37
|
+
KeyboardTimePicker,
|
|
38
|
+
MuiPickersUtilsProvider
|
|
39
|
+
} from '@material-ui/pickers';
|
|
40
|
+
import DayjsUtils from '@date-io/dayjs';
|
|
41
|
+
import { createOnChangeHandler, getData, useFocus } from '../util';
|
|
42
|
+
|
|
43
|
+
export const MaterialTimeControl = (props: ControlProps) => {
|
|
44
|
+
const [focused, onFocus, onBlur] = useFocus();
|
|
45
|
+
const {
|
|
46
|
+
id,
|
|
47
|
+
description,
|
|
48
|
+
errors,
|
|
49
|
+
label,
|
|
50
|
+
uischema,
|
|
51
|
+
visible,
|
|
52
|
+
enabled,
|
|
53
|
+
required,
|
|
54
|
+
path,
|
|
55
|
+
handleChange,
|
|
56
|
+
data,
|
|
57
|
+
config
|
|
58
|
+
} = props;
|
|
59
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
60
|
+
const isValid = errors.length === 0;
|
|
61
|
+
|
|
62
|
+
const showDescription = !isDescriptionHidden(
|
|
63
|
+
visible,
|
|
64
|
+
description,
|
|
65
|
+
focused,
|
|
66
|
+
appliedUiSchemaOptions.showUnfocusedDescription
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const format = appliedUiSchemaOptions.timeFormat ?? 'HH:mm';
|
|
70
|
+
const saveFormat = appliedUiSchemaOptions.timeSaveFormat ?? 'HH:mm:ss';
|
|
71
|
+
|
|
72
|
+
const firstFormHelperText = showDescription
|
|
73
|
+
? description
|
|
74
|
+
: !isValid
|
|
75
|
+
? errors
|
|
76
|
+
: null;
|
|
77
|
+
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
78
|
+
|
|
79
|
+
const onChange = useMemo(() => createOnChangeHandler(
|
|
80
|
+
path,
|
|
81
|
+
handleChange,
|
|
82
|
+
saveFormat
|
|
83
|
+
),[path, handleChange, saveFormat]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Hidden xsUp={!visible}>
|
|
87
|
+
<MuiPickersUtilsProvider utils={DayjsUtils}>
|
|
88
|
+
<KeyboardTimePicker
|
|
89
|
+
id={id + '-input'}
|
|
90
|
+
required={required && !appliedUiSchemaOptions.hideRequiredAsterisk}
|
|
91
|
+
label={label}
|
|
92
|
+
error={!isValid}
|
|
93
|
+
fullWidth={!appliedUiSchemaOptions.trim}
|
|
94
|
+
onFocus={onFocus}
|
|
95
|
+
onBlur={onBlur}
|
|
96
|
+
InputLabelProps={data ? { shrink: true } : undefined}
|
|
97
|
+
value={getData(data, saveFormat)}
|
|
98
|
+
clearable
|
|
99
|
+
onChange={onChange}
|
|
100
|
+
format={format}
|
|
101
|
+
ampm={!!appliedUiSchemaOptions.ampm}
|
|
102
|
+
views={appliedUiSchemaOptions.views}
|
|
103
|
+
disabled={!enabled}
|
|
104
|
+
autoFocus={appliedUiSchemaOptions.focus}
|
|
105
|
+
cancelLabel={appliedUiSchemaOptions.cancelLabel}
|
|
106
|
+
clearLabel={appliedUiSchemaOptions.clearLabel}
|
|
107
|
+
okLabel={appliedUiSchemaOptions.okLabel}
|
|
108
|
+
invalidDateMessage={null}
|
|
109
|
+
maxDateMessage={null}
|
|
110
|
+
minDateMessage={null}
|
|
111
|
+
/>
|
|
112
|
+
<FormHelperText error={!isValid && !showDescription}>
|
|
113
|
+
{firstFormHelperText}
|
|
114
|
+
</FormHelperText>
|
|
115
|
+
<FormHelperText error={!isValid}>
|
|
116
|
+
{secondFormHelperText}
|
|
117
|
+
</FormHelperText>
|
|
118
|
+
</MuiPickersUtilsProvider>
|
|
119
|
+
</Hidden>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const materialTimeControlTester: RankedTester = rankWith(
|
|
124
|
+
4,
|
|
125
|
+
isTimeControl
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
export default withJsonFormsControlProps(MaterialTimeControl);
|
package/src/controls/index.ts
CHANGED
|
@@ -46,6 +46,10 @@ import MaterialDateTimeControl, {
|
|
|
46
46
|
materialDateTimeControlTester,
|
|
47
47
|
MaterialDateTimeControl as MaterialDateTimeControlUnwrapped
|
|
48
48
|
} from './MaterialDateTimeControl';
|
|
49
|
+
import MaterialTimeControl, {
|
|
50
|
+
materialTimeControlTester,
|
|
51
|
+
MaterialTimeControl as MaterialTimeControlUnwrapped
|
|
52
|
+
} from './MaterialTimeControl';
|
|
49
53
|
import MaterialSliderControl, {
|
|
50
54
|
materialSliderControlTester,
|
|
51
55
|
MaterialSliderControl as MaterialSliderControlUnwrapped
|
|
@@ -89,6 +93,7 @@ export const Unwrapped = {
|
|
|
89
93
|
MaterialNativeControl: MaterialNativeControlUnwrapped,
|
|
90
94
|
MaterialDateControl: MaterialDateControlUnwrapped,
|
|
91
95
|
MaterialDateTimeControl: MaterialDateTimeControlUnwrapped,
|
|
96
|
+
MaterialTimeControl: MaterialTimeControlUnwrapped,
|
|
92
97
|
MaterialSliderControl: MaterialSliderControlUnwrapped,
|
|
93
98
|
MaterialRadioGroupControl: MaterialRadioGroupControlUnwrapped,
|
|
94
99
|
MaterialIntegerControl: MaterialIntegerControlUnwrapped,
|
|
@@ -112,6 +117,8 @@ export {
|
|
|
112
117
|
materialDateControlTester,
|
|
113
118
|
MaterialDateTimeControl,
|
|
114
119
|
materialDateTimeControlTester,
|
|
120
|
+
MaterialTimeControl,
|
|
121
|
+
materialTimeControlTester,
|
|
115
122
|
MaterialSliderControl,
|
|
116
123
|
materialSliderControlTester,
|
|
117
124
|
MaterialRadioGroupControl,
|
|
@@ -27,7 +27,6 @@ import { EnumCellProps, EnumOption, WithClassname } from '@jsonforms/core';
|
|
|
27
27
|
|
|
28
28
|
import Input from '@material-ui/core/Input';
|
|
29
29
|
import Autocomplete, { AutocompleteRenderOptionState } from '@material-ui/lab/Autocomplete';
|
|
30
|
-
import { areEqual } from '@jsonforms/react';
|
|
31
30
|
import merge from 'lodash/merge';
|
|
32
31
|
import { FilterOptionsState } from '@material-ui/lab/useAutocomplete';
|
|
33
32
|
|
|
@@ -37,7 +36,7 @@ export interface WithOptionLabel {
|
|
|
37
36
|
filterOptions?(options: EnumOption[], state: FilterOptionsState<EnumOption>) : EnumOption[];
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
export const MuiAutocomplete =
|
|
39
|
+
export const MuiAutocomplete = (props: EnumCellProps & WithClassname & WithOptionLabel) => {
|
|
41
40
|
const {
|
|
42
41
|
data,
|
|
43
42
|
className,
|
|
@@ -90,4 +89,4 @@ export const MuiAutocomplete = React.memo((props: EnumCellProps & WithClassname
|
|
|
90
89
|
filterOptions={filterOptions}
|
|
91
90
|
/>
|
|
92
91
|
);
|
|
93
|
-
}
|
|
92
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -57,6 +57,8 @@ import {
|
|
|
57
57
|
materialDateControlTester,
|
|
58
58
|
MaterialDateTimeControl,
|
|
59
59
|
materialDateTimeControlTester,
|
|
60
|
+
MaterialTimeControl,
|
|
61
|
+
materialTimeControlTester,
|
|
60
62
|
MaterialEnumControl,
|
|
61
63
|
materialEnumControlTester,
|
|
62
64
|
MaterialIntegerControl,
|
|
@@ -103,6 +105,8 @@ import {
|
|
|
103
105
|
materialNumberCellTester,
|
|
104
106
|
MaterialNumberFormatCell,
|
|
105
107
|
materialNumberFormatCellTester,
|
|
108
|
+
MaterialOneOfEnumCell,
|
|
109
|
+
materialOneOfEnumCellTester,
|
|
106
110
|
MaterialTextCell,
|
|
107
111
|
materialTextCellTester,
|
|
108
112
|
MaterialTimeCell,
|
|
@@ -134,6 +138,7 @@ export const materialRenderers: JsonFormsRendererRegistryEntry[] = [
|
|
|
134
138
|
{ tester: materialTextControlTester, renderer: MaterialTextControl },
|
|
135
139
|
{ tester: materialDateTimeControlTester, renderer: MaterialDateTimeControl },
|
|
136
140
|
{ tester: materialDateControlTester, renderer: MaterialDateControl },
|
|
141
|
+
{ tester: materialTimeControlTester, renderer: MaterialTimeControl },
|
|
137
142
|
{ tester: materialSliderControlTester, renderer: MaterialSliderControl },
|
|
138
143
|
{ tester: materialObjectControlTester, renderer: MaterialObjectRenderer },
|
|
139
144
|
{ tester: materialAllOfControlTester, renderer: MaterialAllOfRenderer },
|
|
@@ -188,6 +193,7 @@ export const materialCells: JsonFormsCellRendererRegistryEntry[] = [
|
|
|
188
193
|
{ tester: materialIntegerCellTester, cell: MaterialIntegerCell },
|
|
189
194
|
{ tester: materialNumberCellTester, cell: MaterialNumberCell },
|
|
190
195
|
{ tester: materialNumberFormatCellTester, cell: MaterialNumberFormatCell },
|
|
196
|
+
{ tester: materialOneOfEnumCellTester, cell: MaterialOneOfEnumCell },
|
|
191
197
|
{ tester: materialTextCellTester, cell: MaterialTextCell },
|
|
192
198
|
{ tester: materialTimeCellTester, cell: MaterialTimeCell }
|
|
193
199
|
];
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
-
import React, { Dispatch, Fragment, ReducerAction, useMemo, useState } from 'react';
|
|
4
|
-
import { ComponentType } from 'enzyme';
|
|
3
|
+
import React, { ComponentType, Dispatch, Fragment, ReducerAction, useMemo, useState, useEffect, useCallback } from 'react';
|
|
5
4
|
import {
|
|
6
|
-
|
|
7
|
-
ResolvedJsonFormsDispatch,
|
|
5
|
+
JsonFormsDispatch,
|
|
8
6
|
JsonFormsStateContext,
|
|
9
7
|
withJsonFormsContext
|
|
10
8
|
} from '@jsonforms/react';
|
|
@@ -20,19 +18,20 @@ import {
|
|
|
20
18
|
update,
|
|
21
19
|
JsonFormsCellRendererRegistryEntry,
|
|
22
20
|
JsonFormsUISchemaRegistryEntry,
|
|
23
|
-
getFirstPrimitiveProp
|
|
21
|
+
getFirstPrimitiveProp,
|
|
22
|
+
createId,
|
|
23
|
+
removeId
|
|
24
24
|
} from '@jsonforms/core';
|
|
25
|
-
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
|
|
26
25
|
import IconButton from '@material-ui/core/IconButton';
|
|
27
|
-
import
|
|
28
|
-
import
|
|
26
|
+
import Accordion from '@material-ui/core/Accordion';
|
|
27
|
+
import AccordionSummary from '@material-ui/core/AccordionSummary';
|
|
28
|
+
import AccordionDetails from '@material-ui/core/AccordionDetails';
|
|
29
29
|
import { Grid } from '@material-ui/core';
|
|
30
30
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
31
31
|
import Avatar from '@material-ui/core/Avatar';
|
|
32
32
|
import DeleteIcon from '@material-ui/icons/Delete';
|
|
33
33
|
import ArrowUpward from '@material-ui/icons/ArrowUpward';
|
|
34
34
|
import ArrowDownward from '@material-ui/icons/ArrowDownward';
|
|
35
|
-
import uuid from 'uuid/v1';
|
|
36
35
|
|
|
37
36
|
const iconStyle: any = { float: 'right' };
|
|
38
37
|
|
|
@@ -73,8 +72,14 @@ export interface ExpandPanelProps
|
|
|
73
72
|
extends StatePropsOfExpandPanel,
|
|
74
73
|
DispatchPropsOfExpandPanel {}
|
|
75
74
|
|
|
76
|
-
const
|
|
77
|
-
const [labelHtmlId] = useState(
|
|
75
|
+
const ExpandPanelRendererComponent = (props: ExpandPanelProps) => {
|
|
76
|
+
const [labelHtmlId] = useState<string>(createId('expand-panel'));
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
return () => {
|
|
80
|
+
removeId(labelHtmlId);
|
|
81
|
+
};
|
|
82
|
+
}, [labelHtmlId]);
|
|
78
83
|
|
|
79
84
|
const {
|
|
80
85
|
childLabel,
|
|
@@ -114,12 +119,12 @@ const ExpandPanelRenderer = (props: ExpandPanelProps) => {
|
|
|
114
119
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
115
120
|
|
|
116
121
|
return (
|
|
117
|
-
<
|
|
122
|
+
<Accordion
|
|
118
123
|
aria-labelledby={labelHtmlId}
|
|
119
124
|
expanded={expanded}
|
|
120
125
|
onChange={handleExpansion(childPath)}
|
|
121
126
|
>
|
|
122
|
-
<
|
|
127
|
+
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
|
123
128
|
<Grid container alignItems={'center'}>
|
|
124
129
|
<Grid item xs={7} md={9}>
|
|
125
130
|
<Grid container alignItems={'center'}>
|
|
@@ -180,9 +185,9 @@ const ExpandPanelRenderer = (props: ExpandPanelProps) => {
|
|
|
180
185
|
</Grid>
|
|
181
186
|
</Grid>
|
|
182
187
|
</Grid>
|
|
183
|
-
</
|
|
184
|
-
<
|
|
185
|
-
<
|
|
188
|
+
</AccordionSummary>
|
|
189
|
+
<AccordionDetails>
|
|
190
|
+
<JsonFormsDispatch
|
|
186
191
|
schema={schema}
|
|
187
192
|
uischema={foundUISchema}
|
|
188
193
|
path={childPath}
|
|
@@ -190,11 +195,13 @@ const ExpandPanelRenderer = (props: ExpandPanelProps) => {
|
|
|
190
195
|
renderers={renderers}
|
|
191
196
|
cells={cells}
|
|
192
197
|
/>
|
|
193
|
-
</
|
|
194
|
-
</
|
|
198
|
+
</AccordionDetails>
|
|
199
|
+
</Accordion>
|
|
195
200
|
);
|
|
196
201
|
};
|
|
197
202
|
|
|
203
|
+
const ExpandPanelRenderer = React.memo(ExpandPanelRendererComponent);
|
|
204
|
+
|
|
198
205
|
/**
|
|
199
206
|
* Maps state to dispatch properties of an expand pandel control.
|
|
200
207
|
*
|
|
@@ -204,7 +211,7 @@ const ExpandPanelRenderer = (props: ExpandPanelProps) => {
|
|
|
204
211
|
export const ctxDispatchToExpandPanelProps: (
|
|
205
212
|
dispatch: Dispatch<ReducerAction<any>>
|
|
206
213
|
) => DispatchPropsOfExpandPanel = dispatch => ({
|
|
207
|
-
removeItems: (path: string, toDelete: number[]) => (event: any): void => {
|
|
214
|
+
removeItems: useCallback((path: string, toDelete: number[]) => (event: any): void => {
|
|
208
215
|
event.stopPropagation();
|
|
209
216
|
dispatch(
|
|
210
217
|
update(path, array => {
|
|
@@ -215,8 +222,8 @@ export const ctxDispatchToExpandPanelProps: (
|
|
|
215
222
|
return array;
|
|
216
223
|
})
|
|
217
224
|
);
|
|
218
|
-
},
|
|
219
|
-
moveUp: (path: string, toMove: number) => (event: any): void => {
|
|
225
|
+
}, [dispatch]),
|
|
226
|
+
moveUp: useCallback((path: string, toMove: number) => (event: any): void => {
|
|
220
227
|
event.stopPropagation();
|
|
221
228
|
dispatch(
|
|
222
229
|
update(path, array => {
|
|
@@ -224,8 +231,8 @@ export const ctxDispatchToExpandPanelProps: (
|
|
|
224
231
|
return array;
|
|
225
232
|
})
|
|
226
233
|
);
|
|
227
|
-
},
|
|
228
|
-
moveDown: (path: string, toMove: number) => (event: any): void => {
|
|
234
|
+
}, [dispatch]),
|
|
235
|
+
moveDown: useCallback((path: string, toMove: number) => (event: any): void => {
|
|
229
236
|
event.stopPropagation();
|
|
230
237
|
dispatch(
|
|
231
238
|
update(path, array => {
|
|
@@ -233,7 +240,7 @@ export const ctxDispatchToExpandPanelProps: (
|
|
|
233
240
|
return array;
|
|
234
241
|
})
|
|
235
242
|
);
|
|
236
|
-
}
|
|
243
|
+
}, [dispatch])
|
|
237
244
|
});
|
|
238
245
|
|
|
239
246
|
/**
|
|
@@ -271,13 +278,6 @@ export const withJsonFormsExpandPanelProps = (
|
|
|
271
278
|
Component: ComponentType<ExpandPanelProps>
|
|
272
279
|
): ComponentType<OwnPropsOfExpandPanel> =>
|
|
273
280
|
withJsonFormsContext(
|
|
274
|
-
withContextToExpandPanelProps(
|
|
275
|
-
React.memo(
|
|
276
|
-
Component,
|
|
277
|
-
(prevProps: ExpandPanelProps, nextProps: ExpandPanelProps) =>
|
|
278
|
-
areEqual(prevProps, nextProps)
|
|
279
|
-
)
|
|
280
|
-
)
|
|
281
|
-
);
|
|
281
|
+
withContextToExpandPanelProps(Component));
|
|
282
282
|
|
|
283
283
|
export default withJsonFormsExpandPanelProps(ExpandPanelRenderer);
|
|
@@ -23,100 +23,90 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import range from 'lodash/range';
|
|
26
|
-
import React from 'react';
|
|
26
|
+
import React, {useState, useCallback} from 'react';
|
|
27
27
|
import {
|
|
28
28
|
ArrayLayoutProps,
|
|
29
29
|
composePaths,
|
|
30
30
|
computeLabel,
|
|
31
31
|
createDefaultValue,
|
|
32
|
-
isPlainLabel
|
|
33
32
|
} from '@jsonforms/core';
|
|
34
33
|
import map from 'lodash/map';
|
|
35
34
|
import { ArrayLayoutToolbar } from './ArrayToolbar';
|
|
36
35
|
import ExpandPanelRenderer from './ExpandPanelRenderer';
|
|
37
36
|
import merge from 'lodash/merge';
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
expanded
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
required,
|
|
69
|
-
rootSchema,
|
|
70
|
-
config,
|
|
71
|
-
uischemas
|
|
72
|
-
} = this.props;
|
|
73
|
-
const appliedUiSchemaOptions = merge(
|
|
74
|
-
{},
|
|
75
|
-
config,
|
|
76
|
-
this.props.uischema.options
|
|
77
|
-
);
|
|
38
|
+
const MaterialArrayLayoutComponent = (props: ArrayLayoutProps)=> {
|
|
39
|
+
const [expanded, setExpanded] = useState<string|boolean>(false);
|
|
40
|
+
const innerCreateDefaultValue = useCallback(() => createDefaultValue(props.schema), [props.schema]);
|
|
41
|
+
const handleChange = useCallback((panel: string) => (_event: any, expandedPanel: boolean) => {
|
|
42
|
+
setExpanded(expandedPanel ? panel : false)
|
|
43
|
+
}, []);
|
|
44
|
+
const isExpanded = (index: number) =>
|
|
45
|
+
expanded === composePaths(props.path, `${index}`);
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
data,
|
|
49
|
+
path,
|
|
50
|
+
schema,
|
|
51
|
+
uischema,
|
|
52
|
+
errors,
|
|
53
|
+
addItem,
|
|
54
|
+
renderers,
|
|
55
|
+
cells,
|
|
56
|
+
label,
|
|
57
|
+
required,
|
|
58
|
+
rootSchema,
|
|
59
|
+
config,
|
|
60
|
+
uischemas
|
|
61
|
+
} = props;
|
|
62
|
+
const appliedUiSchemaOptions = merge(
|
|
63
|
+
{},
|
|
64
|
+
config,
|
|
65
|
+
props.uischema.options
|
|
66
|
+
);
|
|
78
67
|
|
|
79
|
-
|
|
68
|
+
return (
|
|
69
|
+
<div>
|
|
70
|
+
<ArrayLayoutToolbar
|
|
71
|
+
label={computeLabel(
|
|
72
|
+
label,
|
|
73
|
+
required,
|
|
74
|
+
appliedUiSchemaOptions.hideRequiredAsterisk
|
|
75
|
+
)}
|
|
76
|
+
errors={errors}
|
|
77
|
+
path={path}
|
|
78
|
+
addItem={addItem}
|
|
79
|
+
createDefault={innerCreateDefaultValue}
|
|
80
|
+
/>
|
|
80
81
|
<div>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
rootSchema={rootSchema}
|
|
107
|
-
enableMoveUp={index != 0}
|
|
108
|
-
enableMoveDown={index < data - 1}
|
|
109
|
-
config={config}
|
|
110
|
-
childLabelProp={appliedUiSchemaOptions.elementLabelProp}
|
|
111
|
-
uischemas={uischemas}
|
|
112
|
-
/>
|
|
113
|
-
);
|
|
114
|
-
})
|
|
115
|
-
) : (
|
|
116
|
-
<p>No data</p>
|
|
117
|
-
)}
|
|
118
|
-
</div>
|
|
82
|
+
{data > 0 ? (
|
|
83
|
+
map(range(data), index => {
|
|
84
|
+
return (
|
|
85
|
+
<ExpandPanelRenderer
|
|
86
|
+
index={index}
|
|
87
|
+
expanded={isExpanded(index)}
|
|
88
|
+
schema={schema}
|
|
89
|
+
path={path}
|
|
90
|
+
handleExpansion={handleChange}
|
|
91
|
+
uischema={uischema}
|
|
92
|
+
renderers={renderers}
|
|
93
|
+
cells={cells}
|
|
94
|
+
key={index}
|
|
95
|
+
rootSchema={rootSchema}
|
|
96
|
+
enableMoveUp={index != 0}
|
|
97
|
+
enableMoveDown={index < data - 1}
|
|
98
|
+
config={config}
|
|
99
|
+
childLabelProp={appliedUiSchemaOptions.elementLabelProp}
|
|
100
|
+
uischemas={uischemas}
|
|
101
|
+
/>
|
|
102
|
+
);
|
|
103
|
+
})
|
|
104
|
+
) : (
|
|
105
|
+
<p>No data</p>
|
|
106
|
+
)}
|
|
119
107
|
</div>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const MaterialArrayLayout = React.memo(MaterialArrayLayoutComponent);
|
|
@@ -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 from 'react';
|
|
25
|
+
import React, {useState} from 'react';
|
|
26
26
|
import { Hidden, Tab, Tabs } from '@material-ui/core';
|
|
27
27
|
import AppBar from '@material-ui/core/AppBar';
|
|
28
28
|
import {
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
UISchemaElement,
|
|
38
38
|
uiTypeIs
|
|
39
39
|
} from '@jsonforms/core';
|
|
40
|
-
import {
|
|
40
|
+
import { withJsonFormsLayoutProps } from '@jsonforms/react';
|
|
41
41
|
import {
|
|
42
42
|
AjvProps,
|
|
43
43
|
MaterialLayoutRenderer,
|
|
@@ -76,71 +76,55 @@ export interface MaterialCategorizationLayoutRendererProps
|
|
|
76
76
|
onChange?(selected: number, prevSelected: number): void;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
export const MaterialCategorizationLayoutRenderer = (props: MaterialCategorizationLayoutRendererProps) => {
|
|
80
|
+
const {
|
|
81
|
+
data,
|
|
82
|
+
path,
|
|
83
|
+
renderers,
|
|
84
|
+
cells,
|
|
85
|
+
schema,
|
|
86
|
+
uischema,
|
|
87
|
+
visible,
|
|
88
|
+
enabled,
|
|
89
|
+
selected,
|
|
90
|
+
onChange,
|
|
91
|
+
ajv
|
|
92
|
+
} = props;
|
|
93
|
+
const categorization = uischema as Categorization;
|
|
94
|
+
const [activeCategory, setActiveCategory]= useState<number|undefined>(selected??0);
|
|
95
|
+
const categories = categorization.elements.filter((category: Category) =>
|
|
96
|
+
isVisible(category, data, undefined, ajv)
|
|
97
|
+
);
|
|
98
|
+
const childProps: MaterialLayoutRendererProps = {
|
|
99
|
+
elements: categories[activeCategory].elements,
|
|
100
|
+
schema,
|
|
101
|
+
path,
|
|
102
|
+
direction: 'column',
|
|
103
|
+
enabled,
|
|
104
|
+
visible,
|
|
105
|
+
renderers,
|
|
106
|
+
cells
|
|
85
107
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
data,
|
|
90
|
-
path,
|
|
91
|
-
renderers,
|
|
92
|
-
cells,
|
|
93
|
-
schema,
|
|
94
|
-
uischema,
|
|
95
|
-
visible,
|
|
96
|
-
enabled,
|
|
97
|
-
selected,
|
|
98
|
-
ajv
|
|
99
|
-
} = this.props;
|
|
100
|
-
const categorization = uischema as Categorization;
|
|
101
|
-
const value = this.hasOwnState() ? this.state.activeCategory : selected;
|
|
102
|
-
const childProps: MaterialLayoutRendererProps = {
|
|
103
|
-
elements: categorization.elements[value].elements,
|
|
104
|
-
schema,
|
|
105
|
-
path,
|
|
106
|
-
direction: 'column',
|
|
107
|
-
enabled,
|
|
108
|
-
visible,
|
|
109
|
-
renderers,
|
|
110
|
-
cells
|
|
111
|
-
};
|
|
112
|
-
const categories = categorization.elements.filter((category: Category) =>
|
|
113
|
-
isVisible(category, data, undefined, ajv)
|
|
114
|
-
);
|
|
115
|
-
return (
|
|
116
|
-
<Hidden xsUp={!visible}>
|
|
117
|
-
<AppBar position='static'>
|
|
118
|
-
<Tabs value={value} onChange={this.handleChange} variant='scrollable'>
|
|
119
|
-
{categories.map((e: Category, idx: number) => (
|
|
120
|
-
<Tab key={idx} label={e.label} />
|
|
121
|
-
))}
|
|
122
|
-
</Tabs>
|
|
123
|
-
</AppBar>
|
|
124
|
-
<div style={{ marginTop: '0.5em' }}>
|
|
125
|
-
<MaterialLayoutRenderer {...childProps} />
|
|
126
|
-
</div>
|
|
127
|
-
</Hidden>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
hasOwnState = () => {
|
|
132
|
-
return this.props.ownState !== undefined ? this.props.ownState : true;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
private handleChange = (_event: any, value: any) => {
|
|
136
|
-
if (this.props.onChange) {
|
|
137
|
-
this.props.onChange(value, this.state.activeCategory);
|
|
138
|
-
}
|
|
139
|
-
const hasOwnState = this.hasOwnState();
|
|
140
|
-
if (hasOwnState) {
|
|
141
|
-
this.setState({ activeCategory: value });
|
|
108
|
+
const onTabChange = (_event: any, value: any) => {
|
|
109
|
+
if (onChange) {
|
|
110
|
+
onChange(value, activeCategory);
|
|
142
111
|
}
|
|
112
|
+
setActiveCategory(value);
|
|
143
113
|
};
|
|
144
|
-
|
|
114
|
+
return (
|
|
115
|
+
<Hidden xsUp={!visible}>
|
|
116
|
+
<AppBar position='static'>
|
|
117
|
+
<Tabs value={activeCategory} onChange={onTabChange} variant='scrollable'>
|
|
118
|
+
{categories.map((e: Category, idx: number) => (
|
|
119
|
+
<Tab key={idx} label={e.label} />
|
|
120
|
+
))}
|
|
121
|
+
</Tabs>
|
|
122
|
+
</AppBar>
|
|
123
|
+
<div style={{ marginTop: '0.5em' }}>
|
|
124
|
+
<MaterialLayoutRenderer {...childProps} />
|
|
125
|
+
</div>
|
|
126
|
+
</Hidden>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
145
129
|
|
|
146
130
|
export default withJsonFormsLayoutProps(withAjvProps(MaterialCategorizationLayoutRenderer));
|