vue-pointing-bubble 0.4.0 → 0.5.1

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/README.md CHANGED
@@ -48,20 +48,20 @@ const btn = ref<HTMLElement | null>(null)
48
48
  | Prop | Default | Notes |
49
49
  | --- | --- | --- |
50
50
  | `target` | `null` | `{x,y}`, `Element`, CSS selector, or `null` (in-flow box only) |
51
- | `placement` | `'auto'` | `'auto'` \| quadrant \| `'manual'` (CSS positions the box) |
51
+ | `placement` | `'auto'` | `'auto'` \| quadrant \| `'manual'` (CSS / host positions the **root** box) |
52
52
  | `targetAnchor` | `'center'` | `'center'` \| `'edge'` for element targets |
53
53
  | `maxWidth` | — | Wrap width (px) unless CSS sets width/max-width |
54
54
  | `tailLength` | `45` | Tip → box offset (px) |
55
55
  | `tailBaseWidth` | `24` | Tail width at the box (px) |
56
56
  | `padding` | `8` | Via `--pb-padding` unless CSS sets padding |
57
- | `shadow` | `true` | Shared drop-shadow on overlay/box |
57
+ | `shadow` | `true` | Drop-shadow on the root (includes the SVG tail) |
58
58
  | `transitionDuration` | `200` | Glide ms (`0` off; respects reduced motion) |
59
59
 
60
60
  Expose / ref: `update()` after non-reactive layout changes.
61
61
 
62
- CSS hooks: `.pointing-bubble`, `.pointing-bubble__inner`, `.pointing-bubble__svg`, `.pointing-bubble__path`. Vars: `--pb-padding`, `--pb-max-width`, `--pb-width`.
62
+ The component root is always the bubble chrome (`.pointing-bubble` + `.pointing-bubble__inner`). With a `target`, tip/tail use the nearest positioned ancestor as the coordinate frame; keep the bubble under that stage (avoid `overflow: hidden` between them). Free dragging / absolute CSS ⇒ `placement="manual"`; `auto` owns `left`/`top`.
63
63
 
64
- **Breaking (v0.2):** class prefix renamed from `.vue-pointing-bubble*` / `--vpb-*` to `.pointing-bubble*` / `--pb-*`.
64
+ CSS hooks: `.pointing-bubble`, `.pointing-bubble__inner`, `.pointing-bubble__svg`, `.pointing-bubble__path`. Vars: `--pb-padding`, `--pb-max-width`, `--pb-width`.
65
65
 
66
66
  ## License
67
67
 
@@ -13,7 +13,7 @@ type __VLS_Props = {
13
13
  };
14
14
  declare function update(): void;
