@lemonadejs/contextmenu 1.0.6 → 1.0.8

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/index.js CHANGED
@@ -72,9 +72,10 @@ if (! Modal && typeof (require) === 'function') {
72
72
 
73
73
  /**
74
74
  * Open submenu handler
75
- * @param s
75
+ * @param {object} s
76
+ * @param {boolean} cursor - Activate the first item
76
77
  */
77
- self.open = function(s) {
78
+ self.open = function(s, cursor) {
78
79
  if (s.submenu) {
79
80
  // Get the modal in the container of modals
80
81
  let item = self.parent.modals[index+1];
@@ -100,10 +101,14 @@ if (! Modal && typeof (require) === 'function') {
100
101
  // Define the position
101
102
  modal.top = parent.top + s.el.offsetTop + 2;
102
103
  modal.left = parent.left + 248;
103
- // Place cursor in the first position
104
- modal.options[0].cursor = true;
105
- // Position cursor
106
- modal.cursor = 0;
104
+
105
+ // Activate the cursor
106
+ if (cursor === true) {
107
+ // Place cursor in the first position
108
+ modal.options[0].cursor = true;
109
+ // Position cursor
110
+ modal.cursor = 0;
111
+ }
107
112
  } else {
108
113
  // Close modals with higher level
109
114
  self.parent.close(index+1);
@@ -135,7 +140,7 @@ if (! Modal && typeof (require) === 'function') {
135
140
  }
136
141
  }
137
142
 
138
- let template = `<Modal :closed="true" :ref="self.modal" :responsive="false" :auto-adjust="true" :onclose="self.onclose" :focus="false" :layers="false">
143
+ let template = `<Modal :overflow="true" :closed="true" :ref="self.modal" :responsive="false" :auto-adjust="true" :onclose="self.onclose" :focus="false" :layers="false">
139
144
  <div class="lm-menu-submenu">
140
145
  <Item :loop="self.options" />
141
146
  </div>
@@ -226,7 +231,7 @@ if (! Modal && typeof (require) === 'function') {
226
231
  if (typeof(item) !== 'undefined') {
227
232
  // Open submenu in case that exists
228
233
  if (item.submenu) {
229
- this.parent.open(item);
234
+ this.parent.open(item, true);
230
235
  return true;
231
236
  }
232
237
  }
@@ -339,7 +344,8 @@ if (! Modal && typeof (require) === 'function') {
339
344
  self.root.addEventListener("contextmenu", function(e) {
340
345
  let [x,y] = getCoords(e);
341
346
  // Open the context menu
342
- self.open(self.options, x, y, e);
347
+ var scrollPosition = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
348
+ self.open(self.options, x, y+scrollPosition, e);
343
349
  e.preventDefault();
344
350
  e.stopImmediatePropagation();
345
351
  });
package/dist/react.js ADDED
@@ -0,0 +1,37 @@
1
+ // @ts-nocheck
2
+ import React, { useRef, useEffect } from "react";
3
+ import Component from './index';
4
+
5
+
6
+ // @ts-ignore
7
+ export default React.forwardRef((props, mainReference) => {
8
+ // Dom element
9
+ const Ref = useRef(null);
10
+
11
+ // Get the properties for the spreadsheet
12
+ let options = { ...props };
13
+
14
+ useEffect(() => {
15
+ // @ts-ignore
16
+ if (!Ref.current.innerHTML) {
17
+ mainReference.current = Component(Ref.current, options);
18
+ }
19
+ }, []);
20
+
21
+ useEffect(() => {
22
+ for (let key in props) {
23
+ if (props.hasOwnProperty(key) && mainReference.current.hasOwnProperty(key)) {
24
+ if (props[key] !== mainReference.current[key]) {
25
+ mainReference.current[key] = props[key];
26
+ }
27
+ }
28
+ }
29
+ }, [props])
30
+
31
+ let prop = {
32
+ ref: Ref,
33
+ style: { height: '100%', width: '100%' }
34
+ };
35
+
36
+ return React.createElement("div", prop);
37
+ })
package/dist/style.css CHANGED
@@ -3,31 +3,14 @@
3
3
  user-select: none;
4
4
  border: 1px solid transparent;
5
5
  border-radius: 4px;
6
- box-shadow: 0 2px 6px 2px rgba(60,64,67,.15);
6
+ box-shadow: 0 2px 6px 2px rgba(60,64,67,.2);
7
7
  max-height: 300px;
8
- overflow-y: auto;
9
-
10
8
  width: initial;
11
9
  height: initial;
12
10
  min-width: 250px;
13
11
  min-height: initial;
14
12
  }
15
13
 
16
- .lm-menu .lm-modal::-webkit-scrollbar {
17
- width: 12px;
18
- height: 12px;
19
- }
20
-
21
- .lm-menu .lm-modal::-webkit-scrollbar-track {
22
- border: 1px solid #fff;
23
- background: #eee;
24
- }
25
-
26
- .lm-menu .lm-modal::-webkit-scrollbar-thumb {
27
- border: 1px solid #fff;
28
- background: #888;
29
- }
30
-
31
14
  .lm-menu-submenu {
32
15
  padding-top: 1px;
33
16
  padding-bottom: 1px;
@@ -53,6 +36,8 @@
53
36
 
54
37
  .lm-menu-submenu > div.lm-menu-item div {
55
38
  margin-right: 5px;
39
+ font-size: 0.9em;
40
+ color: #888;
56
41
  }
57
42
 
58
43
  .lm-menu-submenu > div.lm-menu-item[data-submenu="true"]::after {
@@ -82,5 +67,4 @@
82
67
  position: absolute;
83
68
  left: 9px;
84
69
  line-height: 24px;
85
- transform: rotate(0.03deg);
86
70
  }
package/dist/vue.js ADDED
@@ -0,0 +1,45 @@
1
+ import { h } from 'vue';
2
+ import component from "./index";
3
+
4
+
5
+ export default {
6
+ inheritAttrs: false,
7
+ mounted() {
8
+ let options = {
9
+ ...this.$attrs
10
+ };
11
+
12
+ this.el = this.$refs.container;
13
+
14
+ this.current = component(this.$refs.container, options);
15
+ },
16
+ setup() {
17
+ let containerProps = {
18
+ ref: 'container',
19
+ style: {
20
+ width: '100%',
21
+ height: '100%',
22
+ }
23
+ };
24
+ return () => h('div', containerProps);
25
+ },
26
+ watch: {
27
+ $attrs: {
28
+ deep: true,
29
+ handler() {
30
+ this.updateState();
31
+ }
32
+ }
33
+ },
34
+ methods: {
35
+ updateState() {
36
+ for (let key in this.$attrs) {
37
+ if (this.$attrs.hasOwnProperty(key) && this.current.hasOwnProperty(key)) {
38
+ if (this.$attrs[key] !== this.current[key]) {
39
+ this.current[key] = this.$attrs[key];
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
package/package.json CHANGED
@@ -14,10 +14,10 @@
14
14
  "build": "webpack --config webpack.config.js"
15
15
  },
16
16
  "dependencies": {
17
- "@lemonadejs/modal": "^2.3.3",
18
- "lemonadejs": "^3.4.0"
17
+ "@lemonadejs/modal": "^2.4.4",
18
+ "lemonadejs": "^4.0.7"
19
19
  },
20
20
  "main": "dist/index.js",
21
21
  "types": "dist/index.d.ts",
22
- "version": "1.0.6"
22
+ "version": "1.0.8"
23
23
  }