{"id":13535243,"url":"https://github.com/j-f1/MenuBuilder","last_synced_at":"2025-04-02T00:32:58.637Z","repository":{"id":37863084,"uuid":"325868167","full_name":"j-f1/MenuBuilder","owner":"j-f1","description":"Swift Function Builder for creating NSMenuItems","archived":false,"fork":false,"pushed_at":"2023-03-04T20:34:35.000Z","size":326,"stargazers_count":58,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T21:04:42.491Z","etag":null,"topics":["appkit","cocoa","dsl","functionbuilder","nsmenu","swift"],"latest_commit_sha":null,"homepage":"https://menubuilder.jedfox.com","language":"Swift","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/j-f1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-31T20:22:02.000Z","updated_at":"2025-03-30T00:47:39.000Z","dependencies_parsed_at":"2022-07-09T03:47:03.576Z","dependency_job_id":null,"html_url":"https://github.com/j-f1/MenuBuilder","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j-f1%2FMenuBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j-f1%2FMenuBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j-f1%2FMenuBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j-f1%2FMenuBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j-f1","download_url":"https://codeload.github.com/j-f1/MenuBuilder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246709881,"owners_count":20821298,"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":["appkit","cocoa","dsl","functionbuilder","nsmenu","swift"],"created_at":"2024-08-01T08:00:51.897Z","updated_at":"2025-04-02T00:32:58.321Z","avatar_url":"https://github.com/j-f1.png","language":"Swift","funding_links":[],"categories":["AppKit"],"sub_categories":[],"readme":"# MenuBuilder\n\nA function builder for `NSMenu`s, similar in spirit to SwiftUI’s `ViewBuilder`.\n\nUsage example (see demo or [read the documentation](https://menubuilder.jedfox.com) for more details):\n\n```swift\nlet menu = NSMenu {\n  MenuItem(\"Click me\")\n    .onSelect { print(\"clicked!\") } \n  MenuItem(\"Item with a view\")\n    .view {\n      MyMenuItemView() // any SwiftUI view\n    }\n  SeparatorItem()\n  MenuItem(\"About\") {\n    // rendered as disabled items in a submenu\n    MenuItem(\"Version 1.2.3\")\n    MenuItem(\"Copyright 2021\")\n  }\n  MenuItem(\"Quit\")\n    .shortcut(\"q\")\n    .onSelect { NSApp.terminate(nil) }\n}\n\n// later, to replace the menu items with different/updated ones:\nmenu.replaceItems {\n  MenuItem(\"Replaced item\").onSelect { print(\"Hello!\") }\n}\n```\n\nNote that there is no way to preserve the existing menu items, although it should be possible to implement that — feel free to open an issue or PR adding update support if you want it!\n\n## Changelog\n\n### v3.0.0\n\n* (Potentially **BREAKING**) When your app has a deployment target of macOS 12 or newer, passing a string literal to `MenuItem(\"Title Here\")` will now create a `String.LocalizationValue`, which will make it easier to localize your app if you use MenuBuilder.\n  * If your app is not localized (or your deployment target is macOS 11 or older), you shouldn’t notice any changes.\n  * If your app is localized, review your UI that uses MenuBuilder and make sure that you’re not getting any unexpected translations. You can migrate to `MenuItem(verbatim: \"Title Here\")` if you want to opt out of the new behavior.\n  * Thanks to @ShikiSuen for getting this started!\n\n### v2.1.0\n\nCheck out the new API docs! https://menubuilder.jedfox.com\n\nNew Features:\n\n* Add `action` and `tag` modifiers (Thanks @patr0nus!)\n* Update the SwiftUI custom view wrapper to use Auto Layout (Thanks @rurza!)\n* Add support for menu item titles using `AttributedString` on macOS 12+\n* Add a convenience initializer to `NSMenu` that takes a `title` and an `@MenuBuilder` closure\n* Deprecate the `MenuItem(_:children:)` initializer in favor of `MenuItem(title).submenu { ... children ... }`\n* Add an `onSelect(target:action:)` convenience method to set the `target` and `action` at the same time.\n\nBugfixes:\n\n* Update the SwiftUI custom view wrapper’s selection indicator to match the menu styling of macOS Big Sur and later (Thanks @rurza!)\n* Make the parameter to `toolTip` optional (Thanks @mlch911!)\n* `update()` is now called on an `NSMenu` when you use the `replaceItems` API\n\n### v2.0.0\n* (**BREAKING**) Migrate to `@resultBuilder` (Xcode 12.5+ is now required)\n* Apply modifiers to shortcuts\n* Add a `MenuItem.set(WriteableKeyPath, to: Value)` method to make it easier to customize the menu item\n* Add a `MenuItem.apply { menuItem in }` method to allow arbitrary customization of the menu item\n* Add `IndentGroup` to make it easier to indent several adjacent menu items\n* Add `CustomMenuItem` which allows you to include custom subclasses of `NSMenuItem` in a `MenuBuilder`\n\n### v1.3.0\n\nFixes \u0026 cleanup\n\n### v1.2.0\n\nAdd loop support\n\n### v1.1.0\n\nAdd conditional support\n\n### v1.0.1\n\nAdd license, clean up code\n\n### v1.0.0\n\nInitial version!\n\n\n## Contributing\n\nOpen the `MenuBuilder.xcworkspace` to view the package and demo at the same time. PRs and issues are appreciated!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj-f1%2FMenuBuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj-f1%2FMenuBuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj-f1%2FMenuBuilder/lists"}