From 3b53df74e750dd1d019fcb9796a7ca670fd68313 Mon Sep 17 00:00:00 2001 From: Rizon Date: Sat, 22 Aug 2026 01:14:54 +0100 Subject: [PATCH 1/4] feat: new billing --- app/dashboard/new/actions/create-server.ts | 65 +++++++++++++----- lib/pricing.ts | 8 +++ lib/providers | 2 +- .../migration.sql | 24 +++++++ prisma/schema.prisma | 66 ++++++++++++------- test/hetzner-catalog.test.ts | 15 ++++- vercel.json | 8 +++ 7 files changed, 144 insertions(+), 44 deletions(-) create mode 100644 prisma/migrations/20260820120000_usage_billing/migration.sql create mode 100644 vercel.json diff --git a/app/dashboard/new/actions/create-server.ts b/app/dashboard/new/actions/create-server.ts index 3a639f4..bf0103d 100644 --- a/app/dashboard/new/actions/create-server.ts +++ b/app/dashboard/new/actions/create-server.ts @@ -39,30 +39,52 @@ export type CreateServerResult = * Get or create a Stripe Price for a given server type and monthly GBP pence amount. * Uses a stable lookup_key so repeated calls are idempotent. */ -const getOrCreateStripePrice = async ( +const getOrCreateStripePrices = async ( stripe: Stripe, serverTypeName: string, pricePerMonthCents: number -): Promise => { - const lookupKey = `nodebyte-${serverTypeName.toLowerCase()}-monthly`; - const existing = await stripe.prices.list({ lookup_keys: [lookupKey] }); - if (existing.data.length > 0) { - return existing.data[0].id; +): Promise<{ + introductoryPriceId: string; + usageSubscriptionPriceId: string; +}> => { + const priceKey = `nodebyte-${serverTypeName.toLowerCase()}-${pricePerMonthCents}`; + const [introductoryPrices, usagePrices] = await Promise.all([ + stripe.prices.list({ lookup_keys: [`${priceKey}-first-month`] }), + stripe.prices.list({ lookup_keys: [`${priceKey}-usage-base`] }), + ]); + if (introductoryPrices.data[0] && usagePrices.data[0]) { + return { + introductoryPriceId: introductoryPrices.data[0].id, + usageSubscriptionPriceId: usagePrices.data[0].id, + }; } - // Create a recurring product + price for this server type const product = await stripe.products.create({ metadata: { serverType: serverTypeName }, name: `NodeByte — ${serverTypeName} Game Server`, }); - const price = await stripe.prices.create({ - currency: "gbp", - lookup_key: lookupKey, - product: product.id, - recurring: { interval: "month" }, - transfer_lookup_key: true, - unit_amount: pricePerMonthCents, - }); - return price.id; + const [introductoryPrice, usageSubscriptionPrice] = await Promise.all([ + introductoryPrices.data[0] ?? + stripe.prices.create({ + currency: "gbp", + lookup_key: `${priceKey}-first-month`, + product: product.id, + transfer_lookup_key: true, + unit_amount: pricePerMonthCents, + }), + usagePrices.data[0] ?? + stripe.prices.create({ + currency: "gbp", + lookup_key: `${priceKey}-usage-base`, + product: product.id, + recurring: { interval: "month" }, + transfer_lookup_key: true, + unit_amount: 0, + }), + ]); + return { + introductoryPriceId: introductoryPrice.id, + usageSubscriptionPriceId: usageSubscriptionPrice.id, + }; }; export const createServer = async ( @@ -151,7 +173,7 @@ export const createServer = async ( ); const pricePerMonthCents = Math.round(type.pricePerMonth * 100); - const priceId = await getOrCreateStripePrice( + const prices = await getOrCreateStripePrices( stripe, type.name, pricePerMonthCents @@ -170,16 +192,23 @@ export const createServer = async ( const session = await stripe.checkout.sessions.create({ cancel_url: `${stripeReturnUrl}/dashboard/new${bypassParam ? `?${bypassParam.slice(1)}` : ""}`, customer: stripeCustomerId, - line_items: [{ price: priceId, quantity: 1 }], + line_items: [ + { price: prices.introductoryPriceId, quantity: 1 }, + { price: prices.usageSubscriptionPriceId, quantity: 1 }, + ], metadata: { + hourlyRateMilliCents: String(location.hourlyPriceMilliCents), nodebyteServerId: server.id, nodebyteUserId: user.id, + pricePerMonthCents: String(pricePerMonthCents), }, mode: "subscription", subscription_data: { metadata: { + hourlyRateMilliCents: String(location.hourlyPriceMilliCents), nodebyteServerId: server.id, nodebyteUserId: user.id, + pricePerMonthCents: String(pricePerMonthCents), serverType: type.name, }, }, diff --git a/lib/pricing.ts b/lib/pricing.ts index 9f44e88..7a2c979 100644 --- a/lib/pricing.ts +++ b/lib/pricing.ts @@ -43,6 +43,14 @@ export const applyMarkup = ( return Math.max(rounded, MIN_PRICE_CENTS); }; +export const applyHourlyMarkupMilliCents = ( + hetznerHourlyPriceEur: number, + cpuType: "shared" | "dedicated" +): number => { + const gbp = hetznerHourlyPriceEur * EUR_TO_GBP_RATE; + return Math.max(0, Math.round(gbp * (1 + MARKUP[cpuType]) * 100_000)); +}; + /** * Format a price in pence to a GBP display string. */ diff --git a/lib/providers b/lib/providers index ee0be55..f741ebe 160000 --- a/lib/providers +++ b/lib/providers @@ -1 +1 @@ -Subproject commit ee0be55303c2a9a9c52bbd52dea16160f08a4dcc +Subproject commit f741ebe318460fcd2c2da05a1775a4a456537b4a diff --git a/prisma/migrations/20260820120000_usage_billing/migration.sql b/prisma/migrations/20260820120000_usage_billing/migration.sql new file mode 100644 index 0000000..dc2fe03 --- /dev/null +++ b/prisma/migrations/20260820120000_usage_billing/migration.sql @@ -0,0 +1,24 @@ +ALTER TABLE "subscriptions" + ADD COLUMN "hourlyRateMilliCents" INTEGER, + ADD COLUMN "usageBillingStartedAt" TIMESTAMP(3), + ADD COLUMN "usageLastBilledAt" TIMESTAMP(3); + +CREATE TABLE "usage_invoices" ( + "id" TEXT NOT NULL, + "subscriptionId" TEXT NOT NULL, + "periodStart" TIMESTAMP(3) NOT NULL, + "periodEnd" TIMESTAMP(3) NOT NULL, + "amountCents" INTEGER NOT NULL, + "stripeInvoiceId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT "usage_invoices_pkey" PRIMARY KEY ("id") +); + +CREATE UNIQUE INDEX "usage_invoices_stripeInvoiceId_key" ON "usage_invoices"("stripeInvoiceId"); +CREATE UNIQUE INDEX "usage_invoices_subscriptionId_periodStart_key" ON "usage_invoices"("subscriptionId", "periodStart"); +CREATE INDEX "usage_invoices_subscriptionId_idx" ON "usage_invoices"("subscriptionId"); + +ALTER TABLE "usage_invoices" + ADD CONSTRAINT "usage_invoices_subscriptionId_fkey" + FOREIGN KEY ("subscriptionId") REFERENCES "subscriptions"("id") + ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ab5699d..345d022 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -379,37 +379,57 @@ enum SubscriptionStatus { } model Subscription { - id String @id - serverId String @unique - billingCustomerId String - stripeSubscriptionId String @unique - stripePriceId String - stripeProductId String - status SubscriptionStatus @default(incomplete) + id String @id + serverId String @unique + billingCustomerId String + stripeSubscriptionId String @unique + stripePriceId String + stripeProductId String + status SubscriptionStatus @default(incomplete) // NodeByte-facing plan metadata - planName String // e.g. "CX21", "CPX31" - pricePerMonthCents Int // NodeByte price (not Hetzner base) - currency String @default("GBP") - currentPeriodStart DateTime? - currentPeriodEnd DateTime? - canceledAt DateTime? - suspendedAt DateTime? // set when server is suspended due to non-payment + planName String // e.g. "CX21", "CPX31" + pricePerMonthCents Int // NodeByte price (not Hetzner base) + // First-month fixed fee and subsequent Hetzner hourly cost-plus rate. + hourlyRateMilliCents Int? // GBP thousandths of a penny per provider hour + usageBillingStartedAt DateTime? + usageLastBilledAt DateTime? + currency String @default("GBP") + currentPeriodStart DateTime? + currentPeriodEnd DateTime? + canceledAt DateTime? + suspendedAt DateTime? // set when server is suspended due to non-payment // Promo / discount - promoCode String? // human-readable promo code applied - discountAmountCents Int? // flat GBP pence discount (if any) - trialEnd DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - server Server @relation(fields: [serverId], references: [id], onDelete: Cascade) - billingCustomer BillingCustomer @relation(fields: [billingCustomerId], references: [id]) - invoices Invoice[] - addons ServerAddon[] + promoCode String? // human-readable promo code applied + discountAmountCents Int? // flat GBP pence discount (if any) + trialEnd DateTime? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + server Server @relation(fields: [serverId], references: [id], onDelete: Cascade) + billingCustomer BillingCustomer @relation(fields: [billingCustomerId], references: [id]) + invoices Invoice[] + addons ServerAddon[] + usageInvoices UsageInvoice[] @@index([billingCustomerId]) @@index([status]) @@map("subscriptions") } +model UsageInvoice { + id String @id @default(cuid()) + subscriptionId String + periodStart DateTime + periodEnd DateTime + amountCents Int + stripeInvoiceId String? @unique + createdAt DateTime @default(now()) + subscription Subscription @relation(fields: [subscriptionId], references: [id], onDelete: Cascade) + + @@unique([subscriptionId, periodStart]) + @@index([subscriptionId]) + @@map("usage_invoices") +} + enum InvoiceStatus { draft open diff --git a/test/hetzner-catalog.test.ts b/test/hetzner-catalog.test.ts index ff228d5..ce2fc7b 100644 --- a/test/hetzner-catalog.test.ts +++ b/test/hetzner-catalog.test.ts @@ -55,8 +55,16 @@ const baseServerType = (overrides: Record = {}) => ({ memory: 4, name: "cx22", prices: [ - { location: "fsn1", price_monthly: { gross: "5.00" } }, - { location: "nbg1", price_monthly: { gross: "6.00" } }, + { + location: "fsn1", + price_hourly: { gross: "0.01" }, + price_monthly: { gross: "5.00" }, + }, + { + location: "nbg1", + price_hourly: { gross: "0.01" }, + price_monthly: { gross: "6.00" }, + }, ], ...overrides, }); @@ -102,9 +110,12 @@ describe("getHetznerCatalog", () => { expect(type.name).toBe("cx22"); expect(type.cpuType).toBe("shared"); expect(type.architecture).toBe("x86"); + expect(type.pricePerMonth).toBe(6.5); + expect(type.hourlyPriceMilliCents).toBe(1204); expect(type.locations.map((l) => l.name)).toEqual(["fsn1", "nbg1"]); expect(type.locations[0]).toMatchObject({ available: true, name: "fsn1" }); expect(type.locations[1]).toMatchObject({ available: false, name: "nbg1" }); + expect(type.locations[0].hourlyPriceMilliCents).toBe(1204); }); test("falls back to alphabetical name sort when locations share availability", async () => { diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..2720d9b --- /dev/null +++ b/vercel.json @@ -0,0 +1,8 @@ +{ + "crons": [ + { + "path": "/api/cron/billing", + "schedule": "15 * * * *" + } + ] +} From c53ad8923471439d0faac5630735b1ab34fbb797 Mon Sep 17 00:00:00 2001 From: Rizon Date: Sat, 22 Aug 2026 01:16:55 +0100 Subject: [PATCH 2/4] update: providers --- lib/providers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/providers b/lib/providers index f741ebe..1d587d4 160000 --- a/lib/providers +++ b/lib/providers @@ -1 +1 @@ -Subproject commit f741ebe318460fcd2c2da05a1775a4a456537b4a +Subproject commit 1d587d43ab9b6aa4273c2acba2be8fd6e99c8d68 From 7f91e064226c88e9cfef4c3c4a3cecd4f8eecdcb Mon Sep 17 00:00:00 2001 From: Rizon Date: Sat, 22 Aug 2026 01:21:30 +0100 Subject: [PATCH 3/4] chore: prettier --- agent | 2 +- bun.lock | 7 +- components/ui/accordion.tsx | 36 ++-- components/ui/alert-dialog.tsx | 52 +++--- components/ui/alert.tsx | 24 +-- components/ui/aspect-ratio.tsx | 8 +- components/ui/avatar.tsx | 36 ++-- components/ui/badge.tsx | 18 +- components/ui/breadcrumb.tsx | 39 ++-- components/ui/button-group.tsx | 28 +-- components/ui/button.tsx | 20 +-- components/ui/calendar.tsx | 89 +++++----- components/ui/card.tsx | 28 +-- components/ui/carousel.tsx | 136 +++++++------- components/ui/chart.tsx | 160 ++++++++--------- components/ui/checkbox.tsx | 19 +- components/ui/collapsible.tsx | 12 +- components/ui/command.tsx | 59 +++--- components/ui/context-menu.tsx | 84 ++++----- components/ui/dialog.tsx | 54 +++--- components/ui/direction.tsx | 14 +- components/ui/drawer.tsx | 41 ++--- components/ui/dropdown-menu.tsx | 82 +++++---- components/ui/empty.tsx | 33 ++-- components/ui/field.tsx | 74 ++++---- components/ui/form.tsx | 81 ++++----- components/ui/hover-card.tsx | 18 +- components/ui/input-group.tsx | 48 ++--- components/ui/input-otp.tsx | 37 ++-- components/ui/input.tsx | 10 +- components/ui/item.tsx | 54 +++--- components/ui/kbd.tsx | 10 +- components/ui/label.tsx | 14 +- components/ui/menubar.tsx | 86 ++++----- components/ui/native-select.tsx | 26 +-- components/ui/navigation-menu.tsx | 53 +++--- components/ui/pagination.tsx | 37 ++-- components/ui/popover.tsx | 26 +-- components/ui/progress.tsx | 14 +- components/ui/radio-group.tsx | 16 +- components/ui/resizable.tsx | 20 +-- components/ui/scroll-area.tsx | 16 +- components/ui/select.tsx | 59 +++--- components/ui/separator.tsx | 14 +- components/ui/shared-sidebar.tsx | 20 +-- components/ui/sheet.tsx | 50 +++--- components/ui/sidebar.tsx | 286 +++++++++++++++--------------- components/ui/skeleton.tsx | 6 +- components/ui/slider.tsx | 18 +- components/ui/sonner.tsx | 42 ++--- components/ui/spinner.tsx | 15 +- components/ui/switch.tsx | 16 +- components/ui/table.tsx | 32 ++-- components/ui/tabs.tsx | 28 +-- components/ui/textarea.tsx | 10 +- components/ui/toggle-group.tsx | 34 ++-- components/ui/toggle.tsx | 18 +- components/ui/tooltip.tsx | 20 +-- games | 2 +- hooks/use-mobile.ts | 24 +-- lib/utils.ts | 6 +- package.json | 5 +- 62 files changed, 1225 insertions(+), 1201 deletions(-) diff --git a/agent b/agent index 52ea16d..2f4d61a 160000 --- a/agent +++ b/agent @@ -1 +1 @@ -Subproject commit 52ea16d9af8e2435c79075eba765efff24bc451a +Subproject commit 2f4d61a1f0f7bada99b91cb471b76f65864ea401 diff --git a/bun.lock b/bun.lock index ccf4768..742637d 100644 --- a/bun.lock +++ b/bun.lock @@ -79,6 +79,7 @@ "oxfmt": "^0.48.0", "oxlint": "^1.63.0", "postcss": "^8.5.14", + "prettier": "3.9.6", "prisma": "^7.8.0", "tailwindcss": "^4.2.4", "tailwindcss-animate": "^1.0.7", @@ -2464,7 +2465,7 @@ "powershell-utils": ["powershell-utils@0.1.0", "", {}, "sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A=="], - "prettier": ["prettier@2.8.8", "", { "bin": { "prettier": "bin-prettier.js" } }, "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q=="], + "prettier": ["prettier@3.9.6", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g=="], "pretty-ms": ["pretty-ms@9.3.0", "", { "dependencies": { "parse-ms": "^4.0.0" } }, "sha512-gjVS5hOP+M3wMm5nmNOucbIrqudzs9v/57bWRHQWLYklXqoXKrVfYW2W9+glfGsqtPgpiz5WwyEEB+ksXIx3gQ=="], @@ -2958,8 +2959,12 @@ "@better-auth/passkey/zod": ["zod@4.4.1", "", {}, "sha512-a6ENMBBGZBsnlSebQ/eKCguSBeGKSf4O7BPnqVPmYGtpBYI7VSqoVqw+QcB7kPRjbqPwhYTpFbVj/RqNz/CT0Q=="], + "@changesets/apply-release-plan/prettier": ["prettier@2.8.8", "", { "bin": { "prettier": "bin-prettier.js" } }, "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q=="], + "@changesets/get-github-info/node-fetch": ["node-fetch@2.7.0", "", { "dependencies": { "whatwg-url": "^5.0.0" }, "peerDependencies": { "encoding": "^0.1.0" }, "optionalPeers": ["encoding"] }, "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A=="], + "@changesets/write/prettier": ["prettier@2.8.8", "", { "bin": { "prettier": "bin-prettier.js" } }, "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q=="], + "@dotenvx/dotenvx/commander": ["commander@11.1.0", "", {}, "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ=="], "@dotenvx/dotenvx/dotenv": ["dotenv@17.4.2", "", {}, "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw=="], diff --git a/components/ui/accordion.tsx b/components/ui/accordion.tsx index ce3db75..e94b372 100644 --- a/components/ui/accordion.tsx +++ b/components/ui/accordion.tsx @@ -1,10 +1,10 @@ -"use client" +"use client"; -import * as React from "react" -import { Accordion as AccordionPrimitive } from "radix-ui" +import * as React from "react"; +import { Accordion as AccordionPrimitive } from "radix-ui"; -import { cn } from "@/lib/utils" -import { ChevronDownIcon, ChevronUpIcon } from "lucide-react" +import { cn } from "@/lib/utils"; +import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"; function Accordion({ className, @@ -15,11 +15,11 @@ function Accordion({ data-slot="accordion" className={cn( "flex w-full flex-col overflow-hidden rounded-2xl border", - className + className, )} {...props} /> - ) + ); } function AccordionItem({ @@ -32,7 +32,7 @@ function AccordionItem({ className={cn("not-last:border-b data-open:bg-muted/50", className)} {...props} /> - ) + ); } function AccordionTrigger({ @@ -46,16 +46,22 @@ function AccordionTrigger({ data-slot="accordion-trigger" className={cn( "group/accordion-trigger relative flex flex-1 items-start justify-between gap-6 border border-transparent p-4 text-left text-sm font-medium transition-all outline-none hover:underline disabled:pointer-events-none disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground", - className + className, )} {...props} > {children} - - + + - ) + ); } function AccordionContent({ @@ -72,13 +78,13 @@ function AccordionContent({
{children}
- ) + ); } -export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }; diff --git a/components/ui/alert-dialog.tsx b/components/ui/alert-dialog.tsx index 96158b0..ffc7acf 100644 --- a/components/ui/alert-dialog.tsx +++ b/components/ui/alert-dialog.tsx @@ -1,15 +1,15 @@ -"use client" +"use client"; -import * as React from "react" -import { AlertDialog as AlertDialogPrimitive } from "radix-ui" +import * as React from "react"; +import { AlertDialog as AlertDialogPrimitive } from "radix-ui"; -import { cn } from "@/lib/utils" -import { Button } from "@/components/ui/button" +import { cn } from "@/lib/utils"; +import { Button } from "@/components/ui/button"; function AlertDialog({ ...props }: React.ComponentProps) { - return + return ; } function AlertDialogTrigger({ @@ -17,7 +17,7 @@ function AlertDialogTrigger({ }: React.ComponentProps) { return ( - ) + ); } function AlertDialogPortal({ @@ -25,7 +25,7 @@ function AlertDialogPortal({ }: React.ComponentProps) { return ( - ) + ); } function AlertDialogOverlay({ @@ -37,11 +37,11 @@ function AlertDialogOverlay({ data-slot="alert-dialog-overlay" className={cn( "fixed inset-0 z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", - className + className, )} {...props} /> - ) + ); } function AlertDialogContent({ @@ -49,7 +49,7 @@ function AlertDialogContent({ size = "default", ...props }: React.ComponentProps & { - size?: "default" | "sm" + size?: "default" | "sm"; }) { return ( @@ -59,12 +59,12 @@ function AlertDialogContent({ data-size={size} className={cn( "group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-4xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/5 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", - className + className, )} {...props} /> - ) + ); } function AlertDialogHeader({ @@ -76,11 +76,11 @@ function AlertDialogHeader({ data-slot="alert-dialog-header" className={cn( "grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", - className + className, )} {...props} /> - ) + ); } function AlertDialogFooter({ @@ -92,11 +92,11 @@ function AlertDialogFooter({ data-slot="alert-dialog-footer" className={cn( "flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end", - className + className, )} {...props} /> - ) + ); } function AlertDialogMedia({ @@ -108,11 +108,11 @@ function AlertDialogMedia({ data-slot="alert-dialog-media" className={cn( "mb-2 inline-flex size-16 items-center justify-center rounded-full bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8", - className + className, )} {...props} /> - ) + ); } function AlertDialogTitle({ @@ -124,11 +124,11 @@ function AlertDialogTitle({ data-slot="alert-dialog-title" className={cn( "text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2", - className + className, )} {...props} /> - ) + ); } function AlertDialogDescription({ @@ -140,11 +140,11 @@ function AlertDialogDescription({ data-slot="alert-dialog-description" className={cn( "text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", - className + className, )} {...props} /> - ) + ); } function AlertDialogAction({ @@ -162,7 +162,7 @@ function AlertDialogAction({ {...props} /> - ) + ); } function AlertDialogCancel({ @@ -180,7 +180,7 @@ function AlertDialogCancel({ {...props} /> - ) + ); } export { @@ -196,4 +196,4 @@ export { AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, -} +}; diff --git a/components/ui/alert.tsx b/components/ui/alert.tsx index 2d8ecac..0588f71 100644 --- a/components/ui/alert.tsx +++ b/components/ui/alert.tsx @@ -1,7 +1,7 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const alertVariants = cva( "group/alert relative grid w-full gap-0.5 rounded-lg border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4", @@ -16,8 +16,8 @@ const alertVariants = cva( defaultVariants: { variant: "default", }, - } -) + }, +); function Alert({ className, @@ -31,7 +31,7 @@ function Alert({ className={cn(alertVariants({ variant }), className)} {...props} /> - ) + ); } function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { @@ -40,11 +40,11 @@ function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { data-slot="alert-title" className={cn( "font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground", - className + className, )} {...props} /> - ) + ); } function AlertDescription({ @@ -56,11 +56,11 @@ function AlertDescription({ data-slot="alert-description" className={cn( "text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4", - className + className, )} {...props} /> - ) + ); } function AlertAction({ className, ...props }: React.ComponentProps<"div">) { @@ -70,7 +70,7 @@ function AlertAction({ className, ...props }: React.ComponentProps<"div">) { className={cn("absolute top-2.5 right-3", className)} {...props} /> - ) + ); } -export { Alert, AlertTitle, AlertDescription, AlertAction } +export { Alert, AlertTitle, AlertDescription, AlertAction }; diff --git a/components/ui/aspect-ratio.tsx b/components/ui/aspect-ratio.tsx index 57e38fa..41720ca 100644 --- a/components/ui/aspect-ratio.tsx +++ b/components/ui/aspect-ratio.tsx @@ -1,11 +1,11 @@ -"use client" +"use client"; -import { AspectRatio as AspectRatioPrimitive } from "radix-ui" +import { AspectRatio as AspectRatioPrimitive } from "radix-ui"; function AspectRatio({ ...props }: React.ComponentProps) { - return + return ; } -export { AspectRatio } +export { AspectRatio }; diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx index 47ff2e2..f283711 100644 --- a/components/ui/avatar.tsx +++ b/components/ui/avatar.tsx @@ -1,16 +1,16 @@ -"use client" +"use client"; -import * as React from "react" -import { Avatar as AvatarPrimitive } from "radix-ui" +import * as React from "react"; +import { Avatar as AvatarPrimitive } from "radix-ui"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Avatar({ className, size = "default", ...props }: React.ComponentProps & { - size?: "default" | "sm" | "lg" + size?: "default" | "sm" | "lg"; }) { return ( - ) + ); } function AvatarImage({ @@ -34,11 +34,11 @@ function AvatarImage({ data-slot="avatar-image" className={cn( "aspect-square size-full rounded-full object-cover", - className + className, )} {...props} /> - ) + ); } function AvatarFallback({ @@ -50,11 +50,11 @@ function AvatarFallback({ data-slot="avatar-fallback" className={cn( "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs", - className + className, )} {...props} /> - ) + ); } function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) { @@ -66,11 +66,11 @@ function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) { "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden", "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2", "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2", - className + className, )} {...props} /> - ) + ); } function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) { @@ -79,11 +79,11 @@ function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) { data-slot="avatar-group" className={cn( "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background", - className + className, )} {...props} /> - ) + ); } function AvatarGroupCount({ @@ -95,11 +95,11 @@ function AvatarGroupCount({ data-slot="avatar-group-count" className={cn( "relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3", - className + className, )} {...props} /> - ) + ); } export { @@ -109,4 +109,4 @@ export { AvatarGroup, AvatarGroupCount, AvatarBadge, -} +}; diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx index f428bc5..0f82c2d 100644 --- a/components/ui/badge.tsx +++ b/components/ui/badge.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" -import { Slot } from "radix-ui" +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; +import { Slot } from "radix-ui"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const badgeVariants = cva( "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", @@ -24,8 +24,8 @@ const badgeVariants = cva( defaultVariants: { variant: "default", }, - } -) + }, +); function Badge({ className, @@ -34,7 +34,7 @@ function Badge({ ...props }: React.ComponentProps<"span"> & VariantProps & { asChild?: boolean }) { - const Comp = asChild ? Slot.Root : "span" + const Comp = asChild ? Slot.Root : "span"; return ( - ) + ); } -export { Badge, badgeVariants } +export { Badge, badgeVariants }; diff --git a/components/ui/breadcrumb.tsx b/components/ui/breadcrumb.tsx index a48cc1f..93b801b 100644 --- a/components/ui/breadcrumb.tsx +++ b/components/ui/breadcrumb.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import { Slot } from "radix-ui" +import * as React from "react"; +import { Slot } from "radix-ui"; -import { cn } from "@/lib/utils" -import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react" +import { cn } from "@/lib/utils"; +import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"; function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) { return ( @@ -12,7 +12,7 @@ function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) { className={cn(className)} {...props} /> - ) + ); } function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) { @@ -21,11 +21,11 @@ function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) { data-slot="breadcrumb-list" className={cn( "flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground sm:gap-2.5", - className + className, )} {...props} /> - ) + ); } function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) { @@ -35,7 +35,7 @@ function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) { className={cn("inline-flex items-center gap-1.5", className)} {...props} /> - ) + ); } function BreadcrumbLink({ @@ -43,9 +43,9 @@ function BreadcrumbLink({ className, ...props }: React.ComponentProps<"a"> & { - asChild?: boolean + asChild?: boolean; }) { - const Comp = asChild ? Slot.Root : "a" + const Comp = asChild ? Slot.Root : "a"; return ( - ) + ); } function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) { @@ -66,7 +66,7 @@ function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) { className={cn("font-normal text-foreground", className)} {...props} /> - ) + ); } function BreadcrumbSeparator({ @@ -82,11 +82,9 @@ function BreadcrumbSeparator({ className={cn("[&>svg]:size-3.5", className)} {...props} > - {children ?? ( - - )} + {children ?? } - ) + ); } function BreadcrumbEllipsis({ @@ -100,15 +98,14 @@ function BreadcrumbEllipsis({ aria-hidden="true" className={cn( "flex size-5 items-center justify-center [&>svg]:size-4", - className + className, )} {...props} > - + More - ) + ); } export { @@ -119,4 +116,4 @@ export { BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, -} +}; diff --git a/components/ui/button-group.tsx b/components/ui/button-group.tsx index e1c0f5b..e49f638 100644 --- a/components/ui/button-group.tsx +++ b/components/ui/button-group.tsx @@ -1,8 +1,8 @@ -import { cva, type VariantProps } from "class-variance-authority" -import { Slot } from "radix-ui" +import { cva, type VariantProps } from "class-variance-authority"; +import { Slot } from "radix-ui"; -import { cn } from "@/lib/utils" -import { Separator } from "@/components/ui/separator" +import { cn } from "@/lib/utils"; +import { Separator } from "@/components/ui/separator"; const buttonGroupVariants = cva( "group/button-group flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-4xl [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", @@ -18,8 +18,8 @@ const buttonGroupVariants = cva( defaultVariants: { orientation: "horizontal", }, - } -) + }, +); function ButtonGroup({ className, @@ -34,7 +34,7 @@ function ButtonGroup({ className={cn(buttonGroupVariants({ orientation }), className)} {...props} /> - ) + ); } function ButtonGroupText({ @@ -42,19 +42,19 @@ function ButtonGroupText({ asChild = false, ...props }: React.ComponentProps<"div"> & { - asChild?: boolean + asChild?: boolean; }) { - const Comp = asChild ? Slot.Root : "div" + const Comp = asChild ? Slot.Root : "div"; return ( - ) + ); } function ButtonGroupSeparator({ @@ -68,11 +68,11 @@ function ButtonGroupSeparator({ orientation={orientation} className={cn( "relative self-stretch bg-input data-horizontal:mx-px data-horizontal:w-auto data-vertical:my-px data-vertical:h-auto", - className + className, )} {...props} /> - ) + ); } export { @@ -80,4 +80,4 @@ export { ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants, -} +}; diff --git a/components/ui/button.tsx b/components/ui/button.tsx index 652d5d3..2644971 100644 --- a/components/ui/button.tsx +++ b/components/ui/button.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" -import { Slot } from "radix-ui" +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; +import { Slot } from "radix-ui"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const buttonVariants = cva( "group/button inline-flex shrink-0 items-center justify-center rounded-4xl border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", @@ -36,8 +36,8 @@ const buttonVariants = cva( variant: "default", size: "default", }, - } -) + }, +); function Button({ className, @@ -47,9 +47,9 @@ function Button({ ...props }: React.ComponentProps<"button"> & VariantProps & { - asChild?: boolean + asChild?: boolean; }) { - const Comp = asChild ? Slot.Root : "button" + const Comp = asChild ? Slot.Root : "button"; return ( - ) + ); } -export { Button, buttonVariants } +export { Button, buttonVariants }; diff --git a/components/ui/calendar.tsx b/components/ui/calendar.tsx index 5329e12..c9119c2 100644 --- a/components/ui/calendar.tsx +++ b/components/ui/calendar.tsx @@ -1,16 +1,20 @@ -"use client" +"use client"; -import * as React from "react" +import * as React from "react"; import { DayPicker, getDefaultClassNames, type DayButton, type Locale, -} from "react-day-picker" +} from "react-day-picker"; -import { cn } from "@/lib/utils" -import { Button, buttonVariants } from "@/components/ui/button" -import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react" +import { cn } from "@/lib/utils"; +import { Button, buttonVariants } from "@/components/ui/button"; +import { + ChevronLeftIcon, + ChevronRightIcon, + ChevronDownIcon, +} from "lucide-react"; function Calendar({ className, @@ -23,9 +27,9 @@ function Calendar({ components, ...props }: React.ComponentProps & { - buttonVariant?: React.ComponentProps["variant"] + buttonVariant?: React.ComponentProps["variant"]; }) { - const defaultClassNames = getDefaultClassNames() + const defaultClassNames = getDefaultClassNames(); return ( svg]:rotate-180`, String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`, - className + className, )} captionLayout={captionLayout} locale={locale} @@ -47,88 +51,88 @@ function Calendar({ root: cn("w-fit", defaultClassNames.root), months: cn( "relative flex flex-col gap-4 md:flex-row", - defaultClassNames.months + defaultClassNames.months, ), month: cn("flex w-full flex-col gap-4", defaultClassNames.month), nav: cn( "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1", - defaultClassNames.nav + defaultClassNames.nav, ), button_previous: cn( buttonVariants({ variant: buttonVariant }), "size-(--cell-size) p-0 select-none aria-disabled:opacity-50", - defaultClassNames.button_previous + defaultClassNames.button_previous, ), button_next: cn( buttonVariants({ variant: buttonVariant }), "size-(--cell-size) p-0 select-none aria-disabled:opacity-50", - defaultClassNames.button_next + defaultClassNames.button_next, ), month_caption: cn( "flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)", - defaultClassNames.month_caption + defaultClassNames.month_caption, ), dropdowns: cn( "flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium", - defaultClassNames.dropdowns + defaultClassNames.dropdowns, ), dropdown_root: cn( "relative rounded-(--cell-radius)", - defaultClassNames.dropdown_root + defaultClassNames.dropdown_root, ), dropdown: cn( "absolute inset-0 bg-popover opacity-0", - defaultClassNames.dropdown + defaultClassNames.dropdown, ), caption_label: cn( "font-medium select-none", captionLayout === "label" ? "text-sm" : "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground", - defaultClassNames.caption_label + defaultClassNames.caption_label, ), table: "w-full border-collapse", weekdays: cn("flex", defaultClassNames.weekdays), weekday: cn( "flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none", - defaultClassNames.weekday + defaultClassNames.weekday, ), week: cn("mt-2 flex w-full", defaultClassNames.week), week_number_header: cn( "w-(--cell-size) select-none", - defaultClassNames.week_number_header + defaultClassNames.week_number_header, ), week_number: cn( "text-[0.8rem] text-muted-foreground select-none", - defaultClassNames.week_number + defaultClassNames.week_number, ), day: cn( "group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)", props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)" : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)", - defaultClassNames.day + defaultClassNames.day, ), range_start: cn( "relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted", - defaultClassNames.range_start + defaultClassNames.range_start, ), range_middle: cn("rounded-none", defaultClassNames.range_middle), range_end: cn( "relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted", - defaultClassNames.range_end + defaultClassNames.range_end, ), today: cn( "rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none", - defaultClassNames.today + defaultClassNames.today, ), outside: cn( "text-muted-foreground aria-selected:text-muted-foreground", - defaultClassNames.outside + defaultClassNames.outside, ), disabled: cn( "text-muted-foreground opacity-50", - defaultClassNames.disabled + defaultClassNames.disabled, ), hidden: cn("invisible", defaultClassNames.hidden), ...classNames, @@ -142,24 +146,27 @@ function Calendar({ className={cn(className)} {...props} /> - ) + ); }, Chevron: ({ className, orientation, ...props }) => { if (orientation === "left") { return ( - ) + ); } if (orientation === "right") { return ( - - ) + + ); } return ( - ) + ); }, DayButton: ({ ...props }) => ( @@ -171,13 +178,13 @@ function Calendar({ {children} - ) + ); }, ...components, }} {...props} /> - ) + ); } function CalendarDayButton({ @@ -187,12 +194,12 @@ function CalendarDayButton({ locale, ...props }: React.ComponentProps & { locale?: Partial }) { - const defaultClassNames = getDefaultClassNames() + const defaultClassNames = getDefaultClassNames(); - const ref = React.useRef(null) + const ref = React.useRef(null); React.useEffect(() => { - if (modifiers.focused) ref.current?.focus() - }, [modifiers.focused]) + if (modifiers.focused) ref.current?.focus(); + }, [modifiers.focused]); return ( - ) + ); } function CarouselNext({ @@ -207,7 +207,7 @@ function CarouselNext({ size = "icon-sm", ...props }: React.ComponentProps) { - const { orientation, scrollNext, canScrollNext } = useCarousel() + const { orientation, scrollNext, canScrollNext } = useCarousel(); return ( - ) + ); } export { @@ -239,4 +239,4 @@ export { CarouselPrevious, CarouselNext, useCarousel, -} +}; diff --git a/components/ui/chart.tsx b/components/ui/chart.tsx index 7c2dc84..b59312a 100644 --- a/components/ui/chart.tsx +++ b/components/ui/chart.tsx @@ -1,42 +1,42 @@ -"use client" +"use client"; -import * as React from "react" -import * as RechartsPrimitive from "recharts" -import type { TooltipValueType } from "recharts" +import * as React from "react"; +import * as RechartsPrimitive from "recharts"; +import type { TooltipValueType } 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; -const INITIAL_DIMENSION = { width: 320, height: 200 } as const -type TooltipNameType = number | string +const INITIAL_DIMENSION = { width: 320, height: 200 } as const; +type TooltipNameType = number | string; export type ChartConfig = Record< string, { - label?: React.ReactNode - icon?: React.ComponentType + 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 ") + throw new Error("useChart must be used within a "); } - return context + return context; } function ChartContainer({ @@ -47,17 +47,17 @@ function ChartContainer({ initialDimension = INITIAL_DIMENSION, ...props }: React.ComponentProps<"div"> & { - config: ChartConfig + config: ChartConfig; children: React.ComponentProps< typeof RechartsPrimitive.ResponsiveContainer - >["children"] + >["children"]; initialDimension?: { - width: number - height: number - } + width: number; + height: number; + }; }) { - const uniqueId = React.useId() - const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}` + const uniqueId = React.useId(); + const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`; return ( @@ -66,7 +66,7 @@ function ChartContainer({ data-chart={chartId} className={cn( "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", - className + className, )} {...props} > @@ -78,16 +78,16 @@ function ChartContainer({ - ) + ); } const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { const colorConfig = Object.entries(config).filter( - ([, config]) => config.theme ?? config.color - ) + ([, config]) => config.theme ?? config.color, + ); if (!colorConfig.length) { - return null + return null; } return ( @@ -101,20 +101,20 @@ ${colorConfig .map(([key, itemConfig]) => { const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ?? - itemConfig.color - return color ? ` --color-${key}: ${color};` : null + itemConfig.color; + return color ? ` --color-${key}: ${color};` : null; }) .join("\n")} } -` +`, ) .join("\n"), }} /> - ) -} + ); +}; -const ChartTooltip = RechartsPrimitive.Tooltip +const ChartTooltip = RechartsPrimitive.Tooltip; function ChartTooltipContent({ active, @@ -132,11 +132,11 @@ function ChartTooltipContent({ labelKey, }: React.ComponentProps & React.ComponentProps<"div"> & { - hideLabel?: boolean - hideIndicator?: boolean - indicator?: "line" | "dot" | "dashed" - nameKey?: string - labelKey?: string + hideLabel?: boolean; + hideIndicator?: boolean; + indicator?: "line" | "dot" | "dashed"; + nameKey?: string; + labelKey?: string; } & Omit< RechartsPrimitive.DefaultTooltipContentProps< TooltipValueType, @@ -144,34 +144,34 @@ function ChartTooltipContent({ >, "accessibilityLayer" >) { - const { config } = useChart() + const { config } = useChart(); const tooltipLabel = React.useMemo(() => { if (hideLabel || !payload?.length) { - return null + return null; } - const [item] = payload - const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}` - const itemConfig = getPayloadConfigFromPayload(config, item, key) + const [item] = payload; + const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`; + const itemConfig = getPayloadConfigFromPayload(config, item, key); const value = !labelKey && typeof label === "string" ? (config[label]?.label ?? label) - : itemConfig?.label + : itemConfig?.label; if (labelFormatter) { return (
{labelFormatter(value, payload)}
- ) + ); } if (!value) { - return null + return null; } - return
{value}
+ return
{value}
; }, [ label, labelFormatter, @@ -180,19 +180,19 @@ function ChartTooltipContent({ labelClassName, config, labelKey, - ]) + ]); if (!active || !payload?.length) { - return null + return null; } - const nestLabel = payload.length === 1 && indicator !== "dot" + const nestLabel = payload.length === 1 && indicator !== "dot"; return (
{!nestLabel ? tooltipLabel : null} @@ -200,16 +200,16 @@ function ChartTooltipContent({ {payload .filter((item) => item.type !== "none") .map((item, index) => { - const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}` - const itemConfig = getPayloadConfigFromPayload(config, item, key) - const indicatorColor = color ?? item.payload?.fill ?? item.color + const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`; + const itemConfig = getPayloadConfigFromPayload(config, item, key); + const indicatorColor = color ?? item.payload?.fill ?? item.color; return (
svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", - indicator === "dot" && "items-center" + indicator === "dot" && "items-center", )} > {formatter && item?.value !== undefined && item.name ? ( @@ -229,7 +229,7 @@ function ChartTooltipContent({ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed", "my-0.5": nestLabel && indicator === "dashed", - } + }, )} style={ { @@ -243,7 +243,7 @@ function ChartTooltipContent({
@@ -263,14 +263,14 @@ function ChartTooltipContent({ )}
- ) + ); })}
- ) + ); } -const ChartLegend = RechartsPrimitive.Legend +const ChartLegend = RechartsPrimitive.Legend; function ChartLegendContent({ className, @@ -279,13 +279,13 @@ function ChartLegendContent({ verticalAlign = "bottom", nameKey, }: React.ComponentProps<"div"> & { - hideIcon?: boolean - nameKey?: string + hideIcon?: boolean; + nameKey?: string; } & RechartsPrimitive.DefaultLegendContentProps) { - const { config } = useChart() + const { config } = useChart(); if (!payload?.length) { - return null + return null; } return ( @@ -293,20 +293,20 @@ function ChartLegendContent({ className={cn( "flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", - className + className, )} > {payload .filter((item) => item.type !== "none") .map((item, index) => { - const key = `${nameKey ?? item.dataKey ?? "value"}` - const itemConfig = getPayloadConfigFromPayload(config, item, key) + const key = `${nameKey ?? item.dataKey ?? "value"}`; + const itemConfig = getPayloadConfigFromPayload(config, item, key); return (
svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground" + "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground", )} > {itemConfig?.icon && !hideIcon ? ( @@ -321,19 +321,19 @@ function ChartLegendContent({ )} {itemConfig?.label}
- ) + ); })}
- ) + ); } function getPayloadConfigFromPayload( config: ChartConfig, payload: unknown, - key: string + key: string, ) { if (typeof payload !== "object" || payload === null) { - return undefined + return undefined; } const payloadPayload = @@ -341,15 +341,15 @@ function getPayloadConfigFromPayload( typeof payload.payload === "object" && payload.payload !== null ? payload.payload - : undefined + : undefined; - let configLabelKey: string = key + let configLabelKey: string = key; if ( key in payload && typeof payload[key as keyof typeof payload] === "string" ) { - configLabelKey = payload[key as keyof typeof payload] as string + configLabelKey = payload[key as keyof typeof payload] as string; } else if ( payloadPayload && key in payloadPayload && @@ -357,10 +357,10 @@ function getPayloadConfigFromPayload( ) { configLabelKey = payloadPayload[ key as keyof typeof payloadPayload - ] as string + ] as string; } - return configLabelKey in config ? config[configLabelKey] : config[key] + return configLabelKey in config ? config[configLabelKey] : config[key]; } export { @@ -370,4 +370,4 @@ export { ChartLegend, ChartLegendContent, ChartStyle, -} +}; diff --git a/components/ui/checkbox.tsx b/components/ui/checkbox.tsx index 9e22145..f94b930 100644 --- a/components/ui/checkbox.tsx +++ b/components/ui/checkbox.tsx @@ -1,10 +1,10 @@ -"use client" +"use client"; -import * as React from "react" -import { Checkbox as CheckboxPrimitive } from "radix-ui" +import * as React from "react"; +import { Checkbox as CheckboxPrimitive } from "radix-ui"; -import { cn } from "@/lib/utils" -import { CheckIcon } from "lucide-react" +import { cn } from "@/lib/utils"; +import { CheckIcon } from "lucide-react"; function Checkbox({ className, @@ -15,7 +15,7 @@ function Checkbox({ data-slot="checkbox" className={cn( "peer relative flex size-4 shrink-0 items-center justify-center rounded-[6px] border border-input transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary", - className + className, )} {...props} > @@ -23,11 +23,10 @@ function Checkbox({ data-slot="checkbox-indicator" className="grid place-content-center text-current transition-none [&>svg]:size-3.5" > - + - ) + ); } -export { Checkbox } +export { Checkbox }; diff --git a/components/ui/collapsible.tsx b/components/ui/collapsible.tsx index 2f7a4e7..a8bf893 100644 --- a/components/ui/collapsible.tsx +++ b/components/ui/collapsible.tsx @@ -1,11 +1,11 @@ -"use client" +"use client"; -import { Collapsible as CollapsiblePrimitive } from "radix-ui" +import { Collapsible as CollapsiblePrimitive } from "radix-ui"; function Collapsible({ ...props }: React.ComponentProps) { - return + return ; } function CollapsibleTrigger({ @@ -16,7 +16,7 @@ function CollapsibleTrigger({ data-slot="collapsible-trigger" {...props} /> - ) + ); } function CollapsibleContent({ @@ -27,7 +27,7 @@ function CollapsibleContent({ data-slot="collapsible-content" {...props} /> - ) + ); } -export { Collapsible, CollapsibleTrigger, CollapsibleContent } +export { Collapsible, CollapsibleTrigger, CollapsibleContent }; diff --git a/components/ui/command.tsx b/components/ui/command.tsx index d6375b3..d240bc8 100644 --- a/components/ui/command.tsx +++ b/components/ui/command.tsx @@ -1,21 +1,18 @@ -"use client" +"use client"; -import * as React from "react" -import { Command as CommandPrimitive } from "cmdk" +import * as React from "react"; +import { Command as CommandPrimitive } from "cmdk"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, -} from "@/components/ui/dialog" -import { - InputGroup, - InputGroupAddon, -} from "@/components/ui/input-group" -import { SearchIcon, CheckIcon } from "lucide-react" +} from "@/components/ui/dialog"; +import { InputGroup, InputGroupAddon } from "@/components/ui/input-group"; +import { SearchIcon, CheckIcon } from "lucide-react"; function Command({ className, @@ -26,11 +23,11 @@ function Command({ data-slot="command" className={cn( "flex size-full flex-col overflow-hidden rounded-4xl bg-popover p-1 text-popover-foreground", - className + className, )} {...props} /> - ) + ); } function CommandDialog({ @@ -41,10 +38,10 @@ function CommandDialog({ showCloseButton = false, ...props }: React.ComponentProps & { - title?: string - description?: string - className?: string - showCloseButton?: boolean + title?: string; + description?: string; + className?: string; + showCloseButton?: boolean; }) { return ( @@ -55,14 +52,14 @@ function CommandDialog({ {children} - ) + ); } function CommandInput({ @@ -76,7 +73,7 @@ function CommandInput({ data-slot="command-input" className={cn( "w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50", - className + className, )} {...props} /> @@ -85,7 +82,7 @@ function CommandInput({ - ) + ); } function CommandList({ @@ -97,11 +94,11 @@ function CommandList({ data-slot="command-list" className={cn( "no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none", - className + className, )} {...props} /> - ) + ); } function CommandEmpty({ @@ -114,7 +111,7 @@ function CommandEmpty({ className={cn("py-6 text-center text-sm", className)} {...props} /> - ) + ); } function CommandGroup({ @@ -126,11 +123,11 @@ function CommandGroup({ data-slot="command-group" className={cn( "overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-3 **:[[cmdk-group-heading]]:py-2 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground", - className + className, )} {...props} /> - ) + ); } function CommandSeparator({ @@ -143,7 +140,7 @@ function CommandSeparator({ className={cn("my-1 h-px bg-border/50", className)} {...props} /> - ) + ); } function CommandItem({ @@ -156,14 +153,14 @@ function CommandItem({ data-slot="command-item" className={cn( "group/command-item relative flex cursor-default items-center gap-2 rounded-lg px-3 py-2 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-2xl data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground", - className + className, )} {...props} > {children} - ) + ); } function CommandShortcut({ @@ -175,11 +172,11 @@ function CommandShortcut({ data-slot="command-shortcut" className={cn( "ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground", - className + className, )} {...props} /> - ) + ); } export { @@ -192,4 +189,4 @@ export { CommandItem, CommandShortcut, CommandSeparator, -} +}; diff --git a/components/ui/context-menu.tsx b/components/ui/context-menu.tsx index ef28518..df8cafa 100644 --- a/components/ui/context-menu.tsx +++ b/components/ui/context-menu.tsx @@ -1,15 +1,15 @@ -"use client" +"use client"; -import * as React from "react" -import { ContextMenu as ContextMenuPrimitive } from "radix-ui" +import * as React from "react"; +import { ContextMenu as ContextMenuPrimitive } from "radix-ui"; -import { cn } from "@/lib/utils" -import { ChevronRightIcon, CheckIcon } from "lucide-react" +import { cn } from "@/lib/utils"; +import { ChevronRightIcon, CheckIcon } from "lucide-react"; function ContextMenu({ ...props }: React.ComponentProps) { - return + return ; } function ContextMenuTrigger({ @@ -22,7 +22,7 @@ function ContextMenuTrigger({ className={cn("select-none", className)} {...props} /> - ) + ); } function ContextMenuGroup({ @@ -30,7 +30,7 @@ function ContextMenuGroup({ }: React.ComponentProps) { return ( - ) + ); } function ContextMenuPortal({ @@ -38,13 +38,13 @@ function ContextMenuPortal({ }: React.ComponentProps) { return ( - ) + ); } function ContextMenuSub({ ...props }: React.ComponentProps) { - return + return ; } function ContextMenuRadioGroup({ @@ -55,24 +55,27 @@ function ContextMenuRadioGroup({ data-slot="context-menu-radio-group" {...props} /> - ) + ); } function ContextMenuContent({ className, ...props }: React.ComponentProps & { - side?: "top" | "right" | "bottom" | "left" + side?: "top" | "right" | "bottom" | "left"; }) { return ( - ) + ); } function ContextMenuItem({ @@ -81,8 +84,8 @@ function ContextMenuItem({ variant = "default", ...props }: React.ComponentProps & { - inset?: boolean - variant?: "default" | "destructive" + inset?: boolean; + variant?: "default" | "destructive"; }) { return ( - ) + ); } function ContextMenuSubTrigger({ @@ -104,7 +107,7 @@ function ContextMenuSubTrigger({ children, ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { return ( {children} - ) + ); } function ContextMenuSubContent({ @@ -129,10 +132,13 @@ function ContextMenuSubContent({ return ( - ) + ); } function ContextMenuCheckboxItem({ @@ -142,7 +148,7 @@ function ContextMenuCheckboxItem({ inset, ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { return ( - + {children} - ) + ); } function ContextMenuRadioItem({ @@ -172,7 +177,7 @@ function ContextMenuRadioItem({ inset, ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { return ( - + {children} - ) + ); } function ContextMenuLabel({ @@ -200,7 +204,7 @@ function ContextMenuLabel({ inset, ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { return ( - ) + ); } function ContextMenuSeparator({ @@ -225,7 +229,7 @@ function ContextMenuSeparator({ className={cn("-mx-1 my-1 h-px bg-border/50", className)} {...props} /> - ) + ); } function ContextMenuShortcut({ @@ -237,11 +241,11 @@ function ContextMenuShortcut({ data-slot="context-menu-shortcut" className={cn( "ml-auto text-xs tracking-widest text-muted-foreground group-focus/context-menu-item:text-accent-foreground", - className + className, )} {...props} /> - ) + ); } export { @@ -260,4 +264,4 @@ export { ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuRadioGroup, -} +}; diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx index 7c17b89..5bbf68e 100644 --- a/components/ui/dialog.tsx +++ b/components/ui/dialog.tsx @@ -1,34 +1,34 @@ -"use client" +"use client"; -import * as React from "react" -import { Dialog as DialogPrimitive } from "radix-ui" +import * as React from "react"; +import { Dialog as DialogPrimitive } from "radix-ui"; -import { cn } from "@/lib/utils" -import { Button } from "@/components/ui/button" -import { XIcon } from "lucide-react" +import { cn } from "@/lib/utils"; +import { Button } from "@/components/ui/button"; +import { XIcon } from "lucide-react"; function Dialog({ ...props }: React.ComponentProps) { - return + return ; } function DialogTrigger({ ...props }: React.ComponentProps) { - return + return ; } function DialogPortal({ ...props }: React.ComponentProps) { - return + return ; } function DialogClose({ ...props }: React.ComponentProps) { - return + return ; } function DialogOverlay({ @@ -40,11 +40,11 @@ function DialogOverlay({ data-slot="dialog-overlay" className={cn( "fixed inset-0 isolate z-50 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", - className + className, )} {...props} /> - ) + ); } function DialogContent({ @@ -53,7 +53,7 @@ function DialogContent({ showCloseButton = true, ...props }: React.ComponentProps & { - showCloseButton?: boolean + showCloseButton?: boolean; }) { return ( @@ -62,7 +62,7 @@ function DialogContent({ data-slot="dialog-content" className={cn( "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-4xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/5 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", - className + className, )} {...props} > @@ -74,15 +74,14 @@ function DialogContent({ className="absolute top-4 right-4" size="icon-sm" > - + Close )} - ) + ); } function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { @@ -92,7 +91,7 @@ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { className={cn("flex flex-col gap-2", className)} {...props} /> - ) + ); } function DialogFooter({ @@ -101,14 +100,14 @@ function DialogFooter({ children, ...props }: React.ComponentProps<"div"> & { - showCloseButton?: boolean + showCloseButton?: boolean; }) { return (
@@ -119,7 +118,7 @@ function DialogFooter({ )}
- ) + ); } function DialogTitle({ @@ -129,13 +128,10 @@ function DialogTitle({ return ( - ) + ); } function DialogDescription({ @@ -147,11 +143,11 @@ function DialogDescription({ data-slot="dialog-description" className={cn( "text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", - className + className, )} {...props} /> - ) + ); } export { @@ -165,4 +161,4 @@ export { DialogPortal, DialogTitle, DialogTrigger, -} +}; diff --git a/components/ui/direction.tsx b/components/ui/direction.tsx index 22e1657..ed312b3 100644 --- a/components/ui/direction.tsx +++ b/components/ui/direction.tsx @@ -1,22 +1,22 @@ -"use client" +"use client"; -import * as React from "react" -import { Direction } from "radix-ui" +import * as React from "react"; +import { Direction } from "radix-ui"; function DirectionProvider({ dir, direction, children, }: React.ComponentProps & { - direction?: React.ComponentProps["dir"] + direction?: React.ComponentProps["dir"]; }) { return ( {children} - ) + ); } -const useDirection = Direction.useDirection +const useDirection = Direction.useDirection; -export { DirectionProvider, useDirection } +export { DirectionProvider, useDirection }; diff --git a/components/ui/drawer.tsx b/components/ui/drawer.tsx index ea5b6d3..ede913e 100644 --- a/components/ui/drawer.tsx +++ b/components/ui/drawer.tsx @@ -1,32 +1,32 @@ -"use client" +"use client"; -import * as React from "react" -import { Drawer as DrawerPrimitive } from "vaul" +import * as React from "react"; +import { Drawer as DrawerPrimitive } from "vaul"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Drawer({ ...props }: React.ComponentProps) { - return + return ; } function DrawerTrigger({ ...props }: React.ComponentProps) { - return + return ; } function DrawerPortal({ ...props }: React.ComponentProps) { - return + return ; } function DrawerClose({ ...props }: React.ComponentProps) { - return + return ; } function DrawerOverlay({ @@ -38,11 +38,11 @@ function DrawerOverlay({ data-slot="drawer-overlay" className={cn( "fixed inset-0 z-50 bg-black/80 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", - className + className, )} {...props} /> - ) + ); } function DrawerContent({ @@ -57,7 +57,7 @@ function DrawerContent({ data-slot="drawer-content" className={cn( "group/drawer-content fixed z-50 flex h-auto flex-col bg-transparent p-4 text-sm text-popover-foreground before:absolute before:inset-2 before:-z-10 before:rounded-4xl before:border before:border-border before:bg-popover data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=left]:sm:max-w-sm data-[vaul-drawer-direction=right]:sm:max-w-sm", - className + className, )} {...props} > @@ -65,7 +65,7 @@ function DrawerContent({ {children} - ) + ); } function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) { @@ -74,11 +74,11 @@ function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) { data-slot="drawer-header" className={cn( "flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-left", - className + className, )} {...props} /> - ) + ); } function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) { @@ -88,7 +88,7 @@ function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) { className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} /> - ) + ); } function DrawerTitle({ @@ -98,13 +98,10 @@ function DrawerTitle({ return ( - ) + ); } function DrawerDescription({ @@ -117,7 +114,7 @@ function DrawerDescription({ className={cn("text-sm text-muted-foreground", className)} {...props} /> - ) + ); } export { @@ -131,4 +128,4 @@ export { DrawerFooter, DrawerTitle, DrawerDescription, -} +}; diff --git a/components/ui/dropdown-menu.tsx b/components/ui/dropdown-menu.tsx index 172cc15..8027fc2 100644 --- a/components/ui/dropdown-menu.tsx +++ b/components/ui/dropdown-menu.tsx @@ -1,15 +1,15 @@ -"use client" +"use client"; -import * as React from "react" -import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui" +import * as React from "react"; +import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"; -import { cn } from "@/lib/utils" -import { CheckIcon, ChevronRightIcon } from "lucide-react" +import { cn } from "@/lib/utils"; +import { CheckIcon, ChevronRightIcon } from "lucide-react"; function DropdownMenu({ ...props }: React.ComponentProps) { - return + return ; } function DropdownMenuPortal({ @@ -17,7 +17,7 @@ function DropdownMenuPortal({ }: React.ComponentProps) { return ( - ) + ); } function DropdownMenuTrigger({ @@ -28,7 +28,7 @@ function DropdownMenuTrigger({ data-slot="dropdown-menu-trigger" {...props} /> - ) + ); } function DropdownMenuContent({ @@ -43,11 +43,14 @@ function DropdownMenuContent({ data-slot="dropdown-menu-content" sideOffset={sideOffset} align={align} - className={cn("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-48 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-2xl ring-1 ring-foreground/5 duration-100 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 data-[state=closed]:overflow-hidden dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )} + className={cn( + "z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-48 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-2xl ring-1 ring-foreground/5 duration-100 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 data-[state=closed]:overflow-hidden dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", + className, + )} {...props} /> - ) + ); } function DropdownMenuGroup({ @@ -55,7 +58,7 @@ function DropdownMenuGroup({ }: React.ComponentProps) { return ( - ) + ); } function DropdownMenuItem({ @@ -64,8 +67,8 @@ function DropdownMenuItem({ variant = "default", ...props }: React.ComponentProps & { - inset?: boolean - variant?: "default" | "destructive" + inset?: boolean; + variant?: "default" | "destructive"; }) { return ( - ) + ); } function DropdownMenuCheckboxItem({ @@ -88,7 +91,7 @@ function DropdownMenuCheckboxItem({ inset, ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { return ( - + {children} - ) + ); } function DropdownMenuRadioGroup({ @@ -123,7 +125,7 @@ function DropdownMenuRadioGroup({ data-slot="dropdown-menu-radio-group" {...props} /> - ) + ); } function DropdownMenuRadioItem({ @@ -132,7 +134,7 @@ function DropdownMenuRadioItem({ inset, ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { return ( @@ -149,13 +151,12 @@ function DropdownMenuRadioItem({ data-slot="dropdown-menu-radio-item-indicator" > - + {children} - ) + ); } function DropdownMenuLabel({ @@ -163,7 +164,7 @@ function DropdownMenuLabel({ inset, ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { return ( - ) + ); } function DropdownMenuSeparator({ @@ -188,7 +189,7 @@ function DropdownMenuSeparator({ className={cn("-mx-1 my-1 h-px bg-border/50", className)} {...props} /> - ) + ); } function DropdownMenuShortcut({ @@ -200,17 +201,17 @@ function DropdownMenuShortcut({ data-slot="dropdown-menu-shortcut" className={cn( "ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground", - className + className, )} {...props} /> - ) + ); } function DropdownMenuSub({ ...props }: React.ComponentProps) { - return + return ; } function DropdownMenuSubTrigger({ @@ -219,7 +220,7 @@ function DropdownMenuSubTrigger({ children, ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean; }) { return ( {children} - ) + ); } function DropdownMenuSubContent({ @@ -244,10 +245,13 @@ function DropdownMenuSubContent({ return ( - ) + ); } export { @@ -266,4 +270,4 @@ export { DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, -} +}; diff --git a/components/ui/empty.tsx b/components/ui/empty.tsx index f96c914..ee9b00d 100644 --- a/components/ui/empty.tsx +++ b/components/ui/empty.tsx @@ -1,6 +1,6 @@ -import { cva, type VariantProps } from "class-variance-authority" +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Empty({ className, ...props }: React.ComponentProps<"div">) { return ( @@ -8,11 +8,11 @@ function Empty({ className, ...props }: React.ComponentProps<"div">) { data-slot="empty" className={cn( "flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-lg border-dashed p-12 text-center text-balance", - className + className, )} {...props} /> - ) + ); } function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) { @@ -22,7 +22,7 @@ function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) { className={cn("flex max-w-sm flex-col items-center gap-2", className)} {...props} /> - ) + ); } const emptyMediaVariants = cva( @@ -37,8 +37,8 @@ const emptyMediaVariants = cva( defaultVariants: { variant: "default", }, - } -) + }, +); function EmptyMedia({ className, @@ -52,20 +52,17 @@ function EmptyMedia({ className={cn(emptyMediaVariants({ variant, className }))} {...props} /> - ) + ); } function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) { return (
- ) + ); } function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) { @@ -74,11 +71,11 @@ function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) { data-slot="empty-description" className={cn( "text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", - className + className, )} {...props} /> - ) + ); } function EmptyContent({ className, ...props }: React.ComponentProps<"div">) { @@ -87,11 +84,11 @@ function EmptyContent({ className, ...props }: React.ComponentProps<"div">) { data-slot="empty-content" className={cn( "flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance", - className + className, )} {...props} /> - ) + ); } export { @@ -101,4 +98,4 @@ export { EmptyDescription, EmptyContent, EmptyMedia, -} +}; diff --git a/components/ui/field.tsx b/components/ui/field.tsx index 0c3dde6..ec2409a 100644 --- a/components/ui/field.tsx +++ b/components/ui/field.tsx @@ -1,11 +1,11 @@ -"use client" +"use client"; -import { useMemo } from "react" -import { cva, type VariantProps } from "class-variance-authority" +import { useMemo } from "react"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" -import { Label } from "@/components/ui/label" -import { Separator } from "@/components/ui/separator" +import { cn } from "@/lib/utils"; +import { Label } from "@/components/ui/label"; +import { Separator } from "@/components/ui/separator"; function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) { return ( @@ -13,11 +13,11 @@ function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) { data-slot="field-set" className={cn( "flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", - className + className, )} {...props} /> - ) + ); } function FieldLegend({ @@ -31,11 +31,11 @@ function FieldLegend({ data-variant={variant} className={cn( "mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base", - className + className, )} {...props} /> - ) + ); } function FieldGroup({ className, ...props }: React.ComponentProps<"div">) { @@ -44,11 +44,11 @@ function FieldGroup({ className, ...props }: React.ComponentProps<"div">) { data-slot="field-group" className={cn( "group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4", - className + className, )} {...props} /> - ) + ); } const fieldVariants = cva( @@ -66,8 +66,8 @@ const fieldVariants = cva( defaultVariants: { orientation: "vertical", }, - } -) + }, +); function Field({ className, @@ -82,7 +82,7 @@ function Field({ className={cn(fieldVariants({ orientation }), className)} {...props} /> - ) + ); } function FieldContent({ className, ...props }: React.ComponentProps<"div">) { @@ -91,11 +91,11 @@ function FieldContent({ className, ...props }: React.ComponentProps<"div">) { data-slot="field-content" className={cn( "group/field-content flex flex-1 flex-col gap-1 leading-snug", - className + className, )} {...props} /> - ) + ); } function FieldLabel({ @@ -108,11 +108,11 @@ function FieldLabel({ className={cn( "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-xl has-[>[data-slot=field]]:border *:data-[slot=field]:p-4 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col", - className + className, )} {...props} /> - ) + ); } function FieldTitle({ className, ...props }: React.ComponentProps<"div">) { @@ -121,11 +121,11 @@ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) { data-slot="field-label" className={cn( "flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50", - className + className, )} {...props} /> - ) + ); } function FieldDescription({ className, ...props }: React.ComponentProps<"p">) { @@ -136,11 +136,11 @@ function FieldDescription({ className, ...props }: React.ComponentProps<"p">) { "text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5", "last:mt-0 nth-last-2:-mt-1", "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", - className + className, )} {...props} /> - ) + ); } function FieldSeparator({ @@ -148,7 +148,7 @@ function FieldSeparator({ className, ...props }: React.ComponentProps<"div"> & { - children?: React.ReactNode + children?: React.ReactNode; }) { return (
@@ -170,7 +170,7 @@ function FieldSeparator({ )}
- ) + ); } function FieldError({ @@ -179,37 +179,37 @@ function FieldError({ errors, ...props }: React.ComponentProps<"div"> & { - errors?: Array<{ message?: string } | undefined> + errors?: Array<{ message?: string } | undefined>; }) { const content = useMemo(() => { if (children) { - return children + return children; } if (!errors?.length) { - return null + return null; } const uniqueErrors = [ ...new Map(errors.map((error) => [error?.message, error])).values(), - ] + ]; if (uniqueErrors?.length == 1) { - return uniqueErrors[0]?.message + return uniqueErrors[0]?.message; } return (
    {uniqueErrors.map( (error, index) => - error?.message &&
  • {error.message}
  • + error?.message &&
  • {error.message}
  • , )}
- ) - }, [children, errors]) + ); + }, [children, errors]); if (!content) { - return null + return null; } return ( @@ -221,7 +221,7 @@ function FieldError({ > {content}
- ) + ); } export { @@ -235,4 +235,4 @@ export { FieldSet, FieldContent, FieldTitle, -} +}; diff --git a/components/ui/form.tsx b/components/ui/form.tsx index 524b986..bf4214d 100644 --- a/components/ui/form.tsx +++ b/components/ui/form.tsx @@ -1,8 +1,8 @@ -"use client" +"use client"; -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" -import { Slot } from "@radix-ui/react-slot" +import * as React from "react"; +import * as LabelPrimitive from "@radix-ui/react-label"; +import { Slot } from "@radix-ui/react-slot"; import { Controller, FormProvider, @@ -11,23 +11,23 @@ import { type ControllerProps, type FieldPath, type FieldValues, -} from "react-hook-form" +} from "react-hook-form"; -import { cn } from "@/lib/utils" -import { Label } from "@/components/ui/label" +import { cn } from "@/lib/utils"; +import { Label } from "@/components/ui/label"; -const Form = FormProvider +const Form = FormProvider; type FormFieldContextValue< TFieldValues extends FieldValues = FieldValues, TName extends FieldPath = FieldPath, > = { - name: TName -} + name: TName; +}; const FormFieldContext = React.createContext( - {} as FormFieldContextValue -) + {} as FormFieldContextValue, +); const FormField = < TFieldValues extends FieldValues = FieldValues, @@ -39,21 +39,21 @@ const FormField = < - ) -} + ); +}; const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext) - const itemContext = React.useContext(FormItemContext) - const { getFieldState } = useFormContext() - const formState = useFormState({ name: fieldContext.name }) - const fieldState = getFieldState(fieldContext.name, formState) + const fieldContext = React.useContext(FormFieldContext); + const itemContext = React.useContext(FormItemContext); + const { getFieldState } = useFormContext(); + const formState = useFormState({ name: fieldContext.name }); + const fieldState = getFieldState(fieldContext.name, formState); if (!fieldContext) { - throw new Error("useFormField should be used within ") + throw new Error("useFormField should be used within "); } - const { id } = itemContext + const { id } = itemContext; return { id, @@ -62,19 +62,19 @@ const useFormField = () => { formDescriptionId: `${id}-form-item-description`, formMessageId: `${id}-form-item-message`, ...fieldState, - } -} + }; +}; type FormItemContextValue = { - id: string -} + id: string; +}; const FormItemContext = React.createContext( - {} as FormItemContextValue -) + {} as FormItemContextValue, +); function FormItem({ className, ...props }: React.ComponentProps<"div">) { - const id = React.useId() + const id = React.useId(); return ( @@ -84,14 +84,14 @@ function FormItem({ className, ...props }: React.ComponentProps<"div">) { {...props} /> - ) + ); } function FormLabel({ className, ...props }: React.ComponentProps) { - const { error, formItemId } = useFormField() + const { error, formItemId } = useFormField(); return (