react-calendar
Advanced tools
Comparing version 3.0.0-beta.4 to 3.0.0-beta.5
@@ -226,3 +226,3 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
_defineProperty(_assertThisInitialized(_this), "drillDown", function (nextActiveStartDate) { | ||
_defineProperty(_assertThisInitialized(_this), "drillDown", function (nextActiveStartDate, event) { | ||
if (!_this.drillDownAvailable) { | ||
@@ -232,3 +232,3 @@ return; | ||
_this.onClickTile(nextActiveStartDate); | ||
_this.onClickTile(nextActiveStartDate, event); | ||
@@ -262,3 +262,3 @@ var _assertThisInitialize2 = _assertThisInitialized(_this), | ||
_defineProperty(_assertThisInitialized(_this), "onChange", function (value) { | ||
_defineProperty(_assertThisInitialized(_this), "onChange", function (value, event) { | ||
var _this$props2 = _this.props, | ||
@@ -268,3 +268,3 @@ onChange = _this$props2.onChange, | ||
_this.onClickTile(value); | ||
_this.onClickTile(value, event); | ||
@@ -306,3 +306,3 @@ var nextValue; | ||
_defineProperty(_assertThisInitialized(_this), "onClickTile", function (value) { | ||
_defineProperty(_assertThisInitialized(_this), "onClickTile", function (value, event) { | ||
var _assertThisInitialize5 = _assertThisInitialized(_this), | ||
@@ -317,3 +317,3 @@ view = _assertThisInitialize5.view; | ||
var cb = function () { | ||
var callback = function () { | ||
switch (view) { | ||
@@ -337,3 +337,3 @@ case 'century': | ||
callIfDefined(cb, value); | ||
callIfDefined(callback, value, event); | ||
}); | ||
@@ -340,0 +340,0 @@ |
@@ -12,57 +12,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import WeekNumbers from './MonthView/WeekNumbers'; | ||
import { CALENDAR_TYPES } from './shared/const'; | ||
import { CALENDAR_TYPES, CALENDAR_TYPE_LOCALES } from './shared/const'; | ||
import { isCalendarType, isMaxDate, isMinDate, isValue } from './shared/propTypes'; | ||
function getCalendarTypeFromLocale(locale) { | ||
switch (locale) { | ||
case 'en-CA': | ||
case 'en-US': | ||
case 'es-AR': | ||
case 'es-BO': | ||
case 'es-CL': | ||
case 'es-CO': | ||
case 'es-CR': | ||
case 'es-DO': | ||
case 'es-EC': | ||
case 'es-GT': | ||
case 'es-HN': | ||
case 'es-MX': | ||
case 'es-NI': | ||
case 'es-PA': | ||
case 'es-PE': | ||
case 'es-PR': | ||
case 'es-SV': | ||
case 'es-VE': | ||
case 'pt-BR': | ||
return CALENDAR_TYPES.US; | ||
// ar-LB, ar-MA intentionally missing | ||
case 'ar': | ||
case 'ar-AE': | ||
case 'ar-BH': | ||
case 'ar-DZ': | ||
case 'ar-EG': | ||
case 'ar-IQ': | ||
case 'ar-JO': | ||
case 'ar-KW': | ||
case 'ar-LY': | ||
case 'ar-OM': | ||
case 'ar-QA': | ||
case 'ar-SA': | ||
case 'ar-SD': | ||
case 'ar-SY': | ||
case 'ar-YE': | ||
case 'dv': | ||
case 'dv-MV': | ||
case 'ps': | ||
case 'ps-AR': | ||
return CALENDAR_TYPES.ARABIC; | ||
case 'he': | ||
case 'he-IL': | ||
return CALENDAR_TYPES.HEBREW; | ||
default: | ||
return CALENDAR_TYPES.ISO_8601; | ||
} | ||
return Object.keys(CALENDAR_TYPE_LOCALES).find(function (calendarType) { | ||
return CALENDAR_TYPE_LOCALES[calendarType].includes(locale); | ||
}) || CALENDAR_TYPES.ISO_8601; | ||
} | ||
@@ -69,0 +21,0 @@ |
@@ -56,3 +56,4 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
var activeEndDate = new Date(year, monthIndex, daysInMonth); | ||
return daysInMonth + (7 - getDayOfWeek(activeEndDate, calendarType) - 1); | ||
var daysUntilEndOfTheWeek = 7 - getDayOfWeek(activeEndDate, calendarType) - 1; | ||
return daysInMonth + daysUntilEndOfTheWeek; | ||
} | ||
@@ -59,0 +60,0 @@ |
@@ -17,4 +17,4 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
return onClickWeekNumber ? React.createElement("button", _extends({}, props, { | ||
onClick: function onClick() { | ||
return onClickWeekNumber(weekNumber, date); | ||
onClick: function onClick(event) { | ||
return onClickWeekNumber(weekNumber, date, event); | ||
}, | ||
@@ -27,3 +27,3 @@ type: "button" | ||
onClickWeekNumber: PropTypes.func, | ||
weekNumber: PropTypes.number.isRequired | ||
weekNumber: PropTypes.node.isRequired | ||
}; |
@@ -0,1 +1,3 @@ | ||
var _CALENDAR_TYPE_LOCALE; | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -9,2 +11,4 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
export var CALENDAR_TYPES = { | ||
@@ -16,4 +20,6 @@ ARABIC: 'Arabic', | ||
}; | ||
export var CALENDAR_TYPE_LOCALES = (_CALENDAR_TYPE_LOCALE = {}, _defineProperty(_CALENDAR_TYPE_LOCALE, CALENDAR_TYPES.US, ['en-CA', 'en-US', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-EC', 'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PR', 'es-SV', 'es-VE', 'pt-BR']), _defineProperty(_CALENDAR_TYPE_LOCALE, CALENDAR_TYPES.ARABIC, [// ar-LB, ar-MA intentionally missing | ||
'ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LY', 'ar-OM', 'ar-QA', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-YE', 'dv', 'dv-MV', 'ps', 'ps-AR']), _defineProperty(_CALENDAR_TYPE_LOCALE, CALENDAR_TYPES.HEBREW, ['he', 'he-IL']), _CALENDAR_TYPE_LOCALE); | ||
export var WEEKDAYS = _toConsumableArray(Array(7)).map(function (el, index) { | ||
return index; | ||
}); |
@@ -93,4 +93,4 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
}), | ||
onClick: onClick && function () { | ||
return onClick(date); | ||
onClick: onClick && function (event) { | ||
return onClick(date, event); | ||
}, | ||
@@ -97,0 +97,0 @@ onFocus: onMouseOver && function () { |
@@ -248,3 +248,3 @@ "use strict"; | ||
_defineProperty(_assertThisInitialized(_this), "drillDown", function (nextActiveStartDate) { | ||
_defineProperty(_assertThisInitialized(_this), "drillDown", function (nextActiveStartDate, event) { | ||
if (!_this.drillDownAvailable) { | ||
@@ -254,3 +254,3 @@ return; | ||
_this.onClickTile(nextActiveStartDate); | ||
_this.onClickTile(nextActiveStartDate, event); | ||
@@ -284,3 +284,3 @@ var _assertThisInitialize2 = _assertThisInitialized(_this), | ||
_defineProperty(_assertThisInitialized(_this), "onChange", function (value) { | ||
_defineProperty(_assertThisInitialized(_this), "onChange", function (value, event) { | ||
var _this$props2 = _this.props, | ||
@@ -290,3 +290,3 @@ onChange = _this$props2.onChange, | ||
_this.onClickTile(value); | ||
_this.onClickTile(value, event); | ||
@@ -328,3 +328,3 @@ var nextValue; | ||
_defineProperty(_assertThisInitialized(_this), "onClickTile", function (value) { | ||
_defineProperty(_assertThisInitialized(_this), "onClickTile", function (value, event) { | ||
var _assertThisInitialize5 = _assertThisInitialized(_this), | ||
@@ -339,3 +339,3 @@ view = _assertThisInitialize5.view; | ||
var cb = function () { | ||
var callback = function () { | ||
switch (view) { | ||
@@ -359,3 +359,3 @@ case 'century': | ||
(0, _utils.callIfDefined)(cb, value); | ||
(0, _utils.callIfDefined)(callback, value, event); | ||
}); | ||
@@ -362,0 +362,0 @@ |
@@ -31,53 +31,5 @@ "use strict"; | ||
function getCalendarTypeFromLocale(locale) { | ||
switch (locale) { | ||
case 'en-CA': | ||
case 'en-US': | ||
case 'es-AR': | ||
case 'es-BO': | ||
case 'es-CL': | ||
case 'es-CO': | ||
case 'es-CR': | ||
case 'es-DO': | ||
case 'es-EC': | ||
case 'es-GT': | ||
case 'es-HN': | ||
case 'es-MX': | ||
case 'es-NI': | ||
case 'es-PA': | ||
case 'es-PE': | ||
case 'es-PR': | ||
case 'es-SV': | ||
case 'es-VE': | ||
case 'pt-BR': | ||
return _const.CALENDAR_TYPES.US; | ||
// ar-LB, ar-MA intentionally missing | ||
case 'ar': | ||
case 'ar-AE': | ||
case 'ar-BH': | ||
case 'ar-DZ': | ||
case 'ar-EG': | ||
case 'ar-IQ': | ||
case 'ar-JO': | ||
case 'ar-KW': | ||
case 'ar-LY': | ||
case 'ar-OM': | ||
case 'ar-QA': | ||
case 'ar-SA': | ||
case 'ar-SD': | ||
case 'ar-SY': | ||
case 'ar-YE': | ||
case 'dv': | ||
case 'dv-MV': | ||
case 'ps': | ||
case 'ps-AR': | ||
return _const.CALENDAR_TYPES.ARABIC; | ||
case 'he': | ||
case 'he-IL': | ||
return _const.CALENDAR_TYPES.HEBREW; | ||
default: | ||
return _const.CALENDAR_TYPES.ISO_8601; | ||
} | ||
return Object.keys(_const.CALENDAR_TYPE_LOCALES).find(function (calendarType) { | ||
return _const.CALENDAR_TYPE_LOCALES[calendarType].includes(locale); | ||
}) || _const.CALENDAR_TYPES.ISO_8601; | ||
} | ||
@@ -84,0 +36,0 @@ |
@@ -72,3 +72,4 @@ "use strict"; | ||
var activeEndDate = new Date(year, monthIndex, daysInMonth); | ||
return daysInMonth + (7 - (0, _dates.getDayOfWeek)(activeEndDate, calendarType) - 1); | ||
var daysUntilEndOfTheWeek = 7 - (0, _dates.getDayOfWeek)(activeEndDate, calendarType) - 1; | ||
return daysInMonth + daysUntilEndOfTheWeek; | ||
} | ||
@@ -75,0 +76,0 @@ |
@@ -30,4 +30,4 @@ "use strict"; | ||
return onClickWeekNumber ? _react["default"].createElement("button", _extends({}, props, { | ||
onClick: function onClick() { | ||
return onClickWeekNumber(weekNumber, date); | ||
onClick: function onClick(event) { | ||
return onClickWeekNumber(weekNumber, date, event); | ||
}, | ||
@@ -41,3 +41,3 @@ type: "button" | ||
onClickWeekNumber: _propTypes["default"].func, | ||
weekNumber: _propTypes["default"].number.isRequired | ||
weekNumber: _propTypes["default"].node.isRequired | ||
}; |
@@ -6,4 +6,6 @@ "use strict"; | ||
}); | ||
exports.WEEKDAYS = exports.CALENDAR_TYPES = void 0; | ||
exports.WEEKDAYS = exports.CALENDAR_TYPE_LOCALES = exports.CALENDAR_TYPES = void 0; | ||
var _CALENDAR_TYPE_LOCALE; | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -17,2 +19,4 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var CALENDAR_TYPES = { | ||
@@ -25,2 +29,5 @@ ARABIC: 'Arabic', | ||
exports.CALENDAR_TYPES = CALENDAR_TYPES; | ||
var CALENDAR_TYPE_LOCALES = (_CALENDAR_TYPE_LOCALE = {}, _defineProperty(_CALENDAR_TYPE_LOCALE, CALENDAR_TYPES.US, ['en-CA', 'en-US', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-EC', 'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PR', 'es-SV', 'es-VE', 'pt-BR']), _defineProperty(_CALENDAR_TYPE_LOCALE, CALENDAR_TYPES.ARABIC, [// ar-LB, ar-MA intentionally missing | ||
'ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LY', 'ar-OM', 'ar-QA', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-YE', 'dv', 'dv-MV', 'ps', 'ps-AR']), _defineProperty(_CALENDAR_TYPE_LOCALE, CALENDAR_TYPES.HEBREW, ['he', 'he-IL']), _CALENDAR_TYPE_LOCALE); | ||
exports.CALENDAR_TYPE_LOCALES = CALENDAR_TYPE_LOCALES; | ||
@@ -27,0 +34,0 @@ var WEEKDAYS = _toConsumableArray(Array(7)).map(function (el, index) { |
@@ -107,4 +107,4 @@ "use strict"; | ||
}), | ||
onClick: onClick && function () { | ||
return onClick(date); | ||
onClick: onClick && function (event) { | ||
return onClick(date, event); | ||
}, | ||
@@ -111,0 +111,0 @@ onFocus: onMouseOver && function () { |
{ | ||
"name": "react-calendar", | ||
"version": "3.0.0-beta.4", | ||
"version": "3.0.0-beta.5", | ||
"description": "Ultimate calendar for your React app.", | ||
"main": "dist/umd/entry.js", | ||
"module": "dist/esm/entry.js", | ||
"source": "src/entry.js", | ||
"main": "dist/umd/index.js", | ||
"module": "dist/esm/index.js", | ||
"source": "src/index.js", | ||
"sideEffects": false, | ||
@@ -14,5 +14,3 @@ "scripts": { | ||
"build-js-umd": "cross-env BABEL_ENV=production-umd babel src -d dist/umd --ignore **/*.spec.js,**/*.spec.jsx", | ||
"build-styles": "yarn build-styles-esm && yarn build-styles-umd", | ||
"build-styles-esm": "lessc ./dist/esm/Calendar.less ./dist/esm/Calendar.css", | ||
"build-styles-umd": "lessc ./dist/umd/Calendar.less ./dist/umd/Calendar.css", | ||
"build-styles": "lessc ./dist/Calendar.less ./dist/Calendar.css", | ||
"clean": "rimraf dist", | ||
@@ -32,4 +30,3 @@ "copy-styles": "node ./copy-styles.js", | ||
"**/src/**.{js,jsx}", | ||
"!**/src/entry.js", | ||
"!**/src/entry.nostyle.js" | ||
"!**/src/index.js" | ||
] | ||
@@ -36,0 +33,0 @@ }, |
@@ -81,10 +81,6 @@ [![npm](https://img.shields.io/npm/v/react-calendar.svg)](https://www.npmjs.com/package/react-calendar) ![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) ![dev dependencies](https://img.shields.io/david/dev/wojtekmaj/react-calendar.svg) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) | ||
If you don't want to use default React-Calendar styling to build upon it, you can import React-Calendar by using: | ||
If you want to use default React-Calendar styling to build upon it, you can import React-Calendar's styles by using: | ||
```js | ||
// using ES6 modules | ||
import Calendar from 'react-calendar/dist/esm/entry.nostyle'; | ||
// using CommonJS modules | ||
import Calendar from 'react-calendar/dist/umd/entry.nostyle'; | ||
import 'react-calendar/dist/Calendar.css'; | ||
``` | ||
@@ -127,9 +123,9 @@ | ||
|onActiveStartDateChange|Function called when the user navigates from one view to another using previous/next button.|n/a|`({ activeStartDate, view }) => alert('Changed view to: ', activeStartDate, view)`| | ||
|onChange|Function called when the user clicks an item (day on month view, month on year view and so on) on the most detailed view available.|n/a|`(value) => alert('New date is: ', value)`| | ||
|onChange|Function called when the user clicks an item (day on month view, month on year view and so on) on the most detailed view available.|n/a|`(value, event) => alert('New date is: ', value)`| | ||
|onViewChange|Function called when the user navigates from one view to another using drill up button or by clicking a tile.|n/a|`({ activeStartDate, view }) => alert('New view is: ', view)`| | ||
|onClickDay|Function called when the user clicks a day.|n/a|`(value) => alert('Clicked day: ', value)`| | ||
|onClickDecade|Function called when the user clicks a decade.|n/a|`(value) => alert('Clicked decade: ', value)`| | ||
|onClickMonth|Function called when the user clicks a month.|n/a|`(value) => alert('Clicked month: ', value)`| | ||
|onClickWeekNumber|Function called when the user clicks a week number.|n/a|`(weekNumber, date) => alert('Clicked week: ', weekNumber, 'that starts on: ', date)`| | ||
|onClickYear|Function called when the user clicks a year.|n/a|`(value) => alert('Clicked year: ', value)`| | ||
|onClickDay|Function called when the user clicks a day.|n/a|`(value, event) => alert('Clicked day: ', value)`| | ||
|onClickDecade|Function called when the user clicks a decade.|n/a|`(value, event) => alert('Clicked decade: ', value)`| | ||
|onClickMonth|Function called when the user clicks a month.|n/a|`(value, event) => alert('Clicked month: ', value)`| | ||
|onClickWeekNumber|Function called when the user clicks a week number.|n/a|`(weekNumber, date, event) => alert('Clicked week: ', weekNumber, 'that starts on: ', date)`| | ||
|onClickYear|Function called when the user clicks a year.|n/a|`(value, event) => alert('Clicked year: ', value)`| | ||
|onDrillDown|Function called when the user drills down by clicking a tile.|n/a|`({ activeStartDate, view }) => alert('Drilled down to: ', activeStartDate, view)`| | ||
@@ -136,0 +132,0 @@ |onDrillUp|Function called when the user drills up by clicking drill up button.|n/a|`({ activeStartDate, view }) => alert('Drilled up to: ', activeStartDate, view)`| |
@@ -256,3 +256,3 @@ import React, { Component } from 'react'; | ||
drillDown = (nextActiveStartDate) => { | ||
drillDown = (nextActiveStartDate, event) => { | ||
if (!this.drillDownAvailable) { | ||
@@ -262,3 +262,3 @@ return; | ||
this.onClickTile(nextActiveStartDate); | ||
this.onClickTile(nextActiveStartDate, event); | ||
@@ -287,6 +287,6 @@ const { view, views } = this; | ||
onChange = (value) => { | ||
onChange = (value, event) => { | ||
const { onChange, selectRange } = this.props; | ||
this.onClickTile(value); | ||
this.onClickTile(value, event); | ||
@@ -316,3 +316,3 @@ let nextValue; | ||
onClickTile = (value) => { | ||
onClickTile = (value, event) => { | ||
const { view } = this; | ||
@@ -326,3 +326,3 @@ const { | ||
const cb = (() => { | ||
const callback = (() => { | ||
switch (view) { | ||
@@ -342,3 +342,3 @@ case 'century': | ||
callIfDefined(cb, value); | ||
callIfDefined(callback, value, event); | ||
} | ||
@@ -345,0 +345,0 @@ |
@@ -111,3 +111,3 @@ import React from 'react'; | ||
expect(onClick).toHaveBeenCalled(); | ||
expect(onClick).toHaveBeenCalledWith(date); | ||
expect(onClick).toHaveBeenCalledWith(date, expect.any(Object)); | ||
}); | ||
@@ -114,0 +114,0 @@ |
@@ -111,3 +111,3 @@ import React from 'react'; | ||
expect(onClick).toHaveBeenCalled(); | ||
expect(onClick).toHaveBeenCalledWith(date); | ||
expect(onClick).toHaveBeenCalledWith(date, expect.any(Object)); | ||
}); | ||
@@ -114,0 +114,0 @@ |
@@ -8,3 +8,3 @@ import React from 'react'; | ||
import { CALENDAR_TYPES } from './shared/const'; | ||
import { CALENDAR_TYPES, CALENDAR_TYPE_LOCALES } from './shared/const'; | ||
import { | ||
@@ -18,50 +18,7 @@ isCalendarType, | ||
function getCalendarTypeFromLocale(locale) { | ||
switch (locale) { | ||
case 'en-CA': | ||
case 'en-US': | ||
case 'es-AR': | ||
case 'es-BO': | ||
case 'es-CL': | ||
case 'es-CO': | ||
case 'es-CR': | ||
case 'es-DO': | ||
case 'es-EC': | ||
case 'es-GT': | ||
case 'es-HN': | ||
case 'es-MX': | ||
case 'es-NI': | ||
case 'es-PA': | ||
case 'es-PE': | ||
case 'es-PR': | ||
case 'es-SV': | ||
case 'es-VE': | ||
case 'pt-BR': | ||
return CALENDAR_TYPES.US; | ||
// ar-LB, ar-MA intentionally missing | ||
case 'ar': | ||
case 'ar-AE': | ||
case 'ar-BH': | ||
case 'ar-DZ': | ||
case 'ar-EG': | ||
case 'ar-IQ': | ||
case 'ar-JO': | ||
case 'ar-KW': | ||
case 'ar-LY': | ||
case 'ar-OM': | ||
case 'ar-QA': | ||
case 'ar-SA': | ||
case 'ar-SD': | ||
case 'ar-SY': | ||
case 'ar-YE': | ||
case 'dv': | ||
case 'dv-MV': | ||
case 'ps': | ||
case 'ps-AR': | ||
return CALENDAR_TYPES.ARABIC; | ||
case 'he': | ||
case 'he-IL': | ||
return CALENDAR_TYPES.HEBREW; | ||
default: | ||
return CALENDAR_TYPES.ISO_8601; | ||
} | ||
return ( | ||
Object.keys(CALENDAR_TYPE_LOCALES) | ||
.find(calendarType => CALENDAR_TYPE_LOCALES[calendarType].includes(locale)) | ||
|| CALENDAR_TYPES.ISO_8601 | ||
); | ||
} | ||
@@ -68,0 +25,0 @@ |
@@ -137,3 +137,3 @@ import React from 'react'; | ||
expect(onClick).toHaveBeenCalled(); | ||
expect(onClick).toHaveBeenCalledWith(date); | ||
expect(onClick).toHaveBeenCalledWith(date, expect.any(Object)); | ||
}); | ||
@@ -140,0 +140,0 @@ |
@@ -56,3 +56,4 @@ import React from 'react'; | ||
const activeEndDate = new Date(year, monthIndex, daysInMonth); | ||
return daysInMonth + (7 - getDayOfWeek(activeEndDate, calendarType) - 1); | ||
const daysUntilEndOfTheWeek = 7 - getDayOfWeek(activeEndDate, calendarType) - 1; | ||
return daysInMonth + daysUntilEndOfTheWeek; | ||
} | ||
@@ -59,0 +60,0 @@ |
@@ -25,3 +25,3 @@ import React from 'react'; | ||
{...props} | ||
onClick={() => onClickWeekNumber(weekNumber, date)} | ||
onClick={event => onClickWeekNumber(weekNumber, date, event)} | ||
type="button" | ||
@@ -43,3 +43,3 @@ > | ||
onClickWeekNumber: PropTypes.func, | ||
weekNumber: PropTypes.number.isRequired, | ||
weekNumber: PropTypes.node.isRequired, | ||
}; |
@@ -128,3 +128,3 @@ import React from 'react'; | ||
children.first().simulate('click'); | ||
expect(onClickWeekNumber).toHaveBeenCalledWith(52, new Date(2016, 11, 26)); | ||
expect(onClickWeekNumber).toHaveBeenCalledWith(52, new Date(2016, 11, 26), expect.any(Object)); | ||
}); | ||
@@ -145,4 +145,4 @@ | ||
children.first().simulate('click'); | ||
expect(onClickWeekNumber).toHaveBeenCalledWith(1, new Date(2017, 0, 1)); | ||
expect(onClickWeekNumber).toHaveBeenCalledWith(1, new Date(2017, 0, 1), expect.any(Object)); | ||
}); | ||
}); |
@@ -8,2 +8,52 @@ export const CALENDAR_TYPES = { | ||
export const CALENDAR_TYPE_LOCALES = { | ||
[CALENDAR_TYPES.US]: [ | ||
'en-CA', | ||
'en-US', | ||
'es-AR', | ||
'es-BO', | ||
'es-CL', | ||
'es-CO', | ||
'es-CR', | ||
'es-DO', | ||
'es-EC', | ||
'es-GT', | ||
'es-HN', | ||
'es-MX', | ||
'es-NI', | ||
'es-PA', | ||
'es-PE', | ||
'es-PR', | ||
'es-SV', | ||
'es-VE', | ||
'pt-BR', | ||
], | ||
[CALENDAR_TYPES.ARABIC]: [ | ||
// ar-LB, ar-MA intentionally missing | ||
'ar', | ||
'ar-AE', | ||
'ar-BH', | ||
'ar-DZ', | ||
'ar-EG', | ||
'ar-IQ', | ||
'ar-JO', | ||
'ar-KW', | ||
'ar-LY', | ||
'ar-OM', | ||
'ar-QA', | ||
'ar-SA', | ||
'ar-SD', | ||
'ar-SY', | ||
'ar-YE', | ||
'dv', | ||
'dv-MV', | ||
'ps', | ||
'ps-AR', | ||
], | ||
[CALENDAR_TYPES.HEBREW]: [ | ||
'he', | ||
'he-IL', | ||
], | ||
}; | ||
export const WEEKDAYS = [...Array(7)].map((el, index) => index); |
@@ -64,3 +64,3 @@ import React, { Component } from 'react'; | ||
} | ||
onClick={onClick && (() => onClick(date))} | ||
onClick={onClick && (event => onClick(date, event))} | ||
onFocus={onMouseOver && (() => onMouseOver(date))} | ||
@@ -67,0 +67,0 @@ onMouseOver={onMouseOver && (() => onMouseOver(date))} |
@@ -111,3 +111,3 @@ import React from 'react'; | ||
expect(onClick).toHaveBeenCalled(); | ||
expect(onClick).toHaveBeenCalledWith(date); | ||
expect(onClick).toHaveBeenCalledWith(date, expect.any(Object)); | ||
}); | ||
@@ -114,0 +114,0 @@ |
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
428353
102
10056
203