@v-c/util 0.0.12 → 0.0.14

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 (110) hide show
  1. package/dist/Children/isFragment.cjs +5 -1
  2. package/dist/Children/isFragment.js +4 -6
  3. package/dist/Children/toArray.cjs +13 -1
  4. package/dist/Children/toArray.js +12 -10
  5. package/dist/Dom/addEventListener.cjs +8 -1
  6. package/dist/Dom/addEventListener.js +7 -10
  7. package/dist/Dom/canUseDom.cjs +5 -1
  8. package/dist/Dom/canUseDom.js +3 -5
  9. package/dist/Dom/class.cjs +15 -1
  10. package/dist/Dom/class.js +10 -16
  11. package/dist/Dom/contains.cjs +12 -1
  12. package/dist/Dom/contains.js +10 -15
  13. package/dist/Dom/css.cjs +81 -1
  14. package/dist/Dom/css.js +63 -64
  15. package/dist/Dom/dynamicCSS.cjs +83 -1
  16. package/dist/Dom/dynamicCSS.js +70 -67
  17. package/dist/Dom/findDOMNode.cjs +13 -1
  18. package/dist/Dom/findDOMNode.js +9 -10
  19. package/dist/Dom/focus.cjs +53 -1
  20. package/dist/Dom/focus.js +43 -34
  21. package/dist/Dom/isVisible.cjs +17 -1
  22. package/dist/Dom/isVisible.js +15 -21
  23. package/dist/Dom/scrollLocker.cjs +67 -1
  24. package/dist/Dom/scrollLocker.js +65 -63
  25. package/dist/Dom/shadow.cjs +11 -1
  26. package/dist/Dom/shadow.js +7 -10
  27. package/dist/Dom/styleChecker.cjs +21 -1
  28. package/dist/Dom/styleChecker.js +18 -17
  29. package/dist/Dom/support.cjs +20 -1
  30. package/dist/Dom/support.js +17 -22
  31. package/dist/EventInterface.cjs +0 -1
  32. package/dist/EventInterface.js +0 -1
  33. package/dist/KeyCode.cjs +166 -1
  34. package/dist/KeyCode.js +164 -515
  35. package/dist/Portal.cjs +42 -1
  36. package/dist/Portal.js +38 -31
  37. package/dist/PortalWrapper.cjs +135 -1
  38. package/dist/PortalWrapper.js +130 -113
  39. package/dist/classnames.cjs +37 -1
  40. package/dist/classnames.js +33 -30
  41. package/dist/composeProps.cjs +17 -1
  42. package/dist/composeProps.js +15 -12
  43. package/dist/createRef.cjs +22 -1
  44. package/dist/createRef.js +16 -18
  45. package/dist/debug/diff.cjs +44 -1
  46. package/dist/debug/diff.js +41 -39
  47. package/dist/deprecated.cjs +5 -1
  48. package/dist/deprecated.js +3 -7
  49. package/dist/getScrollBarSize.cjs +47 -1
  50. package/dist/getScrollBarSize.js +42 -34
  51. package/dist/guid.cjs +6 -1
  52. package/dist/guid.js +4 -6
  53. package/dist/hooks/useEvent.cjs +5 -1
  54. package/dist/hooks/useEvent.js +3 -5
  55. package/dist/hooks/useId.cjs +13 -1
  56. package/dist/hooks/useId.js +10 -10
  57. package/dist/hooks/useLayoutEffect.cjs +35 -1
  58. package/dist/hooks/useLayoutEffect.js +32 -26
  59. package/dist/hooks/useMemo.cjs +12 -1
  60. package/dist/hooks/useMemo.js +10 -9
  61. package/dist/hooks/useMergedState.cjs +25 -1
  62. package/dist/hooks/useMergedState.js +23 -20
  63. package/dist/hooks/useMobile.cjs +16 -1
  64. package/dist/hooks/useMobile.js +13 -13
  65. package/dist/hooks/useState.cjs +10 -1
  66. package/dist/hooks/useState.js +8 -10
  67. package/dist/index.cjs +9 -1
  68. package/dist/index.js +5 -11
  69. package/dist/isEqual.cjs +28 -1
  70. package/dist/isEqual.js +26 -31
  71. package/dist/isMobile.cjs +7 -1
  72. package/dist/isMobile.js +5 -12
  73. package/dist/isValid.cjs +6 -1
  74. package/dist/isValid.js +4 -5
  75. package/dist/omit.cjs +9 -1
  76. package/dist/omit.js +7 -8
  77. package/dist/pickAttrs.cjs +25 -3
  78. package/dist/pickAttrs.js +22 -24
  79. package/dist/props-util/index.cjs +52 -1
  80. package/dist/props-util/index.js +42 -34
  81. package/dist/raf.cjs +45 -1
  82. package/dist/raf.js +39 -33
  83. package/dist/setStyle.cjs +16 -1
  84. package/dist/setStyle.js +14 -12
  85. package/dist/switchScrollingEffect.cjs +32 -1
  86. package/dist/switchScrollingEffect.js +29 -29
  87. package/dist/test/domHook.cjs +38 -1
  88. package/dist/test/domHook.js +35 -35
  89. package/dist/type.cjs +70 -1
  90. package/dist/type.d.ts +1 -1
  91. package/dist/type.js +59 -49
  92. package/dist/utils/checkSlotProp.cjs +9 -1
  93. package/dist/utils/checkSlotProp.js +8 -5
  94. package/dist/utils/get.cjs +10 -1
  95. package/dist/utils/get.js +8 -11
  96. package/dist/utils/omit.cjs +8 -1
  97. package/dist/utils/omit.js +7 -8
  98. package/dist/utils/set.cjs +50 -1
  99. package/dist/utils/set.js +42 -37
  100. package/dist/utils/transition.cjs +92 -1
  101. package/dist/utils/transition.js +83 -86
  102. package/dist/utils/watchState.cjs +18 -1
  103. package/dist/utils/watchState.js +15 -13
  104. package/dist/vnode.cjs +48 -1
  105. package/dist/vnode.js +38 -34
  106. package/dist/vueuse/unref-element.cjs +6 -1
  107. package/dist/vueuse/unref-element.js +5 -7
  108. package/dist/warning.cjs +45 -1
  109. package/dist/warning.js +30 -41
  110. package/package.json +1 -1
