@zohodesk/components 1.0.0-temp-242 → 1.0.0-temp-244

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.
Files changed (44) hide show
  1. package/README.md +0 -4
  2. package/es/AvatarTeam/AvatarTeam.module.css +189 -189
  3. package/es/Buttongroup/Buttongroup.module.css +104 -104
  4. package/es/DropBox/css/DropBox.module.css +58 -58
  5. package/es/DropDown/DropDownHeading.module.css +53 -53
  6. package/es/DropDown/DropDownItem.module.css +94 -94
  7. package/es/Label/Label.module.css +57 -57
  8. package/es/PopOver/PopOver.module.css +8 -8
  9. package/es/Popup/Popup.js +1045 -21
  10. package/es/Popup/PositionMapping.js +72 -0
  11. package/es/Popup/Registry.js +36 -0
  12. package/es/Popup/intersectionObserver.js +49 -0
  13. package/es/Popup/viewPort.js +373 -0
  14. package/es/Ribbon/Ribbon.module.css +499 -499
  15. package/es/Switch/Switch.module.css +127 -127
  16. package/es/Tag/Tag.module.css +253 -253
  17. package/es/TextBox/TextBox.module.css +196 -196
  18. package/es/TextBoxIcon/TextBoxIcon.module.css +79 -79
  19. package/es/Tooltip/Tooltip.js +2 -2
  20. package/es/common/customscroll.module.css +141 -141
  21. package/es/utils/Common.js +1 -1
  22. package/es/v1/Popup/Popup.js +1 -1
  23. package/lib/AvatarTeam/AvatarTeam.module.css +189 -189
  24. package/lib/Buttongroup/Buttongroup.module.css +104 -104
  25. package/lib/DropBox/css/DropBox.module.css +58 -58
  26. package/lib/DropDown/DropDownHeading.module.css +53 -53
  27. package/lib/DropDown/DropDownItem.module.css +94 -94
  28. package/lib/Label/Label.module.css +57 -57
  29. package/lib/PopOver/PopOver.module.css +8 -8
  30. package/lib/Popup/Popup.js +1152 -25
  31. package/lib/Popup/PositionMapping.js +81 -0
  32. package/lib/Popup/Registry.js +46 -0
  33. package/lib/Popup/intersectionObserver.js +72 -0
  34. package/lib/Popup/viewPort.js +367 -0
  35. package/lib/Ribbon/Ribbon.module.css +499 -499
  36. package/lib/Switch/Switch.module.css +127 -127
  37. package/lib/Tag/Tag.module.css +253 -253
  38. package/lib/TextBox/TextBox.module.css +196 -196
  39. package/lib/TextBoxIcon/TextBoxIcon.module.css +79 -79
  40. package/lib/Tooltip/Tooltip.js +2 -2
  41. package/lib/common/customscroll.module.css +141 -141
  42. package/lib/utils/Common.js +1 -1
  43. package/lib/v1/Popup/Popup.js +1 -1
  44. package/package.json +4 -4
