MCPcopy
hub / github.com/flatpickr/flatpickr / getNextAvailableDay

Function getNextAvailableDay

src/index.ts:781–821  ·  view source on GitHub ↗
(current: DayElement, delta: number)

Source from the content-addressed store, hash-verified

779 }
780
781 function getNextAvailableDay(current: DayElement, delta: number) {
782 const givenMonth =
783 current.className.indexOf("Month") === -1
784 ? current.dateObj.getMonth()
785 : self.currentMonth;
786 const endMonth = delta > 0 ? self.config.showMonths : -1;
787 const loopDelta = delta > 0 ? 1 : -1;
788
789 for (
790 let m = givenMonth - self.currentMonth;
791 m != endMonth;
792 m += loopDelta
793 ) {
794 const month = (self.daysContainer as HTMLDivElement).children[m];
795 const startIndex =
796 givenMonth - self.currentMonth === m
797 ? current.$i + delta
798 : delta < 0
799 ? month.children.length - 1
800 : 0;
801 const numMonthDays = month.children.length;
802
803 for (
804 let i = startIndex;
805 i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1);
806 i += loopDelta
807 ) {
808 const c = month.children[i] as DayElement;
809 if (
810 c.className.indexOf("hidden") === -1 &&
811 isEnabled(c.dateObj) &&
812 Math.abs(current.$i - i) >= Math.abs(delta)
813 )
814 return focusOnDayElem(c);
815 }
816 }
817
818 self.changeMonth(loopDelta);
819 focusOnDay(getFirstAvailableDay(loopDelta), 0);
820 return undefined;
821 }
822
823 function focusOnDay(current: DayElement | undefined, offset: number) {
824 const activeElement = getClosestActiveElement();

Callers 1

focusOnDayFunction · 0.85

Calls 4

isEnabledFunction · 0.85
focusOnDayElemFunction · 0.85
focusOnDayFunction · 0.85
getFirstAvailableDayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…