From 43fbfecafe31778403d97e5182265afe82874150 Mon Sep 17 00:00:00 2001 From: Sufian <9989266+SufianBabri@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:46:15 +0500 Subject: [PATCH 1/2] Update index.d.ts Update type definition for better DX --- src/index.d.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 7e1ef2e..d14b00f 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -24,7 +24,7 @@ declare module "react-native-popup-menu" { } interface MenuProviderStatic extends React.ComponentClass { - // 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; toggleMenu(name: string): Promise; @@ -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; + openAnimationDuration?: number; + closeAnimationDuration?: number; + }; style?: StyleProp; onSelect?(optionValue: any): any; @@ -88,7 +104,7 @@ declare module "react-native-popup-menu" { triggerOnLongPress?: boolean; onPress?(): void; - onAlternativeAction? (): void; + onAlternativeAction?(): void; children?: React.ReactNode; style?: StyleProp; } @@ -199,7 +215,7 @@ declare module "react-native-popup-menu" { 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; From 58d230e0d5f3cd0bf8f7e242bfb3c5e4ef147ae0 Mon Sep 17 00:00:00 2001 From: Sufian <9989266+SufianBabri@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:48:50 +0500 Subject: [PATCH 2/2] Update api.md Fix typo --- doc/api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api.md b/doc/api.md index 6ab0776..37ca93f 100644 --- a/doc/api.md +++ b/doc/api.md @@ -122,7 +122,7 @@ To style `` 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. @@ -152,7 +152,7 @@ To style `` and it's `` 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 `` component. @@ -190,7 +190,7 @@ To style `` 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.