Skip to content

Commit ea4ce08

Browse files
author
Radosław Rosłaniec
committed
Hande custom input component
1 parent fe4c5cf commit ea4ce08

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

DateTime.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var Datetime = React.createClass({
2828
onChange: TYPES.func,
2929
locale: TYPES.string,
3030
input: TYPES.bool,
31+
inputComponent: TYPES.element,
3132
// dateFormat: TYPES.string | TYPES.bool,
3233
// timeFormat: TYPES.string | TYPES.bool,
3334
inputProps: TYPES.object,
@@ -46,6 +47,7 @@ var Datetime = React.createClass({
4647
className: '',
4748
defaultValue: '',
4849
inputProps: {},
50+
inputComponent: null,
4951
input: true,
5052
onFocus: nof,
5153
onBlur: nof,
@@ -376,7 +378,7 @@ var Datetime = React.createClass({
376378
children = []
377379
;
378380

379-
if ( this.props.input ){
381+
if ( this.props.input && !this.props.inputComponent ){
380382
children = [ DOM.input( assign({
381383
key: 'i',
382384
type:'text',
@@ -386,6 +388,15 @@ var Datetime = React.createClass({
386388
onKeyDown: this.onInputKey,
387389
value: this.state.inputValue
388390
}, this.props.inputProps ))];
391+
} else if ( this.props.inputComponent ) {
392+
children = [
393+
React.cloneElement( this.props.inputComponent, assign({
394+
key: 'i',
395+
onFocus: this.openCalendar,
396+
onChange: this.onInputChange,
397+
onKeyDown: this.onInputKey,
398+
value: this.state.inputValue
399+
}, this.props.inputProps ))];
389400
} else {
390401
className += ' rdtStatic';
391402
}

0 commit comments

Comments
 (0)