commit | author | age
|
92485e
|
1 |
// Type definitions for react-datetime |
IV |
2 |
// Project: https://github.com/YouCanBookMe/react-datetime |
|
3 |
// Definitions by: Ivan Verevkin <vereva@x-root.org> |
|
4 |
|
a20f58
|
5 |
// These are the typings for Typescript 1.8 |
AS |
6 |
// for Typescrip 2.0+ see typings/index.d.ts |
|
7 |
|
92485e
|
8 |
//// <reference path="../moment/moment-node.d.ts" /> |
IV |
9 |
|
|
10 |
declare module ReactDatetime { |
|
11 |
import React = __React; |
|
12 |
// import * as moment from 'moment'; |
|
13 |
|
|
14 |
export interface DatetimepickerProps { |
|
15 |
/* |
|
16 |
Represents the selected date by the component, in order to use it as a controlled component. |
|
17 |
This prop is parsed by moment.js, so it is possible to use a date string or a moment.js date. |
|
18 |
*/ |
fe4c5c
|
19 |
value?: Date; |
92485e
|
20 |
/* |
IV |
21 |
Represents the selected date for the component to use it as a uncontrolled component. |
|
22 |
This prop is parsed by moment.js, so it is possible to use a date string or a moment.js date. |
|
23 |
*/ |
fe4c5c
|
24 |
defaultValue?: Date; |
92485e
|
25 |
/* |
IV |
26 |
Defines the format for the date. It accepts any moment.js date format. |
|
27 |
If true the date will be displayed using the defaults for the current locale. |
|
28 |
If false the datepicker is disabled and the component can be used as timepicker. |
|
29 |
*/ |
|
30 |
dateFormat?: boolean|string; |
|
31 |
/* |
|
32 |
Defines the format for the time. It accepts any moment.js time format. |
|
33 |
If true the time will be displayed using the defaults for the current locale. |
|
34 |
If false the timepicker is disabled and the component can be used as datepicker. |
|
35 |
*/ |
|
36 |
timeFormat?: boolean|string; |
|
37 |
/* |
c5845c
|
38 |
Whether to show an input field to edit the date manually. |
92485e
|
39 |
*/ |
IV |
40 |
input?: boolean; |
|
41 |
/* |
c5845c
|
42 |
Whether to open or close the picker. If not set react-datetime will open the |
92485e
|
43 |
datepicker on input focus and close it on click outside. |
IV |
44 |
*/ |
|
45 |
open?: boolean; |
|
46 |
/* |
|
47 |
Manually set the locale for the react-datetime instance. |
|
48 |
Moment.js locale needs to be loaded to be used, see i18n docs. |
|
49 |
*/ |
|
50 |
locale?: string; |
|
51 |
/* |
049c33
|
52 |
Whether to interpret input times as UTC or the user's local timezone. |
TS |
53 |
*/ |
|
54 |
utc?: boolean; |
|
55 |
/* |
fe4c5c
|
56 |
Callback trigger when the date changes. The callback receives the selected `moment` object as |
MV |
57 |
only parameter, if the date in the input is valid. If the date in the input is not valid, the |
|
58 |
callback receives the value of the input (a string). |
92485e
|
59 |
*/ |
fe4c5c
|
60 |
onChange?: (momentOrInputString: string|any) => void; |
92485e
|
61 |
/* |
IV |
62 |
Callback trigger for when the user opens the datepicker. |
|
63 |
*/ |
fe4c5c
|
64 |
onFocus?: () => void; |
92485e
|
65 |
/* |
IV |
66 |
Callback trigger for when the user clicks outside of the input, simulating a regular onBlur. |
fe4c5c
|
67 |
The callback receives the selected `moment` object as only parameter, if the date in the input |
MV |
68 |
is valid. If the date in the input is not valid, the callback receives the value of the |
|
69 |
input (a string). |
92485e
|
70 |
*/ |
fe4c5c
|
71 |
onBlur?: (momentOrInputString : string|any) => void; |
92485e
|
72 |
/* |
IV |
73 |
The default view to display when the picker is shown. ('years', 'months', 'days', 'time') |
|
74 |
*/ |
|
75 |
viewMode?: string|number; |
|
76 |
/* |
|
77 |
Extra class names for the component markup. |
|
78 |
*/ |
|
79 |
className?: string; |
|
80 |
/* |
|
81 |
Defines additional attributes for the input element of the component. |
|
82 |
*/ |
|
83 |
inputProps?: Object; |
|
84 |
/* |
|
85 |
Define the dates that can be selected. The function receives (currentDate, selectedDate) |
|
86 |
and should return a true or false whether the currentDate is valid or not. See selectable dates. |
|
87 |
*/ |
fe4c5c
|
88 |
isValidDate?: (currentDate: any, selectedDate: any) => boolean; |
92485e
|
89 |
/* |
IV |
90 |
Customize the way that the days are shown in the day picker. The accepted function has |
|
91 |
the selectedDate, the current date and the default calculated props for the cell, |
|
92 |
and must return a React component. See appearance customization |
|
93 |
*/ |
fe4c5c
|
94 |
renderDay?: (props: any, currentDate: any, selectedDate: any) => React.Component<any, any>; |
92485e
|
95 |
/* |
IV |
96 |
Customize the way that the months are shown in the month picker. |
|
97 |
The accepted function has the selectedDate, the current date and the default calculated |
|
98 |
props for the cell, the month and the year to be shown, and must return a |
|
99 |
React component. See appearance customization |
|
100 |
*/ |
fe4c5c
|
101 |
renderMonth?: (props: any, month: number, year: number, selectedDate: any) => React.Component<any, any>; |
92485e
|
102 |
/* |
IV |
103 |
Customize the way that the years are shown in the year picker. |
|
104 |
The accepted function has the selectedDate, the current date and the default calculated |
|
105 |
props for the cell, the year to be shown, and must return a React component. |
|
106 |
See appearance customization |
|
107 |
*/ |
fe4c5c
|
108 |
renderYear?: (props: any, year: number, selectedDate: any) => React.Component<any, any>; |
92485e
|
109 |
/* |
IV |
110 |
Whether to use moment's strict parsing when parsing input. |
|
111 |
*/ |
|
112 |
strictParsing?: boolean; |
|
113 |
/* |
|
114 |
When true, once the day has been selected, the react-datetime will be automatically closed. |
|
115 |
*/ |
|
116 |
closeOnSelect?: boolean; |
fe4c5c
|
117 |
/* |
MV |
118 |
Allow to add some constraints to the time selector. It accepts an object with the format |
|
119 |
{hours:{ min: 9, max: 15, step:2}} so the hours can't be lower than 9 or higher than 15, and |
|
120 |
it will change adding or subtracting 2 hours everytime the buttons are clicked. The constraints |
|
121 |
can be added to the hours, minutes, seconds and milliseconds. |
|
122 |
*/ |
049c33
|
123 |
timeConstraints?: Object; |
fe4c5c
|
124 |
/* |
MV |
125 |
When true, keep the picker open when click event is triggered outside of component. When false, |
|
126 |
close it. |
|
127 |
*/ |
|
128 |
disableOnClickOutside?: boolean; |
92485e
|
129 |
} |
IV |
130 |
|
|
131 |
interface DatetimeComponent extends React.ComponentClass<DatetimepickerProps> { |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
135 |
declare module "react-datetime" { |
|
136 |
var ReactDatetime: ReactDatetime.DatetimeComponent; |
|
137 |
export = ReactDatetime; |
|
138 |
} |