-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcommand.ts
80 lines (69 loc) · 2.11 KB
/
command.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { ComponentType, ReactNode } from 'react'
import { TFunction } from 'react-i18next'
import { ContractVersion } from './features'
export type StatefulCommandModalProps = {
visible: boolean
setVisible: (visible: boolean) => void
// Root context maker can take no extra options.
makeRootContext: CommandModalContextMaker
}
export type CommandModalContextSectionItem<
ExtraItemProperties extends {} = {},
> = ExtraItemProperties & {
name: string
tooltip?: string
className?: string
disabled?: boolean
loading?: boolean
// If true, sorts last even if it matches search.
sortLast?: boolean
/**
* Optional set of additional keywords to match.
*/
keywords?: string[]
} & (
| {
imageUrl: string
Icon?: never
}
| {
imageUrl?: never
Icon: ComponentType<{ className: string }>
}
)
export type CommandModalContextSection<ExtraItemProperties extends {} = {}> = {
name: string
items: CommandModalContextSectionItem<ExtraItemProperties>[]
onChoose: (item: CommandModalContextSectionItem<ExtraItemProperties>) => void
loading?: boolean
}
export type CommandModalContextUseSectionsOptions = {
filter: string
}
export type CommandModalContextUseSections = (
options: CommandModalContextUseSectionsOptions
) => CommandModalContextSection[]
export type CommandModalContext = {
useSections: CommandModalContextUseSections
name: string
imageUrl?: string
// If defined, will wrap the context with this component around where
// `useSections` will be called.
Wrapper?: CommandModalContextWrapper
}
export type CommandModalContextWrapper = ComponentType<{ children: ReactNode }>
export type CommandModalContextMakerOptions<MakerOptions extends {} = {}> =
MakerOptions & {
t: TFunction
openContext: (context: CommandModalContext) => void
}
export type CommandModalContextMaker<MakerOptions extends {} = {}> = (
options: CommandModalContextMakerOptions<MakerOptions>
) => CommandModalContext
export type CommandModalDaoInfo = {
chainId: string
coreAddress: string
coreVersion: ContractVersion | undefined
name: string
imageUrl: string
}