@octane-xplat/context-menu 0.11.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# `@octane-xplat/context-menu`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Platform-specific context menus for Octane xplat apps: a SwiftUI
|
|
4
4
|
`.contextMenu` on iOS, a Material 3 `DropdownMenu` anchored to a hosted
|
|
5
5
|
trigger on Android, an in-page right-click menu on web, and a real
|
|
6
6
|
`NSMenu` on the backing view on macOS.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
|
|
8
|
+
There is no shared context-menu component. Install the package in the app
|
|
9
|
+
that renders a control, then import `SwiftUIContextMenu` from
|
|
10
|
+
`@octane-xplat/context-menu/ios`, `MaterialContextMenu` from
|
|
11
|
+
`@octane-xplat/context-menu/android`, `ContextMenu` from
|
|
12
|
+
`@octane-xplat/context-menu/web`, or `AppKitContextMenu` from
|
|
13
|
+
`@octane-xplat/context-menu/macos` in the matching platform-suffixed file.
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
16
|
/** @jsxImportSource @nativescript-community/octane */
|
|
@@ -80,14 +80,9 @@ export function Menu() {
|
|
|
80
80
|
}
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
through `NativeScriptViewFactory` (the same factory the swift-ui plugin's
|
|
87
|
-
`NativeScriptView` uses), and Android through the leaf's
|
|
88
|
-
`XplatViewRegistry` + `AndroidView`. Menu items cross the bridge as
|
|
89
|
-
serialized data (`{id, title, destructive, disabled, divider}`), reported
|
|
90
|
-
back through `onItemSelected(id)`.
|
|
83
|
+
Menu items are plain data (`{id, title, destructive, disabled, divider}`),
|
|
84
|
+
reported back through `onItemSelected(id)`. The iOS entry also accepts an
|
|
85
|
+
optional `preview` render function (iOS 16+):
|
|
91
86
|
|
|
92
87
|
```tsx
|
|
93
88
|
/** @jsxImportSource @nativescript-community/octane */
|
|
@@ -117,6 +112,15 @@ export function Actions() {
|
|
|
117
112
|
- macOS: right-click — the NSMenu is the view's `menu`, so AppKit owns
|
|
118
113
|
activation and disabled-item dimming; the trigger renders inline.
|
|
119
114
|
|
|
115
|
+
## How the native menus work
|
|
116
|
+
|
|
117
|
+
Unlike props-only leaves (picker, date-picker), this leaf exercises subtree
|
|
118
|
+
embedding: `trigger` is a render fn whose octane output mounts into a
|
|
119
|
+
detached root, and the native menu wraps that subtree — SwiftUI resolves it
|
|
120
|
+
through `NativeScriptViewFactory` (the same factory the swift-ui plugin's
|
|
121
|
+
`NativeScriptView` uses), and Android through the leaf's
|
|
122
|
+
`XplatViewRegistry` + `AndroidView`.
|
|
123
|
+
|
|
120
124
|
The native implementations are adapted from `@expo/ui` (MIT,
|
|
121
125
|
`packages/expo-ui` sdk-57): `ios/ContextMenu/ContextMenu.swift` and
|
|
122
126
|
`android/.../ui/menu/DropdownMenu*.kt`. Attribution headers sit on the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/context-menu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Platform-specific context menu controls for Octane xplat",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@nativescript-community/octane": "0.2.4",
|
|
46
|
-
"@nativescript/core": "9.1.
|
|
46
|
+
"@nativescript/core": "9.1.3",
|
|
47
47
|
"@octanejs/vite-plugin": "0.1.60",
|
|
48
48
|
"octane": "0.5.0",
|
|
49
49
|
"tsrx-typegen": "0.2.2",
|