first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
@@ -0,0 +1,98 @@
import { DayOfWeek, DateRangeType, FirstWeekOfYear } from '../dateValues/dateValues';
export interface IDay {
/** `Date.toString()` value of current date */
key: string;
/** `Date.getDate()` value of current date */
date: string;
/** `Date` object of current date */
originalDate: Date;
/** Is current date is in the same month as "today" date */
isInMonth: boolean;
/** Is current date is "today" date */
isToday: boolean;
/** Is current date is selected */
isSelected: boolean;
/** Is current date within restriction boundaries */
isInBounds: boolean;
/** Is current date marked */
isMarked: boolean;
}
export interface IAvailableDateOptions extends IRestrictedDatesOptions {
/** Date from which we start the search */
initialDate: Date;
/** Ideal available date */
targetDate: Date;
/** Direction of search (`1` - search in future / `-1` search in past) */
direction: number;
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface IRestrictedDatesOptions {
/**
* If set the Calendar will not allow navigation to or selection of a date earlier than this value.
*/
minDate?: Date;
/**
* If set the Calendar will not allow navigation to or selection of a date later than this value.
*/
maxDate?: Date;
/**
* If set the Calendar will not allow selection of dates in this array.
*/
restrictedDates?: Date[];
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface IDayGridOptions extends IRestrictedDatesOptions {
/**
* The first day of the week for your locale.
*/
firstDayOfWeek: DayOfWeek;
/**
* Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,
* FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values
*/
firstWeekOfYear: FirstWeekOfYear;
/**
* The date range type indicating how many days should be selected as the user
* selects days
*/
dateRangeType: DateRangeType;
/**
* The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day
* views.
*/
daysToSelectInDayView?: number;
/**
* Value of today. If unspecified, current time in client machine will be used.
*/
today?: Date;
/**
* Whether the calendar should show the week number (weeks 1 to 53) before each week row
*/
showWeekNumbers?: boolean;
/**
* The days that are selectable when `dateRangeType` is WorkWeek.
* If `dateRangeType` is not WorkWeek this property does nothing.
*/
workWeekDays?: DayOfWeek[];
/**
* Which days in the generated grid should be marked.
*/
markedDays?: Date[];
/**
* The currently selected date
*/
selectedDate: Date;
/**
* The currently navigated date
*/
navigatedDate: Date;
/**
* How many weeks to show by default. If not provided, will show enough weeks to display the current
* month, between 4 and 6 depending
*/
weeksToShow?: number;
}
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=dateGrid.types.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dateGrid.types.js","sourceRoot":"../src/","sources":["dateGrid/dateGrid.types.ts"],"names":[],"mappings":"","sourcesContent":["import { DayOfWeek, DateRangeType, FirstWeekOfYear } from '../dateValues/dateValues';\n\nexport interface IDay {\n /** `Date.toString()` value of current date */\n key: string;\n /** `Date.getDate()` value of current date */\n date: string;\n /** `Date` object of current date */\n originalDate: Date;\n /** Is current date is in the same month as \"today\" date */\n isInMonth: boolean;\n /** Is current date is \"today\" date */\n isToday: boolean;\n /** Is current date is selected */\n isSelected: boolean;\n /** Is current date within restriction boundaries */\n isInBounds: boolean;\n /** Is current date marked */\n isMarked: boolean;\n}\n\nexport interface IAvailableDateOptions extends IRestrictedDatesOptions {\n /** Date from which we start the search */\n initialDate: Date;\n /** Ideal available date */\n targetDate: Date;\n /** Direction of search (`1` - search in future / `-1` search in past) */\n direction: number;\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IRestrictedDatesOptions {\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IDayGridOptions extends IRestrictedDatesOptions {\n /**\n * The first day of the week for your locale.\n */\n firstDayOfWeek: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,\n * FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values\n */\n firstWeekOfYear: FirstWeekOfYear;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n */\n dateRangeType: DateRangeType;\n\n /**\n * The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day\n * views.\n */\n daysToSelectInDayView?: number;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n */\n showWeekNumbers?: boolean;\n\n /**\n * The days that are selectable when `dateRangeType` is WorkWeek.\n * If `dateRangeType` is not WorkWeek this property does nothing.\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Which days in the generated grid should be marked.\n */\n markedDays?: Date[];\n\n /**\n * The currently selected date\n */\n selectedDate: Date;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * How many weeks to show by default. If not provided, will show enough weeks to display the current\n * month, between 4 and 6 depending\n */\n weeksToShow?: number;\n}\n"]}
@@ -0,0 +1,6 @@
import { IAvailableDateOptions } from './dateGrid.types';
/**
* Returns closest available date given the restriction `options`, or undefined otherwise
* @param options - list of search options
*/
export declare const findAvailableDate: (options: IAvailableDateOptions) => Date | undefined;
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findAvailableDate = void 0;
var tslib_1 = require("tslib");
var isRestrictedDate_1 = require("./isRestrictedDate");
var isAfterMaxDate_1 = require("./isAfterMaxDate");
var isBeforeMinDate_1 = require("./isBeforeMinDate");
var dateMath_1 = require("../dateMath/dateMath");
/**
* Returns closest available date given the restriction `options`, or undefined otherwise
* @param options - list of search options
*/
var findAvailableDate = function (options) {
var targetDate = options.targetDate, initialDate = options.initialDate, direction = options.direction, restrictedDateOptions = tslib_1.__rest(options, ["targetDate", "initialDate", "direction"]);
var availableDate = targetDate;
// if the target date is available, return it immediately
if (!(0, isRestrictedDate_1.isRestrictedDate)(targetDate, restrictedDateOptions)) {
return targetDate;
}
while ((0, dateMath_1.compareDatePart)(initialDate, availableDate) !== 0 &&
(0, isRestrictedDate_1.isRestrictedDate)(availableDate, restrictedDateOptions) &&
!(0, isAfterMaxDate_1.isAfterMaxDate)(availableDate, restrictedDateOptions) &&
!(0, isBeforeMinDate_1.isBeforeMinDate)(availableDate, restrictedDateOptions)) {
availableDate = (0, dateMath_1.addDays)(availableDate, direction);
}
if ((0, dateMath_1.compareDatePart)(initialDate, availableDate) !== 0 && !(0, isRestrictedDate_1.isRestrictedDate)(availableDate, restrictedDateOptions)) {
return availableDate;
}
return undefined;
};
exports.findAvailableDate = findAvailableDate;
//# sourceMappingURL=findAvailableDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"findAvailableDate.js","sourceRoot":"../src/","sources":["dateGrid/findAvailableDate.ts"],"names":[],"mappings":";;;;AAEA,uDAAsD;AAEtD,mDAAkD;AAElD,qDAAoD;AACpD,iDAAgE;AAEhE;;;GAGG;AACI,IAAM,iBAAiB,GAAG,UAAC,OAA8B;IACtD,IAAA,UAAU,GAAuD,OAAO,WAA9D,EAAE,WAAW,GAA0C,OAAO,YAAjD,EAAE,SAAS,GAA+B,OAAO,UAAtC,EAAK,qBAAqB,kBAAK,OAAO,EAA1E,0CAAgE,CAAF,CAAa;IACjF,IAAI,aAAa,GAAG,UAAU,CAAC;IAC/B,yDAAyD;IACzD,IAAI,CAAC,IAAA,mCAAgB,EAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACzD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OACE,IAAA,0BAAe,EAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC;QACjD,IAAA,mCAAgB,EAAC,aAAa,EAAE,qBAAqB,CAAC;QACtD,CAAC,IAAA,+BAAc,EAAC,aAAa,EAAE,qBAAqB,CAAC;QACrD,CAAC,IAAA,iCAAe,EAAC,aAAa,EAAE,qBAAqB,CAAC,EACtD,CAAC;QACD,aAAa,GAAG,IAAA,kBAAO,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,IAAA,0BAAe,EAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAA,mCAAgB,EAAC,aAAa,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACjH,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAtBW,QAAA,iBAAiB,qBAsB5B","sourcesContent":["import { IAvailableDateOptions } from './dateGrid.types';\n\nimport { isRestrictedDate } from './isRestrictedDate';\n\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { compareDatePart, addDays } from '../dateMath/dateMath';\n\n/**\n * Returns closest available date given the restriction `options`, or undefined otherwise\n * @param options - list of search options\n */\nexport const findAvailableDate = (options: IAvailableDateOptions): Date | undefined => {\n const { targetDate, initialDate, direction, ...restrictedDateOptions } = options;\n let availableDate = targetDate;\n // if the target date is available, return it immediately\n if (!isRestrictedDate(targetDate, restrictedDateOptions)) {\n return targetDate;\n }\n\n while (\n compareDatePart(initialDate, availableDate) !== 0 &&\n isRestrictedDate(availableDate, restrictedDateOptions) &&\n !isAfterMaxDate(availableDate, restrictedDateOptions) &&\n !isBeforeMinDate(availableDate, restrictedDateOptions)\n ) {\n availableDate = addDays(availableDate, direction);\n }\n\n if (compareDatePart(initialDate, availableDate) !== 0 && !isRestrictedDate(availableDate, restrictedDateOptions)) {\n return availableDate;\n }\n\n return undefined;\n};\n"]}
@@ -0,0 +1,7 @@
/**
* Generates a list of dates, bounded by min and max dates
* @param dateRange - input date range
* @param minDate - min date to limit the range
* @param maxDate - max date to limit the range
*/
export declare const getBoundedDateRange: (dateRange: Date[], minDate?: Date, maxDate?: Date) => Date[];
@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBoundedDateRange = void 0;
var tslib_1 = require("tslib");
var dateMath_1 = require("../dateMath/dateMath");
/**
* Generates a list of dates, bounded by min and max dates
* @param dateRange - input date range
* @param minDate - min date to limit the range
* @param maxDate - max date to limit the range
*/
var getBoundedDateRange = function (dateRange, minDate, maxDate) {
var boundedDateRange = tslib_1.__spreadArray([], dateRange, true);
if (minDate) {
boundedDateRange = boundedDateRange.filter(function (date) { return (0, dateMath_1.compareDatePart)(date, minDate) >= 0; });
}
if (maxDate) {
boundedDateRange = boundedDateRange.filter(function (date) { return (0, dateMath_1.compareDatePart)(date, maxDate) <= 0; });
}
return boundedDateRange;
};
exports.getBoundedDateRange = getBoundedDateRange;
//# sourceMappingURL=getBoundedDateRange.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getBoundedDateRange.js","sourceRoot":"../src/","sources":["dateGrid/getBoundedDateRange.ts"],"names":[],"mappings":";;;;AAAA,iDAAuD;AAEvD;;;;;GAKG;AACI,IAAM,mBAAmB,GAAG,UAAC,SAAiB,EAAE,OAAc,EAAE,OAAc;IACnF,IAAI,gBAAgB,6BAAO,SAAS,OAAC,CAAC;IACtC,IAAI,OAAO,EAAE,CAAC;QACZ,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAC,IAAU,IAAK,OAAA,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAe,CAAC,IAAI,CAAC,EAA3C,CAA2C,CAAC,CAAC;IAC1G,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAC,IAAU,IAAK,OAAA,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAe,CAAC,IAAI,CAAC,EAA3C,CAA2C,CAAC,CAAC;IAC1G,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B","sourcesContent":["import { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Generates a list of dates, bounded by min and max dates\n * @param dateRange - input date range\n * @param minDate - min date to limit the range\n * @param maxDate - max date to limit the range\n */\nexport const getBoundedDateRange = (dateRange: Date[], minDate?: Date, maxDate?: Date): Date[] => {\n let boundedDateRange = [...dateRange];\n if (minDate) {\n boundedDateRange = boundedDateRange.filter((date: Date) => compareDatePart(date, minDate as Date) >= 0);\n }\n if (maxDate) {\n boundedDateRange = boundedDateRange.filter((date: Date) => compareDatePart(date, maxDate as Date) <= 0);\n }\n return boundedDateRange;\n};\n"]}
@@ -0,0 +1,9 @@
import { DateRangeType, DayOfWeek } from '../dateValues/dateValues';
/**
* Return corrected date range type, given `dateRangeType` and list of working days.
* For non-contiguous working days and working week range type, returns general week range type.
* For other cases returns input date range type.
* @param dateRangeType - input type of range
* @param workWeekDays - list of working days in a week
*/
export declare const getDateRangeTypeToUse: (dateRangeType: DateRangeType, workWeekDays: DayOfWeek[] | undefined, firstDayOfWeek: DayOfWeek) => DateRangeType;
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDateRangeTypeToUse = void 0;
var dateValues_1 = require("../dateValues/dateValues");
var isContiguous_1 = require("./isContiguous");
/**
* Return corrected date range type, given `dateRangeType` and list of working days.
* For non-contiguous working days and working week range type, returns general week range type.
* For other cases returns input date range type.
* @param dateRangeType - input type of range
* @param workWeekDays - list of working days in a week
*/
var getDateRangeTypeToUse = function (dateRangeType, workWeekDays, firstDayOfWeek) {
if (workWeekDays && dateRangeType === dateValues_1.DateRangeType.WorkWeek) {
if (!(0, isContiguous_1.isContiguous)(workWeekDays, true, firstDayOfWeek) || workWeekDays.length === 0) {
return dateValues_1.DateRangeType.Week;
}
}
return dateRangeType;
};
exports.getDateRangeTypeToUse = getDateRangeTypeToUse;
//# sourceMappingURL=getDateRangeTypeToUse.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getDateRangeTypeToUse.js","sourceRoot":"../src/","sources":["dateGrid/getDateRangeTypeToUse.ts"],"names":[],"mappings":";;;AAAA,uDAAoE;AACpE,+CAA8C;AAC9C;;;;;;GAMG;AACI,IAAM,qBAAqB,GAAG,UACnC,aAA4B,EAC5B,YAAqC,EACrC,cAAyB;IAEzB,IAAI,YAAY,IAAI,aAAa,KAAK,0BAAa,CAAC,QAAQ,EAAE,CAAC;QAC7D,IAAI,CAAC,IAAA,2BAAY,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnF,OAAO,0BAAa,CAAC,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAZW,QAAA,qBAAqB,yBAYhC","sourcesContent":["import { DateRangeType, DayOfWeek } from '../dateValues/dateValues';\nimport { isContiguous } from './isContiguous';\n/**\n * Return corrected date range type, given `dateRangeType` and list of working days.\n * For non-contiguous working days and working week range type, returns general week range type.\n * For other cases returns input date range type.\n * @param dateRangeType - input type of range\n * @param workWeekDays - list of working days in a week\n */\nexport const getDateRangeTypeToUse = (\n dateRangeType: DateRangeType,\n workWeekDays: DayOfWeek[] | undefined,\n firstDayOfWeek: DayOfWeek,\n): DateRangeType => {\n if (workWeekDays && dateRangeType === DateRangeType.WorkWeek) {\n if (!isContiguous(workWeekDays, true, firstDayOfWeek) || workWeekDays.length === 0) {\n return DateRangeType.Week;\n }\n }\n\n return dateRangeType;\n};\n"]}
@@ -0,0 +1,8 @@
import { IDay, IDayGridOptions } from './dateGrid.types';
/**
* Generates a grid of days, given the `options`.
* Returns one additional week at the begining from the previous range
* and one at the end from the future range
* @param options - parameters to specify date related restrictions for the resulting grid
*/
export declare const getDayGrid: (options: IDayGridOptions) => IDay[][];
@@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDayGrid = void 0;
var dateMath_1 = require("../dateMath/dateMath");
var dateValues_1 = require("../dateValues/dateValues");
var getDateRangeTypeToUse_1 = require("./getDateRangeTypeToUse");
var getBoundedDateRange_1 = require("./getBoundedDateRange");
var isRestrictedDate_1 = require("./isRestrictedDate");
/**
* Generates a grid of days, given the `options`.
* Returns one additional week at the begining from the previous range
* and one at the end from the future range
* @param options - parameters to specify date related restrictions for the resulting grid
*/
var getDayGrid = function (options) {
var selectedDate = options.selectedDate, dateRangeType = options.dateRangeType, firstDayOfWeek = options.firstDayOfWeek, today = options.today, minDate = options.minDate, maxDate = options.maxDate, weeksToShow = options.weeksToShow, workWeekDays = options.workWeekDays, daysToSelectInDayView = options.daysToSelectInDayView, restrictedDates = options.restrictedDates, markedDays = options.markedDays;
var restrictedDateOptions = { minDate: minDate, maxDate: maxDate, restrictedDates: restrictedDates };
var todaysDate = today || new Date();
var navigatedDate = options.navigatedDate ? options.navigatedDate : todaysDate;
var date;
if (weeksToShow && weeksToShow <= 4) {
// if showing less than a full month, just use date == navigatedDate
date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), navigatedDate.getDate());
}
else {
date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1);
}
var weeks = [];
// Cycle the date backwards to get to the first day of the week.
while (date.getDay() !== firstDayOfWeek) {
date.setDate(date.getDate() - 1);
}
// add the transition week as last week of previous range
date = (0, dateMath_1.addDays)(date, -dateValues_1.DAYS_IN_WEEK);
// a flag to indicate whether all days of the week are outside the month
var isAllDaysOfWeekOutOfMonth = false;
// in work week view if the days aren't contiguous we use week view instead
var selectedDateRangeType = (0, getDateRangeTypeToUse_1.getDateRangeTypeToUse)(dateRangeType, workWeekDays, firstDayOfWeek);
var selectedDates = [];
if (selectedDate) {
selectedDates = (0, dateMath_1.getDateRangeArray)(selectedDate, selectedDateRangeType, firstDayOfWeek, workWeekDays, daysToSelectInDayView);
selectedDates = (0, getBoundedDateRange_1.getBoundedDateRange)(selectedDates, minDate, maxDate);
}
var shouldGetWeeks = true;
for (var weekIndex = 0; shouldGetWeeks; weekIndex++) {
var week = [];
isAllDaysOfWeekOutOfMonth = true;
var _loop_1 = function (dayIndex) {
var originalDate = new Date(date.getTime());
var dayInfo = {
key: date.toString(),
date: date.getDate().toString(),
originalDate: originalDate,
isInMonth: date.getMonth() === navigatedDate.getMonth(),
isToday: (0, dateMath_1.compareDates)(todaysDate, date),
isSelected: (0, dateMath_1.isInDateRangeArray)(date, selectedDates),
isInBounds: !(0, isRestrictedDate_1.isRestrictedDate)(date, restrictedDateOptions),
isMarked: (markedDays === null || markedDays === void 0 ? void 0 : markedDays.some(function (markedDay) { return (0, dateMath_1.compareDates)(originalDate, markedDay); })) || false,
};
week.push(dayInfo);
if (dayInfo.isInMonth) {
isAllDaysOfWeekOutOfMonth = false;
}
date.setDate(date.getDate() + 1);
};
for (var dayIndex = 0; dayIndex < dateValues_1.DAYS_IN_WEEK; dayIndex++) {
_loop_1(dayIndex);
}
// We append the condition of the loop depending upon the showSixWeeksByDefault prop.
shouldGetWeeks = weeksToShow ? weekIndex < weeksToShow + 1 : !isAllDaysOfWeekOutOfMonth || weekIndex === 0;
// we don't check shouldGetWeeks before pushing because we want to add one extra week for transition state
weeks.push(week);
}
return weeks;
};
exports.getDayGrid = getDayGrid;
//# sourceMappingURL=getDayGrid.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
export * from './dateGrid.types';
export * from './findAvailableDate';
export * from './getBoundedDateRange';
export * from './getDateRangeTypeToUse';
export * from './getDayGrid';
export * from './isAfterMaxDate';
export * from './isBeforeMinDate';
export * from './isRestrictedDate';
export * from './isContiguous';
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./dateGrid.types"), exports);
tslib_1.__exportStar(require("./findAvailableDate"), exports);
tslib_1.__exportStar(require("./getBoundedDateRange"), exports);
tslib_1.__exportStar(require("./getDateRangeTypeToUse"), exports);
tslib_1.__exportStar(require("./getDayGrid"), exports);
tslib_1.__exportStar(require("./isAfterMaxDate"), exports);
tslib_1.__exportStar(require("./isBeforeMinDate"), exports);
tslib_1.__exportStar(require("./isRestrictedDate"), exports);
tslib_1.__exportStar(require("./isContiguous"), exports);
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["dateGrid/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,8DAAoC;AACpC,gEAAsC;AACtC,kEAAwC;AACxC,uDAA6B;AAC7B,2DAAiC;AACjC,4DAAkC;AAClC,6DAAmC;AACnC,yDAA+B","sourcesContent":["export * from './dateGrid.types';\nexport * from './findAvailableDate';\nexport * from './getBoundedDateRange';\nexport * from './getDateRangeTypeToUse';\nexport * from './getDayGrid';\nexport * from './isAfterMaxDate';\nexport * from './isBeforeMinDate';\nexport * from './isRestrictedDate';\nexport * from './isContiguous';\n"]}
@@ -0,0 +1,7 @@
import { IRestrictedDatesOptions } from './dateGrid.types';
/**
* Checks if `date` happens later than max date
* @param date - date to check
* @param options - object with max date to check against
*/
export declare const isAfterMaxDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAfterMaxDate = void 0;
var dateMath_1 = require("../dateMath/dateMath");
/**
* Checks if `date` happens later than max date
* @param date - date to check
* @param options - object with max date to check against
*/
var isAfterMaxDate = function (date, options) {
var maxDate = options.maxDate;
return maxDate ? (0, dateMath_1.compareDatePart)(date, maxDate) >= 1 : false;
};
exports.isAfterMaxDate = isAfterMaxDate;
//# sourceMappingURL=isAfterMaxDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isAfterMaxDate.js","sourceRoot":"../src/","sources":["dateGrid/isAfterMaxDate.ts"],"names":[],"mappings":";;;AACA,iDAAuD;AAEvD;;;;GAIG;AACI,IAAM,cAAc,GAAG,UAAC,IAAU,EAAE,OAAgC;IACjE,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;IAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/D,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB","sourcesContent":["import { IRestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens later than max date\n * @param date - date to check\n * @param options - object with max date to check against\n */\nexport const isAfterMaxDate = (date: Date, options: IRestrictedDatesOptions): boolean => {\n const { maxDate } = options;\n return maxDate ? compareDatePart(date, maxDate) >= 1 : false;\n};\n"]}
@@ -0,0 +1,7 @@
import { IRestrictedDatesOptions } from './dateGrid.types';
/**
* Checks if `date` happens earlier than min date
* @param date - date to check
* @param options - object with min date to check against
*/
export declare const isBeforeMinDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBeforeMinDate = void 0;
var dateMath_1 = require("../dateMath/dateMath");
/**
* Checks if `date` happens earlier than min date
* @param date - date to check
* @param options - object with min date to check against
*/
var isBeforeMinDate = function (date, options) {
var minDate = options.minDate;
return minDate ? (0, dateMath_1.compareDatePart)(minDate, date) >= 1 : false;
};
exports.isBeforeMinDate = isBeforeMinDate;
//# sourceMappingURL=isBeforeMinDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isBeforeMinDate.js","sourceRoot":"../src/","sources":["dateGrid/isBeforeMinDate.ts"],"names":[],"mappings":";;;AACA,iDAAuD;AAEvD;;;;GAIG;AACI,IAAM,eAAe,GAAG,UAAC,IAAU,EAAE,OAAgC;IAClE,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;IAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,IAAA,0BAAe,EAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/D,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B","sourcesContent":["import { IRestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens earlier than min date\n * @param date - date to check\n * @param options - object with min date to check against\n */\nexport const isBeforeMinDate = (date: Date, options: IRestrictedDatesOptions): boolean => {\n const { minDate } = options;\n return minDate ? compareDatePart(minDate, date) >= 1 : false;\n};\n"]}
@@ -0,0 +1,8 @@
import { DayOfWeek } from '../dateValues/dateValues';
/**
* Returns whether provided week days are contiguous.
* @param days - list of days in a week
* @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not
* @param firstDayOfWeek - decides which day of week is the first one in the order.
*/
export declare const isContiguous: (days: DayOfWeek[], isSingleWeek: boolean, firstDayOfWeek: DayOfWeek) => boolean;
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isContiguous = void 0;
/**
* Returns whether provided week days are contiguous.
* @param days - list of days in a week
* @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not
* @param firstDayOfWeek - decides which day of week is the first one in the order.
*/
var isContiguous = function (days, isSingleWeek, firstDayOfWeek) {
var daySet = new Set(days);
var amountOfNoNeighbors = 0;
for (var _i = 0, days_1 = days; _i < days_1.length; _i++) {
var day = days_1[_i];
var nextDay = (day + 1) % 7;
if (!(daySet.has(nextDay) && (!isSingleWeek || firstDayOfWeek !== nextDay))) {
amountOfNoNeighbors++;
}
}
// In case the full week is provided, then each day has a neighbor
//, otherwise the last day does not have a neighbor.
return amountOfNoNeighbors < 2;
};
exports.isContiguous = isContiguous;
//# sourceMappingURL=isContiguous.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isContiguous.js","sourceRoot":"../src/","sources":["dateGrid/isContiguous.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,IAAM,YAAY,GAAG,UAAC,IAAiB,EAAE,YAAqB,EAAE,cAAyB;IAC9F,IAAM,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,mBAAmB,GAAG,CAAC,CAAC;IAC5B,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE,CAAC;QAApB,IAAM,GAAG,aAAA;QACZ,IAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,cAAc,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;YAC5E,mBAAmB,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;IAED,kEAAkE;IAClE,oDAAoD;IACpD,OAAO,mBAAmB,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC;AAbW,QAAA,YAAY,gBAavB","sourcesContent":["import { DayOfWeek } from '../dateValues/dateValues';\n\n/**\n * Returns whether provided week days are contiguous.\n * @param days - list of days in a week\n * @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not\n * @param firstDayOfWeek - decides which day of week is the first one in the order.\n */\nexport const isContiguous = (days: DayOfWeek[], isSingleWeek: boolean, firstDayOfWeek: DayOfWeek): boolean => {\n const daySet = new Set(days);\n let amountOfNoNeighbors = 0;\n for (const day of days) {\n const nextDay = (day + 1) % 7;\n if (!(daySet.has(nextDay) && (!isSingleWeek || firstDayOfWeek !== nextDay))) {\n amountOfNoNeighbors++;\n }\n }\n\n // In case the full week is provided, then each day has a neighbor\n //, otherwise the last day does not have a neighbor.\n return amountOfNoNeighbors < 2;\n};\n"]}
@@ -0,0 +1,7 @@
import { IRestrictedDatesOptions } from './dateGrid.types';
/**
* Checks if `date` falls into the restricted `options`
* @param date - date to check
* @param options - restriction options (min date, max date and list of restricted dates)
*/
export declare const isRestrictedDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isRestrictedDate = void 0;
var dateMath_1 = require("../dateMath/dateMath");
var isBeforeMinDate_1 = require("./isBeforeMinDate");
var isAfterMaxDate_1 = require("./isAfterMaxDate");
/**
* Checks if `date` falls into the restricted `options`
* @param date - date to check
* @param options - restriction options (min date, max date and list of restricted dates)
*/
var isRestrictedDate = function (date, options) {
var restrictedDates = options.restrictedDates, minDate = options.minDate, maxDate = options.maxDate;
if (!restrictedDates && !minDate && !maxDate) {
return false;
}
var inRestrictedDates = restrictedDates && restrictedDates.some(function (rd) { return (0, dateMath_1.compareDates)(rd, date); });
return inRestrictedDates || (0, isBeforeMinDate_1.isBeforeMinDate)(date, options) || (0, isAfterMaxDate_1.isAfterMaxDate)(date, options);
};
exports.isRestrictedDate = isRestrictedDate;
//# sourceMappingURL=isRestrictedDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isRestrictedDate.js","sourceRoot":"../src/","sources":["dateGrid/isRestrictedDate.ts"],"names":[],"mappings":";;;AACA,iDAAoD;AACpD,qDAAoD;AACpD,mDAAkD;AAElD;;;;GAIG;AACI,IAAM,gBAAgB,GAAG,UAAC,IAAU,EAAE,OAAgC;IACnE,IAAA,eAAe,GAAuB,OAAO,gBAA9B,EAAE,OAAO,GAAc,OAAO,QAArB,EAAE,OAAO,GAAK,OAAO,QAAZ,CAAa;IACtD,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAM,iBAAiB,GAAG,eAAe,IAAI,eAAe,CAAC,IAAI,CAAC,UAAC,EAAQ,IAAK,OAAA,IAAA,uBAAY,EAAC,EAAE,EAAE,IAAI,CAAC,EAAtB,CAAsB,CAAC,CAAC;IACxG,OAAO,iBAAiB,IAAI,IAAA,iCAAe,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAA,+BAAc,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9F,CAAC,CAAC;AAPW,QAAA,gBAAgB,oBAO3B","sourcesContent":["import { IRestrictedDatesOptions } from './dateGrid.types';\nimport { compareDates } from '../dateMath/dateMath';\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\n/**\n * Checks if `date` falls into the restricted `options`\n * @param date - date to check\n * @param options - restriction options (min date, max date and list of restricted dates)\n */\nexport const isRestrictedDate = (date: Date, options: IRestrictedDatesOptions): boolean => {\n const { restrictedDates, minDate, maxDate } = options;\n if (!restrictedDates && !minDate && !maxDate) {\n return false;\n }\n const inRestrictedDates = restrictedDates && restrictedDates.some((rd: Date) => compareDates(rd, date));\n return inRestrictedDates || isBeforeMinDate(date, options) || isAfterMaxDate(date, options);\n};\n"]}