forked from Zerthox/betterdiscord-types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.d.ts
102 lines (84 loc) · 2.67 KB
/
ui.d.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
export interface UI {
/** Shows a generic but customizable modal. */
alert(title: string, content: React.ReactNode): void;
/** Creates a tooltip to show on hover. */
createTooltip(
node: HTMLElement,
content: string | HTMLElement,
options?: TooltipOptions,
): Tooltip;
/** Shows a generic but customizable confirmation modal with optional confirm and cancel callbacks. */
showConfirmationModal(
title: string,
content: React.ReactNode,
options?: ConfirmationModalOptions,
): string;
/** Shows a toast towards the bottom of the screen. */
showToast(content: string, options?: ToastOptions): void;
/** Shows a notice above Discord's chat layer. */
showNotice(content: string | Node, options?: NoticeOptions): CloseNotice;
/** Opens an Electron dialog. */
openDialog(options: DialogSaveOptions): Promise<DialogSaveResult>;
openDialog(options: DialogOpenOptions): Promise<DialogOpenResult>;
}
export interface TooltipOptions {
style?: "primary" | "info" | "success" | "warn" | "danger";
side?: "top" | "right" | "bottom" | "left";
preventFlip?: boolean;
disabled?: boolean;
}
export type Tooltip = any;
export interface ConfirmationModalOptions {
danger?: boolean;
confirmText?: string;
cancelText?: string;
onConfirm?: () => void;
onCancel?: () => void;
}
export interface NoticeOptions {
type?: "info" | "error" | "warning" | "success";
buttons?: { label: string; onClick: () => void }[];
timeout?: number;
}
export type CloseNotice = (immediately?: boolean) => void;
export interface ToastOptions {
type?: "" | "info" | "success" | "danger" | "error" | "warning" | "warn";
icon?: boolean;
timeout?: number;
forceShow?: boolean;
}
export interface DialogOptions {
mode?: "open" | "save";
defaultPath?: string;
filters?: FileFilter[];
title?: string;
message?: string;
showOverwriteConfirmation?: boolean;
showHiddenFiles?: boolean;
promptToCreate?: boolean;
openDirectory?: boolean;
openFile?: boolean;
multiSelections?: boolean;
modal?: boolean;
}
export interface FileFilter {
name: string;
extensions: string[];
}
export interface DialogOpenOptions extends DialogOptions {
mode?: "open";
}
export interface DialogSaveOptions extends DialogOptions {
mode: "save";
}
export interface DialogResult {
cancelled: boolean;
filePath?: string;
filePaths?: string[];
}
export interface DialogOpenResult extends Omit<DialogResult, "filePaths"> {
filePath: string;
}
export interface DialogSaveResult extends Omit<DialogResult, "filePath"> {
filePaths: string[];
}