@react-native-menu/menu 1.1.1 → 1.1.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/README.md +0 -12
- package/android/src/main/java/com/reactnativemenu/MenuView.kt +10 -0
- package/ios/MenuViewManager.mm +10 -0
- package/ios/NewArch/MenuView.mm +4 -0
- package/ios/Shared/MenuViewImplementation.swift +19 -0
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +11 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.tsx +13 -2
- package/src/types.ts +11 -0
package/README.md
CHANGED
|
@@ -37,18 +37,6 @@ The package is [automatically linked](https://github.com/react-native-community/
|
|
|
37
37
|
npx pod-install
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## Fabric
|
|
41
|
-
|
|
42
|
-
If you plan on using fabric with this project, you may want to add the following lines on your projects' Podfile:
|
|
43
|
-
|
|
44
|
-
```ruby
|
|
45
|
-
+ # @react-native-menu/menu (fabric+swift requirements)
|
|
46
|
-
+ pod 'React-Fabric', :modular_headers => true, :path => '../node_modules/react-native/ReactCommon'
|
|
47
|
-
+ pod 'React-graphics', :modular_headers => true, :path => '../node_modules/react-native/ReactCommon/react/renderer/graphics'
|
|
48
|
-
+ pod 'React-utils', :modular_headers => true, :path => '../node_modules/react-native/ReactCommon/react/utils'
|
|
49
|
-
+ pod 'React-debug', :modular_headers => true, :path => '../node_modules/react-native/ReactCommon/react/debug'
|
|
50
|
-
```
|
|
51
|
-
|
|
52
40
|
## Usage
|
|
53
41
|
|
|
54
42
|
```jsx
|
|
@@ -98,6 +98,7 @@ class MenuView(private val mContext: ReactContext): ReactViewGroup(mContext) {
|
|
|
98
98
|
true -> config.getArray("subactions")
|
|
99
99
|
else -> null
|
|
100
100
|
}
|
|
101
|
+
val menuState = config?.getString("state")
|
|
101
102
|
|
|
102
103
|
if (titleColor != null) {
|
|
103
104
|
menuItem.title = getMenuItemTextWithColor(menuItem.title.toString(), titleColor)
|
|
@@ -153,6 +154,15 @@ class MenuView(private val mContext: ReactContext): ReactViewGroup(mContext) {
|
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
// Handle menuState for checkable items
|
|
158
|
+
when (menuState) {
|
|
159
|
+
"on", "off" -> {
|
|
160
|
+
menuItem.isCheckable = true
|
|
161
|
+
menuItem.isChecked = menuState == "on"
|
|
162
|
+
}
|
|
163
|
+
else -> menuItem.isCheckable = false
|
|
164
|
+
}
|
|
165
|
+
|
|
156
166
|
// On Android SubMenu cannot contain another SubMenu, so even if there are subactions provided
|
|
157
167
|
// we are checking if item has submenu (which will occur only for 1 lvl nesting)
|
|
158
168
|
if (subactions != null && menuItem.hasSubMenu()) {
|
package/ios/MenuViewManager.mm
CHANGED
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
#import "MenuView.h"
|
|
8
8
|
#else
|
|
9
9
|
// OLD ARCH
|
|
10
|
+
#if __has_include(<react_native_menu/react_native_menu-Swift.h>)
|
|
10
11
|
#import <react_native_menu/react_native_menu-Swift.h>
|
|
12
|
+
#else
|
|
13
|
+
#import <react_native_menu-Swift.h>
|
|
14
|
+
#endif
|
|
15
|
+
|
|
11
16
|
#endif
|
|
12
17
|
|
|
13
18
|
@interface MenuViewManager : RCTViewManager
|
|
@@ -61,4 +66,9 @@ RCT_EXPORT_VIEW_PROPERTY(shouldOpenOnLongPress, BOOL)
|
|
|
61
66
|
*/
|
|
62
67
|
RCT_EXPORT_VIEW_PROPERTY(themeVariant, NSString)
|
|
63
68
|
|
|
69
|
+
/**
|
|
70
|
+
* hitSlop: The same as hitSlop in React Native
|
|
71
|
+
*/
|
|
72
|
+
RCT_EXPORT_VIEW_PROPERTY(hitSlop, UIEdgeInsets)
|
|
73
|
+
|
|
64
74
|
@end
|
package/ios/NewArch/MenuView.mm
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#if __has_include(<react_native_menu/react_native_menu-Swift.h>)
|
|
3
|
+
#import <react_native_menu/react_native_menu-Swift.h>
|
|
4
|
+
#else
|
|
2
5
|
#import <react_native_menu-Swift.h>
|
|
6
|
+
#endif
|
|
3
7
|
#import "MenuView.h"
|
|
4
8
|
|
|
5
9
|
#import <react/renderer/components/RNMenuViewSpec/ComponentDescriptors.h>
|
|
@@ -50,6 +50,8 @@ public class MenuViewImplementation: UIButton {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
@objc var hitSlop: UIEdgeInsets = .zero
|
|
54
|
+
|
|
53
55
|
override init(frame: CGRect) {
|
|
54
56
|
super.init(frame: frame)
|
|
55
57
|
self.setup()
|
|
@@ -77,6 +79,23 @@ public class MenuViewImplementation: UIButton {
|
|
|
77
79
|
super.reactSetFrame(frame);
|
|
78
80
|
};
|
|
79
81
|
|
|
82
|
+
public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
|
83
|
+
if hitSlop == .zero || !self.isEnabled || self.isHidden {
|
|
84
|
+
return super.point(inside: point, with: event)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Create a larger hit frame that extends beyond the view's bounds
|
|
88
|
+
let largerFrame = CGRect(
|
|
89
|
+
x: self.bounds.origin.x - hitSlop.left,
|
|
90
|
+
y: self.bounds.origin.y - hitSlop.top,
|
|
91
|
+
width: self.bounds.size.width + hitSlop.left + hitSlop.right,
|
|
92
|
+
height: self.bounds.size.height + hitSlop.top + hitSlop.bottom
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
// Check if the point is within the larger frame
|
|
96
|
+
return largerFrame.contains(point)
|
|
97
|
+
}
|
|
98
|
+
|
|
80
99
|
|
|
81
100
|
required init?(coder aDecoder: NSCoder) {
|
|
82
101
|
fatalError("init(coder:) has not been implemented")
|
package/lib/commonjs/index.js
CHANGED
|
@@ -20,8 +20,15 @@ function processAction(action) {
|
|
|
20
20
|
subactions: action.subactions?.map(subAction => processAction(subAction))
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
const defaultHitslop = {
|
|
24
|
+
top: 0,
|
|
25
|
+
left: 0,
|
|
26
|
+
bottom: 0,
|
|
27
|
+
right: 0
|
|
28
|
+
};
|
|
23
29
|
const MenuView = ({
|
|
24
30
|
actions,
|
|
31
|
+
hitSlop = defaultHitslop,
|
|
25
32
|
...props
|
|
26
33
|
}) => {
|
|
27
34
|
const processedActions = actions.map(action => processAction(action));
|
|
@@ -29,6 +36,7 @@ const MenuView = ({
|
|
|
29
36
|
return (0, _utils.objectHash)(processedActions);
|
|
30
37
|
}, [processedActions]);
|
|
31
38
|
return /*#__PURE__*/_react.default.createElement(_UIMenuView.default, _extends({}, props, {
|
|
39
|
+
hitSlop: hitSlop,
|
|
32
40
|
actions: processedActions,
|
|
33
41
|
actionsHash: hash
|
|
34
42
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_UIMenuView","_interopRequireDefault","_utils","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","processAction","action","imageColor","processColor","titleColor","subactions","map","subAction","MenuView","actions","props","processedActions","hash","useMemo","objectHash","createElement","actionsHash","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAOA,IAAAI,MAAA,GAAAJ,OAAA;AAAqC,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAA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,CAAAU,MAAA,CAAAC,IAAA,eAAAC,MAAA,aAAAL,CAAA,MAAAA,CAAA,GAAAM,SAAA,CAAAC,MAAA,EAAAP,CAAA,UAAAQ,MAAA,GAAAF,SAAA,CAAAN,CAAA,YAAAS,GAAA,IAAAD,MAAA,QAAAf,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAS,MAAA,EAAAC,GAAA,KAAAJ,MAAA,CAAAI,GAAA,IAAAD,MAAA,CAAAC,GAAA,gBAAAJ,MAAA,YAAAH,QAAA,CAAAQ,KAAA,OAAAJ,SAAA;AAErC,SAASK,aAAaA,CAACC,MAAkB,EAAuB;EAC9D,OAAO;IACL,GAAGA,MAAM;IACTC,UAAU,EAAE,IAAAC,yBAAY,EAACF,MAAM,CAACC,UAAU,CAAC;IAC3CE,UAAU,EAAE,IAAAD,yBAAY,EAACF,MAAM,CAACG,UAAU,CAAC;IAC3CC,UAAU,EAAEJ,MAAM,CAACI,UAAU,EAAEC,GAAG,CAAEC,SAAS,IAAKP,aAAa,CAACO,SAAS,CAAC;EAC5E,CAAC;AACH;AAEA,MAAMC,QAAsC,GAAGA,CAAC;
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_UIMenuView","_interopRequireDefault","_utils","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","processAction","action","imageColor","processColor","titleColor","subactions","map","subAction","defaultHitslop","top","left","bottom","right","MenuView","actions","hitSlop","props","processedActions","hash","useMemo","objectHash","createElement","actionsHash","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAOA,IAAAI,MAA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BACEvD,MAAA,CAAAS,OAAA,CAAAkD,aAAA,CAACvD,WAAA,CAAAK,OAAU,EAAAoB,QAAA,KACLyB,KAAK;IACTD,OAAO,EAAEA,OAAQ;IACjBD,OAAO,EAAEG,gBAAiB;IAC1BK,WAAW,EAAEJ;EAAK,EACnB,CAAC;AAEN,CAAC;AAACK,OAAA,CAAAV,QAAA,GAAAA,QAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -11,8 +11,15 @@ function processAction(action) {
|
|
|
11
11
|
subactions: action.subactions?.map(subAction => processAction(subAction))
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
const defaultHitslop = {
|
|
15
|
+
top: 0,
|
|
16
|
+
left: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
right: 0
|
|
19
|
+
};
|
|
14
20
|
const MenuView = ({
|
|
15
21
|
actions,
|
|
22
|
+
hitSlop = defaultHitslop,
|
|
16
23
|
...props
|
|
17
24
|
}) => {
|
|
18
25
|
const processedActions = actions.map(action => processAction(action));
|
|
@@ -20,6 +27,7 @@ const MenuView = ({
|
|
|
20
27
|
return objectHash(processedActions);
|
|
21
28
|
}, [processedActions]);
|
|
22
29
|
return /*#__PURE__*/React.createElement(UIMenuView, _extends({}, props, {
|
|
30
|
+
hitSlop: hitSlop,
|
|
23
31
|
actions: processedActions,
|
|
24
32
|
actionsHash: hash
|
|
25
33
|
}));
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","processColor","UIMenuView","objectHash","processAction","action","imageColor","titleColor","subactions","map","subAction","MenuView","actions","props","processedActions","hash","createElement","_extends","actionsHash"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,YAAY,QAAQ,cAAc;AAE3C,OAAOC,UAAU,MAAM,cAAc;AAOrC,SAASC,UAAU,QAAQ,SAAS;AAEpC,SAASC,aAAaA,CAACC,MAAkB,EAAuB;EAC9D,OAAO;IACL,GAAGA,MAAM;IACTC,UAAU,EAAEL,YAAY,CAACI,MAAM,CAACC,UAAU,CAAC;IAC3CC,UAAU,EAAEN,YAAY,CAACI,MAAM,CAACE,UAAU,CAAC;IAC3CC,UAAU,EAAEH,MAAM,CAACG,UAAU,EAAEC,GAAG,CAAEC,SAAS,IAAKN,aAAa,CAACM,SAAS,CAAC;EAC5E,CAAC;AACH;AAEA,MAAMC,QAAsC,GAAGA,CAAC;
|
|
1
|
+
{"version":3,"names":["React","useMemo","processColor","UIMenuView","objectHash","processAction","action","imageColor","titleColor","subactions","map","subAction","defaultHitslop","top","left","bottom","right","MenuView","actions","hitSlop","props","processedActions","hash","createElement","_extends","actionsHash"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,YAAY,QAAQ,cAAc;AAE3C,OAAOC,UAAU,MAAM,cAAc;AAOrC,SAASC,UAAU,QAAQ,SAAS;AAEpC,SAASC,aAAaA,CAACC,MAAkB,EAAuB;EAC9D,OAAO;IACL,GAAGA,MAAM;IACTC,UAAU,EAAEL,YAAY,CAACI,MAAM,CAACC,UAAU,CAAC;IAC3CC,UAAU,EAAEN,YAAY,CAACI,MAAM,CAACE,UAAU,CAAC;IAC3CC,UAAU,EAAEH,MAAM,CAACG,UAAU,EAAEC,GAAG,CAAEC,SAAS,IAAKN,aAAa,CAACM,SAAS,CAAC;EAC5E,CAAC;AACH;AAEA,MAAMC,cAAc,GAAG;EAAEC,GAAG,EAAE,CAAC;EAAEC,IAAI,EAAE,CAAC;EAAEC,MAAM,EAAE,CAAC;EAAEC,KAAK,EAAE;AAAE,CAAC;AAE/D,MAAMC,QAAsC,GAAGA,CAAC;EAC9CC,OAAO;EACPC,OAAO,GAAGP,cAAc;EACxB,GAAGQ;AACL,CAAC,KAAK;EACJ,MAAMC,gBAAgB,GAAGH,OAAO,CAACR,GAAG,CAAuBJ,MAAM,IAC/DD,aAAa,CAACC,MAAM,CACtB,CAAC;EACD,MAAMgB,IAAI,GAAGrB,OAAO,CAAC,MAAM;IACzB,OAAOG,UAAU,CAACiB,gBAAgB,CAAC;EACrC,CAAC,EAAE,CAACA,gBAAgB,CAAC,CAAC;EACtB,oBACErB,KAAA,CAAAuB,aAAA,CAACpB,UAAU,EAAAqB,QAAA,KACLJ,KAAK;IACTD,OAAO,EAAEA,OAAQ;IACjBD,OAAO,EAAEG,gBAAiB;IAC1BI,WAAW,EAAEH;EAAK,EACnB,CAAC;AAEN,CAAC;AAED,SAASL,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,iBAAiB,EAClB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAcjB,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmB1C,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -133,6 +133,16 @@ type MenuComponentPropsBase = {
|
|
|
133
133
|
* @platform iOS
|
|
134
134
|
*/
|
|
135
135
|
themeVariant?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Custom OpenSpace hitSlop prop. Works like touchable hitslop.
|
|
138
|
+
* @platform iOS
|
|
139
|
+
*/
|
|
140
|
+
hitSlop?: {
|
|
141
|
+
top: number;
|
|
142
|
+
bottom: number;
|
|
143
|
+
left: number;
|
|
144
|
+
right: number;
|
|
145
|
+
};
|
|
136
146
|
};
|
|
137
147
|
export type MenuComponentProps = React.PropsWithChildren<MenuComponentPropsBase>;
|
|
138
148
|
export type ProcessedMenuAction = Omit<MenuAction, 'imageColor' | 'titleColor' | 'subactions'> & {
|
|
@@ -146,6 +156,7 @@ export type NativeMenuComponentProps = {
|
|
|
146
156
|
actions: ProcessedMenuAction[];
|
|
147
157
|
actionsHash: string;
|
|
148
158
|
title?: string;
|
|
159
|
+
hitSlop?: MenuComponentProps['hitSlop'];
|
|
149
160
|
};
|
|
150
161
|
export {};
|
|
151
162
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,KAAK,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,UAAU,CAAC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E,MAAM,CAAC;IAEf;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC5B,KAAK,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC;AAElD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,UAAU,EACV,YAAY,GAAG,YAAY,GAAG,YAAY,CAC3C,GAAG;IACF,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC5C,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7D,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;CACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-menu/menu",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "UIMenu component for react-native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@callstack/react-native-visionos": "^0.73.0",
|
|
49
49
|
"@react-native/babel-preset": "^0.74.79",
|
|
50
50
|
"@react-native/eslint-config": "^0.74.0",
|
|
51
|
-
"@react-native/metro-config": "0.74.
|
|
51
|
+
"@react-native/metro-config": "0.74.85",
|
|
52
52
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
53
|
-
"@rnx-kit/metro-config": "^
|
|
53
|
+
"@rnx-kit/metro-config": "^2.0.0",
|
|
54
54
|
"@types/jest": "^29.1.2",
|
|
55
55
|
"@types/react": "^18.2.2",
|
|
56
56
|
"@types/react-native": "0.73.0",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"prettier": "^3.1.1",
|
|
64
64
|
"react": "18.2.0",
|
|
65
65
|
"react-native": "^0.73.0",
|
|
66
|
-
"react-native-builder-bob": "^0.
|
|
67
|
-
"react-native-test-app": "^3.
|
|
66
|
+
"react-native-builder-bob": "^0.30.2",
|
|
67
|
+
"react-native-test-app": "^3.8.1",
|
|
68
68
|
"release-it": "^17.2.0",
|
|
69
|
-
"typescript": "5.
|
|
69
|
+
"typescript": "5.6.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "*",
|
package/src/index.tsx
CHANGED
|
@@ -19,7 +19,13 @@ function processAction(action: MenuAction): ProcessedMenuAction {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const defaultHitslop = { top: 0, left: 0, bottom: 0, right: 0 };
|
|
23
|
+
|
|
24
|
+
const MenuView: React.FC<MenuComponentProps> = ({
|
|
25
|
+
actions,
|
|
26
|
+
hitSlop = defaultHitslop,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
23
29
|
const processedActions = actions.map<ProcessedMenuAction>((action) =>
|
|
24
30
|
processAction(action)
|
|
25
31
|
);
|
|
@@ -27,7 +33,12 @@ const MenuView: React.FC<MenuComponentProps> = ({ actions, ...props }) => {
|
|
|
27
33
|
return objectHash(processedActions);
|
|
28
34
|
}, [processedActions]);
|
|
29
35
|
return (
|
|
30
|
-
<UIMenuView
|
|
36
|
+
<UIMenuView
|
|
37
|
+
{...props}
|
|
38
|
+
hitSlop={hitSlop}
|
|
39
|
+
actions={processedActions}
|
|
40
|
+
actionsHash={hash}
|
|
41
|
+
/>
|
|
31
42
|
);
|
|
32
43
|
};
|
|
33
44
|
|
package/src/types.ts
CHANGED
|
@@ -144,6 +144,16 @@ type MenuComponentPropsBase = {
|
|
|
144
144
|
* @platform iOS
|
|
145
145
|
*/
|
|
146
146
|
themeVariant?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Custom OpenSpace hitSlop prop. Works like touchable hitslop.
|
|
149
|
+
* @platform iOS
|
|
150
|
+
*/
|
|
151
|
+
hitSlop?: {
|
|
152
|
+
top: number;
|
|
153
|
+
bottom: number;
|
|
154
|
+
left: number;
|
|
155
|
+
right: number;
|
|
156
|
+
};
|
|
147
157
|
};
|
|
148
158
|
|
|
149
159
|
export type MenuComponentProps =
|
|
@@ -164,4 +174,5 @@ export type NativeMenuComponentProps = {
|
|
|
164
174
|
actions: ProcessedMenuAction[];
|
|
165
175
|
actionsHash: string;
|
|
166
176
|
title?: string;
|
|
177
|
+
hitSlop?: MenuComponentProps['hitSlop'];
|
|
167
178
|
};
|