@tamagui/context-menu 2.0.0-1
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 +182 -0
- package/dist/cjs/ContextMenu.js +145 -0
- package/dist/cjs/ContextMenu.js.map +6 -0
- package/dist/cjs/ContextMenu.native.js +191 -0
- package/dist/cjs/ContextMenu.native.js.map +1 -0
- package/dist/cjs/createNonNativeContextMenu.cjs +394 -0
- package/dist/cjs/createNonNativeContextMenu.js +318 -0
- package/dist/cjs/createNonNativeContextMenu.js.map +6 -0
- package/dist/cjs/createNonNativeContextMenu.native.js +420 -0
- package/dist/cjs/createNonNativeContextMenu.native.js.map +1 -0
- package/dist/cjs/index.cjs +39 -0
- package/dist/cjs/index.js +32 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/index.native.js +42 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/esm/ContextMenu.js +127 -0
- package/dist/esm/ContextMenu.js.map +6 -0
- package/dist/esm/ContextMenu.mjs +148 -0
- package/dist/esm/ContextMenu.mjs.map +1 -0
- package/dist/esm/ContextMenu.native.js +154 -0
- package/dist/esm/ContextMenu.native.js.map +1 -0
- package/dist/esm/createNonNativeContextMenu.js +307 -0
- package/dist/esm/createNonNativeContextMenu.js.map +6 -0
- package/dist/esm/createNonNativeContextMenu.mjs +359 -0
- package/dist/esm/createNonNativeContextMenu.mjs.map +1 -0
- package/dist/esm/createNonNativeContextMenu.native.js +382 -0
- package/dist/esm/createNonNativeContextMenu.native.js.map +1 -0
- package/dist/esm/index.js +18 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +16 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +16 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/jsx/ContextMenu.js +127 -0
- package/dist/jsx/ContextMenu.js.map +6 -0
- package/dist/jsx/ContextMenu.mjs +148 -0
- package/dist/jsx/ContextMenu.mjs.map +1 -0
- package/dist/jsx/ContextMenu.native.js +191 -0
- package/dist/jsx/ContextMenu.native.js.map +1 -0
- package/dist/jsx/createNonNativeContextMenu.js +307 -0
- package/dist/jsx/createNonNativeContextMenu.js.map +6 -0
- package/dist/jsx/createNonNativeContextMenu.mjs +359 -0
- package/dist/jsx/createNonNativeContextMenu.mjs.map +1 -0
- package/dist/jsx/createNonNativeContextMenu.native.js +420 -0
- package/dist/jsx/createNonNativeContextMenu.native.js.map +1 -0
- package/dist/jsx/index.js +18 -0
- package/dist/jsx/index.js.map +6 -0
- package/dist/jsx/index.mjs +16 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +42 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/package.json +56 -0
- package/src/ContextMenu.tsx +187 -0
- package/src/createNonNativeContextMenu.tsx +607 -0
- package/src/index.tsx +17 -0
- package/types/ContextMenu.d.ts +98 -0
- package/types/ContextMenu.d.ts.map +1 -0
- package/types/createNonNativeContextMenu.d.ts +123 -0
- package/types/createNonNativeContextMenu.d.ts.map +1 -0
- package/types/index.d.ts +96 -0
- package/types/index.d.ts.map +1 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createNativeMenu, withNativeMenu } from "@tamagui/create-menu";
|
|
2
|
+
import { withStaticProperties } from "@tamagui/web";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { CONTEXTMENU_CONTEXT, createNonNativeContextMenu } from "./createNonNativeContextMenu.mjs";
|
|
5
|
+
const COMMON_PARAMS = {
|
|
6
|
+
isRoot: !1,
|
|
7
|
+
scope: CONTEXTMENU_CONTEXT
|
|
8
|
+
};
|
|
9
|
+
function createContextMenu(param) {
|
|
10
|
+
const {
|
|
11
|
+
Menu: NativeMenuRoot
|
|
12
|
+
} = createNativeMenu("ContextMenu"),
|
|
13
|
+
NonNativeContextMenu = createNonNativeContextMenu(param),
|
|
14
|
+
ContextMenuComp = withNativeMenu({
|
|
15
|
+
...COMMON_PARAMS,
|
|
16
|
+
Component: NonNativeContextMenu.Root,
|
|
17
|
+
NativeComponent: NativeMenuRoot,
|
|
18
|
+
isRoot: !0
|
|
19
|
+
}),
|
|
20
|
+
Trigger = withNativeMenu({
|
|
21
|
+
...COMMON_PARAMS,
|
|
22
|
+
Component: NonNativeContextMenu.Trigger,
|
|
23
|
+
NativeComponent: NativeMenuRoot.Trigger
|
|
24
|
+
}),
|
|
25
|
+
Portal = withNativeMenu({
|
|
26
|
+
...COMMON_PARAMS,
|
|
27
|
+
Component: NonNativeContextMenu.Portal,
|
|
28
|
+
NativeComponent: React.Fragment
|
|
29
|
+
}),
|
|
30
|
+
Content = withNativeMenu({
|
|
31
|
+
...COMMON_PARAMS,
|
|
32
|
+
Component: NonNativeContextMenu.Content,
|
|
33
|
+
NativeComponent: NativeMenuRoot.Content
|
|
34
|
+
}),
|
|
35
|
+
Preview = withNativeMenu({
|
|
36
|
+
...COMMON_PARAMS,
|
|
37
|
+
Component: NonNativeContextMenu.Preview,
|
|
38
|
+
NativeComponent: NativeMenuRoot.Preview
|
|
39
|
+
}),
|
|
40
|
+
Group = withNativeMenu({
|
|
41
|
+
...COMMON_PARAMS,
|
|
42
|
+
Component: NonNativeContextMenu.Group,
|
|
43
|
+
NativeComponent: NativeMenuRoot.Group
|
|
44
|
+
}),
|
|
45
|
+
Label = withNativeMenu({
|
|
46
|
+
...COMMON_PARAMS,
|
|
47
|
+
Component: NonNativeContextMenu.Label,
|
|
48
|
+
NativeComponent: NativeMenuRoot.Label
|
|
49
|
+
}),
|
|
50
|
+
Item = withNativeMenu({
|
|
51
|
+
...COMMON_PARAMS,
|
|
52
|
+
Component: NonNativeContextMenu.Item,
|
|
53
|
+
NativeComponent: NativeMenuRoot.Item
|
|
54
|
+
}),
|
|
55
|
+
ItemTitle = withNativeMenu({
|
|
56
|
+
...COMMON_PARAMS,
|
|
57
|
+
Component: NonNativeContextMenu.ItemTitle,
|
|
58
|
+
NativeComponent: NativeMenuRoot.ItemTitle
|
|
59
|
+
}),
|
|
60
|
+
ItemSubtitle = withNativeMenu({
|
|
61
|
+
...COMMON_PARAMS,
|
|
62
|
+
Component: NonNativeContextMenu.ItemSubtitle,
|
|
63
|
+
NativeComponent: NativeMenuRoot.ItemSubtitle
|
|
64
|
+
}),
|
|
65
|
+
ItemIcon = withNativeMenu({
|
|
66
|
+
...COMMON_PARAMS,
|
|
67
|
+
Component: NonNativeContextMenu.ItemIcon,
|
|
68
|
+
NativeComponent: NativeMenuRoot.ItemIcon
|
|
69
|
+
}),
|
|
70
|
+
ItemImage = withNativeMenu({
|
|
71
|
+
...COMMON_PARAMS,
|
|
72
|
+
Component: NonNativeContextMenu.ItemImage,
|
|
73
|
+
NativeComponent: NativeMenuRoot.ItemImage
|
|
74
|
+
}),
|
|
75
|
+
CheckboxItem = withNativeMenu({
|
|
76
|
+
...COMMON_PARAMS,
|
|
77
|
+
Component: NonNativeContextMenu.CheckboxItem,
|
|
78
|
+
NativeComponent: NativeMenuRoot.CheckboxItem
|
|
79
|
+
}),
|
|
80
|
+
RadioGroup = withNativeMenu({
|
|
81
|
+
...COMMON_PARAMS,
|
|
82
|
+
Component: NonNativeContextMenu.RadioGroup,
|
|
83
|
+
NativeComponent: () => null
|
|
84
|
+
}),
|
|
85
|
+
RadioItem = withNativeMenu({
|
|
86
|
+
...COMMON_PARAMS,
|
|
87
|
+
Component: NonNativeContextMenu.RadioItem,
|
|
88
|
+
NativeComponent: ({
|
|
89
|
+
children
|
|
90
|
+
}) => children
|
|
91
|
+
}),
|
|
92
|
+
ItemIndicator = withNativeMenu({
|
|
93
|
+
...COMMON_PARAMS,
|
|
94
|
+
Component: NonNativeContextMenu.ItemIndicator,
|
|
95
|
+
NativeComponent: NativeMenuRoot.ItemIndicator
|
|
96
|
+
}),
|
|
97
|
+
Separator = withNativeMenu({
|
|
98
|
+
...COMMON_PARAMS,
|
|
99
|
+
Component: NonNativeContextMenu.Separator,
|
|
100
|
+
NativeComponent: NativeMenuRoot.Separator
|
|
101
|
+
}),
|
|
102
|
+
Arrow = withNativeMenu({
|
|
103
|
+
...COMMON_PARAMS,
|
|
104
|
+
Component: NonNativeContextMenu.Arrow,
|
|
105
|
+
NativeComponent: NativeMenuRoot.Arrow
|
|
106
|
+
}),
|
|
107
|
+
Sub = withNativeMenu({
|
|
108
|
+
...COMMON_PARAMS,
|
|
109
|
+
Component: NonNativeContextMenu.Sub,
|
|
110
|
+
NativeComponent: NativeMenuRoot.Sub
|
|
111
|
+
}),
|
|
112
|
+
SubTrigger = withNativeMenu({
|
|
113
|
+
...COMMON_PARAMS,
|
|
114
|
+
Component: NonNativeContextMenu.SubTrigger,
|
|
115
|
+
NativeComponent: NativeMenuRoot.SubTrigger
|
|
116
|
+
}),
|
|
117
|
+
SubContent = withNativeMenu({
|
|
118
|
+
...COMMON_PARAMS,
|
|
119
|
+
Component: NonNativeContextMenu.SubContent,
|
|
120
|
+
NativeComponent: NativeMenuRoot.SubContent
|
|
121
|
+
});
|
|
122
|
+
return withStaticProperties(ContextMenuComp, {
|
|
123
|
+
Trigger,
|
|
124
|
+
Portal,
|
|
125
|
+
Content,
|
|
126
|
+
Group,
|
|
127
|
+
Label,
|
|
128
|
+
Item,
|
|
129
|
+
CheckboxItem,
|
|
130
|
+
RadioGroup,
|
|
131
|
+
RadioItem,
|
|
132
|
+
ItemIndicator,
|
|
133
|
+
Separator,
|
|
134
|
+
Arrow,
|
|
135
|
+
Sub,
|
|
136
|
+
// cast to React.FC to avoid TS error
|
|
137
|
+
SubTrigger,
|
|
138
|
+
SubContent,
|
|
139
|
+
ItemTitle,
|
|
140
|
+
ItemSubtitle,
|
|
141
|
+
// cast to React.FC to avoid TS error
|
|
142
|
+
ItemIcon,
|
|
143
|
+
ItemImage,
|
|
144
|
+
Preview
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
export { createContextMenu };
|
|
148
|
+
//# sourceMappingURL=ContextMenu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createNativeMenu","withNativeMenu","withStaticProperties","React","CONTEXTMENU_CONTEXT","createNonNativeContextMenu","COMMON_PARAMS","isRoot","scope","createContextMenu","param","Menu","NativeMenuRoot","NonNativeContextMenu","ContextMenuComp","Component","Root","NativeComponent","Trigger","Portal","Fragment","Content","Preview","Group","Label","Item","ItemTitle","ItemSubtitle","ItemIcon","ItemImage","CheckboxItem","RadioGroup","RadioItem","children","ItemIndicator","Separator","Arrow","Sub","SubTrigger","SubContent"],"sources":["../../src/ContextMenu.tsx"],"sourcesContent":[null],"mappings":"AAKA,SAASA,gBAAA,EAAkBC,cAAA,QAAsB;AACjD,SAASC,oBAAA,QAA4B;AACrC,OAAOC,KAAA,MAAW;AAElB,SACEC,mBAAA,EAGAC,0BAAA,QACK;AAEP,MAAMC,aAAA,GAAgB;EACpBC,MAAA,EAAQ;EACRC,KAAA,EAAOJ;AACT;AAEO,SAASK,kBAAkBC,KAAA,EAA4B;EAC5D,MAAM;MAAEC,IAAA,EAAMC;IAAe,IAAIZ,gBAAA,CAAiB,aAAa;IACzDa,oBAAA,GAAuBR,0BAAA,CAA2BK,KAAK;IAEvDI,eAAA,GAAkBb,cAAA,CAAe;MACrC,GAAGK,aAAA;MACHS,SAAA,EAAWF,oBAAA,CAAqBG,IAAA;MAChCC,eAAA,EAAiBL,cAAA;MACjBL,MAAA,EAAQ;IACV,CAAC;IAEKW,OAAA,GAAUjB,cAAA,CAAe;MAC7B,GAAGK,aAAA;MACHS,SAAA,EAAWF,oBAAA,CAAqBK,OAAA;MAChCD,eAAA,EAAiBL,cAAA,CAAeM;IAClC,CAAC;IACKC,MAAA,GAASlB,cAAA,CAAe;MAC5B,GAAGK,aAAA;MACHS,SAAA,EAAWF,oBAAA,CAAqBM,MAAA;MAChCF,eAAA,EAAiBd,KAAA,CAAMiB;IACzB,CAAC;IACKC,OAAA,GAAUpB,cAAA,CAAe;MAC7B,GAAGK,aAAA;MACHS,SAAA,EAAWF,oBAAA,CAAqBQ,OAAA;MACh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;EAgCD,OAxBoBrC,oBAAA,CAAqBY,eAAA,EAAiB;IACxDI,OAAA;IACAC,MAAA;IACAE,OAAA;IACAE,KAAA;IACAC,KAAA;IACAC,IAAA;IACAK,YAAA;IACAC,UAAA;IACAC,SAAA;IACAE,aAAA;IACAC,SAAA;IACAC,KAAA;IACAC,GAAA;IAAA;IAEAC,UAAA;IACAC,UAAA;IACAb,SAAA;IACAC,YAAA;IAAA;IAEAC,QAAA;IACAC,SAAA;IACAP;EACF,CAAC;AAEH","ignoreList":[]}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
__copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: !0
|
|
30
|
+
}) : target, mod)),
|
|
31
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: !0
|
|
33
|
+
}), mod);
|
|
34
|
+
var ContextMenu_exports = {};
|
|
35
|
+
__export(ContextMenu_exports, {
|
|
36
|
+
createContextMenu: () => createContextMenu
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(ContextMenu_exports);
|
|
39
|
+
var import_create_menu = require("@tamagui/create-menu"),
|
|
40
|
+
import_web = require("@tamagui/web"),
|
|
41
|
+
import_react = __toESM(require("react")),
|
|
42
|
+
import_createNonNativeContextMenu = require("./createNonNativeContextMenu.native.js"),
|
|
43
|
+
COMMON_PARAMS = {
|
|
44
|
+
isRoot: !1,
|
|
45
|
+
scope: import_createNonNativeContextMenu.CONTEXTMENU_CONTEXT
|
|
46
|
+
};
|
|
47
|
+
function createContextMenu(param) {
|
|
48
|
+
var {
|
|
49
|
+
Menu: NativeMenuRoot
|
|
50
|
+
} = (0, import_create_menu.createNativeMenu)("ContextMenu"),
|
|
51
|
+
NonNativeContextMenu = (0, import_createNonNativeContextMenu.createNonNativeContextMenu)(param),
|
|
52
|
+
ContextMenuComp = (0, import_create_menu.withNativeMenu)({
|
|
53
|
+
...COMMON_PARAMS,
|
|
54
|
+
Component: NonNativeContextMenu.Root,
|
|
55
|
+
NativeComponent: NativeMenuRoot,
|
|
56
|
+
isRoot: !0
|
|
57
|
+
}),
|
|
58
|
+
Trigger = (0, import_create_menu.withNativeMenu)({
|
|
59
|
+
...COMMON_PARAMS,
|
|
60
|
+
Component: NonNativeContextMenu.Trigger,
|
|
61
|
+
NativeComponent: NativeMenuRoot.Trigger
|
|
62
|
+
}),
|
|
63
|
+
Portal = (0, import_create_menu.withNativeMenu)({
|
|
64
|
+
...COMMON_PARAMS,
|
|
65
|
+
Component: NonNativeContextMenu.Portal,
|
|
66
|
+
NativeComponent: import_react.default.Fragment
|
|
67
|
+
}),
|
|
68
|
+
Content = (0, import_create_menu.withNativeMenu)({
|
|
69
|
+
...COMMON_PARAMS,
|
|
70
|
+
Component: NonNativeContextMenu.Content,
|
|
71
|
+
NativeComponent: NativeMenuRoot.Content
|
|
72
|
+
}),
|
|
73
|
+
Preview = (0, import_create_menu.withNativeMenu)({
|
|
74
|
+
...COMMON_PARAMS,
|
|
75
|
+
Component: NonNativeContextMenu.Preview,
|
|
76
|
+
NativeComponent: NativeMenuRoot.Preview
|
|
77
|
+
}),
|
|
78
|
+
Group = (0, import_create_menu.withNativeMenu)({
|
|
79
|
+
...COMMON_PARAMS,
|
|
80
|
+
Component: NonNativeContextMenu.Group,
|
|
81
|
+
NativeComponent: NativeMenuRoot.Group
|
|
82
|
+
}),
|
|
83
|
+
Label = (0, import_create_menu.withNativeMenu)({
|
|
84
|
+
...COMMON_PARAMS,
|
|
85
|
+
Component: NonNativeContextMenu.Label,
|
|
86
|
+
NativeComponent: NativeMenuRoot.Label
|
|
87
|
+
}),
|
|
88
|
+
Item = (0, import_create_menu.withNativeMenu)({
|
|
89
|
+
...COMMON_PARAMS,
|
|
90
|
+
Component: NonNativeContextMenu.Item,
|
|
91
|
+
NativeComponent: NativeMenuRoot.Item
|
|
92
|
+
}),
|
|
93
|
+
ItemTitle = (0, import_create_menu.withNativeMenu)({
|
|
94
|
+
...COMMON_PARAMS,
|
|
95
|
+
Component: NonNativeContextMenu.ItemTitle,
|
|
96
|
+
NativeComponent: NativeMenuRoot.ItemTitle
|
|
97
|
+
}),
|
|
98
|
+
ItemSubtitle = (0, import_create_menu.withNativeMenu)({
|
|
99
|
+
...COMMON_PARAMS,
|
|
100
|
+
Component: NonNativeContextMenu.ItemSubtitle,
|
|
101
|
+
NativeComponent: NativeMenuRoot.ItemSubtitle
|
|
102
|
+
}),
|
|
103
|
+
ItemIcon = (0, import_create_menu.withNativeMenu)({
|
|
104
|
+
...COMMON_PARAMS,
|
|
105
|
+
Component: NonNativeContextMenu.ItemIcon,
|
|
106
|
+
NativeComponent: NativeMenuRoot.ItemIcon
|
|
107
|
+
}),
|
|
108
|
+
ItemImage = (0, import_create_menu.withNativeMenu)({
|
|
109
|
+
...COMMON_PARAMS,
|
|
110
|
+
Component: NonNativeContextMenu.ItemImage,
|
|
111
|
+
NativeComponent: NativeMenuRoot.ItemImage
|
|
112
|
+
}),
|
|
113
|
+
CheckboxItem = (0, import_create_menu.withNativeMenu)({
|
|
114
|
+
...COMMON_PARAMS,
|
|
115
|
+
Component: NonNativeContextMenu.CheckboxItem,
|
|
116
|
+
NativeComponent: NativeMenuRoot.CheckboxItem
|
|
117
|
+
}),
|
|
118
|
+
RadioGroup = (0, import_create_menu.withNativeMenu)({
|
|
119
|
+
...COMMON_PARAMS,
|
|
120
|
+
Component: NonNativeContextMenu.RadioGroup,
|
|
121
|
+
NativeComponent: function () {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
RadioItem = (0, import_create_menu.withNativeMenu)({
|
|
126
|
+
...COMMON_PARAMS,
|
|
127
|
+
Component: NonNativeContextMenu.RadioItem,
|
|
128
|
+
NativeComponent: function (param2) {
|
|
129
|
+
var {
|
|
130
|
+
children
|
|
131
|
+
} = param2;
|
|
132
|
+
return children;
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
ItemIndicator = (0, import_create_menu.withNativeMenu)({
|
|
136
|
+
...COMMON_PARAMS,
|
|
137
|
+
Component: NonNativeContextMenu.ItemIndicator,
|
|
138
|
+
NativeComponent: NativeMenuRoot.ItemIndicator
|
|
139
|
+
}),
|
|
140
|
+
Separator = (0, import_create_menu.withNativeMenu)({
|
|
141
|
+
...COMMON_PARAMS,
|
|
142
|
+
Component: NonNativeContextMenu.Separator,
|
|
143
|
+
NativeComponent: NativeMenuRoot.Separator
|
|
144
|
+
}),
|
|
145
|
+
Arrow = (0, import_create_menu.withNativeMenu)({
|
|
146
|
+
...COMMON_PARAMS,
|
|
147
|
+
Component: NonNativeContextMenu.Arrow,
|
|
148
|
+
NativeComponent: NativeMenuRoot.Arrow
|
|
149
|
+
}),
|
|
150
|
+
Sub = (0, import_create_menu.withNativeMenu)({
|
|
151
|
+
...COMMON_PARAMS,
|
|
152
|
+
Component: NonNativeContextMenu.Sub,
|
|
153
|
+
NativeComponent: NativeMenuRoot.Sub
|
|
154
|
+
}),
|
|
155
|
+
SubTrigger = (0, import_create_menu.withNativeMenu)({
|
|
156
|
+
...COMMON_PARAMS,
|
|
157
|
+
Component: NonNativeContextMenu.SubTrigger,
|
|
158
|
+
NativeComponent: NativeMenuRoot.SubTrigger
|
|
159
|
+
}),
|
|
160
|
+
SubContent = (0, import_create_menu.withNativeMenu)({
|
|
161
|
+
...COMMON_PARAMS,
|
|
162
|
+
Component: NonNativeContextMenu.SubContent,
|
|
163
|
+
NativeComponent: NativeMenuRoot.SubContent
|
|
164
|
+
}),
|
|
165
|
+
ContextMenu = (0, import_web.withStaticProperties)(ContextMenuComp, {
|
|
166
|
+
Trigger,
|
|
167
|
+
Portal,
|
|
168
|
+
Content,
|
|
169
|
+
Group,
|
|
170
|
+
Label,
|
|
171
|
+
Item,
|
|
172
|
+
CheckboxItem,
|
|
173
|
+
RadioGroup,
|
|
174
|
+
RadioItem,
|
|
175
|
+
ItemIndicator,
|
|
176
|
+
Separator,
|
|
177
|
+
Arrow,
|
|
178
|
+
Sub,
|
|
179
|
+
// cast to React.FC to avoid TS error
|
|
180
|
+
SubTrigger,
|
|
181
|
+
SubContent,
|
|
182
|
+
ItemTitle,
|
|
183
|
+
ItemSubtitle,
|
|
184
|
+
// cast to React.FC to avoid TS error
|
|
185
|
+
ItemIcon,
|
|
186
|
+
ItemImage,
|
|
187
|
+
Preview
|
|
188
|
+
});
|
|
189
|
+
return ContextMenu;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=ContextMenu.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","ContextMenu_exports","createContextMenu","module","exports","import_create_menu","require","import_web","import_react","import_createNonNativeContextMenu","COMMON_PARAMS","isRoot","scope","CONTEXTMENU_CONTEXT","param","Menu","NativeMenuRoot","createNativeMenu","NonNativeContextMenu","createNonNativeContextMenu","ContextMenuComp","withNativeMenu","Component","Root","NativeComponent","Trigger","Portal","default","Fragment","Content","Preview","Group","Label","Item","ItemTitle","ItemSubtitle","ItemIcon","ItemImage","CheckboxItem","RadioGroup","RadioItem","param2","children","ItemIndicator","Separator","Arrow","Sub","SubTrigger","SubContent"],"sources":["../../src/ContextMenu.tsx"],"sourcesContent":[null],"mappings":"AAKA,YAAS;;AACT,IAAAA,QAAS,GAAAC,MAAA,CAAAC,MAAA;AACT,IAAAC,SAAO,GAAAF,MAAW,CAAAG,cAAA;AAElB,IAAAC,gBAAA,GAAAJ,MAAA,CAAAK,wBAAA;AAAA,IACEC,iBAAA,GAAAN,MAAA,CAAAO,mBAAA;AAAA,IAGAC,YAAA,GAAAR,MAAA,CAAAS,cAAA;EAAAC,YAAA,GAAAV,MAAA,CAAAW,SAAA,CAAAC,cAAA;AAAA,IAAAC,QACK,GAAAA,CAAAC,MAAA,EAAAC,GAAA;IAEP,KAAM,IAAAC,IAAA,IAAAD,GAAgB,EACpBb,SAAQ,CAAAY,MAAA,EAAAE,IAAA;MAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;MAAAE,UAAA;IAAA;EAAA;EACRC,WAAO,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,IAAA;IACT,IAAAF,IAAA,WAAAA,IAAA,uBAAAA,IA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A,CAAAgB,cAAA;MACA,GAAAX,aAAA;MACAY,SAAA,EAAAJ,oBAAA,CAAAyB,aAAA;MACAnB,eAAA,EAAAR,cAAA,CAAA2B;IAAA,EACA;IAAAC,SAAA,OAAAvC,kBAAA,CAAAgB,cAAA;MACA,GAAAX,aAAA;MACAY,SAAA,EAAAJ,oBAAA,CAAA0B,SAAA;MACApB,eAAA,EAAAR,cAAA,CAAA4B;IAAA,EACA;IAAAC,KAAA,OAAAxC,kBAAA,CAAAgB,cAAA;MACA,GAAAX,aAAA;MACAY,SAAA,EAAAJ,oBAAA,CAAA2B,KAAA;MACArB,eAAA,EAAAR,cAAA,CAAA6B;IAAA,EACA;IAAAC,GAAA,OAAAzC,kBAAA,CAAAgB,cAAA;MAAA,GAAAX,aAAA;MAEAY,SAAA,EAAAJ,oBAAA,CAAA4B,GAAA;MACAtB,eAAA,EAAAR,cAAA,CAAA8B;IAAA,EACA;IAAAC,UAAA,OAAA1C,kBAAA,CAAAgB,cAAA;MACA,GAAAX,aAAA;MAAAY,SAAA,EAAAJ,oBAAA,CAAA6B,UAAA;MAEAvB,eAAA,EAAAR,cAAA,CAAA+B;IAAA,EACA;IAAAC,UAAA,OAAA3C,kBAAA,CAAAgB,cAAA;MACA,GAAAX,aAAA;MACDY,SAAA,EAAAJ,oBAAA,CAAA8B,UAAA;MAEHxB,eAAA,EAAAR,cAAA,CAAAgC","ignoreList":[]}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { createBaseMenu } from "@tamagui/create-menu";
|
|
2
|
+
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
3
|
+
import {
|
|
4
|
+
composeEventHandlers,
|
|
5
|
+
composeRefs,
|
|
6
|
+
createStyledContext,
|
|
7
|
+
isAndroid,
|
|
8
|
+
isWeb,
|
|
9
|
+
Slot,
|
|
10
|
+
View,
|
|
11
|
+
withStaticProperties
|
|
12
|
+
} from "@tamagui/web";
|
|
13
|
+
import React, { useId } from "react";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
const CONTEXTMENU_CONTEXT = "ContextMenuContext";
|
|
16
|
+
function createNonNativeContextMenu(params) {
|
|
17
|
+
const { Menu } = createBaseMenu(params), CONTEXT_MENU_NAME = "ContextMenu", { Provider: ContextMenuProvider, useStyledContext: useContextMenuContext } = createStyledContext(), ContextMenuComp = (props) => {
|
|
18
|
+
const { scope, children, onOpenChange, dir, modal = !0, ...rest } = props, [open, setOpen] = React.useState(!1), triggerRef = React.useRef(null), handleOpenChange = React.useCallback(
|
|
19
|
+
(open2) => {
|
|
20
|
+
setOpen(open2), onOpenChange?.(open2);
|
|
21
|
+
},
|
|
22
|
+
[onOpenChange]
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
ContextMenuProvider,
|
|
26
|
+
{
|
|
27
|
+
scope,
|
|
28
|
+
triggerId: useId(),
|
|
29
|
+
triggerRef,
|
|
30
|
+
contentId: useId(),
|
|
31
|
+
open,
|
|
32
|
+
onOpenChange: handleOpenChange,
|
|
33
|
+
modal,
|
|
34
|
+
children: /* @__PURE__ */ jsx(
|
|
35
|
+
Menu,
|
|
36
|
+
{
|
|
37
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
38
|
+
dir,
|
|
39
|
+
open,
|
|
40
|
+
onOpenChange: handleOpenChange,
|
|
41
|
+
modal,
|
|
42
|
+
...rest,
|
|
43
|
+
children
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
ContextMenuComp.displayName = CONTEXT_MENU_NAME;
|
|
50
|
+
const TRIGGER_NAME = "ContextMenuTrigger", ContextMenuTrigger = View.styleable(
|
|
51
|
+
(props, forwardedRef) => {
|
|
52
|
+
const { scope, style, disabled = !1, asChild, children, ...triggerProps } = props, context = useContextMenuContext(scope), pointRef = React.useRef({ x: 0, y: 0 }), virtualRef = React.useMemo(
|
|
53
|
+
() => ({
|
|
54
|
+
current: {
|
|
55
|
+
getBoundingClientRect: () => isWeb ? DOMRect.fromRect({ width: 0, height: 0, ...pointRef.current }) : { width: 0, height: 0, top: 0, left: 0, ...pointRef.current },
|
|
56
|
+
...!isWeb && {
|
|
57
|
+
measure: (c) => c(pointRef.current.x, pointRef.current.y, 0, 0),
|
|
58
|
+
measureInWindow: (c) => c(pointRef.current.x, pointRef.current.y, 0, 0)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
[pointRef.current.x, pointRef.current.y]
|
|
63
|
+
), longPressTimerRef = React.useRef(0), clearLongPress = React.useCallback(
|
|
64
|
+
() => window.clearTimeout(longPressTimerRef.current),
|
|
65
|
+
[]
|
|
66
|
+
), handleOpen = (event) => {
|
|
67
|
+
isWeb && (event instanceof MouseEvent || event instanceof PointerEvent) ? pointRef.current = { x: event.clientX, y: event.clientY } : pointRef.current = {
|
|
68
|
+
x: event.nativeEvent.pageX,
|
|
69
|
+
y: event.nativeEvent.pageY
|
|
70
|
+
}, context.onOpenChange(!0);
|
|
71
|
+
};
|
|
72
|
+
React.useEffect(() => clearLongPress, [clearLongPress]), React.useEffect(
|
|
73
|
+
() => void (disabled && clearLongPress()),
|
|
74
|
+
[disabled, clearLongPress]
|
|
75
|
+
);
|
|
76
|
+
const Comp = asChild ? Slot : View;
|
|
77
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
+
/* @__PURE__ */ jsx(Menu.Anchor, { scope: scope || CONTEXTMENU_CONTEXT, virtualRef }),
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
Comp,
|
|
81
|
+
{
|
|
82
|
+
tag: "span",
|
|
83
|
+
componentName: TRIGGER_NAME,
|
|
84
|
+
id: context.triggerId,
|
|
85
|
+
"data-state": context.open ? "open" : "closed",
|
|
86
|
+
"data-disabled": disabled ? "" : void 0,
|
|
87
|
+
...triggerProps,
|
|
88
|
+
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
89
|
+
style: isWeb ? { WebkitTouchCallout: "none", ...style } : null,
|
|
90
|
+
...isWeb && {
|
|
91
|
+
onContextMenu: disabled ? props.onContextMenu : composeEventHandlers(props.onContextMenu, (event) => {
|
|
92
|
+
clearLongPress(), handleOpen(event), event.preventDefault();
|
|
93
|
+
}),
|
|
94
|
+
onPointerDown: disabled ? props.onPointerDown : composeEventHandlers(props.onPointerDown, (event) => {
|
|
95
|
+
event.pointerType !== "mouse" && (clearLongPress(), longPressTimerRef.current = window.setTimeout(
|
|
96
|
+
() => handleOpen(event),
|
|
97
|
+
700
|
|
98
|
+
));
|
|
99
|
+
}),
|
|
100
|
+
onPointerMove: disabled ? props.onPointerMove : composeEventHandlers(props.onPointerMove, (event) => {
|
|
101
|
+
event.pointerType !== "mouse" && clearLongPress();
|
|
102
|
+
}),
|
|
103
|
+
onPointerCancel: disabled ? props.onPointerCancel : composeEventHandlers(props.onPointerCancel, (event) => {
|
|
104
|
+
event.pointerType !== "mouse" && clearLongPress();
|
|
105
|
+
}),
|
|
106
|
+
onPointerUp: disabled ? props.onPointerUp : composeEventHandlers(props.onPointerUp, (event) => {
|
|
107
|
+
event.pointerType !== "mouse" && clearLongPress();
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
...!isWeb && {
|
|
111
|
+
onLongPress: disabled ? props.onLongPress : composeEventHandlers(props.onLongPress, (event) => {
|
|
112
|
+
clearLongPress(), handleOpen(event), event.preventDefault();
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
children
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
ContextMenuTrigger.displayName = TRIGGER_NAME;
|
|
122
|
+
const PORTAL_NAME = "ContextMenuPortal", ContextMenuPortal = (props) => {
|
|
123
|
+
const { scope, children, ...portalProps } = props, context = isAndroid ? useContextMenuContext(scope) : null, content = isAndroid ? /* @__PURE__ */ jsx(ContextMenuProvider, { ...context, children }) : children;
|
|
124
|
+
return /* @__PURE__ */ jsx(Menu.Portal, { scope: scope || CONTEXTMENU_CONTEXT, ...portalProps, children: content });
|
|
125
|
+
};
|
|
126
|
+
ContextMenuPortal.displayName = PORTAL_NAME;
|
|
127
|
+
const CONTENT_NAME = "ContextMenuContent", ContextMenuContent = React.forwardRef((props, forwardedRef) => {
|
|
128
|
+
const { scope, ...contentProps } = props, context = useContextMenuContext(scope), hasInteractedOutsideRef = React.useRef(!1);
|
|
129
|
+
return /* @__PURE__ */ jsx(
|
|
130
|
+
Menu.Content,
|
|
131
|
+
{
|
|
132
|
+
id: context.contentId,
|
|
133
|
+
"aria-labelledby": context.triggerId,
|
|
134
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
135
|
+
...contentProps,
|
|
136
|
+
ref: forwardedRef,
|
|
137
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
138
|
+
hasInteractedOutsideRef.current || context.triggerRef.current?.focus(), hasInteractedOutsideRef.current = !1, event.preventDefault();
|
|
139
|
+
}),
|
|
140
|
+
onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
|
|
141
|
+
const originalEvent = event.detail.originalEvent, ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0, isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
142
|
+
(!context.modal || isRightClick) && (hasInteractedOutsideRef.current = !0);
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
ContextMenuContent.displayName = CONTENT_NAME;
|
|
148
|
+
const ITEM_NAME = "ContextMenuItem", ContextMenuItem = React.forwardRef((props, forwardedRef) => {
|
|
149
|
+
const { scope, ...itemProps } = props;
|
|
150
|
+
return /* @__PURE__ */ jsx(
|
|
151
|
+
Menu.Item,
|
|
152
|
+
{
|
|
153
|
+
componentName: ITEM_NAME,
|
|
154
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
155
|
+
...itemProps,
|
|
156
|
+
ref: forwardedRef
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
ContextMenuItem.displayName = ITEM_NAME;
|
|
161
|
+
const CHECKBOX_ITEM_NAME = "ContextMenuCheckboxItem", ContextMenuCheckboxItem = React.forwardRef((props, forwardedRef) => {
|
|
162
|
+
const { scope, ...checkboxItemProps } = props;
|
|
163
|
+
return /* @__PURE__ */ jsx(
|
|
164
|
+
Menu.CheckboxItem,
|
|
165
|
+
{
|
|
166
|
+
componentName: CHECKBOX_ITEM_NAME,
|
|
167
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
168
|
+
...checkboxItemProps,
|
|
169
|
+
ref: forwardedRef
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
ContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
|
|
174
|
+
const RADIO_GROUP_NAME = "ContextMenuRadioGroup", ContextMenuRadioGroup = React.forwardRef((props, forwardedRef) => {
|
|
175
|
+
const { scope, ...radioGroupProps } = props;
|
|
176
|
+
return /* @__PURE__ */ jsx(
|
|
177
|
+
Menu.RadioGroup,
|
|
178
|
+
{
|
|
179
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
180
|
+
...radioGroupProps,
|
|
181
|
+
ref: forwardedRef
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
ContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
186
|
+
const RADIO_ITEM_NAME = "ContextMenuRadioItem", ContextMenuRadioItem = React.forwardRef((props, forwardedRef) => {
|
|
187
|
+
const { scope, ...radioItemProps } = props;
|
|
188
|
+
return /* @__PURE__ */ jsx(
|
|
189
|
+
Menu.RadioItem,
|
|
190
|
+
{
|
|
191
|
+
componentName: RADIO_ITEM_NAME,
|
|
192
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
193
|
+
...radioItemProps,
|
|
194
|
+
ref: forwardedRef
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
ContextMenuRadioItem.displayName = RADIO_ITEM_NAME;
|
|
199
|
+
const INDICATOR_NAME = "ContextMenuItemIndicator", ContextMenuItemIndicator = Menu.ItemIndicator.styleable((props, forwardedRef) => {
|
|
200
|
+
const { scope, ...itemIndicatorProps } = props;
|
|
201
|
+
return /* @__PURE__ */ jsx(
|
|
202
|
+
Menu.ItemIndicator,
|
|
203
|
+
{
|
|
204
|
+
componentName: INDICATOR_NAME,
|
|
205
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
206
|
+
...itemIndicatorProps,
|
|
207
|
+
ref: forwardedRef
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
ContextMenuItemIndicator.displayName = INDICATOR_NAME;
|
|
212
|
+
const SUB_NAME = "ContextMenuSub", ContextMenuSub = (props) => {
|
|
213
|
+
const { scope, children, onOpenChange, open: openProp, defaultOpen, ...rest } = props, [open, setOpen] = useControllableState({
|
|
214
|
+
prop: openProp,
|
|
215
|
+
defaultProp: defaultOpen,
|
|
216
|
+
onChange: onOpenChange
|
|
217
|
+
});
|
|
218
|
+
return /* @__PURE__ */ jsx(
|
|
219
|
+
Menu.Sub,
|
|
220
|
+
{
|
|
221
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
222
|
+
open,
|
|
223
|
+
onOpenChange: setOpen,
|
|
224
|
+
...rest,
|
|
225
|
+
children
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
ContextMenuSub.displayName = SUB_NAME;
|
|
230
|
+
const SUB_TRIGGER_NAME = "ContextMenuSubTrigger", ContextMenuSubTrigger = View.styleable(
|
|
231
|
+
(props, forwardedRef) => {
|
|
232
|
+
const { scope, ...subTriggerProps } = props;
|
|
233
|
+
return /* @__PURE__ */ jsx(
|
|
234
|
+
Menu.SubTrigger,
|
|
235
|
+
{
|
|
236
|
+
componentName: SUB_TRIGGER_NAME,
|
|
237
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
238
|
+
...subTriggerProps,
|
|
239
|
+
ref: forwardedRef
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
ContextMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
245
|
+
const SUB_CONTENT_NAME = "ContextMenuSubContent", ContextMenuSubContent = React.forwardRef((props, forwardedRef) => {
|
|
246
|
+
const { scope, ...subContentProps } = props;
|
|
247
|
+
return /* @__PURE__ */ jsx(
|
|
248
|
+
Menu.SubContent,
|
|
249
|
+
{
|
|
250
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
251
|
+
...subContentProps,
|
|
252
|
+
ref: forwardedRef,
|
|
253
|
+
style: isWeb ? {
|
|
254
|
+
...props.style,
|
|
255
|
+
"--tamagui-context-menu-content-transform-origin": "var(--tamagui-popper-transform-origin)",
|
|
256
|
+
"--tamagui-context-menu-content-available-width": "var(--tamagui-popper-available-width)",
|
|
257
|
+
"--tamagui-context-menu-content-available-height": "var(--tamagui-popper-available-height)",
|
|
258
|
+
"--tamagui-context-menu-trigger-width": "var(--tamagui-popper-anchor-width)",
|
|
259
|
+
"--tamagui-context-menu-trigger-height": "var(--tamagui-popper-anchor-height)"
|
|
260
|
+
} : null
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
ContextMenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
265
|
+
const ARROW_NAME = "ContextMenuArrow", ContextMenuArrow = React.forwardRef((props, forwardedRef) => {
|
|
266
|
+
const { scope, ...arrowProps } = props;
|
|
267
|
+
return /* @__PURE__ */ jsx(
|
|
268
|
+
Menu.Arrow,
|
|
269
|
+
{
|
|
270
|
+
componentName: ARROW_NAME,
|
|
271
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
272
|
+
...arrowProps,
|
|
273
|
+
ref: forwardedRef
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
ContextMenuArrow.displayName = ARROW_NAME;
|
|
278
|
+
const ContextMenuGroup = Menu.Group, ContextMenuLabel = Menu.Label, ContextMenuSeparator = Menu.Separator, ContextMenuItemTitle = Menu.ItemTitle, ContextMenuItemSubTitle = Menu.ItemSubtitle, ContextMenuItemImage = Menu.ItemImage, ContextMenuItemIcon = Menu.ItemIcon;
|
|
279
|
+
return withStaticProperties(ContextMenuComp, {
|
|
280
|
+
Root: ContextMenuComp,
|
|
281
|
+
Trigger: ContextMenuTrigger,
|
|
282
|
+
Portal: ContextMenuPortal,
|
|
283
|
+
Content: ContextMenuContent,
|
|
284
|
+
Group: ContextMenuGroup,
|
|
285
|
+
Label: ContextMenuLabel,
|
|
286
|
+
Item: ContextMenuItem,
|
|
287
|
+
CheckboxItem: ContextMenuCheckboxItem,
|
|
288
|
+
RadioGroup: ContextMenuRadioGroup,
|
|
289
|
+
RadioItem: ContextMenuRadioItem,
|
|
290
|
+
ItemIndicator: ContextMenuItemIndicator,
|
|
291
|
+
Separator: ContextMenuSeparator,
|
|
292
|
+
Arrow: ContextMenuArrow,
|
|
293
|
+
Sub: ContextMenuSub,
|
|
294
|
+
SubTrigger: ContextMenuSubTrigger,
|
|
295
|
+
SubContent: ContextMenuSubContent,
|
|
296
|
+
ItemTitle: ContextMenuItemTitle,
|
|
297
|
+
ItemSubtitle: ContextMenuItemSubTitle,
|
|
298
|
+
ItemIcon: ContextMenuItemIcon,
|
|
299
|
+
ItemImage: ContextMenuItemImage,
|
|
300
|
+
Preview: () => null
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
export {
|
|
304
|
+
CONTEXTMENU_CONTEXT,
|
|
305
|
+
createNonNativeContextMenu
|
|
306
|
+
};
|
|
307
|
+
//# sourceMappingURL=createNonNativeContextMenu.js.map
|