@@ -10,41 +10,66 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
10
10
*/
11
11
12
12
import React from 'react' ;
13
+
13
14
import SLDSUtilityIcon from '../../utilities/utility-icon' ;
14
15
15
- const displayName = 'InputIcon' ;
16
-
17
- const propTypes = {
18
- category : React . PropTypes . string ,
19
- name : React . PropTypes . string ,
20
- onClick : React . PropTypes . func ,
21
- } ;
22
- const defaultProps = {
23
- category : 'utility' ,
24
- } ;
25
-
26
- class InputIcon extends React . Component {
27
-
28
- constructor ( props ) {
29
- super ( props ) ;
30
- this . state = { } ;
31
- }
32
-
33
- render ( ) {
34
- const className = 'slds-input__icon slds-icon-text-default' ;
35
- return < SLDSUtilityIcon
36
- style = { this . props . style }
37
- aria-hidden = 'true'
38
- category = { this . props . category }
39
- className = { className }
40
- name = { this . props . name }
41
- onClick = { this . props . onClick }
42
- /> ;
43
- }
44
- }
45
-
46
- InputIcon . displayName = displayName ;
47
- InputIcon . propTypes = propTypes ;
48
- InputIcon . defaultProps = defaultProps ;
16
+ import { ICON_INPUT } from '../../../utilities/constants' ;
17
+
18
+ // Remove the need for `React.PropTypes`
19
+ const { PropTypes } = React ;
20
+
21
+ // ### isFunction
22
+ import isFunction from 'lodash.isfunction' ;
23
+
24
+ const InputIcon = React . createClass ( {
25
+
26
+ displayName : ICON_INPUT ,
27
+
28
+ propTypes : {
29
+ category : PropTypes . string ,
30
+ name : PropTypes . string ,
31
+ style : PropTypes . string ,
32
+ /**
33
+ * This event fires when the icon is clicked.
34
+ */
35
+ onClick : PropTypes . func
36
+ } ,
37
+
38
+ getDefaultProps ( ) {
39
+ return {
40
+ category : 'utility'
41
+ } ;
42
+ } ,
43
+
44
+ render ( ) {
45
+ const onClickIsFunction = isFunction ( this . props . onClick ) ;
46
+
47
+ return (
48
+ < div >
49
+ { onClickIsFunction ?
50
+ < button
51
+ className = "slds-input__icon slds-button slds-button--icon"
52
+ onClick = { this . props . onClick }
53
+ >
54
+ < SLDSUtilityIcon
55
+ style = { this . props . style }
56
+ aria-hidden
57
+ category = { this . props . category }
58
+ className = "slds-button__icon slds-icon-text-default"
59
+ name = { this . props . name }
60
+ />
61
+ </ button >
62
+ : < SLDSUtilityIcon
63
+ style = { this . props . style }
64
+ aria-hidden
65
+ category = { this . props . category }
66
+ className = "slds-input__icon slds-icon-text-default"
67
+ name = { this . props . name }
68
+ />
69
+ }
70
+ </ div >
71
+ ) ;
72
+ }
73
+ } ) ;
49
74
50
75
module . exports = InputIcon ;
0 commit comments