vue-pointing-bubble 0.2.0 → 0.4.0
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.
- package/dist/vue-pointing-bubble.cjs +2 -2
- package/dist/vue-pointing-bubble.js +236 -231
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("vue"),P={target:null,placement:"auto",targetAnchor:"center",tailLength:45,tailBaseWidth:24,padding:8,shadow:!0,transitionDuration:200},T="pointing-bubble-styles",q=`:where(.pointing-bubble__inner) {
|
|
2
2
|
box-sizing: border-box;
|
|
3
3
|
width: var(--pb-width, max-content);
|
|
4
4
|
max-width: var(--pb-max-width, none);
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
background: white;
|
|
7
7
|
border: 2px solid gray;
|
|
8
8
|
border-radius: 8px;
|
|
9
|
-
}`,_="drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";function H(n=document){if(n.getElementById(I))return;const e=n.createElement("style");e.id=I,e.textContent=U,n.head.prepend(e)}function P(n){return typeof n=="object"&&n!==null&&typeof n.x=="number"&&typeof n.y=="number"&&n.nodeType!==1}function D(n){return typeof Element>"u"||n==null?null:typeof n=="string"?document.querySelector(n):n instanceof Element?n:null}function z(n,e){return!n||!e?!1:Object.keys(n).every(t=>n[t]===e[t])}function X(n){const e=n.getBoundingClientRect(),t=getComputedStyle(n),a=parseFloat(t.width)||0,l=parseFloat(t.height)||0;return{left:e.left,top:e.top,width:a,height:l,scaleX:a?e.width/a:1,scaleY:l?e.height/l:1,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function G(n,e,t,a){const l=getComputedStyle(n),{scaleX:r,scaleY:u}=t,i=n.getBoundingClientRect(),d=e.getBoundingClientRect();return{x:a?(i.left-d.left)/r:0,y:a?(i.top-d.top)/u:0,width:i.width/r,height:i.height/u,fill:l.backgroundColor,stroke:l.borderTopColor,strokeWidth:parseFloat(l.borderTopWidth)||0,radius:l.borderTopLeftRadius,zIndex:l.zIndex}}function F(n,e,t){const a=n.x-t;let l=a,r=e.width?e.width-n.x-t:1/0;return e.viewportWidth&&(l=Math.min(l,e.left/e.scaleX+a),r=Math.min(r,(e.viewportWidth-e.left)/e.scaleX-n.x-t)),{left:Math.max(0,l),right:Math.max(0,r)}}function O(n){return n.left>n.right?"left":"right"}function j(n){const{tip:e,box:t,frame:a,placement:l,targetRect:r,room:u,tailLength:i}=n;if(!t.width||!t.height)return null;const{width:d,height:f}=t,{x,y}=e,E=l==="manual",o=n.targetAnchor==="edge"?r:null;if(E){if(o){const v=t.x+d/2,w=t.y+f/2;if(!(v>=o.left&&v<=o.right&&w>=o.top&&w<=o.bottom)){const g=Math.min(o.right,Math.max(o.left,v)),b=Math.min(o.bottom,Math.max(o.top,w));return{placement:"manual",tx:g,ty:b,bx:t.x,by:t.y,w:d,h:f}}}return{placement:"manual",tx:x,ty:y,bx:t.x,by:t.y,w:d,h:f}}const k=v=>o?v==="top"?o.top:o.bottom:y;let S=l;if(l==="auto"){let v=y>(a.height||600)/2?"top":"bottom",w=O(u);const{scaleX:p,scaleY:g}=a;if(a.viewportHeight){const b=a.top+(k("top")-f-i)*g>=0,B=a.top+(k("bottom")+f+i)*g<=a.viewportHeight;v==="top"&&!b&&B?v="bottom":v==="bottom"&&!B&&b&&(v="top")}if(a.viewportWidth){const b=a.left+(x-d-i)*p>=0,B=a.left+(x+d+i)*p<=a.viewportWidth;w==="left"&&!b&&B?w="right":w==="right"&&!B&&b&&(w="left")}S=`${v}-${w}`}const[W,C]=S.split("-"),$=k(W);return{placement:S,tx:x,ty:$,bx:C==="left"?x-d-i:x+i,by:W==="top"?$-f-i:$+i,w:d,h:f}}const q=["tx","ty","bx","by"],V=["tx","ty"];function Z(){return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function K(n,e,t,a){let l=0;const r=()=>{typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l)};if(!e||!n||t<=0||typeof requestAnimationFrame>"u"||Z())return a(e),{cancel:r};const u=performance.now(),i=d=>{const f=Math.min(1,(d-u)/t),x=1-Math.pow(1-f,3),y={...e},E=e.placement==="manual"?V:q;for(const o of E)y[o]=n[o]+(e[o]-n[o])*x;a(y),f<1&&(l=requestAnimationFrame(i))};return l=requestAnimationFrame(i),{cancel:r}}function N(n){const{geometry:e,strokeWidth:t,radius:a,tailBaseWidth:l}=n,{placement:r,tx:u,ty:i,bx:d,by:f,w:x,h:y}=e,E=parseFloat(a)*(a.endsWith("%")?Math.min(x,y)/100:1)||0,o=l/2,k=(s,c,h)=>c>h?(c+h)/2:Math.min(h,Math.max(c,s));let S=null,W=0;if(r==="manual"){const s=Math.max(d-u,u-(d+x),0),c=Math.max(f-i,i-(f+y),0);if(s>0&&s>=c)S=u<d?"left":"right",W=i;else if(c>0)S=i<f?"top":"bottom",W=u;else return null}else if(r!=="none"){const[s,c]=r.split("-");S=c==="left"?"right":"left",W=f+y*(s==="top"?.65:.35)}else return null;const C=1,$=S==="top"||S==="bottom",v={left:(s,c)=>[d-c,s],right:(s,c)=>[d+x+c,s],top:(s,c)=>[s,f-c],bottom:(s,c)=>[s,f+y+c]}[S],w={left:d-u,right:u-d-x,top:f-i,bottom:i-f-y}[S],p=$?k(W,d+E+o+t/2,d+x-E-o-t/2):k(W,f+E+o+t/2,f+y-E-o-t/2),g=Math.max(0,Math.min(t,w/2)),b=([s,c])=>`${s} ${c}`,B=(s,c)=>{const h=v(s,g),L=Math.hypot(u-h[0],i-h[1])||1,R=[h[0]+(u-h[0])*g/L,h[1]+(i-h[1])*g/L];return{inner:b(v(s,c)),outer:b(v(s,0)),ctrl:b(h),end:b(R)}},M=s=>{const c=B(p-o,s),h=B(p+o,s);return`M ${c.inner} L ${c.outer} Q ${c.ctrl} ${c.end} L ${u} ${i} L ${h.end} Q ${h.ctrl} ${h.outer} L ${h.inner}`};return{fill:`${M(-t-C)} Z`,stroke:t?M(-t):null}}function Q(n){return{hasTarget:n,placement:"none",tip:null,slotTip:null,overlayStyle:{},boxStyle:{},rootIsBox:!n,tail:null,boxFill:"",boxStroke:"",boxStrokeWidth:0,boxZIndex:"auto"}}function Y(n){H();let e={...T},t=null,a=null,l=null,r={left:0,top:0,width:0,height:0,scaleX:1,scaleY:1,viewportWidth:0,viewportHeight:0},u=null,i=null,d=null,f=null,x=Q(!1);const y=()=>{x=E(),n.onChange?.(x)};function E(){const p=e.target!=null,g=e.placement==="manual",b=p?u?.placement??"none":"none",B={position:"absolute",inset:"0",pointerEvents:"none",filter:e.shadow?_:void 0},M=l?.zIndex;M&&M!=="auto"&&(B.zIndex=M);const s={"--pb-padding":typeof e.padding=="number"?`${e.padding}px`:e.padding};if(e.maxWidth!=null&&(s["--pb-max-width"]=`${e.maxWidth}px`),!p)s["--pb-width"]="fit-content",e.shadow&&(s.filter=_);else if(Object.assign(s,{position:"absolute",pointerEvents:"auto",visibility:u?"visible":"hidden"}),g)s["--pb-width"]="fit-content";else if(Object.assign(s,{left:`${u?.bx??0}px`,top:`${u?.by??0}px`,margin:"0"}),e.maxWidth==null&&t){const h=F(t,r,e.tailLength),L=i?.placement??e.placement,R=L==="auto"?O(h):L.split("-")[1];s["--pb-max-width"]=`${h[R]}px`}const c=p&&u&&l?N({geometry:u,strokeWidth:l.strokeWidth,radius:l.radius,tailBaseWidth:e.tailBaseWidth}):null;return{hasTarget:p,placement:b,tip:t,slotTip:i?{x:i.tx,y:i.ty}:t,overlayStyle:B,boxStyle:s,rootIsBox:!p,tail:c,boxFill:l?.fill??"",boxStroke:l?.stroke??"",boxStrokeWidth:l?.strokeWidth??0,boxZIndex:l?.zIndex??"auto"}}function o(){if(!t||!l){i=null,k(null);return}const p=F(t,r,e.tailLength);i=j({tip:t,box:l,frame:r,placement:e.placement,targetAnchor:e.targetAnchor,targetRect:a,room:p,tailLength:e.tailLength}),k(i)}function k(p){d?.cancel(),d=K(u,p,e.transitionDuration,g=>{u=g,y()})}function S(){const p=n.getRootEl(),g=n.getBoxEl();if(!g||e.target==null||!p)return;const b=G(g,p,r,e.placement==="manual");z(b,l)||(l=b)}function W(){const p=n.getRootEl();if(e.target==null||!p){t=null,a=null,l=null,i=null,u=null,y();return}r=X(p);const g=D(e.target);if(g){const b=g.getBoundingClientRect(),{scaleX:B,scaleY:M,left:s,top:c}=r,h={left:(b.left-s)/B,top:(b.top-c)/M,right:(b.right-s)/B,bottom:(b.bottom-c)/M};z(h,a)||(a=h),t={x:(h.left+h.right)/2,y:(h.top+h.bottom)/2}}else if(P(e.target))a=null,t={x:e.target.x,y:e.target.y};else{a=null,t=null,l=null,i=null,u=null,y();return}S(),o()}function C(){W()}typeof window<"u"&&(window.addEventListener("resize",C),window.addEventListener("scroll",C,!0));function $(){if(typeof ResizeObserver>"u")return;f?.disconnect(),f=new ResizeObserver(()=>W());const p=n.getRootEl(),g=n.getBoxEl();p&&f.observe(p),g&&f.observe(g)}const v=W;function w(){$(),v()}return{update:w,setConfig(p){e={...e,...p},w()},getConfig:()=>e,getState:()=>x,destroy(){d?.cancel(),f?.disconnect(),typeof window<"u"&&(window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0))}}}const J=["data-placement"],tt=["d","fill"],et=["d","stroke","stroke-width"],A=m.defineComponent({name:"PointingBubble",inheritAttrs:!1,__name:"PointingBubble",props:{target:{default:null},placement:{default:"auto"},targetAnchor:{default:"center"},maxWidth:{default:void 0},tailLength:{default:45},tailBaseWidth:{default:24},padding:{default:8},shadow:{type:Boolean,default:!0},transitionDuration:{default:200}},setup(n,{expose:e}){const t=n,a=m.ref(null),l=m.ref(null),r=m.ref({hasTarget:!1,placement:"none",tip:null,slotTip:null,overlayStyle:{},boxStyle:{},rootIsBox:!0,tail:null,boxFill:"",boxStroke:"",boxStrokeWidth:0,boxZIndex:"auto"});function u(o){return o==null?null:typeof o=="string"||typeof Element<"u"&&o instanceof Element?o:typeof o=="object"&&"$el"in o&&o.$el instanceof Element?o.$el:typeof o=="object"&&typeof o.x=="number"&&typeof o.y=="number"?o:null}const i=Y({getRootEl:()=>a.value,getBoxEl:()=>l.value,onChange:o=>{r.value=o}});function d(){i.setConfig({target:u(t.target),placement:t.placement,targetAnchor:t.targetAnchor,maxWidth:t.maxWidth,tailLength:t.tailLength,tailBaseWidth:t.tailBaseWidth,padding:t.padding,shadow:t.shadow,transitionDuration:t.transitionDuration})}m.watch(()=>[t.target,typeof t.target=="object"&&t.target&&"x"in t.target?t.target.x:null,typeof t.target=="object"&&t.target&&"y"in t.target?t.target.y:null,t.placement,t.targetAnchor,t.maxWidth,t.tailLength,t.tailBaseWidth,t.padding,t.shadow,t.transitionDuration],d,{flush:"post"}),m.onMounted(()=>{d()}),m.onUpdated(()=>{i.update()}),m.onBeforeUnmount(()=>{i.destroy()});function f(){i.update()}e({update:f});const x=m.computed(()=>r.value.rootIsBox?r.value.boxStyle:r.value.overlayStyle),y=m.computed(()=>r.value.rootIsBox?{display:"contents"}:r.value.boxStyle),E=m.computed(()=>({position:"absolute",inset:"0",width:"100%",height:"100%",overflow:"visible",zIndex:r.value.boxZIndex}));return(o,k)=>(m.openBlock(),m.createElementBlock("div",m.mergeProps({ref_key:"rootRef",ref:a,class:["pointing-bubble",{"pointing-bubble__inner":!n.target}],"data-placement":r.value.placement},n.target?{}:o.$attrs,{style:x.value}),[m.createElementVNode("div",m.mergeProps({ref_key:"boxRef",ref:l,class:{"pointing-bubble__inner":!!n.target}},n.target?o.$attrs:{},{style:y.value}),[m.renderSlot(o.$slots,"default",{placement:r.value.placement,tip:r.value.slotTip},()=>[k[0]||(k[0]=m.createElementVNode("p",{style:{margin:0,fontSize:"14px",fontWeight:600,color:"#1e293b"}}," Callout content ",-1))])],16),n.target&&r.value.tail?(m.openBlock(),m.createElementBlock("svg",{key:0,class:"pointing-bubble__svg",style:m.normalizeStyle(E.value)},[m.createElementVNode("path",{class:"pointing-bubble__path",d:r.value.tail.fill,fill:r.value.boxFill},null,8,tt),r.value.tail.stroke?(m.openBlock(),m.createElementBlock("path",{key:0,class:"pointing-bubble__path",d:r.value.tail.stroke,fill:"none",stroke:r.value.boxStroke,"stroke-width":r.value.boxStrokeWidth,"stroke-linejoin":"round","stroke-linecap":"butt"},null,8,et)):m.createCommentVNode("",!0)],4)):m.createCommentVNode("",!0)],16,J))}}),nt={install(n,e={}){const t=e.name??"PointingBubble";n.component(t,A),n.component("Callout",A)}};exports.Callout=A;exports.DEFAULT_BUBBLE_CONFIG=T;exports.PointingBubble=A;exports.PointingBubblePlugin=nt;exports.buildTailPaths=N;exports.computeGeometry=j;exports.createBubbleController=Y;exports.default=A;exports.isPoint=P;exports.resolveElement=D;
|
|
9
|
+
}`,_="drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";function H(e=document){if(e.getElementById(T))return;const t=e.createElement("style");t.id=T,t.textContent=q,e.head.prepend(t)}function D(e){return typeof e=="object"&&e!==null&&typeof e.x=="number"&&typeof e.y=="number"&&e.nodeType!==1}function O(e){return typeof Element>"u"||e==null?null:typeof e=="string"?document.querySelector(e):e instanceof Element?e:null}function A(e,t){return!e||!t?!1:Object.keys(e).every(n=>e[n]===t[n])}function X(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),a=parseFloat(n.width)||0,l=parseFloat(n.height)||0;return{left:t.left,top:t.top,width:a,height:l,scaleX:a?t.width/a:1,scaleY:l?t.height/l:1,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function Z(e,t,n,a){const l=getComputedStyle(e),{scaleX:i,scaleY:d}=n,r=e.getBoundingClientRect(),f=t.getBoundingClientRect();return{x:a?(r.left-f.left)/i:0,y:a?(r.top-f.top)/d:0,width:r.width/i,height:r.height/d,fill:l.backgroundColor,stroke:l.borderTopColor,strokeWidth:parseFloat(l.borderTopWidth)||0,radius:l.borderTopLeftRadius,zIndex:l.zIndex}}function F(e,t,n){const a=e.x-n;let l=a,i=t.width?t.width-e.x-n:1/0;return t.viewportWidth&&(l=Math.min(l,t.left/t.scaleX+a),i=Math.min(i,(t.viewportWidth-t.left)/t.scaleX-e.x-n)),{left:Math.max(0,l),right:Math.max(0,i)}}function j(e){return e.left>e.right?"left":"right"}function N(e){const{tip:t,box:n,frame:a,placement:l,targetRect:i,room:d,tailLength:r}=e;if(!n.width||!n.height)return null;const{width:f,height:p}=n,{x:b,y}=t,k=l==="manual",o=e.targetAnchor==="edge"?i:null;if(k){if(o){const v=n.x+f/2,w=n.y+p/2;if(!(v>=o.left&&v<=o.right&&w>=o.top&&w<=o.bottom)){const x=Math.min(o.right,Math.max(o.left,v)),g=Math.min(o.bottom,Math.max(o.top,w));return{placement:"manual",tx:x,ty:g,bx:n.x,by:n.y,w:f,h:p}}}return{placement:"manual",tx:b,ty:y,bx:n.x,by:n.y,w:f,h:p}}const E=v=>o?v==="top"?o.top:o.bottom:y;let B=l;if(l==="auto"){let v=y>(a.height||600)/2?"top":"bottom",w=j(d);const{scaleX:u,scaleY:x}=a;if(a.viewportHeight){const g=a.top+(E("top")-p-r)*x>=0,S=a.top+(E("bottom")+p+r)*x<=a.viewportHeight;v==="top"&&!g&&S?v="bottom":v==="bottom"&&!S&&g&&(v="top")}if(a.viewportWidth){const g=a.left+(b-f-r)*u>=0,S=a.left+(b+f+r)*u<=a.viewportWidth;w==="left"&&!g&&S?w="right":w==="right"&&!S&&g&&(w="left")}B=`${v}-${w}`}const[W,C]=B.split("-"),I=E(W);return{placement:B,tx:b,ty:I,bx:C==="left"?b-f-r:b+r,by:W==="top"?I-p-r:I+r,w:f,h:p}}const G=["tx","ty","bx","by"],V=["tx","ty"];function K(){return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Q(e,t,n,a){let l=0;const i=()=>{typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l)};if(!t||!e||n<=0||typeof requestAnimationFrame>"u"||K())return a(t),{cancel:i};const d=performance.now(),r=f=>{const p=Math.min(1,(f-d)/n),b=1-Math.pow(1-p,3),y={...t},k=t.placement==="manual"?V:G;for(const o of k)y[o]=e[o]+(t[o]-e[o])*b;a(y),p<1&&(l=requestAnimationFrame(r))};return l=requestAnimationFrame(r),{cancel:i}}function Y(e){const{geometry:t,strokeWidth:n,radius:a,tailBaseWidth:l}=e,{placement:i,tx:d,ty:r,bx:f,by:p,w:b,h:y}=t,k=parseFloat(a)*(a.endsWith("%")?Math.min(b,y)/100:1)||0,o=l/2,E=(s,c,h)=>c>h?(c+h)/2:Math.min(h,Math.max(c,s));let B=null,W=0;if(i==="manual"){const s=Math.max(f-d,d-(f+b),0),c=Math.max(p-r,r-(p+y),0);if(s>0&&s>=c)B=d<f?"left":"right",W=r;else if(c>0)B=r<p?"top":"bottom",W=d;else return null}else if(i!=="none"){const[s,c]=i.split("-");B=c==="left"?"right":"left",W=p+y*(s==="top"?.65:.35)}else return null;const C=1,I=B==="top"||B==="bottom",v={left:(s,c)=>[f-c,s],right:(s,c)=>[f+b+c,s],top:(s,c)=>[s,p-c],bottom:(s,c)=>[s,p+y+c]}[B],w={left:f-d,right:d-f-b,top:p-r,bottom:r-p-y}[B],u=I?E(W,f+k+o+n/2,f+b-k-o-n/2):E(W,p+k+o+n/2,p+y-k-o-n/2),x=Math.max(0,Math.min(n,w/2)),g=([s,c])=>`${s} ${c}`,S=(s,c)=>{const h=v(s,x),$=Math.hypot(d-h[0],r-h[1])||1,R=[h[0]+(d-h[0])*x/$,h[1]+(r-h[1])*x/$];return{inner:g(v(s,c)),outer:g(v(s,0)),ctrl:g(h),end:g(R)}},M=s=>{const c=S(u-o,s),h=S(u+o,s);return`M ${c.inner} L ${c.outer} Q ${c.ctrl} ${c.end} L ${d} ${r} L ${h.end} Q ${h.ctrl} ${h.outer} L ${h.inner}`};return{fill:`${M(-n-C)} Z`,stroke:n?M(-n):null}}function J(e){return{hasTarget:e,placement:"none",tip:null,slotTip:null,overlayStyle:{},boxStyle:{},rootIsBox:!e,tail:null,boxFill:"",boxStroke:"",boxStrokeWidth:0,boxZIndex:"auto"}}function z(e,t){return e===t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function tt(e,t){return e.hasTarget===t.hasTarget&&e.placement===t.placement&&e.rootIsBox===t.rootIsBox&&e.boxFill===t.boxFill&&e.boxStroke===t.boxStroke&&e.boxStrokeWidth===t.boxStrokeWidth&&e.boxZIndex===t.boxZIndex&&z(e.tip,t.tip)&&z(e.slotTip,t.slotTip)&&A(e.overlayStyle,t.overlayStyle)&&A(e.boxStyle,t.boxStyle)&&e.tail?.fill===t.tail?.fill&&e.tail?.stroke===t.tail?.stroke}function U(e){H();let t={...P},n=null,a=null,l=null,i={left:0,top:0,width:0,height:0,scaleX:1,scaleY:1,viewportWidth:0,viewportHeight:0},d=null,r=null,f=null,p=null,b=J(!1);const y=()=>{const u=k();tt(b,u)||(b=u,e.onChange?.(b))};function k(){const u=t.target!=null,x=t.placement==="manual",g=u?d?.placement??"none":"none",S={position:"absolute",inset:"0",pointerEvents:"none",filter:t.shadow?_:void 0},M=l?.zIndex;M&&M!=="auto"&&(S.zIndex=M);const s={"--pb-padding":typeof t.padding=="number"?`${t.padding}px`:t.padding};if(t.maxWidth!=null&&(s["--pb-max-width"]=`${t.maxWidth}px`),!u)s["--pb-width"]="fit-content",t.shadow&&(s.filter=_);else if(Object.assign(s,{position:"absolute",pointerEvents:"auto",visibility:d?"visible":"hidden"}),x)s["--pb-width"]="fit-content";else if(Object.assign(s,{left:`${d?.bx??0}px`,top:`${d?.by??0}px`,margin:"0"}),t.maxWidth==null&&n){const h=F(n,i,t.tailLength),$=r?.placement??t.placement,R=$==="auto"?j(h):$.split("-")[1];s["--pb-max-width"]=`${h[R]}px`}const c=u&&d&&l?Y({geometry:d,strokeWidth:l.strokeWidth,radius:l.radius,tailBaseWidth:t.tailBaseWidth}):null;return{hasTarget:u,placement:g,tip:n,slotTip:r?{x:r.tx,y:r.ty}:n,overlayStyle:S,boxStyle:s,rootIsBox:!u,tail:c,boxFill:l?.fill??"",boxStroke:l?.stroke??"",boxStrokeWidth:l?.strokeWidth??0,boxZIndex:l?.zIndex??"auto"}}function o(){if(!n||!l){r=null,E(null);return}const u=F(n,i,t.tailLength);r=N({tip:n,box:l,frame:i,placement:t.placement,targetAnchor:t.targetAnchor,targetRect:a,room:u,tailLength:t.tailLength}),E(r)}function E(u){f?.cancel(),f=Q(d,u,t.transitionDuration,x=>{d=x,y()})}function B(){const u=e.getRootEl(),x=e.getBoxEl();if(!x||t.target==null||!u)return;const g=Z(x,u,i,t.placement==="manual");A(g,l)||(l=g)}function W(){const u=e.getRootEl();if(t.target==null||!u){n=null,a=null,l=null,r=null,d=null,y();return}i=X(u);const x=O(t.target);if(x){const g=x.getBoundingClientRect(),{scaleX:S,scaleY:M,left:s,top:c}=i,h={left:(g.left-s)/S,top:(g.top-c)/M,right:(g.right-s)/S,bottom:(g.bottom-c)/M};A(h,a)||(a=h),n={x:(h.left+h.right)/2,y:(h.top+h.bottom)/2}}else if(D(t.target))a=null,n={x:t.target.x,y:t.target.y};else{a=null,n=null,l=null,r=null,d=null,y();return}B(),o()}function C(){W()}typeof window<"u"&&(window.addEventListener("resize",C),window.addEventListener("scroll",C,!0));function I(){if(typeof ResizeObserver>"u")return;p?.disconnect(),p=new ResizeObserver(()=>W());const u=e.getRootEl(),x=e.getBoxEl();u&&p.observe(u),x&&p.observe(x)}const v=W;function w(){I(),v()}return{update:w,setConfig(u){t={...t,...u},w()},getConfig:()=>t,getState:()=>b,destroy(){f?.cancel(),p?.disconnect(),typeof window<"u"&&(window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0))}}}const et=["data-placement"],nt=["d","fill"],ot=["d","stroke","stroke-width"],L=m.defineComponent({name:"PointingBubble",inheritAttrs:!1,__name:"PointingBubble",props:{target:{default:null},placement:{default:"auto"},targetAnchor:{default:"center"},maxWidth:{default:void 0},tailLength:{default:45},tailBaseWidth:{default:24},padding:{default:8},shadow:{type:Boolean,default:!0},transitionDuration:{default:200}},setup(e,{expose:t}){const n=e,a=m.ref(null),l=m.ref(null),i=m.ref({hasTarget:!1,placement:"none",tip:null,slotTip:null,overlayStyle:{},boxStyle:{},rootIsBox:!0,tail:null,boxFill:"",boxStroke:"",boxStrokeWidth:0,boxZIndex:"auto"});function d(o){return o==null?null:typeof o=="string"||typeof Element<"u"&&o instanceof Element?o:typeof o=="object"&&"$el"in o&&o.$el instanceof Element?o.$el:typeof o=="object"&&typeof o.x=="number"&&typeof o.y=="number"?o:null}const r=U({getRootEl:()=>a.value,getBoxEl:()=>l.value,onChange:o=>{i.value=o}});function f(){r.setConfig({target:d(n.target),placement:n.placement,targetAnchor:n.targetAnchor,maxWidth:n.maxWidth,tailLength:n.tailLength,tailBaseWidth:n.tailBaseWidth,padding:n.padding,shadow:n.shadow,transitionDuration:n.transitionDuration})}m.watch(()=>[n.target,typeof n.target=="object"&&n.target&&"x"in n.target?n.target.x:null,typeof n.target=="object"&&n.target&&"y"in n.target?n.target.y:null,n.placement,n.targetAnchor,n.maxWidth,n.tailLength,n.tailBaseWidth,n.padding,n.shadow,n.transitionDuration],f,{flush:"post"}),m.onMounted(()=>{f()}),m.onBeforeUnmount(()=>{r.destroy()});function p(){r.update()}t({update:p});const b=m.computed(()=>i.value.rootIsBox?i.value.boxStyle:i.value.overlayStyle),y=m.computed(()=>i.value.rootIsBox?{display:"contents"}:i.value.boxStyle),k=m.computed(()=>({position:"absolute",inset:"0",width:"100%",height:"100%",overflow:"visible",zIndex:i.value.boxZIndex}));return(o,E)=>(m.openBlock(),m.createElementBlock("div",m.mergeProps({ref_key:"rootRef",ref:a,class:["pointing-bubble",{"pointing-bubble__inner":!e.target}],"data-placement":i.value.placement},e.target?{}:o.$attrs,{style:b.value}),[m.createElementVNode("div",m.mergeProps({ref_key:"boxRef",ref:l,class:{"pointing-bubble__inner":!!e.target}},e.target?o.$attrs:{},{style:y.value}),[m.renderSlot(o.$slots,"default",{placement:i.value.placement,tip:i.value.slotTip},()=>[E[0]||(E[0]=m.createElementVNode("p",{style:{margin:0,fontSize:"14px",fontWeight:600,color:"#1e293b"}}," Callout content ",-1))])],16),e.target&&i.value.tail?(m.openBlock(),m.createElementBlock("svg",{key:0,class:"pointing-bubble__svg",style:m.normalizeStyle(k.value)},[m.createElementVNode("path",{class:"pointing-bubble__path",d:i.value.tail.fill,fill:i.value.boxFill},null,8,nt),i.value.tail.stroke?(m.openBlock(),m.createElementBlock("path",{key:0,class:"pointing-bubble__path",d:i.value.tail.stroke,fill:"none",stroke:i.value.boxStroke,"stroke-width":i.value.boxStrokeWidth,"stroke-linejoin":"round","stroke-linecap":"butt"},null,8,ot)):m.createCommentVNode("",!0)],4)):m.createCommentVNode("",!0)],16,et))}}),lt={install(e,t={}){const n=t.name??"PointingBubble";e.component(n,L),e.component("Callout",L)}};exports.Callout=L;exports.DEFAULT_BUBBLE_CONFIG=P;exports.PointingBubble=L;exports.PointingBubblePlugin=lt;exports.buildTailPaths=Y;exports.computeGeometry=N;exports.createBubbleController=U;exports.default=L;exports.isPoint=D;exports.resolveElement=O;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as Z, ref as L, watch as q, onMounted as N, onBeforeUnmount as U, computed as R, openBlock as z, createElementBlock as T, mergeProps as _, createElementVNode as F, renderSlot as G, normalizeStyle as K, createCommentVNode as D } from "vue";
|
|
2
2
|
const Q = {
|
|
3
3
|
target: null,
|
|
4
4
|
placement: "auto",
|
|
@@ -8,7 +8,7 @@ const Q = {
|
|
|
8
8
|
padding: 8,
|
|
9
9
|
shadow: !0,
|
|
10
10
|
transitionDuration: 200
|
|
11
|
-
},
|
|
11
|
+
}, j = "pointing-bubble-styles", V = `:where(.pointing-bubble__inner) {
|
|
12
12
|
box-sizing: border-box;
|
|
13
13
|
width: var(--pb-width, max-content);
|
|
14
14
|
max-width: var(--pb-max-width, none);
|
|
@@ -16,41 +16,41 @@ const Q = {
|
|
|
16
16
|
background: white;
|
|
17
17
|
border: 2px solid gray;
|
|
18
18
|
border-radius: 8px;
|
|
19
|
-
}`,
|
|
20
|
-
function J(
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
|
|
19
|
+
}`, O = "drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";
|
|
20
|
+
function J(e = document) {
|
|
21
|
+
if (e.getElementById(j)) return;
|
|
22
|
+
const t = e.createElement("style");
|
|
23
|
+
t.id = j, t.textContent = V, e.head.prepend(t);
|
|
24
24
|
}
|
|
25
|
-
function tt(
|
|
26
|
-
return typeof
|
|
25
|
+
function tt(e) {
|
|
26
|
+
return typeof e == "object" && e !== null && typeof e.x == "number" && typeof e.y == "number" && e.nodeType !== 1;
|
|
27
27
|
}
|
|
28
|
-
function et(
|
|
29
|
-
return typeof Element > "u" ||
|
|
28
|
+
function et(e) {
|
|
29
|
+
return typeof Element > "u" || e == null ? null : typeof e == "string" ? document.querySelector(e) : e instanceof Element ? e : null;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return !
|
|
31
|
+
function A(e, t) {
|
|
32
|
+
return !e || !t ? !1 : Object.keys(e).every((n) => e[n] === t[n]);
|
|
33
33
|
}
|
|
34
|
-
function nt(
|
|
35
|
-
const
|
|
34
|
+
function nt(e) {
|
|
35
|
+
const t = e.getBoundingClientRect(), n = getComputedStyle(e), a = parseFloat(n.width) || 0, l = parseFloat(n.height) || 0;
|
|
36
36
|
return {
|
|
37
|
-
left:
|
|
38
|
-
top:
|
|
37
|
+
left: t.left,
|
|
38
|
+
top: t.top,
|
|
39
39
|
width: a,
|
|
40
40
|
height: l,
|
|
41
|
-
scaleX: a ?
|
|
42
|
-
scaleY: l ?
|
|
41
|
+
scaleX: a ? t.width / a : 1,
|
|
42
|
+
scaleY: l ? t.height / l : 1,
|
|
43
43
|
viewportWidth: window.innerWidth,
|
|
44
44
|
viewportHeight: window.innerHeight
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
function ot(
|
|
48
|
-
const l = getComputedStyle(
|
|
47
|
+
function ot(e, t, n, a) {
|
|
48
|
+
const l = getComputedStyle(e), { scaleX: i, scaleY: d } = n, r = e.getBoundingClientRect(), f = t.getBoundingClientRect();
|
|
49
49
|
return {
|
|
50
|
-
x: a ? (
|
|
51
|
-
y: a ? (
|
|
52
|
-
width:
|
|
53
|
-
height:
|
|
50
|
+
x: a ? (r.left - f.left) / i : 0,
|
|
51
|
+
y: a ? (r.top - f.top) / d : 0,
|
|
52
|
+
width: r.width / i,
|
|
53
|
+
height: r.height / d,
|
|
54
54
|
fill: l.backgroundColor,
|
|
55
55
|
stroke: l.borderTopColor,
|
|
56
56
|
strokeWidth: parseFloat(l.borderTopWidth) || 0,
|
|
@@ -58,106 +58,106 @@ function ot(n, e, t, a) {
|
|
|
58
58
|
zIndex: l.zIndex
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
function P(
|
|
62
|
-
const a =
|
|
63
|
-
let l = a,
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
(
|
|
67
|
-
)), { left: Math.max(0, l), right: Math.max(0,
|
|
61
|
+
function P(e, t, n) {
|
|
62
|
+
const a = e.x - n;
|
|
63
|
+
let l = a, i = t.width ? t.width - e.x - n : 1 / 0;
|
|
64
|
+
return t.viewportWidth && (l = Math.min(l, t.left / t.scaleX + a), i = Math.min(
|
|
65
|
+
i,
|
|
66
|
+
(t.viewportWidth - t.left) / t.scaleX - e.x - n
|
|
67
|
+
)), { left: Math.max(0, l), right: Math.max(0, i) };
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
69
|
+
function X(e) {
|
|
70
|
+
return e.left > e.right ? "left" : "right";
|
|
71
71
|
}
|
|
72
|
-
function lt(
|
|
73
|
-
const { tip:
|
|
74
|
-
if (!
|
|
75
|
-
const { width:
|
|
76
|
-
if (
|
|
72
|
+
function lt(e) {
|
|
73
|
+
const { tip: t, box: n, frame: a, placement: l, targetRect: i, room: d, tailLength: r } = e;
|
|
74
|
+
if (!n.width || !n.height) return null;
|
|
75
|
+
const { width: f, height: p } = n, { x: g, y: x } = t, k = l === "manual", o = e.targetAnchor === "edge" ? i : null;
|
|
76
|
+
if (k) {
|
|
77
77
|
if (o) {
|
|
78
|
-
const y =
|
|
78
|
+
const y = n.x + f / 2, v = n.y + p / 2;
|
|
79
79
|
if (!(y >= o.left && y <= o.right && v >= o.top && v <= o.bottom)) {
|
|
80
80
|
const b = Math.min(o.right, Math.max(o.left, y)), m = Math.min(o.bottom, Math.max(o.top, v));
|
|
81
|
-
return { placement: "manual", tx: b, ty: m, bx:
|
|
81
|
+
return { placement: "manual", tx: b, ty: m, bx: n.x, by: n.y, w: f, h: p };
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
return { placement: "manual", tx: g, ty: x, bx:
|
|
84
|
+
return { placement: "manual", tx: g, ty: x, bx: n.x, by: n.y, w: f, h: p };
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const W = (y) => o ? y === "top" ? o.top : o.bottom : x;
|
|
87
87
|
let S = l;
|
|
88
88
|
if (l === "auto") {
|
|
89
|
-
let y = x > (a.height || 600) / 2 ? "top" : "bottom", v =
|
|
90
|
-
const { scaleX:
|
|
89
|
+
let y = x > (a.height || 600) / 2 ? "top" : "bottom", v = X(d);
|
|
90
|
+
const { scaleX: u, scaleY: b } = a;
|
|
91
91
|
if (a.viewportHeight) {
|
|
92
|
-
const m = a.top + (
|
|
92
|
+
const m = a.top + (W("top") - p - r) * b >= 0, w = a.top + (W("bottom") + p + r) * b <= a.viewportHeight;
|
|
93
93
|
y === "top" && !m && w ? y = "bottom" : y === "bottom" && !w && m && (y = "top");
|
|
94
94
|
}
|
|
95
95
|
if (a.viewportWidth) {
|
|
96
|
-
const m = a.left + (g -
|
|
96
|
+
const m = a.left + (g - f - r) * u >= 0, w = a.left + (g + f + r) * u <= a.viewportWidth;
|
|
97
97
|
v === "left" && !m && w ? v = "right" : v === "right" && !w && m && (v = "left");
|
|
98
98
|
}
|
|
99
99
|
S = `${y}-${v}`;
|
|
100
100
|
}
|
|
101
|
-
const [
|
|
101
|
+
const [B, $] = S.split("-"), I = W(B);
|
|
102
102
|
return {
|
|
103
103
|
placement: S,
|
|
104
104
|
tx: g,
|
|
105
|
-
ty:
|
|
106
|
-
bx: $ === "left" ? g -
|
|
107
|
-
by:
|
|
108
|
-
w:
|
|
109
|
-
h:
|
|
105
|
+
ty: I,
|
|
106
|
+
bx: $ === "left" ? g - f - r : g + r,
|
|
107
|
+
by: B === "top" ? I - p - r : I + r,
|
|
108
|
+
w: f,
|
|
109
|
+
h: p
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
const it = ["tx", "ty", "bx", "by"], rt = ["tx", "ty"];
|
|
113
113
|
function at() {
|
|
114
114
|
return typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
115
115
|
}
|
|
116
|
-
function st(
|
|
116
|
+
function st(e, t, n, a) {
|
|
117
117
|
let l = 0;
|
|
118
|
-
const
|
|
118
|
+
const i = () => {
|
|
119
119
|
typeof cancelAnimationFrame < "u" && cancelAnimationFrame(l);
|
|
120
120
|
};
|
|
121
|
-
if (!
|
|
122
|
-
return a(
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
for (const o of
|
|
126
|
-
x[o] =
|
|
127
|
-
a(x),
|
|
121
|
+
if (!t || !e || n <= 0 || typeof requestAnimationFrame > "u" || at())
|
|
122
|
+
return a(t), { cancel: i };
|
|
123
|
+
const d = performance.now(), r = (f) => {
|
|
124
|
+
const p = Math.min(1, (f - d) / n), g = 1 - Math.pow(1 - p, 3), x = { ...t }, k = t.placement === "manual" ? rt : it;
|
|
125
|
+
for (const o of k)
|
|
126
|
+
x[o] = e[o] + (t[o] - e[o]) * g;
|
|
127
|
+
a(x), p < 1 && (l = requestAnimationFrame(r));
|
|
128
128
|
};
|
|
129
|
-
return l = requestAnimationFrame(
|
|
129
|
+
return l = requestAnimationFrame(r), { cancel: i };
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
const { geometry:
|
|
133
|
-
let S = null,
|
|
134
|
-
if (
|
|
135
|
-
const s = Math.max(
|
|
131
|
+
function ut(e) {
|
|
132
|
+
const { geometry: t, strokeWidth: n, radius: a, tailBaseWidth: l } = e, { placement: i, tx: d, ty: r, bx: f, by: p, w: g, h: x } = t, k = parseFloat(a) * (a.endsWith("%") ? Math.min(g, x) / 100 : 1) || 0, o = l / 2, W = (s, c, h) => c > h ? (c + h) / 2 : Math.min(h, Math.max(c, s));
|
|
133
|
+
let S = null, B = 0;
|
|
134
|
+
if (i === "manual") {
|
|
135
|
+
const s = Math.max(f - d, d - (f + g), 0), c = Math.max(p - r, r - (p + x), 0);
|
|
136
136
|
if (s > 0 && s >= c)
|
|
137
|
-
S =
|
|
137
|
+
S = d < f ? "left" : "right", B = r;
|
|
138
138
|
else if (c > 0)
|
|
139
|
-
S =
|
|
139
|
+
S = r < p ? "top" : "bottom", B = d;
|
|
140
140
|
else
|
|
141
141
|
return null;
|
|
142
|
-
} else if (
|
|
143
|
-
const [s, c] =
|
|
144
|
-
S = c === "left" ? "right" : "left",
|
|
142
|
+
} else if (i !== "none") {
|
|
143
|
+
const [s, c] = i.split("-");
|
|
144
|
+
S = c === "left" ? "right" : "left", B = p + x * (s === "top" ? 0.65 : 0.35);
|
|
145
145
|
} else
|
|
146
146
|
return null;
|
|
147
|
-
const $ = 1,
|
|
148
|
-
left: (s, c) => [
|
|
149
|
-
right: (s, c) => [
|
|
150
|
-
top: (s, c) => [s,
|
|
151
|
-
bottom: (s, c) => [s,
|
|
147
|
+
const $ = 1, I = S === "top" || S === "bottom", y = {
|
|
148
|
+
left: (s, c) => [f - c, s],
|
|
149
|
+
right: (s, c) => [f + g + c, s],
|
|
150
|
+
top: (s, c) => [s, p - c],
|
|
151
|
+
bottom: (s, c) => [s, p + x + c]
|
|
152
152
|
}[S], v = {
|
|
153
|
-
left:
|
|
154
|
-
right:
|
|
155
|
-
top:
|
|
156
|
-
bottom:
|
|
157
|
-
}[S],
|
|
158
|
-
const h = y(s, b),
|
|
159
|
-
h[0] + (
|
|
160
|
-
h[1] + (
|
|
153
|
+
left: f - d,
|
|
154
|
+
right: d - f - g,
|
|
155
|
+
top: p - r,
|
|
156
|
+
bottom: r - p - x
|
|
157
|
+
}[S], u = I ? W(B, f + k + o + n / 2, f + g - k - o - n / 2) : W(B, p + k + o + n / 2, p + x - k - o - n / 2), b = Math.max(0, Math.min(n, v / 2)), m = ([s, c]) => `${s} ${c}`, w = (s, c) => {
|
|
158
|
+
const h = y(s, b), M = Math.hypot(d - h[0], r - h[1]) || 1, C = [
|
|
159
|
+
h[0] + (d - h[0]) * b / M,
|
|
160
|
+
h[1] + (r - h[1]) * b / M
|
|
161
161
|
];
|
|
162
162
|
return {
|
|
163
163
|
inner: m(y(s, c)),
|
|
@@ -166,23 +166,23 @@ function ct(n) {
|
|
|
166
166
|
end: m(C)
|
|
167
167
|
};
|
|
168
168
|
}, E = (s) => {
|
|
169
|
-
const c = w(
|
|
170
|
-
return `M ${c.inner} L ${c.outer} Q ${c.ctrl} ${c.end} L ${
|
|
169
|
+
const c = w(u - o, s), h = w(u + o, s);
|
|
170
|
+
return `M ${c.inner} L ${c.outer} Q ${c.ctrl} ${c.end} L ${d} ${r} L ${h.end} Q ${h.ctrl} ${h.outer} L ${h.inner}`;
|
|
171
171
|
};
|
|
172
172
|
return {
|
|
173
|
-
fill: `${E(-
|
|
174
|
-
stroke:
|
|
173
|
+
fill: `${E(-n - $)} Z`,
|
|
174
|
+
stroke: n ? E(-n) : null
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function ct(e) {
|
|
178
178
|
return {
|
|
179
|
-
hasTarget:
|
|
179
|
+
hasTarget: e,
|
|
180
180
|
placement: "none",
|
|
181
181
|
tip: null,
|
|
182
182
|
slotTip: null,
|
|
183
183
|
overlayStyle: {},
|
|
184
184
|
boxStyle: {},
|
|
185
|
-
rootIsBox: !
|
|
185
|
+
rootIsBox: !e,
|
|
186
186
|
tail: null,
|
|
187
187
|
boxFill: "",
|
|
188
188
|
boxStroke: "",
|
|
@@ -190,9 +190,15 @@ function ut(n) {
|
|
|
190
190
|
boxZIndex: "auto"
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function Y(e, t) {
|
|
194
|
+
return e === t ? !0 : !e || !t ? !1 : e.x === t.x && e.y === t.y;
|
|
195
|
+
}
|
|
196
|
+
function dt(e, t) {
|
|
197
|
+
return e.hasTarget === t.hasTarget && e.placement === t.placement && e.rootIsBox === t.rootIsBox && e.boxFill === t.boxFill && e.boxStroke === t.boxStroke && e.boxStrokeWidth === t.boxStrokeWidth && e.boxZIndex === t.boxZIndex && Y(e.tip, t.tip) && Y(e.slotTip, t.slotTip) && A(e.overlayStyle, t.overlayStyle) && A(e.boxStyle, t.boxStyle) && e.tail?.fill === t.tail?.fill && e.tail?.stroke === t.tail?.stroke;
|
|
198
|
+
}
|
|
199
|
+
function ft(e) {
|
|
194
200
|
J();
|
|
195
|
-
let
|
|
201
|
+
let t = { ...Q }, n = null, a = null, l = null, i = {
|
|
196
202
|
left: 0,
|
|
197
203
|
top: 0,
|
|
198
204
|
width: 0,
|
|
@@ -201,51 +207,52 @@ function dt(n) {
|
|
|
201
207
|
scaleY: 1,
|
|
202
208
|
viewportWidth: 0,
|
|
203
209
|
viewportHeight: 0
|
|
204
|
-
},
|
|
210
|
+
}, d = null, r = null, f = null, p = null, g = ct(!1);
|
|
205
211
|
const x = () => {
|
|
206
|
-
|
|
212
|
+
const u = k();
|
|
213
|
+
dt(g, u) || (g = u, e.onChange?.(g));
|
|
207
214
|
};
|
|
208
|
-
function
|
|
209
|
-
const
|
|
215
|
+
function k() {
|
|
216
|
+
const u = t.target != null, b = t.placement === "manual", m = u ? d?.placement ?? "none" : "none", w = {
|
|
210
217
|
position: "absolute",
|
|
211
218
|
inset: "0",
|
|
212
219
|
pointerEvents: "none",
|
|
213
|
-
filter:
|
|
220
|
+
filter: t.shadow ? O : void 0
|
|
214
221
|
}, E = l?.zIndex;
|
|
215
222
|
E && E !== "auto" && (w.zIndex = E);
|
|
216
223
|
const s = {
|
|
217
|
-
"--pb-padding": typeof
|
|
224
|
+
"--pb-padding": typeof t.padding == "number" ? `${t.padding}px` : t.padding
|
|
218
225
|
};
|
|
219
|
-
if (
|
|
220
|
-
s["--pb-width"] = "fit-content",
|
|
226
|
+
if (t.maxWidth != null && (s["--pb-max-width"] = `${t.maxWidth}px`), !u)
|
|
227
|
+
s["--pb-width"] = "fit-content", t.shadow && (s.filter = O);
|
|
221
228
|
else if (Object.assign(s, {
|
|
222
229
|
position: "absolute",
|
|
223
230
|
pointerEvents: "auto",
|
|
224
|
-
visibility:
|
|
231
|
+
visibility: d ? "visible" : "hidden"
|
|
225
232
|
}), b)
|
|
226
233
|
s["--pb-width"] = "fit-content";
|
|
227
234
|
else if (Object.assign(s, {
|
|
228
|
-
left: `${
|
|
229
|
-
top: `${
|
|
235
|
+
left: `${d?.bx ?? 0}px`,
|
|
236
|
+
top: `${d?.by ?? 0}px`,
|
|
230
237
|
margin: "0"
|
|
231
|
-
}),
|
|
232
|
-
const h = P(
|
|
238
|
+
}), t.maxWidth == null && n) {
|
|
239
|
+
const h = P(n, i, t.tailLength), M = r?.placement ?? t.placement, C = M === "auto" ? X(h) : M.split("-")[1];
|
|
233
240
|
s["--pb-max-width"] = `${h[C]}px`;
|
|
234
241
|
}
|
|
235
|
-
const c =
|
|
236
|
-
geometry:
|
|
242
|
+
const c = u && d && l ? ut({
|
|
243
|
+
geometry: d,
|
|
237
244
|
strokeWidth: l.strokeWidth,
|
|
238
245
|
radius: l.radius,
|
|
239
|
-
tailBaseWidth:
|
|
246
|
+
tailBaseWidth: t.tailBaseWidth
|
|
240
247
|
}) : null;
|
|
241
248
|
return {
|
|
242
|
-
hasTarget:
|
|
249
|
+
hasTarget: u,
|
|
243
250
|
placement: m,
|
|
244
|
-
tip:
|
|
245
|
-
slotTip:
|
|
251
|
+
tip: n,
|
|
252
|
+
slotTip: r ? { x: r.tx, y: r.ty } : n,
|
|
246
253
|
overlayStyle: w,
|
|
247
254
|
boxStyle: s,
|
|
248
|
-
rootIsBox: !
|
|
255
|
+
rootIsBox: !u,
|
|
249
256
|
tail: c,
|
|
250
257
|
boxFill: l?.fill ?? "",
|
|
251
258
|
boxStroke: l?.stroke ?? "",
|
|
@@ -254,100 +261,100 @@ function dt(n) {
|
|
|
254
261
|
};
|
|
255
262
|
}
|
|
256
263
|
function o() {
|
|
257
|
-
if (!
|
|
258
|
-
|
|
264
|
+
if (!n || !l) {
|
|
265
|
+
r = null, W(null);
|
|
259
266
|
return;
|
|
260
267
|
}
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
tip:
|
|
268
|
+
const u = P(n, i, t.tailLength);
|
|
269
|
+
r = lt({
|
|
270
|
+
tip: n,
|
|
264
271
|
box: l,
|
|
265
|
-
frame:
|
|
266
|
-
placement:
|
|
267
|
-
targetAnchor:
|
|
272
|
+
frame: i,
|
|
273
|
+
placement: t.placement,
|
|
274
|
+
targetAnchor: t.targetAnchor,
|
|
268
275
|
targetRect: a,
|
|
269
|
-
room:
|
|
270
|
-
tailLength:
|
|
271
|
-
}),
|
|
276
|
+
room: u,
|
|
277
|
+
tailLength: t.tailLength
|
|
278
|
+
}), W(r);
|
|
272
279
|
}
|
|
273
|
-
function
|
|
274
|
-
|
|
280
|
+
function W(u) {
|
|
281
|
+
f?.cancel(), f = st(
|
|
282
|
+
d,
|
|
275
283
|
u,
|
|
276
|
-
|
|
277
|
-
e.transitionDuration,
|
|
284
|
+
t.transitionDuration,
|
|
278
285
|
(b) => {
|
|
279
|
-
|
|
286
|
+
d = b, x();
|
|
280
287
|
}
|
|
281
288
|
);
|
|
282
289
|
}
|
|
283
290
|
function S() {
|
|
284
|
-
const
|
|
285
|
-
if (!b ||
|
|
291
|
+
const u = e.getRootEl(), b = e.getBoxEl();
|
|
292
|
+
if (!b || t.target == null || !u) return;
|
|
286
293
|
const m = ot(
|
|
287
294
|
b,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
295
|
+
u,
|
|
296
|
+
i,
|
|
297
|
+
t.placement === "manual"
|
|
291
298
|
);
|
|
292
|
-
|
|
299
|
+
A(
|
|
293
300
|
m,
|
|
294
301
|
l
|
|
295
302
|
) || (l = m);
|
|
296
303
|
}
|
|
297
|
-
function
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
300
|
-
|
|
304
|
+
function B() {
|
|
305
|
+
const u = e.getRootEl();
|
|
306
|
+
if (t.target == null || !u) {
|
|
307
|
+
n = null, a = null, l = null, r = null, d = null, x();
|
|
301
308
|
return;
|
|
302
309
|
}
|
|
303
|
-
|
|
304
|
-
const b = et(
|
|
310
|
+
i = nt(u);
|
|
311
|
+
const b = et(t.target);
|
|
305
312
|
if (b) {
|
|
306
|
-
const m = b.getBoundingClientRect(), { scaleX: w, scaleY: E, left: s, top: c } =
|
|
313
|
+
const m = b.getBoundingClientRect(), { scaleX: w, scaleY: E, left: s, top: c } = i, h = {
|
|
307
314
|
left: (m.left - s) / w,
|
|
308
315
|
top: (m.top - c) / E,
|
|
309
316
|
right: (m.right - s) / w,
|
|
310
317
|
bottom: (m.bottom - c) / E
|
|
311
318
|
};
|
|
312
|
-
|
|
319
|
+
A(h, a) || (a = h), n = {
|
|
313
320
|
x: (h.left + h.right) / 2,
|
|
314
321
|
y: (h.top + h.bottom) / 2
|
|
315
322
|
};
|
|
316
|
-
} else if (tt(
|
|
317
|
-
a = null,
|
|
323
|
+
} else if (tt(t.target))
|
|
324
|
+
a = null, n = { x: t.target.x, y: t.target.y };
|
|
318
325
|
else {
|
|
319
|
-
a = null,
|
|
326
|
+
a = null, n = null, l = null, r = null, d = null, x();
|
|
320
327
|
return;
|
|
321
328
|
}
|
|
322
329
|
S(), o();
|
|
323
330
|
}
|
|
324
331
|
function $() {
|
|
325
|
-
|
|
332
|
+
B();
|
|
326
333
|
}
|
|
327
334
|
typeof window < "u" && (window.addEventListener("resize", $), window.addEventListener("scroll", $, !0));
|
|
328
|
-
function
|
|
335
|
+
function I() {
|
|
329
336
|
if (typeof ResizeObserver > "u") return;
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
|
|
337
|
+
p?.disconnect(), p = new ResizeObserver(() => B());
|
|
338
|
+
const u = e.getRootEl(), b = e.getBoxEl();
|
|
339
|
+
u && p.observe(u), b && p.observe(b);
|
|
333
340
|
}
|
|
334
|
-
const y =
|
|
341
|
+
const y = B;
|
|
335
342
|
function v() {
|
|
336
|
-
|
|
343
|
+
I(), y();
|
|
337
344
|
}
|
|
338
345
|
return {
|
|
339
346
|
update: v,
|
|
340
|
-
setConfig(
|
|
341
|
-
|
|
347
|
+
setConfig(u) {
|
|
348
|
+
t = { ...t, ...u }, v();
|
|
342
349
|
},
|
|
343
|
-
getConfig: () =>
|
|
350
|
+
getConfig: () => t,
|
|
344
351
|
getState: () => g,
|
|
345
352
|
destroy() {
|
|
346
|
-
|
|
353
|
+
f?.cancel(), p?.disconnect(), typeof window < "u" && (window.removeEventListener("resize", $), window.removeEventListener("scroll", $, !0));
|
|
347
354
|
}
|
|
348
355
|
};
|
|
349
356
|
}
|
|
350
|
-
const
|
|
357
|
+
const pt = ["data-placement"], ht = ["d", "fill"], mt = ["d", "stroke", "stroke-width"], H = /* @__PURE__ */ Z({
|
|
351
358
|
name: "PointingBubble",
|
|
352
359
|
inheritAttrs: !1,
|
|
353
360
|
__name: "PointingBubble",
|
|
@@ -362,8 +369,8 @@ const ft = ["data-placement"], pt = ["d", "fill"], ht = ["d", "stroke", "stroke-
|
|
|
362
369
|
shadow: { type: Boolean, default: !0 },
|
|
363
370
|
transitionDuration: { default: 200 }
|
|
364
371
|
},
|
|
365
|
-
setup(
|
|
366
|
-
const
|
|
372
|
+
setup(e, { expose: t }) {
|
|
373
|
+
const n = e, a = L(null), l = L(null), i = L({
|
|
367
374
|
hasTarget: !1,
|
|
368
375
|
placement: "none",
|
|
369
376
|
tip: null,
|
|
@@ -377,84 +384,82 @@ const ft = ["data-placement"], pt = ["d", "fill"], ht = ["d", "stroke", "stroke-
|
|
|
377
384
|
boxStrokeWidth: 0,
|
|
378
385
|
boxZIndex: "auto"
|
|
379
386
|
});
|
|
380
|
-
function
|
|
387
|
+
function d(o) {
|
|
381
388
|
return o == null ? null : typeof o == "string" || typeof Element < "u" && o instanceof Element ? o : typeof o == "object" && "$el" in o && o.$el instanceof Element ? o.$el : typeof o == "object" && typeof o.x == "number" && typeof o.y == "number" ? o : null;
|
|
382
389
|
}
|
|
383
|
-
const
|
|
390
|
+
const r = ft({
|
|
384
391
|
getRootEl: () => a.value,
|
|
385
392
|
getBoxEl: () => l.value,
|
|
386
393
|
onChange: (o) => {
|
|
387
|
-
|
|
394
|
+
i.value = o;
|
|
388
395
|
}
|
|
389
396
|
});
|
|
390
|
-
function
|
|
391
|
-
|
|
392
|
-
target:
|
|
393
|
-
placement:
|
|
394
|
-
targetAnchor:
|
|
395
|
-
maxWidth:
|
|
396
|
-
tailLength:
|
|
397
|
-
tailBaseWidth:
|
|
398
|
-
padding:
|
|
399
|
-
shadow:
|
|
400
|
-
transitionDuration:
|
|
397
|
+
function f() {
|
|
398
|
+
r.setConfig({
|
|
399
|
+
target: d(n.target),
|
|
400
|
+
placement: n.placement,
|
|
401
|
+
targetAnchor: n.targetAnchor,
|
|
402
|
+
maxWidth: n.maxWidth,
|
|
403
|
+
tailLength: n.tailLength,
|
|
404
|
+
tailBaseWidth: n.tailBaseWidth,
|
|
405
|
+
padding: n.padding,
|
|
406
|
+
shadow: n.shadow,
|
|
407
|
+
transitionDuration: n.transitionDuration
|
|
401
408
|
});
|
|
402
409
|
}
|
|
403
|
-
|
|
410
|
+
q(
|
|
404
411
|
() => [
|
|
405
|
-
|
|
406
|
-
typeof
|
|
407
|
-
typeof
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
412
|
+
n.target,
|
|
413
|
+
typeof n.target == "object" && n.target && "x" in n.target ? n.target.x : null,
|
|
414
|
+
typeof n.target == "object" && n.target && "y" in n.target ? n.target.y : null,
|
|
415
|
+
n.placement,
|
|
416
|
+
n.targetAnchor,
|
|
417
|
+
n.maxWidth,
|
|
418
|
+
n.tailLength,
|
|
419
|
+
n.tailBaseWidth,
|
|
420
|
+
n.padding,
|
|
421
|
+
n.shadow,
|
|
422
|
+
n.transitionDuration
|
|
416
423
|
],
|
|
417
|
-
|
|
424
|
+
f,
|
|
418
425
|
{ flush: "post" }
|
|
419
426
|
), N(() => {
|
|
420
|
-
|
|
421
|
-
}),
|
|
422
|
-
|
|
423
|
-
}), q(() => {
|
|
424
|
-
i.destroy();
|
|
427
|
+
f();
|
|
428
|
+
}), U(() => {
|
|
429
|
+
r.destroy();
|
|
425
430
|
});
|
|
426
|
-
function
|
|
427
|
-
|
|
431
|
+
function p() {
|
|
432
|
+
r.update();
|
|
428
433
|
}
|
|
429
|
-
|
|
434
|
+
t({ update: p });
|
|
430
435
|
const g = R(
|
|
431
|
-
() =>
|
|
432
|
-
), x = R(() =>
|
|
436
|
+
() => i.value.rootIsBox ? i.value.boxStyle : i.value.overlayStyle
|
|
437
|
+
), x = R(() => i.value.rootIsBox ? { display: "contents" } : i.value.boxStyle), k = R(
|
|
433
438
|
() => ({
|
|
434
439
|
position: "absolute",
|
|
435
440
|
inset: "0",
|
|
436
441
|
width: "100%",
|
|
437
442
|
height: "100%",
|
|
438
443
|
overflow: "visible",
|
|
439
|
-
zIndex:
|
|
444
|
+
zIndex: i.value.boxZIndex
|
|
440
445
|
})
|
|
441
446
|
);
|
|
442
|
-
return (o,
|
|
447
|
+
return (o, W) => (z(), T("div", _({
|
|
443
448
|
ref_key: "rootRef",
|
|
444
449
|
ref: a,
|
|
445
|
-
class: ["pointing-bubble", { "pointing-bubble__inner": !
|
|
446
|
-
"data-placement":
|
|
447
|
-
},
|
|
448
|
-
|
|
450
|
+
class: ["pointing-bubble", { "pointing-bubble__inner": !e.target }],
|
|
451
|
+
"data-placement": i.value.placement
|
|
452
|
+
}, e.target ? {} : o.$attrs, { style: g.value }), [
|
|
453
|
+
F("div", _({
|
|
449
454
|
ref_key: "boxRef",
|
|
450
455
|
ref: l,
|
|
451
|
-
class: { "pointing-bubble__inner": !!
|
|
452
|
-
},
|
|
456
|
+
class: { "pointing-bubble__inner": !!e.target }
|
|
457
|
+
}, e.target ? o.$attrs : {}, { style: x.value }), [
|
|
453
458
|
G(o.$slots, "default", {
|
|
454
|
-
placement:
|
|
455
|
-
tip:
|
|
459
|
+
placement: i.value.placement,
|
|
460
|
+
tip: i.value.slotTip
|
|
456
461
|
}, () => [
|
|
457
|
-
|
|
462
|
+
W[0] || (W[0] = F("p", { style: {
|
|
458
463
|
margin: 0,
|
|
459
464
|
fontSize: "14px",
|
|
460
465
|
fontWeight: 600,
|
|
@@ -462,44 +467,44 @@ const ft = ["data-placement"], pt = ["d", "fill"], ht = ["d", "stroke", "stroke-
|
|
|
462
467
|
} }, " Callout content ", -1))
|
|
463
468
|
])
|
|
464
469
|
], 16),
|
|
465
|
-
|
|
470
|
+
e.target && i.value.tail ? (z(), T("svg", {
|
|
466
471
|
key: 0,
|
|
467
472
|
class: "pointing-bubble__svg",
|
|
468
|
-
style: K(
|
|
473
|
+
style: K(k.value)
|
|
469
474
|
}, [
|
|
470
|
-
|
|
475
|
+
F("path", {
|
|
471
476
|
class: "pointing-bubble__path",
|
|
472
|
-
d:
|
|
473
|
-
fill:
|
|
474
|
-
}, null, 8,
|
|
475
|
-
|
|
477
|
+
d: i.value.tail.fill,
|
|
478
|
+
fill: i.value.boxFill
|
|
479
|
+
}, null, 8, ht),
|
|
480
|
+
i.value.tail.stroke ? (z(), T("path", {
|
|
476
481
|
key: 0,
|
|
477
482
|
class: "pointing-bubble__path",
|
|
478
|
-
d:
|
|
483
|
+
d: i.value.tail.stroke,
|
|
479
484
|
fill: "none",
|
|
480
|
-
stroke:
|
|
481
|
-
"stroke-width":
|
|
485
|
+
stroke: i.value.boxStroke,
|
|
486
|
+
"stroke-width": i.value.boxStrokeWidth,
|
|
482
487
|
"stroke-linejoin": "round",
|
|
483
488
|
"stroke-linecap": "butt"
|
|
484
|
-
}, null, 8,
|
|
485
|
-
], 4)) :
|
|
486
|
-
], 16,
|
|
489
|
+
}, null, 8, mt)) : D("", !0)
|
|
490
|
+
], 4)) : D("", !0)
|
|
491
|
+
], 16, pt));
|
|
487
492
|
}
|
|
488
493
|
}), bt = {
|
|
489
|
-
install(
|
|
490
|
-
const
|
|
491
|
-
|
|
494
|
+
install(e, t = {}) {
|
|
495
|
+
const n = t.name ?? "PointingBubble";
|
|
496
|
+
e.component(n, H), e.component("Callout", H);
|
|
492
497
|
}
|
|
493
498
|
};
|
|
494
499
|
export {
|
|
495
|
-
|
|
500
|
+
H as Callout,
|
|
496
501
|
Q as DEFAULT_BUBBLE_CONFIG,
|
|
497
|
-
|
|
502
|
+
H as PointingBubble,
|
|
498
503
|
bt as PointingBubblePlugin,
|
|
499
|
-
|
|
504
|
+
ut as buildTailPaths,
|
|
500
505
|
lt as computeGeometry,
|
|
501
|
-
|
|
502
|
-
|
|
506
|
+
ft as createBubbleController,
|
|
507
|
+
H as default,
|
|
503
508
|
tt as isPoint,
|
|
504
509
|
et as resolveElement
|
|
505
510
|
};
|