@eui/core 18.0.0-rc.4 → 18.0.0-rc.40

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 (56) hide show
  1. package/docs/classes/CssUtils.html +59 -2
  2. package/docs/dependencies.html +3 -3
  3. package/docs/index.html +1 -1
  4. package/docs/injectables/CoreAppEffects.html +24 -5
  5. package/docs/injectables/EuiAppShellService.html +13 -1
  6. package/docs/injectables/EuiDynamicMenuService.html +2 -2
  7. package/docs/injectables/EuiThemeService.html +297 -96
  8. package/docs/injectables/LocalStorageService.html +12 -1
  9. package/docs/injectables/StoreService.html +12 -1
  10. package/docs/interfaces/IEuiTheme.html +387 -0
  11. package/docs/interfaces/ThemeState.html +309 -0
  12. package/docs/js/menu-wc.js +6 -0
  13. package/docs/js/menu-wc_es5.js +1 -1
  14. package/docs/js/search/search_index.js +2 -2
  15. package/docs/miscellaneous/enumerations.html +66 -6
  16. package/docs/miscellaneous/functions.html +284 -0
  17. package/docs/miscellaneous/variables.html +119 -31
  18. package/esm2022/index.mjs +3 -1
  19. package/esm2022/lib/helpers/css-utils.mjs +74 -60
  20. package/esm2022/lib/helpers/dom-helpers.mjs +3 -9
  21. package/esm2022/lib/services/dynamic-menu/dynamic-menu.service.mjs +2 -5
  22. package/esm2022/lib/services/eui-app-shell.service.mjs +20 -16
  23. package/esm2022/lib/services/eui-theme.service.mjs +186 -26
  24. package/esm2022/lib/services/locale/locale.service.mjs +2 -1
  25. package/esm2022/lib/services/storage/local-storage.service.mjs +36 -25
  26. package/esm2022/lib/services/store/effects/app.effects.mjs +19 -7
  27. package/esm2022/lib/services/store/reducers/meta.reducers.mjs +46 -32
  28. package/esm2022/lib/services/store/store.service.mjs +17 -9
  29. package/esm2022/lib/services/store/store.service.mock.mjs +3 -2
  30. package/fesm2022/eui-core.mjs +403 -194
  31. package/fesm2022/eui-core.mjs.map +1 -1
  32. package/index.d.ts +1 -0
  33. package/index.d.ts.map +1 -1
  34. package/lib/helpers/css-utils.d.ts +24 -18
  35. package/lib/helpers/css-utils.d.ts.map +1 -1
  36. package/lib/helpers/dom-helpers.d.ts +1 -1
  37. package/lib/helpers/dom-helpers.d.ts.map +1 -1
  38. package/lib/services/dynamic-menu/dynamic-menu.service.d.ts +5 -5
  39. package/lib/services/dynamic-menu/dynamic-menu.service.d.ts.map +1 -1
  40. package/lib/services/eui-app-shell.service.d.ts +3 -2
  41. package/lib/services/eui-app-shell.service.d.ts.map +1 -1
  42. package/lib/services/eui-theme.service.d.ts +41 -15
  43. package/lib/services/eui-theme.service.d.ts.map +1 -1
  44. package/lib/services/locale/locale.service.d.ts +1 -0
  45. package/lib/services/locale/locale.service.d.ts.map +1 -1
  46. package/lib/services/storage/local-storage.service.d.ts +3 -2
  47. package/lib/services/storage/local-storage.service.d.ts.map +1 -1
  48. package/lib/services/store/effects/app.effects.d.ts +2 -1
  49. package/lib/services/store/effects/app.effects.d.ts.map +1 -1
  50. package/lib/services/store/reducers/meta.reducers.d.ts +11 -1
  51. package/lib/services/store/reducers/meta.reducers.d.ts.map +1 -1
  52. package/lib/services/store/store.service.d.ts +3 -2
  53. package/lib/services/store/store.service.d.ts.map +1 -1
  54. package/lib/services/store/store.service.mock.d.ts +1 -0
  55. package/lib/services/store/store.service.mock.d.ts.map +1 -1
  56. package/package.json +4 -4
@@ -1,19 +1,20 @@
1
+ import * as i1 from '@eui/base';
2
+ import { LogLevel, ConsoleAppender, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, Logger, LoggerMock, xhr, getApiQueue, getApiQueueItem, mergeAll, getI18nLoaderConfig, EuiLazyService, getI18nServiceConfigFromBase, getI18nState, getLastAddedModule, getBrowserDefaultLanguage, EuiEuLanguages, getActiveLang, EuiService, getUserRights, getUserState, getLocaleServiceConfigFromBase, getLocaleState, transformToUxHttpResponse } from '@eui/base';
3
+ export * from '@eui/base';
1
4
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Inject, Injector, NgModule, Optional, APP_INITIALIZER, SkipSelf, ErrorHandler, PLATFORM_ID, LOCALE_ID } from '@angular/core';
5
+ import { InjectionToken, Injectable, PLATFORM_ID, Inject, inject, Injector, NgModule, Optional, APP_INITIALIZER, SkipSelf, ErrorHandler, LOCALE_ID } from '@angular/core';
3
6
  import * as extendProxy from 'extend';
4
- import * as i1$2 from '@eui/base';
5
- import { LogLevel, ConsoleAppender, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, Logger, LoggerMock, xhr, getApiQueue, getApiQueueItem, mergeAll, getI18nLoaderConfig, EuiLazyService, getI18nServiceConfigFromBase, getI18nState, getLastAddedModule, getBrowserDefaultLanguage, EuiEuLanguages, getActiveLang, EuiService, getUserRights, getUserState, getLocaleServiceConfigFromBase, getLocaleState, transformToUxHttpResponse } from '@eui/base';
6
- import * as i1 from '@ngrx/effects';
7
+ import * as i1$1 from '@ngrx/effects';
7
8
  import { createEffect, ofType } from '@ngrx/effects';
8
- import { merge, fromEvent, throwError, of, forkJoin, from, BehaviorSubject, defer, firstValueFrom, ReplaySubject, map as map$1, Subject } from 'rxjs';
9
+ import { merge, fromEvent, of, throwError, forkJoin, from, BehaviorSubject, defer, firstValueFrom, Subject } from 'rxjs';
9
10
  import { mapTo, map, mergeMap, tap, debounceTime, distinctUntilChanged, take, switchMap, catchError, concatMap, filter, takeUntil } from 'rxjs/operators';
10
- import * as i1$1 from '@ngx-translate/core';
11
+ import { isPlatformBrowser, LOCATION_INITIALIZED, DOCUMENT, isPlatformServer, getLocaleId, registerLocaleData } from '@angular/common';
12
+ import * as i1$2 from '@ngx-translate/core';
11
13
  import { TranslateLoader } from '@ngx-translate/core';
12
14
  import * as i1$3 from '@ngrx/store';
13
15
  import { createSelector } from '@ngrx/store';
14
16
  import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
15
17
  import { MomentDateAdapter } from '@angular/material-moment-adapter';
16
- import { LOCATION_INITIALIZED, DOCUMENT, isPlatformBrowser, getLocaleId, registerLocaleData } from '@angular/common';
17
18
  import * as i1$5 from '@angular/common/http';
18
19
  import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
19
20
  import * as i1$4 from '@angular/router';
