-
Notifications
You must be signed in to change notification settings - Fork 31
/
dialogs.types.ts
77 lines (73 loc) · 2.45 KB
/
dialogs.types.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
import { SerializedJSONValue } from './utils'
export interface OpenAlertOptions {
title: string
message: string
confirmLabel?: string
shouldCloseOnEscapePress?: boolean
shouldCloseOnOverlayClick?: boolean
}
export type OpenConfirmOptions = OpenAlertOptions & {
cancelLabel?: string
intent?: 'primary' | 'positive' | 'negative'
}
export interface OpenCustomWidgetOptions {
id?: string
width?: number | 'small' | 'medium' | 'large' | 'fullWidth'
minHeight?: number | string
allowHeightOverflow?: boolean
position?: 'center' | 'top'
title?: string
shouldCloseOnOverlayClick?: boolean
shouldCloseOnEscapePress?: boolean
parameters?: SerializedJSONValue
}
export interface EntityDialogOptions {
locale?: string
contentTypes?: string[]
min?: number
max?: number
}
export interface DialogsAPI {
/** Opens a simple alert window (which can only be closed). */
openAlert: (options: OpenAlertOptions) => Promise<boolean>
/** Opens a confirmation window. A user can either confirm or cancel the dialog. */
openConfirm: (options: OpenConfirmOptions) => Promise<boolean>
/** Opens a prompt window. A user can either provide a string input or cancel the dialog. */
openPrompt: (
options: OpenConfirmOptions & {
defaultValue?: string
},
) => Promise<string | boolean>
/** Opens an extension in a dialog. */
openExtension: (options: OpenCustomWidgetOptions) => Promise<any>
/** Opens the current app in a dialog */
openCurrentApp: (options?: Omit<OpenCustomWidgetOptions, 'id'>) => Promise<any>
/** Opens the current app or extension in a dialog */
openCurrent: (
options?: Omit<OpenCustomWidgetOptions, 'id'> | OpenCustomWidgetOptions,
) => Promise<any>
/** Opens a dialog for selecting a single entry. */
selectSingleEntry: <T = Object>(options?: {
locale?: string
contentTypes?: string[]
}) => Promise<T | null>
/** Opens a dialog for selecting multiple entries. */
selectMultipleEntries: <T = Object>(options?: {
locale?: string
contentTypes?: string[]
min?: number
max?: number
}) => Promise<T[] | null>
/** Opens a dialog for selecting a single asset. */
selectSingleAsset: <T = Object>(options?: {
locale?: string
mimetypeGroups?: string[]
}) => Promise<T | null>
/** Opens a dialog for selecting multiple assets. */
selectMultipleAssets: <T = Object>(options?: {
locale?: string
min?: number
max?: number
mimetypeGroups?: string[]
}) => Promise<T[] | null>
}