{"id":16976937,"url":"https://github.com/johndatserakis/vue-simple-context-menu","last_synced_at":"2025-04-04T06:06:37.741Z","repository":{"id":32498760,"uuid":"135372245","full_name":"johndatserakis/vue-simple-context-menu","owner":"johndatserakis","description":"📌 Simple context-menu component built for Vue. Works well with both left and right clicks. Nothing too fancy, just works and is simple to use.","archived":false,"fork":false,"pushed_at":"2023-11-26T04:03:57.000Z","size":1854,"stargazers_count":231,"open_issues_count":1,"forks_count":54,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2024-04-24T08:16:03.416Z","etag":null,"topics":["click","content","menu","right","simple","vue","vue2","vue3","vuejs"],"latest_commit_sha":null,"homepage":"https://johndatserakis.github.io/vue-simple-context-menu/","language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johndatserakis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-05-30T01:38:04.000Z","updated_at":"2024-04-03T15:33:37.000Z","dependencies_parsed_at":"2024-01-02T23:34:38.318Z","dependency_job_id":"616abb38-4b0e-4949-8f95-0e345e919b0f","html_url":"https://github.com/johndatserakis/vue-simple-context-menu","commit_stats":{"total_commits":70,"total_committers":9,"mean_commits":7.777777777777778,"dds":0.2857142857142857,"last_synced_commit":"7148986381c5fab0581c87f8a4e53a6ff3f78737"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndatserakis%2Fvue-simple-context-menu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndatserakis%2Fvue-simple-context-menu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndatserakis%2Fvue-simple-context-menu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndatserakis%2Fvue-simple-context-menu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johndatserakis","download_url":"https://codeload.github.com/johndatserakis/vue-simple-context-menu/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128739,"owners_count":20888234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["click","content","menu","right","simple","vue","vue2","vue3","vuejs"],"created_at":"2024-10-14T01:27:38.369Z","updated_at":"2025-04-04T06:06:37.726Z","avatar_url":"https://github.com/johndatserakis.png","language":"Vue","funding_links":[],"categories":["Components \u0026 Libraries","UI组件","UI Components","UI Components [🔝](#readme)"],"sub_categories":["UI Components","形成","Form"],"readme":"# vue-simple-context-menu\n\nSimple context-menu component built for Vue. Works well with both left and right clicks. Nothing too fancy, just works and is simple to use.\n\n\u003cp align=\"left\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vue-simple-context-menu\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/vue-simple-context-menu.svg\" alt=\"NPM Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vue-simple-context-menu\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/vue-simple-context-menu.svg\" alt=\"NPM Downloads\"\u003e\u003c/a\u003e\n  \u003ca href=\"http://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fjohndatserakis%2Fvue-simple-context-menu\u0026text=Check%20out%20vue-simple-context-menu%20on%20GitHub\u0026via=johndatserakis\"\u003e\n  \u003cimg src=\"https://img.shields.io/twitter/url/https/github.com/johndatserakis/vue-simple-context-menu.svg?style=social\" alt=\"Tweet\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n- [Demo](https://johndatserakis.github.io/vue-simple-context-menu/)\n- [GitHub](https://github.com/johndatserakis/vue-simple-context-menu)\n- [npm](https://www.npmjs.com/package/vue-simple-context-menu)\n- [StackBlitz](https://stackblitz.com/edit/vue-chj3sg?file=src/App.vue)\n\n## Vue 3 Support\n\nVue 3 is supported from `v4.0.0` and beyond (current `master`). To use `vue-simple-context-menu` with Vue 2, use `v3.4.2`.\n\n## Install\n\n```\nyarn add vue-simple-context-menu\n```\n\n## About\n\nJust a simple little menu to be shown where a click happens - closes after use automatically by clicking an option or outside of the menu. Multiple menus are supported - just make sure to use a unique string as your `element-id` prop value.\n\nA nice feature that comes baked in is the menu placement after a click - it sits just ever so slightly under your click location - so that any hover style you had on the item that was clicked gets removed nicely. I modeled it after the macOS right click menu.\n\n## Usage\n\n```js\nimport { createApp } from 'vue';\nimport VueSimpleContextMenu from 'vue-simple-context-menu';\nimport 'vue-simple-context-menu/dist/vue-simple-context-menu.css';\n\nconst app = createApp(App);\n\napp.component('vue-simple-context-menu', VueSimpleContextMenu);\n```\n\n```html\n\u003c!-- This is a basic use case where you have an array of items that you want\nto allow to be clicked. In this case, `items` is an array of objects.\nEach item has a click event that ties to a function. See the demo for a full example (with multiple menus as well). --\u003e\n\u003cdiv class=\"item-wrapper\"\u003e\n  \u003cdiv\n    v-for=\"item in items\"\n    @click.prevent.stop=\"handleClick($event, item)\"\n    class=\"item-wrapper__item\"\n  \u003e\n    {{item.name}}\n  \u003c/div\u003e\n\u003c/div\u003e\n\n\u003c!-- Make sure you add the `ref` attribute, as that is what gives you the ability\nto open the menu. --\u003e\n\u003cvue-simple-context-menu\n  element-id=\"myUniqueId\"\n  :options=\"options\"\n  ref=\"vueSimpleContextMenu\"\n  @option-clicked=\"optionClicked\"\n/\u003e\n```\n\n```js\nhandleClick (event, item) {\n  this.$refs.vueSimpleContextMenu.showMenu(event, item)\n}\n\n\noptionClicked (event) {\n  window.alert(JSON.stringify(event))\n}\n```\n\nNote - you must pass the click event-info variable to the `showMenu()` function because that's how we know where to show the menu.\n\nNote - make sure to use `@click.prevent.stop` (or `@contextmenu.prevent.stop` for right click) when setting up the click handler.\n\n## Props\n\n| prop            | type   | description                                                                                  | required |\n| --------------- | ------ | -------------------------------------------------------------------------------------------- | -------- |\n| `elementId`     | String | Unique String that acts as the id of your menu.                                              | Yes      |\n| `options`       | Array  | Array of menu options to show. Component will use the `name` parameter as the label.         | Yes      |\n| `options.name`  | String | Label for the option.                                                                        | Yes      |\n| `options.class` | String | A custom class that will be applied to the option.                                           | No       |\n| `options.type`  | String | Only one possible value at the moment - `divider`. Pass this to set the object as a divider. | No       |\n| `ref`           | String | Unique String that allows you to show the menu on command.                                   | Yes      |\n\n## Methods\n\n| method     | parameters                        | description                                                          |\n| ---------- | --------------------------------- | -------------------------------------------------------------------- |\n| `showMenu` | event (MouseEvent), item (Object) | Used to show the menu. Make sure to pass a MouseEvent and an Object. |\n\n## Events\n\n| event            | value  | description                                                                                                                                                                                          |\n| ---------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `option-clicked` | Object | When a menu item is clicked the component will emit an event with a value containing the clicked item and the menu option that was clicked. Register for this event to capture the selection result. |\n| `menu-closed`    |        | Emitted when the menu is closed                                                                                                                                                                      |\n\n## SASS Structure\n\n```scss\n.vue-simple-context-menu {\n  \u0026--active {\n  }\n\n  \u0026__item {\n    \u0026:hover {\n    }\n  }\n\n  \u0026__divider {\n  }\n}\n```\n\n## Development\n\n```bash\n# Install dependencies\nyarn\n\n# Serve with hot reload\nyarn dev\n\n# Run the tests\nyarn test\n\n# Build demo page\nyarn build:example\n\n# Build library\nyarn build:library\n\n# Build everything and run tests\nyarn build\n```\n\n## Other\n\nGo ahead and fork the project! Submit an issue if needed. Have fun!\n\n## Thank You\n\nInfluenced by [Lucas Calazans](https://codepen.io/lucascalazans)'s [pen](https://codepen.io/lucascalazans/pen/ALvVVw). Go ahead and check out his other work.\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohndatserakis%2Fvue-simple-context-menu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohndatserakis%2Fvue-simple-context-menu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohndatserakis%2Fvue-simple-context-menu/lists"}