@openui5/sap.ui.webc.main 1.117.1 → 1.119.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/THIRDPARTY.txt +2 -2
- package/package.json +3 -3
- package/src/sap/ui/webc/main/.library +1 -1
- package/src/sap/ui/webc/main/Avatar.js +4 -4
- package/src/sap/ui/webc/main/AvatarGroup.js +4 -4
- package/src/sap/ui/webc/main/Badge.js +4 -4
- package/src/sap/ui/webc/main/Breadcrumbs.js +4 -4
- package/src/sap/ui/webc/main/BreadcrumbsItem.js +4 -4
- package/src/sap/ui/webc/main/BusyIndicator.js +4 -4
- package/src/sap/ui/webc/main/Button.js +6 -6
- package/src/sap/ui/webc/main/Calendar.js +4 -4
- package/src/sap/ui/webc/main/CalendarDate.js +4 -4
- package/src/sap/ui/webc/main/Card.js +4 -4
- package/src/sap/ui/webc/main/CardHeader.js +4 -4
- package/src/sap/ui/webc/main/Carousel.js +4 -4
- package/src/sap/ui/webc/main/CheckBox.js +5 -5
- package/src/sap/ui/webc/main/ColorPalette.js +6 -6
- package/src/sap/ui/webc/main/ColorPaletteItem.js +4 -4
- package/src/sap/ui/webc/main/ColorPalettePopover.js +6 -6
- package/src/sap/ui/webc/main/ColorPicker.js +4 -4
- package/src/sap/ui/webc/main/ComboBox.js +5 -5
- package/src/sap/ui/webc/main/ComboBoxGroupItem.js +4 -4
- package/src/sap/ui/webc/main/ComboBoxItem.js +4 -4
- package/src/sap/ui/webc/main/CustomListItem.js +4 -4
- package/src/sap/ui/webc/main/DatePicker.js +5 -5
- package/src/sap/ui/webc/main/DateRangePicker.js +5 -5
- package/src/sap/ui/webc/main/DateTimePicker.js +5 -5
- package/src/sap/ui/webc/main/Dialog.js +4 -4
- package/src/sap/ui/webc/main/FileUploader.js +5 -5
- package/src/sap/ui/webc/main/GroupHeaderListItem.js +4 -4
- package/src/sap/ui/webc/main/Icon.js +4 -4
- package/src/sap/ui/webc/main/Input.js +7 -7
- package/src/sap/ui/webc/main/Label.js +4 -4
- package/src/sap/ui/webc/main/Link.js +5 -5
- package/src/sap/ui/webc/main/List.js +4 -4
- package/src/sap/ui/webc/main/Menu.js +4 -4
- package/src/sap/ui/webc/main/MenuItem.js +5 -5
- package/src/sap/ui/webc/main/MessageStrip.js +4 -4
- package/src/sap/ui/webc/main/MultiComboBox.js +5 -5
- package/src/sap/ui/webc/main/MultiComboBoxGroupItem.js +4 -4
- package/src/sap/ui/webc/main/MultiComboBoxItem.js +4 -4
- package/src/sap/ui/webc/main/MultiInput.js +7 -7
- package/src/sap/ui/webc/main/Option.js +5 -5
- package/src/sap/ui/webc/main/Panel.js +4 -4
- package/src/sap/ui/webc/main/Popover.js +4 -4
- package/src/sap/ui/webc/main/ProgressIndicator.js +5 -5
- package/src/sap/ui/webc/main/RadioButton.js +5 -5
- package/src/sap/ui/webc/main/RangeSlider.js +5 -5
- package/src/sap/ui/webc/main/RatingIndicator.js +5 -5
- package/src/sap/ui/webc/main/ResponsivePopover.js +4 -4
- package/src/sap/ui/webc/main/SegmentedButton.js +4 -4
- package/src/sap/ui/webc/main/SegmentedButtonItem.js +5 -5
- package/src/sap/ui/webc/main/Select.js +5 -5
- package/src/sap/ui/webc/main/Slider.js +5 -5
- package/src/sap/ui/webc/main/SplitButton.js +5 -5
- package/src/sap/ui/webc/main/StandardListItem.js +4 -4
- package/src/sap/ui/webc/main/StepInput.js +5 -5
- package/src/sap/ui/webc/main/SuggestionGroupItem.js +4 -4
- package/src/sap/ui/webc/main/SuggestionItem.js +4 -4
- package/src/sap/ui/webc/main/Switch.js +5 -5
- package/src/sap/ui/webc/main/Tab.js +5 -5
- package/src/sap/ui/webc/main/TabContainer.js +4 -4
- package/src/sap/ui/webc/main/TabSeparator.js +4 -4
- package/src/sap/ui/webc/main/Table.js +4 -4
- package/src/sap/ui/webc/main/TableCell.js +4 -4
- package/src/sap/ui/webc/main/TableColumn.js +4 -4
- package/src/sap/ui/webc/main/TableGroupRow.js +4 -4
- package/src/sap/ui/webc/main/TableRow.js +4 -4
- package/src/sap/ui/webc/main/TextArea.js +5 -5
- package/src/sap/ui/webc/main/TimePicker.js +5 -5
- package/src/sap/ui/webc/main/Title.js +4 -4
- package/src/sap/ui/webc/main/Toast.js +4 -4
- package/src/sap/ui/webc/main/ToggleButton.js +5 -5
- package/src/sap/ui/webc/main/Token.js +4 -4
- package/src/sap/ui/webc/main/Tree.js +4 -4
- package/src/sap/ui/webc/main/TreeItem.js +4 -4
- package/src/sap/ui/webc/main/TreeItemCustom.js +4 -4
- package/src/sap/ui/webc/main/changeHandler/ChangeLinkTarget.js +1 -1
- package/src/sap/ui/webc/main/library.js +2 -2
- package/src/sap/ui/webc/main/thirdparty/Popover.js +477 -582
- package/src/sap/ui/webc/main/thirdparty/popup-utils/PopoverRegistry.js +127 -135
- package/ui5.yaml +5 -0
@@ -1,591 +1,486 @@
|
|
1
|
-
sap.ui.define([
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
* It can also include actions in the footer.
|
41
|
-
*
|
42
|
-
* <h3>Structure</h3>
|
43
|
-
*
|
44
|
-
* The popover has three main areas:
|
45
|
-
* <ul>
|
46
|
-
* <li>Header (optional)</li>
|
47
|
-
* <li>Content</li>
|
48
|
-
* <li>Footer (optional)</li>
|
49
|
-
* </ul>
|
50
|
-
*
|
51
|
-
* <b>Note:</b> The <code>ui5-popover</code> is closed when the user clicks
|
52
|
-
* or taps outside the popover
|
53
|
-
* or selects an action within the popover. You can prevent this with the
|
54
|
-
* <code>modal</code> property.
|
55
|
-
*
|
56
|
-
* <h3>CSS Shadow Parts</h3>
|
57
|
-
*
|
58
|
-
* <ui5-link target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/::part">CSS Shadow Parts</ui5-link> allow developers to style elements inside the Shadow DOM.
|
59
|
-
* <br>
|
60
|
-
* The <code>ui5-popover</code> exposes the following CSS Shadow Parts:
|
61
|
-
* <ul>
|
62
|
-
* <li>header - Used to style the header of the component</li>
|
63
|
-
* <li>content - Used to style the content of the component</li>
|
64
|
-
* <li>footer - Used to style the footer of the component</li>
|
65
|
-
* </ul>
|
66
|
-
*
|
67
|
-
* <h3>ES6 Module Import</h3>
|
68
|
-
*
|
69
|
-
* <code>import "@ui5/webcomponents/dist/Popover.js";</code>
|
70
|
-
*
|
71
|
-
* @constructor
|
72
|
-
* @author SAP SE
|
73
|
-
* @alias sap.ui.webc.main.Popover
|
74
|
-
* @extends sap.ui.webc.main.Popup
|
75
|
-
* @tagname ui5-popover
|
76
|
-
* @since 1.0.0-rc.6
|
77
|
-
* @public
|
78
|
-
*/
|
79
|
-
let Popover = Popover_1 = class Popover extends _Popup.default {
|
80
|
-
static get VIEWPORT_MARGIN() {
|
81
|
-
return 10; // px
|
1
|
+
sap.ui.define([
|
2
|
+
'exports',
|
3
|
+
'sap/ui/webc/common/thirdparty/base/decorators/customElement',
|
4
|
+
'sap/ui/webc/common/thirdparty/base/decorators/property',
|
5
|
+
'sap/ui/webc/common/thirdparty/base/decorators/slot',
|
6
|
+
'sap/ui/webc/common/thirdparty/base/types/Integer',
|
7
|
+
'sap/ui/webc/common/thirdparty/base/Device',
|
8
|
+
'sap/ui/webc/common/thirdparty/base/types/DOMReference',
|
9
|
+
'sap/ui/webc/common/thirdparty/base/util/PopupUtils',
|
10
|
+
'sap/ui/webc/common/thirdparty/base/util/clamp',
|
11
|
+
'./Popup',
|
12
|
+
'./types/PopoverPlacementType',
|
13
|
+
'./types/PopoverVerticalAlign',
|
14
|
+
'./types/PopoverHorizontalAlign',
|
15
|
+
'./popup-utils/PopoverRegistry',
|
16
|
+
'./generated/templates/PopoverTemplate.lit',
|
17
|
+
'./generated/themes/BrowserScrollbar.css',
|
18
|
+
'./generated/themes/PopupsCommon.css',
|
19
|
+
'./generated/themes/Popover.css'
|
20
|
+
], function (_exports, _customElement, _property, _slot, _Integer, _Device, _DOMReference, _PopupUtils, _clamp, _Popup, _PopoverPlacementType, _PopoverVerticalAlign, _PopoverHorizontalAlign, _PopoverRegistry, _PopoverTemplate, _BrowserScrollbar, _PopupsCommon, _Popover) {
|
21
|
+
'use strict';
|
22
|
+
Object.defineProperty(_exports, '__esModule', { value: true });
|
23
|
+
_exports.instanceOfPopover = _exports.default = void 0;
|
24
|
+
_customElement = _interopRequireDefault(_customElement);
|
25
|
+
_property = _interopRequireDefault(_property);
|
26
|
+
_slot = _interopRequireDefault(_slot);
|
27
|
+
_Integer = _interopRequireDefault(_Integer);
|
28
|
+
_DOMReference = _interopRequireDefault(_DOMReference);
|
29
|
+
_clamp = _interopRequireDefault(_clamp);
|
30
|
+
_Popup = _interopRequireDefault(_Popup);
|
31
|
+
_PopoverPlacementType = _interopRequireDefault(_PopoverPlacementType);
|
32
|
+
_PopoverVerticalAlign = _interopRequireDefault(_PopoverVerticalAlign);
|
33
|
+
_PopoverHorizontalAlign = _interopRequireDefault(_PopoverHorizontalAlign);
|
34
|
+
_PopoverTemplate = _interopRequireDefault(_PopoverTemplate);
|
35
|
+
_BrowserScrollbar = _interopRequireDefault(_BrowserScrollbar);
|
36
|
+
_PopupsCommon = _interopRequireDefault(_PopupsCommon);
|
37
|
+
_Popover = _interopRequireDefault(_Popover);
|
38
|
+
function _interopRequireDefault(obj) {
|
39
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
82
40
|
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
41
|
+
var __decorate = void 0 && (void 0).__decorate || function (decorators, target, key, desc) {
|
42
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
43
|
+
if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')
|
44
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
45
|
+
else
|
46
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
47
|
+
if (d = decorators[i])
|
48
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
49
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
50
|
+
};
|
51
|
+
var Popover_1;
|
52
|
+
const ARROW_SIZE = 8;
|
53
|
+
let Popover = Popover_1 = class Popover extends _Popup.default {
|
54
|
+
static get VIEWPORT_MARGIN() {
|
55
|
+
return 10;
|
94
56
|
}
|
95
|
-
|
96
|
-
|
97
|
-
return;
|
57
|
+
constructor() {
|
58
|
+
super();
|
98
59
|
}
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Shows the popover.
|
117
|
-
* @param {HTMLElement} opener the element that the popover is shown at
|
118
|
-
* @param {boolean} [preventInitialFocus=false] prevents applying the focus inside the popover
|
119
|
-
* @public
|
120
|
-
* @async
|
121
|
-
* @method
|
122
|
-
* @name sap.ui.webc.main.Popover#showAt
|
123
|
-
* @async
|
124
|
-
* @returns {Promise} Resolved when the popover is open
|
125
|
-
*/
|
126
|
-
async showAt(opener, preventInitialFocus = false) {
|
127
|
-
if (!opener || this.opened) {
|
128
|
-
return;
|
129
|
-
}
|
130
|
-
this._opener = opener;
|
131
|
-
this._openerRect = opener.getBoundingClientRect();
|
132
|
-
await super._open(preventInitialFocus);
|
133
|
-
}
|
134
|
-
/**
|
135
|
-
* Override for the _addOpenedPopup hook, which would otherwise just call addOpenedPopup(this)
|
136
|
-
* @private
|
137
|
-
*/
|
138
|
-
_addOpenedPopup() {
|
139
|
-
(0, _PopoverRegistry.addOpenedPopover)(this);
|
140
|
-
}
|
141
|
-
/**
|
142
|
-
* Override for the _removeOpenedPopup hook, which would otherwise just call removeOpenedPopup(this)
|
143
|
-
* @private
|
144
|
-
*/
|
145
|
-
_removeOpenedPopup() {
|
146
|
-
(0, _PopoverRegistry.removeOpenedPopover)(this);
|
147
|
-
}
|
148
|
-
shouldCloseDueToOverflow(placement, openerRect) {
|
149
|
-
const threshold = 32;
|
150
|
-
const limits = {
|
151
|
-
"Right": openerRect.right,
|
152
|
-
"Left": openerRect.left,
|
153
|
-
"Top": openerRect.top,
|
154
|
-
"Bottom": openerRect.bottom
|
155
|
-
};
|
156
|
-
const closedPopupParent = (0, _PopupUtils.getClosedPopupParent)(this._opener);
|
157
|
-
let overflowsBottom = false;
|
158
|
-
let overflowsTop = false;
|
159
|
-
if (closedPopupParent.showAt) {
|
160
|
-
const contentRect = closedPopupParent.contentDOM.getBoundingClientRect();
|
161
|
-
overflowsBottom = openerRect.top > contentRect.top + contentRect.height;
|
162
|
-
overflowsTop = openerRect.top + openerRect.height < contentRect.top;
|
163
|
-
}
|
164
|
-
return limits[placement] < 0 || limits[placement] + threshold > closedPopupParent.innerHeight || overflowsBottom || overflowsTop;
|
165
|
-
}
|
166
|
-
shouldCloseDueToNoOpener(openerRect) {
|
167
|
-
return openerRect.top === 0 && openerRect.bottom === 0 && openerRect.left === 0 && openerRect.right === 0;
|
168
|
-
}
|
169
|
-
isOpenerOutsideViewport(openerRect) {
|
170
|
-
return openerRect.bottom < 0 || openerRect.top > window.innerHeight || openerRect.right < 0 || openerRect.left > window.innerWidth;
|
171
|
-
}
|
172
|
-
/**
|
173
|
-
* @override
|
174
|
-
*/
|
175
|
-
_resize() {
|
176
|
-
super._resize();
|
177
|
-
if (this.opened) {
|
178
|
-
this.reposition();
|
179
|
-
}
|
180
|
-
}
|
181
|
-
reposition() {
|
182
|
-
this._show();
|
183
|
-
}
|
184
|
-
_show() {
|
185
|
-
let placement;
|
186
|
-
const popoverSize = this.getPopoverSize();
|
187
|
-
if (popoverSize.width === 0 || popoverSize.height === 0) {
|
188
|
-
// size can not be determined properly at this point, popover will be shown with the next reposition
|
189
|
-
return;
|
190
|
-
}
|
191
|
-
if (this.isOpen()) {
|
192
|
-
// update opener rect if it was changed during the popover being opened
|
193
|
-
this._openerRect = this._opener.getBoundingClientRect();
|
194
|
-
}
|
195
|
-
if (this.shouldCloseDueToNoOpener(this._openerRect) && this.isFocusWithin()) {
|
196
|
-
// reuse the old placement as the opener is not available,
|
197
|
-
// but keep the popover open as the focus is within
|
198
|
-
placement = this._oldPlacement;
|
199
|
-
} else {
|
200
|
-
placement = this.calcPlacement(this._openerRect, popoverSize);
|
201
|
-
}
|
202
|
-
if (this._preventRepositionAndClose || this.isOpenerOutsideViewport(this._openerRect)) {
|
203
|
-
return this.close();
|
204
|
-
}
|
205
|
-
this._oldPlacement = placement;
|
206
|
-
this.actualPlacementType = placement.placementType;
|
207
|
-
let left = (0, _clamp.default)(this._left, Popover_1.VIEWPORT_MARGIN, document.documentElement.clientWidth - popoverSize.width - Popover_1.VIEWPORT_MARGIN);
|
208
|
-
if (this.actualPlacementType === _PopoverPlacementType.default.Right) {
|
209
|
-
left = Math.max(left, this._left);
|
210
|
-
}
|
211
|
-
let top = (0, _clamp.default)(this._top, Popover_1.VIEWPORT_MARGIN, document.documentElement.clientHeight - popoverSize.height - Popover_1.VIEWPORT_MARGIN);
|
212
|
-
if (this.actualPlacementType === _PopoverPlacementType.default.Bottom) {
|
213
|
-
top = Math.max(top, this._top);
|
214
|
-
}
|
215
|
-
this.arrowTranslateX = placement.arrow.x;
|
216
|
-
this.arrowTranslateY = placement.arrow.y;
|
217
|
-
top = this._adjustForIOSKeyboard(top);
|
218
|
-
Object.assign(this.style, {
|
219
|
-
top: `${top}px`,
|
220
|
-
left: `${left}px`
|
221
|
-
});
|
222
|
-
super._show();
|
223
|
-
if (this.horizontalAlign === _PopoverHorizontalAlign.default.Stretch && this._width) {
|
224
|
-
this.style.width = this._width;
|
225
|
-
}
|
226
|
-
}
|
227
|
-
/**
|
228
|
-
* Adjust the desired top position to compensate for shift of the screen
|
229
|
-
* caused by opened keyboard on iOS which affects all elements with position:fixed.
|
230
|
-
* @private
|
231
|
-
* @param {int} top The target top in px.
|
232
|
-
* @returns {int} The adjusted top in px.
|
233
|
-
*/
|
234
|
-
_adjustForIOSKeyboard(top) {
|
235
|
-
if (!(0, _Device.isIOS)()) {
|
236
|
-
return top;
|
237
|
-
}
|
238
|
-
const actualTop = Math.ceil(this.getBoundingClientRect().top);
|
239
|
-
return top + (Number.parseInt(this.style.top || "0") - actualTop);
|
240
|
-
}
|
241
|
-
getPopoverSize() {
|
242
|
-
if (!this.opened) {
|
243
|
-
Object.assign(this.style, {
|
244
|
-
display: "block",
|
245
|
-
top: "-10000px",
|
246
|
-
left: "-10000px"
|
247
|
-
});
|
248
|
-
}
|
249
|
-
const rect = this.getBoundingClientRect(),
|
250
|
-
width = rect.width,
|
251
|
-
height = rect.height;
|
252
|
-
return {
|
253
|
-
width,
|
254
|
-
height
|
255
|
-
};
|
256
|
-
}
|
257
|
-
get arrowDOM() {
|
258
|
-
return this.shadowRoot.querySelector(".ui5-popover-arrow");
|
259
|
-
}
|
260
|
-
/**
|
261
|
-
* @private
|
262
|
-
*/
|
263
|
-
calcPlacement(targetRect, popoverSize) {
|
264
|
-
let left = 0;
|
265
|
-
let top = 0;
|
266
|
-
const allowTargetOverlap = this.allowTargetOverlap;
|
267
|
-
const clientWidth = document.documentElement.clientWidth;
|
268
|
-
const clientHeight = document.documentElement.clientHeight;
|
269
|
-
let maxHeight = clientHeight;
|
270
|
-
let maxWidth = clientWidth;
|
271
|
-
const placementType = this.getActualPlacementType(targetRect, popoverSize);
|
272
|
-
this._preventRepositionAndClose = this.shouldCloseDueToNoOpener(targetRect) || this.shouldCloseDueToOverflow(placementType, targetRect);
|
273
|
-
const isVertical = placementType === _PopoverPlacementType.default.Top || placementType === _PopoverPlacementType.default.Bottom;
|
274
|
-
if (this.horizontalAlign === _PopoverHorizontalAlign.default.Stretch && isVertical) {
|
275
|
-
popoverSize.width = targetRect.width;
|
276
|
-
this._width = `${targetRect.width}px`;
|
277
|
-
} else if (this.verticalAlign === _PopoverVerticalAlign.default.Stretch && !isVertical) {
|
278
|
-
popoverSize.height = targetRect.height;
|
279
|
-
}
|
280
|
-
const arrowOffset = this.hideArrow ? 0 : ARROW_SIZE;
|
281
|
-
// calc popover positions
|
282
|
-
switch (placementType) {
|
283
|
-
case _PopoverPlacementType.default.Top:
|
284
|
-
left = this.getVerticalLeft(targetRect, popoverSize);
|
285
|
-
top = Math.max(targetRect.top - popoverSize.height - arrowOffset, 0);
|
286
|
-
if (!allowTargetOverlap) {
|
287
|
-
maxHeight = targetRect.top - arrowOffset;
|
288
|
-
}
|
289
|
-
break;
|
290
|
-
case _PopoverPlacementType.default.Bottom:
|
291
|
-
left = this.getVerticalLeft(targetRect, popoverSize);
|
292
|
-
top = targetRect.bottom + arrowOffset;
|
293
|
-
if (allowTargetOverlap) {
|
294
|
-
top = Math.max(Math.min(top, clientHeight - popoverSize.height), 0);
|
295
|
-
} else {
|
296
|
-
maxHeight = clientHeight - targetRect.bottom - arrowOffset;
|
297
|
-
}
|
298
|
-
break;
|
299
|
-
case _PopoverPlacementType.default.Left:
|
300
|
-
left = Math.max(targetRect.left - popoverSize.width - arrowOffset, 0);
|
301
|
-
top = this.getHorizontalTop(targetRect, popoverSize);
|
302
|
-
if (!allowTargetOverlap) {
|
303
|
-
maxWidth = targetRect.left - arrowOffset;
|
304
|
-
}
|
305
|
-
break;
|
306
|
-
case _PopoverPlacementType.default.Right:
|
307
|
-
left = targetRect.left + targetRect.width + arrowOffset;
|
308
|
-
top = this.getHorizontalTop(targetRect, popoverSize);
|
309
|
-
if (allowTargetOverlap) {
|
310
|
-
left = Math.max(Math.min(left, clientWidth - popoverSize.width), 0);
|
311
|
-
} else {
|
312
|
-
maxWidth = clientWidth - targetRect.right - arrowOffset;
|
313
|
-
}
|
314
|
-
break;
|
315
|
-
}
|
316
|
-
// correct popover positions
|
317
|
-
if (isVertical) {
|
318
|
-
if (popoverSize.width > clientWidth || left < 0) {
|
319
|
-
left = 0;
|
320
|
-
} else if (left + popoverSize.width > clientWidth) {
|
321
|
-
left -= left + popoverSize.width - clientWidth;
|
60
|
+
onAfterRendering() {
|
61
|
+
if (!this.isOpen() && this.open) {
|
62
|
+
let opener;
|
63
|
+
if (this.opener instanceof HTMLElement) {
|
64
|
+
opener = this.opener;
|
65
|
+
} else if (typeof this.opener === 'string') {
|
66
|
+
opener = this.getRootNode().getElementById(this.opener);
|
67
|
+
}
|
68
|
+
if (!opener) {
|
69
|
+
console.warn('Valid opener id is required.');
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
this.showAt(opener);
|
73
|
+
} else if (this.isOpen() && !this.open) {
|
74
|
+
this.close();
|
75
|
+
}
|
322
76
|
}
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
77
|
+
isOpenerClicked(e) {
|
78
|
+
const target = e.target;
|
79
|
+
if (target === this._opener) {
|
80
|
+
return true;
|
81
|
+
}
|
82
|
+
const ui5ElementTarget = target;
|
83
|
+
if (ui5ElementTarget.getFocusDomRef && ui5ElementTarget.getFocusDomRef() === this._opener) {
|
84
|
+
return true;
|
85
|
+
}
|
86
|
+
return e.composedPath().indexOf(this._opener) > -1;
|
329
87
|
}
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
this._top = Math.round(top);
|
338
|
-
}
|
339
|
-
const borderRadius = Number.parseInt(window.getComputedStyle(this).getPropertyValue("border-radius"));
|
340
|
-
const arrowPos = this.getArrowPosition(targetRect, popoverSize, left, top, isVertical, borderRadius);
|
341
|
-
return {
|
342
|
-
arrow: arrowPos,
|
343
|
-
top: this._top,
|
344
|
-
left: this._left,
|
345
|
-
placementType
|
346
|
-
};
|
347
|
-
}
|
348
|
-
/**
|
349
|
-
* Calculates the position for the arrow.
|
350
|
-
* @private
|
351
|
-
* @param targetRect BoundingClientRect of the target element
|
352
|
-
* @param {{width: number, height: number}} popoverSize Width and height of the popover
|
353
|
-
* @param left Left offset of the popover
|
354
|
-
* @param top Top offset of the popover
|
355
|
-
* @param isVertical If the popover is positioned vertically to the target element
|
356
|
-
* @param {number} borderRadius Value of the border-radius property
|
357
|
-
* @returns {{x: number, y: number}} Arrow's coordinates
|
358
|
-
*/
|
359
|
-
getArrowPosition(targetRect, popoverSize, left, top, isVertical, borderRadius) {
|
360
|
-
const horizontalAlign = this._actualHorizontalAlign;
|
361
|
-
let arrowXCentered = horizontalAlign === _PopoverHorizontalAlign.default.Center || horizontalAlign === _PopoverHorizontalAlign.default.Stretch;
|
362
|
-
if (horizontalAlign === _PopoverHorizontalAlign.default.Right && left <= targetRect.left) {
|
363
|
-
arrowXCentered = true;
|
364
|
-
}
|
365
|
-
if (horizontalAlign === _PopoverHorizontalAlign.default.Left && left + popoverSize.width >= targetRect.left + targetRect.width) {
|
366
|
-
arrowXCentered = true;
|
367
|
-
}
|
368
|
-
let arrowTranslateX = 0;
|
369
|
-
if (isVertical && arrowXCentered) {
|
370
|
-
arrowTranslateX = targetRect.left + targetRect.width / 2 - left - popoverSize.width / 2;
|
371
|
-
}
|
372
|
-
let arrowTranslateY = 0;
|
373
|
-
if (!isVertical) {
|
374
|
-
arrowTranslateY = targetRect.top + targetRect.height / 2 - top - popoverSize.height / 2;
|
375
|
-
}
|
376
|
-
// Restricts the arrow's translate value along each dimension,
|
377
|
-
// so that the arrow does not clip over the popover's rounded borders.
|
378
|
-
const safeRangeForArrowY = popoverSize.height / 2 - borderRadius - ARROW_SIZE / 2;
|
379
|
-
arrowTranslateY = (0, _clamp.default)(arrowTranslateY, -safeRangeForArrowY, safeRangeForArrowY);
|
380
|
-
const safeRangeForArrowX = popoverSize.width / 2 - borderRadius - ARROW_SIZE / 2;
|
381
|
-
arrowTranslateX = (0, _clamp.default)(arrowTranslateX, -safeRangeForArrowX, safeRangeForArrowX);
|
382
|
-
return {
|
383
|
-
x: Math.round(arrowTranslateX),
|
384
|
-
y: Math.round(arrowTranslateY)
|
385
|
-
};
|
386
|
-
}
|
387
|
-
/**
|
388
|
-
* Fallbacks to new placement, prioritizing <code>Left</code> and <code>Right</code> placements.
|
389
|
-
* @private
|
390
|
-
*/
|
391
|
-
fallbackPlacement(clientWidth, clientHeight, targetRect, popoverSize) {
|
392
|
-
if (targetRect.left > popoverSize.width) {
|
393
|
-
return _PopoverPlacementType.default.Left;
|
394
|
-
}
|
395
|
-
if (clientWidth - targetRect.right > targetRect.left) {
|
396
|
-
return _PopoverPlacementType.default.Right;
|
397
|
-
}
|
398
|
-
if (clientHeight - targetRect.bottom > popoverSize.height) {
|
399
|
-
return _PopoverPlacementType.default.Bottom;
|
400
|
-
}
|
401
|
-
if (clientHeight - targetRect.bottom < targetRect.top) {
|
402
|
-
return _PopoverPlacementType.default.Top;
|
403
|
-
}
|
404
|
-
}
|
405
|
-
getActualPlacementType(targetRect, popoverSize) {
|
406
|
-
const placementType = this.placementType;
|
407
|
-
let actualPlacementType = placementType;
|
408
|
-
const clientWidth = document.documentElement.clientWidth;
|
409
|
-
const clientHeight = document.documentElement.clientHeight;
|
410
|
-
switch (placementType) {
|
411
|
-
case _PopoverPlacementType.default.Top:
|
412
|
-
if (targetRect.top < popoverSize.height && targetRect.top < clientHeight - targetRect.bottom) {
|
413
|
-
actualPlacementType = _PopoverPlacementType.default.Bottom;
|
414
|
-
}
|
415
|
-
break;
|
416
|
-
case _PopoverPlacementType.default.Bottom:
|
417
|
-
if (clientHeight - targetRect.bottom < popoverSize.height && clientHeight - targetRect.bottom < targetRect.top) {
|
418
|
-
actualPlacementType = _PopoverPlacementType.default.Top;
|
419
|
-
}
|
420
|
-
break;
|
421
|
-
case _PopoverPlacementType.default.Left:
|
422
|
-
if (targetRect.left < popoverSize.width) {
|
423
|
-
actualPlacementType = this.fallbackPlacement(clientWidth, clientHeight, targetRect, popoverSize) || placementType;
|
424
|
-
}
|
425
|
-
break;
|
426
|
-
case _PopoverPlacementType.default.Right:
|
427
|
-
if (clientWidth - targetRect.right < popoverSize.width) {
|
428
|
-
actualPlacementType = this.fallbackPlacement(clientWidth, clientHeight, targetRect, popoverSize) || placementType;
|
429
|
-
}
|
430
|
-
break;
|
431
|
-
}
|
432
|
-
return actualPlacementType;
|
433
|
-
}
|
434
|
-
getVerticalLeft(targetRect, popoverSize) {
|
435
|
-
const horizontalAlign = this._actualHorizontalAlign;
|
436
|
-
let left = 0;
|
437
|
-
switch (horizontalAlign) {
|
438
|
-
case _PopoverHorizontalAlign.default.Center:
|
439
|
-
case _PopoverHorizontalAlign.default.Stretch:
|
440
|
-
left = targetRect.left - (popoverSize.width - targetRect.width) / 2;
|
441
|
-
break;
|
442
|
-
case _PopoverHorizontalAlign.default.Left:
|
443
|
-
left = targetRect.left;
|
444
|
-
break;
|
445
|
-
case _PopoverHorizontalAlign.default.Right:
|
446
|
-
left = targetRect.right - popoverSize.width;
|
447
|
-
break;
|
448
|
-
}
|
449
|
-
return left;
|
450
|
-
}
|
451
|
-
getHorizontalTop(targetRect, popoverSize) {
|
452
|
-
let top = 0;
|
453
|
-
switch (this.verticalAlign) {
|
454
|
-
case _PopoverVerticalAlign.default.Center:
|
455
|
-
case _PopoverVerticalAlign.default.Stretch:
|
456
|
-
top = targetRect.top - (popoverSize.height - targetRect.height) / 2;
|
457
|
-
break;
|
458
|
-
case _PopoverVerticalAlign.default.Top:
|
459
|
-
top = targetRect.top;
|
460
|
-
break;
|
461
|
-
case _PopoverVerticalAlign.default.Bottom:
|
462
|
-
top = targetRect.bottom - popoverSize.height;
|
463
|
-
break;
|
464
|
-
}
|
465
|
-
return top;
|
466
|
-
}
|
467
|
-
get isModal() {
|
468
|
-
return this.modal;
|
469
|
-
}
|
470
|
-
get shouldHideBackdrop() {
|
471
|
-
return this.hideBackdrop;
|
472
|
-
}
|
473
|
-
get _ariaLabelledBy() {
|
474
|
-
if (!this._ariaLabel && this._displayHeader) {
|
475
|
-
return "ui5-popup-header";
|
476
|
-
}
|
477
|
-
return undefined;
|
478
|
-
}
|
479
|
-
get styles() {
|
480
|
-
return {
|
481
|
-
...super.styles,
|
482
|
-
root: {
|
483
|
-
"max-height": this._maxHeight ? `${this._maxHeight}px` : "",
|
484
|
-
"max-width": this._maxWidth ? `${this._maxWidth}px` : ""
|
485
|
-
},
|
486
|
-
arrow: {
|
487
|
-
transform: `translate(${this.arrowTranslateX}px, ${this.arrowTranslateY}px)`
|
88
|
+
async showAt(opener, preventInitialFocus = false) {
|
89
|
+
if (!opener || this.opened) {
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
this._opener = opener;
|
93
|
+
this._openerRect = opener.getBoundingClientRect();
|
94
|
+
await super._open(preventInitialFocus);
|
488
95
|
}
|
489
|
-
|
490
|
-
|
491
|
-
get classes() {
|
492
|
-
const allClasses = super.classes;
|
493
|
-
allClasses.root["ui5-popover-root"] = true;
|
494
|
-
return allClasses;
|
495
|
-
}
|
496
|
-
/**
|
497
|
-
* Hook for descendants to hide header.
|
498
|
-
*/
|
499
|
-
get _displayHeader() {
|
500
|
-
return !!(this.header.length || this.headerText);
|
501
|
-
}
|
502
|
-
/**
|
503
|
-
* Hook for descendants to hide footer.
|
504
|
-
*/
|
505
|
-
get _displayFooter() {
|
506
|
-
return true;
|
507
|
-
}
|
508
|
-
get _actualHorizontalAlign() {
|
509
|
-
if (this.effectiveDir === "rtl") {
|
510
|
-
if (this.horizontalAlign === _PopoverHorizontalAlign.default.Left) {
|
511
|
-
return _PopoverHorizontalAlign.default.Right;
|
96
|
+
_addOpenedPopup() {
|
97
|
+
(0, sap.ui.require('sap/ui/webc/main/thirdparty/popup-utils/PopoverRegistry').addOpenedPopover)(this);
|
512
98
|
}
|
513
|
-
|
514
|
-
|
99
|
+
_removeOpenedPopup() {
|
100
|
+
(0, sap.ui.require('sap/ui/webc/main/thirdparty/popup-utils/PopoverRegistry').removeOpenedPopover)(this);
|
515
101
|
}
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
102
|
+
shouldCloseDueToOverflow(placement, openerRect) {
|
103
|
+
const threshold = 32;
|
104
|
+
const limits = {
|
105
|
+
'Right': openerRect.right,
|
106
|
+
'Left': openerRect.left,
|
107
|
+
'Top': openerRect.top,
|
108
|
+
'Bottom': openerRect.bottom
|
109
|
+
};
|
110
|
+
const closedPopupParent = (0, _PopupUtils.getClosedPopupParent)(this._opener);
|
111
|
+
let overflowsBottom = false;
|
112
|
+
let overflowsTop = false;
|
113
|
+
if (closedPopupParent.showAt) {
|
114
|
+
const contentRect = closedPopupParent.contentDOM.getBoundingClientRect();
|
115
|
+
overflowsBottom = openerRect.top > contentRect.top + contentRect.height;
|
116
|
+
overflowsTop = openerRect.top + openerRect.height < contentRect.top;
|
117
|
+
}
|
118
|
+
return limits[placement] < 0 || limits[placement] + threshold > closedPopupParent.innerHeight || overflowsBottom || overflowsTop;
|
119
|
+
}
|
120
|
+
shouldCloseDueToNoOpener(openerRect) {
|
121
|
+
return openerRect.top === 0 && openerRect.bottom === 0 && openerRect.left === 0 && openerRect.right === 0;
|
122
|
+
}
|
123
|
+
isOpenerOutsideViewport(openerRect) {
|
124
|
+
return openerRect.bottom < 0 || openerRect.top > window.innerHeight || openerRect.right < 0 || openerRect.left > window.innerWidth;
|
125
|
+
}
|
126
|
+
_resize() {
|
127
|
+
super._resize();
|
128
|
+
if (this.opened) {
|
129
|
+
this.reposition();
|
130
|
+
}
|
131
|
+
}
|
132
|
+
reposition() {
|
133
|
+
this._show();
|
134
|
+
}
|
135
|
+
_show() {
|
136
|
+
let placement;
|
137
|
+
const popoverSize = this.getPopoverSize();
|
138
|
+
if (popoverSize.width === 0 || popoverSize.height === 0) {
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
if (this.isOpen()) {
|
142
|
+
this._openerRect = this._opener.getBoundingClientRect();
|
143
|
+
}
|
144
|
+
if (this.shouldCloseDueToNoOpener(this._openerRect) && this.isFocusWithin()) {
|
145
|
+
placement = this._oldPlacement;
|
146
|
+
} else {
|
147
|
+
placement = this.calcPlacement(this._openerRect, popoverSize);
|
148
|
+
}
|
149
|
+
if (this._preventRepositionAndClose || this.isOpenerOutsideViewport(this._openerRect)) {
|
150
|
+
return this.close();
|
151
|
+
}
|
152
|
+
this._oldPlacement = placement;
|
153
|
+
this.actualPlacementType = placement.placementType;
|
154
|
+
let left = (0, _clamp.default)(this._left, Popover_1.VIEWPORT_MARGIN, document.documentElement.clientWidth - popoverSize.width - Popover_1.VIEWPORT_MARGIN);
|
155
|
+
if (this.actualPlacementType === _PopoverPlacementType.default.Right) {
|
156
|
+
left = Math.max(left, this._left);
|
157
|
+
}
|
158
|
+
let top = (0, _clamp.default)(this._top, Popover_1.VIEWPORT_MARGIN, document.documentElement.clientHeight - popoverSize.height - Popover_1.VIEWPORT_MARGIN);
|
159
|
+
if (this.actualPlacementType === _PopoverPlacementType.default.Bottom) {
|
160
|
+
top = Math.max(top, this._top);
|
161
|
+
}
|
162
|
+
this.arrowTranslateX = placement.arrow.x;
|
163
|
+
this.arrowTranslateY = placement.arrow.y;
|
164
|
+
top = this._adjustForIOSKeyboard(top);
|
165
|
+
Object.assign(this.style, {
|
166
|
+
top: `${ top }px`,
|
167
|
+
left: `${ left }px`
|
168
|
+
});
|
169
|
+
super._show();
|
170
|
+
if (this.horizontalAlign === _PopoverHorizontalAlign.default.Stretch && this._width) {
|
171
|
+
this.style.width = this._width;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
_adjustForIOSKeyboard(top) {
|
175
|
+
if (!(0, _Device.isIOS)()) {
|
176
|
+
return top;
|
177
|
+
}
|
178
|
+
const actualTop = Math.ceil(this.getBoundingClientRect().top);
|
179
|
+
return top + (Number.parseInt(this.style.top || '0') - actualTop);
|
180
|
+
}
|
181
|
+
getPopoverSize() {
|
182
|
+
if (!this.opened) {
|
183
|
+
Object.assign(this.style, {
|
184
|
+
display: 'block',
|
185
|
+
top: '-10000px',
|
186
|
+
left: '-10000px'
|
187
|
+
});
|
188
|
+
}
|
189
|
+
const rect = this.getBoundingClientRect(), width = rect.width, height = rect.height;
|
190
|
+
return {
|
191
|
+
width,
|
192
|
+
height
|
193
|
+
};
|
194
|
+
}
|
195
|
+
get arrowDOM() {
|
196
|
+
return this.shadowRoot.querySelector('.ui5-popover-arrow');
|
197
|
+
}
|
198
|
+
calcPlacement(targetRect, popoverSize) {
|
199
|
+
let left = 0;
|
200
|
+
let top = 0;
|
201
|
+
const allowTargetOverlap = this.allowTargetOverlap;
|
202
|
+
const clientWidth = document.documentElement.clientWidth;
|
203
|
+
const clientHeight = document.documentElement.clientHeight;
|
204
|
+
let maxHeight = clientHeight;
|
205
|
+
let maxWidth = clientWidth;
|
206
|
+
const placementType = this.getActualPlacementType(targetRect, popoverSize);
|
207
|
+
this._preventRepositionAndClose = this.shouldCloseDueToNoOpener(targetRect) || this.shouldCloseDueToOverflow(placementType, targetRect);
|
208
|
+
const isVertical = placementType === _PopoverPlacementType.default.Top || placementType === _PopoverPlacementType.default.Bottom;
|
209
|
+
if (this.horizontalAlign === _PopoverHorizontalAlign.default.Stretch && isVertical) {
|
210
|
+
popoverSize.width = targetRect.width;
|
211
|
+
this._width = `${ targetRect.width }px`;
|
212
|
+
} else if (this.verticalAlign === _PopoverVerticalAlign.default.Stretch && !isVertical) {
|
213
|
+
popoverSize.height = targetRect.height;
|
214
|
+
}
|
215
|
+
const arrowOffset = this.hideArrow ? 0 : ARROW_SIZE;
|
216
|
+
switch (placementType) {
|
217
|
+
case _PopoverPlacementType.default.Top:
|
218
|
+
left = this.getVerticalLeft(targetRect, popoverSize);
|
219
|
+
top = Math.max(targetRect.top - popoverSize.height - arrowOffset, 0);
|
220
|
+
if (!allowTargetOverlap) {
|
221
|
+
maxHeight = targetRect.top - arrowOffset;
|
222
|
+
}
|
223
|
+
break;
|
224
|
+
case _PopoverPlacementType.default.Bottom:
|
225
|
+
left = this.getVerticalLeft(targetRect, popoverSize);
|
226
|
+
top = targetRect.bottom + arrowOffset;
|
227
|
+
if (allowTargetOverlap) {
|
228
|
+
top = Math.max(Math.min(top, clientHeight - popoverSize.height), 0);
|
229
|
+
} else {
|
230
|
+
maxHeight = clientHeight - targetRect.bottom - arrowOffset;
|
231
|
+
}
|
232
|
+
break;
|
233
|
+
case _PopoverPlacementType.default.Left:
|
234
|
+
left = Math.max(targetRect.left - popoverSize.width - arrowOffset, 0);
|
235
|
+
top = this.getHorizontalTop(targetRect, popoverSize);
|
236
|
+
if (!allowTargetOverlap) {
|
237
|
+
maxWidth = targetRect.left - arrowOffset;
|
238
|
+
}
|
239
|
+
break;
|
240
|
+
case _PopoverPlacementType.default.Right:
|
241
|
+
left = targetRect.left + targetRect.width + arrowOffset;
|
242
|
+
top = this.getHorizontalTop(targetRect, popoverSize);
|
243
|
+
if (allowTargetOverlap) {
|
244
|
+
left = Math.max(Math.min(left, clientWidth - popoverSize.width), 0);
|
245
|
+
} else {
|
246
|
+
maxWidth = clientWidth - targetRect.right - arrowOffset;
|
247
|
+
}
|
248
|
+
break;
|
249
|
+
}
|
250
|
+
if (isVertical) {
|
251
|
+
if (popoverSize.width > clientWidth || left < 0) {
|
252
|
+
left = 0;
|
253
|
+
} else if (left + popoverSize.width > clientWidth) {
|
254
|
+
left -= left + popoverSize.width - clientWidth;
|
255
|
+
}
|
256
|
+
} else {
|
257
|
+
if (popoverSize.height > clientHeight || top < 0) {
|
258
|
+
top = 0;
|
259
|
+
} else if (top + popoverSize.height > clientHeight) {
|
260
|
+
top -= top + popoverSize.height - clientHeight;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
this._maxHeight = Math.round(maxHeight - Popover_1.VIEWPORT_MARGIN);
|
264
|
+
this._maxWidth = Math.round(maxWidth - Popover_1.VIEWPORT_MARGIN);
|
265
|
+
if (this._left === undefined || Math.abs(this._left - left) > 1.5) {
|
266
|
+
this._left = Math.round(left);
|
267
|
+
}
|
268
|
+
if (this._top === undefined || Math.abs(this._top - top) > 1.5) {
|
269
|
+
this._top = Math.round(top);
|
270
|
+
}
|
271
|
+
const borderRadius = Number.parseInt(window.getComputedStyle(this).getPropertyValue('border-radius'));
|
272
|
+
const arrowPos = this.getArrowPosition(targetRect, popoverSize, left, top, isVertical, borderRadius);
|
273
|
+
return {
|
274
|
+
arrow: arrowPos,
|
275
|
+
top: this._top,
|
276
|
+
left: this._left,
|
277
|
+
placementType
|
278
|
+
};
|
279
|
+
}
|
280
|
+
getArrowPosition(targetRect, popoverSize, left, top, isVertical, borderRadius) {
|
281
|
+
const horizontalAlign = this._actualHorizontalAlign;
|
282
|
+
let arrowXCentered = horizontalAlign === _PopoverHorizontalAlign.default.Center || horizontalAlign === _PopoverHorizontalAlign.default.Stretch;
|
283
|
+
if (horizontalAlign === _PopoverHorizontalAlign.default.Right && left <= targetRect.left) {
|
284
|
+
arrowXCentered = true;
|
285
|
+
}
|
286
|
+
if (horizontalAlign === _PopoverHorizontalAlign.default.Left && left + popoverSize.width >= targetRect.left + targetRect.width) {
|
287
|
+
arrowXCentered = true;
|
288
|
+
}
|
289
|
+
let arrowTranslateX = 0;
|
290
|
+
if (isVertical && arrowXCentered) {
|
291
|
+
arrowTranslateX = targetRect.left + targetRect.width / 2 - left - popoverSize.width / 2;
|
292
|
+
}
|
293
|
+
let arrowTranslateY = 0;
|
294
|
+
if (!isVertical) {
|
295
|
+
arrowTranslateY = targetRect.top + targetRect.height / 2 - top - popoverSize.height / 2;
|
296
|
+
}
|
297
|
+
const safeRangeForArrowY = popoverSize.height / 2 - borderRadius - ARROW_SIZE / 2;
|
298
|
+
arrowTranslateY = (0, _clamp.default)(arrowTranslateY, -safeRangeForArrowY, safeRangeForArrowY);
|
299
|
+
const safeRangeForArrowX = popoverSize.width / 2 - borderRadius - ARROW_SIZE / 2;
|
300
|
+
arrowTranslateX = (0, _clamp.default)(arrowTranslateX, -safeRangeForArrowX, safeRangeForArrowX);
|
301
|
+
return {
|
302
|
+
x: Math.round(arrowTranslateX),
|
303
|
+
y: Math.round(arrowTranslateY)
|
304
|
+
};
|
305
|
+
}
|
306
|
+
fallbackPlacement(clientWidth, clientHeight, targetRect, popoverSize) {
|
307
|
+
if (targetRect.left > popoverSize.width) {
|
308
|
+
return _PopoverPlacementType.default.Left;
|
309
|
+
}
|
310
|
+
if (clientWidth - targetRect.right > targetRect.left) {
|
311
|
+
return _PopoverPlacementType.default.Right;
|
312
|
+
}
|
313
|
+
if (clientHeight - targetRect.bottom > popoverSize.height) {
|
314
|
+
return _PopoverPlacementType.default.Bottom;
|
315
|
+
}
|
316
|
+
if (clientHeight - targetRect.bottom < targetRect.top) {
|
317
|
+
return _PopoverPlacementType.default.Top;
|
318
|
+
}
|
319
|
+
}
|
320
|
+
getActualPlacementType(targetRect, popoverSize) {
|
321
|
+
const placementType = this.placementType;
|
322
|
+
let actualPlacementType = placementType;
|
323
|
+
const clientWidth = document.documentElement.clientWidth;
|
324
|
+
const clientHeight = document.documentElement.clientHeight;
|
325
|
+
switch (placementType) {
|
326
|
+
case _PopoverPlacementType.default.Top:
|
327
|
+
if (targetRect.top < popoverSize.height && targetRect.top < clientHeight - targetRect.bottom) {
|
328
|
+
actualPlacementType = _PopoverPlacementType.default.Bottom;
|
329
|
+
}
|
330
|
+
break;
|
331
|
+
case _PopoverPlacementType.default.Bottom:
|
332
|
+
if (clientHeight - targetRect.bottom < popoverSize.height && clientHeight - targetRect.bottom < targetRect.top) {
|
333
|
+
actualPlacementType = _PopoverPlacementType.default.Top;
|
334
|
+
}
|
335
|
+
break;
|
336
|
+
case _PopoverPlacementType.default.Left:
|
337
|
+
if (targetRect.left < popoverSize.width) {
|
338
|
+
actualPlacementType = this.fallbackPlacement(clientWidth, clientHeight, targetRect, popoverSize) || placementType;
|
339
|
+
}
|
340
|
+
break;
|
341
|
+
case _PopoverPlacementType.default.Right:
|
342
|
+
if (clientWidth - targetRect.right < popoverSize.width) {
|
343
|
+
actualPlacementType = this.fallbackPlacement(clientWidth, clientHeight, targetRect, popoverSize) || placementType;
|
344
|
+
}
|
345
|
+
break;
|
346
|
+
}
|
347
|
+
return actualPlacementType;
|
348
|
+
}
|
349
|
+
getVerticalLeft(targetRect, popoverSize) {
|
350
|
+
const horizontalAlign = this._actualHorizontalAlign;
|
351
|
+
let left = 0;
|
352
|
+
switch (horizontalAlign) {
|
353
|
+
case _PopoverHorizontalAlign.default.Center:
|
354
|
+
case _PopoverHorizontalAlign.default.Stretch:
|
355
|
+
left = targetRect.left - (popoverSize.width - targetRect.width) / 2;
|
356
|
+
break;
|
357
|
+
case _PopoverHorizontalAlign.default.Left:
|
358
|
+
left = targetRect.left;
|
359
|
+
break;
|
360
|
+
case _PopoverHorizontalAlign.default.Right:
|
361
|
+
left = targetRect.right - popoverSize.width;
|
362
|
+
break;
|
363
|
+
}
|
364
|
+
return left;
|
365
|
+
}
|
366
|
+
getHorizontalTop(targetRect, popoverSize) {
|
367
|
+
let top = 0;
|
368
|
+
switch (this.verticalAlign) {
|
369
|
+
case _PopoverVerticalAlign.default.Center:
|
370
|
+
case _PopoverVerticalAlign.default.Stretch:
|
371
|
+
top = targetRect.top - (popoverSize.height - targetRect.height) / 2;
|
372
|
+
break;
|
373
|
+
case _PopoverVerticalAlign.default.Top:
|
374
|
+
top = targetRect.top;
|
375
|
+
break;
|
376
|
+
case _PopoverVerticalAlign.default.Bottom:
|
377
|
+
top = targetRect.bottom - popoverSize.height;
|
378
|
+
break;
|
379
|
+
}
|
380
|
+
return top;
|
381
|
+
}
|
382
|
+
get isModal() {
|
383
|
+
return this.modal;
|
384
|
+
}
|
385
|
+
get shouldHideBackdrop() {
|
386
|
+
return this.hideBackdrop;
|
387
|
+
}
|
388
|
+
get _ariaLabelledBy() {
|
389
|
+
if (!this._ariaLabel && this._displayHeader) {
|
390
|
+
return 'ui5-popup-header';
|
391
|
+
}
|
392
|
+
return undefined;
|
393
|
+
}
|
394
|
+
get styles() {
|
395
|
+
return {
|
396
|
+
...super.styles,
|
397
|
+
root: {
|
398
|
+
'max-height': this._maxHeight ? `${ this._maxHeight }px` : '',
|
399
|
+
'max-width': this._maxWidth ? `${ this._maxWidth }px` : ''
|
400
|
+
},
|
401
|
+
arrow: { transform: `translate(${ this.arrowTranslateX }px, ${ this.arrowTranslateY }px)` }
|
402
|
+
};
|
403
|
+
}
|
404
|
+
get classes() {
|
405
|
+
const allClasses = super.classes;
|
406
|
+
allClasses.root['ui5-popover-root'] = true;
|
407
|
+
return allClasses;
|
408
|
+
}
|
409
|
+
get _displayHeader() {
|
410
|
+
return !!(this.header.length || this.headerText);
|
411
|
+
}
|
412
|
+
get _displayFooter() {
|
413
|
+
return true;
|
414
|
+
}
|
415
|
+
get _actualHorizontalAlign() {
|
416
|
+
if (this.effectiveDir === 'rtl') {
|
417
|
+
if (this.horizontalAlign === _PopoverHorizontalAlign.default.Left) {
|
418
|
+
return _PopoverHorizontalAlign.default.Right;
|
419
|
+
}
|
420
|
+
if (this.horizontalAlign === _PopoverHorizontalAlign.default.Right) {
|
421
|
+
return _PopoverHorizontalAlign.default.Left;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
return this.horizontalAlign;
|
425
|
+
}
|
426
|
+
};
|
427
|
+
__decorate([(0, _property.default)()], Popover.prototype, 'headerText', void 0);
|
428
|
+
__decorate([(0, _property.default)({
|
429
|
+
type: _PopoverPlacementType.default,
|
430
|
+
defaultValue: _PopoverPlacementType.default.Right
|
431
|
+
})], Popover.prototype, 'placementType', void 0);
|
432
|
+
__decorate([(0, _property.default)({
|
433
|
+
type: _PopoverHorizontalAlign.default,
|
434
|
+
defaultValue: _PopoverHorizontalAlign.default.Center
|
435
|
+
})], Popover.prototype, 'horizontalAlign', void 0);
|
436
|
+
__decorate([(0, _property.default)({
|
437
|
+
type: _PopoverVerticalAlign.default,
|
438
|
+
defaultValue: _PopoverVerticalAlign.default.Center
|
439
|
+
})], Popover.prototype, 'verticalAlign', void 0);
|
440
|
+
__decorate([(0, _property.default)({ type: Boolean })], Popover.prototype, 'modal', void 0);
|
441
|
+
__decorate([(0, _property.default)({ type: Boolean })], Popover.prototype, 'hideBackdrop', void 0);
|
442
|
+
__decorate([(0, _property.default)({ type: Boolean })], Popover.prototype, 'hideArrow', void 0);
|
443
|
+
__decorate([(0, _property.default)({ type: Boolean })], Popover.prototype, 'allowTargetOverlap', void 0);
|
444
|
+
__decorate([(0, _property.default)({ validator: _DOMReference.default })], Popover.prototype, 'opener', void 0);
|
445
|
+
__decorate([(0, _property.default)({ type: Boolean })], Popover.prototype, 'disableScrolling', void 0);
|
446
|
+
__decorate([(0, _property.default)({
|
447
|
+
validator: _Integer.default,
|
448
|
+
defaultValue: 0,
|
449
|
+
noAttribute: true
|
450
|
+
})], Popover.prototype, 'arrowTranslateX', void 0);
|
451
|
+
__decorate([(0, _property.default)({
|
452
|
+
validator: _Integer.default,
|
453
|
+
defaultValue: 0,
|
454
|
+
noAttribute: true
|
455
|
+
})], Popover.prototype, 'arrowTranslateY', void 0);
|
456
|
+
__decorate([(0, _property.default)({
|
457
|
+
type: _PopoverPlacementType.default,
|
458
|
+
defaultValue: _PopoverPlacementType.default.Right
|
459
|
+
})], Popover.prototype, 'actualPlacementType', void 0);
|
460
|
+
__decorate([(0, _property.default)({
|
461
|
+
validator: _Integer.default,
|
462
|
+
noAttribute: true
|
463
|
+
})], Popover.prototype, '_maxHeight', void 0);
|
464
|
+
__decorate([(0, _property.default)({
|
465
|
+
validator: _Integer.default,
|
466
|
+
noAttribute: true
|
467
|
+
})], Popover.prototype, '_maxWidth', void 0);
|
468
|
+
__decorate([(0, _slot.default)({ type: HTMLElement })], Popover.prototype, 'header', void 0);
|
469
|
+
__decorate([(0, _slot.default)({ type: HTMLElement })], Popover.prototype, 'footer', void 0);
|
470
|
+
Popover = Popover_1 = __decorate([(0, _customElement.default)({
|
471
|
+
tag: 'ui5-popover',
|
472
|
+
styles: [
|
473
|
+
_BrowserScrollbar.default,
|
474
|
+
_PopupsCommon.default,
|
475
|
+
_Popover.default
|
476
|
+
],
|
477
|
+
template: _PopoverTemplate.default
|
478
|
+
})], Popover);
|
479
|
+
const instanceOfPopover = object => {
|
480
|
+
return 'showAt' in object;
|
481
|
+
};
|
482
|
+
_exports.instanceOfPopover = instanceOfPopover;
|
483
|
+
Popover.define();
|
484
|
+
var _default = Popover;
|
485
|
+
_exports.default = _default;
|
591
486
|
});
|