-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommand.ts
73 lines (64 loc) · 2.02 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
import { ComponentType } from 'react'
import { TFunction } from 'react-i18next'
export interface 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
} & (
| {
imageUrl: string
Icon?: never
}
| {
imageUrl?: never
Icon: ComponentType<{ className?: string }>
}
)
export interface CommandModalContextSection<
ExtraItemProperties extends {} = {}
> {
name: string
items: CommandModalContextSectionItem<ExtraItemProperties>[]
onChoose: (item: CommandModalContextSectionItem<ExtraItemProperties>) => void
// If present, will be used to order sections before sorting by search field.
// For example: following DAOs should always appear above searched DAOs. If
// not present, will be after those with an order set. Ascending by order, so
// lowest orders first. This only applies when a search is being applied.
// Otherwise, the section order is used.
searchOrder?: number
}
export interface CommandModalContextUseSectionsOptions {
filter: string
}
export type CommandModalContextUseSections = (
options: CommandModalContextUseSectionsOptions
) => CommandModalContextSection[]
export interface CommandModalContext {
useSections: CommandModalContextUseSections
name: string
imageUrl?: string
}
export type CommandModalContextMakerOptions<MakerOptions extends {} = {}> =
MakerOptions & {
t: TFunction
openContext: (context: CommandModalContext) => void
}
export type CommandModalContextMaker<MakerOptions extends {} = {}> = (
options: CommandModalContextMakerOptions<MakerOptions>
) => CommandModalContext
export interface CommandModalDaoInfo {
chainId: string | undefined
coreAddress: string
name: string
imageUrl: string
}