@@ -25,10 +25,14 @@ class TimeInput extends React.Component {
2525 defaultValue . setSeconds ( 0 )
2626 defaultValue . setMilliseconds ( 0 )
2727
28+ const open = ! ! props . autoOpen
29+ const value = props . value || props . defaultValue || props . initialTime || defaultValue
30+
2831 this . state = {
29- open : false ,
30- value : props . value || props . defaultValue || props . initialTime || defaultValue ,
31- hasChanged : false
32+ open,
33+ value,
34+ hasChanged : false ,
35+ newValue : open ? value : null
3236 }
3337 }
3438
@@ -80,6 +84,7 @@ class TimeInput extends React.Component {
8084 render ( ) {
8185 const {
8286 autoOk,
87+ autoOpen, // eslint-disable-line
8388 cancelLabel,
8489 classes,
8590 defaultValue,
@@ -91,6 +96,8 @@ class TimeInput extends React.Component {
9196 okLabel,
9297 onChange,
9398 value : valueProp ,
99+ ClockProps,
100+ TimePickerProps,
94101 ...other
95102 } = this . props
96103
@@ -114,11 +121,13 @@ class TimeInput extends React.Component {
114121 onClose = { this . handleCancel }
115122 >
116123 < TimePicker
124+ { ...TimePickerProps }
117125 mode = { mode }
118126 value = { newValue }
119127 onChange = { this . handleChange }
120128 onMinutesSelected = { autoOk ? this . handleOk : null }
121129 classes = { { header : classes . header , body : classes . body } }
130+ ClockProps = { ClockProps }
122131 />
123132 < DialogActions >
124133 < Button onClick = { this . handleCancel } color = 'primary' > { cancelLabel } </ Button >
@@ -133,6 +142,8 @@ class TimeInput extends React.Component {
133142TimeInput . propTypes = {
134143 /** If true, automatically accept and close the picker on set minutes. */
135144 autoOk : PropTypes . bool ,
145+ /** If true, automatically opens the dialog when the component is mounted */
146+ autoOpen : PropTypes . bool ,
136147 /** Override the label of the cancel button. */
137148 cancelLabel : PropTypes . string ,
138149 /** This default value overrides initialTime and placeholder. */
@@ -150,7 +161,11 @@ TimeInput.propTypes = {
150161 /** Callback that is called with the new date (as Date instance) when the value is changed. */
151162 onChange : PropTypes . func ,
152163 /** The value of the time picker, for use in controlled mode. */
153- value : PropTypes . instanceOf ( Date )
164+ value : PropTypes . instanceOf ( Date ) ,
165+ /** Properties to pass down to the TimePicker component */
166+ TimePickerProps : PropTypes . object ,
167+ /** Properties to pass down to the Clock component */
168+ ClockProps : PropTypes . object
154169}
155170
156171TimeInput . defaultProps = {
0 commit comments