@progress/kendo-angular-tooltip 3.1.6 → 4.0.0-dev.202204131841

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 (146) hide show
  1. package/bundles/kendo-angular-tooltip.umd.js +5 -0
  2. package/{dist/es/constants.d.ts → constants.d.ts} +0 -0
  3. package/{dist/es2015 → esm2015}/constants.js +0 -0
  4. package/{dist/es/models/functions.model.js → esm2015/kendo-angular-tooltip.js} +4 -0
  5. package/esm2015/localization/localized-messages.directive.js +38 -0
  6. package/{dist/es → esm2015}/main.js +2 -0
  7. package/{dist/es2015 → esm2015}/models/animation.model.js +1 -0
  8. package/{dist/es2015 → esm2015}/models/events.js +0 -0
  9. package/{dist/es2015 → esm2015}/models/functions.model.js +1 -0
  10. package/{dist/es → esm2015}/models/popover-show-option.type.js +1 -0
  11. package/{dist/es2015 → esm2015}/models/position.type.js +1 -0
  12. package/{dist/es → esm2015}/models/show.option.type.js +1 -0
  13. package/{dist/es2015 → esm2015}/package-metadata.js +1 -1
  14. package/{dist/es2015 → esm2015}/popover/anchor.directive.js +22 -19
  15. package/{dist/es2015 → esm2015}/popover/container.directive.js +24 -23
  16. package/{dist/es2015 → esm2015}/popover/directives-base.js +13 -12
  17. package/{dist/es2015 → esm2015}/popover/popover.component.js +118 -108
  18. package/{dist/es2015 → esm2015}/popover/popover.service.js +9 -9
  19. package/esm2015/popover/template-directives/actions-template.directive.js +27 -0
  20. package/esm2015/popover/template-directives/body-template.directive.js +27 -0
  21. package/esm2015/popover/template-directives/title-template.directive.js +27 -0
  22. package/{dist/es2015 → esm2015}/popover.module.js +31 -16
  23. package/{dist/es2015 → esm2015}/tooltip/tooltip.content.component.js +95 -73
  24. package/{dist/es2015 → esm2015}/tooltip/tooltip.directive.js +57 -80
  25. package/{dist/es2015 → esm2015}/tooltip/tooltip.settings.js +12 -7
  26. package/{dist/es2015 → esm2015}/tooltip.module.js +15 -12
  27. package/{dist/es2015 → esm2015}/tooltips.module.js +12 -9
  28. package/{dist/es2015 → esm2015}/utils.js +0 -1
  29. package/{dist/fesm2015/index.js → fesm2015/kendo-angular-tooltip.js} +456 -399
  30. package/{dist/es2015/constants.d.ts → kendo-angular-tooltip.d.ts} +3 -6
  31. package/{dist/es2015/localization → localization}/localized-messages.directive.d.ts +3 -0
  32. package/{dist/es/main.d.ts → main.d.ts} +3 -0
  33. package/{dist/es/models → models}/animation.model.d.ts +0 -0
  34. package/{dist/es/models → models}/events.d.ts +0 -0
  35. package/{dist/es/models → models}/functions.model.d.ts +0 -0
  36. package/{dist/es/models → models}/popover-show-option.type.d.ts +0 -0
  37. package/{dist/es/models → models}/position.type.d.ts +0 -0
  38. package/{dist/es/models → models}/show.option.type.d.ts +0 -0
  39. package/{dist/es/package-metadata.d.ts → package-metadata.d.ts} +0 -0
  40. package/package.json +34 -113
  41. package/{dist/es2015/popover → popover}/anchor.directive.d.ts +3 -0
  42. package/{dist/es/popover → popover}/container.directive.d.ts +3 -0
  43. package/{dist/es2015/popover → popover}/directives-base.d.ts +9 -4
  44. package/{dist/es2015/popover → popover}/popover.component.d.ts +21 -8
  45. package/{dist/es/popover → popover}/popover.service.d.ts +7 -4
  46. package/{dist/es2015/popover → popover}/template-directives/actions-template.directive.d.ts +3 -0
  47. package/{dist/es2015/popover → popover}/template-directives/body-template.directive.d.ts +3 -0
  48. package/{dist/es2015/popover → popover}/template-directives/title-template.directive.d.ts +3 -0
  49. package/popover.module.d.ts +43 -0
  50. package/schematics/ngAdd/index.js +5 -2
  51. package/schematics/ngAdd/index.js.map +1 -1
  52. package/{dist/es/tooltip → tooltip}/tooltip.content.component.d.ts +7 -4
  53. package/{dist/es/tooltip → tooltip}/tooltip.directive.d.ts +5 -1
  54. package/{dist/es/tooltip → tooltip}/tooltip.settings.d.ts +7 -0
  55. package/{dist/es2015/tooltip.module.d.ts → tooltip.module.d.ts} +9 -0
  56. package/{dist/es2015/tooltips.module.d.ts → tooltips.module.d.ts} +6 -0
  57. package/{dist/es/utils.d.ts → utils.d.ts} +0 -0
  58. package/dist/cdn/js/kendo-angular-tooltip.js +0 -20
  59. package/dist/cdn/main.js +0 -5
  60. package/dist/es/constants.js +0 -12
  61. package/dist/es/index.d.ts +0 -12
  62. package/dist/es/index.js +0 -12
  63. package/dist/es/index.metadata.json +0 -1
  64. package/dist/es/localization/localized-messages.directive.d.ts +0 -16
  65. package/dist/es/localization/localized-messages.directive.js +0 -38
  66. package/dist/es/models/animation.model.js +0 -4
  67. package/dist/es/models/events.js +0 -78
  68. package/dist/es/models/position.type.js +0 -4
  69. package/dist/es/package-metadata.js +0 -15
  70. package/dist/es/popover/anchor.directive.d.ts +0 -44
  71. package/dist/es/popover/anchor.directive.js +0 -156
  72. package/dist/es/popover/container.directive.js +0 -182
  73. package/dist/es/popover/directives-base.d.ts +0 -90
  74. package/dist/es/popover/directives-base.js +0 -294
  75. package/dist/es/popover/popover.component.d.ts +0 -166
  76. package/dist/es/popover/popover.component.js +0 -300
  77. package/dist/es/popover/popover.service.js +0 -88
  78. package/dist/es/popover/template-directives/actions-template.directive.d.ts +0 -15
  79. package/dist/es/popover/template-directives/actions-template.directive.js +0 -26
  80. package/dist/es/popover/template-directives/body-template.directive.d.ts +0 -15
  81. package/dist/es/popover/template-directives/body-template.directive.js +0 -26
  82. package/dist/es/popover/template-directives/title-template.directive.d.ts +0 -15
  83. package/dist/es/popover/template-directives/title-template.directive.js +0 -26
  84. package/dist/es/popover.module.d.ts +0 -31
  85. package/dist/es/popover.module.js +0 -65
  86. package/dist/es/tooltip/tooltip.content.component.js +0 -192
  87. package/dist/es/tooltip/tooltip.directive.js +0 -452
  88. package/dist/es/tooltip/tooltip.settings.js +0 -46
  89. package/dist/es/tooltip.module.d.ts +0 -36
  90. package/dist/es/tooltip.module.js +0 -57
  91. package/dist/es/tooltips.module.d.ts +0 -32
  92. package/dist/es/tooltips.module.js +0 -45
  93. package/dist/es/utils.js +0 -113
  94. package/dist/es2015/index.d.ts +0 -12
  95. package/dist/es2015/index.js +0 -12
  96. package/dist/es2015/index.metadata.json +0 -1
  97. package/dist/es2015/localization/localized-messages.directive.js +0 -34
  98. package/dist/es2015/main.d.ts +0 -22
  99. package/dist/es2015/main.js +0 -18
  100. package/dist/es2015/models/animation.model.d.ts +0 -9
  101. package/dist/es2015/models/events.d.ts +0 -78
  102. package/dist/es2015/models/functions.model.d.ts +0 -17
  103. package/dist/es2015/models/popover-show-option.type.d.ts +0 -8
  104. package/dist/es2015/models/popover-show-option.type.js +0 -4
  105. package/dist/es2015/models/position.type.d.ts +0 -14
  106. package/dist/es2015/models/show.option.type.d.ts +0 -13
  107. package/dist/es2015/models/show.option.type.js +0 -4
  108. package/dist/es2015/package-metadata.d.ts +0 -9
  109. package/dist/es2015/popover/container.directive.d.ts +0 -56
  110. package/dist/es2015/popover/popover.service.d.ts +0 -30
  111. package/dist/es2015/popover/template-directives/actions-template.directive.js +0 -25
  112. package/dist/es2015/popover/template-directives/body-template.directive.js +0 -25
  113. package/dist/es2015/popover/template-directives/title-template.directive.js +0 -25
  114. package/dist/es2015/popover.module.d.ts +0 -31
  115. package/dist/es2015/tooltip/tooltip.content.component.d.ts +0 -41
  116. package/dist/es2015/tooltip/tooltip.directive.d.ts +0 -156
  117. package/dist/es2015/tooltip/tooltip.settings.d.ts +0 -72
  118. package/dist/es2015/utils.d.ts +0 -34
  119. package/dist/fesm5/index.js +0 -2071
  120. package/dist/npm/constants.js +0 -14
  121. package/dist/npm/index.js +0 -19
  122. package/dist/npm/localization/localized-messages.directive.js +0 -40
  123. package/dist/npm/main.js +0 -36
  124. package/dist/npm/models/animation.model.js +0 -6
  125. package/dist/npm/models/events.js +0 -80
  126. package/dist/npm/models/functions.model.js +0 -6
  127. package/dist/npm/models/popover-show-option.type.js +0 -6
  128. package/dist/npm/models/position.type.js +0 -6
  129. package/dist/npm/models/show.option.type.js +0 -6
  130. package/dist/npm/package-metadata.js +0 -17
  131. package/dist/npm/popover/anchor.directive.js +0 -158
  132. package/dist/npm/popover/container.directive.js +0 -184
  133. package/dist/npm/popover/directives-base.js +0 -296
  134. package/dist/npm/popover/popover.component.js +0 -302
  135. package/dist/npm/popover/popover.service.js +0 -90
  136. package/dist/npm/popover/template-directives/actions-template.directive.js +0 -28
  137. package/dist/npm/popover/template-directives/body-template.directive.js +0 -28
  138. package/dist/npm/popover/template-directives/title-template.directive.js +0 -28
  139. package/dist/npm/popover.module.js +0 -67
  140. package/dist/npm/tooltip/tooltip.content.component.js +0 -194
  141. package/dist/npm/tooltip/tooltip.directive.js +0 -454
  142. package/dist/npm/tooltip/tooltip.settings.js +0 -48
  143. package/dist/npm/tooltip.module.js +0 -59
  144. package/dist/npm/tooltips.module.js +0 -47
  145. package/dist/npm/utils.js +0 -121
  146. package/dist/systemjs/kendo-angular-tooltip.js +0 -5
