arqex
2015-07-09 1599b392fee17397ea810673e3d4516a13885cd6
Merge pull request #5 from anateus/feature/blur

Added a simulation of onBlur to enable final save events and the like
2 files modified
6 ■■■■ changed files
DateTime.js 5 ●●●● patch | view | raw | blame | history
README.md 1 ●●●● patch | view | raw | blame | history
DateTime.js
@@ -22,6 +22,7 @@
    },
    propTypes: {
        date: TYPES.object,
        onBlur: TYPES.func,
        onChange: TYPES.func,
        locale: TYPES.string,
        input: TYPES.bool,
@@ -39,6 +40,7 @@
            viewMode: 'days',
            inputProps: {},
            input: true,
            onBlur: function () {},
            onChange: function (x) {
                console.log(x);
            }
@@ -217,7 +219,7 @@
            selectedDate: date,
            viewDate: date.clone().startOf('month'),
            inputValue: date.format( this.state.inputFormat )
        });
        }, this.callOnChange );
    },
    openCalendar: function() {
@@ -225,6 +227,7 @@
    },
    handleClickOutside: function(){
        this.props.onBlur(this.state.inputValue);
        if( this.props.input && this.state.open )
            this.setState({ open: false });
    },
README.md
@@ -37,6 +37,7 @@
| **input** | boolean | true | Wether to show an input field to edit the date manually. |
| **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 | x => console.log(x) | Callback trigger when the date changes |
| **onBlur** | function | empty function | Callback trigger for when the user clicks outside of the input, simulating a regular onBlur |
| **viewMode** | string or number | 'days' | The default view to display when the picker is shown. ('years', 'months', 'days', 'time') |
| **inputProps** | object | undefined | Defines additional attributes for the input element of the component. |
| **minDate** | moment | undefined | The earliest date allowed for entry in the calendar view. |