Home / Function/ DataPickerWithDropdowns() — ui Function Reference

DataPickerWithDropdowns() — ui Function Reference

Architecture documentation for the DataPickerWithDropdowns() function in date-picker-demo.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  fc7d97a6_ff39_d56d_5061_c3aaab83d86c["DataPickerWithDropdowns()"]
  c8a1c243_9ab4_c534_0c61_9dd60705e506["date-picker-demo.tsx"]
  fc7d97a6_ff39_d56d_5061_c3aaab83d86c -->|defined in| c8a1c243_9ab4_c534_0c61_9dd60705e506
  style fc7d97a6_ff39_d56d_5061_c3aaab83d86c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/app/(internal)/sink/components/date-picker-demo.tsx lines 105–179

function DataPickerWithDropdowns() {
  const [date, setDate] = React.useState<Date>()
  const [open, setOpen] = React.useState(false)
  const isMobile = useIsMobile(450)

  if (isMobile) {
    return (
      <Drawer open={open} onOpenChange={setOpen}>
        <DrawerTrigger asChild>
          <Button
            variant="outline"
            className={cn(
              "min-w-[200px] justify-start px-2 font-normal",
              !date && "text-muted-foreground"
            )}
          >
            {date ? format(date, "PPP") : <span>Pick a date</span>}
            <CalendarIcon className="text-muted-foreground ml-auto" />
          </Button>
        </DrawerTrigger>
        <DrawerContent>
          <DrawerHeader className="sr-only">
            <DrawerTitle>Select a date</DrawerTitle>
            <DrawerDescription>
              Pick a date for your appointment.
            </DrawerDescription>
          </DrawerHeader>
          <Calendar
            mode="single"
            selected={date}
            onSelect={(day) => {
              setDate(day)
              setOpen(false)
            }}
          />
        </DrawerContent>
      </Drawer>
    )
  }

  return (
    <Popover open={open} onOpenChange={setOpen}>
      <PopoverTrigger asChild>
        <Button
          variant="outline"
          className={cn(
            "min-w-[200px] justify-start px-2 font-normal",
            !date && "text-muted-foreground"
          )}
        >
          {date ? format(date, "PPP") : <span>Pick a date</span>}
          <CalendarIcon className="text-muted-foreground ml-auto" />
        </Button>
      </PopoverTrigger>
      <PopoverContent className="w-auto p-0" align="start">
        <Calendar
          mode="single"
          selected={date}
          onSelect={setDate}
          captionLayout="dropdown"
        />
        <div className="flex gap-2 border-t p-2">
          <Button
            variant="outline"
            size="sm"
            className="w-full"
            onClick={() => setOpen(false)}
          >
            Done
          </Button>
        </div>
      </PopoverContent>
    </Popover>
  )
}

Subdomains

Frequently Asked Questions

What does DataPickerWithDropdowns() do?
DataPickerWithDropdowns() is a function in the ui codebase, defined in apps/v4/app/(internal)/sink/components/date-picker-demo.tsx.
Where is DataPickerWithDropdowns() defined?
DataPickerWithDropdowns() is defined in apps/v4/app/(internal)/sink/components/date-picker-demo.tsx at line 105.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free