Miha Valencic
2016-09-20 fe4c5cf1cc613b9a3d473b95489703bb4409d3ce
Updating typings config to reflect actual callback parameters (#146)

* Updating typings config to reflect actual callback parameters

* Make timeconstraints property optional

* Fixed code style and some signatures; Refs #146

* Fixing readme styling; Refs #146
2 files modified
47 ■■■■■ changed files
README.md 6 ●●●● patch | view | raw | blame | history
react-datetime.d.ts 41 ●●●●● patch | view | raw | blame | history
README.md
@@ -42,9 +42,9 @@
| **input** | `boolean` | `true` | Whether to show an input field to edit the date manually. |
| **open** | `boolean` | `null` | Whether 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. |
| **onFocus** | `function` | empty `function` | Callback trigger for when the user opens the datepicker. |
| **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. |
| **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 the date in the input is not valid, the callback receives the value of the input (a string). |
| **onFocus** | `function` | empty function | Callback trigger for when the user opens the datepicker. |
| **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 the date in the input is not valid, the callback returned. |
| **viewMode** | `string` or `number` | `'days'` | The default view to display when the picker is shown (`'years'`, `'months'`, `'days'`, `'time'`). |
| **className** | `string` or `string array` | `''` | Extra class name for the outermost markup element. |
| **inputProps** | `object` | `undefined` | Defines additional attributes for the input element of the component. For example: `placeholder`, `disabled` and `required`. |
react-datetime.d.ts
@@ -13,12 +13,12 @@
     Represents the selected date by the component, in order to use it as a controlled component.
     This prop is parsed by moment.js, so it is possible to use a date string or a moment.js date.
     */
    value?: string;
    value?: Date;
    /*
     Represents the selected date for the component to use it as a uncontrolled component.
     This prop is parsed by moment.js, so it is possible to use a date string or a moment.js date.
     */
    defaultValue?: string;
    defaultValue?: Date;
    /*
     Defines the format for the date. It accepts any moment.js date format.
     If true the date will be displayed using the defaults for the current locale.
@@ -46,21 +46,22 @@
     */
    locale?: string;
    /*
     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.
     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 the date in the input is not valid, the
     callback receives the value of the input (a string).
     */
    onChange?:(x: string) => void;
    onChange?: (momentOrInputString: string|any) => void;
    /*
     Callback trigger for when the user opens the datepicker.
     */
    onFocus?: (e : FocusEvent) => void;
    onFocus?: () => void;
    /*
     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.
     The callback receives the selected `moment` object as only parameter, if the date in the input
     is valid. If the date in the input is not valid, the callback receives the value of the
     input (a string).
     */
    onBlurs?: (e : FocusEvent) => void;
    onBlur?: (momentOrInputString : string|any) => void;
    /*
     The default view to display when the picker is shown. ('years', 'months', 'days', 'time')
     */
@@ -77,27 +78,27 @@
     Define the dates that can be selected. The function receives (currentDate, selectedDate)
     and should return a true or false whether the currentDate is valid or not. See selectable dates.
     */
    isValidDate?: (x: string) => void;
    isValidDate?: (currentDate: any, selectedDate: any) => boolean;
    /*
     Customize the way that the days are shown in the day picker. The accepted function has
     the selectedDate, the current date and the default calculated props for the cell,
     and must return a React component. See appearance customization
     */
    renderDay?: (x: string) => void;
    renderDay?: (props: any, currentDate: any, selectedDate: any) => React.Component<any, any>;
    /*
     Customize the way that the months are shown in the month picker.
     The accepted function has the selectedDate, the current date and the default calculated
     props for the cell, the month and the year to be shown, and must return a
     React component. See appearance customization
     */
    renderMonth?: (x: string) => void;
    renderMonth?: (props: any, month: number, year: number, selectedDate: any) => React.Component<any, any>;
    /*
     Customize the way that the years are shown in the year picker.
     The accepted function has the selectedDate, the current date and the default calculated
     props for the cell, the year to be shown, and must return a React component.
     See appearance customization
     */
    renderYear?: (x: string) => void;
    renderYear?: (props: any, year: number, selectedDate: any) => React.Component<any, any>;
    /*
     Whether to use moment's strict parsing when parsing input.
     */
@@ -106,6 +107,18 @@
     When true, once the day has been selected, the react-datetime will be automatically closed.
     */
    closeOnSelect?: boolean;
    /*
     Allow to add some constraints to the time selector. It accepts an object with the format
     {hours:{ min: 9, max: 15, step:2}} so the hours can't be lower than 9 or higher than 15, and
     it will change adding or subtracting 2 hours everytime the buttons are clicked. The constraints
     can be added to the hours, minutes, seconds and milliseconds.
    */
    timeConstraints?: Object;
    /*
     When true, keep the picker open when click event is triggered outside of component. When false,
     close it.
    */
    disableOnClickOutside?: boolean;
  }
  interface DatetimeComponent extends React.ComponentClass<DatetimepickerProps> {