diff --git a/.babelrc b/.babelrc index fe2b9d63..e177afed 100644 --- a/.babelrc +++ b/.babelrc @@ -1,42 +1,37 @@ { + "assumptions": { + "setPublicClassFields": true + }, "presets": [ - "react" + "@babel/preset-react" ], "env": { "es6": { "presets": [ [ - "es2015", + "@babel/preset-env", { - "modules": false + "modules": false, + "targets": "defaults and not IE 11", } ] ], - "plugins": [ - "transform-class-properties" - ] }, "es5": { "presets": [ - "es2015" + ["@babel/preset-env", { + "targets": "defaults", + }] ], - "plugins": [ - "transform-class-properties" - ] }, "test": { "presets": [ [ - "env", + "@babel/preset-env", { - "targets": { - "node": 6 - } + "targets": { "node": "current" }, } ] - ], - "plugins": [ - "transform-class-properties" ] } } diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 400887f7..00000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -examples/bundle.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 9fa70bd1..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,11 +0,0 @@ -parser: babel-eslint -extends: - - vkbansal - - vkbansal/react -env: - browser: true -settings: - react: - version: detect -rules: - react/no-array-index-key: 0 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..8ee7940c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# Automatically request reviews for the dependency updates +/package.json @canova +/yarn.lock @canova diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index dc90e5a1..00000000 --- a/.github/stale.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 60 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security -# Label to use when marking an issue as stale -staleLabel: wontfix -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..72e1af72 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: test + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'yarn' + - run: yarn install + - run: yarn lint + - run: yarn test:only + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'yarn' + - run: yarn install + - run: yarn build:dist + - run: yarn build:es5 + - run: yarn build:es6 + - run: yarn build:examples diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..2bd5a0a9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 56c062dd..00000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: node_js -node_js: - - 8 -after_success: - - npm run coveralls -script: - - npm test - - bash ./deploy.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37e31c9c..6143994e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,8 +6,8 @@ Please read https://reactjs.org/ and the Code of Conduct before opening an issue ### Found a bug? ##### Before Submitting A Bug Report -- Please read the [API documentation](https://github.com/vkbansal/react-contextmenu#api) thoroughly -- Perform a [cursory search](https://github.com/vkbansal/react-contextmenu/issues?utf8=%E2%9C%93&q=is%3Aissue) to see if the problem has already been reported. If it has, add a comment to the existing issue instead of opening a new one. +- Please read the [API documentation](https://github.com/firefox-devtools/react-contextmenu#api) thoroughly +- Perform a [cursory search](https://github.com/firefox-devtools/react-contextmenu/issues?utf8=%E2%9C%93&q=is%3Aissue) to see if the problem has already been reported. If it has, add a comment to the existing issue instead of opening a new one. ##### Submiting a (good) bug report @@ -33,19 +33,19 @@ Pull requests need only the 👍 of admin or two or more collaborators to be mer You can run lint + tests via: ``` -npm test +yarn test ``` If you just want to run lint: ``` -npm run lint +yarn lint ``` If you just want to run all tests: ``` -npm run test:only +yarn test:only ``` ##### Development @@ -53,7 +53,7 @@ npm run test:only You can start webpack & dev server that watches for changes and build the examples via: ``` -npm start +yarn start ``` diff --git a/PUBLISHING.md b/PUBLISHING.md new file mode 100644 index 00000000..e68d516a --- /dev/null +++ b/PUBLISHING.md @@ -0,0 +1,17 @@ +# Publishing a new version of this package + +1. run `yarn publish`. This will ask you the new version, login into npm, build + the package, commit and tag before pushing to npm. + If you want to stop at any moment, you can ctrl-c, and depending on the moment, + you'll need to rollback manually. +2. On github, you need to edit the branch protection rules, and uncheck the + option "Do not allow bypassing the above settings". +3. Then you can push to github with the tags: `git push upstream HEAD --tags`. This + is the only case you're allowed to push directly to github. +4. Check the option "Do not allow bypassing the above settings" again. +5. On github, go to the tags page, then create a new release from the new tag + (this is an option in the "..." menu at the right). +6. Click "Generate releases notes" then follow the format of previous releases. + + + diff --git a/README.md b/README.md index 104da2b4..aeadd3cb 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,14 @@ -# Project is no longer maintained - -[![NPM version][npm-image]][npm-url] -[![Build Status][travis-image]][travis-url] -[![Dependency Status][deps-image]][deps-url] -[![Dev Dependency Status][dev-deps-image]][dev-deps-url] -[![Code Climate][climate-image]][climate-url] - -[](https://nodei.co/npm/react-contextmenu/) - # React Contextmenu ContextMenu in React with accessibility support. Live Examples can be found [here](//vkbansal.github.io/react-contextmenu/) +This is a fork from [the original project](https://github.com/vkbansal/react-contextmenu) for use with the [firefox profiler](https://github.com/firefox-devtools/profiler/). We +don't intend to add new features but will fix issues with the existing code, and +sometimes change it for our usage. We hope it can be useful for more projects. + +Thanks [Vivek Kumar Bansal](https://github.com/vkbansal) for all the good work +put in this project. + ## Table of contents - [Installation](#installation) @@ -28,21 +25,21 @@ ContextMenu in React with accessibility support. Live Examples can be found [her Using npm ``` -npm install --save react-contextmenu +npm install --save @firefox-devtools/react-contextmenu ``` Using yarn ``` -yarn add react-contextmenu +yarn add @firefox-devtools/react-contextmenu ``` ## Browser Support -- IE 11 and Edge >= 12 -- FireFox >= 38 -- Chrome >= 47 -- Opera >= 34 -- Safari >= 8 +- Edge >= 94 +- FireFox >= 91 and 78 +- Chrome >= 92 +- Opera >= 79 +- Safari >= 13.1 ## Usage @@ -51,7 +48,7 @@ Simple example ```jsx import React from "react"; import ReactDOM from "react-dom"; -import { ContextMenu, MenuItem, ContextMenuTrigger } from "react-contextmenu"; +import { ContextMenu, MenuItem, ContextMenuTrigger } from "@firefox-devtools/react-contextmenu"; function handleClick(e, data) { console.log(data.foo); @@ -104,27 +101,13 @@ see [usage docs](./docs/usage.md) / [examples](./examples) for more details. ## Contributors -[All Contributors](https://github.com/vkbansal/react-contextmenu/graphs/contributors) +[All Contributors](https://github.com/firefox-devtools/react-contextmenu/graphs/contributors) ## Changelog -For Changelog, see [releases](https://github.com/vkbansal/react-contextmenu/releases) +For Changelog, see [releases](https://github.com/firefox-devtools/react-contextmenu/releases) +For the changelog from before the fork, see [releases](https://github.com/vkbansal/react-contextmenu/releases) ## License [MIT](./LICENSE.md). Copyright(c) [Vivek Kumar Bansal](http://vkbansal.me/) - -[npm-url]: https://npmjs.org/package/react-contextmenu -[npm-image]: http://img.shields.io/npm/v/react-contextmenu.svg?style=flat-square - -[travis-url]: https://travis-ci.org/vkbansal/react-contextmenu -[travis-image]: http://img.shields.io/travis/vkbansal/react-contextmenu/master.svg?style=flat-square - -[deps-url]: https://david-dm.org/vkbansal/react-contextmenu -[deps-image]: https://img.shields.io/david/vkbansal/react-contextmenu.svg?style=flat-square - -[dev-deps-url]: https://david-dm.org/vkbansal/react-contextmenu -[dev-deps-image]: https://img.shields.io/david/dev/vkbansal/react-contextmenu.svg?style=flat-square - -[climate-url]: https://codeclimate.com/github/vkbansal/react-contextmenu -[climate-image]: http://img.shields.io/codeclimate/github/vkbansal/react-contextmenu.svg?style=flat-square diff --git a/deploy.sh b/deploy.sh deleted file mode 100644 index a02f6293..00000000 --- a/deploy.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# - -echo $TRAVIS_BRANCH - -if ([ "$TRAVIS_BRANCH" != "master" ] && [ -z "$TRAVIS_TAG" ]) || [ "$TRAVIS_PULL_REQUEST" != "false" ]; -then - exit -fi - -set -o errexit - -# build examples -NODE_ENV=production npm run build:examples - -cd public -git init - -git config --global user.name "Travis CI" -git config --global user.email "${USER_EMAIL}" - -git add . -git commit -m "Deploy to gh-pages" - -git push --force --quiet "https://${GITHUB_TOKEN}@github.com/vkbansal/react-contextmenu.git" master:gh-pages > /dev/null 2>&1 diff --git a/docs/api.md b/docs/api.md index f0942e9e..686b68f3 100644 --- a/docs/api.md +++ b/docs/api.md @@ -39,6 +39,7 @@ Contextmenu Trigger Component | holdToDisplay | Number | | `1000` | This is applicable only for touch screens. The time (in ms) for which, user has to hold down his/her finger before the menu is shown. **Note:** To disable the long press trigger on left-click just set a negative holdToDisplay value such as `-1` | | renderTag | String or React Element | | | The element inside which the Component must be wrapped. By default `div` is used. But this prop can used to customize it. | | disableIfShiftIsPressed | Boolean | | `false` | If true and shift is pressed, it will open the native browser context menu and ignore this custom component | +| triggerOnLeftClick | Boolean | | `false` | If true, the menu will open with the left click in addition to the right click (or ctrl + click on MacOS) | ### `` diff --git a/docs/usage.md b/docs/usage.md index e80706ad..0265ab6b 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -7,7 +7,7 @@ You need to setup two things: ```jsx import React from "react"; import ReactDOM from "react-dom"; -import { ContextMenu, MenuItem, ContextMenuTrigger } from "react-contextmenu"; +import { ContextMenu, MenuItem, ContextMenuTrigger } from "@firefox-devtools/react-contextmenu"; function handleClick(e, data) { console.log(data.foo); @@ -59,4 +59,4 @@ The styling can be apllied to using following classes. - `react-contextmenu-wrapper` : applied to wrapper around elements in `ContextMenuTrigger`. - `react-contextmenu-submenu` : applied to items that are submenus. -> Note: This package does note include any styling by default. You can use [react-contextmenu.css](https://github.com/vkbansal/react-contextmenu/blob/master/examples/react-contextmenu.css) from examples for quick setup. +> Note: This package does note include any styling by default. You can use [react-contextmenu.css](https://github.com/firefox-devtools/react-contextmenu/blob/master/examples/react-contextmenu.css) from examples for quick setup. diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..138065e6 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,75 @@ +import globals from 'globals'; +import babelParser from '@babel/eslint-parser'; +import jest from 'eslint-plugin-jest'; +import jestDom from 'eslint-plugin-jest-dom'; +import testingLibrary from 'eslint-plugin-testing-library'; +import { FlatCompat } from '@eslint/eslintrc'; + +// Useful function tool to more easily merge external shared configuration for a +// specific files filter. +function configsForFiles({ files, configs }) { + return configs.map(config => ({ ...config, files })); +} + +// Useful to import legacy shared configuration +const compat = new FlatCompat(); + +export default [ + ...compat.extends('vkbansal', 'vkbansal/react'), + { + languageOptions: { + parser: babelParser, + globals: { + ...globals.browser + } + }, + rules: { + 'react/no-array-index-key': 'off' + }, + settings: { + react: { + version: 'detect' + } + } + }, + ...configsForFiles({ + files: ['**/tests/*.js'], + configs: [ + jest.configs['flat/recommended'], + jestDom.configs['flat/recommended'], + testingLibrary.configs['flat/react'], + { + rules: { + 'prefer-arrow-callback': 'off', + 'no-mixed-requires': 'off', + // This disallows using direct Node properties (eg: firstChild), but we + // have legitimate uses: + 'testing-library/no-node-access': 'off', + 'import/no-extraneous-dependencies': [ + 'error', + { devDependencies: true } + ] + } + } + ] + }), + { + files: ['**/examples/*.js'], + settings: { + 'import/resolver': { + webpack: { + config: 'examples/webpack.config.js' + } + } + }, + rules: { + 'import/no-extraneous-dependencies': ['error', { devDependencies: true }] + } + }, + { + files: ['eslint.config.mjs'], + rules: { + 'import/no-extraneous-dependencies': ['error', { devDependencies: true }] + } + } +]; diff --git a/examples/.eslintrc.yml b/examples/.eslintrc.yml deleted file mode 100644 index 504d133d..00000000 --- a/examples/.eslintrc.yml +++ /dev/null @@ -1,6 +0,0 @@ -settings: - import/resolver: - webpack: - config: examples/webpack.config.js -rules: - import/no-extraneous-dependencies: off diff --git a/examples/Customization.js b/examples/Customization.js index f0eb15b5..a72fa5ca 100644 --- a/examples/Customization.js +++ b/examples/Customization.js @@ -35,7 +35,7 @@ export default class Customization extends Component { this.setState(({ logs }) => ({ logs: [`Clicked on ${data.name} menu ${data.item}`, ...logs] })); - } + }; render() { return ( diff --git a/examples/DynamicMenu.js b/examples/DynamicMenu.js index 29cfbb23..d1e984ee 100644 --- a/examples/DynamicMenu.js +++ b/examples/DynamicMenu.js @@ -80,7 +80,7 @@ export default class DynamicMenuExample extends Component { return this.setState(({ logs }) => ({ logs: [` ${data.name} cannot be ${data.action.toLowerCase()}`, ...logs] })); - } + }; render() { const attributes = { diff --git a/examples/MultipleMenus.js b/examples/MultipleMenus.js index 21ae4ac3..1f229944 100644 --- a/examples/MultipleMenus.js +++ b/examples/MultipleMenus.js @@ -18,7 +18,7 @@ export default class MultipleMenus extends Component { this.setState(({ logs }) => ({ logs: [`Clicked on menu ${data.menu} item ${data.item}`, ...logs] })); - } + }; render() { return ( diff --git a/examples/MultipleTargets.js b/examples/MultipleTargets.js index 3bb4deab..5d9636e0 100644 --- a/examples/MultipleTargets.js +++ b/examples/MultipleTargets.js @@ -53,7 +53,7 @@ export default class MultipleTargets extends Component { return this.setState(({ logs }) => ({ logs: [` ${data.name} cannot be ${data.action.toLowerCase()}`, ...logs] })); - } + }; render() { const attributes = { diff --git a/examples/Nested.js b/examples/Nested.js index 3ba0e61b..9fa586fb 100644 --- a/examples/Nested.js +++ b/examples/Nested.js @@ -18,7 +18,7 @@ export default class SimpleMenu extends Component { this.setState(({ logs }) => ({ logs: [`Clicked on menu ${data.item}`, ...logs] })); - } + }; render() { return ( diff --git a/examples/RTLSubMenu.js b/examples/RTLSubMenu.js index 65392d14..ed356839 100644 --- a/examples/RTLSubMenu.js +++ b/examples/RTLSubMenu.js @@ -18,7 +18,7 @@ export default class RTLSubMenu extends Component { this.setState(({ logs }) => ({ logs: [`Clicked on menu ${data.item}`, ...logs] })); - } + }; render() { return ( diff --git a/examples/SimpleMenu.js b/examples/SimpleMenu.js index cbd0e5d1..c4802b62 100644 --- a/examples/SimpleMenu.js +++ b/examples/SimpleMenu.js @@ -17,7 +17,7 @@ export default class SimpleMenu extends Component { this.setState(({ logs }) => ({ logs: [`Clicked on menu ${data.item}`, ...logs] })); - } + }; render() { return ( diff --git a/examples/SubMenus.js b/examples/SubMenus.js index cc70f365..338eabb7 100644 --- a/examples/SubMenus.js +++ b/examples/SubMenus.js @@ -18,7 +18,7 @@ export default class SimpleMenu extends Component { this.setState(({ logs }) => ({ logs: [`Clicked on menu ${data.item}`, ...logs] })); - } + }; render() { return ( diff --git a/examples/index.html b/examples/index.html index c27b9623..4e340397 100644 --- a/examples/index.html +++ b/examples/index.html @@ -30,11 +30,16 @@ vertical-align: bottom; } - .link-active, - .link-active:focus, - .link-active:hover { + .pure-menu-link { + /* Override pure CSS color to add more contrast for accessibility */ + color: #737373; + } + + .pure-menu-link.active, + .pure-menu-link.active:focus, + .pure-menu-link.active:hover { color: #fff; - background: #20a0ff; + background: #0060df; } .well { @@ -51,23 +56,12 @@
ContextMenu in React with accessibility support.
-
-
+
Download / Usage: View on GitHub
+Download / Usage: View on GitHub