@sebgroup/green-angular 1.5.1 → 1.6.0
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/esm2020/index.mjs +2 -1
- package/esm2020/lib/context-menu/context-menu.component.mjs +100 -0
- package/esm2020/lib/context-menu/context-menu.module.mjs +18 -0
- package/esm2020/lib/context-menu/index.mjs +3 -0
- package/esm2020/lib/green-angular.module.mjs +5 -1
- package/fesm2015/sebgroup-green-angular.mjs +118 -2
- package/fesm2015/sebgroup-green-angular.mjs.map +1 -1
- package/fesm2020/sebgroup-green-angular.mjs +116 -2
- package/fesm2020/sebgroup-green-angular.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/lib/context-menu/context-menu.component.d.ts +26 -0
- package/lib/context-menu/context-menu.module.d.ts +8 -0
- package/lib/context-menu/index.d.ts +2 -0
- package/lib/green-angular.module.d.ts +3 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Component, Input, Output, ContentChildren, NgModule, ChangeDetectionStrategy, HostBinding, Directive, Injector, Inject, ViewChild, ContentChild } from '@angular/core';
|
|
2
|
+
import { EventEmitter, Component, Input, Output, ContentChildren, NgModule, ChangeDetectionStrategy, HostBinding, Directive, Injector, Inject, ViewChild, ContentChild, HostListener } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { randomId, dropdownValues, createDropdown, months, years, createDatepicker, calculateDegrees, sliderColors, getSliderTrackBackground, PaginationI18n } from '@sebgroup/extract';
|
|
@@ -1099,6 +1099,117 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
1099
1099
|
}]
|
|
1100
1100
|
}] });
|
|
1101
1101
|
|
|
1102
|
+
class NggContextMenuComponent {
|
|
1103
|
+
constructor(elementRef) {
|
|
1104
|
+
this.elementRef = elementRef;
|
|
1105
|
+
this.direction = 'ltr';
|
|
1106
|
+
this.menuItems = [];
|
|
1107
|
+
this.menuItemTemplate = null;
|
|
1108
|
+
this.menuAnchorTemplate = null;
|
|
1109
|
+
this.contextMenuItemClicked = new EventEmitter();
|
|
1110
|
+
this.isActive = false;
|
|
1111
|
+
this.top = '0px';
|
|
1112
|
+
this.left = '0px';
|
|
1113
|
+
}
|
|
1114
|
+
onDocumentClick(target) {
|
|
1115
|
+
if (!this.isActive) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const contextMenuElement = this.elementRef.nativeElement;
|
|
1119
|
+
if (!contextMenuElement.contains(target)) {
|
|
1120
|
+
this.close();
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
open() {
|
|
1124
|
+
if (this.isActive) {
|
|
1125
|
+
this.close();
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
const anchor = this.anchor?.nativeElement;
|
|
1129
|
+
const buttonRect = anchor.getBoundingClientRect();
|
|
1130
|
+
const left = this.calculateLeft(this.direction, buttonRect);
|
|
1131
|
+
const top = this.calculateTop(buttonRect.bottom);
|
|
1132
|
+
this.left = `${left}px`;
|
|
1133
|
+
this.top = `${top}px`;
|
|
1134
|
+
this.isActive = true;
|
|
1135
|
+
}
|
|
1136
|
+
close() {
|
|
1137
|
+
this.isActive = false;
|
|
1138
|
+
}
|
|
1139
|
+
onItemClick(item) {
|
|
1140
|
+
this.contextMenuItemClicked.emit(item);
|
|
1141
|
+
this.close();
|
|
1142
|
+
}
|
|
1143
|
+
onMenuItemKeyDown(event, menuItem) {
|
|
1144
|
+
switch (event.key) {
|
|
1145
|
+
case 'Enter':
|
|
1146
|
+
case ' ':
|
|
1147
|
+
event.preventDefault();
|
|
1148
|
+
this.onItemClick(menuItem);
|
|
1149
|
+
break;
|
|
1150
|
+
default:
|
|
1151
|
+
break;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
calculateTop(buttonRectBottom) {
|
|
1155
|
+
return buttonRectBottom + window.pageYOffset;
|
|
1156
|
+
}
|
|
1157
|
+
calculateLeft(direction, buttonRect) {
|
|
1158
|
+
const popover = this.popover?.nativeElement;
|
|
1159
|
+
const popoverWidth = popover?.offsetWidth || 0;
|
|
1160
|
+
switch (direction) {
|
|
1161
|
+
case 'rtl':
|
|
1162
|
+
return popoverWidth <= buttonRect.left
|
|
1163
|
+
? buttonRect.right - popoverWidth
|
|
1164
|
+
: buttonRect.left;
|
|
1165
|
+
case 'ltr':
|
|
1166
|
+
default:
|
|
1167
|
+
return buttonRect.right + popoverWidth <= window.innerWidth
|
|
1168
|
+
? buttonRect.left
|
|
1169
|
+
: buttonRect.right - popoverWidth;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
NggContextMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NggContextMenuComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1174
|
+
NggContextMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: NggContextMenuComponent, selector: "ngg-context-menu", inputs: { direction: "direction", menuItems: "menuItems", menuItemTemplate: "menuItemTemplate", menuAnchorTemplate: "menuAnchorTemplate" }, outputs: { contextMenuItemClicked: "contextMenuItemClicked" }, host: { listeners: { "document:click": "onDocumentClick($event.target)" } }, viewQueries: [{ propertyName: "popover", first: true, predicate: ["contextMenuPopover"], descendants: true }, { propertyName: "anchor", first: true, predicate: ["contextMenuAnchor"], descendants: true }], ngImport: i0, template: "<button #contextMenuAnchor class=\"ghost small\" (click)=\"open()\">\n <ng-container\n [ngTemplateOutlet]=\"menuAnchorTemplate ?? defaultButtonTemplate\"\n >\n </ng-container>\n</button>\n\n<div\n class=\"popover popover-context-menu\"\n [class.active]=\"isActive\"\n [style.top]=\"top\"\n [style.left]=\"left\"\n #contextMenuPopover\n>\n <ul role=\"listbox\">\n <li\n *ngFor=\"let menuItem of menuItems\"\n (click)=\"onItemClick(menuItem)\"\n tabindex=\"0\"\n (keydown)=\"onMenuItemKeyDown($event, menuItem)\"\n >\n <ng-container\n [ngTemplateOutlet]=\"menuItemTemplate ?? defaultMenuItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: menuItem }\"\n >\n </ng-container>\n </li>\n </ul>\n</div>\n\n<ng-template #defaultMenuItemTemplate let-menuItem>\n <span>{{ menuItem.label }}</span>\n</ng-template>\n\n<ng-template #defaultButtonTemplate>\n <i class=\"sg-icon sg-icon-ellipsis\">Open context menu</i>\n</ng-template>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
1175
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NggContextMenuComponent, decorators: [{
|
|
1176
|
+
type: Component,
|
|
1177
|
+
args: [{ selector: 'ngg-context-menu', template: "<button #contextMenuAnchor class=\"ghost small\" (click)=\"open()\">\n <ng-container\n [ngTemplateOutlet]=\"menuAnchorTemplate ?? defaultButtonTemplate\"\n >\n </ng-container>\n</button>\n\n<div\n class=\"popover popover-context-menu\"\n [class.active]=\"isActive\"\n [style.top]=\"top\"\n [style.left]=\"left\"\n #contextMenuPopover\n>\n <ul role=\"listbox\">\n <li\n *ngFor=\"let menuItem of menuItems\"\n (click)=\"onItemClick(menuItem)\"\n tabindex=\"0\"\n (keydown)=\"onMenuItemKeyDown($event, menuItem)\"\n >\n <ng-container\n [ngTemplateOutlet]=\"menuItemTemplate ?? defaultMenuItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: menuItem }\"\n >\n </ng-container>\n </li>\n </ul>\n</div>\n\n<ng-template #defaultMenuItemTemplate let-menuItem>\n <span>{{ menuItem.label }}</span>\n</ng-template>\n\n<ng-template #defaultButtonTemplate>\n <i class=\"sg-icon sg-icon-ellipsis\">Open context menu</i>\n</ng-template>\n" }]
|
|
1178
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { direction: [{
|
|
1179
|
+
type: Input
|
|
1180
|
+
}], menuItems: [{
|
|
1181
|
+
type: Input
|
|
1182
|
+
}], menuItemTemplate: [{
|
|
1183
|
+
type: Input
|
|
1184
|
+
}], menuAnchorTemplate: [{
|
|
1185
|
+
type: Input
|
|
1186
|
+
}], contextMenuItemClicked: [{
|
|
1187
|
+
type: Output
|
|
1188
|
+
}], popover: [{
|
|
1189
|
+
type: ViewChild,
|
|
1190
|
+
args: ['contextMenuPopover']
|
|
1191
|
+
}], anchor: [{
|
|
1192
|
+
type: ViewChild,
|
|
1193
|
+
args: ['contextMenuAnchor']
|
|
1194
|
+
}], onDocumentClick: [{
|
|
1195
|
+
type: HostListener,
|
|
1196
|
+
args: ['document:click', ['$event.target']]
|
|
1197
|
+
}] } });
|
|
1198
|
+
|
|
1199
|
+
class NggContextMenuModule {
|
|
1200
|
+
}
|
|
1201
|
+
NggContextMenuModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NggContextMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1202
|
+
NggContextMenuModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: NggContextMenuModule, declarations: [NggContextMenuComponent], imports: [CommonModule], exports: [NggContextMenuComponent] });
|
|
1203
|
+
NggContextMenuModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NggContextMenuModule, imports: [CommonModule] });
|
|
1204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NggContextMenuModule, decorators: [{
|
|
1205
|
+
type: NgModule,
|
|
1206
|
+
args: [{
|
|
1207
|
+
declarations: [NggContextMenuComponent],
|
|
1208
|
+
imports: [CommonModule],
|
|
1209
|
+
exports: [NggContextMenuComponent],
|
|
1210
|
+
}]
|
|
1211
|
+
}] });
|
|
1212
|
+
|
|
1102
1213
|
class NggInPageWizardStepCardComponent {
|
|
1103
1214
|
constructor() {
|
|
1104
1215
|
this.handleNextClick = new EventEmitter();
|
|
@@ -1172,6 +1283,7 @@ NggModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.
|
|
|
1172
1283
|
NggProgressCircleModule,
|
|
1173
1284
|
NggSegmentedControlModule,
|
|
1174
1285
|
NggSliderModule,
|
|
1286
|
+
NggContextMenuModule,
|
|
1175
1287
|
NggInPageWizardModule] });
|
|
1176
1288
|
NggModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NggModule, imports: [CommonModule, NggAccordionModule,
|
|
1177
1289
|
NggBadgeModule,
|
|
@@ -1182,6 +1294,7 @@ NggModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.
|
|
|
1182
1294
|
NggProgressCircleModule,
|
|
1183
1295
|
NggSegmentedControlModule,
|
|
1184
1296
|
NggSliderModule,
|
|
1297
|
+
NggContextMenuModule,
|
|
1185
1298
|
NggInPageWizardModule] });
|
|
1186
1299
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NggModule, decorators: [{
|
|
1187
1300
|
type: NgModule,
|
|
@@ -1198,6 +1311,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
1198
1311
|
NggProgressCircleModule,
|
|
1199
1312
|
NggSegmentedControlModule,
|
|
1200
1313
|
NggSliderModule,
|
|
1314
|
+
NggContextMenuModule,
|
|
1201
1315
|
NggInPageWizardModule,
|
|
1202
1316
|
],
|
|
1203
1317
|
}]
|
|
@@ -1392,5 +1506,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
1392
1506
|
* Generated bundle index. Do not edit.
|
|
1393
1507
|
*/
|
|
1394
1508
|
|
|
1395
|
-
export { NggAccordionComponent, NggAccordionListItemComponent, NggAccordionModule, NggBadgeComponent, NggBadgeModule, NggButtonComponent, NggButtonModule, NggDatepickerComponent, NggDatepickerModule, NggDropdownComponent, NggDropdownModule, NggDropdownOptionDirective, NggInPageWizardModule, NggInPageWizardStepCardComponent, NggModalBodyComponent, NggModalComponent, NggModalFooterComponent, NggModalHeaderComponent, NggModalModule, NggModule, NggPaginationComponent, NggPaginationModule, NggProgressCircleComponent, NggProgressCircleModule, NggSegmentedControlComponent, NggSegmentedControlModule, NggSliderComponent, NggSliderModule, dateValidator };
|
|
1509
|
+
export { NggAccordionComponent, NggAccordionListItemComponent, NggAccordionModule, NggBadgeComponent, NggBadgeModule, NggButtonComponent, NggButtonModule, NggContextMenuComponent, NggContextMenuModule, NggDatepickerComponent, NggDatepickerModule, NggDropdownComponent, NggDropdownModule, NggDropdownOptionDirective, NggInPageWizardModule, NggInPageWizardStepCardComponent, NggModalBodyComponent, NggModalComponent, NggModalFooterComponent, NggModalHeaderComponent, NggModalModule, NggModule, NggPaginationComponent, NggPaginationModule, NggProgressCircleComponent, NggProgressCircleModule, NggSegmentedControlComponent, NggSegmentedControlModule, NggSliderComponent, NggSliderModule, dateValidator };
|
|
1396
1510
|
//# sourceMappingURL=sebgroup-green-angular.mjs.map
|