@v-c/util 0.0.12 → 0.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/Children/isFragment.cjs +7 -1
- package/dist/Children/isFragment.js +4 -4
- package/dist/Children/toArray.cjs +20 -1
- package/dist/Children/toArray.js +17 -8
- package/dist/Dom/addEventListener.cjs +13 -1
- package/dist/Dom/addEventListener.js +7 -5
- package/dist/Dom/canUseDom.cjs +6 -1
- package/dist/Dom/canUseDom.js +3 -3
- package/dist/Dom/class.cjs +29 -1
- package/dist/Dom/class.js +23 -13
- package/dist/Dom/contains.cjs +16 -1
- package/dist/Dom/contains.js +12 -12
- package/dist/Dom/css.cjs +96 -1
- package/dist/Dom/css.js +69 -48
- package/dist/Dom/dynamicCSS.cjs +110 -1
- package/dist/Dom/dynamicCSS.js +92 -59
- package/dist/Dom/findDOMNode.cjs +16 -1
- package/dist/Dom/findDOMNode.js +12 -8
- package/dist/Dom/focus.cjs +60 -1
- package/dist/Dom/focus.js +48 -28
- package/dist/Dom/isVisible.cjs +22 -1
- package/dist/Dom/isVisible.js +16 -16
- package/dist/Dom/scrollLocker.cjs +89 -1
- package/dist/Dom/scrollLocker.js +70 -45
- package/dist/Dom/shadow.cjs +13 -1
- package/dist/Dom/shadow.js +8 -8
- package/dist/Dom/styleChecker.cjs +25 -1
- package/dist/Dom/styleChecker.js +19 -14
- package/dist/Dom/support.cjs +28 -1
- package/dist/Dom/support.js +16 -12
- package/dist/KeyCode.cjs +523 -1
- package/dist/KeyCode.js +62 -55
- package/dist/Portal.cjs +48 -1
- package/dist/Portal.js +34 -19
- package/dist/PortalWrapper.cjs +169 -1
- package/dist/PortalWrapper.js +133 -79
- package/dist/classnames.cjs +45 -1
- package/dist/classnames.js +38 -25
- package/dist/composeProps.cjs +19 -1
- package/dist/composeProps.js +15 -9
- package/dist/createRef.cjs +24 -1
- package/dist/createRef.js +16 -13
- package/dist/debug/diff.cjs +50 -1
- package/dist/debug/diff.js +39 -30
- package/dist/deprecated.cjs +10 -1
- package/dist/deprecated.js +7 -5
- package/dist/getScrollBarSize.cjs +51 -1
- package/dist/getScrollBarSize.js +39 -25
- package/dist/guid.cjs +7 -1
- package/dist/guid.js +4 -4
- package/dist/hooks/useEvent.cjs +6 -1
- package/dist/hooks/useEvent.js +3 -3
- package/dist/hooks/useId.cjs +18 -1
- package/dist/hooks/useId.js +14 -8
- package/dist/hooks/useLayoutEffect.cjs +58 -1
- package/dist/hooks/useLayoutEffect.js +50 -20
- package/dist/hooks/useMemo.cjs +16 -1
- package/dist/hooks/useMemo.js +13 -7
- package/dist/hooks/useMergedState.cjs +30 -1
- package/dist/hooks/useMergedState.js +25 -16
- package/dist/hooks/useMobile.cjs +16 -1
- package/dist/hooks/useMobile.js +13 -11
- package/dist/hooks/useState.cjs +12 -1
- package/dist/hooks/useState.js +8 -7
- package/dist/index.cjs +11 -1
- package/dist/index.js +9 -9
- package/dist/isEqual.cjs +36 -1
- package/dist/isEqual.js +30 -26
- package/dist/isMobile.cjs +13 -1
- package/dist/isMobile.js +7 -7
- package/dist/isValid.cjs +6 -1
- package/dist/isValid.js +3 -3
- package/dist/omit.cjs +12 -1
- package/dist/omit.js +9 -6
- package/dist/pickAttrs.cjs +41 -3
- package/dist/pickAttrs.js +37 -22
- package/dist/props-util/index.cjs +69 -1
- package/dist/props-util/index.js +62 -32
- package/dist/raf.cjs +48 -1
- package/dist/raf.js +37 -26
- package/dist/setStyle.cjs +17 -1
- package/dist/setStyle.js +13 -9
- package/dist/switchScrollingEffect.cjs +38 -1
- package/dist/switchScrollingEffect.js +27 -20
- package/dist/test/domHook.cjs +52 -1
- package/dist/test/domHook.js +43 -28
- package/dist/type.cjs +51 -1
- package/dist/type.js +39 -37
- package/dist/utils/checkSlotProp.cjs +13 -1
- package/dist/utils/checkSlotProp.js +10 -3
- package/dist/utils/get.cjs +12 -1
- package/dist/utils/get.js +8 -8
- package/dist/utils/omit.cjs +10 -1
- package/dist/utils/omit.js +7 -6
- package/dist/utils/set.cjs +64 -1
- package/dist/utils/set.js +54 -32
- package/dist/utils/transition.cjs +96 -1
- package/dist/utils/transition.d.ts +2 -2
- package/dist/utils/transition.js +70 -65
- package/dist/utils/watchState.cjs +20 -1
- package/dist/utils/watchState.js +15 -10
- package/dist/vnode.cjs +56 -1
- package/dist/vnode.js +46 -30
- package/dist/vueuse/unref-element.cjs +8 -1
- package/dist/vueuse/unref-element.js +5 -5
- package/dist/warning.cjs +53 -1
- package/dist/warning.js +40 -35
- package/package.json +1 -1
package/dist/classnames.cjs
CHANGED
|
@@ -1 +1,45 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
function toVal(mix) {
|
|
4
|
+
let str = "";
|
|
5
|
+
if (typeof mix === "string" || typeof mix === "number") {
|
|
6
|
+
str += mix;
|
|
7
|
+
} else if (typeof mix === "object") {
|
|
8
|
+
if (Array.isArray(mix)) {
|
|
9
|
+
for (let k = 0; k < mix.length; k++) {
|
|
10
|
+
if (mix[k]) {
|
|
11
|
+
const y = toVal(mix[k]);
|
|
12
|
+
if (y) {
|
|
13
|
+
str && (str += " ");
|
|
14
|
+
str += y;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
for (const k in mix) {
|
|
20
|
+
if (mix[k]) {
|
|
21
|
+
str && (str += " ");
|
|
22
|
+
str += k;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return str;
|
|
28
|
+
}
|
|
29
|
+
function classNames(...args) {
|
|
30
|
+
let str = "";
|
|
31
|
+
for (let i = 0; i < args.length; i++) {
|
|
32
|
+
const tmp = args[i];
|
|
33
|
+
if (tmp) {
|
|
34
|
+
const x = toVal(tmp);
|
|
35
|
+
if (x) {
|
|
36
|
+
str && (str += " ");
|
|
37
|
+
str += x;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return str;
|
|
42
|
+
}
|
|
43
|
+
const clsx = classNames;
|
|
44
|
+
exports.clsx = clsx;
|
|
45
|
+
exports.default = classNames;
|
package/dist/classnames.js
CHANGED
|
@@ -1,32 +1,45 @@
|
|
|
1
|
-
function
|
|
2
|
-
let
|
|
3
|
-
if (typeof
|
|
4
|
-
|
|
5
|
-
else if (typeof
|
|
6
|
-
if (Array.isArray(
|
|
7
|
-
for (let
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
|
|
1
|
+
function toVal(mix) {
|
|
2
|
+
let str = "";
|
|
3
|
+
if (typeof mix === "string" || typeof mix === "number") {
|
|
4
|
+
str += mix;
|
|
5
|
+
} else if (typeof mix === "object") {
|
|
6
|
+
if (Array.isArray(mix)) {
|
|
7
|
+
for (let k = 0; k < mix.length; k++) {
|
|
8
|
+
if (mix[k]) {
|
|
9
|
+
const y = toVal(mix[k]);
|
|
10
|
+
if (y) {
|
|
11
|
+
str && (str += " ");
|
|
12
|
+
str += y;
|
|
13
|
+
}
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
for (const k in mix) {
|
|
18
|
+
if (mix[k]) {
|
|
19
|
+
str && (str += " ");
|
|
20
|
+
str += k;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return str;
|
|
16
26
|
}
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
for (let
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
|
|
27
|
+
function classNames(...args) {
|
|
28
|
+
let str = "";
|
|
29
|
+
for (let i = 0; i < args.length; i++) {
|
|
30
|
+
const tmp = args[i];
|
|
31
|
+
if (tmp) {
|
|
32
|
+
const x = toVal(tmp);
|
|
33
|
+
if (x) {
|
|
34
|
+
str && (str += " ");
|
|
35
|
+
str += x;
|
|
36
|
+
}
|
|
24
37
|
}
|
|
25
38
|
}
|
|
26
|
-
return
|
|
39
|
+
return str;
|
|
27
40
|
}
|
|
28
|
-
const
|
|
41
|
+
const clsx = classNames;
|
|
29
42
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
clsx,
|
|
44
|
+
classNames as default
|
|
32
45
|
};
|
package/dist/composeProps.cjs
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
function composeProps(originProps, patchProps, isAll) {
|
|
4
|
+
const composedProps = {
|
|
5
|
+
...originProps,
|
|
6
|
+
...isAll ? patchProps : {}
|
|
7
|
+
};
|
|
8
|
+
Object.keys(patchProps).forEach((key) => {
|
|
9
|
+
const func = patchProps[key];
|
|
10
|
+
if (typeof func === "function") {
|
|
11
|
+
composedProps[key] = (...args) => {
|
|
12
|
+
func(...args);
|
|
13
|
+
return originProps[key]?.(...args);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return composedProps;
|
|
18
|
+
}
|
|
19
|
+
exports.default = composeProps;
|
package/dist/composeProps.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
...
|
|
4
|
-
...
|
|
1
|
+
function composeProps(originProps, patchProps, isAll) {
|
|
2
|
+
const composedProps = {
|
|
3
|
+
...originProps,
|
|
4
|
+
...isAll ? patchProps : {}
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
typeof
|
|
9
|
-
|
|
6
|
+
Object.keys(patchProps).forEach((key) => {
|
|
7
|
+
const func = patchProps[key];
|
|
8
|
+
if (typeof func === "function") {
|
|
9
|
+
composedProps[key] = (...args) => {
|
|
10
|
+
func(...args);
|
|
11
|
+
return originProps[key]?.(...args);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return composedProps;
|
|
10
16
|
}
|
|
11
17
|
export {
|
|
12
|
-
|
|
18
|
+
composeProps as default
|
|
13
19
|
};
|
package/dist/createRef.cjs
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
function createRef() {
|
|
4
|
+
const func = (node) => {
|
|
5
|
+
func.current = node;
|
|
6
|
+
};
|
|
7
|
+
return func;
|
|
8
|
+
}
|
|
9
|
+
function fillRef(ref, node) {
|
|
10
|
+
if (typeof ref === "function")
|
|
11
|
+
ref(node);
|
|
12
|
+
else if (typeof ref === "object" && ref && "current" in ref)
|
|
13
|
+
ref.current = node;
|
|
14
|
+
}
|
|
15
|
+
function composeRef(...refs) {
|
|
16
|
+
return (node) => {
|
|
17
|
+
refs.forEach((ref) => {
|
|
18
|
+
fillRef(ref, node);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.composeRef = composeRef;
|
|
23
|
+
exports.default = createRef;
|
|
24
|
+
exports.fillRef = fillRef;
|
package/dist/createRef.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
function createRef() {
|
|
2
|
+
const func = (node) => {
|
|
3
|
+
func.current = node;
|
|
4
4
|
};
|
|
5
|
-
return
|
|
5
|
+
return func;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
7
|
+
function fillRef(ref, node) {
|
|
8
|
+
if (typeof ref === "function")
|
|
9
|
+
ref(node);
|
|
10
|
+
else if (typeof ref === "object" && ref && "current" in ref)
|
|
11
|
+
ref.current = node;
|
|
9
12
|
}
|
|
10
|
-
function
|
|
11
|
-
return (
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
function composeRef(...refs) {
|
|
14
|
+
return (node) => {
|
|
15
|
+
refs.forEach((ref) => {
|
|
16
|
+
fillRef(ref, node);
|
|
14
17
|
});
|
|
15
18
|
};
|
|
16
19
|
}
|
|
17
20
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
composeRef,
|
|
22
|
+
createRef as default,
|
|
23
|
+
fillRef
|
|
21
24
|
};
|
package/dist/debug/diff.cjs
CHANGED
|
@@ -1 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
function createArray() {
|
|
4
|
+
const arr = [];
|
|
5
|
+
arr.__proto__ = [];
|
|
6
|
+
arr.__proto__.format = function toString() {
|
|
7
|
+
return this.map((obj) => ({
|
|
8
|
+
...obj,
|
|
9
|
+
path: obj.path.join(" > ")
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
arr.__proto__.toString = function toString() {
|
|
13
|
+
return JSON.stringify(this.format(), null, 2);
|
|
14
|
+
};
|
|
15
|
+
return arr;
|
|
16
|
+
}
|
|
17
|
+
function diff(obj1, obj2, depth = 10, path = [], diffList = createArray()) {
|
|
18
|
+
if (depth <= 0)
|
|
19
|
+
return diffList;
|
|
20
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(obj1), ...Object.keys(obj2)]);
|
|
21
|
+
keys.forEach((key) => {
|
|
22
|
+
const value1 = obj1[key];
|
|
23
|
+
const value2 = obj2[key];
|
|
24
|
+
if (value1 === value2)
|
|
25
|
+
return;
|
|
26
|
+
const type1 = typeof value1;
|
|
27
|
+
const type2 = typeof value2;
|
|
28
|
+
if (type1 !== type2) {
|
|
29
|
+
diffList.push({
|
|
30
|
+
path: path.concat(key),
|
|
31
|
+
value1,
|
|
32
|
+
value2
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (Number.isNaN(value1) && Number.isNaN(value2))
|
|
37
|
+
return;
|
|
38
|
+
if (type1 === "object" && value1 !== null && value2 !== null) {
|
|
39
|
+
diff(value1, value2, depth - 1, path.concat(key), diffList);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
diffList.push({
|
|
43
|
+
path: path.concat(key),
|
|
44
|
+
value1,
|
|
45
|
+
value2
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return diffList;
|
|
49
|
+
}
|
|
50
|
+
exports.default = diff;
|
package/dist/debug/diff.js
CHANGED
|
@@ -1,41 +1,50 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
function createArray() {
|
|
2
|
+
const arr = [];
|
|
3
|
+
arr.__proto__ = [];
|
|
4
|
+
arr.__proto__.format = function toString() {
|
|
5
|
+
return this.map((obj) => ({
|
|
6
|
+
...obj,
|
|
7
|
+
path: obj.path.join(" > ")
|
|
7
8
|
}));
|
|
8
|
-
}
|
|
9
|
+
};
|
|
10
|
+
arr.__proto__.toString = function toString() {
|
|
9
11
|
return JSON.stringify(this.format(), null, 2);
|
|
10
|
-
}
|
|
12
|
+
};
|
|
13
|
+
return arr;
|
|
11
14
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
function diff(obj1, obj2, depth = 10, path = [], diffList = createArray()) {
|
|
16
|
+
if (depth <= 0)
|
|
17
|
+
return diffList;
|
|
18
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(obj1), ...Object.keys(obj2)]);
|
|
19
|
+
keys.forEach((key) => {
|
|
20
|
+
const value1 = obj1[key];
|
|
21
|
+
const value2 = obj2[key];
|
|
22
|
+
if (value1 === value2)
|
|
16
23
|
return;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const type1 = typeof value1;
|
|
25
|
+
const type2 = typeof value2;
|
|
26
|
+
if (type1 !== type2) {
|
|
27
|
+
diffList.push({
|
|
28
|
+
path: path.concat(key),
|
|
29
|
+
value1,
|
|
30
|
+
value2
|
|
23
31
|
});
|
|
24
32
|
return;
|
|
25
33
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
e.push({
|
|
32
|
-
path: a.concat(u),
|
|
33
|
-
value1: r,
|
|
34
|
-
value2: n
|
|
35
|
-
});
|
|
34
|
+
if (Number.isNaN(value1) && Number.isNaN(value2))
|
|
35
|
+
return;
|
|
36
|
+
if (type1 === "object" && value1 !== null && value2 !== null) {
|
|
37
|
+
diff(value1, value2, depth - 1, path.concat(key), diffList);
|
|
38
|
+
return;
|
|
36
39
|
}
|
|
37
|
-
|
|
40
|
+
diffList.push({
|
|
41
|
+
path: path.concat(key),
|
|
42
|
+
value1,
|
|
43
|
+
value2
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return diffList;
|
|
38
47
|
}
|
|
39
48
|
export {
|
|
40
|
-
|
|
49
|
+
diff as default
|
|
41
50
|
};
|
package/dist/deprecated.cjs
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
function deprecated(props, instead, component) {
|
|
4
|
+
if (typeof window !== "undefined" && window.console && window.console.error) {
|
|
5
|
+
window.console.error(
|
|
6
|
+
`Warning: ${props} is deprecated at [ ${component} ], use [ ${instead} ] instead of it.`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = deprecated;
|
package/dist/deprecated.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
function
|
|
2
|
-
typeof window
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function deprecated(props, instead, component) {
|
|
2
|
+
if (typeof window !== "undefined" && window.console && window.console.error) {
|
|
3
|
+
window.console.error(
|
|
4
|
+
`Warning: ${props} is deprecated at [ ${component} ], use [ ${instead} ] instead of it.`
|
|
5
|
+
);
|
|
6
|
+
}
|
|
5
7
|
}
|
|
6
8
|
export {
|
|
7
|
-
|
|
9
|
+
deprecated as default
|
|
8
10
|
};
|
|
@@ -1 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
let cached;
|
|
4
|
+
function getScrollBarSize(fresh) {
|
|
5
|
+
if (typeof document === "undefined") return 0;
|
|
6
|
+
if (fresh || cached === void 0) {
|
|
7
|
+
const inner = document.createElement("div");
|
|
8
|
+
inner.style.width = "100%";
|
|
9
|
+
inner.style.height = "200px";
|
|
10
|
+
const outer = document.createElement("div");
|
|
11
|
+
const outerStyle = outer.style;
|
|
12
|
+
outerStyle.position = "absolute";
|
|
13
|
+
outerStyle.top = "0";
|
|
14
|
+
outerStyle.left = "0";
|
|
15
|
+
outerStyle.pointerEvents = "none";
|
|
16
|
+
outerStyle.visibility = "hidden";
|
|
17
|
+
outerStyle.width = "200px";
|
|
18
|
+
outerStyle.height = "150px";
|
|
19
|
+
outerStyle.overflow = "hidden";
|
|
20
|
+
outer.appendChild(inner);
|
|
21
|
+
document.body.appendChild(outer);
|
|
22
|
+
const widthContained = inner.offsetWidth;
|
|
23
|
+
outer.style.overflow = "scroll";
|
|
24
|
+
let widthScroll = inner.offsetWidth;
|
|
25
|
+
if (widthContained === widthScroll) widthScroll = outer.clientWidth;
|
|
26
|
+
document.body.removeChild(outer);
|
|
27
|
+
cached = widthContained - widthScroll;
|
|
28
|
+
}
|
|
29
|
+
return cached;
|
|
30
|
+
}
|
|
31
|
+
function ensureSize(str) {
|
|
32
|
+
const match = str.match(/^(.*)px$/);
|
|
33
|
+
const value = Number(match?.[1]);
|
|
34
|
+
return Number.isNaN(value) ? getScrollBarSize() : value;
|
|
35
|
+
}
|
|
36
|
+
function getTargetScrollBarSize(target) {
|
|
37
|
+
if (typeof document === "undefined" || !target || !(target instanceof Element)) return {
|
|
38
|
+
width: 0,
|
|
39
|
+
height: 0
|
|
40
|
+
};
|
|
41
|
+
const {
|
|
42
|
+
width,
|
|
43
|
+
height
|
|
44
|
+
} = getComputedStyle(target, "::-webkit-scrollbar");
|
|
45
|
+
return {
|
|
46
|
+
width: ensureSize(width),
|
|
47
|
+
height: ensureSize(height)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
exports.default = getScrollBarSize;
|
|
51
|
+
exports.getTargetScrollBarSize = getTargetScrollBarSize;
|
package/dist/getScrollBarSize.js
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
|
-
let
|
|
2
|
-
function
|
|
3
|
-
if (typeof document
|
|
4
|
-
if (
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
let cached;
|
|
2
|
+
function getScrollBarSize(fresh) {
|
|
3
|
+
if (typeof document === "undefined") return 0;
|
|
4
|
+
if (fresh || cached === void 0) {
|
|
5
|
+
const inner = document.createElement("div");
|
|
6
|
+
inner.style.width = "100%";
|
|
7
|
+
inner.style.height = "200px";
|
|
8
|
+
const outer = document.createElement("div");
|
|
9
|
+
const outerStyle = outer.style;
|
|
10
|
+
outerStyle.position = "absolute";
|
|
11
|
+
outerStyle.top = "0";
|
|
12
|
+
outerStyle.left = "0";
|
|
13
|
+
outerStyle.pointerEvents = "none";
|
|
14
|
+
outerStyle.visibility = "hidden";
|
|
15
|
+
outerStyle.width = "200px";
|
|
16
|
+
outerStyle.height = "150px";
|
|
17
|
+
outerStyle.overflow = "hidden";
|
|
18
|
+
outer.appendChild(inner);
|
|
19
|
+
document.body.appendChild(outer);
|
|
20
|
+
const widthContained = inner.offsetWidth;
|
|
21
|
+
outer.style.overflow = "scroll";
|
|
22
|
+
let widthScroll = inner.offsetWidth;
|
|
23
|
+
if (widthContained === widthScroll) widthScroll = outer.clientWidth;
|
|
24
|
+
document.body.removeChild(outer);
|
|
25
|
+
cached = widthContained - widthScroll;
|
|
13
26
|
}
|
|
14
|
-
return
|
|
27
|
+
return cached;
|
|
15
28
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
|
|
29
|
+
function ensureSize(str) {
|
|
30
|
+
const match = str.match(/^(.*)px$/);
|
|
31
|
+
const value = Number(match?.[1]);
|
|
32
|
+
return Number.isNaN(value) ? getScrollBarSize() : value;
|
|
19
33
|
}
|
|
20
|
-
function
|
|
21
|
-
if (typeof document
|
|
34
|
+
function getTargetScrollBarSize(target) {
|
|
35
|
+
if (typeof document === "undefined" || !target || !(target instanceof Element)) return {
|
|
22
36
|
width: 0,
|
|
23
37
|
height: 0
|
|
24
38
|
};
|
|
25
39
|
const {
|
|
26
|
-
width
|
|
27
|
-
height
|
|
28
|
-
} = getComputedStyle(
|
|
40
|
+
width,
|
|
41
|
+
height
|
|
42
|
+
} = getComputedStyle(target, "::-webkit-scrollbar");
|
|
29
43
|
return {
|
|
30
|
-
width:
|
|
31
|
-
height:
|
|
44
|
+
width: ensureSize(width),
|
|
45
|
+
height: ensureSize(height)
|
|
32
46
|
};
|
|
33
47
|
}
|
|
34
48
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
getScrollBarSize as default,
|
|
50
|
+
getTargetScrollBarSize
|
|
37
51
|
};
|
package/dist/guid.cjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
let seed = 0;
|
|
4
|
+
function guid() {
|
|
5
|
+
return `${Date.now()}_${seed++}`;
|
|
6
|
+
}
|
|
7
|
+
exports.default = guid;
|
package/dist/guid.js
CHANGED
package/dist/hooks/useEvent.cjs
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
function useEvent(callback) {
|
|
4
|
+
return callback;
|
|
5
|
+
}
|
|
6
|
+
exports.default = useEvent;
|
package/dist/hooks/useEvent.js
CHANGED
package/dist/hooks/useId.cjs
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
function getUseId() {
|
|
5
|
+
return vue.useId;
|
|
6
|
+
}
|
|
7
|
+
const useOriginalId = getUseId();
|
|
8
|
+
function useId(id) {
|
|
9
|
+
const vueId = useOriginalId();
|
|
10
|
+
if (id) {
|
|
11
|
+
return id;
|
|
12
|
+
}
|
|
13
|
+
if (process.env.NODE_ENV === "test") {
|
|
14
|
+
return "test-id";
|
|
15
|
+
}
|
|
16
|
+
return vueId;
|
|
17
|
+
}
|
|
18
|
+
exports.default = useId;
|
package/dist/hooks/useId.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { useId as
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import { useId as useId$1 } from "vue";
|
|
2
|
+
function getUseId() {
|
|
3
|
+
return useId$1;
|
|
4
4
|
}
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
|
|
5
|
+
const useOriginalId = getUseId();
|
|
6
|
+
function useId(id) {
|
|
7
|
+
const vueId = useOriginalId();
|
|
8
|
+
if (id) {
|
|
9
|
+
return id;
|
|
10
|
+
}
|
|
11
|
+
if (process.env.NODE_ENV === "test") {
|
|
12
|
+
return "test-id";
|
|
13
|
+
}
|
|
14
|
+
return vueId;
|
|
9
15
|
}
|
|
10
16
|
export {
|
|
11
|
-
|
|
17
|
+
useId as default
|
|
12
18
|
};
|