@v-c/util 0.0.2 → 0.0.3

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 (103) hide show
  1. package/dist/Children/isFragment.d.ts +0 -1
  2. package/dist/Children/toArray.d.ts +0 -1
  3. package/dist/Dom/addEventListener.cjs +1 -1
  4. package/dist/Dom/addEventListener.d.ts +2 -2
  5. package/dist/Dom/addEventListener.js +5 -6
  6. package/dist/Dom/dynamicCSS.cjs +1 -1
  7. package/dist/Dom/dynamicCSS.d.ts +1 -1
  8. package/dist/Dom/dynamicCSS.js +33 -34
  9. package/dist/Dom/findDOMNode.d.ts +0 -1
  10. package/dist/Dom/scrollLocker.cjs +1 -1
  11. package/dist/Dom/scrollLocker.js +59 -76
  12. package/dist/Dom/shadow.cjs +1 -1
  13. package/dist/Dom/shadow.js +8 -9
  14. package/dist/Portal.cjs +1 -1
  15. package/dist/Portal.js +14 -21
  16. package/dist/PortalWrapper.cjs +1 -1
  17. package/dist/PortalWrapper.d.ts +2 -3
  18. package/dist/PortalWrapper.js +39 -42
  19. package/dist/composeProps.cjs +1 -1
  20. package/dist/composeProps.js +8 -11
  21. package/dist/createRef.d.ts +0 -1
  22. package/dist/debug/diff.d.ts +1 -1
  23. package/dist/getScrollBarSize.cjs +1 -1
  24. package/dist/getScrollBarSize.js +14 -14
  25. package/dist/hooks/useEvent.cjs +1 -0
  26. package/dist/hooks/useEvent.d.ts +1 -0
  27. package/dist/hooks/useEvent.js +6 -0
  28. package/dist/hooks/useId.cjs +1 -1
  29. package/dist/hooks/useId.d.ts +1 -5
  30. package/dist/hooks/useId.js +8 -13
  31. package/dist/hooks/useLayoutEffect.cjs +1 -0
  32. package/dist/hooks/useLayoutEffect.d.ts +3 -0
  33. package/dist/hooks/useLayoutEffect.js +28 -0
  34. package/dist/hooks/useMemo.d.ts +0 -1
  35. package/dist/hooks/useMergedState.cjs +1 -1
  36. package/dist/hooks/useMergedState.d.ts +0 -1
  37. package/dist/hooks/useMergedState.js +16 -16
  38. package/dist/hooks/useMobile.cjs +1 -0
  39. package/dist/hooks/useMobile.d.ts +2 -0
  40. package/dist/hooks/useMobile.js +14 -0
  41. package/dist/hooks/useState.d.ts +0 -1
  42. package/dist/isMobile.cjs +1 -1
  43. package/dist/isMobile.js +4 -4
  44. package/dist/isValid.cjs +1 -0
  45. package/dist/isValid.d.ts +2 -0
  46. package/dist/isValid.js +6 -0
  47. package/dist/pickAttrs.cjs +1 -1
  48. package/dist/pickAttrs.js +1 -1
  49. package/dist/props-util/index.cjs +1 -1
  50. package/dist/props-util/index.d.ts +6 -1
  51. package/dist/props-util/index.js +21 -9
  52. package/dist/props-util/initDefaultProps.cjs +1 -0
  53. package/dist/props-util/initDefaultProps.d.ts +8 -0
  54. package/dist/props-util/initDefaultProps.js +13 -0
  55. package/dist/setStyle.d.ts +0 -1
  56. package/dist/type.d.ts +2 -3
  57. package/dist/utils/checkSlotProp.cjs +1 -1
  58. package/dist/utils/checkSlotProp.js +3 -4
  59. package/dist/utils/omit.cjs +1 -0
  60. package/dist/utils/omit.d.ts +1 -0
  61. package/dist/utils/omit.js +9 -0
  62. package/dist/utils/set.cjs +1 -1
  63. package/dist/utils/set.d.ts +1 -0
  64. package/dist/utils/set.js +1 -0
  65. package/dist/utils/transition.cjs +1 -0
  66. package/dist/utils/transition.d.ts +18 -0
  67. package/dist/utils/transition.js +79 -0
  68. package/dist/vnode.cjs +1 -1
  69. package/dist/vnode.d.ts +1 -2
  70. package/dist/vnode.js +14 -15
  71. package/dist/vueuse/unref-element.cjs +1 -0
  72. package/dist/vueuse/unref-element.d.ts +8 -0
  73. package/dist/vueuse/unref-element.js +8 -0
  74. package/package.json +1 -1
  75. package/src/Children/tests/isFragment.test.tsx +1 -1
  76. package/src/Children/tests/toArray.test.tsx +3 -3
  77. package/src/Dom/addEventListener.ts +2 -2
  78. package/src/Dom/focus.ts +1 -1
  79. package/src/Dom/scrollLocker.ts +5 -4
  80. package/src/KeyCode.ts +2 -1
  81. package/src/Portal.tsx +1 -1
  82. package/src/PortalWrapper.tsx +9 -6
  83. package/src/createRef.ts +0 -1
  84. package/src/hooks/useEvent.ts +3 -0
  85. package/src/hooks/useId.ts +13 -24
  86. package/src/hooks/useLayoutEffect.ts +61 -0
  87. package/src/hooks/useMobile.ts +16 -0
  88. package/src/isMobile.ts +1 -1
  89. package/src/isValid.ts +4 -0
  90. package/src/pickAttrs.ts +3 -2
  91. package/src/props-util/index.ts +57 -22
  92. package/src/props-util/initDefaultProps.ts +34 -0
  93. package/src/test/domHook.ts +1 -2
  94. package/src/type.ts +2 -2
  95. package/src/utils/omit.ts +9 -0
  96. package/src/utils/set.ts +1 -1
  97. package/src/utils/transition.ts +128 -0
  98. package/src/vnode.ts +2 -2
  99. package/src/vueuse/unref-element.ts +13 -0
  100. package/tsconfig.json +3 -2
  101. package/vite.config.ts +1 -1
  102. package/vitest.config.ts +11 -0
  103. package/tests/{Portal.test.tsx → Portal.spec.tsx} +2 -2
