contextmenu
Advanced tools
Comparing version 0.1.2 to 1.0.0
{ | ||
"name": "contextmenu", | ||
"version": "0.1.2", | ||
"description": "A simple context menu for JavaScript", | ||
"main": "index.js", | ||
"types": "lib/src/index.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "rm -rf lib && webpack", | ||
"build-publish": "sh build/publish.sh" | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"dependencies": { | ||
"react": "^16.8.4", | ||
"react-dom": "^16.8.4" | ||
}, | ||
"eslintConfig": { | ||
"extends": "react-app" | ||
}, | ||
"main": "ContextMenu.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/inker/contextmenu.git" | ||
"url": "https://github.com/tetranoir/contextmenu.git" | ||
}, | ||
"keywords": [ | ||
"context", | ||
"menu" | ||
], | ||
"author": "Anton Veselyev", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/inker/contextmenu/issues" | ||
}, | ||
"homepage": "https://github.com/inker/contextmenu#readme", | ||
"dependencies": { | ||
"lodash": "^4.17.4" | ||
}, | ||
"keywords": ["react", "js", "context", "menu", "hooks"], | ||
"devDependencies": { | ||
"awesome-typescript-loader": "^3.0.4-rc.2", | ||
"css-loader": "^0.26.1", | ||
"postcss-loader": "^1.3.0", | ||
"source-map-loader": "^0.1.6", | ||
"style-loader": "^0.13.1", | ||
"typescript": "^2.1.6", | ||
"url-loader": "^0.5.7", | ||
"webpack": "^2.2.1" | ||
"babel-eslint": "^9.0.0", | ||
"eslint": "^5.15.3", | ||
"eslint-config-react-app": "^3.0.8", | ||
"eslint-plugin-flowtype": "^2.50.3", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-jsx-a11y": "^6.2.1", | ||
"eslint-plugin-react": "^7.12.4" | ||
} | ||
} | ||
} |
@@ -1,26 +0,79 @@ | ||
# contextmenu | ||
# ContextMenu | ||
ContextMenu is a context menu build on React (16.8+) hooks. ContextMenu provides a quick and easy way to create instant context menus without having to build jsx. This component supports submenus, custom component menu items, and edge detection. | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] | ||
## Installation | ||
Using npm: | ||
```shell | ||
$ npm i contextmenu | ||
``` | ||
A simple context menu for JavaScript | ||
## How To Use | ||
Import: | ||
```jsx | ||
import useContextMenu from 'contextmenu'; | ||
import 'contextmenu/ContextMenu.css'; | ||
``` | ||
## Installation | ||
Build out your menu: | ||
```jsx | ||
const menuConfig = { | ||
'Say open': () => console.log('open'), | ||
'Disabled': null, | ||
'JSX line': <hr></hr>, | ||
'JSX': <div style={{height: 40, border: '1px solid green'}}>yes</div>, | ||
'Line': '---', | ||
'Submenu': { | ||
'Say wololol': () => console.log('wololol'), | ||
'Go deeper': { | ||
'Onceptioniningiong': () => console.log('inceptioniningiong'), | ||
}, | ||
'Submenu 2': { | ||
'electric': console.log, | ||
'boogaloo': () => console.log('boogaloo'), | ||
}, | ||
}, | ||
}; | ||
``` | ||
npm install --save contextmenu | ||
Render your menu in your component: | ||
```jsx | ||
const [contextMenu, useCM] = useContextMenu({ submenuSymbol: 'O' }); | ||
return <div onContextMenu={useCM(menuConfig)}>{...}{contextMenu}</div> | ||
``` | ||
## Usage | ||
Same as normal `Map` & `WeakMap`, plus the `getKey`, `hasValue` & `deleteValue` methods. | ||
```javascript | ||
import ContextMenu from 'contextmenu' | ||
## API | ||
ContextMenu is built off hooks, which means you must render it within React functional components. | ||
// TODO | ||
### useContextMenu(props) | ||
- `props` is optional | ||
- `props` shape: | ||
``` | ||
{ | ||
submenuSymbol: jsx; // which means jsx component or string or null | ||
depth: number; | ||
// more to be added later | ||
} | ||
``` | ||
[npm-url]: https://npmjs.org/package/contextmenu | ||
[downloads-image]: http://img.shields.io/npm/dm/contextmenu.svg | ||
[npm-image]: http://img.shields.io/npm/v/contextmenu.svg | ||
[david-dm-url]:https://david-dm.org/inker/contextmenu | ||
[david-dm-image]:https://david-dm.org/inker/contextmenu.svg | ||
[david-dm-dev-url]:https://david-dm.org/inker/contextmenu#info=devDependencies | ||
[david-dm-dev-image]:https://david-dm.org/inker/contextmenu/dev-status.svg | ||
### contextMenu | ||
- Returned from `useContextmenu()` which contains the `React.portal` to be rendered (onto `document.body`) | ||
- Must be in your render function, anywhere. | ||
### useCM(menuConfig) | ||
- `menuConfig` is a **JSON** that determines what the rendered context menu looks like. | ||
- menuConfig shape: | ||
``` | ||
{ | ||
[menu option name] : | ||
| [option callback] | ||
| [menuConfig] | ||
| [jsx] | ||
| "-----" | ||
| null | ||
} | ||
``` | ||
- **[menu option name]** is used in conjection with **[option callback]** to create an option that does something | ||
- **[menu option name]** is used in conjection with another `menuConfig` to create a submenu | ||
- **[menu option name]** is used with `null` when the item is disabled | ||
- **[jsx]** shows custom renderings inside menu options (**[menu option name]** is unused here) | ||
- **"---"** is a shortcut to display a separation line between menu items (**[menu option name]** is unused) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7
0
1
80
0
12531
2
4
311
3
2
+ Addedreact@^16.8.4
+ Addedreact-dom@^16.8.4
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact@16.14.0(transitive)
+ Addedreact-dom@16.14.0(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedscheduler@0.19.1(transitive)
- Removedlodash@^4.17.4
- Removedlodash@4.17.21(transitive)