UNPKG

706 BPlain TextView Raw
1import { useMulti } from "./selection/useMulti.js";
2import { useRange } from "./selection/useRange.js";
3import { useSingle } from "./selection/useSingle.js";
4import type { DateLib, DayPickerProps } from "./types/index.js";
5import { Selection } from "./types/selection.js";
6
7export function useSelection<T extends DayPickerProps>(
8 props: T,
9 dateLib: DateLib
10): Selection<T> | undefined {
11 const single = useSingle(props, dateLib);
12 const multi = useMulti(props, dateLib);
13 const range = useRange(props, dateLib);
14
15 switch (props.mode) {
16 case "single":
17 return single;
18 case "multiple":
19 return multi;
20 case "range":
21 return range;
22 default:
23 return undefined;
24 }
25}