@v-c/util 1.2.0 → 1.3.0
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/Dom/shadow.d.ts +2 -2
- package/dist/Dom/shadow.js +1 -0
- package/dist/getScrollBarSize.js +4 -2
- package/dist/hooks/useDelayState.js +2 -1
- package/dist/hooks/useMemo.js +3 -2
- package/dist/hooks/useState.js +2 -1
- package/dist/props-util/index.js +4 -3
- package/dist/type.d.ts +11 -0
- package/package.json +6 -6
package/dist/Dom/shadow.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Check if is in shadowRoot
|
|
3
3
|
*/
|
|
4
|
-
export declare function inShadow(ele
|
|
4
|
+
export declare function inShadow(ele?: Node | null): boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Return shadowRoot if possible
|
|
7
7
|
*/
|
|
8
|
-
export declare function getShadowRoot(ele
|
|
8
|
+
export declare function getShadowRoot(ele?: Node | null): ShadowRoot | null;
|
package/dist/Dom/shadow.js
CHANGED
package/dist/getScrollBarSize.js
CHANGED
|
@@ -22,10 +22,12 @@ function measureScrollbarSize(ele) {
|
|
|
22
22
|
const width = parseInt(webkitScrollbarStyle.width, 10);
|
|
23
23
|
const height = parseInt(webkitScrollbarStyle.height, 10);
|
|
24
24
|
try {
|
|
25
|
+
const widthStyle = width ? `width: ${webkitScrollbarStyle.width};` : "";
|
|
26
|
+
const heightStyle = height ? `height: ${webkitScrollbarStyle.height};` : "";
|
|
25
27
|
updateCSS(`
|
|
26
28
|
#${randomId}::-webkit-scrollbar {
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
+
${widthStyle}
|
|
30
|
+
${heightStyle}
|
|
29
31
|
}`, randomId);
|
|
30
32
|
} catch (e) {
|
|
31
33
|
console.error(e);
|
|
@@ -6,7 +6,8 @@ import { onBeforeUnmount, ref } from "vue";
|
|
|
6
6
|
* Pending updates are always replaced by the latest one.
|
|
7
7
|
*/
|
|
8
8
|
function useDelayState(defaultValue) {
|
|
9
|
-
const
|
|
9
|
+
const initValue = typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
10
|
+
const value = ref(initValue);
|
|
10
11
|
let delayInfo = null;
|
|
11
12
|
const cancelPending = () => {
|
|
12
13
|
if (delayInfo) {
|
package/dist/hooks/useMemo.js
CHANGED
|
@@ -2,10 +2,11 @@ import { isReactive, isRef, ref, watch } from "vue";
|
|
|
2
2
|
//#region src/hooks/useMemo.ts
|
|
3
3
|
function useMemo(getValue, condition, shouldUpdate) {
|
|
4
4
|
const cacheRef = ref(getValue());
|
|
5
|
-
|
|
5
|
+
const sources = condition.map((item) => {
|
|
6
6
|
if (typeof item === "function" || isRef(item) || isReactive(item)) return item;
|
|
7
7
|
return () => item;
|
|
8
|
-
})
|
|
8
|
+
});
|
|
9
|
+
watch(sources, (next, pre) => {
|
|
9
10
|
if (shouldUpdate) {
|
|
10
11
|
if (shouldUpdate(next, pre)) cacheRef.value = getValue();
|
|
11
12
|
} else cacheRef.value = getValue();
|
package/dist/hooks/useState.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
2
|
//#region src/hooks/useState.ts
|
|
3
3
|
function useState(defaultStateValue) {
|
|
4
|
-
const
|
|
4
|
+
const initValue = typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
|
|
5
|
+
const innerValue = ref(initValue);
|
|
5
6
|
function triggerChange(newValue) {
|
|
6
7
|
innerValue.value = newValue;
|
|
7
8
|
}
|
package/dist/props-util/index.js
CHANGED
|
@@ -22,9 +22,10 @@ function flattenChildren(children, isFilterEmpty = true) {
|
|
|
22
22
|
temp.forEach((child) => {
|
|
23
23
|
if (Array.isArray(child)) res.push(...flattenChildren(child, isFilterEmpty));
|
|
24
24
|
else if (isValid(child)) res.push(child);
|
|
25
|
-
else if (child && typeof child === "object" && child.type === Fragment)
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
else if (child && typeof child === "object" && child.type === Fragment) {
|
|
26
|
+
if (child.key === skipFlattenKey) res.push(child);
|
|
27
|
+
else res.push(...flattenChildren(child.children, isFilterEmpty));
|
|
28
|
+
} else if (child && isVNode(child)) {
|
|
28
29
|
if (isFilterEmpty && !isEmptyElement(child)) res.push(child);
|
|
29
30
|
else if (!isFilterEmpty) res.push(child);
|
|
30
31
|
}
|
package/dist/type.d.ts
CHANGED
|
@@ -59,4 +59,15 @@ export declare function someType<T>(types?: any[], defaultVal?: T): {
|
|
|
59
59
|
};
|
|
60
60
|
export type CustomSlotsType<T extends Record<string, any>> = SlotsType<T>;
|
|
61
61
|
export type AnyObject = Record<PropertyKey, any>;
|
|
62
|
+
/**
|
|
63
|
+
* Identity wrapper understood by `vite-plugin-tsx-resolve-types`: the wrapped
|
|
64
|
+
* type is excluded from runtime prop inference, the way `/* @vue-ignore *\/`
|
|
65
|
+
* is, but the marker survives declaration emit so it also works for types
|
|
66
|
+
* consumed from a published `.d.ts`.
|
|
67
|
+
*
|
|
68
|
+
* `interface Props extends Base, VueIgnore<Emits> {}` keeps the `Emits`
|
|
69
|
+
* members as fallthrough attrs; `x?: VueIgnore<Heavy>` declares `x` with no
|
|
70
|
+
* runtime type check.
|
|
71
|
+
*/
|
|
72
|
+
export type VueIgnore<T> = T;
|
|
62
73
|
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/util",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "Vue3 components utils",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "aibayanyu20",
|
|
8
|
+
"email": "aibayanyu@qq.com",
|
|
9
|
+
"url": "https://yanyu.me"
|
|
10
|
+
},
|
|
6
11
|
"license": "MIT",
|
|
7
12
|
"homepage": "https://github.com/antdv-next/vue-components/tree/next/packages/util",
|
|
8
13
|
"repository": {
|
|
@@ -12,11 +17,6 @@
|
|
|
12
17
|
"publishConfig": {
|
|
13
18
|
"access": "public"
|
|
14
19
|
},
|
|
15
|
-
"author": {
|
|
16
|
-
"name": "aibayanyu20",
|
|
17
|
-
"email": "aibayanyu@qq.com",
|
|
18
|
-
"url": "https://yanyu.me"
|
|
19
|
-
},
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"types": "./dist/index.d.ts",
|