@@ -395,12 +396,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
395
396
  class CoreAppEffects {
396
397
  constructor(actions,
397
398
  // TODO: remove on eUI 14
398
- showConnectionStatus, translateService, asService) {
399
+ showConnectionStatus, translateService, asService, platformId) {
399
400
  this.actions = actions;
400
401
  this.showConnectionStatus = showConnectionStatus;
401
402
  this.translateService = translateService;
402
403
  this.asService = asService;
403
- this.getAppConnectionInformation = createEffect(() => merge(fromEvent(window, 'online').pipe(mapTo(true)), fromEvent(window, 'offline').pipe(mapTo(false))).pipe(map((connected) => new UpdateAppConnectionAction(connected))));
404
+ this.platformId = platformId;
405
+ this.getAppConnectionInformation = createEffect(() => {
406
+ if (isPlatformBrowser(this.platformId)) {
407
+ return merge(fromEvent(window, 'online').pipe(mapTo(true)), fromEvent(window, 'offline').pipe(mapTo(false))).pipe(map((connected) => new UpdateAppConnectionAction(connected)));
408
+ }
409
+ else {
410
+ return of(new UpdateAppConnectionAction(false));
411
+ }
412
+ });
404
413
  this.activatedRoute = createEffect(() => this.actions.pipe(ofType(CoreAppActionTypes.ACTIVATED_ROUTE), map((action) => action.payload), mergeMap((route) => {
405
414
  // extract the module name, if defined
406
415
  const module = route.snapshot.data['module'] || 'undefined';
@@ -427,15 +436,18 @@ class CoreAppEffects {
427
436
  }
428
437
  })), { dispatch: false });
429
438
  }
430
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i1$1.TranslateService }, { token: EuiGrowlService }], target: i0.ɵɵFactoryTarget.Injectable }); }
439
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$1.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i1$2.TranslateService }, { token: EuiGrowlService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
431
440
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: CoreAppEffects }); }
432
441
  }
433
442
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: CoreAppEffects, decorators: [{
434
443
  type: Injectable
435
- }], ctorParameters: () => [{ type: i1.Actions }, { type: undefined, decorators: [{
444
+ }], ctorParameters: () => [{ type: i1$1.Actions }, { type: undefined, decorators: [{
436
445
  type: Inject,
437
446
  args: [SHOW_CONNECTION_STATUS_TOKEN]
438
- }] }, { type: i1$1.TranslateService }, { type: EuiGrowlService }] });
447
+ }] }, { type: i1$2.TranslateService }, { type: EuiGrowlService }, { type: undefined, decorators: [{
448
+ type: Inject,
449
+ args: [PLATFORM_ID]
450
+ }] }] });
439
451
 
440
452
  const CoreModuleEffects = [CoreAppEffects];
441
453
 
