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.

Admin SPA CMD+K menu (#13989)

Damian Legawiec53762c6a1ab4
diff --git a/packages/admin/package.json b/packages/admin/package.json
index 0b577221ee..d826e2d50a 100644
--- a/packages/admin/package.json
+++ b/packages/admin/package.json
@@ -27,6 +27,7 @@
"@uiw/react-json-view": "^1.12",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
+ "cmdk": "^1.1.1",
"date-fns": "^4.1.0",
"lucide-react": "^1.14.0",
"react": "^19.2.5",
diff --git a/packages/admin/src/components/spree/app-sidebar.tsx b/packages/admin/src/components/spree/app-sidebar.tsx
index 6e2b6f8b54..d01acc1a0e 100644
--- a/packages/admin/src/components/spree/app-sidebar.tsx
+++ b/packages/admin/src/components/spree/app-sidebar.tsx
@@ -2,9 +2,8 @@ import { useParams } from '@tanstack/react-router'
import { PackageIcon } from 'lucide-react'
import type { ComponentProps } from 'react'
import { type NavItem, NavMain } from '@/components/spree/nav-main'
-import { NavUser } from '@/components/spree/nav-user'
import { StoreSwitcher } from '@/components/spree/store-switcher'
-import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader } from '@/components/ui/sidebar'
+import { Sidebar, SidebarContent, SidebarHeader } from '@/components/ui/sidebar'
import { type NavEntry, useNavEntries } from '@/lib/nav-registry'
import { type Permissions, usePermissions } from '@/providers/permission-provider'
@@ -58,9 +57,6 @@ export function AppSidebar(props: ComponentProps<typeof Sidebar>) {
<SidebarContent>
<NavMain items={navItems} bottomItems={bottomItems} />
</SidebarContent>
- <SidebarFooter>
- <NavUser />
- </SidebarFooter>
</Sidebar>
)
}
diff --git a/packages/admin/src/components/spree/command-palette/command-palette.tsx b/packages/admin/src/components/spree/command-palette/command-palette.tsx
new file mode 100644
index 0000000000..8ade1fdf3a
--- /dev/null
+++ b/packages/admin/src/components/spree/command-palette/command-palette.tsx
@@ -0,0 +1,260 @@
+import { useNavigate, useParams } from '@tanstack/react-router'
+import {
+ HomeIcon,
+ Loader2Icon,
+ LogOutIcon,
+ PackageIcon,
+ ShoppingCartIcon,
+ TagIcon,
+ UsersIcon,
+} from 'lucide-react'
+import { type ReactNode, useState } from 'react'
+import { StatusBadge } from '@/components/ui/badge'
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+ CommandSeparator,
+} from '@/components/ui/command'
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog'
+import { useAuth } from '@/hooks/use-auth'
+import { useCommandPalette } from '@/hooks/use-command-palette'
+import { useGlobalSearch } from '@/hooks/use-global-search'
+
+export function CommandPalette() {
+ const { open, setOpen } = useCommandPalette()
+ // Skip the entire subtree (and its hooks) while the palette is closed —
+ // it's mounted at the layout root and otherwise re-renders on every nav.
+ if (!open) return null
+
+ return <CommandPaletteContent setOpen={setOpen} />
+}
+
+function CommandPaletteContent({ setOpen }: { setOpen: (open: boolean) => void }) {
+ const { storeId: rawStoreId } = useParams({ strict: false }) as { storeId?: string }
+ const storeId = rawStoreId ?? 'default'
+ const navigate = useNavigate()
+ const { logout } = useAuth()
+
+ const [input, setInput] = useState('')
+ const { products, orders, customers, isLoading, isEnabled } = useGlobalSearch(input)
+
+ const close = () => {
+ setOpen(false)
+ setInput('')
+ }
+
+ const q = input.trim().toLowerCase()
+ const matches = (label: string) => !q || label.toLowerCase().includes(q)
+ const gotoItems = [
+ { label: 'Dashboard', icon: HomeIcon, to: '/$storeId' as const },
+ { label: 'Products', icon: PackageIcon, to: '/$storeId/products' as const },
+ { label: 'Orders', icon: ShoppingCartIcon, to: '/$storeId/orders' as const },
+ { label: 'Customers', icon: UsersIcon, to: '/$storeId/customers' as const },
+ ].filter((c) => matches(`Go to ${c.label}`))
+ const showLogout = matches('Log out')
+ const hasResults = products.length > 0 || orders.length > 0 || customers.length > 0
+
+ return (
+ <Dialog
+ open
+ onOpenChange={(next) => {
+ if (!next) close()
+ }}
+ >
+ <DialogHeader className="sr-only">
+ <DialogTitle>Search and commands</DialogTitle>
+ <DialogDescription>
+ Search across products, orders, and customers, or run a command.
+ </DialogDescription>
+ </DialogHeader>
+ <DialogContent
+ className="top-1/3 translate-y-0 overflow-hidden p-0 sm:max-w-2xl"
+ showCloseButton={false}
+ // Don't restore focus to the trigger after navigating — the trigger is
+ // gone (we navigated away) and focus would land on the first sidebar
+ // link, painting it with a misleading focus ring.
+ finalFocus={false}
+ >
+ {/* Server's `search` Ransack scope filters resources; static commands
+ are pre-filtered in JS. Either way, cmdk shouldn't filter again. */}
+ <Command shouldFilter={false}>
+ <CommandInput
+ value={input}
+ onValueChange={setInput}
+ placeholder="Search products, orders, customers… or run a command"
+ />
+ <CommandList>
+ <SearchStatus
+ isEnabled={isEnabled}
+ isLoading={isLoading}
+ hasResults={hasResults}
+ query={input}
+ />
+
+ {products.length > 0 && (
+ <CommandGroup heading="Products">
+ {products.map((p) => (
+ <CommandItem
+ key={p.id}
+ value={`product-${p.id}`}
+ onSelect={() => {
+ close()
+ navigate({
+ to: '/$storeId/products/$productId',
+ params: { storeId, productId: p.id },
+ })
+ }}
+ >
+ <ProductIconOrThumbnail thumbnailUrl={p.primary_media?.mini_url ?? null} />
+ <span className="flex-1 truncate">{p.name}</span>
+ <StatusBadge status={p.status} />
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ )}
+
+ {orders.length > 0 && (
+ <CommandGroup heading="Orders">
+ {orders.map((o) => (
+ <CommandItem
+ key={o.id}
+ value={`order-${o.id}`}
+ onSelect={() => {
+ close()
+ navigate({
+ to: '/$storeId/orders/$orderId',
+ params: { storeId, orderId: o.id },
+ })
+ }}
+ >
+ <ShoppingCartIcon />
+ <span className="flex-1 truncate">
+ <span className="font-mono">{o.number}</span>
+ {o.email && <span className="ml-2 text-muted-foreground">{o.email}</span>}
+ </span>
+ {o.payment_status && <StatusBadge status={o.payment_status} />}
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ )}
+
+ {customers.length > 0 && (
+ <CommandGroup heading="Customers">
+ {customers.map((c) => (
+ <CommandItem
+ key={c.id}
+ value={`customer-${c.id}`}
+ onSelect={() => {
+ close()
+ navigate({
+ to: '/$storeId/customers/$customerId',
+ params: { storeId, customerId: c.id },
+ })
+ }}
+ >
+ <UsersIcon />
+ <span className="flex-1 truncate">
+ {c.full_name || c.email}
+ {c.full_name && <span className="ml-2 text-muted-foreground">{c.email}</span>}
+ </span>
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ )}
+
+ {hasResults && (gotoItems.length > 0 || showLogout) && <CommandSeparator />}
+
+ {gotoItems.length > 0 && (
+ <CommandGroup heading="Go to">
+ {gotoItems.map(({ label, icon: Icon, to }) => (
+ <CommandItem
+ key={to}
+ value={`goto-${label}`}
+ onSelect={() => {
+ close()
+ navigate({ to, params: { storeId } })
+ }}
+ >
+ <Icon />
+ {label}
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ )}
+
+ {gotoItems.length > 0 && showLogout && <CommandSeparator />}
+
+ {showLogout && (
+ <CommandGroup heading="Account">
+ <CommandItem
+ value="action-logout"
+ onSelect={() => {
+ close()
+ logout()
+ }}
+ >
+ <LogOutIcon />
+ Log out
+ </CommandItem>
+ </CommandGroup>
+ )}
+ </CommandList>
+ </Command>
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+// ---------------------------------------------------------------------------
+// Helpers
+// ---------------------------------------------------------------------------
+
+function SearchStatus({
+ isEnabled,
+ isLoading,
+ hasResults,
+ query,
+}: {
+ isEnabled: boolean
+ isLoading: boolean
+ hasResults: boolean
+ query: string
+}): ReactNode {
+ if (isEnabled && isLoading) {
+ return (
+ <div className="flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground">
+ <Loader2Icon className="size-4 animate-spin" />
+ Searching…
+ </div>
+ )
+ }
+ if (isEnabled && !hasResults) {
+ return <CommandEmpty>No results for "{query}".</CommandEmpty>
+ }
+ if (!isEnabled && !query) {
+ return <CommandEmpty>Type to search, or pick a command below.</CommandEmpty>
+ }
+ return null
+}
+
+function ProductIconOrThumbnail({ thumbnailUrl }: { thumbnailUrl: string | null }): ReactNode {
+ if (!thumbnailUrl) return <TagIcon />
+ return (
+ <img
+ src={thumbnailUrl}
+ alt=""
+ className="size-5 shrink-0 rounded object-cover"
+ loading="lazy"
+ />
+ )
+}
diff --git a/packages/admin/src/components/spree/nav-user.tsx b/packages/admin/src/components/spree/nav-user.tsx
deleted file mode 100644
index 67d014252d..0000000000
--- a/packages/admin/src/components/spree/nav-user.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { BookOpenIcon, LogOutIcon, MailIcon, MessageCircleIcon, UserIcon } from 'lucide-react'
-import { Avatar, AvatarFallback } from '@/components/ui/avatar'
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
-} from '@/components/ui/dropdown-menu'
-import { SidebarMenu, SidebarMenuItem, useSidebar } from '@/components/ui/sidebar'
-import { useAuth } from '@/hooks/use-auth'
-
-export function NavUser() {
- const { isMobile, state } = useSidebar()
- const isCollapsed = state === 'collapsed'
- const { user, logout } = useAuth()
-
- if (!user) return null
-
- const initials =
- [user.first_name, user.last_name]
- .filter(Boolean)
- .map((n) => n![0])
- .join('')
- .toUpperCase() || user.email[0]!.toUpperCase()
-
- const displayName = [user.first_name, user.last_name].filter(Boolean).join(' ') || user.email
-
- return (
- <SidebarMenu>
- <SidebarMenuItem>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <button
- type="button"
- className={
- 'flex w-full items-center rounded-lg text-left transition-colors duration-100 outline-none hover:bg-gray-200/50 ' +
- (isCollapsed ? 'justify-center p-0' : 'gap-2 p-1')
- }
- >
- <Avatar className="size-8 shrink-0">
- <AvatarFallback className="text-xs bg-zinc-950 text-white">
- {initials}
- </AvatarFallback>
- </Avatar>
- {!isCollapsed && (
- <span className="flex-1 min-w-0 truncate text-sm text-zinc-950">{displayName}</span>
- )}
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- className="w-56"
- side={isMobile ? 'top' : 'right'}
- align="end"
- sideOffset={8}
- >
- {/* Profile card */}
- <div className="flex items-center gap-2 p-1.5">
- <Avatar className="size-8">
- <AvatarFallback className="text-xs bg-zinc-950 text-white">
- {initials}
- </AvatarFallback>
- </Avatar>
- <div className="grid flex-1 min-w-0 text-sm leading-tight">
- <span className="truncate font-medium text-zinc-950">{displayName}</span>
- <span className="truncate text-xs text-muted-foreground">{user.email}</span>
- </div>
- </div>
- <DropdownMenuSeparator />
- <DropdownMenuItem>
- <UserIcon className="size-4" />
- Edit Profile
- </DropdownMenuItem>
- <DropdownMenuSeparator />
- <DropdownMenuItem>
- <BookOpenIcon className="size-4" />
- Documentation
- </DropdownMenuItem>
- <DropdownMenuItem>
- <MessageCircleIcon className="size-4" />
- Community
- </DropdownMenuItem>
- <DropdownMenuItem>
- <MailIcon className="size-4" />
- Contact Support
- </DropdownMenuItem>
- <DropdownMenuSeparator />
- <DropdownMenuItem onClick={logout} className="text-destructive focus:text-destructive">
- <LogOutIcon className="size-4" />
- Log out
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </SidebarMenuItem>
- </SidebarMenu>
- )
-}
diff --git a/packages/admin/src/components/spree/top-bar.tsx b/packages/admin/src/components/spree/top-bar.tsx
new file mode 100644
index 0000000000..2e829eecb4
--- /dev/null
+++ b/packages/admin/src/components/spree/top-bar.tsx
@@ -0,0 +1,159 @@
+import {
+ BookOpenIcon,
+ ExternalLinkIcon,
+ LogOutIcon,
+ MailIcon,
+ MessageCircleIcon,
+ SearchIcon,
+ UserIcon,
+} from 'lucide-react'
+import { Avatar, AvatarFallback } from '@/components/ui/avatar'
+import { Button } from '@/components/ui/button'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu'
+import { SidebarTrigger } from '@/components/ui/sidebar'
+import { useAuth } from '@/hooks/use-auth'
+import { useCommandPalette } from '@/hooks/use-command-palette'
+import { useStore } from '@/providers/store-provider'
+
+const IS_MAC = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform ?? '')
+
+/**
+ * Top-bar shell for the admin SPA. Three-slot layout:
+ * [☰ sidebar toggle] [global search] [view store · user menu]
+ *
+ * The search trigger opens the global ⌘K command palette (provider mounted at
+ * the layout root). The keyboard shortcut is registered in the provider, not
+ * here, so it works regardless of focus location.
+ */
+export function TopBar() {
+ return (
+ <header className="sticky top-0 z-40 flex h-header-height shrink-0 items-center gap-3 bg-white/90 px-4 shadow-[inset_0_-1px_0_var(--color-border)] backdrop-blur supports-[backdrop-filter]:bg-white/75">
+ <SidebarTrigger className="-ml-1 h-8 w-8" />
+
+ <div className="flex flex-1 justify-center">
+ <SearchTrigger />
+ </div>
+
+ <div className="flex items-center gap-2">
+ <ViewStoreLink />
+ <TopBarUser />
+ </div>
+ </header>
+ )
+}
+
+// ---------------------------------------------------------------------------
+// Search trigger — opens the global command palette
+// ---------------------------------------------------------------------------
+
+function SearchTrigger() {
+ const { setOpen } = useCommandPalette()
+
+ return (
+ <button
+ type="button"
+ onClick={() => setOpen(true)}
+ className="flex w-full max-w-md items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-muted"
+ >
+ <SearchIcon className="size-4" />
+ <span className="flex-1 text-left">Search products, orders, customers…</span>
+ <kbd className="hidden rounded border bg-white px-1.5 py-0.5 font-mono text-xs sm:inline-flex">
+ {IS_MAC ? '⌘K' : 'Ctrl+K'}
+ </kbd>
+ </button>
+ )
+}
+
+// ---------------------------------------------------------------------------
+// View Store link
+// ---------------------------------------------------------------------------
+
+function ViewStoreLink() {
+ const { store } = useStore()
+ if (!store?.url) return null
+
+ // Best-effort: prefix with https if the URL is just a hostname.
+ const href = /^https?:\/\//.test(store.url) ? store.url : `https://${store.url}`
+
+ return (
+ <Button asChild variant="ghost" size="sm">
+ <a href={href} target="_blank" rel="noreferrer">
+ <ExternalLinkIcon className="size-4" />
+ <span className="hidden sm:inline">View store</span>
+ </a>
+ </Button>
+ )
+}
+
+// ---------------------------------------------------------------------------
+// User menu
+// ---------------------------------------------------------------------------
+
+function TopBarUser() {
+ const { user, logout } = useAuth()
+ if (!user) return null
+
+ const initials =
+ [user.first_name, user.last_name]
+ .filter(Boolean)
+ .map((n) => n![0])
+ .join('')
+ .toUpperCase() || user.email[0]!.toUpperCase()
+
+ const displayName = [user.first_name, user.last_name].filter(Boolean).join(' ') || user.email
+
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ type="button"
+ className="flex items-center gap-2 rounded-lg p-1 transition-colors hover:bg-gray-200/50"
+ >
+ <Avatar className="size-7">
+ <AvatarFallback className="bg-zinc-950 text-xs text-white">{initials}</AvatarFallback>
+ </Avatar>
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-56" sideOffset={8}>
+ <div className="flex items-center gap-2 p-1.5">
+ <Avatar className="size-8">
+ <AvatarFallback className="bg-zinc-950 text-xs text-white">{initials}</AvatarFallback>
+ </Avatar>
+ <div className="grid min-w-0 flex-1 text-sm leading-tight">
+ <span className="truncate font-medium text-zinc-950">{displayName}</span>
+ <span className="truncate text-xs text-muted-foreground">{user.email}</span>
+ </div>
+ </div>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem>
+ <UserIcon className="size-4" />
+ Edit Profile
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem>
+ <BookOpenIcon className="size-4" />
+ Documentation
+ </DropdownMenuItem>
+ <DropdownMenuItem>
+ <MessageCircleIcon className="size-4" />
+ Community
+ </DropdownMenuItem>
+ <DropdownMenuItem>
+ <MailIcon className="size-4" />
+ Contact Support
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={logout} className="text-destructive focus:text-destructive">
+ <LogOutIcon className="size-4" />
+ Log out
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )
+}
diff --git a/packages/admin/src/components/ui/command.tsx b/packages/admin/src/components/ui/command.tsx
new file mode 100644
index 0000000000..f4d4b3e23b
--- /dev/null
+++ b/packages/admin/src/components/ui/command.tsx
@@ -0,0 +1,177 @@
+import { Command as CommandPrimitive } from 'cmdk'
+import { CheckIcon, SearchIcon } from 'lucide-react'
+import * as React from 'react'
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog'
+import { InputGroup, InputGroupAddon } from '@/components/ui/input-group'
+import { cn } from '@/lib/utils'
+
+function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
+ return (
+ <CommandPrimitive
+ data-slot="command"
+ className={cn(
+ 'flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground',
+ className,
+ )}
+ {...props}
+ />
+ )
+}
+
+function CommandDialog({
+ title = 'Command Palette',
+ description = 'Search for a command to run...',
+ children,
+ className,
+ showCloseButton = false,
+ ...props
+}: React.ComponentProps<typeof Dialog> & {
+ title?: string
+ description?: string
+ className?: string
+ showCloseButton?: boolean
+}) {
+ return (
+ <Dialog {...props}>
+ <DialogHeader className="sr-only">
+ <DialogTitle>{title}</DialogTitle>
+ <DialogDescription>{description}</DialogDescription>
+ </DialogHeader>
+ <DialogContent
+ className={cn('top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0', className)}
+ showCloseButton={showCloseButton}
+ >
+ {children}
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+function CommandInput({
+ className,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Input>) {
+ return (
+ <div data-slot="command-input-wrapper" className="p-1 pb-0">
+ <InputGroup className="h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!">
+ <CommandPrimitive.Input
+ data-slot="command-input"
+ className={cn(
+ 'w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
+ className,
+ )}
+ {...props}
+ />
+ <InputGroupAddon>
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
+ </InputGroupAddon>
+ </InputGroup>
+ </div>
+ )
+}
+
+function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
+ return (
+ <CommandPrimitive.List
+ data-slot="command-list"
+ className={cn(
+ 'no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none',
+ className,
+ )}
+ {...props}
+ />
+ )
+}
+
+function CommandEmpty({
+ className,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
+ return (
+ <CommandPrimitive.Empty
+ data-slot="command-empty"
+ className={cn('py-6 text-center text-sm', className)}
+ {...props}
+ />
+ )
+}
+
+function CommandGroup({
+ className,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Group>) {
+ return (
+ <CommandPrimitive.Group
+ data-slot="command-group"
+ className={cn(
+ 'overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground',
+ className,
+ )}
+ {...props}
+ />
+ )
+}
+
+function CommandSeparator({
+ className,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
+ return (
+ <CommandPrimitive.Separator
+ data-slot="command-separator"
+ className={cn('-mx-1 h-px bg-border', className)}
+ {...props}
+ />
+ )
+}
+
+function CommandItem({
+ className,
+ children,
+ ...props
+}: React.ComponentProps<typeof CommandPrimitive.Item>) {
+ return (
+ <CommandPrimitive.Item
+ data-slot="command-item"
+ className={cn(
+ "group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <CheckIcon className="ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" />
+ </CommandPrimitive.Item>
+ )
+}
+
+function CommandShortcut({ className, ...props }: React.ComponentProps<'span'>) {
+ return (
+ <span
+ data-slot="command-shortcut"
+ className={cn(
+ 'ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground',
+ className,
+ )}
+ {...props}
+ />
+ )
+}
+
+export {
+ Command,
+ CommandDialog,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+ CommandSeparator,
+ CommandShortcut,
+}
diff --git a/packages/admin/src/components/ui/dialog.tsx b/packages/admin/src/components/ui/dialog.tsx
index 751c3d92a1..9e33f3e063 100644
--- a/packages/admin/src/components/ui/dialog.tsx
+++ b/packages/admin/src/components/ui/dialog.tsx
@@ -82,7 +82,7 @@ function DialogOverlay({
<DialogPrimitive.Backdrop
data-slot="dialog-overlay"
className={cn(
- 'fixed inset-0 isolate z-50 bg-white/80 duration-100 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0 transition-opacity',
+ 'fixed inset-0 isolate z-50 bg-black/50 duration-100 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0 transition-opacity',
className,
)}
{...props}
diff --git a/packages/admin/src/components/ui/sheet.tsx b/packages/admin/src/components/ui/sheet.tsx
index e20c9e73e9..e6b45fa517 100644
--- a/packages/admin/src/components/ui/sheet.tsx
+++ b/packages/admin/src/components/ui/sheet.tsx
@@ -93,7 +93,7 @@ function SheetOverlay({
<SheetPrimitive.Backdrop
data-slot="sheet-overlay"
className={cn(
- 'fixed inset-0 z-50 bg-white/80 duration-200 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0 transition-opacity',
+ 'fixed inset-0 z-50 bg-black/50 duration-200 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0 transition-opacity',
className,
)}
{...props}
diff --git a/packages/admin/src/hooks/use-command-palette.tsx b/packages/admin/src/hooks/use-command-palette.tsx
new file mode 100644
index 0000000000..f6207ebc19
--- /dev/null
+++ b/packages/admin/src/hooks/use-command-palette.tsx
@@ -0,0 +1,41 @@
+import { createContext, type ReactNode, useContext, useEffect, useMemo, useState } from 'react'
+
+interface CommandPaletteState {
+ open: boolean
+ setOpen: (open: boolean) => void
+}
+
+const CommandPaletteContext = createContext<CommandPaletteState | null>(null)
+
+/**
+ * Mounts at the app shell so the top-bar trigger, the global ⌘K shortcut, and
+ * the palette dialog itself share a single source of truth without
+ * prop-drilling through layouts.
+ */
+export function CommandPaletteProvider({ children }: { children: ReactNode }) {
+ const [open, setOpen] = useState(false)
+
+ // Global ⌘K / Ctrl+K shortcut.
+ useEffect(() => {
+ function onKeyDown(e: KeyboardEvent) {
+ if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
+ e.preventDefault()
+ setOpen((prev) => !prev)
+ }
+ }
+ window.addEventListener('keydown', onKeyDown)
+ return () => window.removeEventListener('keydown', onKeyDown)
+ }, [])
+
+ const value = useMemo<CommandPaletteState>(() => ({ open, setOpen }), [open])
+
+ return <CommandPaletteContext.Provider value={value}>{children}</CommandPaletteContext.Provider>
+}
+
+export function useCommandPalette(): CommandPaletteState {
+ const ctx = useContext(CommandPaletteContext)
+ if (!ctx) {
+ throw new Error('useCommandPalette must be used within a CommandPaletteProvider')
+ }
+ return ctx
+}
diff --git a/packages/admin/src/hooks/use-global-search.ts b/packages/admin/src/hooks/use-global-search.ts
new file mode 100644
index 0000000000..3f13496134
--- /dev/null
+++ b/packages/admin/src/hooks/use-global-search.ts
@@ -0,0 +1,66 @@
+import { useQuery } from '@tanstack/react-query'
+import { useEffect, useState } from 'react'
+import { adminClient } from '@/client'
+
+const RESULT_LIMIT = 5
+const MIN_QUERY_LENGTH = 2
+const DEBOUNCE_MS = 200
+const GC_TIME_MS = 60_000
+const STALE_TIME_MS = 30_000
+
+/**
+ * Three parallel `?q[search]=…&limit=5` queries — one per resource. Each model
+ * defines a `search` Ransack scope that does multi-field LIKE matching, so we
+ * pass a single `search` param and let the server decide what to match.
+ *
+ * The query is debounced so a fast typist doesn't fan out a wave of in-flight
+ * requests; results are cached briefly so backspace feels instant but they
+ * don't pile up across long sessions.
+ */
+export function useGlobalSearch(rawQuery: string) {
+ const query = useDebouncedValue(rawQuery, DEBOUNCE_MS)
+ const enabled = query.trim().length >= MIN_QUERY_LENGTH
+
+ const products = useQuery({
+ queryKey: ['cmdk', 'products', query],
+ queryFn: () => adminClient.products.list({ search: query, limit: RESULT_LIMIT }),
+ enabled,
+ gcTime: GC_TIME_MS,
+ staleTime: STALE_TIME_MS,
+ })
+
+ const orders = useQuery({
+ queryKey: ['cmdk', 'orders', query],
+ queryFn: () => adminClient.orders.list({ search: query, limit: RESULT_LIMIT }),
+ enabled,
+ gcTime: GC_TIME_MS,
+ staleTime: STALE_TIME_MS,
+ })
+
+ const customers = useQuery({
+ queryKey: ['cmdk', 'customers', query],
+ queryFn: () => adminClient.customers.list({ search: query, limit: RESULT_LIMIT }),
+ enabled,
+ gcTime: GC_TIME_MS,
+ staleTime: STALE_TIME_MS,
+ })
+
+ return {
+ products: products.data?.data ?? [],
+ orders: orders.data?.data ?? [],
+ customers: customers.data?.data ?? [],
+ isLoading: enabled && (products.isLoading || orders.isLoading || customers.isLoading),
+ isEnabled: enabled,
+ }
+}
+
+function useDebouncedValue<T>(value: T, delayMs: number): T {
+ const [debounced, setDebounced] = useState(value)
+
+ useEffect(() => {
+ const id = setTimeout(() => setDebounced(value), delayMs)
+ return () => clearTimeout(id)
+ }, [value, delayMs])
+
+ return debounced
+}
diff --git a/packages/admin/src/routes/_authenticated/$storeId.tsx b/packages/admin/src/routes/_authenticated/$storeId.tsx
index 813eb304f8..3215ca73ea 100644
--- a/packages/admin/src/routes/_authenticated/$storeId.tsx
+++ b/packages/admin/src/routes/_authenticated/$storeId.tsx
@@ -2,7 +2,10 @@ import { createFileRoute, Outlet } from '@tanstack/react-router'
import { useEffect } from 'react'
import { adminClient } from '@/client'
import { AppSidebar } from '@/components/spree/app-sidebar'
-import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar'
+import { CommandPalette } from '@/components/spree/command-palette/command-palette'
+import { TopBar } from '@/components/spree/top-bar'
+import { SidebarInset, SidebarProvider } from '@/components/ui/sidebar'
+import { CommandPaletteProvider } from '@/hooks/use-command-palette'
import { StoreProvider } from '@/providers/store-provider'
export const Route = createFileRoute('/_authenticated/$storeId')({
@@ -18,19 +21,18 @@ function StoreLayout() {
return (
<StoreProvider storeId={storeId}>
- <SidebarProvider>
- <AppSidebar />
- <SidebarInset>
- <header className="flex h-header-height shrink-0 items-center bg-white shadow-[inset_0_-1px_0_var(--color-border)]">
- <div className="flex items-center gap-2 px-4 h-header-height">
- <SidebarTrigger className="-ml-1 h-8 w-8" />
+ <CommandPaletteProvider>
+ <SidebarProvider>
+ <AppSidebar />
+ <SidebarInset>
+ <TopBar />
+ <div className="container mx-auto flex flex-1 flex-col gap-4 p-4">
+ <Outlet />
</div>
- </header>
- <div className="container mx-auto flex flex-1 flex-col gap-4 p-4">
- <Outlet />
- </div>
- </SidebarInset>
- </SidebarProvider>
+ </SidebarInset>
+ </SidebarProvider>
+ <CommandPalette />
+ </CommandPaletteProvider>
</StoreProvider>
)
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5b19740977..89b9a7cde8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -63,6 +63,9 @@ importers:
clsx:
specifier: ^2.1.1
version: 2.1.1
+ cmdk:
+ specifier: ^1.1.1
date-fns:
specifier: ^4.1.0
version: 4.1.0
@@ -918,6 +921,199 @@ packages:
'@oxc-project/[email protected]':
resolution: {integrity: sha512-aIYXQBo4lCbO4z0R3FHeucQHpF46l2LbMdxRvqvuRuW2OxdnSkcng5B8+K12spgLDj93rtN3+J2Vac/TIO+ciQ==}
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==}
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-jCi/QKUM2r1Ju5a3J64TH2A5SpKAgh0LpknyqdQ4m6DCV0xJ2HG1xARRwNGPQfi1SLdLWZ1OJz6F4OMBBNiGJA==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-TCglVRtzlffRNxRMEyR36DGBLJpeusFcgMVD9PZEzAKnUs1lKCgX5u9BmC2Yg+LL9MgZDugFFs1Vl+Jp4t/PGw==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-Nqcp+t5cTB8BinFkZgXiMJniQH0PsUt2k51FUhbdfeKvc4ACcG2uQniY/8+h1Yv6Kza4Q7lD7PQV0z0oicE0Mg==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-0rFg/Rj2Q62NCm62jZw0QX7a3sz6QCQU0LpZdNrJX8byRGaGVTqbrW9jAoIAHyMQqsNpeZ81YgSizOt5WXq0Pw==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-t2ODlkXBQyn7jkl6TNaw/MtVEVvIGelJDCG41Okq/KwUsJBwQ4XVZsHAVUkK4mBv3ewiAS3PGuUWuY2BoK4ZUw==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-bpIxvq03if6UNwXZ+HTK71JLh4APvnXntDc6XOX8UVq4XQOVl7lwok0AvIl+b8zgCw3fSaVTZMpAPPagXbKmHQ==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-/jfEwNDdQVBCNvjkGit4h6pMOzq8bHkopq458dPt2lMjx+eBQUohZNG9A7DtO/O5ukSbxuaNGXMjHicgwy6rQQ==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-m9gTwRkhy2lvCPe6QJp4d3G1TYEUHn/FzJUtq9MjH46an1wJU+GdoGC5VLof8RX8Ft/DlpshApkhswDLZzHIcQ==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-9hQc4+GNVtJAIEPEqlYqW5RiYdrr8ea5XQ0ZOnD6fgru+83kqT15mq2OCcbe8KnjRZl5vF3ks69AKz3kh1jrhg==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-Jl+bCv8HxKnlTLVrcDE8zTMJ09R9/ukw4qBs/oZClOfoQk/cOTbDn+NceXfV7j09YPVQUryJPHurafcSg6EVKA==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-FkBMwD+qbGQeMu1cOHnuGB6x4yzPjho8ap5WtbEJ26umhgqVXbhekKUQO+hZEL1vU92a3wHwdp0HAcqAUF5iDg==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-BjasUjixPFdS+NKkypcyyN5Pmg83Olst0+c6vGov0diwTEo6mgdqVR6hxcEgFuh4QrAs7Rc+9KuGJ9TVCj0Zzg==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-Qp8WbZOBe+blgpuUT+lw2xheLP8q0oatc9UpmiemEICxGvFLYmHm9QowVZGHtJlGbS6A6yJ3iViad/2cVjnOiA==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-Il0+boE7w/XebUHyBjroE+DbByORGR9KKmITzbR7MyQ4akpORYP/ZmbhAr0DG7RmmBqoOnZdy2QlvajJ2QA59g==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ '@radix-ui/[email protected]':
+ resolution: {integrity: sha512-RbJRS4UWQFkzHTTwVymMTUv8EqYhOp8dOOviLj2ugtTiXRaRQS7GLGxZTLL1jWhMeoSCf5zmcZkqTl9IiYfXcQ==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
'@reduxjs/[email protected]':
resolution: {integrity: sha512-Kd6kAHTA6/nUpp8mySPqj3en3dm0tdMIgbttnQ1xFMVpufoj+ADi8pXLBsd4xzTRHQa7t/Jv8W5UnCuW4kuWMQ==}
peerDependencies:
@@ -1694,6 +1890,10 @@ packages:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
+ resolution: {integrity: sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
engines: {node: '>=8'}
@@ -1821,6 +2021,12 @@ packages:
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-Vsv7kFaXm+ptHDMZ7izaRsP70GgrW9NBNGswt9OZaVBLlE0SNpDq8eu/VGXyF9r7M0azK3Wy7OlYXsuyYLFzHg==}
+ peerDependencies:
+ react: ^18 || ^19 || ^19.0.0-rc
+ react-dom: ^18 || ^19 || ^19.0.0-rc
+
resolution: {integrity: sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg==}
@@ -2009,6 +2215,9 @@ packages:
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==}
+
resolution: {integrity: sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==}
engines: {node: '>=0.3.1'}
@@ -2251,6 +2460,10 @@ packages:
resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-PKsK2FSrQCyxcGHsGrLDcK0lx+0Ke+6e8KFFozA9/fIQLhQzPaRvJFdcz7+Axg3jUH/Mq+NI4xa5u/UT2tQskA==}
engines: {node: '>=14.16'}
@@ -3042,6 +3255,36 @@ packages:
redux:
optional: true
+ resolution: {integrity: sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ resolution: {integrity: sha512-Iqb9NjCCTt6Hf+vOdNIZGdTiH1QSqr27H/Ek9sv/a97gfueI/5h1s3yRi1nngzMUaOOToin5dI1dXKdXiF+u0Q==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ resolution: {integrity: sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
resolution: {integrity: sha512-llUJLzz1zTUBrskt2pwZgLq59AemifIftw4aB7JxOqf1HY2FDaGDxgwpAPVzHU1kdWabH7FauP4i1oEeer2WCA==}
engines: {node: '>=0.10.0'}
@@ -3471,6 +3714,26 @@ packages:
peerDependencies:
browserslist: '>= 4.21.0'
+ resolution: {integrity: sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
+ resolution: {integrity: sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+
resolution: {integrity: sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==}
peerDependencies:
@@ -4360,6 +4623,165 @@ snapshots:
'@oxc-project/[email protected]': {}
+ '@radix-ui/[email protected]': {}
+
+ dependencies:
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ '@radix-ui/primitive': 1.1.3
+ '@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.1.2(@types/[email protected])([email protected])
+ '@radix-ui/react-dismissable-layer': 1.1.11(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
+ '@radix-ui/react-focus-guards': 1.1.3(@types/[email protected])([email protected])
+ '@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])
+ '@radix-ui/react-slot': 1.2.3(@types/[email protected])([email protected])
+ '@radix-ui/react-use-controllable-state': 1.2.2(@types/[email protected])([email protected])
+ aria-hidden: 1.2.6
+ react: 19.2.5
+ react-dom: 19.2.5([email protected])
+ react-remove-scroll: 2.7.2(@types/[email protected])([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+
+ dependencies:
+ '@radix-ui/primitive': 1.1.3
+ '@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-escape-keydown': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ react-dom: 19.2.5([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+
+ dependencies:
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ '@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ react-dom: 19.2.5([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+
+ dependencies:
+ '@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ '@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ react-dom: 19.2.5([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+
+ dependencies:
+ '@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
+ '@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ react-dom: 19.2.5([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+
+ dependencies:
+ '@radix-ui/react-slot': 1.2.3(@types/[email protected])([email protected])
+ react: 19.2.5
+ react-dom: 19.2.5([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+
+ dependencies:
+ '@radix-ui/react-slot': 1.2.4(@types/[email protected])([email protected])
+ react: 19.2.5
+ react-dom: 19.2.5([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+
+ dependencies:
+ '@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ '@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ '@radix-ui/react-use-effect-event': 0.0.2(@types/[email protected])([email protected])
+ '@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ '@radix-ui/react-use-layout-effect': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ '@radix-ui/react-use-callback-ref': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ react: 19.2.5
+ optionalDependencies:
+ '@types/react': 19.2.14
+
dependencies:
'@standard-schema/spec': 1.1.0
@@ -5037,6 +5459,10 @@ snapshots:
+ dependencies:
+ tslib: 2.8.1
+
@@ -5169,6 +5595,18 @@ snapshots:
+ dependencies:
+ '@radix-ui/react-compose-refs': 1.1.2(@types/[email protected])([email protected])
+ '@radix-ui/react-id': 1.1.1(@types/[email protected])([email protected])
+ react: 19.2.5
+ react-dom: 19.2.5([email protected])
+ transitivePeerDependencies:
+ - '@types/react'
+ - '@types/react-dom'
+
@@ -5300,6 +5738,8 @@ snapshots:
+
@@ -5598,6 +6038,8 @@ snapshots:
hasown: 2.0.3
math-intrinsics: 1.1.0
+
@@ -6282,6 +6724,33 @@ snapshots:
'@types/react': 19.2.14
redux: 5.0.1
+ dependencies:
+ react: 19.2.5
+ react-style-singleton: 2.2.3(@types/[email protected])([email protected])
+ tslib: 2.8.1
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ react: 19.2.5
+ react-remove-scroll-bar: 2.3.8(@types/[email protected])([email protected])
+ react-style-singleton: 2.2.3(@types/[email protected])([email protected])
+ tslib: 2.8.1
+ use-callback-ref: 1.3.3(@types/[email protected])([email protected])
+ use-sidecar: 1.1.3(@types/[email protected])([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ get-nonce: 1.0.1
+ react: 19.2.5
+ tslib: 2.8.1
+ optionalDependencies:
+ '@types/react': 19.2.14
+
@@ -6782,6 +7251,21 @@ snapshots:
escalade: 3.2.0
picocolors: 1.1.1
+ dependencies:
+ react: 19.2.5
+ tslib: 2.8.1
+ optionalDependencies:
+ '@types/react': 19.2.14
+
+ dependencies:
+ detect-node-es: 1.1.0
+ react: 19.2.5
+ tslib: 2.8.1
+ optionalDependencies:
+ '@types/react': 19.2.14
+
dependencies:
react: 19.2.5
diff --git a/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb
index fda47cf260..1220d56366 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb
@@ -43,10 +43,15 @@ module Spree
return @collection if @collection.present?
filters = params[:q]&.to_unsafe_h || params[:q] || {}
+ # `q[search]` is the global text-search predicate; pass it through
+ # the provider's `query` arg so it invokes `Product.search` rather
+ # than being treated as a Ransack predicate (which gets stripped
+ # by the provider's filter sanitizer).
+ query = filters['search'] || filters[:search]
result = search_provider.search_and_filter(
scope: scope.includes(collection_includes).preload_associations_lazily.accessible_by(current_ability, :show),
- query: nil,
+ query: query,
filters: filters,
sort: sort_param,
page: page,
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb
index caa6984eb6..6c7b669eb2 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb
@@ -46,6 +46,43 @@ RSpec.describe Spree::Api::V3::Admin::OrdersController, type: :controller do
end
end
+ context 'with q[search] (full-text search)' do
+ # Factories auto-attach a user and a `before_create :link_by_email`
+ # callback resets `email` from `user.email`. Pass `user: nil` so our
+ # explicit email sticks for the email-match assertion.
+ let!(:matching_order) do
+ create(:order, store: store, state: 'cart', user: nil, email: '[email protected]')
+ end
+ let!(:non_matching_order) do
+ create(:order, store: store, state: 'cart', user: nil, email: '[email protected]')
+ end
+
+ it 'matches by order number substring' do
+ substring = matching_order.number[1..6] # 'R' + 6 chars is unique enough to not collide
+ get :index, params: { q: { search: substring } }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ ids = json_response['data'].map { |o| o['id'] }
+ expect(ids).to include(matching_order.prefixed_id)
+ end
+
+ it 'matches by exact email' do
+ get :index, params: { q: { search: '[email protected]' } }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ ids = json_response['data'].map { |o| o['id'] }
+ expect(ids).to include(matching_order.prefixed_id)
+ expect(ids).not_to include(non_matching_order.prefixed_id)
+ end
+
+ it 'returns no results when nothing matches' do
+ get :index, params: { q: { search: 'xqzwkj-no-such-order' } }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['data']).to be_empty
+ end
+ end
+
context 'without authentication' do
let(:headers) { {} }
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb
index e9dbf19176..bbaebaae91 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb
@@ -47,6 +47,38 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller do
end
end
+ context 'with q[search] (full-text search)' do
+ let!(:matching_product) { create(:product, name: 'Espresso Machine', stores: [store]) }
+ let!(:non_matching_product) { create(:product, name: 'Garden Hose', stores: [store]) }
+
+ it 'matches by product name' do
+ get :index, params: { q: { search: 'Espresso' } }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ ids = json_response['data'].map { |p| p['id'] }
+ expect(ids).to include(matching_product.prefixed_id)
+ expect(ids).not_to include(non_matching_product.prefixed_id)
+ end
+
+ it 'matches by master variant SKU' do
+ matching_product.master.update!(sku: 'ESPRESSO-PRO-2026')
+
+ get :index, params: { q: { search: 'ESPRESSO-PRO' } }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ ids = json_response['data'].map { |p| p['id'] }
+ expect(ids).to include(matching_product.prefixed_id)
+ expect(ids).not_to include(non_matching_product.prefixed_id)
+ end
+
+ it 'returns no results when nothing matches' do
+ get :index, params: { q: { search: 'xqzwkj-no-such-product' } }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['data']).to be_empty
+ end
+ end
+
context 'with sorting' do
let!(:second_product) { create(:product, name: 'Alpha Product', stores: [store]) }
diff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rb
index 514a16f575..72d28bc483 100644
--- a/spree/core/app/models/spree/order.rb
+++ b/spree/core/app/models/spree/order.rb
@@ -109,7 +109,7 @@ module Spree
completed_at email number state status payment_state shipment_state
total item_total item_count considered_risky channel
]
- self.whitelisted_ransackable_scopes = %w[complete incomplete refunded partially_refunded multi_search]
+ self.whitelisted_ransackable_scopes = %w[complete incomplete refunded partially_refunded search multi_search]
attr_reader :coupon_code
attr_accessor :temporary_address