All files / src/components/DatePicker/utils getCalendarModes.ts

81.81% Statements 9/11
50% Branches 5/10
100% Functions 1/1
81.81% Lines 9/11

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            97x       97x 97x 97x 97x     97x 97x     97x       97x    
import type {CalendarLayout} from '../../CalendarView/hooks/types';
import type {FormatInfo} from '../../DateField/types';
 
type LayoutModes = Partial<Record<CalendarLayout, boolean>>;
 
export function getCalendarModes(formatInfo: FormatInfo): LayoutModes | undefined {
    Iif (!formatInfo.hasDate) {
        return undefined;
    }
 
    const modes: LayoutModes = {years: true};
    Eif (formatInfo.availableUnits.day) {
        modes.days = true;
        modes.months = true;
    }
 
    Eif (formatInfo.availableUnits.month) {
        modes.months = true;
    }
 
    Iif (formatInfo.availableUnits.quarter && !modes.months) {
        modes.quarters = true;
    }
 
    return modes;
}