@muraai/mnl-commons 0.1.0 → 0.2.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.
Files changed (108) hide show
  1. package/esm2020/lib/commons.module.mjs +136 -0
  2. package/esm2020/lib/components/header/header.component.mjs +31 -0
  3. package/esm2020/lib/components/highlighter/highlighter.component.mjs +23 -0
  4. package/esm2020/lib/components/language-menu/language-menu.component.mjs +36 -0
  5. package/esm2020/lib/components/login/login.component.mjs +55 -0
  6. package/esm2020/lib/components/menu/menu.component.mjs +67 -0
  7. package/esm2020/lib/components/profile/profile.component.mjs +42 -0
  8. package/esm2020/lib/material.module.mjs +60 -0
  9. package/esm2020/lib/model/log-levels.model.mjs +17 -0
  10. package/esm2020/lib/model/menu-data.model.mjs +2 -0
  11. package/esm2020/lib/model/translation-resource.mjs +14 -0
  12. package/esm2020/lib/model/user-model.mjs +2 -0
  13. package/esm2020/lib/pipes/app-config-pipe.mjs +20 -0
  14. package/esm2020/lib/pipes/time-ago-pipe.mjs +43 -0
  15. package/esm2020/lib/pipes/user-fullname-pipe.mjs +34 -0
  16. package/esm2020/lib/pipes/user-initials-pipe.mjs +48 -0
  17. package/esm2020/lib/services/app.config.service.mjs +41 -0
  18. package/esm2020/lib/services/local-storage.service.mjs +48 -0
  19. package/esm2020/lib/services/locale.service.mjs +89 -0
  20. package/esm2020/lib/services/log.service.mjs +89 -0
  21. package/esm2020/lib/services/user-profile.service.mjs +36 -0
  22. package/esm2020/lib/utils/object-utils.mjs +46 -0
  23. package/esm2020/muraai-mnl-commons.mjs +5 -0
  24. package/esm2020/public-api.mjs +25 -0
  25. package/fesm2015/muraai-mnl-commons.mjs +908 -0
  26. package/fesm2015/muraai-mnl-commons.mjs.map +1 -0
  27. package/fesm2020/muraai-mnl-commons.mjs +905 -0
  28. package/fesm2020/muraai-mnl-commons.mjs.map +1 -0
  29. package/index.d.ts +5 -0
  30. package/lib/commons.module.d.ts +21 -0
  31. package/lib/components/header/header.component.d.ts +5 -0
  32. package/lib/components/highlighter/highlighter.component.d.ts +3 -0
  33. package/lib/components/language-menu/language-menu.component.d.ts +6 -1
  34. package/lib/components/login/login.component.d.ts +5 -2
  35. package/lib/components/menu/menu.component.d.ts +3 -0
  36. package/lib/components/profile/profile.component.d.ts +8 -2
  37. package/lib/material.module.d.ts +14 -2
  38. package/lib/model/menu-data.model.d.ts +1 -0
  39. package/lib/pipes/app-config-pipe.d.ts +3 -0
  40. package/lib/pipes/time-ago-pipe.d.ts +4 -1
  41. package/lib/pipes/user-fullname-pipe.d.ts +4 -0
  42. package/lib/pipes/user-initials-pipe.d.ts +6 -0
  43. package/lib/services/app.config.service.d.ts +3 -0
  44. package/lib/services/local-storage.service.d.ts +7 -0
  45. package/lib/services/locale.service.d.ts +4 -0
  46. package/lib/services/log.service.d.ts +4 -1
  47. package/lib/services/user-profile.service.d.ts +3 -0
  48. package/package.json +24 -14
  49. package/public-api.d.ts +1 -0
  50. package/theming.scss +6 -5186
  51. package/bundles/muraai-mnl-commons.umd.js +0 -1087
  52. package/bundles/muraai-mnl-commons.umd.js.map +0 -1
  53. package/bundles/muraai-mnl-commons.umd.min.js +0 -16
  54. package/bundles/muraai-mnl-commons.umd.min.js.map +0 -1
  55. package/esm2015/lib/commons.module.js +0 -89
  56. package/esm2015/lib/components/header/header.component.js +0 -26
  57. package/esm2015/lib/components/highlighter/highlighter.component.js +0 -27
  58. package/esm2015/lib/components/language-menu/language-menu.component.js +0 -29
  59. package/esm2015/lib/components/login/login.component.js +0 -58
  60. package/esm2015/lib/components/menu/menu.component.js +0 -66
  61. package/esm2015/lib/components/profile/profile.component.js +0 -29
  62. package/esm2015/lib/material.module.js +0 -33
  63. package/esm2015/lib/model/log-levels.model.js +0 -17
  64. package/esm2015/lib/model/menu-data.model.js +0 -1
  65. package/esm2015/lib/model/translation-resource.js +0 -14
  66. package/esm2015/lib/model/user-model.js +0 -1
  67. package/esm2015/lib/pipes/app-config-pipe.js +0 -21
  68. package/esm2015/lib/pipes/time-ago-pipe.js +0 -46
  69. package/esm2015/lib/pipes/user-fullname-pipe.js +0 -27
  70. package/esm2015/lib/pipes/user-initials-pipe.js +0 -27
  71. package/esm2015/lib/services/app.config.service.js +0 -45
  72. package/esm2015/lib/services/local-storage.service.js +0 -19
  73. package/esm2015/lib/services/locale.service.js +0 -93
  74. package/esm2015/lib/services/log.service.js +0 -93
  75. package/esm2015/lib/services/user-profile.service.js +0 -43
  76. package/esm2015/lib/utils/object-utils.js +0 -46
  77. package/esm2015/muraai-mnl-commons.js +0 -6
  78. package/esm2015/public-api.js +0 -22
  79. package/esm5/lib/commons.module.js +0 -92
  80. package/esm5/lib/components/header/header.component.js +0 -27
  81. package/esm5/lib/components/highlighter/highlighter.component.js +0 -28
  82. package/esm5/lib/components/language-menu/language-menu.component.js +0 -30
  83. package/esm5/lib/components/login/login.component.js +0 -59
  84. package/esm5/lib/components/menu/menu.component.js +0 -78
  85. package/esm5/lib/components/profile/profile.component.js +0 -30
  86. package/esm5/lib/material.module.js +0 -36
  87. package/esm5/lib/model/log-levels.model.js +0 -24
  88. package/esm5/lib/model/menu-data.model.js +0 -1
  89. package/esm5/lib/model/translation-resource.js +0 -14
  90. package/esm5/lib/model/user-model.js +0 -1
  91. package/esm5/lib/pipes/app-config-pipe.js +0 -22
  92. package/esm5/lib/pipes/time-ago-pipe.js +0 -48
  93. package/esm5/lib/pipes/user-fullname-pipe.js +0 -30
  94. package/esm5/lib/pipes/user-initials-pipe.js +0 -30
  95. package/esm5/lib/services/app.config.service.js +0 -57
  96. package/esm5/lib/services/local-storage.service.js +0 -22
  97. package/esm5/lib/services/locale.service.js +0 -96
  98. package/esm5/lib/services/log.service.js +0 -130
  99. package/esm5/lib/services/user-profile.service.js +0 -45
  100. package/esm5/lib/utils/object-utils.js +0 -54
  101. package/esm5/muraai-mnl-commons.js +0 -6
  102. package/esm5/public-api.js +0 -22
  103. package/fesm2015/muraai-mnl-commons.js +0 -762
  104. package/fesm2015/muraai-mnl-commons.js.map +0 -1
  105. package/fesm5/muraai-mnl-commons.js +0 -863
  106. package/fesm5/muraai-mnl-commons.js.map +0 -1
  107. package/muraai-mnl-commons.d.ts +0 -5
  108. package/muraai-mnl-commons.metadata.json +0 -1
