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