From 7a154fec4117672078ad93dee032f05d8d94a0fc Mon Sep 17 00:00:00 2001 From: Fellipe Utaka Date: Tue, 20 Aug 2024 06:09:19 -0300 Subject: [PATCH] style: set defaultFormatter to biome --- .vscode/settings.json | 3 +- apps/www/package.json | 4 +- apps/www/public/schema.json | 80 ++-- .../src/app/_components/feature-section.tsx | 242 ++++++------ .../app/_components/open-source-section.tsx | 4 +- .../_components/table-of-contents.tsx | 2 +- .../_components/iconify-collection-list.tsx | 49 ++- apps/www/src/app/layout.tsx | 2 +- apps/www/src/components/command-menu.tsx | 15 +- apps/www/src/components/language-icon.tsx | 2 +- apps/www/src/components/main-nav.tsx | 10 +- .../src/components/mdx/component-source.tsx | 2 +- apps/www/src/components/mdx/copy-button.tsx | 4 +- .../www/src/components/mdx/mdx-components.tsx | 10 +- apps/www/src/components/mdx/steps.tsx | 4 +- apps/www/src/components/mdx/tabs.tsx | 2 +- apps/www/src/components/mobile-nav.tsx | 19 +- apps/www/src/components/site-header.tsx | 15 +- apps/www/src/config/docs.ts | 4 + apps/www/src/content/docs/cli.mdx | 37 ++ apps/www/src/hooks/use-copy-to-clipboard.ts | 4 +- apps/www/src/lib/iconify.ts | 6 +- apps/www/src/lib/rehype-command.ts | 12 +- apps/www/src/lib/rehype-component.ts | 8 +- apps/www/src/styles/link.ts | 10 +- apps/www/src/utils/get-doc-by-slug.ts | 22 +- apps/www/src/utils/get-item-ids.ts | 28 +- biome.json | 8 +- config/tsconfig/package.json | 5 +- package.json | 8 +- packages/cli/kanpeki.json | 24 +- packages/cli/package.json | 4 +- packages/cli/src/commands/icon/format.ts | 22 +- packages/cli/src/commands/icon/index.ts | 12 +- packages/cli/src/commands/init.ts | 24 +- packages/cli/src/templates/cn.ts | 14 +- packages/cli/src/templates/globals.ts | 192 +++++----- packages/cli/src/templates/tw-config.ts | 150 ++++---- packages/cli/src/utils/get-config.ts | 184 ++++----- packages/cli/src/utils/get-is-online.ts | 90 ++--- packages/cli/src/utils/get-pkg-manager.ts | 38 +- packages/cli/src/utils/get-project-info.ts | 358 +++++++++--------- packages/cli/src/utils/handle-error.ts | 32 +- packages/cli/src/utils/install-deps.ts | 90 ++--- packages/cli/src/utils/logger.ts | 38 +- packages/cli/src/utils/resolve-import.ts | 32 +- packages/cli/tsup.config.ts | 20 +- packages/components/demos/src/avatar-demo.tsx | 34 +- .../components/demos/src/avatar-group.tsx | 120 +++--- .../components/demos/src/checkbox-demo.tsx | 30 +- .../demos/src/checkbox-disabled.tsx | 36 +- .../components/demos/src/command-demo.tsx | 228 +++++------ packages/components/demos/src/label-demo.tsx | 30 +- .../components/demos/src/scroll-area-demo.tsx | 56 +-- .../demos/src/scroll-area-horizontal.tsx | 104 ++--- .../components/demos/src/separator-demo.tsx | 44 +-- .../demos/src/separator-vertical.tsx | 26 +- .../components/demos/src/skeleton-card.tsx | 26 +- .../components/demos/src/skeleton-demo.tsx | 26 +- packages/components/demos/src/switch-demo.tsx | 26 +- packages/components/demos/src/table-demo.tsx | 170 ++++----- packages/components/demos/src/tabs-demo.tsx | 140 +++---- packages/components/ui/src/alert.tsx | 2 +- packages/components/ui/src/avatar.tsx | 2 +- packages/components/ui/src/breadcrumb.tsx | 2 +- packages/components/ui/src/button.tsx | 2 +- packages/components/ui/src/card.tsx | 2 +- packages/components/ui/src/checkbox.tsx | 4 +- packages/components/ui/src/collapsible.tsx | 2 +- packages/components/ui/src/command.tsx | 2 +- packages/components/ui/src/dialog.tsx | 8 +- packages/components/ui/src/dropdown-menu.tsx | 2 +- packages/components/ui/src/link-button.tsx | 2 +- packages/components/ui/src/popover.tsx | 102 ++--- packages/components/ui/src/scroll-area.tsx | 2 +- packages/components/ui/src/switch.tsx | 4 +- packages/components/ui/src/table.tsx | 2 +- packages/components/ui/src/tabs.tsx | 2 +- packages/components/ui/src/text-field.tsx | 2 +- packages/hooks/src/use-active-item.ts | 2 +- packages/hooks/src/use-animation.ts | 6 +- packages/utils/src/merge-refs.ts | 2 +- pnpm-lock.yaml | 35 +- 83 files changed, 1665 insertions(+), 1565 deletions(-) create mode 100644 apps/www/src/content/docs/cli.mdx diff --git a/.vscode/settings.json b/.vscode/settings.json index c391506..a5791d4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,5 +15,6 @@ "velite" ], "typescript.enablePromptUseWorkspaceTsdk": true, - "typescript.tsdk": "node_modules\\typescript\\lib" + "typescript.tsdk": "node_modules\\typescript\\lib", + "editor.defaultFormatter": "biomejs.biome" } diff --git a/apps/www/package.json b/apps/www/package.json index fc7e0df..6b5f9a3 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -16,14 +16,14 @@ "@kanpeki/ui": "workspace:*", "@kanpeki/utils": "workspace:*", "@react-aria/interactions": "^3.22.1", + "@tanstack/react-virtual": "^3.10.1", "@vercel/analytics": "^1.3.1", "@vercel/speed-insights": "^1.0.12", "geist": "^1.3.1", "next": "15.0.0-rc.0", "next-themes": "^0.3.0", "react": "19.0.0-rc-f994737d14-20240522", - "react-dom": "19.0.0-rc-f994737d14-20240522", - "react-virtuoso": "^4.10.1" + "react-dom": "19.0.0-rc-f994737d14-20240522" }, "devDependencies": { "@kanpeki/tsconfig": "workspace:*", diff --git a/apps/www/public/schema.json b/apps/www/public/schema.json index 7eea762..cf866a3 100644 --- a/apps/www/public/schema.json +++ b/apps/www/public/schema.json @@ -1,40 +1,40 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "rsc": { - "type": "boolean" - }, - "tailwind": { - "type": "object", - "properties": { - "config": { - "type": "string" - }, - "css": { - "type": "string" - }, - "prefix": { - "type": "string" - } - }, - "required": ["config", "css"] - }, - "aliases": { - "type": "object", - "properties": { - "components": { - "type": "string" - }, - "utils": { - "type": "string" - }, - "ui": { - "type": "string" - } - }, - "required": ["components", "utils"] - } - }, - "required": ["rsc", "tailwind", "aliases"] -} +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "rsc": { + "type": "boolean" + }, + "tailwind": { + "type": "object", + "properties": { + "config": { + "type": "string" + }, + "css": { + "type": "string" + }, + "prefix": { + "type": "string" + } + }, + "required": ["config", "css"] + }, + "aliases": { + "type": "object", + "properties": { + "components": { + "type": "string" + }, + "utils": { + "type": "string" + }, + "ui": { + "type": "string" + } + }, + "required": ["components", "utils"] + } + }, + "required": ["rsc", "tailwind", "aliases"] +} diff --git a/apps/www/src/app/_components/feature-section.tsx b/apps/www/src/app/_components/feature-section.tsx index d4e96ec..6c04c4a 100644 --- a/apps/www/src/app/_components/feature-section.tsx +++ b/apps/www/src/app/_components/feature-section.tsx @@ -1,121 +1,121 @@ -import { Card } from "@kanpeki/ui/card"; -import { Icons } from "@kanpeki/ui/icons"; -import { siteConfig } from "~/config/site"; - -const features = [ - { - title: "Fully Customizable", - description: - "Easily customize the appearance and behavior of our components to match your brand and design.", - icon: , - }, - { - title: "Accessible", - description: - "Our components follow the WAI-ARIA guidelines, provide keyboard support and sensible focus management.", - icon: , - }, - { - title: "No runtime styles", - description: - "Kanpeki is based on Tailwind CSS, it means that there are no runtime styles, and no unnecessary classes in your bundle.", - icon: , - }, - { - title: "Minimal bundle size", - description: - "Install only the components and hooks you need, and keep your bundle size to a minimum.", - icon: , - }, - { - title: "TypeScript based", - description: - "Build type safe applications. Kanpeki is TypeScript first, and provides type definitions out of the box.", - icon: ( - - - - - ), - }, - { - title: "Composition Pattern", - description: - "Kanpeki is built using the composition pattern, which means that you can easily extend and compose components.", - icon: , - }, - { - title: "Open Source", - description: - "Kanpeki is open source, allowing you to contribute and help shape the future of the library.", - icon: ( - - - - ), - }, - { - title: "Extensive Community", - description: - "Join a growing community of developers who use and contribute to Kanpeki.", - icon: , - }, -] as const satisfies { - title: string; - description: string; - icon: React.JSX.Element; -}[]; - -export function FeatureSection() { - return ( -
-
-

- Why Choose {siteConfig.name}? -

-

- {siteConfig.name} offers a wide range of high-quality, customizable - React components that will help you build stunning web applications - with ease. -

-
-
- {features.map((feature) => ( - - -
- {feature.icon} -
- - {feature.title} -
- - {feature.description} - -
- ))} -
-
- ); -} +import { Card } from "@kanpeki/ui/card"; +import { Icons } from "@kanpeki/ui/icons"; +import { siteConfig } from "~/config/site"; + +const features = [ + { + title: "Fully Customizable", + description: + "Easily customize the appearance and behavior of our components to match your brand and design.", + icon: , + }, + { + title: "Accessible", + description: + "Our components follow the WAI-ARIA guidelines, provide keyboard support and sensible focus management.", + icon: , + }, + { + title: "No runtime styles", + description: + "Kanpeki is based on Tailwind CSS, it means that there are no runtime styles, and no unnecessary classes in your bundle.", + icon: , + }, + { + title: "Minimal bundle size", + description: + "Install only the components and hooks you need, and keep your bundle size to a minimum.", + icon: , + }, + { + title: "TypeScript based", + description: + "Build type safe applications. Kanpeki is TypeScript first, and provides type definitions out of the box.", + icon: ( + + + + + ), + }, + { + title: "Composition Pattern", + description: + "Kanpeki is built using the composition pattern, which means that you can easily extend and compose components.", + icon: , + }, + { + title: "Open Source", + description: + "Kanpeki is open source, allowing you to contribute and help shape the future of the library.", + icon: ( + + + + ), + }, + { + title: "Extensive Community", + description: + "Join a growing community of developers who use and contribute to Kanpeki.", + icon: , + }, +] as const satisfies { + title: string; + description: string; + icon: React.JSX.Element; +}[]; + +export function FeatureSection() { + return ( +
+
+

+ Why Choose {siteConfig.name}? +

+

+ {siteConfig.name} offers a wide range of high-quality, customizable + React components that will help you build stunning web applications + with ease. +

+
+
+ {features.map((feature) => ( + + +
+ {feature.icon} +
+ + {feature.title} +
+ + {feature.description} + +
+ ))} +
+
+ ); +} diff --git a/apps/www/src/app/_components/open-source-section.tsx b/apps/www/src/app/_components/open-source-section.tsx index 879da4d..e21291b 100644 --- a/apps/www/src/app/_components/open-source-section.tsx +++ b/apps/www/src/app/_components/open-source-section.tsx @@ -44,13 +44,13 @@ async function getGitHubStars() { const response = await fetch( `https://api.github.com/repos/${siteConfig.links.github.replace( "https://github.com/", - "", + "" )}`, { next: { revalidate: 60, }, - }, + } ); if (!response?.ok) { diff --git a/apps/www/src/app/docs/[[...slug]]/_components/table-of-contents.tsx b/apps/www/src/app/docs/[[...slug]]/_components/table-of-contents.tsx index 06f0d25..394c71e 100644 --- a/apps/www/src/app/docs/[[...slug]]/_components/table-of-contents.tsx +++ b/apps/www/src/app/docs/[[...slug]]/_components/table-of-contents.tsx @@ -41,7 +41,7 @@ function Tree({ tree, level = 1, activeItem }: TreeProps) { "inline-block no-underline transition-colors hover:text-foreground", item.url === `#${activeItem}` ? "font-medium text-foreground" - : "text-muted-foreground", + : "text-muted-foreground" )} > {item.title} diff --git a/apps/www/src/app/icons/_components/iconify-collection-list.tsx b/apps/www/src/app/icons/_components/iconify-collection-list.tsx index 8431ff8..458c684 100644 --- a/apps/www/src/app/icons/_components/iconify-collection-list.tsx +++ b/apps/www/src/app/icons/_components/iconify-collection-list.tsx @@ -1,7 +1,8 @@ "use client"; import { Icon } from "@iconify-icon/react"; -import { Virtuoso } from "react-virtuoso"; +import { useVirtualizer } from "@tanstack/react-virtual"; +import { useRef } from "react"; interface IconifyCollectionListProps { prefix: string; @@ -12,13 +13,47 @@ export function IconifyCollectionList({ prefix, icons, }: IconifyCollectionListProps) { + const parentRef = useRef(null); + + const rowVirtualizer = useVirtualizer({ + count: icons.length, + estimateSize: () => 48, + getScrollElement: () => parentRef.current, + }); + return ( -
, +
} - /> + > + {/* The large inner element to hold all of the items */} +
+ {/* Only the visible items in the virtualizer, manually positioned to be in view */} + {rowVirtualizer.getVirtualItems().map((virtualItem) => ( +
+ +
+ ))} +
+
); } diff --git a/apps/www/src/app/layout.tsx b/apps/www/src/app/layout.tsx index b0676f9..82c6e0c 100644 --- a/apps/www/src/app/layout.tsx +++ b/apps/www/src/app/layout.tsx @@ -73,7 +73,7 @@ export default function Layout({ children }: LayoutProps) { className={cn( "relative grid min-h-dvh grid-rows-[auto,1fr,auto] bg-background font-sans text-foreground antialiased", fonts.sans.variable, - fonts.mono.variable, + fonts.mono.variable )} > diff --git a/apps/www/src/components/command-menu.tsx b/apps/www/src/components/command-menu.tsx index bb6463f..2cbc3d6 100644 --- a/apps/www/src/components/command-menu.tsx +++ b/apps/www/src/components/command-menu.tsx @@ -8,9 +8,14 @@ import { useTheme } from "next-themes"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; -import { docsConfig } from "~/config/docs"; +import type { NavItem, SidebarNavItem } from "~/config/docs"; -export function CommandMenu() { +interface CommandMenuProps { + mainNav: NavItem[]; + sidebarNav: SidebarNavItem[]; +} + +export function CommandMenu({ mainNav, sidebarNav }: CommandMenuProps) { const [isOpen, setIsOpen] = useState(false); const { setTheme } = useTheme(); const router = useRouter(); @@ -35,7 +40,7 @@ export function CommandMenu() { setIsOpen((open) => !open); } }, - { signal: controller.signal }, + { signal: controller.signal } ); return () => controller.abort(); @@ -75,7 +80,7 @@ export function CommandMenu() { No results found. - {docsConfig.mainNav.map((navItem) => ( + {mainNav.map((navItem) => ( ))} - {docsConfig.sidebarNav.map((group) => ( + {sidebarNav.map((group) => ( {group.items?.map((navItem) => ( `(${group.replace(/,/g, "|")})`, + (_, group) => `(${group.replace(/,/g, "|")})` ); } diff --git a/apps/www/src/components/main-nav.tsx b/apps/www/src/components/main-nav.tsx index 67f558f..5a01e2c 100644 --- a/apps/www/src/components/main-nav.tsx +++ b/apps/www/src/components/main-nav.tsx @@ -4,10 +4,14 @@ import { Badge } from "@kanpeki/ui/badge"; import { Icons } from "@kanpeki/ui/icons"; import Link from "next/link"; import { usePathname } from "next/navigation"; -import { type NavItem, docsConfig } from "~/config/docs"; +import type { NavItem } from "~/config/docs"; import { siteConfig } from "~/config/site"; -export function MainNav() { +interface MainNavProps { + mainNav: NavItem[]; +} + +export function MainNav({ mainNav }: MainNavProps) { const pathname = usePathname(); return ( @@ -18,7 +22,7 @@ export function MainNav() { Beta diff --git a/apps/www/src/components/mdx/component-source.tsx b/apps/www/src/components/mdx/component-source.tsx index c0ea52e..2d6ce32 100644 --- a/apps/www/src/components/mdx/component-source.tsx +++ b/apps/www/src/components/mdx/component-source.tsx @@ -26,7 +26,7 @@ export function ComponentSource({ children }: ComponentSourceProps) {
- - - - - - - Password - - Change your password here. After saving, you'll be logged out. - - - -
- - - - -
-
- - - - -
-
- - - -
-
- - ); -} +import { Button } from "@kanpeki/ui/button"; +import { Card } from "@kanpeki/ui/card"; +import { Label } from "@kanpeki/ui/label"; +import { Tabs } from "@kanpeki/ui/tabs"; +import { TextField } from "@kanpeki/ui/text-field"; + +export default function TabsDemo() { + return ( + + + Account + Password + + + + + Account + + Make changes to your account here. Click save when you're done. + + + +
+ + + + +
+
+ + + + +
+
+ + + +
+
+ + + + Password + + Change your password here. After saving, you'll be logged out. + + + +
+ + + + +
+
+ + + + +
+
+ + + +
+
+
+ ); +} diff --git a/packages/components/ui/src/alert.tsx b/packages/components/ui/src/alert.tsx index 4d27c3c..8c7102b 100644 --- a/packages/components/ui/src/alert.tsx +++ b/packages/components/ui/src/alert.tsx @@ -68,5 +68,5 @@ export const Alert = Object.assign( Root: AlertRoot, Title: AlertTitle, Description: AlertDescription, - }, + } ); diff --git a/packages/components/ui/src/avatar.tsx b/packages/components/ui/src/avatar.tsx index 764c007..53e335e 100644 --- a/packages/components/ui/src/avatar.tsx +++ b/packages/components/ui/src/avatar.tsx @@ -136,5 +136,5 @@ export const Avatar = Object.assign( Image: AvatarImage, Fallback: AvatarFallback, Placeholder: AvatarPlaceholder, - }, + } ); diff --git a/packages/components/ui/src/breadcrumb.tsx b/packages/components/ui/src/breadcrumb.tsx index 488d228..1d07ccf 100644 --- a/packages/components/ui/src/breadcrumb.tsx +++ b/packages/components/ui/src/breadcrumb.tsx @@ -106,5 +106,5 @@ export const Breadcrumb = Object.assign( Page: BreadcrumbPage, Separator: BreadcrumbSeparator, Ellipsis: BreadcrumbEllipsis, - }, + } ); diff --git a/packages/components/ui/src/button.tsx b/packages/components/ui/src/button.tsx index 7d289ed..59424b4 100644 --- a/packages/components/ui/src/button.tsx +++ b/packages/components/ui/src/button.tsx @@ -92,7 +92,7 @@ export function Button({ onPressUp, isDisabled: props.disabled, }, - ref, + ref ); const { focusProps, isFocusVisible } = useFocusRing({ diff --git a/packages/components/ui/src/card.tsx b/packages/components/ui/src/card.tsx index a52a24f..407fb7d 100644 --- a/packages/components/ui/src/card.tsx +++ b/packages/components/ui/src/card.tsx @@ -66,5 +66,5 @@ export const Card = Object.assign( Description: CardDescription, Content: CardContent, Footer: CardFooter, - }, + } ); diff --git a/packages/components/ui/src/checkbox.tsx b/packages/components/ui/src/checkbox.tsx index a4fec48..f04ed53 100644 --- a/packages/components/ui/src/checkbox.tsx +++ b/packages/components/ui/src/checkbox.tsx @@ -43,7 +43,7 @@ export function CheckboxRoot({ className, ...props }: CheckboxRootProps) { isReadOnly: props.readOnly || props.isReadOnly, }, state, - ref, + ref ); return ( @@ -87,5 +87,5 @@ export const Checkbox = Object.assign( { Root: CheckboxRoot, Indicator: CheckboxIndicator, - }, + } ); diff --git a/packages/components/ui/src/collapsible.tsx b/packages/components/ui/src/collapsible.tsx index afafe5c..adbac44 100644 --- a/packages/components/ui/src/collapsible.tsx +++ b/packages/components/ui/src/collapsible.tsx @@ -43,5 +43,5 @@ export const Collapsible = Object.assign( Root: CollapsibleRoot, Trigger: CollapsibleTrigger, Content: CollapsibleContent, - }, + } ); diff --git a/packages/components/ui/src/command.tsx b/packages/components/ui/src/command.tsx index fd9213e..4e2d6d2 100644 --- a/packages/components/ui/src/command.tsx +++ b/packages/components/ui/src/command.tsx @@ -159,5 +159,5 @@ export const Command = Object.assign( Item: CommandItem, Separator: CommandSeparator, Shortcut: CommandShortcut, - }, + } ); diff --git a/packages/components/ui/src/dialog.tsx b/packages/components/ui/src/dialog.tsx index f0c26ca..b39acf9 100644 --- a/packages/components/ui/src/dialog.tsx +++ b/packages/components/ui/src/dialog.tsx @@ -122,7 +122,7 @@ export function useDialogRootContext() { const context = useContext(DialogRootContext); if (context === null) { throw new Error( - "useDialogRootContext must be used within a DialogProvider", + "useDialogRootContext must be used within a DialogProvider" ); } return context; @@ -164,7 +164,7 @@ export function DialogRoot({ const overlayTriggerState = useOverlayTriggerState(props); const { triggerProps, overlayProps } = useOverlayTrigger( { type: "dialog" }, - overlayTriggerState, + overlayTriggerState ); const modalRef = useRef(null); @@ -175,7 +175,7 @@ export function DialogRoot({ isDismissable, }, overlayTriggerState, - modalRef, + modalRef ); return ( @@ -362,5 +362,5 @@ export const Dialog = Object.assign( Title: DialogTitle, Description: DialogDescription, Close: DialogClose, - }, + } ); diff --git a/packages/components/ui/src/dropdown-menu.tsx b/packages/components/ui/src/dropdown-menu.tsx index f6d31c6..b23cf1e 100644 --- a/packages/components/ui/src/dropdown-menu.tsx +++ b/packages/components/ui/src/dropdown-menu.tsx @@ -274,5 +274,5 @@ export const DropdownMenu = Object.assign( SubContent: DropdownMenuSubContent, SubTrigger: DropdownMenuSubTrigger, RadioGroup: DropdownMenuRadioGroup, - }, + } ); diff --git a/packages/components/ui/src/link-button.tsx b/packages/components/ui/src/link-button.tsx index a6a21df..10b2c83 100644 --- a/packages/components/ui/src/link-button.tsx +++ b/packages/components/ui/src/link-button.tsx @@ -40,7 +40,7 @@ export function LinkButton({ onPressUp, isDisabled: isDisabled ?? props.disabled, }, - ref, + ref ); const { focusProps, isFocusVisible } = useFocusRing({ diff --git a/packages/components/ui/src/popover.tsx b/packages/components/ui/src/popover.tsx index 084e7b4..7984814 100644 --- a/packages/components/ui/src/popover.tsx +++ b/packages/components/ui/src/popover.tsx @@ -1,51 +1,51 @@ -"use client"; - -import { Content, Portal, Root, Trigger } from "@radix-ui/react-popover"; -import { tv } from "tailwind-variants"; - -export const PopoverStyles = { - Content: tv({ - base: [ - "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none", - "data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out", - "data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in", - "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", - ], - }), -}; - -export const PopoverRoot = Root; - -export const PopoverTrigger = Trigger; - -export type PopoverContentProps = React.ComponentProps; - -export function PopoverContent({ - className, - align = "center", - sideOffset = 4, - ...props -}: PopoverContentProps) { - return ( - - - - ); -} - -export const Popover = Object.assign( - {}, - { - Root, - Trigger, - Content: PopoverContent, - }, -); +"use client"; + +import { Content, Portal, Root, Trigger } from "@radix-ui/react-popover"; +import { tv } from "tailwind-variants"; + +export const PopoverStyles = { + Content: tv({ + base: [ + "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none", + "data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out", + "data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in", + "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", + ], + }), +}; + +export const PopoverRoot = Root; + +export const PopoverTrigger = Trigger; + +export type PopoverContentProps = React.ComponentProps; + +export function PopoverContent({ + className, + align = "center", + sideOffset = 4, + ...props +}: PopoverContentProps) { + return ( + + + + ); +} + +export const Popover = Object.assign( + {}, + { + Root, + Trigger, + Content: PopoverContent, + } +); diff --git a/packages/components/ui/src/scroll-area.tsx b/packages/components/ui/src/scroll-area.tsx index a03cd5f..7cb94cb 100644 --- a/packages/components/ui/src/scroll-area.tsx +++ b/packages/components/ui/src/scroll-area.tsx @@ -73,5 +73,5 @@ export const ScrollArea = Object.assign( Viewport: ScrollAreaViewport, Scrollbar: ScrollAreaScrollbar, Thumb: ScrollAreaThumb, - }, + } ); diff --git a/packages/components/ui/src/switch.tsx b/packages/components/ui/src/switch.tsx index e2f0da7..133db33 100644 --- a/packages/components/ui/src/switch.tsx +++ b/packages/components/ui/src/switch.tsx @@ -46,7 +46,7 @@ export function SwitchRoot({ className, ...props }: SwitchRootProps) { isReadOnly: props.readOnly || props.isReadOnly, }, state, - ref, + ref ); return ( @@ -80,5 +80,5 @@ export const Switch = Object.assign( { Root: SwitchRoot, Thumb: SwitchThumb, - }, + } ); diff --git a/packages/components/ui/src/table.tsx b/packages/components/ui/src/table.tsx index ddc5ff0..0c574a8 100644 --- a/packages/components/ui/src/table.tsx +++ b/packages/components/ui/src/table.tsx @@ -94,5 +94,5 @@ export const Table = Object.assign( Head: TableHead, Cell: TableCell, Caption: TableCaption, - }, + } ); diff --git a/packages/components/ui/src/tabs.tsx b/packages/components/ui/src/tabs.tsx index d0ff6b9..19bdb3f 100644 --- a/packages/components/ui/src/tabs.tsx +++ b/packages/components/ui/src/tabs.tsx @@ -55,5 +55,5 @@ export const Tabs = Object.assign( List: TabsList, Trigger: TabsTrigger, Content: TabsContent, - }, + } ); diff --git a/packages/components/ui/src/text-field.tsx b/packages/components/ui/src/text-field.tsx index 718107b..574c8ba 100644 --- a/packages/components/ui/src/text-field.tsx +++ b/packages/components/ui/src/text-field.tsx @@ -84,5 +84,5 @@ export const TextField = Object.assign( Root: TextFieldRoot, Input: TextFieldInput, Slot: TextFieldSlot, - }, + } ); diff --git a/packages/hooks/src/use-active-item.ts b/packages/hooks/src/use-active-item.ts index 8d2ecc4..0c2a49d 100644 --- a/packages/hooks/src/use-active-item.ts +++ b/packages/hooks/src/use-active-item.ts @@ -12,7 +12,7 @@ export function useActiveItem(itemIds: string[]) { } } }, - { rootMargin: "5% 0% -70% 0%" }, + { rootMargin: "5% 0% -70% 0%" } ); for (const id of itemIds) { diff --git a/packages/hooks/src/use-animation.ts b/packages/hooks/src/use-animation.ts index 1dec32f..edcb065 100644 --- a/packages/hooks/src/use-animation.ts +++ b/packages/hooks/src/use-animation.ts @@ -4,7 +4,7 @@ import { flushSync } from "react-dom"; export function useAnimation( ref: React.RefObject, isActive: boolean, - onEnd: () => void, + onEnd: () => void ) { const prevAnimation = useRef(null); if (isActive && ref.current) { @@ -45,7 +45,7 @@ export function useAnimation( export function useExitAnimation( ref: React.RefObject, - isOpen: boolean, + isOpen: boolean ) { // State to trigger a re-render after animation is complete, which causes the element to be removed from the DOM. // Ref to track the state we're in, so we don't immediately reset isExiting to true after the animation. @@ -69,7 +69,7 @@ export function useExitAnimation( useCallback(() => { setExitState("exited"); setExiting(false); - }, []), + }, []) ); return isExiting; diff --git a/packages/utils/src/merge-refs.ts b/packages/utils/src/merge-refs.ts index 4ca8537..99fd9a6 100644 --- a/packages/utils/src/merge-refs.ts +++ b/packages/utils/src/merge-refs.ts @@ -1,5 +1,5 @@ export function mergeRefs( - refs: (React.MutableRefObject | React.LegacyRef | undefined)[], + refs: (React.MutableRefObject | React.LegacyRef | undefined)[] ): React.RefCallback { return (value) => { for (const ref of refs) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee427f5..7b30e90 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -68,6 +68,9 @@ importers: '@react-aria/interactions': specifier: ^3.22.1 version: 3.22.1(react@19.0.0-rc-f994737d14-20240522) + '@tanstack/react-virtual': + specifier: ^3.10.1 + version: 3.10.1(react-dom@19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522))(react@19.0.0-rc-f994737d14-20240522) '@vercel/analytics': specifier: ^1.3.1 version: 1.3.1(next@15.0.0-rc.0(react-dom@19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522))(react@19.0.0-rc-f994737d14-20240522))(react@19.0.0-rc-f994737d14-20240522) @@ -89,9 +92,6 @@ importers: react-dom: specifier: 19.0.0-rc-f994737d14-20240522 version: 19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522) - react-virtuoso: - specifier: ^4.10.1 - version: 4.10.1(react-dom@19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522))(react@19.0.0-rc-f994737d14-20240522) devDependencies: '@kanpeki/tsconfig': specifier: workspace:* @@ -1649,6 +1649,15 @@ packages: '@swc/helpers@0.5.12': resolution: {integrity: sha512-KMZNXiGibsW9kvZAO1Pam2JPTDBm+KSHMMHWdsyI/1DbIZjT2A6Gy3hblVXUMEDvUAKq+e0vL0X0o54owWji7g==} + '@tanstack/react-virtual@3.10.1': + resolution: {integrity: sha512-h5kNeE+yQwspjl9E3sJ3UYQu/MuspNOBT5cVdc+NA0uU9B1XSkxbzp86teV3arMDVcQ4ESExqs4JyIirYAMcuA==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 + + '@tanstack/virtual-core@3.10.1': + resolution: {integrity: sha512-JDi3wU1HIxuxx8BgD7Ix8IXlelCKdTJIh9c0qBs+QXHdix3mjMbkXI3wOq0TuCx1w1RGgzZue34QrM/NPdp/sw==} + '@types/acorn@4.0.6': resolution: {integrity: sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==} @@ -3271,13 +3280,6 @@ packages: '@types/react': optional: true - react-virtuoso@4.10.1: - resolution: {integrity: sha512-vDBt9AarmCjPNshw3VxPXW355ZQKSO0p9vrAJ0pi04TB6aXk+qHWTu8NuaQ3ppcd/Ub1r5ryRA4fJ2QGuH0H0g==} - engines: {node: '>=10'} - peerDependencies: - react: '>=16 || >=17 || >= 18' - react-dom: '>=16 || >=17 || >= 18' - react@18.3.1: resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==} engines: {node: '>=0.10.0'} @@ -5322,6 +5324,14 @@ snapshots: dependencies: tslib: 2.6.3 + '@tanstack/react-virtual@3.10.1(react-dom@19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522))(react@19.0.0-rc-f994737d14-20240522)': + dependencies: + '@tanstack/virtual-core': 3.10.1 + react: 19.0.0-rc-f994737d14-20240522 + react-dom: 19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522) + + '@tanstack/virtual-core@3.10.1': {} + '@types/acorn@4.0.6': dependencies: '@types/estree': 1.0.5 @@ -7127,11 +7137,6 @@ snapshots: optionalDependencies: '@types/react': 18.3.3 - react-virtuoso@4.10.1(react-dom@19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522))(react@19.0.0-rc-f994737d14-20240522): - dependencies: - react: 19.0.0-rc-f994737d14-20240522 - react-dom: 19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522) - react@18.3.1: dependencies: loose-envify: 1.4.0