New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@atlaskit/util-common

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atlaskit/util-common - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

14

CHANGELOG.md

@@ -1,6 +0,16 @@

<a name="1.5.0"></a>
# 1.5.0 (2017-07-17)
<a name="1.5.1"></a>
## 1.5.1 (2017-07-25)
<a name="1.5.1"></a>
## 1.5.1 (2017-07-25)
### Bug Fixes
* **build:** use class transform in loose mode in babel to improve load performance in apps ([fde719a](https://bitbucket.org/atlassian/atlaskit/commits/fde719a))
<a name="1.2.0"></a>

@@ -7,0 +17,0 @@ # 1.2.0 (2017-07-17)

42

dist/bundle-cjs.js

@@ -81,3 +81,3 @@ module.exports = /******/

}), exports.createError = exports.KeyPressHandler = exports.keyCode = exports.enumeration = void 0;
var _keycode = __webpack_require__(2), _keycode2 = _interopRequireDefault(_keycode), _properties = __webpack_require__(3), _properties2 = _interopRequireDefault(_properties), _index = __webpack_require__(6), _index2 = _interopRequireDefault(_index), _createError = __webpack_require__(10), _createError2 = _interopRequireDefault(_createError);
var _keycode = __webpack_require__(2), _keycode2 = _interopRequireDefault(_keycode), _properties = __webpack_require__(3), _properties2 = _interopRequireDefault(_properties), _index = __webpack_require__(6), _index2 = _interopRequireDefault(_index), _createError = __webpack_require__(9), _createError2 = _interopRequireDefault(_createError);
exports.enumeration = _properties2.default, exports.keyCode = _keycode2.default,

