@jsonforms/material-renderers 3.1.1-alpha.0 → 3.2.0-alpha.0
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/lib/cells/MaterialDateCell.d.ts +2 -1
- package/lib/complex/MaterialAnyOfRenderer.d.ts +2 -2
- package/lib/complex/TabSwitchConfirmDialog.d.ts +9 -0
- package/lib/complex/unwrapped.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/jsonforms-react-material.cjs.js +102 -43
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +90 -42
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/mui-controls/MuiInputInteger.d.ts +2 -1
- package/lib/mui-controls/MuiInputNumber.d.ts +2 -1
- package/lib/mui-controls/MuiInputNumberFormat.d.ts +2 -1
- package/lib/mui-controls/MuiInputText.d.ts +2 -1
- package/lib/mui-controls/MuiInputTime.d.ts +2 -1
- package/lib/mui-controls/MuiSelect.d.ts +2 -1
- package/lib/util/theme.d.ts +8 -1
- package/package.json +8 -8
- package/src/cells/MaterialDateCell.tsx +21 -6
- package/src/complex/MaterialAnyOfRenderer.tsx +49 -6
- package/src/complex/MaterialOneOfRenderer.tsx +21 -45
- package/src/complex/TabSwitchConfirmDialog.tsx +56 -0
- package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +9 -4
- package/src/controls/MaterialDateControl.tsx +0 -1
- package/src/controls/MaterialDateTimeControl.tsx +0 -1
- package/src/controls/MaterialInputControl.tsx +3 -2
- package/src/controls/MaterialTimeControl.tsx +0 -1
- package/src/mui-controls/MuiAutocomplete.tsx +0 -1
- package/src/mui-controls/MuiInputInteger.tsx +16 -6
- package/src/mui-controls/MuiInputNumber.tsx +20 -10
- package/src/mui-controls/MuiInputNumberFormat.tsx +6 -4
- package/src/mui-controls/MuiInputText.tsx +11 -4
- package/src/mui-controls/MuiInputTime.tsx +20 -10
- package/src/mui-controls/MuiSelect.tsx +4 -3
- package/src/util/theme.ts +40 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CellProps, RankedTester, WithClassname } from '@jsonforms/core';
|
|
3
|
-
|
|
3
|
+
import { WithInputProps } from '../util';
|
|
4
|
+
export declare const MaterialDateCell: (props: CellProps & WithClassname & WithInputProps) => React.JSX.Element;
|
|
4
5
|
export declare const materialDateCellTester: RankedTester;
|
|
5
6
|
declare const _default: React.ComponentType<import("@jsonforms/core").OwnPropsOfCell>;
|
|
6
7
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const MaterialAnyOfRenderer: ({ schema, rootSchema, indexOfFittingSchema, visible, path, renderers, cells, uischema, uischemas, }:
|
|
2
|
+
import { CombinatorRendererProps, RankedTester } from '@jsonforms/core';
|
|
3
|
+
export declare const MaterialAnyOfRenderer: ({ handleChange, schema, rootSchema, indexOfFittingSchema, visible, path, renderers, cells, uischema, uischemas, id, data, }: CombinatorRendererProps) => React.JSX.Element;
|
|
4
4
|
export declare const materialAnyOfControlTester: RankedTester;
|
|
5
5
|
declare const _default: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
6
6
|
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TabSwitchConfirmDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
handleClose: () => void;
|
|
5
|
+
confirm: () => void;
|
|
6
|
+
cancel: () => void;
|
|
7
|
+
id: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const TabSwitchConfirmDialog: ({ open, handleClose, confirm, cancel, id, }: TabSwitchConfirmDialogProps) => React.JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const UnwrappedComplex: {
|
|
3
3
|
MaterialAllOfRenderer: ({ schema, rootSchema, visible, renderers, cells, path, uischemas, uischema, }: import("@jsonforms/core").StatePropsOfCombinator) => import("react").JSX.Element;
|
|
4
|
-
MaterialAnyOfRenderer: ({ schema, rootSchema, indexOfFittingSchema, visible, path, renderers, cells, uischema, uischemas, }: import("@jsonforms/core").
|
|
4
|
+
MaterialAnyOfRenderer: ({ handleChange, schema, rootSchema, indexOfFittingSchema, visible, path, renderers, cells, uischema, uischemas, id, data, }: import("@jsonforms/core").CombinatorRendererProps) => import("react").JSX.Element;
|
|
5
5
|
MaterialArrayControlRenderer: (props: import("@jsonforms/core").ArrayLayoutProps) => import("react").JSX.Element;
|
|
6
6
|
MaterialEnumArrayRenderer: ({ schema, visible, errors, path, options, data, addItem, removeItem, handleChange: _handleChange, ...otherProps }: import("@jsonforms/core").ControlProps & import("@jsonforms/core").OwnPropsOfEnum & import("@jsonforms/core").DispatchPropsOfMultiEnumControl) => import("react").JSX.Element;
|
|
7
7
|
MaterialObjectRenderer: ({ renderers, cells, uischemas, schema, label, path, visible, enabled, uischema, rootSchema, }: import("@jsonforms/core").StatePropsOfControlWithDetail) => import("react").JSX.Element;
|
package/lib/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const Unwrapped: {
|
|
|
32
32
|
MaterialTextControl: (props: import("@jsonforms/core").ControlProps) => import("react").JSX.Element;
|
|
33
33
|
MaterialTimeControl: (props: import("@jsonforms/core").ControlProps) => import("react").JSX.Element;
|
|
34
34
|
MaterialAllOfRenderer: ({ schema, rootSchema, visible, renderers, cells, path, uischemas, uischema, }: import("@jsonforms/core").StatePropsOfCombinator) => import("react").JSX.Element;
|
|
35
|
-
MaterialAnyOfRenderer: ({ schema, rootSchema, indexOfFittingSchema, visible, path, renderers, cells, uischema, uischemas, }: import("@jsonforms/core").
|
|
35
|
+
MaterialAnyOfRenderer: ({ handleChange, schema, rootSchema, indexOfFittingSchema, visible, path, renderers, cells, uischema, uischemas, id, data, }: import("@jsonforms/core").CombinatorRendererProps) => import("react").JSX.Element;
|
|
36
36
|
MaterialArrayControlRenderer: (props: import("@jsonforms/core").ArrayLayoutProps) => import("react").JSX.Element;
|
|
37
37
|
MaterialEnumArrayRenderer: ({ schema, visible, errors, path, options, data, addItem, removeItem, handleChange: _handleChange, ...otherProps }: import("@jsonforms/core").ControlProps & import("@jsonforms/core").OwnPropsOfEnum & import("@jsonforms/core").DispatchPropsOfMultiEnumControl) => import("react").JSX.Element;
|
|
38
38
|
MaterialObjectRenderer: ({ renderers, cells, uischemas, schema, label, path, visible, enabled, uischema, rootSchema, }: import("@jsonforms/core").StatePropsOfControlWithDetail) => import("react").JSX.Element;
|
|
@@ -27,7 +27,6 @@ var xDatePickers = require('@mui/x-date-pickers');
|
|
|
27
27
|
var AdapterDayjs = require('@mui/x-date-pickers/AdapterDayjs');
|
|
28
28
|
var get = require('lodash/get');
|
|
29
29
|
var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
|
|
30
|
-
var Input = require('@mui/material/Input');
|
|
31
30
|
|
|
32
31
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
33
32
|
|
|
@@ -50,7 +49,6 @@ var Close__default = /*#__PURE__*/_interopDefaultLegacy(Close);
|
|
|
50
49
|
var map__default = /*#__PURE__*/_interopDefaultLegacy(map);
|
|
51
50
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
52
51
|
var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon);
|
|
53
|
-
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
54
52
|
|
|
55
53
|
/******************************************************************************
|
|
56
54
|
Copyright (c) Microsoft Corporation.
|
|
@@ -66,7 +64,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
66
64
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
67
65
|
PERFORMANCE OF THIS SOFTWARE.
|
|
68
66
|
***************************************************************************** */
|
|
69
|
-
/* global Reflect, Promise */
|
|
67
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
70
68
|
|
|
71
69
|
var extendStatics = function(d, b) {
|
|
72
70
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -104,7 +102,12 @@ function __rest(s, e) {
|
|
|
104
102
|
t[p[i]] = s[p[i]];
|
|
105
103
|
}
|
|
106
104
|
return t;
|
|
107
|
-
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
108
|
+
var e = new Error(message);
|
|
109
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
110
|
+
};
|
|
108
111
|
|
|
109
112
|
var MaterialAllOfRenderer = function (_a) {
|
|
110
113
|
var schema = _a.schema, rootSchema = _a.rootSchema, visible = _a.visible, renderers = _a.renderers, cells = _a.cells, path = _a.path, uischemas = _a.uischemas, uischema = _a.uischema;
|
|
@@ -140,18 +143,51 @@ var CombinatorProperties = (function (_super) {
|
|
|
140
143
|
return CombinatorProperties;
|
|
141
144
|
}(React__default["default"].Component));
|
|
142
145
|
|
|
146
|
+
var TabSwitchConfirmDialog = function (_a) {
|
|
147
|
+
var open = _a.open, handleClose = _a.handleClose, confirm = _a.confirm, cancel = _a.cancel, id = _a.id;
|
|
148
|
+
return (React__default["default"].createElement(material.Dialog, { open: open, onClose: handleClose, "aria-labelledby": 'alert-dialog-title', "aria-describedby": 'alert-dialog-description' },
|
|
149
|
+
React__default["default"].createElement(material.DialogTitle, { id: 'alert-dialog-title' }, 'Clear form?'),
|
|
150
|
+
React__default["default"].createElement(material.DialogContent, null,
|
|
151
|
+
React__default["default"].createElement(material.DialogContentText, { id: 'alert-dialog-description' }, "Your data will be cleared if you navigate away from this tab. Do you want to proceed?")),
|
|
152
|
+
React__default["default"].createElement(material.DialogActions, null,
|
|
153
|
+
React__default["default"].createElement(material.Button, { onClick: cancel, color: 'primary' }, "No"),
|
|
154
|
+
React__default["default"].createElement(material.Button, { onClick: confirm, color: 'primary', autoFocus: true, id: id + "-confirm-yes" }, "Yes"))));
|
|
155
|
+
};
|
|
156
|
+
|
|
143
157
|
var MaterialAnyOfRenderer = function (_a) {
|
|
144
|
-
var schema = _a.schema, rootSchema = _a.rootSchema, indexOfFittingSchema = _a.indexOfFittingSchema, visible = _a.visible, path = _a.path, renderers = _a.renderers, cells = _a.cells, uischema = _a.uischema, uischemas = _a.uischemas;
|
|
158
|
+
var handleChange = _a.handleChange, schema = _a.schema, rootSchema = _a.rootSchema, indexOfFittingSchema = _a.indexOfFittingSchema, visible = _a.visible, path = _a.path, renderers = _a.renderers, cells = _a.cells, uischema = _a.uischema, uischemas = _a.uischemas, id = _a.id, data = _a.data;
|
|
145
159
|
var _b = React.useState(indexOfFittingSchema || 0), selectedAnyOf = _b[0], setSelectedAnyOf = _b[1];
|
|
146
|
-
var
|
|
160
|
+
var _c = React.useState(false), confirmDialogOpen = _c[0], setConfirmDialogOpen = _c[1];
|
|
161
|
+
var _d = React.useState(0), newSelectedIndex = _d[0], setNewSelectedIndex = _d[1];
|
|
162
|
+
var handleClose = React.useCallback(function () { return setConfirmDialogOpen(false); }, [setConfirmDialogOpen]);
|
|
163
|
+
var handleTabChange = React.useCallback(function (_event, newIndex) {
|
|
164
|
+
if (isEmpty__default["default"](data) ||
|
|
165
|
+
typeof data ===
|
|
166
|
+
typeof core.createDefaultValue(anyOfRenderInfos[newIndex].schema)) {
|
|
167
|
+
setSelectedAnyOf(newIndex);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
setNewSelectedIndex(newIndex);
|
|
171
|
+
setConfirmDialogOpen(true);
|
|
172
|
+
}
|
|
173
|
+
}, [setConfirmDialogOpen, setSelectedAnyOf, data]);
|
|
174
|
+
var openNewTab = function (newIndex) {
|
|
175
|
+
handleChange(path, core.createDefaultValue(anyOfRenderInfos[newIndex].schema));
|
|
176
|
+
setSelectedAnyOf(newIndex);
|
|
177
|
+
};
|
|
178
|
+
var confirm = React.useCallback(function () {
|
|
179
|
+
openNewTab(newSelectedIndex);
|
|
180
|
+
setConfirmDialogOpen(false);
|
|
181
|
+
}, [handleChange, core.createDefaultValue, newSelectedIndex]);
|
|
147
182
|
var anyOf = 'anyOf';
|
|
148
183
|
var anyOfRenderInfos = core.createCombinatorRenderInfos(schema.anyOf, rootSchema, anyOf, uischema, path, uischemas);
|
|
149
184
|
return (React__default["default"].createElement(material.Hidden, { xsUp: !visible },
|
|
150
185
|
React__default["default"].createElement(CombinatorProperties, { schema: schema, combinatorKeyword: anyOf, path: path }),
|
|
151
|
-
React__default["default"].createElement(material.Tabs, { value: selectedAnyOf, onChange:
|
|
186
|
+
React__default["default"].createElement(material.Tabs, { value: selectedAnyOf, onChange: handleTabChange }, anyOfRenderInfos.map(function (anyOfRenderInfo) { return (React__default["default"].createElement(material.Tab, { key: anyOfRenderInfo.label, label: anyOfRenderInfo.label })); })),
|
|
152
187
|
anyOfRenderInfos.map(function (anyOfRenderInfo, anyOfIndex) {
|
|
153
188
|
return selectedAnyOf === anyOfIndex && (React__default["default"].createElement(react.JsonFormsDispatch, { key: anyOfIndex, schema: anyOfRenderInfo.schema, uischema: anyOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells }));
|
|
154
|
-
})
|
|
189
|
+
}),
|
|
190
|
+
React__default["default"].createElement(TabSwitchConfirmDialog, { cancel: handleClose, confirm: confirm, id: 'anyOf-' + id, open: confirmDialogOpen, handleClose: handleClose })));
|
|
155
191
|
};
|
|
156
192
|
var materialAnyOfControlTester = core.rankWith(3, core.isAnyOfControl);
|
|
157
193
|
var MaterialAnyOfRenderer$1 = react.withJsonFormsAnyOfProps(MaterialAnyOfRenderer);
|
|
@@ -411,7 +447,7 @@ var MuiAutocomplete = function (props) {
|
|
|
411
447
|
}, inputValue: inputValue, onInputChange: function (_event, newInputValue) {
|
|
412
448
|
setInputValue(newInputValue);
|
|
413
449
|
}, autoHighlight: true, autoSelect: true, autoComplete: true, fullWidth: true, options: options, getOptionLabel: getOptionLabel || (function (option) { return option === null || option === void 0 ? void 0 : option.label; }), freeSolo: false, renderInput: function (params) {
|
|
414
|
-
return (React__default["default"].createElement(material.TextField, __assign({ label: label,
|
|
450
|
+
return (React__default["default"].createElement(material.TextField, __assign({ label: label, type: 'text', inputProps: params.inputProps, inputRef: params.InputProps.ref, autoFocus: appliedUiSchemaOptions.focus, disabled: !enabled }, params, { id: id + '-input', required: required && !appliedUiSchemaOptions.hideRequiredAsterisk, error: !isValid, fullWidth: !appliedUiSchemaOptions.trim, InputLabelProps: data ? { shrink: true } : undefined, onFocus: onFocus, onBlur: onBlur, focused: focused })));
|
|
415
451
|
}, renderOption: renderOption, filterOptions: filterOptions }),
|
|
416
452
|
React__default["default"].createElement(material.FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
417
453
|
React__default["default"].createElement(material.FormHelperText, { error: !isValid }, secondFormHelperText)));
|
|
@@ -472,6 +508,25 @@ var withAjvProps = function (Component) {
|
|
|
472
508
|
};
|
|
473
509
|
};
|
|
474
510
|
|
|
511
|
+
var variantToInput = {
|
|
512
|
+
standard: material.Input,
|
|
513
|
+
filled: material.FilledInput,
|
|
514
|
+
outlined: material.OutlinedInput,
|
|
515
|
+
};
|
|
516
|
+
var defaultInputVariant = 'standard';
|
|
517
|
+
function useInputVariant() {
|
|
518
|
+
var _a = material.useThemeProps({
|
|
519
|
+
props: {},
|
|
520
|
+
name: 'MuiTextField',
|
|
521
|
+
}).variant, variant = _a === void 0 ? defaultInputVariant : _a;
|
|
522
|
+
return variant;
|
|
523
|
+
}
|
|
524
|
+
function useInputComponent() {
|
|
525
|
+
var _a;
|
|
526
|
+
var variant = useInputVariant();
|
|
527
|
+
return (_a = variantToInput[variant]) !== null && _a !== void 0 ? _a : variantToInput[defaultInputVariant];
|
|
528
|
+
}
|
|
529
|
+
|
|
475
530
|
var eventToValue$3 = function (ev) { return ev.target.value; };
|
|
476
531
|
var useDebouncedChange = function (handleChange, defaultValue, data, path, eventToValueFunction, timeout) {
|
|
477
532
|
if (eventToValueFunction === void 0) { eventToValueFunction = eventToValue$3; }
|
|
@@ -502,11 +557,12 @@ var toNumber$1 = function (value) {
|
|
|
502
557
|
};
|
|
503
558
|
var eventToValue$2 = function (ev) { return toNumber$1(ev.target.value); };
|
|
504
559
|
var MuiInputInteger = React__default["default"].memo(function MuiInputInteger(props) {
|
|
505
|
-
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, path = props.path, handleChange = props.handleChange, config = props.config;
|
|
560
|
+
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, path = props.path, handleChange = props.handleChange, config = props.config, label = props.label;
|
|
561
|
+
var InputComponent = useInputComponent();
|
|
506
562
|
var inputProps = { step: '1' };
|
|
507
563
|
var appliedUiSchemaOptions = merge__default["default"]({}, config, uischema.options);
|
|
508
564
|
var _a = useDebouncedChange(handleChange, '', data, path, eventToValue$2), inputValue = _a[0], onChange = _a[1];
|
|
509
|
-
return (React__default["default"].createElement(
|
|
565
|
+
return (React__default["default"].createElement(InputComponent, { label: label, type: 'number', value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true }));
|
|
510
566
|
});
|
|
511
567
|
|
|
512
568
|
var toNumber = function (value) {
|
|
@@ -514,15 +570,17 @@ var toNumber = function (value) {
|
|
|
514
570
|
};
|
|
515
571
|
var eventToValue$1 = function (ev) { return toNumber(ev.target.value); };
|
|
516
572
|
var MuiInputNumber = React__default["default"].memo(function MuiInputNumber(props) {
|
|
517
|
-
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, path = props.path, handleChange = props.handleChange, config = props.config;
|
|
573
|
+
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, path = props.path, handleChange = props.handleChange, config = props.config, label = props.label;
|
|
574
|
+
var InputComponent = useInputComponent();
|
|
518
575
|
var inputProps = { step: '0.1' };
|
|
519
576
|
var appliedUiSchemaOptions = merge__default["default"]({}, config, uischema.options);
|
|
520
577
|
var _a = useDebouncedChange(handleChange, '', data, path, eventToValue$1), inputValue = _a[0], onChange = _a[1];
|
|
521
|
-
return (React__default["default"].createElement(
|
|
578
|
+
return (React__default["default"].createElement(InputComponent, { type: 'number', label: label, value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true }));
|
|
522
579
|
});
|
|
523
580
|
|
|
524
581
|
var MuiInputNumberFormat = React__default["default"].memo(function MuiInputNumberFormat(props) {
|
|
525
|
-
var className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, isValid = props.isValid, path = props.path, handleChange = props.handleChange, schema = props.schema, config = props.config;
|
|
582
|
+
var className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, isValid = props.isValid, path = props.path, handleChange = props.handleChange, schema = props.schema, config = props.config, label = props.label;
|
|
583
|
+
var InputComponent = useInputComponent();
|
|
526
584
|
var maxLength = schema.maxLength;
|
|
527
585
|
var appliedUiSchemaOptions = merge__default["default"]({}, config, uischema.options);
|
|
528
586
|
var inputProps;
|
|
@@ -535,7 +593,7 @@ var MuiInputNumberFormat = React__default["default"].memo(function MuiInputNumbe
|
|
|
535
593
|
var formattedNumber = props.toFormatted(props.data);
|
|
536
594
|
var validStringNumber = React.useCallback(function (ev) { return props.fromFormatted(ev.currentTarget.value); }, [props.fromFormatted]);
|
|
537
595
|
var _a = useDebouncedChange(handleChange, '', formattedNumber, path, validStringNumber), inputValue = _a[0], onChange = _a[1];
|
|
538
|
-
return (React__default["default"].createElement(
|
|
596
|
+
return (React__default["default"].createElement(InputComponent, { type: 'text', value: inputValue, onChange: onChange, className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, multiline: appliedUiSchemaOptions.multi, fullWidth: !appliedUiSchemaOptions.trim || maxLength === undefined, inputProps: inputProps, error: !isValid }));
|
|
539
597
|
});
|
|
540
598
|
|
|
541
599
|
var eventToValue = function (ev) {
|
|
@@ -544,7 +602,8 @@ var eventToValue = function (ev) {
|
|
|
544
602
|
var MuiInputText = React__default["default"].memo(function MuiInputText(props) {
|
|
545
603
|
var _a, _b, _c;
|
|
546
604
|
var _d = React.useState(false), showAdornment = _d[0], setShowAdornment = _d[1];
|
|
547
|
-
var data = props.data, config = props.config, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, isValid = props.isValid, path = props.path, handleChange = props.handleChange, schema = props.schema, muiInputProps = props.muiInputProps, inputComponent = props.inputComponent;
|
|
605
|
+
var data = props.data, config = props.config, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, isValid = props.isValid, path = props.path, handleChange = props.handleChange, schema = props.schema, muiInputProps = props.muiInputProps, label = props.label, inputComponent = props.inputComponent;
|
|
606
|
+
var InputComponent = useInputComponent();
|
|
548
607
|
var maxLength = schema.maxLength;
|
|
549
608
|
var appliedUiSchemaOptions = merge__default["default"]({}, config, uischema.options);
|
|
550
609
|
var inputProps;
|
|
@@ -567,7 +626,7 @@ var MuiInputText = React__default["default"].memo(function MuiInputText(props) {
|
|
|
567
626
|
theme.palette.background.default,
|
|
568
627
|
borderRadius: '50%',
|
|
569
628
|
};
|
|
570
|
-
return (React__default["default"].createElement(
|
|
629
|
+
return (React__default["default"].createElement(InputComponent, { label: label, type: appliedUiSchemaOptions.format === 'password' ? 'password' : 'text', value: inputText, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, multiline: appliedUiSchemaOptions.multi, fullWidth: !appliedUiSchemaOptions.trim || maxLength === undefined, inputProps: inputProps, error: !isValid, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, endAdornment: React__default["default"].createElement(material.InputAdornment, { position: 'end', style: {
|
|
571
630
|
display: !showAdornment || !enabled || data === undefined
|
|
572
631
|
? 'none'
|
|
573
632
|
: 'flex',
|
|
@@ -579,17 +638,18 @@ var MuiInputText = React__default["default"].memo(function MuiInputText(props) {
|
|
|
579
638
|
});
|
|
580
639
|
|
|
581
640
|
var MuiInputTime = React__default["default"].memo(function MuiInputTime(props) {
|
|
582
|
-
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, path = props.path, handleChange = props.handleChange, config = props.config;
|
|
641
|
+
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, path = props.path, handleChange = props.handleChange, config = props.config, label = props.label;
|
|
642
|
+
var InputComponent = useInputComponent();
|
|
583
643
|
var appliedUiSchemaOptions = merge__default["default"]({}, config, uischema.options);
|
|
584
644
|
var _a = useDebouncedChange(handleChange, '', data, path), inputValue = _a[0], onChange = _a[1];
|
|
585
|
-
return (React__default["default"].createElement(
|
|
645
|
+
return (React__default["default"].createElement(InputComponent, { type: 'time', value: inputValue, onChange: onChange, className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, fullWidth: true }));
|
|
586
646
|
});
|
|
587
647
|
|
|
588
648
|
var MuiSelect = React__default["default"].memo(function MuiSelect(props) {
|
|
589
|
-
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, schema = props.schema, uischema = props.uischema, path = props.path, handleChange = props.handleChange, options = props.options, config = props.config, t = props.t;
|
|
649
|
+
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, schema = props.schema, uischema = props.uischema, path = props.path, handleChange = props.handleChange, options = props.options, config = props.config, label = props.label, t = props.t;
|
|
590
650
|
var appliedUiSchemaOptions = merge__default["default"]({}, config, uischema.options);
|
|
591
651
|
var noneOptionLabel = React.useMemo(function () { return t('enum.none', i18nDefaults['enum.none'], { schema: schema, uischema: uischema, path: path }); }, [t, schema, uischema, path]);
|
|
592
|
-
return (React__default["default"].createElement(material.Select, { className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, value: data !== undefined ? data : '', onChange: function (ev) { return handleChange(path, ev.target.value || undefined); }, fullWidth: true
|
|
652
|
+
return (React__default["default"].createElement(material.Select, { className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, value: data !== undefined ? data : '', onChange: function (ev) { return handleChange(path, ev.target.value || undefined); }, fullWidth: true }, [
|
|
593
653
|
React__default["default"].createElement(material.MenuItem, { value: '', key: 'jsonforms.enum.none' },
|
|
594
654
|
React__default["default"].createElement("em", null, noneOptionLabel)),
|
|
595
655
|
].concat(options.map(function (optionValue) { return (React__default["default"].createElement(material.MenuItem, { value: optionValue.value, key: optionValue.value }, optionValue.label)); }))));
|
|
@@ -658,13 +718,13 @@ var MaterialObjectRenderer$1 = react.withJsonFormsDetailProps(MaterialObjectRend
|
|
|
658
718
|
|
|
659
719
|
var MaterialOneOfRenderer = function (_a) {
|
|
660
720
|
var handleChange = _a.handleChange, schema = _a.schema, path = _a.path, renderers = _a.renderers, cells = _a.cells, rootSchema = _a.rootSchema, id = _a.id, visible = _a.visible, indexOfFittingSchema = _a.indexOfFittingSchema, uischema = _a.uischema, uischemas = _a.uischemas, data = _a.data;
|
|
661
|
-
var _b = React.useState(false),
|
|
721
|
+
var _b = React.useState(false), confirmDialogOpen = _b[0], setConfirmDialogOpen = _b[1];
|
|
662
722
|
var _c = React.useState(indexOfFittingSchema || 0), selectedIndex = _c[0], setSelectedIndex = _c[1];
|
|
663
723
|
var _d = React.useState(0), newSelectedIndex = _d[0], setNewSelectedIndex = _d[1];
|
|
664
|
-
var handleClose = React.useCallback(function () { return
|
|
724
|
+
var handleClose = React.useCallback(function () { return setConfirmDialogOpen(false); }, [setConfirmDialogOpen]);
|
|
665
725
|
var cancel = React.useCallback(function () {
|
|
666
|
-
|
|
667
|
-
}, [
|
|
726
|
+
setConfirmDialogOpen(false);
|
|
727
|
+
}, [setConfirmDialogOpen]);
|
|
668
728
|
var oneOfRenderInfos = core.createCombinatorRenderInfos(schema.oneOf, rootSchema, 'oneOf', uischema, path, uischemas);
|
|
669
729
|
var openNewTab = function (newIndex) {
|
|
670
730
|
handleChange(path, core.createDefaultValue(oneOfRenderInfos[newIndex].schema));
|
|
@@ -672,7 +732,7 @@ var MaterialOneOfRenderer = function (_a) {
|
|
|
672
732
|
};
|
|
673
733
|
var confirm = React.useCallback(function () {
|
|
674
734
|
openNewTab(newSelectedIndex);
|
|
675
|
-
|
|
735
|
+
setConfirmDialogOpen(false);
|
|
676
736
|
}, [handleChange, core.createDefaultValue, newSelectedIndex]);
|
|
677
737
|
var handleTabChange = React.useCallback(function (_event, newOneOfIndex) {
|
|
678
738
|
setNewSelectedIndex(newOneOfIndex);
|
|
@@ -680,22 +740,16 @@ var MaterialOneOfRenderer = function (_a) {
|
|
|
680
740
|
openNewTab(newOneOfIndex);
|
|
681
741
|
}
|
|
682
742
|
else {
|
|
683
|
-
|
|
743
|
+
setConfirmDialogOpen(true);
|
|
684
744
|
}
|
|
685
|
-
}, [
|
|
745
|
+
}, [setConfirmDialogOpen, setSelectedIndex, data]);
|
|
686
746
|
return (React__default["default"].createElement(material.Hidden, { xsUp: !visible },
|
|
687
747
|
React__default["default"].createElement(CombinatorProperties, { schema: schema, combinatorKeyword: 'oneOf', path: path }),
|
|
688
748
|
React__default["default"].createElement(material.Tabs, { value: selectedIndex, onChange: handleTabChange }, oneOfRenderInfos.map(function (oneOfRenderInfo) { return (React__default["default"].createElement(material.Tab, { key: oneOfRenderInfo.label, label: oneOfRenderInfo.label })); })),
|
|
689
749
|
oneOfRenderInfos.map(function (oneOfRenderInfo, oneOfIndex) {
|
|
690
750
|
return selectedIndex === oneOfIndex && (React__default["default"].createElement(react.JsonFormsDispatch, { key: oneOfIndex, schema: oneOfRenderInfo.schema, uischema: oneOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells }));
|
|
691
751
|
}),
|
|
692
|
-
React__default["default"].createElement(
|
|
693
|
-
React__default["default"].createElement(material.DialogTitle, { id: 'alert-dialog-title' }, 'Clear form?'),
|
|
694
|
-
React__default["default"].createElement(material.DialogContent, null,
|
|
695
|
-
React__default["default"].createElement(material.DialogContentText, { id: 'alert-dialog-description' }, "Your data will be cleared if you navigate away from this tab. Do you want to proceed?")),
|
|
696
|
-
React__default["default"].createElement(material.DialogActions, null,
|
|
697
|
-
React__default["default"].createElement(material.Button, { onClick: cancel, color: 'primary' }, "No"),
|
|
698
|
-
React__default["default"].createElement(material.Button, { onClick: confirm, color: 'primary', autoFocus: true, id: "oneOf-" + id + "-confirm-yes" }, "Yes")))));
|
|
752
|
+
React__default["default"].createElement(TabSwitchConfirmDialog, { cancel: cancel, confirm: confirm, id: 'oneOf-' + id, open: confirmDialogOpen, handleClose: handleClose })));
|
|
699
753
|
};
|
|
700
754
|
var materialOneOfControlTester = core.rankWith(3, core.isOneOfControl);
|
|
701
755
|
var MaterialOneOfRenderer$1 = react.withJsonFormsOneOfProps(MaterialOneOfRenderer);
|
|
@@ -772,6 +826,7 @@ var MaterialListWithDetailRenderer$1 = react.withJsonFormsArrayLayoutProps(Mater
|
|
|
772
826
|
var MaterialInputControl = function (props) {
|
|
773
827
|
var _a = useFocus(), focused = _a[0], onFocus = _a[1], onBlur = _a[2];
|
|
774
828
|
var id = props.id, description = props.description, errors = props.errors, label = props.label, uischema = props.uischema, visible = props.visible, required = props.required, config = props.config, input = props.input;
|
|
829
|
+
var variant = useInputVariant();
|
|
775
830
|
var isValid = errors.length === 0;
|
|
776
831
|
var appliedUiSchemaOptions = merge__default["default"]({}, config, uischema.options);
|
|
777
832
|
var showDescription = !core.isDescriptionHidden(visible, description, focused, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
@@ -783,7 +838,7 @@ var MaterialInputControl = function (props) {
|
|
|
783
838
|
var secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
784
839
|
var InnerComponent = input;
|
|
785
840
|
return (React__default["default"].createElement(material.Hidden, { xsUp: !visible },
|
|
786
|
-
React__default["default"].createElement(material.FormControl, { fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur,
|
|
841
|
+
React__default["default"].createElement(material.FormControl, { fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur, variant: variant, id: id },
|
|
787
842
|
React__default["default"].createElement(material.InputLabel, { htmlFor: id + '-input', error: !isValid, required: core.showAsRequired(required, appliedUiSchemaOptions.hideRequiredAsterisk) }, label),
|
|
788
843
|
React__default["default"].createElement(InnerComponent, __assign({}, props, { id: id + '-input', isValid: isValid, visible: visible })),
|
|
789
844
|
React__default["default"].createElement(material.FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
@@ -797,7 +852,8 @@ var findTextSchema = function (schemas) {
|
|
|
797
852
|
return schemas.find(function (s) { return s.type === 'string' && s.enum === undefined; });
|
|
798
853
|
};
|
|
799
854
|
var MuiAutocompleteInputText = function (props) {
|
|
800
|
-
var data = props.data, config = props.config, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, isValid = props.isValid, path = props.path, handleChange = props.handleChange, schema = props.schema;
|
|
855
|
+
var data = props.data, config = props.config, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, isValid = props.isValid, path = props.path, handleChange = props.handleChange, schema = props.schema, label = props.label;
|
|
856
|
+
var InputComponent = useInputComponent();
|
|
801
857
|
var enumSchema = findEnumSchema(schema.anyOf);
|
|
802
858
|
var stringSchema = findTextSchema(schema.anyOf);
|
|
803
859
|
var maxLength = stringSchema.maxLength;
|
|
@@ -815,7 +871,7 @@ var MuiAutocompleteInputText = function (props) {
|
|
|
815
871
|
}, [appliedUiSchemaOptions, props.id]);
|
|
816
872
|
var _a = useDebouncedChange(handleChange, '', data, path), inputText = _a[0], onChange = _a[1];
|
|
817
873
|
var dataList = (React__default["default"].createElement("datalist", { id: props.id + 'datalist' }, enumSchema.enum.map(function (optionValue) { return (React__default["default"].createElement("option", { value: optionValue, key: optionValue })); })));
|
|
818
|
-
return (React__default["default"].createElement(
|
|
874
|
+
return (React__default["default"].createElement(InputComponent, { type: 'text', value: inputText, onChange: onChange, className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, fullWidth: !appliedUiSchemaOptions.trim || maxLength === undefined, inputProps: inputProps, error: !isValid, endAdornment: dataList }));
|
|
819
875
|
};
|
|
820
876
|
var MaterialAnyOfStringOrEnumControl = (function (_super) {
|
|
821
877
|
__extends(MaterialAnyOfStringOrEnumControl, _super);
|
|
@@ -964,7 +1020,6 @@ var MaterialDateControl = function (props) {
|
|
|
964
1020
|
InputLabelProps: data ? { shrink: true } : undefined,
|
|
965
1021
|
onFocus: onFocus,
|
|
966
1022
|
onBlur: onBlur,
|
|
967
|
-
variant: 'standard',
|
|
968
1023
|
},
|
|
969
1024
|
} }),
|
|
970
1025
|
React__default["default"].createElement(material.FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
@@ -1019,7 +1074,6 @@ var MaterialDateTimeControl = function (props) {
|
|
|
1019
1074
|
InputLabelProps: data ? { shrink: true } : undefined,
|
|
1020
1075
|
onFocus: onFocus,
|
|
1021
1076
|
onBlur: onBlur,
|
|
1022
|
-
variant: 'standard',
|
|
1023
1077
|
},
|
|
1024
1078
|
} }),
|
|
1025
1079
|
React__default["default"].createElement(material.FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
@@ -1176,7 +1230,6 @@ var MaterialTimeControl = function (props) {
|
|
|
1176
1230
|
InputLabelProps: data ? { shrink: true } : undefined,
|
|
1177
1231
|
onFocus: onFocus,
|
|
1178
1232
|
onBlur: onBlur,
|
|
1179
|
-
variant: 'standard',
|
|
1180
1233
|
},
|
|
1181
1234
|
} }),
|
|
1182
1235
|
React__default["default"].createElement(material.FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
@@ -1417,9 +1470,12 @@ var materialBooleanToggleCellTester = core.rankWith(3, core.and(core.isBooleanCo
|
|
|
1417
1470
|
var MaterialBooleanToggleCell$1 = react.withJsonFormsCellProps(MaterialBooleanToggleCell);
|
|
1418
1471
|
|
|
1419
1472
|
var MaterialDateCell = function (props) {
|
|
1420
|
-
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, path = props.path, handleChange = props.handleChange, config = props.config;
|
|
1473
|
+
var data = props.data, className = props.className, id = props.id, enabled = props.enabled, uischema = props.uischema, path = props.path, handleChange = props.handleChange, config = props.config, label = props.label;
|
|
1474
|
+
var InputComponent = useInputComponent();
|
|
1421
1475
|
var appliedUiSchemaOptions = merge__default["default"]({}, config, uischema.options);
|
|
1422
|
-
return (React__default["default"].createElement(
|
|
1476
|
+
return (React__default["default"].createElement(InputComponent, { type: 'date', value: data || '', onChange: function (ev) {
|
|
1477
|
+
return handleChange(path, ev.target.value);
|
|
1478
|
+
}, className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, fullWidth: true }));
|
|
1423
1479
|
};
|
|
1424
1480
|
var materialDateCellTester = core.rankWith(2, core.isDateControl);
|
|
1425
1481
|
var MaterialDateCell$1 = react.withJsonFormsCellProps(MaterialDateCell);
|
|
@@ -1693,6 +1749,7 @@ exports.NonEmptyRow = NonEmptyRow;
|
|
|
1693
1749
|
exports.Unwrapped = Unwrapped;
|
|
1694
1750
|
exports.createOnChangeHandler = createOnChangeHandler;
|
|
1695
1751
|
exports.ctxDispatchToExpandPanelProps = ctxDispatchToExpandPanelProps;
|
|
1752
|
+
exports.defaultInputVariant = defaultInputVariant;
|
|
1696
1753
|
exports.getData = getData;
|
|
1697
1754
|
exports.i18nDefaults = i18nDefaults;
|
|
1698
1755
|
exports.materialAllOfControlTester = materialAllOfControlTester;
|
|
@@ -1738,6 +1795,8 @@ exports.materialVerticalLayoutTester = materialVerticalLayoutTester;
|
|
|
1738
1795
|
exports.renderLayoutElements = renderLayoutElements;
|
|
1739
1796
|
exports.useDebouncedChange = useDebouncedChange;
|
|
1740
1797
|
exports.useFocus = useFocus;
|
|
1798
|
+
exports.useInputComponent = useInputComponent;
|
|
1799
|
+
exports.useInputVariant = useInputVariant;
|
|
1741
1800
|
exports.withAjvProps = withAjvProps;
|
|
1742
1801
|
exports.withContextToExpandPanelProps = withContextToExpandPanelProps;
|
|
1743
1802
|
exports.withJsonFormsExpandPanelProps = withJsonFormsExpandPanelProps;
|