Skip to content

Commit b8a9a7f

Browse files
Dan Forstersimeg
Dan Forster
authored andcommitted
Add optional renderInput prop
1 parent f7c600b commit b8a9a7f

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

DateTime.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,27 @@ var Datetime = createClass({
416416
children = [];
417417

418418
if ( this.props.input ) {
419-
children = [ React.createElement( 'input', assign({
420-
key: 'i',
421-
type: 'text',
422-
className: 'form-control',
423-
onClick: this.openCalendar,
424-
onFocus: this.openCalendar,
425-
onChange: this.onInputChange,
426-
onKeyDown: this.onInputKey,
427-
value: this.state.inputValue
428-
}, this.props.inputProps ))];
419+
if ( this.props.renderInput ) {
420+
children = children.concat( this.props.renderInput({
421+
onClick: this.openCalendar,
422+
onFocus: this.openCalendar,
423+
onChange: this.onInputChange,
424+
onKeyDown: this.onInputKey,
425+
value: this.state.inputValue,
426+
openCalendar: this.openCalendar,
427+
}) );
428+
} else {
429+
children = [ DOM.input( assign({
430+
key: 'i',
431+
type: 'text',
432+
className: 'form-control',
433+
onClick: this.openCalendar,
434+
onFocus: this.openCalendar,
435+
onChange: this.onInputChange,
436+
onKeyDown: this.onInputKey,
437+
value: this.state.inputValue
438+
}, this.props.inputProps ))];
439+
}
429440
} else {
430441
className += ' rdtStatic';
431442
}

0 commit comments

Comments
 (0)