@@ -20,35 +20,28 @@ import {KEYS,EventUtil} from '../utils';
2020const displayName = 'SLDSDatepickerSingleSelect' ;
2121const propTypes = {
2222 abbrWeekDayLabels : React . PropTypes . array ,
23-
2423 /**
2524 * Date formatting function
2625 */
2726 formatter : React . PropTypes . func ,
28-
2927 monthLabels : React . PropTypes . array ,
30-
3128 /**
3229 * Parsing date string into Date
3330 */
3431 parser : React . PropTypes . func ,
35-
3632 relativeYearFrom : React . PropTypes . number ,
37-
3833 relativeYearTo : React . PropTypes . number ,
39-
34+ /**
35+ * If true, adds asterisk next to input label to indicate it is a required field.
36+ */
37+ required : React . PropTypes . bool ,
38+ strValue : React . PropTypes . string ,
4039 todayLabel : React . PropTypes . string ,
41-
4240 /**
4341 * Date
4442 */
4543 value : React . PropTypes . instanceOf ( Date ) ,
46-
47- strValue : React . PropTypes . string ,
48-
4944 weekDayLabels : React . PropTypes . array ,
50-
51-
5245} ;
5346const defaultProps = {
5447 abbrWeekDayLabels : [ 'S' , 'M' , 'T' , 'W' , 'T' , 'F' , 'S' ] ,
@@ -74,6 +67,7 @@ const defaultProps = {
7467 placeholder : 'Pick a Date' ,
7568 relativeYearFrom : - 5 ,
7669 relativeYearTo : 5 ,
70+ required : false ,
7771 todayLabel : 'Today' ,
7872 value : null ,
7973 weekDayLabels : [
@@ -196,16 +190,22 @@ module.exports = React.createClass({
196190 return < InputIcon name = 'event' style = { { pointerEvents : 'none' } } /> ;
197191 } ,
198192
193+ inputRefName ( ) {
194+ return `${ this . props . label } Datepicker` ;
195+ } ,
196+
199197 render ( ) {
198+ const required = this . props . required ? < span style = { { color :"red" } } > * </ span > :null ;
199+ const inputLabel = this . props . label ?< label className = "slds-form-element__label" htmlFor = { this . inputRefName ( ) } style = { { width : "100%" } } > { required } { this . props . label } </ label > :null ;
200200 return (
201201 < div className = 'slds-form-element' >
202- < label className = 'slds-form-element__label' htmlFor = 'date' > { this . props . label } </ label >
202+ { inputLabel }
203203 < div className = 'slds-form-element__control' >
204204 < div className = 'slds-input-has-icon slds-input-has-icon--right' >
205205
206206 { this . getInputIcon ( ) }
207207 < input
208- name = 'date'
208+ id = { this . inputRefName ( ) }
209209 ref = 'date'
210210 className = 'slds-input'
211211 type = 'text'
0 commit comments