@primer/behaviors 0.0.0-20230928160337 → 0.0.0-20231017184313
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/dist/cjs/anchored-position.js +19 -11
- package/dist/esm/anchored-position.js +19 -11
- package/package.json +1 -1
|
@@ -37,25 +37,30 @@ function getPositionedParent(element) {
|
|
|
37
37
|
}
|
|
38
38
|
return document.body;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function isModalDialog(element) {
|
|
41
|
+
return element.matches('dialog:modal');
|
|
42
|
+
}
|
|
43
|
+
function isFullscreen(element) {
|
|
44
|
+
return element.matches(':fullscreen');
|
|
45
|
+
}
|
|
46
|
+
function isPopover(element) {
|
|
41
47
|
var _a;
|
|
42
|
-
if (element.tagName === 'DIALOG') {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
48
|
try {
|
|
46
|
-
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
+
return (element.matches(':popover-open') && /native code/.test((_a = document.body.showPopover) === null || _a === void 0 ? void 0 : _a.toString()));
|
|
49
50
|
}
|
|
50
51
|
catch (_b) {
|
|
51
52
|
return false;
|
|
52
53
|
}
|
|
53
|
-
return false;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function isOnTopLayer(element) {
|
|
56
|
+
return isModalDialog(element) || isFullscreen(element) || isPopover(element);
|
|
57
|
+
}
|
|
58
|
+
function getClippingParent(element) {
|
|
59
|
+
if (element === document.body)
|
|
60
|
+
return element;
|
|
56
61
|
let parentNode = element;
|
|
57
62
|
while (parentNode !== null) {
|
|
58
|
-
if (parentNode
|
|
63
|
+
if (!(parentNode instanceof Element)) {
|
|
59
64
|
break;
|
|
60
65
|
}
|
|
61
66
|
const parentNodeStyle = getComputedStyle(parentNode);
|
|
@@ -64,7 +69,10 @@ function getClippingRect(element) {
|
|
|
64
69
|
}
|
|
65
70
|
parentNode = parentNode.parentNode;
|
|
66
71
|
}
|
|
67
|
-
|
|
72
|
+
return parentNode === document.body || !(parentNode instanceof HTMLElement) ? document.body : parentNode;
|
|
73
|
+
}
|
|
74
|
+
function getClippingRect(element) {
|
|
75
|
+
const clippingNode = getClippingParent(element);
|
|
68
76
|
const elemRect = clippingNode.getBoundingClientRect();
|
|
69
77
|
const elemStyle = getComputedStyle(clippingNode);
|
|
70
78
|
const [borderTop, borderLeft, borderRight, borderBottom] = [
|
|
@@ -33,25 +33,30 @@ function getPositionedParent(element) {
|
|
|
33
33
|
}
|
|
34
34
|
return document.body;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function isModalDialog(element) {
|
|
37
|
+
return element.matches('dialog:modal');
|
|
38
|
+
}
|
|
39
|
+
function isFullscreen(element) {
|
|
40
|
+
return element.matches(':fullscreen');
|
|
41
|
+
}
|
|
42
|
+
function isPopover(element) {
|
|
37
43
|
var _a;
|
|
38
|
-
if (element.tagName === 'DIALOG') {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
44
|
try {
|
|
42
|
-
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
+
return (element.matches(':popover-open') && /native code/.test((_a = document.body.showPopover) === null || _a === void 0 ? void 0 : _a.toString()));
|
|
45
46
|
}
|
|
46
47
|
catch (_b) {
|
|
47
48
|
return false;
|
|
48
49
|
}
|
|
49
|
-
return false;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function isOnTopLayer(element) {
|
|
52
|
+
return isModalDialog(element) || isFullscreen(element) || isPopover(element);
|
|
53
|
+
}
|
|
54
|
+
function getClippingParent(element) {
|
|
55
|
+
if (element === document.body)
|
|
56
|
+
return element;
|
|
52
57
|
let parentNode = element;
|
|
53
58
|
while (parentNode !== null) {
|
|
54
|
-
if (parentNode
|
|
59
|
+
if (!(parentNode instanceof Element)) {
|
|
55
60
|
break;
|
|
56
61
|
}
|
|
57
62
|
const parentNodeStyle = getComputedStyle(parentNode);
|
|
@@ -60,7 +65,10 @@ function getClippingRect(element) {
|
|
|
60
65
|
}
|
|
61
66
|
parentNode = parentNode.parentNode;
|
|
62
67
|
}
|
|
63
|
-
|
|
68
|
+
return parentNode === document.body || !(parentNode instanceof HTMLElement) ? document.body : parentNode;
|
|
69
|
+
}
|
|
70
|
+
function getClippingRect(element) {
|
|
71
|
+
const clippingNode = getClippingParent(element);
|
|
64
72
|
const elemRect = clippingNode.getBoundingClientRect();
|
|
65
73
|
const elemStyle = getComputedStyle(clippingNode);
|
|
66
74
|
const [borderTop, borderLeft, borderRight, borderBottom] = [
|