@jsonforms/material-renderers 2.5.2 → 3.0.0-alpha.3
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 +1040 -328
- package/docs/index.html +84 -51
- package/docs/interfaces/ajvprops.html +1 -4
- package/docs/interfaces/arraylayouttoolbarprops.html +5 -8
- package/docs/interfaces/categorizationstate.html +1 -4
- 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 +39 -49
- package/docs/interfaces/materialcategorizationlayoutrendererprops.html +11 -14
- 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 +2 -5
- package/docs/interfaces/withdeletedialogsupport.html +0 -3
- package/docs/interfaces/withinput.html +1 -4
- package/docs/interfaces/withoptionlabel.html +7 -7
- package/example/index.ts +5 -20
- package/lib/additional/ListWithDetailMasterItem.d.ts +1 -1
- package/lib/additional/ListWithDetailMasterItem.js +8 -8
- package/lib/additional/ListWithDetailMasterItem.js.map +1 -1
- package/lib/additional/MaterialLabelRenderer.d.ts +1 -1
- package/lib/additional/MaterialLabelRenderer.js +6 -4
- package/lib/additional/MaterialLabelRenderer.js.map +1 -1
- package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
- package/lib/additional/MaterialListWithDetailRenderer.js +10 -8
- 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 +4 -2
- 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 +9 -9
- package/lib/complex/DeleteDialog.js.map +1 -1
- package/lib/complex/MaterialAllOfRenderer.d.ts +3 -2
- package/lib/complex/MaterialAllOfRenderer.js +12 -10
- package/lib/complex/MaterialAllOfRenderer.js.map +1 -1
- package/lib/complex/MaterialAnyOfRenderer.d.ts +3 -2
- package/lib/complex/MaterialAnyOfRenderer.js +7 -5
- package/lib/complex/MaterialAnyOfRenderer.js.map +1 -1
- package/lib/complex/MaterialArrayControlRenderer.d.ts +1 -1
- package/lib/complex/MaterialArrayControlRenderer.js +5 -3
- package/lib/complex/MaterialArrayControlRenderer.js.map +1 -1
- package/lib/complex/MaterialEnumArrayRenderer.d.ts +2 -2
- package/lib/complex/MaterialEnumArrayRenderer.js +12 -9
- package/lib/complex/MaterialEnumArrayRenderer.js.map +1 -1
- package/lib/complex/MaterialObjectRenderer.d.ts +3 -2
- package/lib/complex/MaterialObjectRenderer.js +7 -5
- package/lib/complex/MaterialObjectRenderer.js.map +1 -1
- package/lib/complex/MaterialOneOfRenderer.d.ts +2 -1
- package/lib/complex/MaterialOneOfRenderer.js +16 -15
- package/lib/complex/MaterialOneOfRenderer.js.map +1 -1
- package/lib/complex/MaterialTableControl.d.ts +16 -1
- package/lib/complex/MaterialTableControl.js +42 -35
- package/lib/complex/MaterialTableControl.js.map +1 -1
- package/lib/complex/NoBorderTableCell.d.ts +2 -2
- package/lib/complex/NoBorderTableCell.js +8 -10
- package/lib/complex/NoBorderTableCell.js.map +1 -1
- package/lib/complex/TableToolbar.d.ts +2 -2
- package/lib/complex/TableToolbar.js +12 -14
- package/lib/complex/TableToolbar.js.map +1 -1
- package/lib/complex/ValidationIcon.d.ts +2 -6
- package/lib/complex/ValidationIcon.js +9 -13
- 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 +18 -13
- package/lib/controls/MaterialAnyOfStringOrEnumControl.js.map +1 -1
- package/lib/controls/MaterialBooleanControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanControl.js +6 -4
- package/lib/controls/MaterialBooleanControl.js.map +1 -1
- package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanToggleControl.js +6 -4
- package/lib/controls/MaterialBooleanToggleControl.js.map +1 -1
- package/lib/controls/MaterialDateControl.d.ts +3 -15
- package/lib/controls/MaterialDateControl.js +29 -50
- package/lib/controls/MaterialDateControl.js.map +1 -1
- package/lib/controls/MaterialDateTimeControl.d.ts +3 -6
- package/lib/controls/MaterialDateTimeControl.js +29 -31
- 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 +25 -30
- 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 +16 -20
- 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 +16 -23
- 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 +36 -40
- 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 +3 -4
- package/lib/extended/MuiAutocomplete.js +7 -7
- package/lib/extended/MuiAutocomplete.js.map +1 -1
- package/lib/extended/index.d.ts +3 -3
- package/lib/extended/index.js +3 -2
- 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 +248 -315
- package/lib/jsonforms-material.js.map +1 -1
- package/lib/layouts/ArrayToolbar.js +14 -16
- package/lib/layouts/ArrayToolbar.js.map +1 -1
- package/lib/layouts/ExpandPanelRenderer.d.ts +2 -3
- package/lib/layouts/ExpandPanelRenderer.js +47 -45
- 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 +5 -3
- package/lib/layouts/MaterialArrayLayoutRenderer.js.map +1 -1
- package/lib/layouts/MaterialCategorizationLayout.d.ts +2 -10
- package/lib/layouts/MaterialCategorizationLayout.js +35 -52
- package/lib/layouts/MaterialCategorizationLayout.js.map +1 -1
- package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +2 -9
- package/lib/layouts/MaterialCategorizationStepperLayout.js +45 -56
- package/lib/layouts/MaterialCategorizationStepperLayout.js.map +1 -1
- package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
- package/lib/layouts/MaterialGroupLayout.js +11 -9
- 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 +4 -4
- package/lib/mui-controls/MuiCheckbox.js.map +1 -1
- package/lib/mui-controls/MuiInputInteger.js +10 -7
- package/lib/mui-controls/MuiInputInteger.js.map +1 -1
- package/lib/mui-controls/MuiInputNumber.js +10 -7
- package/lib/mui-controls/MuiInputNumber.js.map +1 -1
- package/lib/mui-controls/MuiInputNumberFormat.js +8 -9
- package/lib/mui-controls/MuiInputNumberFormat.js.map +1 -1
- package/lib/mui-controls/MuiInputText.d.ts +1 -1
- package/lib/mui-controls/MuiInputText.js +17 -13
- package/lib/mui-controls/MuiInputText.js.map +1 -1
- package/lib/mui-controls/MuiInputTime.js +6 -4
- package/lib/mui-controls/MuiInputTime.js.map +1 -1
- package/lib/mui-controls/MuiSelect.js +4 -5
- package/lib/mui-controls/MuiSelect.js.map +1 -1
- package/lib/mui-controls/MuiToggle.js +4 -4
- 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 +13 -9
- package/lib/util/layout.js.map +1 -1
- package/lib/util/theme.d.ts +1 -1
- package/package.json +22 -26
- package/src/additional/ListWithDetailMasterItem.tsx +3 -6
- package/src/additional/MaterialLabelRenderer.tsx +1 -1
- package/src/additional/MaterialListWithDetailRenderer.tsx +4 -5
- package/src/cells/CustomizableCells.ts +1 -0
- package/src/cells/MaterialDateCell.tsx +1 -1
- 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/DeleteDialog.tsx +2 -2
- package/src/complex/MaterialAllOfRenderer.tsx +6 -5
- package/src/complex/MaterialAnyOfRenderer.tsx +5 -4
- package/src/complex/MaterialArrayControlRenderer.tsx +1 -1
- package/src/complex/MaterialEnumArrayRenderer.tsx +2 -1
- package/src/complex/MaterialObjectRenderer.tsx +6 -6
- package/src/complex/MaterialOneOfRenderer.tsx +9 -9
- package/src/complex/MaterialTableControl.tsx +45 -37
- package/src/complex/NoBorderTableCell.tsx +10 -12
- package/src/complex/TableToolbar.tsx +10 -9
- package/src/complex/ValidationIcon.tsx +12 -19
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +17 -14
- package/src/controls/MaterialBooleanControl.tsx +1 -1
- package/src/controls/MaterialBooleanToggleControl.tsx +1 -1
- package/src/controls/MaterialDateControl.tsx +87 -119
- package/src/controls/MaterialDateTimeControl.tsx +91 -78
- package/src/controls/MaterialEnumControl.tsx +1 -1
- package/src/controls/MaterialInputControl.tsx +65 -72
- package/src/controls/MaterialNativeControl.tsx +55 -60
- package/src/controls/MaterialOneOfEnumControl.tsx +1 -1
- package/src/controls/MaterialOneOfRadioGroupControl.tsx +4 -4
- package/src/controls/MaterialRadioGroup.tsx +73 -74
- package/src/controls/MaterialRadioGroupControl.tsx +1 -1
- package/src/controls/MaterialSliderControl.tsx +93 -89
- package/src/controls/MaterialTimeControl.tsx +133 -0
- package/src/controls/index.ts +7 -0
- package/src/extended/MuiAutocomplete.tsx +11 -9
- package/src/extended/index.ts +1 -1
- package/src/index.ts +6 -0
- package/src/layouts/ArrayToolbar.tsx +11 -7
- package/src/layouts/ExpandPanelRenderer.tsx +46 -44
- package/src/layouts/MaterialArrayLayout.tsx +73 -83
- package/src/layouts/MaterialArrayLayoutRenderer.tsx +1 -1
- package/src/layouts/MaterialCategorizationLayout.tsx +50 -67
- package/src/layouts/MaterialCategorizationStepperLayout.tsx +80 -88
- package/src/layouts/MaterialGroupLayout.tsx +1 -1
- package/src/mui-controls/MuiCheckbox.tsx +2 -3
- package/src/mui-controls/MuiInputInteger.tsx +13 -10
- package/src/mui-controls/MuiInputNumber.tsx +10 -7
- package/src/mui-controls/MuiInputNumberFormat.tsx +9 -12
- package/src/mui-controls/MuiInputText.tsx +30 -21
- package/src/mui-controls/MuiInputTime.tsx +7 -5
- package/src/mui-controls/MuiSelect.tsx +4 -5
- package/src/mui-controls/MuiToggle.tsx +2 -3
- 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 +7 -8
- package/src/util/theme.ts +1 -1
- package/test/renderers/MaterialAllOfRenderer.test.tsx +1 -1
- package/test/renderers/MaterialAnyOfRenderer.test.tsx +15 -9
- package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +1 -1
- package/test/renderers/MaterialArrayControl.test.tsx +1 -1
- package/test/renderers/MaterialArrayLayout.test.tsx +9 -9
- package/test/renderers/MaterialBooleanCell.test.tsx +1 -1
- package/test/renderers/MaterialBooleanToggleCell.test.tsx +3 -2
- package/test/renderers/MaterialBooleanToggleControl.test.tsx +3 -3
- package/test/renderers/MaterialCategorizationLayout.test.tsx +75 -2
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +75 -2
- package/test/renderers/MaterialDateCell.test.tsx +1 -1
- package/test/renderers/MaterialDateControl.test.tsx +46 -2
- package/test/renderers/MaterialDateTimeControl.test.tsx +57 -12
- package/test/renderers/MaterialEnumArrayRenderer.test.tsx +1 -1
- package/test/renderers/MaterialEnumCell.test.tsx +1 -1
- package/test/renderers/MaterialGroupLayout.test.tsx +1 -1
- package/test/renderers/MaterialInputControl.test.tsx +4 -4
- package/test/renderers/MaterialIntegerCell.test.tsx +42 -21
- package/test/renderers/MaterialLabelRenderer.test.tsx +1 -1
- package/test/renderers/MaterialLayouts.test.tsx +1 -1
- package/test/renderers/MaterialListWithDetailRenderer.test.tsx +2 -2
- package/test/renderers/MaterialNativeControl.test.tsx +2 -2
- package/test/renderers/MaterialNumberCell.test.tsx +46 -25
- package/test/renderers/MaterialObjectControl.test.tsx +1 -1
- package/test/renderers/MaterialOneOfEnumCell.test.tsx +93 -0
- package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +1 -1
- package/test/renderers/MaterialOneOfRenderer.test.tsx +20 -14
- package/test/renderers/MaterialRadioGroupControl.test.tsx +1 -1
- package/test/renderers/MaterialSliderControl.test.tsx +2 -2
- package/test/renderers/MaterialTextCell.test.tsx +47 -33
- package/test/renderers/MaterialTextControl.test.tsx +8 -4
- package/test/renderers/MaterialTimeCell.test.tsx +42 -21
- package/test/renderers/MaterialTimeControl.test.tsx +380 -0
- package/webpack/webpack.build.js +3 -3
- 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
- package/example/CustomAutocomplete.tsx +0 -54
|
@@ -22,9 +22,9 @@
|
|
|
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 merge from 'lodash/merge';
|
|
27
|
-
import { Button, Hidden, Step, StepButton, Stepper } from '@material
|
|
27
|
+
import { Button, Hidden, Step, StepButton, Stepper } from '@mui/material';
|
|
28
28
|
import {
|
|
29
29
|
and,
|
|
30
30
|
Categorization,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
StatePropsOfLayout,
|
|
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,
|
|
@@ -63,94 +63,86 @@ export interface MaterialCategorizationStepperLayoutRendererProps
|
|
|
63
63
|
data: any;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export
|
|
67
|
-
|
|
68
|
-
CategorizationStepperState
|
|
69
|
-
> {
|
|
70
|
-
state = {
|
|
71
|
-
activeCategory: 0
|
|
72
|
-
};
|
|
66
|
+
export const MaterialCategorizationStepperLayoutRenderer = (props: MaterialCategorizationStepperLayoutRendererProps)=> {
|
|
67
|
+
const [activeCategory, setActiveCategory] = useState<number>(0);
|
|
73
68
|
|
|
74
|
-
handleStep = (step: number) => {
|
|
75
|
-
|
|
69
|
+
const handleStep = (step: number) => {
|
|
70
|
+
setActiveCategory( step);
|
|
76
71
|
};
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
73
|
+
const {
|
|
74
|
+
data,
|
|
75
|
+
path,
|
|
76
|
+
renderers,
|
|
77
|
+
schema,
|
|
78
|
+
uischema,
|
|
79
|
+
visible,
|
|
80
|
+
cells,
|
|
81
|
+
config,
|
|
82
|
+
ajv
|
|
83
|
+
} = props;
|
|
84
|
+
const categorization = uischema as Categorization;
|
|
85
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
86
|
+
const buttonWrapperStyle = {
|
|
87
|
+
textAlign: 'right' as 'right',
|
|
88
|
+
width: '100%',
|
|
89
|
+
margin: '1em auto'
|
|
90
|
+
};
|
|
91
|
+
const buttonNextStyle = {
|
|
92
|
+
float: 'right' as 'right'
|
|
93
|
+
};
|
|
94
|
+
const buttonStyle = {
|
|
95
|
+
marginRight: '1em'
|
|
96
|
+
};
|
|
97
|
+
const categories = categorization.elements.filter((category: Category) =>
|
|
98
|
+
isVisible(category, data, undefined, ajv)
|
|
99
|
+
);
|
|
100
|
+
const childProps: MaterialLayoutRendererProps = {
|
|
101
|
+
elements: categories[activeCategory].elements,
|
|
102
|
+
schema,
|
|
103
|
+
path,
|
|
104
|
+
direction: 'column',
|
|
105
|
+
visible,
|
|
106
|
+
renderers,
|
|
107
|
+
cells
|
|
108
|
+
};
|
|
109
|
+
return (
|
|
110
|
+
<Hidden xsUp={!visible}>
|
|
111
|
+
<Stepper activeStep={activeCategory} nonLinear>
|
|
112
|
+
{categories.map((e: Category, idx: number) => (
|
|
113
|
+
<Step key={e.label}>
|
|
114
|
+
<StepButton onClick={() => handleStep(idx)}>
|
|
115
|
+
{e.label}
|
|
116
|
+
</StepButton>
|
|
117
|
+
</Step>
|
|
118
|
+
))}
|
|
119
|
+
</Stepper>
|
|
120
|
+
<div>
|
|
121
|
+
<MaterialLayoutRenderer {...childProps} />
|
|
122
|
+
</div>
|
|
123
|
+
{ !!appliedUiSchemaOptions.showNavButtons ? (<div style={buttonWrapperStyle}>
|
|
124
|
+
<Button
|
|
125
|
+
style={buttonNextStyle}
|
|
126
|
+
variant="contained"
|
|
127
|
+
color="primary"
|
|
128
|
+
disabled={activeCategory >= categories.length - 1}
|
|
129
|
+
onClick={() => handleStep(activeCategory + 1)}
|
|
130
|
+
>
|
|
131
|
+
Next
|
|
132
|
+
</Button>
|
|
133
|
+
<Button
|
|
134
|
+
style={buttonStyle}
|
|
135
|
+
color="secondary"
|
|
136
|
+
variant="contained"
|
|
137
|
+
disabled={activeCategory <= 0}
|
|
138
|
+
onClick={() => handleStep(activeCategory - 1)}
|
|
139
|
+
>
|
|
140
|
+
Previous
|
|
141
|
+
</Button>
|
|
142
|
+
</div>) : (<></>)}
|
|
143
|
+
</Hidden>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
154
146
|
|
|
155
147
|
export default withJsonFormsLayoutProps(withAjvProps(
|
|
156
148
|
MaterialCategorizationStepperLayoutRenderer
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import isEmpty from 'lodash/isEmpty';
|
|
26
26
|
import React from 'react';
|
|
27
|
-
import { Card, CardContent, CardHeader, Hidden } from '@material
|
|
27
|
+
import { Card, CardContent, CardHeader, Hidden } from '@mui/material';
|
|
28
28
|
import {
|
|
29
29
|
GroupLayout,
|
|
30
30
|
LayoutProps,
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import Checkbox from '@material
|
|
28
|
-
import { areEqual } from '@jsonforms/react';
|
|
27
|
+
import { Checkbox } from '@mui/material';
|
|
29
28
|
import merge from 'lodash/merge';
|
|
30
29
|
|
|
31
30
|
export const MuiCheckbox = React.memo((props: CellProps & WithClassname) => {
|
|
@@ -54,4 +53,4 @@ export const MuiCheckbox = React.memo((props: CellProps & WithClassname) => {
|
|
|
54
53
|
inputProps={inputProps}
|
|
55
54
|
/>
|
|
56
55
|
);
|
|
57
|
-
}
|
|
56
|
+
});
|
|
@@ -24,11 +24,15 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import Input from '@material
|
|
28
|
-
import { areEqual } from '@jsonforms/react';
|
|
27
|
+
import { Input } from '@mui/material';
|
|
29
28
|
import merge from 'lodash/merge';
|
|
29
|
+
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
const toNumber = (value: string) =>
|
|
32
|
+
value === '' ? undefined : parseInt(value, 10);
|
|
33
|
+
const eventToValue = (ev:any) => toNumber(ev.target.value);
|
|
34
|
+
|
|
35
|
+
export const MuiInputInteger = React.memo(
|
|
32
36
|
(props: CellProps & WithClassname) => {
|
|
33
37
|
const {
|
|
34
38
|
data,
|
|
@@ -41,15 +45,16 @@ export const MuiInputInteger = React.memo(
|
|
|
41
45
|
config
|
|
42
46
|
} = props;
|
|
43
47
|
const inputProps = { step: '1' };
|
|
44
|
-
|
|
45
|
-
value === '' ? undefined : parseInt(value, 10);
|
|
48
|
+
|
|
46
49
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
47
50
|
|
|
51
|
+
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue);
|
|
52
|
+
|
|
48
53
|
return (
|
|
49
54
|
<Input
|
|
50
55
|
type='number'
|
|
51
|
-
value={
|
|
52
|
-
onChange={
|
|
56
|
+
value={inputValue}
|
|
57
|
+
onChange={onChange}
|
|
53
58
|
className={className}
|
|
54
59
|
id={id}
|
|
55
60
|
disabled={!enabled}
|
|
@@ -58,6 +63,4 @@ export const MuiInputInteger = React.memo(
|
|
|
58
63
|
fullWidth={true}
|
|
59
64
|
/>
|
|
60
65
|
);
|
|
61
|
-
}
|
|
62
|
-
areEqual
|
|
63
|
-
);
|
|
66
|
+
});
|
|
@@ -24,10 +24,13 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import Input from '@material
|
|
28
|
-
import { areEqual } from '@jsonforms/react';
|
|
27
|
+
import { Input } from '@mui/material';
|
|
29
28
|
import merge from 'lodash/merge';
|
|
29
|
+
import {useDebouncedChange} from '../util';
|
|
30
30
|
|
|
31
|
+
const toNumber = (value: string) =>
|
|
32
|
+
value === '' ? undefined : parseFloat(value);
|
|
33
|
+
const eventToValue = (ev:any) => toNumber(ev.target.value);
|
|
31
34
|
export const MuiInputNumber = React.memo((props: CellProps & WithClassname) => {
|
|
32
35
|
const {
|
|
33
36
|
data,
|
|
@@ -40,15 +43,15 @@ export const MuiInputNumber = React.memo((props: CellProps & WithClassname) => {
|
|
|
40
43
|
config
|
|
41
44
|
} = props;
|
|
42
45
|
const inputProps = { step: '0.1' };
|
|
43
|
-
|
|
44
|
-
value === '' ? undefined : parseFloat(value);
|
|
46
|
+
|
|
45
47
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
48
|
+
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue);
|
|
46
49
|
|
|
47
50
|
return (
|
|
48
51
|
<Input
|
|
49
52
|
type='number'
|
|
50
|
-
value={
|
|
51
|
-
onChange={
|
|
53
|
+
value={inputValue}
|
|
54
|
+
onChange={onChange}
|
|
52
55
|
className={className}
|
|
53
56
|
id={id}
|
|
54
57
|
disabled={!enabled}
|
|
@@ -57,4 +60,4 @@ export const MuiInputNumber = React.memo((props: CellProps & WithClassname) => {
|
|
|
57
60
|
fullWidth={true}
|
|
58
61
|
/>
|
|
59
62
|
);
|
|
60
|
-
}
|
|
63
|
+
});
|
|
@@ -22,13 +22,13 @@
|
|
|
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, {useCallback} from 'react';
|
|
26
26
|
import { CellProps, Formatted, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import Input from '@material
|
|
28
|
-
import { areEqual } from '@jsonforms/react';
|
|
27
|
+
import { Input } from '@mui/material';
|
|
29
28
|
import merge from 'lodash/merge';
|
|
29
|
+
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
|
-
export const MuiInputNumberFormat = React.memo(
|
|
31
|
+
export const MuiInputNumberFormat = React.memo(
|
|
32
32
|
(props: CellProps & WithClassname & Formatted<number>) => {
|
|
33
33
|
const {
|
|
34
34
|
className,
|
|
@@ -51,15 +51,14 @@ export const MuiInputNumberFormat = React.memo(
|
|
|
51
51
|
}
|
|
52
52
|
const formattedNumber = props.toFormatted(props.data);
|
|
53
53
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
54
|
+
const validStringNumber = useCallback((ev:any) => props.fromFormatted(ev.currentTarget.value),[props.fromFormatted]);
|
|
55
|
+
const [inputValue, onChange] = useDebouncedChange(handleChange, '', formattedNumber, path, validStringNumber);
|
|
56
|
+
|
|
58
57
|
|
|
59
58
|
return (
|
|
60
59
|
<Input
|
|
61
60
|
type='text'
|
|
62
|
-
value={
|
|
61
|
+
value={inputValue}
|
|
63
62
|
onChange={onChange}
|
|
64
63
|
className={className}
|
|
65
64
|
id={id}
|
|
@@ -71,6 +70,4 @@ export const MuiInputNumberFormat = React.memo(
|
|
|
71
70
|
error={!isValid}
|
|
72
71
|
/>
|
|
73
72
|
);
|
|
74
|
-
}
|
|
75
|
-
areEqual
|
|
76
|
-
);
|
|
73
|
+
});
|
|
@@ -24,22 +24,23 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React, { useState } from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import {
|
|
28
|
-
|
|
27
|
+
import {
|
|
28
|
+
IconButton,
|
|
29
|
+
Input,
|
|
30
|
+
InputAdornment,
|
|
31
|
+
InputBaseComponentProps,
|
|
32
|
+
InputProps,
|
|
33
|
+
useTheme
|
|
34
|
+
} from '@mui/material';
|
|
29
35
|
import merge from 'lodash/merge';
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import Close from '@material-ui/icons/Close';
|
|
33
|
-
import { useTheme } from '@material-ui/core/styles';
|
|
34
|
-
import { JsonFormsTheme } from '../util';
|
|
35
|
-
import { InputBaseComponentProps } from '@material-ui/core';
|
|
36
|
+
import Close from '@mui/icons-material/Close';
|
|
37
|
+
import { JsonFormsTheme, useDebouncedChange } from '../util';
|
|
36
38
|
|
|
37
39
|
interface MuiTextInputProps {
|
|
38
40
|
muiInputProps?: InputProps['inputProps'];
|
|
39
41
|
inputComponent?: InputProps['inputComponent'];
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTextInputProps) => {
|
|
43
|
+
export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTextInputProps) => {
|
|
43
44
|
const [showAdornment, setShowAdornment] = useState(false);
|
|
44
45
|
const {
|
|
45
46
|
data,
|
|
@@ -63,23 +64,30 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
|
|
|
63
64
|
} else {
|
|
64
65
|
inputProps = {};
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
+
|
|
67
68
|
inputProps = merge(inputProps, muiInputProps);
|
|
68
|
-
|
|
69
|
+
|
|
69
70
|
if (appliedUiSchemaOptions.trim && maxLength !== undefined) {
|
|
70
71
|
inputProps.size = maxLength;
|
|
71
|
-
}
|
|
72
|
-
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const [inputText, onChange, onClear] = useDebouncedChange(handleChange, '', data, path);
|
|
75
|
+
const onPointerEnter = () => setShowAdornment(true);
|
|
76
|
+
const onPointerLeave = () => setShowAdornment(false);
|
|
73
77
|
|
|
74
78
|
const theme: JsonFormsTheme = useTheme();
|
|
75
|
-
|
|
79
|
+
|
|
80
|
+
const closeStyle = {
|
|
81
|
+
background: theme.jsonforms?.input?.delete?.background || theme.palette.background.default,
|
|
82
|
+
borderRadius: '50%'
|
|
83
|
+
};
|
|
76
84
|
|
|
77
85
|
return (
|
|
78
86
|
<Input
|
|
79
87
|
type={
|
|
80
88
|
appliedUiSchemaOptions.format === 'password' ? 'password' : 'text'
|
|
81
89
|
}
|
|
82
|
-
value={
|
|
90
|
+
value={inputText}
|
|
83
91
|
onChange={onChange}
|
|
84
92
|
className={className}
|
|
85
93
|
id={id}
|
|
@@ -89,8 +97,8 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
|
|
|
89
97
|
fullWidth={!appliedUiSchemaOptions.trim || maxLength === undefined}
|
|
90
98
|
inputProps={inputProps}
|
|
91
99
|
error={!isValid}
|
|
92
|
-
onPointerEnter={
|
|
93
|
-
onPointerLeave={
|
|
100
|
+
onPointerEnter={onPointerEnter}
|
|
101
|
+
onPointerLeave={onPointerLeave}
|
|
94
102
|
endAdornment={
|
|
95
103
|
<InputAdornment
|
|
96
104
|
position='end'
|
|
@@ -103,13 +111,14 @@ export const MuiInputText = React.memo((props: CellProps & WithClassname & MuiTe
|
|
|
103
111
|
>
|
|
104
112
|
<IconButton
|
|
105
113
|
aria-label='Clear input field'
|
|
106
|
-
onClick={
|
|
114
|
+
onClick={onClear}
|
|
115
|
+
size='large'
|
|
107
116
|
>
|
|
108
|
-
<Close style={
|
|
117
|
+
<Close style={closeStyle}/>
|
|
109
118
|
</IconButton>
|
|
110
119
|
</InputAdornment>
|
|
111
120
|
}
|
|
112
121
|
inputComponent={inputComponent}
|
|
113
122
|
/>
|
|
114
123
|
);
|
|
115
|
-
}
|
|
124
|
+
});
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import Input from '@material
|
|
28
|
-
import { areEqual } from '@jsonforms/react';
|
|
27
|
+
import { Input } from '@mui/material';
|
|
29
28
|
import merge from 'lodash/merge';
|
|
29
|
+
import { useDebouncedChange } from '../util';
|
|
30
30
|
|
|
31
31
|
export const MuiInputTime = React.memo((props: CellProps & WithClassname) => {
|
|
32
32
|
const {
|
|
@@ -40,11 +40,13 @@ export const MuiInputTime = React.memo((props: CellProps & WithClassname) => {
|
|
|
40
40
|
config
|
|
41
41
|
} = props;
|
|
42
42
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
43
|
+
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path);
|
|
44
|
+
|
|
43
45
|
return (
|
|
44
46
|
<Input
|
|
45
47
|
type='time'
|
|
46
|
-
value={
|
|
47
|
-
onChange={
|
|
48
|
+
value={inputValue}
|
|
49
|
+
onChange={onChange}
|
|
48
50
|
className={className}
|
|
49
51
|
id={id}
|
|
50
52
|
disabled={!enabled}
|
|
@@ -52,4 +54,4 @@ export const MuiInputTime = React.memo((props: CellProps & WithClassname) => {
|
|
|
52
54
|
fullWidth={true}
|
|
53
55
|
/>
|
|
54
56
|
);
|
|
55
|
-
}
|
|
57
|
+
});
|
|
@@ -25,9 +25,7 @@
|
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { EnumCellProps, WithClassname } from '@jsonforms/core';
|
|
27
27
|
|
|
28
|
-
import Select from '@material
|
|
29
|
-
import { MenuItem } from '@material-ui/core';
|
|
30
|
-
import { areEqual } from '@jsonforms/react';
|
|
28
|
+
import { MenuItem, Select } from '@mui/material';
|
|
31
29
|
import merge from 'lodash/merge';
|
|
32
30
|
|
|
33
31
|
export const MuiSelect = React.memo((props: EnumCellProps & WithClassname) => {
|
|
@@ -50,9 +48,10 @@ export const MuiSelect = React.memo((props: EnumCellProps & WithClassname) => {
|
|
|
50
48
|
id={id}
|
|
51
49
|
disabled={!enabled}
|
|
52
50
|
autoFocus={appliedUiSchemaOptions.focus}
|
|
53
|
-
value={data
|
|
51
|
+
value={data !== undefined ? data : ''}
|
|
54
52
|
onChange={ev => handleChange(path, ev.target.value)}
|
|
55
53
|
fullWidth={true}
|
|
54
|
+
variant={'standard'}
|
|
56
55
|
>
|
|
57
56
|
{[<MenuItem value='' key={'empty'} />].concat(
|
|
58
57
|
options.map(optionValue => (
|
|
@@ -63,4 +62,4 @@ export const MuiSelect = React.memo((props: EnumCellProps & WithClassname) => {
|
|
|
63
62
|
)}
|
|
64
63
|
</Select>
|
|
65
64
|
);
|
|
66
|
-
}
|
|
65
|
+
});
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import React from 'react';
|
|
26
26
|
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
27
|
-
import Switch from '@material
|
|
28
|
-
import { areEqual } from '@jsonforms/react';
|
|
27
|
+
import { Switch } from '@mui/material';
|
|
29
28
|
import merge from 'lodash/merge';
|
|
30
29
|
|
|
31
30
|
export const MuiToggle = React.memo((props: CellProps & WithClassname) => {
|
|
@@ -53,4 +52,4 @@ export const MuiToggle = React.memo((props: CellProps & WithClassname) => {
|
|
|
53
52
|
inputProps={inputProps}
|
|
54
53
|
/>
|
|
55
54
|
);
|
|
56
|
-
}
|
|
55
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import customParsing from 'dayjs/plugin/customParseFormat';
|
|
3
|
+
|
|
4
|
+
// required for the custom save formats in the date, time and date-time pickers
|
|
5
|
+
dayjs.extend(customParsing);
|
|
6
|
+
|
|
7
|
+
export const createOnChangeHandler = (
|
|
8
|
+
path: string,
|
|
9
|
+
handleChange: (path: string, value: any) => void,
|
|
10
|
+
saveFormat: string | undefined
|
|
11
|
+
) => (time: dayjs.Dayjs) => {
|
|
12
|
+
if (!time) {
|
|
13
|
+
handleChange(path, undefined);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const result = dayjs(time).format(saveFormat);
|
|
17
|
+
handleChange(path, result === 'Invalid Date' ? undefined : result);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const getData = (
|
|
21
|
+
data: any,
|
|
22
|
+
saveFormat: string | undefined
|
|
23
|
+
): dayjs.Dayjs | null => {
|
|
24
|
+
if (!data) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const dayjsData = dayjs(data, saveFormat);
|
|
28
|
+
if (dayjsData.toString() === 'Invalid Date') {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return dayjsData;
|
|
32
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2021 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 { debounce } from 'lodash';
|
|
26
|
+
import { useState, useCallback, useEffect } from 'react'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const eventToValue = (ev: any) => ev.target.value;
|
|
30
|
+
export const useDebouncedChange = (handleChange: (path: string, value: any) => void, defaultValue: any, data: any, path: string, eventToValueFunction: (ev: any) => any = eventToValue, timeout = 300): [any, React.ChangeEventHandler, () => void] => {
|
|
31
|
+
const [input, setInput] = useState(data ?? defaultValue);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setInput(data ?? defaultValue);
|
|
34
|
+
}, [data]);
|
|
35
|
+
const debouncedUpdate = useCallback(debounce((newValue: string) => handleChange(path, newValue), timeout), [handleChange, path, timeout]);
|
|
36
|
+
const onChange = useCallback((ev: any) => {
|
|
37
|
+
const newValue = eventToValueFunction(ev);
|
|
38
|
+
setInput(newValue ?? defaultValue);
|
|
39
|
+
debouncedUpdate(newValue);
|
|
40
|
+
}, [debouncedUpdate, eventToValueFunction]);
|
|
41
|
+
const onClear = useCallback(() => { setInput(defaultValue); handleChange(path, undefined) }, [defaultValue, handleChange, path]);
|
|
42
|
+
return [input, onChange, onClear];
|
|
43
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2021 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 {useState, useCallback} from 'react';
|
|
26
|
+
|
|
27
|
+
export const useFocus = ():[boolean, () => void, () => void] => {
|
|
28
|
+
const [focused, setFocused] = useState(false);
|
|
29
|
+
const onFocus = useCallback(() => setFocused(true), []);
|
|
30
|
+
const onBlur = useCallback(() => setFocused(false), []);
|
|
31
|
+
return [focused, onFocus, onBlur];
|
|
32
|
+
};
|
package/src/util/index.ts
CHANGED