Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-calendar

Package Overview
Dependencies
Maintainers
3
Versions
88
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 2.6.0 to 2.7.0

101

build/Calendar.js

@@ -66,2 +66,6 @@ 'use strict';

var datesAreDifferent = function datesAreDifferent(date1, date2) {
return date1 && !date2 || !date1 && date2 || date1 && date2 && date1.getTime() !== date2.getTime();
};
var Calendar = function (_Component) {

@@ -139,2 +143,3 @@ _inherits(Calendar, _Component);

}
return [this.getValueFrom(value), this.getValueTo(value)];

@@ -146,4 +151,5 @@ }

if (!value) {
return value;
return null;
}
var _props = this.props,

@@ -154,11 +160,11 @@ maxDate = _props.maxDate,

var rawValueFrom = value instanceof Array ? value[0] : value;
var valueFrom = (0, _dates.getBegin)(this.valueType, rawValueFrom);
var valueFromDate = new Date(rawValueFrom);
if (minDate && minDate > valueFrom) {
return minDate;
if (Number.isNaN(valueFromDate.getTime())) {
throw new Error('Invalid date: ' + value);
}
if (maxDate && maxDate < valueFrom) {
return maxDate;
}
return valueFrom;
var valueFrom = (0, _dates.getBegin)(this.valueType, valueFromDate);
return (0, _utils.between)(valueFrom, minDate, maxDate);
}

@@ -169,4 +175,5 @@ }, {

if (!value) {
return value;
return null;
}
var _props2 = this.props,

@@ -176,12 +183,12 @@ maxDate = _props2.maxDate,

var rawValueFrom = value instanceof Array ? value[1] : value;
var valueTo = (0, _dates.getEnd)(this.valueType, rawValueFrom);
var rawValueTo = value instanceof Array ? value[1] : value;
var valueToDate = new Date(rawValueTo);
if (minDate && minDate > valueTo) {
return minDate;
if (Number.isNaN(valueToDate.getTime())) {
throw new Error('Invalid date: ' + value);
}
if (maxDate && maxDate < valueTo) {
return maxDate;
}
return valueTo;
var valueTo = (0, _dates.getEnd)(this.valueType, valueToDate);
return (0, _utils.between)(valueTo, minDate, maxDate);
}

@@ -248,30 +255,28 @@

value: function componentWillReceiveProps(nextProps) {
var props = this.props;
var nextLocale = nextProps.locale,
nextValue = nextProps.value;
var _props3 = this.props,
locale = _props3.locale,
value = _props3.value;
var allowedViewChanged = nextProps.minDetail !== props.minDetail || nextProps.maxDetail !== props.maxDetail;
if (nextLocale !== locale) {
(0, _locales.setLocale)(nextLocale);
}
var nextValueFrom = this.getValueFrom(nextProps.value);
var valueFrom = this.getValueFrom(props.value);
var valueFromChanged = nextValueFrom && !valueFrom || !nextValueFrom && valueFrom || nextValueFrom && valueFrom && nextValueFrom.getTime() !== valueFrom.getTime();
var nextState = {};
var nextValueTo = this.getValueTo(nextProps.value);
var valueTo = this.getValueTo(props.value);
var valueToChanged = nextValueTo && !valueTo || !nextValueTo && valueTo || nextValueTo && valueTo && nextValueTo.getTime() !== valueTo.getTime();
var allowedViewChanged = nextProps.minDetail !== this.props.minDetail || nextProps.maxDetail !== this.props.maxDetail;
var valueChanged = valueFromChanged || valueToChanged;
if (allowedViewChanged && !this.isViewAllowed(nextProps)) {
nextState.view = this.getView(nextProps);
}
var nextState = {};
var nextValueFrom = this.getValueFrom(nextValue);
var valueFrom = this.getValueFrom(value);
if (nextProps.locale !== props.locale) {
(0, _locales.setLocale)(nextProps.locale);
}
var nextValueTo = this.getValueTo(nextValue);
var valueTo = this.getValueTo(value);
if (allowedViewChanged) {
if (!this.isViewAllowed(nextProps)) {
nextState.view = this.getView(nextProps);
}
}
if (allowedViewChanged || valueChanged) {
if (allowedViewChanged || datesAreDifferent(nextValueFrom, valueFrom) || datesAreDifferent(nextValueTo, valueTo)) {
nextState.activeStartDate = this.getActiveStartDate(nextProps);

@@ -319,10 +324,10 @@ }

valueType = this.valueType;
var _props3 = this.props,
calendarType = _props3.calendarType,
maxDate = _props3.maxDate,
minDate = _props3.minDate,
renderChildren = _props3.renderChildren,
tileClassName = _props3.tileClassName,
tileContent = _props3.tileContent,
value = _props3.value;
var _props4 = this.props,
calendarType = _props4.calendarType,
maxDate = _props4.maxDate,
minDate = _props4.minDate,
renderChildren = _props4.renderChildren,
tileClassName = _props4.tileClassName,
tileContent = _props4.tileContent,
value = _props4.value;
var _state = this.state,

@@ -340,3 +345,3 @@ activeStartDate = _state.activeStartDate,

tileContent: tileContent || renderChildren, // For backwards compatibility
value: value,
value: this.getProcessedValue(value),
valueType: valueType

@@ -480,4 +485,4 @@ };

tileContent: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.node]),
value: _propTypes3.isValue,
view: _propTypes2.default.oneOf(allViews) // eslint-disable-line react/no-unused-prop-types
value: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes3.isValue]),
view: _propTypes2.default.oneOf(allViews)
};

