cbvirtua 1.0.6 → 1.0.7
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/menu/wzc-option.vue +74 -0
- package/menu/wzc-select.vue +209 -0
- package/package.json +1 -1
- package/v2/App.vue +0 -56
- package/v2/components/Dropdown.vue +0 -28
- package/v2/components/Menu.vue +0 -9
- package/v2/components/Popper.js +0 -1011
- package/v2/components/PopperContent.vue +0 -270
- package/v2/components/PopperMethods.js +0 -17
- package/v2/components/PopperWrapper.vue +0 -101
- package/v2/components/ResizeObserver.vue +0 -151
- package/v2/components/ThemeClass.js +0 -9
- package/v2/components/Tooltip.vue +0 -22
- package/v2/components/TooltipDirective.vue +0 -171
- package/v2/config.js +0 -133
- package/v2/directives/v-close-popper.js +0 -67
- package/v2/directives/v-tooltip.js +0 -116
- package/v2/floating-ui/core/computeCoordsFromPlacement.js +0 -39
- package/v2/floating-ui/core/computePosition.js +0 -52
- package/v2/floating-ui/core/detectOverflow.js +0 -36
- package/v2/floating-ui/core/enums.js +0 -7
- package/v2/floating-ui/core/index.js +0 -11
- package/v2/floating-ui/core/middleware/arrow.js +0 -52
- package/v2/floating-ui/core/middleware/autoPlacement.js +0 -84
- package/v2/floating-ui/core/middleware/flip.js +0 -82
- package/v2/floating-ui/core/middleware/hide.js +0 -36
- package/v2/floating-ui/core/middleware/inline.js +0 -100
- package/v2/floating-ui/core/middleware/offset.js +0 -26
- package/v2/floating-ui/core/middleware/shift.js +0 -99
- package/v2/floating-ui/core/middleware/size.js +0 -58
- package/v2/floating-ui/core/types.js +0 -11
- package/v2/floating-ui/core/utils/expandPaddingObject.js +0 -3
- package/v2/floating-ui/core/utils/getAlignment.js +0 -3
- package/v2/floating-ui/core/utils/getAlignmentSides.js +0 -23
- package/v2/floating-ui/core/utils/getBasePlacement.js +0 -3
- package/v2/floating-ui/core/utils/getCrossAxis.js +0 -3
- package/v2/floating-ui/core/utils/getExpandedPlacements.js +0 -10
- package/v2/floating-ui/core/utils/getLengthFromAxis.js +0 -3
- package/v2/floating-ui/core/utils/getMainAxisFromPlacement.js +0 -4
- package/v2/floating-ui/core/utils/getOppositeAlignmentPlacement.js +0 -4
- package/v2/floating-ui/core/utils/getOppositePlacement.js +0 -4
- package/v2/floating-ui/core/utils/getPaddingObject.js +0 -6
- package/v2/floating-ui/core/utils/math.js +0 -2
- package/v2/floating-ui/core/utils/rectToClientRect.js +0 -9
- package/v2/floating-ui/core/utils/within.js +0 -4
- package/v2/floating-ui/dom/index.js +0 -5
- package/v2/floating-ui/dom/platform.js +0 -20
- package/v2/floating-ui/dom/utils/contains.js +0 -22
- package/v2/floating-ui/dom/utils/convertOffsetParentRelativeRectToViewportRelativeRect.js +0 -35
- package/v2/floating-ui/dom/utils/getBoundingClientRect.js +0 -27
- package/v2/floating-ui/dom/utils/getClippingClientRect.js +0 -76
- package/v2/floating-ui/dom/utils/getComputedStyle.js +0 -4
- package/v2/floating-ui/dom/utils/getDimensions.js +0 -6
- package/v2/floating-ui/dom/utils/getDocumentElement.js +0 -4
- package/v2/floating-ui/dom/utils/getDocumentRect.js +0 -21
- package/v2/floating-ui/dom/utils/getNodeName.js +0 -4
- package/v2/floating-ui/dom/utils/getNodeScroll.js +0 -13
- package/v2/floating-ui/dom/utils/getOffsetParent.js +0 -43
- package/v2/floating-ui/dom/utils/getParentNode.js +0 -16
- package/v2/floating-ui/dom/utils/getRectRelativeToOffsetParent.js +0 -40
- package/v2/floating-ui/dom/utils/getScrollParent.js +0 -13
- package/v2/floating-ui/dom/utils/getScrollParents.js +0 -18
- package/v2/floating-ui/dom/utils/getViewportRect.js +0 -25
- package/v2/floating-ui/dom/utils/getWindowScrollBarX.js +0 -9
- package/v2/floating-ui/dom/utils/is.js +0 -38
- package/v2/floating-ui/dom/utils/math.js +0 -3
- package/v2/floating-ui/dom/utils/window.js +0 -13
- package/v2/index.js +0 -75
- package/v2/util/assign-deep.js +0 -12
- package/v2/util/env.js +0 -18
- package/v2/util/events.js +0 -12
- package/v2/util/frame.js +0 -5
- package/v2/util/lang.js +0 -6
- package/v2/util/popper.js +0 -5
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { detectOverflow, } from '../detectOverflow';
|
|
2
|
-
import { getBasePlacement } from '../utils/getBasePlacement';
|
|
3
|
-
import { getAlignment } from '../utils/getAlignment';
|
|
4
|
-
import { getAlignmentSides } from '../utils/getAlignmentSides';
|
|
5
|
-
import { getOppositeAlignmentPlacement } from '../utils/getOppositeAlignmentPlacement';
|
|
6
|
-
import { allPlacements } from '../enums';
|
|
7
|
-
export function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
8
|
-
const allowedPlacementsSortedByAlignment = alignment
|
|
9
|
-
? [
|
|
10
|
-
...allowedPlacements.filter((placement) => getAlignment(placement) === alignment),
|
|
11
|
-
...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment),
|
|
12
|
-
]
|
|
13
|
-
: allowedPlacements.filter((placement) => getBasePlacement(placement) === placement);
|
|
14
|
-
return allowedPlacementsSortedByAlignment.filter((placement) => {
|
|
15
|
-
if (alignment) {
|
|
16
|
-
return (getAlignment(placement) === alignment ||
|
|
17
|
-
(autoAlignment
|
|
18
|
-
? getOppositeAlignmentPlacement(placement) !== placement
|
|
19
|
-
: false));
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
export const autoPlacement = (options = {}) => ({
|
|
25
|
-
name: 'autoPlacement',
|
|
26
|
-
options,
|
|
27
|
-
async fn(middlewareArguments) {
|
|
28
|
-
var _a, _b, _c, _d, _e, _f;
|
|
29
|
-
const { x, y, rects, middlewareData, placement } = middlewareArguments;
|
|
30
|
-
const { alignment = null, allowedPlacements = allPlacements, autoAlignment = true, ...detectOverflowOptions } = options;
|
|
31
|
-
if ((_a = middlewareData.autoPlacement) === null || _a === void 0 ? void 0 : _a.skip) {
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
|
-
const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
|
|
35
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
36
|
-
const currentIndex = (_c = (_b = middlewareData.autoPlacement) === null || _b === void 0 ? void 0 : _b.index) !== null && _c !== void 0 ? _c : 0;
|
|
37
|
-
const currentPlacement = placements[currentIndex];
|
|
38
|
-
const { main, cross } = getAlignmentSides(currentPlacement, rects);
|
|
39
|
-
// Make `computeCoords` start from the right place
|
|
40
|
-
if (placement !== currentPlacement) {
|
|
41
|
-
return {
|
|
42
|
-
x,
|
|
43
|
-
y,
|
|
44
|
-
reset: {
|
|
45
|
-
placement: placements[0],
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const currentOverflows = [
|
|
50
|
-
overflow[getBasePlacement(currentPlacement)],
|
|
51
|
-
overflow[main],
|
|
52
|
-
overflow[cross],
|
|
53
|
-
];
|
|
54
|
-
const allOverflows = [
|
|
55
|
-
...((_e = (_d = middlewareData.autoPlacement) === null || _d === void 0 ? void 0 : _d.overflows) !== null && _e !== void 0 ? _e : []),
|
|
56
|
-
{ placement: currentPlacement, overflows: currentOverflows },
|
|
57
|
-
];
|
|
58
|
-
const nextPlacement = placements[currentIndex + 1];
|
|
59
|
-
// There are more placements to check
|
|
60
|
-
if (nextPlacement) {
|
|
61
|
-
return {
|
|
62
|
-
data: {
|
|
63
|
-
index: currentIndex + 1,
|
|
64
|
-
overflows: allOverflows,
|
|
65
|
-
},
|
|
66
|
-
reset: {
|
|
67
|
-
placement: nextPlacement,
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const placementsSortedByLeastOverflow = allOverflows
|
|
72
|
-
.slice()
|
|
73
|
-
.sort((a, b) => a.overflows[0] - b.overflows[0]);
|
|
74
|
-
const placementThatFitsOnAllSides = (_f = placementsSortedByLeastOverflow.find(({ overflows }) => overflows.every((overflow) => overflow <= 0))) === null || _f === void 0 ? void 0 : _f.placement;
|
|
75
|
-
return {
|
|
76
|
-
data: {
|
|
77
|
-
skip: true,
|
|
78
|
-
},
|
|
79
|
-
reset: {
|
|
80
|
-
placement: placementThatFitsOnAllSides !== null && placementThatFitsOnAllSides !== void 0 ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { getOppositePlacement } from '../utils/getOppositePlacement';
|
|
2
|
-
import { getBasePlacement } from '../utils/getBasePlacement';
|
|
3
|
-
import { detectOverflow, } from '../detectOverflow';
|
|
4
|
-
import { getAlignmentSides } from '../utils/getAlignmentSides';
|
|
5
|
-
import { getExpandedPlacements } from '../utils/getExpandedPlacements';
|
|
6
|
-
export const flip = (options = {}) => ({
|
|
7
|
-
name: 'flip',
|
|
8
|
-
options,
|
|
9
|
-
async fn(middlewareArguments) {
|
|
10
|
-
var _a, _b, _c, _d, _e;
|
|
11
|
-
const { placement, middlewareData, rects, initialPlacement } = middlewareArguments;
|
|
12
|
-
if ((_a = middlewareData.flip) === null || _a === void 0 ? void 0 : _a.skip) {
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy = 'bestFit', flipAlignment = true, ...detectOverflowOptions } = options;
|
|
16
|
-
const basePlacement = getBasePlacement(placement);
|
|
17
|
-
const isBasePlacement = basePlacement === initialPlacement;
|
|
18
|
-
const fallbackPlacements = specifiedFallbackPlacements ||
|
|
19
|
-
(isBasePlacement || !flipAlignment
|
|
20
|
-
? [getOppositePlacement(initialPlacement)]
|
|
21
|
-
: getExpandedPlacements(initialPlacement));
|
|
22
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
23
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
24
|
-
const overflows = [];
|
|
25
|
-
let overflowsData = ((_b = middlewareData.flip) === null || _b === void 0 ? void 0 : _b.overflows) || [];
|
|
26
|
-
if (checkMainAxis) {
|
|
27
|
-
overflows.push(overflow[basePlacement]);
|
|
28
|
-
}
|
|
29
|
-
if (checkCrossAxis) {
|
|
30
|
-
const { main, cross } = getAlignmentSides(placement, rects);
|
|
31
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
32
|
-
}
|
|
33
|
-
overflowsData = [...overflowsData, { placement, overflows }];
|
|
34
|
-
// One or more sides is overflowing
|
|
35
|
-
if (!overflows.every((side) => side <= 0)) {
|
|
36
|
-
const nextIndex = ((_d = (_c = middlewareData.flip) === null || _c === void 0 ? void 0 : _c.index) !== null && _d !== void 0 ? _d : 0) + 1;
|
|
37
|
-
const nextPlacement = placements[nextIndex];
|
|
38
|
-
if (nextPlacement) {
|
|
39
|
-
// Try next placement and re-run the lifecycle
|
|
40
|
-
return {
|
|
41
|
-
data: {
|
|
42
|
-
index: nextIndex,
|
|
43
|
-
overflows: overflowsData,
|
|
44
|
-
},
|
|
45
|
-
reset: {
|
|
46
|
-
placement: nextPlacement,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
let resetPlacement = 'bottom';
|
|
51
|
-
switch (fallbackStrategy) {
|
|
52
|
-
case 'bestFit': {
|
|
53
|
-
const placement = (_e = overflowsData
|
|
54
|
-
.slice()
|
|
55
|
-
.sort((a, b) => a.overflows
|
|
56
|
-
.filter((overflow) => overflow > 0)
|
|
57
|
-
.reduce((acc, overflow) => acc + overflow, 0) -
|
|
58
|
-
b.overflows
|
|
59
|
-
.filter((overflow) => overflow > 0)
|
|
60
|
-
.reduce((acc, overflow) => acc + overflow, 0))[0]) === null || _e === void 0 ? void 0 : _e.placement;
|
|
61
|
-
if (placement) {
|
|
62
|
-
resetPlacement = placement;
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
case 'initialPlacement':
|
|
67
|
-
resetPlacement = initialPlacement;
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
data: {
|
|
73
|
-
skip: true,
|
|
74
|
-
},
|
|
75
|
-
reset: {
|
|
76
|
-
placement: resetPlacement,
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return {};
|
|
81
|
-
},
|
|
82
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { basePlacements } from '../enums';
|
|
2
|
-
import { detectOverflow } from '../detectOverflow';
|
|
3
|
-
function getSideOffsets(overflow, rect) {
|
|
4
|
-
return {
|
|
5
|
-
top: overflow.top - rect.height,
|
|
6
|
-
right: overflow.right - rect.width,
|
|
7
|
-
bottom: overflow.bottom - rect.height,
|
|
8
|
-
left: overflow.left - rect.width,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
function isAnySideFullyClipped(overflow) {
|
|
12
|
-
return basePlacements.some((side) => overflow[side] >= 0);
|
|
13
|
-
}
|
|
14
|
-
export const hide = () => ({
|
|
15
|
-
name: 'hide',
|
|
16
|
-
async fn(modifierArguments) {
|
|
17
|
-
const referenceOverflow = await detectOverflow(modifierArguments, {
|
|
18
|
-
elementContext: 'reference',
|
|
19
|
-
});
|
|
20
|
-
const floatingAltOverflow = await detectOverflow(modifierArguments, {
|
|
21
|
-
altBoundary: true,
|
|
22
|
-
});
|
|
23
|
-
const referenceHiddenOffsets = getSideOffsets(referenceOverflow, modifierArguments.rects.reference);
|
|
24
|
-
const escapedOffsets = getSideOffsets(floatingAltOverflow, modifierArguments.rects.floating);
|
|
25
|
-
const referenceHidden = isAnySideFullyClipped(referenceHiddenOffsets);
|
|
26
|
-
const escaped = isAnySideFullyClipped(escapedOffsets);
|
|
27
|
-
return {
|
|
28
|
-
data: {
|
|
29
|
-
referenceHidden,
|
|
30
|
-
referenceHiddenOffsets,
|
|
31
|
-
escaped,
|
|
32
|
-
escapedOffsets,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { getBasePlacement } from '../utils/getBasePlacement';
|
|
2
|
-
import { getMainAxisFromPlacement } from '../utils/getMainAxisFromPlacement';
|
|
3
|
-
import { getSideObjectFromPadding } from '../utils/getPaddingObject';
|
|
4
|
-
import { max, min } from '../utils/math';
|
|
5
|
-
import { rectToClientRect } from '../utils/rectToClientRect';
|
|
6
|
-
export const inline = (options = {}) => ({
|
|
7
|
-
name: 'inline',
|
|
8
|
-
options,
|
|
9
|
-
async fn(middlewareArguments) {
|
|
10
|
-
var _a, _b, _c;
|
|
11
|
-
const { placement, elements, rects, platform, strategy, middlewareData } = middlewareArguments;
|
|
12
|
-
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
13
|
-
// ClientRect's bounds, despite the event listener being triggered. A
|
|
14
|
-
// padding of 2 seems to handle this issue.
|
|
15
|
-
const { padding = 2, x, y } = options;
|
|
16
|
-
if ((_a = middlewareData.inline) === null || _a === void 0 ? void 0 : _a.skip) {
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
const fallback = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
20
|
-
rect: rects.reference,
|
|
21
|
-
offsetParent: await platform.getOffsetParent({
|
|
22
|
-
element: elements.floating,
|
|
23
|
-
}),
|
|
24
|
-
strategy,
|
|
25
|
-
}));
|
|
26
|
-
const clientRects = Array.from((_c = (await ((_b = platform.getClientRects) === null || _b === void 0 ? void 0 : _b.call(platform, { element: elements.reference })))) !== null && _c !== void 0 ? _c : []);
|
|
27
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
28
|
-
function getBoundingClientRect() {
|
|
29
|
-
var _a;
|
|
30
|
-
// There are two rects and they are disjoined
|
|
31
|
-
if (clientRects.length === 2 &&
|
|
32
|
-
clientRects[0].left > clientRects[1].right &&
|
|
33
|
-
x != null &&
|
|
34
|
-
y != null) {
|
|
35
|
-
// Find the first rect in which the point is fully inside
|
|
36
|
-
return ((_a = clientRects.find((rect) => x > rect.left - paddingObject.left &&
|
|
37
|
-
x < rect.right + paddingObject.right &&
|
|
38
|
-
y > rect.top - paddingObject.top &&
|
|
39
|
-
y < rect.bottom + paddingObject.bottom)) !== null && _a !== void 0 ? _a : fallback);
|
|
40
|
-
}
|
|
41
|
-
// There are 2 or more connected rects
|
|
42
|
-
if (clientRects.length >= 2) {
|
|
43
|
-
if (getMainAxisFromPlacement(placement) === 'x') {
|
|
44
|
-
const firstRect = clientRects[0];
|
|
45
|
-
const lastRect = clientRects[clientRects.length - 1];
|
|
46
|
-
const isTop = getBasePlacement(placement) === 'top';
|
|
47
|
-
const top = firstRect.top;
|
|
48
|
-
const bottom = lastRect.bottom;
|
|
49
|
-
const left = isTop ? firstRect.left : lastRect.left;
|
|
50
|
-
const right = isTop ? firstRect.right : lastRect.right;
|
|
51
|
-
const width = right - left;
|
|
52
|
-
const height = bottom - top;
|
|
53
|
-
return {
|
|
54
|
-
top,
|
|
55
|
-
bottom,
|
|
56
|
-
left,
|
|
57
|
-
right,
|
|
58
|
-
width,
|
|
59
|
-
height,
|
|
60
|
-
x: left,
|
|
61
|
-
y: top,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const isLeftPlacement = getBasePlacement(placement) === 'left';
|
|
65
|
-
const maxRight = max(...clientRects.map((rect) => rect.right));
|
|
66
|
-
const minLeft = min(...clientRects.map((rect) => rect.left));
|
|
67
|
-
const measureRects = clientRects.filter((rect) => isLeftPlacement ? rect.left === minLeft : rect.right === maxRight);
|
|
68
|
-
const top = measureRects[0].top;
|
|
69
|
-
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
70
|
-
const left = minLeft;
|
|
71
|
-
const right = maxRight;
|
|
72
|
-
const width = right - left;
|
|
73
|
-
const height = bottom - top;
|
|
74
|
-
return {
|
|
75
|
-
top,
|
|
76
|
-
bottom,
|
|
77
|
-
left,
|
|
78
|
-
right,
|
|
79
|
-
width,
|
|
80
|
-
height,
|
|
81
|
-
x: left,
|
|
82
|
-
y: top,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return fallback;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
data: {
|
|
89
|
-
skip: true,
|
|
90
|
-
},
|
|
91
|
-
reset: {
|
|
92
|
-
rects: await platform.getElementRects({
|
|
93
|
-
reference: { getBoundingClientRect },
|
|
94
|
-
floating: elements.floating,
|
|
95
|
-
strategy,
|
|
96
|
-
}),
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
},
|
|
100
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getBasePlacement } from '../utils/getBasePlacement';
|
|
2
|
-
import { getMainAxisFromPlacement } from '../utils/getMainAxisFromPlacement';
|
|
3
|
-
export function convertValueToCoords({ placement, rects, value, }) {
|
|
4
|
-
const basePlacement = getBasePlacement(placement);
|
|
5
|
-
const multiplier = ['left', 'top'].includes(basePlacement) ? -1 : 1;
|
|
6
|
-
const rawValue = typeof value === 'function' ? value({ ...rects, placement }) : value;
|
|
7
|
-
const { mainAxis, crossAxis } = typeof rawValue === 'number'
|
|
8
|
-
? { mainAxis: rawValue, crossAxis: 0 }
|
|
9
|
-
: { mainAxis: 0, crossAxis: 0, ...rawValue };
|
|
10
|
-
return getMainAxisFromPlacement(basePlacement) === 'x'
|
|
11
|
-
? { x: crossAxis, y: mainAxis * multiplier }
|
|
12
|
-
: { x: mainAxis * multiplier, y: crossAxis };
|
|
13
|
-
}
|
|
14
|
-
export const offset = (value = 0) => ({
|
|
15
|
-
name: 'offset',
|
|
16
|
-
options: value,
|
|
17
|
-
fn(middlewareArguments) {
|
|
18
|
-
const { x, y, placement, rects } = middlewareArguments;
|
|
19
|
-
const diffCoords = convertValueToCoords({ placement, rects, value });
|
|
20
|
-
return {
|
|
21
|
-
x: x + diffCoords.x,
|
|
22
|
-
y: y + diffCoords.y,
|
|
23
|
-
data: diffCoords,
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { getBasePlacement } from '../utils/getBasePlacement';
|
|
2
|
-
import { getMainAxisFromPlacement } from '../utils/getMainAxisFromPlacement';
|
|
3
|
-
import { getCrossAxis } from '../utils/getCrossAxis';
|
|
4
|
-
import { within } from '../utils/within';
|
|
5
|
-
import { detectOverflow, } from '../detectOverflow';
|
|
6
|
-
export const shift = (options = {}) => ({
|
|
7
|
-
name: 'shift',
|
|
8
|
-
options,
|
|
9
|
-
async fn(middlewareArguments) {
|
|
10
|
-
const { x, y, placement } = middlewareArguments;
|
|
11
|
-
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter = { fn: ({ x, y }) => ({ x, y }) }, ...detectOverflowOptions } = options;
|
|
12
|
-
const coords = { x, y };
|
|
13
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
14
|
-
const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));
|
|
15
|
-
const crossAxis = getCrossAxis(mainAxis);
|
|
16
|
-
let mainAxisCoord = coords[mainAxis];
|
|
17
|
-
let crossAxisCoord = coords[crossAxis];
|
|
18
|
-
if (checkMainAxis) {
|
|
19
|
-
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
20
|
-
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
21
|
-
const min = mainAxisCoord + overflow[minSide];
|
|
22
|
-
const max = mainAxisCoord - overflow[maxSide];
|
|
23
|
-
mainAxisCoord = within(min, mainAxisCoord, max);
|
|
24
|
-
}
|
|
25
|
-
if (checkCrossAxis) {
|
|
26
|
-
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
27
|
-
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
28
|
-
const min = crossAxisCoord + overflow[minSide];
|
|
29
|
-
const max = crossAxisCoord - overflow[maxSide];
|
|
30
|
-
crossAxisCoord = within(min, crossAxisCoord, max);
|
|
31
|
-
}
|
|
32
|
-
const limitedCoords = limiter.fn({
|
|
33
|
-
...middlewareArguments,
|
|
34
|
-
[mainAxis]: mainAxisCoord,
|
|
35
|
-
[crossAxis]: crossAxisCoord,
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
...limitedCoords,
|
|
39
|
-
data: {
|
|
40
|
-
x: limitedCoords.x - x,
|
|
41
|
-
y: limitedCoords.y - y,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
export const limitShift = (options = {}) => ({
|
|
47
|
-
options,
|
|
48
|
-
fn(middlewareArguments) {
|
|
49
|
-
var _a, _b, _c, _d;
|
|
50
|
-
const { x, y, placement, rects, middlewareData } = middlewareArguments;
|
|
51
|
-
const { offset = 0, mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, } = options;
|
|
52
|
-
const coords = { x, y };
|
|
53
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
54
|
-
const crossAxis = getCrossAxis(mainAxis);
|
|
55
|
-
let mainAxisCoord = coords[mainAxis];
|
|
56
|
-
let crossAxisCoord = coords[crossAxis];
|
|
57
|
-
const rawOffset = typeof offset === 'function' ? offset({ ...rects, placement }) : offset;
|
|
58
|
-
const computedOffset = typeof rawOffset === 'number'
|
|
59
|
-
? { mainAxis: rawOffset, crossAxis: 0 }
|
|
60
|
-
: { mainAxis: 0, crossAxis: 0, ...rawOffset };
|
|
61
|
-
if (checkMainAxis) {
|
|
62
|
-
const len = mainAxis === 'y' ? 'height' : 'width';
|
|
63
|
-
const limitMin = rects.reference[mainAxis] -
|
|
64
|
-
rects.floating[len] +
|
|
65
|
-
computedOffset.mainAxis;
|
|
66
|
-
const limitMax = rects.reference[mainAxis] +
|
|
67
|
-
rects.reference[len] -
|
|
68
|
-
computedOffset.mainAxis;
|
|
69
|
-
if (mainAxisCoord < limitMin) {
|
|
70
|
-
mainAxisCoord = limitMin;
|
|
71
|
-
}
|
|
72
|
-
else if (mainAxisCoord > limitMax) {
|
|
73
|
-
mainAxisCoord = limitMax;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (checkCrossAxis) {
|
|
77
|
-
const len = mainAxis === 'y' ? 'width' : 'height';
|
|
78
|
-
const isOriginSide = ['top', 'left'].includes(getBasePlacement(placement));
|
|
79
|
-
const limitMin = rects.reference[crossAxis] -
|
|
80
|
-
rects.floating[len] -
|
|
81
|
-
((_b = (_a = middlewareData.offset) === null || _a === void 0 ? void 0 : _a[mainAxis]) !== null && _b !== void 0 ? _b : 0) +
|
|
82
|
-
(isOriginSide ? 0 : computedOffset.crossAxis);
|
|
83
|
-
const limitMax = rects.reference[crossAxis] +
|
|
84
|
-
rects.reference[len] +
|
|
85
|
-
((_d = (_c = middlewareData.offset) === null || _c === void 0 ? void 0 : _c[mainAxis]) !== null && _d !== void 0 ? _d : 0) -
|
|
86
|
-
(isOriginSide ? computedOffset.crossAxis : 0);
|
|
87
|
-
if (crossAxisCoord < limitMin) {
|
|
88
|
-
crossAxisCoord = limitMin;
|
|
89
|
-
}
|
|
90
|
-
else if (crossAxisCoord > limitMax) {
|
|
91
|
-
crossAxisCoord = limitMax;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
[mainAxis]: mainAxisCoord,
|
|
96
|
-
[crossAxis]: crossAxisCoord,
|
|
97
|
-
};
|
|
98
|
-
},
|
|
99
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { detectOverflow, } from '../detectOverflow';
|
|
2
|
-
import { getBasePlacement } from '../utils/getBasePlacement';
|
|
3
|
-
import { getAlignment } from '../utils/getAlignment';
|
|
4
|
-
import { max } from '../utils/math';
|
|
5
|
-
export const size = (options = {}) => ({
|
|
6
|
-
name: 'size',
|
|
7
|
-
options,
|
|
8
|
-
async fn(middlewareArguments) {
|
|
9
|
-
var _a;
|
|
10
|
-
const { placement, rects, middlewareData } = middlewareArguments;
|
|
11
|
-
const { apply, ...detectOverflowOptions } = options;
|
|
12
|
-
if ((_a = middlewareData.size) === null || _a === void 0 ? void 0 : _a.skip) {
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
16
|
-
const basePlacement = getBasePlacement(placement);
|
|
17
|
-
const isEnd = getAlignment(placement) === 'end';
|
|
18
|
-
let heightSide;
|
|
19
|
-
let widthSide;
|
|
20
|
-
if (basePlacement === 'top' || basePlacement === 'bottom') {
|
|
21
|
-
heightSide = basePlacement;
|
|
22
|
-
widthSide = isEnd ? 'left' : 'right';
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
widthSide = basePlacement;
|
|
26
|
-
heightSide = isEnd ? 'top' : 'bottom';
|
|
27
|
-
}
|
|
28
|
-
const xMin = max(overflow.left, 0);
|
|
29
|
-
const xMax = max(overflow.right, 0);
|
|
30
|
-
const yMin = max(overflow.top, 0);
|
|
31
|
-
const yMax = max(overflow.bottom, 0);
|
|
32
|
-
const dimensions = {
|
|
33
|
-
height: rects.floating.height -
|
|
34
|
-
(['left', 'right'].includes(placement)
|
|
35
|
-
? 2 *
|
|
36
|
-
(yMin !== 0 || yMax !== 0
|
|
37
|
-
? yMin + yMax
|
|
38
|
-
: max(overflow.top, overflow.bottom))
|
|
39
|
-
: overflow[heightSide]),
|
|
40
|
-
width: rects.floating.width -
|
|
41
|
-
(['top', 'bottom'].includes(placement)
|
|
42
|
-
? 2 *
|
|
43
|
-
(xMin !== 0 || xMax !== 0
|
|
44
|
-
? xMin + xMax
|
|
45
|
-
: max(overflow.left, overflow.right))
|
|
46
|
-
: overflow[widthSide]),
|
|
47
|
-
};
|
|
48
|
-
apply === null || apply === void 0 ? void 0 : apply({ ...dimensions, ...rects });
|
|
49
|
-
return {
|
|
50
|
-
data: {
|
|
51
|
-
skip: true,
|
|
52
|
-
},
|
|
53
|
-
reset: {
|
|
54
|
-
rects: true,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { computePosition } from './computePosition';
|
|
2
|
-
export { rectToClientRect } from './utils/rectToClientRect';
|
|
3
|
-
export { detectOverflow } from './detectOverflow';
|
|
4
|
-
export { arrow } from './middleware/arrow';
|
|
5
|
-
export { autoPlacement } from './middleware/autoPlacement';
|
|
6
|
-
export { flip } from './middleware/flip';
|
|
7
|
-
export { hide } from './middleware/hide';
|
|
8
|
-
export { offset } from './middleware/offset';
|
|
9
|
-
export { shift, limitShift } from './middleware/shift';
|
|
10
|
-
export { size } from './middleware/size';
|
|
11
|
-
export { inline } from './middleware/inline';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { getLengthFromAxis } from './getLengthFromAxis';
|
|
2
|
-
import { getMainAxisFromPlacement } from './getMainAxisFromPlacement';
|
|
3
|
-
import { getOppositePlacement } from './getOppositePlacement';
|
|
4
|
-
import { getAlignment } from './getAlignment';
|
|
5
|
-
export function getAlignmentSides(placement, rects) {
|
|
6
|
-
const isStart = getAlignment(placement) === 'start';
|
|
7
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
8
|
-
const length = getLengthFromAxis(mainAxis);
|
|
9
|
-
let mainAlignmentSide = mainAxis === 'x'
|
|
10
|
-
? isStart
|
|
11
|
-
? 'right'
|
|
12
|
-
: 'left'
|
|
13
|
-
: isStart
|
|
14
|
-
? 'bottom'
|
|
15
|
-
: 'top';
|
|
16
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
17
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
main: mainAlignmentSide,
|
|
21
|
-
cross: getOppositePlacement(mainAlignmentSide),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getOppositePlacement } from './getOppositePlacement';
|
|
2
|
-
import { getOppositeAlignmentPlacement } from './getOppositeAlignmentPlacement';
|
|
3
|
-
export function getExpandedPlacements(placement) {
|
|
4
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
5
|
-
return [
|
|
6
|
-
getOppositeAlignmentPlacement(placement),
|
|
7
|
-
oppositePlacement,
|
|
8
|
-
getOppositeAlignmentPlacement(oppositePlacement),
|
|
9
|
-
];
|
|
10
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { computePosition as computePositionCore, } from '../core/index';
|
|
2
|
-
import { platform } from './platform';
|
|
3
|
-
export const computePosition = (reference, floating, options) => computePositionCore(reference, floating, { platform, ...options });
|
|
4
|
-
export { arrow, autoPlacement, flip, hide, offset, shift, limitShift, size, inline, detectOverflow, } from '../core/index';
|
|
5
|
-
export { getScrollParents } from './utils/getScrollParents';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { getRectRelativeToOffsetParent } from './utils/getRectRelativeToOffsetParent';
|
|
2
|
-
import { getOffsetParent } from './utils/getOffsetParent';
|
|
3
|
-
import { getDimensions } from './utils/getDimensions';
|
|
4
|
-
import { convertOffsetParentRelativeRectToViewportRelativeRect } from './utils/convertOffsetParentRelativeRectToViewportRelativeRect';
|
|
5
|
-
import { isElement } from './utils/is';
|
|
6
|
-
import { getDocumentElement } from './utils/getDocumentElement';
|
|
7
|
-
import { getClippingClientRect } from './utils/getClippingClientRect';
|
|
8
|
-
export const platform = {
|
|
9
|
-
getElementRects: ({ reference, floating, strategy }) => ({
|
|
10
|
-
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
|
11
|
-
floating: { ...getDimensions(floating), x: 0, y: 0 },
|
|
12
|
-
}),
|
|
13
|
-
convertOffsetParentRelativeRectToViewportRelativeRect: (args) => convertOffsetParentRelativeRectToViewportRelativeRect(args),
|
|
14
|
-
getOffsetParent: ({ element }) => getOffsetParent(element),
|
|
15
|
-
isElement: (value) => isElement(value),
|
|
16
|
-
getDocumentElement: ({ element }) => getDocumentElement(element),
|
|
17
|
-
getClippingClientRect: (args) => getClippingClientRect(args),
|
|
18
|
-
getDimensions: ({ element }) => getDimensions(element),
|
|
19
|
-
getClientRects: ({ element }) => element.getClientRects(),
|
|
20
|
-
};
|