@@ -193,3 +193,3 @@ exports.KeyPressHandler = _index2.default, exports.createError = _createError2.default;

}), exports.CallbackInvalidError = exports.KeyInvalidError = void 0;
var _classCallCheck2 = __webpack_require__(7), _classCallCheck3 = _interopRequireDefault(_classCallCheck2), _createClass2 = __webpack_require__(8), _createClass3 = _interopRequireDefault(_createClass2), _keycode = __webpack_require__(2), _keycode2 = _interopRequireDefault(_keycode), _createError = __webpack_require__(9), _createError2 = _interopRequireDefault(_createError), KeyInvalidError = (0,
var _classCallCheck2 = __webpack_require__(7), _classCallCheck3 = _interopRequireDefault(_classCallCheck2), _keycode = __webpack_require__(2), _keycode2 = _interopRequireDefault(_keycode), _createError = __webpack_require__(8), _createError2 = _interopRequireDefault(_createError), KeyInvalidError = (0,
_createError2.default)("KeyInvalidError"), CallbackInvalidError = (0, _createError2.default)("CallbackInvalidError"), KeyPressHandler = function() {

@@ -222,18 +222,18 @@ /**

*/
return (0, _createClass3.default)(KeyPressHandler, [ {
key: "add",
value: function(key, callback) {
var code = (0, _keycode2.default)(key);
if ("undefined" == typeof code) throw keyInvalidError(key);
if ("function" != typeof callback) throw new CallbackInvalidError();
this.keyListeners[code] = callback;
}
}, {
key: "destroy",
value: function(key) {
key ? delete this.keyListeners[(0, _keycode2.default)(key)] : (// Don't change this to {}, otherwise a destroyed KeyPressHandler can be "recycled"
// without having an event listener attached
this.keyListeners = void 0, this.elem.removeEventListener("keydown", this.listener));
}
} ]), KeyPressHandler;
/**
* Removes a key from the list of listened keys.
* Or removes the whole listener if no key given.
*
* @param {String} [key] A named key. Case insensitive. If none given, event listener is removed.
*/
return KeyPressHandler.prototype.add = function(key, callback) {
var code = (0, _keycode2.default)(key);
if ("undefined" == typeof code) throw keyInvalidError(key);
if ("function" != typeof callback) throw new CallbackInvalidError();
this.keyListeners[code] = callback;
}, KeyPressHandler.prototype.destroy = function(key) {
key ? delete this.keyListeners[(0, _keycode2.default)(key)] : (// Don't change this to {}, otherwise a destroyed KeyPressHandler can be "recycled"
// without having an event listener attached
this.keyListeners = void 0, this.elem.removeEventListener("keydown", this.listener));
}, KeyPressHandler;
}();

@@ -248,10 +248,6 @@ exports.default = KeyPressHandler, exports.KeyInvalidError = KeyInvalidError, exports.CallbackInvalidError = CallbackInvalidError;

function(module, exports) {
module.exports = require("babel-runtime/helpers/createClass");
module.exports = require("create-error");
}, /* 9 */
/***/
function(module, exports) {
module.exports = require("create-error");
}, /* 10 */
/***/
function(module, exports) {
"use strict";

@@ -258,0 +254,0 @@ function createError(propName, componentName, message) {

@@ -1,1 +0,1 @@

module.exports=function(e){function t(n){if(r[n])return r[n].exports;var u=r[n]={exports:{},id:n,loaded:!1};return e[n].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.createError=t.KeyPressHandler=t.keyCode=t.enumeration=void 0;var u=r(2),i=n(u),o=r(3),l=n(o),s=r(6),a=n(s),f=r(10),d=n(f);t.enumeration=l.default,t.keyCode=i.default,t.KeyPressHandler=a.default,t.createError=d.default},function(e,t){e.exports=require("keycode")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function u(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.unshift({},e),l.default.apply(Object,r)}}function i(e){return u({coerce:function(t){return(0,s.computeEnumValue)(e,t)},default:e.missingDefault,initial:e.attribute?e.missingDefault:void 0,deserialize:function(e){return null===e?void 0:e},serialize:function(e){return"undefined"==typeof e?e:String(e)}})}Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),l=n(o),s=r(5);t.default=i},function(e,t){e.exports=require("babel-runtime/core-js/object/assign")},function(e,t){"use strict";function r(e){return null!==e}function n(e,t,r){r?e.setAttribute(t,""):e.removeAttribute(t)}function u(e,t){var r=function(e){return e.toLowerCase()===t.toLowerCase()},n=null===t||"undefined"==typeof t,u=!n&&!e.values.filter(r).length;return n?{}.hasOwnProperty.call(e,"missingDefault")?e.missingDefault:null:u?{}.hasOwnProperty.call(e,"invalidDefault")?e.invalidDefault:{}.hasOwnProperty.call(e,"missingDefault")?e.missingDefault:null:e.values.length?e.values.filter(r)[0]:null}function i(e,t,r){e.setAttribute(t.attribute,r)}Object.defineProperty(t,"__esModule",{value:!0}),t.computeBooleanValue=r,t.setBooleanAttribute=n,t.computeEnumValue=u,t.setEnumAttribute=i},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function u(e){return new v('Given key "'+e+'" is not valid')}Object.defineProperty(t,"__esModule",{value:!0}),t.CallbackInvalidError=t.KeyInvalidError=void 0;var i=r(7),o=n(i),l=r(8),s=n(l),a=r(2),f=n(a),d=r(9),c=n(d),v=(0,c.default)("KeyInvalidError"),y=(0,c.default)("CallbackInvalidError"),p=function(){function e(t,r,n){var i=this;(0,o.default)(this,e),this.keyListeners={};var l=(0,f.default)(t);if("undefined"==typeof l)throw u(t);if("function"!=typeof r)throw new y;this.keyListeners[l]=r,this.elem=n||document,this.listener=function(e){i.keyListeners[e.keyCode]&&i.keyListeners[e.keyCode](e)},this.elem.addEventListener("keydown",this.listener)}return(0,s.default)(e,[{key:"add",value:function(e,t){var r=(0,f.default)(e);if("undefined"==typeof r)throw u(e);if("function"!=typeof t)throw new y;this.keyListeners[r]=t}},{key:"destroy",value:function(e){e?delete this.keyListeners[(0,f.default)(e)]:(this.keyListeners=void 0,this.elem.removeEventListener("keydown",this.listener))}}]),e}();t.default=p,t.KeyInvalidError=v,t.CallbackInvalidError=y},function(e,t){e.exports=require("babel-runtime/helpers/classCallCheck")},function(e,t){e.exports=require("babel-runtime/helpers/createClass")},function(e,t){e.exports=require("create-error")},function(e,t){"use strict";function r(e,t,r){return new Error("Invalid prop `"+e+"` supplied to"+(" `"+t+"`. "+r))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}]);
module.exports=function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.createError=t.KeyPressHandler=t.keyCode=t.enumeration=void 0;var i=r(2),u=n(i),o=r(3),l=n(o),s=r(6),a=n(s),f=r(9),d=n(f);t.enumeration=l.default,t.keyCode=u.default,t.KeyPressHandler=a.default,t.createError=d.default},function(e,t){e.exports=require("keycode")},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.unshift({},e),l.default.apply(Object,r)}}function u(e){return i({coerce:function(t){return(0,s.computeEnumValue)(e,t)},default:e.missingDefault,initial:e.attribute?e.missingDefault:void 0,deserialize:function(e){return null===e?void 0:e},serialize:function(e){return"undefined"==typeof e?e:String(e)}})}Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),l=n(o),s=r(5);t.default=u},function(e,t){e.exports=require("babel-runtime/core-js/object/assign")},function(e,t){"use strict";function r(e){return null!==e}function n(e,t,r){r?e.setAttribute(t,""):e.removeAttribute(t)}function i(e,t){var r=function(e){return e.toLowerCase()===t.toLowerCase()},n=null===t||"undefined"==typeof t,i=!n&&!e.values.filter(r).length;return n?{}.hasOwnProperty.call(e,"missingDefault")?e.missingDefault:null:i?{}.hasOwnProperty.call(e,"invalidDefault")?e.invalidDefault:{}.hasOwnProperty.call(e,"missingDefault")?e.missingDefault:null:e.values.length?e.values.filter(r)[0]:null}function u(e,t,r){e.setAttribute(t.attribute,r)}Object.defineProperty(t,"__esModule",{value:!0}),t.computeBooleanValue=r,t.setBooleanAttribute=n,t.computeEnumValue=i,t.setEnumAttribute=u},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return new d('Given key "'+e+'" is not valid')}Object.defineProperty(t,"__esModule",{value:!0}),t.CallbackInvalidError=t.KeyInvalidError=void 0;var u=r(7),o=n(u),l=r(2),s=n(l),a=r(8),f=n(a),d=(0,f.default)("KeyInvalidError"),c=(0,f.default)("CallbackInvalidError"),p=function(){function e(t,r,n){var u=this;(0,o.default)(this,e),this.keyListeners={};var l=(0,s.default)(t);if("undefined"==typeof l)throw i(t);if("function"!=typeof r)throw new c;this.keyListeners[l]=r,this.elem=n||document,this.listener=function(e){u.keyListeners[e.keyCode]&&u.keyListeners[e.keyCode](e)},this.elem.addEventListener("keydown",this.listener)}return e.prototype.add=function(e,t){var r=(0,s.default)(e);if("undefined"==typeof r)throw i(e);if("function"!=typeof t)throw new c;this.keyListeners[r]=t},e.prototype.destroy=function(e){e?delete this.keyListeners[(0,s.default)(e)]:(this.keyListeners=void 0,this.elem.removeEventListener("keydown",this.listener))},e}();t.default=p,t.KeyInvalidError=d,t.CallbackInvalidError=c},function(e,t){e.exports=require("babel-runtime/helpers/classCallCheck")},function(e,t){e.exports=require("create-error")},function(e,t){"use strict";function r(e,t,r){return new Error("Invalid prop `"+e+"` supplied to"+(" `"+t+"`. "+r))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}]);
!function(root, factory) {
"object" == typeof exports && "object" == typeof module ? module.exports = factory(require("keycode"), require("babel-runtime/core-js/object/assign"), require("babel-runtime/helpers/classCallCheck"), require("babel-runtime/helpers/createClass"), require("create-error")) : "function" == typeof define && define.amd ? define([ "keycode", "babel-runtime/core-js/object/assign", "babel-runtime/helpers/classCallCheck", "babel-runtime/helpers/createClass", "create-error" ], factory) : "object" == typeof exports ? exports["@atlaskit/utilCommon"] = factory(require("keycode"), require("babel-runtime/core-js/object/assign"), require("babel-runtime/helpers/classCallCheck"), require("babel-runtime/helpers/createClass"), require("create-error")) : root["@atlaskit/utilCommon"] = factory(root.keycode, root["babel-runtime/core-js/object/assign"], root["babel-runtime/helpers/classCallCheck"], root["babel-runtime/helpers/createClass"], root["create-error"]);
}(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_7__, __WEBPACK_EXTERNAL_MODULE_8__, __WEBPACK_EXTERNAL_MODULE_9__) {
"object" == typeof exports && "object" == typeof module ? module.exports = factory(require("keycode"), require("babel-runtime/core-js/object/assign"), require("babel-runtime/helpers/classCallCheck"), require("create-error")) : "function" == typeof define && define.amd ? define([ "keycode", "babel-runtime/core-js/object/assign", "babel-runtime/helpers/classCallCheck", "create-error" ], factory) : "object" == typeof exports ? exports["@atlaskit/utilCommon"] = factory(require("keycode"), require("babel-runtime/core-js/object/assign"), require("babel-runtime/helpers/classCallCheck"), require("create-error")) : root["@atlaskit/utilCommon"] = factory(root.keycode, root["babel-runtime/core-js/object/assign"], root["babel-runtime/helpers/classCallCheck"], root["create-error"]);
}(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_7__, __WEBPACK_EXTERNAL_MODULE_8__) {
/******/

@@ -84,3 +84,3 @@ return function(modules) {

}), exports.createError = exports.KeyPressHandler = exports.keyCode = exports.enumeration = void 0;
var _keycode = __webpack_require__(2), _keycode2 = _interopRequireDefault(_keycode), _properties = __webpack_require__(3), _properties2 = _interopRequireDefault(_properties), _index = __webpack_require__(6), _index2 = _interopRequireDefault(_index), _createError = __webpack_require__(10), _createError2 = _interopRequireDefault(_createError);
var _keycode = __webpack_require__(2), _keycode2 = _interopRequireDefault(_keycode), _properties = __webpack_require__(3), _properties2 = _interopRequireDefault(_properties), _index = __webpack_require__(6), _index2 = _interopRequireDefault(_index), _createError = __webpack_require__(9), _createError2 = _interopRequireDefault(_createError);
exports.enumeration = _properties2.default, exports.keyCode = _keycode2.default,

