Skip to content

Commit 3a5303b

Browse files
committed
Add typescript typings
1 parent e6585e6 commit 3a5303b

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

index.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Component } from 'react';
2+
import { NativeSyntheticEvent } from 'react-native';
3+
4+
export interface ContextMenuAction {
5+
/**
6+
* The title of the action
7+
*/
8+
title?: string;
9+
/**
10+
* The icon to use on ios. This is the name of the SFSymbols icon to use. On Android nothing will happen if you set this option.
11+
*/
12+
systemIcon?: string;
13+
}
14+
15+
export interface ContextMenu extends Component {
16+
/**
17+
* The title of the menu
18+
*/
19+
title?: string;
20+
/**
21+
* The actions to show the user when the menu is activated
22+
*/
23+
actions?: Array<ContextMenuAction>;
24+
/**
25+
* Handle when an action is triggered and the menu is closed. The name of the selected action will be passed in the event.
26+
*/
27+
onPress?: (e: NativeSyntheticEvent<{name: string}>) => void;
28+
/**
29+
* Handle when the menu is cancelled and closed
30+
*/
31+
onCancel?: () => void;
32+
}

ios/ContextMenu.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ - (UIView *) view {
1111

1212
RCT_EXPORT_VIEW_PROPERTY(title, NSString)
1313
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
14+
RCT_EXPORT_VIEW_PROPERTY(onCancel, RCTBubblingEventBlock)
1415
RCT_EXPORT_VIEW_PROPERTY(actions, NSArray<ContextMenuAction>)
1516

1617
@end

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "react-native-context-menu-view",
33
"title": "React Native Context Menu View",
4-
"version": "1.0.1",
5-
"description": "TODO",
4+
"version": "1.0.2",
5+
"description": "Use native context menu views from React Native",
66
"main": "index.js",
7+
"types": "index.d.ts",
78
"scripts": {
89
"test": "echo \"Error: no test specified\" && exit 1"
910
},

0 commit comments

Comments
 (0)