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,2 @@
export {};
//# 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,28 @@
import { __rest } from "tslib";
import { isRestrictedDate } from './isRestrictedDate';
import { isAfterMaxDate } from './isAfterMaxDate';
import { isBeforeMinDate } from './isBeforeMinDate';
import { compareDatePart, addDays } from '../dateMath/dateMath';
/**
* Returns closest available date given the restriction `options`, or undefined otherwise
* @param options - list of search options
*/
export var findAvailableDate = function (options) {
var targetDate = options.targetDate, initialDate = options.initialDate, direction = options.direction, restrictedDateOptions = __rest(options, ["targetDate", "initialDate", "direction"]);
var availableDate = targetDate;
// if the target date is available, return it immediately
if (!isRestrictedDate(targetDate, restrictedDateOptions)) {
return targetDate;
}
while (compareDatePart(initialDate, availableDate) !== 0 &&
isRestrictedDate(availableDate, restrictedDateOptions) &&
!isAfterMaxDate(availableDate, restrictedDateOptions) &&
!isBeforeMinDate(availableDate, restrictedDateOptions)) {
availableDate = addDays(availableDate, direction);
}
if (compareDatePart(initialDate, availableDate) !== 0 && !isRestrictedDate(availableDate, restrictedDateOptions)) {
return availableDate;
}
return undefined;
};
//# sourceMappingURL=findAvailableDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"findAvailableDate.js","sourceRoot":"../src/","sources":["dateGrid/findAvailableDate.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAC,OAA8B;IACtD,IAAA,UAAU,GAAuD,OAAO,WAA9D,EAAE,WAAW,GAA0C,OAAO,YAAjD,EAAE,SAAS,GAA+B,OAAO,UAAtC,EAAK,qBAAqB,UAAK,OAAO,EAA1E,0CAAgE,CAAF,CAAa;IACjF,IAAI,aAAa,GAAG,UAAU,CAAC;IAC/B,yDAAyD;IACzD,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACzD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OACE,eAAe,CAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC;QACjD,gBAAgB,CAAC,aAAa,EAAE,qBAAqB,CAAC;QACtD,CAAC,cAAc,CAAC,aAAa,EAAE,qBAAqB,CAAC;QACrD,CAAC,eAAe,CAAC,aAAa,EAAE,qBAAqB,CAAC,EACtD,CAAC;QACD,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,eAAe,CAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACjH,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","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,19 @@
import { __spreadArray } from "tslib";
import { compareDatePart } from '../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
*/
export var getBoundedDateRange = function (dateRange, minDate, maxDate) {
var boundedDateRange = __spreadArray([], dateRange, true);
if (minDate) {
boundedDateRange = boundedDateRange.filter(function (date) { return compareDatePart(date, minDate) >= 0; });
}
if (maxDate) {
boundedDateRange = boundedDateRange.filter(function (date) { return compareDatePart(date, maxDate) <= 0; });
}
return boundedDateRange;
};
//# sourceMappingURL=getBoundedDateRange.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getBoundedDateRange.js","sourceRoot":"../src/","sources":["dateGrid/getBoundedDateRange.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAC,SAAiB,EAAE,OAAc,EAAE,OAAc;IACnF,IAAI,gBAAgB,qBAAO,SAAS,OAAC,CAAC;IACtC,IAAI,OAAO,EAAE,CAAC;QACZ,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAC,IAAU,IAAK,OAAA,eAAe,CAAC,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,eAAe,CAAC,IAAI,EAAE,OAAe,CAAC,IAAI,CAAC,EAA3C,CAA2C,CAAC,CAAC;IAC1G,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC","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,18 @@
import { DateRangeType } from '../dateValues/dateValues';
import { isContiguous } from './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
*/
export var getDateRangeTypeToUse = function (dateRangeType, workWeekDays, firstDayOfWeek) {
if (workWeekDays && dateRangeType === DateRangeType.WorkWeek) {
if (!isContiguous(workWeekDays, true, firstDayOfWeek) || workWeekDays.length === 0) {
return DateRangeType.Week;
}
}
return dateRangeType;
};
//# sourceMappingURL=getDateRangeTypeToUse.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getDateRangeTypeToUse.js","sourceRoot":"../src/","sources":["dateGrid/getDateRangeTypeToUse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C;;;;;;GAMG;AACH,MAAM,CAAC,IAAM,qBAAqB,GAAG,UACnC,aAA4B,EAC5B,YAAqC,EACrC,cAAyB;IAEzB,IAAI,YAAY,IAAI,aAAa,KAAK,aAAa,CAAC,QAAQ,EAAE,CAAC;QAC7D,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnF,OAAO,aAAa,CAAC,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","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[][];
+73
View File
@@ -0,0 +1,73 @@
import { addDays, compareDates, getDateRangeArray, isInDateRangeArray } from '../dateMath/dateMath';
import { DAYS_IN_WEEK } from '../dateValues/dateValues';
import { getDateRangeTypeToUse } from './getDateRangeTypeToUse';
import { getBoundedDateRange } from './getBoundedDateRange';
import { isRestrictedDate } from './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
*/
export 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 = addDays(date, -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 = getDateRangeTypeToUse(dateRangeType, workWeekDays, firstDayOfWeek);
var selectedDates = [];
if (selectedDate) {
selectedDates = getDateRangeArray(selectedDate, selectedDateRangeType, firstDayOfWeek, workWeekDays, daysToSelectInDayView);
selectedDates = 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: compareDates(todaysDate, date),
isSelected: isInDateRangeArray(date, selectedDates),
isInBounds: !isRestrictedDate(date, restrictedDateOptions),
isMarked: (markedDays === null || markedDays === void 0 ? void 0 : markedDays.some(function (markedDay) { return compareDates(originalDate, markedDay); })) || false,
};
week.push(dayInfo);
if (dayInfo.isInMonth) {
isAllDaysOfWeekOutOfMonth = false;
}
date.setDate(date.getDate() + 1);
};
for (var dayIndex = 0; dayIndex < 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;
};
//# sourceMappingURL=getDayGrid.js.map
File diff suppressed because one or more lines are too long
+9
View File
@@ -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';
+10
View File
@@ -0,0 +1,10 @@
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';
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["dateGrid/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC","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,11 @@
import { compareDatePart } from '../dateMath/dateMath';
/**
* Checks if `date` happens later than max date
* @param date - date to check
* @param options - object with max date to check against
*/
export var isAfterMaxDate = function (date, options) {
var maxDate = options.maxDate;
return maxDate ? compareDatePart(date, maxDate) >= 1 : false;
};
//# sourceMappingURL=isAfterMaxDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isAfterMaxDate.js","sourceRoot":"../src/","sources":["dateGrid/isAfterMaxDate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,IAAM,cAAc,GAAG,UAAC,IAAU,EAAE,OAAgC;IACjE,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;IAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/D,CAAC,CAAC","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,11 @@
import { compareDatePart } from '../dateMath/dateMath';
/**
* Checks if `date` happens earlier than min date
* @param date - date to check
* @param options - object with min date to check against
*/
export var isBeforeMinDate = function (date, options) {
var minDate = options.minDate;
return minDate ? compareDatePart(minDate, date) >= 1 : false;
};
//# sourceMappingURL=isBeforeMinDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isBeforeMinDate.js","sourceRoot":"../src/","sources":["dateGrid/isBeforeMinDate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG,UAAC,IAAU,EAAE,OAAgC;IAClE,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;IAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/D,CAAC,CAAC","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,21 @@
/**
* 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 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;
};
//# sourceMappingURL=isContiguous.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isContiguous.js","sourceRoot":"../src/","sources":["dateGrid/isContiguous.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,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","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,17 @@
import { compareDates } from '../dateMath/dateMath';
import { isBeforeMinDate } from './isBeforeMinDate';
import { isAfterMaxDate } from './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)
*/
export 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 compareDates(rd, date); });
return inRestrictedDates || isBeforeMinDate(date, options) || isAfterMaxDate(date, options);
};
//# sourceMappingURL=isRestrictedDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isRestrictedDate.js","sourceRoot":"../src/","sources":["dateGrid/isRestrictedDate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,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,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,EAAtB,CAAsB,CAAC,CAAC;IACxG,OAAO,iBAAiB,IAAI,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9F,CAAC,CAAC","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"]}