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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("vue"),T={target:null,placement:"auto",targetAnchor:"center",tailLength:45,tailBaseWidth:24,padding:8,shadow:!0,transitionDuration:200},I="pointing-bubble-styles",U=`:where(.pointing-bubble__inner) {
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 U, ref as L, watch as X, onMounted as N, onUpdated as Z, onBeforeUnmount as q, computed as R, openBlock as I, createElementBlock as z, mergeProps as F, createElementVNode as _, renderSlot as G, normalizeStyle as K, createCommentVNode as T } from "vue";
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
- }, D = "pointing-bubble-styles", V = `:where(.pointing-bubble__inner) {
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
- }`, j = "drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";
20
- function J(n = document) {
21
- if (n.getElementById(D)) return;
22
- const e = n.createElement("style");
23
- e.id = D, e.textContent = V, n.head.prepend(e);
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(n) {
26
- return typeof n == "object" && n !== null && typeof n.x == "number" && typeof n.y == "number" && n.nodeType !== 1;
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(n) {
29
- return typeof Element > "u" || n == null ? null : typeof n == "string" ? document.querySelector(n) : n instanceof Element ? n : null;
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 O(n, e) {
32
- return !n || !e ? !1 : Object.keys(n).every((t) => n[t] === e[t]);
31
+ function A(e, t) {
32
+ return !e || !t ? !1 : Object.keys(e).every((n) => e[n] === t[n]);
33
33
  }
34
- function nt(n) {
35
- const e = n.getBoundingClientRect(), t = getComputedStyle(n), a = parseFloat(t.width) || 0, l = parseFloat(t.height) || 0;
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: e.left,
38
- top: e.top,
37
+ left: t.left,
38
+ top: t.top,
39
39
  width: a,
40
40
  height: l,
41
- scaleX: a ? e.width / a : 1,
42
- scaleY: l ? e.height / l : 1,
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(n, e, t, a) {
48
- const l = getComputedStyle(n), { scaleX: r, scaleY: u } = t, i = n.getBoundingClientRect(), d = e.getBoundingClientRect();
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 ? (i.left - d.left) / r : 0,
51
- y: a ? (i.top - d.top) / u : 0,
52
- width: i.width / r,
53
- height: i.height / u,
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(n, e, t) {
62
- const a = n.x - t;
63
- let l = a, r = e.width ? e.width - n.x - t : 1 / 0;
64
- return e.viewportWidth && (l = Math.min(l, e.left / e.scaleX + a), r = Math.min(
65
- r,
66
- (e.viewportWidth - e.left) / e.scaleX - n.x - t
67
- )), { left: Math.max(0, l), right: Math.max(0, r) };
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 H(n) {
70
- return n.left > n.right ? "left" : "right";
69
+ function X(e) {
70
+ return e.left > e.right ? "left" : "right";
71
71
  }
72
- function lt(n) {
73
- const { tip: e, box: t, frame: a, placement: l, targetRect: r, room: u, tailLength: i } = n;
74
- if (!t.width || !t.height) return null;
75
- const { width: d, height: f } = t, { x: g, y: x } = e, W = l === "manual", o = n.targetAnchor === "edge" ? r : null;
76
- if (W) {
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 = t.x + d / 2, v = t.y + f / 2;
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: t.x, by: t.y, w: d, h: f };
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: t.x, by: t.y, w: d, h: f };
84
+ return { placement: "manual", tx: g, ty: x, bx: n.x, by: n.y, w: f, h: p };
85
85
  }
86
- const B = (y) => o ? y === "top" ? o.top : o.bottom : x;
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 = H(u);
90
- const { scaleX: p, scaleY: b } = a;
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 + (B("top") - f - i) * b >= 0, w = a.top + (B("bottom") + f + i) * b <= a.viewportHeight;
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 - d - i) * p >= 0, w = a.left + (g + d + i) * p <= a.viewportWidth;
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 [k, $] = S.split("-"), M = B(k);
101
+ const [B, $] = S.split("-"), I = W(B);
102
102
  return {
103
103
  placement: S,
104
104
  tx: g,
105
- ty: M,
106
- bx: $ === "left" ? g - d - i : g + i,
107
- by: k === "top" ? M - f - i : M + i,
108
- w: d,
109
- h: f
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(n, e, t, a) {
116
+ function st(e, t, n, a) {
117
117
  let l = 0;
118
- const r = () => {
118
+ const i = () => {
119
119
  typeof cancelAnimationFrame < "u" && cancelAnimationFrame(l);
120
120
  };
121
- if (!e || !n || t <= 0 || typeof requestAnimationFrame > "u" || at())
122
- return a(e), { cancel: r };
123
- const u = performance.now(), i = (d) => {
124
- const f = Math.min(1, (d - u) / t), g = 1 - Math.pow(1 - f, 3), x = { ...e }, W = e.placement === "manual" ? rt : it;
125
- for (const o of W)
126
- x[o] = n[o] + (e[o] - n[o]) * g;
127
- a(x), f < 1 && (l = requestAnimationFrame(i));
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(i), { cancel: r };
129
+ return l = requestAnimationFrame(r), { cancel: i };
130
130
  }
131
- function ct(n) {
132
- const { geometry: e, strokeWidth: t, radius: a, tailBaseWidth: l } = n, { placement: r, tx: u, ty: i, bx: d, by: f, w: g, h: x } = e, W = parseFloat(a) * (a.endsWith("%") ? Math.min(g, x) / 100 : 1) || 0, o = l / 2, B = (s, c, h) => c > h ? (c + h) / 2 : Math.min(h, Math.max(c, s));
133
- let S = null, k = 0;
134
- if (r === "manual") {
135
- const s = Math.max(d - u, u - (d + g), 0), c = Math.max(f - i, i - (f + x), 0);
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 = u < d ? "left" : "right", k = i;
137
+ S = d < f ? "left" : "right", B = r;
138
138
  else if (c > 0)
139
- S = i < f ? "top" : "bottom", k = u;
139
+ S = r < p ? "top" : "bottom", B = d;
140
140
  else
141
141
  return null;
142
- } else if (r !== "none") {
143
- const [s, c] = r.split("-");
144
- S = c === "left" ? "right" : "left", k = f + x * (s === "top" ? 0.65 : 0.35);
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, M = S === "top" || S === "bottom", y = {
148
- left: (s, c) => [d - c, s],
149
- right: (s, c) => [d + g + c, s],
150
- top: (s, c) => [s, f - c],
151
- bottom: (s, c) => [s, f + x + c]
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: d - u,
154
- right: u - d - g,
155
- top: f - i,
156
- bottom: i - f - x
157
- }[S], p = M ? B(k, d + W + o + t / 2, d + g - W - o - t / 2) : B(k, f + W + o + t / 2, f + x - W - o - t / 2), b = Math.max(0, Math.min(t, v / 2)), m = ([s, c]) => `${s} ${c}`, w = (s, c) => {
158
- const h = y(s, b), A = Math.hypot(u - h[0], i - h[1]) || 1, C = [
159
- h[0] + (u - h[0]) * b / A,
160
- h[1] + (i - h[1]) * b / A
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(p - o, s), h = w(p + o, s);
170
- 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}`;
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(-t - $)} Z`,
174
- stroke: t ? E(-t) : null
173
+ fill: `${E(-n - $)} Z`,
174
+ stroke: n ? E(-n) : null
175
175
  };
176
176
  }
177
- function ut(n) {
177
+ function ct(e) {
178
178
  return {
179
- hasTarget: n,
179
+ hasTarget: e,
180
180
  placement: "none",
181
181
  tip: null,
182
182
  slotTip: null,
183
183
  overlayStyle: {},
184
184
  boxStyle: {},
185
- rootIsBox: !n,
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 dt(n) {
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 e = { ...Q }, t = null, a = null, l = null, r = {
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
- }, u = null, i = null, d = null, f = null, g = ut(!1);
210
+ }, d = null, r = null, f = null, p = null, g = ct(!1);
205
211
  const x = () => {
206
- g = W(), n.onChange?.(g);
212
+ const u = k();
213
+ dt(g, u) || (g = u, e.onChange?.(g));
207
214
  };
208
- function W() {
209
- const p = e.target != null, b = e.placement === "manual", m = p ? u?.placement ?? "none" : "none", w = {
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: e.shadow ? j : void 0
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 e.padding == "number" ? `${e.padding}px` : e.padding
224
+ "--pb-padding": typeof t.padding == "number" ? `${t.padding}px` : t.padding
218
225
  };
219
- if (e.maxWidth != null && (s["--pb-max-width"] = `${e.maxWidth}px`), !p)
220
- s["--pb-width"] = "fit-content", e.shadow && (s.filter = j);
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: u ? "visible" : "hidden"
231
+ visibility: d ? "visible" : "hidden"
225
232
  }), b)
226
233
  s["--pb-width"] = "fit-content";
227
234
  else if (Object.assign(s, {
228
- left: `${u?.bx ?? 0}px`,
229
- top: `${u?.by ?? 0}px`,
235
+ left: `${d?.bx ?? 0}px`,
236
+ top: `${d?.by ?? 0}px`,
230
237
  margin: "0"
231
- }), e.maxWidth == null && t) {
232
- const h = P(t, r, e.tailLength), A = i?.placement ?? e.placement, C = A === "auto" ? H(h) : A.split("-")[1];
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 = p && u && l ? ct({
236
- geometry: u,
242
+ const c = u && d && l ? ut({
243
+ geometry: d,
237
244
  strokeWidth: l.strokeWidth,
238
245
  radius: l.radius,
239
- tailBaseWidth: e.tailBaseWidth
246
+ tailBaseWidth: t.tailBaseWidth
240
247
  }) : null;
241
248
  return {
242
- hasTarget: p,
249
+ hasTarget: u,
243
250
  placement: m,
244
- tip: t,
245
- slotTip: i ? { x: i.tx, y: i.ty } : t,
251
+ tip: n,
252
+ slotTip: r ? { x: r.tx, y: r.ty } : n,
246
253
  overlayStyle: w,
247
254
  boxStyle: s,
248
- rootIsBox: !p,
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 (!t || !l) {
258
- i = null, B(null);
264
+ if (!n || !l) {
265
+ r = null, W(null);
259
266
  return;
260
267
  }
261
- const p = P(t, r, e.tailLength);
262
- i = lt({
263
- tip: t,
268
+ const u = P(n, i, t.tailLength);
269
+ r = lt({
270
+ tip: n,
264
271
  box: l,
265
- frame: r,
266
- placement: e.placement,
267
- targetAnchor: e.targetAnchor,
272
+ frame: i,
273
+ placement: t.placement,
274
+ targetAnchor: t.targetAnchor,
268
275
  targetRect: a,
269
- room: p,
270
- tailLength: e.tailLength
271
- }), B(i);
276
+ room: u,
277
+ tailLength: t.tailLength
278
+ }), W(r);
272
279
  }
273
- function B(p) {
274
- d?.cancel(), d = st(
280
+ function W(u) {
281
+ f?.cancel(), f = st(
282
+ d,
275
283
  u,
276
- p,
277
- e.transitionDuration,
284
+ t.transitionDuration,
278
285
  (b) => {
279
- u = b, x();
286
+ d = b, x();
280
287
  }
281
288
  );
282
289
  }
283
290
  function S() {
284
- const p = n.getRootEl(), b = n.getBoxEl();
285
- if (!b || e.target == null || !p) return;
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
- p,
289
- r,
290
- e.placement === "manual"
295
+ u,
296
+ i,
297
+ t.placement === "manual"
291
298
  );
292
- O(
299
+ A(
293
300
  m,
294
301
  l
295
302
  ) || (l = m);
296
303
  }
297
- function k() {
298
- const p = n.getRootEl();
299
- if (e.target == null || !p) {
300
- t = null, a = null, l = null, i = null, u = null, x();
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
- r = nt(p);
304
- const b = et(e.target);
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 } = r, h = {
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
- O(h, a) || (a = h), t = {
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(e.target))
317
- a = null, t = { x: e.target.x, y: e.target.y };
323
+ } else if (tt(t.target))
324
+ a = null, n = { x: t.target.x, y: t.target.y };
318
325
  else {
319
- a = null, t = null, l = null, i = null, u = null, x();
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
- k();
332
+ B();
326
333
  }
327
334
  typeof window < "u" && (window.addEventListener("resize", $), window.addEventListener("scroll", $, !0));
328
- function M() {
335
+ function I() {
329
336
  if (typeof ResizeObserver > "u") return;
330
- f?.disconnect(), f = new ResizeObserver(() => k());
331
- const p = n.getRootEl(), b = n.getBoxEl();
332
- p && f.observe(p), b && f.observe(b);
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 = k;
341
+ const y = B;
335
342
  function v() {
336
- M(), y();
343
+ I(), y();
337
344
  }
338
345
  return {
339
346
  update: v,
340
- setConfig(p) {
341
- e = { ...e, ...p }, v();
347
+ setConfig(u) {
348
+ t = { ...t, ...u }, v();
342
349
  },
343
- getConfig: () => e,
350
+ getConfig: () => t,
344
351
  getState: () => g,
345
352
  destroy() {
346
- d?.cancel(), f?.disconnect(), typeof window < "u" && (window.removeEventListener("resize", $), window.removeEventListener("scroll", $, !0));
353
+ f?.cancel(), p?.disconnect(), typeof window < "u" && (window.removeEventListener("resize", $), window.removeEventListener("scroll", $, !0));
347
354
  }
348
355
  };
349
356
  }
350
- const ft = ["data-placement"], pt = ["d", "fill"], ht = ["d", "stroke", "stroke-width"], Y = /* @__PURE__ */ U({
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(n, { expose: e }) {
366
- const t = n, a = L(null), l = L(null), r = L({
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 u(o) {
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 i = dt({
390
+ const r = ft({
384
391
  getRootEl: () => a.value,
385
392
  getBoxEl: () => l.value,
386
393
  onChange: (o) => {
387
- r.value = o;
394
+ i.value = o;
388
395
  }
389
396
  });
390
- function d() {
391
- i.setConfig({
392
- target: u(t.target),
393
- placement: t.placement,
394
- targetAnchor: t.targetAnchor,
395
- maxWidth: t.maxWidth,
396
- tailLength: t.tailLength,
397
- tailBaseWidth: t.tailBaseWidth,
398
- padding: t.padding,
399
- shadow: t.shadow,
400
- transitionDuration: t.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
- X(
410
+ q(
404
411
  () => [
405
- t.target,
406
- typeof t.target == "object" && t.target && "x" in t.target ? t.target.x : null,
407
- typeof t.target == "object" && t.target && "y" in t.target ? t.target.y : null,
408
- t.placement,
409
- t.targetAnchor,
410
- t.maxWidth,
411
- t.tailLength,
412
- t.tailBaseWidth,
413
- t.padding,
414
- t.shadow,
415
- t.transitionDuration
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
- d,
424
+ f,
418
425
  { flush: "post" }
419
426
  ), N(() => {
420
- d();
421
- }), Z(() => {
422
- i.update();
423
- }), q(() => {
424
- i.destroy();
427
+ f();
428
+ }), U(() => {
429
+ r.destroy();
425
430
  });
426
- function f() {
427
- i.update();
431
+ function p() {
432
+ r.update();
428
433
  }
429
- e({ update: f });
434
+ t({ update: p });
430
435
  const g = R(
431
- () => r.value.rootIsBox ? r.value.boxStyle : r.value.overlayStyle
432
- ), x = R(() => r.value.rootIsBox ? { display: "contents" } : r.value.boxStyle), W = 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: r.value.boxZIndex
444
+ zIndex: i.value.boxZIndex
440
445
  })
441
446
  );
442
- return (o, B) => (I(), z("div", F({
447
+ return (o, W) => (z(), T("div", _({
443
448
  ref_key: "rootRef",
444
449
  ref: a,
445
- class: ["pointing-bubble", { "pointing-bubble__inner": !n.target }],
446
- "data-placement": r.value.placement
447
- }, n.target ? {} : o.$attrs, { style: g.value }), [
448
- _("div", F({
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": !!n.target }
452
- }, n.target ? o.$attrs : {}, { style: x.value }), [
456
+ class: { "pointing-bubble__inner": !!e.target }
457
+ }, e.target ? o.$attrs : {}, { style: x.value }), [
453
458
  G(o.$slots, "default", {
454
- placement: r.value.placement,
455
- tip: r.value.slotTip
459
+ placement: i.value.placement,
460
+ tip: i.value.slotTip
456
461
  }, () => [
457
- B[0] || (B[0] = _("p", { style: {
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
- n.target && r.value.tail ? (I(), z("svg", {
470
+ e.target && i.value.tail ? (z(), T("svg", {
466
471
  key: 0,
467
472
  class: "pointing-bubble__svg",
468
- style: K(W.value)
473
+ style: K(k.value)
469
474
  }, [
470
- _("path", {
475
+ F("path", {
471
476
  class: "pointing-bubble__path",
472
- d: r.value.tail.fill,
473
- fill: r.value.boxFill
474
- }, null, 8, pt),
475
- r.value.tail.stroke ? (I(), z("path", {
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: r.value.tail.stroke,
483
+ d: i.value.tail.stroke,
479
484
  fill: "none",
480
- stroke: r.value.boxStroke,
481
- "stroke-width": r.value.boxStrokeWidth,
485
+ stroke: i.value.boxStroke,
486
+ "stroke-width": i.value.boxStrokeWidth,
482
487
  "stroke-linejoin": "round",
483
488
  "stroke-linecap": "butt"
484
- }, null, 8, ht)) : T("", !0)
485
- ], 4)) : T("", !0)
486
- ], 16, ft));
489
+ }, null, 8, mt)) : D("", !0)
490
+ ], 4)) : D("", !0)
491
+ ], 16, pt));
487
492
  }
488
493
  }), bt = {
489
- install(n, e = {}) {
490
- const t = e.name ?? "PointingBubble";
491
- n.component(t, Y), n.component("Callout", Y);
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
- Y as Callout,
500
+ H as Callout,
496
501
  Q as DEFAULT_BUBBLE_CONFIG,
497
- Y as PointingBubble,
502
+ H as PointingBubble,
498
503
  bt as PointingBubblePlugin,
499
- ct as buildTailPaths,
504
+ ut as buildTailPaths,
500
505
  lt as computeGeometry,
501
- dt as createBubbleController,
502
- Y as default,
506
+ ft as createBubbleController,
507
+ H as default,
503
508
  tt as isPoint,
504
509
  et as resolveElement
505
510
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-pointing-bubble",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Vue 3 callout / speech bubble whose SVG tail points exactly at coordinates or a DOM element.",
5
5
  "type": "module",
6
6
  "sideEffects": false,