@v-c/util 0.0.12 → 0.0.13

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 (108) hide show
  1. package/dist/Children/isFragment.cjs +7 -1
  2. package/dist/Children/isFragment.js +4 -4
  3. package/dist/Children/toArray.cjs +20 -1
  4. package/dist/Children/toArray.js +17 -8
  5. package/dist/Dom/addEventListener.cjs +13 -1
  6. package/dist/Dom/addEventListener.js +7 -5
  7. package/dist/Dom/canUseDom.cjs +6 -1
  8. package/dist/Dom/canUseDom.js +3 -3
  9. package/dist/Dom/class.cjs +29 -1
  10. package/dist/Dom/class.js +23 -13
  11. package/dist/Dom/contains.cjs +16 -1
  12. package/dist/Dom/contains.js +12 -12
  13. package/dist/Dom/css.cjs +96 -1
  14. package/dist/Dom/css.js +69 -48
  15. package/dist/Dom/dynamicCSS.cjs +110 -1
  16. package/dist/Dom/dynamicCSS.js +92 -59
  17. package/dist/Dom/findDOMNode.cjs +16 -1
  18. package/dist/Dom/findDOMNode.js +12 -8
  19. package/dist/Dom/focus.cjs +60 -1
  20. package/dist/Dom/focus.js +48 -28
  21. package/dist/Dom/isVisible.cjs +22 -1
  22. package/dist/Dom/isVisible.js +16 -16
  23. package/dist/Dom/scrollLocker.cjs +89 -1
  24. package/dist/Dom/scrollLocker.js +70 -45
  25. package/dist/Dom/shadow.cjs +13 -1
  26. package/dist/Dom/shadow.js +8 -8
  27. package/dist/Dom/styleChecker.cjs +25 -1
  28. package/dist/Dom/styleChecker.js +19 -14
  29. package/dist/Dom/support.cjs +28 -1
  30. package/dist/Dom/support.js +16 -12
  31. package/dist/KeyCode.cjs +523 -1
  32. package/dist/KeyCode.js +62 -55
  33. package/dist/Portal.cjs +48 -1
  34. package/dist/Portal.js +34 -19
  35. package/dist/PortalWrapper.cjs +169 -1
  36. package/dist/PortalWrapper.js +133 -79
  37. package/dist/classnames.cjs +45 -1
  38. package/dist/classnames.js +38 -25
  39. package/dist/composeProps.cjs +19 -1
  40. package/dist/composeProps.js +15 -9
  41. package/dist/createRef.cjs +24 -1
  42. package/dist/createRef.js +16 -13
  43. package/dist/debug/diff.cjs +50 -1
  44. package/dist/debug/diff.js +39 -30
  45. package/dist/deprecated.cjs +10 -1
  46. package/dist/deprecated.js +7 -5
  47. package/dist/getScrollBarSize.cjs +51 -1
  48. package/dist/getScrollBarSize.js +39 -25
  49. package/dist/guid.cjs +7 -1
  50. package/dist/guid.js +4 -4
  51. package/dist/hooks/useEvent.cjs +6 -1
  52. package/dist/hooks/useEvent.js +3 -3
  53. package/dist/hooks/useId.cjs +18 -1
  54. package/dist/hooks/useId.js +14 -8
  55. package/dist/hooks/useLayoutEffect.cjs +58 -1
  56. package/dist/hooks/useLayoutEffect.js +50 -20
  57. package/dist/hooks/useMemo.cjs +16 -1
  58. package/dist/hooks/useMemo.js +13 -7
  59. package/dist/hooks/useMergedState.cjs +30 -1
  60. package/dist/hooks/useMergedState.js +25 -16
  61. package/dist/hooks/useMobile.cjs +16 -1
  62. package/dist/hooks/useMobile.js +13 -11
  63. package/dist/hooks/useState.cjs +12 -1
  64. package/dist/hooks/useState.js +8 -7
  65. package/dist/index.cjs +11 -1
  66. package/dist/index.js +9 -9
  67. package/dist/isEqual.cjs +36 -1
  68. package/dist/isEqual.js +30 -26
  69. package/dist/isMobile.cjs +13 -1
  70. package/dist/isMobile.js +7 -7
  71. package/dist/isValid.cjs +6 -1
  72. package/dist/isValid.js +3 -3
  73. package/dist/omit.cjs +12 -1
  74. package/dist/omit.js +9 -6
  75. package/dist/pickAttrs.cjs +41 -3
  76. package/dist/pickAttrs.js +37 -22
  77. package/dist/props-util/index.cjs +69 -1
  78. package/dist/props-util/index.js +62 -32
  79. package/dist/raf.cjs +48 -1
  80. package/dist/raf.js +37 -26
  81. package/dist/setStyle.cjs +17 -1
  82. package/dist/setStyle.js +13 -9
  83. package/dist/switchScrollingEffect.cjs +38 -1
  84. package/dist/switchScrollingEffect.js +27 -20
  85. package/dist/test/domHook.cjs +52 -1
  86. package/dist/test/domHook.js +43 -28
  87. package/dist/type.cjs +51 -1
  88. package/dist/type.js +39 -37
  89. package/dist/utils/checkSlotProp.cjs +13 -1
  90. package/dist/utils/checkSlotProp.js +10 -3
  91. package/dist/utils/get.cjs +12 -1
  92. package/dist/utils/get.js +8 -8
  93. package/dist/utils/omit.cjs +10 -1
  94. package/dist/utils/omit.js +7 -6
  95. package/dist/utils/set.cjs +64 -1
  96. package/dist/utils/set.js +54 -32
  97. package/dist/utils/transition.cjs +96 -1
  98. package/dist/utils/transition.d.ts +2 -2
  99. package/dist/utils/transition.js +70 -65
  100. package/dist/utils/watchState.cjs +20 -1
  101. package/dist/utils/watchState.js +15 -10
  102. package/dist/vnode.cjs +56 -1
  103. package/dist/vnode.js +46 -30
  104. package/dist/vueuse/unref-element.cjs +8 -1
  105. package/dist/vueuse/unref-element.js +5 -5
  106. package/dist/warning.cjs +53 -1
  107. package/dist/warning.js +40 -35
  108. package/package.json +1 -1
