mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 07:39:07 +03:00
fix: add trigger with proper a11y
This commit is contained in:
1 parent
93570ca78c
commit
ee5bb8a6b8
10 files changed
+73
-58
No files matched your search
@@ -15,9 +15,9 @@ import {
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandMenu,
|
||||
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
||||
CommandProvider,
|
||||
useRegisterCommands,
|
||||
useSetCommandMenuOpen,
|
||||
} from 'ui-patterns/CommandMenu'
|
||||
```
|
||||
|
||||
@@ -42,17 +42,18 @@ function Commands() {
|
||||
}
|
||||
|
||||
function CommandMenuTrigger() {
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
return <Button onClick={() => setOpen(true)}>Open command menu</Button>
|
||||
return (
|
||||
<CommandMenuTriggerPrimitive>
|
||||
<Button>Open command menu</Button>
|
||||
</CommandMenuTriggerPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export function CommandMenuDemo() {
|
||||
export default function CommandMenuDemo() {
|
||||
return (
|
||||
<CommandProvider openKey="j">
|
||||
<CommandMenuTrigger />
|
||||
<Commands />
|
||||
<CommandMenu>
|
||||
<CommandMenu trigger={<CommandMenuTrigger />}>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
|
||||
@@ -4,9 +4,9 @@ import {
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandMenu,
|
||||
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
||||
CommandProvider,
|
||||
useRegisterCommands,
|
||||
useSetCommandMenuOpen,
|
||||
} from 'ui-patterns/CommandMenu'
|
||||
|
||||
function Commands() {
|
||||
@@ -48,22 +48,23 @@ function Commands() {
|
||||
}
|
||||
|
||||
function CommandMenuTrigger() {
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
return <Button onClick={() => setOpen(true)}>Open command menu</Button>
|
||||
return (
|
||||
<CommandMenuTriggerPrimitive>
|
||||
<Button>Open command menu</Button>
|
||||
</CommandMenuTriggerPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export default function CommandMenuDemo() {
|
||||
return (
|
||||
<CommandProvider openKey="j">
|
||||
<CommandProvider openKey="">
|
||||
<div className="flex flex-col gap-2">
|
||||
<CommandMenuTrigger />
|
||||
<CommandMenu trigger={<CommandMenuTrigger />}>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
<Commands />
|
||||
</div>
|
||||
<CommandMenu>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
</CommandProvider>
|
||||
)
|
||||
}
|
||||
@@ -3,9 +3,9 @@ import {
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandMenu,
|
||||
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
||||
CommandProvider,
|
||||
useRegisterCommands,
|
||||
useSetCommandMenuOpen,
|
||||
} from 'ui-patterns/CommandMenu'
|
||||
|
||||
function Commands() {
|
||||
@@ -28,17 +28,18 @@ function Commands() {
|
||||
}
|
||||
|
||||
function CommandMenuTrigger() {
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
return <Button onClick={() => setOpen(true)}>Open command menu</Button>
|
||||
return (
|
||||
<CommandMenuTriggerPrimitive>
|
||||
<Button>Open command menu</Button>
|
||||
</CommandMenuTriggerPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export default function CommandMenuDemo() {
|
||||
return (
|
||||
<CommandProvider openKey="j">
|
||||
<CommandMenuTrigger />
|
||||
<Commands />
|
||||
<CommandMenu>
|
||||
<CommandMenu trigger={<CommandMenuTrigger />}>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
|
||||
@@ -3,9 +3,9 @@ import {
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandMenu,
|
||||
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
||||
CommandProvider,
|
||||
useRegisterCommands,
|
||||
useSetCommandMenuOpen,
|
||||
} from 'ui-patterns/CommandMenu'
|
||||
|
||||
function Commands() {
|
||||
@@ -40,17 +40,18 @@ function Commands() {
|
||||
}
|
||||
|
||||
function CommandMenuTrigger() {
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
return <Button onClick={() => setOpen(true)}>Open command menu</Button>
|
||||
return (
|
||||
<CommandMenuTriggerPrimitive>
|
||||
<Button>Open command menu</Button>
|
||||
</CommandMenuTriggerPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export default function CommandMenuDemo() {
|
||||
return (
|
||||
<CommandProvider openKey="">
|
||||
<CommandMenuTrigger />
|
||||
<Commands />
|
||||
<CommandMenu>
|
||||
<CommandMenu trigger={<CommandMenuTrigger />}>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
|
||||
@@ -3,9 +3,9 @@ import {
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandMenu,
|
||||
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
||||
CommandProvider,
|
||||
useRegisterCommands,
|
||||
useSetCommandMenuOpen,
|
||||
} from 'ui-patterns/CommandMenu'
|
||||
|
||||
function Commands() {
|
||||
@@ -27,17 +27,18 @@ function Commands() {
|
||||
}
|
||||
|
||||
function CommandMenuTrigger() {
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
return <Button onClick={() => setOpen(true)}>Open command menu</Button>
|
||||
return (
|
||||
<CommandMenuTriggerPrimitive>
|
||||
<Button>Open command menu</Button>
|
||||
</CommandMenuTriggerPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export default function CommandMenuDemo() {
|
||||
return (
|
||||
<CommandProvider openKey="">
|
||||
<CommandMenuTrigger />
|
||||
<Commands />
|
||||
<CommandMenu>
|
||||
<CommandMenu trigger={<CommandMenuTrigger />}>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
|
||||
@@ -4,9 +4,9 @@ import {
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandMenu,
|
||||
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
||||
CommandProvider,
|
||||
useRegisterCommands,
|
||||
useSetCommandMenuOpen,
|
||||
} from 'ui-patterns/CommandMenu'
|
||||
|
||||
function Commands() {
|
||||
@@ -23,17 +23,18 @@ function Commands() {
|
||||
}
|
||||
|
||||
function CommandMenuTrigger() {
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
return <Button onClick={() => setOpen(true)}>Open command menu</Button>
|
||||
return (
|
||||
<CommandMenuTriggerPrimitive>
|
||||
<Button>Open command menu</Button>
|
||||
</CommandMenuTriggerPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export default function CommandMenuDemo() {
|
||||
return (
|
||||
<CommandProvider openKey="">
|
||||
<CommandMenuTrigger />
|
||||
<Commands />
|
||||
<CommandMenu>
|
||||
<CommandMenu trigger={<CommandMenuTrigger />}>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
|
||||
@@ -5,11 +5,11 @@ import {
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandMenu,
|
||||
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
||||
CommandProvider,
|
||||
PageType,
|
||||
useRegisterCommands,
|
||||
useRegisterPage,
|
||||
useSetCommandMenuOpen,
|
||||
useSetPage,
|
||||
} from 'ui-patterns/CommandMenu'
|
||||
|
||||
@@ -45,17 +45,18 @@ function Commands() {
|
||||
}
|
||||
|
||||
function CommandMenuTrigger() {
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
return <Button onClick={() => setOpen(true)}>Open command menu</Button>
|
||||
return (
|
||||
<CommandMenuTriggerPrimitive>
|
||||
<Button>Open command menu</Button>
|
||||
</CommandMenuTriggerPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export default function CommandMenuDemo() {
|
||||
return (
|
||||
<CommandProvider openKey="">
|
||||
<CommandMenuTrigger />
|
||||
<Commands />
|
||||
<CommandMenu>
|
||||
<CommandMenu trigger={<CommandMenuTrigger />}>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
|
||||
@@ -4,11 +4,11 @@ import {
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandMenu,
|
||||
CommandMenuTrigger as CommandMenuTriggerPrimitive,
|
||||
CommandProvider,
|
||||
PageType,
|
||||
useRegisterCommands,
|
||||
useRegisterPage,
|
||||
useSetCommandMenuOpen,
|
||||
useSetPage,
|
||||
} from 'ui-patterns/CommandMenu'
|
||||
|
||||
@@ -53,17 +53,18 @@ function Commands() {
|
||||
}
|
||||
|
||||
function CommandMenuTrigger() {
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
return <Button onClick={() => setOpen(true)}>Open command menu</Button>
|
||||
return (
|
||||
<CommandMenuTriggerPrimitive>
|
||||
<Button>Open command menu</Button>
|
||||
</CommandMenuTriggerPrimitive>
|
||||
)
|
||||
}
|
||||
|
||||
export default function CommandMenuDemo() {
|
||||
return (
|
||||
<CommandProvider openKey="">
|
||||
<CommandMenuTrigger />
|
||||
<Commands />
|
||||
<CommandMenu>
|
||||
<CommandMenu trigger={<CommandMenuTrigger />}>
|
||||
<CommandInput />
|
||||
<CommandList />
|
||||
</CommandMenu>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use client'
|
||||
|
||||
import { AlertTriangle, ArrowLeft } from 'lucide-react'
|
||||
import { type PropsWithChildren, forwardRef } from 'react'
|
||||
import { type PropsWithChildren, type ReactNode, forwardRef, memo } from 'react'
|
||||
import { ErrorBoundary } from 'react-error-boundary'
|
||||
|
||||
import { Button, Command_Shadcn_, Dialog, DialogContent, cn } from 'ui'
|
||||
import { Button, Command_Shadcn_, Dialog, DialogContent, DialogTrigger, cn } from 'ui'
|
||||
|
||||
import { useCurrentPage, usePageComponent, usePopPage } from './hooks/pagesHooks'
|
||||
import { useQuery, useSetQuery } from './hooks/queryHooks'
|
||||
@@ -82,7 +82,13 @@ function PageSwitch({ children }: PropsWithChildren) {
|
||||
return PageComponent ? <PageComponent /> : <CommandWrapper>{children}</CommandWrapper>
|
||||
}
|
||||
|
||||
function CommandMenu({ children }: PropsWithChildren) {
|
||||
interface CommandMenuProps extends PropsWithChildren {
|
||||
trigger?: ReactNode
|
||||
}
|
||||
|
||||
const CommandMenuTrigger = memo(DialogTrigger)
|
||||
|
||||
function CommandMenu({ children, trigger }: CommandMenuProps) {
|
||||
const open = useCommandMenuOpen()
|
||||
const setOpen = useSetCommandMenuOpen()
|
||||
|
||||
@@ -96,6 +102,7 @@ function CommandMenu({ children }: PropsWithChildren) {
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
{trigger}
|
||||
<DialogContent
|
||||
hideClose
|
||||
onInteractOutside={() => setOpen(false)}
|
||||
@@ -114,4 +121,4 @@ function CommandMenu({ children }: PropsWithChildren) {
|
||||
)
|
||||
}
|
||||
|
||||
export { Breadcrumb, CommandMenu, CommandWrapper }
|
||||
export { Breadcrumb, CommandMenu, CommandMenuTrigger, CommandWrapper }
|
||||
@@ -1,7 +1,7 @@
|
||||
export * from './api/Badges'
|
||||
export { CommandInput } from './api/CommandInput'
|
||||
export { CommandList } from './api/CommandList'
|
||||
export { Breadcrumb, CommandMenu, CommandWrapper } from './api/CommandMenu'
|
||||
export { Breadcrumb, CommandMenu, CommandMenuTrigger, CommandWrapper } from './api/CommandMenu'
|
||||
export { CommandProvider } from './api/CommandProvider'
|
||||
export { TextHighlighter, TextHighlighterBase } from './api/TextHighlighter'
|
||||
export * from './api/hooks/commandsHooks'
|
||||
|
||||
Reference in new issue
Block a user