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