@@ -40,3 +40,3 @@ 'use strict';

{
className: (0, _mergeClassNames2.default)(className, active ? 'react-calendar__tile--active' : '', hasActive ? 'react-calendar__tile--hasActive' : '', 'react-calendar__tile', tileClassName instanceof Function ? tileClassName({ date: date, view: 'century' }) : tileClassName),
className: (0, _mergeClassNames2.default)(className, active && 'react-calendar__tile--active', hasActive && 'react-calendar__tile--hasActive', 'react-calendar__tile', tileClassName instanceof Function ? tileClassName({ date: date, view: 'century' }) : tileClassName),
disabled: minDate && (0, _dates.getBeginOfDecade)(minDate) > date || maxDate && (0, _dates.getEndOfDecade)(maxDate) < date,

@@ -43,0 +43,0 @@ onClick: onClick && function () {

@@ -40,3 +40,3 @@ 'use strict';

{
className: (0, _mergeClassNames2.default)(className, active ? 'react-calendar__tile--active' : '', hasActive ? 'react-calendar__tile--hasActive' : '', 'react-calendar__tile', tileClassName instanceof Function ? tileClassName({ date: date, view: 'decade' }) : tileClassName),
className: (0, _mergeClassNames2.default)(className, active && 'react-calendar__tile--active', hasActive && 'react-calendar__tile--hasActive', 'react-calendar__tile', tileClassName instanceof Function ? tileClassName({ date: date, view: 'decade' }) : tileClassName),
disabled: minDate && (0, _dates.getBeginOfYear)(minDate) > date || maxDate && (0, _dates.getEndOfYear)(maxDate) < date,

@@ -43,0 +43,0 @@ onClick: onClick && function () {

@@ -39,3 +39,3 @@ 'use strict';

{
className: (0, _mergeClassNames2.default)(className, 'react-calendar__tile', active ? 'react-calendar__tile--active' : '', (0, _dates.isWeekend)(date) ? className + '--weekend' : '', date.getMonth() !== currentMonthIndex ? className + '--neighboringMonth' : '', tileClassName instanceof Function ? tileClassName({ date: date, view: 'month' }) : tileClassName),
className: (0, _mergeClassNames2.default)(className, 'react-calendar__tile', active && 'react-calendar__tile--active', (0, _dates.isWeekend)(date) && className + '--weekend', date.getMonth() !== currentMonthIndex && className + '--neighboringMonth', tileClassName instanceof Function ? tileClassName({ date: date, view: 'month' }) : tileClassName),
disabled: minDate && (0, _dates.getBeginOfDay)(minDate) > date || maxDate && (0, _dates.getEndOfDay)(maxDate) < date,

@@ -42,0 +42,0 @@ key: date,

@@ -514,8 +514,10 @@ 'use strict';

if (!(value instanceof Date)) {
var date = new Date(value);
if (Number.isNaN(date.getTime())) {
throw new Error('Invalid date: ' + value);
}
var year = getYear(value);
var month = ('0' + getMonth(value)).slice(-2);
var year = getYear(date);
var month = ('0' + getMonth(date)).slice(-2);

@@ -533,11 +535,13 @@ return year + '-' + month;

if (!(value instanceof Date)) {
var date = new Date(value);
if (Number.isNaN(date.getTime())) {
throw new Error('Invalid date: ' + value);
}
var year = getYear(value);
var month = ('0' + getMonth(value)).slice(-2);
var day = ('0' + getDay(value)).slice(-2);
var year = getYear(date);
var month = ('0' + getMonth(date)).slice(-2);
var day = ('0' + getDay(date)).slice(-2);
return year + '-' + month + '-' + day;
};

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

});
exports.getTileActivityFlags = exports.doRangesOverlap = exports.isRangeWithinRange = exports.isValueWithinRange = exports.mergeFunctions = undefined;
exports.getTileActivityFlags = exports.between = exports.doRangesOverlap = exports.isRangeWithinRange = exports.isValueWithinRange = exports.mergeFunctions = undefined;

@@ -36,7 +36,7 @@ var _dates = require('./dates');

var isValueWithinRange = exports.isValueWithinRange = function isValueWithinRange(value, range) {
return range[0].getTime() <= value.getTime() && range[1].getTime() >= value.getTime();
return range[0] <= value && range[1] >= value;
};
var isRangeWithinRange = exports.isRangeWithinRange = function isRangeWithinRange(greaterRange, smallerRange) {
return greaterRange[0].getTime() <= smallerRange[0].getTime() && greaterRange[1].getTime() >= smallerRange[1].getTime();
return greaterRange[0] <= smallerRange[0] && greaterRange[1] >= smallerRange[1];
};

@@ -48,2 +48,19 @@

/**
* Returns a value no smaller than min and no larger than max.
*
* @param {*} value Value to return.
* @param {*} min Minimum return value.
* @param {*} max Maximum return value.
*/
var between = exports.between = function between(value, min, max) {
if (min && min > value) {
return min;
}
if (max && max < value) {
return max;
}
return value;
};
var getTileActivityFlags = exports.getTileActivityFlags = function getTileActivityFlags(value, valueType, date, dateType) {

@@ -50,0 +67,0 @@ var flags = {};

@@ -41,3 +41,3 @@ 'use strict';

{
className: (0, _mergeClassNames2.default)(className, active ? 'react-calendar__tile--active' : '', hasActive ? 'react-calendar__tile--hasActive' : '', 'react-calendar__tile', tileClassName instanceof Function ? tileClassName({ date: date, view: 'year' }) : tileClassName),
className: (0, _mergeClassNames2.default)(className, active && 'react-calendar__tile--active', hasActive && 'react-calendar__tile--hasActive', 'react-calendar__tile', tileClassName instanceof Function ? tileClassName({ date: date, view: 'year' }) : tileClassName),
disabled: minDate && (0, _dates.getBeginOfMonth)(minDate) > date || maxDate && (0, _dates.getEndOfMonth)(maxDate) < date,

@@ -44,0 +44,0 @@ onClick: onClick && function () {

{
"name": "react-calendar",
"version": "2.6.0",
"version": "2.7.0",
"description": "A component for picking dates or date periods for your React application.",

@@ -20,2 +20,6 @@ "main": "build/entry.js",

"jest": {
"setupFiles": [
"<rootDir>/jest.shim.js",
"<rootDir>/jest.setup.js"
],
"collectCoverageFrom": [

@@ -22,0 +26,0 @@ "**/src/**.{js,jsx}",

@@ -127,3 +127,3 @@ ![downloads](https://img.shields.io/npm/dt/react-calendar.svg) ![build](https://img.shields.io/travis/wojtekmaj/react-calendar.svg) ![dependencies](https://img.shields.io/david/wojtekmaj/react-calendar.svg

|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)]`|
|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>|

@@ -130,0 +130,0 @@ ## License

import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';

@@ -11,4 +10,2 @@ import Calendar from '../Calendar';

configure({ adapter: new Adapter() });
/* eslint-disable comma-dangle */

@@ -15,0 +12,0 @@

import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';
import CenturyView from '../CenturyView';
configure({ adapter: new Adapter() });
/* eslint-disable comma-dangle */

@@ -10,0 +7,0 @@

import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';
import DecadeView from '../DecadeView';
configure({ adapter: new Adapter() });
/* eslint-disable comma-dangle */

@@ -10,0 +7,0 @@

import React from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { shallow } from 'enzyme';
import Flex from '../Flex';
configure({ adapter: new Adapter() });
/* eslint-disable comma-dangle */

@@ -10,0 +7,0 @@

import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';

@@ -10,4 +9,2 @@ import MonthView from '../MonthView';

configure({ adapter: new Adapter() });
/* eslint-disable comma-dangle */

@@ -14,0 +11,0 @@

import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';

@@ -10,4 +9,2 @@ import YearView from '../YearView';

configure({ adapter: new Adapter() });
/* eslint-disable comma-dangle */

@@ -14,0 +11,0 @@

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

import { isCalendarType, isClassName, isMaxDate, isMinDate, isValue } from './shared/propTypes';
import { mergeFunctions } from './shared/utils';
import { between, mergeFunctions } from './shared/utils';

@@ -20,2 +20,8 @@ const allViews = ['century', 'decade', 'year', 'month'];

const datesAreDifferent = (date1, date2) => (
(date1 && !date2) ||
(!date1 && date2) ||
(date1 && date2 && date1.getTime() !== date2.getTime())
);
export default class Calendar extends Component {

@@ -48,2 +54,3 @@ get drillDownAvailable() {

}
return [this.getValueFrom(value), this.getValueTo(value)];

@@ -54,15 +61,16 @@ }

if (!value) {
return value;
return null;
}
const { maxDate, minDate } = this.props;
const rawValueFrom = value instanceof Array ? value[0] : value;
const valueFrom = getBegin(this.valueType, rawValueFrom);
const valueFromDate = new Date(rawValueFrom);
if (minDate && minDate > valueFrom) {
return minDate;
if (Number.isNaN(valueFromDate.getTime())) {
throw new Error(`Invalid date: ${value}`);
}
if (maxDate && maxDate < valueFrom) {
return maxDate;
}
return valueFrom;
const valueFrom = getBegin(this.valueType, valueFromDate);
return between(valueFrom, minDate, maxDate);
}

@@ -72,15 +80,16 @@

if (!value) {
return value;
return null;
}
const { maxDate, minDate } = this.props;
const rawValueFrom = value instanceof Array ? value[1] : value;
const valueTo = getEnd(this.valueType, rawValueFrom);
const rawValueTo = value instanceof Array ? value[1] : value;
const valueToDate = new Date(rawValueTo);
if (minDate && minDate > valueTo) {
return minDate;
if (Number.isNaN(valueToDate.getTime())) {
throw new Error(`Invalid date: ${value}`);
}
if (maxDate && maxDate < valueTo) {
return maxDate;
}
return valueTo;
const valueTo = getEnd(this.valueType, valueToDate);
return between(valueTo, minDate, maxDate);
}

@@ -134,40 +143,31 @@

componentWillReceiveProps(nextProps) {
const { props } = this;
const { locale: nextLocale, value: nextValue } = nextProps;
const { locale, value } = this.props;
const allowedViewChanged = (
nextProps.minDetail !== props.minDetail ||
nextProps.maxDetail !== props.maxDetail
);
if (nextLocale !== locale) {
setLocale(nextLocale);
}
const nextValueFrom = this.getValueFrom(nextProps.value);
const valueFrom = this.getValueFrom(props.value);
const valueFromChanged = (
(nextValueFrom && !valueFrom) ||
(!nextValueFrom && valueFrom) ||
(nextValueFrom && valueFrom && nextValueFrom.getTime() !== valueFrom.getTime())
);
const nextState = {};
const nextValueTo = this.getValueTo(nextProps.value);
const valueTo = this.getValueTo(props.value);
const valueToChanged = (
(nextValueTo && !valueTo) ||
(!nextValueTo && valueTo) ||
(nextValueTo && valueTo && nextValueTo.getTime() !== valueTo.getTime())
const allowedViewChanged = (
nextProps.minDetail !== this.props.minDetail ||
nextProps.maxDetail !== this.props.maxDetail
);
const valueChanged = valueFromChanged || valueToChanged;
if (allowedViewChanged && !this.isViewAllowed(nextProps)) {
nextState.view = this.getView(nextProps);
}
const nextState = {};
const nextValueFrom = this.getValueFrom(nextValue);
const valueFrom = this.getValueFrom(value);
if (nextProps.locale !== props.locale) {
setLocale(nextProps.locale);
}
const nextValueTo = this.getValueTo(nextValue);
const valueTo = this.getValueTo(value);
if (allowedViewChanged) {
if (!this.isViewAllowed(nextProps)) {
nextState.view = this.getView(nextProps);
}
}
if (allowedViewChanged || valueChanged) {
if (
allowedViewChanged ||
datesAreDifferent(nextValueFrom, valueFrom) ||
datesAreDifferent(nextValueTo, valueTo)
) {
nextState.activeStartDate = this.getActiveStartDate(nextProps);

@@ -266,3 +266,3 @@ }

tileContent: tileContent || renderChildren, // For backwards compatibility
value,
value: this.getProcessedValue(value),
valueType,

@@ -387,4 +387,7 @@ };

]),
value: isValue,
view: PropTypes.oneOf(allViews), // eslint-disable-line react/no-unused-prop-types
value: PropTypes.oneOfType([
PropTypes.string,
isValue,
]),
view: PropTypes.oneOf(allViews),
};
import React from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { shallow } from 'enzyme';
import Navigation from '../Navigation';
configure({ adapter: new Adapter() });
const allViews = ['century', 'decade', 'year', 'month'];

@@ -10,0 +7,0 @@

@@ -24,4 +24,4 @@ import React from 'react';

className,
(active ? 'react-calendar__tile--active' : ''),
(hasActive ? 'react-calendar__tile--hasActive' : ''),
active && 'react-calendar__tile--active',
hasActive && 'react-calendar__tile--hasActive',
'react-calendar__tile',

@@ -28,0 +28,0 @@ tileClassName instanceof Function ? tileClassName({ date, view: 'century' }) : tileClassName,

@@ -19,4 +19,4 @@ import React from 'react';

className,
(active ? 'react-calendar__tile--active' : ''),
(hasActive ? 'react-calendar__tile--hasActive' : ''),
active && 'react-calendar__tile--active',
hasActive && 'react-calendar__tile--hasActive',
'react-calendar__tile',

@@ -23,0 +23,0 @@ tileClassName instanceof Function ? tileClassName({ date, view: 'decade' }) : tileClassName,

import React from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { shallow } from 'enzyme';
import WeekNumbers from '../WeekNumbers';
configure({ adapter: new Adapter() });
/* eslint-disable comma-dangle */

@@ -10,0 +7,0 @@

@@ -23,5 +23,5 @@ import React from 'react';

'react-calendar__tile',
(active ? 'react-calendar__tile--active' : ''),
(isWeekend(date) ? `${className}--weekend` : ''),
(date.getMonth() !== currentMonthIndex ? `${className}--neighboringMonth` : ''),
active && 'react-calendar__tile--active',
isWeekend(date) && `${className}--weekend`,
date.getMonth() !== currentMonthIndex && `${className}--neighboringMonth`,
tileClassName instanceof Function ? tileClassName({ date, view: 'month' }) : tileClassName,

@@ -28,0 +28,0 @@ )}

@@ -1100,6 +1100,6 @@ import {

const text = 'wololo';
const flag = true;
const fn = () => {};
expect(() => getISOLocalMonth(text)).toThrow();
expect(() => getISOLocalMonth(flag)).toThrow();
expect(() => getISOLocalMonth(fn)).toThrow();
});

@@ -1123,7 +1123,7 @@ });

const text = 'wololo';
const flag = true;
const fn = () => {};
expect(() => getISOLocalDate(text)).toThrow();
expect(() => getISOLocalDate(flag)).toThrow();
expect(() => getISOLocalDate(fn)).toThrow();
});
});

@@ -6,2 +6,3 @@ import {

doRangesOverlap,
between,
getTileActivityFlags,

@@ -169,2 +170,38 @@ } from '../utils';

describe('between', () => {
it('returns value when value is within set boundaries', () => {
const value = new Date(2017, 6, 1);
const min = new Date(2017, 0, 1);
const max = new Date(2017, 11, 1);
const result = between(value, min, max);
expect(result).toBe(value);
});
it('returns min when value is smaller than min', () => {
const value = new Date(2017, 0, 1);
const min = new Date(2017, 6, 1);
const max = new Date(2017, 11, 1);
const result = between(value, min, max);
expect(result).toBe(min);
});
it('returns max when value is larger than max', () => {
const value = new Date(2017, 11, 1);
const min = new Date(2017, 0, 1);
const max = new Date(2017, 6, 1);
const result = between(value, min, max);
expect(result).toBe(max);
});
it('returns value when min and max are not provided', () => {
const value = new Date(2017, 6, 1);
const result = between(value, null, undefined);
expect(result).toBe(value);
});
});
describe('getTileActivityFlags', () => {

@@ -171,0 +208,0 @@ it('returns all flags set to false when given no value', () => {

@@ -471,8 +471,10 @@ /* Simple getters - getting a property of a given point in time */

if (!(value instanceof Date)) {
const date = new Date(value);
if (Number.isNaN(date.getTime())) {
throw new Error(`Invalid date: ${value}`);
}
const year = getYear(value);
const month = `0${getMonth(value)}`.slice(-2);
const year = getYear(date);
const month = `0${getMonth(date)}`.slice(-2);

@@ -490,11 +492,13 @@ return `${year}-${month}`;

if (!(value instanceof Date)) {
const date = new Date(value);
if (Number.isNaN(date.getTime())) {
throw new Error(`Invalid date: ${value}`);
}
const year = getYear(value);
const month = `0${getMonth(value)}`.slice(-2);
const day = `0${getDay(value)}`.slice(-2);
const year = getYear(date);
const month = `0${getMonth(date)}`.slice(-2);
const day = `0${getDay(date)}`.slice(-2);
return `${year}-${month}-${day}`;
};

@@ -13,9 +13,9 @@ import { getRange } from './dates';

export const isValueWithinRange = (value, range) => (
range[0].getTime() <= value.getTime() &&
range[1].getTime() >= value.getTime()
range[0] <= value &&
range[1] >= value
);
export const isRangeWithinRange = (greaterRange, smallerRange) => (
greaterRange[0].getTime() <= smallerRange[0].getTime() &&
greaterRange[1].getTime() >= smallerRange[1].getTime()
greaterRange[0] <= smallerRange[0] &&
greaterRange[1] >= smallerRange[1]
);

@@ -28,2 +28,19 @@

/**
* Returns a value no smaller than min and no larger than max.
*
* @param {*} value Value to return.
* @param {*} min Minimum return value.
* @param {*} max Maximum return value.
*/
export const between = (value, min, max) => {
if (min && min > value) {
return min;
}
if (max && max < value) {
return max;
}
return value;
};
export const getTileActivityFlags = (value, valueType, date, dateType) => {

@@ -30,0 +47,0 @@ const flags = {};

@@ -21,4 +21,4 @@ import React from 'react';

className,
(active ? 'react-calendar__tile--active' : ''),
(hasActive ? 'react-calendar__tile--hasActive' : ''),
active && 'react-calendar__tile--active',
hasActive && 'react-calendar__tile--hasActive',
'react-calendar__tile',

@@ -25,0 +25,0 @@ tileClassName instanceof Function ? tileClassName({ date, view: 'year' }) : tileClassName,

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