@eui/core 17.0.0-next.1 → 17.0.0-next.11

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 (269) hide show
  1. package/assets/i18n-eui/bg.json +2 -1
  2. package/assets/i18n-eui/cs.json +2 -1
  3. package/assets/i18n-eui/da.json +2 -1
  4. package/assets/i18n-eui/de.json +2 -1
  5. package/assets/i18n-eui/el.json +2 -1
  6. package/assets/i18n-eui/en.json +2 -1
  7. package/assets/i18n-eui/es.json +2 -1
  8. package/assets/i18n-eui/et.json +2 -1
  9. package/assets/i18n-eui/fi.json +2 -1
  10. package/assets/i18n-eui/fr.json +2 -1
  11. package/assets/i18n-eui/ga.json +2 -1
  12. package/assets/i18n-eui/hr.json +2 -1
  13. package/assets/i18n-eui/hu.json +2 -1
  14. package/assets/i18n-eui/it.json +2 -1
  15. package/assets/i18n-eui/lt.json +2 -1
  16. package/assets/i18n-eui/lv.json +2 -1
  17. package/assets/i18n-eui/mt.json +2 -1
  18. package/assets/i18n-eui/nl.json +2 -1
  19. package/assets/i18n-eui/pl.json +2 -1
  20. package/assets/i18n-eui/pt.json +2 -1
  21. package/assets/i18n-eui/readme.md +8 -0
  22. package/assets/i18n-eui/ro.json +2 -1
  23. package/assets/i18n-eui/sk.json +2 -1
  24. package/assets/i18n-eui/sl.json +2 -1
  25. package/assets/i18n-eui/sv.json +2 -1
  26. package/esm2022/lib/eui-core.module.mjs +7 -7
  27. package/esm2022/lib/interceptors/add-lang-param.interceptor.mjs +5 -5
  28. package/esm2022/lib/interceptors/cache-prevention.interceptor.mjs +4 -4
  29. package/esm2022/lib/interceptors/cors-security.interceptor.mjs +4 -4
  30. package/esm2022/lib/interceptors/csrf-prevention.interceptor.mjs +4 -4
  31. package/esm2022/lib/interceptors/eu-login-session-timeout-handling.interceptor.mjs +6 -6
  32. package/esm2022/lib/interceptors/openid/openid-connect.interceptor.mjs +13 -8
  33. package/esm2022/lib/interceptors/openid/openid-connect.service.mjs +5 -5
  34. package/esm2022/lib/interceptors/ux-request-error-model.interceptor.mjs +6 -6
  35. package/esm2022/lib/services/dynamic-component/dynamic-component.service.mjs +63 -0
  36. package/esm2022/lib/services/dynamic-menu/dynamic-menu.service.mjs +11 -11
  37. package/esm2022/lib/services/errors/eui.error.mjs +3 -1
  38. package/esm2022/lib/services/errors/global-error-handler.mjs +5 -5
  39. package/esm2022/lib/services/errors/http-error-handler-callback-functions.mjs +4 -5
  40. package/esm2022/lib/services/errors/http-error-handler.interceptor.mjs +6 -6
  41. package/esm2022/lib/services/eui-app-shell.service.mjs +575 -0
  42. package/esm2022/lib/services/eui-timezone.service.mjs +4 -4
  43. package/esm2022/lib/services/growl/eui-growl.service.mjs +79 -0
  44. package/esm2022/lib/services/growl/index.mjs +2 -0
  45. package/esm2022/lib/services/i18n/i18n.loader.mjs +6 -6
  46. package/esm2022/lib/services/i18n/i18n.service.mjs +6 -6
  47. package/esm2022/lib/services/i18n/i18n.service.mock.mjs +5 -5
  48. package/esm2022/lib/services/index.mjs +4 -5
  49. package/esm2022/lib/services/locale/locale.service.mjs +7 -6
  50. package/esm2022/lib/services/locale/locale.service.mock.mjs +6 -6
  51. package/esm2022/lib/services/log/log.module.mjs +5 -5
  52. package/esm2022/lib/services/log/log.service.mjs +6 -6
  53. package/esm2022/lib/services/permission/permission.service.mjs +6 -6
  54. package/esm2022/lib/services/queue/api-queue.service.mjs +5 -5
  55. package/esm2022/lib/services/queue/api-queue.service.mock.mjs +2 -2
  56. package/esm2022/lib/services/storage/local-forage.service.mjs +6 -6
  57. package/esm2022/lib/services/storage/local-storage.service.mjs +6 -6
  58. package/esm2022/lib/services/storage/session-storage.service.mjs +6 -6
  59. package/esm2022/lib/services/store/effects/app.effects.mjs +11 -21
  60. package/esm2022/lib/services/store/reducers/app.reducers.mjs +2 -1
  61. package/esm2022/lib/services/store/reducers/meta.reducers.mjs +2 -2
  62. package/esm2022/lib/services/store/store.service.mjs +6 -6
  63. package/esm2022/lib/services/store/store.service.mock.mjs +5 -5
  64. package/esm2022/lib/services/user/user.service.mjs +5 -5
  65. package/esm2022/lib/services/user/user.service.mock.mjs +5 -5
  66. package/fesm2022/eui-core.mjs +2093 -2103
  67. package/fesm2022/eui-core.mjs.map +1 -1
  68. package/lib/interceptors/eu-login-session-timeout-handling.interceptor.d.ts +1 -1
  69. package/lib/interceptors/eu-login-session-timeout-handling.interceptor.d.ts.map +1 -1
  70. package/lib/interceptors/openid/openid-connect.interceptor.d.ts.map +1 -1
  71. package/lib/services/{ux-dynamic-component/ux-dynamic-component.service.d.ts → dynamic-component/dynamic-component.service.d.ts} +4 -4
  72. package/lib/services/dynamic-component/dynamic-component.service.d.ts.map +1 -0
  73. package/lib/services/dynamic-menu/dynamic-menu.service.d.ts +2 -2
  74. package/lib/services/dynamic-menu/dynamic-menu.service.d.ts.map +1 -1
  75. package/lib/services/errors/eui.error.d.ts +0 -2
  76. package/lib/services/errors/eui.error.d.ts.map +1 -1
  77. package/lib/services/errors/http-error-handler-callback-functions.d.ts.map +1 -1
  78. package/lib/services/{ux-app-shell.service.d.ts → eui-app-shell.service.d.ts} +13 -4
  79. package/lib/services/eui-app-shell.service.d.ts.map +1 -0
  80. package/lib/services/growl/eui-growl.service.d.ts +22 -0
  81. package/lib/services/growl/eui-growl.service.d.ts.map +1 -0
  82. package/lib/services/growl/index.d.ts +2 -0
  83. package/lib/services/growl/index.d.ts.map +1 -0
  84. package/lib/services/index.d.ts +3 -4
  85. package/lib/services/index.d.ts.map +1 -1
  86. package/lib/services/locale/locale.service.d.ts.map +1 -1
  87. package/lib/services/permission/permission.service.d.ts.map +1 -1
  88. package/lib/services/queue/api-queue.service.d.ts.map +1 -1
  89. package/lib/services/storage/local-forage.service.d.ts.map +1 -1
  90. package/lib/services/store/effects/app.effects.d.ts +3 -3
  91. package/lib/services/store/effects/app.effects.d.ts.map +1 -1
  92. package/lib/services/store/reducers/app.reducers.d.ts.map +1 -1
  93. package/lib/services/store/store.service.d.ts.map +1 -1
  94. package/lib/services/user/user.service.d.ts +1 -1
  95. package/lib/services/user/user.service.d.ts.map +1 -1
  96. package/package.json +2 -2
  97. package/docs/classes/ActivatedRouteAction.html +0 -282
  98. package/docs/classes/AddApiQueueItemAction.html +0 -282
  99. package/docs/classes/AddAppLoadedConfigModulesAction.html +0 -282
  100. package/docs/classes/ApiQueueServiceMock.html +0 -553
  101. package/docs/classes/AsyncStorageService.html +0 -941
  102. package/docs/classes/AsyncStorageServiceMock.html +0 -427
  103. package/docs/classes/EmptyApiQueueAction.html +0 -282
  104. package/docs/classes/EuiCoreRootGuardClass.html +0 -167
  105. package/docs/classes/EuiError.html +0 -227
  106. package/docs/classes/I18nResourceImpl.html +0 -510
  107. package/docs/classes/InitStoreAction.html +0 -282
  108. package/docs/classes/LogServiceMock.html +0 -223
  109. package/docs/classes/OpenIdConnectServiceMock.html +0 -223
  110. package/docs/classes/RemoveApiQueueItemAction.html +0 -282
  111. package/docs/classes/RouterMock.html +0 -499
  112. package/docs/classes/StorageService.html +0 -640
  113. package/docs/classes/StorageServiceMock.html +0 -325
  114. package/docs/classes/StoreMock.html +0 -406
  115. package/docs/classes/TranslateServiceMock.html +0 -929
  116. package/docs/classes/UpdateAppConnectionAction.html +0 -282
  117. package/docs/classes/UpdateAppStatusAction.html +0 -282
  118. package/docs/classes/UpdateAppVersionAction.html +0 -282
  119. package/docs/classes/UpdateCurrentModuleAction.html +0 -282
  120. package/docs/classes/UpdateI18nStateAction.html +0 -282
  121. package/docs/classes/UpdateLocaleStateAction.html +0 -282
  122. package/docs/classes/UpdateNotificationsListAction.html +0 -282
  123. package/docs/classes/UpdateUserDashboardAction.html +0 -282
  124. package/docs/classes/UpdateUserDetailsAction.html +0 -282
  125. package/docs/classes/UpdateUserPreferencesAction.html +0 -282
  126. package/docs/classes/UpdateUserRightsAction.html +0 -282
  127. package/docs/classes/UpdateUserStateAction.html +0 -282
  128. package/docs/classes/UxErrorManager.html +0 -536
  129. package/docs/classes/UxRootInjectorGuard.html +0 -197
  130. package/docs/dependencies.html +0 -319
  131. package/docs/directives/TranslateMockDirective.html +0 -266
  132. package/docs/fonts/ionicons.eot +0 -0
  133. package/docs/fonts/ionicons.svg +0 -2090
  134. package/docs/fonts/ionicons.ttf +0 -0
  135. package/docs/fonts/ionicons.woff +0 -0
  136. package/docs/fonts/ionicons.woff2 +0 -0
  137. package/docs/fonts/roboto-v15-latin-300.eot +0 -0
  138. package/docs/fonts/roboto-v15-latin-300.svg +0 -314
  139. package/docs/fonts/roboto-v15-latin-300.ttf +0 -0
  140. package/docs/fonts/roboto-v15-latin-300.woff +0 -0
  141. package/docs/fonts/roboto-v15-latin-300.woff2 +0 -0
  142. package/docs/fonts/roboto-v15-latin-700.eot +0 -0
  143. package/docs/fonts/roboto-v15-latin-700.svg +0 -310
  144. package/docs/fonts/roboto-v15-latin-700.ttf +0 -0
  145. package/docs/fonts/roboto-v15-latin-700.woff +0 -0
  146. package/docs/fonts/roboto-v15-latin-700.woff2 +0 -0
  147. package/docs/fonts/roboto-v15-latin-italic.eot +0 -0
  148. package/docs/fonts/roboto-v15-latin-italic.svg +0 -323
  149. package/docs/fonts/roboto-v15-latin-italic.ttf +0 -0
  150. package/docs/fonts/roboto-v15-latin-italic.woff +0 -0
  151. package/docs/fonts/roboto-v15-latin-italic.woff2 +0 -0
  152. package/docs/fonts/roboto-v15-latin-regular.eot +0 -0
  153. package/docs/fonts/roboto-v15-latin-regular.svg +0 -308
  154. package/docs/fonts/roboto-v15-latin-regular.ttf +0 -0
  155. package/docs/fonts/roboto-v15-latin-regular.woff +0 -0
  156. package/docs/fonts/roboto-v15-latin-regular.woff2 +0 -0
  157. package/docs/images/compodoc-vectorise-inverted.png +0 -0
  158. package/docs/images/compodoc-vectorise-inverted.svg +0 -201
  159. package/docs/images/compodoc-vectorise.png +0 -0
  160. package/docs/images/compodoc-vectorise.svg +0 -201
  161. package/docs/images/favicon.ico +0 -0
  162. package/docs/index.html +0 -171
  163. package/docs/injectables/ApiQueueService.html +0 -806
  164. package/docs/injectables/CoreAppEffects.html +0 -392
  165. package/docs/injectables/EuiDynamicMenuService.html +0 -379
  166. package/docs/injectables/EuiPermissionService.html +0 -652
  167. package/docs/injectables/EuiTimezoneService.html +0 -382
  168. package/docs/injectables/GlobalErrorHandler.html +0 -293
  169. package/docs/injectables/I18nLoader.html +0 -597
  170. package/docs/injectables/I18nService.html +0 -945
  171. package/docs/injectables/I18nServiceMock.html +0 -634
  172. package/docs/injectables/LocalForageService.html +0 -773
  173. package/docs/injectables/LocalStorageService.html +0 -554
  174. package/docs/injectables/LocaleService.html +0 -799
  175. package/docs/injectables/LocaleServiceMock.html +0 -493
  176. package/docs/injectables/LogService.html +0 -354
  177. package/docs/injectables/OpenIdConnectService.html +0 -225
  178. package/docs/injectables/SessionStorageService.html +0 -554
  179. package/docs/injectables/StoreService.html +0 -651
  180. package/docs/injectables/StoreServiceMock.html +0 -457
  181. package/docs/injectables/UserService.html +0 -760
  182. package/docs/injectables/UserServiceMock.html +0 -649
  183. package/docs/injectables/UxAppShellService.html +0 -2254
  184. package/docs/injectables/UxDynamicComponentService.html +0 -437
  185. package/docs/injectables/UxErrorFeedbackService.html +0 -591
  186. package/docs/interceptors/AddLangParamInterceptor.html +0 -305
  187. package/docs/interceptors/CachePreventionInterceptor.html +0 -254
  188. package/docs/interceptors/CorsSecurityInterceptor.html +0 -254
  189. package/docs/interceptors/CsrfPreventionInterceptor.html +0 -254
  190. package/docs/interceptors/EuLoginSessionTimeoutHandlingInterceptor.html +0 -254
  191. package/docs/interceptors/HttpErrorHandlerInterceptor.html +0 -321
  192. package/docs/interceptors/OpenIdConnectInterceptor.html +0 -347
  193. package/docs/interceptors/UxRequestErrorModelInterceptor.html +0 -297
  194. package/docs/interfaces/EuiTimeZone.html +0 -247
  195. package/docs/interfaces/LoadedResources.html +0 -292
  196. package/docs/interfaces/LoadedResourcesError.html +0 -247
  197. package/docs/interfaces/ModuleLoadEvent.html +0 -292
  198. package/docs/interfaces/OpenIdConnectUserDetails.html +0 -439
  199. package/docs/interfaces/ResourceError.html +0 -298
  200. package/docs/interfaces/UIState.html +0 -1900
  201. package/docs/js/compodoc.js +0 -14
  202. package/docs/js/lazy-load-graphs.js +0 -44
  203. package/docs/js/libs/EventDispatcher.js +0 -5
  204. package/docs/js/libs/bootstrap-native.js +0 -1
  205. package/docs/js/libs/clipboard.min.js +0 -7
  206. package/docs/js/libs/custom-elements-es5-adapter.js +0 -15
  207. package/docs/js/libs/custom-elements.min.js +0 -38
  208. package/docs/js/libs/d3.v3.min.js +0 -2
  209. package/docs/js/libs/deep-iterator.js +0 -2
  210. package/docs/js/libs/es6-shim.min.js +0 -11
  211. package/docs/js/libs/htmlparser.js +0 -23
  212. package/docs/js/libs/innersvg.js +0 -9
  213. package/docs/js/libs/lit-html.js +0 -1
  214. package/docs/js/libs/prism.js +0 -46
  215. package/docs/js/libs/promise.min.js +0 -6
  216. package/docs/js/libs/svg-pan-zoom.min.js +0 -3
  217. package/docs/js/libs/tablesort.min.js +0 -6
  218. package/docs/js/libs/tablesort.number.min.js +0 -6
  219. package/docs/js/libs/vis.min.js +0 -47
  220. package/docs/js/libs/zepto.min.js +0 -2
  221. package/docs/js/menu-wc.js +0 -380
  222. package/docs/js/menu.js +0 -325
  223. package/docs/js/routes.js +0 -301
  224. package/docs/js/search/lunr.min.js +0 -6
  225. package/docs/js/search/search-lunr.js +0 -67
  226. package/docs/js/search/search.js +0 -268
  227. package/docs/js/search/search_index.js +0 -4
  228. package/docs/js/sourceCode.js +0 -58
  229. package/docs/js/svg-pan-zoom.controls.js +0 -53
  230. package/docs/js/tabs.js +0 -21
  231. package/docs/js/tree.js +0 -147
  232. package/docs/license.html +0 -379
  233. package/docs/miscellaneous/enumerations.html +0 -418
  234. package/docs/miscellaneous/functions.html +0 -1864
  235. package/docs/miscellaneous/typealiases.html +0 -258
  236. package/docs/miscellaneous/variables.html +0 -3965
  237. package/docs/modules/CoreModule.html +0 -256
  238. package/docs/modules/I18nModule.html +0 -198
  239. package/docs/modules/LogModule.html +0 -305
  240. package/docs/modules/TranslateMockModule.html +0 -176
  241. package/docs/modules.html +0 -168
  242. package/docs/pipes/TranslateMockPipe.html +0 -227
  243. package/docs/properties.html +0 -124
  244. package/docs/styles/bootstrap-card.css +0 -219
  245. package/docs/styles/bootstrap.min.css +0 -6
  246. package/docs/styles/compodoc.css +0 -1121
  247. package/docs/styles/dark.css +0 -121
  248. package/docs/styles/ionicons.min.css +0 -11
  249. package/docs/styles/laravel.css +0 -113
  250. package/docs/styles/material.css +0 -131
  251. package/docs/styles/original.css +0 -51
  252. package/docs/styles/postmark.css +0 -238
  253. package/docs/styles/prism.css +0 -301
  254. package/docs/styles/readthedocs.css +0 -117
  255. package/docs/styles/reset.css +0 -129
  256. package/docs/styles/stripe.css +0 -106
  257. package/docs/styles/style.css +0 -7
  258. package/docs/styles/tablesort.css +0 -33
  259. package/docs/styles/vagrant.css +0 -130
  260. package/esm2022/lib/services/ux-app-shell.service.mjs +0 -544
  261. package/esm2022/lib/services/ux-dynamic-component/ux-dynamic-component.service.mjs +0 -63
  262. package/esm2022/lib/services/ux-error-feedback/ux-error-feedback.service.mjs +0 -108
  263. package/esm2022/lib/services/ux-error-feedback/ux-error-handler.operator.mjs +0 -16
  264. package/lib/services/ux-app-shell.service.d.ts.map +0 -1
  265. package/lib/services/ux-dynamic-component/ux-dynamic-component.service.d.ts.map +0 -1
  266. package/lib/services/ux-error-feedback/ux-error-feedback.service.d.ts +0 -36
  267. package/lib/services/ux-error-feedback/ux-error-feedback.service.d.ts.map +0 -1
  268. package/lib/services/ux-error-feedback/ux-error-handler.operator.d.ts +0 -4
  269. package/lib/services/ux-error-feedback/ux-error-handler.operator.d.ts.map +0 -1
@@ -1,29 +1,29 @@
1
1
  import * as i1 from '@eui/base';
2
- import { LogLevel, ConsoleAppender, Logger, LoggerMock, mergeAll, getI18nLoaderConfig, EuiLazyService, getI18nServiceConfigFromBase, getI18nState, getLastAddedModule, getBrowserDefaultLanguage, EuiEuLanguages, getActiveLang, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, xhr, getApiQueue, getApiQueueItem, EuiService, getUserRights, getUserState, UxPublishErrorFeedbackEvent, UxClearErrorFeedbackEvent, getLocaleServiceConfigFromBase, getLocaleState, transformToUxHttpResponse } from '@eui/base';
2
+ import { LogLevel, ConsoleAppender, Logger, LoggerMock, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, xhr, getApiQueue, getApiQueueItem, mergeAll, getI18nLoaderConfig, EuiLazyService, getI18nServiceConfigFromBase, getI18nState, getLastAddedModule, getBrowserDefaultLanguage, EuiEuLanguages, getActiveLang, EuiService, getUserRights, getUserState, getLocaleServiceConfigFromBase, getLocaleState, transformToUxHttpResponse } from '@eui/base';
3
3
  export * from '@eui/base';
4
4
  import * as i0 from '@angular/core';
5
- import { InjectionToken, Injectable, Inject, Injector, NgModule, Optional, APP_INITIALIZER, EventEmitter, PLATFORM_ID, SkipSelf, ErrorHandler, LOCALE_ID } from '@angular/core';
5
+ import { InjectionToken, Injectable, Inject, Injector, NgModule, Optional, APP_INITIALIZER, SkipSelf, ErrorHandler, EventEmitter, PLATFORM_ID, LOCALE_ID } from '@angular/core';
6
6
  import * as extendProxy from 'extend';
7
7
  import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
8
8
  import { MomentDateAdapter } from '@angular/material-moment-adapter';
9
9
  import { LOCATION_INITIALIZED, DOCUMENT, isPlatformBrowser, getLocaleId, registerLocaleData } from '@angular/common';
10
- import { throwError, forkJoin, of, BehaviorSubject, defer, merge, fromEvent, Observable, Subject, from } from 'rxjs';
11
- import { debounceTime, distinctUntilChanged, map, catchError, switchMap, tap, filter, take, mapTo, mergeMap, concatMap, takeUntil } from 'rxjs/operators';
10
+ import { throwError, merge, fromEvent, of, forkJoin, BehaviorSubject, defer, from, Subject, Observable } from 'rxjs';
11
+ import { debounceTime, distinctUntilChanged, mapTo, map, mergeMap, tap, take, switchMap, catchError, concatMap, filter, takeUntil, finalize } from 'rxjs/operators';
12
12
  import * as i1$1 from '@ngrx/store';
13
13
  import { createSelector } from '@ngrx/store';
14
- import * as i1$3 from '@ngrx/effects';
14
+ import * as i1$2 from '@ngrx/effects';
15
15
  import { createEffect, ofType } from '@ngrx/effects';
16
- import * as i2 from '@ngx-translate/core';
16
+ import * as i1$3 from '@ngx-translate/core';
17
17
  import { TranslateLoader } from '@ngx-translate/core';
18
- import * as i2$1 from '@angular/router';
19
- import { NavigationEnd } from '@angular/router';
20
- import isEqual from 'lodash-es/isEqual';
21
- import get from 'lodash-es/get';
22
- import * as i1$2 from '@angular/common/http';
18
+ import * as i1$5 from '@angular/common/http';
23
19
  import { HttpErrorResponse, HttpResponse, HttpHeaders, HttpEventType } from '@angular/common/http';
20
+ import * as i1$4 from '@angular/router';
21
+ import { NavigationEnd } from '@angular/router';
24
22
  import { By } from '@angular/platform-browser';
25
23
  import { FormGroup, FormArray } from '@angular/forms';
26
24
  import { DomPortalOutlet, ComponentPortal, PortalInjector } from '@angular/cdk/portal';
25
+ import isEqual from 'lodash-es/isEqual';
26
+ import get from 'lodash-es/get';
27
27
  import * as lf from 'localforage';
28
28
  import localeFr from '@angular/common/locales/fr';
29
29
  import localeEl from '@angular/common/locales/el';
@@ -197,12 +197,12 @@ class LogService extends Logger {
197
197
  }
198
198
  return logger;
199
199
  }
200
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LogService, deps: [{ token: BASE_LOGGER_NAME_TOKEN }, { token: LOG_LEVEL_TOKEN }, { token: LOG_APPENDERS_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
201
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LogService }); }
200
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogService, deps: [{ token: BASE_LOGGER_NAME_TOKEN }, { token: LOG_LEVEL_TOKEN }, { token: LOG_APPENDERS_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
201
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogService }); }
202
202
  }
203
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LogService, decorators: [{
203
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogService, decorators: [{
204
204
  type: Injectable
205
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
205
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
206
206
  type: Inject,
207
207
  args: [BASE_LOGGER_NAME_TOKEN]
208
208
  }] }, { type: i1.LogLevel, decorators: [{
@@ -211,7 +211,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImpor
211
211
  }] }, { type: undefined, decorators: [{
212
212
  type: Inject,
213
213
  args: [LOG_APPENDERS_TOKEN]
214
- }] }]; } });
214
+ }] }] });
215
215
 
216
216
  const LOG_INSTANCES = {};
