@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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metro configuration for React Native
|
|
3
|
+
* https://github.com/facebook/react-native
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const exclusionList = (() => {
|
|
11
|
+
try {
|
|
12
|
+
return require('metro-config/src/defaults/exclusionList');
|
|
13
|
+
} catch (_) {
|
|
14
|
+
// `blacklist` was renamed to `exclusionList` in 0.60
|
|
15
|
+
return require('metro-config/src/defaults/blacklist');
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
const blockList = exclusionList([
|
|
20
|
+
/node_modules\/.*\/node_modules\/react-native\/.*/,
|
|
21
|
+
|
|
22
|
+
// This stops "react-native run-windows" from causing the metro server to
|
|
23
|
+
// crash if its already running
|
|
24
|
+
new RegExp(`${path.join(__dirname, 'windows').replace(/[/\\]+/g, '/')}.*`),
|
|
25
|
+
|
|
26
|
+
// Workaround for `EBUSY: resource busy or locked, open '~\msbuild.ProjectImports.zip'`
|
|
27
|
+
// when building with `yarn windows --release`
|
|
28
|
+
/.*\.ProjectImports\.zip/,
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
resolver: {
|
|
33
|
+
blacklistRE: blockList,
|
|
34
|
+
blockList,
|
|
35
|
+
},
|
|
36
|
+
transformer: {
|
|
37
|
+
getTransformOptions: async () => ({
|
|
38
|
+
transform: {
|
|
39
|
+
experimentalImportSupport: false,
|
|
40
|
+
inlineRequires: false,
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "MenuExample",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"android": "react-native run-android",
|
|
7
|
+
"build:android": "mkdirp dist/res && react-native bundle --entry-file index.js --platform android --dev true --bundle-output dist/main.android.jsbundle --assets-dest dist/res",
|
|
8
|
+
"build:ios": "mkdirp dist && react-native bundle --entry-file index.js --platform ios --dev true --bundle-output dist/main.ios.jsbundle --assets-dest dist",
|
|
9
|
+
"ios": "react-native run-ios",
|
|
10
|
+
"lint": "eslint .",
|
|
11
|
+
"start": "react-native start",
|
|
12
|
+
"test": "jest"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@react-native-menu/menu": "../",
|
|
16
|
+
"react": "17.0.1",
|
|
17
|
+
"react-native": "^0.64.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@babel/core": "^7.12.9",
|
|
21
|
+
"@babel/runtime": "^7.12.5",
|
|
22
|
+
"@react-native-community/eslint-config": "^2.0.0",
|
|
23
|
+
"babel-jest": "^26.6.3",
|
|
24
|
+
"eslint": "7.14.0",
|
|
25
|
+
"jest": "^26.6.3",
|
|
26
|
+
"metro-react-native-babel-preset": "^0.64.0",
|
|
27
|
+
"mkdirp": "^1.0.0",
|
|
28
|
+
"react-native-test-app": "^0.7.5",
|
|
29
|
+
"react-test-renderer": "17.0.1"
|
|
30
|
+
},
|
|
31
|
+
"jest": {
|
|
32
|
+
"preset": "react-native"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const windowsProjectFile = path.join(
|
|
5
|
+
'node_modules',
|
|
6
|
+
'.generated',
|
|
7
|
+
'windows',
|
|
8
|
+
'ReactTestApp',
|
|
9
|
+
'ReactTestApp.vcxproj'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
project: {
|
|
14
|
+
android: {
|
|
15
|
+
sourceDir: 'android',
|
|
16
|
+
manifestPath: path.relative(
|
|
17
|
+
path.join(__dirname, 'android'),
|
|
18
|
+
path.join(
|
|
19
|
+
path.dirname(require.resolve('react-native-test-app/package.json')),
|
|
20
|
+
'android',
|
|
21
|
+
'app',
|
|
22
|
+
'src',
|
|
23
|
+
'main',
|
|
24
|
+
'AndroidManifest.xml'
|
|
25
|
+
)
|
|
26
|
+
),
|
|
27
|
+
},
|
|
28
|
+
ios: {
|
|
29
|
+
project: (() => {
|
|
30
|
+
const {
|
|
31
|
+
packageSatisfiesVersionRange,
|
|
32
|
+
} = require('react-native-test-app/scripts/configure');
|
|
33
|
+
if (
|
|
34
|
+
packageSatisfiesVersionRange(
|
|
35
|
+
'@react-native-community/cli-platform-ios',
|
|
36
|
+
'<5.0.2'
|
|
37
|
+
)
|
|
38
|
+
) {
|
|
39
|
+
// Prior to @react-native-community/cli-platform-ios v5.0.0,
|
|
40
|
+
// `project` was only used to infer `sourceDir` and `podfile`.
|
|
41
|
+
return 'ios/ReactTestApp-Dummy.xcodeproj';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// `sourceDir` and `podfile` detection was fixed in
|
|
45
|
+
// @react-native-community/cli-platform-ios v5.0.2 (see
|
|
46
|
+
// https://github.com/react-native-community/cli/pull/1444).
|
|
47
|
+
return 'node_modules/.generated/ios/ReactTestApp.xcodeproj';
|
|
48
|
+
})(),
|
|
49
|
+
},
|
|
50
|
+
windows: fs.existsSync(windowsProjectFile) && {
|
|
51
|
+
sourceDir: 'windows',
|
|
52
|
+
solutionFile: 'MenuExample.sln',
|
|
53
|
+
project: {
|
|
54
|
+
projectFile: path.relative(
|
|
55
|
+
path.join(__dirname, 'windows'),
|
|
56
|
+
windowsProjectFile
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Platform, StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import { MenuView } from '@react-native-menu/menu';
|
|
4
|
+
|
|
5
|
+
export const App = () => {
|
|
6
|
+
return (
|
|
7
|
+
<View style={styles.container}>
|
|
8
|
+
<MenuView
|
|
9
|
+
title="Menu Title"
|
|
10
|
+
onPressAction={({ nativeEvent }) => {
|
|
11
|
+
console.warn(JSON.stringify(nativeEvent));
|
|
12
|
+
}}
|
|
13
|
+
actions={[
|
|
14
|
+
{
|
|
15
|
+
id: 'add',
|
|
16
|
+
title: 'Add to List',
|
|
17
|
+
titleColor: '#2367A2',
|
|
18
|
+
image: Platform.select({
|
|
19
|
+
ios: 'plus',
|
|
20
|
+
android: 'ic_menu_add',
|
|
21
|
+
}),
|
|
22
|
+
imageColor: '#2367A2',
|
|
23
|
+
subactions: [
|
|
24
|
+
{
|
|
25
|
+
id: 'nested1',
|
|
26
|
+
title: 'Nested action',
|
|
27
|
+
titleColor: 'rgba(250,180,100,0.5)',
|
|
28
|
+
subtitle: 'State is mixed',
|
|
29
|
+
image: Platform.select({
|
|
30
|
+
ios: 'heart.fill',
|
|
31
|
+
android: 'ic_menu_today',
|
|
32
|
+
}),
|
|
33
|
+
imageColor: 'rgba(100,200,250,0.3)',
|
|
34
|
+
state: 'mixed',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'nestedDestructive',
|
|
38
|
+
title: 'Destructive Action',
|
|
39
|
+
attributes: {
|
|
40
|
+
destructive: true,
|
|
41
|
+
},
|
|
42
|
+
image: Platform.select({
|
|
43
|
+
ios: 'trash',
|
|
44
|
+
android: 'ic_menu_delete',
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'share',
|
|
51
|
+
title: 'Share Action',
|
|
52
|
+
titleColor: '#46F289',
|
|
53
|
+
subtitle: 'Share action on SNS',
|
|
54
|
+
image: Platform.select({
|
|
55
|
+
ios: 'square.and.arrow.up',
|
|
56
|
+
android: 'ic_menu_share',
|
|
57
|
+
}),
|
|
58
|
+
imageColor: '#46F289',
|
|
59
|
+
state: 'on',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'mixed',
|
|
63
|
+
title: 'Mixed State',
|
|
64
|
+
titleColor: 'rgba(100,200,250,0.3)',
|
|
65
|
+
subtitle: 'State is mixed',
|
|
66
|
+
image: Platform.select({
|
|
67
|
+
ios: 'heart.fill',
|
|
68
|
+
android: 'ic_menu_today',
|
|
69
|
+
}),
|
|
70
|
+
imageColor: 'rgba(100,200,250,0.3)',
|
|
71
|
+
state: 'mixed',
|
|
72
|
+
subactions: [
|
|
73
|
+
{
|
|
74
|
+
id: 'nested2',
|
|
75
|
+
title: 'Nested action',
|
|
76
|
+
titleColor: 'rgba(250,180,100,0.5)',
|
|
77
|
+
subtitle: 'State is mixed',
|
|
78
|
+
image: Platform.select({
|
|
79
|
+
ios: 'tray',
|
|
80
|
+
android: 'ic_menu_agenda',
|
|
81
|
+
}),
|
|
82
|
+
imageColor: 'rgba(100,200,250,0.3)',
|
|
83
|
+
state: 'mixed',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'nestedMixed',
|
|
87
|
+
title: 'Mixed State',
|
|
88
|
+
subtitle: 'State is mixed',
|
|
89
|
+
image: Platform.select({
|
|
90
|
+
ios: 'heart.fill',
|
|
91
|
+
android: 'ic_menu_today',
|
|
92
|
+
}),
|
|
93
|
+
imageColor: '#46F289',
|
|
94
|
+
subactions: [
|
|
95
|
+
{
|
|
96
|
+
id: 'nestednesteddisabled',
|
|
97
|
+
title: 'Disabled Action',
|
|
98
|
+
subtitle: 'Action is disabled',
|
|
99
|
+
attributes: {
|
|
100
|
+
disabled: true,
|
|
101
|
+
},
|
|
102
|
+
image: Platform.select({
|
|
103
|
+
ios: 'tray',
|
|
104
|
+
android: 'ic_menu_agenda',
|
|
105
|
+
}),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: 'nestednestedhidden',
|
|
109
|
+
title: 'Hidden Action',
|
|
110
|
+
subtitle: 'Action is hidden',
|
|
111
|
+
attributes: {
|
|
112
|
+
hidden: true,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 'nestednesteddestructive',
|
|
117
|
+
title: 'Destructive Action',
|
|
118
|
+
attributes: {
|
|
119
|
+
destructive: true,
|
|
120
|
+
},
|
|
121
|
+
image: Platform.select({
|
|
122
|
+
ios: 'trash',
|
|
123
|
+
android: 'ic_menu_delete',
|
|
124
|
+
}),
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'disabled',
|
|
132
|
+
title: 'Disabled Action',
|
|
133
|
+
subtitle: 'Action is disabled',
|
|
134
|
+
attributes: {
|
|
135
|
+
disabled: true,
|
|
136
|
+
},
|
|
137
|
+
image: Platform.select({
|
|
138
|
+
ios: 'tray',
|
|
139
|
+
android: 'ic_menu_agenda',
|
|
140
|
+
}),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: 'hidden',
|
|
144
|
+
title: 'Hidden Action',
|
|
145
|
+
subtitle: 'Action is hidden',
|
|
146
|
+
attributes: {
|
|
147
|
+
hidden: true,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 'destructive',
|
|
152
|
+
title: 'Destructive Action',
|
|
153
|
+
attributes: {
|
|
154
|
+
destructive: true,
|
|
155
|
+
},
|
|
156
|
+
image: Platform.select({
|
|
157
|
+
ios: 'trash',
|
|
158
|
+
android: 'ic_menu_delete',
|
|
159
|
+
}),
|
|
160
|
+
},
|
|
161
|
+
]}
|
|
162
|
+
shouldOpenOnLongPress={true}
|
|
163
|
+
>
|
|
164
|
+
<View style={styles.button}>
|
|
165
|
+
<Text style={styles.buttonText}>Test</Text>
|
|
166
|
+
</View>
|
|
167
|
+
</MenuView>
|
|
168
|
+
</View>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const styles = StyleSheet.create({
|
|
173
|
+
container: {
|
|
174
|
+
flex: 1,
|
|
175
|
+
alignItems: 'center',
|
|
176
|
+
justifyContent: 'center',
|
|
177
|
+
},
|
|
178
|
+
button: {
|
|
179
|
+
height: 100,
|
|
180
|
+
width: 100,
|
|
181
|
+
backgroundColor: 'red',
|
|
182
|
+
borderRadius: 50,
|
|
183
|
+
justifyContent: 'center',
|
|
184
|
+
alignItems: 'center',
|
|
185
|
+
},
|
|
186
|
+
buttonText: { color: 'white' },
|
|
187
|
+
});
|