|
1
|
"use client" |
|
2
|
|
|
3
|
import { clx } from "@/utils/clx" |
|
4
|
import * as React from "react" |
|
5
|
import { AriaButtonProps, useButton } from "react-aria" |
|
6
|
|
|
7
|
interface CalendarButtonProps extends AriaButtonProps<"button"> { |
|
8
|
size?: "base" | "small" |
|
9
|
} |
|
10
|
|
|
11
|
const DatePickerButton = React.forwardRef< |
|
12
|
HTMLButtonElement, |
|
13
|
CalendarButtonProps |
|
14
|
>(({ children, size = "base", ...props }, ref) => { |
|
15
|
const innerRef = React.useRef<HTMLButtonElement>(null) |
|
16
|
React.useImperativeHandle(ref, () => innerRef.current as HTMLButtonElement) |
|
17
|
|
|
18
|
const { buttonProps } = useButton(props, innerRef) |
|
19
|
|
|
20
|
return ( |
|
21
|
<button |
|
22
|
type="button" |
|
23
|
className={clx( |
|
24
|
"text-ui-fg-muted transition-fg flex items-center justify-center border-r outline-none", |
|
25
|
"disabled:text-ui-fg-disabled", |
|
26
|
"hover:bg-ui-button-transparent-hover", |
|
27
|
"focus-visible:bg-ui-bg-interactive focus-visible:text-ui-fg-on-color", |
|
28
|
{ |
|
29
|
"size-7": size === "small", |
|
30
|
"size-8": size === "base", |
|
31
|
} |
|
32
|
)} |
|
33
|
aria-label="Open calendar" |
|
34
|
{...buttonProps} |
|
35
|
> |
|
36
|
{children} |
|
37
|
</button> |
|
38
|
) |
|
39
|
}) |
|
40
|
DatePickerButton.displayName = "DatePickerButton" |
|
41
|
|
|
42
|
export { DatePickerButton } |