217
217
  /**
@@ -371,11 +371,11 @@ class LogModule {
371
371
  ],
372
372
  };
373
373
  }
374
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
375
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.5", ngImport: i0, type: LogModule }); }
376
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LogModule }); }
374
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
375
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogModule }); }
376
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogModule }); }
377
377
  }
378
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LogModule, decorators: [{
378
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LogModule, decorators: [{
379
379
  type: NgModule
380
380
  }] });
381
381
 
@@ -470,19 +470,19 @@ class StoreService {
470
470
  // Ignore write errors.
471
471
  }
472
472
  }
473
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: StoreService, deps: [{ token: i1$1.Store, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
474
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: StoreService, providedIn: 'root' }); }
473
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: StoreService, deps: [{ token: i1$1.Store, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
474
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: StoreService, providedIn: 'root' }); }
475
475
  }
476
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: StoreService, decorators: [{
476
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: StoreService, decorators: [{
477
477
  type: Injectable,
478
478
  args: [{
479
479
  providedIn: 'root',
480
480
  }]
481
- }], ctorParameters: function () { return [{ type: i1$1.Store, decorators: [{
481
+ }], ctorParameters: () => [{ type: i1$1.Store, decorators: [{
482
482
  type: Optional
483
483
  }] }, { type: LogService, decorators: [{
484
484
  type: Optional
485
- }] }]; } });
485
+ }] }] });
486
486
 
487
487
  const euiInitApp = (injector) => () => new Promise((resolve) => {
488
488
  const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
@@ -615,2260 +615,2244 @@ class UpdateLocaleStateAction {
615
615
  }
616
616
  }
617
617
 
618
- class I18nResourceImpl {
619
- /**
620
- * Resource constructor
621
- *
622
- * @param prefix the prefix of the resource
623
- * @param suffix the suffix of the resource, optional parameter
624
- * @param compileTranslations compiler function, optional parameter
625
- */
626
- constructor(prefix, suffix = '', compileTranslationsFn = (translations) => translations) {
627
- this.prefix = prefix;
628
- this.suffix = suffix;
629
- this.compileTranslationsFn = compileTranslationsFn;
630
- }
631
- /**
632
- * Translations pre-processor
633
- *
634
- * @param translations the object to be pre-processed
635
- * @param lang the translations language
636
- * @returns the pre-processed translations
637
- */
638
- compileTranslations(translations, lang) {
639
- return this.compileTranslationsFn(translations, lang);
618
+ class EuiGrowlService {
619
+ constructor() {
620
+ this.growlMessages = [];
621
+ this.isGrowlSticky = false;
622
+ this.isCloseAllSticky = false;
623
+ this.growlLife = 3000;
624
+ this.growlPosition = 'bottom-right';
625
+ this.growlCallback = null;
640
626
  }
641
627
  /**
642
- * Indicates whether other object is equal-to this one.
643
- *
644
- * @param obj the reference object with which to compare
645
- * @returns true if this object is the same as obj, false otherwise
628
+ * displays a growl UxMessage item, isSticky
646
629
  */
647
- equals(obj) {
648
- return this.prefix === obj.prefix && this.suffix === obj.suffix;
630
+ growl(msg, isSticky, isMultiple, life, position, callback) {
631
+ if (msg.severity !== 'info' && msg.severity !== 'warning' && msg.severity !== 'success' && msg.severity !== 'danger') {
632
+ throw new Error('EuiGrowlService.growl() ERROR : message severity must be either : success, warning, info, danger');
633
+ }
634
+ else {
635
+ if (isMultiple === undefined || !isMultiple) {
636
+ this.growlMessages = [];
637
+ }
638
+ this.growlMessages = this.growlMessages.concat(msg);
639
+ msg.life = life || msg.life;
640
+ msg.sticky = isSticky || msg.sticky;
641
+ if (life === undefined || isNaN(life)) {
642
+ if (msg.severity === 'danger') {
643
+ isSticky = true;
644
+ }
645
+ else {
646
+ this.growlLife = 3000;
647
+ }
648
+ }
649
+ else {
650
+ this.growlLife = life;
651
+ }
652
+ if (isSticky) {
653
+ this.isGrowlSticky = isSticky;
654
+ }
655
+ else {
656
+ this.isGrowlSticky = false;
657
+ }
658
+ if (position) {
659
+ this.growlPosition = position;
660
+ }
661
+ if (callback) {
662
+ this.growlCallback = callback;
663
+ }
664
+ else {
665
+ this.growlCallback = () => { };
666
+ }
667
+ }
649
668
  }
650
- /**
651
- * The path to the resource
652
- *
653
- * @param lang the resource language
654
- * @returns the path
655
- */
656
- getPath(lang) {
657
- return `${this.prefix}${lang}${this.suffix}`;
669
+ clearGrowl() {
670
+ this.growlMessages = [];
658
671
  }
659
- }
660
-
661
- class I18nLoader {
662
- constructor(http, logService, euiAppConfig) {
663
- this.http = http;
664
- this.logService = logService;
665
- this.euiAppConfig = euiAppConfig;
666
- this.resources = [];
667
- this.failedResources = [];
668
- // create the resources from the config object
669
- const i18nConfig = this.euiAppConfig.global && this.euiAppConfig.global.i18n;
670
- const i18nLoaderConfig = i18nConfig && i18nConfig.i18nLoader;
671
- this.resources.push(...this.createResources(i18nLoaderConfig));
672
+ growlSuccess(msg, position) {
673
+ this.growl({ severity: 'success', summary: 'SUCCESS', detail: msg }, false, false, undefined, position);
672
674
  }
673
- /**
674
- * Gets the translations from the server
675
- *
676
- * @param lang
677
- * @returns Observable<any>
678
- */
679
- getTranslation(lang) {
680
- return this.loadResources(this.resources, lang).pipe(map((loadedResources) => {
681
- this.failedResources = loadedResources.hasError ? loadedResources.errors : [];
682
- return loadedResources.translations;
683
- }));
675
+ growlError(msg, position) {
676
+ this.growl({ severity: 'danger', summary: 'ERROR', detail: msg }, false, false, undefined, position);
684
677
  }
685
- /**
686
- * Adds resources
687
- *
688
- * @param config loader configuration
689
- * @returns Observable<any> | false
690
- */
691
- addResources(config) {
692
- // create the resources
693
- let resources = this.createResources(config);
694
- // filter the resources first, to avoid duplicates
695
- resources = resources.filter((resource) => !this.resources.some((res) => res.equals(resource)));
696
- // add the new resources to the list of existing resources
697
- this.resources.push(...resources);
698
- // return the filtered resources
699
- return resources;
678
+ // date helpers
679
+ growlWarning(msg, position) {
680
+ this.growl({ severity: 'warning', summary: 'WARNING', detail: msg }, false, false, undefined, position);
700
681
  }
701
- /**
702
- * Removes resources from the loader instance
703
- */
704
- removeResources(removedResources) {
705
- this.resources = this.resources.filter((res) => !removedResources.some((removedResource) => removedResource.equals(res)));
682
+ growlInfo(msg, position) {
683
+ this.growl({ severity: 'info', summary: 'INFO', detail: msg }, false, false, undefined, position);
706
684
  }
707
- /**
708
- * Loads an array of resources, by language
709
- *
710
- * @param resources the definition of the resources
711
- * @param lang the resource language to load
712
- * @returns Observable<any>
713
- */
714
- loadResources(resources, lang) {
715
- // if there are resources to load
716
- if (Array.isArray(resources) && resources.length > 0) {
717
- // load all the resources in an array of Observable
718
- const requests = resources.map((resource) => this.loadResource(resource, lang));
719
- // group all the observables with forkJoin and deep merge them
720
- return forkJoin(requests).pipe(map((response) => {
721
- const successResp = [];
722
- const errResp = [];
723
- response.forEach((item) => {
724
- if (item.isError) {
725
- errResp.push({ resource: item.resource, error: item.error });
726
- }
727
- else {
728
- successResp.push(item);
729
- }
730
- });
731
- if (successResp.length === response.length) {
732
- return { hasError: false, translations: mergeAll(successResp) };
685
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiGrowlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
686
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiGrowlService, providedIn: 'root' }); }
687
+ }
688
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiGrowlService, decorators: [{
689
+ type: Injectable,
690
+ args: [{
691
+ providedIn: 'root',
692
+ }]
693
+ }] });
694
+
695
+ class CoreAppEffects {
696
+ constructor(actions,
697
+ // TODO: remove on eUI 14
698
+ showConnectionStatus, translateService, asService) {
699
+ this.actions = actions;
700
+ this.showConnectionStatus = showConnectionStatus;
701
+ this.translateService = translateService;
702
+ this.asService = asService;
703
+ this.getAppConnectionInformation = createEffect(() => merge(fromEvent(window, 'online').pipe(mapTo(true)), fromEvent(window, 'offline').pipe(mapTo(false))).pipe(map((connected) => new UpdateAppConnectionAction(connected))));
704
+ this.activatedRoute = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.ACTIVATED_ROUTE), map((action) => action.payload), mergeMap((route) => {
705
+ // extract the module name, if defined
706
+ const module = route.snapshot.data['module'] || 'undefined';
707
+ return [new UpdateCurrentModuleAction(module)];
708
+ })));
709
+ this.updateAppConnection = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.UPDATE_APP_CONNECTION), map((action) => action.payload), tap((connected) => {
710
+ // TODO: for eUI 14, drop boolean support and refactor
711
+ // check if feature is enabled
712
+ const isFeatureEnabled = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.enabled : this.showConnectionStatus;
713
+ // extract lifespan if any
714
+ const lifespan = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.messageBox?.lifespan || 0 : 0;
715
+ // if the user needs to be informed about the connection status
716
+ if (isFeatureEnabled) {
717
+ if (connected) {
718
+ this.translateService.get('eui.CONNECTED').subscribe((translation) => {
719
+ this.asService.growl({ severity: 'success', summary: 'MESSAGE', detail: translation, life: lifespan }, lifespan < 1, false);
720
+ });
733
721
  }
734
722
  else {
735
- return { hasError: true, translations: mergeAll(successResp), errors: errResp };
723
+ this.translateService.get('eui.NOTCONNECTED').subscribe((translation) => {
724
+ this.asService.growl({ severity: 'danger', summary: 'ERROR', detail: translation, life: lifespan }, lifespan < 1, false);
725
+ });
736
726
  }
737
- }));
738
- }
739
- else {
740
- // no resources to load
741
- return of({ hasError: false, translations: {} });
742
- }
743
- }
744
- /**
745
- * Returns resources that failed
746
- */
747
- getFailedResources() {
748
- return this.failedResources;
749
- }
750
- /**
751
- * Create resources from a config file
752
- *
753
- * @param config loader configuration
754
- * @returns I18nResourceImpl[] resources
755
- */
756
- createResources(config) {
757
- // use the default config as a reference base
758
- config = getI18nLoaderConfig(config);
759
- const resources = [];
760
- // extract the i18n folders from config
761
- const i18nFolders = Array.isArray(config.i18nFolders)
762
- ? config.i18nFolders
763
- : config.i18nFolders
764
- ? [config.i18nFolders]
765
- : [];
766
- if (i18nFolders) {
767
- // add the i18n folders to resources
768
- resources.push(...i18nFolders.map((folder) => new I18nResourceImpl(`assets/${folder}/`, '.json')));
769
- }
770
- // extract the i18n services from config
771
- const i18nServices = Array.isArray(config.i18nServices)
772
- ? config.i18nServices
773
- : config.i18nServices
774
- ? [config.i18nServices]
775
- : [];
776
- if (i18nServices) {
777
- // add the i18n services to resources
778
- resources.push(...i18nServices.map((service) => new I18nResourceImpl(service)));
779
- }
780
- // extract the i18n resources from config
781
- const i18nResources = Array.isArray(config.i18nResources)
782
- ? config.i18nResources
783
- : config.i18nResources
784
- ? [config.i18nResources]
785
- : [];
786
- if (i18nResources) {
787
- // add the i18n resources to resources
788
- resources.push(...i18nResources.map((resource) => new I18nResourceImpl(resource.prefix, resource.suffix, this.getResourceCompileFunction(resource.compileTranslations))));
789
- }
790
- return resources;
791
- }
792
- /**
793
- * Loads a resource, by language
794
- *
795
- * @param resource the definition of the resource
796
- * @param lang the resource language to load
797
- * @returns Observable<any>
798
- */
799
- loadResource(resource, lang) {
800
- // the path to the resource
801
- const path = resource.getPath(lang);
802
- // load the translations from the path
803
- return this.http.get(path).pipe(
804
- // preprocess the translations using the resource compiler
805
- map((translations) => resource.compileTranslations(translations, lang)), map((translations) => {
806
- // resource loaded properly, send a info message
807
- if (this.logService) {
808
- this.logService.info(`I18n resource loaded from path ${path}`);
809
- }
810
- // return the translations
811
- return translations;
812
- }), catchError((err) => {
813
- // remove failed resource from loaded resource array
814
- this.removeResources([resource]);
815
- // resource not loaded properly, send a warning message
816
- if (this.logService) {
817
- this.logService.warn(`I18n resource NOT loaded from path ${path}`, err);
818
727
  }
819
- const resourceError = { error: `I18n resource NOT loaded from path ${path}`, resource, isError: true };
820
- return of(resourceError);
821
- }));
822
- }
823
- getResourceCompileFunction(id) {
824
- const customHandlers = this.euiAppConfig.customHandler;
825
- if (customHandlers && typeof customHandlers[id] === 'function') {
826
- return customHandlers[id];
827
- }
828
- return undefined;
728
+ })), { dispatch: false });
829
729
  }
830
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nLoader, deps: [{ token: i1$2.HttpClient }, { token: LogService, optional: true }, { token: CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
831
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nLoader }); }
730
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$2.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i1$3.TranslateService }, { token: EuiGrowlService }], target: i0.ɵɵFactoryTarget.Injectable }); }
731
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CoreAppEffects }); }
832
732
  }
833
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nLoader, decorators: [{
733
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CoreAppEffects, decorators: [{
834
734
  type: Injectable
835
- }], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: LogService, decorators: [{
836
- type: Optional
837
- }] }, { type: undefined, decorators: [{
735
+ }], ctorParameters: () => [{ type: i1$2.Actions }, { type: undefined, decorators: [{
838
736
  type: Inject,
839
- args: [CONFIG_TOKEN]
840
- }] }]; } });
841
- const translateConfig = {
842
- loader: {
843
- provide: TranslateLoader,
844
- useClass: I18nLoader,
737
+ args: [SHOW_CONNECTION_STATUS_TOKEN]
738
+ }] }, { type: i1$3.TranslateService }, { type: EuiGrowlService }] });
739
+
740
+ const CoreModuleEffects = [CoreAppEffects];
741
+
742
+ const updateAppVersion = (state, action) => ({ ...state, version: action.payload });
743
+ const updateAppConnection = (state, action) => ({ ...state, connected: action.payload });
744
+ const AddAppLoadedConfigModules = (state, action) => ({
745
+ ...state,
746
+ loadedConfigModules: {
747
+ lastAddedModule: action.payload.moduleName,
748
+ modulesConfig: {
749
+ ...state.loadedConfigModules.modulesConfig,
750
+ [action.payload.moduleName]: {
751
+ ...action.payload.moduleConfig,
752
+ },
753
+ },
845
754
  },
755
+ });
756
+ const updateAppStatus = (state, action) => ({ ...state, status: action.payload });
757
+ const updateCurrentModule = (state, action) => Object.assign({}, state, { currentModule: action.payload });
758
+ const addApiQueueItem = (state, action) => {
759
+ // apply the timestamp to the queue item
760
+ const apiQueueItem = Object.assign({}, action.payload.item, { timestamp: new Date().getTime() });
761
+ // update the queue
762
+ const apiQueue = Object.assign({}, state.apiQueue, { [action.payload.id]: apiQueueItem });
763
+ return Object.assign({}, state, { apiQueue });
764
+ };
765
+ const removeApiQueueItem = (state, action) => {
766
+ // remove the specified id from the list of item ids and recreate the apiQueue from the remaining ids
767
+ const apiQueue = Object.keys(state.apiQueue)
768
+ .filter((id) => id !== action.payload)
769
+ .reduce((queue, key) => {
770
+ queue[key] = state.apiQueue[key];
771
+ return queue;
772
+ }, {});
773
+ return Object.assign({}, state, { apiQueue });
774
+ };
775
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
776
+ const emptyApiQueue = (state, action) =>
777
+ // remove all items in the Api Queue
778
+ Object.assign({}, state, { apiQueue: {} });
779
+ const actionToReducerMap$4 = {
780
+ [CoreAppActionTypes.UPDATE_APP_VERSION]: updateAppVersion,
781
+ [CoreAppActionTypes.UPDATE_APP_CONNECTION]: updateAppConnection,
782
+ [CoreAppActionTypes.ADD_APP_LOADED_CONFIG_MODULES]: AddAppLoadedConfigModules,
783
+ [CoreAppActionTypes.UPDATE_APP_STATUS]: updateAppStatus,
784
+ [CoreAppActionTypes.UPDATE_CURRENT_MODULE]: updateCurrentModule,
785
+ [CoreAppActionTypes.ADD_API_QUEUE_ITEM]: addApiQueueItem,
786
+ [CoreAppActionTypes.REMOVE_API_QUEUE_ITEM]: removeApiQueueItem,
787
+ [CoreAppActionTypes.EMPTY_API_QUEUE]: emptyApiQueue,
788
+ };
789
+ const coreAppReducers = (state = initialAppState, action) => {
790
+ if (actionToReducerMap$4[action.type]) {
791
+ return actionToReducerMap$4[action.type](state, action);
792
+ }
793
+ // if the action type is not in the map, call the base reducers method
794
+ return state;
846
795
  };
847
796
 
848
- class I18nService extends EuiLazyService {
849
- constructor(baseGlobalConfig, translateService, logService, store, document) {
850
- super({ activeLang: 'en' });
851
- this.baseGlobalConfig = baseGlobalConfig;
852
- this.translateService = translateService;
853
- this.logService = logService;
854
- this.store = store;
855
- this.document = document;
856
- this.config = getI18nServiceConfigFromBase(this.baseGlobalConfig);
857
- this.onModuleLoad = new BehaviorSubject({ ready: false, name: null });
797
+ const updateUser = (state, action) => {
798
+ let fullName = action.payload.fullName;
799
+ if (!fullName) {
800
+ fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
858
801
  }
859
- getState(keyOrMapFn) {
860
- let selector = getI18nState;
861
- let dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
862
- if (keyOrMapFn) {
863
- switch (typeof keyOrMapFn) {
864
- case 'function':
865
- selector = createSelector(getI18nState, keyOrMapFn);
866
- break;
867
- case 'string':
868
- selector = createSelector(getI18nState, (state) => dotNotationToObject(state, keyOrMapFn));
869
- break;
870
- }
871
- }
872
- return this.store.select(selector);
802
+ return Object.assign({}, state, action.payload, { fullName });
803
+ };
804
+ const updateUserDetails = (state, action) => {
805
+ let fullName = action.payload.fullName;
806
+ if (!fullName) {
807
+ fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
873
808
  }
874
- updateState(langState) {
875
- this.updateHTMLDOMLang(langState.activeLang);
876
- this.store.dispatch(new UpdateI18nStateAction(langState));
809
+ // todo should be checked if state.details is really there
810
+ const details = Object.assign({}, state.details, action.payload, { fullName });
811
+ return Object.assign({}, state, details);
812
+ };
813
+ const updateUserPreferences = (state, action) => {
814
+ const preferences = Object.assign({}, state.preferences, action.payload);
815
+ return Object.assign({}, state, { preferences });
816
+ };
817
+ const updateUserRights = (state, action) => Object.assign({}, state, { rights: [...action.payload] });
818
+ const updateUserDashboard = (state, action) => {
819
+ // apply the dashboard to preferences
820
+ const preferences = Object.assign({}, state.preferences, { dashboard: action.payload });
821
+ // update the state
822
+ return { ...state, preferences };
823
+ };
824
+ const actionToReducerMap$3 = {
825
+ [CoreUserActionTypes.UPDATE_USER_DETAILS]: updateUserDetails,
826
+ [CoreUserActionTypes.UPDATE_USER_PREFERENCES]: updateUserPreferences,
827
+ [CoreUserActionTypes.UPDATE_USER_STATE]: updateUser,
828
+ [CoreUserActionTypes.UPDATE_USER_RIGHTS]: updateUserRights,
829
+ [CoreUserActionTypes.UPDATE_USER_DASHBOARD]: updateUserDashboard,
830
+ };
831
+ const coreUserReducers = (state = initialUserState, action) => {
832
+ if (actionToReducerMap$3[action.type]) {
833
+ return actionToReducerMap$3[action.type](state, action);
877
834
  }
878
- init(langState) {
879
- const initLang = langState && langState.activeLang ? langState.activeLang : this.preparedDefaultLanguage();
880
- const initState = {
881
- ...langState,
882
- activeLang: initLang,
883
- };
884
- if (typeof initLang === 'string') {
885
- super.initEuiService(this.store);
886
- this.updateState(initState);
887
- return this.setup(initLang);
888
- }
889
- return of({ success: false, error: 'Initial active lang should be string' });
835
+ return state;
836
+ };
837
+
838
+ const updateNotificationsList = (state, action) => Object.assign({}, state, { list: [...action.payload] });
839
+ const actionToReducerMap$2 = {
840
+ [CoreNotificationsActionTypes.UPDATE_NOTIFICATIONS_LIST]: updateNotificationsList,
841
+ };
842
+ const coreNotificationsReducers = (state = initialNotificationsState, action) => {
843
+ if (actionToReducerMap$2[action.type]) {
844
+ return actionToReducerMap$2[action.type](state, action);
890
845
  }
891
- /**
892
- * A pipe function that could serve as a wrapper of another observable
893
- * e.g. ngx-translate i18n.onReady('my_module').pipe(switchMap(()=>translate.get('eui.KEY')));
894
- * WARNING: onReady will emit only once for a loaded Module, going to another and then going back will not result
895
- * into another emission.
896
- *
897
- * @param moduleName the name of the module that has been given through the eUI globalConfig. In case non provided
898
- * fetch module name from the state.
899
- */
900
- onReady(moduleName) {
901
- return this.onModuleLoad.pipe(switchMap((evt) => moduleName
902
- ? of(evt)
903
- : this.store.select(getLastAddedModule).pipe(tap((m) => (moduleName = m)), map(() => evt))),
904
- // emit only if event emitted matches the module name and is ready
905
- filter((evt) => evt.ready === true && evt.name === moduleName),
906
- // make sure that observable completes
907
- take(1));
846
+ return state;
847
+ };
848
+
849
+ const updateI18nState = (state, action) => ({
850
+ ...state,
851
+ ...action.payload,
852
+ });
853
+ const actionToReducerMap$1 = {
854
+ [CoreI18nActionTypes.UPDATE_I18N_STATE]: updateI18nState,
855
+ };
856
+ const corI18nReducers = (state = initialI18nState, action) => {
857
+ if (actionToReducerMap$1[action.type]) {
858
+ return actionToReducerMap$1[action.type](state, action);
908
859
  }
909
- lazyLoad(config) {
910
- const moduleId = Math.floor(Math.random() * 100000 + 1).toLocaleString();
911
- return this.addResources(config, moduleId);
860
+ return state;
861
+ };
862
+
863
+ const updateLocaleState = (state, action) => ({
864
+ ...state,
865
+ ...action.payload,
866
+ });
867
+ const actionToReducerMap = {
868
+ [CoreLocaleActionTypes.UPDATE_LOCALE_STATE]: updateLocaleState,
869
+ };
870
+ const coreLocaleReducers = (state = initialLocaleState, action) => {
871
+ if (actionToReducerMap[action.type]) {
872
+ return actionToReducerMap[action.type](state, action);
912
873
  }
913
- lazyLoadInit(moduleConfig, moduleName) {
914
- const i18nLoaderConfig = moduleConfig;
915
- // add resources
916
- return this.addResources(i18nLoaderConfig, moduleName);
874
+ return state;
875
+ };
876
+
877
+ const coreReducers = Object.assign({}, {
878
+ app: coreAppReducers,
879
+ user: coreUserReducers,
880
+ notifications: coreNotificationsReducers,
881
+ i18n: corI18nReducers,
882
+ locale: coreLocaleReducers,
883
+ });
884
+
885
+ const extend = extendProxy.default || extendProxy;
886
+ /**
887
+ * Utility meta-reducer to load the state from the local storage
888
+ * @param reducer the action reducer
889
+ */
890
+ function localStorageSync(reducer) {
891
+ return cb(reducer, localStorage);
892
+ }
893
+ /**
894
+ * Utility meta-reducer to load the state from the session storage
895
+ * @param reducer the action reducer
896
+ */
897
+ function sessionStorageSync(reducer) {
898
+ return cb(reducer, sessionStorage);
899
+ }
900
+ // Keys that are allowed to be synced with NgRx state from BrowserStorage
901
+ const disallowedKeys = ['loadedConfigModules', 'connect', 'currentModule', 'status', 'apiQueue'];
902
+ /**
903
+ * filters the AppState by removing those keys from the state and return a new state Object
904
+ * @param app the AppState
905
+ */
906
+ const filterAppState = (app) => {
907
+ // in case app is undefined or null it should return empty object
908
+ if (!app) {
909
+ return {};
917
910
  }
918
- /**
919
- * Add resources based of a config loader
920
- *
921
- * @param config I18nLoaderConfig
922
- * @return Promise<EuiServiceStatus> an EuiServiceStatus when translation has fully loaded
923
- */
924
- addResources(config, moduleName) {
925
- // emit that module is loading
926
- this.onModuleLoad.next({ ready: false, name: moduleName });
927
- const loader = this.translateService.currentLoader;
928
- if (loader instanceof I18nLoader) {
929
- const langSubscription = [];
930
- const i18nLoader = loader;
931
- // add the resources to the loader
932
- const resources = i18nLoader.addResources(config);
933
- // manually load the resources for the CURRENT language and add them to the translate service
934
- langSubscription.push(i18nLoader.loadResources(resources, this.translateService.currentLang).pipe(take(1), tap((loadedResources) => {
935
- // add the new set of translations to the current language
936
- this.translateService.setTranslation(this.translateService.currentLang, loadedResources.translations, true);
937
- })));
938
- // if the current language is different than the DEFAULT language
939
- const defaultLang = this.config.defaultLanguage || this.translateService.defaultLang;
940
- if (this.translateService.currentLang !== defaultLang) {
941
- // manually load the resources for the default language and add them to the translate service
942
- langSubscription.push(i18nLoader.loadResources(resources, defaultLang).pipe(take(1), tap((loadedResources) => {
943
- this.translateService.setTranslation(defaultLang, loadedResources.translations, true);
944
- })));
945
- }
946
- return forkJoin(langSubscription).pipe(map((loadedResourcesArr) => !loadedResourcesArr[0].hasError ? { success: true } : { success: false, error: loadedResourcesArr[0].errors }), tap(() => {
947
- // emit status of module loading progress
948
- this.onModuleLoad.next({ ready: true, name: moduleName });
949
- }), catchError((error) => {
950
- // emit status of module loading progress
951
- this.onModuleLoad.next({ ready: true, name: moduleName, error });
952
- return of({ success: false, error });
953
- }));
954
- }
955
- else {
956
- return of({ success: false, error: 'currentLoader is not an I18nLoader.' });
911
+ return (Object.keys(app)
912
+ // select keys that are present in the allowed list
913
+ .filter((key) => !disallowedKeys.includes(key))
914
+ // build a new object with only the allowed properties
915
+ .reduce((obj, key) => {
916
+ obj[key] = app[key];
917
+ return obj;
918
+ }, {}));
919
+ };
920
+ /**
921
+ *
922
+ * @param storageType
923
+ */
924
+ const loadState = (storage = localStorage) => {
925
+ try {
926
+ // by default falls back to localStorage
927
+ const serializedState = storage.getItem('state');
928
+ if (serializedState === null) {
929
+ return undefined;
957
930
  }
931
+ // deserialize state
932
+ let state = JSON.parse(serializedState);
933
+ // filter AppState and replace
934
+ state = { ...state, app: filterAppState(state?.app) };
935
+ return state;
958
936
  }
959
- /**
960
- * Prepares the default language
961
- */
962
- preparedDefaultLanguage() {
963
- const browserPref = getBrowserDefaultLanguage();
964
- // If user has browser preferred lang, and that language is part of the languages array
965
- if (browserPref && this.config.languages && EuiEuLanguages.getLanguageCodes(this.config.languages).includes(browserPref)) {
966
- return browserPref;
967
- }
968
- return this.config.defaultLanguage;
937
+ catch (err) {
938
+ return undefined;
969
939
  }
970
- /**
971
- * @param default_language if given default language to override default language coming from the
972
- * configuration token.
973
- */
974
- setup(initLanguage) {
975
- // use the default config as a reference base
976
- this.config = Object.assign({}, DEFAULT_I18N_SERVICE_CONFIG, this.config);
977
- // configure the translate config service
978
- if (this.config.languages) {
979
- this.translateService.addLangs(EuiEuLanguages.getLanguageCodes(this.config.languages));
980
- if (this.logService) {
981
- this.logService.info(`I18n accepted languages set to ${EuiEuLanguages.getLanguageCodes(this.config.languages)}`);
940
+ };
941
+ const cb = (reducer, storage) => (state, action) => {
942
+ if (action.type === CoreAppActionTypes.INIT_STORE) {
943
+ // This action must be dispatched from an app initializer
944
+ // We load the state from a storage and compare the version and userId with the provided ones.
945
+ // If they are the same, we merge the local state into the initial state.
946
+ // If there is a mismatch, we don't merge the local state, but update only the initial state.
947
+ // load the state from the localStorage
948
+ const localState = loadState(storage);
949
+ // extract the details about user and app version from the action payload
950
+ const payload = action.payload;
951
+ const payloadVersion = payload?.version;
952
+ if (localState) {
953
+ // TODO: Why all these checks here? What is the purpose of this code?
954
+ // extract the details about user and app version from the storage state
955
+ const localVersion = localState?.app?.version;
956
+ // const localUserId = localState.user && localState.user.userId;
957
+ const isVersionOK = !localVersion || !payloadVersion || localVersion === payloadVersion;
958
+ // const isUserIdOK = (localUserId === payloadUserId);
959
+ // update the entire state with deep merge of states, if the version and user are the same
960
+ if (isVersionOK) {
961
+ state = extend(true, {}, state, localState);
982
962
  }
983
963
  }
984
- // set the current language, causing to load translations
985
- return this.translateService.use(initLanguage).pipe(tap(() => {
986
- this.bindActiveLangStateToTranslateService();
987
- this.bindTranslateServiceLangChangeToState();
988
- if (this.config.defaultLanguage) {
989
- this.setDefaultLanguage(this.config.defaultLanguage);
990
- }
991
- }), map(() => {
992
- if (this.translateService.currentLoader instanceof I18nLoader) {
993
- const failedResources = this.translateService.currentLoader.getFailedResources();
994
- if (failedResources.length > 0) {
995
- return { success: false, error: failedResources };
996
- }
997
- }
998
- return { success: true };
999
- }), catchError((error) => of({ success: false, error })));
1000
- }
1001
- bindActiveLangStateToTranslateService() {
1002
- this.store.select(getActiveLang).subscribe((lang) => {
1003
- if (lang !== null && this.translateService.currentLang !== lang) {
1004
- this.use(lang);
1005
- }
1006
- });
964
+ // update the app version, if defined
965
+ if (payloadVersion) {
966
+ state = { ...state, app: { ...state?.app, version: payloadVersion } };
967
+ }
1007
968
  }
1008
- bindTranslateServiceLangChangeToState() {
1009
- this.translateService.onLangChange.subscribe((event) => {
1010
- if (this.stateInstance.activeLang !== event.lang) {
1011
- this.updateState({ activeLang: event.lang });
1012
- }
1013
- if (this.logService) {
1014
- this.logService.info(`I18n current language set to ${event.lang}`);
1015
- }
1016
- });
969
+ return reducer(state, action);
970
+ };
971
+
972
+ class StoreServiceMock extends StoreService {
973
+ constructor() {
974
+ super(null, null);
1017
975
  }
1018
- setDefaultLanguage(defaultLanguage) {
1019
- // removed, current language is already calculated in init, setup function fill use it directly, not default
1020
- // this.translateService.currentLang = default_language || this.config.defaultLanguage;
1021
- this.translateService.setDefaultLang(defaultLanguage);
1022
- if (this.logService) {
1023
- this.logService.info(`I18n default language set to ${defaultLanguage}`);
1024
- }
976
+ init() { }
977
+ addAutoSaveHandler() { }
978
+ handleAutoSave() { }
979
+ dispatch() { }
980
+ select() {
981
+ return of({});
1025
982
  }
983
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: StoreServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
984
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: StoreServiceMock }); }
985
+ }
986
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: StoreServiceMock, decorators: [{
987
+ type: Injectable
988
+ }], ctorParameters: () => [] });
989
+
990
+ const CORE_ROOT_GUARD = new InjectionToken('Internal Theme ForRoot Guard');
991
+ class CoreModule {
1026
992
  /**
1027
- * change the currently used language
1028
- *
1029
- * @param lang is the language code based on the convention you used e.g. (en or en-EN)
1030
- * @returns Observable that returns an object contain the object translation for given language after language
1031
- * fully loaded.
993
+ * No more providing config from forRoot, you have to use EUI_CONFIG_TOKEN to pass config via providers.
1032
994
  */
1033
- use(lang) {
1034
- return this.translateService.use(lang);
995
+ static forRoot() {
996
+ return {
997
+ ngModule: CoreModule,
998
+ providers: [
999
+ {
1000
+ provide: EuiCoreRootGuardClass,
1001
+ useFactory: euiCoreRootGuardClass,
1002
+ deps: [],
1003
+ },
1004
+ {
1005
+ provide: CORE_ROOT_GUARD,
1006
+ useFactory: createEuiCoreRootGuard,
1007
+ deps: [[EuiCoreRootGuardClass, new Optional(), new SkipSelf()]],
1008
+ },
1009
+ ...getCoreProviders(),
1010
+ ],
1011
+ };
1035
1012
  }
1036
- /**
1037
- * updates the HTML element lang attribute
1038
- *
1039
- * @private
1040
- */
1041
- updateHTMLDOMLang(lang) {
1042
- this.document.documentElement.lang = lang;
1013
+ static forChild(moduleName) {
1014
+ return {
1015
+ ngModule: CoreModule,
1016
+ providers: getCoreChildProviders(moduleName),
1017
+ };
1018
+ }
1019
+ constructor(guard, parentModule, injector) {
1020
+ // if there is a parentModule, a new instance is created in a lazy loaded module
1021
+ if (parentModule) {
1022
+ // extract the i18n service and the i18n loader config
1023
+ // todo, this thing should be achieved by store, and localization service dependency should be removed
1024
+ const storeService = injector.get(StoreService);
1025
+ const moduleName = injector.get(MODULE_NAME_TOKEN);
1026
+ const moduleConfig = injector.get(MODULE_CONFIG_TOKEN);
1027
+ storeService.dispatch(new AddAppLoadedConfigModulesAction({ moduleName, moduleConfig }));
1028
+ }
1043
1029
  }
1044
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i2.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1045
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nService, providedIn: 'root' }); }
1030
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CoreModule, deps: [{ token: CORE_ROOT_GUARD, optional: true }, { token: CoreModule, optional: true, skipSelf: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule }); }
1031
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CoreModule }); }
1032
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CoreModule }); }
1046
1033
  }
1047
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nService, decorators: [{
1048
- type: Injectable,
1034
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CoreModule, decorators: [{
1035
+ type: NgModule,
1049
1036
  args: [{
1050
- providedIn: 'root',
1037
+ imports: [
1038
+ // HttpClientModule, no more..
1039
+ ],
1051
1040
  }]
1052
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1053
- type: Inject,
1054
- args: [GLOBAL_CONFIG_TOKEN]
1055
- }] }, { type: i2.TranslateService }, { type: LogService, decorators: [{
1041
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1056
1042
  type: Optional
1057
- }] }, { type: StoreService }, { type: Document, decorators: [{
1043
+ }, {
1058
1044
  type: Inject,
1059
- args: [DOCUMENT]
1060
- }] }]; } });
1061
-
1062
- class I18nServiceMock extends I18nService {
1063
- constructor() {
1064
- super(null, null, null, null, null);
1065
- this.DEFAULT_LANGUAGE = 'en';
1066
- }
1067
- get onLangChange() {
1068
- return new EventEmitter();
1069
- }
1070
- addResources() {
1071
- return of({ success: true });
1072
- }
1073
- get currentLanguage() {
1074
- return this.DEFAULT_LANGUAGE;
1075
- }
1076
- getState() {
1077
- return of({ activeLang: this.DEFAULT_LANGUAGE });
1078
- }
1079
- updateState(i18nState) {
1080
- this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
1081
- }
1082
- init(i18nState) {
1083
- this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
1084
- return of({ success: true });
1085
- }
1086
- lazyLoadInit() {
1087
- return of({ success: true });
1045
+ args: [CORE_ROOT_GUARD]
1046
+ }] }, { type: CoreModule, decorators: [{
1047
+ type: Optional
1048
+ }, {
1049
+ type: SkipSelf
1050
+ }] }, { type: i0.Injector }] });
1051
+ const createEuiCoreRootGuard = (core) => {
1052
+ if (core) {
1053
+ throw new TypeError(`CoreModule.forRoot() called twice. Feature modules should use ThemeModule.forChild() instead.`);
1088
1054
  }
1089
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1090
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nServiceMock }); }
1055
+ return 'guarded';
1056
+ };
1057
+ class EuiCoreRootGuardClass {
1058
+ constructor() { }
1091
1059
  }
