@react-native-menu/menu 1.1.6 → 1.1.7
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 +15 -1
- package/android/src/main/java/com/reactnativemenu/MenuView.kt +4 -0
- package/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt +11 -0
- package/ios/NewArch/FabricViewImplementationProtocol.swift +3 -0
- package/ios/NewArch/MenuView.mm +20 -0
- package/ios/Shared/ActionSheetView.swift +2 -2
- package/ios/Shared/MenuViewImplementation.swift +3 -3
- package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js +1 -1
- package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -1
- package/lib/commonjs/UIMenuView.android.js +19 -1
- package/lib/commonjs/UIMenuView.android.js.map +1 -1
- package/lib/commonjs/UIMenuView.js +0 -3
- package/lib/commonjs/UIMenuView.js.map +1 -1
- package/lib/commonjs/index.js +6 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils.js +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js +2 -2
- package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.js.map +1 -1
- package/lib/module/UIMenuView.android.js +20 -2
- package/lib/module/UIMenuView.android.js.map +1 -1
- package/lib/module/UIMenuView.ios.js +1 -1
- package/lib/module/UIMenuView.js +1 -2
- package/lib/module/UIMenuView.js.map +1 -1
- package/lib/module/index.js +9 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils.js +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts +10 -2
- package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/UIMenuView.android.d.ts +2 -3
- package/lib/typescript/src/UIMenuView.android.d.ts.map +1 -1
- package/lib/typescript/src/UIMenuView.d.ts +2 -2
- package/lib/typescript/src/UIMenuView.d.ts.map +1 -1
- package/lib/typescript/src/UIMenuView.ios.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +20 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +10 -6
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/package.json +10 -44
- package/src/NativeModuleSpecs/UIMenuNativeComponent.ts +45 -37
- package/src/UIMenuView.android.tsx +34 -4
- package/src/UIMenuView.ios.tsx +1 -1
- package/src/UIMenuView.tsx +11 -11
- package/src/index.tsx +32 -26
- package/src/types.ts +158 -153
- package/src/utils.ts +17 -17
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function objectHash(obj: Record<string,
|
|
1
|
+
export declare function objectHash(obj: Record<string, unknown>[]): string;
|
|
2
2
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAYA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAYA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAYjE"}
|
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.7",
|
|
4
4
|
"description": "UIMenu component for react-native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"android": "react-native run-android",
|
|
24
24
|
"bootstrap": "yarn && yarn pods",
|
|
25
|
-
"format": "
|
|
25
|
+
"format": "biome format --write .",
|
|
26
26
|
"ios": "react-native run-ios",
|
|
27
|
-
"lint": "
|
|
27
|
+
"lint": "biome lint --write .",
|
|
28
28
|
"pods": "cd example && pod-install --quiet",
|
|
29
29
|
"prepare": "bob build",
|
|
30
30
|
"release": "release-it",
|
|
@@ -45,28 +45,23 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/react-native-menu/menu#readme",
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"@biomejs/biome": "1.9.4",
|
|
48
49
|
"@callstack/react-native-visionos": "^0.73.0",
|
|
49
|
-
"@react-native/babel-preset": "^0.
|
|
50
|
-
"@react-native/
|
|
51
|
-
"@react-native/metro-config": "0.74.85",
|
|
50
|
+
"@react-native/babel-preset": "^0.76.1",
|
|
51
|
+
"@react-native/metro-config": "0.76.3",
|
|
52
52
|
"@release-it/conventional-changelog": "^9.0.1",
|
|
53
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",
|
|
57
|
-
"eslint": "8.57.0",
|
|
58
|
-
"eslint-config-prettier": "^9.1.0",
|
|
59
|
-
"eslint-plugin-ft-flow": "^3.0.0",
|
|
60
|
-
"eslint-plugin-prettier": "^5.1.2",
|
|
61
57
|
"jest": "^29.2.1",
|
|
62
|
-
"pod-install": "^0.2
|
|
63
|
-
"prettier": "^3.1.1",
|
|
58
|
+
"pod-install": "^0.3.2",
|
|
64
59
|
"react": "18.2.0",
|
|
65
60
|
"react-native": "^0.73.0",
|
|
66
|
-
"react-native-builder-bob": "^0.
|
|
67
|
-
"react-native-test-app": "^
|
|
61
|
+
"react-native-builder-bob": "^0.33.2",
|
|
62
|
+
"react-native-test-app": "^4.0.4",
|
|
68
63
|
"release-it": "^17.2.0",
|
|
69
|
-
"typescript": "5.
|
|
64
|
+
"typescript": "5.7.2"
|
|
70
65
|
},
|
|
71
66
|
"peerDependencies": {
|
|
72
67
|
"react": "*",
|
|
@@ -96,35 +91,6 @@
|
|
|
96
91
|
}
|
|
97
92
|
}
|
|
98
93
|
},
|
|
99
|
-
"eslintConfig": {
|
|
100
|
-
"extends": [
|
|
101
|
-
"@react-native",
|
|
102
|
-
"prettier"
|
|
103
|
-
],
|
|
104
|
-
"rules": {
|
|
105
|
-
"prettier/prettier": [
|
|
106
|
-
"error",
|
|
107
|
-
{
|
|
108
|
-
"quoteProps": "consistent",
|
|
109
|
-
"singleQuote": true,
|
|
110
|
-
"tabWidth": 2,
|
|
111
|
-
"trailingComma": "es5",
|
|
112
|
-
"useTabs": false
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
"eslintIgnore": [
|
|
118
|
-
"node_modules/",
|
|
119
|
-
"lib/"
|
|
120
|
-
],
|
|
121
|
-
"prettier": {
|
|
122
|
-
"quoteProps": "consistent",
|
|
123
|
-
"singleQuote": true,
|
|
124
|
-
"tabWidth": 2,
|
|
125
|
-
"trailingComma": "es5",
|
|
126
|
-
"useTabs": false
|
|
127
|
-
},
|
|
128
94
|
"react-native-builder-bob": {
|
|
129
95
|
"source": "src",
|
|
130
96
|
"output": "lib",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import type { HostComponent, ViewProps } from
|
|
6
|
-
import codegenNativeComponent from
|
|
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
7
|
/*
|
|
8
8
|
Caution, those below are not just typescript types.
|
|
9
9
|
Codegen is using them to create the corresponding C++ data types.
|
|
@@ -13,43 +13,51 @@ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNati
|
|
|
13
13
|
types here, to avoid issues while `pod install` takes place.
|
|
14
14
|
*/
|
|
15
15
|
type SubAction = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
id?: string;
|
|
17
|
+
title: string;
|
|
18
|
+
titleColor?: Int32;
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
state?: string;
|
|
21
|
+
image?: string;
|
|
22
|
+
imageColor?: Int32;
|
|
23
|
+
displayInline?: boolean;
|
|
24
|
+
attributes?: {
|
|
25
|
+
destructive?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
hidden?: boolean;
|
|
28
|
+
};
|
|
29
29
|
};
|
|
30
30
|
type MenuAction = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
id?: string;
|
|
32
|
+
title: string;
|
|
33
|
+
titleColor?: Int32;
|
|
34
|
+
subtitle?: string;
|
|
35
|
+
state?: string;
|
|
36
|
+
image?: string;
|
|
37
|
+
imageColor?: Int32;
|
|
38
|
+
displayInline?: boolean;
|
|
39
|
+
attributes?: {
|
|
40
|
+
destructive?: boolean;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
hidden?: boolean;
|
|
43
|
+
};
|
|
44
|
+
subactions?: Array<SubAction>;
|
|
45
45
|
};
|
|
46
46
|
export interface NativeProps extends ViewProps {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
onPressAction?: DirectEventHandler<{ event: string }>;
|
|
48
|
+
actions: Array<MenuAction>;
|
|
49
|
+
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)
|
|
50
|
+
title?: string;
|
|
51
|
+
themeVariant?: string;
|
|
52
|
+
shouldOpenOnLongPress?: boolean;
|
|
53
|
+
hitSlop: {
|
|
54
|
+
top: Int32;
|
|
55
|
+
bottom: Int32;
|
|
56
|
+
left: Int32;
|
|
57
|
+
right: Int32;
|
|
58
|
+
}
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
export default codegenNativeComponent<NativeProps>(
|
|
54
|
-
|
|
62
|
+
"MenuView",
|
|
55
63
|
) as HostComponent<NativeProps>;
|
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
findNodeHandle,
|
|
3
|
+
type HostComponent,
|
|
4
|
+
requireNativeComponent,
|
|
5
|
+
UIManager,
|
|
6
|
+
} from "react-native";
|
|
7
|
+
import type { MenuComponentRef, NativeMenuComponentProps } from "./types";
|
|
8
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
3
9
|
|
|
4
|
-
const
|
|
5
|
-
|
|
10
|
+
const NativeMenuComponent = requireNativeComponent(
|
|
11
|
+
"MenuView",
|
|
6
12
|
) as HostComponent<NativeMenuComponentProps>;
|
|
7
13
|
|
|
14
|
+
const MenuComponent = forwardRef<MenuComponentRef, NativeMenuComponentProps>(
|
|
15
|
+
(props, ref) => {
|
|
16
|
+
const nativeRef = useRef(null);
|
|
17
|
+
|
|
18
|
+
useImperativeHandle(
|
|
19
|
+
ref,
|
|
20
|
+
() => ({
|
|
21
|
+
show: () => {
|
|
22
|
+
if (nativeRef.current) {
|
|
23
|
+
const node = findNodeHandle(nativeRef.current);
|
|
24
|
+
const command =
|
|
25
|
+
UIManager.getViewManagerConfig("MenuView").Commands.show;
|
|
26
|
+
|
|
27
|
+
UIManager.dispatchViewManagerCommand(node, command, undefined);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
[],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return <NativeMenuComponent {...props} ref={nativeRef} />;
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
8
38
|
export default MenuComponent;
|
package/src/UIMenuView.ios.tsx
CHANGED
package/src/UIMenuView.tsx
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { View } from
|
|
3
|
-
import type { NativeMenuComponentProps } from
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import type { NativeMenuComponentProps } from "./types";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TODO: implement for Web
|
|
7
7
|
*/
|
|
8
8
|
const MenuView: React.FC<React.PropsWithChildren<NativeMenuComponentProps>> = ({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
style,
|
|
10
|
+
children,
|
|
11
|
+
testID,
|
|
12
12
|
}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
return (
|
|
14
|
+
<View style={style} testID={testID}>
|
|
15
|
+
{children}
|
|
16
|
+
</View>
|
|
17
|
+
);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export default MenuView;
|
package/src/index.tsx
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { processColor } from
|
|
1
|
+
import { forwardRef, useMemo } from "react";
|
|
2
|
+
import { processColor } from "react-native";
|
|
3
3
|
|
|
4
|
-
import UIMenuView from
|
|
4
|
+
import UIMenuView from "./UIMenuView";
|
|
5
5
|
import type {
|
|
6
6
|
MenuComponentProps,
|
|
7
7
|
MenuAction,
|
|
8
8
|
ProcessedMenuAction,
|
|
9
9
|
NativeActionEvent,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
MenuComponentRef,
|
|
11
|
+
} from "./types";
|
|
12
|
+
import { objectHash } from "./utils";
|
|
12
13
|
|
|
13
14
|
function processAction(action: MenuAction): ProcessedMenuAction {
|
|
14
15
|
return {
|
|
@@ -21,26 +22,31 @@ function processAction(action: MenuAction): ProcessedMenuAction {
|
|
|
21
22
|
|
|
22
23
|
const defaultHitslop = { top: 0, left: 0, bottom: 0, right: 0 };
|
|
23
24
|
|
|
24
|
-
const MenuView
|
|
25
|
-
actions,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
const MenuView = forwardRef<MenuComponentRef, MenuComponentProps>(
|
|
26
|
+
({ actions, hitSlop = defaultHitslop, ...props }, ref) => {
|
|
27
|
+
const processedActions = actions.map<ProcessedMenuAction>((action) =>
|
|
28
|
+
processAction(action),
|
|
29
|
+
);
|
|
30
|
+
const hash = useMemo(() => {
|
|
31
|
+
return objectHash(processedActions);
|
|
32
|
+
}, [processedActions]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<UIMenuView
|
|
36
|
+
{...props}
|
|
37
|
+
hitSlop={hitSlop}
|
|
38
|
+
actions={processedActions}
|
|
39
|
+
actionsHash={hash}
|
|
40
|
+
ref={ref}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
);
|
|
44
45
|
|
|
45
46
|
export { MenuView };
|
|
46
|
-
export type {
|
|
47
|
+
export type {
|
|
48
|
+
MenuComponentProps,
|
|
49
|
+
MenuComponentRef,
|
|
50
|
+
MenuAction,
|
|
51
|
+
NativeActionEvent,
|
|
52
|
+
};
|