[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ var __webpack_modules__ = ({ 3 4 /***/ 6689: 5 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 6 7 "use strict"; 8 /* harmony export */ __webpack_require__.d(__webpack_exports__, { 9 /* harmony export */ createUndoManager: () => (/* binding */ createUndoManager) 10 /* harmony export */ }); 11 /* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(923); 12 /* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__); 13 /** 14 * WordPress dependencies 15 */ 16 17 18 /** @typedef {import('./types').HistoryRecord} HistoryRecord */ 19 /** @typedef {import('./types').HistoryChange} HistoryChange */ 20 /** @typedef {import('./types').HistoryChanges} HistoryChanges */ 21 /** @typedef {import('./types').UndoManager} UndoManager */ 22 23 /** 24 * Merge changes for a single item into a record of changes. 25 * 26 * @param {Record< string, HistoryChange >} changes1 Previous changes 27 * @param {Record< string, HistoryChange >} changes2 NextChanges 28 * 29 * @return {Record< string, HistoryChange >} Merged changes 30 */ 31 function mergeHistoryChanges(changes1, changes2) { 32 /** 33 * @type {Record< string, HistoryChange >} 34 */ 35 const newChanges = { 36 ...changes1 37 }; 38 Object.entries(changes2).forEach(([key, value]) => { 39 if (newChanges[key]) { 40 newChanges[key] = { 41 ...newChanges[key], 42 to: value.to 43 }; 44 } else { 45 newChanges[key] = value; 46 } 47 }); 48 return newChanges; 49 } 50 51 /** 52 * Adds history changes for a single item into a record of changes. 53 * 54 * @param {HistoryRecord} record The record to merge into. 55 * @param {HistoryChanges} changes The changes to merge. 56 */ 57 const addHistoryChangesIntoRecord = (record, changes) => { 58 const existingChangesIndex = record?.findIndex(({ 59 id: recordIdentifier 60 }) => { 61 return typeof recordIdentifier === 'string' ? recordIdentifier === changes.id : _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(recordIdentifier, changes.id); 62 }); 63 const nextRecord = [...record]; 64 if (existingChangesIndex !== -1) { 65 // If the edit is already in the stack leave the initial "from" value. 66 nextRecord[existingChangesIndex] = { 67 id: changes.id, 68 changes: mergeHistoryChanges(nextRecord[existingChangesIndex].changes, changes.changes) 69 }; 70 } else { 71 nextRecord.push(changes); 72 } 73 return nextRecord; 74 }; 75 76 /** 77 * Creates an undo manager. 78 * 79 * @return {UndoManager} Undo manager. 80 */ 81 function createUndoManager() { 82 /** 83 * @type {HistoryRecord[]} 84 */ 85 let history = []; 86 /** 87 * @type {HistoryRecord} 88 */ 89 let stagedRecord = []; 90 /** 91 * @type {number} 92 */ 93 let offset = 0; 94 const dropPendingRedos = () => { 95 history = history.slice(0, offset || undefined); 96 offset = 0; 97 }; 98 const appendStagedRecordToLatestHistoryRecord = () => { 99 var _history$index; 100 const index = history.length === 0 ? 0 : history.length - 1; 101 let latestRecord = (_history$index = history[index]) !== null && _history$index !== void 0 ? _history$index : []; 102 stagedRecord.forEach(changes => { 103 latestRecord = addHistoryChangesIntoRecord(latestRecord, changes); 104 }); 105 stagedRecord = []; 106 history[index] = latestRecord; 107 }; 108 109 /** 110 * Checks whether a record is empty. 111 * A record is considered empty if it the changes keep the same values. 112 * Also updates to function values are ignored. 113 * 114 * @param {HistoryRecord} record 115 * @return {boolean} Whether the record is empty. 116 */ 117 const isRecordEmpty = record => { 118 const filteredRecord = record.filter(({ 119 changes 120 }) => { 121 return Object.values(changes).some(({ 122 from, 123 to 124 }) => typeof from !== 'function' && typeof to !== 'function' && !_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(from, to)); 125 }); 126 return !filteredRecord.length; 127 }; 128 return { 129 /** 130 * Record changes into the history. 131 * 132 * @param {HistoryRecord=} record A record of changes to record. 133 * @param {boolean} isStaged Whether to immediately create an undo point or not. 134 */ 135 addRecord(record, isStaged = false) { 136 const isEmpty = !record || isRecordEmpty(record); 137 if (isStaged) { 138 if (isEmpty) { 139 return; 140 } 141 record.forEach(changes => { 142 stagedRecord = addHistoryChangesIntoRecord(stagedRecord, changes); 143 }); 144 } else { 145 dropPendingRedos(); 146 if (stagedRecord.length) { 147 appendStagedRecordToLatestHistoryRecord(); 148 } 149 if (isEmpty) { 150 return; 151 } 152 history.push(record); 153 } 154 }, 155 undo() { 156 if (stagedRecord.length) { 157 dropPendingRedos(); 158 appendStagedRecordToLatestHistoryRecord(); 159 } 160 const undoRecord = history[history.length - 1 + offset]; 161 if (!undoRecord) { 162 return; 163 } 164 offset -= 1; 165 return undoRecord; 166 }, 167 redo() { 168 const redoRecord = history[history.length + offset]; 169 if (!redoRecord) { 170 return; 171 } 172 offset += 1; 173 return redoRecord; 174 }, 175 hasUndo() { 176 return !!history[history.length - 1 + offset]; 177 }, 178 hasRedo() { 179 return !!history[history.length + offset]; 180 } 181 }; 182 } 183 184 185 /***/ }), 186 187 /***/ 3758: 188 /***/ (function(module) { 189 190 /*! 191 * clipboard.js v2.0.11 192 * https://clipboardjs.com/ 193 * 194 * Licensed MIT © Zeno Rocha 195 */ 196 (function webpackUniversalModuleDefinition(root, factory) { 197 if(true) 198 module.exports = factory(); 199 else {} 200 })(this, function() { 201 return /******/ (function() { // webpackBootstrap 202 /******/ var __webpack_modules__ = ({ 203 204 /***/ 686: 205 /***/ (function(__unused_webpack_module, __nested_webpack_exports__, __nested_webpack_require_623__) { 206 207 "use strict"; 208 209 // EXPORTS 210 __nested_webpack_require_623__.d(__nested_webpack_exports__, { 211 "default": function() { return /* binding */ clipboard; } 212 }); 213 214 // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js 215 var tiny_emitter = __nested_webpack_require_623__(279); 216 var tiny_emitter_default = /*#__PURE__*/__nested_webpack_require_623__.n(tiny_emitter); 217 // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js 218 var listen = __nested_webpack_require_623__(370); 219 var listen_default = /*#__PURE__*/__nested_webpack_require_623__.n(listen); 220 // EXTERNAL MODULE: ./node_modules/select/src/select.js 221 var src_select = __nested_webpack_require_623__(817); 222 var select_default = /*#__PURE__*/__nested_webpack_require_623__.n(src_select); 223 ;// CONCATENATED MODULE: ./src/common/command.js 224 /** 225 * Executes a given operation type. 226 * @param {String} type 227 * @return {Boolean} 228 */ 229 function command(type) { 230 try { 231 return document.execCommand(type); 232 } catch (err) { 233 return false; 234 } 235 } 236 ;// CONCATENATED MODULE: ./src/actions/cut.js 237 238 239 /** 240 * Cut action wrapper. 241 * @param {String|HTMLElement} target 242 * @return {String} 243 */ 244 245 var ClipboardActionCut = function ClipboardActionCut(target) { 246 var selectedText = select_default()(target); 247 command('cut'); 248 return selectedText; 249 }; 250 251 /* harmony default export */ var actions_cut = (ClipboardActionCut); 252 ;// CONCATENATED MODULE: ./src/common/create-fake-element.js 253 /** 254 * Creates a fake textarea element with a value. 255 * @param {String} value 256 * @return {HTMLElement} 257 */ 258 function createFakeElement(value) { 259 var isRTL = document.documentElement.getAttribute('dir') === 'rtl'; 260 var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS 261 262 fakeElement.style.fontSize = '12pt'; // Reset box model 263 264 fakeElement.style.border = '0'; 265 fakeElement.style.padding = '0'; 266 fakeElement.style.margin = '0'; // Move element out of screen horizontally 267 268 fakeElement.style.position = 'absolute'; 269 fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically 270 271 var yPosition = window.pageYOffset || document.documentElement.scrollTop; 272 fakeElement.style.top = "".concat(yPosition, "px"); 273 fakeElement.setAttribute('readonly', ''); 274 fakeElement.value = value; 275 return fakeElement; 276 } 277 ;// CONCATENATED MODULE: ./src/actions/copy.js 278 279 280 281 /** 282 * Create fake copy action wrapper using a fake element. 283 * @param {String} target 284 * @param {Object} options 285 * @return {String} 286 */ 287 288 var fakeCopyAction = function fakeCopyAction(value, options) { 289 var fakeElement = createFakeElement(value); 290 options.container.appendChild(fakeElement); 291 var selectedText = select_default()(fakeElement); 292 command('copy'); 293 fakeElement.remove(); 294 return selectedText; 295 }; 296 /** 297 * Copy action wrapper. 298 * @param {String|HTMLElement} target 299 * @param {Object} options 300 * @return {String} 301 */ 302 303 304 var ClipboardActionCopy = function ClipboardActionCopy(target) { 305 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 306 container: document.body 307 }; 308 var selectedText = ''; 309 310 if (typeof target === 'string') { 311 selectedText = fakeCopyAction(target, options); 312 } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) { 313 // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange 314 selectedText = fakeCopyAction(target.value, options); 315 } else { 316 selectedText = select_default()(target); 317 command('copy'); 318 } 319 320 return selectedText; 321 }; 322 323 /* harmony default export */ var actions_copy = (ClipboardActionCopy); 324 ;// CONCATENATED MODULE: ./src/actions/default.js 325 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); } 326 327 328 329 /** 330 * Inner function which performs selection from either `text` or `target` 331 * properties and then executes copy or cut operations. 332 * @param {Object} options 333 */ 334 335 var ClipboardActionDefault = function ClipboardActionDefault() { 336 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 337 // Defines base properties passed from constructor. 338 var _options$action = options.action, 339 action = _options$action === void 0 ? 'copy' : _options$action, 340 container = options.container, 341 target = options.target, 342 text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'. 343 344 if (action !== 'copy' && action !== 'cut') { 345 throw new Error('Invalid "action" value, use either "copy" or "cut"'); 346 } // Sets the `target` property using an element that will be have its content copied. 347 348 349 if (target !== undefined) { 350 if (target && _typeof(target) === 'object' && target.nodeType === 1) { 351 if (action === 'copy' && target.hasAttribute('disabled')) { 352 throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); 353 } 354 355 if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { 356 throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); 357 } 358 } else { 359 throw new Error('Invalid "target" value, use a valid Element'); 360 } 361 } // Define selection strategy based on `text` property. 362 363 364 if (text) { 365 return actions_copy(text, { 366 container: container 367 }); 368 } // Defines which selection strategy based on `target` property. 369 370 371 if (target) { 372 return action === 'cut' ? actions_cut(target) : actions_copy(target, { 373 container: container 374 }); 375 } 376 }; 377 378 /* harmony default export */ var actions_default = (ClipboardActionDefault); 379 ;// CONCATENATED MODULE: ./src/clipboard.js 380 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); } 381 382 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 383 384 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); } } 385 386 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 387 388 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); } 389 390 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 391 392 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); }; } 393 394 function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 395 396 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 397 398 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; } } 399 400 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 401 402 403 404 405 406 407 /** 408 * Helper function to retrieve attribute value. 409 * @param {String} suffix 410 * @param {Element} element 411 */ 412 413 function getAttributeValue(suffix, element) { 414 var attribute = "data-clipboard-".concat(suffix); 415 416 if (!element.hasAttribute(attribute)) { 417 return; 418 } 419 420 return element.getAttribute(attribute); 421 } 422 /** 423 * Base class which takes one or more elements, adds event listeners to them, 424 * and instantiates a new `ClipboardAction` on each click. 425 */ 426 427 428 var Clipboard = /*#__PURE__*/function (_Emitter) { 429 _inherits(Clipboard, _Emitter); 430 431 var _super = _createSuper(Clipboard); 432 433 /** 434 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger 435 * @param {Object} options 436 */ 437 function Clipboard(trigger, options) { 438 var _this; 439 440 _classCallCheck(this, Clipboard); 441 442 _this = _super.call(this); 443 444 _this.resolveOptions(options); 445 446 _this.listenClick(trigger); 447 448 return _this; 449 } 450 /** 451 * Defines if attributes would be resolved using internal setter functions 452 * or custom functions that were passed in the constructor. 453 * @param {Object} options 454 */ 455 456 457 _createClass(Clipboard, [{ 458 key: "resolveOptions", 459 value: function resolveOptions() { 460 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 461 this.action = typeof options.action === 'function' ? options.action : this.defaultAction; 462 this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; 463 this.text = typeof options.text === 'function' ? options.text : this.defaultText; 464 this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body; 465 } 466 /** 467 * Adds a click event listener to the passed trigger. 468 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger 469 */ 470 471 }, { 472 key: "listenClick", 473 value: function listenClick(trigger) { 474 var _this2 = this; 475 476 this.listener = listen_default()(trigger, 'click', function (e) { 477 return _this2.onClick(e); 478 }); 479 } 480 /** 481 * Defines a new `ClipboardAction` on each click event. 482 * @param {Event} e 483 */ 484 485 }, { 486 key: "onClick", 487 value: function onClick(e) { 488 var trigger = e.delegateTarget || e.currentTarget; 489 var action = this.action(trigger) || 'copy'; 490 var text = actions_default({ 491 action: action, 492 container: this.container, 493 target: this.target(trigger), 494 text: this.text(trigger) 495 }); // Fires an event based on the copy operation result. 496 497 this.emit(text ? 'success' : 'error', { 498 action: action, 499 text: text, 500 trigger: trigger, 501 clearSelection: function clearSelection() { 502 if (trigger) { 503 trigger.focus(); 504 } 505 506 window.getSelection().removeAllRanges(); 507 } 508 }); 509 } 510 /** 511 * Default `action` lookup function. 512 * @param {Element} trigger 513 */ 514 515 }, { 516 key: "defaultAction", 517 value: function defaultAction(trigger) { 518 return getAttributeValue('action', trigger); 519 } 520 /** 521 * Default `target` lookup function. 522 * @param {Element} trigger 523 */ 524 525 }, { 526 key: "defaultTarget", 527 value: function defaultTarget(trigger) { 528 var selector = getAttributeValue('target', trigger); 529 530 if (selector) { 531 return document.querySelector(selector); 532 } 533 } 534 /** 535 * Allow fire programmatically a copy action 536 * @param {String|HTMLElement} target 537 * @param {Object} options 538 * @returns Text copied. 539 */ 540 541 }, { 542 key: "defaultText", 543 544 /** 545 * Default `text` lookup function. 546 * @param {Element} trigger 547 */ 548 value: function defaultText(trigger) { 549 return getAttributeValue('text', trigger); 550 } 551 /** 552 * Destroy lifecycle. 553 */ 554 555 }, { 556 key: "destroy", 557 value: function destroy() { 558 this.listener.destroy(); 559 } 560 }], [{ 561 key: "copy", 562 value: function copy(target) { 563 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 564 container: document.body 565 }; 566 return actions_copy(target, options); 567 } 568 /** 569 * Allow fire programmatically a cut action 570 * @param {String|HTMLElement} target 571 * @returns Text cutted. 572 */ 573 574 }, { 575 key: "cut", 576 value: function cut(target) { 577 return actions_cut(target); 578 } 579 /** 580 * Returns the support of the given action, or all actions if no action is 581 * given. 582 * @param {String} [action] 583 */ 584 585 }, { 586 key: "isSupported", 587 value: function isSupported() { 588 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; 589 var actions = typeof action === 'string' ? [action] : action; 590 var support = !!document.queryCommandSupported; 591 actions.forEach(function (action) { 592 support = support && !!document.queryCommandSupported(action); 593 }); 594 return support; 595 } 596 }]); 597 598 return Clipboard; 599 }((tiny_emitter_default())); 600 601 /* harmony default export */ var clipboard = (Clipboard); 602 603 /***/ }), 604 605 /***/ 828: 606 /***/ (function(module) { 607 608 var DOCUMENT_NODE_TYPE = 9; 609 610 /** 611 * A polyfill for Element.matches() 612 */ 613 if (typeof Element !== 'undefined' && !Element.prototype.matches) { 614 var proto = Element.prototype; 615 616 proto.matches = proto.matchesSelector || 617 proto.mozMatchesSelector || 618 proto.msMatchesSelector || 619 proto.oMatchesSelector || 620 proto.webkitMatchesSelector; 621 } 622 623 /** 624 * Finds the closest parent that matches a selector. 625 * 626 * @param {Element} element 627 * @param {String} selector 628 * @return {Function} 629 */ 630 function closest (element, selector) { 631 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { 632 if (typeof element.matches === 'function' && 633 element.matches(selector)) { 634 return element; 635 } 636 element = element.parentNode; 637 } 638 } 639 640 module.exports = closest; 641 642 643 /***/ }), 644 645 /***/ 438: 646 /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_15749__) { 647 648 var closest = __nested_webpack_require_15749__(828); 649 650 /** 651 * Delegates event to a selector. 652 * 653 * @param {Element} element 654 * @param {String} selector 655 * @param {String} type 656 * @param {Function} callback 657 * @param {Boolean} useCapture 658 * @return {Object} 659 */ 660 function _delegate(element, selector, type, callback, useCapture) { 661 var listenerFn = listener.apply(this, arguments); 662 663 element.addEventListener(type, listenerFn, useCapture); 664 665 return { 666 destroy: function() { 667 element.removeEventListener(type, listenerFn, useCapture); 668 } 669 } 670 } 671 672 /** 673 * Delegates event to a selector. 674 * 675 * @param {Element|String|Array} [elements] 676 * @param {String} selector 677 * @param {String} type 678 * @param {Function} callback 679 * @param {Boolean} useCapture 680 * @return {Object} 681 */ 682 function delegate(elements, selector, type, callback, useCapture) { 683 // Handle the regular Element usage 684 if (typeof elements.addEventListener === 'function') { 685 return _delegate.apply(null, arguments); 686 } 687 688 // Handle Element-less usage, it defaults to global delegation 689 if (typeof type === 'function') { 690 // Use `document` as the first parameter, then apply arguments 691 // This is a short way to .unshift `arguments` without running into deoptimizations 692 return _delegate.bind(null, document).apply(null, arguments); 693 } 694 695 // Handle Selector-based usage 696 if (typeof elements === 'string') { 697 elements = document.querySelectorAll(elements); 698 } 699 700 // Handle Array-like based usage 701 return Array.prototype.map.call(elements, function (element) { 702 return _delegate(element, selector, type, callback, useCapture); 703 }); 704 } 705 706 /** 707 * Finds closest match and invokes callback. 708 * 709 * @param {Element} element 710 * @param {String} selector 711 * @param {String} type 712 * @param {Function} callback 713 * @return {Function} 714 */ 715 function listener(element, selector, type, callback) { 716 return function(e) { 717 e.delegateTarget = closest(e.target, selector); 718 719 if (e.delegateTarget) { 720 callback.call(element, e); 721 } 722 } 723 } 724 725 module.exports = delegate; 726 727 728 /***/ }), 729 730 /***/ 879: 731 /***/ (function(__unused_webpack_module, exports) { 732 733 /** 734 * Check if argument is a HTML element. 735 * 736 * @param {Object} value 737 * @return {Boolean} 738 */ 739 exports.node = function(value) { 740 return value !== undefined 741 && value instanceof HTMLElement 742 && value.nodeType === 1; 743 }; 744 745 /** 746 * Check if argument is a list of HTML elements. 747 * 748 * @param {Object} value 749 * @return {Boolean} 750 */ 751 exports.nodeList = function(value) { 752 var type = Object.prototype.toString.call(value); 753 754 return value !== undefined 755 && (type === '[object NodeList]' || type === '[object HTMLCollection]') 756 && ('length' in value) 757 && (value.length === 0 || exports.node(value[0])); 758 }; 759 760 /** 761 * Check if argument is a string. 762 * 763 * @param {Object} value 764 * @return {Boolean} 765 */ 766 exports.string = function(value) { 767 return typeof value === 'string' 768 || value instanceof String; 769 }; 770 771 /** 772 * Check if argument is a function. 773 * 774 * @param {Object} value 775 * @return {Boolean} 776 */ 777 exports.fn = function(value) { 778 var type = Object.prototype.toString.call(value); 779 780 return type === '[object Function]'; 781 }; 782 783 784 /***/ }), 785 786 /***/ 370: 787 /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_19113__) { 788 789 var is = __nested_webpack_require_19113__(879); 790 var delegate = __nested_webpack_require_19113__(438); 791 792 /** 793 * Validates all params and calls the right 794 * listener function based on its target type. 795 * 796 * @param {String|HTMLElement|HTMLCollection|NodeList} target 797 * @param {String} type 798 * @param {Function} callback 799 * @return {Object} 800 */ 801 function listen(target, type, callback) { 802 if (!target && !type && !callback) { 803 throw new Error('Missing required arguments'); 804 } 805 806 if (!is.string(type)) { 807 throw new TypeError('Second argument must be a String'); 808 } 809 810 if (!is.fn(callback)) { 811 throw new TypeError('Third argument must be a Function'); 812 } 813 814 if (is.node(target)) { 815 return listenNode(target, type, callback); 816 } 817 else if (is.nodeList(target)) { 818 return listenNodeList(target, type, callback); 819 } 820 else if (is.string(target)) { 821 return listenSelector(target, type, callback); 822 } 823 else { 824 throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); 825 } 826 } 827 828 /** 829 * Adds an event listener to a HTML element 830 * and returns a remove listener function. 831 * 832 * @param {HTMLElement} node 833 * @param {String} type 834 * @param {Function} callback 835 * @return {Object} 836 */ 837 function listenNode(node, type, callback) { 838 node.addEventListener(type, callback); 839 840 return { 841 destroy: function() { 842 node.removeEventListener(type, callback); 843 } 844 } 845 } 846 847 /** 848 * Add an event listener to a list of HTML elements 849 * and returns a remove listener function. 850 * 851 * @param {NodeList|HTMLCollection} nodeList 852 * @param {String} type 853 * @param {Function} callback 854 * @return {Object} 855 */ 856 function listenNodeList(nodeList, type, callback) { 857 Array.prototype.forEach.call(nodeList, function(node) { 858 node.addEventListener(type, callback); 859 }); 860 861 return { 862 destroy: function() { 863 Array.prototype.forEach.call(nodeList, function(node) { 864 node.removeEventListener(type, callback); 865 }); 866 } 867 } 868 } 869 870 /** 871 * Add an event listener to a selector 872 * and returns a remove listener function. 873 * 874 * @param {String} selector 875 * @param {String} type 876 * @param {Function} callback 877 * @return {Object} 878 */ 879 function listenSelector(selector, type, callback) { 880 return delegate(document.body, selector, type, callback); 881 } 882 883 module.exports = listen; 884 885 886 /***/ }), 887 888 /***/ 817: 889 /***/ (function(module) { 890 891 function select(element) { 892 var selectedText; 893 894 if (element.nodeName === 'SELECT') { 895 element.focus(); 896 897 selectedText = element.value; 898 } 899 else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { 900 var isReadOnly = element.hasAttribute('readonly'); 901 902 if (!isReadOnly) { 903 element.setAttribute('readonly', ''); 904 } 905 906 element.select(); 907 element.setSelectionRange(0, element.value.length); 908 909 if (!isReadOnly) { 910 element.removeAttribute('readonly'); 911 } 912 913 selectedText = element.value; 914 } 915 else { 916 if (element.hasAttribute('contenteditable')) { 917 element.focus(); 918 } 919 920 var selection = window.getSelection(); 921 var range = document.createRange(); 922 923 range.selectNodeContents(element); 924 selection.removeAllRanges(); 925 selection.addRange(range); 926 927 selectedText = selection.toString(); 928 } 929 930 return selectedText; 931 } 932 933 module.exports = select; 934 935 936 /***/ }), 937 938 /***/ 279: 939 /***/ (function(module) { 940 941 function E () { 942 // Keep this empty so it's easier to inherit from 943 // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) 944 } 945 946 E.prototype = { 947 on: function (name, callback, ctx) { 948 var e = this.e || (this.e = {}); 949 950 (e[name] || (e[name] = [])).push({ 951 fn: callback, 952 ctx: ctx 953 }); 954 955 return this; 956 }, 957 958 once: function (name, callback, ctx) { 959 var self = this; 960 function listener () { 961 self.off(name, listener); 962 callback.apply(ctx, arguments); 963 }; 964 965 listener._ = callback 966 return this.on(name, listener, ctx); 967 }, 968 969 emit: function (name) { 970 var data = [].slice.call(arguments, 1); 971 var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); 972 var i = 0; 973 var len = evtArr.length; 974 975 for (i; i < len; i++) { 976 evtArr[i].fn.apply(evtArr[i].ctx, data); 977 } 978 979 return this; 980 }, 981 982 off: function (name, callback) { 983 var e = this.e || (this.e = {}); 984 var evts = e[name]; 985 var liveEvents = []; 986 987 if (evts && callback) { 988 for (var i = 0, len = evts.length; i < len; i++) { 989 if (evts[i].fn !== callback && evts[i].fn._ !== callback) 990 liveEvents.push(evts[i]); 991 } 992 } 993 994 // Remove event from queue to prevent memory leak 995 // Suggested by https://github.com/lazd 996 // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 997 998 (liveEvents.length) 999 ? e[name] = liveEvents 1000 : delete e[name]; 1001 1002 return this; 1003 } 1004 }; 1005 1006 module.exports = E; 1007 module.exports.TinyEmitter = E; 1008 1009 1010 /***/ }) 1011 1012 /******/ }); 1013 /************************************************************************/ 1014 /******/ // The module cache 1015 /******/ var __webpack_module_cache__ = {}; 1016 /******/ 1017 /******/ // The require function 1018 /******/ function __nested_webpack_require_24495__(moduleId) { 1019 /******/ // Check if module is in cache 1020 /******/ if(__webpack_module_cache__[moduleId]) { 1021 /******/ return __webpack_module_cache__[moduleId].exports; 1022 /******/ } 1023 /******/ // Create a new module (and put it into the cache) 1024 /******/ var module = __webpack_module_cache__[moduleId] = { 1025 /******/ // no module.id needed 1026 /******/ // no module.loaded needed 1027 /******/ exports: {} 1028 /******/ }; 1029 /******/ 1030 /******/ // Execute the module function 1031 /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_24495__); 1032 /******/ 1033 /******/ // Return the exports of the module 1034 /******/ return module.exports; 1035 /******/ } 1036 /******/ 1037 /************************************************************************/ 1038 /******/ /* webpack/runtime/compat get default export */ 1039 /******/ !function() { 1040 /******/ // getDefaultExport function for compatibility with non-harmony modules 1041 /******/ __nested_webpack_require_24495__.n = function(module) { 1042 /******/ var getter = module && module.__esModule ? 1043 /******/ function() { return module['default']; } : 1044 /******/ function() { return module; }; 1045 /******/ __nested_webpack_require_24495__.d(getter, { a: getter }); 1046 /******/ return getter; 1047 /******/ }; 1048 /******/ }(); 1049 /******/ 1050 /******/ /* webpack/runtime/define property getters */ 1051 /******/ !function() { 1052 /******/ // define getter functions for harmony exports 1053 /******/ __nested_webpack_require_24495__.d = function(exports, definition) { 1054 /******/ for(var key in definition) { 1055 /******/ if(__nested_webpack_require_24495__.o(definition, key) && !__nested_webpack_require_24495__.o(exports, key)) { 1056 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 1057 /******/ } 1058 /******/ } 1059 /******/ }; 1060 /******/ }(); 1061 /******/ 1062 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 1063 /******/ !function() { 1064 /******/ __nested_webpack_require_24495__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 1065 /******/ }(); 1066 /******/ 1067 /************************************************************************/ 1068 /******/ // module exports must be returned from runtime so entry inlining is disabled 1069 /******/ // startup 1070 /******/ // Load entry module and return exports 1071 /******/ return __nested_webpack_require_24495__(686); 1072 /******/ })() 1073 .default; 1074 }); 1075 1076 /***/ }), 1077 1078 /***/ 1933: 1079 /***/ ((module, exports, __webpack_require__) => { 1080 1081 var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */ 1082 /** 1083 * Copyright 2012-2017 Craig Campbell 1084 * 1085 * Licensed under the Apache License, Version 2.0 (the "License"); 1086 * you may not use this file except in compliance with the License. 1087 * You may obtain a copy of the License at 1088 * 1089 * http://www.apache.org/licenses/LICENSE-2.0 1090 * 1091 * Unless required by applicable law or agreed to in writing, software 1092 * distributed under the License is distributed on an "AS IS" BASIS, 1093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1094 * See the License for the specific language governing permissions and 1095 * limitations under the License. 1096 * 1097 * Mousetrap is a simple keyboard shortcut library for Javascript with 1098 * no external dependencies 1099 * 1100 * @version 1.6.5 1101 * @url craig.is/killing/mice 1102 */ 1103 (function(window, document, undefined) { 1104 1105 // Check if mousetrap is used inside browser, if not, return 1106 if (!window) { 1107 return; 1108 } 1109 1110 /** 1111 * mapping of special keycodes to their corresponding keys 1112 * 1113 * everything in this dictionary cannot use keypress events 1114 * so it has to be here to map to the correct keycodes for 1115 * keyup/keydown events 1116 * 1117 * @type {Object} 1118 */ 1119 var _MAP = { 1120 8: 'backspace', 1121 9: 'tab', 1122 13: 'enter', 1123 16: 'shift', 1124 17: 'ctrl', 1125 18: 'alt', 1126 20: 'capslock', 1127 27: 'esc', 1128 32: 'space', 1129 33: 'pageup', 1130 34: 'pagedown', 1131 35: 'end', 1132 36: 'home', 1133 37: 'left', 1134 38: 'up', 1135 39: 'right', 1136 40: 'down', 1137 45: 'ins', 1138 46: 'del', 1139 91: 'meta', 1140 93: 'meta', 1141 224: 'meta' 1142 }; 1143 1144 /** 1145 * mapping for special characters so they can support 1146 * 1147 * this dictionary is only used incase you want to bind a 1148 * keyup or keydown event to one of these keys 1149 * 1150 * @type {Object} 1151 */ 1152 var _KEYCODE_MAP = { 1153 106: '*', 1154 107: '+', 1155 109: '-', 1156 110: '.', 1157 111 : '/', 1158 186: ';', 1159 187: '=', 1160 188: ',', 1161 189: '-', 1162 190: '.', 1163 191: '/', 1164 192: '`', 1165 219: '[', 1166 220: '\\', 1167 221: ']', 1168 222: '\'' 1169 }; 1170 1171 /** 1172 * this is a mapping of keys that require shift on a US keypad 1173 * back to the non shift equivelents 1174 * 1175 * this is so you can use keyup events with these keys 1176 * 1177 * note that this will only work reliably on US keyboards 1178 * 1179 * @type {Object} 1180 */ 1181 var _SHIFT_MAP = { 1182 '~': '`', 1183 '!': '1', 1184 '@': '2', 1185 '#': '3', 1186 '$': '4', 1187 '%': '5', 1188 '^': '6', 1189 '&': '7', 1190 '*': '8', 1191 '(': '9', 1192 ')': '0', 1193 '_': '-', 1194 '+': '=', 1195 ':': ';', 1196 '\"': '\'', 1197 '<': ',', 1198 '>': '.', 1199 '?': '/', 1200 '|': '\\' 1201 }; 1202 1203 /** 1204 * this is a list of special strings you can use to map 1205 * to modifier keys when you specify your keyboard shortcuts 1206 * 1207 * @type {Object} 1208 */ 1209 var _SPECIAL_ALIASES = { 1210 'option': 'alt', 1211 'command': 'meta', 1212 'return': 'enter', 1213 'escape': 'esc', 1214 'plus': '+', 1215 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl' 1216 }; 1217 1218 /** 1219 * variable to store the flipped version of _MAP from above 1220 * needed to check if we should use keypress or not when no action 1221 * is specified 1222 * 1223 * @type {Object|undefined} 1224 */ 1225 var _REVERSE_MAP; 1226 1227 /** 1228 * loop through the f keys, f1 to f19 and add them to the map 1229 * programatically 1230 */ 1231 for (var i = 1; i < 20; ++i) { 1232 _MAP[111 + i] = 'f' + i; 1233 } 1234 1235 /** 1236 * loop through to map numbers on the numeric keypad 1237 */ 1238 for (i = 0; i <= 9; ++i) { 1239 1240 // This needs to use a string cause otherwise since 0 is falsey 1241 // mousetrap will never fire for numpad 0 pressed as part of a keydown 1242 // event. 1243 // 1244 // @see https://github.com/ccampbell/mousetrap/pull/258 1245 _MAP[i + 96] = i.toString(); 1246 } 1247 1248 /** 1249 * cross browser add event method 1250 * 1251 * @param {Element|HTMLDocument} object 1252 * @param {string} type 1253 * @param {Function} callback 1254 * @returns void 1255 */ 1256 function _addEvent(object, type, callback) { 1257 if (object.addEventListener) { 1258 object.addEventListener(type, callback, false); 1259 return; 1260 } 1261 1262 object.attachEvent('on' + type, callback); 1263 } 1264 1265 /** 1266 * takes the event and returns the key character 1267 * 1268 * @param {Event} e 1269 * @return {string} 1270 */ 1271 function _characterFromEvent(e) { 1272 1273 // for keypress events we should return the character as is 1274 if (e.type == 'keypress') { 1275 var character = String.fromCharCode(e.which); 1276 1277 // if the shift key is not pressed then it is safe to assume 1278 // that we want the character to be lowercase. this means if 1279 // you accidentally have caps lock on then your key bindings 1280 // will continue to work 1281 // 1282 // the only side effect that might not be desired is if you 1283 // bind something like 'A' cause you want to trigger an 1284 // event when capital A is pressed caps lock will no longer 1285 // trigger the event. shift+a will though. 1286 if (!e.shiftKey) { 1287 character = character.toLowerCase(); 1288 } 1289 1290 return character; 1291 } 1292 1293 // for non keypress events the special maps are needed 1294 if (_MAP[e.which]) { 1295 return _MAP[e.which]; 1296 } 1297 1298 if (_KEYCODE_MAP[e.which]) { 1299 return _KEYCODE_MAP[e.which]; 1300 } 1301 1302 // if it is not in the special map 1303 1304 // with keydown and keyup events the character seems to always 1305 // come in as an uppercase character whether you are pressing shift 1306 // or not. we should make sure it is always lowercase for comparisons 1307 return String.fromCharCode(e.which).toLowerCase(); 1308 } 1309 1310 /** 1311 * checks if two arrays are equal 1312 * 1313 * @param {Array} modifiers1 1314 * @param {Array} modifiers2 1315 * @returns {boolean} 1316 */ 1317 function _modifiersMatch(modifiers1, modifiers2) { 1318 return modifiers1.sort().join(',') === modifiers2.sort().join(','); 1319 } 1320 1321 /** 1322 * takes a key event and figures out what the modifiers are 1323 * 1324 * @param {Event} e 1325 * @returns {Array} 1326 */ 1327 function _eventModifiers(e) { 1328 var modifiers = []; 1329 1330 if (e.shiftKey) { 1331 modifiers.push('shift'); 1332 } 1333 1334 if (e.altKey) { 1335 modifiers.push('alt'); 1336 } 1337 1338 if (e.ctrlKey) { 1339 modifiers.push('ctrl'); 1340 } 1341 1342 if (e.metaKey) { 1343 modifiers.push('meta'); 1344 } 1345 1346 return modifiers; 1347 } 1348 1349 /** 1350 * prevents default for this event 1351 * 1352 * @param {Event} e 1353 * @returns void 1354 */ 1355 function _preventDefault(e) { 1356 if (e.preventDefault) { 1357 e.preventDefault(); 1358 return; 1359 } 1360 1361 e.returnValue = false; 1362 } 1363 1364 /** 1365 * stops propogation for this event 1366 * 1367 * @param {Event} e 1368 * @returns void 1369 */ 1370 function _stopPropagation(e) { 1371 if (e.stopPropagation) { 1372 e.stopPropagation(); 1373 return; 1374 } 1375 1376 e.cancelBubble = true; 1377 } 1378 1379 /** 1380 * determines if the keycode specified is a modifier key or not 1381 * 1382 * @param {string} key 1383 * @returns {boolean} 1384 */ 1385 function _isModifier(key) { 1386 return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta'; 1387 } 1388 1389 /** 1390 * reverses the map lookup so that we can look for specific keys 1391 * to see what can and can't use keypress 1392 * 1393 * @return {Object} 1394 */ 1395 function _getReverseMap() { 1396 if (!_REVERSE_MAP) { 1397 _REVERSE_MAP = {}; 1398 for (var key in _MAP) { 1399 1400 // pull out the numeric keypad from here cause keypress should 1401 // be able to detect the keys from the character 1402 if (key > 95 && key < 112) { 1403 continue; 1404 } 1405 1406 if (_MAP.hasOwnProperty(key)) { 1407 _REVERSE_MAP[_MAP[key]] = key; 1408 } 1409 } 1410 } 1411 return _REVERSE_MAP; 1412 } 1413 1414 /** 1415 * picks the best action based on the key combination 1416 * 1417 * @param {string} key - character for key 1418 * @param {Array} modifiers 1419 * @param {string=} action passed in 1420 */ 1421 function _pickBestAction(key, modifiers, action) { 1422 1423 // if no action was picked in we should try to pick the one 1424 // that we think would work best for this key 1425 if (!action) { 1426 action = _getReverseMap()[key] ? 'keydown' : 'keypress'; 1427 } 1428 1429 // modifier keys don't work as expected with keypress, 1430 // switch to keydown 1431 if (action == 'keypress' && modifiers.length) { 1432 action = 'keydown'; 1433 } 1434 1435 return action; 1436 } 1437 1438 /** 1439 * Converts from a string key combination to an array 1440 * 1441 * @param {string} combination like "command+shift+l" 1442 * @return {Array} 1443 */ 1444 function _keysFromString(combination) { 1445 if (combination === '+') { 1446 return ['+']; 1447 } 1448 1449 combination = combination.replace(/\+{2}/g, '+plus'); 1450 return combination.split('+'); 1451 } 1452 1453 /** 1454 * Gets info for a specific key combination 1455 * 1456 * @param {string} combination key combination ("command+s" or "a" or "*") 1457 * @param {string=} action 1458 * @returns {Object} 1459 */ 1460 function _getKeyInfo(combination, action) { 1461 var keys; 1462 var key; 1463 var i; 1464 var modifiers = []; 1465 1466 // take the keys from this pattern and figure out what the actual 1467 // pattern is all about 1468 keys = _keysFromString(combination); 1469 1470 for (i = 0; i < keys.length; ++i) { 1471 key = keys[i]; 1472 1473 // normalize key names 1474 if (_SPECIAL_ALIASES[key]) { 1475 key = _SPECIAL_ALIASES[key]; 1476 } 1477 1478 // if this is not a keypress event then we should 1479 // be smart about using shift keys 1480 // this will only work for US keyboards however 1481 if (action && action != 'keypress' && _SHIFT_MAP[key]) { 1482 key = _SHIFT_MAP[key]; 1483 modifiers.push('shift'); 1484 } 1485 1486 // if this key is a modifier then add it to the list of modifiers 1487 if (_isModifier(key)) { 1488 modifiers.push(key); 1489 } 1490 } 1491 1492 // depending on what the key combination is 1493 // we will try to pick the best event for it 1494 action = _pickBestAction(key, modifiers, action); 1495 1496 return { 1497 key: key, 1498 modifiers: modifiers, 1499 action: action 1500 }; 1501 } 1502 1503 function _belongsTo(element, ancestor) { 1504 if (element === null || element === document) { 1505 return false; 1506 } 1507 1508 if (element === ancestor) { 1509 return true; 1510 } 1511 1512 return _belongsTo(element.parentNode, ancestor); 1513 } 1514 1515 function Mousetrap(targetElement) { 1516 var self = this; 1517 1518 targetElement = targetElement || document; 1519 1520 if (!(self instanceof Mousetrap)) { 1521 return new Mousetrap(targetElement); 1522 } 1523 1524 /** 1525 * element to attach key events to 1526 * 1527 * @type {Element} 1528 */ 1529 self.target = targetElement; 1530 1531 /** 1532 * a list of all the callbacks setup via Mousetrap.bind() 1533 * 1534 * @type {Object} 1535 */ 1536 self._callbacks = {}; 1537 1538 /** 1539 * direct map of string combinations to callbacks used for trigger() 1540 * 1541 * @type {Object} 1542 */ 1543 self._directMap = {}; 1544 1545 /** 1546 * keeps track of what level each sequence is at since multiple 1547 * sequences can start out with the same sequence 1548 * 1549 * @type {Object} 1550 */ 1551 var _sequenceLevels = {}; 1552 1553 /** 1554 * variable to store the setTimeout call 1555 * 1556 * @type {null|number} 1557 */ 1558 var _resetTimer; 1559 1560 /** 1561 * temporary state where we will ignore the next keyup 1562 * 1563 * @type {boolean|string} 1564 */ 1565 var _ignoreNextKeyup = false; 1566 1567 /** 1568 * temporary state where we will ignore the next keypress 1569 * 1570 * @type {boolean} 1571 */ 1572 var _ignoreNextKeypress = false; 1573 1574 /** 1575 * are we currently inside of a sequence? 1576 * type of action ("keyup" or "keydown" or "keypress") or false 1577 * 1578 * @type {boolean|string} 1579 */ 1580 var _nextExpectedAction = false; 1581 1582 /** 1583 * resets all sequence counters except for the ones passed in 1584 * 1585 * @param {Object} doNotReset 1586 * @returns void 1587 */ 1588 function _resetSequences(doNotReset) { 1589 doNotReset = doNotReset || {}; 1590 1591 var activeSequences = false, 1592 key; 1593 1594 for (key in _sequenceLevels) { 1595 if (doNotReset[key]) { 1596 activeSequences = true; 1597 continue; 1598 } 1599 _sequenceLevels[key] = 0; 1600 } 1601 1602 if (!activeSequences) { 1603 _nextExpectedAction = false; 1604 } 1605 } 1606 1607 /** 1608 * finds all callbacks that match based on the keycode, modifiers, 1609 * and action 1610 * 1611 * @param {string} character 1612 * @param {Array} modifiers 1613 * @param {Event|Object} e 1614 * @param {string=} sequenceName - name of the sequence we are looking for 1615 * @param {string=} combination 1616 * @param {number=} level 1617 * @returns {Array} 1618 */ 1619 function _getMatches(character, modifiers, e, sequenceName, combination, level) { 1620 var i; 1621 var callback; 1622 var matches = []; 1623 var action = e.type; 1624 1625 // if there are no events related to this keycode 1626 if (!self._callbacks[character]) { 1627 return []; 1628 } 1629 1630 // if a modifier key is coming up on its own we should allow it 1631 if (action == 'keyup' && _isModifier(character)) { 1632 modifiers = [character]; 1633 } 1634 1635 // loop through all callbacks for the key that was pressed 1636 // and see if any of them match 1637 for (i = 0; i < self._callbacks[character].length; ++i) { 1638 callback = self._callbacks[character][i]; 1639 1640 // if a sequence name is not specified, but this is a sequence at 1641 // the wrong level then move onto the next match 1642 if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) { 1643 continue; 1644 } 1645 1646 // if the action we are looking for doesn't match the action we got 1647 // then we should keep going 1648 if (action != callback.action) { 1649 continue; 1650 } 1651 1652 // if this is a keypress event and the meta key and control key 1653 // are not pressed that means that we need to only look at the 1654 // character, otherwise check the modifiers as well 1655 // 1656 // chrome will not fire a keypress if meta or control is down 1657 // safari will fire a keypress if meta or meta+shift is down 1658 // firefox will fire a keypress if meta or control is down 1659 if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) { 1660 1661 // when you bind a combination or sequence a second time it 1662 // should overwrite the first one. if a sequenceName or 1663 // combination is specified in this call it does just that 1664 // 1665 // @todo make deleting its own method? 1666 var deleteCombo = !sequenceName && callback.combo == combination; 1667 var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level; 1668 if (deleteCombo || deleteSequence) { 1669 self._callbacks[character].splice(i, 1); 1670 } 1671 1672 matches.push(callback); 1673 } 1674 } 1675 1676 return matches; 1677 } 1678 1679 /** 1680 * actually calls the callback function 1681 * 1682 * if your callback function returns false this will use the jquery 1683 * convention - prevent default and stop propogation on the event 1684 * 1685 * @param {Function} callback 1686 * @param {Event} e 1687 * @returns void 1688 */ 1689 function _fireCallback(callback, e, combo, sequence) { 1690 1691 // if this event should not happen stop here 1692 if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) { 1693 return; 1694 } 1695 1696 if (callback(e, combo) === false) { 1697 _preventDefault(e); 1698 _stopPropagation(e); 1699 } 1700 } 1701 1702 /** 1703 * handles a character key event 1704 * 1705 * @param {string} character 1706 * @param {Array} modifiers 1707 * @param {Event} e 1708 * @returns void 1709 */ 1710 self._handleKey = function(character, modifiers, e) { 1711 var callbacks = _getMatches(character, modifiers, e); 1712 var i; 1713 var doNotReset = {}; 1714 var maxLevel = 0; 1715 var processedSequenceCallback = false; 1716 1717 // Calculate the maxLevel for sequences so we can only execute the longest callback sequence 1718 for (i = 0; i < callbacks.length; ++i) { 1719 if (callbacks[i].seq) { 1720 maxLevel = Math.max(maxLevel, callbacks[i].level); 1721 } 1722 } 1723 1724 // loop through matching callbacks for this key event 1725 for (i = 0; i < callbacks.length; ++i) { 1726 1727 // fire for all sequence callbacks 1728 // this is because if for example you have multiple sequences 1729 // bound such as "g i" and "g t" they both need to fire the 1730 // callback for matching g cause otherwise you can only ever 1731 // match the first one 1732 if (callbacks[i].seq) { 1733 1734 // only fire callbacks for the maxLevel to prevent 1735 // subsequences from also firing 1736 // 1737 // for example 'a option b' should not cause 'option b' to fire 1738 // even though 'option b' is part of the other sequence 1739 // 1740 // any sequences that do not match here will be discarded 1741 // below by the _resetSequences call 1742 if (callbacks[i].level != maxLevel) { 1743 continue; 1744 } 1745 1746 processedSequenceCallback = true; 1747 1748 // keep a list of which sequences were matches for later 1749 doNotReset[callbacks[i].seq] = 1; 1750 _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq); 1751 continue; 1752 } 1753 1754 // if there were no sequence matches but we are still here 1755 // that means this is a regular match so we should fire that 1756 if (!processedSequenceCallback) { 1757 _fireCallback(callbacks[i].callback, e, callbacks[i].combo); 1758 } 1759 } 1760 1761 // if the key you pressed matches the type of sequence without 1762 // being a modifier (ie "keyup" or "keypress") then we should 1763 // reset all sequences that were not matched by this event 1764 // 1765 // this is so, for example, if you have the sequence "h a t" and you 1766 // type "h e a r t" it does not match. in this case the "e" will 1767 // cause the sequence to reset 1768 // 1769 // modifier keys are ignored because you can have a sequence 1770 // that contains modifiers such as "enter ctrl+space" and in most 1771 // cases the modifier key will be pressed before the next key 1772 // 1773 // also if you have a sequence such as "ctrl+b a" then pressing the 1774 // "b" key will trigger a "keypress" and a "keydown" 1775 // 1776 // the "keydown" is expected when there is a modifier, but the 1777 // "keypress" ends up matching the _nextExpectedAction since it occurs 1778 // after and that causes the sequence to reset 1779 // 1780 // we ignore keypresses in a sequence that directly follow a keydown 1781 // for the same character 1782 var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress; 1783 if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) { 1784 _resetSequences(doNotReset); 1785 } 1786 1787 _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown'; 1788 }; 1789 1790 /** 1791 * handles a keydown event 1792 * 1793 * @param {Event} e 1794 * @returns void 1795 */ 1796 function _handleKeyEvent(e) { 1797 1798 // normalize e.which for key events 1799 // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion 1800 if (typeof e.which !== 'number') { 1801 e.which = e.keyCode; 1802 } 1803 1804 var character = _characterFromEvent(e); 1805 1806 // no character found then stop 1807 if (!character) { 1808 return; 1809 } 1810 1811 // need to use === for the character check because the character can be 0 1812 if (e.type == 'keyup' && _ignoreNextKeyup === character) { 1813 _ignoreNextKeyup = false; 1814 return; 1815 } 1816 1817 self.handleKey(character, _eventModifiers(e), e); 1818 } 1819 1820 /** 1821 * called to set a 1 second timeout on the specified sequence 1822 * 1823 * this is so after each key press in the sequence you have 1 second 1824 * to press the next key before you have to start over 1825 * 1826 * @returns void 1827 */ 1828 function _resetSequenceTimer() { 1829 clearTimeout(_resetTimer); 1830 _resetTimer = setTimeout(_resetSequences, 1000); 1831 } 1832 1833 /** 1834 * binds a key sequence to an event 1835 * 1836 * @param {string} combo - combo specified in bind call 1837 * @param {Array} keys 1838 * @param {Function} callback 1839 * @param {string=} action 1840 * @returns void 1841 */ 1842 function _bindSequence(combo, keys, callback, action) { 1843 1844 // start off by adding a sequence level record for this combination 1845 // and setting the level to 0 1846 _sequenceLevels[combo] = 0; 1847 1848 /** 1849 * callback to increase the sequence level for this sequence and reset 1850 * all other sequences that were active 1851 * 1852 * @param {string} nextAction 1853 * @returns {Function} 1854 */ 1855 function _increaseSequence(nextAction) { 1856 return function() { 1857 _nextExpectedAction = nextAction; 1858 ++_sequenceLevels[combo]; 1859 _resetSequenceTimer(); 1860 }; 1861 } 1862 1863 /** 1864 * wraps the specified callback inside of another function in order 1865 * to reset all sequence counters as soon as this sequence is done 1866 * 1867 * @param {Event} e 1868 * @returns void 1869 */ 1870 function _callbackAndReset(e) { 1871 _fireCallback(callback, e, combo); 1872 1873 // we should ignore the next key up if the action is key down 1874 // or keypress. this is so if you finish a sequence and 1875 // release the key the final key will not trigger a keyup 1876 if (action !== 'keyup') { 1877 _ignoreNextKeyup = _characterFromEvent(e); 1878 } 1879 1880 // weird race condition if a sequence ends with the key 1881 // another sequence begins with 1882 setTimeout(_resetSequences, 10); 1883 } 1884 1885 // loop through keys one at a time and bind the appropriate callback 1886 // function. for any key leading up to the final one it should 1887 // increase the sequence. after the final, it should reset all sequences 1888 // 1889 // if an action is specified in the original bind call then that will 1890 // be used throughout. otherwise we will pass the action that the 1891 // next key in the sequence should match. this allows a sequence 1892 // to mix and match keypress and keydown events depending on which 1893 // ones are better suited to the key provided 1894 for (var i = 0; i < keys.length; ++i) { 1895 var isFinal = i + 1 === keys.length; 1896 var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action); 1897 _bindSingle(keys[i], wrappedCallback, action, combo, i); 1898 } 1899 } 1900 1901 /** 1902 * binds a single keyboard combination 1903 * 1904 * @param {string} combination 1905 * @param {Function} callback 1906 * @param {string=} action 1907 * @param {string=} sequenceName - name of sequence if part of sequence 1908 * @param {number=} level - what part of the sequence the command is 1909 * @returns void 1910 */ 1911 function _bindSingle(combination, callback, action, sequenceName, level) { 1912 1913 // store a direct mapped reference for use with Mousetrap.trigger 1914 self._directMap[combination + ':' + action] = callback; 1915 1916 // make sure multiple spaces in a row become a single space 1917 combination = combination.replace(/\s+/g, ' '); 1918 1919 var sequence = combination.split(' '); 1920 var info; 1921 1922 // if this pattern is a sequence of keys then run through this method 1923 // to reprocess each pattern one key at a time 1924 if (sequence.length > 1) { 1925 _bindSequence(combination, sequence, callback, action); 1926 return; 1927 } 1928 1929 info = _getKeyInfo(combination, action); 1930 1931 // make sure to initialize array if this is the first time 1932 // a callback is added for this key 1933 self._callbacks[info.key] = self._callbacks[info.key] || []; 1934 1935 // remove an existing match if there is one 1936 _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level); 1937 1938 // add this call back to the array 1939 // if it is a sequence put it at the beginning 1940 // if not put it at the end 1941 // 1942 // this is important because the way these are processed expects 1943 // the sequence ones to come first 1944 self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({ 1945 callback: callback, 1946 modifiers: info.modifiers, 1947 action: info.action, 1948 seq: sequenceName, 1949 level: level, 1950 combo: combination 1951 }); 1952 } 1953 1954 /** 1955 * binds multiple combinations to the same callback 1956 * 1957 * @param {Array} combinations 1958 * @param {Function} callback 1959 * @param {string|undefined} action 1960 * @returns void 1961 */ 1962 self._bindMultiple = function(combinations, callback, action) { 1963 for (var i = 0; i < combinations.length; ++i) { 1964 _bindSingle(combinations[i], callback, action); 1965 } 1966 }; 1967 1968 // start! 1969 _addEvent(targetElement, 'keypress', _handleKeyEvent); 1970 _addEvent(targetElement, 'keydown', _handleKeyEvent); 1971 _addEvent(targetElement, 'keyup', _handleKeyEvent); 1972 } 1973 1974 /** 1975 * binds an event to mousetrap 1976 * 1977 * can be a single key, a combination of keys separated with +, 1978 * an array of keys, or a sequence of keys separated by spaces 1979 * 1980 * be sure to list the modifier keys first to make sure that the 1981 * correct key ends up getting bound (the last key in the pattern) 1982 * 1983 * @param {string|Array} keys 1984 * @param {Function} callback 1985 * @param {string=} action - 'keypress', 'keydown', or 'keyup' 1986 * @returns void 1987 */ 1988 Mousetrap.prototype.bind = function(keys, callback, action) { 1989 var self = this; 1990 keys = keys instanceof Array ? keys : [keys]; 1991 self._bindMultiple.call(self, keys, callback, action); 1992 return self; 1993 }; 1994 1995 /** 1996 * unbinds an event to mousetrap 1997 * 1998 * the unbinding sets the callback function of the specified key combo 1999 * to an empty function and deletes the corresponding key in the 2000 * _directMap dict. 2001 * 2002 * TODO: actually remove this from the _callbacks dictionary instead 2003 * of binding an empty function 2004 * 2005 * the keycombo+action has to be exactly the same as 2006 * it was defined in the bind method 2007 * 2008 * @param {string|Array} keys 2009 * @param {string} action 2010 * @returns void 2011 */ 2012 Mousetrap.prototype.unbind = function(keys, action) { 2013 var self = this; 2014 return self.bind.call(self, keys, function() {}, action); 2015 }; 2016 2017 /** 2018 * triggers an event that has already been bound 2019 * 2020 * @param {string} keys 2021 * @param {string=} action 2022 * @returns void 2023 */ 2024 Mousetrap.prototype.trigger = function(keys, action) { 2025 var self = this; 2026 if (self._directMap[keys + ':' + action]) { 2027 self._directMap[keys + ':' + action]({}, keys); 2028 } 2029 return self; 2030 }; 2031 2032 /** 2033 * resets the library back to its initial state. this is useful 2034 * if you want to clear out the current keyboard shortcuts and bind 2035 * new ones - for example if you switch to another page 2036 * 2037 * @returns void 2038 */ 2039 Mousetrap.prototype.reset = function() { 2040 var self = this; 2041 self._callbacks = {}; 2042 self._directMap = {}; 2043 return self; 2044 }; 2045 2046 /** 2047 * should we stop this event before firing off callbacks 2048 * 2049 * @param {Event} e 2050 * @param {Element} element 2051 * @return {boolean} 2052 */ 2053 Mousetrap.prototype.stopCallback = function(e, element) { 2054 var self = this; 2055 2056 // if the element has the class "mousetrap" then no need to stop 2057 if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) { 2058 return false; 2059 } 2060 2061 if (_belongsTo(element, self.target)) { 2062 return false; 2063 } 2064 2065 // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host, 2066 // not the initial event target in the shadow tree. Note that not all events cross the 2067 // shadow boundary. 2068 // For shadow trees with `mode: 'open'`, the initial event target is the first element in 2069 // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event 2070 // target cannot be obtained. 2071 if ('composedPath' in e && typeof e.composedPath === 'function') { 2072 // For open shadow trees, update `element` so that the following check works. 2073 var initialEventTarget = e.composedPath()[0]; 2074 if (initialEventTarget !== e.target) { 2075 element = initialEventTarget; 2076 } 2077 } 2078 2079 // stop for input, select, and textarea 2080 return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable; 2081 }; 2082 2083 /** 2084 * exposes _handleKey publicly so it can be overwritten by extensions 2085 */ 2086 Mousetrap.prototype.handleKey = function() { 2087 var self = this; 2088 return self._handleKey.apply(self, arguments); 2089 }; 2090 2091 /** 2092 * allow custom key mappings 2093 */ 2094 Mousetrap.addKeycodes = function(object) { 2095 for (var key in object) { 2096 if (object.hasOwnProperty(key)) { 2097 _MAP[key] = object[key]; 2098 } 2099 } 2100 _REVERSE_MAP = null; 2101 }; 2102 2103 /** 2104 * Init the global mousetrap functions 2105 * 2106 * This method is needed to allow the global mousetrap functions to work 2107 * now that mousetrap is a constructor function. 2108 */ 2109 Mousetrap.init = function() { 2110 var documentMousetrap = Mousetrap(document); 2111 for (var method in documentMousetrap) { 2112 if (method.charAt(0) !== '_') { 2113 Mousetrap[method] = (function(method) { 2114 return function() { 2115 return documentMousetrap[method].apply(documentMousetrap, arguments); 2116 }; 2117 } (method)); 2118 } 2119 } 2120 }; 2121 2122 Mousetrap.init(); 2123 2124 // expose mousetrap to the global object 2125 window.Mousetrap = Mousetrap; 2126 2127 // expose as a common js module 2128 if ( true && module.exports) { 2129 module.exports = Mousetrap; 2130 } 2131 2132 // expose mousetrap as an AMD module 2133 if (true) { 2134 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 2135 return Mousetrap; 2136 }).call(exports, __webpack_require__, exports, module), 2137 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 2138 } 2139 }) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null); 2140 2141 2142 /***/ }), 2143 2144 /***/ 5760: 2145 /***/ (() => { 2146 2147 /** 2148 * adds a bindGlobal method to Mousetrap that allows you to 2149 * bind specific keyboard shortcuts that will still work 2150 * inside a text input field 2151 * 2152 * usage: 2153 * Mousetrap.bindGlobal('ctrl+s', _saveChanges); 2154 */ 2155 /* global Mousetrap:true */ 2156 (function(Mousetrap) { 2157 if (! Mousetrap) { 2158 return; 2159 } 2160 var _globalCallbacks = {}; 2161 var _originalStopCallback = Mousetrap.prototype.stopCallback; 2162 2163 Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) { 2164 var self = this; 2165 2166 if (self.paused) { 2167 return true; 2168 } 2169 2170 if (_globalCallbacks[combo] || _globalCallbacks[sequence]) { 2171 return false; 2172 } 2173 2174 return _originalStopCallback.call(self, e, element, combo); 2175 }; 2176 2177 Mousetrap.prototype.bindGlobal = function(keys, callback, action) { 2178 var self = this; 2179 self.bind(keys, callback, action); 2180 2181 if (keys instanceof Array) { 2182 for (var i = 0; i < keys.length; i++) { 2183 _globalCallbacks[keys[i]] = true; 2184 } 2185 return; 2186 } 2187 2188 _globalCallbacks[keys] = true; 2189 }; 2190 2191 Mousetrap.init(); 2192 }) (typeof Mousetrap !== "undefined" ? Mousetrap : undefined); 2193 2194 2195 /***/ }), 2196 2197 /***/ 923: 2198 /***/ ((module) => { 2199 2200 "use strict"; 2201 module.exports = window["wp"]["isShallowEqual"]; 2202 2203 /***/ }) 2204 2205 /******/ }); 2206 /************************************************************************/ 2207 /******/ // The module cache 2208 /******/ var __webpack_module_cache__ = {}; 2209 /******/ 2210 /******/ // The require function 2211 /******/ function __webpack_require__(moduleId) { 2212 /******/ // Check if module is in cache 2213 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 2214 /******/ if (cachedModule !== undefined) { 2215 /******/ return cachedModule.exports; 2216 /******/ } 2217 /******/ // Create a new module (and put it into the cache) 2218 /******/ var module = __webpack_module_cache__[moduleId] = { 2219 /******/ // no module.id needed 2220 /******/ // no module.loaded needed 2221 /******/ exports: {} 2222 /******/ }; 2223 /******/ 2224 /******/ // Execute the module function 2225 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 2226 /******/ 2227 /******/ // Return the exports of the module 2228 /******/ return module.exports; 2229 /******/ } 2230 /******/ 2231 /************************************************************************/ 2232 /******/ /* webpack/runtime/compat get default export */ 2233 /******/ (() => { 2234 /******/ // getDefaultExport function for compatibility with non-harmony modules 2235 /******/ __webpack_require__.n = (module) => { 2236 /******/ var getter = module && module.__esModule ? 2237 /******/ () => (module['default']) : 2238 /******/ () => (module); 2239 /******/ __webpack_require__.d(getter, { a: getter }); 2240 /******/ return getter; 2241 /******/ }; 2242 /******/ })(); 2243 /******/ 2244 /******/ /* webpack/runtime/define property getters */ 2245 /******/ (() => { 2246 /******/ // define getter functions for harmony exports 2247 /******/ __webpack_require__.d = (exports, definition) => { 2248 /******/ for(var key in definition) { 2249 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 2250 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 2251 /******/ } 2252 /******/ } 2253 /******/ }; 2254 /******/ })(); 2255 /******/ 2256 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 2257 /******/ (() => { 2258 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 2259 /******/ })(); 2260 /******/ 2261 /******/ /* webpack/runtime/make namespace object */ 2262 /******/ (() => { 2263 /******/ // define __esModule on exports 2264 /******/ __webpack_require__.r = (exports) => { 2265 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 2266 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 2267 /******/ } 2268 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 2269 /******/ }; 2270 /******/ })(); 2271 /******/ 2272 /************************************************************************/ 2273 var __webpack_exports__ = {}; 2274 // This entry need to be wrapped in an IIFE because it need to be in strict mode. 2275 (() => { 2276 "use strict"; 2277 // ESM COMPAT FLAG 2278 __webpack_require__.r(__webpack_exports__); 2279 2280 // EXPORTS 2281 __webpack_require__.d(__webpack_exports__, { 2282 __experimentalUseDialog: () => (/* reexport */ use_dialog), 2283 __experimentalUseDragging: () => (/* reexport */ useDragging), 2284 __experimentalUseDropZone: () => (/* reexport */ useDropZone), 2285 __experimentalUseFixedWindowList: () => (/* reexport */ useFixedWindowList), 2286 __experimentalUseFocusOutside: () => (/* reexport */ useFocusOutside), 2287 compose: () => (/* reexport */ higher_order_compose), 2288 createHigherOrderComponent: () => (/* reexport */ createHigherOrderComponent), 2289 debounce: () => (/* reexport */ debounce), 2290 ifCondition: () => (/* reexport */ if_condition), 2291 pipe: () => (/* reexport */ higher_order_pipe), 2292 pure: () => (/* reexport */ higher_order_pure), 2293 throttle: () => (/* reexport */ throttle), 2294 useAsyncList: () => (/* reexport */ use_async_list), 2295 useConstrainedTabbing: () => (/* reexport */ use_constrained_tabbing), 2296 useCopyOnClick: () => (/* reexport */ useCopyOnClick), 2297 useCopyToClipboard: () => (/* reexport */ useCopyToClipboard), 2298 useDebounce: () => (/* reexport */ useDebounce), 2299 useDebouncedInput: () => (/* reexport */ useDebouncedInput), 2300 useDisabled: () => (/* reexport */ useDisabled), 2301 useFocusOnMount: () => (/* reexport */ useFocusOnMount), 2302 useFocusReturn: () => (/* reexport */ use_focus_return), 2303 useFocusableIframe: () => (/* reexport */ useFocusableIframe), 2304 useInstanceId: () => (/* reexport */ use_instance_id), 2305 useIsomorphicLayoutEffect: () => (/* reexport */ use_isomorphic_layout_effect), 2306 useKeyboardShortcut: () => (/* reexport */ use_keyboard_shortcut), 2307 useMediaQuery: () => (/* reexport */ useMediaQuery), 2308 useMergeRefs: () => (/* reexport */ useMergeRefs), 2309 usePrevious: () => (/* reexport */ usePrevious), 2310 useReducedMotion: () => (/* reexport */ use_reduced_motion), 2311 useRefEffect: () => (/* reexport */ useRefEffect), 2312 useResizeObserver: () => (/* reexport */ useResizeAware), 2313 useStateWithHistory: () => (/* reexport */ useStateWithHistory), 2314 useThrottle: () => (/* reexport */ useThrottle), 2315 useViewportMatch: () => (/* reexport */ use_viewport_match), 2316 useWarnOnChange: () => (/* reexport */ use_warn_on_change), 2317 withGlobalEvents: () => (/* reexport */ withGlobalEvents), 2318 withInstanceId: () => (/* reexport */ with_instance_id), 2319 withSafeTimeout: () => (/* reexport */ with_safe_timeout), 2320 withState: () => (/* reexport */ withState) 2321 }); 2322 2323 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs 2324 /****************************************************************************** 2325 Copyright (c) Microsoft Corporation. 2326 2327 Permission to use, copy, modify, and/or distribute this software for any 2328 purpose with or without fee is hereby granted. 2329 2330 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 2331 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 2332 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 2333 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 2334 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 2335 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 2336 PERFORMANCE OF THIS SOFTWARE. 2337 ***************************************************************************** */ 2338 /* global Reflect, Promise, SuppressedError, Symbol */ 2339 2340 var extendStatics = function(d, b) { 2341 extendStatics = Object.setPrototypeOf || 2342 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 2343 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 2344 return extendStatics(d, b); 2345 }; 2346 2347 function __extends(d, b) { 2348 if (typeof b !== "function" && b !== null) 2349 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 2350 extendStatics(d, b); 2351 function __() { this.constructor = d; } 2352 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 2353 } 2354 2355 var __assign = function() { 2356 __assign = Object.assign || function __assign(t) { 2357 for (var s, i = 1, n = arguments.length; i < n; i++) { 2358 s = arguments[i]; 2359 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 2360 } 2361 return t; 2362 } 2363 return __assign.apply(this, arguments); 2364 } 2365 2366 function __rest(s, e) { 2367 var t = {}; 2368 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 2369 t[p] = s[p]; 2370 if (s != null && typeof Object.getOwnPropertySymbols === "function") 2371 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 2372 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 2373 t[p[i]] = s[p[i]]; 2374 } 2375 return t; 2376 } 2377 2378 function __decorate(decorators, target, key, desc) { 2379 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 2380 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 2381 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 2382 return c > 3 && r && Object.defineProperty(target, key, r), r; 2383 } 2384 2385 function __param(paramIndex, decorator) { 2386 return function (target, key) { decorator(target, key, paramIndex); } 2387 } 2388 2389 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { 2390 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } 2391 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; 2392 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; 2393 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); 2394 var _, done = false; 2395 for (var i = decorators.length - 1; i >= 0; i--) { 2396 var context = {}; 2397 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; 2398 for (var p in contextIn.access) context.access[p] = contextIn.access[p]; 2399 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; 2400 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); 2401 if (kind === "accessor") { 2402 if (result === void 0) continue; 2403 if (result === null || typeof result !== "object") throw new TypeError("Object expected"); 2404 if (_ = accept(result.get)) descriptor.get = _; 2405 if (_ = accept(result.set)) descriptor.set = _; 2406 if (_ = accept(result.init)) initializers.unshift(_); 2407 } 2408 else if (_ = accept(result)) { 2409 if (kind === "field") initializers.unshift(_); 2410 else descriptor[key] = _; 2411 } 2412 } 2413 if (target) Object.defineProperty(target, contextIn.name, descriptor); 2414 done = true; 2415 }; 2416 2417 function __runInitializers(thisArg, initializers, value) { 2418 var useValue = arguments.length > 2; 2419 for (var i = 0; i < initializers.length; i++) { 2420 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); 2421 } 2422 return useValue ? value : void 0; 2423 }; 2424 2425 function __propKey(x) { 2426 return typeof x === "symbol" ? x : "".concat(x); 2427 }; 2428 2429 function __setFunctionName(f, name, prefix) { 2430 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; 2431 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); 2432 }; 2433 2434 function __metadata(metadataKey, metadataValue) { 2435 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); 2436 } 2437 2438 function __awaiter(thisArg, _arguments, P, generator) { 2439 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 2440 return new (P || (P = Promise))(function (resolve, reject) { 2441 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 2442 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 2443 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 2444 step((generator = generator.apply(thisArg, _arguments || [])).next()); 2445 }); 2446 } 2447 2448 function __generator(thisArg, body) { 2449 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 2450 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 2451 function verb(n) { return function (v) { return step([n, v]); }; } 2452 function step(op) { 2453 if (f) throw new TypeError("Generator is already executing."); 2454 while (g && (g = 0, op[0] && (_ = 0)), _) try { 2455 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 2456 if (y = 0, t) op = [op[0] & 2, t.value]; 2457 switch (op[0]) { 2458 case 0: case 1: t = op; break; 2459 case 4: _.label++; return { value: op[1], done: false }; 2460 case 5: _.label++; y = op[1]; op = [0]; continue; 2461 case 7: op = _.ops.pop(); _.trys.pop(); continue; 2462 default: 2463 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 2464 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 2465 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 2466 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 2467 if (t[2]) _.ops.pop(); 2468 _.trys.pop(); continue; 2469 } 2470 op = body.call(thisArg, _); 2471 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 2472 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 2473 } 2474 } 2475 2476 var __createBinding = Object.create ? (function(o, m, k, k2) { 2477 if (k2 === undefined) k2 = k; 2478 var desc = Object.getOwnPropertyDescriptor(m, k); 2479 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 2480 desc = { enumerable: true, get: function() { return m[k]; } }; 2481 } 2482 Object.defineProperty(o, k2, desc); 2483 }) : (function(o, m, k, k2) { 2484 if (k2 === undefined) k2 = k; 2485 o[k2] = m[k]; 2486 }); 2487 2488 function __exportStar(m, o) { 2489 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); 2490 } 2491 2492 function __values(o) { 2493 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; 2494 if (m) return m.call(o); 2495 if (o && typeof o.length === "number") return { 2496 next: function () { 2497 if (o && i >= o.length) o = void 0; 2498 return { value: o && o[i++], done: !o }; 2499 } 2500 }; 2501 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); 2502 } 2503 2504 function __read(o, n) { 2505 var m = typeof Symbol === "function" && o[Symbol.iterator]; 2506 if (!m) return o; 2507 var i = m.call(o), r, ar = [], e; 2508 try { 2509 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 2510 } 2511 catch (error) { e = { error: error }; } 2512 finally { 2513 try { 2514 if (r && !r.done && (m = i["return"])) m.call(i); 2515 } 2516 finally { if (e) throw e.error; } 2517 } 2518 return ar; 2519 } 2520 2521 /** @deprecated */ 2522 function __spread() { 2523 for (var ar = [], i = 0; i < arguments.length; i++) 2524 ar = ar.concat(__read(arguments[i])); 2525 return ar; 2526 } 2527 2528 /** @deprecated */ 2529 function __spreadArrays() { 2530 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 2531 for (var r = Array(s), k = 0, i = 0; i < il; i++) 2532 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) 2533 r[k] = a[j]; 2534 return r; 2535 } 2536 2537 function __spreadArray(to, from, pack) { 2538 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { 2539 if (ar || !(i in from)) { 2540 if (!ar) ar = Array.prototype.slice.call(from, 0, i); 2541 ar[i] = from[i]; 2542 } 2543 } 2544 return to.concat(ar || Array.prototype.slice.call(from)); 2545 } 2546 2547 function __await(v) { 2548 return this instanceof __await ? (this.v = v, this) : new __await(v); 2549 } 2550 2551 function __asyncGenerator(thisArg, _arguments, generator) { 2552 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 2553 var g = generator.apply(thisArg, _arguments || []), i, q = []; 2554 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; 2555 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } 2556 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } 2557 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } 2558 function fulfill(value) { resume("next", value); } 2559 function reject(value) { resume("throw", value); } 2560 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } 2561 } 2562 2563 function __asyncDelegator(o) { 2564 var i, p; 2565 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 2566 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } 2567 } 2568 2569 function __asyncValues(o) { 2570 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 2571 var m = o[Symbol.asyncIterator], i; 2572 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); 2573 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } 2574 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } 2575 } 2576 2577 function __makeTemplateObject(cooked, raw) { 2578 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } 2579 return cooked; 2580 }; 2581 2582 var __setModuleDefault = Object.create ? (function(o, v) { 2583 Object.defineProperty(o, "default", { enumerable: true, value: v }); 2584 }) : function(o, v) { 2585 o["default"] = v; 2586 }; 2587 2588 function __importStar(mod) { 2589 if (mod && mod.__esModule) return mod; 2590 var result = {}; 2591 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 2592 __setModuleDefault(result, mod); 2593 return result; 2594 } 2595 2596 function __importDefault(mod) { 2597 return (mod && mod.__esModule) ? mod : { default: mod }; 2598 } 2599 2600 function __classPrivateFieldGet(receiver, state, kind, f) { 2601 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); 2602 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); 2603 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); 2604 } 2605 2606 function __classPrivateFieldSet(receiver, state, value, kind, f) { 2607 if (kind === "m") throw new TypeError("Private method is not writable"); 2608 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); 2609 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); 2610 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; 2611 } 2612 2613 function __classPrivateFieldIn(state, receiver) { 2614 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); 2615 return typeof state === "function" ? receiver === state : state.has(receiver); 2616 } 2617 2618 function __addDisposableResource(env, value, async) { 2619 if (value !== null && value !== void 0) { 2620 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); 2621 var dispose; 2622 if (async) { 2623 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); 2624 dispose = value[Symbol.asyncDispose]; 2625 } 2626 if (dispose === void 0) { 2627 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); 2628 dispose = value[Symbol.dispose]; 2629 } 2630 if (typeof dispose !== "function") throw new TypeError("Object not disposable."); 2631 env.stack.push({ value: value, dispose: dispose, async: async }); 2632 } 2633 else if (async) { 2634 env.stack.push({ async: true }); 2635 } 2636 return value; 2637 } 2638 2639 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { 2640 var e = new Error(message); 2641 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; 2642 }; 2643 2644 function __disposeResources(env) { 2645 function fail(e) { 2646 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; 2647 env.hasError = true; 2648 } 2649 function next() { 2650 while (env.stack.length) { 2651 var rec = env.stack.pop(); 2652 try { 2653 var result = rec.dispose && rec.dispose.call(rec.value); 2654 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); 2655 } 2656 catch (e) { 2657 fail(e); 2658 } 2659 } 2660 if (env.hasError) throw env.error; 2661 } 2662 return next(); 2663 } 2664 2665 /* harmony default export */ const tslib_es6 = ({ 2666 __extends, 2667 __assign, 2668 __rest, 2669 __decorate, 2670 __param, 2671 __metadata, 2672 __awaiter, 2673 __generator, 2674 __createBinding, 2675 __exportStar, 2676 __values, 2677 __read, 2678 __spread, 2679 __spreadArrays, 2680 __spreadArray, 2681 __await, 2682 __asyncGenerator, 2683 __asyncDelegator, 2684 __asyncValues, 2685 __makeTemplateObject, 2686 __importStar, 2687 __importDefault, 2688 __classPrivateFieldGet, 2689 __classPrivateFieldSet, 2690 __classPrivateFieldIn, 2691 __addDisposableResource, 2692 __disposeResources, 2693 }); 2694 2695 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js 2696 /** 2697 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt 2698 */ 2699 var SUPPORTED_LOCALE = { 2700 tr: { 2701 regexp: /\u0130|\u0049|\u0049\u0307/g, 2702 map: { 2703 İ: "\u0069", 2704 I: "\u0131", 2705 İ: "\u0069", 2706 }, 2707 }, 2708 az: { 2709 regexp: /\u0130/g, 2710 map: { 2711 İ: "\u0069", 2712 I: "\u0131", 2713 İ: "\u0069", 2714 }, 2715 }, 2716 lt: { 2717 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, 2718 map: { 2719 I: "\u0069\u0307", 2720 J: "\u006A\u0307", 2721 Į: "\u012F\u0307", 2722 Ì: "\u0069\u0307\u0300", 2723 Í: "\u0069\u0307\u0301", 2724 Ĩ: "\u0069\u0307\u0303", 2725 }, 2726 }, 2727 }; 2728 /** 2729 * Localized lower case. 2730 */ 2731 function localeLowerCase(str, locale) { 2732 var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; 2733 if (lang) 2734 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); 2735 return lowerCase(str); 2736 } 2737 /** 2738 * Lower case as a function. 2739 */ 2740 function lowerCase(str) { 2741 return str.toLowerCase(); 2742 } 2743 2744 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js 2745 2746 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). 2747 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 2748 // Remove all non-word characters. 2749 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 2750 /** 2751 * Normalize the string into something other libraries can manipulate easier. 2752 */ 2753 function noCase(input, options) { 2754 if (options === void 0) { options = {}; } 2755 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; 2756 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 2757 var start = 0; 2758 var end = result.length; 2759 // Trim the delimiter from around the output string. 2760 while (result.charAt(start) === "\0") 2761 start++; 2762 while (result.charAt(end - 1) === "\0") 2763 end--; 2764 // Transform each token independently. 2765 return result.slice(start, end).split("\0").map(transform).join(delimiter); 2766 } 2767 /** 2768 * Replace `re` in the input string with the replacement value. 2769 */ 2770 function replace(input, re, value) { 2771 if (re instanceof RegExp) 2772 return input.replace(re, value); 2773 return re.reduce(function (input, re) { return input.replace(re, value); }, input); 2774 } 2775 2776 ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js 2777 2778 2779 function pascalCaseTransform(input, index) { 2780 var firstChar = input.charAt(0); 2781 var lowerChars = input.substr(1).toLowerCase(); 2782 if (index > 0 && firstChar >= "0" && firstChar <= "9") { 2783 return "_" + firstChar + lowerChars; 2784 } 2785 return "" + firstChar.toUpperCase() + lowerChars; 2786 } 2787 function pascalCaseTransformMerge(input) { 2788 return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); 2789 } 2790 function pascalCase(input, options) { 2791 if (options === void 0) { options = {}; } 2792 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); 2793 } 2794 2795 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js 2796 /** 2797 * External dependencies 2798 */ 2799 2800 /** 2801 * Given a function mapping a component to an enhanced component and modifier 2802 * name, returns the enhanced component augmented with a generated displayName. 2803 * 2804 * @param mapComponent Function mapping component to enhanced component. 2805 * @param modifierName Seed name from which to generated display name. 2806 * 2807 * @return Component class with generated display name assigned. 2808 */ 2809 function createHigherOrderComponent(mapComponent, modifierName) { 2810 return Inner => { 2811 const Outer = mapComponent(Inner); 2812 Outer.displayName = hocName(modifierName, Inner); 2813 return Outer; 2814 }; 2815 } 2816 2817 /** 2818 * Returns a displayName for a higher-order component, given a wrapper name. 2819 * 2820 * @example 2821 * hocName( 'MyMemo', Widget ) === 'MyMemo(Widget)'; 2822 * hocName( 'MyMemo', <div /> ) === 'MyMemo(Component)'; 2823 * 2824 * @param name Name assigned to higher-order component's wrapper component. 2825 * @param Inner Wrapped component inside higher-order component. 2826 * @return Wrapped name of higher-order component. 2827 */ 2828 const hocName = (name, Inner) => { 2829 const inner = Inner.displayName || Inner.name || 'Component'; 2830 const outer = pascalCase(name !== null && name !== void 0 ? name : ''); 2831 return `$outer}($inner})`; 2832 }; 2833 2834 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/debounce/index.js 2835 /** 2836 * Parts of this source were derived and modified from lodash, 2837 * released under the MIT license. 2838 * 2839 * https://github.com/lodash/lodash 2840 * 2841 * Copyright JS Foundation and other contributors <https://js.foundation/> 2842 * 2843 * Based on Underscore.js, copyright Jeremy Ashkenas, 2844 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 2845 * 2846 * This software consists of voluntary contributions made by many 2847 * individuals. For exact contribution history, see the revision history 2848 * available at https://github.com/lodash/lodash 2849 * 2850 * The following license applies to all parts of this software except as 2851 * documented below: 2852 * 2853 * ==== 2854 * 2855 * Permission is hereby granted, free of charge, to any person obtaining 2856 * a copy of this software and associated documentation files (the 2857 * "Software"), to deal in the Software without restriction, including 2858 * without limitation the rights to use, copy, modify, merge, publish, 2859 * distribute, sublicense, and/or sell copies of the Software, and to 2860 * permit persons to whom the Software is furnished to do so, subject to 2861 * the following conditions: 2862 * 2863 * The above copyright notice and this permission notice shall be 2864 * included in all copies or substantial portions of the Software. 2865 * 2866 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2867 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2868 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2869 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 2870 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 2871 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2872 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2873 */ 2874 2875 /** 2876 * A simplified and properly typed version of lodash's `debounce`, that 2877 * always uses timers instead of sometimes using rAF. 2878 * 2879 * Creates a debounced function that delays invoking `func` until after `wait` 2880 * milliseconds have elapsed since the last time the debounced function was 2881 * invoked. The debounced function comes with a `cancel` method to cancel delayed 2882 * `func` invocations and a `flush` method to immediately invoke them. Provide 2883 * `options` to indicate whether `func` should be invoked on the leading and/or 2884 * trailing edge of the `wait` timeout. The `func` is invoked with the last 2885 * arguments provided to the debounced function. Subsequent calls to the debounced 2886 * function return the result of the last `func` invocation. 2887 * 2888 * **Note:** If `leading` and `trailing` options are `true`, `func` is 2889 * invoked on the trailing edge of the timeout only if the debounced function 2890 * is invoked more than once during the `wait` timeout. 2891 * 2892 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 2893 * until the next tick, similar to `setTimeout` with a timeout of `0`. 2894 * 2895 * @param {Function} func The function to debounce. 2896 * @param {number} wait The number of milliseconds to delay. 2897 * @param {Partial< DebounceOptions >} options The options object. 2898 * @param {boolean} options.leading Specify invoking on the leading edge of the timeout. 2899 * @param {number} options.maxWait The maximum time `func` is allowed to be delayed before it's invoked. 2900 * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout. 2901 * 2902 * @return Returns the new debounced function. 2903 */ 2904 const debounce = (func, wait, options) => { 2905 let lastArgs; 2906 let lastThis; 2907 let maxWait = 0; 2908 let result; 2909 let timerId; 2910 let lastCallTime; 2911 let lastInvokeTime = 0; 2912 let leading = false; 2913 let maxing = false; 2914 let trailing = true; 2915 if (options) { 2916 leading = !!options.leading; 2917 maxing = 'maxWait' in options; 2918 if (options.maxWait !== undefined) { 2919 maxWait = Math.max(options.maxWait, wait); 2920 } 2921 trailing = 'trailing' in options ? !!options.trailing : trailing; 2922 } 2923 function invokeFunc(time) { 2924 const args = lastArgs; 2925 const thisArg = lastThis; 2926 lastArgs = undefined; 2927 lastThis = undefined; 2928 lastInvokeTime = time; 2929 result = func.apply(thisArg, args); 2930 return result; 2931 } 2932 function startTimer(pendingFunc, waitTime) { 2933 timerId = setTimeout(pendingFunc, waitTime); 2934 } 2935 function cancelTimer() { 2936 if (timerId !== undefined) { 2937 clearTimeout(timerId); 2938 } 2939 } 2940 function leadingEdge(time) { 2941 // Reset any `maxWait` timer. 2942 lastInvokeTime = time; 2943 // Start the timer for the trailing edge. 2944 startTimer(timerExpired, wait); 2945 // Invoke the leading edge. 2946 return leading ? invokeFunc(time) : result; 2947 } 2948 function getTimeSinceLastCall(time) { 2949 return time - (lastCallTime || 0); 2950 } 2951 function remainingWait(time) { 2952 const timeSinceLastCall = getTimeSinceLastCall(time); 2953 const timeSinceLastInvoke = time - lastInvokeTime; 2954 const timeWaiting = wait - timeSinceLastCall; 2955 return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting; 2956 } 2957 function shouldInvoke(time) { 2958 const timeSinceLastCall = getTimeSinceLastCall(time); 2959 const timeSinceLastInvoke = time - lastInvokeTime; 2960 2961 // Either this is the first call, activity has stopped and we're at the 2962 // trailing edge, the system time has gone backwards and we're treating 2963 // it as the trailing edge, or we've hit the `maxWait` limit. 2964 return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; 2965 } 2966 function timerExpired() { 2967 const time = Date.now(); 2968 if (shouldInvoke(time)) { 2969 return trailingEdge(time); 2970 } 2971 // Restart the timer. 2972 startTimer(timerExpired, remainingWait(time)); 2973 return undefined; 2974 } 2975 function clearTimer() { 2976 timerId = undefined; 2977 } 2978 function trailingEdge(time) { 2979 clearTimer(); 2980 2981 // Only invoke if we have `lastArgs` which means `func` has been 2982 // debounced at least once. 2983 if (trailing && lastArgs) { 2984 return invokeFunc(time); 2985 } 2986 lastArgs = lastThis = undefined; 2987 return result; 2988 } 2989 function cancel() { 2990 cancelTimer(); 2991 lastInvokeTime = 0; 2992 clearTimer(); 2993 lastArgs = lastCallTime = lastThis = undefined; 2994 } 2995 function flush() { 2996 return pending() ? trailingEdge(Date.now()) : result; 2997 } 2998 function pending() { 2999 return timerId !== undefined; 3000 } 3001 function debounced(...args) { 3002 const time = Date.now(); 3003 const isInvoking = shouldInvoke(time); 3004 lastArgs = args; 3005 lastThis = this; 3006 lastCallTime = time; 3007 if (isInvoking) { 3008 if (!pending()) { 3009 return leadingEdge(lastCallTime); 3010 } 3011 if (maxing) { 3012 // Handle invocations in a tight loop. 3013 startTimer(timerExpired, wait); 3014 return invokeFunc(lastCallTime); 3015 } 3016 } 3017 if (!pending()) { 3018 startTimer(timerExpired, wait); 3019 } 3020 return result; 3021 } 3022 debounced.cancel = cancel; 3023 debounced.flush = flush; 3024 debounced.pending = pending; 3025 return debounced; 3026 }; 3027 3028 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/throttle/index.js 3029 /** 3030 * Parts of this source were derived and modified from lodash, 3031 * released under the MIT license. 3032 * 3033 * https://github.com/lodash/lodash 3034 * 3035 * Copyright JS Foundation and other contributors <https://js.foundation/> 3036 * 3037 * Based on Underscore.js, copyright Jeremy Ashkenas, 3038 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 3039 * 3040 * This software consists of voluntary contributions made by many 3041 * individuals. For exact contribution history, see the revision history 3042 * available at https://github.com/lodash/lodash 3043 * 3044 * The following license applies to all parts of this software except as 3045 * documented below: 3046 * 3047 * ==== 3048 * 3049 * Permission is hereby granted, free of charge, to any person obtaining 3050 * a copy of this software and associated documentation files (the 3051 * "Software"), to deal in the Software without restriction, including 3052 * without limitation the rights to use, copy, modify, merge, publish, 3053 * distribute, sublicense, and/or sell copies of the Software, and to 3054 * permit persons to whom the Software is furnished to do so, subject to 3055 * the following conditions: 3056 * 3057 * The above copyright notice and this permission notice shall be 3058 * included in all copies or substantial portions of the Software. 3059 * 3060 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3061 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3062 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3063 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 3064 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 3065 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 3066 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 3067 */ 3068 3069 /** 3070 * Internal dependencies 3071 */ 3072 3073 /** 3074 * A simplified and properly typed version of lodash's `throttle`, that 3075 * always uses timers instead of sometimes using rAF. 3076 * 3077 * Creates a throttled function that only invokes `func` at most once per 3078 * every `wait` milliseconds. The throttled function comes with a `cancel` 3079 * method to cancel delayed `func` invocations and a `flush` method to 3080 * immediately invoke them. Provide `options` to indicate whether `func` 3081 * should be invoked on the leading and/or trailing edge of the `wait` 3082 * timeout. The `func` is invoked with the last arguments provided to the 3083 * throttled function. Subsequent calls to the throttled function return 3084 * the result of the last `func` invocation. 3085 * 3086 * **Note:** If `leading` and `trailing` options are `true`, `func` is 3087 * invoked on the trailing edge of the timeout only if the throttled function 3088 * is invoked more than once during the `wait` timeout. 3089 * 3090 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 3091 * until the next tick, similar to `setTimeout` with a timeout of `0`. 3092 * 3093 * @param {Function} func The function to throttle. 3094 * @param {number} wait The number of milliseconds to throttle invocations to. 3095 * @param {Partial< ThrottleOptions >} options The options object. 3096 * @param {boolean} options.leading Specify invoking on the leading edge of the timeout. 3097 * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout. 3098 * @return Returns the new throttled function. 3099 */ 3100 const throttle = (func, wait, options) => { 3101 let leading = true; 3102 let trailing = true; 3103 if (options) { 3104 leading = 'leading' in options ? !!options.leading : leading; 3105 trailing = 'trailing' in options ? !!options.trailing : trailing; 3106 } 3107 return debounce(func, wait, { 3108 leading, 3109 trailing, 3110 maxWait: wait 3111 }); 3112 }; 3113 3114 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pipe.js 3115 /** 3116 * Parts of this source were derived and modified from lodash, 3117 * released under the MIT license. 3118 * 3119 * https://github.com/lodash/lodash 3120 * 3121 * Copyright JS Foundation and other contributors <https://js.foundation/> 3122 * 3123 * Based on Underscore.js, copyright Jeremy Ashkenas, 3124 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 3125 * 3126 * This software consists of voluntary contributions made by many 3127 * individuals. For exact contribution history, see the revision history 3128 * available at https://github.com/lodash/lodash 3129 * 3130 * The following license applies to all parts of this software except as 3131 * documented below: 3132 * 3133 * ==== 3134 * 3135 * Permission is hereby granted, free of charge, to any person obtaining 3136 * a copy of this software and associated documentation files (the 3137 * "Software"), to deal in the Software without restriction, including 3138 * without limitation the rights to use, copy, modify, merge, publish, 3139 * distribute, sublicense, and/or sell copies of the Software, and to 3140 * permit persons to whom the Software is furnished to do so, subject to 3141 * the following conditions: 3142 * 3143 * The above copyright notice and this permission notice shall be 3144 * included in all copies or substantial portions of the Software. 3145 * 3146 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3147 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3148 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3149 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 3150 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 3151 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 3152 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 3153 */ 3154 3155 /** 3156 * Creates a pipe function. 3157 * 3158 * Allows to choose whether to perform left-to-right or right-to-left composition. 3159 * 3160 * @see https://docs-lodash.com/v4/flow/ 3161 * 3162 * @param {boolean} reverse True if right-to-left, false for left-to-right composition. 3163 */ 3164 const basePipe = (reverse = false) => (...funcs) => (...args) => { 3165 const functions = funcs.flat(); 3166 if (reverse) { 3167 functions.reverse(); 3168 } 3169 return functions.reduce((prev, func) => [func(...prev)], args)[0]; 3170 }; 3171 3172 /** 3173 * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function 3174 * composition, where each successive invocation is supplied the return value of the previous. 3175 * 3176 * This is inspired by `lodash`'s `flow` function. 3177 * 3178 * @see https://docs-lodash.com/v4/flow/ 3179 */ 3180 const pipe = basePipe(); 3181 3182 /* harmony default export */ const higher_order_pipe = (pipe); 3183 3184 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js 3185 /** 3186 * Internal dependencies 3187 */ 3188 3189 3190 /** 3191 * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function 3192 * composition, where each successive invocation is supplied the return value of the previous. 3193 * 3194 * This is inspired by `lodash`'s `flowRight` function. 3195 * 3196 * @see https://docs-lodash.com/v4/flow-right/ 3197 */ 3198 const compose = basePipe(true); 3199 /* harmony default export */ const higher_order_compose = (compose); 3200 3201 ;// CONCATENATED MODULE: external "React" 3202 const external_React_namespaceObject = window["React"]; 3203 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js 3204 3205 /** 3206 * External dependencies 3207 */ 3208 3209 /** 3210 * Internal dependencies 3211 */ 3212 3213 3214 /** 3215 * Higher-order component creator, creating a new component which renders if 3216 * the given condition is satisfied or with the given optional prop name. 3217 * 3218 * @example 3219 * ```ts 3220 * type Props = { foo: string }; 3221 * const Component = ( props: Props ) => <div>{ props.foo }</div>; 3222 * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component ); 3223 * <ConditionalComponent foo="" />; // => null 3224 * <ConditionalComponent foo="bar" />; // => <div>bar</div>; 3225 * ``` 3226 * 3227 * @param predicate Function to test condition. 3228 * 3229 * @return Higher-order component. 3230 */ 3231 function ifCondition(predicate) { 3232 return createHigherOrderComponent(WrappedComponent => props => { 3233 if (!predicate(props)) { 3234 return null; 3235 } 3236 return (0,external_React_namespaceObject.createElement)(WrappedComponent, { 3237 ...props 3238 }); 3239 }, 'ifCondition'); 3240 } 3241 /* harmony default export */ const if_condition = (ifCondition); 3242 3243 // EXTERNAL MODULE: external ["wp","isShallowEqual"] 3244 var external_wp_isShallowEqual_ = __webpack_require__(923); 3245 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_); 3246 ;// CONCATENATED MODULE: external ["wp","element"] 3247 const external_wp_element_namespaceObject = window["wp"]["element"]; 3248 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js 3249 3250 /** 3251 * External dependencies 3252 */ 3253 3254 /** 3255 * WordPress dependencies 3256 */ 3257 3258 3259 3260 /** 3261 * Internal dependencies 3262 */ 3263 3264 3265 /** 3266 * Given a component returns the enhanced component augmented with a component 3267 * only re-rendering when its props/state change 3268 * 3269 * @deprecated Use `memo` or `PureComponent` instead. 3270 */ 3271 const pure = createHigherOrderComponent(function (WrappedComponent) { 3272 if (WrappedComponent.prototype instanceof external_wp_element_namespaceObject.Component) { 3273 return class extends WrappedComponent { 3274 shouldComponentUpdate(nextProps, nextState) { 3275 return !external_wp_isShallowEqual_default()(nextProps, this.props) || !external_wp_isShallowEqual_default()(nextState, this.state); 3276 } 3277 }; 3278 } 3279 return class extends external_wp_element_namespaceObject.Component { 3280 shouldComponentUpdate(nextProps) { 3281 return !external_wp_isShallowEqual_default()(nextProps, this.props); 3282 } 3283 render() { 3284 return (0,external_React_namespaceObject.createElement)(WrappedComponent, { 3285 ...this.props 3286 }); 3287 } 3288 }; 3289 }, 'pure'); 3290 /* harmony default export */ const higher_order_pure = (pure); 3291 3292 ;// CONCATENATED MODULE: external ["wp","deprecated"] 3293 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; 3294 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); 3295 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js 3296 /** 3297 * Class responsible for orchestrating event handling on the global window, 3298 * binding a single event to be shared across all handling instances, and 3299 * removing the handler when no instances are listening for the event. 3300 */ 3301 class Listener { 3302 constructor() { 3303 /** @type {any} */ 3304 this.listeners = {}; 3305 this.handleEvent = this.handleEvent.bind(this); 3306 } 3307 add( /** @type {any} */eventType, /** @type {any} */instance) { 3308 if (!this.listeners[eventType]) { 3309 // Adding first listener for this type, so bind event. 3310 window.addEventListener(eventType, this.handleEvent); 3311 this.listeners[eventType] = []; 3312 } 3313 this.listeners[eventType].push(instance); 3314 } 3315 remove( /** @type {any} */eventType, /** @type {any} */instance) { 3316 if (!this.listeners[eventType]) { 3317 return; 3318 } 3319 this.listeners[eventType] = this.listeners[eventType].filter(( /** @type {any} */listener) => listener !== instance); 3320 if (!this.listeners[eventType].length) { 3321 // Removing last listener for this type, so unbind event. 3322 window.removeEventListener(eventType, this.handleEvent); 3323 delete this.listeners[eventType]; 3324 } 3325 } 3326 handleEvent( /** @type {any} */event) { 3327 this.listeners[event.type]?.forEach(( /** @type {any} */instance) => { 3328 instance.handleEvent(event); 3329 }); 3330 } 3331 } 3332 /* harmony default export */ const listener = (Listener); 3333 3334 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js 3335 3336 /** 3337 * WordPress dependencies 3338 */ 3339 3340 3341 3342 /** 3343 * Internal dependencies 3344 */ 3345 3346 3347 3348 /** 3349 * Listener instance responsible for managing document event handling. 3350 */ 3351 const with_global_events_listener = new listener(); 3352 3353 /* eslint-disable jsdoc/no-undefined-types */ 3354 /** 3355 * Higher-order component creator which, given an object of DOM event types and 3356 * values corresponding to a callback function name on the component, will 3357 * create or update a window event handler to invoke the callback when an event 3358 * occurs. On behalf of the consuming developer, the higher-order component 3359 * manages unbinding when the component unmounts, and binding at most a single 3360 * event handler for the entire application. 3361 * 3362 * @deprecated 3363 * 3364 * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM 3365 * event type, the value a 3366 * name of the function on 3367 * the original component's 3368 * instance which handles 3369 * the event. 3370 * 3371 * @return {any} Higher-order component. 3372 */ 3373 function withGlobalEvents(eventTypesToHandlers) { 3374 external_wp_deprecated_default()('wp.compose.withGlobalEvents', { 3375 since: '5.7', 3376 alternative: 'useEffect' 3377 }); 3378 3379 // @ts-ignore We don't need to fix the type-related issues because this is deprecated. 3380 return createHigherOrderComponent(WrappedComponent => { 3381 class Wrapper extends external_wp_element_namespaceObject.Component { 3382 constructor( /** @type {any} */props) { 3383 super(props); 3384 this.handleEvent = this.handleEvent.bind(this); 3385 this.handleRef = this.handleRef.bind(this); 3386 } 3387 componentDidMount() { 3388 Object.keys(eventTypesToHandlers).forEach(eventType => { 3389 with_global_events_listener.add(eventType, this); 3390 }); 3391 } 3392 componentWillUnmount() { 3393 Object.keys(eventTypesToHandlers).forEach(eventType => { 3394 with_global_events_listener.remove(eventType, this); 3395 }); 3396 } 3397 handleEvent( /** @type {any} */event) { 3398 const handler = eventTypesToHandlers[( /** @type {keyof GlobalEventHandlersEventMap} */ 3399 event.type 3400 3401 /* eslint-enable jsdoc/no-undefined-types */)]; 3402 if (typeof this.wrappedRef[handler] === 'function') { 3403 this.wrappedRef[handler](event); 3404 } 3405 } 3406 handleRef( /** @type {any} */el) { 3407 this.wrappedRef = el; 3408 // Any component using `withGlobalEvents` that is not setting a `ref` 3409 // will cause `this.props.forwardedRef` to be `null`, so we need this 3410 // check. 3411 if (this.props.forwardedRef) { 3412 this.props.forwardedRef(el); 3413 } 3414 } 3415 render() { 3416 return (0,external_React_namespaceObject.createElement)(WrappedComponent, { 3417 ...this.props.ownProps, 3418 ref: this.handleRef 3419 }); 3420 } 3421 } 3422 return (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 3423 return (0,external_React_namespaceObject.createElement)(Wrapper, { 3424 ownProps: props, 3425 forwardedRef: ref 3426 }); 3427 }); 3428 }, 'withGlobalEvents'); 3429 } 3430 3431 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js 3432 /** 3433 * WordPress dependencies 3434 */ 3435 3436 const instanceMap = new WeakMap(); 3437 3438 /** 3439 * Creates a new id for a given object. 3440 * 3441 * @param object Object reference to create an id for. 3442 * @return The instance id (index). 3443 */ 3444 function createId(object) { 3445 const instances = instanceMap.get(object) || 0; 3446 instanceMap.set(object, instances + 1); 3447 return instances; 3448 } 3449 3450 /** 3451 * Specify the useInstanceId *function* signatures. 3452 * 3453 * More accurately, useInstanceId distinguishes between three different 3454 * signatures: 3455 * 3456 * 1. When only object is given, the returned value is a number 3457 * 2. When object and prefix is given, the returned value is a string 3458 * 3. When preferredId is given, the returned value is the type of preferredId 3459 * 3460 * @param object Object reference to create an id for. 3461 */ 3462 3463 /** 3464 * Provides a unique instance ID. 3465 * 3466 * @param object Object reference to create an id for. 3467 * @param [prefix] Prefix for the unique id. 3468 * @param [preferredId] Default ID to use. 3469 * @return The unique instance id. 3470 */ 3471 function useInstanceId(object, prefix, preferredId) { 3472 return (0,external_wp_element_namespaceObject.useMemo)(() => { 3473 if (preferredId) return preferredId; 3474 const id = createId(object); 3475 return prefix ? `$prefix}-$id}` : id; 3476 }, [object, preferredId, prefix]); 3477 } 3478 /* harmony default export */ const use_instance_id = (useInstanceId); 3479 3480 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js 3481 3482 /** 3483 * Internal dependencies 3484 */ 3485 3486 3487 3488 /** 3489 * A Higher Order Component used to be provide a unique instance ID by 3490 * component. 3491 */ 3492 const withInstanceId = createHigherOrderComponent(WrappedComponent => { 3493 return props => { 3494 const instanceId = use_instance_id(WrappedComponent); 3495 // @ts-ignore 3496 return (0,external_React_namespaceObject.createElement)(WrappedComponent, { 3497 ...props, 3498 instanceId: instanceId 3499 }); 3500 }; 3501 }, 'instanceId'); 3502 /* harmony default export */ const with_instance_id = (withInstanceId); 3503 3504 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js 3505 3506 /** 3507 * WordPress dependencies 3508 */ 3509 3510 3511 /** 3512 * Internal dependencies 3513 */ 3514 3515 3516 3517 /** 3518 * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']` 3519 * types here because those functions include functionality that is not handled 3520 * by this component, like the ability to pass extra arguments. 3521 * 3522 * In the case of this component, we only handle the simplest case where 3523 * `setTimeout` only accepts a function (not a string) and an optional delay. 3524 */ 3525 3526 /** 3527 * A higher-order component used to provide and manage delayed function calls 3528 * that ought to be bound to a component's lifecycle. 3529 */ 3530 const withSafeTimeout = createHigherOrderComponent(OriginalComponent => { 3531 return class WrappedComponent extends external_wp_element_namespaceObject.Component { 3532 constructor(props) { 3533 super(props); 3534 this.timeouts = []; 3535 this.setTimeout = this.setTimeout.bind(this); 3536 this.clearTimeout = this.clearTimeout.bind(this); 3537 } 3538 componentWillUnmount() { 3539 this.timeouts.forEach(clearTimeout); 3540 } 3541 setTimeout(fn, delay) { 3542 const id = setTimeout(() => { 3543 fn(); 3544 this.clearTimeout(id); 3545 }, delay); 3546 this.timeouts.push(id); 3547 return id; 3548 } 3549 clearTimeout(id) { 3550 clearTimeout(id); 3551 this.timeouts = this.timeouts.filter(timeoutId => timeoutId !== id); 3552 } 3553 render() { 3554 return ( 3555 // @ts-ignore 3556 (0,external_React_namespaceObject.createElement)(OriginalComponent, { 3557 ...this.props, 3558 setTimeout: this.setTimeout, 3559 clearTimeout: this.clearTimeout 3560 }) 3561 ); 3562 } 3563 }; 3564 }, 'withSafeTimeout'); 3565 /* harmony default export */ const with_safe_timeout = (withSafeTimeout); 3566 3567 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js 3568 3569 /** 3570 * WordPress dependencies 3571 */ 3572 3573 3574 3575 /** 3576 * Internal dependencies 3577 */ 3578 3579 3580 /** 3581 * A Higher Order Component used to provide and manage internal component state 3582 * via props. 3583 * 3584 * @deprecated Use `useState` instead. 3585 * 3586 * @param {any} initialState Optional initial state of the component. 3587 * 3588 * @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. 3589 */ 3590 function withState(initialState = {}) { 3591 external_wp_deprecated_default()('wp.compose.withState', { 3592 since: '5.8', 3593 alternative: 'wp.element.useState' 3594 }); 3595 return createHigherOrderComponent(OriginalComponent => { 3596 return class WrappedComponent extends external_wp_element_namespaceObject.Component { 3597 constructor( /** @type {any} */props) { 3598 super(props); 3599 this.setState = this.setState.bind(this); 3600 this.state = initialState; 3601 } 3602 render() { 3603 return (0,external_React_namespaceObject.createElement)(OriginalComponent, { 3604 ...this.props, 3605 ...this.state, 3606 setState: this.setState 3607 }); 3608 } 3609 }; 3610 }, 'withState'); 3611 } 3612 3613 ;// CONCATENATED MODULE: external ["wp","dom"] 3614 const external_wp_dom_namespaceObject = window["wp"]["dom"]; 3615 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-ref-effect/index.js 3616 /** 3617 * External dependencies 3618 */ 3619 3620 /** 3621 * WordPress dependencies 3622 */ 3623 3624 3625 /** 3626 * Effect-like ref callback. Just like with `useEffect`, this allows you to 3627 * return a cleanup function to be run if the ref changes or one of the 3628 * dependencies changes. The ref is provided as an argument to the callback 3629 * functions. The main difference between this and `useEffect` is that 3630 * the `useEffect` callback is not called when the ref changes, but this is. 3631 * Pass the returned ref callback as the component's ref and merge multiple refs 3632 * with `useMergeRefs`. 3633 * 3634 * It's worth noting that if the dependencies array is empty, there's not 3635 * strictly a need to clean up event handlers for example, because the node is 3636 * to be removed. It *is* necessary if you add dependencies because the ref 3637 * callback will be called multiple times for the same node. 3638 * 3639 * @param callback Callback with ref as argument. 3640 * @param dependencies Dependencies of the callback. 3641 * 3642 * @return Ref callback. 3643 */ 3644 function useRefEffect(callback, dependencies) { 3645 const cleanup = (0,external_wp_element_namespaceObject.useRef)(); 3646 return (0,external_wp_element_namespaceObject.useCallback)(node => { 3647 if (node) { 3648 cleanup.current = callback(node); 3649 } else if (cleanup.current) { 3650 cleanup.current(); 3651 } 3652 }, dependencies); 3653 } 3654 3655 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js 3656 /** 3657 * WordPress dependencies 3658 */ 3659 3660 3661 /** 3662 * Internal dependencies 3663 */ 3664 3665 3666 /** 3667 * In Dialogs/modals, the tabbing must be constrained to the content of 3668 * the wrapper element. This hook adds the behavior to the returned ref. 3669 * 3670 * @return {import('react').RefCallback<Element>} Element Ref. 3671 * 3672 * @example 3673 * ```js 3674 * import { useConstrainedTabbing } from '@wordpress/compose'; 3675 * 3676 * const ConstrainedTabbingExample = () => { 3677 * const constrainedTabbingRef = useConstrainedTabbing() 3678 * return ( 3679 * <div ref={ constrainedTabbingRef }> 3680 * <Button /> 3681 * <Button /> 3682 * </div> 3683 * ); 3684 * } 3685 * ``` 3686 */ 3687 function useConstrainedTabbing() { 3688 return useRefEffect(( /** @type {HTMLElement} */node) => { 3689 function onKeyDown( /** @type {KeyboardEvent} */event) { 3690 const { 3691 key, 3692 shiftKey, 3693 target 3694 } = event; 3695 if (key !== 'Tab') { 3696 return; 3697 } 3698 const action = shiftKey ? 'findPrevious' : 'findNext'; 3699 const nextElement = external_wp_dom_namespaceObject.focus.tabbable[action]( /** @type {HTMLElement} */target) || null; 3700 3701 // When the target element contains the element that is about to 3702 // receive focus, for example when the target is a tabbable 3703 // container, browsers may disagree on where to move focus next. 3704 // In this case we can't rely on native browsers behavior. We need 3705 // to manage focus instead. 3706 // See https://github.com/WordPress/gutenberg/issues/46041. 3707 if ( /** @type {HTMLElement} */target.contains(nextElement)) { 3708 event.preventDefault(); 3709 /** @type {HTMLElement} */ 3710 nextElement?.focus(); 3711 return; 3712 } 3713 3714 // If the element that is about to receive focus is inside the 3715 // area, rely on native browsers behavior and let tabbing follow 3716 // the native tab sequence. 3717 if (node.contains(nextElement)) { 3718 return; 3719 } 3720 3721 // If the element that is about to receive focus is outside the 3722 // area, move focus to a div and insert it at the start or end of 3723 // the area, depending on the direction. Without preventing default 3724 // behaviour, the browser will then move focus to the next element. 3725 const domAction = shiftKey ? 'append' : 'prepend'; 3726 const { 3727 ownerDocument 3728 } = node; 3729 const trap = ownerDocument.createElement('div'); 3730 trap.tabIndex = -1; 3731 node[domAction](trap); 3732 3733 // Remove itself when the trap loses focus. 3734 trap.addEventListener('blur', () => node.removeChild(trap)); 3735 trap.focus(); 3736 } 3737 node.addEventListener('keydown', onKeyDown); 3738 return () => { 3739 node.removeEventListener('keydown', onKeyDown); 3740 }; 3741 }, []); 3742 } 3743 /* harmony default export */ const use_constrained_tabbing = (useConstrainedTabbing); 3744 3745 // EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js 3746 var dist_clipboard = __webpack_require__(3758); 3747 var clipboard_default = /*#__PURE__*/__webpack_require__.n(dist_clipboard); 3748 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js 3749 /** 3750 * External dependencies 3751 */ 3752 3753 3754 /** 3755 * WordPress dependencies 3756 */ 3757 3758 3759 3760 /* eslint-disable jsdoc/no-undefined-types */ 3761 /** 3762 * Copies the text to the clipboard when the element is clicked. 3763 * 3764 * @deprecated 3765 * 3766 * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element. 3767 * @param {string|Function} text The text to copy. 3768 * @param {number} [timeout] Optional timeout to reset the returned 3769 * state. 4 seconds by default. 3770 * 3771 * @return {boolean} Whether or not the text has been copied. Resets after the 3772 * timeout. 3773 */ 3774 function useCopyOnClick(ref, text, timeout = 4000) { 3775 /* eslint-enable jsdoc/no-undefined-types */ 3776 external_wp_deprecated_default()('wp.compose.useCopyOnClick', { 3777 since: '5.8', 3778 alternative: 'wp.compose.useCopyToClipboard' 3779 }); 3780 3781 /** @type {import('react').MutableRefObject<Clipboard | undefined>} */ 3782 const clipboard = (0,external_wp_element_namespaceObject.useRef)(); 3783 const [hasCopied, setHasCopied] = (0,external_wp_element_namespaceObject.useState)(false); 3784 (0,external_wp_element_namespaceObject.useEffect)(() => { 3785 /** @type {number | undefined} */ 3786 let timeoutId; 3787 if (!ref.current) { 3788 return; 3789 } 3790 3791 // Clipboard listens to click events. 3792 clipboard.current = new (clipboard_default())(ref.current, { 3793 text: () => typeof text === 'function' ? text() : text 3794 }); 3795 clipboard.current.on('success', ({ 3796 clearSelection, 3797 trigger 3798 }) => { 3799 // Clearing selection will move focus back to the triggering button, 3800 // ensuring that it is not reset to the body, and further that it is 3801 // kept within the rendered node. 3802 clearSelection(); 3803 3804 // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 3805 if (trigger) { 3806 /** @type {HTMLElement} */trigger.focus(); 3807 } 3808 if (timeout) { 3809 setHasCopied(true); 3810 clearTimeout(timeoutId); 3811 timeoutId = setTimeout(() => setHasCopied(false), timeout); 3812 } 3813 }); 3814 return () => { 3815 if (clipboard.current) { 3816 clipboard.current.destroy(); 3817 } 3818 clearTimeout(timeoutId); 3819 }; 3820 }, [text, timeout, setHasCopied]); 3821 return hasCopied; 3822 } 3823 3824 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-to-clipboard/index.js 3825 /** 3826 * External dependencies 3827 */ 3828 3829 3830 /** 3831 * WordPress dependencies 3832 */ 3833 3834 3835 /** 3836 * Internal dependencies 3837 */ 3838 3839 3840 /** 3841 * @template T 3842 * @param {T} value 3843 * @return {import('react').RefObject<T>} The updated ref 3844 */ 3845 function useUpdatedRef(value) { 3846 const ref = (0,external_wp_element_namespaceObject.useRef)(value); 3847 ref.current = value; 3848 return ref; 3849 } 3850 3851 /** 3852 * Copies the given text to the clipboard when the element is clicked. 3853 * 3854 * @template {HTMLElement} TElementType 3855 * @param {string | (() => string)} text The text to copy. Use a function if not 3856 * already available and expensive to compute. 3857 * @param {Function} onSuccess Called when to text is copied. 3858 * 3859 * @return {import('react').Ref<TElementType>} A ref to assign to the target element. 3860 */ 3861 function useCopyToClipboard(text, onSuccess) { 3862 // Store the dependencies as refs and continuously update them so they're 3863 // fresh when the callback is called. 3864 const textRef = useUpdatedRef(text); 3865 const onSuccessRef = useUpdatedRef(onSuccess); 3866 return useRefEffect(node => { 3867 // Clipboard listens to click events. 3868 const clipboard = new (clipboard_default())(node, { 3869 text() { 3870 return typeof textRef.current === 'function' ? textRef.current() : textRef.current || ''; 3871 } 3872 }); 3873 clipboard.on('success', ({ 3874 clearSelection 3875 }) => { 3876 // Clearing selection will move focus back to the triggering 3877 // button, ensuring that it is not reset to the body, and 3878 // further that it is kept within the rendered node. 3879 clearSelection(); 3880 if (onSuccessRef.current) { 3881 onSuccessRef.current(); 3882 } 3883 }); 3884 return () => { 3885 clipboard.destroy(); 3886 }; 3887 }, []); 3888 } 3889 3890 ;// CONCATENATED MODULE: external ["wp","keycodes"] 3891 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; 3892 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js 3893 /** 3894 * WordPress dependencies 3895 */ 3896 3897 3898 3899 /** 3900 * Hook used to focus the first tabbable element on mount. 3901 * 3902 * @param {boolean | 'firstElement'} focusOnMount Focus on mount mode. 3903 * @return {import('react').RefCallback<HTMLElement>} Ref callback. 3904 * 3905 * @example 3906 * ```js 3907 * import { useFocusOnMount } from '@wordpress/compose'; 3908 * 3909 * const WithFocusOnMount = () => { 3910 * const ref = useFocusOnMount() 3911 * return ( 3912 * <div ref={ ref }> 3913 * <Button /> 3914 * <Button /> 3915 * </div> 3916 * ); 3917 * } 3918 * ``` 3919 */ 3920 function useFocusOnMount(focusOnMount = 'firstElement') { 3921 const focusOnMountRef = (0,external_wp_element_namespaceObject.useRef)(focusOnMount); 3922 3923 /** 3924 * Sets focus on a DOM element. 3925 * 3926 * @param {HTMLElement} target The DOM element to set focus to. 3927 * @return {void} 3928 */ 3929 const setFocus = target => { 3930 target.focus({ 3931 // When focusing newly mounted dialogs, 3932 // the position of the popover is often not right on the first render 3933 // This prevents the layout shifts when focusing the dialogs. 3934 preventScroll: true 3935 }); 3936 }; 3937 3938 /** @type {import('react').MutableRefObject<ReturnType<setTimeout> | undefined>} */ 3939 const timerId = (0,external_wp_element_namespaceObject.useRef)(); 3940 (0,external_wp_element_namespaceObject.useEffect)(() => { 3941 focusOnMountRef.current = focusOnMount; 3942 }, [focusOnMount]); 3943 (0,external_wp_element_namespaceObject.useEffect)(() => { 3944 return () => { 3945 if (timerId.current) { 3946 clearTimeout(timerId.current); 3947 } 3948 }; 3949 }, []); 3950 return (0,external_wp_element_namespaceObject.useCallback)(node => { 3951 var _node$ownerDocument$a; 3952 if (!node || focusOnMountRef.current === false) { 3953 return; 3954 } 3955 if (node.contains((_node$ownerDocument$a = node.ownerDocument?.activeElement) !== null && _node$ownerDocument$a !== void 0 ? _node$ownerDocument$a : null)) { 3956 return; 3957 } 3958 if (focusOnMountRef.current === 'firstElement') { 3959 timerId.current = setTimeout(() => { 3960 const firstTabbable = external_wp_dom_namespaceObject.focus.tabbable.find(node)[0]; 3961 if (firstTabbable) { 3962 setFocus( /** @type {HTMLElement} */firstTabbable); 3963 } 3964 }, 0); 3965 return; 3966 } 3967 setFocus(node); 3968 }, []); 3969 } 3970 3971 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js 3972 /** 3973 * WordPress dependencies 3974 */ 3975 3976 3977 /** @type {Element|null} */ 3978 let origin = null; 3979 3980 /** 3981 * Adds the unmount behavior of returning focus to the element which had it 3982 * previously as is expected for roles like menus or dialogs. 3983 * 3984 * @param {() => void} [onFocusReturn] Overrides the default return behavior. 3985 * @return {import('react').RefCallback<HTMLElement>} Element Ref. 3986 * 3987 * @example 3988 * ```js 3989 * import { useFocusReturn } from '@wordpress/compose'; 3990 * 3991 * const WithFocusReturn = () => { 3992 * const ref = useFocusReturn() 3993 * return ( 3994 * <div ref={ ref }> 3995 * <Button /> 3996 * <Button /> 3997 * </div> 3998 * ); 3999 * } 4000 * ``` 4001 */ 4002 function useFocusReturn(onFocusReturn) { 4003 /** @type {import('react').MutableRefObject<null | HTMLElement>} */ 4004 const ref = (0,external_wp_element_namespaceObject.useRef)(null); 4005 /** @type {import('react').MutableRefObject<null | Element>} */ 4006 const focusedBeforeMount = (0,external_wp_element_namespaceObject.useRef)(null); 4007 const onFocusReturnRef = (0,external_wp_element_namespaceObject.useRef)(onFocusReturn); 4008 (0,external_wp_element_namespaceObject.useEffect)(() => { 4009 onFocusReturnRef.current = onFocusReturn; 4010 }, [onFocusReturn]); 4011 return (0,external_wp_element_namespaceObject.useCallback)(node => { 4012 if (node) { 4013 // Set ref to be used when unmounting. 4014 ref.current = node; 4015 4016 // Only set when the node mounts. 4017 if (focusedBeforeMount.current) { 4018 return; 4019 } 4020 focusedBeforeMount.current = node.ownerDocument.activeElement; 4021 } else if (focusedBeforeMount.current) { 4022 const isFocused = ref.current?.contains(ref.current?.ownerDocument.activeElement); 4023 if (ref.current?.isConnected && !isFocused) { 4024 var _origin; 4025 (_origin = origin) !== null && _origin !== void 0 ? _origin : origin = focusedBeforeMount.current; 4026 return; 4027 } 4028 4029 // Defer to the component's own explicit focus return behavior, if 4030 // specified. This allows for support that the `onFocusReturn` 4031 // decides to allow the default behavior to occur under some 4032 // conditions. 4033 if (onFocusReturnRef.current) { 4034 onFocusReturnRef.current(); 4035 } else { 4036 /** @type {null|HTMLElement} */(!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus(); 4037 } 4038 origin = null; 4039 } 4040 }, []); 4041 } 4042 /* harmony default export */ const use_focus_return = (useFocusReturn); 4043 4044 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js 4045 /** 4046 * WordPress dependencies 4047 */ 4048 4049 4050 /** 4051 * Input types which are classified as button types, for use in considering 4052 * whether element is a (focus-normalized) button. 4053 */ 4054 const INPUT_BUTTON_TYPES = ['button', 'submit']; 4055 4056 /** 4057 * List of HTML button elements subject to focus normalization 4058 * 4059 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 4060 */ 4061 4062 /** 4063 * Returns true if the given element is a button element subject to focus 4064 * normalization, or false otherwise. 4065 * 4066 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 4067 * 4068 * @param eventTarget The target from a mouse or touch event. 4069 * 4070 * @return Whether the element is a button element subject to focus normalization. 4071 */ 4072 function isFocusNormalizedButton(eventTarget) { 4073 if (!(eventTarget instanceof window.HTMLElement)) { 4074 return false; 4075 } 4076 switch (eventTarget.nodeName) { 4077 case 'A': 4078 case 'BUTTON': 4079 return true; 4080 case 'INPUT': 4081 return INPUT_BUTTON_TYPES.includes(eventTarget.type); 4082 } 4083 return false; 4084 } 4085 /** 4086 * A react hook that can be used to check whether focus has moved outside the 4087 * element the event handlers are bound to. 4088 * 4089 * @param onFocusOutside A callback triggered when focus moves outside 4090 * the element the event handlers are bound to. 4091 * 4092 * @return An object containing event handlers. Bind the event handlers to a 4093 * wrapping element element to capture when focus moves outside that element. 4094 */ 4095 function useFocusOutside(onFocusOutside) { 4096 const currentOnFocusOutside = (0,external_wp_element_namespaceObject.useRef)(onFocusOutside); 4097 (0,external_wp_element_namespaceObject.useEffect)(() => { 4098 currentOnFocusOutside.current = onFocusOutside; 4099 }, [onFocusOutside]); 4100 const preventBlurCheck = (0,external_wp_element_namespaceObject.useRef)(false); 4101 const blurCheckTimeoutId = (0,external_wp_element_namespaceObject.useRef)(); 4102 4103 /** 4104 * Cancel a blur check timeout. 4105 */ 4106 const cancelBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(() => { 4107 clearTimeout(blurCheckTimeoutId.current); 4108 }, []); 4109 4110 // Cancel blur checks on unmount. 4111 (0,external_wp_element_namespaceObject.useEffect)(() => { 4112 return () => cancelBlurCheck(); 4113 }, []); 4114 4115 // Cancel a blur check if the callback or ref is no longer provided. 4116 (0,external_wp_element_namespaceObject.useEffect)(() => { 4117 if (!onFocusOutside) { 4118 cancelBlurCheck(); 4119 } 4120 }, [onFocusOutside, cancelBlurCheck]); 4121 4122 /** 4123 * Handles a mousedown or mouseup event to respectively assign and 4124 * unassign a flag for preventing blur check on button elements. Some 4125 * browsers, namely Firefox and Safari, do not emit a focus event on 4126 * button elements when clicked, while others do. The logic here 4127 * intends to normalize this as treating click on buttons as focus. 4128 * 4129 * @param event 4130 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 4131 */ 4132 const normalizeButtonFocus = (0,external_wp_element_namespaceObject.useCallback)(event => { 4133 const { 4134 type, 4135 target 4136 } = event; 4137 const isInteractionEnd = ['mouseup', 'touchend'].includes(type); 4138 if (isInteractionEnd) { 4139 preventBlurCheck.current = false; 4140 } else if (isFocusNormalizedButton(target)) { 4141 preventBlurCheck.current = true; 4142 } 4143 }, []); 4144 4145 /** 4146 * A callback triggered when a blur event occurs on the element the handler 4147 * is bound to. 4148 * 4149 * Calls the `onFocusOutside` callback in an immediate timeout if focus has 4150 * move outside the bound element and is still within the document. 4151 */ 4152 const queueBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(event => { 4153 // React does not allow using an event reference asynchronously 4154 // due to recycling behavior, except when explicitly persisted. 4155 event.persist(); 4156 4157 // Skip blur check if clicking button. See `normalizeButtonFocus`. 4158 if (preventBlurCheck.current) { 4159 return; 4160 } 4161 4162 // The usage of this attribute should be avoided. The only use case 4163 // would be when we load modals that are not React components and 4164 // therefore don't exist in the React tree. An example is opening 4165 // the Media Library modal from another dialog. 4166 // This attribute should contain a selector of the related target 4167 // we want to ignore, because we still need to trigger the blur event 4168 // on all other cases. 4169 const ignoreForRelatedTarget = event.target.getAttribute('data-unstable-ignore-focus-outside-for-relatedtarget'); 4170 if (ignoreForRelatedTarget && event.relatedTarget?.closest(ignoreForRelatedTarget)) { 4171 return; 4172 } 4173 blurCheckTimeoutId.current = setTimeout(() => { 4174 // If document is not focused then focus should remain 4175 // inside the wrapped component and therefore we cancel 4176 // this blur event thereby leaving focus in place. 4177 // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus. 4178 if (!document.hasFocus()) { 4179 event.preventDefault(); 4180 return; 4181 } 4182 if ('function' === typeof currentOnFocusOutside.current) { 4183 currentOnFocusOutside.current(event); 4184 } 4185 }, 0); 4186 }, []); 4187 return { 4188 onFocus: cancelBlurCheck, 4189 onMouseDown: normalizeButtonFocus, 4190 onMouseUp: normalizeButtonFocus, 4191 onTouchStart: normalizeButtonFocus, 4192 onTouchEnd: normalizeButtonFocus, 4193 onBlur: queueBlurCheck 4194 }; 4195 } 4196 4197 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js 4198 /** 4199 * WordPress dependencies 4200 */ 4201 4202 4203 /* eslint-disable jsdoc/valid-types */ 4204 /** 4205 * @template T 4206 * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef 4207 */ 4208 /* eslint-enable jsdoc/valid-types */ 4209 4210 /** 4211 * @template T 4212 * @param {import('react').Ref<T>} ref 4213 * @param {T} value 4214 */ 4215 function assignRef(ref, value) { 4216 if (typeof ref === 'function') { 4217 ref(value); 4218 } else if (ref && ref.hasOwnProperty('current')) { 4219 /* eslint-disable jsdoc/no-undefined-types */ 4220 /** @type {import('react').MutableRefObject<T>} */ref.current = value; 4221 /* eslint-enable jsdoc/no-undefined-types */ 4222 } 4223 } 4224 4225 /** 4226 * Merges refs into one ref callback. 4227 * 4228 * It also ensures that the merged ref callbacks are only called when they 4229 * change (as a result of a `useCallback` dependency update) OR when the ref 4230 * value changes, just as React does when passing a single ref callback to the 4231 * component. 4232 * 4233 * As expected, if you pass a new function on every render, the ref callback 4234 * will be called after every render. 4235 * 4236 * If you don't wish a ref callback to be called after every render, wrap it 4237 * with `useCallback( callback, dependencies )`. When a dependency changes, the 4238 * old ref callback will be called with `null` and the new ref callback will be 4239 * called with the same value. 4240 * 4241 * To make ref callbacks easier to use, you can also pass the result of 4242 * `useRefEffect`, which makes cleanup easier by allowing you to return a 4243 * cleanup function instead of handling `null`. 4244 * 4245 * It's also possible to _disable_ a ref (and its behaviour) by simply not 4246 * passing the ref. 4247 * 4248 * ```jsx 4249 * const ref = useRefEffect( ( node ) => { 4250 * node.addEventListener( ... ); 4251 * return () => { 4252 * node.removeEventListener( ... ); 4253 * }; 4254 * }, [ ...dependencies ] ); 4255 * const otherRef = useRef(); 4256 * const mergedRefs useMergeRefs( [ 4257 * enabled && ref, 4258 * otherRef, 4259 * ] ); 4260 * return <div ref={ mergedRefs } />; 4261 * ``` 4262 * 4263 * @template {import('react').Ref<any>} TRef 4264 * @param {Array<TRef>} refs The refs to be merged. 4265 * 4266 * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback. 4267 */ 4268 function useMergeRefs(refs) { 4269 const element = (0,external_wp_element_namespaceObject.useRef)(); 4270 const isAttached = (0,external_wp_element_namespaceObject.useRef)(false); 4271 const didElementChange = (0,external_wp_element_namespaceObject.useRef)(false); 4272 /* eslint-disable jsdoc/no-undefined-types */ 4273 /** @type {import('react').MutableRefObject<TRef[]>} */ 4274 /* eslint-enable jsdoc/no-undefined-types */ 4275 const previousRefs = (0,external_wp_element_namespaceObject.useRef)([]); 4276 const currentRefs = (0,external_wp_element_namespaceObject.useRef)(refs); 4277 4278 // Update on render before the ref callback is called, so the ref callback 4279 // always has access to the current refs. 4280 currentRefs.current = refs; 4281 4282 // If any of the refs change, call the previous ref with `null` and the new 4283 // ref with the node, except when the element changes in the same cycle, in 4284 // which case the ref callbacks will already have been called. 4285 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 4286 if (didElementChange.current === false && isAttached.current === true) { 4287 refs.forEach((ref, index) => { 4288 const previousRef = previousRefs.current[index]; 4289 if (ref !== previousRef) { 4290 assignRef(previousRef, null); 4291 assignRef(ref, element.current); 4292 } 4293 }); 4294 } 4295 previousRefs.current = refs; 4296 }, refs); 4297 4298 // No dependencies, must be reset after every render so ref callbacks are 4299 // correctly called after a ref change. 4300 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 4301 didElementChange.current = false; 4302 }); 4303 4304 // There should be no dependencies so that `callback` is only called when 4305 // the node changes. 4306 return (0,external_wp_element_namespaceObject.useCallback)(value => { 4307 // Update the element so it can be used when calling ref callbacks on a 4308 // dependency change. 4309 assignRef(element, value); 4310 didElementChange.current = true; 4311 isAttached.current = value !== null; 4312 4313 // When an element changes, the current ref callback should be called 4314 // with the new element and the previous one with `null`. 4315 const refsToAssign = value ? currentRefs.current : previousRefs.current; 4316 4317 // Update the latest refs. 4318 for (const ref of refsToAssign) { 4319 assignRef(ref, value); 4320 } 4321 }, []); 4322 } 4323 4324 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js 4325 /** 4326 * External dependencies 4327 */ 4328 4329 /** 4330 * WordPress dependencies 4331 */ 4332 4333 4334 4335 /** 4336 * Internal dependencies 4337 */ 4338 4339 4340 4341 4342 4343 /** 4344 * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors: 4345 * - constrained tabbing. 4346 * - focus on mount. 4347 * - return focus on unmount. 4348 * - focus outside. 4349 * 4350 * @param options Dialog Options. 4351 */ 4352 function useDialog(options) { 4353 const currentOptions = (0,external_wp_element_namespaceObject.useRef)(); 4354 const { 4355 constrainTabbing = options.focusOnMount !== false 4356 } = options; 4357 (0,external_wp_element_namespaceObject.useEffect)(() => { 4358 currentOptions.current = options; 4359 }, Object.values(options)); 4360 const constrainedTabbingRef = use_constrained_tabbing(); 4361 const focusOnMountRef = useFocusOnMount(options.focusOnMount); 4362 const focusReturnRef = use_focus_return(); 4363 const focusOutsideProps = useFocusOutside(event => { 4364 // This unstable prop is here only to manage backward compatibility 4365 // for the Popover component otherwise, the onClose should be enough. 4366 if (currentOptions.current?.__unstableOnClose) { 4367 currentOptions.current.__unstableOnClose('focus-outside', event); 4368 } else if (currentOptions.current?.onClose) { 4369 currentOptions.current.onClose(); 4370 } 4371 }); 4372 const closeOnEscapeRef = (0,external_wp_element_namespaceObject.useCallback)(node => { 4373 if (!node) { 4374 return; 4375 } 4376 node.addEventListener('keydown', event => { 4377 // Close on escape. 4378 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) { 4379 event.preventDefault(); 4380 currentOptions.current.onClose(); 4381 } 4382 }); 4383 }, []); 4384 return [useMergeRefs([constrainTabbing ? constrainedTabbingRef : null, options.focusOnMount !== false ? focusReturnRef : null, options.focusOnMount !== false ? focusOnMountRef : null, closeOnEscapeRef]), { 4385 ...focusOutsideProps, 4386 tabIndex: -1 4387 }]; 4388 } 4389 /* harmony default export */ const use_dialog = (useDialog); 4390 4391 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-disabled/index.js 4392 /** 4393 * Internal dependencies 4394 */ 4395 4396 4397 4398 /** 4399 * In some circumstances, such as block previews, all focusable DOM elements 4400 * (input fields, links, buttons, etc.) need to be disabled. This hook adds the 4401 * behavior to disable nested DOM elements to the returned ref. 4402 * 4403 * If you can, prefer the use of the inert HTML attribute. 4404 * 4405 * @param {Object} config Configuration object. 4406 * @param {boolean=} config.isDisabled Whether the element should be disabled. 4407 * @return {import('react').RefCallback<HTMLElement>} Element Ref. 4408 * 4409 * @example 4410 * ```js 4411 * import { useDisabled } from '@wordpress/compose'; 4412 * 4413 * const DisabledExample = () => { 4414 * const disabledRef = useDisabled(); 4415 * return ( 4416 * <div ref={ disabledRef }> 4417 * <a href="#">This link will have tabindex set to -1</a> 4418 * <input placeholder="This input will have the disabled attribute added to it." type="text" /> 4419 * </div> 4420 * ); 4421 * }; 4422 * ``` 4423 */ 4424 function useDisabled({ 4425 isDisabled: isDisabledProp = false 4426 } = {}) { 4427 return useRefEffect(node => { 4428 if (isDisabledProp) { 4429 return; 4430 } 4431 const defaultView = node?.ownerDocument?.defaultView; 4432 if (!defaultView) { 4433 return; 4434 } 4435 4436 /** A variable keeping track of the previous updates in order to restore them. */ 4437 const updates = []; 4438 const disable = () => { 4439 node.childNodes.forEach(child => { 4440 if (!(child instanceof defaultView.HTMLElement)) { 4441 return; 4442 } 4443 if (!child.getAttribute('inert')) { 4444 child.setAttribute('inert', 'true'); 4445 updates.push(() => { 4446 child.removeAttribute('inert'); 4447 }); 4448 } 4449 }); 4450 }; 4451 4452 // Debounce re-disable since disabling process itself will incur 4453 // additional mutations which should be ignored. 4454 const debouncedDisable = debounce(disable, 0, { 4455 leading: true 4456 }); 4457 disable(); 4458 4459 /** @type {MutationObserver | undefined} */ 4460 const observer = new window.MutationObserver(debouncedDisable); 4461 observer.observe(node, { 4462 childList: true 4463 }); 4464 return () => { 4465 if (observer) { 4466 observer.disconnect(); 4467 } 4468 debouncedDisable.cancel(); 4469 updates.forEach(update => update()); 4470 }; 4471 }, [isDisabledProp]); 4472 } 4473 4474 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js 4475 /** 4476 * WordPress dependencies 4477 */ 4478 4479 4480 /** 4481 * Preferred over direct usage of `useLayoutEffect` when supporting 4482 * server rendered components (SSR) because currently React 4483 * throws a warning when using useLayoutEffect in that environment. 4484 */ 4485 const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_wp_element_namespaceObject.useLayoutEffect : external_wp_element_namespaceObject.useEffect; 4486 /* harmony default export */ const use_isomorphic_layout_effect = (useIsomorphicLayoutEffect); 4487 4488 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js 4489 /** 4490 * WordPress dependencies 4491 */ 4492 4493 4494 /** 4495 * Internal dependencies 4496 */ 4497 4498 4499 // Event handlers that are triggered from `document` listeners accept a MouseEvent, 4500 // while those triggered from React listeners accept a React.MouseEvent. 4501 /** 4502 * @param {Object} props 4503 * @param {(e: import('react').MouseEvent) => void} props.onDragStart 4504 * @param {(e: MouseEvent) => void} props.onDragMove 4505 * @param {(e?: MouseEvent) => void} props.onDragEnd 4506 */ 4507 function useDragging({ 4508 onDragStart, 4509 onDragMove, 4510 onDragEnd 4511 }) { 4512 const [isDragging, setIsDragging] = (0,external_wp_element_namespaceObject.useState)(false); 4513 const eventsRef = (0,external_wp_element_namespaceObject.useRef)({ 4514 onDragStart, 4515 onDragMove, 4516 onDragEnd 4517 }); 4518 use_isomorphic_layout_effect(() => { 4519 eventsRef.current.onDragStart = onDragStart; 4520 eventsRef.current.onDragMove = onDragMove; 4521 eventsRef.current.onDragEnd = onDragEnd; 4522 }, [onDragStart, onDragMove, onDragEnd]); 4523 4524 /** @type {(e: MouseEvent) => void} */ 4525 const onMouseMove = (0,external_wp_element_namespaceObject.useCallback)(event => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event), []); 4526 /** @type {(e?: MouseEvent) => void} */ 4527 const endDrag = (0,external_wp_element_namespaceObject.useCallback)(event => { 4528 if (eventsRef.current.onDragEnd) { 4529 eventsRef.current.onDragEnd(event); 4530 } 4531 document.removeEventListener('mousemove', onMouseMove); 4532 document.removeEventListener('mouseup', endDrag); 4533 setIsDragging(false); 4534 }, []); 4535 /** @type {(e: import('react').MouseEvent) => void} */ 4536 const startDrag = (0,external_wp_element_namespaceObject.useCallback)(event => { 4537 if (eventsRef.current.onDragStart) { 4538 eventsRef.current.onDragStart(event); 4539 } 4540 document.addEventListener('mousemove', onMouseMove); 4541 document.addEventListener('mouseup', endDrag); 4542 setIsDragging(true); 4543 }, []); 4544 4545 // Remove the global events when unmounting if needed. 4546 (0,external_wp_element_namespaceObject.useEffect)(() => { 4547 return () => { 4548 if (isDragging) { 4549 document.removeEventListener('mousemove', onMouseMove); 4550 document.removeEventListener('mouseup', endDrag); 4551 } 4552 }; 4553 }, [isDragging]); 4554 return { 4555 startDrag, 4556 endDrag, 4557 isDragging 4558 }; 4559 } 4560 4561 // EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js 4562 var mousetrap_mousetrap = __webpack_require__(1933); 4563 var mousetrap_default = /*#__PURE__*/__webpack_require__.n(mousetrap_mousetrap); 4564 // EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js 4565 var mousetrap_global_bind = __webpack_require__(5760); 4566 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js 4567 /** 4568 * External dependencies 4569 */ 4570 4571 4572 4573 /** 4574 * WordPress dependencies 4575 */ 4576 4577 4578 4579 /** 4580 * A block selection object. 4581 * 4582 * @typedef {Object} WPKeyboardShortcutConfig 4583 * 4584 * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields. 4585 * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown. 4586 * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true. 4587 * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event. 4588 */ 4589 4590 /* eslint-disable jsdoc/valid-types */ 4591 /** 4592 * Attach a keyboard shortcut handler. 4593 * 4594 * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter. 4595 * 4596 * @param {string[]|string} shortcuts Keyboard Shortcuts. 4597 * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback. 4598 * @param {WPKeyboardShortcutConfig} options Shortcut options. 4599 */ 4600 function useKeyboardShortcut( /* eslint-enable jsdoc/valid-types */ 4601 shortcuts, callback, { 4602 bindGlobal = false, 4603 eventName = 'keydown', 4604 isDisabled = false, 4605 // This is important for performance considerations. 4606 target 4607 } = {}) { 4608 const currentCallback = (0,external_wp_element_namespaceObject.useRef)(callback); 4609 (0,external_wp_element_namespaceObject.useEffect)(() => { 4610 currentCallback.current = callback; 4611 }, [callback]); 4612 (0,external_wp_element_namespaceObject.useEffect)(() => { 4613 if (isDisabled) { 4614 return; 4615 } 4616 const mousetrap = new (mousetrap_default())(target && target.current ? target.current : 4617 // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`. 4618 // 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 4619 // necessary to maintain the existing behavior. 4620 /** @type {Element} */ /** @type {unknown} */ 4621 document); 4622 const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts]; 4623 shortcutsArray.forEach(shortcut => { 4624 const keys = shortcut.split('+'); 4625 // Determines whether a key is a modifier by the length of the string. 4626 // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that 4627 // the modifiers are Shift and Cmd because they're not a single character. 4628 const modifiers = new Set(keys.filter(value => value.length > 1)); 4629 const hasAlt = modifiers.has('alt'); 4630 const hasShift = modifiers.has('shift'); 4631 4632 // This should be better moved to the shortcut registration instead. 4633 if ((0,external_wp_keycodes_namespaceObject.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { 4634 throw new Error(`Cannot bind $shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`); 4635 } 4636 const bindFn = bindGlobal ? 'bindGlobal' : 'bind'; 4637 // @ts-ignore `bindGlobal` is an undocumented property 4638 mousetrap[bindFn](shortcut, ( /* eslint-disable jsdoc/valid-types */ 4639 /** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */...args) => /* eslint-enable jsdoc/valid-types */ 4640 currentCallback.current(...args), eventName); 4641 }); 4642 return () => { 4643 mousetrap.reset(); 4644 }; 4645 }, [shortcuts, bindGlobal, eventName, target, isDisabled]); 4646 } 4647 /* harmony default export */ const use_keyboard_shortcut = (useKeyboardShortcut); 4648 4649 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js 4650 /** 4651 * WordPress dependencies 4652 */ 4653 4654 4655 /** 4656 * A new MediaQueryList object for the media query 4657 * 4658 * @param {string} [query] Media Query. 4659 * @return {MediaQueryList|null} A new object for the media query 4660 */ 4661 function getMediaQueryList(query) { 4662 if (query && typeof window !== 'undefined' && typeof window.matchMedia === 'function') { 4663 return window.matchMedia(query); 4664 } 4665 return null; 4666 } 4667 4668 /** 4669 * Runs a media query and returns its value when it changes. 4670 * 4671 * @param {string} [query] Media Query. 4672 * @return {boolean} return value of the media query. 4673 */ 4674 function useMediaQuery(query) { 4675 const source = (0,external_wp_element_namespaceObject.useMemo)(() => { 4676 const mediaQueryList = getMediaQueryList(query); 4677 return { 4678 /** @type {(onStoreChange: () => void) => () => void} */ 4679 subscribe(onStoreChange) { 4680 if (!mediaQueryList) { 4681 return () => {}; 4682 } 4683 4684 // Avoid a fatal error when browsers don't support `addEventListener` on MediaQueryList. 4685 mediaQueryList.addEventListener?.('change', onStoreChange); 4686 return () => { 4687 mediaQueryList.removeEventListener?.('change', onStoreChange); 4688 }; 4689 }, 4690 getValue() { 4691 var _mediaQueryList$match; 4692 return (_mediaQueryList$match = mediaQueryList?.matches) !== null && _mediaQueryList$match !== void 0 ? _mediaQueryList$match : false; 4693 } 4694 }; 4695 }, [query]); 4696 return (0,external_wp_element_namespaceObject.useSyncExternalStore)(source.subscribe, source.getValue, () => false); 4697 } 4698 4699 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js 4700 /** 4701 * WordPress dependencies 4702 */ 4703 4704 4705 /** 4706 * Use something's value from the previous render. 4707 * Based on https://usehooks.com/usePrevious/. 4708 * 4709 * @param value The value to track. 4710 * 4711 * @return The value from the previous render. 4712 */ 4713 function usePrevious(value) { 4714 const ref = (0,external_wp_element_namespaceObject.useRef)(); 4715 4716 // Store current value in ref. 4717 (0,external_wp_element_namespaceObject.useEffect)(() => { 4718 ref.current = value; 4719 }, [value]); // Re-run when value changes. 4720 4721 // Return previous value (happens before update in useEffect above). 4722 return ref.current; 4723 } 4724 4725 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js 4726 /** 4727 * Internal dependencies 4728 */ 4729 4730 4731 /** 4732 * Hook returning whether the user has a preference for reduced motion. 4733 * 4734 * @return {boolean} Reduced motion preference value. 4735 */ 4736 const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)'); 4737 /* harmony default export */ const use_reduced_motion = (useReducedMotion); 4738 4739 // EXTERNAL MODULE: ./node_modules/@wordpress/undo-manager/build-module/index.js 4740 var build_module = __webpack_require__(6689); 4741 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-state-with-history/index.js 4742 /** 4743 * WordPress dependencies 4744 */ 4745 4746 4747 function undoRedoReducer(state, action) { 4748 switch (action.type) { 4749 case 'UNDO': 4750 { 4751 const undoRecord = state.manager.undo(); 4752 if (undoRecord) { 4753 return { 4754 ...state, 4755 value: undoRecord[0].changes.prop.from 4756 }; 4757 } 4758 return state; 4759 } 4760 case 'REDO': 4761 { 4762 const redoRecord = state.manager.redo(); 4763 if (redoRecord) { 4764 return { 4765 ...state, 4766 value: redoRecord[0].changes.prop.to 4767 }; 4768 } 4769 return state; 4770 } 4771 case 'RECORD': 4772 { 4773 state.manager.addRecord([{ 4774 id: 'object', 4775 changes: { 4776 prop: { 4777 from: state.value, 4778 to: action.value 4779 } 4780 } 4781 }], action.isStaged); 4782 return { 4783 ...state, 4784 value: action.value 4785 }; 4786 } 4787 } 4788 return state; 4789 } 4790 function initReducer(value) { 4791 return { 4792 manager: (0,build_module.createUndoManager)(), 4793 value 4794 }; 4795 } 4796 4797 /** 4798 * useState with undo/redo history. 4799 * 4800 * @param initialValue Initial value. 4801 * @return Value, setValue, hasUndo, hasRedo, undo, redo. 4802 */ 4803 function useStateWithHistory(initialValue) { 4804 const [state, dispatch] = (0,external_wp_element_namespaceObject.useReducer)(undoRedoReducer, initialValue, initReducer); 4805 return { 4806 value: state.value, 4807 setValue: (0,external_wp_element_namespaceObject.useCallback)((newValue, isStaged) => { 4808 dispatch({ 4809 type: 'RECORD', 4810 value: newValue, 4811 isStaged 4812 }); 4813 }, []), 4814 hasUndo: state.manager.hasUndo(), 4815 hasRedo: state.manager.hasRedo(), 4816 undo: (0,external_wp_element_namespaceObject.useCallback)(() => { 4817 dispatch({ 4818 type: 'UNDO' 4819 }); 4820 }, []), 4821 redo: (0,external_wp_element_namespaceObject.useCallback)(() => { 4822 dispatch({ 4823 type: 'REDO' 4824 }); 4825 }, []) 4826 }; 4827 } 4828 4829 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js 4830 /** 4831 * WordPress dependencies 4832 */ 4833 4834 4835 /** 4836 * Internal dependencies 4837 */ 4838 4839 4840 /** 4841 * @typedef {"huge" | "wide" | "large" | "medium" | "small" | "mobile"} WPBreakpoint 4842 */ 4843 4844 /** 4845 * Hash of breakpoint names with pixel width at which it becomes effective. 4846 * 4847 * @see _breakpoints.scss 4848 * 4849 * @type {Record<WPBreakpoint, number>} 4850 */ 4851 const BREAKPOINTS = { 4852 huge: 1440, 4853 wide: 1280, 4854 large: 960, 4855 medium: 782, 4856 small: 600, 4857 mobile: 480 4858 }; 4859 4860 /** 4861 * @typedef {">=" | "<"} WPViewportOperator 4862 */ 4863 4864 /** 4865 * Object mapping media query operators to the condition to be used. 4866 * 4867 * @type {Record<WPViewportOperator, string>} 4868 */ 4869 const CONDITIONS = { 4870 '>=': 'min-width', 4871 '<': 'max-width' 4872 }; 4873 4874 /** 4875 * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values. 4876 * 4877 * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>} 4878 */ 4879 const OPERATOR_EVALUATORS = { 4880 '>=': (breakpointValue, width) => width >= breakpointValue, 4881 '<': (breakpointValue, width) => width < breakpointValue 4882 }; 4883 const ViewportMatchWidthContext = (0,external_wp_element_namespaceObject.createContext)( /** @type {null | number} */null); 4884 4885 /** 4886 * Returns true if the viewport matches the given query, or false otherwise. 4887 * 4888 * @param {WPBreakpoint} breakpoint Breakpoint size name. 4889 * @param {WPViewportOperator} [operator=">="] Viewport operator. 4890 * 4891 * @example 4892 * 4893 * ```js 4894 * useViewportMatch( 'huge', '<' ); 4895 * useViewportMatch( 'medium' ); 4896 * ``` 4897 * 4898 * @return {boolean} Whether viewport matches query. 4899 */ 4900 const useViewportMatch = (breakpoint, operator = '>=') => { 4901 const simulatedWidth = (0,external_wp_element_namespaceObject.useContext)(ViewportMatchWidthContext); 4902 const mediaQuery = !simulatedWidth && `($CONDITIONS[operator]}: $BREAKPOINTS[breakpoint]}px)`; 4903 const mediaQueryResult = useMediaQuery(mediaQuery || undefined); 4904 if (simulatedWidth) { 4905 return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth); 4906 } 4907 return mediaQueryResult; 4908 }; 4909 useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider; 4910 /* harmony default export */ const use_viewport_match = (useViewportMatch); 4911 4912 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js 4913 4914 /** 4915 * External dependencies 4916 */ 4917 4918 /** 4919 * WordPress dependencies 4920 */ 4921 4922 // This of course could've been more streamlined with internal state instead of 4923 // refs, but then host hooks / components could not opt out of renders. 4924 // This could've been exported to its own module, but the current build doesn't 4925 // seem to work with module imports and I had no more time to spend on this... 4926 function useResolvedElement(subscriber, refOrElement) { 4927 const callbackRefElement = (0,external_wp_element_namespaceObject.useRef)(null); 4928 const lastReportRef = (0,external_wp_element_namespaceObject.useRef)(null); 4929 const cleanupRef = (0,external_wp_element_namespaceObject.useRef)(); 4930 const callSubscriber = (0,external_wp_element_namespaceObject.useCallback)(() => { 4931 let element = null; 4932 if (callbackRefElement.current) { 4933 element = callbackRefElement.current; 4934 } else if (refOrElement) { 4935 if (refOrElement instanceof HTMLElement) { 4936 element = refOrElement; 4937 } else { 4938 element = refOrElement.current; 4939 } 4940 } 4941 if (lastReportRef.current && lastReportRef.current.element === element && lastReportRef.current.reporter === callSubscriber) { 4942 return; 4943 } 4944 if (cleanupRef.current) { 4945 cleanupRef.current(); 4946 // Making sure the cleanup is not called accidentally multiple times. 4947 cleanupRef.current = null; 4948 } 4949 lastReportRef.current = { 4950 reporter: callSubscriber, 4951 element 4952 }; 4953 4954 // Only calling the subscriber, if there's an actual element to report. 4955 if (element) { 4956 cleanupRef.current = subscriber(element); 4957 } 4958 }, [refOrElement, subscriber]); 4959 4960 // On each render, we check whether a ref changed, or if we got a new raw 4961 // element. 4962 (0,external_wp_element_namespaceObject.useEffect)(() => { 4963 // With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a 4964 // render accompanying that change as well. 4965 // To guarantee we always have the right element, one must use the ref callback provided instead, but we support 4966 // RefObjects to make the hook API more convenient in certain cases. 4967 callSubscriber(); 4968 }, [callSubscriber]); 4969 return (0,external_wp_element_namespaceObject.useCallback)(element => { 4970 callbackRefElement.current = element; 4971 callSubscriber(); 4972 }, [callSubscriber]); 4973 } 4974 // We're only using the first element of the size sequences, until future versions of the spec solidify on how 4975 // exactly it'll be used for fragments in multi-column scenarios: 4976 // From the spec: 4977 // > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments, 4978 // > which occur in multi-column scenarios. However the current definitions of content rect and border box do not 4979 // > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single 4980 // > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column. 4981 // > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information. 4982 // (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface) 4983 // 4984 // Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback, 4985 // regardless of the "box" option. 4986 // The spec states the following on this: 4987 // > This does not have any impact on which box dimensions are returned to the defined callback when the event 4988 // > is fired, it solely defines which box the author wishes to observe layout changes on. 4989 // (https://drafts.csswg.org/resize-observer/#resize-observer-interface) 4990 // I'm not exactly clear on what this means, especially when you consider a later section stating the following: 4991 // > This section is non-normative. An author may desire to observe more than one CSS box. 4992 // > In this case, author will need to use multiple ResizeObservers. 4993 // (https://drafts.csswg.org/resize-observer/#resize-observer-interface) 4994 // Which is clearly not how current browser implementations behave, and seems to contradict the previous quote. 4995 // For this reason I decided to only return the requested size, 4996 // even though it seems we have access to results for all box types. 4997 // This also means that we get to keep the current api, being able to return a simple { width, height } pair, 4998 // regardless of box option. 4999 const extractSize = (entry, boxProp, sizeType) => { 5000 if (!entry[boxProp]) { 5001 if (boxProp === 'contentBoxSize') { 5002 // The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec. 5003 // See the 6th step in the description for the RO algorithm: 5004 // https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h 5005 // > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box". 5006 // In real browser implementations of course these objects differ, but the width/height values should be equivalent. 5007 return entry.contentRect[sizeType === 'inlineSize' ? 'width' : 'height']; 5008 } 5009 return undefined; 5010 } 5011 5012 // A couple bytes smaller than calling Array.isArray() and just as effective here. 5013 return entry[boxProp][0] ? entry[boxProp][0][sizeType] : 5014 // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current 5015 // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`. 5016 // @ts-ignore 5017 entry[boxProp][sizeType]; 5018 }; 5019 function useResizeObserver(opts = {}) { 5020 // Saving the callback as a ref. With this, I don't need to put onResize in the 5021 // effect dep array, and just passing in an anonymous function without memoising 5022 // will not reinstantiate the hook's ResizeObserver. 5023 const onResize = opts.onResize; 5024 const onResizeRef = (0,external_wp_element_namespaceObject.useRef)(undefined); 5025 onResizeRef.current = onResize; 5026 const round = opts.round || Math.round; 5027 5028 // Using a single instance throughout the hook's lifetime 5029 const resizeObserverRef = (0,external_wp_element_namespaceObject.useRef)(); 5030 const [size, setSize] = (0,external_wp_element_namespaceObject.useState)({ 5031 width: undefined, 5032 height: undefined 5033 }); 5034 5035 // In certain edge cases the RO might want to report a size change just after 5036 // the component unmounted. 5037 const didUnmount = (0,external_wp_element_namespaceObject.useRef)(false); 5038 (0,external_wp_element_namespaceObject.useEffect)(() => { 5039 didUnmount.current = false; 5040 return () => { 5041 didUnmount.current = true; 5042 }; 5043 }, []); 5044 5045 // Using a ref to track the previous width / height to avoid unnecessary renders. 5046 const previous = (0,external_wp_element_namespaceObject.useRef)({ 5047 width: undefined, 5048 height: undefined 5049 }); 5050 5051 // This block is kinda like a useEffect, only it's called whenever a new 5052 // element could be resolved based on the ref option. It also has a cleanup 5053 // function. 5054 const refCallback = useResolvedElement((0,external_wp_element_namespaceObject.useCallback)(element => { 5055 // We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe. 5056 // This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option. 5057 if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) { 5058 resizeObserverRef.current = { 5059 box: opts.box, 5060 round, 5061 instance: new ResizeObserver(entries => { 5062 const entry = entries[0]; 5063 let boxProp = 'borderBoxSize'; 5064 if (opts.box === 'border-box') { 5065 boxProp = 'borderBoxSize'; 5066 } else { 5067 boxProp = opts.box === 'device-pixel-content-box' ? 'devicePixelContentBoxSize' : 'contentBoxSize'; 5068 } 5069 const reportedWidth = extractSize(entry, boxProp, 'inlineSize'); 5070 const reportedHeight = extractSize(entry, boxProp, 'blockSize'); 5071 const newWidth = reportedWidth ? round(reportedWidth) : undefined; 5072 const newHeight = reportedHeight ? round(reportedHeight) : undefined; 5073 if (previous.current.width !== newWidth || previous.current.height !== newHeight) { 5074 const newSize = { 5075 width: newWidth, 5076 height: newHeight 5077 }; 5078 previous.current.width = newWidth; 5079 previous.current.height = newHeight; 5080 if (onResizeRef.current) { 5081 onResizeRef.current(newSize); 5082 } else if (!didUnmount.current) { 5083 setSize(newSize); 5084 } 5085 } 5086 }) 5087 }; 5088 } 5089 resizeObserverRef.current.instance.observe(element, { 5090 box: opts.box 5091 }); 5092 return () => { 5093 if (resizeObserverRef.current) { 5094 resizeObserverRef.current.instance.unobserve(element); 5095 } 5096 }; 5097 }, [opts.box, round]), opts.ref); 5098 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 5099 ref: refCallback, 5100 width: size.width, 5101 height: size.height 5102 }), [refCallback, size ? size.width : null, size ? size.height : null]); 5103 } 5104 5105 /** 5106 * Hook which allows to listen the resize event of any target element when it changes sizes. 5107 * _Note: `useResizeObserver` will report `null` until after first render. 5108 * 5109 * @example 5110 * 5111 * ```js 5112 * const App = () => { 5113 * const [ resizeListener, sizes ] = useResizeObserver(); 5114 * 5115 * return ( 5116 * <div> 5117 * { resizeListener } 5118 * Your content here 5119 * </div> 5120 * ); 5121 * }; 5122 * ``` 5123 */ 5124 function useResizeAware() { 5125 const { 5126 ref, 5127 width, 5128 height 5129 } = useResizeObserver(); 5130 const sizes = (0,external_wp_element_namespaceObject.useMemo)(() => { 5131 return { 5132 width: width !== null && width !== void 0 ? width : null, 5133 height: height !== null && height !== void 0 ? height : null 5134 }; 5135 }, [width, height]); 5136 const resizeListener = (0,external_React_namespaceObject.createElement)("div", { 5137 style: { 5138 position: 'absolute', 5139 top: 0, 5140 left: 0, 5141 right: 0, 5142 bottom: 0, 5143 pointerEvents: 'none', 5144 opacity: 0, 5145 overflow: 'hidden', 5146 zIndex: -1 5147 }, 5148 "aria-hidden": "true", 5149 ref: ref 5150 }); 5151 return [resizeListener, sizes]; 5152 } 5153 5154 ;// CONCATENATED MODULE: external ["wp","priorityQueue"] 5155 const external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"]; 5156 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js 5157 /** 5158 * WordPress dependencies 5159 */ 5160 5161 5162 /** 5163 * Returns the first items from list that are present on state. 5164 * 5165 * @param list New array. 5166 * @param state Current state. 5167 * @return First items present iin state. 5168 */ 5169 function getFirstItemsPresentInState(list, state) { 5170 const firstItems = []; 5171 for (let i = 0; i < list.length; i++) { 5172 const item = list[i]; 5173 if (!state.includes(item)) { 5174 break; 5175 } 5176 firstItems.push(item); 5177 } 5178 return firstItems; 5179 } 5180 5181 /** 5182 * React hook returns an array which items get asynchronously appended from a source array. 5183 * This behavior is useful if we want to render a list of items asynchronously for performance reasons. 5184 * 5185 * @param list Source array. 5186 * @param config Configuration object. 5187 * 5188 * @return Async array. 5189 */ 5190 function useAsyncList(list, config = { 5191 step: 1 5192 }) { 5193 const { 5194 step = 1 5195 } = config; 5196 const [current, setCurrent] = (0,external_wp_element_namespaceObject.useState)([]); 5197 (0,external_wp_element_namespaceObject.useEffect)(() => { 5198 // On reset, we keep the first items that were previously rendered. 5199 let firstItems = getFirstItemsPresentInState(list, current); 5200 if (firstItems.length < step) { 5201 firstItems = firstItems.concat(list.slice(firstItems.length, step)); 5202 } 5203 setCurrent(firstItems); 5204 const asyncQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)(); 5205 for (let i = firstItems.length; i < list.length; i += step) { 5206 asyncQueue.add({}, () => { 5207 (0,external_wp_element_namespaceObject.flushSync)(() => { 5208 setCurrent(state => [...state, ...list.slice(i, i + step)]); 5209 }); 5210 }); 5211 } 5212 return () => asyncQueue.reset(); 5213 }, [list]); 5214 return current; 5215 } 5216 /* harmony default export */ const use_async_list = (useAsyncList); 5217 5218 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js 5219 /** 5220 * Internal dependencies 5221 */ 5222 5223 5224 // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case 5225 // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript 5226 /* eslint-disable jsdoc/check-types */ 5227 /** 5228 * Hook that performs a shallow comparison between the preview value of an object 5229 * and the new one, if there's a difference, it prints it to the console. 5230 * this is useful in performance related work, to check why a component re-renders. 5231 * 5232 * @example 5233 * 5234 * ```jsx 5235 * function MyComponent(props) { 5236 * useWarnOnChange(props); 5237 * 5238 * return "Something"; 5239 * } 5240 * ``` 5241 * 5242 * @param {object} object Object which changes to compare. 5243 * @param {string} prefix Just a prefix to show when console logging. 5244 */ 5245 function useWarnOnChange(object, prefix = 'Change detection') { 5246 const previousValues = usePrevious(object); 5247 Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(([key, value]) => { 5248 if (value !== object[( /** @type {keyof typeof object} */key)]) { 5249 // eslint-disable-next-line no-console 5250 console.warn(`$prefix}: $key} key changed:`, value, object[( /** @type {keyof typeof object} */key)] 5251 /* eslint-enable jsdoc/check-types */); 5252 } 5253 }); 5254 } 5255 /* harmony default export */ const use_warn_on_change = (useWarnOnChange); 5256 5257 ;// CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js 5258 5259 5260 function areInputsEqual(newInputs, lastInputs) { 5261 if (newInputs.length !== lastInputs.length) { 5262 return false; 5263 } 5264 5265 for (var i = 0; i < newInputs.length; i++) { 5266 if (newInputs[i] !== lastInputs[i]) { 5267 return false; 5268 } 5269 } 5270 5271 return true; 5272 } 5273 5274 function useMemoOne(getResult, inputs) { 5275 var initial = (0,external_React_namespaceObject.useState)(function () { 5276 return { 5277 inputs: inputs, 5278 result: getResult() 5279 }; 5280 })[0]; 5281 var isFirstRun = (0,external_React_namespaceObject.useRef)(true); 5282 var committed = (0,external_React_namespaceObject.useRef)(initial); 5283 var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); 5284 var cache = useCache ? committed.current : { 5285 inputs: inputs, 5286 result: getResult() 5287 }; 5288 (0,external_React_namespaceObject.useEffect)(function () { 5289 isFirstRun.current = false; 5290 committed.current = cache; 5291 }, [cache]); 5292 return cache.result; 5293 } 5294 function useCallbackOne(callback, inputs) { 5295 return useMemoOne(function () { 5296 return callback; 5297 }, inputs); 5298 } 5299 var useMemo = (/* unused pure expression or super */ null && (useMemoOne)); 5300 var useCallback = (/* unused pure expression or super */ null && (useCallbackOne)); 5301 5302 5303 5304 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js 5305 /** 5306 * External dependencies 5307 */ 5308 5309 5310 /** 5311 * WordPress dependencies 5312 */ 5313 5314 5315 /** 5316 * Internal dependencies 5317 */ 5318 5319 5320 /** 5321 * Debounces a function similar to Lodash's `debounce`. A new debounced function will 5322 * be returned and any scheduled calls cancelled if any of the arguments change, 5323 * including the function to debounce, so please wrap functions created on 5324 * render in components in `useCallback`. 5325 * 5326 * @see https://docs-lodash.com/v4/debounce/ 5327 * 5328 * @template {(...args: any[]) => void} TFunc 5329 * 5330 * @param {TFunc} fn The function to debounce. 5331 * @param {number} [wait] The number of milliseconds to delay. 5332 * @param {import('../../utils/debounce').DebounceOptions} [options] The options object. 5333 * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Debounced function. 5334 */ 5335 function useDebounce(fn, wait, options) { 5336 const debounced = useMemoOne(() => debounce(fn, wait !== null && wait !== void 0 ? wait : 0, options), [fn, wait, options]); 5337 (0,external_wp_element_namespaceObject.useEffect)(() => () => debounced.cancel(), [debounced]); 5338 return debounced; 5339 } 5340 5341 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-debounced-input/index.js 5342 /** 5343 * WordPress dependencies 5344 */ 5345 5346 5347 /** 5348 * Internal dependencies 5349 */ 5350 5351 5352 /** 5353 * Helper hook for input fields that need to debounce the value before using it. 5354 * 5355 * @param {any} defaultValue The default value to use. 5356 * @return {[string, Function, string]} The input value, the setter and the debounced input value. 5357 */ 5358 function useDebouncedInput(defaultValue = '') { 5359 const [input, setInput] = (0,external_wp_element_namespaceObject.useState)(defaultValue); 5360 const [debouncedInput, setDebouncedState] = (0,external_wp_element_namespaceObject.useState)(defaultValue); 5361 const setDebouncedInput = useDebounce(setDebouncedState, 250); 5362 (0,external_wp_element_namespaceObject.useEffect)(() => { 5363 setDebouncedInput(input); 5364 }, [input]); 5365 return [input, setInput, debouncedInput]; 5366 } 5367 5368 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js 5369 /** 5370 * External dependencies 5371 */ 5372 5373 5374 /** 5375 * WordPress dependencies 5376 */ 5377 5378 5379 /** 5380 * Internal dependencies 5381 */ 5382 5383 5384 /** 5385 * Throttles a function similar to Lodash's `throttle`. A new throttled function will 5386 * be returned and any scheduled calls cancelled if any of the arguments change, 5387 * including the function to throttle, so please wrap functions created on 5388 * render in components in `useCallback`. 5389 * 5390 * @see https://docs-lodash.com/v4/throttle/ 5391 * 5392 * @template {(...args: any[]) => void} TFunc 5393 * 5394 * @param {TFunc} fn The function to throttle. 5395 * @param {number} [wait] The number of milliseconds to throttle invocations to. 5396 * @param {import('../../utils/throttle').ThrottleOptions} [options] The options object. See linked documentation for details. 5397 * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Throttled function. 5398 */ 5399 function useThrottle(fn, wait, options) { 5400 const throttled = useMemoOne(() => throttle(fn, wait !== null && wait !== void 0 ? wait : 0, options), [fn, wait, options]); 5401 (0,external_wp_element_namespaceObject.useEffect)(() => () => throttled.cancel(), [throttled]); 5402 return throttled; 5403 } 5404 5405 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-drop-zone/index.js 5406 /** 5407 * WordPress dependencies 5408 */ 5409 5410 5411 /** 5412 * Internal dependencies 5413 */ 5414 5415 5416 /* eslint-disable jsdoc/valid-types */ 5417 /** 5418 * @template T 5419 * @param {T} value 5420 * @return {import('react').MutableRefObject<T|null>} A ref with the value. 5421 */ 5422 function useFreshRef(value) { 5423 /* eslint-enable jsdoc/valid-types */ 5424 /* eslint-disable jsdoc/no-undefined-types */ 5425 /** @type {import('react').MutableRefObject<T>} */ 5426 /* eslint-enable jsdoc/no-undefined-types */ 5427 // Disable reason: We're doing something pretty JavaScript-y here where the 5428 // ref will always have a current value that is not null or undefined but it 5429 // needs to start as undefined. We don't want to change the return type so 5430 // it's easier to just ts-ignore this specific line that's complaining about 5431 // undefined not being part of T. 5432 // @ts-ignore 5433 const ref = (0,external_wp_element_namespaceObject.useRef)(); 5434 ref.current = value; 5435 return ref; 5436 } 5437 5438 /** 5439 * A hook to facilitate drag and drop handling. 5440 * 5441 * @param {Object} props Named parameters. 5442 * @param {?HTMLElement} [props.dropZoneElement] Optional element to be used as the drop zone. 5443 * @param {boolean} [props.isDisabled] Whether or not to disable the drop zone. 5444 * @param {(e: DragEvent) => void} [props.onDragStart] Called when dragging has started. 5445 * @param {(e: DragEvent) => void} [props.onDragEnter] Called when the zone is entered. 5446 * @param {(e: DragEvent) => void} [props.onDragOver] Called when the zone is moved within. 5447 * @param {(e: DragEvent) => void} [props.onDragLeave] Called when the zone is left. 5448 * @param {(e: MouseEvent) => void} [props.onDragEnd] Called when dragging has ended. 5449 * @param {(e: DragEvent) => void} [props.onDrop] Called when dropping in the zone. 5450 * 5451 * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element. 5452 */ 5453 function useDropZone({ 5454 dropZoneElement, 5455 isDisabled, 5456 onDrop: _onDrop, 5457 onDragStart: _onDragStart, 5458 onDragEnter: _onDragEnter, 5459 onDragLeave: _onDragLeave, 5460 onDragEnd: _onDragEnd, 5461 onDragOver: _onDragOver 5462 }) { 5463 const onDropRef = useFreshRef(_onDrop); 5464 const onDragStartRef = useFreshRef(_onDragStart); 5465 const onDragEnterRef = useFreshRef(_onDragEnter); 5466 const onDragLeaveRef = useFreshRef(_onDragLeave); 5467 const onDragEndRef = useFreshRef(_onDragEnd); 5468 const onDragOverRef = useFreshRef(_onDragOver); 5469 return useRefEffect(elem => { 5470 if (isDisabled) { 5471 return; 5472 } 5473 5474 // If a custom dropZoneRef is passed, use that instead of the element. 5475 // This allows the dropzone to cover an expanded area, rather than 5476 // be restricted to the area of the ref returned by this hook. 5477 const element = dropZoneElement !== null && dropZoneElement !== void 0 ? dropZoneElement : elem; 5478 let isDragging = false; 5479 const { 5480 ownerDocument 5481 } = element; 5482 5483 /** 5484 * Checks if an element is in the drop zone. 5485 * 5486 * @param {EventTarget|null} targetToCheck 5487 * 5488 * @return {boolean} True if in drop zone, false if not. 5489 */ 5490 function isElementInZone(targetToCheck) { 5491 const { 5492 defaultView 5493 } = ownerDocument; 5494 if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) { 5495 return false; 5496 } 5497 5498 /** @type {HTMLElement|null} */ 5499 let elementToCheck = targetToCheck; 5500 do { 5501 if (elementToCheck.dataset.isDropZone) { 5502 return elementToCheck === element; 5503 } 5504 } while (elementToCheck = elementToCheck.parentElement); 5505 return false; 5506 } 5507 function maybeDragStart( /** @type {DragEvent} */event) { 5508 if (isDragging) { 5509 return; 5510 } 5511 isDragging = true; 5512 5513 // Note that `dragend` doesn't fire consistently for file and 5514 // HTML drag events where the drag origin is outside the browser 5515 // window. In Firefox it may also not fire if the originating 5516 // node is removed. 5517 ownerDocument.addEventListener('dragend', maybeDragEnd); 5518 ownerDocument.addEventListener('mousemove', maybeDragEnd); 5519 if (onDragStartRef.current) { 5520 onDragStartRef.current(event); 5521 } 5522 } 5523 function onDragEnter( /** @type {DragEvent} */event) { 5524 event.preventDefault(); 5525 5526 // The `dragenter` event will also fire when entering child 5527 // elements, but we only want to call `onDragEnter` when 5528 // entering the drop zone, which means the `relatedTarget` 5529 // (element that has been left) should be outside the drop zone. 5530 if (element.contains( /** @type {Node} */event.relatedTarget)) { 5531 return; 5532 } 5533 if (onDragEnterRef.current) { 5534 onDragEnterRef.current(event); 5535 } 5536 } 5537 function onDragOver( /** @type {DragEvent} */event) { 5538 // Only call onDragOver for the innermost hovered drop zones. 5539 if (!event.defaultPrevented && onDragOverRef.current) { 5540 onDragOverRef.current(event); 5541 } 5542 5543 // Prevent the browser default while also signalling to parent 5544 // drop zones that `onDragOver` is already handled. 5545 event.preventDefault(); 5546 } 5547 function onDragLeave( /** @type {DragEvent} */event) { 5548 // The `dragleave` event will also fire when leaving child 5549 // elements, but we only want to call `onDragLeave` when 5550 // leaving the drop zone, which means the `relatedTarget` 5551 // (element that has been entered) should be outside the drop 5552 // zone. 5553 // Note: This is not entirely reliable in Safari due to this bug 5554 // https://bugs.webkit.org/show_bug.cgi?id=66547 5555 if (isElementInZone(event.relatedTarget)) { 5556 return; 5557 } 5558 if (onDragLeaveRef.current) { 5559 onDragLeaveRef.current(event); 5560 } 5561 } 5562 function onDrop( /** @type {DragEvent} */event) { 5563 // Don't handle drop if an inner drop zone already handled it. 5564 if (event.defaultPrevented) { 5565 return; 5566 } 5567 5568 // Prevent the browser default while also signalling to parent 5569 // drop zones that `onDrop` is already handled. 5570 event.preventDefault(); 5571 5572 // This seemingly useless line has been shown to resolve a 5573 // Safari issue where files dragged directly from the dock are 5574 // not recognized. 5575 // eslint-disable-next-line no-unused-expressions 5576 event.dataTransfer && event.dataTransfer.files.length; 5577 if (onDropRef.current) { 5578 onDropRef.current(event); 5579 } 5580 maybeDragEnd(event); 5581 } 5582 function maybeDragEnd( /** @type {MouseEvent} */event) { 5583 if (!isDragging) { 5584 return; 5585 } 5586 isDragging = false; 5587 ownerDocument.removeEventListener('dragend', maybeDragEnd); 5588 ownerDocument.removeEventListener('mousemove', maybeDragEnd); 5589 if (onDragEndRef.current) { 5590 onDragEndRef.current(event); 5591 } 5592 } 5593 element.dataset.isDropZone = 'true'; 5594 element.addEventListener('drop', onDrop); 5595 element.addEventListener('dragenter', onDragEnter); 5596 element.addEventListener('dragover', onDragOver); 5597 element.addEventListener('dragleave', onDragLeave); 5598 // The `dragstart` event doesn't fire if the drag started outside 5599 // the document. 5600 ownerDocument.addEventListener('dragenter', maybeDragStart); 5601 return () => { 5602 delete element.dataset.isDropZone; 5603 element.removeEventListener('drop', onDrop); 5604 element.removeEventListener('dragenter', onDragEnter); 5605 element.removeEventListener('dragover', onDragOver); 5606 element.removeEventListener('dragleave', onDragLeave); 5607 ownerDocument.removeEventListener('dragend', maybeDragEnd); 5608 ownerDocument.removeEventListener('mousemove', maybeDragEnd); 5609 ownerDocument.removeEventListener('dragenter', maybeDragStart); 5610 }; 5611 }, [isDisabled, dropZoneElement] // Refresh when the passed in dropZoneElement changes. 5612 ); 5613 } 5614 5615 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js 5616 /** 5617 * External dependencies 5618 */ 5619 5620 /** 5621 * Internal dependencies 5622 */ 5623 5624 5625 /** 5626 * Dispatches a bubbling focus event when the iframe receives focus. Use 5627 * `onFocus` as usual on the iframe or a parent element. 5628 * 5629 * @return Ref to pass to the iframe. 5630 */ 5631 function useFocusableIframe() { 5632 return useRefEffect(element => { 5633 const { 5634 ownerDocument 5635 } = element; 5636 if (!ownerDocument) return; 5637 const { 5638 defaultView 5639 } = ownerDocument; 5640 if (!defaultView) return; 5641 5642 /** 5643 * Checks whether the iframe is the activeElement, inferring that it has 5644 * then received focus, and dispatches a focus event. 5645 */ 5646 function checkFocus() { 5647 if (ownerDocument && ownerDocument.activeElement === element) { 5648 element.focus(); 5649 } 5650 } 5651 defaultView.addEventListener('blur', checkFocus); 5652 return () => { 5653 defaultView.removeEventListener('blur', checkFocus); 5654 }; 5655 }, []); 5656 } 5657 5658 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js 5659 /** 5660 * WordPress dependencies 5661 */ 5662 5663 5664 5665 5666 /** 5667 * Internal dependencies 5668 */ 5669 5670 const DEFAULT_INIT_WINDOW_SIZE = 30; 5671 5672 /** 5673 * @typedef {Object} WPFixedWindowList 5674 * 5675 * @property {number} visibleItems Items visible in the current viewport 5676 * @property {number} start Start index of the window 5677 * @property {number} end End index of the window 5678 * @property {(index:number)=>boolean} itemInView Returns true if item is in the window 5679 */ 5680 5681 /** 5682 * @typedef {Object} WPFixedWindowListOptions 5683 * 5684 * @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window. 5685 * @property {boolean} [useWindowing] When false avoids calculating the window size 5686 * @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size. 5687 * @property {any} [expandedState] Used to recalculate the window size when the expanded state of a list changes. 5688 */ 5689 5690 /** 5691 * 5692 * @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element. 5693 * @param { number } itemHeight Fixed item height in pixels 5694 * @param { number } totalItems Total items in list 5695 * @param { WPFixedWindowListOptions } [options] Options object 5696 * @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter 5697 */ 5698 function useFixedWindowList(elementRef, itemHeight, totalItems, options) { 5699 var _options$initWindowSi, _options$useWindowing; 5700 const initWindowSize = (_options$initWindowSi = options?.initWindowSize) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT_INIT_WINDOW_SIZE; 5701 const useWindowing = (_options$useWindowing = options?.useWindowing) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true; 5702 const [fixedListWindow, setFixedListWindow] = (0,external_wp_element_namespaceObject.useState)({ 5703 visibleItems: initWindowSize, 5704 start: 0, 5705 end: initWindowSize, 5706 itemInView: ( /** @type {number} */index) => { 5707 return index >= 0 && index <= initWindowSize; 5708 } 5709 }); 5710 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 5711 if (!useWindowing) { 5712 return; 5713 } 5714 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); 5715 const measureWindow = ( /** @type {boolean | undefined} */initRender) => { 5716 var _options$windowOversc; 5717 if (!scrollContainer) { 5718 return; 5719 } 5720 const visibleItems = Math.ceil(scrollContainer.clientHeight / itemHeight); 5721 // Aim to keep opening list view fast, afterward we can optimize for scrolling. 5722 const windowOverscan = initRender ? visibleItems : (_options$windowOversc = options?.windowOverscan) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems; 5723 const firstViewableIndex = Math.floor(scrollContainer.scrollTop / itemHeight); 5724 const start = Math.max(0, firstViewableIndex - windowOverscan); 5725 const end = Math.min(totalItems - 1, firstViewableIndex + visibleItems + windowOverscan); 5726 setFixedListWindow(lastWindow => { 5727 const nextWindow = { 5728 visibleItems, 5729 start, 5730 end, 5731 itemInView: ( /** @type {number} */index) => { 5732 return start <= index && index <= end; 5733 } 5734 }; 5735 if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) { 5736 return nextWindow; 5737 } 5738 return lastWindow; 5739 }); 5740 }; 5741 measureWindow(true); 5742 const debounceMeasureList = debounce(() => { 5743 measureWindow(); 5744 }, 16); 5745 scrollContainer?.addEventListener('scroll', debounceMeasureList); 5746 scrollContainer?.ownerDocument?.defaultView?.addEventListener('resize', debounceMeasureList); 5747 scrollContainer?.ownerDocument?.defaultView?.addEventListener('resize', debounceMeasureList); 5748 return () => { 5749 scrollContainer?.removeEventListener('scroll', debounceMeasureList); 5750 scrollContainer?.ownerDocument?.defaultView?.removeEventListener('resize', debounceMeasureList); 5751 }; 5752 }, [itemHeight, elementRef, totalItems, options?.expandedState, options?.windowOverscan, useWindowing]); 5753 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 5754 if (!useWindowing) { 5755 return; 5756 } 5757 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); 5758 const handleKeyDown = ( /** @type {KeyboardEvent} */event) => { 5759 switch (event.keyCode) { 5760 case external_wp_keycodes_namespaceObject.HOME: 5761 { 5762 return scrollContainer?.scrollTo({ 5763 top: 0 5764 }); 5765 } 5766 case external_wp_keycodes_namespaceObject.END: 5767 { 5768 return scrollContainer?.scrollTo({ 5769 top: totalItems * itemHeight 5770 }); 5771 } 5772 case external_wp_keycodes_namespaceObject.PAGEUP: 5773 { 5774 return scrollContainer?.scrollTo({ 5775 top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight 5776 }); 5777 } 5778 case external_wp_keycodes_namespaceObject.PAGEDOWN: 5779 { 5780 return scrollContainer?.scrollTo({ 5781 top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight 5782 }); 5783 } 5784 } 5785 }; 5786 scrollContainer?.ownerDocument?.defaultView?.addEventListener('keydown', handleKeyDown); 5787 return () => { 5788 scrollContainer?.ownerDocument?.defaultView?.removeEventListener('keydown', handleKeyDown); 5789 }; 5790 }, [totalItems, itemHeight, elementRef, fixedListWindow.visibleItems, useWindowing, options?.expandedState]); 5791 return [fixedListWindow, setFixedListWindow]; 5792 } 5793 5794 ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js 5795 // The `createHigherOrderComponent` helper and helper types. 5796 5797 // The `debounce` helper and its types. 5798 5799 // The `throttle` helper and its types. 5800 5801 5802 // The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash). 5803 5804 5805 5806 // Higher-order components. 5807 5808 5809 5810 5811 5812 5813 5814 // Hooks. 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 })(); 5845 5846 (window.wp = window.wp || {}).compose = __webpack_exports__; 5847 /******/ })() 5848 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu May 9 08:20:02 2024 | Cross-referenced by PHPXref |