1092
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: I18nServiceMock, decorators: [{
1093
- type: Injectable
1094
- }], ctorParameters: function () { return []; } });
1060
+ const euiCoreRootGuardClass = () => new EuiCoreRootGuardClass();
1095
1061
 
1096
- const initialState = {
1097
- appName: '',
1098
- appShortName: '',
1099
- appSubTitle: '',
1100
- userInfos: null,
1101
- userSubInfos: null,
1102
- impersonatedUserInfos: null,
1103
- isSidebarOpen: true,
1104
- isSidebarHover: false,
1105
- isSidebarActive: false,
1106
- isSidebarInnerActive: false,
1107
- isSidebarStateCloseWithIcons: false,
1108
- isSidebarExpandOnHover: true,
1109
- hasSidebar: false,
1110
- hasHeader: false,
1111
- hasBreadcrumb: false,
1112
- hasHeaderLogo: false,
1113
- hasHeaderEnvironment: false,
1114
- hasToolbar: false,
1115
- hasToolbarMenu: false,
1116
- environmentValue: '',
1117
- isSidebarHidden: false,
1118
- hasTopMessage: false,
1119
- windowWidth: 0,
1120
- windowHeight: 0,
1121
- mainContentHeight: 0,
1122
- pageHeaderHeight: 0,
1123
- wrapperClasses: '',
1124
- breakpoint: '',
1125
- breakpoints: {
1126
- isMobile: false,
1127
- isTablet: false,
1128
- isLtDesktop: false,
1129
- isDesktop: false,
1130
- isXL: false,
1131
- isXXL: false,
1132
- },
1133
- menuLinks: [],
1134
- sidebarLinks: [],
1135
- combinedLinks: [],
1136
- isBlockDocumentActive: false,
1137
- deviceInfo: null,
1138
- activeLanguage: 'en',
1139
- languages: EuiEuLanguages.getLanguages(),
1140
- appMetadata: null,
1141
- hasModalActive: false,
1142
- isDimmerActive: false,
1143
- };
1144
- // TODO: this service needs to be transferred in the respective component
1145
- class UxAppShellService {
1146
- // -------------------
1147
- get state$() {
1148
- return this._state$.asObservable();
1149
- }
1150
- // -------------------
1151
- // exposed observables
1152
- get breakpoint$() {
1153
- return this._breakpoint$.asObservable();
1154
- }
1155
- get breakpoints$() {
1156
- return this._breakpoints$.asObservable();
1157
- }
1158
- // ----------------
1159
- // state operations
1160
- // ----------------
1161
- get state() {
1162
- return this._state$.getValue();
1163
- }
1164
- // ----------------------------
1165
- // public setters and functions
1166
- // ----------------------------
1167
- set isSidebarOpen(isOpen) {
1168
- this.setState({
1169
- ...this.state,
1170
- isSidebarOpen: isOpen,
1171
- });
1172
- }
1173
- get isSidebarOpen() {
1174
- return this.state.isSidebarOpen;
1062
+ /**
1063
+ * Function to be used before the AppModule is bootstrapped. It is currently used to load dynamic configurations.
1064
+ * It needs to be added in your application main.ts file.
1065
+ * @param envConfig the current environment configuration
1066
+ * @returns the updated environment configuration, as a promise
1067
+ */
1068
+ async function preInitApp(envConfig) {
1069
+ const envDynamicConfig = envConfig && envConfig.envDynamicConfig;
1070
+ if (envDynamicConfig) {
1071
+ // load the local configuration file, if defined
1072
+ const euiAppJsonConfig = await loadEuiDynamicEnvironmentConfig(envDynamicConfig.uri, envDynamicConfig.configTimeout || 2000);
1073
+ envConfig.loadedEnvDynamicConfig = euiAppJsonConfig;
1074
+ return envConfig;
1175
1075
  }
1176
- set isSidebarHover(isHover) {
1177
- if (this.state.isSidebarExpandOnHover) {
1178
- this.setState({
1179
- ...this.state,
1180
- isSidebarHover: isHover,
1076
+ return envConfig;
1077
+ }
1078
+ /**
1079
+ * Function to load asynchronously a dynamic configuration (from a local path or a web service)
1080
+ *
1081
+ * @param url the path to the configuration
1082
+ * @param timeout possible timeout
1083
+ * @returns EuiAppJsonConfig promise
1084
+ */
1085
+ async function loadEuiDynamicEnvironmentConfig(url, timeout) {
1086
+ // if the url is specified
1087
+ if (url) {
1088
+ // fetch the config
1089
+ try {
1090
+ return await xhr({
1091
+ url,
1092
+ timeout,
1181
1093
  });
1182
1094
  }
1095
+ catch (error) {
1096
+ // send a warning to the console
1097
+ console.warn('Dynamic configuration cannot be loaded from url', url, error);
1098
+ }
1183
1099
  }
1184
- get isSidebarHover() {
1185
- return this.state.isSidebarHover;
1186
- }
1187
- set isSidebarActive(isActive) {
1188
- this.setState({
1189
- ...this.state,
1190
- isSidebarActive: isActive,
1191
- });
1192
- }
1193
- set isSidebarInnerActive(isOpen) {
1194
- this.setState({
1195
- ...this.state,
1196
- isSidebarInnerActive: isOpen,
1197
- });
1100
+ // the dynamic config is not loaded
1101
+ return null;
1102
+ }
1103
+
1104
+ const errorCodes = {
1105
+ ERR_GENERIC: 'ERR_GENERIC',
1106
+ };
1107
+ const messages = {
1108
+ ERR_GENERIC: 'An error occured',
1109
+ };
1110
+ // Intermediate "hacky" subclass taken from
1111
+ // https://www.bennadel.com/blog/3226-experimenting-with-error-sub-classing-using-es5-and-typescript-2-1-5.htm
1112
+ class ErrorSubClass {
1113
+ constructor(code, msg, args) {
1114
+ if (!msg && code && code in messages) {
1115
+ if (typeof messages[code] === 'function') {
1116
+ msg = messages[code](...args.messageParams);
1117
+ }
1118
+ else {
1119
+ msg = messages[code];
1120
+ }
1121
+ }
1122
+ this.name = 'ErrorSubClass';
1123
+ this.message = msg;
1124
+ this.code = code;
1125
+ this.stack = new Error(msg).stack;
1126
+ if (args) {
1127
+ Object.keys(args).forEach((k) => {
1128
+ if (k !== 'messageParams') {
1129
+ this[k] = args[k];
1130
+ }
1131
+ });
1132
+ }
1198
1133
  }
1199
- set sidebarLinks(links) {
1200
- this.setState({
1201
- ...this.state,
1202
- sidebarLinks: links,
1203
- });
1134
+ }
1135
+ // This replaces the "extends" on the Class
1136
+ // ErrorSubClass.prototype = <any>Object.create(Error.prototype);
1137
+ class EuiError extends ErrorSubClass {
1138
+ constructor(code = errorCodes.ERR_GENERIC, msg, args) {
1139
+ super(code, msg, args);
1140
+ this.name = 'EuiError';
1204
1141
  }
1205
- set menuLinks(links) {
1206
- this.setState({
1207
- ...this.state,
1208
- menuLinks: links,
1209
- });
1142
+ }
1143
+
1144
+ class GlobalErrorHandler extends ErrorHandler {
1145
+ constructor(logService) {
1146
+ super();
1147
+ this.logService = logService;
1210
1148
  }
1211
- set isBlockDocumentActive(isActive) {
1212
- this.setState({
1213
- ...this.state,
1214
- isBlockDocumentActive: isActive,
1215
- });
1149
+ handleError(error) {
1150
+ // log error
1151
+ this.logService.error(error.message || error.toString());
1152
+ // throw error;
1153
+ super.handleError(error);
1216
1154
  }
1217
- get hasHeader() {
1218
- return this.state.hasHeader;
1155
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: GlobalErrorHandler, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1156
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: GlobalErrorHandler, providedIn: 'root' }); }
1157
+ }
1158
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: GlobalErrorHandler, decorators: [{
1159
+ type: Injectable,
1160
+ args: [{
1161
+ providedIn: 'root',
1162
+ }]
1163
+ }], ctorParameters: () => [{ type: LogService }] });
1164
+
1165
+ class HttpErrorHandlerInterceptor {
1166
+ constructor(config = DEFAULT_HTTP_ERROR_HANDLER_CONFIG, injector, router) {
1167
+ this.config = config;
1168
+ this.injector = injector;
1169
+ this.router = router;
1219
1170
  }
1220
- // Edit mode
1221
- get isDimmerActive() {
1222
- return this.state.isDimmerActive;
1171
+ intercept(req, next) {
1172
+ return next.handle(req).pipe(tap(() => { }, (error) => {
1173
+ // in case of http error
1174
+ if (error instanceof HttpErrorResponse) {
1175
+ const routeConfig = this.getRouteConfig(error);
1176
+ const rule = routeConfig && (routeConfig[error.status] || routeConfig.default);
1177
+ if (typeof rule === 'string') {
1178
+ // perform a redirect
1179
+ this.router.navigate([rule]);
1180
+ }
1181
+ else if (typeof rule === 'function') {
1182
+ // callback function
1183
+ rule.call(null, error, this.injector);
1184
+ }
1185
+ }
1186
+ }));
1223
1187
  }
1224
- set isDimmerActive(isActive) {
1225
- this.setState({
1226
- ...this.state,
1227
- isDimmerActive: isActive,
1188
+ /**
1189
+ * Search in the configuration for the first matching route
1190
+ *
1191
+ * @param error http error response
1192
+ * @returns HttpErrorRouteConfig or null
1193
+ */
1194
+ getRouteConfig(error) {
1195
+ // filter the routes
1196
+ const routes = this.config.routes.filter((route) => {
1197
+ const regex = new RegExp('^' + route.path.split('*').join('.*') + '$');
1198
+ return regex.test(error.url) && (typeof route[error.status] !== 'undefined' || typeof route.default !== 'undefined');
1228
1199
  });
1200
+ // return the first matching route, if any
1201
+ return routes.length > 0 ? routes[0] : null;
1229
1202
  }
1230
- constructor(config, http, platformId, router, storeService, i18nService) {
1231
- this.config = config;
1203
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: HttpErrorHandlerInterceptor, deps: [{ token: HTTP_ERROR_HANDLER_CONFIG_TOKEN }, { token: i0.Injector }, { token: i1$4.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
1204
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: HttpErrorHandlerInterceptor }); }
1205
+ }
1206
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: HttpErrorHandlerInterceptor, decorators: [{
1207
+ type: Injectable
1208
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1209
+ type: Inject,
1210
+ args: [HTTP_ERROR_HANDLER_CONFIG_TOKEN]
1211
+ }] }, { type: i0.Injector }, { type: i1$4.Router }] });
1212
+
1213
+ function AlertHttpErrorCallbackFn(error) {
1214
+ alert(error.statusText);
1215
+ }
1216
+ function ConsoleHttpErrorCallbackFn(error) {
1217
+ console.error('HttpError', error);
1218
+ }
1219
+ function LogHttpErrorCallbackFn(error, injector) {
1220
+ const logService = injector.get(LogService);
1221
+ logService.error('HttpError', error);
1222
+ }
1223
+ function GrowlHttpErrorCallbackFn(error, injector) {
1224
+ const asService = injector.get(EuiGrowlService);
1225
+ asService.growlError(error.statusText);
1226
+ }
1227
+
1228
+ class ApiQueueService {
1229
+ constructor(store, http, logService) {
1230
+ this.store = store;
1232
1231
  this.http = http;
1233
- this.platformId = platformId;
1234
- this.router = router;
1235
- this.storeService = storeService;
1236
- this.i18nService = i18nService;
1237
- this.cssVars = [];
1238
- let stateWithConfig = initialState;
1239
- const languages = config?.i18n?.i18nService?.languages || initialState.languages;
1240
- const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState.activeLanguage;
1241
- stateWithConfig = {
1242
- ...stateWithConfig,
1243
- ...{
1244
- languages,
1245
- activeLanguage: defaultLanguage,
1246
- },
1247
- };
1248
- this._state$ = new BehaviorSubject(stateWithConfig);
1249
- this._breakpoint$ = new BehaviorSubject('');
1250
- this._breakpoints$ = new BehaviorSubject({});
1251
- this.bindActiveLanguageToAppShellState();
1252
- if (isPlatformBrowser(this.platformId)) {
1253
- router.events.subscribe((event) => {
1254
- if (event instanceof NavigationEnd) {
1255
- window.scrollTo(0, 0);
1256
- }
1257
- });
1258
- }
1232
+ this.logService = logService;
1259
1233
  }
1260
- setState(nextState, updateI18 = true) {
1261
- let breakpoint, breakpoints, wrapperClasses;
1262
- let combinedLinks;
1263
- const state = this.state;
1264
- // check if window width has been updated from previous state
1265
- if (this.state.windowWidth !== nextState.windowWidth) {
1266
- breakpoint = this.getBreakpoint(nextState.windowWidth);
1267
- breakpoints = this.getBreakpoints(breakpoint);
1268
- this._breakpoint$.next(breakpoint);
1269
- this._breakpoints$.next(breakpoints);
1270
- // if not propagate the old ones without doing any calculations
1271
- }
1272
- else {
1273
- breakpoint = state.breakpoint;
1274
- breakpoints = state.breakpoints;
1275
- }
1276
- // finally get the wrapper classes when both the state and breakpoint are known
1277
- wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
1278
- // check if the menuLinks or sidebarLinks have changed from previous state
1279
- if (this.state.menuLinks !== nextState.menuLinks || this.state.sidebarLinks !== nextState.sidebarLinks) {
1280
- combinedLinks = [...nextState.menuLinks, ...nextState.sidebarLinks];
1281
- }
1282
- else {
1283
- combinedLinks = this.state.combinedLinks;
1284
- }
1285
- const stateBeforeUpdate = { ...this.state };
1286
- // we put it all together with the calculated properties
1287
- this._state$.next({
1288
- ...nextState,
1289
- wrapperClasses,
1290
- breakpoint,
1291
- breakpoints,
1292
- combinedLinks,
1293
- });
1294
- // update the Store Language
1295
- if (updateI18 && nextState.activeLanguage !== stateBeforeUpdate.activeLanguage) {
1296
- this.i18nService.updateState({ activeLang: nextState.activeLanguage });
1234
+ /**
1235
+ * Adds an item in the queue by dispatching an action to the store.
1236
+ * @param id - The id of the item inside the queue.
1237
+ * WARNING if matches any other queue item id will overwrite it.
1238
+ * @param item - an item for Queue
1239
+ */
1240
+ addQueueItem(id, item) {
1241
+ const allowedMethods = ['post', 'put', 'get'];
1242
+ if (allowedMethods.indexOf(item.method) < 0) {
1243
+ throw new Error(`[ApiQueue] method "${item.method}" is not allowed`);
1297
1244
  }
1245
+ this.store.dispatch(new AddApiQueueItemAction({ id, item }));
1298
1246
  }
1299
1247
  /**
1300
- * Emits a slice from the state whether that changes
1301
- *
1302
- * @param key can be 'key' or 'key.sub.sub'
1248
+ * Subscribes to the store to retrieve queue and then converts the queue object to an array of items.
1249
+ * @return An Observable of array of all items inside the current queue (ApiQueueItem[])
1303
1250
  */
1304
- getState(key) {
1305
- return defer(() =>
1306
- // check if key exists
1307
- key
1308
- ? this.state$.pipe(map((state) => get(state, key)),
1309
- // filter((state) => state),
1310
- distinctUntilChanged((x, y) => isEqual(x, y)))
1311
- : this.state$);
1251
+ getQueue() {
1252
+ return this.store.select(getApiQueue).pipe(take(1), map((queue) => {
1253
+ const queueArray = queue && Object.values(queue);
1254
+ if (!queueArray || queueArray.length < 1) {
1255
+ this.logService.warn('No items in the queue exist.');
1256
+ }
1257
+ return queueArray;
1258
+ }));
1312
1259
  }
1313
- sidebarToggle() {
1314
- this.isSidebarOpen = !this.state.isSidebarOpen;
1260
+ /**
1261
+ * Subscribes to the store to retrieve an item from the queue.
1262
+ * @param id - id of the item inside the queue
1263
+ * @return An Observable of ApiQueueItem type
1264
+ */
1265
+ getQueueItem(id) {
1266
+ return this.store.select(getApiQueueItem(id)).pipe(take(1), map((queue) => {
1267
+ if (!queue) {
1268
+ this.logService.warn(`Queue item with id "${id}" does not exist`);
1269
+ return null;
1270
+ }
1271
+ return queue;
1272
+ }));
1315
1273
  }
1316
- // Edit mode
1317
- dimmerActiveToggle() {
1318
- const isActive = this.isDimmerActive;
1319
- this.setState({
1320
- ...this.state,
1321
- isDimmerActive: !isActive,
1322
- });
1323
- this.activateEditModeCssVars(!isActive);
1274
+ /**
1275
+ * Removes a given item from the queue.
1276
+ * @param id - id of the item inside the queue
1277
+ */
1278
+ removeQueueItem(id) {
1279
+ this.store.dispatch(new RemoveApiQueueItemAction(id));
1324
1280
  }
1325
- setDimmerActiveState(activeState) {
1326
- this.setState({
1327
- ...this.state,
1328
- isDimmerActive: activeState,
1329
- });
1330
- this.activateEditModeCssVars(activeState);
1281
+ /**
1282
+ * Removes all items placed in the queue.
1283
+ */
1284
+ removeAllQueueItem() {
1285
+ this.store.dispatch(new EmptyApiQueueAction(null));
1331
1286
  }
1332
- activateEditModeCssVars(isActive) {
1333
- if (isActive) {
1334
- this._setCssVarValue('--eui-docpage-navigation-z-index', 'inherit'); // Reset doc-page-navigation-column z-index
1335
- this._setCssVarValue('--eui-z-index-sidebar', 'inherit'); // Reset eui-app-sidebar z-index
1336
- this._setCssVarValue('--eui-z-index-root', 'inherit'); // Reset eui-app-main-content z-index
1337
- }
1338
- else {
1339
- this._setCssVarValue('--eui-docpage-navigation-z-index', '2'); // Restore doc-page-navigation-column z-index
1340
- this._setCssVarValue('--eui-z-index-sidebar', '1044'); // Restore eui-app-sidebar z-index
1341
- this._setCssVarValue('--eui-z-index-root', '1'); // Restore eui-app-main-content z-index
1342
- }
1287
+ /**
1288
+ * Process an item from the queue.
1289
+ * @param id - id of the item inside the queue
1290
+ * @return An Observable of type any
1291
+ */
1292
+ processQueueItem(id) {
1293
+ return this.store.select(getApiQueueItem(id)).pipe(take(1), switchMap((queue) => {
1294
+ if (!queue) {
1295
+ this.logService.warn(`Queue item with id "${id}" does not exist`);
1296
+ return of(null);
1297
+ }
1298
+ return this.buildHttpRequest(id, queue);
1299
+ }));
1343
1300
  }
1344
- // --------------
1345
- // public methods
1346
- // --------------
1347
- fetchAppMetadata(metadataFilePath = 'assets/app-metadata.json') {
1348
- this.getJson(metadataFilePath).then((data) => {
1349
- this.setState({
1350
- ...this.state,
1351
- appMetadata: data,
1352
- });
1353
- });
1301
+ /**
1302
+ * Process all the items inside the queue.
1303
+ * @param [continueOnError=true] - in case of an item request fails continue with the rest in queue
1304
+ * @return An Observable with an array which contains all responses from all items in queue.
1305
+ */
1306
+ processAllQueueItems(continueOnError = true) {
1307
+ return this.store.select(getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
1308
+ this.logService.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
1309
+ if (!continueOnError) {
1310
+ throw error;
1311
+ }
1312
+ return of(error);
1313
+ })))), switchMap((obsQueue) => forkJoin(Array.from(obsQueue))));
1354
1314
  }
1355
- activateSidebar() {
1356
- this.setState({
1357
- ...this.state,
1358
- hasSidebar: true,
1359
- });
1360
- if (!this.state.isSidebarHidden) {
1361
- this.activateSidebarCssVars();
1362
- }
1315
+ /**
1316
+ * Process all items in queue after it order them based on their timestamp. Beware that order
1317
+ * matter in execution of Http Request in queue. When a request completes only then next will begin. Emission
1318
+ * or Http response follows order.
1319
+ * @param [ascending=true] - sets the order of queue items based on timestamp
1320
+ */
1321
+ processAllQueueItemsSequential(ascending = true) {
1322
+ return this.store.select(getApiQueue).pipe(concatMap((queue) => Object.entries(queue)
1323
+ .sort((a, b) => (ascending ? this.sortOnTimestamp(a, b) : this.sortOnTimestamp(b, a)))
1324
+ .map(([id, item]) => this.buildHttpRequest(id, item))));
1363
1325
  }
1364
- activateSidebarHeader() {
1365
- this.activateSidebarHeaderCssVars();
1326
+ /**
1327
+ * Short dates ascending based on input
1328
+ * @param a - Date one
1329
+ * @param b - Date two
1330
+ *
1331
+ * @beta
1332
+ */
1333
+ sortOnTimestamp(a, b) {
1334
+ return +new Date(a[1].timestamp) - +new Date(b[1].timestamp);
1366
1335
  }
1367
- activateSidebarFooter() {
1368
- this.activateSidebarFooterCssVars();
1336
+ /**
1337
+ * build and HttpRequest Observable based on the given queue.
1338
+ * After successful request completion removes the item from the queue.
1339
+ * @param id - id of the item inside the queue
1340
+ * @param item - the item of the queue that matches the id.
1341
+ * @return An Observable of HttpClient Request
1342
+ */
1343
+ buildHttpRequest(id, item) {
1344
+ return this.http[item.method.toLowerCase()](item.uri, item.payload).pipe(tap(() => this.removeQueueItem(id)));
1369
1345
  }
1370
- activateHeader() {
1371
- this.setState({
1372
- ...this.state,
1373
- hasHeader: true,
1374
- });
1375
- this.activateHeaderCssVars();
1346
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$5.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1347
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ApiQueueService, providedIn: 'root' }); }
1348
+ }
1349
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: ApiQueueService, decorators: [{
1350
+ type: Injectable,
1351
+ args: [{
1352
+ providedIn: 'root',
1353
+ }]
1354
+ }], ctorParameters: () => [{ type: StoreService }, { type: i1$5.HttpClient }, { type: LogService }] });
1355
+
1356
+ class ApiQueueServiceMock extends ApiQueueService {
1357
+ constructor() {
1358
+ super(null, null, null);
1376
1359
  }
1377
- activateBreadcrumb() {
1378
- this.setState({
1379
- ...this.state,
1380
- hasBreadcrumb: true,
1381
- });
1382
- this.activateBreadcrumbCssVars();
1360
+ getQueue() {
1361
+ return of([]);
1383
1362
  }
1384
- activateTopMessage(height) {
1385
- this.setState({
1386
- ...this.state,
1387
- hasTopMessage: true,
1388
- });
1389
- this.activateTopMessageCssVars(height);
1363
+ getQueueItem(id) {
1364
+ return of({ uri: id, method: 'GET' });
1390
1365
  }
1391
- activateToolbar() {
1392
- this.setState({
1393
- ...this.state,
1394
- hasToolbar: true,
1395
- });
1396
- this.activateToolbarCssVars();
1366
+ removeAllQueueItem() { }
1367
+ processAllQueueItems() {
1368
+ return of({});
1397
1369
  }
1398
- activateToolbarMenu() {
1399
- this.setState({
1400
- ...this.state,
1401
- hasToolbarMenu: true,
1402
- });
1370
+ addQueueItem() { }
1371
+ removeQueueItem() { }
1372
+ processQueueItem() {
1373
+ return of({});
1403
1374
  }
1404
- fetchCssVars() {
1405
- const cssVarNames = [
1406
- '--eui-app-header-height-default',
1407
- '--eui-app-header-height-active',
1408
- '--eui-app-header-height-shrink',
1409
- '--eui-app-breadcrumb-height-default',
1410
- '--eui-app-breadcrumb-height-active',
1411
- '--eui-app-top-message-height-default',
1412
- '--eui-app-top-message-height-active',
1413
- '--eui-app-top-message-height-shrink',
1414
- '--eui-app-toolbar-height-default',
1415
- '--eui-app-toolbar-height-active',
1416
- '--eui-app-sidebar-width-default',
1417
- '--eui-app-sidebar-width-active',
1418
- '--eui-app-sidebar-width-close-default',
1419
- '--eui-app-sidebar-width-close-active',
1420
- '--eui-app-sidebar-header-height-default',
1421
- '--eui-app-sidebar-header-height-active',
1422
- '--eui-app-sidebar-footer-height-default',
1423
- '--eui-app-sidebar-footer-height-active',
1424
- ];
1425
- this.cssVars = cssVarNames.map((v) => ({ key: v, value: this.getCssVarValue(v) }));
1375
+ }
1376
+
1377
+ class I18nResourceImpl {
1378
+ /**
1379
+ * Resource constructor
1380
+ *
1381
+ * @param prefix the prefix of the resource
1382
+ * @param suffix the suffix of the resource, optional parameter
1383
+ * @param compileTranslations compiler function, optional parameter
1384
+ */
1385
+ constructor(prefix, suffix = '', compileTranslationsFn = (translations) => translations) {
1386
+ this.prefix = prefix;
1387
+ this.suffix = suffix;
1388
+ this.compileTranslationsFn = compileTranslationsFn;
1426
1389
  }
1427
- initCssVars() {
1428
- this.setCssVar('--eui-app-header-height-default', '--eui-app-header-height');
1429
- this.setCssVar('--eui-app-breadcrumb-height-default', '--eui-app-breadcrumb-height');
1430
- this.setCssVar('--eui-app-top-message-height-default', '--eui-app-top-message-height');
1431
- this.setCssVar('--eui-app-toolbar-height-default', '--eui-app-toolbar-height');
1432
- this.setCssVar('--eui-app-sidebar-width-default', '--eui-app-sidebar-width');
1433
- this.setCssVar('--eui-app-sidebar-width-close-default', '--eui-app-sidebar-width-close');
1434
- this.setCssVar('--eui-app-sidebar-header-height-default', '--eui-app-sidebar-header-height');
1435
- this.setCssVar('--eui-app-sidebar-footer-height-default', '--eui-app-sidebar-footer-height');
1390
+ /**
1391
+ * Translations pre-processor
1392
+ *
1393
+ * @param translations the object to be pre-processed
1394
+ * @param lang the translations language
1395
+ * @returns the pre-processed translations
1396
+ */
1397
+ compileTranslations(translations, lang) {
1398
+ return this.compileTranslationsFn(translations, lang);
1436
1399
  }
1437
- activateHeaderCssVars() {
1438
- this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
1400
+ /**
1401
+ * Indicates whether other object is equal-to this one.
1402
+ *
1403
+ * @param obj the reference object with which to compare
1404
+ * @returns true if this object is the same as obj, false otherwise
1405
+ */
1406
+ equals(obj) {
1407
+ return this.prefix === obj.prefix && this.suffix === obj.suffix;
1439
1408
  }
1440
- activateBreadcrumbCssVars() {
1441
- this.setCssVar('--eui-app-breadcrumb-height-active', '--eui-app-breadcrumb-height');
1409
+ /**
1410
+ * The path to the resource
1411
+ *
1412
+ * @param lang the resource language
1413
+ * @returns the path
1414
+ */
1415
+ getPath(lang) {
1416
+ return `${this.prefix}${lang}${this.suffix}`;
1442
1417
  }
1443
- activateTopMessageCssVars(height) {
1444
- this._setCssVarValue('--eui-app-top-message-height', `${height}px`);
1418
+ }
1419
+
1420
+ class I18nLoader {
1421
+ constructor(http, logService, euiAppConfig) {
1422
+ this.http = http;
1423
+ this.logService = logService;
1424
+ this.euiAppConfig = euiAppConfig;
1425
+ this.resources = [];
1426
+ this.failedResources = [];
1427
+ // create the resources from the config object
1428
+ const i18nConfig = this.euiAppConfig.global && this.euiAppConfig.global.i18n;
1429
+ const i18nLoaderConfig = i18nConfig && i18nConfig.i18nLoader;
1430
+ this.resources.push(...this.createResources(i18nLoaderConfig));
1445
1431
  }
1446
- activateToolbarCssVars() {
1447
- this.setCssVar('--eui-app-toolbar-height-active', '--eui-app-toolbar-height');
1432
+ /**
1433
+ * Gets the translations from the server
1434
+ *
1435
+ * @param lang
1436
+ * @returns Observable<any>
1437
+ */
1438
+ getTranslation(lang) {
1439
+ return this.loadResources(this.resources, lang).pipe(map((loadedResources) => {
1440
+ this.failedResources = loadedResources.hasError ? loadedResources.errors : [];
1441
+ return loadedResources.translations;
1442
+ }));
1448
1443
  }
1449
- activateFooterCssVars() {
1450
- this.setCssVar('--eui-app-footer-height-active', '--eui-app-footer-height');
1444
+ /**
1445
+ * Adds resources
1446
+ *
1447
+ * @param config loader configuration
1448
+ * @returns Observable<any> | false
1449
+ */
1450
+ addResources(config) {
1451
+ // create the resources
1452
+ let resources = this.createResources(config);
1453
+ // filter the resources first, to avoid duplicates
1454
+ resources = resources.filter((resource) => !this.resources.some((res) => res.equals(resource)));
1455
+ // add the new resources to the list of existing resources
1456
+ this.resources.push(...resources);
1457
+ // return the filtered resources
1458
+ return resources;
1451
1459
  }
1452
- setHeaderShrinkCssVar(active) {
1453
- if (active) {
1454
- this.setCssVar('--eui-app-header-height-shrink', '--eui-app-header-height');
1460
+ /**
1461
+ * Removes resources from the loader instance
1462
+ */
1463
+ removeResources(removedResources) {
1464
+ this.resources = this.resources.filter((res) => !removedResources.some((removedResource) => removedResource.equals(res)));
1465
+ }
1466
+ /**
1467
+ * Loads an array of resources, by language
1468
+ *
1469
+ * @param resources the definition of the resources
1470
+ * @param lang the resource language to load
1471
+ * @returns Observable<any>
1472
+ */
1473
+ loadResources(resources, lang) {
1474
+ // if there are resources to load
1475
+ if (Array.isArray(resources) && resources.length > 0) {
1476
+ // load all the resources in an array of Observable
1477
+ const requests = resources.map((resource) => this.loadResource(resource, lang));
1478
+ // group all the observables with forkJoin and deep merge them
1479
+ return forkJoin(requests).pipe(map((response) => {
1480
+ const successResp = [];
1481
+ const errResp = [];
1482
+ response.forEach((item) => {
1483
+ if (item.isError) {
1484
+ errResp.push({ resource: item.resource, error: item.error });
1485
+ }
1486
+ else {
1487
+ successResp.push(item);
1488
+ }
1489
+ });
1490
+ if (successResp.length === response.length) {
1491
+ return { hasError: false, translations: mergeAll(successResp) };
1492
+ }
1493
+ else {
1494
+ return { hasError: true, translations: mergeAll(successResp), errors: errResp };
1495
+ }
1496
+ }));
1455
1497
  }
1456
1498
  else {
1457
- this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
1499
+ // no resources to load
1500
+ return of({ hasError: false, translations: {} });
1458
1501
  }
1459
1502
  }
1460
- activateSidebarCssVars() {
1461
- this.setCssVar('--eui-app-sidebar-width-active', '--eui-app-sidebar-width');
1462
- this.setCssVar('--eui-app-sidebar-width-close-active', '--eui-app-sidebar-width-close');
1463
- }
1464
- removeSidebarCssVars() {
1465
- document.documentElement.style.removeProperty('--eui-app-sidebar-header-height');
1466
- document.documentElement.style.removeProperty('--eui-app-sidebar-footer-height');
1467
- document.documentElement.style.removeProperty('--eui-app-sidebar-width');
1468
- document.documentElement.style.removeProperty('--eui-app-sidebar-width-close');
1469
- }
1470
- activateSidebarHeaderCssVars() {
1471
- this.setCssVar('--eui-app-sidebar-header-height-active', '--eui-app-sidebar-header-height');
1472
- }
1473
- activateSidebarFooterCssVars() {
1474
- this.setCssVar('--eui-app-sidebar-footer-height-active', '--eui-app-sidebar-footer-height');
1475
- }
1476
1503
  /**
1477
- * Gets the viewport height and width and multiple it by 1% to get a value for a vh/vw unit
1478
- * Sets the value in the --eui-app-vh custom property to the root of the document
1479
- * Sets the value in the --eui-app-vw custom property to the root of the document
1480
- * Example for 100% height: calc(var(--eui-app-vh, 1vh) * 100);
1481
- * Example for 50% height: calc(var(--eui-app-vh, 1vh) * 50);
1482
- * Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
1504
+ * Returns resources that failed
1483
1505
  */
1484
- setAppViewportCssVars() {
1485
- let vh = window.innerHeight * 0.01;
1486
- let vw = window.innerWidth * 0.01;
1487
- this._setCssVarValue('--eui-app-vh', `${vh}px`);
1488
- this._setCssVarValue('--eui-app-vw', `${vw}px`);
1489
- }
1490
- // ---------------
1491
- // private getters
1492
- // ---------------
1493
- getCssVarValue(inputProperty) {
1494
- return getComputedStyle(document.documentElement).getPropertyValue(inputProperty);
1506
+ getFailedResources() {
1507
+ return this.failedResources;
1495
1508
  }
1496
- setCssVar(inputProperty, outputProperty) {
1497
- const cssVarValue = this.cssVars.filter((v) => v.key === inputProperty)[0].value;
1498
- this._setCssVarValue(outputProperty, cssVarValue);
1499
- // console.log(inputProperty, outputProperty, cssVarValue);
1509
+ /**
1510
+ * Create resources from a config file
1511
+ *
1512
+ * @param config loader configuration
1513
+ * @returns I18nResourceImpl[] resources
1514
+ */
1515
+ createResources(config) {
1516
+ // use the default config as a reference base
1517
+ config = getI18nLoaderConfig(config);
1518
+ const resources = [];
1519
+ // extract the i18n folders from config
1520
+ const i18nFolders = Array.isArray(config.i18nFolders)
1521
+ ? config.i18nFolders
1522
+ : config.i18nFolders
1523
+ ? [config.i18nFolders]
1524
+ : [];
1525
+ if (i18nFolders) {
1526
+ // add the i18n folders to resources
1527
+ resources.push(...i18nFolders.map((folder) => new I18nResourceImpl(`assets/${folder}/`, '.json')));
1528
+ }
1529
+ // extract the i18n services from config
1530
+ const i18nServices = Array.isArray(config.i18nServices)
1531
+ ? config.i18nServices
1532
+ : config.i18nServices
1533
+ ? [config.i18nServices]
1534
+ : [];
1535
+ if (i18nServices) {
1536
+ // add the i18n services to resources
1537
+ resources.push(...i18nServices.map((service) => new I18nResourceImpl(service)));
1538
+ }
1539
+ // extract the i18n resources from config
1540
+ const i18nResources = Array.isArray(config.i18nResources)
1541
+ ? config.i18nResources
1542
+ : config.i18nResources
1543
+ ? [config.i18nResources]
1544
+ : [];
1545
+ if (i18nResources) {
1546
+ // add the i18n resources to resources
1547
+ resources.push(...i18nResources.map((resource) => new I18nResourceImpl(resource.prefix, resource.suffix, this.getResourceCompileFunction(resource.compileTranslations))));
1548
+ }
1549
+ return resources;
1500
1550
  }
1501
- _setCssVarValue(varName, varValue) {
1502
- document.documentElement.style.setProperty(varName, varValue);
1503
- }
1504
- getWrapperClasses(state, breakpoint) {
1505
- let classes = [];
1506
- classes.push(breakpoint);
1507
- if (state.hasSidebar) {
1508
- if (state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
1509
- classes.push('sidebar-state-open');
1510
- }
1511
- if (!state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
1512
- classes.push('sidebar-state-close');
1513
- }
1514
- if (state.isSidebarActive) {
1515
- classes.push('sidebar-active');
1516
- }
1517
- if (state.isSidebarInnerActive) {
1518
- classes.push('sidebar-inner-active');
1519
- }
1520
- if (state.isSidebarStateCloseWithIcons) {
1521
- classes.push('sidebar-state-close-with-icons');
1522
- }
1523
- // NEW APP-SHELL props
1524
- if (state.isSidebarHidden) {
1525
- classes.push('sidebar--hidden');
1526
- }
1527
- if (state.isSidebarOpen) {
1528
- classes.push('sidebar--open');
1529
- }
1530
- else {
1531
- classes.push('sidebar--close');
1551
+ /**
1552
+ * Loads a resource, by language
1553
+ *
1554
+ * @param resource the definition of the resource
1555
+ * @param lang the resource language to load
1556
+ * @returns Observable<any>
1557
+ */
1558
+ loadResource(resource, lang) {
1559
+ // the path to the resource
1560
+ const path = resource.getPath(lang);
1561
+ // load the translations from the path
1562
+ return this.http.get(path).pipe(
1563
+ // preprocess the translations using the resource compiler
1564
+ map((translations) => resource.compileTranslations(translations, lang)), map((translations) => {
1565
+ // resource loaded properly, send a info message
1566
+ if (this.logService) {
1567
+ this.logService.info(`I18n resource loaded from path ${path}`);
1532
1568
  }
1533
- if (state.isSidebarHover) {
1534
- classes.push('sidebar--hover');
1569
+ // return the translations
1570
+ return translations;
1571
+ }), catchError((err) => {
1572
+ // remove failed resource from loaded resource array
1573
+ this.removeResources([resource]);
1574
+ // resource not loaded properly, send a warning message
1575
+ if (this.logService) {
1576
+ this.logService.warn(`I18n resource NOT loaded from path ${path}`, err);
1535
1577
  }
1536
- }
1537
- if (state.deviceInfo && state.deviceInfo.isFF) {
1538
- classes.push('ff');
1539
- }
1540
- if (state.deviceInfo && state.deviceInfo.isIE) {
1541
- classes.push('ie');
1542
- }
1543
- if (state.deviceInfo && state.deviceInfo.isIE11) {
1544
- classes.push('ie11');
1545
- }
1546
- if (state.deviceInfo && state.deviceInfo.isChrome) {
1547
- classes.push('chrome');
1548
- }
1549
- return classes.join(' ');
1578
+ const resourceError = { error: `I18n resource NOT loaded from path ${path}`, resource, isError: true };
1579
+ return of(resourceError);
1580
+ }));
1550
1581
  }
1551
- getBreakpoint(windowWidth) {
1552
- let bkp = '';
1553
- switch (true) {
1554
- case windowWidth >= 0 && windowWidth < 576:
1555
- bkp = 'xs';
1556
- break;
1557
- case windowWidth >= 576 && windowWidth < 768:
1558
- bkp = 'sm';
1559
- break;
1560
- case windowWidth >= 768 && windowWidth < 992:
1561
- bkp = 'md';
1562
- break;
1563
- case windowWidth >= 992 && windowWidth < 1200:
1564
- bkp = 'lg';
1565
- break;
1566
- case windowWidth >= 1200 && windowWidth < 1400:
1567
- bkp = 'xl';
1568
- break;
1569
- case windowWidth >= 1400:
1570
- bkp = 'xxl';
1571
- break;
1582
+ getResourceCompileFunction(id) {
1583
+ const customHandlers = this.euiAppConfig.customHandler;
1584
+ if (customHandlers && typeof customHandlers[id] === 'function') {
1585
+ return customHandlers[id];
1572
1586
  }
1573
- return bkp;
1574
- }
1575
- getBreakpoints(bkp) {
1576
- return {
1577
- isMobile: bkp === 'xs' || bkp === 'sm',
1578
- isTablet: bkp === 'md',
1579
- isLtDesktop: bkp === 'xs' || bkp === 'sm' || bkp === 'md',
1580
- isDesktop: bkp === 'lg',
1581
- isXL: bkp === 'xl',
1582
- isXXL: bkp === 'xxl',
1583
- };
1584
- }
1585
- getJson(url) {
1586
- return this.http.get(url).toPromise().then(this.extractData).catch(this.handleError);
1587
- }
1588
- extractData(res) {
1589
- const body = res;
1590
- return body || {};
1591
- }
1592
- handleError(error) {
1593
- console.error('An error occurred', error);
1594
- return Promise.reject(error.message || error);
1595
- }
1596
- bindActiveLanguageToAppShellState() {
1597
- this.storeService.select(getActiveLang).subscribe((activeLang) => {
1598
- if (activeLang !== this.state.activeLanguage) {
1599
- this.setState({
1600
- ...this.state,
1601
- activeLanguage: activeLang,
1602
- }, false);
1603
- }
1604
- });
1605
- }
1606
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$2.HttpClient }, { token: PLATFORM_ID }, { token: i2$1.Router }, { token: StoreService }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
1607
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxAppShellService, providedIn: 'root' }); }
1608
- }
1609
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxAppShellService, decorators: [{
1610
- type: Injectable,
1611
- args: [{
1612
- providedIn: 'root',
1613
- }]
1614
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1615
- type: Optional
1616
- }, {
1617
- type: Inject,
1618
- args: [GLOBAL_CONFIG_TOKEN]
1619
- }] }, { type: i1$2.HttpClient }, { type: undefined, decorators: [{
1620
- type: Inject,
1621
- args: [PLATFORM_ID]
1622
- }] }, { type: i2$1.Router }, { type: StoreService }, { type: I18nService, decorators: [{
1623
- type: Optional
1624
- }] }]; } });
1625
-
1626
- class CoreAppEffects {
1627
- constructor(actions,
1628
- // TODO: remove on eUI 14
1629
- showConnectionStatus, translateService, asService) {
1630
- this.actions = actions;
1631
- this.showConnectionStatus = showConnectionStatus;
1632
- this.translateService = translateService;
1633
- this.asService = asService;
1634
- this.getAppConnectionInformation = createEffect(() => merge(fromEvent(window, 'online').pipe(mapTo(true)), fromEvent(window, 'offline').pipe(mapTo(false))).pipe(map((connected) => new UpdateAppConnectionAction(connected))));
1635
- this.activatedRoute = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.ACTIVATED_ROUTE), map((action) => action.payload), mergeMap((route) => {
1636
- // extract the module name, if defined
1637
- const module = route.snapshot.data['module'] || 'undefined';
1638
- return [new UpdateCurrentModuleAction(module)];
1639
- })));
1640
- this.updateAppConnection = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.UPDATE_APP_CONNECTION), map((action) => action.payload), tap((connected) => {
1641
- // TODO: for eUI 14, drop boolean support and refactor
1642
- // check if feature is enabled
1643
- let isFeatureEnabled = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.enabled : this.showConnectionStatus;
1644
- // extract lifespan if any
1645
- let lifespan = typeof this.showConnectionStatus !== 'boolean' ? this.showConnectionStatus?.messageBox?.lifespan || 0 : 0;
1646
- // if the user needs to be informed about the connection status
1647
- if (isFeatureEnabled) {
1648
- if (connected) {
1649
- this.translateService.get('eui.CONNECTED').subscribe((translation) => {
1650
- // TODO v17 - should be subscribed from the eui-app to display growl
1651
- // this.asService.growl(
1652
- // { severity: 'success', summary: 'MESSAGE', detail: translation, life: lifespan },
1653
- // lifespan < 1,
1654
- // false
1655
- // );
1656
- });
1657
- }
1658
- else {
1659
- this.translateService.get('eui.NOTCONNECTED').subscribe((translation) => {
1660
- // TODO v17 - should be subscribed from the eui-app to display growl
1661
- // this.asService.growl(
1662
- // { severity: 'danger', summary: 'ERROR', detail: translation, life: lifespan },
1663
- // lifespan < 1,
1664
- // false
1665
- // );
1666
- });
1667
- }
1668
- }
1669
- })), { dispatch: false });
1587
+ return undefined;
1670
1588
  }
1671
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$3.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i2.TranslateService }, { token: UxAppShellService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1672
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CoreAppEffects }); }
1589
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nLoader, deps: [{ token: i1$5.HttpClient }, { token: LogService, optional: true }, { token: CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
1590
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nLoader }); }
1673
1591
  }
1674
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CoreAppEffects, decorators: [{
1592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nLoader, decorators: [{
1675
1593
  type: Injectable
1676
- }], ctorParameters: function () { return [{ type: i1$3.Actions }, { type: undefined, decorators: [{
1594
+ }], ctorParameters: () => [{ type: i1$5.HttpClient }, { type: LogService, decorators: [{
1595
+ type: Optional
1596
+ }] }, { type: undefined, decorators: [{
1677
1597
  type: Inject,
1678
- args: [SHOW_CONNECTION_STATUS_TOKEN]
1679
- }] }, { type: i2.TranslateService }, { type: UxAppShellService }]; } });
1680
-
1681
- const CoreModuleEffects = [CoreAppEffects];
1682
-
1683
- const updateAppVersion = (state, action) => ({ ...state, version: action.payload });
1684
- const updateAppConnection = (state, action) => ({ ...state, connected: action.payload });
1685
- const AddAppLoadedConfigModules = (state, action) => ({
1686
- ...state,
1687
- loadedConfigModules: {
1688
- lastAddedModule: action.payload.moduleName,
1689
- modulesConfig: {
1690
- ...state.loadedConfigModules.modulesConfig,
1691
- [action.payload.moduleName]: {
1692
- ...action.payload.moduleConfig,
1693
- },
1694
- },
1598
+ args: [CONFIG_TOKEN]
1599
+ }] }] });
1600
+ const translateConfig = {
1601
+ loader: {
1602
+ provide: TranslateLoader,
1603
+ useClass: I18nLoader,
1695
1604
  },
1696
- });
1697
- const updateAppStatus = (state, action) => ({ ...state, status: action.payload });
1698
- const updateCurrentModule = (state, action) => Object.assign({}, state, { currentModule: action.payload });
1699
- const addApiQueueItem = (state, action) => {
1700
- // apply the timestamp to the queue item
1701
- const apiQueueItem = Object.assign({}, action.payload.item, { timestamp: new Date().getTime() });
1702
- // update the queue
1703
- const apiQueue = Object.assign({}, state.apiQueue, { [action.payload.id]: apiQueueItem });
1704
- return Object.assign({}, state, { apiQueue });
1705
- };
1706
- const removeApiQueueItem = (state, action) => {
1707
- // remove the specified id from the list of item ids and recreate the apiQueue from the remaining ids
1708
- const apiQueue = Object.keys(state.apiQueue)
1709
- .filter((id) => id !== action.payload)
1710
- .reduce((queue, key) => {
1711
- queue[key] = state.apiQueue[key];
1712
- return queue;
1713
- }, {});
1714
- return Object.assign({}, state, { apiQueue });
1715
- };
1716
- const emptyApiQueue = (state, action) =>
1717
- // remove all items in the Api Queue
1718
- Object.assign({}, state, { apiQueue: {} });
1719
- const actionToReducerMap$4 = {
1720
- [CoreAppActionTypes.UPDATE_APP_VERSION]: updateAppVersion,
1721
- [CoreAppActionTypes.UPDATE_APP_CONNECTION]: updateAppConnection,
1722
- [CoreAppActionTypes.ADD_APP_LOADED_CONFIG_MODULES]: AddAppLoadedConfigModules,
1723
- [CoreAppActionTypes.UPDATE_APP_STATUS]: updateAppStatus,
1724
- [CoreAppActionTypes.UPDATE_CURRENT_MODULE]: updateCurrentModule,
1725
- [CoreAppActionTypes.ADD_API_QUEUE_ITEM]: addApiQueueItem,
1726
- [CoreAppActionTypes.REMOVE_API_QUEUE_ITEM]: removeApiQueueItem,
1727
- [CoreAppActionTypes.EMPTY_API_QUEUE]: emptyApiQueue,
1728
- };
1729
- const coreAppReducers = (state = initialAppState, action) => {
1730
- if (actionToReducerMap$4[action.type]) {
1731
- return actionToReducerMap$4[action.type](state, action);
1732
- }
1733
- // if the action type is not in the map, call the base reducers method
1734
- return state;
1735
- };
1736
-
1737
- const updateUser = (state, action) => {
1738
- let fullName = action.payload.fullName;
1739
- if (!fullName) {
1740
- fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
1741
- }
1742
- return Object.assign({}, state, action.payload, { fullName });
1743
- };
1744
- const updateUserDetails = (state, action) => {
1745
- let fullName = action.payload.fullName;
1746
- if (!fullName) {
1747
- fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
1748
- }
1749
- // todo should be checked if state.details is really there
1750
- const details = Object.assign({}, state.details, action.payload, { fullName });
1751
- return Object.assign({}, state, details);
1752
- };
1753
- const updateUserPreferences = (state, action) => {
1754
- const preferences = Object.assign({}, state.preferences, action.payload);
1755
- return Object.assign({}, state, { preferences });
1756
- };
1757
- const updateUserRights = (state, action) => Object.assign({}, state, { rights: [...action.payload] });
1758
- const updateUserDashboard = (state, action) => {
1759
- // apply the dashboard to preferences
1760
- const preferences = Object.assign({}, state.preferences, { dashboard: action.payload });
1761
- // update the state
1762
- return { ...state, preferences };
1763
- };
1764
- const actionToReducerMap$3 = {
1765
- [CoreUserActionTypes.UPDATE_USER_DETAILS]: updateUserDetails,
1766
- [CoreUserActionTypes.UPDATE_USER_PREFERENCES]: updateUserPreferences,
1767
- [CoreUserActionTypes.UPDATE_USER_STATE]: updateUser,
1768
- [CoreUserActionTypes.UPDATE_USER_RIGHTS]: updateUserRights,
1769
- [CoreUserActionTypes.UPDATE_USER_DASHBOARD]: updateUserDashboard,
1770
- };
1771
- const coreUserReducers = (state = initialUserState, action) => {
1772
- if (actionToReducerMap$3[action.type]) {
1773
- return actionToReducerMap$3[action.type](state, action);
1774
- }
1775
- return state;
1776
- };
1777
-
1778
- const updateNotificationsList = (state, action) => Object.assign({}, state, { list: [...action.payload] });
1779
- const actionToReducerMap$2 = {
1780
- [CoreNotificationsActionTypes.UPDATE_NOTIFICATIONS_LIST]: updateNotificationsList,
1781
- };
1782
- const coreNotificationsReducers = (state = initialNotificationsState, action) => {
1783
- if (actionToReducerMap$2[action.type]) {
1784
- return actionToReducerMap$2[action.type](state, action);
1785
- }
1786
- return state;
1787
- };
1788
-
1789
- const updateI18nState = (state, action) => ({
1790
- ...state,
1791
- ...action.payload,
1792
- });
1793
- const actionToReducerMap$1 = {
1794
- [CoreI18nActionTypes.UPDATE_I18N_STATE]: updateI18nState,
1795
- };
1796
- const corI18nReducers = (state = initialI18nState, action) => {
1797
- if (actionToReducerMap$1[action.type]) {
1798
- return actionToReducerMap$1[action.type](state, action);
1799
- }
1800
- return state;
1801
1605
  };
1802
1606
 
1803
- const updateLocaleState = (state, action) => ({
1804
- ...state,
1805
- ...action.payload,
1806
- });
1807
- const actionToReducerMap = {
1808
- [CoreLocaleActionTypes.UPDATE_LOCALE_STATE]: updateLocaleState,
1809
- };
1810
- const coreLocaleReducers = (state = initialLocaleState, action) => {
1811
- if (actionToReducerMap[action.type]) {
1812
- return actionToReducerMap[action.type](state, action);
1607
+ class I18nService extends EuiLazyService {
1608
+ constructor(baseGlobalConfig, translateService, logService, store, document) {
1609
+ super({ activeLang: 'en' });
1610
+ this.baseGlobalConfig = baseGlobalConfig;
1611
+ this.translateService = translateService;
1612
+ this.logService = logService;
1613
+ this.store = store;
1614
+ this.document = document;
1615
+ this.config = getI18nServiceConfigFromBase(this.baseGlobalConfig);
1616
+ this.onModuleLoad = new BehaviorSubject({ ready: false, name: null });
1813
1617
  }
1814
- return state;
1815
- };
1816
-
1817
- const coreReducers = Object.assign({}, {
1818
- app: coreAppReducers,
1819
- user: coreUserReducers,
1820
- notifications: coreNotificationsReducers,
1821
- i18n: corI18nReducers,
1822
- locale: coreLocaleReducers,
1823
- });
1824
-
1825
- const extend = extendProxy.default || extendProxy;
1826
- /**
1827
- * Utility meta-reducer to load the state from the local storage
1828
- * @param reducer the action reducer
1829
- */
1830
- function localStorageSync(reducer) {
1831
- return cb(reducer, localStorage);
1832
- }
1833
- /**
1834
- * Utility meta-reducer to load the state from the session storage
1835
- * @param reducer the action reducer
1836
- */
1837
- function sessionStorageSync(reducer) {
1838
- return cb(reducer, sessionStorage);
1839
- }
1840
- // Keys that are allowed to be synced with NgRx state from BrowserStorage
1841
- const disallowedKeys = ['loadedConfigModules', 'connect', 'currentModule', 'status', 'apiQueue'];
1842
- /**
1843
- * filters the AppState by removing those keys from the state and return a new state Object
1844
- * @param app the AppState
1845
- */
1846
- const filterAppState = (app) => {
1847
- // in case app is undefined or null it should return empty object
1848
- if (!app) {
1849
- return {};
1618
+ getState(keyOrMapFn) {
1619
+ let selector = getI18nState;
1620
+ let dotNotationToObject = (obj, key) => key.split('.').reduce((slice, i) => slice[i], obj);
1621
+ if (keyOrMapFn) {
1622
+ switch (typeof keyOrMapFn) {
1623
+ case 'function':
1624
+ selector = createSelector(getI18nState, keyOrMapFn);
1625
+ break;
1626
+ case 'string':
1627
+ selector = createSelector(getI18nState, (state) => dotNotationToObject(state, keyOrMapFn));
1628
+ break;
1629
+ }
1630
+ }
1631
+ return this.store.select(selector);
1850
1632
  }
1851
- return (Object.keys(app)
1852
- // select keys that are present in the allowed list
1853
- .filter((key) => !disallowedKeys.includes(key))
1854
- // build a new object with only the allowed properties
1855
- .reduce((obj, key) => {
1856
- obj[key] = app[key];
1857
- return obj;
1858
- }, {}));
1859
- };
1860
- /**
1861
- *
1862
- * @param storageType
1863
- */
1864
- const loadState = (storage = localStorage) => {
1865
- try {
1866
- // by default falls back to localStorage
1867
- const serializedState = storage.getItem('state');
1868
- if (serializedState === null) {
1869
- return undefined;
1633
+ updateState(langState) {
1634
+ this.updateHTMLDOMLang(langState.activeLang);
1635
+ this.store.dispatch(new UpdateI18nStateAction(langState));
1636
+ }
1637
+ init(langState) {
1638
+ const initLang = langState && langState.activeLang ? langState.activeLang : this.preparedDefaultLanguage();
1639
+ const initState = {
1640
+ ...langState,
1641
+ activeLang: initLang,
1642
+ };
1643
+ if (typeof initLang === 'string') {
1644
+ super.initEuiService(this.store);
1645
+ this.updateState(initState);
1646
+ return this.setup(initLang);
1870
1647
  }
1871
- // deserialize state
1872
- let state = JSON.parse(serializedState);
1873
- // filter AppState and replace
1874
- state = { ...state, app: filterAppState(state?.app) };
1875
- return state;
1648
+ return of({ success: false, error: 'Initial active lang should be string' });
1876
1649
  }
1877
- catch (err) {
1878
- return undefined;
1650
+ /**
1651
+ * A pipe function that could serve as a wrapper of another observable
1652
+ * e.g. ngx-translate i18n.onReady('my_module').pipe(switchMap(()=>translate.get('eui.KEY')));
1653
+ * WARNING: onReady will emit only once for a loaded Module, going to another and then going back will not result
1654
+ * into another emission.
1655
+ *
1656
+ * @param moduleName the name of the module that has been given through the eUI globalConfig. In case non provided
1657
+ * fetch module name from the state.
1658
+ */
1659
+ onReady(moduleName) {
1660
+ return this.onModuleLoad.pipe(switchMap((evt) => moduleName
1661
+ ? of(evt)
1662
+ : this.store.select(getLastAddedModule).pipe(tap((m) => (moduleName = m)), map(() => evt))),
1663
+ // emit only if event emitted matches the module name and is ready
1664
+ filter((evt) => evt.ready === true && evt.name === moduleName),
1665
+ // make sure that observable completes
1666
+ take(1));
1879
1667
  }
1880
- };
1881
- const cb = (reducer, storage) => function (state, action) {
1882
- if (action.type === CoreAppActionTypes.INIT_STORE) {
1883
- // This action must be dispatched from an app initializer
1884
- // We load the state from a storage and compare the version and userId with the provided ones.
1885
- // If they are the same, we merge the local state into the initial state.
1886
- // If there is a mismatch, we don't merge the local state, but update only the initial state.
1887
- // load the state from the localStorage
1888
- const localState = loadState(storage);
1889
- // extract the details about user and app version from the action payload
1890
- const payload = action.payload;
1891
- const payloadVersion = payload?.version;
1892
- if (localState) {
1893
- // TODO: Why all these checks here? What is the purpose of this code?
1894
- // extract the details about user and app version from the storage state
1895
- const localVersion = localState?.app?.version;
1896
- // const localUserId = localState.user && localState.user.userId;
1897
- const isVersionOK = !localVersion || !payloadVersion || localVersion === payloadVersion;
1898
- // const isUserIdOK = (localUserId === payloadUserId);
1899
- // update the entire state with deep merge of states, if the version and user are the same
1900
- if (isVersionOK) {
1901
- state = extend(true, {}, state, localState);
1668
+ lazyLoad(config) {
1669
+ const moduleId = Math.floor(Math.random() * 100000 + 1).toLocaleString();
1670
+ return this.addResources(config, moduleId);
1671
+ }
1672
+ lazyLoadInit(moduleConfig, moduleName) {
1673
+ const i18nLoaderConfig = moduleConfig;
1674
+ // add resources
1675
+ return this.addResources(i18nLoaderConfig, moduleName);
1676
+ }
1677
+ /**
1678
+ * Add resources based of a config loader
1679
+ *
1680
+ * @param config I18nLoaderConfig
1681
+ * @return Promise<EuiServiceStatus> an EuiServiceStatus when translation has fully loaded
1682
+ */
1683
+ addResources(config, moduleName) {
1684
+ // emit that module is loading
1685
+ this.onModuleLoad.next({ ready: false, name: moduleName });
1686
+ const loader = this.translateService.currentLoader;
1687
+ if (loader instanceof I18nLoader) {
1688
+ const langSubscription = [];
1689
+ const i18nLoader = loader;
1690
+ // add the resources to the loader
1691
+ const resources = i18nLoader.addResources(config);
1692
+ // manually load the resources for the CURRENT language and add them to the translate service
1693
+ langSubscription.push(i18nLoader.loadResources(resources, this.translateService.currentLang).pipe(take(1), tap((loadedResources) => {
1694
+ // add the new set of translations to the current language
1695
+ this.translateService.setTranslation(this.translateService.currentLang, loadedResources.translations, true);
1696
+ })));
1697
+ // if the current language is different than the DEFAULT language
1698
+ const defaultLang = this.config.defaultLanguage || this.translateService.defaultLang;
1699
+ if (this.translateService.currentLang !== defaultLang) {
1700
+ // manually load the resources for the default language and add them to the translate service
1701
+ langSubscription.push(i18nLoader.loadResources(resources, defaultLang).pipe(take(1), tap((loadedResources) => {
1702
+ this.translateService.setTranslation(defaultLang, loadedResources.translations, true);
1703
+ })));
1902
1704
  }
1705
+ return forkJoin(langSubscription).pipe(map((loadedResourcesArr) => !loadedResourcesArr[0].hasError ? { success: true } : { success: false, error: loadedResourcesArr[0].errors }), tap(() => {
1706
+ // emit status of module loading progress
1707
+ this.onModuleLoad.next({ ready: true, name: moduleName });
1708
+ }), catchError((error) => {
1709
+ // emit status of module loading progress
1710
+ this.onModuleLoad.next({ ready: true, name: moduleName, error });
1711
+ return of({ success: false, error });
1712
+ }));
1903
1713
  }
1904
- // update the app version, if defined
1905
- if (payloadVersion) {
1906
- state = { ...state, app: { ...state?.app, version: payloadVersion } };
1714
+ else {
1715
+ return of({ success: false, error: 'currentLoader is not an I18nLoader.' });
1907
1716
  }
1908
1717
  }
1909
- return reducer(state, action);
1910
- };
1911
-
1912
- class StoreServiceMock extends StoreService {
1913
- constructor() {
1914
- super(null, null);
1915
- }
1916
- init() { }
1917
- addAutoSaveHandler() { }
1918
- handleAutoSave() { }
1919
- dispatch() { }
1920
- select() {
1921
- return of({});
1718
+ /**
1719
+ * Prepares the default language
1720
+ */
1721
+ preparedDefaultLanguage() {
1722
+ const browserPref = getBrowserDefaultLanguage();
1723
+ // If user has browser preferred lang, and that language is part of the languages array
1724
+ if (browserPref && this.config.languages && EuiEuLanguages.getLanguageCodes(this.config.languages).includes(browserPref)) {
1725
+ return browserPref;
1726
+ }
1727
+ return this.config.defaultLanguage;
1922
1728
  }
1923
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: StoreServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1924
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: StoreServiceMock }); }
1925
- }
1926
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: StoreServiceMock, decorators: [{
1927
- type: Injectable
1928
- }], ctorParameters: function () { return []; } });
1929
-
1930
- const CORE_ROOT_GUARD = new InjectionToken('Internal Theme ForRoot Guard');
1931
- class CoreModule {
1932
1729
  /**
1933
- * No more providing config from forRoot, you have to use EUI_CONFIG_TOKEN to pass config via providers.
1730
+ * @param default_language if given default language to override default language coming from the
1731
+ * configuration token.
1934
1732
  */
1935
- static forRoot() {
1936
- return {
1937
- ngModule: CoreModule,
1938
- providers: [
1939
- {
1940
- provide: EuiCoreRootGuardClass,
1941
- useFactory: euiCoreRootGuardClass,
1942
- deps: [],
1943
- },
1944
- {
1945
- provide: CORE_ROOT_GUARD,
1946
- useFactory: createEuiCoreRootGuard,
1947
- deps: [[EuiCoreRootGuardClass, new Optional(), new SkipSelf()]],
1948
- },
1949
- ...getCoreProviders(),
1950
- ],
1951
- };
1733
+ setup(initLanguage) {
1734
+ // use the default config as a reference base
1735
+ this.config = Object.assign({}, DEFAULT_I18N_SERVICE_CONFIG, this.config);
1736
+ // configure the translate config service
1737
+ if (this.config.languages) {
1738
+ this.translateService.addLangs(EuiEuLanguages.getLanguageCodes(this.config.languages));
1739
+ if (this.logService) {
1740
+ this.logService.info(`I18n accepted languages set to ${EuiEuLanguages.getLanguageCodes(this.config.languages)}`);
1741
+ }
1742
+ }
1743
+ // set the current language, causing to load translations
1744
+ return this.translateService.use(initLanguage).pipe(tap(() => {
1745
+ this.bindActiveLangStateToTranslateService();
1746
+ this.bindTranslateServiceLangChangeToState();
1747
+ if (this.config.defaultLanguage) {
1748
+ this.setDefaultLanguage(this.config.defaultLanguage);
1749
+ }
1750
+ }), map(() => {
1751
+ if (this.translateService.currentLoader instanceof I18nLoader) {
1752
+ const failedResources = this.translateService.currentLoader.getFailedResources();
1753
+ if (failedResources.length > 0) {
1754
+ return { success: false, error: failedResources };
1755
+ }
1756
+ }
1757
+ return { success: true };
1758
+ }), catchError((error) => of({ success: false, error })));
1952
1759
  }
1953
- static forChild(moduleName) {
1954
- return {
1955
- ngModule: CoreModule,
1956
- providers: getCoreChildProviders(moduleName),
1957
- };
1760
+ bindActiveLangStateToTranslateService() {
1761
+ this.store.select(getActiveLang).subscribe((lang) => {
1762
+ if (lang !== null && this.translateService.currentLang !== lang) {
1763
+ this.use(lang);
1764
+ }
1765
+ });
1958
1766
  }
1959
- constructor(guard, parentModule, injector) {
1960
- // if there is a parentModule, a new instance is created in a lazy loaded module
1961
- if (parentModule) {
1962
- // extract the i18n service and the i18n loader config
1963
- // todo, this thing should be achieved by store, and localization service dependency should be removed
1964
- const storeService = injector.get(StoreService);
1965
- const moduleName = injector.get(MODULE_NAME_TOKEN);
1966
- const moduleConfig = injector.get(MODULE_CONFIG_TOKEN);
1967
- storeService.dispatch(new AddAppLoadedConfigModulesAction({ moduleName, moduleConfig }));
1767
+ bindTranslateServiceLangChangeToState() {
1768
+ this.translateService.onLangChange.subscribe((event) => {
1769
+ if (this.stateInstance.activeLang !== event.lang) {
1770
+ this.updateState({ activeLang: event.lang });
1771
+ }
1772
+ if (this.logService) {
1773
+ this.logService.info(`I18n current language set to ${event.lang}`);
1774
+ }
1775
+ });
1776
+ }
1777
+ setDefaultLanguage(defaultLanguage) {
1778
+ // removed, current language is already calculated in init, setup function fill use it directly, not default
1779
+ // this.translateService.currentLang = default_language || this.config.defaultLanguage;
1780
+ this.translateService.setDefaultLang(defaultLanguage);
1781
+ if (this.logService) {
1782
+ this.logService.info(`I18n default language set to ${defaultLanguage}`);
1968
1783
  }
1969
1784
  }
1970
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CoreModule, deps: [{ token: CORE_ROOT_GUARD, optional: true }, { token: CoreModule, optional: true, skipSelf: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule }); }
1971
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.5", ngImport: i0, type: CoreModule }); }
1972
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CoreModule }); }
1785
+ /**
1786
+ * change the currently used language
1787
+ *
1788
+ * @param lang is the language code based on the convention you used e.g. (en or en-EN)
1789
+ * @returns Observable that returns an object contain the object translation for given language after language
1790
+ * fully loaded.
1791
+ */
1792
+ use(lang) {
1793
+ return this.translateService.use(lang);
1794
+ }
1795
+ /**
1796
+ * updates the HTML element lang attribute
1797
+ *
1798
+ * @private
1799
+ */
1800
+ updateHTMLDOMLang(lang) {
1801
+ this.document.documentElement.lang = lang;
1802
+ }
1803
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i1$3.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1804
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nService, providedIn: 'root' }); }
1973
1805
  }
1974
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CoreModule, decorators: [{
1975
- type: NgModule,
1806
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nService, decorators: [{
1807
+ type: Injectable,
1976
1808
  args: [{
1977
- imports: [
1978
- // HttpClientModule, no more..
1979
- ],
1809
+ providedIn: 'root',
1980
1810
  }]
1981
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1982
- type: Optional
1983
- }, {
1811
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1984
1812
  type: Inject,
1985
- args: [CORE_ROOT_GUARD]
1986
- }] }, { type: CoreModule, decorators: [{
1813
+ args: [GLOBAL_CONFIG_TOKEN]
1814
+ }] }, { type: i1$3.TranslateService }, { type: LogService, decorators: [{
1987
1815
  type: Optional
1988
- }, {
1989
- type: SkipSelf
1990
- }] }, { type: i0.Injector }]; } });
1991
- const createEuiCoreRootGuard = (core) => {
1992
- if (core) {
1993
- throw new TypeError(`CoreModule.forRoot() called twice. Feature modules should use ThemeModule.forChild() instead.`);
1816
+ }] }, { type: StoreService }, { type: Document, decorators: [{
1817
+ type: Inject,
1818
+ args: [DOCUMENT]
1819
+ }] }] });
1820
+
1821
+ class I18nServiceMock extends I18nService {
1822
+ constructor() {
1823
+ super(null, null, null, null, null);
1824
+ this.DEFAULT_LANGUAGE = 'en';
1994
1825
  }
1995
- return 'guarded';
1996
- };
1997
- class EuiCoreRootGuardClass {
1998
- constructor() { }
1826
+ get onLangChange() {
1827
+ return new EventEmitter();
1828
+ }
1829
+ addResources() {
1830
+ return of({ success: true });
1831
+ }
1832
+ get currentLanguage() {
1833
+ return this.DEFAULT_LANGUAGE;
1834
+ }
1835
+ getState() {
1836
+ return of({ activeLang: this.DEFAULT_LANGUAGE });
1837
+ }
1838
+ updateState(i18nState) {
1839
+ this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
1840
+ }
1841
+ init(i18nState) {
1842
+ this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
1843
+ return of({ success: true });
1844
+ }
1845
+ lazyLoadInit() {
1846
+ return of({ success: true });
1847
+ }
1848
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1849
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nServiceMock }); }
1999
1850
  }
