All files / widgets/CreateNotebookJobForm InputContainer.tsx

100% Statements 9/9
100% Branches 3/3
100% Functions 1/1
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 451x 1x   1x 1x   1x 1x                   1x             20x                                     1x  
import React from 'react';
import InfoIcon from '@mui/icons-material/Info';
 
import { TextInput, TextInputProps } from '../../components/textinput';
import { Tooltip } from '../../components/tooltip';
 
import * as Styles from './styles';
import { strHasLength } from '../../utils';
 
interface InputContainerProps extends TextInputProps {
  labelInfo: string;
  required?: boolean;
  errorMessage?: string;
  toolTipText?: string;
  readOnly?: boolean;
}
 
const InputContainer: React.FunctionComponent<InputContainerProps> = ({
  labelInfo,
  required,
  toolTipText,
  errorMessage,
  ...inputProps
}) => {
  return (
    <div className={Styles.InputContainer}>
      <div className={Styles.tooltipsContainer}>
        <label className={Styles.InputLabel(required)}> {labelInfo} </label>
        {toolTipText && !inputProps.readOnly && (
          <Tooltip title={toolTipText} className={Styles.tooltips}>
            <InfoIcon />
          </Tooltip>
        )}
      </div>
      <TextInput {...inputProps} error={strHasLength(errorMessage)} helperText={errorMessage}
        InputProps={{
          readOnly: inputProps.readOnly,
          ...inputProps.InputProps
        }} />
    </div>
  );
};
 
export { InputContainer };