@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,6 +1,5 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const attributes = `accept acceptCharset accessKey action allowFullScreen allowTransparency
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ var propList = `accept acceptCharset accessKey action allowFullScreen allowTransparency
4
3
  alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
5
4
  charSet checked classID className colSpan cols content contentEditable contextMenu
6
5
  controls coords crossOrigin data dateTime default defer dir disabled download draggable
@@ -11,46 +10,31 @@ const attributes = `accept acceptCharset accessKey action allowFullScreen allowT
11
10
  optimum pattern placeholder poster preload radioGroup readOnly rel required
12
11
  reversed role rowSpan rows sandbox scope scoped scrolling seamless selected
13
12
  shape size sizes span spellCheck src srcDoc srcLang srcSet start step style
14
- summary tabIndex target title type useMap value width wmode wrap`;
15
- const eventsName = `onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown
13
+ summary tabIndex target title type useMap value width wmode wrap onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown
16
14
  onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick
17
15
  onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown
18
16
  onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel
19
17
  onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough
20
18
  onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata
21
- onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`;
22
- const propList = `${attributes} ${eventsName}`.split(/\s+/);
23
- const ariaPrefix = "aria-";
24
- const dataPrefix = "data-";
19
+ onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`.split(/\s+/);
20
+ var ariaPrefix = "aria-";
21
+ var dataPrefix = "data-";
25
22
  function match(key, prefix) {
26
- return key.indexOf(prefix) === 0;
23
+ return key.indexOf(prefix) === 0;
27
24
  }
28
25
  function pickAttrs(props, ariaOnly = false) {
29
- let mergedConfig;
30
- if (ariaOnly === false) {
31
- mergedConfig = {
32
- aria: true,
33
- data: true,
34
- attr: true
35
- };
36
- } else if (ariaOnly === true) {
37
- mergedConfig = {
38
- aria: true
39
- };
40
- } else {
41
- mergedConfig = {
42
- ...ariaOnly
43
- };
44
- }
45
- const attrs = {};
46
- Object.keys(props).forEach((key) => {
47
- if (
48
- // Aria
49
- mergedConfig.aria && (key === "role" || match(key, ariaPrefix)) || mergedConfig.data && match(key, dataPrefix) || mergedConfig.attr && propList.includes(key)
50
- ) {
51
- attrs[key] = props[key];
52
- }
53
- });
54
- return attrs;
26
+ let mergedConfig;
27
+ if (ariaOnly === false) mergedConfig = {
28
+ aria: true,
29
+ data: true,
30
+ attr: true
31
+ };
32
+ else if (ariaOnly === true) mergedConfig = { aria: true };
33
+ else mergedConfig = { ...ariaOnly };
34
+ const attrs = {};
35
+ Object.keys(props).forEach((key) => {
36
+ if (mergedConfig.aria && (key === "role" || match(key, ariaPrefix)) || mergedConfig.data && match(key, dataPrefix) || mergedConfig.attr && propList.includes(key)) attrs[key] = props[key];
37
+ });
38
+ return attrs;
55
39
  }
56
40
  exports.default = pickAttrs;
package/dist/pickAttrs.js CHANGED
@@ -1,4 +1,4 @@
1
- const attributes = `accept acceptCharset accessKey action allowFullScreen allowTransparency
1
+ var propList = `accept acceptCharset accessKey action allowFullScreen allowTransparency
2
2
  alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
3
3
  charSet checked classID className colSpan cols content contentEditable contextMenu
4
4
  controls coords crossOrigin data dateTime default defer dir disabled download draggable
@@ -9,48 +9,31 @@ const attributes = `accept acceptCharset accessKey action allowFullScreen allowT
9
9
  optimum pattern placeholder poster preload radioGroup readOnly rel required
10
10
  reversed role rowSpan rows sandbox scope scoped scrolling seamless selected
11
11
  shape size sizes span spellCheck src srcDoc srcLang srcSet start step style
12
- summary tabIndex target title type useMap value width wmode wrap`;
13
- const eventsName = `onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown
12
+ summary tabIndex target title type useMap value width wmode wrap onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown
14
13
  onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick
15
14
  onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown
16
15
  onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel
17
16
  onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough
18
17
  onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata
19
- onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`;
20
- const propList = `${attributes} ${eventsName}`.split(/\s+/);
21
- const ariaPrefix = "aria-";
22
- const dataPrefix = "data-";
18
+ onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`.split(/\s+/);
19
+ var ariaPrefix = "aria-";
20
+ var dataPrefix = "data-";
23
21
  function match(key, prefix) {
24
- return key.indexOf(prefix) === 0;
22
+ return key.indexOf(prefix) === 0;
25
23
  }
