1 | import React from "react";
|
2 |
|
3 | import type { CalendarDay } from "../classes/index.js";
|
4 | import type { Modifiers } from "../types/index.js";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | export function DayButton(
|
16 | props: {
|
17 |
|
18 | day: CalendarDay;
|
19 |
|
20 | modifiers: Modifiers;
|
21 | } & JSX.IntrinsicElements["button"]
|
22 | ) {
|
23 | const { day, modifiers, ...buttonProps } = props;
|
24 |
|
25 | const ref = React.useRef<HTMLButtonElement>(null);
|
26 | React.useEffect(() => {
|
27 | if (modifiers.focused) ref.current?.focus();
|
28 | }, [modifiers.focused]);
|
29 | return <button ref={ref} {...buttonProps} />;
|
30 | }
|
31 |
|
32 | export type DayButtonProps = Parameters<typeof DayButton>[0];
|