@@ -196,3 +196,3 @@ exports.KeyPressHandler = _index2.default, exports.createError = _createError2.default;

}), exports.CallbackInvalidError = exports.KeyInvalidError = void 0;
var _classCallCheck2 = __webpack_require__(7), _classCallCheck3 = _interopRequireDefault(_classCallCheck2), _createClass2 = __webpack_require__(8), _createClass3 = _interopRequireDefault(_createClass2), _keycode = __webpack_require__(2), _keycode2 = _interopRequireDefault(_keycode), _createError = __webpack_require__(9), _createError2 = _interopRequireDefault(_createError), KeyInvalidError = (0,
var _classCallCheck2 = __webpack_require__(7), _classCallCheck3 = _interopRequireDefault(_classCallCheck2), _keycode = __webpack_require__(2), _keycode2 = _interopRequireDefault(_keycode), _createError = __webpack_require__(8), _createError2 = _interopRequireDefault(_createError), KeyInvalidError = (0,
_createError2.default)("KeyInvalidError"), CallbackInvalidError = (0, _createError2.default)("CallbackInvalidError"), KeyPressHandler = function() {

@@ -225,18 +225,18 @@ /**

*/
return (0, _createClass3.default)(KeyPressHandler, [ {
key: "add",
value: function(key, callback) {
var code = (0, _keycode2.default)(key);
if ("undefined" == typeof code) throw keyInvalidError(key);
if ("function" != typeof callback) throw new CallbackInvalidError();
this.keyListeners[code] = callback;
}
}, {
key: "destroy",
value: function(key) {
key ? delete this.keyListeners[(0, _keycode2.default)(key)] : (// Don't change this to {}, otherwise a destroyed KeyPressHandler can be "recycled"
// without having an event listener attached
this.keyListeners = void 0, this.elem.removeEventListener("keydown", this.listener));
}
} ]), KeyPressHandler;
/**
* Removes a key from the list of listened keys.
* Or removes the whole listener if no key given.
*
* @param {String} [key] A named key. Case insensitive. If none given, event listener is removed.
*/
return KeyPressHandler.prototype.add = function(key, callback) {
var code = (0, _keycode2.default)(key);
if ("undefined" == typeof code) throw keyInvalidError(key);
if ("function" != typeof callback) throw new CallbackInvalidError();
this.keyListeners[code] = callback;
}, KeyPressHandler.prototype.destroy = function(key) {
key ? delete this.keyListeners[(0, _keycode2.default)(key)] : (// Don't change this to {}, otherwise a destroyed KeyPressHandler can be "recycled"
// without having an event listener attached
this.keyListeners = void 0, this.elem.removeEventListener("keydown", this.listener));
}, KeyPressHandler;
}();

@@ -255,6 +255,2 @@ exports.default = KeyPressHandler, exports.KeyInvalidError = KeyInvalidError, exports.CallbackInvalidError = CallbackInvalidError;

function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_9__;
}, /* 10 */
/***/
function(module, exports) {
"use strict";

@@ -261,0 +257,0 @@ function createError(propName, componentName, message) {

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("keycode"),require("babel-runtime/core-js/object/assign"),require("babel-runtime/helpers/classCallCheck"),require("babel-runtime/helpers/createClass"),require("create-error")):"function"==typeof define&&define.amd?define(["keycode","babel-runtime/core-js/object/assign","babel-runtime/helpers/classCallCheck","babel-runtime/helpers/createClass","create-error"],t):"object"==typeof exports?exports["@atlaskit/utilCommon"]=t(require("keycode"),require("babel-runtime/core-js/object/assign"),require("babel-runtime/helpers/classCallCheck"),require("babel-runtime/helpers/createClass"),require("create-error")):e["@atlaskit/utilCommon"]=t(e.keycode,e["babel-runtime/core-js/object/assign"],e["babel-runtime/helpers/classCallCheck"],e["babel-runtime/helpers/createClass"],e["create-error"])}(this,function(e,t,r,n,i){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.createError=t.KeyPressHandler=t.keyCode=t.enumeration=void 0;var i=r(2),u=n(i),o=r(3),l=n(o),s=r(6),a=n(s),c=r(10),f=n(c);t.enumeration=l.default,t.keyCode=u.default,t.KeyPressHandler=a.default,t.createError=f.default},function(t,r){t.exports=e},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.unshift({},e),l.default.apply(Object,r)}}function u(e){return i({coerce:function(t){return(0,s.computeEnumValue)(e,t)},default:e.missingDefault,initial:e.attribute?e.missingDefault:void 0,deserialize:function(e){return null===e?void 0:e},serialize:function(e){return"undefined"==typeof e?e:String(e)}})}Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),l=n(o),s=r(5);t.default=u},function(e,r){e.exports=t},function(e,t){"use strict";function r(e){return null!==e}function n(e,t,r){r?e.setAttribute(t,""):e.removeAttribute(t)}function i(e,t){var r=function(e){return e.toLowerCase()===t.toLowerCase()},n=null===t||"undefined"==typeof t,i=!n&&!e.values.filter(r).length;return n?{}.hasOwnProperty.call(e,"missingDefault")?e.missingDefault:null:i?{}.hasOwnProperty.call(e,"invalidDefault")?e.invalidDefault:{}.hasOwnProperty.call(e,"missingDefault")?e.missingDefault:null:e.values.length?e.values.filter(r)[0]:null}function u(e,t,r){e.setAttribute(t.attribute,r)}Object.defineProperty(t,"__esModule",{value:!0}),t.computeBooleanValue=r,t.setBooleanAttribute=n,t.computeEnumValue=i,t.setEnumAttribute=u},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return new p('Given key "'+e+'" is not valid')}Object.defineProperty(t,"__esModule",{value:!0}),t.CallbackInvalidError=t.KeyInvalidError=void 0;var u=r(7),o=n(u),l=r(8),s=n(l),a=r(2),c=n(a),f=r(9),d=n(f),p=(0,d.default)("KeyInvalidError"),b=(0,d.default)("CallbackInvalidError"),y=function(){function e(t,r,n){var u=this;(0,o.default)(this,e),this.keyListeners={};var l=(0,c.default)(t);if("undefined"==typeof l)throw i(t);if("function"!=typeof r)throw new b;this.keyListeners[l]=r,this.elem=n||document,this.listener=function(e){u.keyListeners[e.keyCode]&&u.keyListeners[e.keyCode](e)},this.elem.addEventListener("keydown",this.listener)}return(0,s.default)(e,[{key:"add",value:function(e,t){var r=(0,c.default)(e);if("undefined"==typeof r)throw i(e);if("function"!=typeof t)throw new b;this.keyListeners[r]=t}},{key:"destroy",value:function(e){e?delete this.keyListeners[(0,c.default)(e)]:(this.keyListeners=void 0,this.elem.removeEventListener("keydown",this.listener))}}]),e}();t.default=y,t.KeyInvalidError=p,t.CallbackInvalidError=b},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){e.exports=i},function(e,t){"use strict";function r(e,t,r){return new Error("Invalid prop `"+e+"` supplied to"+(" `"+t+"`. "+r))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("keycode"),require("babel-runtime/core-js/object/assign"),require("babel-runtime/helpers/classCallCheck"),require("create-error")):"function"==typeof define&&define.amd?define(["keycode","babel-runtime/core-js/object/assign","babel-runtime/helpers/classCallCheck","create-error"],t):"object"==typeof exports?exports["@atlaskit/utilCommon"]=t(require("keycode"),require("babel-runtime/core-js/object/assign"),require("babel-runtime/helpers/classCallCheck"),require("create-error")):e["@atlaskit/utilCommon"]=t(e.keycode,e["babel-runtime/core-js/object/assign"],e["babel-runtime/helpers/classCallCheck"],e["create-error"])}(this,function(e,t,r,n){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.createError=t.KeyPressHandler=t.keyCode=t.enumeration=void 0;var i=r(2),o=n(i),u=r(3),l=n(u),s=r(6),a=n(s),f=r(9),c=n(f);t.enumeration=l.default,t.keyCode=o.default,t.KeyPressHandler=a.default,t.createError=c.default},function(t,r){t.exports=e},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.unshift({},e),l.default.apply(Object,r)}}function o(e){return i({coerce:function(t){return(0,s.computeEnumValue)(e,t)},default:e.missingDefault,initial:e.attribute?e.missingDefault:void 0,deserialize:function(e){return null===e?void 0:e},serialize:function(e){return"undefined"==typeof e?e:String(e)}})}Object.defineProperty(t,"__esModule",{value:!0});var u=r(4),l=n(u),s=r(5);t.default=o},function(e,r){e.exports=t},function(e,t){"use strict";function r(e){return null!==e}function n(e,t,r){r?e.setAttribute(t,""):e.removeAttribute(t)}function i(e,t){var r=function(e){return e.toLowerCase()===t.toLowerCase()},n=null===t||"undefined"==typeof t,i=!n&&!e.values.filter(r).length;return n?{}.hasOwnProperty.call(e,"missingDefault")?e.missingDefault:null:i?{}.hasOwnProperty.call(e,"invalidDefault")?e.invalidDefault:{}.hasOwnProperty.call(e,"missingDefault")?e.missingDefault:null:e.values.length?e.values.filter(r)[0]:null}function o(e,t,r){e.setAttribute(t.attribute,r)}Object.defineProperty(t,"__esModule",{value:!0}),t.computeBooleanValue=r,t.setBooleanAttribute=n,t.computeEnumValue=i,t.setEnumAttribute=o},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return new c('Given key "'+e+'" is not valid')}Object.defineProperty(t,"__esModule",{value:!0}),t.CallbackInvalidError=t.KeyInvalidError=void 0;var o=r(7),u=n(o),l=r(2),s=n(l),a=r(8),f=n(a),c=(0,f.default)("KeyInvalidError"),d=(0,f.default)("CallbackInvalidError"),p=function(){function e(t,r,n){var o=this;(0,u.default)(this,e),this.keyListeners={};var l=(0,s.default)(t);if("undefined"==typeof l)throw i(t);if("function"!=typeof r)throw new d;this.keyListeners[l]=r,this.elem=n||document,this.listener=function(e){o.keyListeners[e.keyCode]&&o.keyListeners[e.keyCode](e)},this.elem.addEventListener("keydown",this.listener)}return e.prototype.add=function(e,t){var r=(0,s.default)(e);if("undefined"==typeof r)throw i(e);if("function"!=typeof t)throw new d;this.keyListeners[r]=t},e.prototype.destroy=function(e){e?delete this.keyListeners[(0,s.default)(e)]:(this.keyListeners=void 0,this.elem.removeEventListener("keydown",this.listener))},e}();t.default=p,t.KeyInvalidError=c,t.CallbackInvalidError=d},function(e,t){e.exports=r},function(e,t){e.exports=n},function(e,t){"use strict";function r(e,t,r){return new Error("Invalid prop `"+e+"` supplied to"+(" `"+t+"`. "+r))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}])});
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import keyCode from 'keycode';

