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