vue-pointing-bubble 0.5.1 → 0.6.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/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { PointingBubble, PointingBubble as Callout, PointingBubble as default, PointingBubblePlugin, type PointingBubblePluginOptions, } from './pointing-bubble';
1
+ export { PointingBubble, PointingBubble as default, } from './pointing-bubble';
2
2
  export type { Placement, ResolvedPlacement, TargetAnchor, Point, BubbleTarget, BubbleConfig, BubbleController, BubbleRenderState, } from './pointing-bubble';
3
3
  export { DEFAULT_BUBBLE_CONFIG, createBubbleController, resolveElement, isPoint, computeGeometry, buildTailPaths, } from './pointing-bubble';
@@ -1,11 +1,5 @@
1
- import { Plugin } from 'vue';
2
1
  import { default as PointingBubble } from './PointingBubble.vue';
3
2
  export type { Placement, ResolvedPlacement, TargetAnchor, Point, BubbleTarget, BubbleConfig, BubbleController, BubbleRenderState, } from './core';
4
3
  export { DEFAULT_BUBBLE_CONFIG, createBubbleController, resolveElement, isPoint, computeGeometry, buildTailPaths, } from './core';
5
4
  export { PointingBubble };
6
- export { PointingBubble as Callout };
7
5
  export { PointingBubble as default };
