mantine-contextmenu 6.0.3 → 7.0.0-alpha.2
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 +31 -31
- package/dist/cjs/ContextMenu.js +64 -0
- package/dist/cjs/ContextMenu.js.map +1 -0
- package/dist/cjs/ContextMenuDivider.js +17 -0
- package/dist/cjs/ContextMenuDivider.js.map +1 -0
- package/dist/cjs/ContextMenuItem.js +58 -0
- package/dist/cjs/ContextMenuItem.js.map +1 -0
- package/dist/cjs/ContextMenuPortal.js +39 -0
- package/dist/cjs/ContextMenuPortal.js.map +1 -0
- package/dist/cjs/ContextMenuProvider.js +58 -0
- package/dist/cjs/ContextMenuProvider.js.map +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.js +16 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/css/styles.css +53 -0
- package/dist/css/styles.layer.css +61 -0
- package/dist/esm/ContextMenu.js +38 -0
- package/dist/esm/ContextMenu.js.map +1 -0
- package/dist/esm/ContextMenuDivider.js +9 -0
- package/dist/esm/ContextMenuDivider.js.map +1 -0
- package/dist/esm/ContextMenuItem.js +46 -0
- package/dist/esm/ContextMenuItem.js.map +1 -0
- package/dist/esm/ContextMenuPortal.js +12 -0
- package/dist/esm/ContextMenuPortal.js.map +1 -0
- package/dist/esm/ContextMenuProvider.js +41 -0
- package/dist/esm/ContextMenuProvider.js.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.js +12 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/{ContextMenu.d.ts → types/ContextMenu.d.ts} +1 -2
- package/dist/types/ContextMenuDivider.d.ts +3 -0
- package/dist/{ContextMenuItem.d.ts → types/ContextMenuItem.d.ts} +1 -3
- package/dist/{ContextMenuPortal.d.ts → types/ContextMenuPortal.d.ts} +0 -1
- package/dist/{ContextMenuProvider.d.ts → types/ContextMenuProvider.d.ts} +0 -1
- package/dist/{index.d.ts → types/index.d.ts} +2 -2
- package/dist/{types.d.ts → types/types.d.ts} +33 -19
- package/dist/{utils.d.ts → types/utils.d.ts} +0 -4
- package/package.json +56 -19
- package/LICENSE +0 -21
- package/dist/ContextMenu.d.ts.map +0 -1
- package/dist/ContextMenuDivider.d.ts +0 -9
- package/dist/ContextMenuDivider.d.ts.map +0 -1
- package/dist/ContextMenuItem.d.ts.map +0 -1
- package/dist/ContextMenuPortal.d.ts.map +0 -1
- package/dist/ContextMenuProvider.d.ts.map +0 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -7
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
# Mantine ContextMenu
|
|
1
|
+
# Mantine ContextMenu
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
**⏳ Mantine V7 support is in the roadmap.**
|
|
5
|
-
**❤️ If you want to speed up the process, please consider [sponsoring my work](https://github.com/sponsors/icflorescu).**
|
|
6
|
-
|
|
7
|
-

|
|
3
|
+

|
|
8
4
|
[![NPM version][npm-image]][npm-url]
|
|
9
5
|
[![License][license-image]][license-url]
|
|
10
6
|
[![Stars][stars-image]][stars-url]
|
|
@@ -16,43 +12,47 @@
|
|
|
16
12
|
|
|
17
13
|
The "dark-theme aware" **context-menu** for your Mantine UI applications, built by the creator of [Mantine DataTable](https://icflorescu.github.io/mantine-datatable/).
|
|
18
14
|
|
|
19
|
-
[](https://icflorescu.github.io/mantine-contextmenu
|
|
15
|
+
[](https://icflorescu.github.io/mantine-contextmenu/)
|
|
16
|
+
|
|
17
|
+
**⚠️ NOTE: Mantine ContextMenu V7 is compatible with Mantine V7.**
|
|
18
|
+
**💡 If you're looking for an older version that works with Mantine V6, head over to [Mantine ContextMenu V6](https://icflorescu.github.io/mantine-contextmenu-v6).**
|
|
20
19
|
|
|
21
20
|
## Features
|
|
22
21
|
|
|
23
|
-
- **Lightweight** - no external dependencies, [no bloat](https://bundlephobia.com/package/mantine-contextmenu
|
|
22
|
+
- **Lightweight** - no external dependencies, [no bloat](https://bundlephobia.com/package/mantine-contextmenu)
|
|
24
23
|
- **Dark-theme aware** - automatically adapts to the current Mantine theme
|
|
25
|
-
- **[Simple API](https://icflorescu.github.io/mantine-contextmenu
|
|
26
|
-
- **[Custom content support](https://icflorescu.github.io/mantine-contextmenu
|
|
27
|
-
- **[Highly customizable styling](https://icflorescu.github.io/mantine-contextmenu
|
|
28
|
-
- **[Written in Typescript and well-documented](https://icflorescu.github.io/mantine-contextmenu
|
|
24
|
+
- **[Simple API](https://icflorescu.github.io/mantine-contextmenu/getting-started)** - just wrap your application in the `ContextMenuProvider` component and use the hook-generated function in your code
|
|
25
|
+
- **[Custom content support](https://icflorescu.github.io/mantine-contextmenu/examples/custom-content)** - use any Mantine component as context menu content
|
|
26
|
+
- **[Highly customizable styling](https://icflorescu.github.io/mantine-contextmenu/examples/styling)** - use the `className`/`classNames` and `style`/`styles` props to customize the context menu appearance
|
|
27
|
+
- **[Written in Typescript and well-documented](https://icflorescu.github.io/mantine-contextmenu/type-definitions)** - with detailed JSDoc annotations for each exported function and component
|
|
29
28
|
|
|
30
29
|
## Full documentation and examples
|
|
31
30
|
|
|
32
|
-
Visit [icflorescu.github.io/mantine-contextmenu
|
|
31
|
+
Visit [icflorescu.github.io/mantine-contextmenu](https://icflorescu.github.io/mantine-contextmenu/) to view the full documentation and learn how to use it by browsing the list of usage examples.
|
|
33
32
|
|
|
34
33
|
## Quickstart
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
Create a new [Mantine application](https://mantine.dev/pages/getting-started/), then install the package:
|
|
37
36
|
|
|
38
37
|
```sh
|
|
39
|
-
npm i
|
|
38
|
+
npm i mantine-contextmenu
|
|
40
39
|
```
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Wrap your application in the `ContextMenuProvider` components:
|
|
41
|
+
Wrap your application in a `ContextMenuProvider` **inside** the `MantineProvider` and don't forget to import the necessary CSS files [in the correct order](https://mantine.dev/styles/mantine-styles/) (you [might need to use CSS layers](https://mantine.dev/styles/mantine-styles/#css-layers)):
|
|
45
42
|
|
|
46
43
|
```tsx
|
|
47
44
|
import { MantineProvider } from '@mantine/core';
|
|
48
45
|
import { ContextMenuProvider } from 'mantine-contextmenu';
|
|
49
46
|
|
|
47
|
+
// 👇 Mantine core first
|
|
48
|
+
import '@mantine/core/styles.css';
|
|
49
|
+
// 👇 Mantine context menu second
|
|
50
|
+
import 'mantine-contextmenu/styles.css';
|
|
51
|
+
|
|
50
52
|
function App() {
|
|
51
53
|
return (
|
|
52
54
|
<MantineProvider>
|
|
53
|
-
<ContextMenuProvider>
|
|
54
|
-
{/* your app code here... */}
|
|
55
|
-
</ContextMenuProvider>
|
|
55
|
+
<ContextMenuProvider>{/* your app code here... */}</ContextMenuProvider>
|
|
56
56
|
</MantineProvider>
|
|
57
57
|
);
|
|
58
58
|
}
|
|
@@ -94,7 +94,7 @@ export default function GettingStartedExample() {
|
|
|
94
94
|
}
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
Make sure to browse the list of [usage examples](https://icflorescu.github.io/mantine-contextmenu
|
|
97
|
+
Make sure to browse the list of [usage examples](https://icflorescu.github.io/mantine-contextmenu/examples/basic-usage) to learn how to unleash the full power of Mantine ContextMenu.
|
|
98
98
|
|
|
99
99
|
## Other useful resources
|
|
100
100
|
|
|
@@ -102,9 +102,9 @@ Make sure to browse the list of [usage examples](https://icflorescu.github.io/ma
|
|
|
102
102
|
|
|
103
103
|
## Code contributors
|
|
104
104
|
|
|
105
|
-
[](https://github.com/icflorescu/mantine-contextmenu/graphs/contributors)
|
|
106
106
|
|
|
107
|
-
Want to [become a code contributor](https://icflorescu.github.io/mantine-contextmenu
|
|
107
|
+
Want to [become a code contributor](https://icflorescu.github.io/mantine-contextmenu/contribute-and-support)?
|
|
108
108
|
|
|
109
109
|
## Sponsor the project
|
|
110
110
|
|
|
@@ -129,19 +129,19 @@ Mentioning “Mantine ContextMenu” in your text would help me prioritize your
|
|
|
129
129
|
|
|
130
130
|
## License
|
|
131
131
|
|
|
132
|
-
The [MIT License](https://github.com/icflorescu/mantine-contextmenu
|
|
132
|
+
The [MIT License](https://github.com/icflorescu/mantine-contextmenu/blob/master/LICENSE).
|
|
133
133
|
|
|
134
134
|
[npm-url]: https://npmjs.org/package/mantine-contextmenu
|
|
135
|
-
[repo-url]: https://github.com/icflorescu/mantine-contextmenu
|
|
136
|
-
[stars-url]: https://github.com/icflorescu/mantine-contextmenu
|
|
137
|
-
[closed-issues-url]: https://github.com/icflorescu/mantine-contextmenu
|
|
135
|
+
[repo-url]: https://github.com/icflorescu/mantine-contextmenu
|
|
136
|
+
[stars-url]: https://github.com/icflorescu/mantine-contextmenu/stargazers
|
|
137
|
+
[closed-issues-url]: https://github.com/icflorescu/mantine-contextmenu/issues?q=is%3Aissue+is%3Aclosed
|
|
138
138
|
[license-url]: LICENSE
|
|
139
139
|
[npm-image]: https://img.shields.io/npm/v/mantine-contextmenu.svg?style=flat-square
|
|
140
140
|
[license-image]: http://img.shields.io/npm/l/mantine-contextmenu.svg?style=flat-square
|
|
141
141
|
[downloads-image]: http://img.shields.io/npm/dm/mantine-contextmenu.svg?style=flat-square
|
|
142
142
|
[stars-image]: https://img.shields.io/github/stars/icflorescu/mantine-contextmenu?style=flat-square
|
|
143
|
-
[last-commit-image]: https://img.shields.io/github/last-commit/icflorescu/mantine-contextmenu
|
|
144
|
-
[closed-issues-image]: https://img.shields.io/github/issues-closed-raw/icflorescu/mantine-contextmenu
|
|
145
|
-
[language-image]: https://img.shields.io/github/languages/top/icflorescu/mantine-contextmenu
|
|
143
|
+
[last-commit-image]: https://img.shields.io/github/last-commit/icflorescu/mantine-contextmenu?style=flat-square
|
|
144
|
+
[closed-issues-image]: https://img.shields.io/github/issues-closed-raw/icflorescu/mantine-contextmenu?style=flat-square
|
|
145
|
+
[language-image]: https://img.shields.io/github/languages/top/icflorescu/mantine-contextmenu?style=flat-square
|
|
146
146
|
[sponsor-image]: https://img.shields.io/badge/sponsor-violet?style=flat-square
|
|
147
147
|
[sponsor-url]: https://github.com/sponsors/icflorescu
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
15
|
+
var t = {};
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
19
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
20
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
21
|
+
t[p[i]] = s[p[i]];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ContextMenu = void 0;
|
|
30
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
var core_1 = require("@mantine/core");
|
|
32
|
+
var hooks_1 = require("@mantine/hooks");
|
|
33
|
+
var clsx_1 = __importDefault(require("clsx"));
|
|
34
|
+
var ContextMenuDivider_1 = require("./ContextMenuDivider");
|
|
35
|
+
var ContextMenuItem_1 = require("./ContextMenuItem");
|
|
36
|
+
var utils_1 = require("./utils");
|
|
37
|
+
function ContextMenu(_a) {
|
|
38
|
+
var _b;
|
|
39
|
+
var x = _a.x, y = _a.y, content = _a.content, zIndex = _a.zIndex, shadow = _a.shadow, borderRadius = _a.borderRadius, onHide = _a.onHide, className = _a.className, style = _a.style, classNames = _a.classNames, styles = _a.styles;
|
|
40
|
+
var paperRef = (0, hooks_1.useResizeObserver)()[0];
|
|
41
|
+
var _c = ((_b = paperRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) || { width: 0, height: 0 }, width = _c.width, height = _c.height;
|
|
42
|
+
var windowWidth = 0;
|
|
43
|
+
var windowHeight = 0;
|
|
44
|
+
if (typeof window !== 'undefined')
|
|
45
|
+
(windowWidth = window.innerWidth, windowHeight = window.innerHeight);
|
|
46
|
+
var dir = (0, core_1.useDirection)().dir;
|
|
47
|
+
var theme = (0, core_1.useMantineTheme)();
|
|
48
|
+
var resolvedStyle = typeof style === 'function' ? style(theme) : style;
|
|
49
|
+
var resolvedStyles = typeof styles === 'function' ? styles(theme) : styles;
|
|
50
|
+
var mdSpacing = (0, core_1.px)(theme.spacing.md);
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(core_1.Paper, { ref: paperRef, shadow: shadow, radius: borderRadius, className: (0, clsx_1.default)('mantine-contextmenu', className, classNames === null || classNames === void 0 ? void 0 : classNames.root), style: __assign(__assign(__assign({}, resolvedStyles === null || resolvedStyles === void 0 ? void 0 : resolvedStyles.root), resolvedStyle), { zIndex: zIndex, top: y + height + mdSpacing > windowHeight ? windowHeight - height - mdSpacing : y, left: dir === 'ltr'
|
|
52
|
+
? x + width + mdSpacing > windowWidth
|
|
53
|
+
? windowWidth - width - mdSpacing
|
|
54
|
+
: x
|
|
55
|
+
: windowWidth - mdSpacing - (x - width - mdSpacing < 0 ? width + mdSpacing : x) }), children: Array.isArray(content)
|
|
56
|
+
? content.map(function (_a) {
|
|
57
|
+
var key = _a.key, className = _a.className, style = _a.style, onClick = _a.onClick, items = _a.items, title = _a.title, otherOptions = __rest(_a, ["key", "className", "style", "onClick", "items", "title"]);
|
|
58
|
+
var resolvedItemStyle = typeof style === 'function' ? style(theme) : style;
|
|
59
|
+
return onClick || items ? ((0, jsx_runtime_1.jsx)(ContextMenuItem_1.ContextMenuItem, __assign({ className: (0, clsx_1.default)(classNames === null || classNames === void 0 ? void 0 : classNames.item, className), style: __assign(__assign({}, resolvedStyles === null || resolvedStyles === void 0 ? void 0 : resolvedStyles.item), resolvedItemStyle), title: title !== null && title !== void 0 ? title : (0, utils_1.humanize)(key), onClick: onClick, onHide: onHide, items: items }, otherOptions), key)) : ((0, jsx_runtime_1.jsx)(ContextMenuDivider_1.ContextMenuDivider, { className: (0, clsx_1.default)(classNames === null || classNames === void 0 ? void 0 : classNames.divider, className), style: __assign(__assign({}, resolvedStyles === null || resolvedStyles === void 0 ? void 0 : resolvedStyles.divider), resolvedItemStyle) }, key));
|
|
60
|
+
})
|
|
61
|
+
: content(onHide) }));
|
|
62
|
+
}
|
|
63
|
+
exports.ContextMenu = ContextMenu;
|
|
64
|
+
//# sourceMappingURL=ContextMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../package/ContextMenu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,sCAAyE;AACzE,wCAAmD;AACnD,8CAAwB;AACxB,2DAA0D;AAC1D,qDAAoD;AAEpD,iCAAmC;AAanC,SAAgB,WAAW,CAAC,EAYT;;QAX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,KAAK,cAAL,KAAK,GAAI,IAAA,gBAAQ,EAAC,GAAG,CAAC,EAC7B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,IACR,YAAY,GAPX,GAAG,CAQR,CACH,CAAC,CAAC,CAAC,CACF,uBAAC,uCAAkB,IAEjB,SAAS,EAAE,IAAA,cAAI,EAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,EAAE,SAAS,CAAC,EAC/C,KAAK,wBAAO,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,GAAK,iBAAiB,KAFpD,GAAG,CAGR,CACH,CAAC;YACJ,CAAC,CAAC;YACJ,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GACb,CACT,CAAC;AACJ,CAAC;AAtED,kCAsEC","sourcesContent":["'use client';\n\nimport { Paper, px, useDirection, useMantineTheme } from '@mantine/core';\nimport { useResizeObserver } from '@mantine/hooks';\nimport clsx from 'clsx';\nimport { ContextMenuDivider } from './ContextMenuDivider';\nimport { ContextMenuItem } from './ContextMenuItem';\nimport type { ContextMenuContent, ContextMenuOptions } from './types';\nimport { humanize } from './utils';\n\nexport type ContextMenuInstanceOptions = {\n x: number;\n y: number;\n content: ContextMenuContent;\n};\n\nexport type ContextMenuProps = ContextMenuOptions &\n ContextMenuInstanceOptions & {\n onHide: () => void;\n };\n\nexport function ContextMenu({\n x,\n y,\n content,\n zIndex,\n shadow,\n borderRadius,\n onHide,\n className,\n style,\n classNames,\n styles,\n}: ContextMenuProps) {\n const [paperRef] = useResizeObserver<HTMLDivElement>();\n const { width, height } = paperRef.current?.getBoundingClientRect() || { width: 0, height: 0 };\n\n let windowWidth = 0;\n let windowHeight = 0;\n if (typeof window !== 'undefined') ({ innerWidth: windowWidth, innerHeight: windowHeight } = window);\n\n const { dir } = useDirection();\n const theme = useMantineTheme();\n const resolvedStyle = typeof style === 'function' ? style(theme) : style;\n const resolvedStyles = typeof styles === 'function' ? styles(theme) : styles;\n const mdSpacing = px(theme.spacing.md) as number;\n\n return (\n <Paper\n ref={paperRef}\n shadow={shadow}\n radius={borderRadius}\n className={clsx('mantine-contextmenu', className, classNames?.root)}\n style={{\n ...resolvedStyles?.root,\n ...resolvedStyle,\n zIndex,\n top: y + height + mdSpacing > windowHeight ? windowHeight - height - mdSpacing : y,\n left:\n dir === 'ltr'\n ? x + width + mdSpacing > windowWidth\n ? windowWidth - width - mdSpacing\n : x\n : windowWidth - mdSpacing - (x - width - mdSpacing < 0 ? width + mdSpacing : x),\n }}\n >\n {Array.isArray(content)\n ? content.map(({ key, className, style, onClick, items, title, ...otherOptions }) => {\n const resolvedItemStyle = typeof style === 'function' ? style(theme) : style;\n return onClick || items ? (\n <ContextMenuItem\n key={key}\n className={clsx(classNames?.item, className)}\n style={{ ...resolvedStyles?.item, ...resolvedItemStyle }}\n title={title ?? humanize(key)}\n onClick={onClick}\n onHide={onHide}\n items={items}\n {...otherOptions}\n />\n ) : (\n <ContextMenuDivider\n key={key}\n className={clsx(classNames?.divider, className)}\n style={{ ...resolvedStyles?.divider, ...resolvedItemStyle }}\n />\n );\n })\n : content(onHide)}\n </Paper>\n );\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ContextMenuDivider = void 0;
|
|
8
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
var core_1 = require("@mantine/core");
|
|
10
|
+
var clsx_1 = __importDefault(require("clsx"));
|
|
11
|
+
function ContextMenuDivider(_a) {
|
|
12
|
+
var className = _a.className, style = _a.style;
|
|
13
|
+
var theme = (0, core_1.useMantineTheme)();
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(core_1.Box, { className: (0, clsx_1.default)('mantine-contextmenu-divider', className), style: typeof style === 'function' ? style(theme) : style }));
|
|
15
|
+
}
|
|
16
|
+
exports.ContextMenuDivider = ContextMenuDivider;
|
|
17
|
+
//# sourceMappingURL=ContextMenuDivider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenuDivider.js","sourceRoot":"","sources":["../../package/ContextMenuDivider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,sCAAqD;AACrD,8CAAwB;AAKxB,SAAgB,kBAAkB,CAAC,EAA6C;QAA3C,SAAS,eAAA,EAAE,KAAK,WAAA;IACnD,IAAM,KAAK,GAAG,IAAA,sBAAe,GAAE,CAAC;IAChC,OAAO,CACL,uBAAC,UAAG,IACF,SAAS,EAAE,IAAA,cAAI,EAAC,6BAA6B,EAAE,SAAS,CAAC,EACzD,KAAK,EAAE,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GACzD,CACH,CAAC;AACJ,CAAC;AARD,gDAQC","sourcesContent":["'use client';\n\nimport { Box, useMantineTheme } from '@mantine/core';\nimport clsx from 'clsx';\nimport type { ContextMenuItemOptions } from './types';\n\nexport type ContextMenuDividerProps = Pick<ContextMenuItemOptions, 'className' | 'style'>;\n\nexport function ContextMenuDivider({ className, style }: ContextMenuDividerProps) {\n const theme = useMantineTheme();\n return (\n <Box\n className={clsx('mantine-contextmenu-divider', className)}\n style={typeof style === 'function' ? style(theme) : style}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ContextMenuItem = void 0;
|
|
19
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
20
|
+
var core_1 = require("@mantine/core");
|
|
21
|
+
var clsx_1 = __importDefault(require("clsx"));
|
|
22
|
+
var react_1 = require("react");
|
|
23
|
+
var ContextMenu_1 = require("./ContextMenu");
|
|
24
|
+
function ContextMenuItem(_a) {
|
|
25
|
+
var className = _a.className, style = _a.style, icon = _a.icon, title = _a.title, color = _a.color, disabled = _a.disabled, onClick = _a.onClick, onHide = _a.onHide, items = _a.items;
|
|
26
|
+
var ref = (0, react_1.useRef)(null);
|
|
27
|
+
var _b = (0, react_1.useState)(null), submenuPosition = _b[0], setSubmenuPosition = _b[1];
|
|
28
|
+
var handleClick = onClick
|
|
29
|
+
? function (e) {
|
|
30
|
+
onHide();
|
|
31
|
+
onClick(e);
|
|
32
|
+
}
|
|
33
|
+
: undefined;
|
|
34
|
+
var showSubmenu = function () {
|
|
35
|
+
var _a = ref.current.getBoundingClientRect(), y = _a.top, x = _a.right;
|
|
36
|
+
setSubmenuPosition({ x: x, y: y });
|
|
37
|
+
};
|
|
38
|
+
var hideSubmenu = function () {
|
|
39
|
+
setSubmenuPosition(null);
|
|
40
|
+
};
|
|
41
|
+
var hasItemsAndIsNotDisabled = items && !disabled;
|
|
42
|
+
var theme = (0, core_1.useMantineTheme)();
|
|
43
|
+
var colors = theme.colors;
|
|
44
|
+
var parsedColor = color ? (0, core_1.parseThemeColor)({ color: color, theme: theme }).value : undefined;
|
|
45
|
+
if (color === 'red')
|
|
46
|
+
console.log(parsedColor);
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)("div", { onMouseOver: hasItemsAndIsNotDisabled ? showSubmenu : undefined, onMouseOut: hasItemsAndIsNotDisabled ? hideSubmenu : undefined, children: [(0, jsx_runtime_1.jsxs)(core_1.UnstyledButton, { ref: ref, style: __assign({ '--mantine-contextmenu-item-button-color': parsedColor ? parsedColor : 'var(--mantine-color-text)', '--mantine-contextmenu-item-button-hover-bg-color-light': parsedColor
|
|
48
|
+
? (0, core_1.rgba)(parsedColor, 0.08)
|
|
49
|
+
: (0, core_1.rgba)(colors.gray[4], 0.25), '--mantine-contextmenu-item-button-hover-bg-color-dark': parsedColor
|
|
50
|
+
? (0, core_1.rgba)(parsedColor, 0.15)
|
|
51
|
+
: (0, core_1.rgba)(colors.dark[3], 0.25), '--mantine-contextmenu-item-button-pressed-bg-color-light': parsedColor
|
|
52
|
+
? (0, core_1.rgba)(parsedColor, 0.2)
|
|
53
|
+
: (0, core_1.rgba)(colors.gray[4], 0.5), '--mantine-contextmenu-item-button-pressed-bg-color-dark': parsedColor
|
|
54
|
+
? (0, core_1.rgba)(parsedColor, 0.3)
|
|
55
|
+
: (0, core_1.rgba)(colors.dark[3], 0.5) }, (typeof style === 'function' ? style(theme) : style)), className: (0, clsx_1.default)('mantine-contextmenu-item-button', className), disabled: disabled, onClick: handleClick, children: [icon && ((0, jsx_runtime_1.jsx)(core_1.Box, { fz: 0, mr: "xs", mt: -2, children: icon })), (0, jsx_runtime_1.jsx)("div", { className: "mantine-contextmenu-item-button-title", children: title }), items && ((0, jsx_runtime_1.jsx)(core_1.Box, { fz: 10, mt: -2, ml: "xs", children: "\u25B6" }))] }), submenuPosition && (0, jsx_runtime_1.jsx)(ContextMenu_1.ContextMenu, __assign({ content: items, onHide: onHide }, submenuPosition))] }));
|
|
56
|
+
}
|
|
57
|
+
exports.ContextMenuItem = ContextMenuItem;
|
|
58
|
+
//# sourceMappingURL=ContextMenuItem.js.map
|
|
@@ -0,0 +1 @@
|
|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AAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAEzD,SAAS,EAAE,IAAA,cAAI,EAAC,iCAAiC,EAAE,SAAS,CAAC,EAC7D,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,WAAW,aAEnB,IAAI,IAAI,CACP,uBAAC,UAAG,IAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAC,IAAI,EAAC,EAAE,EAAE,CAAC,CAAC,YACvB,IAAI,GACD,CACP,EACD,gCAAK,SAAS,EAAC,uCAAuC,YAAE,KAAK,GAAO,EACnE,KAAK,IAAI,CACR,uBAAC,UAAG,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAC,IAAI,uBAEtB,CACP,IACc,EAChB,eAAe,IAAI,uBAAC,yBAAW,aAAC,OAAO,EAAE,KAA2B,EAAE,MAAM,EAAE,MAAM,IAAM,eAAe,EAAI,IAC1G,CACP,CAAC;AACJ,CAAC;AA/ED,0CA+EC","sourcesContent":["'use client';\n\nimport { Box, UnstyledButton, parseThemeColor, rgba, useMantineTheme } from '@mantine/core';\nimport clsx from 'clsx';\nimport { useRef, useState, type MouseEventHandler } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport type { ContextMenuContent, ContextMenuItemOptions, WithRequiredProperty } from './types';\n\nexport function ContextMenuItem({\n className,\n style,\n icon,\n title,\n color,\n disabled,\n onClick,\n onHide,\n items,\n}: WithRequiredProperty<Omit<ContextMenuItemOptions, 'key'>, 'title'> & { onHide: () => void }) {\n const ref = useRef<HTMLButtonElement>(null);\n const [submenuPosition, setSubmenuPosition] = useState<{ x: number; y: number } | null>(null);\n\n const handleClick: MouseEventHandler<HTMLButtonElement> | undefined = onClick\n ? (e) => {\n onHide();\n onClick!(e);\n }\n : undefined;\n\n const showSubmenu = () => {\n const { top: y, right: x } = ref.current!.getBoundingClientRect();\n setSubmenuPosition({ x, y });\n };\n\n const hideSubmenu = () => {\n setSubmenuPosition(null);\n };\n\n const hasItemsAndIsNotDisabled = items && !disabled;\n\n const theme = useMantineTheme();\n const { colors } = theme;\n const parsedColor = color ? parseThemeColor({ color, theme }).value : undefined;\n if (color === 'red') console.log(parsedColor);\n\n return (\n <div\n onMouseOver={hasItemsAndIsNotDisabled ? showSubmenu : undefined}\n onMouseOut={hasItemsAndIsNotDisabled ? hideSubmenu : undefined}\n >\n <UnstyledButton\n ref={ref}\n style={{\n '--mantine-contextmenu-item-button-color': parsedColor ? parsedColor : 'var(--mantine-color-text)',\n '--mantine-contextmenu-item-button-hover-bg-color-light': parsedColor\n ? rgba(parsedColor, 0.08)\n : rgba(colors.gray[4], 0.25),\n '--mantine-contextmenu-item-button-hover-bg-color-dark': parsedColor\n ? rgba(parsedColor, 0.15)\n : rgba(colors.dark[3], 0.25),\n '--mantine-contextmenu-item-button-pressed-bg-color-light': parsedColor\n ? rgba(parsedColor, 0.2)\n : rgba(colors.gray[4], 0.5),\n '--mantine-contextmenu-item-button-pressed-bg-color-dark': parsedColor\n ? rgba(parsedColor, 0.3)\n : rgba(colors.dark[3], 0.5),\n ...(typeof style === 'function' ? style(theme) : style),\n }}\n className={clsx('mantine-contextmenu-item-button', className)}\n disabled={disabled}\n onClick={handleClick}\n >\n {icon && (\n <Box fz={0} mr=\"xs\" mt={-2}>\n {icon}\n </Box>\n )}\n <div className=\"mantine-contextmenu-item-button-title\">{title}</div>\n {items && (\n <Box fz={10} mt={-2} ml=\"xs\">\n ▶\n </Box>\n )}\n </UnstyledButton>\n {submenuPosition && <ContextMenu content={items as ContextMenuContent} onHide={onHide} {...submenuPosition} />}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
15
|
+
var t = {};
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
17
|
+
t[p] = s[p];
|
|
18
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
19
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
20
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
21
|
+
t[p[i]] = s[p[i]];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ContextMenuPortal = void 0;
|
|
27
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
var core_1 = require("@mantine/core");
|
|
29
|
+
var hooks_1 = require("@mantine/hooks");
|
|
30
|
+
var ContextMenu_1 = require("./ContextMenu");
|
|
31
|
+
function ContextMenuPortal(_a) {
|
|
32
|
+
var onHide = _a.onHide, otherProps = __rest(_a, ["onHide"]);
|
|
33
|
+
(0, hooks_1.useWindowEvent)('resize', onHide);
|
|
34
|
+
(0, hooks_1.useWindowEvent)('scroll', onHide);
|
|
35
|
+
var ref = (0, hooks_1.useClickOutside)(onHide);
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(core_1.Portal, { ref: ref, children: (0, jsx_runtime_1.jsx)(ContextMenu_1.ContextMenu, __assign({}, otherProps, { onHide: onHide })) }));
|
|
37
|
+
}
|
|
38
|
+
exports.ContextMenuPortal = ContextMenuPortal;
|
|
39
|
+
//# sourceMappingURL=ContextMenuPortal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenuPortal.js","sourceRoot":"","sources":["../../package/ContextMenuPortal.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,sCAAuC;AACvC,wCAAiE;AACjE,6CAAmE;AAEnE,SAAgB,iBAAiB,CAAC,EAA2C;IAAzC,IAAA,MAAM,YAAA,EAAK,UAAU,cAAvB,UAAyB,CAAF;IACvD,IAAA,sBAAc,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjC,IAAA,sBAAc,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjC,IAAM,GAAG,GAAG,IAAA,uBAAe,EAAC,MAAM,CAAC,CAAC;IAEpC,OAAO,CACL,uBAAC,aAAM,IAAC,GAAG,EAAE,GAAG,YACd,uBAAC,yBAAW,eAAK,UAAU,IAAE,MAAM,EAAE,MAAM,IAAI,GACxC,CACV,CAAC;AACJ,CAAC;AAVD,8CAUC","sourcesContent":["'use client';\n\nimport { Portal } from '@mantine/core';\nimport { useClickOutside, useWindowEvent } from '@mantine/hooks';\nimport { ContextMenu, type ContextMenuProps } from './ContextMenu';\n\nexport function ContextMenuPortal({ onHide, ...otherProps }: ContextMenuProps) {\n useWindowEvent('resize', onHide);\n useWindowEvent('scroll', onHide);\n const ref = useClickOutside(onHide);\n\n return (\n <Portal ref={ref}>\n <ContextMenu {...otherProps} onHide={onHide} />\n </Portal>\n );\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.useContextMenu = exports.ContextMenuProvider = void 0;
|
|
16
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
17
|
+
var core_1 = require("@mantine/core");
|
|
18
|
+
var react_1 = require("react");
|
|
19
|
+
var ContextMenuPortal_1 = require("./ContextMenuPortal");
|
|
20
|
+
var MenuContext = (0, react_1.createContext)(function () { return function () { return undefined; }; });
|
|
21
|
+
/**
|
|
22
|
+
* Provider that allows to show a context menu anywhere in your application.
|
|
23
|
+
* If you wrap your application with this provider, you can use the `useContextMenu` hook
|
|
24
|
+
* anywhere in the component tree to access a function that shows the context menu.
|
|
25
|
+
*/
|
|
26
|
+
function ContextMenuProvider(_a) {
|
|
27
|
+
var _b = _a.zIndex, zIndex = _b === void 0 ? 9999 : _b, _c = _a.shadow, shadow = _c === void 0 ? 'sm' : _c, _d = _a.borderRadius, borderRadius = _d === void 0 ? 'xs' : _d, children = _a.children;
|
|
28
|
+
var _e = (0, react_1.useState)(null), data = _e[0], setData = _e[1];
|
|
29
|
+
var destroy = function () {
|
|
30
|
+
setData(null);
|
|
31
|
+
};
|
|
32
|
+
var showContextMenu = function (content, options) { return function (e) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
setData({
|
|
36
|
+
x: e.clientX,
|
|
37
|
+
y: e.clientY,
|
|
38
|
+
content: content,
|
|
39
|
+
zIndex: (options === null || options === void 0 ? void 0 : options.zIndex) || zIndex,
|
|
40
|
+
shadow: (options === null || options === void 0 ? void 0 : options.shadow) || shadow,
|
|
41
|
+
borderRadius: (options === null || options === void 0 ? void 0 : options.borderRadius) || borderRadius,
|
|
42
|
+
className: options === null || options === void 0 ? void 0 : options.className,
|
|
43
|
+
style: options === null || options === void 0 ? void 0 : options.style,
|
|
44
|
+
classNames: options === null || options === void 0 ? void 0 : options.classNames,
|
|
45
|
+
styles: options === null || options === void 0 ? void 0 : options.styles,
|
|
46
|
+
});
|
|
47
|
+
}; };
|
|
48
|
+
return ((0, jsx_runtime_1.jsxs)(MenuContext.Provider, { value: showContextMenu, children: [children, (0, jsx_runtime_1.jsx)(core_1.MantineProvider, { children: data && (0, jsx_runtime_1.jsx)(ContextMenuPortal_1.ContextMenuPortal, __assign({ onHide: destroy }, data)) })] }));
|
|
49
|
+
}
|
|
50
|
+
exports.ContextMenuProvider = ContextMenuProvider;
|
|
51
|
+
/**
|
|
52
|
+
* Hook returning a function that shows a context menu.
|
|
53
|
+
*/
|
|
54
|
+
function useContextMenu() {
|
|
55
|
+
return (0, react_1.useContext)(MenuContext);
|
|
56
|
+
}
|
|
57
|
+
exports.useContextMenu = useContextMenu;
|
|
58
|
+
//# sourceMappingURL=ContextMenuProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenuProvider.js","sourceRoot":"","sources":["../../package/ContextMenuProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;AAEb,sCAAgD;AAChD,+BAA4D;AAE5D,yDAAwD;AAGxD,IAAM,WAAW,GAAG,IAAA,qBAAa,EAA0B,cAAM,OAAA,cAAM,OAAA,SAAS,EAAT,CAAS,EAAf,CAAe,CAAC,CAAC;AAElF;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,EAKT;QAJzB,cAAa,EAAb,MAAM,mBAAG,IAAI,KAAA,EACb,cAAa,EAAb,MAAM,mBAAG,IAAI,KAAA,EACb,oBAAmB,EAAnB,YAAY,mBAAG,IAAI,KAAA,EACnB,QAAQ,cAAA;IAEF,IAAA,KAAkB,IAAA,gBAAQ,EAA2D,IAAI,CAAC,EAAzF,IAAI,QAAA,EAAE,OAAO,QAA4E,CAAC;IAEjG,IAAM,OAAO,GAAG;QACd,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC,CAAC;IAEF,IAAM,eAAe,GAA4B,UAAC,OAAO,EAAE,OAAO,IAAK,OAAA,UAAC,CAAC;QACvE,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,OAAO,CAAC;YACN,CAAC,EAAE,CAAC,CAAC,OAAO;YACZ,CAAC,EAAE,CAAC,CAAC,OAAO;YACZ,OAAO,SAAA;YACP,MAAM,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,KAAI,MAAM;YACjC,MAAM,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,KAAI,MAAM;YACjC,YAAY,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,KAAI,YAAY;YACnD,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS;YAC7B,KAAK,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK;YACrB,UAAU,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;YAC/B,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;SACxB,CAAC,CAAC;IACL,CAAC,EAfsE,CAetE,CAAC;IAEF,OAAO,CACL,wBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,aACzC,QAAQ,EACT,uBAAC,sBAAe,cAAE,IAAI,IAAI,uBAAC,qCAAiB,aAAC,MAAM,EAAE,OAAO,IAAM,IAAI,EAAI,GAAmB,IACxE,CACxB,CAAC;AACJ,CAAC;AAnCD,kDAmCC;AAED;;GAEG;AACH,SAAgB,cAAc;IAC5B,OAAO,IAAA,kBAAU,EAAC,WAAW,CAAC,CAAC;AACjC,CAAC;AAFD,wCAEC","sourcesContent":["'use client';\n\nimport { MantineProvider } from '@mantine/core';\nimport { createContext, useContext, useState } from 'react';\nimport { ContextMenuInstanceOptions } from './ContextMenu';\nimport { ContextMenuPortal } from './ContextMenuPortal';\nimport type { ContextMenuOptions, ContextMenuProviderProps, ShowContextMenuFunction } from './types';\n\nconst MenuContext = createContext<ShowContextMenuFunction>(() => () => undefined);\n\n/**\n * Provider that allows to show a context menu anywhere in your application.\n * If you wrap your application with this provider, you can use the `useContextMenu` hook\n * anywhere in the component tree to access a function that shows the context menu.\n */\nexport function ContextMenuProvider({\n zIndex = 9999,\n shadow = 'sm',\n borderRadius = 'xs',\n children,\n}: ContextMenuProviderProps) {\n const [data, setData] = useState<(ContextMenuInstanceOptions & ContextMenuOptions) | null>(null);\n\n const destroy = () => {\n setData(null);\n };\n\n const showContextMenu: ShowContextMenuFunction = (content, options) => (e) => {\n e.preventDefault();\n e.stopPropagation();\n setData({\n x: e.clientX,\n y: e.clientY,\n content,\n zIndex: options?.zIndex || zIndex,\n shadow: options?.shadow || shadow,\n borderRadius: options?.borderRadius || borderRadius,\n className: options?.className,\n style: options?.style,\n classNames: options?.classNames,\n styles: options?.styles,\n });\n };\n\n return (\n <MenuContext.Provider value={showContextMenu}>\n {children}\n <MantineProvider>{data && <ContextMenuPortal onHide={destroy} {...data} />}</MantineProvider>\n </MenuContext.Provider>\n );\n}\n\n/**\n * Hook returning a function that shows a context menu.\n */\nexport function useContextMenu() {\n return useContext(MenuContext);\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ContextMenuDivider"), exports);
|
|
18
|
+
__exportStar(require("./ContextMenuItem"), exports);
|
|
19
|
+
__exportStar(require("./ContextMenuPortal"), exports);
|
|
20
|
+
__exportStar(require("./ContextMenuProvider"), exports);
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
__exportStar(require("./utils"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../package/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,oDAAkC;AAClC,sDAAoC;AACpC,wDAAsC;AACtC,0CAAwB;AACxB,0CAAwB","sourcesContent":["export * from './ContextMenuDivider';\nexport * from './ContextMenuItem';\nexport * from './ContextMenuPortal';\nexport * from './ContextMenuProvider';\nexport * from './types';\nexport * from './utils';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../package/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MantineColor, MantineShadow, MantineSize, MantineTheme } from '@mantine/core';\nimport type { CSSProperties, MouseEventHandler, ReactNode } from 'react';\n\n/**\n * Utility type that makes a property required\n */\nexport type WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\n/**\n * Utility type that makes a property optional\n */\nexport type WithOptionalProperty<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\n/**\n * Context menu options\n */\nexport type ContextMenuOptions = {\n /**\n * zIndex of context menu\n * @default 9999\n */\n zIndex?: number;\n\n /**\n * Context menu shadow\n * @default 'sm'\n */\n shadow?: MantineShadow;\n\n /**\n * Context menu border radius\n * @default 'xs'\n */\n borderRadius?: MantineSize;\n\n /**\n * Context menu container className\n */\n className?: string;\n\n /**\n * Context menu container style; can be a function that accepts theme and returns a style object\n */\n style?: CSSProperties | ((theme: MantineTheme) => CSSProperties);\n\n /**\n * Context menu elements classNames; an object with `root`, `item` and `divider` keys and class names as values\n * @see https://mantine.dev/styles/styles-api/\n */\n classNames?: Partial<Record<'root' | 'item' | 'divider', string>>;\n\n /**\n * Context menu styles; can be an object with `root`, `item` and `divider` keys and `CSSProperties` as values,\n * or a function that accepts the current theme and returns a similarly structured object\n */\n styles?:\n | Partial<Record<'root' | 'item' | 'divider', CSSProperties>>\n | ((theme: MantineTheme) => Partial<Record<'root' | 'item' | 'divider', CSSProperties>>);\n};\n\n/**\n * Context menu provider props\n */\nexport type ContextMenuProviderProps = ContextMenuOptions & {\n children: ReactNode;\n};\n\n/**\n * Context menu item options\n */\nexport type ContextMenuItemOptions = {\n /**\n * Unique key of the context menu item or divider\n */\n key: string;\n /**\n * Context menu item or divider className\n */\n className?: string;\n\n /**\n * Context menu item or divider style\n */\n style?: CSSProperties | ((theme: MantineTheme) => CSSProperties);\n} & (\n | ({\n /**\n * Optional context menu item icon\n */\n icon?: ReactNode;\n\n /**\n * Optional context menu item title; if not provided, one will be generated automatically by \"humanizing\" the key\n * @default humanize(key)\n */\n title?: ReactNode;\n\n /**\n * Optional context menu item color\n */\n color?: MantineColor;\n\n /**\n * Boolean indicating whether the context menu item is disabled\n */\n disabled?: boolean;\n } & (\n | {\n /**\n * Optional context menu item `onClick` handler; if not provided, a divider will be rendered instead\n */\n onClick: MouseEventHandler<HTMLButtonElement>;\n\n items?: never;\n }\n | {\n onClick?: never;\n\n /**\n * Optional items; if provided, a submenu will be rendered\n */\n items: ContextMenuItemOptions[];\n }\n ))\n | {\n icon?: never;\n title?: never;\n color?: never;\n disabled?: never;\n onClick?: never;\n items?: never;\n }\n);\n\n/**\n * Context menu content - either an array of context menu items or a function that accepts a close callback and returns context menu content\n */\nexport type ContextMenuContent = ContextMenuItemOptions[] | ((close: () => void) => JSX.Element);\n\n/**\n * Context menu hook return value\n */\nexport type ShowContextMenuFunction = (\n /**\n * Context menu content - either an array of context menu items\n * or a function that accepts a close callback and returns context menu content\n */\n content: ContextMenuContent,\n\n /**\n * Context menu options (overrides provider options)\n */\n options?: ContextMenuOptions\n) => MouseEventHandler;\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.humanize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Utility function that returns a humanized version of a string, e.g. "camelCase" -> "Camel Case"
|
|
6
|
+
*/
|
|
7
|
+
function humanize(value) {
|
|
8
|
+
var str = value
|
|
9
|
+
.replace(/([a-z\d])([A-Z]+)/g, '$1 $2')
|
|
10
|
+
.replace(/\W|_/g, ' ')
|
|
11
|
+
.trim()
|
|
12
|
+
.toLowerCase();
|
|
13
|
+
return "".concat(str.charAt(0).toUpperCase()).concat(str.slice(1));
|
|
14
|
+
}
|
|
15
|
+
exports.humanize = humanize;
|
|
16
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../package/utils.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,QAAQ,CAAC,KAAa;IACpC,IAAM,GAAG,GAAG,KAAK;SACd,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,IAAI,EAAE;SACN,WAAW,EAAE,CAAC;IACjB,OAAO,UAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,SAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,CAAC;AACzD,CAAC;AAPD,4BAOC","sourcesContent":["/**\n * Utility function that returns a humanized version of a string, e.g. \"camelCase\" -> \"Camel Case\"\n */\nexport function humanize(value: string) {\n const str = value\n .replace(/([a-z\\d])([A-Z]+)/g, '$1 $2')\n .replace(/\\W|_/g, ' ')\n .trim()\n .toLowerCase();\n return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.mantine-contextmenu {
|
|
2
|
+
position: fixed;
|
|
3
|
+
border: 1px solid var(--mantine-color-gray-3);
|
|
4
|
+
}
|
|
5
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu {
|
|
6
|
+
border: 1px solid var(--mantine-color-dark-4);
|
|
7
|
+
}
|
|
8
|
+
.mantine-contextmenu {
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
transition: all 0.15s ease;
|
|
11
|
+
}
|
|
12
|
+
.mantine-contextmenu-divider {
|
|
13
|
+
height: calc(0.0625rem * var(--mantine-scale));
|
|
14
|
+
background: var(--mantine-color-gray-1);
|
|
15
|
+
}
|
|
16
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu-divider {
|
|
17
|
+
background: var(--mantine-color-dark-5);
|
|
18
|
+
}
|
|
19
|
+
.mantine-contextmenu-item-button {
|
|
20
|
+
width: 100%;
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
padding-top: calc(var(--mantine-spacing-sm) / 2);
|
|
24
|
+
padding-bottom: calc(var(--mantine-spacing-sm) / 2);
|
|
25
|
+
padding-left: var(--mantine-spacing-sm);
|
|
26
|
+
padding-right: var(--mantine-spacing-sm);
|
|
27
|
+
color: var(--mantine-contextmenu-item-button-color);
|
|
28
|
+
transition: background 0.15s ease;
|
|
29
|
+
}
|
|
30
|
+
.mantine-contextmenu-item-button[disabled] {
|
|
31
|
+
cursor: not-allowed;
|
|
32
|
+
color: var(--mantine-color-gray-5);
|
|
33
|
+
}
|
|
34
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu-item-button[disabled] {
|
|
35
|
+
color: var(--mantine-color-dark-3);
|
|
36
|
+
}
|
|
37
|
+
.mantine-contextmenu-item-button:hover:not([disabled]) {
|
|
38
|
+
background: var(--mantine-contextmenu-item-button-hover-bg-color-light);
|
|
39
|
+
}
|
|
40
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu-item-button:hover:not([disabled]) {
|
|
41
|
+
background: var(--mantine-contextmenu-item-button-hover-bg-color-dark);
|
|
42
|
+
}
|
|
43
|
+
.mantine-contextmenu-item-button:active:not([disabled]) {
|
|
44
|
+
background: var(--mantine-contextmenu-item-button-pressed-bg-color-light);
|
|
45
|
+
}
|
|
46
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu-item-button:active:not([disabled]) {
|
|
47
|
+
background: var(--mantine-contextmenu-item-button-pressed-bg-color-dark);
|
|
48
|
+
}
|
|
49
|
+
.mantine-contextmenu-item-button-title {
|
|
50
|
+
font-size: var(--mantine-font-size-sm);
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
flex-grow: 1;
|
|
53
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@layer mantine-contextmenu {
|
|
2
|
+
.mantine-contextmenu {
|
|
3
|
+
position: fixed;
|
|
4
|
+
border: 1px solid var(--mantine-color-gray-3);
|
|
5
|
+
}
|
|
6
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu {
|
|
7
|
+
border: 1px solid var(--mantine-color-dark-4);
|
|
8
|
+
}
|
|
9
|
+
.mantine-contextmenu {
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
transition: all 0.15s ease;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
@layer mantine-contextmenu {
|
|
15
|
+
.mantine-contextmenu-divider {
|
|
16
|
+
height: calc(0.0625rem * var(--mantine-scale));
|
|
17
|
+
background: var(--mantine-color-gray-1);
|
|
18
|
+
}
|
|
19
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu-divider {
|
|
20
|
+
background: var(--mantine-color-dark-5);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
@layer mantine-contextmenu {
|
|
24
|
+
|
|
25
|
+
.mantine-contextmenu-item-button {
|
|
26
|
+
width: 100%;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
padding-top: calc(var(--mantine-spacing-sm) / 2);
|
|
30
|
+
padding-bottom: calc(var(--mantine-spacing-sm) / 2);
|
|
31
|
+
padding-left: var(--mantine-spacing-sm);
|
|
32
|
+
padding-right: var(--mantine-spacing-sm);
|
|
33
|
+
color: var(--mantine-contextmenu-item-button-color);
|
|
34
|
+
transition: background 0.15s ease;
|
|
35
|
+
}
|
|
36
|
+
.mantine-contextmenu-item-button[disabled] {
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
color: var(--mantine-color-gray-5);
|
|
39
|
+
}
|
|
40
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu-item-button[disabled] {
|
|
41
|
+
color: var(--mantine-color-dark-3);
|
|
42
|
+
}
|
|
43
|
+
.mantine-contextmenu-item-button:hover:not([disabled]) {
|
|
44
|
+
background: var(--mantine-contextmenu-item-button-hover-bg-color-light);
|
|
45
|
+
}
|
|
46
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu-item-button:hover:not([disabled]) {
|
|
47
|
+
background: var(--mantine-contextmenu-item-button-hover-bg-color-dark);
|
|
48
|
+
}
|
|
49
|
+
.mantine-contextmenu-item-button:active:not([disabled]) {
|
|
50
|
+
background: var(--mantine-contextmenu-item-button-pressed-bg-color-light);
|
|
51
|
+
}
|
|
52
|
+
[data-mantine-color-scheme='dark'] .mantine-contextmenu-item-button:active:not([disabled]) {
|
|
53
|
+
background: var(--mantine-contextmenu-item-button-pressed-bg-color-dark);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.mantine-contextmenu-item-button-title {
|
|
57
|
+
font-size: var(--mantine-font-size-sm);
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
flex-grow: 1;
|
|
60
|
+
}
|
|
61
|
+
}
|