Repository: electron
Issue: [Feature Request]: Support macOS palette menus
Labels: enhancement :sparkles:,platform/macOS

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a feature request that matches the one I want to file, without success.

### Problem Description

I can't seem to create palette menus with Electron, which were made public API in macOS Sonoma (14). They are described here:

- [WWDC23: What's new in AppKit](https://developer.apple.com/videos/play/wwdc2023/10054/?time=380)
- [`NSMenu.PresentationStyle.palette`](https://developer.apple.com/documentation/appkit/nsmenu/presentationstyle/palette) (also contains a code sample)

These allow for creating menus such as this one, from Messages:

<img src=https://github.com/user-attachments/assets/f522e674-62eb-4d0c-9d25-67585f68fb14 width=500>

From what I can see, Electron doesn't expose a way to create this kind of menu. You need to be able to specify the `NSMenu`'s `presentationStyle`. You can seemingly embed a palette menu (`NSMenu` with a `presentationStyle` of `.palette`) within a larger menu by creating an `NSMenuItem` and setting its submenu to the palette menu.

### Proposed Solution

I would like some way to create palette menus while also being able to populate the palette with images (`NativeImage`s?) from JavaScript. This sounds a bit tricky, so I can take the time to design an API surface if wanted. However, I assume that the maintainers would do a better job than me.

My current use case doesn't involve maintaining a selection state for the items in the palette via [`selectionMode`](https://developer.apple.com/documentation/appkit/nsmenu/4179456-selectionmode). In other words, I'd like to be able to use palette menus just so that I can present menu items arranged horizontally, with only images to represent the item - just like the menu in Messages. However, support for this may or may not be desired if this feature is to be added to Electron.

### Alternatives Considered

You can use `MenuItem`s with icons, but it doesn't provide the same look and feel of a palette menu. There doesn't seem to be any other way to achieve this without dropping down to the renderer and reimplementing menus there.

### Additional Information

With the release of macOS Sonoma, menus (in general, across the system) were reimplemented in Cocoa and that new implementation is used within applications according to some runtime heuristics involving link checks.

A default controlling this is `NSMenuEnableCarbonCompatibilityMode`. The details around this are important because AIUI, Carbon menus involved a modal event-tracking loop that would run for the duration of the menu being on-screen. This would block the main AppKit thread. I believe that Cocoa menus don't use this and the main AppKit thread is able to run unencumbered with Cocoa menus visible. This is just a guess, though.