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