26
24
  function pickAttrs(props, ariaOnly = false) {
27
- let mergedConfig;
28
- if (ariaOnly === false) {
29
- mergedConfig = {
30
- aria: true,
31
- data: true,
32
- attr: true
33
- };
34
- } else if (ariaOnly === true) {
35
- mergedConfig = {
36
- aria: true
37
- };
38
- } else {
39
- mergedConfig = {
40
- ...ariaOnly
41
- };
42
- }
43
- const attrs = {};
44
- Object.keys(props).forEach((key) => {
45
- if (
46
- // Aria
47
- mergedConfig.aria && (key === "role" || match(key, ariaPrefix)) || mergedConfig.data && match(key, dataPrefix) || mergedConfig.attr && propList.includes(key)
48
- ) {
49
- attrs[key] = props[key];
50
- }
51
- });
52
- return attrs;
25
+ let mergedConfig;
26
+ if (ariaOnly === false) mergedConfig = {
27
+ aria: true,
28
+ data: true,
29
+ attr: true
30
+ };
31
+ else if (ariaOnly === true) mergedConfig = { aria: true };
32
+ else mergedConfig = { ...ariaOnly };
33
+ const attrs = {};
34
+ Object.keys(props).forEach((key) => {
35
+ if (mergedConfig.aria && (key === "role" || match(key, ariaPrefix)) || mergedConfig.data && match(key, dataPrefix) || mergedConfig.attr && propList.includes(key)) attrs[key] = props[key];
36
+ });
37
+ return attrs;
53
38
  }
54
- export {
55
- pickAttrs as default
56
- };
39
+ export { pickAttrs as default };
@@ -1,65 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const vue = require("vue");
4
- const isValid = require("../isValid.cjs");
1
+ const require_isValid = require("../isValid.cjs");
2
+ let vue = require("vue");
5
3
  function isEmptyElement(c) {
6
- return c && (c.type === vue.Comment || c.type === vue.Fragment && c.children.length === 0 || c.type === vue.Text && c.children.trim() === "");
4
+ return c && (c.type === vue.Comment || c.type === vue.Fragment && c.children.length === 0 || c.type === vue.Text && c.children.trim() === "");
7
5
  }
8
6
  function filterEmpty(children = []) {
9
- const res = [];
10
- children.forEach((child) => {
11
- if (Array.isArray(child))
12
- res.push(...child);
13
- else if (child?.type === vue.Fragment)
14
- res.push(...filterEmpty(child.children));
15
- else res.push(child);
16
- });
17
- return res.filter((c) => !isEmptyElement(c));
7
+ const res = [];
8
+ children.forEach((child) => {
9
+ if (Array.isArray(child)) res.push(...child);
10
+ else if (child?.type === vue.Fragment) res.push(...filterEmpty(child.children));
11
+ else res.push(child);
12
+ });
13
+ return res.filter((c) => !isEmptyElement(c));
18
14
  }
19
15
  const skipFlattenKey = Symbol("skipFlatten");
20
16
  function flattenChildren(children, isFilterEmpty = true) {
21
- const temp = Array.isArray(children) ? children : [children];
22
- const res = [];
23
- temp.forEach((child) => {
24
- if (Array.isArray(child)) {
25
- res.push(...flattenChildren(child, isFilterEmpty));
26
- } else if (isValid.default(child)) {
27
- res.push(child);
28
- } else if (child && typeof child === "object" && child.type === vue.Fragment) {
29
- if (child.key === skipFlattenKey) {
30
- res.push(child);
31
- } else {
32
- res.push(...flattenChildren(child.children, isFilterEmpty));
33
- }
34
- } else if (child && vue.isVNode(child)) {
35
- if (isFilterEmpty && !isEmptyElement(child)) {
36
- res.push(child);
37
- } else if (!isFilterEmpty) {
38
- res.push(child);
39
- }
40
- }
41
- });
42
- if (isFilterEmpty) {
43
- return filterEmpty(res);
44
- }
45
- return res;
17
+ const temp = Array.isArray(children) ? children : [children];
18
+ const res = [];
19
+ temp.forEach((child) => {
20
+ if (Array.isArray(child)) res.push(...flattenChildren(child, isFilterEmpty));
21
+ else if (require_isValid.default(child)) res.push(child);
22
+ else if (child && typeof child === "object" && child.type === vue.Fragment) if (child.key === skipFlattenKey) res.push(child);
23
+ else res.push(...flattenChildren(child.children, isFilterEmpty));
24
+ else if (child && (0, vue.isVNode)(child)) {
25
+ if (isFilterEmpty && !isEmptyElement(child)) res.push(child);
26
+ else if (!isFilterEmpty) res.push(child);
27
+ }
28
+ });
29
+ if (isFilterEmpty) return filterEmpty(res);
30
+ return res;
46
31
  }
