@react-native-menu/menu 1.2.2 → 1.2.4
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 +34 -0
- package/android/build.gradle +1 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt +1 -1
- package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.ts +66 -0
- package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.ts +66 -0
- package/package.json +11 -6
- package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js +0 -18
- package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js.map +0 -1
- package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js +0 -14
- package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js.map +0 -1
- package/lib/module/package.json +0 -1
package/README.md
CHANGED
|
@@ -325,6 +325,40 @@ Example usage:
|
|
|
325
325
|
</View>
|
|
326
326
|
</MenuView>
|
|
327
327
|
```
|
|
328
|
+
|
|
329
|
+
### Custom icons (Android)
|
|
330
|
+
|
|
331
|
+
You might want to use custom icons in the MenuAction `image` attribute. To do so, follow these steps.
|
|
332
|
+
|
|
333
|
+
1. Search for your icon on e.g. [Material Icons](https://fonts.google.com/icons), customize the fill, weight, grade etc.
|
|
334
|
+
to your liking and then press the `Android` tab and click `Download`. This wil download an xml file, e.g.
|
|
335
|
+
`search_24px.xml`. You can create your own icon or get it somewhere else, as long as it is in a format that Android
|
|
336
|
+
understands.
|
|
337
|
+
2. If using bare react-native, copy the downloaded xml file to your `android/app/src/main/res/drawable` folder.
|
|
338
|
+
If you are using Expo, add a dependency
|
|
339
|
+
on [@expo/config-plugins,](https://www.npmjs.com/package/@expo/config-plugins) and then you can use
|
|
340
|
+
an [expo config plugin](./plugin/withAndroidDrawables.js) to copy the file from your `assets` folder to the drawable
|
|
341
|
+
folder. Copy the config plugin to your app and reference it in your `app.json` or `app.config.js` in the `plugins`
|
|
342
|
+
section like this:
|
|
343
|
+
|
|
344
|
+
```json
|
|
345
|
+
{
|
|
346
|
+
"expo": {
|
|
347
|
+
"plugins": [
|
|
348
|
+
[
|
|
349
|
+
"./plugin/withAndroidDrawables",
|
|
350
|
+
{
|
|
351
|
+
"drawableFiles": [ "./assets/my_icon.xml" ]
|
|
352
|
+
}
|
|
353
|
+
]
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
3. In your `MenuAction` you can now reference the icon using its file name, without the `.xml` extension. For example,
|
|
359
|
+
`image: 'my_icon'` will use the `my_icon.xml` file you copied to the drawable folder.
|
|
360
|
+
4. Remember to run a new build to see changes to these icons.
|
|
361
|
+
|
|
328
362
|
## Testing with Jest
|
|
329
363
|
|
|
330
364
|
In some cases, you might want to mock the package to test your components. You can do this by using the `jest.mock` function.
|
package/android/build.gradle
CHANGED
|
@@ -89,7 +89,7 @@ android {
|
|
|
89
89
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
90
90
|
|
|
91
91
|
defaultConfig {
|
|
92
|
-
minSdkVersion
|
|
92
|
+
minSdkVersion 24
|
|
93
93
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
94
94
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
95
95
|
versionCode 1
|
|
@@ -206,7 +206,7 @@ abstract class MenuViewManagerBase : ReactClippingViewManager<MenuView>() {
|
|
|
206
206
|
|
|
207
207
|
@ReactProp(name = ViewProps.OVERFLOW)
|
|
208
208
|
fun setOverflow(view: ReactViewGroup, overflow: String?) {
|
|
209
|
-
view.overflow
|
|
209
|
+
view.setOverflow(overflow)
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
@ReactProp(name = "backfaceVisibility")
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DirectEventHandler,
|
|
3
|
+
Int32,
|
|
4
|
+
} from "react-native/Libraries/Types/CodegenTypes";
|
|
5
|
+
import type { HostComponent, ViewProps } from "react-native";
|
|
6
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
7
|
+
/*
|
|
8
|
+
Caution, those below are not just typescript types.
|
|
9
|
+
Codegen is using them to create the corresponding C++ data types.
|
|
10
|
+
|
|
11
|
+
Codegen doesn't play very well with reusing the same type within a type,
|
|
12
|
+
OR with extending types in an interface, so for now we'll just keep some duplicate
|
|
13
|
+
types here, to avoid issues while `pod install` takes place.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
type SubAction = {
|
|
17
|
+
id?: string;
|
|
18
|
+
title: string;
|
|
19
|
+
titleColor?: Int32;
|
|
20
|
+
subtitle?: string;
|
|
21
|
+
state?: string;
|
|
22
|
+
image?: string;
|
|
23
|
+
imageColor?: Int32;
|
|
24
|
+
displayInline?: boolean;
|
|
25
|
+
attributes?: {
|
|
26
|
+
destructive?: boolean;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
hidden?: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
type MenuAction = {
|
|
32
|
+
id?: string;
|
|
33
|
+
title: string;
|
|
34
|
+
titleColor?: Int32;
|
|
35
|
+
subtitle?: string;
|
|
36
|
+
state?: string;
|
|
37
|
+
image?: string;
|
|
38
|
+
imageColor?: Int32;
|
|
39
|
+
displayInline?: boolean;
|
|
40
|
+
attributes?: {
|
|
41
|
+
destructive?: boolean;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
hidden?: boolean;
|
|
44
|
+
};
|
|
45
|
+
subactions?: Array<SubAction>;
|
|
46
|
+
};
|
|
47
|
+
export interface NativeProps extends ViewProps {
|
|
48
|
+
onPressAction?: DirectEventHandler<{ event: string }>;
|
|
49
|
+
onCloseMenu?: DirectEventHandler<{ event: string }>;
|
|
50
|
+
onOpenMenu?: DirectEventHandler<{ event: string }>;
|
|
51
|
+
actions: Array<MenuAction>;
|
|
52
|
+
actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
|
|
53
|
+
title?: string;
|
|
54
|
+
themeVariant?: string;
|
|
55
|
+
shouldOpenOnLongPress?: boolean;
|
|
56
|
+
hitSlop: {
|
|
57
|
+
top: Int32;
|
|
58
|
+
bottom: Int32;
|
|
59
|
+
left: Int32;
|
|
60
|
+
right: Int32;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default codegenNativeComponent<NativeProps>(
|
|
65
|
+
"MenuView",
|
|
66
|
+
) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DirectEventHandler,
|
|
3
|
+
Int32,
|
|
4
|
+
} from "react-native/Libraries/Types/CodegenTypes";
|
|
5
|
+
import type { HostComponent, ViewProps } from "react-native";
|
|
6
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
7
|
+
/*
|
|
8
|
+
Caution, those below are not just typescript types.
|
|
9
|
+
Codegen is using them to create the corresponding C++ data types.
|
|
10
|
+
|
|
11
|
+
Codegen doesn't play very well with reusing the same type within a type,
|
|
12
|
+
OR with extending types in an interface, so for now we'll just keep some duplicate
|
|
13
|
+
types here, to avoid issues while `pod install` takes place.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
type SubAction = {
|
|
17
|
+
id?: string;
|
|
18
|
+
title: string;
|
|
19
|
+
titleColor?: Int32;
|
|
20
|
+
subtitle?: string;
|
|
21
|
+
state?: string;
|
|
22
|
+
image?: string;
|
|
23
|
+
imageColor?: Int32;
|
|
24
|
+
displayInline?: boolean;
|
|
25
|
+
attributes?: {
|
|
26
|
+
destructive?: boolean;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
hidden?: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
type MenuAction = {
|
|
32
|
+
id?: string;
|
|
33
|
+
title: string;
|
|
34
|
+
titleColor?: Int32;
|
|
35
|
+
subtitle?: string;
|
|
36
|
+
state?: string;
|
|
37
|
+
image?: string;
|
|
38
|
+
imageColor?: Int32;
|
|
39
|
+
displayInline?: boolean;
|
|
40
|
+
attributes?: {
|
|
41
|
+
destructive?: boolean;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
hidden?: boolean;
|
|
44
|
+
};
|
|
45
|
+
subactions?: Array<SubAction>;
|
|
46
|
+
};
|
|
47
|
+
export interface NativeProps extends ViewProps {
|
|
48
|
+
onPressAction?: DirectEventHandler<{ event: string }>;
|
|
49
|
+
onCloseMenu?: DirectEventHandler<{ event: string }>;
|
|
50
|
+
onOpenMenu?: DirectEventHandler<{ event: string }>;
|
|
51
|
+
actions: Array<MenuAction>;
|
|
52
|
+
actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
|
|
53
|
+
title?: string;
|
|
54
|
+
themeVariant?: string;
|
|
55
|
+
shouldOpenOnLongPress?: boolean;
|
|
56
|
+
hitSlop: {
|
|
57
|
+
top: Int32;
|
|
58
|
+
bottom: Int32;
|
|
59
|
+
left: Int32;
|
|
60
|
+
right: Int32;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default codegenNativeComponent<NativeProps>(
|
|
65
|
+
"MenuView",
|
|
66
|
+
) as HostComponent<NativeProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-menu/menu",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "UIMenu component for react-native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@biomejs/biome": "1.9.4",
|
|
49
49
|
"@callstack/react-native-visionos": "^0.73.0",
|
|
50
|
-
"@react-native/babel-preset": "^0.
|
|
51
|
-
"@react-native/metro-config": "0.
|
|
50
|
+
"@react-native/babel-preset": "^0.78.1",
|
|
51
|
+
"@react-native/metro-config": "0.78.1",
|
|
52
52
|
"@release-it/conventional-changelog": "^10.0.0",
|
|
53
53
|
"@rnx-kit/metro-config": "^2.0.0",
|
|
54
54
|
"@types/jest": "^29.1.2",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"pod-install": "^0.3.2",
|
|
59
59
|
"react": "18.2.0",
|
|
60
60
|
"react-native": "^0.73.0",
|
|
61
|
-
"react-native-builder-bob": "^0.
|
|
61
|
+
"react-native-builder-bob": "^0.38.0",
|
|
62
62
|
"react-native-test-app": "^4.0.4",
|
|
63
63
|
"release-it": "^18.1.1",
|
|
64
|
-
"typescript": "5.
|
|
64
|
+
"typescript": "5.8.3"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"react": "*",
|
|
@@ -110,7 +110,12 @@
|
|
|
110
110
|
"codegenConfig": {
|
|
111
111
|
"name": "RNMenuViewSpec",
|
|
112
112
|
"type": "components",
|
|
113
|
-
"jsSrcsDir": "src"
|
|
113
|
+
"jsSrcsDir": "src",
|
|
114
|
+
"ios": {
|
|
115
|
+
"componentProvider": {
|
|
116
|
+
"MenuView": "MenuView"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
114
119
|
},
|
|
115
120
|
"packageManager": "yarn@4.1.1"
|
|
116
121
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/*
|
|
10
|
-
Caution, those below are not just typescript types.
|
|
11
|
-
Codegen is using them to create the corresponding C++ data types.
|
|
12
|
-
|
|
13
|
-
Codegen doesn't play very well with reusing the same type within a type,
|
|
14
|
-
OR with extending types in an interface, so for now we'll just keep some duplicate
|
|
15
|
-
types here, to avoid issues while `pod install` takes place.
|
|
16
|
-
*/
|
|
17
|
-
var _default = exports.default = (0, _codegenNativeComponent.default)("MenuView");
|
|
18
|
-
//# sourceMappingURL=UIMenuNativeComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sourceRoot":"../../../src","sources":["NativeModuleSpecs/UIMenuNativeComponent.ts"],"mappings":";;;;;;AAKA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAyDe,IAAAG,+BAAsB,EACpC,UACD,CAAC","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
4
|
-
/*
|
|
5
|
-
Caution, those below are not just typescript types.
|
|
6
|
-
Codegen is using them to create the corresponding C++ data types.
|
|
7
|
-
|
|
8
|
-
Codegen doesn't play very well with reusing the same type within a type,
|
|
9
|
-
OR with extending types in an interface, so for now we'll just keep some duplicate
|
|
10
|
-
types here, to avoid issues while `pod install` takes place.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export default codegenNativeComponent("MenuView");
|
|
14
|
-
//# sourceMappingURL=UIMenuNativeComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../../src","sources":["NativeModuleSpecs/UIMenuNativeComponent.ts"],"mappings":";;AAKA,OAAOA,sBAAsB,MAAM,yDAAyD;AAC5F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkDA,eAAeA,sBAAsB,CACpC,UACD,CAAC","ignoreList":[]}
|
package/lib/module/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|