@v-c/util 1.0.9 → 1.0.10

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.
Files changed (61) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +2 -2
  3. package/dist/utils/set.d.ts +14 -1
  4. package/dist/utils/set.js +9 -4
  5. package/package.json +49 -1
  6. package/dist/Children/isFragment.cjs +0 -6
  7. package/dist/Children/toArray.cjs +0 -14
  8. package/dist/Dom/addEventListener.cjs +0 -9
  9. package/dist/Dom/canUseDom.cjs +0 -8
  10. package/dist/Dom/class.cjs +0 -16
  11. package/dist/Dom/contains.cjs +0 -15
  12. package/dist/Dom/css.cjs +0 -82
  13. package/dist/Dom/dynamicCSS.cjs +0 -86
  14. package/dist/Dom/findDOMNode.cjs +0 -23
  15. package/dist/Dom/focus.cjs +0 -101
  16. package/dist/Dom/isVisible.cjs +0 -20
  17. package/dist/Dom/scrollLocker.cjs +0 -70
  18. package/dist/Dom/shadow.cjs +0 -12
  19. package/dist/Dom/styleChecker.cjs +0 -22
  20. package/dist/Dom/support.cjs +0 -21
  21. package/dist/EventInterface.cjs +0 -1
  22. package/dist/KeyCode.cjs +0 -250
  23. package/dist/Portal.cjs +0 -45
  24. package/dist/PortalWrapper.cjs +0 -138
  25. package/dist/RenderComponent.cjs +0 -34
  26. package/dist/classnames.cjs +0 -40
  27. package/dist/composeProps.cjs +0 -20
  28. package/dist/createRef.cjs +0 -25
  29. package/dist/debug/diff.cjs +0 -47
  30. package/dist/deprecated.cjs +0 -8
  31. package/dist/getScrollBarSize.cjs +0 -58
  32. package/dist/guid.cjs +0 -9
  33. package/dist/hooks/useControlledState.cjs +0 -19
  34. package/dist/hooks/useEvent.cjs +0 -8
  35. package/dist/hooks/useId.cjs +0 -16
  36. package/dist/hooks/useLayoutEffect.cjs +0 -36
  37. package/dist/hooks/useMemo.cjs +0 -18
  38. package/dist/hooks/useMergedState.cjs +0 -28
  39. package/dist/hooks/useMobile.cjs +0 -19
  40. package/dist/hooks/useState.cjs +0 -13
  41. package/dist/index.cjs +0 -24
  42. package/dist/isEqual.cjs +0 -31
  43. package/dist/isMobile.cjs +0 -10
  44. package/dist/isValid.cjs +0 -9
  45. package/dist/omit.cjs +0 -12
  46. package/dist/pickAttrs.cjs +0 -43
  47. package/dist/props-util/index.cjs +0 -87
  48. package/dist/raf.cjs +0 -48
  49. package/dist/setStyle.cjs +0 -19
  50. package/dist/switchScrollingEffect.cjs +0 -35
  51. package/dist/test/domHook.cjs +0 -39
  52. package/dist/type.cjs +0 -71
  53. package/dist/utils/checkSlotProp.cjs +0 -10
  54. package/dist/utils/get.cjs +0 -13
  55. package/dist/utils/omit.cjs +0 -9
  56. package/dist/utils/set.cjs +0 -53
  57. package/dist/utils/transition.cjs +0 -94
  58. package/dist/utils/watchState.cjs +0 -19
  59. package/dist/vnode.cjs +0 -71
  60. package/dist/vueuse/unref-element.cjs +0 -7
  61. package/dist/warning.cjs +0 -48
package/dist/index.d.ts CHANGED
@@ -8,5 +8,5 @@ export { default as raf } from './raf';
8
8
  export { default as RenderComponent } from './RenderComponent';
9
9
  export type { VueNode } from './type';
10
10
  export { default as get } from './utils/get';
11
- export { default as set } from './utils/set';
11
+ export { merge, mergeWith, default as set } from './utils/set';
12
12
  export { default as warning } from './warning';
package/dist/index.js CHANGED
@@ -7,6 +7,6 @@ import { useControlledState } from "./hooks/useControlledState.js";
7
7
  import useId_default from "./hooks/useId.js";
8
8
  import useMergedState from "./hooks/useMergedState.js";
9
9
  import get from "./utils/get.js";
