react-datetime
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -142,3 +142,3 @@ 'use strict'; | ||
me.setState({ | ||
viewDate: me.state.viewDate.clone()[ type ]( e.target.innerHTML ).startOf( type ), | ||
viewDate: me.state.viewDate.clone()[ type ]( parseInt(e.target.dataset.value) ).startOf( type ), | ||
currentView: nextViews[ type ] | ||
@@ -210,3 +210,3 @@ }); | ||
.month( this.state.viewDate.month() + modifier ) | ||
.date( parseInt( target.innerHTML ) ) | ||
.date( parseInt( target.dataset.value ) ) | ||
.hours( currentDate.hours() ) | ||
@@ -242,3 +242,3 @@ .minutes( currentDate.minutes() ) | ||
componentProps: { | ||
fromProps: ['viewMode', 'minDate', 'maxDate'], | ||
fromProps: ['viewMode', 'minDate', 'maxDate', 'renderDay', 'renderMonth', 'renderYear'], | ||
fromState: ['viewDate', 'selectedDate' ], | ||
@@ -245,0 +245,0 @@ fromThis: ['setDate', 'setTime', 'showView', 'addTime', 'subtractTime', 'updateDate', 'localMoment'] |
{ | ||
"name": "react-datetime", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "A lightweight but complete datetime picker React.js component.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/arqex/react-datetime", |
@@ -5,2 +5,4 @@ react-datetime | ||
It allows to edit even date's milliseconds. | ||
This project started as a fork of https://github.com/quri/react-bootstrap-datetimepicker but the code and the API has changed a lot. | ||
@@ -34,4 +36,4 @@ | ||
| **date** | Date | new Date() | Represents the inital dateTime, this string is then parsed by moment.js | | ||
| **dateFormat** | string | "MM/DD/YY" | Defines the format moment.js should use to parse and output the date. The default is only set if there is not `timeFormat` defined. | | ||
| **timeFormat** | string | "MM/DD/YY" | Defines the format moment.js should use to parse and output the time. The default is only set if there is not `dateFormat` defined. | | ||
| **dateFormat** | string | Locale default | Defines the format moment.js should use to parse and output the date. The default is only set if there is not `timeFormat` defined. | | ||
| **timeFormat** | string | Locale default | Defines the format moment.js should use to parse and output the time. The default is only set if there is not `dateFormat` defined. | | ||
| **input** | boolean | true | Wether to show an input field to edit the date manually. | | ||
@@ -44,2 +46,5 @@ | **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). | ||
| **maxDate** | moment | undefined | The latest date allowed for entry in the calendar view. | | ||
| **renderDay** | function | DOM.td( day ) | 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](#appearance_customization) | | ||
| **renderMonth** | function | DOM.td( month ) | 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, and must return a React component. See [appearance customization](#appearance_customization) | | ||
| **renderYear** | function | DOM.td( year ) | 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, and must return a React component. See [appearance customization](#appearance_customization) | | ||
@@ -62,2 +67,30 @@ ## i18n | ||
## Appearance customization | ||
It is possible to customize the way that the datetime picker display the days, months and years in the calendar. To adapt the calendar to every need it is possible to use the props `renderDay( props, currentDate, selectedDate )`, `renderMonth( props, month, year, selectedDate )` and `renderYear( props, year, selectedDate )` of react-datetime. | ||
```js | ||
var MyDTPicker = React.createClass({ | ||
render: function(){ | ||
return <Datetime | ||
renderDay={ this.renderDay } | ||
renderMonth={ this.renderMonth } | ||
renderYear={ this.renderYear } | ||
/>; | ||
}, | ||
renderDay: function( selectedDate, currentDate, props ){ | ||
return <td {...props}>{ currentDate.date() }</td>; | ||
}, | ||
renderMonth: function( selectedDate, currentMonthDate, props ){ | ||
return <td {...props}>{ month }</td>; | ||
}, | ||
renderDay: function( selectedDate, year, props ){ | ||
return <td {...props}>{ currentDate.date() }</td>; | ||
} | ||
}); | ||
``` | ||
* `props` is the object that react-date picker has calculated for this object. It is convenient to use this object as the props for your custom component, since it knows how to handle the click event and its `className` attribute is used by the default styles. | ||
* `selectedDate` and `currentDate` are Moment.js objects and can be used to change the output depending on the selected date, or the date for the current day. | ||
* `month` and `year` are the numeric representation of the current month and year to be displayed. Notice that the possible `month` values go from `0` to `11`. | ||
Contributions | ||
@@ -64,0 +97,0 @@ =============================== |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20259
97
0