2000
- const euiCoreRootGuardClass = () => new EuiCoreRootGuardClass();
1851
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: I18nServiceMock, decorators: [{
1852
+ type: Injectable
1853
+ }], ctorParameters: () => [] });
1854
+
1855
+ const diffDays = (dateStart, dateEnd) => Math.round((dateEnd.getTime() - dateStart.getTime()) / 1000 / 60 / 60 / 24);
1856
+ const diffDaysFromToday = (date) => diffDays(new Date(), date);
2001
1857
 
2002
1858
  /**
2003
- * Function to be used before the AppModule is bootstrapped. It is currently used to load dynamic configurations.
2004
- * It needs to be added in your application main.ts file.
2005
- * @param envConfig the current environment configuration
2006
- * @returns the updated environment configuration, as a promise
1859
+ * Provides read-only equivalent of jQuery's position function:
1860
+ * http://api.jquery.com/position/
2007
1861
  */
2008
- async function preInitApp(envConfig) {
2009
- const envDynamicConfig = envConfig && envConfig.envDynamicConfig;
2010
- if (envDynamicConfig) {
2011
- // load the local configuration file, if defined
2012
- const euiAppJsonConfig = await loadEuiDynamicEnvironmentConfig(envDynamicConfig.uri, envDynamicConfig.configTimeout || 2000);
2013
- envConfig.loadedEnvDynamicConfig = euiAppJsonConfig;
2014
- return envConfig;
1862
+ const position = (nativeEl) => {
1863
+ let elBCR = offset(nativeEl);
1864
+ let offsetParentBCR = { top: 0, left: 0 };
1865
+ let offsetParentEl = parentOffsetEl(nativeEl);
1866
+ if (offsetParentEl !== document) {
1867
+ offsetParentBCR = offset(offsetParentEl);
1868
+ offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
1869
+ offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
2015
1870
  }
2016
- return envConfig;
2017
- }
1871
+ let boundingClientRect = nativeEl.getBoundingClientRect();
1872
+ return {
1873
+ width: boundingClientRect.width || nativeEl.offsetWidth,
1874
+ height: boundingClientRect.height || nativeEl.offsetHeight,
1875
+ top: elBCR.top - offsetParentBCR.top,
1876
+ left: elBCR.left - offsetParentBCR.left,
1877
+ };
1878
+ };
2018
1879
  /**
2019
- * Function to load asynchronously a dynamic configuration (from a local path or a web service)
2020
- *
2021
- * @param url the path to the configuration
2022
- * @param timeout possible timeout
2023
- * @returns EuiAppJsonConfig promise
1880
+ * Provides read-only equivalent of jQuery's offset function:
1881
+ * http://api.jquery.com/offset/
2024
1882
  */
2025
- async function loadEuiDynamicEnvironmentConfig(url, timeout) {
2026
- // if the url is specified
2027
- if (url) {
2028
- // fetch the config
2029
- try {
2030
- return await xhr({
2031
- url,
2032
- timeout,
2033
- });
1883
+ const offset = (nativeEl) => {
1884
+ let boundingClientRect = nativeEl.getBoundingClientRect();
1885
+ return {
1886
+ width: boundingClientRect.width || nativeEl.offsetWidth,
1887
+ height: boundingClientRect.height || nativeEl.offsetHeight,
1888
+ top: boundingClientRect.top + (window.pageYOffset || document.documentElement.scrollTop),
1889
+ left: boundingClientRect.left + (window.pageXOffset || document.documentElement.scrollLeft),
1890
+ };
1891
+ };
1892
+ // PRIVATE FUNCTIONS
1893
+ const getStyle = (nativeEl, cssProp) => {
1894
+ // IE
1895
+ if (nativeEl.currentStyle) {
1896
+ return nativeEl.currentStyle[cssProp];
1897
+ }
1898
+ if (window.getComputedStyle) {
1899
+ return window.getComputedStyle(nativeEl)[cssProp];
1900
+ }
1901
+ // finally try and get inline style
1902
+ return nativeEl.style[cssProp];
1903
+ };
1904
+ /**
1905
+ * Checks if a given element is statically positioned
1906
+ */
1907
+ const isStaticPositioned = (nativeEl) => (getStyle(nativeEl, 'position') || 'static') === 'static';
1908
+ /**
1909
+ * returns the closest, non-statically positioned parentOffset of a given element
1910
+ * @param nativeEl
1911
+ */
1912
+ const parentOffsetEl = (nativeEl) => {
1913
+ let offsetParent = nativeEl.offsetParent || document;
1914
+ while (offsetParent && offsetParent !== document && isStaticPositioned(offsetParent)) {
1915
+ offsetParent = offsetParent.offsetParent;
1916
+ }
1917
+ return offsetParent || document;
1918
+ };
1919
+ const getViewElement = (fixture, componentClass, klass) => {
1920
+ let de, el, domElement;
1921
+ de = fixture.debugElement.query(By.css(componentClass));
1922
+ if (de) {
1923
+ el = de.nativeElement;
1924
+ if (el && klass) {
1925
+ domElement = el.querySelectorAll(klass);
1926
+ if (domElement.length <= 1) {
1927
+ domElement = el.querySelector(klass);
1928
+ }
2034
1929
  }
2035
- catch (error) {
2036
- // send a warning to the console
2037
- console.warn('Dynamic configuration cannot be loaded from url', url, error);
1930
+ }
1931
+ return { de, el, domElement };
1932
+ };
1933
+ const closestMatchingParent = (target, className) => {
1934
+ let element = target;
1935
+ while (element && element.nodeType === Node.ELEMENT_NODE) {
1936
+ if (element.classList.contains(className)) {
1937
+ return element;
2038
1938
  }
1939
+ element = element.parentElement;
2039
1940
  }
2040
- // the dynamic config is not loaded
2041
1941
  return null;
2042
- }
1942
+ };
2043
1943
 
2044
- const errorCodes = {
2045
- ERR_GENERIC: 'ERR_GENERIC',
1944
+ const consumeEvent = (event) => {
1945
+ if (event) {
1946
+ event.preventDefault();
1947
+ event.stopPropagation();
1948
+ event.cancelBubble = true;
1949
+ }
1950
+ return false;
2046
1951
  };
2047
- const messages = {
2048
- ERR_GENERIC: 'An error occured',
1952
+
1953
+ const forOwn = (object, iteratee) => {
1954
+ object = Object(object);
1955
+ Object.keys(object).forEach((key) => iteratee(object[key], key, object));
2049
1956
  };
2050
- class ErrorSubClass {
2051
- constructor(code, msg, args) {
2052
- if (!msg && code && code in messages) {
2053
- if (typeof messages[code] === 'function') {
2054
- msg = messages[code](...args.messageParams);
1957
+ const markFormGroupTouched = (FormControls) => {
1958
+ const markFormGroupTouchedRecursive = (controls) => {
1959
+ forOwn(controls, (c) => {
1960
+ if (c instanceof FormGroup || c instanceof FormArray) {
1961
+ markFormGroupTouchedRecursive(c.controls);
1962
+ }
1963
+ else {
1964
+ c.markAsTouched();
1965
+ c.updateValueAndValidity();
1966
+ }
1967
+ });
1968
+ };
1969
+ markFormGroupTouchedRecursive(FormControls);
1970
+ };
1971
+ const markControlsTouched = (group) => {
1972
+ Object.keys(group.controls).forEach((key) => {
1973
+ const abstractControl = group.controls[key];
1974
+ if (abstractControl instanceof FormGroup || abstractControl instanceof FormArray) {
1975
+ markControlsTouched(abstractControl);
1976
+ }
1977
+ else {
1978
+ abstractControl.markAsTouched();
1979
+ }
1980
+ });
1981
+ };
1982
+ const validateEmail = (c) => {
1983
+ const EMAIL_REGEXP =
1984
+ // eslint-disable-next-line max-len, no-useless-escape
1985
+ /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1986
+ const error = {
1987
+ validateEmail: {
1988
+ valid: false,
1989
+ },
1990
+ };
1991
+ return EMAIL_REGEXP.test(c.value) ? null : error;
1992
+ };
1993
+
1994
+ /**
1995
+ * returns a random string with radix=36
1996
+ */
1997
+ const uniqueId = () => Math.random().toString(36).substr(2, 9);
1998
+ /**
1999
+ * Its job is to parse number and format it based on given input.
2000
+ * @param value can be a number or a string number
2001
+ * @param fractionSize size of fraction of a number e.g. 1000.88 fraction is 2 (88) default is 2
2002
+ * @param inDecimalSeparator separator for decimal part of the number default is ','
2003
+ * @param inThousandSeparator separator for the whole part of the number default is ''
2004
+ */
2005
+ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThousandSeparator = '') => {
2006
+ if (inDecimalSeparator || inThousandSeparator) {
2007
+ console.warn('The inDecimalSeparator and inThousandSeparator are deprecated. They will be a ' +
2008
+ 'BREAKING CHANGE for eUI 9 and be replaced by localization strategy.');
2009
+ }
2010
+ let decimalSeparator = '';
2011
+ let thousandsSeparator = '';
2012
+ if (value === null || value === undefined) {
2013
+ return null;
2014
+ }
2015
+ if (typeof value === 'string') {
2016
+ // get all non characters
2017
+ let nonChars = value.match(/[^0-9]+/g) || [];
2018
+ // get all unique chars
2019
+ let uniqueChars = nonChars.reduce((acc, e) => acc.set(e, (acc.get(e) || 0) + 1), new Map());
2020
+ // get separators
2021
+ let separators = Array.from(uniqueChars.keys());
2022
+ // sense where decimal separator and where thousand separator is
2023
+ if (separators.length > 1) {
2024
+ // left detected separator will be thousand and second will be decimal
2025
+ thousandsSeparator = separators[0];
2026
+ decimalSeparator = separators[1];
2027
+ }
2028
+ else if (separators.length > 0) {
2029
+ // in case there is only one separator you don't know exactly who this separator is.
2030
+ // in case there are more than two occurrences means we have a thousand otherwise we'll
2031
+ // agree by conventions that is decimal
2032
+ if (nonChars.length > 1) {
2033
+ return value
2034
+ .split(separators[0])
2035
+ .join('')
2036
+ .replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2055
2037
  }
2056
2038
  else {
2057
- msg = messages[code];
2039
+ return value.replace(separators[0], inDecimalSeparator).replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2058
2040
  }
2059
2041
  }
2060
- this.name = 'ErrorSubClass';
2061
- this.message = msg;
2062
- this.code = code;
2063
- this.stack = new Error(msg).stack;
2064
- if (args) {
2065
- Object.keys(args).forEach((k) => {
2066
- if (k !== 'messageParams') {
2067
- this[k] = args[k];
2068
- }
2069
- });
2042
+ else {
2043
+ // in case there are no separators then only format based on thousand one
2044
+ return value.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2070
2045
  }
2046
+ // do the replacement of separators and parseInt
2047
+ // Beware! Always replace thousand separator first and then decimal
2048
+ value = value.split(thousandsSeparator).join('').replace(decimalSeparator, '.');
2071
2049
  }
2072
- }
2073
- // This replaces the "extends" on the Class
2074
- // ErrorSubClass.prototype = <any>Object.create(Error.prototype);
2075
- class EuiError extends ErrorSubClass {
2076
- constructor(code = errorCodes.ERR_GENERIC, msg, args) {
2077
- super(code, msg, args);
2078
- this.name = 'EuiError';
2079
- }
2080
- }
2050
+ decimalSeparator = inDecimalSeparator;
2051
+ thousandsSeparator = inThousandSeparator;
2052
+ const maxFraction = '0'.repeat(fractionSize);
2053
+ let [integer, fraction = maxFraction] = (value || '0').toString().split('.');
2054
+ fraction = fractionSize > 0 ? (fraction + maxFraction).substring(0, fractionSize) : '';
2055
+ // this rule makes sense only in number in case fraction is all zero
2056
+ fraction = typeof value === 'number' && fraction === maxFraction ? '' : decimalSeparator + fraction;
2057
+ return integer.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator) + fraction;
2058
+ };
2081
2059
 
2082
- class GlobalErrorHandler extends ErrorHandler {
2083
- constructor(logService) {
2084
- super();
2085
- this.logService = logService;
2086
- }
2087
- handleError(error) {
2088
- // log error
2089
- this.logService.error(error.message || error.toString());
2090
- // throw error;
2091
- super.handleError(error);
2092
- }
2093
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: GlobalErrorHandler, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2094
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: GlobalErrorHandler, providedIn: 'root' }); }
2095
- }
2096
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: GlobalErrorHandler, decorators: [{
2097
- type: Injectable,
2098
- args: [{
2099
- providedIn: 'root',
2100
- }]
2101
- }], ctorParameters: function () { return [{ type: LogService }]; } });
2060
+ const handleError = (error) => {
2061
+ let errMsg = error.message ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error';
2062
+ // console.error(errMsg);
2063
+ return throwError(errMsg);
2064
+ };
2102
2065
 
2103
- class HttpErrorHandlerInterceptor {
2104
- constructor(config = DEFAULT_HTTP_ERROR_HANDLER_CONFIG, injector, router) {
2105
- this.config = config;
2106
- this.injector = injector;
2107
- this.router = router;
2108
- }
2109
- intercept(req, next) {
2110
- return next.handle(req).pipe(tap(() => { }, (error) => {
2111
- // in case of http error
2112
- if (error instanceof HttpErrorResponse) {
2113
- const routeConfig = this.getRouteConfig(error);
2114
- const rule = routeConfig && (routeConfig[error.status] || routeConfig.default);
2115
- if (typeof rule === 'string') {
2116
- // perform a redirect
2117
- this.router.navigate([rule]);
2118
- }
2119
- else if (typeof rule === 'function') {
2120
- // callback function
2121
- rule.call(null, error, this.injector);
2122
- }
2123
- }
2124
- }));
2066
+ /**
2067
+ * check if a value is null or undefined. If it's not both returns true otherwise false
2068
+ *
2069
+ * @param value
2070
+ */
2071
+ const isDefined = (value) => value !== undefined && value !== null;
2072
+
2073
+ class EuiPermissionService extends EuiService {
2074
+ constructor(log, store) {
2075
+ super([]);
2076
+ this.log = log;
2077
+ this.store = store;
2078
+ if (log) {
2079
+ this.logger = log.getLogger('core.PermissionService');
2080
+ }
2125
2081
  }
2126
2082
  /**
2127
- * Search in the configuration for the first matching route
2128
- *
2129
- * @param error http error response
2130
- * @returns HttpErrorRouteConfig or null
2083
+ * initialize the service by providing a state
2084
+ * @param rights
2131
2085
  */
2132
- getRouteConfig(error) {
2133
- // filter the routes
2134
- const routes = this.config.routes.filter((route) => {
2135
- const regex = new RegExp('^' + route.path.split('*').join('.*') + '$');
2136
- return regex.test(error.url) && (typeof route[error.status] !== 'undefined' || typeof route.default !== 'undefined');
2137
- });
2138
- // return the first matching route, if any
2139
- return routes.length > 0 ? routes[0] : null;
2086
+ init(rights) {
2087
+ super.initEuiService();
2088
+ if (Array.isArray(rights)) {
2089
+ this.updateState(rights);
2090
+ return of({ success: true });
2091
+ }
2092
+ if (this.logger) {
2093
+ this.logger.error('Init object should be instance of BaseUserState');
2094
+ }
2095
+ return of({ success: false, error: 'Init object should be instance of BaseUserState' });
2140
2096
  }
2141
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: HttpErrorHandlerInterceptor, deps: [{ token: HTTP_ERROR_HANDLER_CONFIG_TOKEN }, { token: i0.Injector }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
2142
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: HttpErrorHandlerInterceptor }); }
2143
- }
2144
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: HttpErrorHandlerInterceptor, decorators: [{
2145
- type: Injectable
2146
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2147
- type: Inject,
2148
- args: [HTTP_ERROR_HANDLER_CONFIG_TOKEN]
2149
- }] }, { type: i0.Injector }, { type: i2$1.Router }]; } });
2150
-
2151
- // import { UxAppShellService } from '../ux-app-shell.service';
2152
- function AlertHttpErrorCallbackFn(error) {
2153
- alert(error.statusText);
2154
- }
2155
- function ConsoleHttpErrorCallbackFn(error) {
2156
- console.error('HttpError', error);
2157
- }
2158
- function LogHttpErrorCallbackFn(error, injector) {
2159
- const logService = injector.get(LogService);
2160
- logService.error('HttpError', error);
2161
- }
2162
- function GrowlHttpErrorCallbackFn(error, injector) {
2163
- // TODO v17 should not display growl from here but from where it's called
2164
- // const asService = injector.get(UxAppShellService);
2165
- // asService.growlError(error.statusText);
2166
- }
2167
-
2168
- class ApiQueueService {
2169
- constructor(store, http, logService) {
2170
- this.store = store;
2171
- this.http = http;
2172
- this.logService = logService;
2097
+ get userRights() {
2098
+ return this.stateInstance;
2173
2099
  }
2174
2100
  /**
2175
- * Adds an item in the queue by dispatching an action to the store.
2176
- * @param id - The id of the item inside the queue.
2177
- * WARNING if matches any other queue item id will overwrite it.
2178
- * @param item - an item for Queue
2101
+ * get the user's Rights from the state
2179
2102
  */
2180
- addQueueItem(id, item) {
2181
- const allowedMethods = ['post', 'put', 'get'];
2182
- if (allowedMethods.indexOf(item.method) < 0) {
2183
- throw new Error(`[ApiQueue] method "${item.method}" is not allowed`);
2184
- }
2185
- this.store.dispatch(new AddApiQueueItemAction({ id, item }));
2103
+ getState() {
2104
+ return this.store.select(getUserRights);
2186
2105
  }
2187
2106
  /**
2188
- * Subscribes to the store to retrieve queue and then converts the queue object to an array of items.
2189
- * @return An Observable of array of all items inside the current queue (ApiQueueItem[])
2107
+ * update the state with the given user's rights
2108
+ * @param rights
2190
2109
  */
2191
- getQueue() {
2192
- return this.store.select(getApiQueue).pipe(take(1), map((queue) => {
2193
- const queueArray = queue && Object.values(queue);
2194
- if (!queueArray || queueArray.length < 1) {
2195
- this.logService.warn('No items in the queue exist.');
2196
- }
2197
- return queueArray;
2198
- }));
2110
+ updateState(rights) {
2111
+ this.store.dispatch(new UpdateUserRightsAction(rights || []));
2199
2112
  }
2200
2113
  /**
2201
- * Subscribes to the store to retrieve an item from the queue.
2202
- * @param id - id of the item inside the queue
2203
- * @return An Observable of ApiQueueItem type
2114
+ * accepts a string of right and or a permission. In string first comes the right and or followed by permission in
2115
+ * a dot separated way e.g. 'RIGHT.PERMISSION' or 'RIGHT'. The string can contain more that 2 separated fields.
2116
+ * In that case the last field should be the permission and all the others a Right. e.g. 'RIGHT1.RIGHT2.PERMISSION'
2117
+ * The last part is useful where you want a user to have multiple rights and the permission of the last right.
2118
+ * @param rightsAndPermission
2204
2119
  */
2205
- getQueueItem(id) {
2206
- return this.store.select(getApiQueueItem(id)).pipe(take(1), map((queue) => {
2207
- if (!queue) {
2208
- this.logService.warn(`Queue item with id "${id}" does not exist`);
2209
- return null;
2120
+ checkAttributePermission(rightsAndPermission) {
2121
+ const permProps = rightsAndPermission.split('.');
2122
+ const rightId = permProps[0];
2123
+ const hasRight = this.checkRight(rightId);
2124
+ if (hasRight) {
2125
+ if (permProps.length === 2) {
2126
+ // in case of 'RIGHT.PERMISSION'
2127
+ const permission = permProps[1];
2128
+ return this.checkPermission(rightId, permission);
2210
2129
  }
2211
- return queue;
2212
- }));
2130
+ else if (permProps.length > 2) {
2131
+ // in case of 'RIGHT1.RIGHT2.....PERMISSION' string call recursively
2132
+ return this.checkAttributePermission(rightsAndPermission.slice(rightId.length + 1));
2133
+ }
2134
+ }
2135
+ return hasRight;
2213
2136
  }
2214
2137
  /**
2215
- * Removes a given item from the queue.
2216
- * @param id - id of the item inside the queue
2138
+ * check if a user has the right.
2139
+ * @param rightId the id of Right
2217
2140
  */
2218
- removeQueueItem(id) {
2219
- this.store.dispatch(new RemoveApiQueueItemAction(id));
2141
+ checkRight(rightId) {
2142
+ return this.userRights.some((right) => right && right.id === rightId);
2220
2143
  }
2221
2144
  /**
2222
- * Removes all items placed in the queue.
2145
+ * check if a user has that right and that right has the permission given.
2146
+ * @param rightId the right of the user
2147
+ * @param permission the permission of the right
2223
2148
  */
2224
- removeAllQueueItem() {
2225
- this.store.dispatch(new EmptyApiQueueAction(null));
2149
+ checkPermission(rightId, permission) {
2150
+ // the user has to have that right and that right has to have the given permission
2151
+ return this.userRights.some((right) => right && right.id === rightId && right.permissions && right.permissions.includes(permission));
2226
2152
  }
2227
2153
  /**
2228
- * Process an item from the queue.
2229
- * @param id - id of the item inside the queue
2230
- * @return An Observable of type any
2154
+ * checks whether a user have all rights passed as an argument
2155
+ * @param rights an array of EuiUserRight
2231
2156
  */
2232
- processQueueItem(id) {
2233
- return this.store.select(getApiQueueItem(id)).pipe(take(1), switchMap((queue) => {
2234
- if (!queue) {
2235
- this.logService.warn(`Queue item with id "${id}" does not exist`);
2236
- return of(null);
2157
+ haveAllRights(rights) {
2158
+ if (!isDefined(rights)) {
2159
+ throw Error(`The rights should be an array but instead it's not defined!`);
2160
+ }
2161
+ return rights.every((right) => this.userRights.find((uRight) => uRight.id === right.id));
2162
+ }
2163
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiPermissionService, deps: [{ token: LogService, optional: true }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2164
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiPermissionService, providedIn: 'root' }); }
2165
+ }
2166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiPermissionService, decorators: [{
2167
+ type: Injectable,
2168
+ args: [{
2169
+ providedIn: 'root',
2170
+ }]
2171
+ }], ctorParameters: () => [{ type: LogService, decorators: [{
2172
+ type: Optional
2173
+ }] }, { type: StoreService }] });
2174
+
2175
+ class EuiDynamicMenuService {
2176
+ // TODO: it should be moved euiservice, or it should be static
2177
+ // TODO: can we moved that service inside the module of the component that's using it?
2178
+ constructor(euiPermission, store) {
2179
+ this.euiPermission = euiPermission;
2180
+ this.store = store;
2181
+ this.menuLinks = [];
2182
+ this.store.select(getUserState).subscribe((user) => {
2183
+ if (user.menuLinks) {
2184
+ this.menuLinks = user.menuLinks;
2237
2185
  }
2238
- return this.buildHttpRequest(id, queue);
2239
- }));
2186
+ });
2240
2187
  }
2241
- /**
2242
- * Process all the items inside the queue.
2243
- * @param [continueOnError=true] - in case of an item request fails continue with the rest in queue
2244
- * @return An Observable with an array which contains all responses from all items in queue.
2245
- */
2246
- processAllQueueItems(continueOnError = true) {
2247
- return this.store.select(getApiQueue).pipe(map((queue) => Object.entries(queue).map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
2248
- this.logService.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
2249
- if (!continueOnError) {
2250
- throw error;
2188
+ getMenuLinks() {
2189
+ return this.menuLinks;
2190
+ }
2191
+ filterEuiMenuItemsWithRights(links) {
2192
+ return links.filter((link) => {
2193
+ if (link.hasChildren) {
2194
+ link.children = this.filterEuiMenuItemsWithRights(link.children);
2251
2195
  }
2252
- return of(error);
2253
- })))), switchMap((obsQueue) => forkJoin(Array.from(obsQueue))));
2196
+ // First check if the user is denied access:
2197
+ if (link.deniedRightId) {
2198
+ if (this.euiPermission.checkRight(link.deniedRightId)) {
2199
+ return false;
2200
+ }
2201
+ }
2202
+ if (link.deniedRightIds) {
2203
+ for (const deniedRightId of link.deniedRightIds) {
2204
+ if (this.euiPermission.checkRight(deniedRightId)) {
2205
+ return false;
2206
+ }
2207
+ }
2208
+ }
2209
+ // Then check if the user needs to be allowed access explicitly:
2210
+ if (link.allowedRightId) {
2211
+ return this.euiPermission.checkRight(link.allowedRightId);
2212
+ }
2213
+ if (link.allowedRightIds) {
2214
+ for (const allowedRightId of link.allowedRightIds) {
2215
+ if (this.euiPermission.checkRight(allowedRightId)) {
2216
+ return true;
2217
+ }
2218
+ }
2219
+ // User doesn't have one of the allowed rights. Deny access:
2220
+ return false;
2221
+ }
2222
+ // Access to the menu item is not denied, therefore allow it:
2223
+ return true;
2224
+ });
2225
+ }
2226
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiDynamicMenuService, deps: [{ token: EuiPermissionService }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2227
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiDynamicMenuService, providedIn: 'root' }); }
2228
+ }
2229
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiDynamicMenuService, decorators: [{
2230
+ type: Injectable,
2231
+ args: [{
2232
+ providedIn: 'root',
2233
+ }]
2234
+ }], ctorParameters: () => [{ type: EuiPermissionService }, { type: StoreService }] });
2235
+
2236
+ const DYNAMIC_COMPONENT_CONFIG = new InjectionToken('DYNAMIC_COMPONENT_CONFIG');
2237
+ class EuiDynamicComponentService {
2238
+ constructor(componentFactoryResolver, injector, appRef) {
2239
+ this.componentFactoryResolver = componentFactoryResolver;
2240
+ this.injector = injector;
2241
+ this.appRef = appRef;
2254
2242
  }
2255
2243
  /**
2256
- * Process all items in queue after it order them based on their timestamp. Beware that order
2257
- * matter in execution of Http Request in queue. When a request completes only then next will begin. Emission
2258
- * or Http response follows order.
2259
- * @param [ascending=true] - sets the order of queue items based on timestamp
2244
+ * Adds a component to portal host dynamically
2245
+ * @param component The component to be injected
2246
+ * @param el The element reference for the component to be injected
2247
+ * @param config The data to be passed (config) for the DYNAMIC_COMPONENT_CONFIG token
2260
2248
  */
2261
- processAllQueueItemsSequential(ascending = true) {
2262
- return this.store.select(getApiQueue).pipe(concatMap((queue) => Object.entries(queue)
2263
- .sort((a, b) => (ascending ? this.sortOnTimestamp(a, b) : this.sortOnTimestamp(b, a)))
2264
- .map(([id, item]) => this.buildHttpRequest(id, item))));
2249
+ add(component, el, config) {
2250
+ // TODO: take a look and replace deprecated componentFactoryResolver https://github.com/angular/components/issues/24334
2251
+ // Create a portalHost from a DOM element
2252
+ this.portalHost = new DomPortalOutlet(el ? el.nativeElement : document.body, this.componentFactoryResolver, this.appRef, this.injector);
2253
+ // Locate the component factory for the ComponentToIncludeDynamicallyComponent
2254
+ this.portal = new ComponentPortal(component, null, config ? this.createInjector(config) : null);
2255
+ // Attach portal to host
2256
+ this.portalComponentInstance = this.portalHost.attach(this.portal);
2257
+ if (config) {
2258
+ Object.assign(config, {
2259
+ portalHostRef: this.portalHost,
2260
+ portalRef: this.portal,
2261
+ portalComponentInstanceRef: this.portalComponentInstance,
2262
+ });
2263
+ }
2264
+ return {
2265
+ portalHost: this.portalHost,
2266
+ portal: this.portal,
2267
+ portalComponentInstance: this.portalComponentInstance,
2268
+ };
2265
2269
  }
2266
2270
  /**
2267
- * Short dates ascending based on input
2268
- * @param a - Date one
2269
- * @param b - Date two
2270
- *
2271
- * @beta
2271
+ * detaches a portalHost
2272
+ * @param portalHostRef reference of portal host to be detached
2272
2273
  */
2273
- sortOnTimestamp(a, b) {
2274
- return +new Date(a[1].timestamp) - +new Date(b[1].timestamp);
2274
+ remove(portalHostRef) {
2275
+ portalHostRef.detach();
2276
+ this.portalHost = null;
2277
+ this.portal = null;
2278
+ this.portalComponentInstance = null;
2275
2279
  }
2276
2280
  /**
2277
- * build and HttpRequest Observable based on the given queue.
2278
- * After successful request completion removes the item from the queue.
2279
- * @param id - id of the item inside the queue
2280
- * @param item - the item of the queue that matches the id.
2281
- * @return An Observable of HttpClient Request
2281
+ * creates a custom injector to be used when providing custom injection tokens to components inside a portal
2282
+ * @param data to be used by DYNAMIC_COMPONENT_CONFIG token
2282
2283
  */
2283
- buildHttpRequest(id, item) {
2284
- return this.http[item.method.toLowerCase()](item.uri, item.payload).pipe(tap(() => this.removeQueueItem(id)));
2284
+ createInjector(data) {
2285
+ const injectorTokens = new WeakMap();
2286
+ injectorTokens.set(DYNAMIC_COMPONENT_CONFIG, data);
2287
+ return new PortalInjector(this.injector, injectorTokens);
2285
2288
  }
2286
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$2.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2287
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: ApiQueueService, providedIn: 'root' }); }
2289
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiDynamicComponentService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.Injector }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Injectable }); }
2290
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiDynamicComponentService }); }
2288
2291
  }
