@getflip/swirl-components 0.49.1 → 0.50.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/components.json +109 -1
- package/dist/cjs/{floating-ui.dom.esm-35943202.js → floating-ui.dom.esm-39236b6a.js} +130 -117
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-autocomplete.cjs.entry.js +1 -1
- package/dist/cjs/swirl-card.cjs.entry.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-dialog.cjs.entry.js +1 -1
- package/dist/cjs/swirl-icon-lock-person.cjs.entry.js +23 -0
- package/dist/cjs/swirl-icon-unlock-person.cjs.entry.js +23 -0
- package/dist/cjs/swirl-modal.cjs.entry.js +1 -1
- package/dist/cjs/swirl-popover.cjs.entry.js +1 -1
- package/dist/cjs/swirl-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/swirl-tree-navigation-item.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/swirl-card/swirl-card.css +4 -0
- package/dist/collection/components/swirl-dialog/swirl-dialog.css +4 -4
- package/dist/collection/components/swirl-icon/icons/swirl-icon-lock-person.js +52 -0
- package/dist/collection/components/swirl-icon/icons/swirl-icon-unlock-person.js +52 -0
- package/dist/collection/components/swirl-modal/swirl-modal.css +4 -4
- package/dist/collection/components/swirl-tree-navigation-item/swirl-tree-navigation-item.css +1 -1
- package/dist/components/floating-ui.dom.esm.js +130 -117
- package/dist/components/swirl-card.js +1 -1
- package/dist/components/swirl-dialog.js +1 -1
- package/dist/components/swirl-icon-lock-person.d.ts +11 -0
- package/dist/components/swirl-icon-lock-person.js +40 -0
- package/dist/components/swirl-icon-unlock-person.d.ts +11 -0
- package/dist/components/swirl-icon-unlock-person.js +40 -0
- package/dist/components/swirl-modal.js +1 -1
- package/dist/components/swirl-tree-navigation-item.js +1 -1
- package/dist/esm/{floating-ui.dom.esm-b9f28f6d.js → floating-ui.dom.esm-ac7cc24e.js} +130 -117
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-autocomplete.entry.js +1 -1
- package/dist/esm/swirl-card.entry.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-dialog.entry.js +1 -1
- package/dist/esm/swirl-icon-lock-person.entry.js +19 -0
- package/dist/esm/swirl-icon-unlock-person.entry.js +19 -0
- package/dist/esm/swirl-modal.entry.js +1 -1
- package/dist/esm/swirl-popover.entry.js +1 -1
- package/dist/esm/swirl-tooltip.entry.js +1 -1
- package/dist/esm/swirl-tree-navigation-item.entry.js +1 -1
- package/dist/swirl-components/{p-b76df929.entry.js → p-063afb09.entry.js} +1 -1
- package/dist/swirl-components/p-3c9f6731.entry.js +1 -0
- package/dist/swirl-components/{p-848cacac.entry.js → p-504ab3ec.entry.js} +1 -1
- package/dist/swirl-components/p-530a0003.entry.js +1 -0
- package/dist/swirl-components/{p-c17b8536.entry.js → p-76c4b5dc.entry.js} +1 -1
- package/dist/swirl-components/p-791d8d8f.entry.js +1 -0
- package/dist/swirl-components/{p-5526e2c9.entry.js → p-dc67a056.entry.js} +1 -1
- package/dist/swirl-components/{p-13376409.entry.js → p-dec381b9.entry.js} +1 -1
- package/dist/swirl-components/p-ecb8b7f5.js +1 -0
- package/dist/swirl-components/p-f6a44042.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-icon/icons/swirl-icon-lock-person.d.ts +5 -0
- package/dist/types/components/swirl-icon/icons/swirl-icon-unlock-person.d.ts +5 -0
- package/dist/types/components.d.ts +30 -0
- package/package.json +3 -3
- package/vscode-data.json +26 -0
- package/dist/swirl-components/p-6526bf3e.js +0 -1
- package/dist/swirl-components/p-c9a34a56.entry.js +0 -1
- package/dist/swirl-components/p-eef15ebc.entry.js +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function getSide(placement) {
|
|
4
|
-
return placement.split('-')[0];
|
|
5
|
-
}
|
|
6
|
-
|
|
7
3
|
function getAlignment(placement) {
|
|
8
4
|
return placement.split('-')[1];
|
|
9
5
|
}
|
|
10
6
|
|
|
11
|
-
function getMainAxisFromPlacement(placement) {
|
|
12
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
7
|
function getLengthFromAxis(axis) {
|
|
16
8
|
return axis === 'y' ? 'height' : 'width';
|
|
17
9
|
}
|
|
18
10
|
|
|
11
|
+
function getSide(placement) {
|
|
12
|
+
return placement.split('-')[0];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getMainAxisFromPlacement(placement) {
|
|
16
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
19
|
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
20
20
|
let {
|
|
21
21
|
reference,
|
|
@@ -29,7 +29,6 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
29
29
|
const side = getSide(placement);
|
|
30
30
|
const isVertical = mainAxis === 'x';
|
|
31
31
|
let coords;
|
|
32
|
-
|
|
33
32
|
switch (side) {
|
|
34
33
|
case 'top':
|
|
35
34
|
coords = {
|
|
@@ -37,45 +36,38 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
37
36
|
y: reference.y - floating.height
|
|
38
37
|
};
|
|
39
38
|
break;
|
|
40
|
-
|
|
41
39
|
case 'bottom':
|
|
42
40
|
coords = {
|
|
43
41
|
x: commonX,
|
|
44
42
|
y: reference.y + reference.height
|
|
45
43
|
};
|
|
46
44
|
break;
|
|
47
|
-
|
|
48
45
|
case 'right':
|
|
49
46
|
coords = {
|
|
50
47
|
x: reference.x + reference.width,
|
|
51
48
|
y: commonY
|
|
52
49
|
};
|
|
53
50
|
break;
|
|
54
|
-
|
|
55
51
|
case 'left':
|
|
56
52
|
coords = {
|
|
57
53
|
x: reference.x - floating.width,
|
|
58
54
|
y: commonY
|
|
59
55
|
};
|
|
60
56
|
break;
|
|
61
|
-
|
|
62
57
|
default:
|
|
63
58
|
coords = {
|
|
64
59
|
x: reference.x,
|
|
65
60
|
y: reference.y
|
|
66
61
|
};
|
|
67
62
|
}
|
|
68
|
-
|
|
69
63
|
switch (getAlignment(placement)) {
|
|
70
64
|
case 'start':
|
|
71
65
|
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
72
66
|
break;
|
|
73
|
-
|
|
74
67
|
case 'end':
|
|
75
68
|
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
76
69
|
break;
|
|
77
70
|
}
|
|
78
|
-
|
|
79
71
|
return coords;
|
|
80
72
|
}
|
|
81
73
|
|
|
@@ -86,7 +78,6 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
86
78
|
* This export does not have any `platform` interface logic. You will need to
|
|
87
79
|
* write one for the platform you are using Floating UI with.
|
|
88
80
|
*/
|
|
89
|
-
|
|
90
81
|
const computePosition$1 = async (reference, floating, config) => {
|
|
91
82
|
const {
|
|
92
83
|
placement = 'bottom',
|
|
@@ -94,8 +85,8 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
94
85
|
middleware = [],
|
|
95
86
|
platform
|
|
96
87
|
} = config;
|
|
88
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
97
89
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
98
|
-
|
|
99
90
|
let rects = await platform.getElementRects({
|
|
100
91
|
reference,
|
|
101
92
|
floating,
|
|
@@ -108,12 +99,11 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
108
99
|
let statefulPlacement = placement;
|
|
109
100
|
let middlewareData = {};
|
|
110
101
|
let resetCount = 0;
|
|
111
|
-
|
|
112
|
-
for (let i = 0; i < middleware.length; i++) {
|
|
102
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
113
103
|
const {
|
|
114
104
|
name,
|
|
115
105
|
fn
|
|
116
|
-
} =
|
|
106
|
+
} = validMiddleware[i];
|
|
117
107
|
const {
|
|
118
108
|
x: nextX,
|
|
119
109
|
y: nextY,
|
|
@@ -135,20 +125,19 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
135
125
|
});
|
|
136
126
|
x = nextX != null ? nextX : x;
|
|
137
127
|
y = nextY != null ? nextY : y;
|
|
138
|
-
middlewareData = {
|
|
139
|
-
|
|
128
|
+
middlewareData = {
|
|
129
|
+
...middlewareData,
|
|
130
|
+
[name]: {
|
|
131
|
+
...middlewareData[name],
|
|
140
132
|
...data
|
|
141
133
|
}
|
|
142
134
|
};
|
|
143
|
-
|
|
144
135
|
if (reset && resetCount <= 50) {
|
|
145
136
|
resetCount++;
|
|
146
|
-
|
|
147
137
|
if (typeof reset === 'object') {
|
|
148
138
|
if (reset.placement) {
|
|
149
139
|
statefulPlacement = reset.placement;
|
|
150
140
|
}
|
|
151
|
-
|
|
152
141
|
if (reset.rects) {
|
|
153
142
|
rects = reset.rects === true ? await platform.getElementRects({
|
|
154
143
|
reference,
|
|
@@ -156,18 +145,15 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
156
145
|
strategy
|
|
157
146
|
}) : reset.rects;
|
|
158
147
|
}
|
|
159
|
-
|
|
160
148
|
({
|
|
161
149
|
x,
|
|
162
150
|
y
|
|
163
151
|
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
164
152
|
}
|
|
165
|
-
|
|
166
153
|
i = -1;
|
|
167
154
|
continue;
|
|
168
155
|
}
|
|
169
156
|
}
|
|
170
|
-
|
|
171
157
|
return {
|
|
172
158
|
x,
|
|
173
159
|
y,
|
|
@@ -197,7 +183,8 @@ function getSideObjectFromPadding(padding) {
|
|
|
197
183
|
}
|
|
198
184
|
|
|
199
185
|
function rectToClientRect(rect) {
|
|
200
|
-
return {
|
|
186
|
+
return {
|
|
187
|
+
...rect,
|
|
201
188
|
top: rect.y,
|
|
202
189
|
left: rect.x,
|
|
203
190
|
right: rect.x + rect.width,
|
|
@@ -207,19 +194,17 @@ function rectToClientRect(rect) {
|
|
|
207
194
|
|
|
208
195
|
/**
|
|
209
196
|
* Resolves with an object of overflow side offsets that determine how much the
|
|
210
|
-
* element is overflowing a given clipping boundary.
|
|
197
|
+
* element is overflowing a given clipping boundary on each side.
|
|
211
198
|
* - positive = overflowing the boundary by that number of pixels
|
|
212
199
|
* - negative = how many pixels left before it will overflow
|
|
213
200
|
* - 0 = lies flush with the boundary
|
|
214
201
|
* @see https://floating-ui.com/docs/detectOverflow
|
|
215
202
|
*/
|
|
216
|
-
async function detectOverflow(
|
|
203
|
+
async function detectOverflow(state, options) {
|
|
217
204
|
var _await$platform$isEle;
|
|
218
|
-
|
|
219
205
|
if (options === void 0) {
|
|
220
206
|
options = {};
|
|
221
207
|
}
|
|
222
|
-
|
|
223
208
|
const {
|
|
224
209
|
x,
|
|
225
210
|
y,
|
|
@@ -227,7 +212,7 @@ async function detectOverflow(middlewareArguments, options) {
|
|
|
227
212
|
rects,
|
|
228
213
|
elements,
|
|
229
214
|
strategy
|
|
230
|
-
} =
|
|
215
|
+
} = state;
|
|
231
216
|
const {
|
|
232
217
|
boundary = 'clippingAncestors',
|
|
233
218
|
rootBoundary = 'viewport',
|
|
@@ -244,19 +229,29 @@ async function detectOverflow(middlewareArguments, options) {
|
|
|
244
229
|
rootBoundary,
|
|
245
230
|
strategy
|
|
246
231
|
}));
|
|
232
|
+
const rect = elementContext === 'floating' ? {
|
|
233
|
+
...rects.floating,
|
|
234
|
+
x,
|
|
235
|
+
y
|
|
236
|
+
} : rects.reference;
|
|
237
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
238
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
239
|
+
x: 1,
|
|
240
|
+
y: 1
|
|
241
|
+
} : {
|
|
242
|
+
x: 1,
|
|
243
|
+
y: 1
|
|
244
|
+
};
|
|
247
245
|
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
248
|
-
rect
|
|
249
|
-
|
|
250
|
-
y
|
|
251
|
-
} : rects.reference,
|
|
252
|
-
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
246
|
+
rect,
|
|
247
|
+
offsetParent,
|
|
253
248
|
strategy
|
|
254
|
-
}) :
|
|
249
|
+
}) : rect);
|
|
255
250
|
return {
|
|
256
|
-
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
257
|
-
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
258
|
-
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
259
|
-
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
251
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
252
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
253
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
254
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
260
255
|
};
|
|
261
256
|
}
|
|
262
257
|
|
|
@@ -267,42 +262,39 @@ function within(min$1$1, value, max$1$1) {
|
|
|
267
262
|
return max$1(min$1$1, min$1(value, max$1$1));
|
|
268
263
|
}
|
|
269
264
|
|
|
270
|
-
const
|
|
265
|
+
const oppositeSideMap = {
|
|
271
266
|
left: 'right',
|
|
272
267
|
right: 'left',
|
|
273
268
|
bottom: 'top',
|
|
274
269
|
top: 'bottom'
|
|
275
270
|
};
|
|
276
271
|
function getOppositePlacement(placement) {
|
|
277
|
-
return placement.replace(/left|right|bottom|top/g,
|
|
272
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
278
273
|
}
|
|
279
274
|
|
|
280
275
|
function getAlignmentSides(placement, rects, rtl) {
|
|
281
276
|
if (rtl === void 0) {
|
|
282
277
|
rtl = false;
|
|
283
278
|
}
|
|
284
|
-
|
|
285
279
|
const alignment = getAlignment(placement);
|
|
286
280
|
const mainAxis = getMainAxisFromPlacement(placement);
|
|
287
281
|
const length = getLengthFromAxis(mainAxis);
|
|
288
282
|
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
289
|
-
|
|
290
283
|
if (rects.reference[length] > rects.floating[length]) {
|
|
291
284
|
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
292
285
|
}
|
|
293
|
-
|
|
294
286
|
return {
|
|
295
287
|
main: mainAlignmentSide,
|
|
296
288
|
cross: getOppositePlacement(mainAlignmentSide)
|
|
297
289
|
};
|
|
298
290
|
}
|
|
299
291
|
|
|
300
|
-
const
|
|
292
|
+
const oppositeAlignmentMap = {
|
|
301
293
|
start: 'end',
|
|
302
294
|
end: 'start'
|
|
303
295
|
};
|
|
304
296
|
function getOppositeAlignmentPlacement(placement) {
|
|
305
|
-
return placement.replace(/start|end/g,
|
|
297
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
306
298
|
}
|
|
307
299
|
|
|
308
300
|
function getExpandedPlacements(placement) {
|
|
@@ -310,23 +302,50 @@ function getExpandedPlacements(placement) {
|
|
|
310
302
|
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
311
303
|
}
|
|
312
304
|
|
|
305
|
+
function getSideList(side, isStart, rtl) {
|
|
306
|
+
const lr = ['left', 'right'];
|
|
307
|
+
const rl = ['right', 'left'];
|
|
308
|
+
const tb = ['top', 'bottom'];
|
|
309
|
+
const bt = ['bottom', 'top'];
|
|
310
|
+
switch (side) {
|
|
311
|
+
case 'top':
|
|
312
|
+
case 'bottom':
|
|
313
|
+
if (rtl) return isStart ? rl : lr;
|
|
314
|
+
return isStart ? lr : rl;
|
|
315
|
+
case 'left':
|
|
316
|
+
case 'right':
|
|
317
|
+
return isStart ? tb : bt;
|
|
318
|
+
default:
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
323
|
+
const alignment = getAlignment(placement);
|
|
324
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
325
|
+
if (alignment) {
|
|
326
|
+
list = list.map(side => side + "-" + alignment);
|
|
327
|
+
if (flipAlignment) {
|
|
328
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return list;
|
|
332
|
+
}
|
|
333
|
+
|
|
313
334
|
/**
|
|
314
|
-
*
|
|
315
|
-
*
|
|
335
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
336
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
337
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
316
338
|
* @see https://floating-ui.com/docs/flip
|
|
317
339
|
*/
|
|
318
340
|
const flip = function (options) {
|
|
319
341
|
if (options === void 0) {
|
|
320
342
|
options = {};
|
|
321
343
|
}
|
|
322
|
-
|
|
323
344
|
return {
|
|
324
345
|
name: 'flip',
|
|
325
346
|
options,
|
|
326
|
-
|
|
327
|
-
async fn(middlewareArguments) {
|
|
347
|
+
async fn(state) {
|
|
328
348
|
var _middlewareData$flip;
|
|
329
|
-
|
|
330
349
|
const {
|
|
331
350
|
placement,
|
|
332
351
|
middlewareData,
|
|
@@ -334,48 +353,49 @@ const flip = function (options) {
|
|
|
334
353
|
initialPlacement,
|
|
335
354
|
platform,
|
|
336
355
|
elements
|
|
337
|
-
} =
|
|
356
|
+
} = state;
|
|
338
357
|
const {
|
|
339
358
|
mainAxis: checkMainAxis = true,
|
|
340
359
|
crossAxis: checkCrossAxis = true,
|
|
341
360
|
fallbackPlacements: specifiedFallbackPlacements,
|
|
342
361
|
fallbackStrategy = 'bestFit',
|
|
362
|
+
fallbackAxisSideDirection = 'none',
|
|
343
363
|
flipAlignment = true,
|
|
344
364
|
...detectOverflowOptions
|
|
345
365
|
} = options;
|
|
346
366
|
const side = getSide(placement);
|
|
347
|
-
const isBasePlacement =
|
|
367
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
368
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
348
369
|
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
370
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
371
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
372
|
+
}
|
|
349
373
|
const placements = [initialPlacement, ...fallbackPlacements];
|
|
350
|
-
const overflow = await detectOverflow(
|
|
374
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
351
375
|
const overflows = [];
|
|
352
376
|
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
353
|
-
|
|
354
377
|
if (checkMainAxis) {
|
|
355
378
|
overflows.push(overflow[side]);
|
|
356
379
|
}
|
|
357
|
-
|
|
358
380
|
if (checkCrossAxis) {
|
|
359
381
|
const {
|
|
360
382
|
main,
|
|
361
383
|
cross
|
|
362
|
-
} = getAlignmentSides(placement, rects,
|
|
384
|
+
} = getAlignmentSides(placement, rects, rtl);
|
|
363
385
|
overflows.push(overflow[main], overflow[cross]);
|
|
364
386
|
}
|
|
365
|
-
|
|
366
387
|
overflowsData = [...overflowsData, {
|
|
367
388
|
placement,
|
|
368
389
|
overflows
|
|
369
|
-
}];
|
|
390
|
+
}];
|
|
370
391
|
|
|
392
|
+
// One or more sides is overflowing.
|
|
371
393
|
if (!overflows.every(side => side <= 0)) {
|
|
372
|
-
var _middlewareData$
|
|
373
|
-
|
|
374
|
-
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
|
|
394
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
395
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
375
396
|
const nextPlacement = placements[nextIndex];
|
|
376
|
-
|
|
377
397
|
if (nextPlacement) {
|
|
378
|
-
// Try next placement and re-run the lifecycle
|
|
398
|
+
// Try next placement and re-run the lifecycle.
|
|
379
399
|
return {
|
|
380
400
|
data: {
|
|
381
401
|
index: nextIndex,
|
|
@@ -387,27 +407,27 @@ const flip = function (options) {
|
|
|
387
407
|
};
|
|
388
408
|
}
|
|
389
409
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
410
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
411
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
412
|
+
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;
|
|
413
|
+
|
|
414
|
+
// Otherwise fallback.
|
|
415
|
+
if (!resetPlacement) {
|
|
416
|
+
switch (fallbackStrategy) {
|
|
417
|
+
case 'bestFit':
|
|
418
|
+
{
|
|
419
|
+
var _overflowsData$map$so;
|
|
420
|
+
const placement = (_overflowsData$map$so = overflowsData.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$map$so[0];
|
|
421
|
+
if (placement) {
|
|
422
|
+
resetPlacement = placement;
|
|
423
|
+
}
|
|
424
|
+
break;
|
|
401
425
|
}
|
|
402
|
-
|
|
426
|
+
case 'initialPlacement':
|
|
427
|
+
resetPlacement = initialPlacement;
|
|
403
428
|
break;
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
case 'initialPlacement':
|
|
407
|
-
resetPlacement = initialPlacement;
|
|
408
|
-
break;
|
|
429
|
+
}
|
|
409
430
|
}
|
|
410
|
-
|
|
411
431
|
if (placement !== resetPlacement) {
|
|
412
432
|
return {
|
|
413
433
|
reset: {
|
|
@@ -416,27 +436,26 @@ const flip = function (options) {
|
|
|
416
436
|
};
|
|
417
437
|
}
|
|
418
438
|
}
|
|
419
|
-
|
|
420
439
|
return {};
|
|
421
440
|
}
|
|
422
|
-
|
|
423
441
|
};
|
|
424
442
|
};
|
|
425
443
|
|
|
426
|
-
async function convertValueToCoords(
|
|
444
|
+
async function convertValueToCoords(state, value) {
|
|
427
445
|
const {
|
|
428
446
|
placement,
|
|
429
447
|
platform,
|
|
430
448
|
elements
|
|
431
|
-
} =
|
|
449
|
+
} = state;
|
|
432
450
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
433
451
|
const side = getSide(placement);
|
|
434
452
|
const alignment = getAlignment(placement);
|
|
435
453
|
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
436
454
|
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
437
455
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
438
|
-
const rawValue = typeof value === 'function' ? value(
|
|
456
|
+
const rawValue = typeof value === 'function' ? value(state) : value;
|
|
439
457
|
|
|
458
|
+
// eslint-disable-next-line prefer-const
|
|
440
459
|
let {
|
|
441
460
|
mainAxis,
|
|
442
461
|
crossAxis,
|
|
@@ -451,11 +470,9 @@ async function convertValueToCoords(middlewareArguments, value) {
|
|
|
451
470
|
alignmentAxis: null,
|
|
452
471
|
...rawValue
|
|
453
472
|
};
|
|
454
|
-
|
|
455
473
|
if (alignment && typeof alignmentAxis === 'number') {
|
|
456
474
|
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
457
475
|
}
|
|
458
|
-
|
|
459
476
|
return isVertical ? {
|
|
460
477
|
x: crossAxis * crossAxisMulti,
|
|
461
478
|
y: mainAxis * mainAxisMulti
|
|
@@ -464,33 +481,33 @@ async function convertValueToCoords(middlewareArguments, value) {
|
|
|
464
481
|
y: crossAxis * crossAxisMulti
|
|
465
482
|
};
|
|
466
483
|
}
|
|
484
|
+
|
|
467
485
|
/**
|
|
468
|
-
*
|
|
486
|
+
* Modifies the placement by translating the floating element along the
|
|
487
|
+
* specified axes.
|
|
488
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
489
|
+
* object may be passed.
|
|
469
490
|
* @see https://floating-ui.com/docs/offset
|
|
470
491
|
*/
|
|
471
|
-
|
|
472
492
|
const offset = function (value) {
|
|
473
493
|
if (value === void 0) {
|
|
474
494
|
value = 0;
|
|
475
495
|
}
|
|
476
|
-
|
|
477
496
|
return {
|
|
478
497
|
name: 'offset',
|
|
479
498
|
options: value,
|
|
480
|
-
|
|
481
|
-
async fn(middlewareArguments) {
|
|
499
|
+
async fn(state) {
|
|
482
500
|
const {
|
|
483
501
|
x,
|
|
484
502
|
y
|
|
485
|
-
} =
|
|
486
|
-
const diffCoords = await convertValueToCoords(
|
|
503
|
+
} = state;
|
|
504
|
+
const diffCoords = await convertValueToCoords(state, value);
|
|
487
505
|
return {
|
|
488
506
|
x: x + diffCoords.x,
|
|
489
507
|
y: y + diffCoords.y,
|
|
490
508
|
data: diffCoords
|
|
491
509
|
};
|
|
492
510
|
}
|
|
493
|
-
|
|
494
511
|
};
|
|
495
512
|
};
|
|
496
513
|
|
|
@@ -499,25 +516,23 @@ function getCrossAxis(axis) {
|
|
|
499
516
|
}
|
|
500
517
|
|
|
501
518
|
/**
|
|
502
|
-
*
|
|
503
|
-
*
|
|
519
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
520
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
504
521
|
* @see https://floating-ui.com/docs/shift
|
|
505
522
|
*/
|
|
506
523
|
const shift = function (options) {
|
|
507
524
|
if (options === void 0) {
|
|
508
525
|
options = {};
|
|
509
526
|
}
|
|
510
|
-
|
|
511
527
|
return {
|
|
512
528
|
name: 'shift',
|
|
513
529
|
options,
|
|
514
|
-
|
|
515
|
-
async fn(middlewareArguments) {
|
|
530
|
+
async fn(state) {
|
|
516
531
|
const {
|
|
517
532
|
x,
|
|
518
533
|
y,
|
|
519
534
|
placement
|
|
520
|
-
} =
|
|
535
|
+
} = state;
|
|
521
536
|
const {
|
|
522
537
|
mainAxis: checkMainAxis = true,
|
|
523
538
|
crossAxis: checkCrossAxis = false,
|
|
@@ -539,12 +554,11 @@ const shift = function (options) {
|
|
|
539
554
|
x,
|
|
540
555
|
y
|
|
541
556
|
};
|
|
542
|
-
const overflow = await detectOverflow(
|
|
557
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
543
558
|
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
544
559
|
const crossAxis = getCrossAxis(mainAxis);
|
|
545
560
|
let mainAxisCoord = coords[mainAxis];
|
|
546
561
|
let crossAxisCoord = coords[crossAxis];
|
|
547
|
-
|
|
548
562
|
if (checkMainAxis) {
|
|
549
563
|
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
550
564
|
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
@@ -552,7 +566,6 @@ const shift = function (options) {
|
|
|
552
566
|
const max = mainAxisCoord - overflow[maxSide];
|
|
553
567
|
mainAxisCoord = within(min, mainAxisCoord, max);
|
|
554
568
|
}
|
|
555
|
-
|
|
556
569
|
if (checkCrossAxis) {
|
|
557
570
|
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
558
571
|
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
@@ -560,19 +573,19 @@ const shift = function (options) {
|
|
|
560
573
|
const max = crossAxisCoord - overflow[maxSide];
|
|
561
574
|
crossAxisCoord = within(min, crossAxisCoord, max);
|
|
562
575
|
}
|
|
563
|
-
|
|
564
|
-
|
|
576
|
+
const limitedCoords = limiter.fn({
|
|
577
|
+
...state,
|
|
565
578
|
[mainAxis]: mainAxisCoord,
|
|
566
579
|
[crossAxis]: crossAxisCoord
|
|
567
580
|
});
|
|
568
|
-
return {
|
|
581
|
+
return {
|
|
582
|
+
...limitedCoords,
|
|
569
583
|
data: {
|
|
570
584
|
x: limitedCoords.x - x,
|
|
571
585
|
y: limitedCoords.y - y
|
|
572
586
|
}
|
|
573
587
|
};
|
|
574
588
|
}
|
|
575
|
-
|
|
576
589
|
};
|
|
577
590
|
};
|
|
578
591
|
|