From 1bee09e6880014acc7b3b7739e99a635e1bde9b7 Mon Sep 17 00:00:00 2001 From: Marko Trebizan Date: Tue, 5 Aug 2025 12:59:18 +0200 Subject: [PATCH] formatter and export icons --- biome.json | 12 +- package.json | 153 ++-- src/components/accordion.tsx | 2 +- src/components/alert-dialog.tsx | 2 +- src/components/alert.tsx | 2 +- src/components/avatar.tsx | 2 +- src/components/badge.tsx | 2 +- src/components/breadcrumb.tsx | 3 +- src/components/calendar.tsx | 2 +- src/components/card.tsx | 2 +- src/components/carousel.tsx | 389 +++++---- src/components/chart.tsx | 585 +++++++------- src/components/checkbox.tsx | 2 +- src/components/command.tsx | 2 +- src/components/context-menu.tsx | 2 +- src/components/dialog.tsx | 2 +- src/components/drawer.tsx | 2 +- src/components/dropdown-menu.tsx | 2 +- src/components/form.tsx | 2 +- src/components/hover-card.tsx | 2 +- src/components/input-otp.tsx | 114 +-- src/components/input.tsx | 2 +- src/components/label.tsx | 2 +- src/components/menubar.tsx | 2 +- src/components/navigation-menu.tsx | 2 +- src/components/pagination.tsx | 188 +++-- src/components/popover.tsx | 2 +- src/components/progress.tsx | 2 +- src/components/radio-group.tsx | 2 +- src/components/resizable.tsx | 2 +- src/components/scroll-area.tsx | 2 +- src/components/select.tsx | 2 +- src/components/separator.tsx | 2 +- src/components/sheet.tsx | 2 +- src/components/sidebar.tsx | 1199 ++++++++++++++-------------- src/components/switch.tsx | 2 +- src/components/table.tsx | 2 +- src/components/tabs.tsx | 2 +- src/components/textarea.tsx | 2 +- src/components/toggle-group.tsx | 2 +- src/components/toggle.tsx | 2 +- src/components/tooltip.tsx | 2 +- src/icons.ts | 2 + src/lib/utils.ts | 6 +- src/styles.ts | 2 - 45 files changed, 1365 insertions(+), 1356 deletions(-) create mode 100644 src/icons.ts diff --git a/biome.json b/biome.json index 7f47e82..9229e0f 100644 --- a/biome.json +++ b/biome.json @@ -15,7 +15,17 @@ "linter": { "enabled": true, "rules": { - "recommended": true + "recommended": true, + "correctness": { + "noUnusedImports": "error" + }, + "suspicious": { + "noExplicitAny": "warn", + "noArrayIndexKey": "warn" + }, + "a11y": { + "noSvgWithoutTitle": "warn" + } } }, "javascript": { diff --git a/package.json b/package.json index 10eb18e..744242a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,11 @@ "import": "./dist/*.js", "require": "./dist/*.cjs" }, + "./icons": { + "types": "./dist/icons.d.ts", + "import": "./dist/icons.js", + "require": "./dist/icons.cjs" + }, "./ui.css": "./dist/ui.css" }, "scripts": { @@ -24,90 +29,90 @@ "build-storybook": "storybook build" }, "dependencies": { - "@hookform/resolvers": "^5.2.1", - "@radix-ui/react-accordion": "^1.2.11", - "@radix-ui/react-alert-dialog": "^1.1.14", - "@radix-ui/react-aspect-ratio": "^1.1.7", - "@radix-ui/react-avatar": "^1.1.10", - "@radix-ui/react-checkbox": "^1.3.2", - "@radix-ui/react-collapsible": "^1.1.11", - "@radix-ui/react-context-menu": "^2.2.15", - "@radix-ui/react-dialog": "^1.1.14", - "@radix-ui/react-dropdown-menu": "^2.1.15", - "@radix-ui/react-hover-card": "^1.1.14", - "@radix-ui/react-label": "^2.1.7", - "@radix-ui/react-menubar": "^1.1.15", - "@radix-ui/react-navigation-menu": "^1.2.13", - "@radix-ui/react-popover": "^1.1.14", - "@radix-ui/react-progress": "^1.1.7", - "@radix-ui/react-radio-group": "^1.3.7", - "@radix-ui/react-scroll-area": "^1.2.9", - "@radix-ui/react-select": "^2.2.5", - "@radix-ui/react-separator": "^1.1.7", - "@radix-ui/react-slider": "^1.3.5", - "@radix-ui/react-slot": "^1.2.3", - "@radix-ui/react-switch": "^1.2.5", - "@radix-ui/react-tabs": "^1.1.12", - "@radix-ui/react-toggle": "^1.1.9", - "@radix-ui/react-toggle-group": "^1.1.10", - "@radix-ui/react-tooltip": "^1.2.7", - "class-variance-authority": "^0.7.1", - "clsx": "^2.1.1", - "cmdk": "^1.1.1", - "date-fns": "^4.1.0", - "embla-carousel-react": "^8.6.0", - "input-otp": "^1.4.2", - "lucide-react": "^0.534.0", - "next-themes": "^0.4.6", - "react-day-picker": "^9.8.1", - "react-hook-form": "^7.61.1", - "react-resizable-panels": "^3.0.4", + "@hookform/resolvers": "5.2.1", + "@radix-ui/react-accordion": "1.2.11", + "@radix-ui/react-alert-dialog": "1.1.14", + "@radix-ui/react-aspect-ratio": "1.1.7", + "@radix-ui/react-avatar": "1.1.10", + "@radix-ui/react-checkbox": "1.3.2", + "@radix-ui/react-collapsible": "1.1.11", + "@radix-ui/react-context-menu": "2.2.15", + "@radix-ui/react-dialog": "1.1.14", + "@radix-ui/react-dropdown-menu": "2.1.15", + "@radix-ui/react-hover-card": "1.1.14", + "@radix-ui/react-label": "2.1.7", + "@radix-ui/react-menubar": "1.1.15", + "@radix-ui/react-navigation-menu": "1.2.13", + "@radix-ui/react-popover": "1.1.14", + "@radix-ui/react-progress": "1.1.7", + "@radix-ui/react-radio-group": "1.3.7", + "@radix-ui/react-scroll-area": "1.2.9", + "@radix-ui/react-select": "2.2.5", + "@radix-ui/react-separator": "1.1.7", + "@radix-ui/react-slider": "1.3.5", + "@radix-ui/react-slot": "1.2.3", + "@radix-ui/react-switch": "1.2.5", + "@radix-ui/react-tabs": "1.1.12", + "@radix-ui/react-toggle": "1.1.9", + "@radix-ui/react-toggle-group": "1.1.10", + "@radix-ui/react-tooltip": "1.2.7", + "class-variance-authority": "0.7.1", + "clsx": "2.1.1", + "cmdk": "1.1.1", + "date-fns": "4.1.0", + "embla-carousel-react": "8.6.0", + "input-otp": "1.4.2", + "lucide-react": "0.534.0", + "next-themes": "0.4.6", + "react-day-picker": "9.8.1", + "react-hook-form": "7.61.1", + "react-resizable-panels": "3.0.4", "recharts": "2.15.4", - "sonner": "^2.0.6", - "vaul": "^1.1.2", - "zod": "^4.0.14" + "sonner": "2.0.6", + "vaul": "1.1.2", + "zod": "4.0.14" }, "peerDependencies": { - "tailwind-merge": "^3.3.1", - "tailwindcss": "^4.1.11", - "react": "^19.0.0", - "react-dom": "^19.0.0" + "tailwind-merge": "3.3.1", + "tailwindcss": "4.1.11", + "react": "19.1.0", + "react-dom": "19.1.0" }, "publishConfig": { "access": "public" }, "devDependencies": { "@biomejs/biome": "2.1.2", - "@chromatic-com/storybook": "^4.0.1", - "@eslint/js": "^9.30.1", - "@storybook/addon-a11y": "^9.0.18", - "@storybook/addon-docs": "^9.0.18", - "@storybook/addon-onboarding": "^9.0.18", - "@storybook/addon-vitest": "^9.0.18", - "@storybook/builder-vite": "^9.0.18", - "@storybook/react-vite": "^9.0.18", - "@tailwindcss/typography": "^0.5.16", - "@tailwindcss/vite": "^4.1.11", + "@chromatic-com/storybook": "4.0.1", + "@eslint/js": "9.30.1", + "@storybook/addon-a11y": "9.0.18", + "@storybook/addon-docs": "9.0.18", + "@storybook/addon-onboarding": "9.0.18", + "@storybook/addon-vitest": "9.0.18", + "@storybook/builder-vite": "9.0.18", + "@storybook/react-vite": "9.0.18", + "@tailwindcss/typography": "0.5.16", + "@tailwindcss/vite": "4.1.11", "@types/bun": "latest", - "@types/glob": "^9.0.0", - "@types/node": "^24.1.0", - "@types/react": "^19.1.8", - "@types/react-dom": "^19.1.6", - "@vitejs/plugin-react": "^4.6.0", - "@vitest/browser": "^3.2.4", - "@vitest/coverage-v8": "^3.2.4", - "eslint": "^9.30.1", - "eslint-plugin-react-hooks": "^5.2.0", - "eslint-plugin-react-refresh": "^0.4.20", - "eslint-plugin-storybook": "^9.0.18", - "glob": "^11.0.3", - "globals": "^16.3.0", - "playwright": "^1.54.1", - "storybook": "^9.0.18", - "tw-animate-css": "^1.3.6", + "@types/glob": "9.0.0", + "@types/node": "24.1.0", + "@types/react": "19.1.8", + "@types/react-dom": "19.1.6", + "@vitejs/plugin-react": "4.6.0", + "@vitest/browser": "3.2.4", + "@vitest/coverage-v8": "3.2.4", + "eslint": "9.30.1", + "eslint-plugin-react-hooks": "5.2.0", + "eslint-plugin-react-refresh": "0.4.20", + "eslint-plugin-storybook": "9.0.18", + "glob": "11.0.3", + "globals": "16.3.0", + "playwright": "1.54.1", + "storybook": "9.0.18", + "tw-animate-css": "1.3.6", "typescript": "~5.8.3", - "typescript-eslint": "^8.35.1", - "vite": "^7.0.4", - "vitest": "^3.2.4" + "typescript-eslint": "8.35.1", + "vite": "7.0.4", + "vitest": "3.2.4" } } diff --git a/src/components/accordion.tsx b/src/components/accordion.tsx index d21b65f..9d6b8f4 100644 --- a/src/components/accordion.tsx +++ b/src/components/accordion.tsx @@ -1,4 +1,4 @@ -import * as React from "react" +import type * as React from "react" import * as AccordionPrimitive from "@radix-ui/react-accordion" import { ChevronDownIcon } from "lucide-react" diff --git a/src/components/alert-dialog.tsx b/src/components/alert-dialog.tsx index f03c038..d463551 100644 --- a/src/components/alert-dialog.tsx +++ b/src/components/alert-dialog.tsx @@ -1,6 +1,6 @@ "use client" -import * as React from "react" +import type * as React from "react" import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" import { cn } from "@/lib/utils" diff --git a/src/components/alert.tsx b/src/components/alert.tsx index 1421354..66242b8 100644 --- a/src/components/alert.tsx +++ b/src/components/alert.tsx @@ -1,4 +1,4 @@ -import * as React from "react" +import type * as React from "react" import { cva, type VariantProps } from "class-variance-authority" import { cn } from "@/lib/utils" diff --git a/src/components/avatar.tsx b/src/components/avatar.tsx index 71e428b..0a3dc7a 100644 --- a/src/components/avatar.tsx +++ b/src/components/avatar.tsx @@ -1,6 +1,6 @@ "use client" -import * as React from "react" +import type * as React from "react" import * as AvatarPrimitive from "@radix-ui/react-avatar" import { cn } from "@/lib/utils" diff --git a/src/components/badge.tsx b/src/components/badge.tsx index 0205413..0e3a360 100644 --- a/src/components/badge.tsx +++ b/src/components/badge.tsx @@ -1,4 +1,4 @@ -import * as React from "react" +import type * as React from "react" import { Slot } from "@radix-ui/react-slot" import { cva, type VariantProps } from "class-variance-authority" diff --git a/src/components/breadcrumb.tsx b/src/components/breadcrumb.tsx index eb88f32..e2604e9 100644 --- a/src/components/breadcrumb.tsx +++ b/src/components/breadcrumb.tsx @@ -1,4 +1,4 @@ -import * as React from "react" +import type * as React from "react" import { Slot } from "@radix-ui/react-slot" import { ChevronRight, MoreHorizontal } from "lucide-react" @@ -53,7 +53,6 @@ function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) { return ( -type CarouselOptions = UseCarouselParameters[0] -type CarouselPlugin = UseCarouselParameters[1] +type CarouselApi = UseEmblaCarouselType[1]; +type UseCarouselParameters = Parameters; +type CarouselOptions = UseCarouselParameters[0]; +type CarouselPlugin = UseCarouselParameters[1]; type CarouselProps = { - opts?: CarouselOptions - plugins?: CarouselPlugin - orientation?: "horizontal" | "vertical" - setApi?: (api: CarouselApi) => void -} + opts?: CarouselOptions; + plugins?: CarouselPlugin; + orientation?: "horizontal" | "vertical"; + setApi?: (api: CarouselApi) => void; +}; type CarouselContextProps = { - carouselRef: ReturnType[0] - api: ReturnType[1] - scrollPrev: () => void - scrollNext: () => void - canScrollPrev: boolean - canScrollNext: boolean -} & CarouselProps + carouselRef: ReturnType[0]; + api: ReturnType[1]; + scrollPrev: () => void; + scrollNext: () => void; + canScrollPrev: boolean; + canScrollNext: boolean; +} & CarouselProps; -const CarouselContext = React.createContext(null) +const CarouselContext = React.createContext(null); function useCarousel() { - const context = React.useContext(CarouselContext) + const context = React.useContext(CarouselContext); - if (!context) { - throw new Error("useCarousel must be used within a ") - } + if (!context) { + throw new Error("useCarousel must be used within a "); + } - return context + return context; } function Carousel({ - orientation = "horizontal", - opts, - setApi, - plugins, - className, - children, - ...props + orientation = "horizontal", + opts, + setApi, + plugins, + className, + children, + ...props }: React.ComponentProps<"div"> & CarouselProps) { - const [carouselRef, api] = useEmblaCarousel( - { - ...opts, - axis: orientation === "horizontal" ? "x" : "y", - }, - plugins - ) - const [canScrollPrev, setCanScrollPrev] = React.useState(false) - const [canScrollNext, setCanScrollNext] = React.useState(false) + const [carouselRef, api] = useEmblaCarousel( + { + ...opts, + axis: orientation === "horizontal" ? "x" : "y", + }, + plugins, + ); + const [canScrollPrev, setCanScrollPrev] = React.useState(false); + const [canScrollNext, setCanScrollNext] = React.useState(false); - const onSelect = React.useCallback((api: CarouselApi) => { - if (!api) return - setCanScrollPrev(api.canScrollPrev()) - setCanScrollNext(api.canScrollNext()) - }, []) + const onSelect = React.useCallback((api: CarouselApi) => { + if (!api) return; + setCanScrollPrev(api.canScrollPrev()); + setCanScrollNext(api.canScrollNext()); + }, []); - const scrollPrev = React.useCallback(() => { - api?.scrollPrev() - }, [api]) + const scrollPrev = React.useCallback(() => { + api?.scrollPrev(); + }, [api]); - const scrollNext = React.useCallback(() => { - api?.scrollNext() - }, [api]) + const scrollNext = React.useCallback(() => { + api?.scrollNext(); + }, [api]); - const handleKeyDown = React.useCallback( - (event: React.KeyboardEvent) => { - if (event.key === "ArrowLeft") { - event.preventDefault() - scrollPrev() - } else if (event.key === "ArrowRight") { - event.preventDefault() - scrollNext() - } - }, - [scrollPrev, scrollNext] - ) + const handleKeyDown = React.useCallback( + (event: React.KeyboardEvent) => { + if (event.key === "ArrowLeft") { + event.preventDefault(); + scrollPrev(); + } else if (event.key === "ArrowRight") { + event.preventDefault(); + scrollNext(); + } + }, + [scrollPrev, scrollNext], + ); - React.useEffect(() => { - if (!api || !setApi) return - setApi(api) - }, [api, setApi]) + React.useEffect(() => { + if (!api || !setApi) return; + setApi(api); + }, [api, setApi]); - React.useEffect(() => { - if (!api) return - onSelect(api) - api.on("reInit", onSelect) - api.on("select", onSelect) + React.useEffect(() => { + if (!api) return; + onSelect(api); + api.on("reInit", onSelect); + api.on("select", onSelect); - return () => { - api?.off("select", onSelect) - } - }, [api, onSelect]) + return () => { + api?.off("select", onSelect); + }; + }, [api, onSelect]); - return ( - -
- {children} -
-
- ) + return ( + +
+ {children} +
+
+ ); } function CarouselContent({ className, ...props }: React.ComponentProps<"div">) { - const { carouselRef, orientation } = useCarousel() + const { carouselRef, orientation } = useCarousel(); - return ( -
-
-
- ) + return ( +
+
+
+ ); } function CarouselItem({ className, ...props }: React.ComponentProps<"div">) { - const { orientation } = useCarousel() + const { orientation } = useCarousel(); - return ( -
- ) + return ( +
+ ); } function CarouselPrevious({ - className, - variant = "outline", - size = "icon", - ...props + className, + variant = "outline", + size = "icon", + ...props }: React.ComponentProps) { - const { orientation, scrollPrev, canScrollPrev } = useCarousel() + const { orientation, scrollPrev, canScrollPrev } = useCarousel(); - return ( - - ) + return ( + + ); } function CarouselNext({ - className, - variant = "outline", - size = "icon", - ...props + className, + variant = "outline", + size = "icon", + ...props }: React.ComponentProps) { - const { orientation, scrollNext, canScrollNext } = useCarousel() + const { orientation, scrollNext, canScrollNext } = useCarousel(); - return ( - - ) + return ( + + ); } export { - type CarouselApi, - Carousel, - CarouselContent, - CarouselItem, - CarouselPrevious, - CarouselNext, -} + Carousel, + CarouselContent, + CarouselItem, + CarouselNext, + CarouselPrevious, + type CarouselApi, +}; diff --git a/src/components/chart.tsx b/src/components/chart.tsx index e4589f0..edb833e 100644 --- a/src/components/chart.tsx +++ b/src/components/chart.tsx @@ -1,351 +1,352 @@ -import * as React from "react" -import * as RechartsPrimitive from "recharts" +import * as React from "react"; +import * as RechartsPrimitive from "recharts"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; // Format: { THEME_NAME: CSS_SELECTOR } -const THEMES = { light: "", dark: ".dark" } as const +const THEMES = { light: "", dark: ".dark" } as const; export type ChartConfig = { - [k in string]: { - label?: React.ReactNode - icon?: React.ComponentType - } & ( - | { color?: string; theme?: never } - | { color?: never; theme: Record } - ) -} + [k in string]: { + label?: React.ReactNode; + icon?: React.ComponentType; + } & ( + | { color?: string; theme?: never } + | { color?: never; theme: Record } + ); +}; type ChartContextProps = { - config: ChartConfig -} + config: ChartConfig; +}; -const ChartContext = React.createContext(null) +const ChartContext = React.createContext(null); function useChart() { - const context = React.useContext(ChartContext) + const context = React.useContext(ChartContext); - if (!context) { - throw new Error("useChart must be used within a ") - } + if (!context) { + throw new Error("useChart must be used within a "); + } - return context + return context; } function ChartContainer({ - id, - className, - children, - config, - ...props + id, + className, + children, + config, + ...props }: React.ComponentProps<"div"> & { - config: ChartConfig - children: React.ComponentProps< - typeof RechartsPrimitive.ResponsiveContainer - >["children"] + config: ChartConfig; + children: React.ComponentProps< + typeof RechartsPrimitive.ResponsiveContainer + >["children"]; }) { - const uniqueId = React.useId() - const chartId = `chart-${id || uniqueId.replace(/:/g, "")}` + const uniqueId = React.useId(); + const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`; - return ( - -
- - - {children} - -
-
- ) + return ( + +
+ + + {children} + +
+
+ ); } const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { - const colorConfig = Object.entries(config).filter( - ([, config]) => config.theme || config.color - ) + const colorConfig = Object.entries(config).filter( + ([, config]) => config.theme || config.color, + ); - if (!colorConfig.length) { - return null - } + if (!colorConfig.length) { + return null; + } - return ( -