@v-c/util 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/Children/isFragment.cjs +5 -1
  2. package/dist/Children/isFragment.js +4 -6
  3. package/dist/Children/toArray.cjs +13 -1
  4. package/dist/Children/toArray.js +12 -10
  5. package/dist/Dom/addEventListener.cjs +8 -1
  6. package/dist/Dom/addEventListener.js +7 -10
  7. package/dist/Dom/canUseDom.cjs +5 -1
  8. package/dist/Dom/canUseDom.js +3 -5
  9. package/dist/Dom/class.cjs +15 -1
  10. package/dist/Dom/class.js +10 -16
  11. package/dist/Dom/contains.cjs +12 -1
  12. package/dist/Dom/contains.js +10 -15
  13. package/dist/Dom/css.cjs +81 -1
  14. package/dist/Dom/css.js +63 -64
  15. package/dist/Dom/dynamicCSS.cjs +83 -1
  16. package/dist/Dom/dynamicCSS.js +70 -67
  17. package/dist/Dom/findDOMNode.cjs +13 -1
  18. package/dist/Dom/findDOMNode.js +9 -10
  19. package/dist/Dom/focus.cjs +53 -1
  20. package/dist/Dom/focus.js +43 -34
  21. package/dist/Dom/isVisible.cjs +17 -1
  22. package/dist/Dom/isVisible.js +15 -21
  23. package/dist/Dom/scrollLocker.cjs +67 -1
  24. package/dist/Dom/scrollLocker.js +65 -63
  25. package/dist/Dom/shadow.cjs +11 -1
  26. package/dist/Dom/shadow.js +7 -10
  27. package/dist/Dom/styleChecker.cjs +21 -1
  28. package/dist/Dom/styleChecker.js +18 -17
  29. package/dist/Dom/support.cjs +20 -1
  30. package/dist/Dom/support.js +17 -22
  31. package/dist/EventInterface.cjs +0 -1
  32. package/dist/EventInterface.js +0 -1
  33. package/dist/KeyCode.cjs +166 -1
  34. package/dist/KeyCode.js +164 -515
  35. package/dist/Portal.cjs +42 -1
  36. package/dist/Portal.js +38 -31
  37. package/dist/PortalWrapper.cjs +135 -1
  38. package/dist/PortalWrapper.js +130 -113
  39. package/dist/classnames.cjs +37 -1
  40. package/dist/classnames.js +33 -30
  41. package/dist/composeProps.cjs +17 -1
  42. package/dist/composeProps.js +15 -12
  43. package/dist/createRef.cjs +22 -1
  44. package/dist/createRef.js +16 -18
  45. package/dist/debug/diff.cjs +44 -1
  46. package/dist/debug/diff.js +41 -39
  47. package/dist/deprecated.cjs +5 -1
  48. package/dist/deprecated.js +3 -7
  49. package/dist/getScrollBarSize.cjs +47 -1
  50. package/dist/getScrollBarSize.js +42 -34
  51. package/dist/guid.cjs +6 -1
  52. package/dist/guid.js +4 -6
  53. package/dist/hooks/useEvent.cjs +5 -1
  54. package/dist/hooks/useEvent.js +3 -5
  55. package/dist/hooks/useId.cjs +13 -1
  56. package/dist/hooks/useId.js +10 -10
  57. package/dist/hooks/useLayoutEffect.cjs +35 -1
  58. package/dist/hooks/useLayoutEffect.js +32 -26
  59. package/dist/hooks/useMemo.cjs +12 -1
  60. package/dist/hooks/useMemo.js +10 -9
  61. package/dist/hooks/useMergedState.cjs +25 -1
  62. package/dist/hooks/useMergedState.js +23 -20
  63. package/dist/hooks/useMobile.cjs +16 -1
  64. package/dist/hooks/useMobile.js +13 -13
  65. package/dist/hooks/useState.cjs +10 -1
  66. package/dist/hooks/useState.js +8 -10
  67. package/dist/index.cjs +9 -1
  68. package/dist/index.js +5 -11
  69. package/dist/isEqual.cjs +28 -1
  70. package/dist/isEqual.js +26 -31
  71. package/dist/isMobile.cjs +7 -1
  72. package/dist/isMobile.js +5 -12
  73. package/dist/isValid.cjs +6 -1
  74. package/dist/isValid.js +4 -5
  75. package/dist/omit.cjs +9 -1
  76. package/dist/omit.js +7 -8
  77. package/dist/pickAttrs.cjs +25 -3
  78. package/dist/pickAttrs.js +22 -24
  79. package/dist/props-util/index.cjs +52 -1
  80. package/dist/props-util/index.js +42 -34
  81. package/dist/raf.cjs +45 -1
  82. package/dist/raf.js +39 -33
  83. package/dist/setStyle.cjs +16 -1
  84. package/dist/setStyle.js +14 -12
  85. package/dist/switchScrollingEffect.cjs +32 -1
  86. package/dist/switchScrollingEffect.js +29 -29
  87. package/dist/test/domHook.cjs +38 -1
  88. package/dist/test/domHook.js +35 -35
  89. package/dist/type.cjs +70 -1
  90. package/dist/type.d.ts +1 -1
  91. package/dist/type.js +59 -49
  92. package/dist/utils/checkSlotProp.cjs +9 -1
  93. package/dist/utils/checkSlotProp.js +8 -5
  94. package/dist/utils/get.cjs +10 -1
  95. package/dist/utils/get.js +8 -11
  96. package/dist/utils/omit.cjs +8 -1
  97. package/dist/utils/omit.js +7 -8
  98. package/dist/utils/set.cjs +50 -1
  99. package/dist/utils/set.js +42 -37
  100. package/dist/utils/transition.cjs +92 -1
  101. package/dist/utils/transition.js +83 -86
  102. package/dist/utils/watchState.cjs +18 -1
  103. package/dist/utils/watchState.js +15 -13
  104. package/dist/vnode.cjs +48 -1
  105. package/dist/vnode.js +38 -34
  106. package/dist/vueuse/unref-element.cjs +6 -1
  107. package/dist/vueuse/unref-element.js +5 -7
  108. package/dist/warning.cjs +45 -1
  109. package/dist/warning.js +30 -41
  110. package/package.json +1 -1
