1 | import { useMulti } from "./selection/useMulti.js";
|
2 | import { useRange } from "./selection/useRange.js";
|
3 | import { useSingle } from "./selection/useSingle.js";
|
4 | import type { DateLib, DayPickerProps } from "./types/index.js";
|
5 | import { Selection } from "./types/selection.js";
|
6 |
|
7 | export 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 | }
|