@@ -1 +1,45 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function f(t){let e="";if(typeof t=="string"||typeof t=="number")e+=t;else if(typeof t=="object")if(Array.isArray(t)){for(let o=0;o<t.length;o++)if(t[o]){const r=f(t[o]);r&&(e&&(e+=" "),e+=r)}}else for(const o in t)t[o]&&(e&&(e+=" "),e+=o);return e}function l(...t){let e="";for(let o=0;o<t.length;o++){const r=t[o];if(r){const s=f(r);s&&(e&&(e+=" "),e+=s)}}return e}const n=l;exports.clsx=n;exports.default=l;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ function toVal(mix) {
4
+ let str = "";
5
+ if (typeof mix === "string" || typeof mix === "number") {
6
+ str += mix;
7
+ } else if (typeof mix === "object") {
8
+ if (Array.isArray(mix)) {
9
+ for (let k = 0; k < mix.length; k++) {
10
+ if (mix[k]) {
11
+ const y = toVal(mix[k]);
12
+ if (y) {
13
+ str && (str += " ");
14
+ str += y;
15
+ }
16
+ }
17
+ }
18
+ } else {
19
+ for (const k in mix) {
20
+ if (mix[k]) {
21
+ str && (str += " ");
22
+ str += k;
23
+ }
24
+ }
25
+ }
26
+ }
27
+ return str;
28
+ }
29
+ function classNames(...args) {
30
+ let str = "";
31
+ for (let i = 0; i < args.length; i++) {
32
+ const tmp = args[i];
33
+ if (tmp) {
34
+ const x = toVal(tmp);
35
+ if (x) {
36
+ str && (str += " ");
37
+ str += x;
38
+ }
39
+ }
40
+ }
41
+ return str;
42
+ }
43
+ const clsx = classNames;
44
+ exports.clsx = clsx;
45
+ exports.default = classNames;
@@ -1,32 +1,45 @@
1
- function r(t) {
2
- let e = "";
3
- if (typeof t == "string" || typeof t == "number")
4
- e += t;
5
- else if (typeof t == "object")
6
- if (Array.isArray(t)) {
7
- for (let f = 0; f < t.length; f++)
8
- if (t[f]) {
9
- const n = r(t[f]);
10
- n && (e && (e += " "), e += n);
1
+ function toVal(mix) {
2
+ let str = "";
3
+ if (typeof mix === "string" || typeof mix === "number") {
4
+ str += mix;
5
+ } else if (typeof mix === "object") {
6
+ if (Array.isArray(mix)) {
7
+ for (let k = 0; k < mix.length; k++) {
8
+ if (mix[k]) {
9
+ const y = toVal(mix[k]);
10
+ if (y) {
11
+ str && (str += " ");
12
+ str += y;
13
+ }
11
14
  }
12
- } else
13
- for (const f in t)
14
- t[f] && (e && (e += " "), e += f);
15
- return e;
15
+ }
16
+ } else {
17
+ for (const k in mix) {
18
+ if (mix[k]) {
19
+ str && (str += " ");
20
+ str += k;
21
+ }
22
+ }
23
+ }
24
+ }
25
+ return str;
16
26
  }
17
- function s(...t) {
18
- let e = "";
19
- for (let f = 0; f < t.length; f++) {
20
- const n = t[f];
21
- if (n) {
22
- const o = r(n);
23
- o && (e && (e += " "), e += o);
27
+ function classNames(...args) {
28
+ let str = "";
29
+ for (let i = 0; i < args.length; i++) {
30
+ const tmp = args[i];
31
+ if (tmp) {
32
+ const x = toVal(tmp);
33
+ if (x) {
34
+ str && (str += " ");
35
+ str += x;
36
+ }
24
37
  }
25
38
  }
26
- return e;
39
+ return str;
27
40
  }
28
- const l = s;
41
+ const clsx = classNames;
29
42
  export {
30
- l as clsx,
31
- s as default
43
+ clsx,
44
+ classNames as default
32
45
  };
@@ -1 +1,19 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function r(o,e,f){const u={...o,...f?e:{}};return Object.keys(e).forEach(t=>{const n=e[t];typeof n=="function"&&(u[t]=(...c)=>(n(...c),o[t]?.(...c)))}),u}exports.default=r;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ function composeProps(originProps, patchProps, isAll) {
4
+ const composedProps = {
5
+ ...originProps,
6
+ ...isAll ? patchProps : {}
7
+ };
8
+ Object.keys(patchProps).forEach((key) => {
9
+ const func = patchProps[key];
10
+ if (typeof func === "function") {
11
+ composedProps[key] = (...args) => {
12
+ func(...args);
13
+ return originProps[key]?.(...args);
14
+ };
15
+ }
16
+ });
17
+ return composedProps;
18
+ }
19
+ exports.default = composeProps;
@@ -1,13 +1,19 @@
1
- function s(t, o, u) {
2
- const c = {
3
- ...t,
4
- ...u ? o : {}
1
+ function composeProps(originProps, patchProps, isAll) {
2
+ const composedProps = {
3
+ ...originProps,
4
+ ...isAll ? patchProps : {}
5
5
  };
6
- return Object.keys(o).forEach((n) => {
7
- const e = o[n];
8
- typeof e == "function" && (c[n] = (...f) => (e(...f), t[n]?.(...f)));
9
- }), c;
6
+ Object.keys(patchProps).forEach((key) => {
7
+ const func = patchProps[key];
8
+ if (typeof func === "function") {
9
+ composedProps[key] = (...args) => {
10
+ func(...args);
11
+ return originProps[key]?.(...args);
12
+ };
13
+ }
14
+ });
15
+ return composedProps;
10
16
  }
11
17
  export {
12
- s as default
18
+ composeProps as default
13
19
  };
@@ -1 +1,24 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function u(){const e=t=>{e.current=t};return e}function n(e,t){typeof e=="function"?e(t):typeof e=="object"&&e&&"current"in e&&(e.current=t)}function c(...e){return t=>{e.forEach(o=>{n(o,t)})}}exports.composeRef=c;exports.default=u;exports.fillRef=n;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ function createRef() {
4
+ const func = (node) => {
5
+ func.current = node;
6
+ };
7
+ return func;
8
+ }
9
+ function fillRef(ref, node) {
10
+ if (typeof ref === "function")
11
+ ref(node);
12
+ else if (typeof ref === "object" && ref && "current" in ref)
13
+ ref.current = node;
14
+ }
15
+ function composeRef(...refs) {
16
+ return (node) => {
17
+ refs.forEach((ref) => {
18
+ fillRef(ref, node);
19
+ });
20
+ };
21
+ }
22
+ exports.composeRef = composeRef;
23
+ exports.default = createRef;
24
+ exports.fillRef = fillRef;
package/dist/createRef.js CHANGED
@@ -1,21 +1,24 @@
1
- function o() {
2
- const t = (n) => {
3
- t.current = n;
1
+ function createRef() {
2
+ const func = (node) => {
3
+ func.current = node;
4
4
  };
5
- return t;
5
+ return func;
6
6
  }
7
- function e(t, n) {
8
- typeof t == "function" ? t(n) : typeof t == "object" && t && "current" in t && (t.current = n);
7
+ function fillRef(ref, node) {
8
+ if (typeof ref === "function")
9
+ ref(node);
10
+ else if (typeof ref === "object" && ref && "current" in ref)
11
+ ref.current = node;
9
12
  }
10
- function u(...t) {
11
- return (n) => {
12
- t.forEach((c) => {
13
- e(c, n);
13
+ function composeRef(...refs) {
14
+ return (node) => {
15
+ refs.forEach((ref) => {
16
+ fillRef(ref, node);
14
17
  });
15
18
  };
16
19
  }
17
20
  export {
18
- u as composeRef,
19
- o as default,
20
- e as fillRef
21
+ composeRef,
22
+ createRef as default,
23
+ fillRef
21
24
  };
@@ -1 +1,50 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function l(){const t=[];return t.__proto__=[],t.__proto__.format=function(){return this.map(n=>({...n,path:n.path.join(" > ")}))},t.__proto__.toString=function(){return JSON.stringify(this.format(),null,2)},t}function i(t,c,n=10,a=[],o=l()){return n<=0||new Set([...Object.keys(t),...Object.keys(c)]).forEach(u=>{const r=t[u],e=c[u];if(r===e)return;const s=typeof r;if(s!==typeof e){o.push({path:a.concat(u),value1:r,value2:e});return}if(!(Number.isNaN(r)&&Number.isNaN(e))){if(s==="object"&&r!==null&&e!==null){i(r,e,n-1,a.concat(u),o);return}o.push({path:a.concat(u),value1:r,value2:e})}}),o}exports.default=i;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ function createArray() {
4
+ const arr = [];
5
+ arr.__proto__ = [];
6
+ arr.__proto__.format = function toString() {
7
+ return this.map((obj) => ({
8
+ ...obj,
9
+ path: obj.path.join(" > ")
10
+ }));
11
+ };
12
+ arr.__proto__.toString = function toString() {
13
+ return JSON.stringify(this.format(), null, 2);
14
+ };
15
+ return arr;
16
+ }
17
+ function diff(obj1, obj2, depth = 10, path = [], diffList = createArray()) {
18
+ if (depth <= 0)
19
+ return diffList;
20
+ const keys = /* @__PURE__ */ new Set([...Object.keys(obj1), ...Object.keys(obj2)]);
21
+ keys.forEach((key) => {
22
+ const value1 = obj1[key];
23
+ const value2 = obj2[key];
24
+ if (value1 === value2)
25
+ return;
26
+ const type1 = typeof value1;
27
+ const type2 = typeof value2;
28
+ if (type1 !== type2) {
29
+ diffList.push({
30
+ path: path.concat(key),
31
+ value1,
32
+ value2
33
+ });
34
+ return;
35
+ }
36
+ if (Number.isNaN(value1) && Number.isNaN(value2))
37
+ return;
38
+ if (type1 === "object" && value1 !== null && value2 !== null) {
39
+ diff(value1, value2, depth - 1, path.concat(key), diffList);
40
+ return;
41
+ }
42
+ diffList.push({
43
+ path: path.concat(key),
44
+ value1,
45
+ value2
46
+ });
47
+ });
48
+ return diffList;
49
+ }
50
+ exports.default = diff;
@@ -1,41 +1,50 @@
1
- function p() {
2
- const t = [];
3
- return t.__proto__ = [], t.__proto__.format = function() {
4
- return this.map((o) => ({
5
- ...o,
6
- path: o.path.join(" > ")
1
+ function createArray() {
2
+ const arr = [];
3
+ arr.__proto__ = [];
4
+ arr.__proto__.format = function toString() {
5
+ return this.map((obj) => ({
6
+ ...obj,
7
+ path: obj.path.join(" > ")
7
8
  }));
8
- }, t.__proto__.toString = function() {
9
+ };
10
+ arr.__proto__.toString = function toString() {
9
11
  return JSON.stringify(this.format(), null, 2);
10
- }, t;
12
+ };
13
+ return arr;
11
14
  }
12
- function i(t, c, o = 10, a = [], e = p()) {
13
- return o <= 0 || (/* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(c)])).forEach((u) => {
14
- const r = t[u], n = c[u];
15
- if (r === n)
15
+ function diff(obj1, obj2, depth = 10, path = [], diffList = createArray()) {
16
+ if (depth <= 0)
17
+ return diffList;
18
+ const keys = /* @__PURE__ */ new Set([...Object.keys(obj1), ...Object.keys(obj2)]);
19
+ keys.forEach((key) => {
20
+ const value1 = obj1[key];
21
+ const value2 = obj2[key];
22
+ if (value1 === value2)
16
23
  return;
17
- const s = typeof r;
18
- if (s !== typeof n) {
19
- e.push({
20
- path: a.concat(u),
21
- value1: r,
22
- value2: n
24
+ const type1 = typeof value1;
25
+ const type2 = typeof value2;
26
+ if (type1 !== type2) {
27
+ diffList.push({
28
+ path: path.concat(key),
29
+ value1,
30
+ value2
23
31
  });
24
32
  return;
25
33
  }
26
- if (!(Number.isNaN(r) && Number.isNaN(n))) {
27
- if (s === "object" && r !== null && n !== null) {
28
- i(r, n, o - 1, a.concat(u), e);
29
- return;
30
- }
31
- e.push({
32
- path: a.concat(u),
33
- value1: r,
34
- value2: n
35
- });
34
+ if (Number.isNaN(value1) && Number.isNaN(value2))
35
+ return;
36
+ if (type1 === "object" && value1 !== null && value2 !== null) {
37
+ diff(value1, value2, depth - 1, path.concat(key), diffList);
38
+ return;
36
39
  }
37
- }), e;
40
+ diffList.push({
41
+ path: path.concat(key),
42
+ value1,
43
+ value2
44
+ });
45
+ });
46
+ return diffList;
38
47
  }
39
48
  export {
40
- i as default
49
+ diff as default
41
50
  };
@@ -1 +1,10 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function d(e,o,n){typeof window<"u"&&window.console&&window.console.error&&window.console.error(`Warning: ${e} is deprecated at [ ${n} ], use [ ${o} ] instead of it.`)}exports.default=d;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ function deprecated(props, instead, component) {
4
+ if (typeof window !== "undefined" && window.console && window.console.error) {
5
+ window.console.error(
6
+ `Warning: ${props} is deprecated at [ ${component} ], use [ ${instead} ] instead of it.`
7
+ );
8
+ }
9
+ }
10
+ exports.default = deprecated;
@@ -1,8 +1,10 @@
1
- function d(e, o, n) {
2
- typeof window < "u" && window.console && window.console.error && window.console.error(
3
- `Warning: ${e} is deprecated at [ ${n} ], use [ ${o} ] instead of it.`
4
- );
1
+ function deprecated(props, instead, component) {
2
+ if (typeof window !== "undefined" && window.console && window.console.error) {
3
+ window.console.error(
4
+ `Warning: ${props} is deprecated at [ ${component} ], use [ ${instead} ] instead of it.`
5
+ );
6
+ }
5
7
  }
6
8
  export {
7
- d as default
9
+ deprecated as default
8
10
  };
@@ -1 +1,51 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let d;function c(n){if(typeof document>"u")return 0;if(n||d===void 0){const t=document.createElement("div");t.style.width="100%",t.style.height="200px";const e=document.createElement("div"),i=e.style;i.position="absolute",i.top="0",i.left="0",i.pointerEvents="none",i.visibility="hidden",i.width="200px",i.height="150px",i.overflow="hidden",e.appendChild(t),document.body.appendChild(e);const l=t.offsetWidth;e.style.overflow="scroll";let o=t.offsetWidth;l===o&&(o=e.clientWidth),document.body.removeChild(e),d=l-o}return d}function r(n){const t=n.match(/^(.*)px$/),e=Number(t?.[1]);return Number.isNaN(e)?c():e}function u(n){if(typeof document>"u"||!n||!(n instanceof Element))return{width:0,height:0};const{width:t,height:e}=getComputedStyle(n,"::-webkit-scrollbar");return{width:r(t),height:r(e)}}exports.default=c;exports.getTargetScrollBarSize=u;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ let cached;
4
+ function getScrollBarSize(fresh) {
5
+ if (typeof document === "undefined") return 0;
6
+ if (fresh || cached === void 0) {
7
+ const inner = document.createElement("div");
8
+ inner.style.width = "100%";
9
+ inner.style.height = "200px";
10
+ const outer = document.createElement("div");
11
+ const outerStyle = outer.style;
12
+ outerStyle.position = "absolute";
13
+ outerStyle.top = "0";
14
+ outerStyle.left = "0";
15
+ outerStyle.pointerEvents = "none";
16
+ outerStyle.visibility = "hidden";
17
+ outerStyle.width = "200px";
18
+ outerStyle.height = "150px";
19
+ outerStyle.overflow = "hidden";
20
+ outer.appendChild(inner);
21
+ document.body.appendChild(outer);
22
+ const widthContained = inner.offsetWidth;
23
+ outer.style.overflow = "scroll";
24
+ let widthScroll = inner.offsetWidth;
25
+ if (widthContained === widthScroll) widthScroll = outer.clientWidth;
26
+ document.body.removeChild(outer);
27
+ cached = widthContained - widthScroll;
28
+ }
29
+ return cached;
30
+ }
31
+ function ensureSize(str) {
32
+ const match = str.match(/^(.*)px$/);
33
+ const value = Number(match?.[1]);
34
+ return Number.isNaN(value) ? getScrollBarSize() : value;
35
+ }
36
+ function getTargetScrollBarSize(target) {
37
+ if (typeof document === "undefined" || !target || !(target instanceof Element)) return {
38
+ width: 0,
39
+ height: 0
40
+ };
41
+ const {
42
+ width,
43
+ height
44
+ } = getComputedStyle(target, "::-webkit-scrollbar");
45
+ return {
46
+ width: ensureSize(width),
47
+ height: ensureSize(height)
48
+ };
49
+ }
50
+ exports.default = getScrollBarSize;
51
+ exports.getTargetScrollBarSize = getTargetScrollBarSize;
@@ -1,37 +1,51 @@
1
- let d;
2
- function c(i) {
3
- if (typeof document > "u") return 0;
4
- if (i || d === void 0) {
5
- const t = document.createElement("div");
6
- t.style.width = "100%", t.style.height = "200px";
7
- const e = document.createElement("div"), n = e.style;
8
- n.position = "absolute", n.top = "0", n.left = "0", n.pointerEvents = "none", n.visibility = "hidden", n.width = "200px", n.height = "150px", n.overflow = "hidden", e.appendChild(t), document.body.appendChild(e);
9
- const l = t.offsetWidth;
10
- e.style.overflow = "scroll";
11
- let o = t.offsetWidth;
12
- l === o && (o = e.clientWidth), document.body.removeChild(e), d = l - o;
1
+ let cached;
2
+ function getScrollBarSize(fresh) {
3
+ if (typeof document === "undefined") return 0;
4
+ if (fresh || cached === void 0) {
5
+ const inner = document.createElement("div");
6
+ inner.style.width = "100%";
7
+ inner.style.height = "200px";
8
+ const outer = document.createElement("div");
9
+ const outerStyle = outer.style;
10
+ outerStyle.position = "absolute";
11
+ outerStyle.top = "0";
12
+ outerStyle.left = "0";
13
+ outerStyle.pointerEvents = "none";
14
+ outerStyle.visibility = "hidden";
15
+ outerStyle.width = "200px";
16
+ outerStyle.height = "150px";
17
+ outerStyle.overflow = "hidden";
18
+ outer.appendChild(inner);
19
+ document.body.appendChild(outer);
20
+ const widthContained = inner.offsetWidth;
21
+ outer.style.overflow = "scroll";
22
+ let widthScroll = inner.offsetWidth;
23
+ if (widthContained === widthScroll) widthScroll = outer.clientWidth;
24
+ document.body.removeChild(outer);
25
+ cached = widthContained - widthScroll;
13
26
  }
14
- return d;
27
+ return cached;
15
28
  }
16
- function r(i) {
17
- const t = i.match(/^(.*)px$/), e = Number(t?.[1]);
18
- return Number.isNaN(e) ? c() : e;
29
+ function ensureSize(str) {
30
+ const match = str.match(/^(.*)px$/);
31
+ const value = Number(match?.[1]);
32
+ return Number.isNaN(value) ? getScrollBarSize() : value;
19
33
  }
20
- function h(i) {
21
- if (typeof document > "u" || !i || !(i instanceof Element)) return {
34
+ function getTargetScrollBarSize(target) {
35
+ if (typeof document === "undefined" || !target || !(target instanceof Element)) return {
22
36
  width: 0,
23
37
  height: 0
24
38
  };
25
39
  const {
26
- width: t,
27
- height: e
28
- } = getComputedStyle(i, "::-webkit-scrollbar");
40
+ width,
41
+ height
42
+ } = getComputedStyle(target, "::-webkit-scrollbar");
29
43
  return {
30
- width: r(t),
31
- height: r(e)
44
+ width: ensureSize(width),
45
+ height: ensureSize(height)
32
46
  };
33
47
  }
34
48
  export {
35
- c as default,
36
- h as getTargetScrollBarSize
49
+ getScrollBarSize as default,
50
+ getTargetScrollBarSize
37
51
  };
package/dist/guid.cjs CHANGED
@@ -1 +1,7 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let e=0;function t(){return`${Date.now()}_${e++}`}exports.default=t;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ let seed = 0;
4
+ function guid() {
5
+ return `${Date.now()}_${seed++}`;
6
+ }
7
+ exports.default = guid;
package/dist/guid.js CHANGED
@@ -1,7 +1,7 @@
1
- let e = 0;
2
- function t() {
3
- return `${Date.now()}_${e++}`;
1
+ let seed = 0;
2
+ function guid() {
3
+ return `${Date.now()}_${seed++}`;
4
4
  }
5
5
  export {
6
- t as default
6
+ guid as default
7
7
  };
@@ -1 +1,6 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function t(e){return e}exports.default=t;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ function useEvent(callback) {
4
+ return callback;
5
+ }
6
+ exports.default = useEvent;
@@ -1,6 +1,6 @@
1
- function t(e) {
2
- return e;
1
+ function useEvent(callback) {
2
+ return callback;
3
3
  }
4
4
  export {
5
- t as default
5
+ useEvent as default
6
6
  };
@@ -1 +1,18 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("vue");function r(){return u.useId}const n=r();function s(e){const t=n();return e||(process.env.NODE_ENV==="test"?"test-id":t)}exports.default=s;
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const vue = require("vue");
4
+ function getUseId() {
5
+ return vue.useId;
6
+ }
7
+ const useOriginalId = getUseId();
8
+ function useId(id) {
9
+ const vueId = useOriginalId();
10
+ if (id) {
11
+ return id;
12
+ }
13
+ if (process.env.NODE_ENV === "test") {
14
+ return "test-id";
15
+ }
16
+ return vueId;
17
+ }
18
+ exports.default = useId;
@@ -1,12 +1,18 @@
1
- import { useId as r } from "vue";
2
- function s() {
3
- return r;
1
+ import { useId as useId$1 } from "vue";
2
+ function getUseId() {
3
+ return useId$1;
4
4
  }
5
- const n = s();
6
- function o(e) {
7
- const t = n();
8
- return e || (process.env.NODE_ENV === "test" ? "test-id" : t);
5
+ const useOriginalId = getUseId();
6
+ function useId(id) {
7
+ const vueId = useOriginalId();
8
+ if (id) {
9
+ return id;
10
+ }
11
+ if (process.env.NODE_ENV === "test") {
12
+ return "test-id";
13
+ }
14
+ return vueId;
9
15
  }
10
16
  export {
11
- o as default
17
+ useId as default
12
18
  };