@@ -1,2071 +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, __metadata, __param, __extends } from 'tslib';
6
- import { InjectionToken, Injectable, HostBinding, Output, EventEmitter, Input, TemplateRef, ElementRef, Component, isDevMode, Directive, Optional, Inject, NgZone, Renderer2, ContentChild, forwardRef, NgModule } from '@angular/core';
7
- import { take, filter, debounceTime, auditTime } from 'rxjs/operators';
8
- import { fromEvent, Subscription, combineLatest, BehaviorSubject, Subject } from 'rxjs';
9
- import { PopupService, PopupModule } from '@progress/kendo-angular-popup';
10
- import { validatePackage } from '@progress/kendo-licensing';
11
- import { LocalizationService, L10N_PREFIX, ComponentMessages } from '@progress/kendo-angular-l10n';
12
- import { PreventableEvent, isDocumentAvailable, closest, hasObservers } from '@progress/kendo-angular-common';
13
- import { CommonModule } from '@angular/common';
14
-
15
- /**
16
- * @hidden
17
- */
18
- var packageMetadata = {
19
- name: '@progress/kendo-angular-tooltip',
20
- productName: 'Kendo UI for Angular',
21
- productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
22
- publishDate: 1646219971,
23
- version: '',
24
- 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'
25
- };
26
-
27
- /**
28
- * Obsolete. Provide the TooltipSettings class instead.
29
- *
30
- * @hidden
31
- */
32
- var TOOLTIP_SETTINGS = new InjectionToken('kendo-ui-tooltip-settings');
33
- /**
34
- * Provides a global configuration for the Kendo UI Tooltip. Once injected through
35
- * the `AppComponent` constructor, the configuration properties can be overridden.
36
- *
37
- * @example
38
- * ```ts-no-run
39
- * import { TooltipSettings } from '@progress/kendo-angular-tooltip';
40
- *
41
- * _@Component({
42
- * selector: 'my-app',
43
- * template: `
44
- * <div kendoTooltip>
45
- * <button title="Saves the current document">Save</button>
46
- * </div>`,
47
- * providers: [{
48
- * provide: TooltipSettings,
49
- * useFactory: (): TooltipSettings => ({
50
- * // Override default values of tooltips if wanted
51
- * position: 'right'
52
- * })
53
- * }]
54
- * })
55
- * export class AppComponent { }
56
- * ```
57
- */
58
- var TooltipSettings = /** @class */ (function () {
59
- function TooltipSettings() {
60
- }
61
- TooltipSettings = __decorate([
62
- Injectable()
63
- ], TooltipSettings);
64
- return TooltipSettings;
65
- }());
66
-
67
- /**
68
- * @hidden
69
- */
70
- function align(position, offset) {
71
- var anchorAlign = {};
72
- var popupAlign = {};
73
- var popupMargin = {};
74
- switch (position) {
75
- case 'top':
76
- anchorAlign = { horizontal: 'center', vertical: 'top' };
77
- popupAlign = { horizontal: 'center', vertical: 'bottom' };
78
- popupMargin = { horizontal: 0, vertical: offset };
79
- break;
80
- case 'bottom':
81
- anchorAlign = { horizontal: 'center', vertical: 'bottom' };
82
- popupAlign = { horizontal: 'center', vertical: 'top' };
83
- popupMargin = { horizontal: 0, vertical: offset };
84
- break;
85
- case 'right':
86
- anchorAlign = { horizontal: 'right', vertical: 'center' };
87
- popupAlign = { horizontal: 'left', vertical: 'center' };
88
- popupMargin = { horizontal: offset, vertical: 0 };
89
- break;
90
- case 'left':
91
- anchorAlign = { horizontal: 'left', vertical: 'center' };
92
- popupAlign = { horizontal: 'right', vertical: 'center' };
93
- popupMargin = { horizontal: offset, vertical: 0 };
94
- break;
95
- default: break;
96
- }
97
- return {
98
- anchorAlign: anchorAlign,
99
- popupAlign: popupAlign,
100
- popupMargin: popupMargin
101
- };
102
- }
103
- /**
104
- * @hidden
105
- */
106
- function collision(inputcollision, position) {
107
- if (inputcollision) {
108
- return inputcollision;
109
- }
110
- if (position === 'top' || position === 'bottom') {
111
- return { horizontal: 'fit', vertical: 'flip' };
112
- }
113
- return { horizontal: 'flip', vertical: 'fit' };
114
- }
115
- function isDocumentNode(container) {
116
- return container.nodeType === 9;
117
- }
118
- /**
119
- * @hidden
120
- */
121
- function closestBySelector(element, selector) {
122
- if (element.closest) {
123
- return element.closest(selector);
124
- }
125
- var matches = Element.prototype.matches ?
126
- function (el, sel) { return el.matches(sel); }
127
- : function (el, sel) { return el.msMatchesSelector(sel); };
128
- var node = element;
129
- while (node && !isDocumentNode(node)) {
130
- if (matches(node, selector)) {
131
- return node;
132
- }
133
- node = node.parentNode;
134
- }
135
- }
136
- /**
137
- * @hidden
138
- */
139
- function contains(container, child) {
140
- if (!container) {
141
- return false;
142
- }
143
- if (isDocumentNode(container)) {
144
- return false;
145
- }
146
- if (container.contains) {
147
- return container.contains(child);
148
- }
149
- if (container.compareDocumentPosition) {
150
- // tslint:disable-next-line
151
- return !!(container.compareDocumentPosition(child) & Node.DOCUMENT_POSITION_CONTAINED_BY);
152
- }
153
- }
154
- /**
155
- * @hidden
156
- */
157
- var hasParent = function (node, parent) {
158
- while (node && node !== parent) {
159
- node = node.parentNode;
160
- }
161
- return node;
162
- };
163
- /**
164
- * @hidden
165
- */
166
- function getCenterOffset(item, dir, size) {
167
- var rect = item.getBoundingClientRect();
168
- return rect[dir] + (rect[size] / 2);
169
- }
170
- /**
171
- * @hidden
172
- */
173
- function containsItem(collection, item) {
174
- return collection.indexOf(item) !== -1;
175
- }
176
-
177
- /**
178
- * @hidden
179
- */
180
- var TooltipContentComponent = /** @class */ (function () {
181
- function TooltipContentComponent(content, localizationService) {
182
- this.content = content;
183
- this.localizationService = localizationService;
184
- this.close = new EventEmitter();
185
- this.tooltipWidth = null;
186
- this.tooltipHeight = null;
187
- this.callout = true;
188
- this.calloutStyles = function (position, calloutSize, isFlip) {
189
- var styles = {};
190
- var isVertical = position === 'top' || position === 'bottom';
191
- var flipDeg = '180deg';
192
- var zeroDeg = '0deg';
193
- if (!isFlip) {
194
- styles.transform = isVertical ? "rotateX(" + zeroDeg + ")" : "rotateY(" + zeroDeg + ")";
195
- return styles;
196
- }
197
- if (position === 'top') {
198
- styles.bottom = 'unset';
199
- }
200
- else if (position === 'bottom') {
201
- styles.top = 'unset';
202
- }
203
- else if (position === 'left') {
204
- styles.right = 'unset';
205
- }
206
- else if (position === 'right') {
207
- styles.left = 'unset';
208
- }
209
- styles[position] = -calloutSize + "px";
210
- styles.transform = isVertical ? "rotateX(" + flipDeg + ")" : "rotateY(" + flipDeg + ")";
211
- return styles;
212
- };
213
- this.direction = localizationService.rtl ? 'rtl' : 'ltr';
214
- }
215
- Object.defineProperty(TooltipContentComponent.prototype, "cssClasses", {
216
- get: function () {
217
- return 'k-widget k-tooltip';
218
- },
219
- enumerable: true,
220
- configurable: true
221
- });
222
- Object.defineProperty(TooltipContentComponent.prototype, "className", {
223
- get: function () {
224
- return this.closable;
225
- },
226
- enumerable: true,
227
- configurable: true
228
- });
229
- Object.defineProperty(TooltipContentComponent.prototype, "cssPosition", {
230
- get: function () {
231
- return 'relative';
232
- },
233
- enumerable: true,
234
- configurable: true
235
- });
236
- TooltipContentComponent.prototype.ngOnInit = function () {
237
- var _this = this;
238
- this.dynamicRTLSubscription = this.localizationService.changes
239
- .subscribe(function (_a) {
240
- var rtl = _a.rtl;
241
- return _this.direction = rtl ? 'rtl' : 'ltr';
242
- });
243
- };
244
- TooltipContentComponent.prototype.ngOnDestroy = function () {
245
- if (this.dynamicRTLSubscription) {
246
- this.dynamicRTLSubscription.unsubscribe();
247
- }
248
- };
249
- Object.defineProperty(TooltipContentComponent.prototype, "closeButtonTitle", {
250
- get: function () {
251
- return this.closeTitle || this.localizationService.get('closeTitle');
252
- },
253
- enumerable: true,
254
- configurable: true
255
- });
256
- TooltipContentComponent.prototype.calloutPositionClass = function () {
257
- return {
258
- 'top': 'k-callout-s',
259
- 'left': 'k-callout-e',
260
- 'bottom': 'k-callout-n',
261
- 'right': 'k-callout-w'
262
- }[this.position];
263
- };
264
- TooltipContentComponent.prototype.onCloseClick = function (event) {
265
- event.preventDefault();
266
- this.close.emit();
267
- };
268
- TooltipContentComponent.prototype.updateCalloutPosition = function (position, isFlip) {
269
- if (!this.callout) {
270
- return;
271
- }
272
- var callout = this.content.nativeElement.querySelector('.k-callout');
273
- var isVertical = position === 'top' || position === 'bottom';
274
- var size = isVertical ? 'width' : 'height';
275
- var dir = isVertical ? 'left' : 'top';
276
- var offsetProperty = isVertical ? 'marginLeft' : 'marginTop';
277
- var calloutSize = callout.getBoundingClientRect()[size];
278
- var anchorCenter = getCenterOffset(this.anchor.nativeElement, dir, size);
279
- var contentCenter = getCenterOffset(this.content.nativeElement, dir, size);
280
- var diff = Math.abs(contentCenter - anchorCenter);
281
- if (diff > 1 || diff === 0 || Math.round(diff) === 0) {
282
- var newMargin = contentCenter - anchorCenter + (calloutSize / 2);
283
- callout.style[offsetProperty] = -newMargin + "px";
284
- }
285
- var calloutStyles = this.calloutStyles(position, calloutSize, isFlip);
286
- Object.keys(calloutStyles).forEach(function (style) {
287
- callout.style[style] = calloutStyles[style];
288
- });
289
- };
290
- __decorate([
291
- HostBinding('attr.dir'),
292
- __metadata("design:type", String)
293
- ], TooltipContentComponent.prototype, "direction", void 0);
294
- __decorate([
295
- Output(),
296
- __metadata("design:type", EventEmitter)
297
- ], TooltipContentComponent.prototype, "close", void 0);
298
- __decorate([
299
- HostBinding('class'),
300
- __metadata("design:type", String),
301
- __metadata("design:paramtypes", [])
302
- ], TooltipContentComponent.prototype, "cssClasses", null);
303
- __decorate([
304
- HostBinding('class.k-tooltip-closable'),
305
- __metadata("design:type", Boolean),
306
- __metadata("design:paramtypes", [])
307
- ], TooltipContentComponent.prototype, "className", null);
308
- __decorate([
309
- HostBinding('style.position'),
310
- __metadata("design:type", String),
311
- __metadata("design:paramtypes", [])
312
- ], TooltipContentComponent.prototype, "cssPosition", null);
313
- __decorate([
314
- HostBinding('style.width.px'),
315
- Input(),
316
- __metadata("design:type", Number)
317
- ], TooltipContentComponent.prototype, "tooltipWidth", void 0);
318
- __decorate([
319
- HostBinding('style.height.px'),
320
- Input(),
321
- __metadata("design:type", Number)
322
- ], TooltipContentComponent.prototype, "tooltipHeight", void 0);
323
- __decorate([
324
- Input(),
325
- __metadata("design:type", TemplateRef)
326
- ], TooltipContentComponent.prototype, "titleTemplate", void 0);
327
- __decorate([
328
- Input(),
329
- __metadata("design:type", ElementRef)
330
- ], TooltipContentComponent.prototype, "anchor", void 0);
331
- __decorate([
332
- Input(),
333
- __metadata("design:type", Boolean)
334
- ], TooltipContentComponent.prototype, "closable", void 0);
335
- __decorate([
336
- Input(),
337
- __metadata("design:type", TemplateRef)
338
- ], TooltipContentComponent.prototype, "templateRef", void 0);
339
- __decorate([
340
- Input(),
341
- __metadata("design:type", String)
342
- ], TooltipContentComponent.prototype, "templateString", void 0);
343
- TooltipContentComponent = __decorate([
344
- Component({
345
- selector: 'kendo-tooltip',
346
- template: "\n <ng-container kendoTooltipLocalizedMessages\n i18n-closeTitle=\"kendo.tooltip.closeTitle|The title of the close button\"\n closeTitle=\"Close\"\n >\n </ng-container>\n\n <div class=\"k-tooltip-content\">\n <div class=\"k-tooltip-title\" *ngIf=\"titleTemplate\">\n <ng-template\n [ngIf]=\"titleTemplate\"\n [ngTemplateOutlet]=\"titleTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: anchor, anchor: anchor }\">\n </ng-template>\n </div>\n\n <ng-template\n [ngIf]=\"templateRef\"\n [ngTemplateOutlet]=\"templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: anchor, anchor: anchor }\">\n </ng-template>\n <ng-template\n [ngIf]=\"templateString\">\n {{ templateString }}\n </ng-template>\n </div>\n\n <div *ngIf=\"closable\" class=\"k-tooltip-button\" (click)=\"onCloseClick($event)\">\n <a href=\"#\" class=\"k-icon k-i-close\" [attr.title]=\"closeButtonTitle\"></a>\n </div>\n\n <div class=\"k-callout\" *ngIf=\"callout\" [ngClass]=\"calloutPositionClass()\"></div>\n ",
347
- providers: [
348
- LocalizationService,
349
- {
350
- provide: L10N_PREFIX,
351
- useValue: 'kendo.tooltip'
352
- }
353
- ]
354
- }),
355
- __metadata("design:paramtypes", [ElementRef,
356
- LocalizationService])
357
- ], TooltipContentComponent);
358
- return TooltipContentComponent;
359
- }());
360
-
361
- /**
362
- * Represents the [Kendo UI Tooltip directive for Angular]({% slug overview_tooltip %}).
363
- * Used to display additional information that is related to an element.
364
- *
365
- * @example
366
- * ```ts-no-run
367
- * <div kendoTooltip>
368
- * <a title="Tooltip title" href="foo">foo</a>
369
- * </div>
370
- * ```
371
- */
372
- var TooltipDirective = /** @class */ (function () {
373
- function TooltipDirective(tooltipWrapper, ngZone, renderer, popupService, settings, legacySettings) {
374
- var _this = this;
375
- this.tooltipWrapper = tooltipWrapper;
376
- this.ngZone = ngZone;
377
- this.renderer = renderer;
378
- this.popupService = popupService;
379
- /**
380
- * Specifies a selector for elements within a container which will display a tooltip
381
- * ([see example]({% slug anchorelements_tooltip %})). The possible values include any
382
- * DOM `selector`. The default value is `[title]`.
383
- */
384
- this.filter = '[title]';
385
- /**
386
- * Specifies the position of the Tooltip that is relative to the
387
- * anchor element ([see example]({% slug positioning_tooltip %})).
388
- *
389
- * The possible values are:
390
- * * `top` (default)
391
- * * `bottom`
392
- * * `left`
393
- * * `right`
394
- */
395
- this.position = 'top';
396
- /**
397
- * Specifies the delay in milliseconds before the Tooltip is shown.
398
- * * `100` (default) milliseconds.
399
- */
400
- this.showAfter = 100;
401
- /**
402
- * Specifies if the Тooltip will display a callout arrow.
403
- *
404
- * The possible values are:
405
- * * `true` (default)
406
- * * `false`
407
- */
408
- this.callout = true;
409
- /**
410
- * Specifies if the Тooltip will display a **Close** button
411
- * ([see example]({% slug closable_tooltip %})).
412
- *
413
- * The possible values are:
414
- * * `true`
415
- * * `false`
416
- */
417
- this.closable = false;
418
- /**
419
- * Specifies the offset in pixels between the Tooltip and the anchor. Defaults to `6` pixels.
420
- * If the `callout` property is set to `true`, the offset is rendered from the callout arrow.
421
- * If the `callout` property is set to `false`, the offset is rendered from the content of the Tooltip.
422
- */
423
- this.offset = 6;
424
- this.anchor = null;
425
- this.validPositions = ['top', 'bottom', 'right', 'left'];
426
- this.validShowOptions = ['hover', 'click', 'none'];
427
- validatePackage(packageMetadata);
428
- Object.assign(this, settings, legacySettings);
429
- this.ngZone.runOutsideAngular(function () {
430
- var wrapper = _this.tooltipWrapper.nativeElement;
431
- _this.anchorTitleSubscription = fromEvent(wrapper, 'mouseover')
432
- .pipe(filter(function () { return _this.filter !== ''; }))
433
- .subscribe(function (e) {
434
- var filterElement = closestBySelector(e.target, _this.filter);
435
- if (filterElement) {
436
- _this.hideElementTitle({ nativeElement: filterElement });
437
- }
438
- });
439
- _this.mouseOverSubscription = fromEvent(wrapper, 'mouseover')
440
- .pipe(debounceTime(100), filter(function () { return _this.filter !== ''; }))
441
- .subscribe(function (e) { return _this.onMouseOver(e); });
442
- _this.mouseOutSubscription = fromEvent(wrapper, 'mouseout')
443
- .pipe(debounceTime(100))
444
- .subscribe(function (e) { return _this.onMouseOut(e); });
445
- });
446
- }
447
- Object.defineProperty(TooltipDirective.prototype, "tooltipTemplate", {
448
- get: function () { return this.template; },
449
- /**
450
- * Sets the content of the Tooltip as a template reference
451
- * ([see example]({% slug templates_tooltip %})).
452
- */
453
- set: function (value) {
454
- this.template = value;
455
- },
456
- enumerable: true,
457
- configurable: true
458
- });
459
- /**
460
- * Shows the Tooltip.
461
- * @param anchor&mdash; ElementRef|Element.
462
- * Specifies the element that will be used as an anchor. The Tooltip opens relative to that element.
463
- */
464
- TooltipDirective.prototype.show = function (anchor) {
465
- var _this = this;
466
- if (this.popupRef) {
467
- return;
468
- }
469
- if (anchor instanceof Element) {
470
- anchor = { nativeElement: anchor };
471
- }
472
- this.anchor = anchor;
473
- if (this.showOn === 'hover') {
474
- if (this.popupRef) {
475
- return;
476
- }
477
- clearTimeout(this.showTimeout);
478
- this.showTimeout = window.setTimeout(function () { return _this.showContent(_this.anchor); }, this.showAfter);
479
- }
480
- else {
481
- this.hideElementTitle(this.anchor);
482
- this.showContent(this.anchor);
483
- }
484
- };
485
- /**
486
- * Hides the Tooltip.
487
- */
488
- TooltipDirective.prototype.hide = function () {
489
- clearTimeout(this.showTimeout);
490
- var anchor = this.anchor && this.anchor.nativeElement;
491
- if (anchor && anchor.getAttribute('data-title')) {
492
- if (!anchor.getAttribute('title') && anchor.hasAttribute('title')) {
493
- anchor.setAttribute('title', anchor.getAttribute('data-title'));
494
- }
495
- anchor.setAttribute('data-title', '');
496
- }
497
- if (this.popupMouseOutSubscription) {
498
- this.popupMouseOutSubscription.unsubscribe();
499
- }
500
- if (this.closeClickSubscription) {
501
- this.closeClickSubscription.unsubscribe();
502
- }
503
- this.closePopup();
504
- };
505
- /**
506
- * Toggle visibility of the Tooltip.
507
- *
508
- * @param anchor&mdash; ElementRef|Element. Specifies the element that will be used as an anchor.
509
- * @param show&mdash; Optional. Boolean. Specifies if the Tooltip will be rendered.
510
- */
511
- TooltipDirective.prototype.toggle = function (anchor, show) {
512
- var previousAnchor = this.anchor && this.anchor.nativeElement;
513
- if (anchor instanceof Element) {
514
- anchor = { nativeElement: anchor };
515
- }
516
- if (previousAnchor !== anchor.nativeElement) {
517
- this.hide();
518
- }
519
- if (previousAnchor === anchor.nativeElement && this.showOn === 'click') {
520
- this.hide();
521
- }
522
- if (typeof show === 'undefined') {
523
- show = !this.popupRef;
524
- }
525
- if (show) {
526
- this.show(anchor);
527
- }
528
- else {
529
- this.hide();
530
- }
531
- };
532
- TooltipDirective.prototype.ngOnInit = function () {
533
- if (this.showOn === undefined) {
534
- this.showOn = 'hover';
535
- }
536
- this.verifyProperties();
537
- };
538
- TooltipDirective.prototype.ngOnChanges = function (changes) {
539
- if (changes.showOn) {
540
- this.subscribeClick();
541
- }
542
- };
543
- TooltipDirective.prototype.ngAfterViewChecked = function () {
544
- if (!this.popupRef) {
545
- return;
546
- }
547
- if (this.anchor &&
548
- !hasParent(this.anchor.nativeElement || this.anchor, this.tooltipWrapper.nativeElement)) {
549
- this.anchor = null;
550
- this.hide();
551
- }
552
- };
553
- TooltipDirective.prototype.ngOnDestroy = function () {
554
- this.hide();
555
- this.template = null;
556
- this.anchorTitleSubscription.unsubscribe();
557
- this.mouseOverSubscription.unsubscribe();
558
- this.mouseOutSubscription.unsubscribe();
559
- if (this.mouseClickSubscription) {
560
- this.mouseClickSubscription.unsubscribe();
561
- }
562
- if (this.popupPositionChangeSubscription) {
563
- this.popupPositionChangeSubscription.unsubscribe();
564
- }
565
- if (this.popupMouseOutSubscription) {
566
- this.popupMouseOutSubscription.unsubscribe();
567
- }
568
- };
569
- TooltipDirective.prototype.showContent = function (anchorRef) {
570
- var _this = this;
571
- if (!anchorRef.nativeElement.getAttribute('data-title') && !this.template) {
572
- return;
573
- }
574
- this.ngZone.run(function () {
575
- _this.openPopup(anchorRef);
576
- _this.bindContent(_this.popupRef.content, anchorRef);
577
- });
578
- this.popupRef.popupAnchorViewportLeave
579
- .pipe(take(1))
580
- .subscribe(function () { return _this.hide(); });
581
- };
582
- TooltipDirective.prototype.bindContent = function (contentComponent, anchorRef) {
583
- var _this = this;
584
- var content = contentComponent.instance;
585
- this.closeClickSubscription = content.close
586
- .subscribe(function () { _this.hide(); });
587
- if (!this.template) {
588
- content.templateString = this.anchor.nativeElement.getAttribute('data-title');
589
- }
590
- else {
591
- content.templateRef = this.template;
592
- }
593
- if (this.titleTemplate) {
594
- content.titleTemplate = this.titleTemplate;
595
- }
596
- content.closeTitle = this.closeTitle;
597
- content.anchor = anchorRef;
598
- content.callout = this.callout;
599
- content.closable = this.closable;
600
- content.position = this.position;
601
- content.tooltipWidth = this.tooltipWidth;
602
- content.tooltipHeight = this.tooltipHeight;
603
- this.popupRef.content.changeDetectorRef.detectChanges();
604
- };
605
- TooltipDirective.prototype.hideElementTitle = function (elementRef) {
606
- var element = elementRef.nativeElement;
607
- if (element.getAttribute('title')) {
608
- element.setAttribute('data-title', element.getAttribute('title'));
609
- element.setAttribute('title', '');
610
- }
611
- };
612
- TooltipDirective.prototype.openPopup = function (anchorRef) {
613
- var _this = this;
614
- var alignSettings = align(this.position, this.offset);
615
- var anchorAlign = alignSettings.anchorAlign;
616
- var popupAlign = alignSettings.popupAlign;
617
- var popupMargin = alignSettings.popupMargin;
618
- this.popupRef = this.popupService.open({
619
- anchor: anchorRef,
620
- anchorAlign: anchorAlign,
621
- animate: false,
622
- content: TooltipContentComponent,
623
- collision: collision(this.collision, this.position),
624
- margin: popupMargin,
625
- popupAlign: popupAlign,
626
- popupClass: 'k-popup-transparent'
627
- });
628
- this.renderer.addClass(this.popupRef.popupElement, 'k-tooltip-wrapper');
629
- if (this.tooltipClass) {
630
- this.renderer.addClass(this.popupRef.popupElement, this.tooltipClass);
631
- }
632
- var popupInstance = this.popupRef.content.instance;
633
- if (popupInstance.callout) {
634
- this.popupPositionChangeSubscription = this.popupRef.popupPositionChange
635
- .subscribe(function (_a) {
636
- var flip = _a.flip;
637
- var isFlip = flip.horizontal === true || flip.vertical === true;
638
- popupInstance.updateCalloutPosition(_this.position, isFlip);
639
- });
640
- }
641
- if (this.showOn === 'hover') {
642
- this.ngZone.runOutsideAngular(function () {
643
- var popup = _this.popupRef.popupElement;
644
- _this.popupMouseOutSubscription = fromEvent(popup, 'mouseout')
645
- .subscribe(function (e) { return _this.onMouseOut(e); });
646
- });
647
- }
648
- };
649
- TooltipDirective.prototype.closePopup = function () {
650
- if (this.popupRef) {
651
- this.popupRef.close();
652
- this.popupRef = null;
653
- }
654
- if (this.popupPositionChangeSubscription) {
655
- this.popupPositionChangeSubscription.unsubscribe();
656
- }
657
- };
658
- TooltipDirective.prototype.subscribeClick = function () {
659
- var _this = this;
660
- if (this.mouseClickSubscription) {
661
- this.mouseClickSubscription.unsubscribe();
662
- }
663
- if (this.showOn === 'click') {
664
- this.mouseClickSubscription = fromEvent(document, 'click')
665
- .pipe(filter(function () { return _this.filter !== ''; }))
666
- .subscribe(function (e) { return _this.onMouseClick(e, _this.tooltipWrapper.nativeElement); });
667
- }
668
- };
669
- TooltipDirective.prototype.onMouseClick = function (e, wrapper) {
670
- var target = e.target;
671
- var filterElement = closestBySelector(target, this.filter);
672
- var popup = this.popupRef && this.popupRef.popupElement;
673
- if (popup) {
674
- if (popup.contains(target)) {
675
- return;
676
- }
677
- if (this.closable) {
678
- return;
679
- }
680
- }
681
- if (wrapper.contains(target) && filterElement) {
682
- this.toggle(filterElement, true);
683
- }
684
- else if (popup) {
685
- this.hide();
686
- }
687
- };
688
- TooltipDirective.prototype.onMouseOver = function (e) {
689
- var filterElement = closestBySelector(e.target, this.filter);
690
- if (this.showOn !== 'hover') {
691
- return;
692
- }
693
- if (filterElement) {
694
- this.toggle(filterElement, true);
695
- }
696
- };
697
- TooltipDirective.prototype.onMouseOut = function (e) {
698
- if (this.showOn !== 'hover') {
699
- return;
700
- }
701
- if (this.closable) {
702
- return;
703
- }
704
- var popup = this.popupRef && this.popupRef.popupElement;
705
- var relatedTarget = e.relatedTarget;
706
- if (relatedTarget && this.anchor && contains(this.anchor.nativeElement, relatedTarget)) {
707
- return;
708
- }
709
- if (relatedTarget && contains(popup, relatedTarget)) {
710
- return;
711
- }
712
- this.hide();
713
- };
714
- TooltipDirective.prototype.verifyProperties = function () {
715
- if (!isDevMode()) {
716
- return;
717
- }
718
- if (!containsItem(this.validPositions, this.position)) {
719
- throw new Error("Invalid value provided for position property.The available options are 'top', 'bottom', 'left', or 'right'.");
720
- }
721
- if (!containsItem(this.validShowOptions, this.showOn)) {
722
- throw new Error("Invalid value provided for showOn property.The available options are 'hover' or 'none'.");
723
- }
724
- };
725
- __decorate([
726
- Input(),
727
- __metadata("design:type", String)
728
- ], TooltipDirective.prototype, "filter", void 0);
729
- __decorate([
730
- Input(),
731
- __metadata("design:type", String)
732
- ], TooltipDirective.prototype, "position", void 0);
733
- __decorate([
734
- Input(),
735
- __metadata("design:type", TemplateRef)
736
- ], TooltipDirective.prototype, "titleTemplate", void 0);
737
- __decorate([
738
- Input(),
739
- __metadata("design:type", String)
740
- ], TooltipDirective.prototype, "showOn", void 0);
741
- __decorate([
742
- Input(),
743
- __metadata("design:type", Number)
744
- ], TooltipDirective.prototype, "showAfter", void 0);
745
- __decorate([
746
- Input(),
747
- __metadata("design:type", Boolean)
748
- ], TooltipDirective.prototype, "callout", void 0);
749
- __decorate([
750
- Input(),
751
- __metadata("design:type", Boolean)
752
- ], TooltipDirective.prototype, "closable", void 0);
753
- __decorate([
754
- Input(),
755
- __metadata("design:type", Number)
756
- ], TooltipDirective.prototype, "offset", void 0);
757
- __decorate([
758
- Input(),
759
- __metadata("design:type", Number)
760
- ], TooltipDirective.prototype, "tooltipWidth", void 0);
761
- __decorate([
762
- Input(),
763
- __metadata("design:type", Number)
764
- ], TooltipDirective.prototype, "tooltipHeight", void 0);
765
- __decorate([
766
- Input(),
767
- __metadata("design:type", String)
768
- ], TooltipDirective.prototype, "tooltipClass", void 0);
769
- __decorate([
770
- Input(),
771
- __metadata("design:type", Object)
772
- ], TooltipDirective.prototype, "collision", void 0);
773
- __decorate([
774
- Input(),
775
- __metadata("design:type", String)
776
- ], TooltipDirective.prototype, "closeTitle", void 0);
777
- __decorate([
778
- Input(),
779
- __metadata("design:type", TemplateRef),
780
- __metadata("design:paramtypes", [TemplateRef])
781
- ], TooltipDirective.prototype, "tooltipTemplate", null);
782
- TooltipDirective = __decorate([
783
- Directive({
784
- selector: '[kendoTooltip]',
785
- exportAs: 'kendoTooltip'
786
- }),
787
- __param(4, Optional()),
788
- __param(5, Optional()), __param(5, Inject(TOOLTIP_SETTINGS)),
789
- __metadata("design:paramtypes", [ElementRef,
790
- NgZone,
791
- Renderer2,
792
- PopupService,
793
- TooltipSettings,
794
- TooltipSettings])
795
- ], TooltipDirective);
796
- return TooltipDirective;
797
- }());
798
-
799
- /**
800
- * @hidden
801
- */
802
- var ERRORS = {
803
- popover: "Invalid value provided for the 'popover' property. The accepted data types are 'PopoverComponent' or 'PopoverFn'.",
804
- templateData: "templateData must be a function, but received",
805
- showOn: "Invalid value provided for the 'showOn' property. The available options are 'click', 'hover', 'focus' or 'none'."
806
- };
807
-
808
- /**
809
- * Represents a template that defines the content of the Popover title.
810
- *
811
- * To define the template, nest an `<ng-template>` tag
812
- * with the `kendoPopoverTitleTemplate` directive inside the `<kendo-popover>` tag.
813
- */
814
- var PopoverTitleTemplateDirective = /** @class */ (function () {
815
- function PopoverTitleTemplateDirective(templateRef) {
816
- this.templateRef = templateRef;
817
- }
818
- PopoverTitleTemplateDirective = __decorate([
819
- Directive({
820
- selector: '[kendoPopoverTitleTemplate]'
821
- }),
822
- __param(0, Optional()),
823
- __metadata("design:paramtypes", [TemplateRef])
824
- ], PopoverTitleTemplateDirective);
825
- return PopoverTitleTemplateDirective;
826
- }());
827
-
828
- /**
829
- * Represents a template that defines the content of the Popover body.
830
- *
831
- * To define the template, nest an `<ng-template>` tag
832
- * with the `kendoPopoverBodyTemplate` directive inside the `<kendo-popover>` tag.
833
- */
834
- var PopoverBodyTemplateDirective = /** @class */ (function () {
835
- function PopoverBodyTemplateDirective(templateRef) {
836
- this.templateRef = templateRef;
837
- }
838
- PopoverBodyTemplateDirective = __decorate([
839
- Directive({
840
- selector: '[kendoPopoverBodyTemplate]'
841
- }),
842
- __param(0, Optional()),
843
- __metadata("design:paramtypes", [TemplateRef])
844
- ], PopoverBodyTemplateDirective);
845
- return PopoverBodyTemplateDirective;
846
- }());
847
-
848
- /**
849
- * Represents a template that defines the content of the Popover actions.
850
- *
851
- * To define the template, nest an `<ng-template>` tag
852
- * with the `kendoPopoverActionsTemplate` directive inside the `<kendo-popover>` tag.
853
- */
854
- var PopoverActionsTemplateDirective = /** @class */ (function () {
855
- function PopoverActionsTemplateDirective(templateRef) {
856
- this.templateRef = templateRef;
857
- }
858
- PopoverActionsTemplateDirective = __decorate([
859
- Directive({
860
- selector: '[kendoPopoverActionsTemplate]'
861
- }),
862
- __param(0, Optional()),
863
- __metadata("design:paramtypes", [TemplateRef])
864
- ], PopoverActionsTemplateDirective);
865
- return PopoverActionsTemplateDirective;
866
- }());
867
-
868
- /**
869
- * Represents the [Kendo UI Popover component for Angular]({% slug overview_popover %}).
870
- * Used to display additional information that is related to a target element.
871
- *
872
- * @example
873
- * ```ts-no-run
874
- * <kendo-popover>
875
- * <ng-template kendoPopoverTitleTemplate>Foo Title</ng-template>
876
- * <ng-template kendoPopoverBodyTemplate>Foo Body</ng-template>
877
- * <ng-template kendoPopoverActionsTemplate>Foo Actions</ng-template>
878
- * </kendo-popover>
879
- * ```
880
- */
881
- var PopoverComponent = /** @class */ (function () {
882
- function PopoverComponent(localization) {
883
- this.localization = localization;
884
- /**
885
- * Specifies the position of the Popover in relation to its anchor element. [See example]({% slug positioning_popover %})
886
- *
887
- * The possible options are:
888
- * `top`
889
- * `bottom`
890
- * `right` (Default)
891
- * `left`
892
- */
893
- this.position = 'right';
894
- /**
895
- * Determines whether a callout will be rendered along the Popover. [See example]({% slug callout_popover %})
896
- *
897
- * @default true
898
- */
899
- this.callout = true;
900
- /**
901
- * Enables and configures the Popover animation. [See example]({% slug animations_popover %})
902
- *
903
- * The possible options are:
904
- *
905
- * * `boolean`&mdash;Enables the default animation
906
- * * `PopoverAnimation`&mdash;A configuration object which allows setting the `direction`, `duration` and `type` of the animation.
907
- *
908
- * @default false
909
- */
910
- this.animation = false;
911
- /**
912
- * @hidden
913
- * Determines the visibility of the Popover.
914
- */
915
- this.visible = false;
916
- /**
917
- * Fires before the Popover is about to be shown ([see example]({% slug events_popover %})).
918
- * The event is preventable. If canceled, the Popover will not be displayed. [See example]({% slug events_popover %})
919
- */
920
- this.show = new EventEmitter();
921
- /**
922
- * Fires after the Popover has been shown and the animation has ended. [See example]({% slug events_popover %})
923
- */
924
- this.shown = new EventEmitter();
925
- /**
926
- * Fires when the Popover is about to be hidden ([see example]({% slug events_popover %})).
927
- * The event is preventable. If canceled, the Popover will remain visible.
928
- */
929
- this.hide = new EventEmitter();
930
- /**
931
- * Fires after the Popover has been hidden and the animation has ended. [See example]({% slug events_popover %})
932
- */
933
- this.hidden = new EventEmitter();
934
- this._offset = 6;
935
- this._width = 'auto';
936
- this._height = 'auto';
937
- this.subs = new Subscription();
938
- /**
939
- * @hidden
940
- */
941
- this._templateData = function () { return null; };
942
- validatePackage(packageMetadata);
943
- }
944
- Object.defineProperty(PopoverComponent.prototype, "offset", {
945
- get: function () {
946
- var calloutBuffer = 14;
947
- return this.callout
948
- ? calloutBuffer + this._offset
949
- : this._offset;
950
- },
951
- /**
952
- * Specifies the distance from the Popover to its anchor element in pixels.
953
- *
954
- * @default `6`
955
- */
956
- set: function (value) {
957
- this._offset = value;
958
- },
959
- enumerable: true,
960
- configurable: true
961
- });
962
- Object.defineProperty(PopoverComponent.prototype, "width", {
963
- get: function () {
964
- return this._width;
965
- },
966
- /**
967
- * Determines the width of the popover. Numeric values are treated as pixels.
968
- * @default 'auto'
969
- */
970
- set: function (value) {
971
- this._width = typeof value === 'number' ? value + "px" : value;
972
- },
973
- enumerable: true,
974
- configurable: true
975
- });
976
- Object.defineProperty(PopoverComponent.prototype, "height", {
977
- get: function () {
978
- return this._height;
979
- },
980
- /**
981
- * Determines the height of the popover. Numeric values are treated as pixels.
982
- * @default 'auto'
983
- */
984
- set: function (value) {
985
- this._height = typeof value === 'number' ? value + "px" : value;
986
- },
987
- enumerable: true,
988
- configurable: true
989
- });
990
- Object.defineProperty(PopoverComponent.prototype, "templateData", {
991
- get: function () {
992
- return this._templateData;
993
- },
994
- /**
995
- * Defines a callback function which returns custom data passed to the Popover templates.
996
- * It exposes the current anchor element as an argument. [See example]({% slug templates_popover %}#toc-popoverdatacallback)
997
- */
998
- set: function (fn) {
999
- if (isDevMode && typeof fn !== 'function') {
1000
- throw new Error(ERRORS.templateData + " " + JSON.stringify(fn) + ".");
1001
- }
1002
- this._templateData = fn;
1003
- },
1004
- enumerable: true,
1005
- configurable: true
1006
- });
1007
- Object.defineProperty(PopoverComponent.prototype, "isHidden", {
1008
- /**
1009
- * @hidden
1010
- */
1011
- get: function () {
1012
- return !this.visible;
1013
- },
1014
- enumerable: true,
1015
- configurable: true
1016
- });
1017
- Object.defineProperty(PopoverComponent.prototype, "hasAttributeHidden", {
1018
- /**
1019
- * @hidden
1020
- */
1021
- get: function () {
1022
- return !this.visible;
1023
- },
1024
- enumerable: true,
1025
- configurable: true
1026
- });
1027
- PopoverComponent.prototype.ngOnInit = function () {
1028
- var _this = this;
1029
- this.subs.add(this.localization.changes.subscribe(function (_a) {
1030
- var rtl = _a.rtl;
1031
- _this.direction = rtl ? 'rtl' : 'ltr';
1032
- }));
1033
- };
1034
- PopoverComponent.prototype.ngOnDestroy = function () {
1035
- this.subs.unsubscribe();
1036
- };
1037
- /**
1038
- * @hidden
1039
- */
1040
- PopoverComponent.prototype.getCalloutPosition = function () {
1041
- switch (this.position) {
1042
- case 'top': return { 'k-callout-s': true };
1043
- case 'bottom': return { 'k-callout-n': true };
1044
- case 'left': return { 'k-callout-e': true };
1045
- case 'right': return { 'k-callout-w': true };
1046
- default: return { 'k-callout-s': true };
1047
- }
1048
- };
1049
- __decorate([
1050
- Input(),
1051
- __metadata("design:type", String)
1052
- ], PopoverComponent.prototype, "position", void 0);
1053
- __decorate([
1054
- Input(),
1055
- __metadata("design:type", Number),
1056
- __metadata("design:paramtypes", [Number])
1057
- ], PopoverComponent.prototype, "offset", null);
1058
- __decorate([
1059
- HostBinding('style.width'),
1060
- Input(),
1061
- __metadata("design:type", Object),
1062
- __metadata("design:paramtypes", [Object])
1063
- ], PopoverComponent.prototype, "width", null);
1064
- __decorate([
1065
- HostBinding('style.height'),
1066
- Input(),
1067
- __metadata("design:type", Object),
1068
- __metadata("design:paramtypes", [Object])
1069
- ], PopoverComponent.prototype, "height", null);
1070
- __decorate([
1071
- HostBinding('attr.dir'),
1072
- __metadata("design:type", String)
1073
- ], PopoverComponent.prototype, "direction", void 0);
1074
- __decorate([
1075
- Input(),
1076
- __metadata("design:type", String)
1077
- ], PopoverComponent.prototype, "title", void 0);
1078
- __decorate([
1079
- Input(),
1080
- __metadata("design:type", String)
1081
- ], PopoverComponent.prototype, "subtitle", void 0);
1082
- __decorate([
1083
- Input(),
1084
- __metadata("design:type", String)
1085
- ], PopoverComponent.prototype, "body", void 0);
1086
- __decorate([
1087
- Input(),
1088
- __metadata("design:type", Boolean)
1089
- ], PopoverComponent.prototype, "callout", void 0);
1090
- __decorate([
1091
- Input(),
1092
- __metadata("design:type", Object)
1093
- ], PopoverComponent.prototype, "animation", void 0);
1094
- __decorate([
1095
- Input(),
1096
- __metadata("design:type", Function),
1097
- __metadata("design:paramtypes", [Function])
1098
- ], PopoverComponent.prototype, "templateData", null);
1099
- __decorate([
1100
- HostBinding('class.k-hidden'),
1101
- __metadata("design:type", Boolean),
1102
- __metadata("design:paramtypes", [])
1103
- ], PopoverComponent.prototype, "isHidden", null);
1104
- __decorate([
1105
- HostBinding('attr.aria-hidden'),
1106
- __metadata("design:type", Boolean),
1107
- __metadata("design:paramtypes", [])
1108
- ], PopoverComponent.prototype, "hasAttributeHidden", null);
1109
- __decorate([
1110
- Output(),
1111
- __metadata("design:type", EventEmitter)
1112
- ], PopoverComponent.prototype, "show", void 0);
1113
- __decorate([
1114
- Output(),
1115
- __metadata("design:type", EventEmitter)
1116
- ], PopoverComponent.prototype, "shown", void 0);
1117
- __decorate([
1118
- Output(),
1119
- __metadata("design:type", EventEmitter)
1120
- ], PopoverComponent.prototype, "hide", void 0);
1121
- __decorate([
1122
- Output(),
1123
- __metadata("design:type", EventEmitter)
1124
- ], PopoverComponent.prototype, "hidden", void 0);
1125
- __decorate([
1126
- ContentChild(PopoverTitleTemplateDirective, { static: false }),
1127
- __metadata("design:type", PopoverTitleTemplateDirective)
1128
- ], PopoverComponent.prototype, "titleTemplate", void 0);
1129
- __decorate([
1130
- ContentChild(PopoverBodyTemplateDirective, { static: false }),
1131
- __metadata("design:type", PopoverBodyTemplateDirective)
1132
- ], PopoverComponent.prototype, "bodyTemplate", void 0);
1133
- __decorate([
1134
- ContentChild(PopoverActionsTemplateDirective, { static: false }),
1135
- __metadata("design:type", PopoverActionsTemplateDirective)
1136
- ], PopoverComponent.prototype, "actionsTemplate", void 0);
1137
- PopoverComponent = __decorate([
1138
- Component({
1139
- selector: 'kendo-popover',
1140
- providers: [
1141
- LocalizationService,
1142
- {
1143
- provide: L10N_PREFIX,
1144
- useValue: 'kendo.popover'
1145
- }
1146
- ],
1147
- template: "\n <div *ngIf=\"visible\" role=\"tooltip\" class=\"k-popover\" [ngStyle]=\"{'width.px': width, 'height.px': height}\">\n <div class=\"k-popover-callout\" [ngClass]=\"getCalloutPosition()\" *ngIf=\"callout\"></div>\n\n <div *ngIf=\"titleTemplate || title\" class=\"k-popover-header\">\n <ng-template *ngIf=\"titleTemplate\"\n [ngTemplateOutlet]=\"titleTemplate?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: anchor, data: contextData }\">\n </ng-template>\n <ng-container *ngIf=\"title && !titleTemplate\">\n {{ title }}\n </ng-container>\n </div>\n\n <div *ngIf=\"bodyTemplate || body\" class=\"k-popover-body\">\n <ng-template *ngIf=\"bodyTemplate\"\n [ngTemplateOutlet]=\"bodyTemplate?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: anchor, data: contextData }\">\n </ng-template>\n <ng-container *ngIf=\"body && !bodyTemplate\">\n {{ body }}\n </ng-container>\n </div>\n\n <div *ngIf=\"actionsTemplate\" class=\"k-popover-actions k-actions k-hstack k-justify-content-between\">\n <ng-template *ngIf=\"actionsTemplate\"\n [ngTemplateOutlet]=\"actionsTemplate?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: anchor, data: contextData }\">\n </ng-template>\n </div>\n </div>\n "
1148
- }),
1149
- __metadata("design:paramtypes", [LocalizationService])
1150
- ], PopoverComponent);
1151
- return PopoverComponent;
1152
- }());
1153
-
1154
- /**
1155
- * Arguments for the `show` event. The `show` event fires when a popover is about
1156
- * to be opened. If you cancel the event, the opening is prevented.
1157
- */
1158
- var PopoverShowEvent = /** @class */ (function (_super) {
1159
- __extends(PopoverShowEvent, _super);
1160
- /**
1161
- * @hidden
1162
- * Constructs the event arguments for the `show` event.
1163
- * @param anchor - The host element related to the popover.
1164
- */
1165
- function PopoverShowEvent(anchor) {
1166
- var _this = _super.call(this) || this;
1167
- _this.anchor = anchor;
1168
- return _this;
1169
- }
1170
- return PopoverShowEvent;
1171
- }(PreventableEvent));
1172
- /**
1173
- * Arguments for the `hide` event. The `hide` event fires when a popover is about
1174
- * to be closed. If you cancel the event, the popover stays open.
1175
- */
1176
- var PopoverHideEvent = /** @class */ (function (_super) {
1177
- __extends(PopoverHideEvent, _super);
1178
- /**
1179
- * @hidden
1180
- * Constructs the event arguments for the `hide` event.
1181
- * @param anchor - The host element related to the popover.
1182
- * @param popover - The popover element.
1183
- */
1184
- function PopoverHideEvent(anchor, popover) {
1185
- var _this = _super.call(this) || this;
1186
- _this.anchor = anchor;
1187
- _this.popover = popover;
1188
- return _this;
1189
- }
1190
- return PopoverHideEvent;
1191
- }(PreventableEvent));
1192
- /**
1193
- * Arguments for the `shown` event. The `shown` event fires after the popover has opened and its opening animation has finished.
1194
- */
1195
- var PopoverShownEvent = /** @class */ (function () {
1196
- /**
1197
- * @hidden
1198
- * Constructs the event arguments for the `shown` event.
1199
- * @param anchor - The host element related to the popover.
1200
- * @param popover - The popover element.
1201
- */
1202
- function PopoverShownEvent(anchor, popover) {
1203
- this.anchor = anchor;
1204
- this.popover = popover;
1205
- }
1206
- return PopoverShownEvent;
1207
- }());
1208
- /**
1209
- * Arguments for the `hidden` event. The `hidden` event fires after the popover has closed and its closing animation has finished.
1210
- */
1211
- var PopoverHiddenEvent = /** @class */ (function () {
1212
- /**
1213
- * @hidden
1214
- * Constructs the event arguments for the `hidden` event.
1215
- * @param anchor - The host element related to the popover.
1216
- */
1217
- function PopoverHiddenEvent(anchor) {
1218
- this.anchor = anchor;
1219
- }
1220
- return PopoverHiddenEvent;
1221
- }());
1222
-
1223
- var validShowOptions = ['hover', 'click', 'none', 'focus'];
1224
- /**
1225
- * @hidden
1226
- */
1227
- var PopoverDirectivesBase = /** @class */ (function () {
1228
- function PopoverDirectivesBase(ngZone, popupService, renderer) {
1229
- this.ngZone = ngZone;
1230
- this.popupService = popupService;
1231
- this.renderer = renderer;
1232
- this.subs = new Subscription();
1233
- this._showOn = 'click';
1234
- }
1235
- Object.defineProperty(PopoverDirectivesBase.prototype, "popover", {
1236
- get: function () {
1237
- return this._popover;
1238
- },
1239
- /**
1240
- * Specifies the popover instance that will be rendered.
1241
- * Accepts a [`PopoverComponent`]({% slug api_tooltip_popovercomponent %}) instance or
1242
- * a [`PopoverFn`]({% slug api_tooltip_popoverfn %}) callback which returns a [`PopoverComponent`]({% slug api_tooltip_popovercomponent %}) instance
1243
- * depending on the current anchor element.
1244
- *
1245
- * [See example]({% slug templates_popover %}#toc-popovercallback)
1246
- */
1247
- set: function (value) {
1248
- if (value instanceof PopoverComponent || typeof value === "function") {
1249
- this._popover = value;
1250
- }
1251
- else {
1252
- if (isDevMode) {
1253
- throw new Error(ERRORS.popover);
1254
- }
1255
- }
1256
- },
1257
- enumerable: true,
1258
- configurable: true
1259
- });
1260
- Object.defineProperty(PopoverDirectivesBase.prototype, "showOn", {
1261
- get: function () {
1262
- return this._showOn;
1263
- },
1264
- /**
1265
- * The event on which the Popover will be shown
1266
- *
1267
- * The supported values are:
1268
- * - `click` (default) &mdash;The Popover will be shown when its `anchor` element is clicked.
1269
- * - `hover`&mdash;The Popover will be shown when its `anchor` element is hovered.
1270
- * - `focus`&mdash;The Popover will be shown when its `anchor` element is focused.
1271
- * - `none`&mdash;The Popover will not be shown on user interaction. It could be rendered via the Popover API methods.
1272
- */
1273
- set: function (value) {
1274
- if (isDevMode && !containsItem(validShowOptions, value)) {
1275
- throw new Error(ERRORS.showOn);
1276
- }
1277
- this._showOn = value;
1278
- },
1279
- enumerable: true,
1280
- configurable: true
1281
- });
1282
- PopoverDirectivesBase.prototype.ngAfterViewInit = function () {
1283
- var _this = this;
1284
- if (!isDocumentAvailable()) {
1285
- return;
1286
- }
1287
- this.ngZone.runOutsideAngular(function () {
1288
- switch (_this.showOn) {
1289
- case 'hover':
1290
- _this.subscribeToEvents([{
1291
- name: 'mouseenter', handler: _this.mouseenterHandler
1292
- }, {
1293
- name: 'mouseleave', handler: _this.mouseleaveHandler
1294
- }]);
1295
- break;
1296
- case 'focus':
1297
- _this.subscribeToEvents([{
1298
- name: 'focus', handler: _this.focusHandler
1299
- }, {
1300
- name: 'blur', handler: _this.blurHandler
1301
- }]);
1302
- break;
1303
- case 'click':
1304
- _this.subscribeClick();
1305
- break;
1306
- default:
1307
- break;
1308
- }
1309
- });
1310
- };
1311
- PopoverDirectivesBase.prototype.ngOnDestroy = function () {
1312
- this.closePopup();
1313
- if (this.disposeHoverOverListener) {
1314
- this.disposeHoverOverListener();
1315
- }
1316
- if (this.disposeHoverOutListener) {
1317
- this.disposeHoverOutListener();
1318
- }
1319
- if (this.disposeClickListener) {
1320
- this.disposeClickListener();
1321
- }
1322
- if (this._focusInsideSub) {
1323
- this._focusInsideSub.unsubscribe();
1324
- }
1325
- if (this._hideSub) {
1326
- this._hideSub.unsubscribe();
1327
- }
1328
- if (this.subs) {
1329
- this.subs.unsubscribe();
1330
- }
1331
- if (this._popupOpenSub) {
1332
- this._popupOpenSub.unsubscribe();
1333
- }
1334
- if (this._popupCloseSub) {
1335
- this._popupCloseSub.unsubscribe();
1336
- }
1337
- };
1338
- /**
1339
- * Hides the Popover ([See example]({% slug programmaticcontrol_popover %})).
1340
- */
1341
- PopoverDirectivesBase.prototype.hide = function () {
1342
- this.closePopup();
1343
- };
1344
- /**
1345
- * @hidden
1346
- */
1347
- PopoverDirectivesBase.prototype.closePopup = function () {
1348
- if (this.popupRef) {
1349
- this.popupRef.close();
1350
- this.popupRef = null;
1351
- if (this.disposePopupHoverOutListener) {
1352
- this.disposePopupHoverOutListener();
1353
- }
1354
- if (this.disposePopupHoverInListener) {
1355
- this.disposePopupHoverInListener();
1356
- }
1357
- if (this.disposePopupFocusOutListener) {
1358
- this.disposePopupFocusOutListener();
1359
- }
1360
- }
1361
- };
1362
- /**
1363
- * @hidden
1364
- */
1365
- PopoverDirectivesBase.prototype.openPopup = function (anchor) {
1366
- var _anchor = anchor instanceof ElementRef ? anchor.nativeElement : anchor;
1367
- var popoverComp = this.popover instanceof PopoverComponent ? this.popover : this.popover(_anchor);
1368
- var alignSettings = align(popoverComp.position, popoverComp.offset);
1369
- var anchorAlign = alignSettings.anchorAlign;
1370
- var popupAlign = alignSettings.popupAlign;
1371
- var popupMargin = alignSettings.popupMargin;
1372
- var _animation = popoverComp.animation;
1373
- this.popupRef = this.popupService.open({
1374
- anchor: { nativeElement: _anchor },
1375
- animate: _animation,
1376
- content: PopoverComponent,
1377
- popupAlign: popupAlign,
1378
- anchorAlign: anchorAlign,
1379
- margin: popupMargin,
1380
- popupClass: 'k-popup-transparent',
1381
- collision: { horizontal: 'fit', vertical: 'fit' }
1382
- });
1383
- this.applySettings(this.popupRef.content, popoverComp, anchor);
1384
- this.monitorPopup();
1385
- this.initializeCompletionEvents(popoverComp, _anchor);
1386
- };
1387
- /**
1388
- * @hidden
1389
- */
1390
- PopoverDirectivesBase.prototype.isPrevented = function (anchorElement, show) {
1391
- var popoverComp = this.popover instanceof PopoverComponent ? this.popover : this.popover(anchorElement);
1392
- var eventArgs;
1393
- eventArgs = this.initializeEvents(popoverComp, eventArgs, show, anchorElement);
1394
- return eventArgs.isDefaultPrevented();
1395
- };
1396
- /**
1397
- * @hidden
1398
- */
1399
- PopoverDirectivesBase.prototype.monitorPopup = function () {
1400
- var _this = this;
1401
- if (this.showOn === 'hover') {
1402
- this.ngZone.runOutsideAngular(function () {
1403
- var popup = _this.popupRef.popupElement;
1404
- _this.disposePopupHoverInListener = _this.renderer.listen(popup, 'mouseenter', function (_) {
1405
- _this.ngZone.run(function (_) { return _this._popoverService.emitPopoverState(true); });
1406
- });
1407
- _this.disposePopupHoverOutListener = _this.renderer.listen(popup, 'mouseleave', function (_) {
1408
- _this.ngZone.run(function (_) { return _this._popoverService.emitPopoverState(false); });
1409
- });
1410
- });
1411
- }
1412
- if (this.showOn === 'focus') {
1413
- this.ngZone.runOutsideAngular(function () {
1414
- var popup = _this.popupRef.popupElement;
1415
- _this.disposePopupFocusOutListener = _this.renderer.listen(popup, 'focusout', function (e) {
1416
- var isInsidePopover = closest(e.relatedTarget, function (node) { return node.classList && node.classList.contains('k-popover'); });
1417
- if (!isInsidePopover) {
1418
- _this.ngZone.run(function (_) { return _this._popoverService.emitFocusInsidePopover(false); });
1419
- }
1420
- });
1421
- });
1422
- }
1423
- };
1424
- PopoverDirectivesBase.prototype.applySettings = function (contentComponent, popover, anchor) {
1425
- var content = contentComponent.instance;
1426
- var _anchor = anchor instanceof ElementRef ? anchor.nativeElement : anchor;
1427
- content.visible = true;
1428
- content.anchor = _anchor;
1429
- content.position = popover.position;
1430
- content.offset = popover.offset;
1431
- content.width = popover.width;
1432
- content.height = popover.height;
1433
- content.title = popover.title;
1434
- content.body = popover.body;
1435
- content.callout = popover.callout;
1436
- content.animation = popover.animation;
1437
- content.contextData = popover.templateData(_anchor);
1438
- content.titleTemplate = popover.titleTemplate;
1439
- content.bodyTemplate = popover.bodyTemplate;
1440
- content.actionsTemplate = popover.actionsTemplate;
1441
- this.popupRef.content.changeDetectorRef.detectChanges();
1442
- };
1443
- /**
1444
- * @hidden
1445
- */
1446
- PopoverDirectivesBase.prototype.initializeEvents = function (popoverComp, eventArgs, show, anchorElement) {
1447
- if (show) {
1448
- eventArgs = new PopoverShowEvent(anchorElement);
1449
- if (this.shouldEmitEvent(!!this.popupRef, 'show', popoverComp)) {
1450
- this.ngZone.run(function () { return popoverComp.show.emit(eventArgs); });
1451
- }
1452
- }
1453
- else {
1454
- eventArgs = new PopoverHideEvent(anchorElement, this.popupRef);
1455
- if (this.shouldEmitEvent(!!this.popupRef, 'hide', popoverComp)) {
1456
- this.ngZone.run(function () { return popoverComp.hide.emit(eventArgs); });
1457
- }
1458
- }
1459
- return eventArgs;
1460
- };
1461
- PopoverDirectivesBase.prototype.initializeCompletionEvents = function (popoverComp, _anchor) {
1462
- var _this = this;
1463
- if (this.shouldEmitCompletionEvents('shown', popoverComp)) {
1464
- this.popupRef.popupOpen.subscribe(function () {
1465
- var eventArgs = new PopoverShownEvent(_anchor, _this.popupRef);
1466
- popoverComp.shown.emit(eventArgs);
1467
- });
1468
- }
1469
- if (this.shouldEmitCompletionEvents('hidden', popoverComp)) {
1470
- this.popupRef.popupClose.subscribe(function () {
1471
- _this.ngZone.run(function (_) {
1472
- var eventArgs = new PopoverHiddenEvent(_anchor);
1473
- popoverComp.hidden.emit(eventArgs);
1474
- });
1475
- });
1476
- }
1477
- };
1478
- PopoverDirectivesBase.prototype.shouldEmitEvent = function (hasPopup, event, popoverComp) {
1479
- if ((event === 'show' && !hasPopup && hasObservers(popoverComp[event]))
1480
- || (event === 'hide' && hasPopup && hasObservers(popoverComp[event]))) {
1481
- return true;
1482
- }
1483
- return false;
1484
- };
1485
- PopoverDirectivesBase.prototype.shouldEmitCompletionEvents = function (event, popoverComp) {
1486
- if ((hasObservers(popoverComp[event]) && !this._popupOpenSub)
1487
- || (hasObservers(popoverComp[event]) && !this._popupCloseSub)) {
1488
- return true;
1489
- }
1490
- return false;
1491
- };
1492
- __decorate([
1493
- Input(),
1494
- __metadata("design:type", Object),
1495
- __metadata("design:paramtypes", [Object])
1496
- ], PopoverDirectivesBase.prototype, "popover", null);
1497
- __decorate([
1498
- Input(),
1499
- __metadata("design:type", String),
1500
- __metadata("design:paramtypes", [String])
1501
- ], PopoverDirectivesBase.prototype, "showOn", null);
1502
- return PopoverDirectivesBase;
1503
- }());
1504
-
1505
- /**
1506
- * @hidden
1507
- */
1508
- var PopoverService = /** @class */ (function () {
1509
- function PopoverService(ngZone) {
1510
- this.ngZone = ngZone;
1511
- this._pointerOverPopup = new BehaviorSubject(null);
1512
- this._pointerOverAnchor = new BehaviorSubject(null);
1513
- this._focusInsidePopover = new BehaviorSubject(null);
1514
- this._hidePopover = new Subject();
1515
- this.subs = new Subscription();
1516
- this.monitor();
1517
- }
1518
- PopoverService.prototype.ngOnDestroy = function () {
1519
- this.subs.unsubscribe();
1520
- };
1521
- Object.defineProperty(PopoverService.prototype, "isPopoverHovered", {
1522
- get: function () {
1523
- return this._pointerOverPopup.asObservable();
1524
- },
1525
- enumerable: true,
1526
- configurable: true
1527
- });
1528
- PopoverService.prototype.emitPopoverState = function (isHovered) {
1529
- var _this = this;
1530
- this.ngZone.run(function (_) { return _this._pointerOverPopup.next(isHovered); });
1531
- };
1532
- Object.defineProperty(PopoverService.prototype, "isAnchorHovered", {
1533
- get: function () {
1534
- return this._pointerOverAnchor.asObservable();
1535
- },
1536
- enumerable: true,
1537
- configurable: true
1538
- });
1539
- PopoverService.prototype.emitAnchorState = function (isHovered, anchor) {
1540
- var _this = this;
1541
- this._isOrigin = this.originAnchor === anchor;
1542
- this.currentAnchor = anchor;
1543
- if (isHovered) {
1544
- this.originAnchor = anchor;
1545
- }
1546
- this.ngZone.run(function (_) { return _this._pointerOverAnchor.next(isHovered); });
1547
- };
1548
- Object.defineProperty(PopoverService.prototype, "isFocusInsidePopover", {
1549
- get: function () {
1550
- return this._focusInsidePopover.asObservable();
1551
- },
1552
- enumerable: true,
1553
- configurable: true
1554
- });
1555
- PopoverService.prototype.emitFocusInsidePopover = function (isFocused) {
1556
- var _this = this;
1557
- this.ngZone.run(function (_) { return _this._focusInsidePopover.next(isFocused); });
1558
- this._focusInsidePopover.next(null);
1559
- };
1560
- Object.defineProperty(PopoverService.prototype, "hidePopover", {
1561
- get: function () {
1562
- return this._hidePopover.asObservable();
1563
- },
1564
- enumerable: true,
1565
- configurable: true
1566
- });
1567
- PopoverService.prototype.monitor = function () {
1568
- var _this = this;
1569
- this.subs.add(combineLatest(this.isPopoverHovered, this.isAnchorHovered).pipe(
1570
- // `auditTime` is used because the `mouseleave` event is emitted before `mouseenter`
1571
- // i.e. there is a millisecond in which the pointer leaves the first target (e.g. anchor) and hasn't reached the second one (e.g. popup)
1572
- // resulting in both observables emitting `false`
1573
- auditTime(20)).subscribe(function (val) {
1574
- var isPopoverHovered = val[0], isAnchorHovered = val[1];
1575
- _this._hidePopover.next([isPopoverHovered, isAnchorHovered, _this._isOrigin, _this.currentAnchor]);
1576
- }));
1577
- };
1578
- PopoverService = __decorate([
1579
- Injectable(),
1580
- __metadata("design:paramtypes", [NgZone])
1581
- ], PopoverService);
1582
- return PopoverService;
1583
- }());
1584
-
1585
- /**
1586
- * Represents the [`kendoPopoverContainer`]({% slug configuration_popover %}#toc-containerdirective) directive.
1587
- * It is used to filter and target multiple elements, which should display a popover on interaction.
1588
- *
1589
- * @example
1590
- * ```ts-no-run
1591
- * <div kendoPopoverContainer [popover]="myPopover" filter=".has-popover">
1592
- * <button class="has-popover">Show Popover</button>
1593
- * <button>Button Without Popover</button>
1594
- * <button class="has-popover">Show Popover</button>
1595
- * </div>
1596
- * ```
1597
- */
1598
- var PopoverContainerDirective = /** @class */ (function (_super) {
1599
- __extends(PopoverContainerDirective, _super);
1600
- function PopoverContainerDirective(wrapperEl, ngZone, popupService, renderer, popoverService) {
1601
- var _this = _super.call(this, ngZone, popupService, renderer) || this;
1602
- _this.wrapperEl = wrapperEl;
1603
- _this.ngZone = ngZone;
1604
- _this.popupService = popupService;
1605
- _this.renderer = renderer;
1606
- _this.popoverService = popoverService;
1607
- _this.mouseenterHandler = function (anchor) {
1608
- _this.controlVisibility(anchor, true);
1609
- };
1610
- _this.mouseleaveHandler = function (args) {
1611
- var anchor = args.anchor;
1612
- if (_this.isPrevented(anchor, false)) {
1613
- return;
1614
- }
1615
- if (!_this._hideSub) {
1616
- _this._hideSub = _this.popoverService.hidePopover.subscribe(function (val) {
1617
- var isPopoverHovered = val[0], isOriginAnchor = val[2], currentAnchor = val[3];
1618
- if (!isPopoverHovered && !isOriginAnchor) {
1619
- _this.hide();
1620
- if (!isOriginAnchor && currentAnchor) {
1621
- _this.show(currentAnchor);
1622
- }
1623
- }
1624
- });
1625
- }
1626
- };
1627
- _this.focusHandler = function (anchor) {
1628
- _this.controlVisibility(anchor, true);
1629
- };
1630
- _this.blurHandler = function (args) {
1631
- var anchor = args.anchor;
1632
- var event = args.domEvent;
1633
- if (_this.isPrevented(anchor, false)) {
1634
- return;
1635
- }
1636
- // from anchor to popup focus check
1637
- var isFocusInside = !!closest(event.relatedTarget, function (node) { return node.classList && node.classList.contains('k-popover'); });
1638
- if (!isFocusInside) {
1639
- _this.hide();
1640
- }
1641
- if (!_this._focusInsideSub) {
1642
- // inside popup focus check
1643
- _this._focusInsideSub = _this.popoverService.isFocusInsidePopover.pipe(filter(function (v) { return v !== null; })).subscribe(function (val) {
1644
- if (!val && !isFocusInside) {
1645
- _this.hide();
1646
- }
1647
- });
1648
- }
1649
- };
1650
- _this._popoverService = _this.popoverService;
1651
- return _this;
1652
- }
1653
- /**
1654
- * Shows the Popover.
1655
- *
1656
- * @param anchor&mdash;Specifies the element that will be used as an anchor. The Popover opens relative to that element. [See example]({% slug programmaticcontrol_popover %})
1657
- */
1658
- PopoverContainerDirective.prototype.show = function (anchor) {
1659
- var _this = this;
1660
- if (this.popupRef) {
1661
- return;
1662
- }
1663
- this.ngZone.run(function () {
1664
- _this.openPopup(anchor);
1665
- });
1666
- this.popupRef.popupAnchorViewportLeave
1667
- .pipe(take(1))
1668
- .subscribe(function () { return _this.hide(); });
1669
- };
1670
- /**
1671
- * Toggles the visibility of the Popover. [See example]({% slug programmaticcontrol_popover %})
1672
- *
1673
- * @param anchor&mdash;Specifies the element that will be used as an anchor. The Popover opens relative to that element.
1674
- */
1675
- PopoverContainerDirective.prototype.toggle = function (anchor) {
1676
- var previousAnchor = this.popupRef && this.popupRef.content.instance.anchor;
1677
- if (this.popupRef) {
1678
- this.hide();
1679
- if (previousAnchor !== anchor) {
1680
- this.show(anchor);
1681
- }
1682
- }
1683
- else {
1684
- this.show(anchor);
1685
- }
1686
- };
1687
- PopoverContainerDirective.prototype.subscribeClick = function () {
1688
- var _this = this;
1689
- if (this.disposeClickListener) {
1690
- this.disposeClickListener();
1691
- }
1692
- this.disposeClickListener = this.renderer.listen(document, 'click', function (e) {
1693
- var filterElement = closestBySelector(e.target, _this.filter);
1694
- _this.clickHandler(filterElement, e);
1695
- });
1696
- };
1697
- PopoverContainerDirective.prototype.subscribeToEvents = function (arr) {
1698
- var _this = this;
1699
- var filteredElements = Array.from(document.querySelectorAll(this.filter));
1700
- filteredElements.forEach(function (el) {
1701
- _this.subs.add(_this.renderer.listen(el, arr[0].name, function () {
1702
- _this.popoverService.emitAnchorState(true, el);
1703
- arr[0].handler(el);
1704
- }));
1705
- _this.subs.add(_this.renderer.listen(el, arr[1].name, function (e) {
1706
- _this.popoverService.emitAnchorState(false, null);
1707
- arr[1].handler({ anchor: el, domEvent: e });
1708
- }));
1709
- });
1710
- };
1711
- PopoverContainerDirective.prototype.clickHandler = function (anchor, event) {
1712
- var isInsidePopup = !!closest(event.target, function (node) { return node.classList && node.classList.contains('k-popup'); });
1713
- var popupRefAnchor = this.popupRef && this.popupRef.content.instance.anchor;
1714
- var isOriginAnchor = !!closest(event.target, function (node) { return node === (popupRefAnchor ? popupRefAnchor : anchor); });
1715
- if (this.showOn !== 'click' || isInsidePopup || (this.popupRef && isOriginAnchor)) {
1716
- return;
1717
- }
1718
- if (!anchor && this.popupRef) {
1719
- this.controlVisibility(anchor, false);
1720
- return;
1721
- }
1722
- if (isOriginAnchor) {
1723
- this.controlVisibility(anchor, true);
1724
- }
1725
- else if (this.popupRef) {
1726
- this.controlVisibility(anchor, false);
1727
- this.controlVisibility(anchor, true);
1728
- }
1729
- };
1730
- PopoverContainerDirective.prototype.controlVisibility = function (anchor, show) {
1731
- if (this.isPrevented(anchor, show)) {
1732
- return;
1733
- }
1734
- show ? this.show(anchor) : this.hide();
1735
- };
1736
- __decorate([
1737
- Input(),
1738
- __metadata("design:type", String)
1739
- ], PopoverContainerDirective.prototype, "filter", void 0);
1740
- PopoverContainerDirective = __decorate([
1741
- Directive({
1742
- selector: '[kendoPopoverContainer]',
1743
- exportAs: 'kendoPopoverContainer',
1744
- providers: [PopoverService]
1745
- }),
1746
- __metadata("design:paramtypes", [ElementRef,
1747
- NgZone,
1748
- PopupService,
1749
- Renderer2,
1750
- PopoverService])
1751
- ], PopoverContainerDirective);
1752
- return PopoverContainerDirective;
1753
- }(PopoverDirectivesBase));
1754
-
1755
- /**
1756
- * Represents the [`kendoPopoverAnchor`]({% slug configuration_popover %}#toc-anchordirective) directive.
1757
- * It is used to target an element, which should display a popover on interaction.
1758
- *
1759
- * @example
1760
- * ```ts-no-run
1761
- * <button kendoPopoverAnchor [popover]="myPopover">Show Popover</button>
1762
- * ```
1763
- */
1764
- var PopoverAnchorDirective = /** @class */ (function (_super) {
1765
- __extends(PopoverAnchorDirective, _super);
1766
- function PopoverAnchorDirective(hostEl, ngZone, popupService, renderer, popoverService) {
1767
- var _this = _super.call(this, ngZone, popupService, renderer) || this;
1768
- _this.hostEl = hostEl;
1769
- _this.ngZone = ngZone;
1770
- _this.popupService = popupService;
1771
- _this.renderer = renderer;
1772
- _this.popoverService = popoverService;
1773
- _this.mouseenterHandler = function () {
1774
- _this.controlVisibility(_this.hostEl.nativeElement, true);
1775
- };
1776
- _this.mouseleaveHandler = function () {
1777
- if (_this.isPrevented(_this.hostEl.nativeElement, false)) {
1778
- return;
1779
- }
1780
- if (!_this._hideSub) {
1781
- _this._hideSub = _this.popoverService.hidePopover.subscribe(function (val) {
1782
- var isPopoverHovered = val[0], isAnchorHovered = val[1];
1783
- if (!isPopoverHovered && !isAnchorHovered) {
1784
- _this.hide();
1785
- }
1786
- });
1787
- }
1788
- };
1789
- _this.focusHandler = function () {
1790
- _this.controlVisibility(_this.hostEl.nativeElement, true);
1791
- };
1792
- _this.blurHandler = function (args) {
1793
- var event = args.domEvent;
1794
- if (_this.isPrevented(_this.hostEl.nativeElement, false)) {
1795
- return;
1796
- }
1797
- // from anchor to popup focus check
1798
- var isFocusInside = !!closest(event.relatedTarget, function (node) { return node.classList && node.classList.contains('k-popover'); });
1799
- if (!isFocusInside) {
1800
- _this.hide();
1801
- }
1802
- if (!_this._focusInsideSub) {
1803
- // inside popup focus check
1804
- _this._focusInsideSub = _this.popoverService.isFocusInsidePopover.pipe(filter(function (v) { return v !== null; })).subscribe(function (val) {
1805
- if (!val) {
1806
- _this.hide();
1807
- }
1808
- });
1809
- }
1810
- };
1811
- _this._popoverService = _this.popoverService;
1812
- return _this;
1813
- }
1814
- /**
1815
- * Shows the Popover. [See example]({% slug programmaticcontrol_popover %})
1816
- */
1817
- PopoverAnchorDirective.prototype.show = function () {
1818
- var _this = this;
1819
- if (this.popupRef) {
1820
- return;
1821
- }
1822
- this.ngZone.run(function () {
1823
- _this.openPopup(_this.hostEl);
1824
- });
1825
- this.popupRef.popupAnchorViewportLeave
1826
- .pipe(take(1))
1827
- .subscribe(function () { return _this.hide(); });
1828
- };
1829
- /**
1830
- * Toggles the visibility of the Popover. [See example]({% slug programmaticcontrol_popover %})
1831
- */
1832
- PopoverAnchorDirective.prototype.toggle = function () {
1833
- if (this.popupRef) {
1834
- this.hide();
1835
- }
1836
- else {
1837
- this.show();
1838
- }
1839
- };
1840
- PopoverAnchorDirective.prototype.subscribeToEvents = function (arr) {
1841
- var _this = this;
1842
- this.subs.add(this.renderer.listen(this.hostEl.nativeElement, arr[0].name, function () {
1843
- _this.popoverService.emitAnchorState(true, _this.hostEl.nativeElement);
1844
- arr[0].handler();
1845
- }));
1846
- this.subs.add(this.renderer.listen(this.hostEl.nativeElement, arr[1].name, function (e) {
1847
- _this.popoverService.emitAnchorState(false, null);
1848
- arr[1].handler({ domEvent: e });
1849
- }));
1850
- };
1851
- PopoverAnchorDirective.prototype.subscribeClick = function () {
1852
- var _this = this;
1853
- if (this.disposeClickListener) {
1854
- this.disposeClickListener();
1855
- }
1856
- this.disposeClickListener = this.renderer.listen(document, 'click', function (e) {
1857
- _this.onClick(e);
1858
- });
1859
- };
1860
- /**
1861
- * @hidden
1862
- */
1863
- PopoverAnchorDirective.prototype.onClick = function (event) {
1864
- var _this = this;
1865
- var isInsidePopup = !!closest(event.target, function (node) { return node.classList && node.classList.contains('k-popup'); });
1866
- var isAnchor = !!closest(event.target, function (node) { return node === _this.hostEl.nativeElement; });
1867
- if (isInsidePopup || (this.popupRef && isAnchor)) {
1868
- return;
1869
- }
1870
- if (isAnchor) {
1871
- // on opening
1872
- this.controlVisibility(this.hostEl.nativeElement, true);
1873
- }
1874
- else {
1875
- // on closing
1876
- this.controlVisibility(this.hostEl.nativeElement, false);
1877
- }
1878
- };
1879
- PopoverAnchorDirective.prototype.controlVisibility = function (anchor, show) {
1880
- if (this.isPrevented(anchor, show)) {
1881
- return;
1882
- }
1883
- show ? this.show() : this.hide();
1884
- };
1885
- PopoverAnchorDirective = __decorate([
1886
- Directive({
1887
- selector: '[kendoPopoverAnchor]',
1888
- exportAs: 'kendoPopoverAnchor',
1889
- providers: [PopoverService]
1890
- }),
1891
- __metadata("design:paramtypes", [ElementRef,
1892
- NgZone,
1893
- PopupService,
1894
- Renderer2,
1895
- PopoverService])
1896
- ], PopoverAnchorDirective);
1897
- return PopoverAnchorDirective;
1898
- }(PopoverDirectivesBase));
1899
-
1900
- /**
1901
- * @hidden
1902
- */
1903
- var LocalizedMessagesDirective = /** @class */ (function (_super) {
1904
- __extends(LocalizedMessagesDirective, _super);
1905
- function LocalizedMessagesDirective(service) {
1906
- var _this = _super.call(this) || this;
1907
- _this.service = service;
1908
- return _this;
1909
- }
1910
- LocalizedMessagesDirective_1 = LocalizedMessagesDirective;
1911
- var LocalizedMessagesDirective_1;
1912
- __decorate([
1913
- Input(),
1914
- __metadata("design:type", String)
1915
- ], LocalizedMessagesDirective.prototype, "closeTitle", void 0);
1916
- LocalizedMessagesDirective = LocalizedMessagesDirective_1 = __decorate([
1917
- Directive({
1918
- providers: [
1919
- {
1920
- provide: ComponentMessages,
1921
- useExisting: forwardRef(function () { return LocalizedMessagesDirective_1; })
1922
- }
1923
- ],
1924
- selector: "[kendoTooltipLocalizedMessages]"
1925
- }),
1926
- __metadata("design:paramtypes", [LocalizationService])
1927
- ], LocalizedMessagesDirective);
1928
- return LocalizedMessagesDirective;
1929
- }(ComponentMessages));
1930
-
1931
- var COMPONENT_DIRECTIVES = [TooltipDirective, TooltipContentComponent, LocalizedMessagesDirective];
1932
- var COMPONENT_MODULES = [PopupModule];
1933
- /**
1934
- * Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }})
1935
- * definition for the Tooltip component.
1936
- *
1937
- * The package exports:
1938
- * - `KendoTooltipDirective`&mdash;The Tooltip directive class.
1939
- *
1940
- * @example
1941
- *
1942
- * ```ts-no-run
1943
- * // Import the Tooltip module
1944
- * import { TooltipModule } from '@progress/kendo-angular-tooltip';
1945
- *
1946
- * // The browser platform with a compiler
1947
- * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1948
- *
1949
- * import { NgModule } from '@angular/core';
1950
- *
1951
- * // Import the app component
1952
- * _@NgModule{{
1953
- * declarations: [AppComponent], // declare app component
1954
- * imports: [BrowserModule, TooltipModule], // import TooltipModule module
1955
- * bootstrap: [AppComponent]
1956
- * }}
1957
- * export class AppModule {}
1958
- *
1959
- * // Compile and launch the module
1960
- * platformBrowserDynamic().bootstrapModule(AppModule);
1961
- * ```
1962
- */
1963
- var TooltipModule = /** @class */ (function () {
1964
- function TooltipModule() {
1965
- }
1966
- TooltipModule = __decorate([
1967
- NgModule({
1968
- declarations: [COMPONENT_DIRECTIVES],
1969
- entryComponents: [TooltipContentComponent],
1970
- imports: [CommonModule].concat(COMPONENT_MODULES),
1971
- exports: [COMPONENT_DIRECTIVES]
1972
- })
1973
- ], TooltipModule);
1974
- return TooltipModule;
1975
- }());
1976
-
1977
- var DIRECTIVES = [
1978
- PopoverActionsTemplateDirective,
1979
- PopoverBodyTemplateDirective,
1980
- PopoverTitleTemplateDirective,
1981
- PopoverAnchorDirective,
1982
- PopoverContainerDirective
1983
- ];
1984
- /**
1985
- * Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }})
1986
- * definition for the Popover component.
1987
- *
1988
- * @example
1989
- *
1990
- * ```ts-no-run
1991
- * import { PopoverModule } from '@progress/kendo-angular-tooltip';
1992
- *
1993
- * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
1994
- * import { NgModule } from '@angular/core';
1995
- *
1996
- * import { AppComponent } from './app.component';
1997
- *
1998
- * _@NgModule({
1999
- * declarations: [AppComponent],
2000
- * imports: [BrowserModule, PopoverModule],
2001
- * bootstrap: [AppComponent]
2002
- * })
2003
- * export class AppModule {}
2004
- *
2005
- * platformBrowserDynamic().bootstrapModule(AppModule);
2006
- *
2007
- * ```
2008
- */
2009
- var PopoverModule = /** @class */ (function () {
2010
- function PopoverModule() {
2011
- }
2012
- PopoverModule = __decorate([
2013
- NgModule({
2014
- declarations: DIRECTIVES.concat([
2015
- PopoverComponent
2016
- ]),
2017
- entryComponents: [PopoverComponent],
2018
- exports: DIRECTIVES.concat([PopoverComponent]),
2019
- imports: [
2020
- CommonModule,
2021
- PopupModule
2022
- ]
2023
- })
2024
- ], PopoverModule);
2025
- return PopoverModule;
2026
- }());
2027
-
2028
- /**
2029
- * Represents the [NgModule]({{ site.data.urls.angular['ngmoduleapi'] }})
2030
- * definition for the Tooltips components.
2031
- *
2032
- * @example
2033
- *
2034
- * ```ts-no-run
2035
- * import { TooltipsModule } from '@progress/kendo-angular-tooltip';
2036
- *
2037
- * // The browser platform with a compiler
2038
- * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2039
- *
2040
- * import { NgModule } from '@angular/core';
2041
- *
2042
- * // Import the app component
2043
- * _@NgModule{{
2044
- * declarations: [AppComponent], // declare app component
2045
- * imports: [BrowserModule, TooltipsModule], // import TooltipsModule module
2046
- * bootstrap: [AppComponent]
2047
- * }}
2048
- * export class AppModule {}
2049
- *
2050
- * // Compile and launch the module
2051
- * platformBrowserDynamic().bootstrapModule(AppModule);
2052
- * ```
2053
- */
2054
- var TooltipsModule = /** @class */ (function () {
2055
- function TooltipsModule() {
2056
- }
2057
- TooltipsModule = __decorate([
2058
- NgModule({
2059
- exports: [TooltipModule, PopoverModule]
2060
- })
2061
- ], TooltipsModule);
2062
- return TooltipsModule;
2063
- }());
2064
-
2065
- // Tooltip
2066
-
2067
- /**
2068
- * Generated bundle index. Do not edit.
2069
- */
2070
-
2071
- export { LocalizedMessagesDirective, PopoverDirectivesBase, PopoverService, TooltipContentComponent, TooltipDirective, TooltipSettings, TOOLTIP_SETTINGS, PopoverComponent, PopoverContainerDirective, PopoverAnchorDirective, PopoverTitleTemplateDirective, PopoverBodyTemplateDirective, PopoverActionsTemplateDirective, PopoverShowEvent, PopoverShownEvent, PopoverHideEvent, PopoverHiddenEvent, TooltipModule, PopoverModule, TooltipsModule };