cbvirtua 1.0.4 → 1.0.6
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/package.json +1 -1
- package/v2/App.vue +56 -0
- package/v2/components/Dropdown.vue +28 -0
- package/v2/components/Menu.vue +9 -0
- package/v2/components/Popper.js +1011 -0
- package/v2/components/PopperContent.vue +270 -0
- package/v2/components/PopperMethods.js +17 -0
- package/v2/components/PopperWrapper.vue +101 -0
- package/v2/components/ResizeObserver.vue +151 -0
- package/v2/components/ThemeClass.js +9 -0
- package/v2/components/Tooltip.vue +22 -0
- package/v2/components/TooltipDirective.vue +171 -0
- package/v2/config.js +133 -0
- package/v2/directives/v-close-popper.js +67 -0
- package/v2/directives/v-tooltip.js +116 -0
- package/v2/floating-ui/core/computeCoordsFromPlacement.js +39 -0
- package/v2/floating-ui/core/computePosition.js +52 -0
- package/v2/floating-ui/core/detectOverflow.js +36 -0
- package/v2/floating-ui/core/enums.js +7 -0
- package/v2/floating-ui/core/index.js +11 -0
- package/v2/floating-ui/core/middleware/arrow.js +52 -0
- package/v2/floating-ui/core/middleware/autoPlacement.js +84 -0
- package/v2/floating-ui/core/middleware/flip.js +82 -0
- package/v2/floating-ui/core/middleware/hide.js +36 -0
- package/v2/floating-ui/core/middleware/inline.js +100 -0
- package/v2/floating-ui/core/middleware/offset.js +26 -0
- package/v2/floating-ui/core/middleware/shift.js +99 -0
- package/v2/floating-ui/core/middleware/size.js +58 -0
- package/v2/floating-ui/core/types.js +11 -0
- package/v2/floating-ui/core/utils/expandPaddingObject.js +3 -0
- package/v2/floating-ui/core/utils/getAlignment.js +3 -0
- package/v2/floating-ui/core/utils/getAlignmentSides.js +23 -0
- package/v2/floating-ui/core/utils/getBasePlacement.js +3 -0
- package/v2/floating-ui/core/utils/getCrossAxis.js +3 -0
- package/v2/floating-ui/core/utils/getExpandedPlacements.js +10 -0
- package/v2/floating-ui/core/utils/getLengthFromAxis.js +3 -0
- package/v2/floating-ui/core/utils/getMainAxisFromPlacement.js +4 -0
- package/v2/floating-ui/core/utils/getOppositeAlignmentPlacement.js +4 -0
- package/v2/floating-ui/core/utils/getOppositePlacement.js +4 -0
- package/v2/floating-ui/core/utils/getPaddingObject.js +6 -0
- package/v2/floating-ui/core/utils/math.js +2 -0
- package/v2/floating-ui/core/utils/rectToClientRect.js +9 -0
- package/v2/floating-ui/core/utils/within.js +4 -0
- package/v2/floating-ui/dom/index.js +5 -0
- package/v2/floating-ui/dom/platform.js +20 -0
- package/v2/floating-ui/dom/utils/contains.js +22 -0
- package/v2/floating-ui/dom/utils/convertOffsetParentRelativeRectToViewportRelativeRect.js +35 -0
- package/v2/floating-ui/dom/utils/getBoundingClientRect.js +27 -0
- package/v2/floating-ui/dom/utils/getClippingClientRect.js +76 -0
- package/v2/floating-ui/dom/utils/getComputedStyle.js +4 -0
- package/v2/floating-ui/dom/utils/getDimensions.js +6 -0
- package/v2/floating-ui/dom/utils/getDocumentElement.js +4 -0
- package/v2/floating-ui/dom/utils/getDocumentRect.js +21 -0
- package/v2/floating-ui/dom/utils/getNodeName.js +4 -0
- package/v2/floating-ui/dom/utils/getNodeScroll.js +13 -0
- package/v2/floating-ui/dom/utils/getOffsetParent.js +43 -0
- package/v2/floating-ui/dom/utils/getParentNode.js +16 -0
- package/v2/floating-ui/dom/utils/getRectRelativeToOffsetParent.js +40 -0
- package/v2/floating-ui/dom/utils/getScrollParent.js +13 -0
- package/v2/floating-ui/dom/utils/getScrollParents.js +18 -0
- package/v2/floating-ui/dom/utils/getViewportRect.js +25 -0
- package/v2/floating-ui/dom/utils/getWindowScrollBarX.js +9 -0
- package/v2/floating-ui/dom/utils/is.js +38 -0
- package/v2/floating-ui/dom/utils/math.js +3 -0
- package/v2/floating-ui/dom/utils/window.js +13 -0
- package/v2/index.js +75 -0
- package/v2/util/assign-deep.js +12 -0
- package/v2/util/env.js +18 -0
- package/v2/util/events.js +12 -0
- package/v2/util/frame.js +5 -0
- package/v2/util/lang.js +6 -0
- package/v2/util/popper.js +5 -0
- package/vue2/VList.js +55 -55
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isShadowRoot } from './is';
|
|
2
|
+
export function contains(parent, child) {
|
|
3
|
+
var _a;
|
|
4
|
+
const rootNode = (_a = child.getRootNode) === null || _a === void 0 ? void 0 : _a.call(child);
|
|
5
|
+
// First, attempt with faster native method
|
|
6
|
+
if (parent.contains(child)) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
// then fallback to custom implementation with Shadow DOM support
|
|
10
|
+
else if (rootNode && isShadowRoot(rootNode)) {
|
|
11
|
+
let next = child;
|
|
12
|
+
do {
|
|
13
|
+
// use `===` replace node.isSameNode()
|
|
14
|
+
if (next && parent === next) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
// @ts-ignore: need a better way to handle this...
|
|
18
|
+
next = next.parentNode || next.host;
|
|
19
|
+
} while (next);
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getBoundingClientRect } from './getBoundingClientRect';
|
|
2
|
+
import { getNodeScroll } from './getNodeScroll';
|
|
3
|
+
import { getNodeName } from './getNodeName';
|
|
4
|
+
import { getDocumentElement } from './getDocumentElement';
|
|
5
|
+
import { isHTMLElement, isScrollParent } from './is';
|
|
6
|
+
export function convertOffsetParentRelativeRectToViewportRelativeRect({ rect, offsetParent, strategy, }) {
|
|
7
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
8
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
9
|
+
if (offsetParent === documentElement) {
|
|
10
|
+
return rect;
|
|
11
|
+
}
|
|
12
|
+
let scroll = { scrollLeft: 0, scrollTop: 0 };
|
|
13
|
+
const offsets = { x: 0, y: 0 };
|
|
14
|
+
if (isOffsetParentAnElement ||
|
|
15
|
+
(!isOffsetParentAnElement && strategy !== 'fixed')) {
|
|
16
|
+
if (getNodeName(offsetParent) !== 'body' ||
|
|
17
|
+
isScrollParent(documentElement)) {
|
|
18
|
+
scroll = getNodeScroll(offsetParent);
|
|
19
|
+
}
|
|
20
|
+
if (isHTMLElement(offsetParent)) {
|
|
21
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
22
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
23
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
24
|
+
}
|
|
25
|
+
// This doesn't appear to be need to be negated.
|
|
26
|
+
// else if (documentElement) {
|
|
27
|
+
// offsets.x = getWindowScrollBarX(documentElement);
|
|
28
|
+
// }
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
...rect,
|
|
32
|
+
x: rect.x - scroll.scrollLeft + offsets.x,
|
|
33
|
+
y: rect.y - scroll.scrollTop + offsets.y,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isHTMLElement } from './is';
|
|
2
|
+
import { round } from './math';
|
|
3
|
+
export function getBoundingClientRect(element, includeScale = false) {
|
|
4
|
+
const clientRect = element.getBoundingClientRect();
|
|
5
|
+
let scaleX = 1;
|
|
6
|
+
let scaleY = 1;
|
|
7
|
+
if (includeScale && isHTMLElement(element)) {
|
|
8
|
+
scaleX =
|
|
9
|
+
element.offsetWidth > 0
|
|
10
|
+
? round(clientRect.width) / element.offsetWidth || 1
|
|
11
|
+
: 1;
|
|
12
|
+
scaleY =
|
|
13
|
+
element.offsetHeight > 0
|
|
14
|
+
? round(clientRect.height) / element.offsetHeight || 1
|
|
15
|
+
: 1;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
width: clientRect.width / scaleX,
|
|
19
|
+
height: clientRect.height / scaleY,
|
|
20
|
+
top: clientRect.top / scaleY,
|
|
21
|
+
right: clientRect.right / scaleX,
|
|
22
|
+
bottom: clientRect.bottom / scaleY,
|
|
23
|
+
left: clientRect.left / scaleX,
|
|
24
|
+
x: clientRect.left / scaleX,
|
|
25
|
+
y: clientRect.top / scaleY,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { rectToClientRect, } from '../../core/';
|
|
2
|
+
import { getViewportRect } from './getViewportRect';
|
|
3
|
+
import { getDocumentRect } from './getDocumentRect';
|
|
4
|
+
import { getScrollParents } from './getScrollParents';
|
|
5
|
+
import { getOffsetParent } from './getOffsetParent';
|
|
6
|
+
import { getDocumentElement } from './getDocumentElement';
|
|
7
|
+
import { getComputedStyle } from './getComputedStyle';
|
|
8
|
+
import { isElement, isHTMLElement } from './is';
|
|
9
|
+
import { getBoundingClientRect } from './getBoundingClientRect';
|
|
10
|
+
import { getParentNode } from './getParentNode';
|
|
11
|
+
import { contains } from './contains';
|
|
12
|
+
import { getNodeName } from './getNodeName';
|
|
13
|
+
import { max, min } from './math';
|
|
14
|
+
function getInnerBoundingClientRect(element) {
|
|
15
|
+
const clientRect = getBoundingClientRect(element);
|
|
16
|
+
const top = clientRect.top + element.clientTop;
|
|
17
|
+
const left = clientRect.left + element.clientLeft;
|
|
18
|
+
return {
|
|
19
|
+
top,
|
|
20
|
+
left,
|
|
21
|
+
x: left,
|
|
22
|
+
y: top,
|
|
23
|
+
right: left + element.clientWidth,
|
|
24
|
+
bottom: top + element.clientHeight,
|
|
25
|
+
width: element.clientWidth,
|
|
26
|
+
height: element.clientHeight,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function getClientRectFromClippingParent(element, clippingParent) {
|
|
30
|
+
if (clippingParent === 'viewport') {
|
|
31
|
+
return rectToClientRect(getViewportRect(element));
|
|
32
|
+
}
|
|
33
|
+
if (isElement(clippingParent)) {
|
|
34
|
+
return getInnerBoundingClientRect(clippingParent);
|
|
35
|
+
}
|
|
36
|
+
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
37
|
+
}
|
|
38
|
+
// A "clipping parent" is an overflowable container with the characteristic of
|
|
39
|
+
// clipping (or hiding) overflowing elements with a position different from
|
|
40
|
+
// `initial`
|
|
41
|
+
function getClippingParents(element) {
|
|
42
|
+
const clippingParents = getScrollParents(getParentNode(element));
|
|
43
|
+
const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle(element).position);
|
|
44
|
+
const clipperElement = canEscapeClipping && isHTMLElement(element)
|
|
45
|
+
? getOffsetParent(element)
|
|
46
|
+
: element;
|
|
47
|
+
if (!isElement(clipperElement)) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
// @ts-ignore isElement check ensures we return Array<Element>
|
|
51
|
+
return clippingParents.filter((clippingParent) => isElement(clippingParent) &&
|
|
52
|
+
contains(clippingParent, clipperElement) &&
|
|
53
|
+
getNodeName(clippingParent) !== 'body');
|
|
54
|
+
}
|
|
55
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
56
|
+
// clipping parents
|
|
57
|
+
export function getClippingClientRect({ element, boundary, rootBoundary, }) {
|
|
58
|
+
const mainClippingParents = boundary === 'clippingParents'
|
|
59
|
+
? getClippingParents(element)
|
|
60
|
+
: [].concat(boundary);
|
|
61
|
+
const clippingParents = [...mainClippingParents, rootBoundary];
|
|
62
|
+
const firstClippingParent = clippingParents[0];
|
|
63
|
+
const clippingRect = clippingParents.reduce((accRect, clippingParent) => {
|
|
64
|
+
const rect = getClientRectFromClippingParent(element, clippingParent);
|
|
65
|
+
accRect.top = max(rect.top, accRect.top);
|
|
66
|
+
accRect.right = min(rect.right, accRect.right);
|
|
67
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
68
|
+
accRect.left = max(rect.left, accRect.left);
|
|
69
|
+
return accRect;
|
|
70
|
+
}, getClientRectFromClippingParent(element, firstClippingParent));
|
|
71
|
+
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
72
|
+
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
73
|
+
clippingRect.x = clippingRect.left;
|
|
74
|
+
clippingRect.y = clippingRect.top;
|
|
75
|
+
return clippingRect;
|
|
76
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getDocumentElement } from './getDocumentElement';
|
|
2
|
+
import { getComputedStyle } from './getComputedStyle';
|
|
3
|
+
import getWindowScrollBarX from './getWindowScrollBarX';
|
|
4
|
+
import { getNodeScroll } from './getNodeScroll';
|
|
5
|
+
import { max } from './math';
|
|
6
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
7
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
8
|
+
export function getDocumentRect(element) {
|
|
9
|
+
var _a;
|
|
10
|
+
const html = getDocumentElement(element);
|
|
11
|
+
const scroll = getNodeScroll(element);
|
|
12
|
+
const body = (_a = element.ownerDocument) === null || _a === void 0 ? void 0 : _a.body;
|
|
13
|
+
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
14
|
+
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
15
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
16
|
+
const y = -scroll.scrollTop;
|
|
17
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
|
18
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
19
|
+
}
|
|
20
|
+
return { width, height, x, y };
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isWindow } from './window';
|
|
2
|
+
export function getNodeScroll(element) {
|
|
3
|
+
if (isWindow(element)) {
|
|
4
|
+
return {
|
|
5
|
+
scrollLeft: element.pageXOffset,
|
|
6
|
+
scrollTop: element.pageYOffset,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
scrollLeft: element.scrollLeft,
|
|
11
|
+
scrollTop: element.scrollTop,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getNodeName } from './getNodeName';
|
|
2
|
+
import { getParentNode } from './getParentNode';
|
|
3
|
+
import { getWindow } from './window';
|
|
4
|
+
import { isContainingBlock, isHTMLElement, isTableElement } from './is';
|
|
5
|
+
function getTrueOffsetParent(element) {
|
|
6
|
+
if (!isHTMLElement(element) ||
|
|
7
|
+
getComputedStyle(element).position === 'fixed') {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return element.offsetParent;
|
|
11
|
+
}
|
|
12
|
+
function getContainingBlock(element) {
|
|
13
|
+
let currentNode = getParentNode(element);
|
|
14
|
+
while (isHTMLElement(currentNode) &&
|
|
15
|
+
!['html', 'body'].includes(getNodeName(currentNode))) {
|
|
16
|
+
if (isContainingBlock(currentNode)) {
|
|
17
|
+
return currentNode;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
currentNode = currentNode.parentNode;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
26
|
+
// such as table ancestors and cross browser bugs.
|
|
27
|
+
export function getOffsetParent(element) {
|
|
28
|
+
const window = getWindow(element);
|
|
29
|
+
let offsetParent = getTrueOffsetParent(element);
|
|
30
|
+
while (offsetParent &&
|
|
31
|
+
isTableElement(offsetParent) &&
|
|
32
|
+
getComputedStyle(offsetParent).position === 'static') {
|
|
33
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
34
|
+
}
|
|
35
|
+
if (offsetParent &&
|
|
36
|
+
(getNodeName(offsetParent) === 'html' ||
|
|
37
|
+
(getNodeName(offsetParent) === 'body' &&
|
|
38
|
+
getComputedStyle(offsetParent).position === 'static' &&
|
|
39
|
+
!isContainingBlock(offsetParent)))) {
|
|
40
|
+
return window;
|
|
41
|
+
}
|
|
42
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getNodeName } from './getNodeName';
|
|
2
|
+
import { getDocumentElement } from './getDocumentElement';
|
|
3
|
+
import { isShadowRoot } from './is';
|
|
4
|
+
export function getParentNode(node) {
|
|
5
|
+
if (getNodeName(node) === 'html') {
|
|
6
|
+
return node;
|
|
7
|
+
}
|
|
8
|
+
return (
|
|
9
|
+
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
12
|
+
node.parentNode || // DOM Element detected
|
|
13
|
+
(isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
|
|
14
|
+
getDocumentElement(node) // fallback
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getBoundingClientRect } from './getBoundingClientRect';
|
|
2
|
+
import { getDocumentElement } from './getDocumentElement';
|
|
3
|
+
import { getNodeName } from './getNodeName';
|
|
4
|
+
import { getNodeScroll } from './getNodeScroll';
|
|
5
|
+
import getWindowScrollBarX from './getWindowScrollBarX';
|
|
6
|
+
import { isHTMLElement, isScrollParent } from './is';
|
|
7
|
+
import { round } from './math';
|
|
8
|
+
function isScaled(element) {
|
|
9
|
+
const rect = getBoundingClientRect(element);
|
|
10
|
+
return (round(rect.width) !== element.offsetWidth ||
|
|
11
|
+
round(rect.height) !== element.offsetHeight);
|
|
12
|
+
}
|
|
13
|
+
export function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
14
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
15
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
16
|
+
const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent));
|
|
17
|
+
let scroll = { scrollLeft: 0, scrollTop: 0 };
|
|
18
|
+
const offsets = { x: 0, y: 0 };
|
|
19
|
+
if (isOffsetParentAnElement ||
|
|
20
|
+
(!isOffsetParentAnElement && strategy !== 'fixed')) {
|
|
21
|
+
if (getNodeName(offsetParent) !== 'body' ||
|
|
22
|
+
isScrollParent(documentElement)) {
|
|
23
|
+
scroll = getNodeScroll(offsetParent);
|
|
24
|
+
}
|
|
25
|
+
if (isHTMLElement(offsetParent)) {
|
|
26
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
27
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
28
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
29
|
+
}
|
|
30
|
+
else if (documentElement) {
|
|
31
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
36
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
37
|
+
width: rect.width,
|
|
38
|
+
height: rect.height,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getParentNode } from './getParentNode';
|
|
2
|
+
import { getNodeName } from './getNodeName';
|
|
3
|
+
import { isScrollParent, isHTMLElement } from './is';
|
|
4
|
+
export function getScrollParent(node) {
|
|
5
|
+
if (['html', 'body', '#document'].includes(getNodeName(node))) {
|
|
6
|
+
// @ts-ignore assume body is always available
|
|
7
|
+
return node.ownerDocument.body;
|
|
8
|
+
}
|
|
9
|
+
if (isHTMLElement(node) && isScrollParent(node)) {
|
|
10
|
+
return node;
|
|
11
|
+
}
|
|
12
|
+
return getScrollParent(getParentNode(node));
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getScrollParent } from './getScrollParent';
|
|
2
|
+
import { getParentNode } from './getParentNode';
|
|
3
|
+
import { getWindow } from './window';
|
|
4
|
+
import { isScrollParent } from './is';
|
|
5
|
+
export function getScrollParents(node, list = []) {
|
|
6
|
+
var _a;
|
|
7
|
+
const scrollParent = getScrollParent(node);
|
|
8
|
+
const isBody = scrollParent === ((_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.body);
|
|
9
|
+
const win = getWindow(scrollParent);
|
|
10
|
+
const target = isBody
|
|
11
|
+
? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : [])
|
|
12
|
+
: scrollParent;
|
|
13
|
+
const updatedList = list.concat(target);
|
|
14
|
+
return isBody
|
|
15
|
+
? updatedList
|
|
16
|
+
: // @ts-ignore: isBody tells us target will be an HTMLElement here
|
|
17
|
+
updatedList.concat(getScrollParents(getParentNode(target)));
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getWindow } from './window';
|
|
2
|
+
import { getDocumentElement } from './getDocumentElement';
|
|
3
|
+
export function getViewportRect(element) {
|
|
4
|
+
const win = getWindow(element);
|
|
5
|
+
const html = getDocumentElement(element);
|
|
6
|
+
const visualViewport = win.visualViewport;
|
|
7
|
+
let width = html.clientWidth;
|
|
8
|
+
let height = html.clientHeight;
|
|
9
|
+
let x = 0;
|
|
10
|
+
let y = 0;
|
|
11
|
+
if (visualViewport) {
|
|
12
|
+
width = visualViewport.width;
|
|
13
|
+
height = visualViewport.height;
|
|
14
|
+
// Uses Layout Viewport (like Chrome; Safari does not currently)
|
|
15
|
+
// In Chrome, it returns a value very close to 0 (+/-) but contains rounding
|
|
16
|
+
// errors due to floating point numbers, so we need to check precision.
|
|
17
|
+
// Safari returns a number <= 0, usually < -1 when pinch-zoomed
|
|
18
|
+
if (Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
|
|
19
|
+
0.01) {
|
|
20
|
+
x = visualViewport.offsetLeft;
|
|
21
|
+
y = visualViewport.offsetTop;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { width, height, x, y };
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getBoundingClientRect } from './getBoundingClientRect';
|
|
2
|
+
import { getDocumentElement } from './getDocumentElement';
|
|
3
|
+
import { getNodeScroll } from './getNodeScroll';
|
|
4
|
+
export default function getWindowScrollBarX(element) {
|
|
5
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
6
|
+
// incorrect for RTL.
|
|
7
|
+
return (getBoundingClientRect(getDocumentElement(element)).left +
|
|
8
|
+
getNodeScroll(element).scrollLeft);
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getComputedStyle } from './getComputedStyle';
|
|
2
|
+
import { getNodeName } from './getNodeName';
|
|
3
|
+
import { getWindow } from './window';
|
|
4
|
+
export function isHTMLElement(value) {
|
|
5
|
+
return value instanceof getWindow(value).HTMLElement;
|
|
6
|
+
}
|
|
7
|
+
export function isElement(value) {
|
|
8
|
+
return value instanceof getWindow(value).Element;
|
|
9
|
+
}
|
|
10
|
+
export function isNode(value) {
|
|
11
|
+
return value instanceof getWindow(value).Node;
|
|
12
|
+
}
|
|
13
|
+
export function isShadowRoot(node) {
|
|
14
|
+
const OwnElement = getWindow(node).ShadowRoot;
|
|
15
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
16
|
+
}
|
|
17
|
+
export function isScrollParent(element) {
|
|
18
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
19
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(element);
|
|
20
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
21
|
+
}
|
|
22
|
+
export function isTableElement(element) {
|
|
23
|
+
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
24
|
+
}
|
|
25
|
+
export function isContainingBlock(element) {
|
|
26
|
+
// TODO: Try and use feature detection here instead
|
|
27
|
+
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
|
|
28
|
+
const css = getComputedStyle(element);
|
|
29
|
+
// This is non-exhaustive but covers the most common CSS properties that
|
|
30
|
+
// create a containing block.
|
|
31
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
32
|
+
return (css.transform !== 'none' ||
|
|
33
|
+
css.perspective !== 'none' ||
|
|
34
|
+
css.contain === 'paint' ||
|
|
35
|
+
['transform', 'perspective'].includes(css.willChange) ||
|
|
36
|
+
(isFirefox && css.willChange === 'filter') ||
|
|
37
|
+
(isFirefox && (css.filter ? css.filter !== 'none' : false)));
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function isWindow(value) {
|
|
2
|
+
return (value === null || value === void 0 ? void 0 : value.toString()) === '[object Window]';
|
|
3
|
+
}
|
|
4
|
+
export function getWindow(node) {
|
|
5
|
+
if (node == null) {
|
|
6
|
+
return window;
|
|
7
|
+
}
|
|
8
|
+
if (!isWindow(node)) {
|
|
9
|
+
const ownerDocument = node.ownerDocument;
|
|
10
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
11
|
+
}
|
|
12
|
+
return node;
|
|
13
|
+
}
|
package/v2/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assign } from './util/assign-deep';
|
|
2
|
+
import { config } from './config';
|
|
3
|
+
import 'vue-resize/dist/vue-resize.css';
|
|
4
|
+
// Components
|
|
5
|
+
import PrivateDropdown from './components/Dropdown.vue';
|
|
6
|
+
import PrivateMenu from './components/Menu.vue';
|
|
7
|
+
import PrivatePopper from './components/Popper';
|
|
8
|
+
import PrivatePopperContent from './components/PopperContent.vue';
|
|
9
|
+
import PrivatePopperMethods from './components/PopperMethods';
|
|
10
|
+
import PrivatePopperWrapper from './components/PopperWrapper.vue';
|
|
11
|
+
import PrivateThemeClass from './components/ThemeClass';
|
|
12
|
+
import PrivateTooltip from './components/Tooltip.vue';
|
|
13
|
+
import PrivateTooltipDirective from './components/TooltipDirective.vue';
|
|
14
|
+
// Directives
|
|
15
|
+
import PrivateVTooltip from './directives/v-tooltip';
|
|
16
|
+
import PrivateVClosePopper from './directives/v-close-popper';
|
|
17
|
+
/* Exports */
|
|
18
|
+
export const options = config;
|
|
19
|
+
// Directive
|
|
20
|
+
export const VTooltip = PrivateVTooltip;
|
|
21
|
+
export { createTooltip, destroyTooltip } from './directives/v-tooltip';
|
|
22
|
+
export const VClosePopper = PrivateVClosePopper;
|
|
23
|
+
console.log(PrivateVClosePopper)
|
|
24
|
+
// Components
|
|
25
|
+
export const Dropdown = PrivateDropdown;
|
|
26
|
+
export const Menu = PrivateMenu;
|
|
27
|
+
export const Popper = PrivatePopper;
|
|
28
|
+
export const PopperContent = PrivatePopperContent;
|
|
29
|
+
export const PopperMethods = PrivatePopperMethods;
|
|
30
|
+
export const PopperWrapper = PrivatePopperWrapper;
|
|
31
|
+
export const ThemeClass = PrivateThemeClass;
|
|
32
|
+
export const Tooltip = PrivateTooltip;
|
|
33
|
+
export const TooltipDirective = PrivateTooltipDirective;
|
|
34
|
+
// Utils
|
|
35
|
+
export { hideAllPoppers } from './components/Popper';
|
|
36
|
+
export * from './util/events';
|
|
37
|
+
export { placements } from './util/popper';
|
|
38
|
+
/* Vue plugin */
|
|
39
|
+
export function install(app, options = {}) {
|
|
40
|
+
if (app.$_vTooltipInstalled)
|
|
41
|
+
return;
|
|
42
|
+
app.$_vTooltipInstalled = true;
|
|
43
|
+
assign(config, options);
|
|
44
|
+
// Directive
|
|
45
|
+
app.directive('tooltip', PrivateVTooltip);
|
|
46
|
+
app.directive('close-popper', PrivateVClosePopper);
|
|
47
|
+
// Components
|
|
48
|
+
// eslint-disable-next-line vue/component-definition-name-casing
|
|
49
|
+
app.component('v-tooltip', PrivateTooltip);
|
|
50
|
+
app.component('VTooltip', PrivateTooltip);
|
|
51
|
+
// eslint-disable-next-line vue/component-definition-name-casing
|
|
52
|
+
app.component('v-dropdown', PrivateDropdown);
|
|
53
|
+
app.component('VDropdown', PrivateDropdown);
|
|
54
|
+
// eslint-disable-next-line vue/component-definition-name-casing
|
|
55
|
+
app.component('v-menu', PrivateMenu);
|
|
56
|
+
app.component('VMenu', PrivateMenu);
|
|
57
|
+
}
|
|
58
|
+
const plugin = {
|
|
59
|
+
// eslint-disable-next-line no-undef
|
|
60
|
+
//version: VERSION,
|
|
61
|
+
install,
|
|
62
|
+
options: config,
|
|
63
|
+
};
|
|
64
|
+
// Auto-install
|
|
65
|
+
let GlobalVue = null;
|
|
66
|
+
if (typeof window !== 'undefined') {
|
|
67
|
+
GlobalVue = window.Vue;
|
|
68
|
+
}
|
|
69
|
+
else if (typeof global !== 'undefined') {
|
|
70
|
+
GlobalVue = global.Vue;
|
|
71
|
+
}
|
|
72
|
+
if (GlobalVue) {
|
|
73
|
+
GlobalVue.use(plugin);
|
|
74
|
+
}
|
|
75
|
+
export default plugin;
|
package/v2/util/env.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export let supportsPassive = false;
|
|
2
|
+
if (typeof window !== 'undefined') {
|
|
3
|
+
supportsPassive = false;
|
|
4
|
+
try {
|
|
5
|
+
const opts = Object.defineProperty({}, 'passive', {
|
|
6
|
+
get() {
|
|
7
|
+
supportsPassive = true;
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
window.addEventListener('test', null, opts);
|
|
11
|
+
}
|
|
12
|
+
catch (e) { }
|
|
13
|
+
}
|
|
14
|
+
export let isIOS = false;
|
|
15
|
+
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
|
|
16
|
+
// @ts-expect-error MSStream is missing in window type
|
|
17
|
+
isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|
18
|
+
}
|
package/v2/util/frame.js
ADDED
package/v2/util/lang.js
ADDED