2289
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: ApiQueueService, decorators: [{
2290
- type: Injectable,
2291
- args: [{
2292
- providedIn: 'root',
2293
- }]
2294
- }], ctorParameters: function () { return [{ type: StoreService }, { type: i1$2.HttpClient }, { type: LogService }]; } });
2292
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiDynamicComponentService, decorators: [{
2293
+ type: Injectable
2294
+ }], ctorParameters: () => [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i0.ApplicationRef }] });
2295
2295
 
2296
- class ApiQueueServiceMock extends ApiQueueService {
2297
- constructor() {
2298
- super(null, null, null);
2296
+ const initialState = {
2297
+ appName: '',
2298
+ appShortName: '',
2299
+ appSubTitle: '',
2300
+ appBaseFontSize: '',
2301
+ userInfos: null,
2302
+ userSubInfos: null,
2303
+ impersonatedUserInfos: null,
2304
+ isSidebarOpen: true,
2305
+ isSidebarHover: false,
2306
+ isSidebarActive: false,
2307
+ isSidebarInnerActive: false,
2308
+ isSidebarStateCloseWithIcons: false,
2309
+ isSidebarExpandOnHover: true,
2310
+ hasSidebar: false,
2311
+ hasHeader: false,
2312
+ hasBreadcrumb: false,
2313
+ hasHeaderLogo: false,
2314
+ hasHeaderEnvironment: false,
2315
+ hasToolbar: false,
2316
+ hasToolbarMenu: false,
2317
+ environmentValue: '',
2318
+ isSidebarHidden: false,
2319
+ hasTopMessage: false,
2320
+ windowWidth: 0,
2321
+ windowHeight: 0,
2322
+ mainContentHeight: 0,
2323
+ pageHeaderHeight: 0,
2324
+ wrapperClasses: '',
2325
+ breakpoint: '',
2326
+ breakpoints: {
2327
+ isMobile: false,
2328
+ isTablet: false,
2329
+ isLtDesktop: false,
2330
+ isDesktop: false,
2331
+ isXL: false,
2332
+ isXXL: false,
2333
+ isFHD: false,
2334
+ is2K: false,
2335
+ is4K: false,
2336
+ },
2337
+ menuLinks: [],
2338
+ sidebarLinks: [],
2339
+ combinedLinks: [],
2340
+ isBlockDocumentActive: false,
2341
+ deviceInfo: null,
2342
+ activeLanguage: 'en',
2343
+ languages: EuiEuLanguages.getLanguages(),
2344
+ appMetadata: null,
2345
+ hasModalActive: false,
2346
+ isDimmerActive: false,
2347
+ };
2348
+ class EuiAppShellService {
2349
+ // -------------------
2350
+ get state$() {
2351
+ return this._state$.asObservable();
2299
2352
  }
2300
- getQueue() {
2301
- return of([]);
2353
+ // -------------------
2354
+ // exposed observables
2355
+ get breakpoint$() {
2356
+ return this._breakpoint$.asObservable();
2302
2357
  }
2303
- getQueueItem(id) {
2304
- return of(null);
2358
+ get breakpoints$() {
2359
+ return this._breakpoints$.asObservable();
2305
2360
  }
2306
- removeAllQueueItem() { }
2307
- processAllQueueItems() {
2308
- return of({});
2361
+ // ----------------
2362
+ // state operations
2363
+ // ----------------
2364
+ get state() {
2365
+ return this._state$.getValue();
2309
2366
  }
2310
- addQueueItem() { }
2311
- removeQueueItem() { }
2312
- processQueueItem() {
2313
- return of({});
2367
+ // ----------------------------
2368
+ // public setters and functions
2369
+ // ----------------------------
2370
+ set isSidebarOpen(isOpen) {
2371
+ this.setState({
2372
+ ...this.state,
2373
+ isSidebarOpen: isOpen,
2374
+ });
2314
2375
  }
2315
- }
2316
-
2317
- const diffDays = (dateStart, dateEnd) => Math.round((dateEnd.getTime() - dateStart.getTime()) / 1000 / 60 / 60 / 24);
2318
- const diffDaysFromToday = (date) => diffDays(new Date(), date);
2319
-
2320
- /**
2321
- * Provides read-only equivalent of jQuery's position function:
2322
- * http://api.jquery.com/position/
2323
- */
2324
- const position = (nativeEl) => {
2325
- let elBCR = offset(nativeEl);
2326
- let offsetParentBCR = { top: 0, left: 0 };
2327
- let offsetParentEl = parentOffsetEl(nativeEl);
2328
- if (offsetParentEl !== document) {
2329
- offsetParentBCR = offset(offsetParentEl);
2330
- offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
2331
- offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
2376
+ get isSidebarOpen() {
2377
+ return this.state.isSidebarOpen;
2332
2378
  }
2333
- let boundingClientRect = nativeEl.getBoundingClientRect();
2334
- return {
2335
- width: boundingClientRect.width || nativeEl.offsetWidth,
2336
- height: boundingClientRect.height || nativeEl.offsetHeight,
2337
- top: elBCR.top - offsetParentBCR.top,
2338
- left: elBCR.left - offsetParentBCR.left,
2339
- };
2340
- };
2341
- /**
2342
- * Provides read-only equivalent of jQuery's offset function:
2343
- * http://api.jquery.com/offset/
2344
- */
2345
- const offset = (nativeEl) => {
2346
- let boundingClientRect = nativeEl.getBoundingClientRect();
2347
- return {
2348
- width: boundingClientRect.width || nativeEl.offsetWidth,
2349
- height: boundingClientRect.height || nativeEl.offsetHeight,
2350
- top: boundingClientRect.top + (window.pageYOffset || document.documentElement.scrollTop),
2351
- left: boundingClientRect.left + (window.pageXOffset || document.documentElement.scrollLeft),
2352
- };
2353
- };
2354
- // PRIVATE FUNCTIONS
2355
- const getStyle = (nativeEl, cssProp) => {
2356
- // IE
2357
- if (nativeEl.currentStyle) {
2358
- return nativeEl.currentStyle[cssProp];
2379
+ set isSidebarHover(isHover) {
2380
+ if (this.state.isSidebarExpandOnHover) {
2381
+ this.setState({
2382
+ ...this.state,
2383
+ isSidebarHover: isHover,
2384
+ });
2385
+ }
2359
2386
  }
2360
- if (window.getComputedStyle) {
2361
- return window.getComputedStyle(nativeEl)[cssProp];
2387
+ get isSidebarHover() {
2388
+ return this.state.isSidebarHover;
2362
2389
  }
2363
- // finally try and get inline style
2364
- return nativeEl.style[cssProp];
2365
- };
2366
- /**
2367
- * Checks if a given element is statically positioned
2368
- */
2369
- const isStaticPositioned = (nativeEl) => (getStyle(nativeEl, 'position') || 'static') === 'static';
2370
- /**
2371
- * returns the closest, non-statically positioned parentOffset of a given element
2372
- * @param nativeEl
2373
- */
2374
- const parentOffsetEl = (nativeEl) => {
2375
- let offsetParent = nativeEl.offsetParent || document;
2376
- while (offsetParent && offsetParent !== document && isStaticPositioned(offsetParent)) {
2377
- offsetParent = offsetParent.offsetParent;
2390
+ set isSidebarActive(isActive) {
2391
+ this.setState({
2392
+ ...this.state,
2393
+ isSidebarActive: isActive,
2394
+ });
2378
2395
  }
2379
- return offsetParent || document;
2380
- };
2381
- const getViewElement = (fixture, componentClass, klass) => {
2382
- let de, el, domElement;
2383
- de = fixture.debugElement.query(By.css(componentClass));
2384
- if (de) {
2385
- el = de.nativeElement;
2386
- if (el && klass) {
2387
- domElement = el.querySelectorAll(klass);
2388
- if (domElement.length <= 1) {
2389
- domElement = el.querySelector(klass);
2390
- }
2391
- }
2396
+ set isSidebarInnerActive(isOpen) {
2397
+ this.setState({
2398
+ ...this.state,
2399
+ isSidebarInnerActive: isOpen,
2400
+ });
2392
2401
  }
2393
- return { de, el, domElement };
2394
- };
2395
- const closestMatchingParent = (target, className) => {
2396
- let element = target;
2397
- while (element && element.nodeType === Node.ELEMENT_NODE) {
2398
- if (element.classList.contains(className)) {
2399
- return element;
2400
- }
2401
- element = element.parentElement;
2402
+ set sidebarLinks(links) {
2403
+ this.setState({
2404
+ ...this.state,
2405
+ sidebarLinks: links,
2406
+ });
2402
2407
  }
2403
- return null;
2404
- };
2405
-
2406
- const consumeEvent = (event) => {
2407
- if (event) {
2408
- event.preventDefault();
2409
- event.stopPropagation();
2410
- event.cancelBubble = true;
2408
+ set menuLinks(links) {
2409
+ this.setState({
2410
+ ...this.state,
2411
+ menuLinks: links,
2412
+ });
2411
2413
  }
2412
- return false;
2413
- };
2414
-
2415
- const forOwn = (object, iteratee) => {
2416
- object = Object(object);
2417
- Object.keys(object).forEach((key) => iteratee(object[key], key, object));
2418
- };
2419
- const markFormGroupTouched = (FormControls) => {
2420
- const markFormGroupTouchedRecursive = (controls) => {
2421
- forOwn(controls, (c) => {
2422
- if (c instanceof FormGroup || c instanceof FormArray) {
2423
- markFormGroupTouchedRecursive(c.controls);
2424
- }
2425
- else {
2426
- c.markAsTouched();
2427
- c.updateValueAndValidity();
2428
- }
2414
+ set isBlockDocumentActive(isActive) {
2415
+ this.setState({
2416
+ ...this.state,
2417
+ isBlockDocumentActive: isActive,
2429
2418
  });
2430
- };
2431
- markFormGroupTouchedRecursive(FormControls);
2432
- };
2433
- const markControlsTouched = (group) => {
2434
- Object.keys(group.controls).forEach((key) => {
2435
- const abstractControl = group.controls[key];
2436
- if (abstractControl instanceof FormGroup || abstractControl instanceof FormArray) {
2437
- markControlsTouched(abstractControl);
2438
- }
2439
- else {
2440
- abstractControl.markAsTouched();
2441
- }
2442
- });
2443
- };
2444
- const validateEmail = (c) => {
2445
- const EMAIL_REGEXP =
2446
- // eslint-disable-next-line max-len, no-useless-escape
2447
- /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
2448
- const error = {
2449
- validateEmail: {
2450
- valid: false,
2451
- },
2452
- };
2453
- return EMAIL_REGEXP.test(c.value) ? null : error;
2454
- };
2455
-
2456
- /**
2457
- * returns a random string with radix=36
2458
- */
2459
- const uniqueId = () => Math.random().toString(36).substr(2, 9);
2460
- /**
2461
- * Its job is to parse number and format it based on given input.
2462
- * @param value can be a number or a string number
2463
- * @param fractionSize size of fraction of a number e.g. 1000.88 fraction is 2 (88) default is 2
2464
- * @param inDecimalSeparator separator for decimal part of the number default is ','
2465
- * @param inThousandSeparator separator for the whole part of the number default is ''
2466
- */
2467
- const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThousandSeparator = '') => {
2468
- if (inDecimalSeparator || inThousandSeparator) {
2469
- console.warn('The inDecimalSeparator and inThousandSeparator are deprecated. They will be a ' +
2470
- 'BREAKING CHANGE for eUI 9 and be replaced by localization strategy.');
2471
2419
  }
2472
- let decimalSeparator = '';
2473
- let thousandsSeparator = '';
2474
- if (value === null || value === undefined) {
2475
- return null;
2420
+ get hasHeader() {
2421
+ return this.state.hasHeader;
2476
2422
  }
2477
- if (typeof value === 'string') {
2478
- // get all non characters
2479
- let nonChars = value.match(/[^0-9]+/g) || [];
2480
- // get all unique chars
2481
- let uniqueChars = nonChars.reduce((acc, e) => acc.set(e, (acc.get(e) || 0) + 1), new Map());
2482
- // get separators
2483
- let separators = Array.from(uniqueChars.keys());
2484
- // sense where decimal separator and where thousand separator is
2485
- if (separators.length > 1) {
2486
- // left detected separator will be thousand and second will be decimal
2487
- thousandsSeparator = separators[0];
2488
- decimalSeparator = separators[1];
2423
+ // Edit mode
2424
+ get isDimmerActive() {
2425
+ return this.state.isDimmerActive;
2426
+ }
2427
+ set isDimmerActive(isActive) {
2428
+ this.setState({
2429
+ ...this.state,
2430
+ isDimmerActive: isActive,
2431
+ });
2432
+ }
2433
+ constructor(config, http, platformId, router, storeService, i18nService) {
2434
+ this.config = config;
2435
+ this.http = http;
2436
+ this.platformId = platformId;
2437
+ this.router = router;
2438
+ this.storeService = storeService;
2439
+ this.i18nService = i18nService;
2440
+ this.cssVars = [];
2441
+ let stateWithConfig = initialState;
2442
+ const languages = config?.i18n?.i18nService?.languages || initialState.languages;
2443
+ const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState.activeLanguage;
2444
+ stateWithConfig = {
2445
+ ...stateWithConfig,
2446
+ ...{
2447
+ languages,
2448
+ activeLanguage: defaultLanguage,
2449
+ },
2450
+ };
2451
+ this._state$ = new BehaviorSubject(stateWithConfig);
2452
+ this._breakpoint$ = new BehaviorSubject('');
2453
+ this._breakpoints$ = new BehaviorSubject({});
2454
+ this.bindActiveLanguageToAppShellState();
2455
+ if (isPlatformBrowser(this.platformId)) {
2456
+ router.events.subscribe((event) => {
2457
+ if (event instanceof NavigationEnd) {
2458
+ window.scrollTo(0, 0);
2459
+ }
2460
+ });
2489
2461
  }
2490
- else if (separators.length > 0) {
2491
- // in case there is only one separator you don't know exactly who this separator is.
2492
- // in case there are more than two occurrences means we have a thousand otherwise we'll
2493
- // agree by conventions that is decimal
2494
- if (nonChars.length > 1) {
2495
- return value
2496
- .split(separators[0])
2497
- .join('')
2498
- .replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2499
- }
2500
- else {
2501
- return value.replace(separators[0], inDecimalSeparator).replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2502
- }
2462
+ }
2463
+ setState(nextState, updateI18 = true) {
2464
+ let breakpoint, breakpoints, wrapperClasses;
2465
+ let combinedLinks;
2466
+ const state = this.state;
2467
+ // check if window width has been updated from previous state
2468
+ if (this.state.windowWidth !== nextState.windowWidth) {
2469
+ breakpoint = this.getBreakpoint(nextState.windowWidth);
2470
+ breakpoints = this.getBreakpoints(breakpoint);
2471
+ this._breakpoint$.next(breakpoint);
2472
+ this._breakpoints$.next(breakpoints);
2473
+ // if not propagate the old ones without doing any calculations
2503
2474
  }
2504
2475
  else {
2505
- // in case there are no separators then only format based on thousand one
2506
- return value.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2507
- }
2508
- // do the replacement of separators and parseInt
2509
- // Beware! Always replace thousand separator first and then decimal
2510
- value = value.split(thousandsSeparator).join('').replace(decimalSeparator, '.');
2511
- }
2512
- decimalSeparator = inDecimalSeparator;
2513
- thousandsSeparator = inThousandSeparator;
2514
- const maxFraction = '0'.repeat(fractionSize);
2515
- let [integer, fraction = maxFraction] = (value || '0').toString().split('.');
2516
- fraction = fractionSize > 0 ? (fraction + maxFraction).substring(0, fractionSize) : '';
2517
- // this rule makes sense only in number in case fraction is all zero
2518
- fraction = typeof value === 'number' && fraction === maxFraction ? '' : decimalSeparator + fraction;
2519
- return integer.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator) + fraction;
2520
- };
2521
-
2522
- const handleError = (error) => {
2523
- let errMsg = error.message ? error.message : error.status ? `${error.status} - ${error.statusText}` : 'Server error';
2524
- // console.error(errMsg);
2525
- return throwError(errMsg);
2526
- };
2527
-
2528
- /**
2529
- * check if a value is null or undefined. If it's not both returns true otherwise false
2530
- *
2531
- * @param value
2532
- */
2533
- const isDefined = (value) => value !== undefined && value !== null;
2534
-
2535
- class EuiPermissionService extends EuiService {
2536
- constructor(log, store) {
2537
- super([]);
2538
- this.log = log;
2539
- this.store = store;
2540
- if (log) {
2541
- this.logger = log.getLogger('core.PermissionService');
2476
+ breakpoint = state.breakpoint;
2477
+ breakpoints = state.breakpoints;
2478
+ }
2479
+ // finally get the wrapper classes when both the state and breakpoint are known
2480
+ wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
2481
+ // check if the menuLinks or sidebarLinks have changed from previous state
2482
+ if (this.state.menuLinks !== nextState.menuLinks || this.state.sidebarLinks !== nextState.sidebarLinks) {
2483
+ combinedLinks = [...nextState.menuLinks, ...nextState.sidebarLinks];
2484
+ }
2485
+ else {
2486
+ combinedLinks = this.state.combinedLinks;
2487
+ }
2488
+ const stateBeforeUpdate = { ...this.state };
2489
+ // we put it all together with the calculated properties
2490
+ this._state$.next({
2491
+ ...nextState,
2492
+ wrapperClasses,
2493
+ breakpoint,
2494
+ breakpoints,
2495
+ combinedLinks,
2496
+ });
2497
+ // update the Store Language
2498
+ if (updateI18 && nextState.activeLanguage !== stateBeforeUpdate.activeLanguage) {
2499
+ this.i18nService.updateState({ activeLang: nextState.activeLanguage });
2542
2500
  }
2543
2501
  }
2544
2502
  /**
2545
- * initialize the service by providing a state
2546
- * @param rights
2503
+ * Emits a slice from the state whether that changes
2504
+ *
2505
+ * @param key can be 'key' or 'key.sub.sub'
2547
2506
  */
2548
- init(rights) {
2549
- super.initEuiService();
2550
- if (Array.isArray(rights)) {
2551
- this.updateState(rights);
2552
- return of({ success: true });
2507
+ getState(key) {
2508
+ return defer(() =>
2509
+ // check if key exists
2510
+ key
2511
+ ? this.state$.pipe(map((state) => get(state, key)),
2512
+ // filter((state) => state),
2513
+ distinctUntilChanged((x, y) => isEqual(x, y)))
2514
+ : this.state$);
2515
+ }
2516
+ sidebarToggle() {
2517
+ this.isSidebarOpen = !this.state.isSidebarOpen;
2518
+ }
2519
+ // Edit mode
2520
+ dimmerActiveToggle() {
2521
+ const isActive = this.isDimmerActive;
2522
+ this.setState({
2523
+ ...this.state,
2524
+ isDimmerActive: !isActive,
2525
+ });
2526
+ this.activateEditModeCssVars(!isActive);
2527
+ }
2528
+ setDimmerActiveState(activeState) {
2529
+ this.setState({
2530
+ ...this.state,
2531
+ isDimmerActive: activeState,
2532
+ });
2533
+ this.activateEditModeCssVars(activeState);
2534
+ }
2535
+ activateEditModeCssVars(isActive) {
2536
+ if (isActive) {
2537
+ this._setCssVarValue('--eui-docpage-navigation-z-index', 'inherit'); // Reset doc-page-navigation-column z-index
2538
+ this._setCssVarValue('--eui-z-index-sidebar', 'inherit'); // Reset eui-app-sidebar z-index
2539
+ this._setCssVarValue('--eui-z-index-root', 'inherit'); // Reset eui-app-main-content z-index
2553
2540
  }
2554
- if (this.logger) {
2555
- this.logger.error('Init object should be instance of BaseUserState');
2541
+ else {
2542
+ this._setCssVarValue('--eui-docpage-navigation-z-index', '2'); // Restore doc-page-navigation-column z-index
2543
+ this._setCssVarValue('--eui-z-index-sidebar', '1044'); // Restore eui-app-sidebar z-index
2544
+ this._setCssVarValue('--eui-z-index-root', '1'); // Restore eui-app-main-content z-index
2556
2545
  }
2557
- return of({ success: false, error: 'Init object should be instance of BaseUserState' });
2558
2546
  }
2559
- get userRights() {
2560
- return this.stateInstance;
2547
+ // --------------
2548
+ // public methods
2549
+ // --------------
2550
+ fetchAppMetadata(metadataFilePath = 'assets/app-metadata.json') {
2551
+ this.getJson(metadataFilePath).then((data) => {
2552
+ this.setState({
2553
+ ...this.state,
2554
+ appMetadata: data,
2555
+ });
2556
+ });
2561
2557
  }
2562
- /**
2563
- * get the user's Rights from the state
2564
- */
2565
- getState() {
2566
- return this.store.select(getUserRights);
2558
+ activateSidebar() {
2559
+ this.setState({
2560
+ ...this.state,
2561
+ hasSidebar: true,
2562
+ });
2563
+ if (!this.state.isSidebarHidden) {
2564
+ this.activateSidebarCssVars();
2565
+ }
2567
2566
  }
2568
- /**
2569
- * update the state with the given user's rights
2570
- * @param rights
2571
- */
2572
- updateState(rights) {
2573
- this.store.dispatch(new UpdateUserRightsAction(rights || []));
2567
+ activateSidebarHeader() {
2568
+ this.activateSidebarHeaderCssVars();
2574
2569
  }
2575
- /**
2576
- * accepts a string of right and or a permission. In string first comes the right and or followed by permission in
2577
- * a dot separated way e.g. 'RIGHT.PERMISSION' or 'RIGHT'. The string can contain more that 2 separated fields.
2578
- * In that case the last field should be the permission and all the others a Right. e.g. 'RIGHT1.RIGHT2.PERMISSION'
2579
- * The last part is useful where you want a user to have multiple rights and the permission of the last right.
2580
- * @param rightsAndPermission
2581
- */
2582
- checkAttributePermission(rightsAndPermission) {
2583
- const permProps = rightsAndPermission.split('.');
2584
- const rightId = permProps[0];
2585
- const hasRight = this.checkRight(rightId);
2586
- if (hasRight) {
2587
- if (permProps.length === 2) {
2588
- // in case of 'RIGHT.PERMISSION'
2589
- const permission = permProps[1];
2590
- return this.checkPermission(rightId, permission);
2591
- }
2592
- else if (permProps.length > 2) {
2593
- // in case of 'RIGHT1.RIGHT2.....PERMISSION' string call recursively
2594
- return this.checkAttributePermission(rightsAndPermission.slice(rightId.length + 1));
2595
- }
2596
- }
2597
- return hasRight;
2570
+ activateSidebarFooter() {
2571
+ this.activateSidebarFooterCssVars();
2598
2572
  }
2599
- /**
2600
- * check if a user has the right.
2601
- * @param rightId the id of Right
2602
- */
2603
- checkRight(rightId) {
2604
- return this.userRights.some((right) => right && right.id === rightId);
2573
+ activateHeader() {
2574
+ this.setState({
2575
+ ...this.state,
2576
+ hasHeader: true,
2577
+ });
2578
+ this.activateHeaderCssVars();
2605
2579
  }
2606
- /**
2607
- * check if a user has that right and that right has the permission given.
2608
- * @param rightId the right of the user
2609
- * @param permission the permission of the right
2610
- */
2611
- checkPermission(rightId, permission) {
2612
- // the user has to have that right and that right has to have the given permission
2613
- return this.userRights.some((right) => right && right.id === rightId && right.permissions && right.permissions.includes(permission));
2580
+ activateBreadcrumb() {
2581
+ this.setState({
2582
+ ...this.state,
2583
+ hasBreadcrumb: true,
2584
+ });
2585
+ this.activateBreadcrumbCssVars();
2614
2586
  }
2615
- /**
2616
- * checks whether a user have all rights passed as an argument
2617
- * @param rights an array of EuiUserRight
2618
- */
2619
- haveAllRights(rights) {
2620
- if (!isDefined(rights)) {
2621
- throw Error(`The rights should be an array but instead it's not defined!`);
2622
- }
2623
- return rights.every((right) => this.userRights.find((uRight) => uRight.id === right.id));
2587
+ activateTopMessage(height) {
2588
+ this.setState({
2589
+ ...this.state,
2590
+ hasTopMessage: true,
2591
+ });
2592
+ this.activateTopMessageCssVars(height);
2624
2593
  }
2625
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiPermissionService, deps: [{ token: LogService, optional: true }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2626
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiPermissionService, providedIn: 'root' }); }
2627
- }
2628
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiPermissionService, decorators: [{
2629
- type: Injectable,
2630
- args: [{
2631
- providedIn: 'root',
2632
- }]
2633
- }], ctorParameters: function () { return [{ type: LogService, decorators: [{
2634
- type: Optional
2635
- }] }, { type: StoreService }]; } });
2636
-
2637
- class EuiDynamicMenuService {
2638
- // TODO: it should be moved euiservice, or it should be static
2639
- // TODO: can we moved that service inside the module of the component that's using it?
2640
- constructor(uxPermission, store) {
2641
- this.uxPermission = uxPermission;
2642
- this.store = store;
2643
- this.menuLinks = [];
2644
- this.store.select(getUserState).subscribe((user) => {
2645
- if (user.menuLinks) {
2646
- this.menuLinks = user.menuLinks;
2647
- }
2594
+ activateToolbar() {
2595
+ this.setState({
2596
+ ...this.state,
2597
+ hasToolbar: true,
2648
2598
  });
2599
+ this.activateToolbarCssVars();
2600
+ }
2601
+ activateToolbarMenu() {
2602
+ this.setState({
2603
+ ...this.state,
2604
+ hasToolbarMenu: true,
2605
+ });
2606
+ }
2607
+ fetchCssVars() {
2608
+ const cssVarNames = [
2609
+ '--eui-app-header-height-default',
2610
+ '--eui-app-header-height-active',
2611
+ '--eui-app-header-height-shrink',
2612
+ '--eui-app-breadcrumb-height-default',
2613
+ '--eui-app-breadcrumb-height-active',
2614
+ '--eui-app-top-message-height-default',
2615
+ '--eui-app-top-message-height-active',
2616
+ '--eui-app-top-message-height-shrink',
2617
+ '--eui-app-toolbar-height-default',
2618
+ '--eui-app-toolbar-height-active',
2619
+ '--eui-app-sidebar-width-default',
2620
+ '--eui-app-sidebar-width-active',
2621
+ '--eui-app-sidebar-width-close-default',
2622
+ '--eui-app-sidebar-width-close-active',
2623
+ '--eui-app-sidebar-header-height-default',
2624
+ '--eui-app-sidebar-header-height-active',
2625
+ '--eui-app-sidebar-footer-height-default',
2626
+ '--eui-app-sidebar-footer-height-active',
2627
+ ];
2628
+ this.cssVars = cssVarNames.map((v) => ({ key: v, value: this.getCssVarValue(v) }));
2629
+ }
2630
+ initCssVars() {
2631
+ this.setCssVar('--eui-app-header-height-default', '--eui-app-header-height');
2632
+ this.setCssVar('--eui-app-breadcrumb-height-default', '--eui-app-breadcrumb-height');
2633
+ this.setCssVar('--eui-app-top-message-height-default', '--eui-app-top-message-height');
2634
+ this.setCssVar('--eui-app-toolbar-height-default', '--eui-app-toolbar-height');
2635
+ this.setCssVar('--eui-app-sidebar-width-default', '--eui-app-sidebar-width');
2636
+ this.setCssVar('--eui-app-sidebar-width-close-default', '--eui-app-sidebar-width-close');
2637
+ this.setCssVar('--eui-app-sidebar-header-height-default', '--eui-app-sidebar-header-height');
2638
+ this.setCssVar('--eui-app-sidebar-footer-height-default', '--eui-app-sidebar-footer-height');
2639
+ }
2640
+ activateHeaderCssVars() {
2641
+ this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
2642
+ }
2643
+ activateBreadcrumbCssVars() {
2644
+ this.setCssVar('--eui-app-breadcrumb-height-active', '--eui-app-breadcrumb-height');
2645
+ }
2646
+ activateTopMessageCssVars(height) {
2647
+ this._setCssVarValue('--eui-app-top-message-height', `${height}px`);
2648
+ }
2649
+ activateToolbarCssVars() {
2650
+ this.setCssVar('--eui-app-toolbar-height-active', '--eui-app-toolbar-height');
2651
+ }
2652
+ activateFooterCssVars() {
2653
+ this.setCssVar('--eui-app-footer-height-active', '--eui-app-footer-height');
2654
+ }
2655
+ setHeaderShrinkCssVar(active) {
2656
+ if (active) {
2657
+ this.setCssVar('--eui-app-header-height-shrink', '--eui-app-header-height');
2658
+ }
2659
+ else {
2660
+ this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
2661
+ }
2662
+ }
2663
+ activateSidebarCssVars() {
2664
+ this.setCssVar('--eui-app-sidebar-width-active', '--eui-app-sidebar-width');
2665
+ this.setCssVar('--eui-app-sidebar-width-close-active', '--eui-app-sidebar-width-close');
2649
2666
  }
2650
- getMenuLinks() {
2651
- return this.menuLinks;
2667
+ removeSidebarCssVars() {
2668
+ document.documentElement.style.removeProperty('--eui-app-sidebar-header-height');
2669
+ document.documentElement.style.removeProperty('--eui-app-sidebar-footer-height');
2670
+ document.documentElement.style.removeProperty('--eui-app-sidebar-width');
2671
+ document.documentElement.style.removeProperty('--eui-app-sidebar-width-close');
2652
2672
  }
2653
- filterEuiMenuItemsWithRights(links) {
2654
- return links.filter((link) => {
2655
- if (link.hasChildren) {
2656
- link.children = this.filterEuiMenuItemsWithRights(link.children);
2657
- }
2658
- // First check if the user is denied access:
2659
- if (link.deniedRightId) {
2660
- if (this.uxPermission.checkRight(link.deniedRightId)) {
2661
- return false;
2662
- }
2663
- }
2664
- if (link.deniedRightIds) {
2665
- for (const deniedRightId of link.deniedRightIds) {
2666
- if (this.uxPermission.checkRight(deniedRightId)) {
2667
- return false;
2668
- }
2669
- }
2670
- }
2671
- // Then check if the user needs to be allowed access explicitly:
2672
- if (link.allowedRightId) {
2673
- return this.uxPermission.checkRight(link.allowedRightId);
2674
- }
2675
- if (link.allowedRightIds) {
2676
- for (const allowedRightId of link.allowedRightIds) {
2677
- if (this.uxPermission.checkRight(allowedRightId)) {
2678
- return true;
2679
- }
2680
- }
2681
- // User doesn't have one of the allowed rights. Deny access:
2682
- return false;
2683
- }
2684
- // Access to the menu item is not denied, therefore allow it:
2685
- return true;
2686
- });
2673
+ activateSidebarHeaderCssVars() {
2674
+ this.setCssVar('--eui-app-sidebar-header-height-active', '--eui-app-sidebar-header-height');
2687
2675
  }
2688
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiDynamicMenuService, deps: [{ token: EuiPermissionService }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2689
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiDynamicMenuService, providedIn: 'root' }); }
2690
- }
2691
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiDynamicMenuService, decorators: [{
2692
- type: Injectable,
2693
- args: [{
2694
- providedIn: 'root',
2695
- }]
2696
- }], ctorParameters: function () { return [{ type: EuiPermissionService }, { type: StoreService }]; } });
2697
-
2698
- function withUxErrorManager(errorManager) {
2699
- return (source$) => new Observable((observer) => {
2700
- const wrapper = {
2701
- next: (value) => {
2702
- errorManager.clearError();
2703
- observer.next(value);
2704
- },
2705
- error: (err) => {
2706
- errorManager.publishError(err);
2707
- },
2708
- };
2709
- return source$.subscribe(wrapper);
2710
- });
2711
- }
2712
-
2713
- class UxErrorFeedbackService {
2714
- constructor(asService, translateService) {
2715
- this.asService = asService;
2716
- this.translateService = translateService;
2717
- this.errors = new Subject();
2676
+ activateSidebarFooterCssVars() {
2677
+ this.setCssVar('--eui-app-sidebar-footer-height-active', '--eui-app-sidebar-footer-height');
2718
2678
  }
2719
2679
  /**
2720
- * Publishes errors to targeted components
2680
+ * Gets the viewport height and width and multiple it by 1% to get a value for a vh/vw unit
2681
+ * Sets the value in the --eui-app-vh custom property to the root of the document
2682
+ * Sets the value in the --eui-app-vw custom property to the root of the document
2683
+ * Example for 100% height: calc(var(--eui-app-vh, 1vh) * 100);
2684
+ * Example for 50% height: calc(var(--eui-app-vh, 1vh) * 50);
2685
+ * Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
2721
2686
  */
2722
- publishError(err, instanceId, groupId, accumulate) {
2723
- if (instanceId) {
2724
- this.errors.next(new UxPublishErrorFeedbackEvent(err.uxHttpErrorOutput, instanceId, groupId, accumulate));
2725
- }
2726
- else {
2727
- this.errors.next(new UxPublishErrorFeedbackEvent(err.uxHttpErrorOutput, undefined, groupId, accumulate));
2728
- }
2687
+ setAppViewportCssVars() {
2688
+ let vh = window.innerHeight * 0.01;
2689
+ let vw = window.innerWidth * 0.01;
2690
+ this._setCssVarValue('--eui-app-vh', `${vh}px`);
2691
+ this._setCssVarValue('--eui-app-vw', `${vw}px`);
2729
2692
  }
2730
2693
  /**
2731
- * Growl errors
2694
+ * Returns the current value of --eui-base-font-size CSS variable
2732
2695
  */
2733
- growlError(err) {
2734
- // TODO v17 - should not display growl from here, but where it's called
2735
- // const feedBacks = err.uxHttpErrorOutput.getFeedBacks();
2736
- // const isGrowlSticky = false;
2737
- // const isGrowlMultiple = true;
2738
- // const growlLife = 10000;
2739
- // const position = 'bottom-right';
2740
- // feedBacks.forEach((feedback: UxErrorFeedback) =>
2741
- // this.translateService
2742
- // .get(feedback.msgId)
2743
- // .pipe(take(1))
2744
- // .subscribe((translate) => {
2745
- // this.asService.growl(
2746
- // {
2747
- // severity: feedback.severity || 'danger',
2748
- // summary: 'ERROR',
2749
- // detail: translate,
2750
- // },
2751
- // isGrowlSticky,
2752
- // isGrowlMultiple,
2753
- // growlLife,
2754
- // position
2755
- // );
2756
- // })
2757
- // );
2696
+ getBaseFontSize() {
2697
+ return this.state.appBaseFontSize || this.getCssVarValue('--eui-base-font-size');
2758
2698
  }
2759
- clearError(id, groupId) {
2760
- this.errors.next(new UxClearErrorFeedbackEvent(id, groupId));
2699
+ /**
2700
+ * Updates the current value of --eui-base-font-size CSS variable and the UIState appBaseFontSize
2701
+ */
2702
+ setBaseFontSize(newsize) {
2703
+ this.setState({
2704
+ ...this.state,
2705
+ appBaseFontSize: newsize,
2706
+ }, false);
2707
+ this._setCssVarValue('--eui-base-font-size', newsize);
2761
2708
  }
2762
- createLocalErrorManager() {
2763
- return new UxErrorManager(this);
2709
+ // ---------------
2710
+ // private getters
2711
+ // ---------------
2712
+ getCssVarValue(inputProperty) {
2713
+ return getComputedStyle(document.documentElement).getPropertyValue(inputProperty);
2764
2714
  }
2765
- createGlobalErrorManager() {
2766
- return new UxErrorManager(this, true);
2715
+ setCssVar(inputProperty, outputProperty) {
2716
+ const cssVarValue = this.cssVars.filter((v) => v.key === inputProperty)[0].value;
2717
+ this._setCssVarValue(outputProperty, cssVarValue);
2718
+ // console.log(inputProperty, outputProperty, cssVarValue);
2767
2719
  }
2768
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxErrorFeedbackService, deps: [{ token: UxAppShellService }, { token: i2.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2769
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxErrorFeedbackService, providedIn: 'root' }); }
2770
- }
2771
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxErrorFeedbackService, decorators: [{
2772
- type: Injectable,
2773
- args: [{
2774
- providedIn: 'root',
2775
- }]
2776
- }], ctorParameters: function () { return [{ type: UxAppShellService }, { type: i2.TranslateService }]; } });
2777
- class UxErrorManager {
2778
- constructor(uxErrorFeedbackService, isGlobal) {
2779
- this.uxErrorFeedbackService = uxErrorFeedbackService;
2780
- this.isGlobal = isGlobal;
2781
- this.httpErrorOperator = withUxErrorManager(this);
2782
- this.id = Math.random().toString();
2783
- }
2784
- publishError(err, groupId, accumulate) {
2785
- if (!this.isGlobal) {
2786
- this.uxErrorFeedbackService.publishError(err, this.id, groupId, accumulate);
2787
- }
2788
- else {
2789
- this.uxErrorFeedbackService.publishError(err, undefined, groupId, accumulate);
2790
- }
2720
+ _setCssVarValue(varName, varValue) {
2721
+ document.documentElement.style.setProperty(varName, varValue);
2791
2722
  }
2792
- clearError(groupId) {
2793
- if (!this.isGlobal) {
2794
- this.uxErrorFeedbackService.clearError(this.id, groupId);
2723
+ getWrapperClasses(state, breakpoint) {
2724
+ let classes = [];
2725
+ classes.push(breakpoint);
2726
+ if (state.hasSidebar) {
2727
+ if (state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
2728
+ classes.push('sidebar-state-open');
2729
+ }
2730
+ if (!state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
2731
+ classes.push('sidebar-state-close');
2732
+ }
2733
+ if (state.isSidebarActive) {
2734
+ classes.push('sidebar-active');
2735
+ }
2736
+ if (state.isSidebarInnerActive) {
2737
+ classes.push('sidebar-inner-active');
2738
+ }
2739
+ if (state.isSidebarStateCloseWithIcons) {
2740
+ classes.push('sidebar-state-close-with-icons');
2741
+ }
2742
+ // NEW APP-SHELL props
2743
+ if (state.isSidebarHidden) {
2744
+ classes.push('sidebar--hidden');
2745
+ }
2746
+ if (state.isSidebarOpen) {
2747
+ classes.push('sidebar--open');
2748
+ }
2749
+ else {
2750
+ classes.push('sidebar--close');
2751
+ }
2752
+ if (state.isSidebarHover) {
2753
+ classes.push('sidebar--hover');
2754
+ }
2795
2755
  }
2796
- else {
2797
- this.uxErrorFeedbackService.clearError(undefined, groupId);
2756
+ if (state.deviceInfo && state.deviceInfo.isFF) {
2757
+ classes.push('ff');
2798
2758
  }
2799
- }
2800
- growlError(err) {
2801
- this.uxErrorFeedbackService.growlError(err);
2802
- }
2803
- errors() {
2804
- if (!this.isGlobal) {
2805
- return this.uxErrorFeedbackService.errors.pipe(filter((evt) => evt.id === this.id));
2759
+ if (state.deviceInfo && state.deviceInfo.isIE) {
2760
+ classes.push('ie');
2806
2761
  }
2807
- else {
2808
- return this.uxErrorFeedbackService.errors.pipe(filter((evt) => !evt.id));
2762
+ if (state.deviceInfo && state.deviceInfo.isIE11) {
2763
+ classes.push('ie11');
2809
2764
  }
2765
+ if (state.deviceInfo && state.deviceInfo.isChrome) {
2766
+ classes.push('chrome');
2767
+ }
2768
+ return classes.join(' ');
2810
2769
  }
2811
- }
2812
-
2813
- const DYNAMIC_COMPONENT_CONFIG = new InjectionToken('DYNAMIC_COMPONENT_CONFIG');
2814
- class UxDynamicComponentService {
2815
- constructor(componentFactoryResolver, injector, appRef) {
2816
- this.componentFactoryResolver = componentFactoryResolver;
2817
- this.injector = injector;
2818
- this.appRef = appRef;
2819
- }
2820
- /**
2821
- * Adds a component to portal host dynamically
2822
- * @param component The component to be injected
2823
- * @param el The element reference for the component to be injected
2824
- * @param config The data to be passed (config) for the DYNAMIC_COMPONENT_CONFIG token
2825
- */
2826
- add(component, el, config) {
2827
- // TODO: take a look and replace deprecated componentFactoryResolver https://github.com/angular/components/issues/24334
2828
- // Create a portalHost from a DOM element
2829
- this.portalHost = new DomPortalOutlet(el ? el.nativeElement : document.body, this.componentFactoryResolver, this.appRef, this.injector);
2830
- // Locate the component factory for the ComponentToIncludeDynamicallyComponent
2831
- this.portal = new ComponentPortal(component, null, config ? this.createInjector(config) : null);
2832
- // Attach portal to host
2833
- this.portalComponentInstance = this.portalHost.attach(this.portal);
2834
- if (config) {
2835
- Object.assign(config, {
2836
- portalHostRef: this.portalHost,
2837
- portalRef: this.portal,
2838
- portalComponentInstanceRef: this.portalComponentInstance,
2839
- });
2770
+ getBreakpoint(windowWidth) {
2771
+ let bkp = '';
2772
+ switch (true) {
2773
+ case windowWidth >= 0 && windowWidth < 576:
2774
+ bkp = 'xs';
2775
+ break;
2776
+ case windowWidth >= 576 && windowWidth < 768:
2777
+ bkp = 'sm';
2778
+ break;
2779
+ case windowWidth >= 768 && windowWidth < 992:
2780
+ bkp = 'md';
2781
+ break;
2782
+ case windowWidth >= 992 && windowWidth < 1200:
2783
+ bkp = 'lg';
2784
+ break;
2785
+ case windowWidth >= 1200 && windowWidth < 1400:
2786
+ bkp = 'xl';
2787
+ break;
2788
+ case windowWidth >= 1400 && windowWidth < 1920:
2789
+ bkp = 'xxl';
2790
+ break;
2791
+ case windowWidth >= 1920 && windowWidth < 2560:
2792
+ bkp = 'fhd';
2793
+ break;
2794
+ case windowWidth >= 2560 && windowWidth < 3840:
2795
+ bkp = '2k';
2796
+ break;
2797
+ case windowWidth >= 3840:
2798
+ bkp = '4k';
2799
+ break;
2840
2800
  }
2801
+ return bkp;
2802
+ }
2803
+ getBreakpoints(bkp) {
2841
2804
  return {
2842
- portalHost: this.portalHost,
2843
- portal: this.portal,
2844
- portalComponentInstance: this.portalComponentInstance,
2805
+ isMobile: bkp === 'xs' || bkp === 'sm',
2806
+ isTablet: bkp === 'md',
2807
+ isLtDesktop: bkp === 'xs' || bkp === 'sm' || bkp === 'md',
2808
+ isDesktop: bkp === 'lg',
2809
+ isXL: bkp === 'xl',
2810
+ isXXL: bkp === 'xxl',
2811
+ isFHD: bkp === 'fhd',
2812
+ is2K: bkp === '2k',
2813
+ is4K: bkp === '4k',
2845
2814
  };
2846
2815
  }
2847
- /**
2848
- * detaches a portalHost
2849
- * @param portalHostRef reference of portal host to be detached
2850
- */
2851
- remove(portalHostRef) {
2852
- portalHostRef.detach();
2853
- this.portalHost = null;
2854
- this.portal = null;
2855
- this.portalComponentInstance = null;
2816
+ getJson(url) {
2817
+ return this.http.get(url).toPromise().then(this.extractData).catch(this.handleError);
2856
2818
  }
2857
- /**
2858
- * creates a custom injector to be used when providing custom injection tokens to components inside a portal
2859
- * @param data to be used by DYNAMIC_COMPONENT_CONFIG token
2860
- */
2861
- createInjector(data) {
2862
- const injectorTokens = new WeakMap();
2863
- injectorTokens.set(DYNAMIC_COMPONENT_CONFIG, data);
2864
- return new PortalInjector(this.injector, injectorTokens);
2819
+ extractData(res) {
2820
+ const body = res;
2821
+ return body || {};
2822
+ }
2823
+ handleError(error) {
2824
+ console.error('An error occurred', error);
2825
+ return Promise.reject(error.message || error);
2826
+ }
2827
+ bindActiveLanguageToAppShellState() {
2828
+ this.storeService.select(getActiveLang).subscribe((activeLang) => {
2829
+ if (activeLang !== this.state.activeLanguage) {
2830
+ this.setState({
2831
+ ...this.state,
2832
+ activeLanguage: activeLang,
2833
+ }, false);
2834
+ }
2835
+ });
2865
2836
  }
2866
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxDynamicComponentService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.Injector }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Injectable }); }
2867
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxDynamicComponentService }); }
2837
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$5.HttpClient }, { token: PLATFORM_ID }, { token: i1$4.Router }, { token: StoreService }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
2838
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiAppShellService, providedIn: 'root' }); }
2868
2839
  }
2869
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxDynamicComponentService, decorators: [{
2870
- type: Injectable
2871
- }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i0.ApplicationRef }]; } });
2840
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiAppShellService, decorators: [{
2841
+ type: Injectable,
2842
+ args: [{
2843
+ providedIn: 'root',
2844
+ }]
2845
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2846
+ type: Optional
2847
+ }, {
2848
+ type: Inject,
2849
+ args: [GLOBAL_CONFIG_TOKEN]
2850
+ }] }, { type: i1$5.HttpClient }, { type: undefined, decorators: [{
2851
+ type: Inject,
2852
+ args: [PLATFORM_ID]
2853
+ }] }, { type: i1$4.Router }, { type: StoreService }, { type: I18nService, decorators: [{
2854
+ type: Optional
2855
+ }] }] });
2872
2856
 
2873
2857
  /* eslint-disable */
2874
2858
  const EUI_COUNTRIES = {
@@ -3577,10 +3561,10 @@ class EuiTimezoneService {
3577
3561
  getTimezone(tz) {
3578
3562
  return EUI_TIMEZONES.find((item) => item.name === tz);
3579
3563
  }
3580
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiTimezoneService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3581
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiTimezoneService }); }
3564
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiTimezoneService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3565
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiTimezoneService }); }
3582
3566
  }
3583
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuiTimezoneService, decorators: [{
3567
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuiTimezoneService, decorators: [{
3584
3568
  type: Injectable
3585
3569
  }] });
3586
3570
 
@@ -3699,14 +3683,14 @@ class LocalStorageService extends StorageService {
3699
3683
  }
3700
3684
  }
3701
3685
  }
3702
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocalStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
3703
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocalStorageService }); }
3686
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocalStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
3687
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocalStorageService }); }
3704
3688
  }
3705
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocalStorageService, decorators: [{
3689
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocalStorageService, decorators: [{
3706
3690
  type: Injectable
3707
- }], ctorParameters: function () { return [{ type: LogService, decorators: [{
3691
+ }], ctorParameters: () => [{ type: LogService, decorators: [{
3708
3692
  type: Optional
3709
- }] }]; } });
3693
+ }] }] });
3710
3694
 
3711
3695
  /**
3712
3696
  * sessionStorage service
@@ -3770,14 +3754,14 @@ class SessionStorageService extends StorageService {
3770
3754
  }
3771
3755
  }
3772
3756
  }
3773
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: SessionStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
3774
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: SessionStorageService }); }
3757
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: SessionStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
3758
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: SessionStorageService }); }
3775
3759
  }
3776
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: SessionStorageService, decorators: [{
3760
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: SessionStorageService, decorators: [{
3777
3761
  type: Injectable
3778
- }], ctorParameters: function () { return [{ type: LogService, decorators: [{
3762
+ }], ctorParameters: () => [{ type: LogService, decorators: [{
3779
3763
  type: Optional
3780
- }] }]; } });
3764
+ }] }] });
3781
3765
 
3782
3766
  /** @internal */
3783
3767
  const localForage = 'defineDriver' in lf ? lf : lf['default'];
@@ -3851,19 +3835,19 @@ class LocalForageService extends AsyncStorageService {
3851
3835
  }
3852
3836
  }));
