@lemonadejs/contextmenu 1.1.2 → 1.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/README.md +74 -1
- package/dist/index.js +10 -6
- package/dist/react.d.ts +4 -1
- package/dist/style.css +10 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -69,6 +69,79 @@ export default function App() {
|
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
Quick example with React
|
|
73
|
+
|
|
74
|
+
```jsx
|
|
75
|
+
import React, { useRef } from 'react';
|
|
76
|
+
import Contextmenu from '@lemonadejs/contextmenu/dist/react';
|
|
77
|
+
import '@lemonadejs/contextmenu/dist/style.css';
|
|
78
|
+
import '@lemonadejs/modal/dist/style.css';
|
|
79
|
+
|
|
80
|
+
const options = [
|
|
81
|
+
{
|
|
82
|
+
title: 'Console.log',
|
|
83
|
+
onclick: function () {
|
|
84
|
+
console.log('Hello!')
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: 'Show Alert',
|
|
89
|
+
onclick: function () {
|
|
90
|
+
alert('Hello!')
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
export default function App() {
|
|
95
|
+
const contextmenu = useRef();
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div style={{ backgroundColor: '#2222AA', width: '100px', height: '100px' }}>
|
|
99
|
+
<Contextmenu options={options} ref={contextmenu} />
|
|
100
|
+
</div>);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Quick example with Vue
|
|
105
|
+
|
|
106
|
+
```vue
|
|
107
|
+
<template>
|
|
108
|
+
<div style="background-color: #2222AA; width: 100px; height: 100px;">
|
|
109
|
+
<Contextmenu :options="options" />
|
|
110
|
+
</div>
|
|
111
|
+
</template>
|
|
112
|
+
|
|
113
|
+
<script>
|
|
114
|
+
import Contextmenu from '@lemonadejs/contextmenu/dist/vue'
|
|
115
|
+
import '@lemonadejs/contextmenu/dist/style.css';
|
|
116
|
+
import '@lemonadejs/modal/dist/style.css';
|
|
117
|
+
|
|
118
|
+
export default {
|
|
119
|
+
name: 'App',
|
|
120
|
+
components: {
|
|
121
|
+
Contextmenu
|
|
122
|
+
},
|
|
123
|
+
data() {
|
|
124
|
+
return {
|
|
125
|
+
options: [
|
|
126
|
+
{
|
|
127
|
+
title: 'Console.log',
|
|
128
|
+
onclick:function() {
|
|
129
|
+
console.log('Hello!')
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
title: 'Show Alert',
|
|
134
|
+
onclick:function() {
|
|
135
|
+
alert('Hello!')
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
</script>
|
|
143
|
+
```
|
|
144
|
+
|
|
72
145
|
### Properties
|
|
73
146
|
|
|
74
147
|
| Property | Type | Description |
|
|
@@ -94,5 +167,5 @@ The [LemonadeJS](https://lemonadejs.net) Context Menu is released under the MIT.
|
|
|
94
167
|
|
|
95
168
|
## Other Tools
|
|
96
169
|
|
|
97
|
-
- [jSuites](https://jsuites.net/
|
|
170
|
+
- [jSuites](https://jsuites.net/docs)
|
|
98
171
|
- [Jspreadsheet Data Grid](https://jspreadsheet.com)
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
if (!lemonade && typeof
|
|
1
|
+
if (! lemonade && typeof(require) === 'function') {
|
|
2
2
|
var lemonade = require('lemonadejs');
|
|
3
3
|
}
|
|
4
4
|
|
|
@@ -42,12 +42,14 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
self.hasSubmenu = !! self.submenu;
|
|
46
|
+
|
|
45
47
|
if (self.type === 'line') {
|
|
46
48
|
return `<hr />`;
|
|
47
49
|
} else if (self.type === 'inline') {
|
|
48
50
|
return `<div></div>`;
|
|
49
51
|
} else {
|
|
50
|
-
return `<div class="lm-menu-item" data-cursor="{{self.cursor}}" data-icon="{{self.icon}}" data-submenu="{{self.
|
|
52
|
+
return `<div class="lm-menu-item" data-disabled="{{self.disabled}}" data-cursor="{{self.cursor}}" data-icon="{{self.icon}}" data-submenu="{{self.hasSubmenu}}" onmouseup="self.parent.parent.mouseUp(self, e)" onmouseenter="self.parent.parent.mouseEnter(self)" onmouseleave="self.parent.parent.mouseLeave(self)">
|
|
51
53
|
<a>{{self.title}}</a> <div>{{self.shortcut}}</div>
|
|
52
54
|
</div>`;
|
|
53
55
|
}
|
|
@@ -250,7 +252,7 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
250
252
|
// Open submenu
|
|
251
253
|
if (typeof(item) !== 'undefined') {
|
|
252
254
|
// Open submenu in case that exists
|
|
253
|
-
if (item.submenu) {
|
|
255
|
+
if (item.submenu && ! item.disabled) {
|
|
254
256
|
this.parent.open(item, true);
|
|
255
257
|
return true;
|
|
256
258
|
}
|
|
@@ -302,14 +304,14 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
302
304
|
if (modal.closed === false) {
|
|
303
305
|
// Close modals with higher level
|
|
304
306
|
self.close(1);
|
|
305
|
-
// Define new position
|
|
306
|
-
modal.top = y;
|
|
307
|
-
modal.left = x;
|
|
308
307
|
// Update the data
|
|
309
308
|
if (modal.options !== options) {
|
|
310
309
|
// Refresh content
|
|
311
310
|
modal.options = options;
|
|
312
311
|
}
|
|
312
|
+
// Define new position
|
|
313
|
+
modal.top = y;
|
|
314
|
+
modal.left = x;
|
|
313
315
|
onopen(self, options);
|
|
314
316
|
}
|
|
315
317
|
}
|
|
@@ -390,6 +392,8 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
390
392
|
|
|
391
393
|
lemonade.setComponents({ Contextmenu: Contextmenu });
|
|
392
394
|
|
|
395
|
+
lemonade.createWebComponent('contextmenu', Contextmenu);
|
|
396
|
+
|
|
393
397
|
return function (root, options) {
|
|
394
398
|
if (typeof (root) === 'object') {
|
|
395
399
|
lemonade.render(Contextmenu, root, options)
|
package/dist/react.d.ts
CHANGED
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
import Component from './index';
|
|
7
7
|
|
|
8
8
|
interface Contextmenu {
|
|
9
|
+
ref?: MutableRefObject<undefined>;
|
|
9
10
|
(): any
|
|
10
11
|
[key: string]: any
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
type Props = IntrinsicAttributes & Component.Options & Contextmenu;
|
|
15
|
+
|
|
16
|
+
declare function Contextmenu<Contextmenu>(props: Props): any;
|
|
14
17
|
|
|
15
18
|
export default Contextmenu;
|
package/dist/style.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.lm-menu .lm-modal {
|
|
2
2
|
color: #555;
|
|
3
3
|
user-select: none;
|
|
4
|
-
border: 1px solid
|
|
4
|
+
border: 1px solid var(--lm-border-color-light, #e9e9e9);
|
|
5
5
|
border-radius: 4px;
|
|
6
6
|
box-shadow: 0 2px 6px 2px rgba(60,64,67,.2);
|
|
7
7
|
max-height: 300px;
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
height: initial;
|
|
10
10
|
min-width: 250px;
|
|
11
11
|
min-height: initial;
|
|
12
|
+
padding-top: 4px;
|
|
13
|
+
padding-bottom: 4px;
|
|
14
|
+
z-index: 16;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
.lm-menu-submenu {
|
|
@@ -44,17 +47,18 @@
|
|
|
44
47
|
content: '\25B6'
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
.lm-menu-submenu > div.lm-menu-item
|
|
48
|
-
|
|
50
|
+
.lm-menu-submenu > div.lm-menu-item[data-disabled="true"] {
|
|
51
|
+
opacity: 0.5;
|
|
52
|
+
pointer-events: none;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
.lm-menu-submenu > div.lm-menu-item:hover,
|
|
52
56
|
.lm-menu-submenu > div.lm-menu-item[data-cursor="true"] {
|
|
53
|
-
background: #ebebeb;
|
|
57
|
+
background-color: var(--lm-background-color-hover, #ebebeb);
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
.lm-menu-submenu hr {
|
|
57
|
-
border: 1px solid #e9e9e9;
|
|
61
|
+
border: 1px solid var(--lm-border-color-light, #e9e9e9);
|
|
58
62
|
border-bottom: 0;
|
|
59
63
|
margin-top:5px;
|
|
60
64
|
margin-bottom:5px;
|
|
@@ -67,4 +71,5 @@
|
|
|
67
71
|
line-height: 24px;
|
|
68
72
|
margin-right: 10px;
|
|
69
73
|
width: 16px;
|
|
74
|
+
color: var(--lm-icon-color, #777);
|
|
70
75
|
}
|
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"build": "webpack --config webpack.config.js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"
|
|
18
|
-
"lemonadejs": "^
|
|
17
|
+
"lemonadejs": "^4.3.3",
|
|
18
|
+
"@lemonadejs/modal": "^3.2.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"version": "1.
|
|
22
|
+
"version": "1.3.0"
|
|
23
23
|
}
|