@intechstudio/grid-uikit 1.20241017.2145 → 1.20241017.2206
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/ContextMenu.svelte +4 -4
- package/dist/context-target.d.ts +6 -2
- package/dist/context-target.js +19 -11
- package/package.json +1 -1
package/dist/ContextMenu.svelte
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<script>import Popover from "svelte-easy-popover/dist/ts/Popover.svelte";
|
|
5
5
|
import { onMount } from "svelte";
|
|
6
|
-
import {
|
|
6
|
+
import { contextMenu } from "./context-target";
|
|
7
7
|
export let target;
|
|
8
8
|
export let items = [];
|
|
9
9
|
export let coord;
|
|
@@ -11,13 +11,13 @@ let maxLength = Math.max(...items.map((e) => e.text[0].length));
|
|
|
11
11
|
let menu;
|
|
12
12
|
function handleItemClicked(item) {
|
|
13
13
|
item.handler();
|
|
14
|
-
|
|
14
|
+
contextMenu.close();
|
|
15
15
|
}
|
|
16
16
|
function handleBlur() {
|
|
17
|
-
|
|
17
|
+
contextMenu.close();
|
|
18
18
|
}
|
|
19
19
|
function handleClickOutside() {
|
|
20
|
-
|
|
20
|
+
contextMenu.close();
|
|
21
21
|
}
|
|
22
22
|
let offset = { x: 0, y: 0 };
|
|
23
23
|
onMount(() => {
|
package/dist/context-target.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Action } from "svelte/action";
|
|
2
|
-
import { type ContextMenuItem } from "./ContextMenu.svelte";
|
|
2
|
+
import ContextMenu, { type ContextMenuItem } from "./ContextMenu.svelte";
|
|
3
|
+
import { type Writable } from "svelte/store";
|
|
3
4
|
interface ContextMenuOptions {
|
|
4
5
|
items: ContextMenuItem[];
|
|
5
6
|
data: any;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
interface ContextMenuWritable extends Writable<ContextMenu | null> {
|
|
9
|
+
close: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare let contextMenu: ContextMenuWritable;
|
|
8
12
|
export declare const contextTarget: Action<HTMLElement, ContextMenuOptions>;
|
|
9
13
|
export {};
|
package/dist/context-target.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import ContextMenu, {} from "./ContextMenu.svelte";
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { get, writable } from "svelte/store";
|
|
3
|
+
export let contextMenu = createContextMenuStore();
|
|
4
|
+
function createContextMenuStore() {
|
|
5
|
+
const store = writable(null);
|
|
6
|
+
const close = () => {
|
|
7
|
+
const cm = get(store);
|
|
8
|
+
if (cm) {
|
|
9
|
+
cm.$destroy(); // Ensure that the context menu has a $destroy method
|
|
10
|
+
store.set(null);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
...store,
|
|
15
|
+
close,
|
|
16
|
+
};
|
|
9
17
|
}
|
|
10
18
|
export const contextTarget = (node, options) => {
|
|
11
19
|
const handleMouseUp = (e) => {
|
|
@@ -16,22 +24,22 @@ export const contextTarget = (node, options) => {
|
|
|
16
24
|
};
|
|
17
25
|
const createContextMenu = async (x, y) => {
|
|
18
26
|
// If a context menu is already open, destroy it
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
contextMenu.close();
|
|
28
|
+
contextMenu.set(new ContextMenu({
|
|
21
29
|
target: node,
|
|
22
30
|
props: {
|
|
23
31
|
target: node,
|
|
24
32
|
items: options.items,
|
|
25
33
|
coord: { x: x, y: y },
|
|
26
34
|
},
|
|
27
|
-
});
|
|
35
|
+
}));
|
|
28
36
|
};
|
|
29
37
|
node.addEventListener("mouseup", (event) => handleMouseUp(event));
|
|
30
38
|
return {
|
|
31
39
|
destroy() {
|
|
32
40
|
node.removeEventListener("mouseup", handleMouseUp);
|
|
33
41
|
// Clean up the current context menu if the node is destroyed
|
|
34
|
-
|
|
42
|
+
contextMenu.close();
|
|
35
43
|
},
|
|
36
44
|
};
|
|
37
45
|
};
|