Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved DX by adding missing type definition #287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ To style `<MenuTrigger />` component you can pass `customStyles` object prop wit
|`triggerOuterWrapper`|`Style`|Style of outer `View` component|
|`triggerWrapper`|`Style`|Style of inner `View` component (can be overriden by `style` prop)|
|`triggerText`|`Style`|Style of `Text` component (used when `text` shorthand option is defined)|
|`TriggerTouchableComponent`|`Component`|Touchable component of trigger. Default value is `TouchableHighlight` for iOS and `TouchableNativeFeedvack` for Android|
|`TriggerTouchableComponent`|`Component`|Touchable component of trigger. Default value is `TouchableHighlight` for iOS and `TouchableNativeFeedback` for Android|
|`triggerTouchable`|`Object`|Properties passed to the touchable component (e.g. `activeOpacity`, `underlayColor` for `TouchableHighlight`)|

**Note:** `Style` type is any valid RN style parameter.
Expand Down Expand Up @@ -152,7 +152,7 @@ To style `<MenuOptions />` and it's `<MenuOption />` components you can pass `cu
|`optionsContainer`|`Style`|Style passed to the menu renderer (e.g. `Animated.View`)|
|`optionWrapper`|`Style`|Style of `View` component wrapping single option|
|`optionText`|`Style`|Style of `Text` component (when `text` shorthand option is defined)|
|`OptionTouchableComponent`|`Component`|Touchable component of option. Default value is `TouchableHighlight` for iOS and `TouchableNativeFeedvack` for Android|
|`OptionTouchableComponent`|`Component`|Touchable component of option. Default value is `TouchableHighlight` for iOS and `TouchableNativeFeedback` for Android|
|`optionTouchable`|`Object`|Properties passed to the touchable component (e.g. `activeOpacity`, `underlayColor` for `TouchableHighlight`)|

**Note:** `optionWrapper`, `optionTouchable` and `optionText` styles of particular menu option can be overriden by `customStyles` prop of `<MenuOption />` component.
Expand Down Expand Up @@ -190,7 +190,7 @@ To style `<MenuOption />` component you can pass `customStyles` object prop with
|---|---|---|
|`optionWrapper`|`Style`|Style of wrapping `View` component.|
|`optionText`|`Style`|Style of `Text` component (when `text` shorthand option is defined)|
|`OptionTouchableComponent`|`Component`|Touchable component of option. Default value is `TouchableHighlight` for iOS and `TouchableNativeFeedvack` for Android|
|`OptionTouchableComponent`|`Component`|Touchable component of option. Default value is `TouchableHighlight` for iOS and `TouchableNativeFeedback` for Android|
|`optionTouchable`|`Object`|Properties passed to the touchable component (e.g. `activeOpacity`, `underlayColor` for `TouchableHighlight`)|

**Note:** `Style` type is any valid RN style parameter.
Expand Down
24 changes: 20 additions & 4 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare module "react-native-popup-menu" {
}

interface MenuProviderStatic extends React.ComponentClass<MenuProviderProps> {
// FIXME: these methods does not get included in ref, unlike WebView in react-native.d.ts
// 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>;
Expand All @@ -41,8 +41,24 @@ declare module "react-native-popup-menu" {
interface MenuProps {
name?: string;
opened?: boolean;
/**
* Possible menu renderer options:
* - `renderer.ContextMenu`
* - `renderer.NotAnimatedContextMenu`
* - `renderer.SlideInMenu`
* - `renderer.Popover`
*/
renderer?: Function;
rendererProps?: any;
/**
* 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;
Expand Down Expand Up @@ -88,7 +104,7 @@ declare module "react-native-popup-menu" {
triggerOnLongPress?: boolean;

onPress?(): void;
onAlternativeAction? (): void;
onAlternativeAction?(): void;
children?: React.ReactNode;
style?: StyleProp<ViewStyle>;
}
Expand Down Expand Up @@ -199,7 +215,7 @@ declare module "react-native-popup-menu" {
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;
Expand Down