@shival99/z-ui 2.0.51 → 2.0.53
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/shival99-z-ui-components-z-autocomplete.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-calendar.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-calendar.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-editor.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-editor.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-filter.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-filter.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-input.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-input.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-kanban.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-kanban.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-media-player.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-media-player.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-menu.mjs +2 -2
- package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-pagination.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-pagination.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-popover.mjs +449 -33
- package/fesm2022/shival99-z-ui-components-z-popover.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-select.mjs +40 -15
- package/fesm2022/shival99-z-ui-components-z-select.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-table.mjs +5 -5
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-utils.mjs +15 -1
- package/fesm2022/shival99-z-ui-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shival99-z-ui-components-z-calendar.d.ts +4 -4
- package/types/shival99-z-ui-components-z-modal.d.ts +1 -1
- package/types/shival99-z-ui-components-z-popover.d.ts +51 -3
- package/types/shival99-z-ui-components-z-select.d.ts +4 -4
- package/types/shival99-z-ui-components-z-table.d.ts +1 -1
- package/types/shival99-z-ui-utils.d.ts +2 -1
|
@@ -5,7 +5,7 @@ import * as i0 from '@angular/core';
|
|
|
5
5
|
import { signal, computed, ChangeDetectionStrategy, Component, inject, Renderer2, DestroyRef, PLATFORM_ID, viewChild, output, input, ElementRef, Directive } from '@angular/core';
|
|
6
6
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
7
|
import { ZOverlayContainerService } from '@shival99/z-ui/services';
|
|
8
|
-
import { zMergeClasses, zTransform } from '@shival99/z-ui/utils';
|
|
8
|
+
import { zMergeClasses, zIsMobileViewport, zTransform } from '@shival99/z-ui/utils';
|
|
9
9
|
import { Subject, switchMap, of, timer, map, filter } from 'rxjs';
|
|
10
10
|
import { cva } from 'class-variance-authority';
|
|
11
11
|
|
|
@@ -184,6 +184,96 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
|
|
|
184
184
|
}]
|
|
185
185
|
}] });
|
|
186
186
|
|
|
187
|
+
const Z_POPOVER_MOBILE_VIEWPORT_MARGIN = 10;
|
|
188
|
+
function isMobilePopoverViewport() {
|
|
189
|
+
return zIsMobileViewport();
|
|
190
|
+
}
|
|
191
|
+
function getPopoverOverlaySize(widthConfig = {}) {
|
|
192
|
+
return widthConfig;
|
|
193
|
+
}
|
|
194
|
+
function getPopoverRenderPosition(position, _mobile = isMobilePopoverViewport()) {
|
|
195
|
+
return position;
|
|
196
|
+
}
|
|
197
|
+
function getMobilePopoverFallbackPositions(position, offset) {
|
|
198
|
+
return getPopoverFallbackPositions(position, offset).map(pos => ({
|
|
199
|
+
...pos,
|
|
200
|
+
offsetX: pos.offsetX ?? 0,
|
|
201
|
+
offsetY: pos.offsetY ?? 0,
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
function clampPopoverPosition(value, min, max) {
|
|
205
|
+
return Math.min(Math.max(value, min), max);
|
|
206
|
+
}
|
|
207
|
+
function getAlignedX(position, triggerRect, overlayRect) {
|
|
208
|
+
if (position === 'left' || position.startsWith('left-')) {
|
|
209
|
+
return triggerRect.left - overlayRect.width;
|
|
210
|
+
}
|
|
211
|
+
if (position === 'right' || position.startsWith('right-')) {
|
|
212
|
+
return triggerRect.right;
|
|
213
|
+
}
|
|
214
|
+
if (position.endsWith('-right')) {
|
|
215
|
+
return triggerRect.right - overlayRect.width;
|
|
216
|
+
}
|
|
217
|
+
if (position === 'top' || position === 'bottom') {
|
|
218
|
+
return triggerRect.left + triggerRect.width / 2 - overlayRect.width / 2;
|
|
219
|
+
}
|
|
220
|
+
return triggerRect.left;
|
|
221
|
+
}
|
|
222
|
+
function getAlignedY(position, triggerRect, overlayRect) {
|
|
223
|
+
if (position === 'top' || position.startsWith('top-')) {
|
|
224
|
+
return triggerRect.top - overlayRect.height;
|
|
225
|
+
}
|
|
226
|
+
if (position === 'bottom' || position.startsWith('bottom-')) {
|
|
227
|
+
return triggerRect.bottom;
|
|
228
|
+
}
|
|
229
|
+
if (position.endsWith('-bottom')) {
|
|
230
|
+
return triggerRect.bottom - overlayRect.height;
|
|
231
|
+
}
|
|
232
|
+
if (position === 'left' || position === 'right') {
|
|
233
|
+
return triggerRect.top + triggerRect.height / 2 - overlayRect.height / 2;
|
|
234
|
+
}
|
|
235
|
+
return triggerRect.top;
|
|
236
|
+
}
|
|
237
|
+
function getMobilePopoverPaneStyles(config) {
|
|
238
|
+
const { position, triggerRect, overlayRect, offset, viewportWidth } = config;
|
|
239
|
+
const viewportMargin = config.viewportMargin ?? Z_POPOVER_MOBILE_VIEWPORT_MARGIN;
|
|
240
|
+
const maxLeft = Math.max(viewportMargin, viewportWidth - overlayRect.width - viewportMargin);
|
|
241
|
+
let left = getAlignedX(position, triggerRect, overlayRect);
|
|
242
|
+
let top = getAlignedY(position, triggerRect, overlayRect);
|
|
243
|
+
if (position === 'top' || position.startsWith('top-')) {
|
|
244
|
+
top -= offset;
|
|
245
|
+
}
|
|
246
|
+
if (position === 'bottom' || position.startsWith('bottom-')) {
|
|
247
|
+
top += offset;
|
|
248
|
+
}
|
|
249
|
+
if (position === 'left' || position.startsWith('left-')) {
|
|
250
|
+
left -= offset;
|
|
251
|
+
}
|
|
252
|
+
if (position === 'right' || position.startsWith('right-')) {
|
|
253
|
+
left += offset;
|
|
254
|
+
}
|
|
255
|
+
left = clampPopoverPosition(left, viewportMargin, maxLeft);
|
|
256
|
+
return {
|
|
257
|
+
top: `${top}px`,
|
|
258
|
+
left: `${left}px`,
|
|
259
|
+
right: '',
|
|
260
|
+
bottom: '',
|
|
261
|
+
transform: 'none',
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function getPopoverPushEnabled(_mobile = isMobilePopoverViewport()) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
function isPopoverTriggerVisibleInViewport(config) {
|
|
268
|
+
const { triggerRect, viewportWidth, viewportHeight } = config;
|
|
269
|
+
if (triggerRect.width <= 0 || triggerRect.height <= 0) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
return (triggerRect.bottom > 0 &&
|
|
273
|
+
triggerRect.top < viewportHeight &&
|
|
274
|
+
triggerRect.right > 0 &&
|
|
275
|
+
triggerRect.left < viewportWidth);
|
|
276
|
+
}
|
|
187
277
|
function createPopoverPosition(position, offset) {
|
|
188
278
|
const positions = {
|
|
189
279
|
top: {
|
|
@@ -292,12 +382,16 @@ function getPopoverFallbackPositions(position, offset) {
|
|
|
292
382
|
return orderedPositions.map(pos => createPopoverPosition(pos, offset));
|
|
293
383
|
}
|
|
294
384
|
function createPopoverPositionStrategy(overlayPositionBuilder, origin, position, offset) {
|
|
385
|
+
const mobile = isMobilePopoverViewport();
|
|
386
|
+
const positions = mobile
|
|
387
|
+
? getMobilePopoverFallbackPositions(position, offset)
|
|
388
|
+
: getPopoverFallbackPositions(position, offset);
|
|
295
389
|
return overlayPositionBuilder
|
|
296
390
|
.flexibleConnectedTo(origin)
|
|
297
|
-
.withPositions(
|
|
391
|
+
.withPositions(positions)
|
|
298
392
|
.withFlexibleDimensions(false)
|
|
299
|
-
.withPush(
|
|
300
|
-
.withViewportMargin(
|
|
393
|
+
.withPush(getPopoverPushEnabled(mobile))
|
|
394
|
+
.withViewportMargin(10);
|
|
301
395
|
}
|
|
302
396
|
function getActualPopoverPosition(change) {
|
|
303
397
|
const { originX, originY, overlayX, overlayY } = change.connectionPair;
|
|
@@ -367,15 +461,21 @@ class ZPopoverComponent {
|
|
|
367
461
|
zManualClose = input(false, { ...(ngDevMode ? { debugName: "zManualClose" } : {}), transform: zTransform });
|
|
368
462
|
zOutsideClickClose = input(false, { ...(ngDevMode ? { debugName: "zOutsideClickClose" } : {}), transform: zTransform });
|
|
369
463
|
zScrollClose = input(false, { ...(ngDevMode ? { debugName: "zScrollClose" } : {}), transform: zTransform });
|
|
464
|
+
zSticky = input(false, { ...(ngDevMode ? { debugName: "zSticky" } : {}), transform: zTransform });
|
|
370
465
|
zShowArrow = input(false, { ...(ngDevMode ? { debugName: "zShowArrow" } : {}), transform: zTransform });
|
|
466
|
+
zKeyboardSafe = input(false, { ...(ngDevMode ? { debugName: "zKeyboardSafe" } : {}), transform: zTransform });
|
|
371
467
|
_overlayRef = null;
|
|
372
468
|
_componentRef = null;
|
|
373
469
|
_delaySubject = new Subject();
|
|
374
470
|
_listenerCleanups = [];
|
|
375
471
|
_positionSubscription = null;
|
|
376
472
|
_scrollSubscription = null;
|
|
473
|
+
_viewportResizeSubscription = null;
|
|
377
474
|
_resizeObserver = null;
|
|
378
475
|
_hideTimeout = null;
|
|
476
|
+
_viewportResizeTimeouts = [];
|
|
477
|
+
_positionFrame = null;
|
|
478
|
+
_viewportSettlingUntil = 0;
|
|
379
479
|
_isVisible = signal(false, ...(ngDevMode ? [{ debugName: "_isVisible" }] : []));
|
|
380
480
|
ngOnInit() {
|
|
381
481
|
if (!isPlatformBrowser(this._platformId)) {
|
|
@@ -445,26 +545,38 @@ class ZPopoverComponent {
|
|
|
445
545
|
if (!this._isVisible()) {
|
|
446
546
|
return;
|
|
447
547
|
}
|
|
448
|
-
this.
|
|
548
|
+
this._schedulePositionUpdate();
|
|
449
549
|
}
|
|
450
550
|
_createOverlay() {
|
|
451
551
|
const positionStrategy = createPopoverPositionStrategy(this._overlayPositionBuilder, this._trigger(), this.zPosition(), this.zOffset());
|
|
452
|
-
const scrollStrategy = this.zScrollClose()
|
|
453
|
-
? this._overlay.scrollStrategies.close()
|
|
454
|
-
: this._overlay.scrollStrategies.reposition({ scrollThrottle: 10, autoClose: false });
|
|
455
552
|
return this._overlay.create({
|
|
456
553
|
positionStrategy,
|
|
457
|
-
scrollStrategy,
|
|
554
|
+
scrollStrategy: this._createScrollStrategy(),
|
|
458
555
|
hasBackdrop: false,
|
|
556
|
+
...getPopoverOverlaySize(),
|
|
459
557
|
});
|
|
460
558
|
}
|
|
559
|
+
_createScrollStrategy() {
|
|
560
|
+
if (this.zScrollClose()) {
|
|
561
|
+
return this._overlay.scrollStrategies.close();
|
|
562
|
+
}
|
|
563
|
+
if (isMobilePopoverViewport() && (this.zSticky() || this.zKeyboardSafe())) {
|
|
564
|
+
return this._overlay.scrollStrategies.noop();
|
|
565
|
+
}
|
|
566
|
+
return this._overlay.scrollStrategies.reposition({ scrollThrottle: 10, autoClose: false });
|
|
567
|
+
}
|
|
461
568
|
_disposeOverlay() {
|
|
462
569
|
this._positionSubscription?.unsubscribe();
|
|
463
570
|
this._positionSubscription = null;
|
|
464
571
|
this._scrollSubscription?.unsubscribe();
|
|
465
572
|
this._scrollSubscription = null;
|
|
573
|
+
this._viewportResizeSubscription?.unsubscribe();
|
|
574
|
+
this._viewportResizeSubscription = null;
|
|
575
|
+
this._clearViewportResizeTimeout();
|
|
576
|
+
this._viewportSettlingUntil = 0;
|
|
466
577
|
this._resizeObserver?.disconnect();
|
|
467
578
|
this._resizeObserver = null;
|
|
579
|
+
this._cancelScheduledPositionUpdate();
|
|
468
580
|
this._overlayRef?.dispose();
|
|
469
581
|
this._overlayRef = null;
|
|
470
582
|
this._componentRef = null;
|
|
@@ -540,9 +652,18 @@ class ZPopoverComponent {
|
|
|
540
652
|
if (ticking) {
|
|
541
653
|
return;
|
|
542
654
|
}
|
|
655
|
+
if (this._shouldDeferForMobileKeyboard()) {
|
|
656
|
+
this._markViewportSettling();
|
|
657
|
+
this._scheduleSettledPositionUpdate();
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
543
660
|
ticking = true;
|
|
544
661
|
requestAnimationFrame(() => {
|
|
545
|
-
this.
|
|
662
|
+
if (this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
663
|
+
ticking = false;
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
this._updatePositionNow();
|
|
546
667
|
ticking = false;
|
|
547
668
|
});
|
|
548
669
|
};
|
|
@@ -553,6 +674,30 @@ class ZPopoverComponent {
|
|
|
553
674
|
},
|
|
554
675
|
};
|
|
555
676
|
}
|
|
677
|
+
_setupViewportResizeReposition() {
|
|
678
|
+
this._viewportResizeSubscription?.unsubscribe();
|
|
679
|
+
this._clearViewportResizeTimeout();
|
|
680
|
+
const onResize = () => {
|
|
681
|
+
if (!this._overlayRef?.hasAttached()) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
if (this._shouldDeferForMobileKeyboard()) {
|
|
685
|
+
this._markViewportSettling();
|
|
686
|
+
this._scheduleSettledPositionUpdate();
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
this._schedulePositionUpdate();
|
|
690
|
+
};
|
|
691
|
+
window.addEventListener('resize', onResize);
|
|
692
|
+
window.visualViewport?.addEventListener('resize', onResize);
|
|
693
|
+
this._viewportResizeSubscription = {
|
|
694
|
+
unsubscribe: () => {
|
|
695
|
+
window.removeEventListener('resize', onResize);
|
|
696
|
+
window.visualViewport?.removeEventListener('resize', onResize);
|
|
697
|
+
this._clearViewportResizeTimeout();
|
|
698
|
+
},
|
|
699
|
+
};
|
|
700
|
+
}
|
|
556
701
|
_showPopover() {
|
|
557
702
|
const content = this.zContent();
|
|
558
703
|
if (!content || this._componentRef) {
|
|
@@ -565,11 +710,13 @@ class ZPopoverComponent {
|
|
|
565
710
|
this._setupScrollClose();
|
|
566
711
|
const positionStrategy = createPopoverPositionStrategy(this._overlayPositionBuilder, this._trigger(), this.zPosition(), this.zOffset());
|
|
567
712
|
this._overlayRef.updatePositionStrategy(positionStrategy);
|
|
713
|
+
this._overlayRef.updateSize(getPopoverOverlaySize());
|
|
568
714
|
const portal = new ComponentPortal(ZPopoverContentComponent);
|
|
569
715
|
this._componentRef = this._overlayRef.attach(portal);
|
|
716
|
+
const renderPosition = getPopoverRenderPosition(this.zPosition());
|
|
570
717
|
this._componentRef.instance.setProps({
|
|
571
718
|
content,
|
|
572
|
-
position:
|
|
719
|
+
position: renderPosition,
|
|
573
720
|
customClass: this.zClass(),
|
|
574
721
|
onClose: () => this.hide(),
|
|
575
722
|
showArrow: this.zShowArrow(),
|
|
@@ -577,11 +724,14 @@ class ZPopoverComponent {
|
|
|
577
724
|
this._positionSubscription = positionStrategy.positionChanges.subscribe(change => {
|
|
578
725
|
const actualPosition = getActualPopoverPosition(change);
|
|
579
726
|
this._componentRef?.instance.position.set(actualPosition);
|
|
727
|
+
this._applyMobilePopoverPosition(actualPosition);
|
|
580
728
|
});
|
|
581
729
|
if (this.zTrigger() === 'hover') {
|
|
582
730
|
this._setupPopoverHover();
|
|
583
731
|
}
|
|
584
732
|
this._setupResizeObserver();
|
|
733
|
+
this._setupViewportResizeReposition();
|
|
734
|
+
this._updatePositionAfterContentSettles();
|
|
585
735
|
this._isVisible.set(true);
|
|
586
736
|
ZPopoverComponent._openPopovers.add(this);
|
|
587
737
|
this.zShow.emit();
|
|
@@ -609,7 +759,7 @@ class ZPopoverComponent {
|
|
|
609
759
|
this._resizeObserver?.disconnect();
|
|
610
760
|
this._resizeObserver = new ResizeObserver(() => {
|
|
611
761
|
if (this._overlayRef && this._isVisible()) {
|
|
612
|
-
this.
|
|
762
|
+
this._schedulePositionUpdate();
|
|
613
763
|
}
|
|
614
764
|
});
|
|
615
765
|
this._resizeObserver.observe(this._trigger().nativeElement);
|
|
@@ -618,6 +768,112 @@ class ZPopoverComponent {
|
|
|
618
768
|
this._resizeObserver.observe(wrapper);
|
|
619
769
|
}
|
|
620
770
|
}
|
|
771
|
+
_updatePositionAfterContentSettles() {
|
|
772
|
+
this._schedulePositionUpdate();
|
|
773
|
+
}
|
|
774
|
+
_schedulePositionUpdate(force = false) {
|
|
775
|
+
if (this._positionFrame !== null) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
this._positionFrame = requestAnimationFrame(() => {
|
|
779
|
+
this._positionFrame = null;
|
|
780
|
+
this._updatePositionNow(force);
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
_scheduleSettledPositionUpdate() {
|
|
784
|
+
this._clearViewportResizeTimeout();
|
|
785
|
+
for (const delay of [80, 180, 320]) {
|
|
786
|
+
const timeout = setTimeout(() => {
|
|
787
|
+
this._viewportResizeTimeouts = this._viewportResizeTimeouts.filter(item => item !== timeout);
|
|
788
|
+
this._schedulePositionUpdate(true);
|
|
789
|
+
}, delay);
|
|
790
|
+
this._viewportResizeTimeouts.push(timeout);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
_cancelScheduledPositionUpdate() {
|
|
794
|
+
if (this._positionFrame === null) {
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
cancelAnimationFrame(this._positionFrame);
|
|
798
|
+
this._positionFrame = null;
|
|
799
|
+
}
|
|
800
|
+
_updatePositionNow(force = false) {
|
|
801
|
+
if (!this._overlayRef?.hasAttached()) {
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
if (isMobilePopoverViewport() && this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
if (!force && this._shouldSkipMobileKeyboardUpdate()) {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
this._overlayRef.updatePosition();
|
|
811
|
+
this._applyMobilePopoverPosition(this._componentRef?.instance.position() ?? this.zPosition());
|
|
812
|
+
}
|
|
813
|
+
_markViewportSettling() {
|
|
814
|
+
this._viewportSettlingUntil = Date.now() + 260;
|
|
815
|
+
}
|
|
816
|
+
_shouldDeferForMobileKeyboard() {
|
|
817
|
+
return this._isMobileOverlayTextInputFocused();
|
|
818
|
+
}
|
|
819
|
+
_shouldSkipMobileKeyboardUpdate() {
|
|
820
|
+
if (!this._isMobileOverlayTextInputFocused()) {
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
return Date.now() < this._viewportSettlingUntil;
|
|
824
|
+
}
|
|
825
|
+
_isMobileOverlayTextInputFocused() {
|
|
826
|
+
if (!this.zKeyboardSafe() || !isMobilePopoverViewport()) {
|
|
827
|
+
return false;
|
|
828
|
+
}
|
|
829
|
+
const { activeElement } = this._document;
|
|
830
|
+
if (!(activeElement instanceof HTMLElement)) {
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
const overlayElement = this._overlayRef?.overlayElement;
|
|
834
|
+
if (!overlayElement?.contains(activeElement)) {
|
|
835
|
+
return false;
|
|
836
|
+
}
|
|
837
|
+
if (activeElement.isContentEditable) {
|
|
838
|
+
return true;
|
|
839
|
+
}
|
|
840
|
+
return activeElement.matches('input, textarea, select');
|
|
841
|
+
}
|
|
842
|
+
_clearViewportResizeTimeout() {
|
|
843
|
+
for (const timeout of this._viewportResizeTimeouts) {
|
|
844
|
+
clearTimeout(timeout);
|
|
845
|
+
}
|
|
846
|
+
this._viewportResizeTimeouts = [];
|
|
847
|
+
}
|
|
848
|
+
_applyMobilePopoverPosition(position) {
|
|
849
|
+
if (!isMobilePopoverViewport() || !this._overlayRef?.hasAttached()) {
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
const { overlayElement } = this._overlayRef;
|
|
853
|
+
const { visualViewport } = window;
|
|
854
|
+
const styles = getMobilePopoverPaneStyles({
|
|
855
|
+
position,
|
|
856
|
+
triggerRect: this._trigger().nativeElement.getBoundingClientRect(),
|
|
857
|
+
overlayRect: overlayElement.getBoundingClientRect(),
|
|
858
|
+
offset: this.zOffset(),
|
|
859
|
+
viewportWidth: visualViewport?.width ?? window.innerWidth,
|
|
860
|
+
viewportHeight: visualViewport?.height ?? window.innerHeight,
|
|
861
|
+
});
|
|
862
|
+
this._setOverlayPaneStyles(styles);
|
|
863
|
+
}
|
|
864
|
+
_isTriggerVisibleInViewport() {
|
|
865
|
+
const { visualViewport } = window;
|
|
866
|
+
return isPopoverTriggerVisibleInViewport({
|
|
867
|
+
triggerRect: this._trigger().nativeElement.getBoundingClientRect(),
|
|
868
|
+
viewportWidth: visualViewport?.width ?? window.innerWidth,
|
|
869
|
+
viewportHeight: visualViewport?.height ?? window.innerHeight,
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
_setOverlayPaneStyles(styles) {
|
|
873
|
+
for (const key of ['top', 'left', 'right', 'bottom', 'transform']) {
|
|
874
|
+
this._renderer.setStyle(this._overlayRef?.overlayElement, key, styles[key]);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
621
877
|
_setupPopoverHover() {
|
|
622
878
|
const overlayElement = this._overlayRef?.overlayElement;
|
|
623
879
|
if (!overlayElement) {
|
|
@@ -662,7 +918,7 @@ class ZPopoverComponent {
|
|
|
662
918
|
this._listenerCleanups = [];
|
|
663
919
|
}
|
|
664
920
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZPopoverComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
665
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.0.9", type: ZPopoverComponent, isStandalone: true, selector: "z-popover", inputs: { zContent: { classPropertyName: "zContent", publicName: "zContent", isSignal: true, isRequired: false, transformFunction: null }, zPosition: { classPropertyName: "zPosition", publicName: "zPosition", isSignal: true, isRequired: false, transformFunction: null }, zTrigger: { classPropertyName: "zTrigger", publicName: "zTrigger", isSignal: true, isRequired: false, transformFunction: null }, zClass: { classPropertyName: "zClass", publicName: "zClass", isSignal: true, isRequired: false, transformFunction: null }, zShowDelay: { classPropertyName: "zShowDelay", publicName: "zShowDelay", isSignal: true, isRequired: false, transformFunction: null }, zHideDelay: { classPropertyName: "zHideDelay", publicName: "zHideDelay", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zOffset: { classPropertyName: "zOffset", publicName: "zOffset", isSignal: true, isRequired: false, transformFunction: null }, zManualClose: { classPropertyName: "zManualClose", publicName: "zManualClose", isSignal: true, isRequired: false, transformFunction: null }, zOutsideClickClose: { classPropertyName: "zOutsideClickClose", publicName: "zOutsideClickClose", isSignal: true, isRequired: false, transformFunction: null }, zScrollClose: { classPropertyName: "zScrollClose", publicName: "zScrollClose", isSignal: true, isRequired: false, transformFunction: null }, zShowArrow: { classPropertyName: "zShowArrow", publicName: "zShowArrow", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zShow: "zShow", zHide: "zHide", zControl: "zControl", zOutsideClick: "zOutsideClick" }, host: { classAttribute: "inline-block" }, viewQueries: [{ propertyName: "_trigger", first: true, predicate: ["trigger"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
921
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.0.9", type: ZPopoverComponent, isStandalone: true, selector: "z-popover", inputs: { zContent: { classPropertyName: "zContent", publicName: "zContent", isSignal: true, isRequired: false, transformFunction: null }, zPosition: { classPropertyName: "zPosition", publicName: "zPosition", isSignal: true, isRequired: false, transformFunction: null }, zTrigger: { classPropertyName: "zTrigger", publicName: "zTrigger", isSignal: true, isRequired: false, transformFunction: null }, zClass: { classPropertyName: "zClass", publicName: "zClass", isSignal: true, isRequired: false, transformFunction: null }, zShowDelay: { classPropertyName: "zShowDelay", publicName: "zShowDelay", isSignal: true, isRequired: false, transformFunction: null }, zHideDelay: { classPropertyName: "zHideDelay", publicName: "zHideDelay", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zOffset: { classPropertyName: "zOffset", publicName: "zOffset", isSignal: true, isRequired: false, transformFunction: null }, zManualClose: { classPropertyName: "zManualClose", publicName: "zManualClose", isSignal: true, isRequired: false, transformFunction: null }, zOutsideClickClose: { classPropertyName: "zOutsideClickClose", publicName: "zOutsideClickClose", isSignal: true, isRequired: false, transformFunction: null }, zScrollClose: { classPropertyName: "zScrollClose", publicName: "zScrollClose", isSignal: true, isRequired: false, transformFunction: null }, zSticky: { classPropertyName: "zSticky", publicName: "zSticky", isSignal: true, isRequired: false, transformFunction: null }, zShowArrow: { classPropertyName: "zShowArrow", publicName: "zShowArrow", isSignal: true, isRequired: false, transformFunction: null }, zKeyboardSafe: { classPropertyName: "zKeyboardSafe", publicName: "zKeyboardSafe", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zShow: "zShow", zHide: "zHide", zControl: "zControl", zOutsideClick: "zOutsideClick" }, host: { classAttribute: "inline-block" }, viewQueries: [{ propertyName: "_trigger", first: true, predicate: ["trigger"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
666
922
|
<span #trigger class="z-popover-trigger inline-block">
|
|
667
923
|
<ng-content />
|
|
668
924
|
</span>
|
|
@@ -683,7 +939,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
|
|
|
683
939
|
class: 'inline-block',
|
|
684
940
|
},
|
|
685
941
|
}]
|
|
686
|
-
}], propDecorators: { _trigger: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }], zShow: [{ type: i0.Output, args: ["zShow"] }], zHide: [{ type: i0.Output, args: ["zHide"] }], zControl: [{ type: i0.Output, args: ["zControl"] }], zOutsideClick: [{ type: i0.Output, args: ["zOutsideClick"] }], zContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "zContent", required: false }] }], zPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPosition", required: false }] }], zTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTrigger", required: false }] }], zClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "zClass", required: false }] }], zShowDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowDelay", required: false }] }], zHideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zHideDelay", required: false }] }], zDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDisabled", required: false }] }], zOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOffset", required: false }] }], zManualClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zManualClose", required: false }] }], zOutsideClickClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOutsideClickClose", required: false }] }], zScrollClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zScrollClose", required: false }] }], zShowArrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowArrow", required: false }] }] } });
|
|
942
|
+
}], propDecorators: { _trigger: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }], zShow: [{ type: i0.Output, args: ["zShow"] }], zHide: [{ type: i0.Output, args: ["zHide"] }], zControl: [{ type: i0.Output, args: ["zControl"] }], zOutsideClick: [{ type: i0.Output, args: ["zOutsideClick"] }], zContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "zContent", required: false }] }], zPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPosition", required: false }] }], zTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTrigger", required: false }] }], zClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "zClass", required: false }] }], zShowDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowDelay", required: false }] }], zHideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zHideDelay", required: false }] }], zDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDisabled", required: false }] }], zOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOffset", required: false }] }], zManualClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zManualClose", required: false }] }], zOutsideClickClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOutsideClickClose", required: false }] }], zScrollClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zScrollClose", required: false }] }], zSticky: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSticky", required: false }] }], zShowArrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowArrow", required: false }] }], zKeyboardSafe: [{ type: i0.Input, args: [{ isSignal: true, alias: "zKeyboardSafe", required: false }] }] } });
|
|
687
943
|
|
|
688
944
|
class ZPopoverDirective {
|
|
689
945
|
static _openPopovers = new Set();
|
|
@@ -701,7 +957,9 @@ class ZPopoverDirective {
|
|
|
701
957
|
zManualClose = input(false, { ...(ngDevMode ? { debugName: "zManualClose" } : {}), transform: zTransform });
|
|
702
958
|
zOutsideClickClose = input(false, { ...(ngDevMode ? { debugName: "zOutsideClickClose" } : {}), transform: zTransform });
|
|
703
959
|
zScrollClose = input(false, { ...(ngDevMode ? { debugName: "zScrollClose" } : {}), transform: zTransform });
|
|
960
|
+
zSticky = input(false, { ...(ngDevMode ? { debugName: "zSticky" } : {}), transform: zTransform });
|
|
704
961
|
zShowArrow = input(false, { ...(ngDevMode ? { debugName: "zShowArrow" } : {}), transform: zTransform });
|
|
962
|
+
zKeyboardSafe = input(false, { ...(ngDevMode ? { debugName: "zKeyboardSafe" } : {}), transform: zTransform });
|
|
705
963
|
zShow = output();
|
|
706
964
|
zHide = output();
|
|
707
965
|
zHideStart = output();
|
|
@@ -723,8 +981,12 @@ class ZPopoverDirective {
|
|
|
723
981
|
_listenerCleanups = [];
|
|
724
982
|
_positionSubscription = null;
|
|
725
983
|
_scrollSubscription = null;
|
|
984
|
+
_viewportResizeSubscription = null;
|
|
726
985
|
_resizeObserver = null;
|
|
727
986
|
_hideTimeout = null;
|
|
987
|
+
_viewportResizeTimeouts = [];
|
|
988
|
+
_positionFrame = null;
|
|
989
|
+
_viewportSettlingUntil = 0;
|
|
728
990
|
_isDestroyed = signal(false, ...(ngDevMode ? [{ debugName: "_isDestroyed" }] : []));
|
|
729
991
|
_isVisible = signal(false, ...(ngDevMode ? [{ debugName: "_isVisible" }] : []));
|
|
730
992
|
ngOnInit() {
|
|
@@ -803,35 +1065,37 @@ class ZPopoverDirective {
|
|
|
803
1065
|
if (!this._isVisible()) {
|
|
804
1066
|
return;
|
|
805
1067
|
}
|
|
806
|
-
this.
|
|
807
|
-
const widthConfig = this._getWidthConfig();
|
|
808
|
-
if (widthConfig.width) {
|
|
809
|
-
this._overlayRef?.updateSize({ width: widthConfig.width, minWidth: widthConfig.minWidth });
|
|
810
|
-
}
|
|
1068
|
+
this._schedulePositionUpdate();
|
|
811
1069
|
}
|
|
812
1070
|
_createOverlay() {
|
|
813
1071
|
const positionStrategy = createPopoverPositionStrategy(this._overlayPositionBuilder, this._getTriggerElement(), this.zPosition(), this.zOffset());
|
|
814
1072
|
const widthConfig = this._getWidthConfig();
|
|
815
|
-
const scrollStrategy = this.zScrollClose()
|
|
816
|
-
? this._overlay.scrollStrategies.close()
|
|
817
|
-
: this._overlay.scrollStrategies.reposition();
|
|
818
1073
|
return this._overlay.create({
|
|
819
1074
|
positionStrategy,
|
|
820
|
-
scrollStrategy,
|
|
1075
|
+
scrollStrategy: this._createScrollStrategy(),
|
|
821
1076
|
hasBackdrop: false,
|
|
822
1077
|
...widthConfig,
|
|
823
1078
|
});
|
|
824
1079
|
}
|
|
1080
|
+
_createScrollStrategy() {
|
|
1081
|
+
if (this.zScrollClose()) {
|
|
1082
|
+
return this._overlay.scrollStrategies.close();
|
|
1083
|
+
}
|
|
1084
|
+
if (isMobilePopoverViewport() && (this.zSticky() || this.zKeyboardSafe())) {
|
|
1085
|
+
return this._overlay.scrollStrategies.noop();
|
|
1086
|
+
}
|
|
1087
|
+
return this._overlay.scrollStrategies.reposition();
|
|
1088
|
+
}
|
|
825
1089
|
_getWidthConfig() {
|
|
826
1090
|
const width = this.zPopoverWidth();
|
|
827
1091
|
if (width === 'auto') {
|
|
828
|
-
return
|
|
1092
|
+
return getPopoverOverlaySize();
|
|
829
1093
|
}
|
|
830
1094
|
if (width === 'trigger') {
|
|
831
1095
|
const triggerWidth = this._getTriggerElement().getBoundingClientRect().width;
|
|
832
|
-
return { width: `${triggerWidth}px`, minWidth: `${triggerWidth}px` };
|
|
1096
|
+
return getPopoverOverlaySize({ width: `${triggerWidth}px`, minWidth: `${triggerWidth}px` });
|
|
833
1097
|
}
|
|
834
|
-
return { width, minWidth: width };
|
|
1098
|
+
return getPopoverOverlaySize({ width, minWidth: width });
|
|
835
1099
|
}
|
|
836
1100
|
_getTriggerElement() {
|
|
837
1101
|
const triggerRef = this.zTriggerRef();
|
|
@@ -845,8 +1109,13 @@ class ZPopoverDirective {
|
|
|
845
1109
|
this._positionSubscription = null;
|
|
846
1110
|
this._scrollSubscription?.unsubscribe();
|
|
847
1111
|
this._scrollSubscription = null;
|
|
1112
|
+
this._viewportResizeSubscription?.unsubscribe();
|
|
1113
|
+
this._viewportResizeSubscription = null;
|
|
1114
|
+
this._clearViewportResizeTimeout();
|
|
1115
|
+
this._viewportSettlingUntil = 0;
|
|
848
1116
|
this._resizeObserver?.disconnect();
|
|
849
1117
|
this._resizeObserver = null;
|
|
1118
|
+
this._cancelScheduledPositionUpdate();
|
|
850
1119
|
this._overlayRef?.dispose();
|
|
851
1120
|
this._overlayRef = null;
|
|
852
1121
|
this._componentRef = null;
|
|
@@ -934,9 +1203,18 @@ class ZPopoverDirective {
|
|
|
934
1203
|
if (ticking) {
|
|
935
1204
|
return;
|
|
936
1205
|
}
|
|
1206
|
+
if (this._shouldDeferForMobileKeyboard()) {
|
|
1207
|
+
this._markViewportSettling();
|
|
1208
|
+
this._scheduleSettledPositionUpdate();
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
937
1211
|
ticking = true;
|
|
938
1212
|
requestAnimationFrame(() => {
|
|
939
|
-
this.
|
|
1213
|
+
if (this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
1214
|
+
ticking = false;
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
this._updatePositionNow();
|
|
940
1218
|
ticking = false;
|
|
941
1219
|
});
|
|
942
1220
|
};
|
|
@@ -947,6 +1225,30 @@ class ZPopoverDirective {
|
|
|
947
1225
|
},
|
|
948
1226
|
};
|
|
949
1227
|
}
|
|
1228
|
+
_setupViewportResizeReposition() {
|
|
1229
|
+
this._viewportResizeSubscription?.unsubscribe();
|
|
1230
|
+
this._clearViewportResizeTimeout();
|
|
1231
|
+
const onResize = () => {
|
|
1232
|
+
if (!this._overlayRef?.hasAttached()) {
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
if (this._shouldDeferForMobileKeyboard()) {
|
|
1236
|
+
this._markViewportSettling();
|
|
1237
|
+
this._scheduleSettledPositionUpdate();
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
this._schedulePositionUpdate();
|
|
1241
|
+
};
|
|
1242
|
+
window.addEventListener('resize', onResize);
|
|
1243
|
+
window.visualViewport?.addEventListener('resize', onResize);
|
|
1244
|
+
this._viewportResizeSubscription = {
|
|
1245
|
+
unsubscribe: () => {
|
|
1246
|
+
window.removeEventListener('resize', onResize);
|
|
1247
|
+
window.visualViewport?.removeEventListener('resize', onResize);
|
|
1248
|
+
this._clearViewportResizeTimeout();
|
|
1249
|
+
},
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
950
1252
|
_delay(show, delay) {
|
|
951
1253
|
this._delaySubject.next({ show, delay });
|
|
952
1254
|
}
|
|
@@ -976,13 +1278,14 @@ class ZPopoverDirective {
|
|
|
976
1278
|
this._overlayRef.updatePositionStrategy(positionStrategy);
|
|
977
1279
|
const widthConfig = this._getWidthConfig();
|
|
978
1280
|
if (widthConfig.width) {
|
|
979
|
-
this._overlayRef.updateSize(
|
|
1281
|
+
this._overlayRef.updateSize(widthConfig);
|
|
980
1282
|
}
|
|
981
1283
|
const portal = new ComponentPortal(ZPopoverContentComponent);
|
|
982
1284
|
this._componentRef = this._overlayRef.attach(portal);
|
|
1285
|
+
const renderPosition = getPopoverRenderPosition(this.zPosition());
|
|
983
1286
|
this._componentRef.instance.setProps({
|
|
984
1287
|
content,
|
|
985
|
-
position:
|
|
1288
|
+
position: renderPosition,
|
|
986
1289
|
customClass: this.zClass(),
|
|
987
1290
|
onClose: () => this.hide(),
|
|
988
1291
|
showArrow: this.zShowArrow(),
|
|
@@ -991,11 +1294,14 @@ class ZPopoverDirective {
|
|
|
991
1294
|
const actualPosition = getActualPopoverPosition(change);
|
|
992
1295
|
this._componentRef?.instance.position.set(actualPosition);
|
|
993
1296
|
this.zPositionChange.emit(actualPosition);
|
|
1297
|
+
this._applyMobilePopoverPosition(actualPosition);
|
|
994
1298
|
});
|
|
995
1299
|
if (this._trigger() === 'hover') {
|
|
996
1300
|
this._setupPopoverHover();
|
|
997
1301
|
}
|
|
998
1302
|
this._setupResizeObserver();
|
|
1303
|
+
this._setupViewportResizeReposition();
|
|
1304
|
+
this._updatePositionAfterContentSettles();
|
|
999
1305
|
this._isVisible.set(true);
|
|
1000
1306
|
ZPopoverDirective._openPopovers.add(this);
|
|
1001
1307
|
this._renderer.addClass(this._elementRef.nativeElement, 'z-popover-open');
|
|
@@ -1025,11 +1331,11 @@ class ZPopoverDirective {
|
|
|
1025
1331
|
this._resizeObserver?.disconnect();
|
|
1026
1332
|
this._resizeObserver = new ResizeObserver(() => {
|
|
1027
1333
|
if (this._overlayRef && this._isVisible()) {
|
|
1028
|
-
this._overlayRef.updatePosition();
|
|
1029
1334
|
const widthConfig = this._getWidthConfig();
|
|
1030
1335
|
if (widthConfig.width) {
|
|
1031
|
-
this._overlayRef.updateSize(
|
|
1336
|
+
this._overlayRef.updateSize(widthConfig);
|
|
1032
1337
|
}
|
|
1338
|
+
this._schedulePositionUpdate();
|
|
1033
1339
|
}
|
|
1034
1340
|
});
|
|
1035
1341
|
const originElement = this._getTriggerElement();
|
|
@@ -1042,6 +1348,116 @@ class ZPopoverDirective {
|
|
|
1042
1348
|
this._resizeObserver.observe(wrapper);
|
|
1043
1349
|
}
|
|
1044
1350
|
}
|
|
1351
|
+
_updatePositionAfterContentSettles() {
|
|
1352
|
+
this._schedulePositionUpdate();
|
|
1353
|
+
}
|
|
1354
|
+
_schedulePositionUpdate(force = false) {
|
|
1355
|
+
if (this._positionFrame !== null) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
this._positionFrame = requestAnimationFrame(() => {
|
|
1359
|
+
this._positionFrame = null;
|
|
1360
|
+
this._updatePositionNow(force);
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
_scheduleSettledPositionUpdate() {
|
|
1364
|
+
this._clearViewportResizeTimeout();
|
|
1365
|
+
for (const delay of [80, 180, 320]) {
|
|
1366
|
+
const timeout = setTimeout(() => {
|
|
1367
|
+
this._viewportResizeTimeouts = this._viewportResizeTimeouts.filter(item => item !== timeout);
|
|
1368
|
+
this._schedulePositionUpdate(true);
|
|
1369
|
+
}, delay);
|
|
1370
|
+
this._viewportResizeTimeouts.push(timeout);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
_cancelScheduledPositionUpdate() {
|
|
1374
|
+
if (this._positionFrame === null) {
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
cancelAnimationFrame(this._positionFrame);
|
|
1378
|
+
this._positionFrame = null;
|
|
1379
|
+
}
|
|
1380
|
+
_updatePositionNow(force = false) {
|
|
1381
|
+
if (!this._overlayRef?.hasAttached()) {
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
if (isMobilePopoverViewport() && this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
if (!force && this._shouldSkipMobileKeyboardUpdate()) {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
const widthConfig = this._getWidthConfig();
|
|
1391
|
+
if (widthConfig.width) {
|
|
1392
|
+
this._overlayRef.updateSize(widthConfig);
|
|
1393
|
+
}
|
|
1394
|
+
this._overlayRef.updatePosition();
|
|
1395
|
+
this._applyMobilePopoverPosition(this._componentRef?.instance.position() ?? this.zPosition());
|
|
1396
|
+
}
|
|
1397
|
+
_markViewportSettling() {
|
|
1398
|
+
this._viewportSettlingUntil = Date.now() + 260;
|
|
1399
|
+
}
|
|
1400
|
+
_shouldDeferForMobileKeyboard() {
|
|
1401
|
+
return this._isMobileOverlayTextInputFocused();
|
|
1402
|
+
}
|
|
1403
|
+
_shouldSkipMobileKeyboardUpdate() {
|
|
1404
|
+
if (!this._isMobileOverlayTextInputFocused()) {
|
|
1405
|
+
return false;
|
|
1406
|
+
}
|
|
1407
|
+
return Date.now() < this._viewportSettlingUntil;
|
|
1408
|
+
}
|
|
1409
|
+
_isMobileOverlayTextInputFocused() {
|
|
1410
|
+
if (!this.zKeyboardSafe() || !isMobilePopoverViewport()) {
|
|
1411
|
+
return false;
|
|
1412
|
+
}
|
|
1413
|
+
const { activeElement } = this._document;
|
|
1414
|
+
if (!(activeElement instanceof HTMLElement)) {
|
|
1415
|
+
return false;
|
|
1416
|
+
}
|
|
1417
|
+
const overlayElement = this._overlayRef?.overlayElement;
|
|
1418
|
+
if (!overlayElement?.contains(activeElement)) {
|
|
1419
|
+
return false;
|
|
1420
|
+
}
|
|
1421
|
+
if (activeElement.isContentEditable) {
|
|
1422
|
+
return true;
|
|
1423
|
+
}
|
|
1424
|
+
return activeElement.matches('input, textarea, select');
|
|
1425
|
+
}
|
|
1426
|
+
_clearViewportResizeTimeout() {
|
|
1427
|
+
for (const timeout of this._viewportResizeTimeouts) {
|
|
1428
|
+
clearTimeout(timeout);
|
|
1429
|
+
}
|
|
1430
|
+
this._viewportResizeTimeouts = [];
|
|
1431
|
+
}
|
|
1432
|
+
_applyMobilePopoverPosition(position) {
|
|
1433
|
+
if (!isMobilePopoverViewport() || !this._overlayRef?.hasAttached()) {
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
const { overlayElement } = this._overlayRef;
|
|
1437
|
+
const { visualViewport } = window;
|
|
1438
|
+
const styles = getMobilePopoverPaneStyles({
|
|
1439
|
+
position,
|
|
1440
|
+
triggerRect: this._getTriggerElement().getBoundingClientRect(),
|
|
1441
|
+
overlayRect: overlayElement.getBoundingClientRect(),
|
|
1442
|
+
offset: this.zOffset(),
|
|
1443
|
+
viewportWidth: visualViewport?.width ?? window.innerWidth,
|
|
1444
|
+
viewportHeight: visualViewport?.height ?? window.innerHeight,
|
|
1445
|
+
});
|
|
1446
|
+
this._setOverlayPaneStyles(styles);
|
|
1447
|
+
}
|
|
1448
|
+
_isTriggerVisibleInViewport() {
|
|
1449
|
+
const { visualViewport } = window;
|
|
1450
|
+
return isPopoverTriggerVisibleInViewport({
|
|
1451
|
+
triggerRect: this._getTriggerElement().getBoundingClientRect(),
|
|
1452
|
+
viewportWidth: visualViewport?.width ?? window.innerWidth,
|
|
1453
|
+
viewportHeight: visualViewport?.height ?? window.innerHeight,
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
_setOverlayPaneStyles(styles) {
|
|
1457
|
+
for (const key of ['top', 'left', 'right', 'bottom', 'transform']) {
|
|
1458
|
+
this._renderer.setStyle(this._overlayRef?.overlayElement, key, styles[key]);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1045
1461
|
_setupPopoverHover() {
|
|
1046
1462
|
const overlayElement = this._overlayRef?.overlayElement;
|
|
1047
1463
|
if (!overlayElement) {
|
|
@@ -1088,7 +1504,7 @@ class ZPopoverDirective {
|
|
|
1088
1504
|
this._listenerCleanups = [];
|
|
1089
1505
|
}
|
|
1090
1506
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZPopoverDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1091
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.9", type: ZPopoverDirective, isStandalone: true, selector: "[z-popover]", inputs: { zContent: { classPropertyName: "zContent", publicName: "zPopoverContent", isSignal: true, isRequired: false, transformFunction: null }, zPosition: { classPropertyName: "zPosition", publicName: "zPosition", isSignal: true, isRequired: false, transformFunction: null }, zTrigger: { classPropertyName: "zTrigger", publicName: "zTrigger", isSignal: true, isRequired: false, transformFunction: null }, zPopoverTrigger: { classPropertyName: "zPopoverTrigger", publicName: "zPopoverTrigger", isSignal: true, isRequired: false, transformFunction: null }, zClass: { classPropertyName: "zClass", publicName: "zClass", isSignal: true, isRequired: false, transformFunction: null }, zShowDelay: { classPropertyName: "zShowDelay", publicName: "zShowDelay", isSignal: true, isRequired: false, transformFunction: null }, zHideDelay: { classPropertyName: "zHideDelay", publicName: "zHideDelay", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zOffset: { classPropertyName: "zOffset", publicName: "zOffset", isSignal: true, isRequired: false, transformFunction: null }, zPopoverWidth: { classPropertyName: "zPopoverWidth", publicName: "zPopoverWidth", isSignal: true, isRequired: false, transformFunction: null }, zTriggerRef: { classPropertyName: "zTriggerRef", publicName: "zTriggerRef", isSignal: true, isRequired: false, transformFunction: null }, zManualClose: { classPropertyName: "zManualClose", publicName: "zManualClose", isSignal: true, isRequired: false, transformFunction: null }, zOutsideClickClose: { classPropertyName: "zOutsideClickClose", publicName: "zOutsideClickClose", isSignal: true, isRequired: false, transformFunction: null }, zScrollClose: { classPropertyName: "zScrollClose", publicName: "zScrollClose", isSignal: true, isRequired: false, transformFunction: null }, zShowArrow: { classPropertyName: "zShowArrow", publicName: "zShowArrow", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zShow: "zShow", zHide: "zHide", zHideStart: "zHideStart", zControl: "zControl", zPositionChange: "zPositionChange", zOutsideClick: "zOutsideClick" }, exportAs: ["zPopover"], ngImport: i0 });
|
|
1507
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.9", type: ZPopoverDirective, isStandalone: true, selector: "[z-popover]", inputs: { zContent: { classPropertyName: "zContent", publicName: "zPopoverContent", isSignal: true, isRequired: false, transformFunction: null }, zPosition: { classPropertyName: "zPosition", publicName: "zPosition", isSignal: true, isRequired: false, transformFunction: null }, zTrigger: { classPropertyName: "zTrigger", publicName: "zTrigger", isSignal: true, isRequired: false, transformFunction: null }, zPopoverTrigger: { classPropertyName: "zPopoverTrigger", publicName: "zPopoverTrigger", isSignal: true, isRequired: false, transformFunction: null }, zClass: { classPropertyName: "zClass", publicName: "zClass", isSignal: true, isRequired: false, transformFunction: null }, zShowDelay: { classPropertyName: "zShowDelay", publicName: "zShowDelay", isSignal: true, isRequired: false, transformFunction: null }, zHideDelay: { classPropertyName: "zHideDelay", publicName: "zHideDelay", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zOffset: { classPropertyName: "zOffset", publicName: "zOffset", isSignal: true, isRequired: false, transformFunction: null }, zPopoverWidth: { classPropertyName: "zPopoverWidth", publicName: "zPopoverWidth", isSignal: true, isRequired: false, transformFunction: null }, zTriggerRef: { classPropertyName: "zTriggerRef", publicName: "zTriggerRef", isSignal: true, isRequired: false, transformFunction: null }, zManualClose: { classPropertyName: "zManualClose", publicName: "zManualClose", isSignal: true, isRequired: false, transformFunction: null }, zOutsideClickClose: { classPropertyName: "zOutsideClickClose", publicName: "zOutsideClickClose", isSignal: true, isRequired: false, transformFunction: null }, zScrollClose: { classPropertyName: "zScrollClose", publicName: "zScrollClose", isSignal: true, isRequired: false, transformFunction: null }, zSticky: { classPropertyName: "zSticky", publicName: "zSticky", isSignal: true, isRequired: false, transformFunction: null }, zShowArrow: { classPropertyName: "zShowArrow", publicName: "zShowArrow", isSignal: true, isRequired: false, transformFunction: null }, zKeyboardSafe: { classPropertyName: "zKeyboardSafe", publicName: "zKeyboardSafe", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zShow: "zShow", zHide: "zHide", zHideStart: "zHideStart", zControl: "zControl", zPositionChange: "zPositionChange", zOutsideClick: "zOutsideClick" }, exportAs: ["zPopover"], ngImport: i0 });
|
|
1092
1508
|
}
|
|
1093
1509
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZPopoverDirective, decorators: [{
|
|
1094
1510
|
type: Directive,
|
|
@@ -1097,7 +1513,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
|
|
|
1097
1513
|
standalone: true,
|
|
1098
1514
|
exportAs: 'zPopover',
|
|
1099
1515
|
}]
|
|
1100
|
-
}], propDecorators: { zContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPopoverContent", required: false }] }], zPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPosition", required: false }] }], zTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTrigger", required: false }] }], zPopoverTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPopoverTrigger", required: false }] }], zClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "zClass", required: false }] }], zShowDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowDelay", required: false }] }], zHideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zHideDelay", required: false }] }], zDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDisabled", required: false }] }], zOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOffset", required: false }] }], zPopoverWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPopoverWidth", required: false }] }], zTriggerRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTriggerRef", required: false }] }], zManualClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zManualClose", required: false }] }], zOutsideClickClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOutsideClickClose", required: false }] }], zScrollClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zScrollClose", required: false }] }], zShowArrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowArrow", required: false }] }], zShow: [{ type: i0.Output, args: ["zShow"] }], zHide: [{ type: i0.Output, args: ["zHide"] }], zHideStart: [{ type: i0.Output, args: ["zHideStart"] }], zControl: [{ type: i0.Output, args: ["zControl"] }], zPositionChange: [{ type: i0.Output, args: ["zPositionChange"] }], zOutsideClick: [{ type: i0.Output, args: ["zOutsideClick"] }] } });
|
|
1516
|
+
}], propDecorators: { zContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPopoverContent", required: false }] }], zPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPosition", required: false }] }], zTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTrigger", required: false }] }], zPopoverTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPopoverTrigger", required: false }] }], zClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "zClass", required: false }] }], zShowDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowDelay", required: false }] }], zHideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "zHideDelay", required: false }] }], zDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDisabled", required: false }] }], zOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOffset", required: false }] }], zPopoverWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPopoverWidth", required: false }] }], zTriggerRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "zTriggerRef", required: false }] }], zManualClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zManualClose", required: false }] }], zOutsideClickClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOutsideClickClose", required: false }] }], zScrollClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "zScrollClose", required: false }] }], zSticky: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSticky", required: false }] }], zShowArrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "zShowArrow", required: false }] }], zKeyboardSafe: [{ type: i0.Input, args: [{ isSignal: true, alias: "zKeyboardSafe", required: false }] }], zShow: [{ type: i0.Output, args: ["zShow"] }], zHide: [{ type: i0.Output, args: ["zHide"] }], zHideStart: [{ type: i0.Output, args: ["zHideStart"] }], zControl: [{ type: i0.Output, args: ["zControl"] }], zPositionChange: [{ type: i0.Output, args: ["zPositionChange"] }], zOutsideClick: [{ type: i0.Output, args: ["zOutsideClick"] }] } });
|
|
1101
1517
|
|
|
1102
1518
|
/**
|
|
1103
1519
|
* Generated bundle index. Do not edit.
|