@shival99/z-ui 2.0.50 → 2.0.52
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 +17 -4
- 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 +353 -83
- package/fesm2022/shival99-z-ui-components-z-popover.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-select.mjs +175 -110
- package/fesm2022/shival99-z-ui-components-z-select.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-table.mjs +4 -4
- 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-components-z-tooltip.mjs +34 -34
- package/fesm2022/shival99-z-ui-components-z-tooltip.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-utils.mjs +26 -1
- package/fesm2022/shival99-z-ui-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shival99-z-ui-components-z-autocomplete.d.ts +5 -2
- package/types/shival99-z-ui-components-z-gallery.d.ts +4 -4
- package/types/shival99-z-ui-components-z-popover.d.ts +34 -4
- package/types/shival99-z-ui-components-z-select.d.ts +13 -7
- package/types/shival99-z-ui-components-z-table.d.ts +3 -3
- package/types/shival99-z-ui-components-z-upload.d.ts +3 -3
- package/types/shival99-z-ui-utils.d.ts +6 -1
|
@@ -5,8 +5,8 @@ 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';
|
|
9
|
-
import { Subject, switchMap, of, timer, map, filter } from 'rxjs';
|
|
8
|
+
import { zMergeClasses, zIsMobileViewport, zTransform } from '@shival99/z-ui/utils';
|
|
9
|
+
import { Subject, switchMap, of, timer, map, filter, fromEvent, throttleTime } from 'rxjs';
|
|
10
10
|
import { cva } from 'class-variance-authority';
|
|
11
11
|
|
|
12
12
|
const zPopoverVariants = cva([
|
|
@@ -38,18 +38,18 @@ const zPopoverVariants = cva([
|
|
|
38
38
|
const zPopoverExitVariants = cva('z-animate-out z-fade-out z-duration-200', {
|
|
39
39
|
variants: {
|
|
40
40
|
zPosition: {
|
|
41
|
-
top: 'z-slide-out-to-
|
|
42
|
-
'top-left': 'z-slide-out-to-
|
|
43
|
-
'top-right': 'z-slide-out-to-
|
|
44
|
-
bottom: 'z-slide-out-to-
|
|
45
|
-
'bottom-left': 'z-slide-out-to-
|
|
46
|
-
'bottom-right': 'z-slide-out-to-
|
|
47
|
-
left: 'z-slide-out-to-
|
|
48
|
-
'left-top': 'z-slide-out-to-
|
|
49
|
-
'left-bottom': 'z-slide-out-to-
|
|
50
|
-
right: 'z-slide-out-to-
|
|
51
|
-
'right-top': 'z-slide-out-to-
|
|
52
|
-
'right-bottom': 'z-slide-out-to-
|
|
41
|
+
top: 'z-slide-out-to-bottom-4',
|
|
42
|
+
'top-left': 'z-slide-out-to-bottom-4',
|
|
43
|
+
'top-right': 'z-slide-out-to-bottom-4',
|
|
44
|
+
bottom: 'z-slide-out-to-top-4',
|
|
45
|
+
'bottom-left': 'z-slide-out-to-top-4',
|
|
46
|
+
'bottom-right': 'z-slide-out-to-top-4',
|
|
47
|
+
left: 'z-slide-out-to-right-4',
|
|
48
|
+
'left-top': 'z-slide-out-to-right-4',
|
|
49
|
+
'left-bottom': 'z-slide-out-to-right-4',
|
|
50
|
+
right: 'z-slide-out-to-left-4',
|
|
51
|
+
'right-top': 'z-slide-out-to-left-4',
|
|
52
|
+
'right-bottom': 'z-slide-out-to-left-4',
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
55
|
defaultVariants: {
|
|
@@ -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) {
|
|
198
|
+
return getPopoverFallbackPositions(position, 0).map(pos => ({
|
|
199
|
+
...pos,
|
|
200
|
+
offsetX: 0,
|
|
201
|
+
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: {
|
|
@@ -275,26 +365,34 @@ function createPopoverPosition(position, offset) {
|
|
|
275
365
|
}
|
|
276
366
|
function getPopoverFallbackPositions(position, offset) {
|
|
277
367
|
const fallbackOrder = {
|
|
278
|
-
|
|
279
|
-
top: ['top', '
|
|
280
|
-
'top-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
bottom: ['bottom', '
|
|
284
|
-
|
|
285
|
-
'
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
'
|
|
289
|
-
'
|
|
290
|
-
// Right positions: if overflows top, try bottom; if overflows right, try left
|
|
291
|
-
right: ['right', 'right-top', 'right-bottom', 'left', 'left-top', 'left-bottom'],
|
|
292
|
-
'right-top': ['right-top', 'right', 'right-bottom', 'left-top', 'left', 'left-bottom'],
|
|
293
|
-
'right-bottom': ['right-bottom', 'right', 'right-top', 'left-bottom', 'left', 'left-top'],
|
|
368
|
+
top: ['top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right'],
|
|
369
|
+
'top-left': ['top-left', 'bottom-left', 'top', 'bottom', 'top-right', 'bottom-right'],
|
|
370
|
+
'top-right': ['top-right', 'bottom-right', 'top', 'bottom', 'top-left', 'bottom-left'],
|
|
371
|
+
bottom: ['bottom', 'top', 'bottom-left', 'bottom-right', 'top-left', 'top-right'],
|
|
372
|
+
'bottom-left': ['bottom-left', 'top-left', 'bottom', 'top', 'bottom-right', 'top-right'],
|
|
373
|
+
'bottom-right': ['bottom-right', 'top-right', 'bottom', 'top', 'bottom-left', 'top-left'],
|
|
374
|
+
left: ['left', 'right', 'left-top', 'left-bottom', 'right-top', 'right-bottom'],
|
|
375
|
+
'left-top': ['left-top', 'right-top', 'left', 'right', 'left-bottom', 'right-bottom'],
|
|
376
|
+
'left-bottom': ['left-bottom', 'right-bottom', 'left', 'right', 'left-top', 'right-top'],
|
|
377
|
+
right: ['right', 'left', 'right-top', 'right-bottom', 'left-top', 'left-bottom'],
|
|
378
|
+
'right-top': ['right-top', 'left-top', 'right', 'left', 'right-bottom', 'left-bottom'],
|
|
379
|
+
'right-bottom': ['right-bottom', 'left-bottom', 'right', 'left', 'right-top', 'left-top'],
|
|
294
380
|
};
|
|
295
381
|
const orderedPositions = fallbackOrder[position] ?? [position];
|
|
296
382
|
return orderedPositions.map(pos => createPopoverPosition(pos, offset));
|
|
297
383
|
}
|
|
384
|
+
function createPopoverPositionStrategy(overlayPositionBuilder, origin, position, offset) {
|
|
385
|
+
const mobile = isMobilePopoverViewport();
|
|
386
|
+
const positions = mobile
|
|
387
|
+
? getMobilePopoverFallbackPositions(position)
|
|
388
|
+
: getPopoverFallbackPositions(position, offset);
|
|
389
|
+
return overlayPositionBuilder
|
|
390
|
+
.flexibleConnectedTo(origin)
|
|
391
|
+
.withPositions(positions)
|
|
392
|
+
.withFlexibleDimensions(false)
|
|
393
|
+
.withPush(getPopoverPushEnabled(mobile))
|
|
394
|
+
.withViewportMargin(10);
|
|
395
|
+
}
|
|
298
396
|
function getActualPopoverPosition(change) {
|
|
299
397
|
const { originX, originY, overlayX, overlayY } = change.connectionPair;
|
|
300
398
|
if (overlayY === 'bottom' && originY === 'top') {
|
|
@@ -363,6 +461,7 @@ class ZPopoverComponent {
|
|
|
363
461
|
zManualClose = input(false, { ...(ngDevMode ? { debugName: "zManualClose" } : {}), transform: zTransform });
|
|
364
462
|
zOutsideClickClose = input(false, { ...(ngDevMode ? { debugName: "zOutsideClickClose" } : {}), transform: zTransform });
|
|
365
463
|
zScrollClose = input(false, { ...(ngDevMode ? { debugName: "zScrollClose" } : {}), transform: zTransform });
|
|
464
|
+
zSticky = input(false, { ...(ngDevMode ? { debugName: "zSticky" } : {}), transform: zTransform });
|
|
366
465
|
zShowArrow = input(false, { ...(ngDevMode ? { debugName: "zShowArrow" } : {}), transform: zTransform });
|
|
367
466
|
_overlayRef = null;
|
|
368
467
|
_componentRef = null;
|
|
@@ -370,8 +469,10 @@ class ZPopoverComponent {
|
|
|
370
469
|
_listenerCleanups = [];
|
|
371
470
|
_positionSubscription = null;
|
|
372
471
|
_scrollSubscription = null;
|
|
472
|
+
_viewportResizeSubscription = null;
|
|
373
473
|
_resizeObserver = null;
|
|
374
474
|
_hideTimeout = null;
|
|
475
|
+
_positionFrame = null;
|
|
375
476
|
_isVisible = signal(false, ...(ngDevMode ? [{ debugName: "_isVisible" }] : []));
|
|
376
477
|
ngOnInit() {
|
|
377
478
|
if (!isPlatformBrowser(this._platformId)) {
|
|
@@ -441,31 +542,36 @@ class ZPopoverComponent {
|
|
|
441
542
|
if (!this._isVisible()) {
|
|
442
543
|
return;
|
|
443
544
|
}
|
|
444
|
-
this.
|
|
545
|
+
this._updatePositionNow();
|
|
445
546
|
}
|
|
446
547
|
_createOverlay() {
|
|
447
|
-
const positionStrategy = this._overlayPositionBuilder
|
|
448
|
-
.flexibleConnectedTo(this._trigger())
|
|
449
|
-
.withPositions(getPopoverFallbackPositions(this.zPosition(), this.zOffset()))
|
|
450
|
-
.withFlexibleDimensions(false)
|
|
451
|
-
.withPush(true)
|
|
452
|
-
.withViewportMargin(8);
|
|
453
|
-
const scrollStrategy = this.zScrollClose()
|
|
454
|
-
? this._overlay.scrollStrategies.close()
|
|
455
|
-
: this._overlay.scrollStrategies.reposition({ scrollThrottle: 10, autoClose: false });
|
|
548
|
+
const positionStrategy = createPopoverPositionStrategy(this._overlayPositionBuilder, this._trigger(), this.zPosition(), this.zOffset());
|
|
456
549
|
return this._overlay.create({
|
|
457
550
|
positionStrategy,
|
|
458
|
-
scrollStrategy,
|
|
551
|
+
scrollStrategy: this._createScrollStrategy(),
|
|
459
552
|
hasBackdrop: false,
|
|
553
|
+
...getPopoverOverlaySize(),
|
|
460
554
|
});
|
|
461
555
|
}
|
|
556
|
+
_createScrollStrategy() {
|
|
557
|
+
if (this.zScrollClose()) {
|
|
558
|
+
return this._overlay.scrollStrategies.close();
|
|
559
|
+
}
|
|
560
|
+
if (isMobilePopoverViewport() && this.zSticky()) {
|
|
561
|
+
return this._overlay.scrollStrategies.noop();
|
|
562
|
+
}
|
|
563
|
+
return this._overlay.scrollStrategies.reposition({ scrollThrottle: 10, autoClose: false });
|
|
564
|
+
}
|
|
462
565
|
_disposeOverlay() {
|
|
463
566
|
this._positionSubscription?.unsubscribe();
|
|
464
567
|
this._positionSubscription = null;
|
|
465
568
|
this._scrollSubscription?.unsubscribe();
|
|
466
569
|
this._scrollSubscription = null;
|
|
570
|
+
this._viewportResizeSubscription?.unsubscribe();
|
|
571
|
+
this._viewportResizeSubscription = null;
|
|
467
572
|
this._resizeObserver?.disconnect();
|
|
468
573
|
this._resizeObserver = null;
|
|
574
|
+
this._cancelScheduledPositionUpdate();
|
|
469
575
|
this._overlayRef?.dispose();
|
|
470
576
|
this._overlayRef = null;
|
|
471
577
|
this._componentRef = null;
|
|
@@ -543,7 +649,11 @@ class ZPopoverComponent {
|
|
|
543
649
|
}
|
|
544
650
|
ticking = true;
|
|
545
651
|
requestAnimationFrame(() => {
|
|
546
|
-
this.
|
|
652
|
+
if (this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
653
|
+
ticking = false;
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
this._updatePositionNow();
|
|
547
657
|
ticking = false;
|
|
548
658
|
});
|
|
549
659
|
};
|
|
@@ -554,6 +664,17 @@ class ZPopoverComponent {
|
|
|
554
664
|
},
|
|
555
665
|
};
|
|
556
666
|
}
|
|
667
|
+
_setupViewportResizeReposition() {
|
|
668
|
+
this._viewportResizeSubscription?.unsubscribe();
|
|
669
|
+
this._viewportResizeSubscription = fromEvent(window, 'resize')
|
|
670
|
+
.pipe(throttleTime(60), takeUntilDestroyed(this._destroyRef))
|
|
671
|
+
.subscribe(() => {
|
|
672
|
+
if (!this._overlayRef?.hasAttached()) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
this._updatePositionNow();
|
|
676
|
+
});
|
|
677
|
+
}
|
|
557
678
|
_showPopover() {
|
|
558
679
|
const content = this.zContent();
|
|
559
680
|
if (!content || this._componentRef) {
|
|
@@ -564,18 +685,15 @@ class ZPopoverComponent {
|
|
|
564
685
|
this._setupOutsideClick();
|
|
565
686
|
}
|
|
566
687
|
this._setupScrollClose();
|
|
567
|
-
const positionStrategy = this._overlayPositionBuilder
|
|
568
|
-
.flexibleConnectedTo(this._trigger())
|
|
569
|
-
.withPositions(getPopoverFallbackPositions(this.zPosition(), this.zOffset()))
|
|
570
|
-
.withFlexibleDimensions(false)
|
|
571
|
-
.withPush(true)
|
|
572
|
-
.withViewportMargin(8);
|
|
688
|
+
const positionStrategy = createPopoverPositionStrategy(this._overlayPositionBuilder, this._trigger(), this.zPosition(), this.zOffset());
|
|
573
689
|
this._overlayRef.updatePositionStrategy(positionStrategy);
|
|
690
|
+
this._overlayRef.updateSize(getPopoverOverlaySize());
|
|
574
691
|
const portal = new ComponentPortal(ZPopoverContentComponent);
|
|
575
692
|
this._componentRef = this._overlayRef.attach(portal);
|
|
693
|
+
const renderPosition = getPopoverRenderPosition(this.zPosition());
|
|
576
694
|
this._componentRef.instance.setProps({
|
|
577
695
|
content,
|
|
578
|
-
position:
|
|
696
|
+
position: renderPosition,
|
|
579
697
|
customClass: this.zClass(),
|
|
580
698
|
onClose: () => this.hide(),
|
|
581
699
|
showArrow: this.zShowArrow(),
|
|
@@ -583,11 +701,14 @@ class ZPopoverComponent {
|
|
|
583
701
|
this._positionSubscription = positionStrategy.positionChanges.subscribe(change => {
|
|
584
702
|
const actualPosition = getActualPopoverPosition(change);
|
|
585
703
|
this._componentRef?.instance.position.set(actualPosition);
|
|
704
|
+
this._applyMobilePopoverPosition(actualPosition);
|
|
586
705
|
});
|
|
587
706
|
if (this.zTrigger() === 'hover') {
|
|
588
707
|
this._setupPopoverHover();
|
|
589
708
|
}
|
|
590
709
|
this._setupResizeObserver();
|
|
710
|
+
this._setupViewportResizeReposition();
|
|
711
|
+
this._updatePositionAfterContentSettles();
|
|
591
712
|
this._isVisible.set(true);
|
|
592
713
|
ZPopoverComponent._openPopovers.add(this);
|
|
593
714
|
this.zShow.emit();
|
|
@@ -615,15 +736,77 @@ class ZPopoverComponent {
|
|
|
615
736
|
this._resizeObserver?.disconnect();
|
|
616
737
|
this._resizeObserver = new ResizeObserver(() => {
|
|
617
738
|
if (this._overlayRef && this._isVisible()) {
|
|
618
|
-
this.
|
|
739
|
+
this._schedulePositionUpdate();
|
|
619
740
|
}
|
|
620
741
|
});
|
|
621
742
|
this._resizeObserver.observe(this._trigger().nativeElement);
|
|
743
|
+
const overlayElement = this._overlayRef?.overlayElement;
|
|
744
|
+
if (overlayElement) {
|
|
745
|
+
this._resizeObserver.observe(overlayElement);
|
|
746
|
+
}
|
|
622
747
|
const wrapper = this._trigger().nativeElement.parentElement?.parentElement;
|
|
623
748
|
if (wrapper && wrapper !== document.body) {
|
|
624
749
|
this._resizeObserver.observe(wrapper);
|
|
625
750
|
}
|
|
626
751
|
}
|
|
752
|
+
_updatePositionAfterContentSettles() {
|
|
753
|
+
this._schedulePositionUpdate();
|
|
754
|
+
}
|
|
755
|
+
_schedulePositionUpdate() {
|
|
756
|
+
if (this._positionFrame !== null) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
this._positionFrame = requestAnimationFrame(() => {
|
|
760
|
+
this._positionFrame = null;
|
|
761
|
+
this._updatePositionNow();
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
_cancelScheduledPositionUpdate() {
|
|
765
|
+
if (this._positionFrame === null) {
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
cancelAnimationFrame(this._positionFrame);
|
|
769
|
+
this._positionFrame = null;
|
|
770
|
+
}
|
|
771
|
+
_updatePositionNow() {
|
|
772
|
+
if (!this._overlayRef?.hasAttached()) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
if (isMobilePopoverViewport() && this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
this._overlayRef.updatePosition();
|
|
779
|
+
this._applyMobilePopoverPosition(this._componentRef?.instance.position() ?? this.zPosition());
|
|
780
|
+
}
|
|
781
|
+
_applyMobilePopoverPosition(position) {
|
|
782
|
+
if (!isMobilePopoverViewport() || !this._overlayRef?.hasAttached()) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const { overlayElement } = this._overlayRef;
|
|
786
|
+
const { visualViewport } = window;
|
|
787
|
+
const styles = getMobilePopoverPaneStyles({
|
|
788
|
+
position,
|
|
789
|
+
triggerRect: this._trigger().nativeElement.getBoundingClientRect(),
|
|
790
|
+
overlayRect: overlayElement.getBoundingClientRect(),
|
|
791
|
+
offset: this.zOffset(),
|
|
792
|
+
viewportWidth: visualViewport?.width ?? window.innerWidth,
|
|
793
|
+
viewportHeight: visualViewport?.height ?? window.innerHeight,
|
|
794
|
+
});
|
|
795
|
+
this._setOverlayPaneStyles(styles);
|
|
796
|
+
}
|
|
797
|
+
_isTriggerVisibleInViewport() {
|
|
798
|
+
const { visualViewport } = window;
|
|
799
|
+
return isPopoverTriggerVisibleInViewport({
|
|
800
|
+
triggerRect: this._trigger().nativeElement.getBoundingClientRect(),
|
|
801
|
+
viewportWidth: visualViewport?.width ?? window.innerWidth,
|
|
802
|
+
viewportHeight: visualViewport?.height ?? window.innerHeight,
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
_setOverlayPaneStyles(styles) {
|
|
806
|
+
for (const key of ['top', 'left', 'right', 'bottom', 'transform']) {
|
|
807
|
+
this._renderer.setStyle(this._overlayRef?.overlayElement, key, styles[key]);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
627
810
|
_setupPopoverHover() {
|
|
628
811
|
const overlayElement = this._overlayRef?.overlayElement;
|
|
629
812
|
if (!overlayElement) {
|
|
@@ -668,7 +851,7 @@ class ZPopoverComponent {
|
|
|
668
851
|
this._listenerCleanups = [];
|
|
669
852
|
}
|
|
670
853
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZPopoverComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
671
|
-
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: `
|
|
854
|
+
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 } }, 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: `
|
|
672
855
|
<span #trigger class="z-popover-trigger inline-block">
|
|
673
856
|
<ng-content />
|
|
674
857
|
</span>
|
|
@@ -689,7 +872,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
|
|
|
689
872
|
class: 'inline-block',
|
|
690
873
|
},
|
|
691
874
|
}]
|
|
692
|
-
}], 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 }] }] } });
|
|
875
|
+
}], 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 }] }] } });
|
|
693
876
|
|
|
694
877
|
class ZPopoverDirective {
|
|
695
878
|
static _openPopovers = new Set();
|
|
@@ -707,6 +890,7 @@ class ZPopoverDirective {
|
|
|
707
890
|
zManualClose = input(false, { ...(ngDevMode ? { debugName: "zManualClose" } : {}), transform: zTransform });
|
|
708
891
|
zOutsideClickClose = input(false, { ...(ngDevMode ? { debugName: "zOutsideClickClose" } : {}), transform: zTransform });
|
|
709
892
|
zScrollClose = input(false, { ...(ngDevMode ? { debugName: "zScrollClose" } : {}), transform: zTransform });
|
|
893
|
+
zSticky = input(false, { ...(ngDevMode ? { debugName: "zSticky" } : {}), transform: zTransform });
|
|
710
894
|
zShowArrow = input(false, { ...(ngDevMode ? { debugName: "zShowArrow" } : {}), transform: zTransform });
|
|
711
895
|
zShow = output();
|
|
712
896
|
zHide = output();
|
|
@@ -729,8 +913,10 @@ class ZPopoverDirective {
|
|
|
729
913
|
_listenerCleanups = [];
|
|
730
914
|
_positionSubscription = null;
|
|
731
915
|
_scrollSubscription = null;
|
|
916
|
+
_viewportResizeSubscription = null;
|
|
732
917
|
_resizeObserver = null;
|
|
733
918
|
_hideTimeout = null;
|
|
919
|
+
_positionFrame = null;
|
|
734
920
|
_isDestroyed = signal(false, ...(ngDevMode ? [{ debugName: "_isDestroyed" }] : []));
|
|
735
921
|
_isVisible = signal(false, ...(ngDevMode ? [{ debugName: "_isVisible" }] : []));
|
|
736
922
|
ngOnInit() {
|
|
@@ -809,40 +995,37 @@ class ZPopoverDirective {
|
|
|
809
995
|
if (!this._isVisible()) {
|
|
810
996
|
return;
|
|
811
997
|
}
|
|
812
|
-
this.
|
|
813
|
-
const widthConfig = this._getWidthConfig();
|
|
814
|
-
if (widthConfig.width) {
|
|
815
|
-
this._overlayRef?.updateSize({ width: widthConfig.width, minWidth: widthConfig.minWidth });
|
|
816
|
-
}
|
|
998
|
+
this._updatePositionNow();
|
|
817
999
|
}
|
|
818
1000
|
_createOverlay() {
|
|
819
|
-
const positionStrategy = this._overlayPositionBuilder
|
|
820
|
-
.flexibleConnectedTo(this._getTriggerElement())
|
|
821
|
-
.withPositions(getPopoverFallbackPositions(this.zPosition(), this.zOffset()))
|
|
822
|
-
.withFlexibleDimensions(false)
|
|
823
|
-
.withPush(this.zScrollClose())
|
|
824
|
-
.withViewportMargin(8);
|
|
1001
|
+
const positionStrategy = createPopoverPositionStrategy(this._overlayPositionBuilder, this._getTriggerElement(), this.zPosition(), this.zOffset());
|
|
825
1002
|
const widthConfig = this._getWidthConfig();
|
|
826
|
-
const scrollStrategy = this.zScrollClose()
|
|
827
|
-
? this._overlay.scrollStrategies.close()
|
|
828
|
-
: this._overlay.scrollStrategies.reposition();
|
|
829
1003
|
return this._overlay.create({
|
|
830
1004
|
positionStrategy,
|
|
831
|
-
scrollStrategy,
|
|
1005
|
+
scrollStrategy: this._createScrollStrategy(),
|
|
832
1006
|
hasBackdrop: false,
|
|
833
1007
|
...widthConfig,
|
|
834
1008
|
});
|
|
835
1009
|
}
|
|
1010
|
+
_createScrollStrategy() {
|
|
1011
|
+
if (this.zScrollClose()) {
|
|
1012
|
+
return this._overlay.scrollStrategies.close();
|
|
1013
|
+
}
|
|
1014
|
+
if (isMobilePopoverViewport() && this.zSticky()) {
|
|
1015
|
+
return this._overlay.scrollStrategies.noop();
|
|
1016
|
+
}
|
|
1017
|
+
return this._overlay.scrollStrategies.reposition();
|
|
1018
|
+
}
|
|
836
1019
|
_getWidthConfig() {
|
|
837
1020
|
const width = this.zPopoverWidth();
|
|
838
1021
|
if (width === 'auto') {
|
|
839
|
-
return
|
|
1022
|
+
return getPopoverOverlaySize();
|
|
840
1023
|
}
|
|
841
1024
|
if (width === 'trigger') {
|
|
842
1025
|
const triggerWidth = this._getTriggerElement().getBoundingClientRect().width;
|
|
843
|
-
return { width: `${triggerWidth}px`, minWidth: `${triggerWidth}px` };
|
|
1026
|
+
return getPopoverOverlaySize({ width: `${triggerWidth}px`, minWidth: `${triggerWidth}px` });
|
|
844
1027
|
}
|
|
845
|
-
return { width, minWidth: width };
|
|
1028
|
+
return getPopoverOverlaySize({ width, minWidth: width });
|
|
846
1029
|
}
|
|
847
1030
|
_getTriggerElement() {
|
|
848
1031
|
const triggerRef = this.zTriggerRef();
|
|
@@ -856,8 +1039,11 @@ class ZPopoverDirective {
|
|
|
856
1039
|
this._positionSubscription = null;
|
|
857
1040
|
this._scrollSubscription?.unsubscribe();
|
|
858
1041
|
this._scrollSubscription = null;
|
|
1042
|
+
this._viewportResizeSubscription?.unsubscribe();
|
|
1043
|
+
this._viewportResizeSubscription = null;
|
|
859
1044
|
this._resizeObserver?.disconnect();
|
|
860
1045
|
this._resizeObserver = null;
|
|
1046
|
+
this._cancelScheduledPositionUpdate();
|
|
861
1047
|
this._overlayRef?.dispose();
|
|
862
1048
|
this._overlayRef = null;
|
|
863
1049
|
this._componentRef = null;
|
|
@@ -947,7 +1133,11 @@ class ZPopoverDirective {
|
|
|
947
1133
|
}
|
|
948
1134
|
ticking = true;
|
|
949
1135
|
requestAnimationFrame(() => {
|
|
950
|
-
this.
|
|
1136
|
+
if (this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
1137
|
+
ticking = false;
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
this._updatePositionNow();
|
|
951
1141
|
ticking = false;
|
|
952
1142
|
});
|
|
953
1143
|
};
|
|
@@ -958,6 +1148,21 @@ class ZPopoverDirective {
|
|
|
958
1148
|
},
|
|
959
1149
|
};
|
|
960
1150
|
}
|
|
1151
|
+
_setupViewportResizeReposition() {
|
|
1152
|
+
this._viewportResizeSubscription?.unsubscribe();
|
|
1153
|
+
this._viewportResizeSubscription = fromEvent(window, 'resize')
|
|
1154
|
+
.pipe(throttleTime(60), takeUntilDestroyed(this._destroyRef))
|
|
1155
|
+
.subscribe(() => {
|
|
1156
|
+
if (!this._overlayRef?.hasAttached()) {
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
const widthConfig = this._getWidthConfig();
|
|
1160
|
+
if (widthConfig.width) {
|
|
1161
|
+
this._overlayRef.updateSize(widthConfig);
|
|
1162
|
+
}
|
|
1163
|
+
this._updatePositionNow();
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
961
1166
|
_delay(show, delay) {
|
|
962
1167
|
this._delaySubject.next({ show, delay });
|
|
963
1168
|
}
|
|
@@ -983,22 +1188,18 @@ class ZPopoverDirective {
|
|
|
983
1188
|
this._setupOutsideClick();
|
|
984
1189
|
}
|
|
985
1190
|
this._setupScrollClose();
|
|
986
|
-
const positionStrategy = this._overlayPositionBuilder
|
|
987
|
-
.flexibleConnectedTo(this._getTriggerElement())
|
|
988
|
-
.withPositions(getPopoverFallbackPositions(this.zPosition(), this.zOffset()))
|
|
989
|
-
.withFlexibleDimensions(false)
|
|
990
|
-
.withPush(this.zScrollClose())
|
|
991
|
-
.withViewportMargin(8);
|
|
1191
|
+
const positionStrategy = createPopoverPositionStrategy(this._overlayPositionBuilder, this._getTriggerElement(), this.zPosition(), this.zOffset());
|
|
992
1192
|
this._overlayRef.updatePositionStrategy(positionStrategy);
|
|
993
1193
|
const widthConfig = this._getWidthConfig();
|
|
994
1194
|
if (widthConfig.width) {
|
|
995
|
-
this._overlayRef.updateSize(
|
|
1195
|
+
this._overlayRef.updateSize(widthConfig);
|
|
996
1196
|
}
|
|
997
1197
|
const portal = new ComponentPortal(ZPopoverContentComponent);
|
|
998
1198
|
this._componentRef = this._overlayRef.attach(portal);
|
|
1199
|
+
const renderPosition = getPopoverRenderPosition(this.zPosition());
|
|
999
1200
|
this._componentRef.instance.setProps({
|
|
1000
1201
|
content,
|
|
1001
|
-
position:
|
|
1202
|
+
position: renderPosition,
|
|
1002
1203
|
customClass: this.zClass(),
|
|
1003
1204
|
onClose: () => this.hide(),
|
|
1004
1205
|
showArrow: this.zShowArrow(),
|
|
@@ -1007,11 +1208,14 @@ class ZPopoverDirective {
|
|
|
1007
1208
|
const actualPosition = getActualPopoverPosition(change);
|
|
1008
1209
|
this._componentRef?.instance.position.set(actualPosition);
|
|
1009
1210
|
this.zPositionChange.emit(actualPosition);
|
|
1211
|
+
this._applyMobilePopoverPosition(actualPosition);
|
|
1010
1212
|
});
|
|
1011
1213
|
if (this._trigger() === 'hover') {
|
|
1012
1214
|
this._setupPopoverHover();
|
|
1013
1215
|
}
|
|
1014
1216
|
this._setupResizeObserver();
|
|
1217
|
+
this._setupViewportResizeReposition();
|
|
1218
|
+
this._updatePositionAfterContentSettles();
|
|
1015
1219
|
this._isVisible.set(true);
|
|
1016
1220
|
ZPopoverDirective._openPopovers.add(this);
|
|
1017
1221
|
this._renderer.addClass(this._elementRef.nativeElement, 'z-popover-open');
|
|
@@ -1041,15 +1245,19 @@ class ZPopoverDirective {
|
|
|
1041
1245
|
this._resizeObserver?.disconnect();
|
|
1042
1246
|
this._resizeObserver = new ResizeObserver(() => {
|
|
1043
1247
|
if (this._overlayRef && this._isVisible()) {
|
|
1044
|
-
this._overlayRef.updatePosition();
|
|
1045
1248
|
const widthConfig = this._getWidthConfig();
|
|
1046
1249
|
if (widthConfig.width) {
|
|
1047
|
-
this._overlayRef.updateSize(
|
|
1250
|
+
this._overlayRef.updateSize(widthConfig);
|
|
1048
1251
|
}
|
|
1252
|
+
this._schedulePositionUpdate();
|
|
1049
1253
|
}
|
|
1050
1254
|
});
|
|
1051
1255
|
const originElement = this._getTriggerElement();
|
|
1052
1256
|
this._resizeObserver.observe(originElement);
|
|
1257
|
+
const overlayElement = this._overlayRef?.overlayElement;
|
|
1258
|
+
if (overlayElement) {
|
|
1259
|
+
this._resizeObserver.observe(overlayElement);
|
|
1260
|
+
}
|
|
1053
1261
|
if (originElement !== this._elementRef.nativeElement) {
|
|
1054
1262
|
this._resizeObserver.observe(this._elementRef.nativeElement);
|
|
1055
1263
|
}
|
|
@@ -1058,6 +1266,68 @@ class ZPopoverDirective {
|
|
|
1058
1266
|
this._resizeObserver.observe(wrapper);
|
|
1059
1267
|
}
|
|
1060
1268
|
}
|
|
1269
|
+
_updatePositionAfterContentSettles() {
|
|
1270
|
+
this._schedulePositionUpdate();
|
|
1271
|
+
}
|
|
1272
|
+
_schedulePositionUpdate() {
|
|
1273
|
+
if (this._positionFrame !== null) {
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
this._positionFrame = requestAnimationFrame(() => {
|
|
1277
|
+
this._positionFrame = null;
|
|
1278
|
+
this._updatePositionNow();
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
_cancelScheduledPositionUpdate() {
|
|
1282
|
+
if (this._positionFrame === null) {
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
cancelAnimationFrame(this._positionFrame);
|
|
1286
|
+
this._positionFrame = null;
|
|
1287
|
+
}
|
|
1288
|
+
_updatePositionNow() {
|
|
1289
|
+
if (!this._overlayRef?.hasAttached()) {
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
if (isMobilePopoverViewport() && this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
const widthConfig = this._getWidthConfig();
|
|
1296
|
+
if (widthConfig.width) {
|
|
1297
|
+
this._overlayRef.updateSize(widthConfig);
|
|
1298
|
+
}
|
|
1299
|
+
this._overlayRef.updatePosition();
|
|
1300
|
+
this._applyMobilePopoverPosition(this._componentRef?.instance.position() ?? this.zPosition());
|
|
1301
|
+
}
|
|
1302
|
+
_applyMobilePopoverPosition(position) {
|
|
1303
|
+
if (!isMobilePopoverViewport() || !this._overlayRef?.hasAttached()) {
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
const { overlayElement } = this._overlayRef;
|
|
1307
|
+
const { visualViewport } = window;
|
|
1308
|
+
const styles = getMobilePopoverPaneStyles({
|
|
1309
|
+
position,
|
|
1310
|
+
triggerRect: this._getTriggerElement().getBoundingClientRect(),
|
|
1311
|
+
overlayRect: overlayElement.getBoundingClientRect(),
|
|
1312
|
+
offset: this.zOffset(),
|
|
1313
|
+
viewportWidth: visualViewport?.width ?? window.innerWidth,
|
|
1314
|
+
viewportHeight: visualViewport?.height ?? window.innerHeight,
|
|
1315
|
+
});
|
|
1316
|
+
this._setOverlayPaneStyles(styles);
|
|
1317
|
+
}
|
|
1318
|
+
_isTriggerVisibleInViewport() {
|
|
1319
|
+
const { visualViewport } = window;
|
|
1320
|
+
return isPopoverTriggerVisibleInViewport({
|
|
1321
|
+
triggerRect: this._getTriggerElement().getBoundingClientRect(),
|
|
1322
|
+
viewportWidth: visualViewport?.width ?? window.innerWidth,
|
|
1323
|
+
viewportHeight: visualViewport?.height ?? window.innerHeight,
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
_setOverlayPaneStyles(styles) {
|
|
1327
|
+
for (const key of ['top', 'left', 'right', 'bottom', 'transform']) {
|
|
1328
|
+
this._renderer.setStyle(this._overlayRef?.overlayElement, key, styles[key]);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1061
1331
|
_setupPopoverHover() {
|
|
1062
1332
|
const overlayElement = this._overlayRef?.overlayElement;
|
|
1063
1333
|
if (!overlayElement) {
|
|
@@ -1104,7 +1374,7 @@ class ZPopoverDirective {
|
|
|
1104
1374
|
this._listenerCleanups = [];
|
|
1105
1375
|
}
|
|
1106
1376
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZPopoverDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1107
|
-
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 });
|
|
1377
|
+
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 } }, outputs: { zShow: "zShow", zHide: "zHide", zHideStart: "zHideStart", zControl: "zControl", zPositionChange: "zPositionChange", zOutsideClick: "zOutsideClick" }, exportAs: ["zPopover"], ngImport: i0 });
|
|
1108
1378
|
}
|
|
1109
1379
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZPopoverDirective, decorators: [{
|
|
1110
1380
|
type: Directive,
|
|
@@ -1113,7 +1383,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
|
|
|
1113
1383
|
standalone: true,
|
|
1114
1384
|
exportAs: 'zPopover',
|
|
1115
1385
|
}]
|
|
1116
|
-
}], 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"] }] } });
|
|
1386
|
+
}], 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 }] }], 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"] }] } });
|
|
1117
1387
|
|
|
1118
1388
|
/**
|
|
1119
1389
|
* Generated bundle index. Do not edit.
|