@@ -1 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue");function r(e){return t.isVNode(e)&&e.type===t.Fragment}exports.isFragment=r;
1
+ let vue = require("vue");
2
+ function isFragment(node) {
3
+ return (0, vue.isVNode)(node) && node.type === vue.Fragment;
4
+ }
5
+ exports.isFragment = isFragment;
@@ -1,7 +1,5 @@
1
- import { isVNode as t, Fragment as e } from "vue";
2
- function m(r) {
3
- return t(r) && r.type === e;
1
+ import { Fragment, isVNode } from "vue";
2
+ function isFragment(node) {
3
+ return isVNode(node) && node.type === Fragment;
4
4
  }
5
- export {
6
- m as isFragment
7
- };
5
+ export { isFragment };
@@ -1 +1,13 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./isFragment.cjs");function a(t,i={}){let e=[];Array.isArray(t)||(t=[t]);for(const r of t)r==null&&!i.keepEmpty||(Array.isArray(r)?e=e.concat(a(r,i)):n.isFragment(r)&&r.children?e=e.concat(a(r.children,i)):e.push(r));return e}exports.toArray=a;
1
+ const require_isFragment = require("./isFragment.cjs");
2
+ function toArray(children, option = {}) {
3
+ let ret = [];
4
+ if (!Array.isArray(children)) children = [children];
5
+ for (const child of children) {
6
+ if ((child === void 0 || child === null) && !option.keepEmpty) continue;
7
+ if (Array.isArray(child)) ret = ret.concat(toArray(child, option));
8
+ else if (require_isFragment.isFragment(child) && child.children) ret = ret.concat(toArray(child.children, option));
9
+ else ret.push(child);
10
+ }
11
+ return ret;
12
+ }
13
+ exports.toArray = toArray;
@@ -1,11 +1,13 @@
1
- import { isFragment as f } from "./isFragment.js";
2
- function a(t, i = {}) {
3
- let e = [];
4
- Array.isArray(t) || (t = [t]);
5
- for (const r of t)
6
- r == null && !i.keepEmpty || (Array.isArray(r) ? e = e.concat(a(r, i)) : f(r) && r.children ? e = e.concat(a(r.children, i)) : e.push(r));
7
- return e;
1
+ import { isFragment } from "./isFragment.js";
2
+ function toArray(children, option = {}) {
3
+ let ret = [];
4
+ if (!Array.isArray(children)) children = [children];
5
+ for (const child of children) {
6
+ if ((child === void 0 || child === null) && !option.keepEmpty) continue;
7
+ if (Array.isArray(child)) ret = ret.concat(toArray(child, option));
8
+ else if (isFragment(child) && child.children) ret = ret.concat(toArray(child.children, option));
9
+ else ret.push(child);
10
+ }
11
+ return ret;
8
12
  }
9
- export {
10
- a as toArray
11
- };
13
+ export { toArray };
@@ -1 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function d(...i){const[e,t,n,r]=i;return e?.addEventListener&&e.addEventListener(t,n,r),{remove(){e?.removeEventListener?.(t,n,r)}}}exports.addEventListener=d;
1
+ function addEventListener(...args) {
2
+ const [target, eventType, cb, option] = args;
3
+ if (target?.addEventListener) target.addEventListener(eventType, cb, option);
4
+ return { remove() {
5
+ target?.removeEventListener?.(eventType, cb, option);
6
+ } };
7
+ }
8
+ exports.addEventListener = addEventListener;
@@ -1,11 +1,8 @@
1
- function o(...i) {
2
- const [e, t, n, r] = i;
3
- return e?.addEventListener && e.addEventListener(t, n, r), {
4
- remove() {
5
- e?.removeEventListener?.(t, n, r);
6
- }
7
- };
1
+ function addEventListener(...args) {
2
+ const [target, eventType, cb, option] = args;
3
+ if (target?.addEventListener) target.addEventListener(eventType, cb, option);
4
+ return { remove() {
5
+ target?.removeEventListener?.(eventType, cb, option);
6
+ } };
8
7
  }
9
- export {
10
- o as addEventListener
11
- };
8
+ export { addEventListener };
@@ -1 +1,5 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function e(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}exports.default=e;
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ function canUseDom() {
3
+ return !!(typeof window !== "undefined" && window.document && window.document.createElement);
4
+ }
5
+ exports.default = canUseDom;
@@ -1,6 +1,4 @@
1
- function e() {
2
- return !!(typeof window < "u" && window.document && window.document.createElement);
1
+ function canUseDom() {
2
+ return !!(typeof window !== "undefined" && window.document && window.document.createElement);
3
3
  }
4
- export {
5
- e as default
6
- };
4
+ export { canUseDom as default };
@@ -1 +1,15 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(s,i){return s.classList?s.classList.contains(i):` ${s.className} `.includes(` ${i} `)}function t(s,i){s.classList?s.classList.add(i):a(s,i)||(s.className=`${s.className} ${i}`)}function c(s,i){if(s.classList)s.classList.remove(i);else if(a(s,i)){const l=s.className;s.className=` ${l} `.replace(` ${i} `," ")}}exports.addClass=t;exports.hasClass=a;exports.removeClass=c;
1
+ function hasClass(node, className) {
2
+ if (node.classList) return node.classList.contains(className);
3
+ return ` ${node.className} `.includes(` ${className} `);
4
+ }
5
+ function addClass(node, className) {
6
+ if (node.classList) node.classList.add(className);
7
+ else if (!hasClass(node, className)) node.className = `${node.className} ${className}`;
8
+ }
9
+ function removeClass(node, className) {
10
+ if (node.classList) node.classList.remove(className);
11
+ else if (hasClass(node, className)) node.className = ` ${node.className} `.replace(` ${className} `, " ");
12
+ }
13
+ exports.addClass = addClass;
14
+ exports.hasClass = hasClass;
15
+ exports.removeClass = removeClass;
package/dist/Dom/class.js CHANGED
@@ -1,19 +1,13 @@
1
- function l(s, i) {
2
- return s.classList ? s.classList.contains(i) : ` ${s.className} `.includes(` ${i} `);
1
+ function hasClass(node, className) {
2
+ if (node.classList) return node.classList.contains(className);
3
+ return ` ${node.className} `.includes(` ${className} `);
3
4
  }
4
- function t(s, i) {
5
- s.classList ? s.classList.add(i) : l(s, i) || (s.className = `${s.className} ${i}`);
5
+ function addClass(node, className) {
6
+ if (node.classList) node.classList.add(className);
7
+ else if (!hasClass(node, className)) node.className = `${node.className} ${className}`;
6
8
  }
7
- function c(s, i) {
8
- if (s.classList)
9
- s.classList.remove(i);
10
- else if (l(s, i)) {
11
- const a = s.className;
12
- s.className = ` ${a} `.replace(` ${i} `, " ");
13
- }
9
+ function removeClass(node, className) {
10
+ if (node.classList) node.classList.remove(className);
11
+ else if (hasClass(node, className)) node.className = ` ${node.className} `.replace(` ${className} `, " ");
14
12
  }
15
- export {
16
- t as addClass,
17
- l as hasClass,
18
- c as removeClass
19
- };
13
+ export { addClass, hasClass, removeClass };
@@ -1 +1,12 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function u(e,n){if(!e)return!1;if(e.contains)return e.contains(n);let t=n;for(;t;){if(t===e)return!0;t=t.parentNode}return!1}exports.default=u;
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ function contains(root, n) {
3
+ if (!root) return false;
4
+ if (root.contains) return root.contains(n);
5
+ let node = n;
6
+ while (node) {
7
+ if (node === root) return true;
8
+ node = node.parentNode;
9
+ }
10
+ return false;
11
+ }
12
+ exports.default = contains;
@@ -1,16 +1,11 @@
1
- function a(e, t) {
2
- if (!e)
3
- return !1;
4
- if (e.contains)
5
- return e.contains(t);
6
- let n = t;
7
- for (; n; ) {
8
- if (n === e)
9
- return !0;
10
- n = n.parentNode;
11
- }
12
- return !1;
1
+ function contains(root, n) {
2
+ if (!root) return false;
3
+ if (root.contains) return root.contains(n);
4
+ let node = n;
5
+ while (node) {
6
+ if (node === root) return true;
7
+ node = node.parentNode;
8
+ }
9
+ return false;
13
10
  }
14
- export {
15
- a as default
16
- };
11
+ export { contains as default };
package/dist/Dom/css.cjs CHANGED
@@ -1 +1,81 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=/margin|padding|width|height|max|min|offset/,i={left:!0,top:!0},r={cssFloat:1,styleFloat:1,float:1};function u(e){return e.nodeType===1?e.ownerDocument.defaultView.getComputedStyle(e,null):{}}function f(e,t,o){if(t=t.toLowerCase(),o==="auto"){if(t==="height")return e.offsetHeight;if(t==="width")return e.offsetWidth}return t in i||(i[t]=l.test(t)),i[t]?Number.parseFloat(o)||0:o}function d(e,t){const o=arguments.length,n=u(e);return t=r[t]?"cssFloat"in e.style?"cssFloat":"styleFloat":t,o===1?n:f(e,t,n[t]||e.style[t])}function s(e,t,o){const n=arguments.length;if(t=r[t]?"cssFloat"in e.style?"cssFloat":"styleFloat":t,n===3)return typeof o=="number"&&l.test(t)&&(o=`${o}px`),e.style[t]=o,o;for(const c in t)c in t&&s(e,c,t[c]);return u(e)}function g(e){return e===document.body?document.documentElement.clientWidth:e.offsetWidth}function m(e){return e===document.body?window.innerHeight||document.documentElement.clientHeight:e.offsetHeight}function h(){const e=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),t=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);return{width:e,height:t}}function a(){const e=document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{width:e,height:t}}function y(){return{scrollLeft:Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),scrollTop:Math.max(document.documentElement.scrollTop,document.body.scrollTop)}}function w(e){const t=e.getBoundingClientRect(),o=document.documentElement;return{left:t.left+(window.pageXOffset||o.scrollLeft)-(o.clientLeft||document.body.clientLeft||0),top:t.top+(window.pageYOffset||o.scrollTop)-(o.clientTop||document.body.clientTop||0)}}exports.get=d;exports.getClientSize=a;exports.getDocSize=h;exports.getOffset=w;exports.getOuterHeight=m;exports.getOuterWidth=g;exports.getScroll=y;exports.set=s;
1
+ var PIXEL_PATTERN = /margin|padding|width|height|max|min|offset/;
2
+ var removePixel = {
3
+ left: true,
4
+ top: true
5
+ };
6
+ var floatMap = {
7
+ cssFloat: 1,
8
+ styleFloat: 1,
9
+ float: 1
10
+ };
11
+ function getComputedStyle(node) {
12
+ return node.nodeType === 1 ? node.ownerDocument.defaultView.getComputedStyle(node, null) : {};
13
+ }
14
+ function getStyleValue(node, type, value) {
15
+ type = type.toLowerCase();
16
+ if (value === "auto") {
17
+ if (type === "height") return node.offsetHeight;
18
+ if (type === "width") return node.offsetWidth;
19
+ }
20
+ if (!(type in removePixel)) removePixel[type] = PIXEL_PATTERN.test(type);
21
+ return removePixel[type] ? Number.parseFloat(value) || 0 : value;
22
+ }
23
+ function get(node, name) {
24
+ const length = arguments.length;
25
+ const style = getComputedStyle(node);
26
+ name = floatMap[name] ? "cssFloat" in node.style ? "cssFloat" : "styleFloat" : name;
27
+ return length === 1 ? style : getStyleValue(node, name, style[name] || node.style[name]);
28
+ }
29
+ function set(node, name, value) {
30
+ const length = arguments.length;
31
+ name = floatMap[name] ? "cssFloat" in node.style ? "cssFloat" : "styleFloat" : name;
32
+ if (length === 3) {
33
+ if (typeof value === "number" && PIXEL_PATTERN.test(name)) value = `${value}px`;
34
+ node.style[name] = value;
35
+ return value;
36
+ }
37
+ for (const x in name) if (x in name) set(node, x, name[x]);
38
+ return getComputedStyle(node);
39
+ }
40
+ function getOuterWidth(el) {
41
+ if (el === document.body) return document.documentElement.clientWidth;
42
+ return el.offsetWidth;
43
+ }
44
+ function getOuterHeight(el) {
45
+ if (el === document.body) return window.innerHeight || document.documentElement.clientHeight;
46
+ return el.offsetHeight;
47
+ }
48
+ function getDocSize() {
49
+ return {
50
+ width: Math.max(document.documentElement.scrollWidth, document.body.scrollWidth),
51
+ height: Math.max(document.documentElement.scrollHeight, document.body.scrollHeight)
52
+ };
53
+ }
54
+ function getClientSize() {
55
+ return {
56
+ width: document.documentElement.clientWidth,
57
+ height: window.innerHeight || document.documentElement.clientHeight
58
+ };
59
+ }
60
+ function getScroll() {
61
+ return {
62
+ scrollLeft: Math.max(document.documentElement.scrollLeft, document.body.scrollLeft),
63
+ scrollTop: Math.max(document.documentElement.scrollTop, document.body.scrollTop)
64
+ };
65
+ }
66
+ function getOffset(node) {
67
+ const box = node.getBoundingClientRect();
68
+ const docElem = document.documentElement;
69
+ return {
70
+ left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || document.body.clientLeft || 0),
71
+ top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || document.body.clientTop || 0)
72
+ };
73
+ }
74
+ exports.get = get;
75
+ exports.getClientSize = getClientSize;
76
+ exports.getDocSize = getDocSize;
77
+ exports.getOffset = getOffset;
78
+ exports.getOuterHeight = getOuterHeight;
79
+ exports.getOuterWidth = getOuterWidth;
80
+ exports.getScroll = getScroll;
81
+ exports.set = set;
package/dist/Dom/css.js CHANGED
@@ -1,75 +1,74 @@
1
- const l = /margin|padding|width|height|max|min|offset/, i = {
2
- left: !0,
3
- top: !0
4
- }, u = {
5
- cssFloat: 1,
6
- styleFloat: 1,
7
- float: 1
1
+ var PIXEL_PATTERN = /margin|padding|width|height|max|min|offset/;
2
+ var removePixel = {
3
+ left: true,
4
+ top: true
8
5
  };
9
- function r(e) {
10
- return e.nodeType === 1 ? e.ownerDocument.defaultView.getComputedStyle(e, null) : {};
6
+ var floatMap = {
7
+ cssFloat: 1,
8
+ styleFloat: 1,
9
+ float: 1
10
+ };
11
+ function getComputedStyle(node) {
12
+ return node.nodeType === 1 ? node.ownerDocument.defaultView.getComputedStyle(node, null) : {};
11
13
  }
12
- function s(e, t, o) {
13
- if (t = t.toLowerCase(), o === "auto") {
14
- if (t === "height")
15
- return e.offsetHeight;
16
- if (t === "width")
17
- return e.offsetWidth;
18
- }
19
- return t in i || (i[t] = l.test(t)), i[t] ? Number.parseFloat(o) || 0 : o;
14
+ function getStyleValue(node, type, value) {
15
+ type = type.toLowerCase();
16
+ if (value === "auto") {
17
+ if (type === "height") return node.offsetHeight;
18
+ if (type === "width") return node.offsetWidth;
19
+ }
20
+ if (!(type in removePixel)) removePixel[type] = PIXEL_PATTERN.test(type);
21
+ return removePixel[type] ? Number.parseFloat(value) || 0 : value;
20
22
  }
21
- function d(e, t) {
22
- const o = arguments.length, n = r(e);
23
- return t = u[t] ? "cssFloat" in e.style ? "cssFloat" : "styleFloat" : t, o === 1 ? n : s(e, t, n[t] || e.style[t]);
23
+ function get(node, name) {
24
+ const length = arguments.length;
25
+ const style = getComputedStyle(node);
26
+ name = floatMap[name] ? "cssFloat" in node.style ? "cssFloat" : "styleFloat" : name;
27
+ return length === 1 ? style : getStyleValue(node, name, style[name] || node.style[name]);
24
28
  }
25
- function f(e, t, o) {
26
- const n = arguments.length;
27
- if (t = u[t] ? "cssFloat" in e.style ? "cssFloat" : "styleFloat" : t, n === 3)
28
- return typeof o == "number" && l.test(t) && (o = `${o}px`), e.style[t] = o, o;
29
- for (const c in t)
30
- c in t && f(e, c, t[c]);
31
- return r(e);
29
+ function set(node, name, value) {
30
+ const length = arguments.length;
31
+ name = floatMap[name] ? "cssFloat" in node.style ? "cssFloat" : "styleFloat" : name;
32
+ if (length === 3) {
33
+ if (typeof value === "number" && PIXEL_PATTERN.test(name)) value = `${value}px`;
34
+ node.style[name] = value;
35
+ return value;
36
+ }
37
+ for (const x in name) if (x in name) set(node, x, name[x]);
38
+ return getComputedStyle(node);
32
39
  }
33
- function m(e) {
34
- return e === document.body ? document.documentElement.clientWidth : e.offsetWidth;
40
+ function getOuterWidth(el) {
41
+ if (el === document.body) return document.documentElement.clientWidth;
42
+ return el.offsetWidth;
35
43
  }
36
- function h(e) {
37
- return e === document.body ? window.innerHeight || document.documentElement.clientHeight : e.offsetHeight;
44
+ function getOuterHeight(el) {
45
+ if (el === document.body) return window.innerHeight || document.documentElement.clientHeight;
46
+ return el.offsetHeight;
38
47
  }
39
- function g() {
40
- const e = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), t = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
41
- return {
42
- width: e,
43
- height: t
44
- };
48
+ function getDocSize() {
49
+ return {
50
+ width: Math.max(document.documentElement.scrollWidth, document.body.scrollWidth),
51
+ height: Math.max(document.documentElement.scrollHeight, document.body.scrollHeight)
52
+ };
45
53
  }
46
- function w() {
47
- const e = document.documentElement.clientWidth, t = window.innerHeight || document.documentElement.clientHeight;
48
- return {
49
- width: e,
50
- height: t
51
- };
54
+ function getClientSize() {
55
+ return {
56
+ width: document.documentElement.clientWidth,
57
+ height: window.innerHeight || document.documentElement.clientHeight
58
+ };
52
59
  }
53
- function a() {
54
- return {
55
- scrollLeft: Math.max(document.documentElement.scrollLeft, document.body.scrollLeft),
56
- scrollTop: Math.max(document.documentElement.scrollTop, document.body.scrollTop)
57
- };
60
+ function getScroll() {
61
+ return {
62
+ scrollLeft: Math.max(document.documentElement.scrollLeft, document.body.scrollLeft),
63
+ scrollTop: Math.max(document.documentElement.scrollTop, document.body.scrollTop)
64
+ };
58
65
  }
59
- function y(e) {
60
- const t = e.getBoundingClientRect(), o = document.documentElement;
61
- return {
62
- left: t.left + (window.pageXOffset || o.scrollLeft) - (o.clientLeft || document.body.clientLeft || 0),
63
- top: t.top + (window.pageYOffset || o.scrollTop) - (o.clientTop || document.body.clientTop || 0)
64
- };
66
+ function getOffset(node) {
67
+ const box = node.getBoundingClientRect();
68
+ const docElem = document.documentElement;
69
+ return {
70
+ left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || document.body.clientLeft || 0),
71
+ top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || document.body.clientTop || 0)
72
+ };
65
73
  }
66
- export {
67
- d as get,
68
- w as getClientSize,
69
- g as getDocSize,
70
- y as getOffset,
71
- h as getOuterHeight,
72
- m as getOuterWidth,
73
- a as getScroll,
74
- f as set
75
- };
74
+ export { get, getClientSize, getDocSize, getOffset, getOuterHeight, getOuterWidth, getScroll, set };
@@ -1 +1,83 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./canUseDom.cjs"),N=require("./contains.cjs"),h="data-vc-order",C="data-vc-priority",v="vc-util-key",a=new Map;function p({mark:e}={}){return e?e.startsWith("data-")?e:`data-${e}`:v}function s(e){return e.attachTo?e.attachTo:document.querySelector("head")||document.body}function P(e){return e==="queue"?"prependQueue":e?"prepend":"append"}function g(e){return Array.from((a.get(e)||e).children).filter(n=>n.tagName==="STYLE")}function f(e,n={}){if(!A.default())return null;const{csp:t,prepend:c,priority:r=0}=n,o=P(c),l=o==="prependQueue",i=document.createElement("style");i.setAttribute(h,o),l&&r&&i.setAttribute(C,`${r}`),t?.nonce&&(i.nonce=t?.nonce),i.innerHTML=e;const u=s(n),{firstChild:m}=u;if(c){if(l){const d=g(u).filter(S=>{if(!["prepend","prependQueue"].includes(S.getAttribute(h)))return!1;const b=Number(S.getAttribute(C)||0);return r>=b});if(d.length)return u.insertBefore(i,d[d.length-1].nextSibling),i}u.insertBefore(i,m)}else u.appendChild(i);return i}function y(e,n={}){const t=s(n);return g(t).find(c=>c.getAttribute(p(n))===e)}function T(e,n={}){const t=y(e,n);t&&s(n).removeChild(t)}function E(e,n){const t=a.get(e);if(!t||!N.default(document,t)){const c=f("",n),{parentNode:r}=c;a.set(e,r),e.removeChild(c)}}function M(){a.clear()}function R(e,n,t={}){const c=s(t);E(c,t);const r=y(n,t);if(r)return t.csp?.nonce&&r.nonce!==t.csp?.nonce&&(r.nonce=t.csp?.nonce),r.innerHTML!==e&&(r.innerHTML=e),r;const o=f(e,t);return o.setAttribute(p(t),n),o}exports.clearContainerCache=M;exports.injectCSS=f;exports.removeCSS=T;exports.updateCSS=R;
1
+ const require_canUseDom = require("./canUseDom.cjs");
2
+ const require_contains = require("./contains.cjs");
3
+ var APPEND_ORDER = "data-vc-order";
4
+ var APPEND_PRIORITY = "data-vc-priority";
5
+ var MARK_KEY = `vc-util-key`;
6
+ var containerCache = /* @__PURE__ */ new Map();
7
+ function getMark({ mark } = {}) {
8
+ if (mark) return mark.startsWith("data-") ? mark : `data-${mark}`;
9
+ return MARK_KEY;
10
+ }
11
+ function getContainer(option) {
12
+ if (option.attachTo) return option.attachTo;
13
+ return document.querySelector("head") || document.body;
14
+ }
15
+ function getOrder(prepend) {
16
+ if (prepend === "queue") return "prependQueue";
17
+ return prepend ? "prepend" : "append";
18
+ }
19
+ function findStyles(container) {
20
+ return Array.from((containerCache.get(container) || container).children).filter((node) => node.tagName === "STYLE");
21
+ }
22
+ function injectCSS(css, option = {}) {
23
+ if (!require_canUseDom.default()) return null;
24
+ const { csp, prepend, priority = 0 } = option;
25
+ const mergedOrder = getOrder(prepend);
26
+ const isPrependQueue = mergedOrder === "prependQueue";
27
+ const styleNode = document.createElement("style");
28
+ styleNode.setAttribute(APPEND_ORDER, mergedOrder);
29
+ if (isPrependQueue && priority) styleNode.setAttribute(APPEND_PRIORITY, `${priority}`);
30
+ if (csp?.nonce) styleNode.nonce = csp?.nonce;
31
+ styleNode.innerHTML = css;
32
+ const container = getContainer(option);
33
+ const { firstChild } = container;
34
+ if (prepend) {
35
+ if (isPrependQueue) {
36
+ const existStyle = findStyles(container).filter((node) => {
37
+ if (!["prepend", "prependQueue"].includes(node.getAttribute(APPEND_ORDER))) return false;
38
+ return priority >= Number(node.getAttribute(APPEND_PRIORITY) || 0);
39
+ });
40
+ if (existStyle.length) {
41
+ container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
42
+ return styleNode;
43
+ }
44
+ }
45
+ container.insertBefore(styleNode, firstChild);
46
+ } else container.appendChild(styleNode);
47
+ return styleNode;
48
+ }
49
+ function findExistNode(key, option = {}) {
50
+ return findStyles(getContainer(option)).find((node) => node.getAttribute(getMark(option)) === key);
51
+ }
52
+ function removeCSS(key, option = {}) {
53
+ const existNode = findExistNode(key, option);
54
+ if (existNode) getContainer(option).removeChild(existNode);
55
+ }
56
+ function syncRealContainer(container, option) {
57
+ const cachedRealContainer = containerCache.get(container);
58
+ if (!cachedRealContainer || !require_contains.default(document, cachedRealContainer)) {
59
+ const placeholderStyle = injectCSS("", option);
60
+ const { parentNode } = placeholderStyle;
61
+ containerCache.set(container, parentNode);
62
+ container.removeChild(placeholderStyle);
63
+ }
64
+ }
65
+ function clearContainerCache() {
66
+ containerCache.clear();
67
+ }
68
+ function updateCSS(css, key, option = {}) {
69
+ syncRealContainer(getContainer(option), option);
70
+ const existNode = findExistNode(key, option);
71
+ if (existNode) {
72
+ if (option.csp?.nonce && existNode.nonce !== option.csp?.nonce) existNode.nonce = option.csp?.nonce;
73
+ if (existNode.innerHTML !== css) existNode.innerHTML = css;
74
+ return existNode;
75
+ }
76
+ const newNode = injectCSS(css, option);
77
+ newNode.setAttribute(getMark(option), key);
78
+ return newNode;
79
+ }
80
+ exports.clearContainerCache = clearContainerCache;
81
+ exports.injectCSS = injectCSS;
82
+ exports.removeCSS = removeCSS;
83
+ exports.updateCSS = updateCSS;