| @@ -31,15 +31,8 @@ | ||
| 31 | 31 | mod |
| 32 | 32 | )); |
| 33 | 33 | var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
| 34 | 34 | |
| 35 | - // package-external:@wordpress/private-apis | |
| 36 | - var require_private_apis = __commonJS({ | |
| 37 | - "package-external:@wordpress/private-apis"(exports, module) { | |
| 38 | - module.exports = window.wp.privateApis; | |
| 39 | - } | |
| 40 | - }); | |
| 41 | - | |
| 42 | 35 | // vendor-external:react/jsx-runtime |
| 43 | 36 | var require_jsx_runtime = __commonJS({ |
| 44 | 37 | "vendor-external:react/jsx-runtime"(exports, module) { |
| 45 | 38 | module.exports = window.ReactJSXRuntime; |
| @@ -73,8 +66,668 @@ | ||
| 73 | 66 | module.exports = window.wp.dom; |
| 74 | 67 | } |
| 75 | 68 | }); |
| 76 | 69 | |
| 70 | + // packages/compose/node_modules/clipboard/dist/clipboard.js | |
| 71 | + var require_clipboard = __commonJS({ | |
| 72 | + "packages/compose/node_modules/clipboard/dist/clipboard.js"(exports, module) { | |
| 73 | + (function webpackUniversalModuleDefinition(root, factory) { | |
| 74 | + if (typeof exports === "object" && typeof module === "object") | |
| 75 | + module.exports = factory(); | |
| 76 | + else if (typeof define === "function" && define.amd) | |
| 77 | + define([], factory); | |
| 78 | + else if (typeof exports === "object") | |
| 79 | + exports["ClipboardJS"] = factory(); | |
| 80 | + else | |
| 81 | + root["ClipboardJS"] = factory(); | |
| 82 | + })(exports, function() { | |
| 83 | + return ( | |
| 84 | + /******/ | |
| 85 | + (function() { | |
| 86 | + var __webpack_modules__ = { | |
| 87 | + /***/ | |
| 88 | + 686: ( | |
| 89 | + /***/ | |
| 90 | + (function(__unused_webpack_module, __webpack_exports__, __webpack_require__2) { | |
| 91 | + "use strict"; | |
| 92 | + __webpack_require__2.d(__webpack_exports__, { | |
| 93 | + "default": function() { | |
| 94 | + return ( | |
| 95 | + /* binding */ | |
| 96 | + clipboard | |
| 97 | + ); | |
| 98 | + } | |
| 99 | + }); | |
| 100 | + var tiny_emitter = __webpack_require__2(279); | |
| 101 | + var tiny_emitter_default = /* @__PURE__ */ __webpack_require__2.n(tiny_emitter); | |
| 102 | + var listen = __webpack_require__2(370); | |
| 103 | + var listen_default = /* @__PURE__ */ __webpack_require__2.n(listen); | |
| 104 | + var src_select = __webpack_require__2(817); | |
| 105 | + var select_default = /* @__PURE__ */ __webpack_require__2.n(src_select); | |
| 106 | + ; | |
| 107 | + function command(type) { | |
| 108 | + try { | |
| 109 | + return document.execCommand(type); | |
| 110 | + } catch (err) { | |
| 111 | + return false; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + ; | |
| 115 | + var ClipboardActionCut = function ClipboardActionCut2(target) { | |
| 116 | + var selectedText = select_default()(target); | |
| 117 | + command("cut"); | |
| 118 | + return selectedText; | |
| 119 | + }; | |
| 120 | + var actions_cut = ClipboardActionCut; | |
| 121 | + ; | |
| 122 | + function createFakeElement(value) { | |
| 123 | + var isRTL = document.documentElement.getAttribute("dir") === "rtl"; | |
| 124 | + var fakeElement = document.createElement("textarea"); | |
| 125 | + fakeElement.style.fontSize = "12pt"; | |
| 126 | + fakeElement.style.border = "0"; | |
| 127 | + fakeElement.style.padding = "0"; | |
| 128 | + fakeElement.style.margin = "0"; | |
| 129 | + fakeElement.style.position = "absolute"; | |
| 130 | + fakeElement.style[isRTL ? "right" : "left"] = "-9999px"; | |
| 131 | + var yPosition = window.pageYOffset || document.documentElement.scrollTop; | |
| 132 | + fakeElement.style.top = "".concat(yPosition, "px"); | |
| 133 | + fakeElement.setAttribute("readonly", ""); | |
| 134 | + fakeElement.value = value; | |
| 135 | + return fakeElement; | |
| 136 | + } | |
| 137 | + ; | |
| 138 | + var fakeCopyAction = function fakeCopyAction2(value, options) { | |
| 139 | + var fakeElement = createFakeElement(value); | |
| 140 | + options.container.appendChild(fakeElement); | |
| 141 | + var selectedText = select_default()(fakeElement); | |
| 142 | + command("copy"); | |
| 143 | + fakeElement.remove(); | |
| 144 | + return selectedText; | |
| 145 | + }; | |
| 146 | + var ClipboardActionCopy = function ClipboardActionCopy2(target) { | |
| 147 | + var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { | |
| 148 | + container: document.body | |
| 149 | + }; | |
| 150 | + var selectedText = ""; | |
| 151 | + if (typeof target === "string") { | |
| 152 | + selectedText = fakeCopyAction(target, options); | |
| 153 | + } else if (target instanceof HTMLInputElement && !["text", "search", "url", "tel", "password"].includes(target === null || target === void 0 ? void 0 : target.type)) { | |
| 154 | + selectedText = fakeCopyAction(target.value, options); | |
| 155 | + } else { | |
| 156 | + selectedText = select_default()(target); | |
| 157 | + command("copy"); | |
| 158 | + } | |
| 159 | + return selectedText; | |
| 160 | + }; | |
| 161 | + var actions_copy = ClipboardActionCopy; | |
| 162 | + ; | |
| 163 | + function _typeof(obj) { | |
| 164 | + "@babel/helpers - typeof"; | |
| 165 | + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | |
| 166 | + _typeof = function _typeof2(obj2) { | |
| 167 | + return typeof obj2; | |
| 168 | + }; | |
| 169 | + } else { | |
| 170 | + _typeof = function _typeof2(obj2) { | |
| 171 | + return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; | |
| 172 | + }; | |
| 173 | + } | |
| 174 | + return _typeof(obj); | |
| 175 | + } | |
| 176 | + var ClipboardActionDefault = function ClipboardActionDefault2() { | |
| 177 | + var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; | |
| 178 | + var _options$action = options.action, action = _options$action === void 0 ? "copy" : _options$action, container = options.container, target = options.target, text = options.text; | |
| 179 | + if (action !== "copy" && action !== "cut") { | |
| 180 | + throw new Error('Invalid "action" value, use either "copy" or "cut"'); | |
| 181 | + } | |
| 182 | + if (target !== void 0) { | |
| 183 | + if (target && _typeof(target) === "object" && target.nodeType === 1) { | |
| 184 | + if (action === "copy" && target.hasAttribute("disabled")) { | |
| 185 | + throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); | |
| 186 | + } | |
| 187 | + if (action === "cut" && (target.hasAttribute("readonly") || target.hasAttribute("disabled"))) { | |
| 188 | + throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`); | |
| 189 | + } | |
| 190 | + } else { | |
| 191 | + throw new Error('Invalid "target" value, use a valid Element'); | |
| 192 | + } | |
| 193 | + } | |
| 194 | + if (text) { | |
| 195 | + return actions_copy(text, { | |
| 196 | + container | |
| 197 | + }); | |
| 198 | + } | |
| 199 | + if (target) { | |
| 200 | + return action === "cut" ? actions_cut(target) : actions_copy(target, { | |
| 201 | + container | |
| 202 | + }); | |
| 203 | + } | |
| 204 | + }; | |
| 205 | + var actions_default = ClipboardActionDefault; | |
| 206 | + ; | |
| 207 | + function clipboard_typeof(obj) { | |
| 208 | + "@babel/helpers - typeof"; | |
| 209 | + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | |
| 210 | + clipboard_typeof = function _typeof2(obj2) { | |
| 211 | + return typeof obj2; | |
| 212 | + }; | |
| 213 | + } else { | |
| 214 | + clipboard_typeof = function _typeof2(obj2) { | |
| 215 | + return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; | |
| 216 | + }; | |
| 217 | + } | |
| 218 | + return clipboard_typeof(obj); | |
| 219 | + } | |
| 220 | + function _classCallCheck(instance, Constructor) { | |
| 221 | + if (!(instance instanceof Constructor)) { | |
| 222 | + throw new TypeError("Cannot call a class as a function"); | |
| 223 | + } | |
| 224 | + } | |
| 225 | + function _defineProperties(target, props) { | |
| 226 | + for (var i = 0; i < props.length; i++) { | |
| 227 | + var descriptor = props[i]; | |
| 228 | + descriptor.enumerable = descriptor.enumerable || false; | |
| 229 | + descriptor.configurable = true; | |
| 230 | + if ("value" in descriptor) descriptor.writable = true; | |
| 231 | + Object.defineProperty(target, descriptor.key, descriptor); | |
| 232 | + } | |
| 233 | + } | |
| 234 | + function _createClass(Constructor, protoProps, staticProps) { | |
| 235 | + if (protoProps) _defineProperties(Constructor.prototype, protoProps); | |
| 236 | + if (staticProps) _defineProperties(Constructor, staticProps); | |
| 237 | + return Constructor; | |
| 238 | + } | |
| 239 | + function _inherits(subClass, superClass) { | |
| 240 | + if (typeof superClass !== "function" && superClass !== null) { | |
| 241 | + throw new TypeError("Super expression must either be null or a function"); | |
| 242 | + } | |
| 243 | + subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); | |
| 244 | + if (superClass) _setPrototypeOf(subClass, superClass); | |
| 245 | + } | |
| 246 | + function _setPrototypeOf(o, p) { | |
| 247 | + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) { | |
| 248 | + o2.__proto__ = p2; | |
| 249 | + return o2; | |
| 250 | + }; | |
| 251 | + return _setPrototypeOf(o, p); | |
| 252 | + } | |
| 253 | + function _createSuper(Derived) { | |
| 254 | + var hasNativeReflectConstruct = _isNativeReflectConstruct(); | |
| 255 | + return function _createSuperInternal() { | |
| 256 | + var Super = _getPrototypeOf(Derived), result; | |
| 257 | + if (hasNativeReflectConstruct) { | |
| 258 | + var NewTarget = _getPrototypeOf(this).constructor; | |
| 259 | + result = Reflect.construct(Super, arguments, NewTarget); | |
| 260 | + } else { | |
| 261 | + result = Super.apply(this, arguments); | |
| 262 | + } | |
| 263 | + return _possibleConstructorReturn(this, result); | |
| 264 | + }; | |
| 265 | + } | |
| 266 | + function _possibleConstructorReturn(self, call) { | |
| 267 | + if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { | |
| 268 | + return call; | |
| 269 | + } | |
| 270 | + return _assertThisInitialized(self); | |
| 271 | + } | |
| 272 | + function _assertThisInitialized(self) { | |
| 273 | + if (self === void 0) { | |
| 274 | + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | |
| 275 | + } | |
| 276 | + return self; | |
| 277 | + } | |
| 278 | + function _isNativeReflectConstruct() { | |
| 279 | + if (typeof Reflect === "undefined" || !Reflect.construct) return false; | |
| 280 | + if (Reflect.construct.sham) return false; | |
| 281 | + if (typeof Proxy === "function") return true; | |
| 282 | + try { | |
| 283 | + Date.prototype.toString.call(Reflect.construct(Date, [], function() { | |
| 284 | + })); | |
| 285 | + return true; | |
| 286 | + } catch (e) { | |
| 287 | + return false; | |
| 288 | + } | |
| 289 | + } | |
| 290 | + function _getPrototypeOf(o) { | |
| 291 | + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) { | |
| 292 | + return o2.__proto__ || Object.getPrototypeOf(o2); | |
| 293 | + }; | |
| 294 | + return _getPrototypeOf(o); | |
| 295 | + } | |
| 296 | + function getAttributeValue(suffix, element) { | |
| 297 | + var attribute = "data-clipboard-".concat(suffix); | |
| 298 | + if (!element.hasAttribute(attribute)) { | |
| 299 | + return; | |
| 300 | + } | |
| 301 | + return element.getAttribute(attribute); | |
| 302 | + } | |
| 303 | + var Clipboard3 = /* @__PURE__ */ (function(_Emitter) { | |
| 304 | + _inherits(Clipboard4, _Emitter); | |
| 305 | + var _super = _createSuper(Clipboard4); | |
| 306 | + function Clipboard4(trigger, options) { | |
| 307 | + var _this; | |
| 308 | + _classCallCheck(this, Clipboard4); | |
| 309 | + _this = _super.call(this); | |
| 310 | + _this.resolveOptions(options); | |
| 311 | + _this.listenClick(trigger); | |
| 312 | + return _this; | |
| 313 | + } | |
| 314 | + _createClass(Clipboard4, [{ | |
| 315 | + key: "resolveOptions", | |
| 316 | + value: function resolveOptions() { | |
| 317 | + var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; | |
| 318 | + this.action = typeof options.action === "function" ? options.action : this.defaultAction; | |
| 319 | + this.target = typeof options.target === "function" ? options.target : this.defaultTarget; | |
| 320 | + this.text = typeof options.text === "function" ? options.text : this.defaultText; | |
| 321 | + this.container = clipboard_typeof(options.container) === "object" ? options.container : document.body; | |
| 322 | + } | |
| 323 | + /** | |
| 324 | + * Adds a click event listener to the passed trigger. | |
| 325 | + * @param {String|HTMLElement|HTMLCollection|NodeList} trigger | |
| 326 | + */ | |
| 327 | + }, { | |
| 328 | + key: "listenClick", | |
| 329 | + value: function listenClick(trigger) { | |
| 330 | + var _this2 = this; | |
| 331 | + this.listener = listen_default()(trigger, "click", function(e) { | |
| 332 | + return _this2.onClick(e); | |
| 333 | + }); | |
| 334 | + } | |
| 335 | + /** | |
| 336 | + * Defines a new `ClipboardAction` on each click event. | |
| 337 | + * @param {Event} e | |
| 338 | + */ | |
| 339 | + }, { | |
| 340 | + key: "onClick", | |
| 341 | + value: function onClick(e) { | |
| 342 | + var trigger = e.delegateTarget || e.currentTarget; | |
| 343 | + var action = this.action(trigger) || "copy"; | |
| 344 | + var text = actions_default({ | |
| 345 | + action, | |
| 346 | + container: this.container, | |
| 347 | + target: this.target(trigger), | |
| 348 | + text: this.text(trigger) | |
| 349 | + }); | |
| 350 | + this.emit(text ? "success" : "error", { | |
| 351 | + action, | |
| 352 | + text, | |
| 353 | + trigger, | |
| 354 | + clearSelection: function clearSelection() { | |
| 355 | + if (trigger) { | |
| 356 | + trigger.focus(); | |
| 357 | + } | |
| 358 | + window.getSelection().removeAllRanges(); | |
| 359 | + } | |
| 360 | + }); | |
| 361 | + } | |
| 362 | + /** | |
| 363 | + * Default `action` lookup function. | |
| 364 | + * @param {Element} trigger | |
| 365 | + */ | |
| 366 | + }, { | |
| 367 | + key: "defaultAction", | |
| 368 | + value: function defaultAction(trigger) { | |
| 369 | + return getAttributeValue("action", trigger); | |
| 370 | + } | |
| 371 | + /** | |
| 372 | + * Default `target` lookup function. | |
| 373 | + * @param {Element} trigger | |
| 374 | + */ | |
| 375 | + }, { | |
| 376 | + key: "defaultTarget", | |
| 377 | + value: function defaultTarget(trigger) { | |
| 378 | + var selector = getAttributeValue("target", trigger); | |
| 379 | + if (selector) { | |
| 380 | + return document.querySelector(selector); | |
| 381 | + } | |
| 382 | + } | |
| 383 | + /** | |
| 384 | + * Allow fire programmatically a copy action | |
| 385 | + * @param {String|HTMLElement} target | |
| 386 | + * @param {Object} options | |
| 387 | + * @returns Text copied. | |
| 388 | + */ | |
| 389 | + }, { | |
| 390 | + key: "defaultText", | |
| 391 | + /** | |
| 392 | + * Default `text` lookup function. | |
| 393 | + * @param {Element} trigger | |
| 394 | + */ | |
| 395 | + value: function defaultText(trigger) { | |
| 396 | + return getAttributeValue("text", trigger); | |
| 397 | + } | |
| 398 | + /** | |
| 399 | + * Destroy lifecycle. | |
| 400 | + */ | |
| 401 | + }, { | |
| 402 | + key: "destroy", | |
| 403 | + value: function destroy() { | |
| 404 | + this.listener.destroy(); | |
| 405 | + } | |
| 406 | + }], [{ | |
| 407 | + key: "copy", | |
| 408 | + value: function copy(target) { | |
| 409 | + var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { | |
| 410 | + container: document.body | |
| 411 | + }; | |
| 412 | + return actions_copy(target, options); | |
| 413 | + } | |
| 414 | + /** | |
| 415 | + * Allow fire programmatically a cut action | |
| 416 | + * @param {String|HTMLElement} target | |
| 417 | + * @returns Text cutted. | |
| 418 | + */ | |
| 419 | + }, { | |
| 420 | + key: "cut", | |
| 421 | + value: function cut(target) { | |
| 422 | + return actions_cut(target); | |
| 423 | + } | |
| 424 | + /** | |
| 425 | + * Returns the support of the given action, or all actions if no action is | |
| 426 | + * given. | |
| 427 | + * @param {String} [action] | |
| 428 | + */ | |
| 429 | + }, { | |
| 430 | + key: "isSupported", | |
| 431 | + value: function isSupported() { | |
| 432 | + var action = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ["copy", "cut"]; | |
| 433 | + var actions = typeof action === "string" ? [action] : action; | |
| 434 | + var support = !!document.queryCommandSupported; | |
| 435 | + actions.forEach(function(action2) { | |
| 436 | + support = support && !!document.queryCommandSupported(action2); | |
| 437 | + }); | |
| 438 | + return support; | |
| 439 | + } | |
| 440 | + }]); | |
| 441 | + return Clipboard4; | |
| 442 | + })(tiny_emitter_default()); | |
| 443 | + var clipboard = Clipboard3; | |
| 444 | + }) | |
| 445 | + ), | |
| 446 | + /***/ | |
| 447 | + 828: ( | |
| 448 | + /***/ | |
| 449 | + (function(module2) { | |
| 450 | + var DOCUMENT_NODE_TYPE = 9; | |
| 451 | + if (typeof Element !== "undefined" && !Element.prototype.matches) { | |
| 452 | + var proto = Element.prototype; | |
| 453 | + proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; | |
| 454 | + } | |
| 455 | + function closest(element, selector) { | |
| 456 | + while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { | |
| 457 | + if (typeof element.matches === "function" && element.matches(selector)) { | |
| 458 | + return element; | |
| 459 | + } | |
| 460 | + element = element.parentNode; | |
| 461 | + } | |
| 462 | + } | |
| 463 | + module2.exports = closest; | |
| 464 | + }) | |
| 465 | + ), | |
| 466 | + /***/ | |
| 467 | + 438: ( | |
| 468 | + /***/ | |
| 469 | + (function(module2, __unused_webpack_exports, __webpack_require__2) { | |
| 470 | + var closest = __webpack_require__2(828); | |
| 471 | + function _delegate(element, selector, type, callback, useCapture) { | |
| 472 | + var listenerFn = listener2.apply(this, arguments); | |
| 473 | + element.addEventListener(type, listenerFn, useCapture); | |
| 474 | + return { | |
| 475 | + destroy: function() { | |
| 476 | + element.removeEventListener(type, listenerFn, useCapture); | |
| 477 | + } | |
| 478 | + }; | |
| 479 | + } | |
| 480 | + function delegate(elements, selector, type, callback, useCapture) { | |
| 481 | + if (typeof elements.addEventListener === "function") { | |
| 482 | + return _delegate.apply(null, arguments); | |
| 483 | + } | |
| 484 | + if (typeof type === "function") { | |
| 485 | + return _delegate.bind(null, document).apply(null, arguments); | |
| 486 | + } | |
| 487 | + if (typeof elements === "string") { | |
| 488 | + elements = document.querySelectorAll(elements); | |
| 489 | + } | |
| 490 | + return Array.prototype.map.call(elements, function(element) { | |
| 491 | + return _delegate(element, selector, type, callback, useCapture); | |
| 492 | + }); | |
| 493 | + } | |
| 494 | + function listener2(element, selector, type, callback) { | |
| 495 | + return function(e) { | |
| 496 | + e.delegateTarget = closest(e.target, selector); | |
| 497 | + if (e.delegateTarget) { | |
| 498 | + callback.call(element, e); | |
| 499 | + } | |
| 500 | + }; | |
| 501 | + } | |
| 502 | + module2.exports = delegate; | |
| 503 | + }) | |
| 504 | + ), | |
| 505 | + /***/ | |
| 506 | + 879: ( | |
| 507 | + /***/ | |
| 508 | + (function(__unused_webpack_module, exports2) { | |
| 509 | + exports2.node = function(value) { | |
| 510 | + return value !== void 0 && value instanceof HTMLElement && value.nodeType === 1; | |
| 511 | + }; | |
| 512 | + exports2.nodeList = function(value) { | |
| 513 | + var type = Object.prototype.toString.call(value); | |
| 514 | + return value !== void 0 && (type === "[object NodeList]" || type === "[object HTMLCollection]") && "length" in value && (value.length === 0 || exports2.node(value[0])); | |
| 515 | + }; | |
| 516 | + exports2.string = function(value) { | |
| 517 | + return typeof value === "string" || value instanceof String; | |
| 518 | + }; | |
| 519 | + exports2.fn = function(value) { | |
| 520 | + var type = Object.prototype.toString.call(value); | |
| 521 | + return type === "[object Function]"; | |
| 522 | + }; | |
| 523 | + }) | |
| 524 | + ), | |
| 525 | + /***/ | |
| 526 | + 370: ( | |
| 527 | + /***/ | |
| 528 | + (function(module2, __unused_webpack_exports, __webpack_require__2) { | |
| 529 | + var is = __webpack_require__2(879); | |
| 530 | + var delegate = __webpack_require__2(438); | |
| 531 | + function listen(target, type, callback) { | |
| 532 | + if (!target && !type && !callback) { | |
| 533 | + throw new Error("Missing required arguments"); | |
| 534 | + } | |
| 535 | + if (!is.string(type)) { | |
| 536 | + throw new TypeError("Second argument must be a String"); | |
| 537 | + } | |
| 538 | + if (!is.fn(callback)) { | |
| 539 | + throw new TypeError("Third argument must be a Function"); | |
| 540 | + } | |
| 541 | + if (is.node(target)) { | |
| 542 | + return listenNode(target, type, callback); | |
| 543 | + } else if (is.nodeList(target)) { | |
| 544 | + return listenNodeList(target, type, callback); | |
| 545 | + } else if (is.string(target)) { | |
| 546 | + return listenSelector(target, type, callback); | |
| 547 | + } else { | |
| 548 | + throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList"); | |
| 549 | + } | |
| 550 | + } | |
| 551 | + function listenNode(node, type, callback) { | |
| 552 | + node.addEventListener(type, callback); | |
| 553 | + return { | |
| 554 | + destroy: function() { | |
| 555 | + node.removeEventListener(type, callback); | |
| 556 | + } | |
| 557 | + }; | |
| 558 | + } | |
| 559 | + function listenNodeList(nodeList, type, callback) { | |
| 560 | + Array.prototype.forEach.call(nodeList, function(node) { | |
| 561 | + node.addEventListener(type, callback); | |
| 562 | + }); | |
| 563 | + return { | |
| 564 | + destroy: function() { | |
| 565 | + Array.prototype.forEach.call(nodeList, function(node) { | |
| 566 | + node.removeEventListener(type, callback); | |
| 567 | + }); | |
| 568 | + } | |
| 569 | + }; | |
| 570 | + } | |
| 571 | + function listenSelector(selector, type, callback) { | |
| 572 | + return delegate(document.body, selector, type, callback); | |
| 573 | + } | |
| 574 | + module2.exports = listen; | |
| 575 | + }) | |
| 576 | + ), | |
| 577 | + /***/ | |
| 578 | + 817: ( | |
| 579 | + /***/ | |
| 580 | + (function(module2) { | |
| 581 | + function select(element) { | |
| 582 | + var selectedText; | |
| 583 | + if (element.nodeName === "SELECT") { | |
| 584 | + element.focus(); | |
| 585 | + selectedText = element.value; | |
| 586 | + } else if (element.nodeName === "INPUT" || element.nodeName === "TEXTAREA") { | |
| 587 | + var isReadOnly = element.hasAttribute("readonly"); | |
| 588 | + if (!isReadOnly) { | |
| 589 | + element.setAttribute("readonly", ""); | |
| 590 | + } | |
| 591 | + element.select(); | |
| 592 | + element.setSelectionRange(0, element.value.length); | |
| 593 | + if (!isReadOnly) { | |
| 594 | + element.removeAttribute("readonly"); | |
| 595 | + } | |
| 596 | + selectedText = element.value; | |
| 597 | + } else { | |
| 598 | + if (element.hasAttribute("contenteditable")) { | |
| 599 | + element.focus(); | |
| 600 | + } | |
| 601 | + var selection = window.getSelection(); | |
| 602 | + var range = document.createRange(); | |
| 603 | + range.selectNodeContents(element); | |
| 604 | + selection.removeAllRanges(); | |
| 605 | + selection.addRange(range); | |
| 606 | + selectedText = selection.toString(); | |
| 607 | + } | |
| 608 | + return selectedText; | |
| 609 | + } | |
| 610 | + module2.exports = select; | |
| 611 | + }) | |
| 612 | + ), | |
| 613 | + /***/ | |
| 614 | + 279: ( | |
| 615 | + /***/ | |
| 616 | + (function(module2) { | |
| 617 | + function E() { | |
| 618 | + } | |
| 619 | + E.prototype = { | |
| 620 | + on: function(name, callback, ctx) { | |
| 621 | + var e = this.e || (this.e = {}); | |
| 622 | + (e[name] || (e[name] = [])).push({ | |
| 623 | + fn: callback, | |
| 624 | + ctx | |
| 625 | + }); | |
| 626 | + return this; | |
| 627 | + }, | |
| 628 | + once: function(name, callback, ctx) { | |
| 629 | + var self = this; | |
| 630 | + function listener2() { | |
| 631 | + self.off(name, listener2); | |
| 632 | + callback.apply(ctx, arguments); | |
| 633 | + } | |
| 634 | + ; | |
| 635 | + listener2._ = callback; | |
| 636 | + return this.on(name, listener2, ctx); | |
| 637 | + }, | |
| 638 | + emit: function(name) { | |
| 639 | + var data = [].slice.call(arguments, 1); | |
| 640 | + var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); | |
| 641 | + var i = 0; | |
| 642 | + var len = evtArr.length; | |
| 643 | + for (i; i < len; i++) { | |
| 644 | + evtArr[i].fn.apply(evtArr[i].ctx, data); | |
| 645 | + } | |
| 646 | + return this; | |
| 647 | + }, | |
| 648 | + off: function(name, callback) { | |
| 649 | + var e = this.e || (this.e = {}); | |
| 650 | + var evts = e[name]; | |
| 651 | + var liveEvents = []; | |
| 652 | + if (evts && callback) { | |
| 653 | + for (var i = 0, len = evts.length; i < len; i++) { | |
| 654 | + if (evts[i].fn !== callback && evts[i].fn._ !== callback) | |
| 655 | + liveEvents.push(evts[i]); | |
| 656 | + } | |
| 657 | + } | |
| 658 | + liveEvents.length ? e[name] = liveEvents : delete e[name]; | |
| 659 | + return this; | |
| 660 | + } | |
| 661 | + }; | |
| 662 | + module2.exports = E; | |
| 663 | + module2.exports.TinyEmitter = E; | |
| 664 | + }) | |
| 665 | + ) | |
| 666 | + /******/ | |
| 667 | + }; | |
| 668 | + var __webpack_module_cache__ = {}; | |
| 669 | + function __webpack_require__(moduleId) { | |
| 670 | + if (__webpack_module_cache__[moduleId]) { | |
| 671 | + return __webpack_module_cache__[moduleId].exports; | |
| 672 | + } | |
| 673 | + var module2 = __webpack_module_cache__[moduleId] = { | |
| 674 | + /******/ | |
| 675 | + // no module.id needed | |
| 676 | + /******/ | |
| 677 | + // no module.loaded needed | |
| 678 | + /******/ | |
| 679 | + exports: {} | |
| 680 | + /******/ | |
| 681 | + }; | |
| 682 | + __webpack_modules__[moduleId](module2, module2.exports, __webpack_require__); | |
| 683 | + return module2.exports; | |
| 684 | + } | |
| 685 | + !(function() { | |
| 686 | + __webpack_require__.n = function(module2) { | |
| 687 | + var getter = module2 && module2.__esModule ? ( | |
| 688 | + /******/ | |
| 689 | + function() { | |
| 690 | + return module2["default"]; | |
| 691 | + } | |
| 692 | + ) : ( | |
| 693 | + /******/ | |
| 694 | + function() { | |
| 695 | + return module2; | |
| 696 | + } | |
| 697 | + ); | |
| 698 | + __webpack_require__.d(getter, { a: getter }); | |
| 699 | + return getter; | |
| 700 | + }; | |
| 701 | + })(); | |
| 702 | + !(function() { | |
| 703 | + __webpack_require__.d = function(exports2, definition) { | |
| 704 | + for (var key in definition) { | |
| 705 | + if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports2, key)) { | |
| 706 | + Object.defineProperty(exports2, key, { enumerable: true, get: definition[key] }); | |
| 707 | + } | |
| 708 | + } | |
| 709 | + }; | |
| 710 | + })(); | |
| 711 | + !(function() { | |
| 712 | + __webpack_require__.o = function(obj, prop) { | |
| 713 | + return Object.prototype.hasOwnProperty.call(obj, prop); | |
| 714 | + }; | |
| 715 | + })(); | |
| 716 | + return __webpack_require__(686); | |
| 717 | + })().default | |
| 718 | + ); | |
| 719 | + }); | |
| 720 | + } | |
| 721 | + }); | |
| 722 | + | |
| 723 | + // package-external:@wordpress/keycodes | |
| 724 | + var require_keycodes = __commonJS({ | |
| 725 | + "package-external:@wordpress/keycodes"(exports, module) { | |
| 726 | + module.exports = window.wp.keycodes; | |
| 727 | + } | |
| 728 | + }); | |
| 729 | + | |
| 77 | 730 | // node_modules/mousetrap/mousetrap.js |
| 78 | 731 | var require_mousetrap = __commonJS({ |
| 79 | 732 | "node_modules/mousetrap/mousetrap.js"(exports, module) { |
| 80 | 733 | (function(window2, document2, undefined2) { |
| @@ -528,15 +1181,8 @@ | ||
| 528 | 1181 | })(typeof window !== "undefined" ? window : null, typeof window !== "undefined" ? document : null); |
| 529 | 1182 | } |
| 530 | 1183 | }); |
| 531 | 1184 | |
| 532 | - // package-external:@wordpress/keycodes | |
| 533 | - var require_keycodes = __commonJS({ | |
| 534 | - "package-external:@wordpress/keycodes"(exports, module) { | |
| 535 | - module.exports = window.wp.keycodes; | |
| 536 | - } | |
| 537 | - }); | |
| 538 | - | |
| 539 | 1185 | // package-external:@wordpress/undo-manager |
| 540 | 1186 | var require_undo_manager = __commonJS({ |
| 541 | 1187 | "package-external:@wordpress/undo-manager"(exports, module) { |
| 542 | 1188 | module.exports = window.wp.undoManager; |
| @@ -570,9 +1216,8 @@ | ||
| 570 | 1216 | debounce: () => debounce, |
| 571 | 1217 | ifCondition: () => if_condition_default, |
| 572 | 1218 | observableMap: () => observableMap, |
| 573 | 1219 | pipe: () => pipe_default, |
| 574 | - privateApis: () => privateApis, | |
| 575 | 1220 | pure: () => pure_default, |
| 576 | 1221 | throttle: () => throttle, |
| 577 | 1222 | useAsyncList: () => use_async_list_default, |
| 578 | 1223 | useConstrainedTabbing: () => use_constrained_tabbing_default, |
| @@ -846,98 +1491,8 @@ | ||
| 846 | 1491 | } |
| 847 | 1492 | }; |
| 848 | 1493 | } |
| 849 | 1494 | |
| 850 | - // packages/compose/build-module/lock-unlock.mjs | |
| 851 | - var import_private_apis = __toESM(require_private_apis(), 1); | |
| 852 | - var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( | |
| 853 | - "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", | |
| 854 | - "@wordpress/compose" | |
| 855 | - ); | |
| 856 | - | |
| 857 | - // packages/compose/build-module/utils/subscribe-delegated-listener/index.mjs | |
| 858 | - var registries = /* @__PURE__ */ new WeakMap(); | |
| 859 | - function subscribeDelegatedListener(target, eventType, callback, capture = false) { | |
| 860 | - const ownerDoc = target.ownerDocument; | |
| 861 | - const root = ownerDoc ?? target; | |
| 862 | - const isWindow = ownerDoc === void 0; | |
| 863 | - let perRoot = registries.get(root); | |
| 864 | - if (!perRoot) { | |
| 865 | - perRoot = /* @__PURE__ */ new Map(); | |
| 866 | - registries.set(root, perRoot); | |
| 867 | - } | |
| 868 | - const key = capture ? `${eventType}:capture` : eventType; | |
| 869 | - let perEvent = perRoot.get(key); | |
| 870 | - if (!perEvent) { | |
| 871 | - perEvent = /* @__PURE__ */ new WeakMap(); | |
| 872 | - perRoot.set(key, perEvent); | |
| 873 | - const subscribers = perEvent; | |
| 874 | - root.addEventListener( | |
| 875 | - eventType, | |
| 876 | - (event) => { | |
| 877 | - if (isWindow) { | |
| 878 | - const set2 = subscribers.get(root); | |
| 879 | - if (set2) { | |
| 880 | - for (const cb of set2) { | |
| 881 | - cb(event); | |
| 882 | - } | |
| 883 | - } | |
| 884 | - return; | |
| 885 | - } | |
| 886 | - if (capture) { | |
| 887 | - const path = []; | |
| 888 | - let current = event.target; | |
| 889 | - while (current) { | |
| 890 | - path.push(current); | |
| 891 | - if (current === root) { | |
| 892 | - break; | |
| 893 | - } | |
| 894 | - current = current.parentNode; | |
| 895 | - } | |
| 896 | - for (let i = path.length - 1; i >= 0; i--) { | |
| 897 | - const set2 = subscribers.get(path[i]); | |
| 898 | - if (set2) { | |
| 899 | - for (const cb of set2) { | |
| 900 | - cb(event); | |
| 901 | - } | |
| 902 | - } | |
| 903 | - } | |
| 904 | - } else { | |
| 905 | - let current = event.target; | |
| 906 | - while (current) { | |
| 907 | - const set2 = subscribers.get(current); | |
| 908 | - if (set2) { | |
| 909 | - for (const cb of set2) { | |
| 910 | - cb(event); | |
| 911 | - } | |
| 912 | - } | |
| 913 | - if (current === root) { | |
| 914 | - break; | |
| 915 | - } | |
| 916 | - current = current.parentNode; | |
| 917 | - } | |
| 918 | - } | |
| 919 | - }, | |
| 920 | - capture | |
| 921 | - ); | |
| 922 | - } | |
| 923 | - let set = perEvent.get(target); | |
| 924 | - if (!set) { | |
| 925 | - set = /* @__PURE__ */ new Set(); | |
| 926 | - perEvent.set(target, set); | |
| 927 | - } | |
| 928 | - set.add(callback); | |
| 929 | - return () => { | |
| 930 | - set.delete(callback); | |
| 931 | - }; | |
| 932 | - } | |
| 933 | - | |
| 934 | - // packages/compose/build-module/private-apis.mjs | |
| 935 | - var privateApis = {}; | |
| 936 | - lock(privateApis, { | |
| 937 | - subscribeDelegatedListener | |
| 938 | - }); | |
| 939 | - | |
| 940 | 1495 | // packages/compose/build-module/higher-order/pipe.mjs |
| 941 | 1496 | var basePipe = (reverse = false) => (...funcs) => (...args) => { |
| 942 | 1497 | const functions = funcs.flat(); |
| 943 | 1498 | if (reverse) { |
| @@ -972,15 +1527,10 @@ | ||
| 972 | 1527 | |
| 973 | 1528 | // packages/compose/build-module/higher-order/pure/index.mjs |
| 974 | 1529 | var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1); |
| 975 | 1530 | var import_element = __toESM(require_element(), 1); |
| 976 | - var import_deprecated = __toESM(require_deprecated(), 1); | |
| 977 | 1531 | var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); |
| 978 | 1532 | var pure = createHigherOrderComponent(function(WrappedComponent) { |
| 979 | - (0, import_deprecated.default)("wp.compose.pure", { | |
| 980 | - since: "7.1", | |
| 981 | - alternative: "Use `memo` or `PureComponent` instead" | |
| 982 | - }); | |
| 983 | 1533 | if (WrappedComponent.prototype instanceof import_element.Component) { |
| 984 | 1534 | return class extends WrappedComponent { |
| 985 | 1535 | shouldComponentUpdate(nextProps, nextState) { |
| 986 | 1536 | return !(0, import_is_shallow_equal.isShallowEqual)(nextProps, this.props) || !(0, import_is_shallow_equal.isShallowEqual)(nextState, this.state); |
| @@ -999,9 +1549,9 @@ | ||
| 999 | 1549 | var pure_default = pure; |
| 1000 | 1550 | |
| 1001 | 1551 | // packages/compose/build-module/higher-order/with-global-events/index.mjs |
| 1002 | 1552 | var import_element2 = __toESM(require_element(), 1); |
| 1003 | - var import_deprecated2 = __toESM(require_deprecated(), 1); | |
| 1553 | + var import_deprecated = __toESM(require_deprecated(), 1); | |
| 1004 | 1554 | |
| 1005 | 1555 | // packages/compose/build-module/higher-order/with-global-events/listener.mjs |
| 1006 | 1556 | var Listener = class { |
| 1007 | 1557 | constructor() { |
| @@ -1040,9 +1590,9 @@ | ||
| 1040 | 1590 | // packages/compose/build-module/higher-order/with-global-events/index.mjs |
| 1041 | 1591 | var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); |
| 1042 | 1592 | var listener = new listener_default(); |
| 1043 | 1593 | function withGlobalEvents(eventTypesToHandlers) { |
| 1044 | - (0, import_deprecated2.default)("wp.compose.withGlobalEvents", { | |
| 1594 | + (0, import_deprecated.default)("wp.compose.withGlobalEvents", { | |
| 1045 | 1595 | since: "5.7", |
| 1046 | 1596 | alternative: "useEffect" |
| 1047 | 1597 | }); |
| 1048 | 1598 | return createHigherOrderComponent((WrappedComponent) => { |
| @@ -1175,12 +1725,12 @@ | ||
| 1175 | 1725 | var with_safe_timeout_default = withSafeTimeout; |
| 1176 | 1726 | |
| 1177 | 1727 | // packages/compose/build-module/higher-order/with-state/index.mjs |
| 1178 | 1728 | var import_element5 = __toESM(require_element(), 1); |
| 1179 | - var import_deprecated3 = __toESM(require_deprecated(), 1); | |
| 1729 | + var import_deprecated2 = __toESM(require_deprecated(), 1); | |
| 1180 | 1730 | var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); |
| 1181 | 1731 | function withState(initialState = {}) { |
| 1182 | - (0, import_deprecated3.default)("wp.compose.withState", { | |
| 1732 | + (0, import_deprecated2.default)("wp.compose.withState", { | |
| 1183 | 1733 | since: "5.8", |
| 1184 | 1734 | alternative: "wp.element.useState" |
| 1185 | 1735 | }); |
| 1186 | 1736 | return createHigherOrderComponent((OriginalComponent) => { |
| @@ -1228,10 +1778,16 @@ | ||
| 1228 | 1778 | if (key !== "Tab") { |
| 1229 | 1779 | return; |
| 1230 | 1780 | } |
| 1231 | 1781 | const action = shiftKey ? "findPrevious" : "findNext"; |
| 1232 | - const nextElement = import_dom.focus.tabbable[action](target) || null; | |
| 1233 | - if (target.contains(nextElement)) { | |
| 1782 | + const nextElement = import_dom.focus.tabbable[action]( | |
| 1783 | + /** @type {HTMLElement} */ | |
| 1784 | + target | |
| 1785 | + ) || null; | |
| 1786 | + if ( | |
| 1787 | + /** @type {HTMLElement} */ | |
| 1788 | + target.contains(nextElement) | |
| 1789 | + ) { | |
| 1234 | 1790 | event.preventDefault(); |
| 1235 | 1791 | nextElement?.focus(); |
| 1236 | 1792 | return; |
| 1237 | 1793 | } |
| @@ -1254,50 +1810,53 @@ | ||
| 1254 | 1810 | } |
| 1255 | 1811 | var use_constrained_tabbing_default = useConstrainedTabbing; |
| 1256 | 1812 | |
| 1257 | 1813 | // packages/compose/build-module/hooks/use-copy-on-click/index.mjs |
| 1258 | - var import_element8 = __toESM(require_element(), 1); | |
| 1259 | - var import_deprecated4 = __toESM(require_deprecated(), 1); | |
| 1260 | - | |
| 1261 | - // packages/compose/build-module/hooks/use-copy-to-clipboard/index.mjs | |
| 1814 | + var import_clipboard = __toESM(require_clipboard(), 1); | |
| 1262 | 1815 | var import_element7 = __toESM(require_element(), 1); |
| 1263 | - async function copyToClipboard(text, trigger) { | |
| 1264 | - if (!trigger) { | |
| 1265 | - return false; | |
| 1266 | - } | |
| 1267 | - const { ownerDocument } = trigger; | |
| 1268 | - if (!ownerDocument) { | |
| 1269 | - return false; | |
| 1270 | - } | |
| 1271 | - const { defaultView } = ownerDocument; | |
| 1272 | - try { | |
| 1273 | - if (defaultView?.navigator?.clipboard?.writeText) { | |
| 1274 | - await defaultView.navigator.clipboard.writeText(text); | |
| 1275 | - return true; | |
| 1816 | + var import_deprecated3 = __toESM(require_deprecated(), 1); | |
| 1817 | + function useCopyOnClick(ref, text, timeout = 4e3) { | |
| 1818 | + (0, import_deprecated3.default)("wp.compose.useCopyOnClick", { | |
| 1819 | + since: "5.8", | |
| 1820 | + alternative: "wp.compose.useCopyToClipboard" | |
| 1821 | + }); | |
| 1822 | + const clipboardRef = (0, import_element7.useRef)(void 0); | |
| 1823 | + const [hasCopied, setHasCopied] = (0, import_element7.useState)(false); | |
| 1824 | + (0, import_element7.useEffect)(() => { | |
| 1825 | + let timeoutId; | |
| 1826 | + if (!ref.current) { | |
| 1827 | + return; | |
| 1276 | 1828 | } |
| 1277 | - const textarea = ownerDocument.createElement("textarea"); | |
| 1278 | - textarea.value = text; | |
| 1279 | - textarea.setAttribute("readonly", ""); | |
| 1280 | - textarea.style.position = "fixed"; | |
| 1281 | - textarea.style.left = "-9999px"; | |
| 1282 | - textarea.style.top = "-9999px"; | |
| 1283 | - ownerDocument.body.appendChild(textarea); | |
| 1284 | - textarea.select(); | |
| 1285 | - const success = ownerDocument.execCommand("copy"); | |
| 1286 | - textarea.remove(); | |
| 1287 | - return success; | |
| 1288 | - } catch { | |
| 1289 | - return false; | |
| 1290 | - } | |
| 1829 | + clipboardRef.current = new import_clipboard.default(ref.current, { | |
| 1830 | + text: () => typeof text === "function" ? text() : text | |
| 1831 | + }); | |
| 1832 | + clipboardRef.current.on("success", ({ clearSelection, trigger }) => { | |
| 1833 | + clearSelection(); | |
| 1834 | + if (trigger) { | |
| 1835 | + trigger.focus(); | |
| 1836 | + } | |
| 1837 | + if (timeout) { | |
| 1838 | + setHasCopied(true); | |
| 1839 | + clearTimeout(timeoutId); | |
| 1840 | + timeoutId = setTimeout(() => setHasCopied(false), timeout); | |
| 1841 | + } | |
| 1842 | + }); | |
| 1843 | + return () => { | |
| 1844 | + if (clipboardRef.current) { | |
| 1845 | + clipboardRef.current.destroy(); | |
| 1846 | + } | |
| 1847 | + clearTimeout(timeoutId); | |
| 1848 | + }; | |
| 1849 | + }, [text, timeout, setHasCopied]); | |
| 1850 | + return hasCopied; | |
| 1291 | 1851 | } |
| 1292 | - function restoreFocus(trigger) { | |
| 1293 | - if ("focus" in trigger && typeof trigger.focus === "function") { | |
| 1294 | - trigger.focus(); | |
| 1295 | - } | |
| 1296 | - } | |
| 1852 | + | |
| 1853 | + // packages/compose/build-module/hooks/use-copy-to-clipboard/index.mjs | |
| 1854 | + var import_clipboard2 = __toESM(require_clipboard(), 1); | |
| 1855 | + var import_element8 = __toESM(require_element(), 1); | |
| 1297 | 1856 | function useUpdatedRef(value) { |
| 1298 | - const ref = (0, import_element7.useRef)(value); | |
| 1299 | - (0, import_element7.useLayoutEffect)(() => { | |
| 1857 | + const ref = (0, import_element8.useRef)(value); | |
| 1858 | + (0, import_element8.useLayoutEffect)(() => { | |
| 1300 | 1859 | ref.current = value; |
| 1301 | 1860 | }, [value]); |
| 1302 | 1861 | return ref; |
| 1303 | 1862 | } |
| @@ -1304,93 +1863,28 @@ | ||
| 1304 | 1863 | function useCopyToClipboard(text, onSuccess) { |
| 1305 | 1864 | const textRef = useUpdatedRef(text); |
| 1306 | 1865 | const onSuccessRef = useUpdatedRef(onSuccess); |
| 1307 | 1866 | return useRefEffect((node) => { |
| 1308 | - let isActive = true; | |
| 1309 | - const handleClick = async () => { | |
| 1310 | - const textToCopy = typeof textRef.current === "function" ? textRef.current() : textRef.current || ""; | |
| 1311 | - const success = await copyToClipboard(textToCopy, node); | |
| 1312 | - if (success) { | |
| 1313 | - if (isActive) { | |
| 1314 | - restoreFocus(node); | |
| 1315 | - } | |
| 1316 | - if (onSuccessRef.current) { | |
| 1317 | - onSuccessRef.current(); | |
| 1318 | - } | |
| 1867 | + const clipboard = new import_clipboard2.default(node, { | |
| 1868 | + text() { | |
| 1869 | + return typeof textRef.current === "function" ? textRef.current() : textRef.current || ""; | |
| 1319 | 1870 | } |
| 1320 | - }; | |
| 1321 | - node.addEventListener("click", handleClick); | |
| 1871 | + }); | |
| 1872 | + clipboard.on("success", ({ clearSelection }) => { | |
| 1873 | + clearSelection(); | |
| 1874 | + if (onSuccessRef.current) { | |
| 1875 | + onSuccessRef.current(); | |
| 1876 | + } | |
| 1877 | + }); | |
| 1322 | 1878 | return () => { |
| 1323 | - isActive = false; | |
| 1324 | - node.removeEventListener("click", handleClick); | |
| 1879 | + clipboard.destroy(); | |
| 1325 | 1880 | }; |
| 1326 | 1881 | }, []); |
| 1327 | 1882 | } |
| 1328 | 1883 | |
| 1329 | - // packages/compose/build-module/hooks/use-copy-on-click/index.mjs | |
| 1330 | - function useCopyOnClick(ref, text, timeout = 4e3) { | |
| 1331 | - (0, import_deprecated4.default)("wp.compose.useCopyOnClick", { | |
| 1332 | - since: "5.8", | |
| 1333 | - alternative: "wp.compose.useCopyToClipboard" | |
| 1334 | - }); | |
| 1335 | - const [hasCopied, setHasCopied] = (0, import_element8.useState)(false); | |
| 1336 | - (0, import_element8.useEffect)(() => { | |
| 1337 | - let isActive = true; | |
| 1338 | - let timeoutId; | |
| 1339 | - if (!ref.current) { | |
| 1340 | - return; | |
| 1341 | - } | |
| 1342 | - let targets; | |
| 1343 | - if (typeof ref.current === "string") { | |
| 1344 | - targets = typeof document !== "undefined" ? Array.from(document.querySelectorAll(ref.current)) : []; | |
| 1345 | - } else if ("length" in ref.current && typeof ref.current.length === "number") { | |
| 1346 | - targets = Array.from(ref.current); | |
| 1347 | - } else { | |
| 1348 | - targets = [ref.current]; | |
| 1349 | - } | |
| 1350 | - if (targets.length === 0) { | |
| 1351 | - return; | |
| 1352 | - } | |
| 1353 | - const handleClick = async (event) => { | |
| 1354 | - const trigger = event.currentTarget; | |
| 1355 | - if (!trigger) { | |
| 1356 | - return; | |
| 1357 | - } | |
| 1358 | - const success = await copyToClipboard( | |
| 1359 | - typeof text === "function" ? text() : text || "", | |
| 1360 | - trigger | |
| 1361 | - ); | |
| 1362 | - if (!isActive) { | |
| 1363 | - return; | |
| 1364 | - } | |
| 1365 | - if (success) { | |
| 1366 | - restoreFocus(trigger); | |
| 1367 | - if (timeout) { | |
| 1368 | - setHasCopied(true); | |
| 1369 | - clearTimeout(timeoutId); | |
| 1370 | - timeoutId = setTimeout( | |
| 1371 | - () => setHasCopied(false), | |
| 1372 | - timeout | |
| 1373 | - ); | |
| 1374 | - } | |
| 1375 | - } | |
| 1376 | - }; | |
| 1377 | - for (const target of targets) { | |
| 1378 | - target.addEventListener("click", handleClick); | |
| 1379 | - } | |
| 1380 | - return () => { | |
| 1381 | - isActive = false; | |
| 1382 | - for (const target of targets) { | |
| 1383 | - target.removeEventListener("click", handleClick); | |
| 1384 | - } | |
| 1385 | - clearTimeout(timeoutId); | |
| 1386 | - }; | |
| 1387 | - }, [ref, text, timeout]); | |
| 1388 | - return hasCopied; | |
| 1389 | - } | |
| 1390 | - | |
| 1391 | 1884 | // packages/compose/build-module/hooks/use-dialog/index.mjs |
| 1392 | 1885 | var import_element13 = __toESM(require_element(), 1); |
| 1886 | + var import_keycodes = __toESM(require_keycodes(), 1); | |
| 1393 | 1887 | |
| 1394 | 1888 | // packages/compose/build-module/hooks/use-focus-on-mount/index.mjs |
| 1395 | 1889 | var import_dom2 = __toESM(require_dom(), 1); |
| 1396 | 1890 | var import_element9 = __toESM(require_element(), 1); |
| @@ -1443,12 +1937,10 @@ | ||
| 1443 | 1937 | var import_element10 = __toESM(require_element(), 1); |
| 1444 | 1938 | var origin = null; |
| 1445 | 1939 | function useFocusReturn(onFocusReturn) { |
| 1446 | 1940 | const ref = (0, import_element10.useRef)(null); |
| 1447 | - const focusedBeforeMountRef = (0, import_element10.useRef)(null); | |
| 1448 | - const onFocusReturnRef = (0, import_element10.useRef)( | |
| 1449 | - onFocusReturn | |
| 1450 | - ); | |
| 1941 | + const focusedBeforeMount = (0, import_element10.useRef)(null); | |
| 1942 | + const onFocusReturnRef = (0, import_element10.useRef)(onFocusReturn); | |
| 1451 | 1943 | (0, import_element10.useEffect)(() => { |
| 1452 | 1944 | onFocusReturnRef.current = onFocusReturn; |
| 1453 | 1945 | }, [onFocusReturn]); |
| 1454 | 1946 | return (0, import_element10.useCallback)((node) => { |
| @@ -1453,26 +1945,25 @@ | ||
| 1453 | 1945 | }, [onFocusReturn]); |
| 1454 | 1946 | return (0, import_element10.useCallback)((node) => { |
| 1455 | 1947 | if (node) { |
| 1456 | 1948 | ref.current = node; |
| 1457 | - if (focusedBeforeMountRef.current) { | |
| 1949 | + if (focusedBeforeMount.current) { | |
| 1458 | 1950 | return; |
| 1459 | 1951 | } |
| 1460 | 1952 | const activeDocument = node.ownerDocument.activeElement instanceof window.HTMLIFrameElement ? node.ownerDocument.activeElement.contentDocument : node.ownerDocument; |
| 1461 | - focusedBeforeMountRef.current = activeDocument?.activeElement ?? null; | |
| 1462 | - } else if (focusedBeforeMountRef.current) { | |
| 1953 | + focusedBeforeMount.current = activeDocument?.activeElement ?? null; | |
| 1954 | + } else if (focusedBeforeMount.current) { | |
| 1463 | 1955 | const isFocused = ref.current?.contains( |
| 1464 | - ref.current?.ownerDocument.activeElement ?? null | |
| 1956 | + ref.current?.ownerDocument.activeElement | |
| 1465 | 1957 | ); |
| 1466 | 1958 | if (ref.current?.isConnected && !isFocused) { |
| 1467 | - origin ??= focusedBeforeMountRef.current; | |
| 1959 | + origin ??= focusedBeforeMount.current; | |
| 1468 | 1960 | return; |
| 1469 | 1961 | } |
| 1470 | 1962 | if (onFocusReturnRef.current) { |
| 1471 | 1963 | onFocusReturnRef.current(); |
| 1472 | 1964 | } else { |
| 1473 | - const elementToFocus = !focusedBeforeMountRef.current.isConnected ? origin : focusedBeforeMountRef.current; | |
| 1474 | - elementToFocus?.focus(); | |
| 1965 | + (!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus(); | |
| 1475 | 1966 | } |
| 1476 | 1967 | origin = null; |
| 1477 | 1968 | } |
| 1478 | 1969 | }, []); |
| @@ -1555,31 +2046,19 @@ | ||
| 1555 | 2046 | // packages/compose/build-module/hooks/use-merge-refs/index.mjs |
| 1556 | 2047 | var import_element12 = __toESM(require_element(), 1); |
| 1557 | 2048 | function assignRef(ref, value) { |
| 1558 | 2049 | if (typeof ref === "function") { |
| 1559 | - const returned = ref(value); | |
| 1560 | - return typeof returned === "function" ? returned : void 0; | |
| 2050 | + ref(value); | |
| 1561 | 2051 | } else if (ref && ref.hasOwnProperty("current")) { |
| 1562 | 2052 | ref.current = value; |
| 1563 | 2053 | } |
| 1564 | - return void 0; | |
| 1565 | 2054 | } |
| 1566 | - function detachRef(ref, index, cleanups) { | |
| 1567 | - const cleanup = cleanups[index]; | |
| 1568 | - if (cleanup) { | |
| 1569 | - cleanups[index] = void 0; | |
| 1570 | - cleanup(); | |
| 1571 | - } else { | |
| 1572 | - assignRef(ref, null); | |
| 1573 | - } | |
| 1574 | - } | |
| 1575 | 2055 | function useMergeRefs(refs) { |
| 1576 | - const elementRef = (0, import_element12.useRef)(null); | |
| 2056 | + const element = (0, import_element12.useRef)(null); | |
| 1577 | 2057 | const isAttachedRef = (0, import_element12.useRef)(false); |
| 1578 | 2058 | const didElementChangeRef = (0, import_element12.useRef)(false); |
| 1579 | 2059 | const previousRefsRef = (0, import_element12.useRef)([]); |
| 1580 | 2060 | const currentRefsRef = (0, import_element12.useRef)(refs); |
| 1581 | - const cleanupsRef = (0, import_element12.useRef)([]); | |
| 1582 | 2061 | currentRefsRef.current = refs; |
| 1583 | 2062 | (0, import_element12.useLayoutEffect)(() => { |
| 1584 | 2063 | if (didElementChangeRef.current === false && isAttachedRef.current === true) { |
| 1585 | 2064 | refs.forEach((ref, index) => { |
| @@ -1584,13 +2063,10 @@ | ||
| 1584 | 2063 | if (didElementChangeRef.current === false && isAttachedRef.current === true) { |
| 1585 | 2064 | refs.forEach((ref, index) => { |
| 1586 | 2065 | const previousRef = previousRefsRef.current[index]; |
| 1587 | 2066 | if (ref !== previousRef) { |
| 1588 | - detachRef(previousRef, index, cleanupsRef.current); | |
| 1589 | - cleanupsRef.current[index] = assignRef( | |
| 1590 | - ref, | |
| 1591 | - elementRef.current | |
| 1592 | - ); | |
| 2067 | + assignRef(previousRef, null); | |
| 2068 | + assignRef(ref, element.current); | |
| 1593 | 2069 | } |
| 1594 | 2070 | }); |
| 1595 | 2071 | } |
| 1596 | 2072 | previousRefsRef.current = refs; |
| @@ -1598,19 +2074,14 @@ | ||
| 1598 | 2074 | (0, import_element12.useLayoutEffect)(() => { |
| 1599 | 2075 | didElementChangeRef.current = false; |
| 1600 | 2076 | }); |
| 1601 | 2077 | return (0, import_element12.useCallback)((value) => { |
| 1602 | - elementRef.current = value; | |
| 2078 | + assignRef(element, value); | |
| 1603 | 2079 | didElementChangeRef.current = true; |
| 1604 | 2080 | isAttachedRef.current = value !== null; |
| 1605 | - if (value === null) { | |
| 1606 | - previousRefsRef.current.forEach((ref, index) => { | |
| 1607 | - detachRef(ref, index, cleanupsRef.current); | |
| 1608 | - }); | |
| 1609 | - } else { | |
| 1610 | - currentRefsRef.current.forEach((ref, index) => { | |
| 1611 | - cleanupsRef.current[index] = assignRef(ref, value); | |
| 1612 | - }); | |
| 2081 | + const refsToAssign = value ? currentRefsRef.current : previousRefsRef.current; | |
| 2082 | + for (const ref of refsToAssign) { | |
| 2083 | + assignRef(ref, value); | |
| 1613 | 2084 | } |
| 1614 | 2085 | }, []); |
| 1615 | 2086 | } |
| 1616 | 2087 | |
| @@ -1630,25 +2101,28 @@ | ||
| 1630 | 2101 | } else if (currentOptions.current?.onClose) { |
| 1631 | 2102 | currentOptions.current.onClose(); |
| 1632 | 2103 | } |
| 1633 | 2104 | }); |
| 1634 | - const onKeyDown = (0, import_element13.useCallback)((event) => { | |
| 1635 | - currentOptions.current?.onKeyDown?.(event); | |
| 1636 | - if (event.key === "Escape" && !event.defaultPrevented && currentOptions.current?.onClose) { | |
| 1637 | - event.preventDefault(); | |
| 1638 | - event.stopPropagation(); | |
| 1639 | - currentOptions.current.onClose(); | |
| 2105 | + const closeOnEscapeRef = (0, import_element13.useCallback)((node) => { | |
| 2106 | + if (!node) { | |
| 2107 | + return; | |
| 1640 | 2108 | } |
| 2109 | + node.addEventListener("keydown", (event) => { | |
| 2110 | + if (event.keyCode === import_keycodes.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) { | |
| 2111 | + event.preventDefault(); | |
| 2112 | + currentOptions.current.onClose(); | |
| 2113 | + } | |
| 2114 | + }); | |
| 1641 | 2115 | }, []); |
| 1642 | 2116 | return [ |
| 1643 | 2117 | useMergeRefs([ |
| 1644 | 2118 | constrainTabbing ? constrainedTabbingRef : null, |
| 1645 | 2119 | options.focusOnMount !== false ? focusReturnRef : null, |
| 1646 | - options.focusOnMount !== false ? focusOnMountRef : null | |
| 2120 | + options.focusOnMount !== false ? focusOnMountRef : null, | |
| 2121 | + closeOnEscapeRef | |
| 1647 | 2122 | ]), |
| 1648 | 2123 | { |
| 1649 | 2124 | ...focusOutsideProps, |
| 1650 | - onKeyDown, | |
| 1651 | 2125 | tabIndex: -1 |
| 1652 | 2126 | } |
| 1653 | 2127 | ]; |
| 1654 | 2128 | } |
| @@ -1726,13 +2200,9 @@ | ||
| 1726 | 2200 | var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_element15.useLayoutEffect : import_element15.useEffect; |
| 1727 | 2201 | var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect; |
| 1728 | 2202 | |
| 1729 | 2203 | // packages/compose/build-module/hooks/use-dragging/index.mjs |
| 1730 | - function useDragging({ | |
| 1731 | - onDragStart, | |
| 1732 | - onDragMove, | |
| 1733 | - onDragEnd | |
| 1734 | - }) { | |
| 2204 | + function useDragging({ onDragStart, onDragMove, onDragEnd }) { | |
| 1735 | 2205 | const [isDragging, setIsDragging] = (0, import_element16.useState)(false); |
| 1736 | 2206 | const eventsRef = (0, import_element16.useRef)({ |
| 1737 | 2207 | onDragStart, |
| 1738 | 2208 | onDragMove, |
| @@ -1742,29 +2212,28 @@ | ||
| 1742 | 2212 | eventsRef.current.onDragStart = onDragStart; |
| 1743 | 2213 | eventsRef.current.onDragMove = onDragMove; |
| 1744 | 2214 | eventsRef.current.onDragEnd = onDragEnd; |
| 1745 | 2215 | }, [onDragStart, onDragMove, onDragEnd]); |
| 1746 | - const onMouseMove = (0, import_element16.useCallback)((event) => { | |
| 1747 | - eventsRef.current.onDragMove?.(event); | |
| 2216 | + const onMouseMove = (0, import_element16.useCallback)( | |
| 2217 | + (event) => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event), | |
| 2218 | + [] | |
| 2219 | + ); | |
| 2220 | + const endDrag = (0, import_element16.useCallback)((event) => { | |
| 2221 | + if (eventsRef.current.onDragEnd) { | |
| 2222 | + eventsRef.current.onDragEnd(event); | |
| 2223 | + } | |
| 2224 | + document.removeEventListener("mousemove", onMouseMove); | |
| 2225 | + document.removeEventListener("mouseup", endDrag); | |
| 2226 | + setIsDragging(false); | |
| 1748 | 2227 | }, []); |
| 1749 | - const endDrag = (0, import_element16.useCallback)( | |
| 1750 | - function endDrag2(event) { | |
| 1751 | - eventsRef.current.onDragEnd?.(event); | |
| 1752 | - document.removeEventListener("mousemove", onMouseMove); | |
| 1753 | - document.removeEventListener("mouseup", endDrag2); | |
| 1754 | - setIsDragging(false); | |
| 1755 | - }, | |
| 1756 | - [onMouseMove] | |
| 1757 | - ); | |
| 1758 | - const startDrag = (0, import_element16.useCallback)( | |
| 1759 | - (event) => { | |
| 1760 | - eventsRef.current.onDragStart?.(event); | |
| 1761 | - document.addEventListener("mousemove", onMouseMove); | |
| 1762 | - document.addEventListener("mouseup", endDrag); | |
| 1763 | - setIsDragging(true); | |
| 1764 | - }, | |
| 1765 | - [onMouseMove, endDrag] | |
| 1766 | - ); | |
| 2228 | + const startDrag = (0, import_element16.useCallback)((event) => { | |
| 2229 | + if (eventsRef.current.onDragStart) { | |
| 2230 | + eventsRef.current.onDragStart(event); | |
| 2231 | + } | |
| 2232 | + document.addEventListener("mousemove", onMouseMove); | |
| 2233 | + document.addEventListener("mouseup", endDrag); | |
| 2234 | + setIsDragging(true); | |
| 2235 | + }, []); | |
| 1767 | 2236 | (0, import_element16.useEffect)(() => { |
| 1768 | 2237 | return () => { |
| 1769 | 2238 | if (isDragging) { |
| 1770 | 2239 | document.removeEventListener("mousemove", onMouseMove); |
| @@ -1770,9 +2239,9 @@ | ||
| 1770 | 2239 | document.removeEventListener("mousemove", onMouseMove); |
| 1771 | 2240 | document.removeEventListener("mouseup", endDrag); |
| 1772 | 2241 | } |
| 1773 | 2242 | }; |
| 1774 | - }, [isDragging, onMouseMove, endDrag]); | |
| 2243 | + }, [isDragging]); | |
| 1775 | 2244 | return { |
| 1776 | 2245 | startDrag, |
| 1777 | 2246 | endDrag, |
| 1778 | 2247 | isDragging |
| @@ -1814,13 +2283,14 @@ | ||
| 1814 | 2283 | })(typeof Mousetrap !== "undefined" ? Mousetrap : void 0); |
| 1815 | 2284 | |
| 1816 | 2285 | // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs |
| 1817 | 2286 | var import_element17 = __toESM(require_element(), 1); |
| 1818 | - var import_keycodes = __toESM(require_keycodes(), 1); | |
| 2287 | + var import_keycodes2 = __toESM(require_keycodes(), 1); | |
| 1819 | 2288 | function useKeyboardShortcut(shortcuts, callback, { |
| 1820 | 2289 | bindGlobal = false, |
| 1821 | 2290 | eventName = "keydown", |
| 1822 | 2291 | isDisabled = false, |
| 2292 | + // This is important for performance considerations. | |
| 1823 | 2293 | target |
| 1824 | 2294 | } = {}) { |
| 1825 | 2295 | const currentCallbackRef = (0, import_element17.useRef)(callback); |
| 1826 | 2296 | (0, import_element17.useEffect)(() => { |
| @@ -1834,8 +2304,10 @@ | ||
| 1834 | 2304 | target && target.current ? target.current : ( |
| 1835 | 2305 | // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`. |
| 1836 | 2306 | // 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 |
| 1837 | 2307 | // necessary to maintain the existing behavior. |
| 2308 | + /** @type {Element} */ | |
| 2309 | + /** @type {unknown} */ | |
| 1838 | 2310 | document |
| 1839 | 2311 | ) |
| 1840 | 2312 | ); |
| 1841 | 2313 | const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts]; |
| @@ -1845,9 +2317,9 @@ | ||
| 1845 | 2317 | keys.filter((value) => value.length > 1) |
| 1846 | 2318 | ); |
| 1847 | 2319 | const hasAlt = modifiers.has("alt"); |
| 1848 | 2320 | const hasShift = modifiers.has("shift"); |
| 1849 | - if ((0, import_keycodes.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { | |
| 2321 | + if ((0, import_keycodes2.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { | |
| 1850 | 2322 | throw new Error( |
| 1851 | 2323 | `Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.` |
| 1852 | 2324 | ); |
| 1853 | 2325 | } |
| @@ -1866,56 +2338,47 @@ | ||
| 1866 | 2338 | var use_keyboard_shortcut_default = useKeyboardShortcut; |
| 1867 | 2339 | |
| 1868 | 2340 | // packages/compose/build-module/hooks/use-media-query/index.mjs |
| 1869 | 2341 | var import_element18 = __toESM(require_element(), 1); |
| 1870 | - var perWindowCache = /* @__PURE__ */ new WeakMap(); | |
| 1871 | - var EMPTY_SUBSCRIBER = { | |
| 1872 | - subscribe: () => () => { | |
| 1873 | - }, | |
| 1874 | - getValue: () => false | |
| 1875 | - }; | |
| 1876 | - function getMQLSubscriber(view, query) { | |
| 1877 | - if (!view || !query || typeof view.matchMedia !== "function") { | |
| 1878 | - return EMPTY_SUBSCRIBER; | |
| 2342 | + var matchMediaCache = /* @__PURE__ */ new Map(); | |
| 2343 | + function getMediaQueryList(query) { | |
| 2344 | + if (!query) { | |
| 2345 | + return null; | |
| 1879 | 2346 | } |
| 1880 | - let queryCache = perWindowCache.get(view); | |
| 1881 | - if (!queryCache) { | |
| 1882 | - queryCache = /* @__PURE__ */ new Map(); | |
| 1883 | - perWindowCache.set(view, queryCache); | |
| 2347 | + let match = matchMediaCache.get(query); | |
| 2348 | + if (match) { | |
| 2349 | + return match; | |
| 1884 | 2350 | } |
| 1885 | - const cached = queryCache.get(query); | |
| 1886 | - if (cached) { | |
| 1887 | - return cached; | |
| 2351 | + if (typeof window !== "undefined" && typeof window.matchMedia === "function") { | |
| 2352 | + match = window.matchMedia(query); | |
| 2353 | + matchMediaCache.set(query, match); | |
| 2354 | + return match; | |
| 1888 | 2355 | } |
| 1889 | - const mediaQueryList = view.matchMedia(query); | |
| 1890 | - const listeners = /* @__PURE__ */ new Set(); | |
| 1891 | - const notify = () => { | |
| 1892 | - for (const listener2 of listeners) { | |
| 1893 | - listener2(); | |
| 1894 | - } | |
| 1895 | - }; | |
| 1896 | - const subscriber = { | |
| 1897 | - subscribe(onStoreChange) { | |
| 1898 | - if (listeners.size === 0) { | |
| 1899 | - mediaQueryList.addEventListener?.("change", notify); | |
| 2356 | + return null; | |
| 2357 | + } | |
| 2358 | + function useMediaQuery(query) { | |
| 2359 | + const source = (0, import_element18.useMemo)(() => { | |
| 2360 | + const mediaQueryList = getMediaQueryList(query); | |
| 2361 | + return { | |
| 2362 | + /** @type {(onStoreChange: () => void) => () => void} */ | |
| 2363 | + subscribe(onStoreChange) { | |
| 2364 | + if (!mediaQueryList) { | |
| 2365 | + return () => { | |
| 2366 | + }; | |
| 2367 | + } | |
| 2368 | + mediaQueryList.addEventListener?.("change", onStoreChange); | |
| 2369 | + return () => { | |
| 2370 | + mediaQueryList.removeEventListener?.( | |
| 2371 | + "change", | |
| 2372 | + onStoreChange | |
| 2373 | + ); | |
| 2374 | + }; | |
| 2375 | + }, | |
| 2376 | + getValue() { | |
| 2377 | + return mediaQueryList?.matches ?? false; | |
| 1900 | 2378 | } |
| 1901 | - listeners.add(onStoreChange); | |
| 1902 | - return () => { | |
| 1903 | - listeners.delete(onStoreChange); | |
| 1904 | - if (listeners.size === 0) { | |
| 1905 | - mediaQueryList.removeEventListener?.("change", notify); | |
| 1906 | - } | |
| 1907 | - }; | |
| 1908 | - }, | |
| 1909 | - getValue() { | |
| 1910 | - return mediaQueryList.matches; | |
| 1911 | - } | |
| 1912 | - }; | |
| 1913 | - queryCache.set(query, subscriber); | |
| 1914 | - return subscriber; | |
| 1915 | - } | |
| 1916 | - function useMediaQuery(query, view = typeof window !== "undefined" ? window : void 0) { | |
| 1917 | - const source = getMQLSubscriber(view, query); | |
| 2379 | + }; | |
| 2380 | + }, [query]); | |
| 1918 | 2381 | return (0, import_element18.useSyncExternalStore)( |
| 1919 | 2382 | source.subscribe, |
| 1920 | 2383 | source.getValue, |
| 1921 | 2384 | () => false |
| @@ -2032,14 +2495,17 @@ | ||
| 2032 | 2495 | var OPERATOR_EVALUATORS = { |
| 2033 | 2496 | ">=": (breakpointValue, width) => width >= breakpointValue, |
| 2034 | 2497 | "<": (breakpointValue, width) => width < breakpointValue |
| 2035 | 2498 | }; |
| 2036 | - var ViewportMatchWidthContext = (0, import_element21.createContext)(null); | |
| 2499 | + var ViewportMatchWidthContext = (0, import_element21.createContext)( | |
| 2500 | + /** @type {null | number} */ | |
| 2501 | + null | |
| 2502 | + ); | |
| 2037 | 2503 | ViewportMatchWidthContext.displayName = "ViewportMatchWidthContext"; |
| 2038 | - var useViewportMatch = (breakpoint, operator = ">=", view = typeof window !== "undefined" ? window : void 0) => { | |
| 2504 | + var useViewportMatch = (breakpoint, operator = ">=") => { | |
| 2039 | 2505 | const simulatedWidth = (0, import_element21.useContext)(ViewportMatchWidthContext); |
| 2040 | 2506 | const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`; |
| 2041 | - const mediaQueryResult = useMediaQuery(mediaQuery || void 0, view); | |
| 2507 | + const mediaQueryResult = useMediaQuery(mediaQuery || void 0); | |
| 2042 | 2508 | if (simulatedWidth) { |
| 2043 | 2509 | return OPERATOR_EVALUATORS[operator]( |
| 2044 | 2510 | BREAKPOINTS[breakpoint], |
| 2045 | 2511 | simulatedWidth |
| @@ -2181,13 +2647,20 @@ | ||
| 2181 | 2647 | // packages/compose/build-module/hooks/use-warn-on-change/index.mjs |
| 2182 | 2648 | function useWarnOnChange(object, prefix = "Change detection") { |
| 2183 | 2649 | const previousValues = usePrevious(object); |
| 2184 | 2650 | Object.entries(previousValues ?? []).forEach(([key, value]) => { |
| 2185 | - if (value !== object[key]) { | |
| 2651 | + if (value !== object[ | |
| 2652 | + /** @type {keyof typeof object} */ | |
| 2653 | + key | |
| 2654 | + ]) { | |
| 2186 | 2655 | console.warn( |
| 2187 | 2656 | `${prefix}: ${key} key changed:`, |
| 2188 | 2657 | value, |
| 2189 | - object[key] | |
| 2658 | + object[ | |
| 2659 | + /** @type {keyof typeof object} */ | |
| 2660 | + key | |
| 2661 | + ] | |
| 2662 | + /* eslint-enable jsdoc/check-types */ | |
| 2190 | 2663 | ); |
| 2191 | 2664 | } |
| 2192 | 2665 | }); |
| 2193 | 2666 | } |
| @@ -2309,9 +2782,12 @@ | ||
| 2309 | 2782 | } |
| 2310 | 2783 | } |
| 2311 | 2784 | function onDragEnter(event) { |
| 2312 | 2785 | event.preventDefault(); |
| 2313 | - if (element.contains(event.relatedTarget)) { | |
| 2786 | + if (element.contains( | |
| 2787 | + /** @type {Node} */ | |
| 2788 | + event.relatedTarget | |
| 2789 | + )) { | |
| 2314 | 2790 | return; |
| 2315 | 2791 | } |
| 2316 | 2792 | if (_onDragEnter) { |
| 2317 | 2793 | onDragEnterEvent(event); |
| @@ -2403,23 +2879,21 @@ | ||
| 2403 | 2879 | |
| 2404 | 2880 | // packages/compose/build-module/hooks/use-fixed-window-list/index.mjs |
| 2405 | 2881 | var import_element28 = __toESM(require_element(), 1); |
| 2406 | 2882 | var import_dom3 = __toESM(require_dom(), 1); |
| 2407 | - var import_keycodes2 = __toESM(require_keycodes(), 1); | |
| 2883 | + var import_keycodes3 = __toESM(require_keycodes(), 1); | |
| 2408 | 2884 | var DEFAULT_INIT_WINDOW_SIZE = 30; |
| 2409 | 2885 | function useFixedWindowList(elementRef, itemHeight, totalItems, options) { |
| 2410 | 2886 | const initWindowSize = options?.initWindowSize ?? DEFAULT_INIT_WINDOW_SIZE; |
| 2411 | 2887 | const useWindowing = options?.useWindowing ?? true; |
| 2412 | - const [fixedListWindow, setFixedListWindow] = (0, import_element28.useState)( | |
| 2413 | - { | |
| 2414 | - visibleItems: initWindowSize, | |
| 2415 | - start: 0, | |
| 2416 | - end: initWindowSize, | |
| 2417 | - itemInView: (index) => { | |
| 2418 | - return index >= 0 && index <= initWindowSize; | |
| 2419 | - } | |
| 2888 | + const [fixedListWindow, setFixedListWindow] = (0, import_element28.useState)({ | |
| 2889 | + visibleItems: initWindowSize, | |
| 2890 | + start: 0, | |
| 2891 | + end: initWindowSize, | |
| 2892 | + itemInView: (index) => { | |
| 2893 | + return index >= 0 && index <= initWindowSize; | |
| 2420 | 2894 | } |
| 2421 | - ); | |
| 2895 | + }); | |
| 2422 | 2896 | (0, import_element28.useLayoutEffect)(() => { |
| 2423 | 2897 | if (!useWindowing) { |
| 2424 | 2898 | return; |
| 2425 | 2899 | } |
| @@ -2492,22 +2966,22 @@ | ||
| 2492 | 2966 | } |
| 2493 | 2967 | const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current); |
| 2494 | 2968 | const handleKeyDown = (event) => { |
| 2495 | 2969 | switch (event.keyCode) { |
| 2496 | - case import_keycodes2.HOME: { | |
| 2970 | + case import_keycodes3.HOME: { | |
| 2497 | 2971 | return scrollContainer?.scrollTo({ top: 0 }); |
| 2498 | 2972 | } |
| 2499 | - case import_keycodes2.END: { | |
| 2973 | + case import_keycodes3.END: { | |
| 2500 | 2974 | return scrollContainer?.scrollTo({ |
| 2501 | 2975 | top: totalItems * itemHeight |
| 2502 | 2976 | }); |
| 2503 | 2977 | } |
| 2504 | - case import_keycodes2.PAGEUP: { | |
| 2978 | + case import_keycodes3.PAGEUP: { | |
| 2505 | 2979 | return scrollContainer?.scrollTo({ |
| 2506 | 2980 | top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight |
| 2507 | 2981 | }); |
| 2508 | 2982 | } |
| 2509 | - case import_keycodes2.PAGEDOWN: { | |
| 2983 | + case import_keycodes3.PAGEDOWN: { | |
| 2510 | 2984 | return scrollContainer?.scrollTo({ |
| 2511 | 2985 | top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight |
| 2512 | 2986 | }); |
| 2513 | 2987 | } |
| @@ -2547,5 +3021,15 @@ | ||
| 2547 | 3021 | return (0, import_element29.useSyncExternalStore)(subscribe, getValue, getValue); |
| 2548 | 3022 | } |
| 2549 | 3023 | return __toCommonJS(index_exports); |
| 2550 | 3024 | })(); |
| 3025 | +/*! Bundled license information: | |
| 3026 | + | |
| 3027 | +clipboard/dist/clipboard.js: | |
| 3028 | + (*! | |
| 3029 | + * clipboard.js v2.0.11 | |
| 3030 | + * https://clipboardjs.com/ | |
| 3031 | + * | |
| 3032 | + * Licensed MIT © Zeno Rocha | |
| 3033 | + *) | |
| 3034 | +*/ | |
| 2551 | 3035 | //# sourceMappingURL=index.js.map |