@v-c/trigger 0.0.7 → 0.0.9

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,4 +1,4 @@
1
- import { CSSMotionProps } from '../../../util/src/utils/transition';
1
+ import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
2
2
  export interface MaskProps {
3
3
  prefixCls: string;
4
4
  open?: boolean;
@@ -1,5 +1,5 @@
1
- import { ResizeObserverProps } from '../../../resize-observer/src';
2
- import { CSSMotionProps } from '../../../util/src/utils/transition';
1
+ import { ResizeObserverProps } from '@v-c/resize-observer';
2
+ import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
3
3
  import { CSSProperties } from 'vue';
4
4
  import { TriggerProps } from '../index.tsx';
5
5
  import { AlignType, ArrowPos, ArrowTypeOuter } from '../interface.ts';
@@ -1,4 +1,4 @@
1
- import { CSSMotionProps } from '../../../util/src/utils/transition';
1
+ import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
2
2
  import { CSSProperties } from 'vue';
3
3
  import { AlignType, ArrowPos } from '../interface.ts';
4
4
  export interface UniqueContainerProps {
package/dist/context.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CSSMotionProps } from '../../util/src/utils/transition';
1
+ import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
2
2
  import { CSSProperties, InjectionKey, Ref } from 'vue';
3
3
  import { TriggerProps } from './index';
4
4
  import { AlignType, ArrowTypeOuter, BuildInPlacements } from './interface';
@@ -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 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,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 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) {
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 Lt(o, a) {
11
+ const [f, c] = a || [];
12
12
  return [
13
- Ot(o.width, f),
14
- Ot(o.height, a)
13
+ Ct(o.width, f),
14
+ Ct(o.height, c)
15
15
  ];
16
16
  }
17
- function Ct(o = "") {
17
+ function It(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 V(o, a) {
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 };
24
24
  }
25
- function b(o, c) {
25
+ function w(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 $e(o, a, f, c, d, X, Tt, D) {
35
+ const h = Bt({
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
+ }), _ = Me(0), J = y(() => !a.value || D?.value ? [] : Ve(a.value)), p = Bt({}), Ft = () => {
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));
53
- }, tt = function() {
54
- F = n.y + r, H = F + X, S = n.x + l, E = S + Y;
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;
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, 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 = {
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";
61
61
  let i;
62
62
  if (Array.isArray(f.value))
63
63
  i = {
@@ -75,190 +75,184 @@ 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: Dt, width: _t } = et.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,
81
+ clientWidth: kt,
82
+ clientHeight: Ut,
83
+ scrollWidth: qt,
84
+ scrollHeight: zt,
85
+ scrollTop: ot,
86
86
  scrollLeft: nt
87
- } = et.documentElement, X = n.height, Y = n.width, C = i.height, L = i.width, se = {
87
+ } = tt.documentElement, Y = s.height, P = s.width, L = i.height, I = i.width, Gt = {
88
88
  left: 0,
89
89
  top: 0,
90
- right: Zt,
91
- bottom: te
92
- }, ne = {
90
+ right: kt,
91
+ bottom: Ut
92
+ }, Jt = {
93
93
  left: -nt,
94
- top: -st,
95
- right: ee - nt,
96
- bottom: oe - st
94
+ top: -ot,
95
+ right: qt - nt,
96
+ bottom: zt - ot
97
97
  };
98
- let { htmlRegion: I } = V;
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;
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;
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 = 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
109
109
  );
110
- if (P === 0 || B === 0 || Le(f) && !Ie(f))
110
+ if (B === 0 || M === 0 || Ye(f) && !Pe(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: Qt, targetOffset: Zt } = C;
113
+ let [x, b] = Lt(s, Qt);
114
+ const [te, ee] = Lt(
115
115
  i,
116
- re
116
+ Zt
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 -= 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
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 ut = u(
124
124
  l,
125
125
  r
126
- ), $ = u(
126
+ ), se = 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;
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
131
  let F, H, S, E;
132
- tt();
133
- const dt = vt(ge), xt = m[0] === A[0];
134
- if (dt && m[0] === "t" && (H > W.bottom || p.value.bt)) {
132
+ Z();
133
+ const xt = dt(re), bt = m[0] === R[0];
134
+ if (xt && m[0] === "t" && (H > W.bottom || p.value.bt)) {
135
135
  let t = r;
136
- xt ? t -= X - C : t = ut.y - gt.y - d;
137
- const h = u(
136
+ bt ? t -= Y - L : t = pt.y - mt.y - b;
137
+ const v = u(
138
138
  l,
139
139
  t
140
140
  ), g = u(
141
141
  l,
142
142
  t,
143
- s
143
+ n
144
144
  );
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)
145
+ $(v, g) ? (p.value.bt = !0, r = t, b = -b, O.points = [
146
+ w(m, 0),
147
+ w(R, 0)
149
148
  ]) : p.value.bt = !1;
150
149
  }
151
- if (dt && m[0] === "b" && (F < W.top || p.value.tb)) {
150
+ if (xt && m[0] === "b" && (F < W.top || p.value.tb)) {
152
151
  let t = r;
153
- xt ? t += X - C : t = ht.y - pt.y - d;
154
- const h = u(
152
+ bt ? t += Y - L : t = gt.y - ht.y - b;
153
+ const v = u(
155
154
  l,
156
155
  t
157
156
  ), g = u(
158
157
  l,
159
158
  t,
160
- s
159
+ n
161
160
  );
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)
161
+ $(v, g) ? (p.value.tb = !0, r = t, b = -b, O.points = [
162
+ w(m, 0),
163
+ w(R, 0)
166
164
  ]) : p.value.tb = !1;
167
165
  }
168
- const bt = vt(he), wt = m[1] === A[1];
169
- if (bt && m[1] === "l" && (E > W.right || p.value.rl)) {
166
+ const wt = dt(le), At = m[1] === R[1];
167
+ if (wt && m[1] === "l" && (E > W.right || p.value.rl)) {
170
168
  let t = l;
171
- wt ? t -= Y - L : t = ut.x - gt.x - v;
172
- const h = u(
169
+ At ? t -= P - I : t = pt.x - mt.x - x;
170
+ const v = u(
173
171
  t,
174
172
  r
175
173
  ), g = u(
176
174
  t,
177
175
  r,
178
- s
176
+ n
179
177
  );
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)
178
+ $(v, g) ? (p.value.rl = !0, l = t, x = -x, O.points = [
179
+ w(m, 1),
180
+ w(R, 1)
184
181
  ]) : p.value.rl = !1;
185
182
  }
186
- if (bt && m[1] === "r" && (S < W.left || p.value.lr)) {
183
+ if (wt && m[1] === "r" && (S < W.left || p.value.lr)) {
187
184
  let t = l;
188
- wt ? t += Y - L : t = ht.x - pt.x - v;
189
- const h = u(
185
+ At ? t += P - I : t = gt.x - ht.x - x;
186
+ const v = u(
190
187
  t,
191
188
  r
192
189
  ), g = u(
193
190
  t,
194
191
  r,
195
- s
192
+ n
196
193
  );
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)
194
+ $(v, g) ? (p.value.lr = !0, l = t, x = -x, O.points = [
195
+ w(m, 1),
196
+ w(R, 1)
201
197
  ]) : p.value.lr = !1;
202
198
  }
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 = {
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 = {
213
209
  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
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
223
219
  };
224
- Object.assign(_, Ye);
220
+ h.value = de;
225
221
  }
226
- }), Q = () => {
227
- k.value += 1;
228
- const u = k.value;
222
+ }), K = () => {
223
+ _.value += 1;
224
+ const u = _.value;
229
225
  Promise.resolve().then(() => {
230
- k.value === u && Tt();
226
+ _.value === u && St();
231
227
  });
232
228
  };
233
- Pt(
234
- c,
229
+ Mt(
230
+ a,
235
231
  async (u) => {
236
- u && o.value && !D?.value && (await J(), Q());
232
+ u && o.value && !D?.value && (await G(), K());
237
233
  }
238
234
  );
239
- const Z = () => {
240
- _.ready = !1;
235
+ const Q = () => {
236
+ h.value.ready = !1;
241
237
  };
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,
259
- Q
238
+ return Mt(c, async () => {
239
+ await G(), Q();
240
+ }), Oe(async () => {
241
+ await G(), o.value || (Ft(), Q());
242
+ }), [
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
260
254
  ];
261
255
  }
262
256
  export {
263
- Ke as default
257
+ $e as default
264
258
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { VueNode } from '../../util/src/type';
2
- import { CSSMotionProps } from '../../util/src/utils/transition';
1
+ import { VueNode } from '@v-c/util/dist/type';
2
+ import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
3
3
  import { CSSProperties } from 'vue';
4
4
  import { ActionType, AlignType, AnimationType, ArrowTypeOuter, BuildInPlacements } from './interface';
5
5
  import { MobileConfig } from './Popup';
@@ -1,4 +1,4 @@
1
- import { VueNode } from '../../util/src/type';
1
+ import { VueNode } from '@v-c/util/dist/type';
2
2
  import { CSSProperties } from 'vue';
3
3
  export type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
4
4
  export type AlignPointTopBottom = 't' | 'b' | 'c';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/trigger",
3
3
  "type": "module",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
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 patch"
40
41
  }
41
42
  }