All files / widgets/CreateNotebookJobForm SelectInputContainer.tsx

100% Statements 10/10
70% Branches 7/10
100% Functions 1/1
100% Lines 10/10

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 45 46 47 48 49 501x 1x 1x   1x 1x 1x                 1x               8x           8x                                     1x  
import React from 'react';
import { Tooltip } from '../../components/tooltip/Tooltip';
import { SelectInput, SelectInputProps } from '../../components/selectinput';
 
import InfoIcon from '@mui/icons-material/Info';
import * as Styles from './styles';
import * as WidgetStyles from '../styles';
 
interface SelectInputContainerProps extends SelectInputProps {
  required?: boolean;
  errorMessage?: string;
  toolTipText?: string;
  toolTipArea?: { descriptionText: string; toolTipComponent: React.ReactNode };
}
 
const SelectInputContainer: React.FunctionComponent<SelectInputContainerProps> = ({
  label,
  required = true,
  toolTipText,
  toolTipArea,
  errorMessage,
  ...inputProps
}) => {
  const toolTipAreaComponent = toolTipArea && (
    <div>
      <span className={WidgetStyles.TooltipTextContainer}>{toolTipArea.descriptionText}</span>
      {toolTipArea.toolTipComponent}
    </div>
  );
  return (
    <div className={Styles.SelectInputContainer}>
      <div className={Styles.tooltipsContainer}>
        <label className={Styles.InputLabel(required)}>{label}</label>
        {(toolTipText || toolTipArea) && !inputProps.readOnly && (
          <Tooltip
            title={toolTipAreaComponent || toolTipText || ''}
            className={Styles.tooltips}
            disableInteractive={toolTipArea === null}
          >
            <InfoIcon />
          </Tooltip>
        )}
      </div>
      <SelectInput label={label} disableClearable={true} {...inputProps} />
    </div>
  );
};
 
export { SelectInputContainer, SelectInputContainerProps };