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