@progress/kendo-vue-popup 3.5.0 → 3.5.1-dev.202208150613
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/cdn/js/kendo-vue-popup.js +1 -1
- package/dist/es/Popup.js +4 -4
- package/dist/es/models/Align.js +1 -0
- package/dist/es/models/AlignElementSettings.js +1 -0
- package/dist/es/models/Collision.js +1 -0
- package/dist/es/models/CollisionType.js +1 -0
- package/dist/es/models/Events.js +1 -0
- package/dist/es/models/Offset.js +1 -0
- package/dist/es/models/PopupAnimation.js +1 -0
- package/dist/es/models/PopupProps.js +1 -0
- package/dist/es/models/PopupSettings.js +1 -0
- package/dist/es/models/Position.js +1 -0
- package/dist/es/models/positionElementSettings.js +1 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/util.js +2 -2
- package/dist/esm/Popup.d.ts +72 -0
- package/dist/esm/Popup.js +424 -0
- package/dist/esm/additionalTypes.ts +21 -0
- package/dist/esm/main.d.ts +9 -0
- package/dist/esm/main.js +2 -0
- package/dist/esm/models/Align.d.ts +23 -0
- package/dist/esm/models/Align.js +1 -0
- package/dist/esm/models/AlignElementSettings.d.ts +11 -0
- package/dist/esm/models/AlignElementSettings.js +1 -0
- package/dist/esm/models/Collision.d.ts +14 -0
- package/dist/esm/models/Collision.js +1 -0
- package/dist/esm/models/CollisionType.d.ts +8 -0
- package/dist/esm/models/CollisionType.js +1 -0
- package/dist/esm/models/Events.d.ts +18 -0
- package/dist/esm/models/Events.js +1 -0
- package/dist/esm/models/Offset.d.ts +13 -0
- package/dist/esm/models/Offset.js +1 -0
- package/dist/esm/models/PopupAnimation.d.ts +13 -0
- package/dist/esm/models/PopupAnimation.js +1 -0
- package/dist/esm/models/PopupProps.d.ts +10 -0
- package/dist/esm/models/PopupProps.js +1 -0
- package/dist/esm/models/PopupSettings.d.ts +68 -0
- package/dist/esm/models/PopupSettings.js +2 -0
- package/dist/esm/models/Position.d.ts +8 -0
- package/dist/esm/models/Position.js +1 -0
- package/dist/esm/models/positionElementSettings.d.ts +13 -0
- package/dist/esm/models/positionElementSettings.js +1 -0
- package/dist/esm/package-metadata.d.ts +5 -0
- package/dist/esm/package-metadata.js +11 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/services/alignService.d.ts +14 -0
- package/dist/esm/services/alignService.js +43 -0
- package/dist/esm/services/domService.d.ts +34 -0
- package/dist/esm/services/domService.js +139 -0
- package/dist/esm/services/positionService.d.ts +12 -0
- package/dist/esm/services/positionService.js +34 -0
- package/dist/esm/util.d.ts +74 -0
- package/dist/esm/util.js +254 -0
- package/dist/npm/Popup.js +10 -10
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/services/alignService.js +3 -3
- package/dist/npm/services/domService.js +18 -18
- package/dist/npm/services/positionService.js +2 -2
- package/dist/npm/util.js +42 -30
- package/package.json +9 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AlignStrategy, CollisionStrategy, OffsetPosition, ViewPort } from '@progress/kendo-popup-common';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
export interface PositionElementSettings {
|
|
6
|
+
anchor?: HTMLElement;
|
|
7
|
+
anchorAlign: AlignStrategy;
|
|
8
|
+
collisions: CollisionStrategy;
|
|
9
|
+
currentLocation: OffsetPosition;
|
|
10
|
+
element: HTMLElement;
|
|
11
|
+
elementAlign: AlignStrategy;
|
|
12
|
+
viewPort?: ViewPort;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
export var packageMetadata = {
|
|
5
|
+
name: '@progress/kendo-vue-popup',
|
|
6
|
+
productName: 'Kendo UI for Vue',
|
|
7
|
+
productCodes: ['KENDOUIVUE', 'KENDOUICOMPLETE'],
|
|
8
|
+
publishDate: 1660542994,
|
|
9
|
+
version: '',
|
|
10
|
+
licensingDocsUrl: 'https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning'
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DOMService } from './domService';
|
|
2
|
+
import { OffsetPosition as Offset } from '@progress/kendo-popup-common';
|
|
3
|
+
import { AlignElementSettings } from '../models/AlignElementSettings';
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export declare class AlignService {
|
|
8
|
+
private _dom;
|
|
9
|
+
constructor(_dom: DOMService);
|
|
10
|
+
alignElement(settings: AlignElementSettings): Offset;
|
|
11
|
+
private absoluteRect;
|
|
12
|
+
private elementScrollPosition;
|
|
13
|
+
private relativeRect;
|
|
14
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { eitherRect, removeStackingOffset } from '../util.js';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
var AlignService = /** @class */ (function () {
|
|
6
|
+
function AlignService(_dom) {
|
|
7
|
+
this._dom = _dom;
|
|
8
|
+
}
|
|
9
|
+
AlignService.prototype.alignElement = function (settings) {
|
|
10
|
+
var anchor = settings.anchor, element = settings.element, anchorAlign = settings.anchorAlign, elementAlign = settings.elementAlign, offset = settings.offset;
|
|
11
|
+
var fixedMode = !this._dom.hasOffsetParent(element);
|
|
12
|
+
var anchorRect = fixedMode ?
|
|
13
|
+
this.absoluteRect(anchor, element, offset) :
|
|
14
|
+
this.relativeRect(anchor, element, offset);
|
|
15
|
+
return this._dom.align({
|
|
16
|
+
anchorAlign: anchorAlign,
|
|
17
|
+
anchorRect: anchorRect,
|
|
18
|
+
elementAlign: elementAlign,
|
|
19
|
+
elementRect: this._dom.offset(element)
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
AlignService.prototype.absoluteRect = function (anchor, element, offset) {
|
|
23
|
+
var dom = this._dom;
|
|
24
|
+
var rect = eitherRect(dom.offset(anchor), offset);
|
|
25
|
+
var stackingOffset = dom.stackingElementOffset(element);
|
|
26
|
+
var removedOffset = removeStackingOffset(rect, stackingOffset);
|
|
27
|
+
var stackingScroll = dom.stackingElementScroll(element);
|
|
28
|
+
var withScroll = dom.addScroll(removedOffset, stackingScroll);
|
|
29
|
+
var scrollPosition = this.elementScrollPosition(anchor, element);
|
|
30
|
+
var result = dom.removeScroll(withScroll, scrollPosition);
|
|
31
|
+
result.left += window.scrollX || window.pageXOffset;
|
|
32
|
+
result.top += window.scrollY || window.pageYOffset;
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
AlignService.prototype.elementScrollPosition = function (anchor, element) {
|
|
36
|
+
return anchor ? { x: 0, y: 0 } : this._dom.scrollPosition(element);
|
|
37
|
+
};
|
|
38
|
+
AlignService.prototype.relativeRect = function (anchor, element, offset) {
|
|
39
|
+
return eitherRect(this._dom.position(anchor, element), offset);
|
|
40
|
+
};
|
|
41
|
+
return AlignService;
|
|
42
|
+
}());
|
|
43
|
+
export { AlignService };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AlignSettings, BoundingRect, ElementRect, OffsetPosition, PositionSettings, ScrollInfo, ViewPort } from '@progress/kendo-popup-common';
|
|
2
|
+
import { Position } from '../models/Position';
|
|
3
|
+
/**
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
export declare class DOMService {
|
|
7
|
+
addOffset(current: OffsetPosition, addition: OffsetPosition): OffsetPosition;
|
|
8
|
+
align(settings: AlignSettings): OffsetPosition;
|
|
9
|
+
boundingOffset(el: HTMLElement): BoundingRect;
|
|
10
|
+
getWindow(): Window & typeof globalThis;
|
|
11
|
+
isBodyOffset(el: HTMLElement): boolean;
|
|
12
|
+
hasOffsetParent(el: HTMLElement): boolean | null;
|
|
13
|
+
offset(el: HTMLElement): ElementRect;
|
|
14
|
+
staticOffset(element: HTMLElement): ElementRect;
|
|
15
|
+
position(element: HTMLElement, popup: HTMLElement): ElementRect;
|
|
16
|
+
relativeOffset(el: HTMLElement, currentLocation: OffsetPosition): ElementRect;
|
|
17
|
+
addScroll(rect: ElementRect, scroll: ScrollInfo): ElementRect;
|
|
18
|
+
removeScroll(rect: ElementRect, scroll: ScrollInfo): ElementRect;
|
|
19
|
+
restrictToView(settings: PositionSettings): Position;
|
|
20
|
+
scrollPosition(el: HTMLElement): ScrollInfo;
|
|
21
|
+
scrollableParents(el: HTMLElement): Array<HTMLElement>;
|
|
22
|
+
stackingElementOffset(el: HTMLElement): ElementRect;
|
|
23
|
+
stackingElementScroll(el: HTMLElement): ScrollInfo;
|
|
24
|
+
stackingElementViewPort(el: HTMLElement): {
|
|
25
|
+
height: number;
|
|
26
|
+
width: number;
|
|
27
|
+
};
|
|
28
|
+
getRelativeContextElement(el: HTMLElement): HTMLElement;
|
|
29
|
+
useRelativePosition(el: HTMLElement): boolean;
|
|
30
|
+
windowViewPort(el: HTMLElement): ViewPort;
|
|
31
|
+
zIndex(anchor: HTMLElement, container: HTMLElement): number;
|
|
32
|
+
zoomLevel(): number;
|
|
33
|
+
isZoomed(): boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { align, applyLocationOffset, boundingOffset, getWindowViewPort, isBodyOffset, offset, positionWithScroll, restrictToView, addScroll, removeScroll, scrollPosition, siblingContainer } from '@progress/kendo-popup-common';
|
|
2
|
+
import { isDocumentAvailable, isWindowAvailable, HAS_RELATIVE_STACKING_CONTEXT, scrollableParents, zIndex } from '../util.js';
|
|
3
|
+
/**
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
var DOMService = /** @class */ (function () {
|
|
7
|
+
function DOMService() {
|
|
8
|
+
}
|
|
9
|
+
DOMService.prototype.addOffset = function (current, addition) {
|
|
10
|
+
return {
|
|
11
|
+
left: current.left + addition.left,
|
|
12
|
+
top: current.top + addition.top
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
DOMService.prototype.align = function (settings) {
|
|
16
|
+
return align(settings);
|
|
17
|
+
};
|
|
18
|
+
DOMService.prototype.boundingOffset = function (el) {
|
|
19
|
+
return boundingOffset(el);
|
|
20
|
+
};
|
|
21
|
+
DOMService.prototype.getWindow = function () {
|
|
22
|
+
return isWindowAvailable() ? window : null;
|
|
23
|
+
};
|
|
24
|
+
DOMService.prototype.isBodyOffset = function (el) {
|
|
25
|
+
return isBodyOffset(el);
|
|
26
|
+
};
|
|
27
|
+
DOMService.prototype.hasOffsetParent = function (el) {
|
|
28
|
+
if (!el) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
var offsetParentEl = el.offsetParent;
|
|
32
|
+
return offsetParentEl &&
|
|
33
|
+
!(offsetParentEl.nodeName === 'BODY' &&
|
|
34
|
+
window.getComputedStyle(offsetParentEl).position === 'static');
|
|
35
|
+
};
|
|
36
|
+
DOMService.prototype.offset = function (el) {
|
|
37
|
+
if (!el) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return offset(el);
|
|
41
|
+
};
|
|
42
|
+
DOMService.prototype.staticOffset = function (element) {
|
|
43
|
+
if (!element) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
var _a = element.style, left = _a.left, top = _a.top;
|
|
47
|
+
element.style.left = '0px';
|
|
48
|
+
element.style.top = '0px';
|
|
49
|
+
var currentOffset = offset(element);
|
|
50
|
+
element.style.left = left;
|
|
51
|
+
element.style.top = top;
|
|
52
|
+
return currentOffset;
|
|
53
|
+
};
|
|
54
|
+
DOMService.prototype.position = function (element, popup) {
|
|
55
|
+
if (!element || !popup) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
var parentSibling = siblingContainer(element, popup);
|
|
59
|
+
return positionWithScroll(element, parentSibling);
|
|
60
|
+
};
|
|
61
|
+
DOMService.prototype.relativeOffset = function (el, currentLocation) {
|
|
62
|
+
return applyLocationOffset(this.offset(el), currentLocation, this.isBodyOffset(el));
|
|
63
|
+
};
|
|
64
|
+
DOMService.prototype.addScroll = function (rect, scroll) {
|
|
65
|
+
return addScroll(rect, scroll);
|
|
66
|
+
};
|
|
67
|
+
DOMService.prototype.removeScroll = function (rect, scroll) {
|
|
68
|
+
return removeScroll(rect, scroll);
|
|
69
|
+
};
|
|
70
|
+
DOMService.prototype.restrictToView = function (settings) {
|
|
71
|
+
return restrictToView(settings);
|
|
72
|
+
};
|
|
73
|
+
DOMService.prototype.scrollPosition = function (el) {
|
|
74
|
+
return scrollPosition(el);
|
|
75
|
+
};
|
|
76
|
+
DOMService.prototype.scrollableParents = function (el) {
|
|
77
|
+
return scrollableParents(el);
|
|
78
|
+
};
|
|
79
|
+
DOMService.prototype.stackingElementOffset = function (el) {
|
|
80
|
+
var relativeContextElement = this.getRelativeContextElement(el);
|
|
81
|
+
if (!relativeContextElement) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return offset(relativeContextElement);
|
|
85
|
+
};
|
|
86
|
+
DOMService.prototype.stackingElementScroll = function (el) {
|
|
87
|
+
var relativeContextElement = this.getRelativeContextElement(el);
|
|
88
|
+
if (!relativeContextElement) {
|
|
89
|
+
return { x: 0, y: 0 };
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
x: relativeContextElement.scrollLeft,
|
|
93
|
+
y: relativeContextElement.scrollTop
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
DOMService.prototype.stackingElementViewPort = function (el) {
|
|
97
|
+
var relativeContextElement = this.getRelativeContextElement(el);
|
|
98
|
+
if (!relativeContextElement) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
height: relativeContextElement.scrollHeight,
|
|
103
|
+
width: relativeContextElement.scrollWidth
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
DOMService.prototype.getRelativeContextElement = function (el) {
|
|
107
|
+
if (!el || !HAS_RELATIVE_STACKING_CONTEXT) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
var parent = el.parentElement;
|
|
111
|
+
while (parent) {
|
|
112
|
+
if (window.getComputedStyle(parent).transform !== 'none') {
|
|
113
|
+
return parent;
|
|
114
|
+
}
|
|
115
|
+
parent = parent.parentElement;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
};
|
|
119
|
+
DOMService.prototype.useRelativePosition = function (el) {
|
|
120
|
+
return !!this.getRelativeContextElement(el);
|
|
121
|
+
};
|
|
122
|
+
DOMService.prototype.windowViewPort = function (el) {
|
|
123
|
+
return getWindowViewPort(el);
|
|
124
|
+
};
|
|
125
|
+
DOMService.prototype.zIndex = function (anchor, container) {
|
|
126
|
+
return zIndex(anchor, container);
|
|
127
|
+
};
|
|
128
|
+
DOMService.prototype.zoomLevel = function () {
|
|
129
|
+
if (!isDocumentAvailable() || !isWindowAvailable()) {
|
|
130
|
+
return 1;
|
|
131
|
+
}
|
|
132
|
+
return parseFloat((document.documentElement.clientWidth / window.innerWidth).toFixed(2));
|
|
133
|
+
};
|
|
134
|
+
DOMService.prototype.isZoomed = function () {
|
|
135
|
+
return this.zoomLevel() > 1;
|
|
136
|
+
};
|
|
137
|
+
return DOMService;
|
|
138
|
+
}());
|
|
139
|
+
export { DOMService };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PositionElementSettings } from '../models/positionElementSettings';
|
|
2
|
+
import { Position } from '../models/Position';
|
|
3
|
+
import { DOMService } from './domService';
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export declare class PositionService {
|
|
8
|
+
private _dom;
|
|
9
|
+
constructor(_dom: DOMService);
|
|
10
|
+
positionElement(settings: PositionElementSettings): Position;
|
|
11
|
+
private elementRect;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { eitherRect, replaceOffset } from '../util.js';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
var PositionService = /** @class */ (function () {
|
|
6
|
+
function PositionService(_dom) {
|
|
7
|
+
this._dom = _dom;
|
|
8
|
+
}
|
|
9
|
+
PositionService.prototype.positionElement = function (settings) {
|
|
10
|
+
var anchor = settings.anchor, currentLocation = settings.currentLocation, element = settings.element, anchorAlign = settings.anchorAlign, elementAlign = settings.elementAlign, collisions = settings.collisions;
|
|
11
|
+
var dom = this._dom;
|
|
12
|
+
var viewPort = settings.viewPort || dom.stackingElementViewPort(element) || dom.windowViewPort(element);
|
|
13
|
+
var anchorRect = eitherRect(dom.offset(anchor), currentLocation);
|
|
14
|
+
var initialElementRect = replaceOffset(dom.staticOffset(element), currentLocation);
|
|
15
|
+
var elementRect = this.elementRect(element, initialElementRect);
|
|
16
|
+
var result = dom.restrictToView({
|
|
17
|
+
anchorAlign: anchorAlign,
|
|
18
|
+
anchorRect: anchorRect,
|
|
19
|
+
collisions: collisions,
|
|
20
|
+
elementAlign: elementAlign,
|
|
21
|
+
elementRect: elementRect,
|
|
22
|
+
viewPort: viewPort
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
flipped: result.flipped,
|
|
26
|
+
offset: dom.addOffset(initialElementRect, result.offset)
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
PositionService.prototype.elementRect = function (element, rect) {
|
|
30
|
+
return this._dom.removeScroll(rect, this._dom.scrollPosition(element));
|
|
31
|
+
};
|
|
32
|
+
return PositionService;
|
|
33
|
+
}());
|
|
34
|
+
export { PositionService };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ElementRect, OffsetPosition } from '@progress/kendo-popup-common';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
export declare const eitherRect: (rect: ElementRect | null, offset: OffsetPosition) => ElementRect;
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export declare const replaceOffset: (rect: ElementRect, offset: OffsetPosition) => ElementRect;
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
export declare const removeStackingOffset: (rect: ElementRect, stackingOffset: ElementRect | null) => ElementRect;
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
|
+
export declare const isDifferentOffset: (oldOffset: OffsetPosition, newOffset: OffsetPosition) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
export declare const isDocumentAvailable: () => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @hidden
|
|
24
|
+
*/
|
|
25
|
+
export declare const isWindowAvailable: () => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @hidden
|
|
28
|
+
*/
|
|
29
|
+
export declare const hasBoundingRect: (elem: HTMLElement) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
33
|
+
export declare const OVERFLOW_REGEXP: RegExp;
|
|
34
|
+
/**
|
|
35
|
+
* @hidden
|
|
36
|
+
*/
|
|
37
|
+
export declare const scrollableParents: (element: HTMLElement) => any[];
|
|
38
|
+
/**
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
export declare const FRAME_DURATION: number;
|
|
42
|
+
/**
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
export declare const hasRelativeStackingContext: () => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* @hidden
|
|
48
|
+
*/
|
|
49
|
+
export declare const HAS_RELATIVE_STACKING_CONTEXT: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* @hidden
|
|
52
|
+
*/
|
|
53
|
+
export declare const zIndex: (anchor: HTMLElement, container: HTMLElement) => number;
|
|
54
|
+
/**
|
|
55
|
+
* @hidden
|
|
56
|
+
*/
|
|
57
|
+
export declare const CollisionType: {
|
|
58
|
+
fit: string;
|
|
59
|
+
flip: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* @hidden
|
|
63
|
+
*/
|
|
64
|
+
export declare const AlignPoint: {
|
|
65
|
+
left: string;
|
|
66
|
+
center: string;
|
|
67
|
+
right: string;
|
|
68
|
+
bottom: string;
|
|
69
|
+
top: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @hidden
|
|
73
|
+
*/
|
|
74
|
+
export declare const throttle: (func: Function, wait: number, options?: any) => () => any;
|
package/dist/esm/util.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { parents, siblingContainer } from '@progress/kendo-popup-common';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export var eitherRect = function eitherRect(rect, offset) {
|
|
7
|
+
if (!rect) {
|
|
8
|
+
return {
|
|
9
|
+
height: 0,
|
|
10
|
+
left: offset.left,
|
|
11
|
+
top: offset.top,
|
|
12
|
+
width: 0
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return rect;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export var replaceOffset = function replaceOffset(rect, offset) {
|
|
23
|
+
if (!offset) {
|
|
24
|
+
return rect;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var result = {
|
|
28
|
+
height: rect.height,
|
|
29
|
+
left: offset.left,
|
|
30
|
+
top: offset.top,
|
|
31
|
+
width: rect.width
|
|
32
|
+
};
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @hidden
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
export var removeStackingOffset = function removeStackingOffset(rect, stackingOffset) {
|
|
40
|
+
if (!stackingOffset) {
|
|
41
|
+
return rect;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var result = {
|
|
45
|
+
height: rect.height,
|
|
46
|
+
left: rect.left - stackingOffset.left,
|
|
47
|
+
top: rect.top - stackingOffset.top,
|
|
48
|
+
width: rect.width
|
|
49
|
+
};
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
export var isDifferentOffset = function isDifferentOffset(oldOffset, newOffset) {
|
|
57
|
+
var oldLeft = oldOffset.left,
|
|
58
|
+
oldTop = oldOffset.top;
|
|
59
|
+
var newLeft = newOffset.left,
|
|
60
|
+
newTop = newOffset.top;
|
|
61
|
+
return Math.abs(oldLeft - newLeft) >= 1 || Math.abs(oldTop - newTop) >= 1;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
export var isDocumentAvailable = function isDocumentAvailable() {
|
|
68
|
+
return typeof document !== 'undefined' && !!document.body;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* @hidden
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
export var isWindowAvailable = function isWindowAvailable() {
|
|
75
|
+
return typeof window !== 'undefined';
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @hidden
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
export var hasBoundingRect = function hasBoundingRect(elem) {
|
|
82
|
+
return !!elem.getBoundingClientRect;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* @hidden
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
export var OVERFLOW_REGEXP = /auto|scroll/;
|
|
89
|
+
/**
|
|
90
|
+
* @hidden
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
var overflowStyle = function overflowStyle(element) {
|
|
94
|
+
var styles = window.getComputedStyle(element);
|
|
95
|
+
return "".concat(styles.overflow).concat(styles.overflowX).concat(styles.overflowY);
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* @hidden
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
export var scrollableParents = function scrollableParents(element) {
|
|
103
|
+
var parentElements = [];
|
|
104
|
+
|
|
105
|
+
if (!isDocumentAvailable() || !isWindowAvailable()) {
|
|
106
|
+
return parentElements;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var parent = element.parentElement;
|
|
110
|
+
|
|
111
|
+
while (parent) {
|
|
112
|
+
if (OVERFLOW_REGEXP.test(overflowStyle(parent))) {
|
|
113
|
+
parentElements.push(parent);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
parent = parent.parentElement;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
parentElements.push(window);
|
|
120
|
+
return parentElements;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* @hidden
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
export var FRAME_DURATION = 1000 / 60; // 1000ms divided by 60fps
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @hidden
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
export var hasRelativeStackingContext = function hasRelativeStackingContext() {
|
|
133
|
+
if (!isDocumentAvailable()) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var top = 10;
|
|
138
|
+
var parent = document.createElement('div');
|
|
139
|
+
parent.style.transform = 'matrix(10, 0, 0, 10, 0, 0)';
|
|
140
|
+
parent.innerHTML = "<div>child</div>";
|
|
141
|
+
document.body.appendChild(parent);
|
|
142
|
+
|
|
143
|
+
if (parent && parent.firstChild) {
|
|
144
|
+
var firstChild = parent.firstChild;
|
|
145
|
+
firstChild.style.position = 'fixed';
|
|
146
|
+
firstChild.style.top = "".concat(top, "px");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var isDifferent = parent.children[0].getBoundingClientRect().top !== top;
|
|
150
|
+
document.body.removeChild(parent);
|
|
151
|
+
return isDifferent;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* @hidden
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
export var HAS_RELATIVE_STACKING_CONTEXT = hasRelativeStackingContext();
|
|
158
|
+
/**
|
|
159
|
+
* @hidden
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
export var zIndex = function zIndex(anchor, container) {
|
|
163
|
+
if (!anchor || !isDocumentAvailable() || !isWindowAvailable()) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
var sibling = siblingContainer(anchor, container);
|
|
168
|
+
|
|
169
|
+
if (!sibling) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
var result = [anchor].concat(parents(anchor, sibling)).reduce(function (index, p) {
|
|
174
|
+
var zIndexStyle = p.style.zIndex || window.getComputedStyle(p).zIndex;
|
|
175
|
+
var current = parseInt(zIndexStyle, 10);
|
|
176
|
+
return current > index ? current : index;
|
|
177
|
+
}, 0);
|
|
178
|
+
return result ? result + 1 : null;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* @hidden
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
export var CollisionType = {
|
|
185
|
+
fit: 'fit',
|
|
186
|
+
flip: 'flip'
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* @hidden
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
export var AlignPoint = {
|
|
193
|
+
left: 'left',
|
|
194
|
+
center: 'center',
|
|
195
|
+
right: 'right',
|
|
196
|
+
bottom: 'bottom',
|
|
197
|
+
top: 'top'
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* @hidden
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
export var throttle = function throttle(func, wait, options) {
|
|
204
|
+
if (options === void 0) {
|
|
205
|
+
options = {};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
var timeout, context, args, result;
|
|
209
|
+
var previous = 0;
|
|
210
|
+
options = options || {};
|
|
211
|
+
|
|
212
|
+
var later = function later() {
|
|
213
|
+
previous = options.leading === false ? 0 : new Date().getTime();
|
|
214
|
+
timeout = null;
|
|
215
|
+
result = func.apply(context, args);
|
|
216
|
+
|
|
217
|
+
if (!timeout) {
|
|
218
|
+
context = args = null;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
var throttled = function throttled() {
|
|
223
|
+
var now = new Date().getTime();
|
|
224
|
+
|
|
225
|
+
if (!previous && options.leading === false) {
|
|
226
|
+
previous = now;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
var remaining = wait - (now - previous); // @ts-ignore
|
|
230
|
+
|
|
231
|
+
context = this;
|
|
232
|
+
args = arguments;
|
|
233
|
+
|
|
234
|
+
if (remaining <= 0 || remaining > wait) {
|
|
235
|
+
if (timeout) {
|
|
236
|
+
clearTimeout(timeout);
|
|
237
|
+
timeout = null;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
previous = now;
|
|
241
|
+
result = func.apply(context, args);
|
|
242
|
+
|
|
243
|
+
if (!timeout) {
|
|
244
|
+
context = args = null;
|
|
245
|
+
}
|
|
246
|
+
} else if (!timeout && options.trailing !== false) {
|
|
247
|
+
timeout = setTimeout(later, remaining);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return result;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return throttled;
|
|
254
|
+
};
|