Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fixed admin `<Select>` positioning + standarize Biome config across packages

Damian Legawiec2edcb0c71dd2
diff --git a/.zed/settings.json b/.zed/settings.json
new file mode 100644
index 0000000000..51dd8a0bc4
--- /dev/null
+++ b/.zed/settings.json
@@ -0,0 +1,21 @@
+{
+ "formatter": {
+ "language_server": { "name": "biome" }
+ },
+ "format_on_save": "on",
+ "code_actions_on_format": {
+ "source.fixAll.biome": true,
+ "source.organizeImports.biome": true
+ },
+ "languages": {
+ "TypeScript": {
+ "language_servers": ["biome", "vtsls", "!typescript-language-server", "!eslint"]
+ },
+ "TSX": {
+ "language_servers": ["biome", "vtsls", "!typescript-language-server", "!eslint"]
+ },
+ "JavaScript": {
+ "language_servers": ["biome", "vtsls", "!typescript-language-server", "!eslint"]
+ }
+ }
+}
diff --git a/biome.json b/biome.json
new file mode 100644
index 0000000000..ce9b2b4ca3
--- /dev/null
+++ b/biome.json
@@ -0,0 +1,62 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
+ "vcs": {
+ "enabled": true,
+ "clientKind": "git",
+ "useIgnoreFile": true
+ },
+ "linter": {
+ "enabled": true,
+ "rules": {
+ "recommended": true,
+ "correctness": {
+ "noUnusedImports": "warn",
+ "noUnusedVariables": "warn"
+ },
+ "suspicious": {
+ "noExplicitAny": "off"
+ },
+ "style": {
+ "noNonNullAssertion": "off"
+ }
+ }
+ },
+ "formatter": {
+ "enabled": true,
+ "indentStyle": "space",
+ "indentWidth": 2,
+ "lineWidth": 100
+ },
+ "javascript": {
+ "formatter": {
+ "quoteStyle": "single",
+ "semicolons": "asNeeded"
+ }
+ },
+ "css": {
+ "linter": { "enabled": false },
+ "formatter": { "enabled": false }
+ },
+ "assist": {
+ "actions": {
+ "source": {
+ "organizeImports": "on"
+ }
+ }
+ },
+ "files": {
+ "includes": [
+ "**",
+ "!**/node_modules",
+ "!**/dist",
+ "!**/build",
+ "!**/.turbo",
+ "!**/coverage",
+ "!**/*.min.js",
+ "!**/*.d.ts",
+ "!server/**",
+ "!spree/**",
+ "!docs/**"
+ ]
+ }
+}
diff --git a/packages/admin-sdk/biome.json b/packages/admin-sdk/biome.json
new file mode 100644
index 0000000000..cbf6832d91
--- /dev/null
+++ b/packages/admin-sdk/biome.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
+ "extends": ["//"],
+ "files": {
+ "includes": ["src/**", "tests/**", "!src/types/generated/**", "!src/zod/generated/**"]
+ }
+}
diff --git a/packages/admin/biome.json b/packages/admin/biome.json
index 146e47d151..a6826114b0 100644
--- a/packages/admin/biome.json
+++ b/packages/admin/biome.json
@@ -1,57 +1,13 @@
{
- "$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
- "linter": {
- "enabled": true,
- "rules": {
- "recommended": true,
- "correctness": {
- "noUnusedImports": "warn",
- "noUnusedVariables": "warn"
- },
- "suspicious": {
- "noExplicitAny": "off"
- },
- "style": {
- "noNonNullAssertion": "off"
- }
- }
- },
- "formatter": {
- "enabled": true,
- "indentStyle": "space",
- "indentWidth": 2,
- "lineWidth": 100
- },
- "javascript": {
- "formatter": {
- "quoteStyle": "single",
- "semicolons": "asNeeded"
- }
- },
- "css": {
- "linter": {
- "enabled": false
- },
- "formatter": {
- "enabled": false
- }
- },
- "assist": {
- "actions": {
- "source": {
- "organizeImports": "on"
- }
- }
- },
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
+ "extends": ["//"],
"files": {
"includes": ["src/**", "!src/routeTree.gen.ts", "!src/**/*.css"]
},
"overrides": [
{
"includes": ["src/components/ui/**"],
- "linter": {
- "enabled": false
- }
+ "linter": { "enabled": false }
}
]
}
diff --git a/packages/admin/src/components/address-form-dialog.tsx b/packages/admin/src/components/address-form-dialog.tsx
index 359443b411..1bd2194be8 100644
--- a/packages/admin/src/components/address-form-dialog.tsx
+++ b/packages/admin/src/components/address-form-dialog.tsx
@@ -9,6 +9,8 @@ import {
ComboboxItem,
ComboboxList,
} from '@/components/ui/combobox'
+import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
+import { Input } from '@/components/ui/input'
import {
Sheet,
SheetContent,
@@ -17,13 +19,13 @@ import {
SheetHeader,
SheetTitle,
} from '@/components/ui/sheet'
-import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
-import { Input } from '@/components/ui/input'
import { useCountries } from '@/hooks/use-countries'
/** Convert 2-letter ISO code to flag emoji (e.g. "US" → "🇺🇸") */
function countryFlag(iso: string): string {
- return [...iso.toUpperCase()].map((c) => String.fromCodePoint(0x1f1e6 + c.charCodeAt(0) - 65)).join('')
+ return [...iso.toUpperCase()]
+ .map((c) => String.fromCodePoint(0x1f1e6 + c.charCodeAt(0) - 65))
+ .join('')
}
export interface AddressParams {
@@ -132,13 +134,22 @@ export function AddressFormDialog({
<SheetTitle>{title}</SheetTitle>
<SheetDescription>Update the address details.</SheetDescription>
</SheetHeader>
- <form onSubmit={handleSubmit} onKeyDown={handleKeyDown} className="flex flex-col flex-1 overflow-hidden">
+ <form
+ onSubmit={handleSubmit}
+ onKeyDown={handleKeyDown}
+ className="flex flex-col flex-1 overflow-hidden"
+ >
<div className="flex-1 overflow-y-auto p-4">
<FieldGroup>
{showLabel && (
<Field>
<FieldLabel htmlFor="addr-label">Label</FieldLabel>
- <Input id="addr-label" name="label" placeholder="e.g. Home, Office" defaultValue={address?.label ?? ''} />
+ <Input
+ id="addr-label"
+ name="label"
+ placeholder="e.g. Home, Office"
+ defaultValue={address?.label ?? ''}
+ />
</Field>
)}
<div className="grid grid-cols-2 gap-3">
@@ -167,7 +178,7 @@ export function AddressFormDialog({
onValueChange={handleCountryChange as any}
itemToStringLabel={(c: any) => {
const co = c as CountryOption
- return co?.iso ? `${countryFlag(co.iso)} ${co.name}` : co?.name ?? ''
+ return co?.iso ? `${countryFlag(co.iso)} ${co.name}` : (co?.name ?? '')
}}
itemToStringValue={(c: any) => (c as CountryOption)?.iso ?? ''}
>
@@ -234,13 +245,21 @@ export function AddressFormDialog({
<>
<Field>
<label className="flex items-center gap-2 text-sm">
- <input type="checkbox" name="is_default_billing" defaultChecked={address?.is_default_billing} />
+ <input
+ type="checkbox"
+ name="is_default_billing"
+ defaultChecked={address?.is_default_billing}
+ />
Default billing address
</label>
</Field>
<Field>
<label className="flex items-center gap-2 text-sm">
- <input type="checkbox" name="is_default_shipping" defaultChecked={address?.is_default_shipping} />
+ <input
+ type="checkbox"
+ name="is_default_shipping"
+ defaultChecked={address?.is_default_shipping}
+ />
Default shipping address
</label>
</Field>
diff --git a/packages/admin/src/components/app-sidebar.tsx b/packages/admin/src/components/app-sidebar.tsx
index 96064a5639..536cb8f5bb 100644
--- a/packages/admin/src/components/app-sidebar.tsx
+++ b/packages/admin/src/components/app-sidebar.tsx
@@ -1,3 +1,4 @@
+import { useParams } from '@tanstack/react-router'
import {
BarChart3Icon,
HomeIcon,
@@ -9,7 +10,6 @@ import {
UsersIcon,
} from 'lucide-react'
import type { ComponentProps } from 'react'
-import { useParams } from '@tanstack/react-router'
import { NavMain } from '@/components/nav-main'
import { NavUser } from '@/components/nav-user'
import { StoreSwitcher } from '@/components/store-switcher'
@@ -64,7 +64,9 @@ function buildNavigation(storeId: string): NavItem[] {
url: `${p}/promotions`,
icon: TagIcon,
subject: Subject.Promotion,
- items: [{ title: 'Gift Cards', url: `${p}/promotions/gift-cards`, subject: Subject.Promotion }],
+ items: [
+ { title: 'Gift Cards', url: `${p}/promotions/gift-cards`, subject: Subject.Promotion },
+ ],
},
{
title: 'Reports',
diff --git a/packages/admin/src/components/back-button.tsx b/packages/admin/src/components/back-button.tsx
index bd787661f5..b5d9a8f16b 100644
--- a/packages/admin/src/components/back-button.tsx
+++ b/packages/admin/src/components/back-button.tsx
@@ -1,4 +1,4 @@
-import { useRouter, useParams } from '@tanstack/react-router'
+import { useParams, useRouter } from '@tanstack/react-router'
import { ArrowLeftIcon } from 'lucide-react'
interface BackButtonProps {
diff --git a/packages/admin/src/components/can.tsx b/packages/admin/src/components/can.tsx
index 7e0b168758..903ecfc1e8 100644
--- a/packages/admin/src/components/can.tsx
+++ b/packages/admin/src/components/can.tsx
@@ -1,6 +1,6 @@
import type { ReactNode } from 'react'
-import { usePermissions } from '@/providers/permission-provider'
import type { ActionName, SubjectName } from '@/lib/permissions'
+import { usePermissions } from '@/providers/permission-provider'
interface CanProps {
/** Action name (e.g. "update", "destroy", "manage") */
diff --git a/packages/admin/src/components/confirm-dialog.tsx b/packages/admin/src/components/confirm-dialog.tsx
index 5439d5f5c6..894a52aedd 100644
--- a/packages/admin/src/components/confirm-dialog.tsx
+++ b/packages/admin/src/components/confirm-dialog.tsx
@@ -1,4 +1,4 @@
-import { createContext, useCallback, useContext, useRef, useState, type ReactNode } from 'react'
+import { createContext, type ReactNode, useCallback, useContext, useRef, useState } from 'react'
import { Button } from '@/components/ui/button'
import {
Dialog,
@@ -53,7 +53,9 @@ export function ConfirmProvider({ children }: { children: ReactNode }) {
{children}
<Dialog
open={open}
- onOpenChange={(o) => { if (!o) handleClose(false) }}
+ onOpenChange={(o) => {
+ if (!o) handleClose(false)
+ }}
>
<DialogContent showCloseButton={false}>
<DialogHeader>
diff --git a/packages/admin/src/components/date-range-picker.tsx b/packages/admin/src/components/date-range-picker.tsx
index f2a7007f06..98b4ae661c 100644
--- a/packages/admin/src/components/date-range-picker.tsx
+++ b/packages/admin/src/components/date-range-picker.tsx
@@ -1,6 +1,6 @@
+import { format, startOfMonth, startOfYear, subDays } from 'date-fns'
import { CalendarIcon, ChevronDownIcon } from 'lucide-react'
import { useState } from 'react'
-import { format, subDays, startOfMonth, startOfYear } from 'date-fns'
import type { DateRange as DayPickerDateRange } from 'react-day-picker'
import { Button } from '@/components/ui/button'
import { Calendar } from '@/components/ui/calendar'
@@ -21,12 +21,36 @@ interface Preset {
}
const presets: Preset[] = [
- { key: '7d', label: 'Last 7 days', value: () => ({ from: subDays(new Date(), 7), to: new Date() }) },
- { key: '14d', label: 'Last 14 days', value: () => ({ from: subDays(new Date(), 14), to: new Date() }) },
- { key: '30d', label: 'Last 30 days', value: () => ({ from: subDays(new Date(), 30), to: new Date() }) },
- { key: '90d', label: 'Last 90 days', value: () => ({ from: subDays(new Date(), 90), to: new Date() }) },
- { key: 'this_month', label: 'This month', value: () => ({ from: startOfMonth(new Date()), to: new Date() }) },
- { key: 'ytd', label: 'Year to date', value: () => ({ from: startOfYear(new Date()), to: new Date() }) },
+ {
+ key: '7d',
+ label: 'Last 7 days',
+ value: () => ({ from: subDays(new Date(), 7), to: new Date() }),
+ },
+ {
+ key: '14d',
+ label: 'Last 14 days',
+ value: () => ({ from: subDays(new Date(), 14), to: new Date() }),
+ },
+ {
+ key: '30d',
+ label: 'Last 30 days',
+ value: () => ({ from: subDays(new Date(), 30), to: new Date() }),
+ },
+ {
+ key: '90d',
+ label: 'Last 90 days',
+ value: () => ({ from: subDays(new Date(), 90), to: new Date() }),
+ },
+ {
+ key: 'this_month',
+ label: 'This month',
+ value: () => ({ from: startOfMonth(new Date()), to: new Date() }),
+ },
+ {
+ key: 'ytd',
+ label: 'Year to date',
+ value: () => ({ from: startOfYear(new Date()), to: new Date() }),
+ },
]
interface DateRangePickerProps {
@@ -39,9 +63,10 @@ export function DateRangePicker({ value, onChange }: DateRangePickerProps) {
const [activePreset, setActivePreset] = useState<PresetKey>('30d')
const [calendarRange, setCalendarRange] = useState<DayPickerDateRange | undefined>()
- const triggerLabel = activePreset === 'custom'
- ? `${format(value.from, 'MMM d')} – ${format(value.to, 'MMM d')}`
- : presets.find((p) => p.key === activePreset)?.label ?? 'Last 30 days'
+ const triggerLabel =
+ activePreset === 'custom'
+ ? `${format(value.from, 'MMM d')} – ${format(value.to, 'MMM d')}`
+ : (presets.find((p) => p.key === activePreset)?.label ?? 'Last 30 days')
function selectPreset(preset: Preset) {
const range = preset.value()
@@ -105,11 +130,7 @@ export function DateRangePicker({ value, onChange }: DateRangePickerProps) {
numberOfMonths={2}
/>
<div className="flex justify-end border-t pt-3">
- <Button
- size="sm"
- disabled={!canApply}
- onClick={applyCustomRange}
- >
+ <Button size="sm" disabled={!canApply} onClick={applyCustomRange}>
Apply
</Button>
</div>
diff --git a/packages/admin/src/components/nav-main.tsx b/packages/admin/src/components/nav-main.tsx
index a9355d7e7b..7ea01bed14 100644
--- a/packages/admin/src/components/nav-main.tsx
+++ b/packages/admin/src/components/nav-main.tsx
@@ -1,12 +1,12 @@
-import { Link, useRouterState } from "@tanstack/react-router";
-import { useState } from "react";
-import type { NavItem } from "@/components/app-sidebar";
+import { Link, useRouterState } from '@tanstack/react-router'
+import { useState } from 'react'
+import type { NavItem } from '@/components/app-sidebar'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
+} from '@/components/ui/dropdown-menu'
import {
SidebarGroup,
SidebarMenu,
@@ -16,37 +16,23 @@ import {
SidebarMenuSubButton,
SidebarMenuSubItem,
useSidebar,
-} from "@/components/ui/sidebar";
+} from '@/components/ui/sidebar'
-function NavIcon({
- icon: Icon,
- isActive,
-}: {
- icon: NavItem["icon"];
- isActive?: boolean;
-}) {
+function NavIcon({ icon: Icon, isActive }: { icon: NavItem['icon']; isActive?: boolean }) {
return (
<span
className={
- "inline-flex shrink-0 items-center justify-center rounded-lg p-[0.2rem] transition-colors duration-100 " +
- (isActive
- ? "bg-zinc-950 text-white"
- : "group-hover/menu-button:text-zinc-950")
+ 'inline-flex shrink-0 items-center justify-center rounded-lg p-[0.2rem] transition-colors duration-100 ' +
+ (isActive ? 'bg-zinc-950 text-white' : 'group-hover/menu-button:text-zinc-950')
}
>
<Icon size={16} strokeWidth={2} />
</span>
- );
+ )
}
-function CollapsedDropdown({
- item,
- children,
-}: {
- item: NavItem;
- children: React.ReactNode;
-}) {
- const [open, setOpen] = useState(false);
+function CollapsedDropdown({ item, children }: { item: NavItem; children: React.ReactNode }) {
+ const [open, setOpen] = useState(false)
return (
<DropdownMenu open={open} onOpenChange={setOpen}>
@@ -70,7 +56,7 @@ function CollapsedDropdown({
))}
</DropdownMenuContent>
</DropdownMenu>
- );
+ )
}
function NavItemContent({
@@ -78,20 +64,19 @@ function NavItemContent({
currentPath,
isCollapsed,
}: {
- item: NavItem;
- currentPath: string;
- isCollapsed: boolean;
+ item: NavItem
+ currentPath: string
+ isCollapsed: boolean
}) {
- const isExactActive = currentPath === item.url || currentPath === item.url + '/';
+ const isExactActive = currentPath === item.url || currentPath === `${item.url}/`
// Only prefix-match for items with a sub-path after the storeId segment (e.g. /store_abc/orders)
- const hasSubPath = item.url.split('/').filter(Boolean).length > 1;
- const isActive =
- isExactActive || (hasSubPath && currentPath.startsWith(item.url));
+ const hasSubPath = item.url.split('/').filter(Boolean).length > 1
+ const isActive = isExactActive || (hasSubPath && currentPath.startsWith(item.url))
const hasActiveChild = item.items?.some(
(sub) => currentPath === sub.url || currentPath.startsWith(sub.url),
- );
- const showSubmenu = isActive || hasActiveChild;
- const itemIsActive = isActive || !!hasActiveChild;
+ )
+ const showSubmenu = isActive || hasActiveChild
+ const itemIsActive = isActive || !!hasActiveChild
const button = (
<SidebarMenuButton
@@ -104,7 +89,7 @@ function NavItemContent({
<span>{item.title}</span>
</Link>
</SidebarMenuButton>
- );
+ )
return (
<SidebarMenuItem>
@@ -116,9 +101,7 @@ function NavItemContent({
{item.items && showSubmenu && (
<SidebarMenuSub>
{item.items.map((subItem) => {
- const subActive =
- currentPath === subItem.url ||
- currentPath.startsWith(subItem.url);
+ const subActive = currentPath === subItem.url || currentPath.startsWith(subItem.url)
return (
<SidebarMenuSubItem key={subItem.title}>
<SidebarMenuSubButton asChild isActive={subActive}>
@@ -127,25 +110,19 @@ function NavItemContent({
</Link>
</SidebarMenuSubButton>
</SidebarMenuSubItem>
- );
+ )
})}
</SidebarMenuSub>
)}
</SidebarMenuItem>
- );
+ )
}
-export function NavMain({
- items,
- bottomItems,
-}: {
- items: NavItem[];
- bottomItems?: NavItem[];
-}) {
- const routerState = useRouterState();
- const currentPath = routerState.location.pathname;
- const { state } = useSidebar();
- const isCollapsed = state === "collapsed";
+export function NavMain({ items, bottomItems }: { items: NavItem[]; bottomItems?: NavItem[] }) {
+ const routerState = useRouterState()
+ const currentPath = routerState.location.pathname
+ const { state } = useSidebar()
+ const isCollapsed = state === 'collapsed'
return (
<>
@@ -167,27 +144,22 @@ export function NavMain({
<SidebarMenu>
{bottomItems.map((item) => {
const isActive =
- currentPath === item.url ||
- (item.url !== "/" && currentPath.startsWith(item.url));
+ currentPath === item.url || (item.url !== '/' && currentPath.startsWith(item.url))
return (
<SidebarMenuItem key={item.title}>
- <SidebarMenuButton
- tooltip={item.title}
- asChild
- isActive={isActive}
- >
+ <SidebarMenuButton tooltip={item.title} asChild isActive={isActive}>
<Link to={item.url}>
<NavIcon icon={item.icon} isActive={isActive} />
<span>{item.title}</span>
</Link>
</SidebarMenuButton>
</SidebarMenuItem>
- );
+ )
})}
</SidebarMenu>
</SidebarGroup>
)}
</>
- );
+ )
}
diff --git a/packages/admin/src/components/store-switcher.tsx b/packages/admin/src/components/store-switcher.tsx
index eba7f2a844..470d9b2d42 100644
--- a/packages/admin/src/components/store-switcher.tsx
+++ b/packages/admin/src/components/store-switcher.tsx
@@ -1,5 +1,5 @@
import { ChevronsUpDownIcon, ExternalLinkIcon } from 'lucide-react'
-import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'
+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import {
DropdownMenu,
DropdownMenuContent,
@@ -18,7 +18,10 @@ export function StoreSwitcher() {
if (isLoading) return <Skeleton className="h-header-height w-full rounded-xl" />
- const storeInitials = store?.name.split(' ').map(name => name[0]).join('')
+ const storeInitials = store?.name
+ .split(' ')
+ .map((name) => name[0])
+ .join('')
return (
<SidebarMenu>
diff --git a/packages/admin/src/components/table-toolbar.tsx b/packages/admin/src/components/table-toolbar.tsx
index 612330de1c..a01ed6ce9b 100644
--- a/packages/admin/src/components/table-toolbar.tsx
+++ b/packages/admin/src/components/table-toolbar.tsx
@@ -6,11 +6,11 @@ import {
SearchIcon,
Trash2Icon,
XIcon,
-} from "lucide-react";
-import { useCallback, useRef, useState } from "react";
-import { Badge } from "@/components/ui/badge";
-import { Button } from "@/components/ui/button";
-import { CardTitle } from "@/components/ui/card";
+} from 'lucide-react'
+import { useCallback, useRef, useState } from 'react'
+import { Badge } from '@/components/ui/badge'
+import { Button } from '@/components/ui/button'
+import { CardTitle } from '@/components/ui/card'
import {
DropdownMenu,
DropdownMenuCheckboxItem,
@@ -20,40 +20,36 @@ import {
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
-import { Input } from "@/components/ui/input";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@/components/ui/popover";
+} from '@/components/ui/dropdown-menu'
+import { Input } from '@/components/ui/input'
+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
-} from "@/components/ui/select";
-import { Tooltip, TooltipTrigger, TooltipContent } from "./ui/tooltip";
-import type { ColumnDef, FilterRule, SortOption } from "@/lib/table-registry";
+} from '@/components/ui/select'
+import type { ColumnDef, FilterRule, SortOption } from '@/lib/table-registry'
+import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'
interface TableToolbarProps {
/** Displayable columns (for column selector and table headers) */
- columns: ColumnDef[];
- visibleColumns: string[];
- onVisibleColumnsChange: (columns: string[]) => void;
- search: string;
- onSearchChange: (value: string) => void;
- searchPlaceholder?: string;
- sort: SortOption;
- onSortChange: (sort: SortOption) => void;
- filters: FilterRule[];
- onFiltersChange: (filters: FilterRule[]) => void;
+ columns: ColumnDef[]
+ visibleColumns: string[]
+ onVisibleColumnsChange: (columns: string[]) => void
+ search: string
+ onSearchChange: (value: string) => void
+ searchPlaceholder?: string
+ sort: SortOption
+ onSortChange: (sort: SortOption) => void
+ filters: FilterRule[]
+ onFiltersChange: (filters: FilterRule[]) => void
/** All columns including filter-only ones (for the filter drawer). Falls back to `columns` if not provided. */
- allColumns?: ColumnDef[];
+ allColumns?: ColumnDef[]
/** Title displayed in the toolbar header */
- title?: string;
- actions?: React.ReactNode;
+ title?: string
+ actions?: React.ReactNode
}
// ============================================================================
@@ -62,42 +58,42 @@ interface TableToolbarProps {
const operatorsByType: Record<string, { value: string; label: string }[]> = {
string: [
- { value: "cont", label: "contains" },
- { value: "eq", label: "equals" },
- { value: "not_eq", label: "does not equal" },
- { value: "start", label: "starts with" },
- { value: "end", label: "ends with" },
- { value: "present", label: "is set" },
- { value: "blank", label: "is not set" },
+ { value: 'cont', label: 'contains' },
+ { value: 'eq', label: 'equals' },
+ { value: 'not_eq', label: 'does not equal' },
+ { value: 'start', label: 'starts with' },
+ { value: 'end', label: 'ends with' },
+ { value: 'present', label: 'is set' },
+ { value: 'blank', label: 'is not set' },
],
status: [
- { value: "eq", label: "is" },
- { value: "not_eq", label: "is not" },
- { value: "in", label: "is any of" },
- { value: "not_in", label: "is none of" },
+ { value: 'eq', label: 'is' },
+ { value: 'not_eq', label: 'is not' },
+ { value: 'in', label: 'is any of' },
+ { value: 'not_in', label: 'is none of' },
],
- boolean: [{ value: "eq", label: "is" }],
+ boolean: [{ value: 'eq', label: 'is' }],
number: [
- { value: "eq", label: "equals" },
- { value: "gt", label: "greater than" },
- { value: "gteq", label: "greater than or equal" },
- { value: "lt", label: "less than" },
- { value: "lteq", label: "less than or equal" },
+ { value: 'eq', label: 'equals' },
+ { value: 'gt', label: 'greater than' },
+ { value: 'gteq', label: 'greater than or equal' },
+ { value: 'lt', label: 'less than' },
+ { value: 'lteq', label: 'less than or equal' },
],
date: [
- { value: "eq", label: "is" },
- { value: "gt", label: "after" },
- { value: "lt", label: "before" },
- { value: "gteq", label: "on or after" },
- { value: "lteq", label: "on or before" },
+ { value: 'eq', label: 'is' },
+ { value: 'gt', label: 'after' },
+ { value: 'lt', label: 'before' },
+ { value: 'gteq', label: 'on or after' },
+ { value: 'lteq', label: 'on or before' },
],
-};
+}
function getOperators(type: string) {
- return operatorsByType[type] || operatorsByType.string;
+ return operatorsByType[type] || operatorsByType.string
}
-const noValueOperators = ["present", "blank"];
+const noValueOperators = ['present', 'blank']
// ============================================================================
// TableToolbar
@@ -109,7 +105,7 @@ export function TableToolbar({
onVisibleColumnsChange,
search,
onSearchChange,
- searchPlaceholder = "Search...",
+ searchPlaceholder = 'Search...',
sort,
onSortChange,
filters,
@@ -118,13 +114,13 @@ export function TableToolbar({
title,
actions,
}: TableToolbarProps) {
- const [filterOpen, setFilterOpen] = useState(false);
- const searchRef = useRef<HTMLInputElement>(null);
+ const [filterOpen, setFilterOpen] = useState(false)
+ const searchRef = useRef<HTMLInputElement>(null)
- const allCols = allColumns ?? columns;
- const sortableColumns = allCols.filter((c) => c.sortable);
- const filterableColumns = allCols.filter((c) => c.filterable);
- const activeFilterCount = filters.length;
+ const allCols = allColumns ?? columns
+ const sortableColumns = allCols.filter((c) => c.sortable)
+ const filterableColumns = allCols.filter((c) => c.filterable)
+ const activeFilterCount = filters.length
return (
<>
@@ -146,8 +142,8 @@ export function TableToolbar({
type="button"
className="p-0.5 text-gray-400 hover:text-gray-600 shrink-0"
onClick={() => {
- onSearchChange("");
- searchRef.current?.focus();
+ onSearchChange('')
+ searchRef.current?.focus()
}}
>
<XIcon className="size-3.5" />
@@ -163,16 +159,10 @@ export function TableToolbar({
<Tooltip>
<TooltipTrigger asChild>
<PopoverTrigger asChild>
- <Button
- variant="outline"
- size="sm"
- className="h-[2.125rem]"
- >
+ <Button variant="outline" size="sm" className="h-[2.125rem]">
<FilterIcon className="size-4" />
{activeFilterCount > 0 && (
- <Badge className="ml-1 px-1.5 py-0 text-xs">
- {activeFilterCount}
- </Badge>
+ <Badge className="ml-1 px-1.5 py-0 text-xs">{activeFilterCount}</Badge>
)}
</Button>
</PopoverTrigger>
@@ -183,7 +173,10 @@ export function TableToolbar({
<FilterPanel
columns={filterableColumns}
filters={filters}
- onApply={(f) => { onFiltersChange(f); setFilterOpen(false); }}
+ onApply={(f) => {
+ onFiltersChange(f)
+ setFilterOpen(false)
+ }}
onClose={() => setFilterOpen(false)}
/>
</PopoverContent>
@@ -192,11 +185,7 @@ export function TableToolbar({
{/* Sort dropdown */}
{sortableColumns.length > 0 && (
- <SortDropdown
- columns={sortableColumns}
- sort={sort}
- onSortChange={onSortChange}
- />
+ <SortDropdown columns={sortableColumns} sort={sort} onSortChange={onSortChange} />
)}
{/* Column selector */}
@@ -214,16 +203,12 @@ export function TableToolbar({
{filters.length > 0 && (
<div className="flex gap-2 flex-wrap px-3 py-2 border-b border-gray-200">
{filters.map((filter) => {
- const col = allCols.find((c) => c.key === filter.field);
- const ops = getOperators(col?.filterType ?? "string");
- const opLabel =
- ops.find((o) => o.value === filter.operator)?.label ??
- filter.operator;
+ const col = allCols.find((c) => c.key === filter.field)
+ const ops = getOperators(col?.filterType ?? 'string')
+ const opLabel = ops.find((o) => o.value === filter.operator)?.label ?? filter.operator
return (
<Badge key={filter.id} className="gap-1.5 pr-1">
- <span className="font-medium">
- {col?.label ?? filter.field}
- </span>
+ <span className="font-medium">{col?.label ?? filter.field}</span>
<span className="text-muted-foreground">{opLabel}</span>
{!noValueOperators.includes(filter.operator) && (
<span className="font-medium">{filter.value}</span>
@@ -231,14 +216,12 @@ export function TableToolbar({
<button
type="button"
className="ml-0.5 p-0.5 rounded-sm hover:bg-gray-200"
- onClick={() =>
- onFiltersChange(filters.filter((f) => f.id !== filter.id))
- }
+ onClick={() => onFiltersChange(filters.filter((f) => f.id !== filter.id))}
>
<XIcon className="size-3" />
</button>
</Badge>
- );
+ )
})}
<button
type="button"
@@ -249,9 +232,8 @@ export function TableToolbar({
</button>
</div>
)}
-
</>
- );
+ )
}
// ============================================================================
@@ -263,11 +245,11 @@ function SortDropdown({
sort,
onSortChange,
}: {
- columns: ColumnDef[];
- sort: SortOption;
- onSortChange: (sort: SortOption) => void;
+ columns: ColumnDef[]
+ sort: SortOption
+ onSortChange: (sort: SortOption) => void
}) {
- const currentCol = columns.find((c) => c.key === sort.field);
+ const currentCol = columns.find((c) => c.key === sort.field)
return (
<DropdownMenu>
@@ -279,16 +261,14 @@ function SortDropdown({
</Button>
</DropdownMenuTrigger>
</TooltipTrigger>
- <TooltipContent>{currentCol?.label ?? "Sort"}</TooltipContent>
+ <TooltipContent>{currentCol?.label ?? 'Sort'}</TooltipContent>
</Tooltip>
<DropdownMenuContent align="end" className="min-w-48">
<DropdownMenuLabel>Sort by</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuRadioGroup
value={sort.field}
- onValueChange={(field) =>
- onSortChange({ field, direction: sort.direction })
- }
+ onValueChange={(field) => onSortChange({ field, direction: sort.direction })}
>
{columns.map((col) => (
<DropdownMenuRadioItem key={col.key} value={col.key}>
@@ -304,7 +284,7 @@ function SortDropdown({
onValueChange={(dir) =>
onSortChange({
field: sort.field,
- direction: dir as "asc" | "desc",
+ direction: dir as 'asc' | 'desc',
})
}
>
@@ -313,7 +293,7 @@ function SortDropdown({
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
- );
+ )
}
// ============================================================================
@@ -325,11 +305,11 @@ function ColumnSelector({
visibleColumns,
onVisibleColumnsChange,
}: {
- columns: ColumnDef[];
- visibleColumns: string[];
- onVisibleColumnsChange: (columns: string[]) => void;
+ columns: ColumnDef[]
+ visibleColumns: string[]
+ onVisibleColumnsChange: (columns: string[]) => void
}) {
- const defaults = columns.filter((c) => c.default).map((c) => c.key);
+ const defaults = columns.filter((c) => c.default).map((c) => c.key)
return (
<DropdownMenu>
@@ -355,7 +335,7 @@ function ColumnSelector({
checked
? [...visibleColumns, col.key]
: visibleColumns.filter((k) => k !== col.key),
- );
+ )
}}
onSelect={(e) => e.preventDefault()}
>
@@ -375,7 +355,7 @@ function ColumnSelector({
</div>
</DropdownMenuContent>
</DropdownMenu>
- );
+ )
}
// ============================================================================
@@ -388,45 +368,40 @@ function FilterPanel({
onApply,
onClose,
}: {
- columns: ColumnDef[];
- filters: FilterRule[];
- onApply: (filters: FilterRule[]) => void;
- onClose: () => void;
+ columns: ColumnDef[]
+ filters: FilterRule[]
+ onApply: (filters: FilterRule[]) => void
+ onClose: () => void
}) {
- const [draft, setDraft] = useState<FilterRule[]>(initialFilters);
+ const [draft, setDraft] = useState<FilterRule[]>(initialFilters)
const addFilter = useCallback(() => {
- const first = columns[0];
- if (!first) return;
+ const first = columns[0]
+ if (!first) return
setDraft((prev) => [
...prev,
{
id: crypto.randomUUID(),
field: first.key,
- operator: getOperators(first.filterType ?? "string")[0].value,
- value: "",
+ operator: getOperators(first.filterType ?? 'string')[0].value,
+ value: '',
},
- ]);
- }, [columns]);
-
- const updateFilter = useCallback(
- (id: string, update: Partial<FilterRule>) => {
- setDraft((prev) =>
- prev.map((f) => (f.id === id ? { ...f, ...update } : f)),
- );
- },
- [],
- );
+ ])
+ }, [columns])
+
+ const updateFilter = useCallback((id: string, update: Partial<FilterRule>) => {
+ setDraft((prev) => prev.map((f) => (f.id === id ? { ...f, ...update } : f)))
+ }, [])
const removeFilter = useCallback((id: string) => {
- setDraft((prev) => prev.filter((f) => f.id !== id));
- }, []);
+ setDraft((prev) => prev.filter((f) => f.id !== id))
+ }, [])
function handleApply() {
const valid = draft.filter(
- (f) => noValueOperators.includes(f.operator) || f.value.trim() !== "",
- );
- onApply(valid);
+ (f) => noValueOperators.includes(f.operator) || f.value.trim() !== '',
+ )
+ onApply(valid)
}
return (
@@ -440,25 +415,22 @@ function FilterPanel({
<div className="max-h-[320px] overflow-y-auto p-3 space-y-2">
{draft.map((filter) => {
- const col = columns.find((c) => c.key === filter.field);
- const type = col?.filterType ?? "string";
- const ops = getOperators(type);
+ const col = columns.find((c) => c.key === filter.field)
+ const type = col?.filterType ?? 'string'
+ const ops = getOperators(type)
return (
- <div
- key={filter.id}
- className="flex items-center gap-1.5"
- >
+ <div key={filter.id} className="flex items-center gap-1.5">
<Select
value={filter.field}
onValueChange={(val) => {
- const newCol = columns.find((c) => c.key === val);
- const newOps = getOperators(newCol?.filterType ?? "string");
+ const newCol = columns.find((c) => c.key === val)
+ const newOps = getOperators(newCol?.filterType ?? 'string')
updateFilter(filter.id, {
field: val,
operator: newOps[0].value,
- value: "",
- });
+ value: '',
+ })
}}
>
<SelectTrigger size="sm" className="flex-1">
@@ -475,9 +447,7 @@ function FilterPanel({
<Select
value={filter.operator}
- onValueChange={(val) =>
- updateFilter(filter.id, { operator: val })
- }
+ onValueChange={(val) => updateFilter(filter.id, { operator: val })}
>
<SelectTrigger size="sm" className="w-[120px] shrink-0">
<SelectValue />
@@ -492,12 +462,10 @@ function FilterPanel({
</Select>
{!noValueOperators.includes(filter.operator) &&
- (col?.filterType === "status" && col.filterOptions ? (
+ (col?.filterType === 'status' && col.filterOptions ? (
<Select
value={filter.value || undefined}
- onValueChange={(val) =>
- updateFilter(filter.id, { value: val })
- }
+ onValueChange={(val) => updateFilter(filter.id, { value: val })}
>
<SelectTrigger size="sm" className="flex-1">
<SelectValue placeholder="Select..." />
@@ -510,12 +478,10 @@ function FilterPanel({
))}
</SelectContent>
</Select>
- ) : col?.filterType === "boolean" ? (
+ ) : col?.filterType === 'boolean' ? (
<Select
value={filter.value || undefined}
- onValueChange={(val) =>
- updateFilter(filter.id, { value: val })
- }
+ onValueChange={(val) => updateFilter(filter.id, { value: val })}
>
<SelectTrigger size="sm" className="flex-1">
<SelectValue placeholder="Select..." />
@@ -528,18 +494,16 @@ function FilterPanel({
) : (
<Input
type={
- col?.filterType === "number"
- ? "number"
- : col?.filterType === "date"
- ? "date"
- : "text"
+ col?.filterType === 'number'
+ ? 'number'
+ : col?.filterType === 'date'
+ ? 'date'
+ : 'text'
}
className="flex-1 py-1 px-2 text-sm h-7"
placeholder="Value..."
value={filter.value}
- onChange={(e) =>
- updateFilter(filter.id, { value: e.target.value })
- }
+ onChange={(e) => updateFilter(filter.id, { value: e.target.value })}
/>
))}
@@ -551,7 +515,7 @@ function FilterPanel({
<Trash2Icon className="size-3.5" />
</button>
</div>
- );
+ )
})}
{draft.length === 0 && (
@@ -578,5 +542,5 @@ function FilterPanel({
</div>
</div>
</div>
- );
+ )
}
diff --git a/packages/admin/src/components/tag-combobox.tsx b/packages/admin/src/components/tag-combobox.tsx
index f4da964ed9..79b58f791a 100644
--- a/packages/admin/src/components/tag-combobox.tsx
+++ b/packages/admin/src/components/tag-combobox.tsx
@@ -1,7 +1,6 @@
import { useQuery } from '@tanstack/react-query'
import { useMemo, useState } from 'react'
import { adminClient } from '@/client'
-import { useAuth } from '@/hooks/use-auth'
import {
Combobox,
ComboboxChip,
@@ -14,6 +13,7 @@ import {
ComboboxValue,
useComboboxAnchor,
} from '@/components/ui/combobox'
+import { useAuth } from '@/hooks/use-auth'
export type TaggableType = 'Spree::Product' | 'Spree::Order' | 'Spree::User'
diff --git a/packages/admin/src/components/ui/avatar.tsx b/packages/admin/src/components/ui/avatar.tsx
index 0ab41c35a2..5288e9388e 100644
--- a/packages/admin/src/components/ui/avatar.tsx
+++ b/packages/admin/src/components/ui/avatar.tsx
@@ -91,4 +91,4 @@ function AvatarGroupCount({ className, ...props }: React.ComponentProps<'div'>)
)
}
-export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge }
+export { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage }
diff --git a/packages/admin/src/components/ui/badge.tsx b/packages/admin/src/components/ui/badge.tsx
index 1eea63470a..5621f234df 100644
--- a/packages/admin/src/components/ui/badge.tsx
+++ b/packages/admin/src/components/ui/badge.tsx
@@ -69,4 +69,4 @@ function StatusBadge({ status, className }: { status: string; className?: string
)
}
-export { Badge, StatusBadge, badgeVariants }
+export { Badge, badgeVariants, StatusBadge }
diff --git a/packages/admin/src/components/ui/breadcrumb.tsx b/packages/admin/src/components/ui/breadcrumb.tsx
index e12ecd42e5..47d37a8088 100644
--- a/packages/admin/src/components/ui/breadcrumb.tsx
+++ b/packages/admin/src/components/ui/breadcrumb.tsx
@@ -92,10 +92,10 @@ function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'
export {
Breadcrumb,
- BreadcrumbList,
+ BreadcrumbEllipsis,
BreadcrumbItem,
BreadcrumbLink,
+ BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
- BreadcrumbEllipsis,
}
diff --git a/packages/admin/src/components/ui/button.tsx b/packages/admin/src/components/ui/button.tsx
index 1e31d4591f..3b5e6f736d 100644
--- a/packages/admin/src/components/ui/button.tsx
+++ b/packages/admin/src/components/ui/button.tsx
@@ -10,7 +10,8 @@ const buttonVariants = cva(
variants: {
variant: {
default: 'bg-primary text-primary-foreground shadow-xs hover:bg-zinc-800',
- outline: 'border-border bg-muted text-foreground shadow-xs hover:bg-gray-100 hover:text-foreground aria-expanded:bg-gray-100',
+ outline:
+ 'border-border bg-muted text-foreground shadow-xs hover:bg-gray-100 hover:text-foreground aria-expanded:bg-gray-100',
ghost: 'hover:bg-accent hover:text-accent-foreground aria-expanded:bg-accent',
destructive: 'text-destructive bg-muted border-border shadow-xs hover:bg-red-100',
link: 'text-primary underline-offset-4 hover:underline',
diff --git a/packages/admin/src/components/ui/card.tsx b/packages/admin/src/components/ui/card.tsx
index 4023ed3f7f..49b719a157 100644
--- a/packages/admin/src/components/ui/card.tsx
+++ b/packages/admin/src/components/ui/card.tsx
@@ -20,7 +20,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
<div
data-slot="card-header"
className={cn(
- 'group/card-header @container/card-header grid auto-rows-min items-start gap-1 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] p-3 border-b border-gray-100 rounded-t-[calc(var(--radius-2xl)-1px)]',
+ 'group/card-header @container/card-header grid auto-rows-min items-start gap-1 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] px-3 py-2 border-b border-gray-100 rounded-t-[calc(var(--radius-2xl)-1px)]',
className,
)}
{...props}
@@ -69,4 +69,4 @@ function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
)
}
-export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }
+export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }
diff --git a/packages/admin/src/components/ui/collapsible.tsx b/packages/admin/src/components/ui/collapsible.tsx
index cb4ce4c9fb..1d051c4364 100644
--- a/packages/admin/src/components/ui/collapsible.tsx
+++ b/packages/admin/src/components/ui/collapsible.tsx
@@ -1,9 +1,7 @@
import { Collapsible as CollapsiblePrimitive } from '@base-ui/react/collapsible'
import type * as React from 'react'
-function Collapsible({
- ...props
-}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
+function Collapsible({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
}
@@ -13,10 +11,8 @@ function CollapsibleTrigger({
return <CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />
}
-function CollapsibleContent({
- ...props
-}: React.ComponentProps<typeof CollapsiblePrimitive.Panel>) {
+function CollapsibleContent({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Panel>) {
return <CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />
}
-export { Collapsible, CollapsibleTrigger, CollapsibleContent }
+export { Collapsible, CollapsibleContent, CollapsibleTrigger }
diff --git a/packages/admin/src/components/ui/combobox.tsx b/packages/admin/src/components/ui/combobox.tsx
index c97a571233..f86834083a 100644
--- a/packages/admin/src/components/ui/combobox.tsx
+++ b/packages/admin/src/components/ui/combobox.tsx
@@ -1,17 +1,16 @@
-"use client"
+'use client'
-import * as React from "react"
-import { Combobox as ComboboxPrimitive } from "@base-ui/react"
-
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
+import { Combobox as ComboboxPrimitive } from '@base-ui/react'
+import { CheckIcon, ChevronDownIcon, XIcon } from 'lucide-react'
+import * as React from 'react'
+import { Button } from '@/components/ui/button'
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
-} from "@/components/ui/input-group"
-import { ChevronDownIcon, XIcon, CheckIcon } from "lucide-react"
+} from '@/components/ui/input-group'
+import { cn } from '@/lib/utils'
const Combobox = ComboboxPrimitive.Root
@@ -19,11 +18,7 @@ function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />
}
-function ComboboxTrigger({
- className,
- children,
- ...props
-}: ComboboxPrimitive.Trigger.Props) {
+function ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {
return (
<ComboboxPrimitive.Trigger
data-slot="combobox-trigger"
@@ -61,11 +56,8 @@ function ComboboxInput({
showClear?: boolean
}) {
return (
- <InputGroup className={cn("w-auto", className)}>
- <ComboboxPrimitive.Input
- render={<InputGroupInput disabled={disabled} />}
- {...props}
- />
+ <InputGroup className={cn('w-auto', className)}>
+ <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />
<InputGroupAddon align="inline-end">
{showTrigger && (
<InputGroupButton
@@ -88,16 +80,16 @@ function ComboboxInput({
function ComboboxContent({
className,
- side = "bottom",
+ side = 'bottom',
sideOffset = 6,
- align = "start",
+ align = 'start',
alignOffset = 0,
anchor,
...props
}: ComboboxPrimitive.Popup.Props &
Pick<
ComboboxPrimitive.Positioner.Props,
- "side" | "align" | "sideOffset" | "alignOffset" | "anchor"
+ 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'
>) {
return (
<ComboboxPrimitive.Portal>
@@ -112,7 +104,10 @@ function ComboboxContent({
<ComboboxPrimitive.Popup
data-slot="combobox-content"
data-chips={!!anchor}
- className={cn("group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none 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(
+ 'group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none 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}
/>
</ComboboxPrimitive.Positioner>
@@ -125,25 +120,21 @@ function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
<ComboboxPrimitive.List
data-slot="combobox-list"
className={cn(
- "no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
- className
+ 'no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0',
+ className,
)}
{...props}
/>
)
}
-function ComboboxItem({
- className,
- children,
- ...props
-}: ComboboxPrimitive.Item.Props) {
+function ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {
return (
<ComboboxPrimitive.Item
data-slot="combobox-item"
className={cn(
"relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
- className
+ className,
)}
{...props}
>
@@ -160,32 +151,21 @@ function ComboboxItem({
}
function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
- return (
- <ComboboxPrimitive.Group
- data-slot="combobox-group"
- className={cn(className)}
- {...props}
- />
- )
+ return <ComboboxPrimitive.Group data-slot="combobox-group" className={cn(className)} {...props} />
}
-function ComboboxLabel({
- className,
- ...props
-}: ComboboxPrimitive.GroupLabel.Props) {
+function ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {
return (
<ComboboxPrimitive.GroupLabel
data-slot="combobox-label"
- className={cn("px-2 py-1.5 text-xs text-muted-foreground", className)}
+ className={cn('px-2 py-1.5 text-xs text-muted-foreground', className)}
{...props}
/>
)
}
function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
- return (
- <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
- )
+ return <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
}
function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
@@ -193,22 +173,19 @@ function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
<ComboboxPrimitive.Empty
data-slot="combobox-empty"
className={cn(
- "hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",
- className
+ 'hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex',
+ className,
)}
{...props}
/>
)
}
-function ComboboxSeparator({
- className,
- ...props
-}: ComboboxPrimitive.Separator.Props) {
+function ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {
return (
<ComboboxPrimitive.Separator
data-slot="combobox-separator"
- className={cn("-mx-1 my-1 h-px bg-border", className)}
+ className={cn('-mx-1 my-1 h-px bg-border', className)}
{...props}
/>
)
@@ -217,14 +194,13 @@ function ComboboxSeparator({
function ComboboxChips({
className,
...props
-}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> &
- ComboboxPrimitive.Chips.Props) {
+}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {
return (
<ComboboxPrimitive.Chips
data-slot="combobox-chips"
className={cn(
- "flex flex-wrap items-center gap-1 rounded-lg border border-gray-200 bg-white shadow-xs px-2.5 py-1.5 text-base transition-all duration-100 ease-in-out focus-within:border-blue-500 focus-within:shadow-[0_0_0_3px_rgba(59,130,246,0.15)] has-aria-invalid:border-destructive has-data-[slot=combobox-chip]:px-1",
- className
+ 'flex flex-wrap items-center gap-1 rounded-lg border border-gray-200 bg-white shadow-xs px-2.5 py-1.5 text-base transition-all duration-100 ease-in-out focus-within:border-blue-500 focus-within:shadow-[0_0_0_3px_rgba(59,130,246,0.15)] has-aria-invalid:border-destructive has-data-[slot=combobox-chip]:px-1',
+ className,
)}
{...props}
/>
@@ -243,8 +219,8 @@ function ComboboxChip({
<ComboboxPrimitive.Chip
data-slot="combobox-chip"
className={cn(
- "flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
- className
+ 'flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0',
+ className,
)}
{...props}
>
@@ -262,14 +238,11 @@ function ComboboxChip({
)
}
-function ComboboxChipsInput({
- className,
- ...props
-}: ComboboxPrimitive.Input.Props) {
+function ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props) {
return (
<ComboboxPrimitive.Input
data-slot="combobox-chip-input"
- className={cn("min-w-16 flex-1 outline-none", className)}
+ className={cn('min-w-16 flex-1 outline-none', className)}
{...props}
/>
)
@@ -281,18 +254,18 @@ function useComboboxAnchor() {
export {
Combobox,
- ComboboxInput,
+ ComboboxChip,
+ ComboboxChips,
+ ComboboxChipsInput,
+ ComboboxCollection,
ComboboxContent,
- ComboboxList,
- ComboboxItem,
+ ComboboxEmpty,
ComboboxGroup,
+ ComboboxInput,
+ ComboboxItem,
ComboboxLabel,
- ComboboxCollection,
- ComboboxEmpty,
+ ComboboxList,
ComboboxSeparator,
- ComboboxChips,
- ComboboxChip,
- ComboboxChipsInput,
ComboboxTrigger,
ComboboxValue,
useComboboxAnchor,
diff --git a/packages/admin/src/components/ui/data-table.tsx b/packages/admin/src/components/ui/data-table.tsx
index fca91a2558..704e9720df 100644
--- a/packages/admin/src/components/ui/data-table.tsx
+++ b/packages/admin/src/components/ui/data-table.tsx
@@ -57,4 +57,4 @@ function TableEmpty({ children, colSpan }: { children: ReactNode; colSpan: numbe
)
}
-export { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, TableEmpty }
+export { Table, TableBody, TableCell, TableEmpty, TableHead, TableHeader, TableRow }
diff --git a/packages/admin/src/components/ui/date-picker.tsx b/packages/admin/src/components/ui/date-picker.tsx
index 3784d36dd3..9ad45620b0 100644
--- a/packages/admin/src/components/ui/date-picker.tsx
+++ b/packages/admin/src/components/ui/date-picker.tsx
@@ -2,8 +2,8 @@ import { format, parseISO } from 'date-fns'
import { CalendarIcon, XIcon } from 'lucide-react'
import { useState } from 'react'
import { Button } from '@/components/ui/button'
-import { Input } from '@/components/ui/input'
import { Calendar } from '@/components/ui/calendar'
+import { Input } from '@/components/ui/input'
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
interface DatePickerProps {
@@ -62,16 +62,10 @@ function DatePicker({
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild disabled={disabled}>
- <Button
- type="button"
- variant="outline"
- data-empty={!isValidDate}
- >
+ <Button type="button" variant="outline" data-empty={!isValidDate}>
<CalendarIcon className="size-4 shrink-0 text-gray-400" />
<span className="flex-1 truncate">
- {isValidDate
- ? format(date, includeTime ? 'PPP p' : 'PPP')
- : placeholder}
+ {isValidDate ? format(date, includeTime ? 'PPP p' : 'PPP') : placeholder}
</span>
{isValidDate && (
<span
@@ -94,11 +88,7 @@ function DatePicker({
/>
{includeTime && (
<div className="border-t border-gray-200 px-3 py-2">
- <Input
- type="time"
- value={timeValue}
- onChange={handleTimeChange}
- />
+ <Input type="time" value={timeValue} onChange={handleTimeChange} />
</div>
)}
</PopoverContent>
@@ -106,5 +96,5 @@ function DatePicker({
)
}
-export { DatePicker }
export type { DatePickerProps }
+export { DatePicker }
diff --git a/packages/admin/src/components/ui/dialog.tsx b/packages/admin/src/components/ui/dialog.tsx
index 035abe6559..751c3d92a1 100644
--- a/packages/admin/src/components/ui/dialog.tsx
+++ b/packages/admin/src/components/ui/dialog.tsx
@@ -1,5 +1,5 @@
-import { XIcon } from 'lucide-react'
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog'
+import { XIcon } from 'lucide-react'
import * as React from 'react'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
@@ -19,7 +19,14 @@ function Dialog({
modal?: boolean | 'trap-focus'
}) {
return (
- <DialogPrimitive.Root data-slot="dialog" open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange} modal={modal} {...props}>
+ <DialogPrimitive.Root
+ data-slot="dialog"
+ open={open}
+ defaultOpen={defaultOpen}
+ onOpenChange={onOpenChange}
+ modal={modal}
+ {...props}
+ >
{children}
</DialogPrimitive.Root>
)
@@ -33,9 +40,7 @@ function DialogTrigger({
asChild?: boolean
}) {
if (asChild && React.isValidElement(children)) {
- return (
- <DialogPrimitive.Trigger data-slot="dialog-trigger" render={children} {...props} />
- )
+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" render={children} {...props} />
}
return (
<DialogPrimitive.Trigger data-slot="dialog-trigger" {...props}>
@@ -60,9 +65,7 @@ function DialogClose({
asChild?: boolean
}) {
if (asChild && React.isValidElement(children)) {
- return (
- <DialogPrimitive.Close data-slot="dialog-close" render={children} {...props} />
- )
+ return <DialogPrimitive.Close data-slot="dialog-close" render={children} {...props} />
}
return (
<DialogPrimitive.Close data-slot="dialog-close" {...props}>
@@ -113,12 +116,15 @@ function DialogContent({
>
{children}
{showCloseButton && (
- <DialogPrimitive.Close data-slot="dialog-close" render={
- <Button variant="ghost" className="absolute top-3 right-3" size="icon-sm">
- <XIcon />
- <span className="sr-only">Close</span>
- </Button>
- } />
+ <DialogPrimitive.Close
+ data-slot="dialog-close"
+ render={
+ <Button variant="ghost" className="absolute top-3 right-3" size="icon-sm">
+ <XIcon />
+ <span className="sr-only">Close</span>
+ </Button>
+ }
+ />
)}
</DialogPrimitive.Popup>
</DialogPortal>
@@ -163,11 +169,7 @@ function DialogFooter({
{...props}
>
{children}
- {showCloseButton && (
- <DialogPrimitive.Close render={
- <Button>Close</Button>
- } />
- )}
+ {showCloseButton && <DialogPrimitive.Close render={<Button>Close</Button>} />}
</div>
)
}
diff --git a/packages/admin/src/components/ui/dropdown-menu.tsx b/packages/admin/src/components/ui/dropdown-menu.tsx
index 64d42ea813..2e22e6a296 100644
--- a/packages/admin/src/components/ui/dropdown-menu.tsx
+++ b/packages/admin/src/components/ui/dropdown-menu.tsx
@@ -1,7 +1,7 @@
'use client'
-import { CheckIcon, ChevronRightIcon } from 'lucide-react'
import { Menu as MenuPrimitive } from '@base-ui/react/menu'
+import { CheckIcon, ChevronRightIcon } from 'lucide-react'
import * as React from 'react'
import { cn } from '@/lib/utils'
@@ -20,7 +20,14 @@ function DropdownMenu({
modal?: boolean
}) {
return (
- <MenuPrimitive.Root data-slot="dropdown-menu" open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange} modal={modal} {...props}>
+ <MenuPrimitive.Root
+ data-slot="dropdown-menu"
+ open={open}
+ defaultOpen={defaultOpen}
+ onOpenChange={onOpenChange}
+ modal={modal}
+ {...props}
+ >
{children}
</MenuPrimitive.Root>
)
@@ -45,9 +52,7 @@ function DropdownMenuTrigger({
asChild?: boolean
}) {
if (asChild && React.isValidElement(children)) {
- return (
- <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" render={children} {...props} />
- )
+ return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" render={children} {...props} />
}
return (
<MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props}>
@@ -72,12 +77,7 @@ function DropdownMenuContent({
} & Omit<React.ComponentProps<typeof MenuPrimitive.Popup>, 'className'>) {
return (
<MenuPrimitive.Portal>
- <MenuPrimitive.Positioner
- side={side}
- sideOffset={sideOffset}
- align={align}
- className="z-50"
- >
+ <MenuPrimitive.Positioner side={side} sideOffset={sideOffset} align={align} className="z-50">
<MenuPrimitive.Popup
data-slot="dropdown-menu-content"
className={cn(
@@ -93,9 +93,7 @@ function DropdownMenuContent({
)
}
-function DropdownMenuGroup({
- ...props
-}: React.ComponentProps<typeof MenuPrimitive.Group>) {
+function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof MenuPrimitive.Group>) {
return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
}
@@ -330,18 +328,18 @@ function DropdownMenuSubContent({
export {
DropdownMenu,
- DropdownMenuPortal,
- DropdownMenuTrigger,
+ DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuGroup,
- DropdownMenuLabel,
DropdownMenuItem,
- DropdownMenuCheckboxItem,
+ DropdownMenuLabel,
+ DropdownMenuPortal,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuSub,
- DropdownMenuSubTrigger,
DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuTrigger,
}
diff --git a/packages/admin/src/components/ui/field.tsx b/packages/admin/src/components/ui/field.tsx
index 4f1426f49e..e565f12488 100644
--- a/packages/admin/src/components/ui/field.tsx
+++ b/packages/admin/src/components/ui/field.tsx
@@ -1,17 +1,16 @@
-import { useMemo } from "react"
-import { cva, type VariantProps } from "class-variance-authority"
+import { cva, type VariantProps } from 'class-variance-authority'
+import { useMemo } from 'react'
+import { Label } from '@/components/ui/label'
+import { Separator } from '@/components/ui/separator'
+import { cn } from '@/lib/utils'
-import { cn } from "@/lib/utils"
-import { Label } from "@/components/ui/label"
-import { Separator } from "@/components/ui/separator"
-
-function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
+function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {
return (
<fieldset
data-slot="field-set"
className={cn(
- "flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
- className
+ 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',
+ className,
)}
{...props}
/>
@@ -20,58 +19,55 @@ function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
function FieldLegend({
className,
- variant = "legend",
+ variant = 'legend',
...props
-}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
+}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {
return (
<legend
data-slot="field-legend"
data-variant={variant}
className={cn(
- "mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
- className
+ 'mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base',
+ className,
)}
{...props}
/>
)
}
-function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
+function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="field-group"
className={cn(
- "group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
- className
+ 'group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',
+ className,
)}
{...props}
/>
)
}
-const fieldVariants = cva(
- "group/field flex w-full gap-2 data-[invalid=true]:text-destructive",
- {
- variants: {
- orientation: {
- vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
- horizontal:
- "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
- responsive:
- "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
- },
- },
- defaultVariants: {
- orientation: "vertical",
+const fieldVariants = cva('group/field flex w-full gap-2 data-[invalid=true]:text-destructive', {
+ variants: {
+ orientation: {
+ vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',
+ horizontal:
+ 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
+ responsive:
+ 'flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
},
- }
-)
+ },
+ defaultVariants: {
+ orientation: 'vertical',
+ },
+})
function Field({
className,
- orientation = "vertical",
+ orientation = 'vertical',
...props
-}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
+}: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>) {
return (
<div
role="group"
@@ -83,58 +79,52 @@ function Field({
)
}
-function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
+function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="field-content"
- className={cn(
- "group/field-content flex flex-1 flex-col gap-0.5 leading-snug",
- className
- )}
+ className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}
{...props}
/>
)
}
-function FieldLabel({
- className,
- ...props
-}: React.ComponentProps<typeof Label>) {
+function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>) {
return (
<Label
data-slot="field-label"
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-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 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
+ '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-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 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,
)}
{...props}
/>
)
}
-function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
+function FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="field-label"
className={cn(
- "flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
- className
+ 'flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50',
+ className,
)}
{...props}
/>
)
}
-function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
+function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
return (
<p
data-slot="field-description"
className={cn(
- "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
+ '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,
)}
{...props}
/>
@@ -145,7 +135,7 @@ function FieldSeparator({
children,
className,
...props
-}: React.ComponentProps<"div"> & {
+}: React.ComponentProps<'div'> & {
children?: React.ReactNode
}) {
return (
@@ -153,8 +143,8 @@ function FieldSeparator({
data-slot="field-separator"
data-content={!!children}
className={cn(
- "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
- className
+ 'relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2',
+ className,
)}
{...props}
>
@@ -176,7 +166,7 @@ function FieldError({
children,
errors,
...props
-}: React.ComponentProps<"div"> & {
+}: React.ComponentProps<'div'> & {
errors?: Array<{ message?: string } | undefined>
}) {
const content = useMemo(() => {
@@ -188,9 +178,7 @@ function FieldError({
return null
}
- const uniqueErrors = [
- ...new Map(errors.map((error) => [error?.message, error])).values(),
- ]
+ const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()]
if (uniqueErrors?.length == 1) {
return uniqueErrors[0]?.message
@@ -198,10 +186,7 @@ function FieldError({
return (
<ul className="ml-4 flex list-disc flex-col gap-1">
- {uniqueErrors.map(
- (error, index) =>
- error?.message && <li key={index}>{error.message}</li>
- )}
+ {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}
</ul>
)
}, [children, errors])
@@ -214,7 +199,7 @@ function FieldError({
<div
role="alert"
data-slot="field-error"
- className={cn("text-sm font-normal text-destructive", className)}
+ className={cn('text-sm font-normal text-destructive', className)}
{...props}
>
{content}
@@ -224,13 +209,13 @@ function FieldError({
export {
Field,
- FieldLabel,
+ FieldContent,
FieldDescription,
FieldError,
FieldGroup,
+ FieldLabel,
FieldLegend,
FieldSeparator,
FieldSet,
- FieldContent,
FieldTitle,
}
diff --git a/packages/admin/src/components/ui/input-group.tsx b/packages/admin/src/components/ui/input-group.tsx
index ebf425fb65..1efbfdb5ab 100644
--- a/packages/admin/src/components/ui/input-group.tsx
+++ b/packages/admin/src/components/ui/input-group.tsx
@@ -1,19 +1,18 @@
-import * as React from "react"
-import { cva, type VariantProps } from "class-variance-authority"
+import { cva, type VariantProps } from 'class-variance-authority'
+import * as React from 'react'
+import { Button } from '@/components/ui/button'
+import { Input } from '@/components/ui/input'
+import { Textarea } from '@/components/ui/textarea'
+import { cn } from '@/lib/utils'
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
-import { Input } from "@/components/ui/input"
-import { Textarea } from "@/components/ui/textarea"
-
-function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
+function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="input-group"
role="group"
className={cn(
- "group/input-group relative flex w-full min-w-0 items-center rounded-lg border border-gray-200 bg-white shadow-xs transition-all duration-100 ease-in-out outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:shadow-none has-disabled:bg-gray-50 has-disabled:border-gray-100 has-disabled:opacity-50 has-disabled:shadow-none has-[[data-slot=input-group-control]:focus-visible]:border-blue-500 has-[[data-slot=input-group-control]:focus-visible]:shadow-[0_0_0_3px_rgba(59,130,246,0.15)] has-[[data-slot][aria-invalid=true]]:border-destructive has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
- className
+ 'group/input-group relative flex w-full min-w-0 items-center rounded-lg border border-gray-200 bg-white shadow-xs transition-all duration-100 ease-in-out outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:shadow-none has-disabled:bg-gray-50 has-disabled:border-gray-100 has-disabled:opacity-50 has-disabled:shadow-none has-[[data-slot=input-group-control]:focus-visible]:border-blue-500 has-[[data-slot=input-group-control]:focus-visible]:shadow-[0_0_0_3px_rgba(59,130,246,0.15)] has-[[data-slot][aria-invalid=true]]:border-destructive has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5',
+ className,
)}
{...props}
/>
@@ -25,27 +24,25 @@ const inputGroupAddonVariants = cva(
{
variants: {
align: {
- "inline-start":
- "order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]",
- "inline-end":
- "order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]",
- "block-start":
- "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
- "block-end":
- "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2",
+ 'inline-start': 'order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]',
+ 'inline-end': 'order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]',
+ 'block-start':
+ 'order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2',
+ 'block-end':
+ 'order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2',
},
},
defaultVariants: {
- align: "inline-start",
+ align: 'inline-start',
},
- }
+ },
)
function InputGroupAddon({
className,
- align = "inline-start",
+ align = 'inline-start',
...props
-}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
+}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {
return (
<div
role="group"
@@ -53,41 +50,37 @@ function InputGroupAddon({
data-align={align}
className={cn(inputGroupAddonVariants({ align }), className)}
onClick={(e) => {
- if ((e.target as HTMLElement).closest("button")) {
+ if ((e.target as HTMLElement).closest('button')) {
return
}
- e.currentTarget.parentElement?.querySelector("input")?.focus()
+ e.currentTarget.parentElement?.querySelector('input')?.focus()
}}
{...props}
/>
)
}
-const inputGroupButtonVariants = cva(
- "flex items-center gap-2 text-sm shadow-none",
- {
- variants: {
- size: {
- xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
- sm: "",
- "icon-xs":
- "size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0",
- "icon-sm": "size-8 p-0 has-[>svg]:p-0",
- },
+const inputGroupButtonVariants = cva('flex items-center gap-2 text-sm shadow-none', {
+ variants: {
+ size: {
+ xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
+ sm: '',
+ 'icon-xs': 'size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0',
+ 'icon-sm': 'size-8 p-0 has-[>svg]:p-0',
},
- defaultVariants: {
- size: "xs",
- },
- }
-)
+ },
+ defaultVariants: {
+ size: 'xs',
+ },
+})
function InputGroupButton({
className,
- type = "button",
- variant = "ghost",
- size = "xs",
+ type = 'button',
+ variant = 'ghost',
+ size = 'xs',
...props
-}: Omit<React.ComponentProps<typeof Button>, "size"> &
+}: Omit<React.ComponentProps<typeof Button>, 'size'> &
VariantProps<typeof inputGroupButtonVariants>) {
return (
<Button
@@ -100,44 +93,38 @@ function InputGroupButton({
)
}
-function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
+function InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {
return (
<span
className={cn(
"flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
- className
+ className,
)}
{...props}
/>
)
}
-function InputGroupInput({
- className,
- ...props
-}: React.ComponentProps<"input">) {
+function InputGroupInput({ className, ...props }: React.ComponentProps<'input'>) {
return (
<Input
data-slot="input-group-control"
className={cn(
- "flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus:border-0 focus:shadow-none focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",
- className
+ 'flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus:border-0 focus:shadow-none focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0',
+ className,
)}
{...props}
/>
)
}
-function InputGroupTextarea({
- className,
- ...props
-}: React.ComponentProps<"textarea">) {
+function InputGroupTextarea({ className, ...props }: React.ComponentProps<'textarea'>) {
return (
<Textarea
data-slot="input-group-control"
className={cn(
- "flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
- className
+ 'flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent',
+ className,
)}
{...props}
/>
@@ -148,7 +135,7 @@ export {
InputGroup,
InputGroupAddon,
InputGroupButton,
- InputGroupText,
InputGroupInput,
+ InputGroupText,
InputGroupTextarea,
}
diff --git a/packages/admin/src/components/ui/label.tsx b/packages/admin/src/components/ui/label.tsx
index 79b967d2bb..b2d3773284 100644
--- a/packages/admin/src/components/ui/label.tsx
+++ b/packages/admin/src/components/ui/label.tsx
@@ -1,7 +1,7 @@
-import * as React from "react"
-import { Field } from "@base-ui/react/field"
+import { Field } from '@base-ui/react/field'
+import * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
/**
* Label component backed by Base UI's Field.Label.
@@ -9,18 +9,14 @@ import { cn } from "@/lib/utils"
* Wraps each label in a Field.Root so it can be used standalone
* without requiring consumers to manually add Field.Root parents.
*/
-function Label({
- className,
- children,
- ...props
-}: React.ComponentProps<"label">) {
+function Label({ className, children, ...props }: React.ComponentProps<'label'>) {
return (
<Field.Root>
<Field.Label
data-slot="label"
className={cn(
- "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
- className
+ 'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
+ className,
)}
{...props}
>
diff --git a/packages/admin/src/components/ui/popover.tsx b/packages/admin/src/components/ui/popover.tsx
index 160f5673bc..49ab2fb3af 100644
--- a/packages/admin/src/components/ui/popover.tsx
+++ b/packages/admin/src/components/ui/popover.tsx
@@ -27,9 +27,7 @@ function PopoverTrigger({
asChild?: boolean
}) {
if (asChild && React.isValidElement(children)) {
- return (
- <PopoverPrimitive.Trigger data-slot="popover-trigger" render={children} {...props} />
- )
+ return <PopoverPrimitive.Trigger data-slot="popover-trigger" render={children} {...props} />
}
return (
<PopoverPrimitive.Trigger data-slot="popover-trigger" {...props}>
@@ -54,11 +52,7 @@ function PopoverContent({
} & Omit<React.ComponentProps<typeof PopoverPrimitive.Popup>, 'className'>) {
return (
<PopoverPrimitive.Portal>
- <PopoverPrimitive.Positioner
- side={side}
- sideOffset={sideOffset}
- align={align}
- >
+ <PopoverPrimitive.Positioner side={side} sideOffset={sideOffset} align={align}>
<PopoverPrimitive.Popup
data-slot="popover-content"
className={cn(
@@ -75,10 +69,8 @@ function PopoverContent({
)
}
-function PopoverAnchor({
- ...props
-}: React.ComponentProps<'div'>) {
+function PopoverAnchor({ ...props }: React.ComponentProps<'div'>) {
return <div data-slot="popover-anchor" {...props} />
}
-export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
+export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger }
diff --git a/packages/admin/src/components/ui/rich-text-editor.tsx b/packages/admin/src/components/ui/rich-text-editor.tsx
index 955d8fa83e..f9d6832e79 100644
--- a/packages/admin/src/components/ui/rich-text-editor.tsx
+++ b/packages/admin/src/components/ui/rich-text-editor.tsx
@@ -1,4 +1,3 @@
-import { cn } from '@/lib/utils'
import Link from '@tiptap/extension-link'
import Placeholder from '@tiptap/extension-placeholder'
import { EditorContent, useEditor } from '@tiptap/react'
@@ -15,6 +14,7 @@ import {
UndoIcon,
} from 'lucide-react'
import { useCallback, useEffect } from 'react'
+import { cn } from '@/lib/utils'
interface RichTextEditorProps {
value?: string
@@ -128,11 +128,7 @@ export function RichTextEditor({
<ToolbarSeparator />
- <ToolbarButton
- active={editor.isActive('link')}
- onClick={setLink}
- title="Link"
- >
+ <ToolbarButton active={editor.isActive('link')} onClick={setLink} title="Link">
<LinkIcon className="size-4" />
</ToolbarButton>
diff --git a/packages/admin/src/components/ui/select.tsx b/packages/admin/src/components/ui/select.tsx
index a6844f2bdb..4236c754c4 100644
--- a/packages/admin/src/components/ui/select.tsx
+++ b/packages/admin/src/components/ui/select.tsx
@@ -1,6 +1,6 @@
-import { CheckIcon, ChevronDownIcon } from 'lucide-react'
import { Select as SelectPrimitive } from '@base-ui/react/select'
-import * as React from 'react'
+import { CheckIcon, ChevronDownIcon } from 'lucide-react'
+import type * as React from 'react'
import { cn } from '@/lib/utils'
function Select({
@@ -13,7 +13,13 @@ function Select({
return (
<SelectPrimitive.Root
data-slot="select"
- onValueChange={onValueChange ? (value: string | null) => { if (value !== null) onValueChange(value) } : undefined}
+ onValueChange={
+ onValueChange
+ ? (value: string | null) => {
+ if (value !== null) onValueChange(value)
+ }
+ : undefined
+ }
{...props}
>
{children}
@@ -64,8 +70,8 @@ function SelectTrigger({
function SelectContent({
className,
children,
- position = 'item-aligned',
- align = 'center',
+ position = 'popper',
+ align = 'start',
side = 'bottom',
...props
}: {
@@ -87,7 +93,7 @@ function SelectContent({
data-slot="select-content"
data-align-trigger={position === 'item-aligned'}
className={cn(
- 'relative z-[100] max-h-[var(--available-height)] min-w-36 overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 transition-[opacity,transform]',
+ 'relative z-[100] max-h-[var(--available-height)] min-w-[var(--anchor-width)] overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 transition-[opacity,transform]',
position === 'popper' &&
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
className,
@@ -101,7 +107,10 @@ function SelectContent({
)
}
-function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {
+function SelectLabel({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {
return (
<SelectPrimitive.GroupLabel
data-slot="select-label"
@@ -135,10 +144,7 @@ function SelectItem({
)
}
-function SelectSeparator({
- className,
- ...props
-}: React.ComponentProps<'div'>) {
+function SelectSeparator({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
role="separator"
diff --git a/packages/admin/src/components/ui/separator.tsx b/packages/admin/src/components/ui/separator.tsx
index 89c4e53b51..04f84b0144 100644
--- a/packages/admin/src/components/ui/separator.tsx
+++ b/packages/admin/src/components/ui/separator.tsx
@@ -1,13 +1,13 @@
-"use client"
+'use client'
-import * as React from "react"
-import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
+import { Separator as SeparatorPrimitive } from '@base-ui/react/separator'
+import * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
function Separator({
className,
- orientation = "horizontal",
+ orientation = 'horizontal',
decorative = true,
...props
}: React.ComponentProps<typeof SeparatorPrimitive> & {
@@ -20,8 +20,8 @@ function Separator({
orientation={orientation}
data-orientation={orientation}
className={cn(
- "shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px",
- className
+ 'shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px',
+ className,
)}
{...props}
/>
diff --git a/packages/admin/src/components/ui/sheet.tsx b/packages/admin/src/components/ui/sheet.tsx
index 20e6a064a2..28d85cb3c5 100644
--- a/packages/admin/src/components/ui/sheet.tsx
+++ b/packages/admin/src/components/ui/sheet.tsx
@@ -1,7 +1,7 @@
'use client'
-import { XIcon } from 'lucide-react'
import { Dialog as SheetPrimitive } from '@base-ui/react/dialog'
+import { XIcon } from 'lucide-react'
import * as React from 'react'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
@@ -19,7 +19,13 @@ function Sheet({
onOpenChange?: (open: boolean, eventDetails: SheetPrimitive.Root.ChangeEventDetails) => void
}) {
return (
- <SheetPrimitive.Root data-slot="sheet" open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange} {...props}>
+ <SheetPrimitive.Root
+ data-slot="sheet"
+ open={open}
+ defaultOpen={defaultOpen}
+ onOpenChange={onOpenChange}
+ {...props}
+ >
{children}
</SheetPrimitive.Root>
)
@@ -33,9 +39,7 @@ function SheetTrigger({
asChild?: boolean
}) {
if (asChild && React.isValidElement(children)) {
- return (
- <SheetPrimitive.Trigger data-slot="sheet-trigger" render={children} {...props} />
- )
+ return <SheetPrimitive.Trigger data-slot="sheet-trigger" render={children} {...props} />
}
return (
<SheetPrimitive.Trigger data-slot="sheet-trigger" {...props}>
@@ -52,9 +56,7 @@ function SheetClose({
asChild?: boolean
}) {
if (asChild && React.isValidElement(children)) {
- return (
- <SheetPrimitive.Close data-slot="sheet-close" render={children} {...props} />
- )
+ return <SheetPrimitive.Close data-slot="sheet-close" render={children} {...props} />
}
return (
<SheetPrimitive.Close data-slot="sheet-close" {...props}>
@@ -120,12 +122,15 @@ function SheetContent({
>
{children}
{showCloseButton && (
- <SheetPrimitive.Close data-slot="sheet-close" render={
- <Button variant="ghost" className="absolute top-3 right-3" size="icon-sm">
- <XIcon />
- <span className="sr-only">Close</span>
- </Button>
- } />
+ <SheetPrimitive.Close
+ data-slot="sheet-close"
+ render={
+ <Button variant="ghost" className="absolute top-3 right-3" size="icon-sm">
+ <XIcon />
+ <span className="sr-only">Close</span>
+ </Button>
+ }
+ />
)}
</SheetPrimitive.Popup>
</SheetPortal>
@@ -180,11 +185,11 @@ function SheetDescription({
export {
Sheet,
- SheetTrigger,
SheetClose,
SheetContent,
- SheetHeader,
+ SheetDescription,
SheetFooter,
+ SheetHeader,
SheetTitle,
- SheetDescription,
+ SheetTrigger,
}
diff --git a/packages/admin/src/components/ui/sidebar.tsx b/packages/admin/src/components/ui/sidebar.tsx
index 2d1583a78d..e4a15449fd 100644
--- a/packages/admin/src/components/ui/sidebar.tsx
+++ b/packages/admin/src/components/ui/sidebar.tsx
@@ -1,52 +1,48 @@
-import { cva, type VariantProps } from "class-variance-authority";
-import { PanelLeftIcon } from "lucide-react";
-import * as React from "react";
-import { Slot } from "@/components/ui/slot";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Separator } from "@/components/ui/separator";
+import { cva, type VariantProps } from 'class-variance-authority'
+import { PanelLeftIcon } from 'lucide-react'
+import * as React from 'react'
+import { Button } from '@/components/ui/button'
+import { Input } from '@/components/ui/input'
+import { Separator } from '@/components/ui/separator'
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
-} from "@/components/ui/sheet";
-import { Skeleton } from "@/components/ui/skeleton";
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { useIsMobile } from "@/hooks/use-mobile";
-import { cn } from "@/lib/utils";
-
-const SIDEBAR_COOKIE_NAME = "sidebar_state";
-const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
-const SIDEBAR_WIDTH = "220px";
-const SIDEBAR_WIDTH_MOBILE = "220px";
-const SIDEBAR_WIDTH_ICON = "59px";
-const SIDEBAR_KEYBOARD_SHORTCUT = "b";
+} from '@/components/ui/sheet'
+import { Skeleton } from '@/components/ui/skeleton'
+import { Slot } from '@/components/ui/slot'
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
+import { useIsMobile } from '@/hooks/use-mobile'
+import { cn } from '@/lib/utils'
+
+const SIDEBAR_COOKIE_NAME = 'sidebar_state'
+const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
+const SIDEBAR_WIDTH = '220px'
+const SIDEBAR_WIDTH_MOBILE = '220px'
+const SIDEBAR_WIDTH_ICON = '59px'
+const SIDEBAR_KEYBOARD_SHORTCUT = 'b'
type SidebarContextProps = {
- state: "expanded" | "collapsed";
- open: boolean;
- setOpen: (open: boolean) => void;
- openMobile: boolean;
- setOpenMobile: (open: boolean) => void;
- isMobile: boolean;
- toggleSidebar: () => void;
-};
+ state: 'expanded' | 'collapsed'
+ open: boolean
+ setOpen: (open: boolean) => void
+ openMobile: boolean
+ setOpenMobile: (open: boolean) => void
+ isMobile: boolean
+ toggleSidebar: () => void
+}
-const SidebarContext = React.createContext<SidebarContextProps | null>(null);
+const SidebarContext = React.createContext<SidebarContextProps | null>(null)
function useSidebar() {
- const context = React.useContext(SidebarContext);
+ const context = React.useContext(SidebarContext)
if (!context) {
- throw new Error("useSidebar must be used within a SidebarProvider.");
+ throw new Error('useSidebar must be used within a SidebarProvider.')
}
- return context;
+ return context
}
function SidebarProvider({
@@ -57,61 +53,58 @@ function SidebarProvider({
style,
children,
...props
-}: React.ComponentProps<"div"> & {
- defaultOpen?: boolean;
- open?: boolean;
- onOpenChange?: (open: boolean) => void;
+}: React.ComponentProps<'div'> & {
+ defaultOpen?: boolean
+ open?: boolean
+ onOpenChange?: (open: boolean) => void
}) {
- const isMobile = useIsMobile();
- const [openMobile, setOpenMobile] = React.useState(false);
+ const isMobile = useIsMobile()
+ const [openMobile, setOpenMobile] = React.useState(false)
// Read persisted sidebar state from cookie, fall back to defaultOpen.
const [_open, _setOpen] = React.useState(() => {
- if (typeof document === 'undefined') return defaultOpen;
- const match = document.cookie.match(new RegExp(`(?:^|; )${SIDEBAR_COOKIE_NAME}=([^;]*)`));
- if (match) return match[1] === 'true';
- return defaultOpen;
- });
- const open = openProp ?? _open;
+ if (typeof document === 'undefined') return defaultOpen
+ const match = document.cookie.match(new RegExp(`(?:^|; )${SIDEBAR_COOKIE_NAME}=([^;]*)`))
+ if (match) return match[1] === 'true'
+ return defaultOpen
+ })
+ const open = openProp ?? _open
const setOpen = React.useCallback(
(value: boolean | ((value: boolean) => boolean)) => {
- const openState = typeof value === "function" ? value(open) : value;
+ const openState = typeof value === 'function' ? value(open) : value
if (setOpenProp) {
- setOpenProp(openState);
+ setOpenProp(openState)
} else {
- _setOpen(openState);
+ _setOpen(openState)
}
// This sets the cookie to keep the sidebar state.
- document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
},
[setOpenProp, open],
- );
+ )
// Helper to toggle the sidebar.
const toggleSidebar = React.useCallback(() => {
- return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
- }, [isMobile, setOpen, setOpenMobile]);
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
+ }, [isMobile, setOpen, setOpenMobile])
// Adds a keyboard shortcut to toggle the sidebar.
React.useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
- if (
- event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
- (event.metaKey || event.ctrlKey)
- ) {
- event.preventDefault();
- toggleSidebar();
+ if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
+ event.preventDefault()
+ toggleSidebar()
}
- };
+ }
- window.addEventListener("keydown", handleKeyDown);
- return () => window.removeEventListener("keydown", handleKeyDown);
- }, [toggleSidebar]);
+ window.addEventListener('keydown', handleKeyDown)
+ return () => window.removeEventListener('keydown', handleKeyDown)
+ }, [toggleSidebar])
// We add a state so that we can do data-state="expanded" or "collapsed".
// This makes it easier to style the sidebar with Tailwind classes.
- const state = open ? "expanded" : "collapsed";
+ const state = open ? 'expanded' : 'collapsed'
const contextValue = React.useMemo<SidebarContextProps>(
() => ({
@@ -124,7 +117,7 @@ function SidebarProvider({
toggleSidebar,
}),
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
- );
+ )
return (
<SidebarContext.Provider value={contextValue}>
@@ -132,13 +125,13 @@ function SidebarProvider({
data-slot="sidebar-wrapper"
style={
{
- "--sidebar-width": SIDEBAR_WIDTH,
- "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
+ '--sidebar-width': SIDEBAR_WIDTH,
+ '--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
...style,
} as React.CSSProperties
}
className={cn(
- "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
+ 'group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar',
className,
)}
{...props}
@@ -146,37 +139,37 @@ function SidebarProvider({
{children}
</div>
</SidebarContext.Provider>
- );
+ )
}
function Sidebar({
- side = "left",
- variant = "sidebar",
- collapsible = "offcanvas",
+ side = 'left',
+ variant = 'sidebar',
+ collapsible = 'offcanvas',
className,
children,
dir,
...props
-}: React.ComponentProps<"div"> & {
- side?: "left" | "right";
- variant?: "sidebar" | "floating" | "inset";
- collapsible?: "offcanvas" | "icon" | "none";
+}: React.ComponentProps<'div'> & {
+ side?: 'left' | 'right'
+ variant?: 'sidebar' | 'floating' | 'inset'
+ collapsible?: 'offcanvas' | 'icon' | 'none'
}) {
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
- if (collapsible === "none") {
+ if (collapsible === 'none') {
return (
<div
data-slot="sidebar"
className={cn(
- "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
+ 'flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground',
className,
)}
{...props}
>
{children}
</div>
- );
+ )
}
if (isMobile) {
@@ -190,7 +183,7 @@ function Sidebar({
className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
style={
{
- "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
+ '--sidebar-width': SIDEBAR_WIDTH_MOBILE,
} as React.CSSProperties
}
side={side}
@@ -202,14 +195,14 @@ function Sidebar({
<div className="flex h-full w-full flex-col">{children}</div>
</SheetContent>
</Sheet>
- );
+ )
}
return (
<div
className="group peer hidden text-sidebar-foreground md:block"
data-state={state}
- data-collapsible={state === "collapsed" ? collapsible : ""}
+ data-collapsible={state === 'collapsed' ? collapsible : ''}
data-variant={variant}
data-side={side}
data-slot="sidebar"
@@ -218,23 +211,23 @@ function Sidebar({
<div
data-slot="sidebar-gap"
className={cn(
- "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
- "group-data-[collapsible=offcanvas]:w-0",
- "group-data-[side=right]:rotate-180",
- variant === "floating" || variant === "inset"
- ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
- : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
+ 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',
+ 'group-data-[collapsible=offcanvas]:w-0',
+ 'group-data-[side=right]:rotate-180',
+ variant === 'floating' || variant === 'inset'
+ ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',
)}
/>
<div
data-slot="sidebar-container"
data-side={side}
className={cn(
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
+ 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex',
// Adjust the padding for floating and inset variants.
- variant === "floating" || variant === "inset"
- ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
- : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
+ variant === 'floating' || variant === 'inset'
+ ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',
className,
)}
{...props}
@@ -248,15 +241,11 @@ function Sidebar({
</div>
</div>
</div>
- );
+ )
}
-function SidebarTrigger({
- className,
- onClick,
- ...props
-}: React.ComponentProps<typeof Button>) {
- const { toggleSidebar } = useSidebar();
+function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
+ const { toggleSidebar } = useSidebar()
return (
<Button
@@ -266,19 +255,19 @@ function SidebarTrigger({
size="icon-sm"
className={cn(className)}
onClick={(event) => {
- onClick?.(event);
- toggleSidebar();
+ onClick?.(event)
+ toggleSidebar()
}}
{...props}
>
<PanelLeftIcon />
<span className="sr-only">Toggle Sidebar</span>
</Button>
- );
+ )
}
-function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
- const { toggleSidebar } = useSidebar();
+function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
+ const { toggleSidebar } = useSidebar()
return (
<button
@@ -289,229 +278,223 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
onClick={toggleSidebar}
title="Toggle Sidebar"
className={cn(
- "absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
- "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
- "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
+ 'absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2',
+ 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
+ '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
+ 'group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar',
+ '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
+ '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
className,
)}
{...props}
/>
- );
+ )
}
-function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
+function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
return (
<main
data-slot="sidebar-inset"
className={cn(
- "relative z-0 flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
+ 'relative z-0 flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2',
className,
)}
{...props}
/>
- );
+ )
}
-function SidebarInput({
- className,
- ...props
-}: React.ComponentProps<typeof Input>) {
+function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
return (
<Input
data-slot="sidebar-input"
data-sidebar="input"
- className={cn("h-8 w-full bg-background shadow-none", className)}
+ className={cn('h-8 w-full bg-background shadow-none', className)}
{...props}
/>
- );
+ )
}
-function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
+function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-header"
data-sidebar="header"
className={cn(
- "flex flex-col gap-0 px-2 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center",
+ 'flex flex-col gap-0 px-2 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center',
className,
)}
{...props}
/>
- );
+ )
}
-function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
+function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-footer"
data-sidebar="footer"
className={cn(
- "flex flex-col gap-0 p-2 mt-auto border-t border-sidebar-border group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center",
+ 'flex flex-col gap-0 p-2 mt-auto border-t border-sidebar-border group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center',
className,
)}
{...props}
/>
- );
+ )
}
-function SidebarSeparator({
- className,
- ...props
-}: React.ComponentProps<typeof Separator>) {
+function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
return (
<Separator
data-slot="sidebar-separator"
data-sidebar="separator"
- className={cn("mx-2 w-auto bg-sidebar-border", className)}
+ className={cn('mx-2 w-auto bg-sidebar-border', className)}
{...props}
/>
- );
+ )
}
-function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
+function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-content"
data-sidebar="content"
className={cn(
- "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 pt-2 overflow-auto group-data-[collapsible=icon]:overflow-visible",
+ 'no-scrollbar flex min-h-0 flex-1 flex-col gap-0 pt-2 overflow-auto group-data-[collapsible=icon]:overflow-visible',
className,
)}
{...props}
/>
- );
+ )
}
-function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
+function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-group"
data-sidebar="group"
className={cn(
- "relative flex w-full min-w-0 flex-col px-3 py-0 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center",
+ 'relative flex w-full min-w-0 flex-col px-3 py-0 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center',
className,
)}
{...props}
/>
- );
+ )
}
function SidebarGroupLabel({
className,
asChild = false,
...props
-}: React.ComponentProps<"div"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "div";
+}: React.ComponentProps<'div'> & { asChild?: boolean }) {
+ const Comp = asChild ? Slot : 'div'
return (
<Comp
data-slot="sidebar-group-label"
data-sidebar="group-label"
className={cn(
- "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
+ 'flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
className,
)}
{...props}
/>
- );
+ )
}
function SidebarGroupAction({
className,
asChild = false,
...props
-}: React.ComponentProps<"button"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot : "button";
+}: React.ComponentProps<'button'> & { asChild?: boolean }) {
+ const Comp = asChild ? Slot : 'button'
return (
<Comp
data-slot="sidebar-group-action"
data-sidebar="group-action"
className={cn(
- "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
+ 'absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',
className,
)}
{...props}
/>
- );
+ )
}
-function SidebarGroupContent({
- className,
- ...props
-}: React.ComponentProps<"div">) {
+function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-group-content"
data-sidebar="group-content"
- className={cn("w-full text-sm", className)}
+ className={cn('w-full text-sm', className)}
{...props}
/>
- );
+ )
}
-function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
+function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {
return (
<ul
data-slot="sidebar-menu"
data-sidebar="menu"
- className={cn("flex w-full min-w-0 flex-col gap-1 group-data-[collapsible=icon]:items-center", className)}
+ className={cn(
+ 'flex w-full min-w-0 flex-col gap-1 group-data-[collapsible=icon]:items-center',
+ className,
+ )}
{...props}
/>
- );
+ )
}
-function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
+function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
return (
<li
data-slot="sidebar-menu-item"
data-sidebar="menu-item"
- className={cn("group/menu-item relative", className)}
+ className={cn('group/menu-item relative', className)}
{...props}
/>
- );
+ )
}
const sidebarMenuButtonVariants = cva(
- "peer/menu-button group/menu-button flex gap-2 w-full items-center overflow-hidden rounded-xl p-1 text-left text-base text-gray-800 ring-sidebar-ring outline-hidden transition-colors duration-100 ease-in-out group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-10! group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:overflow-visible group-data-[collapsible=icon]:p-0! group-data-[collapsible=icon]:gap-0 group-data-[collapsible=icon]:[&>span:last-child]:hidden group-data-[collapsible=icon]:data-active:bg-transparent group-data-[collapsible=icon]:data-active:shadow-none hover:bg-gray-200/50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-gray-200/50 data-open:hover:text-zinc-950 data-active:bg-white data-active:text-zinc-950 data-active:font-semibold data-active:shadow-nav [&>span:last-child]:truncate",
+ 'peer/menu-button group/menu-button flex gap-2 w-full items-center overflow-hidden rounded-xl p-1 text-left text-base text-gray-800 ring-sidebar-ring outline-hidden transition-colors duration-100 ease-in-out group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-10! group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:overflow-visible group-data-[collapsible=icon]:p-0! group-data-[collapsible=icon]:gap-0 group-data-[collapsible=icon]:[&>span:last-child]:hidden group-data-[collapsible=icon]:data-active:bg-transparent group-data-[collapsible=icon]:data-active:shadow-none hover:bg-gray-200/50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-gray-200/50 data-open:hover:text-zinc-950 data-active:bg-white data-active:text-zinc-950 data-active:font-semibold data-active:shadow-nav [&>span:last-child]:truncate',
{
variants: {
variant: {
- default: "",
+ default: '',
outline:
- "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
+ 'bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]',
},
size: {
- default: "h-8 text-base",
- sm: "h-7 text-xs",
- lg: "h-12 text-base group-data-[collapsible=icon]:p-0!",
+ default: 'h-8 text-base',
+ sm: 'h-7 text-xs',
+ lg: 'h-12 text-base group-data-[collapsible=icon]:p-0!',
},
},
defaultVariants: {
- variant: "default",
- size: "default",
+ variant: 'default',
+ size: 'default',
},
},
-);
+)
function SidebarMenuButton({
asChild = false,
isActive = false,
- variant = "default",
- size = "default",
+ variant = 'default',
+ size = 'default',
tooltip,
className,
...props
-}: React.ComponentProps<"button"> & {
- asChild?: boolean;
- isActive?: boolean;
- tooltip?: string | React.ComponentProps<typeof TooltipContent>;
+}: React.ComponentProps<'button'> & {
+ asChild?: boolean
+ isActive?: boolean
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>
} & VariantProps<typeof sidebarMenuButtonVariants>) {
- const Comp = asChild ? Slot : "button";
- const { isMobile, state } = useSidebar();
+ const Comp = asChild ? Slot : 'button'
+ const { isMobile, state } = useSidebar()
const button = (
<Comp
@@ -522,16 +505,16 @@ function SidebarMenuButton({
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
{...props}
/>
- );
+ )
if (!tooltip) {
- return button;
+ return button
}
- if (typeof tooltip === "string") {
+ if (typeof tooltip === 'string') {
tooltip = {
children: tooltip,
- };
+ }
}
return (
@@ -540,11 +523,11 @@ function SidebarMenuButton({
<TooltipContent
side="right"
align="center"
- hidden={state !== "collapsed" || isMobile}
+ hidden={state !== 'collapsed' || isMobile}
{...tooltip}
/>
</Tooltip>
- );
+ )
}
function SidebarMenuAction({
@@ -552,122 +535,111 @@ function SidebarMenuAction({
asChild = false,
showOnHover = false,
...props
-}: React.ComponentProps<"button"> & {
- asChild?: boolean;
- showOnHover?: boolean;
+}: React.ComponentProps<'button'> & {
+ asChild?: boolean
+ showOnHover?: boolean
}) {
- const Comp = asChild ? Slot : "button";
+ const Comp = asChild ? Slot : 'button'
return (
<Comp
data-slot="sidebar-menu-action"
data-sidebar="menu-action"
className={cn(
- "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
+ 'absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',
showOnHover &&
- "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
+ 'group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0',
className,
)}
{...props}
/>
- );
+ )
}
-function SidebarMenuBadge({
- className,
- ...props
-}: React.ComponentProps<"div">) {
+function SidebarMenuBadge({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-menu-badge"
data-sidebar="menu-badge"
className={cn(
- "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
+ 'pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground',
className,
)}
{...props}
/>
- );
+ )
}
function SidebarMenuSkeleton({
className,
showIcon = false,
...props
-}: React.ComponentProps<"div"> & {
- showIcon?: boolean;
+}: React.ComponentProps<'div'> & {
+ showIcon?: boolean
}) {
// Random width between 50 to 90%.
const [width] = React.useState(() => {
- return `${Math.floor(Math.random() * 40) + 50}%`;
- });
+ return `${Math.floor(Math.random() * 40) + 50}%`
+ })
return (
<div
data-slot="sidebar-menu-skeleton"
data-sidebar="menu-skeleton"
- className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
+ className={cn('flex h-8 items-center gap-2 rounded-md px-2', className)}
{...props}
>
- {showIcon && (
- <Skeleton
- className="size-4 rounded-md"
- data-sidebar="menu-skeleton-icon"
- />
- )}
+ {showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
<Skeleton
className="h-4 max-w-(--skeleton-width) flex-1"
data-sidebar="menu-skeleton-text"
style={
{
- "--skeleton-width": width,
+ '--skeleton-width': width,
} as React.CSSProperties
}
/>
</div>
- );
+ )
}
-function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
+function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
return (
<ul
data-slot="sidebar-menu-sub"
data-sidebar="menu-sub"
className={cn(
- "relative ml-4 flex min-w-0 flex-col pt-1 pl-4 group-data-[collapsible=icon]:hidden before:absolute before:left-0 before:top-0 before:bottom-1 before:w-px before:bg-gray-200",
+ 'relative ml-4 flex min-w-0 flex-col pt-1 pl-4 group-data-[collapsible=icon]:hidden before:absolute before:left-0 before:top-0 before:bottom-1 before:w-px before:bg-gray-200',
className,
)}
{...props}
/>
- );
+ )
}
-function SidebarMenuSubItem({
- className,
- ...props
-}: React.ComponentProps<"li">) {
+function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) {
return (
<li
data-slot="sidebar-menu-sub-item"
data-sidebar="menu-sub-item"
- className={cn("group/menu-sub-item relative", className)}
+ className={cn('group/menu-sub-item relative', className)}
{...props}
/>
- );
+ )
}
function SidebarMenuSubButton({
asChild = false,
- size = "md",
+ size = 'md',
isActive = false,
className,
...props
-}: React.ComponentProps<"a"> & {
- asChild?: boolean;
- size?: "sm" | "md";
- isActive?: boolean;
+}: React.ComponentProps<'a'> & {
+ asChild?: boolean
+ size?: 'sm' | 'md'
+ isActive?: boolean
}) {
- const Comp = asChild ? Slot : "a";
+ const Comp = asChild ? Slot : 'a'
return (
<Comp
@@ -676,12 +648,12 @@ function SidebarMenuSubButton({
data-size={size}
data-active={isActive}
className={cn(
- "relative flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-xl p-1 text-gray-800 ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-gray-50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-base data-[size=sm]:text-xs data-active:font-semibold data-active:text-zinc-950 data-active:bg-transparent data-active:shadow-none data-active:before:absolute data-active:before:-left-4 data-active:before:top-[10%] data-active:before:h-[80%] data-active:before:w-[3px] data-active:before:rounded-sm data-active:before:bg-zinc-950 data-active:hover:bg-white [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
+ 'relative flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-xl p-1 text-gray-800 ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-gray-50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-base data-[size=sm]:text-xs data-active:font-semibold data-active:text-zinc-950 data-active:bg-transparent data-active:shadow-none data-active:before:absolute data-active:before:-left-4 data-active:before:top-[10%] data-active:before:h-[80%] data-active:before:w-[3px] data-active:before:rounded-sm data-active:before:bg-zinc-950 data-active:hover:bg-white [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
className,
)}
{...props}
/>
- );
+ )
}
export {
@@ -709,4 +681,4 @@ export {
SidebarSeparator,
SidebarTrigger,
useSidebar,
-};
+}
diff --git a/packages/admin/src/components/ui/textarea.tsx b/packages/admin/src/components/ui/textarea.tsx
index 326e509da6..997b5f93a2 100644
--- a/packages/admin/src/components/ui/textarea.tsx
+++ b/packages/admin/src/components/ui/textarea.tsx
@@ -1,14 +1,14 @@
-import * as React from "react"
+import * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
-function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
+function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
return (
<textarea
data-slot="textarea"
className={cn(
- "flex field-sizing-content min-h-16 w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-base font-normal leading-normal text-gray-950 shadow-xs transition-all duration-100 ease-in-out outline-none placeholder:text-gray-500 focus:border-blue-500 focus:shadow-[0_0_0_3px_rgba(59,130,246,0.15)] disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-gray-50 disabled:border-gray-100 disabled:text-gray-600 disabled:shadow-none aria-invalid:border-destructive",
- className
+ 'flex field-sizing-content min-h-16 w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-base font-normal leading-normal text-gray-950 shadow-xs transition-all duration-100 ease-in-out outline-none placeholder:text-gray-500 focus:border-blue-500 focus:shadow-[0_0_0_3px_rgba(59,130,246,0.15)] disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-gray-50 disabled:border-gray-100 disabled:text-gray-600 disabled:shadow-none aria-invalid:border-destructive',
+ className,
)}
{...props}
/>
diff --git a/packages/admin/src/components/ui/tooltip.tsx b/packages/admin/src/components/ui/tooltip.tsx
index 8979debda8..f46d414302 100644
--- a/packages/admin/src/components/ui/tooltip.tsx
+++ b/packages/admin/src/components/ui/tooltip.tsx
@@ -14,11 +14,7 @@ function TooltipProvider({
children: React.ReactNode
} & Omit<React.ComponentProps<typeof TooltipPrimitive.Provider>, 'delay'>) {
return (
- <TooltipPrimitive.Provider
- data-slot="tooltip-provider"
- delay={delayDuration}
- {...props}
- >
+ <TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delayDuration} {...props}>
{children}
</TooltipPrimitive.Provider>
)
@@ -48,13 +44,7 @@ function TooltipTrigger({
asChild?: boolean
}) {
if (asChild && React.isValidElement(children)) {
- return (
- <TooltipPrimitive.Trigger
- data-slot="tooltip-trigger"
- render={children}
- {...props}
- />
- )
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" render={children} {...props} />
}
return (
diff --git a/packages/admin/src/hooks/use-categories.ts b/packages/admin/src/hooks/use-categories.ts
index f6538ec350..f86ed3f1fe 100644
--- a/packages/admin/src/hooks/use-categories.ts
+++ b/packages/admin/src/hooks/use-categories.ts
@@ -4,8 +4,7 @@ import { adminClient } from '@/client'
export function useCategories() {
return useQuery({
queryKey: ['categories'],
- queryFn: () =>
- adminClient.categories.list({ limit: 100 }),
+ queryFn: () => adminClient.categories.list({ limit: 100 }),
staleTime: 1000 * 60 * 5,
})
}
diff --git a/packages/admin/src/hooks/use-direct-upload.ts b/packages/admin/src/hooks/use-direct-upload.ts
index 01d269af40..2f017f0684 100644
--- a/packages/admin/src/hooks/use-direct-upload.ts
+++ b/packages/admin/src/hooks/use-direct-upload.ts
@@ -45,7 +45,10 @@ export function useDirectUpload() {
const checksum = await computeMD5Checksum(file)
// Step 1: Get presigned upload URL
- let response: { direct_upload: { url: string; headers: Record<string, string> }; signed_id: string }
+ let response: {
+ direct_upload: { url: string; headers: Record<string, string> }
+ signed_id: string
+ }
try {
response = await adminClient.directUploads.create({
blob: {
diff --git a/packages/admin/src/hooks/use-product-media.ts b/packages/admin/src/hooks/use-product-media.ts
index 3581704e2b..ecc5bedc34 100644
--- a/packages/admin/src/hooks/use-product-media.ts
+++ b/packages/admin/src/hooks/use-product-media.ts
@@ -1,4 +1,4 @@
-import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { adminClient } from '@/client'
export function useProductMedia(productId: string) {
@@ -38,8 +38,7 @@ export function useDeleteProductMedia(productId: string) {
const queryClient = useQueryClient()
return useMutation({
- mutationFn: (id: string) =>
- adminClient.products.media.delete(productId, id),
+ mutationFn: (id: string) => adminClient.products.media.delete(productId, id),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['products', productId, 'media'] })
queryClient.invalidateQueries({ queryKey: ['products', productId] })
diff --git a/packages/admin/src/hooks/use-product.ts b/packages/admin/src/hooks/use-product.ts
index f25096935d..eea796bf2a 100644
--- a/packages/admin/src/hooks/use-product.ts
+++ b/packages/admin/src/hooks/use-product.ts
@@ -1,4 +1,4 @@
-import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { adminClient } from '@/client'
export function useProduct(id: string) {
diff --git a/packages/admin/src/providers/auth-provider.tsx b/packages/admin/src/providers/auth-provider.tsx
index b504626f35..bbf525a82a 100644
--- a/packages/admin/src/providers/auth-provider.tsx
+++ b/packages/admin/src/providers/auth-provider.tsx
@@ -53,14 +53,17 @@ export function AuthProvider({ children }: { children: ReactNode }) {
clearRefreshTimer()
}, [clearRefreshTimer])
- const storeTokens = useCallback((accessToken: string, refreshToken: string, authUser: AuthUser) => {
- adminClient.setToken(accessToken)
- setToken(accessToken)
- setUser(authUser)
- localStorage.setItem(TOKEN_KEY, accessToken)
- localStorage.setItem(REFRESH_TOKEN_KEY, refreshToken)
- localStorage.setItem(USER_KEY, JSON.stringify(authUser))
- }, [])
+ const storeTokens = useCallback(
+ (accessToken: string, refreshToken: string, authUser: AuthUser) => {
+ adminClient.setToken(accessToken)
+ setToken(accessToken)
+ setUser(authUser)
+ localStorage.setItem(TOKEN_KEY, accessToken)
+ localStorage.setItem(REFRESH_TOKEN_KEY, refreshToken)
+ localStorage.setItem(USER_KEY, JSON.stringify(authUser))
+ },
+ [],
+ )
const doRefresh = useCallback(async (): Promise<boolean> => {
const refreshToken = localStorage.getItem(REFRESH_TOKEN_KEY)
@@ -97,16 +100,19 @@ export function AuthProvider({ children }: { children: ReactNode }) {
}, REFRESH_INTERVAL_MS)
}, [refreshAccessToken, clearRefreshTimer])
- const login = useCallback(async (email: string, password: string) => {
- setIsLoading(true)
- try {
- const response = await adminClient.auth.login({ email, password })
- storeTokens(response.token, response.refresh_token!, response.user)
- scheduleRefresh()
- } finally {
- setIsLoading(false)
- }
- }, [storeTokens, scheduleRefresh])
+ const login = useCallback(
+ async (email: string, password: string) => {
+ setIsLoading(true)
+ try {
+ const response = await adminClient.auth.login({ email, password })
+ storeTokens(response.token, response.refresh_token!, response.user)
+ scheduleRefresh()
+ } finally {
+ setIsLoading(false)
+ }
+ },
+ [storeTokens, scheduleRefresh],
+ )
const logout = useCallback(() => {
clearTokens()
diff --git a/packages/admin/src/providers/store-provider.tsx b/packages/admin/src/providers/store-provider.tsx
index 399aaac82c..313d4b6025 100644
--- a/packages/admin/src/providers/store-provider.tsx
+++ b/packages/admin/src/providers/store-provider.tsx
@@ -1,5 +1,5 @@
-import { createContext, type ReactNode, useCallback, useContext, useEffect, useState } from 'react'
import type { Store } from '@spree/admin-sdk'
+import { createContext, type ReactNode, useCallback, useContext, useEffect, useState } from 'react'
import { adminClient } from '@/client'
interface StoreContextValue {
@@ -19,6 +19,7 @@ export function StoreProvider({ storeId, children }: { storeId: string; children
const [store, setStore] = useState<Store | null>(null)
const [isLoading, setIsLoading] = useState(true)
+ // biome-ignore lint/correctness/useExhaustiveDependencies: adminClient resolves the store from the route's storeId, so we must refetch when it changes
const fetchStore = useCallback(async () => {
setIsLoading(true)
try {
@@ -29,11 +30,11 @@ export function StoreProvider({ storeId, children }: { storeId: string; children
} finally {
setIsLoading(false)
}
- }, [])
+ }, [storeId])
useEffect(() => {
fetchStore()
- }, [storeId, fetchStore])
+ }, [fetchStore])
const currencies = store?.supported_currencies ?? []
const locales = store?.supported_locales ?? []
@@ -41,7 +42,18 @@ export function StoreProvider({ storeId, children }: { storeId: string; children
const defaultLocale = store?.default_locale ?? 'en'
return (
- <StoreContext.Provider value={{ store, storeId, isLoading, currencies, locales, defaultCurrency, defaultLocale, refetch: fetchStore }}>
+ <StoreContext.Provider
+ value={{
+ store,
+ storeId,
+ isLoading,
+ currencies,
+ locales,
+ defaultCurrency,
+ defaultLocale,
+ refetch: fetchStore,
+ }}
+ >
{children}
</StoreContext.Provider>
)
diff --git a/packages/admin/src/routes/_authenticated/$storeId/customers/$customerId.tsx b/packages/admin/src/routes/_authenticated/$storeId/customers/$customerId.tsx
index 25418b6a86..4e76659654 100644
--- a/packages/admin/src/routes/_authenticated/$storeId/customers/$customerId.tsx
+++ b/packages/admin/src/routes/_authenticated/$storeId/customers/$customerId.tsx
@@ -12,12 +12,10 @@ import {
} from 'lucide-react'
import { type FormEvent, useState } from 'react'
import { adminClient } from '@/client'
-import { useAuth } from '@/hooks/use-auth'
import { AddressFormDialog, type AddressParams } from '@/components/address-form-dialog'
import { BackButton } from '@/components/back-button'
import { useConfirm } from '@/components/confirm-dialog'
import { TagCombobox } from '@/components/tag-combobox'
-import { useCountries } from '@/hooks/use-countries'
import { Badge, StatusBadge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Card, CardAction, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
@@ -39,6 +37,8 @@ import {
import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
import { Input } from '@/components/ui/input'
import { Textarea } from '@/components/ui/textarea'
+import { useAuth } from '@/hooks/use-auth'
+import { useCountries } from '@/hooks/use-countries'
import { formatRelativeTime } from '@/lib/formatters'
export const Route = createFileRoute('/_authenticated/$storeId/customers/$customerId')({
@@ -49,7 +49,8 @@ function useCustomer(customerId: string) {
const { isAuthenticated } = useAuth()
return useQuery({
queryKey: ['customer', customerId],
- queryFn: () => adminClient.customers.get(customerId, { expand: ['addresses', 'store_credits'] }),
+ queryFn: () =>
+ adminClient.customers.get(customerId, { expand: ['addresses', 'store_credits'] }),
enabled: isAuthenticated,
})
}
@@ -70,7 +71,8 @@ function CustomerDetailPage() {
const { data: customer, isLoading, error } = useCustomer(customerId)
if (isLoading) return <p className="text-muted-foreground">Loading customer…</p>
- if (error || !customer) return <p className="text-destructive">Failed to load customer {customerId}.</p>
+ if (error || !customer)
+ return <p className="text-destructive">Failed to load customer {customerId}.</p>
const defaultShipping = customer.addresses?.find((a) => a.is_default_shipping)
const location = [defaultShipping?.city, defaultShipping?.country_iso].filter(Boolean).join(', ')
@@ -80,8 +82,12 @@ function CustomerDetailPage() {
<div className="flex items-center gap-3">
<BackButton fallback="customers" />
<h1 className="text-2xl font-medium">{customer.full_name}</h1>
- {location && <span className="text-base font-normal text-muted-foreground">{location}</span>}
- {customer.tags?.map((tag) => <Badge key={tag}>{tag}</Badge>)}
+ {location && (
+ <span className="text-base font-normal text-muted-foreground">{location}</span>
+ )}
+ {customer.tags?.map((tag) => (
+ <Badge key={tag}>{tag}</Badge>
+ ))}
</div>
<LifetimeStatsCard customer={customer} />
@@ -101,7 +107,12 @@ function CustomerBody({ customer }: { customer: Customer }) {
<div className="grid grid-cols-12 gap-6">
<div className="col-span-12 lg:col-span-8 flex flex-col gap-6">
{lastCompletedOrder && <LastOrderCard order={lastCompletedOrder} />}
- <OrdersCard customer={customer} orders={orders} totalCount={totalCount} isLoading={isLoading} />
+ <OrdersCard
+ customer={customer}
+ orders={orders}
+ totalCount={totalCount}
+ isLoading={isLoading}
+ />
<StoreCreditsCard customer={customer} />
</div>
@@ -146,7 +157,11 @@ function ProfileCard({ customer }: { customer: Customer }) {
)}
<div className="flex items-center gap-2 text-sm">
<StarIcon className="size-4 text-muted-foreground" />
- <span>{customer.accepts_email_marketing ? 'Subscribed to marketing' : 'Not subscribed to marketing'}</span>
+ <span>
+ {customer.accepts_email_marketing
+ ? 'Subscribed to marketing'
+ : 'Not subscribed to marketing'}
+ </span>
</div>
{customer.created_at && (
<div className="text-xs text-muted-foreground">
@@ -171,7 +186,10 @@ function EditProfileDialog({
}) {
const [tags, setTags] = useState<string[]>(customer.tags ?? [])
const mutation = useCustomerMutation(customer.id, (params: Record<string, unknown>) =>
- adminClient.customers.update(customer.id, params as Parameters<typeof adminClient.customers.update>[1]),
+ adminClient.customers.update(
+ customer.id,
+ params as Parameters<typeof adminClient.customers.update>[1],
+ ),
)
function handleSubmit(e: FormEvent<HTMLFormElement>) {
@@ -200,7 +218,13 @@ function EditProfileDialog({
<FieldGroup>
<Field>
<FieldLabel htmlFor="email">Email</FieldLabel>
- <Input id="email" name="email" type="email" defaultValue={customer.email} required />
+ <Input
+ id="email"
+ name="email"
+ type="email"
+ defaultValue={customer.email}
+ required
+ />
</Field>
<Field>
<FieldLabel htmlFor="first_name">First name</FieldLabel>
@@ -220,14 +244,20 @@ function EditProfileDialog({
</Field>
<Field>
<label className="flex items-center gap-2 text-sm">
- <input type="checkbox" name="accepts_email_marketing" defaultChecked={customer.accepts_email_marketing} />
+ <input
+ type="checkbox"
+ name="accepts_email_marketing"
+ defaultChecked={customer.accepts_email_marketing}
+ />
Subscribed to marketing
</label>
</Field>
</FieldGroup>
</DialogBody>
<DialogFooter>
- <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
+ <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
+ Cancel
+ </Button>
<Button type="submit" disabled={mutation.isPending}>
{mutation.isPending ? 'Saving…' : 'Save'}
</Button>
@@ -246,9 +276,10 @@ function LifetimeStatsCard({ customer }: { customer: Customer }) {
const orders = customer.orders_count ?? 0
const totalSpent = Number(customer.total_spent ?? '0')
const aov = orders > 0 ? totalSpent / orders : 0
- const aovDisplay = orders > 0 && totalSpent > 0
- ? customer.display_total_spent?.replace(/[\d.,]+/, aov.toFixed(2))
- : '—'
+ const aovDisplay =
+ orders > 0 && totalSpent > 0
+ ? customer.display_total_spent?.replace(/[\d.,]+/, aov.toFixed(2))
+ : '—'
return (
<Card>
@@ -301,7 +332,7 @@ function LastOrderCard({ order }: { order: Order }) {
<div className="border-t flex items-center justify-between px-6 py-3">
<div>
<Link
- to={"/$storeId/orders/$orderId" as string}
+ to={'/$storeId/orders/$orderId' as string}
params={{ orderId: order.id }}
className="font-medium text-zinc-950 no-underline"
>
@@ -312,7 +343,9 @@ function LastOrderCard({ order }: { order: Order }) {
{order.fulfillment_status && <StatusBadge status={order.fulfillment_status} />}
</span>
{order.completed_at && (
- <div className="text-xs text-muted-foreground mt-1">{formatRelativeTime(order.completed_at)}</div>
+ <div className="text-xs text-muted-foreground mt-1">
+ {formatRelativeTime(order.completed_at)}
+ </div>
)}
</div>
<div className="font-semibold">{order.display_total}</div>
@@ -355,8 +388,12 @@ function OrdersCard({
if (isLoading) {
return (
<Card>
- <CardHeader><CardTitle>Orders</CardTitle></CardHeader>
- <CardContent><p className="text-sm text-muted-foreground">Loading orders…</p></CardContent>
+ <CardHeader>
+ <CardTitle>Orders</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <p className="text-sm text-muted-foreground">Loading orders…</p>
+ </CardContent>
</Card>
)
}
@@ -371,8 +408,10 @@ function OrdersCard({
{totalCount > orders.length && (
<CardAction>
<Link
- to={"/$storeId/orders" as string}
- search={{ filters: [{ id: '1', field: 'user_id_eq', operator: 'eq', value: customer.id }] }}
+ to={'/$storeId/orders' as string}
+ search={{
+ filters: [{ id: '1', field: 'user_id_eq', operator: 'eq', value: customer.id }],
+ }}
className="text-sm text-primary hover:underline"
>
View all →
@@ -400,7 +439,7 @@ function OrdersCard({
<tr key={order.id} className="border-b last:border-b-0">
<td className="px-6 py-3">
<Link
- to={"/$storeId/orders/$orderId" as string}
+ to={'/$storeId/orders/$orderId' as string}
params={{ orderId: order.id }}
className="font-medium text-zinc-950 no-underline"
>
@@ -414,10 +453,14 @@ function OrdersCard({
<span className="inline-flex gap-1">
<StatusBadge status={order.status} />
{order.payment_status && <StatusBadge status={order.payment_status} />}
- {order.fulfillment_status && <StatusBadge status={order.fulfillment_status} />}
+ {order.fulfillment_status && (
+ <StatusBadge status={order.fulfillment_status} />
+ )}
</span>
</td>
- <td className="px-6 py-3 text-right font-medium tabular-nums">{order.display_total}</td>
+ <td className="px-6 py-3 text-right font-medium tabular-nums">
+ {order.display_total}
+ </td>
</tr>
))}
</tbody>
@@ -463,21 +506,35 @@ function InternalNoteCard({ customer }: { customer: Customer }) {
placeholder="Staff-only notes about this customer…"
/>
<div className="flex gap-2 justify-end">
- <Button type="button" variant="outline" size="sm" onClick={() => { setEditing(false); setNote(customer.internal_note_html ?? '') }}>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => {
+ setEditing(false)
+ setNote(customer.internal_note_html ?? '')
+ }}
+ >
Cancel
</Button>
<Button
type="button"
size="sm"
disabled={mutation.isPending}
- onClick={() => mutation.mutate({ internal_note: note }, { onSuccess: () => setEditing(false) })}
+ onClick={() =>
+ mutation.mutate({ internal_note: note }, { onSuccess: () => setEditing(false) })
+ }
>
{mutation.isPending ? 'Saving…' : 'Save'}
</Button>
</div>
</div>
) : customer.internal_note_html ? (
- <div className="text-sm prose-sm" dangerouslySetInnerHTML={{ __html: customer.internal_note_html }} />
+ <div
+ className="text-sm prose-sm"
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: HTML is sanitized server-side via the rich-text pipeline
+ dangerouslySetInnerHTML={{ __html: customer.internal_note_html }}
+ />
) : (
<p className="text-sm text-muted-foreground">No internal notes</p>
)}
@@ -495,7 +552,9 @@ function AddressesCard({ customer }: { customer: Customer }) {
const [editing, setEditing] = useState<Address | null>(null)
const confirm = useConfirm()
const isDefault = (a: Address) => a.is_default_billing || a.is_default_shipping
- const addresses = [...(customer.addresses ?? [])].sort((a, b) => Number(isDefault(b)) - Number(isDefault(a)))
+ const addresses = [...(customer.addresses ?? [])].sort(
+ (a, b) => Number(isDefault(b)) - Number(isDefault(a)),
+ )
const deleteMutation = useCustomerMutation(customer.id, (id: string) =>
adminClient.customers.addresses.delete(customer.id, id),
@@ -531,10 +590,15 @@ function AddressesCard({ customer }: { customer: Customer }) {
) : (
<CardContent className="flex flex-col gap-3">
{addresses.map((addr) => (
- <div key={addr.id} className="flex items-start justify-between gap-2 rounded-md border p-3">
+ <div
+ key={addr.id}
+ className="flex items-start justify-between gap-2 rounded-md border p-3"
+ >
<div className="text-sm">
<div className="font-medium">
- {[addr.first_name, addr.last_name].filter(Boolean).join(' ').trim() || addr.label || '—'}
+ {[addr.first_name, addr.last_name].filter(Boolean).join(' ').trim() ||
+ addr.label ||
+ '—'}
<span className="ml-2 inline-flex gap-1">
{addr.is_default_billing && <Badge variant="info">Default billing</Badge>}
{addr.is_default_shipping && <Badge variant="info">Default shipping</Badge>}
@@ -543,7 +607,8 @@ function AddressesCard({ customer }: { customer: Customer }) {
<div className="text-muted-foreground">{addr.address1}</div>
{addr.address2 && <div className="text-muted-foreground">{addr.address2}</div>}
<div className="text-muted-foreground">
- {[addr.city, addr.state_abbr, addr.postal_code].filter(Boolean).join(', ')} · {addr.country_iso}
+ {[addr.city, addr.state_abbr, addr.postal_code].filter(Boolean).join(', ')} ·{' '}
+ {addr.country_iso}
</div>
{addr.phone && <div className="text-muted-foreground">{addr.phone}</div>}
</div>
@@ -559,19 +624,29 @@ function AddressesCard({ customer }: { customer: Customer }) {
Edit
</DropdownMenuItem>
{!addr.is_default_billing && (
- <DropdownMenuItem onClick={() => setDefaultMutation.mutate({ id: addr.id, kind: 'billing' })}>
+ <DropdownMenuItem
+ onClick={() => setDefaultMutation.mutate({ id: addr.id, kind: 'billing' })}
+ >
Set as default billing
</DropdownMenuItem>
)}
{!addr.is_default_shipping && (
- <DropdownMenuItem onClick={() => setDefaultMutation.mutate({ id: addr.id, kind: 'shipping' })}>
+ <DropdownMenuItem
+ onClick={() => setDefaultMutation.mutate({ id: addr.id, kind: 'shipping' })}
+ >
Set as default shipping
</DropdownMenuItem>
)}
<DropdownMenuItem
className="text-destructive focus:text-destructive"
onClick={async () => {
- if (await confirm({ message: 'Delete this address?', variant: 'destructive', confirmLabel: 'Delete' })) {
+ if (
+ await confirm({
+ message: 'Delete this address?',
+ variant: 'destructive',
+ confirmLabel: 'Delete',
+ })
+ ) {
deleteMutation.mutate(addr.id)
}
}}
@@ -599,7 +674,9 @@ function AddressesCard({ customer }: { customer: Customer }) {
<CustomerAddressDialog
customer={customer}
address={editing}
- onOpenChange={(o) => { if (!o) setEditing(null) }}
+ onOpenChange={(o) => {
+ if (!o) setEditing(null)
+ }}
title="Edit Address"
/>
)}
@@ -714,7 +791,13 @@ function StoreCreditsCard({ customer }: { customer: Customer }) {
<DropdownMenuItem
className="text-destructive focus:text-destructive"
onClick={async () => {
- if (await confirm({ message: 'Delete this store credit?', variant: 'destructive', confirmLabel: 'Delete' })) {
+ if (
+ await confirm({
+ message: 'Delete this store credit?',
+ variant: 'destructive',
+ confirmLabel: 'Delete',
+ })
+ ) {
deleteMutation.mutate(sc.id)
}
}}
@@ -747,19 +830,24 @@ function IssueStoreCreditDialog({
open: boolean
onOpenChange: (open: boolean) => void
}) {
- const mutation = useCustomerMutation(customerId, (params: Parameters<typeof adminClient.customers.storeCredits.create>[1]) =>
- adminClient.customers.storeCredits.create(customerId, params),
+ const mutation = useCustomerMutation(
+ customerId,
+ (params: Parameters<typeof adminClient.customers.storeCredits.create>[1]) =>
+ adminClient.customers.storeCredits.create(customerId, params),
)
function handleSubmit(e: FormEvent<HTMLFormElement>) {
e.preventDefault()
const fd = new FormData(e.currentTarget)
- mutation.mutate({
- amount: Number(fd.get('amount')),
- currency: String(fd.get('currency') ?? ''),
- category_id: String(fd.get('category_id') ?? ''),
- memo: (fd.get('memo') as string) || undefined,
- }, { onSuccess: () => onOpenChange(false) })
+ mutation.mutate(
+ {
+ amount: Number(fd.get('amount')),
+ currency: String(fd.get('currency') ?? ''),
+ category_id: String(fd.get('category_id') ?? ''),
+ memo: (fd.get('memo') as string) || undefined,
+ },
+ { onSuccess: () => onOpenChange(false) },
+ )
}
return (
@@ -788,12 +876,19 @@ function IssueStoreCreditDialog({
</Field>
<Field>
<FieldLabel htmlFor="sc-memo">Memo</FieldLabel>
- <Textarea id="sc-memo" name="memo" rows={3} placeholder="Reason for issuing this credit" />
+ <Textarea
+ id="sc-memo"
+ name="memo"
+ rows={3}
+ placeholder="Reason for issuing this credit"
+ />
</Field>
</FieldGroup>
</DialogBody>
<DialogFooter>
- <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
+ <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
+ Cancel
+ </Button>
<Button type="submit" disabled={mutation.isPending}>
{mutation.isPending ? 'Issuing…' : 'Issue Credit'}
</Button>
diff --git a/packages/admin/src/routes/_authenticated/$storeId/index.tsx b/packages/admin/src/routes/_authenticated/$storeId/index.tsx
index bd7d8bf2d2..bd62054dc8 100644
--- a/packages/admin/src/routes/_authenticated/$storeId/index.tsx
+++ b/packages/admin/src/routes/_authenticated/$storeId/index.tsx
@@ -1,26 +1,20 @@
-import { createFileRoute, Link } from '@tanstack/react-router'
+import type { DashboardAnalytics } from '@spree/admin-sdk'
import { useQuery } from '@tanstack/react-query'
-import { useState } from 'react'
+import { createFileRoute, Link } from '@tanstack/react-router'
import { subDays } from 'date-fns'
-import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts'
import { PackageIcon } from 'lucide-react'
+import { useState } from 'react'
+import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts'
import { adminClient } from '@/client'
-import { DateRangePicker, type DateRange } from '@/components/date-range-picker'
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from '@/components/ui/card'
+import { type DateRange, DateRangePicker } from '@/components/date-range-picker'
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import {
+ type ChartConfig,
ChartContainer,
ChartTooltip,
ChartTooltipContent,
- type ChartConfig,
} from '@/components/ui/chart'
import { Skeleton } from '@/components/ui/skeleton'
-import type { DashboardAnalytics } from '@spree/admin-sdk'
export const Route = createFileRoute('/_authenticated/$storeId/')({
component: DashboardPage,
@@ -100,9 +94,7 @@ function AnalyticsChart({ data }: { data: DashboardAnalytics }) {
type="button"
onClick={() => setActiveMetric(tab.key)}
className={`relative flex flex-1 flex-col justify-center gap-1 px-6 py-4 text-left ${
- activeMetric === tab.key
- ? 'bg-muted/50'
- : 'hover:bg-muted/25'
+ activeMetric === tab.key ? 'bg-muted/50' : 'hover:bg-muted/25'
} sm:border-l sm:first:border-l-0`}
>
<span className="text-xs text-muted-foreground">{tab.label}</span>
@@ -114,7 +106,10 @@ function AnalyticsChart({ data }: { data: DashboardAnalytics }) {
))}
</CardHeader>
<CardContent className="px-2 pt-4 sm:px-6 sm:pt-6">
- <ChartContainer config={chartConfigs[activeMetric]} className="aspect-auto h-[250px] w-full">
+ <ChartContainer
+ config={chartConfigs[activeMetric]}
+ className="aspect-auto h-[250px] w-full"
+ >
<BarChart data={data.chart_data}>
<CartesianGrid vertical={false} />
<XAxis
@@ -156,11 +151,7 @@ function AnalyticsChart({ data }: { data: DashboardAnalytics }) {
)
}
-function TopProducts({
- products,
-}: {
- products: DashboardAnalytics['top_products']
-}) {
+function TopProducts({ products }: { products: DashboardAnalytics['top_products'] }) {
if (products.length === 0) {
return null
}
@@ -230,8 +221,11 @@ function DashboardSkeleton() {
</div>
<Card>
<CardHeader className="flex h-auto flex-col border-b p-0 sm:flex-row">
- {Array.from({ length: 3 }).map((_, i) => (
- <div key={i} className="flex flex-1 flex-col gap-2 px-6 py-4 sm:border-l sm:first:border-l-0">
+ {['stat-1', 'stat-2', 'stat-3'].map((key) => (
+ <div
+ key={key}
+ className="flex flex-1 flex-col gap-2 px-6 py-4 sm:border-l sm:first:border-l-0"
+ >
<Skeleton className="h-3 w-20" />
<Skeleton className="h-7 w-28" />
</div>
@@ -248,8 +242,8 @@ function DashboardSkeleton() {
</CardHeader>
<CardContent className="p-0">
<div className="flex flex-col">
- {Array.from({ length: 5 }).map((_, i) => (
- <div key={i} className="flex items-center gap-3 border-b px-4 py-3 last:border-0">
+ {['row-1', 'row-2', 'row-3', 'row-4', 'row-5'].map((key) => (
+ <div key={key} className="flex items-center gap-3 border-b px-4 py-3 last:border-0">
<Skeleton className="size-10 rounded-md" />
<Skeleton className="h-4 w-32 flex-1" />
<Skeleton className="h-4 w-16" />
diff --git a/packages/admin/src/routes/_authenticated/$storeId/orders/$orderId.tsx b/packages/admin/src/routes/_authenticated/$storeId/orders/$orderId.tsx
index 0f2a976eb0..67326f0ed8 100644
--- a/packages/admin/src/routes/_authenticated/$storeId/orders/$orderId.tsx
+++ b/packages/admin/src/routes/_authenticated/$storeId/orders/$orderId.tsx
@@ -1,9 +1,6 @@
import type { Order, Variant } from '@spree/admin-sdk'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { createFileRoute } from '@tanstack/react-router'
-import { AddressBlock } from '@/components/address-block'
-import { AddressFormDialog, type AddressParams } from '@/components/address-form-dialog'
-import { BackButton } from '@/components/back-button'
import {
CheckCircleIcon,
CreditCardIcon,
@@ -22,10 +19,12 @@ import {
XCircleIcon,
} from 'lucide-react'
import { type FormEvent, useEffect, useState } from 'react'
+import { adminClient } from '@/client'
+import { AddressBlock } from '@/components/address-block'
+import { AddressFormDialog, type AddressParams } from '@/components/address-form-dialog'
+import { BackButton } from '@/components/back-button'
import { useConfirm } from '@/components/confirm-dialog'
import { TagCombobox } from '@/components/tag-combobox'
-import { adminClient } from '@/client'
-import { formatRelativeTime } from '@/lib/formatters'
import { Badge, StatusBadge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Card, CardAction, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
@@ -45,6 +44,16 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
+import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
+import { Input } from '@/components/ui/input'
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select'
+import { Separator } from '@/components/ui/separator'
import {
Sheet,
SheetContent,
@@ -53,14 +62,11 @@ import {
SheetHeader,
SheetTitle,
} from '@/components/ui/sheet'
-import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
-import { Input } from '@/components/ui/input'
-import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
-import { Separator } from '@/components/ui/separator'
-import { Switch } from '@/components/ui/switch'
import { Skeleton } from '@/components/ui/skeleton'
+import { Switch } from '@/components/ui/switch'
import { Textarea } from '@/components/ui/textarea'
import { useAuth } from '@/hooks/use-auth'
+import { formatRelativeTime } from '@/lib/formatters'
import { cn } from '@/lib/utils'
export const Route = createFileRoute('/_authenticated/$storeId/orders/$orderId')({
@@ -124,7 +130,6 @@ function formatDate(iso: string | null) {
})
}
-
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
@@ -172,18 +177,10 @@ function OrderHeader({ order }: { order: Order }) {
const backFallback = order.completed_at ? 'orders' : 'orders/drafts'
- const cancelMutation = useOrderMutation(orderId, () =>
- adminClient.orders.cancel(orderId),
- )
- const completeMutation = useOrderMutation(orderId, () =>
- adminClient.orders.complete(orderId),
- )
- const approveMutation = useOrderMutation(orderId, () =>
- adminClient.orders.approve(orderId),
- )
- const resumeMutation = useOrderMutation(orderId, () =>
- adminClient.orders.resume(orderId),
- )
+ const cancelMutation = useOrderMutation(orderId, () => adminClient.orders.cancel(orderId))
+ const completeMutation = useOrderMutation(orderId, () => adminClient.orders.complete(orderId))
+ const approveMutation = useOrderMutation(orderId, () => adminClient.orders.approve(orderId))
+ const resumeMutation = useOrderMutation(orderId, () => adminClient.orders.resume(orderId))
const resendMutation = useOrderMutation(orderId, () =>
adminClient.orders.resendConfirmation(orderId, {}),
)
@@ -214,7 +211,12 @@ function OrderHeader({ order }: { order: Order }) {
{order.status === 'draft' && (
<DropdownMenuItem
onClick={async () => {
- if (await confirm({ message: 'Complete this draft order now?', confirmLabel: 'Complete' })) {
+ if (
+ await confirm({
+ message: 'Complete this draft order now?',
+ confirmLabel: 'Complete',
+ })
+ ) {
completeMutation.mutate(undefined)
}
}}
@@ -240,7 +242,12 @@ function OrderHeader({ order }: { order: Order }) {
{order.status === 'canceled' && (
<DropdownMenuItem
onClick={async () => {
- if (await confirm({ message: 'Resume this canceled order?', confirmLabel: 'Resume' })) {
+ if (
+ await confirm({
+ message: 'Resume this canceled order?',
+ confirmLabel: 'Resume',
+ })
+ ) {
resumeMutation.mutate(undefined)
}
}}
@@ -270,7 +277,13 @@ function OrderHeader({ order }: { order: Order }) {
<DropdownMenuItem
className="text-destructive focus:text-destructive"
onClick={async () => {
- if (await confirm({ message: 'Are you sure you want to cancel this order?', variant: 'destructive', confirmLabel: 'Cancel Order' })) {
+ if (
+ await confirm({
+ message: 'Are you sure you want to cancel this order?',
+ variant: 'destructive',
+ confirmLabel: 'Cancel Order',
+ })
+ ) {
cancelMutation.mutate(undefined)
}
}}
@@ -388,9 +401,13 @@ function AddLineItemDialog({
{selectedVariant && (
<div className="rounded-lg border border-blue-200 bg-blue-50 p-3 flex items-center justify-between">
<div>
- <div className="font-medium text-sm">{selectedVariant.product_name ?? selectedVariant.sku}</div>
+ <div className="font-medium text-sm">
+ {selectedVariant.product_name ?? selectedVariant.sku}
+ </div>
<div className="text-xs text-muted-foreground">
- {selectedVariant.options_text && <span>{selectedVariant.options_text} · </span>}
+ {selectedVariant.options_text && (
+ <span>{selectedVariant.options_text} · </span>
+ )}
SKU: {selectedVariant.sku || '—'} · {selectedVariant.display_price ?? ''}
</div>
</div>
@@ -443,7 +460,6 @@ function EditQuantityDialog({
open: boolean
onOpenChange: (open: boolean) => void
}) {
-
const mutation = useOrderMutation(orderId, (params: { quantity: number }) =>
adminClient.orders.items.update(orderId, lineItemId, params),
)
@@ -567,7 +583,9 @@ function LineItemsCard({ order }: { order: Order }) {
{item.display_additional_tax_total}
</td>
<td className="p-3 text-right whitespace-nowrap">
- {Number.parseFloat(item.discount_total) !== 0 ? item.display_discount_total : '—'}
+ {Number.parseFloat(item.discount_total) !== 0
+ ? item.display_discount_total
+ : '—'}
</td>
<td className="p-3 text-right font-medium whitespace-nowrap">
{item.display_total}
@@ -590,7 +608,13 @@ function LineItemsCard({ order }: { order: Order }) {
<DropdownMenuItem
className="text-destructive focus:text-destructive"
onClick={async () => {
- if (await confirm({ message: 'Remove this item from the order?', variant: 'destructive', confirmLabel: 'Remove' })) {
+ if (
+ await confirm({
+ message: 'Remove this item from the order?',
+ variant: 'destructive',
+ confirmLabel: 'Remove',
+ })
+ ) {
deleteMutation.mutate(item.id)
}
}}
@@ -645,7 +669,6 @@ function EditTrackingDialog({
open: boolean
onOpenChange: (open: boolean) => void
}) {
-
const mutation = useOrderMutation(orderId, (params: { tracking: string }) =>
adminClient.orders.fulfillments.update(orderId, fulfillmentId, params),
)
@@ -747,7 +770,13 @@ function ShipmentsCard({ order }: { order: Order }) {
{fulfillment.status === 'ready' && (
<DropdownMenuItem
onClick={async () => {
- if (await confirm({ message: 'Ship this fulfillment?', variant: 'default', confirmLabel: 'Fulfill' })) {
+ if (
+ await confirm({
+ message: 'Ship this fulfillment?',
+ variant: 'default',
+ confirmLabel: 'Fulfill',
+ })
+ ) {
fulfillMutation.mutate(fulfillment.id)
}
}}
@@ -762,7 +791,13 @@ function ShipmentsCard({ order }: { order: Order }) {
<DropdownMenuItem
className="text-destructive focus:text-destructive"
onClick={async () => {
- if (await confirm({ message: 'Cancel this fulfillment?', variant: 'destructive', confirmLabel: 'Cancel Fulfillment' })) {
+ if (
+ await confirm({
+ message: 'Cancel this fulfillment?',
+ variant: 'destructive',
+ confirmLabel: 'Cancel Fulfillment',
+ })
+ ) {
cancelFulfillmentMutation.mutate(fulfillment.id)
}
}}
@@ -810,7 +845,8 @@ function ShipmentsCard({ order }: { order: Order }) {
{fulfillment.fulfilled_at && (
<span className="text-xs text-muted-foreground">
- Shipped {fulfillment.fulfilled_at ? formatRelativeTime(fulfillment.fulfilled_at) : ''}
+ Shipped{' '}
+ {fulfillment.fulfilled_at ? formatRelativeTime(fulfillment.fulfilled_at) : ''}
</span>
)}
</div>
@@ -870,75 +906,89 @@ function PaymentsCard({ order }: { order: Order }) {
<p className="text-center text-muted-foreground py-8">No payments yet</p>
</CardContent>
) : (
- <div className="overflow-x-auto">
- <table className="w-full text-sm">
- <thead>
- <tr className="border-b bg-muted/50 text-muted-foreground">
- <th className="p-3 pl-5 text-left font-normal">Number</th>
- <th className="p-3 text-left font-normal">Method</th>
- <th className="p-3 text-left font-normal">State</th>
- <th className="p-3 text-right font-normal">Amount</th>
- <th className="p-3 pr-5 w-10" />
- </tr>
- </thead>
- <tbody>
- {payments.map((payment) => (
- <tr key={payment.id} className="border-b last:border-b-0">
- <td className="p-3 pl-5 font-medium">{payment.number}</td>
- <td className="p-3 text-muted-foreground">{payment.payment_method?.name ?? '—'}</td>
- <td className="p-3">
- <StatusBadge status={payment.status} />
- </td>
- <td className="p-3 text-right font-medium whitespace-nowrap">
- {payment.display_amount}
- </td>
- <td className="p-3 pr-5">
- {(payment.status === 'checkout' ||
- payment.status === 'pending' ||
- payment.status === 'completed') && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="icon-xs">
- <EllipsisVerticalIcon className="size-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- {(payment.status === 'checkout' || payment.status === 'pending') && (
- <DropdownMenuItem
- onClick={async () => {
- if (await confirm({ message: 'Capture this payment?', variant: 'default', confirmLabel: 'Capture' })) {
- captureMutation.mutate(payment.id)
- }
- }}
- >
- <CreditCardIcon className="size-4" />
- Capture
- </DropdownMenuItem>
- )}
- {(payment.status === 'checkout' ||
- payment.status === 'pending' ||
- payment.status === 'completed') && (
- <DropdownMenuItem
- className="text-destructive focus:text-destructive"
- onClick={async () => {
- if (await confirm({ message: 'Void this payment?', variant: 'destructive', confirmLabel: 'Void Payment' })) {
- voidMutation.mutate(payment.id)
- }
- }}
- >
- <XCircleIcon className="size-4" />
- Void
- </DropdownMenuItem>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </td>
+ <div className="overflow-x-auto">
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b bg-muted/50 text-muted-foreground">
+ <th className="p-3 pl-5 text-left font-normal">Number</th>
+ <th className="p-3 text-left font-normal">Method</th>
+ <th className="p-3 text-left font-normal">State</th>
+ <th className="p-3 text-right font-normal">Amount</th>
+ <th className="p-3 pr-5 w-10" />
</tr>
- ))}
- </tbody>
- </table>
- </div>
+ </thead>
+ <tbody>
+ {payments.map((payment) => (
+ <tr key={payment.id} className="border-b last:border-b-0">
+ <td className="p-3 pl-5 font-medium">{payment.number}</td>
+ <td className="p-3 text-muted-foreground">
+ {payment.payment_method?.name ?? '—'}
+ </td>
+ <td className="p-3">
+ <StatusBadge status={payment.status} />
+ </td>
+ <td className="p-3 text-right font-medium whitespace-nowrap">
+ {payment.display_amount}
+ </td>
+ <td className="p-3 pr-5">
+ {(payment.status === 'checkout' ||
+ payment.status === 'pending' ||
+ payment.status === 'completed') && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="icon-xs">
+ <EllipsisVerticalIcon className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {(payment.status === 'checkout' || payment.status === 'pending') && (
+ <DropdownMenuItem
+ onClick={async () => {
+ if (
+ await confirm({
+ message: 'Capture this payment?',
+ variant: 'default',
+ confirmLabel: 'Capture',
+ })
+ ) {
+ captureMutation.mutate(payment.id)
+ }
+ }}
+ >
+ <CreditCardIcon className="size-4" />
+ Capture
+ </DropdownMenuItem>
+ )}
+ {(payment.status === 'checkout' ||
+ payment.status === 'pending' ||
+ payment.status === 'completed') && (
+ <DropdownMenuItem
+ className="text-destructive focus:text-destructive"
+ onClick={async () => {
+ if (
+ await confirm({
+ message: 'Void this payment?',
+ variant: 'destructive',
+ confirmLabel: 'Void Payment',
+ })
+ ) {
+ voidMutation.mutate(payment.id)
+ }
+ }}
+ >
+ <XCircleIcon className="size-4" />
+ Void
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
)}
<AddPaymentDialog order={order} open={addOpen} onOpenChange={setAddOpen} />
</Card>
@@ -978,7 +1028,10 @@ function AddPaymentDialog({
const { data: cardsData } = useQuery({
queryKey: ['customer-credit-cards', customerId],
- queryFn: () => customerId ? adminClient.customers.creditCards.list(customerId, { limit: 50 }) : Promise.resolve(null),
+ queryFn: () =>
+ customerId
+ ? adminClient.customers.creditCards.list(customerId, { limit: 50 })
+ : Promise.resolve(null),
enabled: open && Boolean(customerId) && sourceRequired,
staleTime: 30_000,
})
@@ -1030,19 +1083,26 @@ function AddPaymentDialog({
<DialogContent>
<DialogHeader>
<DialogTitle>Add Payment</DialogTitle>
- <DialogDescription>
- Charge a payment method against this order.
- </DialogDescription>
+ <DialogDescription>Charge a payment method against this order.</DialogDescription>
</DialogHeader>
<form onSubmit={handleSubmit}>
<DialogBody>
<FieldGroup>
<Field>
<FieldLabel htmlFor="pay-method">Payment method</FieldLabel>
- <Select value={paymentMethodId} onValueChange={(v) => { setPaymentMethodId(v); setSourceId('') }}>
+ <Select
+ value={paymentMethodId}
+ onValueChange={(v) => {
+ setPaymentMethodId(v)
+ setSourceId('')
+ }}
+ >
<SelectTrigger id="pay-method">
<SelectValue placeholder="Choose a payment method...">
- {(value) => paymentMethods.find((m) => m.id === value)?.name ?? 'Choose a payment method...'}
+ {(value) =>
+ paymentMethods.find((m) => m.id === value)?.name ??
+ 'Choose a payment method...'
+ }
</SelectValue>
</SelectTrigger>
<SelectContent>
@@ -1060,7 +1120,8 @@ function AddPaymentDialog({
<FieldLabel htmlFor="pay-source">Source</FieldLabel>
{!customerId ? (
<p className="text-sm text-destructive">
- This payment method requires a saved source. Assign a customer to the order first.
+ This payment method requires a saved source. Assign a customer to the order
+ first.
</p>
) : savedCards.length === 0 ? (
<p className="text-sm text-muted-foreground">
@@ -1072,7 +1133,9 @@ function AddPaymentDialog({
<SelectValue placeholder="Choose a saved card…">
{(value) => {
const card = savedCards.find((c) => c.id === value)
- return card ? `${card.brand} •••• ${card.last4} (${card.month}/${card.year})` : 'Choose a saved card…'
+ return card
+ ? `${card.brand} •••• ${card.last4} (${card.month}/${card.year})`
+ : 'Choose a saved card…'
}}
</SelectValue>
</SelectTrigger>
@@ -1099,13 +1162,14 @@ function AddPaymentDialog({
onChange={(e) => setAmount(e.target.value)}
/>
<p className="text-xs text-muted-foreground mt-1">
- Leave blank to default to the outstanding balance ({order.display_amount_due ?? '$0.00'}).
+ Leave blank to default to the outstanding balance (
+ {order.display_amount_due ?? '$0.00'}).
</p>
</Field>
<Field>
- <label className="flex items-center gap-2 text-sm">
- <Switch checked={capture} onCheckedChange={setCapture} />
+ <label className="flex items-center gap-2 text-sm" htmlFor="pay-capture">
+ <Switch id="pay-capture" checked={capture} onCheckedChange={setCapture} />
Capture immediately
</label>
</Field>
@@ -1115,7 +1179,10 @@ function AddPaymentDialog({
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
Cancel
</Button>
- <Button type="submit" disabled={!canSubmit || mutation.isPending || captureMutation.isPending}>
+ <Button
+ type="submit"
+ disabled={!canSubmit || mutation.isPending || captureMutation.isPending}
+ >
{mutation.isPending || captureMutation.isPending ? 'Processing…' : 'Add Payment'}
</Button>
</DialogFooter>
@@ -1154,7 +1221,9 @@ function SummaryRow({
)
}
-function customerDisplayName(customer?: { first_name: string | null; last_name: string | null; email: string } | null): string {
+function customerDisplayName(
+ customer?: { first_name: string | null; last_name: string | null; email: string } | null,
+): string {
if (!customer) return '—'
const name = [customer.first_name, customer.last_name].filter(Boolean).join(' ').trim()
return name || customer.email
@@ -1287,7 +1356,12 @@ function DiscountsCard({ order }: { order: Order }) {
size="sm"
variant="outline"
onClick={async () => {
- if (await confirm({ message: 'Remove this gift card from the order?', confirmLabel: 'Remove' })) {
+ if (
+ await confirm({
+ message: 'Remove this gift card from the order?',
+ confirmLabel: 'Remove',
+ })
+ ) {
removeGiftCardMutation.mutate(undefined)
}
}}
@@ -1324,7 +1398,12 @@ function DiscountsCard({ order }: { order: Order }) {
size="sm"
variant="outline"
onClick={async () => {
- if (await confirm({ message: 'Remove store credit from the order?', confirmLabel: 'Remove' })) {
+ if (
+ await confirm({
+ message: 'Remove store credit from the order?',
+ confirmLabel: 'Remove',
+ })
+ ) {
removeStoreCreditMutation.mutate(undefined)
}
}}
@@ -1385,7 +1464,13 @@ function ApplyGiftCardDialog({
<FieldGroup>
<Field>
<FieldLabel htmlFor="gift-card-code">Code</FieldLabel>
- <Input id="gift-card-code" name="code" placeholder="GIFT-XXXX-YYYY" required autoFocus />
+ <Input
+ id="gift-card-code"
+ name="code"
+ placeholder="GIFT-XXXX-YYYY"
+ required
+ autoFocus
+ />
</Field>
</FieldGroup>
</DialogBody>
@@ -1411,18 +1496,23 @@ function CustomerCard({ order }: { order: Order }) {
const { orderId } = Route.useParams()
const queryClient = useQueryClient()
const user = order.customer
- const [editAddress, setEditAddress] = useState<'shipping_address' | 'billing_address' | null>(null)
+ const [editAddress, setEditAddress] = useState<'shipping_address' | 'billing_address' | null>(
+ null,
+ )
const addressMutation = useMutation({
- mutationFn: (params: { type: 'shipping_address' | 'billing_address'; address: AddressParams }) =>
- adminClient.orders.update(orderId, { [params.type]: params.address } as any),
+ mutationFn: (params: {
+ type: 'shipping_address' | 'billing_address'
+ address: AddressParams
+ }) => adminClient.orders.update(orderId, { [params.type]: params.address } as any),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['order', orderId] })
setEditAddress(null)
},
})
- const editTitle = editAddress === 'shipping_address' ? 'Edit Shipping Address' : 'Edit Billing Address'
+ const editTitle =
+ editAddress === 'shipping_address' ? 'Edit Shipping Address' : 'Edit Billing Address'
return (
<>
@@ -1481,7 +1571,9 @@ function CustomerCard({ order }: { order: Order }) {
{editAddress && (
<AddressFormDialog
title={editTitle}
- address={editAddress === 'shipping_address' ? order.shipping_address : order.billing_address}
+ address={
+ editAddress === 'shipping_address' ? order.shipping_address : order.billing_address
+ }
open={!!editAddress}
onOpenChange={(open) => !open && setEditAddress(null)}
onSave={(address) => addressMutation.mutate({ type: editAddress, address })}
@@ -1537,9 +1629,7 @@ function SpecialInstructionsCard({ order }: { order: Order }) {
</div>
</form>
) : order.customer_note ? (
- <p className="text-sm text-muted-foreground whitespace-pre-wrap">
- {order.customer_note}
- </p>
+ <p className="text-sm text-muted-foreground whitespace-pre-wrap">{order.customer_note}</p>
) : (
<p className="text-sm text-muted-foreground">None</p>
)}
@@ -1566,10 +1656,14 @@ function TagsCard({ order }: { order: Order }) {
<CardHeader>
<CardTitle>Tags</CardTitle>
<CardAction>
- <Button variant="ghost" size="icon-xs" onClick={() => {
- setTags(order.tags ?? [])
- setEditing(!editing)
- }}>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => {
+ setTags(order.tags ?? [])
+ setEditing(!editing)
+ }}
+ >
<PencilIcon className="size-4" />
</Button>
</CardAction>
@@ -1594,7 +1688,9 @@ function TagsCard({ order }: { order: Order }) {
</div>
) : order.tags?.length ? (
<div className="flex flex-wrap gap-1">
- {order.tags.map((tag) => <Badge key={tag}>{tag}</Badge>)}
+ {order.tags.map((tag) => (
+ <Badge key={tag}>{tag}</Badge>
+ ))}
</div>
) : (
<p className="text-sm text-muted-foreground">None</p>
diff --git a/packages/admin/src/routes/_authenticated/$storeId/orders/new.tsx b/packages/admin/src/routes/_authenticated/$storeId/orders/new.tsx
index 80c268565d..0c0088fc08 100644
--- a/packages/admin/src/routes/_authenticated/$storeId/orders/new.tsx
+++ b/packages/admin/src/routes/_authenticated/$storeId/orders/new.tsx
@@ -1,6 +1,7 @@
import type { Customer, Variant } from '@spree/admin-sdk'
import { useMutation, useQuery } from '@tanstack/react-query'
import { createFileRoute, useNavigate } from '@tanstack/react-router'
+import { TrashIcon, XIcon } from 'lucide-react'
import { type FormEvent, useState } from 'react'
import { adminClient } from '@/client'
import { BackButton } from '@/components/back-button'
@@ -10,7 +11,6 @@ import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
import { Input } from '@/components/ui/input'
import { Switch } from '@/components/ui/switch'
import { Textarea } from '@/components/ui/textarea'
-import { TrashIcon, XIcon } from 'lucide-react'
export const Route = createFileRoute('/_authenticated/$storeId/orders/new')({
component: NewOrderPage,
@@ -85,7 +85,9 @@ function NewOrderPage() {
function addItem(variant: Variant) {
const existing = items.find((i) => i.variant.id === variant.id)
if (existing) {
- setItems(items.map((i) => i.variant.id === variant.id ? { ...i, quantity: i.quantity + 1 } : i))
+ setItems(
+ items.map((i) => (i.variant.id === variant.id ? { ...i, quantity: i.quantity + 1 } : i)),
+ )
} else {
setItems([...items, { variant, quantity: 1 }])
}
@@ -94,7 +96,7 @@ function NewOrderPage() {
function updateQuantity(variantId: string, quantity: number) {
if (quantity < 1) return
- setItems(items.map((i) => i.variant.id === variantId ? { ...i, quantity } : i))
+ setItems(items.map((i) => (i.variant.id === variantId ? { ...i, quantity } : i)))
}
function removeItem(variantId: string) {
@@ -126,7 +128,15 @@ function NewOrderPage() {
</div>
)}
</div>
- <Button type="button" size="sm" variant="outline" onClick={() => { setCustomer(null); setCustomerSearch('') }}>
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ onClick={() => {
+ setCustomer(null)
+ setCustomerSearch('')
+ }}
+ >
<XIcon className="size-4" />
Change
</Button>
@@ -146,7 +156,10 @@ function NewOrderPage() {
<button
key={c.id}
type="button"
- onClick={() => { setCustomer(c); setCustomerSearch('') }}
+ onClick={() => {
+ setCustomer(c)
+ setCustomerSearch('')
+ }}
className="block w-full px-3 py-2.5 text-left text-sm hover:bg-muted transition-colors border-b last:border-0"
>
<div className="font-medium">{c.email}</div>
@@ -175,7 +188,9 @@ function NewOrderPage() {
{customer && (
<div className="mt-4 flex items-center gap-3">
<Switch checked={useDefaultAddress} onCheckedChange={setUseDefaultAddress} />
- <span className="text-sm">Use customer's default billing & shipping addresses</span>
+ <span className="text-sm">
+ Use customer's default billing & shipping addresses
+ </span>
</div>
)}
</CardContent>
@@ -228,7 +243,9 @@ function NewOrderPage() {
<tbody>
{items.map(({ variant, quantity }) => (
<tr key={variant.id} className="border-b last:border-b-0">
- <td className="p-3 pl-5 font-medium">{variant.product_name ?? variant.sku ?? variant.id}</td>
+ <td className="p-3 pl-5 font-medium">
+ {variant.product_name ?? variant.sku ?? variant.id}
+ </td>
<td className="p-3 text-muted-foreground">{variant.sku}</td>
<td className="p-3 text-right">
<Input
@@ -240,7 +257,12 @@ function NewOrderPage() {
/>
</td>
<td className="p-3 pr-5 text-right">
- <Button type="button" size="icon-xs" variant="ghost" onClick={() => removeItem(variant.id)}>
+ <Button
+ type="button"
+ size="icon-xs"
+ variant="ghost"
+ onClick={() => removeItem(variant.id)}
+ >
<TrashIcon className="size-4" />
</Button>
</td>
@@ -263,7 +285,9 @@ function NewOrderPage() {
<CardContent>
<FieldGroup>
<Field>
- <FieldLabel htmlFor="customer-note">Customer note (visible to customer)</FieldLabel>
+ <FieldLabel htmlFor="customer-note">
+ Customer note (visible to customer)
+ </FieldLabel>
<Textarea
id="customer-note"
rows={3}
diff --git a/packages/admin/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/admin/src/routes/_authenticated/$storeId/products/$productId.tsx
index 328da23790..24b0eb2d09 100644
--- a/packages/admin/src/routes/_authenticated/$storeId/products/$productId.tsx
+++ b/packages/admin/src/routes/_authenticated/$storeId/products/$productId.tsx
@@ -1,4 +1,4 @@
-import type { Media, Product as BaseProduct, Variant as BaseVariant } from '@spree/admin-sdk'
+import type { Product as BaseProduct, Variant as BaseVariant, Media } from '@spree/admin-sdk'
// Extended types for fields not yet in generated types
type Variant = BaseVariant & {
@@ -12,27 +12,19 @@ type Product = Omit<BaseProduct, 'default_variant' | 'variants'> & {
default_variant?: Variant
variants?: Variant[]
}
+
import { zodResolver } from '@hookform/resolvers/zod'
import { createFileRoute, useRouter } from '@tanstack/react-router'
+import { ImagePlusIcon, Loader2Icon, SaveIcon, TrashIcon, XIcon } from 'lucide-react'
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import { Controller, type UseFormReturn, useForm } from 'react-hook-form'
+import { toast } from 'sonner'
import { BackButton } from '@/components/back-button'
import { useConfirm } from '@/components/confirm-dialog'
import { TagCombobox } from '@/components/tag-combobox'
-import {
- ImagePlusIcon,
- Loader2Icon,
- SaveIcon,
- TrashIcon,
- XIcon,
-} from 'lucide-react'
-import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
-import { Controller, useForm, type UseFormReturn } from 'react-hook-form'
-import { toast } from 'sonner'
import { StatusBadge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
-import { DatePicker } from '@/components/ui/date-picker'
-import { Input } from '@/components/ui/input'
-import { Field, FieldLabel } from '@/components/ui/field'
import {
Combobox,
ComboboxChip,
@@ -45,6 +37,9 @@ import {
ComboboxValue,
useComboboxAnchor,
} from '@/components/ui/combobox'
+import { DatePicker } from '@/components/ui/date-picker'
+import { Field, FieldLabel } from '@/components/ui/field'
+import { Input } from '@/components/ui/input'
import { RichTextEditor } from '@/components/ui/rich-text-editor'
import {
Select,
@@ -56,17 +51,17 @@ import {
import { Skeleton } from '@/components/ui/skeleton'
import { Switch } from '@/components/ui/switch'
import { Textarea } from '@/components/ui/textarea'
-import { useStore } from '@/providers/store-provider'
+import { useCategories } from '@/hooks/use-categories'
import { useDirectUpload } from '@/hooks/use-direct-upload'
-import { useProduct, useUpdateProduct, useDeleteProduct } from '@/hooks/use-product'
+import { useDeleteProduct, useProduct, useUpdateProduct } from '@/hooks/use-product'
import {
- useProductMedia,
useCreateProductMedia,
useDeleteProductMedia,
+ useProductMedia,
} from '@/hooks/use-product-media'
import { useTaxCategories } from '@/hooks/use-tax-categories'
-import { useCategories } from '@/hooks/use-categories'
-import { productFormSchema, type ProductFormValues } from '@/schemas/product'
+import { useStore } from '@/providers/store-provider'
+import { type ProductFormValues, productFormSchema } from '@/schemas/product'
export const Route = createFileRoute('/_authenticated/$storeId/products/$productId')({
component: ProductDetailPage,
@@ -166,12 +161,20 @@ function ProductForm({ product }: { product: Product }) {
}
const handleDelete = async () => {
- const confirmed = await confirm({ message: 'Are you sure you want to delete this product?', variant: 'destructive', confirmLabel: 'Delete' })
+ const confirmed = await confirm({
+ message: 'Are you sure you want to delete this product?',
+ variant: 'destructive',
+ confirmLabel: 'Delete',
+ })
if (!confirmed) return
try {
await deleteProduct.mutateAsync(productId)
toast.success('Product deleted')
- await router.navigate({ to: '/$storeId/products', params: { storeId }, search: { filters: [], columns: [] } })
+ await router.navigate({
+ to: '/$storeId/products',
+ params: { storeId },
+ search: { filters: [], columns: [] },
+ })
} catch {
toast.error('Failed to delete product')
}
@@ -199,7 +202,6 @@ function ProductForm({ product }: { product: Product }) {
</Button>
<Button
type="submit"
-
size="sm"
disabled={updateProduct.isPending || !form.formState.isDirty}
>
@@ -386,11 +388,7 @@ function MediaCard({ productId }: { productId: string }) {
key={upload.id}
className="relative aspect-square overflow-hidden rounded-lg border border-gray-200 bg-gray-50"
>
- <img
- src={upload.preview}
- alt=""
- className="size-full object-cover opacity-60"
- />
+ <img src={upload.preview} alt="" className="size-full object-cover opacity-60" />
<div className="absolute inset-0 flex items-center justify-center">
{upload.progress === 'error' ? (
<span className="text-xs text-destructive font-medium">Failed</span>
@@ -404,41 +402,31 @@ function MediaCard({ productId }: { productId: string }) {
)}
{/* Drop zone */}
- <div
+ <button
+ type="button"
onDrop={handleDrop}
onDragOver={handleDragOver}
- className="flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-gray-200 p-6 text-center transition-colors hover:border-gray-300 cursor-pointer"
+ className="flex w-full flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-gray-200 p-6 text-center transition-colors hover:border-gray-300 cursor-pointer"
onClick={() => fileInputRef.current?.click()}
- onKeyDown={(e) => e.key === 'Enter' && fileInputRef.current?.click()}
- role="button"
- tabIndex={0}
>
<ImagePlusIcon className="size-8 text-gray-400" />
- <p className="text-sm text-gray-600">
- Drag & drop images here, or click to browse
- </p>
+ <p className="text-sm text-gray-600">Drag & drop images here, or click to browse</p>
<p className="text-xs text-gray-400">PNG, JPG, WebP up to 10MB</p>
- <input
- ref={fileInputRef}
- type="file"
- accept="image/*"
- multiple
- className="hidden"
- onChange={(e) => e.target.files && handleFiles(e.target.files)}
- />
- </div>
+ </button>
+ <input
+ ref={fileInputRef}
+ type="file"
+ accept="image/*"
+ multiple
+ className="hidden"
+ onChange={(e) => e.target.files && handleFiles(e.target.files)}
+ />
</CardContent>
</Card>
)
}
-function MediaThumbnail({
- mediaItem,
- onDelete,
-}: {
- mediaItem: Media
- onDelete: () => void
-}) {
+function MediaThumbnail({ mediaItem, onDelete }: { mediaItem: Media; onDelete: () => void }) {
const imageUrl = mediaItem.small_url || mediaItem.mini_url || mediaItem.original_url
return (
@@ -479,14 +467,15 @@ function PricingCard({ form }: FormCardProps) {
<tr className="border-b text-left text-muted-foreground">
<th className="px-4 py-2 font-medium">Currency</th>
<th className="px-4 py-2 font-medium">Amount</th>
- <th className="px-4 py-2 font-medium">
- Compare at amount
- </th>
+ <th className="px-4 py-2 font-medium">Compare at amount</th>
</tr>
</thead>
<tbody>
{prices.map((_, index) => (
- <tr key={form.getValues(`prices.${index}.currency`)} className="border-b last:border-0">
+ <tr
+ key={form.getValues(`prices.${index}.currency`)}
+ className="border-b last:border-0"
+ >
<td className="px-4 py-2 font-medium">
{form.getValues(`prices.${index}.currency`)}
</td>
@@ -560,11 +549,7 @@ function InventoryCard({ form }: FormCardProps) {
name="track_inventory"
control={form.control}
render={({ field }) => (
- <Switch
- id="track_inventory"
- checked={field.value}
- onCheckedChange={field.onChange}
- />
+ <Switch id="track_inventory" checked={field.value} onCheckedChange={field.onChange} />
)}
/>
<FieldLabel htmlFor="track_inventory">Track inventory</FieldLabel>
@@ -597,9 +582,7 @@ function SEOCard({ form, product }: FormCardProps & { product: Product }) {
<CardContent className="flex flex-col gap-4">
{/* Preview */}
<div className="rounded-lg border border-gray-200 p-4 space-y-1">
- <p className="text-sm font-medium text-blue-700 truncate">
- {metaTitle || product.name}
- </p>
+ <p className="text-sm font-medium text-blue-700 truncate">{metaTitle || product.name}</p>
<p className="text-xs text-green-700 truncate">
example.com/products/{slug || product.slug}
</p>
@@ -786,7 +769,8 @@ function CategoryCombobox({
// Convert string[] of IDs to CategoryOption[] for the combobox
const selectedItems = useMemo(
- () => value.map((id) => categories.find((c) => c.id === id)).filter(Boolean) as CategoryOption[],
+ () =>
+ value.map((id) => categories.find((c) => c.id === id)).filter(Boolean) as CategoryOption[],
[value, categories],
)
@@ -808,11 +792,7 @@ function CategoryCombobox({
<ComboboxChips ref={anchorRef}>
<ComboboxValue>
{(selected: CategoryOption[]) =>
- selected.map((c) => (
- <ComboboxChip key={c.id}>
- {c.pretty_name}
- </ComboboxChip>
- ))
+ selected.map((c) => <ComboboxChip key={c.id}>{c.pretty_name}</ComboboxChip>)
}
</ComboboxValue>
<ComboboxChipsInput placeholder="Search categories..." />
diff --git a/packages/admin/src/tables/customers.tsx b/packages/admin/src/tables/customers.tsx
index dc25fdd825..0271bda406 100644
--- a/packages/admin/src/tables/customers.tsx
+++ b/packages/admin/src/tables/customers.tsx
@@ -19,7 +19,7 @@ defineTable('customers', {
default: true,
render: (c) => (
<Link
- to={"/$storeId/customers/$customerId" as string}
+ to={'/$storeId/customers/$customerId' as string}
params={{ customerId: c.id }}
className="font-medium text-zinc-950 no-underline"
>
@@ -65,7 +65,8 @@ defineTable('customers', {
label: 'Last order',
default: true,
className: 'text-sm text-muted-foreground whitespace-nowrap',
- render: (c) => (c.last_order_completed_at ? formatRelativeTime(c.last_order_completed_at) : '—'),
+ render: (c) =>
+ c.last_order_completed_at ? formatRelativeTime(c.last_order_completed_at) : '—',
},
{
key: 'accepts_email_marketing',
diff --git a/packages/admin/src/tables/orders.tsx b/packages/admin/src/tables/orders.tsx
index d36f3dd2c3..719b5f9ca2 100644
--- a/packages/admin/src/tables/orders.tsx
+++ b/packages/admin/src/tables/orders.tsx
@@ -20,7 +20,7 @@ defineTable('orders', {
default: true,
render: (order) => (
<Link
- to={"/$storeId/orders/$orderId" as string}
+ to={'/$storeId/orders/$orderId' as string}
params={{ orderId: order.id }}
className="font-medium text-zinc-950 no-underline"
>
@@ -60,7 +60,8 @@ defineTable('orders', {
{ value: 'paid', label: 'Paid' },
{ value: 'void', label: 'Void' },
],
- render: (order) => (order.payment_status ? <StatusBadge status={order.payment_status} /> : '—'),
+ render: (order) =>
+ order.payment_status ? <StatusBadge status={order.payment_status} /> : '—',
},
{
key: 'fulfillment_status',
diff --git a/packages/admin/src/tables/products.tsx b/packages/admin/src/tables/products.tsx
index ba3bfc39b9..e7d2b4dfc9 100644
--- a/packages/admin/src/tables/products.tsx
+++ b/packages/admin/src/tables/products.tsx
@@ -1,26 +1,26 @@
-import { Link } from "@tanstack/react-router";
-import { PackageIcon } from "lucide-react";
-import { StatusBadge } from "@/components/ui/badge";
-import { formatPrice, formatRelativeTime } from "@/lib/formatters";
-import { defineTable } from "@/lib/table-registry";
+import { Link } from '@tanstack/react-router'
+import { PackageIcon } from 'lucide-react'
+import { StatusBadge } from '@/components/ui/badge'
+import { formatPrice, formatRelativeTime } from '@/lib/formatters'
+import { defineTable } from '@/lib/table-registry'
-defineTable("products", {
- title: "Products",
- searchParam: "multi_search",
- searchPlaceholder: "Search products...",
- defaultSort: { field: "updated_at", direction: "desc" },
+defineTable('products', {
+ title: 'Products',
+ searchParam: 'multi_search',
+ searchPlaceholder: 'Search products...',
+ defaultSort: { field: 'updated_at', direction: 'desc' },
emptyIcon: <PackageIcon className="size-8 text-muted-foreground/50" />,
- emptyMessage: "No products found",
+ emptyMessage: 'No products found',
columns: [
{
- key: "name",
- label: "Name",
+ key: 'name',
+ label: 'Name',
sortable: true,
filterable: true,
default: true,
render: (product) => (
<Link
- to={"/$storeId/products/$productId" as string}
+ to={'/$storeId/products/$productId' as string}
params={{ productId: product.id }}
className="flex items-center gap-3 no-underline"
>
@@ -36,35 +36,33 @@ defineTable("products", {
)}
</div>
<div className="min-w-0">
- <div className="truncate font-medium text-zinc-950">
- {product.name}
- </div>
+ <div className="truncate font-medium text-zinc-950">{product.name}</div>
</div>
</Link>
),
},
{
- key: "status",
- label: "Status",
+ key: 'status',
+ label: 'Status',
sortable: true,
filterable: true,
default: true,
- filterType: "status",
+ filterType: 'status',
filterOptions: [
- { value: "draft", label: "Draft" },
- { value: "active", label: "Active" },
- { value: "archived", label: "Archived" },
+ { value: 'draft', label: 'Draft' },
+ { value: 'active', label: 'Active' },
+ { value: 'archived', label: 'Archived' },
],
render: (product) => <StatusBadge status={product.status} />,
},
{
- key: "inventory",
- label: "Inventory",
+ key: 'inventory',
+ label: 'Inventory',
sortable: false,
filterable: false,
default: true,
render: (product) => {
- const variantCount = product.variant_count;
+ const variantCount = product.variant_count
const inventoryStatus =
!product.in_stock && !product.backorderable ? (
@@ -72,10 +70,8 @@ defineTable("products", {
) : product.backorderable && !product.in_stock ? (
<span className="text-sm text-muted-foreground">On backorder</span>
) : (
- <span className="text-sm text-muted-foreground">
- {product.total_on_hand} in stock
- </span>
- );
+ <span className="text-sm text-muted-foreground">{product.total_on_hand} in stock</span>
+ )
return (
<span>
@@ -83,65 +79,63 @@ defineTable("products", {
{variantCount > 1 ? (
<>
&nbsp; &#8211; &nbsp;
- <span className="text-sm text-muted-foreground">
- {variantCount} variants
- </span>
+ <span className="text-sm text-muted-foreground">{variantCount} variants</span>
</>
) : (
- ""
+ ''
)}
</span>
- );
+ )
},
},
{
- key: "sku",
- label: "SKU",
+ key: 'sku',
+ label: 'SKU',
sortable: false,
filterable: true,
default: false,
- ransackAttribute: "master_sku",
- className: "text-sm text-muted-foreground",
- render: (product) => product.sku ?? "—",
+ ransackAttribute: 'master_sku',
+ className: 'text-sm text-muted-foreground',
+ render: (product) => product.sku ?? '—',
},
{
- key: "price",
- label: "Price",
+ key: 'price',
+ label: 'Price',
sortable: true,
filterable: true,
default: true,
- filterType: "number",
- ransackAttribute: "master_price",
- className: "text-right tabular-nums whitespace-nowrap",
- render: (product) => (product.price ? formatPrice(product.price) : "—"),
+ filterType: 'number',
+ ransackAttribute: 'master_price',
+ className: 'text-right tabular-nums whitespace-nowrap',
+ render: (product) => (product.price ? formatPrice(product.price) : '—'),
},
{
- key: "created_at",
- label: "Created at",
+ key: 'created_at',
+ label: 'Created at',
sortable: true,
filterable: true,
default: false,
- filterType: "date",
- className: "text-sm text-muted-foreground whitespace-nowrap",
+ filterType: 'date',
+ className: 'text-sm text-muted-foreground whitespace-nowrap',
render: (product) => formatRelativeTime(product.created_at),
},
{
- key: "updated_at",
- label: "Updated at",
+ key: 'updated_at',
+ label: 'Updated at',
sortable: true,
filterable: true,
default: false,
- filterType: "date",
- className: "text-sm text-muted-foreground whitespace-nowrap",
+ filterType: 'date',
+ className: 'text-sm text-muted-foreground whitespace-nowrap',
render: (product) => formatRelativeTime(product.updated_at),
},
{
- key: "in_stock",
- label: "In Stock",
+ key: 'in_stock',
+ label: 'In Stock',
filterable: true,
- filterType: "boolean",
+ filterType: 'boolean',
displayable: false,
default: false,
},
],
-});
+})
diff --git a/packages/cli/biome.json b/packages/cli/biome.json
new file mode 100644
index 0000000000..023405807a
--- /dev/null
+++ b/packages/cli/biome.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
+ "extends": ["//"],
+ "files": {
+ "includes": ["src/**", "tests/**"]
+ }
+}
diff --git a/packages/sdk-core/biome.json b/packages/sdk-core/biome.json
new file mode 100644
index 0000000000..023405807a
--- /dev/null
+++ b/packages/sdk-core/biome.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
+ "extends": ["//"],
+ "files": {
+ "includes": ["src/**", "tests/**"]
+ }
+}
diff --git a/packages/sdk/biome.json b/packages/sdk/biome.json
new file mode 100644
index 0000000000..cbf6832d91
--- /dev/null
+++ b/packages/sdk/biome.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
+ "extends": ["//"],
+ "files": {
+ "includes": ["src/**", "tests/**", "!src/types/generated/**", "!src/zod/generated/**"]
+ }
+}