11import { registerFeature } from "../FeaturesRegistry.js" ;
22import { setTheme } from "../config/Theme.js" ;
3+ import { getCurrentZIndex } from "../util/PopupUtils.js" ;
34
4- const sap = window . sap ;
5- const core = sap && sap . ui && typeof sap . ui . getCore === "function" && sap . ui . getCore ( ) ;
5+ const getCore = ( ) => {
6+ const sap = window . sap ;
7+ const core = sap && sap . ui && typeof sap . ui . getCore === "function" && sap . ui . getCore ( ) ;
8+ return core ;
9+ } ;
610
711const isLoaded = ( ) => {
8- return ! ! core ;
12+ return ! ! getCore ( ) ;
913} ;
1014
1115const init = ( ) => {
16+ const core = getCore ( ) ;
1217 if ( ! core ) {
1318 return Promise . resolve ( ) ;
1419 }
1520
1621 return new Promise ( resolve => {
1722 core . attachInit ( ( ) => {
18- sap . ui . require ( [ "sap/ui/core/LocaleData" ] , resolve ) ;
23+ window . sap . ui . require ( [ "sap/ui/core/LocaleData" , "sap/ui/core/Popup" ] , ( LocaleData , Popup ) => {
24+ Popup . setInitialZIndex ( getCurrentZIndex ( ) ) ;
25+ resolve ( ) ;
26+ } ) ;
1927 } ) ;
2028 } ) ;
2129} ;
2230
2331const getConfigurationSettingsObject = ( ) => {
32+ const core = getCore ( ) ;
2433 if ( ! core ) {
2534 return ;
2635 }
2736
2837 const config = core . getConfiguration ( ) ;
29- const LocaleData = sap . ui . require ( "sap/ui/core/LocaleData" ) ;
38+ const LocaleData = window . sap . ui . require ( "sap/ui/core/LocaleData" ) ;
3039
3140 return {
3241 animationMode : config . getAnimationMode ( ) ,
@@ -41,23 +50,26 @@ const getConfigurationSettingsObject = () => {
4150} ;
4251
4352const getLocaleDataObject = ( ) => {
53+ const core = getCore ( ) ;
4454 if ( ! core ) {
4555 return ;
4656 }
4757
4858 const config = core . getConfiguration ( ) ;
49- const LocaleData = sap . ui . require ( "sap/ui/core/LocaleData" ) ;
59+ const LocaleData = window . sap . ui . require ( "sap/ui/core/LocaleData" ) ;
5060 return LocaleData . getInstance ( config . getLocale ( ) ) . _get ( ) ;
5161} ;
5262
5363const listenForThemeChange = ( ) => {
64+ const core = getCore ( ) ;
5465 const config = core . getConfiguration ( ) ;
5566 core . attachThemeChanged ( async ( ) => {
5667 await setTheme ( config . getTheme ( ) ) ;
5768 } ) ;
5869} ;
5970
6071const attachListeners = ( ) => {
72+ const core = getCore ( ) ;
6173 if ( ! core ) {
6274 return ;
6375 }
@@ -66,6 +78,7 @@ const attachListeners = () => {
6678} ;
6779
6880const cssVariablesLoaded = ( ) => {
81+ const core = getCore ( ) ;
6982 if ( ! core ) {
7083 return ;
7184 }
@@ -78,13 +91,35 @@ const cssVariablesLoaded = () => {
7891 return ! ! link . href . match ( / \/ c s s ( - | _ ) v a r i a b l e s \. c s s / ) ;
7992} ;
8093
94+ const getNextZIndex = ( ) => {
95+ const core = getCore ( ) ;
96+ if ( ! core ) {
97+ return ;
98+ }
99+
100+ const Popup = window . sap . ui . require ( "sap/ui/core/Popup" ) ;
101+ return Popup . getNextZIndex ( ) ;
102+ } ;
103+
104+ const setInitialZIndex = ( ) => {
105+ const core = getCore ( ) ;
106+ if ( ! core ) {
107+ return ;
108+ }
109+
110+ const Popup = window . sap . ui . require ( "sap/ui/core/Popup" ) ;
111+ Popup . setInitialZIndex ( getCurrentZIndex ( ) ) ;
112+ } ;
113+
81114const OpenUI5Support = {
82115 isLoaded,
83116 init,
84117 getConfigurationSettingsObject,
85118 getLocaleDataObject,
86119 attachListeners,
87120 cssVariablesLoaded,
121+ getNextZIndex,
122+ setInitialZIndex,
88123} ;
89124
90125registerFeature ( "OpenUI5Support" , OpenUI5Support ) ;
0 commit comments