From 50115307d540a23380f0d9830e27546ae74b1fd7 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Fri, 14 Jul 2023 22:59:19 +0200 Subject: [PATCH] fix: broken ts and shadcdn paths --- components.json | 4 +- src/app/inventory/page.tsx | 2 +- src/app/page.tsx | 2 +- src/components/ui/button.tsx | 51 ++++++++++++--------- src/components/ui/card.tsx | 2 +- src/components/ui/command.tsx | 6 +-- src/components/ui/dialog.tsx | 2 +- src/components/ui/dropdown-menu.tsx | 2 +- src/components/ui/form.tsx | 71 ++++++++++++++++------------- src/components/ui/input.tsx | 4 +- src/components/ui/label.tsx | 21 +++++---- src/components/ui/popover.tsx | 2 +- src/components/ui/select.tsx | 6 +-- src/components/ui/separator.tsx | 39 +++++++++------- src/components/ui/textarea.tsx | 4 +- src/components/ui/toast.tsx | 2 +- src/components/ui/toaster.tsx | 4 +- tsconfig.json | 6 +-- 18 files changed, 127 insertions(+), 103 deletions(-) diff --git a/components.json b/components.json index 437bcf6..0c081fb 100644 --- a/components.json +++ b/components.json @@ -10,7 +10,7 @@ "cssVariables": true }, "aliases": { - "components": "src/components", - "utils": "src/lib/utils" + "components": "@/components", + "utils": "@/lib/utils" } } diff --git a/src/app/inventory/page.tsx b/src/app/inventory/page.tsx index 352aefe..f9f7538 100644 --- a/src/app/inventory/page.tsx +++ b/src/app/inventory/page.tsx @@ -27,7 +27,7 @@ import { } from '@/components/ui/command' import { CaretSortIcon } from '@radix-ui/react-icons' import { cn } from '@/lib/utils' -import { Textarea } from '@spejstore-ui/components/ui/textarea' +import { Textarea } from '@/components/ui/textarea' function NavLink({ href, children }: { href: string; children: React.ReactNode }) { return ( diff --git a/src/app/page.tsx b/src/app/page.tsx index c6bd689..1fb0ff8 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,4 +1,4 @@ -import { ModeToggle } from '@spejstore-ui/components/ModeToggle' +import { ModeToggle } from '@//components/ModeToggle' import Link from 'next/link' import Image from 'next/image' diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 7b5f6b2..d791d9d 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -1,34 +1,37 @@ -import * as React from 'react' -import { Slot } from '@radix-ui/react-slot' -import { cva, type VariantProps } from 'class-variance-authority' +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" -import { cn } from 'src/lib/utils' +import { cn } from "@/lib/utils" const buttonVariants = cva( - 'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50', + "inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", { variants: { variant: { - default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90', - destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90', + default: + "bg-primary text-primary-foreground shadow hover:bg-primary/90", + destructive: + "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", outline: - 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground', - secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80', - ghost: 'hover:bg-accent hover:text-accent-foreground', - link: 'text-primary underline-offset-4 hover:underline', + "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", + secondary: + "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", + ghost: "hover:bg-accent hover:text-accent-foreground", + link: "text-primary underline-offset-4 hover:underline", }, size: { - default: 'h-9 px-4 py-2', - sm: 'h-8 rounded-md px-3 text-xs', - lg: 'h-10 rounded-md px-8', - icon: 'h-9 w-9', + default: "h-9 px-4 py-2", + sm: "h-8 rounded-md px-3 text-xs", + lg: "h-10 rounded-md px-8", + icon: "h-9 w-9", }, }, defaultVariants: { - variant: 'default', - size: 'default', + variant: "default", + size: "default", }, - }, + } ) export interface ButtonProps @@ -39,12 +42,16 @@ export interface ButtonProps const Button = React.forwardRef( ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : 'button' + const Comp = asChild ? Slot : "button" return ( - + ) - }, + } ) -Button.displayName = 'Button' +Button.displayName = "Button" export { Button, buttonVariants } diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx index 24d0451..520e68d 100644 --- a/src/components/ui/card.tsx +++ b/src/components/ui/card.tsx @@ -1,6 +1,6 @@ +import { cn } from '@/lib/utils' import * as React from 'react' -import { cn } from 'src/lib/utils' const Card = React.forwardRef>( ({ className, ...props }, ref) => ( diff --git a/src/components/ui/command.tsx b/src/components/ui/command.tsx index 34043b9..03aade9 100644 --- a/src/components/ui/command.tsx +++ b/src/components/ui/command.tsx @@ -5,8 +5,8 @@ import { DialogProps } from '@radix-ui/react-dialog' import { MagnifyingGlassIcon } from '@radix-ui/react-icons' import { Command as CommandPrimitive } from 'cmdk' -import { cn } from 'src/lib/utils' -import { Dialog, DialogContent } from 'src/components/ui/dialog' +import { cn } from '@/lib/utils' +import { Dialog, DialogContent } from '@/components/ui/dialog' const Command = React.forwardRef< React.ElementRef, @@ -23,7 +23,7 @@ const Command = React.forwardRef< )) Command.displayName = CommandPrimitive.displayName -interface CommandDialogProps extends DialogProps {} +interface CommandDialogProps extends DialogProps { } const CommandDialog = ({ children, ...props }: CommandDialogProps) => { return ( diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index b7860aa..e7c8846 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -4,7 +4,7 @@ import * as React from 'react' import * as DialogPrimitive from '@radix-ui/react-dialog' import { Cross2Icon } from '@radix-ui/react-icons' -import { cn } from 'src/lib/utils' +import { cn } from '@/lib/utils' const Dialog = DialogPrimitive.Root diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx index 3997050..848ca81 100644 --- a/src/components/ui/dropdown-menu.tsx +++ b/src/components/ui/dropdown-menu.tsx @@ -4,7 +4,7 @@ import * as React from 'react' import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu' import { CheckIcon, ChevronRightIcon, DotFilledIcon } from '@radix-ui/react-icons' -import { cn } from 'src/lib/utils' +import { cn } from '@/lib/utils' const DropdownMenu = DropdownMenuPrimitive.Root diff --git a/src/components/ui/form.tsx b/src/components/ui/form.tsx index 4ea5ee7..f6afdaf 100644 --- a/src/components/ui/form.tsx +++ b/src/components/ui/form.tsx @@ -1,6 +1,6 @@ -import * as React from 'react' -import * as LabelPrimitive from '@radix-ui/react-label' -import { Slot } from '@radix-ui/react-slot' +import * as React from "react" +import * as LabelPrimitive from "@radix-ui/react-label" +import { Slot } from "@radix-ui/react-slot" import { Controller, ControllerProps, @@ -8,25 +8,27 @@ import { FieldValues, FormProvider, useFormContext, -} from 'react-hook-form' +} from "react-hook-form" -import { cn } from 'src/lib/utils' -import { Label } from 'src/components/ui/label' +import { cn } from "@/lib/utils" +import { Label } from "@/components/ui/label" const Form = FormProvider type FormFieldContextValue< TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, + TName extends FieldPath = FieldPath > = { name: TName } -const FormFieldContext = React.createContext({} as FormFieldContextValue) +const FormFieldContext = React.createContext( + {} as FormFieldContextValue +) const FormField = < TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, + TName extends FieldPath = FieldPath >({ ...props }: ControllerProps) => { @@ -45,7 +47,7 @@ const useFormField = () => { const fieldState = getFieldState(fieldContext.name, formState) if (!fieldContext) { - throw new Error('useFormField should be used within ') + throw new Error("useFormField should be used within ") } const { id } = itemContext @@ -64,20 +66,23 @@ type FormItemContextValue = { id: string } -const FormItemContext = React.createContext({} as FormItemContextValue) - -const FormItem = React.forwardRef>( - ({ className, ...props }, ref) => { - const id = React.useId() - - return ( - -
- - ) - }, +const FormItemContext = React.createContext( + {} as FormItemContextValue ) -FormItem.displayName = 'FormItem' + +const FormItem = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => { + const id = React.useId() + + return ( + +
+ + ) +}) +FormItem.displayName = "FormItem" const FormLabel = React.forwardRef< React.ElementRef, @@ -88,13 +93,13 @@ const FormLabel = React.forwardRef< return (