2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
19 import { ViewElementBase } from "models/uiModels";
20 import { TextField, InputAdornment, Input, Tooltip, Divider, IconButton, InputBase, Paper, makeStyles, Theme, createStyles, FormControl, InputLabel, FormHelperText } from "@material-ui/core";
21 import * as React from 'react';
22 import { faAdjust } from "@fortawesome/free-solid-svg-icons";
23 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
24 import { InputProps } from "@material-ui/core/Input";
26 const useStyles = makeStyles((theme: Theme) =>
41 type IfwhenProps = InputProps & {
43 element: ViewElementBase;
46 onChangeTooltipVisuability(value: boolean): void;
49 export const IfWhenTextInput = (props: IfwhenProps) => {
51 const { element, onChangeTooltipVisuability: toogleTooltip, id, label, helperText: errorText, error, style, ...otherProps } = props;
52 const classes = useStyles();
55 const ifFeature = element.ifFeature
57 <Tooltip onMouseMove={e => props.onChangeTooltipVisuability(false)} onMouseOut={e => props.onChangeTooltipVisuability(true)} title={element.ifFeature}>
58 <InputAdornment position="start">
59 <FontAwesomeIcon icon={faAdjust} className={classes.iconDark} />
65 const whenFeature = element.when
67 <Tooltip className={classes.padding} onMouseMove={() => props.onChangeTooltipVisuability(false)} onMouseOut={() => props.onChangeTooltipVisuability(true)} title={element.when}>
68 <InputAdornment className={classes.padding} position="end">
69 <FontAwesomeIcon icon={faAdjust} className={classes.iconLight}/>
76 <FormControl error={error} style={style}>
77 <InputLabel htmlFor={id} >{label}</InputLabel>
78 <Input id={id} endAdornment={<div>{ifFeature}{whenFeature}</div>} {...otherProps} />
79 <FormHelperText>{errorText}</FormHelperText>