@v-c/trigger 0.0.9 → 0.0.10

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Ae=require("@v-c/util/dist/Dom/findDOMNode"),Re=require("@v-c/util/dist/Dom/isVisible"),Pe=require("@v-c/util/dist/raf"),f=require("vue"),V=require("../util.cjs");function Mt(o,a=0){const c=`${a}`,u=c.match(/^(.*)\%$/);return u?o*(parseFloat(u[1])/100):parseFloat(c)}function Bt(o,a){const[c,u]=a||[];return[Mt(o.width,c),Mt(o.height,u)]}function Ot(o=""){return[o[0],o[1]]}function T(o,a){const c=a[0],u=a[1];let y,P;return c==="t"?P=o.y:c==="b"?P=o.y+o.height:P=o.y+o.height/2,u==="l"?y=o.x:u==="r"?y=o.x+o.width:y=o.x+o.width/2,{x:y,y:P}}function w(o,a){const c={t:"b",b:"t",l:"r",r:"l"};return o.map((u,y)=>y===a?c[u]||"c":u).join("")}function Xe(o,a,c,u,y,P,Vt,D){const g=f.ref({ready:!1,offsetX:0,offsetY:0,offsetR:0,offsetB:0,arrowX:0,arrowY:0,scaleX:1,scaleY:1,align:y.value[u.value]||{}}),E=f.shallowRef(0),J=f.computed(()=>!a.value||D?.value?[]:V.collectScroller(a.value)),h=f.ref({}),Tt=()=>{h.value={}},Ct=()=>{if(a.value&&c.value&&o.value&&!D?.value){let p=function(t,v,m=rt){const Xt=s.x+t,Yt=s.y+v,de=Xt+Y,ve=Yt+X,ye=Math.max(Xt,m.left),xe=Math.max(Yt,m.top),be=Math.min(de,m.right),we=Math.min(ve,m.bottom);return Math.max(0,(be-ye)*(we-xe))},Z=function(){N=s.y+r,H=N+X,F=s.x+l,k=F+Y};const e=a.value,tt=e.ownerDocument,et=V.getWin(e),{position:It}=et.getComputedStyle(e),St=e.style.left,Nt=e.style.top,Ft=e.style.right,jt=e.style.bottom,Wt=e.style.overflow,C={...y.value[u.value],...P?.value},A=tt.createElement("div");e.parentElement?.appendChild(A),A.style.left=`${e.offsetLeft}px`,A.style.top=`${e.offsetTop}px`,A.style.position=It,A.style.height=`${e.offsetHeight}px`,A.style.width=`${e.offsetWidth}px`,e.style.left="0",e.style.top="0",e.style.right="auto",e.style.bottom="auto",e.style.overflow="hidden";let i;if(Array.isArray(c.value))i={x:c.value[0],y:c.value[1],width:0,height:0};else{const t=c.value.getBoundingClientRect();t.x=t.x??t.left,t.y=t.y??t.top,i={x:t.x,y:t.y,width:t.width,height:t.height}}const s=e.getBoundingClientRect(),{height:$t,width:qt}=et.getComputedStyle(e);s.x=s.x??s.left,s.y=s.y??s.top;const{clientWidth:Ht,clientHeight:kt,scrollWidth:Dt,scrollHeight:Et,scrollTop:ot,scrollLeft:nt}=tt.documentElement,X=s.height,Y=s.width,L=i.height,I=i.width,_t={left:0,top:0,right:Ht,bottom:kt},Ut={left:-nt,top:-ot,right:Dt-nt,bottom:Et-ot};let{htmlRegion:S}=C;const st="visible",it="visibleFirst";S!=="scroll"&&S!==it&&(S=st);const lt=S===it,zt=V.getVisibleArea(Ut,J.value),n=V.getVisibleArea(_t,J.value),rt=S===st?n:zt,$=lt?n:rt;e.style.left="auto",e.style.top="auto",e.style.right="0",e.style.bottom="0";const ft=e.getBoundingClientRect();e.style.left=St,e.style.top=Nt,e.style.right=Ft,e.style.bottom=jt,e.style.overflow=Wt,e.parentElement?.removeChild(A);const M=V.toNum(Math.round(Y/parseFloat(qt)*1e3)/1e3),B=V.toNum(Math.round(X/parseFloat($t)*1e3)/1e3);if(M===0||B===0||Ae.isDOM(c)&&!Re(c))return;const{offset:Gt,targetOffset:Jt}=C;let[x,b]=Bt(s,Gt);const[Kt,Qt]=Bt(i,Jt);i.x-=Kt,i.y-=Qt;const[Zt,te]=C.points||[],R=Ot(te),d=Ot(Zt),ct=T(i,R),at=T(s,d),O={...C};let l=ct.x-at.x+x,r=ct.y-at.y+b;const ut=p(l,r),ee=p(l,r,n),q=(t,v)=>!!(t>ut||lt&&t===ut&&v>=ee),pt=T(i,["t","l"]),ht=T(s,["t","l"]),gt=T(i,["b","r"]),mt=T(s,["b","r"]),oe=C.overflow||{},{adjustX:ne,adjustY:se,shiftX:dt,shiftY:vt}=oe,yt=t=>typeof t=="boolean"?t:t>=0;let N,H,F,k;Z();const xt=yt(se),bt=d[0]===R[0];if(xt&&d[0]==="t"&&(H>$.bottom||h.value.bt)){let t=r;bt?t-=X-L:t=pt.y-mt.y-b;const v=p(l,t),m=p(l,t,n);q(v,m)?(h.value.bt=!0,r=t,b=-b,O.points=[w(d,0),w(R,0)]):h.value.bt=!1}if(xt&&d[0]==="b"&&(N<$.top||h.value.tb)){let t=r;bt?t+=X-L:t=gt.y-ht.y-b;const v=p(l,t),m=p(l,t,n);q(v,m)?(h.value.tb=!0,r=t,b=-b,O.points=[w(d,0),w(R,0)]):h.value.tb=!1}const wt=yt(ne),At=d[1]===R[1];if(wt&&d[1]==="l"&&(k>$.right||h.value.rl)){let t=l;At?t-=Y-I:t=pt.x-mt.x-x;const v=p(t,r),m=p(t,r,n);q(v,m)?(h.value.rl=!0,l=t,x=-x,O.points=[w(d,1),w(R,1)]):h.value.rl=!1}if(wt&&d[1]==="r"&&(F<$.left||h.value.lr)){let t=l;At?t+=Y-I:t=gt.x-ht.x-x;const v=p(t,r),m=p(t,r,n);q(v,m)?(h.value.lr=!0,l=t,x=-x,O.points=[w(d,1),w(R,1)]):h.value.lr=!1}Z();const j=dt===!0?0:dt;typeof j=="number"&&(F<n.left&&(l-=F-n.left-x,i.x+I<n.left+j&&(l+=i.x-n.left+I-j)),k>n.right&&(l-=k-n.right-x,i.x>n.right-j&&(l+=i.x-n.right+j)));const W=vt===!0?0:vt;typeof W=="number"&&(N<n.top&&(r-=N-n.top-b,i.y+L<n.top+W&&(r+=i.y-n.top+L-W)),H>n.bottom&&(r-=H-n.bottom-b,i.y>n.bottom-W&&(r+=i.y-n.bottom+W)));const _=s.x+l,ie=_+Y,U=s.y+r,le=U+X,Rt=i.x,re=Rt+I,Pt=i.y,fe=Pt+L,ce=Math.max(_,Rt),ae=Math.min(ie,re),ue=(ce+ae)/2-_,pe=Math.max(U,Pt),he=Math.min(le,fe),ge=(pe+he)/2-U;Vt?.(a.value,O);let z=ft.right-s.x-(l+s.width),G=ft.bottom-s.y-(r+s.height);M===1&&(l=Math.round(l),z=Math.round(z)),B===1&&(r=Math.round(r),G=Math.round(G));const me={ready:!0,offsetX:l/M,offsetY:r/B,offsetR:z/M,offsetB:G/B,arrowX:ue/M,arrowY:ge/B,scaleX:M,scaleY:B,align:O};g.value=me}},Lt=Pe.rafDebounce(Ct),K=()=>{E.value+=1;const p=E.value;Promise.resolve().then(()=>{E.value===p&&Lt()})};f.watch(a,async p=>{p&&o.value&&!D?.value&&(await f.nextTick(),K())});const Q=()=>{g.value.ready=!1};return f.watch(u,async()=>{await f.nextTick(),Q()}),f.watchEffect(async()=>{await f.nextTick(),o.value||(Tt(),Q())}),[f.computed(()=>g.value?.ready),f.computed(()=>g.value?.offsetX),f.computed(()=>g.value?.offsetY),f.computed(()=>g.value?.offsetR),f.computed(()=>g.value?.offsetB),f.computed(()=>g.value?.arrowX),f.computed(()=>g.value?.arrowY),f.computed(()=>g.value?.scaleX),f.computed(()=>g.value?.scaleY),f.computed(()=>g.value?.align),K]}exports.default=Xe;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const we=require("@v-c/util/dist/Dom/findDOMNode"),Ae=require("@v-c/util/dist/Dom/isVisible"),Re=require("@v-c/util/dist/raf"),f=require("vue"),C=require("../util.cjs");function Pt(o,a=0){const c=`${a}`,u=c.match(/^(.*)\%$/);return u?o*(parseFloat(u[1])/100):parseFloat(c)}function Bt(o,a){const[c,u]=a||[];return[Pt(o.width,c),Pt(o.height,u)]}function Ot(o=""){return[o[0],o[1]]}function L(o,a){const c=a[0],u=a[1];let y,Y;return c==="t"?Y=o.y:c==="b"?Y=o.y+o.height:Y=o.y+o.height/2,u==="l"?y=o.x:u==="r"?y=o.x+o.width:y=o.x+o.width/2,{x:y,y:Y}}function A(o,a){const c={t:"b",b:"t",l:"r",r:"l"};return o.map((u,y)=>y===a?c[u]||"c":u).join("")}function Xe(o,a,c,u,y,Y,Vt,k){const m=f.ref({ready:!1,offsetX:0,offsetY:0,offsetR:0,offsetB:0,arrowX:0,arrowY:0,scaleX:1,scaleY:1,align:y.value[u.value]||{}}),U=f.shallowRef(0),Q=f.computed(()=>!a.value||k?.value?[]:C.collectScroller(a.value)),h=f.ref({}),Ct=()=>{h.value={}},Lt=()=>{if(a.value&&c.value&&o.value&&!k?.value){let p=function(t,g,v=ft){const Yt=n.x+t,Mt=n.y+g,me=Yt+P,ve=Mt+M,de=Math.max(Yt,v.left),ye=Math.max(Mt,v.top),xe=Math.min(me,v.right),be=Math.min(ve,v.bottom);return Math.max(0,(xe-de)*(be-ye))},et=function(){j=n.y+r,E=j+M,W=n.x+l,_=W+P};const e=a.value,ot=e.ownerDocument,st=C.getWin(e),{position:It}=st.getComputedStyle(e),St=e.style.left,Ft=e.style.top,Nt=e.style.right,jt=e.style.bottom,Wt=e.style.overflow,T={...y.value[u.value],...Y?.value},R=ot.createElement("div");e.parentElement?.appendChild(R),R.style.left=`${e.offsetLeft}px`,R.style.top=`${e.offsetTop}px`,R.style.position=It,R.style.height=`${e.offsetHeight}px`,R.style.width=`${e.offsetWidth}px`,e.style.left="0",e.style.top="0",e.style.right="auto",e.style.bottom="auto",e.style.overflow="hidden";let i;if(Array.isArray(c.value))i={x:c.value[0],y:c.value[1],width:0,height:0};else{const t=c.value.getBoundingClientRect();t.x=t.x??t.left,t.y=t.y??t.top,i={x:t.x,y:t.y,width:t.width,height:t.height}}const n=e.getBoundingClientRect(),{height:$t,width:qt}=st.getComputedStyle(e);n.x=n.x??n.left,n.y=n.y??n.top;const{clientWidth:Ht,clientHeight:Dt,scrollWidth:Et,scrollHeight:_t,scrollTop:nt,scrollLeft:it}=ot.documentElement,M=n.height,P=n.width,I=i.height,S=i.width,kt={left:0,top:0,right:Ht,bottom:Dt},Ut={left:-it,top:-nt,right:Et-it,bottom:_t-nt};let{htmlRegion:F}=T;const lt="visible",rt="visibleFirst";F!=="scroll"&&F!==rt&&(F=lt);const N=F===rt,zt=C.getVisibleArea(Ut,Q.value),s=C.getVisibleArea(kt,Q.value),ft=F===lt?s:zt,H=N?s:ft;e.style.left="auto",e.style.top="auto",e.style.right="0",e.style.bottom="0";const ct=e.getBoundingClientRect();e.style.left=St,e.style.top=Ft,e.style.right=Nt,e.style.bottom=jt,e.style.overflow=Wt,e.parentElement?.removeChild(R);const B=C.toNum(Math.round(P/parseFloat(qt)*1e3)/1e3),O=C.toNum(Math.round(M/parseFloat($t)*1e3)/1e3);if(B===0||O===0||we.isDOM(c)&&!Ae(c))return;const{offset:Gt,targetOffset:Jt}=T;let[x,b]=Bt(n,Gt);const[Kt,Qt]=Bt(i,Jt);i.x-=Kt,i.y-=Qt;const[Zt,te]=T.points||[],X=Ot(te),d=Ot(Zt),at=L(i,X),ut=L(n,d),V={...T};let l=at.x-ut.x+x,r=at.y-ut.y+b;const w=p(l,r),D=p(l,r,s),pt=L(i,["t","l"]),ht=L(n,["t","l"]),gt=L(i,["b","r"]),mt=L(n,["b","r"]),ee=T.overflow||{},{adjustX:oe,adjustY:se,shiftX:vt,shiftY:dt}=ee,yt=t=>typeof t=="boolean"?t:t>=0;let j,E,W,_;et();const xt=yt(se),bt=d[0]===X[0];if(xt&&d[0]==="t"&&(E>H.bottom||h.value.bt)){let t=r;bt?t-=M-I:t=pt.y-mt.y-b;const g=p(l,t),v=p(l,t,s);g>w||g===w&&(!N||v>=D)?(h.value.bt=!0,r=t,b=-b,V.points=[A(d,0),A(X,0)]):h.value.bt=!1}if(xt&&d[0]==="b"&&(j<H.top||h.value.tb)){let t=r;bt?t+=M-I:t=gt.y-ht.y-b;const g=p(l,t),v=p(l,t,s);g>w||g===w&&(!N||v>=D)?(h.value.tb=!0,r=t,b=-b,V.points=[A(d,0),A(X,0)]):h.value.tb=!1}const wt=yt(oe),At=d[1]===X[1];if(wt&&d[1]==="l"&&(_>H.right||h.value.rl)){let t=l;At?t-=P-S:t=pt.x-mt.x-x;const g=p(t,r),v=p(t,r,s);g>w||g===w&&(!N||v>=D)?(h.value.rl=!0,l=t,x=-x,V.points=[A(d,1),A(X,1)]):h.value.rl=!1}if(wt&&d[1]==="r"&&(W<H.left||h.value.lr)){let t=l;At?t+=P-S:t=gt.x-ht.x-x;const g=p(t,r),v=p(t,r,s);g>w||g===w&&(!N||v>=D)?(h.value.lr=!0,l=t,x=-x,V.points=[A(d,1),A(X,1)]):h.value.lr=!1}et();const $=vt===!0?0:vt;typeof $=="number"&&(W<s.left&&(l-=W-s.left-x,i.x+S<s.left+$&&(l+=i.x-s.left+S-$)),_>s.right&&(l-=_-s.right-x,i.x>s.right-$&&(l+=i.x-s.right+$)));const q=dt===!0?0:dt;typeof q=="number"&&(j<s.top&&(r-=j-s.top-b,i.y+I<s.top+q&&(r+=i.y-s.top+I-q)),E>s.bottom&&(r-=E-s.bottom-b,i.y>s.bottom-q&&(r+=i.y-s.bottom+q)));const z=n.x+l,ne=z+P,G=n.y+r,ie=G+M,Rt=i.x,le=Rt+S,Xt=i.y,re=Xt+I,fe=Math.max(z,Rt),ce=Math.min(ne,le),ae=(fe+ce)/2-z,ue=Math.max(G,Xt),pe=Math.min(ie,re),he=(ue+pe)/2-G;Vt?.(a.value,V);let J=ct.right-n.x-(l+n.width),K=ct.bottom-n.y-(r+n.height);B===1&&(l=Math.round(l),J=Math.round(J)),O===1&&(r=Math.round(r),K=Math.round(K));const ge={ready:!0,offsetX:l/B,offsetY:r/O,offsetR:J/B,offsetB:K/O,arrowX:ae/B,arrowY:he/O,scaleX:B,scaleY:O,align:V};m.value=ge}},Tt=Re.rafDebounce(Lt),Z=()=>{U.value+=1;const p=U.value;Promise.resolve().then(()=>{U.value===p&&Tt()})};f.watch(a,async p=>{p&&o.value&&!k?.value&&(await f.nextTick(),Z())});const tt=()=>{m.value.ready=!1};return f.watch(u,()=>{tt()}),f.watchEffect(()=>{o.value||(Ct(),tt())}),[f.computed(()=>m.value?.ready),f.computed(()=>m.value?.offsetX),f.computed(()=>m.value?.offsetY),f.computed(()=>m.value?.offsetR),f.computed(()=>m.value?.offsetB),f.computed(()=>m.value?.arrowX),f.computed(()=>m.value?.arrowY),f.computed(()=>m.value?.scaleX),f.computed(()=>m.value?.scaleY),f.computed(()=>m.value?.align),Z]}exports.default=Xe;
@@ -1,28 +1,28 @@
1
- import { isDOM as Ye } from "@v-c/util/dist/Dom/findDOMNode";
2
- import Pe from "@v-c/util/dist/Dom/isVisible";
3
- import { rafDebounce as Be } from "@v-c/util/dist/raf";
4
- import { ref as Bt, shallowRef as Me, computed as y, watch as Mt, nextTick as G, watchEffect as Oe } from "vue";
5
- import { collectScroller as Ve, getWin as Ce, getVisibleArea as Ot, toNum as Vt } from "../util.js";
6
- function Ct(o, a = 0) {
1
+ import { isDOM as Re } from "@v-c/util/dist/Dom/findDOMNode";
2
+ import Xe from "@v-c/util/dist/Dom/isVisible";
3
+ import { rafDebounce as Ye } from "@v-c/util/dist/raf";
4
+ import { ref as Pt, shallowRef as Pe, computed as y, watch as Bt, nextTick as Be, watchEffect as Me } from "vue";
5
+ import { collectScroller as Oe, getWin as Ve, getVisibleArea as Mt, toNum as Ot } from "../util.js";
6
+ function Vt(o, a = 0) {
7
7
  const f = `${a}`, c = f.match(/^(.*)\%$/);
8
8
  return c ? o * (parseFloat(c[1]) / 100) : parseFloat(f);
9
9
  }
10
- function Lt(o, a) {
10
+ function Ct(o, a) {
11
11
  const [f, c] = a || [];
12
12
  return [
13
- Ct(o.width, f),
14
- Ct(o.height, c)
13
+ Vt(o.width, f),
14
+ Vt(o.height, c)
15
15
  ];
16
16
  }
17
- function It(o = "") {
17
+ function Lt(o = "") {
18
18
  return [o[0], o[1]];
19
19
  }
20
- function V(o, a) {
20
+ function C(o, a) {
21
21
  const f = a[0], c = a[1];
22
- let d, X;
23
- return f === "t" ? X = o.y : f === "b" ? X = o.y + o.height : X = o.y + o.height / 2, c === "l" ? d = o.x : c === "r" ? d = o.x + o.width : d = o.x + o.width / 2, { x: d, y: X };
22
+ let d, Y;
23
+ return f === "t" ? Y = o.y : f === "b" ? Y = o.y + o.height : Y = o.y + o.height / 2, c === "l" ? d = o.x : c === "r" ? d = o.x + o.width : d = o.x + o.width / 2, { x: d, y: Y };
24
24
  }
25
- function w(o, a) {
25
+ function A(o, a) {
26
26
  const f = {
27
27
  t: "b",
28
28
  b: "t",
@@ -31,8 +31,8 @@ function w(o, a) {
31
31
  };
32
32
  return o.map((c, d) => d === a ? f[c] || "c" : c).join("");
33
33
  }
34
- function $e(o, a, f, c, d, X, Tt, D) {
35
- const h = Bt({
34
+ function We(o, a, f, c, d, Y, It, k) {
35
+ const g = Pt({
36
36
  ready: !1,
37
37
  offsetX: 0,
38
38
  offsetY: 0,
@@ -43,21 +43,21 @@ function $e(o, a, f, c, d, X, Tt, D) {
43
43
  scaleX: 1,
44
44
  scaleY: 1,
45
45
  align: d.value[c.value] || {}
46
- }), _ = Me(0), J = y(() => !a.value || D?.value ? [] : Ve(a.value)), p = Bt({}), Ft = () => {
46
+ }), U = Pe(0), K = y(() => !a.value || k?.value ? [] : Oe(a.value)), p = Pt({}), Tt = () => {
47
47
  p.value = {};
48
- }, St = Be(() => {
49
- if (a.value && f.value && o.value && !D?.value) {
50
- let u = function(t, v, g = rt) {
51
- const Yt = s.x + t, Pt = s.y + v, xe = Yt + P, be = Pt + Y, we = Math.max(Yt, g.left), Ae = Math.max(Pt, g.top), Re = Math.min(xe, g.right), Xe = Math.min(be, g.bottom);
52
- return Math.max(0, (Re - we) * (Xe - Ae));
53
- }, Z = function() {
54
- F = s.y + r, H = F + Y, S = s.x + l, E = S + P;
48
+ }, Ft = Ye(() => {
49
+ if (a.value && f.value && o.value && !k?.value) {
50
+ let u = function(t, h, m = rt) {
51
+ const Xt = s.x + t, Yt = s.y + h, ye = Xt + B, de = Yt + P, xe = Math.max(Xt, m.left), be = Math.max(Yt, m.top), we = Math.min(ye, m.right), Ae = Math.min(de, m.bottom);
52
+ return Math.max(0, (we - xe) * (Ae - be));
53
+ }, tt = function() {
54
+ j = s.y + r, D = j + P, N = s.x + l, _ = N + B;
55
55
  };
56
- const e = a.value, tt = e.ownerDocument, et = Ce(e), { position: Nt } = et.getComputedStyle(e), jt = e.style.left, Wt = e.style.top, $t = e.style.right, Ht = e.style.bottom, Et = e.style.overflow, C = {
56
+ const e = a.value, et = e.ownerDocument, ot = Ve(e), { position: St } = ot.getComputedStyle(e), jt = e.style.left, Nt = e.style.top, Wt = e.style.right, $t = e.style.bottom, Ht = e.style.overflow, L = {
57
57
  ...d.value[c.value],
58
- ...X?.value
59
- }, A = tt.createElement("div");
60
- e.parentElement?.appendChild(A), A.style.left = `${e.offsetLeft}px`, A.style.top = `${e.offsetTop}px`, A.style.position = Nt, A.style.height = `${e.offsetHeight}px`, A.style.width = `${e.offsetWidth}px`, e.style.left = "0", e.style.top = "0", e.style.right = "auto", e.style.bottom = "auto", e.style.overflow = "hidden";
58
+ ...Y?.value
59
+ }, R = et.createElement("div");
60
+ e.parentElement?.appendChild(R), R.style.left = `${e.offsetLeft}px`, R.style.top = `${e.offsetTop}px`, R.style.position = St, R.style.height = `${e.offsetHeight}px`, R.style.width = `${e.offsetWidth}px`, e.style.left = "0", e.style.top = "0", e.style.right = "auto", e.style.bottom = "auto", e.style.overflow = "hidden";
61
61
  let i;
62
62
  if (Array.isArray(f.value))
63
63
  i = {
@@ -75,184 +75,188 @@ function $e(o, a, f, c, d, X, Tt, D) {
75
75
  height: t.height
76
76
  };
77
77
  }
78
- const s = e.getBoundingClientRect(), { height: Dt, width: _t } = et.getComputedStyle(e);
78
+ const s = e.getBoundingClientRect(), { height: Et, width: Dt } = ot.getComputedStyle(e);
79
79
  s.x = s.x ?? s.left, s.y = s.y ?? s.top;
80
80
  const {
81
- clientWidth: kt,
82
- clientHeight: Ut,
83
- scrollWidth: qt,
84
- scrollHeight: zt,
85
- scrollTop: ot,
86
- scrollLeft: nt
87
- } = tt.documentElement, Y = s.height, P = s.width, L = i.height, I = i.width, Gt = {
81
+ clientWidth: _t,
82
+ clientHeight: kt,
83
+ scrollWidth: Ut,
84
+ scrollHeight: qt,
85
+ scrollTop: nt,
86
+ scrollLeft: st
87
+ } = et.documentElement, P = s.height, B = s.width, I = i.height, T = i.width, zt = {
88
88
  left: 0,
89
89
  top: 0,
90
- right: kt,
91
- bottom: Ut
92
- }, Jt = {
93
- left: -nt,
94
- top: -ot,
95
- right: qt - nt,
96
- bottom: zt - ot
90
+ right: _t,
91
+ bottom: kt
92
+ }, Gt = {
93
+ left: -st,
94
+ top: -nt,
95
+ right: Ut - st,
96
+ bottom: qt - nt
97
97
  };
98
- let { htmlRegion: T } = C;
99
- const st = "visible", it = "visibleFirst";
100
- T !== "scroll" && T !== it && (T = st);
101
- const lt = T === it, Kt = Ot(Jt, J.value), n = Ot(Gt, J.value), rt = T === st ? n : Kt, W = lt ? n : rt;
98
+ let { htmlRegion: F } = L;
99
+ const it = "visible", lt = "visibleFirst";
100
+ F !== "scroll" && F !== lt && (F = it);
101
+ const S = F === lt, Jt = Mt(Gt, K.value), n = Mt(zt, K.value), rt = F === it ? n : Jt, H = S ? n : rt;
102
102
  e.style.left = "auto", e.style.top = "auto", e.style.right = "0", e.style.bottom = "0";
103
103
  const ft = e.getBoundingClientRect();
104
- e.style.left = jt, e.style.top = Wt, e.style.right = $t, e.style.bottom = Ht, e.style.overflow = Et, e.parentElement?.removeChild(A);
105
- const B = Vt(
106
- Math.round(P / parseFloat(_t) * 1e3) / 1e3
107
- ), M = Vt(
108
- Math.round(Y / parseFloat(Dt) * 1e3) / 1e3
104
+ e.style.left = jt, e.style.top = Nt, e.style.right = Wt, e.style.bottom = $t, e.style.overflow = Ht, e.parentElement?.removeChild(R);
105
+ const M = Ot(
106
+ Math.round(B / parseFloat(Dt) * 1e3) / 1e3
107
+ ), O = Ot(
108
+ Math.round(P / parseFloat(Et) * 1e3) / 1e3
109
109
  );
110
- if (B === 0 || M === 0 || Ye(f) && !Pe(f))
110
+ if (M === 0 || O === 0 || Re(f) && !Xe(f))
111
111
  return;
112
- const { offset: Qt, targetOffset: Zt } = C;
113
- let [x, b] = Lt(s, Qt);
114
- const [te, ee] = Lt(
112
+ const { offset: Kt, targetOffset: Qt } = L;
113
+ let [x, b] = Ct(s, Kt);
114
+ const [Zt, te] = Ct(
115
115
  i,
116
- Zt
116
+ Qt
117
117
  );
118
- i.x -= te, i.y -= ee;
119
- const [oe, ne] = C.points || [], R = It(ne), m = It(oe), at = V(i, R), ct = V(s, m), O = {
120
- ...C
118
+ i.x -= Zt, i.y -= te;
119
+ const [ee, oe] = L.points || [], X = Lt(oe), v = Lt(ee), at = C(i, X), ct = C(s, v), V = {
120
+ ...L
121
121
  };
122
122
  let l = at.x - ct.x + x, r = at.y - ct.y + b;
123
- const ut = u(
123
+ const w = u(
124
124
  l,
125
125
  r
126
- ), se = u(
126
+ ), E = u(
127
127
  l,
128
128
  r,
129
129
  n
130
- ), $ = (t, v) => !!(t > ut || lt && t === ut && v >= se), pt = V(i, ["t", "l"]), ht = V(s, ["t", "l"]), gt = V(i, ["b", "r"]), mt = V(s, ["b", "r"]), ie = C.overflow || {}, { adjustX: le, adjustY: re, shiftX: vt, shiftY: yt } = ie, dt = (t) => typeof t == "boolean" ? t : t >= 0;
131
- let F, H, S, E;
132
- Z();
133
- const xt = dt(re), bt = m[0] === R[0];
134
- if (xt && m[0] === "t" && (H > W.bottom || p.value.bt)) {
130
+ ), ut = C(i, ["t", "l"]), pt = C(s, ["t", "l"]), ht = C(i, ["b", "r"]), gt = C(s, ["b", "r"]), ne = L.overflow || {}, { adjustX: se, adjustY: ie, shiftX: mt, shiftY: vt } = ne, yt = (t) => typeof t == "boolean" ? t : t >= 0;
131
+ let j, D, N, _;
132
+ tt();
133
+ const dt = yt(ie), xt = v[0] === X[0];
134
+ if (dt && v[0] === "t" && (D > H.bottom || p.value.bt)) {
135
135
  let t = r;
136
- bt ? t -= Y - L : t = pt.y - mt.y - b;
137
- const v = u(
136
+ xt ? t -= P - I : t = ut.y - gt.y - b;
137
+ const h = u(
138
138
  l,
139
139
  t
140
- ), g = u(
140
+ ), m = u(
141
141
  l,
142
142
  t,
143
143
  n
144
144
  );
145
- $(v, g) ? (p.value.bt = !0, r = t, b = -b, O.points = [
146
- w(m, 0),
147
- w(R, 0)
145
+ // Of course use larger one
146
+ h > w || h === w && (!S || m >= E) ? (p.value.bt = !0, r = t, b = -b, V.points = [
147
+ A(v, 0),
148
+ A(X, 0)
148
149
  ]) : p.value.bt = !1;
149
150
  }
150
- if (xt && m[0] === "b" && (F < W.top || p.value.tb)) {
151
+ if (dt && v[0] === "b" && (j < H.top || p.value.tb)) {
151
152
  let t = r;
152
- bt ? t += Y - L : t = gt.y - ht.y - b;
153
- const v = u(
153
+ xt ? t += P - I : t = ht.y - pt.y - b;
154
+ const h = u(
154
155
  l,
155
156
  t
156
- ), g = u(
157
+ ), m = u(
157
158
  l,
158
159
  t,
159
160
  n
160
161
  );
161
- $(v, g) ? (p.value.tb = !0, r = t, b = -b, O.points = [
162
- w(m, 0),
163
- w(R, 0)
162
+ // Of course use larger one
163
+ h > w || h === w && (!S || m >= E) ? (p.value.tb = !0, r = t, b = -b, V.points = [
164
+ A(v, 0),
165
+ A(X, 0)
164
166
  ]) : p.value.tb = !1;
165
167
  }
166
- const wt = dt(le), At = m[1] === R[1];
167
- if (wt && m[1] === "l" && (E > W.right || p.value.rl)) {
168
+ const bt = yt(se), wt = v[1] === X[1];
169
+ if (bt && v[1] === "l" && (_ > H.right || p.value.rl)) {
168
170
  let t = l;
169
- At ? t -= P - I : t = pt.x - mt.x - x;
170
- const v = u(
171
+ wt ? t -= B - T : t = ut.x - gt.x - x;
172
+ const h = u(
171
173
  t,
172
174
  r
173
- ), g = u(
175
+ ), m = u(
174
176
  t,
175
177
  r,
176
178
  n
177
179
  );
178
- $(v, g) ? (p.value.rl = !0, l = t, x = -x, O.points = [
179
- w(m, 1),
180
- w(R, 1)
180
+ // Of course use larger one
181
+ h > w || h === w && (!S || m >= E) ? (p.value.rl = !0, l = t, x = -x, V.points = [
182
+ A(v, 1),
183
+ A(X, 1)
181
184
  ]) : p.value.rl = !1;
182
185
  }
183
- if (wt && m[1] === "r" && (S < W.left || p.value.lr)) {
186
+ if (bt && v[1] === "r" && (N < H.left || p.value.lr)) {
184
187
  let t = l;
185
- At ? t += P - I : t = gt.x - ht.x - x;
186
- const v = u(
188
+ wt ? t += B - T : t = ht.x - pt.x - x;
189
+ const h = u(
187
190
  t,
188
191
  r
189
- ), g = u(
192
+ ), m = u(
190
193
  t,
191
194
  r,
192
195
  n
193
196
  );
194
- $(v, g) ? (p.value.lr = !0, l = t, x = -x, O.points = [
195
- w(m, 1),
196
- w(R, 1)
197
+ // Of course use larger one
198
+ h > w || h === w && (!S || m >= E) ? (p.value.lr = !0, l = t, x = -x, V.points = [
199
+ A(v, 1),
200
+ A(X, 1)
197
201
  ]) : p.value.lr = !1;
198
202
  }
199
- Z();
200
- const N = vt === !0 ? 0 : vt;
201
- typeof N == "number" && (S < n.left && (l -= S - n.left - x, i.x + I < n.left + N && (l += i.x - n.left + I - N)), E > n.right && (l -= E - n.right - x, i.x > n.right - N && (l += i.x - n.right + N)));
202
- const j = yt === !0 ? 0 : yt;
203
- typeof j == "number" && (F < n.top && (r -= F - n.top - b, i.y + L < n.top + j && (r += i.y - n.top + L - j)), H > n.bottom && (r -= H - n.bottom - b, i.y > n.bottom - j && (r += i.y - n.bottom + j)));
204
- const k = s.x + l, fe = k + P, U = s.y + r, ae = U + Y, Rt = i.x, ce = Rt + I, Xt = i.y, ue = Xt + L, pe = Math.max(k, Rt), he = Math.min(fe, ce), ge = (pe + he) / 2 - k, me = Math.max(U, Xt), ve = Math.min(ae, ue), ye = (me + ve) / 2 - U;
205
- Tt?.(a.value, O);
206
- let q = ft.right - s.x - (l + s.width), z = ft.bottom - s.y - (r + s.height);
207
- B === 1 && (l = Math.round(l), q = Math.round(q)), M === 1 && (r = Math.round(r), z = Math.round(z));
208
- const de = {
203
+ tt();
204
+ const W = mt === !0 ? 0 : mt;
205
+ typeof W == "number" && (N < n.left && (l -= N - n.left - x, i.x + T < n.left + W && (l += i.x - n.left + T - W)), _ > n.right && (l -= _ - n.right - x, i.x > n.right - W && (l += i.x - n.right + W)));
206
+ const $ = vt === !0 ? 0 : vt;
207
+ typeof $ == "number" && (j < n.top && (r -= j - n.top - b, i.y + I < n.top + $ && (r += i.y - n.top + I - $)), D > n.bottom && (r -= D - n.bottom - b, i.y > n.bottom - $ && (r += i.y - n.bottom + $)));
208
+ const q = s.x + l, le = q + B, z = s.y + r, re = z + P, At = i.x, fe = At + T, Rt = i.y, ae = Rt + I, ce = Math.max(q, At), ue = Math.min(le, fe), pe = (ce + ue) / 2 - q, he = Math.max(z, Rt), ge = Math.min(re, ae), me = (he + ge) / 2 - z;
209
+ It?.(a.value, V);
210
+ let G = ft.right - s.x - (l + s.width), J = ft.bottom - s.y - (r + s.height);
211
+ M === 1 && (l = Math.round(l), G = Math.round(G)), O === 1 && (r = Math.round(r), J = Math.round(J));
212
+ const ve = {
209
213
  ready: !0,
210
- offsetX: l / B,
211
- offsetY: r / M,
212
- offsetR: q / B,
213
- offsetB: z / M,
214
- arrowX: ge / B,
215
- arrowY: ye / M,
216
- scaleX: B,
217
- scaleY: M,
218
- align: O
214
+ offsetX: l / M,
215
+ offsetY: r / O,
216
+ offsetR: G / M,
217
+ offsetB: J / O,
218
+ arrowX: pe / M,
219
+ arrowY: me / O,
220
+ scaleX: M,
221
+ scaleY: O,
222
+ align: V
219
223
  };
220
- h.value = de;
224
+ g.value = ve;
221
225
  }
222
- }), K = () => {
223
- _.value += 1;
224
- const u = _.value;
226
+ }), Q = () => {
227
+ U.value += 1;
228
+ const u = U.value;
225
229
  Promise.resolve().then(() => {
226
- _.value === u && St();
230
+ U.value === u && Ft();
227
231
  });
228
232
  };
229
- Mt(
233
+ Bt(
230
234
  a,
231
235
  async (u) => {
232
- u && o.value && !D?.value && (await G(), K());
236
+ u && o.value && !k?.value && (await Be(), Q());
233
237
  }
234
238
  );
235
- const Q = () => {
236
- h.value.ready = !1;
239
+ const Z = () => {
240
+ g.value.ready = !1;
237
241
  };
238
- return Mt(c, async () => {
239
- await G(), Q();
240
- }), Oe(async () => {
241
- await G(), o.value || (Ft(), Q());
242
+ return Bt(c, () => {
243
+ Z();
244
+ }), Me(() => {
245
+ o.value || (Tt(), Z());
242
246
  }), [
243
- y(() => h.value?.ready),
244
- y(() => h.value?.offsetX),
245
- y(() => h.value?.offsetY),
246
- y(() => h.value?.offsetR),
247
- y(() => h.value?.offsetB),
248
- y(() => h.value?.arrowX),
249
- y(() => h.value?.arrowY),
250
- y(() => h.value?.scaleX),
251
- y(() => h.value?.scaleY),
252
- y(() => h.value?.align),
253
- K
247
+ y(() => g.value?.ready),
248
+ y(() => g.value?.offsetX),
249
+ y(() => g.value?.offsetY),
250
+ y(() => g.value?.offsetR),
251
+ y(() => g.value?.offsetB),
252
+ y(() => g.value?.arrowX),
253
+ y(() => g.value?.arrowY),
254
+ y(() => g.value?.scaleX),
255
+ y(() => g.value?.scaleY),
256
+ y(() => g.value?.align),
257
+ Q
254
258
  ];
255
259
  }
256
260
  export {
257
- $e as default
261
+ We as default
258
262
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/trigger",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -37,6 +37,6 @@
37
37
  "build": "vite build",
38
38
  "test": "vitest",
39
39
  "prepublish": "pnpm build",
40
- "bump": "bumpp patch"
40
+ "bump": "bumpp --release patch"
41
41
  }
42
42
  }