Files
upstream-shadcn-ui/apps/v4/registry/new-york-v4/examples/dropdown-menu-dialog.tsx
upstream-mirror 1416db152c
All checks were successful
Release / Create Version PR or Publish Stable Release (push) Has been skipped
Release / Publish Prerelease to NPM (push) Has been skipped
Monitor Registries / Monitor registry health (push) Has been skipped
snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:44:43 +05:00

116 lines
3.8 KiB
TypeScript

"use client"
import { useState } from "react"
import { MoreHorizontalIcon } from "lucide-react"
import { Button } from "@/registry/new-york-v4/ui/button"
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/registry/new-york-v4/ui/dialog"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuTrigger,
} from "@/registry/new-york-v4/ui/dropdown-menu"
import { Field, FieldGroup, FieldLabel } from "@/registry/new-york-v4/ui/field"
import { Input } from "@/registry/new-york-v4/ui/input"
import { Label } from "@/registry/new-york-v4/ui/label"
import { Textarea } from "@/registry/new-york-v4/ui/textarea"
export default function DropdownMenuDialog() {
const [showNewDialog, setShowNewDialog] = useState(false)
const [showShareDialog, setShowShareDialog] = useState(false)
return (
<>
<DropdownMenu modal={false}>
<DropdownMenuTrigger asChild>
<Button variant="outline" aria-label="Open menu" size="icon-sm">
<MoreHorizontalIcon />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-40" align="end">
<DropdownMenuLabel>File Actions</DropdownMenuLabel>
<DropdownMenuGroup>
<DropdownMenuItem onSelect={() => setShowNewDialog(true)}>
New File...
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => setShowShareDialog(true)}>
Share...
</DropdownMenuItem>
<DropdownMenuItem disabled>Download</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
<Dialog open={showNewDialog} onOpenChange={setShowNewDialog}>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Create New File</DialogTitle>
<DialogDescription>
Provide a name for your new file. Click create when you&apos;re
done.
</DialogDescription>
</DialogHeader>
<FieldGroup className="pb-3">
<Field>
<FieldLabel htmlFor="filename">File Name</FieldLabel>
<Input id="filename" name="filename" placeholder="document.txt" />
</Field>
</FieldGroup>
<DialogFooter>
<DialogClose asChild>
<Button variant="outline">Cancel</Button>
</DialogClose>
<Button type="submit">Create</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<Dialog open={showShareDialog} onOpenChange={setShowShareDialog}>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Share File</DialogTitle>
<DialogDescription>
Anyone with the link will be able to view this file.
</DialogDescription>
</DialogHeader>
<FieldGroup className="py-3">
<Field>
<Label htmlFor="email">Email Address</Label>
<Input
id="email"
name="email"
type="email"
placeholder="shadcn@vercel.com"
autoComplete="off"
/>
</Field>
<Field>
<FieldLabel htmlFor="message">Message (Optional)</FieldLabel>
<Textarea
id="message"
name="message"
placeholder="Check out this file"
/>
</Field>
</FieldGroup>
<DialogFooter>
<DialogClose asChild>
<Button variant="outline">Cancel</Button>
</DialogClose>
<Button type="submit">Send Invite</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
)
}