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