@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
package/dist/Portal.cjs CHANGED
@@ -1,48 +1,42 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const vue = require("vue");
4
- const canUseDom = require("./Dom/canUseDom.cjs");
5
- const Portal = /* @__PURE__ */ vue.defineComponent((props, ctx) => {
6
- const parentRef = vue.shallowRef();
7
- const containerRef = vue.shallowRef();
8
- const initRef = vue.shallowRef(false);
9
- if (!initRef.value && canUseDom.default()) {
10
- containerRef.value = props.getContainer();
11
- parentRef.value = containerRef.value?.parentNode;
12
- initRef.value = true;
13
- }
14
- vue.onMounted(() => {
15
- if (containerRef.value?.parentNode === null && parentRef.value !== null) parentRef.value.appendChild(containerRef.value);
16
- });
17
- vue.onBeforeUnmount(() => {
18
- props.didUpdate?.(props);
19
- });
20
- vue.onUnmounted(() => {
21
- containerRef.value?.parentNode?.removeChild?.(containerRef.value);
22
- });
23
- return () => {
24
- if (containerRef.value) {
25
- return vue.createVNode(vue.Teleport, {
26
- "to": containerRef.value
27
- }, {
28
- default: () => [ctx.slots.default?.()]
29
- });
30
- }
31
- return null;
32
- };
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ const require_canUseDom = require("./Dom/canUseDom.cjs");
3
+ let vue = require("vue");
4
+ var Portal = /* @__PURE__ */ (0, vue.defineComponent)((props, ctx) => {
5
+ const parentRef = (0, vue.shallowRef)();
6
+ const containerRef = (0, vue.shallowRef)();
7
+ const initRef = (0, vue.shallowRef)(false);
8
+ if (!initRef.value && require_canUseDom.default()) {
9
+ containerRef.value = props.getContainer();
10
+ parentRef.value = containerRef.value?.parentNode;
11
+ initRef.value = true;
12
+ }
13
+ (0, vue.onMounted)(() => {
14
+ if (containerRef.value?.parentNode === null && parentRef.value !== null) parentRef.value.appendChild(containerRef.value);
15
+ });
16
+ (0, vue.onBeforeUnmount)(() => {
17
+ props.didUpdate?.(props);
18
+ });
19
+ (0, vue.onUnmounted)(() => {
20
+ containerRef.value?.parentNode?.removeChild?.(containerRef.value);
21
+ });
22
+ return () => {
23
+ if (containerRef.value) return (0, vue.createVNode)(vue.Teleport, { "to": containerRef.value }, { default: () => [ctx.slots.default?.()] });
24
+ return null;
25
+ };
33
26
  }, {
34
- props: {
35
- didUpdate: {
36
- type: Function,
37
- required: false,
38
- default: void 0
39
- },
40
- getContainer: {
41
- type: Function,
42
- required: true,
43
- default: void 0
44
- }
45
- },
46
- inheritAttrs: false
27
+ props: {
28
+ didUpdate: {
29
+ type: Function,
30
+ required: false,
31
+ default: void 0
32
+ },
33
+ getContainer: {
34
+ type: Function,
35
+ required: true,
36
+ default: void 0
37
+ }
38
+ },
39
+ inheritAttrs: false
47
40
  });
48
- exports.default = Portal;
41
+ var Portal_default = Portal;
42
+ exports.default = Portal_default;
package/dist/Portal.js CHANGED
@@ -1,48 +1,40 @@
1
- import { defineComponent, shallowRef, onMounted, onBeforeUnmount, onUnmounted, createVNode, Teleport } from "vue";
2
1
  import canUseDom from "./Dom/canUseDom.js";
3
- const Portal = /* @__PURE__ */ defineComponent((props, ctx) => {
4
- const parentRef = shallowRef();
5
- const containerRef = shallowRef();
6
- const initRef = shallowRef(false);
7
- if (!initRef.value && canUseDom()) {
8
- containerRef.value = props.getContainer();
9
- parentRef.value = containerRef.value?.parentNode;
10
- initRef.value = true;
11
- }
12
- onMounted(() => {
13
- if (containerRef.value?.parentNode === null && parentRef.value !== null) parentRef.value.appendChild(containerRef.value);
14
- });
15
- onBeforeUnmount(() => {
16
- props.didUpdate?.(props);
17
- });
18
- onUnmounted(() => {
19
- containerRef.value?.parentNode?.removeChild?.(containerRef.value);
20
- });
21
- return () => {
22
- if (containerRef.value) {
23
- return createVNode(Teleport, {
24
- "to": containerRef.value
25
- }, {
26
- default: () => [ctx.slots.default?.()]
27
- });
28
- }
29
- return null;
30
- };
2
+ import { Teleport, createVNode, defineComponent, onBeforeUnmount, onMounted, onUnmounted, shallowRef } from "vue";
3
+ var Portal_default = /* @__PURE__ */ defineComponent((props, ctx) => {
4
+ const parentRef = shallowRef();
5
+ const containerRef = shallowRef();
6
+ const initRef = shallowRef(false);
7
+ if (!initRef.value && canUseDom()) {
8
+ containerRef.value = props.getContainer();
9
+ parentRef.value = containerRef.value?.parentNode;
10
+ initRef.value = true;
11
+ }
12
+ onMounted(() => {
13
+ if (containerRef.value?.parentNode === null && parentRef.value !== null) parentRef.value.appendChild(containerRef.value);
14
+ });
15
+ onBeforeUnmount(() => {
16
+ props.didUpdate?.(props);
17
+ });
18
+ onUnmounted(() => {
19
+ containerRef.value?.parentNode?.removeChild?.(containerRef.value);
20
+ });
21
+ return () => {
22
+ if (containerRef.value) return createVNode(Teleport, { "to": containerRef.value }, { default: () => [ctx.slots.default?.()] });
23
+ return null;
24
+ };
31
25
  }, {
32
- props: {
33
- didUpdate: {
34
- type: Function,
35
- required: false,
36
- default: void 0
37
- },
38
- getContainer: {
39
- type: Function,
40
- required: true,
41
- default: void 0
42
- }
43
- },
44
- inheritAttrs: false
26
+ props: {
27
+ didUpdate: {
28
+ type: Function,
29
+ required: false,
30
+ default: void 0
31
+ },
32
+ getContainer: {
33
+ type: Function,
34
+ required: true,
35
+ default: void 0
36
+ }
37
+ },
38
+ inheritAttrs: false
45
39
  });
46
- export {
47
- Portal as default
48
- };
40
+ export { Portal_default as default };
@@ -1,169 +1,135 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const vue = require("vue");
4
- const canUseDom = require("./Dom/canUseDom.cjs");
5
- const scrollLocker = require("./Dom/scrollLocker.cjs");
6
- const Portal = require("./Portal.cjs");
7
- const raf = require("./raf.cjs");
8
- const setStyle = require("./setStyle.cjs");
9
- let openCount = 0;
10
- const supportDom = canUseDom.default();
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ const require_canUseDom = require("./Dom/canUseDom.cjs");
3
+ const require_Portal = require("./Portal.cjs");
4
+ const require_setStyle = require("./setStyle.cjs");
5
+ const require_scrollLocker = require("./Dom/scrollLocker.cjs");
6
+ const require_raf = require("./raf.cjs");
7
+ let vue = require("vue");
8
+ var openCount = 0;
9
+ var supportDom = require_canUseDom.default();
11
10
  function getOpenCount() {
12
- return process.env.NODE_ENV === "test" ? openCount : 0;
11
+ return process.env.NODE_ENV === "test" ? openCount : 0;
13
12
  }
14
- let cacheOverflow = {};
13
+ var cacheOverflow = {};
15
14
  function getParent(getContainer) {
16
- if (!supportDom) return null;
17
- if (getContainer) {
18
- if (typeof getContainer === "string") return document.querySelectorAll(getContainer)[0];
19
- if (typeof getContainer === "function") return getContainer();
20
- if (typeof getContainer === "object" && getContainer instanceof window.HTMLElement) {
21
- return getContainer;
22
- }
23
- }
24
- return document.body;
15
+ if (!supportDom) return null;
16
+ if (getContainer) {
17
+ if (typeof getContainer === "string") return document.querySelectorAll(getContainer)[0];
18
+ if (typeof getContainer === "function") return getContainer();
19
+ if (typeof getContainer === "object" && getContainer instanceof window.HTMLElement) return getContainer;
20
+ }
21
+ return document.body;
25
22
  }
26
- const PortalWrapper = /* @__PURE__ */ vue.defineComponent((props, ctx) => {
27
- const container = vue.shallowRef();
28
- const componentRef = vue.shallowRef();
29
- const rafId = vue.shallowRef();
30
- const scrollLocker$1 = vue.shallowRef();
31
- const removeCurrentContainer = () => {
32
- container.value?.parentNode?.removeChild(container.value);
33
- };
34
- const updateOpenCount = (prevProps) => {
35
- const {
36
- visible: prevVisible,
37
- getContainer: prevGetContainer
38
- } = prevProps || {};
39
- const {
40
- visible,
41
- getContainer: getContainer2
42
- } = props;
43
- if (visible !== prevVisible && supportDom && getParent(getContainer2) === document.body) {
44
- if (visible && !prevVisible) openCount += 1;
45
- else if (prevProps) openCount -= 1;
46
- }
47
- const getContainerIsFunc = typeof getContainer2 === "function" && typeof prevGetContainer === "function";
48
- if (getContainerIsFunc ? getContainer2.toString() !== prevGetContainer.toString() : getContainer2 !== prevGetContainer) {
49
- removeCurrentContainer();
50
- }
51
- };
52
- const attachToParent = (force = false) => {
53
- if (force || container.value && !container.value.parentNode) {
54
- const parent = getParent(props.getContainer);
55
- if (parent) {
56
- parent.appendChild(container.value);
57
- return true;
58
- }
59
- return false;
60
- }
61
- return true;
62
- };
63
- const setWrapperClassName = () => {
64
- const {
65
- wrapperClassName
66
- } = props;
67
- if (container.value && wrapperClassName && wrapperClassName !== container.value.className) {
68
- container.value.className = wrapperClassName;
69
- }
70
- };
71
- const getContainer = () => {
72
- if (!supportDom) return null;
73
- if (!container.value) {
74
- container.value = document.createElement("div");
75
- attachToParent(true);
76
- }
77
- setWrapperClassName();
78
- return container.value;
79
- };
80
- vue.onMounted(() => {
81
- scrollLocker$1.value = new scrollLocker.default({
82
- container: getParent(props.getContainer)
83
- });
84
- updateOpenCount();
85
- if (!attachToParent()) {
86
- rafId.value = raf.default(() => {
87
- });
88
- }
89
- });
90
- vue.onUpdated(() => {
91
- updateOpenCount(props);
92
- updateOpenCount(props);
93
- setWrapperClassName();
94
- attachToParent();
95
- });
96
- vue.onBeforeUnmount(() => {
97
- const {
98
- visible,
99
- getContainer: getContainer2
100
- } = props;
101
- if (supportDom && getParent(getContainer2) === document.body) {
102
- openCount = visible && openCount ? openCount - 1 : openCount;
103
- }
104
- removeCurrentContainer();
105
- raf.default.cancel(rafId.value);
106
- });
107
- const switchScrollingEffect = () => {
108
- if (openCount === 1 && !Object.keys(cacheOverflow).length) {
109
- switchScrollingEffect();
110
- cacheOverflow = setStyle.default({
111
- overflow: "hidden",
112
- overflowX: "hidden",
113
- overflowY: "hidden"
114
- });
115
- } else if (!openCount) {
116
- setStyle.default(cacheOverflow);
117
- cacheOverflow = {};
118
- switchScrollingEffect();
119
- }
120
- };
121
- return () => {
122
- const {
123
- forceRender,
124
- visible
125
- } = props;
126
- let portal = null;
127
- const childProps = {
128
- getOpenCount,
129
- getContainer,
130
- switchScrollingEffect,
131
- scrollLocker: scrollLocker$1.value
132
- };
133
- if (forceRender || visible || componentRef.value) {
134
- portal = vue.createVNode(Portal.default, {
135
- "getContainer": getContainer,
136
- "ref": componentRef
137
- }, {
138
- default: () => [ctx?.slots?.default(childProps)]
139
- });
140
- }
141
- return portal;
142
- };
143
- }, {
144
- props: {
145
- visible: {
146
- type: Boolean,
147
- required: false,
148
- default: void 0
149
- },
150
- getContainer: {
151
- type: [String, Function],
152
- required: false,
153
- skipCheck: true,
154
- default: void 0
155
- },
156
- wrapperClassName: {
157
- type: String,
158
- required: false,
159
- default: void 0
160
- },
161
- forceRender: {
162
- type: Boolean,
163
- required: false,
164
- default: void 0
165
- }
166
- }
167
- });
168
- exports.default = PortalWrapper;
23
+ var PortalWrapper = /* @__PURE__ */ (0, vue.defineComponent)((props, ctx) => {
24
+ const container = (0, vue.shallowRef)();
25
+ const componentRef = (0, vue.shallowRef)();
26
+ const rafId = (0, vue.shallowRef)();
27
+ const scrollLocker = (0, vue.shallowRef)();
28
+ const removeCurrentContainer = () => {
29
+ container.value?.parentNode?.removeChild(container.value);
30
+ };
31
+ const updateOpenCount = (prevProps) => {
32
+ const { visible: prevVisible, getContainer: prevGetContainer } = prevProps || {};
33
+ const { visible, getContainer: getContainer$1 } = props;
34
+ if (visible !== prevVisible && supportDom && getParent(getContainer$1) === document.body) {
35
+ if (visible && !prevVisible) openCount += 1;
36
+ else if (prevProps) openCount -= 1;
37
+ }
38
+ if (typeof getContainer$1 === "function" && typeof prevGetContainer === "function" ? getContainer$1.toString() !== prevGetContainer.toString() : getContainer$1 !== prevGetContainer) removeCurrentContainer();
39
+ };
40
+ const attachToParent = (force = false) => {
41
+ if (force || container.value && !container.value.parentNode) {
42
+ const parent = getParent(props.getContainer);
43
+ if (parent) {
44
+ parent.appendChild(container.value);
45
+ return true;
46
+ }
47
+ return false;
48
+ }
49
+ return true;
50
+ };
51
+ const setWrapperClassName = () => {
52
+ const { wrapperClassName } = props;
53
+ if (container.value && wrapperClassName && wrapperClassName !== container.value.className) container.value.className = wrapperClassName;
54
+ };
55
+ const getContainer = () => {
56
+ if (!supportDom) return null;
57
+ if (!container.value) {
58
+ container.value = document.createElement("div");
59
+ attachToParent(true);
60
+ }
61
+ setWrapperClassName();
62
+ return container.value;
63
+ };
64
+ (0, vue.onMounted)(() => {
65
+ scrollLocker.value = new require_scrollLocker.default({ container: getParent(props.getContainer) });
66
+ updateOpenCount();
67
+ if (!attachToParent()) rafId.value = require_raf.default(() => {});
68
+ });
69
+ (0, vue.onUpdated)(() => {
70
+ updateOpenCount(props);
71
+ updateOpenCount(props);
72
+ setWrapperClassName();
73
+ attachToParent();
74
+ });
75
+ (0, vue.onBeforeUnmount)(() => {
76
+ const { visible, getContainer: getContainer$1 } = props;
77
+ if (supportDom && getParent(getContainer$1) === document.body) openCount = visible && openCount ? openCount - 1 : openCount;
78
+ removeCurrentContainer();
79
+ require_raf.default.cancel(rafId.value);
80
+ });
81
+ const switchScrollingEffect = () => {
82
+ if (openCount === 1 && !Object.keys(cacheOverflow).length) {
83
+ switchScrollingEffect();
84
+ cacheOverflow = require_setStyle.default({
85
+ overflow: "hidden",
86
+ overflowX: "hidden",
87
+ overflowY: "hidden"
88
+ });
89
+ } else if (!openCount) {
90
+ require_setStyle.default(cacheOverflow);
91
+ cacheOverflow = {};
92
+ switchScrollingEffect();
93
+ }
94
+ };
95
+ return () => {
96
+ const { forceRender, visible } = props;
97
+ let portal = null;
98
+ const childProps = {
99
+ getOpenCount,
100
+ getContainer,
101
+ switchScrollingEffect,
102
+ scrollLocker: scrollLocker.value
103
+ };
104
+ if (forceRender || visible || componentRef.value) portal = (0, vue.createVNode)(require_Portal.default, {
105
+ "getContainer": getContainer,
106
+ "ref": componentRef
107
+ }, { default: () => [ctx?.slots?.default(childProps)] });
108
+ return portal;
109
+ };
110
+ }, { props: {
111
+ visible: {
112
+ type: Boolean,
113
+ required: false,
114
+ default: void 0
115
+ },
116
+ getContainer: {
117
+ type: [String, Function],
118
+ required: false,
119
+ skipCheck: true,
120
+ default: void 0
121
+ },
122
+ wrapperClassName: {
123
+ type: String,
124
+ required: false,
125
+ default: void 0
126
+ },
127
+ forceRender: {
128
+ type: Boolean,
129
+ required: false,
130
+ default: void 0
131
+ }
132
+ } });
133
+ var PortalWrapper_default = PortalWrapper;
134
+ exports.default = PortalWrapper_default;
169
135
  exports.getOpenCount = getOpenCount;