15
15
  declare var __VLS_1: {
16
- placement: "none";
16
+ placement: string;
17
17
  tip: {
18
18
  x: number;
19
19
  y: number;
@@ -2,12 +2,12 @@ export type { Placement, ResolvedPlacement, TargetAnchor, Point, BubbleTarget, F
2
2
  export { DEFAULT_BUBBLE_CONFIG } from './types';
3
3
  export { injectBubbleStyles, SHADOW } from './styles';
4
4
  export { isPoint, resolveElement } from './resolveTarget';
5
- export { sameKeys, measureFrame, measureBox } from './measure';
5
+ export { sameKeys, positioningFrameEl, measureFrame, measureFrameFrom, measureBox, } from './measure';
6
6
  export { computeRoom, roomierSide, computeGeometry } from './geometry';
7
7
  export type { ComputeGeometryOptions } from './geometry';
8
8
  export { easeGeometry } from './ease';
9
9
  export type { EaseHandle } from './ease';
10
10
  export { buildTailPaths } from './tail';
11
11
  export type { BuildTailOptions } from './tail';
12
- export { createBubbleController } from './createBubbleController';
12
+ export { createBubbleController, isBubbleVisible, } from './createBubbleController';
13
13
  export type { BubbleRenderState, BubbleControllerOptions, BubbleController, } from './createBubbleController';
@@ -5,10 +5,13 @@ export interface BubbleRenderState {
5
5
  tip: Point | null;
6
6
  /** Tip passed to slot/children (resolved geometry tip when available). */
7
7
  slotTip: Point | null;
8
- overlayStyle: StyleMap;
8
+ /** Applied to the component root (always the bubble chrome). */
9
9
  boxStyle: StyleMap;
10
- /** When no target, root element is the box. */
11
- rootIsBox: boolean;
10
+ /**
11
+ * SVG layer covering the positioning frame, offset so path coords stay
12
+ * frame-local. Empty when there is no tail.
13
+ */
14
+ svgStyle: StyleMap;
12
15
  tail: TailPaths | null;
13
16
  boxFill: string;
14
17
  boxStroke: string;
@@ -16,7 +19,7 @@ export interface BubbleRenderState {
16
19
  boxZIndex: string;
17
20
  }
18
21
  export interface BubbleControllerOptions {
19
- getRootEl: () => HTMLElement | null;
22
+ /** The bubble chrome element (component root). */
20
23
  getBoxEl: () => HTMLElement | null;
21
24
  onChange?: (state: BubbleRenderState) => void;
22
25
  }
@@ -27,5 +30,7 @@ export interface BubbleController {
27
30
  getState: () => BubbleRenderState;
28
31
  destroy: () => void;
29
32
  }
33
+ /** True when the bubble chrome is painted (not display/visibility/opacity hidden). */
34
+ export declare function isBubbleVisible(el: HTMLElement): boolean;
30
35
  export declare function createBubbleController(options: BubbleControllerOptions): BubbleController;
31
36
  export type { BubbleTarget };
@@ -1,5 +1,13 @@
1
1
  import { BoxMeasure, FrameRect } from './types';
2
2
  export declare function sameKeys(a: Record<string, unknown> | null | undefined, b: Record<string, unknown> | null | undefined): boolean;
3
- /** Measure root frame including ancestor CSS scale (e.g. Slidev). */
4
- export declare function measureFrame(root: HTMLElement): FrameRect;
5
- export declare function measureBox(boxEl: HTMLElement, rootEl: HTMLElement, frame: FrameRect, manual: boolean): BoxMeasure;
3
+ /**
4
+ * Nearest positioned ancestor of `boxEl`, used as the tip/tail coordinate
5
+ * frame. Falls back to `document.documentElement`.
6
+ */
7
+ export declare function positioningFrameEl(boxEl: HTMLElement): HTMLElement;
8
+ /** Measure a frame element including ancestor CSS scale (e.g. Slidev). */
9
+ export declare function measureFrame(frameEl: HTMLElement): FrameRect;
10
+ /** Frame for tip/tail math: the bubble's positioning containing block. */
11
+ export declare function measureFrameFrom(boxEl: HTMLElement): FrameRect;
12
+ /** Box size and top-left in frame-local coordinates. */
13
+ export declare function measureBox(boxEl: HTMLElement, frame: FrameRect): BoxMeasure;
@@ -6,7 +6,14 @@ export interface BuildTailOptions {
6
6
  tailBaseWidth: number;
7
7
  }
8
8
  /**
9
- * Build fill + stroke SVG path `d` for the tail from the box wall facing the tip.
10
- * Fill extends 1px past the border inner edge to cover zoom snapping seams.
9
+ * Open wedge tail in frame space.
10
+ *
11
+ * The CSS box border stays as-is. SVG only draws the tip: short hooks that sit
12
+ * on the border band, then straight edges to the tip. SVG stroke is centred on
13
+ * the path, so the path runs down the middle of the border (depth −bw/2) and
14
+ * the stroke paints over the CSS border rather than into the content. Fill
15
+ * follows the same mouth→tip rays as the stroke (covering the border band via
16
+ * a short outer stub) so fill does not sit inside the stroke. No box outline
17
+ * is redrawn.
11
18
  */
12
19
  export declare function buildTailPaths(opts: BuildTailOptions): TailPaths | null;
@@ -31,6 +31,9 @@ export interface BoxMeasure {
31
31
  fill: string;
32
32
  stroke: string;
33
33
  strokeWidth: number;
34
+ /** CSS border widths — abspos children are offset from the padding edge. */
35
+ borderLeft: number;
36
+ borderTop: number;
34
37
  radius: string;
35
38
  zIndex: string;
36
39
  }
@@ -1,4 +1,4 @@
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) {
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) {
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(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;
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;
@@ -1,5 +1,5 @@
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
- const Q = {
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 = {
3
3
  target: null,
4
4
  placement: "auto",
5
5
  targetAnchor: "center",
@@ -8,7 +8,7 @@ const Q = {
8
8
  padding: 8,
9
9
  shadow: !0,
10
10
  transitionDuration: 200
11
- }, j = "pointing-bubble-styles", V = `:where(.pointing-bubble__inner) {
11
+ }, V = "pointing-bubble-styles", ht = `: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,173 +16,187 @@ const Q = {
16
16
  background: white;
17
17
  border: 2px solid gray;
18
18
  border-radius: 8px;
19
- }`, O = "drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";
20
- function J(e = document) {
21
- if (e.getElementById(j)) return;
19
+ }`, mt = "drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25))";
20
+ function gt(e = document) {
21
+ if (e.getElementById(V)) return;
22
22
  const t = e.createElement("style");
23
- t.id = j, t.textContent = V, e.head.prepend(t);
23
+ t.id = V, t.textContent = ht, e.head.prepend(t);
24
24
  }
25
- function tt(e) {
25
+ function bt(e) {
26
26
  return typeof e == "object" && e !== null && typeof e.x == "number" && typeof e.y == "number" && e.nodeType !== 1;
27
27
  }
28
- function et(e) {
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 A(e, t) {
31
+ function j(e, t) {
32
32
  return !e || !t ? !1 : Object.keys(e).every((n) => e[n] === t[n]);
33
33
  }
34
- function nt(e) {
35
- const t = e.getBoundingClientRect(), n = getComputedStyle(e), a = parseFloat(n.width) || 0, l = parseFloat(n.height) || 0;
34
+ function tt(e) {
35
+ let t = e.parentElement;
36
+ for (; t; ) {
37
+ const n = getComputedStyle(t).position;
38
+ if (n && n !== "static") return t;
39
+ if (t === document.documentElement) break;
40
+ t = t.parentElement;
41
+ }
42
+ return document.documentElement;
43
+ }
44
+ function xt(e) {
45
+ const t = e.getBoundingClientRect(), n = getComputedStyle(e), i = parseFloat(n.width) || 0, o = parseFloat(n.height) || 0;
36
46
  return {
37
47
  left: t.left,
38
48
  top: t.top,
39
- width: a,
40
- height: l,
41
- scaleX: a ? t.width / a : 1,
42
- scaleY: l ? t.height / l : 1,
49
+ width: i,
50
+ height: o,
51
+ scaleX: i ? t.width / i : 1,
52
+ scaleY: o ? t.height / o : 1,
43
53
  viewportWidth: window.innerWidth,
44
54
  viewportHeight: window.innerHeight
45
55
  };
46
56
  }
47
- function ot(e, t, n, a) {
48
- const l = getComputedStyle(e), { scaleX: i, scaleY: d } = n, r = e.getBoundingClientRect(), f = t.getBoundingClientRect();
57
+ function yt(e) {
58
+ return xt(tt(e));
59
+ }
60
+ function wt(e, t) {
61
+ const n = getComputedStyle(e), { scaleX: i, scaleY: o, left: u, top: a } = t, l = e.getBoundingClientRect();
49
62
  return {
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
- fill: l.backgroundColor,
55
- stroke: l.borderTopColor,
56
- strokeWidth: parseFloat(l.borderTopWidth) || 0,
57
- radius: l.borderTopLeftRadius,
58
- zIndex: l.zIndex
63
+ x: (l.left - u) / i,
64
+ y: (l.top - a) / o,
65
+ width: l.width / i,
66
+ height: l.height / o,
67
+ fill: n.backgroundColor,
68
+ stroke: n.borderTopColor,
69
+ strokeWidth: parseFloat(n.borderTopWidth) || 0,
70
+ // Abspos SVG is positioned against the padding edge; path math uses the
71
+ // border box from getBoundingClientRect — subtract these when offsetting.
72
+ borderLeft: (parseFloat(n.borderLeftWidth) || 0) / i,
73
+ borderTop: (parseFloat(n.borderTopWidth) || 0) / o,
74
+ radius: n.borderTopLeftRadius,
75
+ zIndex: n.zIndex
59
76
  };
60
77
  }
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,
78
+ function G(e, t, n) {
79
+ const i = e.x - n;
80
+ let o = i, u = t.width ? t.width - e.x - n : 1 / 0;
81
+ return t.viewportWidth && (o = Math.min(o, t.left / t.scaleX + i), u = Math.min(
82
+ u,
66
83
  (t.viewportWidth - t.left) / t.scaleX - e.x - n
67
- )), { left: Math.max(0, l), right: Math.max(0, i) };
84
+ )), { left: Math.max(0, o), right: Math.max(0, u) };
68
85
  }
69
- function X(e) {
86
+ function et(e) {
70
87
  return e.left > e.right ? "left" : "right";
71
88
  }
72
- function lt(e) {
73
- const { tip: t, box: n, frame: a, placement: l, targetRect: i, room: d, tailLength: r } = e;
89
+ function vt(e) {
90
+ const { tip: t, box: n, frame: i, placement: o, targetRect: u, room: a, tailLength: l } = e;
74
91
  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;
92
+ const { width: r, height: f } = n, { x: p, y: m } = t, k = o === "manual", c = e.targetAnchor === "edge" ? u : null;
76
93
  if (k) {
77
- if (o) {
78
- const y = n.x + f / 2, v = n.y + p / 2;
79
- if (!(y >= o.left && y <= o.right && v >= o.top && v <= o.bottom)) {
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: n.x, by: n.y, w: f, h: p };
94
+ if (c) {
95
+ const S = n.x + r / 2, W = n.y + f / 2;
96
+ if (!(S >= c.left && S <= c.right && W >= c.top && W <= c.bottom)) {
97
+ const g = Math.min(c.right, Math.max(c.left, S)), E = Math.min(c.bottom, Math.max(c.top, W));
98
+ return { placement: "manual", tx: g, ty: E, bx: n.x, by: n.y, w: r, h: f };
82
99
  }
83
100
  }
84
- return { placement: "manual", tx: g, ty: x, bx: n.x, by: n.y, w: f, h: p };
101
+ return { placement: "manual", tx: p, ty: m, bx: n.x, by: n.y, w: r, h: f };
85
102
  }
86
- const W = (y) => o ? y === "top" ? o.top : o.bottom : x;
87
- let S = l;
88
- if (l === "auto") {
89
- let y = x > (a.height || 600) / 2 ? "top" : "bottom", v = X(d);
90
- const { scaleX: u, scaleY: b } = a;
91
- if (a.viewportHeight) {
92
- const m = a.top + (W("top") - p - r) * b >= 0, w = a.top + (W("bottom") + p + r) * b <= a.viewportHeight;
93
- y === "top" && !m && w ? y = "bottom" : y === "bottom" && !w && m && (y = "top");
103
+ const C = (S) => c ? S === "top" ? c.top : c.bottom : m;
104
+ let y = o;
105
+ if (o === "auto") {
106
+ let S = m > (i.height || 600) / 2 ? "top" : "bottom", W = et(a);
107
+ const { scaleX: $, scaleY: g } = i;
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;
110
+ S === "top" && !E && A ? S = "bottom" : S === "bottom" && !A && E && (S = "top");
94
111
  }
95
- if (a.viewportWidth) {
96
- const m = a.left + (g - f - r) * u >= 0, w = a.left + (g + f + r) * u <= a.viewportWidth;
97
- v === "left" && !m && w ? v = "right" : v === "right" && !w && m && (v = "left");
112
+ if (i.viewportWidth) {
113
+ const E = i.left + (p - r - l) * $ >= 0, A = i.left + (p + r + l) * $ <= i.viewportWidth;
114
+ W === "left" && !E && A ? W = "right" : W === "right" && !A && E && (W = "left");
98
115
  }
99
- S = `${y}-${v}`;
116
+ y = `${S}-${W}`;
100
117
  }
101
- const [B, $] = S.split("-"), I = W(B);
118
+ const [d, _] = y.split("-"), w = C(d);
102
119
  return {
103
- placement: S,
104
- tx: g,
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
120
+ placement: y,
121
+ tx: p,
122
+ ty: w,
123
+ bx: _ === "left" ? p - r - l : p + l,
124
+ by: d === "top" ? w - f - l : w + l,
125
+ w: r,
126
+ h: f
110
127
  };
111
128
  }
112
- const it = ["tx", "ty", "bx", "by"], rt = ["tx", "ty"];
113
- function at() {
129
+ const St = ["tx", "ty", "bx", "by"], kt = ["tx", "ty"];
130
+ function Wt() {
114
131
  return typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches;
115
132
  }
116
- function st(e, t, n, a) {
117
- let l = 0;
118
- const i = () => {
119
- typeof cancelAnimationFrame < "u" && cancelAnimationFrame(l);
133
+ function Et(e, t, n, i) {
134
+ let o = 0;
135
+ const u = () => {
136
+ typeof cancelAnimationFrame < "u" && cancelAnimationFrame(o);
120
137
  };
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));
138
+ if (!t || !e || n <= 0 || typeof requestAnimationFrame > "u" || Wt())
139
+ return i(t), { cancel: u };
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;
142
+ for (const c of k)
143
+ m[c] = e[c] + (t[c] - e[c]) * p;
144
+ i(m), f < 1 && (o = requestAnimationFrame(l));
128
145
  };
129
- return l = requestAnimationFrame(r), { cancel: i };
146
+ return o = requestAnimationFrame(l), { cancel: u };
130
147
  }
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
- if (s > 0 && s >= c)
137
- S = d < f ? "left" : "right", B = r;
138
- else if (c > 0)
139
- S = r < p ? "top" : "bottom", B = d;
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));
150
+ let y = null, d = 0;
151
+ if (u === "manual") {
152
+ const x = Math.max(r - a, a - (r + p), 0), h = Math.max(f - l, l - (f + m), 0);
153
+ if (x > 0 && x >= h)
154
+ y = a < r ? "left" : "right", d = l;
155
+ else if (h > 0)
156
+ y = l < f ? "top" : "bottom", d = a;
140
157
  else
141
158
  return null;
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);
159
+ } else if (u !== "none") {
160
+ const [x, h] = u.split("-");
161
+ y = h === "left" ? "right" : "left", d = f + m * (x === "top" ? 0.65 : 0.35);
145
162
  } else
146
163
  return null;
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
- }[S], v = {
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
- ];
162
- return {
163
- inner: m(y(s, c)),
164
- outer: m(y(s, 0)),
165
- ctrl: m(h),
166
- end: m(C)
167
- };
168
- }, E = (s) => {
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
- };
164
+ const _ = y === "top" || y === "bottom", w = {
165
+ left: (x, h) => [r - h, x],
166
+ right: (x, h) => [r + p + h, x],
167
+ top: (x, h) => [x, f - h],
168
+ bottom: (x, h) => [x, f + m + h]
169
+ }[y], S = _ ? r : f, W = _ ? r + p : f + m, $ = C(
170
+ d,
171
+ S + c + n / 2 + k,
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);
172
174
  return {
173
- fill: `${E(-n - $)} Z`,
174
- stroke: n ? E(-n) : null
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
177
  };
176
178
  }
177
- function ct(e) {
179
+ const Lt = [
180
+ "left",
181
+ "top",
182
+ "right",
183
+ "bottom",
184
+ "width",
185
+ "height",
186
+ "transform",
187
+ "translate",
188
+ "inset",
189
+ "inset-inline",
190
+ "inset-block"
191
+ ];
192
+ function Ct(e) {
178
193
  return {
179
194
  hasTarget: e,
180
195
  placement: "none",
181
196
  tip: null,
182
197
  slotTip: null,
183
- overlayStyle: {},
184
198
  boxStyle: {},
185
- rootIsBox: !e,
199
+ svgStyle: {},
186
200
  tail: null,
187
201
  boxFill: "",
188
202
  boxStroke: "",
@@ -190,15 +204,31 @@ function ct(e) {
190
204
  boxZIndex: "auto"
191
205
  };
192
206
  }
193
- function Y(e, t) {
207
+ function D(e, t) {
194
208
  return e === t ? !0 : !e || !t ? !1 : e.x === t.x && e.y === t.y;
195
209
  }
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;
210
+ function $t(e, t) {
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
+ }
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;
215
+ }
216
+ function K(e) {
217
+ if (typeof e.checkVisibility == "function")
218
+ return e.checkVisibility({
219
+ checkOpacity: !0,
220
+ checkVisibilityCSS: !0
221
+ });
222
+ const t = getComputedStyle(e);
223
+ return !(t.display === "none" || t.visibility === "hidden" || parseFloat(t.opacity) === 0);
224
+ }
225
+ function J(e) {
226
+ const t = e.style;
227
+ return Lt.map((n) => t.getPropertyValue(n)).join("|");
198
228
  }
199
- function ft(e) {
200
- J();
201
- let t = { ...Q }, n = null, a = null, l = null, i = {
229
+ function At(e) {
230
+ gt();
231
+ let t = { ...pt }, n = null, i = null, o = null, u = {
202
232
  left: 0,
203
233
  top: 0,
204
234
  width: 0,
@@ -207,154 +237,194 @@ function ft(e) {
207
237
  scaleY: 1,
208
238
  viewportWidth: 0,
209
239
  viewportHeight: 0
210
- }, d = null, r = null, f = null, p = null, g = ct(!1);
211
- const x = () => {
212
- const u = k();
213
- dt(g, u) || (g = u, e.onChange?.(g));
240
+ }, a = null, l = null, r = null, f = null, p = null, m = null, k = Ct(!1), c = !1, C = "";
241
+ const y = () => {
242
+ const s = d();
243
+ _t(k, s) || (k = s, e.onChange?.(k));
214
244
  };
215
- function k() {
216
- const u = t.target != null, b = t.placement === "manual", m = u ? d?.placement ?? "none" : "none", w = {
217
- position: "absolute",
218
- inset: "0",
219
- pointerEvents: "none",
220
- filter: t.shadow ? O : void 0
221
- }, E = l?.zIndex;
222
- E && E !== "auto" && (w.zIndex = E);
223
- const s = {
245
+ function d() {
246
+ const s = t.target != null, b = t.placement === "manual", z = s ? a?.placement ?? "none" : "none", v = {
224
247
  "--pb-padding": typeof t.padding == "number" ? `${t.padding}px` : t.padding
225
248
  };
226
- if (t.maxWidth != null && (s["--pb-max-width"] = `${t.maxWidth}px`), !u)
227
- s["--pb-width"] = "fit-content", t.shadow && (s.filter = O);
228
- else if (Object.assign(s, {
249
+ if (t.maxWidth != null && (v["--pb-max-width"] = `${t.maxWidth}px`), t.shadow && (v.filter = mt), !s)
250
+ v["--pb-width"] = "fit-content";
251
+ else if (Object.assign(v, {
229
252
  position: "absolute",
230
253
  pointerEvents: "auto",
231
- visibility: d ? "visible" : "hidden"
254
+ overflow: "visible"
232
255
  }), b)
233
- s["--pb-width"] = "fit-content";
234
- else if (Object.assign(s, {
235
- left: `${d?.bx ?? 0}px`,
236
- top: `${d?.by ?? 0}px`,
256
+ v["--pb-width"] = "fit-content";
257
+ else if (Object.assign(v, {
258
+ left: `${a?.bx ?? 0}px`,
259
+ top: `${a?.by ?? 0}px`,
237
260
  margin: "0"
238
261
  }), 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];
240
- s["--pb-max-width"] = `${h[C]}px`;
262
+ const M = G(n, u, t.tailLength), B = l?.placement ?? t.placement, I = B === "auto" ? et(M) : B.split("-")[1];
263
+ v["--pb-max-width"] = `${M[I]}px`;
241
264
  }
242
- const c = u && d && l ? ut({
243
- geometry: d,
244
- strokeWidth: l.strokeWidth,
245
- radius: l.radius,
265
+ const L = o?.zIndex;
266
+ L && L !== "auto" && (v.zIndex = L);
267
+ const F = s && a && o ? Bt({
268
+ geometry: a,
269
+ strokeWidth: o.strokeWidth,
270
+ radius: o.radius,
246
271
  tailBaseWidth: t.tailBaseWidth
247
272
  }) : null;
273
+ let T = {};
274
+ if (F && a && u.width && u.height) {
275
+ const M = o?.borderLeft ?? 0, B = o?.borderTop ?? 0;
276
+ T = {
277
+ position: "absolute",
278
+ left: `${-a.bx - M}px`,
279
+ top: `${-a.by - B}px`,
280
+ width: `${u.width}px`,
281
+ height: `${u.height}px`,
282
+ overflow: "visible",
283
+ pointerEvents: "none",
284
+ zIndex: o?.zIndex ?? "auto"
285
+ };
286
+ }
248
287
  return {
249
- hasTarget: u,
250
- placement: m,
288
+ hasTarget: s,
289
+ placement: z,
251
290
  tip: n,
252
- slotTip: r ? { x: r.tx, y: r.ty } : n,
253
- overlayStyle: w,
254
- boxStyle: s,
255
- rootIsBox: !u,
256
- tail: c,
257
- boxFill: l?.fill ?? "",
258
- boxStroke: l?.stroke ?? "",
259
- boxStrokeWidth: l?.strokeWidth ?? 0,
260
- boxZIndex: l?.zIndex ?? "auto"
291
+ slotTip: l ? { x: l.tx, y: l.ty } : n,
292
+ boxStyle: v,
293
+ svgStyle: T,
294
+ tail: F,
295
+ boxFill: o?.fill ?? "",
296
+ boxStroke: o?.stroke ?? "",
297
+ boxStrokeWidth: o?.strokeWidth ?? 0,
298
+ boxZIndex: o?.zIndex ?? "auto"
261
299
  };
262
300
  }
263
- function o() {
264
- if (!n || !l) {
265
- r = null, W(null);
301
+ function _() {
302
+ if (!n || !o) {
303
+ (l !== null || a !== null) && (l = null, w(null));
266
304
  return;
267
305
  }
268
- const u = P(n, i, t.tailLength);
269
- r = lt({
306
+ const s = G(n, u, t.tailLength), b = vt({
270
307
  tip: n,
271
- box: l,
272
- frame: i,
308
+ box: o,
309
+ frame: u,
273
310
  placement: t.placement,
274
311
  targetAnchor: t.targetAnchor,
275
- targetRect: a,
276
- room: u,
312
+ targetRect: i,
313
+ room: s,
277
314
  tailLength: t.tailLength
278
- }), W(r);
315
+ });
316
+ $t(l, b) || (l = b, w(l));
279
317
  }
280
- function W(u) {
281
- f?.cancel(), f = st(
282
- d,
283
- u,
318
+ function w(s) {
319
+ r?.cancel(), r = Et(
320
+ a,
321
+ s,
284
322
  t.transitionDuration,
285
323
  (b) => {
286
- d = b, x();
324
+ a = b, y();
287
325
  }
288
326
  );
289
327
  }
290
- function S() {
291
- const u = e.getRootEl(), b = e.getBoxEl();
292
- if (!b || t.target == null || !u) return;
293
- const m = ot(
328
+ function S(s) {
329
+ const b = wt(s, u);
330
+ return j(
294
331
  b,
295
- u,
296
- i,
297
- t.placement === "manual"
298
- );
299
- A(
300
- m,
301
- l
302
- ) || (l = m);
332
+ o
333
+ ) ? !1 : (o = b, !0);
303
334
  }
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();
335
+ function W() {
336
+ const s = e.getBoxEl();
337
+ if (!s) {
338
+ n = null, i = null, o = null, l = null, a = null, c = !1, y();
339
+ return;
340
+ }
341
+ if (!K(s)) {
342
+ r?.cancel(), c = !0;
343
+ return;
344
+ }
345
+ const b = c;
346
+ if (c = !1, t.target == null) {
347
+ n = null, i = null, o = null, l = null, a = null, y();
308
348
  return;
309
349
  }
310
- i = nt(u);
311
- const b = et(t.target);
312
- if (b) {
313
- const m = b.getBoundingClientRect(), { scaleX: w, scaleY: E, left: s, top: c } = i, h = {
314
- left: (m.left - s) / w,
315
- top: (m.top - c) / E,
316
- right: (m.right - s) / w,
317
- bottom: (m.bottom - c) / E
350
+ const z = u;
351
+ u = yt(s);
352
+ const v = !j(
353
+ u,
354
+ z
355
+ ), L = typeof t.target == "string" ? tt(s).querySelector(t.target) ?? Z(t.target) : Z(t.target);
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
318
363
  };
319
- A(h, a) || (a = h), n = {
320
- x: (h.left + h.right) / 2,
321
- y: (h.top + h.bottom) / 2
364
+ T = !j(
365
+ R,
366
+ i
367
+ ), T && (i = R);
368
+ const N = {
369
+ x: (R.left + R.right) / 2,
370
+ y: (R.top + R.bottom) / 2
322
371
  };
323
- } else if (tt(t.target))
324
- a = null, n = { x: t.target.x, y: t.target.y };
325
- else {
326
- a = null, n = null, l = null, r = null, d = null, x();
372
+ F = !D(n, N), n = N;
373
+ } else if (bt(t.target)) {
374
+ T = i != null, i = null;
375
+ const B = { x: t.target.x, y: t.target.y };
376
+ F = !D(n, B), n = B;
377
+ } else {
378
+ n = null, i = null, o = null, l = null, a = null, y();
327
379
  return;
328
380
  }
329
- S(), o();
381
+ const M = S(s);
382
+ C = J(s), !(!b && !v && !F && !T && !M && a) && _();
330
383
  }
331
384
  function $() {
332
- B();
385
+ W();
333
386
  }
334
387
  typeof window < "u" && (window.addEventListener("resize", $), window.addEventListener("scroll", $, !0));
335
- function I() {
336
- if (typeof ResizeObserver > "u") return;
337
- p?.disconnect(), p = new ResizeObserver(() => B());
338
- const u = e.getRootEl(), b = e.getBoxEl();
339
- u && p.observe(u), b && p.observe(b);
388
+ const g = W;
389
+ function E(s) {
390
+ const b = e.getBoxEl();
391
+ if (!b) return;
392
+ if (s.some(
393
+ (L) => L.attributeName === "class" || L.attributeName === "hidden"
394
+ )) {
395
+ if (!K(b)) {
396
+ r?.cancel(), c = !0;
397
+ return;
398
+ }
399
+ g();
400
+ return;
401
+ }
402
+ const v = J(b);
403
+ v !== C && (C = v, g());
340
404
  }
341
- const y = B;
342
- function v() {
343
- I(), y();
405
+ function A() {
406
+ const s = e.getBoxEl();
407
+ s !== m && (m = s, f?.disconnect(), p?.disconnect(), f = null, p = null, s && (typeof ResizeObserver < "u" && (f = new ResizeObserver(() => g()), f.observe(s)), typeof MutationObserver < "u" && (p = new MutationObserver(E), p.observe(s, {
408
+ attributes: !0,
409
+ attributeFilter: ["style", "class", "hidden"]
410
+ }))));
411
+ }
412
+ function P() {
413
+ A(), g();
344
414
  }
345
415
  return {
346
- update: v,
347
- setConfig(u) {
348
- t = { ...t, ...u }, v();
416
+ update: P,
417
+ setConfig(s) {
418
+ t = { ...t, ...s }, P();
349
419
  },
350
420
  getConfig: () => t,
351
- getState: () => g,
421
+ getState: () => k,
352
422
  destroy() {
353
- f?.cancel(), p?.disconnect(), 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", $), window.removeEventListener("scroll", $, !0));
354
424
  }
355
425
  };
356
426
  }
357
- const pt = ["data-placement"], ht = ["d", "fill"], mt = ["d", "stroke", "stroke-width"], H = /* @__PURE__ */ Z({
427
+ const Tt = ["data-placement"], Ft = ["d", "fill"], Mt = ["d", "stroke", "stroke-width"], Q = /* @__PURE__ */ nt({
358
428
  name: "PointingBubble",
359
429
  inheritAttrs: !1,
360
430
  __name: "PointingBubble",
@@ -370,33 +440,34 @@ const pt = ["data-placement"], ht = ["d", "fill"], mt = ["d", "stroke", "stroke-
370
440
  transitionDuration: { default: 200 }
371
441
  },
372
442
  setup(e, { expose: t }) {
373
- const n = e, a = L(null), l = L(null), i = L({
443
+ const n = e, i = ot(), o = Y(() => i.class), u = Y(() => i.style), a = Y(() => {
444
+ const { class: d, style: _, ...w } = i;
445
+ return w;
446
+ }), l = it(null), r = lt({
374
447
  hasTarget: !1,
375
448
  placement: "none",
376
449
  tip: null,
377
450
  slotTip: null,
378
- overlayStyle: {},
379
451
  boxStyle: {},
380
- rootIsBox: !0,
452
+ svgStyle: {},
381
453
  tail: null,
382
454
  boxFill: "",
383
455
  boxStroke: "",
384
456
  boxStrokeWidth: 0,
385
457
  boxZIndex: "auto"
386
458
  });
387
- function d(o) {
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;
459
+ function f(d) {
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;
389
461
  }
390
- const r = ft({
391
- getRootEl: () => a.value,
462
+ const p = rt(), m = At({
392
463
  getBoxEl: () => l.value,
393
- onChange: (o) => {
394
- i.value = o;
464
+ onChange: (d) => {
465
+ Object.assign(r, d), p?.update();
395
466
  }
396
467
  });
397
- function f() {
398
- r.setConfig({
399
- target: d(n.target),
468
+ function k() {
469
+ m.setConfig({
470
+ target: f(n.target),
400
471
  placement: n.placement,
401
472
  targetAnchor: n.targetAnchor,
402
473
  maxWidth: n.maxWidth,
@@ -407,7 +478,7 @@ const pt = ["data-placement"], ht = ["d", "fill"], mt = ["d", "stroke", "stroke-
407
478
  transitionDuration: n.transitionDuration
408
479
  });
409
480
  }
410
- q(
481
+ st(
411
482
  () => [
412
483
  n.target,
413
484
  typeof n.target == "object" && n.target && "x" in n.target ? n.target.x : null,
@@ -421,90 +492,78 @@ const pt = ["data-placement"], ht = ["d", "fill"], mt = ["d", "stroke", "stroke-
421
492
  n.shadow,
422
493
  n.transitionDuration
423
494
  ],
424
- f,
495
+ k,
425
496
  { flush: "post" }
426
- ), N(() => {
427
- f();
428
- }), U(() => {
429
- r.destroy();
497
+ ), at(() => {
498
+ k();
499
+ }), ct(() => {
500
+ m.destroy();
430
501
  });
431
- function p() {
432
- r.update();
502
+ function c() {
503
+ m.update();
433
504
  }
434
- t({ update: p });
435
- const g = R(
436
- () => i.value.rootIsBox ? i.value.boxStyle : i.value.overlayStyle
437
- ), x = R(() => i.value.rootIsBox ? { display: "contents" } : i.value.boxStyle), k = R(
505
+ t({ update: c });
506
+ const C = Y(
438
507
  () => ({
439
- position: "absolute",
440
- inset: "0",
441
- width: "100%",
442
- height: "100%",
443
- overflow: "visible",
444
- zIndex: i.value.boxZIndex
508
+ ...u.value,
509
+ ...r.boxStyle
445
510
  })
446
- );
447
- return (o, W) => (z(), T("div", _({
511
+ ), y = Y(() => r.svgStyle);
512
+ return (d, _) => (H(), q("div", ut({
448
513
  ref_key: "rootRef",
449
- ref: a,
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", _({
454
- ref_key: "boxRef",
455
- ref: l,
456
- class: { "pointing-bubble__inner": !!e.target }
457
- }, e.target ? o.$attrs : {}, { style: x.value }), [
458
- G(o.$slots, "default", {
459
- placement: i.value.placement,
460
- tip: i.value.slotTip
461
- }, () => [
462
- W[0] || (W[0] = F("p", { style: {
463
- margin: 0,
464
- fontSize: "14px",
465
- fontWeight: 600,
466
- color: "#1e293b"
467
- } }, " Callout content ", -1))
468
- ])
469
- ], 16),
470
- e.target && i.value.tail ? (z(), T("svg", {
514
+ ref: l,
515
+ class: ["pointing-bubble", "pointing-bubble__inner", o.value],
516
+ "data-placement": r.placement
517
+ }, a.value, { style: C.value }), [
518
+ dt(d.$slots, "default", {
519
+ placement: r.placement,
520
+ tip: r.slotTip
521
+ }, () => [
522
+ _[0] || (_[0] = X("p", { style: {
523
+ margin: 0,
524
+ fontSize: "14px",
525
+ fontWeight: 600,
526
+ color: "#1e293b"
527
+ } }, " Callout content ", -1))
528
+ ]),
529
+ e.target && r.tail ? (H(), q("svg", {
471
530
  key: 0,
472
531
  class: "pointing-bubble__svg",
473
- style: K(k.value)
532
+ style: ft(y.value)
474
533
  }, [
475
- F("path", {
534
+ X("path", {
476
535
  class: "pointing-bubble__path",
477
- d: i.value.tail.fill,
478
- fill: i.value.boxFill
479
- }, null, 8, ht),
480
- i.value.tail.stroke ? (z(), T("path", {
536
+ d: r.tail.fill,
537
+ fill: r.boxFill
538
+ }, null, 8, Ft),
539
+ r.tail.stroke ? (H(), q("path", {
481
540
  key: 0,
482
541
  class: "pointing-bubble__path",
483
- d: i.value.tail.stroke,
542
+ d: r.tail.stroke,
484
543
  fill: "none",
485
- stroke: i.value.boxStroke,
486
- "stroke-width": i.value.boxStrokeWidth,
544
+ stroke: r.boxStroke,
545
+ "stroke-width": r.boxStrokeWidth,
487
546
  "stroke-linejoin": "round",
488
547
  "stroke-linecap": "butt"
489
- }, null, 8, mt)) : D("", !0)
490
- ], 4)) : D("", !0)
491
- ], 16, pt));
548
+ }, null, 8, Mt)) : U("", !0)
549
+ ], 4)) : U("", !0)
550
+ ], 16, Tt));
492
551
  }
493
- }), bt = {
552
+ }), It = {
494
553
  install(e, t = {}) {
495
554
  const n = t.name ?? "PointingBubble";
496
- e.component(n, H), e.component("Callout", H);
555
+ e.component(n, Q), e.component("Callout", Q);
497
556
  }
498
557
  };
499
558
  export {
500
- H as Callout,
501
- Q as DEFAULT_BUBBLE_CONFIG,
502
- H as PointingBubble,
503
- bt as PointingBubblePlugin,
504
- ut as buildTailPaths,
505
- lt as computeGeometry,
506
- ft as createBubbleController,
507
- H as default,
508
- tt as isPoint,
509
- et as resolveElement
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,
568
+ Z as resolveElement
510
569
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-pointing-bubble",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
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,