47
32
  function toPropsRefs(obj, ...args) {
48
- const _res = {};
49
- args.forEach((key) => {
50
- _res[key] = vue.toRef(obj, key);
51
- });
52
- return _res;
33
+ const _res = {};
34
+ args.forEach((key) => {
35
+ _res[key] = (0, vue.toRef)(obj, key);
36
+ });
37
+ return _res;
53
38
  }
54
39
  function removeUndefined(obj) {
55
- const res = {};
56
- Object.keys(obj).forEach((key) => {
57
- const value = obj[key];
58
- if (value !== void 0) {
59
- res[key] = value;
60
- }
61
- });
62
- return res;
40
+ const res = {};
41
+ Object.keys(obj).forEach((key) => {
42
+ const value = obj[key];
43
+ if (value !== void 0) res[key] = value;
44
+ });
45
+ return res;
63
46
  }
64
47
  exports.filterEmpty = filterEmpty;
65
48
  exports.flattenChildren = flattenChildren;
@@ -1,69 +1,47 @@
1
+ import isValid_default from "../isValid.js";
1
2
  import { Comment, Fragment, Text, isVNode, toRef } from "vue";
2
- import isValid from "../isValid.js";
3
3
  function isEmptyElement(c) {
4
- return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === "");
4
+ return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === "");
5
5
  }
6
6
  function filterEmpty(children = []) {
7
- const res = [];
8
- children.forEach((child) => {
9
- if (Array.isArray(child))
10
- res.push(...child);
11
- else if (child?.type === Fragment)
12
- res.push(...filterEmpty(child.children));
13
- else res.push(child);
14
- });
15
- return res.filter((c) => !isEmptyElement(c));
7
+ const res = [];
8
+ children.forEach((child) => {
9
+ if (Array.isArray(child)) res.push(...child);
10
+ else if (child?.type === Fragment) res.push(...filterEmpty(child.children));
11
+ else res.push(child);
12
+ });
13
+ return res.filter((c) => !isEmptyElement(c));
16
14
  }
17
15
  const skipFlattenKey = Symbol("skipFlatten");
18
16
  function flattenChildren(children, isFilterEmpty = true) {
19
- const temp = Array.isArray(children) ? children : [children];
20
- const res = [];
21
- temp.forEach((child) => {
22
- if (Array.isArray(child)) {
23
- res.push(...flattenChildren(child, isFilterEmpty));
24
- } else if (isValid(child)) {
25
- res.push(child);
26
- } else if (child && typeof child === "object" && child.type === Fragment) {
27
- if (child.key === skipFlattenKey) {
28
- res.push(child);
29
- } else {
30
- res.push(...flattenChildren(child.children, isFilterEmpty));
31
- }
32
- } else if (child && isVNode(child)) {
33
- if (isFilterEmpty && !isEmptyElement(child)) {
34
- res.push(child);
35
- } else if (!isFilterEmpty) {
36
- res.push(child);
37
- }
38
- }
39
- });
40
- if (isFilterEmpty) {
41
- return filterEmpty(res);
42
- }
43
- return res;
17
+ const temp = Array.isArray(children) ? children : [children];
18
+ const res = [];
19
+ temp.forEach((child) => {
20
+ if (Array.isArray(child)) res.push(...flattenChildren(child, isFilterEmpty));
21
+ else if (isValid_default(child)) res.push(child);
22
+ else if (child && typeof child === "object" && child.type === Fragment) if (child.key === skipFlattenKey) res.push(child);
23
+ else res.push(...flattenChildren(child.children, isFilterEmpty));
24
+ else if (child && isVNode(child)) {
25
+ if (isFilterEmpty && !isEmptyElement(child)) res.push(child);
26
+ else if (!isFilterEmpty) res.push(child);
27
+ }
28
+ });
29
+ if (isFilterEmpty) return filterEmpty(res);
30
+ return res;
44
31
  }
45
32
  function toPropsRefs(obj, ...args) {
46
- const _res = {};
47
- args.forEach((key) => {
48
- _res[key] = toRef(obj, key);
49
- });
50
- return _res;
33
+ const _res = {};
34
+ args.forEach((key) => {
35
+ _res[key] = toRef(obj, key);
36
+ });
37
+ return _res;
51
38
  }
