UNPKG

@atlaskit/button

Version:

A button triggers an event or action. They let users know what will happen next.

33 lines (32 loc) 802 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = blockEvents; function abort(event) { event.preventDefault(); event.stopPropagation(); } var tabKeyCode = 9; function onKey(event) { // Allowing tab so that a user can move focus away if (event.keyCode === tabKeyCode) { return; } abort(event); } function blockEvents(shouldBlockEvents, events) { return shouldBlockEvents ? { onMouseDownCapture: abort, onMouseUpCapture: abort, onKeyDownCapture: onKey, onKeyUpCapture: onKey, onTouchStartCapture: abort, onTouchEndCapture: abort, onPointerDownCapture: abort, onPointerUpCapture: abort, onClickCapture: abort, // Just smashing the existing onClick for good measure onClick: abort } : events; }