@eui/core 18.0.0-next.52 → 18.0.0-next.53

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.
@@ -2129,6 +2129,123 @@ var handleError = (error) => {
2129
2129
  // lib/helpers/utils.mjs
2130
2130
  var isDefined = (value) => value !== void 0 && value !== null;
2131
2131
 
2132
+ // lib/helpers/css-utils.mjs
2133
+ var CssUtils = class {
2134
+ static {
2135
+ this.getCssVarValue = (inputProperty) => {
2136
+ return getComputedStyle(document.documentElement).getPropertyValue(inputProperty);
2137
+ };
2138
+ }
2139
+ static {
2140
+ this.setCssVarValue = (propertyName, propertyValue) => {
2141
+ document.documentElement.style.setProperty(propertyName, propertyValue);
2142
+ };
2143
+ }
2144
+ static {
2145
+ this.setCssVar = (inputProperty, outputProperty) => {
2146
+ const cssVarValue = this.getCssVarValue(inputProperty);
2147
+ this.setCssVarValue(outputProperty, cssVarValue);
2148
+ };
2149
+ }
2150
+ static {
2151
+ this.initCssVars = () => {
2152
+ this.setCssVar("--eui-app-header-height-default", "--eui-app-header-height");
2153
+ this.setCssVar("--eui-app-breadcrumb-height-default", "--eui-app-breadcrumb-height");
2154
+ this.setCssVar("--eui-app-top-message-height-default", "--eui-app-top-message-height");
2155
+ this.setCssVar("--eui-app-toolbar-height-default", "--eui-app-toolbar-height");
2156
+ this.setCssVar("--eui-app-sidebar-width-default", "--eui-app-sidebar-width");
2157
+ this.setCssVar("--eui-app-sidebar-width-close-default", "--eui-app-sidebar-width-close");
2158
+ this.setCssVar("--eui-app-sidebar-header-height-default", "--eui-app-sidebar-header-height");
2159
+ this.setCssVar("--eui-app-sidebar-footer-height-default", "--eui-app-sidebar-footer-height");
2160
+ };
2161
+ }
2162
+ static {
2163
+ this.activateEditModeCssVars = (isActive) => {
2164
+ if (isActive) {
2165
+ this.setCssVarValue("--eui-docpage-navigation-z-index", "inherit");
2166
+ this.setCssVarValue("--eui-z-index-sidebar", "inherit");
2167
+ this.setCssVarValue("--eui-z-index-root", "inherit");
2168
+ } else {
2169
+ this.setCssVarValue("--eui-docpage-navigation-z-index", "2");
2170
+ this.setCssVarValue("--eui-z-index-sidebar", "1044");
2171
+ this.setCssVarValue("--eui-z-index-root", "1");
2172
+ }
2173
+ };
2174
+ }
2175
+ static {
2176
+ this.activateHeaderCssVars = () => {
2177
+ this.setCssVar("--eui-app-header-height-active", "--eui-app-header-height");
2178
+ };
2179
+ }
2180
+ static {
2181
+ this.activateBreadcrumbCssVars = () => {
2182
+ this.setCssVar("--eui-app-breadcrumb-height-active", "--eui-app-breadcrumb-height");
2183
+ };
2184
+ }
2185
+ static {
2186
+ this.activateTopMessageCssVars = (height) => {
2187
+ this.setCssVarValue("--eui-app-top-message-height", `${height}px`);
2188
+ };
2189
+ }
2190
+ static {
2191
+ this.activateToolbarCssVars = () => {
2192
+ this.setCssVar("--eui-app-toolbar-height-active", "--eui-app-toolbar-height");
2193
+ };
2194
+ }
2195
+ static {
2196
+ this.activateFooterCssVars = () => {
2197
+ this.setCssVar("--eui-app-footer-height-active", "--eui-app-footer-height");
2198
+ };
2199
+ }
2200
+ static {
2201
+ this.setHeaderShrinkCssVar = (active) => {
2202
+ if (active) {
2203
+ this.setCssVar("--eui-app-header-height-shrink", "--eui-app-header-height");
2204
+ } else {
2205
+ this.setCssVar("--eui-app-header-height-active", "--eui-app-header-height");
2206
+ }
2207
+ };
2208
+ }
2209
+ static {
2210
+ this.activateSidebarCssVars = () => {
2211
+ this.setCssVar("--eui-app-sidebar-width-active", "--eui-app-sidebar-width");
2212
+ this.setCssVar("--eui-app-sidebar-width-close-active", "--eui-app-sidebar-width-close");
2213
+ };
2214
+ }
2215
+ static {
2216
+ this.removeSidebarCssVars = () => {
2217
+ document.documentElement.style.removeProperty("--eui-app-sidebar-header-height");
2218
+ document.documentElement.style.removeProperty("--eui-app-sidebar-footer-height");
2219
+ document.documentElement.style.removeProperty("--eui-app-sidebar-width");
2220
+ document.documentElement.style.removeProperty("--eui-app-sidebar-width-close");
2221
+ };
2222
+ }
2223
+ static {
2224
+ this.activateSidebarHeaderCssVars = () => {
2225
+ this.setCssVar("--eui-app-sidebar-header-height-active", "--eui-app-sidebar-header-height");
2226
+ };
2227
+ }
2228
+ static {
2229
+ this.activateSidebarFooterCssVars = () => {
2230
+ this.setCssVar("--eui-app-sidebar-footer-height-active", "--eui-app-sidebar-footer-height");
2231
+ };
2232
+ }
2233
+ /**
2234
+ * Gets the viewport height and width and multiple it by 1% to get a value for a vh/vw unit
2235
+ * Sets the value in the --eui-app-vh custom property to the root of the document
2236
+ * Sets the value in the --eui-app-vw custom property to the root of the document
2237
+ * Example for 100% height: calc(var(--eui-app-vh, 1vh) * 100);
2238
+ * Example for 50% height: calc(var(--eui-app-vh, 1vh) * 50);
2239
+ * Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
2240
+ */
2241
+ static setAppViewportCssVars() {
2242
+ const vh = window.innerHeight * 0.01;
2243
+ const vw = window.innerWidth * 0.01;
2244
+ this.setCssVarValue("--eui-app-vh", `${vh}px`);
2245
+ this.setCssVarValue("--eui-app-vw", `${vw}px`);
2246
+ }
2247
+ };
2248
+
2132
2249
  // lib/services/permission/permission.service.mjs
2133
2250
  import { Injectable as Injectable11, Optional as Optional6 } from "@angular/core";
2134
2251
  import { EuiService, getUserRights } from "@eui/base";
@@ -2559,7 +2676,6 @@ var EuiAppShellService = class _EuiAppShellService {
2559
2676
  get breakpoint$() {
2560
2677
  return this._breakpoint$.asObservable();
2561
2678
  }
2562
- // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
2563
2679
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2564
2680
  get breakpoints$() {
2565
2681
  return this._breakpoints$.asObservable();
@@ -2643,9 +2759,6 @@ var EuiAppShellService = class _EuiAppShellService {
2643
2759
  this.router = router;
2644
2760
  this.storeService = storeService;
2645
2761
  this.i18nService = i18nService;
2646
- this.openModalId = new BehaviorSubject2("");
2647
- this.activeModals = [];
2648
- this.cssVars = [];
2649
2762
  let stateWithConfig = initialState;
2650
2763
  const languages = config?.i18n?.i18nService?.languages || initialState.languages;
2651
2764
  const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState.activeLanguage;
@@ -2704,7 +2817,6 @@ var EuiAppShellService = class _EuiAppShellService {
2704
2817
  *
2705
2818
  * @param key can be 'key' or 'key.sub.sub'
2706
2819
  */
2707
- // TODO: find the correct type or turn into a generic, https://www.typescriptlang.org/docs/handbook/2/generics.html
2708
2820
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2709
2821
  getState(key) {
2710
2822
  return defer(() => (
@@ -2726,25 +2838,14 @@ var EuiAppShellService = class _EuiAppShellService {
2726
2838
  ...this.state,
2727
2839
  isDimmerActive: !isActive
2728
2840
  });
2729
- this.activateEditModeCssVars(!isActive);
2841
+ CssUtils.activateEditModeCssVars(!isActive);
2730
2842
  }
2731
2843
  setDimmerActiveState(activeState) {
2732
2844
  this.setState({
2733
2845
  ...this.state,
2734
2846
  isDimmerActive: activeState
2735
2847
  });
2736
- this.activateEditModeCssVars(activeState);
2737
- }
2738
- activateEditModeCssVars(isActive) {
2739
- if (isActive) {
2740
- this._setCssVarValue("--eui-docpage-navigation-z-index", "inherit");
2741
- this._setCssVarValue("--eui-z-index-sidebar", "inherit");
2742
- this._setCssVarValue("--eui-z-index-root", "inherit");
2743
- } else {
2744
- this._setCssVarValue("--eui-docpage-navigation-z-index", "2");
2745
- this._setCssVarValue("--eui-z-index-sidebar", "1044");
2746
- this._setCssVarValue("--eui-z-index-root", "1");
2747
- }
2848
+ CssUtils.activateEditModeCssVars(activeState);
2748
2849
  }
2749
2850
  // --------------
2750
2851
  // public methods
@@ -2763,42 +2864,42 @@ var EuiAppShellService = class _EuiAppShellService {
2763
2864
  hasSidebar: true
2764
2865
  });
2765
2866
  if (!this.state.isSidebarHidden) {
2766
- this.activateSidebarCssVars();
2867
+ CssUtils.activateSidebarCssVars();
2767
2868
  }
2768
2869
  }
2769
2870
  activateSidebarHeader() {
2770
- this.activateSidebarHeaderCssVars();
2871
+ CssUtils.activateSidebarHeaderCssVars();
2771
2872
  }
2772
2873
  activateSidebarFooter() {
2773
- this.activateSidebarFooterCssVars();
2874
+ CssUtils.activateSidebarFooterCssVars();
2774
2875
  }
2775
2876
  activateHeader() {
2776
2877
  this.setState({
2777
2878
  ...this.state,
2778
2879
  hasHeader: true
2779
2880
  });
2780
- this.activateHeaderCssVars();
2881
+ CssUtils.activateHeaderCssVars();
2781
2882
  }
2782
2883
  activateBreadcrumb() {
2783
2884
  this.setState({
2784
2885
  ...this.state,
2785
2886
  hasBreadcrumb: true
2786
2887
  });
2787
- this.activateBreadcrumbCssVars();
2888
+ CssUtils.activateBreadcrumbCssVars();
2788
2889
  }
2789
2890
  activateTopMessage(height) {
2790
2891
  this.setState({
2791
2892
  ...this.state,
2792
2893
  hasTopMessage: true
2793
2894
  });
2794
- this.activateTopMessageCssVars(height);
2895
+ CssUtils.activateTopMessageCssVars(height);
2795
2896
  }
2796
2897
  activateToolbar() {
2797
2898
  this.setState({
2798
2899
  ...this.state,
2799
2900
  hasToolbar: true
2800
2901
  });
2801
- this.activateToolbarCssVars();
2902
+ CssUtils.activateToolbarCssVars();
2802
2903
  }
2803
2904
  activateToolbarMenu() {
2804
2905
  this.setState({
@@ -2806,96 +2907,11 @@ var EuiAppShellService = class _EuiAppShellService {
2806
2907
  hasToolbarMenu: true
2807
2908
  });
2808
2909
  }
2809
- fetchCssVars() {
2810
- const cssVarNames = [
2811
- "--eui-app-header-height-default",
2812
- "--eui-app-header-height-active",
2813
- "--eui-app-header-height-shrink",
2814
- "--eui-app-breadcrumb-height-default",
2815
- "--eui-app-breadcrumb-height-active",
2816
- "--eui-app-top-message-height-default",
2817
- "--eui-app-top-message-height-active",
2818
- "--eui-app-top-message-height-shrink",
2819
- "--eui-app-toolbar-height-default",
2820
- "--eui-app-toolbar-height-active",
2821
- "--eui-app-sidebar-width-default",
2822
- "--eui-app-sidebar-width-active",
2823
- "--eui-app-sidebar-width-close-default",
2824
- "--eui-app-sidebar-width-close-active",
2825
- "--eui-app-sidebar-header-height-default",
2826
- "--eui-app-sidebar-header-height-active",
2827
- "--eui-app-sidebar-footer-height-default",
2828
- "--eui-app-sidebar-footer-height-active"
2829
- ];
2830
- this.cssVars = cssVarNames.map((v) => ({ key: v, value: this.getCssVarValue(v) }));
2831
- }
2832
- initCssVars() {
2833
- this.setCssVar("--eui-app-header-height-default", "--eui-app-header-height");
2834
- this.setCssVar("--eui-app-breadcrumb-height-default", "--eui-app-breadcrumb-height");
2835
- this.setCssVar("--eui-app-top-message-height-default", "--eui-app-top-message-height");
2836
- this.setCssVar("--eui-app-toolbar-height-default", "--eui-app-toolbar-height");
2837
- this.setCssVar("--eui-app-sidebar-width-default", "--eui-app-sidebar-width");
2838
- this.setCssVar("--eui-app-sidebar-width-close-default", "--eui-app-sidebar-width-close");
2839
- this.setCssVar("--eui-app-sidebar-header-height-default", "--eui-app-sidebar-header-height");
2840
- this.setCssVar("--eui-app-sidebar-footer-height-default", "--eui-app-sidebar-footer-height");
2841
- }
2842
- activateHeaderCssVars() {
2843
- this.setCssVar("--eui-app-header-height-active", "--eui-app-header-height");
2844
- }
2845
- activateBreadcrumbCssVars() {
2846
- this.setCssVar("--eui-app-breadcrumb-height-active", "--eui-app-breadcrumb-height");
2847
- }
2848
- activateTopMessageCssVars(height) {
2849
- this._setCssVarValue("--eui-app-top-message-height", `${height}px`);
2850
- }
2851
- activateToolbarCssVars() {
2852
- this.setCssVar("--eui-app-toolbar-height-active", "--eui-app-toolbar-height");
2853
- }
2854
- activateFooterCssVars() {
2855
- this.setCssVar("--eui-app-footer-height-active", "--eui-app-footer-height");
2856
- }
2857
- setHeaderShrinkCssVar(active) {
2858
- if (active) {
2859
- this.setCssVar("--eui-app-header-height-shrink", "--eui-app-header-height");
2860
- } else {
2861
- this.setCssVar("--eui-app-header-height-active", "--eui-app-header-height");
2862
- }
2863
- }
2864
- activateSidebarCssVars() {
2865
- this.setCssVar("--eui-app-sidebar-width-active", "--eui-app-sidebar-width");
2866
- this.setCssVar("--eui-app-sidebar-width-close-active", "--eui-app-sidebar-width-close");
2867
- }
2868
- removeSidebarCssVars() {
2869
- document.documentElement.style.removeProperty("--eui-app-sidebar-header-height");
2870
- document.documentElement.style.removeProperty("--eui-app-sidebar-footer-height");
2871
- document.documentElement.style.removeProperty("--eui-app-sidebar-width");
2872
- document.documentElement.style.removeProperty("--eui-app-sidebar-width-close");
2873
- }
2874
- activateSidebarHeaderCssVars() {
2875
- this.setCssVar("--eui-app-sidebar-header-height-active", "--eui-app-sidebar-header-height");
2876
- }
2877
- activateSidebarFooterCssVars() {
2878
- this.setCssVar("--eui-app-sidebar-footer-height-active", "--eui-app-sidebar-footer-height");
2879
- }
2880
- /**
2881
- * Gets the viewport height and width and multiple it by 1% to get a value for a vh/vw unit
2882
- * Sets the value in the --eui-app-vh custom property to the root of the document
2883
- * Sets the value in the --eui-app-vw custom property to the root of the document
2884
- * Example for 100% height: calc(var(--eui-app-vh, 1vh) * 100);
2885
- * Example for 50% height: calc(var(--eui-app-vh, 1vh) * 50);
2886
- * Example for 50% width: calc(var(--eui-app-vw, 1vw) * 50);
2887
- */
2888
- setAppViewportCssVars() {
2889
- const vh = window.innerHeight * 0.01;
2890
- const vw = window.innerWidth * 0.01;
2891
- this._setCssVarValue("--eui-app-vh", `${vh}px`);
2892
- this._setCssVarValue("--eui-app-vw", `${vw}px`);
2893
- }
2894
2910
  /**
2895
2911
  * Returns the current value of --eui-f-size-base CSS variable
2896
2912
  */
2897
2913
  getBaseFontSize() {
2898
- return this.state.appBaseFontSize || this.getCssVarValue("--eui-f-size-base");
2914
+ return this.state.appBaseFontSize || CssUtils.getCssVarValue("--eui-f-size-base");
2899
2915
  }
2900
2916
  /**
2901
2917
  * Updates the current value of --eui-f-size-base CSS variable and the UIState appBaseFontSize
@@ -2905,132 +2921,15 @@ var EuiAppShellService = class _EuiAppShellService {
2905
2921
  ...this.state,
2906
2922
  appBaseFontSize: newsize
2907
2923
  }, false);
2908
- this._setCssVarValue("--eui-f-size-base", newsize);
2909
- }
2910
- /**
2911
- * @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
2912
- */
2913
- openModal(modalId) {
2914
- document.body.classList.add("modal-open");
2915
- if (!modalId) {
2916
- modalId = "single_modal";
2917
- }
2918
- this.activeModals.push({
2919
- id: modalId,
2920
- isOpen: true
2921
- });
2922
- setTimeout(() => {
2923
- const el = document.getElementById(modalId + "-close-button");
2924
- if (el) {
2925
- el.focus();
2926
- }
2927
- }, 100);
2928
- }
2929
- /**
2930
- * @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
2931
- */
2932
- openMessageBox(messageBoxId) {
2933
- if (!messageBoxId) {
2934
- messageBoxId = "messagebox_modal";
2935
- }
2936
- this.openModal(messageBoxId);
2937
- }
2938
- /**
2939
- * @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
2940
- */
2941
- closeMessageBox(messageBoxId) {
2942
- if (!messageBoxId) {
2943
- messageBoxId = "messagebox_modal";
2944
- }
2945
- this.closeModal(messageBoxId);
2946
- }
2947
- /**
2948
- * @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
2949
- */
2950
- isModalOpen(modalId) {
2951
- if (!modalId) {
2952
- modalId = "single_modal";
2953
- }
2954
- if (this.activeModals.length) {
2955
- const modalIndex = this.findModalIndex(modalId);
2956
- if (modalIndex !== -1) {
2957
- return this.activeModals[modalIndex].isOpen;
2958
- }
2959
- }
2960
- return false;
2961
- }
2962
- /**
2963
- * @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
2964
- */
2965
- closeModal(modalId) {
2966
- if (!modalId) {
2967
- modalId = "single_modal";
2968
- }
2969
- const index = this.findModalIndex(modalId);
2970
- if (index >= 0) {
2971
- this.activeModals.splice(index, 1);
2972
- }
2973
- if (this.activeModals && this.activeModals.length <= 0) {
2974
- document.body.classList.remove("modal-open");
2975
- } else {
2976
- const lastModalId = this.activeModals[this.activeModals.length - 1].id;
2977
- if (lastModalId) {
2978
- setTimeout(() => {
2979
- const el = document.getElementById(lastModalId + "-close-button");
2980
- if (el) {
2981
- el.focus();
2982
- }
2983
- }, 100);
2984
- }
2985
- }
2986
- }
2987
- /**
2988
- * @deprecated don't remove as it's used for external legacy project under v17 (csdr-eui-legacy) to support MWP transition
2989
- */
2990
- findModalIndex(modalId) {
2991
- let index = -1;
2992
- if (this.activeModals.length) {
2993
- for (let i = 0; i < this.activeModals.length; i++) {
2994
- if (this.activeModals[i].id === modalId) {
2995
- index = i;
2996
- break;
2997
- }
2998
- }
2999
- }
3000
- return index;
2924
+ CssUtils.setCssVarValue("--eui-f-size-base", newsize);
3001
2925
  }
3002
2926
  // ---------------
3003
2927
  // private getters
3004
2928
  // ---------------
3005
- getCssVarValue(inputProperty) {
3006
- return getComputedStyle(document.documentElement).getPropertyValue(inputProperty);
3007
- }
3008
- setCssVar(inputProperty, outputProperty) {
3009
- const cssVarValue = this.cssVars.filter((v) => v.key === inputProperty)[0].value;
3010
- this._setCssVarValue(outputProperty, cssVarValue);
3011
- }
3012
- _setCssVarValue(varName, varValue) {
3013
- document.documentElement.style.setProperty(varName, varValue);
3014
- }
3015
2929
  getWrapperClasses(state, breakpoint) {
3016
2930
  const classes = [];
3017
2931
  classes.push(breakpoint);
3018
2932
  if (state.hasSidebar) {
3019
- if (state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
3020
- classes.push("sidebar-state-open");
3021
- }
3022
- if (!state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
3023
- classes.push("sidebar-state-close");
3024
- }
3025
- if (state.isSidebarActive) {
3026
- classes.push("sidebar-active");
3027
- }
3028
- if (state.isSidebarInnerActive) {
3029
- classes.push("sidebar-inner-active");
3030
- }
3031
- if (state.isSidebarStateCloseWithIcons) {
3032
- classes.push("sidebar-state-close-with-icons");
3033
- }
3034
2933
  if (state.isSidebarHidden) {
3035
2934
  classes.push("sidebar--hidden");
3036
2935
  }
@@ -3043,16 +2942,13 @@ var EuiAppShellService = class _EuiAppShellService {
3043
2942
  classes.push("sidebar--hover");
3044
2943
  }
3045
2944
  }
3046
- if (state.deviceInfo && state.deviceInfo.isFF) {
2945
+ if (state.deviceInfo?.isFF) {
3047
2946
  classes.push("ff");
3048
2947
  }
3049
- if (state.deviceInfo && state.deviceInfo.isIE) {
2948
+ if (state.deviceInfo?.isIE) {
3050
2949
  classes.push("ie");
3051
2950
  }
3052
- if (state.deviceInfo && state.deviceInfo.isIE11) {
3053
- classes.push("ie11");
3054
- }
3055
- if (state.deviceInfo && state.deviceInfo.isChrome) {
2951
+ if (state.deviceInfo?.isChrome) {
3056
2952
  classes.push("chrome");
3057
2953
  }
3058
2954
  return classes.join(" ");
@@ -5079,6 +4975,7 @@ export {
5079
4975
  CoreUserActionTypes,
5080
4976
  CorsSecurityInterceptor,
5081
4977
  CsrfPreventionInterceptor,
4978
+ CssUtils,
5082
4979
  DYNAMIC_COMPONENT_CONFIG,
5083
4980
  EUI_CONFIG_TOKEN,
5084
4981
  EUI_COUNTRIES,