@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/Children/toArray.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isFragment } from "./isFragment.js";
|
|
2
|
+
//#region src/Children/toArray.ts
|
|
2
3
|
function toArray(children, option = {}) {
|
|
3
4
|
let ret = [];
|
|
4
5
|
if (!Array.isArray(children)) children = [children];
|
|
@@ -10,4 +11,5 @@ function toArray(children, option = {}) {
|
|
|
10
11
|
}
|
|
11
12
|
return ret;
|
|
12
13
|
}
|
|
14
|
+
//#endregion
|
|
13
15
|
export { toArray };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/Dom/addEventListener.ts
|
|
1
2
|
function addEventListener(...args) {
|
|
2
3
|
const [target, eventType, cb, option] = args;
|
|
3
4
|
if (target?.addEventListener) target.addEventListener(eventType, cb, option);
|
|
@@ -5,4 +6,5 @@ function addEventListener(...args) {
|
|
|
5
6
|
target?.removeEventListener?.(eventType, cb, option);
|
|
6
7
|
} };
|
|
7
8
|
}
|
|
9
|
+
//#endregion
|
|
8
10
|
export { addEventListener };
|
package/dist/Dom/canUseDom.js
CHANGED
package/dist/Dom/class.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/Dom/class.ts
|
|
1
2
|
function hasClass(node, className) {
|
|
2
3
|
if (node.classList) return node.classList.contains(className);
|
|
3
4
|
return ` ${node.className} `.includes(` ${className} `);
|
|
@@ -10,4 +11,5 @@ function removeClass(node, className) {
|
|
|
10
11
|
if (node.classList) node.classList.remove(className);
|
|
11
12
|
else if (hasClass(node, className)) node.className = ` ${node.className} `.replace(` ${className} `, " ");
|
|
12
13
|
}
|
|
14
|
+
//#endregion
|
|
13
15
|
export { addClass, hasClass, removeClass };
|
package/dist/Dom/contains.js
CHANGED
package/dist/Dom/css.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/Dom/css.ts
|
|
1
2
|
var PIXEL_PATTERN = /margin|padding|width|height|max|min|offset/;
|
|
2
3
|
var removePixel = {
|
|
3
4
|
left: true,
|
|
@@ -71,4 +72,5 @@ function getOffset(node) {
|
|
|
71
72
|
top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || document.body.clientTop || 0)
|
|
72
73
|
};
|
|
73
74
|
}
|
|
75
|
+
//#endregion
|
|
74
76
|
export { get, getClientSize, getDocSize, getOffset, getOuterHeight, getOuterWidth, getScroll, set };
|
package/dist/Dom/dynamicCSS.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import canUseDom from "./canUseDom.js";
|
|
2
2
|
import contains from "./contains.js";
|
|
3
|
+
//#region src/Dom/dynamicCSS.ts
|
|
3
4
|
var APPEND_ORDER = "data-vc-order";
|
|
4
5
|
var APPEND_PRIORITY = "data-vc-priority";
|
|
5
6
|
var MARK_KEY = `vc-util-key`;
|
|
@@ -16,6 +17,9 @@ function getOrder(prepend) {
|
|
|
16
17
|
if (prepend === "queue") return "prependQueue";
|
|
17
18
|
return prepend ? "prepend" : "append";
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Find style which inject by rc-util
|
|
22
|
+
*/
|
|
19
23
|
function findStyles(container) {
|
|
20
24
|
return Array.from((containerCache.get(container) || container).children).filter((node) => node.tagName === "STYLE");
|
|
21
25
|
}
|
|
@@ -35,7 +39,8 @@ function injectCSS(css, option = {}) {
|
|
|
35
39
|
if (isPrependQueue) {
|
|
36
40
|
const existStyle = findStyles(container).filter((node) => {
|
|
37
41
|
if (!["prepend", "prependQueue"].includes(node.getAttribute(APPEND_ORDER))) return false;
|
|
38
|
-
|
|
42
|
+
const nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0);
|
|
43
|
+
return priority >= nodePriority;
|
|
39
44
|
});
|
|
40
45
|
if (existStyle.length) {
|
|
41
46
|
container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
|
|
@@ -54,6 +59,9 @@ function removeCSS(key, option = {}) {
|
|
|
54
59
|
const existNode = findExistNode(key, option);
|
|
55
60
|
if (existNode) getContainer(option).removeChild(existNode);
|
|
56
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* qiankun will inject `appendChild` to insert into other
|
|
64
|
+
*/
|
|
57
65
|
function syncRealContainer(container, option) {
|
|
58
66
|
const cachedRealContainer = containerCache.get(container);
|
|
59
67
|
if (!cachedRealContainer || !contains(document, cachedRealContainer)) {
|
|
@@ -63,6 +71,9 @@ function syncRealContainer(container, option) {
|
|
|
63
71
|
container.removeChild(placeholderStyle);
|
|
64
72
|
}
|
|
65
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* manually clear container cache to avoid global cache in unit testes
|
|
76
|
+
*/
|
|
66
77
|
function clearContainerCache() {
|
|
67
78
|
containerCache.clear();
|
|
68
79
|
}
|
|
@@ -79,4 +90,5 @@ function updateCSS(css, key, option = {}) {
|
|
|
79
90
|
newNode.setAttribute(getMark(option), key);
|
|
80
91
|
return newNode;
|
|
81
92
|
}
|
|
93
|
+
//#endregion
|
|
82
94
|
export { clearContainerCache, injectCSS, removeCSS, updateCSS };
|
package/dist/Dom/findDOMNode.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import canUseDom from "./canUseDom.js";
|
|
2
2
|
import { unref } from "vue";
|
|
3
|
+
//#region src/Dom/findDOMNode.ts
|
|
3
4
|
function isDOM(node) {
|
|
4
5
|
return node instanceof HTMLElement || node instanceof SVGElement;
|
|
5
6
|
}
|
|
@@ -10,6 +11,9 @@ function getDOM(elementRef) {
|
|
|
10
11
|
if (dom && (dom.nodeType === 3 || dom.nodeType === 8) && dom.nextElementSibling) return dom.nextElementSibling;
|
|
11
12
|
return dom;
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Return if a node is a DOM node. Else will return by `findDOMNode`
|
|
16
|
+
*/
|
|
13
17
|
function findDOMNode(_node) {
|
|
14
18
|
const node = unref(_node);
|
|
15
19
|
if (!canUseDom()) return node;
|
|
@@ -17,4 +21,5 @@ function findDOMNode(_node) {
|
|
|
17
21
|
else if (node && "$el" in node) return node.$el;
|
|
18
22
|
return null;
|
|
19
23
|
}
|
|
24
|
+
//#endregion
|
|
20
25
|
export { findDOMNode as default, getDOM, isDOM };
|
package/dist/Dom/focus.js
CHANGED
|
@@ -2,6 +2,7 @@ import useId_default from "../hooks/useId.js";
|
|
|
2
2
|
import { getDOM } from "./findDOMNode.js";
|
|
3
3
|
import isVisible_default from "./isVisible.js";
|
|
4
4
|
import { watch } from "vue";
|
|
5
|
+
//#region src/Dom/focus.ts
|
|
5
6
|
function focusable(node, includePositive = false) {
|
|
6
7
|
if (isVisible_default(node)) {
|
|
7
8
|
const nodeName = node.nodeName.toLowerCase();
|
|
@@ -94,6 +95,11 @@ function onWindowKeyDown(e) {
|
|
|
94
95
|
else if (!e.shiftKey && activeElement === last) lastFocusElement = focusableList[0];
|
|
95
96
|
}
|
|
96
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Lock focus in the element.
|
|
100
|
+
* It will force back to the first focusable element when focus leaves the element.
|
|
101
|
+
* @param id - A stable ID for this lock instance
|
|
102
|
+
*/
|
|
97
103
|
function lockFocus(element, id) {
|
|
98
104
|
if (element) {
|
|
99
105
|
idToElementMap.set(id, element);
|
|
@@ -115,6 +121,12 @@ function lockFocus(element, id) {
|
|
|
115
121
|
}
|
|
116
122
|
};
|
|
117
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Lock focus within an element.
|
|
126
|
+
* When locked, focus will be restricted to focusable elements within the specified element.
|
|
127
|
+
* If multiple elements are locked, only the last locked element will be effective.
|
|
128
|
+
* @returns A function to mark an element as ignored, which will temporarily allow focus on that element even if it's outside the locked area.
|
|
129
|
+
*/
|
|
118
130
|
function useLockFocus(lock, getElement) {
|
|
119
131
|
const id = useId_default();
|
|
120
132
|
watch([lock, () => getElement()], ([nextLock, element], _o, onCleanup) => {
|
|
@@ -143,4 +155,5 @@ function useLockFocus(lock, getElement) {
|
|
|
143
155
|
};
|
|
144
156
|
return [ignoreElement, registerAllowedElement];
|
|
145
157
|
}
|
|
158
|
+
//#endregion
|
|
146
159
|
export { getFocusNodeList, lockFocus, triggerFocus, useLockFocus };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { inject, provide } from "vue";
|
|
2
|
+
//#region src/Dom/focusBoundary.ts
|
|
2
3
|
var FocusBoundaryContextKey = Symbol("FocusBoundaryContext");
|
|
3
4
|
function useFocusBoundaryProvider(props) {
|
|
4
5
|
provide(FocusBoundaryContextKey, props);
|
|
@@ -6,4 +7,5 @@ function useFocusBoundaryProvider(props) {
|
|
|
6
7
|
function useFocusBoundary() {
|
|
7
8
|
return inject(FocusBoundaryContextKey, null);
|
|
8
9
|
}
|
|
10
|
+
//#endregion
|
|
9
11
|
export { useFocusBoundary, useFocusBoundaryProvider };
|
package/dist/Dom/isVisible.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/Dom/isVisible.ts
|
|
1
2
|
var isVisible_default = (element) => {
|
|
2
3
|
if (!element) return false;
|
|
3
4
|
if (element instanceof Element) {
|
|
@@ -13,4 +14,5 @@ var isVisible_default = (element) => {
|
|
|
13
14
|
}
|
|
14
15
|
return false;
|
|
15
16
|
};
|
|
17
|
+
//#endregion
|
|
16
18
|
export { isVisible_default as default };
|
package/dist/Dom/scrollLocker.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import getScrollBarSize from "../getScrollBarSize.js";
|
|
2
|
-
import
|
|
2
|
+
import setStyle from "../setStyle.js";
|
|
3
|
+
//#region src/Dom/scrollLocker.ts
|
|
3
4
|
var uuid = 0;
|
|
4
5
|
var locks = [];
|
|
5
6
|
var scrollingEffectClassName = "ant-scrolling-effect";
|
|
@@ -39,7 +40,7 @@ var ScrollLocker = class {
|
|
|
39
40
|
if (getComputedStyle(container).overflow !== "hidden") scrollBarSize = getScrollBarSize();
|
|
40
41
|
}
|
|
41
42
|
const containerClassName = container.className;
|
|
42
|
-
if (locks.filter(({ options }) => options?.container === this.options?.container).length === 0) cacheStyle.set(container,
|
|
43
|
+
if (locks.filter(({ options }) => options?.container === this.options?.container).length === 0) cacheStyle.set(container, setStyle({
|
|
43
44
|
width: scrollBarSize !== 0 ? `calc(100% - ${scrollBarSize}px)` : void 0,
|
|
44
45
|
overflow: "hidden",
|
|
45
46
|
overflowX: "hidden",
|
|
@@ -58,9 +59,10 @@ var ScrollLocker = class {
|
|
|
58
59
|
const container = this.options?.container || document.body;
|
|
59
60
|
const containerClassName = container.className;
|
|
60
61
|
if (!scrollingEffectClassNameReg.test(containerClassName)) return;
|
|
61
|
-
|
|
62
|
+
setStyle(cacheStyle.get(container), { element: container });
|
|
62
63
|
cacheStyle.delete(container);
|
|
63
64
|
container.className = container.className.replace(scrollingEffectClassNameReg, "").trim();
|
|
64
65
|
};
|
|
65
66
|
};
|
|
67
|
+
//#endregion
|
|
66
68
|
export { ScrollLocker as default };
|
package/dist/Dom/shadow.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
//#region src/Dom/shadow.ts
|
|
1
2
|
function getRoot(ele) {
|
|
2
3
|
return ele?.getRootNode?.();
|
|
3
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* Check if is in shadowRoot
|
|
7
|
+
*/
|
|
4
8
|
function inShadow(ele) {
|
|
5
9
|
return getRoot(ele) instanceof ShadowRoot;
|
|
6
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Return shadowRoot if possible
|
|
13
|
+
*/
|
|
7
14
|
function getShadowRoot(ele) {
|
|
8
15
|
return inShadow(ele) ? getRoot(ele) : null;
|
|
9
16
|
}
|
|
17
|
+
//#endregion
|
|
10
18
|
export { getShadowRoot, inShadow };
|
package/dist/Dom/styleChecker.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import canUseDom from "./canUseDom.js";
|
|
2
|
+
//#region src/Dom/styleChecker.ts
|
|
2
3
|
function isStyleNameSupport(styleName) {
|
|
3
4
|
if (canUseDom() && window.document.documentElement) {
|
|
4
5
|
const styleNameList = Array.isArray(styleName) ? styleName : [styleName];
|
|
@@ -18,4 +19,5 @@ function isStyleSupport(styleName, styleValue) {
|
|
|
18
19
|
if (!Array.isArray(styleName) && styleValue !== void 0) return isStyleValueSupport(styleName, styleValue);
|
|
19
20
|
return isStyleNameSupport(styleName);
|
|
20
21
|
}
|
|
22
|
+
//#endregion
|
|
21
23
|
export { isStyleSupport };
|
package/dist/Dom/support.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import canUseDom from "./canUseDom.js";
|
|
2
|
+
//#region src/Dom/support.ts
|
|
2
3
|
var animationEndEventNames = {
|
|
3
4
|
WebkitAnimation: "webkitAnimationEnd",
|
|
4
5
|
OAnimation: "oAnimationEnd",
|
|
@@ -14,6 +15,7 @@ function supportEnd(names) {
|
|
|
14
15
|
for (const name in names) if (names.hasOwnProperty(name) && el.style[name] !== void 0) return { end: names[name] };
|
|
15
16
|
return false;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
var animation = canUseDom() && supportEnd(animationEndEventNames);
|
|
19
|
+
var transition = canUseDom() && supportEnd(transitionEventNames);
|
|
20
|
+
//#endregion
|
|
19
21
|
export { animation, transition };
|