@@ -61,36 +60,32 @@ import createError from 'create-error';

_createClass(KeyPressHandler, [{
key: 'add',
value: function add(key, callback) {
var code = keyCode(key);
if (typeof code === 'undefined') {
throw keyInvalidError(key);
}
KeyPressHandler.prototype.add = function add(key, callback) {
var code = keyCode(key);
if (typeof code === 'undefined') {
throw keyInvalidError(key);
}
if (typeof callback !== 'function') {
throw new CallbackInvalidError();
}
this.keyListeners[code] = callback;
if (typeof callback !== 'function') {
throw new CallbackInvalidError();
}
this.keyListeners[code] = callback;
};
/**
* Removes a key from the list of listened keys.
* Or removes the whole listener if no key given.
*
* @param {String} [key] A named key. Case insensitive. If none given, event listener is removed.
*/
/**
* Removes a key from the list of listened keys.
* Or removes the whole listener if no key given.
*
* @param {String} [key] A named key. Case insensitive. If none given, event listener is removed.
*/
}, {
key: 'destroy',
value: function destroy(key) {
if (!key) {
// Don't change this to {}, otherwise a destroyed KeyPressHandler can be "recycled"
// without having an event listener attached
this.keyListeners = undefined;
this.elem.removeEventListener('keydown', this.listener);
} else {
delete this.keyListeners[keyCode(key)];
}
KeyPressHandler.prototype.destroy = function destroy(key) {
if (!key) {
// Don't change this to {}, otherwise a destroyed KeyPressHandler can be "recycled"
// without having an event listener attached
this.keyListeners = undefined;
this.elem.removeEventListener('keydown', this.listener);
} else {
delete this.keyListeners[keyCode(key)];
}
}]);
};

@@ -97,0 +92,0 @@ return KeyPressHandler;

{
"name": "@atlaskit/util-common",
"version": "1.5.0",
"version": "1.5.1",
"config": {

@@ -5,0 +5,0 @@ "access": "public"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc