@progress/kendo-angular-tooltip 4.0.0-next.202110211119 → 4.0.0-next.202203281040
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/NOTICE.txt +119 -79
- package/README.md +1 -1
- package/bundles/kendo-angular-tooltip.umd.js +1 -1
- package/constants.d.ts +12 -0
- package/esm2015/constants.js +12 -0
- package/esm2015/localization/localized-messages.directive.js +3 -3
- package/esm2015/main.js +12 -1
- package/esm2015/models/animation.model.js +5 -0
- package/esm2015/models/events.js +65 -0
- package/esm2015/models/functions.model.js +5 -0
- package/esm2015/models/popover-show-option.type.js +5 -0
- package/esm2015/package-metadata.js +1 -1
- package/esm2015/popover/anchor.directive.js +147 -0
- package/esm2015/popover/container.directive.js +172 -0
- package/esm2015/popover/directives-base.js +282 -0
- package/esm2015/popover/popover.component.js +314 -0
- package/esm2015/popover/popover.service.js +67 -0
- package/esm2015/popover/template-directives/actions-template.directive.js +27 -0
- package/esm2015/popover/template-directives/body-template.directive.js +27 -0
- package/esm2015/popover/template-directives/title-template.directive.js +27 -0
- package/esm2015/popover.module.js +78 -0
- package/esm2015/tooltip/tooltip.content.component.js +3 -3
- package/esm2015/tooltip/tooltip.directive.js +7 -7
- package/esm2015/tooltip/tooltip.settings.js +8 -4
- package/esm2015/tooltip.module.js +4 -4
- package/esm2015/tooltips.module.js +45 -0
- package/esm2015/utils.js +1 -1
- package/fesm2015/kendo-angular-tooltip.js +1199 -28
- package/main.d.ts +16 -2
- package/models/animation.model.d.ts +9 -0
- package/models/events.d.ts +78 -0
- package/models/functions.model.d.ts +17 -0
- package/models/popover-show-option.type.d.ts +8 -0
- package/models/position.type.d.ts +1 -1
- package/package.json +4 -4
- package/popover/anchor.directive.d.ts +47 -0
- package/popover/container.directive.d.ts +59 -0
- package/popover/directives-base.d.ts +95 -0
- package/popover/popover.component.d.ts +179 -0
- package/popover/popover.service.d.ts +33 -0
- package/popover/template-directives/actions-template.directive.d.ts +18 -0
- package/popover/template-directives/body-template.directive.d.ts +18 -0
- package/popover/template-directives/title-template.directive.d.ts +18 -0
- package/popover.module.d.ts +43 -0
- package/schematics/ngAdd/index.js +1 -2
- package/schematics/ngAdd/index.js.map +1 -1
- package/tooltip/tooltip.settings.d.ts +4 -0
- package/tooltips.module.d.ts +38 -0
- package/utils.d.ts +1 -1
|
@@ -0,0 +1,282 @@
|
|
|
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 { Directive, ElementRef, Input, isDevMode } from "@angular/core";
|
|
6
|
+
import { closest, hasObservers, isDocumentAvailable } from "@progress/kendo-angular-common";
|
|
7
|
+
import { ERRORS } from '../constants';
|
|
8
|
+
import { PopoverHideEvent, PopoverShowEvent, PopoverShownEvent, PopoverHiddenEvent } from "../models/events";
|
|
9
|
+
import { align, containsItem } from "../utils";
|
|
10
|
+
import { PopoverComponent } from "./popover.component";
|
|
11
|
+
import { Subscription } from "rxjs";
|
|
12
|
+
import * as i0 from "@angular/core";
|
|
13
|
+
import * as i1 from "@progress/kendo-angular-popup";
|
|
14
|
+
const validShowOptions = ['hover', 'click', 'none', 'focus'];
|
|
15
|
+
/**
|
|
16
|
+
* @hidden
|
|
17
|
+
*/
|
|
18
|
+
export class PopoverDirectivesBase {
|
|
19
|
+
constructor(ngZone, popupService, renderer) {
|
|
20
|
+
this.ngZone = ngZone;
|
|
21
|
+
this.popupService = popupService;
|
|
22
|
+
this.renderer = renderer;
|
|
23
|
+
this.subs = new Subscription();
|
|
24
|
+
this._showOn = 'click';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Specifies the popover instance that will be rendered.
|
|
28
|
+
* Accepts a [`PopoverComponent`]({% slug api_tooltip_popovercomponent %}) instance or
|
|
29
|
+
* a [`PopoverFn`]({% slug api_tooltip_popoverfn %}) callback which returns a [`PopoverComponent`]({% slug api_tooltip_popovercomponent %}) instance
|
|
30
|
+
* depending on the current anchor element.
|
|
31
|
+
*
|
|
32
|
+
* [See example]({% slug templates_popover %}#toc-popovercallback)
|
|
33
|
+
*/
|
|
34
|
+
set popover(value) {
|
|
35
|
+
if (value instanceof PopoverComponent || typeof value === `function`) {
|
|
36
|
+
this._popover = value;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (isDevMode) {
|
|
40
|
+
throw new Error(ERRORS.popover);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
get popover() {
|
|
45
|
+
return this._popover;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The event on which the Popover will be shown
|
|
49
|
+
*
|
|
50
|
+
* The supported values are:
|
|
51
|
+
* - `click` (default) —The Popover will be shown when its `anchor` element is clicked.
|
|
52
|
+
* - `hover`—The Popover will be shown when its `anchor` element is hovered.
|
|
53
|
+
* - `focus`—The Popover will be shown when its `anchor` element is focused.
|
|
54
|
+
* - `none`—The Popover will not be shown on user interaction. It could be rendered via the Popover API methods.
|
|
55
|
+
*/
|
|
56
|
+
set showOn(value) {
|
|
57
|
+
if (isDevMode && !containsItem(validShowOptions, value)) {
|
|
58
|
+
throw new Error(ERRORS.showOn);
|
|
59
|
+
}
|
|
60
|
+
this._showOn = value;
|
|
61
|
+
}
|
|
62
|
+
get showOn() {
|
|
63
|
+
return this._showOn;
|
|
64
|
+
}
|
|
65
|
+
ngAfterViewInit() {
|
|
66
|
+
if (!isDocumentAvailable()) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.ngZone.runOutsideAngular(() => {
|
|
70
|
+
switch (this.showOn) {
|
|
71
|
+
case 'hover':
|
|
72
|
+
this.subscribeToEvents([{
|
|
73
|
+
name: 'mouseenter', handler: this.mouseenterHandler
|
|
74
|
+
}, {
|
|
75
|
+
name: 'mouseleave', handler: this.mouseleaveHandler
|
|
76
|
+
}]);
|
|
77
|
+
break;
|
|
78
|
+
case 'focus':
|
|
79
|
+
this.subscribeToEvents([{
|
|
80
|
+
name: 'focus', handler: this.focusHandler
|
|
81
|
+
}, {
|
|
82
|
+
name: 'blur', handler: this.blurHandler
|
|
83
|
+
}]);
|
|
84
|
+
break;
|
|
85
|
+
case 'click':
|
|
86
|
+
this.subscribeClick();
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
ngOnDestroy() {
|
|
94
|
+
this.closePopup();
|
|
95
|
+
if (this.disposeHoverOverListener) {
|
|
96
|
+
this.disposeHoverOverListener();
|
|
97
|
+
}
|
|
98
|
+
if (this.disposeHoverOutListener) {
|
|
99
|
+
this.disposeHoverOutListener();
|
|
100
|
+
}
|
|
101
|
+
if (this.disposeClickListener) {
|
|
102
|
+
this.disposeClickListener();
|
|
103
|
+
}
|
|
104
|
+
if (this._focusInsideSub) {
|
|
105
|
+
this._focusInsideSub.unsubscribe();
|
|
106
|
+
}
|
|
107
|
+
if (this._hideSub) {
|
|
108
|
+
this._hideSub.unsubscribe();
|
|
109
|
+
}
|
|
110
|
+
if (this.subs) {
|
|
111
|
+
this.subs.unsubscribe();
|
|
112
|
+
}
|
|
113
|
+
if (this._popupOpenSub) {
|
|
114
|
+
this._popupOpenSub.unsubscribe();
|
|
115
|
+
}
|
|
116
|
+
if (this._popupCloseSub) {
|
|
117
|
+
this._popupCloseSub.unsubscribe();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Hides the Popover ([See example]({% slug programmaticcontrol_popover %})).
|
|
122
|
+
*/
|
|
123
|
+
hide() {
|
|
124
|
+
this.closePopup();
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @hidden
|
|
128
|
+
*/
|
|
129
|
+
closePopup() {
|
|
130
|
+
if (this.popupRef) {
|
|
131
|
+
this.popupRef.close();
|
|
132
|
+
this.popupRef = null;
|
|
133
|
+
if (this.disposePopupHoverOutListener) {
|
|
134
|
+
this.disposePopupHoverOutListener();
|
|
135
|
+
}
|
|
136
|
+
if (this.disposePopupHoverInListener) {
|
|
137
|
+
this.disposePopupHoverInListener();
|
|
138
|
+
}
|
|
139
|
+
if (this.disposePopupFocusOutListener) {
|
|
140
|
+
this.disposePopupFocusOutListener();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @hidden
|
|
146
|
+
*/
|
|
147
|
+
openPopup(anchor) {
|
|
148
|
+
const _anchor = anchor instanceof ElementRef ? anchor.nativeElement : anchor;
|
|
149
|
+
const popoverComp = this.popover instanceof PopoverComponent ? this.popover : this.popover(_anchor);
|
|
150
|
+
const alignSettings = align(popoverComp.position, popoverComp.offset);
|
|
151
|
+
const anchorAlign = alignSettings.anchorAlign;
|
|
152
|
+
const popupAlign = alignSettings.popupAlign;
|
|
153
|
+
const popupMargin = alignSettings.popupMargin;
|
|
154
|
+
const _animation = popoverComp.animation;
|
|
155
|
+
this.popupRef = this.popupService.open({
|
|
156
|
+
anchor: { nativeElement: _anchor },
|
|
157
|
+
animate: _animation,
|
|
158
|
+
content: PopoverComponent,
|
|
159
|
+
popupAlign,
|
|
160
|
+
anchorAlign,
|
|
161
|
+
margin: popupMargin,
|
|
162
|
+
popupClass: 'k-popup-transparent',
|
|
163
|
+
collision: { horizontal: 'fit', vertical: 'fit' }
|
|
164
|
+
});
|
|
165
|
+
this.applySettings(this.popupRef.content, popoverComp, anchor);
|
|
166
|
+
this.monitorPopup();
|
|
167
|
+
this.initializeCompletionEvents(popoverComp, _anchor);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @hidden
|
|
171
|
+
*/
|
|
172
|
+
isPrevented(anchorElement, show) {
|
|
173
|
+
const popoverComp = this.popover instanceof PopoverComponent ? this.popover : this.popover(anchorElement);
|
|
174
|
+
let eventArgs;
|
|
175
|
+
eventArgs = this.initializeEvents(popoverComp, eventArgs, show, anchorElement);
|
|
176
|
+
return eventArgs.isDefaultPrevented();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* @hidden
|
|
180
|
+
*/
|
|
181
|
+
monitorPopup() {
|
|
182
|
+
if (this.showOn === 'hover') {
|
|
183
|
+
this.ngZone.runOutsideAngular(() => {
|
|
184
|
+
const popup = this.popupRef.popupElement;
|
|
185
|
+
this.disposePopupHoverInListener = this.renderer.listen(popup, 'mouseenter', _ => {
|
|
186
|
+
this.ngZone.run(_ => this._popoverService.emitPopoverState(true));
|
|
187
|
+
});
|
|
188
|
+
this.disposePopupHoverOutListener = this.renderer.listen(popup, 'mouseleave', _ => {
|
|
189
|
+
this.ngZone.run(_ => this._popoverService.emitPopoverState(false));
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (this.showOn === 'focus') {
|
|
194
|
+
this.ngZone.runOutsideAngular(() => {
|
|
195
|
+
const popup = this.popupRef.popupElement;
|
|
196
|
+
this.disposePopupFocusOutListener = this.renderer.listen(popup, 'focusout', (e) => {
|
|
197
|
+
const isInsidePopover = closest(e.relatedTarget, (node) => node.classList && node.classList.contains('k-popover'));
|
|
198
|
+
if (!isInsidePopover) {
|
|
199
|
+
this.ngZone.run(_ => this._popoverService.emitFocusInsidePopover(false));
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
applySettings(contentComponent, popover, anchor) {
|
|
206
|
+
const content = contentComponent.instance;
|
|
207
|
+
const _anchor = anchor instanceof ElementRef ? anchor.nativeElement : anchor;
|
|
208
|
+
content.visible = true;
|
|
209
|
+
content.anchor = _anchor;
|
|
210
|
+
content.position = popover.position;
|
|
211
|
+
content.offset = popover.offset;
|
|
212
|
+
content.width = popover.width;
|
|
213
|
+
content.height = popover.height;
|
|
214
|
+
content.title = popover.title;
|
|
215
|
+
content.body = popover.body;
|
|
216
|
+
content.callout = popover.callout;
|
|
217
|
+
content.animation = popover.animation;
|
|
218
|
+
content.contextData = popover.templateData(_anchor);
|
|
219
|
+
content.titleTemplate = popover.titleTemplate;
|
|
220
|
+
content.bodyTemplate = popover.bodyTemplate;
|
|
221
|
+
content.actionsTemplate = popover.actionsTemplate;
|
|
222
|
+
this.popupRef.content.changeDetectorRef.detectChanges();
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @hidden
|
|
226
|
+
*/
|
|
227
|
+
initializeEvents(popoverComp, eventArgs, show, anchorElement) {
|
|
228
|
+
if (show) {
|
|
229
|
+
eventArgs = new PopoverShowEvent(anchorElement);
|
|
230
|
+
if (this.shouldEmitEvent(!!this.popupRef, 'show', popoverComp)) {
|
|
231
|
+
this.ngZone.run(() => popoverComp.show.emit(eventArgs));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
eventArgs = new PopoverHideEvent(anchorElement, this.popupRef);
|
|
236
|
+
if (this.shouldEmitEvent(!!this.popupRef, 'hide', popoverComp)) {
|
|
237
|
+
this.ngZone.run(() => popoverComp.hide.emit(eventArgs));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return eventArgs;
|
|
241
|
+
}
|
|
242
|
+
initializeCompletionEvents(popoverComp, _anchor) {
|
|
243
|
+
if (this.shouldEmitCompletionEvents('shown', popoverComp)) {
|
|
244
|
+
this.popupRef.popupOpen.subscribe(() => {
|
|
245
|
+
const eventArgs = new PopoverShownEvent(_anchor, this.popupRef);
|
|
246
|
+
popoverComp.shown.emit(eventArgs);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (this.shouldEmitCompletionEvents('hidden', popoverComp)) {
|
|
250
|
+
this.popupRef.popupClose.subscribe(() => {
|
|
251
|
+
this.ngZone.run(_ => {
|
|
252
|
+
const eventArgs = new PopoverHiddenEvent(_anchor);
|
|
253
|
+
popoverComp.hidden.emit(eventArgs);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
shouldEmitEvent(hasPopup, event, popoverComp) {
|
|
259
|
+
if ((event === 'show' && !hasPopup && hasObservers(popoverComp[event]))
|
|
260
|
+
|| (event === 'hide' && hasPopup && hasObservers(popoverComp[event]))) {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
shouldEmitCompletionEvents(event, popoverComp) {
|
|
266
|
+
if ((hasObservers(popoverComp[event]) && !this._popupOpenSub)
|
|
267
|
+
|| (hasObservers(popoverComp[event]) && !this._popupCloseSub)) {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
PopoverDirectivesBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PopoverDirectivesBase, deps: [{ token: i0.NgZone }, { token: i1.PopupService }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
274
|
+
PopoverDirectivesBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: PopoverDirectivesBase, inputs: { popover: "popover", showOn: "showOn" }, ngImport: i0 });
|
|
275
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PopoverDirectivesBase, decorators: [{
|
|
276
|
+
type: Directive,
|
|
277
|
+
args: [{}]
|
|
278
|
+
}], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i1.PopupService }, { type: i0.Renderer2 }]; }, propDecorators: { popover: [{
|
|
279
|
+
type: Input
|
|
280
|
+
}], showOn: [{
|
|
281
|
+
type: Input
|
|
282
|
+
}] } });
|
|
@@ -0,0 +1,314 @@
|
|
|
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 { Component, ContentChild, EventEmitter, HostBinding, Input, isDevMode, Output } from '@angular/core';
|
|
6
|
+
import { LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
|
|
7
|
+
import { Subscription } from 'rxjs';
|
|
8
|
+
import { validatePackage } from '@progress/kendo-licensing';
|
|
9
|
+
import { packageMetadata } from '../package-metadata';
|
|
10
|
+
import { ERRORS } from '../constants';
|
|
11
|
+
import { PopoverTitleTemplateDirective } from './template-directives/title-template.directive';
|
|
12
|
+
import { PopoverBodyTemplateDirective } from './template-directives/body-template.directive';
|
|
13
|
+
import { PopoverActionsTemplateDirective } from './template-directives/actions-template.directive';
|
|
14
|
+
import * as i0 from "@angular/core";
|
|
15
|
+
import * as i1 from "@progress/kendo-angular-l10n";
|
|
16
|
+
import * as i2 from "@angular/common";
|
|
17
|
+
/**
|
|
18
|
+
* Represents the [Kendo UI Popover component for Angular]({% slug overview_popover %}).
|
|
19
|
+
* Used to display additional information that is related to a target element.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts-no-run
|
|
23
|
+
* <kendo-popover>
|
|
24
|
+
* <ng-template kendoPopoverTitleTemplate>Foo Title</ng-template>
|
|
25
|
+
* <ng-template kendoPopoverBodyTemplate>Foo Body</ng-template>
|
|
26
|
+
* <ng-template kendoPopoverActionsTemplate>Foo Actions</ng-template>
|
|
27
|
+
* </kendo-popover>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export class PopoverComponent {
|
|
31
|
+
constructor(localization) {
|
|
32
|
+
this.localization = localization;
|
|
33
|
+
/**
|
|
34
|
+
* Specifies the position of the Popover in relation to its anchor element. [See example]({% slug positioning_popover %})
|
|
35
|
+
*
|
|
36
|
+
* The possible options are:
|
|
37
|
+
* `top`
|
|
38
|
+
* `bottom`
|
|
39
|
+
* `right` (Default)
|
|
40
|
+
* `left`
|
|
41
|
+
*/
|
|
42
|
+
this.position = 'right';
|
|
43
|
+
/**
|
|
44
|
+
* Determines whether a callout will be rendered along the Popover. [See example]({% slug callout_popover %})
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
this.callout = true;
|
|
49
|
+
/**
|
|
50
|
+
* Enables and configures the Popover animation. [See example]({% slug animations_popover %})
|
|
51
|
+
*
|
|
52
|
+
* The possible options are:
|
|
53
|
+
*
|
|
54
|
+
* * `boolean`—Enables the default animation
|
|
55
|
+
* * `PopoverAnimation`—A configuration object which allows setting the `direction`, `duration` and `type` of the animation.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
this.animation = false;
|
|
60
|
+
/**
|
|
61
|
+
* @hidden
|
|
62
|
+
* Determines the visibility of the Popover.
|
|
63
|
+
*/
|
|
64
|
+
this.visible = false;
|
|
65
|
+
/**
|
|
66
|
+
* Fires before the Popover is about to be shown ([see example]({% slug events_popover %})).
|
|
67
|
+
* The event is preventable. If canceled, the Popover will not be displayed. [See example]({% slug events_popover %})
|
|
68
|
+
*/
|
|
69
|
+
this.show = new EventEmitter();
|
|
70
|
+
/**
|
|
71
|
+
* Fires after the Popover has been shown and the animation has ended. [See example]({% slug events_popover %})
|
|
72
|
+
*/
|
|
73
|
+
this.shown = new EventEmitter();
|
|
74
|
+
/**
|
|
75
|
+
* Fires when the Popover is about to be hidden ([see example]({% slug events_popover %})).
|
|
76
|
+
* The event is preventable. If canceled, the Popover will remain visible.
|
|
77
|
+
*/
|
|
78
|
+
this.hide = new EventEmitter();
|
|
79
|
+
/**
|
|
80
|
+
* Fires after the Popover has been hidden and the animation has ended. [See example]({% slug events_popover %})
|
|
81
|
+
*/
|
|
82
|
+
this.hidden = new EventEmitter();
|
|
83
|
+
/**
|
|
84
|
+
* @hidden
|
|
85
|
+
*/
|
|
86
|
+
this._width = 'auto';
|
|
87
|
+
/**
|
|
88
|
+
* @hidden
|
|
89
|
+
*/
|
|
90
|
+
this._height = 'auto';
|
|
91
|
+
this._offset = 6;
|
|
92
|
+
this.subs = new Subscription();
|
|
93
|
+
/**
|
|
94
|
+
* @hidden
|
|
95
|
+
*/
|
|
96
|
+
this._templateData = () => null;
|
|
97
|
+
validatePackage(packageMetadata);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Specifies the distance from the Popover to its anchor element in pixels.
|
|
101
|
+
*
|
|
102
|
+
* @default `6`
|
|
103
|
+
*/
|
|
104
|
+
set offset(value) {
|
|
105
|
+
this._offset = value;
|
|
106
|
+
}
|
|
107
|
+
get offset() {
|
|
108
|
+
const calloutBuffer = 14;
|
|
109
|
+
return this.callout
|
|
110
|
+
? calloutBuffer + this._offset
|
|
111
|
+
: this._offset;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Determines the width of the popover. Numeric values are treated as pixels.
|
|
115
|
+
* @default 'auto'
|
|
116
|
+
*/
|
|
117
|
+
set width(value) {
|
|
118
|
+
this._width = typeof value === 'number' ? `${value}px` : value;
|
|
119
|
+
}
|
|
120
|
+
get width() {
|
|
121
|
+
return this._width;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Determines the height of the popover. Numeric values are treated as pixels.
|
|
125
|
+
* @default 'auto'
|
|
126
|
+
*/
|
|
127
|
+
set height(value) {
|
|
128
|
+
this._height = typeof value === 'number' ? `${value}px` : value;
|
|
129
|
+
}
|
|
130
|
+
get height() {
|
|
131
|
+
return this._height;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Defines a callback function which returns custom data passed to the Popover templates.
|
|
135
|
+
* It exposes the current anchor element as an argument. [See example]({% slug templates_popover %}#toc-popoverdatacallback)
|
|
136
|
+
*/
|
|
137
|
+
set templateData(fn) {
|
|
138
|
+
if (isDevMode && typeof fn !== 'function') {
|
|
139
|
+
throw new Error(`${ERRORS.templateData} ${JSON.stringify(fn)}.`);
|
|
140
|
+
}
|
|
141
|
+
this._templateData = fn;
|
|
142
|
+
}
|
|
143
|
+
get templateData() {
|
|
144
|
+
return this._templateData;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @hidden
|
|
148
|
+
*/
|
|
149
|
+
get isHidden() {
|
|
150
|
+
return !this.visible;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @hidden
|
|
154
|
+
*/
|
|
155
|
+
get hasAttributeHidden() {
|
|
156
|
+
return !this.visible;
|
|
157
|
+
}
|
|
158
|
+
ngOnInit() {
|
|
159
|
+
this.subs.add(this.localization.changes.subscribe(({ rtl }) => {
|
|
160
|
+
this.direction = rtl ? 'rtl' : 'ltr';
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
ngOnDestroy() {
|
|
164
|
+
this.subs.unsubscribe();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @hidden
|
|
168
|
+
*/
|
|
169
|
+
getCalloutPosition() {
|
|
170
|
+
switch (this.position) {
|
|
171
|
+
case 'top': return { 'k-callout-s': true };
|
|
172
|
+
case 'bottom': return { 'k-callout-n': true };
|
|
173
|
+
case 'left': return { 'k-callout-e': true };
|
|
174
|
+
case 'right': return { 'k-callout-w': true };
|
|
175
|
+
default: return { 'k-callout-s': true };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
PopoverComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PopoverComponent, deps: [{ token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
|
|
180
|
+
PopoverComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: PopoverComponent, selector: "kendo-popover", inputs: { position: "position", offset: "offset", width: "width", height: "height", title: "title", subtitle: "subtitle", body: "body", callout: "callout", animation: "animation", templateData: "templateData" }, outputs: { show: "show", shown: "shown", hide: "hide", hidden: "hidden" }, host: { properties: { "attr.dir": "this.direction", "class.k-hidden": "this.isHidden", "attr.aria-hidden": "this.hasAttributeHidden", "style.width": "this._width", "style.height": "this._height" } }, providers: [
|
|
181
|
+
LocalizationService,
|
|
182
|
+
{
|
|
183
|
+
provide: L10N_PREFIX,
|
|
184
|
+
useValue: 'kendo.popover'
|
|
185
|
+
}
|
|
186
|
+
], queries: [{ propertyName: "titleTemplate", first: true, predicate: PopoverTitleTemplateDirective, descendants: true }, { propertyName: "bodyTemplate", first: true, predicate: PopoverBodyTemplateDirective, descendants: true }, { propertyName: "actionsTemplate", first: true, predicate: PopoverActionsTemplateDirective, descendants: true }], ngImport: i0, template: `
|
|
187
|
+
<div *ngIf="visible" role="tooltip" class="k-popover" [ngStyle]="{'width': width, 'height': height}">
|
|
188
|
+
<div class="k-popover-callout" [ngClass]="getCalloutPosition()" *ngIf="callout"></div>
|
|
189
|
+
|
|
190
|
+
<div *ngIf="titleTemplate || title" class="k-popover-header">
|
|
191
|
+
<ng-template *ngIf="titleTemplate"
|
|
192
|
+
[ngTemplateOutlet]="titleTemplate?.templateRef"
|
|
193
|
+
[ngTemplateOutletContext]="{ $implicit: anchor, data: contextData }">
|
|
194
|
+
</ng-template>
|
|
195
|
+
<ng-container *ngIf="title && !titleTemplate">
|
|
196
|
+
{{ title }}
|
|
197
|
+
</ng-container>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<div *ngIf="bodyTemplate || body" class="k-popover-body">
|
|
201
|
+
<ng-template *ngIf="bodyTemplate"
|
|
202
|
+
[ngTemplateOutlet]="bodyTemplate?.templateRef"
|
|
203
|
+
[ngTemplateOutletContext]="{ $implicit: anchor, data: contextData }">
|
|
204
|
+
</ng-template>
|
|
205
|
+
<ng-container *ngIf="body && !bodyTemplate">
|
|
206
|
+
{{ body }}
|
|
207
|
+
</ng-container>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<div *ngIf="actionsTemplate" class="k-popover-actions k-actions k-hstack k-justify-content-between">
|
|
211
|
+
<ng-template *ngIf="actionsTemplate"
|
|
212
|
+
[ngTemplateOutlet]="actionsTemplate?.templateRef"
|
|
213
|
+
[ngTemplateOutletContext]="{ $implicit: anchor, data: contextData }">
|
|
214
|
+
</ng-template>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
`, isInline: true, directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
|
|
218
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PopoverComponent, decorators: [{
|
|
219
|
+
type: Component,
|
|
220
|
+
args: [{
|
|
221
|
+
selector: 'kendo-popover',
|
|
222
|
+
providers: [
|
|
223
|
+
LocalizationService,
|
|
224
|
+
{
|
|
225
|
+
provide: L10N_PREFIX,
|
|
226
|
+
useValue: 'kendo.popover'
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
template: `
|
|
230
|
+
<div *ngIf="visible" role="tooltip" class="k-popover" [ngStyle]="{'width': width, 'height': height}">
|
|
231
|
+
<div class="k-popover-callout" [ngClass]="getCalloutPosition()" *ngIf="callout"></div>
|
|
232
|
+
|
|
233
|
+
<div *ngIf="titleTemplate || title" class="k-popover-header">
|
|
234
|
+
<ng-template *ngIf="titleTemplate"
|
|
235
|
+
[ngTemplateOutlet]="titleTemplate?.templateRef"
|
|
236
|
+
[ngTemplateOutletContext]="{ $implicit: anchor, data: contextData }">
|
|
237
|
+
</ng-template>
|
|
238
|
+
<ng-container *ngIf="title && !titleTemplate">
|
|
239
|
+
{{ title }}
|
|
240
|
+
</ng-container>
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
<div *ngIf="bodyTemplate || body" class="k-popover-body">
|
|
244
|
+
<ng-template *ngIf="bodyTemplate"
|
|
245
|
+
[ngTemplateOutlet]="bodyTemplate?.templateRef"
|
|
246
|
+
[ngTemplateOutletContext]="{ $implicit: anchor, data: contextData }">
|
|
247
|
+
</ng-template>
|
|
248
|
+
<ng-container *ngIf="body && !bodyTemplate">
|
|
249
|
+
{{ body }}
|
|
250
|
+
</ng-container>
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
<div *ngIf="actionsTemplate" class="k-popover-actions k-actions k-hstack k-justify-content-between">
|
|
254
|
+
<ng-template *ngIf="actionsTemplate"
|
|
255
|
+
[ngTemplateOutlet]="actionsTemplate?.templateRef"
|
|
256
|
+
[ngTemplateOutletContext]="{ $implicit: anchor, data: contextData }">
|
|
257
|
+
</ng-template>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
`
|
|
261
|
+
}]
|
|
262
|
+
}], ctorParameters: function () { return [{ type: i1.LocalizationService }]; }, propDecorators: { position: [{
|
|
263
|
+
type: Input
|
|
264
|
+
}], offset: [{
|
|
265
|
+
type: Input
|
|
266
|
+
}], width: [{
|
|
267
|
+
type: Input
|
|
268
|
+
}], height: [{
|
|
269
|
+
type: Input
|
|
270
|
+
}], direction: [{
|
|
271
|
+
type: HostBinding,
|
|
272
|
+
args: ['attr.dir']
|
|
273
|
+
}], title: [{
|
|
274
|
+
type: Input
|
|
275
|
+
}], subtitle: [{
|
|
276
|
+
type: Input
|
|
277
|
+
}], body: [{
|
|
278
|
+
type: Input
|
|
279
|
+
}], callout: [{
|
|
280
|
+
type: Input
|
|
281
|
+
}], animation: [{
|
|
282
|
+
type: Input
|
|
283
|
+
}], templateData: [{
|
|
284
|
+
type: Input
|
|
285
|
+
}], isHidden: [{
|
|
286
|
+
type: HostBinding,
|
|
287
|
+
args: ['class.k-hidden']
|
|
288
|
+
}], hasAttributeHidden: [{
|
|
289
|
+
type: HostBinding,
|
|
290
|
+
args: ['attr.aria-hidden']
|
|
291
|
+
}], show: [{
|
|
292
|
+
type: Output
|
|
293
|
+
}], shown: [{
|
|
294
|
+
type: Output
|
|
295
|
+
}], hide: [{
|
|
296
|
+
type: Output
|
|
297
|
+
}], hidden: [{
|
|
298
|
+
type: Output
|
|
299
|
+
}], titleTemplate: [{
|
|
300
|
+
type: ContentChild,
|
|
301
|
+
args: [PopoverTitleTemplateDirective, { static: false }]
|
|
302
|
+
}], bodyTemplate: [{
|
|
303
|
+
type: ContentChild,
|
|
304
|
+
args: [PopoverBodyTemplateDirective, { static: false }]
|
|
305
|
+
}], actionsTemplate: [{
|
|
306
|
+
type: ContentChild,
|
|
307
|
+
args: [PopoverActionsTemplateDirective, { static: false }]
|
|
308
|
+
}], _width: [{
|
|
309
|
+
type: HostBinding,
|
|
310
|
+
args: ['style.width']
|
|
311
|
+
}], _height: [{
|
|
312
|
+
type: HostBinding,
|
|
313
|
+
args: ['style.height']
|
|
314
|
+
}] } });
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { Injectable } from '@angular/core';
|
|
6
|
+
import { BehaviorSubject, combineLatest, Subject, Subscription } from 'rxjs';
|
|
7
|
+
import { auditTime } from 'rxjs/operators';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
export class PopoverService {
|
|
13
|
+
constructor(ngZone) {
|
|
14
|
+
this.ngZone = ngZone;
|
|
15
|
+
this._pointerOverPopup = new BehaviorSubject(null);
|
|
16
|
+
this._pointerOverAnchor = new BehaviorSubject(null);
|
|
17
|
+
this._focusInsidePopover = new BehaviorSubject(null);
|
|
18
|
+
this._hidePopover = new Subject();
|
|
19
|
+
this.subs = new Subscription();
|
|
20
|
+
this.monitor();
|
|
21
|
+
}
|
|
22
|
+
ngOnDestroy() {
|
|
23
|
+
this.subs.unsubscribe();
|
|
24
|
+
}
|
|
25
|
+
get isPopoverHovered() {
|
|
26
|
+
return this._pointerOverPopup.asObservable();
|
|
27
|
+
}
|
|
28
|
+
emitPopoverState(isHovered) {
|
|
29
|
+
this.ngZone.run(_ => this._pointerOverPopup.next(isHovered));
|
|
30
|
+
}
|
|
31
|
+
get isAnchorHovered() {
|
|
32
|
+
return this._pointerOverAnchor.asObservable();
|
|
33
|
+
}
|
|
34
|
+
emitAnchorState(isHovered, anchor) {
|
|
35
|
+
this._isOrigin = this.originAnchor === anchor;
|
|
36
|
+
this.currentAnchor = anchor;
|
|
37
|
+
if (isHovered) {
|
|
38
|
+
this.originAnchor = anchor;
|
|
39
|
+
}
|
|
40
|
+
this.ngZone.run(_ => this._pointerOverAnchor.next(isHovered));
|
|
41
|
+
}
|
|
42
|
+
get isFocusInsidePopover() {
|
|
43
|
+
return this._focusInsidePopover.asObservable();
|
|
44
|
+
}
|
|
45
|
+
emitFocusInsidePopover(isFocused) {
|
|
46
|
+
this.ngZone.run(_ => this._focusInsidePopover.next(isFocused));
|
|
47
|
+
this._focusInsidePopover.next(null);
|
|
48
|
+
}
|
|
49
|
+
get hidePopover() {
|
|
50
|
+
return this._hidePopover.asObservable();
|
|
51
|
+
}
|
|
52
|
+
monitor() {
|
|
53
|
+
this.subs.add(combineLatest(this.isPopoverHovered, this.isAnchorHovered).pipe(
|
|
54
|
+
// `auditTime` is used because the `mouseleave` event is emitted before `mouseenter`
|
|
55
|
+
// 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)
|
|
56
|
+
// resulting in both observables emitting `false`
|
|
57
|
+
auditTime(20)).subscribe(val => {
|
|
58
|
+
const [isPopoverHovered, isAnchorHovered] = val;
|
|
59
|
+
this._hidePopover.next([isPopoverHovered, isAnchorHovered, this._isOrigin, this.currentAnchor]);
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
PopoverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PopoverService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
64
|
+
PopoverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PopoverService });
|
|
65
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: PopoverService, decorators: [{
|
|
66
|
+
type: Injectable
|
|
67
|
+
}], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
|