@siemens/element-ng 49.12.0 → 49.14.0
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/fesm2022/siemens-element-ng-accordion.mjs +4 -3
- package/fesm2022/siemens-element-ng-accordion.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-application-header.mjs +35 -13
- package/fesm2022/siemens-element-ng-application-header.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-autocomplete.mjs +9 -13
- package/fesm2022/siemens-element-ng-autocomplete.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-form.mjs +24 -46
- package/fesm2022/siemens-element-ng-form.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-header-dropdown.mjs +14 -7
- package/fesm2022/siemens-element-ng-header-dropdown.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-ip-input.mjs +1 -1
- package/fesm2022/siemens-element-ng-ip-input.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-phone-number.mjs +63 -42
- package/fesm2022/siemens-element-ng-phone-number.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-popover.mjs +7 -9
- package/fesm2022/siemens-element-ng-popover.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-summary-chip.mjs +2 -2
- package/fesm2022/siemens-element-ng-summary-chip.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tabs.mjs +33 -6
- package/fesm2022/siemens-element-ng-tabs.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tooltip.mjs +178 -75
- package/fesm2022/siemens-element-ng-tooltip.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tour.mjs +4 -1
- package/fesm2022/siemens-element-ng-tour.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tree-view.mjs +28 -7
- package/fesm2022/siemens-element-ng-tree-view.mjs.map +1 -1
- package/package.json +3 -3
- package/types/siemens-element-ng-application-header.d.ts +12 -4
- package/types/siemens-element-ng-autocomplete.d.ts +19 -19
- package/types/siemens-element-ng-form.d.ts +1 -3
- package/types/siemens-element-ng-header-dropdown.d.ts +5 -0
- package/types/siemens-element-ng-phone-number.d.ts +2 -2
- package/types/siemens-element-ng-popover.d.ts +2 -2
- package/types/siemens-element-ng-tabs.d.ts +4 -0
- package/types/siemens-element-ng-tooltip.d.ts +10 -26
- package/types/siemens-element-ng-tree-view.d.ts +14 -3
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, signal, inject, ElementRef, computed, TemplateRef, ChangeDetectionStrategy, Component, Injector, Injectable, input, booleanAttribute,
|
|
3
|
-
import {
|
|
4
|
-
import { Overlay } from '@angular/cdk/overlay';
|
|
2
|
+
import { InjectionToken, signal, inject, ElementRef, afterRenderEffect, computed, TemplateRef, ChangeDetectionStrategy, Component, Injector, PLATFORM_ID, Injectable, input, booleanAttribute, effect, Directive, NgModule } from '@angular/core';
|
|
3
|
+
import { OverlayRef, Overlay } from '@angular/cdk/overlay';
|
|
5
4
|
import { ComponentPortal } from '@angular/cdk/portal';
|
|
6
|
-
import {
|
|
5
|
+
import { NgTemplateOutlet, NgComponentOutlet, isPlatformBrowser } from '@angular/common';
|
|
6
|
+
import { calculateOverlayArrowPosition, getOverlay, getPositionStrategy } from '@siemens/element-ng/common';
|
|
7
|
+
import { Subject, fromEvent, timer } from 'rxjs';
|
|
8
|
+
import { filter, takeUntil, delayWhen } from 'rxjs/operators';
|
|
7
9
|
import { SiTranslatePipe } from '@siemens/element-translate-ng/translate';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -12,14 +14,45 @@ import { SiTranslatePipe } from '@siemens/element-translate-ng/translate';
|
|
|
12
14
|
*/
|
|
13
15
|
const SI_TOOLTIP_CONFIG = new InjectionToken('SiTooltipConfig');
|
|
14
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (c) Siemens 2016 - 2026
|
|
19
|
+
* SPDX-License-Identifier: MIT
|
|
20
|
+
*/
|
|
15
21
|
class TooltipComponent {
|
|
16
22
|
tooltipPositionClass = signal('', ...(ngDevMode ? [{ debugName: "tooltipPositionClass" }] : []));
|
|
17
23
|
arrowPos = signal(undefined, ...(ngDevMode ? [{ debugName: "arrowPos" }] : []));
|
|
18
24
|
config = inject(SI_TOOLTIP_CONFIG);
|
|
19
25
|
elementRef = inject(ElementRef);
|
|
26
|
+
overlayRef = inject(OverlayRef);
|
|
27
|
+
lastPositionChange;
|
|
28
|
+
lastAnchor;
|
|
29
|
+
constructor() {
|
|
30
|
+
let isFirstRun = true;
|
|
31
|
+
afterRenderEffect(() => {
|
|
32
|
+
this.config.tooltip();
|
|
33
|
+
this.config.tooltipContext();
|
|
34
|
+
if (isFirstRun) {
|
|
35
|
+
isFirstRun = false;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.overlayRef.updatePosition();
|
|
39
|
+
if (this.lastPositionChange) {
|
|
40
|
+
this.updateTooltipPosition(this.lastPositionChange, this.lastAnchor);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
20
44
|
tooltipText = computed(() => {
|
|
21
45
|
const tooltip = this.config.tooltip();
|
|
22
|
-
|
|
46
|
+
if (typeof tooltip === 'string') {
|
|
47
|
+
return tooltip;
|
|
48
|
+
}
|
|
49
|
+
// When an ElementRef is provided, read its current text content whenever the
|
|
50
|
+
// tooltip is shown, so dynamic content is always reflected.
|
|
51
|
+
// The tooltip content is not updated while being displayed.
|
|
52
|
+
if (tooltip instanceof ElementRef) {
|
|
53
|
+
return tooltip.nativeElement.textContent.trim();
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
23
56
|
}, ...(ngDevMode ? [{ debugName: "tooltipText" }] : []));
|
|
24
57
|
tooltipTemplate = computed(() => {
|
|
25
58
|
const tooltip = this.config.tooltip();
|
|
@@ -27,10 +60,16 @@ class TooltipComponent {
|
|
|
27
60
|
}, ...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : []));
|
|
28
61
|
tooltipComponent = computed(() => {
|
|
29
62
|
const tooltip = this.config.tooltip();
|
|
30
|
-
return !(tooltip instanceof TemplateRef) &&
|
|
63
|
+
return !(tooltip instanceof TemplateRef) &&
|
|
64
|
+
!(tooltip instanceof ElementRef) &&
|
|
65
|
+
typeof tooltip !== 'string'
|
|
66
|
+
? tooltip
|
|
67
|
+
: null;
|
|
31
68
|
}, ...(ngDevMode ? [{ debugName: "tooltipComponent" }] : []));
|
|
32
69
|
/** @internal */
|
|
33
70
|
updateTooltipPosition(change, anchor) {
|
|
71
|
+
this.lastPositionChange = change;
|
|
72
|
+
this.lastAnchor = anchor;
|
|
34
73
|
const arrowClassTooltip = `tooltip-${change.connectionPair.overlayX}-${change.connectionPair.overlayY}`;
|
|
35
74
|
// need two updates as class changes affect the position
|
|
36
75
|
if (arrowClassTooltip !== this.tooltipPositionClass()) {
|
|
@@ -47,45 +86,126 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
47
86
|
args: [{ selector: 'si-tooltip', imports: [NgTemplateOutlet, SiTranslatePipe, NgComponentOutlet], changeDetection: ChangeDetectionStrategy.Default, host: {
|
|
48
87
|
'animate.leave': 'tooltip-leave'
|
|
49
88
|
}, template: "<div\n class=\"tooltip show position-relative\"\n role=\"tooltip\"\n [id]=\"config.id\"\n [class]=\"tooltipPositionClass()\"\n>\n <div\n class=\"tooltip-arrow\"\n [style.left.px]=\"arrowPos()?.left\"\n [style.right.px]=\"arrowPos()?.right\"\n ></div>\n <div class=\"tooltip-inner\">\n @if (tooltipText()) {\n <div class=\"si-body\">{{ tooltipText() | translate }}</div>\n } @else if (tooltipTemplate()) {\n <ng-template\n [ngTemplateOutlet]=\"tooltipTemplate()\"\n [ngTemplateOutletContext]=\"config.tooltipContext()\"\n />\n } @else if (tooltipComponent()) {\n <ng-container [ngComponentOutlet]=\"tooltipComponent()!\" />\n }\n </div>\n</div>\n", styles: [":host .tooltip,:host{transition:opacity calc(.15s * var(--element-animations-enabled, 1)) ease-out,transform calc(.15s * var(--element-animations-enabled, 1)) ease-out}:host{opacity:1;transform:scale(1)}:host.tooltip-leave{opacity:0;transform:scale(.8)}@starting-style{:host .tooltip{opacity:0;transform:scale(.8)}}\n"] }]
|
|
50
|
-
}] });
|
|
89
|
+
}], ctorParameters: () => [] });
|
|
51
90
|
|
|
52
91
|
/**
|
|
53
92
|
* Copyright (c) Siemens 2016 - 2026
|
|
54
93
|
* SPDX-License-Identifier: MIT
|
|
55
94
|
*/
|
|
56
95
|
/**
|
|
57
|
-
* TooltipRef
|
|
96
|
+
* A no-op TooltipRef used on platform server where DOM APIs are unavailable.
|
|
97
|
+
*
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
class NoopTooltipRef {
|
|
101
|
+
destroy() { }
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* BrowserTooltipRef is attached to a specific element.
|
|
58
105
|
* Use it to show or hide a tooltip for that element.
|
|
59
106
|
*
|
|
60
107
|
* @internal
|
|
61
108
|
*/
|
|
62
|
-
class
|
|
109
|
+
class BrowserTooltipRef {
|
|
110
|
+
config;
|
|
111
|
+
destroy$ = new Subject();
|
|
112
|
+
isFocused = false;
|
|
113
|
+
isHovered = false;
|
|
63
114
|
overlayRef;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
115
|
+
positionSubscription;
|
|
116
|
+
constructor(config) {
|
|
117
|
+
this.config = config;
|
|
118
|
+
const nativeElement = this.config.element.nativeElement;
|
|
119
|
+
fromEvent(nativeElement, 'focus')
|
|
120
|
+
.pipe(filter(event => event instanceof FocusEvent), takeUntil(this.destroy$))
|
|
121
|
+
.subscribe(event => this.onFocus(event));
|
|
122
|
+
fromEvent(nativeElement, 'mouseenter')
|
|
123
|
+
.pipe(delayWhen(() =>
|
|
124
|
+
// UX Guideline: tooltips on hover should be delayed by 500ms
|
|
125
|
+
timer(500).pipe(takeUntil(fromEvent(nativeElement, 'mouseleave')), takeUntil(fromEvent(nativeElement, 'focusout')) // user started using keyboard
|
|
126
|
+
)), takeUntil(this.destroy$))
|
|
127
|
+
.subscribe(() => this.onMouseEnter());
|
|
128
|
+
fromEvent(nativeElement, 'focusout')
|
|
129
|
+
.pipe(takeUntil(this.destroy$))
|
|
130
|
+
.subscribe(() => this.onFocusOut());
|
|
131
|
+
fromEvent(nativeElement, 'mouseleave')
|
|
132
|
+
.pipe(takeUntil(this.destroy$))
|
|
133
|
+
.subscribe(() => this.onMouseLeave());
|
|
134
|
+
fromEvent(nativeElement, 'touchstart')
|
|
135
|
+
.pipe(takeUntil(this.destroy$))
|
|
136
|
+
.subscribe(() => this.onTouchStart());
|
|
137
|
+
// The tooltip may be created lazily, after the element is already focused or
|
|
138
|
+
// hovered (e.g. when validation errors appear on blur while the pointer still
|
|
139
|
+
// hovers the element). In that case the initial `focus`/`mouseenter` was
|
|
140
|
+
// missed, so show the tooltip immediately based on the live `:focus-visible`
|
|
141
|
+
// and `:hover` state.
|
|
142
|
+
if (nativeElement === document.activeElement && nativeElement.matches(':focus-visible')) {
|
|
143
|
+
this.isFocused = true;
|
|
144
|
+
this.show();
|
|
145
|
+
}
|
|
146
|
+
else if (nativeElement.matches(':hover')) {
|
|
147
|
+
this.onMouseEnter();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
onFocus(event) {
|
|
151
|
+
if (event.target instanceof Element) {
|
|
152
|
+
if (event.target.matches(':focus-visible')) {
|
|
153
|
+
this.isFocused = true;
|
|
154
|
+
this.show();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
onFocusOut() {
|
|
159
|
+
this.isFocused = false;
|
|
160
|
+
this.isHovered = false;
|
|
161
|
+
this.hide();
|
|
162
|
+
}
|
|
163
|
+
onMouseEnter() {
|
|
164
|
+
this.isHovered = true;
|
|
165
|
+
this.show();
|
|
166
|
+
}
|
|
167
|
+
onMouseLeave() {
|
|
168
|
+
this.isHovered = false;
|
|
169
|
+
this.hide();
|
|
170
|
+
}
|
|
171
|
+
onTouchStart() {
|
|
172
|
+
// On touch devices a tooltip is not useful and would obscure the content the
|
|
173
|
+
// user just tapped. Reset the hover/focus state so it is hidden immediately.
|
|
174
|
+
this.isFocused = false;
|
|
175
|
+
this.isHovered = false;
|
|
176
|
+
this.hide();
|
|
177
|
+
}
|
|
178
|
+
getOrCreateOverlay() {
|
|
179
|
+
this.overlayRef ??= getOverlay(this.config.element, this.config.overlay, false, this.config.placement, false, true, this.config.scrollStrategy?.());
|
|
180
|
+
return this.overlayRef;
|
|
70
181
|
}
|
|
71
|
-
subscription;
|
|
72
182
|
show() {
|
|
73
|
-
|
|
183
|
+
const overlayRef = this.getOrCreateOverlay();
|
|
184
|
+
if (overlayRef.hasAttached()) {
|
|
74
185
|
return;
|
|
75
186
|
}
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
187
|
+
const injector = Injector.create({
|
|
188
|
+
parent: this.config.injector,
|
|
189
|
+
providers: [{ provide: OverlayRef, useValue: overlayRef }]
|
|
190
|
+
});
|
|
191
|
+
const toolTipPortal = new ComponentPortal(TooltipComponent, undefined, injector);
|
|
192
|
+
const tooltipRef = overlayRef.attach(toolTipPortal);
|
|
193
|
+
const positionStrategy = getPositionStrategy(overlayRef);
|
|
194
|
+
this.positionSubscription?.unsubscribe();
|
|
195
|
+
this.positionSubscription = positionStrategy?.positionChanges.subscribe(change => tooltipRef.instance.updateTooltipPosition(change, this.config.element));
|
|
81
196
|
}
|
|
82
197
|
hide() {
|
|
83
|
-
this.
|
|
84
|
-
|
|
198
|
+
if (this.isFocused || this.isHovered) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.overlayRef?.detach();
|
|
202
|
+
this.positionSubscription?.unsubscribe();
|
|
85
203
|
}
|
|
86
204
|
destroy() {
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
205
|
+
this.destroy$.next();
|
|
206
|
+
this.destroy$.complete();
|
|
207
|
+
this.overlayRef?.dispose();
|
|
208
|
+
this.positionSubscription?.unsubscribe();
|
|
89
209
|
}
|
|
90
210
|
}
|
|
91
211
|
/**
|
|
@@ -98,7 +218,11 @@ class TooltipRef {
|
|
|
98
218
|
// We cannot provide this in root, as people may override the cdk overlay creation.
|
|
99
219
|
class SiTooltipService {
|
|
100
220
|
overlay = inject(Overlay);
|
|
221
|
+
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
101
222
|
createTooltip(config) {
|
|
223
|
+
if (!this.isBrowser) {
|
|
224
|
+
return new NoopTooltipRef();
|
|
225
|
+
}
|
|
102
226
|
const injector = Injector.create({
|
|
103
227
|
parent: config.injector,
|
|
104
228
|
providers: [
|
|
@@ -112,7 +236,11 @@ class SiTooltipService {
|
|
|
112
236
|
}
|
|
113
237
|
]
|
|
114
238
|
});
|
|
115
|
-
return new
|
|
239
|
+
return new BrowserTooltipRef({
|
|
240
|
+
...config,
|
|
241
|
+
injector,
|
|
242
|
+
overlay: this.overlay
|
|
243
|
+
});
|
|
116
244
|
}
|
|
117
245
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiTooltipService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
118
246
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiTooltipService });
|
|
@@ -152,53 +280,33 @@ class SiTooltipDirective {
|
|
|
152
280
|
tooltipContext = input(...(ngDevMode ? [undefined, { debugName: "tooltipContext" }] : []));
|
|
153
281
|
describedBy = `__tooltip_${SiTooltipDirective.idCounter++}`;
|
|
154
282
|
tooltipRef;
|
|
155
|
-
showTimeout;
|
|
156
283
|
tooltipService = inject(SiTooltipService);
|
|
157
284
|
elementRef = inject(ElementRef);
|
|
158
|
-
|
|
285
|
+
constructor() {
|
|
286
|
+
effect(() => {
|
|
287
|
+
const tooltip = this.siTooltip();
|
|
288
|
+
const disabled = this.isDisabled();
|
|
289
|
+
if (tooltip && !disabled) {
|
|
290
|
+
this.tooltipRef ??= this.tooltipService.createTooltip({
|
|
291
|
+
describedBy: this.describedBy,
|
|
292
|
+
element: this.elementRef,
|
|
293
|
+
placement: this.placement(),
|
|
294
|
+
tooltip: this.siTooltip,
|
|
295
|
+
tooltipContext: this.tooltipContext,
|
|
296
|
+
scrollStrategy: this.tooltipScrollStrategy
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
else if (this.tooltipRef) {
|
|
300
|
+
this.tooltipRef.destroy();
|
|
301
|
+
this.tooltipRef = undefined;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}
|
|
159
305
|
ngOnDestroy() {
|
|
160
|
-
this.clearShowTimeout();
|
|
161
306
|
this.tooltipRef?.destroy();
|
|
162
307
|
}
|
|
163
|
-
clearShowTimeout() {
|
|
164
|
-
if (this.showTimeout) {
|
|
165
|
-
clearTimeout(this.showTimeout);
|
|
166
|
-
this.showTimeout = undefined;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
showTooltip(immediate = false) {
|
|
170
|
-
const siTooltip = this.siTooltip();
|
|
171
|
-
if (this.isDisabled() || !siTooltip) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
this.clearShowTimeout();
|
|
175
|
-
const delay = immediate ? 0 : 500;
|
|
176
|
-
this.showTimeout = setTimeout(() => {
|
|
177
|
-
this.tooltipRef ??= this.tooltipService.createTooltip({
|
|
178
|
-
describedBy: this.describedBy,
|
|
179
|
-
element: this.elementRef,
|
|
180
|
-
placement: this.placement(),
|
|
181
|
-
tooltip: this.siTooltip,
|
|
182
|
-
tooltipContext: this.tooltipContext,
|
|
183
|
-
scrollStrategy: this.tooltipScrollStrategy()
|
|
184
|
-
});
|
|
185
|
-
this.tooltipRef.show();
|
|
186
|
-
}, delay);
|
|
187
|
-
}
|
|
188
|
-
focusIn(event) {
|
|
189
|
-
if (this.isBrowser && event.target.matches(':focus-visible')) {
|
|
190
|
-
this.showTooltip(true);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
show() {
|
|
194
|
-
this.showTooltip(false);
|
|
195
|
-
}
|
|
196
|
-
hide() {
|
|
197
|
-
this.clearShowTimeout();
|
|
198
|
-
this.tooltipRef?.hide();
|
|
199
|
-
}
|
|
200
308
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
201
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.8", type: SiTooltipDirective, isStandalone: true, selector: "[siTooltip]", inputs: { siTooltip: { classPropertyName: "siTooltip", publicName: "siTooltip", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "placement", isSignal: true, isRequired: false, transformFunction: null }, isDisabled: { classPropertyName: "isDisabled", publicName: "isDisabled", isSignal: true, isRequired: false, transformFunction: null }, tooltipScrollStrategy: { classPropertyName: "tooltipScrollStrategy", publicName: "tooltipScrollStrategy", isSignal: true, isRequired: false, transformFunction: null }, tooltipContext: { classPropertyName: "tooltipContext", publicName: "tooltipContext", isSignal: true, isRequired: false, transformFunction: null } }, host: {
|
|
309
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.8", type: SiTooltipDirective, isStandalone: true, selector: "[siTooltip]", inputs: { siTooltip: { classPropertyName: "siTooltip", publicName: "siTooltip", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "placement", isSignal: true, isRequired: false, transformFunction: null }, isDisabled: { classPropertyName: "isDisabled", publicName: "isDisabled", isSignal: true, isRequired: false, transformFunction: null }, tooltipScrollStrategy: { classPropertyName: "tooltipScrollStrategy", publicName: "tooltipScrollStrategy", isSignal: true, isRequired: false, transformFunction: null }, tooltipContext: { classPropertyName: "tooltipContext", publicName: "tooltipContext", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-describedby": "isDisabled() ? null : describedBy" } }, providers: [SiTooltipService], ngImport: i0 });
|
|
202
310
|
}
|
|
203
311
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiTooltipDirective, decorators: [{
|
|
204
312
|
type: Directive,
|
|
@@ -206,15 +314,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
206
314
|
selector: '[siTooltip]',
|
|
207
315
|
providers: [SiTooltipService],
|
|
208
316
|
host: {
|
|
209
|
-
'[attr.aria-describedby]': 'isDisabled() ? null : describedBy'
|
|
210
|
-
'(focus)': 'focusIn($event)',
|
|
211
|
-
'(mouseenter)': 'show()',
|
|
212
|
-
'(touchstart)': 'hide()',
|
|
213
|
-
'(focusout)': 'hide()',
|
|
214
|
-
'(mouseleave)': 'hide()'
|
|
317
|
+
'[attr.aria-describedby]': 'isDisabled() ? null : describedBy'
|
|
215
318
|
}
|
|
216
319
|
}]
|
|
217
|
-
}], propDecorators: { siTooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "siTooltip", required: false }] }], placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "placement", required: false }] }], isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "isDisabled", required: false }] }], tooltipScrollStrategy: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipScrollStrategy", required: false }] }], tooltipContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipContext", required: false }] }] } });
|
|
320
|
+
}], ctorParameters: () => [], propDecorators: { siTooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "siTooltip", required: false }] }], placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "placement", required: false }] }], isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "isDisabled", required: false }] }], tooltipScrollStrategy: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipScrollStrategy", required: false }] }], tooltipContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipContext", required: false }] }] } });
|
|
218
321
|
|
|
219
322
|
/**
|
|
220
323
|
* Copyright (c) Siemens 2016 - 2026
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siemens-element-ng-tooltip.mjs","sources":["../../../../projects/element-ng/tooltip/si-tooltip.model.ts","../../../../projects/element-ng/tooltip/si-tooltip.component.ts","../../../../projects/element-ng/tooltip/si-tooltip.component.html","../../../../projects/element-ng/tooltip/si-tooltip.service.ts","../../../../projects/element-ng/tooltip/si-tooltip.directive.ts","../../../../projects/element-ng/tooltip/si-tooltip.module.ts","../../../../projects/element-ng/tooltip/index.ts","../../../../projects/element-ng/tooltip/siemens-element-ng-tooltip.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { InjectionToken, TemplateRef, Type } from '@angular/core';\nimport { TranslatableString } from '@siemens/element-translate-ng/translate';\n\nexport type SiTooltipContent = TranslatableString | TemplateRef<any> | Type<any> | null | undefined;\n\nexport interface SiTooltipConfig {\n id: string;\n tooltip: () => SiTooltipContent;\n tooltipContext: () => unknown;\n}\n\nexport const SI_TOOLTIP_CONFIG = new InjectionToken<SiTooltipConfig>('SiTooltipConfig');\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { ConnectedOverlayPositionChange } from '@angular/cdk/overlay';\nimport { NgComponentOutlet, NgTemplateOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n ElementRef,\n inject,\n signal,\n TemplateRef\n} from '@angular/core';\nimport { calculateOverlayArrowPosition, OverlayArrowPosition } from '@siemens/element-ng/common';\nimport { SiTranslatePipe } from '@siemens/element-translate-ng/translate';\n\nimport { SI_TOOLTIP_CONFIG } from './si-tooltip.model';\n\n@Component({\n selector: 'si-tooltip',\n imports: [NgTemplateOutlet, SiTranslatePipe, NgComponentOutlet],\n templateUrl: './si-tooltip.component.html',\n styleUrl: './si-tooltip.component.scss',\n changeDetection: ChangeDetectionStrategy.Default,\n host: {\n 'animate.leave': 'tooltip-leave'\n }\n})\nexport class TooltipComponent {\n protected readonly tooltipPositionClass = signal('');\n protected readonly arrowPos = signal<OverlayArrowPosition | undefined>(undefined);\n\n protected readonly config = inject(SI_TOOLTIP_CONFIG);\n private readonly elementRef = inject(ElementRef);\n\n protected readonly tooltipText = computed<string | null>(() => {\n const tooltip = this.config.tooltip();\n return typeof tooltip === 'string' ? tooltip : null;\n });\n\n protected readonly tooltipTemplate = computed<TemplateRef<any> | null>(() => {\n const tooltip = this.config.tooltip();\n return tooltip instanceof TemplateRef ? tooltip : null;\n });\n\n protected readonly tooltipComponent = computed(() => {\n const tooltip = this.config.tooltip();\n return !(tooltip instanceof TemplateRef) && typeof tooltip !== 'string' ? tooltip : null;\n });\n\n /** @internal */\n updateTooltipPosition(change: ConnectedOverlayPositionChange, anchor?: ElementRef): void {\n const arrowClassTooltip = `tooltip-${change.connectionPair.overlayX}-${change.connectionPair.overlayY}`;\n // need two updates as class changes affect the position\n if (arrowClassTooltip !== this.tooltipPositionClass()) {\n this.tooltipPositionClass.set(arrowClassTooltip);\n }\n const arrowPos = calculateOverlayArrowPosition(change, this.elementRef, anchor);\n this.arrowPos.set(arrowPos);\n }\n}\n","<div\n class=\"tooltip show position-relative\"\n role=\"tooltip\"\n [id]=\"config.id\"\n [class]=\"tooltipPositionClass()\"\n>\n <div\n class=\"tooltip-arrow\"\n [style.left.px]=\"arrowPos()?.left\"\n [style.right.px]=\"arrowPos()?.right\"\n ></div>\n <div class=\"tooltip-inner\">\n @if (tooltipText()) {\n <div class=\"si-body\">{{ tooltipText() | translate }}</div>\n } @else if (tooltipTemplate()) {\n <ng-template\n [ngTemplateOutlet]=\"tooltipTemplate()\"\n [ngTemplateOutletContext]=\"config.tooltipContext()\"\n />\n } @else if (tooltipComponent()) {\n <ng-container [ngComponentOutlet]=\"tooltipComponent()!\" />\n }\n </div>\n</div>\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { Overlay, OverlayRef, ScrollStrategy } from '@angular/cdk/overlay';\nimport { ComponentPortal } from '@angular/cdk/portal';\nimport { ComponentRef, ElementRef, inject, Injectable, Injector } from '@angular/core';\nimport { getOverlay, getPositionStrategy, positions } from '@siemens/element-ng/common';\nimport { Subscription } from 'rxjs';\n\nimport { TooltipComponent } from './si-tooltip.component';\nimport { SI_TOOLTIP_CONFIG, SiTooltipContent } from './si-tooltip.model';\n\n/**\n * TooltipRef is attached to a specific element.\n * Use it to show or hide a tooltip for that element.\n *\n * @internal\n */\nclass TooltipRef {\n constructor(\n private overlayRef: OverlayRef,\n private element: ElementRef,\n private injector?: Injector\n ) {}\n\n private subscription?: Subscription;\n\n show(): void {\n if (this.overlayRef.hasAttached()) {\n return;\n }\n\n const toolTipPortal = new ComponentPortal(TooltipComponent, undefined, this.injector);\n const tooltipRef: ComponentRef<TooltipComponent> = this.overlayRef.attach(toolTipPortal);\n\n const positionStrategy = getPositionStrategy(this.overlayRef);\n this.subscription?.unsubscribe();\n this.subscription = positionStrategy?.positionChanges.subscribe(change =>\n tooltipRef.instance.updateTooltipPosition(change, this.element)\n );\n }\n\n hide(): void {\n this.overlayRef.detach();\n this.subscription?.unsubscribe();\n }\n\n destroy(): void {\n this.overlayRef.dispose();\n this.subscription?.unsubscribe();\n }\n}\n\n/**\n * A service to create tooltips for specific elements.\n * Use this if the tooltip directive is not suitable.\n * Must not be used outside element-ng.\n *\n * @internal\n */\n// We cannot provide this in root, as people may override the cdk overlay creation.\n@Injectable()\nexport class SiTooltipService {\n private overlay = inject(Overlay);\n\n createTooltip(config: {\n describedBy: string;\n element: ElementRef;\n placement: keyof typeof positions;\n injector?: Injector;\n tooltip: () => SiTooltipContent;\n tooltipContext: () => unknown;\n scrollStrategy?: ScrollStrategy;\n }): TooltipRef {\n const injector = Injector.create({\n parent: config.injector,\n providers: [\n {\n provide: SI_TOOLTIP_CONFIG,\n useValue: {\n id: config.describedBy,\n tooltip: config.tooltip,\n tooltipContext: config.tooltipContext\n }\n }\n ]\n });\n\n return new TooltipRef(\n getOverlay(\n config.element,\n this.overlay,\n false,\n config.placement,\n false,\n true,\n config.scrollStrategy\n ),\n config.element,\n injector\n );\n }\n}\n\nexport type { TooltipRef };\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { ScrollStrategy } from '@angular/cdk/overlay';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n booleanAttribute,\n Directive,\n ElementRef,\n inject,\n input,\n OnDestroy,\n PLATFORM_ID,\n TemplateRef\n} from '@angular/core';\nimport { positions } from '@siemens/element-ng/common';\nimport { TranslatableString } from '@siemens/element-translate-ng/translate';\n\nimport { SiTooltipService, TooltipRef } from './si-tooltip.service';\n\n@Directive({\n selector: '[siTooltip]',\n providers: [SiTooltipService],\n host: {\n '[attr.aria-describedby]': 'isDisabled() ? null : describedBy',\n '(focus)': 'focusIn($event)',\n '(mouseenter)': 'show()',\n '(touchstart)': 'hide()',\n '(focusout)': 'hide()',\n '(mouseleave)': 'hide()'\n }\n})\nexport class SiTooltipDirective implements OnDestroy {\n private static idCounter = 0;\n\n /**\n * The tooltip text to be displayed\n *\n * @defaultValue ''\n */\n readonly siTooltip = input<TranslatableString | TemplateRef<any>>('');\n\n /**\n * The placement of the tooltip. One of 'top', 'start', end', 'bottom'\n *\n * @defaultValue 'auto'\n */\n readonly placement = input<keyof typeof positions>('auto');\n\n /**\n * Allows the tooltip to be disabled\n *\n * @defaultValue false\n */\n readonly isDisabled = input(false, { transform: booleanAttribute });\n\n /**\n * Optional CDK scroll strategy used for the tooltip overlay.\n * If not provided, the default reposition strategy is used.\n */\n readonly tooltipScrollStrategy = input<ScrollStrategy>();\n\n /**\n * The context for the attached template\n */\n readonly tooltipContext = input();\n\n protected describedBy = `__tooltip_${SiTooltipDirective.idCounter++}`;\n\n private tooltipRef?: TooltipRef;\n private showTimeout?: ReturnType<typeof setTimeout>;\n private tooltipService = inject(SiTooltipService);\n private elementRef = inject(ElementRef);\n private isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n ngOnDestroy(): void {\n this.clearShowTimeout();\n this.tooltipRef?.destroy();\n }\n\n private clearShowTimeout(): void {\n if (this.showTimeout) {\n clearTimeout(this.showTimeout);\n this.showTimeout = undefined;\n }\n }\n\n private showTooltip(immediate = false): void {\n const siTooltip = this.siTooltip();\n if (this.isDisabled() || !siTooltip) {\n return;\n }\n\n this.clearShowTimeout();\n\n const delay = immediate ? 0 : 500;\n\n this.showTimeout = setTimeout(() => {\n this.tooltipRef ??= this.tooltipService.createTooltip({\n describedBy: this.describedBy,\n element: this.elementRef,\n placement: this.placement(),\n tooltip: this.siTooltip,\n tooltipContext: this.tooltipContext,\n scrollStrategy: this.tooltipScrollStrategy()\n });\n this.tooltipRef.show();\n }, delay);\n }\n\n protected focusIn(event: FocusEvent): void {\n if (this.isBrowser && (event.target as Element).matches(':focus-visible')) {\n this.showTooltip(true);\n }\n }\n\n protected show(): void {\n this.showTooltip(false);\n }\n\n protected hide(): void {\n this.clearShowTimeout();\n this.tooltipRef?.hide();\n }\n}\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { NgModule } from '@angular/core';\n\nimport { SiTooltipDirective } from './si-tooltip.directive';\n\n@NgModule({\n imports: [SiTooltipDirective],\n exports: [SiTooltipDirective]\n})\nexport class SiTooltipModule {}\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nexport * from './si-tooltip.module';\nexport * from './si-tooltip.directive';\nexport * from './si-tooltip.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;AAGG;AAYI,MAAM,iBAAiB,GAAG,IAAI,cAAc,CAAkB,iBAAiB,CAAC;;MCe1E,gBAAgB,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.model.ts","../../../../projects/element-ng/tooltip/si-tooltip.component.ts","../../../../projects/element-ng/tooltip/si-tooltip.component.html","../../../../projects/element-ng/tooltip/si-tooltip.service.ts","../../../../projects/element-ng/tooltip/si-tooltip.directive.ts","../../../../projects/element-ng/tooltip/si-tooltip.module.ts","../../../../projects/element-ng/tooltip/index.ts","../../../../projects/element-ng/tooltip/siemens-element-ng-tooltip.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { ElementRef, InjectionToken, TemplateRef, Type } from '@angular/core';\nimport { TranslatableString } from '@siemens/element-translate-ng/translate';\n\nexport type SiTooltipContent =\n | TranslatableString\n | TemplateRef<any>\n | Type<any>\n | ElementRef<Element>\n | null\n | undefined;\n\nexport interface SiTooltipConfig {\n id?: string;\n tooltip: () => SiTooltipContent;\n tooltipContext: () => unknown;\n}\n\nexport const SI_TOOLTIP_CONFIG = new InjectionToken<SiTooltipConfig>('SiTooltipConfig');\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { ConnectedOverlayPositionChange, OverlayRef } from '@angular/cdk/overlay';\nimport { NgComponentOutlet, NgTemplateOutlet } from '@angular/common';\nimport {\n afterRenderEffect,\n ChangeDetectionStrategy,\n Component,\n computed,\n ElementRef,\n inject,\n signal,\n TemplateRef\n} from '@angular/core';\nimport { calculateOverlayArrowPosition, OverlayArrowPosition } from '@siemens/element-ng/common';\nimport { SiTranslatePipe } from '@siemens/element-translate-ng/translate';\n\nimport { SI_TOOLTIP_CONFIG } from './si-tooltip.model';\n\n@Component({\n selector: 'si-tooltip',\n imports: [NgTemplateOutlet, SiTranslatePipe, NgComponentOutlet],\n templateUrl: './si-tooltip.component.html',\n styleUrl: './si-tooltip.component.scss',\n changeDetection: ChangeDetectionStrategy.Default,\n host: {\n 'animate.leave': 'tooltip-leave'\n }\n})\nexport class TooltipComponent {\n protected readonly tooltipPositionClass = signal('');\n protected readonly arrowPos = signal<OverlayArrowPosition | undefined>(undefined);\n\n protected readonly config = inject(SI_TOOLTIP_CONFIG);\n private readonly elementRef = inject(ElementRef);\n private readonly overlayRef = inject(OverlayRef);\n\n private lastPositionChange?: ConnectedOverlayPositionChange;\n private lastAnchor?: ElementRef;\n\n constructor() {\n let isFirstRun = true;\n afterRenderEffect(() => {\n this.config.tooltip();\n this.config.tooltipContext();\n if (isFirstRun) {\n isFirstRun = false;\n return;\n }\n this.overlayRef.updatePosition();\n if (this.lastPositionChange) {\n this.updateTooltipPosition(this.lastPositionChange, this.lastAnchor);\n }\n });\n }\n\n protected readonly tooltipText = computed<string | null>(() => {\n const tooltip = this.config.tooltip();\n if (typeof tooltip === 'string') {\n return tooltip;\n }\n // When an ElementRef is provided, read its current text content whenever the\n // tooltip is shown, so dynamic content is always reflected.\n // The tooltip content is not updated while being displayed.\n if (tooltip instanceof ElementRef) {\n return tooltip.nativeElement.textContent.trim();\n }\n return null;\n });\n\n protected readonly tooltipTemplate = computed<TemplateRef<any> | null>(() => {\n const tooltip = this.config.tooltip();\n return tooltip instanceof TemplateRef ? tooltip : null;\n });\n\n protected readonly tooltipComponent = computed(() => {\n const tooltip = this.config.tooltip();\n return !(tooltip instanceof TemplateRef) &&\n !(tooltip instanceof ElementRef) &&\n typeof tooltip !== 'string'\n ? tooltip\n : null;\n });\n\n /** @internal */\n updateTooltipPosition(change: ConnectedOverlayPositionChange, anchor?: ElementRef): void {\n this.lastPositionChange = change;\n this.lastAnchor = anchor;\n const arrowClassTooltip = `tooltip-${change.connectionPair.overlayX}-${change.connectionPair.overlayY}`;\n // need two updates as class changes affect the position\n if (arrowClassTooltip !== this.tooltipPositionClass()) {\n this.tooltipPositionClass.set(arrowClassTooltip);\n }\n const arrowPos = calculateOverlayArrowPosition(change, this.elementRef, anchor);\n this.arrowPos.set(arrowPos);\n }\n}\n","<div\n class=\"tooltip show position-relative\"\n role=\"tooltip\"\n [id]=\"config.id\"\n [class]=\"tooltipPositionClass()\"\n>\n <div\n class=\"tooltip-arrow\"\n [style.left.px]=\"arrowPos()?.left\"\n [style.right.px]=\"arrowPos()?.right\"\n ></div>\n <div class=\"tooltip-inner\">\n @if (tooltipText()) {\n <div class=\"si-body\">{{ tooltipText() | translate }}</div>\n } @else if (tooltipTemplate()) {\n <ng-template\n [ngTemplateOutlet]=\"tooltipTemplate()\"\n [ngTemplateOutletContext]=\"config.tooltipContext()\"\n />\n } @else if (tooltipComponent()) {\n <ng-container [ngComponentOutlet]=\"tooltipComponent()!\" />\n }\n </div>\n</div>\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { Overlay, OverlayRef, ScrollStrategy } from '@angular/cdk/overlay';\nimport { ComponentPortal } from '@angular/cdk/portal';\nimport { isPlatformBrowser } from '@angular/common';\nimport { ComponentRef, ElementRef, inject, Injectable, Injector, PLATFORM_ID } from '@angular/core';\nimport { getOverlay, getPositionStrategy, positions } from '@siemens/element-ng/common';\nimport { fromEvent, Subject, Subscription, timer } from 'rxjs';\nimport { delayWhen, filter, takeUntil } from 'rxjs/operators';\n\nimport { TooltipComponent } from './si-tooltip.component';\nimport { SI_TOOLTIP_CONFIG, SiTooltipContent } from './si-tooltip.model';\n\n/** @internal */\ninterface TooltipRef {\n destroy(): void;\n}\n\n/**\n * A no-op TooltipRef used on platform server where DOM APIs are unavailable.\n *\n * @internal\n */\nclass NoopTooltipRef {\n destroy(): void {}\n}\n\n/**\n * BrowserTooltipRef is attached to a specific element.\n * Use it to show or hide a tooltip for that element.\n *\n * @internal\n */\nclass BrowserTooltipRef {\n private readonly destroy$ = new Subject<void>();\n private isFocused = false;\n private isHovered = false;\n private overlayRef?: OverlayRef;\n private positionSubscription?: Subscription;\n\n constructor(\n private config: {\n describedBy?: string;\n element: ElementRef;\n injector?: Injector;\n overlay: Overlay;\n placement: keyof typeof positions;\n scrollStrategy?: () => ScrollStrategy | undefined;\n tooltip: () => SiTooltipContent;\n tooltipContext: () => unknown;\n }\n ) {\n const nativeElement = this.config.element.nativeElement;\n\n fromEvent(nativeElement, 'focus')\n .pipe(\n filter(event => event instanceof FocusEvent),\n takeUntil(this.destroy$)\n )\n .subscribe(event => this.onFocus(event));\n\n fromEvent(nativeElement, 'mouseenter')\n .pipe(\n delayWhen(() =>\n // UX Guideline: tooltips on hover should be delayed by 500ms\n timer(500).pipe(\n takeUntil(fromEvent(nativeElement, 'mouseleave')),\n takeUntil(fromEvent(nativeElement, 'focusout')) // user started using keyboard\n )\n ),\n takeUntil(this.destroy$)\n )\n .subscribe(() => this.onMouseEnter());\n\n fromEvent(nativeElement, 'focusout')\n .pipe(takeUntil(this.destroy$))\n .subscribe(() => this.onFocusOut());\n\n fromEvent(nativeElement, 'mouseleave')\n .pipe(takeUntil(this.destroy$))\n .subscribe(() => this.onMouseLeave());\n\n fromEvent(nativeElement, 'touchstart')\n .pipe(takeUntil(this.destroy$))\n .subscribe(() => this.onTouchStart());\n\n // The tooltip may be created lazily, after the element is already focused or\n // hovered (e.g. when validation errors appear on blur while the pointer still\n // hovers the element). In that case the initial `focus`/`mouseenter` was\n // missed, so show the tooltip immediately based on the live `:focus-visible`\n // and `:hover` state.\n if (nativeElement === document.activeElement && nativeElement.matches(':focus-visible')) {\n this.isFocused = true;\n this.show();\n } else if (nativeElement.matches(':hover')) {\n this.onMouseEnter();\n }\n }\n\n private onFocus(event: FocusEvent): void {\n if (event.target instanceof Element) {\n if (event.target.matches(':focus-visible')) {\n this.isFocused = true;\n this.show();\n }\n }\n }\n\n private onFocusOut(): void {\n this.isFocused = false;\n this.isHovered = false;\n this.hide();\n }\n\n private onMouseEnter(): void {\n this.isHovered = true;\n this.show();\n }\n\n private onMouseLeave(): void {\n this.isHovered = false;\n this.hide();\n }\n\n private onTouchStart(): void {\n // On touch devices a tooltip is not useful and would obscure the content the\n // user just tapped. Reset the hover/focus state so it is hidden immediately.\n this.isFocused = false;\n this.isHovered = false;\n this.hide();\n }\n\n private getOrCreateOverlay(): OverlayRef {\n this.overlayRef ??= getOverlay(\n this.config.element,\n this.config.overlay,\n false,\n this.config.placement,\n false,\n true,\n this.config.scrollStrategy?.()\n );\n return this.overlayRef;\n }\n\n private show(): void {\n const overlayRef = this.getOrCreateOverlay();\n if (overlayRef.hasAttached()) {\n return;\n }\n\n const injector = Injector.create({\n parent: this.config.injector,\n providers: [{ provide: OverlayRef, useValue: overlayRef }]\n });\n\n const toolTipPortal = new ComponentPortal(TooltipComponent, undefined, injector);\n const tooltipRef: ComponentRef<TooltipComponent> = overlayRef.attach(toolTipPortal);\n\n const positionStrategy = getPositionStrategy(overlayRef);\n this.positionSubscription?.unsubscribe();\n this.positionSubscription = positionStrategy?.positionChanges.subscribe(change =>\n tooltipRef.instance.updateTooltipPosition(change, this.config.element)\n );\n }\n\n private hide(): void {\n if (this.isFocused || this.isHovered) {\n return;\n }\n this.overlayRef?.detach();\n this.positionSubscription?.unsubscribe();\n }\n\n destroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n this.overlayRef?.dispose();\n this.positionSubscription?.unsubscribe();\n }\n}\n\n/**\n * A service to create tooltips for specific elements.\n * Use this if the tooltip directive is not suitable.\n * Must not be used outside element-ng.\n *\n * @internal\n */\n// We cannot provide this in root, as people may override the cdk overlay creation.\n@Injectable()\nexport class SiTooltipService {\n private overlay = inject(Overlay);\n private isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n createTooltip(config: {\n describedBy?: string;\n element: ElementRef;\n placement: keyof typeof positions;\n injector?: Injector;\n tooltip: () => SiTooltipContent;\n tooltipContext: () => unknown;\n scrollStrategy?: () => ScrollStrategy | undefined;\n }): TooltipRef {\n if (!this.isBrowser) {\n return new NoopTooltipRef();\n }\n\n const injector = Injector.create({\n parent: config.injector,\n providers: [\n {\n provide: SI_TOOLTIP_CONFIG,\n useValue: {\n id: config.describedBy,\n tooltip: config.tooltip,\n tooltipContext: config.tooltipContext\n }\n }\n ]\n });\n\n return new BrowserTooltipRef({\n ...config,\n injector,\n overlay: this.overlay\n });\n }\n}\n\nexport type { TooltipRef };\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { ScrollStrategy } from '@angular/cdk/overlay';\nimport {\n booleanAttribute,\n Directive,\n effect,\n ElementRef,\n inject,\n input,\n OnDestroy,\n TemplateRef\n} from '@angular/core';\nimport { positions } from '@siemens/element-ng/common';\nimport { TranslatableString } from '@siemens/element-translate-ng/translate';\n\nimport { SiTooltipService, TooltipRef } from './si-tooltip.service';\n\n@Directive({\n selector: '[siTooltip]',\n providers: [SiTooltipService],\n host: {\n '[attr.aria-describedby]': 'isDisabled() ? null : describedBy'\n }\n})\nexport class SiTooltipDirective implements OnDestroy {\n private static idCounter = 0;\n\n /**\n * The tooltip text to be displayed\n *\n * @defaultValue ''\n */\n readonly siTooltip = input<TranslatableString | TemplateRef<any>>('');\n\n /**\n * The placement of the tooltip. One of 'top', 'start', end', 'bottom'\n *\n * @defaultValue 'auto'\n */\n readonly placement = input<keyof typeof positions>('auto');\n\n /**\n * Allows the tooltip to be disabled\n *\n * @defaultValue false\n */\n readonly isDisabled = input(false, { transform: booleanAttribute });\n\n /**\n * Optional CDK scroll strategy used for the tooltip overlay.\n * If not provided, the default reposition strategy is used.\n */\n readonly tooltipScrollStrategy = input<ScrollStrategy>();\n\n /**\n * The context for the attached template\n */\n readonly tooltipContext = input();\n\n protected describedBy = `__tooltip_${SiTooltipDirective.idCounter++}`;\n\n private tooltipRef?: TooltipRef;\n private tooltipService = inject(SiTooltipService);\n private elementRef = inject(ElementRef);\n\n constructor() {\n effect(() => {\n const tooltip = this.siTooltip();\n const disabled = this.isDisabled();\n\n if (tooltip && !disabled) {\n this.tooltipRef ??= this.tooltipService.createTooltip({\n describedBy: this.describedBy,\n element: this.elementRef,\n placement: this.placement(),\n tooltip: this.siTooltip,\n tooltipContext: this.tooltipContext,\n scrollStrategy: this.tooltipScrollStrategy\n });\n } else if (this.tooltipRef) {\n this.tooltipRef.destroy();\n this.tooltipRef = undefined;\n }\n });\n }\n\n ngOnDestroy(): void {\n this.tooltipRef?.destroy();\n }\n}\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nimport { NgModule } from '@angular/core';\n\nimport { SiTooltipDirective } from './si-tooltip.directive';\n\n@NgModule({\n imports: [SiTooltipDirective],\n exports: [SiTooltipDirective]\n})\nexport class SiTooltipModule {}\n","/**\n * Copyright (c) Siemens 2016 - 2026\n * SPDX-License-Identifier: MIT\n */\nexport * from './si-tooltip.module';\nexport * from './si-tooltip.directive';\nexport * from './si-tooltip.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;AAGG;AAkBI,MAAM,iBAAiB,GAAG,IAAI,cAAc,CAAkB,iBAAiB,CAAC;;ACrBvF;;;AAGG;MA4BU,gBAAgB,CAAA;AACR,IAAA,oBAAoB,GAAG,MAAM,CAAC,EAAE,gEAAC;AACjC,IAAA,QAAQ,GAAG,MAAM,CAAmC,SAAS,oDAAC;AAE9D,IAAA,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;AACpC,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAC/B,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAExC,IAAA,kBAAkB;AAClB,IAAA,UAAU;AAElB,IAAA,WAAA,GAAA;QACE,IAAI,UAAU,GAAG,IAAI;QACrB,iBAAiB,CAAC,MAAK;AACrB,YAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACrB,YAAA,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;YAC5B,IAAI,UAAU,EAAE;gBACd,UAAU,GAAG,KAAK;gBAClB;YACF;AACA,YAAA,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE;AAChC,YAAA,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBAC3B,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI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A,EALlB,CAAC,gBAAgB,CAAC,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAKlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAP9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,aAAa;oBACvB,SAAS,EAAE,CAAC,gBAAgB,CAAC;AAC7B,oBAAA,IAAI,EAAE;AACJ,wBAAA,yBAAyB,EAAE;AAC5B;AACF,iBAAA;;;AC1BD;;;AAGG;MASU,eAAe,CAAA;uGAAf,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;wGAAf,eAAe,EAAA,OAAA,EAAA,CAHhB,kBAAkB,CAAA,EAAA,OAAA,EAAA,CAClB,kBAAkB,CAAA,EAAA,CAAA;wGAEjB,eAAe,EAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,kBAAkB,CAAC;oBAC7B,OAAO,EAAE,CAAC,kBAAkB;AAC7B,iBAAA;;;ACXD;;;AAGG;;ACHH;;AAEG;;;;"}
|
|
@@ -65,6 +65,7 @@ class SiTourComponent {
|
|
|
65
65
|
elementRef = inject(ElementRef);
|
|
66
66
|
subscription;
|
|
67
67
|
prevFocus = null;
|
|
68
|
+
lastPositionChange;
|
|
68
69
|
focusTrap = viewChild('focusTrap', ...(ngDevMode ? [{ debugName: "focusTrap" }] : []));
|
|
69
70
|
document = inject(DOCUMENT);
|
|
70
71
|
constructor() {
|
|
@@ -78,6 +79,7 @@ class SiTourComponent {
|
|
|
78
79
|
}, 50);
|
|
79
80
|
});
|
|
80
81
|
this.subscription.add(this.tourToken.positionChange.subscribe(update => this.updatePosition(update)));
|
|
82
|
+
this.subscription.add(this.tourToken.sizeChange.subscribe(() => this.updatePosition(this.lastPositionChange)));
|
|
81
83
|
}
|
|
82
84
|
ngOnDestroy() {
|
|
83
85
|
this.subscription?.unsubscribe();
|
|
@@ -112,6 +114,7 @@ class SiTourComponent {
|
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
updatePosition(update) {
|
|
117
|
+
this.lastPositionChange = update;
|
|
115
118
|
if (!update) {
|
|
116
119
|
this.positionClass.set('');
|
|
117
120
|
this.arrowPos.set(undefined);
|
|
@@ -316,11 +319,11 @@ class SiTourService {
|
|
|
316
319
|
{ originX: 'start', overlayX: 'end', originY: 'center', overlayY: 'center' },
|
|
317
320
|
{ originX: 'end', overlayX: 'start', originY: 'center', overlayY: 'center' }
|
|
318
321
|
]);
|
|
319
|
-
this.overlayRef.updatePositionStrategy(positionStrategy);
|
|
320
322
|
this.positionChangeSub = positionStrategy.positionChanges
|
|
321
323
|
.pipe(map(change => ({ change, anchor })))
|
|
322
324
|
// We only want to forward the next channel, as the positionChanges completes when setting a new origin.
|
|
323
325
|
.subscribe(value => this.tourToken.positionChange.next(value));
|
|
326
|
+
this.overlayRef.updatePositionStrategy(positionStrategy);
|
|
324
327
|
}
|
|
325
328
|
createOrUpdateOverlays() {
|
|
326
329
|
if (this.overlayRef) {
|