@progress/kendo-angular-popup 4.0.6-dev.202203161114 → 5.0.0-dev.202204191152

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 (115) hide show
  1. package/bundles/kendo-angular-popup.umd.js +5 -0
  2. package/{dist/es2015/models/position-mode.js → esm2015/kendo-angular-popup.js} +2 -1
  3. package/{dist/es → esm2015}/main.js +0 -0
  4. package/{dist/es → esm2015}/models/align-element-settings.interface.js +1 -0
  5. package/{dist/es2015 → esm2015}/models/align.interface.js +1 -0
  6. package/{dist/es2015 → esm2015}/models/collision.interface.js +1 -0
  7. package/{dist/es2015 → esm2015}/models/collision.type.js +1 -0
  8. package/{dist/es → esm2015}/models/margin.interface.js +1 -0
  9. package/{dist/es → esm2015}/models/offset.interface.js +1 -0
  10. package/{dist/es → esm2015}/models/popup-animation.interface.js +1 -0
  11. package/{dist/es → esm2015}/models/popup-ref.js +1 -0
  12. package/{dist/es → esm2015}/models/popup-settings.js +1 -0
  13. package/{dist/es → esm2015}/models/position-element-settings.interface.js +1 -0
  14. package/{dist/es → esm2015}/models/position-mode.js +1 -0
  15. package/{dist/es → esm2015}/models/position.interface.js +1 -0
  16. package/{dist/es2015 → esm2015}/package-metadata.js +1 -1
  17. package/{dist/es2015 → esm2015}/popup.component.js +64 -86
  18. package/{dist/es2015 → esm2015}/popup.module.js +16 -13
  19. package/{dist/es2015 → esm2015}/popup.service.js +14 -15
  20. package/{dist/es2015 → esm2015}/scale.js +0 -0
  21. package/{dist/es2015 → esm2015}/services/align.service.js +14 -10
  22. package/{dist/es2015 → esm2015}/services/animation.service.js +10 -10
  23. package/{dist/es2015 → esm2015}/services/dom.service.js +9 -8
  24. package/{dist/es2015 → esm2015}/services/position.service.js +14 -10
  25. package/{dist/es2015 → esm2015}/services/resize.service.js +10 -10
  26. package/{dist/es2015 → esm2015}/services/scrollable.service.js +10 -10
  27. package/{dist/es2015 → esm2015}/util.js +5 -10
  28. package/{dist/fesm2015/index.js → fesm2015/kendo-angular-popup.js} +205 -192
  29. package/kendo-angular-popup.d.ts +9 -0
  30. package/{dist/es2015/main.d.ts → main.d.ts} +1 -1
  31. package/{dist/es2015/models → models}/align-element-settings.interface.d.ts +0 -0
  32. package/{dist/es2015/models → models}/align.interface.d.ts +0 -0
  33. package/{dist/es2015/models → models}/collision.interface.d.ts +0 -0
  34. package/{dist/es2015/models → models}/collision.type.d.ts +0 -0
  35. package/{dist/es2015/models → models}/margin.interface.d.ts +0 -0
  36. package/{dist/es2015/models → models}/offset.interface.d.ts +0 -0
  37. package/{dist/es2015/models → models}/popup-animation.interface.d.ts +4 -2
  38. package/{dist/es2015/models → models}/popup-ref.d.ts +0 -0
  39. package/{dist/es2015/models → models}/popup-settings.d.ts +0 -0
  40. package/{dist/es2015/models → models}/position-element-settings.interface.d.ts +0 -0
  41. package/{dist/es2015/models → models}/position-mode.d.ts +0 -0
  42. package/{dist/es2015/models → models}/position.interface.d.ts +0 -0
  43. package/{dist/es2015/package-metadata.d.ts → package-metadata.d.ts} +0 -0
  44. package/package.json +30 -97
  45. package/{dist/es2015/popup.component.d.ts → popup.component.d.ts} +5 -1
  46. package/{dist/es2015/popup.module.d.ts → popup.module.d.ts} +7 -0
  47. package/{dist/es2015/popup.service.d.ts → popup.service.d.ts} +5 -2
  48. package/{dist/es2015/scale.d.ts → scale.d.ts} +0 -0
  49. package/schematics/ngAdd/index.js +5 -2
  50. package/schematics/ngAdd/index.js.map +1 -1
  51. package/{dist/es2015/services → services}/align.service.d.ts +3 -0
  52. package/{dist/es2015/services → services}/animation.service.d.ts +3 -0
  53. package/{dist/es2015/services → services}/dom.service.d.ts +3 -0
  54. package/{dist/es2015/services → services}/position.service.d.ts +3 -0
  55. package/{dist/es2015/services → services}/resize.service.d.ts +3 -0
  56. package/{dist/es2015/services → services}/scrollable.service.d.ts +3 -0
  57. package/{dist/es2015/util.d.ts → util.d.ts} +1 -1
  58. package/dist/cdn/js/kendo-angular-popup.js +0 -20
  59. package/dist/cdn/main.js +0 -5
  60. package/dist/es/index.js +0 -14
  61. package/dist/es/models/align.interface.js +0 -4
  62. package/dist/es/models/collision.interface.js +0 -4
  63. package/dist/es/models/collision.type.js +0 -4
  64. package/dist/es/package-metadata.js +0 -15
  65. package/dist/es/popup.component.js +0 -438
  66. package/dist/es/popup.module.js +0 -57
  67. package/dist/es/popup.service.js +0 -254
  68. package/dist/es/scale.js +0 -21
  69. package/dist/es/services/align.service.js +0 -64
  70. package/dist/es/services/animation.service.js +0 -137
  71. package/dist/es/services/dom.service.js +0 -158
  72. package/dist/es/services/position.service.js +0 -53
  73. package/dist/es/services/resize.service.js +0 -46
  74. package/dist/es/services/scrollable.service.js +0 -78
  75. package/dist/es/util.js +0 -168
  76. package/dist/es2015/index.d.ts +0 -14
  77. package/dist/es2015/index.js +0 -14
  78. package/dist/es2015/index.metadata.json +0 -1
  79. package/dist/es2015/main.js +0 -8
  80. package/dist/es2015/models/align-element-settings.interface.js +0 -4
  81. package/dist/es2015/models/margin.interface.js +0 -4
  82. package/dist/es2015/models/offset.interface.js +0 -4
  83. package/dist/es2015/models/popup-animation.interface.js +0 -4
  84. package/dist/es2015/models/popup-ref.js +0 -4
  85. package/dist/es2015/models/popup-settings.js +0 -4
  86. package/dist/es2015/models/position-element-settings.interface.js +0 -4
  87. package/dist/es2015/models/position.interface.js +0 -4
  88. package/dist/fesm5/index.js +0 -1381
  89. package/dist/npm/index.js +0 -23
  90. package/dist/npm/main.js +0 -15
  91. package/dist/npm/models/align-element-settings.interface.js +0 -6
  92. package/dist/npm/models/align.interface.js +0 -6
  93. package/dist/npm/models/collision.interface.js +0 -6
  94. package/dist/npm/models/collision.type.js +0 -6
  95. package/dist/npm/models/margin.interface.js +0 -6
  96. package/dist/npm/models/offset.interface.js +0 -6
  97. package/dist/npm/models/popup-animation.interface.js +0 -6
  98. package/dist/npm/models/popup-ref.js +0 -6
  99. package/dist/npm/models/popup-settings.js +0 -6
  100. package/dist/npm/models/position-element-settings.interface.js +0 -6
  101. package/dist/npm/models/position-mode.js +0 -9
  102. package/dist/npm/models/position.interface.js +0 -6
  103. package/dist/npm/package-metadata.js +0 -17
  104. package/dist/npm/popup.component.js +0 -440
  105. package/dist/npm/popup.module.js +0 -59
  106. package/dist/npm/popup.service.js +0 -256
  107. package/dist/npm/scale.js +0 -23
  108. package/dist/npm/services/align.service.js +0 -66
  109. package/dist/npm/services/animation.service.js +0 -139
  110. package/dist/npm/services/dom.service.js +0 -160
  111. package/dist/npm/services/position.service.js +0 -55
  112. package/dist/npm/services/resize.service.js +0 -48
  113. package/dist/npm/services/scrollable.service.js +0 -80
  114. package/dist/npm/util.js +0 -173
  115. package/dist/systemjs/kendo-angular-popup.js +0 -5
