fix: broken ts and shadcdn paths

main
palid 2023-07-14 22:59:19 +02:00
parent a7f4c8fe7c
commit 50115307d5
Signed by: palid
SSH Key Fingerprint: SHA256:Mus3wCd2x6nxtARI0DpWGT7lIWbNy3R90BVDg0j35PI
18 changed files with 127 additions and 103 deletions

View File

@ -10,7 +10,7 @@
"cssVariables": true "cssVariables": true
}, },
"aliases": { "aliases": {
"components": "src/components", "components": "@/components",
"utils": "src/lib/utils" "utils": "@/lib/utils"
} }
} }

View File

@ -27,7 +27,7 @@ import {
} from '@/components/ui/command' } from '@/components/ui/command'
import { CaretSortIcon } from '@radix-ui/react-icons' import { CaretSortIcon } from '@radix-ui/react-icons'
import { cn } from '@/lib/utils' 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 }) { function NavLink({ href, children }: { href: string; children: React.ReactNode }) {
return ( return (

View File

@ -1,4 +1,4 @@
import { ModeToggle } from '@spejstore-ui/components/ModeToggle' import { ModeToggle } from '@//components/ModeToggle'
import Link from 'next/link' import Link from 'next/link'
import Image from 'next/image' import Image from 'next/image'

View File

@ -1,34 +1,37 @@
import * as React from 'react' import * as React from "react"
import { Slot } from '@radix-ui/react-slot' import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from 'class-variance-authority' import { cva, type VariantProps } from "class-variance-authority"
import { cn } from 'src/lib/utils' import { cn } from "@/lib/utils"
const buttonVariants = cva( 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: { variants: {
variant: { variant: {
default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90', default:
destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90', "bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
outline: outline:
'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground', "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', secondary:
ghost: 'hover:bg-accent hover:text-accent-foreground', "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
link: 'text-primary underline-offset-4 hover:underline', ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
}, },
size: { size: {
default: 'h-9 px-4 py-2', default: "h-9 px-4 py-2",
sm: 'h-8 rounded-md px-3 text-xs', sm: "h-8 rounded-md px-3 text-xs",
lg: 'h-10 rounded-md px-8', lg: "h-10 rounded-md px-8",
icon: 'h-9 w-9', icon: "h-9 w-9",
}, },
}, },
defaultVariants: { defaultVariants: {
variant: 'default', variant: "default",
size: 'default', size: "default",
}, },
}, }
) )
export interface ButtonProps export interface ButtonProps
@ -39,12 +42,16 @@ export interface ButtonProps
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => { ({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button' const Comp = asChild ? Slot : "button"
return ( return (
<Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} /> <Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
) )
}, }
) )
Button.displayName = 'Button' Button.displayName = "Button"
export { Button, buttonVariants } export { Button, buttonVariants }

View File

