Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

refactor(ts): type the shadcn components

spacesdrive308c8da587df
diff --git a/frontend/src/components/ui/alert-dialog.tsx b/frontend/src/components/ui/alert-dialog.tsx
index 4591b4c..8a5b45f 100644
--- a/frontend/src/components/ui/alert-dialog.tsx
+++ b/frontend/src/components/ui/alert-dialog.tsx
@@ -8,26 +8,26 @@ import { Button } from "@/components/ui/button"
function AlertDialog({
...props
-}) {
+}: AlertDialogPrimitive.Root.Props) {
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />;
}
function AlertDialogTrigger({
...props
-}) {
+}: AlertDialogPrimitive.Trigger.Props) {
return (<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />);
}
function AlertDialogPortal({
...props
-}) {
+}: AlertDialogPrimitive.Portal.Props) {
return (<AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />);
}
function AlertDialogOverlay({
className,
...props
-}) {
+}: AlertDialogPrimitive.Backdrop.Props) {
return (
<AlertDialogPrimitive.Backdrop
data-slot="alert-dialog-overlay"
@@ -43,6 +43,8 @@ function AlertDialogContent({
className,
size = "default",
...props
+}: AlertDialogPrimitive.Popup.Props & {
+ size?: "default" | "sm"
}) {
return (
<AlertDialogPortal>
@@ -62,7 +64,7 @@ function AlertDialogContent({
function AlertDialogHeader({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-header"
@@ -77,7 +79,7 @@ function AlertDialogHeader({
function AlertDialogFooter({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-footer"
@@ -92,7 +94,7 @@ function AlertDialogFooter({
function AlertDialogMedia({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-media"
@@ -107,7 +109,7 @@ function AlertDialogMedia({
function AlertDialogTitle({
className,
...props
-}) {
+}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
return (
<AlertDialogPrimitive.Title
data-slot="alert-dialog-title"
@@ -122,7 +124,7 @@ function AlertDialogTitle({
function AlertDialogDescription({
className,
...props
-}) {
+}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
return (
<AlertDialogPrimitive.Description
data-slot="alert-dialog-description"
@@ -137,7 +139,7 @@ function AlertDialogDescription({
function AlertDialogAction({
className,
...props
-}) {
+}: React.ComponentProps<typeof Button>) {
return (<Button data-slot="alert-dialog-action" className={cn(className)} {...props} />);
}
@@ -146,7 +148,8 @@ function AlertDialogCancel({
variant = "outline",
size = "default",
...props
-}) {
+}: AlertDialogPrimitive.Close.Props &
+ Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
return (
<AlertDialogPrimitive.Close
data-slot="alert-dialog-cancel"
diff --git a/frontend/src/components/ui/alert.tsx b/frontend/src/components/ui/alert.tsx
index becb12d..91a68f3 100644
--- a/frontend/src/components/ui/alert.tsx
+++ b/frontend/src/components/ui/alert.tsx
@@ -1,5 +1,5 @@
import * as React from "react"
-import { cva } from "class-variance-authority";
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils"
@@ -25,7 +25,7 @@ function Alert({
className,
variant,
...props
-}) {
+}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
return (
<div
data-slot="alert"
@@ -38,7 +38,7 @@ function Alert({
function AlertTitle({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-title"
@@ -53,7 +53,7 @@ function AlertTitle({
function AlertDescription({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-description"
@@ -68,7 +68,7 @@ function AlertDescription({
function AlertAction({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-action"
diff --git a/frontend/src/components/ui/avatar.tsx b/frontend/src/components/ui/avatar.tsx
index fee91c8..47085a5 100644
--- a/frontend/src/components/ui/avatar.tsx
+++ b/frontend/src/components/ui/avatar.tsx
@@ -7,6 +7,8 @@ function Avatar({
className,
size = "default",
...props
+}: AvatarPrimitive.Root.Props & {
+ size?: "default" | "sm" | "lg"
}) {
return (
<AvatarPrimitive.Root
@@ -23,7 +25,7 @@ function Avatar({
function AvatarImage({
className,
...props
-}) {
+}: AvatarPrimitive.Image.Props) {
return (
<AvatarPrimitive.Image
data-slot="avatar-image"
@@ -35,7 +37,7 @@ function AvatarImage({
function AvatarFallback({
className,
...props
-}) {
+}: AvatarPrimitive.Fallback.Props) {
return (
<AvatarPrimitive.Fallback
data-slot="avatar-fallback"
@@ -50,7 +52,7 @@ function AvatarFallback({
function AvatarBadge({
className,
...props
-}) {
+}: React.ComponentProps<"span">) {
return (
<span
data-slot="avatar-badge"
@@ -68,7 +70,7 @@ function AvatarBadge({
function AvatarGroup({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="avatar-group"
@@ -83,7 +85,7 @@ function AvatarGroup({
function AvatarGroupCount({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="avatar-group-count"
diff --git a/frontend/src/components/ui/badge.tsx b/frontend/src/components/ui/badge.tsx
index b44caea..f1681ca 100644
--- a/frontend/src/components/ui/badge.tsx
+++ b/frontend/src/components/ui/badge.tsx
@@ -1,6 +1,6 @@
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
-import { cva } from "class-variance-authority";
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils"
@@ -32,7 +32,7 @@ function Badge({
variant = "default",
render,
...props
-}) {
+}: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
return useRender({
defaultTagName: "span",
props: mergeProps({
diff --git a/frontend/src/components/ui/breadcrumb.tsx b/frontend/src/components/ui/breadcrumb.tsx
index db2b171..3aa28cc 100644
--- a/frontend/src/components/ui/breadcrumb.tsx
+++ b/frontend/src/components/ui/breadcrumb.tsx
@@ -8,7 +8,7 @@ import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
function Breadcrumb({
className,
...props
-}) {
+}: React.ComponentProps<"nav">) {
return (
<nav
aria-label="breadcrumb"
@@ -21,7 +21,7 @@ function Breadcrumb({
function BreadcrumbList({
className,
...props
-}) {
+}: React.ComponentProps<"ol">) {
return (
<ol
data-slot="breadcrumb-list"
@@ -36,7 +36,7 @@ function BreadcrumbList({
function BreadcrumbItem({
className,
...props
-}) {
+}: React.ComponentProps<"li">) {
return (
<li
data-slot="breadcrumb-item"
@@ -49,7 +49,7 @@ function BreadcrumbLink({
className,
render,
...props
-}) {
+}: useRender.ComponentProps<"a">) {
return useRender({
defaultTagName: "a",
props: mergeProps({
@@ -65,7 +65,7 @@ function BreadcrumbLink({
function BreadcrumbPage({
className,
...props
-}) {
+}: React.ComponentProps<"span">) {
return (
<span
data-slot="breadcrumb-page"
@@ -81,7 +81,7 @@ function BreadcrumbSeparator({
children,
className,
...props
-}) {
+}: React.ComponentProps<"li">) {
return (
<li
data-slot="breadcrumb-separator"
@@ -99,7 +99,7 @@ function BreadcrumbSeparator({
function BreadcrumbEllipsis({
className,
...props
-}) {
+}: React.ComponentProps<"span">) {
return (
<span
data-slot="breadcrumb-ellipsis"
diff --git a/frontend/src/components/ui/button.tsx b/frontend/src/components/ui/button.tsx
index a9efcee..789c8df 100644
--- a/frontend/src/components/ui/button.tsx
+++ b/frontend/src/components/ui/button.tsx
@@ -1,6 +1,6 @@
import * as React from "react"
import { Button as ButtonPrimitive } from "@base-ui/react/button"
-import { cva } from "class-variance-authority";
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils"
@@ -47,7 +47,7 @@ function Button({
render,
nativeButton,
...props
-}) {
+}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
// A link rendered through `render` is not a <button>, so Base UI must not expect native button semantics.
const isNative = nativeButton ?? (render == null || (React.isValidElement(render) && render.type === "button"));
return (
diff --git a/frontend/src/components/ui/card.tsx b/frontend/src/components/ui/card.tsx
index 494c91d..b1a8955 100644
--- a/frontend/src/components/ui/card.tsx
+++ b/frontend/src/components/ui/card.tsx
@@ -6,7 +6,7 @@ function Card({
className,
size = "default",
...props
-}) {
+}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
return (
<div
data-slot="card"
@@ -22,7 +22,7 @@ function Card({
function CardHeader({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="card-header"
@@ -37,7 +37,7 @@ function CardHeader({
function CardTitle({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="card-title"
@@ -52,7 +52,7 @@ function CardTitle({
function CardDescription({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="card-description"
@@ -64,7 +64,7 @@ function CardDescription({
function CardAction({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="card-action"
@@ -79,7 +79,7 @@ function CardAction({
function CardContent({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
@@ -91,7 +91,7 @@ function CardContent({
function CardFooter({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
diff --git a/frontend/src/components/ui/chart.tsx b/frontend/src/components/ui/chart.tsx
index 4f27e8a..0436fc3 100644
--- a/frontend/src/components/ui/chart.tsx
+++ b/frontend/src/components/ui/chart.tsx
@@ -1,6 +1,7 @@
"use client";
import * as React from "react"
import * as RechartsPrimitive from "recharts"
+import type { TooltipValueType } from "recharts"
import { cn } from "@/lib/utils"
@@ -8,14 +9,30 @@ import { cn } from "@/lib/utils"
const THEMES = {
light: "",
dark: ".dark"
-}
+} as const
const INITIAL_DIMENSION = {
width: 320,
height: 200
+} as const
+type TooltipNameType = number | string
+
+export type ChartConfig = Record<
+ string,
+ {
+ label?: React.ReactNode
+ icon?: React.ComponentType
+ } & (
+ | { color?: string; theme?: never }
+ | { color?: never; theme: Record<keyof typeof THEMES, string> }
+ )
+>
+
+interface ChartContextValue {
+ config: ChartConfig
}
-const ChartContext = React.createContext(null)
+const ChartContext = React.createContext<ChartContextValue | null>(null)
function useChart() {
const context = React.useContext(ChartContext)
@@ -34,6 +51,15 @@ function ChartContainer({
config,
initialDimension = INITIAL_DIMENSION,
...props
+}: React.ComponentProps<"div"> & {
+ config: ChartConfig
+ children: React.ComponentProps<
+ typeof RechartsPrimitive.ResponsiveContainer
+ >["children"]
+ initialDimension?: {
+ width: number
+ height: number
+ }
}) {
const uniqueId = React.useId()
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`
@@ -60,7 +86,7 @@ function ChartContainer({
const ChartStyle = ({
id,
config
-}) => {
+}: { id: string; config: ChartConfig }) => {
const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color)
if (!colorConfig.length) {
@@ -76,7 +102,7 @@ ${prefix} [data-chart=${id}] {
${colorConfig
.map(([key, itemConfig]) => {
const color =
- itemConfig.theme?.[theme] ??
+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
itemConfig.color
return color ? ` --color-${key}: ${color};` : null
})
@@ -104,7 +130,20 @@ function ChartTooltipContent({
color,
nameKey,
labelKey
-}) {
+}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
+ React.ComponentProps<"div"> & {
+ hideLabel?: boolean
+ hideIndicator?: boolean
+ indicator?: "line" | "dot" | "dashed"
+ nameKey?: string
+ labelKey?: string
+ } & Omit<
+ RechartsPrimitive.DefaultTooltipContentProps<
+ TooltipValueType,
+ TooltipNameType
+ >,
+ "accessibilityLayer"
+ >) {
const { config } = useChart()
const tooltipLabel = React.useMemo(() => {
@@ -191,7 +230,7 @@ function ChartTooltipContent({
{
"--color-bg": indicatorColor,
"--color-border": indicatorColor
- }
+ } as React.CSSProperties
} />
)
)}
@@ -232,7 +271,10 @@ function ChartLegendContent({
payload,
verticalAlign = "bottom",
nameKey
-}) {
+}: React.ComponentProps<"div"> & {
+ hideIcon?: boolean
+ nameKey?: string
+} & RechartsPrimitive.DefaultLegendContentProps) {
const { config } = useChart()
if (!payload?.length) {
@@ -276,9 +318,9 @@ function ChartLegendContent({
}
function getPayloadConfigFromPayload(
- config,
- payload,
- key
+ config: ChartConfig,
+ payload: unknown,
+ key: string
) {
if (typeof payload !== "object" || payload === null) {
return undefined
@@ -291,19 +333,19 @@ function getPayloadConfigFromPayload(
? payload.payload
: undefined
- let configLabelKey = key
+ let configLabelKey: string = key
if (
key in payload &&
- typeof payload[key] === "string"
+ typeof payload[key as keyof typeof payload] === "string"
) {
- configLabelKey = payload[key]
+ configLabelKey = payload[key as keyof typeof payload] as string
} else if (
payloadPayload &&
key in payloadPayload &&
- typeof payloadPayload[key] === "string"
+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
) {
- configLabelKey = payloadPayload[key]
+ configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string
}
return configLabelKey in config ? config[configLabelKey] : config[key]
diff --git a/frontend/src/components/ui/checkbox.tsx b/frontend/src/components/ui/checkbox.tsx
index 95a3a90..dd0fc23 100644
--- a/frontend/src/components/ui/checkbox.tsx
+++ b/frontend/src/components/ui/checkbox.tsx
@@ -6,7 +6,7 @@ import { CheckIcon } from "lucide-react"
function Checkbox({
className,
...props
-}) {
+}: CheckboxPrimitive.Root.Props) {
return (
<CheckboxPrimitive.Root
data-slot="checkbox"
diff --git a/frontend/src/components/ui/collapsible.tsx b/frontend/src/components/ui/collapsible.tsx
index 2299fec..e5797c8 100644
--- a/frontend/src/components/ui/collapsible.tsx
+++ b/frontend/src/components/ui/collapsible.tsx
@@ -2,19 +2,19 @@ import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible"
function Collapsible({
...props
-}) {
+}: CollapsiblePrimitive.Root.Props) {
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
}
function CollapsibleTrigger({
...props
-}) {
+}: CollapsiblePrimitive.Trigger.Props) {
return (<CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />);
}
function CollapsibleContent({
...props
-}) {
+}: CollapsiblePrimitive.Panel.Props) {
return (<CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />);
}
diff --git a/frontend/src/components/ui/command.tsx b/frontend/src/components/ui/command.tsx
index eb1f0f2..9a1c0c5 100644
--- a/frontend/src/components/ui/command.tsx
+++ b/frontend/src/components/ui/command.tsx
@@ -20,7 +20,7 @@ import { SearchIcon, CheckIcon } from "lucide-react"
function Command({
className,
...props
-}) {
+}: React.ComponentProps<typeof CommandPrimitive>) {
return (
<CommandPrimitive
data-slot="command"
@@ -39,6 +39,12 @@ function CommandDialog({
className,
showCloseButton = false,
...props
+}: Omit<React.ComponentProps<typeof Dialog>, "children"> & {
+ title?: string
+ description?: string
+ className?: string
+ showCloseButton?: boolean
+ children: React.ReactNode
}) {
return (
<Dialog {...props}>
@@ -58,7 +64,7 @@ function CommandDialog({
function CommandInput({
className,
...props
-}) {
+}: React.ComponentProps<typeof CommandPrimitive.Input>) {
return (
<div data-slot="command-input-wrapper">
<InputGroup
@@ -81,7 +87,7 @@ function CommandInput({
function CommandList({
className,
...props
-}) {
+}: React.ComponentProps<typeof CommandPrimitive.List>) {
return (
<CommandPrimitive.List
data-slot="command-list"
@@ -96,7 +102,7 @@ function CommandList({
function CommandEmpty({
className,
...props
-}) {
+}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
return (
<CommandPrimitive.Empty
data-slot="command-empty"
@@ -108,7 +114,7 @@ function CommandEmpty({
function CommandGroup({
className,
...props
-}) {
+}: React.ComponentProps<typeof CommandPrimitive.Group>) {
return (
<CommandPrimitive.Group
data-slot="command-group"
@@ -123,7 +129,7 @@ function CommandGroup({
function CommandSeparator({
className,
...props
-}) {
+}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
return (
<CommandPrimitive.Separator
data-slot="command-separator"
@@ -136,7 +142,7 @@ function CommandItem({
className,
children,
...props
-}) {
+}: React.ComponentProps<typeof CommandPrimitive.Item>) {
return (
<CommandPrimitive.Item
data-slot="command-item"
@@ -155,7 +161,7 @@ function CommandItem({
function CommandShortcut({
className,
...props
-}) {
+}: React.ComponentProps<"span">) {
return (
<span
data-slot="command-shortcut"
diff --git a/frontend/src/components/ui/dialog.tsx b/frontend/src/components/ui/dialog.tsx
index dc5d252..037307a 100644
--- a/frontend/src/components/ui/dialog.tsx
+++ b/frontend/src/components/ui/dialog.tsx
@@ -7,32 +7,32 @@ import { XIcon } from "lucide-react"
function Dialog({
...props
-}) {
+}: DialogPrimitive.Root.Props) {
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
}
function DialogTrigger({
...props
-}) {
+}: DialogPrimitive.Trigger.Props) {
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
}
function DialogPortal({
...props
-}) {
+}: DialogPrimitive.Portal.Props) {
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
}
function DialogClose({
...props
-}) {
+}: DialogPrimitive.Close.Props) {
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
}
function DialogOverlay({
className,
...props
-}) {
+}: DialogPrimitive.Backdrop.Props) {
return (
<DialogPrimitive.Backdrop
data-slot="dialog-overlay"
@@ -49,6 +49,8 @@ function DialogContent({
children,
showCloseButton = true,
...props
+}: DialogPrimitive.Popup.Props & {
+ showCloseButton?: boolean
}) {
return (
<DialogPortal>
@@ -79,7 +81,7 @@ function DialogContent({
function DialogHeader({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="dialog-header"
@@ -93,6 +95,8 @@ function DialogFooter({
showCloseButton = false,
children,
...props
+}: React.ComponentProps<"div"> & {
+ showCloseButton?: boolean
}) {
return (
<div
@@ -115,7 +119,7 @@ function DialogFooter({
function DialogTitle({
className,
...props
-}) {
+}: DialogPrimitive.Title.Props) {
return (
<DialogPrimitive.Title
data-slot="dialog-title"
@@ -127,7 +131,7 @@ function DialogTitle({
function DialogDescription({
className,
...props
-}) {
+}: DialogPrimitive.Description.Props) {
return (
<DialogPrimitive.Description
data-slot="dialog-description"
diff --git a/frontend/src/components/ui/dropdown-menu.tsx b/frontend/src/components/ui/dropdown-menu.tsx
index 5a91e44..f8aaa13 100644
--- a/frontend/src/components/ui/dropdown-menu.tsx
+++ b/frontend/src/components/ui/dropdown-menu.tsx
@@ -8,19 +8,19 @@ import { ChevronRightIcon, CheckIcon } from "lucide-react"
function DropdownMenu({
...props
-}) {
+}: MenuPrimitive.Root.Props) {
return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
}
function DropdownMenuPortal({
...props
-}) {
+}: MenuPrimitive.Portal.Props) {
return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />;
}
function DropdownMenuTrigger({
...props
-}) {
+}: MenuPrimitive.Trigger.Props) {
return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;
}
@@ -31,7 +31,11 @@ function DropdownMenuContent({
sideOffset = 4,
className,
...props
-}) {
+}: MenuPrimitive.Popup.Props &
+ Pick<
+ MenuPrimitive.Positioner.Props,
+ "align" | "alignOffset" | "side" | "sideOffset"
+ >) {
return (
<MenuPrimitive.Portal>
<MenuPrimitive.Positioner
@@ -54,7 +58,7 @@ function DropdownMenuContent({
function DropdownMenuGroup({
...props
-}) {
+}: MenuPrimitive.Group.Props) {
return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />;
}
@@ -62,6 +66,8 @@ function DropdownMenuLabel({
className,
inset,
...props
+}: MenuPrimitive.GroupLabel.Props & {
+ inset?: boolean
}) {
return (
<MenuPrimitive.GroupLabel
@@ -80,6 +86,9 @@ function DropdownMenuItem({
inset,
variant = "default",
...props
+}: MenuPrimitive.Item.Props & {
+ inset?: boolean
+ variant?: "default" | "destructive"
}) {
return (
<MenuPrimitive.Item
@@ -96,7 +105,7 @@ function DropdownMenuItem({
function DropdownMenuSub({
...props
-}) {
+}: MenuPrimitive.SubmenuRoot.Props) {
return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />;
}
@@ -105,6 +114,8 @@ function DropdownMenuSubTrigger({
inset,
children,
...props
+}: MenuPrimitive.SubmenuTrigger.Props & {
+ inset?: boolean
}) {
return (
<MenuPrimitive.SubmenuTrigger
@@ -128,7 +139,7 @@ function DropdownMenuSubContent({
sideOffset = 0,
className,
...props
-}) {
+}: React.ComponentProps<typeof DropdownMenuContent>) {
return (
<DropdownMenuContent
data-slot="dropdown-menu-sub-content"
@@ -150,6 +161,8 @@ function DropdownMenuCheckboxItem({
checked,
inset,
...props
+}: MenuPrimitive.CheckboxItem.Props & {
+ inset?: boolean
}) {
return (
<MenuPrimitive.CheckboxItem
@@ -175,7 +188,7 @@ function DropdownMenuCheckboxItem({
function DropdownMenuRadioGroup({
...props
-}) {
+}: MenuPrimitive.RadioGroup.Props) {
return (<MenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />);
}
@@ -184,6 +197,8 @@ function DropdownMenuRadioItem({
children,
inset,
...props
+}: MenuPrimitive.RadioItem.Props & {
+ inset?: boolean
}) {
return (
<MenuPrimitive.RadioItem
@@ -209,7 +224,7 @@ function DropdownMenuRadioItem({
function DropdownMenuSeparator({
className,
...props
-}) {
+}: MenuPrimitive.Separator.Props) {
return (
<MenuPrimitive.Separator
data-slot="dropdown-menu-separator"
@@ -221,7 +236,7 @@ function DropdownMenuSeparator({
function DropdownMenuShortcut({
className,
...props
-}) {
+}: React.ComponentProps<"span">) {
return (
<span
data-slot="dropdown-menu-shortcut"
diff --git a/frontend/src/components/ui/empty.tsx b/frontend/src/components/ui/empty.tsx
index c351958..ab3f586 100644
--- a/frontend/src/components/ui/empty.tsx
+++ b/frontend/src/components/ui/empty.tsx
@@ -1,11 +1,12 @@
-import { cva } from "class-variance-authority";
+import type * as React from "react"
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils"
function Empty({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="empty"
@@ -20,7 +21,7 @@ function Empty({
function EmptyHeader({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="empty-header"
@@ -48,7 +49,7 @@ function EmptyMedia({
className,
variant = "default",
...props
-}) {
+}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {
return (
<div
data-slot="empty-icon"
@@ -61,7 +62,7 @@ function EmptyMedia({
function EmptyTitle({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="empty-title"
@@ -73,7 +74,7 @@ function EmptyTitle({
function EmptyDescription({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="empty-description"
@@ -88,7 +89,7 @@ function EmptyDescription({
function EmptyContent({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="empty-content"
diff --git a/frontend/src/components/ui/field.tsx b/frontend/src/components/ui/field.tsx
index 3af78b7..0984732 100644
--- a/frontend/src/components/ui/field.tsx
+++ b/frontend/src/components/ui/field.tsx
@@ -1,5 +1,6 @@
+import type * as React from "react"
import { useMemo } from "react"
-import { cva } from "class-variance-authority";
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils"
import { Label } from "@/components/ui/label"
@@ -8,7 +9,7 @@ import { Separator } from "@/components/ui/separator"
function FieldSet({
className,
...props
-}) {
+}: React.ComponentProps<"fieldset">) {
return (
<fieldset
data-slot="field-set"
@@ -24,7 +25,7 @@ function FieldLegend({
className,
variant = "legend",
...props
-}) {
+}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
return (
<legend
data-slot="field-legend"
@@ -40,7 +41,7 @@ function FieldLegend({
function FieldGroup({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="field-group"
@@ -71,7 +72,7 @@ function Field({
className,
orientation = "vertical",
...props
-}) {
+}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
return (
<div
role="group"
@@ -85,7 +86,7 @@ function Field({
function FieldContent({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="field-content"
@@ -97,7 +98,7 @@ function FieldContent({
function FieldLabel({
className,
...props
-}) {
+}: React.ComponentProps<typeof Label>) {
return (
<Label
data-slot="field-label"
@@ -113,7 +114,7 @@ function FieldLabel({
function FieldTitle({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="field-label"
@@ -128,7 +129,7 @@ function FieldTitle({
function FieldDescription({
className,
...props
-}) {
+}: React.ComponentProps<"p">) {
return (
<p
data-slot="field-description"
@@ -146,6 +147,8 @@ function FieldSeparator({
children,
className,
...props
+}: React.ComponentProps<"div"> & {
+ children?: React.ReactNode
}) {
return (
<div
@@ -173,6 +176,8 @@ function FieldError({
children,
errors,
...props
+}: React.ComponentProps<"div"> & {
+ errors?: Array<{ message?: string } | undefined>
}) {
const content = useMemo(() => {
if (children) {
diff --git a/frontend/src/components/ui/input-group.tsx b/frontend/src/components/ui/input-group.tsx
index 48d0727..5ad8649 100644
--- a/frontend/src/components/ui/input-group.tsx
+++ b/frontend/src/components/ui/input-group.tsx
@@ -1,7 +1,7 @@
"use client"
import * as React from "react"
-import { cva } from "class-variance-authority";
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
@@ -11,7 +11,7 @@ import { Textarea } from "@/components/ui/textarea"
function InputGroup({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="input-group"
@@ -49,7 +49,7 @@ function InputGroupAddon({
className,
align = "inline-start",
...props
-}) {
+}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
return (
<div
role="group"
@@ -57,7 +57,7 @@ function InputGroupAddon({
data-align={align}
className={cn(inputGroupAddonVariants({ align }), className)}
onClick={(e) => {
- if ((e.target).closest("button")) {
+ if ((e.target as HTMLElement).closest("button")) {
return
}
e.currentTarget.parentElement?.querySelector("input")?.focus()
@@ -87,7 +87,10 @@ function InputGroupButton({
variant = "ghost",
size = "xs",
...props
-}) {
+}: Omit<React.ComponentProps<typeof Button>, "size" | "type"> &
+ VariantProps<typeof inputGroupButtonVariants> & {
+ type?: "button" | "submit" | "reset"
+ }) {
return (
<Button
type={type}
@@ -101,7 +104,7 @@ function InputGroupButton({
function InputGroupText({
className,
...props
-}) {
+}: React.ComponentProps<"span">) {
return (
<span
className={cn(
@@ -115,7 +118,7 @@ function InputGroupText({
function InputGroupInput({
className,
...props
-}) {
+}: React.ComponentProps<"input">) {
return (
<Input
data-slot="input-group-control"
@@ -130,7 +133,7 @@ function InputGroupInput({
function InputGroupTextarea({
className,
...props
-}) {
+}: React.ComponentProps<"textarea">) {
return (
<Textarea
data-slot="input-group-control"
diff --git a/frontend/src/components/ui/input.tsx b/frontend/src/components/ui/input.tsx
index 8319e90..033abc7 100644
--- a/frontend/src/components/ui/input.tsx
+++ b/frontend/src/components/ui/input.tsx
@@ -7,7 +7,7 @@ function Input({
className,
type,
...props
-}) {
+}: React.ComponentProps<"input">) {
return (
<InputPrimitive
type={type}
diff --git a/frontend/src/components/ui/label.tsx b/frontend/src/components/ui/label.tsx
index 773076b..38c49f8 100644
--- a/frontend/src/components/ui/label.tsx
+++ b/frontend/src/components/ui/label.tsx
@@ -7,7 +7,7 @@ import { cn } from "@/lib/utils"
function Label({
className,
...props
-}) {
+}: React.ComponentProps<"label">) {
return (
<label
data-slot="label"
diff --git a/frontend/src/components/ui/pagination.tsx b/frontend/src/components/ui/pagination.tsx
index 1321da5..dd04a29 100644
--- a/frontend/src/components/ui/pagination.tsx
+++ b/frontend/src/components/ui/pagination.tsx
@@ -7,7 +7,7 @@ import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from "lucide-re
function Pagination({
className,
...props
-}) {
+}: React.ComponentProps<"nav">) {
return (
<nav
role="navigation"
@@ -21,7 +21,7 @@ function Pagination({
function PaginationContent({
className,
...props
-}) {
+}: React.ComponentProps<"ul">) {
return (
<ul
data-slot="pagination-content"
@@ -32,16 +32,21 @@ function PaginationContent({
function PaginationItem({
...props
-}) {
+}: React.ComponentProps<"li">) {
return <li data-slot="pagination-item" {...props} />;
}
+type PaginationLinkProps = {
+ isActive?: boolean
+} & Pick<React.ComponentProps<typeof Button>, "size"> &
+ React.ComponentProps<"a">
+
function PaginationLink({
className,
isActive,
size = "icon",
...props
-}) {
+}: PaginationLinkProps) {
return (
<Button
variant={isActive ? "outline" : "ghost"}
@@ -62,7 +67,7 @@ function PaginationPrevious({
className,
text = "Previous",
...props
-}) {
+}: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
return (
<PaginationLink
aria-label="Go to previous page"
@@ -79,7 +84,7 @@ function PaginationNext({
className,
text = "Next",
...props
-}) {
+}: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
return (
<PaginationLink
aria-label="Go to next page"
@@ -95,7 +100,7 @@ function PaginationNext({
function PaginationEllipsis({
className,
...props
-}) {
+}: React.ComponentProps<"span">) {
return (
<span
aria-hidden
diff --git a/frontend/src/components/ui/popover.tsx b/frontend/src/components/ui/popover.tsx
index 1752d87..48bbd6e 100644
--- a/frontend/src/components/ui/popover.tsx
+++ b/frontend/src/components/ui/popover.tsx
@@ -7,13 +7,13 @@ import { cn } from "@/lib/utils"
function Popover({
...props
-}) {
+}: PopoverPrimitive.Root.Props) {
return <PopoverPrimitive.Root data-slot="popover" {...props} />;
}
function PopoverTrigger({
...props
-}) {
+}: PopoverPrimitive.Trigger.Props) {
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
}
@@ -24,7 +24,11 @@ function PopoverContent({
side = "bottom",
sideOffset = 4,
...props
-}) {
+}: PopoverPrimitive.Popup.Props &
+ Pick<
+ PopoverPrimitive.Positioner.Props,
+ "align" | "alignOffset" | "side" | "sideOffset"
+ >) {
return (
<PopoverPrimitive.Portal>
<PopoverPrimitive.Positioner
@@ -48,7 +52,7 @@ function PopoverContent({
function PopoverHeader({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="popover-header"
@@ -60,7 +64,7 @@ function PopoverHeader({
function PopoverTitle({
className,
...props
-}) {
+}: PopoverPrimitive.Title.Props) {
return (
<PopoverPrimitive.Title
data-slot="popover-title"
@@ -72,7 +76,7 @@ function PopoverTitle({
function PopoverDescription({
className,
...props
-}) {
+}: PopoverPrimitive.Description.Props) {
return (
<PopoverPrimitive.Description
data-slot="popover-description"
diff --git a/frontend/src/components/ui/progress.tsx b/frontend/src/components/ui/progress.tsx
index d9833cd..bfa9d0c 100644
--- a/frontend/src/components/ui/progress.tsx
+++ b/frontend/src/components/ui/progress.tsx
@@ -7,7 +7,7 @@ function Progress({
children,
value,
...props
-}) {
+}: ProgressPrimitive.Root.Props) {
return (
<ProgressPrimitive.Root
value={value}
@@ -25,7 +25,7 @@ function Progress({
function ProgressTrack({
className,
...props
-}) {
+}: ProgressPrimitive.Track.Props) {
return (
<ProgressPrimitive.Track
className={cn(
@@ -40,7 +40,7 @@ function ProgressTrack({
function ProgressIndicator({
className,
...props
-}) {
+}: ProgressPrimitive.Indicator.Props) {
return (
<ProgressPrimitive.Indicator
data-slot="progress-indicator"
@@ -52,7 +52,7 @@ function ProgressIndicator({
function ProgressLabel({
className,
...props
-}) {
+}: ProgressPrimitive.Label.Props) {
return (
<ProgressPrimitive.Label
className={cn("text-sm font-medium", className)}
@@ -64,7 +64,7 @@ function ProgressLabel({
function ProgressValue({
className,
...props
-}) {
+}: ProgressPrimitive.Value.Props) {
return (
<ProgressPrimitive.Value
className={cn("ml-auto text-sm text-muted-foreground tabular-nums", className)}
diff --git a/frontend/src/components/ui/scroll-area.tsx b/frontend/src/components/ui/scroll-area.tsx
index 24ec853..3b5044e 100644
--- a/frontend/src/components/ui/scroll-area.tsx
+++ b/frontend/src/components/ui/scroll-area.tsx
@@ -7,7 +7,7 @@ function ScrollArea({
className,
children,
...props
-}) {
+}: ScrollAreaPrimitive.Root.Props) {
return (
<ScrollAreaPrimitive.Root data-slot="scroll-area" className={cn("relative", className)} {...props}>
<ScrollAreaPrimitive.Viewport
@@ -25,7 +25,7 @@ function ScrollBar({
className,
orientation = "vertical",
...props
-}) {
+}: ScrollAreaPrimitive.Scrollbar.Props) {
return (
<ScrollAreaPrimitive.Scrollbar
data-slot="scroll-area-scrollbar"
diff --git a/frontend/src/components/ui/select.tsx b/frontend/src/components/ui/select.tsx
index 83f286e..fa790e2 100644
--- a/frontend/src/components/ui/select.tsx
+++ b/frontend/src/components/ui/select.tsx
@@ -9,7 +9,7 @@ const Select = SelectPrimitive.Root
function SelectGroup({
className,
...props
-}) {
+}: SelectPrimitive.Group.Props) {
return (
<SelectPrimitive.Group
data-slot="select-group"
@@ -21,7 +21,7 @@ function SelectGroup({
function SelectValue({
className,
...props
-}) {
+}: SelectPrimitive.Value.Props) {
return (
<SelectPrimitive.Value
data-slot="select-value"
@@ -35,6 +35,8 @@ function SelectTrigger({
size = "default",
children,
...props
+}: SelectPrimitive.Trigger.Props & {
+ size?: "sm" | "default"
}) {
return (
<SelectPrimitive.Trigger
@@ -63,7 +65,11 @@ function SelectContent({
alignOffset = 0,
alignItemWithTrigger = true,
...props
-}) {
+}: SelectPrimitive.Popup.Props &
+ Pick<
+ SelectPrimitive.Positioner.Props,
+ "align" | "alignOffset" | "side" | "sideOffset" | "alignItemWithTrigger"
+ >) {
return (
<SelectPrimitive.Portal>
<SelectPrimitive.Positioner
@@ -93,7 +99,7 @@ function SelectContent({
function SelectLabel({
className,
...props
-}) {
+}: SelectPrimitive.GroupLabel.Props) {
return (
<SelectPrimitive.GroupLabel
data-slot="select-label"
@@ -106,7 +112,7 @@ function SelectItem({
className,
children,
...props
-}) {
+}: SelectPrimitive.Item.Props) {
return (
<SelectPrimitive.Item
data-slot="select-item"
@@ -132,7 +138,7 @@ function SelectItem({
function SelectSeparator({
className,
...props
-}) {
+}: SelectPrimitive.Separator.Props) {
return (
<SelectPrimitive.Separator
data-slot="select-separator"
@@ -144,7 +150,7 @@ function SelectSeparator({
function SelectScrollUpButton({
className,
...props
-}) {
+}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {
return (
<SelectPrimitive.ScrollUpArrow
data-slot="select-scroll-up-button"
@@ -161,7 +167,7 @@ function SelectScrollUpButton({
function SelectScrollDownButton({
className,
...props
-}) {
+}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {
return (
<SelectPrimitive.ScrollDownArrow
data-slot="select-scroll-down-button"
diff --git a/frontend/src/components/ui/separator.tsx b/frontend/src/components/ui/separator.tsx
index 45c56c2..47eece7 100644
--- a/frontend/src/components/ui/separator.tsx
+++ b/frontend/src/components/ui/separator.tsx
@@ -6,7 +6,7 @@ function Separator({
className,
orientation = "horizontal",
...props
-}) {
+}: SeparatorPrimitive.Props) {
return (
<SeparatorPrimitive
data-slot="separator"
diff --git a/frontend/src/components/ui/sheet.tsx b/frontend/src/components/ui/sheet.tsx
index 7c1c900..2723475 100644
--- a/frontend/src/components/ui/sheet.tsx
+++ b/frontend/src/components/ui/sheet.tsx
@@ -7,32 +7,32 @@ import { XIcon } from "lucide-react"
function Sheet({
...props
-}) {
+}: SheetPrimitive.Root.Props) {
return <SheetPrimitive.Root data-slot="sheet" {...props} />;
}
function SheetTrigger({
...props
-}) {
+}: SheetPrimitive.Trigger.Props) {
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;
}
function SheetClose({
...props
-}) {
+}: SheetPrimitive.Close.Props) {
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
}
function SheetPortal({
...props
-}) {
+}: SheetPrimitive.Portal.Props) {
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
}
function SheetOverlay({
className,
...props
-}) {
+}: SheetPrimitive.Backdrop.Props) {
return (
<SheetPrimitive.Backdrop
data-slot="sheet-overlay"
@@ -50,6 +50,9 @@ function SheetContent({
side = "right",
showCloseButton = true,
...props
+}: SheetPrimitive.Popup.Props & {
+ side?: "top" | "right" | "bottom" | "left"
+ showCloseButton?: boolean
}) {
return (
<SheetPortal>
@@ -81,7 +84,7 @@ function SheetContent({
function SheetHeader({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="sheet-header"
@@ -93,7 +96,7 @@ function SheetHeader({
function SheetFooter({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="sheet-footer"
@@ -105,7 +108,7 @@ function SheetFooter({
function SheetTitle({
className,
...props
-}) {
+}: SheetPrimitive.Title.Props) {
return (
<SheetPrimitive.Title
data-slot="sheet-title"
@@ -117,7 +120,7 @@ function SheetTitle({
function SheetDescription({
className,
...props
-}) {
+}: SheetPrimitive.Description.Props) {
return (
<SheetPrimitive.Description
data-slot="sheet-description"
diff --git a/frontend/src/components/ui/sidebar.tsx b/frontend/src/components/ui/sidebar.tsx
index 4da054d..78cb4cc 100644
--- a/frontend/src/components/ui/sidebar.tsx
+++ b/frontend/src/components/ui/sidebar.tsx
@@ -2,7 +2,7 @@
import * as React from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
-import { cva } from "class-variance-authority";
+import { cva, type VariantProps } from "class-variance-authority";
import { useIsMobile } from "@/hooks/use-mobile"
import { cn } from "@/lib/utils"
@@ -32,7 +32,17 @@ const SIDEBAR_WIDTH_MOBILE = "18rem"
const SIDEBAR_WIDTH_ICON = "3.625rem"
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
-const SidebarContext = React.createContext(null)
+interface SidebarContextValue {
+ state: "expanded" | "collapsed"
+ open: boolean
+ setOpen: (value: boolean | ((value: boolean) => boolean)) => void
+ openMobile: boolean
+ setOpenMobile: React.Dispatch<React.SetStateAction<boolean>>
+ isMobile: boolean
+ toggleSidebar: () => void
+}
+
+const SidebarContext = React.createContext<SidebarContextValue | null>(null)
function useSidebar() {
const context = React.useContext(SidebarContext)
@@ -51,6 +61,10 @@ function SidebarProvider({
style,
children,
...props
+}: React.ComponentProps<"div"> & {
+ defaultOpen?: boolean
+ open?: boolean
+ onOpenChange?: (open: boolean) => void
}) {
const isMobile = useIsMobile()
const [openMobile, setOpenMobile] = React.useState(false)
@@ -59,7 +73,7 @@ function SidebarProvider({
// We use openProp and setOpenProp for control from outside the component.
const [_open, _setOpen] = React.useState(defaultOpen)
const open = openProp ?? _open
- const setOpen = React.useCallback((value) => {
+ const setOpen = React.useCallback((value: boolean | ((value: boolean) => boolean)) => {
const openState = typeof value === "function" ? value(open) : value
if (setOpenProp) {
setOpenProp(openState)
@@ -78,7 +92,7 @@ function SidebarProvider({
// Adds a keyboard shortcut to toggle the sidebar.
React.useEffect(() => {
- const handleKeyDown = (event) => {
+ const handleKeyDown = (event: KeyboardEvent) => {
if (
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
(event.metaKey || event.ctrlKey)
@@ -96,7 +110,7 @@ function SidebarProvider({
// This makes it easier to style the sidebar with Tailwind classes.
const state = open ? "expanded" : "collapsed"
- const contextValue = React.useMemo(() => ({
+ const contextValue = React.useMemo<SidebarContextValue>(() => ({
state,
open,
setOpen,
@@ -115,7 +129,7 @@ function SidebarProvider({
"--sidebar-width": SIDEBAR_WIDTH,
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
...style
- }
+ } as React.CSSProperties
}
className={cn(
"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
@@ -136,6 +150,10 @@ function Sidebar({
children,
dir,
...props
+}: React.ComponentProps<"div"> & {
+ side?: "left" | "right"
+ variant?: "sidebar" | "floating" | "inset"
+ collapsible?: "offcanvas" | "icon" | "none"
}) {
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
@@ -165,7 +183,7 @@ function Sidebar({
style={
{
"--sidebar-width": SIDEBAR_WIDTH_MOBILE
- }
+ } as React.CSSProperties
}
side={side}>
<SheetHeader className="sr-only">
@@ -224,7 +242,7 @@ function SidebarTrigger({
className,
onClick,
...props
-}) {
+}: React.ComponentProps<typeof Button>) {
const { toggleSidebar } = useSidebar()
return (
@@ -248,7 +266,7 @@ function SidebarTrigger({
function SidebarRail({
className,
...props
-}) {
+}: React.ComponentProps<"button">) {
const { toggleSidebar } = useSidebar()
return (
@@ -275,7 +293,7 @@ function SidebarRail({
function SidebarInset({
className,
...props
-}) {
+}: React.ComponentProps<"main">) {
return (
<main
data-slot="sidebar-inset"
@@ -290,7 +308,7 @@ function SidebarInset({
function SidebarInput({
className,
...props
-}) {
+}: React.ComponentProps<typeof Input>) {
return (
<Input
data-slot="sidebar-input"
@@ -303,7 +321,7 @@ function SidebarInput({
function SidebarHeader({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="sidebar-header"
@@ -316,7 +334,7 @@ function SidebarHeader({
function SidebarFooter({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="sidebar-footer"
@@ -329,7 +347,7 @@ function SidebarFooter({
function SidebarSeparator({
className,
...props
-}) {
+}: React.ComponentProps<typeof Separator>) {
return (
<Separator
data-slot="sidebar-separator"
@@ -342,7 +360,7 @@ function SidebarSeparator({
function SidebarContent({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="sidebar-content"
@@ -358,7 +376,7 @@ function SidebarContent({
function SidebarGroup({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="sidebar-group"
@@ -372,7 +390,7 @@ function SidebarGroupLabel({
className,
render,
...props
-}) {
+}: useRender.ComponentProps<"div"> & React.ComponentProps<"div">) {
return useRender({
defaultTagName: "div",
props: mergeProps({
@@ -393,7 +411,7 @@ function SidebarGroupAction({
className,
render,
...props
-}) {
+}: useRender.ComponentProps<"button"> & React.ComponentProps<"button">) {
return useRender({
defaultTagName: "button",
props: mergeProps({
@@ -413,7 +431,7 @@ function SidebarGroupAction({
function SidebarGroupContent({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="sidebar-group-content"
@@ -426,7 +444,7 @@ function SidebarGroupContent({
function SidebarMenu({
className,
...props
-}) {
+}: React.ComponentProps<"ul">) {
return (
<ul
data-slot="sidebar-menu"
@@ -439,7 +457,7 @@ function SidebarMenu({
function SidebarMenuItem({
className,
...props
-}) {
+}: React.ComponentProps<"li">) {
return (
<li
data-slot="sidebar-menu-item"
@@ -479,7 +497,11 @@ function SidebarMenuButton({
tooltip,
className,
...props
-}) {
+}: useRender.ComponentProps<"button"> &
+ React.ComponentProps<"button"> & {
+ isActive?: boolean
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
const { isMobile, state } = useSidebar()
const comp = useRender({
defaultTagName: "button",
@@ -522,7 +544,10 @@ function SidebarMenuAction({
render,
showOnHover = false,
...props
-}) {
+}: useRender.ComponentProps<"button"> &
+ React.ComponentProps<"button"> & {
+ showOnHover?: boolean
+ }) {
return useRender({
defaultTagName: "button",
props: mergeProps({
@@ -544,7 +569,7 @@ function SidebarMenuAction({
function SidebarMenuBadge({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="sidebar-menu-badge"
@@ -561,6 +586,8 @@ function SidebarMenuSkeleton({
className,
showIcon = false,
...props
+}: React.ComponentProps<"div"> & {
+ showIcon?: boolean
}) {
// Random width between 50 to 90%.
const [width] = React.useState(() => {
@@ -582,7 +609,7 @@ function SidebarMenuSkeleton({
style={
{
"--skeleton-width": width
- }
+ } as React.CSSProperties
} />
</div>
);
@@ -591,7 +618,7 @@ function SidebarMenuSkeleton({
function SidebarMenuSub({
className,
...props
-}) {
+}: React.ComponentProps<"ul">) {
return (
<ul
data-slot="sidebar-menu-sub"
@@ -607,7 +634,7 @@ function SidebarMenuSub({
function SidebarMenuSubItem({
className,
...props
-}) {
+}: React.ComponentProps<"li">) {
return (
<li
data-slot="sidebar-menu-sub-item"
@@ -623,7 +650,11 @@ function SidebarMenuSubButton({
isActive = false,
className,
...props
-}) {
+}: useRender.ComponentProps<"a"> &
+ React.ComponentProps<"a"> & {
+ size?: "sm" | "md"
+ isActive?: boolean
+ }) {
return useRender({
defaultTagName: "a",
props: mergeProps({
diff --git a/frontend/src/components/ui/skeleton.tsx b/frontend/src/components/ui/skeleton.tsx
index bb70114..f649863 100644
--- a/frontend/src/components/ui/skeleton.tsx
+++ b/frontend/src/components/ui/skeleton.tsx
@@ -1,9 +1,10 @@
+import type * as React from "react"
import { cn } from "@/lib/utils"
function Skeleton({
className,
...props
-}) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="skeleton"
diff --git a/frontend/src/components/ui/sonner.tsx b/frontend/src/components/ui/sonner.tsx
index 0ceecbc..159ba5d 100644
--- a/frontend/src/components/ui/sonner.tsx
+++ b/frontend/src/components/ui/sonner.tsx
@@ -1,17 +1,18 @@
"use client"
+import type * as React from "react"
import { useTheme } from "next-themes"
-import { Toaster as Sonner } from "sonner";
+import { Toaster as Sonner, type ToasterProps } from "sonner";
import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react"
const Toaster = ({
...props
-}) => {
+}: ToasterProps) => {
const { theme = "system" } = useTheme()
return (
<Sonner
- theme={theme}
+ theme={theme as ToasterProps["theme"]}
className="toaster group"
icons={{
success: (
@@ -48,7 +49,7 @@ const Toaster = ({
"--info-bg": "var(--info-soft)",
"--info-text": "var(--info)",
"--info-border": "color-mix(in oklab, var(--info) 30%, transparent)"
- }
+ } as React.CSSProperties
}
toastOptions={{
classNames: {
diff --git a/frontend/src/components/ui/spinner.tsx b/frontend/src/components/ui/spinner.tsx
index 0d4e0e2..a96a654 100644
--- a/frontend/src/components/ui/spinner.tsx
+++ b/frontend/src/components/ui/spinner.tsx
@@ -1,10 +1,11 @@
+import type * as React from "react"
import { cn } from "@/lib/utils"
import { Loader2Icon } from "lucide-react"
function Spinner({
className,
...props
-}) {
+}: React.ComponentProps<"svg">) {
return (
<Loader2Icon
role="status"
diff --git a/frontend/src/components/ui/switch.tsx b/frontend/src/components/ui/switch.tsx
index 8bf23bc..91562c0 100644
--- a/frontend/src/components/ui/switch.tsx
+++ b/frontend/src/components/ui/switch.tsx
@@ -6,6 +6,8 @@ function Switch({
className,
size = "default",
...props
+}: SwitchPrimitive.Root.Props & {
+ size?: "sm" | "default"
}) {
return (
<SwitchPrimitive.Root
diff --git a/frontend/src/components/ui/table.tsx b/frontend/src/components/ui/table.tsx
index 8074002..f5ad0ed 100644
--- a/frontend/src/components/ui/table.tsx
+++ b/frontend/src/components/ui/table.tsx
@@ -5,7 +5,7 @@ import { cn } from "@/lib/utils"
function Table({
className,
...props
-}) {
+}: React.ComponentProps<"table">) {
return (
<div data-slot="table-container" className="relative w-full overflow-x-auto">
<table
@@ -19,7 +19,7 @@ function Table({
function TableHeader({
className,
...props
-}) {
+}: React.ComponentProps<"thead">) {
return (
<thead
data-slot="table-header"
@@ -31,7 +31,7 @@ function TableHeader({
function TableBody({
className,
...props
-}) {
+}: React.ComponentProps<"tbody">) {
return (
<tbody
data-slot="table-body"
@@ -43,7 +43,7 @@ function TableBody({
function TableFooter({
className,
...props
-}) {
+}: React.ComponentProps<"tfoot">) {
return (
<tfoot
data-slot="table-footer"
@@ -55,7 +55,7 @@ function TableFooter({
function TableRow({
className,
...props
-}) {
+}: React.ComponentProps<"tr">) {
return (
<tr
data-slot="table-row"
@@ -70,7 +70,7 @@ function TableRow({
function TableHead({
className,
...props
-}) {
+}: React.ComponentProps<"th">) {
return (
<th
data-slot="table-head"
@@ -85,7 +85,7 @@ function TableHead({
function TableCell({
className,
...props
-}) {
+}: React.ComponentProps<"td">) {
return (
<td
data-slot="table-cell"
@@ -100,7 +100,7 @@ function TableCell({
function TableCaption({
className,
...props
-}) {
+}: React.ComponentProps<"caption">) {
return (
<caption
data-slot="table-caption"
diff --git a/frontend/src/components/ui/tabs.tsx b/frontend/src/components/ui/tabs.tsx
index 678c2e8..4e067c7 100644
--- a/frontend/src/components/ui/tabs.tsx
+++ b/frontend/src/components/ui/tabs.tsx
@@ -1,7 +1,7 @@
"use client"
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs"
-import { cva } from "class-variance-authority";
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils"
@@ -9,7 +9,7 @@ function Tabs({
className,
orientation = "horizontal",
...props
-}) {
+}: TabsPrimitive.Root.Props) {
return (
<TabsPrimitive.Root
data-slot="tabs"
@@ -38,7 +38,7 @@ function TabsList({
className,
variant = "default",
...props
-}) {
+}: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>) {
return (
<TabsPrimitive.List
data-slot="tabs-list"
@@ -51,7 +51,7 @@ function TabsList({
function TabsTrigger({
className,
...props
-}) {
+}: TabsPrimitive.Tab.Props) {
return (
<TabsPrimitive.Tab
data-slot="tabs-trigger"
@@ -68,7 +68,7 @@ function TabsTrigger({
function TabsContent({
className,
...props
-}) {
+}: TabsPrimitive.Panel.Props) {
return (
<TabsPrimitive.Panel
data-slot="tabs-content"
diff --git a/frontend/src/components/ui/textarea.tsx b/frontend/src/components/ui/textarea.tsx
index 27982bb..9a06db3 100644
--- a/frontend/src/components/ui/textarea.tsx
+++ b/frontend/src/components/ui/textarea.tsx
@@ -5,7 +5,7 @@ import { cn } from "@/lib/utils"
function Textarea({
className,
...props
-}) {
+}: React.ComponentProps<"textarea">) {
return (
<textarea
data-slot="textarea"
diff --git a/frontend/src/components/ui/toggle-group.tsx b/frontend/src/components/ui/toggle-group.tsx
index a8fa781..714cf1a 100644
--- a/frontend/src/components/ui/toggle-group.tsx
+++ b/frontend/src/components/ui/toggle-group.tsx
@@ -4,8 +4,14 @@ import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group
import { cn } from "@/lib/utils"
import { toggleVariants } from "@/components/ui/toggle"
+import type { VariantProps } from "class-variance-authority"
-const ToggleGroupContext = React.createContext({
+interface ToggleGroupContextValue extends VariantProps<typeof toggleVariants> {
+ spacing?: number
+ orientation?: "horizontal" | "vertical"
+}
+
+const ToggleGroupContext = React.createContext<ToggleGroupContextValue>({
size: "default",
variant: "default",
spacing: 2,
@@ -20,7 +26,11 @@ function ToggleGroup({
orientation = "horizontal",
children,
...props
-}) {
+}: ToggleGroupPrimitive.Props &
+ VariantProps<typeof toggleVariants> & {
+ spacing?: number
+ orientation?: "horizontal" | "vertical"
+ }) {
return (
<ToggleGroupPrimitive
data-slot="toggle-group"
@@ -30,7 +40,7 @@ function ToggleGroup({
data-orientation={orientation}
style={{
"--gap": spacing
- }}
+ } as React.CSSProperties}
className={cn(
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",
className
@@ -49,7 +59,7 @@ function ToggleGroupItem({
variant = "default",
size = "default",
...props
-}) {
+}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
const context = React.useContext(ToggleGroupContext)
return (
diff --git a/frontend/src/components/ui/toggle.tsx b/frontend/src/components/ui/toggle.tsx
index 18ff385..eadcddd 100644
--- a/frontend/src/components/ui/toggle.tsx
+++ b/frontend/src/components/ui/toggle.tsx
@@ -1,7 +1,7 @@
"use client"
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
-import { cva } from "class-variance-authority";
+import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils"
@@ -32,7 +32,7 @@ function Toggle({
variant = "default",
size = "default",
...props
-}) {
+}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
return (
<TogglePrimitive
data-slot="toggle"
diff --git a/frontend/src/components/ui/tooltip.tsx b/frontend/src/components/ui/tooltip.tsx
index 863fd9e..eee14f8 100644
--- a/frontend/src/components/ui/tooltip.tsx
+++ b/frontend/src/components/ui/tooltip.tsx
@@ -7,19 +7,19 @@ import { cn } from "@/lib/utils"
function TooltipProvider({
delay = 0,
...props
-}) {
+}: TooltipPrimitive.Provider.Props) {
return (<TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delay} {...props} />);
}
function Tooltip({
...props
-}) {
+}: TooltipPrimitive.Root.Props) {
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />;
}
function TooltipTrigger({
...props
-}) {
+}: TooltipPrimitive.Trigger.Props) {
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
}
@@ -31,7 +31,11 @@ function TooltipContent({
alignOffset = 0,
children,
...props
-}) {
+}: TooltipPrimitive.Popup.Props &
+ Pick<
+ TooltipPrimitive.Positioner.Props,
+ "align" | "alignOffset" | "side" | "sideOffset"
+ >) {
return (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Positioner