All files / src/form/fields/ValidationMessage ValidationMessage.js

100% Statements 5/5
57.14% Branches 4/7
100% Functions 1/1
100% Lines 5/5

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 50                    1x 1x 1x                                                       12x 12x                
import React from 'react';
import { defaultProps } from './props/defaultProps';
import { propTypes } from './props/propTypes';
import Label from '@zohodesk/components/lib/Label/Label';
import colors from '@zohodesk/components/lib/Label/LabelColors.module.css';
import style from './ValidationMessage.module.css';
import { Icon } from '@zohodesk/icons';
 
export default class ValidationMessage extends React.Component {
  render() {
    let { palette, text, htmlFor, onClick, type, size, dataId, clipped, a11y, tooltip, dataSelectorId } = this.props;
    let { role = 'alert' } = a11y;
    return (
      <div
        role={role}
        onClick={onClick}
        className={`${type === 'primary' ? style.primary : style.secondary}`}
        data-id='errorMsgContainer'
        data-test-id='errorMsgContainer'
        data-selector-id={dataSelectorId}
      >
        <Label
          text={text}
          htmlFor={htmlFor}
          palette={palette}
          size={size}
          dataId={dataId}
          clipped={clipped}
          title={clipped ? text : ''}
          customClass={style.lable}
        />
        {tooltip ? (
          <span className={`${style.icon} ${colors[palette]}`} data-title={tooltip}>
            <Icon name='ZD-information57' size='14' />
          </span>
        ) : null}
      </div>
    );
  }
}
ValidationMessage.propTypes = propTypes;
ValidationMessage.defaultProps = defaultProps;
 
// if (__DOCS__) {
//   ValidationMessage.docs = {
//     componentGroup: 'Form Fields',
//     folderName: 'Style Guide'
//   };
// }