@eui/core 18.0.0-rc.18 → 18.0.0-rc.19

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.
@@ -6,7 +6,7 @@ import { InjectionToken, Injectable, Inject, Injector, NgModule, Optional, APP_I
6
6
  import * as extendProxy from 'extend';
7
7
  import * as i1$1 from '@ngrx/effects';
8
8
  import { createEffect, ofType } from '@ngrx/effects';
9
- import { merge, fromEvent, throwError, of, forkJoin, from, BehaviorSubject, defer, firstValueFrom, ReplaySubject, map as map$1, Subject } from 'rxjs';
9
+ import { merge, fromEvent, throwError, of, forkJoin, from, BehaviorSubject, defer, firstValueFrom, Subject } from 'rxjs';
10
10
  import { mapTo, map, mergeMap, tap, debounceTime, distinctUntilChanged, take, switchMap, catchError, concatMap, filter, takeUntil } from 'rxjs/operators';
11
11
  import * as i1$2 from '@ngx-translate/core';
12
12
  import { TranslateLoader } from '@ngx-translate/core';
@@ -2780,7 +2780,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
2780
2780
  type: Injectable
2781
2781
  }], ctorParameters: () => [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i0.ApplicationRef }] });
2782
2782
 
2783
- const initialState = {
2783
+ const initialState$1 = {
2784
2784
  appName: '',
2785
2785
  appShortName: '',
2786
2786
  appSubTitle: '',
@@ -2903,9 +2903,9 @@ class EuiAppShellService {
2903
2903
  this.router = router;
2904
2904
  this.storeService = storeService;
2905
2905
  this.i18nService = i18nService;
2906
- let stateWithConfig = initialState;
2907
- const languages = config?.i18n?.i18nService?.languages || initialState.languages;
2908
- const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState.activeLanguage;
2906
+ let stateWithConfig = initialState$1;
2907
+ const languages = config?.i18n?.i18nService?.languages || initialState$1.languages;
2908
+ const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState$1.activeLanguage;
2909
2909
  stateWithConfig = {
2910
2910
  ...stateWithConfig,
2911
2911
  ...{
@@ -3894,46 +3894,204 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImpor
3894
3894
 
3895
3895
  var EuiTheme;
3896
3896
  (function (EuiTheme) {
3897
- EuiTheme["EC"] = "ec";
3898
- EuiTheme["EU"] = "eu";
3899
- EuiTheme["EUI"] = "eui";
3897
+ EuiTheme["DEFAULT"] = "default";
3898
+ EuiTheme["ECL_EC"] = "ecl-ec";
3899
+ EuiTheme["ECL_EC_RTL"] = "ecl-ec-rtl";
3900
+ EuiTheme["ECL_EU"] = "ecl-eu";
3901
+ EuiTheme["ECL_EU_RTL"] = "ecl-eu-rtl";
3902
+ EuiTheme["EUI_LEGACY"] = "eui-legacy";
3903
+ EuiTheme["EUI_LEGACY_HC"] = "eui-legacy-high-contrast";
3904
+ EuiTheme["DARK"] = "dark";
3905
+ EuiTheme["COMPACT"] = "compact";
3900
3906
  })(EuiTheme || (EuiTheme = {}));
3907
+ ;
3908
+ ;
3909
+ const initialState = {
3910
+ themes: [
3911
+ { name: EuiTheme.DEFAULT, isActive: false, styleSheet: null, cssClass: null },
3912
+ { name: EuiTheme.ECL_EC, isActive: false, styleSheet: 'eui-ecl-ec.css', cssClass: null },
3913
+ { name: EuiTheme.ECL_EC_RTL, isActive: false, styleSheet: 'eui-ecl-ec-rtl.css', cssClass: null },
3914
+ { name: EuiTheme.ECL_EU, isActive: false, styleSheet: 'eui-ecl-eu.css', cssClass: null },
3915
+ { name: EuiTheme.ECL_EU_RTL, isActive: false, styleSheet: 'eui-ecl-eu-rtl.css', cssClass: null },
3916
+ { name: EuiTheme.EUI_LEGACY, isActive: false, styleSheet: null, cssClass: 'eui-t-eui-legacy' },
3917
+ { name: EuiTheme.EUI_LEGACY_HC, isActive: false, styleSheet: null, cssClass: 'eui-t-high-contrast' },
3918
+ { name: EuiTheme.DARK, isActive: false, styleSheet: null, cssClass: 'eui-t-dark' },
3919
+ { name: EuiTheme.COMPACT, isActive: false, styleSheet: null, cssClass: 'eui-t-compact' },
3920
+ ],
3921
+ theme: {
3922
+ isDefault: false,
3923
+ isEclEc: false,
3924
+ isEclEcRtl: false,
3925
+ isEclEu: false,
3926
+ isEclEuRtl: false,
3927
+ isEuiLegacy: false,
3928
+ isEuiLegacyHc: false,
3929
+ isDark: false,
3930
+ isCompact: false,
3931
+ },
3932
+ };
3901
3933
  class EuiThemeService {
3902
- constructor(config) {
3934
+ constructor(document, config, asService) {
3935
+ this.document = document;
3903
3936
  this.config = config;
3904
- this.theme = EuiTheme.EC;
3905
- this.themeSubject = new ReplaySubject();
3906
- this.theme$ = this.themeSubject.asObservable();
3907
- this.isEU$ = this.theme$.pipe(map$1((theme) => EuiTheme.EU === theme));
3908
- this.isEC$ = this.theme$.pipe(map$1((theme) => EuiTheme.EC === theme));
3909
- const theme = this.config?.eui?.theme || EuiTheme.EC;
3910
- this.setTheme(theme);
3937
+ this.asService = asService;
3938
+ this._state$ = new BehaviorSubject(initialState);
3939
+ const themeName = this.config?.eui?.theme || EuiTheme.DEFAULT;
3940
+ this.setActiveTheme(themeName, true);
3941
+ }
3942
+ get state$() {
3943
+ return this._state$.asObservable();
3944
+ }
3945
+ get state() {
3946
+ return this._state$.getValue();
3947
+ }
3948
+ isDefault() {
3949
+ return this.state.theme.isDefault;
3950
+ }
3951
+ isEclEc() {
3952
+ return this.state.theme.isEclEc;
3953
+ }
3954
+ isEclEcRtl() {
3955
+ return this.state.theme.isEclEcRtl;
3956
+ }
3957
+ isEclEu() {
3958
+ return this.state.theme.isEclEu;
3959
+ }
3960
+ isEclEuRtl() {
3961
+ return this.state.theme.isEclEuRtl;
3962
+ }
3963
+ isEuiLegacy() {
3964
+ return this.state.theme.isEuiLegacy;
3911
3965
  }
3912
- isECTheme() {
3913
- return EuiTheme.EC === this.theme;
3966
+ isEuiLegacyHc() {
3967
+ return this.state.theme.isEuiLegacyHc;
3914
3968
  }
3915
- isEUTheme() {
3916
- return EuiTheme.EU === this.theme;
3969
+ isDark() {
3970
+ return this.state.theme.isDark;
3971
+ }
3972
+ isCompact() {
3973
+ return this.state.theme.isCompact;
3974
+ }
3975
+ setActiveTheme(theme, isActive) {
3976
+ const themes = this.state.themes;
3977
+ const themeIdx = themes.findIndex(t => t.name === theme);
3978
+ if (themeIdx < 0) {
3979
+ throw new Error('NO_THEME_FOUND');
3980
+ }
3981
+ else {
3982
+ themes[themeIdx].isActive = isActive;
3983
+ const themeFound = themes[themeIdx];
3984
+ const status = initialState.theme;
3985
+ switch (theme) {
3986
+ case EuiTheme.DEFAULT: {
3987
+ status.isDefault = isActive;
3988
+ break;
3989
+ }
3990
+ case EuiTheme.ECL_EC: {
3991
+ status.isEclEc = isActive;
3992
+ break;
3993
+ }
3994
+ case EuiTheme.ECL_EC_RTL: {
3995
+ status.isEclEcRtl = isActive;
3996
+ break;
3997
+ }
3998
+ case EuiTheme.ECL_EU: {
3999
+ status.isEclEu = isActive;
4000
+ break;
4001
+ }
4002
+ case EuiTheme.ECL_EU_RTL: {
4003
+ status.isEclEuRtl = isActive;
4004
+ break;
4005
+ }
4006
+ case EuiTheme.DARK: {
4007
+ status.isDark = isActive;
4008
+ break;
4009
+ }
4010
+ case EuiTheme.COMPACT: {
4011
+ status.isCompact = isActive;
4012
+ break;
4013
+ }
4014
+ case EuiTheme.EUI_LEGACY: {
4015
+ status.isEuiLegacy = isActive;
4016
+ break;
4017
+ }
4018
+ case EuiTheme.EUI_LEGACY_HC: {
4019
+ status.isEuiLegacyHc = isActive;
4020
+ break;
4021
+ }
4022
+ }
4023
+ this._state$.next({
4024
+ themes,
4025
+ theme: status,
4026
+ });
4027
+ this._renderTheme(themeFound, isActive);
4028
+ }
3917
4029
  }
3918
- getTheme() {
3919
- return this.theme;
4030
+ _renderTheme(themeFound, isActive) {
4031
+ if (themeFound.name === EuiTheme.COMPACT) {
4032
+ if (isActive) {
4033
+ this.asService.setBaseFontSize('14px');
4034
+ }
4035
+ else {
4036
+ this.asService.setBaseFontSize('16px');
4037
+ }
4038
+ }
4039
+ else if (themeFound.name === EuiTheme.ECL_EC_RTL || themeFound.name === EuiTheme.ECL_EU_RTL) {
4040
+ const rtlLink = this.document.getElementById('rtl-theme');
4041
+ this._renderThemeCss(themeFound, isActive, rtlLink);
4042
+ }
4043
+ else {
4044
+ const themeLink = this.document.getElementById('eui-theme');
4045
+ this._renderThemeCss(themeFound, isActive, themeLink);
4046
+ }
3920
4047
  }
3921
- setTheme(theme) {
3922
- this.theme = theme;
3923
- this.themeSubject.next(theme);
4048
+ _renderThemeCss(themeFound, isActive, link) {
4049
+ const head = this.document.getElementsByTagName('head')[0];
4050
+ if (isActive) {
4051
+ if (themeFound.cssClass) {
4052
+ document.querySelector('html').classList.add(themeFound.cssClass);
4053
+ }
4054
+ if (themeFound.styleSheet) {
4055
+ if (link) {
4056
+ link.href = themeFound.styleSheet;
4057
+ }
4058
+ else {
4059
+ const style = this.document.createElement('link');
4060
+ style.id = 'eui-theme';
4061
+ style.rel = 'stylesheet';
4062
+ style.href = `assets/${themeFound.styleSheet}`;
4063
+ head.appendChild(style);
4064
+ }
4065
+ }
4066
+ }
4067
+ else {
4068
+ if (themeFound.cssClass) {
4069
+ document.querySelector('html').classList.remove(themeFound.cssClass);
4070
+ }
4071
+ if (themeFound.styleSheet) {
4072
+ if (link) {
4073
+ link.media = '';
4074
+ }
4075
+ }
4076
+ }
3924
4077
  }
3925
- 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 }); }
4078
+ 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 }); }
3926
4079
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiThemeService, providedIn: 'root' }); }
3927
4080
  }
3928
4081
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: EuiThemeService, decorators: [{
3929
4082
  type: Injectable,
3930
- args: [{ providedIn: 'root' }]
3931
- }], ctorParameters: () => [{ type: undefined, decorators: [{
4083
+ args: [{
4084
+ providedIn: 'root',
4085
+ }]
4086
+ }], ctorParameters: () => [{ type: Document, decorators: [{
4087
+ type: Inject,
4088
+ args: [DOCUMENT]
4089
+ }] }, { type: undefined, decorators: [{
3932
4090
  type: Optional
3933
4091
  }, {
3934
4092
  type: Inject,
3935
4093
  args: [GLOBAL_CONFIG_TOKEN]
3936
- }] }] });
4094
+ }] }, { type: EuiAppShellService }] });
3937
4095
 
3938
4096
  /**
3939
4097
  * Generic storage service. Concrete storage services must extend this class