PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/scripts/compose/index.js +724 -130 23.2.222.7.0 View file →
@@ -66,8 +66,661 @@
66 66 module.exports = window.wp.dom;
67 67 }
68 68 });
69 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 +
70 723 // package-external:@wordpress/keycodes
71 724 var require_keycodes = __commonJS({
72 725 "package-external:@wordpress/keycodes"(exports, module) {
73 726 module.exports = window.wp.keycodes;
@@ -1157,51 +1810,53 @@
1157 1810 }
1158 1811 var use_constrained_tabbing_default = useConstrainedTabbing;
1159 1812
1160 1813 // packages/compose/build-module/hooks/use-copy-on-click/index.mjs
1161 - var import_element8 = __toESM(require_element(), 1);
1814 + var import_clipboard = __toESM(require_clipboard(), 1);
1815 + var import_element7 = __toESM(require_element(), 1);
1162 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;
1828 + }
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;
1851 + }
1163 1852
1164 1853 // packages/compose/build-module/hooks/use-copy-to-clipboard/index.mjs
1165 - var import_element7 = __toESM(require_element(), 1);
1166 - async function copyToClipboard(text, trigger) {
1167 - if (!trigger) {
1168 - return false;
1169 - }
1170 - const { ownerDocument } = trigger;
1171 - if (!ownerDocument) {
1172 - return false;
1173 - }
1174 - const { defaultView } = ownerDocument;
1175 - try {
1176 - if (defaultView?.navigator?.clipboard?.writeText) {
1177 - await defaultView.navigator.clipboard.writeText(text);
1178 - return true;
1179 - }
1180 - const textarea = ownerDocument.createElement("textarea");
1181 - textarea.value = text;
1182 - textarea.setAttribute("readonly", "");
1183 - textarea.style.position = "fixed";
1184 - textarea.style.left = "-9999px";
1185 - textarea.style.top = "-9999px";
1186 - ownerDocument.body.appendChild(textarea);
1187 - textarea.select();
1188 - const success = ownerDocument.execCommand("copy");
1189 - textarea.remove();
1190 - return success;
1191 - } catch {
1192 - return false;
1193 - }
1194 - }
1195 - function clearSelection(trigger) {
1196 - if ("focus" in trigger && typeof trigger.focus === "function") {
1197 - trigger.focus();
1198 - }
1199 - trigger.ownerDocument?.defaultView?.getSelection()?.removeAllRanges();
1200 - }
1854 + var import_clipboard2 = __toESM(require_clipboard(), 1);
1855 + var import_element8 = __toESM(require_element(), 1);
1201 1856 function useUpdatedRef(value) {
1202 - const ref = (0, import_element7.useRef)(value);
1203 - (0, import_element7.useLayoutEffect)(() => {
1857 + const ref = (0, import_element8.useRef)(value);
1858 + (0, import_element8.useLayoutEffect)(() => {
1204 1859 ref.current = value;
1205 1860 }, [value]);
1206 1861 return ref;
1207 1862 }
@@ -1208,92 +1863,25 @@
1208 1863 function useCopyToClipboard(text, onSuccess) {
1209 1864 const textRef = useUpdatedRef(text);
1210 1865 const onSuccessRef = useUpdatedRef(onSuccess);
1211 1866 return useRefEffect((node) => {
1212 - let isActive = true;
1213 - const handleClick = async () => {
1214 - const textToCopy = typeof textRef.current === "function" ? textRef.current() : textRef.current || "";
1215 - const success = await copyToClipboard(textToCopy, node);
1216 - if (!isActive) {
1217 - return;
1867 + const clipboard = new import_clipboard2.default(node, {
1868 + text() {
1869 + return typeof textRef.current === "function" ? textRef.current() : textRef.current || "";
1218 1870 }
1219 - if (success) {
1220 - clearSelection(node);
1221 - if (onSuccessRef.current) {
1222 - onSuccessRef.current();
1223 - }
1871 + });
1872 + clipboard.on("success", ({ clearSelection }) => {
1873 + clearSelection();
1874 + if (onSuccessRef.current) {
1875 + onSuccessRef.current();
1224 1876 }
1225 - };
1226 - node.addEventListener("click", handleClick);
1877 + });
1227 1878 return () => {
1228 - isActive = false;
1229 - node.removeEventListener("click", handleClick);
1879 + clipboard.destroy();
1230 1880 };
1231 1881 }, []);
1232 1882 }
1233 1883
1234 - // packages/compose/build-module/hooks/use-copy-on-click/index.mjs
1235 - function useCopyOnClick(ref, text, timeout = 4e3) {
1236 - (0, import_deprecated3.default)("wp.compose.useCopyOnClick", {
1237 - since: "5.8",
1238 - alternative: "wp.compose.useCopyToClipboard"
1239 - });
1240 - const [hasCopied, setHasCopied] = (0, import_element8.useState)(false);
1241 - (0, import_element8.useEffect)(() => {
1242 - let isActive = true;
1243 - let timeoutId;
1244 - if (!ref.current) {
1245 - return;
1246 - }
1247 - let targets;
1248 - if (typeof ref.current === "string") {
1249 - targets = typeof document !== "undefined" ? Array.from(document.querySelectorAll(ref.current)) : [];
1250 - } else if ("length" in ref.current && typeof ref.current.length === "number") {
1251 - targets = Array.from(ref.current);
1252 - } else {
1253 - targets = [ref.current];
1254 - }
1255 - if (targets.length === 0) {
1256 - return;
1257 - }
1258 - const handleClick = async (event) => {
1259 - const trigger = event.currentTarget;
1260 - if (!trigger) {
1261 - return;
1262 - }
1263 - const success = await copyToClipboard(
1264 - typeof text === "function" ? text() : text || "",
1265 - trigger
1266 - );
1267 - if (!isActive) {
1268 - return;
1269 - }
1270 - if (success) {
1271 - clearSelection(trigger);
1272 - if (timeout) {
1273 - setHasCopied(true);
1274 - clearTimeout(timeoutId);
1275 - timeoutId = setTimeout(
1276 - () => setHasCopied(false),
1277 - timeout
1278 - );
1279 - }
1280 - }
1281 - };
1282 - for (const target of targets) {
1283 - target.addEventListener("click", handleClick);
1284 - }
1285 - return () => {
1286 - isActive = false;
1287 - for (const target of targets) {
1288 - target.removeEventListener("click", handleClick);
1289 - }
1290 - clearTimeout(timeoutId);
1291 - };
1292 - }, [ref, text, timeout]);
1293 - return hasCopied;
1294 - }
1295 -
1296 1884 // packages/compose/build-module/hooks/use-dialog/index.mjs
1297 1885 var import_element13 = __toESM(require_element(), 1);
1298 1886 var import_keycodes = __toESM(require_keycodes(), 1);
1299 1887
@@ -1520,9 +2108,8 @@
1520 2108 }
1521 2109 node.addEventListener("keydown", (event) => {
1522 2110 if (event.keyCode === import_keycodes.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) {
1523 2111 event.preventDefault();
1524 - event.stopPropagation();
1525 2112 currentOptions.current.onClose();
1526 2113 }
1527 2114 });
1528 2115 }, []);
@@ -1751,32 +2338,29 @@
1751 2338 var use_keyboard_shortcut_default = useKeyboardShortcut;
1752 2339
1753 2340 // packages/compose/build-module/hooks/use-media-query/index.mjs
1754 2341 var import_element18 = __toESM(require_element(), 1);
1755 - var perWindowCache = /* @__PURE__ */ new WeakMap();
1756 - function getMediaQueryList(view, query) {
2342 + var matchMediaCache = /* @__PURE__ */ new Map();
2343 + function getMediaQueryList(query) {
1757 2344 if (!query) {
1758 2345 return null;
1759 2346 }
1760 - const matchMediaCache = perWindowCache.get(view) ?? /* @__PURE__ */ new Map();
1761 - if (!perWindowCache.has(view)) {
1762 - perWindowCache.set(view, matchMediaCache);
1763 - }
1764 2347 let match = matchMediaCache.get(query);
1765 2348 if (match) {
1766 2349 return match;
1767 2350 }
1768 - if (typeof view?.matchMedia === "function") {
1769 - match = view.matchMedia(query);
2351 + if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
2352 + match = window.matchMedia(query);
1770 2353 matchMediaCache.set(query, match);
1771 2354 return match;
1772 2355 }
1773 2356 return null;
1774 2357 }
1775 - function useMediaQuery(query, view = window) {
2358 + function useMediaQuery(query) {
1776 2359 const source = (0, import_element18.useMemo)(() => {
1777 - const mediaQueryList = getMediaQueryList(view, query);
2360 + const mediaQueryList = getMediaQueryList(query);
1778 2361 return {
2362 + /** @type {(onStoreChange: () => void) => () => void} */
1779 2363 subscribe(onStoreChange) {
1780 2364 if (!mediaQueryList) {
1781 2365 return () => {
1782 2366 };
@@ -1792,9 +2376,9 @@
1792 2376 getValue() {
1793 2377 return mediaQueryList?.matches ?? false;
1794 2378 }
1795 2379 };
1796 - }, [view, query]);
2380 + }, [query]);
1797 2381 return (0, import_element18.useSyncExternalStore)(
1798 2382 source.subscribe,
1799 2383 source.getValue,
1800 2384 () => false
@@ -1916,12 +2500,12 @@
1916 2500 /** @type {null | number} */
1917 2501 null
1918 2502 );
1919 2503 ViewportMatchWidthContext.displayName = "ViewportMatchWidthContext";
1920 - var useViewportMatch = (breakpoint, operator = ">=", view = window) => {
2504 + var useViewportMatch = (breakpoint, operator = ">=") => {
1921 2505 const simulatedWidth = (0, import_element21.useContext)(ViewportMatchWidthContext);
1922 2506 const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`;
1923 - const mediaQueryResult = useMediaQuery(mediaQuery || void 0, view);
2507 + const mediaQueryResult = useMediaQuery(mediaQuery || void 0);
1924 2508 if (simulatedWidth) {
1925 2509 return OPERATOR_EVALUATORS[operator](
1926 2510 BREAKPOINTS[breakpoint],
1927 2511 simulatedWidth
@@ -2437,5 +3021,15 @@
2437 3021 return (0, import_element29.useSyncExternalStore)(subscribe, getValue, getValue);
2438 3022 }
2439 3023 return __toCommonJS(index_exports);
2440 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 +*/
2441 3035 //# sourceMappingURL=index.js.map