-
Notifications
You must be signed in to change notification settings - Fork 37
/
TextFieldIcon.js
38 lines (35 loc) · 1.07 KB
/
TextFieldIcon.js
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
/**
* Text Field Icon
*/
import React from 'react';
import PropTypes from 'prop-types';
import css from './TextField.css';
import Icon from '../Icon';
import IconButton from '../IconButton';
const TextFieldIcon = ({ onClick, ariaLabel, icon, iconClassName, onMouseDown, tabIndex, id, iconSize = 'medium', ...rest }) => (
<div className={css.textFieldIcon}>
{ (typeof onClick === 'function' || typeof onMouseDown === 'function') ? (
<IconButton
aria-label={rest['aria-label'] || ariaLabel}
onClick={onClick}
onMouseDown={onMouseDown}
tabIndex={tabIndex}
icon={icon}
size="small"
id={id}
iconClassName={iconClassName}
/>
) : <Icon id={id} icon={icon} size={iconSize} iconClassName={iconClassName} />}
</div>
);
TextFieldIcon.propTypes = {
ariaLabel: PropTypes.string,
icon: PropTypes.string,
iconClassName: PropTypes.string,
iconSize: PropTypes.string,
id: PropTypes.string,
onClick: PropTypes.func,
onMouseDown: PropTypes.func,
tabIndex: PropTypes.string,
};
export default TextFieldIcon;