mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-16 07:35:39 +01:00
7c8f8d776f
The following package versions were changed: @wordpress/block-directory: 1.5.4 -> 1.5.5 @wordpress/block-editor: 3.7.4 -> 3.7.5 @wordpress/block-library: 2.14.4 -> 2.14.5 @wordpress/components: 9.2.3 -> 9.2.4 @wordpress/dependency-extraction-webpack-plugin: 2.3.0 -> 2.4.0 @wordpress/edit-post: 3.13.5 -> 3.13.6 @wordpress/editor: 9.12.4 -> 9.12.5 @wordpress/format-library: 1.14.4 -> 1.14.5 @wordpress/list-reusable-blocks: 1.13.3 -> 1.13.4 @wordpress/nux: 3.12.3 -> 3.12.4 @wordpress/server-side-render: 1.8.3 -> 1.8.4 Props aduth. Fixes: #49657. Built from https://develop.svn.wordpress.org/trunk@47462 git-svn-id: http://core.svn.wordpress.org/trunk@47249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2661 lines
83 KiB
JavaScript
2661 lines
83 KiB
JavaScript
this["wp"] = this["wp"] || {}; this["wp"]["compose"] =
|
||
/******/ (function(modules) { // webpackBootstrap
|
||
/******/ // The module cache
|
||
/******/ var installedModules = {};
|
||
/******/
|
||
/******/ // The require function
|
||
/******/ function __webpack_require__(moduleId) {
|
||
/******/
|
||
/******/ // Check if module is in cache
|
||
/******/ if(installedModules[moduleId]) {
|
||
/******/ return installedModules[moduleId].exports;
|
||
/******/ }
|
||
/******/ // Create a new module (and put it into the cache)
|
||
/******/ var module = installedModules[moduleId] = {
|
||
/******/ i: moduleId,
|
||
/******/ l: false,
|
||
/******/ exports: {}
|
||
/******/ };
|
||
/******/
|
||
/******/ // Execute the module function
|
||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||
/******/
|
||
/******/ // Flag the module as loaded
|
||
/******/ module.l = true;
|
||
/******/
|
||
/******/ // Return the exports of the module
|
||
/******/ return module.exports;
|
||
/******/ }
|
||
/******/
|
||
/******/
|
||
/******/ // expose the modules object (__webpack_modules__)
|
||
/******/ __webpack_require__.m = modules;
|
||
/******/
|
||
/******/ // expose the module cache
|
||
/******/ __webpack_require__.c = installedModules;
|
||
/******/
|
||
/******/ // define getter function for harmony exports
|
||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||
/******/ }
|
||
/******/ };
|
||
/******/
|
||
/******/ // define __esModule on exports
|
||
/******/ __webpack_require__.r = function(exports) {
|
||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||
/******/ }
|
||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||
/******/ };
|
||
/******/
|
||
/******/ // create a fake namespace object
|
||
/******/ // mode & 1: value is a module id, require it
|
||
/******/ // mode & 2: merge all properties of value into the ns
|
||
/******/ // mode & 4: return value when already ns object
|
||
/******/ // mode & 8|1: behave like require
|
||
/******/ __webpack_require__.t = function(value, mode) {
|
||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||
/******/ if(mode & 8) return value;
|
||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||
/******/ var ns = Object.create(null);
|
||
/******/ __webpack_require__.r(ns);
|
||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||
/******/ return ns;
|
||
/******/ };
|
||
/******/
|
||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||
/******/ __webpack_require__.n = function(module) {
|
||
/******/ var getter = module && module.__esModule ?
|
||
/******/ function getDefault() { return module['default']; } :
|
||
/******/ function getModuleExports() { return module; };
|
||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||
/******/ return getter;
|
||
/******/ };
|
||
/******/
|
||
/******/ // Object.prototype.hasOwnProperty.call
|
||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||
/******/
|
||
/******/ // __webpack_public_path__
|
||
/******/ __webpack_require__.p = "";
|
||
/******/
|
||
/******/
|
||
/******/ // Load entry module and return exports
|
||
/******/ return __webpack_require__(__webpack_require__.s = 429);
|
||
/******/ })
|
||
/************************************************************************/
|
||
/******/ ({
|
||
|
||
/***/ 0:
|
||
/***/ (function(module, exports) {
|
||
|
||
(function() { module.exports = this["wp"]["element"]; }());
|
||
|
||
/***/ }),
|
||
|
||
/***/ 103:
|
||
/***/ (function(module, exports) {
|
||
|
||
// shim for using process in browser
|
||
var process = module.exports = {};
|
||
|
||
// cached from whatever global is present so that test runners that stub it
|
||
// don't break things. But we need to wrap it in a try catch in case it is
|
||
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
||
// function because try/catches deoptimize in certain engines.
|
||
|
||
var cachedSetTimeout;
|
||
var cachedClearTimeout;
|
||
|
||
function defaultSetTimout() {
|
||
throw new Error('setTimeout has not been defined');
|
||
}
|
||
function defaultClearTimeout () {
|
||
throw new Error('clearTimeout has not been defined');
|
||
}
|
||
(function () {
|
||
try {
|
||
if (typeof setTimeout === 'function') {
|
||
cachedSetTimeout = setTimeout;
|
||
} else {
|
||
cachedSetTimeout = defaultSetTimout;
|
||
}
|
||
} catch (e) {
|
||
cachedSetTimeout = defaultSetTimout;
|
||
}
|
||
try {
|
||
if (typeof clearTimeout === 'function') {
|
||
cachedClearTimeout = clearTimeout;
|
||
} else {
|
||
cachedClearTimeout = defaultClearTimeout;
|
||
}
|
||
} catch (e) {
|
||
cachedClearTimeout = defaultClearTimeout;
|
||
}
|
||
} ())
|
||
function runTimeout(fun) {
|
||
if (cachedSetTimeout === setTimeout) {
|
||
//normal enviroments in sane situations
|
||
return setTimeout(fun, 0);
|
||
}
|
||
// if setTimeout wasn't available but was latter defined
|
||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
||
cachedSetTimeout = setTimeout;
|
||
return setTimeout(fun, 0);
|
||
}
|
||
try {
|
||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||
return cachedSetTimeout(fun, 0);
|
||
} catch(e){
|
||
try {
|
||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||
return cachedSetTimeout.call(null, fun, 0);
|
||
} catch(e){
|
||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
||
return cachedSetTimeout.call(this, fun, 0);
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
function runClearTimeout(marker) {
|
||
if (cachedClearTimeout === clearTimeout) {
|
||
//normal enviroments in sane situations
|
||
return clearTimeout(marker);
|
||
}
|
||
// if clearTimeout wasn't available but was latter defined
|
||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
||
cachedClearTimeout = clearTimeout;
|
||
return clearTimeout(marker);
|
||
}
|
||
try {
|
||
// when when somebody has screwed with setTimeout but no I.E. maddness
|
||
return cachedClearTimeout(marker);
|
||
} catch (e){
|
||
try {
|
||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
||
return cachedClearTimeout.call(null, marker);
|
||
} catch (e){
|
||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
||
return cachedClearTimeout.call(this, marker);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
var queue = [];
|
||
var draining = false;
|
||
var currentQueue;
|
||
var queueIndex = -1;
|
||
|
||
function cleanUpNextTick() {
|
||
if (!draining || !currentQueue) {
|
||
return;
|
||
}
|
||
draining = false;
|
||
if (currentQueue.length) {
|
||
queue = currentQueue.concat(queue);
|
||
} else {
|
||
queueIndex = -1;
|
||
}
|
||
if (queue.length) {
|
||
drainQueue();
|
||
}
|
||
}
|
||
|
||
function drainQueue() {
|
||
if (draining) {
|
||
return;
|
||
}
|
||
var timeout = runTimeout(cleanUpNextTick);
|
||
draining = true;
|
||
|
||
var len = queue.length;
|
||
while(len) {
|
||
currentQueue = queue;
|
||
queue = [];
|
||
while (++queueIndex < len) {
|
||
if (currentQueue) {
|
||
currentQueue[queueIndex].run();
|
||
}
|
||
}
|
||
queueIndex = -1;
|
||
len = queue.length;
|
||
}
|
||
currentQueue = null;
|
||
draining = false;
|
||
runClearTimeout(timeout);
|
||
}
|
||
|
||
process.nextTick = function (fun) {
|
||
var args = new Array(arguments.length - 1);
|
||
if (arguments.length > 1) {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
args[i - 1] = arguments[i];
|
||
}
|
||
}
|
||
queue.push(new Item(fun, args));
|
||
if (queue.length === 1 && !draining) {
|
||
runTimeout(drainQueue);
|
||
}
|
||
};
|
||
|
||
// v8 likes predictible objects
|
||
function Item(fun, array) {
|
||
this.fun = fun;
|
||
this.array = array;
|
||
}
|
||
Item.prototype.run = function () {
|
||
this.fun.apply(null, this.array);
|
||
};
|
||
process.title = 'browser';
|
||
process.browser = true;
|
||
process.env = {};
|
||
process.argv = [];
|
||
process.version = ''; // empty string to avoid regexp issues
|
||
process.versions = {};
|
||
|
||
function noop() {}
|
||
|
||
process.on = noop;
|
||
process.addListener = noop;
|
||
process.once = noop;
|
||
process.off = noop;
|
||
process.removeListener = noop;
|
||
process.removeAllListeners = noop;
|
||
process.emit = noop;
|
||
process.prependListener = noop;
|
||
process.prependOnceListener = noop;
|
||
|
||
process.listeners = function (name) { return [] }
|
||
|
||
process.binding = function (name) {
|
||
throw new Error('process.binding is not supported');
|
||
};
|
||
|
||
process.cwd = function () { return '/' };
|
||
process.chdir = function (dir) {
|
||
throw new Error('process.chdir is not supported');
|
||
};
|
||
process.umask = function() { return 0; };
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 110:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useMediaQuery; });
|
||
/* harmony import */ var _babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
|
||
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
|
||
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__);
|
||
|
||
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
/**
|
||
* Runs a media query and returns its value when it changes.
|
||
*
|
||
* @param {string} [query] Media Query.
|
||
* @return {boolean} return value of the media query.
|
||
*/
|
||
|
||
function useMediaQuery(query) {
|
||
var _useState = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["useState"])(false),
|
||
_useState2 = Object(_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(_useState, 2),
|
||
match = _useState2[0],
|
||
setMatch = _useState2[1];
|
||
|
||
Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["useEffect"])(function () {
|
||
if (!query) {
|
||
return;
|
||
}
|
||
|
||
var updateMatch = function updateMatch() {
|
||
return setMatch(window.matchMedia(query).matches);
|
||
};
|
||
|
||
updateMatch();
|
||
var list = window.matchMedia(query);
|
||
list.addListener(updateMatch);
|
||
return function () {
|
||
list.removeListener(updateMatch);
|
||
};
|
||
}, [query]);
|
||
return query && match;
|
||
}
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 12:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
|
||
function _extends() {
|
||
_extends = Object.assign || function (target) {
|
||
for (var i = 1; i < arguments.length; i++) {
|
||
var source = arguments[i];
|
||
|
||
for (var key in source) {
|
||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||
target[key] = source[key];
|
||
}
|
||
}
|
||
}
|
||
|
||
return target;
|
||
};
|
||
|
||
return _extends.apply(this, arguments);
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 13:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
|
||
function _defineProperties(target, props) {
|
||
for (var i = 0; i < props.length; i++) {
|
||
var descriptor = props[i];
|
||
descriptor.enumerable = descriptor.enumerable || false;
|
||
descriptor.configurable = true;
|
||
if ("value" in descriptor) descriptor.writable = true;
|
||
Object.defineProperty(target, descriptor.key, descriptor);
|
||
}
|
||
}
|
||
|
||
function _createClass(Constructor, protoProps, staticProps) {
|
||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||
return Constructor;
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 14:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
|
||
function _classCallCheck(instance, Constructor) {
|
||
if (!(instance instanceof Constructor)) {
|
||
throw new TypeError("Cannot call a class as a function");
|
||
}
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 15:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
|
||
/* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32);
|
||
/* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
||
|
||
|
||
function _possibleConstructorReturn(self, call) {
|
||
if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) {
|
||
return call;
|
||
}
|
||
|
||
return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 16:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
|
||
function _getPrototypeOf(o) {
|
||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
||
return o.__proto__ || Object.getPrototypeOf(o);
|
||
};
|
||
return _getPrototypeOf(o);
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 17:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
|
||
function _setPrototypeOf(o, p) {
|
||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
||
o.__proto__ = p;
|
||
return o;
|
||
};
|
||
|
||
return _setPrototypeOf(o, p);
|
||
}
|
||
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
|
||
|
||
function _inherits(subClass, superClass) {
|
||
if (typeof superClass !== "function" && superClass !== null) {
|
||
throw new TypeError("Super expression must either be null or a function");
|
||
}
|
||
|
||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||
constructor: {
|
||
value: subClass,
|
||
writable: true,
|
||
configurable: true
|
||
}
|
||
});
|
||
if (superClass) _setPrototypeOf(subClass, superClass);
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 2:
|
||
/***/ (function(module, exports) {
|
||
|
||
(function() { module.exports = this["lodash"]; }());
|
||
|
||
/***/ }),
|
||
|
||
/***/ 20:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
||
var arrayWithHoles = __webpack_require__(36);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
|
||
function _iterableToArrayLimit(arr, i) {
|
||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
|
||
return;
|
||
}
|
||
|
||
var _arr = [];
|
||
var _n = true;
|
||
var _d = false;
|
||
var _e = undefined;
|
||
|
||
try {
|
||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||
_arr.push(_s.value);
|
||
|
||
if (i && _arr.length === i) break;
|
||
}
|
||
} catch (err) {
|
||
_d = true;
|
||
_e = err;
|
||
} finally {
|
||
try {
|
||
if (!_n && _i["return"] != null) _i["return"]();
|
||
} finally {
|
||
if (_d) throw _e;
|
||
}
|
||
}
|
||
|
||
return _arr;
|
||
}
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
|
||
var nonIterableRest = __webpack_require__(37);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _slicedToArray; });
|
||
|
||
|
||
|
||
function _slicedToArray(arr, i) {
|
||
return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(nonIterableRest["a" /* default */])();
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 250:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* WEBPACK VAR INJECTION */(function(process) {/* harmony import */ var _use_media_query__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(110);
|
||
/**
|
||
* Internal dependencies
|
||
*/
|
||
|
||
/**
|
||
* Whether or not the user agent is Internet Explorer.
|
||
*
|
||
* @type {boolean}
|
||
*/
|
||
|
||
var IS_IE = typeof window !== 'undefined' && window.navigator.userAgent.indexOf('Trident') >= 0;
|
||
/**
|
||
* Hook returning whether the user has a preference for reduced motion.
|
||
*
|
||
* @return {boolean} Reduced motion preference value.
|
||
*/
|
||
|
||
var useReducedMotion = process.env.FORCE_REDUCED_MOTION || IS_IE ? function () {
|
||
return true;
|
||
} : function () {
|
||
return Object(_use_media_query__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])('(prefers-reduced-motion: reduce)');
|
||
};
|
||
/* harmony default export */ __webpack_exports__["a"] = (useReducedMotion);
|
||
|
||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(103)))
|
||
|
||
/***/ }),
|
||
|
||
/***/ 269:
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */
|
||
/**
|
||
* Copyright 2012-2017 Craig Campbell
|
||
*
|
||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
* you may not use this file except in compliance with the License.
|
||
* You may obtain a copy of the License at
|
||
*
|
||
* http://www.apache.org/licenses/LICENSE-2.0
|
||
*
|
||
* Unless required by applicable law or agreed to in writing, software
|
||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
* See the License for the specific language governing permissions and
|
||
* limitations under the License.
|
||
*
|
||
* Mousetrap is a simple keyboard shortcut library for Javascript with
|
||
* no external dependencies
|
||
*
|
||
* @version 1.6.5
|
||
* @url craig.is/killing/mice
|
||
*/
|
||
(function(window, document, undefined) {
|
||
|
||
// Check if mousetrap is used inside browser, if not, return
|
||
if (!window) {
|
||
return;
|
||
}
|
||
|
||
/**
|
||
* mapping of special keycodes to their corresponding keys
|
||
*
|
||
* everything in this dictionary cannot use keypress events
|
||
* so it has to be here to map to the correct keycodes for
|
||
* keyup/keydown events
|
||
*
|
||
* @type {Object}
|
||
*/
|
||
var _MAP = {
|
||
8: 'backspace',
|
||
9: 'tab',
|
||
13: 'enter',
|
||
16: 'shift',
|
||
17: 'ctrl',
|
||
18: 'alt',
|
||
20: 'capslock',
|
||
27: 'esc',
|
||
32: 'space',
|
||
33: 'pageup',
|
||
34: 'pagedown',
|
||
35: 'end',
|
||
36: 'home',
|
||
37: 'left',
|
||
38: 'up',
|
||
39: 'right',
|
||
40: 'down',
|
||
45: 'ins',
|
||
46: 'del',
|
||
91: 'meta',
|
||
93: 'meta',
|
||
224: 'meta'
|
||
};
|
||
|
||
/**
|
||
* mapping for special characters so they can support
|
||
*
|
||
* this dictionary is only used incase you want to bind a
|
||
* keyup or keydown event to one of these keys
|
||
*
|
||
* @type {Object}
|
||
*/
|
||
var _KEYCODE_MAP = {
|
||
106: '*',
|
||
107: '+',
|
||
109: '-',
|
||
110: '.',
|
||
111 : '/',
|
||
186: ';',
|
||
187: '=',
|
||
188: ',',
|
||
189: '-',
|
||
190: '.',
|
||
191: '/',
|
||
192: '`',
|
||
219: '[',
|
||
220: '\\',
|
||
221: ']',
|
||
222: '\''
|
||
};
|
||
|
||
/**
|
||
* this is a mapping of keys that require shift on a US keypad
|
||
* back to the non shift equivelents
|
||
*
|
||
* this is so you can use keyup events with these keys
|
||
*
|
||
* note that this will only work reliably on US keyboards
|
||
*
|
||
* @type {Object}
|
||
*/
|
||
var _SHIFT_MAP = {
|
||
'~': '`',
|
||
'!': '1',
|
||
'@': '2',
|
||
'#': '3',
|
||
'$': '4',
|
||
'%': '5',
|
||
'^': '6',
|
||
'&': '7',
|
||
'*': '8',
|
||
'(': '9',
|
||
')': '0',
|
||
'_': '-',
|
||
'+': '=',
|
||
':': ';',
|
||
'\"': '\'',
|
||
'<': ',',
|
||
'>': '.',
|
||
'?': '/',
|
||
'|': '\\'
|
||
};
|
||
|
||
/**
|
||
* this is a list of special strings you can use to map
|
||
* to modifier keys when you specify your keyboard shortcuts
|
||
*
|
||
* @type {Object}
|
||
*/
|
||
var _SPECIAL_ALIASES = {
|
||
'option': 'alt',
|
||
'command': 'meta',
|
||
'return': 'enter',
|
||
'escape': 'esc',
|
||
'plus': '+',
|
||
'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
|
||
};
|
||
|
||
/**
|
||
* variable to store the flipped version of _MAP from above
|
||
* needed to check if we should use keypress or not when no action
|
||
* is specified
|
||
*
|
||
* @type {Object|undefined}
|
||
*/
|
||
var _REVERSE_MAP;
|
||
|
||
/**
|
||
* loop through the f keys, f1 to f19 and add them to the map
|
||
* programatically
|
||
*/
|
||
for (var i = 1; i < 20; ++i) {
|
||
_MAP[111 + i] = 'f' + i;
|
||
}
|
||
|
||
/**
|
||
* loop through to map numbers on the numeric keypad
|
||
*/
|
||
for (i = 0; i <= 9; ++i) {
|
||
|
||
// This needs to use a string cause otherwise since 0 is falsey
|
||
// mousetrap will never fire for numpad 0 pressed as part of a keydown
|
||
// event.
|
||
//
|
||
// @see https://github.com/ccampbell/mousetrap/pull/258
|
||
_MAP[i + 96] = i.toString();
|
||
}
|
||
|
||
/**
|
||
* cross browser add event method
|
||
*
|
||
* @param {Element|HTMLDocument} object
|
||
* @param {string} type
|
||
* @param {Function} callback
|
||
* @returns void
|
||
*/
|
||
function _addEvent(object, type, callback) {
|
||
if (object.addEventListener) {
|
||
object.addEventListener(type, callback, false);
|
||
return;
|
||
}
|
||
|
||
object.attachEvent('on' + type, callback);
|
||
}
|
||
|
||
/**
|
||
* takes the event and returns the key character
|
||
*
|
||
* @param {Event} e
|
||
* @return {string}
|
||
*/
|
||
function _characterFromEvent(e) {
|
||
|
||
// for keypress events we should return the character as is
|
||
if (e.type == 'keypress') {
|
||
var character = String.fromCharCode(e.which);
|
||
|
||
// if the shift key is not pressed then it is safe to assume
|
||
// that we want the character to be lowercase. this means if
|
||
// you accidentally have caps lock on then your key bindings
|
||
// will continue to work
|
||
//
|
||
// the only side effect that might not be desired is if you
|
||
// bind something like 'A' cause you want to trigger an
|
||
// event when capital A is pressed caps lock will no longer
|
||
// trigger the event. shift+a will though.
|
||
if (!e.shiftKey) {
|
||
character = character.toLowerCase();
|
||
}
|
||
|
||
return character;
|
||
}
|
||
|
||
// for non keypress events the special maps are needed
|
||
if (_MAP[e.which]) {
|
||
return _MAP[e.which];
|
||
}
|
||
|
||
if (_KEYCODE_MAP[e.which]) {
|
||
return _KEYCODE_MAP[e.which];
|
||
}
|
||
|
||
// if it is not in the special map
|
||
|
||
// with keydown and keyup events the character seems to always
|
||
// come in as an uppercase character whether you are pressing shift
|
||
// or not. we should make sure it is always lowercase for comparisons
|
||
return String.fromCharCode(e.which).toLowerCase();
|
||
}
|
||
|
||
/**
|
||
* checks if two arrays are equal
|
||
*
|
||
* @param {Array} modifiers1
|
||
* @param {Array} modifiers2
|
||
* @returns {boolean}
|
||
*/
|
||
function _modifiersMatch(modifiers1, modifiers2) {
|
||
return modifiers1.sort().join(',') === modifiers2.sort().join(',');
|
||
}
|
||
|
||
/**
|
||
* takes a key event and figures out what the modifiers are
|
||
*
|
||
* @param {Event} e
|
||
* @returns {Array}
|
||
*/
|
||
function _eventModifiers(e) {
|
||
var modifiers = [];
|
||
|
||
if (e.shiftKey) {
|
||
modifiers.push('shift');
|
||
}
|
||
|
||
if (e.altKey) {
|
||
modifiers.push('alt');
|
||
}
|
||
|
||
if (e.ctrlKey) {
|
||
modifiers.push('ctrl');
|
||
}
|
||
|
||
if (e.metaKey) {
|
||
modifiers.push('meta');
|
||
}
|
||
|
||
return modifiers;
|
||
}
|
||
|
||
/**
|
||
* prevents default for this event
|
||
*
|
||
* @param {Event} e
|
||
* @returns void
|
||
*/
|
||
function _preventDefault(e) {
|
||
if (e.preventDefault) {
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
|
||
e.returnValue = false;
|
||
}
|
||
|
||
/**
|
||
* stops propogation for this event
|
||
*
|
||
* @param {Event} e
|
||
* @returns void
|
||
*/
|
||
function _stopPropagation(e) {
|
||
if (e.stopPropagation) {
|
||
e.stopPropagation();
|
||
return;
|
||
}
|
||
|
||
e.cancelBubble = true;
|
||
}
|
||
|
||
/**
|
||
* determines if the keycode specified is a modifier key or not
|
||
*
|
||
* @param {string} key
|
||
* @returns {boolean}
|
||
*/
|
||
function _isModifier(key) {
|
||
return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
|
||
}
|
||
|
||
/**
|
||
* reverses the map lookup so that we can look for specific keys
|
||
* to see what can and can't use keypress
|
||
*
|
||
* @return {Object}
|
||
*/
|
||
function _getReverseMap() {
|
||
if (!_REVERSE_MAP) {
|
||
_REVERSE_MAP = {};
|
||
for (var key in _MAP) {
|
||
|
||
// pull out the numeric keypad from here cause keypress should
|
||
// be able to detect the keys from the character
|
||
if (key > 95 && key < 112) {
|
||
continue;
|
||
}
|
||
|
||
if (_MAP.hasOwnProperty(key)) {
|
||
_REVERSE_MAP[_MAP[key]] = key;
|
||
}
|
||
}
|
||
}
|
||
return _REVERSE_MAP;
|
||
}
|
||
|
||
/**
|
||
* picks the best action based on the key combination
|
||
*
|
||
* @param {string} key - character for key
|
||
* @param {Array} modifiers
|
||
* @param {string=} action passed in
|
||
*/
|
||
function _pickBestAction(key, modifiers, action) {
|
||
|
||
// if no action was picked in we should try to pick the one
|
||
// that we think would work best for this key
|
||
if (!action) {
|
||
action = _getReverseMap()[key] ? 'keydown' : 'keypress';
|
||
}
|
||
|
||
// modifier keys don't work as expected with keypress,
|
||
// switch to keydown
|
||
if (action == 'keypress' && modifiers.length) {
|
||
action = 'keydown';
|
||
}
|
||
|
||
return action;
|
||
}
|
||
|
||
/**
|
||
* Converts from a string key combination to an array
|
||
*
|
||
* @param {string} combination like "command+shift+l"
|
||
* @return {Array}
|
||
*/
|
||
function _keysFromString(combination) {
|
||
if (combination === '+') {
|
||
return ['+'];
|
||
}
|
||
|
||
combination = combination.replace(/\+{2}/g, '+plus');
|
||
return combination.split('+');
|
||
}
|
||
|
||
/**
|
||
* Gets info for a specific key combination
|
||
*
|
||
* @param {string} combination key combination ("command+s" or "a" or "*")
|
||
* @param {string=} action
|
||
* @returns {Object}
|
||
*/
|
||
function _getKeyInfo(combination, action) {
|
||
var keys;
|
||
var key;
|
||
var i;
|
||
var modifiers = [];
|
||
|
||
// take the keys from this pattern and figure out what the actual
|
||
// pattern is all about
|
||
keys = _keysFromString(combination);
|
||
|
||
for (i = 0; i < keys.length; ++i) {
|
||
key = keys[i];
|
||
|
||
// normalize key names
|
||
if (_SPECIAL_ALIASES[key]) {
|
||
key = _SPECIAL_ALIASES[key];
|
||
}
|
||
|
||
// if this is not a keypress event then we should
|
||
// be smart about using shift keys
|
||
// this will only work for US keyboards however
|
||
if (action && action != 'keypress' && _SHIFT_MAP[key]) {
|
||
key = _SHIFT_MAP[key];
|
||
modifiers.push('shift');
|
||
}
|
||
|
||
// if this key is a modifier then add it to the list of modifiers
|
||
if (_isModifier(key)) {
|
||
modifiers.push(key);
|
||
}
|
||
}
|
||
|
||
// depending on what the key combination is
|
||
// we will try to pick the best event for it
|
||
action = _pickBestAction(key, modifiers, action);
|
||
|
||
return {
|
||
key: key,
|
||
modifiers: modifiers,
|
||
action: action
|
||
};
|
||
}
|
||
|
||
function _belongsTo(element, ancestor) {
|
||
if (element === null || element === document) {
|
||
return false;
|
||
}
|
||
|
||
if (element === ancestor) {
|
||
return true;
|
||
}
|
||
|
||
return _belongsTo(element.parentNode, ancestor);
|
||
}
|
||
|
||
function Mousetrap(targetElement) {
|
||
var self = this;
|
||
|
||
targetElement = targetElement || document;
|
||
|
||
if (!(self instanceof Mousetrap)) {
|
||
return new Mousetrap(targetElement);
|
||
}
|
||
|
||
/**
|
||
* element to attach key events to
|
||
*
|
||
* @type {Element}
|
||
*/
|
||
self.target = targetElement;
|
||
|
||
/**
|
||
* a list of all the callbacks setup via Mousetrap.bind()
|
||
*
|
||
* @type {Object}
|
||
*/
|
||
self._callbacks = {};
|
||
|
||
/**
|
||
* direct map of string combinations to callbacks used for trigger()
|
||
*
|
||
* @type {Object}
|
||
*/
|
||
self._directMap = {};
|
||
|
||
/**
|
||
* keeps track of what level each sequence is at since multiple
|
||
* sequences can start out with the same sequence
|
||
*
|
||
* @type {Object}
|
||
*/
|
||
var _sequenceLevels = {};
|
||
|
||
/**
|
||
* variable to store the setTimeout call
|
||
*
|
||
* @type {null|number}
|
||
*/
|
||
var _resetTimer;
|
||
|
||
/**
|
||
* temporary state where we will ignore the next keyup
|
||
*
|
||
* @type {boolean|string}
|
||
*/
|
||
var _ignoreNextKeyup = false;
|
||
|
||
/**
|
||
* temporary state where we will ignore the next keypress
|
||
*
|
||
* @type {boolean}
|
||
*/
|
||
var _ignoreNextKeypress = false;
|
||
|
||
/**
|
||
* are we currently inside of a sequence?
|
||
* type of action ("keyup" or "keydown" or "keypress") or false
|
||
*
|
||
* @type {boolean|string}
|
||
*/
|
||
var _nextExpectedAction = false;
|
||
|
||
/**
|
||
* resets all sequence counters except for the ones passed in
|
||
*
|
||
* @param {Object} doNotReset
|
||
* @returns void
|
||
*/
|
||
function _resetSequences(doNotReset) {
|
||
doNotReset = doNotReset || {};
|
||
|
||
var activeSequences = false,
|
||
key;
|
||
|
||
for (key in _sequenceLevels) {
|
||
if (doNotReset[key]) {
|
||
activeSequences = true;
|
||
continue;
|
||
}
|
||
_sequenceLevels[key] = 0;
|
||
}
|
||
|
||
if (!activeSequences) {
|
||
_nextExpectedAction = false;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* finds all callbacks that match based on the keycode, modifiers,
|
||
* and action
|
||
*
|
||
* @param {string} character
|
||
* @param {Array} modifiers
|
||
* @param {Event|Object} e
|
||
* @param {string=} sequenceName - name of the sequence we are looking for
|
||
* @param {string=} combination
|
||
* @param {number=} level
|
||
* @returns {Array}
|
||
*/
|
||
function _getMatches(character, modifiers, e, sequenceName, combination, level) {
|
||
var i;
|
||
var callback;
|
||
var matches = [];
|
||
var action = e.type;
|
||
|
||
// if there are no events related to this keycode
|
||
if (!self._callbacks[character]) {
|
||
return [];
|
||
}
|
||
|
||
// if a modifier key is coming up on its own we should allow it
|
||
if (action == 'keyup' && _isModifier(character)) {
|
||
modifiers = [character];
|
||
}
|
||
|
||
// loop through all callbacks for the key that was pressed
|
||
// and see if any of them match
|
||
for (i = 0; i < self._callbacks[character].length; ++i) {
|
||
callback = self._callbacks[character][i];
|
||
|
||
// if a sequence name is not specified, but this is a sequence at
|
||
// the wrong level then move onto the next match
|
||
if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
|
||
continue;
|
||
}
|
||
|
||
// if the action we are looking for doesn't match the action we got
|
||
// then we should keep going
|
||
if (action != callback.action) {
|
||
continue;
|
||
}
|
||
|
||
// if this is a keypress event and the meta key and control key
|
||
// are not pressed that means that we need to only look at the
|
||
// character, otherwise check the modifiers as well
|
||
//
|
||
// chrome will not fire a keypress if meta or control is down
|
||
// safari will fire a keypress if meta or meta+shift is down
|
||
// firefox will fire a keypress if meta or control is down
|
||
if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {
|
||
|
||
// when you bind a combination or sequence a second time it
|
||
// should overwrite the first one. if a sequenceName or
|
||
// combination is specified in this call it does just that
|
||
//
|
||
// @todo make deleting its own method?
|
||
var deleteCombo = !sequenceName && callback.combo == combination;
|
||
var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
|
||
if (deleteCombo || deleteSequence) {
|
||
self._callbacks[character].splice(i, 1);
|
||
}
|
||
|
||
matches.push(callback);
|
||
}
|
||
}
|
||
|
||
return matches;
|
||
}
|
||
|
||
/**
|
||
* actually calls the callback function
|
||
*
|
||
* if your callback function returns false this will use the jquery
|
||
* convention - prevent default and stop propogation on the event
|
||
*
|
||
* @param {Function} callback
|
||
* @param {Event} e
|
||
* @returns void
|
||
*/
|
||
function _fireCallback(callback, e, combo, sequence) {
|
||
|
||
// if this event should not happen stop here
|
||
if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
|
||
return;
|
||
}
|
||
|
||
if (callback(e, combo) === false) {
|
||
_preventDefault(e);
|
||
_stopPropagation(e);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* handles a character key event
|
||
*
|
||
* @param {string} character
|
||
* @param {Array} modifiers
|
||
* @param {Event} e
|
||
* @returns void
|
||
*/
|
||
self._handleKey = function(character, modifiers, e) {
|
||
var callbacks = _getMatches(character, modifiers, e);
|
||
var i;
|
||
var doNotReset = {};
|
||
var maxLevel = 0;
|
||
var processedSequenceCallback = false;
|
||
|
||
// Calculate the maxLevel for sequences so we can only execute the longest callback sequence
|
||
for (i = 0; i < callbacks.length; ++i) {
|
||
if (callbacks[i].seq) {
|
||
maxLevel = Math.max(maxLevel, callbacks[i].level);
|
||
}
|
||
}
|
||
|
||
// loop through matching callbacks for this key event
|
||
for (i = 0; i < callbacks.length; ++i) {
|
||
|
||
// fire for all sequence callbacks
|
||
// this is because if for example you have multiple sequences
|
||
// bound such as "g i" and "g t" they both need to fire the
|
||
// callback for matching g cause otherwise you can only ever
|
||
// match the first one
|
||
if (callbacks[i].seq) {
|
||
|
||
// only fire callbacks for the maxLevel to prevent
|
||
// subsequences from also firing
|
||
//
|
||
// for example 'a option b' should not cause 'option b' to fire
|
||
// even though 'option b' is part of the other sequence
|
||
//
|
||
// any sequences that do not match here will be discarded
|
||
// below by the _resetSequences call
|
||
if (callbacks[i].level != maxLevel) {
|
||
continue;
|
||
}
|
||
|
||
processedSequenceCallback = true;
|
||
|
||
// keep a list of which sequences were matches for later
|
||
doNotReset[callbacks[i].seq] = 1;
|
||
_fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
|
||
continue;
|
||
}
|
||
|
||
// if there were no sequence matches but we are still here
|
||
// that means this is a regular match so we should fire that
|
||
if (!processedSequenceCallback) {
|
||
_fireCallback(callbacks[i].callback, e, callbacks[i].combo);
|
||
}
|
||
}
|
||
|
||
// if the key you pressed matches the type of sequence without
|
||
// being a modifier (ie "keyup" or "keypress") then we should
|
||
// reset all sequences that were not matched by this event
|
||
//
|
||
// this is so, for example, if you have the sequence "h a t" and you
|
||
// type "h e a r t" it does not match. in this case the "e" will
|
||
// cause the sequence to reset
|
||
//
|
||
// modifier keys are ignored because you can have a sequence
|
||
// that contains modifiers such as "enter ctrl+space" and in most
|
||
// cases the modifier key will be pressed before the next key
|
||
//
|
||
// also if you have a sequence such as "ctrl+b a" then pressing the
|
||
// "b" key will trigger a "keypress" and a "keydown"
|
||
//
|
||
// the "keydown" is expected when there is a modifier, but the
|
||
// "keypress" ends up matching the _nextExpectedAction since it occurs
|
||
// after and that causes the sequence to reset
|
||
//
|
||
// we ignore keypresses in a sequence that directly follow a keydown
|
||
// for the same character
|
||
var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
|
||
if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
|
||
_resetSequences(doNotReset);
|
||
}
|
||
|
||
_ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
|
||
};
|
||
|
||
/**
|
||
* handles a keydown event
|
||
*
|
||
* @param {Event} e
|
||
* @returns void
|
||
*/
|
||
function _handleKeyEvent(e) {
|
||
|
||
// normalize e.which for key events
|
||
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
|
||
if (typeof e.which !== 'number') {
|
||
e.which = e.keyCode;
|
||
}
|
||
|
||
var character = _characterFromEvent(e);
|
||
|
||
// no character found then stop
|
||
if (!character) {
|
||
return;
|
||
}
|
||
|
||
// need to use === for the character check because the character can be 0
|
||
if (e.type == 'keyup' && _ignoreNextKeyup === character) {
|
||
_ignoreNextKeyup = false;
|
||
return;
|
||
}
|
||
|
||
self.handleKey(character, _eventModifiers(e), e);
|
||
}
|
||
|
||
/**
|
||
* called to set a 1 second timeout on the specified sequence
|
||
*
|
||
* this is so after each key press in the sequence you have 1 second
|
||
* to press the next key before you have to start over
|
||
*
|
||
* @returns void
|
||
*/
|
||
function _resetSequenceTimer() {
|
||
clearTimeout(_resetTimer);
|
||
_resetTimer = setTimeout(_resetSequences, 1000);
|
||
}
|
||
|
||
/**
|
||
* binds a key sequence to an event
|
||
*
|
||
* @param {string} combo - combo specified in bind call
|
||
* @param {Array} keys
|
||
* @param {Function} callback
|
||
* @param {string=} action
|
||
* @returns void
|
||
*/
|
||
function _bindSequence(combo, keys, callback, action) {
|
||
|
||
// start off by adding a sequence level record for this combination
|
||
// and setting the level to 0
|
||
_sequenceLevels[combo] = 0;
|
||
|
||
/**
|
||
* callback to increase the sequence level for this sequence and reset
|
||
* all other sequences that were active
|
||
*
|
||
* @param {string} nextAction
|
||
* @returns {Function}
|
||
*/
|
||
function _increaseSequence(nextAction) {
|
||
return function() {
|
||
_nextExpectedAction = nextAction;
|
||
++_sequenceLevels[combo];
|
||
_resetSequenceTimer();
|
||
};
|
||
}
|
||
|
||
/**
|
||
* wraps the specified callback inside of another function in order
|
||
* to reset all sequence counters as soon as this sequence is done
|
||
*
|
||
* @param {Event} e
|
||
* @returns void
|
||
*/
|
||
function _callbackAndReset(e) {
|
||
_fireCallback(callback, e, combo);
|
||
|
||
// we should ignore the next key up if the action is key down
|
||
// or keypress. this is so if you finish a sequence and
|
||
// release the key the final key will not trigger a keyup
|
||
if (action !== 'keyup') {
|
||
_ignoreNextKeyup = _characterFromEvent(e);
|
||
}
|
||
|
||
// weird race condition if a sequence ends with the key
|
||
// another sequence begins with
|
||
setTimeout(_resetSequences, 10);
|
||
}
|
||
|
||
// loop through keys one at a time and bind the appropriate callback
|
||
// function. for any key leading up to the final one it should
|
||
// increase the sequence. after the final, it should reset all sequences
|
||
//
|
||
// if an action is specified in the original bind call then that will
|
||
// be used throughout. otherwise we will pass the action that the
|
||
// next key in the sequence should match. this allows a sequence
|
||
// to mix and match keypress and keydown events depending on which
|
||
// ones are better suited to the key provided
|
||
for (var i = 0; i < keys.length; ++i) {
|
||
var isFinal = i + 1 === keys.length;
|
||
var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);
|
||
_bindSingle(keys[i], wrappedCallback, action, combo, i);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* binds a single keyboard combination
|
||
*
|
||
* @param {string} combination
|
||
* @param {Function} callback
|
||
* @param {string=} action
|
||
* @param {string=} sequenceName - name of sequence if part of sequence
|
||
* @param {number=} level - what part of the sequence the command is
|
||
* @returns void
|
||
*/
|
||
function _bindSingle(combination, callback, action, sequenceName, level) {
|
||
|
||
// store a direct mapped reference for use with Mousetrap.trigger
|
||
self._directMap[combination + ':' + action] = callback;
|
||
|
||
// make sure multiple spaces in a row become a single space
|
||
combination = combination.replace(/\s+/g, ' ');
|
||
|
||
var sequence = combination.split(' ');
|
||
var info;
|
||
|
||
// if this pattern is a sequence of keys then run through this method
|
||
// to reprocess each pattern one key at a time
|
||
if (sequence.length > 1) {
|
||
_bindSequence(combination, sequence, callback, action);
|
||
return;
|
||
}
|
||
|
||
info = _getKeyInfo(combination, action);
|
||
|
||
// make sure to initialize array if this is the first time
|
||
// a callback is added for this key
|
||
self._callbacks[info.key] = self._callbacks[info.key] || [];
|
||
|
||
// remove an existing match if there is one
|
||
_getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
|
||
|
||
// add this call back to the array
|
||
// if it is a sequence put it at the beginning
|
||
// if not put it at the end
|
||
//
|
||
// this is important because the way these are processed expects
|
||
// the sequence ones to come first
|
||
self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
|
||
callback: callback,
|
||
modifiers: info.modifiers,
|
||
action: info.action,
|
||
seq: sequenceName,
|
||
level: level,
|
||
combo: combination
|
||
});
|
||
}
|
||
|
||
/**
|
||
* binds multiple combinations to the same callback
|
||
*
|
||
* @param {Array} combinations
|
||
* @param {Function} callback
|
||
* @param {string|undefined} action
|
||
* @returns void
|
||
*/
|
||
self._bindMultiple = function(combinations, callback, action) {
|
||
for (var i = 0; i < combinations.length; ++i) {
|
||
_bindSingle(combinations[i], callback, action);
|
||
}
|
||
};
|
||
|
||
// start!
|
||
_addEvent(targetElement, 'keypress', _handleKeyEvent);
|
||
_addEvent(targetElement, 'keydown', _handleKeyEvent);
|
||
_addEvent(targetElement, 'keyup', _handleKeyEvent);
|
||
}
|
||
|
||
/**
|
||
* binds an event to mousetrap
|
||
*
|
||
* can be a single key, a combination of keys separated with +,
|
||
* an array of keys, or a sequence of keys separated by spaces
|
||
*
|
||
* be sure to list the modifier keys first to make sure that the
|
||
* correct key ends up getting bound (the last key in the pattern)
|
||
*
|
||
* @param {string|Array} keys
|
||
* @param {Function} callback
|
||
* @param {string=} action - 'keypress', 'keydown', or 'keyup'
|
||
* @returns void
|
||
*/
|
||
Mousetrap.prototype.bind = function(keys, callback, action) {
|
||
var self = this;
|
||
keys = keys instanceof Array ? keys : [keys];
|
||
self._bindMultiple.call(self, keys, callback, action);
|
||
return self;
|
||
};
|
||
|
||
/**
|
||
* unbinds an event to mousetrap
|
||
*
|
||
* the unbinding sets the callback function of the specified key combo
|
||
* to an empty function and deletes the corresponding key in the
|
||
* _directMap dict.
|
||
*
|
||
* TODO: actually remove this from the _callbacks dictionary instead
|
||
* of binding an empty function
|
||
*
|
||
* the keycombo+action has to be exactly the same as
|
||
* it was defined in the bind method
|
||
*
|
||
* @param {string|Array} keys
|
||
* @param {string} action
|
||
* @returns void
|
||
*/
|
||
Mousetrap.prototype.unbind = function(keys, action) {
|
||
var self = this;
|
||
return self.bind.call(self, keys, function() {}, action);
|
||
};
|
||
|
||
/**
|
||
* triggers an event that has already been bound
|
||
*
|
||
* @param {string} keys
|
||
* @param {string=} action
|
||
* @returns void
|
||
*/
|
||
Mousetrap.prototype.trigger = function(keys, action) {
|
||
var self = this;
|
||
if (self._directMap[keys + ':' + action]) {
|
||
self._directMap[keys + ':' + action]({}, keys);
|
||
}
|
||
return self;
|
||
};
|
||
|
||
/**
|
||
* resets the library back to its initial state. this is useful
|
||
* if you want to clear out the current keyboard shortcuts and bind
|
||
* new ones - for example if you switch to another page
|
||
*
|
||
* @returns void
|
||
*/
|
||
Mousetrap.prototype.reset = function() {
|
||
var self = this;
|
||
self._callbacks = {};
|
||
self._directMap = {};
|
||
return self;
|
||
};
|
||
|
||
/**
|
||
* should we stop this event before firing off callbacks
|
||
*
|
||
* @param {Event} e
|
||
* @param {Element} element
|
||
* @return {boolean}
|
||
*/
|
||
Mousetrap.prototype.stopCallback = function(e, element) {
|
||
var self = this;
|
||
|
||
// if the element has the class "mousetrap" then no need to stop
|
||
if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
|
||
return false;
|
||
}
|
||
|
||
if (_belongsTo(element, self.target)) {
|
||
return false;
|
||
}
|
||
|
||
// Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,
|
||
// not the initial event target in the shadow tree. Note that not all events cross the
|
||
// shadow boundary.
|
||
// For shadow trees with `mode: 'open'`, the initial event target is the first element in
|
||
// the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event
|
||
// target cannot be obtained.
|
||
if ('composedPath' in e && typeof e.composedPath === 'function') {
|
||
// For open shadow trees, update `element` so that the following check works.
|
||
var initialEventTarget = e.composedPath()[0];
|
||
if (initialEventTarget !== e.target) {
|
||
element = initialEventTarget;
|
||
}
|
||
}
|
||
|
||
// stop for input, select, and textarea
|
||
return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
|
||
};
|
||
|
||
/**
|
||
* exposes _handleKey publicly so it can be overwritten by extensions
|
||
*/
|
||
Mousetrap.prototype.handleKey = function() {
|
||
var self = this;
|
||
return self._handleKey.apply(self, arguments);
|
||
};
|
||
|
||
/**
|
||
* allow custom key mappings
|
||
*/
|
||
Mousetrap.addKeycodes = function(object) {
|
||
for (var key in object) {
|
||
if (object.hasOwnProperty(key)) {
|
||
_MAP[key] = object[key];
|
||
}
|
||
}
|
||
_REVERSE_MAP = null;
|
||
};
|
||
|
||
/**
|
||
* Init the global mousetrap functions
|
||
*
|
||
* This method is needed to allow the global mousetrap functions to work
|
||
* now that mousetrap is a constructor function.
|
||
*/
|
||
Mousetrap.init = function() {
|
||
var documentMousetrap = Mousetrap(document);
|
||
for (var method in documentMousetrap) {
|
||
if (method.charAt(0) !== '_') {
|
||
Mousetrap[method] = (function(method) {
|
||
return function() {
|
||
return documentMousetrap[method].apply(documentMousetrap, arguments);
|
||
};
|
||
} (method));
|
||
}
|
||
}
|
||
};
|
||
|
||
Mousetrap.init();
|
||
|
||
// expose mousetrap to the global object
|
||
window.Mousetrap = Mousetrap;
|
||
|
||
// expose as a common js module
|
||
if ( true && module.exports) {
|
||
module.exports = Mousetrap;
|
||
}
|
||
|
||
// expose mousetrap as an AMD module
|
||
if (true) {
|
||
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
|
||
return Mousetrap;
|
||
}).call(exports, __webpack_require__, exports, module),
|
||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
||
}
|
||
}) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 32:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
|
||
function _typeof(obj) {
|
||
"@babel/helpers - typeof";
|
||
|
||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||
_typeof = function _typeof(obj) {
|
||
return typeof obj;
|
||
};
|
||
} else {
|
||
_typeof = function _typeof(obj) {
|
||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||
};
|
||
}
|
||
|
||
return _typeof(obj);
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 36:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
|
||
function _arrayWithHoles(arr) {
|
||
if (Array.isArray(arr)) return arr;
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 37:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
|
||
function _nonIterableRest() {
|
||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||
}
|
||
|
||
/***/ }),
|
||
|
||
/***/ 394:
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* adds a bindGlobal method to Mousetrap that allows you to
|
||
* bind specific keyboard shortcuts that will still work
|
||
* inside a text input field
|
||
*
|
||
* usage:
|
||
* Mousetrap.bindGlobal('ctrl+s', _saveChanges);
|
||
*/
|
||
/* global Mousetrap:true */
|
||
(function(Mousetrap) {
|
||
if (! Mousetrap) {
|
||
return;
|
||
}
|
||
var _globalCallbacks = {};
|
||
var _originalStopCallback = Mousetrap.prototype.stopCallback;
|
||
|
||
Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) {
|
||
var self = this;
|
||
|
||
if (self.paused) {
|
||
return true;
|
||
}
|
||
|
||
if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
|
||
return false;
|
||
}
|
||
|
||
return _originalStopCallback.call(self, e, element, combo);
|
||
};
|
||
|
||
Mousetrap.prototype.bindGlobal = function(keys, callback, action) {
|
||
var self = this;
|
||
self.bind(keys, callback, action);
|
||
|
||
if (keys instanceof Array) {
|
||
for (var i = 0; i < keys.length; i++) {
|
||
_globalCallbacks[keys[i]] = true;
|
||
}
|
||
return;
|
||
}
|
||
|
||
_globalCallbacks[keys] = true;
|
||
};
|
||
|
||
Mousetrap.init();
|
||
}) (typeof Mousetrap !== "undefined" ? Mousetrap : undefined);
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 429:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
__webpack_require__.r(__webpack_exports__);
|
||
|
||
// EXTERNAL MODULE: external {"this":"lodash"}
|
||
var external_this_lodash_ = __webpack_require__(2);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js
|
||
/**
|
||
* External dependencies
|
||
*/
|
||
|
||
/**
|
||
* Given a function mapping a component to an enhanced component and modifier
|
||
* name, returns the enhanced component augmented with a generated displayName.
|
||
*
|
||
* @param {Function} mapComponentToEnhancedComponent Function mapping component
|
||
* to enhanced component.
|
||
* @param {string} modifierName Seed name from which to
|
||
* generated display name.
|
||
*
|
||
* @return {WPComponent} Component class with generated display name assigned.
|
||
*/
|
||
|
||
function createHigherOrderComponent(mapComponentToEnhancedComponent, modifierName) {
|
||
return function (OriginalComponent) {
|
||
var EnhancedComponent = mapComponentToEnhancedComponent(OriginalComponent);
|
||
var _OriginalComponent$di = OriginalComponent.displayName,
|
||
displayName = _OriginalComponent$di === void 0 ? OriginalComponent.name || 'Component' : _OriginalComponent$di;
|
||
EnhancedComponent.displayName = "".concat(Object(external_this_lodash_["upperFirst"])(Object(external_this_lodash_["camelCase"])(modifierName)), "(").concat(displayName, ")");
|
||
return EnhancedComponent;
|
||
};
|
||
}
|
||
|
||
/* harmony default export */ var create_higher_order_component = (createHigherOrderComponent);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js
|
||
/**
|
||
* External dependencies
|
||
*/
|
||
|
||
/**
|
||
* Composes multiple higher-order components into a single higher-order component. Performs right-to-left function
|
||
* composition, where each successive invocation is supplied the return value of the previous.
|
||
*
|
||
* @param {...Function} hocs The HOC functions to invoke.
|
||
*
|
||
* @return {Function} Returns the new composite function.
|
||
*/
|
||
|
||
/* harmony default export */ var compose = (external_this_lodash_["flowRight"]);
|
||
|
||
// EXTERNAL MODULE: external {"this":["wp","element"]}
|
||
var external_this_wp_element_ = __webpack_require__(0);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js
|
||
|
||
|
||
/**
|
||
* Internal dependencies
|
||
*/
|
||
|
||
/**
|
||
* Higher-order component creator, creating a new component which renders if
|
||
* the given condition is satisfied or with the given optional prop name.
|
||
*
|
||
* @param {Function} predicate Function to test condition.
|
||
*
|
||
* @return {Function} Higher-order component.
|
||
*/
|
||
|
||
var if_condition_ifCondition = function ifCondition(predicate) {
|
||
return create_higher_order_component(function (WrappedComponent) {
|
||
return function (props) {
|
||
if (!predicate(props)) {
|
||
return null;
|
||
}
|
||
|
||
return Object(external_this_wp_element_["createElement"])(WrappedComponent, props);
|
||
};
|
||
}, 'ifCondition');
|
||
};
|
||
|
||
/* harmony default export */ var if_condition = (if_condition_ifCondition);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
||
var classCallCheck = __webpack_require__(14);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
|
||
var createClass = __webpack_require__(13);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
|
||
var possibleConstructorReturn = __webpack_require__(15);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
|
||
var getPrototypeOf = __webpack_require__(16);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules
|
||
var inherits = __webpack_require__(17);
|
||
|
||
// EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]}
|
||
var external_this_wp_isShallowEqual_ = __webpack_require__(49);
|
||
var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* Internal dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* Given a component returns the enhanced component augmented with a component
|
||
* only rerendering when its props/state change
|
||
*
|
||
* @param {Function} mapComponentToEnhancedComponent Function mapping component
|
||
* to enhanced component.
|
||
* @param {string} modifierName Seed name from which to
|
||
* generated display name.
|
||
*
|
||
* @return {WPComponent} Component class with generated display name assigned.
|
||
*/
|
||
|
||
var pure = create_higher_order_component(function (Wrapped) {
|
||
if (Wrapped.prototype instanceof external_this_wp_element_["Component"]) {
|
||
return (
|
||
/*#__PURE__*/
|
||
function (_Wrapped) {
|
||
Object(inherits["a" /* default */])(_class, _Wrapped);
|
||
|
||
function _class() {
|
||
Object(classCallCheck["a" /* default */])(this, _class);
|
||
|
||
return Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(_class).apply(this, arguments));
|
||
}
|
||
|
||
Object(createClass["a" /* default */])(_class, [{
|
||
key: "shouldComponentUpdate",
|
||
value: function shouldComponentUpdate(nextProps, nextState) {
|
||
return !external_this_wp_isShallowEqual_default()(nextProps, this.props) || !external_this_wp_isShallowEqual_default()(nextState, this.state);
|
||
}
|
||
}]);
|
||
|
||
return _class;
|
||
}(Wrapped)
|
||
);
|
||
}
|
||
|
||
return (
|
||
/*#__PURE__*/
|
||
function (_Component) {
|
||
Object(inherits["a" /* default */])(_class2, _Component);
|
||
|
||
function _class2() {
|
||
Object(classCallCheck["a" /* default */])(this, _class2);
|
||
|
||
return Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(_class2).apply(this, arguments));
|
||
}
|
||
|
||
Object(createClass["a" /* default */])(_class2, [{
|
||
key: "shouldComponentUpdate",
|
||
value: function shouldComponentUpdate(nextProps) {
|
||
return !external_this_wp_isShallowEqual_default()(nextProps, this.props);
|
||
}
|
||
}, {
|
||
key: "render",
|
||
value: function render() {
|
||
return Object(external_this_wp_element_["createElement"])(Wrapped, this.props);
|
||
}
|
||
}]);
|
||
|
||
return _class2;
|
||
}(external_this_wp_element_["Component"])
|
||
);
|
||
}, 'pure');
|
||
/* harmony default export */ var higher_order_pure = (pure);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
|
||
var esm_extends = __webpack_require__(12);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
|
||
var assertThisInitialized = __webpack_require__(7);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js
|
||
|
||
|
||
|
||
/**
|
||
* External dependencies
|
||
*/
|
||
|
||
/**
|
||
* Class responsible for orchestrating event handling on the global window,
|
||
* binding a single event to be shared across all handling instances, and
|
||
* removing the handler when no instances are listening for the event.
|
||
*/
|
||
|
||
var listener_Listener =
|
||
/*#__PURE__*/
|
||
function () {
|
||
function Listener() {
|
||
Object(classCallCheck["a" /* default */])(this, Listener);
|
||
|
||
this.listeners = {};
|
||
this.handleEvent = this.handleEvent.bind(this);
|
||
}
|
||
|
||
Object(createClass["a" /* default */])(Listener, [{
|
||
key: "add",
|
||
value: function add(eventType, instance) {
|
||
if (!this.listeners[eventType]) {
|
||
// Adding first listener for this type, so bind event.
|
||
window.addEventListener(eventType, this.handleEvent);
|
||
this.listeners[eventType] = [];
|
||
}
|
||
|
||
this.listeners[eventType].push(instance);
|
||
}
|
||
}, {
|
||
key: "remove",
|
||
value: function remove(eventType, instance) {
|
||
this.listeners[eventType] = Object(external_this_lodash_["without"])(this.listeners[eventType], instance);
|
||
|
||
if (!this.listeners[eventType].length) {
|
||
// Removing last listener for this type, so unbind event.
|
||
window.removeEventListener(eventType, this.handleEvent);
|
||
delete this.listeners[eventType];
|
||
}
|
||
}
|
||
}, {
|
||
key: "handleEvent",
|
||
value: function handleEvent(event) {
|
||
Object(external_this_lodash_["forEach"])(this.listeners[event.type], function (instance) {
|
||
instance.handleEvent(event);
|
||
});
|
||
}
|
||
}]);
|
||
|
||
return Listener;
|
||
}();
|
||
|
||
/* harmony default export */ var listener = (listener_Listener);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* External dependencies
|
||
*/
|
||
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* Internal dependencies
|
||
*/
|
||
|
||
|
||
|
||
/**
|
||
* Listener instance responsible for managing document event handling.
|
||
*
|
||
* @type {Listener}
|
||
*/
|
||
|
||
var with_global_events_listener = new listener();
|
||
/**
|
||
* Higher-order component creator which, given an object of DOM event types and
|
||
* values corresponding to a callback function name on the component, will
|
||
* create or update a window event handler to invoke the callback when an event
|
||
* occurs. On behalf of the consuming developer, the higher-order component
|
||
* manages unbinding when the component unmounts, and binding at most a single
|
||
* event handler for the entire application.
|
||
*
|
||
* @param {Object<string,string>} eventTypesToHandlers Object with keys of DOM
|
||
* event type, the value a
|
||
* name of the function on
|
||
* the original component's
|
||
* instance which handles
|
||
* the event.
|
||
*
|
||
* @return {Function} Higher-order component.
|
||
*/
|
||
|
||
function withGlobalEvents(eventTypesToHandlers) {
|
||
return create_higher_order_component(function (WrappedComponent) {
|
||
var Wrapper =
|
||
/*#__PURE__*/
|
||
function (_Component) {
|
||
Object(inherits["a" /* default */])(Wrapper, _Component);
|
||
|
||
function Wrapper() {
|
||
var _this;
|
||
|
||
Object(classCallCheck["a" /* default */])(this, Wrapper);
|
||
|
||
_this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(Wrapper).apply(this, arguments));
|
||
_this.handleEvent = _this.handleEvent.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
||
_this.handleRef = _this.handleRef.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
||
return _this;
|
||
}
|
||
|
||
Object(createClass["a" /* default */])(Wrapper, [{
|
||
key: "componentDidMount",
|
||
value: function componentDidMount() {
|
||
var _this2 = this;
|
||
|
||
Object(external_this_lodash_["forEach"])(eventTypesToHandlers, function (handler, eventType) {
|
||
with_global_events_listener.add(eventType, _this2);
|
||
});
|
||
}
|
||
}, {
|
||
key: "componentWillUnmount",
|
||
value: function componentWillUnmount() {
|
||
var _this3 = this;
|
||
|
||
Object(external_this_lodash_["forEach"])(eventTypesToHandlers, function (handler, eventType) {
|
||
with_global_events_listener.remove(eventType, _this3);
|
||
});
|
||
}
|
||
}, {
|
||
key: "handleEvent",
|
||
value: function handleEvent(event) {
|
||
var handler = eventTypesToHandlers[event.type];
|
||
|
||
if (typeof this.wrappedRef[handler] === 'function') {
|
||
this.wrappedRef[handler](event);
|
||
}
|
||
}
|
||
}, {
|
||
key: "handleRef",
|
||
value: function handleRef(el) {
|
||
this.wrappedRef = el; // Any component using `withGlobalEvents` that is not setting a `ref`
|
||
// will cause `this.props.forwardedRef` to be `null`, so we need this
|
||
// check.
|
||
|
||
if (this.props.forwardedRef) {
|
||
this.props.forwardedRef(el);
|
||
}
|
||
}
|
||
}, {
|
||
key: "render",
|
||
value: function render() {
|
||
return Object(external_this_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, this.props.ownProps, {
|
||
ref: this.handleRef
|
||
}));
|
||
}
|
||
}]);
|
||
|
||
return Wrapper;
|
||
}(external_this_wp_element_["Component"]);
|
||
|
||
return Object(external_this_wp_element_["forwardRef"])(function (props, ref) {
|
||
return Object(external_this_wp_element_["createElement"])(Wrapper, {
|
||
ownProps: props,
|
||
forwardedRef: ref
|
||
});
|
||
});
|
||
}, 'withGlobalEvents');
|
||
}
|
||
|
||
/* harmony default export */ var with_global_events = (withGlobalEvents);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
var instanceMap = new WeakMap();
|
||
/**
|
||
* Creates a new id for a given object.
|
||
*
|
||
* @param {Object} object Object reference to create an id for.
|
||
*/
|
||
|
||
function createId(object) {
|
||
var instances = instanceMap.get(object) || 0;
|
||
instanceMap.set(object, instances + 1);
|
||
return instances;
|
||
}
|
||
/**
|
||
* Provides a unique instance ID.
|
||
*
|
||
* @param {Object} object Object reference to create an id for.
|
||
*/
|
||
|
||
|
||
function useInstanceId(object) {
|
||
return Object(external_this_wp_element_["useMemo"])(function () {
|
||
return createId(object);
|
||
}, [object]);
|
||
}
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js
|
||
|
||
|
||
|
||
/**
|
||
* Internal dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* A Higher Order Component used to be provide a unique instance ID by
|
||
* component.
|
||
*
|
||
* @param {WPComponent} WrappedComponent The wrapped component.
|
||
*
|
||
* @return {WPComponent} Component with an instanceId prop.
|
||
*/
|
||
|
||
/* harmony default export */ var with_instance_id = (create_higher_order_component(function (WrappedComponent) {
|
||
return function (props) {
|
||
var instanceId = useInstanceId(WrappedComponent);
|
||
return Object(external_this_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
|
||
instanceId: instanceId
|
||
}));
|
||
};
|
||
}, 'withInstanceId'));
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* External dependencies
|
||
*/
|
||
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* Internal dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* A higher-order component used to provide and manage delayed function calls
|
||
* that ought to be bound to a component's lifecycle.
|
||
*
|
||
* @param {WPComponent} OriginalComponent Component requiring setTimeout
|
||
*
|
||
* @return {WPComponent} Wrapped component.
|
||
*/
|
||
|
||
var withSafeTimeout = create_higher_order_component(function (OriginalComponent) {
|
||
return (
|
||
/*#__PURE__*/
|
||
function (_Component) {
|
||
Object(inherits["a" /* default */])(WrappedComponent, _Component);
|
||
|
||
function WrappedComponent() {
|
||
var _this;
|
||
|
||
Object(classCallCheck["a" /* default */])(this, WrappedComponent);
|
||
|
||
_this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(WrappedComponent).apply(this, arguments));
|
||
_this.timeouts = [];
|
||
_this.setTimeout = _this.setTimeout.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
||
_this.clearTimeout = _this.clearTimeout.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
||
return _this;
|
||
}
|
||
|
||
Object(createClass["a" /* default */])(WrappedComponent, [{
|
||
key: "componentWillUnmount",
|
||
value: function componentWillUnmount() {
|
||
this.timeouts.forEach(clearTimeout);
|
||
}
|
||
}, {
|
||
key: "setTimeout",
|
||
value: function (_setTimeout) {
|
||
function setTimeout(_x, _x2) {
|
||
return _setTimeout.apply(this, arguments);
|
||
}
|
||
|
||
setTimeout.toString = function () {
|
||
return _setTimeout.toString();
|
||
};
|
||
|
||
return setTimeout;
|
||
}(function (fn, delay) {
|
||
var _this2 = this;
|
||
|
||
var id = setTimeout(function () {
|
||
fn();
|
||
|
||
_this2.clearTimeout(id);
|
||
}, delay);
|
||
this.timeouts.push(id);
|
||
return id;
|
||
})
|
||
}, {
|
||
key: "clearTimeout",
|
||
value: function (_clearTimeout) {
|
||
function clearTimeout(_x3) {
|
||
return _clearTimeout.apply(this, arguments);
|
||
}
|
||
|
||
clearTimeout.toString = function () {
|
||
return _clearTimeout.toString();
|
||
};
|
||
|
||
return clearTimeout;
|
||
}(function (id) {
|
||
clearTimeout(id);
|
||
this.timeouts = Object(external_this_lodash_["without"])(this.timeouts, id);
|
||
})
|
||
}, {
|
||
key: "render",
|
||
value: function render() {
|
||
return Object(external_this_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, this.props, {
|
||
setTimeout: this.setTimeout,
|
||
clearTimeout: this.clearTimeout
|
||
}));
|
||
}
|
||
}]);
|
||
|
||
return WrappedComponent;
|
||
}(external_this_wp_element_["Component"])
|
||
);
|
||
}, 'withSafeTimeout');
|
||
/* harmony default export */ var with_safe_timeout = (withSafeTimeout);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
/**
|
||
* Internal dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* A Higher Order Component used to provide and manage internal component state
|
||
* via props.
|
||
*
|
||
* @param {?Object} initialState Optional initial state of the component.
|
||
*
|
||
* @return {WPComponent} Wrapped component.
|
||
*/
|
||
|
||
function withState() {
|
||
var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||
return create_higher_order_component(function (OriginalComponent) {
|
||
return (
|
||
/*#__PURE__*/
|
||
function (_Component) {
|
||
Object(inherits["a" /* default */])(WrappedComponent, _Component);
|
||
|
||
function WrappedComponent() {
|
||
var _this;
|
||
|
||
Object(classCallCheck["a" /* default */])(this, WrappedComponent);
|
||
|
||
_this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(WrappedComponent).apply(this, arguments));
|
||
_this.setState = _this.setState.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
||
_this.state = initialState;
|
||
return _this;
|
||
}
|
||
|
||
Object(createClass["a" /* default */])(WrappedComponent, [{
|
||
key: "render",
|
||
value: function render() {
|
||
return Object(external_this_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, this.props, this.state, {
|
||
setState: this.setState
|
||
}));
|
||
}
|
||
}]);
|
||
|
||
return WrappedComponent;
|
||
}(external_this_wp_element_["Component"])
|
||
);
|
||
}, 'withState');
|
||
}
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
|
||
var slicedToArray = __webpack_require__(20);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js
|
||
|
||
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_this_wp_element_["useLayoutEffect"] : external_this_wp_element_["useEffect"];
|
||
function useDragging(_ref) {
|
||
var onDragStart = _ref.onDragStart,
|
||
onDragMove = _ref.onDragMove,
|
||
onDragEnd = _ref.onDragEnd;
|
||
|
||
var _useState = Object(external_this_wp_element_["useState"])(false),
|
||
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
|
||
isDragging = _useState2[0],
|
||
setIsDragging = _useState2[1];
|
||
|
||
var eventsRef = Object(external_this_wp_element_["useRef"])({
|
||
onDragStart: onDragStart,
|
||
onDragMove: onDragMove,
|
||
onDragEnd: onDragEnd
|
||
});
|
||
useIsomorphicLayoutEffect(function () {
|
||
eventsRef.current.onDragStart = onDragStart;
|
||
eventsRef.current.onDragMove = onDragMove;
|
||
eventsRef.current.onDragEnd = onDragEnd;
|
||
}, [onDragStart, onDragMove, onDragEnd]);
|
||
var onMouseMove = Object(external_this_wp_element_["useCallback"])(function () {
|
||
var _eventsRef$current;
|
||
|
||
return eventsRef.current.onDragMove && (_eventsRef$current = eventsRef.current).onDragMove.apply(_eventsRef$current, arguments);
|
||
}, []);
|
||
var endDrag = Object(external_this_wp_element_["useCallback"])(function () {
|
||
if (eventsRef.current.onDragEnd) {
|
||
var _eventsRef$current2;
|
||
|
||
(_eventsRef$current2 = eventsRef.current).onDragEnd.apply(_eventsRef$current2, arguments);
|
||
}
|
||
|
||
document.removeEventListener('mousemove', onMouseMove);
|
||
document.removeEventListener('mouseup', endDrag);
|
||
setIsDragging(false);
|
||
}, []);
|
||
var startDrag = Object(external_this_wp_element_["useCallback"])(function () {
|
||
if (eventsRef.current.onDragStart) {
|
||
var _eventsRef$current3;
|
||
|
||
(_eventsRef$current3 = eventsRef.current).onDragStart.apply(_eventsRef$current3, arguments);
|
||
}
|
||
|
||
document.addEventListener('mousemove', onMouseMove);
|
||
document.addEventListener('mouseup', endDrag);
|
||
setIsDragging(true);
|
||
}, []); // Remove the global events when unmounting if needed.
|
||
|
||
Object(external_this_wp_element_["useEffect"])(function () {
|
||
return function () {
|
||
if (isDragging) {
|
||
document.removeEventListener('mousemove', onMouseMove);
|
||
document.removeEventListener('mouseup', endDrag);
|
||
}
|
||
};
|
||
}, [isDragging]);
|
||
return {
|
||
startDrag: startDrag,
|
||
endDrag: endDrag,
|
||
isDragging: isDragging
|
||
};
|
||
}
|
||
|
||
// EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js
|
||
var mousetrap_mousetrap = __webpack_require__(269);
|
||
var mousetrap_default = /*#__PURE__*/__webpack_require__.n(mousetrap_mousetrap);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
|
||
var mousetrap_global_bind = __webpack_require__(394);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js
|
||
/**
|
||
* External dependencies
|
||
*/
|
||
|
||
|
||
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* A block selection object.
|
||
*
|
||
* @typedef {Object} WPKeyboardShortcutConfig
|
||
*
|
||
* @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.
|
||
* @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.
|
||
* @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.
|
||
* @property {Object} [target] React reference to the DOM element used to catch the keyboard event.
|
||
*/
|
||
|
||
/**
|
||
* Return true if platform is MacOS.
|
||
*
|
||
* @param {Object} _window window object by default; used for DI testing.
|
||
*
|
||
* @return {boolean} True if MacOS; false otherwise.
|
||
*/
|
||
|
||
function isAppleOS() {
|
||
var _window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
|
||
|
||
var platform = _window.navigator.platform;
|
||
return platform.indexOf('Mac') !== -1 || Object(external_this_lodash_["includes"])(['iPad', 'iPhone'], platform);
|
||
}
|
||
/**
|
||
* Attach a keyboard shortcut handler.
|
||
*
|
||
* @param {string[]|string} shortcuts Keyboard Shortcuts.
|
||
* @param {Function} callback Shortcut callback.
|
||
* @param {WPKeyboardShortcutConfig} options Shortcut options.
|
||
*/
|
||
|
||
|
||
function useKeyboardShortcut(shortcuts, callback) {
|
||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
||
_ref$bindGlobal = _ref.bindGlobal,
|
||
bindGlobal = _ref$bindGlobal === void 0 ? false : _ref$bindGlobal,
|
||
_ref$eventName = _ref.eventName,
|
||
eventName = _ref$eventName === void 0 ? 'keydown' : _ref$eventName,
|
||
_ref$isDisabled = _ref.isDisabled,
|
||
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
||
target = _ref.target;
|
||
|
||
Object(external_this_wp_element_["useEffect"])(function () {
|
||
if (isDisabled) {
|
||
return;
|
||
}
|
||
|
||
var mousetrap = new mousetrap_default.a(target ? target.current : document);
|
||
Object(external_this_lodash_["castArray"])(shortcuts).forEach(function (shortcut) {
|
||
var keys = shortcut.split('+'); // Determines whether a key is a modifier by the length of the string.
|
||
// E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that
|
||
// the modifiers are Shift and Cmd because they're not a single character.
|
||
|
||
var modifiers = new Set(keys.filter(function (value) {
|
||
return value.length > 1;
|
||
}));
|
||
var hasAlt = modifiers.has('alt');
|
||
var hasShift = modifiers.has('shift'); // This should be better moved to the shortcut registration instead.
|
||
|
||
if (isAppleOS() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) {
|
||
throw new Error("Cannot bind ".concat(shortcut, ". Alt and Shift+Alt modifiers are reserved for character input."));
|
||
}
|
||
|
||
var bindFn = bindGlobal ? 'bindGlobal' : 'bind';
|
||
mousetrap[bindFn](shortcut, callback, eventName);
|
||
});
|
||
return function () {
|
||
mousetrap.reset();
|
||
};
|
||
}, [shortcuts, bindGlobal, eventName, callback, target, isDisabled]);
|
||
}
|
||
|
||
/* harmony default export */ var use_keyboard_shortcut = (useKeyboardShortcut);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js
|
||
var use_media_query = __webpack_require__(110);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js
|
||
var use_reduced_motion = __webpack_require__(250);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js
|
||
/**
|
||
* WordPress dependencies
|
||
*/
|
||
|
||
/**
|
||
* Internal dependencies
|
||
*/
|
||
|
||
|
||
/**
|
||
* @typedef {"huge"|"wide"|"large"|"medium"|"small"|"mobile"} WPBreakpoint
|
||
*/
|
||
|
||
/**
|
||
* Hash of breakpoint names with pixel width at which it becomes effective.
|
||
*
|
||
* @see _breakpoints.scss
|
||
*
|
||
* @type {Object<WPBreakpoint,number>}
|
||
*/
|
||
|
||
var BREAKPOINTS = {
|
||
huge: 1440,
|
||
wide: 1280,
|
||
large: 960,
|
||
medium: 782,
|
||
small: 600,
|
||
mobile: 480
|
||
};
|
||
/**
|
||
* @typedef {">="|"<"} WPViewportOperator
|
||
*/
|
||
|
||
/**
|
||
* Object mapping media query operators to the condition to be used.
|
||
*
|
||
* @type {Object<WPViewportOperator,string>}
|
||
*/
|
||
|
||
var CONDITIONS = {
|
||
'>=': 'min-width',
|
||
'<': 'max-width'
|
||
};
|
||
/**
|
||
* Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.
|
||
*
|
||
* @type {Object<WPViewportOperator,Function>}
|
||
*/
|
||
|
||
var OPERATOR_EVALUATORS = {
|
||
'>=': function _(breakpointValue, width) {
|
||
return width >= breakpointValue;
|
||
},
|
||
'<': function _(breakpointValue, width) {
|
||
return width < breakpointValue;
|
||
}
|
||
};
|
||
var ViewportMatchWidthContext = Object(external_this_wp_element_["createContext"])(null);
|
||
/**
|
||
* Returns true if the viewport matches the given query, or false otherwise.
|
||
*
|
||
* @param {WPBreakpoint} breakpoint Breakpoint size name.
|
||
* @param {WPViewportOperator} [operator=">="] Viewport operator.
|
||
*
|
||
* @example
|
||
*
|
||
* ```js
|
||
* useViewportMatch( 'huge', <' );
|
||
* useViewportMatch( 'medium' );
|
||
* ```
|
||
*
|
||
* @return {boolean} Whether viewport matches query.
|
||
*/
|
||
|
||
var use_viewport_match_useViewportMatch = function useViewportMatch(breakpoint) {
|
||
var operator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '>=';
|
||
var simulatedWidth = Object(external_this_wp_element_["useContext"])(ViewportMatchWidthContext);
|
||
var mediaQuery = !simulatedWidth && "(".concat(CONDITIONS[operator], ": ").concat(BREAKPOINTS[breakpoint], "px)");
|
||
var mediaQueryResult = Object(use_media_query["a" /* default */])(mediaQuery);
|
||
|
||
if (simulatedWidth) {
|
||
return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth);
|
||
}
|
||
|
||
return mediaQueryResult;
|
||
};
|
||
|
||
use_viewport_match_useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider;
|
||
/* harmony default export */ var use_viewport_match = (use_viewport_match_useViewportMatch);
|
||
|
||
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js
|
||
/* concated harmony reexport createHigherOrderComponent */__webpack_require__.d(__webpack_exports__, "createHigherOrderComponent", function() { return create_higher_order_component; });
|
||
/* concated harmony reexport compose */__webpack_require__.d(__webpack_exports__, "compose", function() { return compose; });
|
||
/* concated harmony reexport ifCondition */__webpack_require__.d(__webpack_exports__, "ifCondition", function() { return if_condition; });
|
||
/* concated harmony reexport pure */__webpack_require__.d(__webpack_exports__, "pure", function() { return higher_order_pure; });
|
||
/* concated harmony reexport withGlobalEvents */__webpack_require__.d(__webpack_exports__, "withGlobalEvents", function() { return with_global_events; });
|
||
/* concated harmony reexport withInstanceId */__webpack_require__.d(__webpack_exports__, "withInstanceId", function() { return with_instance_id; });
|
||
/* concated harmony reexport withSafeTimeout */__webpack_require__.d(__webpack_exports__, "withSafeTimeout", function() { return with_safe_timeout; });
|
||
/* concated harmony reexport withState */__webpack_require__.d(__webpack_exports__, "withState", function() { return withState; });
|
||
/* concated harmony reexport __experimentalUseDragging */__webpack_require__.d(__webpack_exports__, "__experimentalUseDragging", function() { return useDragging; });
|
||
/* concated harmony reexport useInstanceId */__webpack_require__.d(__webpack_exports__, "useInstanceId", function() { return useInstanceId; });
|
||
/* concated harmony reexport useKeyboardShortcut */__webpack_require__.d(__webpack_exports__, "useKeyboardShortcut", function() { return use_keyboard_shortcut; });
|
||
/* concated harmony reexport useMediaQuery */__webpack_require__.d(__webpack_exports__, "useMediaQuery", function() { return use_media_query["a" /* default */]; });
|
||
/* concated harmony reexport useReducedMotion */__webpack_require__.d(__webpack_exports__, "useReducedMotion", function() { return use_reduced_motion["a" /* default */]; });
|
||
/* concated harmony reexport useViewportMatch */__webpack_require__.d(__webpack_exports__, "useViewportMatch", function() { return use_viewport_match; });
|
||
// Utils
|
||
// Compose helper (aliased flowRight from Lodash)
|
||
|
||
// Higher-order components
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// Hooks
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/***/ }),
|
||
|
||
/***/ 49:
|
||
/***/ (function(module, exports) {
|
||
|
||
(function() { module.exports = this["wp"]["isShallowEqual"]; }());
|
||
|
||
/***/ }),
|
||
|
||
/***/ 7:
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
|
||
function _assertThisInitialized(self) {
|
||
if (self === void 0) {
|
||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||
}
|
||
|
||
return self;
|
||
}
|
||
|
||
/***/ })
|
||
|
||
/******/ }); |