package/dist/Portal.cjs CHANGED
@@ -1 +1,42 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),o=require("./Dom/canUseDom.cjs"),r=e.defineComponent((n,a)=>{const u=e.shallowRef(),t=e.shallowRef(),l=e.shallowRef(!1);return!l.value&&o.default()&&(t.value=n.getContainer(),u.value=t.value?.parentNode,l.value=!0),e.onMounted(()=>{t.value?.parentNode===null&&u.value!==null&&u.value.appendChild(t.value)}),e.onBeforeUnmount(()=>{n.didUpdate?.(n)}),e.onUnmounted(()=>{t.value?.parentNode?.removeChild?.(t.value)}),()=>t.value?e.createVNode(e.Teleport,{to:t.value},{default:()=>[a.slots.default?.()]}):null},{props:{didUpdate:{type:Function,required:!1,default:void 0},getContainer:{type:Function,required:!0,default:void 0}},inheritAttrs:!1});exports.default=r;
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
+ };
26
+ }, {
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
40
+ });
41
+ var Portal_default = Portal;
42
+ exports.default = Portal_default;
package/dist/Portal.js CHANGED
@@ -1,33 +1,40 @@
1
- import { defineComponent as o, shallowRef as a, onMounted as r, onBeforeUnmount as d, onUnmounted as i, createVNode as f, Teleport as v } from "vue";
2
- import p from "./Dom/canUseDom.js";
3
- const m = /* @__PURE__ */ o((t, l) => {
4
- const n = a(), e = a(), u = a(!1);
5
- return !u.value && p() && (e.value = t.getContainer(), n.value = e.value?.parentNode, u.value = !0), r(() => {
6
- e.value?.parentNode === null && n.value !== null && n.value.appendChild(e.value);
7
- }), d(() => {
8
- t.didUpdate?.(t);
9
- }), i(() => {
10
- e.value?.parentNode?.removeChild?.(e.value);
11
- }), () => e.value ? f(v, {
12
- to: e.value
13
- }, {
14
- default: () => [l.slots.default?.()]
15
- }) : null;
1
+ import canUseDom from "./Dom/canUseDom.js";
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
+ };
16
25
  }, {
17
- props: {
18
- didUpdate: {
19
- type: Function,
20
- required: !1,
21
- default: void 0
22
- },
23
- getContainer: {
24
- type: Function,
25
- required: !0,
26
- default: void 0
27
- }
28
- },
29
- inheritAttrs: !1
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
30
39
  });
