|
1 | 1 | import { clsx } from "clsx"; |
2 | | -import { differenceInDays } from "date-fns"; |
3 | 2 | import React, { Component, createRef } from "react"; |
4 | 3 |
|
5 | 4 | import CalendarContainer from "./calendar_container"; |
@@ -41,9 +40,7 @@ import { |
41 | 40 | DEFAULT_YEAR_ITEM_NUMBER, |
42 | 41 | getMonthInLocale, |
43 | 42 | type Locale, |
44 | | - getStartOfMonth, |
45 | | - getEndOfMonth, |
46 | | - isDayDisabled, |
| 43 | + getEnabledDateInMonth, |
47 | 44 | } from "./date_utils"; |
48 | 45 | import InputTime from "./input_time"; |
49 | 46 | import Month from "./month"; |
@@ -413,29 +410,8 @@ export default class Calendar extends Component<CalendarProps, CalendarState> { |
413 | 410 | this.props.setPreSelection && this.props.setPreSelection(date); |
414 | 411 | }; |
415 | 412 |
|
416 | | - getEnabledPreSelectionDateForMonth = (date: Date) => { |
417 | | - if (!isDayDisabled(date, this.props)) { |
418 | | - return date; |
419 | | - } |
420 | | - |
421 | | - const startOfMonth = getStartOfMonth(date); |
422 | | - const endOfMonth = getEndOfMonth(date); |
423 | | - |
424 | | - const totalDays = differenceInDays(endOfMonth, startOfMonth); |
425 | | - |
426 | | - let preSelectedDate = null; |
427 | | - |
428 | | - for (let dayIdx = 0; dayIdx <= totalDays; dayIdx++) { |
429 | | - const processingDate = addDays(startOfMonth, dayIdx); |
430 | | - |
431 | | - if (!isDayDisabled(processingDate, this.props)) { |
432 | | - preSelectedDate = processingDate; |
433 | | - break; |
434 | | - } |
435 | | - } |
436 | | - |
437 | | - return preSelectedDate; |
438 | | - }; |
| 413 | + getEnabledPreSelectionDateForMonth = (date: Date) => |
| 414 | + getEnabledDateInMonth(date, this.props); |
439 | 415 |
|
440 | 416 | handleMonthChange = (date: Date): void => { |
441 | 417 | const enabledPreSelectionDate = |
|
0 commit comments