@dotglitch/ngx-common 1.0.7 → 1.0.8
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/directives/menu.directive.d.ts +1 -1
- package/esm2020/directives/menu.directive.mjs +10 -7
- package/fesm2015/dotglitch-ngx-common.mjs +9 -6
- package/fesm2015/dotglitch-ngx-common.mjs.map +1 -1
- package/fesm2020/dotglitch-ngx-common.mjs +9 -6
- package/fesm2020/dotglitch-ngx-common.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -703,7 +703,7 @@ class MenuDirective {
|
|
|
703
703
|
el.onclick = this.openMenu.bind(this);
|
|
704
704
|
el.addEventListener('contextmenu', (e) => {
|
|
705
705
|
e.preventDefault();
|
|
706
|
-
this.openMenu(e);
|
|
706
|
+
this.openMenu(e, this.ctxMenuItems);
|
|
707
707
|
});
|
|
708
708
|
}
|
|
709
709
|
if (!this.config?.trigger) {
|
|
@@ -715,7 +715,7 @@ class MenuDirective {
|
|
|
715
715
|
if (t == "contextmenu") {
|
|
716
716
|
el.addEventListener(t, (e) => {
|
|
717
717
|
e.preventDefault();
|
|
718
|
-
this.openMenu(e);
|
|
718
|
+
this.openMenu(e, this.ctxMenuItems);
|
|
719
719
|
});
|
|
720
720
|
}
|
|
721
721
|
else {
|
|
@@ -724,10 +724,11 @@ class MenuDirective {
|
|
|
724
724
|
});
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
|
-
async openMenu(evt) {
|
|
727
|
+
async openMenu(evt, items = this.menuItems) {
|
|
728
728
|
const el = this.viewContainer.element.nativeElement;
|
|
729
729
|
el.classList.add("ngx-menu-open");
|
|
730
|
-
|
|
730
|
+
const isCtxEvent = evt.button == 2;
|
|
731
|
+
return openMenu(this.dialog, items, this.data, evt, this.config, isCtxEvent ? null : el)
|
|
731
732
|
.then((...res) => {
|
|
732
733
|
el.classList.remove("ngx-menu-open");
|
|
733
734
|
return res;
|
|
@@ -778,12 +779,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
778
779
|
}] } });
|
|
779
780
|
// Helper to open the menu without using the directive.
|
|
780
781
|
const openMenu = async (dialog, menuItems, data, evt, config = {}, el) => {
|
|
782
|
+
// console.log({ dialog, menuItems, data, evt, config, el });
|
|
781
783
|
evt.preventDefault();
|
|
782
784
|
evt.stopPropagation();
|
|
783
|
-
|
|
784
|
-
const specificId = crypto.randomUUID();
|
|
785
|
+
// Apply defaults.
|
|
785
786
|
if (!config.alignment)
|
|
786
787
|
config.alignment = "start";
|
|
788
|
+
const cords = getPosition(el || evt, config, await calcMenuItemBounds(menuItems, data));
|
|
789
|
+
const specificId = crypto.randomUUID();
|
|
787
790
|
return new Promise(res => {
|
|
788
791
|
dialog.open(MenuComponent, {
|
|
789
792
|
data: {
|