package.react-utils.metaClick.metaClick.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
import { curry } from "ramda";
export var handleMetaClick = curry(function (history, params, event) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
if (isMetaKeyPressed(event)) {
return window.open(params.pathname || params, "_blank");
}
var _options$isHistoryRep = options.isHistoryReplace,
isHistoryReplace = _options$isHistoryRep === void 0 ? false : _options$isHistoryRep;
var historyMethod = isHistoryReplace ? history.replace : history.push;
return historyMethod(params);
});
export var isMetaKeyPressed = function isMetaKeyPressed(event) {
return !!(event !== null && event !== void 0 && event.ctrlKey || event !== null && event !== void 0 && event.metaKey);
};
//# sourceMappingURL=metaClick.js.map