@ui5/webcomponents-base 2.20.3 → 2.20.5

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/config/ThemeRoot.ts"],
4
- "sourcesContent": ["import createLinkInHead from \"../util/createLinkInHead.js\";\nimport validateThemeRoot from \"../validateThemeRoot.js\";\nimport { getThemeRoot as getConfiguredThemeRoot } from \"../InitialConfiguration.js\";\nimport { getTheme } from \"./Theme.js\";\nimport { attachConfigurationReset } from \"./ConfigurationReset.js\";\n\nlet currThemeRoot: string | undefined;\n\nattachConfigurationReset(() => {\n\tcurrThemeRoot = undefined;\n});\n\n/**\n * Returns the current theme root.\n *\n * @public\n * @since 1.14.0\n * @returns { string } the current theme root\n */\nconst getThemeRoot = (): string | undefined => {\n\tif (currThemeRoot === undefined) {\n\t\tcurrThemeRoot = getConfiguredThemeRoot();\n\t}\n\n\treturn currThemeRoot;\n};\n\n/**\n * Sets theme root for the current theme.\n * When set, the framework will validate the theme root and fetch the theme styles (CSS variables) from this location.\n *\n * **Note:** The feature is specific to custom themes, created with the `UI Theme Designer`.\n * The provided theme root is used only as a base to construct the actual location of the theme styles: `{themeRoot}/.../css_variables.css`.\n *\n * **Note:** Certain security restrictions will apply before fetching the theme assets.\n * Absolute URLs to a different origin than the current page will result in using the current page as an origin.\n *\n * **Important:** To use this feature you must explicitly allow specific origins by using &lt;meta name=\"sap-allowed-theme-origins\" content=\"https://my-example-host.com/\"&gt; tag inside the &lt;head&gt; of the page.\n * Failing to do so will result in a warning in the console and the theme root will not be set.\n *\n * @public\n * @since 1.14.0\n * @param { string } themeRoot the new theme root\n * @returns { Promise<void> }\n */\nconst setThemeRoot = (themeRoot: string): Promise<void> | undefined => {\n\tif (currThemeRoot === themeRoot) {\n\t\treturn;\n\t}\n\n\tcurrThemeRoot = themeRoot;\n\n\tif (!validateThemeRoot(themeRoot)) {\n\t\tconsole.warn(`The ${themeRoot} is not valid. Check the allowed origins as suggested in the \"setThemeRoot\" description.`); // eslint-disable-line\n\t\treturn;\n\t}\n\n\treturn attachCustomThemeStylesToHead(getTheme());\n};\n\nconst formatThemeLink = (theme: string) => {\n\treturn `${getThemeRoot()!}Base/baseLib/${theme}/css_variables.css`; // theme root is always set at this point.\n};\n\nconst attachCustomThemeStylesToHead = async (theme: string): Promise<void> => {\n\tconst link = document.querySelector(`[sap-ui-webcomponents-theme=\"${theme}\"]`);\n\n\tif (link) {\n\t\tdocument.head.removeChild(link);\n\t}\n\n\tawait createLinkInHead(formatThemeLink(theme), { \"sap-ui-webcomponents-theme\": theme });\n};\n\nexport {\n\tgetThemeRoot,\n\tsetThemeRoot,\n\tattachCustomThemeStylesToHead,\n};\n"],
5
- "mappings": "aAAA,OAAOA,MAAsB,8BAC7B,OAAOC,MAAuB,0BAC9B,OAAS,gBAAgBC,MAA8B,6BACvD,OAAS,YAAAC,MAAgB,aACzB,OAAS,4BAAAC,MAAgC,0BAEzC,IAAIC,EAEJD,EAAyB,IAAM,CAC9BC,EAAgB,MACjB,CAAC,EASD,MAAMC,EAAe,KAChBD,IAAkB,SACrBA,EAAgBH,EAAuB,GAGjCG,GAqBFE,EAAgBC,GAAiD,CACtE,GAAIH,IAAkBG,EAMtB,IAFAH,EAAgBG,EAEZ,CAACP,EAAkBO,CAAS,EAAG,CAClC,QAAQ,KAAK,OAAOA,CAAS,0FAA0F,EACvH,MACD,CAEA,OAAOC,EAA8BN,EAAS,CAAC,EAChD,EAEMO,EAAmBC,GACjB,GAAGL,EAAa,CAAE,gBAAgBK,CAAK,qBAGzCF,EAAgC,MAAOE,GAAiC,CAC7E,MAAMC,EAAO,SAAS,cAAc,gCAAgCD,CAAK,IAAI,EAEzEC,GACH,SAAS,KAAK,YAAYA,CAAI,EAG/B,MAAMZ,EAAiBU,EAAgBC,CAAK,EAAG,CAAE,6BAA8BA,CAAM,CAAC,CACvF,EAEA,OACCL,KAAA,aACAC,KAAA,aACAE,KAAA",
6
- "names": ["createLinkInHead", "validateThemeRoot", "getConfiguredThemeRoot", "getTheme", "attachConfigurationReset", "currThemeRoot", "getThemeRoot", "setThemeRoot", "themeRoot", "attachCustomThemeStylesToHead", "formatThemeLink", "theme", "link"]
4
+ "sourcesContent": ["import createLinkInHead from \"../util/createLinkInHead.js\";\nimport validateThemeRoot from \"../validateThemeRoot.js\";\nimport { getThemeRoot as getConfiguredThemeRoot } from \"../InitialConfiguration.js\";\nimport { getTheme } from \"./Theme.js\";\nimport { attachConfigurationReset } from \"./ConfigurationReset.js\";\n\nlet currThemeRoot: string | undefined;\n\nattachConfigurationReset(() => {\n\tcurrThemeRoot = undefined;\n});\n\n/**\n * Returns the current theme root.\n *\n * @public\n * @since 1.14.0\n * @returns { string } the current theme root\n */\nconst getThemeRoot = (): string | undefined => {\n\tif (currThemeRoot === undefined) {\n\t\tcurrThemeRoot = getConfiguredThemeRoot();\n\t}\n\n\treturn currThemeRoot;\n};\n\n/**\n * Sets theme root for the current theme.\n * When set, the framework will validate the theme root and fetch the theme styles (CSS variables) from this location.\n *\n * **Note:** The feature is specific to custom themes, created with the `UI Theme Designer`.\n * The provided theme root is used only as a base to construct the actual location of the theme styles: `{themeRoot}/.../css_variables.css`.\n *\n * **Note:** Certain security restrictions will apply before fetching the theme assets.\n * Absolute URLs to a different origin than the current page will result in using the current page as an origin.\n *\n * **Important:** To use this feature you must explicitly allow specific origins by using &lt;meta name=\"sap-allowed-theme-origins\" content=\"https://my-example-host.com/\"&gt; tag inside the &lt;head&gt; of the page.\n * Failing to do so will result in a warning in the console and the theme root will not be set.\n *\n * @public\n * @since 1.14.0\n * @param { string } themeRoot the new theme root\n * @returns { Promise<void> }\n */\nconst setThemeRoot = (themeRoot: string): Promise<void> | undefined => {\n\tif (currThemeRoot === themeRoot) {\n\t\treturn;\n\t}\n\n\tcurrThemeRoot = themeRoot;\n\n\treturn attachCustomThemeStylesToHead(getTheme());\n};\n\nconst formatThemeLink = (theme: string, validatedThemeRoot: string) => {\n\treturn `${validatedThemeRoot}Base/baseLib/${theme}/css_variables.css`;\n};\n\nconst attachCustomThemeStylesToHead = async (theme: string): Promise<void> => {\n\tconst link = document.querySelector(`[sap-ui-webcomponents-theme=\"${theme}\"]`);\n\n\tif (link) {\n\t\tdocument.head.removeChild(link);\n\t}\n\n\tconst themeRoot = getThemeRoot();\n\n\tif (!themeRoot) {\n\t\treturn;\n\t}\n\n\tconst validatedThemeRoot = validateThemeRoot(themeRoot);\n\n\tif (!validatedThemeRoot) {\n\t\tconsole.warn(`The ${themeRoot} is not valid. Check the allowed origins as suggested in the \"setThemeRoot\" description.`); // eslint-disable-line\n\t\treturn;\n\t}\n\n\tawait createLinkInHead(formatThemeLink(theme, validatedThemeRoot), { \"sap-ui-webcomponents-theme\": theme });\n};\n\nexport {\n\tgetThemeRoot,\n\tsetThemeRoot,\n\tattachCustomThemeStylesToHead,\n};\n"],
5
+ "mappings": "aAAA,OAAOA,MAAsB,8BAC7B,OAAOC,MAAuB,0BAC9B,OAAS,gBAAgBC,MAA8B,6BACvD,OAAS,YAAAC,MAAgB,aACzB,OAAS,4BAAAC,MAAgC,0BAEzC,IAAIC,EAEJD,EAAyB,IAAM,CAC9BC,EAAgB,MACjB,CAAC,EASD,MAAMC,EAAe,KAChBD,IAAkB,SACrBA,EAAgBH,EAAuB,GAGjCG,GAqBFE,EAAgBC,GAAiD,CACtE,GAAIH,IAAkBG,EAItB,OAAAH,EAAgBG,EAETC,EAA8BN,EAAS,CAAC,CAChD,EAEMO,EAAkB,CAACC,EAAeC,IAChC,GAAGA,CAAkB,gBAAgBD,CAAK,qBAG5CF,EAAgC,MAAOE,GAAiC,CAC7E,MAAME,EAAO,SAAS,cAAc,gCAAgCF,CAAK,IAAI,EAEzEE,GACH,SAAS,KAAK,YAAYA,CAAI,EAG/B,MAAML,EAAYF,EAAa,EAE/B,GAAI,CAACE,EACJ,OAGD,MAAMI,EAAqBX,EAAkBO,CAAS,EAEtD,GAAI,CAACI,EAAoB,CACxB,QAAQ,KAAK,OAAOJ,CAAS,0FAA0F,EACvH,MACD,CAEA,MAAMR,EAAiBU,EAAgBC,EAAOC,CAAkB,EAAG,CAAE,6BAA8BD,CAAM,CAAC,CAC3G,EAEA,OACCL,KAAA,aACAC,KAAA,aACAE,KAAA",
6
+ "names": ["createLinkInHead", "validateThemeRoot", "getConfiguredThemeRoot", "getTheme", "attachConfigurationReset", "currThemeRoot", "getThemeRoot", "setThemeRoot", "themeRoot", "attachCustomThemeStylesToHead", "formatThemeLink", "theme", "validatedThemeRoot", "link"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";import u from"../getSharedResource.js";import y from"./insertOpenUI5PopupStyles.js";const p=u("AllOpenedPopupsRegistry",{openedRegistry:[]}),i=e=>{p.openedRegistry.push(e)},a=e=>{const o=p.openedRegistry.findIndex(t=>t.instance===e);o===p.openedRegistry.length-1&&I(),o>-1&&p.openedRegistry.splice(o,1)},c=()=>p.openedRegistry.length===0?null:p.openedRegistry[p.openedRegistry.length-1].instance,l=e=>{for(let o=p.openedRegistry.length-1;o>=0;o--){const t=p.openedRegistry[o];if(t.type==="WebComponent")return!0;if(t.instance===e)break}return!1},s=e=>{const o=e.getContent();return o instanceof HTMLElement?o:o?.getDomRef()||null},d=e=>{if(!["OPENING","OPEN"].includes(e.getOpenState())||!r())return;const t=s(e);if(!t)return;const n=document.getElementById("sap-ui-blocklayer-popup");e.getModal()&&n&&(n.setAttribute("popover","manual"),n.hidePopover(),n.showPopover()),t.setAttribute("popover","manual"),t.showPopover()},g=e=>{const o=s(e);if(o&&(o.hasAttribute("popover")&&(o.hidePopover(),o.removeAttribute("popover")),c()===e&&e.getModal())){const t=document.getElementById("sap-ui-blocklayer-popup");t&&t.hasAttribute("popover")&&t.hidePopover()}},I=()=>{if(!r())return;const e=p.openedRegistry[p.openedRegistry.length-2];if(!e||e.type!=="OpenUI5"||!e.instance.getModal())return;const o=s(e.instance),t=document.getElementById("sap-ui-blocklayer-popup");o?.hidePopover(),t?.showPopover(),o?.showPopover()},r=(e=document)=>e.querySelector(":popover-open")?!0:Array.from(e.querySelectorAll("*")).some(o=>{const t=o.shadowRoot;return t&&r(t)}),P=e=>{const o=e.prototype.onsapescape;e.prototype.onsapescape=function(...n){l(this.oPopup)||o.apply(this,n)}},h=e=>{const o=e.prototype.open;e.prototype.open=function(...n){o.apply(this,n),d(this),i({type:"OpenUI5",instance:this})}},O=e=>{const o=e.prototype._closed;e.prototype._closed=function(...n){g(this),o.apply(this,n),a(this)}},f=e=>{const o=e.prototype.onFocusEvent;e.prototype.onFocusEvent=function(...n){l(this)||o.apply(this,n)}},v=()=>{const e=new CSSStyleSheet;e.replaceSync(".sapMPopup-CTX:popover-open { inset: unset; }"),document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]},m=(e,o)=>{y(),h(e),O(e),v(),f(e),P(o)};export{m as patchPopup,i as addOpenedPopup,a as removeOpenedPopup,c as getTopmostPopup};
1
+ "use strict";import u from"../getSharedResource.js";import y from"./insertOpenUI5PopupStyles.js";const p=u("AllOpenedPopupsRegistry",{openedRegistry:[]}),i=e=>{p.openedRegistry.push(e)},a=e=>{const o=p.openedRegistry.findIndex(t=>t.instance===e);o===p.openedRegistry.length-1&&P(),o>-1&&p.openedRegistry.splice(o,1)},c=()=>p.openedRegistry.length===0?null:p.openedRegistry[p.openedRegistry.length-1].instance,l=e=>{for(let o=p.openedRegistry.length-1;o>=0;o--){const t=p.openedRegistry[o];if(t.type==="WebComponent")return!0;if(t.instance===e)break}return!1},s=e=>{const o=e.getContent();return o instanceof HTMLElement?o:o?.getDomRef()||null},d=e=>{if(!["OPENING","OPEN"].includes(e.getOpenState())||!r())return;const t=s(e);if(!t)return;const n=document.getElementById("sap-ui-blocklayer-popup");e.getModal()&&n&&(n.setAttribute("popover","manual"),n.hidePopover(),n.showPopover()),t.setAttribute("popover","manual"),t.hidePopover(),t.showPopover()},g=e=>{const o=s(e);if(o&&(o.hasAttribute("popover")&&(o.hidePopover(),o.removeAttribute("popover")),c()===e&&e.getModal())){const t=document.getElementById("sap-ui-blocklayer-popup");t&&t.hasAttribute("popover")&&t.hidePopover()}},P=()=>{if(!r())return;const e=p.openedRegistry[p.openedRegistry.length-2];if(!e||e.type!=="OpenUI5"||!e.instance.getModal())return;const o=s(e.instance),t=document.getElementById("sap-ui-blocklayer-popup");o?.hidePopover(),t?.showPopover(),o?.showPopover()},r=(e=document)=>e.querySelector(":popover-open")?!0:Array.from(e.querySelectorAll("*")).some(o=>{const t=o.shadowRoot;return t&&r(t)}),h=e=>{const o=e.prototype.onsapescape;e.prototype.onsapescape=function(...n){l(this.oPopup)||o.apply(this,n)}},I=e=>{const o=e.prototype.open;e.prototype.open=function(...n){o.apply(this,n),d(this),i({type:"OpenUI5",instance:this})}},O=e=>{const o=e.prototype._closed;e.prototype._closed=function(...n){g(this),o.apply(this,n),a(this)}},f=e=>{const o=e.prototype.onFocusEvent;e.prototype.onFocusEvent=function(...n){l(this)||o.apply(this,n)}},v=()=>{const e=new CSSStyleSheet;e.replaceSync(".sapMPopup-CTX:popover-open { inset: unset; }"),document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]},m=(e,o)=>{y(),I(e),O(e),v(),f(e),h(o)};export{m as patchPopup,i as addOpenedPopup,a as removeOpenedPopup,c as getTopmostPopup};
2
2
  //# sourceMappingURL=patchPopup.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/features/patchPopup.ts"],