3853
3837
  }
3854
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocalForageService, deps: [{ token: LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
3855
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocalForageService }); }
3838
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocalForageService, deps: [{ token: LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
3839
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocalForageService }); }
3856
3840
  }
3857
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocalForageService, decorators: [{
3841
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocalForageService, decorators: [{
3858
3842
  type: Injectable
3859
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
3843
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
3860
3844
  type: Inject,
3861
3845
  args: [LOCAL_FORAGE_SERVICE_CONFIG_TOKEN]
3862
3846
  }, {
3863
3847
  type: Optional
3864
3848
  }] }, { type: LogService, decorators: [{
3865
3849
  type: Optional
3866
- }] }]; } });
3850
+ }] }] });
3867
3851
 
3868
3852
  /**
3869
3853
  * Angular is using a gulp task to generate the locales that we dynamically import. This task can be found here
@@ -3962,6 +3946,7 @@ class LocaleService extends EuiService {
3962
3946
  *
3963
3947
  * @param locale array of locale to load
3964
3948
  */
3949
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3965
3950
  loadLocale(locale) {
3966
3951
  // locale = Array.isArray(locale) ? locale : [locale];
3967
3952
  // const localeImports: Observable<{ data: any, localeId: string, extraData: any }>[]
@@ -4060,15 +4045,15 @@ class LocaleService extends EuiService {
4060
4045
  }
4061
4046
  });