@@ -0,0 +1,72 @@
1
+ export const absolutePositionMapping = {
2
+ "bottomCenter": "bottomCenter",
3
+ "bottomRight": "bottomLeftToRight",
4
+ "bottomLeft": "bottomRightToLeft",
5
+ "topCenter": "topCenter",
6
+ "topRight": "topLeftToRight",
7
+ "topLeft": "topRightToLeft",
8
+ "rightCenter": "rightCenter",
9
+ "rightBottom": "rightTopToBottom",
10
+ "rightTop": "rightBottomToTop",
11
+ "leftCenter": "leftCenter",
12
+ "leftBottom": "leftTopToBottom",
13
+ "leftTop": "leftBottomToTop",
14
+ "bottomLeftToRight": "bottomLeftToRight",
15
+ "bottomRightToLeft": "bottomRightToLeft",
16
+ "topLeftToRight": "topLeftToRight",
17
+ "topRightToLeft": "topRightToLeft",
18
+ "rightTopToBottom": "rightTopToBottom",
19
+ "rightBottomToTop": "rightBottomToTop",
20
+ "leftTopToBottom": "leftTopToBottom"
21
+ };
22
+ export const rtlAbsolutePositionMapping = {
23
+ "bottomCenter": "bottomCenter",
24
+ "bottomRight": "bottomRightToLeft",
25
+ "bottomLeft": "bottomLeftToRight",
26
+ "topCenter": "topCenter",
27
+ "topRight": "topRightToLeft",
28
+ "topLeft": "topLeftToRight",
29
+ "rightCenter": "leftCenter",
30
+ "rightBottom": "leftTopToBottom",
31
+ "rightTop": "leftBottomToTop",
32
+ "leftCenter": "rightCenter",
33
+ "leftBottom": "rightTopToBottom",
34
+ "leftTop": "rightBottomToTop",
35
+ "bottomLeftToRight": "bottomLeftToRight",
36
+ "bottomRightToLeft": "bottomRightToLeft",
37
+ "topLeftToRight": "topLeftToRight",
38
+ "topRightToLeft": "topRightToLeft",
39
+ "rightTopToBottom": "rightTopToBottom",
40
+ "rightBottomToTop": "rightBottomToTop",
41
+ "leftTopToBottom": "leftTopToBottom"
42
+ };
43
+ export const rtlFixedPositionMapping = {
44
+ "bottomCenter": "bottomCenter",
45
+ "bottomLeftToRight": "bottomRightToLeft",
46
+ "bottomCenterToRight": "bottomCenterToLeft",
47
+ "bottomRightToLeft": "bottomLeftToRight",
48
+ "bottomCenterToLeft": "bottomCenterToRight",
49
+ "topCenter": "topCenter",
50
+ "topLeftToRight": "topRightToLeft",
51
+ "topCenterToRight": "topCenterToLeft",
52
+ "topRightToLeft": "topLeftToRight",
53
+ "topCenterToLeft": "topCenterToRight",
54
+ "rightTopToBottom": "leftTopToBottom",
55
+ "rightCenterToBottom": "leftCenterToBottom",
56
+ "rightCenter": "leftCenter",
57
+ "rightBottomToTop": "leftBottomToTop",
58
+ "rightCenterToTop": "leftCenterToTop",
59
+ "leftTopToBottom": "rightTopToBottom",
60
+ "leftCenterToBottom": "rightCenterToBottom",
61
+ "leftCenter": "rightCenter",
62
+ "leftBottomToTop": "rightBottomToTop",
63
+ "leftCenterToTop": "rightCenterToTop",
64
+ "bottomRight": "bottomLeft",
65
+ "bottomLeft": "bottomRight",
66
+ "topRight": "topLeft",
67
+ "topLeft": "topRight",
68
+ "rightBottom": "leftBottom",
69
+ "rightTop": "leftTop",
70
+ "leftBottom": "rightBottom",
71
+ "leftTop": "rightTop"
72
+ };
@@ -0,0 +1,36 @@
1
+ import { getLibraryConfig } from "../Provider/Config.js";
2
+ const Registry = {
3
+ lastOpenedGroup: [],
4
+ popups: {},
5
+ listenerPopupRef: undefined,
6
+ scrollBlockedListenerPopupRef: undefined,
7
+ scrollableListenerPopupRef: undefined,
8
+
9
+ getOpenedPopups() {
10
+ return Object.values(Registry.popups).flat().filter(popup => popup.state.isPopupOpen);
11
+ },
12
+
13
+ getOpenedScrollBlockedFixedPopups() {
14
+ return Registry.getOpenedPopups().filter(popup => popup.getIsOutsideScrollBlocked(popup) && !popup.getIsAbsolutePopup(popup));
15
+ },
16
+
17
+ getOpenedScrollableFixedPopups() {
18
+ return Registry.getOpenedPopups().filter(popup => !popup.getIsOutsideScrollBlocked(popup) && !popup.getIsAbsolutePopup(popup));
19
+ },
20
+
21
+ getRootElement() {
22
+ const getRootElement = getLibraryConfig('getRootElement');
23
+
24
+ if (getRootElement && typeof getRootElement === 'function') {
25
+ const parent = getRootElement();
26
+
27
+ if (parent) {
28
+ return parent;
29
+ }
30
+ }
31
+
32
+ return document;
33
+ }
34
+
35
+ };
36
+ export default Registry;
@@ -0,0 +1,49 @@
1
+ let observerCallbacks = null;
2
+ let intersectionObserver = null;
3
+
4
+ function handleObserverCallbacks(entries) {
5
+ entries.forEach(entry => {
6
+ let oldCallbacks = observerCallbacks.get(entry.target);
7
+
8
+ if (Array.isArray(oldCallbacks) && oldCallbacks.length) {
9
+ oldCallbacks.forEach(callback => {
10
+ callback && callback(entry);
11
+ });
12
+ }
13
+ });
14
+ }
15
+
16
+ export function addIntersectionObserver(element, callback, options) {
17
+ if (!!element && typeof callback == 'function') {
18
+ if (intersectionObserver === null && observerCallbacks === null) {
19
+ intersectionObserver = new IntersectionObserver(entries => {
20
+ handleObserverCallbacks(entries);
21
+ }, options);
22
+ observerCallbacks = new Map();
23
+ }
24
+
25
+ intersectionObserver.observe(element);
26
+ let oldCallbacks = observerCallbacks.get(element) || [];
27
+ observerCallbacks.set(element, [...oldCallbacks, callback]);
28
+ }
29
+ }
30
+ export function removeIntersectionObserver(element, callback) {
31
+ if (!!element && typeof callback == 'function') {
32
+ let oldCallbacks = observerCallbacks ? observerCallbacks.get(element) : null;
33
+
34
+ if (Array.isArray(oldCallbacks)) {
35
+ let callbacks = oldCallbacks.filter(handler => handler !== callback);
36
+
37
+ if (intersectionObserver && callbacks.length === 0) {
38
+ observerCallbacks.delete(element);
39
+ intersectionObserver.unobserve(element);
40
+ }
41
+ }
42
+
43
+ if (intersectionObserver && observerCallbacks && observerCallbacks.size === 0) {
44
+ intersectionObserver.disconnect();
45
+ intersectionObserver = null;
46
+ observerCallbacks = null;
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,373 @@
1
+ const defaultOrder = ['bottomCenter', 'bottomLeftToRight', 'bottomCenterToRight', 'bottomRightToLeft', 'bottomCenterToLeft', 'topCenter', 'topLeftToRight', 'topCenterToRight', 'topRightToLeft', 'topCenterToLeft', 'rightTopToBottom', 'rightCenterToBottom', 'rightCenter', 'rightBottomToTop', 'rightCenterToTop', 'leftTopToBottom', 'leftCenterToBottom', 'leftCenter', 'leftBottomToTop', 'leftCenterToTop', 'bottomRight', 'bottomLeft', 'topRight', 'topLeft', 'rightBottom', 'rightTop', 'leftBottom', 'leftTop'];
2
+ let viewPort = {
3
+ frameRelativeRects: (el, customFrame, documentEle) => {
4
+ if (!el) {
5
+ return;
6
+ }
7
+
8
+ let rectTemp = el.getBoundingClientRect();
9
+ let rect = {
10
+ height: rectTemp.height || el.clientHeight,
11
+ width: rectTemp.width || el.clientWidth,
12
+ top: rectTemp.top,
13
+ bottom: rectTemp.bottom,
14
+ left: rectTemp.left,
15
+ right: rectTemp.right,
16
+ x: rectTemp.x,
17
+ y: rectTemp.y
18
+ };
19
+ documentEle = documentEle ? documentEle : document.documentElement;
20
+ let customFrameRect = {
21
+ top: 0,
22
+ left: 0,
23
+ right: documentEle.clientWidth,
24
+ bottom: documentEle.clientHeight,
25
+ height: documentEle.clientHeight,
26
+ width: documentEle.clientWidth,
27
+ x: 0,
28
+ y: 0
29
+ };
30
+
31
+ if (customFrame) {
32
+ customFrameRect = customFrame.getBoundingClientRect();
33
+ }
34
+
35
+ let newRect = {
36
+ top: rect.top - customFrameRect.top,
37
+ left: rect.left - customFrameRect.left,
38
+ height: rect.height,
39
+ width: rect.width
40
+ };
41
+ newRect.bottom = newRect.top + newRect.height;
42
+ newRect.right = newRect.left + newRect.width;
43
+ newRect.x = newRect.left;
44
+ newRect.y = newRect.top;
45
+ let rectGap = {
46
+ top: newRect.top,
47
+ left: newRect.left,
48
+ bottom: customFrameRect.height - newRect.bottom,
49
+ right: customFrameRect.width - newRect.right
50
+ };
51
+ rectGap.center = {
52
+ top: rectGap.top + newRect.height / 2,
53
+ left: rectGap.left + newRect.width / 2,
54
+ bottom: rectGap.bottom + newRect.height / 2,
55
+ right: rectGap.right + newRect.width / 2
56
+ };
57
+ return {
58
+ frameRect: customFrameRect,
59
+ rect: newRect,
60
+ rectGap
61
+ };
62
+ },
63
+ isInViewPort: (el, customFrame) => {
64
+ if (!el) {
65
+ return;
66
+ }
67
+
68
+ let elRects = viewPort.frameRelativeRects(el, customFrame);
69
+ let {
70
+ rect
71
+ } = elRects;
72
+ let {
73
+ frameRect
74
+ } = elRects;
75
+ return rect.top >= 0 && rect.left >= 0 && rect.bottom <= frameRect.height && rect.right <= frameRect.width;
76
+ },
77
+ getViewPortEle: el => {
78
+ return el.closest('[data-viewport-container=true]') ? el.closest('[data-viewport-container=true]') : document.documentElement;
79
+ },
80
+ possibilities: function (el, relativeBox, customFrame) {
81
+ let {
82
+ needArrow,
83
+ isAbsolute
84
+ } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
85
+
86
+ if (!el) {
87
+ return;
88
+ }
89
+
90
+ let elViewPortEle = viewPort.getViewPortEle(el);
91
+ let elRects = viewPort.frameRelativeRects(el, customFrame, elViewPortEle);
92
+ let {
93
+ rect
94
+ } = elRects;
95
+ let relativeBoxViewPortEle = viewPort.getViewPortEle(relativeBox);
96
+ let relativeBoxRects = viewPort.frameRelativeRects(relativeBox, customFrame, relativeBoxViewPortEle);
97
+ let {
98
+ rectGap: relativeBoxGap,
99
+ rect: relativeBoxRect
100
+ } = relativeBoxRects;
101
+ let relativeBoxDocumentRects = viewPort.frameRelativeRects(relativeBox, customFrame);
102
+ let {
103
+ rectGap: documentGap
104
+ } = relativeBoxDocumentRects; //rect => PopOverContainer, relativeBoxGap => PopOverTarget
105
+ //Horizontal ~ ----- X axis
106
+ //Vertical ~ ||||||| Y axis
107
+
108
+ let paddingSpace = 5; // space between target and relative element
109
+
110
+ let arrowSize = needArrow ? 10 : 0;
111
+ let padding = needArrow ? arrowSize : paddingSpace;
112
+ let arrowHorizontalBalancePx = !isAbsolute && needArrow ? 30 : 0;
113
+ let arrowVerticalBalancePx = !isAbsolute && needArrow ? 27 : 0;
114
+ let bottomOverFlow = rect.height + padding > relativeBoxGap.bottom;
115
+ let topOverFlow = rect.height + padding > relativeBoxGap.top;
116
+ let rightOverFlow = rect.width + padding > relativeBoxGap.right;
117
+ let leftOverFlow = rect.width + padding > relativeBoxGap.left;
118
+ let horizontalCenterOverFlow = rect.width / 2 + padding > relativeBoxGap.center.right || rect.width / 2 + padding > relativeBoxGap.center.left;
119
+ let verticalCenterOverFlow = rect.height / 2 + padding > relativeBoxGap.center.top || rect.height / 2 + padding > relativeBoxGap.center.bottom;
120
+ let horizontalLeftToRightOverFlow = rect.width + padding > relativeBoxRect.width + relativeBoxGap.right;
121
+ let horizontalCenterToRightOverFlow = rect.width + padding > relativeBoxGap.center.right || arrowHorizontalBalancePx > relativeBoxGap.center.left;
122
+ let horizontalRightToLeft = rect.width + padding > relativeBoxRect.width + relativeBoxGap.left;
123
+ let horizontalCenterToLeft = rect.width + padding > relativeBoxGap.center.left || arrowHorizontalBalancePx > relativeBoxGap.center.right;
124
+ let verticalTopToBottomOverFlow = rect.height + padding > relativeBoxRect.height + relativeBoxGap.bottom;
125
+ let verticalCenterToBottomOverFlow = rect.height + padding > relativeBoxGap.center.bottom || arrowVerticalBalancePx > relativeBoxGap.center.top;
126
+ let verticalBottomToTopOverFlow = rect.height + padding > relativeBoxRect.height + relativeBoxGap.top;
127
+ let verticalCenterToTopOverFlow = rect.height + padding > relativeBoxGap.center.top || arrowVerticalBalancePx > relativeBoxGap.center.bottom;
128
+ let views = {
129
+ bottomCenter: !(bottomOverFlow || horizontalCenterOverFlow),
130
+ bottomLeftToRight: !(bottomOverFlow || horizontalLeftToRightOverFlow),
131
+ bottomCenterToRight: !(bottomOverFlow || horizontalCenterToRightOverFlow),
132
+ bottomRight: !(bottomOverFlow || rightOverFlow || arrowHorizontalBalancePx > relativeBoxRect.right),
133
+ bottomRightToLeft: !(bottomOverFlow || horizontalRightToLeft),
134
+ bottomCenterToLeft: !(bottomOverFlow || horizontalCenterToLeft),
135
+ bottomLeft: !(bottomOverFlow || leftOverFlow || arrowHorizontalBalancePx > relativeBoxGap.right + relativeBoxRect.width),
136
+ topCenter: !(topOverFlow || horizontalCenterOverFlow),
137
+ topLeftToRight: !(topOverFlow || horizontalLeftToRightOverFlow),
138
+ topCenterToRight: !(topOverFlow || horizontalCenterToRightOverFlow),
139
+ topRight: !(topOverFlow || rightOverFlow || arrowHorizontalBalancePx > relativeBoxRect.right),
140
+ topRightToLeft: !(topOverFlow || horizontalRightToLeft),
141
+ topCenterToLeft: !(topOverFlow || horizontalCenterToLeft),
142
+ topLeft: !(topOverFlow || leftOverFlow || arrowHorizontalBalancePx > relativeBoxGap.right + relativeBoxRect.width),
143
+ rightCenter: !(rightOverFlow || verticalCenterOverFlow),
144
+ rightTopToBottom: !(rightOverFlow || verticalTopToBottomOverFlow),
145
+ rightCenterToBottom: !(rightOverFlow || verticalCenterToBottomOverFlow),
146
+ rightBottom: !(rightOverFlow || bottomOverFlow || arrowVerticalBalancePx > relativeBoxRect.bottom),
147
+ rightBottomToTop: !(rightOverFlow || verticalBottomToTopOverFlow),
148
+ rightCenterToTop: !(rightOverFlow || verticalCenterToTopOverFlow),
149
+ rightTop: !(rightOverFlow || topOverFlow || arrowVerticalBalancePx > relativeBoxGap.bottom + relativeBoxRect.height),
150
+ leftCenter: !(leftOverFlow || verticalCenterOverFlow),
151
+ leftTopToBottom: !(leftOverFlow || verticalTopToBottomOverFlow),
152
+ leftCenterToBottom: !(leftOverFlow || verticalCenterToBottomOverFlow),
153
+ leftBottom: !(leftOverFlow || bottomOverFlow || arrowVerticalBalancePx > relativeBoxRect.bottom),
154
+ leftBottomToTop: !(leftOverFlow || verticalBottomToTopOverFlow),
155
+ leftCenterToTop: !(leftOverFlow || verticalCenterToTopOverFlow),
156
+ leftTop: !(leftOverFlow || topOverFlow || arrowVerticalBalancePx > relativeBoxGap.bottom + relativeBoxRect.height)
157
+ };
158
+ let horizontalCenter = relativeBoxGap.left + relativeBoxRect.width / 2;
159
+ let horizontalLeft = relativeBoxGap.left;
160
+ let horizontalRight = relativeBoxGap.left + relativeBoxRect.width;
161
+ let verticalBottom = relativeBoxGap.top + relativeBoxRect.height;
162
+ let verticalTop = relativeBoxGap.top;
163
+ let verticalCenter = relativeBoxGap.top + relativeBoxRect.height / 2;
164
+ let horizontalTop = documentGap.bottom + relativeBoxRect.height;
165
+ let verticalCenterToTop = documentGap.bottom + relativeBoxRect.height / 2;
166
+ let viewsOffset = {
167
+ bottomCenter: {
168
+ left: horizontalCenter - rect.width / 2,
169
+ top: verticalBottom + arrowSize
170
+ },
171
+ bottomLeftToRight: {
172
+ left: horizontalLeft,
173
+ top: verticalBottom + arrowSize
174
+ },
175
+ bottomCenterToRight: {
176
+ left: horizontalCenter - arrowHorizontalBalancePx,
177
+ top: verticalBottom + arrowSize
178
+ },
179
+ bottomRight: {
180
+ left: horizontalRight - arrowHorizontalBalancePx,
181
+ top: verticalBottom + arrowSize
182
+ },
183
+ bottomRightToLeft: {
184
+ left: horizontalRight - rect.width,
185
+ top: verticalBottom + arrowSize
186
+ },
187
+ bottomCenterToLeft: {
188
+ left: horizontalCenter - rect.width + arrowHorizontalBalancePx,
189
+ top: verticalBottom + arrowSize
190
+ },
191
+ bottomLeft: {
192
+ left: horizontalLeft - rect.width + arrowHorizontalBalancePx,
193
+ top: verticalBottom + arrowSize
194
+ },
195
+ topCenter: {
196
+ left: horizontalCenter - rect.width / 2,
197
+ bottom: horizontalTop + arrowSize
198
+ },
199
+ topLeftToRight: {
200
+ left: horizontalLeft,
201
+ bottom: horizontalTop + arrowSize
202
+ },
203
+ topCenterToRight: {
204
+ left: horizontalCenter - arrowHorizontalBalancePx,
205
+ bottom: horizontalTop + arrowSize
206
+ },
207
+ topRight: {
208
+ left: horizontalRight - arrowHorizontalBalancePx,
209
+ bottom: horizontalTop + arrowSize
210
+ },
211
+ topRightToLeft: {
212
+ left: horizontalRight - rect.width,
213
+ bottom: horizontalTop + arrowSize
214
+ },
215
+ topCenterToLeft: {
216
+ left: horizontalCenter - rect.width + arrowHorizontalBalancePx,
217
+ bottom: horizontalTop + arrowSize
218
+ },
219
+ topLeft: {
220
+ left: horizontalLeft - rect.width + arrowHorizontalBalancePx,
221
+ top: verticalTop - (rect.height + arrowSize)
222
+ },
223
+ rightCenter: {
224
+ left: horizontalRight + arrowSize,
225
+ top: verticalCenter - rect.height / 2
226
+ },
227
+ rightTopToBottom: {
228
+ left: horizontalRight + arrowSize,
229
+ top: verticalTop
230
+ },
231
+ rightCenterToBottom: {
232
+ left: horizontalRight + arrowSize,
233
+ top: verticalCenter - arrowVerticalBalancePx
234
+ },
235
+ rightBottom: {
236
+ left: horizontalRight + arrowSize,
237
+ top: verticalBottom - arrowVerticalBalancePx
238
+ },
239
+ rightBottomToTop: {
240
+ left: horizontalRight + arrowSize,
241
+ bottom: documentGap.bottom
242
+ },
243
+ rightCenterToTop: {
244
+ left: horizontalRight + arrowSize,
245
+ bottom: verticalCenterToTop - arrowVerticalBalancePx
246
+ },
247
+ rightTop: {
248
+ left: horizontalRight + arrowSize,
249
+ bottom: horizontalTop - arrowVerticalBalancePx
250
+ },
251
+ leftCenter: {
252
+ left: horizontalLeft - (rect.width + arrowSize),
253
+ top: verticalCenter - rect.height / 2
254
+ },
255
+ leftTopToBottom: {
256
+ left: horizontalLeft - (rect.width + arrowSize),
257
+ top: verticalTop
258
+ },
259
+ leftCenterToBottom: {
260
+ left: horizontalLeft - (rect.width + arrowSize),
261
+ top: verticalCenter - arrowVerticalBalancePx
262
+ },
263
+ leftBottom: {
264
+ left: horizontalLeft - (rect.width + arrowSize),
265
+ top: verticalBottom - arrowVerticalBalancePx
266
+ },
267
+ leftBottomToTop: {
268
+ left: horizontalLeft - (rect.width + arrowSize),
269
+ bottom: documentGap.bottom
270
+ },
271
+ leftCenterToTop: {
272
+ left: horizontalLeft - (rect.width + arrowSize),
273
+ bottom: verticalCenterToTop - arrowVerticalBalancePx
274
+ },
275
+ leftTop: {
276
+ left: horizontalLeft - (rect.width + arrowSize),
277
+ bottom: horizontalTop - arrowVerticalBalancePx
278
+ }
279
+ };
280
+ return {
281
+ views,
282
+ viewsOffset,
283
+ targetOffset: relativeBoxRect,
284
+ popupOffset: rect
285
+ };
286
+ },
287
+ getArrowAdjustments: (el, relativeBox, customFrame) => {
288
+ if (!el) {
289
+ return;
290
+ }
291
+
292
+ let elRects = viewPort.frameRelativeRects(el, customFrame);
293
+ let {
294
+ rectGap
295
+ } = elRects;
296
+ let relativeBoxRects = viewPort.frameRelativeRects(relativeBox, customFrame);
297
+ let relativeBoxGap = relativeBoxRects.rectGap;
298
+ return {
299
+ left: relativeBoxGap.center.left - rectGap.left,
300
+ right: relativeBoxGap.center.right - rectGap.right,
301
+ top: relativeBoxGap.center.top - rectGap.top,
302
+ bottom: relativeBoxGap.center.bottom - rectGap.bottom
303
+ };
304
+ },
305
+ betterView: function (popup, relativeBox) {
306
+ let defaultView = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
307
+ let customFrame = arguments.length > 3 ? arguments[3] : undefined;
308
+ let {
309
+ needArrow,
310
+ isAbsolute,
311
+ customOrder = []
312
+ } = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
313
+ let customScrollFrame = isAbsolute ? customFrame : '';
314
+ let viewPortPossibilities = viewPort.possibilities(popup, relativeBox, customScrollFrame, {
315
+ needArrow,
316
+ isAbsolute
317
+ });
318
+
319
+ if (!viewPortPossibilities) {
320
+ return;
321
+ }
322
+
323
+ let {
324
+ views,
325
+ viewsOffset,
326
+ targetOffset,
327
+ popupOffset
328
+ } = viewPortPossibilities;
329
+ let view = null;
330
+ let isViewFound = false;
331
+
332
+ if (!isViewFound && defaultView && views[defaultView]) {
333
+ view = defaultView;
334
+ isViewFound = true;
335
+ }
336
+
337
+ if (!isViewFound) {
338
+ if (customOrder.length > 0) {
339
+ isViewFound = customOrder.some(position => {
340
+ if (views[position]) {
341
+ view = position;
342
+ return true;
343
+ }
344
+ });
345
+ } else {
346
+ isViewFound = defaultOrder.some(position => {
347
+ if (views[position]) {
348
+ view = position;
349
+ return true;
350
+ }
351
+ });
352
+ }
353
+ }
354
+
355
+ if (!isViewFound) {
356
+ view = defaultView;
357
+ }
358
+
359
+ return {
360
+ view,
361
+ views,
362
+ viewsOffset,
363
+ targetOffset,
364
+ popupOffset
365
+ };
366
+ }
367
+ };
368
+ export default {
369
+ betterView: viewPort.betterView,
370
+ frameRelativeRects: viewPort.frameRelativeRects,
371
+ getArrowAdjustments: viewPort.getArrowAdjustments,
372
+ isInViewPort: viewPort.isInViewPort
373
+ };