4
- "sourcesContent": ["// OpenUI5's Control.js subset\nimport getSharedResource from \"../getSharedResource.js\";\nimport insertOpenUI5PopupStyles from \"./insertOpenUI5PopupStyles.js\";\n\ntype Control = {\n\tgetDomRef: () => HTMLElement | null,\n}\n\n// The lifecycle of Popup.js is open -> _opened -> close -> _closed, we're interested in the first (open) and last (_closed)\ntype OpenUI5Popup = {\n\topen: (...args: any[]) => void,\n\t_closed: (...args: any[]) => void,\n\tgetOpenState: () => \"CLOSED\" | \"CLOSING\" | \"OPEN\" | \"OPENING\",\n\tgetContent: () => Control | HTMLElement | null, // this is the OpenUI5 Element/Control instance that opens the Popup (usually sap.m.Popover/sap.m.Dialog)\n\tonFocusEvent: (...args: any[]) => void,\n\tgetModal: () => boolean\n};\n\ntype OpenUI5PopupClass = {\n\tprototype: OpenUI5Popup\n};\n\ntype OpenUI5DialogClass = {\n\tprototype: {\n\t\tonsapescape: (...args: any[]) => void,\n\t\toPopup: OpenUI5Popup,\n\t}\n};\n\ntype PopupInfo = {\n\ttype: \"WebComponent\";\n\tinstance: object;\n} | {\n\ttype: \"OpenUI5\";\n\tinstance: OpenUI5Popup;\n};\n\n// contains all OpenUI5 and Web Component popups that are currently opened\nconst AllOpenedPopupsRegistry = getSharedResource<{ openedRegistry: Array<PopupInfo> }>(\"AllOpenedPopupsRegistry\", { openedRegistry: [] });\n\nconst addOpenedPopup = (popupInfo: PopupInfo) => {\n\tAllOpenedPopupsRegistry.openedRegistry.push(popupInfo);\n};\n\nconst removeOpenedPopup = (popup: object) => {\n\tconst index = AllOpenedPopupsRegistry.openedRegistry.findIndex(el => el.instance === popup);\n\n\tif (index === AllOpenedPopupsRegistry.openedRegistry.length - 1) {\n\t\tfixTopmostOpenUI5Popup();\n\t}\n\n\tif (index > -1) {\n\t\tAllOpenedPopupsRegistry.openedRegistry.splice(index, 1);\n\t}\n};\n\nconst getTopmostPopup = () => {\n\tif (AllOpenedPopupsRegistry.openedRegistry.length === 0) {\n\t\treturn null;\n\t}\n\treturn AllOpenedPopupsRegistry.openedRegistry[AllOpenedPopupsRegistry.openedRegistry.length - 1].instance;\n};\n\n/**\n * Determines whether there is a Web Component popup opened above (a specified popup).\n *\n * @param {object} popup The popup instance to check against.\n * @returns {boolean} `true` if a Web Component popup is opened above (the given popup instance); otherwise `false`.\n */\nconst hasWebComponentPopupAbove = (popup: object) => {\n\tfor (let i = AllOpenedPopupsRegistry.openedRegistry.length - 1; i >= 0; i--) {\n\t\tconst popupInfo = AllOpenedPopupsRegistry.openedRegistry[i];\n\t\tif (popupInfo.type === \"WebComponent\") {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (popupInfo.instance === popup) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn false;\n};\n\nconst getPopupContentElement = (popup: OpenUI5Popup): HTMLElement | null => {\n\tconst content = popup.getContent();\n\treturn content instanceof HTMLElement ? content : content?.getDomRef() || null;\n};\n\nconst openNativePopoverForOpenUI5 = (popup: OpenUI5Popup) => {\n\tconst openingInitiated = [\"OPENING\", \"OPEN\"].includes(popup.getOpenState());\n\tif (!openingInitiated || !isNativePopoverOpen()) {\n\t\treturn;\n\t}\n\n\tconst domRef = getPopupContentElement(popup);\n\n\tif (!domRef) {\n\t\treturn;\n\t}\n\n\tconst openUI5BlockLayer = document.getElementById(\"sap-ui-blocklayer-popup\");\n\n\tif (popup.getModal() && openUI5BlockLayer) {\n\t\topenUI5BlockLayer.setAttribute(\"popover\", \"manual\");\n\t\topenUI5BlockLayer.hidePopover();\n\t\topenUI5BlockLayer.showPopover();\n\t}\n\n\tdomRef.setAttribute(\"popover\", \"manual\");\n\tdomRef.showPopover();\n};\n\nconst closeNativePopoverForOpenUI5 = (popup: OpenUI5Popup) => {\n\tconst domRef = getPopupContentElement(popup);\n\n\tif (!domRef) {\n\t\treturn;\n\t}\n\n\tif (domRef.hasAttribute(\"popover\")) {\n\t\tdomRef.hidePopover();\n\t\tdomRef.removeAttribute(\"popover\");\n\t}\n\n\tif (getTopmostPopup() !== popup) {\n\t\treturn;\n\t}\n\n\t// The OpenUI5 block layer is only one for all modal OpenUI5 popups,\n\t// and it is displayed above all opened pupups - OpenUI5 and Web Components,\n\t// as a result, we need to hide this block layer.\n\t// If the underlying popup is a Web Component - it is displayed like a native popover, and we don't need to do anything\n\t// If the underlying popup is an OpenUI5 popup, it will be fixed in fixTopmostOpenUI5Popup method.\n\tif (popup.getModal()) {\n\t\tconst openUI5BlockLayer = document.getElementById(\"sap-ui-blocklayer-popup\");\n\t\tif (openUI5BlockLayer && openUI5BlockLayer.hasAttribute(\"popover\")) {\n\t\t\topenUI5BlockLayer.hidePopover();\n\t\t}\n\t}\n};\n\nconst fixTopmostOpenUI5Popup = () => {\n\tif (!isNativePopoverOpen()) {\n\t\treturn;\n\t}\n\n\tconst prevPopup = AllOpenedPopupsRegistry.openedRegistry[AllOpenedPopupsRegistry.openedRegistry.length - 2];\n\tif (!prevPopup\n\t\t|| prevPopup.type !== \"OpenUI5\"\n\t\t|| !prevPopup.instance.getModal()) {\n\t\treturn;\n\t}\n\n\tconst content = getPopupContentElement(prevPopup.instance);\n\tconst openUI5BlockLayer = document.getElementById(\"sap-ui-blocklayer-popup\");\n\n\tcontent?.hidePopover();\n\topenUI5BlockLayer?.showPopover();\n\n\tcontent?.showPopover();\n};\n\nconst isNativePopoverOpen = (root: Document | ShadowRoot = document): boolean => {\n\tif (root.querySelector(\":popover-open\")) {\n\t\treturn true;\n\t}\n\n\treturn Array.from(root.querySelectorAll(\"*\")).some(element => {\n\t\tconst shadowRoot = element.shadowRoot;\n\t\treturn shadowRoot && isNativePopoverOpen(shadowRoot);\n\t});\n};\n\nconst patchDialog = (Dialog: OpenUI5DialogClass) => {\n\tconst origOnsapescape = Dialog.prototype.onsapescape;\n\tDialog.prototype.onsapescape = function onsapescape(...args: any[]) {\n\t\tif (hasWebComponentPopupAbove(this.oPopup)) {\n\t\t\treturn;\n\t\t}\n\n\t\torigOnsapescape.apply(this, args);\n\t};\n};\n\nconst patchOpen = (Popup: OpenUI5PopupClass) => {\n\tconst origOpen = Popup.prototype.open;\n\tPopup.prototype.open = function open(...args: any[]) {\n\t\torigOpen.apply(this, args); // call open first to initiate opening\n\t\topenNativePopoverForOpenUI5(this);\n\n\t\taddOpenedPopup({\n\t\t\ttype: \"OpenUI5\",\n\t\t\tinstance: this,\n\t\t});\n\t};\n};\n\nconst patchClosed = (Popup: OpenUI5PopupClass) => {\n\tconst _origClosed = Popup.prototype._closed;\n\tPopup.prototype._closed = function _closed(...args: any[]) {\n\t\tcloseNativePopoverForOpenUI5(this);\n\t\t_origClosed.apply(this, args); // only then call _close\n\t\tremoveOpenedPopup(this);\n\t};\n};\n\nconst patchFocusEvent = (Popup: OpenUI5PopupClass) => {\n\tconst origFocusEvent = Popup.prototype.onFocusEvent;\n\tPopup.prototype.onFocusEvent = function onFocusEvent(...args: any[]) {\n\t\tif (!hasWebComponentPopupAbove(this)) {\n\t\t\torigFocusEvent.apply(this, args);\n\t\t}\n\t};\n};\n\nconst createGlobalStyles = () => {\n\tconst stylesheet = new CSSStyleSheet();\n\tstylesheet.replaceSync(`.sapMPopup-CTX:popover-open { inset: unset; }`);\n\tdocument.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];\n};\n\nconst patchPopup = (Popup: OpenUI5PopupClass, Dialog: OpenUI5DialogClass) => {\n\tinsertOpenUI5PopupStyles();\n\tpatchOpen(Popup); // Popup.prototype.open\n\tpatchClosed(Popup); // Popup.prototype._closed\n\tcreateGlobalStyles(); // Ensures correct popover positioning by OpenUI5 (otherwise 0,0 is the center of the screen)\n\tpatchFocusEvent(Popup);// Popup.prototype.onFocusEvent\n\tpatchDialog(Dialog); // Dialog.prototype.onsapescape\n};\n\nexport {\n\tpatchPopup,\n\taddOpenedPopup,\n\tremoveOpenedPopup,\n\tgetTopmostPopup,\n};\n\nexport type { OpenUI5PopupClass, OpenUI5DialogClass, PopupInfo };\n"],
5
- "mappings": "aACA,OAAOA,MAAuB,0BAC9B,OAAOC,MAA8B,gCAoCrC,MAAMC,EAA0BF,EAAwD,0BAA2B,CAAE,eAAgB,CAAC,CAAE,CAAC,EAEnIG,EAAkBC,GAAyB,CAChDF,EAAwB,eAAe,KAAKE,CAAS,CACtD,EAEMC,EAAqBC,GAAkB,CAC5C,MAAMC,EAAQL,EAAwB,eAAe,UAAUM,GAAMA,EAAG,WAAaF,CAAK,EAEtFC,IAAUL,EAAwB,eAAe,OAAS,GAC7DO,EAAuB,EAGpBF,EAAQ,IACXL,E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AAa,IAAI,cACvBA,EAAW,YAAY,+CAA+C,EACtE,SAAS,mBAAqB,CAAC,GAAG,SAAS,mBAAoBA,CAAU,CAC1E,EAEMC,EAAa,CAACR,EAA0BJ,IAA+B,CAC5ExB,EAAyB,EACzB2B,EAAUC,CAAK,EACfE,EAAYF,CAAK,EACjBM,EAAmB,EACnBF,EAAgBJ,CAAK,EACrBL,EAAYC,CAAM,CACnB,EAEA,OACCY,KAAA,WACAlC,KAAA,eACAE,KAAA,kBACAK,KAAA",
4
+ "sourcesContent": ["// OpenUI5's Control.js subset\nimport getSharedResource from \"../getSharedResource.js\";\nimport insertOpenUI5PopupStyles from \"./insertOpenUI5PopupStyles.js\";\n\ntype Control = {\n\tgetDomRef: () => HTMLElement | null,\n}\n\n// The lifecycle of Popup.js is open -> _opened -> close -> _closed, we're interested in the first (open) and last (_closed)\ntype OpenUI5Popup = {\n\topen: (...args: any[]) => void,\n\t_closed: (...args: any[]) => void,\n\tgetOpenState: () => \"CLOSED\" | \"CLOSING\" | \"OPEN\" | \"OPENING\",\n\tgetContent: () => Control | HTMLElement | null, // this is the OpenUI5 Element/Control instance that opens the Popup (usually sap.m.Popover/sap.m.Dialog)\n\tonFocusEvent: (...args: any[]) => void,\n\tgetModal: () => boolean\n};\n\ntype OpenUI5PopupClass = {\n\tprototype: OpenUI5Popup\n};\n\ntype OpenUI5DialogClass = {\n\tprototype: {\n\t\tonsapescape: (...args: any[]) => void,\n\t\toPopup: OpenUI5Popup,\n\t}\n};\n\ntype PopupInfo = {\n\ttype: \"WebComponent\";\n\tinstance: object;\n} | {\n\ttype: \"OpenUI5\";\n\tinstance: OpenUI5Popup;\n};\n\n// contains all OpenUI5 and Web Component popups that are currently opened\nconst AllOpenedPopupsRegistry = getSharedResource<{ openedRegistry: Array<PopupInfo> }>(\"AllOpenedPopupsRegistry\", { openedRegistry: [] });\n\nconst addOpenedPopup = (popupInfo: PopupInfo) => {\n\tAllOpenedPopupsRegistry.openedRegistry.push(popupInfo);\n};\n\nconst removeOpenedPopup = (popup: object) => {\n\tconst index = AllOpenedPopupsRegistry.openedRegistry.findIndex(el => el.instance === popup);\n\n\tif (index === AllOpenedPopupsRegistry.openedRegistry.length - 1) {\n\t\tfixTopmostOpenUI5Popup();\n\t}\n\n\tif (index > -1) {\n\t\tAllOpenedPopupsRegistry.openedRegistry.splice(index, 1);\n\t}\n};\n\nconst getTopmostPopup = () => {\n\tif (AllOpenedPopupsRegistry.openedRegistry.length === 0) {\n\t\treturn null;\n\t}\n\treturn AllOpenedPopupsRegistry.openedRegistry[AllOpenedPopupsRegistry.openedRegistry.length - 1].instance;\n};\n\n/**\n * Determines whether there is a Web Component popup opened above (a specified popup).\n *\n * @param {object} popup The popup instance to check against.\n * @returns {boolean} `true` if a Web Component popup is opened above (the given popup instance); otherwise `false`.\n */\nconst hasWebComponentPopupAbove = (popup: object) => {\n\tfor (let i = AllOpenedPopupsRegistry.openedRegistry.length - 1; i >= 0; i--) {\n\t\tconst popupInfo = AllOpenedPopupsRegistry.openedRegistry[i];\n\t\tif (popupInfo.type === \"WebComponent\") {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (popupInfo.instance === popup) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn false;\n};\n\nconst getPopupContentElement = (popup: OpenUI5Popup): HTMLElement | null => {\n\tconst content = popup.getContent();\n\treturn content instanceof HTMLElement ? content : content?.getDomRef() || null;\n};\n\nconst openNativePopoverForOpenUI5 = (popup: OpenUI5Popup) => {\n\tconst openingInitiated = [\"OPENING\", \"OPEN\"].includes(popup.getOpenState());\n\tif (!openingInitiated || !isNativePopoverOpen()) {\n\t\treturn;\n\t}\n\n\tconst domRef = getPopupContentElement(popup);\n\n\tif (!domRef) {\n\t\treturn;\n\t}\n\n\tconst openUI5BlockLayer = document.getElementById(\"sap-ui-blocklayer-popup\");\n\n\tif (popup.getModal() && openUI5BlockLayer) {\n\t\topenUI5BlockLayer.setAttribute(\"popover\", \"manual\");\n\t\topenUI5BlockLayer.hidePopover();\n\t\topenUI5BlockLayer.showPopover();\n\t}\n\n\tdomRef.setAttribute(\"popover\", \"manual\");\n\tdomRef.hidePopover();\n\tdomRef.showPopover();\n};\n\nconst closeNativePopoverForOpenUI5 = (popup: OpenUI5Popup) => {\n\tconst domRef = getPopupContentElement(popup);\n\n\tif (!domRef) {\n\t\treturn;\n\t}\n\n\tif (domRef.hasAttribute(\"popover\")) {\n\t\tdomRef.hidePopover();\n\t\tdomRef.removeAttribute(\"popover\");\n\t}\n\n\tif (getTopmostPopup() !== popup) {\n\t\treturn;\n\t}\n\n\t// The OpenUI5 block layer is only one for all modal OpenUI5 popups,\n\t// and it is displayed above all opened pupups - OpenUI5 and Web Components,\n\t// as a result, we need to hide this block layer.\n\t// If the underlying popup is a Web Component - it is displayed like a native popover, and we don't need to do anything\n\t// If the underlying popup is an OpenUI5 popup, it will be fixed in fixTopmostOpenUI5Popup method.\n\tif (popup.getModal()) {\n\t\tconst openUI5BlockLayer = document.getElementById(\"sap-ui-blocklayer-popup\");\n\t\tif (openUI5BlockLayer && openUI5BlockLayer.hasAttribute(\"popover\")) {\n\t\t\topenUI5BlockLayer.hidePopover();\n\t\t}\n\t}\n};\n\nconst fixTopmostOpenUI5Popup = () => {\n\tif (!isNativePopoverOpen()) {\n\t\treturn;\n\t}\n\n\tconst prevPopup = AllOpenedPopupsRegistry.openedRegistry[AllOpenedPopupsRegistry.openedRegistry.length - 2];\n\tif (!prevPopup\n\t\t|| prevPopup.type !== \"OpenUI5\"\n\t\t|| !prevPopup.instance.getModal()) {\n\t\treturn;\n\t}\n\n\tconst content = getPopupContentElement(prevPopup.instance);\n\tconst openUI5BlockLayer = document.getElementById(\"sap-ui-blocklayer-popup\");\n\n\tcontent?.hidePopover();\n\topenUI5BlockLayer?.showPopover();\n\n\tcontent?.showPopover();\n};\n\nconst isNativePopoverOpen = (root: Document | ShadowRoot = document): boolean => {\n\tif (root.querySelector(\":popover-open\")) {\n\t\treturn true;\n\t}\n\n\treturn Array.from(root.querySelectorAll(\"*\")).some(element => {\n\t\tconst shadowRoot = element.shadowRoot;\n\t\treturn shadowRoot && isNativePopoverOpen(shadowRoot);\n\t});\n};\n\nconst patchDialog = (Dialog: OpenUI5DialogClass) => {\n\tconst origOnsapescape = Dialog.prototype.onsapescape;\n\tDialog.prototype.onsapescape = function onsapescape(...args: any[]) {\n\t\tif (hasWebComponentPopupAbove(this.oPopup)) {\n\t\t\treturn;\n\t\t}\n\n\t\torigOnsapescape.apply(this, args);\n\t};\n};\n\nconst patchOpen = (Popup: OpenUI5PopupClass) => {\n\tconst origOpen = Popup.prototype.open;\n\tPopup.prototype.open = function open(...args: any[]) {\n\t\torigOpen.apply(this, args); // call open first to initiate opening\n\t\topenNativePopoverForOpenUI5(this);\n\n\t\taddOpenedPopup({\n\t\t\ttype: \"OpenUI5\",\n\t\t\tinstance: this,\n\t\t});\n\t};\n};\n\nconst patchClosed = (Popup: OpenUI5PopupClass) => {\n\tconst _origClosed = Popup.prototype._closed;\n\tPopup.prototype._closed = function _closed(...args: any[]) {\n\t\tcloseNativePopoverForOpenUI5(this);\n\t\t_origClosed.apply(this, args); // only then call _close\n\t\tremoveOpenedPopup(this);\n\t};\n};\n\nconst patchFocusEvent = (Popup: OpenUI5PopupClass) => {\n\tconst origFocusEvent = Popup.prototype.onFocusEvent;\n\tPopup.prototype.onFocusEvent = function onFocusEvent(...args: any[]) {\n\t\tif (!hasWebComponentPopupAbove(this)) {\n\t\t\torigFocusEvent.apply(this, args);\n\t\t}\n\t};\n};\n\nconst createGlobalStyles = () => {\n\tconst stylesheet = new CSSStyleSheet();\n\tstylesheet.replaceSync(`.sapMPopup-CTX:popover-open { inset: unset; }`);\n\tdocument.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];\n};\n\nconst patchPopup = (Popup: OpenUI5PopupClass, Dialog: OpenUI5DialogClass) => {\n\tinsertOpenUI5PopupStyles();\n\tpatchOpen(Popup); // Popup.prototype.open\n\tpatchClosed(Popup); // Popup.prototype._closed\n\tcreateGlobalStyles(); // Ensures correct popover positioning by OpenUI5 (otherwise 0,0 is the center of the screen)\n\tpatchFocusEvent(Popup);// Popup.prototype.onFocusEvent\n\tpatchDialog(Dialog); // Dialog.prototype.onsapescape\n};\n\nexport {\n\tpatchPopup,\n\taddOpenedPopup,\n\tremoveOpenedPopup,\n\tgetTopmostPopup,\n};\n\nexport type { OpenUI5PopupClass, OpenUI5DialogClass, PopupInfo };\n"],
5
+ "mappings": "aACA,OAAOA,MAAuB,0BAC9B,OAAOC,MAA8B,gCAoCrC,MAAMC,EAA0BF,EAAwD,0BAA2B,CAAE,eAAgB,CAAC,CAAE,CAAC,EAEnIG,EAAkBC,GAAyB,CAChDF,EAAwB,eAAe,KAAKE,CAAS,CACtD,EAEMC,EAAqBC,GAAkB,CAC5C,MAAMC,EAAQL,EAAwB,eAAe,UAAUM,GAAMA,EAAG,WAAaF,CAAK,EAEtFC,IAAUL,EAAwB,eAAe,OAAS,GAC7DO,EAAuB,EAGpBF,EAAQ,IACXL,EAAwB,eAAe,OAAOK,EAAO,CAAC,CAExD,EAEMG,EAAkB,IACnBR,EAAwB,eAAe,SAAW,EAC9C,KAEDA,EAAwB,eAAeA,EAAwB,eAAe,OAAS,CAAC,EAAE,SAS5FS,EAA6BL,GAAkB,CACpD,QAASM,EAAIV,EAAwB,eAAe,OAAS,EAAGU,GAAK,EAAGA,IAAK,CAC5E,MAAMR,EAAYF,EAAwB,eAAeU,CAAC,EAC1D,GAAIR,EAAU,OAAS,eACtB,MAAO,GAGR,GAAIA,EAAU,WAAaE,EAC1B,KAEF,CAEA,MAAO,EACR,EAEMO,EAA0BP,GAA4C,CAC3E,MAAMQ,EAAUR,EAAM,WAAW,EACjC,OAAOQ,aAAmB,YAAcA,EAAUA,GAAS,UAAU,GAAK,IAC3E,EAEMC,EAA+BT,GAAwB,CAE5D,GAAI,CADqB,CAAC,UAAW,MAAM,EAAE,SAASA,EAAM,aAAa,CAAC,GACjD,CAACU,EAAoB,EAC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A0B,KAAK,MAAM,GAIzCe,EAAgB,MAAM,KAAMC,CAAI,CACjC,CACD,EAEMC,EAAaC,GAA6B,CAC/C,MAAMC,EAAWD,EAAM,UAAU,KACjCA,EAAM,UAAU,KAAO,YAAiBF,EAAa,CACpDG,EAAS,MAAM,KAAMH,CAAI,EACzBZ,EAA4B,IAAI,EAEhCZ,EAAe,CACd,KAAM,UACN,SAAU,IACX,CAAC,CACF,CACD,EAEM4B,EAAeF,GAA6B,CACjD,MAAMG,EAAcH,EAAM,UAAU,QACpCA,EAAM,UAAU,QAAU,YAAoBF,EAAa,CAC1DR,EAA6B,IAAI,EACjCa,EAAY,MAAM,KAAML,CAAI,EAC5BtB,EAAkB,IAAI,CACvB,CACD,EAEM4B,EAAmBJ,GAA6B,CACrD,MAAMK,EAAiBL,EAAM,UAAU,aACvCA,EAAM,UAAU,aAAe,YAAyBF,EAAa,CAC/DhB,EAA0B,IAAI,GAClCuB,EAAe,MAAM,KAAMP,CAAI,CAEjC,CACD,EAEMQ,EAAqB,IAAM,CAChC,MAAMC,EAAa,IAAI,cACvBA,EAAW,YAAY,+CAA+C,EACtE,SAAS,mBAAqB,CAAC,GAAG,SAAS,mBAAoBA,CAAU,CAC1E,EAEMC,EAAa,CAACR,EAA0BJ,IAA+B,CAC5ExB,EAAyB,EACzB2B,EAAUC,CAAK,EACfE,EAAYF,CAAK,EACjBM,EAAmB,EACnBF,EAAgBJ,CAAK,EACrBL,EAAYC,CAAM,CACnB,EAEA,OACCY,KAAA,WACAlC,KAAA,eACAE,KAAA,kBACAK,KAAA",
6
6
  "names": ["getSharedResource", "insertOpenUI5PopupStyles", "AllOpenedPopupsRegistry", "addOpenedPopup", "popupInfo", "removeOpenedPopup", "popup", "index", "el", "fixTopmostOpenUI5Popup", "getTopmostPopup", "hasWebComponentPopupAbove", "i", "getPopupContentElement", "content", "openNativePopoverForOpenUI5", "isNativePopoverOpen", "domRef", "openUI5BlockLayer", "closeNativePopoverForOpenUI5", "prevPopup", "root", "element", "shadowRoot", "patchDialog", "Dialog", "origOnsapescape", "args", "patchOpen", "Popup", "origOpen", "patchClosed", "_origClosed", "patchFocusEvent", "origFocusEvent", "createGlobalStyles", "stylesheet", "patchPopup"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";const e={version:"2.20.3",major:2,minor:20,patch:3,suffix:"",isNext:!1,buildTime:1776343301};export default e;
1
+ "use strict";const e={version:"2.20.5",major:2,minor:20,patch:5,suffix:"",isNext:!1,buildTime:1781249309};export default e;
2
2
  //# sourceMappingURL=VersionInfo.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/generated/VersionInfo.ts"],
4
- "sourcesContent": ["const VersionInfo = {\n\tversion: \"2.20.3\",\n\tmajor: 2,\n\tminor: 20,\n\tpatch: 3,\n\tsuffix: \"\",\n\tisNext: false,\n\tbuildTime: 1776343301,\n};\nexport default VersionInfo;"],
4
+ "sourcesContent": ["const VersionInfo = {\n\tversion: \"2.20.5\",\n\tmajor: 2,\n\tminor: 20,\n\tpatch: 5,\n\tsuffix: \"\",\n\tisNext: false,\n\tbuildTime: 1781249309,\n};\nexport default VersionInfo;"],
5
5
  "mappings": "aAAA,MAAMA,EAAc,CACnB,QAAS,SACT,MAAO,EACP,MAAO,GACP,MAAO,EACP,OAAQ,GACR,OAAQ,GACR,UAAW,UACZ,EACA,eAAeA",
6
6
  "names": ["VersionInfo"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";import{getLocationHref as i}from"./Location.js";const s=e=>{const t=document.querySelector(`META[name="${e}"]`);return t&&t.getAttribute("content")},o=e=>{const t=s("sap-allowed-theme-origins")??s("sap-allowedThemeOrigins");return t?t.split(",").some(n=>n==="*"||e===n.trim()):!1},a=(e,t)=>{const n=new URL(e).pathname;return new URL(n,t).toString()},g=e=>{let t;try{if(e.startsWith(".")||e.startsWith("/"))t=new URL(e,i()).toString();else{const n=new URL(e),r=n.origin;r&&o(r)?t=n.toString():t=a(n.toString(),i())}return t.endsWith("/")||(t=`${t}/`),`${t}UI5/`}catch{}};export default g;
1
+ "use strict";import{getLocationHref as s}from"./Location.js";const a=t=>{const e=document.querySelector(`META[name="${t}"]`);return e&&e.getAttribute("content")},g=(t,e=!1)=>{const n=a("sap-allowed-theme-origins")??a("sap-allowedThemeOrigins");return n?e?!0:n.split(",").some(r=>r==="*"||t===r.trim()):!1},l=t=>{let e,n=!1;try{if(t.startsWith(".")||t.startsWith("/")&&!t.startsWith("//"))e=new URL(t,s()).toString(),n=!0;else{const r=t.startsWith("//")?new URL(t,s()):new URL(t),i=r.origin,o=new URL(s()).origin;if(n=i===o,i&&g(i,n))e=r.toString();else return}return e.endsWith("/")||(e=`${e}/`),`${e}UI5/`}catch{return}};export default l;
2
2
  //# sourceMappingURL=validateThemeRoot.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/validateThemeRoot.ts"],
4
- "sourcesContent": ["import { getLocationHref } from \"./Location.js\";\n\nconst getMetaTagValue = (metaTagName: string) => {\n\tconst metaTag = document.querySelector(`META[name=\"${metaTagName}\"]`),\n\t\tmetaTagContent = metaTag && metaTag.getAttribute(\"content\");\n\n\treturn metaTagContent;\n};\n\nconst validateThemeOrigin = (origin: string) => {\n\tconst allowedOrigins = getMetaTagValue(\"sap-allowed-theme-origins\") ?? getMetaTagValue(\"sap-allowedThemeOrigins\"); // Prioritize the new meta tag name\n\n\t// If no allowed origins are specified, block.\n\tif (!allowedOrigins) {\n\t\treturn false;\n\t}\n\n\treturn allowedOrigins.split(\",\").some(allowedOrigin => {\n\t\treturn allowedOrigin === \"*\" || origin === allowedOrigin.trim();\n\t});\n};\n\nconst buildCorrectUrl = (oldUrl: string, newOrigin: string) => {\n\tconst oldUrlPath = new URL(oldUrl).pathname;\n\n\treturn new URL(oldUrlPath, newOrigin).toString();\n};\n\nconst validateThemeRoot = (themeRoot: string) => {\n\tlet resultUrl;\n\n\ttry {\n\t\tif (themeRoot.startsWith(\".\") || themeRoot.startsWith(\"/\")) {\n\t\t\t// Handle relative url\n\t\t\t// new URL(\"/newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\t// new URL(\"./newExmPath\", \"http://example.com/exmPath\") => http://example.com/exmPath/newExmPath\n\t\t\t// new URL(\"../newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\tresultUrl = new URL(themeRoot, getLocationHref()).toString();\n\t\t} else {\n\t\t\tconst themeRootURL = new URL(themeRoot);\n\t\t\tconst origin = themeRootURL.origin;\n\n\t\t\tif (origin && validateThemeOrigin(origin)) {\n\t\t\t\t// If origin is allowed, use it\n\t\t\t\tresultUrl = themeRootURL.toString();\n\t\t\t} else {\n\t\t\t\t// If origin is not allow and the URL is not relative, we have to replace the origin\n\t\t\t\t// with current location\n\t\t\t\tresultUrl = buildCorrectUrl(themeRootURL.toString(), getLocationHref());\n\t\t\t}\n\t\t}\n\n\t\tif (!resultUrl.endsWith(\"/\")) {\n\t\t\tresultUrl = `${resultUrl}/`;\n\t\t}\n\n\t\treturn `${resultUrl}UI5/`;\n\t} catch (e) {\n\t\t// Catch if URL is not correct\n\t}\n};\n\nexport default validateThemeRoot;\n"],
5
- "mappings": "aAAA,OAAS,mBAAAA,MAAuB,gBAEhC,MAAMC,EAAmBC,GAAwB,CAChD,MAAMC,EAAU,SAAS,cAAc,cAAcD,CAAW,IAAI,EAGpE,OAFkBC,GAAWA,EAAQ,aAAa,SAAS,CAG5D,EAEMC,EAAuBC,GAAmB,CAC/C,MAAMC,EAAiBL,EAAgB,2BAA2B,GAAKA,EAAgB,yBAAyB,EAGhH,OAAKK,EAIEA,EAAe,MAAM,GAAG,EAAE,KAAKC,GAC9BA,IAAkB,KAAOF,IAAWE,EAAc,KAAK,CAC9D,EALO,EAMT,EAEMC,EAAkB,CAACC,EAAgBC,IAAsB,CAC9D,MAAMC,EAAa,IAAI,IAAIF,CAAM,EAAE,SAEnC,OAAO,IAAI,IAAIE,EAAYD,CAAS,EAAE,SAAS,CAChD,EAEME,EAAqBC,GAAsB,CAChD,IAAIC,EAEJ,GAAI,CACH,GAAID,EAAU,WAAW,GAAG,GAAKA,EAAU,WAAW,GAAG,EAKxDC,EAAY,IAAI,IAAID,EAAWb,EAAgB,CAAC,EAAE,SAAS,MACrD,CACN,MAAMe,EAAe,IAAI,IAAIF,CAAS,EAChCR,EAASU,EAAa,OAExBV,GAAUD,EAAoBC,CAAM,EAEvCS,EAAYC,EAAa,SAAS,EAIlCD,EAAYN,EAAgBO,EAAa,SAAS,EAAGf,EAAgB,CAAC,CAExE,CAEA,OAAKc,EAAU,SAAS,GAAG,IAC1BA,EAAY,GAAGA,CAAS,KAGlB,GAAGA,CAAS,MACpB,MAAY,CAEZ,CACD,EAEA,eAAeF",
6
- "names": ["getLocationHref", "getMetaTagValue", "metaTagName", "metaTag", "validateThemeOrigin", "origin", "allowedOrigins", "allowedOrigin", "buildCorrectUrl", "oldUrl", "newOrigin", "oldUrlPath", "validateThemeRoot", "themeRoot", "resultUrl", "themeRootURL"]
4
+ "sourcesContent": ["import { getLocationHref } from \"./Location.js\";\n\nconst getMetaTagValue = (metaTagName: string) => {\n\tconst metaTag = document.querySelector(`META[name=\"${metaTagName}\"]`),\n\t\tmetaTagContent = metaTag && metaTag.getAttribute(\"content\");\n\n\treturn metaTagContent;\n};\n\nconst validateThemeOrigin = (origin: string, isSameOrigin: boolean = false) => {\n\tconst allowedOrigins = getMetaTagValue(\"sap-allowed-theme-origins\") ?? getMetaTagValue(\"sap-allowedThemeOrigins\"); // Prioritize the new meta tag name\n\n\t// If no allowed origins are specified, block.\n\tif (!allowedOrigins) {\n\t\treturn false;\n\t}\n\n\t// If it's same-origin (relative URL resolved to current page), allow it when there's any meta tag present\n\t// The presence of the meta tag indicates the user wants to use theme roots\n\tif (isSameOrigin) {\n\t\treturn true;\n\t}\n\n\treturn allowedOrigins.split(\",\").some(allowedOrigin => {\n\t\treturn allowedOrigin === \"*\" || origin === allowedOrigin.trim();\n\t});\n};\n\nconst validateThemeRoot = (themeRoot: string) => {\n\tlet resultUrl;\n\tlet isSameOrigin = false;\n\n\ttry {\n\t\tif (themeRoot.startsWith(\".\") || (themeRoot.startsWith(\"/\") && !themeRoot.startsWith(\"//\"))) {\n\t\t\t// Handle relative url\n\t\t\t// new URL(\"/newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\t// new URL(\"./newExmPath\", \"http://example.com/exmPath\") => http://example.com/exmPath/newExmPath\n\t\t\t// new URL(\"../newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\tresultUrl = new URL(themeRoot, getLocationHref()).toString();\n\t\t\tisSameOrigin = true;\n\t\t} else {\n\t\t\t// Protocol-relative URLs (//host/path) need a base to resolve the protocol\n\t\t\tconst themeRootURL = themeRoot.startsWith(\"//\") ? new URL(themeRoot, getLocationHref()) : new URL(themeRoot);\n\t\t\tconst origin = themeRootURL.origin;\n\t\t\tconst currentOrigin = new URL(getLocationHref()).origin;\n\n\t\t\t// Check if the absolute URL is same-origin\n\t\t\tisSameOrigin = origin === currentOrigin;\n\n\t\t\tif (origin && validateThemeOrigin(origin, isSameOrigin)) {\n\t\t\t\t// If origin is allowed, use it\n\t\t\t\tresultUrl = themeRootURL.toString();\n\t\t\t} else {\n\t\t\t\t// If origin is not allowed, return undefined to indicate validation failed\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (!resultUrl.endsWith(\"/\")) {\n\t\t\tresultUrl = `${resultUrl}/`;\n\t\t}\n\n\t\treturn `${resultUrl}UI5/`;\n\t} catch (e) {\n\t\t// Catch if URL is not correct\n\t\treturn undefined;\n\t}\n};\n\nexport default validateThemeRoot;\n"],
5
+ "mappings": "aAAA,OAAS,mBAAAA,MAAuB,gBAEhC,MAAMC,EAAmBC,GAAwB,CAChD,MAAMC,EAAU,SAAS,cAAc,cAAcD,CAAW,IAAI,EAGpE,OAFkBC,GAAWA,EAAQ,aAAa,SAAS,CAG5D,EAEMC,EAAsB,CAACC,EAAgBC,EAAwB,KAAU,CAC9E,MAAMC,EAAiBN,EAAgB,2BAA2B,GAAKA,EAAgB,yBAAyB,EAGhH,OAAKM,EAMDD,EACI,GAGDC,EAAe,MAAM,GAAG,EAAE,KAAKC,GAC9BA,IAAkB,KAAOH,IAAWG,EAAc,KAAK,CAC9D,EAXO,EAYT,EAEMC,EAAqBC,GAAsB,CAChD,IAAIC,EACAL,EAAe,GAEnB,GAAI,CACH,GAAII,EAAU,WAAW,GAAG,GAAMA,EAAU,WAAW,GAAG,GAAK,CAACA,EAAU,WAAW,IAAI,EAKxFC,EAAY,IAAI,IAAID,EAAWV,EAAgB,CAAC,EAAE,SAAS,EAC3DM,EAAe,OACT,CAEN,MAAMM,EAAeF,EAAU,WAAW,IAAI,EAAI,IAAI,IAAIA,EAAWV,EAAgB,CAAC,EAAI,IAAI,IAAIU,CAAS,EACrGL,EAASO,EAAa,OACtBC,EAAgB,IAAI,IAAIb,EAAgB,CAAC,EAAE,OAKjD,GAFAM,EAAeD,IAAWQ,EAEtBR,GAAUD,EAAoBC,EAAQC,CAAY,EAErDK,EAAYC,EAAa,SAAS,MAGlC,OAEF,CAEA,OAAKD,EAAU,SAAS,GAAG,IAC1BA,EAAY,GAAGA,CAAS,KAGlB,GAAGA,CAAS,MACpB,MAAY,CAEX,MACD,CACD,EAEA,eAAeF",
6
+ "names": ["getLocationHref", "getMetaTagValue", "metaTagName", "metaTag", "validateThemeOrigin", "origin", "isSameOrigin", "allowedOrigins", "allowedOrigin", "validateThemeRoot", "themeRoot", "resultUrl", "themeRootURL", "currentOrigin"]
7
7
  }
@@ -3,41 +3,47 @@ const getMetaTagValue = (metaTagName) => {
3
3
  const metaTag = document.querySelector(`META[name="${metaTagName}"]`), metaTagContent = metaTag && metaTag.getAttribute("content");
4
4
  return metaTagContent;
5
5
  };
6
- const validateThemeOrigin = (origin) => {
6
+ const validateThemeOrigin = (origin, isSameOrigin = false) => {
7
7
  const allowedOrigins = getMetaTagValue("sap-allowed-theme-origins") ?? getMetaTagValue("sap-allowedThemeOrigins"); // Prioritize the new meta tag name
8
8
  // If no allowed origins are specified, block.
9
9
  if (!allowedOrigins) {
10
10
  return false;
11
11
  }
12
+ // If it's same-origin (relative URL resolved to current page), allow it when there's any meta tag present
13
+ // The presence of the meta tag indicates the user wants to use theme roots
14
+ if (isSameOrigin) {
15
+ return true;
16
+ }
12
17
  return allowedOrigins.split(",").some(allowedOrigin => {
13
18
  return allowedOrigin === "*" || origin === allowedOrigin.trim();
14
19
  });
15
20
  };
16
- const buildCorrectUrl = (oldUrl, newOrigin) => {
17
- const oldUrlPath = new URL(oldUrl).pathname;
18
- return new URL(oldUrlPath, newOrigin).toString();
19
- };
20
21
  const validateThemeRoot = (themeRoot) => {
21
22
  let resultUrl;
23
+ let isSameOrigin = false;
22
24
  try {
23
- if (themeRoot.startsWith(".") || themeRoot.startsWith("/")) {
25
+ if (themeRoot.startsWith(".") || (themeRoot.startsWith("/") && !themeRoot.startsWith("//"))) {
24
26
  // Handle relative url
25
27
  // new URL("/newExmPath", "http://example.com/exmPath") => http://example.com/newExmPath
26
28
  // new URL("./newExmPath", "http://example.com/exmPath") => http://example.com/exmPath/newExmPath
27
29
  // new URL("../newExmPath", "http://example.com/exmPath") => http://example.com/newExmPath
28
30
  resultUrl = new URL(themeRoot, getLocationHref()).toString();
31
+ isSameOrigin = true;
29
32
  }
30
33
  else {
31
- const themeRootURL = new URL(themeRoot);
34
+ // Protocol-relative URLs (//host/path) need a base to resolve the protocol
35
+ const themeRootURL = themeRoot.startsWith("//") ? new URL(themeRoot, getLocationHref()) : new URL(themeRoot);
32
36
  const origin = themeRootURL.origin;
33
- if (origin && validateThemeOrigin(origin)) {
37
+ const currentOrigin = new URL(getLocationHref()).origin;
38
+ // Check if the absolute URL is same-origin
39
+ isSameOrigin = origin === currentOrigin;
40
+ if (origin && validateThemeOrigin(origin, isSameOrigin)) {
34
41
  // If origin is allowed, use it
35
42
  resultUrl = themeRootURL.toString();
36
43
  }
37
44
  else {
38
- // If origin is not allow and the URL is not relative, we have to replace the origin
39
- // with current location
40
- resultUrl = buildCorrectUrl(themeRootURL.toString(), getLocationHref());
45
+ // If origin is not allowed, return undefined to indicate validation failed
46
+ return undefined;
41
47
  }
42
48
  }
43
49
  if (!resultUrl.endsWith("/")) {
@@ -47,6 +53,7 @@ const validateThemeRoot = (themeRoot) => {
47
53
  }
48
54
  catch (e) {
49
55
  // Catch if URL is not correct
56
+ return undefined;
50
57
  }
51
58
  };
52
59
  export default validateThemeRoot;
@@ -1 +1 @@
1
- {"version":3,"file":"validateThemeRoot.js","sourceRoot":"","sources":["../src/validateThemeRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC/C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,cAAc,WAAW,IAAI,CAAC,EACpE,cAAc,GAAG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAE7D,OAAO,cAAc,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAE,EAAE;IAC9C,MAAM,cAAc,GAAG,eAAe,CAAC,2BAA2B,CAAC,IAAI,eAAe,CAAC,yBAAyB,CAAC,CAAC,CAAC,mCAAmC;IAEtJ,8CAA8C;IAC9C,IAAI,CAAC,cAAc,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;QACrD,OAAO,aAAa,KAAK,GAAG,IAAI,MAAM,KAAK,aAAa,CAAC,IAAI,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,SAAiB,EAAE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ourcesContent":["import { getLocationHref } from \"./Location.js\";\n\nconst getMetaTagValue = (metaTagName: string) => {\n\tconst metaTag = document.querySelector(`META[name=\"${metaTagName}\"]`),\n\t\tmetaTagContent = metaTag && metaTag.getAttribute(\"content\");\n\n\treturn metaTagContent;\n};\n\nconst validateThemeOrigin = (origin: string) => {\n\tconst allowedOrigins = getMetaTagValue(\"sap-allowed-theme-origins\") ?? getMetaTagValue(\"sap-allowedThemeOrigins\"); // Prioritize the new meta tag name\n\n\t// If no allowed origins are specified, block.\n\tif (!allowedOrigins) {\n\t\treturn false;\n\t}\n\n\treturn allowedOrigins.split(\",\").some(allowedOrigin => {\n\t\treturn allowedOrigin === \"*\" || origin === allowedOrigin.trim();\n\t});\n};\n\nconst buildCorrectUrl = (oldUrl: string, newOrigin: string) => {\n\tconst oldUrlPath = new URL(oldUrl).pathname;\n\n\treturn new URL(oldUrlPath, newOrigin).toString();\n};\n\nconst validateThemeRoot = (themeRoot: string) => {\n\tlet resultUrl;\n\n\ttry {\n\t\tif (themeRoot.startsWith(\".\") || themeRoot.startsWith(\"/\")) {\n\t\t\t// Handle relative url\n\t\t\t// new URL(\"/newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\t// new URL(\"./newExmPath\", \"http://example.com/exmPath\") => http://example.com/exmPath/newExmPath\n\t\t\t// new URL(\"../newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\tresultUrl = new URL(themeRoot, getLocationHref()).toString();\n\t\t} else {\n\t\t\tconst themeRootURL = new URL(themeRoot);\n\t\t\tconst origin = themeRootURL.origin;\n\n\t\t\tif (origin && validateThemeOrigin(origin)) {\n\t\t\t\t// If origin is allowed, use it\n\t\t\t\tresultUrl = themeRootURL.toString();\n\t\t\t} else {\n\t\t\t\t// If origin is not allow and the URL is not relative, we have to replace the origin\n\t\t\t\t// with current location\n\t\t\t\tresultUrl = buildCorrectUrl(themeRootURL.toString(), getLocationHref());\n\t\t\t}\n\t\t}\n\n\t\tif (!resultUrl.endsWith(\"/\")) {\n\t\t\tresultUrl = `${resultUrl}/`;\n\t\t}\n\n\t\treturn `${resultUrl}UI5/`;\n\t} catch (e) {\n\t\t// Catch if URL is not correct\n\t}\n};\n\nexport default validateThemeRoot;\n"]}
1
+ {"version":3,"file":"validateThemeRoot.js","sourceRoot":"","sources":["../src/validateThemeRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC/C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,cAAc,WAAW,IAAI,CAAC,EACpE,cAAc,GAAG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAE7D,OAAO,cAAc,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAE,eAAwB,KAAK,EAAE,EAAE;IAC7E,MAAM,cAAc,GAAG,eAAe,CAAC,2BAA2B,CAAC,IAAI,eAAe,CAAC,yBAAyB,CAAC,CAAC,CAAC,mCAAmC;IAEtJ,8CAA8C;IAC9C,IAAI,CAAC,cAAc,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,0GAA0G;IAC1G,2EAA2E;IAC3E,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;QACrD,OAAO,aAAa,KAAK,GAAG,IAAI,MAAM,KAAK,aAAa,CAAC,IAAI,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC/C,IAAI,SAAS,CAAC;IACd,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,IAAI,CAAC;QACJ,I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AAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { getLocationHref } from \"./Location.js\";\n\nconst getMetaTagValue = (metaTagName: string) => {\n\tconst metaTag = document.querySelector(`META[name=\"${metaTagName}\"]`),\n\t\tmetaTagContent = metaTag && metaTag.getAttribute(\"content\");\n\n\treturn metaTagContent;\n};\n\nconst validateThemeOrigin = (origin: string, isSameOrigin: boolean = false) => {\n\tconst allowedOrigins = getMetaTagValue(\"sap-allowed-theme-origins\") ?? getMetaTagValue(\"sap-allowedThemeOrigins\"); // Prioritize the new meta tag name\n\n\t// If no allowed origins are specified, block.\n\tif (!allowedOrigins) {\n\t\treturn false;\n\t}\n\n\t// If it's same-origin (relative URL resolved to current page), allow it when there's any meta tag present\n\t// The presence of the meta tag indicates the user wants to use theme roots\n\tif (isSameOrigin) {\n\t\treturn true;\n\t}\n\n\treturn allowedOrigins.split(\",\").some(allowedOrigin => {\n\t\treturn allowedOrigin === \"*\" || origin === allowedOrigin.trim();\n\t});\n};\n\nconst validateThemeRoot = (themeRoot: string) => {\n\tlet resultUrl;\n\tlet isSameOrigin = false;\n\n\ttry {\n\t\tif (themeRoot.startsWith(\".\") || (themeRoot.startsWith(\"/\") && !themeRoot.startsWith(\"//\"))) {\n\t\t\t// Handle relative url\n\t\t\t// new URL(\"/newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\t// new URL(\"./newExmPath\", \"http://example.com/exmPath\") => http://example.com/exmPath/newExmPath\n\t\t\t// new URL(\"../newExmPath\", \"http://example.com/exmPath\") => http://example.com/newExmPath\n\t\t\tresultUrl = new URL(themeRoot, getLocationHref()).toString();\n\t\t\tisSameOrigin = true;\n\t\t} else {\n\t\t\t// Protocol-relative URLs (//host/path) need a base to resolve the protocol\n\t\t\tconst themeRootURL = themeRoot.startsWith(\"//\") ? new URL(themeRoot, getLocationHref()) : new URL(themeRoot);\n\t\t\tconst origin = themeRootURL.origin;\n\t\t\tconst currentOrigin = new URL(getLocationHref()).origin;\n\n\t\t\t// Check if the absolute URL is same-origin\n\t\t\tisSameOrigin = origin === currentOrigin;\n\n\t\t\tif (origin && validateThemeOrigin(origin, isSameOrigin)) {\n\t\t\t\t// If origin is allowed, use it\n\t\t\t\tresultUrl = themeRootURL.toString();\n\t\t\t} else {\n\t\t\t\t// If origin is not allowed, return undefined to indicate validation failed\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (!resultUrl.endsWith(\"/\")) {\n\t\t\tresultUrl = `${resultUrl}/`;\n\t\t}\n\n\t\treturn `${resultUrl}UI5/`;\n\t} catch (e) {\n\t\t// Catch if URL is not correct\n\t\treturn undefined;\n\t}\n};\n\nexport default validateThemeRoot;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-base",
3
- "version": "2.20.3",
3
+ "version": "2.20.5",
4
4
  "description": "UI5 Web Components: webcomponents.base",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -66,7 +66,7 @@
66
66
  "@openui5/sap.ui.core": "1.146.0",
67
67
  "@sap-theming/theming-base-content": "11.33.0",
68
68
  "@ui5/cypress-internal": "0.1.0",
69
- "@ui5/webcomponents-tools": "2.20.3",
69
+ "@ui5/webcomponents-tools": "2.20.5",
70
70
  "clean-css": "^5.2.2",
71
71
  "cypress": "15.9.0",
72
72
  "mocha": "^11.7.2",
@@ -85,5 +85,5 @@
85
85
  }
86
86
  },
87
87
  "customElements": "dist/custom-elements.json",
88
- "gitHead": "3e3a7936aae93d114542b1b2a7ca1a1d26c63194"
88
+ "gitHead": "3ab617e7daed44d3f576491061ff88f750dff167"
89
89
  }