You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You’ll need to install React, PropTypes, and Moment.js separately since those dependencies aren’t included in the package. Below is a simple example of how to use the Datepicker in a React view. You will also need to require the CSS file from this package (or provide your own). The example below shows how to include the CSS from this package if your build system supports requiring CSS files (Webpack is one that does).
@@ -48,10 +48,12 @@ class Example extends React.Component {
48
48
}
49
49
50
50
render() {
51
-
return<DatePicker
51
+
return (
52
+
<DatePicker
52
53
selected={this.state.startDate}
53
54
onChange={this.handleChange}
54
-
/>;
55
+
/>
56
+
);
55
57
}
56
58
}
57
59
```
@@ -67,7 +69,8 @@ The most basic use of the DatePicker can be described with:
67
69
You can use `onSelect` event handler which fires each time some calendar date has been selected
68
70
69
71
```js
70
-
<DatePicker selected={this.state.date}
72
+
<DatePicker
73
+
selected={this.state.date}
71
74
onSelect={this.handleSelect} //when day is clicked
72
75
onChange={this.handleChange} //only when value has changed
73
76
/>
@@ -86,7 +89,8 @@ You can also include a time picker by adding the showTimeSelect prop
86
89
selected={this.state.date}
87
90
onChange={this.handleChange}
88
91
showTimeSelect
89
-
dateFormat="LLL"/>
92
+
dateFormat="LLL"
93
+
/>
90
94
```
91
95
92
96
Times will be displayed at 30-minute intervals by default (default configurable via timeInterval prop)
@@ -97,8 +101,8 @@ More examples of how to use the time picker are given on the [main website](http
97
101
98
102
The date picker relies on [moment.js internationalization](http://momentjs.com/docs/#/i18n/) to localize its display components. By default, the date picker will use the locale globally set in moment, which is English. Locales can be changed in the following ways:
99
103
100
-
-**Globally** by calling `moment.locale(lang)`
101
-
-**Picker-specific** by providing the `locale` prop
104
+
***Globally** by calling `moment.locale(lang)`
105
+
***Picker-specific** by providing the `locale` prop
102
106
103
107
Locales can be further configured in moment with various [customization options](http://momentjs.com/docs/#/customization/).
104
108
@@ -111,40 +115,42 @@ _As of version 0.23, the `weekdays` and `weekStart` DatePicker props have been r
111
115
We're always trying to stay compatible with the latest version of React. We can't support all older versions of React.
112
116
113
117
Latest compatible versions:
114
-
- React 15.5 or newer: All above React-datepicker v.0.40.0
115
-
- React 15.4.1: needs React-datepicker v0.40.0, newer won't work (due to react-onclickoutside dependencies)
116
-
- React 0.14 or newer: All above React-datepicker v0.13.0
117
-
- React 0.13: React-datepicker v0.13.0
118
-
- pre React 0.13: React-datepicker v0.6.2
118
+
119
+
* React 15.5 or newer: All above React-datepicker v.0.40.0
120
+
* React 15.4.1: needs React-datepicker v0.40.0, newer won't work (due to react-onclickoutside dependencies)
121
+
* React 0.14 or newer: All above React-datepicker v0.13.0
122
+
* React 0.13: React-datepicker v0.13.0
123
+
* pre React 0.13: React-datepicker v0.6.2
119
124
120
125
### Browser Support
121
126
122
127
The date picker is compatible with the latest versions of Chrome, Firefox, and IE10+.
123
128
124
-
Unfortunately, it is difficult to support legacy browsers while maintaining our ability to develop new features in the future. For IE9 support, it is known that the [classlist polyfill](https://www.npmjs.com/package/classlist-polyfill) is needed, but this may change or break at any point in the future.
129
+
Unfortunately, it is difficult to support legacy browsers while maintaining our ability to develop new features in the future. For IE9 support, it is known that the [classlist polyfill](https://www.npmjs.com/package/classlist-polyfill) is needed, but this may change or break at any point in the future.
125
130
126
131
## Local Development
127
132
128
133
The `master` branch contains the latest version of the Datepicker component. To start your example app, you can run `yarn start`. This starts a simple webserver on http://localhost:8080.
129
134
130
-
You can run `yarn test` to execute the test suite and linters. To help you develop the component we’ve set up some tests that cover the basic functionality (can be found in `/tests`). Even though we’re big fans of testing, this only covers a small piece of the component. We highly recommend you add tests when you’re adding new functionality.
135
+
You can run `yarn test` to execute the test suite and linters. To help you develop the component we’ve set up some tests that cover the basic functionality (can be found in `/tests`). Even though we’re big fans of testing, this only covers a small piece of the component. We highly recommend you add tests when you’re adding new functionality.
131
136
132
137
### The examples
138
+
133
139
The examples are hosted within the docs folder and are ran in the simple app that loads the Datepicker. To extend the examples with a new example, you can simply duplicate one of the existing examples and change the unique properties of your example.
134
140
135
141
## Accessibility
136
142
137
143
### Keyboard support
138
144
139
-
**Left*: Move to the previous day.
140
-
**Right*: Move to the next day.
141
-
**Up*: Move to the previous week.
142
-
**Down*: Move to the next week.
143
-
**PgUp*: Move to the previous month.
144
-
**PgDn*: Move to the next month.
145
-
**Home*: Move to the previous year.
146
-
**End*: Move to the next year.
147
-
**Enter/Esc/Tab*: close the calendar. (Enter & Esc calls preventDefault)
145
+
*_Left_: Move to the previous day.
146
+
*_Right_: Move to the next day.
147
+
*_Up_: Move to the previous week.
148
+
*_Down_: Move to the next week.
149
+
*_PgUp_: Move to the previous month.
150
+
*_PgDn_: Move to the next month.
151
+
*_Home_: Move to the previous year.
152
+
*_End_: Move to the next year.
153
+
*_Enter/Esc/Tab_: close the calendar. (Enter & Esc calls preventDefault)
0 commit comments