@octane-xplat/context-menu 0.18.0 → 0.20.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.
Files changed (38) hide show
  1. package/README.md +2 -124
  2. package/package.json +92 -86
  3. package/src/AppKitContextMenu.macos.css +1 -0
  4. package/src/AppKitContextMenu.macos.tsrx +41 -21
  5. package/src/AppKitContextMenu.tsrx +2 -0
  6. package/src/ContextMenu.tsrx +2 -0
  7. package/src/ContextMenu.web.tsrx +168 -149
  8. package/src/MaterialContextMenu.android.tsrx +128 -101
  9. package/src/MaterialContextMenu.tsrx +2 -0
  10. package/src/SwiftUIContextMenu.ios.tsrx +104 -84
  11. package/src/SwiftUIContextMenu.tsrx +2 -0
  12. package/src/android/index.ts +3 -3
  13. package/src/android/types.ts +29 -18
  14. package/src/context-menu-owner.macos.ts +213 -0
  15. package/src/ios/types.ts +28 -19
  16. package/src/macos/types.ts +27 -18
  17. package/src/web/types.ts +29 -14
  18. package/types/generated/.tsrx-typegen-manifest.json +19 -0
  19. package/types/generated/AppKitContextMenu.macos.d.ts +8 -0
  20. package/types/generated/ContextMenu.web.d.ts +7 -0
  21. package/types/generated/MaterialContextMenu.android.d.ts +16 -0
  22. package/types/generated/SwiftUIContextMenu.ios.d.ts +17 -0
  23. package/types/generated/android/index.d.ts +2 -0
  24. package/types/generated/android/types.d.ts +35 -0
  25. package/types/generated/context-menu-owner.macos.d.ts +16 -0
  26. package/types/generated/index.d.ts +1 -0
  27. package/types/generated/ios/index.d.ts +2 -0
  28. package/types/generated/ios/types.d.ts +33 -0
  29. package/types/generated/macos/index.d.ts +2 -0
  30. package/types/generated/macos/types.d.ts +32 -0
  31. package/types/generated/web/index.d.ts +2 -0
  32. package/types/generated/web/types.d.ts +34 -0
  33. package/LICENSE +0 -21
  34. package/types/android/index.d.ts +0 -22
  35. package/types/index.d.ts +0 -1
  36. package/types/ios/index.d.ts +0 -20
  37. package/types/macos/index.d.ts +0 -19
  38. package/types/web/index.d.ts +0 -22
@@ -1,54 +1,71 @@
1
- /** @jsxImportSource @nativescript-community/octane */
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
2
  import { registerElement } from '@nativescript-community/octane'
3
- import type { Attributes } from '@nativescript-community/octane/intrinsics'
3
+ import type { Attributes } from '@octane-xplat/jsx/intrinsics'
4
4
  import { SwiftUI, UIDataDriver, registerSwiftUI, SwiftUIManager } from '@nativescript/swift-ui'
5
5
  import { GridLayout } from '@nativescript/core'
6
- import { getSwiftUIHostLifecycle, registerSwiftUIHost, unregisterSwiftUIHost } from '@octane-xplat/lib'
7
- import { createPortal as createUniversalPortal, type UniversalRenderable } from 'octane/universal/native'
6
+ import {
7
+ getSwiftUIHostLifecycle,
8
+ registerSwiftUIHost,
9
+ unregisterSwiftUIHost,
10
+ } from '@octane-xplat/lib'
11
+
12
+ import {
13
+ createPortal as createUniversalPortal,
14
+ type UniversalRenderable,
15
+ } from 'octane/universal/native'
16
+
8
17
  import { useEffect, useRef, useState } from 'octane'
9
18
  import type { SwiftUIContextMenuProps } from './ios/types'
10
19
 
11
20
  declare const XplatContextMenuProvider: any
12
21
  declare const NativeScriptViewFactory: any
13
22
 
