-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathindex.d.ts
More file actions
232 lines (197 loc) · 6.06 KB
/
index.d.ts
File metadata and controls
232 lines (197 loc) · 6.06 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/**
* TypeScript declaration for https://github.com/instea/react-native-popup-menu
*
* @author Wang Guan <momocraft@gmail>
*/
declare module "react-native-popup-menu" {
import * as React from "react";
import { StyleProp, ViewStyle, TextStyle } from "react-native";
/**
* MenuProvider
* @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#menuprovider
*/
interface MenuProviderProps {
style?: StyleProp<ViewStyle>;
customStyles?: {
menuProviderWrapper?: StyleProp<ViewStyle>;
backdrop?: StyleProp<ViewStyle>;
};
backHandler?: boolean | Function;
skipInstanceCheck?: boolean;
children: React.ReactNode;
}
interface MenuProviderStatic extends React.ComponentClass<MenuProviderProps> {
// FIXME: these methods do not get included in ref, unlike WebView in react-native.d.ts
open(name: string): Promise<void>;
toggleMenu(name: string): Promise<void>;
close(): Promise<void>;
}
export const MenuProvider: MenuProviderStatic;
/**
* Menu
* @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#menu
*/
interface MenuProps {
name?: string;
opened?: boolean;
/**
* Possible menu renderer options:
* - `renderer.ContextMenu`
* - `renderer.NotAnimatedContextMenu`
* - `renderer.SlideInMenu`
* - `renderer.Popover`
*/
renderer?: Function;
/**
* Optional customization if you passed `renderer.Popover` to the `renderer` prop
*/
rendererProps?: {
placement?: "top" | "right" | "bottom" | "left" | "auto";
preferredPlacement?: "top" | "right" | "bottom" | "left";
anchorStyle?: StyleProp<ViewStyle>;
openAnimationDuration?: number;
closeAnimationDuration?: number;
};
style?: StyleProp<ViewStyle>;
onSelect?(optionValue: any): any;
onOpen?(): void;
onClose?(): void;
onBackdropPress?(): void;
children?: React.ReactNode;
}
export class Menu extends React.Component<MenuProps> {
static debug: boolean;
static setDefaultRenderer(renderer: Function): void;
static setDefaultRendererProps(defaultRendererProps: any): void;
/** Closes currently opened menu. */
close(): Promise<void>;
/** Returns `true` if this menu is open. */
isOpen(): boolean;
/** Opens this menu. */
open(): Promise<void>;
}
/**
* MenuTrigger
* @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#menutrigger
*/
interface MenuTriggerProps {
disabled?: boolean;
text?: string;
customStyles?: {
triggerOuterWrapper?: StyleProp<ViewStyle>;
triggerWrapper?: StyleProp<ViewStyle>;
triggerText?: StyleProp<TextStyle>;
TriggerTouchableComponent?: Function;
triggerTouchable?: {};
};
testID?: string;
triggerOnLongPress?: boolean;
onPress?(): void;
onAlternativeAction?(): void;
children?: React.ReactNode;
style?: StyleProp<ViewStyle>;
}
export const MenuTrigger: React.ComponentClass<MenuTriggerProps>;
/**
* MenuOptions
* @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#menuoptions
*/
interface MenuOptionsProps {
optionsContainerStyle?: StyleProp<ViewStyle>;
renderOptionsContainer?: Function;
customStyles?: MenuOptionsCustomStyle;
children?: React.ReactNode;
}
interface MenuOptionsCustomStyle extends MenuOptionCustomStyle {
optionsWrapper?: StyleProp<ViewStyle>;
optionsContainer?: StyleProp<ViewStyle>;
}
export const MenuOptions: React.ComponentClass<MenuOptionsProps>;
/**
* MenuOption
* @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#menuoption
*/
interface MenuOptionProps {
value?: any;
text?: string;
disabled?: boolean;
disableTouchable?: boolean;
customStyles?: MenuOptionCustomStyle;
style?: StyleProp<ViewStyle>;
onSelect?(): any;
children?: React.ReactNode;
testID?: string;
}
interface MenuOptionCustomStyle {
optionWrapper?: StyleProp<ViewStyle>;
optionText?: StyleProp<TextStyle>;
optionTouchable?: {};
OptionTouchableComponent?: Function;
}
export const MenuOption: React.ComponentClass<MenuOptionProps>;
/**
* Menu renderers
* @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#renderers
*/
export const renderers: Readonly<{
ContextMenu: Function;
NotAnimatedContextMenu: Function;
SlideInMenu: Function;
Popover: Function;
}>;
/**
* Types for MenuRegistry (which isn't exported)
*/
interface TriggerLayoutType {
x?: number;
y?: number;
width?: number;
height?: number;
}
interface OptionsLayoutType {
width?: number;
height?: number;
}
interface MenuEntry {
name: string;
instance: Menu;
triggerLayout?: TriggerLayoutType;
optionsLayout?: OptionsLayoutType;
optionsCustomStyles?: MenuOptionsCustomStyle;
}
interface MenuRegistry {
subscribe: (instance: Menu) => void;
unsubscribe: (instance: Menu) => void;
updateLayoutInfo: (
name: string,
layouts?: {
triggerLayout?: TriggerLayoutType;
optionsLayout?: OptionsLayoutType;
}
) => void;
setOptionsCustomStyles: (name: string, optionsCustomStyles: MenuOptionsCustomStyle) => void;
getMenu: (name: string) => MenuEntry;
getAll: () => MenuEntry[];
}
/**
* withMenuContext
* @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#menuprovider
*/
interface MenuActions {
openMenu: (name: string) => Promise<void>;
closeMenu: () => Promise<void>;
toggleMenu: (name: string) => Promise<void>;
isMenuOpen: () => boolean;
}
export interface MenuContext {
// This part shouldn't be exported to the user so it's commented out
// menuRegistry: MenuRegistry;
menuActions: MenuActions;
}
interface MenuContextProps {
ctx: MenuContext;
}
export function withMenuContext<PropType extends MenuContextProps>(
component: React.ComponentType<PropType>
): React.ComponentType<Omit<PropType, "ctx">>;
}