{"id":23053470,"url":"https://github.com/component/menu","last_synced_at":"2025-08-15T03:32:50.508Z","repository":{"id":4139818,"uuid":"5252717","full_name":"component/menu","owner":"component","description":"Menu component","archived":false,"fork":false,"pushed_at":"2015-11-25T18:33:49.000Z","size":346,"stargazers_count":22,"open_issues_count":3,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-06T01:34:16.512Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/component.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-31T23:12:57.000Z","updated_at":"2024-03-04T15:47:37.000Z","dependencies_parsed_at":"2022-07-20T07:17:07.494Z","dependency_job_id":null,"html_url":"https://github.com/component/menu","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fmenu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fmenu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fmenu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fmenu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/component","download_url":"https://codeload.github.com/component/menu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229890467,"owners_count":18140104,"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":[],"created_at":"2024-12-16T00:18:18.994Z","updated_at":"2024-12-16T00:18:19.544Z","avatar_url":"https://github.com/component.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Menu\n\n  Menu component with structural styling to give you a clean slate.\n\n  ![js menu component](http://f.cl.ly/items/1Z1d3B1j283y3e200g3E/Screen%20Shot%202012-07-31%20at%203.57.10%20PM.png)\n\n## Installation\n\n```\n$ npm install menu-component\n```\n\n## Features\n\n  - events for composition\n  - structural CSS letting you decide on style\n  - fluent API\n  - arrow key navigation\n\n## Events\n\n  - `show` when shown\n  - `hide` when hidden\n  - `remove` (item) when an item is removed\n  - `clear` when the menu has been cleared\n  - `select` (item) when an item is selected\n  - `*` menu item events are emitted when clicked\n\n## Example\n\n```js\nvar Menu = require('menu');\n\nvar menu = new Menu;\n\nmenu\n.add('Add item')\n.add('Edit item', function(){ console.log('edit'); })\n.add('Remove item', function(){ console.log('remove'); })\n.add('Remove \"Add item\"', function(){\n  menu.remove('Add item');\n  menu.remove('Remove \"Add item\"');\n});\n\nmenu.on('select', function(item){\n  console.log('selected \"%s\"', item);\n});\n\nmenu.on('Add item', function(){\n  console.log('added an item');\n});\n\noncontextmenu = function(e){\n  e.preventDefault();\n  menu.moveTo(e.pageX, e.pageY);\n  menu.show();\n};\n```\n\n## API\n\n### Menu()\n\n  Create a new `Menu`:\n\n```js\nvar Menu = require('menu');\nvar menu = new Menu();\nvar menu = Menu();\n```\n\n### Menu#add([slug], text, [fn])\n\n  Add a new menu item with the given `text`, optional `slug` and callback `fn`.\n\n  Using events to handle selection:\n\n```js\nmenu.add('Hello');\n\nmenu.on('Hello', function(){\n  console.log('clicked hello');\n});\n```\n\n  Using callbacks:\n\n```js\nmenu.add('Hello', function(){\n  console.log('clicked hello');\n});\n```\n\n  Using a custom slug, otherwise \"hello\" is generated\n  from the `text` given, which may conflict with \"rich\"\n  styling like icons within menu items, or i18n.\n\n```js\nmenu.add('add-item', 'Add Item');\n\nmenu.on('add-item', function(){\n  console.log('clicked \"Add Item\"');\n});\n\nmenu.add('add-item', 'Add Item', function(){\n  console.log('clicked \"Add Item\"');\n});\n```\n\n### Menu#remove(slug)\n\n  Remove an item by the given `slug`:\n\n```js\nmenu.add('Add item');\nmenu.remove('Add item');\n```\n\n  Or with custom slugs:\n\n```js\nmenu.add('add-item', 'Add item');\nmenu.remove('add-item');\n```\n\n### Menu#clear()\n\n  Clears the menu.\n\n```js\nmenu.clear();\n```\n\n### Menu#has(slug)\n\n  Check if a menu item is present.\n\n```js\nmenu.add('Add item');\n\nmenu.has('Add item');\n// =\u003e true\n\nmenu.has('add-item');\n// =\u003e true\n\nmenu.has('Foo');\n// =\u003e false\n```\n\n### Menu#moveTo(x, y)\n\n  Move the menu to `(x, y)`.\n\n### Menu#show()\n\n  Show the menu.\n\n### Menu#hide()\n\n  Hide the menu.\n\n## License\n\n  MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fmenu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomponent%2Fmenu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fmenu/lists"}