@ -1,6 +1,6 @@
import { cn } from '@/lib/utils'
import * as React from 'react' import * as React from 'react'
import { cn } from 'src/lib/utils'
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>( const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => ( ({ className, ...props }, ref) => (

View File

@ -5,8 +5,8 @@ import { DialogProps } from '@radix-ui/react-dialog'
import { MagnifyingGlassIcon } from '@radix-ui/react-icons' import { MagnifyingGlassIcon } from '@radix-ui/react-icons'
import { Command as CommandPrimitive } from 'cmdk' import { Command as CommandPrimitive } from 'cmdk'
import { cn } from 'src/lib/utils' import { cn } from '@/lib/utils'
import { Dialog, DialogContent } from 'src/components/ui/dialog' import { Dialog, DialogContent } from '@/components/ui/dialog'
const Command = React.forwardRef< const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>, React.ElementRef<typeof CommandPrimitive>,
@ -23,7 +23,7 @@ const Command = React.forwardRef<
)) ))
Command.displayName = CommandPrimitive.displayName Command.displayName = CommandPrimitive.displayName
interface CommandDialogProps extends DialogProps {} interface CommandDialogProps extends DialogProps { }
const CommandDialog = ({ children, ...props }: CommandDialogProps) => { const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
return ( return (

View File

@ -4,7 +4,7 @@ import * as React from 'react'
import * as DialogPrimitive from '@radix-ui/react-dialog' import * as DialogPrimitive from '@radix-ui/react-dialog'
import { Cross2Icon } from '@radix-ui/react-icons' import { Cross2Icon } from '@radix-ui/react-icons'
import { cn } from 'src/lib/utils' import { cn } from '@/lib/utils'
const Dialog = DialogPrimitive.Root const Dialog = DialogPrimitive.Root

View File

@ -4,7 +4,7 @@ import * as React from 'react'
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu' import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'
import { CheckIcon, ChevronRightIcon, DotFilledIcon } from '@radix-ui/react-icons' import { CheckIcon, ChevronRightIcon, DotFilledIcon } from '@radix-ui/react-icons'
import { cn } from 'src/lib/utils' import { cn } from '@/lib/utils'
const DropdownMenu = DropdownMenuPrimitive.Root const DropdownMenu = DropdownMenuPrimitive.Root

View File

@ -1,6 +1,6 @@
import * as React from 'react' import * as React from "react"
import * as LabelPrimitive from '@radix-ui/react-label' import * as LabelPrimitive from "@radix-ui/react-label"
import { Slot } from '@radix-ui/react-slot' import { Slot } from "@radix-ui/react-slot"
import { import {
Controller, Controller,
ControllerProps, ControllerProps,
@ -8,25 +8,27 @@ import {
FieldValues, FieldValues,
FormProvider, FormProvider,
useFormContext, useFormContext,
} from 'react-hook-form' } from "react-hook-form"
import { cn } from 'src/lib/utils' import { cn } from "@/lib/utils"
import { Label } from 'src/components/ui/label' import { Label } from "@/components/ui/label"
const Form = FormProvider const Form = FormProvider
type FormFieldContextValue< type FormFieldContextValue<
TFieldValues extends FieldValues = FieldValues, TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
> = { > = {
name: TName name: TName
} }
const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue) const FormFieldContext = React.createContext<FormFieldContextValue>(
{} as FormFieldContextValue
)
const FormField = < const FormField = <
TFieldValues extends FieldValues = FieldValues, TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
>({ >({
...props ...props
}: ControllerProps<TFieldValues, TName>) => { }: ControllerProps<TFieldValues, TName>) => {
@ -45,7 +47,7 @@ const useFormField = () => {
const fieldState = getFieldState(fieldContext.name, formState) const fieldState = getFieldState(fieldContext.name, formState)
if (!fieldContext) { if (!fieldContext) {
throw new Error('useFormField should be used within <FormField>') throw new Error("useFormField should be used within <FormField>")
} }
const { id } = itemContext const { id } = itemContext
@ -64,20 +66,23 @@ type FormItemContextValue = {
id: string id: string
} }
const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue) const FormItemContext = React.createContext<FormItemContextValue>(
{} as FormItemContextValue
const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => {
const id = React.useId()
return (
<FormItemContext.Provider value={{ id }}>
<div ref={ref} className={cn('space-y-2', className)} {...props} />
</FormItemContext.Provider>
)
},
) )
FormItem.displayName = 'FormItem'
const FormItem = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
const id = React.useId()
return (
<FormItemContext.Provider value={{ id }}>
<div ref={ref} className={cn("space-y-2", className)} {...props} />
</FormItemContext.Provider>
)
})
FormItem.displayName = "FormItem"
const FormLabel = React.forwardRef< const FormLabel = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>, React.ElementRef<typeof LabelPrimitive.Root>,
@ -88,13 +93,13 @@ const FormLabel = React.forwardRef<
return ( return (
<Label <Label
ref={ref} ref={ref}
className={cn(error && 'text-destructive', className)} className={cn(error && "text-destructive", className)}
htmlFor={formItemId} htmlFor={formItemId}
{...props} {...props}
/> />
) )
}) })
FormLabel.displayName = 'FormLabel' FormLabel.displayName = "FormLabel"
const FormControl = React.forwardRef< const FormControl = React.forwardRef<
React.ElementRef<typeof Slot>, React.ElementRef<typeof Slot>,
@ -106,13 +111,17 @@ const FormControl = React.forwardRef<
<Slot <Slot
ref={ref} ref={ref}
id={formItemId} id={formItemId}
aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`} aria-describedby={
!error
? `${formDescriptionId}`
: `${formDescriptionId} ${formMessageId}`
}
aria-invalid={!!error} aria-invalid={!!error}
{...props} {...props}
/> />
) )
}) })
FormControl.displayName = 'FormControl' FormControl.displayName = "FormControl"
const FormDescription = React.forwardRef< const FormDescription = React.forwardRef<
HTMLParagraphElement, HTMLParagraphElement,
@ -124,12 +133,12 @@ const FormDescription = React.forwardRef<
<p <p
ref={ref} ref={ref}
id={formDescriptionId} id={formDescriptionId}
className={cn('text-[0.8rem] text-muted-foreground', className)} className={cn("text-[0.8rem] text-muted-foreground", className)}
{...props} {...props}
/> />
) )
}) })
FormDescription.displayName = 'FormDescription' FormDescription.displayName = "FormDescription"
const FormMessage = React.forwardRef< const FormMessage = React.forwardRef<
HTMLParagraphElement, HTMLParagraphElement,
@ -146,14 +155,14 @@ const FormMessage = React.forwardRef<
<p <p
ref={ref} ref={ref}
id={formMessageId} id={formMessageId}
className={cn('text-[0.8rem] font-medium text-destructive', className)} className={cn("text-[0.8rem] font-medium text-destructive", className)}
{...props} {...props}
> >
{body} {body}
</p> </p>
) )
}) })
FormMessage.displayName = 'FormMessage' FormMessage.displayName = "FormMessage"
export { export {
useFormField, useFormField,

View File

@ -1,8 +1,8 @@
import * as React from 'react' import * as React from 'react'
import { cn } from 'src/lib/utils' import { cn } from '@/lib/utils'
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {} export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> { }
const Input = React.forwardRef<HTMLInputElement, InputProps>( const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => { ({ className, type, ...props }, ref) => {

View File

@ -1,20 +1,25 @@
'use client' "use client"
import * as React from 'react' import * as React from "react"
import * as LabelPrimitive from '@radix-ui/react-label' import * as LabelPrimitive from "@radix-ui/react-label"
import { cva, type VariantProps } from 'class-variance-authority' import { cva, type VariantProps } from "class-variance-authority"
import { cn } from 'src/lib/utils' import { cn } from "@/lib/utils"
const labelVariants = cva( const labelVariants = cva(
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70', "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
) )
const Label = React.forwardRef< const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>, React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants> React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} /> <LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
{...props}
/>
)) ))
Label.displayName = LabelPrimitive.Root.displayName Label.displayName = LabelPrimitive.Root.displayName

View File

@ -3,7 +3,7 @@
import * as React from 'react' import * as React from 'react'
import * as PopoverPrimitive from '@radix-ui/react-popover' import * as PopoverPrimitive from '@radix-ui/react-popover'
import { cn } from 'src/lib/utils' import { cn } from '@/lib/utils'
const Popover = PopoverPrimitive.Root const Popover = PopoverPrimitive.Root

View File

@ -4,7 +4,7 @@ import * as React from 'react'
import { CaretSortIcon, CheckIcon } from '@radix-ui/react-icons' import { CaretSortIcon, CheckIcon } from '@radix-ui/react-icons'
import * as SelectPrimitive from '@radix-ui/react-select' import * as SelectPrimitive from '@radix-ui/react-select'
import { cn } from 'src/lib/utils' import { cn } from '@/lib/utils'
const Select = SelectPrimitive.Root const Select = SelectPrimitive.Root
@ -42,7 +42,7 @@ const SelectContent = React.forwardRef<
className={cn( className={cn(
'relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
position === 'popper' && position === 'popper' &&
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
className, className,
)} )}
position={position} position={position}
@ -52,7 +52,7 @@ const SelectContent = React.forwardRef<
className={cn( className={cn(
'p-1', 'p-1',
position === 'popper' && position === 'popper' &&
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]', 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]',
)} )}
> >
{children} {children}

View File

@ -1,26 +1,31 @@
'use client' "use client"
import * as React from 'react' import * as React from "react"
import * as SeparatorPrimitive from '@radix-ui/react-separator' import * as SeparatorPrimitive from "@radix-ui/react-separator"
import { cn } from 'src/lib/utils' import { cn } from "@/lib/utils"
const Separator = React.forwardRef< const Separator = React.forwardRef<
React.ElementRef<typeof SeparatorPrimitive.Root>, React.ElementRef<typeof SeparatorPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => ( >(
<SeparatorPrimitive.Root (
ref={ref} { className, orientation = "horizontal", decorative = true, ...props },
decorative={decorative} ref
orientation={orientation} ) => (
className={cn( <SeparatorPrimitive.Root
'shrink-0 bg-border', ref={ref}
orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]', decorative={decorative}
className, orientation={orientation}
)} className={cn(
{...props} "shrink-0 bg-border",
/> orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
)) className
)}
{...props}
/>
)
)
Separator.displayName = SeparatorPrimitive.Root.displayName Separator.displayName = SeparatorPrimitive.Root.displayName
export { Separator } export { Separator }

View File

@ -1,8 +1,8 @@
import * as React from 'react' import * as React from 'react'
import { cn } from 'src/lib/utils' import { cn } from '@/lib/utils'
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {} export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> { }
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>( const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
({ className, ...props }, ref) => { ({ className, ...props }, ref) => {

View File

@ -3,7 +3,7 @@ import { Cross2Icon } from '@radix-ui/react-icons'
import * as ToastPrimitives from '@radix-ui/react-toast' import * as ToastPrimitives from '@radix-ui/react-toast'
import { cva, type VariantProps } from 'class-variance-authority' import { cva, type VariantProps } from 'class-variance-authority'
import { cn } from 'src/lib/utils' import { cn } from '@/lib/utils'
const ToastProvider = ToastPrimitives.Provider const ToastProvider = ToastPrimitives.Provider

View File

@ -7,8 +7,8 @@ import {
ToastProvider, ToastProvider,
ToastTitle, ToastTitle,
ToastViewport, ToastViewport,
} from 'src/components/ui/toast' } from '@/components/ui/toast'
import { useToast } from 'src/components/ui/use-toast' import { useToast } from '@/components/ui/use-toast'
export function Toaster() { export function Toaster() {
const { toasts } = useToast() const { toasts } = useToast()

View File

@ -20,10 +20,8 @@
} }
], ],
"paths": { "paths": {
"@spejstore-ui/*": ["./src/*"], "@/*": ["./src/*"],
"@/components/*": ["./src/components/*"], "@/components/*": ["./src/components/*"]
"@/utils": ["./src/lib/utils"],
"@/lib/utils": ["./src/lib/utils"]
} }
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],