@shival99/z-ui 2.3.11 → 2.4.1
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-drawer.mjs +7 -2
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs +4 -369
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-icon.mjs +20 -11
- package/fesm2022/shival99-z-ui-components-z-icon.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-media-player.mjs +54 -45
- package/fesm2022/shival99-z-ui-components-z-media-player.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-modal.mjs +12 -2
- package/fesm2022/shival99-z-ui-components-z-modal.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-popover.mjs +75 -43
- package/fesm2022/shival99-z-ui-components-z-popover.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs +17 -11
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shival99-z-ui-components-z-autocomplete.d.ts +1 -1
- package/types/shival99-z-ui-components-z-calendar.d.ts +4 -4
- package/types/shival99-z-ui-components-z-editor.d.ts +1 -1
- package/types/shival99-z-ui-components-z-media-player.d.ts +1 -1
- package/types/shival99-z-ui-components-z-modal.d.ts +1 -1
- package/types/shival99-z-ui-components-z-popover.d.ts +1 -0
- package/types/shival99-z-ui-components-z-select.d.ts +1 -1
- package/types/shival99-z-ui-components-z-table.d.ts +1 -1
- package/types/shival99-z-ui-components-z-tabs.d.ts +6 -2
- package/types/shival99-z-ui-components-z-toast.d.ts +2 -2
- package/types/shival99-z-ui-components-z-upload.d.ts +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NgTemplateOutlet, DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { signal, computed, ChangeDetectionStrategy, Component, inject, Renderer2, DestroyRef, PLATFORM_ID, viewChild, output, input, ElementRef, Directive } from '@angular/core';
|
|
3
|
+
import { signal, computed, ChangeDetectionStrategy, Component, inject, Renderer2, DestroyRef, PLATFORM_ID, NgZone, viewChild, output, input, ElementRef, Directive } from '@angular/core';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { Z_OVERLAY_FALLBACK_ORDER, ZOverlayService, startZOverlayAutoUpdate, computeZOverlayPlacement } from '@shival99/z-ui/components/z-overlay';
|
|
6
6
|
import { ZOverlayContainerService, ZOverlayZIndexService } from '@shival99/z-ui/services';
|
|
@@ -100,6 +100,11 @@ class ZPopoverContentComponent {
|
|
|
100
100
|
close: this.closeHandler(),
|
|
101
101
|
}), /* @ts-ignore */
|
|
102
102
|
...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
103
|
+
templateContext = computed(() => {
|
|
104
|
+
const context = this.context();
|
|
105
|
+
return { $implicit: context, close: context.close };
|
|
106
|
+
}, /* @ts-ignore */
|
|
107
|
+
...(ngDevMode ? [{ debugName: "templateContext" }] : /* istanbul ignore next */ []));
|
|
103
108
|
classes = computed(() => {
|
|
104
109
|
const baseClasses = zPopoverVariants({
|
|
105
110
|
zPosition: this.position(),
|
|
@@ -159,10 +164,7 @@ class ZPopoverContentComponent {
|
|
|
159
164
|
|
|
160
165
|
<!-- Content -->
|
|
161
166
|
<div [class]="contentClasses()">
|
|
162
|
-
<ng-container
|
|
163
|
-
[ngTemplateOutlet]="content()"
|
|
164
|
-
[ngTemplateOutletContext]="{ $implicit: context(), close: context().close }"
|
|
165
|
-
/>
|
|
167
|
+
<ng-container [ngTemplateOutlet]="content()" [ngTemplateOutletContext]="templateContext()" />
|
|
166
168
|
</div>
|
|
167
169
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
168
170
|
}
|
|
@@ -180,10 +182,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImpor
|
|
|
180
182
|
|
|
181
183
|
<!-- Content -->
|
|
182
184
|
<div [class]="contentClasses()">
|
|
183
|
-
<ng-container
|
|
184
|
-
[ngTemplateOutlet]="content()"
|
|
185
|
-
[ngTemplateOutletContext]="{ $implicit: context(), close: context().close }"
|
|
186
|
-
/>
|
|
185
|
+
<ng-container [ngTemplateOutlet]="content()" [ngTemplateOutletContext]="templateContext()" />
|
|
187
186
|
</div>
|
|
188
187
|
`,
|
|
189
188
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -224,6 +223,7 @@ class ZPopoverComponent {
|
|
|
224
223
|
_document = inject(DOCUMENT);
|
|
225
224
|
_overlayContainerService = inject(ZOverlayContainerService);
|
|
226
225
|
_zIndexService = inject(ZOverlayZIndexService);
|
|
226
|
+
_zone = inject(NgZone);
|
|
227
227
|
_trigger = viewChild.required('trigger', /* @ts-ignore */
|
|
228
228
|
...(ngDevMode ? [{ debugName: "_trigger" }] : /* istanbul ignore next */ []));
|
|
229
229
|
zShow = output();
|
|
@@ -421,7 +421,7 @@ class ZPopoverComponent {
|
|
|
421
421
|
return;
|
|
422
422
|
}
|
|
423
423
|
if (this.zScrollClose()) {
|
|
424
|
-
this.hideImmediate();
|
|
424
|
+
this._zone.run(() => this.hideImmediate());
|
|
425
425
|
return;
|
|
426
426
|
}
|
|
427
427
|
if (ticking) {
|
|
@@ -433,16 +433,18 @@ class ZPopoverComponent {
|
|
|
433
433
|
return;
|
|
434
434
|
}
|
|
435
435
|
ticking = true;
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
this._zone.runOutsideAngular(() => {
|
|
437
|
+
requestAnimationFrame(() => {
|
|
438
|
+
if (this.zSticky() && !this._isTriggerVisibleInViewport()) {
|
|
439
|
+
ticking = false;
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
void this._updatePositionNow();
|
|
438
443
|
ticking = false;
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
void this._updatePositionNow();
|
|
442
|
-
ticking = false;
|
|
444
|
+
});
|
|
443
445
|
});
|
|
444
446
|
};
|
|
445
|
-
this._document.addEventListener('scroll', onScroll, true);
|
|
447
|
+
this._zone.runOutsideAngular(() => this._document.addEventListener('scroll', onScroll, true));
|
|
446
448
|
this._scrollSubscription = {
|
|
447
449
|
unsubscribe: () => {
|
|
448
450
|
this._document.removeEventListener('scroll', onScroll, true);
|
|
@@ -463,8 +465,10 @@ class ZPopoverComponent {
|
|
|
463
465
|
}
|
|
464
466
|
this._schedulePositionUpdate();
|
|
465
467
|
};
|
|
466
|
-
|
|
467
|
-
|
|
468
|
+
this._zone.runOutsideAngular(() => {
|
|
469
|
+
window.addEventListener('resize', onResize);
|
|
470
|
+
window.visualViewport?.addEventListener('resize', onResize);
|
|
471
|
+
});
|
|
468
472
|
this._viewportResizeSubscription = {
|
|
469
473
|
unsubscribe: () => {
|
|
470
474
|
window.removeEventListener('resize', onResize);
|
|
@@ -475,7 +479,16 @@ class ZPopoverComponent {
|
|
|
475
479
|
}
|
|
476
480
|
async _showPopover() {
|
|
477
481
|
const content = this.zContent();
|
|
478
|
-
if (!content
|
|
482
|
+
if (!content) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (this._componentRef) {
|
|
486
|
+
if (!this._hideTimeout) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
this._clearHideTimeout();
|
|
490
|
+
this._componentRef.instance.state.set('open');
|
|
491
|
+
this._isVisible.set(true);
|
|
479
492
|
return;
|
|
480
493
|
}
|
|
481
494
|
if (!this._overlayRef) {
|
|
@@ -483,19 +496,23 @@ class ZPopoverComponent {
|
|
|
483
496
|
this._setupOutsideClick();
|
|
484
497
|
}
|
|
485
498
|
this._setupScrollClose();
|
|
486
|
-
|
|
487
|
-
|
|
499
|
+
const overlayRef = this._overlayRef;
|
|
500
|
+
if (!overlayRef) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const componentRef = (this._componentRef = overlayRef.attach(ZPopoverContentComponent));
|
|
504
|
+
componentRef.instance.setProps({
|
|
488
505
|
content,
|
|
489
506
|
position: this.zPosition(),
|
|
490
507
|
customClass: this.zClass(),
|
|
491
508
|
onClose: () => this.hide(),
|
|
492
509
|
showArrow: this.zShowArrow(),
|
|
493
510
|
});
|
|
494
|
-
await this._applyPosition();
|
|
495
|
-
if (
|
|
511
|
+
await this._zone.runOutsideAngular(() => this._applyPosition(overlayRef, componentRef));
|
|
512
|
+
if (this._overlayRef !== overlayRef || this._componentRef !== componentRef || this._destroyRef.destroyed) {
|
|
496
513
|
return; // đã bị dispose (hide/destroy) trong lúc chờ computePosition
|
|
497
514
|
}
|
|
498
|
-
this._autoUpdateCleanup = startZOverlayAutoUpdate(this._trigger().nativeElement,
|
|
515
|
+
this._autoUpdateCleanup = this._zone.runOutsideAngular(() => startZOverlayAutoUpdate(this._trigger().nativeElement, overlayRef.overlayElement, () => void this._applyPosition(overlayRef, componentRef), { ancestorScroll: false }));
|
|
499
516
|
if (this.zTrigger() === 'hover') {
|
|
500
517
|
this._setupPopoverHover();
|
|
501
518
|
}
|
|
@@ -526,25 +543,27 @@ class ZPopoverComponent {
|
|
|
526
543
|
}
|
|
527
544
|
_setupResizeObserver() {
|
|
528
545
|
this._resizeObserver?.disconnect();
|
|
529
|
-
this.
|
|
530
|
-
|
|
531
|
-
this.
|
|
546
|
+
this._zone.runOutsideAngular(() => {
|
|
547
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
548
|
+
if (this._overlayRef && this._isVisible()) {
|
|
549
|
+
this._schedulePositionUpdate();
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
this._resizeObserver.observe(this._trigger().nativeElement);
|
|
553
|
+
const wrapper = this._trigger().nativeElement.parentElement?.parentElement;
|
|
554
|
+
if (wrapper && wrapper !== document.body) {
|
|
555
|
+
this._resizeObserver.observe(wrapper);
|
|
532
556
|
}
|
|
533
557
|
});
|
|
534
|
-
this._resizeObserver.observe(this._trigger().nativeElement);
|
|
535
|
-
const wrapper = this._trigger().nativeElement.parentElement?.parentElement;
|
|
536
|
-
if (wrapper && wrapper !== document.body) {
|
|
537
|
-
this._resizeObserver.observe(wrapper);
|
|
538
|
-
}
|
|
539
558
|
}
|
|
540
559
|
_schedulePositionUpdate(force = false) {
|
|
541
560
|
if (this._positionFrame !== null) {
|
|
542
561
|
return;
|
|
543
562
|
}
|
|
544
|
-
this._positionFrame = requestAnimationFrame(() => {
|
|
563
|
+
this._positionFrame = this._zone.runOutsideAngular(() => requestAnimationFrame(() => {
|
|
545
564
|
this._positionFrame = null;
|
|
546
565
|
void this._updatePositionNow(force);
|
|
547
|
-
});
|
|
566
|
+
}));
|
|
548
567
|
}
|
|
549
568
|
_scheduleSettledPositionUpdate() {
|
|
550
569
|
this._clearViewportResizeTimeout();
|
|
@@ -575,12 +594,15 @@ class ZPopoverComponent {
|
|
|
575
594
|
}
|
|
576
595
|
await this._applyPosition();
|
|
577
596
|
}
|
|
578
|
-
async _applyPosition() {
|
|
579
|
-
if (!
|
|
597
|
+
async _applyPosition(expectedOverlayRef = this._overlayRef, expectedComponentRef = this._componentRef) {
|
|
598
|
+
if (!expectedOverlayRef ||
|
|
599
|
+
!expectedComponentRef ||
|
|
600
|
+
this._overlayRef !== expectedOverlayRef ||
|
|
601
|
+
this._componentRef !== expectedComponentRef) {
|
|
580
602
|
return;
|
|
581
603
|
}
|
|
582
604
|
const anchorElement = this._trigger().nativeElement;
|
|
583
|
-
const floatingElement =
|
|
605
|
+
const floatingElement = expectedOverlayRef.overlayElement;
|
|
584
606
|
const position = this.zPosition();
|
|
585
607
|
const result = await computeZOverlayPlacement({
|
|
586
608
|
reference: anchorElement,
|
|
@@ -591,12 +613,18 @@ class ZPopoverComponent {
|
|
|
591
613
|
push: true,
|
|
592
614
|
viewportPadding: 10,
|
|
593
615
|
});
|
|
594
|
-
if (
|
|
616
|
+
if (this._overlayRef !== expectedOverlayRef || this._componentRef !== expectedComponentRef) {
|
|
595
617
|
return;
|
|
596
618
|
}
|
|
597
619
|
floatingElement.style.left = `${result.x}px`;
|
|
598
620
|
floatingElement.style.top = `${result.y}px`;
|
|
599
|
-
|
|
621
|
+
if (expectedComponentRef.instance.position() !== result.placement) {
|
|
622
|
+
this._zone.run(() => {
|
|
623
|
+
if (this._overlayRef === expectedOverlayRef && this._componentRef === expectedComponentRef) {
|
|
624
|
+
expectedComponentRef.instance.position.set(result.placement);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}
|
|
600
628
|
}
|
|
601
629
|
_markViewportSettling() {
|
|
602
630
|
this._viewportSettlingUntil = Date.now() + 260;
|
|
@@ -656,17 +684,21 @@ class ZPopoverComponent {
|
|
|
656
684
|
}
|
|
657
685
|
}
|
|
658
686
|
_hidePopover() {
|
|
659
|
-
|
|
687
|
+
const componentRef = this._componentRef;
|
|
688
|
+
if (!componentRef || this._hideTimeout) {
|
|
660
689
|
return;
|
|
661
690
|
}
|
|
662
|
-
this.
|
|
691
|
+
this._isVisible.set(false);
|
|
692
|
+
componentRef.instance.state.set('closed');
|
|
663
693
|
this._hideTimeout = setTimeout(() => {
|
|
664
694
|
this._hideTimeout = null;
|
|
665
695
|
if (this._destroyRef.destroyed) {
|
|
666
696
|
return;
|
|
667
697
|
}
|
|
698
|
+
if (this._componentRef !== componentRef) {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
668
701
|
this._disposeOverlay();
|
|
669
|
-
this._isVisible.set(false);
|
|
670
702
|
this.zHide.emit();
|
|
671
703
|
}, Z_POPOVER_ANIMATION_DURATION);
|
|
672
704
|
}
|