10
- import set from "./utils/set.js";
10
+ import set, { merge, mergeWith } from "./utils/set.js";
11
11
  import warning_default from "./warning.js";
12
- export { KeyCode_default as KeyCode, RenderComponent_default as RenderComponent, classNames, clsx, get, omit, raf_default as raf, set, useControlledState, useId_default as useId, useMergedState, warning_default as warning };
12
+ export { KeyCode_default as KeyCode, RenderComponent_default as RenderComponent, classNames, clsx, get, merge, mergeWith, omit, raf_default as raf, set, useControlledState, useId_default as useId, useMergedState, warning_default as warning };
@@ -1,7 +1,20 @@
1
1
  export type Path = (string | number | symbol)[];
2
2
  export default function set<Entity = any, Output = Entity, Value = any>(entity: Entity, paths: Path, value: Value, removeIfUndefined?: boolean): Output;
3
3
  export declare function isObject(obj: any): boolean;
4
+ export type MergeFn = (current: any, next: any) => any;
4
5
  /**
5
- * Merge objects which will create
6
+ * Merge multiple objects. Support custom merge logic.
7
+ * @param sources object sources
8
+ * @param config
9
+ * @param config.prepareArray Customize array prepare function.
10
+ * It will return empty [] by default.
11
+ * So when match array, it will auto be override with next array in sources.
12
+ */
13
+ export declare function mergeWith<T extends object>(sources: T[], config?: {
14
+ prepareArray?: MergeFn;
15
+ }): T;
16
+ /**
17
+ * Merge multiple objects into a new single object.
18
+ * Arrays will be replaced by default.
6
19
  */
7
20
  export declare function merge<T extends object>(...sources: T[]): T;
package/dist/utils/set.js CHANGED
@@ -21,7 +21,9 @@ function createEmpty(source) {
21
21
  return Array.isArray(source) ? [] : {};
22
22
  }
23
23
  var keys = typeof Reflect === "undefined" ? Object.keys : Reflect.ownKeys;
