@jsonforms/material-renderers 3.0.0-alpha.1 → 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/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 +803 -213
- package/docs/index.html +63 -42
- 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 +1 -4
- package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +1 -4
- package/docs/interfaces/materiallayoutrendererprops.html +0 -3
- package/docs/interfaces/materialtabletoolbarprops.html +0 -3
- 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 +3 -1
- 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.js +10 -9
- 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 +1 -1
- package/lib/cells/MaterialOneOfEnumCell.js +3 -1
- package/lib/cells/MaterialOneOfEnumCell.js.map +1 -1
- 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.js +11 -10
- package/lib/cells/index.js.map +1 -1
- package/lib/complex/CombinatorProperties.js +3 -1
- 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 +3 -1
- package/lib/complex/MaterialAllOfRenderer.js.map +1 -1
- package/lib/complex/MaterialAnyOfRenderer.d.ts +3 -2
- package/lib/complex/MaterialAnyOfRenderer.js +3 -1
- 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 +3 -1
- package/lib/complex/MaterialObjectRenderer.js.map +1 -1
- package/lib/complex/MaterialOneOfRenderer.d.ts +2 -1
- package/lib/complex/MaterialOneOfRenderer.js +5 -4
- 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.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 -6
- package/lib/controls/MaterialDateControl.js +25 -29
- package/lib/controls/MaterialDateControl.js.map +1 -1
- package/lib/controls/MaterialDateTimeControl.d.ts +3 -6
- package/lib/controls/MaterialDateTimeControl.js +25 -29
- 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 -19
- 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 +3 -6
- package/lib/controls/MaterialTimeControl.js +25 -29
- package/lib/controls/MaterialTimeControl.js.map +1 -1
- package/lib/controls/index.d.ts +10 -10
- package/lib/controls/index.js +16 -15
- 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 +1 -0
- package/lib/index.js.map +1 -1
- package/lib/jsonforms-material.js +8 -8
- 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 +3 -3
- package/lib/layouts/ExpandPanelRenderer.js +16 -13
- 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 +2 -2
- package/lib/util/datejs.js +5 -2
- package/lib/util/datejs.js.map +1 -1
- 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 +2 -0
- package/lib/util/index.js +3 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/layout.d.ts +2 -1
- package/lib/util/layout.js +8 -4
- package/lib/util/layout.js.map +1 -1
- package/package.json +5 -5
- package/src/cells/MaterialTimeCell.tsx +1 -0
- package/src/complex/MaterialAllOfRenderer.tsx +2 -1
- package/src/complex/MaterialAnyOfRenderer.tsx +2 -1
- package/src/complex/MaterialEnumArrayRenderer.tsx +1 -0
- package/src/complex/MaterialObjectRenderer.tsx +2 -1
- package/src/complex/MaterialOneOfRenderer.tsx +6 -6
- package/src/complex/MaterialTableControl.tsx +36 -24
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +16 -12
- package/src/controls/MaterialDateControl.tsx +80 -85
- package/src/controls/MaterialDateTimeControl.tsx +83 -86
- package/src/controls/MaterialInputControl.tsx +62 -69
- package/src/controls/MaterialNativeControl.tsx +54 -57
- package/src/controls/MaterialRadioGroup.tsx +67 -69
- package/src/controls/MaterialSliderControl.tsx +92 -87
- package/src/controls/MaterialTimeControl.tsx +77 -80
- package/src/extended/MuiAutocomplete.tsx +2 -3
- package/src/layouts/ExpandPanelRenderer.tsx +11 -17
- package/src/layouts/MaterialArrayLayout.tsx +73 -82
- 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/debounce.ts +43 -0
- package/src/util/focus.ts +32 -0
- package/src/util/index.ts +2 -0
- package/src/util/layout.tsx +5 -6
- package/test/renderers/MaterialAnyOfRenderer.test.tsx +14 -8
- package/test/renderers/MaterialArrayLayout.test.tsx +6 -6
- package/test/renderers/MaterialCategorizationLayout.test.tsx +73 -0
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +73 -0
- 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/MaterialOneOfRenderer.test.tsx +7 -4
- package/test/renderers/MaterialTextCell.test.tsx +41 -20
- package/test/renderers/MaterialTimeCell.test.tsx +41 -20
- package/test/renderers/MaterialTimeControl.test.tsx +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/classes/materialtimecontrol.html +0 -825
- package/docs/interfaces/materialarraylayoutstate.html +0 -157
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFocus = void 0;
|
|
4
|
+
/*
|
|
5
|
+
The MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2021 EclipseSource Munich
|
|
8
|
+
https://github.com/eclipsesource/jsonforms
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
|
27
|
+
*/
|
|
28
|
+
var react_1 = require("react");
|
|
29
|
+
var useFocus = function () {
|
|
30
|
+
var _a = react_1.useState(false), focused = _a[0], setFocused = _a[1];
|
|
31
|
+
var onFocus = react_1.useCallback(function () { return setFocused(true); }, []);
|
|
32
|
+
var onBlur = react_1.useCallback(function () { return setFocused(false); }, []);
|
|
33
|
+
return [focused, onFocus, onBlur];
|
|
34
|
+
};
|
|
35
|
+
exports.useFocus = useFocus;
|
|
36
|
+
//# sourceMappingURL=focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.js","sourceRoot":"","sources":["../../src/util/focus.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,+BAA4C;AAErC,IAAM,QAAQ,GAAG;IACd,IAAA,KAAwB,gBAAQ,CAAC,KAAK,CAAC,EAAtC,OAAO,QAAA,EAAE,UAAU,QAAmB,CAAC;IAC9C,IAAM,OAAO,GAAG,mBAAW,CAAC,cAAM,OAAA,UAAU,CAAC,IAAI,CAAC,EAAhB,CAAgB,EAAE,EAAE,CAAC,CAAC;IACxD,IAAM,MAAM,GAAG,mBAAW,CAAC,cAAM,OAAA,UAAU,CAAC,KAAK,CAAC,EAAjB,CAAiB,EAAE,EAAE,CAAC,CAAC;IACxD,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AALW,QAAA,QAAQ,YAKnB"}
|
package/lib/util/index.d.ts
CHANGED
package/lib/util/index.js
CHANGED
|
@@ -27,4 +27,7 @@ var tslib_1 = require("tslib");
|
|
|
27
27
|
*/
|
|
28
28
|
tslib_1.__exportStar(require("./datejs"), exports);
|
|
29
29
|
tslib_1.__exportStar(require("./layout"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./theme"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./debounce"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./focus"), exports);
|
|
30
33
|
//# sourceMappingURL=index.js.map
|
package/lib/util/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,mDAAyB;AACzB,mDAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,mDAAyB;AACzB,mDAAyB;AACzB,kDAAwB;AACxB,qDAA2B;AAC3B,kDAAwB"}
|
package/lib/util/layout.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import Ajv from 'ajv';
|
|
3
4
|
import { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonSchema, OwnPropsOfRenderer, UISchemaElement } from '@jsonforms/core';
|
|
4
5
|
export declare const renderLayoutElements: (elements: UISchemaElement[], schema: JsonSchema, path: string, enabled: boolean, renderers?: JsonFormsRendererRegistryEntry[], cells?: JsonFormsCellRendererRegistryEntry[]) => JSX.Element[];
|
|
5
6
|
export interface MaterialLayoutRendererProps extends OwnPropsOfRenderer {
|
package/lib/util/layout.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withAjvProps = exports.MaterialLayoutRenderer = exports.renderLayoutElements = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
/*
|
|
5
6
|
The MIT License
|
|
@@ -30,11 +31,12 @@ var react_1 = tslib_1.__importDefault(require("react"));
|
|
|
30
31
|
var core_1 = require("@jsonforms/core");
|
|
31
32
|
var react_2 = require("@jsonforms/react");
|
|
32
33
|
var core_2 = require("@material-ui/core");
|
|
33
|
-
|
|
34
|
+
var renderLayoutElements = function (elements, schema, path, enabled, renderers, cells) {
|
|
34
35
|
return elements.map(function (child, index) { return (react_1.default.createElement(core_2.Grid, { item: true, key: path + "-" + index, xs: true },
|
|
35
36
|
react_1.default.createElement(react_2.JsonFormsDispatch, { uischema: child, schema: schema, path: path, enabled: enabled, renderers: renderers, cells: cells }))); });
|
|
36
37
|
};
|
|
37
|
-
exports.
|
|
38
|
+
exports.renderLayoutElements = renderLayoutElements;
|
|
39
|
+
var MaterialLayoutRendererComponent = function (_a) {
|
|
38
40
|
var visible = _a.visible, elements = _a.elements, schema = _a.schema, path = _a.path, enabled = _a.enabled, direction = _a.direction, renderers = _a.renderers, cells = _a.cells;
|
|
39
41
|
if (isEmpty_1.default(elements)) {
|
|
40
42
|
return null;
|
|
@@ -43,12 +45,14 @@ exports.MaterialLayoutRenderer = react_1.default.memo(function (_a) {
|
|
|
43
45
|
return (react_1.default.createElement(core_2.Hidden, { xsUp: !visible },
|
|
44
46
|
react_1.default.createElement(core_2.Grid, { container: true, direction: direction, spacing: direction === 'row' ? 2 : 0 }, exports.renderLayoutElements(elements, schema, path, enabled, renderers, cells))));
|
|
45
47
|
}
|
|
46
|
-
}
|
|
47
|
-
exports.
|
|
48
|
+
};
|
|
49
|
+
exports.MaterialLayoutRenderer = react_1.default.memo(MaterialLayoutRendererComponent);
|
|
50
|
+
var withAjvProps = function (Component) {
|
|
48
51
|
return function (props) {
|
|
49
52
|
var ctx = react_2.useJsonForms();
|
|
50
53
|
var ajv = core_1.getAjv({ jsonforms: tslib_1.__assign({}, ctx) });
|
|
51
54
|
return (react_1.default.createElement(Component, tslib_1.__assign({}, props, { ajv: ajv })));
|
|
52
55
|
};
|
|
53
56
|
};
|
|
57
|
+
exports.withAjvProps = withAjvProps;
|
|
54
58
|
//# sourceMappingURL=layout.js.map
|
package/lib/util/layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/util/layout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/util/layout.tsx"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,mEAAqC;AACrC,wDAA0B;AAG1B,wCAOyB;AACzB,0CAAmE;AACnE,0CAAiD;AAE1C,IAAM,oBAAoB,GAAG,UAClC,QAA2B,EAC3B,MAAkB,EAClB,IAAY,EACZ,OAAgB,EAChB,SAA4C,EAC5C,KAA4C;IAE5C,OAAO,QAAQ,CAAC,GAAG,CAAC,UAAC,KAAK,EAAE,KAAK,IAAK,OAAA,CACpC,8BAAC,WAAI,IAAC,IAAI,QAAC,GAAG,EAAK,IAAI,SAAI,KAAO,EAAE,EAAE;QACpC,8BAAC,yBAAiB,IAChB,QAAQ,EAAE,KAAK,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,GACZ,CACG,CACR,EAXqC,CAWrC,CAAC,CAAC;AACL,CAAC,CAAC;AApBW,QAAA,oBAAoB,wBAoB/B;AAMF,IAAM,+BAA+B,GACnC,UAAC,EAS6B;QAR5B,OAAO,aAAA,EACP,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,IAAI,UAAA,EACJ,OAAO,aAAA,EACP,SAAS,eAAA,EACT,SAAS,eAAA,EACT,KAAK,WAAA;IAEL,IAAI,iBAAO,CAAC,QAAQ,CAAC,EAAE;QACrB,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,CACL,8BAAC,aAAM,IAAC,IAAI,EAAE,CAAC,OAAO;YACpB,8BAAC,WAAI,IACH,SAAS,QACT,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAEnC,4BAAoB,CACnB,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,OAAO,EACP,SAAS,EACT,KAAK,CACN,CACI,CACA,CACV,CAAC;KACH;AACH,CAAC,CAAC;AACS,QAAA,sBAAsB,GAAG,eAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;AAM3E,IAAM,YAAY,GAAG,UAAe,SAAsC;IAC/E,OAAA,UAAC,KAAQ;QACP,IAAM,GAAG,GAAG,oBAAY,EAAE,CAAC;QAC3B,IAAM,GAAG,GAAG,aAAM,CAAC,EAAC,SAAS,uBAAM,GAAG,CAAC,EAAC,CAAC,CAAC;QAE1C,OAAO,CAAC,8BAAC,SAAS,uBAAK,KAAK,IAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC;AALD,CAKC,CAAC;AANS,QAAA,YAAY,gBAMrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonforms/material-renderers",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "Material Renderer Set for JSON Forms",
|
|
5
5
|
"repository": "https://github.com/eclipsesource/jsonforms",
|
|
6
6
|
"bugs": "https://github.com/eclipsesource/jsonforms/issues",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"@material-ui/lab": "^4.0.0-alpha.56"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@jsonforms/core": "^3.0.0-alpha.
|
|
83
|
-
"@jsonforms/react": "^3.0.0-alpha.
|
|
82
|
+
"@jsonforms/core": "^3.0.0-alpha.2",
|
|
83
|
+
"@jsonforms/react": "^3.0.0-alpha.2",
|
|
84
84
|
"@material-ui/core": "^4.7.0",
|
|
85
85
|
"@material-ui/icons": "^4.5.1",
|
|
86
86
|
"@material-ui/lab": "^4.0.0-alpha.56",
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"tslint": "^5.20.1",
|
|
102
102
|
"tslint-loader": "^3.5.4",
|
|
103
103
|
"typedoc": "^0.19.2",
|
|
104
|
-
"typescript": "
|
|
104
|
+
"typescript": "4.2.3",
|
|
105
105
|
"webpack": "^4.41.2",
|
|
106
106
|
"webpack-cli": "^3.2.1",
|
|
107
107
|
"webpack-dev-server": "^3.9.0"
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "7532a3e16558d9f0934bd5c602ccbe3a35ed9dab"
|
|
110
110
|
}
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
} from '@jsonforms/core';
|
|
38
38
|
import { JsonFormsDispatch, withJsonFormsAllOfProps } from '@jsonforms/react';
|
|
39
39
|
|
|
40
|
-
const MaterialAllOfRenderer = ({
|
|
40
|
+
export const MaterialAllOfRenderer = ({
|
|
41
41
|
schema,
|
|
42
42
|
rootSchema,
|
|
43
43
|
visible,
|
|
@@ -95,4 +95,5 @@ export const materialAllOfControlTester: RankedTester = rankWith(
|
|
|
95
95
|
3,
|
|
96
96
|
isAllOfControl
|
|
97
97
|
);
|
|
98
|
+
|
|
98
99
|
export default withJsonFormsAllOfProps(MaterialAllOfRenderer);
|
|
@@ -37,7 +37,7 @@ import { JsonFormsDispatch, withJsonFormsAnyOfProps } from '@jsonforms/react';
|
|
|
37
37
|
import { Hidden, Tab, Tabs } from '@material-ui/core';
|
|
38
38
|
import CombinatorProperties from './CombinatorProperties';
|
|
39
39
|
|
|
40
|
-
const MaterialAnyOfRenderer = ({
|
|
40
|
+
export const MaterialAnyOfRenderer = ({
|
|
41
41
|
schema,
|
|
42
42
|
rootSchema,
|
|
43
43
|
indexOfFittingSchema,
|
|
@@ -97,4 +97,5 @@ export const materialAnyOfControlTester: RankedTester = rankWith(
|
|
|
97
97
|
3,
|
|
98
98
|
isAnyOfControl
|
|
99
99
|
);
|
|
100
|
+
|
|
100
101
|
export default withJsonFormsAnyOfProps(MaterialAnyOfRenderer);
|
|
@@ -35,7 +35,7 @@ import { JsonFormsDispatch, withJsonFormsDetailProps } from '@jsonforms/react';
|
|
|
35
35
|
import { Hidden } from '@material-ui/core';
|
|
36
36
|
import React, { useMemo } from 'react';
|
|
37
37
|
|
|
38
|
-
const MaterialObjectRenderer = ({
|
|
38
|
+
export const MaterialObjectRenderer = ({
|
|
39
39
|
renderers,
|
|
40
40
|
cells,
|
|
41
41
|
uischemas,
|
|
@@ -84,4 +84,5 @@ export const materialObjectControlTester: RankedTester = rankWith(
|
|
|
84
84
|
2,
|
|
85
85
|
isObjectControl
|
|
86
86
|
);
|
|
87
|
+
|
|
87
88
|
export default withJsonFormsDetailProps(MaterialObjectRenderer);
|
|
@@ -26,7 +26,7 @@ import React, { useCallback, useState } from 'react';
|
|
|
26
26
|
import isEmpty from 'lodash/isEmpty';
|
|
27
27
|
|
|
28
28
|
import {
|
|
29
|
-
|
|
29
|
+
CombinatorRendererProps,
|
|
30
30
|
createCombinatorRenderInfos,
|
|
31
31
|
createDefaultValue,
|
|
32
32
|
isOneOfControl,
|
|
@@ -57,9 +57,8 @@ export interface OwnOneOfProps extends OwnPropsOfControl {
|
|
|
57
57
|
indexOfFittingSchema?: number;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
({ handleChange, schema, path, renderers, cells, rootSchema, id, visible, indexOfFittingSchema, uischema, uischemas, data }: CombinatorProps) => {
|
|
60
|
+
export const MaterialOneOfRenderer =
|
|
61
|
+
({ handleChange, schema, path, renderers, cells, rootSchema, id, visible, indexOfFittingSchema, uischema, uischemas, data }: CombinatorRendererProps) => {
|
|
63
62
|
const [open, setOpen] = useState(false);
|
|
64
63
|
const [selectedIndex, setSelectedIndex] = useState(indexOfFittingSchema || 0);
|
|
65
64
|
const [newSelectedIndex, setNewSelectedIndex] = useState(0);
|
|
@@ -67,11 +66,11 @@ const MaterialOneOfRenderer =
|
|
|
67
66
|
const cancel = useCallback(() => {
|
|
68
67
|
setOpen(false);
|
|
69
68
|
}, [setOpen]);
|
|
70
|
-
const _schema = resolveSubSchemas(schema, rootSchema, oneOf);
|
|
69
|
+
const _schema = resolveSubSchemas(schema, rootSchema, 'oneOf');
|
|
71
70
|
const oneOfRenderInfos = createCombinatorRenderInfos(
|
|
72
71
|
(_schema as JsonSchema).oneOf,
|
|
73
72
|
rootSchema,
|
|
74
|
-
oneOf,
|
|
73
|
+
'oneOf',
|
|
75
74
|
uischema,
|
|
76
75
|
path,
|
|
77
76
|
uischemas
|
|
@@ -150,4 +149,5 @@ const MaterialOneOfRenderer =
|
|
|
150
149
|
};
|
|
151
150
|
|
|
152
151
|
export const materialOneOfControlTester: RankedTester = rankWith(3, isOneOfControl);
|
|
152
|
+
|
|
153
153
|
export default withJsonFormsOneOfProps(MaterialOneOfRenderer);
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
} from '@jsonforms/react';
|
|
32
32
|
import startCase from 'lodash/startCase';
|
|
33
33
|
import range from 'lodash/range';
|
|
34
|
-
import React, { Fragment } from 'react';
|
|
34
|
+
import React, { Fragment, useMemo } from 'react';
|
|
35
35
|
import {
|
|
36
36
|
FormHelperText,
|
|
37
37
|
Grid,
|
|
@@ -195,20 +195,19 @@ const controlWithoutLabel = (scope: string): ControlElement => ({
|
|
|
195
195
|
label: false
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
198
|
+
interface NonEmptyCellComponentProps {
|
|
199
|
+
path: string,
|
|
200
|
+
propName?: string,
|
|
201
|
+
schema: JsonSchema,
|
|
202
|
+
rootSchema: JsonSchema,
|
|
203
|
+
errors: string,
|
|
204
|
+
enabled: boolean,
|
|
205
|
+
renderers?: JsonFormsRendererRegistryEntry[],
|
|
206
|
+
cells?: JsonFormsCellRendererRegistryEntry[],
|
|
207
|
+
isValid: boolean
|
|
208
|
+
}
|
|
209
|
+
const NonEmptyCellComponent = React.memo(({path, propName, schema,rootSchema, errors, enabled, renderers, cells, isValid}:NonEmptyCellComponentProps) => {
|
|
210
210
|
|
|
211
|
-
const isValid = isEmpty(errors);
|
|
212
211
|
return (
|
|
213
212
|
<NoBorderTableCell>
|
|
214
213
|
{schema.properties ? (
|
|
@@ -237,35 +236,47 @@ const NonEmptyCell = (ownProps: OwnPropsOfNonEmptyCell) => {
|
|
|
237
236
|
<FormHelperText error={!isValid}>{!isValid && errors}</FormHelperText>
|
|
238
237
|
</NoBorderTableCell>
|
|
239
238
|
);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const NonEmptyCell = (ownProps: OwnPropsOfNonEmptyCell) => {
|
|
242
|
+
const ctx = useJsonForms();
|
|
243
|
+
const emptyCellProps = ctxToNonEmptyCellProps(ctx, ownProps);
|
|
244
|
+
|
|
245
|
+
const isValid = isEmpty(emptyCellProps.errors);
|
|
246
|
+
return <NonEmptyCellComponent {...emptyCellProps} isValid={isValid}/>
|
|
240
247
|
};
|
|
241
248
|
|
|
242
249
|
interface NonEmptyRowProps {
|
|
243
250
|
childPath: string;
|
|
244
251
|
schema: JsonSchema;
|
|
245
252
|
rowIndex: number;
|
|
246
|
-
|
|
247
|
-
|
|
253
|
+
moveUpCreator: (path:string, position: number)=> ()=> void;
|
|
254
|
+
moveDownCreator: (path:string, position: number)=> ()=> void;
|
|
248
255
|
enableUp: boolean;
|
|
249
256
|
enableDown: boolean;
|
|
250
257
|
showSortButtons: boolean;
|
|
251
258
|
enabled: boolean;
|
|
252
259
|
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
260
|
+
path: string;
|
|
253
261
|
}
|
|
254
262
|
|
|
255
|
-
const
|
|
263
|
+
const NonEmptyRowComponent =
|
|
256
264
|
({
|
|
257
265
|
childPath,
|
|
258
266
|
schema,
|
|
259
267
|
rowIndex,
|
|
260
268
|
openDeleteDialog,
|
|
261
|
-
|
|
262
|
-
|
|
269
|
+
moveUpCreator,
|
|
270
|
+
moveDownCreator,
|
|
263
271
|
enableUp,
|
|
264
272
|
enableDown,
|
|
265
273
|
showSortButtons,
|
|
266
274
|
enabled,
|
|
267
|
-
cells
|
|
275
|
+
cells,
|
|
276
|
+
path
|
|
268
277
|
}: NonEmptyRowProps & WithDeleteDialogSupport) => {
|
|
278
|
+
const moveUp = useMemo(() => moveUpCreator(path, rowIndex),[moveUpCreator, path, rowIndex]);
|
|
279
|
+
const moveDown = useMemo(() => moveDownCreator(path, rowIndex),[moveDownCreator, path, rowIndex]);
|
|
269
280
|
return (
|
|
270
281
|
<TableRow key={childPath} hover>
|
|
271
282
|
{generateCells(NonEmptyCell, schema, childPath, enabled, cells)}
|
|
@@ -314,8 +325,8 @@ const NonEmptyRow = React.memo(
|
|
|
314
325
|
) : null}
|
|
315
326
|
</TableRow>
|
|
316
327
|
);
|
|
317
|
-
}
|
|
318
|
-
);
|
|
328
|
+
};
|
|
329
|
+
export const NonEmptyRow = React.memo(NonEmptyRowComponent);
|
|
319
330
|
interface TableRowsProp {
|
|
320
331
|
data: number;
|
|
321
332
|
path: string;
|
|
@@ -359,13 +370,14 @@ const TableRows = ({
|
|
|
359
370
|
rowIndex={index}
|
|
360
371
|
schema={schema}
|
|
361
372
|
openDeleteDialog={openDeleteDialog}
|
|
362
|
-
|
|
363
|
-
|
|
373
|
+
moveUpCreator={moveUp}
|
|
374
|
+
moveDownCreator={moveDown}
|
|
364
375
|
enableUp={index !== 0}
|
|
365
376
|
enableDown={index !== data - 1}
|
|
366
377
|
showSortButtons={appliedUiSchemaOptions.showSortButtons}
|
|
367
378
|
enabled={enabled}
|
|
368
379
|
cells={cells}
|
|
380
|
+
path={path}
|
|
369
381
|
/>
|
|
370
382
|
);
|
|
371
383
|
})}
|
|
@@ -38,7 +38,8 @@ import { Control, withJsonFormsControlProps } from '@jsonforms/react';
|
|
|
38
38
|
import { Input } from '@material-ui/core';
|
|
39
39
|
import { InputBaseComponentProps } from '@material-ui/core/InputBase';
|
|
40
40
|
import merge from 'lodash/merge';
|
|
41
|
-
import React from 'react';
|
|
41
|
+
import React, { useMemo } from 'react';
|
|
42
|
+
import { useDebouncedChange } from '../util';
|
|
42
43
|
import { MaterialInputControl } from './MaterialInputControl';
|
|
43
44
|
|
|
44
45
|
const findEnumSchema = (schemas: JsonSchema[]) =>
|
|
@@ -64,17 +65,20 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
|
|
|
64
65
|
const enumSchema = findEnumSchema(schema.anyOf);
|
|
65
66
|
const stringSchema = findTextSchema(schema.anyOf);
|
|
66
67
|
const maxLength = stringSchema.maxLength;
|
|
67
|
-
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
const appliedUiSchemaOptions = useMemo(() => merge({}, config, uischema.options),[config, uischema.options]);
|
|
69
|
+
const inputProps: InputBaseComponentProps = useMemo(() => {
|
|
70
|
+
let propMemo: InputBaseComponentProps = {};
|
|
71
|
+
if (appliedUiSchemaOptions.restrict) {
|
|
72
|
+
propMemo = { maxLength: maxLength };
|
|
73
|
+
}
|
|
74
|
+
if (appliedUiSchemaOptions.trim && maxLength !== undefined) {
|
|
75
|
+
propMemo.size = maxLength;
|
|
76
|
+
}
|
|
77
|
+
propMemo.list = props.id + 'datalist';
|
|
78
|
+
return propMemo;
|
|
79
|
+
},[appliedUiSchemaOptions,props.id]);
|
|
80
|
+
const [inputText, onChange] = useDebouncedChange(handleChange, '', data, path);
|
|
76
81
|
|
|
77
|
-
inputProps.list = props.id + 'datalist';
|
|
78
82
|
const dataList = (
|
|
79
83
|
<datalist id={props.id + 'datalist'}>
|
|
80
84
|
{enumSchema.enum.map(optionValue => (
|
|
@@ -85,7 +89,7 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
|
|
|
85
89
|
return (
|
|
86
90
|
<Input
|
|
87
91
|
type='text'
|
|
88
|
-
value={
|
|
92
|
+
value={inputText}
|
|
89
93
|
onChange={onChange}
|
|
90
94
|
className={className}
|
|
91
95
|
id={id}
|
|
@@ -23,17 +23,15 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import merge from 'lodash/merge';
|
|
26
|
-
import React from 'react';
|
|
26
|
+
import React, { useMemo } from 'react';
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
DispatchPropsOfControl,
|
|
28
|
+
ControlProps,
|
|
30
29
|
isDateControl,
|
|
31
30
|
isDescriptionHidden,
|
|
32
31
|
RankedTester,
|
|
33
32
|
rankWith,
|
|
34
|
-
StatePropsOfControl
|
|
35
33
|
} from '@jsonforms/core';
|
|
36
|
-
import {
|
|
34
|
+
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
37
35
|
import { FormHelperText, Hidden } from '@material-ui/core';
|
|
38
36
|
import KeyboardArrowLeftIcon from '@material-ui/icons/KeyboardArrowLeft';
|
|
39
37
|
import KeyboardArrowRightIcon from '@material-ui/icons/KeyboardArrowRight';
|
|
@@ -43,90 +41,87 @@ import {
|
|
|
43
41
|
MuiPickersUtilsProvider
|
|
44
42
|
} from '@material-ui/pickers';
|
|
45
43
|
import DayJsUtils from '@date-io/dayjs';
|
|
46
|
-
import { createOnChangeHandler, getData } from '../util';
|
|
44
|
+
import { createOnChangeHandler, getData, useFocus } from '../util';
|
|
47
45
|
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.state.isFocused,
|
|
73
|
-
appliedUiSchemaOptions.showUnfocusedDescription
|
|
74
|
-
);
|
|
46
|
+
export const MaterialDateControl = (props: ControlProps)=> {
|
|
47
|
+
const [focused, onFocus, onBlur] = useFocus();
|
|
48
|
+
const {
|
|
49
|
+
description,
|
|
50
|
+
id,
|
|
51
|
+
errors,
|
|
52
|
+
label,
|
|
53
|
+
uischema,
|
|
54
|
+
visible,
|
|
55
|
+
enabled,
|
|
56
|
+
required,
|
|
57
|
+
path,
|
|
58
|
+
handleChange,
|
|
59
|
+
data,
|
|
60
|
+
config
|
|
61
|
+
} = props;
|
|
62
|
+
const isValid = errors.length === 0;
|
|
63
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
64
|
+
const showDescription = !isDescriptionHidden(
|
|
65
|
+
visible,
|
|
66
|
+
description,
|
|
67
|
+
focused,
|
|
68
|
+
appliedUiSchemaOptions.showUnfocusedDescription
|
|
69
|
+
);
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
const format = appliedUiSchemaOptions.dateFormat ?? 'YYYY-MM-DD';
|
|
72
|
+
const saveFormat = appliedUiSchemaOptions.dateSaveFormat ?? 'YYYY-MM-DD';
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
const firstFormHelperText = showDescription
|
|
75
|
+
? description
|
|
76
|
+
: !isValid
|
|
77
|
+
? errors
|
|
78
|
+
: null;
|
|
79
|
+
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
80
|
+
const onChange = useMemo(() => createOnChangeHandler(
|
|
81
|
+
path,
|
|
82
|
+
handleChange,
|
|
83
|
+
saveFormat
|
|
84
|
+
),[path, handleChange, saveFormat]);
|
|
85
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
|
-
</MuiPickersUtilsProvider>
|
|
126
|
-
</Hidden>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
86
|
+
return (
|
|
87
|
+
<Hidden xsUp={!visible}>
|
|
88
|
+
<MuiPickersUtilsProvider utils={DayJsUtils}>
|
|
89
|
+
<KeyboardDatePicker
|
|
90
|
+
id={id + '-input'}
|
|
91
|
+
required={required && !appliedUiSchemaOptions.hideRequiredAsterisk}
|
|
92
|
+
label={label}
|
|
93
|
+
error={!isValid}
|
|
94
|
+
fullWidth={!appliedUiSchemaOptions.trim}
|
|
95
|
+
InputLabelProps={data ? { shrink: true } : undefined}
|
|
96
|
+
value={getData(data, saveFormat)}
|
|
97
|
+
clearable
|
|
98
|
+
onChange={onChange}
|
|
99
|
+
format={format}
|
|
100
|
+
views={appliedUiSchemaOptions.views}
|
|
101
|
+
disabled={!enabled}
|
|
102
|
+
autoFocus={appliedUiSchemaOptions.focus}
|
|
103
|
+
onFocus={onFocus}
|
|
104
|
+
onBlur={onBlur}
|
|
105
|
+
cancelLabel={appliedUiSchemaOptions.cancelLabel}
|
|
106
|
+
clearLabel={appliedUiSchemaOptions.clearLabel}
|
|
107
|
+
okLabel={appliedUiSchemaOptions.okLabel}
|
|
108
|
+
leftArrowIcon={<KeyboardArrowLeftIcon />}
|
|
109
|
+
rightArrowIcon={<KeyboardArrowRightIcon />}
|
|
110
|
+
keyboardIcon={<EventIcon />}
|
|
111
|
+
invalidDateMessage={null}
|
|
112
|
+
maxDateMessage={null}
|
|
113
|
+
minDateMessage={null}
|
|
114
|
+
/>
|
|
115
|
+
<FormHelperText error={!isValid && !showDescription}>
|
|
116
|
+
{firstFormHelperText}
|
|
117
|
+
</FormHelperText>
|
|
118
|
+
<FormHelperText error={!isValid}>
|
|
119
|
+
{secondFormHelperText}
|
|
120
|
+
</FormHelperText>
|
|
121
|
+
</MuiPickersUtilsProvider>
|
|
122
|
+
</Hidden>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
130
125
|
|
|
131
126
|
export const materialDateControlTester: RankedTester = rankWith(
|
|
132
127
|
4,
|