@hanzogui/context-menu 3.0.2 → 7.3.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/dist/cjs/ContextMenu.cjs +142 -139
- package/dist/cjs/ContextMenu.native.js +172 -170
- package/dist/cjs/ContextMenu.native.js.map +1 -1
- package/dist/cjs/createNonNativeContextMenu.cjs +370 -344
- package/dist/cjs/createNonNativeContextMenu.native.js +391 -364
- package/dist/cjs/createNonNativeContextMenu.native.js.map +1 -1
- package/dist/cjs/index.cjs +24 -22
- package/dist/cjs/index.native.js +26 -24
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/ContextMenu.mjs +114 -113
- package/dist/esm/ContextMenu.mjs.map +1 -1
- package/dist/esm/ContextMenu.native.js +141 -141
- package/dist/esm/ContextMenu.native.js.map +1 -1
- package/dist/esm/createNonNativeContextMenu.mjs +340 -316
- package/dist/esm/createNonNativeContextMenu.mjs.map +1 -1
- package/dist/esm/createNonNativeContextMenu.native.js +361 -336
- package/dist/esm/createNonNativeContextMenu.native.js.map +1 -1
- package/dist/jsx/ContextMenu.mjs +114 -113
- package/dist/jsx/ContextMenu.mjs.map +1 -1
- package/dist/jsx/ContextMenu.native.js +172 -170
- package/dist/jsx/ContextMenu.native.js.map +1 -1
- package/dist/jsx/createNonNativeContextMenu.mjs +340 -316
- package/dist/jsx/createNonNativeContextMenu.mjs.map +1 -1
- package/dist/jsx/createNonNativeContextMenu.native.js +391 -364
- package/dist/jsx/createNonNativeContextMenu.native.js.map +1 -1
- package/dist/jsx/index.native.js +26 -24
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +14 -12
- package/types/ContextMenu.d.ts +59 -59
- package/types/ContextMenu.d.ts.map +1 -0
- package/types/createNonNativeContextMenu.d.ts +53 -53
- package/types/createNonNativeContextMenu.d.ts.map +1 -0
- package/types/index.d.ts +59 -59
- package/types/index.d.ts.map +1 -0
|
@@ -6,354 +6,378 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
const CONTEXTMENU_CONTEXT = "ContextMenuContext";
|
|
7
7
|
function createNonNativeContextMenu(params) {
|
|
8
8
|
const {
|
|
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
|
-
|
|
9
|
+
Menu
|
|
10
|
+
} = createBaseMenu(params);
|
|
11
|
+
const CONTEXT_MENU_NAME = "ContextMenu";
|
|
12
|
+
const {
|
|
13
|
+
Provider: ContextMenuProvider,
|
|
14
|
+
useStyledContext: useContextMenuContext
|
|
15
|
+
} = createStyledContext();
|
|
16
|
+
const ContextMenuComp = props => {
|
|
17
|
+
const {
|
|
18
|
+
scope,
|
|
19
|
+
children,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
dir,
|
|
22
|
+
modal = true,
|
|
23
|
+
...rest
|
|
24
|
+
} = props;
|
|
25
|
+
const [open, setOpen] = React.useState(false);
|
|
26
|
+
const triggerRef = React.useRef(null);
|
|
27
|
+
const handleOpenChange = React.useCallback((open2, event) => {
|
|
28
|
+
onOpenChange?.(open2, event);
|
|
29
|
+
if (event?.defaultPrevented) return;
|
|
30
|
+
setOpen(open2);
|
|
31
|
+
}, [onOpenChange]);
|
|
32
|
+
return /* @__PURE__ */jsx(ContextMenuProvider, {
|
|
33
|
+
scope,
|
|
34
|
+
triggerId: useId(),
|
|
35
|
+
triggerRef,
|
|
36
|
+
contentId: useId(),
|
|
37
|
+
open,
|
|
38
|
+
onOpenChange: handleOpenChange,
|
|
39
|
+
modal,
|
|
40
|
+
children: /* @__PURE__ */jsx(Menu, {
|
|
41
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
42
|
+
dir,
|
|
35
43
|
open,
|
|
36
44
|
onOpenChange: handleOpenChange,
|
|
37
45
|
modal,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
modal,
|
|
44
|
-
...rest,
|
|
45
|
-
children
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
};
|
|
46
|
+
...rest,
|
|
47
|
+
children
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
};
|
|
49
51
|
ContextMenuComp.displayName = CONTEXT_MENU_NAME;
|
|
50
|
-
const TRIGGER_NAME = "ContextMenuTrigger"
|
|
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
|
-
return {
|
|
79
|
-
width: 0,
|
|
80
|
-
height: 0,
|
|
81
|
-
top: 0,
|
|
82
|
-
left: 0,
|
|
83
|
-
...pointRef.current
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
...(!isWeb && {
|
|
87
|
-
measure: c => c(pointRef.current.x, pointRef.current.y, 0, 0),
|
|
88
|
-
measureInWindow: c => c(pointRef.current.x, pointRef.current.y, 0, 0)
|
|
89
|
-
})
|
|
52
|
+
const TRIGGER_NAME = "ContextMenuTrigger";
|
|
53
|
+
const ContextMenuTrigger = View.styleable((props, forwardedRef) => {
|
|
54
|
+
const {
|
|
55
|
+
scope,
|
|
56
|
+
style,
|
|
57
|
+
disabled = false,
|
|
58
|
+
asChild,
|
|
59
|
+
children,
|
|
60
|
+
...triggerProps
|
|
61
|
+
} = props;
|
|
62
|
+
const context = useContextMenuContext(scope);
|
|
63
|
+
const pointRef = React.useRef({
|
|
64
|
+
x: 0,
|
|
65
|
+
y: 0
|
|
66
|
+
});
|
|
67
|
+
const virtualRef = React.useMemo(() => ({
|
|
68
|
+
current: {
|
|
69
|
+
getBoundingClientRect: () => {
|
|
70
|
+
if (isWeb) {
|
|
71
|
+
const scrollX = window.scrollX || document.documentElement.scrollLeft;
|
|
72
|
+
const scrollY = window.scrollY || document.documentElement.scrollTop;
|
|
73
|
+
return DOMRect.fromRect({
|
|
74
|
+
width: 0,
|
|
75
|
+
height: 0,
|
|
76
|
+
x: pointRef.current.x - scrollX,
|
|
77
|
+
y: pointRef.current.y - scrollY
|
|
78
|
+
});
|
|
90
79
|
}
|
|
91
|
-
}), [pointRef.current.x, pointRef.current.y]),
|
|
92
|
-
longPressTimerRef = React.useRef(0),
|
|
93
|
-
clearLongPress = React.useCallback(() => window.clearTimeout(longPressTimerRef.current), []),
|
|
94
|
-
createOpenChangeEvent = () => {
|
|
95
|
-
let defaultPrevented = !1;
|
|
96
80
|
return {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0,
|
|
83
|
+
top: 0,
|
|
84
|
+
left: 0,
|
|
85
|
+
...pointRef.current
|
|
103
86
|
};
|
|
104
87
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
88
|
+
...(!isWeb && {
|
|
89
|
+
measure: c => c(pointRef.current.x, pointRef.current.y, 0, 0),
|
|
90
|
+
measureInWindow: c => c(pointRef.current.x, pointRef.current.y, 0, 0)
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
}), [pointRef.current.x, pointRef.current.y]);
|
|
94
|
+
const longPressTimerRef = React.useRef(0);
|
|
95
|
+
const clearLongPress = React.useCallback(() => window.clearTimeout(longPressTimerRef.current), []);
|
|
96
|
+
const createOpenChangeEvent = () => {
|
|
97
|
+
let defaultPrevented = false;
|
|
98
|
+
return {
|
|
99
|
+
get defaultPrevented() {
|
|
100
|
+
return defaultPrevented;
|
|
101
|
+
},
|
|
102
|
+
preventDefault() {
|
|
103
|
+
defaultPrevented = true;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const handleOpen = event => {
|
|
108
|
+
if (isWeb && (event instanceof MouseEvent || event instanceof PointerEvent)) {
|
|
109
|
+
pointRef.current = {
|
|
110
|
+
x: event.clientX,
|
|
111
|
+
y: event.clientY
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
pointRef.current = {
|
|
115
|
+
x: event.nativeEvent.pageX,
|
|
116
|
+
y: event.nativeEvent.pageY
|
|
115
117
|
};
|
|
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
|
-
event.pointerType !== "mouse" && clearLongPress();
|
|
148
|
-
}),
|
|
149
|
-
onPointerUp: disabled ? props.onPointerUp : composeEventHandlers(props.onPointerUp, event => {
|
|
150
|
-
event.pointerType !== "mouse" && clearLongPress();
|
|
151
|
-
})
|
|
118
|
+
}
|
|
119
|
+
const openChangeEvent = createOpenChangeEvent();
|
|
120
|
+
context.onOpenChange(true, openChangeEvent);
|
|
121
|
+
return openChangeEvent;
|
|
122
|
+
};
|
|
123
|
+
React.useEffect(() => clearLongPress, [clearLongPress]);
|
|
124
|
+
React.useEffect(() => void (disabled && clearLongPress()), [disabled, clearLongPress]);
|
|
125
|
+
const Comp = asChild ? Slot : View;
|
|
126
|
+
return /* @__PURE__ */jsxs(Fragment, {
|
|
127
|
+
children: [/* @__PURE__ */jsx(Menu.Anchor, {
|
|
128
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
129
|
+
virtualRef
|
|
130
|
+
}), /* @__PURE__ */jsx(Comp, {
|
|
131
|
+
render: "span",
|
|
132
|
+
componentName: TRIGGER_NAME,
|
|
133
|
+
id: context.triggerId,
|
|
134
|
+
"data-state": context.open ? "open" : "closed",
|
|
135
|
+
"data-disabled": disabled ? "" : void 0,
|
|
136
|
+
...triggerProps,
|
|
137
|
+
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
138
|
+
style: isWeb ? {
|
|
139
|
+
WebkitTouchCallout: "none",
|
|
140
|
+
...style
|
|
141
|
+
} : null,
|
|
142
|
+
...(isWeb && {
|
|
143
|
+
onContextMenu: disabled ? props.onContextMenu : composeEventHandlers(props.onContextMenu, event => {
|
|
144
|
+
clearLongPress();
|
|
145
|
+
const openChangeEvent = handleOpen(event);
|
|
146
|
+
if (!openChangeEvent.defaultPrevented) {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
}
|
|
152
149
|
}),
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
onPointerDown: disabled ? props.onPointerDown : composeEventHandlers(props.onPointerDown, event => {
|
|
151
|
+
if (event.pointerType === "mouse") return;
|
|
152
|
+
clearLongPress();
|
|
153
|
+
longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700);
|
|
157
154
|
}),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
onPointerMove: disabled ? props.onPointerMove : composeEventHandlers(props.onPointerMove, event => {
|
|
156
|
+
if (event.pointerType === "mouse") return;
|
|
157
|
+
clearLongPress();
|
|
158
|
+
}),
|
|
159
|
+
onPointerCancel: disabled ? props.onPointerCancel : composeEventHandlers(props.onPointerCancel, event => {
|
|
160
|
+
if (event.pointerType === "mouse") return;
|
|
161
|
+
clearLongPress();
|
|
162
|
+
}),
|
|
163
|
+
onPointerUp: disabled ? props.onPointerUp : composeEventHandlers(props.onPointerUp, event => {
|
|
164
|
+
if (event.pointerType === "mouse") return;
|
|
165
|
+
clearLongPress();
|
|
166
|
+
})
|
|
167
|
+
}),
|
|
168
|
+
...(!isWeb && {
|
|
169
|
+
onLongPress: disabled ? props.onLongPress : composeEventHandlers(props.onLongPress, event => {
|
|
170
|
+
clearLongPress();
|
|
171
|
+
const openChangeEvent = handleOpen(event);
|
|
172
|
+
if (!openChangeEvent.defaultPrevented) {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
}),
|
|
177
|
+
children
|
|
178
|
+
})]
|
|
161
179
|
});
|
|
180
|
+
});
|
|
162
181
|
ContextMenuTrigger.displayName = TRIGGER_NAME;
|
|
163
|
-
const PORTAL_NAME = "ContextMenuPortal"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
const PORTAL_NAME = "ContextMenuPortal";
|
|
183
|
+
const ContextMenuPortal = props => {
|
|
184
|
+
const {
|
|
185
|
+
scope,
|
|
186
|
+
children,
|
|
187
|
+
...portalProps
|
|
188
|
+
} = props;
|
|
189
|
+
const context = isAndroid ? useContextMenuContext(scope) : null;
|
|
190
|
+
const content = isAndroid ? /* @__PURE__ */jsx(ContextMenuProvider, {
|
|
191
|
+
...context,
|
|
192
|
+
children
|
|
193
|
+
}) : children;
|
|
194
|
+
return /* @__PURE__ */jsx(Menu.Portal, {
|
|
195
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
196
|
+
...portalProps,
|
|
197
|
+
children: content
|
|
198
|
+
});
|
|
199
|
+
};
|
|
181
200
|
ContextMenuPortal.displayName = PORTAL_NAME;
|
|
182
|
-
const CONTENT_NAME = "ContextMenuContent"
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
const CONTENT_NAME = "ContextMenuContent";
|
|
202
|
+
const ContextMenuContent = React.forwardRef((props, forwardedRef) => {
|
|
203
|
+
const {
|
|
204
|
+
scope,
|
|
205
|
+
...contentProps
|
|
206
|
+
} = props;
|
|
207
|
+
const context = useContextMenuContext(scope);
|
|
208
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
209
|
+
return /* @__PURE__ */jsx(Menu.Content, {
|
|
210
|
+
id: context.contentId,
|
|
211
|
+
"aria-labelledby": context.triggerId,
|
|
212
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
213
|
+
...contentProps,
|
|
214
|
+
ref: forwardedRef,
|
|
215
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, event => {
|
|
216
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
217
|
+
hasInteractedOutsideRef.current = false;
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
}),
|
|
220
|
+
onInteractOutside: composeEventHandlers(props.onInteractOutside, event => {
|
|
221
|
+
const originalEvent = event.detail.originalEvent;
|
|
222
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
223
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
224
|
+
if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
|
|
225
|
+
})
|
|
206
226
|
});
|
|
227
|
+
});
|
|
207
228
|
ContextMenuContent.displayName = CONTENT_NAME;
|
|
208
|
-
const ITEM_NAME = "ContextMenuItem"
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
});
|
|
229
|
+
const ITEM_NAME = "ContextMenuItem";
|
|
230
|
+
const ContextMenuItem = React.forwardRef((props, forwardedRef) => {
|
|
231
|
+
const {
|
|
232
|
+
scope,
|
|
233
|
+
...itemProps
|
|
234
|
+
} = props;
|
|
235
|
+
return /* @__PURE__ */jsx(Menu.Item, {
|
|
236
|
+
componentName: ITEM_NAME,
|
|
237
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
238
|
+
...itemProps,
|
|
239
|
+
ref: forwardedRef
|
|
220
240
|
});
|
|
241
|
+
});
|
|
221
242
|
ContextMenuItem.displayName = ITEM_NAME;
|
|
222
|
-
const CHECKBOX_ITEM_NAME = "ContextMenuCheckboxItem"
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
243
|
+
const CHECKBOX_ITEM_NAME = "ContextMenuCheckboxItem";
|
|
244
|
+
const ContextMenuCheckboxItem = React.forwardRef((props, forwardedRef) => {
|
|
245
|
+
const {
|
|
246
|
+
scope,
|
|
247
|
+
...checkboxItemProps
|
|
248
|
+
} = props;
|
|
249
|
+
return /* @__PURE__ */jsx(Menu.CheckboxItem, {
|
|
250
|
+
componentName: CHECKBOX_ITEM_NAME,
|
|
251
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
252
|
+
...checkboxItemProps,
|
|
253
|
+
ref: forwardedRef
|
|
234
254
|
});
|
|
255
|
+
});
|
|
235
256
|
ContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
|
|
236
|
-
const RADIO_GROUP_NAME = "ContextMenuRadioGroup"
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
257
|
+
const RADIO_GROUP_NAME = "ContextMenuRadioGroup";
|
|
258
|
+
const ContextMenuRadioGroup = React.forwardRef((props, forwardedRef) => {
|
|
259
|
+
const {
|
|
260
|
+
scope,
|
|
261
|
+
...radioGroupProps
|
|
262
|
+
} = props;
|
|
263
|
+
return /* @__PURE__ */jsx(Menu.RadioGroup, {
|
|
264
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
265
|
+
...radioGroupProps,
|
|
266
|
+
ref: forwardedRef
|
|
247
267
|
});
|
|
268
|
+
});
|
|
248
269
|
ContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
249
|
-
const RADIO_ITEM_NAME = "ContextMenuRadioItem"
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
270
|
+
const RADIO_ITEM_NAME = "ContextMenuRadioItem";
|
|
271
|
+
const ContextMenuRadioItem = React.forwardRef((props, forwardedRef) => {
|
|
272
|
+
const {
|
|
273
|
+
scope,
|
|
274
|
+
...radioItemProps
|
|
275
|
+
} = props;
|
|
276
|
+
return /* @__PURE__ */jsx(Menu.RadioItem, {
|
|
277
|
+
componentName: RADIO_ITEM_NAME,
|
|
278
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
279
|
+
...radioItemProps,
|
|
280
|
+
ref: forwardedRef
|
|
261
281
|
});
|
|
282
|
+
});
|
|
262
283
|
ContextMenuRadioItem.displayName = RADIO_ITEM_NAME;
|
|
263
|
-
const INDICATOR_NAME = "ContextMenuItemIndicator"
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
284
|
+
const INDICATOR_NAME = "ContextMenuItemIndicator";
|
|
285
|
+
const ContextMenuItemIndicator = Menu.ItemIndicator.styleable((props, forwardedRef) => {
|
|
286
|
+
const {
|
|
287
|
+
scope,
|
|
288
|
+
...itemIndicatorProps
|
|
289
|
+
} = props;
|
|
290
|
+
return /* @__PURE__ */jsx(Menu.ItemIndicator, {
|
|
291
|
+
componentName: INDICATOR_NAME,
|
|
292
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
293
|
+
...itemIndicatorProps,
|
|
294
|
+
ref: forwardedRef
|
|
275
295
|
});
|
|
296
|
+
});
|
|
276
297
|
ContextMenuItemIndicator.displayName = INDICATOR_NAME;
|
|
277
|
-
const SUB_NAME = "ContextMenuSub"
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
const SUB_NAME = "ContextMenuSub";
|
|
299
|
+
const ContextMenuSub = props => {
|
|
300
|
+
const {
|
|
301
|
+
scope,
|
|
302
|
+
children,
|
|
303
|
+
onOpenChange,
|
|
304
|
+
open: openProp,
|
|
305
|
+
defaultOpen,
|
|
306
|
+
...rest
|
|
307
|
+
} = props;
|
|
308
|
+
const [open, setOpen] = useControllableState({
|
|
309
|
+
prop: openProp,
|
|
310
|
+
defaultProp: defaultOpen,
|
|
311
|
+
onChange: onOpenChange
|
|
312
|
+
});
|
|
313
|
+
return /* @__PURE__ */jsx(Menu.Sub, {
|
|
314
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
315
|
+
open,
|
|
316
|
+
onOpenChange: setOpen,
|
|
317
|
+
...rest,
|
|
318
|
+
children
|
|
319
|
+
});
|
|
320
|
+
};
|
|
300
321
|
ContextMenuSub.displayName = SUB_NAME;
|
|
301
|
-
const SUB_TRIGGER_NAME = "ContextMenuSubTrigger"
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
});
|
|
322
|
+
const SUB_TRIGGER_NAME = "ContextMenuSubTrigger";
|
|
323
|
+
const ContextMenuSubTrigger = View.styleable((props, forwardedRef) => {
|
|
324
|
+
const {
|
|
325
|
+
scope,
|
|
326
|
+
...subTriggerProps
|
|
327
|
+
} = props;
|
|
328
|
+
return /* @__PURE__ */jsx(Menu.SubTrigger, {
|
|
329
|
+
componentName: SUB_TRIGGER_NAME,
|
|
330
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
331
|
+
...subTriggerProps,
|
|
332
|
+
ref: forwardedRef
|
|
313
333
|
});
|
|
334
|
+
});
|
|
314
335
|
ContextMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
315
|
-
const SUB_CONTENT_NAME = "ContextMenuSubContent"
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
"--
|
|
329
|
-
"--
|
|
330
|
-
"--
|
|
331
|
-
"--
|
|
332
|
-
|
|
333
|
-
|
|
336
|
+
const SUB_CONTENT_NAME = "ContextMenuSubContent";
|
|
337
|
+
const ContextMenuSubContent = React.forwardRef((props, forwardedRef) => {
|
|
338
|
+
const {
|
|
339
|
+
scope,
|
|
340
|
+
...subContentProps
|
|
341
|
+
} = props;
|
|
342
|
+
return /* @__PURE__ */jsx(Menu.SubContent, {
|
|
343
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
344
|
+
...subContentProps,
|
|
345
|
+
ref: forwardedRef,
|
|
346
|
+
style: isWeb ? {
|
|
347
|
+
...props.style,
|
|
348
|
+
...{
|
|
349
|
+
"--gui-context-menu-content-transform-origin": "var(--gui-popper-transform-origin)",
|
|
350
|
+
"--gui-context-menu-content-available-width": "var(--gui-popper-available-width)",
|
|
351
|
+
"--gui-context-menu-content-available-height": "var(--gui-popper-available-height)",
|
|
352
|
+
"--gui-context-menu-trigger-width": "var(--gui-popper-anchor-width)",
|
|
353
|
+
"--gui-context-menu-trigger-height": "var(--gui-popper-anchor-height)"
|
|
354
|
+
}
|
|
355
|
+
} : null
|
|
334
356
|
});
|
|
357
|
+
});
|
|
335
358
|
ContextMenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
336
|
-
const ARROW_NAME = "ContextMenuArrow"
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
});
|
|
359
|
+
const ARROW_NAME = "ContextMenuArrow";
|
|
360
|
+
const ContextMenuArrow = React.forwardRef((props, forwardedRef) => {
|
|
361
|
+
const {
|
|
362
|
+
scope,
|
|
363
|
+
...arrowProps
|
|
364
|
+
} = props;
|
|
365
|
+
return /* @__PURE__ */jsx(Menu.Arrow, {
|
|
366
|
+
componentName: ARROW_NAME,
|
|
367
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
368
|
+
...arrowProps,
|
|
369
|
+
ref: forwardedRef
|
|
348
370
|
});
|
|
371
|
+
});
|
|
349
372
|
ContextMenuArrow.displayName = ARROW_NAME;
|
|
350
|
-
const ContextMenuGroup = Menu.Group
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
373
|
+
const ContextMenuGroup = Menu.Group;
|
|
374
|
+
const ContextMenuLabel = Menu.Label;
|
|
375
|
+
const ContextMenuSeparator = Menu.Separator;
|
|
376
|
+
const ContextMenuItemTitle = Menu.ItemTitle;
|
|
377
|
+
const ContextMenuItemSubTitle = Menu.ItemSubtitle;
|
|
378
|
+
const ContextMenuItemImage = Menu.ItemImage;
|
|
379
|
+
const ContextMenuItemIcon = Menu.ItemIcon;
|
|
380
|
+
const ContextMenuPreview = () => null;
|
|
357
381
|
return withStaticProperties(ContextMenuComp, {
|
|
358
382
|
Root: ContextMenuComp,
|
|
359
383
|
Trigger: ContextMenuTrigger,
|
|
@@ -375,7 +399,7 @@ function createNonNativeContextMenu(params) {
|
|
|
375
399
|
ItemSubtitle: ContextMenuItemSubTitle,
|
|
376
400
|
ItemIcon: ContextMenuItemIcon,
|
|
377
401
|
ItemImage: ContextMenuItemImage,
|
|
378
|
-
Preview:
|
|
402
|
+
Preview: ContextMenuPreview
|
|
379
403
|
});
|
|
380
404
|
}
|
|
381
405
|
export { CONTEXTMENU_CONTEXT, createNonNativeContextMenu };
|