24
- function merge(...sources) {
24
+ function mergeWith(sources, config = {}) {
25
+ const { prepareArray } = config;
26
+ const finalPrepareArray = prepareArray || (() => []);
25
27
  let clone = createEmpty(sources[0]);
26
28
  sources.forEach((src) => {
27
29
  function internalMerge(path, parentLoopSet) {
@@ -32,10 +34,10 @@ function merge(...sources) {
32
34
  if (!loopSet.has(value)) {
33
35
  loopSet.add(value);
34
36
  const originValue = get(clone, path);
35
- if (isArr) clone = set(clone, path, []);
37
+ if (isArr) clone = set(clone, path, finalPrepareArray(originValue, value));
36
38
  else if (!originValue || typeof originValue !== "object") clone = set(clone, path, createEmpty(value));
37
39
  keys(value).forEach((key) => {
38
- internalMerge([...path, key], loopSet);
40
+ if (Object.getOwnPropertyDescriptor(value, key).enumerable) internalMerge([...path, key], loopSet);
39
41
  });
40
42
  }
41
43
  } else clone = set(clone, path, value);
@@ -44,4 +46,7 @@ function merge(...sources) {
44
46
  });
45
47
  return clone;
46
48
  }
47
- export { set as default, isObject, merge };
49
+ function merge(...sources) {
50
+ return mergeWith(sources);
51
+ }
52
+ export { set as default, isObject, merge, mergeWith };
package/package.json CHANGED
@@ -1,11 +1,59 @@
1
1
  {
2
2
  "name": "@v-c/util",
3
3
  "type": "module",
4
- "version": "1.0.9",
4
+ "version": "1.0.10",
5
5
  "description": "Vue3 components utils",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./dist/*": {
16
+ "types": "./dist/*.d.ts",
17
+ "import": "./dist/*.js",
18
+ "default": "./dist/*.js"
19
+ },
20
+ "./dist/Children/*": {
21
+ "types": "./dist/Children/*.d.ts",
22
+ "import": "./dist/Children/*.js",
23
+ "default": "./dist/Children/*.js"
24
+ },
25
+ "./dist/Dom/*": {
26
+ "types": "./dist/Dom/*.d.ts",
27
+ "import": "./dist/Dom/*.js",
28
+ "default": "./dist/Dom/*.js"
29
+ },
30
+ "./dist/hooks/*": {
31
+ "types": "./dist/hooks/*.d.ts",
32
+ "import": "./dist/hooks/*.js",
33
+ "default": "./dist/hooks/*.js"
34
+ },
35
+ "./dist/props-util/*": {
36
+ "types": "./dist/props-util/*.d.ts",
37
+ "import": "./dist/props-util/*.js",
38
+ "default": "./dist/props-util/*.js"
39
+ },
40
+ "./dist/utils/*": {
41
+ "types": "./dist/utils/*.d.ts",
42
+ "import": "./dist/utils/*.js",
43
+ "default": "./dist/utils/*.js"
44
+ },
45
+ "./dist/vueuse/*": {
46
+ "types": "./dist/vueuse/*.d.ts",
47
+ "import": "./dist/vueuse/*.js",
48
+ "default": "./dist/vueuse/*.js"
49
+ },
50
+ "./dist/debug/*": {
51
+ "types": "./dist/debug/*.d.ts",
52
+ "import": "./dist/debug/*.js",
53
+ "default": "./dist/debug/*.js"
54
+ },
55
+ "./package.json": "./package.json"
56
+ },
9
57
  "author": {
10
58
  "name": "aibayanyu20",
11
59
  "email": "aibayanyu@qq.com",
@@ -1,6 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let vue = require("vue");
3
- function isFragment(node) {
4
- return (0, vue.isVNode)(node) && node.type === vue.Fragment;
5
- }
6
- exports.isFragment = isFragment;
@@ -1,14 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_isFragment = require("./isFragment.cjs");
3
- function toArray(children, option = {}) {
4
- let ret = [];
5
- if (!Array.isArray(children)) children = [children];
6
- for (const child of children) {
7
- if ((child === void 0 || child === null) && !option.keepEmpty) continue;
8
- if (Array.isArray(child)) ret = ret.concat(toArray(child, option));
9
- else if (require_isFragment.isFragment(child) && child.children) ret = ret.concat(toArray(child.children, option));
10
- else ret.push(child);
11
- }
12
- return ret;
13
- }
14
- exports.toArray = toArray;
@@ -1,9 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- function addEventListener(...args) {
3
- const [target, eventType, cb, option] = args;
4
- if (target?.addEventListener) target.addEventListener(eventType, cb, option);
5
- return { remove() {
6
- target?.removeEventListener?.(eventType, cb, option);
7
- } };
8
- }
9
- exports.addEventListener = addEventListener;
@@ -1,8 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- function canUseDom() {
6
- return !!(typeof window !== "undefined" && window.document && window.document.createElement);
7
- }
8
- exports.default = canUseDom;
@@ -1,16 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- function hasClass(node, className) {
3
- if (node.classList) return node.classList.contains(className);
4
- return ` ${node.className} `.includes(` ${className} `);
5
- }
6
- function addClass(node, className) {
7
- if (node.classList) node.classList.add(className);
8
- else if (!hasClass(node, className)) node.className = `${node.className} ${className}`;
9
- }
10
- function removeClass(node, className) {
11
- if (node.classList) node.classList.remove(className);
12
- else if (hasClass(node, className)) node.className = ` ${node.className} `.replace(` ${className} `, " ");
13
- }
14
- exports.addClass = addClass;
15
- exports.hasClass = hasClass;
16
- exports.removeClass = removeClass;
@@ -1,15 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- function contains(root, n) {
6
- if (!root) return false;
7
- if (root.contains) return root.contains(n);
8
- let node = n;
9
- while (node) {
10
- if (node === root) return true;
11
- node = node.parentNode;
12
- }
13
- return false;
14
- }
15
- exports.default = contains;
package/dist/Dom/css.cjs DELETED
@@ -1,82 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- var PIXEL_PATTERN = /margin|padding|width|height|max|min|offset/;
3
- var removePixel = {
4
- left: true,
5
- top: true
6
- };
7
- var floatMap = {
8
- cssFloat: 1,
9
- styleFloat: 1,
10
- float: 1
11
- };
12
- function getComputedStyle(node) {
13
- return node.nodeType === 1 ? node.ownerDocument.defaultView.getComputedStyle(node, null) : {};
14
- }
15
- function getStyleValue(node, type, value) {
16
- type = type.toLowerCase();
17
- if (value === "auto") {
18
- if (type === "height") return node.offsetHeight;
19
- if (type === "width") return node.offsetWidth;
20
- }
21
- if (!(type in removePixel)) removePixel[type] = PIXEL_PATTERN.test(type);
22
- return removePixel[type] ? Number.parseFloat(value) || 0 : value;
23
- }
24
- function get(node, name) {
25
- const length = arguments.length;
26
- const style = getComputedStyle(node);
27
- name = floatMap[name] ? "cssFloat" in node.style ? "cssFloat" : "styleFloat" : name;
28
- return length === 1 ? style : getStyleValue(node, name, style[name] || node.style[name]);
29
- }
30
- function set(node, name, value) {
31
- const length = arguments.length;
32
- name = floatMap[name] ? "cssFloat" in node.style ? "cssFloat" : "styleFloat" : name;
33
- if (length === 3) {
34
- if (typeof value === "number" && PIXEL_PATTERN.test(name)) value = `${value}px`;
35
- node.style[name] = value;
36
- return value;
37
- }
38
- for (const x in name) if (x in name) set(node, x, name[x]);
39
- return getComputedStyle(node);
40
- }
41
- function getOuterWidth(el) {
42
- if (el === document.body) return document.documentElement.clientWidth;
43
- return el.offsetWidth;
44
- }
45
- function getOuterHeight(el) {
46
- if (el === document.body) return window.innerHeight || document.documentElement.clientHeight;
47
- return el.offsetHeight;
48
- }
49
- function getDocSize() {
50
- return {
51
- width: Math.max(document.documentElement.scrollWidth, document.body.scrollWidth),
52
- height: Math.max(document.documentElement.scrollHeight, document.body.scrollHeight)
53
- };
54
- }
55
- function getClientSize() {
56
- return {
57
- width: document.documentElement.clientWidth,
58
- height: window.innerHeight || document.documentElement.clientHeight
59
- };
60
- }
61
- function getScroll() {
62
- return {
63
- scrollLeft: Math.max(document.documentElement.scrollLeft, document.body.scrollLeft),
64
- scrollTop: Math.max(document.documentElement.scrollTop, document.body.scrollTop)
65
- };
66
- }
67
- function getOffset(node) {
68
- const box = node.getBoundingClientRect();
69
- const docElem = document.documentElement;
70
- return {
71
- left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || document.body.clientLeft || 0),
72
- top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || document.body.clientTop || 0)
73
- };
74
- }
75
- exports.get = get;
76
- exports.getClientSize = getClientSize;
77
- exports.getDocSize = getDocSize;
78
- exports.getOffset = getOffset;
79
- exports.getOuterHeight = getOuterHeight;
80
- exports.getOuterWidth = getOuterWidth;
81
- exports.getScroll = getScroll;
82
- exports.set = set;
@@ -1,86 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_canUseDom = require("./canUseDom.cjs");
3
- const require_contains = require("./contains.cjs");
4
- var APPEND_ORDER = "data-vc-order";
5
- var APPEND_PRIORITY = "data-vc-priority";
6
- var MARK_KEY = `vc-util-key`;
7
- var containerCache = /* @__PURE__ */ new Map();
8
- function getMark({ mark } = {}) {
9
- if (mark) return mark.startsWith("data-") ? mark : `data-${mark}`;
10
- return MARK_KEY;
11
- }
12
- function getContainer(option) {
13
- if (option.attachTo) return option.attachTo;
14
- return document.querySelector("head") || document.body;
15
- }
16
- function getOrder(prepend) {
17
- if (prepend === "queue") return "prependQueue";
18
- return prepend ? "prepend" : "append";
19
- }
20
- function findStyles(container) {
21
- return Array.from((containerCache.get(container) || container).children).filter((node) => node.tagName === "STYLE");
22
- }
23
- function injectCSS(css, option = {}) {
24
- if (!require_canUseDom.default()) return null;
25
- const { csp, prepend, priority = 0 } = option;
26
- const mergedOrder = getOrder(prepend);
27
- const isPrependQueue = mergedOrder === "prependQueue";
28
- const styleNode = document.createElement("style");
29
- styleNode.setAttribute(APPEND_ORDER, mergedOrder);
30
- if (isPrependQueue && priority) styleNode.setAttribute(APPEND_PRIORITY, `${priority}`);
31
- if (csp?.nonce) styleNode.nonce = csp?.nonce;
32
- styleNode.innerHTML = css;
33
- const container = getContainer(option);
34
- const { firstChild } = container;
35
- if (prepend) {
36
- if (isPrependQueue) {
37
- const existStyle = findStyles(container).filter((node) => {
38
- if (!["prepend", "prependQueue"].includes(node.getAttribute(APPEND_ORDER))) return false;
39
- return priority >= Number(node.getAttribute(APPEND_PRIORITY) || 0);
40
- });
41
- if (existStyle.length) {
42
- container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
43
- return styleNode;
44
- }
45
- }
46
- container.insertBefore(styleNode, firstChild);
47
- } else container.appendChild(styleNode);
48
- return styleNode;
49
- }
50
- function findExistNode(key, option = {}) {
51
- return findStyles(getContainer(option)).find((node) => node.getAttribute(getMark(option)) === key);
52
- }
53
- function removeCSS(key, option = {}) {
54
- if (!require_canUseDom.default()) return null;
55
- const existNode = findExistNode(key, option);
56
- if (existNode) getContainer(option).removeChild(existNode);
57
- }
58
- function syncRealContainer(container, option) {
59
- const cachedRealContainer = containerCache.get(container);
60
- if (!cachedRealContainer || !require_contains.default(document, cachedRealContainer)) {
61
- const placeholderStyle = injectCSS("", option);
62
- const { parentNode } = placeholderStyle;
63
- containerCache.set(container, parentNode);
64
- container.removeChild(placeholderStyle);
65
- }
66
- }
67
- function clearContainerCache() {
68
- containerCache.clear();
69
- }
70
- function updateCSS(css, key, option = {}) {
71
- if (!require_canUseDom.default()) return null;
72
- syncRealContainer(getContainer(option), option);
73
- const existNode = findExistNode(key, option);
74
- if (existNode) {
75
- if (option.csp?.nonce && existNode.nonce !== option.csp?.nonce) existNode.nonce = option.csp?.nonce;
76
- if (existNode.innerHTML !== css) existNode.innerHTML = css;
77
- return existNode;
78
- }
79
- const newNode = injectCSS(css, option);
80
- newNode.setAttribute(getMark(option), key);
81
- return newNode;
82
- }
83
- exports.clearContainerCache = clearContainerCache;
84
- exports.injectCSS = injectCSS;
85
- exports.removeCSS = removeCSS;
86
- exports.updateCSS = updateCSS;
@@ -1,23 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- let vue = require("vue");
6
- function isDOM(node) {
7
- return node instanceof HTMLElement || node instanceof SVGElement;
8
- }
9
- function getDOM(elementRef) {
10
- const unrefElementRef = (0, vue.unref)(elementRef);
11
- const dom = findDOMNode(unrefElementRef) || (unrefElementRef && typeof unrefElementRef === "object" ? findDOMNode(unrefElementRef.nativeElement) : null);
12
- if (dom && (dom.nodeType === 3 || dom.nodeType === 8) && dom.nextElementSibling) return dom.nextElementSibling;
13
- return dom;
14
- }
15
- function findDOMNode(_node) {
16
- const node = (0, vue.unref)(_node);
17
- if (isDOM(node)) return node;
18
- else if (node && "$el" in node) return node.$el;
19
- return null;
20
- }
21
- exports.default = findDOMNode;
22
- exports.getDOM = getDOM;
23
- exports.isDOM = isDOM;
@@ -1,101 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_isVisible = require("./isVisible.cjs");
3
- let vue = require("vue");
4
- function focusable(node, includePositive = false) {
5
- if (require_isVisible.default(node)) {
6
- const nodeName = node.nodeName.toLowerCase();
7
- const isFocusableElement = [
8
- "input",
9
- "select",
10
- "textarea",
11
- "button"
12
- ].includes(nodeName) || node.isContentEditable || nodeName === "a" && !!node.getAttribute("href");
13
- const tabIndexAttr = node.getAttribute("tabindex");
14
- const tabIndexNum = Number(tabIndexAttr);
15
- let tabIndex = null;
16
- if (tabIndexAttr && !Number.isNaN(tabIndexNum)) tabIndex = tabIndexNum;
17
- else if (isFocusableElement && tabIndex === null) tabIndex = 0;
18
- if (isFocusableElement && node.disabled) tabIndex = null;
19
- return tabIndex !== null && (tabIndex >= 0 || includePositive && tabIndex < 0);
20
- }
21
- return false;
22
- }
23
- function getFocusNodeList(node, includePositive = false) {
24
- const res = [...node.querySelectorAll("*")].filter((child) => {
25
- return focusable(child, includePositive);
26
- });
27
- if (focusable(node, includePositive)) res.unshift(node);
28
- return res;
29
- }
30
- function triggerFocus(element, option) {
31
- if (!element) return;
32
- element.focus(option);
33
- const { cursor } = option || {};
34
- if (cursor) {
35
- const len = element.value.length;
36
- switch (cursor) {
37
- case "start":
38
- element.setSelectionRange(0, 0);
39
- break;
40
- case "end":
41
- element.setSelectionRange(len, len);
42
- break;
43
- default: element.setSelectionRange(0, len);
44
- }
45
- }
46
- }
47
- var lastFocusElement = null;
48
- var focusElements = [];
49
- function getLastElement() {
50
- return focusElements[focusElements.length - 1];
51
- }
52
- function hasFocus(element) {
53
- const { activeElement } = document;
54
- return element === activeElement || element.contains(activeElement);
55
- }
56
- function syncFocus() {
57
- const lastElement = getLastElement();
58
- const { activeElement } = document;
59
- if (lastElement && !hasFocus(lastElement)) {
60
- const focusableList = getFocusNodeList(lastElement);
61
- (focusableList.includes(lastFocusElement) ? lastFocusElement : focusableList[0])?.focus();
62
- } else lastFocusElement = activeElement;
63
- }
64
- function onWindowKeyDown(e) {
65
- if (e.key === "Tab") {
66
- const { activeElement } = document;
67
- const focusableList = getFocusNodeList(getLastElement());
68
- const last = focusableList[focusableList.length - 1];
69
- if (e.shiftKey && activeElement === focusableList[0]) lastFocusElement = last;
70
- else if (!e.shiftKey && activeElement === last) lastFocusElement = focusableList[0];
71
- }
72
- }
73
- function lockFocus(element) {
74
- if (element) {
75
- focusElements = focusElements.filter((ele) => ele !== element);
76
- focusElements.push(element);
77
- window.addEventListener("focusin", syncFocus);
78
- window.addEventListener("keydown", onWindowKeyDown, true);
79
- syncFocus();
80
- }
81
- return () => {
82
- lastFocusElement = null;
83
- focusElements = focusElements.filter((ele) => ele !== element);
84
- if (focusElements.length === 0) {
85
- window.removeEventListener("focusin", syncFocus);
86
- window.removeEventListener("keydown", onWindowKeyDown, true);
87
- }
88
- };
89
- }
90
- function useLockFocus(lock, getElement) {
91
- (0, vue.watch)(lock, (_, _o, onCleanup) => {
92
- if (lock.value) {
93
- const element = getElement();
94
- if (element) onCleanup(lockFocus(element));
95
- }
96
- });
97
- }
98
- exports.getFocusNodeList = getFocusNodeList;
99
- exports.lockFocus = lockFocus;
100
- exports.triggerFocus = triggerFocus;
101
- exports.useLockFocus = useLockFocus;
@@ -1,20 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- var isVisible_default = (element) => {
6
- if (!element) return false;
7
- if (element instanceof Element) {
8
- if (element.offsetParent) return true;
9
- if (element.getBBox) {
10
- const { width, height } = element.getBBox();
11
- if (width || height) return true;
12
- }
13
- if (element.getBoundingClientRect) {
14
- const { width, height } = element.getBoundingClientRect();
15
- if (width || height) return true;
16
- }
17
- }
18
- return false;
19
- };
20
- exports.default = isVisible_default;
@@ -1,70 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_getScrollBarSize = require("../getScrollBarSize.cjs");
6
- const require_setStyle = require("../setStyle.cjs");
7
- var uuid = 0;
8
- var locks = [];
9
- var scrollingEffectClassName = "ant-scrolling-effect";
10
- var scrollingEffectClassNameReg = new RegExp(`${scrollingEffectClassName}`, "g");
11
- var cacheStyle = /* @__PURE__ */ new Map();
12
- var ScrollLocker = class {
13
- lockTarget;
14
- options;
15
- constructor(options) {
16
- this.lockTarget = uuid++;
17
- this.options = options;
18
- }
19
- getContainer = () => {
20
- return this.options?.container;
21
- };
22
- reLock = (options) => {
23
- const findLock = locks.find(({ target }) => target === this.lockTarget);
24
- if (findLock) this.unLock();
25
- this.options = options;
26
- if (findLock) {
27
- findLock.options = options;
28
- this.lock();
29
- }
30
- };
31
- lock = () => {
32
- if (locks.some(({ target }) => target === this.lockTarget)) return;
33
- if (locks.some(({ options }) => options?.container === this.options?.container)) {
34
- locks = [...locks, {
35
- target: this.lockTarget,
36
- options: this.options
37
- }];
38
- return;
39
- }
40
- let scrollBarSize = 0;
41
- const container = this.options?.container || document.body;
42
- if (container === document.body && window.innerWidth - document.documentElement.clientWidth > 0 || container.scrollHeight > container.clientHeight) {
43
- if (getComputedStyle(container).overflow !== "hidden") scrollBarSize = require_getScrollBarSize.default();
44
- }
45
- const containerClassName = container.className;
46
- if (locks.filter(({ options }) => options?.container === this.options?.container).length === 0) cacheStyle.set(container, require_setStyle.default({
47
- width: scrollBarSize !== 0 ? `calc(100% - ${scrollBarSize}px)` : void 0,
48
- overflow: "hidden",
49
- overflowX: "hidden",
50
- overflowY: "hidden"
51
- }, { element: container }));
52
- if (!scrollingEffectClassNameReg.test(containerClassName)) container.className = `${containerClassName} ${scrollingEffectClassName}`.trim();
53
- locks = [...locks, {
54
- target: this.lockTarget,
55
- options: this.options
56
- }];
57
- };
58
- unLock = () => {
59
- const findLock = locks.find(({ target }) => target === this.lockTarget);
60
- locks = locks.filter(({ target }) => target !== this.lockTarget);
61
- if (!findLock || locks.some(({ options }) => options?.container === findLock.options?.container)) return;
62
- const container = this.options?.container || document.body;
63
- const containerClassName = container.className;
64
- if (!scrollingEffectClassNameReg.test(containerClassName)) return;
65
- require_setStyle.default(cacheStyle.get(container), { element: container });
66
- cacheStyle.delete(container);
67
- container.className = container.className.replace(scrollingEffectClassNameReg, "").trim();
68
- };
69
- };
70
- exports.default = ScrollLocker;
@@ -1,12 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- function getRoot(ele) {
3
- return ele?.getRootNode?.();
4
- }
5
- function inShadow(ele) {
6
- return getRoot(ele) instanceof ShadowRoot;
7
- }
8
- function getShadowRoot(ele) {
9
- return inShadow(ele) ? getRoot(ele) : null;
10
- }
11
- exports.getShadowRoot = getShadowRoot;
12
- exports.inShadow = inShadow;
@@ -1,22 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_canUseDom = require("./canUseDom.cjs");
3
- function isStyleNameSupport(styleName) {
4
- if (require_canUseDom.default() && window.document.documentElement) {
5
- const styleNameList = Array.isArray(styleName) ? styleName : [styleName];
6
- const { documentElement } = window.document;
7
- return styleNameList.some((name) => name in documentElement.style);
8
- }
9
- return false;
10
- }
11
- function isStyleValueSupport(styleName, value) {
12
- if (!isStyleNameSupport(styleName)) return false;
13
- const ele = document.createElement("div");
14
- const origin = ele.style[styleName];
15
- ele.style[styleName] = value;
16
- return ele.style[styleName] !== origin;
17
- }
18
- function isStyleSupport(styleName, styleValue) {
19
- if (!Array.isArray(styleName) && styleValue !== void 0) return isStyleValueSupport(styleName, styleValue);
20
- return isStyleNameSupport(styleName);
21
- }
22
- exports.isStyleSupport = isStyleSupport;
@@ -1,21 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_canUseDom = require("./canUseDom.cjs");
3
- var animationEndEventNames = {
4
- WebkitAnimation: "webkitAnimationEnd",
5
- OAnimation: "oAnimationEnd",
6
- animation: "animationend"
7
- };
8
- var transitionEventNames = {
9
- WebkitTransition: "webkitTransitionEnd",
10
- OTransition: "oTransitionEnd",
11
- transition: "transitionend"
12
- };
13
- function supportEnd(names) {
14
- const el = document.createElement("div");
15
- for (const name in names) if (names.hasOwnProperty(name) && el.style[name] !== void 0) return { end: names[name] };
16
- return false;
17
- }
18
- const animation = require_canUseDom.default() && supportEnd(animationEndEventNames);
19
- const transition = require_canUseDom.default() && supportEnd(transitionEventNames);
20
- exports.animation = animation;
21
- exports.transition = transition;
@@ -1 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });