/** * TypeScript declaration for https://github.com/instea/react-native-popup-menu * * @author Wang Guan */ declare module "react-native-popup-menu" { import * as React from "react"; import { StyleProp, ViewStyle, TextStyle, ViewProps } from "react-native"; /** * MenuProvider * @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#menuprovider */ interface MenuProviderProps { style?: StyleProp; customStyles?: { menuProviderWrapper?: StyleProp; backdrop?: StyleProp; safeArea?: StyleProp; }; backHandler?: boolean | Function; skipInstanceCheck?: boolean; SafeAreaComponent?: React.ComponentType; children: React.ReactNode; } interface MenuProviderStatic extends React.ComponentClass { // FIXME: these methods does not get included in ref, unlike WebView in react-native.d.ts open(name: string): Promise; toggleMenu(name: string): Promise; close(): Promise; } 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; renderer?: Function; rendererProps?: any; style?: StyleProp; onSelect?(optionValue: any): any; onOpen?(): void; onClose?(): void; onBackdropPress?(): void; children?: React.ReactNode; } export class Menu extends React.Component { static debug: boolean; static setDefaultRenderer(renderer: Function): void; static setDefaultRendererProps(defaultRendererProps: any): void; /** Closes currently opened menu. */ close(): Promise; /** Returns `true` if this menu is open. */ isOpen(): boolean; /** Opens this menu. */ open(): Promise; } /** * 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; triggerWrapper?: StyleProp; triggerText?: StyleProp; TriggerTouchableComponent?: Function; triggerTouchable?: {}; }; testID?: string; triggerOnLongPress?: boolean; onPress?(): void; onAlternativeAction?(): void; children?: React.ReactNode; style?: StyleProp; accessible?: ViewProps["accessible"]; accessibilityRole?: ViewProps["accessibilityRole"]; accessibilityLabel?: ViewProps["accessibilityLabel"]; } export const MenuTrigger: React.ComponentClass; /** * MenuOptions * @see https://github.com/instea/react-native-popup-menu/blob/master/doc/api.md#menuoptions */ interface MenuOptionsProps { optionsContainerStyle?: StyleProp; renderOptionsContainer?: Function; customStyles?: MenuOptionsCustomStyle; children?: React.ReactNode; } interface MenuOptionsCustomStyle extends MenuOptionCustomStyle { optionsWrapper?: StyleProp; optionsContainer?: StyleProp; } export const MenuOptions: React.ComponentClass; /** * 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; onSelect?(): any; children?: React.ReactNode; accessible?: ViewProps["accessible"]; accessibilityRole?: ViewProps["accessibilityRole"]; accessibilityLabel?: ViewProps["accessibilityLabel"]; } interface MenuOptionCustomStyle { optionWrapper?: StyleProp; optionText?: StyleProp; optionTouchable?: {}; OptionTouchableComponent?: Function; } export const MenuOption: React.ComponentClass; /** * 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; closeMenu: () => Promise; toggleMenu: (name: string) => Promise; 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( component: React.ComponentType ): React.ComponentType>; }