@cuby-ui/core 0.0.60 → 0.0.64
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/components/context-menu/context-menu.component.d.ts +4 -0
- package/esm2020/components/context-menu/context-menu.component.mjs +22 -8
- package/fesm2015/cuby-ui-core.mjs +21 -7
- package/fesm2015/cuby-ui-core.mjs.map +1 -1
- package/fesm2020/cuby-ui-core.mjs +21 -7
- package/fesm2020/cuby-ui-core.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -5,8 +5,8 @@ import { CommonModule, DOCUMENT } from '@angular/common';
|
|
|
5
5
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
6
6
|
import { cuiIsIcon, CUI_ICONS } from '@cuby-ui/icons';
|
|
7
7
|
import * as i2 from '@cuby-ui/cdk';
|
|
8
|
-
import { cuiCreateToken, cuiCreateTokenFromFactory, CuiDestroyService, CuiLetDirective, CuiFilterPipe, CuiPopoverService, CUI_LOCAL_STORAGE, CuiItemDirective, CuiClickOutsideDirective, CuiTargetDirective, cuiProvide, CuiAutoResizingDirective } from '@cuby-ui/cdk';
|
|
9
|
-
import { BehaviorSubject, takeUntil } from 'rxjs';
|
|
8
|
+
import { cuiCreateToken, cuiCreateTokenFromFactory, CuiDestroyService, CuiLetDirective, CuiFilterPipe, CuiPopoverService, CUI_LOCAL_STORAGE, CuiItemDirective, CUI_WINDOW, CuiClickOutsideDirective, CuiTargetDirective, cuiProvide, CuiAutoResizingDirective } from '@cuby-ui/cdk';
|
|
9
|
+
import { BehaviorSubject, takeUntil, fromEvent, take } from 'rxjs';
|
|
10
10
|
import * as i2$1 from '@angular/forms';
|
|
11
11
|
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
12
12
|
import Quill from 'quill';
|
|
@@ -725,6 +725,7 @@ class CuiContextMenuComponent {
|
|
|
725
725
|
this.element = inject(ElementRef).nativeElement;
|
|
726
726
|
this.document = inject(DOCUMENT);
|
|
727
727
|
this.documentElement = this.document.documentElement;
|
|
728
|
+
this.window = inject(CUI_WINDOW);
|
|
728
729
|
this.destroy$ = inject(CuiDestroyService, { self: true });
|
|
729
730
|
this.cuiClickOutsideDirective = inject(CuiClickOutsideDirective, { self: true });
|
|
730
731
|
this.cuiTargetDirective = inject(CuiTargetDirective, { self: true });
|
|
@@ -744,7 +745,7 @@ class CuiContextMenuComponent {
|
|
|
744
745
|
item.command?.();
|
|
745
746
|
}
|
|
746
747
|
onClose() {
|
|
747
|
-
this.
|
|
748
|
+
this.close();
|
|
748
749
|
}
|
|
749
750
|
onStopClickPropagation(event) {
|
|
750
751
|
event.stopPropagation();
|
|
@@ -767,6 +768,7 @@ class CuiContextMenuComponent {
|
|
|
767
768
|
this.isVisible = !this.isVisible;
|
|
768
769
|
if (this.isVisible) {
|
|
769
770
|
this.changePosition(clientX, clientY);
|
|
771
|
+
this.initHidingSubscription();
|
|
770
772
|
}
|
|
771
773
|
this.changeDetectorRef.markForCheck();
|
|
772
774
|
};
|
|
@@ -774,6 +776,21 @@ class CuiContextMenuComponent {
|
|
|
774
776
|
.pipe(takeUntil(this.destroy$))
|
|
775
777
|
.subscribe(this.targetEventListener);
|
|
776
778
|
}
|
|
779
|
+
initHidingSubscription() {
|
|
780
|
+
this.initHidingFromWindowEvent('scroll');
|
|
781
|
+
this.initHidingFromWindowEvent('resize');
|
|
782
|
+
}
|
|
783
|
+
initHidingFromWindowEvent(eventName) {
|
|
784
|
+
fromEvent(this.window, eventName)
|
|
785
|
+
.pipe(take(1))
|
|
786
|
+
.subscribe(() => {
|
|
787
|
+
this.close();
|
|
788
|
+
this.changeDetectorRef.markForCheck();
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
close() {
|
|
792
|
+
this.isVisible = false;
|
|
793
|
+
}
|
|
777
794
|
changePosition(x, y) {
|
|
778
795
|
this.isHidden = true;
|
|
779
796
|
setTimeout(() => {
|
|
@@ -798,7 +815,7 @@ class CuiContextMenuComponent {
|
|
|
798
815
|
}
|
|
799
816
|
}
|
|
800
817
|
CuiContextMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiContextMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
801
|
-
CuiContextMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: CuiContextMenuComponent, selector: "cui-context-menu[items][target]", inputs: { items: "items", target: "target" }, host: { listeners: { "window:
|
|
818
|
+
CuiContextMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: CuiContextMenuComponent, selector: "cui-context-menu[items][target]", inputs: { items: "items", target: "target" }, host: { listeners: { "window:resize": "onClose()", "click": "onStopClickPropagation($event)" }, properties: { "class._hidden": "this.isHidden", "style.left.px": "this.clientX", "style.top.px": "this.clientY" } }, providers: [CuiDestroyService], hostDirectives: [{ directive: i2.CuiClickOutsideDirective }, { directive: i2.CuiTargetDirective, inputs: ["ccTarget", "target"] }], ngImport: i0, template: "<ul\n *ngIf=\"isVisible\"\n class=\"c-ul\"\n>\n <li\n *ngFor=\"let item of items; trackBy: trackByFn\"\n [style.color]=\"item.color\"\n >\n <button\n class=\"c-button\"\n (click)=\"onSelect(item)\"\n >\n <cui-svg\n *ngIf=\"item.icon\"\n [icon]=\"item.icon\"\n [color]=\"item.color\"\n ></cui-svg>\n <span>{{ item.label }}</span>\n </button>\n </li>\n</ul>\n", styles: [":host{position:fixed;z-index:2;display:block;width:268px;border-radius:8px}:host._hidden{visibility:hidden}.c-ul{padding:7px 0;margin:0;list-style:none;font-weight:400;font-size:14px;line-height:20px;box-shadow:0 1px 4px #0000000a,0 1px 4px #0000000a;border:1px solid var(--cui-base-200);border-radius:inherit;background:var(--cui-base-0);color:var(--cui-base-900);font-family:var(--cui-main-font)}.c-button{padding:8px 11px 8px 0;border:0;outline:none;cursor:pointer;appearance:none;color:inherit;font:inherit;background:inherit;text-decoration:none;-webkit-tap-highlight-color:transparent;padding:8px 11px;width:100%;display:flex;align-items:center;gap:12px}.c-button:active{background:var(--cui-base-50)}@media (hover: hover){.c-button:hover{background:var(--cui-base-50)}}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: CuiSvgComponent, selector: "cui-svg[icon]", inputs: ["width", "height", "strokeWidth", "color", "icon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
802
819
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiContextMenuComponent, decorators: [{
|
|
803
820
|
type: Component,
|
|
804
821
|
args: [{ selector: 'cui-context-menu[items][target]', changeDetection: ChangeDetectionStrategy.OnPush, providers: [CuiDestroyService], hostDirectives: [
|
|
@@ -822,9 +839,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
822
839
|
type: HostBinding,
|
|
823
840
|
args: ['style.top.px']
|
|
824
841
|
}], onClose: [{
|
|
825
|
-
type: HostListener,
|
|
826
|
-
args: ['window:scroll']
|
|
827
|
-
}, {
|
|
828
842
|
type: HostListener,
|
|
829
843
|
args: ['window:resize']
|
|
830
844
|
}], onStopClickPropagation: [{
|