@immense/vue-pom-generator 1.0.49 → 1.0.51
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/RELEASE_NOTES.md +14 -20
- package/class-generation/{BasePage.ts → base-page.ts} +20 -4
- package/class-generation/callout.ts +827 -0
- package/class-generation/floating-ui.ts +837 -0
- package/class-generation/index.ts +11 -10
- package/class-generation/{Pointer.ts → pointer.ts} +81 -101
- package/dist/class-generation/{BasePage.d.ts → base-page.d.ts} +6 -2
- package/dist/class-generation/base-page.d.ts.map +1 -0
- package/dist/class-generation/callout.d.ts +20 -0
- package/dist/class-generation/callout.d.ts.map +1 -0
- package/dist/class-generation/floating-ui.d.ts +100 -0
- package/dist/class-generation/floating-ui.d.ts.map +1 -0
- package/dist/class-generation/{Pointer.d.ts → pointer.d.ts} +5 -5
- package/dist/class-generation/pointer.d.ts.map +1 -0
- package/dist/index.cjs +27 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +27 -14
- package/dist/index.mjs.map +1 -1
- package/dist/playwright.config.d.ts +3 -0
- package/dist/playwright.config.d.ts.map +1 -0
- package/dist/plugin/support/build-plugin.d.ts.map +1 -1
- package/dist/plugin/support/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +1 -1
- package/dist/tests/fixtures/generated-tsc/{BasePage.full.d.ts → base-page.full.d.ts} +1 -1
- package/dist/tests/fixtures/generated-tsc/base-page.full.d.ts.map +1 -0
- package/dist/tests/fixtures/generated-tsc/{BasePage.minimal.d.ts → base-page.minimal.d.ts} +1 -1
- package/dist/tests/fixtures/generated-tsc/base-page.minimal.d.ts.map +1 -0
- package/dist/tests/fixtures/generated-tsc/{Pointer.d.ts → pointer.d.ts} +1 -1
- package/dist/tests/fixtures/generated-tsc/pointer.d.ts.map +1 -0
- package/dist/tests/playwright/pointer-callout.spec.d.ts +2 -0
- package/dist/tests/playwright/pointer-callout.spec.d.ts.map +1 -0
- package/package.json +6 -2
- package/dist/class-generation/BasePage.d.ts.map +0 -1
- package/dist/class-generation/Pointer.d.ts.map +0 -1
- package/dist/tests/fixtures/generated-tsc/BasePage.full.d.ts.map +0 -1
- package/dist/tests/fixtures/generated-tsc/BasePage.minimal.d.ts.map +0 -1
- package/dist/tests/fixtures/generated-tsc/Pointer.d.ts.map +0 -1
|
@@ -0,0 +1,837 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Portions of this file are derived from Floating UI.
|
|
3
|
+
* Copyright (c) 2021-present Floating UI contributors
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
/* eslint-disable */
|
|
25
|
+
// @ts-nocheck
|
|
26
|
+
// This file is auto-generated by scripts/bundle-floating-ui-runtime.mjs.
|
|
27
|
+
// It vendors the Floating UI core runtime into class-generation/ so generated
|
|
28
|
+
// Playwright POM runtimes do not require consumers to install @floating-ui/*.
|
|
29
|
+
|
|
30
|
+
// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
31
|
+
var sides = ["top", "right", "bottom", "left"];
|
|
32
|
+
var alignments = ["start", "end"];
|
|
33
|
+
var placements = /* @__PURE__ */ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
34
|
+
var min = Math.min;
|
|
35
|
+
var max = Math.max;
|
|
36
|
+
var oppositeSideMap = {
|
|
37
|
+
left: "right",
|
|
38
|
+
right: "left",
|
|
39
|
+
bottom: "top",
|
|
40
|
+
top: "bottom"
|
|
41
|
+
};
|
|
42
|
+
function clamp(start, value, end) {
|
|
43
|
+
return max(start, min(value, end));
|
|
44
|
+
}
|
|
45
|
+
function evaluate(value, param) {
|
|
46
|
+
return typeof value === "function" ? value(param) : value;
|
|
47
|
+
}
|
|
48
|
+
function getSide(placement) {
|
|
49
|
+
return placement.split("-")[0];
|
|
50
|
+
}
|
|
51
|
+
function getAlignment(placement) {
|
|
52
|
+
return placement.split("-")[1];
|
|
53
|
+
}
|
|
54
|
+
function getOppositeAxis(axis) {
|
|
55
|
+
return axis === "x" ? "y" : "x";
|
|
56
|
+
}
|
|
57
|
+
function getAxisLength(axis) {
|
|
58
|
+
return axis === "y" ? "height" : "width";
|
|
59
|
+
}
|
|
60
|
+
function getSideAxis(placement) {
|
|
61
|
+
const firstChar = placement[0];
|
|
62
|
+
return firstChar === "t" || firstChar === "b" ? "y" : "x";
|
|
63
|
+
}
|
|
64
|
+
function getAlignmentAxis(placement) {
|
|
65
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
66
|
+
}
|
|
67
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
68
|
+
if (rtl === void 0) {
|
|
69
|
+
rtl = false;
|
|
70
|
+
}
|
|
71
|
+
const alignment = getAlignment(placement);
|
|
72
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
73
|
+
const length = getAxisLength(alignmentAxis);
|
|
74
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
75
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
76
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
77
|
+
}
|
|
78
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
79
|
+
}
|
|
80
|
+
function getExpandedPlacements(placement) {
|
|
81
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
82
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
83
|
+
}
|
|
84
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
85
|
+
return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
|
|
86
|
+
}
|
|
87
|
+
var lrPlacement = ["left", "right"];
|
|
88
|
+
var rlPlacement = ["right", "left"];
|
|
89
|
+
var tbPlacement = ["top", "bottom"];
|
|
90
|
+
var btPlacement = ["bottom", "top"];
|
|
91
|
+
function getSideList(side, isStart, rtl) {
|
|
92
|
+
switch (side) {
|
|
93
|
+
case "top":
|
|
94
|
+
case "bottom":
|
|
95
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
96
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
97
|
+
case "left":
|
|
98
|
+
case "right":
|
|
99
|
+
return isStart ? tbPlacement : btPlacement;
|
|
100
|
+
default:
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
105
|
+
const alignment = getAlignment(placement);
|
|
106
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
107
|
+
if (alignment) {
|
|
108
|
+
list = list.map((side) => side + "-" + alignment);
|
|
109
|
+
if (flipAlignment) {
|
|
110
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return list;
|
|
114
|
+
}
|
|
115
|
+
function getOppositePlacement(placement) {
|
|
116
|
+
const side = getSide(placement);
|
|
117
|
+
return oppositeSideMap[side] + placement.slice(side.length);
|
|
118
|
+
}
|
|
119
|
+
function expandPaddingObject(padding) {
|
|
120
|
+
return {
|
|
121
|
+
top: 0,
|
|
122
|
+
right: 0,
|
|
123
|
+
bottom: 0,
|
|
124
|
+
left: 0,
|
|
125
|
+
...padding
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function getPaddingObject(padding) {
|
|
129
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
130
|
+
top: padding,
|
|
131
|
+
right: padding,
|
|
132
|
+
bottom: padding,
|
|
133
|
+
left: padding
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function rectToClientRect(rect) {
|
|
137
|
+
const {
|
|
138
|
+
x,
|
|
139
|
+
y,
|
|
140
|
+
width,
|
|
141
|
+
height
|
|
142
|
+
} = rect;
|
|
143
|
+
return {
|
|
144
|
+
width,
|
|
145
|
+
height,
|
|
146
|
+
top: y,
|
|
147
|
+
left: x,
|
|
148
|
+
right: x + width,
|
|
149
|
+
bottom: y + height,
|
|
150
|
+
x,
|
|
151
|
+
y
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
156
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
157
|
+
let {
|
|
158
|
+
reference,
|
|
159
|
+
floating
|
|
160
|
+
} = _ref;
|
|
161
|
+
const sideAxis = getSideAxis(placement);
|
|
162
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
163
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
164
|
+
const side = getSide(placement);
|
|
165
|
+
const isVertical = sideAxis === "y";
|
|
166
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
167
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
168
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
169
|
+
let coords;
|
|
170
|
+
switch (side) {
|
|
171
|
+
case "top":
|
|
172
|
+
coords = {
|
|
173
|
+
x: commonX,
|
|
174
|
+
y: reference.y - floating.height
|
|
175
|
+
};
|
|
176
|
+
break;
|
|
177
|
+
case "bottom":
|
|
178
|
+
coords = {
|
|
179
|
+
x: commonX,
|
|
180
|
+
y: reference.y + reference.height
|
|
181
|
+
};
|
|
182
|
+
break;
|
|
183
|
+
case "right":
|
|
184
|
+
coords = {
|
|
185
|
+
x: reference.x + reference.width,
|
|
186
|
+
y: commonY
|
|
187
|
+
};
|
|
188
|
+
break;
|
|
189
|
+
case "left":
|
|
190
|
+
coords = {
|
|
191
|
+
x: reference.x - floating.width,
|
|
192
|
+
y: commonY
|
|
193
|
+
};
|
|
194
|
+
break;
|
|
195
|
+
default:
|
|
196
|
+
coords = {
|
|
197
|
+
x: reference.x,
|
|
198
|
+
y: reference.y
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
switch (getAlignment(placement)) {
|
|
202
|
+
case "start":
|
|
203
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
204
|
+
break;
|
|
205
|
+
case "end":
|
|
206
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
return coords;
|
|
210
|
+
}
|
|
211
|
+
async function detectOverflow(state, options) {
|
|
212
|
+
var _await$platform$isEle;
|
|
213
|
+
if (options === void 0) {
|
|
214
|
+
options = {};
|
|
215
|
+
}
|
|
216
|
+
const {
|
|
217
|
+
x,
|
|
218
|
+
y,
|
|
219
|
+
platform,
|
|
220
|
+
rects,
|
|
221
|
+
elements,
|
|
222
|
+
strategy
|
|
223
|
+
} = state;
|
|
224
|
+
const {
|
|
225
|
+
boundary = "clippingAncestors",
|
|
226
|
+
rootBoundary = "viewport",
|
|
227
|
+
elementContext = "floating",
|
|
228
|
+
altBoundary = false,
|
|
229
|
+
padding = 0
|
|
230
|
+
} = evaluate(options, state);
|
|
231
|
+
const paddingObject = getPaddingObject(padding);
|
|
232
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
233
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
234
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
235
|
+
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)),
|
|
236
|
+
boundary,
|
|
237
|
+
rootBoundary,
|
|
238
|
+
strategy
|
|
239
|
+
}));
|
|
240
|
+
const rect = elementContext === "floating" ? {
|
|
241
|
+
x,
|
|
242
|
+
y,
|
|
243
|
+
width: rects.floating.width,
|
|
244
|
+
height: rects.floating.height
|
|
245
|
+
} : rects.reference;
|
|
246
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
247
|
+
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
|
|
248
|
+
x: 1,
|
|
249
|
+
y: 1
|
|
250
|
+
} : {
|
|
251
|
+
x: 1,
|
|
252
|
+
y: 1
|
|
253
|
+
};
|
|
254
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
255
|
+
elements,
|
|
256
|
+
rect,
|
|
257
|
+
offsetParent,
|
|
258
|
+
strategy
|
|
259
|
+
}) : rect);
|
|
260
|
+
return {
|
|
261
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
262
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
263
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
264
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
var MAX_RESET_COUNT = 50;
|
|
268
|
+
var computePosition = async (reference, floating, config) => {
|
|
269
|
+
const {
|
|
270
|
+
placement = "bottom",
|
|
271
|
+
strategy = "absolute",
|
|
272
|
+
middleware = [],
|
|
273
|
+
platform
|
|
274
|
+
} = config;
|
|
275
|
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
|
276
|
+
...platform,
|
|
277
|
+
detectOverflow
|
|
278
|
+
};
|
|
279
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
280
|
+
let rects = await platform.getElementRects({
|
|
281
|
+
reference,
|
|
282
|
+
floating,
|
|
283
|
+
strategy
|
|
284
|
+
});
|
|
285
|
+
let {
|
|
286
|
+
x,
|
|
287
|
+
y
|
|
288
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
289
|
+
let statefulPlacement = placement;
|
|
290
|
+
let resetCount = 0;
|
|
291
|
+
const middlewareData = {};
|
|
292
|
+
for (let i = 0; i < middleware.length; i++) {
|
|
293
|
+
const currentMiddleware = middleware[i];
|
|
294
|
+
if (!currentMiddleware) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const {
|
|
298
|
+
name,
|
|
299
|
+
fn
|
|
300
|
+
} = currentMiddleware;
|
|
301
|
+
const {
|
|
302
|
+
x: nextX,
|
|
303
|
+
y: nextY,
|
|
304
|
+
data,
|
|
305
|
+
reset
|
|
306
|
+
} = await fn({
|
|
307
|
+
x,
|
|
308
|
+
y,
|
|
309
|
+
initialPlacement: placement,
|
|
310
|
+
placement: statefulPlacement,
|
|
311
|
+
strategy,
|
|
312
|
+
middlewareData,
|
|
313
|
+
rects,
|
|
314
|
+
platform: platformWithDetectOverflow,
|
|
315
|
+
elements: {
|
|
316
|
+
reference,
|
|
317
|
+
floating
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
x = nextX != null ? nextX : x;
|
|
321
|
+
y = nextY != null ? nextY : y;
|
|
322
|
+
middlewareData[name] = {
|
|
323
|
+
...middlewareData[name],
|
|
324
|
+
...data
|
|
325
|
+
};
|
|
326
|
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
|
327
|
+
resetCount++;
|
|
328
|
+
if (typeof reset === "object") {
|
|
329
|
+
if (reset.placement) {
|
|
330
|
+
statefulPlacement = reset.placement;
|
|
331
|
+
}
|
|
332
|
+
if (reset.rects) {
|
|
333
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
334
|
+
reference,
|
|
335
|
+
floating,
|
|
336
|
+
strategy
|
|
337
|
+
}) : reset.rects;
|
|
338
|
+
}
|
|
339
|
+
({
|
|
340
|
+
x,
|
|
341
|
+
y
|
|
342
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
343
|
+
}
|
|
344
|
+
i = -1;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
x,
|
|
349
|
+
y,
|
|
350
|
+
placement: statefulPlacement,
|
|
351
|
+
strategy,
|
|
352
|
+
middlewareData
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
var arrow = (options) => ({
|
|
356
|
+
name: "arrow",
|
|
357
|
+
options,
|
|
358
|
+
async fn(state) {
|
|
359
|
+
const {
|
|
360
|
+
x,
|
|
361
|
+
y,
|
|
362
|
+
placement,
|
|
363
|
+
rects,
|
|
364
|
+
platform,
|
|
365
|
+
elements,
|
|
366
|
+
middlewareData
|
|
367
|
+
} = state;
|
|
368
|
+
const {
|
|
369
|
+
element,
|
|
370
|
+
padding = 0
|
|
371
|
+
} = evaluate(options, state) || {};
|
|
372
|
+
if (element == null) {
|
|
373
|
+
return {};
|
|
374
|
+
}
|
|
375
|
+
const paddingObject = getPaddingObject(padding);
|
|
376
|
+
const coords = {
|
|
377
|
+
x,
|
|
378
|
+
y
|
|
379
|
+
};
|
|
380
|
+
const axis = getAlignmentAxis(placement);
|
|
381
|
+
const length = getAxisLength(axis);
|
|
382
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
383
|
+
const isYAxis = axis === "y";
|
|
384
|
+
const minProp = isYAxis ? "top" : "left";
|
|
385
|
+
const maxProp = isYAxis ? "bottom" : "right";
|
|
386
|
+
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
|
|
387
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
388
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
389
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
390
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
391
|
+
if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) {
|
|
392
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
393
|
+
}
|
|
394
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
395
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
396
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
397
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
398
|
+
const min$1 = minPadding;
|
|
399
|
+
const max2 = clientSize - arrowDimensions[length] - maxPadding;
|
|
400
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
401
|
+
const offset2 = clamp(min$1, center, max2);
|
|
402
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
403
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
|
|
404
|
+
return {
|
|
405
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
406
|
+
data: {
|
|
407
|
+
[axis]: offset2,
|
|
408
|
+
centerOffset: center - offset2 - alignmentOffset,
|
|
409
|
+
...shouldAddOffset && {
|
|
410
|
+
alignmentOffset
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
reset: shouldAddOffset
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
418
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement);
|
|
419
|
+
return allowedPlacementsSortedByAlignment.filter((placement) => {
|
|
420
|
+
if (alignment) {
|
|
421
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
422
|
+
}
|
|
423
|
+
return true;
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
var autoPlacement = function(options) {
|
|
427
|
+
if (options === void 0) {
|
|
428
|
+
options = {};
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
name: "autoPlacement",
|
|
432
|
+
options,
|
|
433
|
+
async fn(state) {
|
|
434
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
435
|
+
const {
|
|
436
|
+
rects,
|
|
437
|
+
middlewareData,
|
|
438
|
+
placement,
|
|
439
|
+
platform,
|
|
440
|
+
elements
|
|
441
|
+
} = state;
|
|
442
|
+
const {
|
|
443
|
+
crossAxis = false,
|
|
444
|
+
alignment,
|
|
445
|
+
allowedPlacements = placements,
|
|
446
|
+
autoAlignment = true,
|
|
447
|
+
...detectOverflowOptions
|
|
448
|
+
} = evaluate(options, state);
|
|
449
|
+
const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
450
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
451
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
452
|
+
const currentPlacement = placements$1[currentIndex];
|
|
453
|
+
if (currentPlacement == null) {
|
|
454
|
+
return {};
|
|
455
|
+
}
|
|
456
|
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
457
|
+
if (placement !== currentPlacement) {
|
|
458
|
+
return {
|
|
459
|
+
reset: {
|
|
460
|
+
placement: placements$1[0]
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
465
|
+
const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], {
|
|
466
|
+
placement: currentPlacement,
|
|
467
|
+
overflows: currentOverflows
|
|
468
|
+
}];
|
|
469
|
+
const nextPlacement = placements$1[currentIndex + 1];
|
|
470
|
+
if (nextPlacement) {
|
|
471
|
+
return {
|
|
472
|
+
data: {
|
|
473
|
+
index: currentIndex + 1,
|
|
474
|
+
overflows: allOverflows
|
|
475
|
+
},
|
|
476
|
+
reset: {
|
|
477
|
+
placement: nextPlacement
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
const placementsSortedByMostSpace = allOverflows.map((d) => {
|
|
482
|
+
const alignment2 = getAlignment(d.placement);
|
|
483
|
+
return [d.placement, alignment2 && crossAxis ? (
|
|
484
|
+
// Check along the mainAxis and main crossAxis side.
|
|
485
|
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0)
|
|
486
|
+
) : (
|
|
487
|
+
// Check only the mainAxis.
|
|
488
|
+
d.overflows[0]
|
|
489
|
+
), d.overflows];
|
|
490
|
+
}).sort((a, b) => a[1] - b[1]);
|
|
491
|
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d) => d[2].slice(
|
|
492
|
+
0,
|
|
493
|
+
// Aligned placements should not check their opposite crossAxis
|
|
494
|
+
// side.
|
|
495
|
+
getAlignment(d[0]) ? 2 : 3
|
|
496
|
+
).every((v) => v <= 0));
|
|
497
|
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
498
|
+
if (resetPlacement !== placement) {
|
|
499
|
+
return {
|
|
500
|
+
data: {
|
|
501
|
+
index: currentIndex + 1,
|
|
502
|
+
overflows: allOverflows
|
|
503
|
+
},
|
|
504
|
+
reset: {
|
|
505
|
+
placement: resetPlacement
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
return {};
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
var flip = function(options) {
|
|
514
|
+
if (options === void 0) {
|
|
515
|
+
options = {};
|
|
516
|
+
}
|
|
517
|
+
return {
|
|
518
|
+
name: "flip",
|
|
519
|
+
options,
|
|
520
|
+
async fn(state) {
|
|
521
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
522
|
+
const {
|
|
523
|
+
placement,
|
|
524
|
+
middlewareData,
|
|
525
|
+
rects,
|
|
526
|
+
initialPlacement,
|
|
527
|
+
platform,
|
|
528
|
+
elements
|
|
529
|
+
} = state;
|
|
530
|
+
const {
|
|
531
|
+
mainAxis: checkMainAxis = true,
|
|
532
|
+
crossAxis: checkCrossAxis = true,
|
|
533
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
534
|
+
fallbackStrategy = "bestFit",
|
|
535
|
+
fallbackAxisSideDirection = "none",
|
|
536
|
+
flipAlignment = true,
|
|
537
|
+
...detectOverflowOptions
|
|
538
|
+
} = evaluate(options, state);
|
|
539
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
540
|
+
return {};
|
|
541
|
+
}
|
|
542
|
+
const side = getSide(placement);
|
|
543
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
544
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
545
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
546
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
547
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
548
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
549
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
550
|
+
}
|
|
551
|
+
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
552
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
553
|
+
const overflows = [];
|
|
554
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
555
|
+
if (checkMainAxis) {
|
|
556
|
+
overflows.push(overflow[side]);
|
|
557
|
+
}
|
|
558
|
+
if (checkCrossAxis) {
|
|
559
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
560
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
561
|
+
}
|
|
562
|
+
overflowsData = [...overflowsData, {
|
|
563
|
+
placement,
|
|
564
|
+
overflows
|
|
565
|
+
}];
|
|
566
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
567
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
568
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
569
|
+
const nextPlacement = placements2[nextIndex];
|
|
570
|
+
if (nextPlacement) {
|
|
571
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
572
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
573
|
+
// overflows the main axis.
|
|
574
|
+
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
575
|
+
return {
|
|
576
|
+
data: {
|
|
577
|
+
index: nextIndex,
|
|
578
|
+
overflows: overflowsData
|
|
579
|
+
},
|
|
580
|
+
reset: {
|
|
581
|
+
placement: nextPlacement
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
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;
|
|
587
|
+
if (!resetPlacement) {
|
|
588
|
+
switch (fallbackStrategy) {
|
|
589
|
+
case "bestFit": {
|
|
590
|
+
var _overflowsData$filter2;
|
|
591
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
592
|
+
if (hasFallbackAxisSideDirection) {
|
|
593
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
594
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
595
|
+
// reading directions favoring greater width.
|
|
596
|
+
currentSideAxis === "y";
|
|
597
|
+
}
|
|
598
|
+
return true;
|
|
599
|
+
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
600
|
+
if (placement2) {
|
|
601
|
+
resetPlacement = placement2;
|
|
602
|
+
}
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
case "initialPlacement":
|
|
606
|
+
resetPlacement = initialPlacement;
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
if (placement !== resetPlacement) {
|
|
611
|
+
return {
|
|
612
|
+
reset: {
|
|
613
|
+
placement: resetPlacement
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return {};
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
};
|
|
622
|
+
var originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
623
|
+
async function convertValueToCoords(state, options) {
|
|
624
|
+
const {
|
|
625
|
+
placement,
|
|
626
|
+
platform,
|
|
627
|
+
elements
|
|
628
|
+
} = state;
|
|
629
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
630
|
+
const side = getSide(placement);
|
|
631
|
+
const alignment = getAlignment(placement);
|
|
632
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
633
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
634
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
635
|
+
const rawValue = evaluate(options, state);
|
|
636
|
+
let {
|
|
637
|
+
mainAxis,
|
|
638
|
+
crossAxis,
|
|
639
|
+
alignmentAxis
|
|
640
|
+
} = typeof rawValue === "number" ? {
|
|
641
|
+
mainAxis: rawValue,
|
|
642
|
+
crossAxis: 0,
|
|
643
|
+
alignmentAxis: null
|
|
644
|
+
} : {
|
|
645
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
646
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
647
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
648
|
+
};
|
|
649
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
650
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
651
|
+
}
|
|
652
|
+
return isVertical ? {
|
|
653
|
+
x: crossAxis * crossAxisMulti,
|
|
654
|
+
y: mainAxis * mainAxisMulti
|
|
655
|
+
} : {
|
|
656
|
+
x: mainAxis * mainAxisMulti,
|
|
657
|
+
y: crossAxis * crossAxisMulti
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
var offset = function(options) {
|
|
661
|
+
if (options === void 0) {
|
|
662
|
+
options = 0;
|
|
663
|
+
}
|
|
664
|
+
return {
|
|
665
|
+
name: "offset",
|
|
666
|
+
options,
|
|
667
|
+
async fn(state) {
|
|
668
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
669
|
+
const {
|
|
670
|
+
x,
|
|
671
|
+
y,
|
|
672
|
+
placement,
|
|
673
|
+
middlewareData
|
|
674
|
+
} = state;
|
|
675
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
676
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
677
|
+
return {};
|
|
678
|
+
}
|
|
679
|
+
return {
|
|
680
|
+
x: x + diffCoords.x,
|
|
681
|
+
y: y + diffCoords.y,
|
|
682
|
+
data: {
|
|
683
|
+
...diffCoords,
|
|
684
|
+
placement
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
};
|
|
690
|
+
var shift = function(options) {
|
|
691
|
+
if (options === void 0) {
|
|
692
|
+
options = {};
|
|
693
|
+
}
|
|
694
|
+
return {
|
|
695
|
+
name: "shift",
|
|
696
|
+
options,
|
|
697
|
+
async fn(state) {
|
|
698
|
+
const {
|
|
699
|
+
x,
|
|
700
|
+
y,
|
|
701
|
+
placement,
|
|
702
|
+
platform
|
|
703
|
+
} = state;
|
|
704
|
+
const {
|
|
705
|
+
mainAxis: checkMainAxis = true,
|
|
706
|
+
crossAxis: checkCrossAxis = false,
|
|
707
|
+
limiter = {
|
|
708
|
+
fn: (_ref) => {
|
|
709
|
+
let {
|
|
710
|
+
x: x2,
|
|
711
|
+
y: y2
|
|
712
|
+
} = _ref;
|
|
713
|
+
return {
|
|
714
|
+
x: x2,
|
|
715
|
+
y: y2
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
...detectOverflowOptions
|
|
720
|
+
} = evaluate(options, state);
|
|
721
|
+
const coords = {
|
|
722
|
+
x,
|
|
723
|
+
y
|
|
724
|
+
};
|
|
725
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
726
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
727
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
728
|
+
let mainAxisCoord = coords[mainAxis];
|
|
729
|
+
let crossAxisCoord = coords[crossAxis];
|
|
730
|
+
if (checkMainAxis) {
|
|
731
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
732
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
733
|
+
const min2 = mainAxisCoord + overflow[minSide];
|
|
734
|
+
const max2 = mainAxisCoord - overflow[maxSide];
|
|
735
|
+
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
736
|
+
}
|
|
737
|
+
if (checkCrossAxis) {
|
|
738
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
739
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
740
|
+
const min2 = crossAxisCoord + overflow[minSide];
|
|
741
|
+
const max2 = crossAxisCoord - overflow[maxSide];
|
|
742
|
+
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
743
|
+
}
|
|
744
|
+
const limitedCoords = limiter.fn({
|
|
745
|
+
...state,
|
|
746
|
+
[mainAxis]: mainAxisCoord,
|
|
747
|
+
[crossAxis]: crossAxisCoord
|
|
748
|
+
});
|
|
749
|
+
return {
|
|
750
|
+
...limitedCoords,
|
|
751
|
+
data: {
|
|
752
|
+
x: limitedCoords.x - x,
|
|
753
|
+
y: limitedCoords.y - y,
|
|
754
|
+
enabled: {
|
|
755
|
+
[mainAxis]: checkMainAxis,
|
|
756
|
+
[crossAxis]: checkCrossAxis
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
};
|
|
763
|
+
var limitShift = function(options) {
|
|
764
|
+
if (options === void 0) {
|
|
765
|
+
options = {};
|
|
766
|
+
}
|
|
767
|
+
return {
|
|
768
|
+
options,
|
|
769
|
+
fn(state) {
|
|
770
|
+
const {
|
|
771
|
+
x,
|
|
772
|
+
y,
|
|
773
|
+
placement,
|
|
774
|
+
rects,
|
|
775
|
+
middlewareData
|
|
776
|
+
} = state;
|
|
777
|
+
const {
|
|
778
|
+
offset: offset2 = 0,
|
|
779
|
+
mainAxis: checkMainAxis = true,
|
|
780
|
+
crossAxis: checkCrossAxis = true
|
|
781
|
+
} = evaluate(options, state);
|
|
782
|
+
const coords = {
|
|
783
|
+
x,
|
|
784
|
+
y
|
|
785
|
+
};
|
|
786
|
+
const crossAxis = getSideAxis(placement);
|
|
787
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
788
|
+
let mainAxisCoord = coords[mainAxis];
|
|
789
|
+
let crossAxisCoord = coords[crossAxis];
|
|
790
|
+
const rawOffset = evaluate(offset2, state);
|
|
791
|
+
const computedOffset = typeof rawOffset === "number" ? {
|
|
792
|
+
mainAxis: rawOffset,
|
|
793
|
+
crossAxis: 0
|
|
794
|
+
} : {
|
|
795
|
+
mainAxis: 0,
|
|
796
|
+
crossAxis: 0,
|
|
797
|
+
...rawOffset
|
|
798
|
+
};
|
|
799
|
+
if (checkMainAxis) {
|
|
800
|
+
const len = mainAxis === "y" ? "height" : "width";
|
|
801
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
802
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
803
|
+
if (mainAxisCoord < limitMin) {
|
|
804
|
+
mainAxisCoord = limitMin;
|
|
805
|
+
} else if (mainAxisCoord > limitMax) {
|
|
806
|
+
mainAxisCoord = limitMax;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
if (checkCrossAxis) {
|
|
810
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
811
|
+
const len = mainAxis === "y" ? "width" : "height";
|
|
812
|
+
const isOriginSide = originSides.has(getSide(placement));
|
|
813
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
814
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
815
|
+
if (crossAxisCoord < limitMin) {
|
|
816
|
+
crossAxisCoord = limitMin;
|
|
817
|
+
} else if (crossAxisCoord > limitMax) {
|
|
818
|
+
crossAxisCoord = limitMax;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return {
|
|
822
|
+
[mainAxis]: mainAxisCoord,
|
|
823
|
+
[crossAxis]: crossAxisCoord
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
export {
|
|
829
|
+
arrow,
|
|
830
|
+
autoPlacement,
|
|
831
|
+
computePosition,
|
|
832
|
+
detectOverflow,
|
|
833
|
+
flip,
|
|
834
|
+
limitShift,
|
|
835
|
+
offset,
|
|
836
|
+
shift
|
|
837
|
+
};
|