aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementLeafList.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/odlux/apps/configurationApp/src/components/uiElementLeafList.tsx')
-rw-r--r--sdnr/wt/odlux/apps/configurationApp/src/components/uiElementLeafList.tsx170
1 files changed, 87 insertions, 83 deletions
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementLeafList.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementLeafList.tsx
index 5937ed7b3..669ddff63 100644
--- a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementLeafList.tsx
+++ b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementLeafList.tsx
@@ -16,19 +16,23 @@
* ============LICENSE_END==========================================================================
*/
-import * as React from "react"
-import { FormControl, InputLabel, Paper, Chip, FormHelperText, Dialog, DialogTitle, DialogContentText, DialogActions, Button, DialogContent } from "@mui/material";
+import React from 'react';
+import FormControl from '@mui/material/FormControl';
+import InputLabel from '@mui/material/InputLabel';
+import Chip from '@mui/material/Chip';
+import Dialog from '@mui/material/Dialog';
+import DialogTitle from '@mui/material/DialogTitle';
+import DialogContent from '@mui/material/DialogContent';
+import DialogActions from '@mui/material/DialogActions';
+import Button from '@mui/material/Button';
+
import makeStyles from '@mui/styles/makeStyles';
import AddIcon from '@mui/icons-material/Add';
import { Theme } from '@mui/material/styles';
-import { ViewElement } from "../models/uiModels";
-
-import { BaseProps } from "./baseProps";
+import { ViewElement } from '../models/uiModels';
-type LeafListProps = BaseProps<any []> & {
- getEditorForViewElement: (uiElement: ViewElement) => (null | React.ComponentType<BaseProps<any>>)
-};
+import { BaseProps } from './baseProps';
const useStyles = makeStyles((theme: Theme) => {
const light = theme.palette.mode === 'light';
@@ -50,93 +54,93 @@ const useStyles = makeStyles((theme: Theme) => {
margin: theme.spacing(0.5),
},
underline: {
- '&:after': {
- borderBottom: `2px solid ${theme.palette.primary.main}`,
- left: 0,
- bottom: 0,
- // Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
- content: '""',
- position: 'absolute',
- right: 0,
- transform: 'scaleX(0)',
- transition: theme.transitions.create('transform', {
- duration: theme.transitions.duration.shorter,
- easing: theme.transitions.easing.easeOut,
- }),
- pointerEvents: 'none', // Transparent to the hover style.
- },
- '&.Mui-focused:after': {
- transform: 'scaleX(1)',
- },
- '&.Mui-error:after': {
- borderBottomColor: theme.palette.error.main,
- transform: 'scaleX(1)', // error is always underlined in red
- },
- '&:before': {
+ '&:after': {
+ borderBottom: `2px solid ${theme.palette.primary.main}`,
+ left: 0,
+ bottom: 0,
+ // Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
+ content: '""',
+ position: 'absolute',
+ right: 0,
+ transform: 'scaleX(0)',
+ transition: theme.transitions.create('transform', {
+ duration: theme.transitions.duration.shorter,
+ easing: theme.transitions.easing.easeOut,
+ }),
+ pointerEvents: 'none', // Transparent to the hover style.
+ },
+ '&.Mui-focused:after': {
+ transform: 'scaleX(1)',
+ },
+ '&.Mui-error:after': {
+ borderBottomColor: theme.palette.error.main,
+ transform: 'scaleX(1)', // error is always underlined in red
+ },
+ '&:before': {
+ borderBottom: `1px solid ${bottomLineColor}`,
+ left: 0,
+ bottom: 0,
+ // Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
+ content: '"\\00a0"',
+ position: 'absolute',
+ right: 0,
+ transition: theme.transitions.create('border-bottom-color', {
+ duration: theme.transitions.duration.shorter,
+ }),
+ pointerEvents: 'none', // Transparent to the hover style.
+ },
+ '&:hover:not($disabled):before': {
+ borderBottom: `2px solid ${theme.palette.text.primary}`,
+ // Reset on touch devices, it doesn't add specificity
+ // eslint-disable-next-line @typescript-eslint/naming-convention
+ '@media (hover: none)': {
borderBottom: `1px solid ${bottomLineColor}`,
- left: 0,
- bottom: 0,
- // Doing the other way around crash on IE 11 "''" https://github.com/cssinjs/jss/issues/242
- content: '"\\00a0"',
- position: 'absolute',
- right: 0,
- transition: theme.transitions.create('border-bottom-color', {
- duration: theme.transitions.duration.shorter,
- }),
- pointerEvents: 'none', // Transparent to the hover style.
- },
- '&:hover:not($disabled):before': {
- borderBottom: `2px solid ${theme.palette.text.primary}`,
- // Reset on touch devices, it doesn't add specificity
- '@media (hover: none)': {
- borderBottom: `1px solid ${bottomLineColor}`,
- },
- },
- '&.Mui-disabled:before': {
- borderBottomStyle: 'dotted',
},
},
- })
+ '&.Mui-disabled:before': {
+ borderBottomStyle: 'dotted',
+ },
+ },
+ });
});
+type LeafListProps = BaseProps<any []> & {
+ getEditorForViewElement: (uiElement: ViewElement) => (null | React.ComponentType<BaseProps<any>>);
+};
+
export const UiElementLeafList = (props: LeafListProps) => {
const { value: element, inputValue, onChange } = props;
const classes = useStyles();
const [open, setOpen] = React.useState(false);
- const [editorValue, setEditorValue] = React.useState("");
+ const [editorValue, setEditorValue] = React.useState('');
const [editorValueIndex, setEditorValueIndex] = React.useState(-1);
-
- const handleClickOpen = () => {
- setOpen(true);
- };
-
const handleClose = () => {
setOpen(false);
};
const onApplyButton = () => {
- if (editorValue != null && editorValue != "" && editorValueIndex < 0) {
- props.onChange([
- ...inputValue,
- editorValue,
- ]);
- } else if (editorValue != null && editorValue != "") {
- props.onChange([
- ...inputValue.slice(0, editorValueIndex),
- editorValue,
- ...inputValue.slice(editorValueIndex+1),
- ]);
- }
- setOpen(false);
+ if (editorValue != null && editorValue != '' && editorValueIndex < 0) {
+ props.onChange([
+ ...inputValue,
+ editorValue,
+ ]);
+ } else if (editorValue != null && editorValue != '') {
+ props.onChange([
+ ...inputValue.slice(0, editorValueIndex),
+ editorValue,
+ ...inputValue.slice(editorValueIndex + 1),
+ ]);
+ }
+ setOpen(false);
};
const onDelete = (index : number) => {
const newValue : any[] = [
...inputValue.slice(0, index),
- ...inputValue.slice(index+1),
+ ...inputValue.slice(index + 1),
];
onChange(newValue);
};
@@ -151,15 +155,15 @@ export const UiElementLeafList = (props: LeafListProps) => {
{ !props.readOnly ? <li>
<Chip
icon={<AddIcon />}
- label={"Add"}
+ label={'Add'}
className={classes.chip}
size="small"
color="secondary"
onClick={ () => {
setOpen(true);
- setEditorValue("");
+ setEditorValue('');
setEditorValueIndex(-1);
- }
+ }
}
/>
</li> : null }
@@ -172,24 +176,24 @@ export const UiElementLeafList = (props: LeafListProps) => {
label={String(val)}
onDelete={ !props.readOnly ? () => { onDelete(ind); } : undefined }
onClick={ !props.readOnly ? () => {
- setOpen(true);
- setEditorValue(val);
- setEditorValueIndex(ind);
- } : undefined
+ setOpen(true);
+ setEditorValue(val);
+ setEditorValueIndex(ind);
+ } : undefined
}
/>
</li>
- ))
+ ))
}
</ul>
{/* <FormHelperText>{ "Value is mandetory"}</FormHelperText> */}
</FormControl>
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
- <DialogTitle id="form-dialog-title">{editorValueIndex < 0 ? "Add new value" : "Edit value" } </DialogTitle>
+ <DialogTitle id="form-dialog-title">{editorValueIndex < 0 ? 'Add new value' : 'Edit value' } </DialogTitle>
<DialogContent>
{ ValueEditor && <ValueEditor
inputValue={ editorValue }
- value={{ ...element, isList: false}}
+ value={{ ...element, isList: false }}
disabled={false}
readOnly={props.readOnly}
onChange={ setEditorValue }
@@ -197,7 +201,7 @@ export const UiElementLeafList = (props: LeafListProps) => {
</DialogContent>
<DialogActions>
<Button color="inherit" onClick={ handleClose }> Cancel </Button>
- <Button disabled={editorValue == null || editorValue === "" } onClick={ onApplyButton } color="secondary"> {editorValueIndex < 0 ? "Add" : "Apply"} </Button>
+ <Button disabled={editorValue == null || editorValue === '' } onClick={ onApplyButton } color="secondary"> {editorValueIndex < 0 ? 'Add' : 'Apply'} </Button>
</DialogActions>
</Dialog>
</>