vue-pointing-bubble 0.1.0 → 0.2.0

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