@@ -1,1381 +0,0 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the project root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- import { __decorate, __param, __metadata } from 'tslib';
6
- import { Injectable, InjectionToken, Inject, Optional, NgZone, isDevMode, EventEmitter, Input, Output, ViewChild, ElementRef, Component, Renderer2, TemplateRef, ApplicationRef, ComponentFactoryResolver, Injector, NgModule } from '@angular/core';
7
- import { siblingContainer, parents, addScroll, align, boundingOffset, offset, positionWithScroll, removeScroll, restrictToView, scrollPosition, getWindowViewPort } from '@progress/kendo-popup-common';
8
- import { isDocumentAvailable, hasObservers, ResizeSensorComponent, ResizeSensorModule } from '@progress/kendo-angular-common';
9
- import { fromEvent, merge, from } from 'rxjs';
10
- import { auditTime } from 'rxjs/operators';
11
- import { style, animate, AnimationBuilder } from '@angular/animations';
12
- import { validatePackage } from '@progress/kendo-licensing';
13
- import { CommonModule } from '@angular/common';
14
-
15
- /**
16
- * @hidden
17
- */
18
- var eitherRect = function (rect, offset$$1) {
19
- if (!rect) {
20
- return { height: 0, left: offset$$1.left, top: offset$$1.top, width: 0 };
21
- }
22
- return rect;
23
- };
24
- /**
25
- * @hidden
26
- */
27
- var removeStackingOffset = function (rect, stackingOffset) {
28
- if (!stackingOffset) {
29
- return rect;
30
- }
31
- var result = {
32
- height: rect.height,
33
- left: rect.left - stackingOffset.left,
34
- top: rect.top - stackingOffset.top,
35
- width: rect.width
36
- };
37
- return result;
38
- };
39
- /**
40
- * @hidden
41
- */
42
- var isDifferentOffset = function (oldOffset, newOffset) {
43
- var oldLeft = oldOffset.left, oldTop = oldOffset.top;
44
- var newLeft = newOffset.left, newTop = newOffset.top;
45
- return Math.abs(oldLeft - newLeft) >= 1 || Math.abs(oldTop - newTop) >= 1;
46
- };
47
- /**
48
- * @hidden
49
- */
50
- var isWindowAvailable = function () {
51
- return typeof window !== 'undefined';
52
- };
53
- /**
54
- * @hidden
55
- */
56
- var OVERFLOW_REGEXP = /auto|scroll/;
57
- var overflowElementStyle = function (element) {
58
- return "" + element.style.overflow + element.style.overflowX + element.style.overflowY;
59
- };
60
- var overflowComputedStyle = function (element) {
61
- var styles = window.getComputedStyle(element);
62
- return "" + styles.overflow + styles.overflowX + styles.overflowY;
63
- };
64
- var overflowStyle = function (element) {
65
- return overflowElementStyle(element) || overflowComputedStyle(element);
66
- };
67
- /**
68
- * @hidden
69
- */
70
- var scrollableParents = function (element) {
71
- var parentElements = [];
72
- if (!isDocumentAvailable() || !isWindowAvailable()) {
73
- return parentElements;
74
- }
75
- var parent = element.parentElement;
76
- while (parent) {
77
- if (OVERFLOW_REGEXP.test(overflowStyle(parent)) || parent.hasAttribute('data-scrollable')) {
78
- parentElements.push(parent);
79
- }
80
- parent = parent.parentElement;
81
- }
82
- parentElements.push(window);
83
- return parentElements;
84
- };
85
- /**
86
- * @hidden
87
- */
88
- var FRAME_DURATION = 1000 / 60; //1000ms divided by 60fps
89
- function memoize(fun) {
90
- var result;
91
- var called = false;
92
- return function () {
93
- var args = [];
94
- for (var _i = 0; _i < arguments.length; _i++) {
95
- args[_i] = arguments[_i];
96
- }
97
- if (called) {
98
- return result;
99
- }
100
- result = fun.apply(void 0, args);
101
- called = true;
102
- return result;
103
- };
104
- }
105
- var ɵ3 = function () {
106
- if (!isDocumentAvailable() && document.body !== null) {
107
- return false;
108
- }
109
- var top = 10;
110
- var parent = document.createElement("div");
111
- parent.style.transform = "matrix(10, 0, 0, 10, 0, 0)";
112
- parent.innerHTML = "<div style=\"position: fixed; top: " + top + "px;\">child</div>";
113
- document.body.appendChild(parent);
114
- var isDifferent = parent.children[0].getBoundingClientRect().top !== top;
115
- document.body.removeChild(parent);
116
- return isDifferent;
117
- };
118
- /**
119
- * @hidden
120
- */
121
- var hasRelativeStackingContext = memoize(ɵ3);
122
- /**
123
- * @hidden
124
- */
125
- var zIndex = function (anchor, container) {
126
- if (!anchor || !isDocumentAvailable() || !isWindowAvailable()) {
127
- return null;
128
- }
129
- var sibling = siblingContainer(anchor, container);
130
- if (!sibling) {
131
- return null;
132
- }
133
- var result = [anchor].concat(parents(anchor, sibling)).reduce(function (index, p) {
134
- var zIndexStyle = p.style.zIndex || window.getComputedStyle(p).zIndex;
135
- var current = parseInt(zIndexStyle, 10);
136
- return current > index ? current : index;
137
- }, 0);
138
- return result ? (result + 1) : null;
139
- };
140
- /**
141
- * @hidden
142
- */
143
- var scaleRect = function (rect, scale) {
144
- if (!rect || scale === 1) {
145
- return rect;
146
- }
147
- return {
148
- height: rect.height / scale,
149
- left: rect.left / scale,
150
- top: rect.top / scale,
151
- width: rect.width / scale
152
- };
153
- };
154
-
155
- var STYLES = [
156
- 'font-size',
157
- 'font-family',
158
- 'font-stretch',
159
- 'font-style',
160
- 'font-weight',
161
- 'line-height'
162
- ];
163
- /**
164
- * @hidden
165
- */
166
- var DOMService = /** @class */ (function () {
167
- function DOMService() {
168
- }
169
- DOMService.prototype.addOffset = function (current, addition) {
170
- return {
171
- left: current.left + addition.left,
172
- top: current.top + addition.top
173
- };
174
- };
175
- DOMService.prototype.addScroll = function (rect, scroll) {
176
- return addScroll(rect, scroll);
177
- };
178
- DOMService.prototype.align = function (settings) {
179
- return align(settings);
180
- };
181
- DOMService.prototype.boundingOffset = function (el) {
182
- return boundingOffset(el);
183
- };
184
- DOMService.prototype.getFontStyles = function (el) {
185
- var window = this.getWindow();
186
- if (!window || !el) {
187
- return [];
188
- }
189
- var computedStyles = window.getComputedStyle(el);
190
- return STYLES.map(function (font) { return ({ key: font, value: computedStyles[font] }); });
191
- };
192
- DOMService.prototype.getWindow = function () {
193
- return isWindowAvailable() ? window : null;
194
- };
195
- DOMService.prototype.hasOffsetParent = function (el) {
196
- if (!el) {
197
- return false;
198
- }
199
- return !!this.nativeElement(el).offsetParent;
200
- };
201
- DOMService.prototype.offset = function (el) {
202
- if (!el) {
203
- return null;
204
- }
205
- return offset(el);
206
- };
207
- DOMService.prototype.offsetAtPoint = function (el, currentLocation) {
208
- if (!el) {
209
- return null;
210
- }
211
- var element = this.nativeElement(el);
212
- var _a = element.style, left = _a.left, top = _a.top, transition = _a.transition;
213
- element.style.transition = 'none';
214
- element.style.left = currentLocation.left + "px";
215
- element.style.top = currentLocation.top + "px";
216
- var currentOffset = offset(element);
217
- element.style.left = left;
218
- element.style.top = top;
219
- // prevents elements with transition to be animated because of the change
220
- // tslint:disable-next-line:no-unused-expression
221
- element.offsetHeight;
222
- element.style.transition = transition;
223
- return currentOffset;
224
- };
225
- DOMService.prototype.nativeElement = function (el) {
226
- if (!el) {
227
- return null;
228
- }
229
- return el.nativeElement || el;
230
- };
231
- DOMService.prototype.position = function (element, popup, scale) {
232
- if (scale === void 0) { scale = 1; }
233
- if (!element || !popup) {
234
- return null;
235
- }
236
- return positionWithScroll(element, this.nativeElement(popup), scale);
237
- };
238
- DOMService.prototype.removeScroll = function (rect, scroll) {
239
- return removeScroll(rect, scroll);
240
- };
241
- DOMService.prototype.restrictToView = function (settings) {
242
- return restrictToView(settings);
243
- };
244
- DOMService.prototype.scrollPosition = function (el) {
245
- return scrollPosition(this.nativeElement(el));
246
- };
247
- DOMService.prototype.scrollableParents = function (el) {
248
- return scrollableParents(el);
249
- };
250
- DOMService.prototype.stackingElementOffset = function (el) {
251
- var relativeContextElement = this.getRelativeContextElement(el);
252
- if (!relativeContextElement) {
253
- return null;
254
- }
255
- return offset(relativeContextElement);
256
- };
257
- DOMService.prototype.stackingElementScroll = function (el) {
258
- var relativeContextElement = this.getRelativeContextElement(el);
259
- if (!relativeContextElement) {
260
- return { x: 0, y: 0 };
261
- }
262
- return {
263
- x: relativeContextElement.scrollLeft,
264
- y: relativeContextElement.scrollTop
265
- };
266
- };
267
- DOMService.prototype.getRelativeContextElement = function (el) {
268
- if (!el || !hasRelativeStackingContext()) {
269
- return null;
270
- }
271
- var parent = this.nativeElement(el).parentElement;
272
- while (parent) {
273
- if (window.getComputedStyle(parent).transform !== 'none') {
274
- return parent;
275
- }
276
- parent = parent.parentElement;
277
- }
278
- return null;
279
- };
280
- DOMService.prototype.useRelativePosition = function (el) {
281
- return !!this.getRelativeContextElement(el);
282
- };
283
- DOMService.prototype.windowViewPort = function (el) {
284
- return getWindowViewPort(this.nativeElement(el));
285
- };
286
- DOMService.prototype.zIndex = function (anchor, container) {
287
- return zIndex(anchor, this.nativeElement(container));
288
- };
289
- DOMService.prototype.zoomLevel = function () {
290
- if (!isDocumentAvailable() || !isWindowAvailable()) {
291
- return 1;
292
- }
293
- return parseFloat((document.documentElement.clientWidth / window.innerWidth).toFixed(2)) || 1;
294
- };
295
- DOMService.prototype.isZoomed = function () {
296
- return this.zoomLevel() > 1;
297
- };
298
- DOMService = __decorate([
299
- Injectable()
300
- ], DOMService);
301
- return DOMService;
302
- }());
303
-
304
- /**
305
- * Used to set the document scale when using a [scale transform](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale).
306
- *
307
- * The document or container scale is required to compute the popup position correctly. Detecting the scale is not reliable and must be set by providing a value for SCALE. See [Support for Document Scale]({% slug documentscale_popup %}).
308
- *
309
- * > Using this token is not necessary for user-applied browser zoom.
310
- *
311
- * {% meta height:300 %}
312
- * {% embed_file scale/app.component.ts preview %}
313
- * {% embed_file shared/app.module.ts %}
314
- * {% embed_file shared/main.ts %}
315
- * {% endmeta %}
316
- *
317
- *
318
- */
319
- var SCALE = new InjectionToken('Popup Document Scale');
320
-
321
- /**
322
- * @hidden
323
- */
324
- var AlignService = /** @class */ (function () {
325
- function AlignService(_dom, scale) {
326
- if (scale === void 0) { scale = 1; }
327
- this._dom = _dom;
328
- this.scale = scale;
329
- }
330
- AlignService.prototype.alignElement = function (settings) {
331
- var anchor = settings.anchor, element = settings.element, anchorAlign = settings.anchorAlign, elementAlign = settings.elementAlign, margin = settings.margin, offset$$1 = settings.offset, positionMode = settings.positionMode;
332
- var scale = this.scale || 1;
333
- var fixedMode = positionMode === 'fixed' || !this._dom.hasOffsetParent(element);
334
- var anchorRect = fixedMode ? this.absoluteRect(anchor, element, offset$$1, scale) : this.relativeRect(anchor, element, offset$$1, scale);
335
- var elementRect = scaleRect(this._dom.offset(element.nativeElement), scale);
336
- var result = this._dom.align({
337
- anchorAlign: anchorAlign,
338
- anchorRect: anchorRect,
339
- elementAlign: elementAlign,
340
- elementRect: elementRect,
341
- margin: margin
342
- });
343
- return result;
344
- };
345
- AlignService.prototype.absoluteRect = function (anchor, element, offset$$1, scale) {
346
- var scrollPos = this.elementScrollPosition(anchor, element);
347
- var rect = eitherRect(this._dom.offset(anchor), offset$$1);
348
- var stackScale = 2 * scale;
349
- var stackScroll = this._dom.stackingElementScroll(element);
350
- if (scale !== 1 && stackScroll) {
351
- stackScroll.x /= stackScale;
352
- stackScroll.y /= stackScale;
353
- }
354
- var stackOffset = this._dom.stackingElementOffset(element);
355
- if (scale !== 1 && stackOffset) {
356
- stackOffset.left /= stackScale;
357
- stackOffset.top /= stackScale;
358
- }
359
- return this._dom.removeScroll(this._dom.addScroll(removeStackingOffset(scaleRect(rect, scale), stackOffset), stackScroll), scrollPos);
360
- };
361
- AlignService.prototype.elementScrollPosition = function (anchor, element) {
362
- return anchor ? { x: 0, y: 0 } : this._dom.scrollPosition(element);
363
- };
364
- AlignService.prototype.relativeRect = function (anchor, element, offset$$1, scale) {
365
- var rect = eitherRect(this._dom.position(anchor, element, scale), offset$$1);
366
- return scaleRect(rect, scale);
367
- };
368
- AlignService = __decorate([
369
- Injectable(),
370
- __param(1, Inject(SCALE)), __param(1, Optional()),
371
- __metadata("design:paramtypes", [DOMService, Number])
372
- ], AlignService);
373
- return AlignService;
374
- }());
375
-
376
- /**
377
- * @hidden
378
- */
379
- var PositionService = /** @class */ (function () {
380
- function PositionService(_dom, scale) {
381
- if (scale === void 0) { scale = 1; }
382
- this._dom = _dom;
383
- this.scale = scale;
384
- }
385
- PositionService.prototype.positionElement = function (settings) {
386
- var anchor = settings.anchor, currentLocation = settings.currentLocation, element = settings.element, anchorAlign = settings.anchorAlign, elementAlign = settings.elementAlign, collisions = settings.collisions, margin = settings.margin;
387
- var dom = this._dom;
388
- var scale = this.scale || 1;
389
- var elementOffset = dom.offsetAtPoint(element, currentLocation);
390
- var elementRect = scaleRect(elementOffset, scale);
391
- var anchorOffset = scaleRect(dom.offset(anchor), scale);
392
- var anchorRect = eitherRect(anchorOffset, currentLocation);
393
- var viewPort = settings.viewPort || dom.windowViewPort(element);
394
- viewPort.width = viewPort.width / scale;
395
- viewPort.height = viewPort.height / scale;
396
- var result = dom.restrictToView({
397
- anchorAlign: anchorAlign,
398
- anchorRect: anchorRect,
399
- collisions: collisions,
400
- elementAlign: elementAlign,
401
- elementRect: elementRect,
402
- margin: margin,
403
- viewPort: viewPort
404
- });
405
- var offset$$1 = dom.addOffset(currentLocation, result.offset);
406
- return {
407
- flip: result.flip,
408
- flipped: result.flipped,
409
- offset: offset$$1
410
- };
411
- };
412
- PositionService = __decorate([
413
- Injectable(),
414
- __param(1, Inject(SCALE)), __param(1, Optional()),
415
- __metadata("design:paramtypes", [DOMService, Number])
416
- ], PositionService);
417
- return PositionService;
418
- }());
419
-
420
- /**
421
- * @hidden
422
- */
423
- var ResizeService = /** @class */ (function () {
424
- function ResizeService(_dom, _zone) {
425
- this._dom = _dom;
426
- this._zone = _zone;
427
- }
428
- ResizeService.prototype.subscribe = function (callback) {
429
- var _this = this;
430
- if (!isDocumentAvailable()) {
431
- return;
432
- }
433
- this._zone.runOutsideAngular(function () {
434
- _this.subscription = fromEvent(_this._dom.getWindow(), "resize")
435
- .pipe(auditTime(FRAME_DURATION))
436
- .subscribe(function () { return callback(); });
437
- });
438
- };
439
- ResizeService.prototype.unsubscribe = function () {
440
- if (!this.subscription) {
441
- return;
442
- }
443
- this.subscription.unsubscribe();
444
- };
445
- ResizeService.prototype.isUnsubscribed = function () {
446
- return this.subscription && this.subscription.closed;
447
- };
448
- ResizeService = __decorate([
449
- Injectable(),
450
- __metadata("design:paramtypes", [DOMService, NgZone])
451
- ], ResizeService);
452
- return ResizeService;
453
- }());
454
-
455
- /**
456
- * @hidden
457
- */
458
- var THRESHOLD_DIFF = 1;
459
- /**
460
- * @hidden
461
- */
462
- var ScrollableService = /** @class */ (function () {
463
- function ScrollableService(_dom, _zone) {
464
- this._dom = _dom;
465
- this._zone = _zone;
466
- }
467
- ScrollableService.prototype.forElement = function (element) {
468
- this.unsubscribe();
469
- this.element = element;
470
- return this;
471
- };
472
- ScrollableService.prototype.subscribe = function (callback) {
473
- var _this = this;
474
- if (!callback || !isDocumentAvailable() || !this.element) {
475
- return;
476
- }
477
- var parents$$1 = this._dom.scrollableParents(this.element);
478
- this._zone.runOutsideAngular(function () {
479
- var observables = parents$$1.map(function (p) { return fromEvent(p, "scroll").pipe(auditTime(FRAME_DURATION)); });
480
- var subscriber = function (e) {
481
- var target = e.target;
482
- var isParent = parents$$1.filter(function (p) { return p === target; }).length > 0;
483
- var isDocument = target === document;
484
- var isWindow = target === window;
485
- if (isParent || isDocument || isWindow) {
486
- callback(_this.isVisible(_this.element, target));
487
- }
488
- };
489
- _this.subscription = merge.apply(void 0, observables).subscribe(subscriber);
490
- });
491
- };
492
- ScrollableService.prototype.unsubscribe = function () {
493
- if (!this.subscription) {
494
- return;
495
- }
496
- this.subscription.unsubscribe();
497
- };
498
- ScrollableService.prototype.isVisible = function (elem, container) {
499
- var elemRect = this._dom.boundingOffset(elem);
500
- var containerRect = this._dom.boundingOffset(this._dom.nativeElement(container));
501
- if (THRESHOLD_DIFF < (containerRect.top - elemRect.bottom)) {
502
- return false;
503
- }
504
- if (THRESHOLD_DIFF < (elemRect.top - containerRect.bottom)) {
505
- return false;
506
- }
507
- if (THRESHOLD_DIFF < (elemRect.left - containerRect.right)) {
508
- return false;
509
- }
510
- if (THRESHOLD_DIFF < (containerRect.left - elemRect.right)) {
511
- return false;
512
- }
513
- return true;
514
- };
515
- ScrollableService = __decorate([
516
- Injectable(),
517
- __metadata("design:paramtypes", [DOMService, NgZone])
518
- ], ScrollableService);
519
- return ScrollableService;
520
- }());
521
-
522
- var LEFT = 'left';
523
- var RIGHT = 'right';
524
- var DOWN = 'down';
525
- var UP = 'up';
526
- var DEFAULT_TYPE = 'slide';
527
- var DEFAULT_DURATION = 100;
528
- var animationTypes = {};
529
- /* tslint:disable:object-literal-sort-keys */
530
- animationTypes.expand = function (direction) {
531
- var scale = direction === UP || direction === DOWN ? 'scaleY' : 'scaleX';
532
- var startScale = 0;
533
- var endScale = 1;
534
- var origin;
535
- if (direction === DOWN) {
536
- origin = 'top';
537
- }
538
- else if (direction === LEFT) {
539
- origin = RIGHT;
540
- }
541
- else if (direction === RIGHT) {
542
- origin = LEFT;
543
- }
544
- else {
545
- origin = 'bottom';
546
- }
547
- return {
548
- start: { transform: scale + "(" + startScale + ")", transformOrigin: origin },
549
- end: { transform: scale + "(" + endScale + ")" }
550
- };
551
- };
552
- animationTypes.slide = function (direction) {
553
- var translate = direction === LEFT || direction === RIGHT ? 'translateX' : 'translateY';
554
- var start = direction === RIGHT || direction === DOWN ? -100 : 100;
555
- var end = 0;
556
- return {
557
- start: { transform: translate + "(" + start + "%)" },
558
- end: { transform: translate + "(" + end + "%)" }
559
- };
560
- };
561
- animationTypes.fade = function () {
562
- return {
563
- start: { opacity: 0 },
564
- end: { opacity: 1 }
565
- };
566
- };
567
- animationTypes.zoom = function () {
568
- var start = 0;
569
- var end = 1;
570
- return {
571
- start: { transform: "scale(" + start + ")" },
572
- end: { transform: "scale(" + end + ")" }
573
- };
574
- };
575
- /**
576
- * @hidden
577
- */
578
- var AnimationService = /** @class */ (function () {
579
- function AnimationService(animationBuilder) {
580
- this.animationBuilder = animationBuilder;
581
- this.start = new EventEmitter();
582
- this.end = new EventEmitter();
583
- }
584
- AnimationService.prototype.play = function (element, options, flip) {
585
- if (!this.flip || this.flip.horizontal !== flip.horizontal ||
586
- this.flip.vertical !== flip.vertical) {
587
- this.flip = flip;
588
- var type = options.type || DEFAULT_TYPE;
589
- var statesFn = animationTypes[type];
590
- if (statesFn) {
591
- var direction = this.getDirection(flip, options);
592
- var states = statesFn(direction);
593
- this.playStates(element, states, options);
594
- }
595
- else if (isDevMode()) {
596
- throw new Error("Unsupported animation type: \"" + type + "\". The supported types are slide, expand, fade and zoom.");
597
- }
598
- }
599
- };
600
- AnimationService.prototype.ngOnDestroy = function () {
601
- this.stopPlayer();
602
- };
603
- AnimationService.prototype.playStates = function (element, states, options) {
604
- var _this = this;
605
- this.stopPlayer();
606
- var duration = options.duration || DEFAULT_DURATION;
607
- var factory = this.animationBuilder.build([
608
- style(states.start),
609
- animate(duration + "ms ease-in", style(states.end))
610
- ]);
611
- var player = this.player = factory.create(element);
612
- player.onDone(function () {
613
- _this.end.emit();
614
- _this.stopPlayer();
615
- });
616
- this.start.emit();
617
- player.play();
618
- };
619
- AnimationService.prototype.getDirection = function (flip, options) {
620
- var direction = options.direction || DOWN;
621
- if (flip.horizontal) {
622
- if (direction === LEFT) {
623
- direction = RIGHT;
624
- }
625
- else if (direction === RIGHT) {
626
- direction = LEFT;
627
- }
628
- }
629
- if (flip.vertical) {
630
- if (direction === DOWN) {
631
- direction = UP;
632
- }
633
- else if (direction === UP) {
634
- direction = DOWN;
635
- }
636
- }
637
- return direction;
638
- };
639
- AnimationService.prototype.stopPlayer = function () {
640
- if (this.player) {
641
- this.player.destroy();
642
- this.player = null;
643
- }
644
- };
645
- AnimationService = __decorate([
646
- Injectable(),
647
- __metadata("design:paramtypes", [AnimationBuilder])
648
- ], AnimationService);
649
- return AnimationService;
650
- }());
651
-
652
- /**
653
- * @hidden
654
- */
655
- var packageMetadata = {
656
- name: '@progress/kendo-angular-popup',
657
- productName: 'Kendo UI for Angular',
658
- productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
659
- publishDate: 1647429230,
660
- version: '',
661
- licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
662
- };
663
-
664
- var DEFAULT_OFFSET = { left: -10000, top: 0 };
665
- var ANIMATION_CONTAINER = 'k-animation-container';
666
- var ANIMATION_CONTAINER_FIXED = 'k-animation-container-fixed';
667
- /**
668
- * Represents the [Kendo UI Popup component for Angular]({% slug overview_popup %}).
669
- *
670
- * @example
671
- * ```ts
672
- * _@Component({
673
- * selector: 'my-app',
674
- * template: `
675
- * <button #anchor (click)="show=!show">Toggle</button>
676
- * <kendo-popup *ngIf="show" [anchor]="anchor">
677
- * <strong>Popup content!</strong>
678
- * </kendo-popup>
679
- * `
680
- * })
681
- * class AppComponent {
682
- * public show: boolean = false;
683
- * }
684
- * ```
685
- */
686
- var PopupComponent = /** @class */ (function () {
687
- function PopupComponent(container, _alignService, domService, _positionService, _resizeService, _scrollableService, animationService, _renderer, _zone) {
688
- this.container = container;
689
- this._alignService = _alignService;
690
- this.domService = domService;
691
- this._positionService = _positionService;
692
- this._resizeService = _resizeService;
693
- this._scrollableService = _scrollableService;
694
- this.animationService = animationService;
695
- this._renderer = _renderer;
696
- this._zone = _zone;
697
- /**
698
- * Controls the Popup animation. By default, the opening and closing animations
699
- * are enabled ([see example]({% slug animations_popup %})).
700
- */
701
- this.animate = true;
702
- /**
703
- * Specifies the anchor pivot point
704
- * ([see example]({% slug alignmentpositioning_popup %}#toc-positioning)).
705
- */
706
- this.anchorAlign = { horizontal: 'left', vertical: 'bottom' };
707
- /**
708
- * Configures the collision behavior of the Popup
709
- * ([see example]({% slug viewportboundarydetection_popup %})).
710
- */
711
- this.collision = { horizontal: 'fit', vertical: 'flip' };
712
- /**
713
- * Specifies the pivot point of the Popup
714
- * ([see example]({% slug alignmentpositioning_popup %}#toc-positioning)).
715
- */
716
- this.popupAlign = { horizontal: 'left', vertical: 'top' };
717
- /**
718
- * Controls whether the component will copy the `anchor` font styles.
719
- */
720
- this.copyAnchorStyles = false;
721
- /**
722
- * Specifies the position mode of the component. By default, the Popup uses fixed positioning.
723
- * To make the Popup acquire absolute positioning, set this option to `absolute`.
724
- *
725
- * > If you need to support mobile browsers with the zoom option,
726
- * use the `absolute` positioning of the Popup.
727
- *
728
- * @example
729
- * ```html
730
- * <style>
731
- * .parent-content {
732
- * position: relative;
733
- * width: 200px;
734
- * height: 200px;
735
- * overflow: auto;
736
- * margin: 200px auto;
737
- * border: 1px solid red;
738
- * }
739
- * .content {
740
- * position: relative;
741
- * width: 100px;
742
- * height: 100px;
743
- * overflow: auto;
744
- * margin: 300px;
745
- * border: 1px solid blue;
746
- * }
747
- * .anchor {
748
- * position: absolute;
749
- * top: 200px;
750
- * left: 200px;
751
- * }
752
- * </style>
753
- * ```
754
- * ```ts
755
- * _@Component({
756
- * selector: 'my-app',
757
- * template: `
758
- * <div class="example-config">
759
- * Position mode:
760
- * <label><input type="radio" value="fixed" [(ngModel)]="mode" /> Fixed</label>
761
- * <label><input type="radio" value="absolute" [(ngModel)]="mode" /> Absolute</label>
762
- * </div>
763
- * <div class="example-config">
764
- * Append to
765
- * <label>
766
- * <input type="radio" name="place" [value]="1" [(ngModel)]="checked" />
767
- * Root component
768
- * </label>
769
- * <label>
770
- * <input type="radio" name="place" [value]="2" [(ngModel)]="checked" />
771
- * <span style="color: red">Red Container</span>
772
- * </label>
773
- * <label>
774
- * <input type="radio" name="place" [value]="3" [(ngModel)]="checked" />
775
- * <span style="color: blue">Blue Container</span>
776
- * </label>
777
- * </div>
778
- * <div class="example">
779
- * <div class="parent-content" [scrollLeft]="250" [scrollTop]="230">
780
- * <div class="content" [scrollLeft]="170" [scrollTop]="165">
781
- * <button #anchor class="anchor" (click)="show = !show">Toggle</button>
782
- * <kendo-popup [positionMode]="mode" [anchor]="anchor" (anchorViewportLeave)="show=false" *ngIf="show && checked === 3">
783
- * <ul>
784
- * <li>Item1</li>
785
- * <li>Item2</li>
786
- * <li>Item3</li>
787
- * </ul>
788
- * </kendo-popup>
789
- * <span style="position: absolute; top: 400px; left: 400px">Bottom/Right</span>
790
- * </div>
791
- * <kendo-popup [positionMode]="mode" [anchor]="anchor" (anchorViewportLeave)="show=false" *ngIf="show && checked === 2">
792
- * <ul>
793
- * <li>Item1</li>
794
- * <li>Item2</li>
795
- * <li>Item3</li>
796
- * </ul>
797
- * </kendo-popup>
798
- * <span style="position: absolute; top: 600px; left: 600px">Bottom/Right</span>
799
- * </div>
800
- * <kendo-popup [positionMode]="mode" [anchor]="anchor" (anchorViewportLeave)="show=false" *ngIf="show && checked === 1">
801
- * <ul>
802
- * <li>Item1</li>
803
- * <li>Item2</li>
804
- * <li>Item3</li>
805
- * </ul>
806
- * </kendo-popup>
807
- * </div>
808
- * `
809
- * })
810
- * class AppComponent {
811
- * public checked: number = 3;
812
- * public mode: string = 'absolute';
813
- * public show: boolean = true;
814
- * }
815
- * ```
816
- */
817
- this.positionMode = 'fixed';
818
- /**
819
- * Specifies the absolute position of the element
820
- * ([see example]({% slug alignmentpositioning_popup %}#toc-aligning-to-absolute-points)).
821
- * The Popup opens next to that point. The Popup pivot point is defined by the `popupAlign` configuration option.
822
- * The boundary detection is applied by using the window viewport.
823
- */
824
- this.offset = DEFAULT_OFFSET;
825
- /**
826
- * Fires when the anchor is scrolled outside the screen boundaries.
827
- * ([see example]({% slug closing_popup %}#toc-after-leaving-the-viewport)).
828
- */
829
- this.anchorViewportLeave = new EventEmitter();
830
- /**
831
- * Fires after the component is closed.
832
- */
833
- this.close = new EventEmitter();
834
- /**
835
- * Fires after the component is opened and the opening animation ends.
836
- */
837
- this.open = new EventEmitter();
838
- /**
839
- * Fires after the component is opened and the Popup is positioned.
840
- */
841
- this.positionChange = new EventEmitter();
842
- this.resolvedPromise = Promise.resolve(null);
843
- this.initialCheck = true;
844
- validatePackage(packageMetadata);
845
- this._renderer.addClass(container.nativeElement, ANIMATION_CONTAINER);
846
- this.updateFixedClass();
847
- }
848
- PopupComponent.prototype.ngOnInit = function () {
849
- this.reposition = this.reposition.bind(this);
850
- this._resizeService.subscribe(this.reposition);
851
- this.animationSubscriptions = this.animationService.start.subscribe(this.onAnimationStart.bind(this));
852
- this.animationSubscriptions.add(this.animationService.end.subscribe(this.onAnimationEnd.bind(this)));
853
- this._scrollableService.forElement(this.domService.nativeElement(this.anchor) || this.container.nativeElement).subscribe(this.onScroll.bind(this));
854
- this.currentOffset = DEFAULT_OFFSET;
855
- this.setZIndex();
856
- this.copyFontStyles();
857
- this.updateFixedClass();
858
- this.reposition();
859
- };
860
- PopupComponent.prototype.ngOnChanges = function (changes) {
861
- if (changes.copyAnchorStyles) {
862
- this.copyFontStyles();
863
- }
864
- if (changes.positionMode) {
865
- this.updateFixedClass();
866
- }
867
- };
868
- PopupComponent.prototype.ngAfterViewInit = function () {
869
- var _this = this;
870
- if (!this.animate) {
871
- this.resolvedPromise.then(function () {
872
- _this.onAnimationEnd();
873
- });
874
- }
875
- };
876
- PopupComponent.prototype.ngAfterViewChecked = function () {
877
- var _this = this;
878
- if (this.initialCheck) {
879
- this.initialCheck = false;
880
- return;
881
- }
882
- this._zone.runOutsideAngular(function () {
883
- // workarounds https://github.com/angular/angular/issues/19094
884
- // uses promise because it is executed synchronously after the content is updated
885
- // does not use onStable in case the current zone is not the angular one.
886
- _this.unsubscribeReposition();
887
- _this.repositionSubscription = from(_this.resolvedPromise)
888
- .subscribe(_this.reposition);
889
- });
890
- };
891
- PopupComponent.prototype.ngOnDestroy = function () {
892
- this.anchorViewportLeave.complete();
893
- this.positionChange.complete();
894
- this.close.emit();
895
- this.close.complete();
896
- this._resizeService.unsubscribe();
897
- this._scrollableService.unsubscribe();
898
- this.animationSubscriptions.unsubscribe();
899
- this.unsubscribeReposition();
900
- };
901
- /**
902
- * @hidden
903
- */
904
- PopupComponent.prototype.onResize = function () {
905
- this.reposition();
906
- };
907
- PopupComponent.prototype.onAnimationStart = function () {
908
- this._renderer.removeClass(this.container.nativeElement, 'k-animation-container-shown');
909
- };
910
- PopupComponent.prototype.onAnimationEnd = function () {
911
- this._renderer.addClass(this.container.nativeElement, 'k-animation-container-shown');
912
- this.open.emit();
913
- this.open.complete();
914
- };
915
- Object.defineProperty(PopupComponent.prototype, "currentOffset", {
916
- get: function () {
917
- return this._currentOffset;
918
- },
919
- set: function (offset$$1) {
920
- this.setContainerStyle('left', offset$$1.left + "px");
921
- this.setContainerStyle('top', offset$$1.top + "px");
922
- this._currentOffset = offset$$1;
923
- },
924
- enumerable: true,
925
- configurable: true
926
- });
927
- PopupComponent.prototype.setZIndex = function () {
928
- if (this.anchor) {
929
- this.setContainerStyle('z-index', String(this.domService.zIndex(this.domService.nativeElement(this.anchor), this.container)));
930
- }
931
- };
932
- PopupComponent.prototype.reposition = function () {
933
- var _this = this;
934
- if (!isDocumentAvailable()) {
935
- return;
936
- }
937
- var _a = this.position(), flip = _a.flip, offset$$1 = _a.offset;
938
- if (!this.currentOffset || isDifferentOffset(this.currentOffset, offset$$1)) {
939
- this.currentOffset = offset$$1;
940
- if (hasObservers(this.positionChange)) {
941
- this._zone.run(function () { return _this.positionChange.emit({ offset: offset$$1, flip: flip }); });
942
- }
943
- }
944
- if (this.animate) {
945
- this.animationService.play(this.contentContainer.nativeElement, this.animate, flip);
946
- }
947
- this.resizeSensor.acceptSize();
948
- };
949
- PopupComponent.prototype.position = function () {
950
- var alignedOffset = this._alignService.alignElement({
951
- anchor: this.domService.nativeElement(this.anchor),
952
- anchorAlign: this.anchorAlign,
953
- element: this.container,
954
- elementAlign: this.popupAlign,
955
- margin: this.margin,
956
- offset: this.offset,
957
- positionMode: this.positionMode
958
- });
959
- return this._positionService.positionElement({
960
- anchor: this.domService.nativeElement(this.anchor),
961
- anchorAlign: this.anchorAlign,
962
- collisions: this.collision,
963
- currentLocation: alignedOffset,
964
- element: this.container,
965
- elementAlign: this.popupAlign,
966
- margin: this.margin
967
- });
968
- };
969
- PopupComponent.prototype.onScroll = function (isInViewPort) {
970
- var _this = this;
971
- var hasLeaveObservers = hasObservers(this.anchorViewportLeave);
972
- if (isInViewPort || !hasLeaveObservers) {
973
- this.reposition();
974
- }
975
- else if (hasLeaveObservers) {
976
- this._zone.run(function () {
977
- _this.anchorViewportLeave.emit();
978
- });
979
- }
980
- };
981
- PopupComponent.prototype.copyFontStyles = function () {
982
- var _this = this;
983
- if (!this.anchor || !this.copyAnchorStyles) {
984
- return;
985
- }
986
- this.domService.getFontStyles(this.domService.nativeElement(this.anchor))
987
- .forEach(function (s) { return _this.setContainerStyle(s.key, s.value); });
988
- };
989
- PopupComponent.prototype.updateFixedClass = function () {
990
- var action = this.positionMode === 'fixed' ? 'addClass' : 'removeClass';
991
- this._renderer[action](this.container.nativeElement, ANIMATION_CONTAINER_FIXED);
992
- };
993
- PopupComponent.prototype.setContainerStyle = function (name, value) {
994
- this._renderer.setStyle(this.container.nativeElement, name, value);
995
- };
996
- PopupComponent.prototype.unsubscribeReposition = function () {
997
- if (this.repositionSubscription) {
998
- this.repositionSubscription.unsubscribe();
999
- }
1000
- };
1001
- __decorate([
1002
- Input(),
1003
- __metadata("design:type", Object)
1004
- ], PopupComponent.prototype, "animate", void 0);
1005
- __decorate([
1006
- Input(),
1007
- __metadata("design:type", Object)
1008
- ], PopupComponent.prototype, "anchor", void 0);
1009
- __decorate([
1010
- Input(),
1011
- __metadata("design:type", Object)
1012
- ], PopupComponent.prototype, "anchorAlign", void 0);
1013
- __decorate([
1014
- Input(),
1015
- __metadata("design:type", Object)
1016
- ], PopupComponent.prototype, "collision", void 0);
1017
- __decorate([
1018
- Input(),
1019
- __metadata("design:type", Object)
1020
- ], PopupComponent.prototype, "popupAlign", void 0);
1021
- __decorate([
1022
- Input(),
1023
- __metadata("design:type", Boolean)
1024
- ], PopupComponent.prototype, "copyAnchorStyles", void 0);
1025
- __decorate([
1026
- Input(),
1027
- __metadata("design:type", Object)
1028
- ], PopupComponent.prototype, "popupClass", void 0);
1029
- __decorate([
1030
- Input(),
1031
- __metadata("design:type", String)
1032
- ], PopupComponent.prototype, "positionMode", void 0);
1033
- __decorate([
1034
- Input(),
1035
- __metadata("design:type", Object)
1036
- ], PopupComponent.prototype, "offset", void 0);
1037
- __decorate([
1038
- Input(),
1039
- __metadata("design:type", Object)
1040
- ], PopupComponent.prototype, "margin", void 0);
1041
- __decorate([
1042
- Output(),
1043
- __metadata("design:type", EventEmitter)
1044
- ], PopupComponent.prototype, "anchorViewportLeave", void 0);
1045
- __decorate([
1046
- Output(),
1047
- __metadata("design:type", EventEmitter)
1048
- ], PopupComponent.prototype, "close", void 0);
1049
- __decorate([
1050
- Output(),
1051
- __metadata("design:type", EventEmitter)
1052
- ], PopupComponent.prototype, "open", void 0);
1053
- __decorate([
1054
- Output(),
1055
- __metadata("design:type", EventEmitter)
1056
- ], PopupComponent.prototype, "positionChange", void 0);
1057
- __decorate([
1058
- ViewChild('container', { static: true }),
1059
- __metadata("design:type", ElementRef)
1060
- ], PopupComponent.prototype, "contentContainer", void 0);
1061
- __decorate([
1062
- ViewChild(ResizeSensorComponent, { static: true }),
1063
- __metadata("design:type", ResizeSensorComponent)
1064
- ], PopupComponent.prototype, "resizeSensor", void 0);
1065
- PopupComponent = __decorate([
1066
- Component({
1067
- exportAs: 'kendo-popup',
1068
- providers: [AlignService, AnimationService, DOMService, PositionService, ResizeService, ScrollableService],
1069
- selector: 'kendo-popup',
1070
- template: "\n <div class=\"k-popup\" [ngClass]=\"popupClass\" #container>\n <ng-content></ng-content>\n <ng-template [ngTemplateOutlet]=\"content\" [ngIf]=\"content\"></ng-template>\n <kendo-resize-sensor [rateLimit]=\"100\" (resize)=\"onResize()\">\n </kendo-resize-sensor>\n </div>\n "
1071
- }),
1072
- __metadata("design:paramtypes", [ElementRef,
1073
- AlignService,
1074
- DOMService,
1075
- PositionService,
1076
- ResizeService,
1077
- ScrollableService,
1078
- AnimationService,
1079
- Renderer2,
1080
- NgZone])
1081
- ], PopupComponent);
1082
- return PopupComponent;
1083
- }());
1084
-
1085
- var removeElement = function (element) {
1086
- if (element && element.parentNode) {
1087
- element.parentNode.removeChild(element);
1088
- }
1089
- };
1090
- /**
1091
- * Used to inject the Popup container. If not provided, the first root component of
1092
- * the application is used.
1093
- *
1094
- * > The `POPUP_CONTAINER` can be used only with the [`PopupService`]({% slug service_popup %}) class.
1095
- *
1096
- * @example
1097
- *
1098
- * ```ts-no-run
1099
- * // Import the Popup module
1100
- * import { PopupModule, POPUP_CONTAINER } from '@progress/kendo-angular-popup';
1101
- *
1102
- * // The browser platform with a compiler
1103
- * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1104
- *
1105
- * import { ElementRef, NgModule } from '@angular/core';
1106
- *
1107
- * // Import the app component
1108
- * import { AppComponent } from './app.component';
1109
- *
1110
- * // Define the app module
1111
- * _@NgModule({
1112
- * declarations: [AppComponent], // declare app component
1113
- * imports: [BrowserModule, PopupModule], // import Popup module
1114
- * bootstrap: [AppComponent],
1115
- * providers: [{
1116
- * provide: POPUP_CONTAINER,
1117
- * useFactory: () => {
1118
- * //return the container ElementRef, where the popup will be injected
1119
- * return { nativeElement: document.body } as ElementRef;
1120
- * }
1121
- * }]
1122
- * })
1123
- * export class AppModule {}
1124
- *
1125
- * // Compile and launch the module
1126
- * platformBrowserDynamic().bootstrapModule(AppModule);
1127
- * ```
1128
- */
1129
- var POPUP_CONTAINER = new InjectionToken('Popup Container');
1130
- /**
1131
- * A service for opening Popup components dynamically
1132
- * ([see example]({% slug service_popup %})).
1133
- *
1134
- * @export
1135
- * @class PopupService
1136
- */
1137
- var PopupService = /** @class */ (function () {
1138
- function PopupService(applicationRef, componentFactoryResolver, injector, container) {
1139
- this.applicationRef = applicationRef;
1140
- this.componentFactoryResolver = componentFactoryResolver;
1141
- this.injector = injector;
1142
- this.container = container;
1143
- }
1144
- Object.defineProperty(PopupService.prototype, "rootViewContainer", {
1145
- /**
1146
- * Gets the root view container into which the component will be injected.
1147
- *
1148
- * @returns {ComponentRef<any>}
1149
- */
1150
- get: function () {
1151
- // https://github.com/angular/angular/blob/4.0.x/packages/core/src/application_ref.ts#L571
1152
- var rootComponents = this.applicationRef.components || [];
1153
- if (rootComponents[0]) {
1154
- return rootComponents[0];
1155
- }
1156
- throw new Error("\n View Container not found! Inject the POPUP_CONTAINER or define a specific ViewContainerRef via the appendTo option.\n See http://www.telerik.com/kendo-angular-ui/components/popup/api/POPUP_CONTAINER/ for more details.\n ");
1157
- },
1158
- enumerable: true,
1159
- configurable: true
1160
- });
1161
- Object.defineProperty(PopupService.prototype, "rootViewContainerNode", {
1162
- /**
1163
- * Sets or gets the HTML element of the root component container.
1164
- *
1165
- * @returns {HTMLElement}
1166
- */
1167
- get: function () {
1168
- return this.container ? this.container.nativeElement : this.getComponentRootNode(this.rootViewContainer);
1169
- },
1170
- enumerable: true,
1171
- configurable: true
1172
- });
1173
- /**
1174
- * Opens a Popup component. Created Popups are mounted
1175
- * in the DOM directly in the root application component.
1176
- *
1177
- * @param {PopupSettings} options - The options which define the Popup.
1178
- * @returns {ComponentRef<PopupComponent>} - A reference to the Popup object.
1179
- *
1180
- * @example
1181
- *
1182
- * ```ts-no-run
1183
- * _@Component({
1184
- * selector: 'my-app',
1185
- * template: `
1186
- * <ng-template #template>
1187
- * Popup content
1188
- * </ng-template>
1189
- * <button #anchor kendoButton (click)="open(anchor, template)">Open</button>
1190
- * `
1191
- * })
1192
- * export class AppComponent {
1193
- * public popupRef: PopupRef;
1194
- *
1195
- * constructor( private popupService: PopupService ) {}
1196
- *
1197
- * public open(anchor: ElementRef, template: TemplateRef<any>): void {
1198
- * if (this.popupRef) {
1199
- * this.popupRef.close();
1200
- * this.popupRef = null;
1201
- * return;
1202
- * }
1203
- *
1204
- * this.popupRef = this.popupService.open({
1205
- * anchor: anchor,
1206
- * content: template
1207
- * });
1208
- * }
1209
- * }
1210
- * ```
1211
- */
1212
- PopupService.prototype.open = function (options) {
1213
- if (options === void 0) { options = {}; }
1214
- var _a = this.contentFrom(options.content), component = _a.component, nodes = _a.nodes;
1215
- var popupComponentRef = this.appendPopup(nodes, options.appendTo);
1216
- var popupInstance = popupComponentRef.instance;
1217
- this.projectComponentInputs(popupComponentRef, options);
1218
- popupComponentRef.changeDetectorRef.detectChanges();
1219
- if (component) {
1220
- component.changeDetectorRef.detectChanges();
1221
- }
1222
- var popupElement = this.getComponentRootNode(popupComponentRef);
1223
- return {
1224
- close: function () {
1225
- if (component) {
1226
- component.destroy();
1227
- }
1228
- popupComponentRef.destroy();
1229
- // Angular will not remove the element unless the change detection is triggered
1230
- removeElement(popupElement);
1231
- },
1232
- content: component,
1233
- popup: popupComponentRef,
1234
- popupAnchorViewportLeave: popupInstance.anchorViewportLeave,
1235
- popupClose: popupInstance.close,
1236
- popupElement: popupElement,
1237
- popupOpen: popupInstance.open,
1238
- popupPositionChange: popupInstance.positionChange
1239
- };
1240
- };
1241
- PopupService.prototype.appendPopup = function (nodes, container) {
1242
- var popupComponentRef = this.createComponent(PopupComponent, nodes, container);
1243
- if (!container) {
1244
- this.rootViewContainerNode.appendChild(this.getComponentRootNode(popupComponentRef));
1245
- }
1246
- return popupComponentRef;
1247
- };
1248
- /**
1249
- * Gets the HTML element for a component reference.
1250
- *
1251
- * @param {ComponentRef<any>} componentRef
1252
- * @returns {HTMLElement}
1253
- */
1254
- PopupService.prototype.getComponentRootNode = function (componentRef) {
1255
- return componentRef.location.nativeElement;
1256
- };
1257
- /**
1258
- * Gets the `ComponentFactory` instance by its type.
1259
- *
1260
- * @param {*} componentClass
1261
- * @param {*} nodes
1262
- * @returns {ComponentRef<any>}
1263
- */
1264
- PopupService.prototype.getComponentFactory = function (componentClass) {
1265
- return this.componentFactoryResolver.resolveComponentFactory(componentClass);
1266
- };
1267
- /**
1268
- * Creates a component reference from a `Component` type class.
1269
- *
1270
- * @param {*} componentClass
1271
- * @param {*} nodes
1272
- * @returns {ComponentRef<any>}
1273
- */
1274
- PopupService.prototype.createComponent = function (componentClass, nodes, container) {
1275
- var factory = this.getComponentFactory(componentClass);
1276
- if (container) {
1277
- return container.createComponent(factory, undefined, this.injector, nodes);
1278
- }
1279
- else {
1280
- var component = factory.create(this.injector, nodes);
1281
- this.applicationRef.attachView(component.hostView);
1282
- return component;
1283
- }
1284
- };
1285
- /**
1286
- * Projects the inputs on the component.
1287
- *
1288
- * @param {ComponentRef<any>} component
1289
- * @param {*} options
1290
- * @returns {ComponentRef<any>}
1291
- */
1292
- PopupService.prototype.projectComponentInputs = function (component, options) {
1293
- Object.getOwnPropertyNames(options)
1294
- .filter(function (prop) { return prop !== 'content' || options.content instanceof TemplateRef; })
1295
- .map(function (prop) {
1296
- component.instance[prop] = options[prop];
1297
- });
1298
- return component;
1299
- };
1300
- /**
1301
- * Gets the component and the nodes to append from the `content` option.
1302
- *
1303
- * @param {*} content
1304
- * @returns {any}
1305
- */
1306
- PopupService.prototype.contentFrom = function (content) {
1307
- if (!content || content instanceof TemplateRef) {
1308
- return { component: null, nodes: [[]] };
1309
- }
1310
- var component = this.createComponent(content);
1311
- var nodes = component ? [component.location.nativeElement] : [];
1312
- return {
1313
- component: component,
1314
- nodes: [
1315
- nodes // <ng-content>
1316
- ]
1317
- };
1318
- };
1319
- PopupService = __decorate([
1320
- Injectable(),
1321
- __param(3, Inject(POPUP_CONTAINER)), __param(3, Optional()),
1322
- __metadata("design:paramtypes", [ApplicationRef,
1323
- ComponentFactoryResolver,
1324
- Injector,
1325
- ElementRef])
1326
- ], PopupService);
1327
- return PopupService;
1328
- }());
1329
-
1330
- var POPUP_DIRECTIVES = [PopupComponent];
1331
- /**
1332
- * Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }})
1333
- * definition for the Popup component.
1334
- *
1335
- * @example
1336
- *
1337
- * ```ts-no-run
1338
- * // Import the Popup module
1339
- * import { PopupModule } from '@progress/kendo-angular-popup';
1340
- *
1341
- * // The browser platform with a compiler
1342
- * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1343
- *
1344
- * import { NgModule } from '@angular/core';
1345
- *
1346
- * // Import the app component
1347
- * import { AppComponent } from './app.component';
1348
- *
1349
- * // Define the app module
1350
- * _@NgModule({
1351
- * declarations: [AppComponent], // declare app component
1352
- * imports: [BrowserModule, PopupModule], // import Popup module
1353
- * bootstrap: [AppComponent]
1354
- * })
1355
- * export class AppModule {}
1356
- *
1357
- * // Compile and launch the module
1358
- * platformBrowserDynamic().bootstrapModule(AppModule);
1359
- *
1360
- * ```
1361
- */
1362
- var PopupModule = /** @class */ (function () {
1363
- function PopupModule() {
1364
- }
1365
- PopupModule = __decorate([
1366
- NgModule({
1367
- declarations: [POPUP_DIRECTIVES],
1368
- entryComponents: [POPUP_DIRECTIVES],
1369
- exports: [POPUP_DIRECTIVES],
1370
- imports: [CommonModule, ResizeSensorModule],
1371
- providers: [PopupService]
1372
- })
1373
- ], PopupModule);
1374
- return PopupModule;
1375
- }());
1376
-
1377
- /**
1378
- * Generated bundle index. Do not edit.
1379
- */
1380
-
1381
- export { AlignService, AnimationService, DOMService, PositionService, ResizeService, ScrollableService, PopupService, POPUP_CONTAINER, PopupComponent, PopupModule, SCALE };