@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.
- package/README.md +2 -124
- package/package.json +92 -86
- package/src/AppKitContextMenu.macos.css +1 -0
- package/src/AppKitContextMenu.macos.tsrx +41 -21
- package/src/AppKitContextMenu.tsrx +2 -0
- package/src/ContextMenu.tsrx +2 -0
- package/src/ContextMenu.web.tsrx +168 -149
- package/src/MaterialContextMenu.android.tsrx +128 -101
- package/src/MaterialContextMenu.tsrx +2 -0
- package/src/SwiftUIContextMenu.ios.tsrx +104 -84
- package/src/SwiftUIContextMenu.tsrx +2 -0
- package/src/android/index.ts +3 -3
- package/src/android/types.ts +29 -18
- package/src/context-menu-owner.macos.ts +213 -0
- package/src/ios/types.ts +28 -19
- package/src/macos/types.ts +27 -18
- package/src/web/types.ts +29 -14
- package/types/generated/.tsrx-typegen-manifest.json +19 -0
- package/types/generated/AppKitContextMenu.macos.d.ts +8 -0
- package/types/generated/ContextMenu.web.d.ts +7 -0
- package/types/generated/MaterialContextMenu.android.d.ts +16 -0
- package/types/generated/SwiftUIContextMenu.ios.d.ts +17 -0
- package/types/generated/android/index.d.ts +2 -0
- package/types/generated/android/types.d.ts +35 -0
- package/types/generated/context-menu-owner.macos.d.ts +16 -0
- package/types/generated/index.d.ts +1 -0
- package/types/generated/ios/index.d.ts +2 -0
- package/types/generated/ios/types.d.ts +33 -0
- package/types/generated/macos/index.d.ts +2 -0
- package/types/generated/macos/types.d.ts +32 -0
- package/types/generated/web/index.d.ts +2 -0
- package/types/generated/web/types.d.ts +34 -0
- package/LICENSE +0 -21
- package/types/android/index.d.ts +0 -22
- package/types/index.d.ts +0 -1
- package/types/ios/index.d.ts +0 -20
- package/types/macos/index.d.ts +0 -19
- package/types/web/index.d.ts +0 -22
package/src/ContextMenu.web.tsrx
CHANGED
|
@@ -1,157 +1,176 @@
|
|
|
1
|
-
/** @jsxImportSource octane */
|
|
1
|
+
/** @jsxImportSource @octane-xplat/jsx/dom */
|
|
2
|
+
import type { JSX } from 'octane/jsx-runtime'
|
|
2
3
|
import { Fragment, useLayoutEffect, useRef, useState } from 'octane'
|
|
3
4
|
import type { ContextMenuProps } from './web/types'
|
|
4
5
|
|
|
5
6
|
/** Web context menu: the trigger subtree renders inline; right-click (or
|
|
6
7
|
* long-press via the `activation` prop's 'singlePress' = click) opens an
|
|
7
8
|
* in-page menu at the pointer. */
|
|
8
|
-
export function ContextMenu(props: ContextMenuProps) @{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
9
|
+
export function ContextMenu(props: ContextMenuProps): JSX.Element @{
|
|
10
|
+
const [menu, setMenu] = useState<{ x: number; y: number } | null>(null)
|
|
11
|
+
const [active, setActive] = useState(0)
|
|
12
|
+
const listRef = useRef<HTMLUListElement | null>(null)
|
|
13
|
+
const items = props.items ?? []
|
|
14
|
+
const enabled = items
|
|
15
|
+
.map((item, index) => (item.disabled ? -1 : index))
|
|
16
|
+
.filter((index) => index >= 0)
|
|
17
|
+
|
|
18
|
+
const openAt = (e: any) => {
|
|
19
|
+
e.preventDefault?.()
|
|
20
|
+
setActive(enabled[0] ?? 0)
|
|
21
|
+
setMenu({ x: e.clientX ?? 0, y: e.clientY ?? 0 })
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const choose = (index: number) => {
|
|
25
|
+
const item = items[index]
|
|
26
|
+
|
|
27
|
+
if (!item || item.disabled) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setMenu(null)
|
|
32
|
+
props.onItemSelected?.(item.id)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Once the menu is mounted: clamp it into the viewport so every item
|
|
36
|
+
// stays reachable, then focus it so the keyboard contract works.
|
|
37
|
+
useLayoutEffect(() => {
|
|
38
|
+
const el = listRef.current
|
|
39
|
+
|
|
40
|
+
if (!menu || !el) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const x = Math.max(0, Math.min(menu.x, window.innerWidth - el.offsetWidth - 8))
|
|
45
|
+
const y = Math.max(0, Math.min(menu.y, window.innerHeight - el.offsetHeight - 8))
|
|
46
|
+
|
|
47
|
+
if (x !== menu.x || y !== menu.y) {
|
|
48
|
+
setMenu({ x, y })
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
el.focus()
|
|
53
|
+
}, [menu])
|
|
54
|
+
|
|
55
|
+
const onMenuKeyDown = (e: any) => {
|
|
56
|
+
if (e.key === 'Escape') {
|
|
57
|
+
e.preventDefault?.()
|
|
58
|
+
e.stopPropagation?.()
|
|
59
|
+
setMenu(null)
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!enabled.length) {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const at = Math.max(0, enabled.indexOf(active))
|
|
68
|
+
|
|
69
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
70
|
+
e.preventDefault?.()
|
|
71
|
+
|
|
72
|
+
const step = e.key === 'ArrowDown' ? 1 : -1
|
|
73
|
+
|
|
74
|
+
setActive(enabled[(at + step + enabled.length) % enabled.length])
|
|
75
|
+
} else if (e.key === 'Home') {
|
|
76
|
+
e.preventDefault?.()
|
|
77
|
+
setActive(enabled[0])
|
|
78
|
+
} else if (e.key === 'End') {
|
|
79
|
+
e.preventDefault?.()
|
|
80
|
+
setActive(enabled[enabled.length - 1])
|
|
81
|
+
} else if (e.key === 'Enter' || e.key === ' ') {
|
|
82
|
+
e.preventDefault?.()
|
|
83
|
+
choose(active)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
<span
|
|
88
|
+
id={props.id}
|
|
89
|
+
className={props.className}
|
|
90
|
+
style={{ display: 'inline-block', ...props.style }}
|
|
91
|
+
onContextMenu={props.activation === 'singlePress' ? undefined : openAt}
|
|
92
|
+
onClick={props.activation === 'singlePress' ? openAt : undefined}
|
|
93
|
+
aria-label={props.accessibilityLabel}
|
|
94
|
+
>
|
|
95
|
+
{props.trigger()}
|
|
96
|
+
{menu && (
|
|
97
|
+
<>
|
|
98
|
+
{/* Events from the backdrop and the menu must not bubble to the
|
|
83
99
|
opener handlers — dismissal stays final. */}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
100
|
+
<span
|
|
101
|
+
style={{ position: 'fixed', inset: 0, zIndex: 999 }}
|
|
102
|
+
onClick={(e: any) => {
|
|
103
|
+
e.stopPropagation?.()
|
|
104
|
+
setMenu(null)
|
|
105
|
+
}}
|
|
106
|
+
onContextMenu={(e: any) => {
|
|
107
|
+
e.preventDefault?.()
|
|
108
|
+
e.stopPropagation?.()
|
|
109
|
+
setMenu(null)
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
<ul
|
|
113
|
+
role="menu"
|
|
114
|
+
tabIndex={-1}
|
|
115
|
+
ref={(el: any) => {
|
|
116
|
+
listRef.current = el
|
|
117
|
+
}}
|
|
118
|
+
onClick={(e: any) => e.stopPropagation?.()}
|
|
119
|
+
onContextMenu={(e: any) => {
|
|
120
|
+
e.preventDefault?.()
|
|
121
|
+
e.stopPropagation?.()
|
|
122
|
+
}}
|
|
123
|
+
onKeyDown={onMenuKeyDown}
|
|
124
|
+
style={{
|
|
125
|
+
position: 'fixed',
|
|
126
|
+
left: menu.x,
|
|
127
|
+
top: menu.y,
|
|
128
|
+
zIndex: 1000,
|
|
129
|
+
margin: 0,
|
|
130
|
+
padding: '4px 0',
|
|
131
|
+
listStyle: 'none',
|
|
132
|
+
background: 'var(--menu-bg, Canvas)',
|
|
133
|
+
color: 'var(--menu-fg, CanvasText)',
|
|
134
|
+
border: '1px solid color-mix(in srgb, CanvasText 20%, transparent)',
|
|
135
|
+
borderRadius: 8,
|
|
136
|
+
boxShadow: '0 6px 24px rgb(0 0 0 / 0.18)',
|
|
137
|
+
minWidth: 160,
|
|
138
|
+
outline: 'none',
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
{items.map((item, index) => (
|
|
142
|
+
<Fragment key={item.id}>
|
|
143
|
+
{item.divider && (
|
|
144
|
+
<li
|
|
145
|
+
aria-hidden="true"
|
|
146
|
+
style={{
|
|
147
|
+
borderTop: '1px solid color-mix(in srgb, CanvasText 15%, transparent)',
|
|
148
|
+
margin: '4px 0',
|
|
149
|
+
}}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
<li
|
|
153
|
+
role="menuitem"
|
|
154
|
+
aria-disabled={item.disabled || undefined}
|
|
155
|
+
aria-current={index === active || undefined}
|
|
156
|
+
style={{
|
|
157
|
+
padding: '6px 12px',
|
|
158
|
+
cursor: item.disabled ? 'default' : 'pointer',
|
|
159
|
+
opacity: item.disabled ? 0.5 : 1,
|
|
160
|
+
color: item.destructive ? 'crimson' : undefined,
|
|
161
|
+
background:
|
|
162
|
+
index === active
|
|
163
|
+
? 'color-mix(in srgb, CanvasText 10%, transparent)'
|
|
164
|
+
: undefined,
|
|
165
|
+
}}
|
|
166
|
+
onClick={() => choose(index)}
|
|
167
|
+
>
|
|
168
|
+
{item.title}
|
|
169
|
+
</li>
|
|
170
|
+
</Fragment>
|
|
171
|
+
))}
|
|
172
|
+
</ul>
|
|
173
|
+
</>
|
|
174
|
+
)}
|
|
175
|
+
</span>
|
|
157
176
|
}
|
|
@@ -1,23 +1,41 @@
|
|
|
1
|
-
/** @jsxImportSource @
|
|
1
|
+
/** @jsxImportSource @octane-xplat/jsx */
|
|
2
2
|
import { registerElement } from '@nativescript-community/octane'
|
|
3
|
-
import type { Attributes } from '@
|
|
4
|
-
import {
|
|
3
|
+
import type { Attributes } from '@octane-xplat/jsx/intrinsics'
|
|
4
|
+
import {
|
|
5
|
+
ComposeDataDriver,
|
|
6
|
+
JetpackCompose,
|
|
7
|
+
registerJetpackCompose,
|
|
8
|
+
} from '@nativescript/jetpack-compose'
|
|
9
|
+
|
|
5
10
|
import { Application, GridLayout } from '@nativescript/core'
|
|
6
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
createPortal as createUniversalPortal,
|
|
13
|
+
type UniversalRenderable,
|
|
14
|
+
} from 'octane/universal/native'
|
|
15
|
+
|
|
7
16
|
import { useEffect, useRef, useState } from 'octane'
|
|
8
17
|
import type { MaterialContextMenuProps } from './android/types'
|
|
9
18
|
|
|
10
19
|
declare const com: any
|
|
11
20
|
|
|
12
|
-
declare module '@
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
declare module '@octane-xplat/jsx/intrinsics' {
|
|
22
|
+
interface NativeElements<TElement> {
|
|
23
|
+
xplatandroidcontextmenu: Attributes<
|
|
24
|
+
TElement,
|
|
25
|
+
{
|
|
26
|
+
composeId?: string
|
|
27
|
+
data?: Record<string, unknown>
|
|
28
|
+
onComposeEvent?: (event: { data?: unknown }) => void
|
|
29
|
+
}
|
|
30
|
+
>
|
|
31
|
+
}
|
|
16
32
|
}
|
|
17
33
|
|
|
18
34
|
registerElement('xplatandroidcontextmenu', JetpackCompose)
|
|
19
|
-
registerJetpackCompose(
|
|
20
|
-
|
|
35
|
+
registerJetpackCompose(
|
|
36
|
+
'xplat-material-contextmenu',
|
|
37
|
+
(owner: any) =>
|
|
38
|
+
new ComposeDataDriver(new com.octanexplat.contextmenu.XplatContextMenuProvider(), owner),
|
|
21
39
|
)
|
|
22
40
|
|
|
23
41
|
// Dash-free ids — the host-side representable appends "-<uuid>" and the
|
|
@@ -25,102 +43,111 @@ registerJetpackCompose('xplat-material-contextmenu', (owner: any) =>
|
|
|
25
43
|
let seq = 0
|
|
26
44
|
|
|
27
45
|
function TriggerRoot(props: { render: () => any }) @{
|
|
28
|
-
|
|
46
|
+
<>{props.render()}</>
|
|
29
47
|
}
|
|
30
48
|
|
|
31
49
|
function createPortal(children: unknown, target: unknown) {
|
|
32
|
-
|
|
50
|
+
return createUniversalPortal(children as UniversalRenderable, target)
|
|
33
51
|
}
|
|
34
52
|
|
|
35
53
|
/** Renders a Material 3 DropdownMenu anchored to a NativeScript-hosted
|
|
36
54
|
* trigger subtree portaled from the declaring Octane tree. */
|
|
37
|
-
export function MaterialContextMenu(props: MaterialContextMenuProps) @{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
55
|
+
export function MaterialContextMenu(props: MaterialContextMenuProps): unknown @{
|
|
56
|
+
const triggerId = useRef<string>('')
|
|
57
|
+
|
|
58
|
+
if (!triggerId.current) {
|
|
59
|
+
triggerId.current = `ctxmenu${++seq}`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const mounted = useRef<{ host: any } | null>(null)
|
|
63
|
+
const [portalHost, setPortalHost] = useState<GridLayout | null>(null)
|
|
64
|
+
const [expanded, setExpanded] = useState(false)
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const host = new GridLayout()
|
|
68
|
+
// Detached subtree — the plugin's generateNativeView shortcut passes
|
|
69
|
+
// `{}` as the native context, which fails to marshal on Android; the
|
|
70
|
+
// view factory needs a real android.content.Context to build its
|
|
71
|
+
// native view.
|
|
72
|
+
|
|
73
|
+
const context =
|
|
74
|
+
(Application.android as any).foregroundActivity ?? (Application.android as any).startActivity
|
|
75
|
+
|
|
76
|
+
const nativeHost = host as any
|
|
77
|
+
|
|
78
|
+
nativeHost._setupAsRootView(context)
|
|
79
|
+
nativeHost.callLoaded()
|
|
80
|
+
com.octanexplat.contextmenu.XplatViewRegistry.register(triggerId.current, host.android)
|
|
81
|
+
mounted.current = { host }
|
|
82
|
+
|
|
83
|
+
// Gate triggerId on registration — the provider only composes the
|
|
84
|
+
// AndroidView host once triggerId is non-empty, so the factory must
|
|
85
|
+
// find the view in the registry on first read.
|
|
86
|
+
setPortalHost(host)
|
|
87
|
+
|
|
88
|
+
return () => {
|
|
89
|
+
com.octanexplat.contextmenu.XplatViewRegistry.unregister(triggerId.current)
|
|
90
|
+
mounted.current = null
|
|
91
|
+
nativeHost.callUnloaded?.()
|
|
92
|
+
nativeHost.removeChildren?.()
|
|
93
|
+
}
|
|
94
|
+
}, [])
|
|
95
|
+
|
|
96
|
+
// Activation is an NS gesture on the trigger host — the hosted subtree
|
|
97
|
+
// consumes pointer input before Compose's gesture detectors could resolve
|
|
98
|
+
// it, so expanded is pushed through data instead. Rebind when the
|
|
99
|
+
// activation prop or the mounted host changes.
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const host = mounted.current?.host
|
|
102
|
+
|
|
103
|
+
if (!portalHost || !host) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const open = () => setExpanded(true)
|
|
108
|
+
const event = (props.activation ?? 'longPress') === 'singlePress' ? 'tap' : 'longPress'
|
|
109
|
+
|
|
110
|
+
host.on(event, open)
|
|
111
|
+
return () => host.off(event, open)
|
|
112
|
+
}, [portalHost, props.activation])
|
|
113
|
+
|
|
114
|
+
const items = props.items ?? []
|
|
115
|
+
|
|
116
|
+
<>
|
|
117
|
+
<xplatandroidcontextmenu
|
|
118
|
+
id={props.id}
|
|
119
|
+
className={props.className}
|
|
120
|
+
style={props.style}
|
|
121
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
122
|
+
composeId="xplat-material-contextmenu"
|
|
123
|
+
data={{
|
|
124
|
+
triggerId: portalHost ? triggerId.current : '',
|
|
125
|
+
expanded: expanded ? 1 : 0,
|
|
126
|
+
items: items.map((item) => ({
|
|
127
|
+
id: item.id,
|
|
128
|
+
title: item.title,
|
|
129
|
+
// The bridge's dataSerialize throws on booleans; send numbers.
|
|
130
|
+
destructive: item.destructive ? 1 : 0,
|
|
131
|
+
disabled: item.disabled ? 1 : 0,
|
|
132
|
+
divider: item.divider ? 1 : 0,
|
|
133
|
+
})),
|
|
134
|
+
}}
|
|
135
|
+
onComposeEvent={(event: any) => {
|
|
136
|
+
if (event.data?.dismissed) {
|
|
137
|
+
setExpanded(false)
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const item = event.data?.item
|
|
142
|
+
|
|
143
|
+
if (typeof item === 'string' && item) {
|
|
144
|
+
setExpanded(false)
|
|
145
|
+
props.onItemSelected?.(item)
|
|
146
|
+
}
|
|
147
|
+
}}
|
|
148
|
+
/>
|
|
149
|
+
{portalHost && props.trigger
|
|
150
|
+
? createPortal(<TriggerRoot render={props.trigger} />, portalHost)
|
|
151
|
+
: null}
|
|
152
|
+
</>
|
|
126
153
|
}
|