The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Move searchable item component out
Terry Sutton4fb69fc38221
diff --git a/packages/ui/src/components/Command/SearchOnlyItem.tsx b/packages/ui/src/components/Command/SearchOnlyItem.tsxnew file mode 100644index 00000000000..33f43ff78cc--- /dev/null+++ b/packages/ui/src/components/Command/SearchOnlyItem.tsx@@ -0,0 +1,11 @@+import { useCommandState } from 'cmdk-supabase'+import React from 'react'+import { CommandItem } from './Command.utils'++export default function SearchOnlyItem({ children, isSubItem, ...props }: any) {+ const search = useCommandState((state) => state.search)+ // if search is empty & items is marked as a subItem, don't show it+ // ie: only show these items in search results, not top level+ if (!search && isSubItem) return null+ return <CommandItem {...props}>{children}</CommandItem>+}diff --git a/packages/ui/src/components/Command/SearchableStudioItems.tsx b/packages/ui/src/components/Command/SearchableStudioItems.tsxnew file mode 100644index 00000000000..6e0f89557d6--- /dev/null+++ b/packages/ui/src/components/Command/SearchableStudioItems.tsx@@ -0,0 +1,34 @@+import React from 'react'+import { CommandGroup } from './Command.utils'+import SearchOnlyItem from './SearchOnlyItem'+import { useRouter } from 'next/router'++import sharedItems from './utils/shared-nav-items.json'+import { IconSearch } from '../Icon/icons/IconSearch'+sharedItems.tools.map((item) => {+ if (item.subItems) {+ item.subItems.map((subItem) => {+ console.log('sharedItems', subItem.label)+ })+ }+})+export default function SearchableStudioItems() {+ const router = useRouter()+ return (+ <CommandGroup heading="Find">+ {sharedItems.tools+ .filter((item) => item.subItems) // filter items with subItems+ .flatMap((item) =>+ item.subItems?.map((subItem) => (+ <SearchOnlyItem+ key={subItem.url}+ isSubItem={true}+ onSelect={() => router.push(subItem.url)}+ >+ {subItem.label}+ </SearchOnlyItem>+ ))+ )}+ </CommandGroup>+ )+}