@v-c/util 0.0.13 → 0.0.15

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