@@ -1,3 +1,2 @@
1
1
  import { VNode, VNodeChild } from 'vue';
2
-
3
2
  export declare function isFragment(node: VNodeChild): node is VNode;
@@ -1,5 +1,4 @@
1
1
  import { VNode } from 'vue';
2
-
3
2
  export interface Option {
4
3
  keepEmpty?: boolean;
5
4
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function v(...o){const[e,n,i,t]=o;return e!=null&&e.addEventListener&&e.addEventListener(n,i,t),{remove(){var d;(d=e==null?void 0:e.removeEventListener)==null||d.call(e,n,i,t)}}}exports.addEventListener=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function d(...i){const[e,t,n,r]=i;return e?.addEventListener&&e.addEventListener(t,n,r),{remove(){e?.removeEventListener?.(t,n,r)}}}exports.addEventListener=d;
@@ -1,8 +1,8 @@
1
1
  export type WindowEventName = keyof WindowEventMap;
2
2
  export type DocumentEventName = keyof DocumentEventMap;
3
3
  export declare function addEventListener<E extends WindowEventName = WindowEventName>(target: Window, eventType: E, cb: WindowEventMap[E], option?: AddEventListenerOptions): {
4
- remove(): void;
4
+ remove: () => void;
5
5
  };
6
6
  export declare function addEventListener<E extends DocumentEventName = DocumentEventName>(target: Document, eventType: E, cb: DocumentEventMap[E], option?: AddEventListenerOptions): {
7
- remove(): void;
7
+ remove: () => void;
8
8
  };
@@ -1,12 +1,11 @@
1
- function s(...d) {
2
- const [e, n, i, o] = d;
3
- return e != null && e.addEventListener && e.addEventListener(n, i, o), {
1
+ function o(...i) {
2
+ const [e, t, n, r] = i;
3
+ return e?.addEventListener && e.addEventListener(t, n, r), {
4
4
  remove() {
5
- var v;
6
- (v = e == null ? void 0 : e.removeEventListener) == null || v.call(e, n, i, o);
5
+ e?.removeEventListener?.(t, n, r);
7
6
  }
8
7
  };
9
8
  }
10
9
  export {
11
- s as addEventListener
10
+ o as addEventListener
12
11
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./canUseDom.cjs"),N=require("./contains.cjs"),h="data-vc-order",C="data-vc-priority",v="vc-util-key",d=new Map;function g({mark:e}={}){return e?e.startsWith("data-")?e:`data-${e}`:v}function s(e){return e.attachTo?e.attachTo:document.querySelector("head")||document.body}function P(e){return e==="queue"?"prependQueue":e?"prepend":"append"}function y(e){return Array.from((d.get(e)||e).children).filter(n=>n.tagName==="STYLE")}function l(e,n={}){if(!A.default())return null;const{csp:t,prepend:i,priority:r=0}=n,u=P(i),a=u==="prependQueue",c=document.createElement("style");c.setAttribute(h,u),a&&r&&c.setAttribute(C,`${r}`),t!=null&&t.nonce&&(c.nonce=t==null?void 0:t.nonce),c.innerHTML=e;const o=s(n),{firstChild:p}=o;if(i){if(a){const f=y(o).filter(S=>{if(!["prepend","prependQueue"].includes(S.getAttribute(h)))return!1;const b=Number(S.getAttribute(C)||0);return r>=b});if(f.length)return o.insertBefore(c,f[f.length-1].nextSibling),c}o.insertBefore(c,p)}else o.appendChild(c);return c}function m(e,n={}){const t=s(n);return y(t).find(i=>i.getAttribute(g(n))===e)}function T(e,n={}){const t=m(e,n);t&&s(n).removeChild(t)}function E(e,n){const t=d.get(e);if(!t||!N.default(document,t)){const i=l("",n),{parentNode:r}=i;d.set(e,r),e.removeChild(i)}}function M(){d.clear()}function R(e,n,t={}){var a,c,o;const i=s(t);E(i,t);const r=m(n,t);if(r)return(a=t.csp)!=null&&a.nonce&&r.nonce!==((c=t.csp)==null?void 0:c.nonce)&&(r.nonce=(o=t.csp)==null?void 0:o.nonce),r.innerHTML!==e&&(r.innerHTML=e),r;const u=l(e,t);return u.setAttribute(g(t),n),u}exports.clearContainerCache=M;exports.injectCSS=l;exports.removeCSS=T;exports.updateCSS=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./canUseDom.cjs"),N=require("./contains.cjs"),h="data-vc-order",C="data-vc-priority",v="vc-util-key",a=new Map;function p({mark:e}={}){return e?e.startsWith("data-")?e:`data-${e}`:v}function s(e){return e.attachTo?e.attachTo:document.querySelector("head")||document.body}function P(e){return e==="queue"?"prependQueue":e?"prepend":"append"}function g(e){return Array.from((a.get(e)||e).children).filter(n=>n.tagName==="STYLE")}function f(e,n={}){if(!A.default())return null;const{csp:t,prepend:c,priority:r=0}=n,o=P(c),l=o==="prependQueue",i=document.createElement("style");i.setAttribute(h,o),l&&r&&i.setAttribute(C,`${r}`),t?.nonce&&(i.nonce=t?.nonce),i.innerHTML=e;const u=s(n),{firstChild:m}=u;if(c){if(l){const d=g(u).filter(S=>{if(!["prepend","prependQueue"].includes(S.getAttribute(h)))return!1;const b=Number(S.getAttribute(C)||0);return r>=b});if(d.length)return u.insertBefore(i,d[d.length-1].nextSibling),i}u.insertBefore(i,m)}else u.appendChild(i);return i}function y(e,n={}){const t=s(n);return g(t).find(c=>c.getAttribute(p(n))===e)}function T(e,n={}){const t=y(e,n);t&&s(n).removeChild(t)}function E(e,n){const t=a.get(e);if(!t||!N.default(document,t)){const c=f("",n),{parentNode:r}=c;a.set(e,r),e.removeChild(c)}}function M(){a.clear()}function R(e,n,t={}){const c=s(t);E(c,t);const r=y(n,t);if(r)return t.csp?.nonce&&r.nonce!==t.csp?.nonce&&(r.nonce=t.csp?.nonce),r.innerHTML!==e&&(r.innerHTML=e),r;const o=f(e,t);return o.setAttribute(p(t),n),o}exports.clearContainerCache=M;exports.injectCSS=f;exports.removeCSS=T;exports.updateCSS=R;
@@ -14,7 +14,7 @@ interface Options {
14
14
  priority?: number;
15
15
  mark?: string;
16
16
  }
17
- export declare function injectCSS(css: string, option?: Options): HTMLStyleElement | null;
17
+ export declare function injectCSS(css: string, option?: Options): HTMLStyleElement;
18
18
  export declare function removeCSS(key: string, option?: Options): void;
19
19
  /**
20
20
  * manually clear container cache to avoid global cache in unit testes
@@ -1,74 +1,73 @@
1
1
  import N from "./canUseDom.js";
2
2
  import b from "./contains.js";
3
- const h = "data-vc-order", m = "data-vc-priority", E = "vc-util-key", a = /* @__PURE__ */ new Map();
4
- function g({ mark: e } = {}) {
3
+ const h = "data-vc-order", p = "data-vc-priority", E = "vc-util-key", s = /* @__PURE__ */ new Map();
4
+ function m({ mark: e } = {}) {
5
5
  return e ? e.startsWith("data-") ? e : `data-${e}` : E;
6
6
  }
7
- function s(e) {
7
+ function d(e) {
8
8
  return e.attachTo ? e.attachTo : document.querySelector("head") || document.body;
9
9
  }
10
10
  function P(e) {
11
11
  return e === "queue" ? "prependQueue" : e ? "prepend" : "append";
12
12
  }
13
- function p(e) {
13
+ function g(e) {
14
14
  return Array.from(
15
- (a.get(e) || e).children
15
+ (s.get(e) || e).children
16
16
  ).filter((n) => n.tagName === "STYLE");
17
17
  }
18
18
  function C(e, n = {}) {
19
19
  if (!N())
20
20
  return null;
21
- const { csp: t, prepend: i, priority: r = 0 } = n, u = P(i), d = u === "prependQueue", c = document.createElement("style");
22
- c.setAttribute(h, u), d && r && c.setAttribute(m, `${r}`), t != null && t.nonce && (c.nonce = t == null ? void 0 : t.nonce), c.innerHTML = e;
23
- const o = s(n), { firstChild: S } = o;
24
- if (i) {
25
- if (d) {
26
- const f = p(o).filter((l) => {
21
+ const { csp: t, prepend: c, priority: r = 0 } = n, o = P(c), f = o === "prependQueue", i = document.createElement("style");
22
+ i.setAttribute(h, o), f && r && i.setAttribute(p, `${r}`), t?.nonce && (i.nonce = t?.nonce), i.innerHTML = e;
23
+ const u = d(n), { firstChild: S } = u;
24
+ if (c) {
25
+ if (f) {
26
+ const a = g(u).filter((l) => {
27
27
  if (!["prepend", "prependQueue"].includes(l.getAttribute(h)))
28
28
  return !1;
29
- const A = Number(l.getAttribute(m) || 0);
29
+ const A = Number(l.getAttribute(p) || 0);
30
30
  return r >= A;
31
31
  });
32
- if (f.length)
33
- return o.insertBefore(
34
- c,
35
- f[f.length - 1].nextSibling
36
- ), c;
32
+ if (a.length)
33
+ return u.insertBefore(
34
+ i,
35
+ a[a.length - 1].nextSibling
36
+ ), i;
37
37
  }
38
- o.insertBefore(c, S);
38
+ u.insertBefore(i, S);
39
39
  } else
40
- o.appendChild(c);
41
- return c;
40
+ u.appendChild(i);
41
+ return i;
42
42
  }
43
43
  function y(e, n = {}) {
44
- const t = s(n);
45
- return p(t).find(
46
- (i) => i.getAttribute(g(n)) === e
44
+ const t = d(n);
45
+ return g(t).find(
46
+ (c) => c.getAttribute(m(n)) === e
47
47
  );
48
48
  }
49
49
  function x(e, n = {}) {
50
50
  const t = y(e, n);
51
- t && s(n).removeChild(t);
51
+ t && d(n).removeChild(t);
52
52
  }
53
53
  function R(e, n) {
54
- const t = a.get(e);
54
+ const t = s.get(e);
55
55
  if (!t || !b(document, t)) {
56
- const i = C("", n), { parentNode: r } = i;
57
- a.set(e, r), e.removeChild(i);
56
+ const c = C("", n), { parentNode: r } = c;
57
+ s.set(e, r), e.removeChild(c);
58
58
  }
59
59
  }
60
60
  function M() {
61
- a.clear();
61
+ s.clear();
62
62
  }
63
63
  function D(e, n, t = {}) {
64
- var d, c, o;
65
- const i = s(t);
66
- R(i, t);
64
+ const c = d(t);
65
+ R(c, t);
67
66
  const r = y(n, t);
68
67
  if (r)
69
- return (d = t.csp) != null && d.nonce && r.nonce !== ((c = t.csp) == null ? void 0 : c.nonce) && (r.nonce = (o = t.csp) == null ? void 0 : o.nonce), r.innerHTML !== e && (r.innerHTML = e), r;
70
- const u = C(e, t);
71
- return u.setAttribute(g(t), n), u;
68
+ return t.csp?.nonce && r.nonce !== t.csp?.nonce && (r.nonce = t.csp?.nonce), r.innerHTML !== e && (r.innerHTML = e), r;
69
+ const o = C(e, t);
70
+ return o.setAttribute(m(t), n), o;
72
71
  }
73
72
  export {
74
73
  M as clearContainerCache,
@@ -1,5 +1,4 @@
1
1
  import { ComponentPublicInstance, MaybeRef } from 'vue';
2
-
3
2
  export declare function isDOM(node: any): node is HTMLElement | SVGElement;
4
3
  /**
5
4
  * Return if a node is a DOM node. Else will return by `findDOMNode`
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var g=(s,t,e)=>t in s?u(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var c=(s,t,e)=>g(s,typeof t!="symbol"?t+"":t,e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("../getScrollBarSize.cjs"),f=require("../setStyle.cjs");let k=0,n=[];const h="ant-scrolling-effect",a=new RegExp(`${h}`,"g"),d=new Map;class N{constructor(t){c(this,"lockTarget");c(this,"options");c(this,"getContainer",()=>{var t;return(t=this.options)==null?void 0:t.container});c(this,"reLock",t=>{const e=n.find(({target:l})=>l===this.lockTarget);e&&this.unLock(),this.options=t,e&&(e.options=t,this.lock())});c(this,"lock",()=>{var r;if(n.some(({target:o})=>o===this.lockTarget))return;if(n.some(({options:o})=>{var i;return(o==null?void 0:o.container)===((i=this.options)==null?void 0:i.container)})){n=[...n,{target:this.lockTarget,options:this.options}];return}let t=0;const e=((r=this.options)==null?void 0:r.container)||document.body;(e===document.body&&window.innerWidth-document.documentElement.clientWidth>0||e.scrollHeight>e.clientHeight)&&getComputedStyle(e).overflow!=="hidden"&&(t=m.default());const l=e.className;if(n.filter(({options:o})=>{var i;return(o==null?void 0:o.container)===((i=this.options)==null?void 0:i.container)}).length===0&&d.set(e,f.default({width:t!==0?`calc(100% - ${t}px)`:void 0,overflow:"hidden",overflowX:"hidden",overflowY:"hidden"},{element:e})),!a.test(l)){const o=`${l} ${h}`;e.className=o.trim()}n=[...n,{target:this.lockTarget,options:this.options}]});c(this,"unLock",()=>{var r;const t=n.find(({target:o})=>o===this.lockTarget);if(n=n.filter(({target:o})=>o!==this.lockTarget),!t||n.some(({options:o})=>{var i;return(o==null?void 0:o.container)===((i=t.options)==null?void 0:i.container)}))return;const e=((r=this.options)==null?void 0:r.container)||document.body,l=e.className;a.test(l)&&(f.default(d.get(e),{element:e}),d.delete(e),e.className=e.className.replace(a,"").trim())});this.lockTarget=k++,this.options=t}}exports.default=N;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("../getScrollBarSize.cjs"),l=require("../setStyle.cjs");let d=0,o=[];const r="ant-scrolling-effect",s=new RegExp(`${r}`,"g"),c=new Map;class f{lockTarget;options;constructor(n){this.lockTarget=d++,this.options=n}getContainer=()=>this.options?.container;reLock=n=>{const t=o.find(({target:i})=>i===this.lockTarget);t&&this.unLock(),this.options=n,t&&(t.options=n,this.lock())};lock=()=>{if(o.some(({target:e})=>e===this.lockTarget))return;if(o.some(({options:e})=>e?.container===this.options?.container)){o=[...o,{target:this.lockTarget,options:this.options}];return}let n=0;const t=this.options?.container||document.body;(t===document.body&&window.innerWidth-document.documentElement.clientWidth>0||t.scrollHeight>t.clientHeight)&&getComputedStyle(t).overflow!=="hidden"&&(n=a.default());const i=t.className;if(o.filter(({options:e})=>e?.container===this.options?.container).length===0&&c.set(t,l.default({width:n!==0?`calc(100% - ${n}px)`:void 0,overflow:"hidden",overflowX:"hidden",overflowY:"hidden"},{element:t})),!s.test(i)){const e=`${i} ${r}`;t.className=e.trim()}o=[...o,{target:this.lockTarget,options:this.options}]};unLock=()=>{const n=o.find(({target:e})=>e===this.lockTarget);if(o=o.filter(({target:e})=>e!==this.lockTarget),!n||o.some(({options:e})=>e?.container===n.options?.container))return;const t=this.options?.container||document.body,i=t.className;s.test(i)&&(l.default(c.get(t),{element:t}),c.delete(t),t.className=t.className.replace(s,"").trim())}}exports.default=f;
@@ -1,81 +1,64 @@
1
- var m = Object.defineProperty;
2
- var g = (s, e, t) => e in s ? m(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var c = (s, e, t) => g(s, typeof e != "symbol" ? e + "" : e, t);
4
- import k from "../getScrollBarSize.js";
5
- import f from "../setStyle.js";
6
- let u = 0, n = [];
7
- const h = "ant-scrolling-effect", a = new RegExp(
8
- `${h}`,
1
+ import a from "../getScrollBarSize.js";
2
+ import r from "../setStyle.js";
3
+ let d = 0, o = [];
4
+ const l = "ant-scrolling-effect", s = new RegExp(
5
+ `${l}`,
9
6
  "g"
10
- ), d = /* @__PURE__ */ new Map();
11
- class T {
12
- constructor(e) {
13
- c(this, "lockTarget");
14
- c(this, "options");
15
- c(this, "getContainer", () => {
16
- var e;
17
- return (e = this.options) == null ? void 0 : e.container;
18
- });
19
- // if options change...
20
- c(this, "reLock", (e) => {
21
- const t = n.find(({ target: r }) => r === this.lockTarget);
22
- t && this.unLock(), this.options = e, t && (t.options = e, this.lock());
23
- });
24
- c(this, "lock", () => {
25
- var l;
26
- if (n.some(({ target: o }) => o === this.lockTarget))
27
- return;
28
- if (n.some(
29
- ({ options: o }) => {
30
- var i;
31
- return (o == null ? void 0 : o.container) === ((i = this.options) == null ? void 0 : i.container);
32
- }
33
- )) {
34
- n = [...n, { target: this.lockTarget, options: this.options }];
35
- return;
36
- }
37
- let e = 0;
38
- const t = ((l = this.options) == null ? void 0 : l.container) || document.body;
39
- (t === document.body && window.innerWidth - document.documentElement.clientWidth > 0 || t.scrollHeight > t.clientHeight) && getComputedStyle(t).overflow !== "hidden" && (e = k());
40
- const r = t.className;
41
- if (n.filter(
42
- ({ options: o }) => {
43
- var i;
44
- return (o == null ? void 0 : o.container) === ((i = this.options) == null ? void 0 : i.container);
45
- }
46
- ).length === 0 && d.set(
47
- t,
48
- f(
49
- {
50
- width: e !== 0 ? `calc(100% - ${e}px)` : void 0,
51
- overflow: "hidden",
52
- overflowX: "hidden",
53
- overflowY: "hidden"
54
- },
55
- { element: t }
56
- )
57
- ), !a.test(r)) {
58
- const o = `${r} ${h}`;
59
- t.className = o.trim();
60
- }
61
- n = [...n, { target: this.lockTarget, options: this.options }];
62
- });
63
- c(this, "unLock", () => {
64
- var l;
65
- const e = n.find(({ target: o }) => o === this.lockTarget);
66
- if (n = n.filter(({ target: o }) => o !== this.lockTarget), !e || n.some(
67
- ({ options: o }) => {
68
- var i;
69
- return (o == null ? void 0 : o.container) === ((i = e.options) == null ? void 0 : i.container);
70
- }
71
- ))
72
- return;
73
- const t = ((l = this.options) == null ? void 0 : l.container) || document.body, r = t.className;
74
- a.test(r) && (f(d.get(t), { element: t }), d.delete(t), t.className = t.className.replace(a, "").trim());
75
- });
76
- this.lockTarget = u++, this.options = e;
7
+ ), c = /* @__PURE__ */ new Map();
8
+ class g {
9
+ lockTarget;
10
+ options;
11
+ constructor(n) {
12
+ this.lockTarget = d++, this.options = n;
77
13
  }
14
+ getContainer = () => this.options?.container;
15
+ // if options change...
16
+ reLock = (n) => {
17
+ const t = o.find(({ target: i }) => i === this.lockTarget);
18
+ t && this.unLock(), this.options = n, t && (t.options = n, this.lock());
19
+ };
20
+ lock = () => {
21
+ if (o.some(({ target: e }) => e === this.lockTarget))
22
+ return;
23
+ if (o.some(
24
+ ({ options: e }) => e?.container === this.options?.container
25
+ )) {
26
+ o = [...o, { target: this.lockTarget, options: this.options }];
27
+ return;
28
+ }
29
+ let n = 0;
30
+ const t = this.options?.container || document.body;
31
+ (t === document.body && window.innerWidth - document.documentElement.clientWidth > 0 || t.scrollHeight > t.clientHeight) && getComputedStyle(t).overflow !== "hidden" && (n = a());
32
+ const i = t.className;
33
+ if (o.filter(
34
+ ({ options: e }) => e?.container === this.options?.container
35
+ ).length === 0 && c.set(
36
+ t,
37
+ r(
38
+ {
39
+ width: n !== 0 ? `calc(100% - ${n}px)` : void 0,
40
+ overflow: "hidden",
41
+ overflowX: "hidden",
42
+ overflowY: "hidden"
43
+ },
44
+ { element: t }
45
+ )
46
+ ), !s.test(i)) {
47
+ const e = `${i} ${l}`;
48
+ t.className = e.trim();
49
+ }
50
+ o = [...o, { target: this.lockTarget, options: this.options }];
51
+ };
52
+ unLock = () => {
53
+ const n = o.find(({ target: e }) => e === this.lockTarget);
54
+ if (o = o.filter(({ target: e }) => e !== this.lockTarget), !n || o.some(
55
+ ({ options: e }) => e?.container === n.options?.container
56
+ ))
57
+ return;
58
+ const t = this.options?.container || document.body, i = t.className;
59
+ s.test(i) && (r(c.get(t), { element: t }), c.delete(t), t.className = t.className.replace(s, "").trim());
60
+ };
78
61
  }
79
62
  export {
80
- T as default
63
+ g as default
81
64
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(o){var t;return(t=o==null?void 0:o.getRootNode)==null?void 0:t.call(o)}function r(o){return n(o)instanceof ShadowRoot}function u(o){return r(o)?n(o):null}exports.getShadowRoot=u;exports.inShadow=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(o){return o?.getRootNode?.()}function n(o){return t(o)instanceof ShadowRoot}function e(o){return n(o)?t(o):null}exports.getShadowRoot=e;exports.inShadow=n;
@@ -1,14 +1,13 @@
1
- function n(o) {
2
- var t;
3
- return (t = o == null ? void 0 : o.getRootNode) == null ? void 0 : t.call(o);
1
+ function t(o) {
2
+ return o?.getRootNode?.();
4
3
  }
5
- function r(o) {
6
- return n(o) instanceof ShadowRoot;
4
+ function n(o) {
5
+ return t(o) instanceof ShadowRoot;
7
6
  }
8
- function u(o) {
9
- return r(o) ? n(o) : null;
7
+ function e(o) {
8
+ return n(o) ? t(o) : null;
10
9
  }
11
10
  export {
12
- u as getShadowRoot,
13
- r as inShadow
11
+ e as getShadowRoot,
12
+ n as inShadow
14
13
  };
package/dist/Portal.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),f=require("./Dom/canUseDom.cjs"),v=t.defineComponent((u,i)=>{var r;const a=t.shallowRef(),n=t.shallowRef(),o=t.shallowRef(!1);return!o.value&&f.default()&&(n.value=u.getContainer(),a.value=(r=n.value)==null?void 0:r.parentNode,o.value=!0),t.onMounted(()=>{var e;((e=n.value)==null?void 0:e.parentNode)===null&&a.value!==null&&a.value.appendChild(n.value)}),t.onBeforeUnmount(()=>{var e;(e=u.didUpdate)==null||e.call(u,u)}),t.onUnmounted(()=>{var e,l,d;(d=(l=(e=n.value)==null?void 0:e.parentNode)==null?void 0:l.removeChild)==null||d.call(l,n.value)}),()=>n.value?t.createVNode(t.Teleport,{to:n.value},{default:()=>{var e,l;return[(l=(e=i.slots).default)==null?void 0:l.call(e)]}}):null},{props:{didUpdate:{type:Function,required:!1},getContainer:{type:Function,required:!0}},inheritAttrs:!1});exports.default=v;
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 l=e.shallowRef(),t=e.shallowRef(),u=e.shallowRef(!1);return!u.value&&o.default()&&(t.value=n.getContainer(),l.value=t.value?.parentNode,u.value=!0),e.onMounted(()=>{t.value?.parentNode===null&&l.value!==null&&l.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},getContainer:{type:Function,required:!0}},inheritAttrs:!1});exports.default=r;
package/dist/Portal.js CHANGED
@@ -1,24 +1,17 @@
1
- import { defineComponent as f, shallowRef as u, onMounted as v, onBeforeUnmount as c, onUnmounted as m, createVNode as s, Teleport as p } from "vue";
2
- import C from "./Dom/canUseDom.js";
3
- const N = /* @__PURE__ */ f((a, i) => {
4
- var r;
5
- const l = u(), t = u(), o = u(!1);
6
- return !o.value && C() && (t.value = a.getContainer(), l.value = (r = t.value) == null ? void 0 : r.parentNode, o.value = !0), v(() => {
7
- var e;
8
- ((e = t.value) == null ? void 0 : e.parentNode) === null && l.value !== null && l.value.appendChild(t.value);
9
- }), c(() => {
10
- var e;
11
- (e = a.didUpdate) == null || e.call(a, a);
12
- }), m(() => {
13
- var e, n, d;
14
- (d = (n = (e = t.value) == null ? void 0 : e.parentNode) == null ? void 0 : n.removeChild) == null || d.call(n, t.value);
15
- }), () => t.value ? s(p, {
16
- to: t.value
1
+ import { defineComponent as u, 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__ */ u((t, l) => {
4
+ const n = a(), e = a(), o = a(!1);
5
+ return !o.value && p() && (e.value = t.getContainer(), n.value = e.value?.parentNode, o.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
17
13
  }, {
18
- default: () => {
19
- var e, n;
20
- return [(n = (e = i.slots).default) == null ? void 0 : n.call(e)];
21
- }
14
+ default: () => [l.slots.default?.()]
22
15
  }) : null;
23
16
  }, {
24
17
  props: {
@@ -34,5 +27,5 @@ const N = /* @__PURE__ */ f((a, i) => {
34
27
  inheritAttrs: !1
35
28
  });
36
29
  export {
37
- N as default
30
+ m as default
38
31
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),q=require("./raf.cjs"),O=require("./Dom/canUseDom.cjs"),R=require("./Dom/scrollLocker.cjs"),N=require("./setStyle.cjs"),k=require("./Portal.cjs");let l=0;const f=O.default();function S(){return process.env.NODE_ENV==="test"?l:0}let s={};function c(e){if(!f)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,d)=>{const o=r.shallowRef(),C=r.shallowRef(),y=r.shallowRef(),g=r.shallowRef(),h=()=>{var t,n;(n=(t=o.value)==null?void 0:t.parentNode)==null||n.removeChild(o.value)},v=t=>{const{visible:n,getContainer:a}=t||{},{visible:i,getContainer:u}=e;i!==n&&f&&c(u)===document.body&&(i&&!n?l+=1:t&&(l-=1)),(typeof u=="function"&&typeof a=="function"?u.toString()!==a.toString():u!==a)&&h()},p=(t=!1)=>{if(t||o.value&&!o.value.parentNode){const n=c(e.getContainer);return n?(n.appendChild(o.value),!0):!1}return!0},w=()=>{const{wrapperClassName:t}=e;o.value&&t&&t!==o.value.className&&(o.value.className=t)},b=()=>f?(o.value||(o.value=document.createElement("div"),p(!0)),w(),o.value):null;r.onMounted(()=>{g.value=new R.default({container:c(e.getContainer)}),v(),p()||(y.value=q.default(()=>{}))}),r.onUpdated(()=>{v(e),v(e),w(),p()}),r.onBeforeUnmount(()=>{const{visible:t,getContainer:n}=e;f&&c(n)===document.body&&(l=t&&l?l-1:l),h(),q.default.cancel(y.value)});const m=()=>{l===1&&!Object.keys(s).length?(m(),s=N.default({overflow:"hidden",overflowX:"hidden",overflowY:"hidden"})):l||(N.default(s),s={},m())};return()=>{const{forceRender:t,visible:n}=e;let a=null;const i={getOpenCount:S,getContainer:b,switchScrollingEffect:m,scrollLocker:g.value};return(t||n||C.value)&&(a=r.createVNode(k.default,{getContainer:b,ref:C},{default:()=>{var u;return[(u=d==null?void 0:d.slots)==null?void 0:u.default(i)]}})),a}},{props:{visible:{type:Boolean,required:!1},getContainer:{type:[String,Function],required:!1,skipCheck:!0},wrapperClassName:{type:String,required:!1},forceRender:{type:Boolean,required:!1}}});exports.default=E;exports.getOpenCount=S;
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 f=O.default();function N(){return process.env.NODE_ENV==="test"?l:0}let c={};function s(e){if(!f)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&&f&&s(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=s(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=()=>f?(n.value||(n.value=document.createElement("div"),v(!0)),h(),n.value):null;r.onMounted(()=>{y.value=new R.default({container:s(e.getContainer)}),d(),v()||(C.value=b.default(()=>{}))}),r.onUpdated(()=>{d(e),d(e),h(),v()}),r.onBeforeUnmount(()=>{const{visible:t,getContainer:o}=e;f&&s(o)===document.body&&(l=t&&l?l-1:l),g(),b.default.cancel(C.value)});const p=()=>{l===1&&!Object.keys(c).length?(p(),c=q.default({overflow:"hidden",overflowX:"hidden",overflowY:"hidden"})):l||(q.default(c),c={},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},getContainer:{type:[String,Function],required:!1,skipCheck:!0},wrapperClassName:{type:String,required:!1},forceRender:{type:Boolean,required:!1}}});exports.default=E;exports.getOpenCount=N;
@@ -1,6 +1,5 @@
1
1
  import { SlotsType } from 'vue';
2
2
  import { default as ScrollLocker } from './Dom/scrollLocker';
3
-
4
3
  /**
5
4
  * @private
6
5
  */
@@ -21,8 +20,8 @@ export interface PortalWrapperProps {
21
20
  forceRender?: boolean;
22
21
  }
23
22
  declare const PortalWrapper: import('vue').DefineSetupFnComponent<PortalWrapperProps, any, DefaultSlotInfo, PortalWrapperProps & ({} | {
24
- [x: `on${Capitalize<any>}`]: ((...args: any[]) => any) | undefined;
23
+ [x: `on${Capitalize<any>}`]: (...args: any[]) => any;
25
24
  } | {
26
- [x: `on${Capitalize<string>}`]: ((...args: any[] | unknown[]) => any) | undefined;
25
+ [x: `on${Capitalize<string>}`]: (...args: any[] | unknown[]) => any;
27
26
  }), import('vue').PublicProps>;
28
27
  export default PortalWrapper;
@@ -1,9 +1,9 @@
1
1
  import { defineComponent as k, shallowRef as u, onMounted as q, onUpdated as E, onBeforeUnmount as O, createVNode as R } from "vue";
2
- import N from "./raf.js";
3
2
  import L from "./Dom/canUseDom.js";
4
3
  import P from "./Dom/scrollLocker.js";
5
- import S from "./setStyle.js";
6
4
  import B from "./Portal.js";
5
+ import b from "./raf.js";
6
+ import N from "./setStyle.js";
7
7
  let r = 0;
8
8
  const s = L();
9
9
  function D() {
@@ -15,77 +15,74 @@ function f(e) {
15
15
  if (e) {
16
16
  if (typeof e == "string") return document.querySelectorAll(e)[0];
17
17
  if (typeof e == "function") return e();
18
- if (typeof e == "object" && e instanceof window.HTMLElement) return e;
18
+ if (typeof e == "object" && e instanceof window.HTMLElement)
19
+ return e;
19
20
  }
20
21
  return document.body;
21
22
  }
22
- const W = /* @__PURE__ */ k((e, d) => {
23
- const o = u(), C = u(), y = u(), g = u(), h = () => {
24
- var t, n;
25
- (n = (t = o.value) == null ? void 0 : t.parentNode) == null || n.removeChild(o.value);
26
- }, p = (t) => {
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
27
  const {
28
- visible: n,
29
- getContainer: a
30
- } = t || {}, {
31
- visible: i,
28
+ visible: o,
32
29
  getContainer: l
30
+ } = t || {}, {
31
+ visible: a,
32
+ getContainer: i
33
33
  } = e;
34
- i !== n && s && f(l) === document.body && (i && !n ? r += 1 : t && (r -= 1)), (typeof l == "function" && typeof a == "function" ? l.toString() !== a.toString() : l !== a) && h();
35
- }, m = (t = !1) => {
36
- if (t || o.value && !o.value.parentNode) {
37
- const n = f(e.getContainer);
38
- return n ? (n.appendChild(o.value), !0) : !1;
34
+ a !== o && s && f(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 = f(e.getContainer);
38
+ return o ? (o.appendChild(n.value), !0) : !1;
39
39
  }
40
40
  return !0;
41
- }, w = () => {
41
+ }, h = () => {
42
42
  const {
43
43
  wrapperClassName: t
44
44
  } = e;
45
- o.value && t && t !== o.value.className && (o.value.className = t);
46
- }, b = () => s ? (o.value || (o.value = document.createElement("div"), m(!0)), w(), o.value) : null;
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
47
  q(() => {
48
- g.value = new P({
48
+ y.value = new P({
49
49
  container: f(e.getContainer)
50
- }), p(), m() || (y.value = N(() => {
50
+ }), d(), p() || (C.value = b(() => {
51
51
  }));
52
52
  }), E(() => {
53
- p(e), p(e), w(), m();
53
+ d(e), d(e), h(), p();
54
54
  }), O(() => {
55
55
  const {
56
56
  visible: t,
57
- getContainer: n
57
+ getContainer: o
58
58
  } = e;
59
- s && f(n) === document.body && (r = t && r ? r - 1 : r), h(), N.cancel(y.value);
59
+ s && f(o) === document.body && (r = t && r ? r - 1 : r), g(), b.cancel(C.value);
60
60
  });
61
- const v = () => {
62
- r === 1 && !Object.keys(c).length ? (v(), c = S({
61
+ const m = () => {
62
+ r === 1 && !Object.keys(c).length ? (m(), c = N({
63
63
  overflow: "hidden",
64
64
  overflowX: "hidden",
65
65
  overflowY: "hidden"
66
- })) : r || (S(c), c = {}, v());
66
+ })) : r || (N(c), c = {}, m());
67
67
  };
68
68
  return () => {
69
69
  const {
70
70
  forceRender: t,
71
- visible: n
71
+ visible: o
72
72
  } = e;
73
- let a = null;
74
- const i = {
73
+ let l = null;
74
+ const a = {
75
75
  getOpenCount: D,
76
- getContainer: b,
77
- switchScrollingEffect: v,
78
- scrollLocker: g.value
76
+ getContainer: w,
77
+ switchScrollingEffect: m,
78
+ scrollLocker: y.value
79
79
  };
80
- return (t || n || C.value) && (a = R(B, {
81
- getContainer: b,
82
- ref: C
80
+ return (t || o || v.value) && (l = R(B, {
81
+ getContainer: w,
82
+ ref: v
83
83
  }, {
84
- default: () => {
85
- var l;
86
- return [(l = d == null ? void 0 : d.slots) == null ? void 0 : l.default(i)];
87
- }
88
- })), a;
84
+ default: () => [S?.slots?.default(a)]
85
+ })), l;
89
86
  };
90
87
  }, {
91
88
  props: {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function o(e,t,d){const c={...e,...d?t:{}};return Object.keys(t).forEach(u=>{const f=t[u];typeof f=="function"&&(c[u]=(...l)=>{var n;return f(...l),(n=e[u])==null?void 0:n.call(e,...l)})}),c}exports.default=o;
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,16 +1,13 @@
1
- function b(t, c, m) {
2
- const f = {
1
+ function s(t, o, u) {
2
+ const c = {
3
3
  ...t,
4
- ...m ? c : {}
4
+ ...u ? o : {}
5
5
  };
6
- return Object.keys(c).forEach((e) => {
7
- const u = c[e];
8
- typeof u == "function" && (f[e] = (...n) => {
9
- var d;
10
- return u(...n), (d = t[e]) == null ? void 0 : d.call(t, ...n);
11
- });
12
- }), f;
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;
13
10
  }
14
11
  export {
15
- b as default
12
+ s as default
16
13
  };
@@ -1,5 +1,4 @@
1
1
  import { Ref } from 'vue';
2
-
3
2
  export interface RefObject extends Function {
4
3
  current?: any;
5
4
  }
@@ -1 +1 @@
1
- export default function diff(obj1: any, obj2: any, depth?: number, path?: never[], diffList?: any[]): any[];
1
+ export default function diff(obj1: any, obj2: any, depth?: number, path?: any[], diffList?: any[]): any[];