@anguless/angulux 22.6.3 → 22.6.5
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/anguless-angulux-button.mjs +4 -1
- package/fesm2022/anguless-angulux-button.mjs.map +1 -1
- package/fesm2022/anguless-angulux-confirmdialog.mjs +2 -0
- package/fesm2022/anguless-angulux-confirmdialog.mjs.map +1 -1
- package/fesm2022/anguless-angulux-datepicker.mjs +17 -3
- package/fesm2022/anguless-angulux-datepicker.mjs.map +1 -1
- package/fesm2022/anguless-angulux-dialog.mjs +10 -2
- package/fesm2022/anguless-angulux-dialog.mjs.map +1 -1
- package/fesm2022/anguless-angulux-dom.mjs +9 -1
- package/fesm2022/anguless-angulux-dom.mjs.map +1 -1
- package/fesm2022/anguless-angulux-drawer.mjs +5 -1
- package/fesm2022/anguless-angulux-drawer.mjs.map +1 -1
- package/fesm2022/anguless-angulux-menu.mjs +4 -1
- package/fesm2022/anguless-angulux-menu.mjs.map +1 -1
- package/fesm2022/anguless-angulux-message.mjs +5 -2
- package/fesm2022/anguless-angulux-message.mjs.map +1 -1
- package/fesm2022/anguless-angulux-multiselect.mjs +8 -5
- package/fesm2022/anguless-angulux-multiselect.mjs.map +1 -1
- package/fesm2022/anguless-angulux-overlay.mjs +11 -1
- package/fesm2022/anguless-angulux-overlay.mjs.map +1 -1
- package/fesm2022/anguless-angulux-paginator.mjs +6 -6
- package/fesm2022/anguless-angulux-paginator.mjs.map +1 -1
- package/fesm2022/anguless-angulux-select.mjs +169 -37
- package/fesm2022/anguless-angulux-select.mjs.map +1 -1
- package/fesm2022/anguless-angulux-selectbutton.mjs +2 -2
- package/fesm2022/anguless-angulux-selectbutton.mjs.map +1 -1
- package/fesm2022/anguless-angulux-table.mjs +36 -19
- package/fesm2022/anguless-angulux-table.mjs.map +1 -1
- package/fesm2022/anguless-angulux-tabs.mjs +7 -1
- package/fesm2022/anguless-angulux-tabs.mjs.map +1 -1
- package/fesm2022/anguless-angulux-tooltip.mjs +231 -46
- package/fesm2022/anguless-angulux-tooltip.mjs.map +1 -1
- package/fesm2022/anguless-angulux-treetable.mjs +4 -4
- package/fesm2022/anguless-angulux-treetable.mjs.map +1 -1
- package/package.json +1 -1
- package/types/anguless-angulux-dialog.d.ts +6 -0
- package/types/anguless-angulux-select.d.ts +28 -3
- package/types/anguless-angulux-table.d.ts +9 -0
- package/types/anguless-angulux-tooltip.d.ts +74 -18
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isPlatformBrowser } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { Injectable, InjectionToken, inject, input, computed, effect, booleanAttribute, numberAttribute, Input, Directive, NgModule } from '@angular/core';
|
|
4
|
-
import { uuid, hasClass, createElement, appendChild,
|
|
5
|
-
import { BaseComponent
|
|
4
|
+
import { uuid, hasClass, createElement, appendChild, getFocusableElements, getWindowScrollLeft, getWindowScrollTop, findSingle, getOuterWidth, getOuterHeight, getViewport, removeChild } from '@anguless/angulux-utils';
|
|
5
|
+
import { BaseComponent } from '@anguless/angulux/basecomponent';
|
|
6
6
|
import { BindModule } from '@anguless/angulux/bind';
|
|
7
7
|
import { ConnectedOverlayScrollHandler } from '@anguless/angulux/dom';
|
|
8
8
|
import { ZIndexUtils } from '@anguless/angulux/utils';
|
|
@@ -48,6 +48,32 @@ var TooltipClasses;
|
|
|
48
48
|
})(TooltipClasses || (TooltipClasses = {}));
|
|
49
49
|
|
|
50
50
|
const TOOLTIP_INSTANCE = new InjectionToken('TOOLTIP_INSTANCE');
|
|
51
|
+
/** The options a tooltip starts with. An option set to `undefined` goes back to its value here. */
|
|
52
|
+
const TOOLTIP_DEFAULTS = {
|
|
53
|
+
tooltipLabel: null,
|
|
54
|
+
tooltipPosition: 'right',
|
|
55
|
+
tooltipEvent: 'hover',
|
|
56
|
+
appendTo: 'body',
|
|
57
|
+
positionStyle: null,
|
|
58
|
+
tooltipStyleClass: null,
|
|
59
|
+
tooltipZIndex: 'auto',
|
|
60
|
+
escape: true,
|
|
61
|
+
disabled: null,
|
|
62
|
+
showDelay: null,
|
|
63
|
+
hideDelay: null,
|
|
64
|
+
positionTop: null,
|
|
65
|
+
positionLeft: null,
|
|
66
|
+
life: null,
|
|
67
|
+
autoHide: true,
|
|
68
|
+
hideOnEscape: true,
|
|
69
|
+
showOnEllipsis: false
|
|
70
|
+
};
|
|
71
|
+
/** Length of the fade-in, in milliseconds. */
|
|
72
|
+
const FADE_DURATION = 250;
|
|
73
|
+
/** Whether the user asked the system to reduce motion. */
|
|
74
|
+
function prefersReducedMotion() {
|
|
75
|
+
return typeof window !== 'undefined' && !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
76
|
+
}
|
|
51
77
|
/**
|
|
52
78
|
* Tooltip directive provides advisory information for a component.
|
|
53
79
|
* @group Components
|
|
@@ -164,25 +190,18 @@ class Tooltip extends BaseComponent {
|
|
|
164
190
|
$appendTo = computed(() => this.appendTo() || this.config.overlayAppendTo(), /* @ts-ignore */
|
|
165
191
|
...(ngDevMode ? [{ debugName: "$appendTo" }] : /* istanbul ignore next */ []));
|
|
166
192
|
_tooltipOptions = {
|
|
167
|
-
|
|
168
|
-
tooltipPosition: 'right',
|
|
169
|
-
tooltipEvent: 'hover',
|
|
170
|
-
appendTo: 'body',
|
|
171
|
-
positionStyle: null,
|
|
172
|
-
tooltipStyleClass: null,
|
|
173
|
-
tooltipZIndex: 'auto',
|
|
174
|
-
escape: true,
|
|
175
|
-
disabled: null,
|
|
176
|
-
showDelay: null,
|
|
177
|
-
hideDelay: null,
|
|
178
|
-
positionTop: null,
|
|
179
|
-
positionLeft: null,
|
|
180
|
-
life: null,
|
|
181
|
-
autoHide: true,
|
|
182
|
-
hideOnEscape: true,
|
|
183
|
-
showOnEllipsis: false,
|
|
193
|
+
...TOOLTIP_DEFAULTS,
|
|
184
194
|
id: uuid('pn_id_') + '_tooltip'
|
|
185
195
|
};
|
|
196
|
+
/** The element `aria-describedby` was set on while the tooltip shows, so hiding can take it off. */
|
|
197
|
+
describedElement = null;
|
|
198
|
+
/** The pending frame of the fade-in, cancelled when the tooltip is removed. */
|
|
199
|
+
fadeFrame = null;
|
|
200
|
+
/** The pending wait for a dialog's opening animation, so a tooltip removed meanwhile is not shown. */
|
|
201
|
+
showToken = 0;
|
|
202
|
+
targetKeydownListener;
|
|
203
|
+
containerKeydownListener;
|
|
204
|
+
containerFocusoutListener;
|
|
186
205
|
_disabled;
|
|
187
206
|
container;
|
|
188
207
|
styleClass;
|
|
@@ -259,10 +278,7 @@ class Tooltip extends BaseComponent {
|
|
|
259
278
|
if (tooltipEvent === 'focus' || tooltipEvent === 'both') {
|
|
260
279
|
this.focusListener = this.onFocus.bind(this);
|
|
261
280
|
this.blurListener = this.onBlur.bind(this);
|
|
262
|
-
|
|
263
|
-
if (!target) {
|
|
264
|
-
target = this.getTarget(this.el.nativeElement);
|
|
265
|
-
}
|
|
281
|
+
const target = this.describedTarget;
|
|
266
282
|
target.addEventListener('focus', this.focusListener);
|
|
267
283
|
target.addEventListener('blur', this.blurListener);
|
|
268
284
|
}
|
|
@@ -336,7 +352,7 @@ class Tooltip extends BaseComponent {
|
|
|
336
352
|
this.setOption({ id: simpleChange.id.currentValue });
|
|
337
353
|
}
|
|
338
354
|
if (simpleChange.tooltipOptions) {
|
|
339
|
-
this.
|
|
355
|
+
this.setOption(simpleChange.tooltipOptions.currentValue ?? {});
|
|
340
356
|
this.deactivate();
|
|
341
357
|
if (this.active) {
|
|
342
358
|
if (this.getOption('tooltipLabel')) {
|
|
@@ -404,6 +420,10 @@ class Tooltip extends BaseComponent {
|
|
|
404
420
|
this.activate();
|
|
405
421
|
}
|
|
406
422
|
onBlur(e) {
|
|
423
|
+
// Focus moving into a persistent tooltip stays with it, so its links can be reached by Tab.
|
|
424
|
+
const to = e?.relatedTarget;
|
|
425
|
+
if (this.container && to instanceof Node && this.container.contains(to))
|
|
426
|
+
return;
|
|
407
427
|
this.deactivate();
|
|
408
428
|
}
|
|
409
429
|
onInputClick(e) {
|
|
@@ -434,8 +454,12 @@ class Tooltip extends BaseComponent {
|
|
|
434
454
|
}
|
|
435
455
|
if (this.getOption('hideOnEscape')) {
|
|
436
456
|
this.documentEscapeListener = this.renderer.listen('document', 'keydown.escape', () => {
|
|
457
|
+
// Escape from inside a persistent tooltip returns focus to the target it belongs to.
|
|
458
|
+
const returnFocus = !!this.container?.contains(document.activeElement);
|
|
459
|
+
const target = this.describedTarget;
|
|
437
460
|
this.deactivate();
|
|
438
461
|
this.documentEscapeListener?.();
|
|
462
|
+
returnFocus && target.focus();
|
|
439
463
|
});
|
|
440
464
|
}
|
|
441
465
|
this.interactionInProgress = true;
|
|
@@ -465,6 +489,7 @@ class Tooltip extends BaseComponent {
|
|
|
465
489
|
}
|
|
466
490
|
this.container = createElement('div', { class: this.cx('root'), 'p-bind': this.ptm('root'), 'data-pc-section': 'root' });
|
|
467
491
|
this.container.setAttribute('role', 'tooltip');
|
|
492
|
+
this.container.setAttribute('id', this.getOption('id'));
|
|
468
493
|
let tooltipArrow = createElement('div', { class: this.cx('arrow'), 'p-bind': this.ptm('arrow'), 'data-pc-section': 'arrow' });
|
|
469
494
|
this.container.appendChild(tooltipArrow);
|
|
470
495
|
this.tooltipText = createElement('div', { class: this.cx('text'), 'p-bind': this.ptm('text'), 'data-pc-section': 'text' });
|
|
@@ -501,7 +526,9 @@ class Tooltip extends BaseComponent {
|
|
|
501
526
|
}
|
|
502
527
|
unbindContainerMouseleaveListener() {
|
|
503
528
|
if (this.containerMouseleaveListener) {
|
|
504
|
-
|
|
529
|
+
// This called bindContainerMouseleaveListener(), which does nothing while a listener is
|
|
530
|
+
// bound, so the listener was never removed (upstream 22.1.5).
|
|
531
|
+
this.containerMouseleaveListener();
|
|
505
532
|
this.containerMouseleaveListener = null;
|
|
506
533
|
}
|
|
507
534
|
}
|
|
@@ -510,26 +537,160 @@ class Tooltip extends BaseComponent {
|
|
|
510
537
|
return;
|
|
511
538
|
}
|
|
512
539
|
this.create();
|
|
513
|
-
const
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
this.container && (this.container.style.display = 'inline-block');
|
|
518
|
-
this.container && this.align();
|
|
519
|
-
}, 100);
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
540
|
+
const token = ++this.showToken;
|
|
541
|
+
const reveal = () => {
|
|
542
|
+
if (token !== this.showToken || !this.container)
|
|
543
|
+
return;
|
|
522
544
|
this.container.style.display = 'inline-block';
|
|
523
545
|
this.align();
|
|
524
|
-
|
|
525
|
-
|
|
546
|
+
this.fadeIn();
|
|
547
|
+
};
|
|
548
|
+
const opening = this.openingDialogAnimations();
|
|
549
|
+
if (opening.length)
|
|
550
|
+
Promise.all(opening.map((a) => a.finished)).then(reveal, reveal);
|
|
551
|
+
else
|
|
552
|
+
reveal();
|
|
526
553
|
if (this.getOption('tooltipZIndex') === 'auto')
|
|
527
554
|
ZIndexUtils.set('tooltip', this.container, this.config.zIndex.tooltip);
|
|
528
555
|
else
|
|
529
556
|
this.container.style.zIndex = this.getOption('tooltipZIndex');
|
|
557
|
+
this.describe();
|
|
558
|
+
this.bindKeyboardListeners();
|
|
530
559
|
this.bindDocumentResizeListener();
|
|
531
560
|
this.bindScrollListener();
|
|
532
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* The animations still running on the dialog around the target. While a dialog opens, its
|
|
564
|
+
* animation moves the target, so the tooltip waits for it before measuring. It used to wait a
|
|
565
|
+
* fixed 100 ms inside any dialog, opening or long open, and start its fade at once, so it
|
|
566
|
+
* appeared late and already 40% opaque (upstream 22.1.5).
|
|
567
|
+
*/
|
|
568
|
+
openingDialogAnimations() {
|
|
569
|
+
const dialog = this.el.nativeElement.closest('.p-dialog');
|
|
570
|
+
if (!dialog || typeof dialog.getAnimations !== 'function')
|
|
571
|
+
return [];
|
|
572
|
+
return dialog.getAnimations().filter((a) => a.playState === 'running' && a.effect?.getComputedTiming().endTime !== Infinity);
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Fade the tooltip in, unless the user asked the system to reduce motion. The frame is kept, so
|
|
576
|
+
* removing the tooltip cancels the fade: the shared fadeIn() helper kept writing opacity to the
|
|
577
|
+
* removed element until it reached 1, and ignored reduced motion (upstream 22.1.5).
|
|
578
|
+
*/
|
|
579
|
+
fadeIn() {
|
|
580
|
+
this.cancelFade();
|
|
581
|
+
const el = this.container;
|
|
582
|
+
if (!el || prefersReducedMotion())
|
|
583
|
+
return;
|
|
584
|
+
el.style.opacity = '0';
|
|
585
|
+
let last = performance.now();
|
|
586
|
+
const tick = () => {
|
|
587
|
+
this.fadeFrame = null;
|
|
588
|
+
if (this.container !== el)
|
|
589
|
+
return;
|
|
590
|
+
const now = performance.now();
|
|
591
|
+
const opacity = Math.min(1, Number(el.style.opacity) + (now - last) / FADE_DURATION);
|
|
592
|
+
el.style.opacity = String(opacity);
|
|
593
|
+
last = now;
|
|
594
|
+
if (opacity < 1)
|
|
595
|
+
this.fadeFrame = requestAnimationFrame(tick);
|
|
596
|
+
};
|
|
597
|
+
this.zone.runOutsideAngular(() => (this.fadeFrame = requestAnimationFrame(tick)));
|
|
598
|
+
}
|
|
599
|
+
cancelFade() {
|
|
600
|
+
if (this.fadeFrame !== null) {
|
|
601
|
+
cancelAnimationFrame(this.fadeFrame);
|
|
602
|
+
this.fadeFrame = null;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* The element the tooltip listens on for focus and describes: the focusable root of a component
|
|
607
|
+
* host, or the target itself (an input inside an input wrapper).
|
|
608
|
+
*/
|
|
609
|
+
get describedTarget() {
|
|
610
|
+
const host = this.el.nativeElement;
|
|
611
|
+
return host.querySelector('.p-component') ?? this.getTarget(host);
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Link the target to the tooltip while it shows (WAI-ARIA tooltip pattern). The tooltip had an id
|
|
615
|
+
* option and never used it, so assistive technology had no way to tie the two (upstream 22.1.5).
|
|
616
|
+
* Ids the author put in aria-describedby are kept.
|
|
617
|
+
*/
|
|
618
|
+
describe() {
|
|
619
|
+
const target = this.describedTarget;
|
|
620
|
+
const id = this.getOption('id');
|
|
621
|
+
const ids = (target.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean);
|
|
622
|
+
if (!ids.includes(id))
|
|
623
|
+
target.setAttribute('aria-describedby', [...ids, id].join(' '));
|
|
624
|
+
this.describedElement = target;
|
|
625
|
+
}
|
|
626
|
+
undescribe() {
|
|
627
|
+
const target = this.describedElement;
|
|
628
|
+
if (!target)
|
|
629
|
+
return;
|
|
630
|
+
const id = this.container?.id || this.getOption('id');
|
|
631
|
+
const ids = (target.getAttribute('aria-describedby') ?? '').split(/\s+/).filter((t) => t && t !== id);
|
|
632
|
+
if (ids.length)
|
|
633
|
+
target.setAttribute('aria-describedby', ids.join(' '));
|
|
634
|
+
else
|
|
635
|
+
target.removeAttribute('aria-describedby');
|
|
636
|
+
this.describedElement = null;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* A persistent tooltip (autoHide false) can hold links. Tab from the target moves into it, Tab
|
|
640
|
+
* past its last focusable element leaves it for whatever follows the target, and Shift+Tab from
|
|
641
|
+
* its first goes back to the target. Appended to the body, it sat at the end of the tab order,
|
|
642
|
+
* and the target's blur hid it before focus could arrive (upstream 22.1.5).
|
|
643
|
+
*/
|
|
644
|
+
bindKeyboardListeners() {
|
|
645
|
+
if (this.isAutoHide() || !this.container)
|
|
646
|
+
return;
|
|
647
|
+
const target = this.describedTarget;
|
|
648
|
+
const container = this.container;
|
|
649
|
+
this.targetKeydownListener = this.renderer.listen(target, 'keydown', (e) => {
|
|
650
|
+
if (e.key !== 'Tab' || e.shiftKey)
|
|
651
|
+
return;
|
|
652
|
+
const first = this.focusablesInside()[0];
|
|
653
|
+
if (first) {
|
|
654
|
+
e.preventDefault();
|
|
655
|
+
first.focus();
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
this.containerKeydownListener = this.renderer.listen(container, 'keydown', (e) => {
|
|
659
|
+
if (e.key !== 'Tab')
|
|
660
|
+
return;
|
|
661
|
+
const inside = this.focusablesInside();
|
|
662
|
+
const index = inside.indexOf(document.activeElement);
|
|
663
|
+
if (e.shiftKey && index === 0) {
|
|
664
|
+
e.preventDefault();
|
|
665
|
+
target.focus();
|
|
666
|
+
}
|
|
667
|
+
else if (!e.shiftKey && index === inside.length - 1) {
|
|
668
|
+
e.preventDefault();
|
|
669
|
+
const after = this.focusableAfter(target);
|
|
670
|
+
this.deactivate();
|
|
671
|
+
after?.focus();
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
this.containerFocusoutListener = this.renderer.listen(container, 'focusout', (e) => {
|
|
675
|
+
const to = e.relatedTarget;
|
|
676
|
+
if (!to || (!container.contains(to) && !target.contains(to)))
|
|
677
|
+
this.deactivate();
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
unbindKeyboardListeners() {
|
|
681
|
+
this.targetKeydownListener?.();
|
|
682
|
+
this.containerKeydownListener?.();
|
|
683
|
+
this.containerFocusoutListener?.();
|
|
684
|
+
this.targetKeydownListener = this.containerKeydownListener = this.containerFocusoutListener = null;
|
|
685
|
+
}
|
|
686
|
+
focusablesInside() {
|
|
687
|
+
return this.container ? getFocusableElements(this.container) : [];
|
|
688
|
+
}
|
|
689
|
+
/** The first focusable element after the target in document order, outside the target and the tooltip. */
|
|
690
|
+
focusableAfter(target) {
|
|
691
|
+
const all = getFocusableElements(document.body);
|
|
692
|
+
return all.find((el) => !target.contains(el) && !this.container?.contains(el) && !!(target.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING)) ?? null;
|
|
693
|
+
}
|
|
533
694
|
hide() {
|
|
534
695
|
if (this.getOption('tooltipZIndex') === 'auto') {
|
|
535
696
|
ZIndexUtils.clear(this.container);
|
|
@@ -544,8 +705,10 @@ class Tooltip extends BaseComponent {
|
|
|
544
705
|
embeddedViewRef.rootNodes.forEach((node) => this.tooltipText.appendChild(node));
|
|
545
706
|
}
|
|
546
707
|
else if (this.getOption('escape')) {
|
|
547
|
-
|
|
548
|
-
|
|
708
|
+
// textContent, not innerHTML: under require-trusted-types-for even an empty string needs
|
|
709
|
+
// TrustedHTML, so every tooltip threw in such an app (upstream 22.1.5). With escape false
|
|
710
|
+
// the content is HTML by request, and a TrustedHTML value from the app's policy works.
|
|
711
|
+
this.tooltipText.textContent = content;
|
|
549
712
|
}
|
|
550
713
|
else {
|
|
551
714
|
this.tooltipText.innerHTML = content;
|
|
@@ -654,8 +817,17 @@ class Tooltip extends BaseComponent {
|
|
|
654
817
|
this.container.style.left = left + this.getOption('positionLeft') + 'px';
|
|
655
818
|
this.container.style.top = top + this.getOption('positionTop') + 'px';
|
|
656
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Merge options in. An option given as `undefined` goes back to its default rather than becoming
|
|
822
|
+
* undefined: `[tooltipPosition]="maybe"` or `tooltipOptions: { tooltipPosition: undefined }` left the
|
|
823
|
+
* tooltip with no position at all, drawn at the left edge of the page (upstream 22.1.5).
|
|
824
|
+
*/
|
|
657
825
|
setOption(option) {
|
|
658
|
-
|
|
826
|
+
const next = { ...this._tooltipOptions };
|
|
827
|
+
for (const [key, value] of Object.entries(option ?? {})) {
|
|
828
|
+
next[key] = value === undefined ? (key === 'id' ? this._tooltipOptions.id : TOOLTIP_DEFAULTS[key]) : value;
|
|
829
|
+
}
|
|
830
|
+
this._tooltipOptions = next;
|
|
659
831
|
}
|
|
660
832
|
getOption(option) {
|
|
661
833
|
return this._tooltipOptions[option];
|
|
@@ -663,10 +835,13 @@ class Tooltip extends BaseComponent {
|
|
|
663
835
|
getTarget(el) {
|
|
664
836
|
return hasClass(el, 'p-inputwrapper') ? findSingle(el, 'input') : el;
|
|
665
837
|
}
|
|
838
|
+
/** The width the tooltip takes with room to spare, measured off-screen before each placement. */
|
|
839
|
+
naturalWidth = 0;
|
|
666
840
|
preAlign(position) {
|
|
667
841
|
this.container.style.left = -999 + 'px';
|
|
668
842
|
this.container.style.top = -999 + 'px';
|
|
669
843
|
this.container.className = this.cn(this.cx('root'), this.ptm('root')?.class, 'p-tooltip-' + position, this.getOption('tooltipStyleClass'));
|
|
844
|
+
this.naturalWidth = getOuterWidth(this.container);
|
|
670
845
|
}
|
|
671
846
|
isOutOfBounds() {
|
|
672
847
|
let offset = this.container.getBoundingClientRect();
|
|
@@ -675,7 +850,12 @@ class Tooltip extends BaseComponent {
|
|
|
675
850
|
let width = getOuterWidth(this.container);
|
|
676
851
|
let height = getOuterHeight(this.container);
|
|
677
852
|
let viewport = getViewport();
|
|
678
|
-
|
|
853
|
+
// A tooltip placed against the edge of the page does not overflow it: it shrinks, down to a
|
|
854
|
+
// word per line, so it still looked in bounds and the next position was never tried (measured
|
|
855
|
+
// 2026-11-17 beside a menu as wide as the page). Narrower than its natural width means it
|
|
856
|
+
// does not fit there.
|
|
857
|
+
const squeezed = width < this.naturalWidth - 1;
|
|
858
|
+
return squeezed || targetLeft + width > viewport.width || targetLeft < 0 || targetTop < 0 || targetTop + height > viewport.height;
|
|
679
859
|
}
|
|
680
860
|
onWindowResize(e) {
|
|
681
861
|
this.hide();
|
|
@@ -719,16 +899,17 @@ class Tooltip extends BaseComponent {
|
|
|
719
899
|
this.unbindDocumentTouchListener();
|
|
720
900
|
}
|
|
721
901
|
if (tooltipEvent === 'focus' || tooltipEvent === 'both') {
|
|
722
|
-
|
|
723
|
-
if (!target) {
|
|
724
|
-
target = this.getTarget(this.el.nativeElement);
|
|
725
|
-
}
|
|
902
|
+
const target = this.describedTarget;
|
|
726
903
|
target.removeEventListener('focus', this.focusListener);
|
|
727
904
|
target.removeEventListener('blur', this.blurListener);
|
|
728
905
|
}
|
|
729
906
|
this.unbindDocumentResizeListener();
|
|
730
907
|
}
|
|
731
908
|
remove() {
|
|
909
|
+
this.showToken++;
|
|
910
|
+
this.cancelFade();
|
|
911
|
+
this.undescribe();
|
|
912
|
+
this.unbindKeyboardListeners();
|
|
732
913
|
if (this.container && this.container.parentElement) {
|
|
733
914
|
if (this.getOption('appendTo') === 'body')
|
|
734
915
|
document.body.removeChild(this.container);
|
|
@@ -776,14 +957,18 @@ class Tooltip extends BaseComponent {
|
|
|
776
957
|
}
|
|
777
958
|
}
|
|
778
959
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.2", ngImport: i0, type: Tooltip, deps: [{ token: i0.NgZone }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
779
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.2", type: Tooltip, isStandalone: true, selector: "[aglTooltip]", inputs: { tooltipPosition: { classPropertyName: "tooltipPosition", publicName: "tooltipPosition", isSignal: false, isRequired: false, transformFunction: null }, tooltipEvent: { classPropertyName: "tooltipEvent", publicName: "tooltipEvent", isSignal: false, isRequired: false, transformFunction: null }, positionStyle: { classPropertyName: "positionStyle", publicName: "positionStyle", isSignal: false, isRequired: false, transformFunction: null }, tooltipStyleClass: { classPropertyName: "tooltipStyleClass", publicName: "tooltipStyleClass", isSignal: false, isRequired: false, transformFunction: null }, tooltipZIndex: { classPropertyName: "tooltipZIndex", publicName: "tooltipZIndex", isSignal: false, isRequired: false, transformFunction: null }, escape: { classPropertyName: "escape", publicName: "escape", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: false, isRequired: false, transformFunction: numberAttribute }, hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: false, isRequired: false, transformFunction: numberAttribute }, life: { classPropertyName: "life", publicName: "life", isSignal: false, isRequired: false, transformFunction: numberAttribute }, positionTop: { classPropertyName: "positionTop", publicName: "positionTop", isSignal: false, isRequired: false, transformFunction: numberAttribute }, positionLeft: { classPropertyName: "positionLeft", publicName: "positionLeft", isSignal: false, isRequired: false, transformFunction: numberAttribute }, autoHide: { classPropertyName: "autoHide", publicName: "autoHide", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, fitContent: { classPropertyName: "fitContent", publicName: "fitContent", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, hideOnEscape: { classPropertyName: "hideOnEscape", publicName: "hideOnEscape", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, showOnEllipsis: { classPropertyName: "showOnEllipsis", publicName: "showOnEllipsis", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, content: { classPropertyName: "content", publicName: "aglTooltip", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "tooltipDisabled", isSignal: false, isRequired: false, transformFunction: null }, tooltipOptions: { classPropertyName: "tooltipOptions", publicName: "tooltipOptions", isSignal: false, isRequired: false, transformFunction: null }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: true, isRequired: false, transformFunction: null }, ptTooltip: { classPropertyName: "ptTooltip", publicName: "ptTooltip", isSignal: true, isRequired: false, transformFunction: null }, pTooltipPT: { classPropertyName: "pTooltipPT", publicName: "pTooltipPT", isSignal: true, isRequired: false, transformFunction: null }, pTooltipUnstyled: { classPropertyName: "pTooltipUnstyled", publicName: "pTooltipUnstyled", isSignal: true, isRequired: false, transformFunction: null } }, providers: [TooltipStyle, { provide: TOOLTIP_INSTANCE, useExisting: Tooltip }
|
|
960
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.2", type: Tooltip, isStandalone: true, selector: "[aglTooltip]", inputs: { tooltipPosition: { classPropertyName: "tooltipPosition", publicName: "tooltipPosition", isSignal: false, isRequired: false, transformFunction: null }, tooltipEvent: { classPropertyName: "tooltipEvent", publicName: "tooltipEvent", isSignal: false, isRequired: false, transformFunction: null }, positionStyle: { classPropertyName: "positionStyle", publicName: "positionStyle", isSignal: false, isRequired: false, transformFunction: null }, tooltipStyleClass: { classPropertyName: "tooltipStyleClass", publicName: "tooltipStyleClass", isSignal: false, isRequired: false, transformFunction: null }, tooltipZIndex: { classPropertyName: "tooltipZIndex", publicName: "tooltipZIndex", isSignal: false, isRequired: false, transformFunction: null }, escape: { classPropertyName: "escape", publicName: "escape", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: false, isRequired: false, transformFunction: numberAttribute }, hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: false, isRequired: false, transformFunction: numberAttribute }, life: { classPropertyName: "life", publicName: "life", isSignal: false, isRequired: false, transformFunction: numberAttribute }, positionTop: { classPropertyName: "positionTop", publicName: "positionTop", isSignal: false, isRequired: false, transformFunction: numberAttribute }, positionLeft: { classPropertyName: "positionLeft", publicName: "positionLeft", isSignal: false, isRequired: false, transformFunction: numberAttribute }, autoHide: { classPropertyName: "autoHide", publicName: "autoHide", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, fitContent: { classPropertyName: "fitContent", publicName: "fitContent", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, hideOnEscape: { classPropertyName: "hideOnEscape", publicName: "hideOnEscape", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, showOnEllipsis: { classPropertyName: "showOnEllipsis", publicName: "showOnEllipsis", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, content: { classPropertyName: "content", publicName: "aglTooltip", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "tooltipDisabled", isSignal: false, isRequired: false, transformFunction: null }, tooltipOptions: { classPropertyName: "tooltipOptions", publicName: "tooltipOptions", isSignal: false, isRequired: false, transformFunction: null }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: true, isRequired: false, transformFunction: null }, ptTooltip: { classPropertyName: "ptTooltip", publicName: "ptTooltip", isSignal: true, isRequired: false, transformFunction: null }, pTooltipPT: { classPropertyName: "pTooltipPT", publicName: "pTooltipPT", isSignal: true, isRequired: false, transformFunction: null }, pTooltipUnstyled: { classPropertyName: "pTooltipUnstyled", publicName: "pTooltipUnstyled", isSignal: true, isRequired: false, transformFunction: null } }, providers: [TooltipStyle, { provide: TOOLTIP_INSTANCE, useExisting: Tooltip }], usesInheritance: true, ngImport: i0 });
|
|
780
961
|
}
|
|
781
962
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.2", ngImport: i0, type: Tooltip, decorators: [{
|
|
782
963
|
type: Directive,
|
|
783
964
|
args: [{
|
|
784
965
|
selector: '[aglTooltip]',
|
|
785
966
|
standalone: true,
|
|
786
|
-
|
|
967
|
+
// No PARENT_INSTANCE here. A directive on a component host that provided it would stand in for
|
|
968
|
+
// that component as the parent of everything inside it: an InputIcon in an IconField carrying
|
|
969
|
+
// a tooltip found the Tooltip as its parent instead of the IconField (upstream 22.1.5, measured
|
|
970
|
+
// 2026-11-17 in e2e/upstream-repro-22-1-5.spec.ts).
|
|
971
|
+
providers: [TooltipStyle, { provide: TOOLTIP_INSTANCE, useExisting: Tooltip }]
|
|
787
972
|
}]
|
|
788
973
|
}], ctorParameters: () => [{ type: i0.NgZone }, { type: i0.ViewContainerRef }], propDecorators: { tooltipPosition: [{
|
|
789
974
|
type: Input
|