Skip to content

Commit

Permalink
Add typescript typings
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiannucci committed Apr 28, 2020
1 parent e6585e6 commit 3a5303b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
32 changes: 32 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Component } from 'react';
import { NativeSyntheticEvent } from 'react-native';

export interface ContextMenuAction {
/**
* The title of the action
*/
title?: string;
/**
* 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.
*/
systemIcon?: string;
}

export interface ContextMenu extends Component {
/**
* The title of the menu
*/
title?: string;
/**
* The actions to show the user when the menu is activated
*/
actions?: Array<ContextMenuAction>;
/**
* Handle when an action is triggered and the menu is closed. The name of the selected action will be passed in the event.
*/
onPress?: (e: NativeSyntheticEvent<{name: string}>) => void;
/**
* Handle when the menu is cancelled and closed
*/
onCancel?: () => void;
}
1 change: 1 addition & 0 deletions ios/ContextMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ - (UIView *) view {

RCT_EXPORT_VIEW_PROPERTY(title, NSString)
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onCancel, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(actions, NSArray<ContextMenuAction>)

@end
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "react-native-context-menu-view",
"title": "React Native Context Menu View",
"version": "1.0.1",
"description": "TODO",
"version": "1.0.2",
"description": "Use native context menu views from React Native",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down

0 comments on commit 3a5303b

Please sign in to comment.