diff --git a/packages/js/services/use-display-feedback.ts b/packages/js/services/use-display-feedback.ts index fe12387e..8ed65c0c 100644 --- a/packages/js/services/use-display-feedback.ts +++ b/packages/js/services/use-display-feedback.ts @@ -1,5 +1,8 @@ import { __ } from '@wpsocio/i18n'; -import { type Toast, useToast } from '@wpsocio/ui-components/ui/use-toast.js'; +import { + type Toast, + useToast, +} from '@wpsocio/ui-components/ui/hooks/use-toast.js'; import { FORM_ERROR } from '@wpsocio/utilities/constants.js'; import { getErrorStrings } from '@wpsocio/utilities/misc.js'; import type { AnyObject } from '@wpsocio/utilities/types.js'; diff --git a/packages/js/ui-components/components.json b/packages/js/ui-components/components.json index 9def1d6b..38283326 100644 --- a/packages/js/ui-components/components.json +++ b/packages/js/ui-components/components.json @@ -10,6 +10,8 @@ }, "aliases": { "components": "@", - "utils": "@/lib/utils.js" + "utils": "@/lib/utils.js", + "lib": "@/lib", + "hooks": "@/ui/hooks" } } diff --git a/packages/js/ui-components/tools/tailwind.config.js b/packages/js/ui-components/tools/tailwind.config.js index 3c363ad6..126b12cb 100644 --- a/packages/js/ui-components/tools/tailwind.config.js +++ b/packages/js/ui-components/tools/tailwind.config.js @@ -11,7 +11,7 @@ export default { ], theme: { container: { - center: true, + center: 'true', padding: '2rem', screens: { '2xl': '1400px', @@ -60,12 +60,20 @@ export default { }, keyframes: { 'accordion-down': { - from: { height: 0 }, - to: { height: 'var(--radix-accordion-content-height)' }, + from: { + height: '0', + }, + to: { + height: 'var(--radix-accordion-content-height)', + }, }, 'accordion-up': { - from: { height: 'var(--radix-accordion-content-height)' }, - to: { height: 0 }, + from: { + height: 'var(--radix-accordion-content-height)', + }, + to: { + height: '0', + }, }, }, animation: { diff --git a/packages/js/ui-components/ui/accordion.tsx b/packages/js/ui-components/ui/accordion.tsx index 5a2339e7..f0b17117 100644 --- a/packages/js/ui-components/ui/accordion.tsx +++ b/packages/js/ui-components/ui/accordion.tsx @@ -4,11 +4,6 @@ import { ChevronDown } from "lucide-react" import { cn } from "../lib/utils.js" -export type AccordionHeaderProps = { - beforeTrigger?: React.ReactNode - afterTrigger?: React.ReactNode -} - const Accordion = AccordionPrimitive.Root const AccordionItem = React.forwardRef< @@ -25,10 +20,9 @@ AccordionItem.displayName = "AccordionItem" const AccordionTrigger = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef & AccordionHeaderProps ->(({ className, children, beforeTrigger, afterTrigger, ...props }, ref) => ( - - {beforeTrigger} + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + - {afterTrigger} )) AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName @@ -51,12 +44,7 @@ const AccordionContent = React.forwardRef< >(({ className, children, ...props }, ref) => (
{children}
diff --git a/packages/js/ui-components/ui/button.tsx b/packages/js/ui-components/ui/button.tsx index a743bcdb..16fc5e3d 100644 --- a/packages/js/ui-components/ui/button.tsx +++ b/packages/js/ui-components/ui/button.tsx @@ -5,7 +5,7 @@ import { cva, type VariantProps } from "class-variance-authority" import { cn } from "../lib/utils.js" const buttonVariants = cva( - "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", + "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", { variants: { variant: { diff --git a/packages/js/ui-components/ui/card.tsx b/packages/js/ui-components/ui/card.tsx index 99e07464..0c581128 100644 --- a/packages/js/ui-components/ui/card.tsx +++ b/packages/js/ui-components/ui/card.tsx @@ -30,10 +30,10 @@ const CardHeader = React.forwardRef< CardHeader.displayName = "CardHeader" const CardTitle = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes + HTMLDivElement, + React.HTMLAttributes >(({ className, ...props }, ref) => ( -

+ HTMLDivElement, + React.HTMLAttributes >(({ className, ...props }, ref) => ( -

, - React.ComponentPropsWithoutRef & { - inset?: boolean - } ->(({ className, inset, children, ...props }, ref) => ( - - {children} - - -)) -DropdownMenuSubTrigger.displayName = - DropdownMenuPrimitive.SubTrigger.displayName - -const DropdownMenuSubContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -DropdownMenuSubContent.displayName = - DropdownMenuPrimitive.SubContent.displayName - -const DropdownMenuContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, sideOffset = 4, ...props }, ref) => ( - - - -)) -DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName - -const DropdownMenuItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean - } ->(({ className, inset, ...props }, ref) => ( - -)) -DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName - -const DropdownMenuCheckboxItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, checked, ...props }, ref) => ( - - - - - - - {children} - -)) -DropdownMenuCheckboxItem.displayName = - DropdownMenuPrimitive.CheckboxItem.displayName - -const DropdownMenuRadioItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( - - - - - - - {children} - -)) -DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName - -const DropdownMenuLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean - } ->(({ className, inset, ...props }, ref) => ( - -)) -DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName - -const DropdownMenuSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName - -const DropdownMenuShortcut = ({ - className, - ...props -}: React.HTMLAttributes) => { - return ( - - ) -} -DropdownMenuShortcut.displayName = "DropdownMenuShortcut" - -export { - DropdownMenu, - DropdownMenuTrigger, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuCheckboxItem, - DropdownMenuRadioItem, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuShortcut, - DropdownMenuGroup, - DropdownMenuPortal, - DropdownMenuSub, - DropdownMenuSubContent, - DropdownMenuSubTrigger, - DropdownMenuRadioGroup, -} diff --git a/packages/js/ui-components/ui/use-toast.ts b/packages/js/ui-components/ui/hooks/use-toast.ts similarity index 97% rename from packages/js/ui-components/ui/use-toast.ts rename to packages/js/ui-components/ui/hooks/use-toast.ts index b257be66..09f88cfe 100644 --- a/packages/js/ui-components/ui/use-toast.ts +++ b/packages/js/ui-components/ui/hooks/use-toast.ts @@ -4,7 +4,13 @@ import * as React from "react" import type { ToastActionElement, ToastProps, -} from "./toast.js" +} from "../toast.js" + +/** + * Customizations: + * - TOAST_LIMIT = 5 + * - status?: prop + */ const TOAST_LIMIT = 5 const TOAST_REMOVE_DELAY = 1000000 diff --git a/packages/js/ui-components/ui/input.tsx b/packages/js/ui-components/ui/input.tsx index 60bd4509..b36a6ef2 100644 --- a/packages/js/ui-components/ui/input.tsx +++ b/packages/js/ui-components/ui/input.tsx @@ -2,16 +2,13 @@ import * as React from "react" import { cn } from "../lib/utils.js" -export interface InputProps - extends React.InputHTMLAttributes {} - -const Input = React.forwardRef( +const Input = React.forwardRef>( ({ className, type, ...props }, ref) => { return ( , - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( - - - {children} - - - - -)) -ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName - -const ScrollBar = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, orientation = "vertical", ...props }, ref) => ( - - - -)) -ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName - -export { ScrollArea, ScrollBar } diff --git a/packages/js/ui-components/ui/select.tsx b/packages/js/ui-components/ui/select.tsx index f0bbfd65..a300e52c 100644 --- a/packages/js/ui-components/ui/select.tsx +++ b/packages/js/ui-components/ui/select.tsx @@ -4,6 +4,11 @@ import { Check, ChevronDown, ChevronUp } from "lucide-react" import { cn } from "../lib/utils.js" +/** + * Customizations: + * - portalContainer + */ + const Select = SelectPrimitive.Root const SelectGroup = SelectPrimitive.Group diff --git a/packages/js/ui-components/ui/sheet.tsx b/packages/js/ui-components/ui/sheet.tsx deleted file mode 100644 index 62eeb198..00000000 --- a/packages/js/ui-components/ui/sheet.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import * as React from "react" -import * as SheetPrimitive from "@radix-ui/react-dialog" -import { cva, type VariantProps } from "class-variance-authority" -import { X } from "lucide-react" - -import { cn } from "../lib/utils.js" - -const Sheet = SheetPrimitive.Root - -const SheetTrigger = SheetPrimitive.Trigger - -const SheetClose = SheetPrimitive.Close - -const SheetPortal = SheetPrimitive.Portal - -const SheetOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -SheetOverlay.displayName = SheetPrimitive.Overlay.displayName - -const sheetVariants = cva( - "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", - { - variants: { - side: { - top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", - bottom: - "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom", - left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", - right: - "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", - }, - }, - defaultVariants: { - side: "right", - }, - } -) - -interface SheetContentProps - extends React.ComponentPropsWithoutRef, - VariantProps {} - -const SheetContent = React.forwardRef< - React.ElementRef, - SheetContentProps ->(({ side = "right", className, children, ...props }, ref) => ( - - - - {children} - - - Close - - - -)) -SheetContent.displayName = SheetPrimitive.Content.displayName - -const SheetHeader = ({ - className, - ...props -}: React.HTMLAttributes) => ( -

-) -SheetHeader.displayName = "SheetHeader" - -const SheetFooter = ({ - className, - ...props -}: React.HTMLAttributes) => ( -
-) -SheetFooter.displayName = "SheetFooter" - -const SheetTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -SheetTitle.displayName = SheetPrimitive.Title.displayName - -const SheetDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -SheetDescription.displayName = SheetPrimitive.Description.displayName - -export { - Sheet, - SheetPortal, - SheetOverlay, - SheetTrigger, - SheetClose, - SheetContent, - SheetHeader, - SheetFooter, - SheetTitle, - SheetDescription, -} diff --git a/packages/js/ui-components/ui/table.tsx b/packages/js/ui-components/ui/table.tsx deleted file mode 100644 index 2f67de98..00000000 --- a/packages/js/ui-components/ui/table.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import * as React from "react" - -import { cn } from "../lib/utils.js" - -const Table = React.forwardRef< - HTMLTableElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
- - -)) -Table.displayName = "Table" - -const TableHeader = React.forwardRef< - HTMLTableSectionElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( - -)) -TableHeader.displayName = "TableHeader" - -const TableBody = React.forwardRef< - HTMLTableSectionElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( - -)) -TableBody.displayName = "TableBody" - -const TableFooter = React.forwardRef< - HTMLTableSectionElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( - tr]:last:border-b-0", - className - )} - {...props} - /> -)) -TableFooter.displayName = "TableFooter" - -const TableRow = React.forwardRef< - HTMLTableRowElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( - -)) -TableRow.displayName = "TableRow" - -const TableHead = React.forwardRef< - HTMLTableCellElement, - React.ThHTMLAttributes ->(({ className, ...props }, ref) => ( -
-)) -TableHead.displayName = "TableHead" - -const TableCell = React.forwardRef< - HTMLTableCellElement, - React.TdHTMLAttributes ->(({ className, ...props }, ref) => ( - -)) -TableCell.displayName = "TableCell" - -const TableCaption = React.forwardRef< - HTMLTableCaptionElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)) -TableCaption.displayName = "TableCaption" - -export { - Table, - TableHeader, - TableBody, - TableFooter, - TableHead, - TableRow, - TableCell, - TableCaption, -} diff --git a/packages/js/ui-components/ui/textarea.tsx b/packages/js/ui-components/ui/textarea.tsx index f56a9f28..9c33b7d3 100644 --- a/packages/js/ui-components/ui/textarea.tsx +++ b/packages/js/ui-components/ui/textarea.tsx @@ -2,23 +2,21 @@ import * as React from "react" import { cn } from "../lib/utils.js" -export interface TextareaProps - extends React.TextareaHTMLAttributes {} - -const Textarea = React.forwardRef( - ({ className, ...props }, ref) => { - return ( -