Socket
Socket
Sign inDemoInstall

react-calendar

Package Overview
Dependencies
Maintainers
3
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-calendar - npm Package Compare versions

Comparing version 3.0.0-beta.3 to 3.0.0-beta.4

302

dist/esm/Calendar.js

@@ -41,3 +41,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); }

import { isCalendarType, isClassName, isMaxDate, isMinDate, isValue, isView } from './shared/propTypes';
import { between, callIfDefined, mergeFunctions } from './shared/utils';
import { between, callIfDefined } from './shared/utils';
var baseClassName = 'react-calendar';

@@ -73,3 +73,3 @@ var allViews = ['century', 'decade', 'year', 'month'];

return getLimitedViews(minDetail, maxDetail).pop();
return maxDetail;
};

@@ -85,3 +85,3 @@ /**

var getValueFrom = function getValueFrom(value) {
var getValue = function getValue(value, index) {
if (!value) {

@@ -91,60 +91,44 @@ return null;

var rawValueFrom = value instanceof Array && value.length === 2 ? value[0] : value;
var rawValue = value instanceof Array && value.length === 2 ? value[index] : value;
if (!rawValueFrom) {
if (!rawValue) {
return null;
}
var valueFromDate = new Date(rawValueFrom);
var valueDate = new Date(rawValue);
if (isNaN(valueFromDate.getTime())) {
if (isNaN(valueDate.getTime())) {
throw new Error("Invalid date: ".concat(value));
}
return valueFromDate;
return valueDate;
};
var getDetailValueFrom = function getDetailValueFrom(value, minDate, maxDate, maxDetail) {
var valueFrom = getValueFrom(value);
var getDetailValue = function getDetailValue(_ref, index) {
var value = _ref.value,
minDate = _ref.minDate,
maxDate = _ref.maxDate,
maxDetail = _ref.maxDetail;
var valuePiece = getValue(value, index);
if (!valueFrom) {
if (!valuePiece) {
return null;
}
var detailValueFrom = getBegin(getValueType(maxDetail), valueFrom);
var valueType = getValueType(maxDetail);
var detailValueFrom = [getBegin, getEnd][index](valueType, valuePiece);
return between(detailValueFrom, minDate, maxDate);
};
var getValueTo = function getValueTo(value) {
if (!value) {
return null;
}
var getDetailValueFrom = function getDetailValueFrom(args) {
return getDetailValue(args, 0);
};
var rawValueTo = value instanceof Array && value.length === 2 ? value[1] : value;
if (!rawValueTo) {
return null;
}
var valueToDate = new Date(rawValueTo);
if (isNaN(valueToDate.getTime())) {
throw new Error("Invalid date: ".concat(value));
}
return valueToDate;
var getDetailValueTo = function getDetailValueTo(args) {
return getDetailValue(args, 1);
};
var getDetailValueTo = function getDetailValueTo(value, minDate, maxDate, maxDetail) {
var valueTo = getValueTo(value);
var getDetailValueArray = function getDetailValueArray(args) {
var value = args.value;
if (!valueTo) {
return null;
}
var detailValueTo = getEnd(getValueType(maxDetail), valueTo);
return between(detailValueTo, minDate, maxDate);
};
var getDetailValueArray = function getDetailValueArray(value, minDate, maxDate, maxDetail) {
if (value instanceof Array) {

@@ -154,3 +138,5 @@ return value;

return [getDetailValueFrom(value, minDate, maxDate, maxDetail), getDetailValueTo(value, minDate, maxDate, maxDetail)];
return [getDetailValueFrom, getDetailValueTo].map(function (fn) {
return fn(args);
});
};

@@ -170,3 +156,8 @@

var rangeType = getView(view || defaultView, minDetail, maxDetail);
var valueFrom = activeStartDate || defaultActiveStartDate || getDetailValueFrom(value || defaultValue, minDate, maxDate, maxDetail) || new Date();
var valueFrom = activeStartDate || defaultActiveStartDate || getDetailValueFrom({
value: value || defaultValue,
minDate: minDate,
maxDate: maxDate,
maxDetail: maxDetail
}) || new Date();
return getBegin(rangeType, valueFrom);

@@ -191,7 +182,7 @@ };

for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
_args[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Calendar)).call.apply(_getPrototypeOf2, [this].concat(args)));
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Calendar)).call.apply(_getPrototypeOf2, [this].concat(_args)));

@@ -223,3 +214,3 @@ _defineProperty(_assertThisInitialized(_this), "state", {

_defineProperty(_assertThisInitialized(_this), "setActiveStartDateAndView", function (activeStartDate, view) {
_defineProperty(_assertThisInitialized(_this), "setActiveStartDateAndView", function (activeStartDate, view, callback) {
var _this$props = _this.props,

@@ -233,10 +224,9 @@ onActiveStartDateChange = _this$props.onActiveStartDateChange,

}, function () {
callIfDefined(onActiveStartDateChange, {
var args = {
activeStartDate: activeStartDate,
view: view
});
callIfDefined(onViewChange, {
activeStartDate: activeStartDate,
view: view
});
};
callIfDefined(onActiveStartDateChange, args);
callIfDefined(onViewChange, args);
callIfDefined(callback, args);
});

@@ -250,2 +240,4 @@ });

_this.onClickTile(nextActiveStartDate);
var _assertThisInitialize2 = _assertThisInitialized(_this),

@@ -258,8 +250,3 @@ view = _assertThisInitialize2.view,

_this.setActiveStartDateAndView(nextActiveStartDate, nextView);
callIfDefined(onDrillDown, {
activeStartDate: nextActiveStartDate,
view: nextView
});
_this.setActiveStartDateAndView(nextActiveStartDate, nextView, onDrillDown);
});

@@ -281,8 +268,3 @@

_this.setActiveStartDateAndView(nextActiveStartDate, nextView);
callIfDefined(onDrillUp, {
activeStartDate: nextActiveStartDate,
view: nextView
});
_this.setActiveStartDateAndView(nextActiveStartDate, nextView, onDrillUp);
});

@@ -294,2 +276,5 @@

selectRange = _this$props2.selectRange;
_this.onClickTile(value);
var nextValue;

@@ -299,13 +284,14 @@ var callback;

if (selectRange) {
// Range selection turned on
var _assertThisInitialize4 = _assertThisInitialized(_this),
previousValue = _assertThisInitialize4.value; // Range selection turned on
previousValue = _assertThisInitialize4.value,
valueType = _assertThisInitialize4.valueType;
if (!isSingleValue(previousValue)) {
// Value has 0 or 2 elements - either way we're starting a new array
// First value
nextValue = getBegin(_this.valueType, value);
nextValue = getBegin(valueType, value);
} else {
// Second value
nextValue = getValueRange(_this.valueType, previousValue, value);
nextValue = getValueRange(valueType, previousValue, value);

@@ -330,2 +316,34 @@ callback = function callback() {

_defineProperty(_assertThisInitialized(_this), "onClickTile", function (value) {
var _assertThisInitialize5 = _assertThisInitialized(_this),
view = _assertThisInitialize5.view;
var _this$props3 = _this.props,
onClickDay = _this$props3.onClickDay,
onClickDecade = _this$props3.onClickDecade,
onClickMonth = _this$props3.onClickMonth,
onClickYear = _this$props3.onClickYear;
var cb = function () {
switch (view) {
case 'century':
return onClickDecade;
case 'decade':
return onClickYear;
case 'year':
return onClickMonth;
case 'month':
return onClickDay;
default:
throw new Error("Invalid view: ".concat(view, "."));
}
}();
callIfDefined(cb, value);
});
_defineProperty(_assertThisInitialized(_this), "onMouseOver", function (value) {

@@ -359,7 +377,7 @@ _this.setState(function (prevState) {

value: function getProcessedValue(value) {
var _this$props3 = this.props,
minDate = _this$props3.minDate,
maxDate = _this$props3.maxDate,
maxDetail = _this$props3.maxDetail,
returnValue = _this$props3.returnValue;
var _this$props4 = this.props,
minDate = _this$props4.minDate,
maxDate = _this$props4.maxDate,
maxDetail = _this$props4.maxDetail,
returnValue = _this$props4.returnValue;

@@ -382,3 +400,8 @@ var processFunction = function () {

return processFunction(value, minDate, maxDate, maxDetail);
return processFunction({
value: value,
minDate: minDate,
maxDate: maxDate,
maxDetail: maxDetail
});
}

@@ -397,14 +420,14 @@ /**

view = this.view;
var _this$props4 = this.props,
calendarType = _this$props4.calendarType,
locale = _this$props4.locale,
maxDate = _this$props4.maxDate,
minDate = _this$props4.minDate,
renderChildren = _this$props4.renderChildren,
selectRange = _this$props4.selectRange,
tileClassName = _this$props4.tileClassName,
tileContent = _this$props4.tileContent,
tileDisabled = _this$props4.tileDisabled;
var _this$props5 = this.props,
calendarType = _this$props5.calendarType,
locale = _this$props5.locale,
maxDate = _this$props5.maxDate,
minDate = _this$props5.minDate,
selectRange = _this$props5.selectRange,
tileClassName = _this$props5.tileClassName,
tileContent = _this$props5.tileContent,
tileDisabled = _this$props5.tileDisabled;
var hover = this.hover;
var activeStartDate = next ? getBeginNext(view, currentActiveStartDate) : currentActiveStartDate;
var onClick = this.drillDownAvailable ? this.drillDown : this.onChange;
var commonProps = {

@@ -416,6 +439,6 @@ activeStartDate: activeStartDate,

minDate: minDate,
onClick: onClick,
onMouseOver: selectRange ? onMouseOver : null,
tileClassName: tileClassName,
tileContent: tileContent || renderChildren,
// For backwards compatibility
tileContent: tileContent,
tileDisabled: tileDisabled,

@@ -425,3 +448,2 @@ value: value,

};
var clickAction = this.drillDownAvailable ? this.drillDown : this.onChange;

@@ -431,8 +453,5 @@ switch (view) {

{
var _this$props5 = this.props,
formatYear = _this$props5.formatYear,
onClickDecade = _this$props5.onClickDecade;
var formatYear = this.props.formatYear;
return React.createElement(CenturyView, _extends({
formatYear: formatYear,
onClick: mergeFunctions(clickAction, onClickDecade)
formatYear: formatYear
}, commonProps));

@@ -443,8 +462,5 @@ }

{
var _this$props6 = this.props,
_formatYear = _this$props6.formatYear,
onClickYear = _this$props6.onClickYear;
var _formatYear = this.props.formatYear;
return React.createElement(DecadeView, _extends({
formatYear: _formatYear,
onClick: mergeFunctions(clickAction, onClickYear)
formatYear: _formatYear
}, commonProps));

@@ -455,10 +471,8 @@ }

{
var _this$props7 = this.props,
formatMonth = _this$props7.formatMonth,
formatMonthYear = _this$props7.formatMonthYear,
onClickMonth = _this$props7.onClickMonth;
var _this$props6 = this.props,
formatMonth = _this$props6.formatMonth,
formatMonthYear = _this$props6.formatMonthYear;
return React.createElement(YearView, _extends({
formatMonth: formatMonth,
formatMonthYear: formatMonthYear,
onClick: mergeFunctions(clickAction, onClickMonth)
formatMonthYear: formatMonthYear
}, commonProps));

@@ -469,11 +483,10 @@ }

{
var _this$props8 = this.props,
formatLongDate = _this$props8.formatLongDate,
formatShortWeekday = _this$props8.formatShortWeekday,
onClickDay = _this$props8.onClickDay,
onClickWeekNumber = _this$props8.onClickWeekNumber,
showDoubleView = _this$props8.showDoubleView,
showFixedNumberOfWeeks = _this$props8.showFixedNumberOfWeeks,
showNeighboringMonth = _this$props8.showNeighboringMonth,
showWeekNumbers = _this$props8.showWeekNumbers;
var _this$props7 = this.props,
formatLongDate = _this$props7.formatLongDate,
formatShortWeekday = _this$props7.formatShortWeekday,
onClickWeekNumber = _this$props7.onClickWeekNumber,
showDoubleView = _this$props7.showDoubleView,
showFixedNumberOfWeeks = _this$props7.showFixedNumberOfWeeks,
showNeighboringMonth = _this$props7.showNeighboringMonth,
showWeekNumbers = _this$props7.showWeekNumbers;
var onMouseLeave = this.onMouseLeave;

@@ -484,3 +497,2 @@ return React.createElement(MonthView, _extends({

formatShortWeekday: formatShortWeekday,
onClick: mergeFunctions(clickAction, onClickDay),
onClickWeekNumber: onClickWeekNumber,

@@ -510,19 +522,19 @@ onMouseLeave: onMouseLeave,

views = this.views;
var _this$props9 = this.props,
formatMonthYear = _this$props9.formatMonthYear,
formatYear = _this$props9.formatYear,
locale = _this$props9.locale,
maxDate = _this$props9.maxDate,
minDate = _this$props9.minDate,
navigationAriaLabel = _this$props9.navigationAriaLabel,
navigationLabel = _this$props9.navigationLabel,
next2AriaLabel = _this$props9.next2AriaLabel,
next2Label = _this$props9.next2Label,
nextAriaLabel = _this$props9.nextAriaLabel,
nextLabel = _this$props9.nextLabel,
prev2AriaLabel = _this$props9.prev2AriaLabel,
prev2Label = _this$props9.prev2Label,
prevAriaLabel = _this$props9.prevAriaLabel,
prevLabel = _this$props9.prevLabel,
showDoubleView = _this$props9.showDoubleView;
var _this$props8 = this.props,
formatMonthYear = _this$props8.formatMonthYear,
formatYear = _this$props8.formatYear,
locale = _this$props8.locale,
maxDate = _this$props8.maxDate,
minDate = _this$props8.minDate,
navigationAriaLabel = _this$props8.navigationAriaLabel,
navigationLabel = _this$props8.navigationLabel,
next2AriaLabel = _this$props8.next2AriaLabel,
next2Label = _this$props8.next2Label,
nextAriaLabel = _this$props8.nextAriaLabel,
nextLabel = _this$props8.nextLabel,
prev2AriaLabel = _this$props8.prev2AriaLabel,
prev2Label = _this$props8.prev2Label,
prevAriaLabel = _this$props8.prevAriaLabel,
prevLabel = _this$props8.prevLabel,
showDoubleView = _this$props8.showDoubleView;
return React.createElement(Navigation, {

@@ -555,6 +567,6 @@ activeStartDate: activeStartDate,

value: function render() {
var _this$props10 = this.props,
className = _this$props10.className,
selectRange = _this$props10.selectRange,
showDoubleView = _this$props10.showDoubleView;
var _this$props9 = this.props,
className = _this$props9.className,
selectRange = _this$props9.selectRange,
showDoubleView = _this$props9.showDoubleView;
var onMouseLeave = this.onMouseLeave,

@@ -581,5 +593,5 @@ value = this.value;

get: function get() {
var _this$props11 = this.props,
selectRange = _this$props11.selectRange,
valueProps = _this$props11.value;
var _this$props10 = this.props,
selectRange = _this$props10.selectRange,
valueProps = _this$props10.value;
var valueState = this.state.value; // In the middle of range selection, use value from state

@@ -602,6 +614,6 @@

get: function get() {
var _this$props12 = this.props,
minDetail = _this$props12.minDetail,
maxDetail = _this$props12.maxDetail,
viewProps = _this$props12.view;
var _this$props11 = this.props,
minDetail = _this$props11.minDetail,
maxDetail = _this$props11.maxDetail,
viewProps = _this$props11.view;
var viewState = this.state.view;

@@ -613,5 +625,5 @@ return getView(viewProps || viewState, minDetail, maxDetail);

get: function get() {
var _this$props13 = this.props,
minDetail = _this$props13.minDetail,
maxDetail = _this$props13.maxDetail;
var _this$props12 = this.props,
minDetail = _this$props12.minDetail,
maxDetail = _this$props12.maxDetail;
return getLimitedViews(minDetail, maxDetail);

@@ -692,4 +704,2 @@ }

prevLabel: PropTypes.node,
renderChildren: PropTypes.func,
// For backwards compatibility
returnValue: PropTypes.oneOf(['start', 'end', 'range']),

@@ -696,0 +706,0 @@ selectRange: PropTypes.bool,

import { getRange } from './dates';
/**
* Returns a function that, when called, calls all the functions
* passed to it, applying its arguments to them.
*
* @param {Function[]} functions
*/
export var mergeFunctions = function mergeFunctions() {
for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) {
functions[_key] = arguments[_key];
}
return function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return functions.filter(Boolean).forEach(function (f) {
return f.apply(void 0, args);
});
};
};
/**
* Calls a function, if it's defined, with specified arguments

@@ -32,4 +10,4 @@ * @param {Function} fn

if (fn && typeof fn === 'function') {
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}

@@ -36,0 +14,0 @@

@@ -30,2 +30,13 @@ 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; }

function getValue(nextProps, prop) {
var activeStartDate = nextProps.activeStartDate,
date = nextProps.date,
view = nextProps.view;
return typeof prop === 'function' ? prop({
activeStartDate: activeStartDate,
date: date,
view: view
}) : prop;
}
var Tile =

@@ -101,15 +112,8 @@ /*#__PURE__*/