14
- declare module '@nativescript-community/octane/intrinsics' {
15
- interface NativeScriptElements {
16
- xplatioscontextmenu: Attributes<typeof SwiftUI>
17
- }
23
+ declare module '@octane-xplat/jsx/intrinsics' {
24
+ interface NativeElements<TElement> {
25
+ xplatioscontextmenu: Attributes<
26
+ TElement,
27
+ {
28
+ swiftId?: string
29
+ data?: Record<string, unknown>
30
+ onSwiftUIEvent?: (event: { data?: unknown }) => void
31
+ }
32
+ >
33
+ }
18
34
  }
19
35
 
20
36
  registerElement('xplatioscontextmenu', SwiftUI)
21
- registerSwiftUI('xplat-swiftui-contextmenu', (owner: any) =>
22
- new UIDataDriver(new XplatContextMenuProvider(), owner),
37
+ registerSwiftUI(
38
+ 'xplat-swiftui-contextmenu',
39
+ (owner: any) => new UIDataDriver(new XplatContextMenuProvider(), owner),
23
40
  )
24
41
 
25
42
  function createPortal(children: unknown, target: unknown) {
26
- return createUniversalPortal(children as UniversalRenderable, target)
43
+ return createUniversalPortal(children as UniversalRenderable, target)
27
44
  }
28
45
 
29
46
  function ensureNativeScriptViewFactory(): void {
30
- if (!NativeScriptViewFactory.shared) {
31
- NativeScriptViewFactory.initShared()
32
- }
47
+ if (!NativeScriptViewFactory.shared) {
48
+ NativeScriptViewFactory.initShared()
49
+ }
33
50
  }
34
51
 
35
52
  function registerHosts(
36
- triggerId: string,
37
- trigger: GridLayout,
38
- previewId: string,
39
- preview: GridLayout,
53
+ triggerId: string,
54
+ trigger: GridLayout,
55
+ previewId: string,
56
+ preview: GridLayout,
40
57
  ): void {
41
- ensureNativeScriptViewFactory()
42
- registerSwiftUIHost(triggerId, { create: () => trigger })
43
- registerSwiftUIHost(previewId, { create: () => preview })
44
- SwiftUIManager.registerNativeScriptViews(
45
- { [triggerId]: true, [previewId]: true },
46
- getSwiftUIHostLifecycle(),
47
- )
58
+ ensureNativeScriptViewFactory()
59
+ registerSwiftUIHost(triggerId, { create: () => trigger })
60
+ registerSwiftUIHost(previewId, { create: () => preview })
61
+ SwiftUIManager.registerNativeScriptViews(
62
+ { [triggerId]: true, [previewId]: true },
63
+ getSwiftUIHostLifecycle(),
64
+ )
48
65
  }
49
66
 
50
67
  function TriggerRoot(props: { render: () => any }) @{
51
- <>{props.render()}</>;
68
+ <>{props.render()}</>
52
69
  }
53
70
 
54
71
  let seq = 0
@@ -56,62 +73,65 @@ let seq = 0
56
73
  /** Renders a SwiftUI .contextMenu whose trigger and optional preview portal
57
74
  * from the declaring Octane tree into NativeScript hosts. Menu items arrive
58
75
  * as serialized data. */
59
- export function SwiftUIContextMenu(props: SwiftUIContextMenuProps) @{
60
- const triggerId = useRef<string>('')
61
- if (!triggerId.current) {
62
- triggerId.current = `ctxmenu${++seq}`
63
- }
64
-
65
- const previewId = `${triggerId.current}preview`
66
- const [portalHosts, setPortalHosts] = useState<{
67
- trigger: GridLayout
68
- preview: GridLayout
69
- } | null>(null)
70
-
71
- useEffect(() => {
72
- const trigger = new GridLayout()
73
- const preview = new GridLayout()
74
- registerHosts(triggerId.current, trigger, previewId, preview)
75
- setPortalHosts({ trigger, preview })
76
-
77
- return () => {
78
- unregisterSwiftUIHost(triggerId.current)
79
- unregisterSwiftUIHost(previewId)
80
- }
81
- }, [])
82
-
83
- const items = props.items ?? []
84
-
85
- <>
86
- <xplatioscontextmenu
87
- id={props.id}
88
- className={props.className}
89
- style={props.style}
90
- accessibilityLabel={props.accessibilityLabel}
91
- swiftId="xplat-swiftui-contextmenu"
92
- data={{
93
- triggerId: portalHosts ? triggerId.current : '',
94
- previewId: portalHosts && props.preview ? previewId : '',
95
- items: items.map((item) => ({
96
- id: item.id,
97
- title: item.title,
98
- destructive: item.destructive ? 1 : 0,
99
- disabled: item.disabled ? 1 : 0,
100
- divider: item.divider ? 1 : 0,
101
- })),
102
- }}
103
- onSwiftUIEvent={(event: any) => {
104
- const item = event.data?.item
105
- if (typeof item === 'string' && item) {
106
- props.onItemSelected?.(item)
107
- }
108
- }}
109
- />
110
- {portalHosts && props.trigger
111
- ? createPortal(<TriggerRoot render={props.trigger} />, portalHosts.trigger)
112
- : null}
113
- {portalHosts && props.preview
114
- ? createPortal(<TriggerRoot render={props.preview} />, portalHosts.preview)
115
- : null}
116
- </>;
76
+ export function SwiftUIContextMenu(props: SwiftUIContextMenuProps): unknown @{
77
+ const triggerId = useRef<string>('')
78
+
79
+ if (!triggerId.current) {
80
+ triggerId.current = `ctxmenu${++seq}`
81
+ }
82
+
83
+ const previewId = `${triggerId.current}preview`
84
+ const [portalHosts, setPortalHosts] = useState<{
85
+ trigger: GridLayout
86
+ preview: GridLayout
87
+ } | null>(null)
88
+
89
+ useEffect(() => {
90
+ const trigger = new GridLayout()
91
+ const preview = new GridLayout()
92
+
93
+ registerHosts(triggerId.current, trigger, previewId, preview)
94
+ setPortalHosts({ trigger, preview })
95
+
96
+ return () => {
97
+ unregisterSwiftUIHost(triggerId.current)
98
+ unregisterSwiftUIHost(previewId)
99
+ }
100
+ }, [])
101
+
102
+ const items = props.items ?? []
103
+
104
+ <>
105
+ <xplatioscontextmenu
106
+ id={props.id}
107
+ className={props.className}
108
+ style={props.style}
109
+ accessibilityLabel={props.accessibilityLabel}
110
+ swiftId="xplat-swiftui-contextmenu"
111
+ data={{
112
+ triggerId: portalHosts ? triggerId.current : '',
113
+ previewId: portalHosts && props.preview ? previewId : '',
114
+ items: items.map((item) => ({
115
+ id: item.id,
116
+ title: item.title,
117
+ destructive: item.destructive ? 1 : 0,
118
+ disabled: item.disabled ? 1 : 0,
119
+ divider: item.divider ? 1 : 0,
120
+ })),
121
+ }}
122
+ onSwiftUIEvent={(event: any) => {
123
+ const item = event.data?.item
124
+
125
+ if (typeof item === 'string' && item) {
126
+ props.onItemSelected?.(item)
127
+ }
128
+ }}
129
+ />
130
+ {portalHosts && props.trigger
131
+ ? createPortal(<TriggerRoot render={props.trigger} />, portalHosts.trigger)
132
+ : null}
133
+ {portalHosts && props.preview
134
+ ? createPortal(<TriggerRoot render={props.preview} />, portalHosts.preview)
135
+ : null}
136
+ </>
117
137
  }
@@ -0,0 +1,2 @@
1
+ // Type contract only. The target build must select a platform implementation.
2
+ export declare const SwiftUIContextMenu: typeof import('./SwiftUIContextMenu.ios.tsrx').SwiftUIContextMenu
@@ -1,6 +1,6 @@
1
1
  export { MaterialContextMenu } from '../MaterialContextMenu.android.tsrx'
2
2
  export type {
3
- MaterialContextMenuActivation,
4
- MaterialContextMenuItem,
5
- MaterialContextMenuProps,
3
+ MaterialContextMenuActivation,
4
+ MaterialContextMenuItem,
5
+ MaterialContextMenuProps,
6
6
  } from './types'
@@ -1,26 +1,37 @@
1
+ /** How the menu opens on Android. */
1
2
  export type MaterialContextMenuActivation = 'longPress' | 'singlePress'
2
3
 
3
4
  /** One row of serialized menu content carried over the bridge. */
4
5
  export interface MaterialContextMenuItem {
5
- /** Stable id reported to `onItemSelected`. */
6
- id: string
7
- title: string
8
- destructive?: boolean
9
- disabled?: boolean
10
- /** Render a divider before this item. */
11
- divider?: boolean
6
+ /** Stable id reported to `onItemSelected`. */
7
+ id: string
8
+ /** Item display text. */
9
+ title: string
10
+ /** Marks the action destructive (red styling where supported). */
11
+ destructive?: boolean
12
+ /** Greys the item; not selectable. */
13
+ disabled?: boolean
14
+ /** Render a divider before this item. */
15
+ divider?: boolean
12
16
  }
13
17
 
18
+ /** Android context-menu props. */
14
19
  export interface MaterialContextMenuProps {
15
- id?: string
16
- className?: any
17
- style?: any
18
- /** Activation gesture. @default 'longPress' */
19
- activation?: MaterialContextMenuActivation
20
- items?: readonly MaterialContextMenuItem[]
21
- /** Render fn producing the trigger subtree — portaled from the declaring
22
- * Octane tree into the menu's AndroidView anchor. */
23
- trigger: () => any
24
- onItemSelected?: (id: string) => void
25
- accessibilityLabel?: string
20
+ /** Element id passed through to the host element. */
21
+ id?: string
22
+ /** Class list applied to the element. */
23
+ className?: any
24
+ /** Inline style (string CSS or object). */
25
+ style?: any
26
+ /** Activation gesture. @default 'longPress' */
27
+ activation?: MaterialContextMenuActivation
28
+ /** Menu entries in display order. */
29
+ items?: readonly MaterialContextMenuItem[]
30
+ /** Render fn producing the trigger subtree — portaled from the declaring
31
+ * Octane tree into the menu's AndroidView anchor. */
32
+ trigger: () => any
33
+ /** Fires with the selected item id. */
34
+ onItemSelected?: (id: string) => void
35
+ /** Spoken name for assistive tech. */
36
+ accessibilityLabel?: string
26
37
  }
@@ -0,0 +1,213 @@
1
+ import type { AppKitContextMenuItem, AppKitContextMenuProps } from './macos/types'
2
+
3
+ export type ContextMenuAttach = (
4
+ view: object,
5
+ options: { items: readonly AppKitContextMenuItem[] },
6
+ onSelect: (id: string | undefined) => void,
7
+ ) => (() => void) | null
8
+
9
+ export type ContextMenuStatus = 'ready' | 'empty' | 'invalid' | 'unavailable'
10
+
11
+ /** Copy primitive content so in-place item changes cannot rewrite an old menu. */
12
+ function menuSnapshot(
13
+ items: readonly AppKitContextMenuItem[] = [],
14
+ ): AppKitContextMenuItem[] | null {
15
+ const ids = new Set<string>()
16
+
17
+ try {
18
+ return items.map((item) => {
19
+ if (typeof item.id !== 'string' || typeof item.title !== 'string' || ids.has(item.id)) {
20
+ throw Error('invalid menu')
21
+ }
22
+
23
+ ids.add(item.id)
24
+ return {
25
+ id: item.id,
26
+ title: item.title,
27
+ disabled: !!item.disabled,
28
+ divider: !!item.divider,
29
+ destructive: !!item.destructive,
30
+ }
31
+ })
32
+ } catch {
33
+ return null
34
+ }
35
+ }
36
+
37
+ const sameMenuItems = (a: readonly AppKitContextMenuItem[], b: readonly AppKitContextMenuItem[]) =>
38
+ a.length === b.length &&
39
+ a.every((item, i) => {
40
+ const other = b[i]
41
+
42
+ return (
43
+ item.id === other.id &&
44
+ item.title === other.title &&
45
+ item.disabled === other.disabled &&
46
+ item.divider === other.divider &&
47
+ item.destructive === other.destructive
48
+ )
49
+ })
50
+
51
+ /** Current native menu session; callback-only renders preserve its tracking menu. */
52
+ export function createContextMenuOwner(deps: {
53
+ props(): AppKitContextMenuProps
54
+ attach(): ContextMenuAttach | undefined
55
+ status?(status: ContextMenuStatus): void
56
+ }): {
57
+ update: () => void
58
+ bind(next: object | null): void
59
+ dispose(): void
60
+ getStatus: () => ContextMenuStatus
61
+ } {
62
+ type Session = {
63
+ view: object
64
+ scope: string | undefined
65
+ items: AppKitContextMenuItem[]
66
+ ready: boolean
67
+ selecting: boolean
68
+ detach?: () => void
69
+ }
70
+
71
+ let view: object | null = null,
72
+ session: Session | null = null,
73
+ disposed = false
74
+
75
+ let status: ContextMenuStatus = 'empty'
76
+ const report = (next: ContextMenuStatus) => {
77
+ if (!disposed && next !== status) {
78
+ status = next
79
+ deps.status?.(next)
80
+ }
81
+ }
82
+
83
+ const detach = () => {
84
+ const old = session
85
+
86
+ session = null
87
+ try {
88
+ old?.detach?.()
89
+ } catch {}
90
+ }
91
+
92
+ const update = () => {
93
+ if (disposed || !view) {
94
+ return
95
+ }
96
+
97
+ const props = deps.props(),
98
+ items = menuSnapshot(props.items)
99
+
100
+ if (!items) {
101
+ detach()
102
+ report('invalid')
103
+ return
104
+ }
105
+
106
+ if (!items.length) {
107
+ detach()
108
+ report('empty')
109
+ return
110
+ }
111
+
112
+ if (
113
+ session &&
114
+ session.view === view &&
115
+ session.scope === props.id &&
116
+ sameMenuItems(session.items, items)
117
+ ) {
118
+ return
119
+ }
120
+
121
+ detach()
122
+
123
+ const attach = deps.attach()
124
+
125
+ if (!attach) {
126
+ report('unavailable')
127
+ return
128
+ }
129
+
130
+ const owner: Session = { view, scope: props.id, items, ready: false, selecting: false }
131
+
132
+ session = owner
133
+ try {
134
+ const cleanup = attach(view, { items }, (id) => {
135
+ if (
136
+ disposed ||
137
+ session !== owner ||
138
+ !owner.ready ||
139
+ owner.selecting ||
140
+ typeof id !== 'string'
141
+ ) {
142
+ return
143
+ }
144
+
145
+ const current = deps.props(),
146
+ currentItems = menuSnapshot(current.items)
147
+
148
+ if (
149
+ !currentItems ||
150
+ current.id !== owner.scope ||
151
+ !sameMenuItems(owner.items, currentItems)
152
+ ) {
153
+ update()
154
+ return
155
+ }
156
+
157
+ const item = currentItems.find((item) => item.id === id)
158
+
159
+ if (!item || item.disabled) {
160
+ return
161
+ }
162
+
163
+ owner.selecting = true
164
+ try {
165
+ current.onItemSelected?.(id)
166
+ } finally {
167
+ owner.selecting = false
168
+ }
169
+ })
170
+
171
+ if (disposed || session !== owner) {
172
+ cleanup?.()
173
+ return
174
+ }
175
+
176
+ if (typeof cleanup !== 'function') {
177
+ session = null
178
+ report('unavailable')
179
+ return
180
+ }
181
+
182
+ owner.detach = cleanup
183
+ owner.ready = true
184
+ report('ready')
185
+ } catch {
186
+ if (session === owner) {
187
+ detach()
188
+ report('unavailable')
189
+ }
190
+ }
191
+ }
192
+
193
+ return {
194
+ update,
195
+ bind(next: object | null) {
196
+ if (!disposed && next !== view) {
197
+ detach()
198
+ view = next
199
+ if (view) {
200
+ update()
201
+ }
202
+ }
203
+ },
204
+ dispose() {
205
+ if (!disposed) {
206
+ disposed = true
207
+ detach()
208
+ view = null
209
+ }
210
+ },
211
+ getStatus: () => status,
212
+ }
213
+ }
package/src/ios/types.ts CHANGED
@@ -1,25 +1,34 @@
1
1
  /** One row of serialized menu content carried over the bridge. */
2
2
  export interface SwiftUIContextMenuItem {
3
- /** Stable id reported to `onItemSelected`. */
4
- id: string
5
- title: string
6
- /** Renders the item with .destructive role. */
7
- destructive?: boolean
8
- disabled?: boolean
9
- /** Render a divider before this item. */
10
- divider?: boolean
3
+ /** Stable id reported to `onItemSelected`. */
4
+ id: string
5
+ /** Item display text. */
6
+ title: string
7
+ /** Renders the item with .destructive role. */
8
+ destructive?: boolean
9
+ /** Greys the item; not selectable. */
10
+ disabled?: boolean
11
+ /** Render a divider before this item. */
12
+ divider?: boolean
11
13
  }
12
14
 
15
+ /** iOS context-menu props (SwiftUI contextMenu). */
13
16
  export interface SwiftUIContextMenuProps {
14
- id?: string
15
- className?: any
16
- style?: any
17
- items?: readonly SwiftUIContextMenuItem[]
18
- /** Render fn producing the activation element — hosted inside the
19
- * SwiftUI tree via the plugin's NativeScriptView-by-id factory. */
20
- trigger: () => any
21
- /** Optional preview shown while the menu opens (iOS 16+). */
22
- preview?: () => any
23
- onItemSelected?: (id: string) => void
24
- accessibilityLabel?: string
17
+ /** Element id passed through to the host element. */
18
+ id?: string
19
+ /** Class list applied to the element. */
20
+ className?: any
21
+ /** Inline style (string CSS or object). */
22
+ style?: any
23
+ /** Menu entries in display order. */
24
+ items?: readonly SwiftUIContextMenuItem[]
25
+ /** Render fn producing the activation element — hosted inside the
26
+ * SwiftUI tree via the plugin's NativeScriptView-by-id factory. */
27
+ trigger: () => any
28
+ /** Optional preview shown while the menu opens (iOS 16+). */
29
+ preview?: () => any
30
+ /** Fires with the selected item id. */
31
+ onItemSelected?: (id: string) => void
32
+ /** Spoken name for assistive tech. */
33
+ accessibilityLabel?: string
25
34
  }
@@ -1,24 +1,33 @@
1
1
  /** One row of serialized menu content carried over the bridge. */
2
2
  export interface AppKitContextMenuItem {
3
- /** Stable id reported to `onItemSelected`. */
4
- id: string
5
- title: string
6
- /** No AppKit destructive role — kept in the contract for parity; the
7
- * item renders as a normal menu row. */
8
- destructive?: boolean
9
- disabled?: boolean
10
- /** Render a divider before this item. */
11
- divider?: boolean
3
+ /** Stable id reported to `onItemSelected`; unique within this menu. */
4
+ id: string
5
+ /** Item display text. */
6
+ title: string
7
+ /** No AppKit destructive role — kept in the contract for parity; the
8
+ * item renders as a normal menu row. */
9
+ destructive?: boolean
10
+ /** Greys the item; not selectable. */
11
+ disabled?: boolean
12
+ /** Render a divider before this item. */
13
+ divider?: boolean
12
14
  }
13
15
 
16
+ /** macOS context-menu props (NSMenu). */
14
17
  export interface AppKitContextMenuProps {
15
- id?: string
16
- className?: any
17
- style?: any
18
- items?: readonly AppKitContextMenuItem[]
19
- /** Render fn producing the trigger element — rendered inline; the NSMenu
20
- * attaches to the host's backing NSView. */
21
- trigger: () => any
22
- onItemSelected?: (id: string) => void
23
- accessibilityLabel?: string
18
+ /** Native view identifier. Changing it retires this record's menu session. */
19
+ id?: string
20
+ /** Class list applied to the element. */
21
+ className?: any
22
+ /** Inline style (string CSS or object). */
23
+ style?: any
24
+ /** Menu entries in display order. */
25
+ items?: readonly AppKitContextMenuItem[]
26
+ /** Render fn producing the trigger element — rendered inline; the NSMenu
27
+ * attaches to the host's backing NSView. */
28
+ trigger: () => any
29
+ /** Current enabled item selections; retired/replaced menu actions are ignored. */
30
+ onItemSelected?: (id: string) => void
31
+ /** Spoken name for assistive tech. */
32
+ accessibilityLabel?: string
24
33
  }
package/src/web/types.ts CHANGED
@@ -1,21 +1,36 @@
1
+ /** How the menu opens (right-click/long-press variants). */
1
2
  export type ContextMenuActivation = 'longPress' | 'singlePress'
2
3
 
4
+ /** One menu entry or separator. */
3
5
  export interface ContextMenuItem {
4
- id: string
5
- title: string
6
- destructive?: boolean
7
- disabled?: boolean
8
- divider?: boolean
6
+ /** Element id passed through to the host element. */
7
+ id: string
8
+ /** Item display text. */
9
+ title: string
10
+ /** Marks the action destructive (red styling where supported). */
11
+ destructive?: boolean
12
+ /** Greys the item; not selectable. */
13
+ disabled?: boolean
14
+ /** Render as a separator instead of an item. */
15
+ divider?: boolean
9
16
  }
10
17
 
18
+ /** Web context-menu props (composed web menu). */
11
19
  export interface ContextMenuProps {
12
- id?: string
13
- className?: any
14
- style?: any
15
- /** 'longPress' maps to right-click (contextmenu); 'singlePress' to click. */
16
- activation?: ContextMenuActivation
17
- items?: readonly ContextMenuItem[]
18
- trigger: () => any
19
- onItemSelected?: (id: string) => void
20
- accessibilityLabel?: string
20
+ /** Element id passed through to the host element. */
21
+ id?: string
22
+ /** Class list applied to the element. */
23
+ className?: any
24
+ /** Inline style (string CSS or object). */
25
+ style?: any
26
+ /** 'longPress' maps to right-click (contextmenu); 'singlePress' to click. */
27
+ activation?: ContextMenuActivation
28
+ /** Menu entries in display order. */
29
+ items?: readonly ContextMenuItem[]
30
+ /** Content that hosts the context menu (long-press/right-click). */
31
+ trigger: () => any
32
+ /** Fires with the selected item id. */
33
+ onItemSelected?: (id: string) => void
34
+ /** Spoken name for assistive tech. */
35
+ accessibilityLabel?: string
21
36
  }