31
- export {
32
- m as default
33
- };
40
+ export { Portal_default as default };
@@ -1 +1,135 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),O=require("./Dom/canUseDom.cjs"),R=require("./Dom/scrollLocker.cjs"),k=require("./Portal.cjs"),b=require("./raf.cjs"),q=require("./setStyle.cjs");let l=0;const s=O.default();function N(){return process.env.NODE_ENV==="test"?l:0}let f={};function c(e){if(!s)return null;if(e){if(typeof e=="string")return document.querySelectorAll(e)[0];if(typeof e=="function")return e();if(typeof e=="object"&&e instanceof window.HTMLElement)return e}return document.body}const E=r.defineComponent((e,S)=>{const n=r.shallowRef(),m=r.shallowRef(),C=r.shallowRef(),y=r.shallowRef(),g=()=>{n.value?.parentNode?.removeChild(n.value)},d=t=>{const{visible:o,getContainer:u}=t||{},{visible:a,getContainer:i}=e;a!==o&&s&&c(i)===document.body&&(a&&!o?l+=1:t&&(l-=1)),(typeof i=="function"&&typeof u=="function"?i.toString()!==u.toString():i!==u)&&g()},v=(t=!1)=>{if(t||n.value&&!n.value.parentNode){const o=c(e.getContainer);return o?(o.appendChild(n.value),!0):!1}return!0},h=()=>{const{wrapperClassName:t}=e;n.value&&t&&t!==n.value.className&&(n.value.className=t)},w=()=>s?(n.value||(n.value=document.createElement("div"),v(!0)),h(),n.value):null;r.onMounted(()=>{y.value=new R.default({container:c(e.getContainer)}),d(),v()||(C.value=b.default(()=>{}))}),r.onUpdated(()=>{d(e),d(e),h(),v()}),r.onBeforeUnmount(()=>{const{visible:t,getContainer:o}=e;s&&c(o)===document.body&&(l=t&&l?l-1:l),g(),b.default.cancel(C.value)});const p=()=>{l===1&&!Object.keys(f).length?(p(),f=q.default({overflow:"hidden",overflowX:"hidden",overflowY:"hidden"})):l||(q.default(f),f={},p())};return()=>{const{forceRender:t,visible:o}=e;let u=null;const a={getOpenCount:N,getContainer:w,switchScrollingEffect:p,scrollLocker:y.value};return(t||o||m.value)&&(u=r.createVNode(k.default,{getContainer:w,ref:m},{default:()=>[S?.slots?.default(a)]})),u}},{props:{visible:{type:Boolean,required:!1,default:void 0},getContainer:{type:[String,Function],required:!1,skipCheck:!0,default:void 0},wrapperClassName:{type:String,required:!1,default:void 0},forceRender:{type:Boolean,required:!1,default:void 0}}});exports.default=E;exports.getOpenCount=N;
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();
10
+ function getOpenCount() {
11
+ return process.env.NODE_ENV === "test" ? openCount : 0;
12
+ }
13
+ var cacheOverflow = {};
14
+ function getParent(getContainer) {
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;
22
+ }
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;
135
+ exports.getOpenCount = getOpenCount;
@@ -1,115 +1,132 @@
1
- import { defineComponent as k, shallowRef as u, onMounted as q, onUpdated as E, onBeforeUnmount as O, createVNode as R } from "vue";
2
- import L from "./Dom/canUseDom.js";
3
- import P from "./Dom/scrollLocker.js";
4
- import B from "./Portal.js";
5
- import b from "./raf.js";
6
- import N from "./setStyle.js";
7
- let r = 0;
8
- const s = L();
9
- function D() {
10
- return process.env.NODE_ENV === "test" ? r : 0;
1
+ import canUseDom from "./Dom/canUseDom.js";
2
+ import Portal_default from "./Portal.js";
3
+ import setStyle_default from "./setStyle.js";
4
+ import ScrollLocker from "./Dom/scrollLocker.js";
5
+ import raf_default from "./raf.js";
6
+ import { createVNode, defineComponent, onBeforeUnmount, onMounted, onUpdated, shallowRef } from "vue";
7
+ var openCount = 0;
8
+ var supportDom = canUseDom();
9
+ function getOpenCount() {
10
+ return process.env.NODE_ENV === "test" ? openCount : 0;
11
11
  }
12
- let f = {};
13
- function c(e) {
14
- if (!s) return null;
15
- if (e) {
16
- if (typeof e == "string") return document.querySelectorAll(e)[0];
17
- if (typeof e == "function") return e();
18
- if (typeof e == "object" && e instanceof window.HTMLElement)
19
- return e;
20
- }
21
- return document.body;
12
+ var cacheOverflow = {};
13
+ function getParent(getContainer) {
14
+ if (!supportDom) return null;
15
+ if (getContainer) {
16
+ if (typeof getContainer === "string") return document.querySelectorAll(getContainer)[0];
17
+ if (typeof getContainer === "function") return getContainer();
18
+ if (typeof getContainer === "object" && getContainer instanceof window.HTMLElement) return getContainer;
19
+ }
20
+ return document.body;
22
21
  }
23
- const W = /* @__PURE__ */ k((e, S) => {
24
- const n = u(), v = u(), C = u(), y = u(), g = () => {
25
- n.value?.parentNode?.removeChild(n.value);
26
- }, d = (t) => {
27
- const {
28
- visible: o,
29
- getContainer: l
30
- } = t || {}, {
31
- visible: a,
32
- getContainer: i
33
- } = e;
34
- a !== o && s && c(i) === document.body && (a && !o ? r += 1 : t && (r -= 1)), (typeof i == "function" && typeof l == "function" ? i.toString() !== l.toString() : i !== l) && g();
35
- }, p = (t = !1) => {
36
- if (t || n.value && !n.value.parentNode) {
37
- const o = c(e.getContainer);
38
- return o ? (o.appendChild(n.value), !0) : !1;
39
- }
40
- return !0;
41
- }, h = () => {
42
- const {
43
- wrapperClassName: t
44
- } = e;
45
- n.value && t && t !== n.value.className && (n.value.className = t);
46
- }, w = () => s ? (n.value || (n.value = document.createElement("div"), p(!0)), h(), n.value) : null;
47
- q(() => {
48
- y.value = new P({
49
- container: c(e.getContainer)
50
- }), d(), p() || (C.value = b(() => {
51
- }));
52
- }), E(() => {
53
- d(e), d(e), h(), p();
54
- }), O(() => {
55
- const {
56
- visible: t,
57
- getContainer: o
58
- } = e;
59
- s && c(o) === document.body && (r = t && r ? r - 1 : r), g(), b.cancel(C.value);
60
- });
61
- const m = () => {
62
- r === 1 && !Object.keys(f).length ? (m(), f = N({
63
- overflow: "hidden",
64
- overflowX: "hidden",
65
- overflowY: "hidden"
66
- })) : r || (N(f), f = {}, m());
67
- };
68
- return () => {
69
- const {
70
- forceRender: t,
71
- visible: o
72
- } = e;
73
- let l = null;
74
- const a = {
75
- getOpenCount: D,
76
- getContainer: w,
77
- switchScrollingEffect: m,
78
- scrollLocker: y.value
79
- };
80
- return (t || o || v.value) && (l = R(B, {
81
- getContainer: w,
82
- ref: v
83
- }, {
84
- default: () => [S?.slots?.default(a)]
85
- })), l;
86
- };
87
- }, {
88
- props: {
89
- visible: {
90
- type: Boolean,
91
- required: !1,
92
- default: void 0
93
- },
94
- getContainer: {
95
- type: [String, Function],
96
- required: !1,
97
- skipCheck: !0,
98
- default: void 0
99
- },
100
- wrapperClassName: {
101
- type: String,
102
- required: !1,
103
- default: void 0
104
- },
105
- forceRender: {
106
- type: Boolean,
107
- required: !1,
108
- default: void 0
109
- }
110
- }
111
- });
112
- export {
113
- W as default,
114
- D as getOpenCount
115
- };
22
+ var PortalWrapper_default = /* @__PURE__ */ defineComponent((props, ctx) => {
23
+ const container = shallowRef();
24
+ const componentRef = shallowRef();
25
+ const rafId = shallowRef();
26
+ const scrollLocker = shallowRef();
27
+ const removeCurrentContainer = () => {
28
+ container.value?.parentNode?.removeChild(container.value);
29
+ };
30
+ const updateOpenCount = (prevProps) => {
31
+ const { visible: prevVisible, getContainer: prevGetContainer } = prevProps || {};
32
+ const { visible, getContainer: getContainer$1 } = props;
33
+ if (visible !== prevVisible && supportDom && getParent(getContainer$1) === document.body) {
34
+ if (visible && !prevVisible) openCount += 1;
35
+ else if (prevProps) openCount -= 1;
36
+ }
37
+ if (typeof getContainer$1 === "function" && typeof prevGetContainer === "function" ? getContainer$1.toString() !== prevGetContainer.toString() : getContainer$1 !== prevGetContainer) removeCurrentContainer();
38
+ };
39
+ const attachToParent = (force = false) => {
40
+ if (force || container.value && !container.value.parentNode) {
41
+ const parent = getParent(props.getContainer);
42
+ if (parent) {
43
+ parent.appendChild(container.value);
44
+ return true;
45
+ }
46
+ return false;
47
+ }
48
+ return true;
49
+ };
50
+ const setWrapperClassName = () => {
51
+ const { wrapperClassName } = props;
52
+ if (container.value && wrapperClassName && wrapperClassName !== container.value.className) container.value.className = wrapperClassName;
53
+ };
54
+ const getContainer = () => {
55
+ if (!supportDom) return null;
56
+ if (!container.value) {
57
+ container.value = document.createElement("div");
58
+ attachToParent(true);
59
+ }
60
+ setWrapperClassName();
61
+ return container.value;
62
+ };
63
+ onMounted(() => {
64
+ scrollLocker.value = new ScrollLocker({ container: getParent(props.getContainer) });
65
+ updateOpenCount();
66
+ if (!attachToParent()) rafId.value = raf_default(() => {});
67
+ });
68
+ onUpdated(() => {
69
+ updateOpenCount(props);
70
+ updateOpenCount(props);
71
+ setWrapperClassName();
72
+ attachToParent();
73
+ });
74
+ onBeforeUnmount(() => {
75
+ const { visible, getContainer: getContainer$1 } = props;
76
+ if (supportDom && getParent(getContainer$1) === document.body) openCount = visible && openCount ? openCount - 1 : openCount;
77
+ removeCurrentContainer();
78
+ raf_default.cancel(rafId.value);
79
+ });
80
+ const switchScrollingEffect = () => {
81
+ if (openCount === 1 && !Object.keys(cacheOverflow).length) {
82
+ switchScrollingEffect();
83
+ cacheOverflow = setStyle_default({
84
+ overflow: "hidden",
85
+ overflowX: "hidden",
86
+ overflowY: "hidden"
87
+ });
88
+ } else if (!openCount) {
89
+ setStyle_default(cacheOverflow);
90
+ cacheOverflow = {};
91
+ switchScrollingEffect();
92
+ }
93
+ };
94
+ return () => {
95
+ const { forceRender, visible } = props;
96
+ let portal = null;
97
+ const childProps = {
98
+ getOpenCount,
99
+ getContainer,
100
+ switchScrollingEffect,
101
+ scrollLocker: scrollLocker.value
102
+ };
103
+ if (forceRender || visible || componentRef.value) portal = createVNode(Portal_default, {
104
+ "getContainer": getContainer,
105
+ "ref": componentRef
106
+ }, { default: () => [ctx?.slots?.default(childProps)] });
107
+ return portal;
108
+ };
109
+ }, { props: {
110
+ visible: {
111
+ type: Boolean,
112
+ required: false,
113
+ default: void 0
114
+ },
115
+ getContainer: {
116
+ type: [String, Function],
117
+ required: false,
118
+ skipCheck: true,
119
+ default: void 0
120
+ },
121
+ wrapperClassName: {
122
+ type: String,
123
+ required: false,
124
+ default: void 0
125
+ },
126
+ forceRender: {
127
+ type: Boolean,
128
+ required: false,
129
+ default: void 0
130
+ }
131
+ } });
132
+ export { PortalWrapper_default as default, getOpenCount };
@@ -1 +1,37 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ function toVal(mix) {
3
+ let str = "";
4
+ if (typeof mix === "string" || typeof mix === "number") str += mix;
5
+ else if (typeof mix === "object") {
6
+ if (Array.isArray(mix)) {
7
+ for (let k = 0; k < mix.length; k++) if (mix[k]) {
8
+ const y = toVal(mix[k]);
9
+ if (y) {
10
+ str && (str += " ");
11
+ str += y;
12
+ }
13
+ }
14
+ } else for (const k in mix) if (mix[k]) {
15
+ str && (str += " ");
16
+ str += k;
17
+ }
18
+ }
19
+ return str;
20
+ }
21
+ function classNames(...args) {
22
+ let str = "";
23
+ for (let i = 0; i < args.length; i++) {
24
+ const tmp = args[i];
25
+ if (tmp) {
26
+ const x = toVal(tmp);
27
+ if (x) {
28
+ str && (str += " ");
29
+ str += x;
30
+ }
31
+ }
32
+ }
33
+ return str;
34
+ }
35
+ const clsx = classNames;
36
+ exports.clsx = clsx;
37
+ exports.default = classNames;
@@ -1,32 +1,35 @@
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);
11
- }
12
- } else
13
- for (const f in t)
14
- t[f] && (e && (e += " "), e += f);
15
- return e;
1
+ function toVal(mix) {
2
+ let str = "";
3
+ if (typeof mix === "string" || typeof mix === "number") str += mix;
4
+ else if (typeof mix === "object") {
5
+ if (Array.isArray(mix)) {
6
+ for (let k = 0; k < mix.length; k++) if (mix[k]) {
7
+ const y = toVal(mix[k]);
8
+ if (y) {
9
+ str && (str += " ");
10
+ str += y;
11
+ }
12
+ }
13
+ } else for (const k in mix) if (mix[k]) {
14
+ str && (str += " ");
15
+ str += k;
16
+ }
17
+ }
18
+ return str;
16
19
  }
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);
24
- }
25
- }
26
- return e;
20
+ function classNames(...args) {
21
+ let str = "";
22
+ for (let i = 0; i < args.length; i++) {
23
+ const tmp = args[i];
24
+ if (tmp) {
25
+ const x = toVal(tmp);
26
+ if (x) {
27
+ str && (str += " ");
28
+ str += x;
29
+ }
30
+ }
31
+ }
32
+ return str;
27
33
  }
