Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 15x 44x 44x 44x | import { isSameDay, isWeekend, isWithinInterval } from "date-fns" import { isDisabled } from "./is-disabled" import { isEndDate } from "./is-end-date" import { isNextMonth } from "./is-next-month" import { isPrevMonth } from "./is-prev-month" import { isStartDate } from "./is-start-date" import { toRange } from "./to-range" /** * * @typedef {Object} Day * @prop {Date} date * @prop {Array} events * @prop {boolean} isToday * @prop {boolean} isWeekend * @prop {boolean} isPrevMonth * @prop {boolean} isNextMonth * @prop {boolean} isStartDate * @prop {boolean} isDisabled * @prop {boolean} isEndDate * @prop {boolean} isWithinSelection */ /** * * @param {Object} params * @prop {Date} date * @prop {Date} tempEnd * @prop {Date[]} events * @prop {Date} month * @prop {boolean} singlePicker * @prop {Date} tempStartDate * @prop {Date} today * @prop {Date} maxDate * @prop {Date} minDate * @prop {Date[]} disabledDates * * @returns {Day} */ export const getDayMetaData = params => { const { date, tempEndDate, events, month, singlePicker, tempStartDate, today, maxDate, minDate, disabledDates } = params // Sort the range asc for `isWithinInterval` function. const { start, end } = toRange(tempStartDate, tempEndDate) return { date, events, isToday: isSameDay(date, today), isWeekend: isWeekend(date), isPrevMonth: isPrevMonth(month, date), isNextMonth: isNextMonth(month, date), isStartDate: isStartDate(params), isDisabled: isDisabled({ date, maxDate, minDate, disabledDates }), // Used only in range mode isEndDate: isEndDate(params), isWithinSelection: !singlePicker ? isWithinInterval(date, { start, end }) : false } } |