8
- export interface PointingBubblePluginOptions {
9
- name?: string;
10
- }
11
- export declare const PointingBubblePlugin: Plugin;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("vue"),Z={target:null,placement:"auto",targetAnchor:"center",tailLength:45,tailBaseWidth:24,padding:8,shadow:!0,transitionDuration:200},U="pointing-bubble-styles",ot=`:where(.pointing-bubble__inner) {
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("vue"),G={target:null,placement:"auto",targetAnchor:"center",tailLength:45,tailBaseWidth:24,padding:8,shadow:!0,transitionDuration:200},H="pointing-bubble-styles",ot=`: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
- }`,lt="drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";function it(e=document){if(e.getElementById(U))return;const t=e.createElement("style");t.id=U,t.textContent=ot,e.head.prepend(t)}function K(e){return typeof e=="object"&&e!==null&&typeof e.x=="number"&&typeof e.y=="number"&&e.nodeType!==1}function q(e){return typeof Element>"u"||e==null?null:typeof e=="string"?document.querySelector(e):e instanceof Element?e:null}function Y(e,t){return!e||!t?!1:Object.keys(e).every(n=>e[n]===t[n])}function J(e){let t=e.parentElement;for(;t;){const n=getComputedStyle(t).position;if(n&&n!=="static")return t;if(t===document.documentElement)break;t=t.parentElement}return document.documentElement}function rt(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),l=parseFloat(n.width)||0,o=parseFloat(n.height)||0;return{left:t.left,top:t.top,width:l,height:o,scaleX:l?t.width/l:1,scaleY:o?t.height/o:1,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function st(e){return rt(J(e))}function at(e,t){const n=getComputedStyle(e),{scaleX:l,scaleY:o,left:u,top:a}=t,i=e.getBoundingClientRect();return{x:(i.left-u)/l,y:(i.top-a)/o,width:i.width/l,height:i.height/o,fill:n.backgroundColor,stroke:n.borderTopColor,strokeWidth:parseFloat(n.borderTopWidth)||0,borderLeft:(parseFloat(n.borderLeftWidth)||0)/l,borderTop:(parseFloat(n.borderTopWidth)||0)/o,radius:n.borderTopLeftRadius,zIndex:n.zIndex}}function V(e,t,n){const l=e.x-n;let o=l,u=t.width?t.width-e.x-n:1/0;return t.viewportWidth&&(o=Math.min(o,t.left/t.scaleX+l),u=Math.min(u,(t.viewportWidth-t.left)/t.scaleX-e.x-n)),{left:Math.max(0,o),right:Math.max(0,u)}}function Q(e){return e.left>e.right?"left":"right"}function tt(e){const{tip:t,box:n,frame:l,placement:o,targetRect:u,room:a,tailLength:i}=e;if(!n.width||!n.height)return null;const{width:r,height:f}=n,{x:h,y:g}=t,E=o==="manual",c=e.targetAnchor==="edge"?u:null;if(E){if(c){const k=n.x+r/2,B=n.y+f/2;if(!(k>=c.left&&k<=c.right&&B>=c.top&&B<=c.bottom)){const b=Math.min(c.right,Math.max(c.left,k)),W=Math.min(c.bottom,Math.max(c.top,B));return{placement:"manual",tx:b,ty:W,bx:n.x,by:n.y,w:r,h:f}}}return{placement:"manual",tx:h,ty:g,bx:n.x,by:n.y,w:r,h:f}}const _=k=>c?k==="top"?c.top:c.bottom:g;let w=o;if(o==="auto"){let k=g>(l.height||600)/2?"top":"bottom",B=Q(a);const{scaleX:$,scaleY:b}=l;if(l.viewportHeight){const W=l.top+(_("top")-f-i)*b>=0,A=l.top+(_("bottom")+f+i)*b<=l.viewportHeight;k==="top"&&!W&&A?k="bottom":k==="bottom"&&!A&&W&&(k="top")}if(l.viewportWidth){const W=l.left+(h-r-i)*$>=0,A=l.left+(h+r+i)*$<=l.viewportWidth;B==="left"&&!W&&A?B="right":B==="right"&&!A&&W&&(B="left")}w=`${k}-${B}`}const[d,T]=w.split("-"),v=_(d);return{placement:w,tx:h,ty:v,bx:T==="left"?h-r-i:h+i,by:d==="top"?v-f-i:v+i,w:r,h:f}}const ct=["tx","ty","bx","by"],ut=["tx","ty"];function dt(){return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function ft(e,t,n,l){let o=0;const u=()=>{typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(o)};if(!t||!e||n<=0||typeof requestAnimationFrame>"u"||dt())return l(t),{cancel:u};const a=performance.now(),i=r=>{const f=Math.min(1,(r-a)/n),h=1-Math.pow(1-f,3),g={...t},E=t.placement==="manual"?ut:ct;for(const c of E)g[c]=e[c]+(t[c]-e[c])*h;l(g),f<1&&(o=requestAnimationFrame(i))};return o=requestAnimationFrame(i),{cancel:u}}function et(e){const{geometry:t,strokeWidth:n,radius:l,tailBaseWidth:o}=e,{placement:u,tx:a,ty:i,bx:r,by:f,w:h,h:g}=t,E=parseFloat(l)*(l.endsWith("%")?Math.min(h,g)/100:1)||0,c=o/2,_=(y,m,P)=>m>P?(m+P)/2:Math.min(P,Math.max(m,y));let w=null,d=0;if(u==="manual"){const y=Math.max(r-a,a-(r+h),0),m=Math.max(f-i,i-(f+g),0);if(y>0&&y>=m)w=a<r?"left":"right",d=i;else if(m>0)w=i<f?"top":"bottom",d=a;else return null}else if(u!=="none"){const[y,m]=u.split("-");w=m==="left"?"right":"left",d=f+g*(y==="top"?.65:.35)}else return null;const T=w==="top"||w==="bottom",v={left:(y,m)=>[r-m,y],right:(y,m)=>[r+h+m,y],top:(y,m)=>[y,f-m],bottom:(y,m)=>[y,f+g+m]}[w],k=T?r:f,B=T?r+h:f+g,$=_(d,k+c+n/2+E,B-c-n/2-E),b=([y,m])=>`${y} ${m}`,W=n>0?-n/2:0,A=2,j=2,s=$-c,x=$+c,z=v(s-A,W),S=v(s,W),C=v(x,W),M=v(x+A,W),F=v(s,-(n+j)),O=v(x,-(n+j)),L=v(s,1),I=v(x,1);return{fill:`M ${b(F)} L ${b(L)} L ${b(S)} L ${a} ${i} L ${b(C)} L ${b(I)} L ${b(O)} Z`,stroke:n?`M ${b(z)} L ${b(S)} L ${a} ${i} L ${b(C)} L ${b(M)}`:null}}const pt=["left","top","right","bottom","width","height","transform","translate","inset","inset-inline","inset-block"];function ht(e){return{hasTarget:e,placement:"none",tip:null,slotTip:null,boxStyle:{},svgStyle:{},tail:null,boxFill:"",boxStroke:"",boxStrokeWidth:0,boxZIndex:"auto"}}function N(e,t){return e===t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function mt(e,t){return e===t?!0:!e||!t?!1:e.placement===t.placement&&e.tx===t.tx&&e.ty===t.ty&&e.bx===t.bx&&e.by===t.by&&e.w===t.w&&e.h===t.h}function gt(e,t){return e.hasTarget===t.hasTarget&&e.placement===t.placement&&e.boxFill===t.boxFill&&e.boxStroke===t.boxStroke&&e.boxStrokeWidth===t.boxStrokeWidth&&e.boxZIndex===t.boxZIndex&&N(e.tip,t.tip)&&N(e.slotTip,t.slotTip)&&Y(e.boxStyle,t.boxStyle)&&Y(e.svgStyle,t.svgStyle)&&e.tail?.fill===t.tail?.fill&&e.tail?.stroke===t.tail?.stroke}function X(e){if(typeof e.checkVisibility=="function")return e.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});const t=getComputedStyle(e);return!(t.display==="none"||t.visibility==="hidden"||parseFloat(t.opacity)===0)}function G(e){const t=e.style;return pt.map(n=>t.getPropertyValue(n)).join("|")}function nt(e){it();let t={...Z},n=null,l=null,o=null,u={left:0,top:0,width:0,height:0,scaleX:1,scaleY:1,viewportWidth:0,viewportHeight:0},a=null,i=null,r=null,f=null,h=null,g=null,E=ht(!1),c=!1,_="";const w=()=>{const s=d();gt(E,s)||(E=s,e.onChange?.(E))};function d(){const s=t.target!=null,x=t.placement==="manual",z=s?a?.placement??"none":"none",S={"--pb-padding":typeof t.padding=="number"?`${t.padding}px`:t.padding};if(t.maxWidth!=null&&(S["--pb-max-width"]=`${t.maxWidth}px`),t.shadow&&(S.filter=lt),!s)S["--pb-width"]="fit-content";else if(Object.assign(S,{position:"absolute",pointerEvents:"auto",overflow:"visible"}),x)S["--pb-width"]="fit-content";else if(Object.assign(S,{left:`${a?.bx??0}px`,top:`${a?.by??0}px`,margin:"0"}),t.maxWidth==null&&n){const O=V(n,u,t.tailLength),L=i?.placement??t.placement,I=L==="auto"?Q(O):L.split("-")[1];S["--pb-max-width"]=`${O[I]}px`}const C=o?.zIndex;C&&C!=="auto"&&(S.zIndex=C);const M=s&&a&&o?et({geometry:a,strokeWidth:o.strokeWidth,radius:o.radius,tailBaseWidth:t.tailBaseWidth}):null;let F={};if(M&&a&&u.width&&u.height){const O=o?.borderLeft??0,L=o?.borderTop??0;F={position:"absolute",left:`${-a.bx-O}px`,top:`${-a.by-L}px`,width:`${u.width}px`,height:`${u.height}px`,overflow:"visible",pointerEvents:"none",zIndex:o?.zIndex??"auto"}}return{hasTarget:s,placement:z,tip:n,slotTip:i?{x:i.tx,y:i.ty}:n,boxStyle:S,svgStyle:F,tail:M,boxFill:o?.fill??"",boxStroke:o?.stroke??"",boxStrokeWidth:o?.strokeWidth??0,boxZIndex:o?.zIndex??"auto"}}function T(){if(!n||!o){(i!==null||a!==null)&&(i=null,v(null));return}const s=V(n,u,t.tailLength),x=tt({tip:n,box:o,frame:u,placement:t.placement,targetAnchor:t.targetAnchor,targetRect:l,room:s,tailLength:t.tailLength});mt(i,x)||(i=x,v(i))}function v(s){r?.cancel(),r=ft(a,s,t.transitionDuration,x=>{a=x,w()})}function k(s){const x=at(s,u);return Y(x,o)?!1:(o=x,!0)}function B(){const s=e.getBoxEl();if(!s){n=null,l=null,o=null,i=null,a=null,c=!1,w();return}if(!X(s)){r?.cancel(),c=!0;return}const x=c;if(c=!1,t.target==null){n=null,l=null,o=null,i=null,a=null,w();return}const z=u;u=st(s);const S=!Y(u,z),C=typeof t.target=="string"?J(s).querySelector(t.target)??q(t.target):q(t.target);let M=!1,F=!1;if(C){const L=C.getBoundingClientRect(),{scaleX:I,scaleY:y,left:m,top:P}=u,R={left:(L.left-m)/I,top:(L.top-P)/y,right:(L.right-m)/I,bottom:(L.bottom-P)/y};F=!Y(R,l),F&&(l=R);const H={x:(R.left+R.right)/2,y:(R.top+R.bottom)/2};M=!N(n,H),n=H}else if(K(t.target)){F=l!=null,l=null;const L={x:t.target.x,y:t.target.y};M=!N(n,L),n=L}else{n=null,l=null,o=null,i=null,a=null,w();return}const O=k(s);_=G(s),!(!x&&!S&&!M&&!F&&!O&&a)&&T()}function $(){B()}typeof window<"u"&&(window.addEventListener("resize",$),window.addEventListener("scroll",$,!0));const b=B;function W(s){const x=e.getBoxEl();if(!x)return;if(s.some(C=>C.attributeName==="class"||C.attributeName==="hidden")){if(!X(x)){r?.cancel(),c=!0;return}b();return}const S=G(x);S!==_&&(_=S,b())}function A(){const s=e.getBoxEl();s!==g&&(g=s,f?.disconnect(),h?.disconnect(),f=null,h=null,s&&(typeof ResizeObserver<"u"&&(f=new ResizeObserver(()=>b()),f.observe(s)),typeof MutationObserver<"u"&&(h=new MutationObserver(W),h.observe(s,{attributes:!0,attributeFilter:["style","class","hidden"]}))))}function j(){A(),b()}return{update:j,setConfig(s){t={...t,...s},j()},getConfig:()=>t,getState:()=>E,destroy(){r?.cancel(),f?.disconnect(),h?.disconnect(),g=null,typeof window<"u"&&(window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0))}}}const bt=["data-placement"],xt=["d","fill"],yt=["d","stroke","stroke-width"],D=p.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,l=p.useAttrs(),o=p.computed(()=>l.class),u=p.computed(()=>l.style),a=p.computed(()=>{const{class:d,style:T,...v}=l;return v}),i=p.ref(null),r=p.reactive({hasTarget:!1,placement:"none",tip:null,slotTip:null,boxStyle:{},svgStyle:{},tail:null,boxFill:"",boxStroke:"",boxStrokeWidth:0,boxZIndex:"auto"});function f(d){return d==null?null:typeof d=="string"||typeof Element<"u"&&d instanceof Element?d:typeof d=="object"&&"$el"in d&&d.$el instanceof Element?d.$el:typeof d=="object"&&typeof d.x=="number"&&typeof d.y=="number"?d:null}const h=p.getCurrentInstance(),g=nt({getBoxEl:()=>i.value,onChange:d=>{Object.assign(r,d),h?.update()}});function E(){g.setConfig({target:f(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})}p.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],E,{flush:"post"}),p.onMounted(()=>{E()}),p.onBeforeUnmount(()=>{g.destroy()});function c(){g.update()}t({update:c});const _=p.computed(()=>({...u.value,...r.boxStyle})),w=p.computed(()=>r.svgStyle);return(d,T)=>(p.openBlock(),p.createElementBlock("div",p.mergeProps({ref_key:"rootRef",ref:i,class:["pointing-bubble","pointing-bubble__inner",o.value],"data-placement":r.placement},a.value,{style:_.value}),[p.renderSlot(d.$slots,"default",{placement:r.placement,tip:r.slotTip},()=>[T[0]||(T[0]=p.createElementVNode("p",{style:{margin:0,fontSize:"14px",fontWeight:600,color:"#1e293b"}}," Callout content ",-1))]),e.target&&r.tail?(p.openBlock(),p.createElementBlock("svg",{key:0,class:"pointing-bubble__svg",style:p.normalizeStyle(w.value)},[p.createElementVNode("path",{class:"pointing-bubble__path",d:r.tail.fill,fill:r.boxFill},null,8,xt),r.tail.stroke?(p.openBlock(),p.createElementBlock("path",{key:0,class:"pointing-bubble__path",d:r.tail.stroke,fill:"none",stroke:r.boxStroke,"stroke-width":r.boxStrokeWidth,"stroke-linejoin":"round","stroke-linecap":"butt"},null,8,yt)):p.createCommentVNode("",!0)],4)):p.createCommentVNode("",!0)],16,bt))}}),wt={install(e,t={}){const n=t.name??"PointingBubble";e.component(n,D),e.component("Callout",D)}};exports.Callout=D;exports.DEFAULT_BUBBLE_CONFIG=Z;exports.PointingBubble=D;exports.PointingBubblePlugin=wt;exports.buildTailPaths=et;exports.computeGeometry=tt;exports.createBubbleController=nt;exports.default=D;exports.isPoint=K;exports.resolveElement=q;
9
+ }`,lt="drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";function it(e=document){if(e.getElementById(H))return;const t=e.createElement("style");t.id=H,t.textContent=ot,e.head.prepend(t)}function Z(e){return typeof e=="object"&&e!==null&&typeof e.x=="number"&&typeof e.y=="number"&&e.nodeType!==1}function N(e){return typeof Element>"u"||e==null?null:typeof e=="string"?document.querySelector(e):e instanceof Element?e:null}function Y(e,t){return!e||!t?!1:Object.keys(e).every(n=>e[n]===t[n])}function K(e){let t=e.parentElement;for(;t;){const n=getComputedStyle(t).position;if(n&&n!=="static")return t;if(t===document.documentElement)break;t=t.parentElement}return document.documentElement}function rt(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),l=parseFloat(n.width)||0,o=parseFloat(n.height)||0;return{left:t.left,top:t.top,width:l,height:o,scaleX:l?t.width/l:1,scaleY:o?t.height/o:1,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}function st(e){return rt(K(e))}function at(e,t){const n=getComputedStyle(e),{scaleX:l,scaleY:o,left:u,top:a}=t,i=e.getBoundingClientRect();return{x:(i.left-u)/l,y:(i.top-a)/o,width:i.width/l,height:i.height/o,fill:n.backgroundColor,stroke:n.borderTopColor,strokeWidth:parseFloat(n.borderTopWidth)||0,borderLeft:(parseFloat(n.borderLeftWidth)||0)/l,borderTop:(parseFloat(n.borderTopWidth)||0)/o,radius:n.borderTopLeftRadius,zIndex:n.zIndex}}function U(e,t,n){const l=e.x-n;let o=l,u=t.width?t.width-e.x-n:1/0;return t.viewportWidth&&(o=Math.min(o,t.left/t.scaleX+l),u=Math.min(u,(t.viewportWidth-t.left)/t.scaleX-e.x-n)),{left:Math.max(0,o),right:Math.max(0,u)}}function J(e){return e.left>e.right?"left":"right"}function Q(e){const{tip:t,box:n,frame:l,placement:o,targetRect:u,room:a,tailLength:i}=e;if(!n.width||!n.height)return null;const{width:r,height:f}=n,{x:h,y:g}=t,E=o==="manual",c=e.targetAnchor==="edge"?u:null;if(E){if(c){const k=n.x+r/2,W=n.y+f/2;if(!(k>=c.left&&k<=c.right&&W>=c.top&&W<=c.bottom)){const b=Math.min(c.right,Math.max(c.left,k)),B=Math.min(c.bottom,Math.max(c.top,W));return{placement:"manual",tx:b,ty:B,bx:n.x,by:n.y,w:r,h:f}}}return{placement:"manual",tx:h,ty:g,bx:n.x,by:n.y,w:r,h:f}}const _=k=>c?k==="top"?c.top:c.bottom:g;let w=o;if(o==="auto"){let k=g>(l.height||600)/2?"top":"bottom",W=J(a);const{scaleX:$,scaleY:b}=l;if(l.viewportHeight){const B=l.top+(_("top")-f-i)*b>=0,A=l.top+(_("bottom")+f+i)*b<=l.viewportHeight;k==="top"&&!B&&A?k="bottom":k==="bottom"&&!A&&B&&(k="top")}if(l.viewportWidth){const B=l.left+(h-r-i)*$>=0,A=l.left+(h+r+i)*$<=l.viewportWidth;W==="left"&&!B&&A?W="right":W==="right"&&!A&&B&&(W="left")}w=`${k}-${W}`}const[d,T]=w.split("-"),v=_(d);return{placement:w,tx:h,ty:v,bx:T==="left"?h-r-i:h+i,by:d==="top"?v-f-i:v+i,w:r,h:f}}const ct=["tx","ty","bx","by"],ut=["tx","ty"];function dt(){return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function ft(e,t,n,l){let o=0;const u=()=>{typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(o)};if(!t||!e||n<=0||typeof requestAnimationFrame>"u"||dt())return l(t),{cancel:u};const a=performance.now(),i=r=>{const f=Math.min(1,(r-a)/n),h=1-Math.pow(1-f,3),g={...t},E=t.placement==="manual"?ut:ct;for(const c of E)g[c]=e[c]+(t[c]-e[c])*h;l(g),f<1&&(o=requestAnimationFrame(i))};return o=requestAnimationFrame(i),{cancel:u}}function tt(e){const{geometry:t,strokeWidth:n,radius:l,tailBaseWidth:o}=e,{placement:u,tx:a,ty:i,bx:r,by:f,w:h,h:g}=t,E=parseFloat(l)*(l.endsWith("%")?Math.min(h,g)/100:1)||0,c=o/2,_=(y,m,R)=>m>R?(m+R)/2:Math.min(R,Math.max(m,y));let w=null,d=0;if(u==="manual"){const y=Math.max(r-a,a-(r+h),0),m=Math.max(f-i,i-(f+g),0);if(y>0&&y>=m)w=a<r?"left":"right",d=i;else if(m>0)w=i<f?"top":"bottom",d=a;else return null}else if(u!=="none"){const[y,m]=u.split("-");w=m==="left"?"right":"left",d=f+g*(y==="top"?.65:.35)}else return null;const T=w==="top"||w==="bottom",v={left:(y,m)=>[r-m,y],right:(y,m)=>[r+h+m,y],top:(y,m)=>[y,f-m],bottom:(y,m)=>[y,f+g+m]}[w],k=T?r:f,W=T?r+h:f+g,$=_(d,k+c+n/2+E,W-c-n/2-E),b=([y,m])=>`${y} ${m}`,B=n>0?-n/2:0,A=2,P=2,s=$-c,x=$+c,z=v(s-A,B),S=v(s,B),C=v(x,B),M=v(x+A,B),F=v(s,-(n+P)),O=v(x,-(n+P)),L=v(s,1),I=v(x,1);return{fill:`M ${b(F)} L ${b(L)} L ${b(S)} L ${a} ${i} L ${b(C)} L ${b(I)} L ${b(O)} Z`,stroke:n?`M ${b(z)} L ${b(S)} L ${a} ${i} L ${b(C)} L ${b(M)}`:null}}const pt=["left","top","right","bottom","width","height","transform","translate","inset","inset-inline","inset-block"];function ht(e){return{hasTarget:e,placement:"none",tip:null,slotTip:null,boxStyle:{},svgStyle:{},tail:null,boxFill:"",boxStroke:"",boxStrokeWidth:0,boxZIndex:"auto"}}function D(e,t){return e===t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function mt(e,t){return e===t?!0:!e||!t?!1:e.placement===t.placement&&e.tx===t.tx&&e.ty===t.ty&&e.bx===t.bx&&e.by===t.by&&e.w===t.w&&e.h===t.h}function gt(e,t){return e.hasTarget===t.hasTarget&&e.placement===t.placement&&e.boxFill===t.boxFill&&e.boxStroke===t.boxStroke&&e.boxStrokeWidth===t.boxStrokeWidth&&e.boxZIndex===t.boxZIndex&&D(e.tip,t.tip)&&D(e.slotTip,t.slotTip)&&Y(e.boxStyle,t.boxStyle)&&Y(e.svgStyle,t.svgStyle)&&e.tail?.fill===t.tail?.fill&&e.tail?.stroke===t.tail?.stroke}function V(e){if(typeof e.checkVisibility=="function")return e.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});const t=getComputedStyle(e);return!(t.display==="none"||t.visibility==="hidden"||parseFloat(t.opacity)===0)}function X(e){const t=e.style;return pt.map(n=>t.getPropertyValue(n)).join("|")}function et(e){it();let t={...G},n=null,l=null,o=null,u={left:0,top:0,width:0,height:0,scaleX:1,scaleY:1,viewportWidth:0,viewportHeight:0},a=null,i=null,r=null,f=null,h=null,g=null,E=ht(!1),c=!1,_="";const w=()=>{const s=d();gt(E,s)||(E=s,e.onChange?.(E))};function d(){const s=t.target!=null,x=t.placement==="manual",z=s?a?.placement??"none":"none",S={"--pb-padding":typeof t.padding=="number"?`${t.padding}px`:t.padding};if(t.maxWidth!=null&&(S["--pb-max-width"]=`${t.maxWidth}px`),t.shadow&&(S.filter=lt),!s)S["--pb-width"]="fit-content";else if(Object.assign(S,{position:"absolute",pointerEvents:"auto",overflow:"visible"}),x)S["--pb-width"]="fit-content";else if(Object.assign(S,{left:`${a?.bx??0}px`,top:`${a?.by??0}px`,margin:"0"}),t.maxWidth==null&&n){const O=U(n,u,t.tailLength),L=i?.placement??t.placement,I=L==="auto"?J(O):L.split("-")[1];S["--pb-max-width"]=`${O[I]}px`}const C=o?.zIndex;C&&C!=="auto"&&(S.zIndex=C);const M=s&&a&&o?tt({geometry:a,strokeWidth:o.strokeWidth,radius:o.radius,tailBaseWidth:t.tailBaseWidth}):null;let F={};if(M&&a&&u.width&&u.height){const O=o?.borderLeft??0,L=o?.borderTop??0;F={position:"absolute",left:`${-a.bx-O}px`,top:`${-a.by-L}px`,width:`${u.width}px`,height:`${u.height}px`,overflow:"visible",pointerEvents:"none",zIndex:o?.zIndex??"auto"}}return{hasTarget:s,placement:z,tip:n,slotTip:i?{x:i.tx,y:i.ty}:n,boxStyle:S,svgStyle:F,tail:M,boxFill:o?.fill??"",boxStroke:o?.stroke??"",boxStrokeWidth:o?.strokeWidth??0,boxZIndex:o?.zIndex??"auto"}}function T(){if(!n||!o){(i!==null||a!==null)&&(i=null,v(null));return}const s=U(n,u,t.tailLength),x=Q({tip:n,box:o,frame:u,placement:t.placement,targetAnchor:t.targetAnchor,targetRect:l,room:s,tailLength:t.tailLength});mt(i,x)||(i=x,v(i))}function v(s){r?.cancel(),r=ft(a,s,t.transitionDuration,x=>{a=x,w()})}function k(s){const x=at(s,u);return Y(x,o)?!1:(o=x,!0)}function W(){const s=e.getBoxEl();if(!s){n=null,l=null,o=null,i=null,a=null,c=!1,w();return}if(!V(s)){r?.cancel(),c=!0;return}const x=c;if(c=!1,t.target==null){n=null,l=null,o=null,i=null,a=null,w();return}const z=u;u=st(s);const S=!Y(u,z),C=typeof t.target=="string"?K(s).querySelector(t.target)??N(t.target):N(t.target);let M=!1,F=!1;if(C){const L=C.getBoundingClientRect(),{scaleX:I,scaleY:y,left:m,top:R}=u,j={left:(L.left-m)/I,top:(L.top-R)/y,right:(L.right-m)/I,bottom:(L.bottom-R)/y};F=!Y(j,l),F&&(l=j);const q={x:(j.left+j.right)/2,y:(j.top+j.bottom)/2};M=!D(n,q),n=q}else if(Z(t.target)){F=l!=null,l=null;const L={x:t.target.x,y:t.target.y};M=!D(n,L),n=L}else{n=null,l=null,o=null,i=null,a=null,w();return}const O=k(s);_=X(s),!(!x&&!S&&!M&&!F&&!O&&a)&&T()}function $(){W()}typeof window<"u"&&(window.addEventListener("resize",$),window.addEventListener("scroll",$,!0));const b=W;function B(s){const x=e.getBoxEl();if(!x)return;if(s.some(C=>C.attributeName==="class"||C.attributeName==="hidden")){if(!V(x)){r?.cancel(),c=!0;return}b();return}const S=X(x);S!==_&&(_=S,b())}function A(){const s=e.getBoxEl();s!==g&&(g=s,f?.disconnect(),h?.disconnect(),f=null,h=null,s&&(typeof ResizeObserver<"u"&&(f=new ResizeObserver(()=>b()),f.observe(s)),typeof MutationObserver<"u"&&(h=new MutationObserver(B),h.observe(s,{attributes:!0,attributeFilter:["style","class","hidden"]}))))}function P(){A(),b()}return{update:P,setConfig(s){t={...t,...s},P()},getConfig:()=>t,getState:()=>E,destroy(){r?.cancel(),f?.disconnect(),h?.disconnect(),g=null,typeof window<"u"&&(window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0))}}}const bt=["data-placement"],xt=["d","fill"],yt=["d","stroke","stroke-width"],nt=p.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,l=p.useAttrs(),o=p.computed(()=>l.class),u=p.computed(()=>l.style),a=p.computed(()=>{const{class:d,style:T,...v}=l;return v}),i=p.ref(null),r=p.reactive({hasTarget:!1,placement:"none",tip:null,slotTip:null,boxStyle:{},svgStyle:{},tail:null,boxFill:"",boxStroke:"",boxStrokeWidth:0,boxZIndex:"auto"});function f(d){return d==null?null:typeof d=="string"||typeof Element<"u"&&d instanceof Element?d:typeof d=="object"&&"$el"in d&&d.$el instanceof Element?d.$el:typeof d=="object"&&typeof d.x=="number"&&typeof d.y=="number"?d:null}const h=p.getCurrentInstance(),g=et({getBoxEl:()=>i.value,onChange:d=>{Object.assign(r,d),h?.update()}});function E(){g.setConfig({target:f(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})}p.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],E,{flush:"post"}),p.onMounted(()=>{E()}),p.onBeforeUnmount(()=>{g.destroy()});function c(){g.update()}t({update:c});const _=p.computed(()=>({...u.value,...r.boxStyle})),w=p.computed(()=>r.svgStyle);return(d,T)=>(p.openBlock(),p.createElementBlock("div",p.mergeProps({ref_key:"rootRef",ref:i,class:["pointing-bubble","pointing-bubble__inner",o.value],"data-placement":r.placement},a.value,{style:_.value}),[p.renderSlot(d.$slots,"default",{placement:r.placement,tip:r.slotTip},()=>[T[0]||(T[0]=p.createElementVNode("p",{style:{margin:0,fontSize:"14px",fontWeight:600,color:"#1e293b"}}," Callout content ",-1))]),e.target&&r.tail?(p.openBlock(),p.createElementBlock("svg",{key:0,class:"pointing-bubble__svg",style:p.normalizeStyle(w.value)},[p.createElementVNode("path",{class:"pointing-bubble__path",d:r.tail.fill,fill:r.boxFill},null,8,xt),r.tail.stroke?(p.openBlock(),p.createElementBlock("path",{key:0,class:"pointing-bubble__path",d:r.tail.stroke,fill:"none",stroke:r.boxStroke,"stroke-width":r.boxStrokeWidth,"stroke-linejoin":"round","stroke-linecap":"butt"},null,8,yt)):p.createCommentVNode("",!0)],4)):p.createCommentVNode("",!0)],16,bt))}});exports.DEFAULT_BUBBLE_CONFIG=G;exports.PointingBubble=nt;exports.buildTailPaths=tt;exports.computeGeometry=Q;exports.createBubbleController=et;exports.default=nt;exports.isPoint=Z;exports.resolveElement=N;
@@ -1,5 +1,5 @@
1
- import { defineComponent as nt, useAttrs as ot, computed as Y, ref as it, reactive as lt, getCurrentInstance as rt, watch as st, onMounted as at, onBeforeUnmount as ct, openBlock as H, createElementBlock as q, mergeProps as ut, renderSlot as dt, createElementVNode as X, normalizeStyle as ft, createCommentVNode as U } from "vue";
2
- const pt = {
1
+ import { defineComponent as et, useAttrs as nt, computed as j, ref as ot, reactive as it, getCurrentInstance as lt, watch as rt, onMounted as st, onBeforeUnmount as at, openBlock as H, createElementBlock as q, mergeProps as ct, renderSlot as ut, createElementVNode as X, normalizeStyle as dt, createCommentVNode as U } from "vue";
2
+ const ft = {
3
3
  target: null,
4
4
  placement: "auto",
5
5
  targetAnchor: "center",
@@ -8,7 +8,7 @@ const pt = {
8
8
  padding: 8,
9
9
  shadow: !0,
10
10
  transitionDuration: 200
11
- }, V = "pointing-bubble-styles", ht = `:where(.pointing-bubble__inner) {
11
+ }, V = "pointing-bubble-styles", pt = `: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,22 +16,22 @@ const pt = {
16
16
  background: white;
17
17
  border: 2px solid gray;
18
18
  border-radius: 8px;
19
- }`, mt = "drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";
20
- function gt(e = document) {
19
+ }`, ht = "drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";
20
+ function mt(e = document) {
21
21
  if (e.getElementById(V)) return;
22
22
  const t = e.createElement("style");
23
- t.id = V, t.textContent = ht, e.head.prepend(t);
23
+ t.id = V, t.textContent = pt, e.head.prepend(t);
24
24
  }
25
- function bt(e) {
25
+ function gt(e) {
26
26
  return typeof e == "object" && e !== null && typeof e.x == "number" && typeof e.y == "number" && e.nodeType !== 1;
27
27
  }
28
28
  function Z(e) {
29
29
  return typeof Element > "u" || e == null ? null : typeof e == "string" ? document.querySelector(e) : e instanceof Element ? e : null;
30
30
  }
31
- function j(e, t) {
31
+ function D(e, t) {
32
32
  return !e || !t ? !1 : Object.keys(e).every((n) => e[n] === t[n]);
33
33
  }
34
- function tt(e) {
34
+ function Q(e) {
35
35
  let t = e.parentElement;
36
36
  for (; t; ) {
37
37
  const n = getComputedStyle(t).position;
@@ -41,7 +41,7 @@ function tt(e) {
41
41
  }
42
42
  return document.documentElement;
43
43
  }
44
- function xt(e) {
44
+ function bt(e) {
45
45
  const t = e.getBoundingClientRect(), n = getComputedStyle(e), i = parseFloat(n.width) || 0, o = parseFloat(n.height) || 0;
46
46
  return {
47
47
  left: t.left,
@@ -54,10 +54,10 @@ function xt(e) {
54
54
  viewportHeight: window.innerHeight
55
55
  };
56
56
  }
57
- function yt(e) {
58
- return xt(tt(e));
57
+ function xt(e) {
58
+ return bt(Q(e));
59
59
  }
60
- function wt(e, t) {
60
+ function yt(e, t) {
61
61
  const n = getComputedStyle(e), { scaleX: i, scaleY: o, left: u, top: a } = t, l = e.getBoundingClientRect();
62
62
  return {
63
63
  x: (l.left - u) / i,
@@ -83,10 +83,10 @@ function G(e, t, n) {
83
83
  (t.viewportWidth - t.left) / t.scaleX - e.x - n
84
84
  )), { left: Math.max(0, o), right: Math.max(0, u) };
85
85
  }
86
- function et(e) {
86
+ function tt(e) {
87
87
  return e.left > e.right ? "left" : "right";
88
88
  }
89
- function vt(e) {
89
+ function wt(e) {
90
90
  const { tip: t, box: n, frame: i, placement: o, targetRect: u, room: a, tailLength: l } = e;
91
91
  if (!n.width || !n.height) return null;
92
92
  const { width: r, height: f } = n, { x: p, y: m } = t, k = o === "manual", c = e.targetAnchor === "edge" ? u : null;
@@ -100,22 +100,22 @@ function vt(e) {
100
100
  }
101
101
  return { placement: "manual", tx: p, ty: m, bx: n.x, by: n.y, w: r, h: f };
102
102
  }
103
- const C = (S) => c ? S === "top" ? c.top : c.bottom : m;
103
+ const $ = (S) => c ? S === "top" ? c.top : c.bottom : m;
104
104
  let y = o;
105
105
  if (o === "auto") {
106
- let S = m > (i.height || 600) / 2 ? "top" : "bottom", W = et(a);
107
- const { scaleX: $, scaleY: g } = i;
106
+ let S = m > (i.height || 600) / 2 ? "top" : "bottom", W = tt(a);
107
+ const { scaleX: C, scaleY: g } = i;
108
108
  if (i.viewportHeight) {
109
- const E = i.top + (C("top") - f - l) * g >= 0, A = i.top + (C("bottom") + f + l) * g <= i.viewportHeight;
109
+ const E = i.top + ($("top") - f - l) * g >= 0, A = i.top + ($("bottom") + f + l) * g <= i.viewportHeight;
110
110
  S === "top" && !E && A ? S = "bottom" : S === "bottom" && !A && E && (S = "top");
111
111
  }
112
112
  if (i.viewportWidth) {
113
- const E = i.left + (p - r - l) * $ >= 0, A = i.left + (p + r + l) * $ <= i.viewportWidth;
113
+ const E = i.left + (p - r - l) * C >= 0, A = i.left + (p + r + l) * C <= i.viewportWidth;
114
114
  W === "left" && !E && A ? W = "right" : W === "right" && !A && E && (W = "left");
115
115
  }
116
116
  y = `${S}-${W}`;
117
117
  }
118
- const [d, _] = y.split("-"), w = C(d);
118
+ const [d, _] = y.split("-"), w = $(d);
119
119
  return {
120
120
  placement: y,
121
121
  tx: p,
@@ -126,27 +126,27 @@ function vt(e) {
126
126
  h: f
127
127
  };
128
128
  }
129
- const St = ["tx", "ty", "bx", "by"], kt = ["tx", "ty"];
130
- function Wt() {
129
+ const vt = ["tx", "ty", "bx", "by"], St = ["tx", "ty"];
130
+ function kt() {
131
131
  return typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches;
132
132
  }
133
- function Et(e, t, n, i) {
133
+ function Wt(e, t, n, i) {
134
134
  let o = 0;
135
135
  const u = () => {
136
136
  typeof cancelAnimationFrame < "u" && cancelAnimationFrame(o);
137
137
  };
138
- if (!t || !e || n <= 0 || typeof requestAnimationFrame > "u" || Wt())
138
+ if (!t || !e || n <= 0 || typeof requestAnimationFrame > "u" || kt())
139
139
  return i(t), { cancel: u };
140
140
  const a = performance.now(), l = (r) => {
141
- const f = Math.min(1, (r - a) / n), p = 1 - Math.pow(1 - f, 3), m = { ...t }, k = t.placement === "manual" ? kt : St;
141
+ const f = Math.min(1, (r - a) / n), p = 1 - Math.pow(1 - f, 3), m = { ...t }, k = t.placement === "manual" ? St : vt;
142
142
  for (const c of k)
143
143
  m[c] = e[c] + (t[c] - e[c]) * p;
144
144
  i(m), f < 1 && (o = requestAnimationFrame(l));
145
145
  };
146
146
  return o = requestAnimationFrame(l), { cancel: u };
147
147
  }
148
- function Bt(e) {
149
- const { geometry: t, strokeWidth: n, radius: i, tailBaseWidth: o } = e, { placement: u, tx: a, ty: l, bx: r, by: f, w: p, h: m } = t, k = parseFloat(i) * (i.endsWith("%") ? Math.min(p, m) / 100 : 1) || 0, c = o / 2, C = (x, h, O) => h > O ? (h + O) / 2 : Math.min(O, Math.max(h, x));
148
+ function Et(e) {
149
+ const { geometry: t, strokeWidth: n, radius: i, tailBaseWidth: o } = e, { placement: u, tx: a, ty: l, bx: r, by: f, w: p, h: m } = t, k = parseFloat(i) * (i.endsWith("%") ? Math.min(p, m) / 100 : 1) || 0, c = o / 2, $ = (x, h, O) => h > O ? (h + O) / 2 : Math.min(O, Math.max(h, x));
150
150
  let y = null, d = 0;
151
151
  if (u === "manual") {
152
152
  const x = Math.max(r - a, a - (r + p), 0), h = Math.max(f - l, l - (f + m), 0);
@@ -166,14 +166,14 @@ function Bt(e) {
166
166
  right: (x, h) => [r + p + h, x],
167
167
  top: (x, h) => [x, f - h],
168
168
  bottom: (x, h) => [x, f + m + h]
169
- }[y], S = _ ? r : f, W = _ ? r + p : f + m, $ = C(
169
+ }[y], S = _ ? r : f, W = _ ? r + p : f + m, C = $(
170
170
  d,
171
171
  S + c + n / 2 + k,
172
172
  W - c - n / 2 - k
173
- ), g = ([x, h]) => `${x} ${h}`, E = n > 0 ? -n / 2 : 0, A = 2, P = 2, s = $ - c, b = $ + c, z = w(s - A, E), v = w(s, E), L = w(b, E), F = w(b + A, E), T = w(s, -(n + P)), M = w(b, -(n + P)), B = w(s, 1), I = w(b, 1);
173
+ ), g = ([x, h]) => `${x} ${h}`, E = n > 0 ? -n / 2 : 0, A = 2, Y = 2, s = C - c, b = C + c, z = w(s - A, E), v = w(s, E), B = w(b, E), F = w(b + A, E), T = w(s, -(n + Y)), M = w(b, -(n + Y)), L = w(s, 1), I = w(b, 1);
174
174
  return {
175
- fill: `M ${g(T)} L ${g(B)} L ${g(v)} L ${a} ${l} L ${g(L)} L ${g(I)} L ${g(M)} Z`,
176
- stroke: n ? `M ${g(z)} L ${g(v)} L ${a} ${l} L ${g(L)} L ${g(F)}` : null
175
+ fill: `M ${g(T)} L ${g(L)} L ${g(v)} L ${a} ${l} L ${g(B)} L ${g(I)} L ${g(M)} Z`,
176
+ stroke: n ? `M ${g(z)} L ${g(v)} L ${a} ${l} L ${g(B)} L ${g(F)}` : null
177
177
  };
178
178
  }
179
179
  const Lt = [
@@ -189,7 +189,7 @@ const Lt = [
189
189
  "inset-inline",
190
190
  "inset-block"
191
191
  ];
192
- function Ct(e) {
192
+ function Bt(e) {
193
193
  return {
194
194
  hasTarget: e,
195
195
  placement: "none",
@@ -204,14 +204,14 @@ function Ct(e) {
204
204
  boxZIndex: "auto"
205
205
  };
206
206
  }
207
- function D(e, t) {
207
+ function P(e, t) {
208
208
  return e === t ? !0 : !e || !t ? !1 : e.x === t.x && e.y === t.y;
209
209
  }
210
210
  function $t(e, t) {
211
211
  return e === t ? !0 : !e || !t ? !1 : e.placement === t.placement && e.tx === t.tx && e.ty === t.ty && e.bx === t.bx && e.by === t.by && e.w === t.w && e.h === t.h;
212
212
  }
213
- function _t(e, t) {
214
- return e.hasTarget === t.hasTarget && e.placement === t.placement && e.boxFill === t.boxFill && e.boxStroke === t.boxStroke && e.boxStrokeWidth === t.boxStrokeWidth && e.boxZIndex === t.boxZIndex && D(e.tip, t.tip) && D(e.slotTip, t.slotTip) && j(e.boxStyle, t.boxStyle) && j(e.svgStyle, t.svgStyle) && e.tail?.fill === t.tail?.fill && e.tail?.stroke === t.tail?.stroke;
213
+ function Ct(e, t) {
214
+ return e.hasTarget === t.hasTarget && e.placement === t.placement && e.boxFill === t.boxFill && e.boxStroke === t.boxStroke && e.boxStrokeWidth === t.boxStrokeWidth && e.boxZIndex === t.boxZIndex && P(e.tip, t.tip) && P(e.slotTip, t.slotTip) && D(e.boxStyle, t.boxStyle) && D(e.svgStyle, t.svgStyle) && e.tail?.fill === t.tail?.fill && e.tail?.stroke === t.tail?.stroke;
215
215
  }
216
216
  function K(e) {
217
217
  if (typeof e.checkVisibility == "function")
@@ -226,9 +226,9 @@ function J(e) {
226
226
  const t = e.style;
227
227
  return Lt.map((n) => t.getPropertyValue(n)).join("|");
228
228
  }
229
- function At(e) {
230
- gt();
231
- let t = { ...pt }, n = null, i = null, o = null, u = {
229
+ function _t(e) {
230
+ mt();
231
+ let t = { ...ft }, n = null, i = null, o = null, u = {
232
232
  left: 0,
233
233
  top: 0,
234
234
  width: 0,
@@ -237,16 +237,16 @@ function At(e) {
237
237
  scaleY: 1,
238
238
  viewportWidth: 0,
239
239
  viewportHeight: 0
240
- }, a = null, l = null, r = null, f = null, p = null, m = null, k = Ct(!1), c = !1, C = "";
240
+ }, a = null, l = null, r = null, f = null, p = null, m = null, k = Bt(!1), c = !1, $ = "";
241
241
  const y = () => {
242
242
  const s = d();
243
- _t(k, s) || (k = s, e.onChange?.(k));
243
+ Ct(k, s) || (k = s, e.onChange?.(k));
244
244
  };
245
245
  function d() {
246
246
  const s = t.target != null, b = t.placement === "manual", z = s ? a?.placement ?? "none" : "none", v = {
247
247
  "--pb-padding": typeof t.padding == "number" ? `${t.padding}px` : t.padding
248
248
  };
249
- if (t.maxWidth != null && (v["--pb-max-width"] = `${t.maxWidth}px`), t.shadow && (v.filter = mt), !s)
249
+ if (t.maxWidth != null && (v["--pb-max-width"] = `${t.maxWidth}px`), t.shadow && (v.filter = ht), !s)
250
250
  v["--pb-width"] = "fit-content";
251
251
  else if (Object.assign(v, {
252
252
  position: "absolute",
@@ -259,12 +259,12 @@ function At(e) {
259
259
  top: `${a?.by ?? 0}px`,
260
260
  margin: "0"
261
261
  }), t.maxWidth == null && n) {
262
- const M = G(n, u, t.tailLength), B = l?.placement ?? t.placement, I = B === "auto" ? et(M) : B.split("-")[1];
262
+ const M = G(n, u, t.tailLength), L = l?.placement ?? t.placement, I = L === "auto" ? tt(M) : L.split("-")[1];
263
263
  v["--pb-max-width"] = `${M[I]}px`;
264
264
  }
265
- const L = o?.zIndex;
266
- L && L !== "auto" && (v.zIndex = L);
267
- const F = s && a && o ? Bt({
265
+ const B = o?.zIndex;
266
+ B && B !== "auto" && (v.zIndex = B);
267
+ const F = s && a && o ? Et({
268
268
  geometry: a,
269
269
  strokeWidth: o.strokeWidth,
270
270
  radius: o.radius,
@@ -272,11 +272,11 @@ function At(e) {
272
272
  }) : null;
273
273
  let T = {};
274
274
  if (F && a && u.width && u.height) {
275
- const M = o?.borderLeft ?? 0, B = o?.borderTop ?? 0;
275
+ const M = o?.borderLeft ?? 0, L = o?.borderTop ?? 0;
276
276
  T = {
277
277
  position: "absolute",
278
278
  left: `${-a.bx - M}px`,
279
- top: `${-a.by - B}px`,
279
+ top: `${-a.by - L}px`,
280
280
  width: `${u.width}px`,
281
281
  height: `${u.height}px`,
282
282
  overflow: "visible",
@@ -303,7 +303,7 @@ function At(e) {
303
303
  (l !== null || a !== null) && (l = null, w(null));
304
304
  return;
305
305
  }
306
- const s = G(n, u, t.tailLength), b = vt({
306
+ const s = G(n, u, t.tailLength), b = wt({
307
307
  tip: n,
308
308
  box: o,
309
309
  frame: u,
@@ -316,7 +316,7 @@ function At(e) {
316
316
  $t(l, b) || (l = b, w(l));
317
317
  }
318
318
  function w(s) {
319
- r?.cancel(), r = Et(
319
+ r?.cancel(), r = Wt(
320
320
  a,
321
321
  s,
322
322
  t.transitionDuration,
@@ -326,8 +326,8 @@ function At(e) {
326
326
  );
327
327
  }
328
328
  function S(s) {
329
- const b = wt(s, u);
330
- return j(
329
+ const b = yt(s, u);
330
+ return D(
331
331
  b,
332
332
  o
333
333
  ) ? !1 : (o = b, !0);
@@ -348,20 +348,20 @@ function At(e) {
348
348
  return;
349
349
  }
350
350
  const z = u;
351
- u = yt(s);
352
- const v = !j(
351
+ u = xt(s);
352
+ const v = !D(
353
353
  u,
354
354
  z
355
- ), L = typeof t.target == "string" ? tt(s).querySelector(t.target) ?? Z(t.target) : Z(t.target);
355
+ ), B = typeof t.target == "string" ? Q(s).querySelector(t.target) ?? Z(t.target) : Z(t.target);
356
356
  let F = !1, T = !1;
357
- if (L) {
358
- const B = L.getBoundingClientRect(), { scaleX: I, scaleY: x, left: h, top: O } = u, R = {
359
- left: (B.left - h) / I,
360
- top: (B.top - O) / x,
361
- right: (B.right - h) / I,
362
- bottom: (B.bottom - O) / x
357
+ if (B) {
358
+ const L = B.getBoundingClientRect(), { scaleX: I, scaleY: x, left: h, top: O } = u, R = {
359
+ left: (L.left - h) / I,
360
+ top: (L.top - O) / x,
361
+ right: (L.right - h) / I,
362
+ bottom: (L.bottom - O) / x
363
363
  };
364
- T = !j(
364
+ T = !D(
365
365
  R,
366
366
  i
367
367
  ), T && (i = R);
@@ -369,28 +369,28 @@ function At(e) {
369
369
  x: (R.left + R.right) / 2,
370
370
  y: (R.top + R.bottom) / 2
371
371
  };
372
- F = !D(n, N), n = N;
373
- } else if (bt(t.target)) {
372
+ F = !P(n, N), n = N;
373
+ } else if (gt(t.target)) {
374
374
  T = i != null, i = null;
375
- const B = { x: t.target.x, y: t.target.y };
376
- F = !D(n, B), n = B;
375
+ const L = { x: t.target.x, y: t.target.y };
376
+ F = !P(n, L), n = L;
377
377
  } else {
378
378
  n = null, i = null, o = null, l = null, a = null, y();
379
379
  return;
380
380
  }
381
381
  const M = S(s);
382
- C = J(s), !(!b && !v && !F && !T && !M && a) && _();
382
+ $ = J(s), !(!b && !v && !F && !T && !M && a) && _();
383
383
  }
384
- function $() {
384
+ function C() {
385
385
  W();
386
386
  }
387
- typeof window < "u" && (window.addEventListener("resize", $), window.addEventListener("scroll", $, !0));
387
+ typeof window < "u" && (window.addEventListener("resize", C), window.addEventListener("scroll", C, !0));
388
388
  const g = W;
389
389
  function E(s) {
390
390
  const b = e.getBoxEl();
391
391
  if (!b) return;
392
392
  if (s.some(
393
- (L) => L.attributeName === "class" || L.attributeName === "hidden"
393
+ (B) => B.attributeName === "class" || B.attributeName === "hidden"
394
394
  )) {
395
395
  if (!K(b)) {
396
396
  r?.cancel(), c = !0;
@@ -400,7 +400,7 @@ function At(e) {
400
400
  return;
401
401
  }
402
402
  const v = J(b);
403
- v !== C && (C = v, g());
403
+ v !== $ && ($ = v, g());
404
404
  }
405
405
  function A() {
406
406
  const s = e.getBoxEl();
@@ -409,22 +409,22 @@ function At(e) {
409
409
  attributeFilter: ["style", "class", "hidden"]
410
410
  }))));
411
411
  }
412
- function P() {
412
+ function Y() {
413
413
  A(), g();
414
414
  }
415
415
  return {
416
- update: P,
416
+ update: Y,
417
417
  setConfig(s) {
418
- t = { ...t, ...s }, P();
418
+ t = { ...t, ...s }, Y();
419
419
  },
420
420
  getConfig: () => t,
421
421
  getState: () => k,
422
422
  destroy() {
423
- r?.cancel(), f?.disconnect(), p?.disconnect(), m = null, typeof window < "u" && (window.removeEventListener("resize", $), window.removeEventListener("scroll", $, !0));
423
+ r?.cancel(), f?.disconnect(), p?.disconnect(), m = null, typeof window < "u" && (window.removeEventListener("resize", C), window.removeEventListener("scroll", C, !0));
424
424
  }
425
425
  };
426
426
  }
427
- const Tt = ["data-placement"], Ft = ["d", "fill"], Mt = ["d", "stroke", "stroke-width"], Q = /* @__PURE__ */ nt({
427
+ const At = ["data-placement"], Tt = ["d", "fill"], Ft = ["d", "stroke", "stroke-width"], zt = /* @__PURE__ */ et({
428
428
  name: "PointingBubble",
429
429
  inheritAttrs: !1,
430
430
  __name: "PointingBubble",
@@ -440,10 +440,10 @@ const Tt = ["data-placement"], Ft = ["d", "fill"], Mt = ["d", "stroke", "stroke-
440
440
  transitionDuration: { default: 200 }
441
441
  },
442
442
  setup(e, { expose: t }) {
443
- const n = e, i = ot(), o = Y(() => i.class), u = Y(() => i.style), a = Y(() => {
443
+ const n = e, i = nt(), o = j(() => i.class), u = j(() => i.style), a = j(() => {
444
444
  const { class: d, style: _, ...w } = i;
445
445
  return w;
446
- }), l = it(null), r = lt({
446
+ }), l = ot(null), r = it({
447
447
  hasTarget: !1,
448
448
  placement: "none",
449
449
  tip: null,
@@ -459,7 +459,7 @@ const Tt = ["data-placement"], Ft = ["d", "fill"], Mt = ["d", "stroke", "stroke-
459
459
  function f(d) {
460
460
  return d == null ? null : typeof d == "string" || typeof Element < "u" && d instanceof Element ? d : typeof d == "object" && "$el" in d && d.$el instanceof Element ? d.$el : typeof d == "object" && typeof d.x == "number" && typeof d.y == "number" ? d : null;
461
461
  }
462
- const p = rt(), m = At({
462
+ const p = lt(), m = _t({
463
463
  getBoxEl: () => l.value,
464
464
  onChange: (d) => {
465
465
  Object.assign(r, d), p?.update();
@@ -478,7 +478,7 @@ const Tt = ["data-placement"], Ft = ["d", "fill"], Mt = ["d", "stroke", "stroke-
478
478
  transitionDuration: n.transitionDuration
479
479
  });
480
480
  }
481
- st(
481
+ rt(
482
482
  () => [
483
483
  n.target,
484
484
  typeof n.target == "object" && n.target && "x" in n.target ? n.target.x : null,
@@ -494,28 +494,28 @@ const Tt = ["data-placement"], Ft = ["d", "fill"], Mt = ["d", "stroke", "stroke-
494
494
  ],
495
495
  k,
496
496
  { flush: "post" }
497
- ), at(() => {
497
+ ), st(() => {
498
498
  k();
499
- }), ct(() => {
499
+ }), at(() => {
500
500
  m.destroy();
501
501
  });
502
502
  function c() {
503
503
  m.update();
504
504
  }
505
505
  t({ update: c });
506
- const C = Y(
506
+ const $ = j(
507
507
  () => ({
508
508
  ...u.value,
509
509
  ...r.boxStyle
510
510
  })
511
- ), y = Y(() => r.svgStyle);
512
- return (d, _) => (H(), q("div", ut({
511
+ ), y = j(() => r.svgStyle);
512
+ return (d, _) => (H(), q("div", ct({
513
513
  ref_key: "rootRef",
514
514
  ref: l,
515
515
  class: ["pointing-bubble", "pointing-bubble__inner", o.value],
516
516
  "data-placement": r.placement
517
- }, a.value, { style: C.value }), [
518
- dt(d.$slots, "default", {
517
+ }, a.value, { style: $.value }), [
518
+ ut(d.$slots, "default", {
519
519
  placement: r.placement,
520
520
  tip: r.slotTip
521
521
  }, () => [
@@ -529,13 +529,13 @@ const Tt = ["data-placement"], Ft = ["d", "fill"], Mt = ["d", "stroke", "stroke-
529
529
  e.target && r.tail ? (H(), q("svg", {
530
530
  key: 0,
531
531
  class: "pointing-bubble__svg",
532
- style: ft(y.value)
532
+ style: dt(y.value)
533
533
  }, [
534
534
  X("path", {
535
535
  class: "pointing-bubble__path",
536
536
  d: r.tail.fill,
537
537
  fill: r.boxFill
538
- }, null, 8, Ft),
538
+ }, null, 8, Tt),
539
539
  r.tail.stroke ? (H(), q("path", {
540
540
  key: 0,
541
541
  class: "pointing-bubble__path",
@@ -545,25 +545,18 @@ const Tt = ["data-placement"], Ft = ["d", "fill"], Mt = ["d", "stroke", "stroke-
545
545
  "stroke-width": r.boxStrokeWidth,
546
546
  "stroke-linejoin": "round",
547
547
  "stroke-linecap": "butt"
548
- }, null, 8, Mt)) : U("", !0)
548
+ }, null, 8, Ft)) : U("", !0)
549
549
  ], 4)) : U("", !0)
550
- ], 16, Tt));
551
- }
552
- }), It = {
553
- install(e, t = {}) {
554
- const n = t.name ?? "PointingBubble";
555
- e.component(n, Q), e.component("Callout", Q);
550
+ ], 16, At));
556
551
  }
557
- };
552
+ });
558
553
  export {
559
- Q as Callout,
560
- pt as DEFAULT_BUBBLE_CONFIG,
561
- Q as PointingBubble,
562
- It as PointingBubblePlugin,
563
- Bt as buildTailPaths,
564
- vt as computeGeometry,
565
- At as createBubbleController,
566
- Q as default,
567
- bt as isPoint,
554
+ ft as DEFAULT_BUBBLE_CONFIG,
555
+ zt as PointingBubble,
556
+ Et as buildTailPaths,
557
+ wt as computeGeometry,
558
+ _t as createBubbleController,
559
+ zt as default,
560
+ gt as isPoint,
568
561
  Z as resolveElement
569
562
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-pointing-bubble",
3
- "version": "0.5.1",
3
+ "version": "0.6.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,