4062
4047
  }
4063
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocaleService, deps: [{ token: StoreService }, { token: GLOBAL_CONFIG_TOKEN }, { token: LOCALE_ID }, { token: LOCALE_ID_MAPPER, optional: true }, { token: I18nService, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
4064
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocaleService, providedIn: 'root' }); }
4048
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocaleService, deps: [{ token: StoreService }, { token: GLOBAL_CONFIG_TOKEN }, { token: LOCALE_ID }, { token: LOCALE_ID_MAPPER, optional: true }, { token: I18nService, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
4049
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocaleService, providedIn: 'root' }); }
4065
4050
  }
4066
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocaleService, decorators: [{
4051
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocaleService, decorators: [{
4067
4052
  type: Injectable,
4068
4053
  args: [{
4069
4054
  providedIn: 'root',
4070
4055
  }]
4071
- }], ctorParameters: function () { return [{ type: StoreService }, { type: undefined, decorators: [{
4056
+ }], ctorParameters: () => [{ type: StoreService }, { type: undefined, decorators: [{
4072
4057
  type: Inject,
4073
4058
  args: [GLOBAL_CONFIG_TOKEN]
4074
4059
  }] }, { type: undefined, decorators: [{
@@ -4083,7 +4068,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImpor
4083
4068
  type: Optional
4084
4069
  }] }, { type: LogService, decorators: [{
4085
4070
  type: Optional
4086
- }] }]; } });
4071
+ }] }] });
4087
4072
 
