Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mo.ui.date popover #3855

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions frontend/src/components/ui/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { cn } from "@/utils/cn";
import { FieldGroup, FieldError, Label } from "./field";
import { DateInput } from "./date-input";
import { Popover } from "./aria-popover";
import { useState } from "react";

const DatePickerContent = ({
className,
Expand Down Expand Up @@ -65,17 +66,25 @@ const DatePicker = <T extends AriaDateValue>({
className,
...props
}: DatePickerProps<T>) => {
const [open, setOpen] = useState(false);
return (
<AriaDatePicker
isOpen={open}
className={composeRenderProps(className, (className) =>
cn("group flex flex-col gap-2", className),
)}
onOpenChange={(open) => {
setOpen(open);
}}
{...props}
>
{label && <Label>{label}</Label>}
<FieldGroup>
<DateInput aria-label="date input" className="flex-1" variant="ghost" />
<AriaButton
onPressChange={() => {
setOpen(true);
}}
className={cn(
buttonVariants({ variant: "text", size: "icon" }),
"ml-1 size-6 data-[focus-visible]:ring-offset-0",
Expand Down Expand Up @@ -121,11 +130,16 @@ const DateRangePicker = <T extends AriaDateValue>({
className,
...props
}: DateRangePickerProps<T>) => {
const [open, setOpen] = useState(false);
return (
<AriaDateRangePicker
isOpen={open}
className={composeRenderProps(className, (className) =>
cn("group flex flex-col gap-2", className),
)}
onOpenChange={(open) => {
setOpen(open);
}}
{...props}
>
<Label>{label}</Label>
Expand All @@ -137,6 +151,9 @@ const DateRangePicker = <T extends AriaDateValue>({
<DateInput className="flex-1" variant="ghost" slot={"end"} />

<AriaButton
onPressChange={() => {
setOpen(true);
}}
className={cn(
buttonVariants({ variant: "text", size: "icon" }),
"ml-1 size-6 data-[focus-visible]:ring-offset-0",
Expand Down
Loading