@jsonforms/material-renderers 3.1.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/additional/ListWithDetailMasterItem.d.ts +1 -1
- package/lib/additional/MaterialLabelRenderer.d.ts +1 -1
- package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
- package/lib/additional/unwrapped.d.ts +2 -2
- package/lib/cells/MaterialBooleanCell.d.ts +1 -1
- package/lib/cells/MaterialBooleanToggleCell.d.ts +1 -1
- package/lib/cells/MaterialDateCell.d.ts +2 -1
- package/lib/cells/MaterialEnumCell.d.ts +1 -1
- package/lib/cells/MaterialIntegerCell.d.ts +1 -1
- package/lib/cells/MaterialNumberCell.d.ts +1 -1
- package/lib/cells/MaterialNumberFormatCell.d.ts +1 -1
- package/lib/cells/MaterialOneOfEnumCell.d.ts +1 -1
- package/lib/cells/MaterialTextCell.d.ts +1 -1
- package/lib/cells/MaterialTimeCell.d.ts +1 -1
- package/lib/complex/CombinatorProperties.d.ts +1 -1
- package/lib/complex/MaterialAllOfRenderer.d.ts +1 -1
- package/lib/complex/MaterialAnyOfRenderer.d.ts +2 -2
- package/lib/complex/MaterialArrayControlRenderer.d.ts +1 -1
- package/lib/complex/MaterialEnumArrayRenderer.d.ts +1 -1
- package/lib/complex/MaterialObjectRenderer.d.ts +1 -1
- package/lib/complex/MaterialOneOfRenderer.d.ts +1 -1
- package/lib/complex/MaterialTableControl.d.ts +2 -2
- package/lib/complex/NoBorderTableCell.d.ts +2 -2
- package/lib/complex/TabSwitchConfirmDialog.d.ts +9 -0
- package/lib/complex/unwrapped.d.ts +6 -6
- package/lib/controls/MaterialAnyOfStringOrEnumControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanControl.d.ts +1 -1
- package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
- package/lib/controls/MaterialDateControl.d.ts +1 -1
- package/lib/controls/MaterialDateTimeControl.d.ts +1 -1
- package/lib/controls/MaterialEnumControl.d.ts +1 -1
- package/lib/controls/MaterialInputControl.d.ts +2 -2
- package/lib/controls/MaterialIntegerControl.d.ts +1 -1
- package/lib/controls/MaterialNativeControl.d.ts +1 -1
- package/lib/controls/MaterialNumberControl.d.ts +1 -1
- package/lib/controls/MaterialOneOfEnumControl.d.ts +1 -1
- package/lib/controls/MaterialOneOfRadioGroupControl.d.ts +1 -1
- package/lib/controls/MaterialRadioGroup.d.ts +2 -2
- package/lib/controls/MaterialRadioGroupControl.d.ts +1 -1
- package/lib/controls/MaterialSliderControl.d.ts +1 -1
- package/lib/controls/MaterialTextControl.d.ts +1 -1
- package/lib/controls/MaterialTimeControl.d.ts +1 -1
- package/lib/controls/unwrapped.d.ts +14 -14
- package/lib/index.d.ts +28 -28
- 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/layouts/ExpandPanelRenderer.d.ts +1 -1
- package/lib/layouts/MaterialArrayLayout.d.ts +1 -1
- package/lib/layouts/MaterialArrayLayoutRenderer.d.ts +1 -1
- package/lib/layouts/MaterialCategorizationLayout.d.ts +3 -3
- package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +3 -3
- package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
- package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
- package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
- package/lib/layouts/unwrapped.d.ts +6 -6
- package/lib/mui-controls/MuiAutocomplete.d.ts +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/layout.d.ts +3 -3
- package/lib/util/theme.d.ts +8 -1
- package/package.json +26 -17
- 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,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback, useMemo, Fragment, useEffect } from 'react';
|
|
2
|
-
import { Hidden, Tabs, Tab, TableCell, styled as styled$1, Badge, Tooltip, TableRow, Grid, Typography, IconButton, FormHelperText, Table, TableHead, TableBody,
|
|
2
|
+
import { Hidden, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Tabs, Tab, TableCell, styled as styled$1, Badge, Tooltip, TableRow, Grid, Typography, IconButton, FormHelperText, Table, TableHead, TableBody, Autocomplete, TextField, Checkbox, useThemeProps, Input, FilledInput, OutlinedInput, useTheme, InputAdornment, Select, MenuItem, Switch, FormControl, FormGroup, FormControlLabel, Toolbar, ListItem, ListItemAvatar, Avatar, ListItemText, ListItemSecondaryAction, List, InputLabel, FormLabel, RadioGroup, Radio, Slider, Accordion, AccordionSummary, AccordionDetails, Card, CardHeader, CardContent, AppBar, Stepper, Step, StepButton } from '@mui/material';
|
|
3
3
|
import { rankWith, isAllOfControl, findMatchingUISchema, createCombinatorRenderInfos, Generate, isLayout, isAnyOfControl, createDefaultValue, Resolve, encode, Paths, formatErrorMessage, errorsAt, or, isObjectArrayControl, isPrimitiveArrayControl, isDescriptionHidden, getAjv, and, uiTypeIs, schemaMatches, hasType, schemaSubPathMatches, isObjectControl, findUISchema, isOneOfControl, isObjectArray, computeLabel, composePaths, showAsRequired, isBooleanControl, optionIs, isDateControl, isDateTimeControl, isEnumControl, isIntegerControl, isTimeControl, isNumberControl, isOneOfEnumControl, isRangeControl, isStringControl, createId, removeId, update, moveUp, moveDown, getFirstPrimitiveProp, withIncreasedRank, isVisible, deriveLabelForUISchemaElement, isObjectArrayWithNesting, isNumberFormatControl, categorizationHasCategory } from '@jsonforms/core';
|
|
4
4
|
import { withJsonFormsAllOfProps, JsonFormsDispatch, withJsonFormsAnyOfProps, DispatchCell, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsMultiEnumProps, withJsonFormsDetailProps, withJsonFormsOneOfProps, withJsonFormsLabelProps, withJsonFormsMasterListItemProps, withJsonFormsControlProps, Control, withJsonFormsEnumProps, withTranslateProps, withJsonFormsOneOfEnumProps, withJsonFormsContext, withJsonFormsLayoutProps, withJsonFormsCellProps, withJsonFormsEnumCellProps, withJsonFormsOneOfEnumCellProps } from '@jsonforms/react';
|
|
5
5
|
import omit from 'lodash/omit';
|
|
@@ -23,7 +23,6 @@ import { LocalizationProvider, DatePicker, DateTimePicker, TimePicker } from '@m
|
|
|
23
23
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
24
24
|
import get from 'lodash/get';
|
|
25
25
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
26
|
-
import Input$1 from '@mui/material/Input';
|
|
27
26
|
|
|
28
27
|
const MaterialAllOfRenderer = ({ schema, rootSchema, visible, renderers, cells, path, uischemas, uischema, }) => {
|
|
29
28
|
const delegateUISchema = findMatchingUISchema(uischemas)(schema, uischema.scope, path);
|
|
@@ -53,15 +52,47 @@ class CombinatorProperties extends React.Component {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
const
|
|
55
|
+
const TabSwitchConfirmDialog = ({ open, handleClose, confirm, cancel, id, }) => {
|
|
56
|
+
return (React.createElement(Dialog, { open: open, onClose: handleClose, "aria-labelledby": 'alert-dialog-title', "aria-describedby": 'alert-dialog-description' },
|
|
57
|
+
React.createElement(DialogTitle, { id: 'alert-dialog-title' }, 'Clear form?'),
|
|
58
|
+
React.createElement(DialogContent, null,
|
|
59
|
+
React.createElement(DialogContentText, { id: 'alert-dialog-description' }, "Your data will be cleared if you navigate away from this tab. Do you want to proceed?")),
|
|
60
|
+
React.createElement(DialogActions, null,
|
|
61
|
+
React.createElement(Button, { onClick: cancel, color: 'primary' }, "No"),
|
|
62
|
+
React.createElement(Button, { onClick: confirm, color: 'primary', autoFocus: true, id: `${id}-confirm-yes` }, "Yes"))));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const MaterialAnyOfRenderer = ({ handleChange, schema, rootSchema, indexOfFittingSchema, visible, path, renderers, cells, uischema, uischemas, id, data, }) => {
|
|
57
66
|
const [selectedAnyOf, setSelectedAnyOf] = useState(indexOfFittingSchema || 0);
|
|
58
|
-
const
|
|
67
|
+
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
68
|
+
const [newSelectedIndex, setNewSelectedIndex] = useState(0);
|
|
69
|
+
const handleClose = useCallback(() => setConfirmDialogOpen(false), [setConfirmDialogOpen]);
|
|
70
|
+
const handleTabChange = useCallback((_event, newIndex) => {
|
|
71
|
+
if (isEmpty(data) ||
|
|
72
|
+
typeof data ===
|
|
73
|
+
typeof createDefaultValue(anyOfRenderInfos[newIndex].schema)) {
|
|
74
|
+
setSelectedAnyOf(newIndex);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
setNewSelectedIndex(newIndex);
|
|
78
|
+
setConfirmDialogOpen(true);
|
|
79
|
+
}
|
|
80
|
+
}, [setConfirmDialogOpen, setSelectedAnyOf, data]);
|
|
81
|
+
const openNewTab = (newIndex) => {
|
|
82
|
+
handleChange(path, createDefaultValue(anyOfRenderInfos[newIndex].schema));
|
|
83
|
+
setSelectedAnyOf(newIndex);
|
|
84
|
+
};
|
|
85
|
+
const confirm = useCallback(() => {
|
|
86
|
+
openNewTab(newSelectedIndex);
|
|
87
|
+
setConfirmDialogOpen(false);
|
|
88
|
+
}, [handleChange, createDefaultValue, newSelectedIndex]);
|
|
59
89
|
const anyOf = 'anyOf';
|
|
60
90
|
const anyOfRenderInfos = createCombinatorRenderInfos(schema.anyOf, rootSchema, anyOf, uischema, path, uischemas);
|
|
61
91
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
62
92
|
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: anyOf, path: path }),
|
|
63
|
-
React.createElement(Tabs, { value: selectedAnyOf, onChange:
|
|
64
|
-
anyOfRenderInfos.map((anyOfRenderInfo, anyOfIndex) => selectedAnyOf === anyOfIndex && (React.createElement(JsonFormsDispatch, { key: anyOfIndex, schema: anyOfRenderInfo.schema, uischema: anyOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells })))
|
|
93
|
+
React.createElement(Tabs, { value: selectedAnyOf, onChange: handleTabChange }, anyOfRenderInfos.map((anyOfRenderInfo) => (React.createElement(Tab, { key: anyOfRenderInfo.label, label: anyOfRenderInfo.label })))),
|
|
94
|
+
anyOfRenderInfos.map((anyOfRenderInfo, anyOfIndex) => selectedAnyOf === anyOfIndex && (React.createElement(JsonFormsDispatch, { key: anyOfIndex, schema: anyOfRenderInfo.schema, uischema: anyOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells }))),
|
|
95
|
+
React.createElement(TabSwitchConfirmDialog, { cancel: handleClose, confirm: confirm, id: 'anyOf-' + id, open: confirmDialogOpen, handleClose: handleClose })));
|
|
65
96
|
};
|
|
66
97
|
const materialAnyOfControlTester = rankWith(3, isAnyOfControl);
|
|
67
98
|
var MaterialAnyOfRenderer$1 = withJsonFormsAnyOfProps(MaterialAnyOfRenderer);
|
|
@@ -300,7 +331,7 @@ const MuiAutocomplete = (props) => {
|
|
|
300
331
|
}, inputValue: inputValue, onInputChange: (_event, newInputValue) => {
|
|
301
332
|
setInputValue(newInputValue);
|
|
302
333
|
}, autoHighlight: true, autoSelect: true, autoComplete: true, fullWidth: true, options: options, getOptionLabel: getOptionLabel || ((option) => option?.label), freeSolo: false, renderInput: (params) => {
|
|
303
|
-
return (React.createElement(TextField, Object.assign({ label: label,
|
|
334
|
+
return (React.createElement(TextField, Object.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 })));
|
|
304
335
|
}, renderOption: renderOption, filterOptions: filterOptions }),
|
|
305
336
|
React.createElement(FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
306
337
|
React.createElement(FormHelperText, { error: !isValid }, secondFormHelperText)));
|
|
@@ -356,6 +387,24 @@ const withAjvProps = (Component) => function WithAjvProps(props) {
|
|
|
356
387
|
return React.createElement(Component, Object.assign({}, props, { ajv: ajv }));
|
|
357
388
|
};
|
|
358
389
|
|
|
390
|
+
const variantToInput = {
|
|
391
|
+
standard: Input,
|
|
392
|
+
filled: FilledInput,
|
|
393
|
+
outlined: OutlinedInput,
|
|
394
|
+
};
|
|
395
|
+
const defaultInputVariant = 'standard';
|
|
396
|
+
function useInputVariant() {
|
|
397
|
+
const { variant = defaultInputVariant } = useThemeProps({
|
|
398
|
+
props: {},
|
|
399
|
+
name: 'MuiTextField',
|
|
400
|
+
});
|
|
401
|
+
return variant;
|
|
402
|
+
}
|
|
403
|
+
function useInputComponent() {
|
|
404
|
+
const variant = useInputVariant();
|
|
405
|
+
return variantToInput[variant] ?? variantToInput[defaultInputVariant];
|
|
406
|
+
}
|
|
407
|
+
|
|
359
408
|
const eventToValue$3 = (ev) => ev.target.value;
|
|
360
409
|
const useDebouncedChange = (handleChange, defaultValue, data, path, eventToValueFunction = eventToValue$3, timeout = 300) => {
|
|
361
410
|
const [input, setInput] = useState(data ?? defaultValue);
|
|
@@ -382,25 +431,28 @@ const i18nDefaults = {
|
|
|
382
431
|
const toNumber$1 = (value) => value === '' ? undefined : parseInt(value, 10);
|
|
383
432
|
const eventToValue$2 = (ev) => toNumber$1(ev.target.value);
|
|
384
433
|
const MuiInputInteger = React.memo(function MuiInputInteger(props) {
|
|
385
|
-
const { data, className, id, enabled, uischema, path, handleChange, config } = props;
|
|
434
|
+
const { data, className, id, enabled, uischema, path, handleChange, config, label, } = props;
|
|
435
|
+
const InputComponent = useInputComponent();
|
|
386
436
|
const inputProps = { step: '1' };
|
|
387
437
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
388
438
|
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue$2);
|
|
389
|
-
return (React.createElement(
|
|
439
|
+
return (React.createElement(InputComponent, { label: label, type: 'number', value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true }));
|
|
390
440
|
});
|
|
391
441
|
|
|
392
442
|
const toNumber = (value) => value === '' ? undefined : parseFloat(value);
|
|
393
443
|
const eventToValue$1 = (ev) => toNumber(ev.target.value);
|
|
394
444
|
const MuiInputNumber = React.memo(function MuiInputNumber(props) {
|
|
395
|
-
const { data, className, id, enabled, uischema, path, handleChange, config } = props;
|
|
445
|
+
const { data, className, id, enabled, uischema, path, handleChange, config, label, } = props;
|
|
446
|
+
const InputComponent = useInputComponent();
|
|
396
447
|
const inputProps = { step: '0.1' };
|
|
397
448
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
398
449
|
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue$1);
|
|
399
|
-
return (React.createElement(
|
|
450
|
+
return (React.createElement(InputComponent, { type: 'number', label: label, value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true }));
|
|
400
451
|
});
|
|
401
452
|
|
|
402
453
|
const MuiInputNumberFormat = React.memo(function MuiInputNumberFormat(props) {
|
|
403
|
-
const { className, id, enabled, uischema, isValid, path, handleChange, schema, config, } = props;
|
|
454
|
+
const { className, id, enabled, uischema, isValid, path, handleChange, schema, config, label, } = props;
|
|
455
|
+
const InputComponent = useInputComponent();
|
|
404
456
|
const maxLength = schema.maxLength;
|
|
405
457
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
406
458
|
let inputProps;
|
|
@@ -413,13 +465,14 @@ const MuiInputNumberFormat = React.memo(function MuiInputNumberFormat(props) {
|
|
|
413
465
|
const formattedNumber = props.toFormatted(props.data);
|
|
414
466
|
const validStringNumber = useCallback((ev) => props.fromFormatted(ev.currentTarget.value), [props.fromFormatted]);
|
|
415
467
|
const [inputValue, onChange] = useDebouncedChange(handleChange, '', formattedNumber, path, validStringNumber);
|
|
416
|
-
return (React.createElement(
|
|
468
|
+
return (React.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 }));
|
|
417
469
|
});
|
|
418
470
|
|
|
419
471
|
const eventToValue = (ev) => ev.target.value === '' ? undefined : ev.target.value;
|
|
420
472
|
const MuiInputText = React.memo(function MuiInputText(props) {
|
|
421
473
|
const [showAdornment, setShowAdornment] = useState(false);
|
|
422
|
-
const { data, config, className, id, enabled, uischema, isValid, path, handleChange, schema, muiInputProps, inputComponent, } = props;
|
|
474
|
+
const { data, config, className, id, enabled, uischema, isValid, path, handleChange, schema, muiInputProps, label, inputComponent, } = props;
|
|
475
|
+
const InputComponent = useInputComponent();
|
|
423
476
|
const maxLength = schema.maxLength;
|
|
424
477
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
425
478
|
let inputProps;
|
|
@@ -442,7 +495,7 @@ const MuiInputText = React.memo(function MuiInputText(props) {
|
|
|
442
495
|
theme.palette.background.default,
|
|
443
496
|
borderRadius: '50%',
|
|
444
497
|
};
|
|
445
|
-
return (React.createElement(
|
|
498
|
+
return (React.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.createElement(InputAdornment, { position: 'end', style: {
|
|
446
499
|
display: !showAdornment || !enabled || data === undefined
|
|
447
500
|
? 'none'
|
|
448
501
|
: 'flex',
|
|
@@ -454,17 +507,18 @@ const MuiInputText = React.memo(function MuiInputText(props) {
|
|
|
454
507
|
});
|
|
455
508
|
|
|
456
509
|
const MuiInputTime = React.memo(function MuiInputTime(props) {
|
|
457
|
-
const { data, className, id, enabled, uischema, path, handleChange, config } = props;
|
|
510
|
+
const { data, className, id, enabled, uischema, path, handleChange, config, label, } = props;
|
|
511
|
+
const InputComponent = useInputComponent();
|
|
458
512
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
459
513
|
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path);
|
|
460
|
-
return (React.createElement(
|
|
514
|
+
return (React.createElement(InputComponent, { type: 'time', value: inputValue, onChange: onChange, className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, fullWidth: true }));
|
|
461
515
|
});
|
|
462
516
|
|
|
463
517
|
const MuiSelect = React.memo(function MuiSelect(props) {
|
|
464
|
-
const { data, className, id, enabled, schema, uischema, path, handleChange, options, config, t, } = props;
|
|
518
|
+
const { data, className, id, enabled, schema, uischema, path, handleChange, options, config, label, t, } = props;
|
|
465
519
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
466
520
|
const noneOptionLabel = useMemo(() => t('enum.none', i18nDefaults['enum.none'], { schema, uischema, path }), [t, schema, uischema, path]);
|
|
467
|
-
return (React.createElement(Select, { className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, value: data !== undefined ? data : '', onChange: (ev) => handleChange(path, ev.target.value || undefined), fullWidth: true
|
|
521
|
+
return (React.createElement(Select, { className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, value: data !== undefined ? data : '', onChange: (ev) => handleChange(path, ev.target.value || undefined), fullWidth: true }, [
|
|
468
522
|
React.createElement(MenuItem, { value: '', key: 'jsonforms.enum.none' },
|
|
469
523
|
React.createElement("em", null, noneOptionLabel)),
|
|
470
524
|
].concat(options.map((optionValue) => (React.createElement(MenuItem, { value: optionValue.value, key: optionValue.value }, optionValue.label))))));
|
|
@@ -518,13 +572,13 @@ const materialObjectControlTester = rankWith(2, isObjectControl);
|
|
|
518
572
|
var MaterialObjectRenderer$1 = withJsonFormsDetailProps(MaterialObjectRenderer);
|
|
519
573
|
|
|
520
574
|
const MaterialOneOfRenderer = ({ handleChange, schema, path, renderers, cells, rootSchema, id, visible, indexOfFittingSchema, uischema, uischemas, data, }) => {
|
|
521
|
-
const [
|
|
575
|
+
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
522
576
|
const [selectedIndex, setSelectedIndex] = useState(indexOfFittingSchema || 0);
|
|
523
577
|
const [newSelectedIndex, setNewSelectedIndex] = useState(0);
|
|
524
|
-
const handleClose = useCallback(() =>
|
|
578
|
+
const handleClose = useCallback(() => setConfirmDialogOpen(false), [setConfirmDialogOpen]);
|
|
525
579
|
const cancel = useCallback(() => {
|
|
526
|
-
|
|
527
|
-
}, [
|
|
580
|
+
setConfirmDialogOpen(false);
|
|
581
|
+
}, [setConfirmDialogOpen]);
|
|
528
582
|
const oneOfRenderInfos = createCombinatorRenderInfos(schema.oneOf, rootSchema, 'oneOf', uischema, path, uischemas);
|
|
529
583
|
const openNewTab = (newIndex) => {
|
|
530
584
|
handleChange(path, createDefaultValue(oneOfRenderInfos[newIndex].schema));
|
|
@@ -532,7 +586,7 @@ const MaterialOneOfRenderer = ({ handleChange, schema, path, renderers, cells, r
|
|
|
532
586
|
};
|
|
533
587
|
const confirm = useCallback(() => {
|
|
534
588
|
openNewTab(newSelectedIndex);
|
|
535
|
-
|
|
589
|
+
setConfirmDialogOpen(false);
|
|
536
590
|
}, [handleChange, createDefaultValue, newSelectedIndex]);
|
|
537
591
|
const handleTabChange = useCallback((_event, newOneOfIndex) => {
|
|
538
592
|
setNewSelectedIndex(newOneOfIndex);
|
|
@@ -540,20 +594,14 @@ const MaterialOneOfRenderer = ({ handleChange, schema, path, renderers, cells, r
|
|
|
540
594
|
openNewTab(newOneOfIndex);
|
|
541
595
|
}
|
|
542
596
|
else {
|
|
543
|
-
|
|
597
|
+
setConfirmDialogOpen(true);
|
|
544
598
|
}
|
|
545
|
-
}, [
|
|
599
|
+
}, [setConfirmDialogOpen, setSelectedIndex, data]);
|
|
546
600
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
547
601
|
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: 'oneOf', path: path }),
|
|
548
602
|
React.createElement(Tabs, { value: selectedIndex, onChange: handleTabChange }, oneOfRenderInfos.map((oneOfRenderInfo) => (React.createElement(Tab, { key: oneOfRenderInfo.label, label: oneOfRenderInfo.label })))),
|
|
549
603
|
oneOfRenderInfos.map((oneOfRenderInfo, oneOfIndex) => selectedIndex === oneOfIndex && (React.createElement(JsonFormsDispatch, { key: oneOfIndex, schema: oneOfRenderInfo.schema, uischema: oneOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells }))),
|
|
550
|
-
React.createElement(
|
|
551
|
-
React.createElement(DialogTitle, { id: 'alert-dialog-title' }, 'Clear form?'),
|
|
552
|
-
React.createElement(DialogContent, null,
|
|
553
|
-
React.createElement(DialogContentText, { id: 'alert-dialog-description' }, "Your data will be cleared if you navigate away from this tab. Do you want to proceed?")),
|
|
554
|
-
React.createElement(DialogActions, null,
|
|
555
|
-
React.createElement(Button, { onClick: cancel, color: 'primary' }, "No"),
|
|
556
|
-
React.createElement(Button, { onClick: confirm, color: 'primary', autoFocus: true, id: `oneOf-${id}-confirm-yes` }, "Yes")))));
|
|
604
|
+
React.createElement(TabSwitchConfirmDialog, { cancel: cancel, confirm: confirm, id: 'oneOf-' + id, open: confirmDialogOpen, handleClose: handleClose })));
|
|
557
605
|
};
|
|
558
606
|
const materialOneOfControlTester = rankWith(3, isOneOfControl);
|
|
559
607
|
var MaterialOneOfRenderer$1 = withJsonFormsOneOfProps(MaterialOneOfRenderer);
|
|
@@ -624,6 +672,7 @@ var MaterialListWithDetailRenderer$1 = withJsonFormsArrayLayoutProps(MaterialLis
|
|
|
624
672
|
const MaterialInputControl = (props) => {
|
|
625
673
|
const [focused, onFocus, onBlur] = useFocus();
|
|
626
674
|
const { id, description, errors, label, uischema, visible, required, config, input, } = props;
|
|
675
|
+
const variant = useInputVariant();
|
|
627
676
|
const isValid = errors.length === 0;
|
|
628
677
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
629
678
|
const showDescription = !isDescriptionHidden(visible, description, focused, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
@@ -635,7 +684,7 @@ const MaterialInputControl = (props) => {
|
|
|
635
684
|
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
636
685
|
const InnerComponent = input;
|
|
637
686
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
638
|
-
React.createElement(FormControl, { fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur,
|
|
687
|
+
React.createElement(FormControl, { fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur, variant: variant, id: id },
|
|
639
688
|
React.createElement(InputLabel, { htmlFor: id + '-input', error: !isValid, required: showAsRequired(required, appliedUiSchemaOptions.hideRequiredAsterisk) }, label),
|
|
640
689
|
React.createElement(InnerComponent, Object.assign({}, props, { id: id + '-input', isValid: isValid, visible: visible })),
|
|
641
690
|
React.createElement(FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
@@ -645,7 +694,8 @@ const MaterialInputControl = (props) => {
|
|
|
645
694
|
const findEnumSchema = (schemas) => schemas.find((s) => s.enum !== undefined && (s.type === 'string' || s.type === undefined));
|
|
646
695
|
const findTextSchema = (schemas) => schemas.find((s) => s.type === 'string' && s.enum === undefined);
|
|
647
696
|
const MuiAutocompleteInputText = (props) => {
|
|
648
|
-
const { data, config, className, id, enabled, uischema, isValid, path, handleChange, schema, } = props;
|
|
697
|
+
const { data, config, className, id, enabled, uischema, isValid, path, handleChange, schema, label, } = props;
|
|
698
|
+
const InputComponent = useInputComponent();
|
|
649
699
|
const enumSchema = findEnumSchema(schema.anyOf);
|
|
650
700
|
const stringSchema = findTextSchema(schema.anyOf);
|
|
651
701
|
const maxLength = stringSchema.maxLength;
|
|
@@ -663,7 +713,7 @@ const MuiAutocompleteInputText = (props) => {
|
|
|
663
713
|
}, [appliedUiSchemaOptions, props.id]);
|
|
664
714
|
const [inputText, onChange] = useDebouncedChange(handleChange, '', data, path);
|
|
665
715
|
const dataList = (React.createElement("datalist", { id: props.id + 'datalist' }, enumSchema.enum.map((optionValue) => (React.createElement("option", { value: optionValue, key: optionValue })))));
|
|
666
|
-
return (React.createElement(
|
|
716
|
+
return (React.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 }));
|
|
667
717
|
};
|
|
668
718
|
class MaterialAnyOfStringOrEnumControl extends Control {
|
|
669
719
|
render() {
|
|
@@ -799,7 +849,6 @@ const MaterialDateControl = (props) => {
|
|
|
799
849
|
InputLabelProps: data ? { shrink: true } : undefined,
|
|
800
850
|
onFocus: onFocus,
|
|
801
851
|
onBlur: onBlur,
|
|
802
|
-
variant: 'standard',
|
|
803
852
|
},
|
|
804
853
|
} }),
|
|
805
854
|
React.createElement(FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
@@ -850,7 +899,6 @@ const MaterialDateTimeControl = (props) => {
|
|
|
850
899
|
InputLabelProps: data ? { shrink: true } : undefined,
|
|
851
900
|
onFocus: onFocus,
|
|
852
901
|
onBlur: onBlur,
|
|
853
|
-
variant: 'standard',
|
|
854
902
|
},
|
|
855
903
|
} }),
|
|
856
904
|
React.createElement(FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
@@ -1001,7 +1049,6 @@ const MaterialTimeControl = (props) => {
|
|
|
1001
1049
|
InputLabelProps: data ? { shrink: true } : undefined,
|
|
1002
1050
|
onFocus: onFocus,
|
|
1003
1051
|
onBlur: onBlur,
|
|
1004
|
-
variant: 'standard',
|
|
1005
1052
|
},
|
|
1006
1053
|
} }),
|
|
1007
1054
|
React.createElement(FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
@@ -1218,9 +1265,10 @@ const materialBooleanToggleCellTester = rankWith(3, and(isBooleanControl, option
|
|
|
1218
1265
|
var MaterialBooleanToggleCell$1 = withJsonFormsCellProps(MaterialBooleanToggleCell);
|
|
1219
1266
|
|
|
1220
1267
|
const MaterialDateCell = (props) => {
|
|
1221
|
-
const { data, className, id, enabled, uischema, path, handleChange, config } = props;
|
|
1268
|
+
const { data, className, id, enabled, uischema, path, handleChange, config, label, } = props;
|
|
1269
|
+
const InputComponent = useInputComponent();
|
|
1222
1270
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
1223
|
-
return (React.createElement(
|
|
1271
|
+
return (React.createElement(InputComponent, { type: 'date', value: data || '', onChange: (ev) => handleChange(path, ev.target.value), className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, fullWidth: true }));
|
|
1224
1272
|
};
|
|
1225
1273
|
const materialDateCellTester = rankWith(2, isDateControl);
|
|
1226
1274
|
var MaterialDateCell$1 = withJsonFormsCellProps(MaterialDateCell);
|
|
@@ -1434,5 +1482,5 @@ const Unwrapped = {
|
|
|
1434
1482
|
...UnwrappedLayouts,
|
|
1435
1483
|
};
|
|
1436
1484
|
|
|
1437
|
-
export { ArrayLayoutToolbar, CombinatorProperties, CustomizableCells as Customizable, DeleteDialog, ExpandPanelRenderer$1 as ExpandPanelRenderer, ListWithDetailMasterItem, MaterialAllOfRenderer$1 as MaterialAllOfRenderer, MaterialAnyOfRenderer$1 as MaterialAnyOfRenderer, MaterialAnyOfStringOrEnumControl$1 as MaterialAnyOfStringOrEnumControl, MaterialArrayControlRenderer$1 as MaterialArrayControlRenderer, MaterialArrayLayout, MaterialBooleanCell$1 as MaterialBooleanCell, MaterialBooleanControl$1 as MaterialBooleanControl, MaterialBooleanToggleCell$1 as MaterialBooleanToggleCell, MaterialBooleanToggleControl$1 as MaterialBooleanToggleControl, MaterialCategorizationLayout, MaterialDateCell$1 as MaterialDateCell, MaterialDateControl$1 as MaterialDateControl, MaterialDateTimeControl$1 as MaterialDateTimeControl, MaterialEnumArrayRenderer$1 as MaterialEnumArrayRenderer, MaterialEnumCell$1 as MaterialEnumCell, MaterialEnumControl$1 as MaterialEnumControl, MaterialGroupLayout, MaterialHorizontalLayout, MaterialInputControl, MaterialIntegerCell$1 as MaterialIntegerCell, MaterialIntegerControl$1 as MaterialIntegerControl, MaterialLabelRenderer$1 as MaterialLabelRenderer, MaterialLayoutRenderer, MaterialListWithDetailRenderer$1 as MaterialListWithDetailRenderer, MaterialNativeControl$1 as MaterialNativeControl, MaterialNumberCell$1 as MaterialNumberCell, MaterialNumberControl$1 as MaterialNumberControl, MaterialNumberFormatCell$1 as MaterialNumberFormatCell, MaterialObjectRenderer$1 as MaterialObjectRenderer, MaterialOneOfEnumCell$1 as MaterialOneOfEnumCell, MaterialOneOfEnumControl$1 as MaterialOneOfEnumControl, MaterialOneOfRadioGroupControl$1 as MaterialOneOfRadioGroupControl, MaterialOneOfRenderer$1 as MaterialOneOfRenderer, MaterialRadioGroupControl$1 as MaterialRadioGroupControl, MaterialSliderControl$1 as MaterialSliderControl, MaterialTableControl, MaterialTextCell$1 as MaterialTextCell, MaterialTextControl$1 as MaterialTextControl, MaterialTimeCell$1 as MaterialTimeCell, MaterialTimeControl$1 as MaterialTimeControl, MaterialVerticalLayout, MuiAutocomplete, MuiCheckbox, MuiInputInteger, MuiInputNumber, MuiInputNumberFormat, MuiInputText, MuiInputTime, MuiSelect, MuiToggle, NoBorderTableCell, NonEmptyRow, Unwrapped, createOnChangeHandler, ctxDispatchToExpandPanelProps, getData, i18nDefaults, materialAllOfControlTester, materialAnyOfControlTester, materialAnyOfStringOrEnumControlTester, materialArrayControlTester, materialArrayLayoutTester, materialBooleanCellTester, materialBooleanControlTester, materialBooleanToggleCellTester, materialBooleanToggleControlTester, materialCategorizationTester, materialCells, materialDateCellTester, materialDateControlTester, materialDateTimeControlTester, materialEnumArrayRendererTester, materialEnumCellTester, materialEnumControlTester, materialGroupTester, materialHorizontalLayoutTester, materialIntegerCellTester, materialIntegerControlTester, materialLabelRendererTester, materialListWithDetailTester, materialNativeControlTester, materialNumberCellTester, materialNumberControlTester, materialNumberFormatCellTester, materialObjectControlTester, materialOneOfControlTester, materialOneOfEnumCellTester, materialOneOfEnumControlTester, materialOneOfRadioGroupControlTester, materialRadioGroupControlTester, materialRenderers, materialSliderControlTester, materialTextCellTester, materialTextControlTester, materialTimeCellTester, materialTimeControlTester, materialVerticalLayoutTester, renderLayoutElements, useDebouncedChange, useFocus, withAjvProps, withContextToExpandPanelProps, withJsonFormsExpandPanelProps };
|
|
1485
|
+
export { ArrayLayoutToolbar, CombinatorProperties, CustomizableCells as Customizable, DeleteDialog, ExpandPanelRenderer$1 as ExpandPanelRenderer, ListWithDetailMasterItem, MaterialAllOfRenderer$1 as MaterialAllOfRenderer, MaterialAnyOfRenderer$1 as MaterialAnyOfRenderer, MaterialAnyOfStringOrEnumControl$1 as MaterialAnyOfStringOrEnumControl, MaterialArrayControlRenderer$1 as MaterialArrayControlRenderer, MaterialArrayLayout, MaterialBooleanCell$1 as MaterialBooleanCell, MaterialBooleanControl$1 as MaterialBooleanControl, MaterialBooleanToggleCell$1 as MaterialBooleanToggleCell, MaterialBooleanToggleControl$1 as MaterialBooleanToggleControl, MaterialCategorizationLayout, MaterialDateCell$1 as MaterialDateCell, MaterialDateControl$1 as MaterialDateControl, MaterialDateTimeControl$1 as MaterialDateTimeControl, MaterialEnumArrayRenderer$1 as MaterialEnumArrayRenderer, MaterialEnumCell$1 as MaterialEnumCell, MaterialEnumControl$1 as MaterialEnumControl, MaterialGroupLayout, MaterialHorizontalLayout, MaterialInputControl, MaterialIntegerCell$1 as MaterialIntegerCell, MaterialIntegerControl$1 as MaterialIntegerControl, MaterialLabelRenderer$1 as MaterialLabelRenderer, MaterialLayoutRenderer, MaterialListWithDetailRenderer$1 as MaterialListWithDetailRenderer, MaterialNativeControl$1 as MaterialNativeControl, MaterialNumberCell$1 as MaterialNumberCell, MaterialNumberControl$1 as MaterialNumberControl, MaterialNumberFormatCell$1 as MaterialNumberFormatCell, MaterialObjectRenderer$1 as MaterialObjectRenderer, MaterialOneOfEnumCell$1 as MaterialOneOfEnumCell, MaterialOneOfEnumControl$1 as MaterialOneOfEnumControl, MaterialOneOfRadioGroupControl$1 as MaterialOneOfRadioGroupControl, MaterialOneOfRenderer$1 as MaterialOneOfRenderer, MaterialRadioGroupControl$1 as MaterialRadioGroupControl, MaterialSliderControl$1 as MaterialSliderControl, MaterialTableControl, MaterialTextCell$1 as MaterialTextCell, MaterialTextControl$1 as MaterialTextControl, MaterialTimeCell$1 as MaterialTimeCell, MaterialTimeControl$1 as MaterialTimeControl, MaterialVerticalLayout, MuiAutocomplete, MuiCheckbox, MuiInputInteger, MuiInputNumber, MuiInputNumberFormat, MuiInputText, MuiInputTime, MuiSelect, MuiToggle, NoBorderTableCell, NonEmptyRow, Unwrapped, createOnChangeHandler, ctxDispatchToExpandPanelProps, defaultInputVariant, getData, i18nDefaults, materialAllOfControlTester, materialAnyOfControlTester, materialAnyOfStringOrEnumControlTester, materialArrayControlTester, materialArrayLayoutTester, materialBooleanCellTester, materialBooleanControlTester, materialBooleanToggleCellTester, materialBooleanToggleControlTester, materialCategorizationTester, materialCells, materialDateCellTester, materialDateControlTester, materialDateTimeControlTester, materialEnumArrayRendererTester, materialEnumCellTester, materialEnumControlTester, materialGroupTester, materialHorizontalLayoutTester, materialIntegerCellTester, materialIntegerControlTester, materialLabelRendererTester, materialListWithDetailTester, materialNativeControlTester, materialNumberCellTester, materialNumberControlTester, materialNumberFormatCellTester, materialObjectControlTester, materialOneOfControlTester, materialOneOfEnumCellTester, materialOneOfEnumControlTester, materialOneOfRadioGroupControlTester, materialRadioGroupControlTester, materialRenderers, materialSliderControlTester, materialTextCellTester, materialTextControlTester, materialTimeCellTester, materialTimeControlTester, materialVerticalLayoutTester, renderLayoutElements, useDebouncedChange, useFocus, useInputComponent, useInputVariant, withAjvProps, withContextToExpandPanelProps, withJsonFormsExpandPanelProps };
|
|
1438
1486
|
//# sourceMappingURL=jsonforms-react-material.esm.js.map
|