marquex
2015-10-14 87c67792b0cfb269cfb473975b98c8b6c83006cd
Adds open attribute
2 files modified
10 ■■■■ changed files
DateTime.js 9 ●●●●● patch | view | raw | blame | history
README.md 1 ●●●● patch | view | raw | blame | history
DateTime.js
@@ -52,7 +52,9 @@
    getInitialState: function() {
        var state = this.getStateFromProps( this.props );
        state.open = !this.props.input;
        if( state.open == undefined )
            state.open = !this.props.input;
        state.currentView = this.props.dateFormat ? this.props.viewMode : 'time';
        return state;
@@ -81,7 +83,8 @@
            inputFormat: formats.datetime,
            viewDate: viewDate,
            selectedDate: selectedDate,
            inputValue: selectedDate ? selectedDate.format( formats.datetime ) : (date || '')
            inputValue: selectedDate ? selectedDate.format( formats.datetime ) : (date || ''),
            open: props.open != undefined ? props.open : this.state && this.state.open
        };
    },
@@ -249,7 +252,7 @@
    },
    handleClickOutside: function(){
        if( this.props.input && this.state.open ){
        if( this.props.input && this.state.open && !this.props.open ){
            this.setState({ open: false });
            this.props.onBlur( this.state.selectedDate || this.state.inputValue );
        }
README.md
@@ -41,6 +41,7 @@
| **dateFormat**   | `bool` or `string`  | `true` | Defines the format for the date. It accepts any [moment.js date format](http://momentjs.com/docs/#/displaying/format/). If `true` the date will be displayed using the defaults for the current locale. If `false` the datepicker is disabled and the component can be used as timepicker. |
| **timeFormat**   | `bool` or `string`  | `true` | Defines the format for the time. It accepts any [moment.js time format](http://momentjs.com/docs/#/displaying/format/). If `true` the time will be displayed using the defaults for the current locale. If `false` the timepicker is disabled and the component can be used as datepicker. |
| **input** | boolean | true | Wether to show an input field to edit the date manually. |
| **open** | boolean | null | Wether to open or close the picker. If not set react-datetime will open the datepicker on input focus and close it on click outside. |
| **locale** | string | null | Manually set the locale for the react-datetime instance. Moment.js locale needs to be loaded to be used, see [i18n docs](#i18n).
| **onChange** | function | empty function | Callback trigger when the date changes. The callback receives the selected `moment` object as only parameter, if the date in the input is valid. If it isn't, the value of the input (a string) is returned. |
| **onBlur** | function | empty function | Callback trigger for when the user clicks outside of the input, simulating a regular onBlur. The callback receives the selected `moment` object as only parameter, if the date in the input is valid. If it isn't, the value of the input (a string) is returned. |