@v-c/menu 1.0.11 → 1.0.13
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/hooks/useKeyRecords.js +12 -9
- package/package.json +4 -4
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { nextSlice } from "../utils/timeUtil.js";
|
|
2
|
-
import { onBeforeUnmount, ref, shallowRef } from "vue";
|
|
2
|
+
import { onBeforeUnmount, ref, shallowRef, triggerRef } from "vue";
|
|
3
3
|
var PATH_SPLIT = "__VC_UTIL_PATH_SPLIT__";
|
|
4
4
|
var getPathStr = (keyPath) => keyPath.join(PATH_SPLIT);
|
|
5
5
|
var getPathKeys = (keyPathStr) => keyPathStr.split(PATH_SPLIT);
|
|
6
6
|
const OVERFLOW_KEY = "vc-menu-more";
|
|
7
7
|
function useKeyRecords() {
|
|
8
|
-
const forceUpdateCount = ref(0);
|
|
9
8
|
const key2pathRef = shallowRef(/* @__PURE__ */ new Map());
|
|
10
9
|
const path2keyRef = shallowRef(/* @__PURE__ */ new Map());
|
|
11
10
|
const overflowKeys = ref([]);
|
|
12
11
|
const updateRef = ref(0);
|
|
13
12
|
const destroyRef = ref(false);
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
const schedulePathRegisterUpdate = () => {
|
|
14
|
+
updateRef.value += 1;
|
|
15
|
+
const id = updateRef.value;
|
|
16
|
+
nextSlice(() => {
|
|
17
|
+
if (!destroyRef.value && id === updateRef.value) {
|
|
18
|
+
triggerRef(key2pathRef);
|
|
19
|
+
triggerRef(path2keyRef);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
16
22
|
};
|
|
17
23
|
const registerPath = (key, keyPath) => {
|
|
18
24
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -21,16 +27,13 @@ function useKeyRecords() {
|
|
|
21
27
|
const connectedPath = getPathStr(keyPath);
|
|
22
28
|
path2keyRef.value.set(connectedPath, key);
|
|
23
29
|
key2pathRef.value.set(key, connectedPath);
|
|
24
|
-
|
|
25
|
-
const id = updateRef.value;
|
|
26
|
-
nextSlice(() => {
|
|
27
|
-
if (id === updateRef.value) forceUpdate();
|
|
28
|
-
});
|
|
30
|
+
schedulePathRegisterUpdate();
|
|
29
31
|
};
|
|
30
32
|
const unregisterPath = (key, keyPath) => {
|
|
31
33
|
const connectedPath = getPathStr(keyPath);
|
|
32
34
|
path2keyRef.value.delete(connectedPath);
|
|
33
35
|
key2pathRef.value.delete(key);
|
|
36
|
+
schedulePathRegisterUpdate();
|
|
34
37
|
};
|
|
35
38
|
const refreshOverflowKeys = (keys) => {
|
|
36
39
|
overflowKeys.value = keys;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/menu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.13",
|
|
5
5
|
"description": "menu ui component for vue",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"vue": "^3.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@v-c/
|
|
29
|
-
"@v-c/
|
|
30
|
-
"@v-c/util": "^1.0.
|
|
28
|
+
"@v-c/trigger": "^1.0.14",
|
|
29
|
+
"@v-c/overflow": "^1.0.5",
|
|
30
|
+
"@v-c/util": "^1.0.19"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "vite build",
|