@@ -0,0 +1,908 @@
1
+ import * as i0 from '@angular/core';
2
+ import { NgModule, EventEmitter, Component, ViewEncapsulation, Input, Output, Injectable, Inject, Pipe, InjectionToken, APP_INITIALIZER } from '@angular/core';
3
+ import * as i3 from '@angular/material/button';
4
+ import { MatButtonModule } from '@angular/material/button';
5
+ import * as i3$2 from '@angular/material/list';
6
+ import { MatListModule } from '@angular/material/list';
7
+ import * as i3$1 from '@angular/material/icon';
8
+ import { MatIconModule } from '@angular/material/icon';
9
+ import * as i6 from '@angular/material/input';
10
+ import { MatInputModule } from '@angular/material/input';
11
+ import * as i5 from '@angular/material/form-field';
12
+ import { MatFormFieldModule } from '@angular/material/form-field';
13
+ import * as i4$1 from '@angular/material/card';
14
+ import { MatCardModule } from '@angular/material/card';
15
+ import * as i7 from '@angular/forms';
16
+ import { FormsModule, ReactiveFormsModule, UntypedFormGroup, UntypedFormControl, Validators } from '@angular/forms';
17
+ import * as i4 from '@angular/material/menu';
18
+ import { MatMenuModule } from '@angular/material/menu';
19
+ import * as i1 from '@angular/common';
20
+ import { DOCUMENT, DatePipe, registerLocaleData, CommonModule } from '@angular/common';
21
+ import * as i1$1 from '@angular/common/http';
22
+ import { HttpClient } from '@angular/common/http';
23
+ import localeAR from '@angular/common/locales/ar';
24
+ import localeDE from '@angular/common/locales/de';
25
+ import localeFR from '@angular/common/locales/fr';
26
+ import * as i2 from '@angular/material/toolbar';
27
+ import { MatToolbarModule } from '@angular/material/toolbar';
28
+ import * as i2$1 from '@ngx-translate/core';
29
+ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
30
+ import { __awaiter } from 'tslib';
31
+ import * as i1$2 from '@angular/platform-browser';
32
+ import { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
33
+ import { formatDistance } from 'date-fns';
34
+ import differenceInDays from 'date-fns/differenceInDays';
35
+ import { Subject } from 'rxjs';
36
+
37
+ function modules() {
38
+ return [
39
+ MatButtonModule,
40
+ MatCardModule,
41
+ MatFormFieldModule,
42
+ MatIconModule,
43
+ MatInputModule,
44
+ MatListModule,
45
+ FormsModule,
46
+ ReactiveFormsModule,
47
+ MatMenuModule,
48
+ ];
49
+ }
50
+ class MaterialModule {
51
+ }
52
+ MaterialModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MaterialModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
53
+ MaterialModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: MaterialModule, imports: [MatButtonModule,
54
+ MatCardModule,
55
+ MatFormFieldModule,
56
+ MatIconModule,
57
+ MatInputModule,
58
+ MatListModule,
59
+ FormsModule,
60
+ ReactiveFormsModule,
61
+ MatMenuModule], exports: [MatButtonModule,
62
+ MatCardModule,
63
+ MatFormFieldModule,
64
+ MatIconModule,
65
+ MatInputModule,
66
+ MatListModule,
67
+ FormsModule,
68
+ ReactiveFormsModule,
69
+ MatMenuModule] });
70
+ MaterialModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MaterialModule, imports: [modules(), MatButtonModule,
71
+ MatCardModule,
72
+ MatFormFieldModule,
73
+ MatIconModule,
74
+ MatInputModule,
75
+ MatListModule,
76
+ FormsModule,
77
+ ReactiveFormsModule,
78
+ MatMenuModule] });
79
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MaterialModule, decorators: [{
80
+ type: NgModule,
81
+ args: [{
82
+ imports: modules(),
83
+ exports: modules()
84
+ }]
85
+ }] });
86
+
87
+ class HeaderComponent {
88
+ constructor() {
89
+ this.menuButonClickEvent = new EventEmitter();
90
+ this.logoClick = new EventEmitter();
91
+ }
92
+ menuClick(event) {
93
+ this.menuButonClickEvent.emit(event);
94
+ }
95
+ onLogoClick(event) {
96
+ this.logoClick.emit(event);
97
+ }
98
+ }
99
+ HeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
100
+ HeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: HeaderComponent, selector: "mnl-header", inputs: { header: "header" }, outputs: { menuButonClickEvent: "menuButonClickEvent", logoClick: "logoClick" }, ngImport: i0, template: "<mat-toolbar *ngIf=\"header\" color=\"{{ header.toolbarColor }}\">\n <mat-toolbar-row>\n <div class=\"flex justify-start items-center\">\n <button mat-icon-button *ngIf=\"header.showMenuIcon\">\n <mat-icon (click)=\"menuClick($event)\">menu</mat-icon>\n </button>\n <img\n class=\"mr-[15px]\"\n (click)=\"onLogoClick($event)\"\n src=\"{{ header.logo }}\"\n />\n <span>{{ header.name }}</span>\n </div>\n <div class=\"flex justify-end items-center grow max-w-full\">\n <ng-content select=\"`[mnl-header-content]`\"></ng-content>\n </div>\n </mat-toolbar-row>\n</mat-toolbar>\n", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }, { kind: "directive", type: i2.MatToolbarRow, selector: "mat-toolbar-row", exportAs: ["matToolbarRow"] }, { kind: "component", type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], encapsulation: i0.ViewEncapsulation.None });
101
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HeaderComponent, decorators: [{
102
+ type: Component,
103
+ args: [{ selector: 'mnl-header', encapsulation: ViewEncapsulation.None, template: "<mat-toolbar *ngIf=\"header\" color=\"{{ header.toolbarColor }}\">\n <mat-toolbar-row>\n <div class=\"flex justify-start items-center\">\n <button mat-icon-button *ngIf=\"header.showMenuIcon\">\n <mat-icon (click)=\"menuClick($event)\">menu</mat-icon>\n </button>\n <img\n class=\"mr-[15px]\"\n (click)=\"onLogoClick($event)\"\n src=\"{{ header.logo }}\"\n />\n <span>{{ header.name }}</span>\n </div>\n <div class=\"flex justify-end items-center grow max-w-full\">\n <ng-content select=\"`[mnl-header-content]`\"></ng-content>\n </div>\n </mat-toolbar-row>\n</mat-toolbar>\n" }]
104
+ }], propDecorators: { header: [{
105
+ type: Input
106
+ }], menuButonClickEvent: [{
107
+ type: Output
108
+ }], logoClick: [{
109
+ type: Output
110
+ }] } });
111
+
112
+ class HighlighterComponent {
113
+ constructor() {
114
+ this.height = '40px';
115
+ this.width = '4px';
116
+ this.enabled = true;
117
+ }
118
+ }
119
+ HighlighterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HighlighterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
120
+ HighlighterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: HighlighterComponent, selector: "mnl-highlighter", inputs: { height: "height", width: "width", enabled: "enabled" }, ngImport: i0, template: "<div\n [ngClass]=\"{ 'mnl-bg-primary': enabled }\"\n [ngStyle]=\"{ height: height, width: width }\"\n></div>\n", styles: [""], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
121
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HighlighterComponent, decorators: [{
122
+ type: Component,
123
+ args: [{ selector: 'mnl-highlighter', template: "<div\n [ngClass]=\"{ 'mnl-bg-primary': enabled }\"\n [ngStyle]=\"{ height: height, width: width }\"\n></div>\n" }]
124
+ }], propDecorators: { height: [{
125
+ type: Input
126
+ }], width: [{
127
+ type: Input
128
+ }], enabled: [{
129
+ type: Input
130
+ }] } });
131
+
132
+ class ObjectUtils {
133
+ /**
134
+ * Gets a value from an object by composed key
135
+ * ObjectUtils.getValue({ item: { nodeType: 'cm:folder' }}, 'item.nodeType') ==> 'cm:folder'
136
+ */
137
+ static getValue(target, key) {
138
+ if (!target) {
139
+ return undefined;
140
+ }
141
+ const keys = key.split('.');
142
+ key = '';
143
+ do {
144
+ key += keys.shift();
145
+ const value = target[key];
146
+ if (value !== undefined && (typeof value === 'object' || !keys.length)) {
147
+ target = value;
148
+ key = '';
149
+ }
150
+ else if (!keys.length) {
151
+ target = undefined;
152
+ }
153
+ else {
154
+ key += '.';
155
+ }
156
+ } while (keys.length);
157
+ return target;
158
+ }
159
+ static merge(...objects) {
160
+ const result = {};
161
+ objects.forEach((source) => {
162
+ Object.keys(source).forEach((prop) => {
163
+ if (prop in result && Array.isArray(result[prop])) {
164
+ result[prop] = result[prop].concat(source[prop]);
165
+ }
166
+ else if (prop in result && typeof result[prop] === 'object') {
167
+ result[prop] = ObjectUtils.merge(result[prop], source[prop]);
168
+ }
169
+ else {
170
+ result[prop] = source[prop];
171
+ }
172
+ });
173
+ });
174
+ return result;
175
+ }
176
+ }
177
+
178
+ class AppConfigService {
179
+ constructor(http) {
180
+ this.http = http;
181
+ this.config = null;
182
+ }
183
+ /**
184
+ * Use to get the data found in the file (config file)
185
+ */
186
+ get(key, defaultValue) {
187
+ const result = ObjectUtils.getValue(this.config, key);
188
+ return (result === undefined ? defaultValue : result);
189
+ }
190
+ /**
191
+ * This method:
192
+ * Loads "config.json" to get all variables (e.g.: 'app.config.json')
193
+ */
194
+ load() {
195
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
196
+ const configUrl = `assets/app.config.json`;
197
+ yield this.http.get(configUrl).subscribe((data) => {
198
+ this.config = Object.assign({}, this.config, data || {});
199
+ resolve(this.config);
200
+ }, () => {
201
+ resolve(this.config);
202
+ });
203
+ }));
204
+ }
205
+ }
206
+ AppConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppConfigService, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
207
+ AppConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppConfigService, providedIn: 'root' });
208
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppConfigService, decorators: [{
209
+ type: Injectable,
210
+ args: [{
211
+ providedIn: 'root',
212
+ }]
213
+ }], ctorParameters: function () { return [{ type: i1$1.HttpClient }]; } });
214
+
215
+ class LocalStorageService {
216
+ constructor() {
217
+ this.memoryStore = {};
218
+ this.useLocalStorage = false;
219
+ this.useLocalStorage = this.isStorageAvailable('localStorage');
220
+ }
221
+ set(key, value) {
222
+ if (this.useLocalStorage) {
223
+ localStorage.setItem(key, value);
224
+ }
225
+ else {
226
+ this.memoryStore[key] = value;
227
+ }
228
+ }
229
+ get(key) {
230
+ if (this.useLocalStorage) {
231
+ return localStorage.getItem(key);
232
+ }
233
+ else {
234
+ return this.memoryStore.hasOwnProperty(key)
235
+ ? this.memoryStore[key]
236
+ : null;
237
+ }
238
+ }
239
+ isStorageAvailable(type) {
240
+ try {
241
+ const storage = window[type];
242
+ const key = '__storage_test__';
243
+ storage.setItem(key, key);
244
+ storage.removeItem(key, key);
245
+ return true;
246
+ }
247
+ catch (e) {
248
+ return false;
249
+ }
250
+ }
251
+ }
252
+ LocalStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
253
+ LocalStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocalStorageService, providedIn: 'root' });
254
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocalStorageService, decorators: [{
255
+ type: Injectable,
256
+ args: [{
257
+ providedIn: 'root',
258
+ }]
259
+ }], ctorParameters: function () { return []; } });
260
+
261
+ class UserProfileService {
262
+ constructor(appConfigService, localStorageService) {
263
+ this.appConfigService = appConfigService;
264
+ this.localStorageService = localStorageService;
265
+ this.userPrefix = '';
266
+ }
267
+ getApplicationId() {
268
+ return this.appConfigService.get('applicationId') ? this.appConfigService.get('applicationId') : '';
269
+ }
270
+ setUserPrefix(userPrefix) {
271
+ this.userPrefix = userPrefix;
272
+ }
273
+ getUserPrefix() {
274
+ return this.userPrefix ? this.userPrefix : '';
275
+ }
276
+ setLocale(locale) {
277
+ this.localStorageService.set(this.getApplicationId() + this.userPrefix + UserProfileService.LOCALE_PREFIX, locale);
278
+ }
279
+ getLocale() {
280
+ return this.localStorageService.get(this.getApplicationId() + this.userPrefix + UserProfileService.LOCALE_PREFIX);
281
+ }
282
+ }
283
+ UserProfileService.LOCALE_PREFIX = '____locale';
284
+ UserProfileService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserProfileService, deps: [{ token: AppConfigService }, { token: LocalStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
285
+ UserProfileService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserProfileService, providedIn: 'root' });
286
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserProfileService, decorators: [{
287
+ type: Injectable,
288
+ args: [{
289
+ providedIn: 'root'
290
+ }]
291
+ }], ctorParameters: function () { return [{ type: AppConfigService }, { type: LocalStorageService }]; } });
292
+
293
+ /** @dynamic */
294
+ class LocaleService {
295
+ constructor(config, translate, userProfileService, document) {
296
+ this.config = config;
297
+ this.translate = translate;
298
+ this.userProfileService = userProfileService;
299
+ this.document = document;
300
+ this.languages = [];
301
+ this.initUserLanguage();
302
+ }
303
+ initUserLanguage() {
304
+ this.setActiveLocale(this.getActiveLocale() || this.getDefaultLocale());
305
+ }
306
+ setTextOrientation(direction) {
307
+ document.body.setAttribute('dir', direction);
308
+ }
309
+ getTextOrientation() {
310
+ return document.body.getAttribute('dir');
311
+ }
312
+ getLanguages() {
313
+ this.languages = this.config.get('languages');
314
+ if (!this.languages) {
315
+ this.languages = [
316
+ {
317
+ key: 'fr',
318
+ label: 'French',
319
+ direction: 'ltr',
320
+ },
321
+ {
322
+ key: 'de',
323
+ label: 'German',
324
+ direction: 'ltr',
325
+ },
326
+ {
327
+ key: 'en',
328
+ label: 'English',
329
+ direction: 'ltr',
330
+ },
331
+ {
332
+ key: 'ar',
333
+ label: 'Arabic',
334
+ direction: 'rtl',
335
+ },
336
+ ];
337
+ }
338
+ return this.languages;
339
+ }
340
+ getDefaultLocale() {
341
+ this.locale = this.userProfileService.getLocale();
342
+ if (!this.locale) {
343
+ this.locale = this.config.get('locale')
344
+ ? this.config.get('locale')
345
+ : this.translate.getBrowserLang()
346
+ ? this.translate.getBrowserLang()
347
+ : 'en';
348
+ }
349
+ return this.getLanguages().find((e) => e.key === this.locale);
350
+ }
351
+ getActiveLocale() {
352
+ if (this.userProfileService.getLocale()) {
353
+ return this.getLanguages().find((e) => e.key === this.userProfileService.getLocale());
354
+ }
355
+ }
356
+ setActiveLocale(locale) {
357
+ if (locale) {
358
+ this.translate.use(locale.key);
359
+ this.setTextOrientation(locale.direction);
360
+ this.userProfileService.setLocale(locale.key);
361
+ }
362
+ }
363
+ }
364
+ LocaleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocaleService, deps: [{ token: AppConfigService }, { token: i2$1.TranslateService }, { token: UserProfileService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
365
+ LocaleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocaleService, providedIn: 'root' });
366
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LocaleService, decorators: [{
367
+ type: Injectable,
368
+ args: [{
369
+ providedIn: 'root',
370
+ }]
371
+ }], ctorParameters: function () {
372
+ return [{ type: AppConfigService }, { type: i2$1.TranslateService }, { type: UserProfileService }, { type: Document, decorators: [{
373
+ type: Inject,
374
+ args: [DOCUMENT]
375
+ }] }];
376
+ } });
377
+
378
+ class LanguageMenuComponent {
379
+ constructor(localeService) {
380
+ this.localeService = localeService;
381
+ this.showLocaleKeyAsLabel = false;
382
+ this.showLocaleAsLabel = false;
383
+ this.languages = [];
384
+ }
385
+ ngOnInit() {
386
+ this.languages = this.localeService.getLanguages();
387
+ this.localeService.setActiveLocale(this.locale);
388
+ }
389
+ onChangeLanguage(language) {
390
+ this.localeService.setActiveLocale(language);
391
+ }
392
+ get locale() {
393
+ return this.localeService.getActiveLocale() || this.localeService.getDefaultLocale();
394
+ }
395
+ }
396
+ LanguageMenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LanguageMenuComponent, deps: [{ token: LocaleService }], target: i0.ɵɵFactoryTarget.Component });
397
+ LanguageMenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: LanguageMenuComponent, selector: "mnl-language-menu", inputs: { showLocaleKeyAsLabel: "showLocaleKeyAsLabel", showLocaleAsLabel: "showLocaleAsLabel" }, ngImport: i0, template: "<button id=\"mnl-locale-button\" mat-menu-item [matMenuTriggerFor]=\"languageMenu\">\n <ng-container *ngIf=\"showLocaleKeyAsLabel || showLocaleAsLabel; else defaultLabel\">\n <div *ngIf=\"showLocaleKeyAsLabel\">{{ locale.key | uppercase }}</div>\n <div *ngIf=\"showLocaleAsLabel\">{{ locale.label }}</div>\n </ng-container>\n <ng-template #defaultLabel>\n <mat-icon>language</mat-icon>\n {{ \"MNL.LANGUAGE-SELECTOR.LANGUAGES\" | translate }}\n </ng-template>\n</button>\n<mat-menu #languageMenu=\"matMenu\">\n <button\n mat-menu-item\n *ngFor=\"let language of languages\"\n (click)=\"onChangeLanguage(language)\"\n id=\"langMenu\"\n >\n {{ language.label }}\n </button>\n</mat-menu>\n", styles: [""], 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: i3$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i4.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { kind: "component", type: i4.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i4.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { kind: "pipe", type: i1.UpperCasePipe, name: "uppercase" }, { kind: "pipe", type: i2$1.TranslatePipe, name: "translate" }] });
398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LanguageMenuComponent, decorators: [{
399
+ type: Component,
400
+ args: [{ selector: 'mnl-language-menu', template: "<button id=\"mnl-locale-button\" mat-menu-item [matMenuTriggerFor]=\"languageMenu\">\n <ng-container *ngIf=\"showLocaleKeyAsLabel || showLocaleAsLabel; else defaultLabel\">\n <div *ngIf=\"showLocaleKeyAsLabel\">{{ locale.key | uppercase }}</div>\n <div *ngIf=\"showLocaleAsLabel\">{{ locale.label }}</div>\n </ng-container>\n <ng-template #defaultLabel>\n <mat-icon>language</mat-icon>\n {{ \"MNL.LANGUAGE-SELECTOR.LANGUAGES\" | translate }}\n </ng-template>\n</button>\n<mat-menu #languageMenu=\"matMenu\">\n <button\n mat-menu-item\n *ngFor=\"let language of languages\"\n (click)=\"onChangeLanguage(language)\"\n id=\"langMenu\"\n >\n {{ language.label }}\n </button>\n</mat-menu>\n" }]
401
+ }], ctorParameters: function () { return [{ type: LocaleService }]; }, propDecorators: { showLocaleKeyAsLabel: [{
402
+ type: Input
403
+ }], showLocaleAsLabel: [{
404
+ type: Input
405
+ }] } });
406
+
407
+ class LoginComponent {
408
+ constructor(sanitizer) {
409
+ this.sanitizer = sanitizer;
410
+ this.title = '';
411
+ this.logoImageUrl = './assets/images/logo.png';
412
+ this.backgroundImageUrl = './assets/images/background.jpg';
413
+ this.disabled = false;
414
+ this.login = new EventEmitter();
415
+ }
416
+ ngOnInit() {
417
+ this.initForm();
418
+ }
419
+ initForm() {
420
+ this.formGroup = new UntypedFormGroup({
421
+ username: new UntypedFormControl('', [Validators.required]),
422
+ password: new UntypedFormControl('', [Validators.required])
423
+ });
424
+ }
425
+ onSubmit() {
426
+ if (this.formGroup.valid) {
427
+ this.login.emit(this.formGroup.value);
428
+ }
429
+ }
430
+ getBackgroundImageUrl() {
431
+ return this.sanitizer.bypassSecurityTrustStyle(`url(${this.backgroundImageUrl})`);
432
+ }
433
+ }
434
+ LoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoginComponent, deps: [{ token: i1$2.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component });
435
+ LoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: LoginComponent, selector: "mnl-login", inputs: { title: "title", logoImageUrl: "logoImageUrl", backgroundImageUrl: "backgroundImageUrl", disabled: "disabled" }, outputs: { login: "login" }, ngImport: i0, template: "<div class=\"flex justify-center items-center min-h-full bg-cover\" [style.background-image]=\"getBackgroundImageUrl()\">\n <mat-card class=\"min-w-[260px]\">\n <form class=\"flex items-stretch flex-col\" [formGroup]=\"formGroup\" (ngSubmit)=\"onSubmit()\">\n <mat-card-header class=\"flex justify-center items-center\">\n <mat-card-title>\n <img *ngIf=\"logoImageUrl\" src=\"{{logoImageUrl}}\">\n </mat-card-title>\n </mat-card-header>\n <h3 class=\"flex justify-center items-center opacity-60\" *ngIf=\"title\">{{title | translate}}</h3>\n <mat-form-field class=\"grow max-w-100\">\n <input id=\"username\" matInput placeholder=\"{{'MNL.LOGIN.USERNAME' | translate}}\"\n formControlName=\"username\">\n </mat-form-field>\n\n <mat-form-field class=\"grow max-w-100\">\n <input id=\"password\" matInput type=\"password\" placeholder=\"{{'MNL.LOGIN.PASSWORD' | translate}}\"\n formControlName=\"password\">\n </mat-form-field>\n <mat-card-actions class=\"flex justify-center items-center\">\n <button id=\"loginButton\" mat-raised-button color=\"accent\" [disabled]=\"disabled || !formGroup.valid\"\n type=\"submit\"> {{'MNL.LOGIN.LOGIN_BUTTON' | translate}}</button>\n </mat-card-actions>\n\n </form>\n </mat-card>\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i4$1.MatCard, selector: "mat-card", exportAs: ["matCard"] }, { kind: "component", type: i4$1.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i4$1.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "directive", type: i4$1.MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "component", type: i5.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i6.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "directive", type: i7.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i7.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i7.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i7.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "pipe", type: i2$1.TranslatePipe, name: "translate" }] });
436
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LoginComponent, decorators: [{
437
+ type: Component,
438
+ args: [{ selector: 'mnl-login', template: "<div class=\"flex justify-center items-center min-h-full bg-cover\" [style.background-image]=\"getBackgroundImageUrl()\">\n <mat-card class=\"min-w-[260px]\">\n <form class=\"flex items-stretch flex-col\" [formGroup]=\"formGroup\" (ngSubmit)=\"onSubmit()\">\n <mat-card-header class=\"flex justify-center items-center\">\n <mat-card-title>\n <img *ngIf=\"logoImageUrl\" src=\"{{logoImageUrl}}\">\n </mat-card-title>\n </mat-card-header>\n <h3 class=\"flex justify-center items-center opacity-60\" *ngIf=\"title\">{{title | translate}}</h3>\n <mat-form-field class=\"grow max-w-100\">\n <input id=\"username\" matInput placeholder=\"{{'MNL.LOGIN.USERNAME' | translate}}\"\n formControlName=\"username\">\n </mat-form-field>\n\n <mat-form-field class=\"grow max-w-100\">\n <input id=\"password\" matInput type=\"password\" placeholder=\"{{'MNL.LOGIN.PASSWORD' | translate}}\"\n formControlName=\"password\">\n </mat-form-field>\n <mat-card-actions class=\"flex justify-center items-center\">\n <button id=\"loginButton\" mat-raised-button color=\"accent\" [disabled]=\"disabled || !formGroup.valid\"\n type=\"submit\"> {{'MNL.LOGIN.LOGIN_BUTTON' | translate}}</button>\n </mat-card-actions>\n\n </form>\n </mat-card>\n</div>" }]
439
+ }], ctorParameters: function () { return [{ type: i1$2.DomSanitizer }]; }, propDecorators: { title: [{
440
+ type: Input
441
+ }], logoImageUrl: [{
442
+ type: Input
443
+ }], backgroundImageUrl: [{
444
+ type: Input
445
+ }], disabled: [{
446
+ type: Input
447
+ }], login: [{
448
+ type: Output
449
+ }] } });
450
+
451
+ class MenuComponent {
452
+ constructor() {
453
+ this.menuClick = new EventEmitter();
454
+ }
455
+ onMenuClick(menu) {
456
+ if (this.hasSubMenu(menu)) {
457
+ this.openMenu(menu);
458
+ this.onSubMenuClick(menu.subMenus[0], menu);
459
+ }
460
+ else {
461
+ this.deSelectMenus(this.menuData);
462
+ this.selectMenu(menu);
463
+ this.menuClick.emit(menu);
464
+ }
465
+ }
466
+ onSubMenuClick(subMenu, menu) {
467
+ this.deSelectMenus(this.menuData);
468
+ this.selectMenu(menu);
469
+ this.selectMenu(subMenu);
470
+ this.menuClick.emit(subMenu);
471
+ }
472
+ deSelectMenus(menus) {
473
+ if (menus) {
474
+ for (const menu of menus) {
475
+ if (menu.selected) {
476
+ menu.selected = false;
477
+ }
478
+ this.deSelectMenus(menu.subMenus);
479
+ }
480
+ }
481
+ }
482
+ selectMenu(menu) {
483
+ if (menu) {
484
+ menu.selected = true;
485
+ }
486
+ }
487
+ hasSubMenu(menu) {
488
+ return menu.subMenus && menu.subMenus.length > 0;
489
+ }
490
+ toggleMenu(menu, event) {
491
+ menu.expanded = !menu.expanded;
492
+ if (event) {
493
+ event.stopPropagation();
494
+ }
495
+ }
496
+ openMenu(menu) {
497
+ menu.expanded = true;
498
+ }
499
+ }
500
+ MenuComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
501
+ MenuComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: MenuComponent, selector: "mnl-menu", inputs: { menuData: "menuData" }, outputs: { menuClick: "menuClick" }, ngImport: i0, template: "<mat-nav-list *ngFor=\"let menu of menuData\">\n <a mat-list-item class=\"flex flex-row\" (click)=\"onMenuClick(menu)\" id=\"mnl-menu-anchor\">\n <mnl-highlighter [enabled]=\"menu.selected\"></mnl-highlighter>\n <mat-icon *ngIf=\"menu.icon; else svgTemplate \">{{menu.icon}}</mat-icon>\n <ng-template #svgTemplate>\n <mat-icon svgIcon=\"{{menu.svgIcon}}\"> </mat-icon>\n </ng-template>\n <span class=\"mnl-menu\" id=\"mnl-menu\">{{menu.name | translate }}</span>\n <mat-icon class=\"mnl-menu-button\" *ngIf=\"menu.subMenus\" (click)=\"toggleMenu(menu, $event)\"\n [ngClass]=\"{'mnl-rotated' : menu.expanded}\">expand_more</mat-icon>\n </a>\n <ng-container *ngFor=\"let sub of menu.subMenus\">\n <a mat-list-item class=\"mnl-submenu flex flex-row\" [class.mnl-expanded]=\"menu.expanded\" *ngIf=\"menu.expanded\"\n (click)=\"onSubMenuClick(sub, menu)\" id=\"mnl-submenu-anchor\">\n <mnl-highlighter [enabled]=\"sub.selected\"></mnl-highlighter>\n <mat-icon>{{sub.icon}}</mat-icon>\n <span class=\"mnl-menu\" id=\"mnl-submenu\">{{sub.name | translate }}</span>\n </a>\n </ng-container>\n</mat-nav-list>", styles: [".mnl-submenu{overflow-y:hidden;transition:transform .3s ease;transform:scaleY(0);transform-origin:top;padding-left:15px!important}.mnl-submenu.mnl-expanded{transform:scaleY(1)}.mnl-menu{margin-top:5px;margin-left:10px;margin-right:10px}.mnl-menu-button{transition:.3s ease-in-out;transform:rotate(0);margin-top:3px;margin-left:25px}.mnl-menu-button.mnl-rotated{transform:rotate(180deg)}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { 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: i3$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i3$2.MatNavList, selector: "mat-nav-list", inputs: ["disableRipple", "disabled"], exportAs: ["matNavList"] }, { kind: "component", type: i3$2.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["disableRipple", "disabled"], exportAs: ["matListItem"] }, { kind: "component", type: HighlighterComponent, selector: "mnl-highlighter", inputs: ["height", "width", "enabled"] }, { kind: "pipe", type: i2$1.TranslatePipe, name: "translate" }] });
502
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: MenuComponent, decorators: [{
503
+ type: Component,
504
+ args: [{ selector: 'mnl-menu', template: "<mat-nav-list *ngFor=\"let menu of menuData\">\n <a mat-list-item class=\"flex flex-row\" (click)=\"onMenuClick(menu)\" id=\"mnl-menu-anchor\">\n <mnl-highlighter [enabled]=\"menu.selected\"></mnl-highlighter>\n <mat-icon *ngIf=\"menu.icon; else svgTemplate \">{{menu.icon}}</mat-icon>\n <ng-template #svgTemplate>\n <mat-icon svgIcon=\"{{menu.svgIcon}}\"> </mat-icon>\n </ng-template>\n <span class=\"mnl-menu\" id=\"mnl-menu\">{{menu.name | translate }}</span>\n <mat-icon class=\"mnl-menu-button\" *ngIf=\"menu.subMenus\" (click)=\"toggleMenu(menu, $event)\"\n [ngClass]=\"{'mnl-rotated' : menu.expanded}\">expand_more</mat-icon>\n </a>\n <ng-container *ngFor=\"let sub of menu.subMenus\">\n <a mat-list-item class=\"mnl-submenu flex flex-row\" [class.mnl-expanded]=\"menu.expanded\" *ngIf=\"menu.expanded\"\n (click)=\"onSubMenuClick(sub, menu)\" id=\"mnl-submenu-anchor\">\n <mnl-highlighter [enabled]=\"sub.selected\"></mnl-highlighter>\n <mat-icon>{{sub.icon}}</mat-icon>\n <span class=\"mnl-menu\" id=\"mnl-submenu\">{{sub.name | translate }}</span>\n </a>\n </ng-container>\n</mat-nav-list>", styles: [".mnl-submenu{overflow-y:hidden;transition:transform .3s ease;transform:scaleY(0);transform-origin:top;padding-left:15px!important}.mnl-submenu.mnl-expanded{transform:scaleY(1)}.mnl-menu{margin-top:5px;margin-left:10px;margin-right:10px}.mnl-menu-button{transition:.3s ease-in-out;transform:rotate(0);margin-top:3px;margin-left:25px}.mnl-menu-button.mnl-rotated{transform:rotate(180deg)}\n"] }]
505
+ }], propDecorators: { menuData: [{
506
+ type: Input
507
+ }], menuClick: [{
508
+ type: Output
509
+ }] } });
510
+
511
+ class UserInitialPipe {
512
+ transform(value) {
513
+ let userInitials = '';
514
+ if (!this.isEmptyObject(value)) {
515
+ if (value.firstName && value.lastName) {
516
+ userInitials = value.firstName.substring(0, 1).toUpperCase() + value.lastName.substring(0, 1).toUpperCase();
517
+ }
518
+ else if (!value.firstName && value.lastName) {
519
+ userInitials = this.getUserInitials(value.lastName);
520
+ }
521
+ else if (value.firstName && !value.lastName) {
522
+ userInitials = this.getUserInitials(value.firstName);
523
+ }
524
+ else if (!value.firstName && !value.lastName) {
525
+ userInitials = value.email.substring(0, 1).toUpperCase();
526
+ }
527
+ }
528
+ return userInitials;
529
+ }
530
+ isEmptyObject(data) {
531
+ return (data && (Object.keys(data).length === 0));
532
+ }
533
+ getUserInitials(name) {
534
+ let userInitial = '';
535
+ if (this.hasWhiteSpace(name.trim())) {
536
+ const data = name.split(/\s+/);
537
+ userInitial = data[0].substring(0, 1).toUpperCase() + data[1].substring(0, 1).toUpperCase();
538
+ }
539
+ else {
540
+ userInitial = name.trim().substring(0, 1).toUpperCase();
541
+ }
542
+ return userInitial;
543
+ }
544
+ hasWhiteSpace(data) {
545
+ return /\s/g.test(data);
546
+ }
547
+ }
548
+ UserInitialPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserInitialPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
549
+ UserInitialPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: UserInitialPipe, name: "mnlUserInitialPipe" });
550
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserInitialPipe, decorators: [{
551
+ type: Pipe,
552
+ args: [{
553
+ name: 'mnlUserInitialPipe'
554
+ }]
555
+ }] });
556
+
557
+ class UserFullnamePipe {
558
+ transform(value) {
559
+ let fullName = '';
560
+ if (!this.isEmptyObject(value)) {
561
+ if (value.firstName && value.lastName) {
562
+ fullName = value.firstName + ' ' + value.lastName;
563
+ }
564
+ else if (!value.firstName && value.lastName) {
565
+ fullName = value.lastName;
566
+ }
567
+ else if (value.firstName && !value.lastName) {
568
+ fullName = value.firstName;
569
+ }
570
+ else if (!value.firstName && !value.lastName) {
571
+ fullName = value.email;
572
+ }
573
+ }
574
+ return fullName;
575
+ }
576
+ isEmptyObject(data) {
577
+ return (data && (Object.keys(data).length === 0));
578
+ }
579
+ }
580
+ UserFullnamePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserFullnamePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
581
+ UserFullnamePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: UserFullnamePipe, name: "mnlUserFullName" });
582
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: UserFullnamePipe, decorators: [{
583
+ type: Pipe,
584
+ args: [{
585
+ name: 'mnlUserFullName'
586
+ }]
587
+ }] });
588
+
589
+ class ProfileComponent {
590
+ constructor() {
591
+ this.showDisplayName = true;
592
+ this.userInitialClick = new EventEmitter();
593
+ this.profileMenuClick = new EventEmitter();
594
+ }
595
+ onUserInitialClick(event) {
596
+ this.userInitialClick.emit(event);
597
+ }
598
+ ngOnChanges(changes) {
599
+ if (changes && changes.userProfileDetails && changes.userProfileDetails.currentValue
600
+ && changes.userProfileDetails.currentValue.firstName && changes.userProfileDetails.currentValue.lastName
601
+ && changes.userProfileDetails.currentValue.email) {
602
+ this.hasUserDetails = true;
603
+ }
604
+ else {
605
+ this.hasUserDetails = false;
606
+ }
607
+ }
608
+ }
609
+ ProfileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ProfileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
610
+ ProfileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ProfileComponent, selector: "mnl-user-profile", inputs: { userProfileDetails: "userProfileDetails", showDisplayName: "showDisplayName" }, outputs: { userInitialClick: "userInitialClick", profileMenuClick: "profileMenuClick" }, usesOnChanges: true, ngImport: i0, template: "<div id=\"mnl-profile-container\" class=\"flex gap-[10px]\">\n <span\n *ngIf=\"showDisplayName && hasUserDetails\"\n id=\"mnl-userinfo-name\"\n class=\" hidden md:inline\"\n >{{ userProfileDetails | mnlUserFullName }}</span\n >\n <button\n *ngIf=\"hasUserDetails\"\n id=\"mnl-initials-button\"\n mat-raised-button\n (click)=\"onUserInitialClick($event)\"\n mat-icon-button\n >\n {{ userProfileDetails | mnlUserInitialPipe }}\n </button>\n\n <button\n *ngIf=\"!hasUserDetails\"\n id=\"mnl-user-icon-button\"\n mat-raised-button\n (click)=\"onUserInitialClick($event)\"\n mat-icon-button\n >\n <mat-icon>person</mat-icon>\n </button>\n</div>\n", styles: ["#mnl-initials-button{border-radius:20px}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i3$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "pipe", type: UserInitialPipe, name: "mnlUserInitialPipe" }, { kind: "pipe", type: UserFullnamePipe, name: "mnlUserFullName" }] });
611
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ProfileComponent, decorators: [{
612
+ type: Component,
613
+ args: [{ selector: 'mnl-user-profile', template: "<div id=\"mnl-profile-container\" class=\"flex gap-[10px]\">\n <span\n *ngIf=\"showDisplayName && hasUserDetails\"\n id=\"mnl-userinfo-name\"\n class=\" hidden md:inline\"\n >{{ userProfileDetails | mnlUserFullName }}</span\n >\n <button\n *ngIf=\"hasUserDetails\"\n id=\"mnl-initials-button\"\n mat-raised-button\n (click)=\"onUserInitialClick($event)\"\n mat-icon-button\n >\n {{ userProfileDetails | mnlUserInitialPipe }}\n </button>\n\n <button\n *ngIf=\"!hasUserDetails\"\n id=\"mnl-user-icon-button\"\n mat-raised-button\n (click)=\"onUserInitialClick($event)\"\n mat-icon-button\n >\n <mat-icon>person</mat-icon>\n </button>\n</div>\n", styles: ["#mnl-initials-button{border-radius:20px}\n"] }]
614
+ }], propDecorators: { userProfileDetails: [{
615
+ type: Input
616
+ }], showDisplayName: [{
617
+ type: Input
618
+ }], userInitialClick: [{
619
+ type: Output
620
+ }], profileMenuClick: [{
621
+ type: Output
622
+ }] } });
623
+
624
+ const MNL_TRANSLATION_RESOURCE = new InjectionToken('Translation Resource');
625
+ function translationLoaderFactory(http, resources) {
626
+ if (!resources) {
627
+ resources = [];
628
+ }
629
+ else if (!resources.length) {
630
+ resources = [resources];
631
+ }
632
+ resources.push({ prefix: './assets/mnl-commons/i18n/', suffix: '.json' });
633
+ return new MultiTranslateHttpLoader(http, resources);
634
+ }
635
+
636
+ class AppConfigPipe {
637
+ constructor(config) {
638
+ this.config = config;
639
+ }
640
+ transform(value, defaultValue) {
641
+ return this.config.get(value) || defaultValue || '';
642
+ }
643
+ }
644
+ AppConfigPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppConfigPipe, deps: [{ token: AppConfigService }], target: i0.ɵɵFactoryTarget.Pipe });
645
+ AppConfigPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: AppConfigPipe, name: "mnlAppConfig" });
646
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AppConfigPipe, decorators: [{
647
+ type: Pipe,
648
+ args: [{
649
+ name: 'mnlAppConfig'
650
+ }]
651
+ }], ctorParameters: function () { return [{ type: AppConfigService }]; } });
652
+
653
+ class TimeAgoPipe {
654
+ constructor(appConfigService, userProfileService) {
655
+ this.appConfigService = appConfigService;
656
+ this.userProfileService = userProfileService;
657
+ this.defaultLocale = TimeAgoPipe.DEFAULT_LOCALE;
658
+ this.defaultDateTimeFormat = TimeAgoPipe.DEFAULT_DATE_TIME_FORMAT;
659
+ }
660
+ transform(value, dateTimeFormat, locale) {
661
+ if (value) {
662
+ const currentLocale = this.userProfileService.getLocale();
663
+ const currentDateTimeFormat = this.appConfigService.get('dateTimeFormat');
664
+ const requiredLocale = locale || currentLocale || this.defaultLocale;
665
+ const requiredDateTimeFormat = dateTimeFormat || currentDateTimeFormat || this.defaultDateTimeFormat;
666
+ if (differenceInDays(new Date(), new Date(value)) > 7) {
667
+ const datePipe = new DatePipe(requiredLocale);
668
+ return datePipe.transform(value, requiredDateTimeFormat);
669
+ }
670
+ return formatDistance(new Date(value), new Date(), {
671
+ includeSeconds: true,
672
+ addSuffix: true,
673
+ });
674
+ }
675
+ return '';
676
+ }
677
+ }
678
+ TimeAgoPipe.DEFAULT_LOCALE = 'en-US';
679
+ TimeAgoPipe.DEFAULT_DATE_TIME_FORMAT = 'dd/MM/yyyy HH:mm';
680
+ TimeAgoPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeAgoPipe, deps: [{ token: AppConfigService }, { token: UserProfileService }], target: i0.ɵɵFactoryTarget.Pipe });
681
+ TimeAgoPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: TimeAgoPipe, name: "mnlTimeAgo" });
682
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeAgoPipe, decorators: [{
683
+ type: Pipe,
684
+ args: [{
685
+ name: 'mnlTimeAgo',
686
+ }]
687
+ }], ctorParameters: function () { return [{ type: AppConfigService }, { type: UserProfileService }]; } });
688
+
689
+ class LogLevelsEnum extends Number {
690
+ }
691
+ LogLevelsEnum.TRACE = 5;
692
+ LogLevelsEnum.DEBUG = 1;
693
+ LogLevelsEnum.INFO = 2;
694
+ LogLevelsEnum.WARN = 3;
695
+ LogLevelsEnum.ERROR = 4;
696
+ LogLevelsEnum.SILENT = 0;
697
+ let logLevels = [
698
+ { level: LogLevelsEnum.TRACE, name: 'TRACE' },
699
+ { level: LogLevelsEnum.DEBUG, name: 'DEBUG' },
700
+ { level: LogLevelsEnum.INFO, name: 'INFO' },
701
+ { level: LogLevelsEnum.WARN, name: 'WARN' },
702
+ { level: LogLevelsEnum.ERROR, name: 'ERROR' },
703
+ { level: LogLevelsEnum.SILENT, name: 'SILENT' }
704
+ ];
705
+
706
+ /* eslint-disable no-console */
707
+ class LogService {
708
+ constructor(appConfigService) {
709
+ this.appConfigService = appConfigService;
710
+ this.onMessage = new Subject();
711
+ }
712
+ get currentLogLevel() {
713
+ const configLevel = this.appConfigService.get('logLevel');
714
+ if (configLevel) {
715
+ return this.getLogLevel(configLevel);
716
+ }
717
+ return LogLevelsEnum.ERROR;
718
+ }
719
+ error(message, ...optionalParams) {
720
+ if (this.currentLogLevel >= LogLevelsEnum.ERROR) {
721
+ this.messageBus(message, 'ERROR');
722
+ console.error(message, ...optionalParams);
723
+ }
724
+ }
725
+ debug(message, ...optionalParams) {
726
+ if (this.currentLogLevel >= LogLevelsEnum.DEBUG) {
727
+ this.messageBus(message, 'DEBUG');
728
+ console.debug(message, ...optionalParams);
729
+ }
730
+ }
731
+ info(message, ...optionalParams) {
732
+ if (this.currentLogLevel >= LogLevelsEnum.INFO) {
733
+ this.messageBus(message, 'INFO');
734
+ console.info(message, ...optionalParams);
735
+ }
736
+ }
737
+ log(message, ...optionalParams) {
738
+ if (this.currentLogLevel >= LogLevelsEnum.TRACE) {
739
+ this.messageBus(message, 'LOG');
740
+ console.log(message, ...optionalParams);
741
+ }
742
+ }
743
+ trace(message, ...optionalParams) {
744
+ if (this.currentLogLevel >= LogLevelsEnum.TRACE) {
745
+ this.messageBus(message, 'TRACE');
746
+ console.trace(message, ...optionalParams);
747
+ }
748
+ }
749
+ warn(message, ...optionalParams) {
750
+ if (this.currentLogLevel >= LogLevelsEnum.WARN) {
751
+ this.messageBus(message, 'WARN');
752
+ console.warn(message, ...optionalParams);
753
+ }
754
+ }
755
+ assert(test, message, ...optionalParams) {
756
+ if (this.currentLogLevel !== LogLevelsEnum.SILENT) {
757
+ this.messageBus(message, 'ASSERT');
758
+ console.assert(test, message, ...optionalParams);
759
+ }
760
+ }
761
+ group(groupTitle, ...optionalParams) {
762
+ if (this.currentLogLevel !== LogLevelsEnum.SILENT) {
763
+ console.group(groupTitle, ...optionalParams);
764
+ }
765
+ }
766
+ groupEnd() {
767
+ if (this.currentLogLevel !== LogLevelsEnum.SILENT) {
768
+ console.groupEnd();
769
+ }
770
+ }
771
+ getLogLevel(level) {
772
+ const referencedLevel = logLevels.find((currentLevel) => {
773
+ return currentLevel.name.toLocaleLowerCase() === level.toLocaleLowerCase();
774
+ });
775
+ return referencedLevel ? referencedLevel.level : 4;
776
+ }
777
+ messageBus(message, logLevel) {
778
+ this.onMessage.next({ text: message, type: logLevel });
779
+ }
780
+ }
781
+ LogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LogService, deps: [{ token: AppConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
782
+ LogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LogService, providedIn: 'root' });
783
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: LogService, decorators: [{
784
+ type: Injectable,
785
+ args: [{
786
+ providedIn: 'root'
787
+ }]
788
+ }], ctorParameters: function () { return [{ type: AppConfigService }]; } });
789
+
790
+ registerLocaleData(localeFR);
791
+ registerLocaleData(localeDE);
792
+ registerLocaleData(localeAR);
793
+ class CommonsModule {
794
+ static forRoot() {
795
+ return {
796
+ ngModule: CommonsModule,
797
+ providers: [
798
+ {
799
+ provide: APP_INITIALIZER,
800
+ useFactory: loadConfig,
801
+ deps: [
802
+ AppConfigService,
803
+ UserProfileService,
804
+ LocalStorageService,
805
+ LogService,
806
+ LocaleService,
807
+ ],
808
+ multi: true,
809
+ },
810
+ ],
811
+ };
812
+ }
813
+ static forChild() {
814
+ return {
815
+ ngModule: CommonsModule,
816
+ };
817
+ }
818
+ }
819
+ CommonsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CommonsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
820
+ CommonsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: CommonsModule, declarations: [HeaderComponent,
821
+ MenuComponent,
822
+ HighlighterComponent,
823
+ AppConfigPipe,
824
+ LoginComponent,
825
+ LanguageMenuComponent,
826
+ ProfileComponent,
827
+ UserInitialPipe,
828
+ TimeAgoPipe,
829
+ UserFullnamePipe], imports: [CommonModule,
830
+ MatToolbarModule,
831
+ MaterialModule, i2$1.TranslateModule], exports: [HeaderComponent,
832
+ MenuComponent,
833
+ HighlighterComponent,
834
+ AppConfigPipe,
835
+ LanguageMenuComponent,
836
+ LoginComponent,
837
+ ProfileComponent,
838
+ UserInitialPipe,
839
+ TimeAgoPipe,
840
+ UserFullnamePipe,
841
+ TranslateModule] });
842
+ CommonsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CommonsModule, imports: [CommonModule,
843
+ MatToolbarModule,
844
+ MaterialModule,
845
+ TranslateModule.forRoot({
846
+ loader: {
847
+ provide: TranslateLoader,
848
+ useFactory: translationLoaderFactory,
849
+ deps: [HttpClient, MNL_TRANSLATION_RESOURCE],
850
+ },
851
+ }), TranslateModule] });
852
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CommonsModule, decorators: [{
853
+ type: NgModule,
854
+ args: [{
855
+ declarations: [
856
+ HeaderComponent,
857
+ MenuComponent,
858
+ HighlighterComponent,
859
+ AppConfigPipe,
860
+ LoginComponent,
861
+ LanguageMenuComponent,
862
+ ProfileComponent,
863
+ UserInitialPipe,
864
+ TimeAgoPipe,
865
+ UserFullnamePipe,
866
+ ],
867
+ imports: [
868
+ CommonModule,
869
+ MatToolbarModule,
870
+ MaterialModule,
871
+ TranslateModule.forRoot({
872
+ loader: {
873
+ provide: TranslateLoader,
874
+ useFactory: translationLoaderFactory,
875
+ deps: [HttpClient, MNL_TRANSLATION_RESOURCE],
876
+ },
877
+ }),
878
+ ],
879
+ exports: [
880
+ HeaderComponent,
881
+ MenuComponent,
882
+ HighlighterComponent,
883
+ AppConfigPipe,
884
+ LanguageMenuComponent,
885
+ LoginComponent,
886
+ ProfileComponent,
887
+ UserInitialPipe,
888
+ TimeAgoPipe,
889
+ UserFullnamePipe,
890
+ TranslateModule,
891
+ ],
892
+ }]
893
+ }] });
894
+ function loadConfig(config) {
895
+ const conf = () => config.load();
896
+ return conf;
897
+ }
898
+
899
+ /*
900
+ * Public API Surface of mnl-commons
901
+ */
902
+
903
+ /**
904
+ * Generated bundle index. Do not edit.
905
+ */
906
+
907
+ export { AppConfigPipe, AppConfigService, CommonsModule, HeaderComponent, HighlighterComponent, LanguageMenuComponent, LocalStorageService, LocaleService, LogLevelsEnum, LogService, LoginComponent, MNL_TRANSLATION_RESOURCE, MaterialModule, MenuComponent, ProfileComponent, TimeAgoPipe, UserFullnamePipe, UserInitialPipe, UserProfileService, loadConfig, logLevels, modules, translationLoaderFactory };
908
+ //# sourceMappingURL=muraai-mnl-commons.mjs.map