diff --git a/packages/plasma-new-hope/src/components/Calendar/hooks/useDays.ts b/packages/plasma-new-hope/src/components/Calendar/hooks/useDays.ts index f9a407b2f1..81f131a78a 100644 --- a/packages/plasma-new-hope/src/components/Calendar/hooks/useDays.ts +++ b/packages/plasma-new-hope/src/components/Calendar/hooks/useDays.ts @@ -8,7 +8,7 @@ import { getOffsetDayInWeek, getPrevDate, IsCurrentDay, - isDayInRage, + isDayInRange, isSelectedDay, } from '../utils'; import type { CalendarValueType, DateItem, DateObject, DisabledDay, EventDay } from '../Calendar.types'; @@ -25,7 +25,7 @@ const getDaysInPrevMonth = (date: DateObject, offsetDayInWeek: number, value: Ca isSelected: false, isDayInCurrentMonth: false, inRange: Array.isArray(value) - ? isDayInRage(prevYear, prevMonth, daysInPrevMonth - (offsetDayInWeek - i) + 1, value) + ? isDayInRange(prevYear, prevMonth, daysInPrevMonth - (offsetDayInWeek - i) + 1, value) : false, date: { day: daysInPrevMonth - (offsetDayInWeek - i) + 1, @@ -45,7 +45,7 @@ const getDaysInCurrentMonth = (date: DateObject, daysInMonth: number, value: Cal ? Boolean(value.find((v) => isSelectedDay(date, i + 1, v))) : isSelectedDay(date, i + 1, value), isDayInCurrentMonth: true, - inRange: Array.isArray(value) ? isDayInRage(date.year, date.monthIndex, i + 1, value) : false, + inRange: Array.isArray(value) ? isDayInRange(date.year, date.monthIndex, i + 1, value) : false, date: { day: i + 1, monthIndex: date.monthIndex, @@ -71,7 +71,7 @@ const getDaysInNextMonth = ( isCurrent: false, isSelected: false, isDayInCurrentMonth: false, - inRange: Array.isArray(value) ? isDayInRage(nextYear, nextMonthIndex, i + 1, value) : false, + inRange: Array.isArray(value) ? isDayInRange(nextYear, nextMonthIndex, i + 1, value) : false, date: { day: i + 1, monthIndex: nextMonthIndex, diff --git a/packages/plasma-new-hope/src/components/Calendar/utils/index.ts b/packages/plasma-new-hope/src/components/Calendar/utils/index.ts index 7a70b4ceaa..83f4764262 100644 --- a/packages/plasma-new-hope/src/components/Calendar/utils/index.ts +++ b/packages/plasma-new-hope/src/components/Calendar/utils/index.ts @@ -103,7 +103,7 @@ export const getSortedValues = (values: [Date | undefined, (Date | undefined)?]) return start.getTime() - end.getTime(); }); -export const isDayInRage = ( +export const isDayInRange = ( year: number, monthIndex: number, currentDay: number, @@ -111,12 +111,12 @@ export const isDayInRage = ( ) => { const [startValue, endValue] = getSortedValues(values); - if (!endValue) { + if (!endValue || !startValue) { return false; } const day = new Date(year, monthIndex, currentDay); - return startValue && startValue <= day && day <= endValue; + return startValue < day && day <= endValue; }; export const isSameDay = (firstDate: DateObject, secondDate?: DateObject) => @@ -243,10 +243,6 @@ export const canSelectDate = ( const hoverDate = new Date(year, monthIndex, day); const [startDate] = value; - if (hoverDate?.getTime() === startDate?.getTime()) { - return false; - } - if (!disabledList?.length) { return true; }