52
39
  function removeUndefined(obj) {
53
- const res = {};
54
- Object.keys(obj).forEach((key) => {
55
- const value = obj[key];
56
- if (value !== void 0) {
57
- res[key] = value;
58
- }
59
- });
60
- return res;
40
+ const res = {};
41
+ Object.keys(obj).forEach((key) => {
42
+ const value = obj[key];
43
+ if (value !== void 0) res[key] = value;
44
+ });
45
+ return res;
61
46
  }
62
- export {
63
- filterEmpty,
64
- flattenChildren,
65
- isEmptyElement,
66
- removeUndefined,
67
- skipFlattenKey,
68
- toPropsRefs
69
- };
47
+ export { filterEmpty, flattenChildren, isEmptyElement, removeUndefined, skipFlattenKey, toPropsRefs };
package/dist/raf.cjs CHANGED
@@ -1,48 +1,45 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- let raf = (callback) => +setTimeout(callback, 16);
4
- let caf = (num) => clearTimeout(num);
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ var raf = (callback) => +setTimeout(callback, 16);
3
+ var caf = (num) => clearTimeout(num);
5
4
  if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
6
- raf = (callback) => window.requestAnimationFrame(callback);
7
- caf = (handle) => window.cancelAnimationFrame(handle);
5
+ raf = (callback) => window.requestAnimationFrame(callback);
6
+ caf = (handle) => window.cancelAnimationFrame(handle);
8
7
  }
9
- let rafUUID = 0;
10
- const rafIds = /* @__PURE__ */ new Map();
8
+ var rafUUID = 0;
9
+ var rafIds = /* @__PURE__ */ new Map();
11
10
  function cleanup(id) {
12
- rafIds.delete(id);
11
+ rafIds.delete(id);
13
12
  }
14
13
  function wrapperRaf(callback, times = 1) {
15
- rafUUID += 1;
16
- const id = rafUUID;
17
- function callRef(leftTimes) {
18
- if (leftTimes === 0) {
19
- cleanup(id);
20
- callback();
21
- } else {
22
- const realId = raf(() => {
23
- callRef(leftTimes - 1);
24
- });
25
- rafIds.set(id, realId);
26
- }
27
- }
28
- callRef(times);
29
- return id;
14
+ rafUUID += 1;
15
+ const id = rafUUID;
16
+ function callRef(leftTimes) {
17
+ if (leftTimes === 0) {
18
+ cleanup(id);
19
+ callback();
20
+ } else {
21
+ const realId = raf(() => {
22
+ callRef(leftTimes - 1);
23
+ });
24
+ rafIds.set(id, realId);
25
+ }
26
+ }
27
+ callRef(times);
28
+ return id;
30
29
  }
31
30
  wrapperRaf.cancel = (id) => {
32
- const realId = rafIds.get(id);
33
- cleanup(id);
34
- return caf(realId);
31
+ const realId = rafIds.get(id);
32
+ cleanup(id);
33
+ return caf(realId);
35
34
  };
36
- if (process.env.NODE_ENV !== "production")
37
- wrapperRaf.ids = () => rafIds;
35
+ if (process.env.NODE_ENV !== "production") wrapperRaf.ids = () => rafIds;
36
+ var raf_default = wrapperRaf;
38
37
  function rafDebounce(fn) {
39
- let id = null;
40
- return () => {
41
- if (id !== null) {
42
- wrapperRaf.cancel(id);
43
- }
44
- id = wrapperRaf(fn);
45
- };
38
+ let id = null;
39
+ return () => {
40
+ if (id !== null) wrapperRaf.cancel(id);
41
+ id = wrapperRaf(fn);
42
+ };
46
43
  }
47
- exports.default = wrapperRaf;
44
+ exports.default = raf_default;
48
45
  exports.rafDebounce = rafDebounce;
package/dist/raf.js CHANGED
@@ -1,48 +1,43 @@
1
- let raf = (callback) => +setTimeout(callback, 16);
2
- let caf = (num) => clearTimeout(num);
1
+ var raf = (callback) => +setTimeout(callback, 16);
2
+ var caf = (num) => clearTimeout(num);
3
3
  if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
4
- raf = (callback) => window.requestAnimationFrame(callback);
5
- caf = (handle) => window.cancelAnimationFrame(handle);
4
+ raf = (callback) => window.requestAnimationFrame(callback);
5
+ caf = (handle) => window.cancelAnimationFrame(handle);
6
6
  }
