UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

19 lines 791 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.openInNewTab = void 0; /** Wrapper for an onClick handler on link-like components, i.e. that navigate to a different URL on click. * Opens a link (url) in a new tab when CMD or CTRL key is pressed at click time. */ const openInNewTab = (event, handler, url) => { //if ctrl key or cmd key bypass click handler and delegation open in the background new tab if (url && (event.ctrlKey || event.metaKey)) { event.preventDefault(); event.nativeEvent.stopImmediatePropagation(); event.stopPropagation(); window.open(url, "_blank"); } else if (handler) { handler(event); } }; exports.openInNewTab = openInNewTab; //# sourceMappingURL=openInNewTab.js.map