@octane-xplat/context-menu 0.9.0 → 0.11.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
|
@@ -4,7 +4,6 @@ An install boundary for platform-specific context menus: 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
7
|
Install the package in the app that renders a control. Import
|
|
9
8
|
`SwiftUIContextMenu` from `@octane-xplat/context-menu/ios`,
|
|
10
9
|
`MaterialContextMenu` from `@octane-xplat/context-menu/android`,
|
|
@@ -13,6 +12,74 @@ Install the package in the app that renders a control. Import
|
|
|
13
12
|
platform-suffixed file. There is no shared context-menu API at the package
|
|
14
13
|
root.
|
|
15
14
|
|
|
15
|
+
```tsx
|
|
16
|
+
/** @jsxImportSource @nativescript-community/octane */
|
|
17
|
+
// SwiftUIContextMenuExample.ios.tsx
|
|
18
|
+
import { SwiftUIContextMenu } from '@octane-xplat/context-menu/ios'
|
|
19
|
+
import { Text } from '@octane-xplat/ui'
|
|
20
|
+
|
|
21
|
+
export function Menu() {
|
|
22
|
+
return (
|
|
23
|
+
<SwiftUIContextMenu
|
|
24
|
+
trigger={() => <Text>Trip actions</Text>}
|
|
25
|
+
items={[{ id: 'rename', title: 'Rename' }]}
|
|
26
|
+
onItemSelected={(id) => console.log(id)}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
/** @jsxImportSource @nativescript-community/octane */
|
|
34
|
+
// MaterialContextMenuExample.android.tsx
|
|
35
|
+
import { MaterialContextMenu } from '@octane-xplat/context-menu/android'
|
|
36
|
+
import { Text } from '@octane-xplat/ui'
|
|
37
|
+
|
|
38
|
+
export function Menu() {
|
|
39
|
+
return (
|
|
40
|
+
<MaterialContextMenu
|
|
41
|
+
activation="singlePress"
|
|
42
|
+
trigger={() => <Text>Trip actions</Text>}
|
|
43
|
+
items={[{ id: 'rename', title: 'Rename' }]}
|
|
44
|
+
onItemSelected={(id) => console.log(id)}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
// ContextMenuExample.web.tsx
|
|
52
|
+
import { ContextMenu } from '@octane-xplat/context-menu/web'
|
|
53
|
+
import { Text } from '@octane-xplat/ui'
|
|
54
|
+
|
|
55
|
+
export function Menu() {
|
|
56
|
+
return (
|
|
57
|
+
<ContextMenu
|
|
58
|
+
activation="singlePress"
|
|
59
|
+
trigger={() => <Text>Trip actions</Text>}
|
|
60
|
+
items={[{ id: 'rename', title: 'Rename' }]}
|
|
61
|
+
onItemSelected={(id) => console.log(id)}
|
|
62
|
+
/>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
// AppKitContextMenuExample.macos.tsx
|
|
69
|
+
import { AppKitContextMenu } from '@octane-xplat/context-menu/macos'
|
|
70
|
+
import { Text } from '@octane-xplat/ui'
|
|
71
|
+
|
|
72
|
+
export function Menu() {
|
|
73
|
+
return (
|
|
74
|
+
<AppKitContextMenu
|
|
75
|
+
trigger={() => <Text>Trip actions</Text>}
|
|
76
|
+
items={[{ id: 'rename', title: 'Rename' }]}
|
|
77
|
+
onItemSelected={(id) => console.log(id)}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
16
83
|
Unlike props-only leaves (picker, date-picker), this leaf exercises subtree
|
|
17
84
|
embedding: `trigger` is a render fn whose octane output mounts into a
|
|
18
85
|
detached root, and the native menu wraps that subtree — SwiftUI resolves it
|
|
@@ -22,6 +89,24 @@ through `NativeScriptViewFactory` (the same factory the swift-ui plugin's
|
|
|
22
89
|
serialized data (`{id, title, destructive, disabled, divider}`), reported
|
|
23
90
|
back through `onItemSelected(id)`.
|
|
24
91
|
|
|
92
|
+
```tsx
|
|
93
|
+
/** @jsxImportSource @nativescript-community/octane */
|
|
94
|
+
// Actions.ios.tsx
|
|
95
|
+
import { SwiftUIContextMenu } from '@octane-xplat/context-menu/ios'
|
|
96
|
+
import { Text } from '@octane-xplat/ui'
|
|
97
|
+
|
|
98
|
+
export function Actions() {
|
|
99
|
+
return (
|
|
100
|
+
<SwiftUIContextMenu
|
|
101
|
+
trigger={() => <Text>Trip actions</Text>}
|
|
102
|
+
preview={() => <Text>Kyoto trip</Text>}
|
|
103
|
+
items={[{ id: 'delete', title: 'Delete', destructive: true, divider: true }]}
|
|
104
|
+
onItemSelected={(id) => console.log(id)}
|
|
105
|
+
/>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
25
110
|
- iOS: long-press activation (platform native); optional `preview` render fn
|
|
26
111
|
(iOS 16+).
|
|
27
112
|
- Android: `activation` prop — `'longPress'` (default) or `'singlePress'`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/context-menu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Platform-specific context menu controls for Octane xplat",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@nativescript/core": "9.1.2",
|
|
41
41
|
"@octanejs/vite-plugin": "0.1.60",
|
|
42
42
|
"octane": "0.5.0",
|
|
43
|
-
"tsrx-typegen": "0.2.
|
|
43
|
+
"tsrx-typegen": "0.2.2",
|
|
44
44
|
"typescript": "5.9.3",
|
|
45
45
|
"vite": "8.3.0"
|
|
46
46
|
},
|