[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 this["wp"] = this["wp"] || {}; this["wp"]["compose"] = 2 /******/ (function(modules) { // webpackBootstrap 3 /******/ // The module cache 4 /******/ var installedModules = {}; 5 /******/ 6 /******/ // The require function 7 /******/ function __webpack_require__(moduleId) { 8 /******/ 9 /******/ // Check if module is in cache 10 /******/ if(installedModules[moduleId]) { 11 /******/ return installedModules[moduleId].exports; 12 /******/ } 13 /******/ // Create a new module (and put it into the cache) 14 /******/ var module = installedModules[moduleId] = { 15 /******/ i: moduleId, 16 /******/ l: false, 17 /******/ exports: {} 18 /******/ }; 19 /******/ 20 /******/ // Execute the module function 21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 22 /******/ 23 /******/ // Flag the module as loaded 24 /******/ module.l = true; 25 /******/ 26 /******/ // Return the exports of the module 27 /******/ return module.exports; 28 /******/ } 29 /******/ 30 /******/ 31 /******/ // expose the modules object (__webpack_modules__) 32 /******/ __webpack_require__.m = modules; 33 /******/ 34 /******/ // expose the module cache 35 /******/ __webpack_require__.c = installedModules; 36 /******/ 37 /******/ // define getter function for harmony exports 38 /******/ __webpack_require__.d = function(exports, name, getter) { 39 /******/ if(!__webpack_require__.o(exports, name)) { 40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 41 /******/ } 42 /******/ }; 43 /******/ 44 /******/ // define __esModule on exports 45 /******/ __webpack_require__.r = function(exports) { 46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 48 /******/ } 49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 50 /******/ }; 51 /******/ 52 /******/ // create a fake namespace object 53 /******/ // mode & 1: value is a module id, require it 54 /******/ // mode & 2: merge all properties of value into the ns 55 /******/ // mode & 4: return value when already ns object 56 /******/ // mode & 8|1: behave like require 57 /******/ __webpack_require__.t = function(value, mode) { 58 /******/ if(mode & 1) value = __webpack_require__(value); 59 /******/ if(mode & 8) return value; 60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 61 /******/ var ns = Object.create(null); 62 /******/ __webpack_require__.r(ns); 63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 65 /******/ return ns; 66 /******/ }; 67 /******/ 68 /******/ // getDefaultExport function for compatibility with non-harmony modules 69 /******/ __webpack_require__.n = function(module) { 70 /******/ var getter = module && module.__esModule ? 71 /******/ function getDefault() { return module['default']; } : 72 /******/ function getModuleExports() { return module; }; 73 /******/ __webpack_require__.d(getter, 'a', getter); 74 /******/ return getter; 75 /******/ }; 76 /******/ 77 /******/ // Object.prototype.hasOwnProperty.call 78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 79 /******/ 80 /******/ // __webpack_public_path__ 81 /******/ __webpack_require__.p = ""; 82 /******/ 83 /******/ 84 /******/ // Load entry module and return exports 85 /******/ return __webpack_require__(__webpack_require__.s = 447); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ 0: 91 /***/ (function(module, exports) { 92 93 (function() { module.exports = window["wp"]["element"]; }()); 94 95 /***/ }), 96 97 /***/ 11: 98 /***/ (function(module, __webpack_exports__, __webpack_require__) { 99 100 "use strict"; 101 102 // EXPORTS 103 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; }); 104 105 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js 106 var arrayWithHoles = __webpack_require__(38); 107 108 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js 109 function _iterableToArrayLimit(arr, i) { 110 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 111 var _arr = []; 112 var _n = true; 113 var _d = false; 114 var _e = undefined; 115 116 try { 117 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 118 _arr.push(_s.value); 119 120 if (i && _arr.length === i) break; 121 } 122 } catch (err) { 123 _d = true; 124 _e = err; 125 } finally { 126 try { 127 if (!_n && _i["return"] != null) _i["return"](); 128 } finally { 129 if (_d) throw _e; 130 } 131 } 132 133 return _arr; 134 } 135 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js 136 var unsupportedIterableToArray = __webpack_require__(32); 137 138 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js 139 var nonIterableRest = __webpack_require__(39); 140 141 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js 142 143 144 145 146 function _slicedToArray(arr, i) { 147 return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])(); 148 } 149 150 /***/ }), 151 152 /***/ 122: 153 /***/ (function(module, __webpack_exports__, __webpack_require__) { 154 155 "use strict"; 156 /* unused harmony export useCallback */ 157 /* unused harmony export useCallbackOne */ 158 /* unused harmony export useMemo */ 159 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useMemoOne; }); 160 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14); 161 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); 162 163 164 function areInputsEqual(newInputs, lastInputs) { 165 if (newInputs.length !== lastInputs.length) { 166 return false; 167 } 168 169 for (var i = 0; i < newInputs.length; i++) { 170 if (newInputs[i] !== lastInputs[i]) { 171 return false; 172 } 173 } 174 175 return true; 176 } 177 178 function useMemoOne(getResult, inputs) { 179 var initial = Object(react__WEBPACK_IMPORTED_MODULE_0__["useState"])(function () { 180 return { 181 inputs: inputs, 182 result: getResult() 183 }; 184 })[0]; 185 var isFirstRun = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(true); 186 var committed = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(initial); 187 var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); 188 var cache = useCache ? committed.current : { 189 inputs: inputs, 190 result: getResult() 191 }; 192 Object(react__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () { 193 isFirstRun.current = false; 194 committed.current = cache; 195 }, [cache]); 196 return cache.result; 197 } 198 function useCallbackOne(callback, inputs) { 199 return useMemoOne(function () { 200 return callback; 201 }, inputs); 202 } 203 var useMemo = useMemoOne; 204 var useCallback = useCallbackOne; 205 206 207 208 209 /***/ }), 210 211 /***/ 14: 212 /***/ (function(module, exports) { 213 214 (function() { module.exports = window["React"]; }()); 215 216 /***/ }), 217 218 /***/ 145: 219 /***/ (function(module, exports, __webpack_require__) { 220 221 var e=__webpack_require__(14),n={display:"block",opacity:0,position:"absolute",top:0,left:0,height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",zIndex:-1},t=function(t){var r=t.onResize,u=e.useRef();return function(n,t){var r=function(){return n.current&&n.current.contentDocument&&n.current.contentDocument.defaultView};function u(){t();var e=r();e&&e.addEventListener("resize",t)}e.useEffect((function(){return r()?u():n.current&&n.current.addEventListener&&n.current.addEventListener("load",u),function(){var e=r();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("resize",t)}}),[])}(u,(function(){return r(u)})),e.createElement("iframe",{style:n,src:"about:blank",ref:u,"aria-hidden":!0,tabIndex:-1,frameBorder:0})},r=function(e){return{width:null!=e?e.offsetWidth:null,height:null!=e?e.offsetHeight:null}};module.exports=function(n){void 0===n&&(n=r);var u=e.useState(n(null)),o=u[0],i=u[1],c=e.useCallback((function(e){return i(n(e.current))}),[n]);return[e.useMemo((function(){return e.createElement(t,{onResize:c})}),[c]),o]}; 222 223 224 /***/ }), 225 226 /***/ 146: 227 /***/ (function(module, exports) { 228 229 (function() { module.exports = window["wp"]["priorityQueue"]; }()); 230 231 /***/ }), 232 233 /***/ 15: 234 /***/ (function(module, __webpack_exports__, __webpack_require__) { 235 236 "use strict"; 237 238 // EXPORTS 239 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; }); 240 241 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js 242 var arrayLikeToArray = __webpack_require__(24); 243 244 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js 245 246 function _arrayWithoutHoles(arr) { 247 if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr); 248 } 249 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js 250 var iterableToArray = __webpack_require__(37); 251 252 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js 253 var unsupportedIterableToArray = __webpack_require__(32); 254 255 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js 256 function _nonIterableSpread() { 257 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 258 } 259 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js 260 261 262 263 264 function _toConsumableArray(arr) { 265 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread(); 266 } 267 268 /***/ }), 269 270 /***/ 16: 271 /***/ (function(module, exports) { 272 273 (function() { module.exports = window["wp"]["keycodes"]; }()); 274 275 /***/ }), 276 277 /***/ 18: 278 /***/ (function(module, __webpack_exports__, __webpack_require__) { 279 280 "use strict"; 281 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; }); 282 function _assertThisInitialized(self) { 283 if (self === void 0) { 284 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 285 } 286 287 return self; 288 } 289 290 /***/ }), 291 292 /***/ 19: 293 /***/ (function(module, __webpack_exports__, __webpack_require__) { 294 295 "use strict"; 296 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; }); 297 function _getPrototypeOf(o) { 298 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 299 return o.__proto__ || Object.getPrototypeOf(o); 300 }; 301 return _getPrototypeOf(o); 302 } 303 304 /***/ }), 305 306 /***/ 2: 307 /***/ (function(module, exports) { 308 309 (function() { module.exports = window["lodash"]; }()); 310 311 /***/ }), 312 313 /***/ 24: 314 /***/ (function(module, __webpack_exports__, __webpack_require__) { 315 316 "use strict"; 317 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; }); 318 function _arrayLikeToArray(arr, len) { 319 if (len == null || len > arr.length) len = arr.length; 320 321 for (var i = 0, arr2 = new Array(len); i < len; i++) { 322 arr2[i] = arr[i]; 323 } 324 325 return arr2; 326 } 327 328 /***/ }), 329 330 /***/ 25: 331 /***/ (function(module, __webpack_exports__, __webpack_require__) { 332 333 "use strict"; 334 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); 335 function _classCallCheck(instance, Constructor) { 336 if (!(instance instanceof Constructor)) { 337 throw new TypeError("Cannot call a class as a function"); 338 } 339 } 340 341 /***/ }), 342 343 /***/ 26: 344 /***/ (function(module, __webpack_exports__, __webpack_require__) { 345 346 "use strict"; 347 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); 348 function _defineProperties(target, props) { 349 for (var i = 0; i < props.length; i++) { 350 var descriptor = props[i]; 351 descriptor.enumerable = descriptor.enumerable || false; 352 descriptor.configurable = true; 353 if ("value" in descriptor) descriptor.writable = true; 354 Object.defineProperty(target, descriptor.key, descriptor); 355 } 356 } 357 358 function _createClass(Constructor, protoProps, staticProps) { 359 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 360 if (staticProps) _defineProperties(Constructor, staticProps); 361 return Constructor; 362 } 363 364 /***/ }), 365 366 /***/ 27: 367 /***/ (function(module, exports) { 368 369 (function() { module.exports = window["wp"]["dom"]; }()); 370 371 /***/ }), 372 373 /***/ 276: 374 /***/ (function(module, exports, __webpack_require__) { 375 376 /*! 377 * clipboard.js v2.0.6 378 * https://clipboardjs.com/ 379 * 380 * Licensed MIT © Zeno Rocha 381 */ 382 (function webpackUniversalModuleDefinition(root, factory) { 383 if(true) 384 module.exports = factory(); 385 else {} 386 })(this, function() { 387 return /******/ (function(modules) { // webpackBootstrap 388 /******/ // The module cache 389 /******/ var installedModules = {}; 390 /******/ 391 /******/ // The require function 392 /******/ function __webpack_require__(moduleId) { 393 /******/ 394 /******/ // Check if module is in cache 395 /******/ if(installedModules[moduleId]) { 396 /******/ return installedModules[moduleId].exports; 397 /******/ } 398 /******/ // Create a new module (and put it into the cache) 399 /******/ var module = installedModules[moduleId] = { 400 /******/ i: moduleId, 401 /******/ l: false, 402 /******/ exports: {} 403 /******/ }; 404 /******/ 405 /******/ // Execute the module function 406 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 407 /******/ 408 /******/ // Flag the module as loaded 409 /******/ module.l = true; 410 /******/ 411 /******/ // Return the exports of the module 412 /******/ return module.exports; 413 /******/ } 414 /******/ 415 /******/ 416 /******/ // expose the modules object (__webpack_modules__) 417 /******/ __webpack_require__.m = modules; 418 /******/ 419 /******/ // expose the module cache 420 /******/ __webpack_require__.c = installedModules; 421 /******/ 422 /******/ // define getter function for harmony exports 423 /******/ __webpack_require__.d = function(exports, name, getter) { 424 /******/ if(!__webpack_require__.o(exports, name)) { 425 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 426 /******/ } 427 /******/ }; 428 /******/ 429 /******/ // define __esModule on exports 430 /******/ __webpack_require__.r = function(exports) { 431 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 432 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 433 /******/ } 434 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 435 /******/ }; 436 /******/ 437 /******/ // create a fake namespace object 438 /******/ // mode & 1: value is a module id, require it 439 /******/ // mode & 2: merge all properties of value into the ns 440 /******/ // mode & 4: return value when already ns object 441 /******/ // mode & 8|1: behave like require 442 /******/ __webpack_require__.t = function(value, mode) { 443 /******/ if(mode & 1) value = __webpack_require__(value); 444 /******/ if(mode & 8) return value; 445 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 446 /******/ var ns = Object.create(null); 447 /******/ __webpack_require__.r(ns); 448 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 449 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 450 /******/ return ns; 451 /******/ }; 452 /******/ 453 /******/ // getDefaultExport function for compatibility with non-harmony modules 454 /******/ __webpack_require__.n = function(module) { 455 /******/ var getter = module && module.__esModule ? 456 /******/ function getDefault() { return module['default']; } : 457 /******/ function getModuleExports() { return module; }; 458 /******/ __webpack_require__.d(getter, 'a', getter); 459 /******/ return getter; 460 /******/ }; 461 /******/ 462 /******/ // Object.prototype.hasOwnProperty.call 463 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 464 /******/ 465 /******/ // __webpack_public_path__ 466 /******/ __webpack_require__.p = ""; 467 /******/ 468 /******/ 469 /******/ // Load entry module and return exports 470 /******/ return __webpack_require__(__webpack_require__.s = 6); 471 /******/ }) 472 /************************************************************************/ 473 /******/ ([ 474 /* 0 */ 475 /***/ (function(module, exports) { 476 477 function select(element) { 478 var selectedText; 479 480 if (element.nodeName === 'SELECT') { 481 element.focus(); 482 483 selectedText = element.value; 484 } 485 else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { 486 var isReadOnly = element.hasAttribute('readonly'); 487 488 if (!isReadOnly) { 489 element.setAttribute('readonly', ''); 490 } 491 492 element.select(); 493 element.setSelectionRange(0, element.value.length); 494 495 if (!isReadOnly) { 496 element.removeAttribute('readonly'); 497 } 498 499 selectedText = element.value; 500 } 501 else { 502 if (element.hasAttribute('contenteditable')) { 503 element.focus(); 504 } 505 506 var selection = window.getSelection(); 507 var range = document.createRange(); 508 509 range.selectNodeContents(element); 510 selection.removeAllRanges(); 511 selection.addRange(range); 512 513 selectedText = selection.toString(); 514 } 515 516 return selectedText; 517 } 518 519 module.exports = select; 520 521 522 /***/ }), 523 /* 1 */ 524 /***/ (function(module, exports) { 525 526 function E () { 527 // Keep this empty so it's easier to inherit from 528 // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) 529 } 530 531 E.prototype = { 532 on: function (name, callback, ctx) { 533 var e = this.e || (this.e = {}); 534 535 (e[name] || (e[name] = [])).push({ 536 fn: callback, 537 ctx: ctx 538 }); 539 540 return this; 541 }, 542 543 once: function (name, callback, ctx) { 544 var self = this; 545 function listener () { 546 self.off(name, listener); 547 callback.apply(ctx, arguments); 548 }; 549 550 listener._ = callback 551 return this.on(name, listener, ctx); 552 }, 553 554 emit: function (name) { 555 var data = [].slice.call(arguments, 1); 556 var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); 557 var i = 0; 558 var len = evtArr.length; 559 560 for (i; i < len; i++) { 561 evtArr[i].fn.apply(evtArr[i].ctx, data); 562 } 563 564 return this; 565 }, 566 567 off: function (name, callback) { 568 var e = this.e || (this.e = {}); 569 var evts = e[name]; 570 var liveEvents = []; 571 572 if (evts && callback) { 573 for (var i = 0, len = evts.length; i < len; i++) { 574 if (evts[i].fn !== callback && evts[i].fn._ !== callback) 575 liveEvents.push(evts[i]); 576 } 577 } 578 579 // Remove event from queue to prevent memory leak 580 // Suggested by https://github.com/lazd 581 // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 582 583 (liveEvents.length) 584 ? e[name] = liveEvents 585 : delete e[name]; 586 587 return this; 588 } 589 }; 590 591 module.exports = E; 592 module.exports.TinyEmitter = E; 593 594 595 /***/ }), 596 /* 2 */ 597 /***/ (function(module, exports, __webpack_require__) { 598 599 var is = __webpack_require__(3); 600 var delegate = __webpack_require__(4); 601 602 /** 603 * Validates all params and calls the right 604 * listener function based on its target type. 605 * 606 * @param {String|HTMLElement|HTMLCollection|NodeList} target 607 * @param {String} type 608 * @param {Function} callback 609 * @return {Object} 610 */ 611 function listen(target, type, callback) { 612 if (!target && !type && !callback) { 613 throw new Error('Missing required arguments'); 614 } 615 616 if (!is.string(type)) { 617 throw new TypeError('Second argument must be a String'); 618 } 619 620 if (!is.fn(callback)) { 621 throw new TypeError('Third argument must be a Function'); 622 } 623 624 if (is.node(target)) { 625 return listenNode(target, type, callback); 626 } 627 else if (is.nodeList(target)) { 628 return listenNodeList(target, type, callback); 629 } 630 else if (is.string(target)) { 631 return listenSelector(target, type, callback); 632 } 633 else { 634 throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); 635 } 636 } 637 638 /** 639 * Adds an event listener to a HTML element 640 * and returns a remove listener function. 641 * 642 * @param {HTMLElement} node 643 * @param {String} type 644 * @param {Function} callback 645 * @return {Object} 646 */ 647 function listenNode(node, type, callback) { 648 node.addEventListener(type, callback); 649 650 return { 651 destroy: function() { 652 node.removeEventListener(type, callback); 653 } 654 } 655 } 656 657 /** 658 * Add an event listener to a list of HTML elements 659 * and returns a remove listener function. 660 * 661 * @param {NodeList|HTMLCollection} nodeList 662 * @param {String} type 663 * @param {Function} callback 664 * @return {Object} 665 */ 666 function listenNodeList(nodeList, type, callback) { 667 Array.prototype.forEach.call(nodeList, function(node) { 668 node.addEventListener(type, callback); 669 }); 670 671 return { 672 destroy: function() { 673 Array.prototype.forEach.call(nodeList, function(node) { 674 node.removeEventListener(type, callback); 675 }); 676 } 677 } 678 } 679 680 /** 681 * Add an event listener to a selector 682 * and returns a remove listener function. 683 * 684 * @param {String} selector 685 * @param {String} type 686 * @param {Function} callback 687 * @return {Object} 688 */ 689 function listenSelector(selector, type, callback) { 690 return delegate(document.body, selector, type, callback); 691 } 692 693 module.exports = listen; 694 695 696 /***/ }), 697 /* 3 */ 698 /***/ (function(module, exports) { 699 700 /** 701 * Check if argument is a HTML element. 702 * 703 * @param {Object} value 704 * @return {Boolean} 705 */ 706 exports.node = function(value) { 707 return value !== undefined 708 && value instanceof HTMLElement 709 && value.nodeType === 1; 710 }; 711 712 /** 713 * Check if argument is a list of HTML elements. 714 * 715 * @param {Object} value 716 * @return {Boolean} 717 */ 718 exports.nodeList = function(value) { 719 var type = Object.prototype.toString.call(value); 720 721 return value !== undefined 722 && (type === '[object NodeList]' || type === '[object HTMLCollection]') 723 && ('length' in value) 724 && (value.length === 0 || exports.node(value[0])); 725 }; 726 727 /** 728 * Check if argument is a string. 729 * 730 * @param {Object} value 731 * @return {Boolean} 732 */ 733 exports.string = function(value) { 734 return typeof value === 'string' 735 || value instanceof String; 736 }; 737 738 /** 739 * Check if argument is a function. 740 * 741 * @param {Object} value 742 * @return {Boolean} 743 */ 744 exports.fn = function(value) { 745 var type = Object.prototype.toString.call(value); 746 747 return type === '[object Function]'; 748 }; 749 750 751 /***/ }), 752 /* 4 */ 753 /***/ (function(module, exports, __webpack_require__) { 754 755 var closest = __webpack_require__(5); 756 757 /** 758 * Delegates event to a selector. 759 * 760 * @param {Element} element 761 * @param {String} selector 762 * @param {String} type 763 * @param {Function} callback 764 * @param {Boolean} useCapture 765 * @return {Object} 766 */ 767 function _delegate(element, selector, type, callback, useCapture) { 768 var listenerFn = listener.apply(this, arguments); 769 770 element.addEventListener(type, listenerFn, useCapture); 771 772 return { 773 destroy: function() { 774 element.removeEventListener(type, listenerFn, useCapture); 775 } 776 } 777 } 778 779 /** 780 * Delegates event to a selector. 781 * 782 * @param {Element|String|Array} [elements] 783 * @param {String} selector 784 * @param {String} type 785 * @param {Function} callback 786 * @param {Boolean} useCapture 787 * @return {Object} 788 */ 789 function delegate(elements, selector, type, callback, useCapture) { 790 // Handle the regular Element usage 791 if (typeof elements.addEventListener === 'function') { 792 return _delegate.apply(null, arguments); 793 } 794 795 // Handle Element-less usage, it defaults to global delegation 796 if (typeof type === 'function') { 797 // Use `document` as the first parameter, then apply arguments 798 // This is a short way to .unshift `arguments` without running into deoptimizations 799 return _delegate.bind(null, document).apply(null, arguments); 800 } 801 802 // Handle Selector-based usage 803 if (typeof elements === 'string') { 804 elements = document.querySelectorAll(elements); 805 } 806 807 // Handle Array-like based usage 808 return Array.prototype.map.call(elements, function (element) { 809 return _delegate(element, selector, type, callback, useCapture); 810 }); 811 } 812 813 /** 814 * Finds closest match and invokes callback. 815 * 816 * @param {Element} element 817 * @param {String} selector 818 * @param {String} type 819 * @param {Function} callback 820 * @return {Function} 821 */ 822 function listener(element, selector, type, callback) { 823 return function(e) { 824 e.delegateTarget = closest(e.target, selector); 825 826 if (e.delegateTarget) { 827 callback.call(element, e); 828 } 829 } 830 } 831 832 module.exports = delegate; 833 834 835 /***/ }), 836 /* 5 */ 837 /***/ (function(module, exports) { 838 839 var DOCUMENT_NODE_TYPE = 9; 840 841 /** 842 * A polyfill for Element.matches() 843 */ 844 if (typeof Element !== 'undefined' && !Element.prototype.matches) { 845 var proto = Element.prototype; 846 847 proto.matches = proto.matchesSelector || 848 proto.mozMatchesSelector || 849 proto.msMatchesSelector || 850 proto.oMatchesSelector || 851 proto.webkitMatchesSelector; 852 } 853 854 /** 855 * Finds the closest parent that matches a selector. 856 * 857 * @param {Element} element 858 * @param {String} selector 859 * @return {Function} 860 */ 861 function closest (element, selector) { 862 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { 863 if (typeof element.matches === 'function' && 864 element.matches(selector)) { 865 return element; 866 } 867 element = element.parentNode; 868 } 869 } 870 871 module.exports = closest; 872 873 874 /***/ }), 875 /* 6 */ 876 /***/ (function(module, __webpack_exports__, __webpack_require__) { 877 878 "use strict"; 879 __webpack_require__.r(__webpack_exports__); 880 881 // EXTERNAL MODULE: ./node_modules/select/src/select.js 882 var src_select = __webpack_require__(0); 883 var select_default = /*#__PURE__*/__webpack_require__.n(src_select); 884 885 // CONCATENATED MODULE: ./src/clipboard-action.js 886 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 887 888 var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 889 890 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 891 892 893 894 /** 895 * Inner class which performs selection from either `text` or `target` 896 * properties and then executes copy or cut operations. 897 */ 898 899 var clipboard_action_ClipboardAction = function () { 900 /** 901 * @param {Object} options 902 */ 903 function ClipboardAction(options) { 904 _classCallCheck(this, ClipboardAction); 905 906 this.resolveOptions(options); 907 this.initSelection(); 908 } 909 910 /** 911 * Defines base properties passed from constructor. 912 * @param {Object} options 913 */ 914 915 916 _createClass(ClipboardAction, [{ 917 key: 'resolveOptions', 918 value: function resolveOptions() { 919 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 920 921 this.action = options.action; 922 this.container = options.container; 923 this.emitter = options.emitter; 924 this.target = options.target; 925 this.text = options.text; 926 this.trigger = options.trigger; 927 928 this.selectedText = ''; 929 } 930 931 /** 932 * Decides which selection strategy is going to be applied based 933 * on the existence of `text` and `target` properties. 934 */ 935 936 }, { 937 key: 'initSelection', 938 value: function initSelection() { 939 if (this.text) { 940 this.selectFake(); 941 } else if (this.target) { 942 this.selectTarget(); 943 } 944 } 945 946 /** 947 * Creates a fake textarea element, sets its value from `text` property, 948 * and makes a selection on it. 949 */ 950 951 }, { 952 key: 'selectFake', 953 value: function selectFake() { 954 var _this = this; 955 956 var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; 957 958 this.removeFake(); 959 960 this.fakeHandlerCallback = function () { 961 return _this.removeFake(); 962 }; 963 this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; 964 965 this.fakeElem = document.createElement('textarea'); 966 // Prevent zooming on iOS 967 this.fakeElem.style.fontSize = '12pt'; 968 // Reset box model 969 this.fakeElem.style.border = '0'; 970 this.fakeElem.style.padding = '0'; 971 this.fakeElem.style.margin = '0'; 972 // Move element out of screen horizontally 973 this.fakeElem.style.position = 'absolute'; 974 this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; 975 // Move element to the same position vertically 976 var yPosition = window.pageYOffset || document.documentElement.scrollTop; 977 this.fakeElem.style.top = yPosition + 'px'; 978 979 this.fakeElem.setAttribute('readonly', ''); 980 this.fakeElem.value = this.text; 981 982 this.container.appendChild(this.fakeElem); 983 984 this.selectedText = select_default()(this.fakeElem); 985 this.copyText(); 986 } 987 988 /** 989 * Only removes the fake element after another click event, that way 990 * a user can hit `Ctrl+C` to copy because selection still exists. 991 */ 992 993 }, { 994 key: 'removeFake', 995 value: function removeFake() { 996 if (this.fakeHandler) { 997 this.container.removeEventListener('click', this.fakeHandlerCallback); 998 this.fakeHandler = null; 999 this.fakeHandlerCallback = null; 1000 } 1001 1002 if (this.fakeElem) { 1003 this.container.removeChild(this.fakeElem); 1004 this.fakeElem = null; 1005 } 1006 } 1007 1008 /** 1009 * Selects the content from element passed on `target` property. 1010 */ 1011 1012 }, { 1013 key: 'selectTarget', 1014 value: function selectTarget() { 1015 this.selectedText = select_default()(this.target); 1016 this.copyText(); 1017 } 1018 1019 /** 1020 * Executes the copy operation based on the current selection. 1021 */ 1022 1023 }, { 1024 key: 'copyText', 1025 value: function copyText() { 1026 var succeeded = void 0; 1027 1028 try { 1029 succeeded = document.execCommand(this.action); 1030 } catch (err) { 1031 succeeded = false; 1032 } 1033 1034 this.handleResult(succeeded); 1035 } 1036 1037 /** 1038 * Fires an event based on the copy operation result. 1039 * @param {Boolean} succeeded 1040 */ 1041 1042 }, { 1043 key: 'handleResult', 1044 value: function handleResult(succeeded) { 1045 this.emitter.emit(succeeded ? 'success' : 'error', { 1046 action: this.action, 1047 text: this.selectedText, 1048 trigger: this.trigger, 1049 clearSelection: this.clearSelection.bind(this) 1050 }); 1051 } 1052 1053 /** 1054 * Moves focus away from `target` and back to the trigger, removes current selection. 1055 */ 1056 1057 }, { 1058 key: 'clearSelection', 1059 value: function clearSelection() { 1060 if (this.trigger) { 1061 this.trigger.focus(); 1062 } 1063 document.activeElement.blur(); 1064 window.getSelection().removeAllRanges(); 1065 } 1066 1067 /** 1068 * Sets the `action` to be performed which can be either 'copy' or 'cut'. 1069 * @param {String} action 1070 */ 1071 1072 }, { 1073 key: 'destroy', 1074 1075 1076 /** 1077 * Destroy lifecycle. 1078 */ 1079 value: function destroy() { 1080 this.removeFake(); 1081 } 1082 }, { 1083 key: 'action', 1084 set: function set() { 1085 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; 1086 1087 this._action = action; 1088 1089 if (this._action !== 'copy' && this._action !== 'cut') { 1090 throw new Error('Invalid "action" value, use either "copy" or "cut"'); 1091 } 1092 } 1093 1094 /** 1095 * Gets the `action` property. 1096 * @return {String} 1097 */ 1098 , 1099 get: function get() { 1100 return this._action; 1101 } 1102 1103 /** 1104 * Sets the `target` property using an element 1105 * that will be have its content copied. 1106 * @param {Element} target 1107 */ 1108 1109 }, { 1110 key: 'target', 1111 set: function set(target) { 1112 if (target !== undefined) { 1113 if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { 1114 if (this.action === 'copy' && target.hasAttribute('disabled')) { 1115 throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); 1116 } 1117 1118 if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { 1119 throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); 1120 } 1121 1122 this._target = target; 1123 } else { 1124 throw new Error('Invalid "target" value, use a valid Element'); 1125 } 1126 } 1127 } 1128 1129 /** 1130 * Gets the `target` property. 1131 * @return {String|HTMLElement} 1132 */ 1133 , 1134 get: function get() { 1135 return this._target; 1136 } 1137 }]); 1138 1139 return ClipboardAction; 1140 }(); 1141 1142 /* harmony default export */ var clipboard_action = (clipboard_action_ClipboardAction); 1143 // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js 1144 var tiny_emitter = __webpack_require__(1); 1145 var tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter); 1146 1147 // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js 1148 var listen = __webpack_require__(2); 1149 var listen_default = /*#__PURE__*/__webpack_require__.n(listen); 1150 1151 // CONCATENATED MODULE: ./src/clipboard.js 1152 var clipboard_typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 1153 1154 var clipboard_createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 1155 1156 function clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1157 1158 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 1159 1160 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 1161 1162 1163 1164 1165 1166 /** 1167 * Base class which takes one or more elements, adds event listeners to them, 1168 * and instantiates a new `ClipboardAction` on each click. 1169 */ 1170 1171 var clipboard_Clipboard = function (_Emitter) { 1172 _inherits(Clipboard, _Emitter); 1173 1174 /** 1175 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger 1176 * @param {Object} options 1177 */ 1178 function Clipboard(trigger, options) { 1179 clipboard_classCallCheck(this, Clipboard); 1180 1181 var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this)); 1182 1183 _this.resolveOptions(options); 1184 _this.listenClick(trigger); 1185 return _this; 1186 } 1187 1188 /** 1189 * Defines if attributes would be resolved using internal setter functions 1190 * or custom functions that were passed in the constructor. 1191 * @param {Object} options 1192 */ 1193 1194 1195 clipboard_createClass(Clipboard, [{ 1196 key: 'resolveOptions', 1197 value: function resolveOptions() { 1198 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 1199 1200 this.action = typeof options.action === 'function' ? options.action : this.defaultAction; 1201 this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; 1202 this.text = typeof options.text === 'function' ? options.text : this.defaultText; 1203 this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body; 1204 } 1205 1206 /** 1207 * Adds a click event listener to the passed trigger. 1208 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger 1209 */ 1210 1211 }, { 1212 key: 'listenClick', 1213 value: function listenClick(trigger) { 1214 var _this2 = this; 1215 1216 this.listener = listen_default()(trigger, 'click', function (e) { 1217 return _this2.onClick(e); 1218 }); 1219 } 1220 1221 /** 1222 * Defines a new `ClipboardAction` on each click event. 1223 * @param {Event} e 1224 */ 1225 1226 }, { 1227 key: 'onClick', 1228 value: function onClick(e) { 1229 var trigger = e.delegateTarget || e.currentTarget; 1230 1231 if (this.clipboardAction) { 1232 this.clipboardAction = null; 1233 } 1234 1235 this.clipboardAction = new clipboard_action({ 1236 action: this.action(trigger), 1237 target: this.target(trigger), 1238 text: this.text(trigger), 1239 container: this.container, 1240 trigger: trigger, 1241 emitter: this 1242 }); 1243 } 1244 1245 /** 1246 * Default `action` lookup function. 1247 * @param {Element} trigger 1248 */ 1249 1250 }, { 1251 key: 'defaultAction', 1252 value: function defaultAction(trigger) { 1253 return getAttributeValue('action', trigger); 1254 } 1255 1256 /** 1257 * Default `target` lookup function. 1258 * @param {Element} trigger 1259 */ 1260 1261 }, { 1262 key: 'defaultTarget', 1263 value: function defaultTarget(trigger) { 1264 var selector = getAttributeValue('target', trigger); 1265 1266 if (selector) { 1267 return document.querySelector(selector); 1268 } 1269 } 1270 1271 /** 1272 * Returns the support of the given action, or all actions if no action is 1273 * given. 1274 * @param {String} [action] 1275 */ 1276 1277 }, { 1278 key: 'defaultText', 1279 1280 1281 /** 1282 * Default `text` lookup function. 1283 * @param {Element} trigger 1284 */ 1285 value: function defaultText(trigger) { 1286 return getAttributeValue('text', trigger); 1287 } 1288 1289 /** 1290 * Destroy lifecycle. 1291 */ 1292 1293 }, { 1294 key: 'destroy', 1295 value: function destroy() { 1296 this.listener.destroy(); 1297 1298 if (this.clipboardAction) { 1299 this.clipboardAction.destroy(); 1300 this.clipboardAction = null; 1301 } 1302 } 1303 }], [{ 1304 key: 'isSupported', 1305 value: function isSupported() { 1306 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; 1307 1308 var actions = typeof action === 'string' ? [action] : action; 1309 var support = !!document.queryCommandSupported; 1310 1311 actions.forEach(function (action) { 1312 support = support && !!document.queryCommandSupported(action); 1313 }); 1314 1315 return support; 1316 } 1317 }]); 1318 1319 return Clipboard; 1320 }(tiny_emitter_default.a); 1321 1322 /** 1323 * Helper function to retrieve attribute value. 1324 * @param {String} suffix 1325 * @param {Element} element 1326 */ 1327 1328 1329 function getAttributeValue(suffix, element) { 1330 var attribute = 'data-clipboard-' + suffix; 1331 1332 if (!element.hasAttribute(attribute)) { 1333 return; 1334 } 1335 1336 return element.getAttribute(attribute); 1337 } 1338 1339 /* harmony default export */ var clipboard = __webpack_exports__["default"] = (clipboard_Clipboard); 1340 1341 /***/ }) 1342 /******/ ])["default"]; 1343 }); 1344 1345 /***/ }), 1346 1347 /***/ 277: 1348 /***/ (function(module, exports, __webpack_require__) { 1349 1350 var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */ 1351 /** 1352 * Copyright 2012-2017 Craig Campbell 1353 * 1354 * Licensed under the Apache License, Version 2.0 (the "License"); 1355 * you may not use this file except in compliance with the License. 1356 * You may obtain a copy of the License at 1357 * 1358 * http://www.apache.org/licenses/LICENSE-2.0 1359 * 1360 * Unless required by applicable law or agreed to in writing, software 1361 * distributed under the License is distributed on an "AS IS" BASIS, 1362 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1363 * See the License for the specific language governing permissions and 1364 * limitations under the License. 1365 * 1366 * Mousetrap is a simple keyboard shortcut library for Javascript with 1367 * no external dependencies 1368 * 1369 * @version 1.6.5 1370 * @url craig.is/killing/mice 1371 */ 1372 (function(window, document, undefined) { 1373 1374 // Check if mousetrap is used inside browser, if not, return 1375 if (!window) { 1376 return; 1377 } 1378 1379 /** 1380 * mapping of special keycodes to their corresponding keys 1381 * 1382 * everything in this dictionary cannot use keypress events 1383 * so it has to be here to map to the correct keycodes for 1384 * keyup/keydown events 1385 * 1386 * @type {Object} 1387 */ 1388 var _MAP = { 1389 8: 'backspace', 1390 9: 'tab', 1391 13: 'enter', 1392 16: 'shift', 1393 17: 'ctrl', 1394 18: 'alt', 1395 20: 'capslock', 1396 27: 'esc', 1397 32: 'space', 1398 33: 'pageup', 1399 34: 'pagedown', 1400 35: 'end', 1401 36: 'home', 1402 37: 'left', 1403 38: 'up', 1404 39: 'right', 1405 40: 'down', 1406 45: 'ins', 1407 46: 'del', 1408 91: 'meta', 1409 93: 'meta', 1410 224: 'meta' 1411 }; 1412 1413 /** 1414 * mapping for special characters so they can support 1415 * 1416 * this dictionary is only used incase you want to bind a 1417 * keyup or keydown event to one of these keys 1418 * 1419 * @type {Object} 1420 */ 1421 var _KEYCODE_MAP = { 1422 106: '*', 1423 107: '+', 1424 109: '-', 1425 110: '.', 1426 111 : '/', 1427 186: ';', 1428 187: '=', 1429 188: ',', 1430 189: '-', 1431 190: '.', 1432 191: '/', 1433 192: '`', 1434 219: '[', 1435 220: '\\', 1436 221: ']', 1437 222: '\'' 1438 }; 1439 1440 /** 1441 * this is a mapping of keys that require shift on a US keypad 1442 * back to the non shift equivelents 1443 * 1444 * this is so you can use keyup events with these keys 1445 * 1446 * note that this will only work reliably on US keyboards 1447 * 1448 * @type {Object} 1449 */ 1450 var _SHIFT_MAP = { 1451 '~': '`', 1452 '!': '1', 1453 '@': '2', 1454 '#': '3', 1455 '$': '4', 1456 '%': '5', 1457 '^': '6', 1458 '&': '7', 1459 '*': '8', 1460 '(': '9', 1461 ')': '0', 1462 '_': '-', 1463 '+': '=', 1464 ':': ';', 1465 '\"': '\'', 1466 '<': ',', 1467 '>': '.', 1468 '?': '/', 1469 '|': '\\' 1470 }; 1471 1472 /** 1473 * this is a list of special strings you can use to map 1474 * to modifier keys when you specify your keyboard shortcuts 1475 * 1476 * @type {Object} 1477 */ 1478 var _SPECIAL_ALIASES = { 1479 'option': 'alt', 1480 'command': 'meta', 1481 'return': 'enter', 1482 'escape': 'esc', 1483 'plus': '+', 1484 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl' 1485 }; 1486 1487 /** 1488 * variable to store the flipped version of _MAP from above 1489 * needed to check if we should use keypress or not when no action 1490 * is specified 1491 * 1492 * @type {Object|undefined} 1493 */ 1494 var _REVERSE_MAP; 1495 1496 /** 1497 * loop through the f keys, f1 to f19 and add them to the map 1498 * programatically 1499 */ 1500 for (var i = 1; i < 20; ++i) { 1501 _MAP[111 + i] = 'f' + i; 1502 } 1503 1504 /** 1505 * loop through to map numbers on the numeric keypad 1506 */ 1507 for (i = 0; i <= 9; ++i) { 1508 1509 // This needs to use a string cause otherwise since 0 is falsey 1510 // mousetrap will never fire for numpad 0 pressed as part of a keydown 1511 // event. 1512 // 1513 // @see https://github.com/ccampbell/mousetrap/pull/258 1514 _MAP[i + 96] = i.toString(); 1515 } 1516 1517 /** 1518 * cross browser add event method 1519 * 1520 * @param {Element|HTMLDocument} object 1521 * @param {string} type 1522 * @param {Function} callback 1523 * @returns void 1524 */ 1525 function _addEvent(object, type, callback) { 1526 if (object.addEventListener) { 1527 object.addEventListener(type, callback, false); 1528 return; 1529 } 1530 1531 object.attachEvent('on' + type, callback); 1532 } 1533 1534 /** 1535 * takes the event and returns the key character 1536 * 1537 * @param {Event} e 1538 * @return {string} 1539 */ 1540 function _characterFromEvent(e) { 1541 1542 // for keypress events we should return the character as is 1543 if (e.type == 'keypress') { 1544 var character = String.fromCharCode(e.which); 1545 1546 // if the shift key is not pressed then it is safe to assume 1547 // that we want the character to be lowercase. this means if 1548 // you accidentally have caps lock on then your key bindings 1549 // will continue to work 1550 // 1551 // the only side effect that might not be desired is if you 1552 // bind something like 'A' cause you want to trigger an 1553 // event when capital A is pressed caps lock will no longer 1554 // trigger the event. shift+a will though. 1555 if (!e.shiftKey) { 1556 character = character.toLowerCase(); 1557 } 1558 1559 return character; 1560 } 1561 1562 // for non keypress events the special maps are needed 1563 if (_MAP[e.which]) { 1564 return _MAP[e.which]; 1565 } 1566 1567 if (_KEYCODE_MAP[e.which]) { 1568 return _KEYCODE_MAP[e.which]; 1569 } 1570 1571 // if it is not in the special map 1572 1573 // with keydown and keyup events the character seems to always 1574 // come in as an uppercase character whether you are pressing shift 1575 // or not. we should make sure it is always lowercase for comparisons 1576 return String.fromCharCode(e.which).toLowerCase(); 1577 } 1578 1579 /** 1580 * checks if two arrays are equal 1581 * 1582 * @param {Array} modifiers1 1583 * @param {Array} modifiers2 1584 * @returns {boolean} 1585 */ 1586 function _modifiersMatch(modifiers1, modifiers2) { 1587 return modifiers1.sort().join(',') === modifiers2.sort().join(','); 1588 } 1589 1590 /** 1591 * takes a key event and figures out what the modifiers are 1592 * 1593 * @param {Event} e 1594 * @returns {Array} 1595 */ 1596 function _eventModifiers(e) { 1597 var modifiers = []; 1598 1599 if (e.shiftKey) { 1600 modifiers.push('shift'); 1601 } 1602 1603 if (e.altKey) { 1604 modifiers.push('alt'); 1605 } 1606 1607 if (e.ctrlKey) { 1608 modifiers.push('ctrl'); 1609 } 1610 1611 if (e.metaKey) { 1612 modifiers.push('meta'); 1613 } 1614 1615 return modifiers; 1616 } 1617 1618 /** 1619 * prevents default for this event 1620 * 1621 * @param {Event} e 1622 * @returns void 1623 */ 1624 function _preventDefault(e) { 1625 if (e.preventDefault) { 1626 e.preventDefault(); 1627 return; 1628 } 1629 1630 e.returnValue = false; 1631 } 1632 1633 /** 1634 * stops propogation for this event 1635 * 1636 * @param {Event} e 1637 * @returns void 1638 */ 1639 function _stopPropagation(e) { 1640 if (e.stopPropagation) { 1641 e.stopPropagation(); 1642 return; 1643 } 1644 1645 e.cancelBubble = true; 1646 } 1647 1648 /** 1649 * determines if the keycode specified is a modifier key or not 1650 * 1651 * @param {string} key 1652 * @returns {boolean} 1653 */ 1654 function _isModifier(key) { 1655 return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta'; 1656 } 1657 1658 /** 1659 * reverses the map lookup so that we can look for specific keys 1660 * to see what can and can't use keypress 1661 * 1662 * @return {Object} 1663 */ 1664 function _getReverseMap() { 1665 if (!_REVERSE_MAP) { 1666 _REVERSE_MAP = {}; 1667 for (var key in _MAP) { 1668 1669 // pull out the numeric keypad from here cause keypress should 1670 // be able to detect the keys from the character 1671 if (key > 95 && key < 112) { 1672 continue; 1673 } 1674 1675 if (_MAP.hasOwnProperty(key)) { 1676 _REVERSE_MAP[_MAP[key]] = key; 1677 } 1678 } 1679 } 1680 return _REVERSE_MAP; 1681 } 1682 1683 /** 1684 * picks the best action based on the key combination 1685 * 1686 * @param {string} key - character for key 1687 * @param {Array} modifiers 1688 * @param {string=} action passed in 1689 */ 1690 function _pickBestAction(key, modifiers, action) { 1691 1692 // if no action was picked in we should try to pick the one 1693 // that we think would work best for this key 1694 if (!action) { 1695 action = _getReverseMap()[key] ? 'keydown' : 'keypress'; 1696 } 1697 1698 // modifier keys don't work as expected with keypress, 1699 // switch to keydown 1700 if (action == 'keypress' && modifiers.length) { 1701 action = 'keydown'; 1702 } 1703 1704 return action; 1705 } 1706 1707 /** 1708 * Converts from a string key combination to an array 1709 * 1710 * @param {string} combination like "command+shift+l" 1711 * @return {Array} 1712 */ 1713 function _keysFromString(combination) { 1714 if (combination === '+') { 1715 return ['+']; 1716 } 1717 1718 combination = combination.replace(/\+{2}/g, '+plus'); 1719 return combination.split('+'); 1720 } 1721 1722 /** 1723 * Gets info for a specific key combination 1724 * 1725 * @param {string} combination key combination ("command+s" or "a" or "*") 1726 * @param {string=} action 1727 * @returns {Object} 1728 */ 1729 function _getKeyInfo(combination, action) { 1730 var keys; 1731 var key; 1732 var i; 1733 var modifiers = []; 1734 1735 // take the keys from this pattern and figure out what the actual 1736 // pattern is all about 1737 keys = _keysFromString(combination); 1738 1739 for (i = 0; i < keys.length; ++i) { 1740 key = keys[i]; 1741 1742 // normalize key names 1743 if (_SPECIAL_ALIASES[key]) { 1744 key = _SPECIAL_ALIASES[key]; 1745 } 1746 1747 // if this is not a keypress event then we should 1748 // be smart about using shift keys 1749 // this will only work for US keyboards however 1750 if (action && action != 'keypress' && _SHIFT_MAP[key]) { 1751 key = _SHIFT_MAP[key]; 1752 modifiers.push('shift'); 1753 } 1754 1755 // if this key is a modifier then add it to the list of modifiers 1756 if (_isModifier(key)) { 1757 modifiers.push(key); 1758 } 1759 } 1760 1761 // depending on what the key combination is 1762 // we will try to pick the best event for it 1763 action = _pickBestAction(key, modifiers, action); 1764 1765 return { 1766 key: key, 1767 modifiers: modifiers, 1768 action: action 1769 }; 1770 } 1771 1772 function _belongsTo(element, ancestor) { 1773 if (element === null || element === document) { 1774 return false; 1775 } 1776 1777 if (element === ancestor) { 1778 return true; 1779 } 1780 1781 return _belongsTo(element.parentNode, ancestor); 1782 } 1783 1784 function Mousetrap(targetElement) { 1785 var self = this; 1786 1787 targetElement = targetElement || document; 1788 1789 if (!(self instanceof Mousetrap)) { 1790 return new Mousetrap(targetElement); 1791 } 1792 1793 /** 1794 * element to attach key events to 1795 * 1796 * @type {Element} 1797 */ 1798 self.target = targetElement; 1799 1800 /** 1801 * a list of all the callbacks setup via Mousetrap.bind() 1802 * 1803 * @type {Object} 1804 */ 1805 self._callbacks = {}; 1806 1807 /** 1808 * direct map of string combinations to callbacks used for trigger() 1809 * 1810 * @type {Object} 1811 */ 1812 self._directMap = {}; 1813 1814 /** 1815 * keeps track of what level each sequence is at since multiple 1816 * sequences can start out with the same sequence 1817 * 1818 * @type {Object} 1819 */ 1820 var _sequenceLevels = {}; 1821 1822 /** 1823 * variable to store the setTimeout call 1824 * 1825 * @type {null|number} 1826 */ 1827 var _resetTimer; 1828 1829 /** 1830 * temporary state where we will ignore the next keyup 1831 * 1832 * @type {boolean|string} 1833 */ 1834 var _ignoreNextKeyup = false; 1835 1836 /** 1837 * temporary state where we will ignore the next keypress 1838 * 1839 * @type {boolean} 1840 */ 1841 var _ignoreNextKeypress = false; 1842 1843 /** 1844 * are we currently inside of a sequence? 1845 * type of action ("keyup" or "keydown" or "keypress") or false 1846 * 1847 * @type {boolean|string} 1848 */ 1849 var _nextExpectedAction = false; 1850 1851 /** 1852 * resets all sequence counters except for the ones passed in 1853 * 1854 * @param {Object} doNotReset 1855 * @returns void 1856 */ 1857 function _resetSequences(doNotReset) { 1858 doNotReset = doNotReset || {}; 1859 1860 var activeSequences = false, 1861 key; 1862 1863 for (key in _sequenceLevels) { 1864 if (doNotReset[key]) { 1865 activeSequences = true; 1866 continue; 1867 } 1868 _sequenceLevels[key] = 0; 1869 } 1870 1871 if (!activeSequences) { 1872 _nextExpectedAction = false; 1873 } 1874 } 1875 1876 /** 1877 * finds all callbacks that match based on the keycode, modifiers, 1878 * and action 1879 * 1880 * @param {string} character 1881 * @param {Array} modifiers 1882 * @param {Event|Object} e 1883 * @param {string=} sequenceName - name of the sequence we are looking for 1884 * @param {string=} combination 1885 * @param {number=} level 1886 * @returns {Array} 1887 */ 1888 function _getMatches(character, modifiers, e, sequenceName, combination, level) { 1889 var i; 1890 var callback; 1891 var matches = []; 1892 var action = e.type; 1893 1894 // if there are no events related to this keycode 1895 if (!self._callbacks[character]) { 1896 return []; 1897 } 1898 1899 // if a modifier key is coming up on its own we should allow it 1900 if (action == 'keyup' && _isModifier(character)) { 1901 modifiers = [character]; 1902 } 1903 1904 // loop through all callbacks for the key that was pressed 1905 // and see if any of them match 1906 for (i = 0; i < self._callbacks[character].length; ++i) { 1907 callback = self._callbacks[character][i]; 1908 1909 // if a sequence name is not specified, but this is a sequence at 1910 // the wrong level then move onto the next match 1911 if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) { 1912 continue; 1913 } 1914 1915 // if the action we are looking for doesn't match the action we got 1916 // then we should keep going 1917 if (action != callback.action) { 1918 continue; 1919 } 1920 1921 // if this is a keypress event and the meta key and control key 1922 // are not pressed that means that we need to only look at the 1923 // character, otherwise check the modifiers as well 1924 // 1925 // chrome will not fire a keypress if meta or control is down 1926 // safari will fire a keypress if meta or meta+shift is down 1927 // firefox will fire a keypress if meta or control is down 1928 if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) { 1929 1930 // when you bind a combination or sequence a second time it 1931 // should overwrite the first one. if a sequenceName or 1932 // combination is specified in this call it does just that 1933 // 1934 // @todo make deleting its own method? 1935 var deleteCombo = !sequenceName && callback.combo == combination; 1936 var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level; 1937 if (deleteCombo || deleteSequence) { 1938 self._callbacks[character].splice(i, 1); 1939 } 1940 1941 matches.push(callback); 1942 } 1943 } 1944 1945 return matches; 1946 } 1947 1948 /** 1949 * actually calls the callback function 1950 * 1951 * if your callback function returns false this will use the jquery 1952 * convention - prevent default and stop propogation on the event 1953 * 1954 * @param {Function} callback 1955 * @param {Event} e 1956 * @returns void 1957 */ 1958 function _fireCallback(callback, e, combo, sequence) { 1959 1960 // if this event should not happen stop here 1961 if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) { 1962 return; 1963 } 1964 1965 if (callback(e, combo) === false) { 1966 _preventDefault(e); 1967 _stopPropagation(e); 1968 } 1969 } 1970 1971 /** 1972 * handles a character key event 1973 * 1974 * @param {string} character 1975 * @param {Array} modifiers 1976 * @param {Event} e 1977 * @returns void 1978 */ 1979 self._handleKey = function(character, modifiers, e) { 1980 var callbacks = _getMatches(character, modifiers, e); 1981 var i; 1982 var doNotReset = {}; 1983 var maxLevel = 0; 1984 var processedSequenceCallback = false; 1985 1986 // Calculate the maxLevel for sequences so we can only execute the longest callback sequence 1987 for (i = 0; i < callbacks.length; ++i) { 1988 if (callbacks[i].seq) { 1989 maxLevel = Math.max(maxLevel, callbacks[i].level); 1990 } 1991 } 1992 1993 // loop through matching callbacks for this key event 1994 for (i = 0; i < callbacks.length; ++i) { 1995 1996 // fire for all sequence callbacks 1997 // this is because if for example you have multiple sequences 1998 // bound such as "g i" and "g t" they both need to fire the 1999 // callback for matching g cause otherwise you can only ever 2000 // match the first one 2001 if (callbacks[i].seq) { 2002 2003 // only fire callbacks for the maxLevel to prevent 2004 // subsequences from also firing 2005 // 2006 // for example 'a option b' should not cause 'option b' to fire 2007 // even though 'option b' is part of the other sequence 2008 // 2009 // any sequences that do not match here will be discarded 2010 // below by the _resetSequences call 2011 if (callbacks[i].level != maxLevel) { 2012 continue; 2013 } 2014 2015 processedSequenceCallback = true; 2016 2017 // keep a list of which sequences were matches for later 2018 doNotReset[callbacks[i].seq] = 1; 2019 _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq); 2020 continue; 2021 } 2022 2023 // if there were no sequence matches but we are still here 2024 // that means this is a regular match so we should fire that 2025 if (!processedSequenceCallback) { 2026 _fireCallback(callbacks[i].callback, e, callbacks[i].combo); 2027 } 2028 } 2029 2030 // if the key you pressed matches the type of sequence without 2031 // being a modifier (ie "keyup" or "keypress") then we should 2032 // reset all sequences that were not matched by this event 2033 // 2034 // this is so, for example, if you have the sequence "h a t" and you 2035 // type "h e a r t" it does not match. in this case the "e" will 2036 // cause the sequence to reset 2037 // 2038 // modifier keys are ignored because you can have a sequence 2039 // that contains modifiers such as "enter ctrl+space" and in most 2040 // cases the modifier key will be pressed before the next key 2041 // 2042 // also if you have a sequence such as "ctrl+b a" then pressing the 2043 // "b" key will trigger a "keypress" and a "keydown" 2044 // 2045 // the "keydown" is expected when there is a modifier, but the 2046 // "keypress" ends up matching the _nextExpectedAction since it occurs 2047 // after and that causes the sequence to reset 2048 // 2049 // we ignore keypresses in a sequence that directly follow a keydown 2050 // for the same character 2051 var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress; 2052 if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) { 2053 _resetSequences(doNotReset); 2054 } 2055 2056 _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown'; 2057 }; 2058 2059 /** 2060 * handles a keydown event 2061 * 2062 * @param {Event} e 2063 * @returns void 2064 */ 2065 function _handleKeyEvent(e) { 2066 2067 // normalize e.which for key events 2068 // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion 2069 if (typeof e.which !== 'number') { 2070 e.which = e.keyCode; 2071 } 2072 2073 var character = _characterFromEvent(e); 2074 2075 // no character found then stop 2076 if (!character) { 2077 return; 2078 } 2079 2080 // need to use === for the character check because the character can be 0 2081 if (e.type == 'keyup' && _ignoreNextKeyup === character) { 2082 _ignoreNextKeyup = false; 2083 return; 2084 } 2085 2086 self.handleKey(character, _eventModifiers(e), e); 2087 } 2088 2089 /** 2090 * called to set a 1 second timeout on the specified sequence 2091 * 2092 * this is so after each key press in the sequence you have 1 second 2093 * to press the next key before you have to start over 2094 * 2095 * @returns void 2096 */ 2097 function _resetSequenceTimer() { 2098 clearTimeout(_resetTimer); 2099 _resetTimer = setTimeout(_resetSequences, 1000); 2100 } 2101 2102 /** 2103 * binds a key sequence to an event 2104 * 2105 * @param {string} combo - combo specified in bind call 2106 * @param {Array} keys 2107 * @param {Function} callback 2108 * @param {string=} action 2109 * @returns void 2110 */ 2111 function _bindSequence(combo, keys, callback, action) { 2112 2113 // start off by adding a sequence level record for this combination 2114 // and setting the level to 0 2115 _sequenceLevels[combo] = 0; 2116 2117 /** 2118 * callback to increase the sequence level for this sequence and reset 2119 * all other sequences that were active 2120 * 2121 * @param {string} nextAction 2122 * @returns {Function} 2123 */ 2124 function _increaseSequence(nextAction) { 2125 return function() { 2126 _nextExpectedAction = nextAction; 2127 ++_sequenceLevels[combo]; 2128 _resetSequenceTimer(); 2129 }; 2130 } 2131 2132 /** 2133 * wraps the specified callback inside of another function in order 2134 * to reset all sequence counters as soon as this sequence is done 2135 * 2136 * @param {Event} e 2137 * @returns void 2138 */ 2139 function _callbackAndReset(e) { 2140 _fireCallback(callback, e, combo); 2141 2142 // we should ignore the next key up if the action is key down 2143 // or keypress. this is so if you finish a sequence and 2144 // release the key the final key will not trigger a keyup 2145 if (action !== 'keyup') { 2146 _ignoreNextKeyup = _characterFromEvent(e); 2147 } 2148 2149 // weird race condition if a sequence ends with the key 2150 // another sequence begins with 2151 setTimeout(_resetSequences, 10); 2152 } 2153 2154 // loop through keys one at a time and bind the appropriate callback 2155 // function. for any key leading up to the final one it should 2156 // increase the sequence. after the final, it should reset all sequences 2157 // 2158 // if an action is specified in the original bind call then that will 2159 // be used throughout. otherwise we will pass the action that the 2160 // next key in the sequence should match. this allows a sequence 2161 // to mix and match keypress and keydown events depending on which 2162 // ones are better suited to the key provided 2163 for (var i = 0; i < keys.length; ++i) { 2164 var isFinal = i + 1 === keys.length; 2165 var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action); 2166 _bindSingle(keys[i], wrappedCallback, action, combo, i); 2167 } 2168 } 2169 2170 /** 2171 * binds a single keyboard combination 2172 * 2173 * @param {string} combination 2174 * @param {Function} callback 2175 * @param {string=} action 2176 * @param {string=} sequenceName - name of sequence if part of sequence 2177 * @param {number=} level - what part of the sequence the command is 2178 * @returns void 2179 */ 2180 function _bindSingle(combination, callback, action, sequenceName, level) { 2181 2182 // store a direct mapped reference for use with Mousetrap.trigger 2183 self._directMap[combination + ':' + action] = callback; 2184 2185 // make sure multiple spaces in a row become a single space 2186 combination = combination.replace(/\s+/g, ' '); 2187 2188 var sequence = combination.split(' '); 2189 var info; 2190 2191 // if this pattern is a sequence of keys then run through this method 2192 // to reprocess each pattern one key at a time 2193 if (sequence.length > 1) { 2194 _bindSequence(combination, sequence, callback, action); 2195 return; 2196 } 2197 2198 info = _getKeyInfo(combination, action); 2199 2200 // make sure to initialize array if this is the first time 2201 // a callback is added for this key 2202 self._callbacks[info.key] = self._callbacks[info.key] || []; 2203 2204 // remove an existing match if there is one 2205 _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level); 2206 2207 // add this call back to the array 2208 // if it is a sequence put it at the beginning 2209 // if not put it at the end 2210 // 2211 // this is important because the way these are processed expects 2212 // the sequence ones to come first 2213 self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({ 2214 callback: callback, 2215 modifiers: info.modifiers, 2216 action: info.action, 2217 seq: sequenceName, 2218 level: level, 2219 combo: combination 2220 }); 2221 } 2222 2223 /** 2224 * binds multiple combinations to the same callback 2225 * 2226 * @param {Array} combinations 2227 * @param {Function} callback 2228 * @param {string|undefined} action 2229 * @returns void 2230 */ 2231 self._bindMultiple = function(combinations, callback, action) { 2232 for (var i = 0; i < combinations.length; ++i) { 2233 _bindSingle(combinations[i], callback, action); 2234 } 2235 }; 2236 2237 // start! 2238 _addEvent(targetElement, 'keypress', _handleKeyEvent); 2239 _addEvent(targetElement, 'keydown', _handleKeyEvent); 2240 _addEvent(targetElement, 'keyup', _handleKeyEvent); 2241 } 2242 2243 /** 2244 * binds an event to mousetrap 2245 * 2246 * can be a single key, a combination of keys separated with +, 2247 * an array of keys, or a sequence of keys separated by spaces 2248 * 2249 * be sure to list the modifier keys first to make sure that the 2250 * correct key ends up getting bound (the last key in the pattern) 2251 * 2252 * @param {string|Array} keys 2253 * @param {Function} callback 2254 * @param {string=} action - 'keypress', 'keydown', or 'keyup' 2255 * @returns void 2256 */ 2257 Mousetrap.prototype.bind = function(keys, callback, action) { 2258 var self = this; 2259 keys = keys instanceof Array ? keys : [keys]; 2260 self._bindMultiple.call(self, keys, callback, action); 2261 return self; 2262 }; 2263 2264 /** 2265 * unbinds an event to mousetrap 2266 * 2267 * the unbinding sets the callback function of the specified key combo 2268 * to an empty function and deletes the corresponding key in the 2269 * _directMap dict. 2270 * 2271 * TODO: actually remove this from the _callbacks dictionary instead 2272 * of binding an empty function 2273 * 2274 * the keycombo+action has to be exactly the same as 2275 * it was defined in the bind method 2276 * 2277 * @param {string|Array} keys 2278 * @param {string} action 2279 * @returns void 2280 */ 2281 Mousetrap.prototype.unbind = function(keys, action) { 2282 var self = this; 2283 return self.bind.call(self, keys, function() {}, action); 2284 }; 2285 2286 /** 2287 * triggers an event that has already been bound 2288 * 2289 * @param {string} keys 2290 * @param {string=} action 2291 * @returns void 2292 */ 2293 Mousetrap.prototype.trigger = function(keys, action) { 2294 var self = this; 2295 if (self._directMap[keys + ':' + action]) { 2296 self._directMap[keys + ':' + action]({}, keys); 2297 } 2298 return self; 2299 }; 2300 2301 /** 2302 * resets the library back to its initial state. this is useful 2303 * if you want to clear out the current keyboard shortcuts and bind 2304 * new ones - for example if you switch to another page 2305 * 2306 * @returns void 2307 */ 2308 Mousetrap.prototype.reset = function() { 2309 var self = this; 2310 self._callbacks = {}; 2311 self._directMap = {}; 2312 return self; 2313 }; 2314 2315 /** 2316 * should we stop this event before firing off callbacks 2317 * 2318 * @param {Event} e 2319 * @param {Element} element 2320 * @return {boolean} 2321 */ 2322 Mousetrap.prototype.stopCallback = function(e, element) { 2323 var self = this; 2324 2325 // if the element has the class "mousetrap" then no need to stop 2326 if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) { 2327 return false; 2328 } 2329 2330 if (_belongsTo(element, self.target)) { 2331 return false; 2332 } 2333 2334 // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host, 2335 // not the initial event target in the shadow tree. Note that not all events cross the 2336 // shadow boundary. 2337 // For shadow trees with `mode: 'open'`, the initial event target is the first element in 2338 // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event 2339 // target cannot be obtained. 2340 if ('composedPath' in e && typeof e.composedPath === 'function') { 2341 // For open shadow trees, update `element` so that the following check works. 2342 var initialEventTarget = e.composedPath()[0]; 2343 if (initialEventTarget !== e.target) { 2344 element = initialEventTarget; 2345 } 2346 } 2347 2348 // stop for input, select, and textarea 2349 return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable; 2350 }; 2351 2352 /** 2353 * exposes _handleKey publicly so it can be overwritten by extensions 2354 */ 2355 Mousetrap.prototype.handleKey = function() { 2356 var self = this; 2357 return self._handleKey.apply(self, arguments); 2358 }; 2359 2360 /** 2361 * allow custom key mappings 2362 */ 2363 Mousetrap.addKeycodes = function(object) { 2364 for (var key in object) { 2365 if (object.hasOwnProperty(key)) { 2366 _MAP[key] = object[key]; 2367 } 2368 } 2369 _REVERSE_MAP = null; 2370 }; 2371 2372 /** 2373 * Init the global mousetrap functions 2374 * 2375 * This method is needed to allow the global mousetrap functions to work 2376 * now that mousetrap is a constructor function. 2377 */ 2378 Mousetrap.init = function() { 2379 var documentMousetrap = Mousetrap(document); 2380 for (var method in documentMousetrap) { 2381 if (method.charAt(0) !== '_') { 2382 Mousetrap[method] = (function(method) { 2383 return function() { 2384 return documentMousetrap[method].apply(documentMousetrap, arguments); 2385 }; 2386 } (method)); 2387 } 2388 } 2389 }; 2390 2391 Mousetrap.init(); 2392 2393 // expose mousetrap to the global object 2394 window.Mousetrap = Mousetrap; 2395 2396 // expose as a common js module 2397 if ( true && module.exports) { 2398 module.exports = Mousetrap; 2399 } 2400 2401 // expose mousetrap as an AMD module 2402 if (true) { 2403 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 2404 return Mousetrap; 2405 }).call(exports, __webpack_require__, exports, module), 2406 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 2407 } 2408 }) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null); 2409 2410 2411 /***/ }), 2412 2413 /***/ 28: 2414 /***/ (function(module, __webpack_exports__, __webpack_require__) { 2415 2416 "use strict"; 2417 2418 // EXPORTS 2419 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _inherits; }); 2420 2421 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js 2422 function _setPrototypeOf(o, p) { 2423 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 2424 o.__proto__ = p; 2425 return o; 2426 }; 2427 2428 return _setPrototypeOf(o, p); 2429 } 2430 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js 2431 2432 function _inherits(subClass, superClass) { 2433 if (typeof superClass !== "function" && superClass !== null) { 2434 throw new TypeError("Super expression must either be null or a function"); 2435 } 2436 2437 subClass.prototype = Object.create(superClass && superClass.prototype, { 2438 constructor: { 2439 value: subClass, 2440 writable: true, 2441 configurable: true 2442 } 2443 }); 2444 if (superClass) _setPrototypeOf(subClass, superClass); 2445 } 2446 2447 /***/ }), 2448 2449 /***/ 29: 2450 /***/ (function(module, __webpack_exports__, __webpack_require__) { 2451 2452 "use strict"; 2453 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; }); 2454 /* harmony import */ var _babel_runtime_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(42); 2455 /* harmony import */ var _babel_runtime_helpers_esm_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18); 2456 2457 2458 function _possibleConstructorReturn(self, call) { 2459 if (call && (Object(_babel_runtime_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) { 2460 return call; 2461 } 2462 2463 return Object(_babel_runtime_helpers_esm_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self); 2464 } 2465 2466 /***/ }), 2467 2468 /***/ 32: 2469 /***/ (function(module, __webpack_exports__, __webpack_require__) { 2470 2471 "use strict"; 2472 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; }); 2473 /* harmony import */ var _babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24); 2474 2475 function _unsupportedIterableToArray(o, minLen) { 2476 if (!o) return; 2477 if (typeof o === "string") return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); 2478 var n = Object.prototype.toString.call(o).slice(8, -1); 2479 if (n === "Object" && o.constructor) n = o.constructor.name; 2480 if (n === "Map" || n === "Set") return Array.from(o); 2481 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); 2482 } 2483 2484 /***/ }), 2485 2486 /***/ 35: 2487 /***/ (function(module, exports) { 2488 2489 (function() { module.exports = window["wp"]["deprecated"]; }()); 2490 2491 /***/ }), 2492 2493 /***/ 37: 2494 /***/ (function(module, __webpack_exports__, __webpack_require__) { 2495 2496 "use strict"; 2497 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); 2498 function _iterableToArray(iter) { 2499 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); 2500 } 2501 2502 /***/ }), 2503 2504 /***/ 38: 2505 /***/ (function(module, __webpack_exports__, __webpack_require__) { 2506 2507 "use strict"; 2508 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); 2509 function _arrayWithHoles(arr) { 2510 if (Array.isArray(arr)) return arr; 2511 } 2512 2513 /***/ }), 2514 2515 /***/ 39: 2516 /***/ (function(module, __webpack_exports__, __webpack_require__) { 2517 2518 "use strict"; 2519 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); 2520 function _nonIterableRest() { 2521 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 2522 } 2523 2524 /***/ }), 2525 2526 /***/ 42: 2527 /***/ (function(module, __webpack_exports__, __webpack_require__) { 2528 2529 "use strict"; 2530 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); 2531 function _typeof(obj) { 2532 "@babel/helpers - typeof"; 2533 2534 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 2535 _typeof = function _typeof(obj) { 2536 return typeof obj; 2537 }; 2538 } else { 2539 _typeof = function _typeof(obj) { 2540 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 2541 }; 2542 } 2543 2544 return _typeof(obj); 2545 } 2546 2547 /***/ }), 2548 2549 /***/ 423: 2550 /***/ (function(module, exports) { 2551 2552 /** 2553 * adds a bindGlobal method to Mousetrap that allows you to 2554 * bind specific keyboard shortcuts that will still work 2555 * inside a text input field 2556 * 2557 * usage: 2558 * Mousetrap.bindGlobal('ctrl+s', _saveChanges); 2559 */ 2560 /* global Mousetrap:true */ 2561 (function(Mousetrap) { 2562 if (! Mousetrap) { 2563 return; 2564 } 2565 var _globalCallbacks = {}; 2566 var _originalStopCallback = Mousetrap.prototype.stopCallback; 2567 2568 Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) { 2569 var self = this; 2570 2571 if (self.paused) { 2572 return true; 2573 } 2574 2575 if (_globalCallbacks[combo] || _globalCallbacks[sequence]) { 2576 return false; 2577 } 2578 2579 return _originalStopCallback.call(self, e, element, combo); 2580 }; 2581 2582 Mousetrap.prototype.bindGlobal = function(keys, callback, action) { 2583 var self = this; 2584 self.bind(keys, callback, action); 2585 2586 if (keys instanceof Array) { 2587 for (var i = 0; i < keys.length; i++) { 2588 _globalCallbacks[keys[i]] = true; 2589 } 2590 return; 2591 } 2592 2593 _globalCallbacks[keys] = true; 2594 }; 2595 2596 Mousetrap.init(); 2597 }) (typeof Mousetrap !== "undefined" ? Mousetrap : undefined); 2598 2599 2600 /***/ }), 2601 2602 /***/ 447: 2603 /***/ (function(module, __webpack_exports__, __webpack_require__) { 2604 2605 "use strict"; 2606 // ESM COMPAT FLAG 2607 __webpack_require__.r(__webpack_exports__); 2608 2609 // EXPORTS 2610 __webpack_require__.d(__webpack_exports__, "createHigherOrderComponent", function() { return /* reexport */ create_higher_order_component; }); 2611 __webpack_require__.d(__webpack_exports__, "compose", function() { return /* reexport */ compose; }); 2612 __webpack_require__.d(__webpack_exports__, "ifCondition", function() { return /* reexport */ if_condition; }); 2613 __webpack_require__.d(__webpack_exports__, "pure", function() { return /* reexport */ higher_order_pure; }); 2614 __webpack_require__.d(__webpack_exports__, "withGlobalEvents", function() { return /* reexport */ withGlobalEvents; }); 2615 __webpack_require__.d(__webpack_exports__, "withInstanceId", function() { return /* reexport */ with_instance_id; }); 2616 __webpack_require__.d(__webpack_exports__, "withSafeTimeout", function() { return /* reexport */ with_safe_timeout; }); 2617 __webpack_require__.d(__webpack_exports__, "withState", function() { return /* reexport */ withState; }); 2618 __webpack_require__.d(__webpack_exports__, "useConstrainedTabbing", function() { return /* reexport */ use_constrained_tabbing; }); 2619 __webpack_require__.d(__webpack_exports__, "useCopyOnClick", function() { return /* reexport */ useCopyOnClick; }); 2620 __webpack_require__.d(__webpack_exports__, "__experimentalUseDialog", function() { return /* reexport */ use_dialog; }); 2621 __webpack_require__.d(__webpack_exports__, "__experimentalUseDragging", function() { return /* reexport */ useDragging; }); 2622 __webpack_require__.d(__webpack_exports__, "useFocusOnMount", function() { return /* reexport */ useFocusOnMount; }); 2623 __webpack_require__.d(__webpack_exports__, "__experimentalUseFocusOutside", function() { return /* reexport */ useFocusOutside; }); 2624 __webpack_require__.d(__webpack_exports__, "useFocusReturn", function() { return /* reexport */ use_focus_return; }); 2625 __webpack_require__.d(__webpack_exports__, "useInstanceId", function() { return /* reexport */ useInstanceId; }); 2626 __webpack_require__.d(__webpack_exports__, "useIsomorphicLayoutEffect", function() { return /* reexport */ use_isomorphic_layout_effect; }); 2627 __webpack_require__.d(__webpack_exports__, "useKeyboardShortcut", function() { return /* reexport */ use_keyboard_shortcut; }); 2628 __webpack_require__.d(__webpack_exports__, "useMediaQuery", function() { return /* reexport */ useMediaQuery; }); 2629 __webpack_require__.d(__webpack_exports__, "usePrevious", function() { return /* reexport */ usePrevious; }); 2630 __webpack_require__.d(__webpack_exports__, "useReducedMotion", function() { return /* reexport */ use_reduced_motion; }); 2631 __webpack_require__.d(__webpack_exports__, "useViewportMatch", function() { return /* reexport */ use_viewport_match; }); 2632 __webpack_require__.d(__webpack_exports__, "useResizeObserver", function() { return /* reexport */ use_resize_observer; }); 2633 __webpack_require__.d(__webpack_exports__, "useAsyncList", function() { return /* reexport */ use_async_list; }); 2634 __webpack_require__.d(__webpack_exports__, "useWarnOnChange", function() { return /* reexport */ use_warn_on_change; }); 2635 __webpack_require__.d(__webpack_exports__, "useDebounce", function() { return /* reexport */ useDebounce; }); 2636 __webpack_require__.d(__webpack_exports__, "useThrottle", function() { return /* reexport */ useThrottle; }); 2637 2638 // EXTERNAL MODULE: external "lodash" 2639 var external_lodash_ = __webpack_require__(2); 2640 2641 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js 2642 /** 2643 * External dependencies 2644 */ 2645 2646 /** 2647 * Given a function mapping a component to an enhanced component and modifier 2648 * name, returns the enhanced component augmented with a generated displayName. 2649 * 2650 * @param {Function} mapComponentToEnhancedComponent Function mapping component 2651 * to enhanced component. 2652 * @param {string} modifierName Seed name from which to 2653 * generated display name. 2654 * 2655 * @return {WPComponent} Component class with generated display name assigned. 2656 */ 2657 2658 function createHigherOrderComponent(mapComponentToEnhancedComponent, modifierName) { 2659 return function (OriginalComponent) { 2660 var EnhancedComponent = mapComponentToEnhancedComponent(OriginalComponent); 2661 var _OriginalComponent$di = OriginalComponent.displayName, 2662 displayName = _OriginalComponent$di === void 0 ? OriginalComponent.name || 'Component' : _OriginalComponent$di; 2663 EnhancedComponent.displayName = "".concat(Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(modifierName)), "(").concat(displayName, ")"); 2664 return EnhancedComponent; 2665 }; 2666 } 2667 2668 /* harmony default export */ var create_higher_order_component = (createHigherOrderComponent); 2669 2670 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js 2671 /** 2672 * External dependencies 2673 */ 2674 2675 /** 2676 * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function 2677 * composition, where each successive invocation is supplied the return value of the previous. 2678 * 2679 * @param {...Function} hocs The HOC functions to invoke. 2680 * 2681 * @return {Function} Returns the new composite function. 2682 */ 2683 2684 /* harmony default export */ var compose = (external_lodash_["flowRight"]); 2685 2686 // EXTERNAL MODULE: external ["wp","element"] 2687 var external_wp_element_ = __webpack_require__(0); 2688 2689 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js 2690 2691 2692 /** 2693 * Internal dependencies 2694 */ 2695 2696 /** 2697 * Higher-order component creator, creating a new component which renders if 2698 * the given condition is satisfied or with the given optional prop name. 2699 * 2700 * @param {Function} predicate Function to test condition. 2701 * 2702 * @return {Function} Higher-order component. 2703 */ 2704 2705 var if_condition_ifCondition = function ifCondition(predicate) { 2706 return create_higher_order_component(function (WrappedComponent) { 2707 return function (props) { 2708 if (!predicate(props)) { 2709 return null; 2710 } 2711 2712 return Object(external_wp_element_["createElement"])(WrappedComponent, props); 2713 }; 2714 }, 'ifCondition'); 2715 }; 2716 2717 /* harmony default export */ var if_condition = (if_condition_ifCondition); 2718 2719 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js 2720 var classCallCheck = __webpack_require__(25); 2721 2722 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js 2723 var createClass = __webpack_require__(26); 2724 2725 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules 2726 var inherits = __webpack_require__(28); 2727 2728 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js 2729 var possibleConstructorReturn = __webpack_require__(29); 2730 2731 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js 2732 var getPrototypeOf = __webpack_require__(19); 2733 2734 // EXTERNAL MODULE: external ["wp","isShallowEqual"] 2735 var external_wp_isShallowEqual_ = __webpack_require__(59); 2736 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_); 2737 2738 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js 2739 2740 2741 2742 2743 2744 2745 2746 function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } 2747 2748 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 2749 2750 /** 2751 * WordPress dependencies 2752 */ 2753 2754 2755 /** 2756 * Internal dependencies 2757 */ 2758 2759 2760 /** 2761 * Given a component returns the enhanced component augmented with a component 2762 * only rerendering when its props/state change 2763 * 2764 * @param {Function} mapComponentToEnhancedComponent Function mapping component 2765 * to enhanced component. 2766 * @param {string} modifierName Seed name from which to 2767 * generated display name. 2768 * 2769 * @return {WPComponent} Component class with generated display name assigned. 2770 */ 2771 2772 var pure = create_higher_order_component(function (Wrapped) { 2773 if (Wrapped.prototype instanceof external_wp_element_["Component"]) { 2774 return /*#__PURE__*/function (_Wrapped) { 2775 Object(inherits["a" /* default */])(_class, _Wrapped); 2776 2777 var _super = _createSuper(_class); 2778 2779 function _class() { 2780 Object(classCallCheck["a" /* default */])(this, _class); 2781 2782 return _super.apply(this, arguments); 2783 } 2784 2785 Object(createClass["a" /* default */])(_class, [{ 2786 key: "shouldComponentUpdate", 2787 value: function shouldComponentUpdate(nextProps, nextState) { 2788 return !external_wp_isShallowEqual_default()(nextProps, this.props) || !external_wp_isShallowEqual_default()(nextState, this.state); 2789 } 2790 }]); 2791 2792 return _class; 2793 }(Wrapped); 2794 } 2795 2796 return /*#__PURE__*/function (_Component) { 2797 Object(inherits["a" /* default */])(_class2, _Component); 2798 2799 var _super2 = _createSuper(_class2); 2800 2801 function _class2() { 2802 Object(classCallCheck["a" /* default */])(this, _class2); 2803 2804 return _super2.apply(this, arguments); 2805 } 2806 2807 Object(createClass["a" /* default */])(_class2, [{ 2808 key: "shouldComponentUpdate", 2809 value: function shouldComponentUpdate(nextProps) { 2810 return !external_wp_isShallowEqual_default()(nextProps, this.props); 2811 } 2812 }, { 2813 key: "render", 2814 value: function render() { 2815 return Object(external_wp_element_["createElement"])(Wrapped, this.props); 2816 } 2817 }]); 2818 2819 return _class2; 2820 }(external_wp_element_["Component"]); 2821 }, 'pure'); 2822 /* harmony default export */ var higher_order_pure = (pure); 2823 2824 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js 2825 var esm_extends = __webpack_require__(8); 2826 2827 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js 2828 var assertThisInitialized = __webpack_require__(18); 2829 2830 // EXTERNAL MODULE: external ["wp","deprecated"] 2831 var external_wp_deprecated_ = __webpack_require__(35); 2832 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_); 2833 2834 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js 2835 2836 2837 2838 /** 2839 * External dependencies 2840 */ 2841 2842 /** 2843 * Class responsible for orchestrating event handling on the global window, 2844 * binding a single event to be shared across all handling instances, and 2845 * removing the handler when no instances are listening for the event. 2846 */ 2847 2848 var listener_Listener = /*#__PURE__*/function () { 2849 function Listener() { 2850 Object(classCallCheck["a" /* default */])(this, Listener); 2851 2852 this.listeners = {}; 2853 this.handleEvent = this.handleEvent.bind(this); 2854 } 2855 2856 Object(createClass["a" /* default */])(Listener, [{ 2857 key: "add", 2858 value: function add(eventType, instance) { 2859 if (!this.listeners[eventType]) { 2860 // Adding first listener for this type, so bind event. 2861 window.addEventListener(eventType, this.handleEvent); 2862 this.listeners[eventType] = []; 2863 } 2864 2865 this.listeners[eventType].push(instance); 2866 } 2867 }, { 2868 key: "remove", 2869 value: function remove(eventType, instance) { 2870 this.listeners[eventType] = Object(external_lodash_["without"])(this.listeners[eventType], instance); 2871 2872 if (!this.listeners[eventType].length) { 2873 // Removing last listener for this type, so unbind event. 2874 window.removeEventListener(eventType, this.handleEvent); 2875 delete this.listeners[eventType]; 2876 } 2877 } 2878 }, { 2879 key: "handleEvent", 2880 value: function handleEvent(event) { 2881 Object(external_lodash_["forEach"])(this.listeners[event.type], function (instance) { 2882 instance.handleEvent(event); 2883 }); 2884 } 2885 }]); 2886 2887 return Listener; 2888 }(); 2889 2890 /* harmony default export */ var listener = (listener_Listener); 2891 2892 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 function with_global_events_createSuper(Derived) { var hasNativeReflectConstruct = with_global_events_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } 2903 2904 function with_global_events_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 2905 2906 /** 2907 * External dependencies 2908 */ 2909 2910 /** 2911 * WordPress dependencies 2912 */ 2913 2914 2915 2916 /** 2917 * Internal dependencies 2918 */ 2919 2920 2921 2922 /** 2923 * Listener instance responsible for managing document event handling. 2924 * 2925 * @type {Listener} 2926 */ 2927 2928 var with_global_events_listener = new listener(); 2929 /** 2930 * Higher-order component creator which, given an object of DOM event types and 2931 * values corresponding to a callback function name on the component, will 2932 * create or update a window event handler to invoke the callback when an event 2933 * occurs. On behalf of the consuming developer, the higher-order component 2934 * manages unbinding when the component unmounts, and binding at most a single 2935 * event handler for the entire application. 2936 * 2937 * @deprecated 2938 * 2939 * @param {Object<string,string>} eventTypesToHandlers Object with keys of DOM 2940 * event type, the value a 2941 * name of the function on 2942 * the original component's 2943 * instance which handles 2944 * the event. 2945 * 2946 * @return {Function} Higher-order component. 2947 */ 2948 2949 function withGlobalEvents(eventTypesToHandlers) { 2950 external_wp_deprecated_default()('wp.compose.withGlobalEvents', { 2951 alternative: 'useEffect' 2952 }); 2953 return create_higher_order_component(function (WrappedComponent) { 2954 var Wrapper = /*#__PURE__*/function (_Component) { 2955 Object(inherits["a" /* default */])(Wrapper, _Component); 2956 2957 var _super = with_global_events_createSuper(Wrapper); 2958 2959 function Wrapper() { 2960 var _this; 2961 2962 Object(classCallCheck["a" /* default */])(this, Wrapper); 2963 2964 _this = _super.apply(this, arguments); 2965 _this.handleEvent = _this.handleEvent.bind(Object(assertThisInitialized["a" /* default */])(_this)); 2966 _this.handleRef = _this.handleRef.bind(Object(assertThisInitialized["a" /* default */])(_this)); 2967 return _this; 2968 } 2969 2970 Object(createClass["a" /* default */])(Wrapper, [{ 2971 key: "componentDidMount", 2972 value: function componentDidMount() { 2973 var _this2 = this; 2974 2975 Object(external_lodash_["forEach"])(eventTypesToHandlers, function (handler, eventType) { 2976 with_global_events_listener.add(eventType, _this2); 2977 }); 2978 } 2979 }, { 2980 key: "componentWillUnmount", 2981 value: function componentWillUnmount() { 2982 var _this3 = this; 2983 2984 Object(external_lodash_["forEach"])(eventTypesToHandlers, function (handler, eventType) { 2985 with_global_events_listener.remove(eventType, _this3); 2986 }); 2987 } 2988 }, { 2989 key: "handleEvent", 2990 value: function handleEvent(event) { 2991 var handler = eventTypesToHandlers[event.type]; 2992 2993 if (typeof this.wrappedRef[handler] === 'function') { 2994 this.wrappedRef[handler](event); 2995 } 2996 } 2997 }, { 2998 key: "handleRef", 2999 value: function handleRef(el) { 3000 this.wrappedRef = el; // Any component using `withGlobalEvents` that is not setting a `ref` 3001 // will cause `this.props.forwardedRef` to be `null`, so we need this 3002 // check. 3003 3004 if (this.props.forwardedRef) { 3005 this.props.forwardedRef(el); 3006 } 3007 } 3008 }, { 3009 key: "render", 3010 value: function render() { 3011 return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, this.props.ownProps, { 3012 ref: this.handleRef 3013 })); 3014 } 3015 }]); 3016 3017 return Wrapper; 3018 }(external_wp_element_["Component"]); 3019 3020 return Object(external_wp_element_["forwardRef"])(function (props, ref) { 3021 return Object(external_wp_element_["createElement"])(Wrapper, { 3022 ownProps: props, 3023 forwardedRef: ref 3024 }); 3025 }); 3026 }, 'withGlobalEvents'); 3027 } 3028 3029 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js 3030 /** 3031 * WordPress dependencies 3032 */ 3033 3034 var instanceMap = new WeakMap(); 3035 /** 3036 * Creates a new id for a given object. 3037 * 3038 * @param {Object} object Object reference to create an id for. 3039 */ 3040 3041 function createId(object) { 3042 var instances = instanceMap.get(object) || 0; 3043 instanceMap.set(object, instances + 1); 3044 return instances; 3045 } 3046 /** 3047 * Provides a unique instance ID. 3048 * 3049 * @param {Object} object Object reference to create an id for. 3050 * @param {string} prefix Prefix for the unique id. 3051 */ 3052 3053 3054 function useInstanceId(object, prefix) { 3055 return Object(external_wp_element_["useMemo"])(function () { 3056 var id = createId(object); 3057 return prefix ? "".concat(prefix, "-").concat(id) : id; 3058 }, [object]); 3059 } 3060 3061 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js 3062 3063 3064 3065 /** 3066 * Internal dependencies 3067 */ 3068 3069 3070 /** 3071 * A Higher Order Component used to be provide a unique instance ID by 3072 * component. 3073 * 3074 * @param {WPComponent} WrappedComponent The wrapped component. 3075 * 3076 * @return {WPComponent} Component with an instanceId prop. 3077 */ 3078 3079 /* harmony default export */ var with_instance_id = (create_higher_order_component(function (WrappedComponent) { 3080 return function (props) { 3081 var instanceId = useInstanceId(WrappedComponent); 3082 return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, { 3083 instanceId: instanceId 3084 })); 3085 }; 3086 }, 'withInstanceId')); 3087 3088 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 function with_safe_timeout_createSuper(Derived) { var hasNativeReflectConstruct = with_safe_timeout_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } 3099 3100 function with_safe_timeout_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 3101 3102 /** 3103 * External dependencies 3104 */ 3105 3106 /** 3107 * WordPress dependencies 3108 */ 3109 3110 3111 /** 3112 * Internal dependencies 3113 */ 3114 3115 3116 /** 3117 * A higher-order component used to provide and manage delayed function calls 3118 * that ought to be bound to a component's lifecycle. 3119 * 3120 * @param {WPComponent} OriginalComponent Component requiring setTimeout 3121 * 3122 * @return {WPComponent} Wrapped component. 3123 */ 3124 3125 var withSafeTimeout = create_higher_order_component(function (OriginalComponent) { 3126 return /*#__PURE__*/function (_Component) { 3127 Object(inherits["a" /* default */])(WrappedComponent, _Component); 3128 3129 var _super = with_safe_timeout_createSuper(WrappedComponent); 3130 3131 function WrappedComponent() { 3132 var _this; 3133 3134 Object(classCallCheck["a" /* default */])(this, WrappedComponent); 3135 3136 _this = _super.apply(this, arguments); 3137 _this.timeouts = []; 3138 _this.setTimeout = _this.setTimeout.bind(Object(assertThisInitialized["a" /* default */])(_this)); 3139 _this.clearTimeout = _this.clearTimeout.bind(Object(assertThisInitialized["a" /* default */])(_this)); 3140 return _this; 3141 } 3142 3143 Object(createClass["a" /* default */])(WrappedComponent, [{ 3144 key: "componentWillUnmount", 3145 value: function componentWillUnmount() { 3146 this.timeouts.forEach(clearTimeout); 3147 } 3148 }, { 3149 key: "setTimeout", 3150 value: function (_setTimeout) { 3151 function setTimeout(_x, _x2) { 3152 return _setTimeout.apply(this, arguments); 3153 } 3154 3155 setTimeout.toString = function () { 3156 return _setTimeout.toString(); 3157 }; 3158 3159 return setTimeout; 3160 }(function (fn, delay) { 3161 var _this2 = this; 3162 3163 var id = setTimeout(function () { 3164 fn(); 3165 3166 _this2.clearTimeout(id); 3167 }, delay); 3168 this.timeouts.push(id); 3169 return id; 3170 }) 3171 }, { 3172 key: "clearTimeout", 3173 value: function (_clearTimeout) { 3174 function clearTimeout(_x3) { 3175 return _clearTimeout.apply(this, arguments); 3176 } 3177 3178 clearTimeout.toString = function () { 3179 return _clearTimeout.toString(); 3180 }; 3181 3182 return clearTimeout; 3183 }(function (id) { 3184 clearTimeout(id); 3185 this.timeouts = Object(external_lodash_["without"])(this.timeouts, id); 3186 }) 3187 }, { 3188 key: "render", 3189 value: function render() { 3190 return Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, this.props, { 3191 setTimeout: this.setTimeout, 3192 clearTimeout: this.clearTimeout 3193 })); 3194 } 3195 }]); 3196 3197 return WrappedComponent; 3198 }(external_wp_element_["Component"]); 3199 }, 'withSafeTimeout'); 3200 /* harmony default export */ var with_safe_timeout = (withSafeTimeout); 3201 3202 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 function with_state_createSuper(Derived) { var hasNativeReflectConstruct = with_state_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } 3213 3214 function with_state_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 3215 3216 /** 3217 * WordPress dependencies 3218 */ 3219 3220 /** 3221 * Internal dependencies 3222 */ 3223 3224 3225 /** 3226 * A Higher Order Component used to provide and manage internal component state 3227 * via props. 3228 * 3229 * @param {?Object} initialState Optional initial state of the component. 3230 * 3231 * @return {WPComponent} Wrapped component. 3232 */ 3233 3234 function withState() { 3235 var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3236 return create_higher_order_component(function (OriginalComponent) { 3237 return /*#__PURE__*/function (_Component) { 3238 Object(inherits["a" /* default */])(WrappedComponent, _Component); 3239 3240 var _super = with_state_createSuper(WrappedComponent); 3241 3242 function WrappedComponent() { 3243 var _this; 3244 3245 Object(classCallCheck["a" /* default */])(this, WrappedComponent); 3246 3247 _this = _super.apply(this, arguments); 3248 _this.setState = _this.setState.bind(Object(assertThisInitialized["a" /* default */])(_this)); 3249 _this.state = initialState; 3250 return _this; 3251 } 3252 3253 Object(createClass["a" /* default */])(WrappedComponent, [{ 3254 key: "render", 3255 value: function render() { 3256 return Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, this.props, this.state, { 3257 setState: this.setState 3258 })); 3259 } 3260 }]); 3261 3262 return WrappedComponent; 3263 }(external_wp_element_["Component"]); 3264 }, 'withState'); 3265 } 3266 3267 // EXTERNAL MODULE: external ["wp","keycodes"] 3268 var external_wp_keycodes_ = __webpack_require__(16); 3269 3270 // EXTERNAL MODULE: external ["wp","dom"] 3271 var external_wp_dom_ = __webpack_require__(27); 3272 3273 // EXTERNAL MODULE: ./node_modules/memize/index.js 3274 var memize = __webpack_require__(62); 3275 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); 3276 3277 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-callback-ref/index.js 3278 /** 3279 * External dependencies 3280 */ 3281 3282 /** 3283 * WordPress dependencies 3284 */ 3285 3286 3287 3288 function useCallbackRef(callback, deps) { 3289 return Object(external_wp_element_["useCallback"])(memize_default()(callback, { 3290 maxSize: 1 3291 }), deps); 3292 } 3293 3294 /* harmony default export */ var use_callback_ref = (useCallbackRef); 3295 3296 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js 3297 /** 3298 * WordPress dependencies 3299 */ 3300 3301 3302 /** 3303 * Internal dependencies 3304 */ 3305 3306 3307 /** 3308 * In Dialogs/modals, the tabbing must be constrained to the content of 3309 * the wrapper element. This hook adds the behavior to the returned ref. 3310 * 3311 * @return {Object|Function} Element Ref. 3312 * 3313 * @example 3314 * ```js 3315 * import { useConstrainedTabbing } from '@wordpress/compose'; 3316 * 3317 * const ConstrainedTabbingExample = () => { 3318 * const constrainedTabbingRef = useConstrainedTabbing() 3319 * return ( 3320 * <div ref={ constrainedTabbingRef }> 3321 * <Button /> 3322 * <Button /> 3323 * </div> 3324 * ); 3325 * } 3326 * ``` 3327 */ 3328 3329 function useConstrainedTabbing() { 3330 var ref = use_callback_ref(function (node) { 3331 if (!node) { 3332 return; 3333 } 3334 3335 node.addEventListener('keydown', function (event) { 3336 if (event.keyCode !== external_wp_keycodes_["TAB"]) { 3337 return; 3338 } 3339 3340 var tabbables = external_wp_dom_["focus"].tabbable.find(node); 3341 3342 if (!tabbables.length) { 3343 return; 3344 } 3345 3346 var firstTabbable = tabbables[0]; 3347 var lastTabbable = tabbables[tabbables.length - 1]; 3348 3349 if (event.shiftKey && event.target === firstTabbable) { 3350 event.preventDefault(); 3351 lastTabbable.focus(); 3352 } else if (!event.shiftKey && event.target === lastTabbable) { 3353 event.preventDefault(); 3354 firstTabbable.focus(); 3355 /* 3356 * When pressing Tab and none of the tabbables has focus, the keydown 3357 * event happens on the wrapper div: move focus on the first tabbable. 3358 */ 3359 } else if (!tabbables.includes(event.target)) { 3360 event.preventDefault(); 3361 firstTabbable.focus(); 3362 } 3363 }); 3364 }, []); 3365 return ref; 3366 } 3367 3368 /* harmony default export */ var use_constrained_tabbing = (useConstrainedTabbing); 3369 3370 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules 3371 var slicedToArray = __webpack_require__(11); 3372 3373 // EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js 3374 var dist_clipboard = __webpack_require__(276); 3375 var clipboard_default = /*#__PURE__*/__webpack_require__.n(dist_clipboard); 3376 3377 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js 3378 3379 3380 /** 3381 * External dependencies 3382 */ 3383 3384 /** 3385 * WordPress dependencies 3386 */ 3387 3388 3389 /** 3390 * Copies the text to the clipboard when the element is clicked. 3391 * 3392 * @param {Object} ref Reference with the element. 3393 * @param {string|Function} text The text to copy. 3394 * @param {number} timeout Optional timeout to reset the returned 3395 * state. 4 seconds by default. 3396 * 3397 * @return {boolean} Whether or not the text has been copied. Resets after the 3398 * timeout. 3399 */ 3400 3401 function useCopyOnClick(ref, _text) { 3402 var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 4000; 3403 var clipboard = Object(external_wp_element_["useRef"])(); 3404 3405 var _useState = Object(external_wp_element_["useState"])(false), 3406 _useState2 = Object(slicedToArray["a" /* default */])(_useState, 2), 3407 hasCopied = _useState2[0], 3408 setHasCopied = _useState2[1]; 3409 3410 Object(external_wp_element_["useEffect"])(function () { 3411 var timeoutId; // Clipboard listens to click events. 3412 3413 clipboard.current = new clipboard_default.a(ref.current, { 3414 text: function text() { 3415 return typeof _text === 'function' ? _text() : _text; 3416 } 3417 }); 3418 clipboard.current.on('success', function (_ref) { 3419 var clearSelection = _ref.clearSelection, 3420 trigger = _ref.trigger; 3421 // Clearing selection will move focus back to the triggering button, 3422 // ensuring that it is not reset to the body, and further that it is 3423 // kept within the rendered node. 3424 clearSelection(); // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 3425 3426 if (trigger) { 3427 trigger.focus(); 3428 } 3429 3430 if (timeout) { 3431 setHasCopied(true); 3432 clearTimeout(timeoutId); 3433 timeoutId = setTimeout(function () { 3434 return setHasCopied(false); 3435 }, timeout); 3436 } 3437 }); 3438 return function () { 3439 clipboard.current.destroy(); 3440 clearTimeout(timeoutId); 3441 }; 3442 }, [_text, timeout, setHasCopied]); 3443 return hasCopied; 3444 } 3445 3446 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 3447 var defineProperty = __webpack_require__(5); 3448 3449 // EXTERNAL MODULE: ./node_modules/react-merge-refs/dist/react-merge-refs.esm.js 3450 var react_merge_refs_esm = __webpack_require__(81); 3451 3452 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js 3453 /** 3454 * WordPress dependencies 3455 */ 3456 3457 3458 /** 3459 * Internal dependencies 3460 */ 3461 3462 3463 /** 3464 * Hook used to focus the first tabbable element on mount. 3465 * 3466 * @param {boolean|string} focusOnMount Focus on mount mode. 3467 * @return {Function} Ref callback. 3468 * 3469 * @example 3470 * ```js 3471 * import { useFocusOnMount } from '@wordpress/compose'; 3472 * 3473 * const WithFocusOnMount = () => { 3474 * const ref = useFocusOnMount() 3475 * return ( 3476 * <div ref={ ref }> 3477 * <Button /> 3478 * <Button /> 3479 * </div> 3480 * ); 3481 * } 3482 * ``` 3483 */ 3484 3485 function useFocusOnMount() { 3486 var focusOnMount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'firstElement'; 3487 var focusOnMountRef = Object(external_wp_element_["useRef"])(focusOnMount); 3488 Object(external_wp_element_["useEffect"])(function () { 3489 focusOnMountRef.current = focusOnMount; 3490 }, [focusOnMount]); 3491 return use_callback_ref(function (node) { 3492 if (!node || focusOnMountRef.current === false) { 3493 return; 3494 } 3495 3496 if (node.contains(node.ownerDocument.activeElement)) { 3497 return; 3498 } 3499 3500 var target = node; 3501 3502 if (focusOnMountRef.current === 'firstElement') { 3503 var firstTabbable = external_wp_dom_["focus"].tabbable.find(node)[0]; 3504 3505 if (firstTabbable) { 3506 target = firstTabbable; 3507 } 3508 } 3509 3510 target.focus(); 3511 }, []); 3512 } 3513 3514 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js 3515 /** 3516 * WordPress dependencies 3517 */ 3518 3519 /** 3520 * Internal dependencies 3521 */ 3522 3523 3524 /** 3525 * When opening modals/sidebars/dialogs, the focus 3526 * must move to the opened area and return to the 3527 * previously focused element when closed. 3528 * The current hook implements the returning behavior. 3529 * 3530 * @param {Function?} onFocusReturn Overrides the default return behavior. 3531 * @return {Function} Element Ref. 3532 * 3533 * @example 3534 * ```js 3535 * import { useFocusReturn } from '@wordpress/compose'; 3536 * 3537 * const WithFocusReturn = () => { 3538 * const ref = useFocusReturn() 3539 * return ( 3540 * <div ref={ ref }> 3541 * <Button /> 3542 * <Button /> 3543 * </div> 3544 * ); 3545 * } 3546 * ``` 3547 */ 3548 3549 function useFocusReturn(onFocusReturn) { 3550 var ref = Object(external_wp_element_["useRef"])(); 3551 var focusedBeforeMount = Object(external_wp_element_["useRef"])(); 3552 var onFocusReturnRef = Object(external_wp_element_["useRef"])(onFocusReturn); 3553 Object(external_wp_element_["useEffect"])(function () { 3554 onFocusReturnRef.current = onFocusReturn; 3555 }, [onFocusReturn]); 3556 return use_callback_ref(function (node) { 3557 if (node) { 3558 // Set ref to be used when unmounting. 3559 ref.current = node; // Only set when the node mounts. 3560 3561 if (focusedBeforeMount.current) { 3562 return; 3563 } 3564 3565 focusedBeforeMount.current = node.ownerDocument.activeElement; 3566 } else if (focusedBeforeMount.current) { 3567 var isFocused = ref.current.contains(ref.current.ownerDocument.activeElement); 3568 3569 if (!isFocused) { 3570 return; 3571 } // Defer to the component's own explicit focus return behavior, if 3572 // specified. This allows for support that the `onFocusReturn` 3573 // decides to allow the default behavior to occur under some 3574 // conditions. 3575 3576 3577 if (onFocusReturnRef.current) { 3578 onFocusReturnRef.current(); 3579 } else { 3580 focusedBeforeMount.current.focus(); 3581 } 3582 } 3583 }, []); 3584 } 3585 3586 /* harmony default export */ var use_focus_return = (useFocusReturn); 3587 3588 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js 3589 /** 3590 * External dependencies 3591 */ 3592 3593 /** 3594 * WordPress dependencies 3595 */ 3596 3597 3598 /** 3599 * Input types which are classified as button types, for use in considering 3600 * whether element is a (focus-normalized) button. 3601 * 3602 * @type {string[]} 3603 */ 3604 3605 var INPUT_BUTTON_TYPES = ['button', 'submit']; 3606 /** 3607 * @typedef {HTMLButtonElement | HTMLLinkElement | HTMLInputElement} FocusNormalizedButton 3608 */ 3609 // Disable reason: Rule doesn't support predicate return types 3610 3611 /* eslint-disable jsdoc/valid-types */ 3612 3613 /** 3614 * Returns true if the given element is a button element subject to focus 3615 * normalization, or false otherwise. 3616 * 3617 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 3618 * 3619 * @param {EventTarget} eventTarget The target from a mouse or touch event. 3620 * 3621 * @return {eventTarget is FocusNormalizedButton} Whether element is a button. 3622 */ 3623 3624 function isFocusNormalizedButton(eventTarget) { 3625 if (!(eventTarget instanceof window.HTMLElement)) { 3626 return false; 3627 } 3628 3629 switch (eventTarget.nodeName) { 3630 case 'A': 3631 case 'BUTTON': 3632 return true; 3633 3634 case 'INPUT': 3635 return Object(external_lodash_["includes"])(INPUT_BUTTON_TYPES, 3636 /** @type {HTMLInputElement} */ 3637 eventTarget.type); 3638 } 3639 3640 return false; 3641 } 3642 /* eslint-enable jsdoc/valid-types */ 3643 3644 /** 3645 * @typedef {import('react').SyntheticEvent} SyntheticEvent 3646 */ 3647 3648 /** 3649 * @callback EventCallback 3650 * @param {SyntheticEvent} event input related event. 3651 */ 3652 3653 /** 3654 * @typedef FocusOutsideReactElement 3655 * @property {EventCallback} handleFocusOutside callback for a focus outside event. 3656 */ 3657 3658 /** 3659 * @typedef {import('react').MutableRefObject<FocusOutsideReactElement | undefined>} FocusOutsideRef 3660 */ 3661 3662 /** 3663 * @typedef {Object} FocusOutsideReturnValue 3664 * @property {EventCallback} onFocus An event handler for focus events. 3665 * @property {EventCallback} onBlur An event handler for blur events. 3666 * @property {EventCallback} onMouseDown An event handler for mouse down events. 3667 * @property {EventCallback} onMouseUp An event handler for mouse up events. 3668 * @property {EventCallback} onTouchStart An event handler for touch start events. 3669 * @property {EventCallback} onTouchEnd An event handler for touch end events. 3670 */ 3671 3672 /** 3673 * A react hook that can be used to check whether focus has moved outside the 3674 * element the event handlers are bound to. 3675 * 3676 * @param {EventCallback} onFocusOutside A callback triggered when focus moves outside 3677 * the element the event handlers are bound to. 3678 * 3679 * @return {FocusOutsideReturnValue} An object containing event handlers. Bind the event handlers 3680 * to a wrapping element element to capture when focus moves 3681 * outside that element. 3682 */ 3683 3684 3685 function useFocusOutside(onFocusOutside) { 3686 var currentOnFocusOutside = Object(external_wp_element_["useRef"])(onFocusOutside); 3687 Object(external_wp_element_["useEffect"])(function () { 3688 currentOnFocusOutside.current = onFocusOutside; 3689 }, [onFocusOutside]); 3690 var preventBlurCheck = Object(external_wp_element_["useRef"])(false); 3691 /** 3692 * @type {import('react').MutableRefObject<number | undefined>} 3693 */ 3694 3695 var blurCheckTimeoutId = Object(external_wp_element_["useRef"])(); 3696 /** 3697 * Cancel a blur check timeout. 3698 */ 3699 3700 var cancelBlurCheck = Object(external_wp_element_["useCallback"])(function () { 3701 clearTimeout(blurCheckTimeoutId.current); 3702 }, []); // Cancel blur checks on unmount. 3703 3704 Object(external_wp_element_["useEffect"])(function () { 3705 return function () { 3706 return cancelBlurCheck(); 3707 }; 3708 }, []); // Cancel a blur check if the callback or ref is no longer provided. 3709 3710 Object(external_wp_element_["useEffect"])(function () { 3711 if (!onFocusOutside) { 3712 cancelBlurCheck(); 3713 } 3714 }, [onFocusOutside, cancelBlurCheck]); 3715 /** 3716 * Handles a mousedown or mouseup event to respectively assign and 3717 * unassign a flag for preventing blur check on button elements. Some 3718 * browsers, namely Firefox and Safari, do not emit a focus event on 3719 * button elements when clicked, while others do. The logic here 3720 * intends to normalize this as treating click on buttons as focus. 3721 * 3722 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 3723 * 3724 * @param {SyntheticEvent} event Event for mousedown or mouseup. 3725 */ 3726 3727 var normalizeButtonFocus = Object(external_wp_element_["useCallback"])(function (event) { 3728 var type = event.type, 3729 target = event.target; 3730 var isInteractionEnd = Object(external_lodash_["includes"])(['mouseup', 'touchend'], type); 3731 3732 if (isInteractionEnd) { 3733 preventBlurCheck.current = false; 3734 } else if (isFocusNormalizedButton(target)) { 3735 preventBlurCheck.current = true; 3736 } 3737 }, []); 3738 /** 3739 * A callback triggered when a blur event occurs on the element the handler 3740 * is bound to. 3741 * 3742 * Calls the `onFocusOutside` callback in an immediate timeout if focus has 3743 * move outside the bound element and is still within the document. 3744 * 3745 * @param {SyntheticEvent} event Blur event. 3746 */ 3747 3748 var queueBlurCheck = Object(external_wp_element_["useCallback"])(function (event) { 3749 // React does not allow using an event reference asynchronously 3750 // due to recycling behavior, except when explicitly persisted. 3751 event.persist(); // Skip blur check if clicking button. See `normalizeButtonFocus`. 3752 3753 if (preventBlurCheck.current) { 3754 return; 3755 } 3756 3757 blurCheckTimeoutId.current = setTimeout(function () { 3758 // If document is not focused then focus should remain 3759 // inside the wrapped component and therefore we cancel 3760 // this blur event thereby leaving focus in place. 3761 // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus. 3762 if (!document.hasFocus()) { 3763 event.preventDefault(); 3764 return; 3765 } 3766 3767 if ('function' === typeof currentOnFocusOutside.current) { 3768 currentOnFocusOutside.current(event); 3769 } 3770 }, 0); 3771 }, []); 3772 return { 3773 onFocus: cancelBlurCheck, 3774 onMouseDown: normalizeButtonFocus, 3775 onMouseUp: normalizeButtonFocus, 3776 onTouchStart: normalizeButtonFocus, 3777 onTouchEnd: normalizeButtonFocus, 3778 onBlur: queueBlurCheck 3779 }; 3780 } 3781 3782 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js 3783 3784 3785 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } 3786 3787 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 3788 3789 /** 3790 * External dependencies 3791 */ 3792 3793 /** 3794 * WordPress dependencies 3795 */ 3796 3797 3798 3799 /** 3800 * Internal dependencies 3801 */ 3802 3803 3804 3805 3806 3807 3808 /** 3809 * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors: 3810 * - constrained tabbing. 3811 * - focus on mount. 3812 * - return focus on unmount. 3813 * - focus outside. 3814 * 3815 * @param {Object} options Dialog Options. 3816 */ 3817 3818 function useDialog(options) { 3819 var onClose = Object(external_wp_element_["useRef"])(); 3820 Object(external_wp_element_["useEffect"])(function () { 3821 onClose.current = options.onClose; 3822 }, [options.onClose]); 3823 var constrainedTabbingRef = use_constrained_tabbing(); 3824 var focusOnMountRef = useFocusOnMount(); 3825 var focusReturnRef = use_focus_return(); 3826 var focusOutsideProps = useFocusOutside(options.onClose); 3827 var closeOnEscapeRef = use_callback_ref(function (node) { 3828 if (!node) { 3829 return; 3830 } 3831 3832 node.addEventListener('keydown', function (event) { 3833 // Close on escape 3834 if (event.keyCode === external_wp_keycodes_["ESCAPE"] && onClose.current) { 3835 event.stopPropagation(); 3836 onClose.current(); 3837 } 3838 }); 3839 }, []); 3840 return [Object(react_merge_refs_esm["a" /* default */])([constrainedTabbingRef, focusReturnRef, focusOnMountRef, closeOnEscapeRef]), _objectSpread(_objectSpread({}, focusOutsideProps), {}, { 3841 tabIndex: '-1' 3842 })]; 3843 } 3844 3845 /* harmony default export */ var use_dialog = (useDialog); 3846 3847 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js 3848 /** 3849 * WordPress dependencies 3850 */ 3851 3852 /** 3853 * Preferred over direct usage of `useLayoutEffect` when supporting 3854 * server rendered components (SSR) because currently React 3855 * throws a warning when using useLayoutEffect in that environment. 3856 */ 3857 3858 var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_wp_element_["useLayoutEffect"] : external_wp_element_["useEffect"]; 3859 /* harmony default export */ var use_isomorphic_layout_effect = (useIsomorphicLayoutEffect); 3860 3861 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js 3862 3863 3864 /** 3865 * WordPress dependencies 3866 */ 3867 3868 /** 3869 * Internal dependencies 3870 */ 3871 3872 3873 function useDragging(_ref) { 3874 var onDragStart = _ref.onDragStart, 3875 onDragMove = _ref.onDragMove, 3876 onDragEnd = _ref.onDragEnd; 3877 3878 var _useState = Object(external_wp_element_["useState"])(false), 3879 _useState2 = Object(slicedToArray["a" /* default */])(_useState, 2), 3880 isDragging = _useState2[0], 3881 setIsDragging = _useState2[1]; 3882 3883 var eventsRef = Object(external_wp_element_["useRef"])({ 3884 onDragStart: onDragStart, 3885 onDragMove: onDragMove, 3886 onDragEnd: onDragEnd 3887 }); 3888 use_isomorphic_layout_effect(function () { 3889 eventsRef.current.onDragStart = onDragStart; 3890 eventsRef.current.onDragMove = onDragMove; 3891 eventsRef.current.onDragEnd = onDragEnd; 3892 }, [onDragStart, onDragMove, onDragEnd]); 3893 var onMouseMove = Object(external_wp_element_["useCallback"])(function () { 3894 var _eventsRef$current; 3895 3896 return eventsRef.current.onDragMove && (_eventsRef$current = eventsRef.current).onDragMove.apply(_eventsRef$current, arguments); 3897 }, []); 3898 var endDrag = Object(external_wp_element_["useCallback"])(function () { 3899 if (eventsRef.current.onDragEnd) { 3900 var _eventsRef$current2; 3901 3902 (_eventsRef$current2 = eventsRef.current).onDragEnd.apply(_eventsRef$current2, arguments); 3903 } 3904 3905 document.removeEventListener('mousemove', onMouseMove); 3906 document.removeEventListener('mouseup', endDrag); 3907 setIsDragging(false); 3908 }, []); 3909 var startDrag = Object(external_wp_element_["useCallback"])(function () { 3910 if (eventsRef.current.onDragStart) { 3911 var _eventsRef$current3; 3912 3913 (_eventsRef$current3 = eventsRef.current).onDragStart.apply(_eventsRef$current3, arguments); 3914 } 3915 3916 document.addEventListener('mousemove', onMouseMove); 3917 document.addEventListener('mouseup', endDrag); 3918 setIsDragging(true); 3919 }, []); // Remove the global events when unmounting if needed. 3920 3921 Object(external_wp_element_["useEffect"])(function () { 3922 return function () { 3923 if (isDragging) { 3924 document.removeEventListener('mousemove', onMouseMove); 3925 document.removeEventListener('mouseup', endDrag); 3926 } 3927 }; 3928 }, [isDragging]); 3929 return { 3930 startDrag: startDrag, 3931 endDrag: endDrag, 3932 isDragging: isDragging 3933 }; 3934 } 3935 3936 // EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js 3937 var mousetrap_mousetrap = __webpack_require__(277); 3938 var mousetrap_default = /*#__PURE__*/__webpack_require__.n(mousetrap_mousetrap); 3939 3940 // EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js 3941 var mousetrap_global_bind = __webpack_require__(423); 3942 3943 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js 3944 /** 3945 * External dependencies 3946 */ 3947 3948 3949 3950 /** 3951 * WordPress dependencies 3952 */ 3953 3954 3955 /** 3956 * A block selection object. 3957 * 3958 * @typedef {Object} WPKeyboardShortcutConfig 3959 * 3960 * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields. 3961 * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown. 3962 * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true. 3963 * @property {Object} [target] React reference to the DOM element used to catch the keyboard event. 3964 */ 3965 3966 /** 3967 * Return true if platform is MacOS. 3968 * 3969 * @param {Object} _window window object by default; used for DI testing. 3970 * 3971 * @return {boolean} True if MacOS; false otherwise. 3972 */ 3973 3974 function isAppleOS() { 3975 var _window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window; 3976 3977 var platform = _window.navigator.platform; 3978 return platform.indexOf('Mac') !== -1 || Object(external_lodash_["includes"])(['iPad', 'iPhone'], platform); 3979 } 3980 /** 3981 * Attach a keyboard shortcut handler. 3982 * 3983 * @param {string[]|string} shortcuts Keyboard Shortcuts. 3984 * @param {Function} callback Shortcut callback. 3985 * @param {WPKeyboardShortcutConfig} options Shortcut options. 3986 */ 3987 3988 3989 function useKeyboardShortcut(shortcuts, callback) { 3990 var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, 3991 _ref$bindGlobal = _ref.bindGlobal, 3992 bindGlobal = _ref$bindGlobal === void 0 ? false : _ref$bindGlobal, 3993 _ref$eventName = _ref.eventName, 3994 eventName = _ref$eventName === void 0 ? 'keydown' : _ref$eventName, 3995 _ref$isDisabled = _ref.isDisabled, 3996 isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled, 3997 target = _ref.target; 3998 3999 var currentCallback = Object(external_wp_element_["useRef"])(callback); 4000 Object(external_wp_element_["useEffect"])(function () { 4001 currentCallback.current = callback; 4002 }, [callback]); 4003 Object(external_wp_element_["useEffect"])(function () { 4004 if (isDisabled) { 4005 return; 4006 } 4007 4008 var mousetrap = new mousetrap_default.a(target ? target.current : document); 4009 Object(external_lodash_["castArray"])(shortcuts).forEach(function (shortcut) { 4010 var keys = shortcut.split('+'); // Determines whether a key is a modifier by the length of the string. 4011 // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that 4012 // the modifiers are Shift and Cmd because they're not a single character. 4013 4014 var modifiers = new Set(keys.filter(function (value) { 4015 return value.length > 1; 4016 })); 4017 var hasAlt = modifiers.has('alt'); 4018 var hasShift = modifiers.has('shift'); // This should be better moved to the shortcut registration instead. 4019 4020 if (isAppleOS() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { 4021 throw new Error("Cannot bind ".concat(shortcut, ". Alt and Shift+Alt modifiers are reserved for character input.")); 4022 } 4023 4024 var bindFn = bindGlobal ? 'bindGlobal' : 'bind'; 4025 mousetrap[bindFn](shortcut, function () { 4026 return currentCallback.current.apply(currentCallback, arguments); 4027 }, eventName); 4028 }); 4029 return function () { 4030 mousetrap.reset(); 4031 }; 4032 }, [shortcuts, bindGlobal, eventName, target, isDisabled]); 4033 } 4034 4035 /* harmony default export */ var use_keyboard_shortcut = (useKeyboardShortcut); 4036 4037 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js 4038 4039 4040 /** 4041 * WordPress dependencies 4042 */ 4043 4044 /** 4045 * Runs a media query and returns its value when it changes. 4046 * 4047 * @param {string} [query] Media Query. 4048 * @return {boolean} return value of the media query. 4049 */ 4050 4051 function useMediaQuery(query) { 4052 var _useState = Object(external_wp_element_["useState"])(function () { 4053 return !!(query && typeof window !== 'undefined' && window.matchMedia(query).matches); 4054 }), 4055 _useState2 = Object(slicedToArray["a" /* default */])(_useState, 2), 4056 match = _useState2[0], 4057 setMatch = _useState2[1]; 4058 4059 Object(external_wp_element_["useEffect"])(function () { 4060 if (!query) { 4061 return; 4062 } 4063 4064 var updateMatch = function updateMatch() { 4065 return setMatch(window.matchMedia(query).matches); 4066 }; 4067 4068 updateMatch(); 4069 var list = window.matchMedia(query); 4070 list.addListener(updateMatch); 4071 return function () { 4072 list.removeListener(updateMatch); 4073 }; 4074 }, [query]); 4075 return query && match; 4076 } 4077 4078 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js 4079 /** 4080 * WordPress dependencies 4081 */ 4082 4083 /** 4084 * Use something's value from the previous render. 4085 * Based on https://usehooks.com/usePrevious/. 4086 * 4087 * @template T 4088 * 4089 * @param {T} value The value to track. 4090 * 4091 * @return {T|undefined} The value from the previous render. 4092 */ 4093 4094 function usePrevious(value) { 4095 // Disable reason: without an explicit type detail, the type of ref will be 4096 // inferred based on the initial useRef argument, which is undefined. 4097 // https://github.com/WordPress/gutenberg/pull/22597#issuecomment-633588366 4098 4099 /* eslint-disable jsdoc/no-undefined-types */ 4100 var ref = Object(external_wp_element_["useRef"])( 4101 /** @type {T|undefined} */ 4102 undefined); 4103 /* eslint-enable jsdoc/no-undefined-types */ 4104 // Store current value in ref. 4105 4106 Object(external_wp_element_["useEffect"])(function () { 4107 ref.current = value; 4108 }, [value]); // Re-run when value changes. 4109 // Return previous value (happens before update in useEffect above). 4110 4111 return ref.current; 4112 } 4113 4114 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js 4115 /** 4116 * Internal dependencies 4117 */ 4118 4119 /** 4120 * Whether or not the user agent is Internet Explorer. 4121 * 4122 * @type {boolean} 4123 */ 4124 4125 var IS_IE = typeof window !== 'undefined' && window.navigator.userAgent.indexOf('Trident') >= 0; 4126 /** 4127 * Hook returning whether the user has a preference for reduced motion. 4128 * 4129 * @return {boolean} Reduced motion preference value. 4130 */ 4131 4132 var useReducedMotion = undefined || IS_IE ? function () { 4133 return true; 4134 } : function () { 4135 return useMediaQuery('(prefers-reduced-motion: reduce)'); 4136 }; 4137 /* harmony default export */ var use_reduced_motion = (useReducedMotion); 4138 4139 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js 4140 /** 4141 * WordPress dependencies 4142 */ 4143 4144 /** 4145 * Internal dependencies 4146 */ 4147 4148 4149 /** 4150 * @typedef {"huge"|"wide"|"large"|"medium"|"small"|"mobile"} WPBreakpoint 4151 */ 4152 4153 /** 4154 * Hash of breakpoint names with pixel width at which it becomes effective. 4155 * 4156 * @see _breakpoints.scss 4157 * 4158 * @type {Object<WPBreakpoint,number>} 4159 */ 4160 4161 var BREAKPOINTS = { 4162 huge: 1440, 4163 wide: 1280, 4164 large: 960, 4165 medium: 782, 4166 small: 600, 4167 mobile: 480 4168 }; 4169 /** 4170 * @typedef {">="|"<"} WPViewportOperator 4171 */ 4172 4173 /** 4174 * Object mapping media query operators to the condition to be used. 4175 * 4176 * @type {Object<WPViewportOperator,string>} 4177 */ 4178 4179 var CONDITIONS = { 4180 '>=': 'min-width', 4181 '<': 'max-width' 4182 }; 4183 /** 4184 * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values. 4185 * 4186 * @type {Object<WPViewportOperator,Function>} 4187 */ 4188 4189 var OPERATOR_EVALUATORS = { 4190 '>=': function _(breakpointValue, width) { 4191 return width >= breakpointValue; 4192 }, 4193 '<': function _(breakpointValue, width) { 4194 return width < breakpointValue; 4195 } 4196 }; 4197 var ViewportMatchWidthContext = Object(external_wp_element_["createContext"])(null); 4198 /** 4199 * Returns true if the viewport matches the given query, or false otherwise. 4200 * 4201 * @param {WPBreakpoint} breakpoint Breakpoint size name. 4202 * @param {WPViewportOperator} [operator=">="] Viewport operator. 4203 * 4204 * @example 4205 * 4206 * ```js 4207 * useViewportMatch( 'huge', '<' ); 4208 * useViewportMatch( 'medium' ); 4209 * ``` 4210 * 4211 * @return {boolean} Whether viewport matches query. 4212 */ 4213 4214 var use_viewport_match_useViewportMatch = function useViewportMatch(breakpoint) { 4215 var operator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '>='; 4216 var simulatedWidth = Object(external_wp_element_["useContext"])(ViewportMatchWidthContext); 4217 var mediaQuery = !simulatedWidth && "(".concat(CONDITIONS[operator], ": ").concat(BREAKPOINTS[breakpoint], "px)"); 4218 var mediaQueryResult = useMediaQuery(mediaQuery); 4219 4220 if (simulatedWidth) { 4221 return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth); 4222 } 4223 4224 return mediaQueryResult; 4225 }; 4226 4227 use_viewport_match_useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider; 4228 /* harmony default export */ var use_viewport_match = (use_viewport_match_useViewportMatch); 4229 4230 // EXTERNAL MODULE: ./node_modules/react-resize-aware/dist/index.js 4231 var dist = __webpack_require__(145); 4232 var dist_default = /*#__PURE__*/__webpack_require__.n(dist); 4233 4234 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js 4235 /** 4236 * External dependencies 4237 */ 4238 4239 /** 4240 * Hook which allows to listen the resize event of any target element when it changes sizes. 4241 * _Note: `useResizeObserver` will report `null` until after first render_ 4242 * 4243 * @return {Array} An array of {Element} `resizeListener` and {?Object} `sizes` with properties `width` and `height` 4244 * 4245 * @example 4246 * 4247 * ```js 4248 * const App = () => { 4249 * const [ resizeListener, sizes ] = useResizeObserver(); 4250 * 4251 * return ( 4252 * <div> 4253 * { resizeListener } 4254 * Your content here 4255 * </div> 4256 * ); 4257 * }; 4258 * ``` 4259 * 4260 */ 4261 4262 /* harmony default export */ var use_resize_observer = (dist_default.a); 4263 4264 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules 4265 var toConsumableArray = __webpack_require__(15); 4266 4267 // EXTERNAL MODULE: external ["wp","priorityQueue"] 4268 var external_wp_priorityQueue_ = __webpack_require__(146); 4269 4270 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js 4271 4272 4273 4274 /** 4275 * WordPress dependencies 4276 */ 4277 4278 4279 /** 4280 * Returns the first items from list that are present on state. 4281 * 4282 * @param {Array} list New array. 4283 * @param {Array} state Current state. 4284 * @return {Array} First items present iin state. 4285 */ 4286 4287 function getFirstItemsPresentInState(list, state) { 4288 var firstItems = []; 4289 4290 for (var i = 0; i < list.length; i++) { 4291 var item = list[i]; 4292 4293 if (!state.includes(item)) { 4294 break; 4295 } 4296 4297 firstItems.push(item); 4298 } 4299 4300 return firstItems; 4301 } 4302 /** 4303 * Reducer keeping track of a list of appended items. 4304 * 4305 * @param {Array} state Current state 4306 * @param {Object} action Action 4307 * 4308 * @return {Array} update state. 4309 */ 4310 4311 4312 function listReducer(state, action) { 4313 if (action.type === 'reset') { 4314 return action.list; 4315 } 4316 4317 if (action.type === 'append') { 4318 return [].concat(Object(toConsumableArray["a" /* default */])(state), [action.item]); 4319 } 4320 4321 return state; 4322 } 4323 /** 4324 * React hook returns an array which items get asynchronously appended from a source array. 4325 * This behavior is useful if we want to render a list of items asynchronously for performance reasons. 4326 * 4327 * @param {Array} list Source array. 4328 * @return {Array} Async array. 4329 */ 4330 4331 4332 function useAsyncList(list) { 4333 var _useReducer = Object(external_wp_element_["useReducer"])(listReducer, []), 4334 _useReducer2 = Object(slicedToArray["a" /* default */])(_useReducer, 2), 4335 current = _useReducer2[0], 4336 dispatch = _useReducer2[1]; 4337 4338 Object(external_wp_element_["useEffect"])(function () { 4339 // On reset, we keep the first items that were previously rendered. 4340 var firstItems = getFirstItemsPresentInState(list, current); 4341 dispatch({ 4342 type: 'reset', 4343 list: firstItems 4344 }); 4345 var asyncQueue = Object(external_wp_priorityQueue_["createQueue"])(); 4346 4347 var append = function append(index) { 4348 return function () { 4349 if (list.length <= index) { 4350 return; 4351 } 4352 4353 dispatch({ 4354 type: 'append', 4355 item: list[index] 4356 }); 4357 asyncQueue.add({}, append(index + 1)); 4358 }; 4359 }; 4360 4361 asyncQueue.add({}, append(firstItems.length)); 4362 return function () { 4363 return asyncQueue.reset(); 4364 }; 4365 }, [list]); 4366 return current; 4367 } 4368 4369 /* harmony default export */ var use_async_list = (useAsyncList); 4370 4371 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js 4372 4373 4374 /** 4375 * Internal dependencies 4376 */ 4377 4378 /** 4379 * Hook that performs a shallow comparison between the preview value of an object 4380 * and the new one, if there's a difference, it prints it to the console. 4381 * this is useful in performance related work, to check why a component re-renders. 4382 * 4383 * @example 4384 * 4385 * ```jsx 4386 * function MyComponent(props) { 4387 * useWarnOnChange(props); 4388 * 4389 * return "Something"; 4390 * } 4391 * ``` 4392 * 4393 * @param {Object} object Object which changes to compare. 4394 * @param {string} prefix Just a prefix to show when console logging. 4395 */ 4396 4397 function useWarnOnChange(object) { 4398 var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Change detection'; 4399 var previousValues = usePrevious(object); 4400 Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(function (_ref) { 4401 var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 2), 4402 key = _ref2[0], 4403 value = _ref2[1]; 4404 4405 if (value !== object[key]) { 4406 // eslint-disable-next-line no-console 4407 console.warn("".concat(prefix, ": ").concat(key, " key changed:"), value, object[key]); 4408 } 4409 }); 4410 } 4411 4412 /* harmony default export */ var use_warn_on_change = (useWarnOnChange); 4413 4414 // EXTERNAL MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js 4415 var use_memo_one_esm = __webpack_require__(122); 4416 4417 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js 4418 /** 4419 * External dependencies 4420 */ 4421 4422 4423 /** 4424 * WordPress dependencies 4425 */ 4426 4427 4428 /** 4429 * Debounces a function with Lodash's `debounce`. A new debounced function will 4430 * be returned and any scheduled calls cancelled if any of the arguments change, 4431 * including the function to debounce, so please wrap functions created on 4432 * render in components in `useCallback`. 4433 * 4434 * @param {...any} args Arguments passed to Lodash's `debounce`. 4435 * 4436 * @return {Function} Debounced function. 4437 */ 4438 4439 function useDebounce() { 4440 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 4441 args[_key] = arguments[_key]; 4442 } 4443 4444 var debounced = Object(use_memo_one_esm["a" /* useMemoOne */])(function () { 4445 return external_lodash_["debounce"].apply(void 0, args); 4446 }, args); 4447 Object(external_wp_element_["useEffect"])(function () { 4448 return function () { 4449 return debounced.cancel(); 4450 }; 4451 }, [debounced]); 4452 return debounced; 4453 } 4454 4455 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js 4456 /** 4457 * External dependencies 4458 */ 4459 4460 4461 /** 4462 * WordPress dependencies 4463 */ 4464 4465 4466 /** 4467 * Throttles a function with Lodash's `throttle`. A new throttled function will 4468 * be returned and any scheduled calls cancelled if any of the arguments change, 4469 * including the function to throttle, so please wrap functions created on 4470 * render in components in `useCallback`. 4471 * 4472 * @param {...any} args Arguments passed to Lodash's `throttle`. 4473 * 4474 * @return {Function} Throttled function. 4475 */ 4476 4477 function useThrottle() { 4478 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 4479 args[_key] = arguments[_key]; 4480 } 4481 4482 var throttled = Object(use_memo_one_esm["a" /* useMemoOne */])(function () { 4483 return external_lodash_["throttle"].apply(void 0, args); 4484 }, args); 4485 Object(external_wp_element_["useEffect"])(function () { 4486 return function () { 4487 return throttled.cancel(); 4488 }; 4489 }, [throttled]); 4490 return throttled; 4491 } 4492 4493 // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js 4494 // Utils 4495 // Compose helper (aliased flowRight from Lodash) 4496 4497 // Higher-order components 4498 4499 4500 4501 4502 4503 4504 // Hooks 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 /***/ }), 4528 4529 /***/ 5: 4530 /***/ (function(module, __webpack_exports__, __webpack_require__) { 4531 4532 "use strict"; 4533 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); 4534 function _defineProperty(obj, key, value) { 4535 if (key in obj) { 4536 Object.defineProperty(obj, key, { 4537 value: value, 4538 enumerable: true, 4539 configurable: true, 4540 writable: true 4541 }); 4542 } else { 4543 obj[key] = value; 4544 } 4545 4546 return obj; 4547 } 4548 4549 /***/ }), 4550 4551 /***/ 59: 4552 /***/ (function(module, exports) { 4553 4554 (function() { module.exports = window["wp"]["isShallowEqual"]; }()); 4555 4556 /***/ }), 4557 4558 /***/ 62: 4559 /***/ (function(module, exports, __webpack_require__) { 4560 4561 /** 4562 * Memize options object. 4563 * 4564 * @typedef MemizeOptions 4565 * 4566 * @property {number} [maxSize] Maximum size of the cache. 4567 */ 4568 4569 /** 4570 * Internal cache entry. 4571 * 4572 * @typedef MemizeCacheNode 4573 * 4574 * @property {?MemizeCacheNode|undefined} [prev] Previous node. 4575 * @property {?MemizeCacheNode|undefined} [next] Next node. 4576 * @property {Array<*>} args Function arguments for cache 4577 * entry. 4578 * @property {*} val Function result. 4579 */ 4580 4581 /** 4582 * Properties of the enhanced function for controlling cache. 4583 * 4584 * @typedef MemizeMemoizedFunction 4585 * 4586 * @property {()=>void} clear Clear the cache. 4587 */ 4588 4589 /** 4590 * Accepts a function to be memoized, and returns a new memoized function, with 4591 * optional options. 4592 * 4593 * @template {Function} F 4594 * 4595 * @param {F} fn Function to memoize. 4596 * @param {MemizeOptions} [options] Options object. 4597 * 4598 * @return {F & MemizeMemoizedFunction} Memoized function. 4599 */ 4600 function memize( fn, options ) { 4601 var size = 0; 4602 4603 /** @type {?MemizeCacheNode|undefined} */ 4604 var head; 4605 4606 /** @type {?MemizeCacheNode|undefined} */ 4607 var tail; 4608 4609 options = options || {}; 4610 4611 function memoized( /* ...args */ ) { 4612 var node = head, 4613 len = arguments.length, 4614 args, i; 4615 4616 searchCache: while ( node ) { 4617 // Perform a shallow equality test to confirm that whether the node 4618 // under test is a candidate for the arguments passed. Two arrays 4619 // are shallowly equal if their length matches and each entry is 4620 // strictly equal between the two sets. Avoid abstracting to a 4621 // function which could incur an arguments leaking deoptimization. 4622 4623 // Check whether node arguments match arguments length 4624 if ( node.args.length !== arguments.length ) { 4625 node = node.next; 4626 continue; 4627 } 4628 4629 // Check whether node arguments match arguments values 4630 for ( i = 0; i < len; i++ ) { 4631 if ( node.args[ i ] !== arguments[ i ] ) { 4632 node = node.next; 4633 continue searchCache; 4634 } 4635 } 4636 4637 // At this point we can assume we've found a match 4638 4639 // Surface matched node to head if not already 4640 if ( node !== head ) { 4641 // As tail, shift to previous. Must only shift if not also 4642 // head, since if both head and tail, there is no previous. 4643 if ( node === tail ) { 4644 tail = node.prev; 4645 } 4646 4647 // Adjust siblings to point to each other. If node was tail, 4648 // this also handles new tail's empty `next` assignment. 4649 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; 4650 if ( node.next ) { 4651 node.next.prev = node.prev; 4652 } 4653 4654 node.next = head; 4655 node.prev = null; 4656 /** @type {MemizeCacheNode} */ ( head ).prev = node; 4657 head = node; 4658 } 4659 4660 // Return immediately 4661 return node.val; 4662 } 4663 4664 // No cached value found. Continue to insertion phase: 4665 4666 // Create a copy of arguments (avoid leaking deoptimization) 4667 args = new Array( len ); 4668 for ( i = 0; i < len; i++ ) { 4669 args[ i ] = arguments[ i ]; 4670 } 4671 4672 node = { 4673 args: args, 4674 4675 // Generate the result from original function 4676 val: fn.apply( null, args ), 4677 }; 4678 4679 // Don't need to check whether node is already head, since it would 4680 // have been returned above already if it was 4681 4682 // Shift existing head down list 4683 if ( head ) { 4684 head.prev = node; 4685 node.next = head; 4686 } else { 4687 // If no head, follows that there's no tail (at initial or reset) 4688 tail = node; 4689 } 4690 4691 // Trim tail if we're reached max size and are pending cache insertion 4692 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { 4693 tail = /** @type {MemizeCacheNode} */ ( tail ).prev; 4694 /** @type {MemizeCacheNode} */ ( tail ).next = null; 4695 } else { 4696 size++; 4697 } 4698 4699 head = node; 4700 4701 return node.val; 4702 } 4703 4704 memoized.clear = function() { 4705 head = null; 4706 tail = null; 4707 size = 0; 4708 }; 4709 4710 if ( false ) {} 4711 4712 // Ignore reason: There's not a clear solution to create an intersection of 4713 // the function with additional properties, where the goal is to retain the 4714 // function signature of the incoming argument and add control properties 4715 // on the return value. 4716 4717 // @ts-ignore 4718 return memoized; 4719 } 4720 4721 module.exports = memize; 4722 4723 4724 /***/ }), 4725 4726 /***/ 8: 4727 /***/ (function(module, __webpack_exports__, __webpack_require__) { 4728 4729 "use strict"; 4730 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); 4731 function _extends() { 4732 _extends = Object.assign || function (target) { 4733 for (var i = 1; i < arguments.length; i++) { 4734 var source = arguments[i]; 4735 4736 for (var key in source) { 4737 if (Object.prototype.hasOwnProperty.call(source, key)) { 4738 target[key] = source[key]; 4739 } 4740 } 4741 } 4742 4743 return target; 4744 }; 4745 4746 return _extends.apply(this, arguments); 4747 } 4748 4749 /***/ }), 4750 4751 /***/ 81: 4752 /***/ (function(module, __webpack_exports__, __webpack_require__) { 4753 4754 "use strict"; 4755 function mergeRefs(refs) { 4756 return function (value) { 4757 refs.forEach(function (ref) { 4758 if (typeof ref === "function") { 4759 ref(value); 4760 } else if (ref != null) { 4761 ref.current = value; 4762 } 4763 }); 4764 }; 4765 } 4766 4767 /* harmony default export */ __webpack_exports__["a"] = (mergeRefs); 4768 4769 4770 /***/ }) 4771 4772 /******/ });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu Jan 28 08:20:02 2021 | Cross-referenced by PHPXref |