@brightspace-ui/core 3.251.0 → 3.252.1
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.
|
@@ -40,11 +40,16 @@ const pointerRotatedLength = Math.SQRT2 * parseFloat(pointerLength);
|
|
|
40
40
|
|
|
41
41
|
export const isPopoverSupported = ('popover' in HTMLElement.prototype);
|
|
42
42
|
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const SCROLLBAR_WIDTH = (() => {
|
|
44
|
+
const div = document.createElement('div');
|
|
45
|
+
div.style.overflow = 'scroll';
|
|
46
|
+
div.style.position = 'fixed';
|
|
47
|
+
div.style.top = '-99999px';
|
|
48
|
+
document.documentElement.appendChild(div);
|
|
49
|
+
const width = div.offsetWidth - div.clientWidth;
|
|
50
|
+
document.documentElement.removeChild(div);
|
|
51
|
+
return width && width + 1;
|
|
52
|
+
})(); // ~16 when present, but can be 0 even if invisible (e.g. macOS depending on settings)
|
|
48
53
|
|
|
49
54
|
export const PopoverMixin = superclass => class extends superclass {
|
|
50
55
|
|
|
@@ -482,6 +487,10 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
482
487
|
this._contentHeight = this._maxHeight !== null && availableHeight > this._maxHeight
|
|
483
488
|
? this._maxHeight - 2 : availableHeight;
|
|
484
489
|
|
|
490
|
+
if (height === (this._maxHeight ?? 0) || content.clientHeight >= availableHeight) {
|
|
491
|
+
this._width = this._width + SCROLLBAR_WIDTH;
|
|
492
|
+
}
|
|
493
|
+
|
|
485
494
|
// ensure the content height has updated when the __toggleScrollStyles event handler runs
|
|
486
495
|
await this.updateComplete;
|
|
487
496
|
}
|
|
@@ -493,7 +502,7 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
493
502
|
|
|
494
503
|
};
|
|
495
504
|
|
|
496
|
-
const scrollWidth = content.
|
|
505
|
+
const scrollWidth = Math.ceil(content.getBoundingClientRect().width);
|
|
497
506
|
const availableWidth = window.innerWidth - 40;
|
|
498
507
|
|
|
499
508
|
this._width = (availableWidth > scrollWidth ? scrollWidth : availableWidth);
|
|
@@ -823,7 +832,7 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
823
832
|
}
|
|
824
833
|
|
|
825
834
|
// if no width property set, automatically size to maximum width
|
|
826
|
-
let widthOverride = this._width
|
|
835
|
+
let widthOverride = this._width || maxWidthOverride;
|
|
827
836
|
// ensure width is between minWidth and maxWidth
|
|
828
837
|
if (widthOverride && maxWidthOverride && widthOverride > (maxWidthOverride - 20)) widthOverride = maxWidthOverride - 20;
|
|
829
838
|
if (widthOverride && minWidthOverride && widthOverride < (minWidthOverride - 20)) widthOverride = minWidthOverride - 20;
|
|
@@ -910,16 +919,16 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
910
919
|
}
|
|
911
920
|
} else {
|
|
912
921
|
if (this._preferredPosition.span === positionSpans.end) {
|
|
913
|
-
position.right = window.innerWidth - openerRect.right + xAdjustment -
|
|
922
|
+
position.right = window.innerWidth - openerRect.right + xAdjustment - SCROLLBAR_WIDTH;
|
|
914
923
|
} else {
|
|
915
|
-
position.left = (window.innerWidth - openerRect.left - xAdjustment -
|
|
924
|
+
position.left = (window.innerWidth - openerRect.left - xAdjustment - SCROLLBAR_WIDTH) * -1;
|
|
916
925
|
}
|
|
917
926
|
}
|
|
918
927
|
} else {
|
|
919
928
|
if (!this._rtl) {
|
|
920
929
|
position.left = openerRect.left + ((openerRect.width - pointerRect.width) / 2);
|
|
921
930
|
} else {
|
|
922
|
-
position.right = window.innerWidth - openerRect.left - ((openerRect.width + pointerRect.width) / 2) -
|
|
931
|
+
position.right = window.innerWidth - openerRect.left - ((openerRect.width + pointerRect.width) / 2) - SCROLLBAR_WIDTH;
|
|
923
932
|
}
|
|
924
933
|
}
|
|
925
934
|
|
|
@@ -937,13 +946,13 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
937
946
|
if (!this._rtl) {
|
|
938
947
|
position.right = (openerRect.left - this._offset + 7) * -1; // 7 minor adjustment to position pointer at edge of content
|
|
939
948
|
} else {
|
|
940
|
-
position.left = (window.innerWidth - openerRect.right + 7 - this._offset -
|
|
949
|
+
position.left = (window.innerWidth - openerRect.right + 7 - this._offset - SCROLLBAR_WIDTH) * -1; // 7 minor adjustment to position pointer at edge of content
|
|
941
950
|
}
|
|
942
951
|
} else {
|
|
943
952
|
if (!this._rtl) {
|
|
944
953
|
position.left = openerRect.left + openerRect.width + this._offset - 7; // 7 minor adjustment to position pointer at edge of content
|
|
945
954
|
} else {
|
|
946
|
-
position.right = window.innerWidth - openerRect.left - 7 + this._offset -
|
|
955
|
+
position.right = window.innerWidth - openerRect.left - 7 + this._offset - SCROLLBAR_WIDTH; // 7 minor adjustment to position pointer at edge of content
|
|
947
956
|
}
|
|
948
957
|
}
|
|
949
958
|
|
|
@@ -962,7 +971,7 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
962
971
|
if (!this._rtl) {
|
|
963
972
|
position.left = openerRect.left + xAdjustment;
|
|
964
973
|
} else {
|
|
965
|
-
position.right = window.innerWidth - openerRect.left - openerRect.width + xAdjustment -
|
|
974
|
+
position.right = window.innerWidth - openerRect.left - openerRect.width + xAdjustment - SCROLLBAR_WIDTH;
|
|
966
975
|
}
|
|
967
976
|
}
|
|
968
977
|
|
|
@@ -983,13 +992,13 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
983
992
|
if (!this._rtl) {
|
|
984
993
|
position.right = (openerRect.left - this._offset) * -1;
|
|
985
994
|
} else {
|
|
986
|
-
position.left = (window.innerWidth - openerRect.right - this._offset -
|
|
995
|
+
position.left = (window.innerWidth - openerRect.right - this._offset - SCROLLBAR_WIDTH) * -1;
|
|
987
996
|
}
|
|
988
997
|
} else {
|
|
989
998
|
if (!this._rtl) {
|
|
990
999
|
position.left = openerRect.left + openerRect.width + this._offset;
|
|
991
1000
|
} else {
|
|
992
|
-
position.right = window.innerWidth - openerRect.left + this._offset -
|
|
1001
|
+
position.right = window.innerWidth - openerRect.left + this._offset - SCROLLBAR_WIDTH;
|
|
993
1002
|
}
|
|
994
1003
|
}
|
|
995
1004
|
|
|
@@ -1082,7 +1091,7 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
1082
1091
|
const widthStyle = {
|
|
1083
1092
|
maxWidth: this._maxWidth ? `${this._maxWidth}px` : undefined,
|
|
1084
1093
|
minWidth: this._minWidth ? `${this._minWidth}px` : undefined,
|
|
1085
|
-
width: this._width ? `${this._width +
|
|
1094
|
+
width: this._width ? `${this._width + 2}px` : undefined
|
|
1086
1095
|
};
|
|
1087
1096
|
|
|
1088
1097
|
const contentStyle = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.252.1",
|
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|