ng-mat-multilevel-menu 7.0.2
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/esm2022/lib/animation.mjs +31 -0
- package/esm2022/lib/app.model.mjs +7 -0
- package/esm2022/lib/common-utils.mjs +9 -0
- package/esm2022/lib/constants.mjs +19 -0
- package/esm2022/lib/list-item/list-item-content/list-item-content.component.mjs +68 -0
- package/esm2022/lib/list-item/list-item.component.mjs +176 -0
- package/esm2022/lib/materials.module.mjs +35 -0
- package/esm2022/lib/multilevel-menu.service.mjs +93 -0
- package/esm2022/lib/ng-material-multilevel-menu.component.mjs +204 -0
- package/esm2022/lib/ng-material-multilevel-menu.module.mjs +36 -0
- package/esm2022/ng-mat-multilevel-menu.mjs +5 -0
- package/esm2022/public_api.mjs +9 -0
- package/fesm2022/ng-mat-multilevel-menu.mjs +651 -0
- package/fesm2022/ng-mat-multilevel-menu.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/animation.d.ts +3 -0
- package/lib/app.model.d.ts +52 -0
- package/lib/common-utils.d.ts +4 -0
- package/lib/constants.d.ts +18 -0
- package/lib/list-item/list-item-content/list-item-content.component.d.ts +20 -0
- package/lib/list-item/list-item.component.d.ts +41 -0
- package/lib/materials.module.d.ts +9 -0
- package/lib/multilevel-menu.service.d.ts +21 -0
- package/lib/ng-material-multilevel-menu.component.d.ts +38 -0
- package/lib/ng-material-multilevel-menu.module.d.ts +12 -0
- package/package.json +44 -0
- package/public_api.d.ts +5 -0
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
import * as i3 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Injectable, Component, Input, EventEmitter, Output, NgModule, ContentChild } from '@angular/core';
|
|
5
|
+
import * as i1 from '@angular/router';
|
|
6
|
+
import { NavigationEnd, RouterModule } from '@angular/router';
|
|
7
|
+
import { trigger, state, style, transition, group, animate } from '@angular/animations';
|
|
8
|
+
import { Subject } from 'rxjs';
|
|
9
|
+
import * as i4 from '@angular/cdk/bidi';
|
|
10
|
+
import * as i5 from '@angular/material/list';
|
|
11
|
+
import { MatListModule } from '@angular/material/list';
|
|
12
|
+
import * as i6 from '@angular/material/divider';
|
|
13
|
+
import * as i7 from '@angular/material/core';
|
|
14
|
+
import { MatRippleModule } from '@angular/material/core';
|
|
15
|
+
import * as i2 from '@angular/material/icon';
|
|
16
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
17
|
+
|
|
18
|
+
var ExpandCollapseStatusEnum;
|
|
19
|
+
(function (ExpandCollapseStatusEnum) {
|
|
20
|
+
ExpandCollapseStatusEnum["expand"] = "expand";
|
|
21
|
+
ExpandCollapseStatusEnum["collapse"] = "collapse";
|
|
22
|
+
ExpandCollapseStatusEnum["neutral"] = "neutral";
|
|
23
|
+
})(ExpandCollapseStatusEnum || (ExpandCollapseStatusEnum = {}));
|
|
24
|
+
|
|
25
|
+
const CONSTANT = {
|
|
26
|
+
PADDING_AT_START: true,
|
|
27
|
+
DEFAULT_CLASS_NAME: `amml-container`,
|
|
28
|
+
DEFAULT_LIST_CLASS_NAME: `amml-item`,
|
|
29
|
+
SELECTED_LIST_CLASS_NAME: `selected-amml-item`,
|
|
30
|
+
ACTIVE_ITEM_CLASS_NAME: `active-amml-item`,
|
|
31
|
+
DISABLED_ITEM_CLASS_NAME: `disabled-amml-item`,
|
|
32
|
+
SUBMENU_ITEM_CLASS_NAME: `amml-submenu`,
|
|
33
|
+
HAS_SUBMENU_ITEM_CLASS_NAME: `has-amml-submenu`,
|
|
34
|
+
DEFAULT_SELECTED_FONT_COLOR: `#1976d2`,
|
|
35
|
+
DEFAULT_LIST_BACKGROUND_COLOR: `transparent`,
|
|
36
|
+
DEFAULT_LIST_FONT_COLOR: `rgba(0,0,0,.87)`,
|
|
37
|
+
DEFAULT_HREF_TARGET_TYPE: '_self',
|
|
38
|
+
ERROR_MESSAGE: `Invalid data for material Multilevel List Component`,
|
|
39
|
+
POSSIBLE: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
|
|
40
|
+
YES: 'yes',
|
|
41
|
+
NO: 'no'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const SlideInOut = trigger('SlideInOut', [
|
|
45
|
+
state('in', style({ height: '*', opacity: 0 })),
|
|
46
|
+
transition(':leave', [
|
|
47
|
+
style({ height: '*', opacity: 0.2 }),
|
|
48
|
+
group([
|
|
49
|
+
animate(200, style({ height: 0 })),
|
|
50
|
+
animate('200ms ease-out', style({ opacity: 0 }))
|
|
51
|
+
])
|
|
52
|
+
]),
|
|
53
|
+
transition(':enter', [
|
|
54
|
+
style({ height: '0', opacity: 0 }),
|
|
55
|
+
group([
|
|
56
|
+
animate(200, style({ height: '*' })),
|
|
57
|
+
animate('400ms ease-out', style({ opacity: 1 }))
|
|
58
|
+
])
|
|
59
|
+
])
|
|
60
|
+
]);
|
|
61
|
+
const ExpandedLTR = trigger('ExpandedLTR', [
|
|
62
|
+
state('no', style({ transform: 'rotate(-90deg)' })),
|
|
63
|
+
state('yes', style({ transform: 'rotate(0deg)', })),
|
|
64
|
+
transition('no => yes', animate(200)),
|
|
65
|
+
transition('yes => no', animate(200))
|
|
66
|
+
]);
|
|
67
|
+
const ExpandedRTL = trigger('ExpandedRTL', [
|
|
68
|
+
state('no', style({ transform: 'rotate(90deg)' })),
|
|
69
|
+
state('yes', style({ transform: 'rotate(0deg)', })),
|
|
70
|
+
transition('no => yes', animate(200)),
|
|
71
|
+
transition('yes => no', animate(200))
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
class CommonUtils {
|
|
75
|
+
static { this.isNullOrUndefinedOrEmpty = function (object) {
|
|
76
|
+
return CommonUtils.isNullOrUndefined(object) || object === '';
|
|
77
|
+
}; }
|
|
78
|
+
static { this.isNullOrUndefined = function (object) {
|
|
79
|
+
return object === null || object === undefined;
|
|
80
|
+
}; }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
class MultilevelMenuService {
|
|
84
|
+
constructor() {
|
|
85
|
+
this.expandCollapseStatus = new Subject();
|
|
86
|
+
this.expandCollapseStatus$ = this.expandCollapseStatus.asObservable();
|
|
87
|
+
this.selectedMenuID = new Subject();
|
|
88
|
+
this.selectedMenuID$ = this.selectedMenuID.asObservable();
|
|
89
|
+
}
|
|
90
|
+
generateId() {
|
|
91
|
+
let text = '';
|
|
92
|
+
for (let i = 0; i < 20; i++) {
|
|
93
|
+
text += CONSTANT.POSSIBLE.charAt(Math.floor(Math.random() * CONSTANT.POSSIBLE.length));
|
|
94
|
+
}
|
|
95
|
+
return text;
|
|
96
|
+
}
|
|
97
|
+
addRandomId(nodes) {
|
|
98
|
+
nodes.forEach((node) => {
|
|
99
|
+
node.id = this.generateId();
|
|
100
|
+
if (node.items !== undefined) {
|
|
101
|
+
this.addRandomId(node.items);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
recursiveCheckId(node, nodeId) {
|
|
106
|
+
if (node.id === nodeId) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
if (node.items !== undefined) {
|
|
111
|
+
return node.items.some((nestedNode) => {
|
|
112
|
+
return this.recursiveCheckId(nestedNode, nodeId);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
findNodeRecursively({ nodes, link, id }) {
|
|
118
|
+
for (let nodeIndex = 0; nodeIndex < nodes.length; nodeIndex++) {
|
|
119
|
+
const node = nodes[nodeIndex];
|
|
120
|
+
for (const key in node) {
|
|
121
|
+
if (node.hasOwnProperty(key)) {
|
|
122
|
+
if (encodeURI(node.link) === link) {
|
|
123
|
+
this.foundLinkObject = node;
|
|
124
|
+
}
|
|
125
|
+
else if (node.id === id) {
|
|
126
|
+
this.foundLinkObject = node;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
if (node.items !== undefined) {
|
|
130
|
+
this.findNodeRecursively({
|
|
131
|
+
nodes: node.items,
|
|
132
|
+
link: link ? link : null,
|
|
133
|
+
id: id ? id : null
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
getMatchedObjectByUrl(nodes, link) {
|
|
142
|
+
this.findNodeRecursively({ nodes, link });
|
|
143
|
+
return this.foundLinkObject;
|
|
144
|
+
}
|
|
145
|
+
getMatchedObjectById(nodes, id) {
|
|
146
|
+
this.findNodeRecursively({ nodes, id });
|
|
147
|
+
return this.foundLinkObject;
|
|
148
|
+
}
|
|
149
|
+
// overrides key-value pipe's default reordering (by key) by implementing dummy comprarer function
|
|
150
|
+
// https://angular.io/api/common/KeyValuePipe#description
|
|
151
|
+
kvDummyComparerFn() {
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
setMenuExpandCollapseStatus(status) {
|
|
155
|
+
this.expandCollapseStatus.next(status ? status : ExpandCollapseStatusEnum.neutral);
|
|
156
|
+
}
|
|
157
|
+
selectMenuByID(menuID) {
|
|
158
|
+
this.selectedMenuID.next(menuID);
|
|
159
|
+
return this.foundLinkObject;
|
|
160
|
+
}
|
|
161
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MultilevelMenuService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
162
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MultilevelMenuService, providedIn: 'root' }); }
|
|
163
|
+
}
|
|
164
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MultilevelMenuService, decorators: [{
|
|
165
|
+
type: Injectable,
|
|
166
|
+
args: [{
|
|
167
|
+
providedIn: 'root'
|
|
168
|
+
}]
|
|
169
|
+
}] });
|
|
170
|
+
|
|
171
|
+
class ListItemContentComponent {
|
|
172
|
+
constructor() {
|
|
173
|
+
this.nodeConfiguration = null;
|
|
174
|
+
// NOOP
|
|
175
|
+
}
|
|
176
|
+
ngOnInit() {
|
|
177
|
+
// NOOP
|
|
178
|
+
}
|
|
179
|
+
getListIcon(node) {
|
|
180
|
+
if (!CommonUtils.isNullOrUndefinedOrEmpty(node.icon)) {
|
|
181
|
+
return `icon`;
|
|
182
|
+
}
|
|
183
|
+
else if (!CommonUtils.isNullOrUndefinedOrEmpty(node.faIcon)) {
|
|
184
|
+
return `faIcon`;
|
|
185
|
+
}
|
|
186
|
+
else if (!CommonUtils.isNullOrUndefinedOrEmpty(node.imageIcon)) {
|
|
187
|
+
return `imageIcon`;
|
|
188
|
+
}
|
|
189
|
+
else if (!CommonUtils.isNullOrUndefinedOrEmpty(node.svgIcon)) {
|
|
190
|
+
return `svgIcon`;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
return ``;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
getHrefTargetType() {
|
|
197
|
+
return this.node.hrefTargetType ? this.node.hrefTargetType : CONSTANT.DEFAULT_HREF_TARGET_TYPE;
|
|
198
|
+
}
|
|
199
|
+
getSelectedSvgIcon() {
|
|
200
|
+
return this.node.isSelected && this.node.activeSvgIcon ? this.node.activeSvgIcon : this.node.svgIcon;
|
|
201
|
+
}
|
|
202
|
+
getSelectedIcon() {
|
|
203
|
+
return this.node.isSelected && this.node.activeIcon ? this.node.activeIcon : this.node.icon;
|
|
204
|
+
}
|
|
205
|
+
getSelectedFaIcon() {
|
|
206
|
+
return this.node.isSelected && this.node.activeFaIcon ? this.node.activeFaIcon : this.node.faIcon;
|
|
207
|
+
}
|
|
208
|
+
getSelectedImageIcon() {
|
|
209
|
+
return this.node.isSelected && this.node.activeImageIcon ? this.node.activeImageIcon : this.node.imageIcon;
|
|
210
|
+
}
|
|
211
|
+
nodeExpandStatus() {
|
|
212
|
+
return this.node.expanded ? CONSTANT.YES : CONSTANT.NO;
|
|
213
|
+
}
|
|
214
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ListItemContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
215
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: ListItemContentComponent, selector: "ng-list-item-content", inputs: { node: "node", isRtlLayout: "isRtlLayout", listContentStyle: "listContentStyle", nodeConfiguration: "nodeConfiguration" }, ngImport: i0, template: "<ng-container *ngTemplateOutlet=\"node.externalRedirect ? redirectLinkTemplate : routerLinkTemplate\"></ng-container>\r\n\r\n<ng-template #redirectLinkTemplate>\r\n <a class=\"anml-link\" [href]=\"node.link\" [target]=\"getHrefTargetType()\" [ngStyle]=\"listContentStyle\">\r\n <ng-container *ngTemplateOutlet=\"isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet\"></ng-container>\r\n </a>\r\n</ng-template>\r\n\r\n<ng-template #routerLinkTemplate>\r\n <ng-container *ngIf=\"node.link && nodeConfiguration.interfaceWithRoute; else defaultContentContainer\">\r\n <a class=\"anml-link\" [routerLink]=\"node.link\" [ngStyle]=\"listContentStyle\">\r\n <ng-container *ngTemplateOutlet=\"isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet\"></ng-container>\r\n </a>\r\n </ng-container>\r\n</ng-template>\r\n\r\n<ng-template #defaultContentContainer>\r\n <a class=\"anml-link\" [ngStyle]=\"listContentStyle\">\r\n <ng-container *ngTemplateOutlet=\"isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet\"></ng-container>\r\n </a>\r\n</ng-template>\r\n\r\n<ng-template #linkLabelLtrOutlet>\r\n <div class=\"anml-data\" [dir]=\"'ltr'\">\r\n <ng-container *ngTemplateOutlet=\"iconContainer\"></ng-container>\r\n <span class=\"label\">{{node.label}}</span>\r\n </div>\r\n <div class=\"amml-icon-arrow-container\" *ngIf='node.hasChildren'>\r\n <mat-icon [@ExpandedLTR]=\"nodeExpandStatus()\">\r\n keyboard_arrow_down\r\n </mat-icon>\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #linkLabelRtlOutlet>\r\n <div class=\"anml-data\" [dir]=\"'rtl'\">\r\n <ng-container *ngTemplateOutlet=\"iconContainer\"></ng-container>\r\n <span class=\"label\">{{node.label}}</span>\r\n </div>\r\n <div class=\"amml-icon-arrow-container\" *ngIf='node.hasChildren'>\r\n <mat-icon [@ExpandedRTL]=\"nodeExpandStatus()\">\r\n keyboard_arrow_down\r\n </mat-icon>\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #iconContainer>\r\n <div class=\"icon-container\" [ngSwitch]=\"getListIcon(node)\">\r\n <span *ngSwitchCase=\"'faIcon'\" class=\"amml-icon amml-icon-fa\">\r\n <i [ngClass]=\"getSelectedFaIcon()\"></i>\r\n </span>\r\n <mat-icon *ngSwitchCase=\"'icon'\" class=\"amml-icon\">\r\n {{getSelectedIcon()}}\r\n </mat-icon>\r\n <mat-icon *ngSwitchCase=\"'svgIcon'\" class=\"amml-icon amml-svg-icon\"\r\n svgIcon=\"{{getSelectedSvgIcon()}}\">\r\n </mat-icon>\r\n <img *ngSwitchCase=\"'imageIcon'\" class=\"amml-icon amml-img-icon\"\r\n src=\"{{getSelectedImageIcon()}}\" alt=\"{{node.label}}\"/>\r\n </div>\r\n</ng-template>\r\n\r\n", styles: [".amml-item{position:relative;cursor:pointer}.anml-link{width:100%;display:flex;justify-content:flex-start;text-transform:capitalize;text-decoration:none}.anml-data{width:100%;height:48px;display:flex;justify-content:flex-start}.icon-container{display:flex;flex-direction:column;justify-content:center}.amml-icon-fa{font-size:20px}.label{line-height:48px;font-weight:400}.amml-svg-icon{width:22px;height:22px;margin-top:-12px}.amml-img-icon{flex-shrink:0;width:40px;height:40px;border-radius:50%;object-fit:cover}.amml-icon-arrow-container{direction:ltr;display:flex;align-items:center}div[dir=ltr] .amml-icon{margin-right:16px}div[dir=rtl] .amml-icon{margin-left:16px}\n"], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "directive", type: i1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }], animations: [ExpandedLTR, ExpandedRTL] }); }
|
|
216
|
+
}
|
|
217
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ListItemContentComponent, decorators: [{
|
|
218
|
+
type: Component,
|
|
219
|
+
args: [{ selector: 'ng-list-item-content', animations: [ExpandedLTR, ExpandedRTL], template: "<ng-container *ngTemplateOutlet=\"node.externalRedirect ? redirectLinkTemplate : routerLinkTemplate\"></ng-container>\r\n\r\n<ng-template #redirectLinkTemplate>\r\n <a class=\"anml-link\" [href]=\"node.link\" [target]=\"getHrefTargetType()\" [ngStyle]=\"listContentStyle\">\r\n <ng-container *ngTemplateOutlet=\"isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet\"></ng-container>\r\n </a>\r\n</ng-template>\r\n\r\n<ng-template #routerLinkTemplate>\r\n <ng-container *ngIf=\"node.link && nodeConfiguration.interfaceWithRoute; else defaultContentContainer\">\r\n <a class=\"anml-link\" [routerLink]=\"node.link\" [ngStyle]=\"listContentStyle\">\r\n <ng-container *ngTemplateOutlet=\"isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet\"></ng-container>\r\n </a>\r\n </ng-container>\r\n</ng-template>\r\n\r\n<ng-template #defaultContentContainer>\r\n <a class=\"anml-link\" [ngStyle]=\"listContentStyle\">\r\n <ng-container *ngTemplateOutlet=\"isRtlLayout ? linkLabelRtlOutlet : linkLabelLtrOutlet\"></ng-container>\r\n </a>\r\n</ng-template>\r\n\r\n<ng-template #linkLabelLtrOutlet>\r\n <div class=\"anml-data\" [dir]=\"'ltr'\">\r\n <ng-container *ngTemplateOutlet=\"iconContainer\"></ng-container>\r\n <span class=\"label\">{{node.label}}</span>\r\n </div>\r\n <div class=\"amml-icon-arrow-container\" *ngIf='node.hasChildren'>\r\n <mat-icon [@ExpandedLTR]=\"nodeExpandStatus()\">\r\n keyboard_arrow_down\r\n </mat-icon>\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #linkLabelRtlOutlet>\r\n <div class=\"anml-data\" [dir]=\"'rtl'\">\r\n <ng-container *ngTemplateOutlet=\"iconContainer\"></ng-container>\r\n <span class=\"label\">{{node.label}}</span>\r\n </div>\r\n <div class=\"amml-icon-arrow-container\" *ngIf='node.hasChildren'>\r\n <mat-icon [@ExpandedRTL]=\"nodeExpandStatus()\">\r\n keyboard_arrow_down\r\n </mat-icon>\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #iconContainer>\r\n <div class=\"icon-container\" [ngSwitch]=\"getListIcon(node)\">\r\n <span *ngSwitchCase=\"'faIcon'\" class=\"amml-icon amml-icon-fa\">\r\n <i [ngClass]=\"getSelectedFaIcon()\"></i>\r\n </span>\r\n <mat-icon *ngSwitchCase=\"'icon'\" class=\"amml-icon\">\r\n {{getSelectedIcon()}}\r\n </mat-icon>\r\n <mat-icon *ngSwitchCase=\"'svgIcon'\" class=\"amml-icon amml-svg-icon\"\r\n svgIcon=\"{{getSelectedSvgIcon()}}\">\r\n </mat-icon>\r\n <img *ngSwitchCase=\"'imageIcon'\" class=\"amml-icon amml-img-icon\"\r\n src=\"{{getSelectedImageIcon()}}\" alt=\"{{node.label}}\"/>\r\n </div>\r\n</ng-template>\r\n\r\n", styles: [".amml-item{position:relative;cursor:pointer}.anml-link{width:100%;display:flex;justify-content:flex-start;text-transform:capitalize;text-decoration:none}.anml-data{width:100%;height:48px;display:flex;justify-content:flex-start}.icon-container{display:flex;flex-direction:column;justify-content:center}.amml-icon-fa{font-size:20px}.label{line-height:48px;font-weight:400}.amml-svg-icon{width:22px;height:22px;margin-top:-12px}.amml-img-icon{flex-shrink:0;width:40px;height:40px;border-radius:50%;object-fit:cover}.amml-icon-arrow-container{direction:ltr;display:flex;align-items:center}div[dir=ltr] .amml-icon{margin-right:16px}div[dir=rtl] .amml-icon{margin-left:16px}\n"] }]
|
|
220
|
+
}], ctorParameters: () => [], propDecorators: { node: [{
|
|
221
|
+
type: Input
|
|
222
|
+
}], isRtlLayout: [{
|
|
223
|
+
type: Input
|
|
224
|
+
}], listContentStyle: [{
|
|
225
|
+
type: Input
|
|
226
|
+
}], nodeConfiguration: [{
|
|
227
|
+
type: Input
|
|
228
|
+
}] } });
|
|
229
|
+
|
|
230
|
+
class ListItemComponent {
|
|
231
|
+
constructor(router, multilevelMenuService) {
|
|
232
|
+
this.router = router;
|
|
233
|
+
this.multilevelMenuService = multilevelMenuService;
|
|
234
|
+
this.level = 1;
|
|
235
|
+
this.submenuLevel = 0;
|
|
236
|
+
this.nodeConfiguration = null;
|
|
237
|
+
this.nodeExpandCollapseStatus = null;
|
|
238
|
+
this.listTemplate = null;
|
|
239
|
+
this.selectedItem = new EventEmitter();
|
|
240
|
+
this.isSelected = false;
|
|
241
|
+
this.expanded = false;
|
|
242
|
+
this.firstInitializer = false;
|
|
243
|
+
this.selectedListClasses = {
|
|
244
|
+
[CONSTANT.DEFAULT_LIST_CLASS_NAME]: true,
|
|
245
|
+
[CONSTANT.SELECTED_LIST_CLASS_NAME]: false,
|
|
246
|
+
[CONSTANT.ACTIVE_ITEM_CLASS_NAME]: false,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
ngOnChanges() {
|
|
250
|
+
this.nodeChildren = this.node && this.node.items ? this.node.items.filter(n => !n.hidden) : [];
|
|
251
|
+
this.node.hasChildren = this.hasItems();
|
|
252
|
+
if (!CommonUtils.isNullOrUndefined(this.selectedNode)) {
|
|
253
|
+
this.setSelectedClass(this.multilevelMenuService.recursiveCheckId(this.node, this.selectedNode.id));
|
|
254
|
+
}
|
|
255
|
+
this.setExpandCollapseStatus();
|
|
256
|
+
}
|
|
257
|
+
ngOnInit() {
|
|
258
|
+
this.selectedListClasses[CONSTANT.DISABLED_ITEM_CLASS_NAME] = this.node.disabled;
|
|
259
|
+
if (!CommonUtils.isNullOrUndefined(this.node.faIcon) &&
|
|
260
|
+
this.node.faIcon.match(/\bfa\w(?!-)/) === null) {
|
|
261
|
+
this.node.faIcon = `fas ${this.node.faIcon}`;
|
|
262
|
+
}
|
|
263
|
+
this.selectedListClasses[`level-${this.level}-submenulevel-${this.submenuLevel}`] = true;
|
|
264
|
+
if (typeof this.node.expanded === 'boolean') {
|
|
265
|
+
this.expanded = this.node.expanded;
|
|
266
|
+
}
|
|
267
|
+
this.setClasses();
|
|
268
|
+
}
|
|
269
|
+
setSelectedClass(isFound) {
|
|
270
|
+
if (isFound) {
|
|
271
|
+
if (!this.firstInitializer) {
|
|
272
|
+
this.expanded = true;
|
|
273
|
+
}
|
|
274
|
+
this.isSelected = this.nodeConfiguration.highlightOnSelect || this.selectedNode.items === undefined;
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
this.isSelected = false;
|
|
278
|
+
if (this.nodeConfiguration.collapseOnSelect) {
|
|
279
|
+
this.node.expanded = false;
|
|
280
|
+
this.expanded = false;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
this.selectedListClasses = {
|
|
284
|
+
[CONSTANT.DEFAULT_LIST_CLASS_NAME]: true,
|
|
285
|
+
[CONSTANT.SELECTED_LIST_CLASS_NAME]: this.isSelected,
|
|
286
|
+
[CONSTANT.ACTIVE_ITEM_CLASS_NAME]: this.selectedNode.id === this.node.id,
|
|
287
|
+
[CONSTANT.DISABLED_ITEM_CLASS_NAME]: this.node.disabled,
|
|
288
|
+
[`level-${this.level}-submenulevel-${this.submenuLevel}`]: true,
|
|
289
|
+
};
|
|
290
|
+
this.node.isSelected = this.isSelected;
|
|
291
|
+
this.setClasses();
|
|
292
|
+
}
|
|
293
|
+
getPaddingAtStart() {
|
|
294
|
+
return this.nodeConfiguration.paddingAtStart;
|
|
295
|
+
}
|
|
296
|
+
getListStyle() {
|
|
297
|
+
const styles = {
|
|
298
|
+
background: CONSTANT.DEFAULT_LIST_BACKGROUND_COLOR,
|
|
299
|
+
color: CONSTANT.DEFAULT_LIST_FONT_COLOR
|
|
300
|
+
};
|
|
301
|
+
if (this.nodeConfiguration.listBackgroundColor !== null) {
|
|
302
|
+
styles.background = this.nodeConfiguration.listBackgroundColor;
|
|
303
|
+
}
|
|
304
|
+
if (this.isSelected) {
|
|
305
|
+
this.nodeConfiguration.selectedListFontColor !== null ?
|
|
306
|
+
styles.color = this.nodeConfiguration.selectedListFontColor : styles.color = CONSTANT.DEFAULT_SELECTED_FONT_COLOR;
|
|
307
|
+
}
|
|
308
|
+
else if (this.nodeConfiguration.fontColor !== null) {
|
|
309
|
+
styles.color = this.nodeConfiguration.fontColor;
|
|
310
|
+
}
|
|
311
|
+
return styles;
|
|
312
|
+
}
|
|
313
|
+
hasItems() {
|
|
314
|
+
return this.nodeChildren.length > 0;
|
|
315
|
+
}
|
|
316
|
+
isRtlLayout() {
|
|
317
|
+
return this.nodeConfiguration.rtlLayout;
|
|
318
|
+
}
|
|
319
|
+
setClasses() {
|
|
320
|
+
this.classes = {
|
|
321
|
+
[`level-${this.level + 1}`]: true,
|
|
322
|
+
[CONSTANT.SUBMENU_ITEM_CLASS_NAME]: this.hasItems() && this.getPaddingAtStart(),
|
|
323
|
+
[CONSTANT.HAS_SUBMENU_ITEM_CLASS_NAME]: this.hasItems()
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
setExpandCollapseStatus() {
|
|
327
|
+
if (!CommonUtils.isNullOrUndefined(this.nodeExpandCollapseStatus)) {
|
|
328
|
+
if (this.nodeExpandCollapseStatus === ExpandCollapseStatusEnum.expand) {
|
|
329
|
+
this.expanded = true;
|
|
330
|
+
if (this.nodeConfiguration.customTemplate) {
|
|
331
|
+
this.node.expanded = true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (this.nodeExpandCollapseStatus === ExpandCollapseStatusEnum.collapse) {
|
|
335
|
+
this.expanded = false;
|
|
336
|
+
if (this.nodeConfiguration.customTemplate) {
|
|
337
|
+
this.node.expanded = false;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
expand(node) {
|
|
343
|
+
if (node.disabled) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
this.nodeExpandCollapseStatus = ExpandCollapseStatusEnum.neutral;
|
|
347
|
+
this.expanded = !this.expanded;
|
|
348
|
+
this.node.expanded = this.expanded;
|
|
349
|
+
this.firstInitializer = true;
|
|
350
|
+
this.setClasses();
|
|
351
|
+
if (this.nodeConfiguration.interfaceWithRoute !== null
|
|
352
|
+
&& this.nodeConfiguration.interfaceWithRoute
|
|
353
|
+
&& node.link !== undefined
|
|
354
|
+
&& node.link) {
|
|
355
|
+
this.router.navigate([node.link], node.navigationExtras).then();
|
|
356
|
+
}
|
|
357
|
+
else if (node.onSelected && typeof node.onSelected === 'function') {
|
|
358
|
+
node.onSelected(node);
|
|
359
|
+
this.selectedListItem(node);
|
|
360
|
+
}
|
|
361
|
+
else if (node.items === undefined || this.nodeConfiguration.collapseOnSelect) {
|
|
362
|
+
this.selectedListItem(node);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
selectedListItem(node) {
|
|
366
|
+
this.selectedItem.emit(node);
|
|
367
|
+
}
|
|
368
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ListItemComponent, deps: [{ token: i1.Router }, { token: MultilevelMenuService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
369
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: ListItemComponent, selector: "ng-list-item", inputs: { node: "node", level: "level", submenuLevel: "submenuLevel", selectedNode: "selectedNode", nodeConfiguration: "nodeConfiguration", nodeExpandCollapseStatus: "nodeExpandCollapseStatus", listTemplate: "listTemplate" }, outputs: { selectedItem: "selectedItem" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"amml-menu-container\">\r\n <!-- Base Template rendering condition starts -->\r\n <div *ngIf=\"nodeConfiguration.customTemplate && !node.hidden;else baseTemplate\"\r\n [ngClass]=\"selectedListClasses\"\r\n (click)=\"expand(node)\">\r\n <ng-container [ngTemplateOutlet]=\"listTemplate\"\r\n [ngTemplateOutletContext]=\"{item: node, configuration: nodeConfiguration}\">\r\n </ng-container>\r\n </div>\r\n <!-- Base Template rendering condition ends -->\r\n\r\n <!-- Recursive Template calls begins -->\r\n <div *ngIf=\"hasItems() && expanded\" [@SlideInOut] [dir]=\"isRtlLayout() ? 'rtl' : 'ltr'\" [ngClass]=\"classes\">\r\n <ng-list-item *ngFor=\"let singleNode of nodeChildren | keyvalue : multilevelMenuService.kvDummyComparerFn\"\r\n [nodeConfiguration]='nodeConfiguration'\r\n [node]=\"singleNode.value\"\r\n [level]=\"level + 1\"\r\n [submenuLevel]=\"singleNode.key\"\r\n [selectedNode]='selectedNode'\r\n [nodeExpandCollapseStatus]='nodeExpandCollapseStatus'\r\n (selectedItem)=\"selectedListItem($event)\"\r\n [listTemplate]=\"listTemplate\">\r\n </ng-list-item>\r\n </div>\r\n</div>\r\n<!-- Recursive Template calls ends -->\r\n\r\n<!-- Base Template starts from here -->\r\n<ng-template #baseTemplate>\r\n <mat-list-item matRipple\r\n *ngIf=\"!node.hidden\"\r\n title=\"{{node.label}}\"\r\n [matRippleDisabled]=\"node.disabled\"\r\n [ngClass]=\"selectedListClasses\"\r\n (click)=\"expand(node)\">\r\n <ng-container *ngTemplateOutlet=\"linkTemplate\"></ng-container>\r\n </mat-list-item>\r\n <mat-divider *ngIf=\"nodeConfiguration.useDividers\"></mat-divider>\r\n</ng-template>\r\n\r\n<ng-template #linkTemplate>\r\n <ng-list-item-content class=\"filled\" [node]=\"node\" [nodeConfiguration]=\"nodeConfiguration\" [isRtlLayout]=\"isRtlLayout()\" [listContentStyle]=\"getListStyle()\"></ng-list-item-content>\r\n</ng-template>\r\n", styles: [".filled{width:100%}div[dir=rtl].amml-submenu{margin-right:16px}div[dir=ltr].amml-submenu{margin-left:16px}.disabled-amml-item{opacity:.5;text-decoration:none;pointer-events:none}\n"], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "component", type: i5.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }, { kind: "component", type: i6.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "directive", type: i7.MatRipple, selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }, { kind: "component", type: ListItemComponent, selector: "ng-list-item", inputs: ["node", "level", "submenuLevel", "selectedNode", "nodeConfiguration", "nodeExpandCollapseStatus", "listTemplate"], outputs: ["selectedItem"] }, { kind: "component", type: ListItemContentComponent, selector: "ng-list-item-content", inputs: ["node", "isRtlLayout", "listContentStyle", "nodeConfiguration"] }, { kind: "pipe", type: i3.KeyValuePipe, name: "keyvalue" }], animations: [SlideInOut] }); }
|
|
370
|
+
}
|
|
371
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ListItemComponent, decorators: [{
|
|
372
|
+
type: Component,
|
|
373
|
+
args: [{ selector: 'ng-list-item', animations: [SlideInOut], template: "<div class=\"amml-menu-container\">\r\n <!-- Base Template rendering condition starts -->\r\n <div *ngIf=\"nodeConfiguration.customTemplate && !node.hidden;else baseTemplate\"\r\n [ngClass]=\"selectedListClasses\"\r\n (click)=\"expand(node)\">\r\n <ng-container [ngTemplateOutlet]=\"listTemplate\"\r\n [ngTemplateOutletContext]=\"{item: node, configuration: nodeConfiguration}\">\r\n </ng-container>\r\n </div>\r\n <!-- Base Template rendering condition ends -->\r\n\r\n <!-- Recursive Template calls begins -->\r\n <div *ngIf=\"hasItems() && expanded\" [@SlideInOut] [dir]=\"isRtlLayout() ? 'rtl' : 'ltr'\" [ngClass]=\"classes\">\r\n <ng-list-item *ngFor=\"let singleNode of nodeChildren | keyvalue : multilevelMenuService.kvDummyComparerFn\"\r\n [nodeConfiguration]='nodeConfiguration'\r\n [node]=\"singleNode.value\"\r\n [level]=\"level + 1\"\r\n [submenuLevel]=\"singleNode.key\"\r\n [selectedNode]='selectedNode'\r\n [nodeExpandCollapseStatus]='nodeExpandCollapseStatus'\r\n (selectedItem)=\"selectedListItem($event)\"\r\n [listTemplate]=\"listTemplate\">\r\n </ng-list-item>\r\n </div>\r\n</div>\r\n<!-- Recursive Template calls ends -->\r\n\r\n<!-- Base Template starts from here -->\r\n<ng-template #baseTemplate>\r\n <mat-list-item matRipple\r\n *ngIf=\"!node.hidden\"\r\n title=\"{{node.label}}\"\r\n [matRippleDisabled]=\"node.disabled\"\r\n [ngClass]=\"selectedListClasses\"\r\n (click)=\"expand(node)\">\r\n <ng-container *ngTemplateOutlet=\"linkTemplate\"></ng-container>\r\n </mat-list-item>\r\n <mat-divider *ngIf=\"nodeConfiguration.useDividers\"></mat-divider>\r\n</ng-template>\r\n\r\n<ng-template #linkTemplate>\r\n <ng-list-item-content class=\"filled\" [node]=\"node\" [nodeConfiguration]=\"nodeConfiguration\" [isRtlLayout]=\"isRtlLayout()\" [listContentStyle]=\"getListStyle()\"></ng-list-item-content>\r\n</ng-template>\r\n", styles: [".filled{width:100%}div[dir=rtl].amml-submenu{margin-right:16px}div[dir=ltr].amml-submenu{margin-left:16px}.disabled-amml-item{opacity:.5;text-decoration:none;pointer-events:none}\n"] }]
|
|
374
|
+
}], ctorParameters: () => [{ type: i1.Router }, { type: MultilevelMenuService }], propDecorators: { node: [{
|
|
375
|
+
type: Input
|
|
376
|
+
}], level: [{
|
|
377
|
+
type: Input
|
|
378
|
+
}], submenuLevel: [{
|
|
379
|
+
type: Input
|
|
380
|
+
}], selectedNode: [{
|
|
381
|
+
type: Input
|
|
382
|
+
}], nodeConfiguration: [{
|
|
383
|
+
type: Input
|
|
384
|
+
}], nodeExpandCollapseStatus: [{
|
|
385
|
+
type: Input
|
|
386
|
+
}], listTemplate: [{
|
|
387
|
+
type: Input
|
|
388
|
+
}], selectedItem: [{
|
|
389
|
+
type: Output
|
|
390
|
+
}] } });
|
|
391
|
+
|
|
392
|
+
class MaterialsModule {
|
|
393
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MaterialsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
394
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: MaterialsModule, imports: [MatIconModule,
|
|
395
|
+
MatListModule,
|
|
396
|
+
MatRippleModule], exports: [MatIconModule,
|
|
397
|
+
MatListModule,
|
|
398
|
+
MatRippleModule] }); }
|
|
399
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MaterialsModule, imports: [MatIconModule,
|
|
400
|
+
MatListModule,
|
|
401
|
+
MatRippleModule, MatIconModule,
|
|
402
|
+
MatListModule,
|
|
403
|
+
MatRippleModule] }); }
|
|
404
|
+
}
|
|
405
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MaterialsModule, decorators: [{
|
|
406
|
+
type: NgModule,
|
|
407
|
+
args: [{
|
|
408
|
+
imports: [
|
|
409
|
+
MatIconModule,
|
|
410
|
+
MatListModule,
|
|
411
|
+
MatRippleModule,
|
|
412
|
+
],
|
|
413
|
+
declarations: [],
|
|
414
|
+
exports: [
|
|
415
|
+
MatIconModule,
|
|
416
|
+
MatListModule,
|
|
417
|
+
MatRippleModule,
|
|
418
|
+
]
|
|
419
|
+
}]
|
|
420
|
+
}] });
|
|
421
|
+
|
|
422
|
+
class NgMaterialMultilevelMenuComponent {
|
|
423
|
+
constructor(router, multilevelMenuService) {
|
|
424
|
+
this.router = router;
|
|
425
|
+
this.multilevelMenuService = multilevelMenuService;
|
|
426
|
+
this.configuration = null;
|
|
427
|
+
this.selectedItem = new EventEmitter();
|
|
428
|
+
this.selectedLabel = new EventEmitter();
|
|
429
|
+
this.menuIsReady = new EventEmitter();
|
|
430
|
+
this.expandCollapseStatusSubscription = null;
|
|
431
|
+
this.selectMenuByIDSubscription = null;
|
|
432
|
+
this.currentNode = null;
|
|
433
|
+
this.nodeConfig = {
|
|
434
|
+
paddingAtStart: true,
|
|
435
|
+
listBackgroundColor: null,
|
|
436
|
+
fontColor: null,
|
|
437
|
+
selectedListFontColor: null,
|
|
438
|
+
interfaceWithRoute: null,
|
|
439
|
+
collapseOnSelect: null,
|
|
440
|
+
highlightOnSelect: false,
|
|
441
|
+
useDividers: true,
|
|
442
|
+
rtlLayout: false,
|
|
443
|
+
customTemplate: false
|
|
444
|
+
};
|
|
445
|
+
this.isInvalidConfig = true;
|
|
446
|
+
this.isInvalidData = true;
|
|
447
|
+
this.nodeExpandCollapseStatus = ExpandCollapseStatusEnum.neutral;
|
|
448
|
+
// NOOP
|
|
449
|
+
}
|
|
450
|
+
ngOnChanges() {
|
|
451
|
+
this.detectInvalidConfig();
|
|
452
|
+
this.initExpandCollapseStatus();
|
|
453
|
+
this.initSelectedMenuID();
|
|
454
|
+
if (!this.isInvalidData) {
|
|
455
|
+
this.menuIsReady.emit(this.items);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
ngOnInit() {
|
|
459
|
+
if (!CommonUtils.isNullOrUndefinedOrEmpty(this.configuration) &&
|
|
460
|
+
this.configuration.interfaceWithRoute !== null && this.configuration.interfaceWithRoute) {
|
|
461
|
+
this.router.events
|
|
462
|
+
.subscribe((event) => {
|
|
463
|
+
if (event instanceof NavigationEnd) {
|
|
464
|
+
this.updateNodeByURL(event.urlAfterRedirects);
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
this.updateNodeByURL(this.router.url);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
updateNodeByURL(url) {
|
|
471
|
+
const foundNode = this.multilevelMenuService.getMatchedObjectByUrl(this.items, url);
|
|
472
|
+
if (foundNode !== undefined && !CommonUtils.isNullOrUndefinedOrEmpty(foundNode.link)
|
|
473
|
+
// && !foundNode.disabled // Prevent route redirection for disabled menu
|
|
474
|
+
) {
|
|
475
|
+
this.currentNode = foundNode;
|
|
476
|
+
if (!CommonUtils.isNullOrUndefined(foundNode.dontEmit) && !foundNode.dontEmit) {
|
|
477
|
+
this.selectedListItem(foundNode);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
checkValidData() {
|
|
482
|
+
if (this.items === undefined || (Array.isArray(this.items) && this.items.length === 0)) {
|
|
483
|
+
console.warn(CONSTANT.ERROR_MESSAGE);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
this.items = this.items.filter(n => !n.hidden);
|
|
487
|
+
this.multilevelMenuService.addRandomId(this.items);
|
|
488
|
+
this.isInvalidData = false;
|
|
489
|
+
}
|
|
490
|
+
detectInvalidConfig() {
|
|
491
|
+
if (CommonUtils.isNullOrUndefinedOrEmpty(this.configuration)) {
|
|
492
|
+
this.isInvalidConfig = true;
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
this.isInvalidConfig = false;
|
|
496
|
+
const config = this.configuration;
|
|
497
|
+
if (!CommonUtils.isNullOrUndefined(config.paddingAtStart) &&
|
|
498
|
+
typeof config.paddingAtStart === 'boolean') {
|
|
499
|
+
this.nodeConfig.paddingAtStart = config.paddingAtStart;
|
|
500
|
+
}
|
|
501
|
+
if (!CommonUtils.isNullOrUndefinedOrEmpty(config.listBackgroundColor)) {
|
|
502
|
+
this.nodeConfig.listBackgroundColor = config.listBackgroundColor;
|
|
503
|
+
}
|
|
504
|
+
if (!CommonUtils.isNullOrUndefinedOrEmpty(config.fontColor)) {
|
|
505
|
+
this.nodeConfig.fontColor = config.fontColor;
|
|
506
|
+
}
|
|
507
|
+
if (!CommonUtils.isNullOrUndefinedOrEmpty(config.selectedListFontColor)) {
|
|
508
|
+
this.nodeConfig.selectedListFontColor = config.selectedListFontColor;
|
|
509
|
+
}
|
|
510
|
+
if (!CommonUtils.isNullOrUndefined(config.interfaceWithRoute) &&
|
|
511
|
+
typeof config.interfaceWithRoute === 'boolean') {
|
|
512
|
+
this.nodeConfig.interfaceWithRoute = config.interfaceWithRoute;
|
|
513
|
+
}
|
|
514
|
+
if (!CommonUtils.isNullOrUndefined(config.collapseOnSelect) &&
|
|
515
|
+
typeof config.collapseOnSelect === 'boolean') {
|
|
516
|
+
this.nodeConfig.collapseOnSelect = config.collapseOnSelect;
|
|
517
|
+
}
|
|
518
|
+
if (!CommonUtils.isNullOrUndefined(config.highlightOnSelect) &&
|
|
519
|
+
typeof config.highlightOnSelect === 'boolean') {
|
|
520
|
+
this.nodeConfig.highlightOnSelect = config.highlightOnSelect;
|
|
521
|
+
}
|
|
522
|
+
if (!CommonUtils.isNullOrUndefined(config.useDividers) &&
|
|
523
|
+
typeof config.useDividers === 'boolean') {
|
|
524
|
+
this.nodeConfig.useDividers = config.useDividers;
|
|
525
|
+
}
|
|
526
|
+
if (!CommonUtils.isNullOrUndefined(config.rtlLayout) &&
|
|
527
|
+
typeof config.rtlLayout === 'boolean') {
|
|
528
|
+
this.nodeConfig.rtlLayout = config.rtlLayout;
|
|
529
|
+
}
|
|
530
|
+
if (!CommonUtils.isNullOrUndefined(config.customTemplate) &&
|
|
531
|
+
typeof config.customTemplate === 'boolean') {
|
|
532
|
+
this.nodeConfig.customTemplate = config.customTemplate;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
this.checkValidData();
|
|
536
|
+
}
|
|
537
|
+
initExpandCollapseStatus() {
|
|
538
|
+
this.expandCollapseStatusSubscription = this.multilevelMenuService.expandCollapseStatus$
|
|
539
|
+
.subscribe((expandCollapseStatus) => {
|
|
540
|
+
this.nodeExpandCollapseStatus = expandCollapseStatus ? expandCollapseStatus : ExpandCollapseStatusEnum.neutral;
|
|
541
|
+
}, () => {
|
|
542
|
+
this.nodeExpandCollapseStatus = ExpandCollapseStatusEnum.neutral;
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
initSelectedMenuID() {
|
|
546
|
+
this.selectMenuByIDSubscription = this.multilevelMenuService.selectedMenuID$.subscribe((selectedMenuID) => {
|
|
547
|
+
if (selectedMenuID) {
|
|
548
|
+
const foundNode = this.multilevelMenuService.getMatchedObjectById(this.items, selectedMenuID);
|
|
549
|
+
if (foundNode !== undefined) {
|
|
550
|
+
this.currentNode = foundNode;
|
|
551
|
+
this.selectedListItem(foundNode);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
getClassName() {
|
|
557
|
+
if (!this.isInvalidConfig && !CommonUtils.isNullOrUndefinedOrEmpty(this.configuration.classname)) {
|
|
558
|
+
return `${CONSTANT.DEFAULT_CLASS_NAME} ${this.configuration.classname}`;
|
|
559
|
+
}
|
|
560
|
+
return CONSTANT.DEFAULT_CLASS_NAME;
|
|
561
|
+
}
|
|
562
|
+
getGlobalStyle() {
|
|
563
|
+
if (!this.isInvalidConfig) {
|
|
564
|
+
const styles = {
|
|
565
|
+
background: null
|
|
566
|
+
};
|
|
567
|
+
if (!CommonUtils.isNullOrUndefinedOrEmpty(this.configuration.backgroundColor)) {
|
|
568
|
+
styles.background = this.configuration.backgroundColor;
|
|
569
|
+
}
|
|
570
|
+
return styles;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
isRtlLayout() {
|
|
574
|
+
return this.nodeConfig.rtlLayout;
|
|
575
|
+
}
|
|
576
|
+
selectedListItem(event) {
|
|
577
|
+
this.nodeExpandCollapseStatus = ExpandCollapseStatusEnum.neutral;
|
|
578
|
+
this.currentNode = event;
|
|
579
|
+
if (!CommonUtils.isNullOrUndefined(event.dontEmit) && event.dontEmit) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
if (event.items === undefined && (!event.onSelected || typeof event.onSelected !== 'function')) {
|
|
583
|
+
this.selectedItem.emit(event);
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
this.selectedLabel.emit(event);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
ngOnDestroy() {
|
|
590
|
+
this.expandCollapseStatusSubscription.unsubscribe();
|
|
591
|
+
this.selectMenuByIDSubscription.unsubscribe();
|
|
592
|
+
}
|
|
593
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NgMaterialMultilevelMenuComponent, deps: [{ token: i1.Router }, { token: MultilevelMenuService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
594
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: NgMaterialMultilevelMenuComponent, selector: "ng-material-multilevel-menu", inputs: { items: "items", configuration: "configuration" }, outputs: { selectedItem: "selectedItem", selectedLabel: "selectedLabel", menuIsReady: "menuIsReady" }, queries: [{ propertyName: "listTemplate", first: true, predicate: ["listTemplate"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div [ngClass]=\"getClassName()\" [ngStyle]=\"getGlobalStyle()\" *ngIf='!isInvalidData && items.length !== 0' [dir]=\"isRtlLayout() ? 'rtl' : 'ltr'\">\r\n <mat-list>\r\n <ng-list-item\r\n *ngFor=\"let node of items | keyvalue: multilevelMenuService.kvDummyComparerFn\"\r\n [nodeConfiguration]='nodeConfig'\r\n [node]='node.value'\r\n [level]=\"1\"\r\n [submenuLevel]=\"node.key\"\r\n [selectedNode]='currentNode'\r\n [nodeExpandCollapseStatus]='nodeExpandCollapseStatus'\r\n (selectedItem)=\"selectedListItem($event)\"\r\n [listTemplate] = \"listTemplate\"\r\n >\r\n </ng-list-item>\r\n </mat-list>\r\n</div>\r\n", styles: [".amml-container .mat-list-base{padding-top:unset}.amml-item{line-height:48px;display:flex;justify-content:space-between;position:relative}.anml-data{width:100%;text-transform:capitalize;display:flex;justify-content:flex-start}.amml-icon-fa{font-size:20px}.amml-icon{line-height:48px}.active{color:#1976d2}div[dir=ltr] .amml-icon{margin-right:15px}div[dir=ltr] .amml-submenu{margin-left:16px}div[dir=rtl] .amml-icon{margin-left:15px}div[dir=rtl] .amml-submenu{margin-right:16px}\n"], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "component", type: i5.MatList, selector: "mat-list", exportAs: ["matList"] }, { kind: "component", type: ListItemComponent, selector: "ng-list-item", inputs: ["node", "level", "submenuLevel", "selectedNode", "nodeConfiguration", "nodeExpandCollapseStatus", "listTemplate"], outputs: ["selectedItem"] }, { kind: "pipe", type: i3.KeyValuePipe, name: "keyvalue" }] }); }
|
|
595
|
+
}
|
|
596
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NgMaterialMultilevelMenuComponent, decorators: [{
|
|
597
|
+
type: Component,
|
|
598
|
+
args: [{ selector: 'ng-material-multilevel-menu', template: "<div [ngClass]=\"getClassName()\" [ngStyle]=\"getGlobalStyle()\" *ngIf='!isInvalidData && items.length !== 0' [dir]=\"isRtlLayout() ? 'rtl' : 'ltr'\">\r\n <mat-list>\r\n <ng-list-item\r\n *ngFor=\"let node of items | keyvalue: multilevelMenuService.kvDummyComparerFn\"\r\n [nodeConfiguration]='nodeConfig'\r\n [node]='node.value'\r\n [level]=\"1\"\r\n [submenuLevel]=\"node.key\"\r\n [selectedNode]='currentNode'\r\n [nodeExpandCollapseStatus]='nodeExpandCollapseStatus'\r\n (selectedItem)=\"selectedListItem($event)\"\r\n [listTemplate] = \"listTemplate\"\r\n >\r\n </ng-list-item>\r\n </mat-list>\r\n</div>\r\n", styles: [".amml-container .mat-list-base{padding-top:unset}.amml-item{line-height:48px;display:flex;justify-content:space-between;position:relative}.anml-data{width:100%;text-transform:capitalize;display:flex;justify-content:flex-start}.amml-icon-fa{font-size:20px}.amml-icon{line-height:48px}.active{color:#1976d2}div[dir=ltr] .amml-icon{margin-right:15px}div[dir=ltr] .amml-submenu{margin-left:16px}div[dir=rtl] .amml-icon{margin-left:15px}div[dir=rtl] .amml-submenu{margin-right:16px}\n"] }]
|
|
599
|
+
}], ctorParameters: () => [{ type: i1.Router }, { type: MultilevelMenuService }], propDecorators: { items: [{
|
|
600
|
+
type: Input
|
|
601
|
+
}], configuration: [{
|
|
602
|
+
type: Input
|
|
603
|
+
}], selectedItem: [{
|
|
604
|
+
type: Output
|
|
605
|
+
}], selectedLabel: [{
|
|
606
|
+
type: Output
|
|
607
|
+
}], menuIsReady: [{
|
|
608
|
+
type: Output
|
|
609
|
+
}], listTemplate: [{
|
|
610
|
+
type: ContentChild,
|
|
611
|
+
args: ['listTemplate', { static: true }]
|
|
612
|
+
}] } });
|
|
613
|
+
|
|
614
|
+
class NgMaterialMultilevelMenuModule {
|
|
615
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NgMaterialMultilevelMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
616
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: NgMaterialMultilevelMenuModule, declarations: [NgMaterialMultilevelMenuComponent,
|
|
617
|
+
ListItemComponent,
|
|
618
|
+
ListItemContentComponent], imports: [CommonModule,
|
|
619
|
+
MaterialsModule,
|
|
620
|
+
RouterModule], exports: [NgMaterialMultilevelMenuComponent] }); }
|
|
621
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NgMaterialMultilevelMenuModule, imports: [CommonModule,
|
|
622
|
+
MaterialsModule,
|
|
623
|
+
RouterModule] }); }
|
|
624
|
+
}
|
|
625
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NgMaterialMultilevelMenuModule, decorators: [{
|
|
626
|
+
type: NgModule,
|
|
627
|
+
args: [{
|
|
628
|
+
imports: [
|
|
629
|
+
CommonModule,
|
|
630
|
+
MaterialsModule,
|
|
631
|
+
RouterModule,
|
|
632
|
+
],
|
|
633
|
+
declarations: [
|
|
634
|
+
NgMaterialMultilevelMenuComponent,
|
|
635
|
+
ListItemComponent,
|
|
636
|
+
ListItemContentComponent,
|
|
637
|
+
],
|
|
638
|
+
exports: [NgMaterialMultilevelMenuComponent]
|
|
639
|
+
}]
|
|
640
|
+
}] });
|
|
641
|
+
|
|
642
|
+
/*
|
|
643
|
+
* Public API Surface of ng-material-multilevel-menu
|
|
644
|
+
*/
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Generated bundle index. Do not edit.
|
|
648
|
+
*/
|
|
649
|
+
|
|
650
|
+
export { ExpandCollapseStatusEnum, ExpandedLTR, ExpandedRTL, MultilevelMenuService, NgMaterialMultilevelMenuComponent, NgMaterialMultilevelMenuModule, SlideInOut };
|
|
651
|
+
//# sourceMappingURL=ng-mat-multilevel-menu.mjs.map
|