@react-native-menu/menu 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +15 -0
- package/.gitattributes +3 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +8 -0
- package/.github/dependabot.yml +51 -0
- package/.github/workflows/ci.yml +90 -0
- package/.gitignore +60 -0
- package/CONTRIBUTING.md +184 -0
- package/android/gradle.properties +3 -3
- package/babel.config.js +3 -0
- package/example/.gitignore +14 -0
- package/example/.watchmanconfig +1 -0
- package/example/android/build.gradle +14 -0
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/example/android/gradle.properties +6 -0
- package/example/android/gradlew +185 -0
- package/example/android/gradlew.bat +89 -0
- package/example/android/settings.gradle +12 -0
- package/example/app.json +28 -0
- package/example/babel.config.js +3 -0
- package/example/index.tsx +5 -0
- package/example/ios/Podfile +7 -0
- package/example/ios/Podfile.lock +515 -0
- package/example/metro.config.js +44 -0
- package/example/package.json +34 -0
- package/example/react-native.config.js +61 -0
- package/example/src/App.tsx +187 -0
- package/example/yarn.lock +6542 -0
- package/ios/ActionSheetView.swift +3 -8
- package/lib/commonjs/UIMenuView.android.js.map +1 -1
- package/lib/commonjs/UIMenuView.ios.js.map +1 -1
- package/lib/commonjs/UIMenuView.js +2 -2
- package/lib/commonjs/UIMenuView.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/UIMenuView.android.js.map +1 -1
- package/lib/module/UIMenuView.ios.js.map +1 -1
- package/lib/module/UIMenuView.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/example/index.d.ts +1 -0
- package/lib/typescript/example/src/App.d.ts +2 -0
- package/lib/typescript/src/__tests__/index.test.d.ts +0 -0
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/types.d.ts +4 -2
- package/package.json +6 -5
- package/src/__tests__/index.test.tsx +1 -0
- package/src/index.tsx +2 -1
- package/src/types.ts +6 -2
- package/tsconfig.json +27 -0
- package/yarn.lock +10334 -0
|
@@ -11,14 +11,9 @@ import UIKit
|
|
|
11
11
|
@objc(ActionSheetView)
|
|
12
12
|
class ActionSheetView: UIView {
|
|
13
13
|
@objc var onPressAction: RCTDirectEventBlock?
|
|
14
|
-
private var _title: String
|
|
14
|
+
private var _title: String?;
|
|
15
15
|
@objc var title: NSString? {
|
|
16
|
-
didSet {
|
|
17
|
-
guard let title = self.title else {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
self._title = title as String
|
|
21
|
-
}
|
|
16
|
+
didSet { self._title = title as? String }
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
private var _actions: [UIAlertAction] = [];
|
|
@@ -53,7 +48,7 @@ class ActionSheetView: UIView {
|
|
|
53
48
|
let alert = UIAlertController(title: _title, message: nil, preferredStyle: .actionSheet)
|
|
54
49
|
|
|
55
50
|
self._actions.forEach({action in
|
|
56
|
-
alert.addAction(action)
|
|
51
|
+
alert.addAction(action.copy() as! UIAlertAction)
|
|
57
52
|
})
|
|
58
53
|
|
|
59
54
|
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["MenuComponent","requireNativeComponent"],"sources":["UIMenuView.android.tsx"],"sourcesContent":["import { HostComponent, requireNativeComponent } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\nconst MenuComponent = requireNativeComponent(\n 'MenuView'\n) as HostComponent<NativeMenuComponentProps>;\n\nexport default MenuComponent;\n"],"mappings":";;;;;;;AAAA;;AAGA,MAAMA,aAAa,GAAG,IAAAC,mCAAA,EACpB,UADoB,CAAtB;eAIeD,a"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["MenuComponent","requireNativeComponent"],"sources":["UIMenuView.ios.tsx"],"sourcesContent":["import { HostComponent, requireNativeComponent } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\nconst MenuComponent = requireNativeComponent(\n 'RCTUIMenu'\n) as HostComponent<NativeMenuComponentProps>;\n\nexport default MenuComponent;\n"],"mappings":";;;;;;;AAAA;;AAGA,MAAMA,aAAa,GAAG,IAAAC,mCAAA,EACpB,WADoB,CAAtB;eAIeD,a"}
|
|
@@ -9,9 +9,9 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
|
|
12
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* TODO: implement for Web
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["MenuView","style","children"],"sources":["UIMenuView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\n/**\n * TODO: implement for Web\n */\nconst MenuView: React.FC<NativeMenuComponentProps> = ({ style, children }) => {\n return <View style={style}>{children}</View>;\n};\n\nexport default MenuView;\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAGA;AACA;AACA;AACA,MAAMA,QAA4C,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAyB;EAC5E,oBAAO,oBAAC,iBAAD;IAAM,KAAK,EAAED;EAAb,GAAqBC,QAArB,CAAP;AACD,CAFD;;eAIeF,Q"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var _UIMenuView = _interopRequireDefault(require("./UIMenuView"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
function _extends() { _extends = Object.assign
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
17
|
|
|
18
18
|
function processAction(action) {
|
|
19
19
|
var _action$subactions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["processAction","action","imageColor","processColor","titleColor","subactions","map","subAction","MenuView","actions","props","processedActions"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\nimport { processColor } from 'react-native';\n\nimport UIMenuView from './UIMenuView';\nimport type {\n MenuComponentProps,\n MenuAction,\n ProcessedMenuAction,\n NativeActionEvent,\n} from './types';\n\nfunction processAction(action: MenuAction): ProcessedMenuAction {\n return {\n ...action,\n imageColor: processColor(action.imageColor),\n titleColor: processColor(action.titleColor),\n subactions: action.subactions?.map((subAction) => processAction(subAction)),\n };\n}\n\nconst MenuView: React.FC<MenuComponentProps> = ({ actions, ...props }) => {\n const processedActions = actions.map<ProcessedMenuAction>((action) =>\n processAction(action)\n );\n return <UIMenuView {...props} actions={processedActions} />;\n};\n\nexport { MenuView };\nexport type { MenuComponentProps, MenuAction, NativeActionEvent };\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;AAQA,SAASA,aAAT,CAAuBC,MAAvB,EAAgE;EAAA;;EAC9D,OAAO,EACL,GAAGA,MADE;IAELC,UAAU,EAAE,IAAAC,yBAAA,EAAaF,MAAM,CAACC,UAApB,CAFP;IAGLE,UAAU,EAAE,IAAAD,yBAAA,EAAaF,MAAM,CAACG,UAApB,CAHP;IAILC,UAAU,wBAAEJ,MAAM,CAACI,UAAT,uDAAE,mBAAmBC,GAAnB,CAAwBC,SAAD,IAAeP,aAAa,CAACO,SAAD,CAAnD;EAJP,CAAP;AAMD;;AAED,MAAMC,QAAsC,GAAG,CAAC;EAAEC,OAAF;EAAW,GAAGC;AAAd,CAAD,KAA2B;EACxE,MAAMC,gBAAgB,GAAGF,OAAO,CAACH,GAAR,CAAkCL,MAAD,IACxDD,aAAa,CAACC,MAAD,CADU,CAAzB;EAGA,oBAAO,6BAAC,mBAAD,eAAgBS,KAAhB;IAAuB,OAAO,EAAEC;EAAhC,GAAP;AACD,CALD"}
|
package/lib/commonjs/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n ColorValue,\n processColor,\n StyleProp,\n ViewStyle,\n} from 'react-native';\nimport type * as React from 'react';\n\nexport type NativeActionEvent = {\n nativeEvent: {\n event: string;\n };\n};\n\ntype MenuAttributes = {\n /**\n * An attribute indicating the destructive style.\n */\n destructive?: boolean;\n /**\n * An attribute indicating the disabled style.\n */\n disabled?: boolean;\n /**\n * An attribute indicating the hidden style.\n */\n hidden?: boolean;\n};\n\n/**\n * The state of the action.\n * - off: A constant indicating the menu element is in the “off” state.\n * - on: A constant indicating the menu element is in the “on” state.\n * - mixed: A constant indicating the menu element is in the “mixed” state.\n */\ntype MenuState = 'off' | 'on' | 'mixed';\n\nexport type MenuAction = {\n /**\n * Identifier of the menu action.\n * The value set in this id will be returned when menu is selected.\n */\n id?: string;\n /**\n * The action's title.\n */\n title: string;\n /**\n * (Android only)\n * The action's title color.\n * @platform Android\n */\n titleColor?: number | ColorValue;\n /**\n * (iOS14+ only)\n * An elaborated title that explains the purpose of the action.\n * @platform iOS\n */\n subtitle?: string;\n /**\n * The attributes indicating the style of the action.\n */\n attributes?: MenuAttributes;\n /**\n * (iOS14+ only)\n * The state of the action.\n * @platform iOS\n */\n state?: MenuState;\n /**\n * (Android and iOS13+ only)\n * - The action's image.\n * - Allows icon name included in project or system (Android) resources drawables and\n * in SF Symbol (iOS)\n * @example // (iOS)\n * image=\"plus\"\n * @example // (Android)\n * image=\"ic_menu_add\"\n * - TODO: Allow images other than those included in SF Symbol and resources drawables\n */\n image?: string;\n /**\n * (Android and iOS13+ only)\n * - The action's image color.\n */\n imageColor?: number | ColorValue;\n /**\n * (Android and iOS14+ only)\n * - Actions to be displayed in the sub menu\n * - On Android it does not support nesting next sub menus in sub menu item\n */\n subactions?: MenuAction[];\n};\n\ntype MenuComponentPropsBase = {\n style?: StyleProp<ViewStyle>;\n /**\n * Callback function that will be called when selecting a menu item.\n * It will contain id of the given action.\n */\n onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;\n /**\n * Actions to be displayed in the menu.\n */\n actions: MenuAction[];\n /**\n * The title of the menu.\n */\n title?: string;\n /**\n * (Android API 23+)\n * Boolean value determines whether popup menu should be anchored\n * to right corner of parent view - default value is `false`\n * @platform Android\n */\n isAnchoredToRight?: boolean;\n /**\n * Determines if menu should open after long press or on normal press\n *\n * @default false\n */\n shouldOpenOnLongPress?: boolean;\n};\n\nexport type MenuComponentProps =\n React.PropsWithChildren<MenuComponentPropsBase>;\n\nexport type ProcessedMenuAction = Omit<\n MenuAction,\n 'imageColor' | 'titleColor' | 'subactions'\n> & {\n imageColor: ReturnType<typeof processColor>;\n titleColor: ReturnType<typeof processColor>;\n subactions?: ProcessedMenuAction[];\n};\n\nexport type NativeMenuComponentProps = {\n style?: StyleProp<ViewStyle>;\n onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;\n actions: ProcessedMenuAction[];\n title?: string;\n};\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["requireNativeComponent","MenuComponent"],"sources":["UIMenuView.android.tsx"],"sourcesContent":["import { HostComponent, requireNativeComponent } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\nconst MenuComponent = requireNativeComponent(\n 'MenuView'\n) as HostComponent<NativeMenuComponentProps>;\n\nexport default MenuComponent;\n"],"mappings":"AAAA,SAAwBA,sBAAxB,QAAsD,cAAtD;AAGA,MAAMC,aAAa,GAAGD,sBAAsB,CAC1C,UAD0C,CAA5C;AAIA,eAAeC,aAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["requireNativeComponent","MenuComponent"],"sources":["UIMenuView.ios.tsx"],"sourcesContent":["import { HostComponent, requireNativeComponent } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\nconst MenuComponent = requireNativeComponent(\n 'RCTUIMenu'\n) as HostComponent<NativeMenuComponentProps>;\n\nexport default MenuComponent;\n"],"mappings":"AAAA,SAAwBA,sBAAxB,QAAsD,cAAtD;AAGA,MAAMC,aAAa,GAAGD,sBAAsB,CAC1C,WAD0C,CAA5C;AAIA,eAAeC,aAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","View","MenuView","style","children"],"sources":["UIMenuView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\nimport type { NativeMenuComponentProps } from './types';\n\n/**\n * TODO: implement for Web\n */\nconst MenuView: React.FC<NativeMenuComponentProps> = ({ style, children }) => {\n return <View style={style}>{children}</View>;\n};\n\nexport default MenuView;\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAqB,cAArB;;AAGA;AACA;AACA;AACA,MAAMC,QAA4C,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAyB;EAC5E,oBAAO,oBAAC,IAAD;IAAM,KAAK,EAAED;EAAb,GAAqBC,QAArB,CAAP;AACD,CAFD;;AAIA,eAAeF,QAAf"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { processColor } from 'react-native';
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","processColor","UIMenuView","processAction","action","imageColor","titleColor","subactions","map","subAction","MenuView","actions","props","processedActions"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\nimport { processColor } from 'react-native';\n\nimport UIMenuView from './UIMenuView';\nimport type {\n MenuComponentProps,\n MenuAction,\n ProcessedMenuAction,\n NativeActionEvent,\n} from './types';\n\nfunction processAction(action: MenuAction): ProcessedMenuAction {\n return {\n ...action,\n imageColor: processColor(action.imageColor),\n titleColor: processColor(action.titleColor),\n subactions: action.subactions?.map((subAction) => processAction(subAction)),\n };\n}\n\nconst MenuView: React.FC<MenuComponentProps> = ({ actions, ...props }) => {\n const processedActions = actions.map<ProcessedMenuAction>((action) =>\n processAction(action)\n );\n return <UIMenuView {...props} actions={processedActions} />;\n};\n\nexport { MenuView };\nexport type { MenuComponentProps, MenuAction, NativeActionEvent };\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,YAAT,QAA6B,cAA7B;AAEA,OAAOC,UAAP,MAAuB,cAAvB;;AAQA,SAASC,aAAT,CAAuBC,MAAvB,EAAgE;EAAA;;EAC9D,OAAO,EACL,GAAGA,MADE;IAELC,UAAU,EAAEJ,YAAY,CAACG,MAAM,CAACC,UAAR,CAFnB;IAGLC,UAAU,EAAEL,YAAY,CAACG,MAAM,CAACE,UAAR,CAHnB;IAILC,UAAU,wBAAEH,MAAM,CAACG,UAAT,uDAAE,mBAAmBC,GAAnB,CAAwBC,SAAD,IAAeN,aAAa,CAACM,SAAD,CAAnD;EAJP,CAAP;AAMD;;AAED,MAAMC,QAAsC,GAAG,CAAC;EAAEC,OAAF;EAAW,GAAGC;AAAd,CAAD,KAA2B;EACxE,MAAMC,gBAAgB,GAAGF,OAAO,CAACH,GAAR,CAAkCJ,MAAD,IACxDD,aAAa,CAACC,MAAD,CADU,CAAzB;EAGA,oBAAO,oBAAC,UAAD,eAAgBQ,KAAhB;IAAuB,OAAO,EAAEC;EAAhC,GAAP;AACD,CALD;;AAOA,SAASH,QAAT"}
|
package/lib/module/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n ColorValue,\n processColor,\n StyleProp,\n ViewStyle,\n} from 'react-native';\nimport type * as React from 'react';\n\nexport type NativeActionEvent = {\n nativeEvent: {\n event: string;\n };\n};\n\ntype MenuAttributes = {\n /**\n * An attribute indicating the destructive style.\n */\n destructive?: boolean;\n /**\n * An attribute indicating the disabled style.\n */\n disabled?: boolean;\n /**\n * An attribute indicating the hidden style.\n */\n hidden?: boolean;\n};\n\n/**\n * The state of the action.\n * - off: A constant indicating the menu element is in the “off” state.\n * - on: A constant indicating the menu element is in the “on” state.\n * - mixed: A constant indicating the menu element is in the “mixed” state.\n */\ntype MenuState = 'off' | 'on' | 'mixed';\n\nexport type MenuAction = {\n /**\n * Identifier of the menu action.\n * The value set in this id will be returned when menu is selected.\n */\n id?: string;\n /**\n * The action's title.\n */\n title: string;\n /**\n * (Android only)\n * The action's title color.\n * @platform Android\n */\n titleColor?: number | ColorValue;\n /**\n * (iOS14+ only)\n * An elaborated title that explains the purpose of the action.\n * @platform iOS\n */\n subtitle?: string;\n /**\n * The attributes indicating the style of the action.\n */\n attributes?: MenuAttributes;\n /**\n * (iOS14+ only)\n * The state of the action.\n * @platform iOS\n */\n state?: MenuState;\n /**\n * (Android and iOS13+ only)\n * - The action's image.\n * - Allows icon name included in project or system (Android) resources drawables and\n * in SF Symbol (iOS)\n * @example // (iOS)\n * image=\"plus\"\n * @example // (Android)\n * image=\"ic_menu_add\"\n * - TODO: Allow images other than those included in SF Symbol and resources drawables\n */\n image?: string;\n /**\n * (Android and iOS13+ only)\n * - The action's image color.\n */\n imageColor?: number | ColorValue;\n /**\n * (Android and iOS14+ only)\n * - Actions to be displayed in the sub menu\n * - On Android it does not support nesting next sub menus in sub menu item\n */\n subactions?: MenuAction[];\n};\n\ntype MenuComponentPropsBase = {\n style?: StyleProp<ViewStyle>;\n /**\n * Callback function that will be called when selecting a menu item.\n * It will contain id of the given action.\n */\n onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;\n /**\n * Actions to be displayed in the menu.\n */\n actions: MenuAction[];\n /**\n * The title of the menu.\n */\n title?: string;\n /**\n * (Android API 23+)\n * Boolean value determines whether popup menu should be anchored\n * to right corner of parent view - default value is `false`\n * @platform Android\n */\n isAnchoredToRight?: boolean;\n /**\n * Determines if menu should open after long press or on normal press\n *\n * @default false\n */\n shouldOpenOnLongPress?: boolean;\n};\n\nexport type MenuComponentProps =\n React.PropsWithChildren<MenuComponentPropsBase>;\n\nexport type ProcessedMenuAction = Omit<\n MenuAction,\n 'imageColor' | 'titleColor' | 'subactions'\n> & {\n imageColor: ReturnType<typeof processColor>;\n titleColor: ReturnType<typeof processColor>;\n subactions?: ProcessedMenuAction[];\n};\n\nexport type NativeMenuComponentProps = {\n style?: StyleProp<ViewStyle>;\n onPressAction?: ({ nativeEvent }: NativeActionEvent) => void;\n actions: ProcessedMenuAction[];\n title?: string;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { MenuComponentProps, MenuAction } from './types';
|
|
2
|
+
import type { MenuComponentProps, MenuAction, NativeActionEvent } from './types';
|
|
3
3
|
declare const MenuView: React.FC<MenuComponentProps>;
|
|
4
4
|
export { MenuView };
|
|
5
|
-
export type { MenuComponentProps, MenuAction };
|
|
5
|
+
export type { MenuComponentProps, MenuAction, NativeActionEvent };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ColorValue, processColor, StyleProp, ViewStyle } from 'react-native';
|
|
2
|
-
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
export declare type NativeActionEvent = {
|
|
3
4
|
nativeEvent: {
|
|
4
5
|
event: string;
|
|
5
6
|
};
|
|
@@ -81,7 +82,7 @@ export declare type MenuAction = {
|
|
|
81
82
|
*/
|
|
82
83
|
subactions?: MenuAction[];
|
|
83
84
|
};
|
|
84
|
-
|
|
85
|
+
declare type MenuComponentPropsBase = {
|
|
85
86
|
style?: StyleProp<ViewStyle>;
|
|
86
87
|
/**
|
|
87
88
|
* Callback function that will be called when selecting a menu item.
|
|
@@ -110,6 +111,7 @@ export declare type MenuComponentProps = {
|
|
|
110
111
|
*/
|
|
111
112
|
shouldOpenOnLongPress?: boolean;
|
|
112
113
|
};
|
|
114
|
+
export declare type MenuComponentProps = React.PropsWithChildren<MenuComponentPropsBase>;
|
|
113
115
|
export declare type ProcessedMenuAction = Omit<MenuAction, 'imageColor' | 'titleColor' | 'subactions'> & {
|
|
114
116
|
imageColor: ReturnType<typeof processColor>;
|
|
115
117
|
titleColor: ReturnType<typeof processColor>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-menu/menu",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "UIMenu component for react-native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -45,17 +45,18 @@
|
|
|
45
45
|
"@react-native-community/bob": "^0.17.1",
|
|
46
46
|
"@react-native-community/eslint-config": "^3.0.0",
|
|
47
47
|
"@release-it/conventional-changelog": "^1.1.4",
|
|
48
|
-
"@types/jest": "^
|
|
48
|
+
"@types/jest": "^27.0.3",
|
|
49
49
|
"@types/react": "^17.0.1",
|
|
50
|
-
"@types/react-native": "0.
|
|
51
|
-
"eslint": "7.
|
|
50
|
+
"@types/react-native": "0.67.6",
|
|
51
|
+
"eslint": "7.32.0",
|
|
52
52
|
"eslint-config-prettier": "^8.1.0",
|
|
53
53
|
"eslint-plugin-prettier": "^3.1.3",
|
|
54
|
-
"jest": "^
|
|
54
|
+
"jest": "^27.0.6",
|
|
55
55
|
"pod-install": "^0.1.0",
|
|
56
56
|
"prettier": "^2.2.1",
|
|
57
57
|
"react": "17.0.1",
|
|
58
58
|
"react-native": "0.64.1",
|
|
59
|
+
"react-native-test-app": "^1.6.17",
|
|
59
60
|
"release-it": "^14.10.0",
|
|
60
61
|
"typescript": "^4.1.3"
|
|
61
62
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
it.todo('write a test');
|
package/src/index.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
MenuComponentProps,
|
|
7
7
|
MenuAction,
|
|
8
8
|
ProcessedMenuAction,
|
|
9
|
+
NativeActionEvent,
|
|
9
10
|
} from './types';
|
|
10
11
|
|
|
11
12
|
function processAction(action: MenuAction): ProcessedMenuAction {
|
|
@@ -25,4 +26,4 @@ const MenuView: React.FC<MenuComponentProps> = ({ actions, ...props }) => {
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
export { MenuView };
|
|
28
|
-
export type { MenuComponentProps, MenuAction };
|
|
29
|
+
export type { MenuComponentProps, MenuAction, NativeActionEvent };
|
package/src/types.ts
CHANGED
|
@@ -4,8 +4,9 @@ import type {
|
|
|
4
4
|
StyleProp,
|
|
5
5
|
ViewStyle,
|
|
6
6
|
} from 'react-native';
|
|
7
|
+
import type * as React from 'react';
|
|
7
8
|
|
|
8
|
-
type NativeActionEvent = {
|
|
9
|
+
export type NativeActionEvent = {
|
|
9
10
|
nativeEvent: {
|
|
10
11
|
event: string;
|
|
11
12
|
};
|
|
@@ -91,7 +92,7 @@ export type MenuAction = {
|
|
|
91
92
|
subactions?: MenuAction[];
|
|
92
93
|
};
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
type MenuComponentPropsBase = {
|
|
95
96
|
style?: StyleProp<ViewStyle>;
|
|
96
97
|
/**
|
|
97
98
|
* Callback function that will be called when selecting a menu item.
|
|
@@ -121,6 +122,9 @@ export type MenuComponentProps = {
|
|
|
121
122
|
shouldOpenOnLongPress?: boolean;
|
|
122
123
|
};
|
|
123
124
|
|
|
125
|
+
export type MenuComponentProps =
|
|
126
|
+
React.PropsWithChildren<MenuComponentPropsBase>;
|
|
127
|
+
|
|
124
128
|
export type ProcessedMenuAction = Omit<
|
|
125
129
|
MenuAction,
|
|
126
130
|
'imageColor' | 'titleColor' | 'subactions'
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"paths": {
|
|
5
|
+
"@react-native-menu/menu": ["./src/index"]
|
|
6
|
+
},
|
|
7
|
+
"allowUnreachableCode": false,
|
|
8
|
+
"allowUnusedLabels": false,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"importsNotUsedAsValues": "error",
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"jsx": "react",
|
|
13
|
+
"lib": ["esnext"],
|
|
14
|
+
"module": "esnext",
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
|
17
|
+
"noImplicitReturns": true,
|
|
18
|
+
"noImplicitUseStrict": false,
|
|
19
|
+
"noStrictGenericChecks": false,
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
"noUnusedParameters": true,
|
|
22
|
+
"resolveJsonModule": true,
|
|
23
|
+
"skipLibCheck": true,
|
|
24
|
+
"strict": true,
|
|
25
|
+
"target": "esnext"
|
|
26
|
+
}
|
|
27
|
+
}
|