value: function getDerivedStateFromProps(nextProps, prevState) {
var activeStartDate = nextProps.activeStartDate,
date = nextProps.date,
tileClassName = nextProps.tileClassName,
tileContent = nextProps.tileContent,
view = nextProps.view;
var tileClassName = nextProps.tileClassName,
tileContent = nextProps.tileContent;
var nextState = {};
if (tileClassName !== prevState.tileClassNameProps) {
nextState.tileClassName = typeof tileClassName === 'function' ? tileClassName({
activeStartDate: activeStartDate,
date: date,
view: view
}) : tileClassName;
nextState.tileClassName = getValue(nextProps, tileClassName);
nextState.tileClassNameProps = tileClassName;

@@ -119,7 +123,3 @@ }

if (tileContent !== prevState.tileContentProps) {
nextState.tileContent = typeof tileContent === 'function' ? tileContent({
activeStartDate: activeStartDate,
date: date,
view: view
}) : tileContent;
nextState.tileContent = getValue(nextProps, tileContent);
nextState.tileContentProps = tileContent;

@@ -126,0 +126,0 @@ }

@@ -94,3 +94,3 @@ "use strict";

return getLimitedViews(minDetail, maxDetail).pop();
return maxDetail;
};

@@ -106,3 +106,3 @@ /**

var getValueFrom = function getValueFrom(value) {
var getValue = function getValue(value, index) {
if (!value) {

@@ -112,60 +112,44 @@ return null;

var rawValueFrom = value instanceof Array && value.length === 2 ? value[0] : value;
var rawValue = value instanceof Array && value.length === 2 ? value[index] : value;
if (!rawValueFrom) {
if (!rawValue) {
return null;
}
var valueFromDate = new Date(rawValueFrom);
var valueDate = new Date(rawValue);
if (isNaN(valueFromDate.getTime())) {
if (isNaN(valueDate.getTime())) {
throw new Error("Invalid date: ".concat(value));
}
return valueFromDate;
return valueDate;
};
var getDetailValueFrom = function getDetailValueFrom(value, minDate, maxDate, maxDetail) {
var valueFrom = getValueFrom(value);
var getDetailValue = function getDetailValue(_ref, index) {
var value = _ref.value,
minDate = _ref.minDate,
maxDate = _ref.maxDate,
maxDetail = _ref.maxDetail;
var valuePiece = getValue(value, index);
if (!valueFrom) {
if (!valuePiece) {
return null;
}
var detailValueFrom = (0, _dates.getBegin)(getValueType(maxDetail), valueFrom);
var valueType = getValueType(maxDetail);
var detailValueFrom = [_dates.getBegin, _dates.getEnd][index](valueType, valuePiece);
return (0, _utils.between)(detailValueFrom, minDate, maxDate);
};
var getValueTo = function getValueTo(value) {
if (!value) {
return null;
}
var getDetailValueFrom = function getDetailValueFrom(args) {
return getDetailValue(args, 0);
};
var rawValueTo = value instanceof Array && value.length === 2 ? value[1] : value;
if (!rawValueTo) {
return null;
}
var valueToDate = new Date(rawValueTo);
if (isNaN(valueToDate.getTime())) {
throw new Error("Invalid date: ".concat(value));
}
return valueToDate;
var getDetailValueTo = function getDetailValueTo(args) {
return getDetailValue(args, 1);
};
var getDetailValueTo = function getDetailValueTo(value, minDate, maxDate, maxDetail) {
var valueTo = getValueTo(value);
var getDetailValueArray = function getDetailValueArray(args) {
var value = args.value;
if (!valueTo) {
return null;
}
var detailValueTo = (0, _dates.getEnd)(getValueType(maxDetail), valueTo);
return (0, _utils.between)(detailValueTo, minDate, maxDate);
};
var getDetailValueArray = function getDetailValueArray(value, minDate, maxDate, maxDetail) {
if (value instanceof Array) {

@@ -175,3 +159,5 @@ return value;

return [getDetailValueFrom(value, minDate, maxDate, maxDetail), getDetailValueTo(value, minDate, maxDate, maxDetail)];
return [getDetailValueFrom, getDetailValueTo].map(function (fn) {
return fn(args);
});
};

@@ -191,3 +177,8 @@

var rangeType = getView(view || defaultView, minDetail, maxDetail);
var valueFrom = activeStartDate || defaultActiveStartDate || getDetailValueFrom(value || defaultValue, minDate, maxDate, maxDetail) || new Date();
var valueFrom = activeStartDate || defaultActiveStartDate || getDetailValueFrom({
value: value || defaultValue,
minDate: minDate,
maxDate: maxDate,
maxDetail: maxDetail
}) || new Date();
return (0, _dates.getBegin)(rangeType, valueFrom);

@@ -212,7 +203,7 @@ };

for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
_args[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Calendar)).call.apply(_getPrototypeOf2, [this].concat(args)));
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Calendar)).call.apply(_getPrototypeOf2, [this].concat(_args)));

@@ -244,3 +235,3 @@ _defineProperty(_assertThisInitialized(_this), "state", {

_defineProperty(_assertThisInitialized(_this), "setActiveStartDateAndView", function (activeStartDate, view) {
_defineProperty(_assertThisInitialized(_this), "setActiveStartDateAndView", function (activeStartDate, view, callback) {
var _this$props = _this.props,

@@ -254,10 +245,9 @@ onActiveStartDateChange = _this$props.onActiveStartDateChange,

}, function () {
(0, _utils.callIfDefined)(onActiveStartDateChange, {
var args = {
activeStartDate: activeStartDate,
view: view
});
(0, _utils.callIfDefined)(onViewChange, {
activeStartDate: activeStartDate,
view: view
});
};
(0, _utils.callIfDefined)(onActiveStartDateChange, args);
(0, _utils.callIfDefined)(onViewChange, args);
(0, _utils.callIfDefined)(callback, args);
});

@@ -271,2 +261,4 @@ });

_this.onClickTile(nextActiveStartDate);
var _assertThisInitialize2 = _assertThisInitialized(_this),

@@ -279,8 +271,3 @@ view = _assertThisInitialize2.view,

_this.setActiveStartDateAndView(nextActiveStartDate, nextView);
(0, _utils.callIfDefined)(onDrillDown, {
activeStartDate: nextActiveStartDate,
view: nextView
});
_this.setActiveStartDateAndView(nextActiveStartDate, nextView, onDrillDown);
});

@@ -302,8 +289,3 @@

_this.setActiveStartDateAndView(nextActiveStartDate, nextView);
(0, _utils.callIfDefined)(onDrillUp, {
activeStartDate: nextActiveStartDate,
view: nextView
});
_this.setActiveStartDateAndView(nextActiveStartDate, nextView, onDrillUp);
});

@@ -315,2 +297,5 @@

selectRange = _this$props2.selectRange;
_this.onClickTile(value);
var nextValue;

@@ -320,13 +305,14 @@ var callback;

if (selectRange) {
// Range selection turned on
var _assertThisInitialize4 = _assertThisInitialized(_this),
previousValue = _assertThisInitialize4.value; // Range selection turned on
previousValue = _assertThisInitialize4.value,
valueType = _assertThisInitialize4.valueType;
if (!isSingleValue(previousValue)) {
// Value has 0 or 2 elements - either way we're starting a new array
// First value
nextValue = (0, _dates.getBegin)(_this.valueType, value);
nextValue = (0, _dates.getBegin)(valueType, value);
} else {
// Second value
nextValue = (0, _dates.getValueRange)(_this.valueType, previousValue, value);
nextValue = (0, _dates.getValueRange)(valueType, previousValue, value);

@@ -351,2 +337,34 @@ callback = function callback() {

_defineProperty(_assertThisInitialized(_this), "onClickTile", function (value) {
var _assertThisInitialize5 = _assertThisInitialized(_this),
view = _assertThisInitialize5.view;
var _this$props3 = _this.props,
onClickDay = _this$props3.onClickDay,
onClickDecade = _this$props3.onClickDecade,
onClickMonth = _this$props3.onClickMonth,
onClickYear = _this$props3.onClickYear;
var cb = function () {
switch (view) {
case 'century':
return onClickDecade;
case 'decade':
return onClickYear;
case 'year':
return onClickMonth;
case 'month':
return onClickDay;
default:
throw new Error("Invalid view: ".concat(view, "."));
}
}();
(0, _utils.callIfDefined)(cb, value);
});
_defineProperty(_assertThisInitialized(_this), "onMouseOver", function (value) {

@@ -380,7 +398,7 @@ _this.setState(function (prevState) {

value: function getProcessedValue(value) {
var _this$props3 = this.props,
minDate = _this$props3.minDate,
maxDate = _this$props3.maxDate,
maxDetail = _this$props3.maxDetail,
returnValue = _this$props3.returnValue;
var _this$props4 = this.props,
minDate = _this$props4.minDate,
maxDate = _this$props4.maxDate,
maxDetail = _this$props4.maxDetail,
returnValue = _this$props4.returnValue;

@@ -403,3 +421,8 @@ var processFunction = function () {

return processFunction(value, minDate, maxDate, maxDetail);
return processFunction({
value: value,
minDate: minDate,
maxDate: maxDate,
maxDetail: maxDetail
});
}

@@ -418,14 +441,14 @@ /**

view = this.view;
var _this$props4 = this.props,
calendarType = _this$props4.calendarType,
locale = _this$props4.locale,
maxDate = _this$props4.maxDate,
minDate = _this$props4.minDate,
renderChildren = _this$props4.renderChildren,
selectRange = _this$props4.selectRange,
tileClassName = _this$props4.tileClassName,
tileContent = _this$props4.tileContent,
tileDisabled = _this$props4.tileDisabled;
var _this$props5 = this.props,
calendarType = _this$props5.calendarType,
locale = _this$props5.locale,
maxDate = _this$props5.maxDate,
minDate = _this$props5.minDate,
selectRange = _this$props5.selectRange,
tileClassName = _this$props5.tileClassName,
tileContent = _this$props5.tileContent,
tileDisabled = _this$props5.tileDisabled;
var hover = this.hover;
var activeStartDate = next ? (0, _dates.getBeginNext)(view, currentActiveStartDate) : currentActiveStartDate;
var onClick = this.drillDownAvailable ? this.drillDown : this.onChange;
var commonProps = {

@@ -437,6 +460,6 @@ activeStartDate: activeStartDate,

minDate: minDate,
onClick: onClick,
onMouseOver: selectRange ? onMouseOver : null,
tileClassName: tileClassName,
tileContent: tileContent || renderChildren,
// For backwards compatibility
tileContent: tileContent,
tileDisabled: tileDisabled,

@@ -446,3 +469,2 @@ value: value,

};
var clickAction = this.drillDownAvailable ? this.drillDown : this.onChange;

@@ -452,8 +474,5 @@ switch (view) {

{
var _this$props5 = this.props,
formatYear = _this$props5.formatYear,
onClickDecade = _this$props5.onClickDecade;
var formatYear = this.props.formatYear;
return _react["default"].createElement(_CenturyView["default"], _extends({
formatYear: formatYear,
onClick: (0, _utils.mergeFunctions)(clickAction, onClickDecade)
formatYear: formatYear
}, commonProps));

@@ -464,8 +483,5 @@ }

{
var _this$props6 = this.props,
_formatYear = _this$props6.formatYear,
onClickYear = _this$props6.onClickYear;
var _formatYear = this.props.formatYear;
return _react["default"].createElement(_DecadeView["default"], _extends({
formatYear: _formatYear,
onClick: (0, _utils.mergeFunctions)(clickAction, onClickYear)
formatYear: _formatYear
}, commonProps));

@@ -476,10 +492,8 @@ }

{
var _this$props7 = this.props,
formatMonth = _this$props7.formatMonth,
formatMonthYear = _this$props7.formatMonthYear,
onClickMonth = _this$props7.onClickMonth;
var _this$props6 = this.props,
formatMonth = _this$props6.formatMonth,
formatMonthYear = _this$props6.formatMonthYear;
return _react["default"].createElement(_YearView["default"], _extends({
formatMonth: formatMonth,
formatMonthYear: formatMonthYear,
onClick: (0, _utils.mergeFunctions)(clickAction, onClickMonth)
formatMonthYear: formatMonthYear
}, commonProps));

@@ -490,11 +504,10 @@ }

{
var _this$props8 = this.props,
formatLongDate = _this$props8.formatLongDate,
formatShortWeekday = _this$props8.formatShortWeekday,
onClickDay = _this$props8.onClickDay,
onClickWeekNumber = _this$props8.onClickWeekNumber,
showDoubleView = _this$props8.showDoubleView,
showFixedNumberOfWeeks = _this$props8.showFixedNumberOfWeeks,
showNeighboringMonth = _this$props8.showNeighboringMonth,
showWeekNumbers = _this$props8.showWeekNumbers;
var _this$props7 = this.props,
formatLongDate = _this$props7.formatLongDate,
formatShortWeekday = _this$props7.formatShortWeekday,
onClickWeekNumber = _this$props7.onClickWeekNumber,
showDoubleView = _this$props7.showDoubleView,
showFixedNumberOfWeeks = _this$props7.showFixedNumberOfWeeks,
showNeighboringMonth = _this$props7.showNeighboringMonth,
showWeekNumbers = _this$props7.showWeekNumbers;
var onMouseLeave = this.onMouseLeave;

@@ -505,3 +518,2 @@ return _react["default"].createElement(_MonthView["default"], _extends({

formatShortWeekday: formatShortWeekday,
onClick: (0, _utils.mergeFunctions)(clickAction, onClickDay),
onClickWeekNumber: onClickWeekNumber,

@@ -531,19 +543,19 @@ onMouseLeave: onMouseLeave,

views = this.views;
var _this$props9 = this.props,
formatMonthYear = _this$props9.formatMonthYear,
formatYear = _this$props9.formatYear,
locale = _this$props9.locale,
maxDate = _this$props9.maxDate,
minDate = _this$props9.minDate,
navigationAriaLabel = _this$props9.navigationAriaLabel,
navigationLabel = _this$props9.navigationLabel,
next2AriaLabel = _this$props9.next2AriaLabel,
next2Label = _this$props9.next2Label,
nextAriaLabel = _this$props9.nextAriaLabel,
nextLabel = _this$props9.nextLabel,
prev2AriaLabel = _this$props9.prev2AriaLabel,
prev2Label = _this$props9.prev2Label,
prevAriaLabel = _this$props9.prevAriaLabel,
prevLabel = _this$props9.prevLabel,
showDoubleView = _this$props9.showDoubleView;
var _this$props8 = this.props,
formatMonthYear = _this$props8.formatMonthYear,
formatYear = _this$props8.formatYear,
locale = _this$props8.locale,
maxDate = _this$props8.maxDate,
minDate = _this$props8.minDate,
navigationAriaLabel = _this$props8.navigationAriaLabel,
navigationLabel = _this$props8.navigationLabel,
next2AriaLabel = _this$props8.next2AriaLabel,
next2Label = _this$props8.next2Label,
nextAriaLabel = _this$props8.nextAriaLabel,
nextLabel = _this$props8.nextLabel,
prev2AriaLabel = _this$props8.prev2AriaLabel,
prev2Label = _this$props8.prev2Label,
prevAriaLabel = _this$props8.prevAriaLabel,
prevLabel = _this$props8.prevLabel,
showDoubleView = _this$props8.showDoubleView;
return _react["default"].createElement(_Navigation["default"], {

@@ -576,6 +588,6 @@ activeStartDate: activeStartDate,

value: function render() {
var _this$props10 = this.props,
className = _this$props10.className,
selectRange = _this$props10.selectRange,
showDoubleView = _this$props10.showDoubleView;
var _this$props9 = this.props,
className = _this$props9.className,
selectRange = _this$props9.selectRange,
showDoubleView = _this$props9.showDoubleView;
var onMouseLeave = this.onMouseLeave,

@@ -602,5 +614,5 @@ value = this.value;

get: function get() {
var _this$props11 = this.props,
selectRange = _this$props11.selectRange,
valueProps = _this$props11.value;
var _this$props10 = this.props,
selectRange = _this$props10.selectRange,
valueProps = _this$props10.value;
var valueState = this.state.value; // In the middle of range selection, use value from state

@@ -623,6 +635,6 @@

get: function get() {
var _this$props12 = this.props,
minDetail = _this$props12.minDetail,
maxDetail = _this$props12.maxDetail,
viewProps = _this$props12.view;
var _this$props11 = this.props,
minDetail = _this$props11.minDetail,
maxDetail = _this$props11.maxDetail,
viewProps = _this$props11.view;
var viewState = this.state.view;

@@ -634,5 +646,5 @@ return getView(viewProps || viewState, minDetail, maxDetail);

get: function get() {
var _this$props13 = this.props,
minDetail = _this$props13.minDetail,
maxDetail = _this$props13.maxDetail;
var _this$props12 = this.props,
minDetail = _this$props12.minDetail,
maxDetail = _this$props12.maxDetail;
return getLimitedViews(minDetail, maxDetail);

@@ -716,4 +728,2 @@ }

prevLabel: _propTypes["default"].node,
renderChildren: _propTypes["default"].func,
// For backwards compatibility
returnValue: _propTypes["default"].oneOf(['start', 'end', 'range']),

@@ -720,0 +730,0 @@ selectRange: _propTypes["default"].bool,

@@ -6,3 +6,3 @@ "use strict";

});
exports.getTileClasses = exports.between = exports.doRangesOverlap = exports.isRangeWithinRange = exports.isValueWithinRange = exports.callIfDefined = exports.mergeFunctions = void 0;
exports.getTileClasses = exports.between = exports.doRangesOverlap = exports.isRangeWithinRange = exports.isValueWithinRange = exports.callIfDefined = void 0;

@@ -12,23 +12,2 @@ var _dates = require("./dates");

/**
* Returns a function that, when called, calls all the functions
* passed to it, applying its arguments to them.
*
* @param {Function[]} functions
*/
var mergeFunctions = function mergeFunctions() {
for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) {
functions[_key] = arguments[_key];
}
return function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return functions.filter(Boolean).forEach(function (f) {
return f.apply(void 0, args);
});
};
};
/**
* Calls a function, if it's defined, with specified arguments

@@ -38,10 +17,6 @@ * @param {Function} fn

*/
exports.mergeFunctions = mergeFunctions;
var callIfDefined = function callIfDefined(fn) {
if (fn && typeof fn === 'function') {
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}

@@ -48,0 +23,0 @@

@@ -44,2 +44,13 @@ "use strict";

function getValue(nextProps, prop) {
var activeStartDate = nextProps.activeStartDate,
date = nextProps.date,
view = nextProps.view;
return typeof prop === 'function' ? prop({
activeStartDate: activeStartDate,
date: date,
view: view
}) : prop;
}
var Tile =

@@ -115,15 +126,8 @@ /*#__PURE__*/

value: function getDerivedStateFromProps(nextProps, prevState) {
var activeStartDate = nextProps.activeStartDate,
date = nextProps.date,
tileClassName = nextProps.tileClassName,
tileContent = nextProps.tileContent,
view = nextProps.view;
var tileClassName = nextProps.tileClassName,
tileContent = nextProps.tileContent;
var nextState = {};
if (tileClassName !== prevState.tileClassNameProps) {
nextState.tileClassName = typeof tileClassName === 'function' ? tileClassName({
activeStartDate: activeStartDate,
date: date,
view: view
}) : tileClassName;
nextState.tileClassName = getValue(nextProps, tileClassName);
nextState.tileClassNameProps = tileClassName;

@@ -133,7 +137,3 @@ }

if (tileContent !== prevState.tileContentProps) {
nextState.tileContent = typeof tileContent === 'function' ? tileContent({
activeStartDate: activeStartDate,
date: date,
view: view
}) : tileContent;
nextState.tileContent = getValue(nextProps, tileContent);
nextState.tileContentProps = tileContent;

@@ -140,0 +140,0 @@ }

{
"name": "react-calendar",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"description": "Ultimate calendar for your React app.",

@@ -5,0 +5,0 @@ "main": "dist/umd/entry.js",

@@ -17,3 +17,3 @@ import React, { Component } from 'react';

} from './shared/propTypes';
import { between, callIfDefined, mergeFunctions } from './shared/utils';
import { between, callIfDefined } from './shared/utils';

@@ -48,3 +48,3 @@ const baseClassName = 'react-calendar';

return getLimitedViews(minDetail, maxDetail).pop();
return maxDetail;
};

@@ -57,3 +57,3 @@

const getValueFrom = (value) => {
const getValue = (value, index) => {
if (!value) {

@@ -63,25 +63,28 @@ return null;

const rawValueFrom = value instanceof Array && value.length === 2 ? value[0] : value;
const rawValue = value instanceof Array && value.length === 2 ? value[index] : value;
if (!rawValueFrom) {
if (!rawValue) {
return null;
}
const valueFromDate = new Date(rawValueFrom);
const valueDate = new Date(rawValue);
if (isNaN(valueFromDate.getTime())) {
if (isNaN(valueDate.getTime())) {
throw new Error(`Invalid date: ${value}`);
}
return valueFromDate;
return valueDate;
};
const getDetailValueFrom = (value, minDate, maxDate, maxDetail) => {
const valueFrom = getValueFrom(value);
const getDetailValue = ({
value, minDate, maxDate, maxDetail,
}, index) => {
const valuePiece = getValue(value, index);
if (!valueFrom) {
if (!valuePiece) {
return null;
}
const detailValueFrom = getBegin(getValueType(maxDetail), valueFrom);
const valueType = getValueType(maxDetail);
const detailValueFrom = [getBegin, getEnd][index](valueType, valuePiece);

@@ -91,35 +94,9 @@ return between(detailValueFrom, minDate, maxDate);

const getValueTo = (value) => {
if (!value) {
return null;
}
const getDetailValueFrom = args => getDetailValue(args, 0);
const rawValueTo = value instanceof Array && value.length === 2 ? value[1] : value;
const getDetailValueTo = args => getDetailValue(args, 1);
if (!rawValueTo) {
return null;
}
const getDetailValueArray = (args) => {
const { value } = args;
const valueToDate = new Date(rawValueTo);
if (isNaN(valueToDate.getTime())) {
throw new Error(`Invalid date: ${value}`);
}
return valueToDate;
};
const getDetailValueTo = (value, minDate, maxDate, maxDetail) => {
const valueTo = getValueTo(value);
if (!valueTo) {
return null;
}
const detailValueTo = getEnd(getValueType(maxDetail), valueTo);
return between(detailValueTo, minDate, maxDate);
};
const getDetailValueArray = (value, minDate, maxDate, maxDetail) => {
if (value instanceof Array) {

@@ -129,6 +106,3 @@ return value;

return [
getDetailValueFrom(value, minDate, maxDate, maxDetail),
getDetailValueTo(value, minDate, maxDate, maxDetail),
];
return [getDetailValueFrom, getDetailValueTo].map(fn => fn(args));
};

@@ -153,3 +127,5 @@

activeStartDate || defaultActiveStartDate
|| getDetailValueFrom(value || defaultValue, minDate, maxDate, maxDetail)
|| getDetailValueFrom({
value: value || defaultValue, minDate, maxDate, maxDetail,
})
|| new Date()

@@ -249,3 +225,5 @@ );

return processFunction(value, minDate, maxDate, maxDetail);
return processFunction({
value, minDate, maxDate, maxDetail,
});
}

@@ -272,14 +250,13 @@

*/
setActiveStartDateAndView = (activeStartDate, view) => {
setActiveStartDateAndView = (activeStartDate, view, callback) => {
const { onActiveStartDateChange, onViewChange } = this.props;
this.setState({ activeStartDate, view }, () => {
callIfDefined(onActiveStartDateChange, {
const args = {
activeStartDate,
view,
});
callIfDefined(onViewChange, {
activeStartDate,
view,
});
};
callIfDefined(onActiveStartDateChange, args);
callIfDefined(onViewChange, args);
callIfDefined(callback, args);
});

@@ -293,2 +270,4 @@ }

this.onClickTile(nextActiveStartDate);
const { view, views } = this;

@@ -299,8 +278,3 @@ const { onDrillDown } = this.props;

this.setActiveStartDateAndView(nextActiveStartDate, nextView);
callIfDefined(onDrillDown, {
activeStartDate: nextActiveStartDate,
view: nextView,
});
this.setActiveStartDateAndView(nextActiveStartDate, nextView, onDrillDown);
}

@@ -319,8 +293,3 @@

this.setActiveStartDateAndView(nextActiveStartDate, nextView);
callIfDefined(onDrillUp, {
activeStartDate: nextActiveStartDate,
view: nextView,
});
this.setActiveStartDateAndView(nextActiveStartDate, nextView, onDrillUp);
}

@@ -331,14 +300,16 @@

this.onClickTile(value);
let nextValue;
let callback;
if (selectRange) {
const { value: previousValue } = this;
// Range selection turned on
const { value: previousValue, valueType } = this;
if (!isSingleValue(previousValue)) {
// Value has 0 or 2 elements - either way we're starting a new array
// First value
nextValue = getBegin(this.valueType, value);
nextValue = getBegin(valueType, value);
} else {
// Second value
nextValue = getValueRange(this.valueType, previousValue, value);
nextValue = getValueRange(valueType, previousValue, value);
callback = () => callIfDefined(onChange, nextValue);

@@ -355,2 +326,29 @@ }

onClickTile = (value) => {
const { view } = this;
const {
onClickDay,
onClickDecade,
onClickMonth,
onClickYear,
} = this.props;
const cb = (() => {
switch (view) {
case 'century':
return onClickDecade;
case 'decade':
return onClickYear;
case 'year':
return onClickMonth;
case 'month':
return onClickDay;
default:
throw new Error(`Invalid view: ${view}.`);
}
})();
callIfDefined(cb, value);
}
onMouseOver = (value) => {

@@ -383,3 +381,2 @@ this.setState((prevState) => {

minDate,
renderChildren,
selectRange,

@@ -398,2 +395,4 @@ tileClassName,

const onClick = this.drillDownAvailable ? this.drillDown : this.onChange;
const commonProps = {

@@ -405,5 +404,6 @@ activeStartDate,

minDate,
onClick,
onMouseOver: selectRange ? onMouseOver : null,
tileClassName,
tileContent: tileContent || renderChildren, // For backwards compatibility
tileContent,
tileDisabled,

@@ -414,7 +414,5 @@ value,

const clickAction = this.drillDownAvailable ? this.drillDown : this.onChange;
switch (view) {
case 'century': {
const { formatYear, onClickDecade } = this.props;
const { formatYear } = this.props;

@@ -424,3 +422,2 @@ return (

formatYear={formatYear}
onClick={mergeFunctions(clickAction, onClickDecade)}
{...commonProps}

@@ -431,3 +428,3 @@ />

case 'decade': {
const { formatYear, onClickYear } = this.props;
const { formatYear } = this.props;

@@ -437,3 +434,2 @@ return (

formatYear={formatYear}
onClick={mergeFunctions(clickAction, onClickYear)}
{...commonProps}

@@ -444,3 +440,3 @@ />

case 'year': {
const { formatMonth, formatMonthYear, onClickMonth } = this.props;
const { formatMonth, formatMonthYear } = this.props;

@@ -451,3 +447,2 @@ return (

formatMonthYear={formatMonthYear}
onClick={mergeFunctions(clickAction, onClickMonth)}
{...commonProps}

@@ -461,3 +456,2 @@ />

formatShortWeekday,
onClickDay,
onClickWeekNumber,

@@ -476,3 +470,2 @@ showDoubleView,

formatShortWeekday={formatShortWeekday}
onClick={mergeFunctions(clickAction, onClickDay)}
onClickWeekNumber={onClickWeekNumber}

@@ -625,3 +618,2 @@ onMouseLeave={onMouseLeave}

prevLabel: PropTypes.node,
renderChildren: PropTypes.func, // For backwards compatibility
returnValue: PropTypes.oneOf(['start', 'end', 'range']),

@@ -628,0 +620,0 @@ selectRange: PropTypes.bool,

import { getRange } from './dates';
/**
* Returns a function that, when called, calls all the functions
* passed to it, applying its arguments to them.
*
* @param {Function[]} functions
*/
export const mergeFunctions = (...functions) => (...args) => functions
.filter(Boolean).forEach(f => f(...args));
/**
* Calls a function, if it's defined, with specified arguments

@@ -14,0 +5,0 @@ * @param {Function} fn

import {
mergeFunctions,
isValueWithinRange,

@@ -10,41 +9,2 @@ isRangeWithinRange,

describe('mergeFunctions', () => {
it('returns a function when called', () => {
const testFunction1 = jest.fn();
const testFunction2 = jest.fn();
const mergedFunctions = mergeFunctions(testFunction1, testFunction2);
expect(mergedFunctions).toBeInstanceOf(Function);
});
it('calls all functions passed to it upon creation of a merged function exactly once', () => {
const testFunction1 = jest.fn();
const testFunction2 = jest.fn();
const mergedFunctions = mergeFunctions(testFunction1, testFunction2);
mergedFunctions();
expect(testFunction1).toHaveBeenCalledTimes(1);
expect(testFunction2).toHaveBeenCalledTimes(1);
});
it('passes the same arguments to all functions passed to it upon creation of a merged function', () => {
const arg1 = 'hello';
const arg2 = null;
const arg3 = 42;
const testFunction1 = jest.fn();
const testFunction2 = jest.fn();
const mergedFunctions = mergeFunctions(testFunction1, testFunction2);
mergedFunctions(arg1, arg2, arg3);
expect(testFunction1).toHaveBeenCalledWith(arg1, arg2, arg3);
expect(testFunction2).toHaveBeenCalledWith(arg1, arg2, arg3);
});
});
describe('isValueWithinRange', () => {

@@ -51,0 +11,0 @@ it('returns true for a value between range bonduaries', () => {

@@ -7,11 +7,13 @@ import React, { Component } from 'react';

function getValue(nextProps, prop) {
const { activeStartDate, date, view } = nextProps;
return typeof prop === 'function'
? prop({ activeStartDate, date, view })
: prop;
}
export default class Tile extends Component {
static getDerivedStateFromProps(nextProps, prevState) {
const {
activeStartDate,
date,
tileClassName,
tileContent,
view,
} = nextProps;
const { tileClassName, tileContent } = nextProps;

@@ -21,7 +23,3 @@ const nextState = {};

if (tileClassName !== prevState.tileClassNameProps) {
nextState.tileClassName = (
typeof tileClassName === 'function'
? tileClassName({ activeStartDate, date, view })
: tileClassName
);
nextState.tileClassName = getValue(nextProps, tileClassName);
nextState.tileClassNameProps = tileClassName;

@@ -31,7 +29,3 @@ }

if (tileContent !== prevState.tileContentProps) {
nextState.tileContent = (
typeof tileContent === 'function'
? tileContent({ activeStartDate, date, view })
: tileContent
);
nextState.tileContent = getValue(nextProps, tileContent);
nextState.tileContentProps = tileContent;

@@ -38,0 +32,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc