@vingy/vueltip 2.1.0 → 2.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.
- package/README.md +53 -36
- package/dist/basicTooltip.component.d.ts +1 -0
- package/dist/basicTooltip.css +1 -42
- package/dist/composables.d.ts +21 -0
- package/dist/directive.d.ts +8 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +193 -0
- package/dist/keyboardListeners.d.ts +1 -0
- package/dist/listeners.d.ts +2 -0
- package/dist/options.d.ts +3 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/state.d.ts +20 -0
- package/dist/types.d.ts +45 -0
- package/dist/utils.d.ts +4 -0
- package/package.json +11 -8
- package/dist/chunk-CtajNgzt.mjs +0 -36
- package/dist/index.d.mts +0 -332
- package/dist/index.mjs +0 -1667
package/dist/index.mjs
DELETED
|
@@ -1,1667 +0,0 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./chunk-CtajNgzt.mjs";
|
|
2
|
-
import * as Vue from "vue";
|
|
3
|
-
import { computed, createApp, defineComponent, h, ref, useTemplateRef, watch } from "vue";
|
|
4
|
-
|
|
5
|
-
//#region ../../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
6
|
-
const min = Math.min;
|
|
7
|
-
const max = Math.max;
|
|
8
|
-
const round = Math.round;
|
|
9
|
-
const floor = Math.floor;
|
|
10
|
-
const createCoords = (v) => ({
|
|
11
|
-
x: v,
|
|
12
|
-
y: v
|
|
13
|
-
});
|
|
14
|
-
const oppositeSideMap = {
|
|
15
|
-
left: "right",
|
|
16
|
-
right: "left",
|
|
17
|
-
bottom: "top",
|
|
18
|
-
top: "bottom"
|
|
19
|
-
};
|
|
20
|
-
const oppositeAlignmentMap = {
|
|
21
|
-
start: "end",
|
|
22
|
-
end: "start"
|
|
23
|
-
};
|
|
24
|
-
function clamp(start, value, end) {
|
|
25
|
-
return max(start, min(value, end));
|
|
26
|
-
}
|
|
27
|
-
function evaluate(value, param) {
|
|
28
|
-
return typeof value === "function" ? value(param) : value;
|
|
29
|
-
}
|
|
30
|
-
function getSide(placement) {
|
|
31
|
-
return placement.split("-")[0];
|
|
32
|
-
}
|
|
33
|
-
function getAlignment(placement) {
|
|
34
|
-
return placement.split("-")[1];
|
|
35
|
-
}
|
|
36
|
-
function getOppositeAxis(axis) {
|
|
37
|
-
return axis === "x" ? "y" : "x";
|
|
38
|
-
}
|
|
39
|
-
function getAxisLength(axis) {
|
|
40
|
-
return axis === "y" ? "height" : "width";
|
|
41
|
-
}
|
|
42
|
-
const yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
43
|
-
function getSideAxis(placement) {
|
|
44
|
-
return yAxisSides.has(getSide(placement)) ? "y" : "x";
|
|
45
|
-
}
|
|
46
|
-
function getAlignmentAxis(placement) {
|
|
47
|
-
return getOppositeAxis(getSideAxis(placement));
|
|
48
|
-
}
|
|
49
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
50
|
-
if (rtl === void 0) rtl = false;
|
|
51
|
-
const alignment = getAlignment(placement);
|
|
52
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
53
|
-
const length = getAxisLength(alignmentAxis);
|
|
54
|
-
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
55
|
-
if (rects.reference[length] > rects.floating[length]) mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
56
|
-
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
57
|
-
}
|
|
58
|
-
function getExpandedPlacements(placement) {
|
|
59
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
60
|
-
return [
|
|
61
|
-
getOppositeAlignmentPlacement(placement),
|
|
62
|
-
oppositePlacement,
|
|
63
|
-
getOppositeAlignmentPlacement(oppositePlacement)
|
|
64
|
-
];
|
|
65
|
-
}
|
|
66
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
67
|
-
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
68
|
-
}
|
|
69
|
-
const lrPlacement = ["left", "right"];
|
|
70
|
-
const rlPlacement = ["right", "left"];
|
|
71
|
-
const tbPlacement = ["top", "bottom"];
|
|
72
|
-
const btPlacement = ["bottom", "top"];
|
|
73
|
-
function getSideList(side, isStart, rtl) {
|
|
74
|
-
switch (side) {
|
|
75
|
-
case "top":
|
|
76
|
-
case "bottom":
|
|
77
|
-
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
78
|
-
return isStart ? lrPlacement : rlPlacement;
|
|
79
|
-
case "left":
|
|
80
|
-
case "right": return isStart ? tbPlacement : btPlacement;
|
|
81
|
-
default: return [];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
85
|
-
const alignment = getAlignment(placement);
|
|
86
|
-
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
87
|
-
if (alignment) {
|
|
88
|
-
list = list.map((side) => side + "-" + alignment);
|
|
89
|
-
if (flipAlignment) list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
90
|
-
}
|
|
91
|
-
return list;
|
|
92
|
-
}
|
|
93
|
-
function getOppositePlacement(placement) {
|
|
94
|
-
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
95
|
-
}
|
|
96
|
-
function expandPaddingObject(padding) {
|
|
97
|
-
return {
|
|
98
|
-
top: 0,
|
|
99
|
-
right: 0,
|
|
100
|
-
bottom: 0,
|
|
101
|
-
left: 0,
|
|
102
|
-
...padding
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function getPaddingObject(padding) {
|
|
106
|
-
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
107
|
-
top: padding,
|
|
108
|
-
right: padding,
|
|
109
|
-
bottom: padding,
|
|
110
|
-
left: padding
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function rectToClientRect(rect) {
|
|
114
|
-
const { x, y, width, height } = rect;
|
|
115
|
-
return {
|
|
116
|
-
width,
|
|
117
|
-
height,
|
|
118
|
-
top: y,
|
|
119
|
-
left: x,
|
|
120
|
-
right: x + width,
|
|
121
|
-
bottom: y + height,
|
|
122
|
-
x,
|
|
123
|
-
y
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region ../../node_modules/.pnpm/@floating-ui+core@1.7.4/node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
129
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
130
|
-
let { reference, floating } = _ref;
|
|
131
|
-
const sideAxis = getSideAxis(placement);
|
|
132
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
133
|
-
const alignLength = getAxisLength(alignmentAxis);
|
|
134
|
-
const side = getSide(placement);
|
|
135
|
-
const isVertical = sideAxis === "y";
|
|
136
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
137
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
138
|
-
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
139
|
-
let coords;
|
|
140
|
-
switch (side) {
|
|
141
|
-
case "top":
|
|
142
|
-
coords = {
|
|
143
|
-
x: commonX,
|
|
144
|
-
y: reference.y - floating.height
|
|
145
|
-
};
|
|
146
|
-
break;
|
|
147
|
-
case "bottom":
|
|
148
|
-
coords = {
|
|
149
|
-
x: commonX,
|
|
150
|
-
y: reference.y + reference.height
|
|
151
|
-
};
|
|
152
|
-
break;
|
|
153
|
-
case "right":
|
|
154
|
-
coords = {
|
|
155
|
-
x: reference.x + reference.width,
|
|
156
|
-
y: commonY
|
|
157
|
-
};
|
|
158
|
-
break;
|
|
159
|
-
case "left":
|
|
160
|
-
coords = {
|
|
161
|
-
x: reference.x - floating.width,
|
|
162
|
-
y: commonY
|
|
163
|
-
};
|
|
164
|
-
break;
|
|
165
|
-
default: coords = {
|
|
166
|
-
x: reference.x,
|
|
167
|
-
y: reference.y
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
switch (getAlignment(placement)) {
|
|
171
|
-
case "start":
|
|
172
|
-
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
173
|
-
break;
|
|
174
|
-
case "end":
|
|
175
|
-
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
return coords;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
182
|
-
* element is overflowing a given clipping boundary on each side.
|
|
183
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
184
|
-
* - negative = how many pixels left before it will overflow
|
|
185
|
-
* - 0 = lies flush with the boundary
|
|
186
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
187
|
-
*/
|
|
188
|
-
async function detectOverflow(state, options) {
|
|
189
|
-
var _await$platform$isEle;
|
|
190
|
-
if (options === void 0) options = {};
|
|
191
|
-
const { x, y, platform, rects, elements, strategy } = state;
|
|
192
|
-
const { boundary = "clippingAncestors", rootBoundary = "viewport", elementContext = "floating", altBoundary = false, padding = 0 } = evaluate(options, state);
|
|
193
|
-
const paddingObject = getPaddingObject(padding);
|
|
194
|
-
const element = elements[altBoundary ? elementContext === "floating" ? "reference" : "floating" : elementContext];
|
|
195
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
196
|
-
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)),
|
|
197
|
-
boundary,
|
|
198
|
-
rootBoundary,
|
|
199
|
-
strategy
|
|
200
|
-
}));
|
|
201
|
-
const rect = elementContext === "floating" ? {
|
|
202
|
-
x,
|
|
203
|
-
y,
|
|
204
|
-
width: rects.floating.width,
|
|
205
|
-
height: rects.floating.height
|
|
206
|
-
} : rects.reference;
|
|
207
|
-
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
208
|
-
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
|
|
209
|
-
x: 1,
|
|
210
|
-
y: 1
|
|
211
|
-
} : {
|
|
212
|
-
x: 1,
|
|
213
|
-
y: 1
|
|
214
|
-
};
|
|
215
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
216
|
-
elements,
|
|
217
|
-
rect,
|
|
218
|
-
offsetParent,
|
|
219
|
-
strategy
|
|
220
|
-
}) : rect);
|
|
221
|
-
return {
|
|
222
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
223
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
224
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
225
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
230
|
-
* next to a given reference element.
|
|
231
|
-
*
|
|
232
|
-
* This export does not have any `platform` interface logic. You will need to
|
|
233
|
-
* write one for the platform you are using Floating UI with.
|
|
234
|
-
*/
|
|
235
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
236
|
-
const { placement = "bottom", strategy = "absolute", middleware = [], platform } = config;
|
|
237
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
238
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
239
|
-
let rects = await platform.getElementRects({
|
|
240
|
-
reference,
|
|
241
|
-
floating,
|
|
242
|
-
strategy
|
|
243
|
-
});
|
|
244
|
-
let { x, y } = computeCoordsFromPlacement(rects, placement, rtl);
|
|
245
|
-
let statefulPlacement = placement;
|
|
246
|
-
let middlewareData = {};
|
|
247
|
-
let resetCount = 0;
|
|
248
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
249
|
-
var _platform$detectOverf;
|
|
250
|
-
const { name, fn } = validMiddleware[i];
|
|
251
|
-
const { x: nextX, y: nextY, data, reset } = await fn({
|
|
252
|
-
x,
|
|
253
|
-
y,
|
|
254
|
-
initialPlacement: placement,
|
|
255
|
-
placement: statefulPlacement,
|
|
256
|
-
strategy,
|
|
257
|
-
middlewareData,
|
|
258
|
-
rects,
|
|
259
|
-
platform: {
|
|
260
|
-
...platform,
|
|
261
|
-
detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
|
|
262
|
-
},
|
|
263
|
-
elements: {
|
|
264
|
-
reference,
|
|
265
|
-
floating
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
x = nextX != null ? nextX : x;
|
|
269
|
-
y = nextY != null ? nextY : y;
|
|
270
|
-
middlewareData = {
|
|
271
|
-
...middlewareData,
|
|
272
|
-
[name]: {
|
|
273
|
-
...middlewareData[name],
|
|
274
|
-
...data
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
if (reset && resetCount <= 50) {
|
|
278
|
-
resetCount++;
|
|
279
|
-
if (typeof reset === "object") {
|
|
280
|
-
if (reset.placement) statefulPlacement = reset.placement;
|
|
281
|
-
if (reset.rects) rects = reset.rects === true ? await platform.getElementRects({
|
|
282
|
-
reference,
|
|
283
|
-
floating,
|
|
284
|
-
strategy
|
|
285
|
-
}) : reset.rects;
|
|
286
|
-
({x, y} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
287
|
-
}
|
|
288
|
-
i = -1;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return {
|
|
292
|
-
x,
|
|
293
|
-
y,
|
|
294
|
-
placement: statefulPlacement,
|
|
295
|
-
strategy,
|
|
296
|
-
middlewareData
|
|
297
|
-
};
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* Provides data to position an inner element of the floating element so that it
|
|
301
|
-
* appears centered to the reference element.
|
|
302
|
-
* @see https://floating-ui.com/docs/arrow
|
|
303
|
-
*/
|
|
304
|
-
const arrow$2 = (options) => ({
|
|
305
|
-
name: "arrow",
|
|
306
|
-
options,
|
|
307
|
-
async fn(state) {
|
|
308
|
-
const { x, y, placement, rects, platform, elements, middlewareData } = state;
|
|
309
|
-
const { element, padding = 0 } = evaluate(options, state) || {};
|
|
310
|
-
if (element == null) return {};
|
|
311
|
-
const paddingObject = getPaddingObject(padding);
|
|
312
|
-
const coords = {
|
|
313
|
-
x,
|
|
314
|
-
y
|
|
315
|
-
};
|
|
316
|
-
const axis = getAlignmentAxis(placement);
|
|
317
|
-
const length = getAxisLength(axis);
|
|
318
|
-
const arrowDimensions = await platform.getDimensions(element);
|
|
319
|
-
const isYAxis = axis === "y";
|
|
320
|
-
const minProp = isYAxis ? "top" : "left";
|
|
321
|
-
const maxProp = isYAxis ? "bottom" : "right";
|
|
322
|
-
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
323
|
-
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
324
|
-
const startDiff = coords[axis] - rects.reference[axis];
|
|
325
|
-
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
326
|
-
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
327
|
-
if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
328
|
-
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
329
|
-
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
330
|
-
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
331
|
-
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
332
|
-
const min$1 = minPadding;
|
|
333
|
-
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
334
|
-
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
335
|
-
const offset = clamp(min$1, center, max);
|
|
336
|
-
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
337
|
-
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
338
|
-
return {
|
|
339
|
-
[axis]: coords[axis] + alignmentOffset,
|
|
340
|
-
data: {
|
|
341
|
-
[axis]: offset,
|
|
342
|
-
centerOffset: center - offset - alignmentOffset,
|
|
343
|
-
...shouldAddOffset && { alignmentOffset }
|
|
344
|
-
},
|
|
345
|
-
reset: shouldAddOffset
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
/**
|
|
350
|
-
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
351
|
-
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
352
|
-
* clipping boundary. Alternative to `autoPlacement`.
|
|
353
|
-
* @see https://floating-ui.com/docs/flip
|
|
354
|
-
*/
|
|
355
|
-
const flip$1 = function(options) {
|
|
356
|
-
if (options === void 0) options = {};
|
|
357
|
-
return {
|
|
358
|
-
name: "flip",
|
|
359
|
-
options,
|
|
360
|
-
async fn(state) {
|
|
361
|
-
var _middlewareData$arrow, _middlewareData$flip;
|
|
362
|
-
const { placement, middlewareData, rects, initialPlacement, platform, elements } = state;
|
|
363
|
-
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy = "bestFit", fallbackAxisSideDirection = "none", flipAlignment = true, ...detectOverflowOptions } = evaluate(options, state);
|
|
364
|
-
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {};
|
|
365
|
-
const side = getSide(placement);
|
|
366
|
-
const initialSideAxis = getSideAxis(initialPlacement);
|
|
367
|
-
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
368
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
369
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
370
|
-
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
371
|
-
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
372
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
373
|
-
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
374
|
-
const overflows = [];
|
|
375
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
376
|
-
if (checkMainAxis) overflows.push(overflow[side]);
|
|
377
|
-
if (checkCrossAxis) {
|
|
378
|
-
const sides = getAlignmentSides(placement, rects, rtl);
|
|
379
|
-
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
380
|
-
}
|
|
381
|
-
overflowsData = [...overflowsData, {
|
|
382
|
-
placement,
|
|
383
|
-
overflows
|
|
384
|
-
}];
|
|
385
|
-
if (!overflows.every((side) => side <= 0)) {
|
|
386
|
-
var _middlewareData$flip2, _overflowsData$filter;
|
|
387
|
-
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
388
|
-
const nextPlacement = placements[nextIndex];
|
|
389
|
-
if (nextPlacement) {
|
|
390
|
-
if (!(checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false) || overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) return {
|
|
391
|
-
data: {
|
|
392
|
-
index: nextIndex,
|
|
393
|
-
overflows: overflowsData
|
|
394
|
-
},
|
|
395
|
-
reset: { placement: nextPlacement }
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
399
|
-
if (!resetPlacement) switch (fallbackStrategy) {
|
|
400
|
-
case "bestFit": {
|
|
401
|
-
var _overflowsData$filter2;
|
|
402
|
-
const placement = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
403
|
-
if (hasFallbackAxisSideDirection) {
|
|
404
|
-
const currentSideAxis = getSideAxis(d.placement);
|
|
405
|
-
return currentSideAxis === initialSideAxis || currentSideAxis === "y";
|
|
406
|
-
}
|
|
407
|
-
return true;
|
|
408
|
-
}).map((d) => [d.placement, d.overflows.filter((overflow) => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
409
|
-
if (placement) resetPlacement = placement;
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
case "initialPlacement":
|
|
413
|
-
resetPlacement = initialPlacement;
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
if (placement !== resetPlacement) return { reset: { placement: resetPlacement } };
|
|
417
|
-
}
|
|
418
|
-
return {};
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
};
|
|
422
|
-
const originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
423
|
-
async function convertValueToCoords(state, options) {
|
|
424
|
-
const { placement, platform, elements } = state;
|
|
425
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
426
|
-
const side = getSide(placement);
|
|
427
|
-
const alignment = getAlignment(placement);
|
|
428
|
-
const isVertical = getSideAxis(placement) === "y";
|
|
429
|
-
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
430
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
431
|
-
const rawValue = evaluate(options, state);
|
|
432
|
-
let { mainAxis, crossAxis, alignmentAxis } = typeof rawValue === "number" ? {
|
|
433
|
-
mainAxis: rawValue,
|
|
434
|
-
crossAxis: 0,
|
|
435
|
-
alignmentAxis: null
|
|
436
|
-
} : {
|
|
437
|
-
mainAxis: rawValue.mainAxis || 0,
|
|
438
|
-
crossAxis: rawValue.crossAxis || 0,
|
|
439
|
-
alignmentAxis: rawValue.alignmentAxis
|
|
440
|
-
};
|
|
441
|
-
if (alignment && typeof alignmentAxis === "number") crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
442
|
-
return isVertical ? {
|
|
443
|
-
x: crossAxis * crossAxisMulti,
|
|
444
|
-
y: mainAxis * mainAxisMulti
|
|
445
|
-
} : {
|
|
446
|
-
x: mainAxis * mainAxisMulti,
|
|
447
|
-
y: crossAxis * crossAxisMulti
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Modifies the placement by translating the floating element along the
|
|
452
|
-
* specified axes.
|
|
453
|
-
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
454
|
-
* object may be passed.
|
|
455
|
-
* @see https://floating-ui.com/docs/offset
|
|
456
|
-
*/
|
|
457
|
-
const offset$1 = function(options) {
|
|
458
|
-
if (options === void 0) options = 0;
|
|
459
|
-
return {
|
|
460
|
-
name: "offset",
|
|
461
|
-
options,
|
|
462
|
-
async fn(state) {
|
|
463
|
-
var _middlewareData$offse, _middlewareData$arrow;
|
|
464
|
-
const { x, y, placement, middlewareData } = state;
|
|
465
|
-
const diffCoords = await convertValueToCoords(state, options);
|
|
466
|
-
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {};
|
|
467
|
-
return {
|
|
468
|
-
x: x + diffCoords.x,
|
|
469
|
-
y: y + diffCoords.y,
|
|
470
|
-
data: {
|
|
471
|
-
...diffCoords,
|
|
472
|
-
placement
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
};
|
|
478
|
-
/**
|
|
479
|
-
* Optimizes the visibility of the floating element by shifting it in order to
|
|
480
|
-
* keep it in view when it will overflow the clipping boundary.
|
|
481
|
-
* @see https://floating-ui.com/docs/shift
|
|
482
|
-
*/
|
|
483
|
-
const shift$1 = function(options) {
|
|
484
|
-
if (options === void 0) options = {};
|
|
485
|
-
return {
|
|
486
|
-
name: "shift",
|
|
487
|
-
options,
|
|
488
|
-
async fn(state) {
|
|
489
|
-
const { x, y, placement, platform } = state;
|
|
490
|
-
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter = { fn: (_ref) => {
|
|
491
|
-
let { x, y } = _ref;
|
|
492
|
-
return {
|
|
493
|
-
x,
|
|
494
|
-
y
|
|
495
|
-
};
|
|
496
|
-
} }, ...detectOverflowOptions } = evaluate(options, state);
|
|
497
|
-
const coords = {
|
|
498
|
-
x,
|
|
499
|
-
y
|
|
500
|
-
};
|
|
501
|
-
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
502
|
-
const crossAxis = getSideAxis(getSide(placement));
|
|
503
|
-
const mainAxis = getOppositeAxis(crossAxis);
|
|
504
|
-
let mainAxisCoord = coords[mainAxis];
|
|
505
|
-
let crossAxisCoord = coords[crossAxis];
|
|
506
|
-
if (checkMainAxis) {
|
|
507
|
-
const minSide = mainAxis === "y" ? "top" : "left";
|
|
508
|
-
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
509
|
-
const min = mainAxisCoord + overflow[minSide];
|
|
510
|
-
const max = mainAxisCoord - overflow[maxSide];
|
|
511
|
-
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
512
|
-
}
|
|
513
|
-
if (checkCrossAxis) {
|
|
514
|
-
const minSide = crossAxis === "y" ? "top" : "left";
|
|
515
|
-
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
516
|
-
const min = crossAxisCoord + overflow[minSide];
|
|
517
|
-
const max = crossAxisCoord - overflow[maxSide];
|
|
518
|
-
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
519
|
-
}
|
|
520
|
-
const limitedCoords = limiter.fn({
|
|
521
|
-
...state,
|
|
522
|
-
[mainAxis]: mainAxisCoord,
|
|
523
|
-
[crossAxis]: crossAxisCoord
|
|
524
|
-
});
|
|
525
|
-
return {
|
|
526
|
-
...limitedCoords,
|
|
527
|
-
data: {
|
|
528
|
-
x: limitedCoords.x - x,
|
|
529
|
-
y: limitedCoords.y - y,
|
|
530
|
-
enabled: {
|
|
531
|
-
[mainAxis]: checkMainAxis,
|
|
532
|
-
[crossAxis]: checkCrossAxis
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
//#endregion
|
|
541
|
-
//#region ../../node_modules/.pnpm/@floating-ui+utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
542
|
-
function hasWindow() {
|
|
543
|
-
return typeof window !== "undefined";
|
|
544
|
-
}
|
|
545
|
-
function getNodeName(node) {
|
|
546
|
-
if (isNode(node)) return (node.nodeName || "").toLowerCase();
|
|
547
|
-
return "#document";
|
|
548
|
-
}
|
|
549
|
-
function getWindow(node) {
|
|
550
|
-
var _node$ownerDocument;
|
|
551
|
-
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
552
|
-
}
|
|
553
|
-
function getDocumentElement(node) {
|
|
554
|
-
var _ref;
|
|
555
|
-
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
556
|
-
}
|
|
557
|
-
function isNode(value) {
|
|
558
|
-
if (!hasWindow()) return false;
|
|
559
|
-
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
560
|
-
}
|
|
561
|
-
function isElement(value) {
|
|
562
|
-
if (!hasWindow()) return false;
|
|
563
|
-
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
564
|
-
}
|
|
565
|
-
function isHTMLElement(value) {
|
|
566
|
-
if (!hasWindow()) return false;
|
|
567
|
-
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
568
|
-
}
|
|
569
|
-
function isShadowRoot(value) {
|
|
570
|
-
if (!hasWindow() || typeof ShadowRoot === "undefined") return false;
|
|
571
|
-
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
572
|
-
}
|
|
573
|
-
const invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
574
|
-
function isOverflowElement(element) {
|
|
575
|
-
const { overflow, overflowX, overflowY, display } = getComputedStyle$1(element);
|
|
576
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
577
|
-
}
|
|
578
|
-
const tableElements = /* @__PURE__ */ new Set([
|
|
579
|
-
"table",
|
|
580
|
-
"td",
|
|
581
|
-
"th"
|
|
582
|
-
]);
|
|
583
|
-
function isTableElement(element) {
|
|
584
|
-
return tableElements.has(getNodeName(element));
|
|
585
|
-
}
|
|
586
|
-
const topLayerSelectors = [":popover-open", ":modal"];
|
|
587
|
-
function isTopLayer(element) {
|
|
588
|
-
return topLayerSelectors.some((selector) => {
|
|
589
|
-
try {
|
|
590
|
-
return element.matches(selector);
|
|
591
|
-
} catch (_e) {
|
|
592
|
-
return false;
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
const transformProperties = [
|
|
597
|
-
"transform",
|
|
598
|
-
"translate",
|
|
599
|
-
"scale",
|
|
600
|
-
"rotate",
|
|
601
|
-
"perspective"
|
|
602
|
-
];
|
|
603
|
-
const willChangeValues = [
|
|
604
|
-
"transform",
|
|
605
|
-
"translate",
|
|
606
|
-
"scale",
|
|
607
|
-
"rotate",
|
|
608
|
-
"perspective",
|
|
609
|
-
"filter"
|
|
610
|
-
];
|
|
611
|
-
const containValues = [
|
|
612
|
-
"paint",
|
|
613
|
-
"layout",
|
|
614
|
-
"strict",
|
|
615
|
-
"content"
|
|
616
|
-
];
|
|
617
|
-
function isContainingBlock(elementOrCss) {
|
|
618
|
-
const webkit = isWebKit();
|
|
619
|
-
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
620
|
-
return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
|
|
621
|
-
}
|
|
622
|
-
function getContainingBlock(element) {
|
|
623
|
-
let currentNode = getParentNode(element);
|
|
624
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
625
|
-
if (isContainingBlock(currentNode)) return currentNode;
|
|
626
|
-
else if (isTopLayer(currentNode)) return null;
|
|
627
|
-
currentNode = getParentNode(currentNode);
|
|
628
|
-
}
|
|
629
|
-
return null;
|
|
630
|
-
}
|
|
631
|
-
function isWebKit() {
|
|
632
|
-
if (typeof CSS === "undefined" || !CSS.supports) return false;
|
|
633
|
-
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
634
|
-
}
|
|
635
|
-
const lastTraversableNodeNames = /* @__PURE__ */ new Set([
|
|
636
|
-
"html",
|
|
637
|
-
"body",
|
|
638
|
-
"#document"
|
|
639
|
-
]);
|
|
640
|
-
function isLastTraversableNode(node) {
|
|
641
|
-
return lastTraversableNodeNames.has(getNodeName(node));
|
|
642
|
-
}
|
|
643
|
-
function getComputedStyle$1(element) {
|
|
644
|
-
return getWindow(element).getComputedStyle(element);
|
|
645
|
-
}
|
|
646
|
-
function getNodeScroll(element) {
|
|
647
|
-
if (isElement(element)) return {
|
|
648
|
-
scrollLeft: element.scrollLeft,
|
|
649
|
-
scrollTop: element.scrollTop
|
|
650
|
-
};
|
|
651
|
-
return {
|
|
652
|
-
scrollLeft: element.scrollX,
|
|
653
|
-
scrollTop: element.scrollY
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
function getParentNode(node) {
|
|
657
|
-
if (getNodeName(node) === "html") return node;
|
|
658
|
-
const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
|
|
659
|
-
return isShadowRoot(result) ? result.host : result;
|
|
660
|
-
}
|
|
661
|
-
function getNearestOverflowAncestor(node) {
|
|
662
|
-
const parentNode = getParentNode(node);
|
|
663
|
-
if (isLastTraversableNode(parentNode)) return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
664
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) return parentNode;
|
|
665
|
-
return getNearestOverflowAncestor(parentNode);
|
|
666
|
-
}
|
|
667
|
-
function getOverflowAncestors(node, list, traverseIframes) {
|
|
668
|
-
var _node$ownerDocument2;
|
|
669
|
-
if (list === void 0) list = [];
|
|
670
|
-
if (traverseIframes === void 0) traverseIframes = true;
|
|
671
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
672
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
673
|
-
const win = getWindow(scrollableAncestor);
|
|
674
|
-
if (isBody) {
|
|
675
|
-
const frameElement = getFrameElement(win);
|
|
676
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
677
|
-
}
|
|
678
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
679
|
-
}
|
|
680
|
-
function getFrameElement(win) {
|
|
681
|
-
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
//#endregion
|
|
685
|
-
//#region ../../node_modules/.pnpm/@floating-ui+dom@1.7.5/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
686
|
-
function getCssDimensions(element) {
|
|
687
|
-
const css = getComputedStyle$1(element);
|
|
688
|
-
let width = parseFloat(css.width) || 0;
|
|
689
|
-
let height = parseFloat(css.height) || 0;
|
|
690
|
-
const hasOffset = isHTMLElement(element);
|
|
691
|
-
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
692
|
-
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
693
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
694
|
-
if (shouldFallback) {
|
|
695
|
-
width = offsetWidth;
|
|
696
|
-
height = offsetHeight;
|
|
697
|
-
}
|
|
698
|
-
return {
|
|
699
|
-
width,
|
|
700
|
-
height,
|
|
701
|
-
$: shouldFallback
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
function unwrapElement$1(element) {
|
|
705
|
-
return !isElement(element) ? element.contextElement : element;
|
|
706
|
-
}
|
|
707
|
-
function getScale(element) {
|
|
708
|
-
const domElement = unwrapElement$1(element);
|
|
709
|
-
if (!isHTMLElement(domElement)) return createCoords(1);
|
|
710
|
-
const rect = domElement.getBoundingClientRect();
|
|
711
|
-
const { width, height, $ } = getCssDimensions(domElement);
|
|
712
|
-
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
713
|
-
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
714
|
-
if (!x || !Number.isFinite(x)) x = 1;
|
|
715
|
-
if (!y || !Number.isFinite(y)) y = 1;
|
|
716
|
-
return {
|
|
717
|
-
x,
|
|
718
|
-
y
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
const noOffsets = /* @__PURE__ */ createCoords(0);
|
|
722
|
-
function getVisualOffsets(element) {
|
|
723
|
-
const win = getWindow(element);
|
|
724
|
-
if (!isWebKit() || !win.visualViewport) return noOffsets;
|
|
725
|
-
return {
|
|
726
|
-
x: win.visualViewport.offsetLeft,
|
|
727
|
-
y: win.visualViewport.offsetTop
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
731
|
-
if (isFixed === void 0) isFixed = false;
|
|
732
|
-
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) return false;
|
|
733
|
-
return isFixed;
|
|
734
|
-
}
|
|
735
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
736
|
-
if (includeScale === void 0) includeScale = false;
|
|
737
|
-
if (isFixedStrategy === void 0) isFixedStrategy = false;
|
|
738
|
-
const clientRect = element.getBoundingClientRect();
|
|
739
|
-
const domElement = unwrapElement$1(element);
|
|
740
|
-
let scale = createCoords(1);
|
|
741
|
-
if (includeScale) if (offsetParent) {
|
|
742
|
-
if (isElement(offsetParent)) scale = getScale(offsetParent);
|
|
743
|
-
} else scale = getScale(element);
|
|
744
|
-
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
745
|
-
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
746
|
-
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
747
|
-
let width = clientRect.width / scale.x;
|
|
748
|
-
let height = clientRect.height / scale.y;
|
|
749
|
-
if (domElement) {
|
|
750
|
-
const win = getWindow(domElement);
|
|
751
|
-
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
752
|
-
let currentWin = win;
|
|
753
|
-
let currentIFrame = getFrameElement(currentWin);
|
|
754
|
-
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
755
|
-
const iframeScale = getScale(currentIFrame);
|
|
756
|
-
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
757
|
-
const css = getComputedStyle$1(currentIFrame);
|
|
758
|
-
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
759
|
-
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
760
|
-
x *= iframeScale.x;
|
|
761
|
-
y *= iframeScale.y;
|
|
762
|
-
width *= iframeScale.x;
|
|
763
|
-
height *= iframeScale.y;
|
|
764
|
-
x += left;
|
|
765
|
-
y += top;
|
|
766
|
-
currentWin = getWindow(currentIFrame);
|
|
767
|
-
currentIFrame = getFrameElement(currentWin);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
return rectToClientRect({
|
|
771
|
-
width,
|
|
772
|
-
height,
|
|
773
|
-
x,
|
|
774
|
-
y
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
function getWindowScrollBarX(element, rect) {
|
|
778
|
-
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
779
|
-
if (!rect) return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
780
|
-
return rect.left + leftScroll;
|
|
781
|
-
}
|
|
782
|
-
function getHTMLOffset(documentElement, scroll) {
|
|
783
|
-
const htmlRect = documentElement.getBoundingClientRect();
|
|
784
|
-
return {
|
|
785
|
-
x: htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect),
|
|
786
|
-
y: htmlRect.top + scroll.scrollTop
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
790
|
-
let { elements, rect, offsetParent, strategy } = _ref;
|
|
791
|
-
const isFixed = strategy === "fixed";
|
|
792
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
793
|
-
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
794
|
-
if (offsetParent === documentElement || topLayer && isFixed) return rect;
|
|
795
|
-
let scroll = {
|
|
796
|
-
scrollLeft: 0,
|
|
797
|
-
scrollTop: 0
|
|
798
|
-
};
|
|
799
|
-
let scale = createCoords(1);
|
|
800
|
-
const offsets = createCoords(0);
|
|
801
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
802
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
803
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
|
|
804
|
-
if (isHTMLElement(offsetParent)) {
|
|
805
|
-
const offsetRect = getBoundingClientRect(offsetParent);
|
|
806
|
-
scale = getScale(offsetParent);
|
|
807
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
808
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
812
|
-
return {
|
|
813
|
-
width: rect.width * scale.x,
|
|
814
|
-
height: rect.height * scale.y,
|
|
815
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
816
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
function getClientRects(element) {
|
|
820
|
-
return Array.from(element.getClientRects());
|
|
821
|
-
}
|
|
822
|
-
function getDocumentRect(element) {
|
|
823
|
-
const html = getDocumentElement(element);
|
|
824
|
-
const scroll = getNodeScroll(element);
|
|
825
|
-
const body = element.ownerDocument.body;
|
|
826
|
-
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
827
|
-
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
828
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
829
|
-
const y = -scroll.scrollTop;
|
|
830
|
-
if (getComputedStyle$1(body).direction === "rtl") x += max(html.clientWidth, body.clientWidth) - width;
|
|
831
|
-
return {
|
|
832
|
-
width,
|
|
833
|
-
height,
|
|
834
|
-
x,
|
|
835
|
-
y
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
const SCROLLBAR_MAX = 25;
|
|
839
|
-
function getViewportRect(element, strategy) {
|
|
840
|
-
const win = getWindow(element);
|
|
841
|
-
const html = getDocumentElement(element);
|
|
842
|
-
const visualViewport = win.visualViewport;
|
|
843
|
-
let width = html.clientWidth;
|
|
844
|
-
let height = html.clientHeight;
|
|
845
|
-
let x = 0;
|
|
846
|
-
let y = 0;
|
|
847
|
-
if (visualViewport) {
|
|
848
|
-
width = visualViewport.width;
|
|
849
|
-
height = visualViewport.height;
|
|
850
|
-
const visualViewportBased = isWebKit();
|
|
851
|
-
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
852
|
-
x = visualViewport.offsetLeft;
|
|
853
|
-
y = visualViewport.offsetTop;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
const windowScrollbarX = getWindowScrollBarX(html);
|
|
857
|
-
if (windowScrollbarX <= 0) {
|
|
858
|
-
const doc = html.ownerDocument;
|
|
859
|
-
const body = doc.body;
|
|
860
|
-
const bodyStyles = getComputedStyle(body);
|
|
861
|
-
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
862
|
-
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
863
|
-
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) width -= clippingStableScrollbarWidth;
|
|
864
|
-
} else if (windowScrollbarX <= SCROLLBAR_MAX) width += windowScrollbarX;
|
|
865
|
-
return {
|
|
866
|
-
width,
|
|
867
|
-
height,
|
|
868
|
-
x,
|
|
869
|
-
y
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
const absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
873
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
874
|
-
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
875
|
-
const top = clientRect.top + element.clientTop;
|
|
876
|
-
const left = clientRect.left + element.clientLeft;
|
|
877
|
-
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
878
|
-
return {
|
|
879
|
-
width: element.clientWidth * scale.x,
|
|
880
|
-
height: element.clientHeight * scale.y,
|
|
881
|
-
x: left * scale.x,
|
|
882
|
-
y: top * scale.y
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
886
|
-
let rect;
|
|
887
|
-
if (clippingAncestor === "viewport") rect = getViewportRect(element, strategy);
|
|
888
|
-
else if (clippingAncestor === "document") rect = getDocumentRect(getDocumentElement(element));
|
|
889
|
-
else if (isElement(clippingAncestor)) rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
890
|
-
else {
|
|
891
|
-
const visualOffsets = getVisualOffsets(element);
|
|
892
|
-
rect = {
|
|
893
|
-
x: clippingAncestor.x - visualOffsets.x,
|
|
894
|
-
y: clippingAncestor.y - visualOffsets.y,
|
|
895
|
-
width: clippingAncestor.width,
|
|
896
|
-
height: clippingAncestor.height
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
return rectToClientRect(rect);
|
|
900
|
-
}
|
|
901
|
-
function hasFixedPositionAncestor(element, stopNode) {
|
|
902
|
-
const parentNode = getParentNode(element);
|
|
903
|
-
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) return false;
|
|
904
|
-
return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
905
|
-
}
|
|
906
|
-
function getClippingElementAncestors(element, cache) {
|
|
907
|
-
const cachedResult = cache.get(element);
|
|
908
|
-
if (cachedResult) return cachedResult;
|
|
909
|
-
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
910
|
-
let currentContainingBlockComputedStyle = null;
|
|
911
|
-
const elementIsFixed = getComputedStyle$1(element).position === "fixed";
|
|
912
|
-
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
913
|
-
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
914
|
-
const computedStyle = getComputedStyle$1(currentNode);
|
|
915
|
-
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
916
|
-
if (!currentNodeIsContaining && computedStyle.position === "fixed") currentContainingBlockComputedStyle = null;
|
|
917
|
-
if (elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode)) result = result.filter((ancestor) => ancestor !== currentNode);
|
|
918
|
-
else currentContainingBlockComputedStyle = computedStyle;
|
|
919
|
-
currentNode = getParentNode(currentNode);
|
|
920
|
-
}
|
|
921
|
-
cache.set(element, result);
|
|
922
|
-
return result;
|
|
923
|
-
}
|
|
924
|
-
function getClippingRect(_ref) {
|
|
925
|
-
let { element, boundary, rootBoundary, strategy } = _ref;
|
|
926
|
-
const clippingAncestors = [...boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary), rootBoundary];
|
|
927
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
928
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
929
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
930
|
-
accRect.top = max(rect.top, accRect.top);
|
|
931
|
-
accRect.right = min(rect.right, accRect.right);
|
|
932
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
933
|
-
accRect.left = max(rect.left, accRect.left);
|
|
934
|
-
return accRect;
|
|
935
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
936
|
-
return {
|
|
937
|
-
width: clippingRect.right - clippingRect.left,
|
|
938
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
939
|
-
x: clippingRect.left,
|
|
940
|
-
y: clippingRect.top
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
function getDimensions(element) {
|
|
944
|
-
const { width, height } = getCssDimensions(element);
|
|
945
|
-
return {
|
|
946
|
-
width,
|
|
947
|
-
height
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
951
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
952
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
953
|
-
const isFixed = strategy === "fixed";
|
|
954
|
-
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
955
|
-
let scroll = {
|
|
956
|
-
scrollLeft: 0,
|
|
957
|
-
scrollTop: 0
|
|
958
|
-
};
|
|
959
|
-
const offsets = createCoords(0);
|
|
960
|
-
function setLeftRTLScrollbarOffset() {
|
|
961
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
962
|
-
}
|
|
963
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
964
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
|
|
965
|
-
if (isOffsetParentAnElement) {
|
|
966
|
-
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
967
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
968
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
969
|
-
} else if (documentElement) setLeftRTLScrollbarOffset();
|
|
970
|
-
}
|
|
971
|
-
if (isFixed && !isOffsetParentAnElement && documentElement) setLeftRTLScrollbarOffset();
|
|
972
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
973
|
-
return {
|
|
974
|
-
x: rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x,
|
|
975
|
-
y: rect.top + scroll.scrollTop - offsets.y - htmlOffset.y,
|
|
976
|
-
width: rect.width,
|
|
977
|
-
height: rect.height
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
function isStaticPositioned(element) {
|
|
981
|
-
return getComputedStyle$1(element).position === "static";
|
|
982
|
-
}
|
|
983
|
-
function getTrueOffsetParent(element, polyfill) {
|
|
984
|
-
if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") return null;
|
|
985
|
-
if (polyfill) return polyfill(element);
|
|
986
|
-
let rawOffsetParent = element.offsetParent;
|
|
987
|
-
if (getDocumentElement(element) === rawOffsetParent) rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
988
|
-
return rawOffsetParent;
|
|
989
|
-
}
|
|
990
|
-
function getOffsetParent(element, polyfill) {
|
|
991
|
-
const win = getWindow(element);
|
|
992
|
-
if (isTopLayer(element)) return win;
|
|
993
|
-
if (!isHTMLElement(element)) {
|
|
994
|
-
let svgOffsetParent = getParentNode(element);
|
|
995
|
-
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
996
|
-
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) return svgOffsetParent;
|
|
997
|
-
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
998
|
-
}
|
|
999
|
-
return win;
|
|
1000
|
-
}
|
|
1001
|
-
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1002
|
-
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1003
|
-
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) return win;
|
|
1004
|
-
return offsetParent || getContainingBlock(element) || win;
|
|
1005
|
-
}
|
|
1006
|
-
const getElementRects = async function(data) {
|
|
1007
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1008
|
-
const getDimensionsFn = this.getDimensions;
|
|
1009
|
-
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1010
|
-
return {
|
|
1011
|
-
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1012
|
-
floating: {
|
|
1013
|
-
x: 0,
|
|
1014
|
-
y: 0,
|
|
1015
|
-
width: floatingDimensions.width,
|
|
1016
|
-
height: floatingDimensions.height
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
|
-
};
|
|
1020
|
-
function isRTL(element) {
|
|
1021
|
-
return getComputedStyle$1(element).direction === "rtl";
|
|
1022
|
-
}
|
|
1023
|
-
const platform = {
|
|
1024
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1025
|
-
getDocumentElement,
|
|
1026
|
-
getClippingRect,
|
|
1027
|
-
getOffsetParent,
|
|
1028
|
-
getElementRects,
|
|
1029
|
-
getClientRects,
|
|
1030
|
-
getDimensions,
|
|
1031
|
-
getScale,
|
|
1032
|
-
isElement,
|
|
1033
|
-
isRTL
|
|
1034
|
-
};
|
|
1035
|
-
function rectsAreEqual(a, b) {
|
|
1036
|
-
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
1037
|
-
}
|
|
1038
|
-
function observeMove(element, onMove) {
|
|
1039
|
-
let io = null;
|
|
1040
|
-
let timeoutId;
|
|
1041
|
-
const root = getDocumentElement(element);
|
|
1042
|
-
function cleanup() {
|
|
1043
|
-
var _io;
|
|
1044
|
-
clearTimeout(timeoutId);
|
|
1045
|
-
(_io = io) == null || _io.disconnect();
|
|
1046
|
-
io = null;
|
|
1047
|
-
}
|
|
1048
|
-
function refresh(skip, threshold) {
|
|
1049
|
-
if (skip === void 0) skip = false;
|
|
1050
|
-
if (threshold === void 0) threshold = 1;
|
|
1051
|
-
cleanup();
|
|
1052
|
-
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
1053
|
-
const { left, top, width, height } = elementRectForRootMargin;
|
|
1054
|
-
if (!skip) onMove();
|
|
1055
|
-
if (!width || !height) return;
|
|
1056
|
-
const insetTop = floor(top);
|
|
1057
|
-
const insetRight = floor(root.clientWidth - (left + width));
|
|
1058
|
-
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1059
|
-
const insetLeft = floor(left);
|
|
1060
|
-
const options = {
|
|
1061
|
-
rootMargin: -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px",
|
|
1062
|
-
threshold: max(0, min(1, threshold)) || 1
|
|
1063
|
-
};
|
|
1064
|
-
let isFirstUpdate = true;
|
|
1065
|
-
function handleObserve(entries) {
|
|
1066
|
-
const ratio = entries[0].intersectionRatio;
|
|
1067
|
-
if (ratio !== threshold) {
|
|
1068
|
-
if (!isFirstUpdate) return refresh();
|
|
1069
|
-
if (!ratio) timeoutId = setTimeout(() => {
|
|
1070
|
-
refresh(false, 1e-7);
|
|
1071
|
-
}, 1e3);
|
|
1072
|
-
else refresh(false, ratio);
|
|
1073
|
-
}
|
|
1074
|
-
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) refresh();
|
|
1075
|
-
isFirstUpdate = false;
|
|
1076
|
-
}
|
|
1077
|
-
try {
|
|
1078
|
-
io = new IntersectionObserver(handleObserve, {
|
|
1079
|
-
...options,
|
|
1080
|
-
root: root.ownerDocument
|
|
1081
|
-
});
|
|
1082
|
-
} catch (_e) {
|
|
1083
|
-
io = new IntersectionObserver(handleObserve, options);
|
|
1084
|
-
}
|
|
1085
|
-
io.observe(element);
|
|
1086
|
-
}
|
|
1087
|
-
refresh(true);
|
|
1088
|
-
return cleanup;
|
|
1089
|
-
}
|
|
1090
|
-
/**
|
|
1091
|
-
* Automatically updates the position of the floating element when necessary.
|
|
1092
|
-
* Should only be called when the floating element is mounted on the DOM or
|
|
1093
|
-
* visible on the screen.
|
|
1094
|
-
* @returns cleanup function that should be invoked when the floating element is
|
|
1095
|
-
* removed from the DOM or hidden from the screen.
|
|
1096
|
-
* @see https://floating-ui.com/docs/autoUpdate
|
|
1097
|
-
*/
|
|
1098
|
-
function autoUpdate(reference, floating, update, options) {
|
|
1099
|
-
if (options === void 0) options = {};
|
|
1100
|
-
const { ancestorScroll = true, ancestorResize = true, elementResize = typeof ResizeObserver === "function", layoutShift = typeof IntersectionObserver === "function", animationFrame = false } = options;
|
|
1101
|
-
const referenceEl = unwrapElement$1(reference);
|
|
1102
|
-
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
|
|
1103
|
-
ancestors.forEach((ancestor) => {
|
|
1104
|
-
ancestorScroll && ancestor.addEventListener("scroll", update, { passive: true });
|
|
1105
|
-
ancestorResize && ancestor.addEventListener("resize", update);
|
|
1106
|
-
});
|
|
1107
|
-
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1108
|
-
let reobserveFrame = -1;
|
|
1109
|
-
let resizeObserver = null;
|
|
1110
|
-
if (elementResize) {
|
|
1111
|
-
resizeObserver = new ResizeObserver((_ref) => {
|
|
1112
|
-
let [firstEntry] = _ref;
|
|
1113
|
-
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1114
|
-
resizeObserver.unobserve(floating);
|
|
1115
|
-
cancelAnimationFrame(reobserveFrame);
|
|
1116
|
-
reobserveFrame = requestAnimationFrame(() => {
|
|
1117
|
-
var _resizeObserver;
|
|
1118
|
-
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
update();
|
|
1122
|
-
});
|
|
1123
|
-
if (referenceEl && !animationFrame) resizeObserver.observe(referenceEl);
|
|
1124
|
-
resizeObserver.observe(floating);
|
|
1125
|
-
}
|
|
1126
|
-
let frameId;
|
|
1127
|
-
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1128
|
-
if (animationFrame) frameLoop();
|
|
1129
|
-
function frameLoop() {
|
|
1130
|
-
const nextRefRect = getBoundingClientRect(reference);
|
|
1131
|
-
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) update();
|
|
1132
|
-
prevRefRect = nextRefRect;
|
|
1133
|
-
frameId = requestAnimationFrame(frameLoop);
|
|
1134
|
-
}
|
|
1135
|
-
update();
|
|
1136
|
-
return () => {
|
|
1137
|
-
var _resizeObserver2;
|
|
1138
|
-
ancestors.forEach((ancestor) => {
|
|
1139
|
-
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
1140
|
-
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
1141
|
-
});
|
|
1142
|
-
cleanupIo?.();
|
|
1143
|
-
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
1144
|
-
resizeObserver = null;
|
|
1145
|
-
if (animationFrame) cancelAnimationFrame(frameId);
|
|
1146
|
-
};
|
|
1147
|
-
}
|
|
1148
|
-
/**
|
|
1149
|
-
* Modifies the placement by translating the floating element along the
|
|
1150
|
-
* specified axes.
|
|
1151
|
-
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1152
|
-
* object may be passed.
|
|
1153
|
-
* @see https://floating-ui.com/docs/offset
|
|
1154
|
-
*/
|
|
1155
|
-
const offset = offset$1;
|
|
1156
|
-
/**
|
|
1157
|
-
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1158
|
-
* keep it in view when it will overflow the clipping boundary.
|
|
1159
|
-
* @see https://floating-ui.com/docs/shift
|
|
1160
|
-
*/
|
|
1161
|
-
const shift = shift$1;
|
|
1162
|
-
/**
|
|
1163
|
-
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1164
|
-
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1165
|
-
* clipping boundary. Alternative to `autoPlacement`.
|
|
1166
|
-
* @see https://floating-ui.com/docs/flip
|
|
1167
|
-
*/
|
|
1168
|
-
const flip = flip$1;
|
|
1169
|
-
/**
|
|
1170
|
-
* Provides data to position an inner element of the floating element so that it
|
|
1171
|
-
* appears centered to the reference element.
|
|
1172
|
-
* @see https://floating-ui.com/docs/arrow
|
|
1173
|
-
*/
|
|
1174
|
-
const arrow$1 = arrow$2;
|
|
1175
|
-
/**
|
|
1176
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1177
|
-
* next to a given reference element.
|
|
1178
|
-
*/
|
|
1179
|
-
const computePosition = (reference, floating, options) => {
|
|
1180
|
-
const cache = /* @__PURE__ */ new Map();
|
|
1181
|
-
const mergedOptions = {
|
|
1182
|
-
platform,
|
|
1183
|
-
...options
|
|
1184
|
-
};
|
|
1185
|
-
const platformWithCache = {
|
|
1186
|
-
...mergedOptions.platform,
|
|
1187
|
-
_c: cache
|
|
1188
|
-
};
|
|
1189
|
-
return computePosition$1(reference, floating, {
|
|
1190
|
-
...mergedOptions,
|
|
1191
|
-
platform: platformWithCache
|
|
1192
|
-
});
|
|
1193
|
-
};
|
|
1194
|
-
|
|
1195
|
-
//#endregion
|
|
1196
|
-
//#region ../../node_modules/.pnpm/vue-demi@0.14.10_vue@3.5.28_typescript@5.9.3_/node_modules/vue-demi/lib/index.mjs
|
|
1197
|
-
var lib_exports = /* @__PURE__ */ __exportAll({
|
|
1198
|
-
Vue: () => Vue,
|
|
1199
|
-
Vue2: () => Vue2,
|
|
1200
|
-
del: () => del,
|
|
1201
|
-
install: () => install,
|
|
1202
|
-
isVue2: () => isVue2,
|
|
1203
|
-
isVue3: () => isVue3,
|
|
1204
|
-
set: () => set
|
|
1205
|
-
});
|
|
1206
|
-
import * as import_vue from "vue";
|
|
1207
|
-
__reExport(lib_exports, import_vue);
|
|
1208
|
-
var isVue2 = false;
|
|
1209
|
-
var isVue3 = true;
|
|
1210
|
-
var Vue2 = void 0;
|
|
1211
|
-
function install() {}
|
|
1212
|
-
function set(target, key, val) {
|
|
1213
|
-
if (Array.isArray(target)) {
|
|
1214
|
-
target.length = Math.max(target.length, key);
|
|
1215
|
-
target.splice(key, 1, val);
|
|
1216
|
-
return val;
|
|
1217
|
-
}
|
|
1218
|
-
target[key] = val;
|
|
1219
|
-
return val;
|
|
1220
|
-
}
|
|
1221
|
-
function del(target, key) {
|
|
1222
|
-
if (Array.isArray(target)) {
|
|
1223
|
-
target.splice(key, 1);
|
|
1224
|
-
return;
|
|
1225
|
-
}
|
|
1226
|
-
delete target[key];
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
//#endregion
|
|
1230
|
-
//#region ../../node_modules/.pnpm/@floating-ui+vue@1.1.10_vue@3.5.28_typescript@5.9.3_/node_modules/@floating-ui/vue/dist/floating-ui.vue.mjs
|
|
1231
|
-
function isComponentPublicInstance(target) {
|
|
1232
|
-
return target != null && typeof target === "object" && "$el" in target;
|
|
1233
|
-
}
|
|
1234
|
-
function unwrapElement(target) {
|
|
1235
|
-
if (isComponentPublicInstance(target)) {
|
|
1236
|
-
const element = target.$el;
|
|
1237
|
-
return isNode(element) && getNodeName(element) === "#comment" ? null : element;
|
|
1238
|
-
}
|
|
1239
|
-
return target;
|
|
1240
|
-
}
|
|
1241
|
-
function toValue(source) {
|
|
1242
|
-
return typeof source === "function" ? source() : (0, lib_exports.unref)(source);
|
|
1243
|
-
}
|
|
1244
|
-
/**
|
|
1245
|
-
* Positions an inner element of the floating element such that it is centered to the reference element.
|
|
1246
|
-
* @param options The arrow options.
|
|
1247
|
-
* @see https://floating-ui.com/docs/arrow
|
|
1248
|
-
*/
|
|
1249
|
-
function arrow(options) {
|
|
1250
|
-
return {
|
|
1251
|
-
name: "arrow",
|
|
1252
|
-
options,
|
|
1253
|
-
fn(args) {
|
|
1254
|
-
const element = unwrapElement(toValue(options.element));
|
|
1255
|
-
if (element == null) return {};
|
|
1256
|
-
return arrow$1({
|
|
1257
|
-
element,
|
|
1258
|
-
padding: options.padding
|
|
1259
|
-
}).fn(args);
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
1262
|
-
}
|
|
1263
|
-
function getDPR(element) {
|
|
1264
|
-
if (typeof window === "undefined") return 1;
|
|
1265
|
-
return (element.ownerDocument.defaultView || window).devicePixelRatio || 1;
|
|
1266
|
-
}
|
|
1267
|
-
function roundByDPR(element, value) {
|
|
1268
|
-
const dpr = getDPR(element);
|
|
1269
|
-
return Math.round(value * dpr) / dpr;
|
|
1270
|
-
}
|
|
1271
|
-
/**
|
|
1272
|
-
* Computes the `x` and `y` coordinates that will place the floating element next to a reference element when it is given a certain CSS positioning strategy.
|
|
1273
|
-
* @param reference The reference template ref.
|
|
1274
|
-
* @param floating The floating template ref.
|
|
1275
|
-
* @param options The floating options.
|
|
1276
|
-
* @see https://floating-ui.com/docs/vue
|
|
1277
|
-
*/
|
|
1278
|
-
function useFloating(reference, floating, options) {
|
|
1279
|
-
if (options === void 0) options = {};
|
|
1280
|
-
const whileElementsMountedOption = options.whileElementsMounted;
|
|
1281
|
-
const openOption = (0, lib_exports.computed)(() => {
|
|
1282
|
-
var _toValue;
|
|
1283
|
-
return (_toValue = toValue(options.open)) != null ? _toValue : true;
|
|
1284
|
-
});
|
|
1285
|
-
const middlewareOption = (0, lib_exports.computed)(() => toValue(options.middleware));
|
|
1286
|
-
const placementOption = (0, lib_exports.computed)(() => {
|
|
1287
|
-
var _toValue2;
|
|
1288
|
-
return (_toValue2 = toValue(options.placement)) != null ? _toValue2 : "bottom";
|
|
1289
|
-
});
|
|
1290
|
-
const strategyOption = (0, lib_exports.computed)(() => {
|
|
1291
|
-
var _toValue3;
|
|
1292
|
-
return (_toValue3 = toValue(options.strategy)) != null ? _toValue3 : "absolute";
|
|
1293
|
-
});
|
|
1294
|
-
const transformOption = (0, lib_exports.computed)(() => {
|
|
1295
|
-
var _toValue4;
|
|
1296
|
-
return (_toValue4 = toValue(options.transform)) != null ? _toValue4 : true;
|
|
1297
|
-
});
|
|
1298
|
-
const referenceElement = (0, lib_exports.computed)(() => unwrapElement(reference.value));
|
|
1299
|
-
const floatingElement = (0, lib_exports.computed)(() => unwrapElement(floating.value));
|
|
1300
|
-
const x = (0, lib_exports.ref)(0);
|
|
1301
|
-
const y = (0, lib_exports.ref)(0);
|
|
1302
|
-
const strategy = (0, lib_exports.ref)(strategyOption.value);
|
|
1303
|
-
const placement = (0, lib_exports.ref)(placementOption.value);
|
|
1304
|
-
const middlewareData = (0, lib_exports.shallowRef)({});
|
|
1305
|
-
const isPositioned = (0, lib_exports.ref)(false);
|
|
1306
|
-
const floatingStyles = (0, lib_exports.computed)(() => {
|
|
1307
|
-
const initialStyles = {
|
|
1308
|
-
position: strategy.value,
|
|
1309
|
-
left: "0",
|
|
1310
|
-
top: "0"
|
|
1311
|
-
};
|
|
1312
|
-
if (!floatingElement.value) return initialStyles;
|
|
1313
|
-
const xVal = roundByDPR(floatingElement.value, x.value);
|
|
1314
|
-
const yVal = roundByDPR(floatingElement.value, y.value);
|
|
1315
|
-
if (transformOption.value) return {
|
|
1316
|
-
...initialStyles,
|
|
1317
|
-
transform: "translate(" + xVal + "px, " + yVal + "px)",
|
|
1318
|
-
...getDPR(floatingElement.value) >= 1.5 && { willChange: "transform" }
|
|
1319
|
-
};
|
|
1320
|
-
return {
|
|
1321
|
-
position: strategy.value,
|
|
1322
|
-
left: xVal + "px",
|
|
1323
|
-
top: yVal + "px"
|
|
1324
|
-
};
|
|
1325
|
-
});
|
|
1326
|
-
let whileElementsMountedCleanup;
|
|
1327
|
-
function update() {
|
|
1328
|
-
if (referenceElement.value == null || floatingElement.value == null) return;
|
|
1329
|
-
const open = openOption.value;
|
|
1330
|
-
computePosition(referenceElement.value, floatingElement.value, {
|
|
1331
|
-
middleware: middlewareOption.value,
|
|
1332
|
-
placement: placementOption.value,
|
|
1333
|
-
strategy: strategyOption.value
|
|
1334
|
-
}).then((position) => {
|
|
1335
|
-
x.value = position.x;
|
|
1336
|
-
y.value = position.y;
|
|
1337
|
-
strategy.value = position.strategy;
|
|
1338
|
-
placement.value = position.placement;
|
|
1339
|
-
middlewareData.value = position.middlewareData;
|
|
1340
|
-
/**
|
|
1341
|
-
* The floating element's position may be recomputed while it's closed
|
|
1342
|
-
* but still mounted (such as when transitioning out). To ensure
|
|
1343
|
-
* `isPositioned` will be `false` initially on the next open, avoid
|
|
1344
|
-
* setting it to `true` when `open === false` (must be specified).
|
|
1345
|
-
*/
|
|
1346
|
-
isPositioned.value = open !== false;
|
|
1347
|
-
});
|
|
1348
|
-
}
|
|
1349
|
-
function cleanup() {
|
|
1350
|
-
if (typeof whileElementsMountedCleanup === "function") {
|
|
1351
|
-
whileElementsMountedCleanup();
|
|
1352
|
-
whileElementsMountedCleanup = void 0;
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
function attach() {
|
|
1356
|
-
cleanup();
|
|
1357
|
-
if (whileElementsMountedOption === void 0) {
|
|
1358
|
-
update();
|
|
1359
|
-
return;
|
|
1360
|
-
}
|
|
1361
|
-
if (referenceElement.value != null && floatingElement.value != null) {
|
|
1362
|
-
whileElementsMountedCleanup = whileElementsMountedOption(referenceElement.value, floatingElement.value, update);
|
|
1363
|
-
return;
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
function reset() {
|
|
1367
|
-
if (!openOption.value) isPositioned.value = false;
|
|
1368
|
-
}
|
|
1369
|
-
(0, lib_exports.watch)([
|
|
1370
|
-
middlewareOption,
|
|
1371
|
-
placementOption,
|
|
1372
|
-
strategyOption,
|
|
1373
|
-
openOption
|
|
1374
|
-
], update, { flush: "sync" });
|
|
1375
|
-
(0, lib_exports.watch)([referenceElement, floatingElement], attach, { flush: "sync" });
|
|
1376
|
-
(0, lib_exports.watch)(openOption, reset, { flush: "sync" });
|
|
1377
|
-
if ((0, lib_exports.getCurrentScope)()) (0, lib_exports.onScopeDispose)(cleanup);
|
|
1378
|
-
return {
|
|
1379
|
-
x: (0, lib_exports.shallowReadonly)(x),
|
|
1380
|
-
y: (0, lib_exports.shallowReadonly)(y),
|
|
1381
|
-
strategy: (0, lib_exports.shallowReadonly)(strategy),
|
|
1382
|
-
placement: (0, lib_exports.shallowReadonly)(placement),
|
|
1383
|
-
middlewareData: (0, lib_exports.shallowReadonly)(middlewareData),
|
|
1384
|
-
isPositioned: (0, lib_exports.shallowReadonly)(isPositioned),
|
|
1385
|
-
floatingStyles,
|
|
1386
|
-
update
|
|
1387
|
-
};
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
//#endregion
|
|
1391
|
-
//#region src/options.ts
|
|
1392
|
-
let options = {
|
|
1393
|
-
placementAttribute: "data-vueltip-placement",
|
|
1394
|
-
keyAttribute: "data-vueltip-key",
|
|
1395
|
-
truncateAttribute: "data-vueltip-truncate",
|
|
1396
|
-
showDelay: 0,
|
|
1397
|
-
hideDelay: 200,
|
|
1398
|
-
handleDialogModals: false,
|
|
1399
|
-
defaultTruncateDetection: "both",
|
|
1400
|
-
defaultPlacement: "top"
|
|
1401
|
-
};
|
|
1402
|
-
const setOptions = (opts) => {
|
|
1403
|
-
options = {
|
|
1404
|
-
...options,
|
|
1405
|
-
...opts
|
|
1406
|
-
};
|
|
1407
|
-
};
|
|
1408
|
-
const getOption = (key) => options[key];
|
|
1409
|
-
|
|
1410
|
-
//#endregion
|
|
1411
|
-
//#region src/state.ts
|
|
1412
|
-
let timerId;
|
|
1413
|
-
const tooltipPlacement = ref("top");
|
|
1414
|
-
const debouncedTooltipPlacement = ref("top");
|
|
1415
|
-
const hoveredElement = ref();
|
|
1416
|
-
const debouncedHoveredElement = ref();
|
|
1417
|
-
const forceClearHoveredElement = (el) => {
|
|
1418
|
-
if (el !== debouncedHoveredElement.value && el !== hoveredElement.value) return;
|
|
1419
|
-
hoveredElement.value = void 0;
|
|
1420
|
-
debouncedHoveredElement.value = void 0;
|
|
1421
|
-
if (timerId) clearTimeout(timerId);
|
|
1422
|
-
};
|
|
1423
|
-
const contentMap = ref(/* @__PURE__ */ new Map());
|
|
1424
|
-
const getContent = (key) => contentMap.value.get(key);
|
|
1425
|
-
const setContent = (key, value) => contentMap.value.set(key, value);
|
|
1426
|
-
const deleteContent = (key) => contentMap.value.delete(key);
|
|
1427
|
-
const generateKey = () => crypto.randomUUID();
|
|
1428
|
-
const tooltipKey = ref();
|
|
1429
|
-
const tooltipContent = ref();
|
|
1430
|
-
watch([
|
|
1431
|
-
tooltipKey,
|
|
1432
|
-
hoveredElement,
|
|
1433
|
-
tooltipPlacement,
|
|
1434
|
-
() => getContent(tooltipKey.value ?? "")
|
|
1435
|
-
], ([key, el, placement]) => {
|
|
1436
|
-
if (!key) return;
|
|
1437
|
-
if (timerId) clearTimeout(timerId);
|
|
1438
|
-
const timeout = el ? getOption("showDelay") : getOption("hideDelay");
|
|
1439
|
-
timerId = setTimeout(() => {
|
|
1440
|
-
tooltipContent.value = getContent(key);
|
|
1441
|
-
debouncedHoveredElement.value = el;
|
|
1442
|
-
debouncedTooltipPlacement.value = placement;
|
|
1443
|
-
timerId = void 0;
|
|
1444
|
-
}, timeout);
|
|
1445
|
-
});
|
|
1446
|
-
|
|
1447
|
-
//#endregion
|
|
1448
|
-
//#region src/composables.ts
|
|
1449
|
-
const sideMap = {
|
|
1450
|
-
top: "bottom",
|
|
1451
|
-
right: "left",
|
|
1452
|
-
bottom: "top",
|
|
1453
|
-
left: "right"
|
|
1454
|
-
};
|
|
1455
|
-
const useVueltip = ({ tooltipElement, arrowElement, offset: _offset, padding, arrowSize, floatingOptions }) => {
|
|
1456
|
-
let initialParent;
|
|
1457
|
-
const show = computed(() => !!debouncedHoveredElement.value);
|
|
1458
|
-
watch(show, (value, _, onCleanup) => {
|
|
1459
|
-
if (!value) return;
|
|
1460
|
-
const el = tooltipElement.value;
|
|
1461
|
-
if (!el) return;
|
|
1462
|
-
initialParent = el.parentElement;
|
|
1463
|
-
const onEnter = () => hoveredElement.value = debouncedHoveredElement.value;
|
|
1464
|
-
const onLeave = () => hoveredElement.value = void 0;
|
|
1465
|
-
el.addEventListener("mouseenter", onEnter);
|
|
1466
|
-
el.addEventListener("mouseleave", onLeave);
|
|
1467
|
-
onCleanup(() => {
|
|
1468
|
-
el.removeEventListener("mouseenter", onEnter);
|
|
1469
|
-
el.removeEventListener("mouseleave", onLeave);
|
|
1470
|
-
});
|
|
1471
|
-
}, { flush: "post" });
|
|
1472
|
-
const middleware = [
|
|
1473
|
-
offset(_offset),
|
|
1474
|
-
flip(),
|
|
1475
|
-
shift({ padding })
|
|
1476
|
-
];
|
|
1477
|
-
if (arrowElement) middleware.push(arrow({
|
|
1478
|
-
element: arrowElement,
|
|
1479
|
-
padding: 6
|
|
1480
|
-
}));
|
|
1481
|
-
const { floatingStyles, middlewareData, placement } = useFloating(debouncedHoveredElement, tooltipElement, {
|
|
1482
|
-
placement: debouncedTooltipPlacement,
|
|
1483
|
-
whileElementsMounted: autoUpdate,
|
|
1484
|
-
middleware,
|
|
1485
|
-
...floatingOptions
|
|
1486
|
-
});
|
|
1487
|
-
const staticSide = computed(() => sideMap[placement.value.split("-")[0]]);
|
|
1488
|
-
const size = arrowSize ?? 10;
|
|
1489
|
-
const arrowStyles = computed(() => {
|
|
1490
|
-
return {
|
|
1491
|
-
width: `${size}px`,
|
|
1492
|
-
height: `${size}px`,
|
|
1493
|
-
rotate: "45deg",
|
|
1494
|
-
position: "absolute",
|
|
1495
|
-
left: middlewareData.value.arrow?.x != null ? `${middlewareData.value.arrow.x}px` : "",
|
|
1496
|
-
top: middlewareData.value.arrow?.y != null ? `${middlewareData.value.arrow.y}px` : "",
|
|
1497
|
-
[staticSide.value]: `-${size / 2}px`
|
|
1498
|
-
};
|
|
1499
|
-
});
|
|
1500
|
-
if (getOption("handleDialogModals")) watch(show, (value) => {
|
|
1501
|
-
if (!value || !tooltipElement.value || !debouncedHoveredElement.value || !initialParent) return;
|
|
1502
|
-
const dialogEl = debouncedHoveredElement.value.closest("dialog");
|
|
1503
|
-
if (!dialogEl) {
|
|
1504
|
-
if (tooltipElement.value.parentElement !== initialParent) initialParent.appendChild(tooltipElement.value);
|
|
1505
|
-
return;
|
|
1506
|
-
}
|
|
1507
|
-
if (globalThis.getComputedStyle(dialogEl, "::backdrop").display !== "none") dialogEl.appendChild(tooltipElement.value);
|
|
1508
|
-
});
|
|
1509
|
-
return {
|
|
1510
|
-
tooltipStyles: floatingStyles,
|
|
1511
|
-
arrowStyles,
|
|
1512
|
-
show,
|
|
1513
|
-
content: tooltipContent
|
|
1514
|
-
};
|
|
1515
|
-
};
|
|
1516
|
-
|
|
1517
|
-
//#endregion
|
|
1518
|
-
//#region src/basicTooltip.component.ts
|
|
1519
|
-
const BasicTooltip = defineComponent(() => {
|
|
1520
|
-
const { tooltipStyles, arrowStyles, show, content } = useVueltip({
|
|
1521
|
-
tooltipElement: useTemplateRef("tooltipElement"),
|
|
1522
|
-
arrowElement: useTemplateRef("arrowElement"),
|
|
1523
|
-
offset: 8,
|
|
1524
|
-
padding: 8
|
|
1525
|
-
});
|
|
1526
|
-
return () => {
|
|
1527
|
-
if (!show.value) return null;
|
|
1528
|
-
return h("div", {
|
|
1529
|
-
ref: "tooltipElement",
|
|
1530
|
-
class: "vueltip-theme",
|
|
1531
|
-
style: tooltipStyles.value,
|
|
1532
|
-
role: "tooltip"
|
|
1533
|
-
}, [h("div", {
|
|
1534
|
-
ref: "arrowElement",
|
|
1535
|
-
class: "vueltip-arrow",
|
|
1536
|
-
style: arrowStyles.value
|
|
1537
|
-
}), h("div", { class: "vueltip-content" }, [content.value?.text])]);
|
|
1538
|
-
};
|
|
1539
|
-
});
|
|
1540
|
-
|
|
1541
|
-
//#endregion
|
|
1542
|
-
//#region src/utils.ts
|
|
1543
|
-
function isTruncated(el) {
|
|
1544
|
-
const direction = getTruncationDirection(el);
|
|
1545
|
-
const x = el.offsetWidth < el.scrollWidth - 1;
|
|
1546
|
-
const y = el.offsetHeight < el.scrollHeight - 1;
|
|
1547
|
-
switch (direction) {
|
|
1548
|
-
case "x": return x;
|
|
1549
|
-
case "y": return y;
|
|
1550
|
-
case "both": return x || y;
|
|
1551
|
-
case "none": return true;
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
function getTruncationDirection(el) {
|
|
1555
|
-
return el.getAttribute(getOption("truncateAttribute")) ?? getOption("defaultTruncateDetection");
|
|
1556
|
-
}
|
|
1557
|
-
function elementContainsText(el, text) {
|
|
1558
|
-
if (isInputElement(el) || isTextAreaElement(el)) return getInputValue(el).includes(text);
|
|
1559
|
-
return !!(el.innerText || el.textContent)?.includes(text);
|
|
1560
|
-
}
|
|
1561
|
-
function isHtmlElement(el) {
|
|
1562
|
-
return el instanceof HTMLElement;
|
|
1563
|
-
}
|
|
1564
|
-
function isInputElement(el) {
|
|
1565
|
-
return el instanceof HTMLInputElement;
|
|
1566
|
-
}
|
|
1567
|
-
function isTextAreaElement(el) {
|
|
1568
|
-
return el instanceof HTMLTextAreaElement;
|
|
1569
|
-
}
|
|
1570
|
-
function getInputValue(el) {
|
|
1571
|
-
return el.value;
|
|
1572
|
-
}
|
|
1573
|
-
const ensureKey = (el, fn) => {
|
|
1574
|
-
const key = el.getAttribute(getOption("keyAttribute"));
|
|
1575
|
-
if (!key) return;
|
|
1576
|
-
return fn(key);
|
|
1577
|
-
};
|
|
1578
|
-
|
|
1579
|
-
//#endregion
|
|
1580
|
-
//#region src/listeners.ts
|
|
1581
|
-
const ensureEventTarget = (fn) => (event) => {
|
|
1582
|
-
const { target } = event;
|
|
1583
|
-
if (!target || !isHtmlElement(target)) return;
|
|
1584
|
-
fn(target);
|
|
1585
|
-
};
|
|
1586
|
-
const onMouseover = ensureEventTarget((target) => ensureKey(target, (key) => {
|
|
1587
|
-
const content = getContent(key);
|
|
1588
|
-
if (!content) return;
|
|
1589
|
-
const { text } = content;
|
|
1590
|
-
if (!text || elementContainsText(target, text) && !isTruncated(target)) return;
|
|
1591
|
-
const placement = target.getAttribute(getOption("placementAttribute"));
|
|
1592
|
-
tooltipKey.value = key;
|
|
1593
|
-
hoveredElement.value = target;
|
|
1594
|
-
tooltipPlacement.value = placement;
|
|
1595
|
-
}));
|
|
1596
|
-
const onMouseout = ensureEventTarget((target) => {
|
|
1597
|
-
if (target !== hoveredElement.value) return;
|
|
1598
|
-
hoveredElement.value = void 0;
|
|
1599
|
-
});
|
|
1600
|
-
|
|
1601
|
-
//#endregion
|
|
1602
|
-
//#region src/directive.ts
|
|
1603
|
-
const toContent = (value) => {
|
|
1604
|
-
if (value == null) return { text: value };
|
|
1605
|
-
if (typeof value === "string") return { text: value };
|
|
1606
|
-
const { placement: _, ...rest } = value;
|
|
1607
|
-
return rest;
|
|
1608
|
-
};
|
|
1609
|
-
const extractPlacement = (binding) => {
|
|
1610
|
-
const { value, arg } = binding;
|
|
1611
|
-
if (value && typeof value !== "string" && "placement" in value && value.placement != null) return value.placement;
|
|
1612
|
-
if (!arg) return getOption("defaultPlacement");
|
|
1613
|
-
return arg;
|
|
1614
|
-
};
|
|
1615
|
-
const truncationDirection = (modifiers) => {
|
|
1616
|
-
if (modifiers.none) return "none";
|
|
1617
|
-
if (modifiers.both) return "both";
|
|
1618
|
-
if (modifiers.x && modifiers.y) return "both";
|
|
1619
|
-
if (modifiers.x) return "x";
|
|
1620
|
-
if (modifiers.y) return "y";
|
|
1621
|
-
return getOption("defaultTruncateDetection");
|
|
1622
|
-
};
|
|
1623
|
-
const vueltipDirective = {
|
|
1624
|
-
updated: (el, binding) => {
|
|
1625
|
-
ensureKey(el, (key) => {
|
|
1626
|
-
el.setAttribute(getOption("placementAttribute"), extractPlacement(binding));
|
|
1627
|
-
el.setAttribute(getOption("truncateAttribute"), truncationDirection(binding.modifiers ?? {}));
|
|
1628
|
-
setContent(key, toContent(binding.value));
|
|
1629
|
-
});
|
|
1630
|
-
},
|
|
1631
|
-
created: (el, binding) => {
|
|
1632
|
-
const key = generateKey();
|
|
1633
|
-
setContent(key, toContent(binding.value));
|
|
1634
|
-
el.setAttribute(getOption("keyAttribute"), key);
|
|
1635
|
-
el.setAttribute(getOption("placementAttribute"), extractPlacement(binding));
|
|
1636
|
-
el.setAttribute(getOption("truncateAttribute"), truncationDirection(binding.modifiers ?? {}));
|
|
1637
|
-
el.addEventListener("mouseenter", onMouseover);
|
|
1638
|
-
el.addEventListener("focus", onMouseover);
|
|
1639
|
-
el.addEventListener("mouseleave", onMouseout);
|
|
1640
|
-
el.addEventListener("blur", onMouseout);
|
|
1641
|
-
},
|
|
1642
|
-
beforeUnmount: (el) => {
|
|
1643
|
-
ensureKey(el, (key) => deleteContent(key));
|
|
1644
|
-
forceClearHoveredElement(el);
|
|
1645
|
-
el.removeEventListener("mouseenter", onMouseover);
|
|
1646
|
-
el.removeEventListener("focus", onMouseover);
|
|
1647
|
-
el.removeEventListener("mouseleave", onMouseout);
|
|
1648
|
-
el.removeEventListener("blur", onMouseout);
|
|
1649
|
-
}
|
|
1650
|
-
};
|
|
1651
|
-
|
|
1652
|
-
//#endregion
|
|
1653
|
-
//#region src/plugin.ts
|
|
1654
|
-
const vueltipPlugin = { install: (app, options) => {
|
|
1655
|
-
const { component, ...rest } = options;
|
|
1656
|
-
setOptions(rest);
|
|
1657
|
-
if (!component) return;
|
|
1658
|
-
const container = document.createElement("div");
|
|
1659
|
-
container.id = "__vueltip_root__";
|
|
1660
|
-
document.body.appendChild(container);
|
|
1661
|
-
const tooltipApp = createApp(component);
|
|
1662
|
-
tooltipApp._context = app._context;
|
|
1663
|
-
tooltipApp.mount(container);
|
|
1664
|
-
} };
|
|
1665
|
-
|
|
1666
|
-
//#endregion
|
|
1667
|
-
export { BasicTooltip, setOptions, useVueltip, vueltipDirective, vueltipPlugin };
|