The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: command menu v2 ui components (#27761)
Charis1b89fa0b5cd2
diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsxindex ac171675bb0..35186ae216b 100644--- a/apps/design-system/__registry__/index.tsx+++ b/apps/design-system/__registry__/index.tsx@@ -489,6 +489,94 @@ export const Index: Record<string, any> = {subcategory: "undefined",chunks: []},+ "commandmenu-demo": {+ name: "commandmenu-demo",+ type: "components:example",+ registryDependencies: ["commandmenu"],+ component: React.lazy(() => import("@/registry/default/example/commandmenu-demo")),+ source: "",+ files: ["registry/default/example/commandmenu-demo.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "commandmenu-badge": {+ name: "commandmenu-badge",+ type: "components:example",+ registryDependencies: ["commandmenu"],+ component: React.lazy(() => import("@/registry/default/example/commandmenu-badge")),+ source: "",+ files: ["registry/default/example/commandmenu-badge.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "commandmenu-icon": {+ name: "commandmenu-icon",+ type: "components:example",+ registryDependencies: ["commandmenu"],+ component: React.lazy(() => import("@/registry/default/example/commandmenu-icon")),+ source: "",+ files: ["registry/default/example/commandmenu-icon.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "commandmenu-hidden": {+ name: "commandmenu-hidden",+ type: "components:example",+ registryDependencies: ["commandmenu"],+ component: React.lazy(() => import("@/registry/default/example/commandmenu-hidden")),+ source: "",+ files: ["registry/default/example/commandmenu-hidden.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "commandmenu-force": {+ name: "commandmenu-force",+ type: "components:example",+ registryDependencies: ["commandmenu"],+ component: React.lazy(() => import("@/registry/default/example/commandmenu-force")),+ source: "",+ files: ["registry/default/example/commandmenu-force.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "commandmenu-conditional": {+ name: "commandmenu-conditional",+ type: "components:example",+ registryDependencies: ["commandmenu"],+ component: React.lazy(() => import("@/registry/default/example/commandmenu-conditional")),+ source: "",+ files: ["registry/default/example/commandmenu-conditional.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "commandmenu-subpage": {+ name: "commandmenu-subpage",+ type: "components:example",+ registryDependencies: ["commandmenu"],+ component: React.lazy(() => import("@/registry/default/example/commandmenu-subpage")),+ source: "",+ files: ["registry/default/example/commandmenu-subpage.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "commandmenu-subpage-custom": {+ name: "commandmenu-subpage-custom",+ type: "components:example",+ registryDependencies: ["commandmenu"],+ component: React.lazy(() => import("@/registry/default/example/commandmenu-subpage-custom")),+ source: "",+ files: ["registry/default/example/commandmenu-subpage-custom.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },"context-menu-demo": {name: "context-menu-demo",type: "components:example",diff --git a/apps/design-system/config/docs.ts b/apps/design-system/config/docs.tsindex 6a3cad91db9..f2c5ee94b8a 100644--- a/apps/design-system/config/docs.ts+++ b/apps/design-system/config/docs.ts@@ -198,6 +198,11 @@ export const docsConfig: DocsConfig = {href: '/docs/components/command',items: [],},+ {+ title: 'Command Menu (cmdk)',+ href: '/docs/components/commandmenu',+ items: [],+ },{title: 'Context Menu',href: '/docs/components/context-menu',diff --git a/apps/design-system/content/docs/components/commandmenu.mdx b/apps/design-system/content/docs/components/commandmenu.mdxnew file mode 100644index 00000000000..e4fdd9801df--- /dev/null+++ b/apps/design-system/content/docs/components/commandmenu.mdx@@ -0,0 +1,111 @@+---+title: Command Menu (cmdk)+description: A central command menu that acts as a control center with searchable actions.+component: true+---++The example below uses `cmd-j` as the shortcut instead of `cmd-k` to avoid clashing with this site's native command menu.++<ComponentPreview name="commandmenu-demo" peekCode wide />++## Usage++```tsx+import {+ CommandInput,+ CommandList,+ CommandMenu,+ CommandMenuTrigger as CommandMenuTriggerPrimitive,+ CommandProvider,+ useRegisterCommands,+} from 'ui-patterns/CommandMenu'+```++```tsx+function Commands() {+ useRegisterCommands('Action commands', [+ {+ id: 'alert',+ name: 'Alert',+ action: () => alert('You triggered a command'),+ },+ ])+ useRegisterCommands('Route commands', [+ {+ id: 'supabase-website',+ name: 'Go to Supabase website',+ route: 'https://supabase.com',+ },+ ])++ return null+}++function CommandMenuTrigger() {+ return (+ <CommandMenuTriggerPrimitive>+ <Button>Open command menu</Button>+ </CommandMenuTriggerPrimitive>+ )+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="j">+ <Commands />+ <CommandMenu trigger={<CommandMenuTrigger />}>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ </CommandProvider>+ )+}+```++## Examples++To avoid keyboard shortcuts clashing wildly, the open shortcut is disabled for the following examples. Use the button to open the example previews.++### With experimental badge++You can add an experimental badge to any command item:++<ComponentPreview name="commandmenu-badge" />++### With icon++You can add an icon to any command item:++<ComponentPreview name="commandmenu-icon" />++### With default hidden++You can hide any command menu item unless it matches an active search query. Try searching for `open sesame` here:++<ComponentPreview name="commandmenu-hidden" />++### With force-mount++You can force-mount any command item (force it to always show, regardless of search query). You can also force-mount an entire section.++<ComponentPreview name="commandmenu-force" />++### With conditional commands++You can use the dependencies (`deps`) array on the register command options to change the registered commands in response to state changes.++Dependency equality is calculated using the `lodash` [isEqual](https://lodash.com/docs/4.17.15#isEqual) function, so you may need suitable use of `useCallback` or `useMemo` to maintain or break equality.++<ComponentPreview name="commandmenu-conditional" />++### With subpage++You can define a subpage of commands:++<ComponentPreview name="commandmenu-subpage" />++### With arbitrary subpage++You can define an arbitrary subpage that loads a custom component:++<ComponentPreview name="commandmenu-subpage-custom" />diff --git a/apps/design-system/registry/default/example/commandmenu-badge.tsx b/apps/design-system/registry/default/example/commandmenu-badge.tsxnew file mode 100644index 00000000000..309f8cd2afa--- /dev/null+++ b/apps/design-system/registry/default/example/commandmenu-badge.tsx@@ -0,0 +1,42 @@+import { Button } from '@ui/components/shadcn/ui/button'+import {+ BadgeExperimental,+ CommandInput,+ CommandList,+ CommandMenu,+ CommandProvider,+ useRegisterCommands,+ useSetCommandMenuOpen,+} from 'ui-patterns/CommandMenu'++function Commands() {+ useRegisterCommands('Commands', [+ {+ id: 'experimental',+ name: 'Experimental',+ action: () => alert('You triggered an experimental command'),+ badge: () => <BadgeExperimental />,+ },+ ])++ return null+}++function CommandMenuTrigger() {+ const setOpen = useSetCommandMenuOpen()++ return <Button onClick={() => setOpen(true)}>Open command menu</Button>+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="">+ <CommandMenuTrigger />+ <Commands />+ <CommandMenu>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ </CommandProvider>+ )+}diff --git a/apps/design-system/registry/default/example/commandmenu-conditional.tsx b/apps/design-system/registry/default/example/commandmenu-conditional.tsxnew file mode 100644index 00000000000..4d8159b3573--- /dev/null+++ b/apps/design-system/registry/default/example/commandmenu-conditional.tsx@@ -0,0 +1,70 @@+import { Button } from '@ui/components/shadcn/ui/button'+import { useMemo, useState } from 'react'+import {+ CommandInput,+ CommandList,+ CommandMenu,+ CommandMenuTrigger as CommandMenuTriggerPrimitive,+ CommandProvider,+ useRegisterCommands,+} from 'ui-patterns/CommandMenu'++function Commands() {+ const [activeCommand, setActiveCommand] = useState(1)++ const toggleCommands = () => setActiveCommand((state) => (state === 1 ? 2 : 1))++ const commandOne = useMemo(+ () => [+ {+ id: 'one',+ name: 'One',+ action: () => alert('One'),+ },+ ],+ []+ )++ const commandTwo = useMemo(+ () => [+ {+ id: 'two',+ name: 'Two',+ action: () => alert('Two'),+ },+ ],+ []+ )++ const command = activeCommand === 1 ? commandOne : commandTwo++ useRegisterCommands('Commands', command, { deps: [command] })++ return (+ <Button onClick={toggleCommands}>+ {activeCommand === 1 ? 'Change command to command two' : 'Change command to command one'}+ </Button>+ )+}++function CommandMenuTrigger() {+ return (+ <CommandMenuTriggerPrimitive>+ <Button>Open command menu</Button>+ </CommandMenuTriggerPrimitive>+ )+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="">+ <div className="flex flex-col gap-2">+ <CommandMenu trigger={<CommandMenuTrigger />}>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ <Commands />+ </div>+ </CommandProvider>+ )+}diff --git a/apps/design-system/registry/default/example/commandmenu-demo.tsx b/apps/design-system/registry/default/example/commandmenu-demo.tsxnew file mode 100644index 00000000000..a1cfec496cd--- /dev/null+++ b/apps/design-system/registry/default/example/commandmenu-demo.tsx@@ -0,0 +1,48 @@+import { Button } from '@ui/components/shadcn/ui/button'+import {+ CommandInput,+ CommandList,+ CommandMenu,+ CommandMenuTrigger as CommandMenuTriggerPrimitive,+ CommandProvider,+ useRegisterCommands,+} from 'ui-patterns/CommandMenu'++function Commands() {+ useRegisterCommands('Action commands', [+ {+ id: 'alert',+ name: 'Alert',+ action: () => alert('You triggered a command'),+ },+ ])+ useRegisterCommands('Route commands', [+ {+ id: 'supabase-website',+ name: 'Go to Supabase website',+ route: 'https://supabase.com',+ },+ ])++ return null+}++function CommandMenuTrigger() {+ return (+ <CommandMenuTriggerPrimitive>+ <Button>Open command menu</Button>+ </CommandMenuTriggerPrimitive>+ )+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="j">+ <Commands />+ <CommandMenu trigger={<CommandMenuTrigger />}>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ </CommandProvider>+ )+}diff --git a/apps/design-system/registry/default/example/commandmenu-force.tsx b/apps/design-system/registry/default/example/commandmenu-force.tsxnew file mode 100644index 00000000000..ac475beb238--- /dev/null+++ b/apps/design-system/registry/default/example/commandmenu-force.tsx@@ -0,0 +1,60 @@+import { Button } from '@ui/components/shadcn/ui/button'+import {+ CommandInput,+ CommandList,+ CommandMenu,+ CommandMenuTrigger as CommandMenuTriggerPrimitive,+ CommandProvider,+ useRegisterCommands,+} from 'ui-patterns/CommandMenu'++function Commands() {+ useRegisterCommands('Commands', [+ {+ id: 'forced',+ name: 'Force-mounted',+ action: () => alert("This command always shows even if it doesn't match the search query"),+ forceMount: true,+ },+ {+ id: 'not-forced',+ name: 'Not force-mounted',+ action: () => alert("This command will disappear if it doesn't match the search query"),+ },+ ])+ useRegisterCommands(+ 'Force-mounted section',+ [+ {+ id: 'example',+ name: 'An example',+ action: () => alert('This entire section is force-mounted'),+ },+ ],+ {+ forceMountSection: true,+ }+ )++ return null+}++function CommandMenuTrigger() {+ return (+ <CommandMenuTriggerPrimitive>+ <Button>Open command menu</Button>+ </CommandMenuTriggerPrimitive>+ )+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="">+ <Commands />+ <CommandMenu trigger={<CommandMenuTrigger />}>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ </CommandProvider>+ )+}diff --git a/apps/design-system/registry/default/example/commandmenu-hidden.tsx b/apps/design-system/registry/default/example/commandmenu-hidden.tsxnew file mode 100644index 00000000000..a9d60c69025--- /dev/null+++ b/apps/design-system/registry/default/example/commandmenu-hidden.tsx@@ -0,0 +1,47 @@+import { Button } from '@ui/components/shadcn/ui/button'+import {+ CommandInput,+ CommandList,+ CommandMenu,+ CommandMenuTrigger as CommandMenuTriggerPrimitive,+ CommandProvider,+ useRegisterCommands,+} from 'ui-patterns/CommandMenu'++function Commands() {+ useRegisterCommands('Commands', [+ {+ id: 'shown',+ name: 'shown',+ action: () => alert('This command is shown by default'),+ },+ {+ id: 'hidden',+ name: 'open sesame',+ action: () => alert('This command is only shown when searched'),+ defaultHidden: true,+ },+ ])++ return null+}++function CommandMenuTrigger() {+ return (+ <CommandMenuTriggerPrimitive>+ <Button>Open command menu</Button>+ </CommandMenuTriggerPrimitive>+ )+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="">+ <Commands />+ <CommandMenu trigger={<CommandMenuTrigger />}>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ </CommandProvider>+ )+}diff --git a/apps/design-system/registry/default/example/commandmenu-icon.tsx b/apps/design-system/registry/default/example/commandmenu-icon.tsxnew file mode 100644index 00000000000..c877f83e450--- /dev/null+++ b/apps/design-system/registry/default/example/commandmenu-icon.tsx@@ -0,0 +1,43 @@+import { Button } from '@ui/components/shadcn/ui/button'+import { Github } from 'lucide-react'+import {+ CommandInput,+ CommandList,+ CommandMenu,+ CommandMenuTrigger as CommandMenuTriggerPrimitive,+ CommandProvider,+ useRegisterCommands,+} from 'ui-patterns/CommandMenu'++function Commands() {+ useRegisterCommands('Commands', [+ {+ id: 'github',+ name: 'Go to repo',+ route: 'https://github.com/supabase/supabase',+ icon: () => <Github />,+ },+ ])++ return null+}++function CommandMenuTrigger() {+ return (+ <CommandMenuTriggerPrimitive>+ <Button>Open command menu</Button>+ </CommandMenuTriggerPrimitive>+ )+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="">+ <Commands />+ <CommandMenu trigger={<CommandMenuTrigger />}>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ </CommandProvider>+ )+}diff --git a/apps/design-system/registry/default/example/commandmenu-subpage-custom.tsx b/apps/design-system/registry/default/example/commandmenu-subpage-custom.tsxnew file mode 100644index 00000000000..0cd74c1d7a1--- /dev/null+++ b/apps/design-system/registry/default/example/commandmenu-subpage-custom.tsx@@ -0,0 +1,65 @@+import { Button } from '@ui/components/shadcn/ui/button'+import { useMemo } from 'react'+import {+ Breadcrumb,+ CommandInput,+ CommandList,+ CommandMenu,+ CommandMenuTrigger as CommandMenuTriggerPrimitive,+ CommandProvider,+ PageType,+ useRegisterCommands,+ useRegisterPage,+ useSetPage,+} from 'ui-patterns/CommandMenu'++function CustomSubpage() {+ return (+ <div className="p-5">+ <Breadcrumb className="mb-4" />+ <h1 className="font-heading text-xl mb-4 text-foreground">Custom subpage</h1>+ <p className="text-foreground-light text-sm">+ Here is a custom subpage built from a component that you provide.+ </p>+ </div>+ )+}++function Commands() {+ const setPage = useSetPage()++ useRegisterPage('Subpage', {+ type: PageType.Component,+ component: CustomSubpage,+ })++ useRegisterCommands('Commands', [+ {+ id: 'subpage',+ name: 'Go to subpage',+ action: () => setPage('Subpage'),+ },+ ])++ return null+}++function CommandMenuTrigger() {+ return (+ <CommandMenuTriggerPrimitive>+ <Button>Open command menu</Button>+ </CommandMenuTriggerPrimitive>+ )+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="">+ <Commands />+ <CommandMenu trigger={<CommandMenuTrigger />}>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ </CommandProvider>+ )+}diff --git a/apps/design-system/registry/default/example/commandmenu-subpage.tsx b/apps/design-system/registry/default/example/commandmenu-subpage.tsxnew file mode 100644index 00000000000..ef842b43143--- /dev/null+++ b/apps/design-system/registry/default/example/commandmenu-subpage.tsx@@ -0,0 +1,73 @@+import { Button } from '@ui/components/shadcn/ui/button'+import { useMemo } from 'react'+import {+ CommandInput,+ CommandList,+ CommandMenu,+ CommandMenuTrigger as CommandMenuTriggerPrimitive,+ CommandProvider,+ PageType,+ useRegisterCommands,+ useRegisterPage,+ useSetPage,+} from 'ui-patterns/CommandMenu'++function Commands() {+ const setPage = useSetPage()++ const commands = useMemo(+ () => [+ {+ id: 'subcommand',+ name: 'Subcommand',+ action: () => alert('Triggered from subpage'),+ },+ ],+ []+ )++ useRegisterPage(+ 'Subpage',+ {+ type: PageType.Commands,+ sections: [+ {+ id: 'subpage',+ name: 'Subpage',+ commands,+ },+ ],+ },+ { deps: [commands] }+ )++ useRegisterCommands('Commands', [+ {+ id: 'subpage',+ name: 'Go to subpage',+ action: () => setPage('Subpage'),+ },+ ])++ return null+}++function CommandMenuTrigger() {+ return (+ <CommandMenuTriggerPrimitive>+ <Button>Open command menu</Button>+ </CommandMenuTriggerPrimitive>+ )+}++export default function CommandMenuDemo() {+ return (+ <CommandProvider openKey="">+ <Commands />+ <CommandMenu trigger={<CommandMenuTrigger />}>+ <CommandInput />+ <CommandList />+ </CommandMenu>+ </CommandProvider>+ )+}diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.tsindex 035003469da..51be42a11c6 100644--- a/apps/design-system/registry/examples.ts+++ b/apps/design-system/registry/examples.ts@@ -331,6 +331,54 @@ export const examples: Registry = [registryDependencies: ['command', 'dialog'],files: ['example/command-dialog.tsx'],},+ {+ name: 'commandmenu-demo',+ type: 'components:example',+ registryDependencies: ['commandmenu'],+ files: ['example/commandmenu-demo.tsx'],+ },+ {+ name: 'commandmenu-badge',+ type: 'components:example',+ registryDependencies: ['commandmenu'],+ files: ['example/commandmenu-badge.tsx'],+ },+ {+ name: 'commandmenu-icon',+ type: 'components:example',+ registryDependencies: ['commandmenu'],+ files: ['example/commandmenu-icon.tsx'],+ },+ {+ name: 'commandmenu-hidden',+ type: 'components:example',+ registryDependencies: ['commandmenu'],+ files: ['example/commandmenu-hidden.tsx'],+ },+ {+ name: 'commandmenu-force',+ type: 'components:example',+ registryDependencies: ['commandmenu'],+ files: ['example/commandmenu-force.tsx'],+ },+ {+ name: 'commandmenu-conditional',+ type: 'components:example',+ registryDependencies: ['commandmenu'],+ files: ['example/commandmenu-conditional.tsx'],+ },+ {+ name: 'commandmenu-subpage',+ type: 'components:example',+ registryDependencies: ['commandmenu'],+ files: ['example/commandmenu-subpage.tsx'],+ },+ {+ name: 'commandmenu-subpage-custom',+ type: 'components:example',+ registryDependencies: ['commandmenu'],+ files: ['example/commandmenu-subpage-custom.tsx'],+ },{name: 'context-menu-demo',type: 'components:example',diff --git a/package-lock.json b/package-lock.jsonindex 800de5b7d57..191997e238d 100644--- a/package-lock.json+++ b/package-lock.json@@ -2990,9 +2990,9 @@}},"node_modules/@adobe/css-tools": {- "version": "4.3.2",- "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.3.2.tgz",- "integrity": "sha512-DA5a1C0gD/pLOvhv33YMrbf2FK3oUzwNl9oOJqE4XVjuEtt6XIakRcsd7eLiOSPkp1kTRQGICTA8cKra/vFbjw==",+ "version": "4.4.0",+ "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.0.tgz",+ "integrity": "sha512-Ff9+ksdQQB3rMncgqDK78uLznstjyfIf2Arnh22pW8kBpLs6rpKDwgnZT46hin5Hl1WzazzK64DOrhSwYpS7bQ==","dev": true},"node_modules/@alloc/quick-lru": {@@ -3006,11 +3006,12 @@}},"node_modules/@ampproject/remapping": {- "version": "2.2.1",- "license": "Apache-2.0",+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",+ "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==","dependencies": {- "@jridgewell/gen-mapping": "^0.3.0",- "@jridgewell/trace-mapping": "^0.3.9"+ "@jridgewell/gen-mapping": "^0.3.5",+ "@jridgewell/trace-mapping": "^0.3.24"},"engines": {"node": ">=6.0.0"@@ -13913,12 +13914,12 @@}},"node_modules/@testing-library/jest-dom": {- "version": "6.4.5",- "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.5.tgz",- "integrity": "sha512-AguB9yvTXmCnySBP1lWjfNNUwpbElsaQ567lt2VdGqAdHtpieLgjmcVyv1q7PMIvLbgpDdkWV5Ydv3FEejyp2A==",+ "version": "6.4.6",+ "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.6.tgz",+ "integrity": "sha512-8qpnGVincVDLEcQXWaHOf6zmlbwTKc6Us6PPu4CRnPXCzo2OGBS5cwgMMOWdxDpEz1mkbvXHpEy99M5Yvt682w==","dev": true,"dependencies": {- "@adobe/css-tools": "^4.3.2",+ "@adobe/css-tools": "^4.4.0","@babel/runtime": "^7.9.2","aria-query": "^5.0.0","chalk": "^3.0.0",@@ -15295,6 +15296,18 @@"url": "https://opencollective.com/vitest"}},+ "node_modules/@vitest/pretty-format": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.0.3.tgz",+ "integrity": "sha512-URM4GLsB2xD37nnTyvf6kfObFafxmycCL8un3OC9gaCs5cti2u+5rJdIflZ2fUJUen4NbvF6jCufwViAFLvz1g==",+ "dev": true,+ "dependencies": {+ "tinyrainbow": "^1.2.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },"node_modules/@vitest/runner": {"version": "1.6.0","resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-1.6.0.tgz",@@ -21449,8 +21462,9 @@}},"node_modules/flatted": {- "version": "3.2.9",- "license": "ISC"+ "version": "3.3.1",+ "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz",+ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw=="},"node_modules/for-each": {"version": "0.3.3",@@ -39771,9 +39785,9 @@"license": "MIT"},"node_modules/tinybench": {- "version": "2.6.0",- "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.6.0.tgz",- "integrity": "sha512-N8hW3PG/3aOoZAN5V/NSAEDz0ZixDSSt5b/a05iqtpgfLWMSVuCo7w0k2vVvEjdrIoeGqZzweX2WlyioNIHchA=="+ "version": "2.8.0",+ "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.8.0.tgz",+ "integrity": "sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw=="},"node_modules/tinycolor2": {"version": "1.6.0",@@ -39788,6 +39802,15 @@"node": ">=14.0.0"}},+ "node_modules/tinyrainbow": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz",+ "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==",+ "dev": true,+ "engines": {+ "node": ">=14.0.0"+ }+ },"node_modules/tinyspy": {"version": "2.2.1","resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-2.2.1.tgz",@@ -43385,6 +43408,7 @@"react-markdown": "^9.0.1","react-syntax-highlighter": "^15.5.0","react-tooltip": "*",+ "react-use": "^17.5.0","reactflow": "*","remark-gfm": "^4.0.0","sql-formatter": "^15.3.1",@@ -43395,6 +43419,7 @@"devDependencies": {"@supabase/auth-helpers-react": "^0.4.2","@testing-library/dom": "^10.1.0",+ "@testing-library/jest-dom": "^6.4.6","@testing-library/react": "^16.0.0","@testing-library/user-event": "^13.5.0","@types/common-tags": "^1.8.4",@@ -43402,9 +43427,8 @@"@types/react": "^18.3.3","@types/react-dom": "^18.3.0","api-types": "*",- "jest": "^29.7.0",- "jest-environment-jsdom": "^29.7.0",- "ts-jest": "^29.1.2"+ "next-router-mock": "^0.9.13",+ "vitest": "^2.0.3"},"peerDependencies": {"next": "*",@@ -43471,6 +43495,98 @@"resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz","integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="},+ "packages/ui-patterns/node_modules/@vitest/expect": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.0.3.tgz",+ "integrity": "sha512-X6AepoOYePM0lDNUPsGXTxgXZAl3EXd0GYe/MZyVE4HzkUqyUVC6S3PrY5mClDJ6/7/7vALLMV3+xD/Ko60Hqg==",+ "dev": true,+ "dependencies": {+ "@vitest/spy": "2.0.3",+ "@vitest/utils": "2.0.3",+ "chai": "^5.1.1",+ "tinyrainbow": "^1.2.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "packages/ui-patterns/node_modules/@vitest/runner": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.0.3.tgz",+ "integrity": "sha512-EmSP4mcjYhAcuBWwqgpjR3FYVeiA4ROzRunqKltWjBfLNs1tnMLtF+qtgd5ClTwkDP6/DGlKJTNa6WxNK0bNYQ==",+ "dev": true,+ "dependencies": {+ "@vitest/utils": "2.0.3",+ "pathe": "^1.1.2"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "packages/ui-patterns/node_modules/@vitest/snapshot": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.0.3.tgz",+ "integrity": "sha512-6OyA6v65Oe3tTzoSuRPcU6kh9m+mPL1vQ2jDlPdn9IQoUxl8rXhBnfICNOC+vwxWY684Vt5UPgtcA2aPFBb6wg==",+ "dev": true,+ "dependencies": {+ "@vitest/pretty-format": "2.0.3",+ "magic-string": "^0.30.10",+ "pathe": "^1.1.2"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "packages/ui-patterns/node_modules/@vitest/spy": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.0.3.tgz",+ "integrity": "sha512-sfqyAw/ypOXlaj4S+w8689qKM1OyPOqnonqOc9T91DsoHbfN5mU7FdifWWv3MtQFf0lEUstEwR9L/q/M390C+A==",+ "dev": true,+ "dependencies": {+ "tinyspy": "^3.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "packages/ui-patterns/node_modules/@vitest/ui": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-2.0.3.tgz",+ "integrity": "sha512-UAkzHk5veR3NRF7BNUxWlLly7Cw7H+wzP3+eiMIVeKo3Md33Ey20rYsNQn/9McIqOeO02tMzqHhpThmjk1yRzw==",+ "dev": true,+ "optional": true,+ "peer": true,+ "dependencies": {+ "@vitest/utils": "2.0.3",+ "fast-glob": "^3.3.2",+ "fflate": "^0.8.2",+ "flatted": "^3.3.1",+ "pathe": "^1.1.2",+ "sirv": "^2.0.4",+ "tinyrainbow": "^1.2.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ },+ "peerDependencies": {+ "vitest": "2.0.3"+ }+ },+ "packages/ui-patterns/node_modules/@vitest/utils": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.0.3.tgz",+ "integrity": "sha512-c/UdELMuHitQbbc/EVctlBaxoYAwQPQdSNwv7z/vHyBKy2edYZaFgptE27BRueZB7eW8po+cllotMNTDpL3HWg==",+ "dev": true,+ "dependencies": {+ "@vitest/pretty-format": "2.0.3",+ "estree-walker": "^3.0.3",+ "loupe": "^3.1.1",+ "tinyrainbow": "^1.2.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },"packages/ui-patterns/node_modules/ansi-styles": {"version": "4.3.0","resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",@@ -43491,6 +43607,31 @@"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz","integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="},+ "packages/ui-patterns/node_modules/assertion-error": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",+ "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",+ "dev": true,+ "engines": {+ "node": ">=12"+ }+ },+ "packages/ui-patterns/node_modules/chai": {+ "version": "5.1.1",+ "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz",+ "integrity": "sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==",+ "dev": true,+ "dependencies": {+ "assertion-error": "^2.0.1",+ "check-error": "^2.1.1",+ "deep-eql": "^5.0.1",+ "loupe": "^3.1.0",+ "pathval": "^2.0.0"+ },+ "engines": {+ "node": ">=12"+ }+ },"packages/ui-patterns/node_modules/chalk": {"version": "4.1.2","resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",@@ -43507,6 +43648,64 @@"url": "https://github.com/chalk/chalk?sponsor=1"}},+ "packages/ui-patterns/node_modules/check-error": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz",+ "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==",+ "dev": true,+ "engines": {+ "node": ">= 16"+ }+ },+ "packages/ui-patterns/node_modules/debug": {+ "version": "4.3.5",+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz",+ "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==",+ "dev": true,+ "dependencies": {+ "ms": "2.1.2"+ },+ "engines": {+ "node": ">=6.0"+ },+ "peerDependenciesMeta": {+ "supports-color": {+ "optional": true+ }+ }+ },+ "packages/ui-patterns/node_modules/deep-eql": {+ "version": "5.0.2",+ "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz",+ "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==",+ "dev": true,+ "engines": {+ "node": ">=6"+ }+ },+ "packages/ui-patterns/node_modules/execa": {+ "version": "8.0.1",+ "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz",+ "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==",+ "dev": true,+ "dependencies": {+ "cross-spawn": "^7.0.3",+ "get-stream": "^8.0.1",+ "human-signals": "^5.0.0",+ "is-stream": "^3.0.0",+ "merge-stream": "^2.0.0",+ "npm-run-path": "^5.1.0",+ "onetime": "^6.0.0",+ "signal-exit": "^4.1.0",+ "strip-final-newline": "^3.0.0"+ },+ "engines": {+ "node": ">=16.17"+ },+ "funding": {+ "url": "https://github.com/sindresorhus/execa?sponsor=1"+ }+ },"packages/ui-patterns/node_modules/framer-motion": {"version": "11.1.9","resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.1.9.tgz",@@ -43531,6 +43730,18 @@}}},+ "packages/ui-patterns/node_modules/get-stream": {+ "version": "8.0.1",+ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz",+ "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==",+ "dev": true,+ "engines": {+ "node": ">=16"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },"packages/ui-patterns/node_modules/has-flag": {"version": "4.0.0","resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",@@ -43540,6 +43751,45 @@"node": ">=8"}},+ "packages/ui-patterns/node_modules/human-signals": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz",+ "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==",+ "dev": true,+ "engines": {+ "node": ">=16.17.0"+ }+ },+ "packages/ui-patterns/node_modules/is-stream": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz",+ "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==",+ "dev": true,+ "engines": {+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "packages/ui-patterns/node_modules/loupe": {+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz",+ "integrity": "sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==",+ "dev": true,+ "dependencies": {+ "get-func-name": "^2.0.1"+ }+ },+ "packages/ui-patterns/node_modules/magic-string": {+ "version": "0.30.10",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.10.tgz",+ "integrity": "sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==",+ "dev": true,+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.4.15"+ }+ },"packages/ui-patterns/node_modules/mdast-util-to-hast": {"version": "13.1.0","resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.1.0.tgz",@@ -43610,6 +43860,69 @@}]},+ "packages/ui-patterns/node_modules/mimic-fn": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",+ "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==",+ "dev": true,+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "packages/ui-patterns/node_modules/npm-run-path": {+ "version": "5.3.0",+ "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz",+ "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==",+ "dev": true,+ "dependencies": {+ "path-key": "^4.0.0"+ },+ "engines": {+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "packages/ui-patterns/node_modules/onetime": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz",+ "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==",+ "dev": true,+ "dependencies": {+ "mimic-fn": "^4.0.0"+ },+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "packages/ui-patterns/node_modules/path-key": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz",+ "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==",+ "dev": true,+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "packages/ui-patterns/node_modules/pathval": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz",+ "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==",+ "dev": true,+ "engines": {+ "node": ">= 14.16"+ }+ },"packages/ui-patterns/node_modules/react-markdown": {"version": "9.0.1","resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-9.0.1.tgz",@@ -43696,6 +44009,18 @@"sql-formatter": "bin/sql-formatter-cli.cjs"}},+ "packages/ui-patterns/node_modules/strip-final-newline": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz",+ "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==",+ "dev": true,+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },"packages/ui-patterns/node_modules/supports-color": {"version": "7.2.0","resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",@@ -43708,6 +44033,24 @@"node": ">=8"}},+ "packages/ui-patterns/node_modules/tinypool": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.0.tgz",+ "integrity": "sha512-KIKExllK7jp3uvrNtvRBYBWBOAXSX8ZvoaD8T+7KB/QHIuoJW3Pmr60zucywjAlMb5TeXUkcs/MWeWLu0qvuAQ==",+ "dev": true,+ "engines": {+ "node": "^18.0.0 || >=20.0.0"+ }+ },+ "packages/ui-patterns/node_modules/tinyspy": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.0.tgz",+ "integrity": "sha512-q5nmENpTHgiPVd1cJDDc9cVoYN5x4vCvwT3FMilvKPKneCBZAxn2YWQjDF0UMcE9k0Cay1gBiDfTMU0g+mPMQA==",+ "dev": true,+ "engines": {+ "node": ">=14.0.0"+ }+ },"packages/ui-patterns/node_modules/unified": {"version": "11.0.4","resolved": "https://registry.npmjs.org/unified/-/unified-11.0.4.tgz",@@ -43778,6 +44121,92 @@"url": "https://opencollective.com/unified"}},+ "packages/ui-patterns/node_modules/vite-node": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.0.3.tgz",+ "integrity": "sha512-14jzwMx7XTcMB+9BhGQyoEAmSl0eOr3nrnn+Z12WNERtOvLN+d2scbRUvyni05rT3997Bg+rZb47NyP4IQPKXg==",+ "dev": true,+ "dependencies": {+ "cac": "^6.7.14",+ "debug": "^4.3.5",+ "pathe": "^1.1.2",+ "tinyrainbow": "^1.2.0",+ "vite": "^5.0.0"+ },+ "bin": {+ "vite-node": "vite-node.mjs"+ },+ "engines": {+ "node": "^18.0.0 || >=20.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "packages/ui-patterns/node_modules/vitest": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.0.3.tgz",+ "integrity": "sha512-o3HRvU93q6qZK4rI2JrhKyZMMuxg/JRt30E6qeQs6ueaiz5hr1cPj+Sk2kATgQzMMqsa2DiNI0TIK++1ULx8Jw==",+ "dev": true,+ "dependencies": {+ "@ampproject/remapping": "^2.3.0",+ "@vitest/expect": "2.0.3",+ "@vitest/pretty-format": "^2.0.3",+ "@vitest/runner": "2.0.3",+ "@vitest/snapshot": "2.0.3",+ "@vitest/spy": "2.0.3",+ "@vitest/utils": "2.0.3",+ "chai": "^5.1.1",+ "debug": "^4.3.5",+ "execa": "^8.0.1",+ "magic-string": "^0.30.10",+ "pathe": "^1.1.2",+ "std-env": "^3.7.0",+ "tinybench": "^2.8.0",+ "tinypool": "^1.0.0",+ "tinyrainbow": "^1.2.0",+ "vite": "^5.0.0",+ "vite-node": "2.0.3",+ "why-is-node-running": "^2.2.2"+ },+ "bin": {+ "vitest": "vitest.mjs"+ },+ "engines": {+ "node": "^18.0.0 || >=20.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ },+ "peerDependencies": {+ "@edge-runtime/vm": "*",+ "@types/node": "^18.0.0 || >=20.0.0",+ "@vitest/browser": "2.0.3",+ "@vitest/ui": "2.0.3",+ "happy-dom": "*",+ "jsdom": "*"+ },+ "peerDependenciesMeta": {+ "@edge-runtime/vm": {+ "optional": true+ },+ "@types/node": {+ "optional": true+ },+ "@vitest/browser": {+ "optional": true+ },+ "@vitest/ui": {+ "optional": true+ },+ "happy-dom": {+ "optional": true+ },+ "jsdom": {+ "optional": true+ }+ }+ },"packages/ui/node_modules/@radix-ui/react-avatar": {"version": "1.0.4","license": "MIT",diff --git a/packages/common/hooks/useDragToClose.tsx b/packages/common/hooks/useDragToClose.tsxindex afa0596a400..fd510e0c3f8 100644--- a/packages/common/hooks/useDragToClose.tsx+++ b/packages/common/hooks/useDragToClose.tsx@@ -1,4 +1,4 @@-import React from 'react'+import React, { useCallback } from 'react'/*** Custom hook to enable closing bottom drawers by dragging down.@@ -14,19 +14,25 @@ const useDragToClose = ({const [currentY, setCurrentY] = React.useState(0)const ref = React.useRef<HTMLDivElement>(null)- const handleTouchStart = (e: React.TouchEvent<HTMLDivElement>) => {- setStartY(e.touches[0].clientY)- }+ const handleTouchStart = useCallback(+ (e: React.TouchEvent<HTMLDivElement>) => {+ setStartY(e.touches[0].clientY)+ },+ [setStartY]+ )- const handleTouchMove = (e: React.TouchEvent<HTMLDivElement>) => {- setCurrentY(e.touches[0].clientY)- const translateY = currentY - startY- if (translateY > 0 && ref.current) {- ref.current.style.transform = `translateY(${translateY}px)`- }- }+ const handleTouchMove = useCallback(+ (e: React.TouchEvent<HTMLDivElement>) => {+ setCurrentY(e.touches[0].clientY)+ const translateY = currentY - startY+ if (translateY > 0 && ref.current) {+ ref.current.style.transform = `translateY(${translateY}px)`+ }+ },+ [setCurrentY, startY, currentY]+ )- const handleTouchEnd = () => {+ const handleTouchEnd = useCallback(() => {if (currentY - startY > threshold) {onClose()} else if (ref.current) {@@ -34,7 +40,7 @@ const useDragToClose = ({}setStartY(0)setCurrentY(0)- }+ }, [setStartY, setCurrentY, startY, currentY])return { ref, handleTouchStart, handleTouchMove, handleTouchEnd }}diff --git a/packages/ui-patterns/CommandMenu/api/Badges.tsx b/packages/ui-patterns/CommandMenu/api/Badges.tsxnew file mode 100644index 00000000000..1534561d3a2--- /dev/null+++ b/packages/ui-patterns/CommandMenu/api/Badges.tsx@@ -0,0 +1,17 @@+import { Microscope } from 'lucide-react'++import { Badge } from 'ui'++interface BadgeExperimentalProps {+ className?: string+}++function BadgeExperimental({ className }: BadgeExperimentalProps) {+ return (+ <Badge className={className}>+ <Microscope className="!mr-1.5 !w-3.5 !h-3.5" /> Experimental+ </Badge>+ )+}++export { BadgeExperimental }diff --git a/packages/ui-patterns/CommandMenu/api/CommandInput.tsx b/packages/ui-patterns/CommandMenu/api/CommandInput.tsxnew file mode 100644index 00000000000..80a0890c5df--- /dev/null+++ b/packages/ui-patterns/CommandMenu/api/CommandInput.tsx@@ -0,0 +1,42 @@+'use client'++import { forwardRef } from 'react'++import { CommandInput_Shadcn_, cn } from 'ui'++import { useQuery, useSetQuery } from './hooks/queryHooks'+import { useCommandMenuTouchGestures } from './hooks/viewHooks'++const CommandInput = forwardRef<+ React.ElementRef<typeof CommandInput_Shadcn_>,+ React.ComponentPropsWithoutRef<typeof CommandInput_Shadcn_>+>(({ className, ...props }, ref) => {+ const query = useQuery()+ const setQuery = useSetQuery()++ const { handleTouchStart, handleTouchMove, handleTouchEnd } = useCommandMenuTouchGestures()++ return (+ <CommandInput_Shadcn_+ autoFocus+ ref={ref}+ value={query}+ onValueChange={setQuery}+ placeholder="Type a command or search..."+ onTouchStart={handleTouchStart}+ onTouchMove={handleTouchMove}+ onTouchEnd={handleTouchEnd}+ className={cn(+ 'flex h-11 w-full rounded-md bg-transparent px-4 py-7 outline-none',+ 'focus:shadow-none focus:ring-transparent',+ 'text-foreground-light placeholder:text-foreground-muted disabled:cursor-not-allowed disabled:opacity-50 border-0',+ className+ )}+ {...props}+ />+ )+})++CommandInput.displayName = CommandInput_Shadcn_.displayName++export { CommandInput }diff --git a/packages/ui-patterns/CommandMenu/api/CommandList.tsx b/packages/ui-patterns/CommandMenu/api/CommandList.tsxnew file mode 100644index 00000000000..12c11f0bac8--- /dev/null+++ b/packages/ui-patterns/CommandMenu/api/CommandList.tsx@@ -0,0 +1,60 @@+'use client'++import { forwardRef, useRef } from 'react'++import { CommandList_Shadcn_, cn } from 'ui'++import { CommandItem, type ICommand } from '../internal/Command'+import { CommandEmpty } from '../internal/CommandEmpty'+import { CommandGroup } from '../internal/CommandGroup'+import { useCommands } from './hooks/commandsHooks'+import { useQuery } from './hooks/queryHooks'+import { TextHighlighter } from './TextHighlighter'++const CommandList = forwardRef<+ React.ElementRef<typeof CommandList_Shadcn_>,+ React.ComponentPropsWithoutRef<typeof CommandList_Shadcn_>+>(({ className, ...props }, ref) => {+ const commandSections = useCommands()+ const query = useQuery()++ const innerRef = useRef<HTMLDivElement | undefined>(undefined)+ const setInnerRef = (elem: HTMLDivElement) => (innerRef.current = elem)++ const setRef = (elem: HTMLDivElement) => {+ if (ref) typeof ref === 'function' ? ref(elem) : (ref.current = elem)+ setInnerRef(elem)+ }++ return (+ <CommandList_Shadcn_+ ref={setRef}+ className={cn('overflow-y-auto overflow-x-hidden bg-transparent', className)}+ {...props}+ >+ <CommandEmpty listRef={innerRef}>No results found.</CommandEmpty>+ {commandSections.map((section) => {+ if (section.commands.every((command) => command.defaultHidden) && !query) return null++ return (+ <CommandGroup key={section.id} heading={section.name} forceMount={section.forceMount}>+ {section.commands+ .filter((command) => !command.defaultHidden || query)+ .map((_command) => {+ const command = _command as ICommand // strip the readonly applied from the proxy++ return (+ <CommandItem key={command.id} command={command}>+ <TextHighlighter>{command.name}</TextHighlighter>+ </CommandItem>+ )+ })}+ </CommandGroup>+ )+ })}+ </CommandList_Shadcn_>+ )+})+CommandList.displayName = CommandList_Shadcn_.displayName++export { CommandList }diff --git a/packages/ui-patterns/CommandMenu/api/CommandMenu.tsx b/packages/ui-patterns/CommandMenu/api/CommandMenu.tsxnew file mode 100644index 00000000000..3184889ae8e--- /dev/null+++ b/packages/ui-patterns/CommandMenu/api/CommandMenu.tsx@@ -0,0 +1,168 @@+'use client'++import { AlertTriangle, ArrowLeft } from 'lucide-react'+import { type PropsWithChildren, type ReactNode, forwardRef, memo, useEffect, useMemo } from 'react'+import { ErrorBoundary } from 'react-error-boundary'++import { useBreakpoint } from 'common'+import useDragToClose from 'common/hooks/useDragToClose'+import { Button, Command_Shadcn_, Dialog, DialogContent, DialogTrigger, cn } from 'ui'++import { useCurrentPage, usePageComponent, usePopPage } from './hooks/pagesHooks'+import { useQuery, useSetQuery } from './hooks/queryHooks'+import {+ useCommandMenuSize,+ useCommandMenuOpen,+ useSetCommandMenuOpen,+ useSetupCommandMenuTouchEvents,+} from './hooks/viewHooks'+import { PageType } from './utils'++function Breadcrumb({ className }: { className?: string }) {+ const currPage = useCurrentPage()+ const popPage = usePopPage()++ if (!currPage) return++ return (+ <div+ className={cn('flex items-center gap-2 mt-2 ml-2 text-xs text-foreground-muted', className)}+ >+ <button onClick={popPage}>+ <ArrowLeft width={12} height={12} />+ </button>+ {currPage.name}+ </div>+ )+}++const CommandWrapper = forwardRef<+ React.ElementRef<typeof Command_Shadcn_>,+ React.ComponentPropsWithoutRef<typeof Command_Shadcn_>+>(({ children, className, ...props }, ref) => {+ const currPage = useCurrentPage()++ return (+ <Command_Shadcn_+ ref={ref}+ className={cn(+ 'h-full w-full flex flex-col overflow-hidden',+ '[&_[cmdk-group]]:px-2 [&_[cmdk-group]]:!bg-transparent [&_[cmdk-group-heading]]:!bg-transparent [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-border-stronger [&_[cmdk-input]]:h-12',+ '[&_[cmdk-item]_svg]:h-5',+ '[&_[cmdk-item]_svg]:w-5',+ '[&_[cmdk-item]_svg]:stroke-1',+ '[&_[cmdk-input-wrapper]_svg]:h-5',+ '[&_[cmdk-input-wrapper]_svg]:w-5',++ '[&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0',+ className+ )}+ {...props}+ >+ {currPage?.type === PageType.Commands && <Breadcrumb />}+ {children}+ </Command_Shadcn_>+ )+})+CommandWrapper.displayName = Command_Shadcn_.displayName++function CommandError({ resetErrorBoundary }: { resetErrorBoundary: () => void }) {+ return (+ <div className={cn('min-h-64', 'flex items-center justify-center')}>+ <div className="p-10 flex flex-col items-center gap-6 mt-4">+ <AlertTriangle strokeWidth={1.5} size={40} />+ <p className="text-lg text-center">+ Sorry, looks like we're having some issues with the command menu!+ </p>+ <p className="text-sm text-center">Please try again in a bit.</p>+ <Button size="tiny" type="secondary" onClick={resetErrorBoundary}>+ Try again?+ </Button>+ </div>+ </div>+ )+}++function PageSwitch({ children }: PropsWithChildren) {+ const PageComponent = usePageComponent()++ return PageComponent ? <PageComponent /> : <CommandWrapper>{children}</CommandWrapper>+}++function useTouchGestures({ toggleOpen }: { toggleOpen: () => void }) {+ const { ref, handleTouchStart, handleTouchMove, handleTouchEnd } = useDragToClose({+ onClose: toggleOpen,+ })++ const setupTouchHandlers = useSetupCommandMenuTouchEvents()+ const touchHandlers = useMemo(+ () => ({ handleTouchStart, handleTouchMove, handleTouchEnd }),+ [handleTouchStart, handleTouchMove, handleTouchEnd]+ )+ useEffect(() => {+ setupTouchHandlers(touchHandlers)+ }, [touchHandlers])++ return { ref }+}++const CommandMenuTrigger = memo(DialogTrigger)++interface CommandMenuProps extends PropsWithChildren {+ trigger?: ReactNode+}++function CommandMenu({ children, trigger }: CommandMenuProps) {+ const open = useCommandMenuOpen()+ const setOpen = useSetCommandMenuOpen()++ const isMobile = useBreakpoint()++ const size = useCommandMenuSize()++ const page = useCurrentPage()+ const popPage = usePopPage()++ const query = useQuery()+ const setQuery = useSetQuery()++ const { ref: contentRef } = useTouchGestures({ toggleOpen: () => setOpen(!open) })++ return (+ <Dialog open={open} onOpenChange={setOpen}>+ {trigger}+ <DialogContent+ hideClose+ forceMount+ ref={contentRef}+ onOpenAutoFocus={(e) => isMobile && e.preventDefault()}+ onInteractOutside={() => setOpen(false)}+ onEscapeKeyDown={(e) => {+ e.preventDefault()+ return query ? setQuery('') : page ? popPage() : setOpen(false)+ }}+ size={size}+ className={cn(+ 'relative my-0 mx-auto rounded-t-lg overflow-y-scroll',+ 'h-[85dvh] mt-[15vh] md:max-h-[500px] md:mt-0 left-0 bottom-0 md:bottom-auto',+ 'place-self-end md:place-self-auto',+ open && '!animate-in !slide-in-from-bottom !duration-300',+ 'data-[state=closed]:!animate-out data-[state=closed]:!slide-out-to-bottom',+ 'md:data-[state=open]:!animate-in md:data-[state=closed]:!animate-out',+ 'md:data-[state=closed]:!zoom-out-95 md:data-[state=open]:!zoom-in-95',+ 'md:data-[state=closed]:!slide-out-to-left-[0%] md:data-[state=closed]:!slide-out-to-top-[0%]',+ 'md:data-[state=open]:!slide-in-from-left-[0%] md:data-[state=open]:!slide-in-from-top-[0%]'+ )}+ dialogOverlayProps={{+ className: cn('overflow-hidden flex data-closed:delay-100'),+ }}+ >+ <ErrorBoundary FallbackComponent={CommandError}>+ <PageSwitch>{children}</PageSwitch>+ </ErrorBoundary>+ </DialogContent>+ </Dialog>+ )+}++export { Breadcrumb, CommandMenu, CommandMenuTrigger, CommandWrapper }diff --git a/packages/ui-patterns/CommandMenu/api/CommandProvider.tsx b/packages/ui-patterns/CommandMenu/api/CommandProvider.tsxindex 06bc2393a09..10f1f8edad9 100644--- a/packages/ui-patterns/CommandMenu/api/CommandProvider.tsx+++ b/packages/ui-patterns/CommandMenu/api/CommandProvider.tsx@@ -1,12 +1,15 @@+'use client'+import { useConstant } from 'common'-import { useEffect, type PropsWithChildren } from 'react'+import { type PropsWithChildren, useEffect, useMemo, useCallback } from 'react'-import { useToggleCommandMenu } from './hooks/viewHooks'import { CommandContext } from '../internal/Context'import { initCommandsState } from '../internal/state/commandsState'import { initPagesState } from '../internal/state/pagesState'import { initQueryState } from '../internal/state/queryState'import { initViewState } from '../internal/state/viewState'+import { useCrossCompatRouter } from './hooks/useCrossCompatRouter'+import { useSetCommandMenuOpen, useToggleCommandMenu } from './hooks/viewHooks'const CommandProviderInternal = ({ children }: PropsWithChildren) => {const combinedState = useConstant(() => ({@@ -19,12 +22,15 @@ const CommandProviderInternal = ({ children }: PropsWithChildren) => {return <CommandContext.Provider value={combinedState}>{children}</CommandContext.Provider>}-const CommandShortcut = () => {+// This is a component not a hook so it can access the wrapping context.+const CommandShortcut = ({ openKey }: { openKey: string }) => {const toggleOpen = useToggleCommandMenu()useEffect(() => {const handleKeydown = (evt: KeyboardEvent) => {- if (evt.key === 'k' && evt.metaKey) {+ if (openKey === '') return++ if (evt.key === openKey && evt.metaKey) {evt.preventDefault()toggleOpen()}@@ -38,9 +44,37 @@ const CommandShortcut = () => {return null}-const CommandProvider = ({ children }: PropsWithChildren) => (+// This is a component not a hook so it can access the wrapping context.+function CloseOnNavigation() {+ const setIsOpen = useSetCommandMenuOpen()+ const router = useCrossCompatRouter()++ const completeNavigation = useCallback(() => {+ setIsOpen(false)+ }, [setIsOpen])++ useEffect(() => {+ router.events.onRouteChangeComplete(completeNavigation)+ return () => router.events.offRouteChangeComplete(completeNavigation)+ }, [router])++ return null+}++interface CommandProviderProps extends PropsWithChildren {+ /**+ * The keyboard shortcut that opens the command menu when used in+ * combination with the meta key.+ *+ * Defaults to `k`. Pass an empty string to disable the keyboard shortcut.+ */+ openKey?: string+}++const CommandProvider = ({ children, openKey }: CommandProviderProps) => (<CommandProviderInternal>- <CommandShortcut />+ <CommandShortcut openKey={openKey ?? 'k'} />+ <CloseOnNavigation />{children}</CommandProviderInternal>)diff --git a/packages/ui-patterns/CommandMenu/api/TextHighlighter.tsx b/packages/ui-patterns/CommandMenu/api/TextHighlighter.tsxnew file mode 100644index 00000000000..aa8ecddd79d--- /dev/null+++ b/packages/ui-patterns/CommandMenu/api/TextHighlighter.tsx@@ -0,0 +1,42 @@+'use client'++import {+ Children,+ type DetailedHTMLProps,+ type HTMLAttributes,+ type PropsWithChildren,+} from 'react'++import { useQuery } from './hooks/queryHooks'++interface TextHighlighterBaseProps+ extends PropsWithChildren<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>> {+ query: string+ text?: string+}++function TextHighlighterBase({ children, text, query, ...props }: TextHighlighterBaseProps) {+ const child = text ?? Children.toArray(children)[0]+ if (typeof child !== 'string') return child++ const idx = child.toLowerCase().indexOf(query.toLowerCase())+ if (idx === -1) {+ return <span {...props}>{child}</span>+ }++ return (+ <span {...props}>+ {child.substring(0, idx)}+ <span className="text-foreground">{child.substring(idx, idx + query.length)}</span>+ {child.substring(idx + query.length)}+ </span>+ )+}++function TextHighlighter(props: Omit<TextHighlighterBaseProps, 'query'>) {+ const query = useQuery()++ return <TextHighlighterBase query={query} {...props} />+}++export { TextHighlighter, TextHighlighterBase }diff --git a/packages/ui-patterns/CommandMenu/api/hooks/commandsHooks.test.tsx b/packages/ui-patterns/CommandMenu/api/hooks/commandsHooks.test.tsxindex a0c80d59c82..52552408efd 100644--- a/packages/ui-patterns/CommandMenu/api/hooks/commandsHooks.test.tsx+++ b/packages/ui-patterns/CommandMenu/api/hooks/commandsHooks.test.tsx@@ -1,11 +1,7 @@-/**- * @jest-environment jsdom- */--import '@testing-library/jest-dom'import { act, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { Fragment, useState } from 'react'+import { beforeEach, describe, expect, it } from 'vitest'import { CommandProvider } from '../CommandProvider'import type { ICommand } from '../types'diff --git a/packages/ui-patterns/CommandMenu/api/hooks/commandsHooks.ts b/packages/ui-patterns/CommandMenu/api/hooks/commandsHooks.tsindex d67b483e7c4..c58d7dcfd34 100644--- a/packages/ui-patterns/CommandMenu/api/hooks/commandsHooks.ts+++ b/packages/ui-patterns/CommandMenu/api/hooks/commandsHooks.ts@@ -1,3 +1,5 @@+'use client'+import { isEqual } from 'lodash'import { useEffect, useMemo, useRef } from 'react'import { useSnapshot } from 'valtio'diff --git a/packages/ui-patterns/CommandMenu/api/hooks/pagesHooks.test.tsx b/packages/ui-patterns/CommandMenu/api/hooks/pagesHooks.test.tsxindex efdd8724dd1..07e50203216 100644--- a/packages/ui-patterns/CommandMenu/api/hooks/pagesHooks.test.tsx+++ b/packages/ui-patterns/CommandMenu/api/hooks/pagesHooks.test.tsx@@ -1,11 +1,7 @@-/**- * @jest-environment jsdom- */--import '@testing-library/jest-dom'import { act, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { useEffect, useState } from 'react'+import { describe, expect, it } from 'vitest'import { CommandProvider } from '../CommandProvider'import { useCurrentPage, useRegisterPage, useSetPage } from './pagesHooks'diff --git a/packages/ui-patterns/CommandMenu/api/hooks/pagesHooks.ts b/packages/ui-patterns/CommandMenu/api/hooks/pagesHooks.tsindex 9136ef3d474..b1b5728e995 100644--- a/packages/ui-patterns/CommandMenu/api/hooks/pagesHooks.ts+++ b/packages/ui-patterns/CommandMenu/api/hooks/pagesHooks.ts@@ -1,3 +1,5 @@+'use client'+import { isEqual } from 'lodash'import { useEffect, useMemo, useRef } from 'react'import { useSnapshot } from 'valtio'diff --git a/packages/ui-patterns/CommandMenu/api/hooks/useCrossCompatRouter.ts b/packages/ui-patterns/CommandMenu/api/hooks/useCrossCompatRouter.tsnew file mode 100644index 00000000000..dec64423056--- /dev/null+++ b/packages/ui-patterns/CommandMenu/api/hooks/useCrossCompatRouter.ts@@ -0,0 +1,67 @@+'use client'++import { useRouter as useLegacyRouter } from 'next/compat/router'+import { useRouter as useNextRouter } from 'next/navigation'+import { useEffect, useMemo, useRef, useTransition } from 'react'+import { usePrevious } from 'react-use'++type Handler = (...evts: any[]) => void++function useHasChanged<T>(value: T, { onlyTo }: { onlyTo?: T } = {}) {+ const prev = usePrevious(value)++ if (prev === value) return false+ if (onlyTo && value !== onlyTo) return false++ return true+}++function useCrossCompatRouter() {+ const legacyRouter = useLegacyRouter()+ const newRouter = useNextRouter()+ const isUsingLegacyRouting = !!legacyRouter++ const [isPending, startTransition] = useTransition()+ const hasPendingEnded = useHasChanged(isPending, { onlyTo: false })+ const onPendingEnd = useRef(new Set<() => void>())+ useEffect(() => {+ if (!isUsingLegacyRouting && hasPendingEnded) {+ onPendingEnd.current.forEach((fn) => fn())+ }+ }, [hasPendingEnded, isUsingLegacyRouting])++ const api = useMemo(+ () => ({+ events: {+ onRouteChangeComplete: (fn: Handler) => {+ if (isUsingLegacyRouting) {+ legacyRouter.events.on('routeChangeComplete', fn)+ } else {+ onPendingEnd.current.add(fn)+ }+ },+ offRouteChangeComplete: (fn: Handler) => {+ if (isUsingLegacyRouting) {+ legacyRouter.events.off('routeChangeComplete', fn)+ } else {+ onPendingEnd.current.delete(fn)+ }+ },+ },+ push: (path: string) => {+ if (isUsingLegacyRouting) {+ legacyRouter.push(path)+ } else {+ startTransition(() => {+ newRouter.push(path)+ })+ }+ },+ }),+ []+ )++ return api+}++export { useCrossCompatRouter }diff --git a/packages/ui-patterns/CommandMenu/api/hooks/useHistoryKeys.ts b/packages/ui-patterns/CommandMenu/api/hooks/useHistoryKeys.tsnew file mode 100644index 00000000000..0a4673a9853--- /dev/null+++ b/packages/ui-patterns/CommandMenu/api/hooks/useHistoryKeys.ts@@ -0,0 +1,46 @@+'use client'++import { useCallback, useEffect, useState } from 'react'++import { useSetQuery } from './queryHooks'++interface UseHistoryKeysOptions {+ stack: string[]+ enable?: boolean+}++/**+ * Enables shell-style message history when hitting up/down on the keyboard+ */+function useHistoryKeys({ stack, enable = true }: UseHistoryKeysOptions) {+ const [idx, setIdx] = useState(0)+ const setQuery = useSetQuery()++ const navigateIdx = useCallback((newIdx: number) => {+ if (!enable) return++ setQuery(stack[newIdx] ?? '')+ setIdx(newIdx)+ }, [])++ useEffect(() => {+ function onKeyDown(e: KeyboardEvent) {+ switch (e.key) {+ case 'ArrowUp':+ return navigateIdx(Math.max(idx - 1, 0))+ case 'ArrowDown':+ return navigateIdx(Math.min(idx + 1, stack.length - 1))+ default:+ return+ }+ }++ window.addEventListener('keydown', onKeyDown)++ return () => {+ window.removeEventListener('keydown', onKeyDown)+ }+ }, [navigateIdx, stack])+}++export { useHistoryKeys }diff --git a/packages/ui-patterns/CommandMenu/api/hooks/viewHooks.ts b/packages/ui-patterns/CommandMenu/api/hooks/viewHooks.tsindex 85e0c9560d4..8c8bd0af348 100644--- a/packages/ui-patterns/CommandMenu/api/hooks/viewHooks.ts+++ b/packages/ui-patterns/CommandMenu/api/hooks/viewHooks.ts@@ -1,8 +1,10 @@+'use client'+import { useLayoutEffect, useRef } from 'react'import { useSnapshot } from 'valtio'import { useCommandContext } from '../../internal/Context'-import { type DialogSize } from '../../internal/state/viewState'+import { type DialogSize, type ITouchHandlers } from '../../internal/state/viewState'const useCommandMenuInitiated = () => {const { viewState } = useCommandContext()@@ -10,7 +12,7 @@ const useCommandMenuInitiated = () => {return initiated}-const useCommandMenuVisible = () => {+const useCommandMenuOpen = () => {const { viewState } = useCommandContext()const { open } = useSnapshot(viewState)return open@@ -28,18 +30,6 @@ const useToggleCommandMenu = () => {return toggleOpen}-const useIsCommandNavigating = () => {- const { viewState } = useCommandContext()- const { isNavigating } = useSnapshot(viewState)- return isNavigating-}--const useSetIsCommandNavigating = () => {- const { viewState } = useCommandContext()- const { setIsNavigating } = useSnapshot(viewState)- return setIsNavigating-}-const useCommandMenuSize = () => {const { viewState } = useCommandContext()const { size } = useSnapshot(viewState)@@ -58,13 +48,27 @@ const useSetCommandMenuSize = (newSize: DialogSize) => {}, [setSize])}+const useSetupCommandMenuTouchEvents = () => {+ const { viewState } = useCommandContext()+ const { setTouchHandlers } = useSnapshot(viewState)++ return setTouchHandlers+}++const useCommandMenuTouchGestures = () => {+ const { viewState } = useCommandContext()+ const { touchHandlers } = useSnapshot(viewState)++ return touchHandlers+}+export {useCommandMenuInitiated,- useCommandMenuVisible,+ useCommandMenuOpen,useSetCommandMenuOpen,useToggleCommandMenu,- useIsCommandNavigating,- useSetIsCommandNavigating,useCommandMenuSize,useSetCommandMenuSize,+ useSetupCommandMenuTouchEvents,+ useCommandMenuTouchGestures,}diff --git a/packages/ui-patterns/CommandMenu/api/utils.ts b/packages/ui-patterns/CommandMenu/api/utils.tsindex 491708a8436..efbdbcb2d72 100644--- a/packages/ui-patterns/CommandMenu/api/utils.ts+++ b/packages/ui-patterns/CommandMenu/api/utils.ts@@ -1 +1,6 @@+const escapeAttributeSelector = (str: string) => encodeURIComponent(str)++export { escapeAttributeSelector }+export { generateCommandClassNames } from '../internal/Command'+export { orderSectionFirst } from '../internal/state/commandsState'export { PageType } from '../internal/state/pagesState'diff --git a/packages/ui-patterns/CommandMenu/index.tsx b/packages/ui-patterns/CommandMenu/index.tsxnew file mode 100644index 00000000000..d3653d6baf3--- /dev/null+++ b/packages/ui-patterns/CommandMenu/index.tsx@@ -0,0 +1,14 @@+export * from './api/Badges'+export { CommandInput } from './api/CommandInput'+export { CommandList } from './api/CommandList'+export { Breadcrumb, CommandMenu, CommandMenuTrigger, CommandWrapper } from './api/CommandMenu'+export { CommandProvider } from './api/CommandProvider'+export { TextHighlighter, TextHighlighterBase } from './api/TextHighlighter'+export * from './api/hooks/commandsHooks'+export * from './api/hooks/pagesHooks'+export * from './api/hooks/queryHooks'+export { useHistoryKeys } from './api/hooks/useHistoryKeys'+export * from './api/hooks/viewHooks'+export * from './api/utils'++export * from './api/types'diff --git a/packages/ui-patterns/CommandMenu/internal/Command.tsx b/packages/ui-patterns/CommandMenu/internal/Command.tsxindex 7d09e407635..8c7712a22e0 100644--- a/packages/ui-patterns/CommandMenu/internal/Command.tsx+++ b/packages/ui-patterns/CommandMenu/internal/Command.tsx@@ -1,4 +1,11 @@-import { type ReactNode } from 'react'+'use client'++import { type PropsWithChildren, type ReactNode, forwardRef } from 'react'++import { CommandItem_Shadcn_, cn } from 'ui'+import { useCrossCompatRouter } from '../api/hooks/useCrossCompatRouter'+import { useQuery } from '../api/hooks/queryHooks'+import { useSetCommandMenuOpen } from '../api/hooks/viewHooks'type ICommand = IActionCommand | IRouteCommand@@ -15,7 +22,7 @@ interface IBaseCommand {*/defaultHidden?: boolean/**- * Curerntly unused+ * Currently unused*/keywords?: string[]/**@@ -32,4 +39,89 @@ interface IRouteCommand extends IBaseCommand {route: `/${string}` | `http${string}`}+const isActionCommand = (command: ICommand): command is IActionCommand => 'action' in command+const isRouteCommand = (command: ICommand): command is IRouteCommand => 'route' in command++const generateCommandClassNames = (isLink: boolean) =>+ cn(+ 'cursor-default',+ 'select-none',+ 'items-center gap-2',+ 'rounded-md',+ 'text-sm',+ 'group',+ 'py-3',+ 'text-foreground-light',+ 'relative',+ 'flex',+ isLink+ ? `+bg-transparent+px-2+transition-all+outline-none+aria-selected:border-overlay+aria-selected:bg-selection/90+aria-selected:shadow-sm+aria-selected:scale-[100.3%]+data-[disabled]:pointer-events-none data-[disabled]:opacity-50`+ : `+px-2+aria-selected:bg-selection/80+aria-selected:backdrop-filter+aria-selected:backdrop-blur-md+data-[disabled]:pointer-events-none+data-[disabled]:opacity-50+`+ )++interface CommandItemProps extends React.ComponentPropsWithoutRef<typeof CommandItem_Shadcn_> {+ command: ICommand+}++const CommandItem = forwardRef<+ React.ElementRef<typeof CommandItem_Shadcn_>,+ PropsWithChildren<CommandItemProps>+>(({ children, className, command: _command, ...props }, ref) => {+ const router = useCrossCompatRouter()+ const setIsOpen = useSetCommandMenuOpen()+ const query = useQuery()++ const command = _command as ICommand // strip the readonly applied from the proxy++ return (+ <CommandItem_Shadcn_+ ref={ref}+ onSelect={+ isActionCommand(command)+ ? command.action+ : isRouteCommand(command)+ ? () => {+ command.route.startsWith('http')+ ? (setIsOpen(false), window.open(command.route, '_blank', 'noreferrer,noopener'))+ : router.push(command.route)+ }+ : () => {}+ }+ value={command.forceMount ? `${query} ${command.value}` : command.value}+ className={cn(+ generateCommandClassNames(isRouteCommand(command)),+ className,+ command.className+ )}+ {...props}+ >+ <div className="w-full flex flex-row justify-between items-center">+ <div className="flex flex-row gap-2 flex-grow items-center">+ {command.icon?.()}+ {children}+ </div>+ {command.badge?.()}+ </div>+ </CommandItem_Shadcn_>+ )+})+CommandItem.displayName = CommandItem_Shadcn_.displayName++export { CommandItem, generateCommandClassNames, isActionCommand, isRouteCommand }export type { ICommand }diff --git a/packages/ui-patterns/CommandMenu/internal/CommandEmpty.tsx b/packages/ui-patterns/CommandMenu/internal/CommandEmpty.tsxnew file mode 100644index 00000000000..2128bbba340--- /dev/null+++ b/packages/ui-patterns/CommandMenu/internal/CommandEmpty.tsx@@ -0,0 +1,46 @@+'use client'++import { type PropsWithChildren, type RefObject, useMemo, useState } from 'react'++import { cn } from 'ui'++import { useQuery } from '../api/hooks/queryHooks'++const CommandEmpty = ({+ children,+ className,+ listRef,+ ...props+}: PropsWithChildren<{+ className?: string+ /**+ * Reference to the div that contains the command item list in the DOM.+ *+ * Hacking around a bug in cmdk where the empty state will show even when+ * there are force-mounted items.+ */+ listRef: RefObject<HTMLDivElement | undefined>+}>) => {+ const query = useQuery()++ const [render, setRender] = useState(false)+ useMemo(() => {+ if (!query) setRender(false)+ /**+ * In a timeout so the DOM update happens before we query.+ */+ setTimeout(() => {+ setRender(!listRef?.current?.querySelector('[cmdk-item]'))+ })+ }, [query])++ return (+ render && (+ <div className={cn('py-6 text-center text-sm text-foreground-muted', className)} {...props}>+ {children}+ </div>+ )+ )+}++export { CommandEmpty }diff --git a/packages/ui-patterns/CommandMenu/internal/CommandGroup.tsx b/packages/ui-patterns/CommandMenu/internal/CommandGroup.tsxnew file mode 100644index 00000000000..fc2cc297995--- /dev/null+++ b/packages/ui-patterns/CommandMenu/internal/CommandGroup.tsx@@ -0,0 +1,24 @@+'use client'++import { forwardRef } from 'react'++import { CommandGroup_Shadcn_, cn } from 'ui'++const CommandGroup = forwardRef<+ React.ElementRef<typeof CommandGroup_Shadcn_>,+ React.ComponentPropsWithoutRef<typeof CommandGroup_Shadcn_>+>(({ className, ...props }, ref) => {+ return (+ <CommandGroup_Shadcn_+ ref={ref}+ className={cn(+ 'overflow-hidden py-3 px-2 text-foreground-muted [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pb-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-foreground-muted',+ className+ )}+ {...props}+ />+ )+})+CommandGroup.displayName = CommandGroup_Shadcn_.displayName++export { CommandGroup }diff --git a/packages/ui-patterns/CommandMenu/internal/CommandSection.tsx b/packages/ui-patterns/CommandMenu/internal/CommandSection.tsxindex 7fad0501156..79749b2f09c 100644--- a/packages/ui-patterns/CommandMenu/internal/CommandSection.tsx+++ b/packages/ui-patterns/CommandMenu/internal/CommandSection.tsx@@ -3,8 +3,8 @@ import { type ICommand } from './Command'type ICommandSection = {id: stringname: string- forceMount: booleancommands: Array<ICommand>+ forceMount?: boolean}const toSectionId = (str: string) => str.toLowerCase().replace(/\s+/g, '-')diff --git a/packages/ui-patterns/CommandMenu/internal/Context.tsx b/packages/ui-patterns/CommandMenu/internal/Context.tsxindex 4c28b7dc527..e8f67e1b834 100644--- a/packages/ui-patterns/CommandMenu/internal/Context.tsx+++ b/packages/ui-patterns/CommandMenu/internal/Context.tsx@@ -1,3 +1,5 @@+'use client'+import { createContext, useContext } from 'react'import { type ICommandsState } from '../internal/state/commandsState'diff --git a/packages/ui-patterns/CommandMenu/internal/state/commandsStates.test.ts b/packages/ui-patterns/CommandMenu/internal/state/commandsStates.test.tsindex 28f5121adb8..3479c9e2f81 100644--- a/packages/ui-patterns/CommandMenu/internal/state/commandsStates.test.ts+++ b/packages/ui-patterns/CommandMenu/internal/state/commandsStates.test.ts@@ -1,3 +1,5 @@+import { beforeEach, describe, expect, it } from 'vitest'+import { type ICommandSection, section$new } from '../CommandSection'import { initCommandsState, orderSectionFirst, type ICommandsState } from './commandsState'diff --git a/packages/ui-patterns/CommandMenu/internal/state/pagesState.test.ts b/packages/ui-patterns/CommandMenu/internal/state/pagesState.test.tsindex 74115cd5438..ce91bdb1d0f 100644--- a/packages/ui-patterns/CommandMenu/internal/state/pagesState.test.ts+++ b/packages/ui-patterns/CommandMenu/internal/state/pagesState.test.ts@@ -1,3 +1,5 @@+import { beforeEach, describe, expect, it } from 'vitest'+import { PageType, initPagesState, type IPagesState, type PageDefinition } from './pagesState'describe('pagesState', () => {diff --git a/packages/ui-patterns/CommandMenu/internal/state/viewState.ts b/packages/ui-patterns/CommandMenu/internal/state/viewState.tsindex 93ac8bdc30b..162b65aa75d 100644--- a/packages/ui-patterns/CommandMenu/internal/state/viewState.ts+++ b/packages/ui-patterns/CommandMenu/internal/state/viewState.ts@@ -1,17 +1,25 @@+import type { TouchEventHandler } from 'react'+import { proxy } from 'valtio'type DialogSize = 'small' | 'tiny' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | 'xxxlarge'+interface ITouchHandlers {+ handleTouchStart: TouchEventHandler+ handleTouchMove: TouchEventHandler+ handleTouchEnd: TouchEventHandler+}+type IViewState = {initiated: booleaninit: () => voidopen: booleansetOpen: (open: boolean) => voidtoggleOpen: () => void- isNavigating: boolean- setIsNavigating: (isNavigating: boolean) => voidsize: DialogSizesetSize: (size: DialogSize) => void+ touchHandlers: ITouchHandlers+ setTouchHandlers: (handlers: ITouchHandlers) => void}const initViewState = () => {@@ -27,13 +35,17 @@ const initViewState = () => {state.init()state.open = !state.open},- isNavigating: false,- setIsNavigating: (isNavigating) => (state.isNavigating = isNavigating),size: 'large',setSize: (size) => (state.size = size),+ touchHandlers: {+ handleTouchStart: () => {},+ handleTouchMove: () => {},+ handleTouchEnd: () => {},+ },+ setTouchHandlers: (handlers) => (state.touchHandlers = handlers),})return state}export { initViewState }-export type { DialogSize, IViewState }+export type { DialogSize, IViewState, ITouchHandlers }diff --git a/packages/ui-patterns/jest.config.js b/packages/ui-patterns/jest.config.jsdeleted file mode 100644index 8bb37208d7a..00000000000--- a/packages/ui-patterns/jest.config.js+++ /dev/null@@ -1,5 +0,0 @@-/** @type {import('ts-jest').JestConfigWithTsJest} */-module.exports = {- preset: 'ts-jest',- testEnvironment: 'node',-}diff --git a/packages/ui-patterns/package.json b/packages/ui-patterns/package.jsonindex ee62b3c0aa1..3eed79e543b 100644--- a/packages/ui-patterns/package.json+++ b/packages/ui-patterns/package.json@@ -5,7 +5,7 @@"license": "MIT","sideEffects": false,"scripts": {- "test": "jest",+ "test": "vitest","typecheck": "tsc --noEmit"},"dependencies": {@@ -24,6 +24,7 @@"react-markdown": "^9.0.1","react-syntax-highlighter": "^15.5.0","react-tooltip": "*",+ "react-use": "^17.5.0","reactflow": "*","remark-gfm": "^4.0.0","sql-formatter": "^15.3.1",@@ -34,6 +35,7 @@"devDependencies": {"@supabase/auth-helpers-react": "^0.4.2","@testing-library/dom": "^10.1.0",+ "@testing-library/jest-dom": "^6.4.6","@testing-library/react": "^16.0.0","@testing-library/user-event": "^13.5.0","@types/common-tags": "^1.8.4",@@ -41,9 +43,8 @@"@types/react": "^18.3.3","@types/react-dom": "^18.3.0","api-types": "*",- "jest": "^29.7.0",- "jest-environment-jsdom": "^29.7.0",- "ts-jest": "^29.1.2"+ "next-router-mock": "^0.9.13",+ "vitest": "^2.0.3"},"peerDependencies": {"next": "*",diff --git a/packages/ui-patterns/vitest.config.ts b/packages/ui-patterns/vitest.config.tsnew file mode 100644index 00000000000..8623a6c59bf--- /dev/null+++ b/packages/ui-patterns/vitest.config.ts@@ -0,0 +1,10 @@+/// <reference types="vitest" />++import { defineConfig } from 'vite'++export default defineConfig({+ test: {+ environment: 'jsdom',+ setupFiles: ['./vitest.setup.ts'],+ },+})diff --git a/packages/ui-patterns/vitest.setup.ts b/packages/ui-patterns/vitest.setup.tsnew file mode 100644index 00000000000..810240d35a3--- /dev/null+++ b/packages/ui-patterns/vitest.setup.ts@@ -0,0 +1,13 @@+/// <reference types="@testing-library/jest-dom" />++import * as matchers from '@testing-library/jest-dom/matchers'+import { cleanup } from '@testing-library/react'+import { afterEach, expect, vi } from 'vitest'++expect.extend(matchers)++vi.mock('next/navigation', () => require('next-router-mock'))++afterEach(() => {+ cleanup()+})diff --git a/packages/ui/src/layout/ai-icon-animation/ai-icon-animation.tsx b/packages/ui/src/layout/ai-icon-animation/ai-icon-animation.tsxindex 6e3136e43ae..e56009e4675 100644--- a/packages/ui/src/layout/ai-icon-animation/ai-icon-animation.tsx+++ b/packages/ui/src/layout/ai-icon-animation/ai-icon-animation.tsx@@ -2,7 +2,7 @@// make a function that returns a component-import styles from '@ui/layout/ai-icon-animation/ai-icon-animation-style.module.css'+import styles from './ai-icon-animation-style.module.css'import { useEffect, useState } from 'react'import { cn } from '../../lib/utils/cn'