7
- let rafUUID = 0;
8
- const rafIds = /* @__PURE__ */ new Map();
7
+ var rafUUID = 0;
8
+ var rafIds = /* @__PURE__ */ new Map();
9
9
  function cleanup(id) {
10
- rafIds.delete(id);
10
+ rafIds.delete(id);
11
11
  }
12
12
  function wrapperRaf(callback, times = 1) {
13
- rafUUID += 1;
14
- const id = rafUUID;
15
- function callRef(leftTimes) {
16
- if (leftTimes === 0) {
17
- cleanup(id);
18
- callback();
19
- } else {
20
- const realId = raf(() => {
21
- callRef(leftTimes - 1);
22
- });
23
- rafIds.set(id, realId);
24
- }
25
- }
26
- callRef(times);
27
- return id;
13
+ rafUUID += 1;
14
+ const id = rafUUID;
15
+ function callRef(leftTimes) {
16
+ if (leftTimes === 0) {
17
+ cleanup(id);
18
+ callback();
19
+ } else {
20
+ const realId = raf(() => {
21
+ callRef(leftTimes - 1);
22
+ });
23
+ rafIds.set(id, realId);
24
+ }
25
+ }
26
+ callRef(times);
27
+ return id;
28
28
  }
29
29
  wrapperRaf.cancel = (id) => {
30
- const realId = rafIds.get(id);
31
- cleanup(id);
32
- return caf(realId);
30
+ const realId = rafIds.get(id);
31
+ cleanup(id);
32
+ return caf(realId);
33
33
  };
34
- if (process.env.NODE_ENV !== "production")
35
- wrapperRaf.ids = () => rafIds;
34
+ if (process.env.NODE_ENV !== "production") wrapperRaf.ids = () => rafIds;
35
+ var raf_default = wrapperRaf;
36
36
  function rafDebounce(fn) {
37
- let id = null;
38
- return () => {
39
- if (id !== null) {
40
- wrapperRaf.cancel(id);
41
- }
42
- id = wrapperRaf(fn);
43
- };
37
+ let id = null;
38
+ return () => {
39
+ if (id !== null) wrapperRaf.cancel(id);
40
+ id = wrapperRaf(fn);
41
+ };
44
42
  }
45
- export {
46
- wrapperRaf as default,
47
- rafDebounce
48
- };
43
+ export { raf_default as default, rafDebounce };
package/dist/setStyle.cjs CHANGED
@@ -1,17 +1,16 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
1
+ Object.defineProperty(exports, "__esModule", { value: true });
3
2
  function setStyle(style, options = {}) {
4
- if (!style)
5
- return {};
6
- const { element = document.body } = options;
7
- const oldStyle = {};
8
- const styleKeys = Object.keys(style);
9
- styleKeys.forEach((key) => {
10
- oldStyle[key] = element.style[key];
11
- });
12
- styleKeys.forEach((key) => {
13
- element.style[key] = style[key];
14
- });
15
- return oldStyle;
3
+ if (!style) return {};
4
+ const { element = document.body } = options;
5
+ const oldStyle = {};
6
+ const styleKeys = Object.keys(style);
7
+ styleKeys.forEach((key) => {
8
+ oldStyle[key] = element.style[key];
9
+ });
10
+ styleKeys.forEach((key) => {
11
+ element.style[key] = style[key];
12
+ });
13
+ return oldStyle;
16
14
  }
17
- exports.default = setStyle;
15
+ var setStyle_default = setStyle;
16
+ exports.default = setStyle_default;
package/dist/setStyle.js CHANGED
@@ -1,17 +1,15 @@
1
1
  function setStyle(style, options = {}) {
2
- if (!style)
3
- return {};
4
- const { element = document.body } = options;
5
- const oldStyle = {};
6
- const styleKeys = Object.keys(style);
7
- styleKeys.forEach((key) => {
8
- oldStyle[key] = element.style[key];
9
- });
10
- styleKeys.forEach((key) => {
11
- element.style[key] = style[key];
12
- });
13
- return oldStyle;
2
+ if (!style) return {};
3
+ const { element = document.body } = options;
4
+ const oldStyle = {};
5
+ const styleKeys = Object.keys(style);
6
+ styleKeys.forEach((key) => {
7
+ oldStyle[key] = element.style[key];
8
+ });
9
+ styleKeys.forEach((key) => {
10
+ element.style[key] = style[key];
11
+ });
12
+ return oldStyle;
14
13
  }
15
- export {
16
- setStyle as default
17
- };
14
+ var setStyle_default = setStyle;
15
+ export { setStyle_default as default };