@destyler/tooltip 0.0.1-beta.9 → 0.0.2
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/LICENSE +21 -0
- package/dist/component.cjs +672 -0
- package/dist/component.d.cts +390 -0
- package/dist/component.d.mts +390 -0
- package/dist/component.d.ts +390 -0
- package/dist/component.mjs +663 -0
- package/dist/index.cjs +19 -670
- package/dist/index.d.cts +5 -999
- package/dist/index.d.mts +5 -999
- package/dist/index.d.ts +5 -999
- package/dist/index.mjs +10 -642
- package/dist/resolver.cjs +25 -0
- package/dist/resolver.d.cts +6 -0
- package/dist/resolver.d.mts +6 -0
- package/dist/resolver.d.ts +6 -0
- package/dist/resolver.mjs +22 -0
- package/dist/shared/tooltip.79d8523b.d.cts +600 -0
- package/dist/shared/tooltip.79d8523b.d.mts +600 -0
- package/dist/shared/tooltip.79d8523b.d.ts +600 -0
- package/package.json +18 -8
package/dist/index.cjs
CHANGED
|
@@ -1,672 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
required: false,
|
|
23
|
-
default: 5
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const DestylerTooltipArrow = vue.defineComponent({
|
|
27
|
-
name: "DestylerTooltipArrow",
|
|
28
|
-
props: destylerTooltipArrowProps,
|
|
29
|
-
render() {
|
|
30
|
-
return vue.h(popper.DestylerPopperArrow, vue.mergeProps(this.$props), this.$slots.default?.());
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const destylerTooltipProviderProps = {
|
|
35
|
-
delayDuration: {
|
|
36
|
-
type: Number,
|
|
37
|
-
required: false,
|
|
38
|
-
default: 700
|
|
39
|
-
},
|
|
40
|
-
skipDelayDuration: {
|
|
41
|
-
type: Number,
|
|
42
|
-
required: false,
|
|
43
|
-
default: 300
|
|
44
|
-
},
|
|
45
|
-
disableHoverableContent: {
|
|
46
|
-
type: Boolean,
|
|
47
|
-
required: false,
|
|
48
|
-
default: false
|
|
49
|
-
},
|
|
50
|
-
disableClosingTrigger: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
required: false,
|
|
53
|
-
default: false
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const [injectTooltipProviderContext, provideTooltipProviderContext] = shared.createContext("DestylerTooltipProvider");
|
|
57
|
-
const DestylerTooltipProvider = vue.defineComponent({
|
|
58
|
-
name: "DestylerTooltipProvider",
|
|
59
|
-
props: destylerTooltipProviderProps,
|
|
60
|
-
setup(props) {
|
|
61
|
-
const { delayDuration, skipDelayDuration, disableHoverableContent, disableClosingTrigger } = vue.toRefs(props);
|
|
62
|
-
const isOpenDelayed = vue.ref(true);
|
|
63
|
-
const isPointerInTransitRef = vue.ref(false);
|
|
64
|
-
const { start: startTimer, stop: clearTimer } = composition.useTimeoutFn(() => {
|
|
65
|
-
isOpenDelayed.value = true;
|
|
66
|
-
}, skipDelayDuration, { immediate: false });
|
|
67
|
-
provideTooltipProviderContext({
|
|
68
|
-
isOpenDelayed,
|
|
69
|
-
delayDuration,
|
|
70
|
-
onOpen() {
|
|
71
|
-
clearTimer();
|
|
72
|
-
isOpenDelayed.value = false;
|
|
73
|
-
},
|
|
74
|
-
onClose() {
|
|
75
|
-
startTimer();
|
|
76
|
-
},
|
|
77
|
-
isPointerInTransitRef,
|
|
78
|
-
onPointerInTransitChange(inTransit) {
|
|
79
|
-
isPointerInTransitRef.value = inTransit;
|
|
80
|
-
},
|
|
81
|
-
disableHoverableContent,
|
|
82
|
-
disableClosingTrigger
|
|
83
|
-
});
|
|
84
|
-
},
|
|
85
|
-
render() {
|
|
86
|
-
return this.$slots.default?.();
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const TOOLTIP_OPEN = "tooltip.open";
|
|
91
|
-
function getExitSideFromRect(point, rect) {
|
|
92
|
-
const top = Math.abs(rect.top - point.y);
|
|
93
|
-
const bottom = Math.abs(rect.bottom - point.y);
|
|
94
|
-
const right = Math.abs(rect.right - point.x);
|
|
95
|
-
const left = Math.abs(rect.left - point.x);
|
|
96
|
-
switch (Math.min(top, bottom, right, left)) {
|
|
97
|
-
case left:
|
|
98
|
-
return "left";
|
|
99
|
-
case right:
|
|
100
|
-
return "right";
|
|
101
|
-
case top:
|
|
102
|
-
return "top";
|
|
103
|
-
case bottom:
|
|
104
|
-
return "bottom";
|
|
105
|
-
default:
|
|
106
|
-
throw new Error("unreachable");
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
|
|
110
|
-
const paddedExitPoints = [];
|
|
111
|
-
switch (exitSide) {
|
|
112
|
-
case "top":
|
|
113
|
-
paddedExitPoints.push(
|
|
114
|
-
{ x: exitPoint.x - padding, y: exitPoint.y + padding },
|
|
115
|
-
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
|
|
116
|
-
);
|
|
117
|
-
break;
|
|
118
|
-
case "bottom":
|
|
119
|
-
paddedExitPoints.push(
|
|
120
|
-
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
|
|
121
|
-
{ x: exitPoint.x + padding, y: exitPoint.y - padding }
|
|
122
|
-
);
|
|
123
|
-
break;
|
|
124
|
-
case "left":
|
|
125
|
-
paddedExitPoints.push(
|
|
126
|
-
{ x: exitPoint.x + padding, y: exitPoint.y - padding },
|
|
127
|
-
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
|
|
128
|
-
);
|
|
129
|
-
break;
|
|
130
|
-
case "right":
|
|
131
|
-
paddedExitPoints.push(
|
|
132
|
-
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
|
|
133
|
-
{ x: exitPoint.x - padding, y: exitPoint.y + padding }
|
|
134
|
-
);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
return paddedExitPoints;
|
|
138
|
-
}
|
|
139
|
-
function getPointsFromRect(rect) {
|
|
140
|
-
const { top, right, bottom, left } = rect;
|
|
141
|
-
return [
|
|
142
|
-
{ x: left, y: top },
|
|
143
|
-
{ x: right, y: top },
|
|
144
|
-
{ x: right, y: bottom },
|
|
145
|
-
{ x: left, y: bottom }
|
|
146
|
-
];
|
|
147
|
-
}
|
|
148
|
-
function isPointInPolygon(point, polygon) {
|
|
149
|
-
const { x, y } = point;
|
|
150
|
-
let inside = false;
|
|
151
|
-
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
152
|
-
const xi = polygon[i].x;
|
|
153
|
-
const yi = polygon[i].y;
|
|
154
|
-
const xj = polygon[j].x;
|
|
155
|
-
const yj = polygon[j].y;
|
|
156
|
-
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
157
|
-
if (intersect)
|
|
158
|
-
inside = !inside;
|
|
159
|
-
}
|
|
160
|
-
return inside;
|
|
161
|
-
}
|
|
162
|
-
function getHull(points) {
|
|
163
|
-
const newPoints = points.slice();
|
|
164
|
-
newPoints.sort((a, b) => {
|
|
165
|
-
if (a.x < b.x)
|
|
166
|
-
return -1;
|
|
167
|
-
else if (a.x > b.x)
|
|
168
|
-
return 1;
|
|
169
|
-
else if (a.y < b.y)
|
|
170
|
-
return -1;
|
|
171
|
-
else if (a.y > b.y)
|
|
172
|
-
return 1;
|
|
173
|
-
else
|
|
174
|
-
return 0;
|
|
175
|
-
});
|
|
176
|
-
return getHullPresorted(newPoints);
|
|
177
|
-
}
|
|
178
|
-
function getHullPresorted(points) {
|
|
179
|
-
if (points.length <= 1)
|
|
180
|
-
return points.slice();
|
|
181
|
-
const upperHull = [];
|
|
182
|
-
for (let i = 0; i < points.length; i++) {
|
|
183
|
-
const p = points[i];
|
|
184
|
-
while (upperHull.length >= 2) {
|
|
185
|
-
const q = upperHull[upperHull.length - 1];
|
|
186
|
-
const r = upperHull[upperHull.length - 2];
|
|
187
|
-
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x))
|
|
188
|
-
upperHull.pop();
|
|
189
|
-
else
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
upperHull.push(p);
|
|
193
|
-
}
|
|
194
|
-
upperHull.pop();
|
|
195
|
-
const lowerHull = [];
|
|
196
|
-
for (let i = points.length - 1; i >= 0; i--) {
|
|
197
|
-
const p = points[i];
|
|
198
|
-
while (lowerHull.length >= 2) {
|
|
199
|
-
const q = lowerHull[lowerHull.length - 1];
|
|
200
|
-
const r = lowerHull[lowerHull.length - 2];
|
|
201
|
-
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x))
|
|
202
|
-
lowerHull.pop();
|
|
203
|
-
else
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
lowerHull.push(p);
|
|
207
|
-
}
|
|
208
|
-
lowerHull.pop();
|
|
209
|
-
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y)
|
|
210
|
-
return upperHull;
|
|
211
|
-
else
|
|
212
|
-
return upperHull.concat(lowerHull);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const destylerTooltipRootProps = {
|
|
216
|
-
defaultOpen: {
|
|
217
|
-
type: Boolean,
|
|
218
|
-
required: false,
|
|
219
|
-
default: false
|
|
220
|
-
},
|
|
221
|
-
open: {
|
|
222
|
-
type: Boolean,
|
|
223
|
-
required: false,
|
|
224
|
-
default: void 0
|
|
225
|
-
},
|
|
226
|
-
delayDuration: {
|
|
227
|
-
type: Number,
|
|
228
|
-
required: false,
|
|
229
|
-
default: 400
|
|
230
|
-
},
|
|
231
|
-
disableHoverableContent: {
|
|
232
|
-
type: Boolean,
|
|
233
|
-
required: false,
|
|
234
|
-
default: void 0
|
|
235
|
-
},
|
|
236
|
-
disableClosingTrigger: {
|
|
237
|
-
type: Boolean,
|
|
238
|
-
required: false,
|
|
239
|
-
default: void 0
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
const [injectTooltipRootContext, provideTooltipRootContext] = shared.createContext("DestylerTooltipRoot");
|
|
243
|
-
const DestylerTooltipRoot = vue.defineComponent({
|
|
244
|
-
name: "DestylerTooltipRoot",
|
|
245
|
-
props: destylerTooltipRootProps,
|
|
246
|
-
emits: ["update:open"],
|
|
247
|
-
setup(props, { emit }) {
|
|
248
|
-
const providerContext = injectTooltipProviderContext();
|
|
249
|
-
const disableHoverableContent = vue.computed(() => {
|
|
250
|
-
return props.disableHoverableContent ?? providerContext.disableHoverableContent.value;
|
|
251
|
-
});
|
|
252
|
-
const disableClosingTrigger = vue.computed(() => props.disableClosingTrigger ?? providerContext.disableClosingTrigger.value);
|
|
253
|
-
const delayDuration = vue.computed(() => props.delayDuration ?? providerContext.delayDuration.value);
|
|
254
|
-
const openRef = composition.useVModel(props, "open", emit, {
|
|
255
|
-
defaultValue: props.defaultOpen,
|
|
256
|
-
passive: props.open === void 0
|
|
257
|
-
});
|
|
258
|
-
vue.watch(openRef, (isOpen) => {
|
|
259
|
-
if (!providerContext.onClose)
|
|
260
|
-
return;
|
|
261
|
-
if (isOpen) {
|
|
262
|
-
providerContext.onOpen();
|
|
263
|
-
document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
|
|
264
|
-
} else {
|
|
265
|
-
providerContext.onClose();
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
const wasOpenDelayedRef = vue.ref(false);
|
|
269
|
-
const trigger = vue.ref();
|
|
270
|
-
const stateAttribute = vue.computed(() => {
|
|
271
|
-
if (!openRef.value)
|
|
272
|
-
return "closed";
|
|
273
|
-
return wasOpenDelayedRef.value ? "delayed-open" : "instant-open";
|
|
274
|
-
});
|
|
275
|
-
const { start: startTimer, stop: clearTimer } = composition.useTimeoutFn(() => {
|
|
276
|
-
wasOpenDelayedRef.value = true;
|
|
277
|
-
openRef.value = true;
|
|
278
|
-
}, delayDuration, { immediate: false });
|
|
279
|
-
function handleOpen() {
|
|
280
|
-
clearTimer();
|
|
281
|
-
wasOpenDelayedRef.value = false;
|
|
282
|
-
openRef.value = true;
|
|
283
|
-
}
|
|
284
|
-
function handleClose() {
|
|
285
|
-
clearTimer();
|
|
286
|
-
openRef.value = false;
|
|
287
|
-
}
|
|
288
|
-
function handleDelayedOpen() {
|
|
289
|
-
startTimer();
|
|
290
|
-
}
|
|
291
|
-
provideTooltipRootContext({
|
|
292
|
-
contentId: composition.useId(),
|
|
293
|
-
open: openRef,
|
|
294
|
-
stateAttribute,
|
|
295
|
-
trigger,
|
|
296
|
-
onTriggerChange(el) {
|
|
297
|
-
trigger.value = el;
|
|
298
|
-
},
|
|
299
|
-
onTriggerEnter() {
|
|
300
|
-
if (providerContext.isOpenDelayed.value)
|
|
301
|
-
handleDelayedOpen();
|
|
302
|
-
else
|
|
303
|
-
handleOpen();
|
|
304
|
-
},
|
|
305
|
-
onTriggerLeave() {
|
|
306
|
-
if (disableHoverableContent.value)
|
|
307
|
-
handleClose();
|
|
308
|
-
else
|
|
309
|
-
clearTimer();
|
|
310
|
-
},
|
|
311
|
-
onOpen: handleOpen,
|
|
312
|
-
onClose: handleClose,
|
|
313
|
-
disableHoverableContent,
|
|
314
|
-
disableClosingTrigger
|
|
315
|
-
});
|
|
316
|
-
},
|
|
317
|
-
render() {
|
|
318
|
-
return vue.h(popper.DestylerPopperRoot, this.$slots.default?.());
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
const destylerTooltipContentImplProps = {
|
|
323
|
-
...primitive.destylerPrimitiveProps,
|
|
324
|
-
side: {
|
|
325
|
-
type: String,
|
|
326
|
-
required: false,
|
|
327
|
-
default: "top"
|
|
328
|
-
},
|
|
329
|
-
sideOffset: {
|
|
330
|
-
type: Number,
|
|
331
|
-
required: false,
|
|
332
|
-
default: 0
|
|
333
|
-
},
|
|
334
|
-
align: {
|
|
335
|
-
type: String,
|
|
336
|
-
required: false,
|
|
337
|
-
default: "center"
|
|
338
|
-
},
|
|
339
|
-
alignOffset: {
|
|
340
|
-
type: Number,
|
|
341
|
-
required: false,
|
|
342
|
-
default: 0
|
|
343
|
-
},
|
|
344
|
-
avoidCollisions: {
|
|
345
|
-
type: Boolean,
|
|
346
|
-
required: false,
|
|
347
|
-
default: true
|
|
348
|
-
},
|
|
349
|
-
collisionBoundary: {
|
|
350
|
-
type: [Object, Array, null],
|
|
351
|
-
required: false,
|
|
352
|
-
default: () => []
|
|
353
|
-
},
|
|
354
|
-
collisionPadding: {
|
|
355
|
-
type: [Number, Object],
|
|
356
|
-
required: false,
|
|
357
|
-
default: 0
|
|
358
|
-
},
|
|
359
|
-
arrowPadding: {
|
|
360
|
-
type: Number,
|
|
361
|
-
required: false,
|
|
362
|
-
default: 0
|
|
363
|
-
},
|
|
364
|
-
sticky: {
|
|
365
|
-
type: String,
|
|
366
|
-
required: false,
|
|
367
|
-
default: "partial"
|
|
368
|
-
},
|
|
369
|
-
hideWhenDetached: {
|
|
370
|
-
type: Boolean,
|
|
371
|
-
required: false,
|
|
372
|
-
default: false
|
|
373
|
-
},
|
|
374
|
-
ariaLabel: {
|
|
375
|
-
type: String,
|
|
376
|
-
required: false
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
const destylerTooltipContentImplEmits = ["escapeKeyDown", "pointerDownOutside"];
|
|
380
|
-
const DestylerTooltipContentImpl = vue.defineComponent({
|
|
381
|
-
name: "DestylerTooltipContentImpl",
|
|
382
|
-
props: destylerTooltipContentImplProps,
|
|
383
|
-
emits: destylerTooltipContentImplEmits,
|
|
384
|
-
setup(props) {
|
|
385
|
-
const contentElement = vue.ref();
|
|
386
|
-
const rootContext = injectTooltipRootContext();
|
|
387
|
-
const slot = vue.useSlots();
|
|
388
|
-
const defaultSlot = vue.computed(() => slot.default?.());
|
|
389
|
-
const ariaLabel = vue.computed(() => {
|
|
390
|
-
if (props.ariaLabel)
|
|
391
|
-
return props.ariaLabel;
|
|
392
|
-
let content = "";
|
|
393
|
-
function recursiveTextSearch(node) {
|
|
394
|
-
if (typeof node.children === "string")
|
|
395
|
-
content += node.children;
|
|
396
|
-
else if (Array.isArray(node.children))
|
|
397
|
-
node.children.forEach((child) => recursiveTextSearch(child));
|
|
398
|
-
}
|
|
399
|
-
defaultSlot.value?.forEach((node) => recursiveTextSearch(node));
|
|
400
|
-
return content;
|
|
401
|
-
});
|
|
402
|
-
const popperContentProps = vue.computed(() => {
|
|
403
|
-
const { ariaLabel: _, ...restProps } = props;
|
|
404
|
-
return restProps;
|
|
405
|
-
});
|
|
406
|
-
vue.onMounted(() => {
|
|
407
|
-
core.useEventListener(window, "scroll", (event) => {
|
|
408
|
-
const target = event.target;
|
|
409
|
-
if (target?.contains(rootContext.trigger.value))
|
|
410
|
-
rootContext.onClose();
|
|
411
|
-
});
|
|
412
|
-
core.useEventListener(window, TOOLTIP_OPEN, rootContext.onClose);
|
|
413
|
-
});
|
|
414
|
-
return {
|
|
415
|
-
contentElement,
|
|
416
|
-
rootContext,
|
|
417
|
-
popperContentProps,
|
|
418
|
-
ariaLabel
|
|
419
|
-
};
|
|
420
|
-
},
|
|
421
|
-
render() {
|
|
422
|
-
return vue.h(dismissableLayer.DestylerDismissableLayer, {
|
|
423
|
-
asChild: true,
|
|
424
|
-
disableOutsidePointerEvents: false,
|
|
425
|
-
onEscapeKeyDown: (event) => {
|
|
426
|
-
this.$emit("escapeKeyDown", event);
|
|
427
|
-
},
|
|
428
|
-
onPointerDownOutside: (event) => {
|
|
429
|
-
if (this.rootContext.disableClosingTrigger.value && this.rootContext.trigger.value?.contains(event.target))
|
|
430
|
-
event.preventDefault();
|
|
431
|
-
this.$emit("pointerDownOutside", event);
|
|
432
|
-
},
|
|
433
|
-
onDismiss: () => {
|
|
434
|
-
this.rootContext.onClose();
|
|
435
|
-
}
|
|
436
|
-
}, vue.h(popper.DestylerPopperContent, vue.mergeProps(this.$attrs, this.popperContentProps, {
|
|
437
|
-
"ref": "contentElement",
|
|
438
|
-
"data-state": this.rootContext.stateAttribute.value,
|
|
439
|
-
"style": {
|
|
440
|
-
"--destyler_tooltip_content_transform_origin": "var(--destyler_popper_transform_origin)",
|
|
441
|
-
"--destyler_tooltip_content_available_width": "var(--destyler_popper_available_width)",
|
|
442
|
-
"--destyler_tooltip_content_available_height": "var(--destyler_popper_available_height)",
|
|
443
|
-
"--destyler_tooltip_trigger_width": "var(--destyler_popper_anchor_width)",
|
|
444
|
-
"--destyler_tooltip_trigger_height": "var(--destyler_popper_anchor_height)"
|
|
445
|
-
}
|
|
446
|
-
}), [
|
|
447
|
-
this.$slots.default?.(),
|
|
448
|
-
vue.h(visuallyHidden.DestylerVisuallyhidden, {
|
|
449
|
-
role: "tooltip"
|
|
450
|
-
}, this.ariaLabel)
|
|
451
|
-
]));
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
const DestylerTooltipContentHoverable = vue.defineComponent({
|
|
456
|
-
name: "DestylerTooltipContentHoverable",
|
|
457
|
-
props: destylerTooltipContentImplProps,
|
|
458
|
-
setup() {
|
|
459
|
-
const { customElement, currentElement } = composition.useCustomElement();
|
|
460
|
-
const { trigger, onClose } = injectTooltipRootContext();
|
|
461
|
-
const providerContext = injectTooltipProviderContext();
|
|
462
|
-
const pointerGraceArea = vue.ref(null);
|
|
463
|
-
function handleRemoveGraceArea() {
|
|
464
|
-
pointerGraceArea.value = null;
|
|
465
|
-
providerContext.onPointerInTransitChange(false);
|
|
466
|
-
}
|
|
467
|
-
function handleCreateGraceArea(event, hoverTarget) {
|
|
468
|
-
const currentTarget = event.currentTarget;
|
|
469
|
-
const exitPoint = { x: event.clientX, y: event.clientY };
|
|
470
|
-
const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
|
|
471
|
-
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
|
|
472
|
-
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
473
|
-
const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
|
|
474
|
-
pointerGraceArea.value = graceArea;
|
|
475
|
-
providerContext.onPointerInTransitChange(true);
|
|
476
|
-
}
|
|
477
|
-
vue.watchEffect((cleanupFn) => {
|
|
478
|
-
if (trigger.value && currentElement.value) {
|
|
479
|
-
const handleTriggerLeave = (event) => handleCreateGraceArea(event, currentElement.value);
|
|
480
|
-
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger.value);
|
|
481
|
-
trigger.value.addEventListener("pointerleave", handleTriggerLeave);
|
|
482
|
-
currentElement.value.addEventListener("pointerleave", handleContentLeave);
|
|
483
|
-
cleanupFn(() => {
|
|
484
|
-
trigger.value?.removeEventListener("pointerleave", handleTriggerLeave);
|
|
485
|
-
currentElement.value?.removeEventListener("pointerleave", handleContentLeave);
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
vue.watchEffect((cleanupFn) => {
|
|
490
|
-
if (pointerGraceArea.value) {
|
|
491
|
-
const handleTrackPointerGrace = (event) => {
|
|
492
|
-
if (!pointerGraceArea.value)
|
|
493
|
-
return;
|
|
494
|
-
const target = event.target;
|
|
495
|
-
const pointerPosition = { x: event.clientX, y: event.clientY };
|
|
496
|
-
const hasEnteredTarget = trigger.value?.contains(target) || currentElement.value?.contains(target);
|
|
497
|
-
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea.value);
|
|
498
|
-
if (hasEnteredTarget) {
|
|
499
|
-
handleRemoveGraceArea();
|
|
500
|
-
} else if (isPointerOutsideGraceArea) {
|
|
501
|
-
handleRemoveGraceArea();
|
|
502
|
-
onClose();
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
document.addEventListener("pointermove", handleTrackPointerGrace);
|
|
506
|
-
cleanupFn(() => document.removeEventListener("pointermove", handleTrackPointerGrace));
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
return {
|
|
510
|
-
customElement
|
|
511
|
-
};
|
|
512
|
-
},
|
|
513
|
-
render() {
|
|
514
|
-
return vue.h(DestylerTooltipContentImpl, {
|
|
515
|
-
ref: "customElement",
|
|
516
|
-
...vue.mergeProps(this.$props)
|
|
517
|
-
}, this.$slots.default?.());
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
const destylerTooltipContentProps = {
|
|
522
|
-
...destylerTooltipContentImplProps
|
|
523
|
-
};
|
|
524
|
-
const destylerTooltipContentEmits = [...destylerTooltipContentImplEmits];
|
|
525
|
-
const DestylerTooltipContent = vue.defineComponent({
|
|
526
|
-
name: "DestylerTooltipContent",
|
|
527
|
-
props: destylerTooltipContentProps,
|
|
528
|
-
emits: destylerTooltipContentEmits,
|
|
529
|
-
setup(props, { emit }) {
|
|
530
|
-
const rootContext = injectTooltipRootContext();
|
|
531
|
-
const forwarded = composition.useForwardPropsEmits(props, emit);
|
|
532
|
-
return {
|
|
533
|
-
rootContext,
|
|
534
|
-
forwarded
|
|
535
|
-
};
|
|
536
|
-
},
|
|
537
|
-
render() {
|
|
538
|
-
const useVShow = this.rootContext.open.value;
|
|
539
|
-
return useVShow ? vue.h(this.rootContext.disableHoverableContent.value ? DestylerTooltipContentImpl : DestylerTooltipContentHoverable, {
|
|
540
|
-
...this.forwarded
|
|
541
|
-
}, this.$slots.default?.()) : null;
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
const destylerTooltipPortalProps = {
|
|
546
|
-
...teleport.destylerTeleportProps
|
|
547
|
-
};
|
|
548
|
-
const DestylerTooltipPortal = vue.defineComponent({
|
|
549
|
-
name: "DestylerTooltipPortal",
|
|
550
|
-
props: destylerTooltipPortalProps,
|
|
551
|
-
render() {
|
|
552
|
-
return vue.h(teleport.DestylerTeleport, vue.mergeProps(this.$props), this.$slots.default?.());
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
const destylerTooltipTriggerProps = {
|
|
557
|
-
...primitive.destylerPrimitiveProp,
|
|
558
|
-
as: {
|
|
559
|
-
type: [String, Object],
|
|
560
|
-
required: false,
|
|
561
|
-
default: "button"
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
const DestylerTooltipTrigger = vue.defineComponent({
|
|
565
|
-
name: "DestylerTooltipTrigger",
|
|
566
|
-
props: destylerTooltipTriggerProps,
|
|
567
|
-
setup() {
|
|
568
|
-
const rootContext = injectTooltipRootContext();
|
|
569
|
-
const providerContext = injectTooltipProviderContext();
|
|
570
|
-
const { customElement, currentElement: triggerElement } = composition.useCustomElement();
|
|
571
|
-
const isPointerDown = vue.ref(false);
|
|
572
|
-
const hasPointerMoveOpened = vue.ref(false);
|
|
573
|
-
function handlePointerUp() {
|
|
574
|
-
isPointerDown.value = false;
|
|
575
|
-
}
|
|
576
|
-
function handlePointerDown() {
|
|
577
|
-
isPointerDown.value = true;
|
|
578
|
-
document.addEventListener("pointerup", handlePointerUp, { once: true });
|
|
579
|
-
}
|
|
580
|
-
vue.onMounted(() => {
|
|
581
|
-
rootContext.onTriggerChange(triggerElement.value);
|
|
582
|
-
});
|
|
583
|
-
return {
|
|
584
|
-
rootContext,
|
|
585
|
-
providerContext,
|
|
586
|
-
customElement,
|
|
587
|
-
isPointerDown,
|
|
588
|
-
hasPointerMoveOpened,
|
|
589
|
-
handlePointerDown
|
|
590
|
-
};
|
|
591
|
-
},
|
|
592
|
-
render() {
|
|
593
|
-
return vue.h(popper.DestylerPopperAnchor, {
|
|
594
|
-
asChild: true
|
|
595
|
-
}, vue.h(primitive.DestylerPrimitive, {
|
|
596
|
-
"ref": "customElement",
|
|
597
|
-
"aria-describedby": this.rootContext.open.value ? this.rootContext.contentId : void 0,
|
|
598
|
-
"data-state": this.rootContext.stateAttribute.value,
|
|
599
|
-
"as": this.$props.as,
|
|
600
|
-
"asChild": this.$props.asChild,
|
|
601
|
-
"onPointermove": (event) => {
|
|
602
|
-
if (event.pointerType === "touch")
|
|
603
|
-
return;
|
|
604
|
-
if (!this.hasPointerMoveOpened && !this.providerContext.isPointerInTransitRef.value) {
|
|
605
|
-
this.rootContext.onTriggerEnter();
|
|
606
|
-
this.hasPointerMoveOpened = true;
|
|
607
|
-
}
|
|
608
|
-
},
|
|
609
|
-
"onPointerleave": () => {
|
|
610
|
-
this.rootContext.onTriggerLeave();
|
|
611
|
-
this.hasPointerMoveOpened = false;
|
|
612
|
-
},
|
|
613
|
-
"onPointerdown": () => {
|
|
614
|
-
this.handlePointerDown();
|
|
615
|
-
},
|
|
616
|
-
"onFocus": () => {
|
|
617
|
-
if (!this.isPointerDown)
|
|
618
|
-
this.rootContext.onOpen();
|
|
619
|
-
},
|
|
620
|
-
"onBlur": () => {
|
|
621
|
-
this.rootContext.onClose();
|
|
622
|
-
},
|
|
623
|
-
"onClick": () => {
|
|
624
|
-
if (!this.rootContext.disableClosingTrigger.value)
|
|
625
|
-
this.rootContext.onClose();
|
|
626
|
-
}
|
|
627
|
-
}, this.$slots.default?.()));
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
const name = "@destyler/tooltip";
|
|
632
|
-
|
|
633
|
-
const packageName = name;
|
|
634
|
-
function DestylerTooltipResolver() {
|
|
635
|
-
return {
|
|
636
|
-
type: "component",
|
|
637
|
-
resolve: (name2) => {
|
|
638
|
-
if (name2 === "DestylerTemplate")
|
|
639
|
-
return { name: name2, from: packageName };
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
exports.DestylerTooltipArrow = DestylerTooltipArrow;
|
|
645
|
-
exports.DestylerTooltipContent = DestylerTooltipContent;
|
|
646
|
-
exports.DestylerTooltipContentHoverable = DestylerTooltipContentHoverable;
|
|
647
|
-
exports.DestylerTooltipContentImpl = DestylerTooltipContentImpl;
|
|
648
|
-
exports.DestylerTooltipPortal = DestylerTooltipPortal;
|
|
649
|
-
exports.DestylerTooltipProvider = DestylerTooltipProvider;
|
|
650
|
-
exports.DestylerTooltipResolver = DestylerTooltipResolver;
|
|
651
|
-
exports.DestylerTooltipRoot = DestylerTooltipRoot;
|
|
652
|
-
exports.DestylerTooltipTrigger = DestylerTooltipTrigger;
|
|
653
|
-
exports.TOOLTIP_OPEN = TOOLTIP_OPEN;
|
|
654
|
-
exports.destylerTooltipArrowProps = destylerTooltipArrowProps;
|
|
655
|
-
exports.destylerTooltipContentEmits = destylerTooltipContentEmits;
|
|
656
|
-
exports.destylerTooltipContentImplEmits = destylerTooltipContentImplEmits;
|
|
657
|
-
exports.destylerTooltipContentImplProps = destylerTooltipContentImplProps;
|
|
658
|
-
exports.destylerTooltipContentProps = destylerTooltipContentProps;
|
|
659
|
-
exports.destylerTooltipPortalProps = destylerTooltipPortalProps;
|
|
660
|
-
exports.destylerTooltipProviderProps = destylerTooltipProviderProps;
|
|
661
|
-
exports.destylerTooltipRootProps = destylerTooltipRootProps;
|
|
662
|
-
exports.destylerTooltipTriggerProps = destylerTooltipTriggerProps;
|
|
663
|
-
exports.getExitSideFromRect = getExitSideFromRect;
|
|
664
|
-
exports.getHull = getHull;
|
|
665
|
-
exports.getHullPresorted = getHullPresorted;
|
|
666
|
-
exports.getPaddedExitPoints = getPaddedExitPoints;
|
|
667
|
-
exports.getPointsFromRect = getPointsFromRect;
|
|
668
|
-
exports.injectTooltipProviderContext = injectTooltipProviderContext;
|
|
669
|
-
exports.injectTooltipRootContext = injectTooltipRootContext;
|
|
670
|
-
exports.isPointInPolygon = isPointInPolygon;
|
|
671
|
-
exports.provideTooltipProviderContext = provideTooltipProviderContext;
|
|
672
|
-
exports.provideTooltipRootContext = provideTooltipRootContext;
|
|
3
|
+
const index = require('./component.cjs');
|
|
4
|
+
require('vue');
|
|
5
|
+
require('@destyler/popper');
|
|
6
|
+
require('@destyler/composition');
|
|
7
|
+
require('@destyler/shared');
|
|
8
|
+
require('@vueuse/core');
|
|
9
|
+
require('@destyler/dismissable-layer');
|
|
10
|
+
require('@destyler/visually-hidden');
|
|
11
|
+
require('@destyler/teleport');
|
|
12
|
+
require('@destyler/primitive');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.DestylerTooltipArrow = index.DestylerTooltipArrow;
|
|
17
|
+
exports.DestylerTooltipContent = index.DestylerTooltipContent;
|
|
18
|
+
exports.DestylerTooltipPortal = index.DestylerTooltipPortal;
|
|
19
|
+
exports.DestylerTooltipProvider = index.DestylerTooltipProvider;
|
|
20
|
+
exports.DestylerTooltipRoot = index.DestylerTooltipRoot;
|
|
21
|
+
exports.DestylerTooltipTrigger = index.DestylerTooltipTrigger;
|