From 2119fd2293263f69f030a72b3b3544c55ee115c3 Mon Sep 17 00:00:00 2001 From: marszayn Date: Mon, 10 Mar 2025 14:08:20 +0700 Subject: [PATCH] feat: Menambahkan komponen date picker, pagination, dan dialog --- resources/js/components/ui/command.tsx | 151 +++++++++++++++++++++ resources/js/components/ui/date-picker.tsx | 43 ++++++ resources/js/components/ui/dialog.tsx | 2 + resources/js/components/ui/pagination.tsx | 117 ++++++++++++++++ 4 files changed, 313 insertions(+) create mode 100644 resources/js/components/ui/command.tsx create mode 100644 resources/js/components/ui/date-picker.tsx create mode 100644 resources/js/components/ui/pagination.tsx diff --git a/resources/js/components/ui/command.tsx b/resources/js/components/ui/command.tsx new file mode 100644 index 0000000..0db642a --- /dev/null +++ b/resources/js/components/ui/command.tsx @@ -0,0 +1,151 @@ +import * as React from "react" +import { type DialogProps } from "@radix-ui/react-dialog" +import { Command as CommandPrimitive } from "cmdk" +import { Search } from "lucide-react" + +import { cn } from "@/lib/utils" +import { Dialog, DialogContent } from "@/components/ui/dialog" + +const Command = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +Command.displayName = CommandPrimitive.displayName + +const CommandDialog = ({ children, ...props }: DialogProps) => { + return ( + + + + {children} + + + + ) +} + +const CommandInput = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( +
+ + +
+)) + +CommandInput.displayName = CommandPrimitive.Input.displayName + +const CommandList = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandList.displayName = CommandPrimitive.List.displayName + +const CommandEmpty = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>((props, ref) => ( + +)) + +CommandEmpty.displayName = CommandPrimitive.Empty.displayName + +const CommandGroup = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandGroup.displayName = CommandPrimitive.Group.displayName + +const CommandSeparator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +CommandSeparator.displayName = CommandPrimitive.Separator.displayName + +const CommandItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandItem.displayName = CommandPrimitive.Item.displayName + +const CommandShortcut = ({ + className, + ...props +}: React.HTMLAttributes) => { + return ( + + ) +} +CommandShortcut.displayName = "CommandShortcut" + +export { + Command, + CommandDialog, + CommandInput, + CommandList, + CommandEmpty, + CommandGroup, + CommandItem, + CommandShortcut, + CommandSeparator, +} diff --git a/resources/js/components/ui/date-picker.tsx b/resources/js/components/ui/date-picker.tsx new file mode 100644 index 0000000..0d54a9e --- /dev/null +++ b/resources/js/components/ui/date-picker.tsx @@ -0,0 +1,43 @@ +"use client"; + +import * as React from "react"; +import { format } from "date-fns"; +import { CalendarIcon } from "lucide-react"; + +import { cn } from "@/lib/utils"; +import { Button } from "@/components/ui/button"; +import { Calendar } from "@/components/ui/calendar"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; + +export function DatePickerDemo() { + const [date, setDate] = React.useState(); + + return ( + + + + + + + + + ); +} diff --git a/resources/js/components/ui/dialog.tsx b/resources/js/components/ui/dialog.tsx index 9dbeaa0..1647513 100644 --- a/resources/js/components/ui/dialog.tsx +++ b/resources/js/components/ui/dialog.tsx @@ -1,3 +1,5 @@ +"use client" + import * as React from "react" import * as DialogPrimitive from "@radix-ui/react-dialog" import { X } from "lucide-react" diff --git a/resources/js/components/ui/pagination.tsx b/resources/js/components/ui/pagination.tsx new file mode 100644 index 0000000..7ac0b53 --- /dev/null +++ b/resources/js/components/ui/pagination.tsx @@ -0,0 +1,117 @@ +import * as React from "react"; +import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react"; + +import { cn } from "@/lib/utils"; +import { ButtonProps, buttonVariants } from "@/components/ui/button"; + +const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => ( +