@v-c/util 1.0.19 → 1.0.20
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.js +2 -0
- package/dist/Children/toArray.js +2 -0
- package/dist/Dom/addEventListener.js +2 -0
- package/dist/Dom/canUseDom.js +2 -0
- package/dist/Dom/class.js +2 -0
- package/dist/Dom/contains.js +2 -0
- package/dist/Dom/css.js +2 -0
- package/dist/Dom/dynamicCSS.js +13 -1
- package/dist/Dom/findDOMNode.js +5 -0
- package/dist/Dom/focus.js +13 -0
- package/dist/Dom/focusBoundary.js +2 -0
- package/dist/Dom/isVisible.js +2 -0
- package/dist/Dom/scrollLocker.js +5 -3
- package/dist/Dom/shadow.js +8 -0
- package/dist/Dom/styleChecker.js +2 -0
- package/dist/Dom/support.js +4 -2
- package/dist/KeyCode.js +329 -3
- package/dist/Portal.js +5 -4
- package/dist/PortalWrapper.d.ts +1 -1
- package/dist/PortalWrapper.js +28 -15
- package/dist/RenderComponent.js +9 -7
- package/dist/classnames.js +3 -1
- package/dist/composeProps.js +3 -2
- package/dist/createRef.js +6 -2
- package/dist/debug/diff.js +3 -1
- package/dist/deprecated.js +2 -0
- package/dist/getScrollBarSize.js +2 -0
- package/dist/guid.js +2 -0
- package/dist/hooks/useControlledState.js +2 -0
- package/dist/hooks/useEvent.js +3 -2
- package/dist/hooks/useId.js +9 -0
- package/dist/hooks/useLayoutEffect.js +2 -0
- package/dist/hooks/useMemo.js +2 -0
- package/dist/hooks/useMergedState.js +2 -0
- package/dist/hooks/useMobile.js +6 -5
- package/dist/hooks/useState.js +2 -0
- package/dist/index.js +4 -4
- package/dist/isEqual.js +11 -4
- package/dist/isMobile.js +3 -2
- package/dist/isValid.js +3 -2
- package/dist/omit.js +2 -0
- package/dist/pickAttrs.js +7 -0
- package/dist/props-util/index.js +5 -3
- package/dist/raf.js +3 -2
- package/dist/setStyle.js +9 -2
- package/dist/switchScrollingEffect.js +5 -3
- package/dist/test/domHook.js +2 -0
- package/dist/type.js +4 -2
- package/dist/utils/checkSlotProp.js +2 -0
- package/dist/utils/get.js +2 -0
- package/dist/utils/omit.js +2 -0
- package/dist/utils/set.js +14 -0
- package/dist/utils/transition.js +2 -0
- package/dist/utils/watchState.js +2 -0
- package/dist/vnode.d.ts +13 -0
- package/dist/vnode.js +32 -4
- package/dist/vueuse/unref-element.js +7 -0
- package/dist/warning.js +7 -2
- package/package.json +7 -1
package/dist/getScrollBarSize.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { removeCSS, updateCSS } from "./Dom/dynamicCSS.js";
|
|
2
|
+
//#region src/getScrollBarSize.tsx
|
|
2
3
|
var cached;
|
|
3
4
|
function measureScrollbarSize(ele) {
|
|
4
5
|
const randomId = `vc-scrollbar-measure-${Math.random().toString(36).substring(7)}`;
|
|
@@ -54,4 +55,5 @@ function getTargetScrollBarSize(target) {
|
|
|
54
55
|
};
|
|
55
56
|
return measureScrollbarSize(target);
|
|
56
57
|
}
|
|
58
|
+
//#endregion
|
|
57
59
|
export { getScrollBarSize as default, getTargetScrollBarSize };
|
package/dist/guid.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { nextTick, shallowRef, toValue, watch } from "vue";
|
|
2
|
+
//#region src/hooks/useControlledState.ts
|
|
2
3
|
function useControlledState(state, emit, updateKey = "value", defaultState, props) {
|
|
3
4
|
const mergedState = shallowRef(defaultState ?? state.value);
|
|
4
5
|
function setState(nextState) {
|
|
@@ -15,4 +16,5 @@ function useControlledState(state, emit, updateKey = "value", defaultState, prop
|
|
|
15
16
|
});
|
|
16
17
|
return [state, setState];
|
|
17
18
|
}
|
|
19
|
+
//#endregion
|
|
18
20
|
export { useControlledState };
|
package/dist/hooks/useEvent.js
CHANGED
package/dist/hooks/useId.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useId } from "vue";
|
|
2
|
+
//#region src/hooks/useId.ts
|
|
2
3
|
function getUseId() {
|
|
3
4
|
return useId;
|
|
4
5
|
}
|
|
@@ -9,7 +10,15 @@ function useId_default(id) {
|
|
|
9
10
|
if (process.env.NODE_ENV === "test") return "test-id";
|
|
10
11
|
return vueId;
|
|
11
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate a valid HTML id from prefix and key.
|
|
15
|
+
* Sanitizes the key by replacing invalid characters with hyphens.
|
|
16
|
+
* @param prefix - The prefix for the id
|
|
17
|
+
* @param key - The element key, may contain spaces or invalid characters
|
|
18
|
+
* @returns A valid HTML id string
|
|
19
|
+
*/
|
|
12
20
|
function getId(prefix, key) {
|
|
13
21
|
return `${prefix}-${String(key).replace(/[^a-zA-Z0-9_.:-]/g, "-")}`;
|
|
14
22
|
}
|
|
23
|
+
//#endregion
|
|
15
24
|
export { useId_default as default, getId };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { nextTick, onMounted, onUnmounted, onUpdated, watch } from "vue";
|
|
2
|
+
//#region src/hooks/useLayoutEffect.ts
|
|
2
3
|
function useLayoutEffect(callback, deps = []) {
|
|
3
4
|
let close = null;
|
|
4
5
|
if (deps && deps.length) watch(deps, async () => {
|
|
@@ -31,4 +32,5 @@ function useLayoutUpdateEffect(callback, deps) {
|
|
|
31
32
|
if (typeof callback === "function") close = callback();
|
|
32
33
|
}, { flush: "post" });
|
|
33
34
|
}
|
|
35
|
+
//#endregion
|
|
34
36
|
export { useLayoutEffect, useLayoutUpdateEffect };
|
package/dist/hooks/useMemo.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isReactive, isRef, ref, watch } from "vue";
|
|
2
|
+
//#region src/hooks/useMemo.ts
|
|
2
3
|
function useMemo(getValue, condition, shouldUpdate) {
|
|
3
4
|
const cacheRef = ref(getValue());
|
|
4
5
|
watch(condition.map((item) => {
|
|
@@ -11,4 +12,5 @@ function useMemo(getValue, condition, shouldUpdate) {
|
|
|
11
12
|
});
|
|
12
13
|
return cacheRef;
|
|
13
14
|
}
|
|
15
|
+
//#endregion
|
|
14
16
|
export { useMemo as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ref, toRaw, unref, watch, watchEffect } from "vue";
|
|
2
|
+
//#region src/hooks/useMergedState.ts
|
|
2
3
|
function useMergedState(defaultStateValue, option) {
|
|
3
4
|
const { defaultValue, value = ref() } = option || {};
|
|
4
5
|
let initValue = typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
|
|
@@ -21,4 +22,5 @@ function useMergedState(defaultStateValue, option) {
|
|
|
21
22
|
});
|
|
22
23
|
return [mergedValue, triggerChange];
|
|
23
24
|
}
|
|
25
|
+
//#endregion
|
|
24
26
|
export { useMergedState as default };
|
package/dist/hooks/useMobile.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import getIsMobile from "../isMobile.js";
|
|
2
2
|
import { onMounted, onUpdated, shallowRef } from "vue";
|
|
3
|
+
//#region src/hooks/useMobile.ts
|
|
3
4
|
function useMobile() {
|
|
4
5
|
const mobile = shallowRef(false);
|
|
5
6
|
onMounted(() => {
|
|
6
|
-
mobile.value =
|
|
7
|
+
mobile.value = getIsMobile();
|
|
7
8
|
});
|
|
8
9
|
onUpdated(() => {
|
|
9
|
-
mobile.value =
|
|
10
|
+
mobile.value = getIsMobile();
|
|
10
11
|
});
|
|
11
12
|
return mobile;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
export {
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useMobile as default, useMobile };
|
package/dist/hooks/useState.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
|
+
//#region src/hooks/useState.ts
|
|
2
3
|
function useState(defaultStateValue) {
|
|
3
4
|
const innerValue = ref(typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue);
|
|
4
5
|
function triggerChange(newValue) {
|
|
@@ -6,4 +7,5 @@ function useState(defaultStateValue) {
|
|
|
6
7
|
}
|
|
7
8
|
return [innerValue, triggerChange];
|
|
8
9
|
}
|
|
10
|
+
//#endregion
|
|
9
11
|
export { useState as default };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import KeyCode from "./KeyCode.js";
|
|
2
|
+
import wrapperRaf from "./raf.js";
|
|
3
3
|
import omit from "./omit.js";
|
|
4
4
|
import RenderComponent_default from "./RenderComponent.js";
|
|
5
5
|
import classNames, { clsx } from "./classnames.js";
|
|
@@ -8,5 +8,5 @@ import useId_default from "./hooks/useId.js";
|
|
|
8
8
|
import useMergedState from "./hooks/useMergedState.js";
|
|
9
9
|
import get from "./utils/get.js";
|
|
10
10
|
import set, { merge, mergeWith } from "./utils/set.js";
|
|
11
|
-
import
|
|
12
|
-
export {
|
|
11
|
+
import warningOnce from "./warning.js";
|
|
12
|
+
export { KeyCode, RenderComponent_default as RenderComponent, classNames, clsx, get, merge, mergeWith, omit, wrapperRaf as raf, set, useControlledState, useId_default as useId, useMergedState, warningOnce as warning };
|
package/dist/isEqual.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import warningOnce from "./warning.js";
|
|
2
|
+
//#region src/isEqual.ts
|
|
3
|
+
/**
|
|
4
|
+
* Deeply compares two object literals.
|
|
5
|
+
* @param obj1 object 1
|
|
6
|
+
* @param obj2 object 2
|
|
7
|
+
* @param shallow shallow compare
|
|
8
|
+
*/
|
|
2
9
|
function isEqual(obj1, obj2, shallow = false) {
|
|
3
10
|
const refSet = /* @__PURE__ */ new Set();
|
|
4
11
|
function deepEqual(a, b, level = 1) {
|
|
5
12
|
const circular = refSet.has(a);
|
|
6
|
-
|
|
13
|
+
warningOnce(!circular, "Warning: There may be circular references");
|
|
7
14
|
if (circular) return false;
|
|
8
15
|
if (a === b) return true;
|
|
9
16
|
if (shallow && level > 1) return false;
|
|
@@ -23,5 +30,5 @@ function isEqual(obj1, obj2, shallow = false) {
|
|
|
23
30
|
}
|
|
24
31
|
return deepEqual(obj1, obj2);
|
|
25
32
|
}
|
|
26
|
-
|
|
27
|
-
export {
|
|
33
|
+
//#endregion
|
|
34
|
+
export { isEqual as default };
|
package/dist/isMobile.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
//#region src/isMobile.ts
|
|
1
2
|
var getIsMobile = () => {
|
|
2
3
|
if (typeof navigator === "undefined" || typeof window === "undefined") return false;
|
|
3
4
|
const agent = navigator.userAgent || navigator.vendor || window.opera;
|
|
4
5
|
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-([mpt])|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c([\- _agpst])|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac([ \-/])|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/([klu])|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t([\- ov])|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[23]|n30(0|2)|n50([025])|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan([adt])|pdxg|pg(13|-([1-8c]))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c([\-01])|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent?.substr(0, 4));
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
-
export {
|
|
7
|
+
//#endregion
|
|
8
|
+
export { getIsMobile as default };
|
package/dist/isValid.js
CHANGED
package/dist/omit.js
CHANGED
package/dist/pickAttrs.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/pickAttrs.ts
|
|
1
2
|
var propList = `accept acceptCharset accessKey action allowFullScreen allowTransparency
|
|
2
3
|
alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
|
|
3
4
|
charSet checked classID className colSpan cols content contentEditable contextMenu
|
|
@@ -21,6 +22,11 @@ var dataPrefix = "data-";
|
|
|
21
22
|
function match(key, prefix) {
|
|
22
23
|
return key.indexOf(prefix) === 0;
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Picker props from exist props with filter
|
|
27
|
+
* @param props Passed props
|
|
28
|
+
* @param ariaOnly boolean | { aria?: boolean; data?: boolean; attr?: boolean; } filter config
|
|
29
|
+
*/
|
|
24
30
|
function pickAttrs(props, ariaOnly = false) {
|
|
25
31
|
let mergedConfig;
|
|
26
32
|
if (ariaOnly === false) mergedConfig = {
|
|
@@ -36,4 +42,5 @@ function pickAttrs(props, ariaOnly = false) {
|
|
|
36
42
|
});
|
|
37
43
|
return attrs;
|
|
38
44
|
}
|
|
45
|
+
//#endregion
|
|
39
46
|
export { pickAttrs as default };
|
package/dist/props-util/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import isValid from "../isValid.js";
|
|
2
2
|
import omit from "../omit.js";
|
|
3
3
|
import { Comment, Fragment, Text, isVNode, toRef } from "vue";
|
|
4
|
+
//#region src/props-util/index.ts
|
|
4
5
|
function isEmptyElement(c) {
|
|
5
6
|
return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === "");
|
|
6
7
|
}
|
|
@@ -14,13 +15,13 @@ function filterEmpty(children = []) {
|
|
|
14
15
|
});
|
|
15
16
|
return res.filter((c) => !isEmptyElement(c));
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
var skipFlattenKey = Symbol("skipFlatten");
|
|
18
19
|
function flattenChildren(children, isFilterEmpty = true) {
|
|
19
20
|
const temp = Array.isArray(children) ? children : [children];
|
|
20
21
|
const res = [];
|
|
21
22
|
temp.forEach((child) => {
|
|
22
23
|
if (Array.isArray(child)) res.push(...flattenChildren(child, isFilterEmpty));
|
|
23
|
-
else if (
|
|
24
|
+
else if (isValid(child)) res.push(child);
|
|
24
25
|
else if (child && typeof child === "object" && child.type === Fragment) if (child.key === skipFlattenKey) res.push(child);
|
|
25
26
|
else res.push(...flattenChildren(child.children, isFilterEmpty));
|
|
26
27
|
else if (child && isVNode(child)) {
|
|
@@ -75,4 +76,5 @@ function getStylePxValue(value) {
|
|
|
75
76
|
}
|
|
76
77
|
return value;
|
|
77
78
|
}
|
|
79
|
+
//#endregion
|
|
78
80
|
export { filterEmpty, flattenChildren, getAttrStyleAndClass, getStylePxValue, isEmptyElement, pureAttrs, removeUndefined, skipFlattenKey, toPropsRefs };
|
package/dist/raf.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/raf.ts
|
|
1
2
|
var raf = (callback) => +setTimeout(callback, 16);
|
|
2
3
|
var caf = (num) => clearTimeout(num);
|
|
3
4
|
if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
|
|
@@ -32,7 +33,6 @@ wrapperRaf.cancel = (id) => {
|
|
|
32
33
|
return caf(realId);
|
|
33
34
|
};
|
|
34
35
|
if (process.env.NODE_ENV !== "production") wrapperRaf.ids = () => rafIds;
|
|
35
|
-
var raf_default = wrapperRaf;
|
|
36
36
|
function rafDebounce(fn) {
|
|
37
37
|
let id = null;
|
|
38
38
|
return () => {
|
|
@@ -40,4 +40,5 @@ function rafDebounce(fn) {
|
|
|
40
40
|
id = wrapperRaf(fn);
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
export { wrapperRaf as default, rafDebounce };
|
package/dist/setStyle.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
//#region src/setStyle.ts
|
|
2
|
+
/**
|
|
3
|
+
* Easy to set element style, return previous style
|
|
4
|
+
* IE browser compatible(IE browser doesn't merge overflow style, need to set it separately)
|
|
5
|
+
* https://github.com/ant-design/ant-design/issues/19393
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
1
8
|
function setStyle(style, options = {}) {
|
|
2
9
|
if (!style) return {};
|
|
3
10
|
const { element = document.body } = options;
|
|
@@ -11,5 +18,5 @@ function setStyle(style, options = {}) {
|
|
|
11
18
|
});
|
|
12
19
|
return oldStyle;
|
|
13
20
|
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
21
|
+
//#endregion
|
|
22
|
+
export { setStyle as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import getScrollBarSize from "./getScrollBarSize.js";
|
|
2
|
-
import
|
|
2
|
+
import setStyle from "./setStyle.js";
|
|
3
|
+
//#region src/switchScrollingEffect.ts
|
|
3
4
|
function isBodyOverflowing() {
|
|
4
5
|
return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth;
|
|
5
6
|
}
|
|
@@ -11,14 +12,14 @@ var switchScrollingEffect_default = (close) => {
|
|
|
11
12
|
const bodyClassName = document.body.className;
|
|
12
13
|
if (close) {
|
|
13
14
|
if (!scrollingEffectClassNameReg.test(bodyClassName)) return;
|
|
14
|
-
|
|
15
|
+
setStyle(cacheStyle);
|
|
15
16
|
cacheStyle = {};
|
|
16
17
|
document.body.className = bodyClassName.replace(scrollingEffectClassNameReg, "").trim();
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
const scrollBarSize = getScrollBarSize();
|
|
20
21
|
if (scrollBarSize) {
|
|
21
|
-
cacheStyle =
|
|
22
|
+
cacheStyle = setStyle({
|
|
22
23
|
position: "relative",
|
|
23
24
|
width: `calc(100% - ${scrollBarSize}px)`
|
|
24
25
|
});
|
|
@@ -28,4 +29,5 @@ var switchScrollingEffect_default = (close) => {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
};
|
|
32
|
+
//#endregion
|
|
31
33
|
export { switchScrollingEffect_default as default };
|
package/dist/test/domHook.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/test/domHook.ts
|
|
1
2
|
var NO_EXIST = { __NOT_EXIST: true };
|
|
2
3
|
function spyElementPrototypes(elementClass, properties) {
|
|
3
4
|
const propNames = Object.keys(properties);
|
|
@@ -34,4 +35,5 @@ function spyElementPrototypes(elementClass, properties) {
|
|
|
34
35
|
function spyElementPrototype(Element, propName, property) {
|
|
35
36
|
return spyElementPrototypes(Element, { [propName]: property });
|
|
36
37
|
}
|
|
38
|
+
//#endregion
|
|
37
39
|
export { spyElementPrototype, spyElementPrototypes };
|
package/dist/type.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/type.ts
|
|
2
|
+
var tuple = (...args) => args;
|
|
3
|
+
var tupleNum = (...args) => args;
|
|
3
4
|
function withInstall(comp) {
|
|
4
5
|
const c = comp;
|
|
5
6
|
c.install = function(app) {
|
|
@@ -56,4 +57,5 @@ function someType(types, defaultVal) {
|
|
|
56
57
|
default: defaultVal
|
|
57
58
|
} : anyType(defaultVal);
|
|
58
59
|
}
|
|
60
|
+
//#endregion
|
|
59
61
|
export { anyType, arrayType, booleanType, eventType, functionType, objectType, someType, stringType, tuple, tupleNum, vNodeType, withInstall };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/utils/checkSlotProp.ts
|
|
1
2
|
function checkSlotProp(props, slots, name, ...args) {
|
|
2
3
|
if (slots[name]) return slots[name]?.(...args);
|
|
3
4
|
if (name in props) {
|
|
@@ -6,4 +7,5 @@ function checkSlotProp(props, slots, name, ...args) {
|
|
|
6
7
|
}
|
|
7
8
|
return null;
|
|
8
9
|
}
|
|
10
|
+
//#endregion
|
|
9
11
|
export { checkSlotProp };
|
package/dist/utils/get.js
CHANGED
package/dist/utils/omit.js
CHANGED
package/dist/utils/set.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import get from "./get.js";
|
|
2
|
+
//#region src/utils/set.ts
|
|
2
3
|
function internalSet(entity, paths, value, removeIfUndefined) {
|
|
3
4
|
if (!paths.length) return value;
|
|
4
5
|
const [path, ...restPath] = paths;
|
|
@@ -21,6 +22,14 @@ function createEmpty(source) {
|
|
|
21
22
|
return Array.isArray(source) ? [] : {};
|
|
22
23
|
}
|
|
23
24
|
var keys = typeof Reflect === "undefined" ? Object.keys : Reflect.ownKeys;
|
|
25
|
+
/**
|
|
26
|
+
* Merge multiple objects. Support custom merge logic.
|
|
27
|
+
* @param sources object sources
|
|
28
|
+
* @param config
|
|
29
|
+
* @param config.prepareArray Customize array prepare function.
|
|
30
|
+
* It will return empty [] by default.
|
|
31
|
+
* So when match array, it will auto be override with next array in sources.
|
|
32
|
+
*/
|
|
24
33
|
function mergeWith(sources, config = {}) {
|
|
25
34
|
const { prepareArray } = config;
|
|
26
35
|
const finalPrepareArray = prepareArray || (() => []);
|
|
@@ -46,7 +55,12 @@ function mergeWith(sources, config = {}) {
|
|
|
46
55
|
});
|
|
47
56
|
return clone;
|
|
48
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Merge multiple objects into a new single object.
|
|
60
|
+
* Arrays will be replaced by default.
|
|
61
|
+
*/
|
|
49
62
|
function merge(...sources) {
|
|
50
63
|
return mergeWith(sources);
|
|
51
64
|
}
|
|
65
|
+
//#endregion
|
|
52
66
|
export { set as default, isObject, merge, mergeWith };
|
package/dist/utils/transition.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { tuple } from "../type.js";
|
|
2
2
|
import { nextTick } from "vue";
|
|
3
|
+
//#region src/utils/transition.ts
|
|
3
4
|
tuple("bottomLeft", "bottomRight", "topLeft", "topRight");
|
|
4
5
|
function getTransitionDirection(placement) {
|
|
5
6
|
if (placement !== void 0 && (placement === "topLeft" || placement === "topRight")) return `slide-down`;
|
|
@@ -86,4 +87,5 @@ function getTransitionName(rootPrefixCls, motion, transitionName) {
|
|
|
86
87
|
if (transitionName !== void 0) return transitionName;
|
|
87
88
|
return `${rootPrefixCls}-${motion}`;
|
|
88
89
|
}
|
|
90
|
+
//#endregion
|
|
89
91
|
export { collapseMotion, getTransitionDirection, getTransitionGroupProps, getTransitionName, getTransitionProps };
|
package/dist/utils/watchState.js
CHANGED
package/dist/vnode.d.ts
CHANGED
|
@@ -10,4 +10,17 @@ export declare function triggerVNodeUpdate(vm: VNode, attrs: Record<string, any>
|
|
|
10
10
|
export declare function ensureValidVNode<T extends Array<unknown>>(slot: T | null): T;
|
|
11
11
|
export declare function customRenderSlot(slots: Slots, name: string, props: Record<string, unknown>, fallback?: () => VNodeArrayChildren): VNodeArrayChildren;
|
|
12
12
|
export declare function resolveToElement(node: any): any;
|
|
13
|
+
/**
|
|
14
|
+
* Create a function-ref callback that resolves the referenced node to a DOM
|
|
15
|
+
* element before handing it to `apply`.
|
|
16
|
+
*
|
|
17
|
+
* Vue invokes function refs synchronously at patch time, while a component's
|
|
18
|
+
* exposed template ref only lands in a post job — and since vue 3.5.39
|
|
19
|
+
* function refs run with tracking paused (vuejs/core#14985), the callback is
|
|
20
|
+
* no longer re-invoked reactively once that ref lands. So when the node is
|
|
21
|
+
* present but not resolvable yet, re-resolve after the current flush instead
|
|
22
|
+
* of applying `null`. A later invocation (e.g. unmount) supersedes the
|
|
23
|
+
* pending retry.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createElementRef<T extends Element = HTMLElement>(apply: (element: T | null, node: any) => void, resolve?: (node: any) => T | null): (node: any) => void;
|
|
13
26
|
export {};
|
package/dist/vnode.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { filterEmpty } from "./props-util/index.js";
|
|
2
|
-
import
|
|
2
|
+
import warningOnce from "./warning.js";
|
|
3
3
|
import { isDOM } from "./Dom/findDOMNode.js";
|
|
4
|
-
import { Comment, Fragment, cloneVNode, isVNode, render } from "vue";
|
|
4
|
+
import { Comment, Fragment, cloneVNode, isVNode, nextTick, render } from "vue";
|
|
5
|
+
//#region src/vnode.ts
|
|
5
6
|
function cloneElement(vnode, nodeProps = {}, override = true, mergeRef = false) {
|
|
6
7
|
let ele = vnode;
|
|
7
8
|
if (Array.isArray(vnode)) ele = filterEmpty(vnode)[0];
|
|
@@ -11,7 +12,7 @@ function cloneElement(vnode, nodeProps = {}, override = true, mergeRef = false)
|
|
|
11
12
|
...node.props,
|
|
12
13
|
...nodeProps
|
|
13
14
|
} : node.props;
|
|
14
|
-
|
|
15
|
+
warningOnce(typeof node.props.class !== "object", "class must be string");
|
|
15
16
|
return node;
|
|
16
17
|
}
|
|
17
18
|
function cloneVNodes(vnodes, nodeProps = {}, override = true) {
|
|
@@ -64,4 +65,31 @@ function resolveToElement(node) {
|
|
|
64
65
|
}
|
|
65
66
|
return null;
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Create a function-ref callback that resolves the referenced node to a DOM
|
|
70
|
+
* element before handing it to `apply`.
|
|
71
|
+
*
|
|
72
|
+
* Vue invokes function refs synchronously at patch time, while a component's
|
|
73
|
+
* exposed template ref only lands in a post job — and since vue 3.5.39
|
|
74
|
+
* function refs run with tracking paused (vuejs/core#14985), the callback is
|
|
75
|
+
* no longer re-invoked reactively once that ref lands. So when the node is
|
|
76
|
+
* present but not resolvable yet, re-resolve after the current flush instead
|
|
77
|
+
* of applying `null`. A later invocation (e.g. unmount) supersedes the
|
|
78
|
+
* pending retry.
|
|
79
|
+
*/
|
|
80
|
+
function createElementRef(apply, resolve = resolveToElement) {
|
|
81
|
+
let seq = 0;
|
|
82
|
+
return (node) => {
|
|
83
|
+
const current = ++seq;
|
|
84
|
+
const element = resolve(node);
|
|
85
|
+
if (node && !element) {
|
|
86
|
+
nextTick(() => {
|
|
87
|
+
if (current === seq) apply(resolve(node), node);
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
apply(element, node);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { cloneElement, cloneVNodes, createElementRef, customRenderSlot, deepCloneElement, ensureValidVNode, resolveToElement, triggerVNodeUpdate };
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { toValue } from "vue";
|
|
2
|
+
//#region src/vueuse/unref-element.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get the dom element of a ref of element or Vue component instance
|
|
5
|
+
*
|
|
6
|
+
* @param elRef
|
|
7
|
+
*/
|
|
2
8
|
function unrefElement(elRef) {
|
|
3
9
|
const plain = toValue(elRef);
|
|
4
10
|
return plain?.$el ?? plain;
|
|
5
11
|
}
|
|
12
|
+
//#endregion
|
|
6
13
|
export { unrefElement };
|
package/dist/warning.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
//#region src/warning.ts
|
|
1
2
|
var warned = {};
|
|
2
3
|
var preWarningFns = [];
|
|
4
|
+
/**
|
|
5
|
+
* Pre warning enable you to parse content before console.error.
|
|
6
|
+
* Modify to null will prevent warning.
|
|
7
|
+
*/
|
|
3
8
|
function preMessage(fn) {
|
|
4
9
|
preWarningFns.push(fn);
|
|
5
10
|
}
|
|
@@ -33,5 +38,5 @@ function noteOnce(valid, message) {
|
|
|
33
38
|
warningOnce.preMessage = preMessage;
|
|
34
39
|
warningOnce.resetWarned = resetWarned;
|
|
35
40
|
warningOnce.noteOnce = noteOnce;
|
|
36
|
-
|
|
37
|
-
export { call,
|
|
41
|
+
//#endregion
|
|
42
|
+
export { call, warningOnce as default, warningOnce, note, noteOnce, preMessage, resetWarned, warning };
|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/util",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.20",
|
|
5
5
|
"description": "Vue3 components utils",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/antdv-next/vue-components/tree/next/packages/util",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/antdv-next/vue-components.git"
|
|
11
|
+
},
|
|
6
12
|
"publishConfig": {
|
|
7
13
|
"access": "public"
|
|
8
14
|
},
|