4088
4073
  class LocaleServiceMock extends LocaleService {
4089
4074
  constructor(locale_id) {
@@ -4109,17 +4094,17 @@ class LocaleServiceMock extends LocaleService {
4109
4094
  this.DEFAULT_LOCALE = state.id || 'en';
4110
4095
  return of({ success: true });
4111
4096
  }
4112
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocaleServiceMock, deps: [{ token: LOCALE_ID, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
4113
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocaleServiceMock }); }
4097
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocaleServiceMock, deps: [{ token: LOCALE_ID, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
4098
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocaleServiceMock }); }
4114
4099
  }
4115
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: LocaleServiceMock, decorators: [{
4100
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: LocaleServiceMock, decorators: [{
4116
4101
  type: Injectable
4117
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
4102
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4118
4103
  type: Optional
4119
4104
  }, {
4120
4105
  type: Inject,
4121
4106
  args: [LOCALE_ID]
4122
- }] }]; } });
4107
+ }] }] });
4123
4108
 
4124
4109
  // export const USER_API_CONFIG_TOKEN = new InjectionToken<UserApiConfig>('USER_API_CONFIG');
4125
4110
  // export const DEFAULT_USER_PREFERENCES_TOKEN = new InjectionToken<BaseUserPreferences>('DEFAULT_USER_PREFERENCES');
@@ -4168,15 +4153,15 @@ class UserService extends EuiService {
4168
4153
  this.store.dispatch(new UpdateUserStateAction(userState));
4169
4154
  }
4170
4155
  }
4171
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UserService, deps: [{ token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4172
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UserService, providedIn: 'root' }); }
4156
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UserService, deps: [{ token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4157
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UserService, providedIn: 'root' }); }
4173
4158
  }
4174
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UserService, decorators: [{
4159
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UserService, decorators: [{
4175
4160
  type: Injectable,
4176
4161
  args: [{
4177
4162
  providedIn: 'root',
4178
4163
  }]
4179
- }], ctorParameters: function () { return [{ type: StoreService }]; } });
4164
+ }], ctorParameters: () => [{ type: StoreService }] });
4180
4165
 
4181
4166
  class UserServiceMock extends UserService {
4182
4167
  constructor() {
@@ -4199,12 +4184,12 @@ class UserServiceMock extends UserService {
4199
4184
  getUserId() {
4200
4185
  return of('anonymous');
4201
4186
  }
4202
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UserServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4203
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UserServiceMock }); }
4187
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UserServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4188
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UserServiceMock }); }
4204
4189
  }
4205
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UserServiceMock, decorators: [{
4190
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UserServiceMock, decorators: [{
4206
4191
  type: Injectable
4207
- }], ctorParameters: function () { return []; } });
4192
+ }], ctorParameters: () => [] });
4208
4193
 
4209
4194
  const LANG_PARAM_KEY = 'X-Lang-Param';
4210
4195
  /**
@@ -4231,12 +4216,12 @@ class AddLangParamInterceptor {
4231
4216
  params: req.params.set(langParam, langValue),
4232
4217
  }));
4233
4218
  }
4234
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i2.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4235
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AddLangParamInterceptor }); }
4219
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i1$3.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4220
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: AddLangParamInterceptor }); }
4236
4221
  }
4237
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AddLangParamInterceptor, decorators: [{
4222
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: AddLangParamInterceptor, decorators: [{
4238
4223
  type: Injectable
4239
- }], ctorParameters: function () { return [{ type: i2.TranslateService }]; } });
4224
+ }], ctorParameters: () => [{ type: i1$3.TranslateService }] });
4240
4225
 
4241
4226
  class CachePreventionInterceptor {
4242
4227
  intercept(req, next) {
@@ -4250,10 +4235,10 @@ class CachePreventionInterceptor {
4250
4235
  headers: req.headers.set('Cache-Control', 'No-Cache'),
4251
4236
  }));
4252
4237
  }
4253
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CachePreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4254
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CachePreventionInterceptor }); }
4238
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CachePreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4239
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CachePreventionInterceptor }); }
4255
4240
  }
4256
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CachePreventionInterceptor, decorators: [{
4241
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CachePreventionInterceptor, decorators: [{
4257
4242
  type: Injectable
4258
4243
  }] });
4259
4244
 
@@ -4263,10 +4248,10 @@ class CorsSecurityInterceptor {
4263
4248
  withCredentials: true,
4264
4249
  }));
4265
4250
  }
4266
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CorsSecurityInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4267
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CorsSecurityInterceptor }); }
4251
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CorsSecurityInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4252
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CorsSecurityInterceptor }); }
4268
4253
  }
4269
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CorsSecurityInterceptor, decorators: [{
4254
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CorsSecurityInterceptor, decorators: [{
4270
4255
  type: Injectable
4271
4256
  }] });
4272
4257
 
@@ -4276,10 +4261,10 @@ class CsrfPreventionInterceptor {
4276
4261
  headers: request.headers.set('X-Requested-With', 'XMLHttpRequest'),
4277
4262
  }));
4278
4263
  }
4279
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CsrfPreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4280
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CsrfPreventionInterceptor }); }
4264
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CsrfPreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4265
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CsrfPreventionInterceptor }); }
4281
4266
  }
4282
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: CsrfPreventionInterceptor, decorators: [{
4267
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: CsrfPreventionInterceptor, decorators: [{
4283
4268
  type: Injectable
4284
4269
  }] });
4285
4270
 
@@ -4298,7 +4283,7 @@ class EuLoginSessionTimeoutHandlingInterceptor {
4298
4283
  checkRequestSuccessForEULoginSessionTimeout(request, event) {
4299
4284
  if (event instanceof HttpResponse) {
4300
4285
  if (this.isSsoResponse(event.body)) {
4301
- this.reauthenticate(request, event);
4286
+ this.reauthenticate();
4302
4287
  }
4303
4288
  }
4304
4289
  }
@@ -4341,13 +4326,13 @@ class EuLoginSessionTimeoutHandlingInterceptor {
4341
4326
  return false;
4342
4327
  }
4343
4328
  }
4344
- reauthenticate(request, response) {
4329
+ reauthenticate() {
4345
4330
  document.location.reload();
4346
4331
  }
4347
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4348
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor }); }
4332
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4333
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor }); }
4349
4334
  }
4350
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, decorators: [{
4335
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, decorators: [{
4351
4336
  type: Injectable
4352
4337
  }] });
4353
4338
 
@@ -4366,15 +4351,15 @@ class UxRequestErrorModelInterceptor {
4366
4351
  return of(err);
4367
4352
  }));
4368
4353
  }
4369
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxRequestErrorModelInterceptor, deps: [{ token: UX_ERROR_MAPPING_HANDLER_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
4370
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxRequestErrorModelInterceptor }); }
4354
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UxRequestErrorModelInterceptor, deps: [{ token: UX_ERROR_MAPPING_HANDLER_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable }); }
4355
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UxRequestErrorModelInterceptor }); }
4371
4356
  }
4372
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: UxRequestErrorModelInterceptor, decorators: [{
4357
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: UxRequestErrorModelInterceptor, decorators: [{
4373
4358
  type: Injectable
4374
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
4359
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
4375
4360
  type: Inject,
4376
4361
  args: [UX_ERROR_MAPPING_HANDLER_TOKEN]
4377
- }] }]; } });
4362
+ }] }] });
4378
4363
 
4379
4364
  class OpenIdConnectInterceptor {
4380
4365
  constructor() {
@@ -4391,6 +4376,7 @@ class OpenIdConnectInterceptor {
4391
4376
  if (!authorizedRequest) {
4392
4377
  authorizedRequest = new Subject();
4393
4378
  }
4379
+ let subscription = null;
4394
4380
  OpenIdConnect.getAuthorizationHeaders(request.urlWithParams, (headers) => {
4395
4381
  let newRequest = request;
4396
4382
  if (headers) {
@@ -4413,7 +4399,6 @@ class OpenIdConnectInterceptor {
4413
4399
  }
4414
4400
  // Don't mix the next line with the line below it.
4415
4401
  // We would get a "Cannot access 'subscription' before initialization" error.
4416
- let subscription = null;
4417
4402
  subscription = next
4418
4403
  .handle(newRequest)
4419
4404
  .pipe(catchError((response) => this.handleErrorResponse(response, request, next, retryCount, authorizedRequest, subscription)))
@@ -4438,7 +4423,12 @@ class OpenIdConnectInterceptor {
4438
4423
  }
4439
4424
  return this.handleErrorResponse(new HttpErrorResponse(errorProperties), request, next, retryCount, authorizedRequest, null);
4440
4425
  });
4441
- return authorizedRequest;
4426
+ // EUI-3992 will cancel the xhr request when observable is unsubscribed from or terminated
4427
+ return authorizedRequest.pipe(finalize(() => {
4428
+ if (subscription) {
4429
+ subscription.unsubscribe();
4430
+ }
4431
+ }));
4442
4432
  }
4443
4433
  else {
4444
4434
  return next.handle(request);
@@ -4513,12 +4503,12 @@ class OpenIdConnectInterceptor {
4513
4503
  return this.defaultMaximumRequestRetries;
4514
4504
  }
4515
4505
  }
4516
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: OpenIdConnectInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4517
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: OpenIdConnectInterceptor }); }
4506
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: OpenIdConnectInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4507
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: OpenIdConnectInterceptor }); }
4518
4508
  }
4519
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: OpenIdConnectInterceptor, decorators: [{
4509
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: OpenIdConnectInterceptor, decorators: [{
4520
4510
  type: Injectable
4521
- }], ctorParameters: function () { return []; } });
4511
+ }], ctorParameters: () => [] });
4522
4512
 
4523
4513
  class OpenIdConnectService {
4524
4514
  constructor() {
@@ -4563,15 +4553,15 @@ class OpenIdConnectService {
4563
4553
  getUserDetails() {
4564
4554
  return this.userDetails;
4565
4555
  }
4566
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: OpenIdConnectService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4567
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: OpenIdConnectService, providedIn: 'root' }); }
4556
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: OpenIdConnectService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4557
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: OpenIdConnectService, providedIn: 'root' }); }
4568
4558
  }
4569
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: OpenIdConnectService, decorators: [{
4559
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-rc.0", ngImport: i0, type: OpenIdConnectService, decorators: [{
4570
4560
  type: Injectable,
4571
4561
  args: [{
4572
4562
  providedIn: 'root',
4573
4563
  }]
4574
- }], ctorParameters: function () { return []; } });
4564
+ }], ctorParameters: () => [] });
4575
4565
 
4576
4566
  class OpenIdConnectServiceMock extends OpenIdConnectService {
4577
4567
  getUserDetails() {
@@ -4585,5 +4575,5 @@ class OpenIdConnectServiceMock extends OpenIdConnectService {
4585
4575
  * Generated bundle index. Do not edit.
4586
4576
  */
4587
4577
 
4588
- export { ActivatedRouteAction, AddApiQueueItemAction, AddAppLoadedConfigModulesAction, AddLangParamInterceptor, AlertHttpErrorCallbackFn, ApiQueueService, ApiQueueServiceMock, AsyncStorageService, AsyncStorageServiceMock, BASE_LOGGER_NAME_TOKEN, BASE_NAME_TOKEN, BrowserStorageType, CONFIG_TOKEN, CORE_ROOT_GUARD, CachePreventionInterceptor, ConsoleHttpErrorCallbackFn, CoreAppActionTypes, CoreAppEffects, CoreI18nActionTypes, CoreLocaleActionTypes, CoreModule, CoreModuleEffects, CoreNotificationsActionTypes, CoreUserActionTypes, CorsSecurityInterceptor, CsrfPreventionInterceptor, DYNAMIC_COMPONENT_CONFIG, EUI_CONFIG_TOKEN, EUI_COUNTRIES, EUI_TIMEZONES, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiCoreRootGuardClass, EuiDynamicMenuService, EuiError, EuiPermissionService, EuiTimezoneService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService, I18nServiceMock, InitStoreAction, LANG_PARAM_KEY, LOCALE_ID_MAPPER, LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, LOG_APPENDERS_TOKEN, LOG_LEVEL_TOKEN, LocalForageService, LocalStorageService, LocaleService, LocaleServiceMock, LogHttpErrorCallbackFn, LogModule, LogService, LogServiceMock, MODULE_CONFIG_TOKEN, MODULE_NAME_TOKEN, OpenIdConnectInterceptor, OpenIdConnectService, OpenIdConnectServiceMock, ROOT_LOG_CONFIG_TOKEN, RemoveApiQueueItemAction, SHOW_CONNECTION_STATUS_TOKEN, SessionStorageService, StorageService, StorageServiceMock, StoreService, StoreServiceMock, UX_ERROR_MAPPING_HANDLER_TOKEN, UpdateAppConnectionAction, UpdateAppStatusAction, UpdateAppVersionAction, UpdateCurrentModuleAction, UpdateI18nStateAction, UpdateLocaleStateAction, UpdateNotificationsListAction, UpdateUserDashboardAction, UpdateUserDetailsAction, UpdateUserPreferencesAction, UpdateUserRightsAction, UpdateUserStateAction, UserService, UserServiceMock, UxAppShellService, UxDynamicComponentService, UxErrorFeedbackService, UxErrorManager, UxRequestErrorModelInterceptor, closestMatchingParent, consumeEvent, corI18nReducers, coreAppReducers, coreLocaleReducers, coreNotificationsReducers, coreUserReducers, createEuiCoreRootGuard, diffDays, diffDaysFromToday, errorCodes, euiCoreRootGuardClass, formatNumber, getGlobalConfig, getHttpErrorHandlingConfig, getModuleConfig, getRootLogConfig, getShowConnectionStatus, getViewElement, handleError, isDefined, loadEuiDynamicEnvironmentConfig, loadState, localForage, localStorageSync, markControlsTouched, markFormGroupTouched, mergeAppHandlerConfigToAppConfig, mergeAppJsonConfigToAppConfig, offset, position, preInitApp, prepareEuiAppConfigToken, coreReducers as reducers, sessionStorageSync, translateConfig, uniqueId, validateEmail, withUxErrorManager };
4578
+ export { ActivatedRouteAction, AddApiQueueItemAction, AddAppLoadedConfigModulesAction, AddLangParamInterceptor, AlertHttpErrorCallbackFn, ApiQueueService, ApiQueueServiceMock, AsyncStorageService, AsyncStorageServiceMock, BASE_LOGGER_NAME_TOKEN, BASE_NAME_TOKEN, BrowserStorageType, CONFIG_TOKEN, CORE_ROOT_GUARD, CachePreventionInterceptor, ConsoleHttpErrorCallbackFn, CoreAppActionTypes, CoreAppEffects, CoreI18nActionTypes, CoreLocaleActionTypes, CoreModule, CoreModuleEffects, CoreNotificationsActionTypes, CoreUserActionTypes, CorsSecurityInterceptor, CsrfPreventionInterceptor, DYNAMIC_COMPONENT_CONFIG, EUI_CONFIG_TOKEN, EUI_COUNTRIES, EUI_TIMEZONES, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiAppShellService, EuiCoreRootGuardClass, EuiDynamicComponentService, EuiDynamicMenuService, EuiError, EuiGrowlService, EuiPermissionService, EuiTimezoneService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService, I18nServiceMock, InitStoreAction, LANG_PARAM_KEY, LOCALE_ID_MAPPER, LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, LOG_APPENDERS_TOKEN, LOG_LEVEL_TOKEN, LocalForageService, LocalStorageService, LocaleService, LocaleServiceMock, LogHttpErrorCallbackFn, LogModule, LogService, LogServiceMock, MODULE_CONFIG_TOKEN, MODULE_NAME_TOKEN, OpenIdConnectInterceptor, OpenIdConnectService, OpenIdConnectServiceMock, ROOT_LOG_CONFIG_TOKEN, RemoveApiQueueItemAction, SHOW_CONNECTION_STATUS_TOKEN, SessionStorageService, StorageService, StorageServiceMock, StoreService, StoreServiceMock, UX_ERROR_MAPPING_HANDLER_TOKEN, UpdateAppConnectionAction, UpdateAppStatusAction, UpdateAppVersionAction, UpdateCurrentModuleAction, UpdateI18nStateAction, UpdateLocaleStateAction, UpdateNotificationsListAction, UpdateUserDashboardAction, UpdateUserDetailsAction, UpdateUserPreferencesAction, UpdateUserRightsAction, UpdateUserStateAction, UserService, UserServiceMock, UxRequestErrorModelInterceptor, closestMatchingParent, consumeEvent, corI18nReducers, coreAppReducers, coreLocaleReducers, coreNotificationsReducers, coreUserReducers, createEuiCoreRootGuard, diffDays, diffDaysFromToday, errorCodes, euiCoreRootGuardClass, formatNumber, getGlobalConfig, getHttpErrorHandlingConfig, getModuleConfig, getRootLogConfig, getShowConnectionStatus, getViewElement, handleError, isDefined, loadEuiDynamicEnvironmentConfig, loadState, localForage, localStorageSync, markControlsTouched, markFormGroupTouched, mergeAppHandlerConfigToAppConfig, mergeAppJsonConfigToAppConfig, offset, position, preInitApp, prepareEuiAppConfigToken, coreReducers as reducers, sessionStorageSync, translateConfig, uniqueId, validateEmail };
4589
4579
  //# sourceMappingURL=eui-core.mjs.map