@@ -586,19 +598,27 @@ const coreReducers = Object.assign({}, {
586
598
  // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
587
599
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
588
600
  const extend = extendProxy.default || extendProxy;
589
- /**
590
- * Utility meta-reducer to load the state from the local storage
591
- * @param reducer the action reducer
592
- */
593
- function localStorageSync(reducer) {
594
- return cb(reducer, localStorage);
601
+ function localStorageSync(reducer, platformId) {
602
+ if (platformId) {
603
+ return (reducer) => {
604
+ return cb(reducer, isPlatformBrowser(platformId) ? localStorage : null);
605
+ };
606
+ }
607
+ else {
608
+ const platformId = inject(PLATFORM_ID, { optional: true });
609
+ return cb(reducer, isPlatformBrowser(platformId) ? localStorage : null);
610
+ }
595
611
  }
596
- /**
597
- * Utility meta-reducer to load the state from the session storage
598
- * @param reducer the action reducer
599
- */
600
- function sessionStorageSync(reducer) {
601
- return cb(reducer, sessionStorage);
612
+ function sessionStorageSync(reducer, platformId) {
613
+ if (platformId) {
614
+ return (reducer) => {
615
+ return cb(reducer, isPlatformBrowser(platformId) ? sessionStorage : null);
616
+ };
617
+ }
618
+ else {
619
+ const platformId = inject(PLATFORM_ID, { optional: true });
620
+ return cb(reducer, isPlatformBrowser(platformId) ? sessionStorage : null);
621
+ }
602
622
  }
603
623
  // Keys that are allowed to be synced with NgRx state from BrowserStorage
604
624
  const disallowedKeys = ['loadedConfigModules', 'connect', 'currentModule', 'status', 'apiQueue'];
@@ -625,6 +645,9 @@ const filterAppState = (app) => {
625
645
  * @param storage Type of storage to load the state from
626
646
  */
627
647
  const loadState = (storage = localStorage) => {
648
+ if (!storage) {
649
+ return undefined;
650
+ }
628
651
  try {
629
652
  // by default falls back to localStorage
630
653
  const serializedState = storage.getItem('state');
@@ -647,26 +670,27 @@ const cb = (reducer, storage) => (state, action) => {
647
670
  // We load the state from a storage and compare the version and userId with the provided ones.
648
671
  // If they are the same, we merge the local state into the initial state.
649
672
  // If there is a mismatch, we don't merge the local state, but update only the initial state.
650
- // load the state from the localStorage
651
- const localState = loadState(storage);
652
- // extract the details about user and app version from the action payload
653
- const payload = action.payload;
654
- const payloadVersion = payload?.version;
655
- if (localState) {
656
- // TODO: Why all these checks here? What is the purpose of this code?
657
- // extract the details about user and app version from the storage state
658
- const localVersion = localState?.app?.version;
659
- // const localUserId = localState.user && localState.user.userId;
660
- const isVersionOK = !localVersion || !payloadVersion || localVersion === payloadVersion;
661
- // const isUserIdOK = (localUserId === payloadUserId);
662
- // update the entire state with deep merge of states, if the version and user are the same
663
- if (isVersionOK) {
664
- state = extend(true, {}, state, localState);
673
+ if (storage) {
674
+ // load the state from the localStorage
675
+ const localState = loadState(storage);
676
+ // extract the details about user and app version from the action payload
677
+ const payloadVersion = action.payload?.version;
678
+ if (localState) {
679
+ // TODO: Why all these checks here? What is the purpose of this code?
680
+ // extract the details about user and app version from the storage state
681
+ const localVersion = localState?.app?.version;
682
+ // const localUserId = localState.user && localState.user.userId;
683
+ const isVersionOK = !localVersion || !payloadVersion || localVersion === payloadVersion;
684
+ // const isUserIdOK = (localUserId === payloadUserId);
685
+ // update the entire state with deep merge of states, if the version and user are the same
686
+ if (isVersionOK) {
687
+ state = extend(true, {}, state, localState);
688
+ }
689
+ }
690
+ // update the app version, if defined
691
+ if (payloadVersion) {
692
+ state = { ...state, app: { ...state?.app, version: payloadVersion } };
665
693
  }
666
- }
667
- // update the app version, if defined
668
- if (payloadVersion) {
669
- state = { ...state, app: { ...state?.app, version: payloadVersion } };
670
694
  }
671
695
  }
672
696
  return reducer(state, action);
@@ -711,7 +735,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
711
735
  }], ctorParameters: () => [{ type: undefined, decorators: [{
712
736
  type: Inject,
713
737
  args: [BASE_LOGGER_NAME_TOKEN]
714
- }] }, { type: i1$2.LogLevel, decorators: [{
738
+ }] }, { type: i1.LogLevel, decorators: [{
715
739
  type: Inject,
716
740
  args: [LOG_LEVEL_TOKEN]
717
741
  }] }, { type: undefined, decorators: [{
@@ -820,23 +844,27 @@ var BrowserStorageType;
820
844
  // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
821
845
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
822
846
  class StoreService {
823
- constructor(store, logService) {
847
+ constructor(store, logService, platformId) {
824
848
  this.store = store;
825
849
  this.logService = logService;
850
+ this.platformId = platformId;
826
851
  /**
827
852
  * autoSave handlers to call before saving in local Storage
828
853
  */
829
854
  this._autoSaveHandlers = {};
830
- /** storage instance e.g. localStorage, sessionStorage */
831
- this._storage = localStorage;
855
+ if (isPlatformBrowser(this.platformId)) {
856
+ this._storage = localStorage;
857
+ }
832
858
  }
833
859
  // use init with just version info, to update to user state, UserService.updateState
834
860
  // initializeStore(version?: string, userDetails?: BaseUserDetails) {
835
861
  // this.dispatch(new InitStoreAction({ version, userDetails }));
836
862
  // }
837
863
  init(version, storageType) {
838
- this.dispatch(new InitStoreAction({ version }));
839
- this._storage = storageType === BrowserStorageType.session ? sessionStorage : localStorage;
864
+ if (isPlatformBrowser(this.platformId)) {
865
+ this.dispatch(new InitStoreAction({ version }));
866
+ this._storage = storageType === BrowserStorageType.session ? sessionStorage : localStorage;
867
+ }
840
868
  }
841
869
  addAutoSaveHandler(stateSlice, handler) {
842
870
  if (!this.store) {
@@ -904,13 +932,13 @@ class StoreService {
904
932
  });
905
933
  try {
906
934
  const serializedState = JSON.stringify(stateToSave);
907
- this._storage.setItem('state', serializedState);
935
+ this._storage?.setItem('state', serializedState);
908
936
  }
909
937
  catch (err) {
910
938
  // Ignore write errors.
911
939
  }
912
940
  }
913
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: StoreService, deps: [{ token: i1$3.Store, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
941
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: StoreService, deps: [{ token: i1$3.Store, optional: true }, { token: LogService, optional: true }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
914
942
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: StoreService, providedIn: 'root' }); }
915
943
  }
916
944
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: StoreService, decorators: [{
@@ -922,11 +950,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
922
950
  type: Optional
923
951
  }] }, { type: LogService, decorators: [{
924
952
  type: Optional
953
+ }] }, { type: undefined, decorators: [{
954
+ type: Inject,
955
+ args: [PLATFORM_ID]
925
956
  }] }] });
926
957
 
958
+ const PLATFORM_BROWSER_ID = 'browser';
927
959
  class StoreServiceMock extends StoreService {
928
960
  constructor() {
929
- super(null, null);
961
+ super(null, null, PLATFORM_BROWSER_ID);
930
962
  }
931
963
  init() { }
932
964
  addAutoSaveHandler() { }
@@ -2044,7 +2076,7 @@ class I18nService extends EuiLazyService {
2044
2076
  updateHTMLDOMLang(lang) {
2045
2077
  this.document.documentElement.lang = lang;
2046
2078
  }
2047
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i1$1.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
2079
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i1$2.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
2048
2080
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: I18nService, providedIn: 'root' }); }
2049
2081
  }
2050
2082
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: I18nService, decorators: [{
@@ -2055,7 +2087,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
2055
2087
  }], ctorParameters: () => [{ type: undefined, decorators: [{
2056
2088
  type: Inject,
2057
2089
  args: [GLOBAL_CONFIG_TOKEN]
2058
- }] }, { type: i1$1.TranslateService }, { type: LogService, decorators: [{
2090
+ }] }, { type: i1$2.TranslateService }, { type: LogService, decorators: [{
2059
2091
  type: Optional
2060
2092
  }] }, { type: StoreService }, { type: Document, decorators: [{
2061
2093
  type: Inject,
@@ -2102,16 +2134,10 @@ const offset = (nativeEl) => {
2102
2134
  };
2103
2135
  };
2104
2136
  // PRIVATE FUNCTIONS
2105
- // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
2106
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2107
2137
  const getStyle = (nativeEl, cssProp) => {
2108
- // IE
2109
2138
  /* istanbul ignore if */
2110
- if (nativeEl.currentStyle) {
2111
- return nativeEl.currentStyle[cssProp];
2112
- }
2113
- if (window.getComputedStyle) {
2114
- return window.getComputedStyle(nativeEl)[cssProp];
2139
+ if (getComputedStyle(nativeEl)) {
2140
+ return getComputedStyle(nativeEl)[cssProp];
2115
2141
  }
2116
2142
  // finally try and get inline style
2117
2143
  /* istanbul ignore next */
@@ -2303,113 +2329,126 @@ const handleError = (error) => {
2303
2329
  const isDefined = (value) => value !== undefined && value !== null;
2304
2330
 
2305
2331
  class CssUtils {
2306
- static { this.getCssVarValue = (inputProperty) => {
2307
- return getComputedStyle(document.documentElement).getPropertyValue(inputProperty);
2332
+ /**
2333
+ * Get the value of a CSS variable. Using getComputedStyle to get the value of the CSS variable (Browser Specific API)
2334
+ * @param inputProperty
2335
+ * @param document
2336
+ * @param platform
2337
+ */
2338
+ static { this.getCssVarValue = (inputProperty, document, platform) => {
2339
+ if (isPlatformServer(platform)) {
2340
+ return document.documentElement.style.getPropertyValue(inputProperty);
2341
+ }
2342
+ else {
2343
+ return getComputedStyle(document.documentElement).getPropertyValue(inputProperty);
2344
+ }
2308
2345
  }; }
2309
- static { this.setCssVarValue = (propertyName, propertyValue) => {
2346
+ static { this.setCssVarValue = (propertyName, propertyValue, document) => {
2310
2347
  document.documentElement.style.setProperty(propertyName, propertyValue);
2311
2348
  }; }
2312
- static { this.setCssVar = (inputProperty, outputProperty) => {
2313
- const cssVarValue = this.getCssVarValue(inputProperty);
2314
- this.setCssVarValue(outputProperty, cssVarValue);
2349
+ static { this.setCssVar = (inputProperty, outputProperty, document, platform) => {
2350
+ const cssVarValue = this.getCssVarValue(inputProperty, document, platform);
2351
+ this.setCssVarValue(outputProperty, cssVarValue, document);
2315
2352
  }; }
2316
- static { this.initCssVars = () => {
2317
- this.setCssVar('--eui-app-header-height-default', '--eui-app-header-height');
2318
- this.setCssVar('--eui-app-breadcrumb-height-default', '--eui-app-breadcrumb-height');
2319
- this.setCssVar('--eui-app-top-message-height-default', '--eui-app-top-message-height');
2320
- this.setCssVar('--eui-app-toolbar-height-default', '--eui-app-toolbar-height');
2321
- this.setCssVar('--eui-app-sidebar-width-default', '--eui-app-sidebar-width');
2322
- this.setCssVar('--eui-app-sidebar-width-close-default', '--eui-app-sidebar-width-close');
2323
- this.setCssVar('--eui-app-sidebar-header-height-default', '--eui-app-sidebar-header-height');
2324
- this.setCssVar('--eui-app-sidebar-footer-height-default', '--eui-app-sidebar-footer-height');
2353
+ static { this.initCssVars = (document, platform) => {
2354
+ this.setCssVar('--eui-app-header-height-default', '--eui-app-header-height', document, platform);
2355
+ this.setCssVar('--eui-app-breadcrumb-height-default', '--eui-app-breadcrumb-height', document, platform);
2356
+ this.setCssVar('--eui-app-top-message-height-default', '--eui-app-top-message-height', document, platform);
2357
+ this.setCssVar('--eui-app-toolbar-height-default', '--eui-app-toolbar-height', document, platform);
2358
+ this.setCssVar('--eui-app-sidebar-width-default', '--eui-app-sidebar-width', document, platform);
2359
+ this.setCssVar('--eui-app-sidebar-width-close-default', '--eui-app-sidebar-width-close', document, platform);
2360
+ this.setCssVar('--eui-app-sidebar-header-height-default', '--eui-app-sidebar-header-height', document, platform);
2361
+ this.setCssVar('--eui-app-sidebar-footer-height-default', '--eui-app-sidebar-footer-height', document, platform);
2325
2362
  }; }
2326
2363
  // eslint-disable-next-line
2327
- static { this.getBreakpointValues = () => {
2364
+ static { this.getBreakpointValues = (document, platform) => {
2328
2365
  const breakpoints = [];
2329
- const xs = this.getCssVarValue('--eui-bp-xs');
2366
+ const xs = this.getCssVarValue('--eui-bp-xs', document, platform);
2330
2367
  breakpoints.push({ bkp: 'xs', pxValue: xs, value: xs.replace('px', '') });
2331
- const sm = this.getCssVarValue('--eui-bp-sm');
2368
+ const sm = this.getCssVarValue('--eui-bp-sm', document, platform);
2332
2369
  breakpoints.push({ bkp: 'sm', pxValue: sm, value: sm.replace('px', '') });
2333
- const md = this.getCssVarValue('--eui-bp-md');
2370
+ const md = this.getCssVarValue('--eui-bp-md', document, platform);
2334
2371
  breakpoints.push({ bkp: 'md', pxValue: md, value: md.replace('px', '') });
2335
- const lg = this.getCssVarValue('--eui-bp-lg');
2372
+ const lg = this.getCssVarValue('--eui-bp-lg', document, platform);
2336
2373
  breakpoints.push({ bkp: 'lg', pxValue: lg, value: lg.replace('px', '') });
2337
- const xl = this.getCssVarValue('--eui-bp-xl');
2374
+ const xl = this.getCssVarValue('--eui-bp-xl', document, platform);
2338
2375
  breakpoints.push({ bkp: 'xl', pxValue: xl, value: xl.replace('px', '') });
2339
- const xxl = this.getCssVarValue('--eui-bp-xxl');
2376
+ const xxl = this.getCssVarValue('--eui-bp-xxl', document, platform);
2340
2377
  breakpoints.push({ bkp: 'xxl', pxValue: xxl, value: xxl.replace('px', '') });
2341
- const fhd = this.getCssVarValue('--eui-bp-fhd');
2378
+ const fhd = this.getCssVarValue('--eui-bp-fhd', document, platform);
2342
2379
  breakpoints.push({ bkp: 'fhd', pxValue: fhd, value: fhd.replace('px', '') });
2343
- const twok = this.getCssVarValue('--eui-bp-2k');
2380
+ const twok = this.getCssVarValue('--eui-bp-2k', document, platform);
2344
2381
  breakpoints.push({ bkp: '2k', pxValue: twok, value: twok.replace('px', '') });
2345
- const fourk = this.getCssVarValue('--eui-bp-4k');
2382
+ const fourk = this.getCssVarValue('--eui-bp-4k', document, platform);
2346
2383
  breakpoints.push({ bkp: '4k', pxValue: fourk, value: fourk.replace('px', '') });
2347
2384
  return breakpoints;
2348
2385
  }; }
2349
- static { this.activateEditModeCssVars = (isActive) => {
2386
+ static { this.activateEditModeCssVars = (isActive, document) => {
2350
2387
  if (isActive) {
2351
- this.setCssVarValue('--eui-docpage-navigation-z-index', 'inherit'); // Reset doc-page-navigation-column z-index
2352
- this.setCssVarValue('--eui-z-index-sidebar', 'inherit'); // Reset eui-app-sidebar z-index
2353
- this.setCssVarValue('--eui-z-index-root', 'inherit'); // Reset eui-app-main-content z-index
2388
+ this.setCssVarValue('--eui-docpage-navigation-z-index', 'inherit', document); // Reset doc-page-navigation-column z-index
2389
+ this.setCssVarValue('--eui-z-index-sidebar', 'inherit', document); // Reset eui-app-sidebar z-index
2390
+ this.setCssVarValue('--eui-z-index-root', 'inherit', document); // Reset eui-app-main-content z-index
2354
2391
  }
2355
2392
  else {
2356
- this.setCssVarValue('--eui-docpage-navigation-z-index', '2'); // Restore doc-page-navigation-column z-index
2357
- this.setCssVarValue('--eui-z-index-sidebar', '1044'); // Restore eui-app-sidebar z-index
2358
- this.setCssVarValue('--eui-z-index-root', '1'); // Restore eui-app-main-content z-index
2393
+ this.setCssVarValue('--eui-docpage-navigation-z-index', '2', document); // Restore doc-page-navigation-column z-index
2394
+ this.setCssVarValue('--eui-z-index-sidebar', '1044', document); // Restore eui-app-sidebar z-index
2395
+ this.setCssVarValue('--eui-z-index-root', '1', document); // Restore eui-app-main-content z-index
2359
2396
  }
2360
2397
  }; }
2361
- static { this.activateHeaderCssVars = () => {
2362
- this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
2398
+ static { this.activateHeaderCssVars = (document, platform) => {
2399
+ this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height', document, platform);
2363
2400
  }; }
2364
- static { this.activateBreadcrumbCssVars = () => {
2365
- this.setCssVar('--eui-app-breadcrumb-height-active', '--eui-app-breadcrumb-height');
2401
+ static { this.activateBreadcrumbCssVars = (document, platform) => {
2402
+ this.setCssVar('--eui-app-breadcrumb-height-active', '--eui-app-breadcrumb-height', document, platform);
2366
2403
  }; }
2367
- static { this.activateTopMessageCssVars = (height) => {
2368
- this.setCssVarValue('--eui-app-top-message-height', `${height}px`);
2404
+ static { this.activateTopMessageCssVars = (height, document) => {
2405
+ this.setCssVarValue('--eui-app-top-message-height', `${height}px`, document);
2369
2406
  }; }
2370
- static { this.activateToolbarCssVars = () => {
2371
- this.setCssVar('--eui-app-toolbar-height-active', '--eui-app-toolbar-height');
2407
+ static { this.activateToolbarCssVars = (document, platform) => {
2408
+ this.setCssVar('--eui-app-toolbar-height-active', '--eui-app-toolbar-height', document, platform);
2372
2409
  }; }
2373
- static { this.activateFooterCssVars = () => {
2374
- this.setCssVar('--eui-app-footer-height-active', '--eui-app-footer-height');
2410
+ static { this.activateFooterCssVars = (document, platform) => {
2411
+ this.setCssVar('--eui-app-footer-height-active', '--eui-app-footer-height', document, platform);
2375
2412
  }; }
2376
- static { this.setHeaderShrinkCssVar = (active) => {
2413
+ static { this.setHeaderShrinkCssVar = (active, document, platform) => {
2377
2414
  if (active) {
2378
- this.setCssVar('--eui-app-header-height-shrink', '--eui-app-header-height');
2415
+ this.setCssVar('--eui-app-header-height-shrink', '--eui-app-header-height', document, platform);
2379
2416
  }
2380
2417
  else {
2381
- this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
2418
+ this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height', document, platform);
2382
2419
  }
2383
2420
  }; }
2384
- static { this.activateSidebarCssVars = () => {
2385
- this.setCssVar('--eui-app-sidebar-width-active', '--eui-app-sidebar-width');
2386
- this.setCssVar('--eui-app-sidebar-width-close-active', '--eui-app-sidebar-width-close');
2421
+ static { this.activateSidebarCssVars = (document, platform) => {
2422
+ this.setCssVar('--eui-app-sidebar-width-active', '--eui-app-sidebar-width', document, platform);
2423
+ this.setCssVar('--eui-app-sidebar-width-close-active', '--eui-app-sidebar-width-close', document, platform);
2387
2424
  }; }
2388
- static { this.removeSidebarCssVars = () => {
2425
+ static { this.removeSidebarCssVars = (document) => {
2389
2426
  document.documentElement.style.removeProperty('--eui-app-sidebar-header-height');
2390
2427
  document.documentElement.style.removeProperty('--eui-app-sidebar-footer-height');
2391
2428
  document.documentElement.style.removeProperty('--eui-app-sidebar-width');
2392
2429
  document.documentElement.style.removeProperty('--eui-app-sidebar-width-close');
2393
2430
  }; }
2394
- static { this.activateSidebarHeaderCssVars = () => {
2395
- this.setCssVar('--eui-app-sidebar-header-height-active', '--eui-app-sidebar-header-height');
2431
+ static { this.activateSidebarHeaderCssVars = (document, platform) => {
2432
+ this.setCssVar('--eui-app-sidebar-header-height-active', '--eui-app-sidebar-header-height', document, platform);
2396
2433
  }; }
2397
- static { this.activateSidebarFooterCssVars = () => {
2398
- this.setCssVar('--eui-app-sidebar-footer-height-active', '--eui-app-sidebar-footer-height');
2434
+ static { this.activateSidebarFooterCssVars = (document, platform) => {
2435
+ this.setCssVar('--eui-app-sidebar-footer-height-active', '--eui-app-sidebar-footer-height', document, platform);
2399
2436
  }; }
2400
2437
  /**
2401
- * Gets the viewport height and width and multiple it by 1% to get a value for a vh/vw unit
2438
+ * Gets the viewport height and width and multiply it by 1% to get a value for a vh/vw unit
2402
2439
  * Sets the value in the --eui-app-vh custom property to the root of the document
2403
2440
  * Sets the value in the --eui-app-vw custom property to the root of the document
2404
2441
  * Example for 100% height: calc(var(--eui-app-vh, 1vh) * 100);
2405
2442
  * Example for 50% height: calc(var(--eui-app-vh, 1vh) * 50);
2406
2443
  * Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
2407
2444
  */
2408
- static setAppViewportCssVars() {
2409
- const vh = window.innerHeight * 0.01;
2410
- const vw = window.innerWidth * 0.01;
2411
- this.setCssVarValue('--eui-app-vh', `${vh}px`);
2412
- this.setCssVarValue('--eui-app-vw', `${vw}px`);
2445
+ static setAppViewportCssVars(platform) {
2446
+ if (isPlatformBrowser(platform)) {
2447
+ const vh = window.innerHeight * 0.01;
2448
+ const vw = window.innerWidth * 0.01;
2449
+ this.setCssVarValue('--eui-app-vh', `${vh}px`, document);
2450
+ this.setCssVarValue('--eui-app-vw', `${vw}px`, document);
2451
+ }
2413
2452
  }
2414
2453
  }
2415
2454
 
@@ -2650,11 +2689,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
2650
2689
  type: Optional
2651
2690
  }] }, { type: StoreService }] });
2652
2691
 
2653
- // TODO: Type of LINK should be UxLink or something relevant. Do we need that service anymore?
2654
- // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
2655
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2656
2692
  class EuiDynamicMenuService {
2657
- // TODO: it should be moved euiservice, or it should be static
2693
+ // TODO: it should be moved euiService, or it should be static
2658
2694
  // TODO: can we moved that service inside the module of the component that's using it?
2659
2695
  constructor(euiPermission, store) {
2660
2696
  this.euiPermission = euiPermission;
@@ -2779,7 +2815,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
2779
2815
  type: Injectable
2780
2816
  }], ctorParameters: () => [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i0.ApplicationRef }] });
2781
2817
 
2782
- const initialState = {
2818
+ const initialState$1 = {
2783
2819
  appName: '',
2784
2820
  appShortName: '',
2785
2821
  appSubTitle: '',
@@ -2895,16 +2931,17 @@ class EuiAppShellService {
2895
2931
  isDimmerActive: isActive,
2896
2932
  });
2897
2933
  }
2898
- constructor(config, http, platformId, router, storeService, i18nService) {
2934
+ constructor(config, http, platformId, document, router, storeService, i18nService) {
2899
2935
  this.config = config;
2900
2936
  this.http = http;
2901
2937
  this.platformId = platformId;
2938
+ this.document = document;
2902
2939
  this.router = router;
2903
2940
  this.storeService = storeService;
2904
2941
  this.i18nService = i18nService;
2905
- let stateWithConfig = initialState;
2906
- const languages = config?.i18n?.i18nService?.languages || initialState.languages;
2907
- const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState.activeLanguage;
2942
+ let stateWithConfig = initialState$1;
2943
+ const languages = config?.i18n?.i18nService?.languages || initialState$1.languages;
2944
+ const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState$1.activeLanguage;
2908
2945
  stateWithConfig = {
2909
2946
  ...stateWithConfig,
2910
2947
  ...{
@@ -2988,14 +3025,14 @@ class EuiAppShellService {
2988
3025
  ...this.state,
2989
3026
  isDimmerActive: !isActive,
2990
3027
  });
2991
- CssUtils.activateEditModeCssVars(!isActive);
3028
+ CssUtils.activateEditModeCssVars(!isActive, this.document);
2992
3029
  }
2993
3030
  setDimmerActiveState(activeState) {
2994
3031
  this.setState({
2995
3032
  ...this.state,
2996
3033
  isDimmerActive: activeState,
2997
3034
  });
2998
- CssUtils.activateEditModeCssVars(activeState);
3035
+ CssUtils.activateEditModeCssVars(activeState, this.document);
2999
3036
  }
3000
3037
  // --------------
3001
3038
  // public methods
@@ -3014,42 +3051,42 @@ class EuiAppShellService {
3014
3051
  hasSidebar: true,
3015
3052
  });
3016
3053
  if (!this.state.isSidebarHidden) {
3017
- CssUtils.activateSidebarCssVars();
3054
+ CssUtils.activateSidebarCssVars(this.document, this.platformId);
3018
3055
  }
3019
3056
  }
3020
3057
  activateSidebarHeader() {
3021
- CssUtils.activateSidebarHeaderCssVars();
3058
+ CssUtils.activateSidebarHeaderCssVars(this.document, this.platformId);
3022
3059
  }
3023
3060
  activateSidebarFooter() {
3024
- CssUtils.activateSidebarFooterCssVars();
3061
+ CssUtils.activateSidebarFooterCssVars(this.document, this.platformId);
3025
3062
  }
3026
3063
  activateHeader() {
3027
3064
  this.setState({
3028
3065
  ...this.state,
3029
3066
  hasHeader: true,
3030
3067
  });
3031
- CssUtils.activateHeaderCssVars();
3068
+ CssUtils.activateHeaderCssVars(this.document, this.platformId);
3032
3069
  }
3033
3070
  activateBreadcrumb() {
3034
3071
  this.setState({
3035
3072
  ...this.state,
3036
3073
  hasBreadcrumb: true,
3037
3074
  });
3038
- CssUtils.activateBreadcrumbCssVars();
3075
+ CssUtils.activateBreadcrumbCssVars(this.document, this.platformId);
3039
3076
  }
3040
3077
  activateTopMessage(height) {
3041
3078
  this.setState({
3042
3079
  ...this.state,
3043
3080
  hasTopMessage: true,
3044
3081
  });
3045
- CssUtils.activateTopMessageCssVars(height);
3082
+ CssUtils.activateTopMessageCssVars(height, this.document);
3046
3083
  }
3047
3084
  activateToolbar() {
3048
3085
  this.setState({
3049
3086
  ...this.state,
3050
3087
  hasToolbar: true,
3051
3088
  });
3052
- CssUtils.activateToolbarCssVars();
3089
+ CssUtils.activateToolbarCssVars(this.document, this.platformId);
3053
3090
  }
3054
3091
  activateToolbarMenu() {
3055
3092
  this.setState({
@@ -3061,7 +3098,7 @@ class EuiAppShellService {
3061
3098
  * Returns the current value of --eui-f-size-base CSS variable
3062
3099
  */
3063
3100
  getBaseFontSize() {
3064
- return this.state.appBaseFontSize || CssUtils.getCssVarValue('--eui-f-size-base');
3101
+ return this.state.appBaseFontSize || CssUtils.getCssVarValue('--eui-f-size-base', this.document, this.platformId);
3065
3102
  }
3066
3103
  /**
3067
3104
  * Updates the current value of --eui-f-size-base CSS variable and the UIState appBaseFontSize
@@ -3071,7 +3108,7 @@ class EuiAppShellService {
3071
3108
  ...this.state,
3072
3109
  appBaseFontSize: newsize,
3073
3110
  }, false);
3074
- CssUtils.setCssVarValue('--eui-f-size-base', newsize);
3111
+ CssUtils.setCssVarValue('--eui-f-size-base', newsize, this.document);
3075
3112
  }
3076
3113
  // ---------------
3077
3114
  // private getters
@@ -3106,7 +3143,7 @@ class EuiAppShellService {
3106
3143
  if (this.state.breakpointValues.length === 0) {
3107
3144
  this.setState({
3108
3145
  ...this.state,
3109
- breakpointValues: CssUtils.getBreakpointValues(),
3146
+ breakpointValues: CssUtils.getBreakpointValues(this.document, this.platformId),
3110
3147
  });
3111
3148
  }
3112
3149
  this.state.breakpointValues.forEach((b, i) => {
@@ -3157,7 +3194,7 @@ class EuiAppShellService {
3157
3194
  }
3158
3195
  });
3159
3196
  }
3160
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.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 }); }
3197
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$5.HttpClient }, { token: PLATFORM_ID }, { token: DOCUMENT }, { token: i1$4.Router }, { token: StoreService }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
3161
3198
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiAppShellService, providedIn: 'root' }); }
3162
3199
  }
3163
3200
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiAppShellService, decorators: [{
@@ -3173,6 +3210,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
3173
3210
  }] }, { type: i1$5.HttpClient }, { type: undefined, decorators: [{
3174
3211
  type: Inject,
3175
3212
  args: [PLATFORM_ID]
3213
+ }] }, { type: Document, decorators: [{
3214
+ type: Inject,
3215
+ args: [DOCUMENT]
3176
3216
  }] }, { type: i1$4.Router }, { type: StoreService }, { type: I18nService, decorators: [{
3177
3217
  type: Optional
3178
3218
  }] }] });
@@ -3893,46 +3933,204 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
3893
3933
 
3894
3934
  var EuiTheme;
3895
3935
  (function (EuiTheme) {
3896
- EuiTheme["EC"] = "ec";
3897
- EuiTheme["EU"] = "eu";
3898
- EuiTheme["EUI"] = "eui";
3936
+ EuiTheme["DEFAULT"] = "default";
3937
+ EuiTheme["ECL_EC"] = "ecl-ec";
3938
+ EuiTheme["ECL_EC_RTL"] = "ecl-ec-rtl";
3939
+ EuiTheme["ECL_EU"] = "ecl-eu";
3940
+ EuiTheme["ECL_EU_RTL"] = "ecl-eu-rtl";
3941
+ EuiTheme["EUI_LEGACY"] = "eui-legacy";
3942
+ EuiTheme["EUI_LEGACY_HC"] = "eui-legacy-high-contrast";
3943
+ EuiTheme["DARK"] = "dark";
3944
+ EuiTheme["COMPACT"] = "compact";
3899
3945
  })(EuiTheme || (EuiTheme = {}));
3946
+ ;
3947
+ ;
3948
+ const initialState = {
3949
+ themes: [
3950
+ { name: EuiTheme.DEFAULT, isActive: false, styleSheet: null, cssClass: null },
3951
+ { name: EuiTheme.ECL_EC, isActive: false, styleSheet: 'eui-ecl-ec.css', cssClass: null },
3952
+ { name: EuiTheme.ECL_EC_RTL, isActive: false, styleSheet: 'eui-ecl-ec-rtl.css', cssClass: null },
3953
+ { name: EuiTheme.ECL_EU, isActive: false, styleSheet: 'eui-ecl-eu.css', cssClass: null },
3954
+ { name: EuiTheme.ECL_EU_RTL, isActive: false, styleSheet: 'eui-ecl-eu-rtl.css', cssClass: null },
3955
+ { name: EuiTheme.EUI_LEGACY, isActive: false, styleSheet: null, cssClass: 'eui-t-eui-legacy' },
3956
+ { name: EuiTheme.EUI_LEGACY_HC, isActive: false, styleSheet: null, cssClass: 'eui-t-high-contrast' },
3957
+ { name: EuiTheme.DARK, isActive: false, styleSheet: null, cssClass: 'eui-t-dark' },
3958
+ { name: EuiTheme.COMPACT, isActive: false, styleSheet: null, cssClass: 'eui-t-compact' },
3959
+ ],
3960
+ theme: {
3961
+ isDefault: false,
3962
+ isEclEc: false,
3963
+ isEclEcRtl: false,
3964
+ isEclEu: false,
3965
+ isEclEuRtl: false,
3966
+ isEuiLegacy: false,
3967
+ isEuiLegacyHc: false,
3968
+ isDark: false,
3969
+ isCompact: false,
3970
+ },
3971
+ };
3900
3972
  class EuiThemeService {
3901
- constructor(config) {
3973
+ constructor(document, config, asService) {
3974
+ this.document = document;
3902
3975
  this.config = config;
3903
- this.theme = EuiTheme.EC;
3904
- this.themeSubject = new ReplaySubject();
3905
- this.theme$ = this.themeSubject.asObservable();
3906
- this.isEU$ = this.theme$.pipe(map$1((theme) => EuiTheme.EU === theme));
3907
- this.isEC$ = this.theme$.pipe(map$1((theme) => EuiTheme.EC === theme));
3908
- const theme = this.config?.eui?.theme || EuiTheme.EC;
3909
- this.setTheme(theme);
3976
+ this.asService = asService;
3977
+ this._state$ = new BehaviorSubject(initialState);
3978
+ const themeName = this.config?.eui?.theme || EuiTheme.DEFAULT;
3979
+ this.setActiveTheme(themeName, true);
3980
+ }
3981
+ get state$() {
3982
+ return this._state$.asObservable();
3983
+ }
3984
+ get state() {
3985
+ return this._state$.getValue();
3986
+ }
3987
+ isDefault() {
3988
+ return this.state.theme.isDefault;
3989
+ }
3990
+ isEclEc() {
3991
+ return this.state.theme.isEclEc;
3992
+ }
3993
+ isEclEcRtl() {
3994
+ return this.state.theme.isEclEcRtl;
3995
+ }
3996
+ isEclEu() {
3997
+ return this.state.theme.isEclEu;
3910
3998
  }
3911
- isECTheme() {
3912
- return EuiTheme.EC === this.theme;
3999
+ isEclEuRtl() {
4000
+ return this.state.theme.isEclEuRtl;
3913
4001
  }
3914
- isEUTheme() {
3915
- return EuiTheme.EU === this.theme;
4002
+ isEuiLegacy() {
4003
+ return this.state.theme.isEuiLegacy;
4004
+ }
4005
+ isEuiLegacyHc() {
4006
+ return this.state.theme.isEuiLegacyHc;
4007
+ }
4008
+ isDark() {
4009
+ return this.state.theme.isDark;
4010
+ }
4011
+ isCompact() {
4012
+ return this.state.theme.isCompact;
4013
+ }
4014
+ setActiveTheme(theme, isActive) {
4015
+ const themes = this.state.themes;
4016
+ const themeIdx = themes.findIndex(t => t.name === theme);
4017
+ if (themeIdx < 0) {
4018
+ throw new Error('NO_THEME_FOUND');
4019
+ }
4020
+ else {
4021
+ themes[themeIdx].isActive = isActive;
4022
+ const themeFound = themes[themeIdx];
4023
+ const status = initialState.theme;
4024
+ switch (theme) {
4025
+ case EuiTheme.DEFAULT: {
4026
+ status.isDefault = isActive;
4027
+ break;
4028
+ }
4029
+ case EuiTheme.ECL_EC: {
4030
+ status.isEclEc = isActive;
4031
+ break;
4032
+ }
4033
+ case EuiTheme.ECL_EC_RTL: {
4034
+ status.isEclEcRtl = isActive;
4035
+ break;
4036
+ }
4037
+ case EuiTheme.ECL_EU: {
4038
+ status.isEclEu = isActive;
4039
+ break;
4040
+ }
4041
+ case EuiTheme.ECL_EU_RTL: {
4042
+ status.isEclEuRtl = isActive;
4043
+ break;
4044
+ }
4045
+ case EuiTheme.DARK: {
4046
+ status.isDark = isActive;
4047
+ break;
4048
+ }
4049
+ case EuiTheme.COMPACT: {
4050
+ status.isCompact = isActive;
4051
+ break;
4052
+ }
4053
+ case EuiTheme.EUI_LEGACY: {
4054
+ status.isEuiLegacy = isActive;
4055
+ break;
4056
+ }
4057
+ case EuiTheme.EUI_LEGACY_HC: {
4058
+ status.isEuiLegacyHc = isActive;
4059
+ break;
4060
+ }
4061
+ }
4062
+ this._state$.next({
4063
+ themes,
4064
+ theme: status,
4065
+ });
4066
+ this._renderTheme(themeFound, isActive);
4067
+ }
3916
4068
  }
3917
- getTheme() {
3918
- return this.theme;
4069
+ _renderTheme(themeFound, isActive) {
4070
+ if (themeFound.name === EuiTheme.COMPACT) {
4071
+ if (isActive) {
4072
+ this.asService.setBaseFontSize('14px');
4073
+ }
4074
+ else {
4075
+ this.asService.setBaseFontSize('16px');
4076
+ }
4077
+ }
4078
+ else if (themeFound.name === EuiTheme.ECL_EC_RTL || themeFound.name === EuiTheme.ECL_EU_RTL) {
4079
+ const rtlLink = this.document.getElementById('rtl-theme');
4080
+ this._renderThemeCss(themeFound, isActive, rtlLink);
4081
+ }
4082
+ else {
4083
+ const themeLink = this.document.getElementById('eui-theme');
4084
+ this._renderThemeCss(themeFound, isActive, themeLink);
4085
+ }
3919
4086
  }
3920
- setTheme(theme) {
3921
- this.theme = theme;
3922
- this.themeSubject.next(theme);
4087
+ _renderThemeCss(themeFound, isActive, link) {
4088
+ const head = this.document.getElementsByTagName('head')[0];
4089
+ if (isActive) {
4090
+ if (themeFound.cssClass) {
4091
+ document.querySelector('html').classList.add(themeFound.cssClass);
4092
+ }
4093
+ if (themeFound.styleSheet) {
4094
+ if (link) {
4095
+ link.href = themeFound.styleSheet;
4096
+ }
4097
+ else {
4098
+ const style = this.document.createElement('link');
4099
+ style.id = 'eui-theme';
4100
+ style.rel = 'stylesheet';
4101
+ style.href = `assets/${themeFound.styleSheet}`;
4102
+ head.appendChild(style);
4103
+ }
4104
+ }
4105
+ }
4106
+ else {
4107
+ if (themeFound.cssClass) {
4108
+ document.querySelector('html').classList.remove(themeFound.cssClass);
4109
+ }
4110
+ if (themeFound.styleSheet) {
4111
+ if (link) {
4112
+ link.media = '';
4113
+ }
4114
+ }
4115
+ }
3923
4116
  }
3924
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiThemeService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
4117
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiThemeService, deps: [{ token: DOCUMENT }, { token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: EuiAppShellService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3925
4118
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiThemeService, providedIn: 'root' }); }
3926
4119
  }
3927
4120
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiThemeService, decorators: [{
3928
4121
  type: Injectable,
3929
- args: [{ providedIn: 'root' }]
3930
- }], ctorParameters: () => [{ type: undefined, decorators: [{
4122
+ args: [{
4123
+ providedIn: 'root',
4124
+ }]
4125
+ }], ctorParameters: () => [{ type: Document, decorators: [{
4126
+ type: Inject,
4127
+ args: [DOCUMENT]
4128
+ }] }, { type: undefined, decorators: [{
3931
4129
  type: Optional
3932
4130
  }, {
3933
4131
  type: Inject,
3934
4132
  args: [GLOBAL_CONFIG_TOKEN]
3935
- }] }] });
4133
+ }] }, { type: EuiAppShellService }] });
3936
4134
 
3937
4135
  /**
3938
4136
  * Generic storage service. Concrete storage services must extend this class
@@ -4000,9 +4198,10 @@ class AsyncStorageServiceMock extends AsyncStorageService {
4000
4198
  */
4001
4199
  class LocalStorageService extends StorageService {
4002
4200
  static { this.NAME = 'LocalStorageService'; }
4003
- constructor(log) {
4201
+ constructor(log, platformId) {
4004
4202
  super();
4005
4203
  this.log = log;
4204
+ this.platformId = platformId;
4006
4205
  }
4007
4206
  /**
4008
4207
  * the name of the storage service
@@ -4018,15 +4217,17 @@ class LocalStorageService extends StorageService {
4018
4217
  // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
4019
4218
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4020
4219
  get(key) {
4021
- try {
4022
- const serialized = localStorage.getItem(key);
4023
- return serialized && JSON.parse(serialized);
4024
- }
4025
- catch (err) {
4026
- if (this.log) {
4027
- this.log.error(this.name(), 'get', err);
4220
+ if (isPlatformBrowser(this.platformId)) {
4221
+ try {
4222
+ const serialized = localStorage.getItem(key);
4223
+ return serialized && JSON.parse(serialized);
4224
+ }
4225
+ catch (err) {
4226
+ if (this.log) {
4227
+ this.log.error(this.name(), 'get', err);
4228
+ }
4229
+ return undefined;
4028
4230
  }
4029
- return undefined;
4030
4231
  }
4031
4232
  }
4032
4233
  /**
@@ -4037,13 +4238,15 @@ class LocalStorageService extends StorageService {
4037
4238
  // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
4038
4239
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4039
4240
  set(key, value) {
4040
- try {
4041
- const serialized = JSON.stringify(value);
4042
- localStorage.setItem(key, serialized);
4043
- }
4044
- catch (err) {
4045
- if (this.log) {
4046
- this.log.error(this.name(), 'set', err);
4241
+ if (isPlatformBrowser(this.platformId)) {
4242
+ try {
4243
+ const serialized = JSON.stringify(value);
4244
+ localStorage.setItem(key, serialized);
4245
+ }
4246
+ catch (err) {
4247
+ if (this.log) {
4248
+ this.log.error(this.name(), 'set', err);
4249
+ }
4047
4250
  }
4048
4251
  }
4049
4252
  }
@@ -4052,22 +4255,27 @@ class LocalStorageService extends StorageService {
4052
4255
  * @param key the associated key
4053
4256
  */
4054
4257
  remove(key) {
4055
- try {
4056
- localStorage.removeItem(key);
4057
- }
4058
- catch (err) {
4059
- if (this.log) {
4060
- this.log.error(this.name(), 'remove', err);
4258
+ if (isPlatformBrowser(this.platformId)) {
4259
+ try {
4260
+ localStorage.removeItem(key);
4261
+ }
4262
+ catch (err) {
4263
+ if (this.log) {
4264
+ this.log.error(this.name(), 'remove', err);
4265
+ }
4061
4266
  }
4062
4267
  }
4063
4268
  }
4064
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: LocalStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
4269
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: LocalStorageService, deps: [{ token: LogService, optional: true }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
4065
4270
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: LocalStorageService }); }
4066
4271
  }
4067
4272
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: LocalStorageService, decorators: [{
4068
4273
  type: Injectable
4069
4274
  }], ctorParameters: () => [{ type: LogService, decorators: [{
4070
4275
  type: Optional
4276
+ }] }, { type: undefined, decorators: [{
4277
+ type: Inject,
4278
+ args: [PLATFORM_ID]
4071
4279
  }] }] });
4072
4280
 
4073
4281
  /**
@@ -4267,6 +4475,7 @@ const LOCALE_ID_MAPPER = new InjectionToken('localeIdMapper');
4267
4475
  * - Updating the Angular LOCALE_ID token.
4268
4476
  *
4269
4477
  * @template T - Extends LocaleState, representing the state structure for locales.
4478
+ * @template L - The type of the locale data.
4270
4479
  * @extends EuiService<T | LocaleState>
4271
4480
  */
4272
4481
  class LocaleService extends EuiService {
@@ -4921,12 +5130,12 @@ class AddLangParamInterceptor {
4921
5130
  params: req.params.set(langParam, langValue),
4922
5131
  }));
4923
5132
  }
4924
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
5133
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i1$2.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4925
5134
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AddLangParamInterceptor }); }
4926
5135
  }
4927
5136
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AddLangParamInterceptor, decorators: [{
4928
5137
  type: Injectable
4929
- }], ctorParameters: () => [{ type: i1$1.TranslateService }] });
5138
+ }], ctorParameters: () => [{ type: i1$2.TranslateService }] });
4930
5139
 
4931
5140
  class CachePreventionInterceptor {
4932
5141
  intercept(req, next) {
@@ -5078,11 +5287,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
5078
5287
  args: [UX_ERROR_MAPPING_HANDLER_TOKEN]
5079
5288
  }] }] });
5080
5289
 
5081
- /* CORE MODULES */
5290
+ /* BASE PACKAGE */
5082
5291
 
5083
5292
  /**
5084
5293
  * Generated bundle index. Do not edit.
5085
5294
  */
5086
5295
 
5087
- 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, CssUtils, DYNAMIC_COMPONENT_CONFIG, EUI_CONFIG_TOKEN, EUI_COUNTRIES, EUI_TIMEZONES, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiAppShellService, EuiCoreRootGuardClass, EuiDynamicComponentService, EuiDynamicMenuService, EuiError, EuiGrowlService, EuiLoaderService, EuiPermissionService, EuiTheme, EuiThemeService, EuiTimezoneService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService, 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, ROOT_LOG_CONFIG_TOKEN, RemoveApiQueueItemAction, SHOW_CONNECTION_STATUS_TOKEN, SessionStorageService, Status, 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, parentOffsetEl, position, preInitApp, prepareEuiAppConfigToken, coreReducers as reducers, sessionStorageSync, translateConfig, uniqueId, validateEmail };
5296
+ 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, CssUtils, DYNAMIC_COMPONENT_CONFIG, EUI_CONFIG_TOKEN, EUI_COUNTRIES, EUI_TIMEZONES, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiAppShellService, EuiCoreRootGuardClass, EuiDynamicComponentService, EuiDynamicMenuService, EuiError, EuiGrowlService, EuiLoaderService, EuiPermissionService, EuiTheme, EuiThemeService, EuiTimezoneService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService, 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, PLATFORM_BROWSER_ID, ROOT_LOG_CONFIG_TOKEN, RemoveApiQueueItemAction, SHOW_CONNECTION_STATUS_TOKEN, SessionStorageService, Status, 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, parentOffsetEl, position, preInitApp, prepareEuiAppConfigToken, coreReducers as reducers, sessionStorageSync, translateConfig, uniqueId, validateEmail };
5088
5297
  //# sourceMappingURL=eui-core.mjs.map