react-calendar
Advanced tools
Comparing version 2.14.0 to 2.15.0
@@ -107,2 +107,7 @@ 'use strict'; | ||
var rawValueFrom = value instanceof Array && value.length === 2 ? value[0] : value; | ||
if (!rawValueFrom) { | ||
return null; | ||
} | ||
var valueFromDate = new Date(rawValueFrom); | ||
@@ -125,2 +130,7 @@ | ||
var rawValueTo = value instanceof Array && value.length === 2 ? value[1] : value; | ||
if (!rawValueTo) { | ||
return null; | ||
} | ||
var valueToDate = new Date(rawValueTo); | ||
@@ -361,2 +371,3 @@ | ||
nextLabel: this.props.nextLabel, | ||
navigationLabel: this.props.navigationLabel, | ||
prev2Label: this.props.prev2Label, | ||
@@ -487,2 +498,3 @@ prevLabel: this.props.prevLabel, | ||
minDetail: _propTypes2.default.oneOf(allViews), | ||
navigationLabel: _propTypes2.default.func, | ||
next2Label: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.node]), | ||
@@ -489,0 +501,0 @@ nextLabel: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.node]), |
@@ -87,3 +87,4 @@ 'use strict'; | ||
drillUp = _props.drillUp, | ||
view = _props.view; | ||
view = _props.view, | ||
date = _props.activeStartDate; | ||
@@ -99,3 +100,3 @@ | ||
}, | ||
view !== 'century' && _react2.default.createElement( | ||
this.props.prev2Label !== null && view !== 'century' && _react2.default.createElement( | ||
'button', | ||
@@ -129,3 +130,3 @@ { | ||
}, | ||
label | ||
this.props.navigationLabel ? this.props.navigationLabel({ date: date, view: view, label: label }) : label | ||
), | ||
@@ -142,3 +143,3 @@ _react2.default.createElement( | ||
), | ||
view !== 'century' && _react2.default.createElement( | ||
this.props.next2Label !== null && view !== 'century' && _react2.default.createElement( | ||
'button', | ||
@@ -264,2 +265,3 @@ { | ||
nextLabel: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.node]), | ||
navigationLabel: _propTypes2.default.func, | ||
prev2Label: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.node]), | ||
@@ -266,0 +268,0 @@ prevLabel: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.node]), |
{ | ||
"name": "react-calendar", | ||
"version": "2.14.0", | ||
"version": "2.15.0", | ||
"description": "Ultimate calendar for your React app.", | ||
@@ -9,6 +9,7 @@ "main": "dist/entry.js", | ||
"scripts": { | ||
"build": "npm run build-js && npm run copy-styles && npm run build-styles", | ||
"build-js": "babel src -d dist --ignore **/__tests__", | ||
"build": "npm run build-js && npm run copy-styles && npm run build-styles && npm run copy-types", | ||
"build-js": "babel src -d dist --ignore __tests__", | ||
"build-styles": "lessc ./dist/Calendar.less ./dist/Calendar.css", | ||
"copy-styles": "node ./copy-styles.js", | ||
"copy-types": "node ./copy-types.js", | ||
"prepublishOnly": "npm run build", | ||
@@ -46,2 +47,5 @@ "test": "npm run test-eslint && npm run test-jest", | ||
{ | ||
"name": "Jack Willis-Craig" | ||
}, | ||
{ | ||
"name": "Justin Davis" | ||
@@ -48,0 +52,0 @@ }, |
@@ -96,2 +96,3 @@ ![downloads](https://img.shields.io/npm/dt/react-calendar.svg) ![build](https://img.shields.io/travis/wojtekmaj/react-calendar/master.svg) ![dependencies](https://img.shields.io/david/wojtekmaj/react-calendar.svg | ||
|minDetail|Defines the least detailed view that the user shall see. Can be "month", "year", "decade" or "century". Defaults to "century".|`"century"`| | ||
|navigationLabel|Defines the content of a label rendered on calendar navigation bar.|``({ date, view, label }) => `Current view: ${view}, date: ${date.toLocaleDateString()}` ``| | ||
|nextLabel|Defines the content of the "next" button on the navigation pane. Defaults to "›".|<ul><li>String: `"›"`</li><li>React element: `<NextIcon />`</li></ul>| | ||
@@ -136,3 +137,3 @@ |next2Label|Defines the content of the "next on higher level" button on the navigation pane. Defaults to "»". |<ul><li>String: `"»"`</li><li>React element: `<DoubleNextIcon />`</li></ul>| | ||
|tileContent|Allows to render custom content within a given item (day on month view, month on year view and so on). Note: For tiles with custom content you might want to set fixed height of `react-calendar__tile` to ensure consistent layout.|`({ date, view }) => view === 'month' && date.getDay() === 0 ? <p>It's Sunday!</p> : null`| | ||
|value|Defines the value of the calendar.|<ul><li>Date: `new Date()`</li><li>An array of dates: `[new Date(2017, 0, 1), new Date(2017, 7, 1)]`</li><li>String: `2017-01-01`</li><li>An array of dates: `['2017-01-01', '2017-08-01']`</li></ul>| | ||
|value|Defines the value of the calendar.|<ul><li>Date: `new Date()`</li><li>An array of dates: `[new Date(2017, 0, 1), new Date(2017, 7, 1)]`</li><li>String: `2017-01-01`</li><li>An array of strings: `['2017-01-01', '2017-08-01']`</li></ul>| | ||
@@ -139,0 +140,0 @@ ## License |
@@ -60,2 +60,7 @@ import React, { Component } from 'react'; | ||
const rawValueFrom = value instanceof Array && value.length === 2 ? value[0] : value; | ||
if (!rawValueFrom) { | ||
return null; | ||
} | ||
const valueFromDate = new Date(rawValueFrom); | ||
@@ -78,2 +83,7 @@ | ||
const rawValueTo = value instanceof Array && value.length === 2 ? value[1] : value; | ||
if (!rawValueTo) { | ||
return null; | ||
} | ||
const valueToDate = new Date(rawValueTo); | ||
@@ -371,2 +381,3 @@ | ||
nextLabel={this.props.nextLabel} | ||
navigationLabel={this.props.navigationLabel} | ||
prev2Label={this.props.prev2Label} | ||
@@ -425,2 +436,3 @@ prevLabel={this.props.prevLabel} | ||
minDetail: PropTypes.oneOf(allViews), | ||
navigationLabel: PropTypes.func, | ||
next2Label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), | ||
@@ -427,0 +439,0 @@ nextLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), |
@@ -433,2 +433,26 @@ import React from 'react'; | ||
}); | ||
it('renders custom navigation label when given navigationLabel prop', () => { | ||
const date = new Date(2017, 0, 1); | ||
const label = 'Custom label'; | ||
const view = 'month'; | ||
const navigationLabel = jest.fn().mockReturnValue(label); | ||
const component = shallow( | ||
<Navigation | ||
activeStartDate={date} | ||
drillUp={jest.fn()} | ||
navigationLabel={navigationLabel} | ||
setActiveStartDate={jest.fn()} | ||
view={view} | ||
views={allViews} | ||
/> | ||
); | ||
const [, , drillUp] = component.children(); | ||
expect(navigationLabel).toHaveBeenCalledWith({ date, view, label: 'January 2017' }); | ||
expect(drillUp.props.children.toString()).toBe(label); | ||
}); | ||
}); |
@@ -104,3 +104,3 @@ import React, { Component } from 'react'; | ||
const { label } = this; | ||
const { drillUp, view } = this.props; | ||
const { drillUp, view, activeStartDate: date } = this.props; | ||
@@ -114,4 +114,3 @@ const className = 'react-calendar__navigation'; | ||
> | ||
{ | ||
view !== 'century' && | ||
{this.props.prev2Label !== null && view !== 'century' && ( | ||
<button | ||
@@ -125,3 +124,3 @@ className={`${className}__arrow ${className}__prev2-button`} | ||
</button> | ||
} | ||
)} | ||
<button | ||
@@ -142,3 +141,6 @@ className={`${className}__arrow ${className}__prev-button`} | ||
> | ||
{label} | ||
{this.props.navigationLabel ? | ||
this.props.navigationLabel({ date, view, label }) : | ||
label | ||
} | ||
</button> | ||
@@ -153,4 +155,3 @@ <button | ||
</button> | ||
{ | ||
view !== 'century' && | ||
{this.props.next2Label !== null && view !== 'century' && ( | ||
<button | ||
@@ -164,3 +165,3 @@ className={`${className}__arrow ${className}__next2-button`} | ||
</button> | ||
} | ||
)} | ||
</div> | ||
@@ -188,2 +189,3 @@ ); | ||
nextLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), | ||
navigationLabel: PropTypes.func, | ||
prev2Label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), | ||
@@ -190,0 +192,0 @@ prevLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
320514
78
7968
156