| @@ -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) { |
| @@ -1255,143 +1810,81 @@ | ||
| 1255 | 1810 | } |
| 1256 | 1811 | var use_constrained_tabbing_default = useConstrainedTabbing; |
| 1257 | 1812 | |
| 1258 | 1813 | // packages/compose/build-module/hooks/use-copy-on-click/index.mjs |
| 1259 | - var import_element8 = __toESM(require_element(), 1); | |
| 1814 | + var import_clipboard = __toESM(require_clipboard(), 1); | |
| 1815 | + var import_element7 = __toESM(require_element(), 1); | |
| 1260 | 1816 | var import_deprecated3 = __toESM(require_deprecated(), 1); |
| 1261 | - | |
| 1262 | - // packages/compose/build-module/hooks/use-copy-to-clipboard/index.mjs | |
| 1263 | - var import_element7 = __toESM(require_element(), 1); | |
| 1264 | - async function copyToClipboard(text, trigger) { | |
| 1265 | - if (!trigger) { | |
| 1266 | - return false; | |
| 1267 | - } | |
| 1268 | - const { ownerDocument } = trigger; | |
| 1269 | - if (!ownerDocument) { | |
| 1270 | - return false; | |
| 1271 | - } | |
| 1272 | - const { defaultView } = ownerDocument; | |
| 1273 | - try { | |
| 1274 | - if (defaultView?.navigator?.clipboard?.writeText) { | |
| 1275 | - await defaultView.navigator.clipboard.writeText(text); | |
| 1276 | - return true; | |
| 1277 | - } | |
| 1278 | - const textarea = ownerDocument.createElement("textarea"); | |
| 1279 | - textarea.value = text; | |
| 1280 | - textarea.setAttribute("readonly", ""); | |
| 1281 | - textarea.style.position = "fixed"; | |
| 1282 | - textarea.style.left = "-9999px"; | |
| 1283 | - textarea.style.top = "-9999px"; | |
| 1284 | - ownerDocument.body.appendChild(textarea); | |
| 1285 | - textarea.select(); | |
| 1286 | - const success = ownerDocument.execCommand("copy"); | |
| 1287 | - textarea.remove(); | |
| 1288 | - return success; | |
| 1289 | - } catch { | |
| 1290 | - return false; | |
| 1291 | - } | |
| 1292 | - } | |
| 1293 | - function restoreFocus(trigger) { | |
| 1294 | - if ("focus" in trigger && typeof trigger.focus === "function") { | |
| 1295 | - trigger.focus(); | |
| 1296 | - } | |
| 1297 | - } | |
| 1298 | - function useUpdatedRef(value) { | |
| 1299 | - const ref = (0, import_element7.useRef)(value); | |
| 1300 | - (0, import_element7.useLayoutEffect)(() => { | |
| 1301 | - ref.current = value; | |
| 1302 | - }, [value]); | |
| 1303 | - return ref; | |
| 1304 | - } | |
| 1305 | - function useCopyToClipboard(text, onSuccess) { | |
| 1306 | - const textRef = useUpdatedRef(text); | |
| 1307 | - const onSuccessRef = useUpdatedRef(onSuccess); | |
| 1308 | - return useRefEffect((node) => { | |
| 1309 | - let isActive = true; | |
| 1310 | - const handleClick = async () => { | |
| 1311 | - const textToCopy = typeof textRef.current === "function" ? textRef.current() : textRef.current || ""; | |
| 1312 | - const success = await copyToClipboard(textToCopy, node); | |
| 1313 | - if (success) { | |
| 1314 | - if (isActive) { | |
| 1315 | - restoreFocus(node); | |
| 1316 | - } | |
| 1317 | - if (onSuccessRef.current) { | |
| 1318 | - onSuccessRef.current(); | |
| 1319 | - } | |
| 1320 | - } | |
| 1321 | - }; | |
| 1322 | - node.addEventListener("click", handleClick); | |
| 1323 | - return () => { | |
| 1324 | - isActive = false; | |
| 1325 | - node.removeEventListener("click", handleClick); | |
| 1326 | - }; | |
| 1327 | - }, []); | |
| 1328 | - } | |
| 1329 | - | |
| 1330 | - // packages/compose/build-module/hooks/use-copy-on-click/index.mjs | |
| 1331 | 1817 | function useCopyOnClick(ref, text, timeout = 4e3) { |
| 1332 | 1818 | (0, import_deprecated3.default)("wp.compose.useCopyOnClick", { |
| 1333 | 1819 | since: "5.8", |
| 1334 | 1820 | alternative: "wp.compose.useCopyToClipboard" |
| 1335 | 1821 | }); |
| 1336 | - const [hasCopied, setHasCopied] = (0, import_element8.useState)(false); | |
| 1337 | - (0, import_element8.useEffect)(() => { | |
| 1338 | - let isActive = true; | |
| 1822 | + const clipboardRef = (0, import_element7.useRef)(void 0); | |
| 1823 | + const [hasCopied, setHasCopied] = (0, import_element7.useState)(false); | |
| 1824 | + (0, import_element7.useEffect)(() => { | |
| 1339 | 1825 | let timeoutId; |
| 1340 | 1826 | if (!ref.current) { |
| 1341 | 1827 | return; |
| 1342 | 1828 | } |
| 1343 | - let targets; | |
| 1344 | - if (typeof ref.current === "string") { | |
| 1345 | - targets = typeof document !== "undefined" ? Array.from(document.querySelectorAll(ref.current)) : []; | |
| 1346 | - } else if ("length" in ref.current && typeof ref.current.length === "number") { | |
| 1347 | - targets = Array.from(ref.current); | |
| 1348 | - } else { | |
| 1349 | - targets = [ref.current]; | |
| 1350 | - } | |
| 1351 | - if (targets.length === 0) { | |
| 1352 | - return; | |
| 1353 | - } | |
| 1354 | - const handleClick = async (event) => { | |
| 1355 | - const trigger = event.currentTarget; | |
| 1356 | - if (!trigger) { | |
| 1357 | - return; | |
| 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(); | |
| 1358 | 1836 | } |
| 1359 | - const success = await copyToClipboard( | |
| 1360 | - typeof text === "function" ? text() : text || "", | |
| 1361 | - trigger | |
| 1362 | - ); | |
| 1363 | - if (!isActive) { | |
| 1364 | - return; | |
| 1837 | + if (timeout) { | |
| 1838 | + setHasCopied(true); | |
| 1839 | + clearTimeout(timeoutId); | |
| 1840 | + timeoutId = setTimeout(() => setHasCopied(false), timeout); | |
| 1365 | 1841 | } |
| 1366 | - if (success) { | |
| 1367 | - restoreFocus(trigger); | |
| 1368 | - if (timeout) { | |
| 1369 | - setHasCopied(true); | |
| 1370 | - clearTimeout(timeoutId); | |
| 1371 | - timeoutId = setTimeout( | |
| 1372 | - () => setHasCopied(false), | |
| 1373 | - timeout | |
| 1374 | - ); | |
| 1375 | - } | |
| 1376 | - } | |
| 1377 | - }; | |
| 1378 | - for (const target of targets) { | |
| 1379 | - target.addEventListener("click", handleClick); | |
| 1380 | - } | |
| 1842 | + }); | |
| 1381 | 1843 | return () => { |
| 1382 | - isActive = false; | |
| 1383 | - for (const target of targets) { | |
| 1384 | - target.removeEventListener("click", handleClick); | |
| 1844 | + if (clipboardRef.current) { | |
| 1845 | + clipboardRef.current.destroy(); | |
| 1385 | 1846 | } |
| 1386 | 1847 | clearTimeout(timeoutId); |
| 1387 | 1848 | }; |
| 1388 | - }, [ref, text, timeout]); | |
| 1849 | + }, [text, timeout, setHasCopied]); | |
| 1389 | 1850 | return hasCopied; |
| 1390 | 1851 | } |
| 1391 | 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); | |
| 1856 | + function useUpdatedRef(value) { | |
| 1857 | + const ref = (0, import_element8.useRef)(value); | |
| 1858 | + (0, import_element8.useLayoutEffect)(() => { | |
| 1859 | + ref.current = value; | |
| 1860 | + }, [value]); | |
| 1861 | + return ref; | |
| 1862 | + } | |
| 1863 | + function useCopyToClipboard(text, onSuccess) { | |
| 1864 | + const textRef = useUpdatedRef(text); | |
| 1865 | + const onSuccessRef = useUpdatedRef(onSuccess); | |
| 1866 | + return useRefEffect((node) => { | |
| 1867 | + const clipboard = new import_clipboard2.default(node, { | |
| 1868 | + text() { | |
| 1869 | + return typeof textRef.current === "function" ? textRef.current() : textRef.current || ""; | |
| 1870 | + } | |
| 1871 | + }); | |
| 1872 | + clipboard.on("success", ({ clearSelection }) => { | |
| 1873 | + clearSelection(); | |
| 1874 | + if (onSuccessRef.current) { | |
| 1875 | + onSuccessRef.current(); | |
| 1876 | + } | |
| 1877 | + }); | |
| 1878 | + return () => { | |
| 1879 | + clipboard.destroy(); | |
| 1880 | + }; | |
| 1881 | + }, []); | |
| 1882 | + } | |
| 1883 | + | |
| 1392 | 1884 | // packages/compose/build-module/hooks/use-dialog/index.mjs |
| 1393 | 1885 | var import_element13 = __toESM(require_element(), 1); |
| 1886 | + var import_keycodes = __toESM(require_keycodes(), 1); | |
| 1394 | 1887 | |
| 1395 | 1888 | // packages/compose/build-module/hooks/use-focus-on-mount/index.mjs |
| 1396 | 1889 | var import_dom2 = __toESM(require_dom(), 1); |
| 1397 | 1890 | var import_element9 = __toESM(require_element(), 1); |
| @@ -1608,25 +2101,28 @@ | ||
| 1608 | 2101 | } else if (currentOptions.current?.onClose) { |
| 1609 | 2102 | currentOptions.current.onClose(); |
| 1610 | 2103 | } |
| 1611 | 2104 | }); |
| 1612 | - const onKeyDown = (0, import_element13.useCallback)((event) => { | |
| 1613 | - currentOptions.current?.onKeyDown?.(event); | |
| 1614 | - if (event.key === "Escape" && !event.defaultPrevented && currentOptions.current?.onClose) { | |
| 1615 | - event.preventDefault(); | |
| 1616 | - event.stopPropagation(); | |
| 1617 | - currentOptions.current.onClose(); | |
| 2105 | + const closeOnEscapeRef = (0, import_element13.useCallback)((node) => { | |
| 2106 | + if (!node) { | |
| 2107 | + return; | |
| 1618 | 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 | + }); | |
| 1619 | 2115 | }, []); |
| 1620 | 2116 | return [ |
| 1621 | 2117 | useMergeRefs([ |
| 1622 | 2118 | constrainTabbing ? constrainedTabbingRef : null, |
| 1623 | 2119 | options.focusOnMount !== false ? focusReturnRef : null, |
| 1624 | - options.focusOnMount !== false ? focusOnMountRef : null | |
| 2120 | + options.focusOnMount !== false ? focusOnMountRef : null, | |
| 2121 | + closeOnEscapeRef | |
| 1625 | 2122 | ]), |
| 1626 | 2123 | { |
| 1627 | 2124 | ...focusOutsideProps, |
| 1628 | - onKeyDown, | |
| 1629 | 2125 | tabIndex: -1 |
| 1630 | 2126 | } |
| 1631 | 2127 | ]; |
| 1632 | 2128 | } |
| @@ -1787,9 +2283,9 @@ | ||
| 1787 | 2283 | })(typeof Mousetrap !== "undefined" ? Mousetrap : void 0); |
| 1788 | 2284 | |
| 1789 | 2285 | // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs |
| 1790 | 2286 | var import_element17 = __toESM(require_element(), 1); |
| 1791 | - var import_keycodes = __toESM(require_keycodes(), 1); | |
| 2287 | + var import_keycodes2 = __toESM(require_keycodes(), 1); | |
| 1792 | 2288 | function useKeyboardShortcut(shortcuts, callback, { |
| 1793 | 2289 | bindGlobal = false, |
| 1794 | 2290 | eventName = "keydown", |
| 1795 | 2291 | isDisabled = false, |
| @@ -1821,9 +2317,9 @@ | ||
| 1821 | 2317 | keys.filter((value) => value.length > 1) |
| 1822 | 2318 | ); |
| 1823 | 2319 | const hasAlt = modifiers.has("alt"); |
| 1824 | 2320 | const hasShift = modifiers.has("shift"); |
| 1825 | - 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)) { | |
| 1826 | 2322 | throw new Error( |
| 1827 | 2323 | `Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.` |
| 1828 | 2324 | ); |
| 1829 | 2325 | } |
| @@ -1842,56 +2338,47 @@ | ||
| 1842 | 2338 | var use_keyboard_shortcut_default = useKeyboardShortcut; |
| 1843 | 2339 | |
| 1844 | 2340 | // packages/compose/build-module/hooks/use-media-query/index.mjs |
| 1845 | 2341 | var import_element18 = __toESM(require_element(), 1); |
| 1846 | - var perWindowCache = /* @__PURE__ */ new WeakMap(); | |
| 1847 | - var EMPTY_SUBSCRIBER = { | |
| 1848 | - subscribe: () => () => { | |
| 1849 | - }, | |
| 1850 | - getValue: () => false | |
| 1851 | - }; | |
| 1852 | - function getMQLSubscriber(view, query) { | |
| 1853 | - if (!query || typeof view?.matchMedia !== "function") { | |
| 1854 | - return EMPTY_SUBSCRIBER; | |
| 2342 | + var matchMediaCache = /* @__PURE__ */ new Map(); | |
| 2343 | + function getMediaQueryList(query) { | |
| 2344 | + if (!query) { | |
| 2345 | + return null; | |
| 1855 | 2346 | } |
| 1856 | - let queryCache = perWindowCache.get(view); | |
| 1857 | - if (!queryCache) { | |
| 1858 | - queryCache = /* @__PURE__ */ new Map(); | |
| 1859 | - perWindowCache.set(view, queryCache); | |
| 2347 | + let match = matchMediaCache.get(query); | |
| 2348 | + if (match) { | |
| 2349 | + return match; | |
| 1860 | 2350 | } |
| 1861 | - const cached = queryCache.get(query); | |
| 1862 | - if (cached) { | |
| 1863 | - return cached; | |
| 2351 | + if (typeof window !== "undefined" && typeof window.matchMedia === "function") { | |
| 2352 | + match = window.matchMedia(query); | |
| 2353 | + matchMediaCache.set(query, match); | |
| 2354 | + return match; | |
| 1864 | 2355 | } |
| 1865 | - const mediaQueryList = view.matchMedia(query); | |
| 1866 | - const listeners = /* @__PURE__ */ new Set(); | |
| 1867 | - const notify = () => { | |
| 1868 | - for (const listener2 of listeners) { | |
| 1869 | - listener2(); | |
| 1870 | - } | |
| 1871 | - }; | |
| 1872 | - const subscriber = { | |
| 1873 | - subscribe(onStoreChange) { | |
| 1874 | - if (listeners.size === 0) { | |
| 1875 | - 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; | |
| 1876 | 2378 | } |
| 1877 | - listeners.add(onStoreChange); | |
| 1878 | - return () => { | |
| 1879 | - listeners.delete(onStoreChange); | |
| 1880 | - if (listeners.size === 0) { | |
| 1881 | - mediaQueryList.removeEventListener?.("change", notify); | |
| 1882 | - } | |
| 1883 | - }; | |
| 1884 | - }, | |
| 1885 | - getValue() { | |
| 1886 | - return mediaQueryList.matches; | |
| 1887 | - } | |
| 1888 | - }; | |
| 1889 | - queryCache.set(query, subscriber); | |
| 1890 | - return subscriber; | |
| 1891 | - } | |
| 1892 | - function useMediaQuery(query, view = window) { | |
| 1893 | - const source = getMQLSubscriber(view, query); | |
| 2379 | + }; | |
| 2380 | + }, [query]); | |
| 1894 | 2381 | return (0, import_element18.useSyncExternalStore)( |
| 1895 | 2382 | source.subscribe, |
| 1896 | 2383 | source.getValue, |
| 1897 | 2384 | () => false |
| @@ -2013,12 +2500,12 @@ | ||
| 2013 | 2500 | /** @type {null | number} */ |
| 2014 | 2501 | null |
| 2015 | 2502 | ); |
| 2016 | 2503 | ViewportMatchWidthContext.displayName = "ViewportMatchWidthContext"; |
| 2017 | - var useViewportMatch = (breakpoint, operator = ">=", view = window) => { | |
| 2504 | + var useViewportMatch = (breakpoint, operator = ">=") => { | |
| 2018 | 2505 | const simulatedWidth = (0, import_element21.useContext)(ViewportMatchWidthContext); |
| 2019 | 2506 | const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`; |
| 2020 | - const mediaQueryResult = useMediaQuery(mediaQuery || void 0, view); | |
| 2507 | + const mediaQueryResult = useMediaQuery(mediaQuery || void 0); | |
| 2021 | 2508 | if (simulatedWidth) { |
| 2022 | 2509 | return OPERATOR_EVALUATORS[operator]( |
| 2023 | 2510 | BREAKPOINTS[breakpoint], |
| 2024 | 2511 | simulatedWidth |
| @@ -2392,9 +2879,9 @@ | ||
| 2392 | 2879 | |
| 2393 | 2880 | // packages/compose/build-module/hooks/use-fixed-window-list/index.mjs |
| 2394 | 2881 | var import_element28 = __toESM(require_element(), 1); |
| 2395 | 2882 | var import_dom3 = __toESM(require_dom(), 1); |
| 2396 | - var import_keycodes2 = __toESM(require_keycodes(), 1); | |
| 2883 | + var import_keycodes3 = __toESM(require_keycodes(), 1); | |
| 2397 | 2884 | var DEFAULT_INIT_WINDOW_SIZE = 30; |
| 2398 | 2885 | function useFixedWindowList(elementRef, itemHeight, totalItems, options) { |
| 2399 | 2886 | const initWindowSize = options?.initWindowSize ?? DEFAULT_INIT_WINDOW_SIZE; |
| 2400 | 2887 | const useWindowing = options?.useWindowing ?? true; |
| @@ -2479,22 +2966,22 @@ | ||
| 2479 | 2966 | } |
| 2480 | 2967 | const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current); |
| 2481 | 2968 | const handleKeyDown = (event) => { |
| 2482 | 2969 | switch (event.keyCode) { |
| 2483 | - case import_keycodes2.HOME: { | |
| 2970 | + case import_keycodes3.HOME: { | |
| 2484 | 2971 | return scrollContainer?.scrollTo({ top: 0 }); |
| 2485 | 2972 | } |
| 2486 | - case import_keycodes2.END: { | |
| 2973 | + case import_keycodes3.END: { | |
| 2487 | 2974 | return scrollContainer?.scrollTo({ |
| 2488 | 2975 | top: totalItems * itemHeight |
| 2489 | 2976 | }); |
| 2490 | 2977 | } |
| 2491 | - case import_keycodes2.PAGEUP: { | |
| 2978 | + case import_keycodes3.PAGEUP: { | |
| 2492 | 2979 | return scrollContainer?.scrollTo({ |
| 2493 | 2980 | top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight |
| 2494 | 2981 | }); |
| 2495 | 2982 | } |
| 2496 | - case import_keycodes2.PAGEDOWN: { | |
| 2983 | + case import_keycodes3.PAGEDOWN: { | |
| 2497 | 2984 | return scrollContainer?.scrollTo({ |
| 2498 | 2985 | top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight |
| 2499 | 2986 | }); |
| 2500 | 2987 | } |
| @@ -2534,5 +3021,15 @@ | ||
| 2534 | 3021 | return (0, import_element29.useSyncExternalStore)(subscribe, getValue, getValue); |
| 2535 | 3022 | } |
| 2536 | 3023 | return __toCommonJS(index_exports); |
| 2537 | 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 | +*/ | |
| 2538 | 3035 | //# sourceMappingURL=index.js.map |