diff --git a/alert.tsx b/alert.tsx index 3b67f9e..be64275 100644 --- a/alert.tsx +++ b/alert.tsx @@ -1,7 +1,7 @@ import type { VariantProps } from "class-variance-authority"; import { type HTMLAttributes, forwardRef } from "react"; import { tv } from "tailwind-variants"; -import cn from "./cn"; +import { cn } from "./cn"; const alertVariants = tv({ base: "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:text-foreground [&>svg~*]:pl-7", diff --git a/avatar.tsx b/avatar.tsx index 5752419..b410aa0 100644 --- a/avatar.tsx +++ b/avatar.tsx @@ -2,7 +2,7 @@ import * as AvatarPrimitive from "@radix-ui/react-avatar"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Avatar = forwardRef< ElementRef, diff --git a/badge.tsx b/badge.tsx index 126af99..7ffec45 100644 --- a/badge.tsx +++ b/badge.tsx @@ -1,6 +1,6 @@ import { type VariantProps, cva } from "class-variance-authority"; import type { HTMLAttributes } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const badgeVariants = cva( "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", @@ -19,7 +19,7 @@ const badgeVariants = cva( }, ); -interface BadgeProps extends HTMLAttributes, VariantProps { +export interface BadgeProps extends HTMLAttributes, VariantProps { // any other prop goes here } @@ -27,6 +27,4 @@ function Badge({ className, variant, ...rest }: BadgeProps) { return
; } -export { badgeVariants }; - -export default Badge; +export { Badge, badgeVariants }; diff --git a/button.tsx b/button.tsx index 3dd5fb4..0063832 100644 --- a/button.tsx +++ b/button.tsx @@ -2,7 +2,7 @@ import { Slot } from "@radix-ui/react-slot"; import { type VariantProps, cva } from "class-variance-authority"; import { Loader2Icon } from "lucide-react"; import { type ButtonHTMLAttributes, type ReactElement, cloneElement, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const buttonVariants = cva( "inline-flex items-center justify-center whitespace-nowrap 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", @@ -45,7 +45,7 @@ const iconVariants = cva(undefined, { }, }); -interface ButtonProps extends ButtonHTMLAttributes, VariantProps { +export interface ButtonProps extends ButtonHTMLAttributes, VariantProps { asChild?: boolean; isLoading?: boolean; startIcon?: ReactElement; @@ -83,6 +83,4 @@ const Button = forwardRef( Button.displayName = "Button"; -export { buttonVariants }; - -export default Button; +export { Button, buttonVariants }; diff --git a/card.tsx b/card.tsx index 3340bb6..4f124b5 100644 --- a/card.tsx +++ b/card.tsx @@ -1,5 +1,5 @@ import { type HTMLAttributes, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Card = forwardRef>(({ className, ...rest }, ref) => (
diff --git a/checkbox.tsx b/checkbox.tsx index 97a2736..7f8eb52 100644 --- a/checkbox.tsx +++ b/checkbox.tsx @@ -3,7 +3,7 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import { CheckIcon } from "lucide-react"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Checkbox = forwardRef< ElementRef, @@ -25,4 +25,4 @@ const Checkbox = forwardRef< Checkbox.displayName = CheckboxPrimitive.Root.displayName; -export default Checkbox; +export { Checkbox }; diff --git a/cn.ts b/cn.ts index dbc16d6..365058c 100644 --- a/cn.ts +++ b/cn.ts @@ -1,6 +1,6 @@ import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; -export default function cn(...inputs: ClassValue[]) { +export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } diff --git a/command.tsx b/command.tsx index 12d39b6..f54786f 100644 --- a/command.tsx +++ b/command.tsx @@ -4,7 +4,7 @@ import type { DialogProps } from "@radix-ui/react-dialog"; import { Command as CommandPrimitive } from "cmdk"; import { SearchIcon } from "lucide-react"; import { type ComponentPropsWithoutRef, type ElementRef, type HTMLAttributes, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; import { Dialog, DialogContent } from "./dialog"; const Command = forwardRef, ComponentPropsWithoutRef>( @@ -19,9 +19,8 @@ const Command = forwardRef, ComponentPropsWi /> ), ); -Command.displayName = CommandPrimitive.displayName; -interface CommandDialogProps extends DialogProps {} +export interface CommandDialogProps extends DialogProps {} const CommandDialog = ({ children, ...rest }: CommandDialogProps) => { return ( @@ -65,15 +64,11 @@ const CommandList = forwardRef< /> )); -CommandList.displayName = CommandPrimitive.List.displayName; - const CommandEmpty = forwardRef< ElementRef, ComponentPropsWithoutRef >((props, ref) => ); -CommandEmpty.displayName = CommandPrimitive.Empty.displayName; - const CommandGroup = forwardRef< ElementRef, ComponentPropsWithoutRef @@ -88,15 +83,12 @@ const CommandGroup = forwardRef< /> )); -CommandGroup.displayName = CommandPrimitive.Group.displayName; - const CommandSeparator = forwardRef< ElementRef, ComponentPropsWithoutRef >(({ className, ...rest }, ref) => ( )); -CommandSeparator.displayName = CommandPrimitive.Separator.displayName; const CommandItem = forwardRef< ElementRef, @@ -112,12 +104,17 @@ const CommandItem = forwardRef< /> )); -CommandItem.displayName = CommandPrimitive.Item.displayName; - const CommandShortcut = ({ className, ...rest }: HTMLAttributes) => { return ; }; + CommandShortcut.displayName = "CommandShortcut"; +CommandGroup.displayName = CommandPrimitive.Group.displayName; +CommandSeparator.displayName = CommandPrimitive.Separator.displayName; +CommandEmpty.displayName = CommandPrimitive.Empty.displayName; +Command.displayName = CommandPrimitive.displayName; +CommandList.displayName = CommandPrimitive.List.displayName; +CommandItem.displayName = CommandPrimitive.Item.displayName; export { Command, diff --git a/dialog.tsx b/dialog.tsx index 5b50d11..ce4e354 100644 --- a/dialog.tsx +++ b/dialog.tsx @@ -3,7 +3,7 @@ import * as DialogPrimitive from "@radix-ui/react-dialog"; import { XIcon } from "lucide-react"; import { type ComponentPropsWithoutRef, type ElementRef, type HTMLAttributes, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const DialogOverlay = forwardRef< ElementRef, diff --git a/dropdown-menu.tsx b/dropdown-menu.tsx index 8c25a28..afba8a1 100644 --- a/dropdown-menu.tsx +++ b/dropdown-menu.tsx @@ -3,7 +3,7 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import { CheckIcon, ChevronRightIcon, DotIcon } from "lucide-react"; import { type ComponentPropsWithoutRef, type ElementRef, type HTMLAttributes, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const DropdownMenuSubTrigger = forwardRef< ElementRef, diff --git a/form.tsx b/form.tsx index 04a9a44..48a2d3a 100644 --- a/form.tsx +++ b/form.tsx @@ -17,8 +17,8 @@ import { FormProvider, useFormContext, } from "react-hook-form"; -import cn from "./cn"; -import Label from "./label"; +import { cn } from "./cn"; +import { Label } from "./label"; const Form = FormProvider; diff --git a/hooks/useEventListener.ts b/hooks/useEventListener.ts index 548559f..8253f39 100644 --- a/hooks/useEventListener.ts +++ b/hooks/useEventListener.ts @@ -45,4 +45,4 @@ const useEventListener = ( }, [eventName, element, handler]); }; -export default useEventListener; +export { useEventListener }; diff --git a/hooks/useLocalStorage.ts b/hooks/useLocalStorage.ts index 845cd16..5c7e641 100644 --- a/hooks/useLocalStorage.ts +++ b/hooks/useLocalStorage.ts @@ -1,7 +1,7 @@ import { isEqual, isFunction, isNil } from "lodash-es"; import { type Dispatch, type SetStateAction, useEffect, useRef, useState } from "react"; -import parseJSON from "../utils/parseJSON"; -import useEventListener from "./useEventListener"; +import { parseJSON } from "../utils/parseJSON"; +import { useEventListener } from "./useEventListener"; type SetValue = Dispatch>; @@ -106,4 +106,4 @@ const useLocalStorage = (key: string, initialValue: T): [T, SetValue] => { return [storedValue, setValue]; }; -export default useLocalStorage; +export { useLocalStorage }; diff --git a/input.tsx b/input.tsx index 729b9d4..c405de7 100644 --- a/input.tsx +++ b/input.tsx @@ -1,5 +1,5 @@ import { type InputHTMLAttributes, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; export interface InputProps extends InputHTMLAttributes { // any other prop goes here @@ -19,4 +19,4 @@ const Input = forwardRef(({ className, type, ...re Input.displayName = "Input"; -export default Input; +export { Input }; diff --git a/label.tsx b/label.tsx index 31c1f1c..bcfb8cf 100644 --- a/label.tsx +++ b/label.tsx @@ -4,7 +4,7 @@ import * as LabelPrimitive from "@radix-ui/react-label"; import type { VariantProps } from "class-variance-authority"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; import { tv } from "tailwind-variants"; -import cn from "./cn"; +import { cn } from "./cn"; const labelVariants = tv({ base: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", @@ -19,4 +19,4 @@ const Label = forwardRef< Label.displayName = LabelPrimitive.Root.displayName; -export default Label; +export { Label }; diff --git a/link.tsx b/link.tsx index b6b8b76..f025bc5 100644 --- a/link.tsx +++ b/link.tsx @@ -4,7 +4,7 @@ import { addBasePath } from "next/dist/client/add-base-path"; import NextLink from "next/link"; import NProgress from "nprogress"; import { type ComponentProps, type MouseEvent, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; function onStart() { NProgress.start(); @@ -81,4 +81,4 @@ const Link = forwardRef>(function Link( ); }); -export default Link; +export { Link }; diff --git a/loader.tsx b/loader.tsx index 90fb176..827f764 100644 --- a/loader.tsx +++ b/loader.tsx @@ -1,6 +1,6 @@ import Image from "next/image"; -export default function Loader() { +export function Loader() { return (
Loading diff --git a/package.json b/package.json index 7e4ed1d..ee67049 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@risc0/ui", - "version": "0.0.34", + "version": "0.0.35", "sideEffects": false, "type": "module", "scripts": { diff --git a/popover.tsx b/popover.tsx index 71f563e..cbb57a9 100644 --- a/popover.tsx +++ b/popover.tsx @@ -2,7 +2,7 @@ import * as PopoverPrimitive from "@radix-ui/react-popover"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Popover = PopoverPrimitive.Root; const PopoverTrigger = PopoverPrimitive.Trigger; diff --git a/progress.tsx b/progress.tsx index c5f3444..9923671 100644 --- a/progress.tsx +++ b/progress.tsx @@ -2,7 +2,7 @@ import * as ProgressPrimitive from "@radix-ui/react-progress"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Progress = forwardRef< ElementRef, @@ -22,4 +22,4 @@ const Progress = forwardRef< Progress.displayName = ProgressPrimitive.Root.displayName; -export default Progress; +export { Progress }; diff --git a/radio-group.tsx b/radio-group.tsx index a0680cf..bba6ba8 100644 --- a/radio-group.tsx +++ b/radio-group.tsx @@ -2,7 +2,7 @@ import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const RadioGroup = forwardRef< ElementRef, diff --git a/required.tsx b/required.tsx index 160fdc7..6639d65 100644 --- a/required.tsx +++ b/required.tsx @@ -1,3 +1,3 @@ -export default function Required() { +export function Required() { return *; } diff --git a/select.tsx b/select.tsx index 0b989ad..8f8dd1c 100644 --- a/select.tsx +++ b/select.tsx @@ -3,7 +3,7 @@ import * as SelectPrimitive from "@radix-ui/react-select"; import { CheckIcon, ChevronDownIcon, ChevronUpIcon, ChevronsUpDownIcon } from "lucide-react"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const SelectTrigger = forwardRef< ElementRef, diff --git a/separator.tsx b/separator.tsx index 19e3a5a..2d128b5 100644 --- a/separator.tsx +++ b/separator.tsx @@ -2,7 +2,7 @@ import * as SeparatorPrimitive from "@radix-ui/react-separator"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Separator = forwardRef< ElementRef, @@ -19,4 +19,4 @@ const Separator = forwardRef< Separator.displayName = SeparatorPrimitive.Root.displayName; -export default Separator; +export { Separator }; diff --git a/sheet.tsx b/sheet.tsx index d88b80a..ed9e00a 100644 --- a/sheet.tsx +++ b/sheet.tsx @@ -4,7 +4,7 @@ import * as SheetPrimitive from "@radix-ui/react-dialog"; import { type VariantProps, cva } from "class-variance-authority"; import { XIcon } from "lucide-react"; import { type ComponentPropsWithoutRef, type ElementRef, type HTMLAttributes, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Sheet = SheetPrimitive.Root; const SheetTrigger = SheetPrimitive.Trigger; diff --git a/skeleton.tsx b/skeleton.tsx index b648889..5761d2d 100644 --- a/skeleton.tsx +++ b/skeleton.tsx @@ -1,6 +1,6 @@ import type { HTMLAttributes } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; -export default function Skeleton({ className, ...rest }: HTMLAttributes) { +export function Skeleton({ className, ...rest }: HTMLAttributes) { return
; } diff --git a/slider.tsx b/slider.tsx index 949befc..f050b25 100644 --- a/slider.tsx +++ b/slider.tsx @@ -2,7 +2,7 @@ import * as SliderPrimitive from "@radix-ui/react-slider"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Slider = forwardRef< ElementRef, @@ -22,4 +22,4 @@ const Slider = forwardRef< Slider.displayName = SliderPrimitive.Root.displayName; -export default Slider; +export { Slider }; diff --git a/sonner.tsx b/sonner.tsx index dc1a68c..e5a8ec8 100644 --- a/sonner.tsx +++ b/sonner.tsx @@ -4,16 +4,14 @@ import { useTheme } from "next-themes"; import type { ComponentProps } from "react"; // @ts-ignore -- not sure why this is not working import { Toaster as Sonner } from "sonner"; -import cn from "./cn"; +import { cn } from "./cn"; -type ToasterProps = ComponentProps; - -export default function Toaster({ ...props }: ToasterProps) { +export function Toaster({ ...props }) { const { theme = "system" } = useTheme(); return ( >(({ className, ...rest }, ref) => (
diff --git a/tabs.tsx b/tabs.tsx index 1a0458d..ce13e07 100644 --- a/tabs.tsx +++ b/tabs.tsx @@ -2,7 +2,7 @@ import * as TabsPrimitive from "@radix-ui/react-tabs"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const Tabs = TabsPrimitive.Root; diff --git a/textarea.tsx b/textarea.tsx index c59625b..e7d816d 100644 --- a/textarea.tsx +++ b/textarea.tsx @@ -1,5 +1,5 @@ import { type TextareaHTMLAttributes, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; export interface TextareaProps extends TextareaHTMLAttributes { // any other prop goes here @@ -18,4 +18,4 @@ const Textarea = forwardRef(({ className, .. Textarea.displayName = "Textarea"; -export default Textarea; +export { Textarea }; diff --git a/tooltip.tsx b/tooltip.tsx index ffde278..4a41926 100644 --- a/tooltip.tsx +++ b/tooltip.tsx @@ -2,7 +2,7 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip"; import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react"; -import cn from "./cn"; +import { cn } from "./cn"; const TooltipContent = forwardRef< ElementRef, diff --git a/utils/parseJSON.ts b/utils/parseJSON.ts index 1e389b9..c99d941 100644 --- a/utils/parseJSON.ts +++ b/utils/parseJSON.ts @@ -9,4 +9,4 @@ const parseJSON = (value?: string | null): T | undefined => { } }; -export default parseJSON; +export { parseJSON }; diff --git a/utils/setClipboard.ts b/utils/setClipboard.ts index f1bc2ab..00d335b 100644 --- a/utils/setClipboard.ts +++ b/utils/setClipboard.ts @@ -1,11 +1,11 @@ // @ts-ignore -- not sure why this is not working import { toast } from "sonner"; -type SetClipboardParams = { +export interface SetClipboardParams { onFailure?: () => void; onSuccess?: () => void; value: string; -}; +} const setClipboard = ({ value, @@ -22,4 +22,4 @@ const setClipboard = ({ }); }; -export default setClipboard; +export { setClipboard }; diff --git a/utils/sleep.ts b/utils/sleep.ts index 515b738..8d1eab3 100644 --- a/utils/sleep.ts +++ b/utils/sleep.ts @@ -1,4 +1,4 @@ // Helpful function to sleep for a given amount of time -export default function sleep(ms: number) { +export function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } diff --git a/utils/truncate.spec.ts b/utils/truncate.spec.ts index 7375cd7..0ecf15b 100644 --- a/utils/truncate.spec.ts +++ b/utils/truncate.spec.ts @@ -1,4 +1,4 @@ -import truncate from './truncate'; +import { truncate} from './truncate'; describe('truncate', () => { it('should truncate longer textes with a fixed length of characters in the last chunk', () => { diff --git a/utils/truncate.ts b/utils/truncate.ts index 0c044e2..6b78b9d 100644 --- a/utils/truncate.ts +++ b/utils/truncate.ts @@ -19,4 +19,4 @@ const truncate = (text: string, chars = 9): string => { return `${firstChunk}…${lastChunk}`; }; -export default truncate; +export { truncate };