@deot/vc-hooks 1.0.65 → 1.0.67
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.cjs +60 -66
- package/dist/index.iife.js +60 -67
- package/dist/index.js +59 -62
- package/dist/index.umd.cjs +63 -70
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,72 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let vue = require("vue");
|
|
3
|
+
//#region packages/hooks/src/use-attrs.ts
|
|
4
|
+
/**
|
|
5
|
+
* Tips:
|
|
6
|
+
* 1. attrs: 未在emits和props中的值;
|
|
7
|
+
* 2. inheritAttrs只是取决于是否作用到根节点上
|
|
8
|
+
* @param options ~
|
|
9
|
+
* @returns ~
|
|
10
|
+
*/
|
|
11
|
+
var useAttrs = (options) => {
|
|
12
|
+
const attrs = (0, vue.useAttrs)();
|
|
13
|
+
const { merge = true, exclude = [] } = options || {};
|
|
14
|
+
return (0, vue.computed)(() => {
|
|
15
|
+
if (merge && !exclude.length) return attrs;
|
|
16
|
+
const result = Object.entries(attrs).reduce((pre, [key, val]) => {
|
|
17
|
+
if (exclude.includes(key)) return pre;
|
|
18
|
+
if (!merge && /^on([A-Z])/.test(key)) pre.listeners[key] = val;
|
|
19
|
+
else if (!merge && /(class|style)/.test(key)) pre[key] = val;
|
|
20
|
+
else pre.attrs[key] = val;
|
|
21
|
+
return pre;
|
|
22
|
+
}, {
|
|
23
|
+
style: void 0,
|
|
24
|
+
class: void 0,
|
|
25
|
+
attrs: {},
|
|
26
|
+
listeners: {}
|
|
27
|
+
});
|
|
28
|
+
return merge ? result.attrs : result;
|
|
29
|
+
});
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
original = document.body.style.overflow;
|
|
53
|
-
visibleRef.value && setScrollBar(true);
|
|
54
|
-
});
|
|
55
|
-
vue.onBeforeUnmount(() => {
|
|
56
|
-
setScrollBar(false);
|
|
57
|
-
});
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region packages/hooks/src/use-scrollbar.ts
|
|
33
|
+
var useScrollbar = (visibleRef) => {
|
|
34
|
+
let original = "";
|
|
35
|
+
let isMounted = false;
|
|
36
|
+
const setScrollBar = (v) => {
|
|
37
|
+
if (!isMounted || original === "hidden") return;
|
|
38
|
+
if (v) document.body.style.overflow = "hidden";
|
|
39
|
+
else document.body.style.removeProperty("overflow");
|
|
40
|
+
};
|
|
41
|
+
(0, vue.watch)(() => visibleRef.value, (v) => {
|
|
42
|
+
setScrollBar(v);
|
|
43
|
+
}, { immediate: false });
|
|
44
|
+
(0, vue.onMounted)(() => {
|
|
45
|
+
isMounted = true;
|
|
46
|
+
original = document.body.style.overflow;
|
|
47
|
+
visibleRef.value && setScrollBar(true);
|
|
48
|
+
});
|
|
49
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
50
|
+
setScrollBar(false);
|
|
51
|
+
});
|
|
58
52
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region packages/hooks/src/get-instance.ts
|
|
55
|
+
var getInstance = (componentName, privateKey) => {
|
|
56
|
+
const instance = (0, vue.getCurrentInstance)();
|
|
57
|
+
const regex = new RegExp(`${componentName}$`);
|
|
58
|
+
let parent = instance.parent;
|
|
59
|
+
/* istanbul ignore next -- @preserve */
|
|
60
|
+
while (parent && !(parent?.type?.name && regex.test(parent.type.name)) && (!privateKey || !parent?.[privateKey] || !parent?.proxy?.[privateKey])) parent = parent.parent || (parent?.type)?.parent;
|
|
61
|
+
return parent;
|
|
68
62
|
};
|
|
69
|
-
|
|
63
|
+
//#endregion
|
|
70
64
|
exports.getInstance = getInstance;
|
|
71
65
|
exports.useAttrs = useAttrs;
|
|
72
66
|
exports.useScrollbar = useScrollbar;
|
package/dist/index.iife.js
CHANGED
|
@@ -1,75 +1,68 @@
|
|
|
1
|
-
var VcHooks = (function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
var VcHooks = (function(exports, vue) {
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region packages/hooks/src/use-attrs.ts
|
|
4
|
+
/**
|
|
5
|
+
* Tips:
|
|
6
|
+
* 1. attrs: 未在emits和props中的值;
|
|
7
|
+
* 2. inheritAttrs只是取决于是否作用到根节点上
|
|
8
|
+
* @param options ~
|
|
9
|
+
* @returns ~
|
|
10
|
+
*/
|
|
11
|
+
var useAttrs = (options) => {
|
|
12
|
+
const attrs = (0, vue.useAttrs)();
|
|
13
|
+
const { merge = true, exclude = [] } = options || {};
|
|
14
|
+
return (0, vue.computed)(() => {
|
|
15
|
+
if (merge && !exclude.length) return attrs;
|
|
16
|
+
const result = Object.entries(attrs).reduce((pre, [key, val]) => {
|
|
17
|
+
if (exclude.includes(key)) return pre;
|
|
18
|
+
if (!merge && /^on([A-Z])/.test(key)) pre.listeners[key] = val;
|
|
19
|
+
else if (!merge && /(class|style)/.test(key)) pre[key] = val;
|
|
20
|
+
else pre.attrs[key] = val;
|
|
21
|
+
return pre;
|
|
22
|
+
}, {
|
|
23
|
+
style: void 0,
|
|
24
|
+
class: void 0,
|
|
25
|
+
attrs: {},
|
|
26
|
+
listeners: {}
|
|
27
|
+
});
|
|
28
|
+
return merge ? result.attrs : result;
|
|
29
|
+
});
|
|
27
30
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
original = document.body.style.overflow;
|
|
50
|
-
visibleRef.value && setScrollBar(true);
|
|
51
|
-
});
|
|
52
|
-
vue.onBeforeUnmount(() => {
|
|
53
|
-
setScrollBar(false);
|
|
54
|
-
});
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region packages/hooks/src/use-scrollbar.ts
|
|
33
|
+
var useScrollbar = (visibleRef) => {
|
|
34
|
+
let original = "";
|
|
35
|
+
let isMounted = false;
|
|
36
|
+
const setScrollBar = (v) => {
|
|
37
|
+
if (!isMounted || original === "hidden") return;
|
|
38
|
+
if (v) document.body.style.overflow = "hidden";
|
|
39
|
+
else document.body.style.removeProperty("overflow");
|
|
40
|
+
};
|
|
41
|
+
(0, vue.watch)(() => visibleRef.value, (v) => {
|
|
42
|
+
setScrollBar(v);
|
|
43
|
+
}, { immediate: false });
|
|
44
|
+
(0, vue.onMounted)(() => {
|
|
45
|
+
isMounted = true;
|
|
46
|
+
original = document.body.style.overflow;
|
|
47
|
+
visibleRef.value && setScrollBar(true);
|
|
48
|
+
});
|
|
49
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
50
|
+
setScrollBar(false);
|
|
51
|
+
});
|
|
55
52
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region packages/hooks/src/get-instance.ts
|
|
55
|
+
var getInstance = (componentName, privateKey) => {
|
|
56
|
+
const instance = (0, vue.getCurrentInstance)();
|
|
57
|
+
const regex = new RegExp(`${componentName}$`);
|
|
58
|
+
let parent = instance.parent;
|
|
59
|
+
/* istanbul ignore next -- @preserve */
|
|
60
|
+
while (parent && !(parent?.type?.name && regex.test(parent.type.name)) && (!privateKey || !parent?.[privateKey] || !parent?.proxy?.[privateKey])) parent = parent.parent || (parent?.type)?.parent;
|
|
61
|
+
return parent;
|
|
65
62
|
};
|
|
66
|
-
|
|
63
|
+
//#endregion
|
|
67
64
|
exports.getInstance = getInstance;
|
|
68
65
|
exports.useAttrs = useAttrs;
|
|
69
66
|
exports.useScrollbar = useScrollbar;
|
|
70
|
-
|
|
71
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
72
|
-
|
|
73
67
|
return exports;
|
|
74
|
-
|
|
75
68
|
})({}, Vue);
|
package/dist/index.js
CHANGED
|
@@ -1,66 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { computed, getCurrentInstance, onBeforeUnmount, onMounted, useAttrs as useAttrs$1, watch } from "vue";
|
|
2
|
+
//#region packages/hooks/src/use-attrs.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tips:
|
|
5
|
+
* 1. attrs: 未在emits和props中的值;
|
|
6
|
+
* 2. inheritAttrs只是取决于是否作用到根节点上
|
|
7
|
+
* @param options ~
|
|
8
|
+
* @returns ~
|
|
9
|
+
*/
|
|
10
|
+
var useAttrs = (options) => {
|
|
11
|
+
const attrs = useAttrs$1();
|
|
12
|
+
const { merge = true, exclude = [] } = options || {};
|
|
13
|
+
return computed(() => {
|
|
14
|
+
if (merge && !exclude.length) return attrs;
|
|
15
|
+
const result = Object.entries(attrs).reduce((pre, [key, val]) => {
|
|
16
|
+
if (exclude.includes(key)) return pre;
|
|
17
|
+
if (!merge && /^on([A-Z])/.test(key)) pre.listeners[key] = val;
|
|
18
|
+
else if (!merge && /(class|style)/.test(key)) pre[key] = val;
|
|
19
|
+
else pre.attrs[key] = val;
|
|
20
|
+
return pre;
|
|
21
|
+
}, {
|
|
22
|
+
style: void 0,
|
|
23
|
+
class: void 0,
|
|
24
|
+
attrs: {},
|
|
25
|
+
listeners: {}
|
|
26
|
+
});
|
|
27
|
+
return merge ? result.attrs : result;
|
|
28
|
+
});
|
|
26
29
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
original = document.body.style.overflow;
|
|
49
|
-
visibleRef.value && setScrollBar(true);
|
|
50
|
-
});
|
|
51
|
-
onBeforeUnmount(() => {
|
|
52
|
-
setScrollBar(false);
|
|
53
|
-
});
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region packages/hooks/src/use-scrollbar.ts
|
|
32
|
+
var useScrollbar = (visibleRef) => {
|
|
33
|
+
let original = "";
|
|
34
|
+
let isMounted = false;
|
|
35
|
+
const setScrollBar = (v) => {
|
|
36
|
+
if (!isMounted || original === "hidden") return;
|
|
37
|
+
if (v) document.body.style.overflow = "hidden";
|
|
38
|
+
else document.body.style.removeProperty("overflow");
|
|
39
|
+
};
|
|
40
|
+
watch(() => visibleRef.value, (v) => {
|
|
41
|
+
setScrollBar(v);
|
|
42
|
+
}, { immediate: false });
|
|
43
|
+
onMounted(() => {
|
|
44
|
+
isMounted = true;
|
|
45
|
+
original = document.body.style.overflow;
|
|
46
|
+
visibleRef.value && setScrollBar(true);
|
|
47
|
+
});
|
|
48
|
+
onBeforeUnmount(() => {
|
|
49
|
+
setScrollBar(false);
|
|
50
|
+
});
|
|
54
51
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region packages/hooks/src/get-instance.ts
|
|
54
|
+
var getInstance = (componentName, privateKey) => {
|
|
55
|
+
const instance = getCurrentInstance();
|
|
56
|
+
const regex = new RegExp(`${componentName}$`);
|
|
57
|
+
let parent = instance.parent;
|
|
58
|
+
/* istanbul ignore next -- @preserve */
|
|
59
|
+
while (parent && !(parent?.type?.name && regex.test(parent.type.name)) && (!privateKey || !parent?.[privateKey] || !parent?.proxy?.[privateKey])) parent = parent.parent || (parent?.type)?.parent;
|
|
60
|
+
return parent;
|
|
64
61
|
};
|
|
65
|
-
|
|
62
|
+
//#endregion
|
|
66
63
|
export { getInstance, useAttrs, useScrollbar };
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,76 +1,69 @@
|
|
|
1
|
-
(function
|
|
2
|
-
typeof exports ===
|
|
3
|
-
|
|
4
|
-
(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.VcHooks = {}, global.Vue));
|
|
3
|
+
})(this, function(exports, vue) {
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5
|
+
//#region packages/hooks/src/use-attrs.ts
|
|
6
|
+
/**
|
|
7
|
+
* Tips:
|
|
8
|
+
* 1. attrs: 未在emits和props中的值;
|
|
9
|
+
* 2. inheritAttrs只是取决于是否作用到根节点上
|
|
10
|
+
* @param options ~
|
|
11
|
+
* @returns ~
|
|
12
|
+
*/
|
|
13
|
+
var useAttrs = (options) => {
|
|
14
|
+
const attrs = (0, vue.useAttrs)();
|
|
15
|
+
const { merge = true, exclude = [] } = options || {};
|
|
16
|
+
return (0, vue.computed)(() => {
|
|
17
|
+
if (merge && !exclude.length) return attrs;
|
|
18
|
+
const result = Object.entries(attrs).reduce((pre, [key, val]) => {
|
|
19
|
+
if (exclude.includes(key)) return pre;
|
|
20
|
+
if (!merge && /^on([A-Z])/.test(key)) pre.listeners[key] = val;
|
|
21
|
+
else if (!merge && /(class|style)/.test(key)) pre[key] = val;
|
|
22
|
+
else pre.attrs[key] = val;
|
|
23
|
+
return pre;
|
|
24
|
+
}, {
|
|
25
|
+
style: void 0,
|
|
26
|
+
class: void 0,
|
|
27
|
+
attrs: {},
|
|
28
|
+
listeners: {}
|
|
29
|
+
});
|
|
30
|
+
return merge ? result.attrs : result;
|
|
31
|
+
});
|
|
30
32
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
original = document.body.style.overflow;
|
|
53
|
-
visibleRef.value && setScrollBar(true);
|
|
54
|
-
});
|
|
55
|
-
vue.onBeforeUnmount(() => {
|
|
56
|
-
setScrollBar(false);
|
|
57
|
-
});
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region packages/hooks/src/use-scrollbar.ts
|
|
35
|
+
var useScrollbar = (visibleRef) => {
|
|
36
|
+
let original = "";
|
|
37
|
+
let isMounted = false;
|
|
38
|
+
const setScrollBar = (v) => {
|
|
39
|
+
if (!isMounted || original === "hidden") return;
|
|
40
|
+
if (v) document.body.style.overflow = "hidden";
|
|
41
|
+
else document.body.style.removeProperty("overflow");
|
|
42
|
+
};
|
|
43
|
+
(0, vue.watch)(() => visibleRef.value, (v) => {
|
|
44
|
+
setScrollBar(v);
|
|
45
|
+
}, { immediate: false });
|
|
46
|
+
(0, vue.onMounted)(() => {
|
|
47
|
+
isMounted = true;
|
|
48
|
+
original = document.body.style.overflow;
|
|
49
|
+
visibleRef.value && setScrollBar(true);
|
|
50
|
+
});
|
|
51
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
52
|
+
setScrollBar(false);
|
|
53
|
+
});
|
|
58
54
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region packages/hooks/src/get-instance.ts
|
|
57
|
+
var getInstance = (componentName, privateKey) => {
|
|
58
|
+
const instance = (0, vue.getCurrentInstance)();
|
|
59
|
+
const regex = new RegExp(`${componentName}$`);
|
|
60
|
+
let parent = instance.parent;
|
|
61
|
+
/* istanbul ignore next -- @preserve */
|
|
62
|
+
while (parent && !(parent?.type?.name && regex.test(parent.type.name)) && (!privateKey || !parent?.[privateKey] || !parent?.proxy?.[privateKey])) parent = parent.parent || (parent?.type)?.parent;
|
|
63
|
+
return parent;
|
|
68
64
|
};
|
|
69
|
-
|
|
65
|
+
//#endregion
|
|
70
66
|
exports.getInstance = getInstance;
|
|
71
67
|
exports.useAttrs = useAttrs;
|
|
72
68
|
exports.useScrollbar = useScrollbar;
|
|
73
|
-
|
|
74
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
75
|
-
|
|
76
|
-
}));
|
|
69
|
+
});
|