28
- const l = s;
29
- export {
30
- l as clsx,
31
- s as default
32
- };
34
+ const clsx = classNames;
35
+ export { clsx, classNames as default };
@@ -1 +1,17 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ function composeProps(originProps, patchProps, isAll) {
3
+ const composedProps = {
4
+ ...originProps,
5
+ ...isAll ? patchProps : {}
6
+ };
7
+ Object.keys(patchProps).forEach((key) => {
8
+ const func = patchProps[key];
9
+ if (typeof func === "function") composedProps[key] = (...args) => {
10
+ func(...args);
11
+ return originProps[key]?.(...args);
12
+ };
13
+ });
14
+ return composedProps;
15
+ }
16
+ var composeProps_default = composeProps;
17
+ exports.default = composeProps_default;
@@ -1,13 +1,16 @@
1
- function s(t, o, u) {
2
- const c = {
3
- ...t,
4
- ...u ? o : {}
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;
1
+ function composeProps(originProps, patchProps, isAll) {
2
+ const composedProps = {
3
+ ...originProps,
4
+ ...isAll ? patchProps : {}
5
+ };
6
+ Object.keys(patchProps).forEach((key) => {
7
+ const func = patchProps[key];
8
+ if (typeof func === "function") composedProps[key] = (...args) => {
9
+ func(...args);
10
+ return originProps[key]?.(...args);
11
+ };
12
+ });
13
+ return composedProps;
10
14
  }
11
- export {
12
- s as default
13
- };
15
+ var composeProps_default = composeProps;
16
+ export { composeProps_default as default };