PluginProbe
Gutenberg / 14.7.0
Gutenberg v14.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
gutenberg / build / edit-site / index.js

index.js in Gutenberg 14.7.0, at build/edit-site/index.js

16,205 lines 586.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ 6411:
5 /***/ (function(module, exports) {
6
7 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
8 autosize 4.0.2
9 license: MIT
10 http://www.jacklmoore.com/autosize
11 */
12 (function (global, factory) {
13 if (true) {
14 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
15 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
16 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
17 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
18 } else { var mod; }
19 })(this, function (module, exports) {
20 'use strict';
21
22 var map = typeof Map === "function" ? new Map() : function () {
23 var keys = [];
24 var values = [];
25
26 return {
27 has: function has(key) {
28 return keys.indexOf(key) > -1;
29 },
30 get: function get(key) {
31 return values[keys.indexOf(key)];
32 },
33 set: function set(key, value) {
34 if (keys.indexOf(key) === -1) {
35 keys.push(key);
36 values.push(value);
37 }
38 },
39 delete: function _delete(key) {
40 var index = keys.indexOf(key);
41 if (index > -1) {
42 keys.splice(index, 1);
43 values.splice(index, 1);
44 }
45 }
46 };
47 }();
48
49 var createEvent = function createEvent(name) {
50 return new Event(name, { bubbles: true });
51 };
52 try {
53 new Event('test');
54 } catch (e) {
55 // IE does not support `new Event()`
56 createEvent = function createEvent(name) {
57 var evt = document.createEvent('Event');
58 evt.initEvent(name, true, false);
59 return evt;
60 };
61 }
62
63 function assign(ta) {
64 if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
65
66 var heightOffset = null;
67 var clientWidth = null;
68 var cachedHeight = null;
69
70 function init() {
71 var style = window.getComputedStyle(ta, null);
72
73 if (style.resize === 'vertical') {
74 ta.style.resize = 'none';
75 } else if (style.resize === 'both') {
76 ta.style.resize = 'horizontal';
77 }
78
79 if (style.boxSizing === 'content-box') {
80 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
81 } else {
82 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
83 }
84 // Fix when a textarea is not on document body and heightOffset is Not a Number
85 if (isNaN(heightOffset)) {
86 heightOffset = 0;
87 }
88
89 update();
90 }
91
92 function changeOverflow(value) {
93 {
94 // Chrome/Safari-specific fix:
95 // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
96 // made available by removing the scrollbar. The following forces the necessary text reflow.
97 var width = ta.style.width;
98 ta.style.width = '0px';
99 // Force reflow:
100 /* jshint ignore:start */
101 ta.offsetWidth;
102 /* jshint ignore:end */
103 ta.style.width = width;
104 }
105
106 ta.style.overflowY = value;
107 }
108
109 function getParentOverflows(el) {
110 var arr = [];
111
112 while (el && el.parentNode && el.parentNode instanceof Element) {
113 if (el.parentNode.scrollTop) {
114 arr.push({
115 node: el.parentNode,
116 scrollTop: el.parentNode.scrollTop
117 });
118 }
119 el = el.parentNode;
120 }
121
122 return arr;
123 }
124
125 function resize() {
126 if (ta.scrollHeight === 0) {
127 // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
128 return;
129 }
130
131 var overflows = getParentOverflows(ta);
132 var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
133
134 ta.style.height = '';
135 ta.style.height = ta.scrollHeight + heightOffset + 'px';
136
137 // used to check if an update is actually necessary on window.resize
138 clientWidth = ta.clientWidth;
139
140 // prevents scroll-position jumping
141 overflows.forEach(function (el) {
142 el.node.scrollTop = el.scrollTop;
143 });
144
145 if (docTop) {
146 document.documentElement.scrollTop = docTop;
147 }
148 }
149
150 function update() {
151 resize();
152
153 var styleHeight = Math.round(parseFloat(ta.style.height));
154 var computed = window.getComputedStyle(ta, null);
155
156 // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
157 var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
158
159 // The actual height not matching the style height (set via the resize method) indicates that
160 // the max-height has been exceeded, in which case the overflow should be allowed.
161 if (actualHeight < styleHeight) {
162 if (computed.overflowY === 'hidden') {
163 changeOverflow('scroll');
164 resize();
165 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
166 }
167 } else {
168 // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
169 if (computed.overflowY !== 'hidden') {
170 changeOverflow('hidden');
171 resize();
172 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
173 }
174 }
175
176 if (cachedHeight !== actualHeight) {
177 cachedHeight = actualHeight;
178 var evt = createEvent('autosize:resized');
179 try {
180 ta.dispatchEvent(evt);
181 } catch (err) {
182 // Firefox will throw an error on dispatchEvent for a detached element
183 // https://bugzilla.mozilla.org/show_bug.cgi?id=889376
184 }
185 }
186 }
187
188 var pageResize = function pageResize() {
189 if (ta.clientWidth !== clientWidth) {
190 update();
191 }
192 };
193
194 var destroy = function (style) {
195 window.removeEventListener('resize', pageResize, false);
196 ta.removeEventListener('input', update, false);
197 ta.removeEventListener('keyup', update, false);
198 ta.removeEventListener('autosize:destroy', destroy, false);
199 ta.removeEventListener('autosize:update', update, false);
200
201 Object.keys(style).forEach(function (key) {
202 ta.style[key] = style[key];
203 });
204
205 map.delete(ta);
206 }.bind(ta, {
207 height: ta.style.height,
208 resize: ta.style.resize,
209 overflowY: ta.style.overflowY,
210 overflowX: ta.style.overflowX,
211 wordWrap: ta.style.wordWrap
212 });
213
214 ta.addEventListener('autosize:destroy', destroy, false);
215
216 // IE9 does not fire onpropertychange or oninput for deletions,
217 // so binding to onkeyup to catch most of those events.
218 // There is no way that I know of to detect something like 'cut' in IE9.
219 if ('onpropertychange' in ta && 'oninput' in ta) {
220 ta.addEventListener('keyup', update, false);
221 }
222
223 window.addEventListener('resize', pageResize, false);
224 ta.addEventListener('input', update, false);
225 ta.addEventListener('autosize:update', update, false);
226 ta.style.overflowX = 'hidden';
227 ta.style.wordWrap = 'break-word';
228
229 map.set(ta, {
230 destroy: destroy,
231 update: update
232 });
233
234 init();
235 }
236
237 function destroy(ta) {
238 var methods = map.get(ta);
239 if (methods) {
240 methods.destroy();
241 }
242 }
243
244 function update(ta) {
245 var methods = map.get(ta);
246 if (methods) {
247 methods.update();
248 }
249 }
250
251 var autosize = null;
252
253 // Do nothing in Node.js environment and IE8 (or lower)
254 if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
255 autosize = function autosize(el) {
256 return el;
257 };
258 autosize.destroy = function (el) {
259 return el;
260 };
261 autosize.update = function (el) {
262 return el;
263 };
264 } else {
265 autosize = function autosize(el, options) {
266 if (el) {
267 Array.prototype.forEach.call(el.length ? el : [el], function (x) {
268 return assign(x, options);
269 });
270 }
271 return el;
272 };
273 autosize.destroy = function (el) {
274 if (el) {
275 Array.prototype.forEach.call(el.length ? el : [el], destroy);
276 }
277 return el;
278 };
279 autosize.update = function (el) {
280 if (el) {
281 Array.prototype.forEach.call(el.length ? el : [el], update);
282 }
283 return el;
284 };
285 }
286
287 exports.default = autosize;
288 module.exports = exports['default'];
289 });
290
291 /***/ }),
292
293 /***/ 4403:
294 /***/ (function(module, exports) {
295
296 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
297 Copyright (c) 2018 Jed Watson.
298 Licensed under the MIT License (MIT), see
299 http://jedwatson.github.io/classnames
300 */
301 /* global define */
302
303 (function () {
304 'use strict';
305
306 var hasOwn = {}.hasOwnProperty;
307
308 function classNames() {
309 var classes = [];
310
311 for (var i = 0; i < arguments.length; i++) {
312 var arg = arguments[i];
313 if (!arg) continue;
314
315 var argType = typeof arg;
316
317 if (argType === 'string' || argType === 'number') {
318 classes.push(arg);
319 } else if (Array.isArray(arg)) {
320 if (arg.length) {
321 var inner = classNames.apply(null, arg);
322 if (inner) {
323 classes.push(inner);
324 }
325 }
326 } else if (argType === 'object') {
327 if (arg.toString === Object.prototype.toString) {
328 for (var key in arg) {
329 if (hasOwn.call(arg, key) && arg[key]) {
330 classes.push(key);
331 }
332 }
333 } else {
334 classes.push(arg.toString());
335 }
336 }
337 }
338
339 return classes.join(' ');
340 }
341
342 if ( true && module.exports) {
343 classNames.default = classNames;
344 module.exports = classNames;
345 } else if (true) {
346 // register as 'classnames', consistent with npm package name
347 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
348 return classNames;
349 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
350 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
351 } else {}
352 }());
353
354
355 /***/ }),
356
357 /***/ 4827:
358 /***/ (function(module) {
359
360 // This code has been refactored for 140 bytes
361 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
362 var computedStyle = function (el, prop, getComputedStyle) {
363 getComputedStyle = window.getComputedStyle;
364
365 // In one fell swoop
366 return (
367 // If we have getComputedStyle
368 getComputedStyle ?
369 // Query it
370 // TODO: From CSS-Query notes, we might need (node, null) for FF
371 getComputedStyle(el) :
372
373 // Otherwise, we are in IE and use currentStyle
374 el.currentStyle
375 )[
376 // Switch to camelCase for CSSOM
377 // DEV: Grabbed from jQuery
378 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
379 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
380 prop.replace(/-(\w)/gi, function (word, letter) {
381 return letter.toUpperCase();
382 })
383 ];
384 };
385
386 module.exports = computedStyle;
387
388
389 /***/ }),
390
391 /***/ 8981:
392 /***/ (function(module, exports) {
393
394 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;//download.js v4.2, by dandavis; 2008-2016. [MIT] see http://danml.com/download.html for tests/usage
395 // v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
396 // v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
397 // v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support. 3.1 improved safari handling.
398 // v4 adds AMD/UMD, commonJS, and plain browser support
399 // v4.1 adds url download capability via solo URL argument (same domain/CORS only)
400 // v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors
401 // https://github.com/rndme/download
402
403 (function (root, factory) {
404 if (true) {
405 // AMD. Register as an anonymous module.
406 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
407 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
408 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
409 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
410 } else {}
411 }(this, function () {
412
413 return function download(data, strFileName, strMimeType) {
414
415 var self = window, // this script is only for browsers anyway...
416 defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads
417 mimeType = strMimeType || defaultMime,
418 payload = data,
419 url = !strFileName && !strMimeType && payload,
420 anchor = document.createElement("a"),
421 toString = function(a){return String(a);},
422 myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString),
423 fileName = strFileName || "download",
424 blob,
425 reader;
426 myBlob= myBlob.call ? myBlob.bind(self) : Blob ;
427
428 if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
429 payload=[payload, mimeType];
430 mimeType=payload[0];
431 payload=payload[1];
432 }
433
434
435 if(url && url.length< 2048){ // if no filename and no mime, assume a url was passed as the only argument
436 fileName = url.split("/").pop().split("?")[0];
437 anchor.href = url; // assign href prop to temp anchor
438 if(anchor.href.indexOf(url) !== -1){ // if the browser determines that it's a potentially valid url path:
439 var ajax=new XMLHttpRequest();
440 ajax.open( "GET", url, true);
441 ajax.responseType = 'blob';
442 ajax.onload= function(e){
443 download(e.target.response, fileName, defaultMime);
444 };
445 setTimeout(function(){ ajax.send();}, 0); // allows setting custom ajax headers using the return:
446 return ajax;
447 } // end if valid url?
448 } // end if url?
449
450
451 //go ahead and download dataURLs right away
452 if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)){
453
454 if(payload.length > (1024*1024*1.999) && myBlob !== toString ){
455 payload=dataUrlToBlob(payload);
456 mimeType=payload.type || defaultMime;
457 }else{
458 return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs:
459 navigator.msSaveBlob(dataUrlToBlob(payload), fileName) :
460 saver(payload) ; // everyone else can save dataURLs un-processed
461 }
462
463 }else{//not data url, is it a string with special needs?
464 if(/([\x80-\xff])/.test(payload)){
465 var i=0, tempUiArr= new Uint8Array(payload.length), mx=tempUiArr.length;
466 for(i;i<mx;++i) tempUiArr[i]= payload.charCodeAt(i);
467 payload=new myBlob([tempUiArr], {type: mimeType});
468 }
469 }
470 blob = payload instanceof myBlob ?
471 payload :
472 new myBlob([payload], {type: mimeType}) ;
473
474
475 function dataUrlToBlob(strUrl) {
476 var parts= strUrl.split(/[:;,]/),
477 type= parts[1],
478 decoder= parts[2] == "base64" ? atob : decodeURIComponent,
479 binData= decoder( parts.pop() ),
480 mx= binData.length,
481 i= 0,
482 uiArr= new Uint8Array(mx);
483
484 for(i;i<mx;++i) uiArr[i]= binData.charCodeAt(i);
485
486 return new myBlob([uiArr], {type: type});
487 }
488
489 function saver(url, winMode){
490
491 if ('download' in anchor) { //html5 A[download]
492 anchor.href = url;
493 anchor.setAttribute("download", fileName);
494 anchor.className = "download-js-link";
495 anchor.innerHTML = "downloading...";
496 anchor.style.display = "none";
497 document.body.appendChild(anchor);
498 setTimeout(function() {
499 anchor.click();
500 document.body.removeChild(anchor);
501 if(winMode===true){setTimeout(function(){ self.URL.revokeObjectURL(anchor.href);}, 250 );}
502 }, 66);
503 return true;
504 }
505
506 // handle non-a[download] safari as best we can:
507 if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
508 if(/^data:/.test(url)) url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
509 if(!window.open(url)){ // popup blocked, offer direct download:
510 if(confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")){ location.href=url; }
511 }
512 return true;
513 }
514
515 //do iframe dataURL download (old ch+FF):
516 var f = document.createElement("iframe");
517 document.body.appendChild(f);
518
519 if(!winMode && /^data:/.test(url)){ // force a mime that will download:
520 url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
521 }
522 f.src=url;
523 setTimeout(function(){ document.body.removeChild(f); }, 333);
524
525 }//end saver
526
527
528
529
530 if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL)
531 return navigator.msSaveBlob(blob, fileName);
532 }
533
534 if(self.URL){ // simple fast and modern way using Blob and URL:
535 saver(self.URL.createObjectURL(blob), true);
536 }else{
537 // handle non-Blob()+non-URL browsers:
538 if(typeof blob === "string" || blob.constructor===toString ){
539 try{
540 return saver( "data:" + mimeType + ";base64," + self.btoa(blob) );
541 }catch(y){
542 return saver( "data:" + mimeType + "," + encodeURIComponent(blob) );
543 }
544 }
545
546 // Blob but not URL support:
547 reader=new FileReader();
548 reader.onload=function(e){
549 saver(this.result);
550 };
551 reader.readAsDataURL(blob);
552 }
553 return true;
554 }; /* end download() */
555 }));
556
557
558 /***/ }),
559
560 /***/ 9894:
561 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
562
563 // Load in dependencies
564 var computedStyle = __webpack_require__(4827);
565
566 /**
567 * Calculate the `line-height` of a given node
568 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
569 * @returns {Number} `line-height` of the element in pixels
570 */
571 function lineHeight(node) {
572 // Grab the line-height via style
573 var lnHeightStr = computedStyle(node, 'line-height');
574 var lnHeight = parseFloat(lnHeightStr, 10);
575
576 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
577 if (lnHeightStr === lnHeight + '') {
578 // Save the old lineHeight style and update the em unit to the element
579 var _lnHeightStyle = node.style.lineHeight;
580 node.style.lineHeight = lnHeightStr + 'em';
581
582 // Calculate the em based height
583 lnHeightStr = computedStyle(node, 'line-height');
584 lnHeight = parseFloat(lnHeightStr, 10);
585
586 // Revert the lineHeight style
587 if (_lnHeightStyle) {
588 node.style.lineHeight = _lnHeightStyle;
589 } else {
590 delete node.style.lineHeight;
591 }
592 }
593
594 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
595 // DEV: `em` units are converted to `pt` in IE6
596 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
597 if (lnHeightStr.indexOf('pt') !== -1) {
598 lnHeight *= 4;
599 lnHeight /= 3;
600 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
601 } else if (lnHeightStr.indexOf('mm') !== -1) {
602 lnHeight *= 96;
603 lnHeight /= 25.4;
604 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
605 } else if (lnHeightStr.indexOf('cm') !== -1) {
606 lnHeight *= 96;
607 lnHeight /= 2.54;
608 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
609 } else if (lnHeightStr.indexOf('in') !== -1) {
610 lnHeight *= 96;
611 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
612 } else if (lnHeightStr.indexOf('pc') !== -1) {
613 lnHeight *= 16;
614 }
615
616 // Continue our computation
617 lnHeight = Math.round(lnHeight);
618
619 // If the line-height is "normal", calculate by font-size
620 if (lnHeightStr === 'normal') {
621 // Create a temporary node
622 var nodeName = node.nodeName;
623 var _node = document.createElement(nodeName);
624 _node.innerHTML = '&nbsp;';
625
626 // If we have a text area, reset it to only 1 row
627 // https://github.com/twolfson/line-height/issues/4
628 if (nodeName.toUpperCase() === 'TEXTAREA') {
629 _node.setAttribute('rows', '1');
630 }
631
632 // Set the font-size of the element
633 var fontSizeStr = computedStyle(node, 'font-size');
634 _node.style.fontSize = fontSizeStr;
635
636 // Remove default padding/border which can affect offset height
637 // https://github.com/twolfson/line-height/issues/4
638 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
639 _node.style.padding = '0px';
640 _node.style.border = '0px';
641
642 // Append it to the body
643 var body = document.body;
644 body.appendChild(_node);
645
646 // Assume the line height of the element is the height
647 var height = _node.offsetHeight;
648 lnHeight = height;
649
650 // Remove our child from the DOM
651 body.removeChild(_node);
652 }
653
654 // Return the calculated height
655 return lnHeight;
656 }
657
658 // Export lineHeight
659 module.exports = lineHeight;
660
661
662 /***/ }),
663
664 /***/ 5372:
665 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
666
667 "use strict";
668 /**
669 * Copyright (c) 2013-present, Facebook, Inc.
670 *
671 * This source code is licensed under the MIT license found in the
672 * LICENSE file in the root directory of this source tree.
673 */
674
675
676
677 var ReactPropTypesSecret = __webpack_require__(9567);
678
679 function emptyFunction() {}
680 function emptyFunctionWithReset() {}
681 emptyFunctionWithReset.resetWarningCache = emptyFunction;
682
683 module.exports = function() {
684 function shim(props, propName, componentName, location, propFullName, secret) {
685 if (secret === ReactPropTypesSecret) {
686 // It is still safe when called from React.
687 return;
688 }
689 var err = new Error(
690 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
691 'Use PropTypes.checkPropTypes() to call them. ' +
692 'Read more at http://fb.me/use-check-prop-types'
693 );
694 err.name = 'Invariant Violation';
695 throw err;
696 };
697 shim.isRequired = shim;
698 function getShim() {
699 return shim;
700 };
701 // Important!
702 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
703 var ReactPropTypes = {
704 array: shim,
705 bool: shim,
706 func: shim,
707 number: shim,
708 object: shim,
709 string: shim,
710 symbol: shim,
711
712 any: shim,
713 arrayOf: getShim,
714 element: shim,
715 elementType: shim,
716 instanceOf: getShim,
717 node: shim,
718 objectOf: getShim,
719 oneOf: getShim,
720 oneOfType: getShim,
721 shape: getShim,
722 exact: getShim,
723
724 checkPropTypes: emptyFunctionWithReset,
725 resetWarningCache: emptyFunction
726 };
727
728 ReactPropTypes.PropTypes = ReactPropTypes;
729
730 return ReactPropTypes;
731 };
732
733
734 /***/ }),
735
736 /***/ 2652:
737 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
738
739 /**
740 * Copyright (c) 2013-present, Facebook, Inc.
741 *
742 * This source code is licensed under the MIT license found in the
743 * LICENSE file in the root directory of this source tree.
744 */
745
746 if (false) { var throwOnDirectAccess, ReactIs; } else {
747 // By explicitly using `prop-types` you are opting into new production behavior.
748 // http://fb.me/prop-types-in-prod
749 module.exports = __webpack_require__(5372)();
750 }
751
752
753 /***/ }),
754
755 /***/ 9567:
756 /***/ (function(module) {
757
758 "use strict";
759 /**
760 * Copyright (c) 2013-present, Facebook, Inc.
761 *
762 * This source code is licensed under the MIT license found in the
763 * LICENSE file in the root directory of this source tree.
764 */
765
766
767
768 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
769
770 module.exports = ReactPropTypesSecret;
771
772
773 /***/ }),
774
775 /***/ 5438:
776 /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
777
778 "use strict";
779
780 var __extends = (this && this.__extends) || (function () {
781 var extendStatics = Object.setPrototypeOf ||
782 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
783 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
784 return function (d, b) {
785 extendStatics(d, b);
786 function __() { this.constructor = d; }
787 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
788 };
789 })();
790 var __assign = (this && this.__assign) || Object.assign || function(t) {
791 for (var s, i = 1, n = arguments.length; i < n; i++) {
792 s = arguments[i];
793 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
794 t[p] = s[p];
795 }
796 return t;
797 };
798 var __rest = (this && this.__rest) || function (s, e) {
799 var t = {};
800 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
801 t[p] = s[p];
802 if (s != null && typeof Object.getOwnPropertySymbols === "function")
803 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
804 t[p[i]] = s[p[i]];
805 return t;
806 };
807 exports.__esModule = true;
808 var React = __webpack_require__(9196);
809 var PropTypes = __webpack_require__(2652);
810 var autosize = __webpack_require__(6411);
811 var _getLineHeight = __webpack_require__(9894);
812 var getLineHeight = _getLineHeight;
813 var RESIZED = "autosize:resized";
814 /**
815 * A light replacement for built-in textarea component
816 * which automaticaly adjusts its height to match the content
817 */
818 var TextareaAutosizeClass = /** @class */ (function (_super) {
819 __extends(TextareaAutosizeClass, _super);
820 function TextareaAutosizeClass() {
821 var _this = _super !== null && _super.apply(this, arguments) || this;
822 _this.state = {
823 lineHeight: null
824 };
825 _this.textarea = null;
826 _this.onResize = function (e) {
827 if (_this.props.onResize) {
828 _this.props.onResize(e);
829 }
830 };
831 _this.updateLineHeight = function () {
832 if (_this.textarea) {
833 _this.setState({
834 lineHeight: getLineHeight(_this.textarea)
835 });
836 }
837 };
838 _this.onChange = function (e) {
839 var onChange = _this.props.onChange;
840 _this.currentValue = e.currentTarget.value;
841 onChange && onChange(e);
842 };
843 return _this;
844 }
845 TextareaAutosizeClass.prototype.componentDidMount = function () {
846 var _this = this;
847 var _a = this.props, maxRows = _a.maxRows, async = _a.async;
848 if (typeof maxRows === "number") {
849 this.updateLineHeight();
850 }
851 if (typeof maxRows === "number" || async) {
852 /*
853 the defer is needed to:
854 - force "autosize" to activate the scrollbar when this.props.maxRows is passed
855 - support StyledComponents (see #71)
856 */
857 setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
858 }
859 else {
860 this.textarea && autosize(this.textarea);
861 }
862 if (this.textarea) {
863 this.textarea.addEventListener(RESIZED, this.onResize);
864 }
865 };
866 TextareaAutosizeClass.prototype.componentWillUnmount = function () {
867 if (this.textarea) {
868 this.textarea.removeEventListener(RESIZED, this.onResize);
869 autosize.destroy(this.textarea);
870 }
871 };
872 TextareaAutosizeClass.prototype.render = function () {
873 var _this = this;
874 var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
875 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
876 return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
877 _this.textarea = element;
878 if (typeof _this.props.innerRef === 'function') {
879 _this.props.innerRef(element);
880 }
881 else if (_this.props.innerRef) {
882 _this.props.innerRef.current = element;
883 }
884 } }), children));
885 };
886 TextareaAutosizeClass.prototype.componentDidUpdate = function () {
887 this.textarea && autosize.update(this.textarea);
888 };
889 TextareaAutosizeClass.defaultProps = {
890 rows: 1,
891 async: false
892 };
893 TextareaAutosizeClass.propTypes = {
894 rows: PropTypes.number,
895 maxRows: PropTypes.number,
896 onResize: PropTypes.func,
897 innerRef: PropTypes.any,
898 async: PropTypes.bool
899 };
900 return TextareaAutosizeClass;
901 }(React.Component));
902 exports.TextareaAutosize = React.forwardRef(function (props, ref) {
903 return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
904 });
905
906
907 /***/ }),
908
909 /***/ 773:
910 /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
911
912 "use strict";
913 var __webpack_unused_export__;
914
915 __webpack_unused_export__ = true;
916 var TextareaAutosize_1 = __webpack_require__(5438);
917 exports.Z = TextareaAutosize_1.TextareaAutosize;
918
919
920 /***/ }),
921
922 /***/ 9196:
923 /***/ (function(module) {
924
925 "use strict";
926 module.exports = window["React"];
927
928 /***/ })
929
930 /******/ });
931 /************************************************************************/
932 /******/ // The module cache
933 /******/ var __webpack_module_cache__ = {};
934 /******/
935 /******/ // The require function
936 /******/ function __webpack_require__(moduleId) {
937 /******/ // Check if module is in cache
938 /******/ var cachedModule = __webpack_module_cache__[moduleId];
939 /******/ if (cachedModule !== undefined) {
940 /******/ return cachedModule.exports;
941 /******/ }
942 /******/ // Create a new module (and put it into the cache)
943 /******/ var module = __webpack_module_cache__[moduleId] = {
944 /******/ // no module.id needed
945 /******/ // no module.loaded needed
946 /******/ exports: {}
947 /******/ };
948 /******/
949 /******/ // Execute the module function
950 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
951 /******/
952 /******/ // Return the exports of the module
953 /******/ return module.exports;
954 /******/ }
955 /******/
956 /************************************************************************/
957 /******/ /* webpack/runtime/compat get default export */
958 /******/ !function() {
959 /******/ // getDefaultExport function for compatibility with non-harmony modules
960 /******/ __webpack_require__.n = function(module) {
961 /******/ var getter = module && module.__esModule ?
962 /******/ function() { return module['default']; } :
963 /******/ function() { return module; };
964 /******/ __webpack_require__.d(getter, { a: getter });
965 /******/ return getter;
966 /******/ };
967 /******/ }();
968 /******/
969 /******/ /* webpack/runtime/define property getters */
970 /******/ !function() {
971 /******/ // define getter functions for harmony exports
972 /******/ __webpack_require__.d = function(exports, definition) {
973 /******/ for(var key in definition) {
974 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
975 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
976 /******/ }
977 /******/ }
978 /******/ };
979 /******/ }();
980 /******/
981 /******/ /* webpack/runtime/hasOwnProperty shorthand */
982 /******/ !function() {
983 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
984 /******/ }();
985 /******/
986 /******/ /* webpack/runtime/make namespace object */
987 /******/ !function() {
988 /******/ // define __esModule on exports
989 /******/ __webpack_require__.r = function(exports) {
990 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
991 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
992 /******/ }
993 /******/ Object.defineProperty(exports, '__esModule', { value: true });
994 /******/ };
995 /******/ }();
996 /******/
997 /************************************************************************/
998 var __webpack_exports__ = {};
999 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
1000 !function() {
1001 "use strict";
1002 // ESM COMPAT FLAG
1003 __webpack_require__.r(__webpack_exports__);
1004
1005 // EXPORTS
1006 __webpack_require__.d(__webpack_exports__, {
1007 "PluginMoreMenuItem": function() { return /* reexport */ plugin_more_menu_item; },
1008 "PluginSidebar": function() { return /* reexport */ PluginSidebarEditSite; },
1009 "PluginSidebarMoreMenuItem": function() { return /* reexport */ PluginSidebarMoreMenuItem; },
1010 "__experimentalNavigationToggle": function() { return /* reexport */ navigation_toggle; },
1011 "initializeEditor": function() { return /* binding */ initializeEditor; },
1012 "reinitializeEditor": function() { return /* binding */ reinitializeEditor; }
1013 });
1014
1015 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
1016 var actions_namespaceObject = {};
1017 __webpack_require__.r(actions_namespaceObject);
1018 __webpack_require__.d(actions_namespaceObject, {
1019 "disableComplementaryArea": function() { return disableComplementaryArea; },
1020 "enableComplementaryArea": function() { return enableComplementaryArea; },
1021 "pinItem": function() { return pinItem; },
1022 "setDefaultComplementaryArea": function() { return setDefaultComplementaryArea; },
1023 "setFeatureDefaults": function() { return setFeatureDefaults; },
1024 "setFeatureValue": function() { return setFeatureValue; },
1025 "toggleFeature": function() { return toggleFeature; },
1026 "unpinItem": function() { return unpinItem; }
1027 });
1028
1029 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
1030 var selectors_namespaceObject = {};
1031 __webpack_require__.r(selectors_namespaceObject);
1032 __webpack_require__.d(selectors_namespaceObject, {
1033 "getActiveComplementaryArea": function() { return getActiveComplementaryArea; },
1034 "isFeatureActive": function() { return isFeatureActive; },
1035 "isItemPinned": function() { return isItemPinned; }
1036 });
1037
1038 // NAMESPACE OBJECT: ./packages/edit-site/build-module/store/actions.js
1039 var store_actions_namespaceObject = {};
1040 __webpack_require__.r(store_actions_namespaceObject);
1041 __webpack_require__.d(store_actions_namespaceObject, {
1042 "__experimentalSetPreviewDeviceType": function() { return __experimentalSetPreviewDeviceType; },
1043 "addTemplate": function() { return addTemplate; },
1044 "closeGeneralSidebar": function() { return closeGeneralSidebar; },
1045 "openGeneralSidebar": function() { return openGeneralSidebar; },
1046 "openNavigationPanelToMenu": function() { return openNavigationPanelToMenu; },
1047 "removeTemplate": function() { return removeTemplate; },
1048 "revertTemplate": function() { return revertTemplate; },
1049 "setHomeTemplateId": function() { return setHomeTemplateId; },
1050 "setIsInserterOpened": function() { return setIsInserterOpened; },
1051 "setIsListViewOpened": function() { return setIsListViewOpened; },
1052 "setIsNavigationPanelOpened": function() { return setIsNavigationPanelOpened; },
1053 "setIsSaveViewOpened": function() { return setIsSaveViewOpened; },
1054 "setNavigationPanelActiveMenu": function() { return setNavigationPanelActiveMenu; },
1055 "setPage": function() { return setPage; },
1056 "setTemplate": function() { return setTemplate; },
1057 "setTemplatePart": function() { return setTemplatePart; },
1058 "switchEditorMode": function() { return switchEditorMode; },
1059 "toggleFeature": function() { return actions_toggleFeature; },
1060 "updateSettings": function() { return updateSettings; }
1061 });
1062
1063 // NAMESPACE OBJECT: ./packages/edit-site/build-module/store/selectors.js
1064 var store_selectors_namespaceObject = {};
1065 __webpack_require__.r(store_selectors_namespaceObject);
1066 __webpack_require__.d(store_selectors_namespaceObject, {
1067 "__experimentalGetInsertionPoint": function() { return __experimentalGetInsertionPoint; },
1068 "__experimentalGetPreviewDeviceType": function() { return __experimentalGetPreviewDeviceType; },
1069 "__unstableGetPreference": function() { return __unstableGetPreference; },
1070 "getCanUserCreateMedia": function() { return getCanUserCreateMedia; },
1071 "getCurrentTemplateNavigationPanelSubMenu": function() { return getCurrentTemplateNavigationPanelSubMenu; },
1072 "getCurrentTemplateTemplateParts": function() { return getCurrentTemplateTemplateParts; },
1073 "getEditedPostId": function() { return getEditedPostId; },
1074 "getEditedPostType": function() { return getEditedPostType; },
1075 "getEditorMode": function() { return getEditorMode; },
1076 "getHomeTemplateId": function() { return getHomeTemplateId; },
1077 "getNavigationPanelActiveMenu": function() { return getNavigationPanelActiveMenu; },
1078 "getPage": function() { return getPage; },
1079 "getReusableBlocks": function() { return getReusableBlocks; },
1080 "getSettings": function() { return getSettings; },
1081 "isFeatureActive": function() { return selectors_isFeatureActive; },
1082 "isInserterOpened": function() { return isInserterOpened; },
1083 "isListViewOpened": function() { return isListViewOpened; },
1084 "isNavigationOpened": function() { return isNavigationOpened; },
1085 "isSaveViewOpened": function() { return isSaveViewOpened; }
1086 });
1087
1088 ;// CONCATENATED MODULE: external ["wp","element"]
1089 var external_wp_element_namespaceObject = window["wp"]["element"];
1090 ;// CONCATENATED MODULE: external ["wp","blocks"]
1091 var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
1092 ;// CONCATENATED MODULE: external ["wp","blockLibrary"]
1093 var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
1094 ;// CONCATENATED MODULE: external ["wp","data"]
1095 var external_wp_data_namespaceObject = window["wp"]["data"];
1096 ;// CONCATENATED MODULE: external ["wp","coreData"]
1097 var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1098 ;// CONCATENATED MODULE: external ["wp","editor"]
1099 var external_wp_editor_namespaceObject = window["wp"]["editor"];
1100 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
1101 function extends_extends() {
1102 extends_extends = Object.assign || function (target) {
1103 for (var i = 1; i < arguments.length; i++) {
1104 var source = arguments[i];
1105
1106 for (var key in source) {
1107 if (Object.prototype.hasOwnProperty.call(source, key)) {
1108 target[key] = source[key];
1109 }
1110 }
1111 }
1112
1113 return target;
1114 };
1115
1116 return extends_extends.apply(this, arguments);
1117 }
1118 // EXTERNAL MODULE: ./node_modules/classnames/index.js
1119 var classnames = __webpack_require__(4403);
1120 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
1121 ;// CONCATENATED MODULE: external ["wp","components"]
1122 var external_wp_components_namespaceObject = window["wp"]["components"];
1123 ;// CONCATENATED MODULE: external ["wp","i18n"]
1124 var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
1125 ;// CONCATENATED MODULE: external ["wp","primitives"]
1126 var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
1127 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
1128
1129
1130 /**
1131 * WordPress dependencies
1132 */
1133
1134 const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1135 xmlns: "http://www.w3.org/2000/svg",
1136 viewBox: "0 0 24 24"
1137 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1138 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
1139 }));
1140 /* harmony default export */ var library_check = (check);
1141
1142 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
1143
1144
1145 /**
1146 * WordPress dependencies
1147 */
1148
1149 const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1150 xmlns: "http://www.w3.org/2000/svg",
1151 viewBox: "0 0 24 24"
1152 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1153 d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"
1154 }));
1155 /* harmony default export */ var star_filled = (starFilled);
1156
1157 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
1158
1159
1160 /**
1161 * WordPress dependencies
1162 */
1163
1164 const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1165 xmlns: "http://www.w3.org/2000/svg",
1166 viewBox: "0 0 24 24"
1167 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1168 fillRule: "evenodd",
1169 d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",
1170 clipRule: "evenodd"
1171 }));
1172 /* harmony default export */ var star_empty = (starEmpty);
1173
1174 ;// CONCATENATED MODULE: external ["wp","viewport"]
1175 var external_wp_viewport_namespaceObject = window["wp"]["viewport"];
1176 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
1177
1178
1179 /**
1180 * WordPress dependencies
1181 */
1182
1183 const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1184 xmlns: "http://www.w3.org/2000/svg",
1185 viewBox: "0 0 24 24"
1186 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1187 d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"
1188 }));
1189 /* harmony default export */ var close_small = (closeSmall);
1190
1191 ;// CONCATENATED MODULE: external ["wp","deprecated"]
1192 var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
1193 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
1194 ;// CONCATENATED MODULE: external ["wp","preferences"]
1195 var external_wp_preferences_namespaceObject = window["wp"]["preferences"];
1196 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
1197 /**
1198 * WordPress dependencies
1199 */
1200
1201
1202 /**
1203 * Set a default complementary area.
1204 *
1205 * @param {string} scope Complementary area scope.
1206 * @param {string} area Area identifier.
1207 *
1208 * @return {Object} Action object.
1209 */
1210
1211 const setDefaultComplementaryArea = (scope, area) => ({
1212 type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
1213 scope,
1214 area
1215 });
1216 /**
1217 * Enable the complementary area.
1218 *
1219 * @param {string} scope Complementary area scope.
1220 * @param {string} area Area identifier.
1221 */
1222
1223 const enableComplementaryArea = (scope, area) => _ref => {
1224 let {
1225 registry,
1226 dispatch
1227 } = _ref;
1228
1229 // Return early if there's no area.
1230 if (!area) {
1231 return;
1232 }
1233
1234 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
1235
1236 if (!isComplementaryAreaVisible) {
1237 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true);
1238 }
1239
1240 dispatch({
1241 type: 'ENABLE_COMPLEMENTARY_AREA',
1242 scope,
1243 area
1244 });
1245 };
1246 /**
1247 * Disable the complementary area.
1248 *
1249 * @param {string} scope Complementary area scope.
1250 */
1251
1252 const disableComplementaryArea = scope => _ref2 => {
1253 let {
1254 registry
1255 } = _ref2;
1256 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
1257
1258 if (isComplementaryAreaVisible) {
1259 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false);
1260 }
1261 };
1262 /**
1263 * Pins an item.
1264 *
1265 * @param {string} scope Item scope.
1266 * @param {string} item Item identifier.
1267 *
1268 * @return {Object} Action object.
1269 */
1270
1271 const pinItem = (scope, item) => _ref3 => {
1272 let {
1273 registry
1274 } = _ref3;
1275
1276 // Return early if there's no item.
1277 if (!item) {
1278 return;
1279 }
1280
1281 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
1282
1283 if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
1284 return;
1285 }
1286
1287 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
1288 [item]: true
1289 });
1290 };
1291 /**
1292 * Unpins an item.
1293 *
1294 * @param {string} scope Item scope.
1295 * @param {string} item Item identifier.
1296 */
1297
1298 const unpinItem = (scope, item) => _ref4 => {
1299 let {
1300 registry
1301 } = _ref4;
1302
1303 // Return early if there's no item.
1304 if (!item) {
1305 return;
1306 }
1307
1308 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
1309 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
1310 [item]: false
1311 });
1312 };
1313 /**
1314 * Returns an action object used in signalling that a feature should be toggled.
1315 *
1316 * @param {string} scope The feature scope (e.g. core/edit-post).
1317 * @param {string} featureName The feature name.
1318 */
1319
1320 function toggleFeature(scope, featureName) {
1321 return function (_ref5) {
1322 let {
1323 registry
1324 } = _ref5;
1325 external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
1326 since: '6.0',
1327 alternative: `dispatch( 'core/preferences' ).toggle`
1328 });
1329 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
1330 };
1331 }
1332 /**
1333 * Returns an action object used in signalling that a feature should be set to
1334 * a true or false value
1335 *
1336 * @param {string} scope The feature scope (e.g. core/edit-post).
1337 * @param {string} featureName The feature name.
1338 * @param {boolean} value The value to set.
1339 *
1340 * @return {Object} Action object.
1341 */
1342
1343 function setFeatureValue(scope, featureName, value) {
1344 return function (_ref6) {
1345 let {
1346 registry
1347 } = _ref6;
1348 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
1349 since: '6.0',
1350 alternative: `dispatch( 'core/preferences' ).set`
1351 });
1352 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
1353 };
1354 }
1355 /**
1356 * Returns an action object used in signalling that defaults should be set for features.
1357 *
1358 * @param {string} scope The feature scope (e.g. core/edit-post).
1359 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
1360 *
1361 * @return {Object} Action object.
1362 */
1363
1364 function setFeatureDefaults(scope, defaults) {
1365 return function (_ref7) {
1366 let {
1367 registry
1368 } = _ref7;
1369 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
1370 since: '6.0',
1371 alternative: `dispatch( 'core/preferences' ).setDefaults`
1372 });
1373 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
1374 };
1375 }
1376
1377 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
1378 /**
1379 * WordPress dependencies
1380 */
1381
1382
1383
1384 /**
1385 * Returns the complementary area that is active in a given scope.
1386 *
1387 * @param {Object} state Global application state.
1388 * @param {string} scope Item scope.
1389 *
1390 * @return {string | null | undefined} The complementary area that is active in the given scope.
1391 */
1392
1393 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
1394 var _state$complementaryA;
1395
1396 const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); // Return `undefined` to indicate that the user has never toggled
1397 // visibility, this is the vanilla default. Other code relies on this
1398 // nuance in the return value.
1399
1400 if (isComplementaryAreaVisible === undefined) {
1401 return undefined;
1402 } // Return `null` to indicate the user hid the complementary area.
1403
1404
1405 if (!isComplementaryAreaVisible) {
1406 return null;
1407 }
1408
1409 return state === null || state === void 0 ? void 0 : (_state$complementaryA = state.complementaryAreas) === null || _state$complementaryA === void 0 ? void 0 : _state$complementaryA[scope];
1410 });
1411 /**
1412 * Returns a boolean indicating if an item is pinned or not.
1413 *
1414 * @param {Object} state Global application state.
1415 * @param {string} scope Scope.
1416 * @param {string} item Item to check.
1417 *
1418 * @return {boolean} True if the item is pinned and false otherwise.
1419 */
1420
1421 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
1422 var _pinnedItems$item;
1423
1424 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
1425 return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
1426 });
1427 /**
1428 * Returns a boolean indicating whether a feature is active for a particular
1429 * scope.
1430 *
1431 * @param {Object} state The store state.
1432 * @param {string} scope The scope of the feature (e.g. core/edit-post).
1433 * @param {string} featureName The name of the feature.
1434 *
1435 * @return {boolean} Is the feature enabled?
1436 */
1437
1438 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
1439 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
1440 since: '6.0',
1441 alternative: `select( 'core/preferences' ).get( scope, featureName )`
1442 });
1443 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
1444 });
1445
1446 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js
1447 /**
1448 * WordPress dependencies
1449 */
1450
1451 function complementaryAreas() {
1452 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1453 let action = arguments.length > 1 ? arguments[1] : undefined;
1454
1455 switch (action.type) {
1456 case 'SET_DEFAULT_COMPLEMENTARY_AREA':
1457 {
1458 const {
1459 scope,
1460 area
1461 } = action; // If there's already an area, don't overwrite it.
1462
1463 if (state[scope]) {
1464 return state;
1465 }
1466
1467 return { ...state,
1468 [scope]: area
1469 };
1470 }
1471
1472 case 'ENABLE_COMPLEMENTARY_AREA':
1473 {
1474 const {
1475 scope,
1476 area
1477 } = action;
1478 return { ...state,
1479 [scope]: area
1480 };
1481 }
1482 }
1483
1484 return state;
1485 }
1486 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
1487 complementaryAreas
1488 }));
1489
1490 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
1491 /**
1492 * The identifier for the data store.
1493 *
1494 * @type {string}
1495 */
1496 const STORE_NAME = 'core/interface';
1497
1498 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
1499 /**
1500 * WordPress dependencies
1501 */
1502
1503 /**
1504 * Internal dependencies
1505 */
1506
1507
1508
1509
1510
1511 /**
1512 * Store definition for the interface namespace.
1513 *
1514 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
1515 *
1516 * @type {Object}
1517 */
1518
1519 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
1520 reducer: reducer,
1521 actions: actions_namespaceObject,
1522 selectors: selectors_namespaceObject
1523 }); // Once we build a more generic persistence plugin that works across types of stores
1524 // we'd be able to replace this with a register call.
1525
1526 (0,external_wp_data_namespaceObject.register)(store);
1527
1528 ;// CONCATENATED MODULE: external ["wp","plugins"]
1529 var external_wp_plugins_namespaceObject = window["wp"]["plugins"];
1530 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
1531 /**
1532 * WordPress dependencies
1533 */
1534
1535 /* harmony default export */ var complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
1536 return {
1537 icon: ownProps.icon || context.icon,
1538 identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
1539 };
1540 }));
1541
1542 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
1543
1544
1545
1546 /**
1547 * WordPress dependencies
1548 */
1549
1550
1551 /**
1552 * Internal dependencies
1553 */
1554
1555
1556
1557
1558 function ComplementaryAreaToggle(_ref) {
1559 let {
1560 as = external_wp_components_namespaceObject.Button,
1561 scope,
1562 identifier,
1563 icon,
1564 selectedIcon,
1565 name,
1566 ...props
1567 } = _ref;
1568 const ComponentToUse = as;
1569 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier]);
1570 const {
1571 enableComplementaryArea,
1572 disableComplementaryArea
1573 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1574 return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, extends_extends({
1575 icon: selectedIcon && isSelected ? selectedIcon : icon,
1576 onClick: () => {
1577 if (isSelected) {
1578 disableComplementaryArea(scope);
1579 } else {
1580 enableComplementaryArea(scope, identifier);
1581 }
1582 }
1583 }, props));
1584 }
1585
1586 /* harmony default export */ var complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
1587
1588 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
1589
1590
1591
1592 /**
1593 * External dependencies
1594 */
1595
1596 /**
1597 * WordPress dependencies
1598 */
1599
1600
1601 /**
1602 * Internal dependencies
1603 */
1604
1605
1606
1607 const ComplementaryAreaHeader = _ref => {
1608 let {
1609 smallScreenTitle,
1610 children,
1611 className,
1612 toggleButtonProps
1613 } = _ref;
1614 const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, extends_extends({
1615 icon: close_small
1616 }, toggleButtonProps));
1617 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
1618 className: "components-panel__header interface-complementary-area-header__small"
1619 }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", {
1620 className: "interface-complementary-area-header__small-title"
1621 }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", {
1622 className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className),
1623 tabIndex: -1
1624 }, children, toggleButton));
1625 };
1626
1627 /* harmony default export */ var complementary_area_header = (ComplementaryAreaHeader);
1628
1629 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
1630
1631
1632
1633 /**
1634 * WordPress dependencies
1635 */
1636
1637
1638
1639 const noop = () => {};
1640
1641 function ActionItemSlot(_ref) {
1642 let {
1643 name,
1644 as: Component = external_wp_components_namespaceObject.ButtonGroup,
1645 fillProps = {},
1646 bubblesVirtually,
1647 ...props
1648 } = _ref;
1649 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
1650 name: name,
1651 bubblesVirtually: bubblesVirtually,
1652 fillProps: fillProps
1653 }, fills => {
1654 if (!external_wp_element_namespaceObject.Children.toArray(fills).length) {
1655 return null;
1656 } // Special handling exists for backward compatibility.
1657 // It ensures that menu items created by plugin authors aren't
1658 // duplicated with automatically injected menu items coming
1659 // from pinnable plugin sidebars.
1660 // @see https://github.com/WordPress/gutenberg/issues/14457
1661
1662
1663 const initializedByPlugins = [];
1664 external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => {
1665 let {
1666 props: {
1667 __unstableExplicitMenuItem,
1668 __unstableTarget
1669 }
1670 } = _ref2;
1671
1672 if (__unstableTarget && __unstableExplicitMenuItem) {
1673 initializedByPlugins.push(__unstableTarget);
1674 }
1675 });
1676 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
1677 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
1678 return null;
1679 }
1680
1681 return child;
1682 });
1683 return (0,external_wp_element_namespaceObject.createElement)(Component, props, children);
1684 });
1685 }
1686
1687 function ActionItem(_ref3) {
1688 let {
1689 name,
1690 as: Component = external_wp_components_namespaceObject.Button,
1691 onClick,
1692 ...props
1693 } = _ref3;
1694 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
1695 name: name
1696 }, _ref4 => {
1697 let {
1698 onClick: fpOnClick
1699 } = _ref4;
1700 return (0,external_wp_element_namespaceObject.createElement)(Component, extends_extends({
1701 onClick: onClick || fpOnClick ? function () {
1702 (onClick || noop)(...arguments);
1703 (fpOnClick || noop)(...arguments);
1704 } : undefined
1705 }, props));
1706 });
1707 }
1708
1709 ActionItem.Slot = ActionItemSlot;
1710 /* harmony default export */ var action_item = (ActionItem);
1711
1712 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
1713
1714
1715
1716 /**
1717 * WordPress dependencies
1718 */
1719
1720
1721 /**
1722 * Internal dependencies
1723 */
1724
1725
1726
1727
1728 const PluginsMenuItem = _ref => {
1729 let {
1730 // Menu item is marked with unstable prop for backward compatibility.
1731 // They are removed so they don't leak to DOM elements.
1732 // @see https://github.com/WordPress/gutenberg/issues/14457
1733 __unstableExplicitMenuItem,
1734 __unstableTarget,
1735 ...restProps
1736 } = _ref;
1737 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, restProps);
1738 };
1739
1740 function ComplementaryAreaMoreMenuItem(_ref2) {
1741 let {
1742 scope,
1743 target,
1744 __unstableExplicitMenuItem,
1745 ...props
1746 } = _ref2;
1747 return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, extends_extends({
1748 as: toggleProps => {
1749 return (0,external_wp_element_namespaceObject.createElement)(action_item, extends_extends({
1750 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
1751 __unstableTarget: `${scope}/${target}`,
1752 as: PluginsMenuItem,
1753 name: `${scope}/plugin-more-menu`
1754 }, toggleProps));
1755 },
1756 role: "menuitemcheckbox",
1757 selectedIcon: library_check,
1758 name: target,
1759 scope: scope
1760 }, props));
1761 }
1762
1763 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
1764
1765
1766
1767 /**
1768 * External dependencies
1769 */
1770
1771 /**
1772 * WordPress dependencies
1773 */
1774
1775
1776
1777 function PinnedItems(_ref) {
1778 let {
1779 scope,
1780 ...props
1781 } = _ref;
1782 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, extends_extends({
1783 name: `PinnedItems/${scope}`
1784 }, props));
1785 }
1786
1787 function PinnedItemsSlot(_ref2) {
1788 let {
1789 scope,
1790 className,
1791 ...props
1792 } = _ref2;
1793 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, extends_extends({
1794 name: `PinnedItems/${scope}`
1795 }, props), fills => (fills === null || fills === void 0 ? void 0 : fills.length) > 0 && (0,external_wp_element_namespaceObject.createElement)("div", {
1796 className: classnames_default()(className, 'interface-pinned-items')
1797 }, fills));
1798 }
1799
1800 PinnedItems.Slot = PinnedItemsSlot;
1801 /* harmony default export */ var pinned_items = (PinnedItems);
1802
1803 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
1804
1805
1806
1807 /**
1808 * External dependencies
1809 */
1810
1811 /**
1812 * WordPress dependencies
1813 */
1814
1815
1816
1817
1818
1819
1820
1821 /**
1822 * Internal dependencies
1823 */
1824
1825
1826
1827
1828
1829
1830
1831
1832 function ComplementaryAreaSlot(_ref) {
1833 let {
1834 scope,
1835 ...props
1836 } = _ref;
1837 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, extends_extends({
1838 name: `ComplementaryArea/${scope}`
1839 }, props));
1840 }
1841
1842 function ComplementaryAreaFill(_ref2) {
1843 let {
1844 scope,
1845 children,
1846 className
1847 } = _ref2;
1848 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
1849 name: `ComplementaryArea/${scope}`
1850 }, (0,external_wp_element_namespaceObject.createElement)("div", {
1851 className: className
1852 }, children));
1853 }
1854
1855 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
1856 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
1857 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
1858 const {
1859 enableComplementaryArea,
1860 disableComplementaryArea
1861 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1862 (0,external_wp_element_namespaceObject.useEffect)(() => {
1863 // If the complementary area is active and the editor is switching from a big to a small window size.
1864 if (isActive && isSmall && !previousIsSmall.current) {
1865 // Disable the complementary area.
1866 disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big.
1867
1868 shouldOpenWhenNotSmall.current = true;
1869 } else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size
1870 // and we are going from a small to big window size.
1871 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
1872 // Remove the flag indicating the complementary area should be enabled.
1873 shouldOpenWhenNotSmall.current = false; // Enable the complementary area.
1874
1875 enableComplementaryArea(scope, identifier);
1876 } else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active,
1877 // remove the flag.
1878 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
1879 shouldOpenWhenNotSmall.current = false;
1880 }
1881
1882 if (isSmall !== previousIsSmall.current) {
1883 previousIsSmall.current = isSmall;
1884 }
1885 }, [isActive, isSmall, scope, identifier, activeArea]);
1886 }
1887
1888 function ComplementaryArea(_ref3) {
1889 let {
1890 children,
1891 className,
1892 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
1893 identifier,
1894 header,
1895 headerClassName,
1896 icon,
1897 isPinnable = true,
1898 panelClassName,
1899 scope,
1900 name,
1901 smallScreenTitle,
1902 title,
1903 toggleShortcut,
1904 isActiveByDefault,
1905 showIconLabels = false
1906 } = _ref3;
1907 const {
1908 isActive,
1909 isPinned,
1910 activeArea,
1911 isSmall,
1912 isLarge
1913 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1914 const {
1915 getActiveComplementaryArea,
1916 isItemPinned
1917 } = select(store);
1918
1919 const _activeArea = getActiveComplementaryArea(scope);
1920
1921 return {
1922 isActive: _activeArea === identifier,
1923 isPinned: isItemPinned(scope, identifier),
1924 activeArea: _activeArea,
1925 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
1926 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large')
1927 };
1928 }, [identifier, scope]);
1929 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
1930 const {
1931 enableComplementaryArea,
1932 disableComplementaryArea,
1933 pinItem,
1934 unpinItem
1935 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1936 (0,external_wp_element_namespaceObject.useEffect)(() => {
1937 if (isActiveByDefault && activeArea === undefined && !isSmall) {
1938 enableComplementaryArea(scope, identifier);
1939 }
1940 }, [activeArea, isActiveByDefault, scope, identifier, isSmall]);
1941 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, {
1942 scope: scope
1943 }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, {
1944 scope: scope,
1945 identifier: identifier,
1946 isPressed: isActive && (!showIconLabels || isLarge),
1947 "aria-expanded": isActive,
1948 label: title,
1949 icon: showIconLabels ? library_check : icon,
1950 showTooltip: !showIconLabels,
1951 variant: showIconLabels ? 'tertiary' : undefined
1952 })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
1953 target: name,
1954 scope: scope,
1955 icon: icon
1956 }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, {
1957 className: classnames_default()('interface-complementary-area', className),
1958 scope: scope
1959 }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, {
1960 className: headerClassName,
1961 closeLabel: closeLabel,
1962 onClose: () => disableComplementaryArea(scope),
1963 smallScreenTitle: smallScreenTitle,
1964 toggleButtonProps: {
1965 label: closeLabel,
1966 shortcut: toggleShortcut,
1967 scope,
1968 identifier
1969 }
1970 }, header || (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, title), isPinnable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1971 className: "interface-complementary-area__pin-unpin-item",
1972 icon: isPinned ? star_filled : star_empty,
1973 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
1974 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
1975 isPressed: isPinned,
1976 "aria-expanded": isPinned
1977 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, {
1978 className: panelClassName
1979 }, children)));
1980 }
1981
1982 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
1983 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
1984 /* harmony default export */ var complementary_area = (ComplementaryAreaWrapped);
1985
1986 ;// CONCATENATED MODULE: external ["wp","compose"]
1987 var external_wp_compose_namespaceObject = window["wp"]["compose"];
1988 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/navigable-region/index.js
1989
1990
1991
1992 /**
1993 * External dependencies
1994 */
1995
1996 function NavigableRegion(_ref) {
1997 let {
1998 children,
1999 className,
2000 ariaLabel,
2001 as: Tag = 'div',
2002 ...props
2003 } = _ref;
2004 return (0,external_wp_element_namespaceObject.createElement)(Tag, extends_extends({
2005 className: classnames_default()('interface-navigable-region', className),
2006 "aria-label": ariaLabel,
2007 role: "region",
2008 tabIndex: "-1"
2009 }, props), (0,external_wp_element_namespaceObject.createElement)("div", {
2010 className: "interface-navigable-region__stacker"
2011 }, children));
2012 }
2013
2014 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
2015
2016
2017
2018 /**
2019 * External dependencies
2020 */
2021
2022 /**
2023 * WordPress dependencies
2024 */
2025
2026
2027
2028
2029
2030 /**
2031 * Internal dependencies
2032 */
2033
2034
2035
2036 function useHTMLClass(className) {
2037 (0,external_wp_element_namespaceObject.useEffect)(() => {
2038 const element = document && document.querySelector(`html:not(.${className})`);
2039
2040 if (!element) {
2041 return;
2042 }
2043
2044 element.classList.toggle(className);
2045 return () => {
2046 element.classList.toggle(className);
2047 };
2048 }, [className]);
2049 }
2050
2051 function InterfaceSkeleton(_ref, ref) {
2052 let {
2053 isDistractionFree,
2054 footer,
2055 header,
2056 editorNotices,
2057 sidebar,
2058 secondarySidebar,
2059 notices,
2060 content,
2061 drawer,
2062 actions,
2063 labels,
2064 className,
2065 shortcuts
2066 } = _ref;
2067 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
2068 useHTMLClass('interface-interface-skeleton__html-container');
2069 const defaultLabels = {
2070 /* translators: accessibility text for the nav bar landmark region. */
2071 drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'),
2072
2073 /* translators: accessibility text for the top bar landmark region. */
2074 header: (0,external_wp_i18n_namespaceObject.__)('Header'),
2075
2076 /* translators: accessibility text for the content landmark region. */
2077 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
2078
2079 /* translators: accessibility text for the secondary sidebar landmark region. */
2080 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
2081
2082 /* translators: accessibility text for the settings landmark region. */
2083 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
2084
2085 /* translators: accessibility text for the publish landmark region. */
2086 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
2087
2088 /* translators: accessibility text for the footer landmark region. */
2089 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
2090 };
2091 const mergedLabels = { ...defaultLabels,
2092 ...labels
2093 };
2094 const headerVariants = {
2095 hidden: isDistractionFree ? {
2096 opacity: 0
2097 } : {
2098 opacity: 1
2099 },
2100 hover: {
2101 opacity: 1,
2102 transition: {
2103 type: 'tween',
2104 delay: 0.2,
2105 delayChildren: 0.2
2106 }
2107 }
2108 };
2109 return (0,external_wp_element_namespaceObject.createElement)("div", extends_extends({}, navigateRegionsProps, {
2110 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]),
2111 className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer')
2112 }), !!drawer && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, {
2113 className: "interface-interface-skeleton__drawer",
2114 ariaLabel: mergedLabels.drawer
2115 }, drawer), (0,external_wp_element_namespaceObject.createElement)("div", {
2116 className: "interface-interface-skeleton__editor"
2117 }, !!header && isDistractionFree && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, {
2118 as: external_wp_components_namespaceObject.__unstableMotion.div,
2119 className: "interface-interface-skeleton__header",
2120 "aria-label": mergedLabels.header,
2121 initial: isDistractionFree ? 'hidden' : 'hover',
2122 whileHover: "hover",
2123 variants: headerVariants,
2124 transition: {
2125 type: 'tween',
2126 delay: 0.8
2127 }
2128 }, header), !!header && !isDistractionFree && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, {
2129 className: "interface-interface-skeleton__header",
2130 ariaLabel: mergedLabels.header
2131 }, header), isDistractionFree && (0,external_wp_element_namespaceObject.createElement)("div", {
2132 className: "interface-interface-skeleton__header"
2133 }, editorNotices), (0,external_wp_element_namespaceObject.createElement)("div", {
2134 className: "interface-interface-skeleton__body"
2135 }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, {
2136 className: "interface-interface-skeleton__secondary-sidebar",
2137 ariaLabel: mergedLabels.secondarySidebar
2138 }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", {
2139 className: "interface-interface-skeleton__notices"
2140 }, notices), (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, {
2141 className: "interface-interface-skeleton__content",
2142 ariaLabel: mergedLabels.body
2143 }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, {
2144 className: "interface-interface-skeleton__sidebar",
2145 ariaLabel: mergedLabels.sidebar
2146 }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, {
2147 className: "interface-interface-skeleton__actions",
2148 ariaLabel: mergedLabels.actions
2149 }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, {
2150 className: "interface-interface-skeleton__footer",
2151 ariaLabel: mergedLabels.footer
2152 }, footer));
2153 }
2154
2155 /* harmony default export */ var interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
2156
2157 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
2158
2159
2160 /**
2161 * WordPress dependencies
2162 */
2163
2164 const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2165 xmlns: "http://www.w3.org/2000/svg",
2166 viewBox: "0 0 24 24"
2167 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2168 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
2169 }));
2170 /* harmony default export */ var more_vertical = (moreVertical);
2171
2172 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-dropdown/index.js
2173
2174
2175 /**
2176 * External dependencies
2177 */
2178
2179 /**
2180 * WordPress dependencies
2181 */
2182
2183
2184
2185
2186 function MoreMenuDropdown(_ref) {
2187 let {
2188 as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu,
2189 className,
2190
2191 /* translators: button label text should, if possible, be under 16 characters. */
2192 label = (0,external_wp_i18n_namespaceObject.__)('Options'),
2193 popoverProps,
2194 toggleProps,
2195 children
2196 } = _ref;
2197 return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, {
2198 className: classnames_default()('interface-more-menu-dropdown', className),
2199 icon: more_vertical,
2200 label: label,
2201 popoverProps: {
2202 position: 'bottom left',
2203 ...popoverProps,
2204 className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
2205 },
2206 toggleProps: {
2207 tooltipPosition: 'bottom',
2208 ...toggleProps
2209 }
2210 }, onClose => children(onClose));
2211 }
2212
2213 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal/index.js
2214
2215
2216 /**
2217 * WordPress dependencies
2218 */
2219
2220
2221 function PreferencesModal(_ref) {
2222 let {
2223 closeModal,
2224 children
2225 } = _ref;
2226 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
2227 className: "interface-preferences-modal",
2228 title: (0,external_wp_i18n_namespaceObject.__)('Preferences'),
2229 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
2230 onRequestClose: closeModal
2231 }, children);
2232 }
2233
2234 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
2235 /**
2236 * WordPress dependencies
2237 */
2238
2239 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
2240
2241 /**
2242 * Return an SVG icon.
2243 *
2244 * @param {IconProps} props icon is the SVG component to render
2245 * size is a number specifiying the icon size in pixels
2246 * Other props will be passed to wrapped SVG component
2247 *
2248 * @return {JSX.Element} Icon component
2249 */
2250
2251 function Icon(_ref) {
2252 let {
2253 icon,
2254 size = 24,
2255 ...props
2256 } = _ref;
2257 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
2258 width: size,
2259 height: size,
2260 ...props
2261 });
2262 }
2263
2264 /* harmony default export */ var icon = (Icon);
2265
2266 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left.js
2267
2268
2269 /**
2270 * WordPress dependencies
2271 */
2272
2273 const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2274 xmlns: "http://www.w3.org/2000/svg",
2275 viewBox: "0 0 24 24"
2276 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2277 d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
2278 }));
2279 /* harmony default export */ var chevron_left = (chevronLeft);
2280
2281 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right.js
2282
2283
2284 /**
2285 * WordPress dependencies
2286 */
2287
2288 const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2289 xmlns: "http://www.w3.org/2000/svg",
2290 viewBox: "0 0 24 24"
2291 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2292 d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
2293 }));
2294 /* harmony default export */ var chevron_right = (chevronRight);
2295
2296 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-tabs/index.js
2297
2298
2299 /**
2300 * WordPress dependencies
2301 */
2302
2303
2304
2305
2306
2307 const PREFERENCES_MENU = 'preferences-menu';
2308 function PreferencesModalTabs(_ref) {
2309 let {
2310 sections
2311 } = _ref;
2312 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); // This is also used to sync the two different rendered components
2313 // between small and large viewports.
2314
2315 const [activeMenu, setActiveMenu] = (0,external_wp_element_namespaceObject.useState)(PREFERENCES_MENU);
2316 /**
2317 * Create helper objects from `sections` for easier data handling.
2318 * `tabs` is used for creating the `TabPanel` and `sectionsContentMap`
2319 * is used for easier access to active tab's content.
2320 */
2321
2322 const {
2323 tabs,
2324 sectionsContentMap
2325 } = (0,external_wp_element_namespaceObject.useMemo)(() => {
2326 let mappedTabs = {
2327 tabs: [],
2328 sectionsContentMap: {}
2329 };
2330
2331 if (sections.length) {
2332 mappedTabs = sections.reduce((accumulator, _ref2) => {
2333 let {
2334 name,
2335 tabLabel: title,
2336 content
2337 } = _ref2;
2338 accumulator.tabs.push({
2339 name,
2340 title
2341 });
2342 accumulator.sectionsContentMap[name] = content;
2343 return accumulator;
2344 }, {
2345 tabs: [],
2346 sectionsContentMap: {}
2347 });
2348 }
2349
2350 return mappedTabs;
2351 }, [sections]);
2352 const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => sectionsContentMap[tab.name] || null, [sectionsContentMap]);
2353 let modalContent; // We render different components based on the viewport size.
2354
2355 if (isLargeViewport) {
2356 modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
2357 className: "interface-preferences__tabs",
2358 tabs: tabs,
2359 initialTabName: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined,
2360 onSelect: setActiveMenu,
2361 orientation: "vertical"
2362 }, getCurrentTab);
2363 } else {
2364 modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, {
2365 initialPath: "/",
2366 className: "interface-preferences__provider"
2367 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
2368 path: "/"
2369 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
2370 isBorderless: true,
2371 size: "small"
2372 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, tabs.map(tab => {
2373 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, {
2374 key: tab.name,
2375 path: tab.name,
2376 as: external_wp_components_namespaceObject.__experimentalItem,
2377 isAction: true
2378 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
2379 justify: "space-between"
2380 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, null, tab.title)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(icon, {
2381 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
2382 }))));
2383 }))))), sections.length && sections.map(section => {
2384 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
2385 key: `${section.name}-menu`,
2386 path: section.name
2387 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
2388 isBorderless: true,
2389 size: "large"
2390 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardHeader, {
2391 isBorderless: false,
2392 justify: "left",
2393 size: "small",
2394 gap: "6"
2395 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, {
2396 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
2397 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view')
2398 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
2399 size: "16"
2400 }, section.tabLabel)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, section.content)));
2401 }));
2402 }
2403
2404 return modalContent;
2405 }
2406
2407 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-section/index.js
2408
2409
2410 const Section = _ref => {
2411 let {
2412 description,
2413 title,
2414 children
2415 } = _ref;
2416 return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
2417 className: "interface-preferences-modal__section"
2418 }, (0,external_wp_element_namespaceObject.createElement)("legend", {
2419 className: "interface-preferences-modal__section-legend"
2420 }, (0,external_wp_element_namespaceObject.createElement)("h2", {
2421 className: "interface-preferences-modal__section-title"
2422 }, title), description && (0,external_wp_element_namespaceObject.createElement)("p", {
2423 className: "interface-preferences-modal__section-description"
2424 }, description)), children);
2425 };
2426
2427 /* harmony default export */ var preferences_modal_section = (Section);
2428
2429 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-base-option/index.js
2430
2431
2432 /**
2433 * WordPress dependencies
2434 */
2435
2436
2437 function BaseOption(_ref) {
2438 let {
2439 help,
2440 label,
2441 isChecked,
2442 onChange,
2443 children
2444 } = _ref;
2445 return (0,external_wp_element_namespaceObject.createElement)("div", {
2446 className: "interface-preferences-modal__option"
2447 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
2448 __nextHasNoMarginBottom: true,
2449 help: help,
2450 label: label,
2451 checked: isChecked,
2452 onChange: onChange
2453 }), children);
2454 }
2455
2456 /* harmony default export */ var preferences_modal_base_option = (BaseOption);
2457
2458 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473 ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
2474
2475
2476
2477 ;// CONCATENATED MODULE: external ["wp","url"]
2478 var external_wp_url_namespaceObject = window["wp"]["url"];
2479 ;// CONCATENATED MODULE: external ["wp","hooks"]
2480 var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
2481 ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
2482 var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
2483 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/hooks/components.js
2484 /**
2485 * WordPress dependencies
2486 */
2487
2488
2489 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-site/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload);
2490
2491 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
2492 var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
2493 ;// CONCATENATED MODULE: ./node_modules/history/index.js
2494 var r,B=r||(r={});B.Pop="POP";B.Push="PUSH";B.Replace="REPLACE";var C= false?0:function(b){return b};function D(b,h){if(!b){"undefined"!==typeof console&&console.warn(h);try{throw Error(h);}catch(k){}}}function E(b){b.preventDefault();b.returnValue=""}
2495 function F(){var b=[];return{get length(){return b.length},push:function(h){b.push(h);return function(){b=b.filter(function(k){return k!==h})}},call:function(h){b.forEach(function(k){return k&&k(h)})}}}function H(){return Math.random().toString(36).substr(2,8)}function I(b){var h=b.pathname,k=b.search;b=b.hash;return(void 0===h?"/":h)+(void 0===k?"":k)+(void 0===b?"":b)}
2496 function J(b){var h={};if(b){var k=b.indexOf("#");0<=k&&(h.hash=b.substr(k),b=b.substr(0,k));k=b.indexOf("?");0<=k&&(h.search=b.substr(k),b=b.substr(0,k));b&&(h.pathname=b)}return h}
2497 function createBrowserHistory(b){function h(){var c=p.location,a=m.state||{};return[a.idx,C({pathname:c.pathname,search:c.search,hash:c.hash,state:a.usr||null,key:a.key||"default"})]}function k(c){return"string"===typeof c?c:I(c)}function x(c,a){void 0===a&&(a=null);return C(extends_extends({pathname:q.pathname,hash:"",search:""},"string"===typeof c?J(c):c,{state:a,key:H()}))}function z(c){t=c;c=h();v=c[0];q=c[1];d.call({action:t,location:q})}function A(c,a){function e(){A(c,a)}var l=r.Push,g=x(c,
2498 a);if(!f.length||(f.call({action:l,location:g,retry:e}),!1)){var n=[{usr:g.state,key:g.key,idx:v+1},k(g)];g=n[0];n=n[1];try{m.pushState(g,"",n)}catch(G){p.location.assign(n)}z(l)}}function y(c,a){function e(){y(c,a)}var l=r.Replace,g=x(c,a);f.length&&(f.call({action:l,location:g,retry:e}),1)||(g=[{usr:g.state,key:g.key,idx:v},k(g)],m.replaceState(g[0],"",g[1]),z(l))}function w(c){m.go(c)}void 0===b&&(b={});b=b.window;var p=void 0===b?document.defaultView:b,m=p.history,u=null;p.addEventListener("popstate",
2499 function(){if(u)f.call(u),u=null;else{var c=r.Pop,a=h(),e=a[0];a=a[1];if(f.length)if(null!=e){var l=v-e;l&&(u={action:c,location:a,retry:function(){w(-1*l)}},w(l))}else false?0:
2500 void 0;else z(c)}});var t=r.Pop;b=h();var v=b[0],q=b[1],d=F(),f=F();null==v&&(v=0,m.replaceState(extends_extends({},m.state,{idx:v}),""));return{get action(){return t},get location(){return q},createHref:k,push:A,replace:y,go:w,back:function(){w(-1)},forward:function(){w(1)},listen:function(c){return d.push(c)},block:function(c){var a=f.push(c);1===f.length&&p.addEventListener("beforeunload",E);return function(){a();f.length||p.removeEventListener("beforeunload",E)}}}};
2501 function createHashHistory(b){function h(){var a=J(m.location.hash.substr(1)),e=a.pathname,l=a.search;a=a.hash;var g=u.state||{};return[g.idx,C({pathname:void 0===e?"/":e,search:void 0===l?"":l,hash:void 0===a?"":a,state:g.usr||null,key:g.key||"default"})]}function k(){if(t)c.call(t),t=null;else{var a=r.Pop,e=h(),l=e[0];e=e[1];if(c.length)if(null!=l){var g=q-l;g&&(t={action:a,location:e,retry:function(){p(-1*g)}},p(g))}else false?0:
2502 void 0;else A(a)}}function x(a){var e=document.querySelector("base"),l="";e&&e.getAttribute("href")&&(e=m.location.href,l=e.indexOf("#"),l=-1===l?e:e.slice(0,l));return l+"#"+("string"===typeof a?a:I(a))}function z(a,e){void 0===e&&(e=null);return C(_extends({pathname:d.pathname,hash:"",search:""},"string"===typeof a?J(a):a,{state:e,key:H()}))}function A(a){v=a;a=h();q=a[0];d=a[1];f.call({action:v,location:d})}function y(a,e){function l(){y(a,e)}var g=r.Push,n=z(a,e); false?
2503 0:void 0;if(!c.length||(c.call({action:g,location:n,retry:l}),!1)){var G=[{usr:n.state,key:n.key,idx:q+1},x(n)];n=G[0];G=G[1];try{u.pushState(n,"",G)}catch(K){m.location.assign(G)}A(g)}}function w(a,e){function l(){w(a,e)}var g=r.Replace,n=z(a,e); false?0:void 0;c.length&&(c.call({action:g,location:n,retry:l}),1)||(n=[{usr:n.state,key:n.key,idx:q},x(n)],u.replaceState(n[0],"",n[1]),A(g))}function p(a){u.go(a)}void 0===b&&(b={});b=b.window;var m=void 0===b?document.defaultView:b,u=m.history,t=null;m.addEventListener("popstate",k);m.addEventListener("hashchange",function(){var a=h()[1];I(a)!==I(d)&&k()});var v=r.Pop;b=h();var q=b[0],d=b[1],f=F(),c=F();null==q&&(q=0,u.replaceState(_extends({},u.state,{idx:q}),""));return{get action(){return v},get location(){return d},
2504 createHref:x,push:y,replace:w,go:p,back:function(){p(-1)},forward:function(){p(1)},listen:function(a){return f.push(a)},block:function(a){var e=c.push(a);1===c.length&&m.addEventListener("beforeunload",E);return function(){e();c.length||m.removeEventListener("beforeunload",E)}}}};
2505 function createMemoryHistory(b){function h(d,f){void 0===f&&(f=null);return C(_extends({pathname:t.pathname,search:"",hash:""},"string"===typeof d?J(d):d,{state:f,key:H()}))}function k(d,f,c){return!q.length||(q.call({action:d,location:f,retry:c}),!1)}function x(d,f){u=d;t=f;v.call({action:u,location:t})}function z(d,f){var c=r.Push,a=h(d,f); false?0:
2506 void 0;k(c,a,function(){z(d,f)})&&(m+=1,p.splice(m,p.length,a),x(c,a))}function A(d,f){var c=r.Replace,a=h(d,f); false?0:void 0;k(c,a,function(){A(d,f)})&&(p[m]=a,x(c,a))}function y(d){var f=Math.min(Math.max(m+d,0),p.length-1),c=r.Pop,a=p[f];k(c,a,function(){y(d)})&&(m=f,x(c,a))}void 0===b&&(b={});var w=b;b=w.initialEntries;w=w.initialIndex;var p=(void 0===
2507 b?["/"]:b).map(function(d){var f=C(_extends({pathname:"/",search:"",hash:"",state:null,key:H()},"string"===typeof d?J(d):d)); false?0:void 0;return f}),m=Math.min(Math.max(null==w?p.length-1:w,0),p.length-1),u=r.Pop,t=p[m],v=F(),q=F();return{get index(){return m},get action(){return u},get location(){return t},createHref:function(d){return"string"===
2508 typeof d?d:I(d)},push:z,replace:A,go:y,back:function(){y(-1)},forward:function(){y(1)},listen:function(d){return v.push(d)},block:function(d){return q.push(d)}}};
2509
2510 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/history.js
2511 /**
2512 * External dependencies
2513 */
2514
2515 /**
2516 * WordPress dependencies
2517 */
2518
2519
2520 const history_history = createBrowserHistory();
2521 const originalHistoryPush = history_history.push;
2522 const originalHistoryReplace = history_history.replace;
2523
2524 function push(params, state) {
2525 return originalHistoryPush.call(history_history, (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params), state);
2526 }
2527
2528 function replace(params, state) {
2529 return originalHistoryReplace.call(history_history, (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params), state);
2530 }
2531
2532 history_history.push = push;
2533 history_history.replace = replace;
2534 /* harmony default export */ var utils_history = (history_history);
2535
2536 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/index.js
2537
2538
2539 /**
2540 * WordPress dependencies
2541 */
2542
2543 /**
2544 * Internal dependencies
2545 */
2546
2547
2548 const RoutesContext = (0,external_wp_element_namespaceObject.createContext)();
2549 const HistoryContext = (0,external_wp_element_namespaceObject.createContext)();
2550 function useLocation() {
2551 return (0,external_wp_element_namespaceObject.useContext)(RoutesContext);
2552 }
2553 function useHistory() {
2554 return (0,external_wp_element_namespaceObject.useContext)(HistoryContext);
2555 }
2556
2557 function getLocationWithParams(location) {
2558 const searchParams = new URLSearchParams(location.search);
2559 return { ...location,
2560 params: Object.fromEntries(searchParams.entries())
2561 };
2562 }
2563
2564 function Routes(_ref) {
2565 let {
2566 children
2567 } = _ref;
2568 const [location, setLocation] = (0,external_wp_element_namespaceObject.useState)(() => getLocationWithParams(utils_history.location));
2569 (0,external_wp_element_namespaceObject.useEffect)(() => {
2570 return utils_history.listen(_ref2 => {
2571 let {
2572 location: updatedLocation
2573 } = _ref2;
2574 setLocation(getLocationWithParams(updatedLocation));
2575 });
2576 }, []);
2577 return (0,external_wp_element_namespaceObject.createElement)(HistoryContext.Provider, {
2578 value: utils_history
2579 }, (0,external_wp_element_namespaceObject.createElement)(RoutesContext.Provider, {
2580 value: location
2581 }, children(location)));
2582 }
2583
2584 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/link.js
2585
2586
2587
2588 /**
2589 * WordPress dependencies
2590 */
2591
2592 /**
2593 * Internal dependencies
2594 */
2595
2596
2597 function useLink() {
2598 let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2599 let state = arguments.length > 1 ? arguments[1] : undefined;
2600 let shouldReplace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2601 const history = useHistory();
2602
2603 function onClick(event) {
2604 event.preventDefault();
2605
2606 if (shouldReplace) {
2607 history.replace(params, state);
2608 } else {
2609 history.push(params, state);
2610 }
2611 }
2612
2613 return {
2614 href: (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params),
2615 onClick
2616 };
2617 }
2618 function Link(_ref) {
2619 let {
2620 params = {},
2621 state,
2622 replace: shouldReplace = false,
2623 children,
2624 ...props
2625 } = _ref;
2626 const {
2627 href,
2628 onClick
2629 } = useLink(params, state, shouldReplace);
2630 return (0,external_wp_element_namespaceObject.createElement)("a", extends_extends({
2631 href: href,
2632 onClick: onClick
2633 }, props), children);
2634 }
2635
2636 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/hooks/template-part-edit.js
2637
2638
2639
2640 /**
2641 * WordPress dependencies
2642 */
2643
2644
2645
2646
2647
2648
2649
2650 /**
2651 * Internal dependencies
2652 */
2653
2654
2655
2656
2657 function EditTemplatePartMenuItem(_ref) {
2658 let {
2659 attributes
2660 } = _ref;
2661 const {
2662 theme,
2663 slug
2664 } = attributes;
2665 const {
2666 params
2667 } = useLocation();
2668 const templatePart = (0,external_wp_data_namespaceObject.useSelect)(select => {
2669 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template_part', // Ideally this should be an official public API.
2670 `${theme}//${slug}`);
2671 }, [theme, slug]);
2672 const linkProps = useLink({
2673 postId: templatePart === null || templatePart === void 0 ? void 0 : templatePart.id,
2674 postType: templatePart === null || templatePart === void 0 ? void 0 : templatePart.type
2675 }, {
2676 fromTemplateId: params.postId
2677 });
2678
2679 if (!templatePart) {
2680 return null;
2681 }
2682
2683 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, {
2684 group: "other"
2685 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, extends_extends({}, linkProps, {
2686 onClick: event => {
2687 linkProps.onClick(event);
2688 }
2689 }), (0,external_wp_i18n_namespaceObject.__)('Edit')));
2690 }
2691
2692 const withEditBlockControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
2693 const {
2694 attributes,
2695 name
2696 } = props;
2697 const isDisplayed = name === 'core/template-part' && attributes.slug;
2698 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), isDisplayed && (0,external_wp_element_namespaceObject.createElement)(EditTemplatePartMenuItem, {
2699 attributes: attributes
2700 }));
2701 }, 'withEditBlockControls');
2702 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-site/template-part-edit-button', withEditBlockControls);
2703
2704 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/hooks/index.js
2705 /**
2706 * Internal dependencies
2707 */
2708
2709
2710
2711 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/constants.js
2712 /**
2713 * The identifier for the data store.
2714 *
2715 * @type {string}
2716 */
2717 const constants_STORE_NAME = 'core/edit-site';
2718 const TEMPLATE_PART_AREA_HEADER = 'header';
2719 const TEMPLATE_PART_AREA_FOOTER = 'footer';
2720 const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';
2721 const TEMPLATE_PART_AREA_GENERAL = 'uncategorized';
2722
2723 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/constants.js
2724 /**
2725 * WordPress dependencies
2726 */
2727
2728 /**
2729 * Internal dependencies
2730 */
2731
2732
2733 const TEMPLATES_PRIMARY = ['index', 'singular', 'archive', 'single', 'page', 'home', '404', 'search'];
2734 const TEMPLATES_SECONDARY = ['author', 'category', 'taxonomy', 'date', 'tag', 'attachment', 'single', 'front-page'];
2735 const TEMPLATES_TOP_LEVEL = [...TEMPLATES_PRIMARY, ...TEMPLATES_SECONDARY];
2736 const TEMPLATES_GENERAL = ['page-home'];
2737 const TEMPLATES_POSTS_PREFIXES = ['post-', 'author-', 'single-', 'tag-'];
2738 const TEMPLATES_PAGES_PREFIXES = ['page-'];
2739 const TEMPLATE_OVERRIDES = {
2740 singular: ['single', 'page'],
2741 index: ['archive', '404', 'search', 'singular', 'home'],
2742 home: ['front-page']
2743 };
2744 const MENU_ROOT = 'root';
2745 const MENU_TEMPLATE_PARTS = 'template-parts';
2746 const MENU_TEMPLATES = 'templates';
2747 const MENU_TEMPLATES_GENERAL = 'templates-general';
2748 const MENU_TEMPLATES_PAGES = 'templates-pages';
2749 const MENU_TEMPLATES_POSTS = 'templates-posts';
2750 const MENU_TEMPLATES_UNUSED = 'templates-unused';
2751 const MENU_TEMPLATE_PARTS_HEADERS = 'template-parts-headers';
2752 const MENU_TEMPLATE_PARTS_FOOTERS = 'template-parts-footers';
2753 const MENU_TEMPLATE_PARTS_SIDEBARS = 'template-parts-sidebars';
2754 const MENU_TEMPLATE_PARTS_GENERAL = 'template-parts-general';
2755 const TEMPLATE_PARTS_SUB_MENUS = [{
2756 area: TEMPLATE_PART_AREA_HEADER,
2757 menu: MENU_TEMPLATE_PARTS_HEADERS,
2758 title: (0,external_wp_i18n_namespaceObject.__)('headers')
2759 }, {
2760 area: TEMPLATE_PART_AREA_FOOTER,
2761 menu: MENU_TEMPLATE_PARTS_FOOTERS,
2762 title: (0,external_wp_i18n_namespaceObject.__)('footers')
2763 }, {
2764 area: TEMPLATE_PART_AREA_SIDEBAR,
2765 menu: MENU_TEMPLATE_PARTS_SIDEBARS,
2766 title: (0,external_wp_i18n_namespaceObject.__)('sidebars')
2767 }, {
2768 area: TEMPLATE_PART_AREA_GENERAL,
2769 menu: MENU_TEMPLATE_PARTS_GENERAL,
2770 title: (0,external_wp_i18n_namespaceObject.__)('general')
2771 }];
2772
2773 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/reducer.js
2774 /**
2775 * WordPress dependencies
2776 */
2777
2778 /**
2779 * Internal dependencies
2780 */
2781
2782
2783 /**
2784 * Reducer returning the editing canvas device type.
2785 *
2786 * @param {Object} state Current state.
2787 * @param {Object} action Dispatched action.
2788 *
2789 * @return {Object} Updated state.
2790 */
2791
2792 function deviceType() {
2793 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Desktop';
2794 let action = arguments.length > 1 ? arguments[1] : undefined;
2795
2796 switch (action.type) {
2797 case 'SET_PREVIEW_DEVICE_TYPE':
2798 return action.deviceType;
2799 }
2800
2801 return state;
2802 }
2803 /**
2804 * Reducer returning the settings.
2805 *
2806 * @param {Object} state Current state.
2807 * @param {Object} action Dispatched action.
2808 *
2809 * @return {Object} Updated state.
2810 */
2811
2812 function settings() {
2813 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2814 let action = arguments.length > 1 ? arguments[1] : undefined;
2815
2816 switch (action.type) {
2817 case 'UPDATE_SETTINGS':
2818 return { ...state,
2819 ...action.settings
2820 };
2821 }
2822
2823 return state;
2824 }
2825 /**
2826 * Reducer keeping track of the currently edited Post Type,
2827 * Post Id and the context provided to fill the content of the block editor.
2828 *
2829 * @param {Object} state Current edited post.
2830 * @param {Object} action Dispatched action.
2831 *
2832 * @return {Object} Updated state.
2833 */
2834
2835 function editedPost() {
2836 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2837 let action = arguments.length > 1 ? arguments[1] : undefined;
2838
2839 switch (action.type) {
2840 case 'SET_TEMPLATE':
2841 case 'SET_PAGE':
2842 return {
2843 type: 'wp_template',
2844 id: action.templateId,
2845 page: action.page
2846 };
2847
2848 case 'SET_TEMPLATE_PART':
2849 return {
2850 type: 'wp_template_part',
2851 id: action.templatePartId
2852 };
2853 }
2854
2855 return state;
2856 }
2857 /**
2858 * Reducer for information about the site's homepage.
2859 *
2860 * @param {Object} state Current state.
2861 * @param {Object} action Dispatched action.
2862 *
2863 * @return {Object} Updated state.
2864 */
2865
2866 function homeTemplateId(state, action) {
2867 switch (action.type) {
2868 case 'SET_HOME_TEMPLATE':
2869 return action.homeTemplateId;
2870 }
2871
2872 return state;
2873 }
2874 /**
2875 * Reducer for information about the navigation panel, such as its active menu
2876 * and whether it should be opened or closed.
2877 *
2878 * Note: this reducer interacts with the inserter and list view panels reducers
2879 * to make sure that only one of the three panels is open at the same time.
2880 *
2881 * @param {Object} state Current state.
2882 * @param {Object} action Dispatched action.
2883 */
2884
2885 function navigationPanel() {
2886 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
2887 menu: MENU_ROOT,
2888 isOpen: false
2889 };
2890 let action = arguments.length > 1 ? arguments[1] : undefined;
2891
2892 switch (action.type) {
2893 case 'SET_NAVIGATION_PANEL_ACTIVE_MENU':
2894 return { ...state,
2895 menu: action.menu
2896 };
2897
2898 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
2899 return { ...state,
2900 isOpen: true,
2901 menu: action.menu
2902 };
2903
2904 case 'SET_IS_NAVIGATION_PANEL_OPENED':
2905 return { ...state,
2906 menu: !action.isOpen ? MENU_ROOT : state.menu,
2907 // Set menu to root when closing panel.
2908 isOpen: action.isOpen
2909 };
2910
2911 case 'SET_IS_LIST_VIEW_OPENED':
2912 return { ...state,
2913 menu: state.isOpen && action.isOpen ? MENU_ROOT : state.menu,
2914 // Set menu to root when closing panel.
2915 isOpen: action.isOpen ? false : state.isOpen
2916 };
2917
2918 case 'SET_IS_INSERTER_OPENED':
2919 return { ...state,
2920 menu: state.isOpen && action.value ? MENU_ROOT : state.menu,
2921 // Set menu to root when closing panel.
2922 isOpen: action.value ? false : state.isOpen
2923 };
2924 }
2925
2926 return state;
2927 }
2928 /**
2929 * Reducer to set the block inserter panel open or closed.
2930 *
2931 * Note: this reducer interacts with the navigation and list view panels reducers
2932 * to make sure that only one of the three panels is open at the same time.
2933 *
2934 * @param {boolean|Object} state Current state.
2935 * @param {Object} action Dispatched action.
2936 */
2937
2938 function blockInserterPanel() {
2939 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2940 let action = arguments.length > 1 ? arguments[1] : undefined;
2941
2942 switch (action.type) {
2943 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
2944 return false;
2945
2946 case 'SET_IS_NAVIGATION_PANEL_OPENED':
2947 case 'SET_IS_LIST_VIEW_OPENED':
2948 return action.isOpen ? false : state;
2949
2950 case 'SET_IS_INSERTER_OPENED':
2951 return action.value;
2952 }
2953
2954 return state;
2955 }
2956 /**
2957 * Reducer to set the list view panel open or closed.
2958 *
2959 * Note: this reducer interacts with the navigation and inserter panels reducers
2960 * to make sure that only one of the three panels is open at the same time.
2961 *
2962 * @param {Object} state Current state.
2963 * @param {Object} action Dispatched action.
2964 */
2965
2966 function listViewPanel() {
2967 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2968 let action = arguments.length > 1 ? arguments[1] : undefined;
2969
2970 switch (action.type) {
2971 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
2972 return false;
2973
2974 case 'SET_IS_NAVIGATION_PANEL_OPENED':
2975 return action.isOpen ? false : state;
2976
2977 case 'SET_IS_INSERTER_OPENED':
2978 return action.value ? false : state;
2979
2980 case 'SET_IS_LIST_VIEW_OPENED':
2981 return action.isOpen;
2982 }
2983
2984 return state;
2985 }
2986 /**
2987 * Reducer to set the save view panel open or closed.
2988 *
2989 * @param {Object} state Current state.
2990 * @param {Object} action Dispatched action.
2991 */
2992
2993 function saveViewPanel() {
2994 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2995 let action = arguments.length > 1 ? arguments[1] : undefined;
2996
2997 switch (action.type) {
2998 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
2999 return false;
3000
3001 case 'SET_IS_NAVIGATION_PANEL_OPENED':
3002 return action.isOpen ? false : state;
3003
3004 case 'SET_IS_SAVE_VIEW_OPENED':
3005 return action.isOpen;
3006 }
3007
3008 return state;
3009 }
3010 /* harmony default export */ var store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
3011 deviceType,
3012 settings,
3013 editedPost,
3014 homeTemplateId,
3015 navigationPanel,
3016 blockInserterPanel,
3017 listViewPanel,
3018 saveViewPanel
3019 }));
3020
3021 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
3022 var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
3023 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
3024 ;// CONCATENATED MODULE: external ["wp","notices"]
3025 var external_wp_notices_namespaceObject = window["wp"]["notices"];
3026 ;// CONCATENATED MODULE: external ["wp","a11y"]
3027 var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
3028 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/is-template-revertable.js
3029 /**
3030 * Check if a template is revertable to its original theme-provided template file.
3031 *
3032 * @param {Object} template The template entity to check.
3033 * @return {boolean} Whether the template is revertable.
3034 */
3035 function isTemplateRevertable(template) {
3036 if (!template) {
3037 return false;
3038 }
3039 /* eslint-disable camelcase */
3040
3041
3042 return (template === null || template === void 0 ? void 0 : template.source) === 'custom' && (template === null || template === void 0 ? void 0 : template.has_theme_file);
3043 /* eslint-enable camelcase */
3044 }
3045
3046 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/actions.js
3047 /**
3048 * WordPress dependencies
3049 */
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061 /**
3062 * Internal dependencies
3063 */
3064
3065
3066
3067 /**
3068 * Dispatches an action that toggles a feature flag.
3069 *
3070 * @param {string} featureName Feature name.
3071 */
3072
3073 function actions_toggleFeature(featureName) {
3074 return function (_ref) {
3075 let {
3076 registry
3077 } = _ref;
3078 external_wp_deprecated_default()("select( 'core/edit-site' ).toggleFeature( featureName )", {
3079 since: '6.0',
3080 alternative: "select( 'core/preferences').toggle( 'core/edit-site', featureName )"
3081 });
3082 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core/edit-site', featureName);
3083 };
3084 }
3085 /**
3086 * Action that changes the width of the editing canvas.
3087 *
3088 * @param {string} deviceType
3089 *
3090 * @return {Object} Action object.
3091 */
3092
3093 function __experimentalSetPreviewDeviceType(deviceType) {
3094 return {
3095 type: 'SET_PREVIEW_DEVICE_TYPE',
3096 deviceType
3097 };
3098 }
3099 /**
3100 * Action that sets a template, optionally fetching it from REST API.
3101 *
3102 * @param {number} templateId The template ID.
3103 * @param {string} templateSlug The template slug.
3104 * @return {Object} Action object.
3105 */
3106
3107 const setTemplate = (templateId, templateSlug) => async _ref2 => {
3108 let {
3109 dispatch,
3110 registry
3111 } = _ref2;
3112
3113 if (!templateSlug) {
3114 const template = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', templateId);
3115 templateSlug = template === null || template === void 0 ? void 0 : template.slug;
3116 }
3117
3118 dispatch({
3119 type: 'SET_TEMPLATE',
3120 templateId,
3121 page: {
3122 context: {
3123 templateSlug
3124 }
3125 }
3126 });
3127 };
3128 /**
3129 * Action that adds a new template and sets it as the current template.
3130 *
3131 * @param {Object} template The template.
3132 *
3133 * @return {Object} Action object used to set the current template.
3134 */
3135
3136 const addTemplate = template => async _ref3 => {
3137 let {
3138 dispatch,
3139 registry
3140 } = _ref3;
3141 const newTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
3142
3143 if (template.content) {
3144 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', 'wp_template', newTemplate.id, {
3145 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content)
3146 }, {
3147 undoIgnore: true
3148 });
3149 }
3150
3151 dispatch({
3152 type: 'SET_TEMPLATE',
3153 templateId: newTemplate.id,
3154 page: {
3155 context: {
3156 templateSlug: newTemplate.slug
3157 }
3158 }
3159 });
3160 };
3161 /**
3162 * Action that removes a template.
3163 *
3164 * @param {Object} template The template object.
3165 */
3166
3167 const removeTemplate = template => async _ref4 => {
3168 let {
3169 registry
3170 } = _ref4;
3171
3172 try {
3173 await registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', template.type, template.id, {
3174 force: true
3175 });
3176 const lastError = registry.select(external_wp_coreData_namespaceObject.store).getLastEntityDeleteError('postType', template.type, template.id);
3177
3178 if (lastError) {
3179 throw lastError;
3180 }
3181
3182 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
3183 /* translators: The template/part's name. */
3184 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), template.title.rendered), {
3185 type: 'snackbar'
3186 });
3187 } catch (error) {
3188 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template.');
3189 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
3190 type: 'snackbar'
3191 });
3192 }
3193 };
3194 /**
3195 * Action that sets a template part.
3196 *
3197 * @param {string} templatePartId The template part ID.
3198 *
3199 * @return {Object} Action object.
3200 */
3201
3202 function setTemplatePart(templatePartId) {
3203 return {
3204 type: 'SET_TEMPLATE_PART',
3205 templatePartId
3206 };
3207 }
3208 /**
3209 * Action that sets the home template ID to the template ID of the page resolved
3210 * from a given path.
3211 *
3212 * @param {number} homeTemplateId The template ID for the homepage.
3213 */
3214
3215 function setHomeTemplateId(homeTemplateId) {
3216 return {
3217 type: 'SET_HOME_TEMPLATE',
3218 homeTemplateId
3219 };
3220 }
3221 /**
3222 * Resolves the template for a page and displays both. If no path is given, attempts
3223 * to use the postId to generate a path like `?p=${ postId }`.
3224 *
3225 * @param {Object} page The page object.
3226 * @param {string} page.type The page type.
3227 * @param {string} page.slug The page slug.
3228 * @param {string} page.path The page path.
3229 * @param {Object} page.context The page context.
3230 *
3231 * @return {number} The resolved template ID for the page route.
3232 */
3233
3234 const setPage = page => async _ref5 => {
3235 var _page$context;
3236
3237 let {
3238 dispatch,
3239 registry
3240 } = _ref5;
3241
3242 if (!page.path && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId) {
3243 const entity = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', page.context.postType || 'post', page.context.postId); // If the entity is undefined for some reason, path will resolve to "/"
3244
3245 page.path = (0,external_wp_url_namespaceObject.getPathAndQueryString)(entity === null || entity === void 0 ? void 0 : entity.link);
3246 }
3247
3248 const template = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).__experimentalGetTemplateForLink(page.path);
3249
3250 if (!template) {
3251 return;
3252 }
3253
3254 dispatch({
3255 type: 'SET_PAGE',
3256 page: template.slug ? { ...page,
3257 context: { ...page.context,
3258 templateSlug: template.slug
3259 }
3260 } : page,
3261 templateId: template.id
3262 });
3263 return template.id;
3264 };
3265 /**
3266 * Action that sets the active navigation panel menu.
3267 *
3268 * @param {string} menu Menu prop of active menu.
3269 *
3270 * @return {Object} Action object.
3271 */
3272
3273 function setNavigationPanelActiveMenu(menu) {
3274 return {
3275 type: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',
3276 menu
3277 };
3278 }
3279 /**
3280 * Opens the navigation panel and sets its active menu at the same time.
3281 *
3282 * @param {string} menu Identifies the menu to open.
3283 */
3284
3285 function openNavigationPanelToMenu(menu) {
3286 return {
3287 type: 'OPEN_NAVIGATION_PANEL_TO_MENU',
3288 menu
3289 };
3290 }
3291 /**
3292 * Sets whether the navigation panel should be open.
3293 *
3294 * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It
3295 * does not toggle the state, but sets it directly.
3296 */
3297
3298 function setIsNavigationPanelOpened(isOpen) {
3299 return {
3300 type: 'SET_IS_NAVIGATION_PANEL_OPENED',
3301 isOpen
3302 };
3303 }
3304 /**
3305 * Opens or closes the inserter.
3306 *
3307 * @param {boolean|Object} value Whether the inserter should be
3308 * opened (true) or closed (false).
3309 * To specify an insertion point,
3310 * use an object.
3311 * @param {string} value.rootClientId The root client ID to insert at.
3312 * @param {number} value.insertionIndex The index to insert at.
3313 *
3314 * @return {Object} Action object.
3315 */
3316
3317 function setIsInserterOpened(value) {
3318 return {
3319 type: 'SET_IS_INSERTER_OPENED',
3320 value
3321 };
3322 }
3323 /**
3324 * Returns an action object used to update the settings.
3325 *
3326 * @param {Object} settings New settings.
3327 *
3328 * @return {Object} Action object.
3329 */
3330
3331 function updateSettings(settings) {
3332 return {
3333 type: 'UPDATE_SETTINGS',
3334 settings
3335 };
3336 }
3337 /**
3338 * Sets whether the list view panel should be open.
3339 *
3340 * @param {boolean} isOpen If true, opens the list view. If false, closes it.
3341 * It does not toggle the state, but sets it directly.
3342 */
3343
3344 function setIsListViewOpened(isOpen) {
3345 return {
3346 type: 'SET_IS_LIST_VIEW_OPENED',
3347 isOpen
3348 };
3349 }
3350 /**
3351 * Sets whether the save view panel should be open.
3352 *
3353 * @param {boolean} isOpen If true, opens the save view. If false, closes it.
3354 * It does not toggle the state, but sets it directly.
3355 */
3356
3357 function setIsSaveViewOpened(isOpen) {
3358 return {
3359 type: 'SET_IS_SAVE_VIEW_OPENED',
3360 isOpen
3361 };
3362 }
3363 /**
3364 * Reverts a template to its original theme-provided file.
3365 *
3366 * @param {Object} template The template to revert.
3367 * @param {Object} [options]
3368 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
3369 * reverting the template. Default true.
3370 */
3371
3372 const revertTemplate = function (template) {
3373 let {
3374 allowUndo = true
3375 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3376 return async _ref6 => {
3377 let {
3378 registry
3379 } = _ref6;
3380
3381 if (!isTemplateRevertable(template)) {
3382 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
3383 type: 'snackbar'
3384 });
3385 return;
3386 }
3387
3388 try {
3389 var _fileTemplate$content;
3390
3391 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
3392
3393 if (!templateEntityConfig) {
3394 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
3395 type: 'snackbar'
3396 });
3397 return;
3398 }
3399
3400 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
3401 context: 'edit',
3402 source: 'theme'
3403 });
3404 const fileTemplate = await external_wp_apiFetch_default()({
3405 path: fileTemplatePath
3406 });
3407
3408 if (!fileTemplate) {
3409 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
3410 type: 'snackbar'
3411 });
3412 return;
3413 }
3414
3415 const serializeBlocks = _ref7 => {
3416 let {
3417 blocks: blocksForSerialization = []
3418 } = _ref7;
3419 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
3420 };
3421
3422 const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id); // We are fixing up the undo level here to make sure we can undo
3423 // the revert in the header toolbar correctly.
3424
3425 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
3426 content: serializeBlocks,
3427 // Required to make the `undo` behave correctly.
3428 blocks: edited.blocks,
3429 // Required to revert the blocks in the editor.
3430 source: 'custom' // required to avoid turning the editor into a dirty state
3431
3432 }, {
3433 undoIgnore: true // Required to merge this edit with the last undo level.
3434
3435 });
3436 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate === null || fileTemplate === void 0 ? void 0 : (_fileTemplate$content = fileTemplate.content) === null || _fileTemplate$content === void 0 ? void 0 : _fileTemplate$content.raw);
3437 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
3438 content: serializeBlocks,
3439 blocks,
3440 source: 'theme'
3441 });
3442
3443 if (allowUndo) {
3444 const undoRevert = () => {
3445 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
3446 content: serializeBlocks,
3447 blocks: edited.blocks,
3448 source: 'custom'
3449 });
3450 };
3451
3452 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reverted.'), {
3453 type: 'snackbar',
3454 actions: [{
3455 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
3456 onClick: undoRevert
3457 }]
3458 });
3459 } else {
3460 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reverted.'));
3461 }
3462 } catch (error) {
3463 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
3464 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
3465 type: 'snackbar'
3466 });
3467 }
3468 };
3469 };
3470 /**
3471 * Action that opens an editor sidebar.
3472 *
3473 * @param {?string} name Sidebar name to be opened.
3474 */
3475
3476 const openGeneralSidebar = name => _ref8 => {
3477 let {
3478 registry
3479 } = _ref8;
3480 registry.dispatch(store).enableComplementaryArea(constants_STORE_NAME, name);
3481 };
3482 /**
3483 * Action that closes the sidebar.
3484 */
3485
3486 const closeGeneralSidebar = () => _ref9 => {
3487 let {
3488 registry
3489 } = _ref9;
3490 registry.dispatch(store).disableComplementaryArea(constants_STORE_NAME);
3491 };
3492 const switchEditorMode = mode => _ref10 => {
3493 let {
3494 registry
3495 } = _ref10;
3496 registry.dispatch('core/preferences').set('core/edit-site', 'editorMode', mode); // Unselect blocks when we switch to a non visual mode.
3497
3498 if (mode !== 'visual') {
3499 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
3500 }
3501
3502 if (mode === 'visual') {
3503 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
3504 } else if (mode === 'mosaic') {
3505 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Mosaic view selected'), 'assertive');
3506 }
3507 };
3508
3509 ;// CONCATENATED MODULE: external "lodash"
3510 var external_lodash_namespaceObject = window["lodash"];
3511 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
3512
3513
3514 /** @typedef {(...args: any[]) => *[]} GetDependants */
3515
3516 /** @typedef {() => void} Clear */
3517
3518 /**
3519 * @typedef {{
3520 * getDependants: GetDependants,
3521 * clear: Clear
3522 * }} EnhancedSelector
3523 */
3524
3525 /**
3526 * Internal cache entry.
3527 *
3528 * @typedef CacheNode
3529 *
3530 * @property {?CacheNode|undefined} [prev] Previous node.
3531 * @property {?CacheNode|undefined} [next] Next node.
3532 * @property {*[]} args Function arguments for cache entry.
3533 * @property {*} val Function result.
3534 */
3535
3536 /**
3537 * @typedef Cache
3538 *
3539 * @property {Clear} clear Function to clear cache.
3540 * @property {boolean} [isUniqueByDependants] Whether dependants are valid in
3541 * considering cache uniqueness. A cache is unique if dependents are all arrays
3542 * or objects.
3543 * @property {CacheNode?} [head] Cache head.
3544 * @property {*[]} [lastDependants] Dependants from previous invocation.
3545 */
3546
3547 /**
3548 * Arbitrary value used as key for referencing cache object in WeakMap tree.
3549 *
3550 * @type {{}}
3551 */
3552 var LEAF_KEY = {};
3553
3554 /**
3555 * Returns the first argument as the sole entry in an array.
3556 *
3557 * @template T
3558 *
3559 * @param {T} value Value to return.
3560 *
3561 * @return {[T]} Value returned as entry in array.
3562 */
3563 function arrayOf(value) {
3564 return [value];
3565 }
3566
3567 /**
3568 * Returns true if the value passed is object-like, or false otherwise. A value
3569 * is object-like if it can support property assignment, e.g. object or array.
3570 *
3571 * @param {*} value Value to test.
3572 *
3573 * @return {boolean} Whether value is object-like.
3574 */
3575 function isObjectLike(value) {
3576 return !!value && 'object' === typeof value;
3577 }
3578
3579 /**
3580 * Creates and returns a new cache object.
3581 *
3582 * @return {Cache} Cache object.
3583 */
3584 function createCache() {
3585 /** @type {Cache} */
3586 var cache = {
3587 clear: function () {
3588 cache.head = null;
3589 },
3590 };
3591
3592 return cache;
3593 }
3594
3595 /**
3596 * Returns true if entries within the two arrays are strictly equal by
3597 * reference from a starting index.
3598 *
3599 * @param {*[]} a First array.
3600 * @param {*[]} b Second array.
3601 * @param {number} fromIndex Index from which to start comparison.
3602 *
3603 * @return {boolean} Whether arrays are shallowly equal.
3604 */
3605 function isShallowEqual(a, b, fromIndex) {
3606 var i;
3607
3608 if (a.length !== b.length) {
3609 return false;
3610 }
3611
3612 for (i = fromIndex; i < a.length; i++) {
3613 if (a[i] !== b[i]) {
3614 return false;
3615 }
3616 }
3617
3618 return true;
3619 }
3620
3621 /**
3622 * Returns a memoized selector function. The getDependants function argument is
3623 * called before the memoized selector and is expected to return an immutable
3624 * reference or array of references on which the selector depends for computing
3625 * its own return value. The memoize cache is preserved only as long as those
3626 * dependant references remain the same. If getDependants returns a different
3627 * reference(s), the cache is cleared and the selector value regenerated.
3628 *
3629 * @template {(...args: *[]) => *} S
3630 *
3631 * @param {S} selector Selector function.
3632 * @param {GetDependants=} getDependants Dependant getter returning an array of
3633 * references used in cache bust consideration.
3634 */
3635 /* harmony default export */ function rememo(selector, getDependants) {
3636 /** @type {WeakMap<*,*>} */
3637 var rootCache;
3638
3639 /** @type {GetDependants} */
3640 var normalizedGetDependants = getDependants ? getDependants : arrayOf;
3641
3642 /**
3643 * Returns the cache for a given dependants array. When possible, a WeakMap
3644 * will be used to create a unique cache for each set of dependants. This
3645 * is feasible due to the nature of WeakMap in allowing garbage collection
3646 * to occur on entries where the key object is no longer referenced. Since
3647 * WeakMap requires the key to be an object, this is only possible when the
3648 * dependant is object-like. The root cache is created as a hierarchy where
3649 * each top-level key is the first entry in a dependants set, the value a
3650 * WeakMap where each key is the next dependant, and so on. This continues
3651 * so long as the dependants are object-like. If no dependants are object-
3652 * like, then the cache is shared across all invocations.
3653 *
3654 * @see isObjectLike
3655 *
3656 * @param {*[]} dependants Selector dependants.
3657 *
3658 * @return {Cache} Cache object.
3659 */
3660 function getCache(dependants) {
3661 var caches = rootCache,
3662 isUniqueByDependants = true,
3663 i,
3664 dependant,
3665 map,
3666 cache;
3667
3668 for (i = 0; i < dependants.length; i++) {
3669 dependant = dependants[i];
3670
3671 // Can only compose WeakMap from object-like key.
3672 if (!isObjectLike(dependant)) {
3673 isUniqueByDependants = false;
3674 break;
3675 }
3676
3677 // Does current segment of cache already have a WeakMap?
3678 if (caches.has(dependant)) {
3679 // Traverse into nested WeakMap.
3680 caches = caches.get(dependant);
3681 } else {
3682 // Create, set, and traverse into a new one.
3683 map = new WeakMap();
3684 caches.set(dependant, map);
3685 caches = map;
3686 }
3687 }
3688
3689 // We use an arbitrary (but consistent) object as key for the last item
3690 // in the WeakMap to serve as our running cache.
3691 if (!caches.has(LEAF_KEY)) {
3692 cache = createCache();
3693 cache.isUniqueByDependants = isUniqueByDependants;
3694 caches.set(LEAF_KEY, cache);
3695 }
3696
3697 return caches.get(LEAF_KEY);
3698 }
3699
3700 /**
3701 * Resets root memoization cache.
3702 */
3703 function clear() {
3704 rootCache = new WeakMap();
3705 }
3706
3707 /* eslint-disable jsdoc/check-param-names */
3708 /**
3709 * The augmented selector call, considering first whether dependants have
3710 * changed before passing it to underlying memoize function.
3711 *
3712 * @param {*} source Source object for derivation.
3713 * @param {...*} extraArgs Additional arguments to pass to selector.
3714 *
3715 * @return {*} Selector result.
3716 */
3717 /* eslint-enable jsdoc/check-param-names */
3718 function callSelector(/* source, ...extraArgs */) {
3719 var len = arguments.length,
3720 cache,
3721 node,
3722 i,
3723 args,
3724 dependants;
3725
3726 // Create copy of arguments (avoid leaking deoptimization).
3727 args = new Array(len);
3728 for (i = 0; i < len; i++) {
3729 args[i] = arguments[i];
3730 }
3731
3732 dependants = normalizedGetDependants.apply(null, args);
3733 cache = getCache(dependants);
3734
3735 // If not guaranteed uniqueness by dependants (primitive type), shallow
3736 // compare against last dependants and, if references have changed,
3737 // destroy cache to recalculate result.
3738 if (!cache.isUniqueByDependants) {
3739 if (
3740 cache.lastDependants &&
3741 !isShallowEqual(dependants, cache.lastDependants, 0)
3742 ) {
3743 cache.clear();
3744 }
3745
3746 cache.lastDependants = dependants;
3747 }
3748
3749 node = cache.head;
3750 while (node) {
3751 // Check whether node arguments match arguments
3752 if (!isShallowEqual(node.args, args, 1)) {
3753 node = node.next;
3754 continue;
3755 }
3756
3757 // At this point we can assume we've found a match
3758
3759 // Surface matched node to head if not already
3760 if (node !== cache.head) {
3761 // Adjust siblings to point to each other.
3762 /** @type {CacheNode} */ (node.prev).next = node.next;
3763 if (node.next) {
3764 node.next.prev = node.prev;
3765 }
3766
3767 node.next = cache.head;
3768 node.prev = null;
3769 /** @type {CacheNode} */ (cache.head).prev = node;
3770 cache.head = node;
3771 }
3772
3773 // Return immediately
3774 return node.val;
3775 }
3776
3777 // No cached value found. Continue to insertion phase:
3778
3779 node = /** @type {CacheNode} */ ({
3780 // Generate the result from original function
3781 val: selector.apply(null, args),
3782 });
3783
3784 // Avoid including the source object in the cache.
3785 args[0] = null;
3786 node.args = args;
3787
3788 // Don't need to check whether node is already head, since it would
3789 // have been returned above already if it was
3790
3791 // Shift existing head down list
3792 if (cache.head) {
3793 cache.head.prev = node;
3794 node.next = cache.head;
3795 }
3796
3797 cache.head = node;
3798
3799 return node.val;
3800 }
3801
3802 callSelector.getDependants = normalizedGetDependants;
3803 callSelector.clear = clear;
3804 clear();
3805
3806 return /** @type {S & EnhancedSelector} */ (callSelector);
3807 }
3808
3809 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js
3810 /**
3811 * External dependencies
3812 */
3813
3814 /**
3815 * Internal dependencies
3816 */
3817
3818
3819 function isTemplateSuperseded(slug, existingSlugs, showOnFront) {
3820 if (!TEMPLATE_OVERRIDES[slug]) {
3821 return false;
3822 } // `home` template is unused if it is superseded by `front-page`
3823 // or "show on front" is set to show a page rather than blog posts.
3824
3825
3826 if (slug === 'home' && showOnFront !== 'posts') {
3827 return true;
3828 }
3829
3830 return TEMPLATE_OVERRIDES[slug].every(overrideSlug => existingSlugs.includes(overrideSlug) || isTemplateSuperseded(overrideSlug, existingSlugs, showOnFront));
3831 }
3832 function getTemplateLocation(slug) {
3833 const isTopLevelTemplate = TEMPLATES_TOP_LEVEL.includes(slug);
3834
3835 if (isTopLevelTemplate) {
3836 return MENU_TEMPLATES;
3837 }
3838
3839 const isGeneralTemplate = TEMPLATES_GENERAL.includes(slug);
3840
3841 if (isGeneralTemplate) {
3842 return MENU_TEMPLATES_GENERAL;
3843 }
3844
3845 const isPostsTemplate = TEMPLATES_POSTS_PREFIXES.some(prefix => slug.startsWith(prefix));
3846
3847 if (isPostsTemplate) {
3848 return MENU_TEMPLATES_POSTS;
3849 }
3850
3851 const isPagesTemplate = TEMPLATES_PAGES_PREFIXES.some(prefix => slug.startsWith(prefix));
3852
3853 if (isPagesTemplate) {
3854 return MENU_TEMPLATES_PAGES;
3855 }
3856
3857 return MENU_TEMPLATES_GENERAL;
3858 }
3859 function getUnusedTemplates(templates, showOnFront) {
3860 const templateSlugs = map(templates, 'slug');
3861 const supersededTemplates = templates.filter(_ref => {
3862 let {
3863 slug
3864 } = _ref;
3865 return isTemplateSuperseded(slug, templateSlugs, showOnFront);
3866 });
3867 return supersededTemplates;
3868 }
3869 function getTemplatesLocationMap(templates) {
3870 return templates.reduce((obj, template) => {
3871 obj[template.slug] = getTemplateLocation(template.slug);
3872 return obj;
3873 }, {});
3874 }
3875
3876 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/selectors.js
3877 /**
3878 * External dependencies
3879 */
3880
3881
3882 /**
3883 * WordPress dependencies
3884 */
3885
3886
3887
3888
3889
3890
3891
3892
3893 /**
3894 * Internal dependencies
3895 */
3896
3897
3898
3899 /**
3900 * @typedef {'template'|'template_type'} TemplateType Template type.
3901 */
3902
3903 /**
3904 * Helper for getting a preference from the preferences store.
3905 *
3906 * This is only present so that `getSettings` doesn't need to be made a
3907 * registry selector.
3908 *
3909 * It's unstable because the selector needs to be exported and so part of the
3910 * public API to work.
3911 */
3912
3913 const __unstableGetPreference = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, name) => select(external_wp_preferences_namespaceObject.store).get('core/edit-site', name));
3914 /**
3915 * Returns whether the given feature is enabled or not.
3916 *
3917 * @param {Object} state Global application state.
3918 * @param {string} featureName Feature slug.
3919 *
3920 * @return {boolean} Is active.
3921 */
3922
3923 function selectors_isFeatureActive(state, featureName) {
3924 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive`, {
3925 since: '6.0',
3926 alternative: `select( 'core/preferences' ).get`
3927 });
3928 return !!__unstableGetPreference(state, featureName);
3929 }
3930 /**
3931 * Returns the current editing canvas device type.
3932 *
3933 * @param {Object} state Global application state.
3934 *
3935 * @return {string} Device type.
3936 */
3937
3938 function __experimentalGetPreviewDeviceType(state) {
3939 return state.deviceType;
3940 }
3941 /**
3942 * Returns whether the current user can create media or not.
3943 *
3944 * @param {Object} state Global application state.
3945 *
3946 * @return {Object} Whether the current user can create media or not.
3947 */
3948
3949 const getCanUserCreateMedia = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => select(external_wp_coreData_namespaceObject.store).canUser('create', 'media'));
3950 /**
3951 * Returns any available Reusable blocks.
3952 *
3953 * @param {Object} state Global application state.
3954 *
3955 * @return {Array} The available reusable blocks.
3956 */
3957
3958 const getReusableBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3959 const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web';
3960 return isWeb ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', {
3961 per_page: -1
3962 }) : [];
3963 });
3964 /**
3965 * Returns the settings, taking into account active features and permissions.
3966 *
3967 * @param {Object} state Global application state.
3968 * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.
3969 *
3970 * @return {Object} Settings.
3971 */
3972
3973 const getSettings = rememo((state, setIsInserterOpen) => {
3974 const settings = { ...state.settings,
3975 outlineMode: true,
3976 focusMode: !!__unstableGetPreference(state, 'focusMode'),
3977 hasFixedToolbar: !!__unstableGetPreference(state, 'fixedToolbar'),
3978 keepCaretInsideBlock: !!__unstableGetPreference(state, 'keepCaretInsideBlock'),
3979 showIconLabels: !!__unstableGetPreference(state, 'showIconLabels'),
3980 __experimentalSetIsInserterOpened: setIsInserterOpen,
3981 __experimentalReusableBlocks: getReusableBlocks(state),
3982 __experimentalPreferPatternsOnRoot: 'wp_template' === getEditedPostType(state)
3983 };
3984 const canUserCreateMedia = getCanUserCreateMedia(state);
3985
3986 if (!canUserCreateMedia) {
3987 return settings;
3988 }
3989
3990 settings.mediaUpload = _ref => {
3991 let {
3992 onError,
3993 ...rest
3994 } = _ref;
3995 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
3996 wpAllowedMimeTypes: state.settings.allowedMimeTypes,
3997 onError: _ref2 => {
3998 let {
3999 message
4000 } = _ref2;
4001 return onError(message);
4002 },
4003 ...rest
4004 });
4005 };
4006
4007 return settings;
4008 }, state => [getCanUserCreateMedia(state), state.settings, __unstableGetPreference(state, 'focusMode'), __unstableGetPreference(state, 'fixedToolbar'), __unstableGetPreference(state, 'keepCaretInsideBlock'), __unstableGetPreference(state, 'showIconLabels'), getReusableBlocks(state), getEditedPostType(state)]);
4009 /**
4010 * Returns the current home template ID.
4011 *
4012 * @param {Object} state Global application state.
4013 *
4014 * @return {number?} Home template ID.
4015 */
4016
4017 function getHomeTemplateId(state) {
4018 return state.homeTemplateId;
4019 }
4020
4021 function getCurrentEditedPost(state) {
4022 return state.editedPost;
4023 }
4024 /**
4025 * Returns the current edited post type (wp_template or wp_template_part).
4026 *
4027 * @param {Object} state Global application state.
4028 *
4029 * @return {TemplateType?} Template type.
4030 */
4031
4032
4033 function getEditedPostType(state) {
4034 return getCurrentEditedPost(state).type;
4035 }
4036 /**
4037 * Returns the ID of the currently edited template or template part.
4038 *
4039 * @param {Object} state Global application state.
4040 *
4041 * @return {string?} Post ID.
4042 */
4043
4044 function getEditedPostId(state) {
4045 return getCurrentEditedPost(state).id;
4046 }
4047 /**
4048 * Returns the current page object.
4049 *
4050 * @param {Object} state Global application state.
4051 *
4052 * @return {Object} Page.
4053 */
4054
4055 function getPage(state) {
4056 return getCurrentEditedPost(state).page;
4057 }
4058 /**
4059 * Returns the active menu in the navigation panel.
4060 *
4061 * @param {Object} state Global application state.
4062 *
4063 * @return {string} Active menu.
4064 */
4065
4066 function getNavigationPanelActiveMenu(state) {
4067 return state.navigationPanel.menu;
4068 }
4069 /**
4070 * Returns the current template or template part's corresponding
4071 * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.
4072 *
4073 * @param {Object} state Global application state.
4074 *
4075 * @return {string} The current template or template part's sub menu.
4076 */
4077
4078 const getCurrentTemplateNavigationPanelSubMenu = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
4079 const templateType = getEditedPostType(state);
4080 const templateId = getEditedPostId(state);
4081 const template = templateId ? select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', templateType, templateId) : null;
4082
4083 if (!template) {
4084 return MENU_ROOT;
4085 }
4086
4087 if ('wp_template_part' === templateType) {
4088 var _TEMPLATE_PARTS_SUB_M;
4089
4090 return ((_TEMPLATE_PARTS_SUB_M = TEMPLATE_PARTS_SUB_MENUS.find(submenu => submenu.area === (template === null || template === void 0 ? void 0 : template.area))) === null || _TEMPLATE_PARTS_SUB_M === void 0 ? void 0 : _TEMPLATE_PARTS_SUB_M.menu) || MENU_TEMPLATE_PARTS;
4091 }
4092
4093 const templates = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template');
4094 const showOnFront = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('root', 'site').show_on_front;
4095
4096 if (isTemplateSuperseded(template.slug, (0,external_lodash_namespaceObject.map)(templates, 'slug'), showOnFront)) {
4097 return MENU_TEMPLATES_UNUSED;
4098 }
4099
4100 return getTemplateLocation(template.slug);
4101 });
4102 /**
4103 * Returns the current opened/closed state of the navigation panel.
4104 *
4105 * @param {Object} state Global application state.
4106 *
4107 * @return {boolean} True if the navigation panel should be open; false if closed.
4108 */
4109
4110 function isNavigationOpened(state) {
4111 return state.navigationPanel.isOpen;
4112 }
4113 /**
4114 * Returns the current opened/closed state of the inserter panel.
4115 *
4116 * @param {Object} state Global application state.
4117 *
4118 * @return {boolean} True if the inserter panel should be open; false if closed.
4119 */
4120
4121 function isInserterOpened(state) {
4122 return !!state.blockInserterPanel;
4123 }
4124 /**
4125 * Get the insertion point for the inserter.
4126 *
4127 * @param {Object} state Global application state.
4128 *
4129 * @return {Object} The root client ID, index to insert at and starting filter value.
4130 */
4131
4132 function __experimentalGetInsertionPoint(state) {
4133 const {
4134 rootClientId,
4135 insertionIndex,
4136 filterValue
4137 } = state.blockInserterPanel;
4138 return {
4139 rootClientId,
4140 insertionIndex,
4141 filterValue
4142 };
4143 }
4144 /**
4145 * Returns the current opened/closed state of the list view panel.
4146 *
4147 * @param {Object} state Global application state.
4148 *
4149 * @return {boolean} True if the list view panel should be open; false if closed.
4150 */
4151
4152 function isListViewOpened(state) {
4153 return state.listViewPanel;
4154 }
4155 /**
4156 * Returns the current opened/closed state of the save panel.
4157 *
4158 * @param {Object} state Global application state.
4159 *
4160 * @return {boolean} True if the save panel should be open; false if closed.
4161 */
4162
4163 function isSaveViewOpened(state) {
4164 return state.saveViewPanel;
4165 }
4166 /**
4167 * Returns the template parts and their blocks for the current edited template.
4168 *
4169 * @param {Object} state Global application state.
4170 * @return {Array} Template parts and their blocks in an array.
4171 */
4172
4173 const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
4174 var _template$blocks;
4175
4176 const templateType = getEditedPostType(state);
4177 const templateId = getEditedPostId(state);
4178 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', templateType, templateId);
4179 const templateParts = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template_part', {
4180 per_page: -1
4181 });
4182 const templatePartsById = templateParts ? // Key template parts by their ID.
4183 templateParts.reduce((newTemplateParts, part) => ({ ...newTemplateParts,
4184 [part.id]: part
4185 }), {}) : {};
4186 return ((_template$blocks = template.blocks) !== null && _template$blocks !== void 0 ? _template$blocks : []).filter(block => (0,external_wp_blocks_namespaceObject.isTemplatePart)(block)).map(block => {
4187 const {
4188 attributes: {
4189 theme,
4190 slug
4191 }
4192 } = block;
4193 const templatePartId = `${theme}//${slug}`;
4194 const templatePart = templatePartsById[templatePartId];
4195 return {
4196 templatePart,
4197 block
4198 };
4199 }).filter(_ref3 => {
4200 let {
4201 templatePart
4202 } = _ref3;
4203 return !!templatePart;
4204 });
4205 });
4206 /**
4207 * Returns the current editing mode.
4208 *
4209 * @param {Object} state Global application state.
4210 *
4211 * @return {string} Editing mode.
4212 */
4213
4214 function getEditorMode(state) {
4215 return __unstableGetPreference(state, 'editorMode');
4216 }
4217
4218 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/index.js
4219 /**
4220 * WordPress dependencies
4221 */
4222
4223 /**
4224 * Internal dependencies
4225 */
4226
4227
4228
4229
4230
4231 const storeConfig = {
4232 reducer: store_reducer,
4233 actions: store_actions_namespaceObject,
4234 selectors: store_selectors_namespaceObject
4235 };
4236 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, storeConfig);
4237 (0,external_wp_data_namespaceObject.register)(store_store);
4238
4239 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
4240 var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
4241 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
4242
4243
4244 /**
4245 * WordPress dependencies
4246 */
4247
4248 const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4249 xmlns: "http://www.w3.org/2000/svg",
4250 viewBox: "0 0 24 24"
4251 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4252 d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
4253 }));
4254 /* harmony default export */ var library_plus = (plus);
4255
4256 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
4257
4258
4259 /**
4260 * WordPress dependencies
4261 */
4262
4263 const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4264 viewBox: "0 0 24 24",
4265 xmlns: "http://www.w3.org/2000/svg"
4266 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4267 d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
4268 }));
4269 /* harmony default export */ var list_view = (listView);
4270
4271 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-up-down.js
4272
4273
4274 /**
4275 * WordPress dependencies
4276 */
4277
4278 const chevronUpDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4279 xmlns: "http://www.w3.org/2000/svg",
4280 viewBox: "0 0 24 24"
4281 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4282 d: "m12 20-4.5-3.6-.9 1.2L12 22l5.5-4.4-.9-1.2L12 20zm0-16 4.5 3.6.9-1.2L12 2 6.5 6.4l.9 1.2L12 4z"
4283 }));
4284 /* harmony default export */ var chevron_up_down = (chevronUpDown);
4285
4286 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
4287
4288
4289 /**
4290 * WordPress dependencies
4291 */
4292
4293 const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4294 xmlns: "http://www.w3.org/2000/svg",
4295 viewBox: "0 0 24 24"
4296 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4297 d: "M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"
4298 }));
4299 /* harmony default export */ var library_external = (external);
4300
4301 ;// CONCATENATED MODULE: external ["wp","keycodes"]
4302 var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
4303 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/config.js
4304 /**
4305 * WordPress dependencies
4306 */
4307
4308 const textFormattingShortcuts = [{
4309 keyCombination: {
4310 modifier: 'primary',
4311 character: 'b'
4312 },
4313 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
4314 }, {
4315 keyCombination: {
4316 modifier: 'primary',
4317 character: 'i'
4318 },
4319 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
4320 }, {
4321 keyCombination: {
4322 modifier: 'primary',
4323 character: 'k'
4324 },
4325 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
4326 }, {
4327 keyCombination: {
4328 modifier: 'primaryShift',
4329 character: 'k'
4330 },
4331 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
4332 }, {
4333 keyCombination: {
4334 character: '[['
4335 },
4336 description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page')
4337 }, {
4338 keyCombination: {
4339 modifier: 'primary',
4340 character: 'u'
4341 },
4342 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
4343 }, {
4344 keyCombination: {
4345 modifier: 'access',
4346 character: 'd'
4347 },
4348 description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.')
4349 }, {
4350 keyCombination: {
4351 modifier: 'access',
4352 character: 'x'
4353 },
4354 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.')
4355 }];
4356
4357 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/shortcut.js
4358
4359
4360 /**
4361 * WordPress dependencies
4362 */
4363
4364
4365
4366 function KeyCombination(_ref) {
4367 let {
4368 keyCombination,
4369 forceAriaLabel
4370 } = _ref;
4371 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
4372 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
4373 return (0,external_wp_element_namespaceObject.createElement)("kbd", {
4374 className: "edit-site-keyboard-shortcut-help-modal__shortcut-key-combination",
4375 "aria-label": forceAriaLabel || ariaLabel
4376 }, (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => {
4377 if (character === '+') {
4378 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
4379 key: index
4380 }, character);
4381 }
4382
4383 return (0,external_wp_element_namespaceObject.createElement)("kbd", {
4384 key: index,
4385 className: "edit-site-keyboard-shortcut-help-modal__shortcut-key"
4386 }, character);
4387 }));
4388 }
4389
4390 function Shortcut(_ref2) {
4391 let {
4392 description,
4393 keyCombination,
4394 aliases = [],
4395 ariaLabel
4396 } = _ref2;
4397 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
4398 className: "edit-site-keyboard-shortcut-help-modal__shortcut-description"
4399 }, description), (0,external_wp_element_namespaceObject.createElement)("div", {
4400 className: "edit-site-keyboard-shortcut-help-modal__shortcut-term"
4401 }, (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
4402 keyCombination: keyCombination,
4403 forceAriaLabel: ariaLabel
4404 }), aliases.map((alias, index) => (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
4405 keyCombination: alias,
4406 forceAriaLabel: ariaLabel,
4407 key: index
4408 }))));
4409 }
4410
4411 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
4412
4413
4414 /**
4415 * WordPress dependencies
4416 */
4417
4418
4419 /**
4420 * Internal dependencies
4421 */
4422
4423
4424 function DynamicShortcut(_ref) {
4425 let {
4426 name
4427 } = _ref;
4428 const {
4429 keyCombination,
4430 description,
4431 aliases
4432 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4433 const {
4434 getShortcutKeyCombination,
4435 getShortcutDescription,
4436 getShortcutAliases
4437 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
4438 return {
4439 keyCombination: getShortcutKeyCombination(name),
4440 aliases: getShortcutAliases(name),
4441 description: getShortcutDescription(name)
4442 };
4443 }, [name]);
4444
4445 if (!keyCombination) {
4446 return null;
4447 }
4448
4449 return (0,external_wp_element_namespaceObject.createElement)(Shortcut, {
4450 keyCombination: keyCombination,
4451 description: description,
4452 aliases: aliases
4453 });
4454 }
4455
4456 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/index.js
4457
4458
4459 /**
4460 * External dependencies
4461 */
4462
4463 /**
4464 * WordPress dependencies
4465 */
4466
4467
4468
4469
4470
4471 /**
4472 * Internal dependencies
4473 */
4474
4475
4476
4477
4478
4479 const ShortcutList = _ref => {
4480 let {
4481 shortcuts
4482 } = _ref;
4483 return (
4484 /*
4485 * Disable reason: The `list` ARIA role is redundant but
4486 * Safari+VoiceOver won't announce the list otherwise.
4487 */
4488
4489 /* eslint-disable jsx-a11y/no-redundant-roles */
4490 (0,external_wp_element_namespaceObject.createElement)("ul", {
4491 className: "edit-site-keyboard-shortcut-help-modal__shortcut-list",
4492 role: "list"
4493 }, shortcuts.map((shortcut, index) => (0,external_wp_element_namespaceObject.createElement)("li", {
4494 className: "edit-site-keyboard-shortcut-help-modal__shortcut",
4495 key: index
4496 }, typeof shortcut === 'string' ? (0,external_wp_element_namespaceObject.createElement)(DynamicShortcut, {
4497 name: shortcut
4498 }) : (0,external_wp_element_namespaceObject.createElement)(Shortcut, shortcut))))
4499 /* eslint-enable jsx-a11y/no-redundant-roles */
4500
4501 );
4502 };
4503
4504 const ShortcutSection = _ref2 => {
4505 let {
4506 title,
4507 shortcuts,
4508 className
4509 } = _ref2;
4510 return (0,external_wp_element_namespaceObject.createElement)("section", {
4511 className: classnames_default()('edit-site-keyboard-shortcut-help-modal__section', className)
4512 }, !!title && (0,external_wp_element_namespaceObject.createElement)("h2", {
4513 className: "edit-site-keyboard-shortcut-help-modal__section-title"
4514 }, title), (0,external_wp_element_namespaceObject.createElement)(ShortcutList, {
4515 shortcuts: shortcuts
4516 }));
4517 };
4518
4519 const ShortcutCategorySection = _ref3 => {
4520 let {
4521 title,
4522 categoryName,
4523 additionalShortcuts = []
4524 } = _ref3;
4525 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
4526 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
4527 }, [categoryName]);
4528 return (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4529 title: title,
4530 shortcuts: categoryShortcuts.concat(additionalShortcuts)
4531 });
4532 };
4533
4534 function KeyboardShortcutHelpModal(_ref4) {
4535 let {
4536 isModalActive,
4537 toggleModal
4538 } = _ref4;
4539
4540 if (!isModalActive) {
4541 return null;
4542 }
4543
4544 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
4545 className: "edit-site-keyboard-shortcut-help-modal",
4546 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
4547 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
4548 onRequestClose: toggleModal
4549 }, (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4550 className: "edit-site-keyboard-shortcut-help-modal__main-shortcuts",
4551 shortcuts: ['core/edit-site/keyboard-shortcuts']
4552 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4553 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
4554 categoryName: "global"
4555 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4556 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
4557 categoryName: "selection"
4558 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4559 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
4560 categoryName: "block",
4561 additionalShortcuts: [{
4562 keyCombination: {
4563 character: '/'
4564 },
4565 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
4566
4567 /* translators: The forward-slash character. e.g. '/'. */
4568 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
4569 }]
4570 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4571 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
4572 shortcuts: textFormattingShortcuts
4573 }));
4574 }
4575
4576 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/preferences-modal/enable-feature.js
4577
4578
4579
4580 /**
4581 * WordPress dependencies
4582 */
4583
4584
4585
4586 function EnableFeature(props) {
4587 const {
4588 featureName,
4589 ...remainingProps
4590 } = props;
4591 const isChecked = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', featureName), [featureName]);
4592 const {
4593 toggle
4594 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
4595
4596 const onChange = () => toggle('core/edit-site', featureName);
4597
4598 return (0,external_wp_element_namespaceObject.createElement)(preferences_modal_base_option, extends_extends({
4599 onChange: onChange,
4600 isChecked: isChecked
4601 }, remainingProps));
4602 }
4603
4604 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/preferences-modal/index.js
4605
4606
4607 /**
4608 * WordPress dependencies
4609 */
4610
4611
4612
4613 /**
4614 * Internal dependencies
4615 */
4616
4617
4618 function EditSitePreferencesModal(_ref) {
4619 let {
4620 isModalActive,
4621 toggleModal
4622 } = _ref;
4623 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
4624 name: 'general',
4625 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
4626 content: (0,external_wp_element_namespaceObject.createElement)(preferences_modal_section, {
4627 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
4628 description: (0,external_wp_i18n_namespaceObject.__)('Customize options related to the block editor interface and editing flow.')
4629 }, (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4630 featureName: "focusMode",
4631 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
4632 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
4633 }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4634 featureName: "showIconLabels",
4635 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'),
4636 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons.')
4637 }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4638 featureName: "showListViewByDefault",
4639 help: (0,external_wp_i18n_namespaceObject.__)('Opens the block list view sidebar by default.'),
4640 label: (0,external_wp_i18n_namespaceObject.__)('Always open list view')
4641 }))
4642 }, {
4643 name: 'blocks',
4644 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
4645 content: (0,external_wp_element_namespaceObject.createElement)(preferences_modal_section, {
4646 title: (0,external_wp_i18n_namespaceObject.__)('Block interactions'),
4647 description: (0,external_wp_i18n_namespaceObject.__)('Customize how you interact with blocks in the block library and editing canvas.')
4648 }, (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4649 featureName: "keepCaretInsideBlock",
4650 help: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'),
4651 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
4652 }))
4653 }]);
4654
4655 if (!isModalActive) {
4656 return null;
4657 }
4658
4659 return (0,external_wp_element_namespaceObject.createElement)(PreferencesModal, {
4660 closeModal: toggleModal
4661 }, (0,external_wp_element_namespaceObject.createElement)(PreferencesModalTabs, {
4662 sections: sections
4663 }));
4664 }
4665
4666 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/tools-more-menu-group/index.js
4667
4668
4669 /**
4670 * External dependencies
4671 */
4672
4673 /**
4674 * WordPress dependencies
4675 */
4676
4677
4678 const {
4679 Fill: ToolsMoreMenuGroup,
4680 Slot
4681 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteToolsMoreMenuGroup');
4682
4683 ToolsMoreMenuGroup.Slot = _ref => {
4684 let {
4685 fillProps
4686 } = _ref;
4687 return (0,external_wp_element_namespaceObject.createElement)(Slot, {
4688 fillProps: fillProps
4689 }, fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && fills);
4690 };
4691
4692 /* harmony default export */ var tools_more_menu_group = (ToolsMoreMenuGroup);
4693
4694 // EXTERNAL MODULE: ./node_modules/downloadjs/download.js
4695 var download = __webpack_require__(8981);
4696 var download_default = /*#__PURE__*/__webpack_require__.n(download);
4697 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/download.js
4698
4699
4700 /**
4701 * WordPress dependencies
4702 */
4703
4704 const download_download = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4705 xmlns: "http://www.w3.org/2000/svg",
4706 viewBox: "0 0 24 24"
4707 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4708 d: "M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z"
4709 }));
4710 /* harmony default export */ var library_download = (download_download);
4711
4712 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/more-menu/site-export.js
4713
4714
4715 /**
4716 * External dependencies
4717 */
4718
4719 /**
4720 * WordPress dependencies
4721 */
4722
4723
4724
4725
4726
4727
4728
4729 function SiteExport() {
4730 const {
4731 createErrorNotice
4732 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
4733
4734 async function handleExport() {
4735 try {
4736 const response = await external_wp_apiFetch_default()({
4737 path: '/wp-block-editor/v1/export',
4738 parse: false,
4739 headers: {
4740 Accept: 'application/zip'
4741 }
4742 });
4743 const blob = await response.blob();
4744 const contentDisposition = response.headers.get('content-disposition');
4745 const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/);
4746 const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : 'edit-site-export';
4747 download_default()(blob, fileName + '.zip', 'application/zip');
4748 } catch (errorResponse) {
4749 let error = {};
4750
4751 try {
4752 error = await errorResponse.json();
4753 } catch (e) {}
4754
4755 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the site export.');
4756 createErrorNotice(errorMessage, {
4757 type: 'snackbar'
4758 });
4759 }
4760 }
4761
4762 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4763 role: "menuitem",
4764 icon: library_download,
4765 onClick: handleExport,
4766 info: (0,external_wp_i18n_namespaceObject.__)('Download your theme with updated templates and styles.')
4767 }, (0,external_wp_i18n_namespaceObject._x)('Export', 'site exporter menu item'));
4768 }
4769
4770 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/more-menu/welcome-guide-menu-item.js
4771
4772
4773 /**
4774 * WordPress dependencies
4775 */
4776
4777
4778
4779
4780 function WelcomeGuideMenuItem() {
4781 const {
4782 toggle
4783 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
4784 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4785 onClick: () => toggle('core/edit-site', 'welcomeGuide')
4786 }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'));
4787 }
4788
4789 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js
4790
4791
4792 /**
4793 * WordPress dependencies
4794 */
4795
4796
4797
4798
4799
4800
4801
4802 /**
4803 * Internal dependencies
4804 */
4805
4806
4807 function CopyContentMenuItem() {
4808 const {
4809 createNotice
4810 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
4811 const getText = (0,external_wp_data_namespaceObject.useSelect)(select => {
4812 return () => {
4813 const {
4814 getEditedPostId,
4815 getEditedPostType
4816 } = select(store_store);
4817 const {
4818 getEditedEntityRecord
4819 } = select(external_wp_coreData_namespaceObject.store);
4820 const record = getEditedEntityRecord('postType', getEditedPostType(), getEditedPostId());
4821
4822 if (record) {
4823 if (typeof record.content === 'function') {
4824 return record.content(record);
4825 } else if (record.blocks) {
4826 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
4827 } else if (record.content) {
4828 return record.content;
4829 }
4830 }
4831
4832 return '';
4833 };
4834 }, []);
4835
4836 function onSuccess() {
4837 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
4838 isDismissible: true,
4839 type: 'snackbar'
4840 });
4841 }
4842
4843 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
4844 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4845 ref: ref
4846 }, (0,external_wp_i18n_namespaceObject.__)('Copy all blocks'));
4847 }
4848
4849 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/mode-switcher/index.js
4850
4851
4852 /**
4853 * WordPress dependencies
4854 */
4855
4856
4857
4858
4859 /**
4860 * Internal dependencies
4861 */
4862
4863
4864 /**
4865 * Set of available mode options.
4866 *
4867 * @type {Array}
4868 */
4869
4870 const MODES = [{
4871 value: 'visual',
4872 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
4873 }, {
4874 value: 'text',
4875 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
4876 }];
4877
4878 function ModeSwitcher() {
4879 const {
4880 shortcut,
4881 mode
4882 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
4883 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-mode'),
4884 isRichEditingEnabled: select(store_store).getSettings().richEditingEnabled,
4885 isCodeEditingEnabled: select(store_store).getSettings().codeEditingEnabled,
4886 mode: select(store_store).getEditorMode()
4887 }), []);
4888 const {
4889 switchEditorMode
4890 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4891 const choices = MODES.map(choice => {
4892 if (choice.value !== mode) {
4893 return { ...choice,
4894 shortcut
4895 };
4896 }
4897
4898 return choice;
4899 });
4900 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4901 label: (0,external_wp_i18n_namespaceObject.__)('Editor')
4902 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
4903 choices: choices,
4904 value: mode,
4905 onSelect: switchEditorMode
4906 }));
4907 }
4908
4909 /* harmony default export */ var mode_switcher = (ModeSwitcher);
4910
4911 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/more-menu/index.js
4912
4913
4914 /**
4915 * WordPress dependencies
4916 */
4917
4918
4919
4920
4921
4922
4923
4924
4925 /**
4926 * Internal dependencies
4927 */
4928
4929
4930
4931
4932
4933
4934
4935
4936 function MoreMenu(_ref) {
4937 let {
4938 showIconLabels
4939 } = _ref;
4940 const [isModalActive, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
4941 const [isPreferencesModalActive, togglePreferencesModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
4942 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/keyboard-shortcuts', toggleModal);
4943 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, {
4944 toggleProps: {
4945 showTooltip: !showIconLabels,
4946 ...(showIconLabels && {
4947 variant: 'tertiary'
4948 })
4949 }
4950 }, _ref2 => {
4951 let {
4952 onClose
4953 } = _ref2;
4954 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4955 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun')
4956 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
4957 scope: "core/edit-site",
4958 name: "fixedToolbar",
4959 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
4960 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
4961 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
4962 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
4963 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
4964 scope: "core/edit-site",
4965 name: "focusMode",
4966 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
4967 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
4968 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'),
4969 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated')
4970 }), (0,external_wp_element_namespaceObject.createElement)(mode_switcher, null), (0,external_wp_element_namespaceObject.createElement)(action_item.Slot, {
4971 name: "core/edit-site/plugin-more-menu",
4972 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
4973 as: external_wp_components_namespaceObject.MenuGroup,
4974 fillProps: {
4975 onClick: onClose
4976 }
4977 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4978 label: (0,external_wp_i18n_namespaceObject.__)('Tools')
4979 }, (0,external_wp_element_namespaceObject.createElement)(SiteExport, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4980 onClick: toggleModal,
4981 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h')
4982 }, (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideMenuItem, null), (0,external_wp_element_namespaceObject.createElement)(CopyContentMenuItem, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4983 icon: library_external,
4984 role: "menuitem",
4985 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/site-editor/'),
4986 target: "_blank",
4987 rel: "noopener noreferrer"
4988 }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
4989 as: "span"
4990 },
4991 /* translators: accessibility text */
4992 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group.Slot, {
4993 fillProps: {
4994 onClose
4995 }
4996 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4997 onClick: togglePreferencesModal
4998 }, (0,external_wp_i18n_namespaceObject.__)('Preferences'))));
4999 }), (0,external_wp_element_namespaceObject.createElement)(KeyboardShortcutHelpModal, {
5000 isModalActive: isModalActive,
5001 toggleModal: toggleModal
5002 }), (0,external_wp_element_namespaceObject.createElement)(EditSitePreferencesModal, {
5003 isModalActive: isPreferencesModalActive,
5004 toggleModal: togglePreferencesModal
5005 }));
5006 }
5007
5008 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/save-button/index.js
5009
5010
5011 /**
5012 * WordPress dependencies
5013 */
5014
5015
5016
5017
5018
5019 /**
5020 * Internal dependencies
5021 */
5022
5023
5024 function SaveButton() {
5025 const {
5026 isDirty,
5027 isSaving,
5028 isSaveViewOpen
5029 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5030 const {
5031 __experimentalGetDirtyEntityRecords,
5032 isSavingEntityRecord
5033 } = select(external_wp_coreData_namespaceObject.store);
5034
5035 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
5036
5037 const {
5038 isSaveViewOpened
5039 } = select(store_store);
5040 return {
5041 isDirty: dirtyEntityRecords.length > 0,
5042 isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)),
5043 isSaveViewOpen: isSaveViewOpened()
5044 };
5045 }, []);
5046 const {
5047 setIsSaveViewOpened
5048 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5049 const disabled = !isDirty || isSaving;
5050
5051 const label = (0,external_wp_i18n_namespaceObject.__)('Save');
5052
5053 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5054 variant: "primary",
5055 className: "edit-site-save-button__button",
5056 "aria-disabled": disabled,
5057 "aria-expanded": isSaveViewOpen,
5058 isBusy: isSaving,
5059 onClick: disabled ? undefined : () => setIsSaveViewOpened(true),
5060 label: label
5061 /*
5062 * We want the tooltip to show the keyboard shortcut only when the
5063 * button does something, i.e. when it's not disabled.
5064 */
5065 ,
5066 shortcut: disabled ? undefined : external_wp_keycodes_namespaceObject.displayShortcut.primary('s')
5067 /*
5068 * Displaying the keyboard shortcut conditionally makes the tooltip
5069 * itself show conditionally. This would trigger a full-rerendering
5070 * of the button that we want to avoid. By setting `showTooltip`,
5071 & the tooltip is always rendered even when there's no keyboard shortcut.
5072 */
5073 ,
5074 showTooltip: true
5075 }, label);
5076 }
5077
5078 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
5079
5080
5081 /**
5082 * WordPress dependencies
5083 */
5084
5085 const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5086 xmlns: "http://www.w3.org/2000/svg",
5087 viewBox: "0 0 24 24"
5088 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5089 d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"
5090 }));
5091 /* harmony default export */ var library_undo = (undo);
5092
5093 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
5094
5095
5096 /**
5097 * WordPress dependencies
5098 */
5099
5100 const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5101 xmlns: "http://www.w3.org/2000/svg",
5102 viewBox: "0 0 24 24"
5103 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5104 d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z"
5105 }));
5106 /* harmony default export */ var library_redo = (redo);
5107
5108 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/undo-redo/undo.js
5109
5110
5111
5112 /**
5113 * WordPress dependencies
5114 */
5115
5116
5117
5118
5119
5120
5121
5122
5123 function UndoButton(props, ref) {
5124 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []);
5125 const {
5126 undo
5127 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
5128 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, extends_extends({}, props, {
5129 ref: ref,
5130 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo,
5131 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5132 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
5133 // button, because it will remove focus for keyboard users.
5134 // See: https://github.com/WordPress/gutenberg/issues/3486
5135 ,
5136 "aria-disabled": !hasUndo,
5137 onClick: hasUndo ? undo : undefined
5138 }));
5139 }
5140
5141 /* harmony default export */ var undo_redo_undo = ((0,external_wp_element_namespaceObject.forwardRef)(UndoButton));
5142
5143 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/undo-redo/redo.js
5144
5145
5146
5147 /**
5148 * WordPress dependencies
5149 */
5150
5151
5152
5153
5154
5155
5156
5157
5158 function RedoButton(props, ref) {
5159 const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y');
5160 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []);
5161 const {
5162 redo
5163 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
5164 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, extends_extends({}, props, {
5165 ref: ref,
5166 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo,
5167 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
5168 shortcut: shortcut // If there are no undo levels we don't want to actually disable this
5169 // button, because it will remove focus for keyboard users.
5170 // See: https://github.com/WordPress/gutenberg/issues/3486
5171 ,
5172 "aria-disabled": !hasRedo,
5173 onClick: hasRedo ? redo : undefined
5174 }));
5175 }
5176
5177 /* harmony default export */ var undo_redo_redo = ((0,external_wp_element_namespaceObject.forwardRef)(RedoButton));
5178
5179 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js
5180
5181
5182 /**
5183 * WordPress dependencies
5184 */
5185
5186 const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5187 viewBox: "0 0 24 24",
5188 xmlns: "http://www.w3.org/2000/svg"
5189 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5190 d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
5191 }));
5192 /* harmony default export */ var chevron_down = (chevronDown);
5193
5194 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
5195 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
5196 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/template-areas.js
5197
5198
5199
5200 /**
5201 * WordPress dependencies
5202 */
5203
5204
5205
5206
5207
5208
5209 /**
5210 * Internal dependencies
5211 */
5212
5213
5214
5215
5216
5217
5218 function TemplatePartItemMore(_ref) {
5219 var _templatePart$title;
5220
5221 let {
5222 onClose,
5223 templatePart,
5224 closeTemplateDetailsDropdown
5225 } = _ref;
5226 const {
5227 revertTemplate
5228 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5229 const {
5230 params
5231 } = useLocation();
5232 const editLinkProps = useLink({
5233 postId: templatePart.id,
5234 postType: templatePart.type
5235 }, {
5236 fromTemplateId: params.postId
5237 });
5238
5239 function editTemplatePart(event) {
5240 editLinkProps.onClick(event);
5241 onClose();
5242 closeTemplateDetailsDropdown();
5243 }
5244
5245 function clearCustomizations() {
5246 revertTemplate(templatePart);
5247 onClose();
5248 closeTemplateDetailsDropdown();
5249 }
5250
5251 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, extends_extends({}, editLinkProps, {
5252 onClick: editTemplatePart
5253 }), (0,external_wp_i18n_namespaceObject.sprintf)(
5254 /* translators: %s: template part title */
5255 (0,external_wp_i18n_namespaceObject.__)('Edit %s'), (_templatePart$title = templatePart.title) === null || _templatePart$title === void 0 ? void 0 : _templatePart$title.rendered))), isTemplateRevertable(templatePart) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5256 info: (0,external_wp_i18n_namespaceObject.__)('Use the template part as supplied by the theme.'),
5257 onClick: clearCustomizations
5258 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations'))));
5259 }
5260
5261 function TemplatePartItem(_ref2) {
5262 let {
5263 templatePart,
5264 clientId,
5265 closeTemplateDetailsDropdown
5266 } = _ref2;
5267 const {
5268 selectBlock,
5269 toggleBlockHighlight
5270 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
5271 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => {
5272 const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas();
5273
5274 return defaultAreas.find(defaultArea => defaultArea.area === templatePart.area);
5275 }, [templatePart.area]);
5276
5277 const highlightBlock = () => toggleBlockHighlight(clientId, true);
5278
5279 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
5280
5281 return (0,external_wp_element_namespaceObject.createElement)("div", {
5282 role: "menuitem",
5283 className: "edit-site-template-details__template-areas-item"
5284 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5285 role: "button",
5286 icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
5287 iconPosition: "left",
5288 onClick: () => {
5289 selectBlock(clientId);
5290 },
5291 onMouseOver: highlightBlock,
5292 onMouseLeave: cancelHighlightBlock,
5293 onFocus: highlightBlock,
5294 onBlur: cancelHighlightBlock
5295 }, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
5296 icon: more_vertical,
5297 label: (0,external_wp_i18n_namespaceObject.__)('More options'),
5298 className: "edit-site-template-details__template-areas-item-more"
5299 }, _ref3 => {
5300 let {
5301 onClose
5302 } = _ref3;
5303 return (0,external_wp_element_namespaceObject.createElement)(TemplatePartItemMore, {
5304 onClose: onClose,
5305 templatePart: templatePart,
5306 closeTemplateDetailsDropdown: closeTemplateDetailsDropdown
5307 });
5308 }));
5309 }
5310
5311 function TemplateAreas(_ref4) {
5312 let {
5313 closeTemplateDetailsDropdown
5314 } = _ref4;
5315 const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentTemplateTemplateParts(), []);
5316
5317 if (!templateParts.length) {
5318 return null;
5319 }
5320
5321 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
5322 label: (0,external_wp_i18n_namespaceObject.__)('Areas'),
5323 className: "edit-site-template-details__group edit-site-template-details__template-areas"
5324 }, templateParts.map(_ref5 => {
5325 let {
5326 templatePart,
5327 block
5328 } = _ref5;
5329 return (0,external_wp_element_namespaceObject.createElement)(TemplatePartItem, {
5330 key: templatePart.slug,
5331 clientId: block.clientId,
5332 templatePart: templatePart,
5333 closeTemplateDetailsDropdown: closeTemplateDetailsDropdown
5334 });
5335 }));
5336 }
5337
5338 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/edit-template-title.js
5339
5340
5341 /**
5342 * WordPress dependencies
5343 */
5344
5345
5346
5347
5348 function EditTemplateTitle(_ref) {
5349 let {
5350 template
5351 } = _ref;
5352 const [forceEmpty, setForceEmpty] = (0,external_wp_element_namespaceObject.useState)(false);
5353 const [title, setTitle] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', template.type, 'title', template.id);
5354 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
5355 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
5356 value: forceEmpty ? '' : title,
5357 help: template.type !== 'wp_template_part' ? (0,external_wp_i18n_namespaceObject.__)('Give the template a title that indicates its purpose, e.g. "Full Width".') : null,
5358 onChange: newTitle => {
5359 if (!newTitle && !forceEmpty) {
5360 setForceEmpty(true);
5361 return;
5362 }
5363
5364 setForceEmpty(false);
5365 setTitle(newTitle);
5366 },
5367 onBlur: () => setForceEmpty(false)
5368 });
5369 }
5370
5371 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/template-part-area-selector.js
5372
5373
5374 /**
5375 * WordPress dependencies
5376 */
5377
5378
5379
5380
5381
5382 function TemplatePartAreaSelector(_ref) {
5383 let {
5384 id
5385 } = _ref;
5386 const [area, setArea] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', 'wp_template_part', 'area', id);
5387 const definedAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []);
5388 const areaOptions = definedAreas.map(_ref2 => {
5389 let {
5390 label,
5391 area: _area
5392 } = _ref2;
5393 return {
5394 label,
5395 value: _area
5396 };
5397 });
5398 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
5399 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
5400 labelPosition: "top",
5401 options: areaOptions,
5402 value: area,
5403 onChange: setArea
5404 });
5405 }
5406
5407 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/index.js
5408
5409
5410
5411 /**
5412 * WordPress dependencies
5413 */
5414
5415
5416
5417
5418
5419 /**
5420 * Internal dependencies
5421 */
5422
5423
5424
5425
5426
5427
5428
5429 function TemplateDetails(_ref) {
5430 let {
5431 template,
5432 onClose
5433 } = _ref;
5434 const {
5435 title,
5436 description
5437 } = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetTemplateInfo(template), []);
5438 const {
5439 revertTemplate
5440 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5441 const browseAllLinkProps = useLink({
5442 // TODO: We should update this to filter by template part's areas as well.
5443 postType: template.type,
5444 postId: undefined
5445 });
5446 const isTemplatePart = template.type === 'wp_template_part'; // Only user-created and non-default templates can change the name.
5447 // But any user-created template part can be renamed.
5448
5449 const canEditTitle = isTemplatePart ? !template.has_theme_file : template.is_custom && !template.has_theme_file;
5450
5451 if (!template) {
5452 return null;
5453 }
5454
5455 const revert = () => {
5456 revertTemplate(template);
5457 onClose();
5458 };
5459
5460 return (0,external_wp_element_namespaceObject.createElement)("div", {
5461 className: "edit-site-template-details"
5462 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
5463 className: "edit-site-template-details__group",
5464 spacing: 3
5465 }, canEditTitle ? (0,external_wp_element_namespaceObject.createElement)(EditTemplateTitle, {
5466 template: template
5467 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5468 size: 16,
5469 weight: 600,
5470 className: "edit-site-template-details__title",
5471 as: "p"
5472 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)), description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5473 size: "body",
5474 className: "edit-site-template-details__description",
5475 as: "p"
5476 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(description))), isTemplatePart && (0,external_wp_element_namespaceObject.createElement)("div", {
5477 className: "edit-site-template-details__group"
5478 }, (0,external_wp_element_namespaceObject.createElement)(TemplatePartAreaSelector, {
5479 id: template.id
5480 })), (0,external_wp_element_namespaceObject.createElement)(TemplateAreas, {
5481 closeTemplateDetailsDropdown: onClose
5482 }), isTemplateRevertable(template) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
5483 className: "edit-site-template-details__group edit-site-template-details__revert"
5484 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5485 className: "edit-site-template-details__revert-button",
5486 info: (0,external_wp_i18n_namespaceObject.__)('Use the template as supplied by the theme.'),
5487 onClick: revert
5488 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, extends_extends({
5489 className: "edit-site-template-details__show-all-button"
5490 }, browseAllLinkProps), (template === null || template === void 0 ? void 0 : template.type) === 'wp_template' ? (0,external_wp_i18n_namespaceObject.__)('Browse all templates') : (0,external_wp_i18n_namespaceObject.__)('Browse all template parts')));
5491 }
5492
5493 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/document-actions/index.js
5494
5495
5496 /**
5497 * External dependencies
5498 */
5499
5500 /**
5501 * WordPress dependencies
5502 */
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515 /**
5516 * Internal dependencies
5517 */
5518
5519
5520
5521
5522 function getBlockDisplayText(block) {
5523 if (block) {
5524 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
5525 return blockType ? (0,external_wp_blocks_namespaceObject.__experimentalGetBlockLabel)(blockType, block.attributes) : null;
5526 }
5527
5528 return null;
5529 }
5530
5531 function useSecondaryText() {
5532 const {
5533 getBlock
5534 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
5535 const activeEntityBlockId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).__experimentalGetActiveBlockIdByBlockNames(['core/template-part']), []);
5536 const blockInformation = (0,external_wp_blockEditor_namespaceObject.useBlockDisplayInformation)(activeEntityBlockId);
5537
5538 if (activeEntityBlockId) {
5539 return {
5540 label: getBlockDisplayText(getBlock(activeEntityBlockId)),
5541 isActive: true,
5542 icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon
5543 };
5544 }
5545
5546 return {};
5547 }
5548
5549 function DocumentActions() {
5550 const {
5551 showIconLabels,
5552 entityTitle,
5553 template,
5554 templateType,
5555 isLoaded
5556 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5557 const {
5558 getEditedPostType,
5559 getEditedPostId
5560 } = select(store_store);
5561 const {
5562 getEditedEntityRecord
5563 } = select(external_wp_coreData_namespaceObject.store);
5564 const {
5565 __experimentalGetTemplateInfo: getTemplateInfo
5566 } = select(external_wp_editor_namespaceObject.store);
5567 const postType = getEditedPostType();
5568 const postId = getEditedPostId();
5569 const record = getEditedEntityRecord('postType', postType, postId);
5570
5571 const _isLoaded = !!postId;
5572
5573 return {
5574 showIconLabels: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showIconLabels'),
5575 entityTitle: getTemplateInfo(record).title,
5576 isLoaded: _isLoaded,
5577 template: record,
5578 templateType: postType
5579 };
5580 }, []);
5581 const entityLabel = templateType === 'wp_template_part' ? 'template part' : 'template';
5582 const {
5583 label,
5584 icon
5585 } = useSecondaryText(); // Use internal state instead of a ref to make sure that the component
5586 // re-renders when the popover's anchor updates.
5587
5588 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null); // Memoize popoverProps to avoid returning a new object every time.
5589
5590 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
5591 // Use the title wrapper as the popover anchor so that the dropdown is
5592 // centered over the whole title area rather than just one part of it.
5593 anchor: popoverAnchor
5594 }), [popoverAnchor]); // Return a simple loading indicator until we have information to show.
5595
5596 if (!isLoaded) {
5597 return (0,external_wp_element_namespaceObject.createElement)("div", {
5598 className: "edit-site-document-actions"
5599 }, (0,external_wp_i18n_namespaceObject.__)('Loading…'));
5600 } // Return feedback that the template does not seem to exist.
5601
5602
5603 if (!entityTitle) {
5604 return (0,external_wp_element_namespaceObject.createElement)("div", {
5605 className: "edit-site-document-actions"
5606 }, (0,external_wp_i18n_namespaceObject.__)('Template not found'));
5607 }
5608
5609 return (0,external_wp_element_namespaceObject.createElement)("div", {
5610 className: classnames_default()('edit-site-document-actions', {
5611 'has-secondary-label': !!label
5612 })
5613 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5614 ref: setPopoverAnchor,
5615 className: "edit-site-document-actions__title-wrapper"
5616 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5617 size: "body",
5618 className: "edit-site-document-actions__title",
5619 as: "h1"
5620 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
5621 as: "span"
5622 }, (0,external_wp_i18n_namespaceObject.sprintf)(
5623 /* translators: %s: the entity being edited, like "template"*/
5624 (0,external_wp_i18n_namespaceObject.__)('Editing %s: '), entityLabel)), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityTitle)), (0,external_wp_element_namespaceObject.createElement)("div", {
5625 className: "edit-site-document-actions__secondary-item"
5626 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, {
5627 icon: icon,
5628 showColors: true
5629 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5630 size: "body"
5631 }, label !== null && label !== void 0 ? label : '')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
5632 popoverProps: popoverProps,
5633 position: "bottom center",
5634 renderToggle: _ref => {
5635 let {
5636 isOpen,
5637 onToggle
5638 } = _ref;
5639 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5640 className: "edit-site-document-actions__get-info",
5641 icon: chevron_down,
5642 "aria-expanded": isOpen,
5643 "aria-haspopup": "true",
5644 onClick: onToggle,
5645 variant: showIconLabels ? 'tertiary' : undefined,
5646 label: (0,external_wp_i18n_namespaceObject.sprintf)(
5647 /* translators: %s: the entity to see details about, like "template"*/
5648 (0,external_wp_i18n_namespaceObject.__)('Show %s details'), entityLabel)
5649 }, showIconLabels && (0,external_wp_i18n_namespaceObject.__)('Details'));
5650 },
5651 contentClassName: "edit-site-document-actions__info-dropdown",
5652 renderContent: _ref2 => {
5653 let {
5654 onClose
5655 } = _ref2;
5656 return (0,external_wp_element_namespaceObject.createElement)(TemplateDetails, {
5657 template: template,
5658 onClose: onClose
5659 });
5660 }
5661 })));
5662 }
5663
5664 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/index.js
5665
5666
5667 /**
5668 * External dependencies
5669 */
5670
5671 /**
5672 * WordPress dependencies
5673 */
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685 /**
5686 * Internal dependencies
5687 */
5688
5689
5690
5691
5692
5693
5694
5695
5696 const preventDefault = event => {
5697 event.preventDefault();
5698 };
5699
5700 function Header(_ref) {
5701 var _window;
5702
5703 let {
5704 showIconLabels
5705 } = _ref;
5706 const inserterButton = (0,external_wp_element_namespaceObject.useRef)();
5707 const {
5708 deviceType,
5709 templateType,
5710 isInserterOpen,
5711 isListViewOpen,
5712 listViewShortcut,
5713 isVisualMode,
5714 blockEditorMode,
5715 homeUrl
5716 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5717 var _getUnstableBase;
5718
5719 const {
5720 __experimentalGetPreviewDeviceType,
5721 getEditedPostType,
5722 isInserterOpened,
5723 isListViewOpened,
5724 getEditorMode
5725 } = select(store_store);
5726 const {
5727 getShortcutRepresentation
5728 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
5729 const {
5730 __unstableGetEditorMode
5731 } = select(external_wp_blockEditor_namespaceObject.store);
5732 const postType = getEditedPostType();
5733 const {
5734 getUnstableBase // Site index.
5735
5736 } = select(external_wp_coreData_namespaceObject.store);
5737 return {
5738 deviceType: __experimentalGetPreviewDeviceType(),
5739 templateType: postType,
5740 isInserterOpen: isInserterOpened(),
5741 isListViewOpen: isListViewOpened(),
5742 listViewShortcut: getShortcutRepresentation('core/edit-site/toggle-list-view'),
5743 isVisualMode: getEditorMode() === 'visual',
5744 blockEditorMode: __unstableGetEditorMode(),
5745 homeUrl: (_getUnstableBase = getUnstableBase()) === null || _getUnstableBase === void 0 ? void 0 : _getUnstableBase.home
5746 };
5747 }, []);
5748 const {
5749 __experimentalSetPreviewDeviceType: setPreviewDeviceType,
5750 setIsInserterOpened,
5751 setIsListViewOpened
5752 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5753 const {
5754 __unstableSetEditorMode
5755 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
5756 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
5757 const openInserter = (0,external_wp_element_namespaceObject.useCallback)(() => {
5758 if (isInserterOpen) {
5759 // Focusing the inserter button closes the inserter popover.
5760 inserterButton.current.focus();
5761 } else {
5762 setIsInserterOpened(true);
5763 }
5764 }, [isInserterOpen, setIsInserterOpened]);
5765 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
5766 const isFocusMode = templateType === 'wp_template_part';
5767 /* translators: button label text should, if possible, be under 16 characters. */
5768
5769 const longLabel = (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button');
5770
5771 const shortLabel = !isInserterOpen ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close');
5772 const isZoomedOutViewExperimentEnabled = ((_window = window) === null || _window === void 0 ? void 0 : _window.__experimentalEnableZoomedOutView) && isVisualMode;
5773 const isZoomedOutView = blockEditorMode === 'zoom-out';
5774 return (0,external_wp_element_namespaceObject.createElement)("div", {
5775 className: "edit-site-header-edit-mode"
5776 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
5777 className: "edit-site-header-edit-mode__start",
5778 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools')
5779 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5780 className: "edit-site-header-edit-mode__toolbar"
5781 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5782 ref: inserterButton,
5783 as: external_wp_components_namespaceObject.Button,
5784 className: "edit-site-header-edit-mode__inserter-toggle",
5785 variant: "primary",
5786 isPressed: isInserterOpen,
5787 onMouseDown: preventDefault,
5788 onClick: openInserter,
5789 disabled: !isVisualMode,
5790 icon: library_plus,
5791 label: showIconLabels ? shortLabel : longLabel,
5792 showTooltip: !showIconLabels
5793 }), isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5794 as: external_wp_blockEditor_namespaceObject.ToolSelector,
5795 showTooltip: !showIconLabels,
5796 variant: showIconLabels ? 'tertiary' : undefined,
5797 disabled: !isVisualMode
5798 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5799 as: undo_redo_undo,
5800 showTooltip: !showIconLabels,
5801 variant: showIconLabels ? 'tertiary' : undefined
5802 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5803 as: undo_redo_redo,
5804 showTooltip: !showIconLabels,
5805 variant: showIconLabels ? 'tertiary' : undefined
5806 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5807 as: external_wp_components_namespaceObject.Button,
5808 className: "edit-site-header-edit-mode__list-view-toggle",
5809 disabled: !isVisualMode && isZoomedOutView,
5810 icon: list_view,
5811 isPressed: isListViewOpen
5812 /* translators: button label text should, if possible, be under 16 characters. */
5813 ,
5814 label: (0,external_wp_i18n_namespaceObject.__)('List View'),
5815 onClick: toggleListView,
5816 shortcut: listViewShortcut,
5817 showTooltip: !showIconLabels,
5818 variant: showIconLabels ? 'tertiary' : undefined
5819 }), isZoomedOutViewExperimentEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5820 as: external_wp_components_namespaceObject.Button,
5821 icon: chevron_up_down,
5822 isPressed: isZoomedOutView
5823 /* translators: button label text should, if possible, be under 16 characters. */
5824 ,
5825 label: (0,external_wp_i18n_namespaceObject.__)('Zoom-out View'),
5826 onClick: () => {
5827 setPreviewDeviceType('desktop');
5828
5829 __unstableSetEditorMode(isZoomedOutView ? 'edit' : 'zoom-out');
5830 }
5831 })))), (0,external_wp_element_namespaceObject.createElement)("div", {
5832 className: "edit-site-header-edit-mode__center"
5833 }, (0,external_wp_element_namespaceObject.createElement)(DocumentActions, null)), (0,external_wp_element_namespaceObject.createElement)("div", {
5834 className: "edit-site-header-edit-mode__end"
5835 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5836 className: "edit-site-header-edit-mode__actions"
5837 }, !isFocusMode && (0,external_wp_element_namespaceObject.createElement)("div", {
5838 className: classnames_default()('edit-site-header-edit-mode__preview-options', {
5839 'is-zoomed-out': isZoomedOutView
5840 })
5841 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalPreviewOptions, {
5842 deviceType: deviceType,
5843 setDeviceType: setPreviewDeviceType
5844 /* translators: button label text should, if possible, be under 16 characters. */
5845 ,
5846 viewLabel: (0,external_wp_i18n_namespaceObject.__)('View')
5847 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5848 href: homeUrl,
5849 target: "_blank",
5850 icon: library_external
5851 }, (0,external_wp_i18n_namespaceObject.__)('View site'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
5852 as: "span"
5853 },
5854 /* translators: accessibility text */
5855 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')))))), (0,external_wp_element_namespaceObject.createElement)(SaveButton, null), (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, {
5856 scope: "core/edit-site"
5857 }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, {
5858 showIconLabels: showIconLabels
5859 }))));
5860 }
5861
5862 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drawer-left.js
5863
5864
5865 /**
5866 * WordPress dependencies
5867 */
5868
5869 const drawerLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5870 width: "24",
5871 height: "24",
5872 xmlns: "http://www.w3.org/2000/svg",
5873 viewBox: "0 0 24 24"
5874 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5875 fillRule: "evenodd",
5876 clipRule: "evenodd",
5877 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z"
5878 }));
5879 /* harmony default export */ var drawer_left = (drawerLeft);
5880
5881 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drawer-right.js
5882
5883
5884 /**
5885 * WordPress dependencies
5886 */
5887
5888 const drawerRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5889 width: "24",
5890 height: "24",
5891 xmlns: "http://www.w3.org/2000/svg",
5892 viewBox: "0 0 24 24"
5893 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5894 fillRule: "evenodd",
5895 clipRule: "evenodd",
5896 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z"
5897 }));
5898 /* harmony default export */ var drawer_right = (drawerRight);
5899
5900 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/default-sidebar.js
5901
5902
5903 /**
5904 * WordPress dependencies
5905 */
5906
5907
5908 /**
5909 * Internal dependencies
5910 */
5911
5912
5913 function DefaultSidebar(_ref) {
5914 let {
5915 className,
5916 identifier,
5917 title,
5918 icon,
5919 children,
5920 closeLabel,
5921 header,
5922 headerClassName,
5923 panelClassName
5924 } = _ref;
5925 const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getSettings().showIconLabels, []);
5926 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(complementary_area, {
5927 className: className,
5928 scope: "core/edit-site",
5929 identifier: identifier,
5930 title: title,
5931 icon: icon,
5932 closeLabel: closeLabel,
5933 header: header,
5934 headerClassName: headerClassName,
5935 panelClassName: panelClassName,
5936 showIconLabels: showIconLabels
5937 }, children), (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
5938 scope: "core/edit-site",
5939 identifier: identifier,
5940 icon: icon
5941 }, title));
5942 }
5943
5944 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/styles.js
5945
5946
5947 /**
5948 * WordPress dependencies
5949 */
5950
5951 const styles = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5952 viewBox: "0 0 24 24",
5953 xmlns: "http://www.w3.org/2000/svg"
5954 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5955 d: "M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z"
5956 }));
5957 /* harmony default export */ var library_styles = (styles);
5958
5959 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/icon-with-current-color.js
5960
5961
5962
5963 /**
5964 * External dependencies
5965 */
5966
5967 /**
5968 * WordPress dependencies
5969 */
5970
5971
5972 function IconWithCurrentColor(_ref) {
5973 let {
5974 className,
5975 ...props
5976 } = _ref;
5977 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, extends_extends({
5978 className: classnames_default()(className, 'edit-site-global-styles-icon-with-current-color')
5979 }, props));
5980 }
5981
5982 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/navigation-button.js
5983
5984
5985
5986 /**
5987 * WordPress dependencies
5988 */
5989
5990 /**
5991 * Internal dependencies
5992 */
5993
5994
5995
5996 function GenericNavigationButton(_ref) {
5997 let {
5998 icon,
5999 children,
6000 ...props
6001 } = _ref;
6002 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, props, icon && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
6003 justify: "flex-start"
6004 }, (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, {
6005 icon: icon,
6006 size: 24
6007 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, children)), !icon && children);
6008 }
6009
6010 function NavigationButtonAsItem(props) {
6011 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, extends_extends({
6012 as: GenericNavigationButton
6013 }, props));
6014 }
6015
6016 function NavigationBackButtonAsItem(props) {
6017 return createElement(NavigatorBackButton, _extends({
6018 as: GenericNavigationButton
6019 }, props));
6020 }
6021
6022
6023
6024 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/typography.js
6025
6026
6027 /**
6028 * WordPress dependencies
6029 */
6030
6031 const typography = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
6032 xmlns: "http://www.w3.org/2000/svg",
6033 viewBox: "0 0 24 24"
6034 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
6035 d: "M6.9 7L3 17.8h1.7l1-2.8h4.1l1 2.8h1.7L8.6 7H6.9zm-.7 6.6l1.5-4.3 1.5 4.3h-3zM21.6 17c-.1.1-.2.2-.3.2-.1.1-.2.1-.4.1s-.3-.1-.4-.2c-.1-.1-.1-.3-.1-.6V12c0-.5 0-1-.1-1.4-.1-.4-.3-.7-.5-1-.2-.2-.5-.4-.9-.5-.4 0-.8-.1-1.3-.1s-1 .1-1.4.2c-.4.1-.7.3-1 .4-.2.2-.4.3-.6.5-.1.2-.2.4-.2.7 0 .3.1.5.2.8.2.2.4.3.8.3.3 0 .6-.1.8-.3.2-.2.3-.4.3-.7 0-.3-.1-.5-.2-.7-.2-.2-.4-.3-.6-.4.2-.2.4-.3.7-.4.3-.1.6-.1.8-.1.3 0 .6 0 .8.1.2.1.4.3.5.5.1.2.2.5.2.9v1.1c0 .3-.1.5-.3.6-.2.2-.5.3-.9.4-.3.1-.7.3-1.1.4-.4.1-.8.3-1.1.5-.3.2-.6.4-.8.7-.2.3-.3.7-.3 1.2 0 .6.2 1.1.5 1.4.3.4.9.5 1.6.5.5 0 1-.1 1.4-.3.4-.2.8-.6 1.1-1.1 0 .4.1.7.3 1 .2.3.6.4 1.2.4.4 0 .7-.1.9-.2.2-.1.5-.3.7-.4h-.3zm-3-.9c-.2.4-.5.7-.8.8-.3.2-.6.2-.8.2-.4 0-.6-.1-.9-.3-.2-.2-.3-.6-.3-1.1 0-.5.1-.9.3-1.2s.5-.5.8-.7c.3-.2.7-.3 1-.5.3-.1.6-.3.7-.6v3.4z"
6036 }));
6037 /* harmony default export */ var library_typography = (typography);
6038
6039 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/color.js
6040
6041
6042 /**
6043 * WordPress dependencies
6044 */
6045
6046 const color = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
6047 viewBox: "0 0 24 24",
6048 xmlns: "http://www.w3.org/2000/svg"
6049 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
6050 d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z"
6051 }));
6052 /* harmony default export */ var library_color = (color);
6053
6054 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
6055
6056
6057 /**
6058 * WordPress dependencies
6059 */
6060
6061 const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
6062 xmlns: "http://www.w3.org/2000/svg",
6063 viewBox: "0 0 24 24"
6064 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
6065 d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
6066 }));
6067 /* harmony default export */ var library_layout = (layout);
6068
6069 ;// CONCATENATED MODULE: ./packages/edit-site/node_modules/colord/index.mjs
6070 var colord_r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(colord_r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},colord_I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},colord_H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(colord_H(this.rgba),2)},r.prototype.isDark=function(){return colord_H(this.rgba)<.5},r.prototype.isLight=function(){return colord_H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},colord_E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};
6071
6072 ;// CONCATENATED MODULE: ./packages/edit-site/node_modules/colord/plugins/a11y.mjs
6073 var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}}
6074
6075 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/typography-utils.js
6076 /**
6077 * The fluid utilities must match the backend equivalent.
6078 * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php
6079 * ---------------------------------------------------------------
6080 */
6081
6082 /**
6083 * WordPress dependencies
6084 */
6085
6086 /**
6087 * @typedef {Object} FluidPreset
6088 * @property {string|undefined} max A maximum font size value.
6089 * @property {?string|undefined} min A minimum font size value.
6090 */
6091
6092 /**
6093 * @typedef {Object} Preset
6094 * @property {?string|?number} size A default font size.
6095 * @property {string} name A font size name, displayed in the UI.
6096 * @property {string} slug A font size slug
6097 * @property {boolean|FluidPreset|undefined} fluid A font size slug
6098 */
6099
6100 /**
6101 * Returns a font-size value based on a given font-size preset.
6102 * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.
6103 *
6104 * @param {Preset} preset
6105 * @param {Object} typographySettings
6106 * @param {boolean} typographySettings.fluid Whether fluid typography is enabled.
6107 *
6108 * @return {string|*} A font-size value or the value of preset.size.
6109 */
6110
6111 function getTypographyFontSizeValue(preset, typographySettings) {
6112 var _preset$fluid, _preset$fluid2;
6113
6114 const {
6115 size: defaultSize
6116 } = preset;
6117 /*
6118 * Catches falsy values and 0/'0'.
6119 * Fluid calculations cannot be performed on 0.
6120 */
6121
6122 if (!defaultSize || '0' === defaultSize) {
6123 return defaultSize;
6124 }
6125
6126 if (true !== (typographySettings === null || typographySettings === void 0 ? void 0 : typographySettings.fluid)) {
6127 return defaultSize;
6128 } // A font size has explicitly bypassed fluid calculations.
6129
6130
6131 if (false === (preset === null || preset === void 0 ? void 0 : preset.fluid)) {
6132 return defaultSize;
6133 }
6134
6135 const fluidFontSizeValue = (0,external_wp_blockEditor_namespaceObject.getComputedFluidTypographyValue)({
6136 minimumFontSize: preset === null || preset === void 0 ? void 0 : (_preset$fluid = preset.fluid) === null || _preset$fluid === void 0 ? void 0 : _preset$fluid.min,
6137 maximumFontSize: preset === null || preset === void 0 ? void 0 : (_preset$fluid2 = preset.fluid) === null || _preset$fluid2 === void 0 ? void 0 : _preset$fluid2.max,
6138 fontSize: defaultSize
6139 });
6140
6141 if (!!fluidFontSizeValue) {
6142 return fluidFontSizeValue;
6143 }
6144
6145 return defaultSize;
6146 }
6147
6148 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/utils.js
6149 /**
6150 * External dependencies
6151 */
6152
6153 /**
6154 * Internal dependencies
6155 */
6156
6157
6158 /* Supporting data. */
6159
6160 const ROOT_BLOCK_NAME = 'root';
6161 const ROOT_BLOCK_SELECTOR = 'body';
6162 const ROOT_BLOCK_SUPPORTS = (/* unused pure expression or super */ null && (['background', 'backgroundColor', 'color', 'linkColor', 'buttonColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform', 'padding']));
6163 const PRESET_METADATA = [{
6164 path: ['color', 'palette'],
6165 valueKey: 'color',
6166 cssVarInfix: 'color',
6167 classes: [{
6168 classSuffix: 'color',
6169 propertyName: 'color'
6170 }, {
6171 classSuffix: 'background-color',
6172 propertyName: 'background-color'
6173 }, {
6174 classSuffix: 'border-color',
6175 propertyName: 'border-color'
6176 }]
6177 }, {
6178 path: ['color', 'gradients'],
6179 valueKey: 'gradient',
6180 cssVarInfix: 'gradient',
6181 classes: [{
6182 classSuffix: 'gradient-background',
6183 propertyName: 'background'
6184 }]
6185 }, {
6186 path: ['color', 'duotone'],
6187 cssVarInfix: 'duotone',
6188 valueFunc: _ref => {
6189 let {
6190 slug
6191 } = _ref;
6192 return `url( '#wp-duotone-${slug}' )`;
6193 },
6194 classes: []
6195 }, {
6196 path: ['typography', 'fontSizes'],
6197 valueFunc: (preset, _ref2) => {
6198 let {
6199 typography: typographySettings
6200 } = _ref2;
6201 return getTypographyFontSizeValue(preset, typographySettings);
6202 },
6203 valueKey: 'size',
6204 cssVarInfix: 'font-size',
6205 classes: [{
6206 classSuffix: 'font-size',
6207 propertyName: 'font-size'
6208 }]
6209 }, {
6210 path: ['typography', 'fontFamilies'],
6211 valueKey: 'fontFamily',
6212 cssVarInfix: 'font-family',
6213 classes: [{
6214 classSuffix: 'font-family',
6215 propertyName: 'font-family'
6216 }]
6217 }, {
6218 path: ['spacing', 'spacingSizes'],
6219 valueKey: 'size',
6220 cssVarInfix: 'spacing',
6221 valueFunc: _ref3 => {
6222 let {
6223 size
6224 } = _ref3;
6225 return size;
6226 },
6227 classes: []
6228 }];
6229 const STYLE_PATH_TO_CSS_VAR_INFIX = {
6230 'color.background': 'color',
6231 'color.text': 'color',
6232 'elements.link.color.text': 'color',
6233 'elements.button.color.text': 'color',
6234 'elements.button.backgroundColor': 'background-color',
6235 'elements.heading.color': 'color',
6236 'elements.heading.backgroundColor': 'background-color',
6237 'elements.heading.gradient': 'gradient',
6238 'color.gradient': 'gradient',
6239 'typography.fontSize': 'font-size',
6240 'typography.fontFamily': 'font-family'
6241 };
6242
6243 function findInPresetsBy(features, blockName, presetPath, presetProperty, presetValueValue) {
6244 // Block presets take priority above root level presets.
6245 const orderedPresetsByOrigin = [(0,external_lodash_namespaceObject.get)(features, ['blocks', blockName, ...presetPath]), (0,external_lodash_namespaceObject.get)(features, presetPath)];
6246
6247 for (const presetByOrigin of orderedPresetsByOrigin) {
6248 if (presetByOrigin) {
6249 // Preset origins ordered by priority.
6250 const origins = ['custom', 'theme', 'default'];
6251
6252 for (const origin of origins) {
6253 const presets = presetByOrigin[origin];
6254
6255 if (presets) {
6256 const presetObject = (0,external_lodash_namespaceObject.find)(presets, preset => preset[presetProperty] === presetValueValue);
6257
6258 if (presetObject) {
6259 if (presetProperty === 'slug') {
6260 return presetObject;
6261 } // If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
6262
6263
6264 const highestPresetObjectWithSameSlug = findInPresetsBy(features, blockName, presetPath, 'slug', presetObject.slug);
6265
6266 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) {
6267 return presetObject;
6268 }
6269
6270 return undefined;
6271 }
6272 }
6273 }
6274 }
6275 }
6276 }
6277
6278 function getPresetVariableFromValue(features, blockName, variableStylePath, presetPropertyValue) {
6279 if (!presetPropertyValue) {
6280 return presetPropertyValue;
6281 }
6282
6283 const cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[variableStylePath];
6284 const metadata = (0,external_lodash_namespaceObject.find)(PRESET_METADATA, ['cssVarInfix', cssVarInfix]);
6285
6286 if (!metadata) {
6287 // The property doesn't have preset data
6288 // so the value should be returned as it is.
6289 return presetPropertyValue;
6290 }
6291
6292 const {
6293 valueKey,
6294 path
6295 } = metadata;
6296 const presetObject = findInPresetsBy(features, blockName, path, valueKey, presetPropertyValue);
6297
6298 if (!presetObject) {
6299 // Value wasn't found in the presets,
6300 // so it must be a custom value.
6301 return presetPropertyValue;
6302 }
6303
6304 return `var:preset|${cssVarInfix}|${presetObject.slug}`;
6305 }
6306
6307 function getValueFromPresetVariable(features, blockName, variable, _ref4) {
6308 let [presetType, slug] = _ref4;
6309 const metadata = (0,external_lodash_namespaceObject.find)(PRESET_METADATA, ['cssVarInfix', presetType]);
6310
6311 if (!metadata) {
6312 return variable;
6313 }
6314
6315 const presetObject = findInPresetsBy(features.settings, blockName, metadata.path, 'slug', slug);
6316
6317 if (presetObject) {
6318 const {
6319 valueKey
6320 } = metadata;
6321 const result = presetObject[valueKey];
6322 return getValueFromVariable(features, blockName, result);
6323 }
6324
6325 return variable;
6326 }
6327
6328 function getValueFromCustomVariable(features, blockName, variable, path) {
6329 var _get;
6330
6331 const result = (_get = (0,external_lodash_namespaceObject.get)(features.settings, ['blocks', blockName, 'custom', ...path])) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(features.settings, ['custom', ...path]);
6332
6333 if (!result) {
6334 return variable;
6335 } // A variable may reference another variable so we need recursion until we find the value.
6336
6337
6338 return getValueFromVariable(features, blockName, result);
6339 }
6340 /**
6341 * Attempts to fetch the value of a theme.json CSS variable.
6342 *
6343 * @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.
6344 * @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.
6345 * @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.
6346 * @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.
6347 */
6348
6349
6350 function getValueFromVariable(features, blockName, variable) {
6351 if (!variable || typeof variable !== 'string') {
6352 var _variable, _variable2;
6353
6354 if ((_variable = variable) !== null && _variable !== void 0 && _variable.ref && typeof ((_variable2 = variable) === null || _variable2 === void 0 ? void 0 : _variable2.ref) === 'string') {
6355 var _variable3;
6356
6357 const refPath = variable.ref.split('.');
6358 variable = (0,external_lodash_namespaceObject.get)(features, refPath); // Presence of another ref indicates a reference to another dynamic value.
6359 // Pointing to another dynamic value is not supported.
6360
6361 if (!variable || !!((_variable3 = variable) !== null && _variable3 !== void 0 && _variable3.ref)) {
6362 return variable;
6363 }
6364 } else {
6365 return variable;
6366 }
6367 }
6368
6369 const USER_VALUE_PREFIX = 'var:';
6370 const THEME_VALUE_PREFIX = 'var(--wp--';
6371 const THEME_VALUE_SUFFIX = ')';
6372 let parsedVar;
6373
6374 if (variable.startsWith(USER_VALUE_PREFIX)) {
6375 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split('|');
6376 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) {
6377 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split('--');
6378 } else {
6379 // We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`
6380 return variable;
6381 }
6382
6383 const [type, ...path] = parsedVar;
6384
6385 if (type === 'preset') {
6386 return getValueFromPresetVariable(features, blockName, variable, path);
6387 }
6388
6389 if (type === 'custom') {
6390 return getValueFromCustomVariable(features, blockName, variable, path);
6391 }
6392
6393 return variable;
6394 }
6395 /**
6396 * Function that scopes a selector with another one. This works a bit like
6397 * SCSS nesting except the `&` operator isn't supported.
6398 *
6399 * @example
6400 * ```js
6401 * const scope = '.a, .b .c';
6402 * const selector = '> .x, .y';
6403 * const merged = scopeSelector( scope, selector );
6404 * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
6405 * ```
6406 *
6407 * @param {string} scope Selector to scope to.
6408 * @param {string} selector Original selector.
6409 *
6410 * @return {string} Scoped selector.
6411 */
6412
6413 function scopeSelector(scope, selector) {
6414 const scopes = scope.split(',');
6415 const selectors = selector.split(',');
6416 const selectorsScoped = [];
6417 scopes.forEach(outer => {
6418 selectors.forEach(inner => {
6419 selectorsScoped.push(`${outer.trim()} ${inner.trim()}`);
6420 });
6421 });
6422 return selectorsScoped.join(', ');
6423 }
6424
6425 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/context.js
6426 /**
6427 * WordPress dependencies
6428 */
6429
6430 const DEFAULT_GLOBAL_STYLES_CONTEXT = {
6431 user: {},
6432 base: {},
6433 merged: {},
6434 setUserConfig: () => {}
6435 };
6436 const GlobalStylesContext = (0,external_wp_element_namespaceObject.createContext)(DEFAULT_GLOBAL_STYLES_CONTEXT);
6437
6438 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/hooks.js
6439 /**
6440 * External dependencies
6441 */
6442
6443
6444
6445 /**
6446 * WordPress dependencies
6447 */
6448
6449
6450
6451
6452 /**
6453 * Internal dependencies
6454 */
6455
6456
6457 // Enable colord's a11y plugin.
6458
6459 k([a11y]);
6460 const EMPTY_CONFIG = {
6461 settings: {},
6462 styles: {}
6463 };
6464 const useGlobalStylesReset = () => {
6465 const {
6466 user: config,
6467 setUserConfig
6468 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
6469 const canReset = !!config && !(0,external_lodash_namespaceObject.isEqual)(config, EMPTY_CONFIG);
6470 return [canReset, (0,external_wp_element_namespaceObject.useCallback)(() => setUserConfig(() => EMPTY_CONFIG), [setUserConfig])];
6471 };
6472 function useSetting(path, blockName) {
6473 var _getSettingValueForCo;
6474
6475 let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
6476 const {
6477 merged: mergedConfig,
6478 base: baseConfig,
6479 user: userConfig,
6480 setUserConfig
6481 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
6482 const fullPath = !blockName ? `settings.${path}` : `settings.blocks.${blockName}.${path}`;
6483
6484 const setSetting = newValue => {
6485 setUserConfig(currentConfig => {
6486 // Deep clone `currentConfig` to avoid mutating it later.
6487 const newUserConfig = JSON.parse(JSON.stringify(currentConfig));
6488 const pathToSet = external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[path] ? fullPath + '.custom' : fullPath;
6489 (0,external_lodash_namespaceObject.set)(newUserConfig, pathToSet, newValue);
6490 return newUserConfig;
6491 });
6492 };
6493
6494 const getSettingValueForContext = name => {
6495 const currentPath = !name ? `settings.${path}` : `settings.blocks.${name}.${path}`;
6496
6497 const getSettingValue = configToUse => {
6498 const result = (0,external_lodash_namespaceObject.get)(configToUse, currentPath);
6499
6500 if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[path]) {
6501 var _ref, _result$custom;
6502
6503 return (_ref = (_result$custom = result === null || result === void 0 ? void 0 : result.custom) !== null && _result$custom !== void 0 ? _result$custom : result === null || result === void 0 ? void 0 : result.theme) !== null && _ref !== void 0 ? _ref : result === null || result === void 0 ? void 0 : result.default;
6504 }
6505
6506 return result;
6507 };
6508
6509 let result;
6510
6511 switch (source) {
6512 case 'all':
6513 result = getSettingValue(mergedConfig);
6514 break;
6515
6516 case 'user':
6517 result = getSettingValue(userConfig);
6518 break;
6519
6520 case 'base':
6521 result = getSettingValue(baseConfig);
6522 break;
6523
6524 default:
6525 throw 'Unsupported source';
6526 }
6527
6528 return result;
6529 }; // Unlike styles settings get inherited from top level settings.
6530
6531
6532 const resultWithFallback = (_getSettingValueForCo = getSettingValueForContext(blockName)) !== null && _getSettingValueForCo !== void 0 ? _getSettingValueForCo : getSettingValueForContext();
6533 return [resultWithFallback, setSetting];
6534 }
6535 function useStyle(path, blockName) {
6536 var _get;
6537
6538 let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
6539 const {
6540 merged: mergedConfig,
6541 base: baseConfig,
6542 user: userConfig,
6543 setUserConfig
6544 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
6545 const finalPath = !blockName ? `styles.${path}` : `styles.blocks.${blockName}.${path}`;
6546
6547 const setStyle = newValue => {
6548 setUserConfig(currentConfig => {
6549 // Deep clone `currentConfig` to avoid mutating it later.
6550 const newUserConfig = JSON.parse(JSON.stringify(currentConfig));
6551 (0,external_lodash_namespaceObject.set)(newUserConfig, finalPath, getPresetVariableFromValue(mergedConfig.settings, blockName, path, newValue));
6552 return newUserConfig;
6553 });
6554 };
6555
6556 let result;
6557
6558 switch (source) {
6559 case 'all':
6560 result = getValueFromVariable(mergedConfig, blockName, (_get = (0,external_lodash_namespaceObject.get)(userConfig, finalPath)) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(baseConfig, finalPath));
6561 break;
6562
6563 case 'user':
6564 result = getValueFromVariable(mergedConfig, blockName, (0,external_lodash_namespaceObject.get)(userConfig, finalPath));
6565 break;
6566
6567 case 'base':
6568 result = getValueFromVariable(baseConfig, blockName, (0,external_lodash_namespaceObject.get)(baseConfig, finalPath));
6569 break;
6570
6571 default:
6572 throw 'Unsupported source';
6573 }
6574
6575 return [result, setStyle];
6576 }
6577 const hooks_ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'buttonColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'padding', 'contentSize', 'wideSize', 'blockGap'];
6578 function getSupportedGlobalStylesPanels(name) {
6579 var _blockType$supports, _blockType$supports$s, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports3$, _blockType$supports3$2, _blockType$supports3$3;
6580
6581 if (!name) {
6582 return hooks_ROOT_BLOCK_SUPPORTS;
6583 }
6584
6585 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
6586
6587 if (!blockType) {
6588 return [];
6589 }
6590
6591 const supportKeys = []; // Check for blockGap support.
6592 // Block spacing support doesn't map directly to a single style property, so needs to be handled separately.
6593 // Also, only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.
6594
6595 if (blockType !== null && blockType !== void 0 && (_blockType$supports = blockType.supports) !== null && _blockType$supports !== void 0 && (_blockType$supports$s = _blockType$supports.spacing) !== null && _blockType$supports$s !== void 0 && _blockType$supports$s.blockGap && (blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.spacing) === null || _blockType$supports2$ === void 0 ? void 0 : _blockType$supports2$.__experimentalSkipSerialization) !== true && !(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && (_blockType$supports3$ = _blockType$supports3.spacing) !== null && _blockType$supports3$ !== void 0 && (_blockType$supports3$2 = _blockType$supports3$.__experimentalSkipSerialization) !== null && _blockType$supports3$2 !== void 0 && (_blockType$supports3$3 = _blockType$supports3$2.some) !== null && _blockType$supports3$3 !== void 0 && _blockType$supports3$3.call(_blockType$supports3$2, spacingType => spacingType === 'blockGap'))) {
6596 supportKeys.push('blockGap');
6597 }
6598
6599 Object.keys(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY).forEach(styleName => {
6600 if (!external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) {
6601 return;
6602 } // Opting out means that, for certain support keys like background color,
6603 // blocks have to explicitly set the support value false. If the key is
6604 // unset, we still enable it.
6605
6606
6607 if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].requiresOptOut) {
6608 if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support[0] in blockType.supports && (0,external_lodash_namespaceObject.get)(blockType.supports, external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) !== false) {
6609 return supportKeys.push(styleName);
6610 }
6611 }
6612
6613 if ((0,external_lodash_namespaceObject.get)(blockType.supports, external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support, false)) {
6614 return supportKeys.push(styleName);
6615 }
6616 });
6617 return supportKeys;
6618 }
6619 function useColorsPerOrigin(name) {
6620 const [customColors] = useSetting('color.palette.custom', name);
6621 const [themeColors] = useSetting('color.palette.theme', name);
6622 const [defaultColors] = useSetting('color.palette.default', name);
6623 const [shouldDisplayDefaultColors] = useSetting('color.defaultPalette');
6624 return (0,external_wp_element_namespaceObject.useMemo)(() => {
6625 const result = [];
6626
6627 if (themeColors && themeColors.length) {
6628 result.push({
6629 name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
6630 colors: themeColors
6631 });
6632 }
6633
6634 if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) {
6635 result.push({
6636 name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
6637 colors: defaultColors
6638 });
6639 }
6640
6641 if (customColors && customColors.length) {
6642 result.push({
6643 name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'),
6644 colors: customColors
6645 });
6646 }
6647
6648 return result;
6649 }, [customColors, themeColors, defaultColors]);
6650 }
6651 function useGradientsPerOrigin(name) {
6652 const [customGradients] = useSetting('color.gradients.custom', name);
6653 const [themeGradients] = useSetting('color.gradients.theme', name);
6654 const [defaultGradients] = useSetting('color.gradients.default', name);
6655 const [shouldDisplayDefaultGradients] = useSetting('color.defaultGradients');
6656 return (0,external_wp_element_namespaceObject.useMemo)(() => {
6657 const result = [];
6658
6659 if (themeGradients && themeGradients.length) {
6660 result.push({
6661 name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
6662 gradients: themeGradients
6663 });
6664 }
6665
6666 if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) {
6667 result.push({
6668 name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
6669 gradients: defaultGradients
6670 });
6671 }
6672
6673 if (customGradients && customGradients.length) {
6674 result.push({
6675 name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'),
6676 gradients: customGradients
6677 });
6678 }
6679
6680 return result;
6681 }, [customGradients, themeGradients, defaultGradients]);
6682 }
6683 function useColorRandomizer(name) {
6684 const [themeColors, setThemeColors] = useSetting('color.palette.theme', name);
6685
6686 function randomizeColors() {
6687 /* eslint-disable no-restricted-syntax */
6688 const randomRotationValue = Math.floor(Math.random() * 225);
6689 /* eslint-enable no-restricted-syntax */
6690
6691 const newColors = themeColors.map(colorObject => {
6692 const {
6693 color
6694 } = colorObject;
6695 const newColor = w(color).rotate(randomRotationValue).toHex();
6696 return { ...colorObject,
6697 color: newColor
6698 };
6699 });
6700 setThemeColors(newColors);
6701 }
6702
6703 return window.__experimentalEnableColorRandomizer ? [randomizeColors] : [];
6704 }
6705
6706 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/border-panel.js
6707
6708
6709 /**
6710 * WordPress dependencies
6711 */
6712
6713
6714
6715
6716 /**
6717 * Internal dependencies
6718 */
6719
6720
6721 function useHasBorderPanel(name) {
6722 const controls = [useHasBorderColorControl(name), useHasBorderRadiusControl(name), useHasBorderStyleControl(name), useHasBorderWidthControl(name)];
6723 return controls.some(Boolean);
6724 }
6725
6726 function useHasBorderColorControl(name) {
6727 const supports = getSupportedGlobalStylesPanels(name);
6728 return useSetting('border.color', name)[0] && supports.includes('borderColor');
6729 }
6730
6731 function useHasBorderRadiusControl(name) {
6732 const supports = getSupportedGlobalStylesPanels(name);
6733 return useSetting('border.radius', name)[0] && supports.includes('borderRadius');
6734 }
6735
6736 function useHasBorderStyleControl(name) {
6737 const supports = getSupportedGlobalStylesPanels(name);
6738 return useSetting('border.style', name)[0] && supports.includes('borderStyle');
6739 }
6740
6741 function useHasBorderWidthControl(name) {
6742 const supports = getSupportedGlobalStylesPanels(name);
6743 return useSetting('border.width', name)[0] && supports.includes('borderWidth');
6744 }
6745
6746 function applyFallbackStyle(border) {
6747 if (!border) {
6748 return border;
6749 }
6750
6751 if (!border.style && (border.color || border.width)) {
6752 return { ...border,
6753 style: 'solid'
6754 };
6755 }
6756
6757 return border;
6758 }
6759
6760 function applyAllFallbackStyles(border) {
6761 if (!border) {
6762 return border;
6763 }
6764
6765 if ((0,external_wp_components_namespaceObject.__experimentalHasSplitBorders)(border)) {
6766 return {
6767 top: applyFallbackStyle(border.top),
6768 right: applyFallbackStyle(border.right),
6769 bottom: applyFallbackStyle(border.bottom),
6770 left: applyFallbackStyle(border.left)
6771 };
6772 }
6773
6774 return applyFallbackStyle(border);
6775 }
6776
6777 function BorderPanel(_ref) {
6778 let {
6779 name
6780 } = _ref;
6781 // To better reflect if the user has customized a value we need to
6782 // ensure the style value being checked is from the `user` origin.
6783 const [userBorderStyles] = useStyle('border', name, 'user');
6784 const [border, setBorder] = useStyle('border', name);
6785 const colors = useColorsPerOrigin(name);
6786 const showBorderColor = useHasBorderColorControl(name);
6787 const showBorderStyle = useHasBorderStyleControl(name);
6788 const showBorderWidth = useHasBorderWidthControl(name); // Border radius.
6789
6790 const showBorderRadius = useHasBorderRadiusControl(name);
6791 const [borderRadiusValues, setBorderRadius] = useStyle('border.radius', name);
6792
6793 const hasBorderRadius = () => {
6794 const borderValues = userBorderStyles === null || userBorderStyles === void 0 ? void 0 : userBorderStyles.radius;
6795
6796 if (typeof borderValues === 'object') {
6797 return Object.entries(borderValues).some(Boolean);
6798 }
6799
6800 return !!borderValues;
6801 };
6802
6803 const resetBorder = () => {
6804 if (hasBorderRadius()) {
6805 return setBorder({
6806 radius: userBorderStyles.radius
6807 });
6808 }
6809
6810 setBorder(undefined);
6811 };
6812
6813 const resetAll = (0,external_wp_element_namespaceObject.useCallback)(() => setBorder(undefined), [setBorder]);
6814 const onBorderChange = (0,external_wp_element_namespaceObject.useCallback)(newBorder => {
6815 // Ensure we have a visible border style when a border width or
6816 // color is being selected.
6817 const newBorderWithStyle = applyAllFallbackStyles(newBorder); // As we can't conditionally generate styles based on if other
6818 // style properties have been set we need to force split border
6819 // definitions for user set border styles. Border radius is derived
6820 // from the same property i.e. `border.radius` if it is a string
6821 // that is used. The longhand border radii styles are only generated
6822 // if that property is an object.
6823 //
6824 // For borders (color, style, and width) those are all properties on
6825 // the `border` style property. This means if the theme.json defined
6826 // split borders and the user condenses them into a flat border or
6827 // vice-versa we'd get both sets of styles which would conflict.
6828
6829 const updatedBorder = !(0,external_wp_components_namespaceObject.__experimentalHasSplitBorders)(newBorderWithStyle) ? {
6830 top: newBorderWithStyle,
6831 right: newBorderWithStyle,
6832 bottom: newBorderWithStyle,
6833 left: newBorderWithStyle
6834 } : {
6835 color: null,
6836 style: null,
6837 width: null,
6838 ...newBorderWithStyle
6839 }; // As radius is maintained separately to color, style, and width
6840 // maintain its value. Undefined values here will be cleaned when
6841 // global styles are saved.
6842
6843 setBorder({
6844 radius: border === null || border === void 0 ? void 0 : border.radius,
6845 ...updatedBorder
6846 });
6847 }, [setBorder]);
6848 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
6849 label: (0,external_wp_i18n_namespaceObject.__)('Border'),
6850 resetAll: resetAll
6851 }, (showBorderWidth || showBorderColor) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6852 hasValue: () => (0,external_wp_components_namespaceObject.__experimentalIsDefinedBorder)(userBorderStyles),
6853 label: (0,external_wp_i18n_namespaceObject.__)('Border'),
6854 onDeselect: () => resetBorder(),
6855 isShownByDefault: true
6856 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBorderBoxControl, {
6857 colors: colors,
6858 enableAlpha: true,
6859 enableStyle: showBorderStyle,
6860 onChange: onBorderChange,
6861 popoverOffset: 40,
6862 popoverPlacement: "left-start",
6863 value: border,
6864 __experimentalHasMultipleOrigins: true,
6865 __experimentalIsRenderedInSidebar: true,
6866 size: '__unstable-large'
6867 })), showBorderRadius && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6868 hasValue: hasBorderRadius,
6869 label: (0,external_wp_i18n_namespaceObject.__)('Radius'),
6870 onDeselect: () => setBorderRadius(undefined),
6871 isShownByDefault: true
6872 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBorderRadiusControl, {
6873 values: borderRadiusValues,
6874 onChange: value => {
6875 setBorderRadius(value || undefined);
6876 }
6877 })));
6878 }
6879
6880 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-utils.js
6881 /**
6882 * Internal dependencies
6883 */
6884
6885 function useHasColorPanel(name) {
6886 const supports = getSupportedGlobalStylesPanels(name);
6887 return supports.includes('color') || supports.includes('backgroundColor') || supports.includes('background') || supports.includes('linkColor');
6888 }
6889
6890 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/position-center.js
6891
6892
6893 /**
6894 * WordPress dependencies
6895 */
6896
6897 const positionCenter = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
6898 xmlns: "http://www.w3.org/2000/svg",
6899 viewBox: "0 0 24 24"
6900 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
6901 d: "M7 9v6h10V9H7zM5 19.8h14v-1.5H5v1.5zM5 4.3v1.5h14V4.3H5z"
6902 }));
6903 /* harmony default export */ var position_center = (positionCenter);
6904
6905 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/stretch-wide.js
6906
6907
6908 /**
6909 * WordPress dependencies
6910 */
6911
6912 const stretchWide = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
6913 xmlns: "http://www.w3.org/2000/svg",
6914 viewBox: "0 0 24 24"
6915 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
6916 d: "M5 9v6h14V9H5zm11-4.8H8v1.5h8V4.2zM8 19.8h8v-1.5H8v1.5z"
6917 }));
6918 /* harmony default export */ var stretch_wide = (stretchWide);
6919
6920 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/dimensions-panel.js
6921
6922
6923 /**
6924 * External dependencies
6925 */
6926
6927 /**
6928 * WordPress dependencies
6929 */
6930
6931
6932
6933
6934
6935 /**
6936 * Internal dependencies
6937 */
6938
6939
6940 const AXIAL_SIDES = ['horizontal', 'vertical'];
6941 function useHasDimensionsPanel(name) {
6942 const hasContentSize = useHasContentSize(name);
6943 const hasWideSize = useHasWideSize(name);
6944 const hasPadding = useHasPadding(name);
6945 const hasMargin = useHasMargin(name);
6946 const hasGap = useHasGap(name);
6947 const hasMinHeight = useHasMinHeight(name);
6948 return hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap || hasMinHeight;
6949 }
6950
6951 function useHasContentSize(name) {
6952 const supports = getSupportedGlobalStylesPanels(name);
6953 const [settings] = useSetting('layout.contentSize', name);
6954 return settings && supports.includes('contentSize');
6955 }
6956
6957 function useHasWideSize(name) {
6958 const supports = getSupportedGlobalStylesPanels(name);
6959 const [settings] = useSetting('layout.wideSize', name);
6960 return settings && supports.includes('wideSize');
6961 }
6962
6963 function useHasPadding(name) {
6964 const supports = getSupportedGlobalStylesPanels(name);
6965 const [settings] = useSetting('spacing.padding', name);
6966 return settings && supports.includes('padding');
6967 }
6968
6969 function useHasMargin(name) {
6970 const supports = getSupportedGlobalStylesPanels(name);
6971 const [settings] = useSetting('spacing.margin', name);
6972 return settings && supports.includes('margin');
6973 }
6974
6975 function useHasGap(name) {
6976 const supports = getSupportedGlobalStylesPanels(name);
6977 const [settings] = useSetting('spacing.blockGap', name);
6978 return settings && supports.includes('blockGap');
6979 }
6980
6981 function useHasMinHeight(name) {
6982 const supports = getSupportedGlobalStylesPanels(name);
6983 const [settings] = useSetting('dimensions.minHeight', name);
6984 return settings && supports.includes('minHeight');
6985 }
6986
6987 function useHasSpacingPresets() {
6988 const [settings] = useSetting('spacing.spacingSizes');
6989 return settings && settings.length > 0;
6990 }
6991
6992 function filterValuesBySides(values, sides) {
6993 if (!sides) {
6994 // If no custom side configuration all sides are opted into by default.
6995 return values;
6996 } // Only include sides opted into within filtered values.
6997
6998
6999 const filteredValues = {};
7000 sides.forEach(side => {
7001 if (side === 'vertical') {
7002 filteredValues.top = values.top;
7003 filteredValues.bottom = values.bottom;
7004 }
7005
7006 if (side === 'horizontal') {
7007 filteredValues.left = values.left;
7008 filteredValues.right = values.right;
7009 }
7010
7011 filteredValues[side] = values[side];
7012 });
7013 return filteredValues;
7014 }
7015
7016 function splitStyleValue(value) {
7017 // Check for shorthand value (a string value).
7018 if (value && typeof value === 'string') {
7019 // Convert to value for individual sides for BoxControl.
7020 return {
7021 top: value,
7022 right: value,
7023 bottom: value,
7024 left: value
7025 };
7026 }
7027
7028 return value;
7029 }
7030
7031 function splitGapValue(value) {
7032 // Check for shorthand value (a string value).
7033 if (value && typeof value === 'string') {
7034 // If the value is a string, treat it as a single side (top) for the spacing controls.
7035 return {
7036 top: value
7037 };
7038 }
7039
7040 if (value) {
7041 return { ...value,
7042 right: value === null || value === void 0 ? void 0 : value.left,
7043 bottom: value === null || value === void 0 ? void 0 : value.top
7044 };
7045 }
7046
7047 return value;
7048 } // Props for managing `layout.contentSize`.
7049
7050
7051 function useContentSizeProps(name) {
7052 const [contentSizeValue, setContentSizeValue] = useSetting('layout.contentSize', name);
7053 const [userSetContentSizeValue] = useSetting('layout.contentSize', name, 'user');
7054
7055 const hasUserSetContentSizeValue = () => !!userSetContentSizeValue;
7056
7057 const resetContentSizeValue = () => setContentSizeValue('');
7058
7059 return {
7060 contentSizeValue,
7061 setContentSizeValue,
7062 hasUserSetContentSizeValue,
7063 resetContentSizeValue
7064 };
7065 } // Props for managing `layout.wideSize`.
7066
7067
7068 function useWideSizeProps(name) {
7069 const [wideSizeValue, setWideSizeValue] = useSetting('layout.wideSize', name);
7070 const [userSetWideSizeValue] = useSetting('layout.wideSize', name, 'user');
7071
7072 const hasUserSetWideSizeValue = () => !!userSetWideSizeValue;
7073
7074 const resetWideSizeValue = () => setWideSizeValue('');
7075
7076 return {
7077 wideSizeValue,
7078 setWideSizeValue,
7079 hasUserSetWideSizeValue,
7080 resetWideSizeValue
7081 };
7082 } // Props for managing `spacing.padding`.
7083
7084
7085 function usePaddingProps(name) {
7086 const [rawPadding, setRawPadding] = useStyle('spacing.padding', name);
7087 const paddingValues = splitStyleValue(rawPadding);
7088 const paddingSides = (0,external_wp_blockEditor_namespaceObject.__experimentalUseCustomSides)(name, 'padding');
7089 const isAxialPadding = paddingSides && paddingSides.some(side => AXIAL_SIDES.includes(side));
7090
7091 const setPaddingValues = newPaddingValues => {
7092 const padding = filterValuesBySides(newPaddingValues, paddingSides);
7093 setRawPadding(padding);
7094 };
7095
7096 const resetPaddingValue = () => setPaddingValues({});
7097
7098 const [userSetPaddingValue] = useStyle('spacing.padding', name, 'user'); // The `hasPaddingValue` check does not need a parsed value, as `userSetPaddingValue` will be `undefined` if not set.
7099
7100 const hasPaddingValue = () => !!userSetPaddingValue;
7101
7102 return {
7103 paddingValues,
7104 paddingSides,
7105 isAxialPadding,
7106 setPaddingValues,
7107 resetPaddingValue,
7108 hasPaddingValue
7109 };
7110 } // Props for managing `spacing.margin`.
7111
7112
7113 function useMarginProps(name) {
7114 const [rawMargin, setRawMargin] = useStyle('spacing.margin', name);
7115 const marginValues = splitStyleValue(rawMargin);
7116 const marginSides = (0,external_wp_blockEditor_namespaceObject.__experimentalUseCustomSides)(name, 'margin');
7117 const isAxialMargin = marginSides && marginSides.some(side => AXIAL_SIDES.includes(side));
7118
7119 const setMarginValues = newMarginValues => {
7120 const margin = filterValuesBySides(newMarginValues, marginSides);
7121 setRawMargin(margin);
7122 };
7123
7124 const resetMarginValue = () => setMarginValues({});
7125
7126 const hasMarginValue = () => !!marginValues && Object.keys(marginValues).length;
7127
7128 return {
7129 marginValues,
7130 marginSides,
7131 isAxialMargin,
7132 setMarginValues,
7133 resetMarginValue,
7134 hasMarginValue
7135 };
7136 } // Props for managing `spacing.blockGap`.
7137
7138
7139 function useBlockGapProps(name) {
7140 const [gapValue, setGapValue] = useStyle('spacing.blockGap', name);
7141 const gapValues = splitGapValue(gapValue);
7142 const gapSides = (0,external_wp_blockEditor_namespaceObject.__experimentalUseCustomSides)(name, 'blockGap');
7143 const isAxialGap = gapSides && gapSides.some(side => AXIAL_SIDES.includes(side));
7144
7145 const resetGapValue = () => setGapValue(undefined);
7146
7147 const [userSetGapValue] = useStyle('spacing.blockGap', name, 'user');
7148
7149 const hasGapValue = () => !!userSetGapValue;
7150
7151 const setGapValues = nextBoxGapValue => {
7152 if (!nextBoxGapValue) {
7153 setGapValue(null);
7154 } // If axial gap is not enabled, treat the 'top' value as the shorthand gap value.
7155
7156
7157 if (!isAxialGap && nextBoxGapValue !== null && nextBoxGapValue !== void 0 && nextBoxGapValue.hasOwnProperty('top')) {
7158 setGapValue(nextBoxGapValue.top);
7159 } else {
7160 setGapValue({
7161 top: nextBoxGapValue === null || nextBoxGapValue === void 0 ? void 0 : nextBoxGapValue.top,
7162 left: nextBoxGapValue === null || nextBoxGapValue === void 0 ? void 0 : nextBoxGapValue.left
7163 });
7164 }
7165 };
7166
7167 return {
7168 gapValue,
7169 gapValues,
7170 gapSides,
7171 isAxialGap,
7172 setGapValue,
7173 setGapValues,
7174 resetGapValue,
7175 hasGapValue
7176 };
7177 } // Props for managing `dimensions.minHeight`.
7178
7179
7180 function useMinHeightProps(name) {
7181 const [minHeightValue, setMinHeightValue] = useStyle('dimensions.minHeight', name);
7182
7183 const resetMinHeightValue = () => setMinHeightValue(undefined);
7184
7185 const hasMinHeightValue = () => !!minHeightValue;
7186
7187 return {
7188 minHeightValue,
7189 setMinHeightValue,
7190 resetMinHeightValue,
7191 hasMinHeightValue
7192 };
7193 }
7194
7195 function DimensionsPanel(_ref) {
7196 let {
7197 name
7198 } = _ref;
7199 const showContentSizeControl = useHasContentSize(name);
7200 const showWideSizeControl = useHasWideSize(name);
7201 const showPaddingControl = useHasPadding(name);
7202 const showMarginControl = useHasMargin(name);
7203 const showGapControl = useHasGap(name);
7204 const showMinHeightControl = useHasMinHeight(name);
7205 const showSpacingPresetsControl = useHasSpacingPresets();
7206 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
7207 availableUnits: useSetting('spacing.units', name)[0] || ['%', 'px', 'em', 'rem', 'vw']
7208 }); // Props for managing `layout.contentSize`.
7209
7210 const {
7211 contentSizeValue,
7212 setContentSizeValue,
7213 hasUserSetContentSizeValue,
7214 resetContentSizeValue
7215 } = useContentSizeProps(name); // Props for managing `layout.wideSize`.
7216
7217 const {
7218 wideSizeValue,
7219 setWideSizeValue,
7220 hasUserSetWideSizeValue,
7221 resetWideSizeValue
7222 } = useWideSizeProps(name); // Props for managing `spacing.padding`.
7223
7224 const {
7225 paddingValues,
7226 paddingSides,
7227 isAxialPadding,
7228 setPaddingValues,
7229 resetPaddingValue,
7230 hasPaddingValue
7231 } = usePaddingProps(name); // Props for managing `spacing.margin`.
7232
7233 const {
7234 marginValues,
7235 marginSides,
7236 isAxialMargin,
7237 setMarginValues,
7238 resetMarginValue,
7239 hasMarginValue
7240 } = useMarginProps(name); // Props for managing `spacing.blockGap`.
7241
7242 const {
7243 gapValue,
7244 gapValues,
7245 gapSides,
7246 isAxialGap,
7247 setGapValue,
7248 setGapValues,
7249 resetGapValue,
7250 hasGapValue
7251 } = useBlockGapProps(name); // Props for managing `dimensions.minHeight`.
7252
7253 const {
7254 minHeightValue,
7255 setMinHeightValue,
7256 resetMinHeightValue,
7257 hasMinHeightValue
7258 } = useMinHeightProps(name);
7259
7260 const resetAll = () => {
7261 resetPaddingValue();
7262 resetMarginValue();
7263 resetGapValue();
7264 resetContentSizeValue();
7265 resetWideSizeValue();
7266 };
7267
7268 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
7269 label: (0,external_wp_i18n_namespaceObject.__)('Dimensions'),
7270 resetAll: resetAll
7271 }, (showContentSizeControl || showWideSizeControl) && (0,external_wp_element_namespaceObject.createElement)("span", {
7272 className: "span-columns"
7273 }, (0,external_wp_i18n_namespaceObject.__)('Set the width of the main content area.')), showContentSizeControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7274 className: "single-column",
7275 label: (0,external_wp_i18n_namespaceObject.__)('Content size'),
7276 hasValue: hasUserSetContentSizeValue,
7277 onDeselect: resetContentSizeValue,
7278 isShownByDefault: true
7279 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7280 alignment: "flex-end",
7281 justify: "flex-start"
7282 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
7283 label: (0,external_wp_i18n_namespaceObject.__)('Content'),
7284 labelPosition: "top",
7285 __unstableInputWidth: "80px",
7286 value: contentSizeValue || '',
7287 onChange: nextContentSize => {
7288 setContentSizeValue(nextContentSize);
7289 },
7290 units: units
7291 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalView, null, (0,external_wp_element_namespaceObject.createElement)(icon, {
7292 icon: position_center
7293 })))), showWideSizeControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7294 className: "single-column",
7295 label: (0,external_wp_i18n_namespaceObject.__)('Wide size'),
7296 hasValue: hasUserSetWideSizeValue,
7297 onDeselect: resetWideSizeValue,
7298 isShownByDefault: true
7299 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7300 alignment: "flex-end",
7301 justify: "flex-start"
7302 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
7303 label: (0,external_wp_i18n_namespaceObject.__)('Wide'),
7304 labelPosition: "top",
7305 __unstableInputWidth: "80px",
7306 value: wideSizeValue || '',
7307 onChange: nextWideSize => {
7308 setWideSizeValue(nextWideSize);
7309 },
7310 units: units
7311 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalView, null, (0,external_wp_element_namespaceObject.createElement)(icon, {
7312 icon: stretch_wide
7313 })))), showPaddingControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7314 hasValue: hasPaddingValue,
7315 label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
7316 onDeselect: resetPaddingValue,
7317 isShownByDefault: true,
7318 className: classnames_default()({
7319 'tools-panel-item-spacing': showSpacingPresetsControl
7320 })
7321 }, !showSpacingPresetsControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
7322 values: paddingValues,
7323 onChange: setPaddingValues,
7324 label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
7325 sides: paddingSides,
7326 units: units,
7327 allowReset: false,
7328 splitOnAxis: isAxialPadding
7329 }), showSpacingPresetsControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalSpacingSizesControl, {
7330 values: paddingValues,
7331 onChange: setPaddingValues,
7332 label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
7333 sides: paddingSides,
7334 units: units,
7335 allowReset: false,
7336 splitOnAxis: isAxialPadding
7337 })), showMarginControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7338 hasValue: hasMarginValue,
7339 label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
7340 onDeselect: resetMarginValue,
7341 isShownByDefault: true,
7342 className: classnames_default()({
7343 'tools-panel-item-spacing': showSpacingPresetsControl
7344 })
7345 }, !showSpacingPresetsControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
7346 values: marginValues,
7347 onChange: setMarginValues,
7348 label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
7349 sides: marginSides,
7350 units: units,
7351 allowReset: false,
7352 splitOnAxis: isAxialMargin
7353 }), showSpacingPresetsControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalSpacingSizesControl, {
7354 values: marginValues,
7355 onChange: setMarginValues,
7356 label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
7357 sides: marginSides,
7358 units: units,
7359 allowReset: false,
7360 splitOnAxis: isAxialMargin
7361 })), showGapControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7362 hasValue: hasGapValue,
7363 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
7364 onDeselect: resetGapValue,
7365 isShownByDefault: true,
7366 className: classnames_default()({
7367 'tools-panel-item-spacing': showSpacingPresetsControl
7368 })
7369 }, !showSpacingPresetsControl && (isAxialGap ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
7370 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
7371 min: 0,
7372 onChange: setGapValues,
7373 units: units,
7374 sides: gapSides,
7375 values: gapValues,
7376 allowReset: false,
7377 splitOnAxis: isAxialGap
7378 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
7379 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
7380 __unstableInputWidth: "80px",
7381 min: 0,
7382 onChange: setGapValue,
7383 units: units,
7384 value: gapValue
7385 })), showSpacingPresetsControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalSpacingSizesControl, {
7386 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
7387 min: 0,
7388 onChange: setGapValues,
7389 sides: isAxialGap ? gapSides : ['top'] // Use 'top' as the shorthand property in non-axial configurations.
7390 ,
7391 values: gapValues,
7392 allowReset: false,
7393 splitOnAxis: isAxialGap
7394 })), showMinHeightControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7395 hasValue: hasMinHeightValue,
7396 label: (0,external_wp_i18n_namespaceObject.__)('Min. height'),
7397 onDeselect: resetMinHeightValue,
7398 isShownByDefault: true
7399 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalHeightControl, {
7400 label: (0,external_wp_i18n_namespaceObject.__)('Min. height'),
7401 value: minHeightValue,
7402 onChange: setMinHeightValue
7403 })));
7404 }
7405
7406 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/typography-panel.js
7407
7408
7409 /**
7410 * WordPress dependencies
7411 */
7412
7413
7414
7415 /**
7416 * Internal dependencies
7417 */
7418
7419
7420 function useHasTypographyPanel(name) {
7421 const hasFontFamily = useHasFontFamilyControl(name);
7422 const hasLineHeight = useHasLineHeightControl(name);
7423 const hasFontAppearance = useHasAppearanceControl(name);
7424 const hasLetterSpacing = useHasLetterSpacingControl(name);
7425 const supports = getSupportedGlobalStylesPanels(name);
7426 return hasFontFamily || hasLineHeight || hasFontAppearance || hasLetterSpacing || supports.includes('fontSize');
7427 }
7428
7429 function useHasFontFamilyControl(name) {
7430 const supports = getSupportedGlobalStylesPanels(name);
7431 const [fontFamilies] = useSetting('typography.fontFamilies', name);
7432 return supports.includes('fontFamily') && !!(fontFamilies !== null && fontFamilies !== void 0 && fontFamilies.length);
7433 }
7434
7435 function useHasLineHeightControl(name) {
7436 const supports = getSupportedGlobalStylesPanels(name);
7437 return useSetting('typography.lineHeight', name)[0] && supports.includes('lineHeight');
7438 }
7439
7440 function useHasAppearanceControl(name) {
7441 const supports = getSupportedGlobalStylesPanels(name);
7442 const hasFontStyles = useSetting('typography.fontStyle', name)[0] && supports.includes('fontStyle');
7443 const hasFontWeights = useSetting('typography.fontWeight', name)[0] && supports.includes('fontWeight');
7444 return hasFontStyles || hasFontWeights;
7445 }
7446
7447 function useAppearanceControlLabel(name) {
7448 const supports = getSupportedGlobalStylesPanels(name);
7449 const hasFontStyles = useSetting('typography.fontStyle', name)[0] && supports.includes('fontStyle');
7450 const hasFontWeights = useSetting('typography.fontWeight', name)[0] && supports.includes('fontWeight');
7451
7452 if (!hasFontStyles) {
7453 return (0,external_wp_i18n_namespaceObject.__)('Font weight');
7454 }
7455
7456 if (!hasFontWeights) {
7457 return (0,external_wp_i18n_namespaceObject.__)('Font style');
7458 }
7459
7460 return (0,external_wp_i18n_namespaceObject.__)('Appearance');
7461 }
7462
7463 function useHasLetterSpacingControl(name, element) {
7464 const setting = useSetting('typography.letterSpacing', name)[0];
7465
7466 if (!setting) {
7467 return false;
7468 }
7469
7470 if (!name && element === 'heading') {
7471 return true;
7472 }
7473
7474 const supports = getSupportedGlobalStylesPanels(name);
7475 return supports.includes('letterSpacing');
7476 }
7477
7478 function useHasTextTransformControl(name, element) {
7479 const setting = useSetting('typography.textTransform', name)[0];
7480
7481 if (!setting) {
7482 return false;
7483 }
7484
7485 if (!name && element === 'heading') {
7486 return true;
7487 }
7488
7489 const supports = getSupportedGlobalStylesPanels(name);
7490 return supports.includes('textTransform');
7491 }
7492
7493 function useHasTextDecorationControl(name, element) {
7494 // This is an exception for link elements.
7495 // We shouldn't allow other blocks or elements to set textDecoration
7496 // because this will be inherited by their children.
7497 return !name && element === 'link';
7498 }
7499
7500 function useStyleWithReset(path, blockName) {
7501 const [style, setStyle] = useStyle(path, blockName);
7502 const [userStyle] = useStyle(path, blockName, 'user');
7503
7504 const hasStyle = () => !!userStyle;
7505
7506 const resetStyle = () => setStyle(undefined);
7507
7508 return [style, setStyle, hasStyle, resetStyle];
7509 }
7510
7511 function useFontSizeWithReset(path, blockName) {
7512 const [fontSize, setStyleCallback] = useStyle(path, blockName);
7513 const [userStyle] = useStyle(path, blockName, 'user');
7514
7515 const hasFontSize = () => !!userStyle;
7516
7517 const resetFontSize = () => setStyleCallback(undefined);
7518
7519 const setFontSize = (newValue, metadata) => {
7520 if (!!(metadata !== null && metadata !== void 0 && metadata.slug)) {
7521 newValue = `var:preset|font-size|${metadata === null || metadata === void 0 ? void 0 : metadata.slug}`;
7522 }
7523
7524 setStyleCallback(newValue);
7525 };
7526
7527 return {
7528 fontSize,
7529 setFontSize,
7530 hasFontSize,
7531 resetFontSize
7532 };
7533 }
7534
7535 function useFontAppearance(prefix, name) {
7536 const [fontStyle, setFontStyle] = useStyle(prefix + 'typography.fontStyle', name);
7537 const [userFontStyle] = useStyle(prefix + 'typography.fontStyle', name, 'user');
7538 const [fontWeight, setFontWeight] = useStyle(prefix + 'typography.fontWeight', name);
7539 const [userFontWeight] = useStyle(prefix + 'typography.fontWeight', name, 'user');
7540
7541 const hasFontAppearance = () => !!userFontStyle || !!userFontWeight;
7542
7543 const resetFontAppearance = () => {
7544 setFontStyle(undefined);
7545 setFontWeight(undefined);
7546 };
7547
7548 return {
7549 fontStyle,
7550 setFontStyle,
7551 fontWeight,
7552 setFontWeight,
7553 hasFontAppearance,
7554 resetFontAppearance
7555 };
7556 }
7557
7558 function TypographyPanel(_ref) {
7559 let {
7560 name,
7561 element,
7562 headingLevel
7563 } = _ref;
7564 const supports = getSupportedGlobalStylesPanels(name);
7565 let prefix = '';
7566
7567 if (element === 'heading') {
7568 prefix = `elements.${headingLevel}.`;
7569 } else if (element && element !== 'text') {
7570 prefix = `elements.${element}.`;
7571 }
7572
7573 const [fontSizes] = useSetting('typography.fontSizes', name);
7574 const disableCustomFontSizes = !useSetting('typography.customFontSize', name)[0];
7575 const [fontFamilies] = useSetting('typography.fontFamilies', name);
7576 const hasFontStyles = useSetting('typography.fontStyle', name)[0] && supports.includes('fontStyle');
7577 const hasFontWeights = useSetting('typography.fontWeight', name)[0] && supports.includes('fontWeight');
7578 const hasFontFamilyEnabled = useHasFontFamilyControl(name);
7579 const hasLineHeightEnabled = useHasLineHeightControl(name);
7580 const hasAppearanceControl = useHasAppearanceControl(name);
7581 const appearanceControlLabel = useAppearanceControlLabel(name);
7582 const hasLetterSpacingControl = useHasLetterSpacingControl(name, element);
7583 const hasTextTransformControl = useHasTextTransformControl(name, element);
7584 const hasTextDecorationControl = useHasTextDecorationControl(name, element);
7585 /* Disable font size controls when the option to style all headings is selected. */
7586
7587 let hasFontSizeEnabled = supports.includes('fontSize');
7588
7589 if (element === 'heading' && headingLevel === 'heading') {
7590 hasFontSizeEnabled = false;
7591 }
7592
7593 const [fontFamily, setFontFamily, hasFontFamily, resetFontFamily] = useStyleWithReset(prefix + 'typography.fontFamily', name);
7594 const {
7595 fontSize,
7596 setFontSize,
7597 hasFontSize,
7598 resetFontSize
7599 } = useFontSizeWithReset(prefix + 'typography.fontSize', name);
7600 const {
7601 fontStyle,
7602 setFontStyle,
7603 fontWeight,
7604 setFontWeight,
7605 hasFontAppearance,
7606 resetFontAppearance
7607 } = useFontAppearance(prefix, name);
7608 const [lineHeight, setLineHeight, hasLineHeight, resetLineHeight] = useStyleWithReset(prefix + 'typography.lineHeight', name);
7609 const [letterSpacing, setLetterSpacing, hasLetterSpacing, resetLetterSpacing] = useStyleWithReset(prefix + 'typography.letterSpacing', name);
7610 const [textTransform, setTextTransform, hasTextTransform, resetTextTransform] = useStyleWithReset(prefix + 'typography.textTransform', name);
7611 const [textDecoration, setTextDecoration, hasTextDecoration, resetTextDecoration] = useStyleWithReset(prefix + 'typography.textDecoration', name);
7612
7613 const resetAll = () => {
7614 resetFontFamily();
7615 resetFontSize();
7616 resetFontAppearance();
7617 resetLineHeight();
7618 resetLetterSpacing();
7619 resetTextTransform();
7620 };
7621
7622 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
7623 label: (0,external_wp_i18n_namespaceObject.__)('Typography'),
7624 resetAll: resetAll
7625 }, hasFontFamilyEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7626 label: (0,external_wp_i18n_namespaceObject.__)('Font family'),
7627 hasValue: hasFontFamily,
7628 onDeselect: resetFontFamily,
7629 isShownByDefault: true
7630 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalFontFamilyControl, {
7631 fontFamilies: fontFamilies,
7632 value: fontFamily,
7633 onChange: setFontFamily,
7634 size: "__unstable-large",
7635 __nextHasNoMarginBottom: true
7636 })), hasFontSizeEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7637 label: (0,external_wp_i18n_namespaceObject.__)('Font size'),
7638 hasValue: hasFontSize,
7639 onDeselect: resetFontSize,
7640 isShownByDefault: true
7641 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FontSizePicker, {
7642 value: fontSize,
7643 onChange: setFontSize,
7644 fontSizes: fontSizes,
7645 disableCustomFontSizes: disableCustomFontSizes,
7646 withReset: false,
7647 withSlider: true,
7648 size: "__unstable-large",
7649 __nextHasNoMarginBottom: true
7650 })), hasAppearanceControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7651 className: "single-column",
7652 label: appearanceControlLabel,
7653 hasValue: hasFontAppearance,
7654 onDeselect: resetFontAppearance,
7655 isShownByDefault: true
7656 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalFontAppearanceControl, {
7657 value: {
7658 fontStyle,
7659 fontWeight
7660 },
7661 onChange: _ref2 => {
7662 let {
7663 fontStyle: newFontStyle,
7664 fontWeight: newFontWeight
7665 } = _ref2;
7666 setFontStyle(newFontStyle);
7667 setFontWeight(newFontWeight);
7668 },
7669 hasFontStyles: hasFontStyles,
7670 hasFontWeights: hasFontWeights,
7671 size: "__unstable-large",
7672 __nextHasNoMarginBottom: true
7673 })), hasLineHeightEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7674 className: "single-column",
7675 label: (0,external_wp_i18n_namespaceObject.__)('Line height'),
7676 hasValue: hasLineHeight,
7677 onDeselect: resetLineHeight,
7678 isShownByDefault: true
7679 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.LineHeightControl, {
7680 __nextHasNoMarginBottom: true,
7681 __unstableInputWidth: "auto",
7682 value: lineHeight,
7683 onChange: setLineHeight,
7684 size: "__unstable-large"
7685 })), hasLetterSpacingControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7686 className: "single-column",
7687 label: (0,external_wp_i18n_namespaceObject.__)('Letter spacing'),
7688 hasValue: hasLetterSpacing,
7689 onDeselect: resetLetterSpacing,
7690 isShownByDefault: true
7691 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLetterSpacingControl, {
7692 value: letterSpacing,
7693 onChange: setLetterSpacing,
7694 size: "__unstable-large",
7695 __unstableInputWidth: "auto"
7696 })), hasTextTransformControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7697 label: (0,external_wp_i18n_namespaceObject.__)('Letter case'),
7698 hasValue: hasTextTransform,
7699 onDeselect: resetTextTransform,
7700 isShownByDefault: true
7701 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalTextTransformControl, {
7702 value: textTransform,
7703 onChange: setTextTransform,
7704 showNone: true,
7705 isBlock: true,
7706 size: "__unstable-large",
7707 __nextHasNoMarginBottom: true
7708 })), hasTextDecorationControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
7709 className: "single-column",
7710 label: (0,external_wp_i18n_namespaceObject.__)('Text decoration'),
7711 hasValue: hasTextDecoration,
7712 onDeselect: resetTextDecoration,
7713 isShownByDefault: true
7714 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalTextDecorationControl, {
7715 value: textDecoration,
7716 onChange: setTextDecoration,
7717 size: "__unstable-large",
7718 __unstableInputWidth: "auto"
7719 })));
7720 }
7721
7722 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/context-menu.js
7723
7724
7725 /**
7726 * WordPress dependencies
7727 */
7728
7729
7730
7731 /**
7732 * Internal dependencies
7733 */
7734
7735
7736
7737
7738
7739
7740
7741 function ContextMenu(_ref) {
7742 let {
7743 name,
7744 parentMenu = ''
7745 } = _ref;
7746 const hasTypographyPanel = useHasTypographyPanel(name);
7747 const hasColorPanel = useHasColorPanel(name);
7748 const hasBorderPanel = useHasBorderPanel(name);
7749 const hasDimensionsPanel = useHasDimensionsPanel(name);
7750 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
7751 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, hasTypographyPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
7752 icon: library_typography,
7753 path: parentMenu + '/typography',
7754 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Typography styles')
7755 }, (0,external_wp_i18n_namespaceObject.__)('Typography')), hasColorPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
7756 icon: library_color,
7757 path: parentMenu + '/colors',
7758 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Colors styles')
7759 }, (0,external_wp_i18n_namespaceObject.__)('Colors')), hasLayoutPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
7760 icon: library_layout,
7761 path: parentMenu + '/layout',
7762 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Layout styles')
7763 }, (0,external_wp_i18n_namespaceObject.__)('Layout')));
7764 }
7765
7766 /* harmony default export */ var context_menu = (ContextMenu);
7767
7768 ;// CONCATENATED MODULE: external ["wp","styleEngine"]
7769 var external_wp_styleEngine_namespaceObject = window["wp"]["styleEngine"];
7770 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/use-global-styles-output.js
7771
7772
7773 /**
7774 * External dependencies
7775 */
7776
7777 /**
7778 * WordPress dependencies
7779 */
7780
7781
7782
7783
7784
7785
7786 /**
7787 * Internal dependencies
7788 */
7789
7790
7791
7792
7793 // List of block support features that can have their related styles
7794 // generated under their own feature level selector rather than the block's.
7795
7796 const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
7797 __experimentalBorder: 'border',
7798 color: 'color',
7799 spacing: 'spacing',
7800 typography: 'typography'
7801 };
7802
7803 function compileStyleValue(uncompiledValue) {
7804 var _uncompiledValue$star;
7805
7806 const VARIABLE_REFERENCE_PREFIX = 'var:';
7807 const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
7808 const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
7809
7810 if (uncompiledValue !== null && uncompiledValue !== void 0 && (_uncompiledValue$star = uncompiledValue.startsWith) !== null && _uncompiledValue$star !== void 0 && _uncompiledValue$star.call(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
7811 const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
7812 return `var(--wp--${variable})`;
7813 }
7814
7815 return uncompiledValue;
7816 }
7817 /**
7818 * Transform given preset tree into a set of style declarations.
7819 *
7820 * @param {Object} blockPresets
7821 * @param {Object} mergedSettings Merged theme.json settings.
7822 *
7823 * @return {Array<Object>} An array of style declarations.
7824 */
7825
7826
7827 function getPresetsDeclarations() {
7828 let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7829 let mergedSettings = arguments.length > 1 ? arguments[1] : undefined;
7830 return PRESET_METADATA.reduce((declarations, _ref) => {
7831 let {
7832 path,
7833 valueKey,
7834 valueFunc,
7835 cssVarInfix
7836 } = _ref;
7837 const presetByOrigin = (0,external_lodash_namespaceObject.get)(blockPresets, path, []);
7838 ['default', 'theme', 'custom'].forEach(origin => {
7839 if (presetByOrigin[origin]) {
7840 presetByOrigin[origin].forEach(value => {
7841 if (valueKey && !valueFunc) {
7842 declarations.push(`--wp--preset--${cssVarInfix}--${(0,external_lodash_namespaceObject.kebabCase)(value.slug)}: ${value[valueKey]}`);
7843 } else if (valueFunc && typeof valueFunc === 'function') {
7844 declarations.push(`--wp--preset--${cssVarInfix}--${(0,external_lodash_namespaceObject.kebabCase)(value.slug)}: ${valueFunc(value, mergedSettings)}`);
7845 }
7846 });
7847 }
7848 });
7849 return declarations;
7850 }, []);
7851 }
7852 /**
7853 * Transform given preset tree into a set of preset class declarations.
7854 *
7855 * @param {string} blockSelector
7856 * @param {Object} blockPresets
7857 * @return {string} CSS declarations for the preset classes.
7858 */
7859
7860
7861 function getPresetsClasses(blockSelector) {
7862 let blockPresets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7863 return PRESET_METADATA.reduce((declarations, _ref2) => {
7864 let {
7865 path,
7866 cssVarInfix,
7867 classes
7868 } = _ref2;
7869
7870 if (!classes) {
7871 return declarations;
7872 }
7873
7874 const presetByOrigin = (0,external_lodash_namespaceObject.get)(blockPresets, path, []);
7875 ['default', 'theme', 'custom'].forEach(origin => {
7876 if (presetByOrigin[origin]) {
7877 presetByOrigin[origin].forEach(_ref3 => {
7878 let {
7879 slug
7880 } = _ref3;
7881 classes.forEach(_ref4 => {
7882 let {
7883 classSuffix,
7884 propertyName
7885 } = _ref4;
7886 const classSelectorToUse = `.has-${(0,external_lodash_namespaceObject.kebabCase)(slug)}-${classSuffix}`;
7887 const selectorToUse = blockSelector.split(',') // Selector can be "h1, h2, h3"
7888 .map(selector => `${selector}${classSelectorToUse}`).join(',');
7889 const value = `var(--wp--preset--${cssVarInfix}--${(0,external_lodash_namespaceObject.kebabCase)(slug)})`;
7890 declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
7891 });
7892 });
7893 }
7894 });
7895 return declarations;
7896 }, '');
7897 }
7898
7899 function getPresetsSvgFilters() {
7900 let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7901 return PRESET_METADATA.filter( // Duotone are the only type of filters for now.
7902 metadata => metadata.path.at(-1) === 'duotone').flatMap(metadata => {
7903 const presetByOrigin = (0,external_lodash_namespaceObject.get)(blockPresets, metadata.path, {});
7904 return ['default', 'theme'].filter(origin => presetByOrigin[origin]).flatMap(origin => presetByOrigin[origin].map(preset => (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstablePresetDuotoneFilter, {
7905 preset: preset,
7906 key: preset.slug
7907 })));
7908 });
7909 }
7910
7911 function flattenTree() {
7912 let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7913 let prefix = arguments.length > 1 ? arguments[1] : undefined;
7914 let token = arguments.length > 2 ? arguments[2] : undefined;
7915 let result = [];
7916 Object.keys(input).forEach(key => {
7917 const newKey = prefix + (0,external_lodash_namespaceObject.kebabCase)(key.replace('/', '-'));
7918 const newLeaf = input[key];
7919
7920 if (newLeaf instanceof Object) {
7921 const newPrefix = newKey + token;
7922 result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
7923 } else {
7924 result.push(`${newKey}: ${newLeaf}`);
7925 }
7926 });
7927 return result;
7928 }
7929 /**
7930 * Transform given style tree into a set of style declarations.
7931 *
7932 * @param {Object} blockStyles Block styles.
7933 *
7934 * @param {string} selector The selector these declarations should attach to.
7935 *
7936 * @param {boolean} useRootPaddingAlign Whether to use CSS custom properties in root selector.
7937 *
7938 * @param {Object} tree A theme.json tree containing layout definitions.
7939 *
7940 * @return {Array} An array of style declarations.
7941 */
7942
7943
7944 function getStylesDeclarations() {
7945 let blockStyles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7946 let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
7947 let useRootPaddingAlign = arguments.length > 2 ? arguments[2] : undefined;
7948 let tree = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
7949 const isRoot = ROOT_BLOCK_SELECTOR === selector;
7950 const output = Object.entries(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY).reduce((declarations, _ref5) => {
7951 let [key, {
7952 value,
7953 properties,
7954 useEngine,
7955 rootOnly
7956 }] = _ref5;
7957
7958 if (rootOnly && !isRoot) {
7959 return declarations;
7960 }
7961
7962 const pathToValue = value;
7963
7964 if (pathToValue[0] === 'elements' || useEngine) {
7965 return declarations;
7966 }
7967
7968 const styleValue = (0,external_lodash_namespaceObject.get)(blockStyles, pathToValue); // Root-level padding styles don't currently support strings with CSS shorthand values.
7969 // This may change: https://github.com/WordPress/gutenberg/issues/40132.
7970
7971 if (key === '--wp--style--root--padding' && (typeof styleValue === 'string' || !useRootPaddingAlign)) {
7972 return declarations;
7973 }
7974
7975 if (!!properties && typeof styleValue !== 'string') {
7976 Object.entries(properties).forEach(entry => {
7977 const [name, prop] = entry;
7978
7979 if (!(0,external_lodash_namespaceObject.get)(styleValue, [prop], false)) {
7980 // Do not create a declaration
7981 // for sub-properties that don't have any value.
7982 return;
7983 }
7984
7985 const cssProperty = name.startsWith('--') ? name : (0,external_lodash_namespaceObject.kebabCase)(name);
7986 declarations.push(`${cssProperty}: ${compileStyleValue((0,external_lodash_namespaceObject.get)(styleValue, [prop]))}`);
7987 });
7988 } else if ((0,external_lodash_namespaceObject.get)(blockStyles, pathToValue, false)) {
7989 const cssProperty = key.startsWith('--') ? key : (0,external_lodash_namespaceObject.kebabCase)(key);
7990 declarations.push(`${cssProperty}: ${compileStyleValue((0,external_lodash_namespaceObject.get)(blockStyles, pathToValue))}`);
7991 }
7992
7993 return declarations;
7994 }, []); // The goal is to move everything to server side generated engine styles
7995 // This is temporary as we absorb more and more styles into the engine.
7996
7997 const extraRules = (0,external_wp_styleEngine_namespaceObject.getCSSRules)(blockStyles);
7998 extraRules.forEach(rule => {
7999 var _ruleValue;
8000
8001 // Don't output padding properties if padding variables are set.
8002 if (isRoot && useRootPaddingAlign && rule.key.startsWith('padding')) {
8003 return;
8004 }
8005
8006 const cssProperty = rule.key.startsWith('--') ? rule.key : (0,external_lodash_namespaceObject.kebabCase)(rule.key);
8007 let ruleValue = rule.value;
8008
8009 if (typeof ruleValue !== 'string' && (_ruleValue = ruleValue) !== null && _ruleValue !== void 0 && _ruleValue.ref) {
8010 var _ruleValue2;
8011
8012 const refPath = ruleValue.ref.split('.');
8013 ruleValue = (0,external_lodash_namespaceObject.get)(tree, refPath); // Presence of another ref indicates a reference to another dynamic value.
8014 // Pointing to another dynamic value is not supported.
8015
8016 if (!ruleValue || !!((_ruleValue2 = ruleValue) !== null && _ruleValue2 !== void 0 && _ruleValue2.ref)) {
8017 return;
8018 }
8019 } // Calculate fluid typography rules where available.
8020
8021
8022 if (cssProperty === 'font-size') {
8023 var _tree$settings;
8024
8025 /*
8026 * getTypographyFontSizeValue() will check
8027 * if fluid typography has been activated and also
8028 * whether the incoming value can be converted to a fluid value.
8029 * Values that already have a "clamp()" function will not pass the test,
8030 * and therefore the original $value will be returned.
8031 */
8032 ruleValue = getTypographyFontSizeValue({
8033 size: ruleValue
8034 }, tree === null || tree === void 0 ? void 0 : (_tree$settings = tree.settings) === null || _tree$settings === void 0 ? void 0 : _tree$settings.typography);
8035 }
8036
8037 output.push(`${cssProperty}: ${ruleValue}`);
8038 });
8039 return output;
8040 }
8041 /**
8042 * Get generated CSS for layout styles by looking up layout definitions provided
8043 * in theme.json, and outputting common layout styles, and specific blockGap values.
8044 *
8045 * @param {Object} props
8046 * @param {Object} props.tree A theme.json tree containing layout definitions.
8047 * @param {Object} props.style A style object containing spacing values.
8048 * @param {string} props.selector Selector used to group together layout styling rules.
8049 * @param {boolean} props.hasBlockGapSupport Whether or not the theme opts-in to blockGap support.
8050 * @param {boolean} props.hasFallbackGapSupport Whether or not the theme allows fallback gap styles.
8051 * @param {?string} props.fallbackGapValue An optional fallback gap value if no real gap value is available.
8052 * @return {string} Generated CSS rules for the layout styles.
8053 */
8054
8055 function getLayoutStyles(_ref6) {
8056 var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
8057
8058 let {
8059 tree,
8060 style,
8061 selector,
8062 hasBlockGapSupport,
8063 hasFallbackGapSupport,
8064 fallbackGapValue
8065 } = _ref6;
8066 let ruleset = '';
8067 let gapValue = hasBlockGapSupport ? (0,external_wp_blockEditor_namespaceObject.__experimentalGetGapCSSValue)(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap) : ''; // Ensure a fallback gap value for the root layout definitions,
8068 // and use a fallback value if one is provided for the current block.
8069
8070 if (hasFallbackGapSupport) {
8071 if (selector === ROOT_BLOCK_SELECTOR) {
8072 gapValue = !gapValue ? '0.5em' : gapValue;
8073 } else if (!hasBlockGapSupport && fallbackGapValue) {
8074 gapValue = fallbackGapValue;
8075 }
8076 }
8077
8078 if (gapValue && tree !== null && tree !== void 0 && (_tree$settings2 = tree.settings) !== null && _tree$settings2 !== void 0 && (_tree$settings2$layou = _tree$settings2.layout) !== null && _tree$settings2$layou !== void 0 && _tree$settings2$layou.definitions) {
8079 Object.values(tree.settings.layout.definitions).forEach(_ref7 => {
8080 let {
8081 className,
8082 name,
8083 spacingStyles
8084 } = _ref7;
8085
8086 // Allow outputting fallback gap styles for flex layout type when block gap support isn't available.
8087 if (!hasBlockGapSupport && 'flex' !== name) {
8088 return;
8089 }
8090
8091 if (spacingStyles !== null && spacingStyles !== void 0 && spacingStyles.length) {
8092 spacingStyles.forEach(spacingStyle => {
8093 const declarations = [];
8094
8095 if (spacingStyle.rules) {
8096 Object.entries(spacingStyle.rules).forEach(_ref8 => {
8097 let [cssProperty, cssValue] = _ref8;
8098 declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
8099 });
8100 }
8101
8102 if (declarations.length) {
8103 let combinedSelector = '';
8104
8105 if (!hasBlockGapSupport) {
8106 // For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
8107 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `:where(.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})` : `:where(${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''})`;
8108 } else {
8109 combinedSelector = selector === ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
8110 }
8111
8112 ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
8113 }
8114 });
8115 }
8116 }); // For backwards compatibility, ensure the legacy block gap CSS variable is still available.
8117
8118 if (selector === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
8119 ruleset += `${selector} { --wp--style--block-gap: ${gapValue}; }`;
8120 }
8121 } // Output base styles
8122
8123
8124 if (selector === ROOT_BLOCK_SELECTOR && tree !== null && tree !== void 0 && (_tree$settings3 = tree.settings) !== null && _tree$settings3 !== void 0 && (_tree$settings3$layou = _tree$settings3.layout) !== null && _tree$settings3$layou !== void 0 && _tree$settings3$layou.definitions) {
8125 const validDisplayModes = ['block', 'flex', 'grid'];
8126 Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
8127 let {
8128 className,
8129 displayMode,
8130 baseStyles
8131 } = _ref9;
8132
8133 if (displayMode && validDisplayModes.includes(displayMode)) {
8134 ruleset += `${selector} .${className} { display:${displayMode}; }`;
8135 }
8136
8137 if (baseStyles !== null && baseStyles !== void 0 && baseStyles.length) {
8138 baseStyles.forEach(baseStyle => {
8139 const declarations = [];
8140
8141 if (baseStyle.rules) {
8142 Object.entries(baseStyle.rules).forEach(_ref10 => {
8143 let [cssProperty, cssValue] = _ref10;
8144 declarations.push(`${cssProperty}: ${cssValue}`);
8145 });
8146 }
8147
8148 if (declarations.length) {
8149 const combinedSelector = `${selector} .${className}${(baseStyle === null || baseStyle === void 0 ? void 0 : baseStyle.selector) || ''}`;
8150 ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
8151 }
8152 });
8153 }
8154 });
8155 }
8156
8157 return ruleset;
8158 }
8159 const getNodesWithStyles = (tree, blockSelectors) => {
8160 var _tree$styles$blocks, _tree$styles3;
8161
8162 const nodes = [];
8163
8164 if (!(tree !== null && tree !== void 0 && tree.styles)) {
8165 return nodes;
8166 }
8167
8168 const pickStyleKeys = treeToPickFrom => (0,external_lodash_namespaceObject.pickBy)(treeToPickFrom, (value, key) => ['border', 'color', 'dimensions', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key)); // Top-level.
8169
8170
8171 const styles = pickStyleKeys(tree.styles);
8172
8173 if (!!styles) {
8174 nodes.push({
8175 styles,
8176 selector: ROOT_BLOCK_SELECTOR
8177 });
8178 }
8179
8180 Object.entries(external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS).forEach(_ref11 => {
8181 var _tree$styles;
8182
8183 let [name, selector] = _ref11;
8184
8185 if (!!((_tree$styles = tree.styles) !== null && _tree$styles !== void 0 && _tree$styles.elements[name])) {
8186 var _tree$styles2;
8187
8188 nodes.push({
8189 styles: (_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.elements[name],
8190 selector
8191 });
8192 }
8193 }); // Iterate over blocks: they can have styles & elements.
8194
8195 Object.entries((_tree$styles$blocks = (_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : _tree$styles3.blocks) !== null && _tree$styles$blocks !== void 0 ? _tree$styles$blocks : {}).forEach(_ref12 => {
8196 var _blockSelectors$block, _node$elements;
8197
8198 let [blockName, node] = _ref12;
8199 const blockStyles = pickStyleKeys(node);
8200
8201 if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
8202 nodes.push({
8203 duotoneSelector: blockSelectors[blockName].duotoneSelector,
8204 fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
8205 hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
8206 selector: blockSelectors[blockName].selector,
8207 styles: blockStyles,
8208 featureSelectors: blockSelectors[blockName].featureSelectors
8209 });
8210 }
8211
8212 Object.entries((_node$elements = node === null || node === void 0 ? void 0 : node.elements) !== null && _node$elements !== void 0 ? _node$elements : {}).forEach(_ref13 => {
8213 let [elementName, value] = _ref13;
8214
8215 if (!!value && !!(blockSelectors !== null && blockSelectors !== void 0 && blockSelectors[blockName]) && !!(external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS !== null && external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS !== void 0 && external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[elementName])) {
8216 nodes.push({
8217 styles: value,
8218 selector: blockSelectors[blockName].selector.split(',').map(sel => {
8219 const elementSelectors = external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[elementName].split(',');
8220 return elementSelectors.map(elementSelector => sel + ' ' + elementSelector);
8221 }).join(',')
8222 });
8223 }
8224 });
8225 });
8226 return nodes;
8227 };
8228 const getNodesWithSettings = (tree, blockSelectors) => {
8229 var _tree$settings4, _tree$settings$blocks, _tree$settings5;
8230
8231 const nodes = [];
8232
8233 if (!(tree !== null && tree !== void 0 && tree.settings)) {
8234 return nodes;
8235 }
8236
8237 const pickPresets = treeToPickFrom => {
8238 const presets = {};
8239 PRESET_METADATA.forEach(_ref14 => {
8240 let {
8241 path
8242 } = _ref14;
8243 const value = (0,external_lodash_namespaceObject.get)(treeToPickFrom, path, false);
8244
8245 if (value !== false) {
8246 (0,external_lodash_namespaceObject.set)(presets, path, value);
8247 }
8248 });
8249 return presets;
8250 }; // Top-level.
8251
8252
8253 const presets = pickPresets(tree.settings);
8254 const custom = (_tree$settings4 = tree.settings) === null || _tree$settings4 === void 0 ? void 0 : _tree$settings4.custom;
8255
8256 if (!(0,external_lodash_namespaceObject.isEmpty)(presets) || !!custom) {
8257 nodes.push({
8258 presets,
8259 custom,
8260 selector: ROOT_BLOCK_SELECTOR
8261 });
8262 } // Blocks.
8263
8264
8265 Object.entries((_tree$settings$blocks = (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(_ref15 => {
8266 let [blockName, node] = _ref15;
8267 const blockPresets = pickPresets(node);
8268 const blockCustom = node.custom;
8269
8270 if (!(0,external_lodash_namespaceObject.isEmpty)(blockPresets) || !!blockCustom) {
8271 nodes.push({
8272 presets: blockPresets,
8273 custom: blockCustom,
8274 selector: blockSelectors[blockName].selector
8275 });
8276 }
8277 });
8278 return nodes;
8279 };
8280 const toCustomProperties = (tree, blockSelectors) => {
8281 const settings = getNodesWithSettings(tree, blockSelectors);
8282 let ruleset = '';
8283 settings.forEach(_ref16 => {
8284 let {
8285 presets,
8286 custom,
8287 selector
8288 } = _ref16;
8289 const declarations = getPresetsDeclarations(presets, tree === null || tree === void 0 ? void 0 : tree.settings);
8290 const customProps = flattenTree(custom, '--wp--custom--', '--');
8291
8292 if (customProps.length > 0) {
8293 declarations.push(...customProps);
8294 }
8295
8296 if (declarations.length > 0) {
8297 ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
8298 }
8299 });
8300 return ruleset;
8301 };
8302 const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport) {
8303 var _tree$settings6, _tree$settings7;
8304
8305 let disableLayoutStyles = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
8306 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
8307 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
8308 const useRootPaddingAlign = tree === null || tree === void 0 ? void 0 : (_tree$settings6 = tree.settings) === null || _tree$settings6 === void 0 ? void 0 : _tree$settings6.useRootPaddingAwareAlignments;
8309 const {
8310 contentSize,
8311 wideSize
8312 } = (tree === null || tree === void 0 ? void 0 : (_tree$settings7 = tree.settings) === null || _tree$settings7 === void 0 ? void 0 : _tree$settings7.layout) || {};
8313 /*
8314 * Reset default browser margin on the root body element.
8315 * This is set on the root selector **before** generating the ruleset
8316 * from the `theme.json`. This is to ensure that if the `theme.json` declares
8317 * `margin` in its `spacing` declaration for the `body` element then these
8318 * user-generated values take precedence in the CSS cascade.
8319 * @link https://github.com/WordPress/gutenberg/issues/36147.
8320 */
8321
8322 let ruleset = 'body {margin: 0;';
8323
8324 if (contentSize) {
8325 ruleset += ` --wp--style--global--content-size: ${contentSize};`;
8326 }
8327
8328 if (wideSize) {
8329 ruleset += ` --wp--style--global--wide-size: ${wideSize};`;
8330 }
8331
8332 if (useRootPaddingAlign) {
8333 ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
8334 .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
8335 .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
8336 .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
8337 .has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
8338 .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
8339 .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
8340 }
8341
8342 ruleset += '}';
8343 nodesWithStyles.forEach(_ref17 => {
8344 let {
8345 selector,
8346 duotoneSelector,
8347 styles,
8348 fallbackGapValue,
8349 hasLayoutSupport,
8350 featureSelectors
8351 } = _ref17;
8352
8353 // Process styles for block support features with custom feature level
8354 // CSS selectors set.
8355 if (featureSelectors) {
8356 Object.entries(featureSelectors).forEach(_ref18 => {
8357 let [featureName, featureSelector] = _ref18;
8358
8359 if (styles !== null && styles !== void 0 && styles[featureName]) {
8360 const featureStyles = {
8361 [featureName]: styles[featureName]
8362 };
8363 const featureDeclarations = getStylesDeclarations(featureStyles);
8364 delete styles[featureName];
8365
8366 if (!!featureDeclarations.length) {
8367 ruleset = ruleset + `${featureSelector}{${featureDeclarations.join(';')} }`;
8368 }
8369 }
8370 });
8371 }
8372
8373 const duotoneStyles = {};
8374
8375 if (styles !== null && styles !== void 0 && styles.filter) {
8376 duotoneStyles.filter = styles.filter;
8377 delete styles.filter;
8378 } // Process duotone styles (they use color.__experimentalDuotone selector).
8379
8380
8381 if (duotoneSelector) {
8382 const duotoneDeclarations = getStylesDeclarations(duotoneStyles);
8383
8384 if (duotoneDeclarations.length > 0) {
8385 ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
8386 }
8387 } // Process blockGap and layout styles.
8388
8389
8390 if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport)) {
8391 ruleset += getLayoutStyles({
8392 tree,
8393 style: styles,
8394 selector,
8395 hasBlockGapSupport,
8396 hasFallbackGapSupport,
8397 fallbackGapValue
8398 });
8399 } // Process the remaining block styles (they use either normal block class or __experimentalSelector).
8400
8401
8402 const declarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree);
8403
8404 if (declarations !== null && declarations !== void 0 && declarations.length) {
8405 ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
8406 } // Check for pseudo selector in `styles` and handle separately.
8407
8408
8409 const pseudoSelectorStyles = Object.entries(styles).filter(_ref19 => {
8410 let [key] = _ref19;
8411 return key.startsWith(':');
8412 });
8413
8414 if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
8415 pseudoSelectorStyles.forEach(_ref20 => {
8416 let [pseudoKey, pseudoStyle] = _ref20;
8417 const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
8418
8419 if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
8420 return;
8421 } // `selector` maybe provided in a form
8422 // where block level selectors have sub element
8423 // selectors appended to them as a comma separated
8424 // string.
8425 // e.g. `h1 a,h2 a,h3 a,h4 a,h5 a,h6 a`;
8426 // Split and append pseudo selector to create
8427 // the proper rules to target the elements.
8428
8429
8430 const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
8431
8432 const pseudoRule = `${_selector}{${pseudoDeclarations.join(';')};}`;
8433 ruleset = ruleset + pseudoRule;
8434 });
8435 }
8436 });
8437 /* Add alignment / layout styles */
8438
8439 ruleset = ruleset + '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
8440 ruleset = ruleset + '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }';
8441 ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
8442
8443 if (hasBlockGapSupport) {
8444 var _tree$styles4, _tree$styles4$spacing;
8445
8446 // Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
8447 const gapValue = (0,external_wp_blockEditor_namespaceObject.__experimentalGetGapCSSValue)(tree === null || tree === void 0 ? void 0 : (_tree$styles4 = tree.styles) === null || _tree$styles4 === void 0 ? void 0 : (_tree$styles4$spacing = _tree$styles4.spacing) === null || _tree$styles4$spacing === void 0 ? void 0 : _tree$styles4$spacing.blockGap) || '0.5em';
8448 ruleset = ruleset + '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
8449 ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
8450 }
8451
8452 nodesWithSettings.forEach(_ref21 => {
8453 let {
8454 selector,
8455 presets
8456 } = _ref21;
8457
8458 if (ROOT_BLOCK_SELECTOR === selector) {
8459 // Do not add extra specificity for top-level classes.
8460 selector = '';
8461 }
8462
8463 const classes = getPresetsClasses(selector, presets);
8464
8465 if (!(0,external_lodash_namespaceObject.isEmpty)(classes)) {
8466 ruleset = ruleset + classes;
8467 }
8468 });
8469 return ruleset;
8470 };
8471 function toSvgFilters(tree, blockSelectors) {
8472 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
8473 return nodesWithSettings.flatMap(_ref22 => {
8474 let {
8475 presets
8476 } = _ref22;
8477 return getPresetsSvgFilters(presets);
8478 });
8479 }
8480 const getBlockSelectors = blockTypes => {
8481 const result = {};
8482 blockTypes.forEach(blockType => {
8483 var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports4, _blockType$supports4$, _blockType$supports4$2;
8484
8485 const name = blockType.name;
8486 const selector = (_blockType$supports$_ = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports = blockType.supports) === null || _blockType$supports === void 0 ? void 0 : _blockType$supports.__experimentalSelector) !== null && _blockType$supports$_ !== void 0 ? _blockType$supports$_ : '.wp-block-' + name.replace('core/', '').replace('/', '-');
8487 const duotoneSelector = (_blockType$supports$c = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.color) === null || _blockType$supports2$ === void 0 ? void 0 : _blockType$supports2$.__experimentalDuotone) !== null && _blockType$supports$c !== void 0 ? _blockType$supports$c : null;
8488 const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && _blockType$supports3.__experimentalLayout);
8489 const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports4 = blockType.supports) === null || _blockType$supports4 === void 0 ? void 0 : (_blockType$supports4$ = _blockType$supports4.spacing) === null || _blockType$supports4$ === void 0 ? void 0 : (_blockType$supports4$2 = _blockType$supports4$.blockGap) === null || _blockType$supports4$2 === void 0 ? void 0 : _blockType$supports4$2.__experimentalDefault; // For each block support feature add any custom selectors.
8490
8491 const featureSelectors = {};
8492 Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach(_ref23 => {
8493 var _blockType$supports5, _blockType$supports5$;
8494
8495 let [featureKey, featureName] = _ref23;
8496 const featureSelector = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports5 = blockType.supports) === null || _blockType$supports5 === void 0 ? void 0 : (_blockType$supports5$ = _blockType$supports5[featureKey]) === null || _blockType$supports5$ === void 0 ? void 0 : _blockType$supports5$.__experimentalSelector;
8497
8498 if (featureSelector) {
8499 featureSelectors[featureName] = scopeSelector(selector, featureSelector);
8500 }
8501 });
8502 result[name] = {
8503 duotoneSelector,
8504 fallbackGapValue,
8505 featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : undefined,
8506 hasLayoutSupport,
8507 name,
8508 selector
8509 };
8510 });
8511 return result;
8512 };
8513 /**
8514 * If there is a separator block whose color is defined in theme.json via background,
8515 * update the separator color to the same value by using border color.
8516 *
8517 * @param {Object} config Theme.json configuration file object.
8518 * @return {Object} configTheme.json configuration file object updated.
8519 */
8520
8521 function updateConfigWithSeparator(config) {
8522 var _config$styles, _config$styles2, _config$styles2$block, _config$styles3, _config$styles3$block, _config$styles4, _config$styles4$block;
8523
8524 const needsSeparatorStyleUpdate = ((_config$styles = config.styles) === null || _config$styles === void 0 ? void 0 : _config$styles.blocks['core/separator']) && ((_config$styles2 = config.styles) === null || _config$styles2 === void 0 ? void 0 : (_config$styles2$block = _config$styles2.blocks['core/separator'].color) === null || _config$styles2$block === void 0 ? void 0 : _config$styles2$block.background) && !((_config$styles3 = config.styles) !== null && _config$styles3 !== void 0 && (_config$styles3$block = _config$styles3.blocks['core/separator'].color) !== null && _config$styles3$block !== void 0 && _config$styles3$block.text) && !((_config$styles4 = config.styles) !== null && _config$styles4 !== void 0 && (_config$styles4$block = _config$styles4.blocks['core/separator'].border) !== null && _config$styles4$block !== void 0 && _config$styles4$block.color);
8525
8526 if (needsSeparatorStyleUpdate) {
8527 var _config$styles5;
8528
8529 return { ...config,
8530 styles: { ...config.styles,
8531 blocks: { ...config.styles.blocks,
8532 'core/separator': { ...config.styles.blocks['core/separator'],
8533 color: { ...config.styles.blocks['core/separator'].color,
8534 text: (_config$styles5 = config.styles) === null || _config$styles5 === void 0 ? void 0 : _config$styles5.blocks['core/separator'].color.background
8535 }
8536 }
8537 }
8538 }
8539 };
8540 }
8541
8542 return config;
8543 }
8544
8545 function useGlobalStylesOutput() {
8546 let {
8547 merged: mergedConfig
8548 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
8549 const [blockGap] = useSetting('spacing.blockGap');
8550 const hasBlockGapSupport = blockGap !== null;
8551 const hasFallbackGapSupport = !hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
8552
8553 const disableLayoutStyles = (0,external_wp_data_namespaceObject.useSelect)(select => {
8554 const {
8555 getSettings
8556 } = select(external_wp_blockEditor_namespaceObject.store);
8557 return !!getSettings().disableLayoutStyles;
8558 });
8559 return (0,external_wp_element_namespaceObject.useMemo)(() => {
8560 var _mergedConfig, _mergedConfig2;
8561
8562 if (!((_mergedConfig = mergedConfig) !== null && _mergedConfig !== void 0 && _mergedConfig.styles) || !((_mergedConfig2 = mergedConfig) !== null && _mergedConfig2 !== void 0 && _mergedConfig2.settings)) {
8563 return [];
8564 }
8565
8566 mergedConfig = updateConfigWithSeparator(mergedConfig);
8567 const blockSelectors = getBlockSelectors((0,external_wp_blocks_namespaceObject.getBlockTypes)());
8568 const customProperties = toCustomProperties(mergedConfig, blockSelectors);
8569 const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles);
8570 const filters = toSvgFilters(mergedConfig, blockSelectors);
8571 const stylesheets = [{
8572 css: customProperties,
8573 isGlobalStyles: true
8574 }, {
8575 css: globalStyles,
8576 isGlobalStyles: true
8577 }];
8578 return [stylesheets, mergedConfig.settings, filters];
8579 }, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig, disableLayoutStyles]);
8580 }
8581
8582 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/preview.js
8583
8584
8585 /**
8586 * WordPress dependencies
8587 */
8588
8589
8590
8591
8592 /**
8593 * Internal dependencies
8594 */
8595
8596
8597
8598 const firstFrame = {
8599 start: {
8600 scale: 1,
8601 opacity: 1
8602 },
8603 hover: {
8604 scale: 0,
8605 opacity: 0
8606 }
8607 };
8608 const midFrame = {
8609 hover: {
8610 opacity: 1
8611 },
8612 start: {
8613 opacity: 0.5
8614 }
8615 };
8616 const secondFrame = {
8617 hover: {
8618 scale: 1,
8619 opacity: 1
8620 },
8621 start: {
8622 scale: 0,
8623 opacity: 0
8624 }
8625 };
8626 const normalizedWidth = 248;
8627 const normalizedHeight = 152;
8628 const normalizedColorSwatchSize = 32;
8629
8630 const StylesPreview = _ref => {
8631 let {
8632 label,
8633 isFocused,
8634 withHoverView
8635 } = _ref;
8636 const [fontWeight] = useStyle('typography.fontWeight');
8637 const [fontFamily = 'serif'] = useStyle('typography.fontFamily');
8638 const [headingFontFamily = fontFamily] = useStyle('elements.h1.typography.fontFamily');
8639 const [headingFontWeight = fontWeight] = useStyle('elements.h1.typography.fontWeight');
8640 const [textColor = 'black'] = useStyle('color.text');
8641 const [headingColor = textColor] = useStyle('elements.h1.color.text');
8642 const [backgroundColor = 'white'] = useStyle('color.background');
8643 const [gradientValue] = useStyle('color.gradient');
8644 const [styles] = useGlobalStylesOutput();
8645 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
8646 const [coreColors] = useSetting('color.palette.core');
8647 const [themeColors] = useSetting('color.palette.theme');
8648 const [customColors] = useSetting('color.palette.custom');
8649 const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
8650 const [containerResizeListener, {
8651 width
8652 }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
8653 const ratio = width ? width / normalizedWidth : 1;
8654 const paletteColors = (themeColors !== null && themeColors !== void 0 ? themeColors : []).concat(customColors !== null && customColors !== void 0 ? customColors : []).concat(coreColors !== null && coreColors !== void 0 ? coreColors : []);
8655 const highlightedColors = paletteColors.filter( // we exclude these two colors because they are already visible in the preview.
8656 _ref2 => {
8657 let {
8658 color
8659 } = _ref2;
8660 return color !== backgroundColor && color !== headingColor;
8661 }).slice(0, 2); // Reset leaked styles from WP common.css and remove main content layout padding and border.
8662
8663 const editorStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
8664 if (styles) {
8665 return [...styles, {
8666 css: 'html{overflow:hidden}body{min-width: 0;padding: 0;border: none;}',
8667 isGlobalStyles: true
8668 }];
8669 }
8670
8671 return styles;
8672 }, [styles]);
8673 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, {
8674 className: "edit-site-global-styles-preview__iframe",
8675 head: (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
8676 styles: editorStyles
8677 }),
8678 style: {
8679 height: normalizedHeight * ratio,
8680 visibility: !width ? 'hidden' : 'visible'
8681 },
8682 onMouseEnter: () => setIsHovered(true),
8683 onMouseLeave: () => setIsHovered(false),
8684 tabIndex: -1
8685 }, containerResizeListener, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
8686 style: {
8687 height: normalizedHeight * ratio,
8688 width: '100%',
8689 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
8690 cursor: 'pointer'
8691 },
8692 initial: "start",
8693 animate: (isHovered || isFocused) && !disableMotion && label ? 'hover' : 'start'
8694 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
8695 variants: firstFrame,
8696 style: {
8697 height: '100%',
8698 overflow: 'hidden'
8699 }
8700 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8701 spacing: 10 * ratio,
8702 justify: "center",
8703 style: {
8704 height: '100%',
8705 overflow: 'hidden'
8706 }
8707 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
8708 style: {
8709 fontFamily: headingFontFamily,
8710 fontSize: 65 * ratio,
8711 color: headingColor,
8712 fontWeight: headingFontWeight
8713 },
8714 animate: {
8715 scale: 1,
8716 opacity: 1
8717 },
8718 initial: {
8719 scale: 0.1,
8720 opacity: 0
8721 },
8722 transition: {
8723 delay: 0.3,
8724 type: 'tween'
8725 }
8726 }, "Aa"), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8727 spacing: 4 * ratio
8728 }, highlightedColors.map((_ref3, index) => {
8729 let {
8730 slug,
8731 color
8732 } = _ref3;
8733 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
8734 key: slug,
8735 style: {
8736 height: normalizedColorSwatchSize * ratio,
8737 width: normalizedColorSwatchSize * ratio,
8738 background: color,
8739 borderRadius: normalizedColorSwatchSize * ratio / 2
8740 },
8741 animate: {
8742 scale: 1,
8743 opacity: 1
8744 },
8745 initial: {
8746 scale: 0.1,
8747 opacity: 0
8748 },
8749 transition: {
8750 delay: index === 1 ? 0.2 : 0.1
8751 }
8752 });
8753 })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
8754 variants: withHoverView && midFrame,
8755 style: {
8756 height: '100%',
8757 width: '100%',
8758 position: 'absolute',
8759 top: 0,
8760 overflow: 'hidden',
8761 filter: 'blur(60px)',
8762 opacity: 0.1
8763 }
8764 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8765 spacing: 0,
8766 justify: "flex-start",
8767 style: {
8768 height: '100%',
8769 overflow: 'hidden'
8770 }
8771 }, paletteColors.slice(0, 4).map((_ref4, index) => {
8772 let {
8773 color
8774 } = _ref4;
8775 return (0,external_wp_element_namespaceObject.createElement)("div", {
8776 key: index,
8777 style: {
8778 height: '100%',
8779 background: color,
8780 flexGrow: 1
8781 }
8782 });
8783 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
8784 variants: secondFrame,
8785 style: {
8786 height: '100%',
8787 width: '100%',
8788 overflow: 'hidden',
8789 position: 'absolute',
8790 top: 0
8791 }
8792 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8793 spacing: 3 * ratio,
8794 justify: "center",
8795 style: {
8796 height: '100%',
8797 overflow: 'hidden',
8798 padding: 10 * ratio,
8799 boxSizing: 'border-box'
8800 }
8801 }, label && (0,external_wp_element_namespaceObject.createElement)("div", {
8802 style: {
8803 fontSize: 40 * ratio,
8804 fontFamily: headingFontFamily,
8805 color: headingColor,
8806 fontWeight: headingFontWeight,
8807 lineHeight: '1em',
8808 textAlign: 'center'
8809 }
8810 }, label)))));
8811 };
8812
8813 /* harmony default export */ var preview = (StylesPreview);
8814
8815 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-root.js
8816
8817
8818 /**
8819 * WordPress dependencies
8820 */
8821
8822
8823
8824
8825
8826 /**
8827 * Internal dependencies
8828 */
8829
8830
8831
8832
8833
8834
8835 function ScreenRoot() {
8836 const {
8837 variations
8838 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8839 return {
8840 variations: select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations()
8841 };
8842 }, []);
8843 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
8844 size: "small"
8845 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8846 spacing: 4
8847 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardMedia, null, (0,external_wp_element_namespaceObject.createElement)(preview, null))), !!(variations !== null && variations !== void 0 && variations.length) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
8848 path: "/variations",
8849 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Browse styles')
8850 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8851 justify: "space-between"
8852 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Browse styles')), (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, {
8853 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
8854 })))), (0,external_wp_element_namespaceObject.createElement)(context_menu, null))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardDivider, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
8855 as: "p",
8856 paddingTop: 2
8857 /*
8858 * 13px matches the text inset of the NavigationButton (12px padding, plus the width of the button's border).
8859 * This is an ad hoc override for this particular instance only and should be reconsidered before making into a pattern.
8860 */
8861 ,
8862 paddingX: "13px",
8863 marginBottom: 4
8864 }, (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks for the whole site.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
8865 path: "/blocks",
8866 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Blocks styles')
8867 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8868 justify: "space-between"
8869 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Blocks')), (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, {
8870 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
8871 }))))));
8872 }
8873
8874 /* harmony default export */ var screen_root = (ScreenRoot);
8875
8876 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/header.js
8877
8878
8879 /**
8880 * WordPress dependencies
8881 */
8882
8883
8884
8885
8886 function ScreenHeader(_ref) {
8887 let {
8888 title,
8889 description
8890 } = _ref;
8891 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
8892 spacing: 0
8893 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalView, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
8894 marginBottom: 0,
8895 paddingX: 4,
8896 paddingY: 3
8897 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8898 spacing: 2
8899 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, {
8900 style: // TODO: This style override is also used in ToolsPanelHeader.
8901 // It should be supported out-of-the-box by Button.
8902 {
8903 minWidth: 24,
8904 padding: 0
8905 },
8906 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
8907 isSmall: true,
8908 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view')
8909 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
8910 level: 5
8911 }, title))))), description && (0,external_wp_element_namespaceObject.createElement)("p", {
8912 className: "edit-site-global-styles-header__description"
8913 }, description));
8914 }
8915
8916 /* harmony default export */ var header = (ScreenHeader);
8917
8918 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-block-list.js
8919
8920
8921 /**
8922 * WordPress dependencies
8923 */
8924
8925
8926
8927
8928
8929
8930
8931
8932 /**
8933 * Internal dependencies
8934 */
8935
8936
8937
8938
8939
8940
8941
8942
8943 function useSortedBlockTypes() {
8944 const blockItems = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).getBlockTypes(), []); // Ensure core blocks are prioritized in the returned results,
8945 // because third party blocks can be registered earlier than
8946 // the core blocks (usually by using the `init` action),
8947 // thus affecting the display order.
8948 // We don't sort reusable blocks as they are handled differently.
8949
8950 const groupByType = (blocks, block) => {
8951 const {
8952 core,
8953 noncore
8954 } = blocks;
8955 const type = block.name.startsWith('core/') ? core : noncore;
8956 type.push(block);
8957 return blocks;
8958 };
8959
8960 const {
8961 core: coreItems,
8962 noncore: nonCoreItems
8963 } = blockItems.reduce(groupByType, {
8964 core: [],
8965 noncore: []
8966 });
8967 return [...coreItems, ...nonCoreItems];
8968 }
8969
8970 function BlockMenuItem(_ref) {
8971 let {
8972 block
8973 } = _ref;
8974 const hasTypographyPanel = useHasTypographyPanel(block.name);
8975 const hasColorPanel = useHasColorPanel(block.name);
8976 const hasBorderPanel = useHasBorderPanel(block.name);
8977 const hasDimensionsPanel = useHasDimensionsPanel(block.name);
8978 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
8979 const hasBlockMenuItem = hasTypographyPanel || hasColorPanel || hasLayoutPanel;
8980
8981 if (!hasBlockMenuItem) {
8982 return null;
8983 }
8984
8985 const navigationButtonLabel = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: is the name of a block e.g., 'Image' or 'Table'.
8986 (0,external_wp_i18n_namespaceObject.__)('%s block styles'), block.title);
8987 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
8988 path: '/blocks/' + block.name,
8989 "aria-label": navigationButtonLabel
8990 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
8991 justify: "flex-start"
8992 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, {
8993 icon: block.icon
8994 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, block.title)));
8995 }
8996
8997 function ScreenBlockList() {
8998 const sortedBlockTypes = useSortedBlockTypes();
8999 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
9000 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
9001 const isMatchingSearchTerm = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).isMatchingSearchTerm, []);
9002 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
9003 if (!filterValue) {
9004 return sortedBlockTypes;
9005 }
9006
9007 return sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue));
9008 }, [filterValue, sortedBlockTypes, isMatchingSearchTerm]);
9009 const blockTypesListRef = (0,external_wp_element_namespaceObject.useRef)(); // Announce search results on change
9010
9011 (0,external_wp_element_namespaceObject.useEffect)(() => {
9012 if (!filterValue) {
9013 return;
9014 } // We extract the results from the wrapper div's `ref` because
9015 // filtered items can contain items that will eventually not
9016 // render and there is no reliable way to detect when a child
9017 // will return `null`.
9018 // TODO: We should find a better way of handling this as it's
9019 // fragile and depends on the number of rendered elements of `BlockMenuItem`,
9020 // which is now one.
9021 // @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116
9022
9023
9024 const count = blockTypesListRef.current.childElementCount;
9025 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
9026 /* translators: %d: number of results. */
9027 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
9028 debouncedSpeak(resultsFoundMessage, count);
9029 }, [filterValue, debouncedSpeak]);
9030 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
9031 title: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
9032 description: (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks and for the whole site.')
9033 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
9034 __nextHasNoMarginBottom: true,
9035 className: "edit-site-block-types-search",
9036 onChange: setFilterValue,
9037 value: filterValue,
9038 label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks'),
9039 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
9040 }), (0,external_wp_element_namespaceObject.createElement)("div", {
9041 ref: blockTypesListRef,
9042 className: "edit-site-block-types-item-list"
9043 }, filteredBlockTypes.map(block => (0,external_wp_element_namespaceObject.createElement)(BlockMenuItem, {
9044 block: block,
9045 key: 'menu-itemblock-' + block.name
9046 }))));
9047 }
9048
9049 /* harmony default export */ var screen_block_list = (ScreenBlockList);
9050
9051 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-block.js
9052
9053
9054 /**
9055 * WordPress dependencies
9056 */
9057
9058 /**
9059 * Internal dependencies
9060 */
9061
9062
9063
9064
9065 function ScreenBlock(_ref) {
9066 let {
9067 name
9068 } = _ref;
9069 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
9070 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
9071 title: blockType.title
9072 }), (0,external_wp_element_namespaceObject.createElement)(context_menu, {
9073 parentMenu: '/blocks/' + name,
9074 name: name
9075 }));
9076 }
9077
9078 /* harmony default export */ var screen_block = (ScreenBlock);
9079
9080 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/subtitle.js
9081
9082
9083 /**
9084 * WordPress dependencies
9085 */
9086
9087
9088 function Subtitle(_ref) {
9089 let {
9090 children
9091 } = _ref;
9092 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
9093 className: "edit-site-global-styles-subtitle",
9094 level: 2
9095 }, children);
9096 }
9097
9098 /* harmony default export */ var subtitle = (Subtitle);
9099
9100 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-typography.js
9101
9102
9103 /**
9104 * WordPress dependencies
9105 */
9106
9107
9108 /**
9109 * Internal dependencies
9110 */
9111
9112
9113
9114
9115
9116
9117
9118 function Item(_ref) {
9119 let {
9120 name,
9121 parentMenu,
9122 element,
9123 label
9124 } = _ref;
9125 const hasSupport = !name;
9126 const prefix = element === 'text' || !element ? '' : `elements.${element}.`;
9127 const extraStyles = element === 'link' ? {
9128 textDecoration: 'underline'
9129 } : {};
9130 const [fontFamily] = useStyle(prefix + 'typography.fontFamily', name);
9131 const [fontStyle] = useStyle(prefix + 'typography.fontStyle', name);
9132 const [fontWeight] = useStyle(prefix + 'typography.fontWeight', name);
9133 const [letterSpacing] = useStyle(prefix + 'typography.letterSpacing', name);
9134 const [backgroundColor] = useStyle(prefix + 'color.background', name);
9135 const [gradientValue] = useStyle(prefix + 'color.gradient', name);
9136 const [color] = useStyle(prefix + 'color.text', name);
9137
9138 if (!hasSupport) {
9139 return null;
9140 }
9141
9142 const navigationButtonLabel = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: is a subset of Typography, e.g., 'text' or 'links'.
9143 (0,external_wp_i18n_namespaceObject.__)('Typography %s styles'), label);
9144 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
9145 path: parentMenu + '/typography/' + element,
9146 "aria-label": navigationButtonLabel
9147 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
9148 justify: "flex-start"
9149 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
9150 className: "edit-site-global-styles-screen-typography__indicator",
9151 style: {
9152 fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif',
9153 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
9154 color,
9155 fontStyle,
9156 fontWeight,
9157 letterSpacing,
9158 ...extraStyles
9159 }
9160 }, (0,external_wp_i18n_namespaceObject.__)('Aa')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, label)));
9161 }
9162
9163 function ScreenTypography(_ref2) {
9164 let {
9165 name
9166 } = _ref2;
9167 const parentMenu = name === undefined ? '' : '/blocks/' + name;
9168 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
9169 title: (0,external_wp_i18n_namespaceObject.__)('Typography'),
9170 description: (0,external_wp_i18n_namespaceObject.__)('Manage the typography settings for different elements.')
9171 }), !name && (0,external_wp_element_namespaceObject.createElement)("div", {
9172 className: "edit-site-global-styles-screen-typography"
9173 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
9174 spacing: 3
9175 }, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Elements')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, {
9176 isBordered: true,
9177 isSeparated: true
9178 }, (0,external_wp_element_namespaceObject.createElement)(Item, {
9179 name: name,
9180 parentMenu: parentMenu,
9181 element: "text",
9182 label: (0,external_wp_i18n_namespaceObject.__)('Text')
9183 }), (0,external_wp_element_namespaceObject.createElement)(Item, {
9184 name: name,
9185 parentMenu: parentMenu,
9186 element: "link",
9187 label: (0,external_wp_i18n_namespaceObject.__)('Links')
9188 }), (0,external_wp_element_namespaceObject.createElement)(Item, {
9189 name: name,
9190 parentMenu: parentMenu,
9191 element: "heading",
9192 label: (0,external_wp_i18n_namespaceObject.__)('Headings')
9193 }), (0,external_wp_element_namespaceObject.createElement)(Item, {
9194 name: name,
9195 parentMenu: parentMenu,
9196 element: "button",
9197 label: (0,external_wp_i18n_namespaceObject.__)('Buttons')
9198 })))), !!name && (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, {
9199 name: name,
9200 element: "text"
9201 }));
9202 }
9203
9204 /* harmony default export */ var screen_typography = (ScreenTypography);
9205
9206 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/typography-preview.js
9207
9208
9209 /**
9210 * Internal dependencies
9211 */
9212
9213 function TypographyPreview(_ref) {
9214 let {
9215 name,
9216 element,
9217 headingLevel
9218 } = _ref;
9219 let prefix = '';
9220
9221 if (element === 'heading') {
9222 prefix = `elements.${headingLevel}.`;
9223 } else if (element && element !== 'text') {
9224 prefix = `elements.${element}.`;
9225 }
9226
9227 const [fontFamily] = useStyle(prefix + 'typography.fontFamily', name);
9228 const [gradientValue] = useStyle(prefix + 'color.gradient', name);
9229 const [backgroundColor] = useStyle(prefix + 'color.background', name);
9230 const [color] = useStyle(prefix + 'color.text', name);
9231 const [fontSize] = useStyle(prefix + 'typography.fontSize', name);
9232 const [fontStyle] = useStyle(prefix + 'typography.fontStyle', name);
9233 const [fontWeight] = useStyle(prefix + 'typography.fontWeight', name);
9234 const [letterSpacing] = useStyle(prefix + 'typography.letterSpacing', name);
9235 const extraStyles = element === 'link' ? {
9236 textDecoration: 'underline'
9237 } : {};
9238 return (0,external_wp_element_namespaceObject.createElement)("div", {
9239 className: "edit-site-typography-preview",
9240 style: {
9241 fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif',
9242 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
9243 color,
9244 fontSize,
9245 fontStyle,
9246 fontWeight,
9247 letterSpacing,
9248 ...extraStyles
9249 }
9250 }, "Aa");
9251 }
9252
9253 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-typography-element.js
9254
9255
9256 /**
9257 * WordPress dependencies
9258 */
9259
9260
9261
9262 /**
9263 * Internal dependencies
9264 */
9265
9266
9267
9268
9269 const screen_typography_element_elements = {
9270 text: {
9271 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts used on the site.'),
9272 title: (0,external_wp_i18n_namespaceObject.__)('Text')
9273 },
9274 link: {
9275 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on the links.'),
9276 title: (0,external_wp_i18n_namespaceObject.__)('Links')
9277 },
9278 heading: {
9279 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on headings.'),
9280 title: (0,external_wp_i18n_namespaceObject.__)('Headings')
9281 },
9282 button: {
9283 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on buttons.'),
9284 title: (0,external_wp_i18n_namespaceObject.__)('Buttons')
9285 }
9286 };
9287
9288 function ScreenTypographyElement(_ref) {
9289 let {
9290 name,
9291 element
9292 } = _ref;
9293 const [headingLevel, setHeadingLevel] = (0,external_wp_element_namespaceObject.useState)('heading');
9294 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
9295 title: screen_typography_element_elements[element].title,
9296 description: screen_typography_element_elements[element].description
9297 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
9298 marginX: 4
9299 }, (0,external_wp_element_namespaceObject.createElement)(TypographyPreview, {
9300 name: name,
9301 element: element,
9302 headingLevel: headingLevel
9303 })), element === 'heading' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
9304 marginX: 4,
9305 marginBottom: "1em"
9306 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, {
9307 label: (0,external_wp_i18n_namespaceObject.__)('Select heading level'),
9308 hideLabelFromVision: true,
9309 value: headingLevel,
9310 onChange: setHeadingLevel,
9311 isBlock: true,
9312 size: "__unstable-large",
9313 __nextHasNoMarginBottom: true
9314 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
9315 value: "heading"
9316 /* translators: 'All' refers to selecting all heading levels
9317 and applying the same style to h1-h6. */
9318 ,
9319 label: (0,external_wp_i18n_namespaceObject.__)('All')
9320 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
9321 value: "h1",
9322 label: (0,external_wp_i18n_namespaceObject.__)('H1')
9323 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
9324 value: "h2",
9325 label: (0,external_wp_i18n_namespaceObject.__)('H2')
9326 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
9327 value: "h3",
9328 label: (0,external_wp_i18n_namespaceObject.__)('H3')
9329 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
9330 value: "h4",
9331 label: (0,external_wp_i18n_namespaceObject.__)('H4')
9332 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
9333 value: "h5",
9334 label: (0,external_wp_i18n_namespaceObject.__)('H5')
9335 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
9336 value: "h6",
9337 label: (0,external_wp_i18n_namespaceObject.__)('H6')
9338 }))), (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, {
9339 name: name,
9340 element: element,
9341 headingLevel: headingLevel
9342 }));
9343 }
9344
9345 /* harmony default export */ var screen_typography_element = (ScreenTypographyElement);
9346
9347 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/shuffle.js
9348
9349
9350 /**
9351 * WordPress dependencies
9352 */
9353
9354 const shuffle = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9355 viewBox: "0 0 24 24",
9356 xmlns: "http://www.w3.org/2000/SVG"
9357 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9358 d: "M17.192 6.75L15.47 5.03l1.06-1.06 3.537 3.53-3.537 3.53-1.06-1.06 1.723-1.72h-3.19c-.602 0-.993.202-1.28.498-.309.319-.538.792-.695 1.383-.13.488-.222 1.023-.296 1.508-.034.664-.116 1.413-.303 2.117-.193.721-.513 1.467-1.068 2.04-.575.594-1.359.954-2.357.954H4v-1.5h4.003c.601 0 .993-.202 1.28-.498.308-.319.538-.792.695-1.383.149-.557.216-1.093.288-1.662l.039-.31a9.653 9.653 0 0 1 .272-1.653c.193-.722.513-1.467 1.067-2.04.576-.594 1.36-.954 2.358-.954h3.19zM8.004 6.75c.8 0 1.46.23 1.988.628a6.24 6.24 0 0 0-.684 1.396 1.725 1.725 0 0 0-.024-.026c-.287-.296-.679-.498-1.28-.498H4v-1.5h4.003zM12.699 14.726c-.161.459-.38.94-.684 1.396.527.397 1.188.628 1.988.628h3.19l-1.722 1.72 1.06 1.06L20.067 16l-3.537-3.53-1.06 1.06 1.723 1.72h-3.19c-.602 0-.993-.202-1.28-.498a1.96 1.96 0 0 1-.024-.026z"
9359 }));
9360 /* harmony default export */ var library_shuffle = (shuffle);
9361
9362 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-indicator-wrapper.js
9363
9364
9365
9366 /**
9367 * External dependencies
9368 */
9369
9370 /**
9371 * WordPress dependencies
9372 */
9373
9374
9375
9376 function ColorIndicatorWrapper(_ref) {
9377 let {
9378 className,
9379 ...props
9380 } = _ref;
9381 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, extends_extends({
9382 className: classnames_default()('edit-site-global-styles__color-indicator-wrapper', className)
9383 }, props));
9384 }
9385
9386 /* harmony default export */ var color_indicator_wrapper = (ColorIndicatorWrapper);
9387
9388 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/palette.js
9389
9390
9391 /**
9392 * WordPress dependencies
9393 */
9394
9395
9396
9397
9398 /**
9399 * Internal dependencies
9400 */
9401
9402
9403
9404
9405
9406 const EMPTY_COLORS = [];
9407
9408 function Palette(_ref) {
9409 let {
9410 name
9411 } = _ref;
9412 const [customColors] = useSetting('color.palette.custom');
9413 const [themeColors] = useSetting('color.palette.theme');
9414 const [defaultColors] = useSetting('color.palette.default');
9415 const [defaultPaletteEnabled] = useSetting('color.defaultPalette', name);
9416 const [randomizeThemeColors] = useColorRandomizer();
9417 const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(customColors || EMPTY_COLORS), ...(themeColors || EMPTY_COLORS), ...(defaultColors && defaultPaletteEnabled ? defaultColors : EMPTY_COLORS)], [customColors, themeColors, defaultColors, defaultPaletteEnabled]);
9418 const screenPath = !name ? '/colors/palette' : '/blocks/' + name + '/colors/palette';
9419 const paletteButtonText = colors.length > 0 ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of palette colors.
9420 (0,external_wp_i18n_namespaceObject._n)('%d color', '%d colors', colors.length), colors.length) : (0,external_wp_i18n_namespaceObject.__)('Add custom colors');
9421 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
9422 spacing: 3
9423 }, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Palette')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, {
9424 isBordered: true,
9425 isSeparated: true
9426 }, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
9427 path: screenPath,
9428 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Color palettes')
9429 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
9430 direction: colors.length === 0 ? 'row-reverse' : 'row'
9431 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalZStack, {
9432 isLayered: false,
9433 offset: -8
9434 }, colors.slice(0, 5).map((_ref2, index) => {
9435 let {
9436 color
9437 } = _ref2;
9438 return (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9439 key: `${color}-${index}`
9440 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9441 colorValue: color
9442 }));
9443 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, paletteButtonText)))), randomizeThemeColors && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9444 variant: "secondary",
9445 icon: library_shuffle,
9446 onClick: randomizeThemeColors
9447 }, (0,external_wp_i18n_namespaceObject.__)('Randomize colors')));
9448 }
9449
9450 /* harmony default export */ var palette = (Palette);
9451
9452 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-colors.js
9453
9454
9455 /**
9456 * WordPress dependencies
9457 */
9458
9459
9460 /**
9461 * Internal dependencies
9462 */
9463
9464
9465
9466
9467
9468
9469
9470
9471 function BackgroundColorItem(_ref) {
9472 let {
9473 name,
9474 parentMenu
9475 } = _ref;
9476 const supports = getSupportedGlobalStylesPanels(name);
9477 const hasSupport = supports.includes('backgroundColor') || supports.includes('background');
9478 const [backgroundColor] = useStyle('color.background', name);
9479 const [gradientValue] = useStyle('color.gradient', name);
9480
9481 if (!hasSupport) {
9482 return null;
9483 }
9484
9485 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
9486 path: parentMenu + '/colors/background',
9487 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Colors background styles')
9488 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
9489 justify: "flex-start"
9490 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9491 expanded: false
9492 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9493 colorValue: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
9494 "data-testid": "background-color-indicator"
9495 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
9496 className: "edit-site-global-styles__color-label"
9497 }, (0,external_wp_i18n_namespaceObject.__)('Background'))));
9498 }
9499
9500 function TextColorItem(_ref2) {
9501 let {
9502 name,
9503 parentMenu
9504 } = _ref2;
9505 const supports = getSupportedGlobalStylesPanels(name);
9506 const hasSupport = supports.includes('color');
9507 const [color] = useStyle('color.text', name);
9508
9509 if (!hasSupport) {
9510 return null;
9511 }
9512
9513 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
9514 path: parentMenu + '/colors/text',
9515 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Colors text styles')
9516 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
9517 justify: "flex-start"
9518 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9519 expanded: false
9520 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9521 colorValue: color,
9522 "data-testid": "text-color-indicator"
9523 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
9524 className: "edit-site-global-styles__color-label"
9525 }, (0,external_wp_i18n_namespaceObject.__)('Text'))));
9526 }
9527
9528 function LinkColorItem(_ref3) {
9529 let {
9530 name,
9531 parentMenu
9532 } = _ref3;
9533 const supports = getSupportedGlobalStylesPanels(name);
9534 const hasSupport = supports.includes('linkColor');
9535 const [color] = useStyle('elements.link.color.text', name);
9536 const [colorHover] = useStyle('elements.link.:hover.color.text', name);
9537
9538 if (!hasSupport) {
9539 return null;
9540 }
9541
9542 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
9543 path: parentMenu + '/colors/link',
9544 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Colors link styles')
9545 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
9546 justify: "flex-start"
9547 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalZStack, {
9548 isLayered: false,
9549 offset: -8
9550 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9551 expanded: false
9552 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9553 colorValue: color
9554 })), (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9555 expanded: false
9556 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9557 colorValue: colorHover
9558 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
9559 className: "edit-site-global-styles__color-label"
9560 }, (0,external_wp_i18n_namespaceObject.__)('Links'))));
9561 }
9562
9563 function HeadingColorItem(_ref4) {
9564 let {
9565 name,
9566 parentMenu
9567 } = _ref4;
9568 const supports = getSupportedGlobalStylesPanels(name);
9569 const hasSupport = supports.includes('color');
9570 const [color] = useStyle('elements.heading.color.text', name);
9571 const [bgColor] = useStyle('elements.heading.color.background', name);
9572
9573 if (!hasSupport) {
9574 return null;
9575 }
9576
9577 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
9578 path: parentMenu + '/colors/heading',
9579 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Colors heading styles')
9580 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
9581 justify: "flex-start"
9582 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalZStack, {
9583 isLayered: false,
9584 offset: -8
9585 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9586 expanded: false
9587 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9588 colorValue: bgColor
9589 })), (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9590 expanded: false
9591 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9592 colorValue: color
9593 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Headings'))));
9594 }
9595
9596 function ButtonColorItem(_ref5) {
9597 let {
9598 name,
9599 parentMenu
9600 } = _ref5;
9601 const supports = getSupportedGlobalStylesPanels(name);
9602 const hasSupport = supports.includes('buttonColor');
9603 const [color] = useStyle('elements.button.color.text', name);
9604 const [bgColor] = useStyle('elements.button.color.background', name);
9605
9606 if (!hasSupport) {
9607 return null;
9608 }
9609
9610 return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, {
9611 path: parentMenu + '/colors/button'
9612 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
9613 justify: "flex-start"
9614 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalZStack, {
9615 isLayered: false,
9616 offset: -8
9617 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9618 expanded: false
9619 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9620 colorValue: bgColor
9621 })), (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
9622 expanded: false
9623 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
9624 colorValue: color
9625 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
9626 className: "edit-site-global-styles__color-label"
9627 }, (0,external_wp_i18n_namespaceObject.__)('Buttons'))));
9628 }
9629
9630 function ScreenColors(_ref6) {
9631 let {
9632 name
9633 } = _ref6;
9634 const parentMenu = name === undefined ? '' : '/blocks/' + name;
9635 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
9636 title: (0,external_wp_i18n_namespaceObject.__)('Colors'),
9637 description: (0,external_wp_i18n_namespaceObject.__)('Manage palettes and the default color of different global elements on the site.')
9638 }), (0,external_wp_element_namespaceObject.createElement)("div", {
9639 className: "edit-site-global-styles-screen-colors"
9640 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
9641 spacing: 10
9642 }, (0,external_wp_element_namespaceObject.createElement)(palette, {
9643 name: name
9644 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
9645 spacing: 3
9646 }, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Elements')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, {
9647 isBordered: true,
9648 isSeparated: true
9649 }, (0,external_wp_element_namespaceObject.createElement)(BackgroundColorItem, {
9650 name: name,
9651 parentMenu: parentMenu
9652 }), (0,external_wp_element_namespaceObject.createElement)(TextColorItem, {
9653 name: name,
9654 parentMenu: parentMenu
9655 }), (0,external_wp_element_namespaceObject.createElement)(LinkColorItem, {
9656 name: name,
9657 parentMenu: parentMenu
9658 }), (0,external_wp_element_namespaceObject.createElement)(HeadingColorItem, {
9659 name: name,
9660 parentMenu: parentMenu
9661 }), (0,external_wp_element_namespaceObject.createElement)(ButtonColorItem, {
9662 name: name,
9663 parentMenu: parentMenu
9664 }))))));
9665 }
9666
9667 /* harmony default export */ var screen_colors = (ScreenColors);
9668
9669 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-palette-panel.js
9670
9671
9672 /**
9673 * WordPress dependencies
9674 */
9675
9676
9677 /**
9678 * Internal dependencies
9679 */
9680
9681
9682 function ColorPalettePanel(_ref) {
9683 let {
9684 name
9685 } = _ref;
9686 const [themeColors, setThemeColors] = useSetting('color.palette.theme', name);
9687 const [baseThemeColors] = useSetting('color.palette.theme', name, 'base');
9688 const [defaultColors, setDefaultColors] = useSetting('color.palette.default', name);
9689 const [baseDefaultColors] = useSetting('color.palette.default', name, 'base');
9690 const [customColors, setCustomColors] = useSetting('color.palette.custom', name);
9691 const [defaultPaletteEnabled] = useSetting('color.defaultPalette', name);
9692 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
9693 className: "edit-site-global-styles-color-palette-panel",
9694 spacing: 10
9695 }, !!themeColors && !!themeColors.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
9696 canReset: themeColors !== baseThemeColors,
9697 canOnlyChangeValues: true,
9698 colors: themeColors,
9699 onChange: setThemeColors,
9700 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme')
9701 }), !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
9702 canReset: defaultColors !== baseDefaultColors,
9703 canOnlyChangeValues: true,
9704 colors: defaultColors,
9705 onChange: setDefaultColors,
9706 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default')
9707 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
9708 colors: customColors,
9709 onChange: setCustomColors,
9710 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'),
9711 emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom colors are empty! Add some colors to create your own color palette.'),
9712 slugPrefix: "custom-"
9713 }));
9714 }
9715
9716 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/gradients-palette-panel.js
9717
9718
9719 /**
9720 * WordPress dependencies
9721 */
9722
9723
9724 /**
9725 * Internal dependencies
9726 */
9727
9728
9729
9730
9731 const gradients_palette_panel_noop = () => {};
9732
9733 function GradientPalettePanel(_ref) {
9734 let {
9735 name
9736 } = _ref;
9737 const [themeGradients, setThemeGradients] = useSetting('color.gradients.theme', name);
9738 const [baseThemeGradients] = useSetting('color.gradients.theme', name, 'base');
9739 const [defaultGradients, setDefaultGradients] = useSetting('color.gradients.default', name);
9740 const [baseDefaultGradients] = useSetting('color.gradients.default', name, 'base');
9741 const [customGradients, setCustomGradients] = useSetting('color.gradients.custom', name);
9742 const [defaultPaletteEnabled] = useSetting('color.defaultGradients', name);
9743 const [customDuotone] = useSetting('color.duotone.custom') || [];
9744 const [defaultDuotone] = useSetting('color.duotone.default') || [];
9745 const [themeDuotone] = useSetting('color.duotone.theme') || [];
9746 const [defaultDuotoneEnabled] = useSetting('color.defaultDuotone');
9747 const duotonePalette = [...(customDuotone || []), ...(themeDuotone || []), ...(defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : [])];
9748 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
9749 className: "edit-site-global-styles-gradient-palette-panel",
9750 spacing: 10
9751 }, !!themeGradients && !!themeGradients.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
9752 canReset: themeGradients !== baseThemeGradients,
9753 canOnlyChangeValues: true,
9754 gradients: themeGradients,
9755 onChange: setThemeGradients,
9756 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme')
9757 }), !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
9758 canReset: defaultGradients !== baseDefaultGradients,
9759 canOnlyChangeValues: true,
9760 gradients: defaultGradients,
9761 onChange: setDefaultGradients,
9762 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default')
9763 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
9764 gradients: customGradients,
9765 onChange: setCustomGradients,
9766 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'),
9767 emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom gradients are empty! Add some gradients to create your own palette.'),
9768 slugPrefix: "custom-"
9769 }), !!duotonePalette && !!duotonePalette.length && (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Duotone')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
9770 margin: 3
9771 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotonePicker, {
9772 duotonePalette: duotonePalette,
9773 disableCustomDuotone: true,
9774 disableCustomColors: true,
9775 clearable: false,
9776 onChange: gradients_palette_panel_noop
9777 })));
9778 }
9779
9780 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-color-palette.js
9781
9782
9783 /**
9784 * WordPress dependencies
9785 */
9786
9787
9788 /**
9789 * Internal dependencies
9790 */
9791
9792
9793
9794
9795
9796 function ScreenColorPalette(_ref) {
9797 let {
9798 name
9799 } = _ref;
9800 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
9801 title: (0,external_wp_i18n_namespaceObject.__)('Palette'),
9802 description: (0,external_wp_i18n_namespaceObject.__)('Palettes are used to provide default color options for blocks and various design tools. Here you can edit the colors with their labels.')
9803 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
9804 tabs: [{
9805 name: 'solid',
9806 title: 'Solid',
9807 value: 'solid'
9808 }, {
9809 name: 'gradient',
9810 title: 'Gradient',
9811 value: 'gradient'
9812 }]
9813 }, tab => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, tab.value === 'solid' && (0,external_wp_element_namespaceObject.createElement)(ColorPalettePanel, {
9814 name: name
9815 }), tab.value === 'gradient' && (0,external_wp_element_namespaceObject.createElement)(GradientPalettePanel, {
9816 name: name
9817 }))));
9818 }
9819
9820 /* harmony default export */ var screen_color_palette = (ScreenColorPalette);
9821
9822 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-background-color.js
9823
9824
9825
9826 /**
9827 * WordPress dependencies
9828 */
9829
9830
9831 /**
9832 * Internal dependencies
9833 */
9834
9835
9836
9837
9838 function ScreenBackgroundColor(_ref) {
9839 let {
9840 name
9841 } = _ref;
9842 const supports = getSupportedGlobalStylesPanels(name);
9843 const [solids] = useSetting('color.palette', name);
9844 const [gradients] = useSetting('color.gradients', name);
9845 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
9846 const [areCustomGradientsEnabled] = useSetting('color.customGradient', name);
9847 const colorsPerOrigin = useColorsPerOrigin(name);
9848 const gradientsPerOrigin = useGradientsPerOrigin(name);
9849 const [isBackgroundEnabled] = useSetting('color.background', name);
9850 const hasBackgroundColor = supports.includes('backgroundColor') && isBackgroundEnabled && (solids.length > 0 || areCustomSolidsEnabled);
9851 const hasGradientColor = supports.includes('background') && (gradients.length > 0 || areCustomGradientsEnabled);
9852 const [backgroundColor, setBackgroundColor] = useStyle('color.background', name);
9853 const [userBackgroundColor] = useStyle('color.background', name, 'user');
9854 const [gradient, setGradient] = useStyle('color.gradient', name);
9855 const [userGradient] = useStyle('color.gradient', name, 'user');
9856
9857 if (!hasBackgroundColor && !hasGradientColor) {
9858 return null;
9859 }
9860
9861 let backgroundSettings = {};
9862
9863 if (hasBackgroundColor) {
9864 backgroundSettings = {
9865 colorValue: backgroundColor,
9866 onColorChange: setBackgroundColor
9867 };
9868
9869 if (backgroundColor) {
9870 backgroundSettings.clearable = backgroundColor === userBackgroundColor;
9871 }
9872 }
9873
9874 let gradientSettings = {};
9875
9876 if (hasGradientColor) {
9877 gradientSettings = {
9878 gradientValue: gradient,
9879 onGradientChange: setGradient
9880 };
9881
9882 if (gradient) {
9883 gradientSettings.clearable = gradient === userGradient;
9884 }
9885 }
9886
9887 const controlProps = { ...backgroundSettings,
9888 ...gradientSettings
9889 };
9890 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
9891 title: (0,external_wp_i18n_namespaceObject.__)('Background'),
9892 description: (0,external_wp_i18n_namespaceObject.__)('Set a background color or gradient for the whole site.')
9893 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, extends_extends({
9894 className: "edit-site-screen-background-color__control",
9895 colors: colorsPerOrigin,
9896 gradients: gradientsPerOrigin,
9897 disableCustomColors: !areCustomSolidsEnabled,
9898 disableCustomGradients: !areCustomGradientsEnabled,
9899 __experimentalHasMultipleOrigins: true,
9900 showTitle: false,
9901 enableAlpha: true,
9902 __experimentalIsRenderedInSidebar: true
9903 }, controlProps)));
9904 }
9905
9906 /* harmony default export */ var screen_background_color = (ScreenBackgroundColor);
9907
9908 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-text-color.js
9909
9910
9911 /**
9912 * WordPress dependencies
9913 */
9914
9915
9916 /**
9917 * Internal dependencies
9918 */
9919
9920
9921
9922
9923 function ScreenTextColor(_ref) {
9924 let {
9925 name
9926 } = _ref;
9927 const supports = getSupportedGlobalStylesPanels(name);
9928 const [solids] = useSetting('color.palette', name);
9929 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
9930 const [isTextEnabled] = useSetting('color.text', name);
9931 const colorsPerOrigin = useColorsPerOrigin(name);
9932 const hasTextColor = supports.includes('color') && isTextEnabled && (solids.length > 0 || areCustomSolidsEnabled);
9933 const [color, setColor] = useStyle('color.text', name);
9934 const [userColor] = useStyle('color.text', name, 'user');
9935
9936 if (!hasTextColor) {
9937 return null;
9938 }
9939
9940 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
9941 title: (0,external_wp_i18n_namespaceObject.__)('Text'),
9942 description: (0,external_wp_i18n_namespaceObject.__)('Set the default color used for text across the site.')
9943 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
9944 className: "edit-site-screen-text-color__control",
9945 colors: colorsPerOrigin,
9946 disableCustomColors: !areCustomSolidsEnabled,
9947 __experimentalHasMultipleOrigins: true,
9948 showTitle: false,
9949 enableAlpha: true,
9950 __experimentalIsRenderedInSidebar: true,
9951 colorValue: color,
9952 onColorChange: setColor,
9953 clearable: color === userColor
9954 }));
9955 }
9956
9957 /* harmony default export */ var screen_text_color = (ScreenTextColor);
9958
9959 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-link-color.js
9960
9961
9962 /**
9963 * WordPress dependencies
9964 */
9965
9966
9967
9968 /**
9969 * Internal dependencies
9970 */
9971
9972
9973
9974
9975 function ScreenLinkColor(_ref) {
9976 let {
9977 name
9978 } = _ref;
9979 const supports = getSupportedGlobalStylesPanels(name);
9980 const [solids] = useSetting('color.palette', name);
9981 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
9982 const colorsPerOrigin = useColorsPerOrigin(name);
9983 const [isLinkEnabled] = useSetting('color.link', name);
9984 const hasLinkColor = supports.includes('linkColor') && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
9985 const pseudoStates = {
9986 default: {
9987 label: (0,external_wp_i18n_namespaceObject.__)('Default'),
9988 value: useStyle('elements.link.color.text', name)[0],
9989 handler: useStyle('elements.link.color.text', name)[1],
9990 userValue: useStyle('elements.link.color.text', name, 'user')[0]
9991 },
9992 hover: {
9993 label: (0,external_wp_i18n_namespaceObject.__)('Hover'),
9994 value: useStyle('elements.link.:hover.color.text', name)[0],
9995 handler: useStyle('elements.link.:hover.color.text', name)[1],
9996 userValue: useStyle('elements.link.:hover.color.text', name, 'user')[0]
9997 }
9998 };
9999
10000 if (!hasLinkColor) {
10001 return null;
10002 }
10003
10004 const tabs = Object.entries(pseudoStates).map(_ref2 => {
10005 let [selector, config] = _ref2;
10006 return {
10007 name: selector,
10008 title: config.label,
10009 className: `color-text-${selector}`
10010 };
10011 });
10012 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
10013 title: (0,external_wp_i18n_namespaceObject.__)('Links'),
10014 description: (0,external_wp_i18n_namespaceObject.__)('Set the colors used for links across the site.')
10015 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
10016 tabs: tabs
10017 }, tab => {
10018 var _pseudoStates$tab$nam;
10019
10020 const pseudoSelectorConfig = (_pseudoStates$tab$nam = pseudoStates[tab.name]) !== null && _pseudoStates$tab$nam !== void 0 ? _pseudoStates$tab$nam : null;
10021
10022 if (!pseudoSelectorConfig) {
10023 return null;
10024 }
10025
10026 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
10027 className: "edit-site-screen-link-color__control",
10028 colors: colorsPerOrigin,
10029 disableCustomColors: !areCustomSolidsEnabled,
10030 __experimentalHasMultipleOrigins: true,
10031 showTitle: false,
10032 enableAlpha: true,
10033 __experimentalIsRenderedInSidebar: true,
10034 colorValue: pseudoSelectorConfig.value,
10035 onColorChange: pseudoSelectorConfig.handler,
10036 clearable: pseudoSelectorConfig.value === pseudoSelectorConfig.userValue
10037 }));
10038 }));
10039 }
10040
10041 /* harmony default export */ var screen_link_color = (ScreenLinkColor);
10042
10043 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-heading-color.js
10044
10045
10046
10047 /**
10048 * WordPress dependencies
10049 */
10050
10051
10052
10053
10054 /**
10055 * Internal dependencies
10056 */
10057
10058
10059
10060
10061 function ScreenHeadingColor(_ref) {
10062 let {
10063 name
10064 } = _ref;
10065 const [selectedLevel, setCurrentTab] = (0,external_wp_element_namespaceObject.useState)('heading');
10066 const supports = getSupportedGlobalStylesPanels(name);
10067 const [solids] = useSetting('color.palette', name);
10068 const [gradients] = useSetting('color.gradients', name);
10069 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
10070 const [areCustomGradientsEnabled] = useSetting('color.customGradient', name);
10071 const [isTextEnabled] = useSetting('color.text', name);
10072 const [isBackgroundEnabled] = useSetting('color.background', name);
10073 const colorsPerOrigin = useColorsPerOrigin(name);
10074 const gradientsPerOrigin = useGradientsPerOrigin(name);
10075 const hasTextColor = supports.includes('color') && isTextEnabled && (solids.length > 0 || areCustomSolidsEnabled);
10076 const hasBackgroundColor = supports.includes('backgroundColor') && isBackgroundEnabled && (solids.length > 0 || areCustomSolidsEnabled);
10077 const hasGradientColor = supports.includes('background') && (gradients.length > 0 || areCustomGradientsEnabled);
10078 const [color, setColor] = useStyle('elements.' + selectedLevel + '.color.text', name);
10079 const [userColor] = useStyle('elements.' + selectedLevel + '.color.text', name, 'user');
10080 const [backgroundColor, setBackgroundColor] = useStyle('elements.' + selectedLevel + '.color.background', name);
10081 const [userBackgroundColor] = useStyle('elements.' + selectedLevel + '.color.background', name, 'user');
10082 const [gradient, setGradient] = useStyle('elements.' + selectedLevel + '.color.gradient', name);
10083 const [userGradient] = useStyle('elements.' + selectedLevel + '.color.gradient', name, 'user');
10084
10085 if (!hasTextColor && !hasBackgroundColor && !hasGradientColor) {
10086 return null;
10087 }
10088
10089 let backgroundSettings = {};
10090
10091 if (hasBackgroundColor) {
10092 backgroundSettings = {
10093 colorValue: backgroundColor,
10094 onColorChange: setBackgroundColor
10095 };
10096
10097 if (backgroundColor) {
10098 backgroundSettings.clearable = backgroundColor === userBackgroundColor;
10099 }
10100 }
10101
10102 let gradientSettings = {};
10103
10104 if (hasGradientColor) {
10105 gradientSettings = {
10106 gradientValue: gradient,
10107 onGradientChange: setGradient
10108 };
10109
10110 if (gradient) {
10111 gradientSettings.clearable = gradient === userGradient;
10112 }
10113 }
10114
10115 const controlProps = { ...backgroundSettings,
10116 ...gradientSettings
10117 };
10118 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
10119 title: (0,external_wp_i18n_namespaceObject.__)('Headings'),
10120 description: (0,external_wp_i18n_namespaceObject.__)('Set the default color used for headings across the site.')
10121 }), (0,external_wp_element_namespaceObject.createElement)("div", {
10122 className: "edit-site-global-styles-screen-heading-color"
10123 }, (0,external_wp_element_namespaceObject.createElement)("h4", null, (0,external_wp_i18n_namespaceObject.__)('Select heading level')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, {
10124 label: (0,external_wp_i18n_namespaceObject.__)('Select heading level'),
10125 hideLabelFromVision: true,
10126 value: selectedLevel,
10127 onChange: setCurrentTab,
10128 isBlock: true
10129 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
10130 value: "heading"
10131 /* translators: 'All' refers to selecting all heading levels
10132 and applying the same style to h1-h6. */
10133 ,
10134 label: (0,external_wp_i18n_namespaceObject.__)('All')
10135 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
10136 value: "h1",
10137 label: (0,external_wp_i18n_namespaceObject.__)('H1')
10138 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
10139 value: "h2",
10140 label: (0,external_wp_i18n_namespaceObject.__)('H2')
10141 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
10142 value: "h3",
10143 label: (0,external_wp_i18n_namespaceObject.__)('H3')
10144 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
10145 value: "h4",
10146 label: (0,external_wp_i18n_namespaceObject.__)('H4')
10147 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
10148 value: "h5",
10149 label: (0,external_wp_i18n_namespaceObject.__)('H5')
10150 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
10151 value: "h6",
10152 label: (0,external_wp_i18n_namespaceObject.__)('H6')
10153 }))), hasTextColor && (0,external_wp_element_namespaceObject.createElement)("div", {
10154 className: "edit-site-global-styles-screen-heading-color"
10155 }, (0,external_wp_element_namespaceObject.createElement)("h4", null, selectedLevel === 'heading' ? (0,external_wp_i18n_namespaceObject.__)('Text color for all heading levels') : (0,external_wp_i18n_namespaceObject.sprintf)(
10156 /* translators: %s: heading level (h1-h6) */
10157 (0,external_wp_i18n_namespaceObject.__)('Text color for %s'), selectedLevel.toUpperCase())), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
10158 className: "edit-site-screen-heading-text-color__control",
10159 colors: colorsPerOrigin,
10160 disableCustomColors: !areCustomSolidsEnabled,
10161 __experimentalHasMultipleOrigins: true,
10162 showTitle: false,
10163 enableAlpha: true,
10164 __experimentalIsRenderedInSidebar: true,
10165 colorValue: color,
10166 onColorChange: setColor,
10167 clearable: color === userColor
10168 })), hasBackgroundColor && (0,external_wp_element_namespaceObject.createElement)("div", {
10169 className: "edit-site-global-styles-screen-heading-color"
10170 }, (0,external_wp_element_namespaceObject.createElement)("h4", null, selectedLevel === 'heading' ? (0,external_wp_i18n_namespaceObject.__)('Background color for all heading levels') : (0,external_wp_i18n_namespaceObject.sprintf)(
10171 /* translators: %s: heading level (h1-h6) */
10172 (0,external_wp_i18n_namespaceObject.__)('Background color for %s'), selectedLevel.toUpperCase())), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, extends_extends({
10173 className: "edit-site-screen-heading-background-color__control",
10174 colors: colorsPerOrigin,
10175 gradients: gradientsPerOrigin,
10176 disableCustomColors: !areCustomSolidsEnabled,
10177 disableCustomGradients: !areCustomGradientsEnabled,
10178 __experimentalHasMultipleOrigins: true,
10179 showTitle: false,
10180 enableAlpha: true,
10181 __experimentalIsRenderedInSidebar: true
10182 }, controlProps))));
10183 }
10184
10185 /* harmony default export */ var screen_heading_color = (ScreenHeadingColor);
10186
10187 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-button-color.js
10188
10189
10190 /**
10191 * WordPress dependencies
10192 */
10193
10194
10195 /**
10196 * Internal dependencies
10197 */
10198
10199
10200
10201
10202 function ScreenButtonColor(_ref) {
10203 let {
10204 name
10205 } = _ref;
10206 const supports = getSupportedGlobalStylesPanels(name);
10207 const [solids] = useSetting('color.palette', name);
10208 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
10209 const colorsPerOrigin = useColorsPerOrigin(name);
10210 const [isBackgroundEnabled] = useSetting('color.background', name);
10211 const hasButtonColor = supports.includes('buttonColor') && isBackgroundEnabled && (solids.length > 0 || areCustomSolidsEnabled);
10212 const [buttonTextColor, setButtonTextColor] = useStyle('elements.button.color.text', name);
10213 const [userButtonTextColor] = useStyle('elements.button.color.text', name, 'user');
10214 const [buttonBgColor, setButtonBgColor] = useStyle('elements.button.color.background', name);
10215 const [userButtonBgColor] = useStyle('elements.button.color.background', name, 'user');
10216
10217 if (!hasButtonColor) {
10218 return null;
10219 }
10220
10221 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
10222 title: (0,external_wp_i18n_namespaceObject.__)('Buttons'),
10223 description: (0,external_wp_i18n_namespaceObject.__)('Set the default colors used for buttons across the site.')
10224 }), (0,external_wp_element_namespaceObject.createElement)("h4", {
10225 className: "edit-site-global-styles-section-title"
10226 }, (0,external_wp_i18n_namespaceObject.__)('Text color')), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
10227 className: "edit-site-screen-button-color__control",
10228 colors: colorsPerOrigin,
10229 disableCustomColors: !areCustomSolidsEnabled,
10230 __experimentalHasMultipleOrigins: true,
10231 showTitle: false,
10232 enableAlpha: true,
10233 __experimentalIsRenderedInSidebar: true,
10234 colorValue: buttonTextColor,
10235 onColorChange: setButtonTextColor,
10236 clearable: buttonTextColor === userButtonTextColor
10237 }), (0,external_wp_element_namespaceObject.createElement)("h4", {
10238 className: "edit-site-global-styles-section-title"
10239 }, (0,external_wp_i18n_namespaceObject.__)('Background color')), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
10240 className: "edit-site-screen-button-color__control",
10241 colors: colorsPerOrigin,
10242 disableCustomColors: !areCustomSolidsEnabled,
10243 __experimentalHasMultipleOrigins: true,
10244 showTitle: false,
10245 enableAlpha: true,
10246 __experimentalIsRenderedInSidebar: true,
10247 colorValue: buttonBgColor,
10248 onColorChange: setButtonBgColor,
10249 clearable: buttonBgColor === userButtonBgColor
10250 }));
10251 }
10252
10253 /* harmony default export */ var screen_button_color = (ScreenButtonColor);
10254
10255 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-layout.js
10256
10257
10258 /**
10259 * WordPress dependencies
10260 */
10261
10262 /**
10263 * Internal dependencies
10264 */
10265
10266
10267
10268
10269
10270 function ScreenLayout(_ref) {
10271 let {
10272 name
10273 } = _ref;
10274 const hasBorderPanel = useHasBorderPanel(name);
10275 const hasDimensionsPanel = useHasDimensionsPanel(name);
10276 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
10277 title: (0,external_wp_i18n_namespaceObject.__)('Layout')
10278 }), hasDimensionsPanel && (0,external_wp_element_namespaceObject.createElement)(DimensionsPanel, {
10279 name: name
10280 }), hasBorderPanel && (0,external_wp_element_namespaceObject.createElement)(BorderPanel, {
10281 name: name
10282 }));
10283 }
10284
10285 /* harmony default export */ var screen_layout = (ScreenLayout);
10286
10287 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/global-styles-provider.js
10288
10289
10290 /**
10291 * External dependencies
10292 */
10293
10294 /**
10295 * WordPress dependencies
10296 */
10297
10298
10299
10300
10301 /**
10302 * Internal dependencies
10303 */
10304
10305
10306
10307 function mergeTreesCustomizer(_, srcValue) {
10308 // We only pass as arrays the presets,
10309 // in which case we want the new array of values
10310 // to override the old array (no merging).
10311 if (Array.isArray(srcValue)) {
10312 return srcValue;
10313 }
10314 }
10315
10316 function mergeBaseAndUserConfigs(base, user) {
10317 return (0,external_lodash_namespaceObject.mergeWith)({}, base, user, mergeTreesCustomizer);
10318 }
10319
10320 const cleanEmptyObject = object => {
10321 if (object === null || typeof object !== 'object' || Array.isArray(object)) {
10322 return object;
10323 }
10324
10325 const cleanedNestedObjects = Object.fromEntries(Object.entries((0,external_lodash_namespaceObject.mapValues)(object, cleanEmptyObject)).filter(_ref => {
10326 let [, value] = _ref;
10327 return Boolean(value);
10328 }));
10329 return (0,external_lodash_namespaceObject.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
10330 };
10331
10332 function useGlobalStylesUserConfig() {
10333 const {
10334 globalStylesId,
10335 isReady,
10336 settings,
10337 styles
10338 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10339 const {
10340 getEditedEntityRecord,
10341 hasFinishedResolution
10342 } = select(external_wp_coreData_namespaceObject.store);
10343
10344 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId();
10345
10346 const record = _globalStylesId ? getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined;
10347 let hasResolved = false;
10348
10349 if (hasFinishedResolution('__experimentalGetCurrentGlobalStylesId')) {
10350 hasResolved = _globalStylesId ? hasFinishedResolution('getEditedEntityRecord', ['root', 'globalStyles', _globalStylesId]) : true;
10351 }
10352
10353 return {
10354 globalStylesId: _globalStylesId,
10355 isReady: hasResolved,
10356 settings: record === null || record === void 0 ? void 0 : record.settings,
10357 styles: record === null || record === void 0 ? void 0 : record.styles
10358 };
10359 }, []);
10360 const {
10361 getEditedEntityRecord
10362 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
10363 const {
10364 editEntityRecord
10365 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
10366 const config = (0,external_wp_element_namespaceObject.useMemo)(() => {
10367 return {
10368 settings: settings !== null && settings !== void 0 ? settings : {},
10369 styles: styles !== null && styles !== void 0 ? styles : {}
10370 };
10371 }, [settings, styles]);
10372 const setConfig = (0,external_wp_element_namespaceObject.useCallback)(callback => {
10373 var _record$styles, _record$settings;
10374
10375 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
10376 const currentConfig = {
10377 styles: (_record$styles = record === null || record === void 0 ? void 0 : record.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
10378 settings: (_record$settings = record === null || record === void 0 ? void 0 : record.settings) !== null && _record$settings !== void 0 ? _record$settings : {}
10379 };
10380 const updatedConfig = callback(currentConfig);
10381 editEntityRecord('root', 'globalStyles', globalStylesId, {
10382 styles: cleanEmptyObject(updatedConfig.styles) || {},
10383 settings: cleanEmptyObject(updatedConfig.settings) || {}
10384 });
10385 }, [globalStylesId]);
10386 return [isReady, config, setConfig];
10387 }
10388
10389 function useGlobalStylesBaseConfig() {
10390 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => {
10391 return select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles();
10392 }, []);
10393 return [!!baseConfig, baseConfig];
10394 }
10395
10396 function useGlobalStylesContext() {
10397 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
10398 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
10399 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
10400 if (!baseConfig || !userConfig) {
10401 return {};
10402 }
10403
10404 return mergeBaseAndUserConfigs(baseConfig, userConfig);
10405 }, [userConfig, baseConfig]);
10406 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
10407 return {
10408 isReady: isUserConfigReady && isBaseConfigReady,
10409 user: userConfig,
10410 base: baseConfig,
10411 merged: mergedConfig,
10412 setUserConfig
10413 };
10414 }, [mergedConfig, userConfig, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]);
10415 return context;
10416 }
10417
10418 function GlobalStylesProvider(_ref2) {
10419 let {
10420 children
10421 } = _ref2;
10422 const context = useGlobalStylesContext();
10423
10424 if (!context.isReady) {
10425 return null;
10426 }
10427
10428 return (0,external_wp_element_namespaceObject.createElement)(GlobalStylesContext.Provider, {
10429 value: context
10430 }, children);
10431 }
10432
10433 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-style-variations.js
10434
10435
10436 /**
10437 * External dependencies
10438 */
10439
10440
10441 /**
10442 * WordPress dependencies
10443 */
10444
10445
10446
10447
10448
10449
10450
10451
10452 /**
10453 * Internal dependencies
10454 */
10455
10456
10457
10458
10459
10460
10461 function compareVariations(a, b) {
10462 return (0,external_lodash_namespaceObject.isEqual)(a.styles, b.styles) && (0,external_lodash_namespaceObject.isEqual)(a.settings, b.settings);
10463 }
10464
10465 function Variation(_ref) {
10466 let {
10467 variation
10468 } = _ref;
10469 const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
10470 const {
10471 base,
10472 user,
10473 setUserConfig
10474 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
10475 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
10476 var _variation$settings, _variation$styles;
10477
10478 return {
10479 user: {
10480 settings: (_variation$settings = variation.settings) !== null && _variation$settings !== void 0 ? _variation$settings : {},
10481 styles: (_variation$styles = variation.styles) !== null && _variation$styles !== void 0 ? _variation$styles : {}
10482 },
10483 base,
10484 merged: mergeBaseAndUserConfigs(base, variation),
10485 setUserConfig: () => {}
10486 };
10487 }, [variation, base]);
10488
10489 const selectVariation = () => {
10490 setUserConfig(() => {
10491 return {
10492 settings: variation.settings,
10493 styles: variation.styles
10494 };
10495 });
10496 };
10497
10498 const selectOnEnter = event => {
10499 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
10500 event.preventDefault();
10501 selectVariation();
10502 }
10503 };
10504
10505 const isActive = (0,external_wp_element_namespaceObject.useMemo)(() => {
10506 return compareVariations(user, variation);
10507 }, [user, variation]);
10508 return (0,external_wp_element_namespaceObject.createElement)(GlobalStylesContext.Provider, {
10509 value: context
10510 }, (0,external_wp_element_namespaceObject.createElement)("div", {
10511 className: classnames_default()('edit-site-global-styles-variations_item', {
10512 'is-active': isActive
10513 }),
10514 role: "button",
10515 onClick: selectVariation,
10516 onKeyDown: selectOnEnter,
10517 tabIndex: "0",
10518 "aria-label": variation === null || variation === void 0 ? void 0 : variation.title,
10519 "aria-current": isActive,
10520 onFocus: () => setIsFocused(true),
10521 onBlur: () => setIsFocused(false)
10522 }, (0,external_wp_element_namespaceObject.createElement)("div", {
10523 className: "edit-site-global-styles-variations_item-preview"
10524 }, (0,external_wp_element_namespaceObject.createElement)(preview, {
10525 label: variation === null || variation === void 0 ? void 0 : variation.title,
10526 isFocused: isFocused,
10527 withHoverView: true
10528 }))));
10529 }
10530
10531 function ScreenStyleVariations() {
10532 const {
10533 variations,
10534 mode
10535 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10536 return {
10537 variations: select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations(),
10538 mode: select(external_wp_blockEditor_namespaceObject.store).__unstableGetEditorMode()
10539 };
10540 }, []);
10541 const withEmptyVariation = (0,external_wp_element_namespaceObject.useMemo)(() => {
10542 return [{
10543 title: (0,external_wp_i18n_namespaceObject.__)('Default'),
10544 settings: {},
10545 styles: {}
10546 }, ...variations.map(variation => {
10547 var _variation$settings2, _variation$styles2;
10548
10549 return { ...variation,
10550 settings: (_variation$settings2 = variation.settings) !== null && _variation$settings2 !== void 0 ? _variation$settings2 : {},
10551 styles: (_variation$styles2 = variation.styles) !== null && _variation$styles2 !== void 0 ? _variation$styles2 : {}
10552 };
10553 })];
10554 }, [variations]);
10555 const {
10556 __unstableSetEditorMode
10557 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
10558 const shouldRevertInitialMode = (0,external_wp_element_namespaceObject.useRef)(null);
10559 (0,external_wp_element_namespaceObject.useEffect)(() => {
10560 // ignore changes to zoom-out mode as we explictily change to it on mount.
10561 if (mode !== 'zoom-out') {
10562 shouldRevertInitialMode.current = false;
10563 }
10564 }, [mode]); // Intentionality left without any dependency.
10565 // This effect should only run the first time the component is rendered.
10566 // The effect opens the zoom-out view if it is not open before when applying a style variation.
10567
10568 (0,external_wp_element_namespaceObject.useEffect)(() => {
10569 if (mode !== 'zoom-out') {
10570 __unstableSetEditorMode('zoom-out');
10571
10572 shouldRevertInitialMode.current = true;
10573 return () => {
10574 // if there were not mode changes revert to the initial mode when unmounting.
10575 if (shouldRevertInitialMode.current) {
10576 __unstableSetEditorMode(mode);
10577 }
10578 };
10579 }
10580 }, []);
10581 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
10582 back: "/",
10583 title: (0,external_wp_i18n_namespaceObject.__)('Browse styles'),
10584 description: (0,external_wp_i18n_namespaceObject.__)('Choose a variation to change the look of the site.')
10585 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
10586 size: "small",
10587 isBorderless: true
10588 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalGrid, {
10589 columns: 2
10590 }, withEmptyVariation === null || withEmptyVariation === void 0 ? void 0 : withEmptyVariation.map((variation, index) => (0,external_wp_element_namespaceObject.createElement)(Variation, {
10591 key: index,
10592 variation: variation
10593 }))))));
10594 }
10595
10596 /* harmony default export */ var screen_style_variations = (ScreenStyleVariations);
10597
10598 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/ui.js
10599
10600
10601
10602 /**
10603 * WordPress dependencies
10604 */
10605
10606
10607 /**
10608 * Internal dependencies
10609 */
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626 function GlobalStylesNavigationScreen(_ref) {
10627 let {
10628 className,
10629 ...props
10630 } = _ref;
10631 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, extends_extends({
10632 className: ['edit-site-global-styles-sidebar__navigator-screen', className].filter(Boolean).join(' ')
10633 }, props));
10634 }
10635
10636 function ContextScreens(_ref2) {
10637 let {
10638 name
10639 } = _ref2;
10640 const parentMenu = name === undefined ? '' : '/blocks/' + name;
10641 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10642 path: parentMenu + '/typography'
10643 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography, {
10644 name: name
10645 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10646 path: parentMenu + '/typography/text'
10647 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, {
10648 name: name,
10649 element: "text"
10650 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10651 path: parentMenu + '/typography/link'
10652 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, {
10653 name: name,
10654 element: "link"
10655 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10656 path: parentMenu + '/typography/heading'
10657 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, {
10658 name: name,
10659 element: "heading"
10660 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10661 path: parentMenu + '/typography/button'
10662 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, {
10663 name: name,
10664 element: "button"
10665 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10666 path: parentMenu + '/colors'
10667 }, (0,external_wp_element_namespaceObject.createElement)(screen_colors, {
10668 name: name
10669 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10670 path: parentMenu + '/colors/palette'
10671 }, (0,external_wp_element_namespaceObject.createElement)(screen_color_palette, {
10672 name: name
10673 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10674 path: parentMenu + '/colors/background'
10675 }, (0,external_wp_element_namespaceObject.createElement)(screen_background_color, {
10676 name: name
10677 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10678 path: parentMenu + '/colors/text'
10679 }, (0,external_wp_element_namespaceObject.createElement)(screen_text_color, {
10680 name: name
10681 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10682 path: parentMenu + '/colors/link'
10683 }, (0,external_wp_element_namespaceObject.createElement)(screen_link_color, {
10684 name: name
10685 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10686 path: parentMenu + '/colors/heading'
10687 }, (0,external_wp_element_namespaceObject.createElement)(screen_heading_color, {
10688 name: name
10689 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10690 path: parentMenu + '/colors/button'
10691 }, (0,external_wp_element_namespaceObject.createElement)(screen_button_color, {
10692 name: name
10693 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10694 path: parentMenu + '/layout'
10695 }, (0,external_wp_element_namespaceObject.createElement)(screen_layout, {
10696 name: name
10697 })));
10698 }
10699
10700 function GlobalStylesUI() {
10701 const blocks = (0,external_wp_blocks_namespaceObject.getBlockTypes)();
10702 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, {
10703 className: "edit-site-global-styles-sidebar__navigator-provider",
10704 initialPath: "/"
10705 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10706 path: "/"
10707 }, (0,external_wp_element_namespaceObject.createElement)(screen_root, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10708 path: "/variations"
10709 }, (0,external_wp_element_namespaceObject.createElement)(screen_style_variations, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10710 path: "/blocks"
10711 }, (0,external_wp_element_namespaceObject.createElement)(screen_block_list, null)), blocks.map(block => (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
10712 key: 'menu-block-' + block.name,
10713 path: '/blocks/' + block.name
10714 }, (0,external_wp_element_namespaceObject.createElement)(screen_block, {
10715 name: block.name
10716 }))), (0,external_wp_element_namespaceObject.createElement)(ContextScreens, null), blocks.map(block => (0,external_wp_element_namespaceObject.createElement)(ContextScreens, {
10717 key: 'screens-block-' + block.name,
10718 name: block.name
10719 })));
10720 }
10721
10722 /* harmony default export */ var ui = (GlobalStylesUI);
10723
10724 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/index.js
10725
10726
10727
10728
10729 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/global-styles-sidebar.js
10730
10731
10732 /**
10733 * WordPress dependencies
10734 */
10735
10736
10737
10738
10739
10740 /**
10741 * Internal dependencies
10742 */
10743
10744
10745
10746 function GlobalStylesSidebar() {
10747 const [canReset, onReset] = useGlobalStylesReset();
10748 const {
10749 toggle
10750 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
10751 return (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
10752 className: "edit-site-global-styles-sidebar",
10753 identifier: "edit-site/global-styles",
10754 title: (0,external_wp_i18n_namespaceObject.__)('Styles'),
10755 icon: library_styles,
10756 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close global styles sidebar'),
10757 panelClassName: "edit-site-global-styles-sidebar__panel",
10758 header: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Styles'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
10759 icon: more_vertical,
10760 label: (0,external_wp_i18n_namespaceObject.__)('More Global Styles Actions'),
10761 controls: [{
10762 title: (0,external_wp_i18n_namespaceObject.__)('Reset to defaults'),
10763 onClick: onReset,
10764 isDisabled: !canReset
10765 }, {
10766 title: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'),
10767 onClick: () => toggle('core/edit-site', 'welcomeGuideStyles')
10768 }]
10769 })))
10770 }, (0,external_wp_element_namespaceObject.createElement)(ui, null));
10771 }
10772
10773 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/navigation.js
10774
10775
10776 /**
10777 * WordPress dependencies
10778 */
10779
10780 const navigation = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
10781 viewBox: "0 0 24 24",
10782 xmlns: "http://www.w3.org/2000/svg"
10783 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
10784 d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z"
10785 }));
10786 /* harmony default export */ var library_navigation = (navigation);
10787
10788 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js
10789
10790
10791 /**
10792 * WordPress dependencies
10793 */
10794
10795
10796
10797 const ALLOWED_BLOCKS = {
10798 'core/navigation': ['core/navigation-link', 'core/search', 'core/social-links', 'core/page-list', 'core/spacer', 'core/home-link', 'core/site-title', 'core/site-logo', 'core/navigation-submenu'],
10799 'core/social-links': ['core/social-link'],
10800 'core/navigation-submenu': ['core/navigation-link', 'core/navigation-submenu'],
10801 'core/navigation-link': ['core/navigation-link', 'core/navigation-submenu']
10802 };
10803 function NavigationMenu(_ref) {
10804 let {
10805 innerBlocks,
10806 id
10807 } = _ref;
10808 const {
10809 updateBlockListSettings
10810 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
10811 //Think through a better way of doing this, possible with adding allowed blocks to block library metadata
10812
10813 (0,external_wp_element_namespaceObject.useEffect)(() => {
10814 updateBlockListSettings('', {
10815 allowedBlocks: ALLOWED_BLOCKS['core/navigation']
10816 });
10817 innerBlocks.forEach(block => {
10818 if (ALLOWED_BLOCKS[block.name]) {
10819 updateBlockListSettings(block.clientId, {
10820 allowedBlocks: ALLOWED_BLOCKS[block.name]
10821 });
10822 }
10823 });
10824 }, [updateBlockListSettings, innerBlocks]);
10825 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
10826 id: id
10827 });
10828 }
10829
10830 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js
10831
10832
10833 /**
10834 * WordPress dependencies
10835 */
10836
10837
10838
10839
10840
10841
10842
10843
10844 /**
10845 * Internal dependencies
10846 */
10847
10848
10849 const NAVIGATION_MENUS_QUERY = [{
10850 per_page: -1,
10851 status: 'publish'
10852 }];
10853 function NavigationInspector() {
10854 var _navigationMenus$;
10855
10856 const {
10857 selectedNavigationBlockId,
10858 clientIdToRef,
10859 navigationMenus,
10860 isResolvingNavigationMenus,
10861 hasResolvedNavigationMenus,
10862 firstNavigationBlockId
10863 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10864 const {
10865 __experimentalGetActiveBlockIdByBlockNames,
10866 __experimentalGetGlobalBlocksByName,
10867 getBlock
10868 } = select(external_wp_blockEditor_namespaceObject.store);
10869 const {
10870 getEntityRecords,
10871 hasFinishedResolution,
10872 isResolving
10873 } = select(external_wp_coreData_namespaceObject.store);
10874 const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY[0]]; // Get the active Navigation block (if present).
10875
10876 const selectedNavId = __experimentalGetActiveBlockIdByBlockNames('core/navigation'); // Get all Navigation blocks currently within the editor canvas.
10877
10878
10879 const navBlockIds = __experimentalGetGlobalBlocksByName('core/navigation');
10880
10881 const idToRef = {};
10882 navBlockIds.forEach(id => {
10883 var _getBlock, _getBlock$attributes;
10884
10885 idToRef[id] = (_getBlock = getBlock(id)) === null || _getBlock === void 0 ? void 0 : (_getBlock$attributes = _getBlock.attributes) === null || _getBlock$attributes === void 0 ? void 0 : _getBlock$attributes.ref;
10886 });
10887 return {
10888 selectedNavigationBlockId: selectedNavId,
10889 firstNavigationBlockId: navBlockIds === null || navBlockIds === void 0 ? void 0 : navBlockIds[0],
10890 clientIdToRef: idToRef,
10891 navigationMenus: getEntityRecords(...navigationMenusQuery),
10892 isResolvingNavigationMenus: isResolving('getEntityRecords', navigationMenusQuery),
10893 hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
10894 };
10895 }, []);
10896 const navMenuListId = (0,external_wp_compose_namespaceObject.useInstanceId)(NavigationMenu, 'edit-site-navigation-inspector-menu');
10897 const firstNavRefInTemplate = clientIdToRef[firstNavigationBlockId];
10898 const firstNavigationMenuRef = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id; // Default Navigation Menu is either:
10899 // - the Navigation Menu referenced by the first Nav block within the template.
10900 // - the first of the available Navigation Menus (`wp_navigation`) posts.
10901
10902 const defaultNavigationMenuId = firstNavRefInTemplate || firstNavigationMenuRef; // The Navigation Menu manually selected by the user within the Nav inspector.
10903
10904 const [currentMenuId, setCurrentMenuId] = (0,external_wp_element_namespaceObject.useState)(firstNavRefInTemplate); // If a Nav block is selected within the canvas then set the
10905 // Navigation Menu referenced by it's `ref` attribute to be
10906 // active within the Navigation sidebar.
10907
10908 (0,external_wp_element_namespaceObject.useEffect)(() => {
10909 if (selectedNavigationBlockId) {
10910 setCurrentMenuId(clientIdToRef[selectedNavigationBlockId]);
10911 }
10912 }, [selectedNavigationBlockId]);
10913 let options = [];
10914
10915 if (navigationMenus) {
10916 options = navigationMenus.map(_ref => {
10917 let {
10918 id,
10919 title
10920 } = _ref;
10921 return {
10922 value: id,
10923 label: title.rendered
10924 };
10925 });
10926 }
10927
10928 const [innerBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', 'wp_navigation', {
10929 id: currentMenuId || defaultNavigationMenuId
10930 });
10931 const {
10932 isLoadingInnerBlocks,
10933 hasLoadedInnerBlocks
10934 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10935 const {
10936 isResolving,
10937 hasFinishedResolution
10938 } = select(external_wp_coreData_namespaceObject.store);
10939 return {
10940 isLoadingInnerBlocks: isResolving('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId]),
10941 hasLoadedInnerBlocks: hasFinishedResolution('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId])
10942 };
10943 }, [currentMenuId, defaultNavigationMenuId]);
10944 const isLoading = !(hasResolvedNavigationMenus && hasLoadedInnerBlocks);
10945 const hasMoreThanOneNavigationMenu = (navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.length) > 1;
10946 const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length); // Entity block editor will return entities that are not currently published.
10947 // Guard by only allowing their usage if there are published Nav Menus.
10948
10949 const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
10950 const hasInnerBlocks = !!(publishedInnerBlocks !== null && publishedInnerBlocks !== void 0 && publishedInnerBlocks.length);
10951 (0,external_wp_element_namespaceObject.useEffect)(() => {
10952 if (isResolvingNavigationMenus) {
10953 (0,external_wp_a11y_namespaceObject.speak)('Loading Navigation sidebar menus.');
10954 }
10955
10956 if (hasResolvedNavigationMenus) {
10957 (0,external_wp_a11y_namespaceObject.speak)('Navigation sidebar menus have loaded.');
10958 }
10959 }, [isResolvingNavigationMenus, hasResolvedNavigationMenus]);
10960 (0,external_wp_element_namespaceObject.useEffect)(() => {
10961 if (isLoadingInnerBlocks) {
10962 (0,external_wp_a11y_namespaceObject.speak)('Loading Navigation sidebar selected menu items.');
10963 }
10964
10965 if (hasLoadedInnerBlocks) {
10966 (0,external_wp_a11y_namespaceObject.speak)('Navigation sidebar selected menu items have loaded.');
10967 }
10968 }, [isLoadingInnerBlocks, hasLoadedInnerBlocks]);
10969 return (0,external_wp_element_namespaceObject.createElement)("div", {
10970 className: "edit-site-navigation-inspector"
10971 }, hasResolvedNavigationMenus && !hasNavigationMenus && (0,external_wp_element_namespaceObject.createElement)("p", {
10972 className: "edit-site-navigation-inspector__empty-msg"
10973 }, (0,external_wp_i18n_namespaceObject.__)('There are no Navigation Menus.')), !hasResolvedNavigationMenus && (0,external_wp_element_namespaceObject.createElement)("div", {
10974 className: "edit-site-navigation-inspector__placeholder"
10975 }), hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
10976 "aria-controls": // aria-controls should only apply when referenced element is in DOM
10977 hasLoadedInnerBlocks ? navMenuListId : undefined,
10978 value: currentMenuId || defaultNavigationMenuId,
10979 options: options,
10980 onChange: newMenuId => setCurrentMenuId(Number(newMenuId))
10981 }), isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
10982 className: "edit-site-navigation-inspector__placeholder is-child"
10983 }), (0,external_wp_element_namespaceObject.createElement)("div", {
10984 className: "edit-site-navigation-inspector__placeholder is-child"
10985 }), (0,external_wp_element_namespaceObject.createElement)("div", {
10986 className: "edit-site-navigation-inspector__placeholder is-child"
10987 })), hasInnerBlocks && !isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
10988 value: publishedInnerBlocks,
10989 onChange: onChange,
10990 onInput: onInput
10991 }, (0,external_wp_element_namespaceObject.createElement)(NavigationMenu, {
10992 id: navMenuListId,
10993 innerBlocks: publishedInnerBlocks
10994 })), !hasInnerBlocks && !isLoading && (0,external_wp_element_namespaceObject.createElement)("p", {
10995 className: "edit-site-navigation-inspector__empty-msg"
10996 }, (0,external_wp_i18n_namespaceObject.__)('Navigation Menu is empty.')));
10997 }
10998
10999 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js
11000
11001
11002 /**
11003 * WordPress dependencies
11004 */
11005
11006
11007
11008 /**
11009 * Internal dependencies
11010 */
11011
11012
11013
11014 function NavigationMenuSidebar() {
11015 return (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
11016 className: "edit-site-navigation-menu-sidebar",
11017 identifier: "edit-site/navigation-menu",
11018 title: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
11019 icon: library_navigation,
11020 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close navigation menu sidebar'),
11021 panelClassName: "edit-site-navigation-menu-sidebar__panel",
11022 header: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Navigation Menus')), (0,external_wp_element_namespaceObject.createElement)("span", {
11023 className: "edit-site-navigation-sidebar__beta"
11024 }, (0,external_wp_i18n_namespaceObject.__)('Beta'))))
11025 }, (0,external_wp_element_namespaceObject.createElement)(NavigationInspector, null));
11026 }
11027
11028 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/constants.js
11029 const SIDEBAR_TEMPLATE = 'edit-site/template';
11030 const SIDEBAR_BLOCK = 'edit-site/block-inspector';
11031
11032 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/settings-header/index.js
11033
11034
11035 /**
11036 * WordPress dependencies
11037 */
11038
11039
11040
11041
11042 /**
11043 * Internal dependencies
11044 */
11045
11046
11047
11048
11049 const SettingsHeader = _ref => {
11050 let {
11051 sidebarName
11052 } = _ref;
11053 const {
11054 enableComplementaryArea
11055 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
11056
11057 const openTemplateSettings = () => enableComplementaryArea(constants_STORE_NAME, SIDEBAR_TEMPLATE);
11058
11059 const openBlockSettings = () => enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK);
11060
11061 const [templateAriaLabel, templateActiveClass] = sidebarName === SIDEBAR_TEMPLATE ? // translators: ARIA label for the Template sidebar tab, selected.
11062 [(0,external_wp_i18n_namespaceObject.__)('Template (selected)'), 'is-active'] : // translators: ARIA label for the Template Settings Sidebar tab, not selected.
11063 [(0,external_wp_i18n_namespaceObject.__)('Template'), ''];
11064 const [blockAriaLabel, blockActiveClass] = sidebarName === SIDEBAR_BLOCK ? // translators: ARIA label for the Block Settings Sidebar tab, selected.
11065 [(0,external_wp_i18n_namespaceObject.__)('Block (selected)'), 'is-active'] : // translators: ARIA label for the Block Settings Sidebar tab, not selected.
11066 [(0,external_wp_i18n_namespaceObject.__)('Block'), ''];
11067 /* Use a list so screen readers will announce how many tabs there are. */
11068
11069 return (0,external_wp_element_namespaceObject.createElement)("ul", null, (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11070 onClick: openTemplateSettings,
11071 className: `edit-site-sidebar-edit-mode__panel-tab ${templateActiveClass}`,
11072 "aria-label": templateAriaLabel // translators: Data label for the Template Settings Sidebar tab.
11073 ,
11074 "data-label": (0,external_wp_i18n_namespaceObject.__)('Template')
11075 }, // translators: Text label for the Template Settings Sidebar tab.
11076 (0,external_wp_i18n_namespaceObject.__)('Template'))), (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11077 onClick: openBlockSettings,
11078 className: `edit-site-sidebar-edit-mode__panel-tab ${blockActiveClass}`,
11079 "aria-label": blockAriaLabel // translators: Data label for the Block Settings Sidebar tab.
11080 ,
11081 "data-label": (0,external_wp_i18n_namespaceObject.__)('Block')
11082 }, // translators: Text label for the Block Settings Sidebar tab.
11083 (0,external_wp_i18n_namespaceObject.__)('Block'))));
11084 };
11085
11086 /* harmony default export */ var settings_header = (SettingsHeader);
11087
11088 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/template-card/template-actions.js
11089
11090
11091 /**
11092 * WordPress dependencies
11093 */
11094
11095
11096
11097
11098 /**
11099 * Internal dependencies
11100 */
11101
11102
11103
11104 function Actions(_ref) {
11105 let {
11106 template
11107 } = _ref;
11108 const {
11109 revertTemplate
11110 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11111 const isRevertable = isTemplateRevertable(template);
11112
11113 if (!isRevertable) {
11114 return null;
11115 }
11116
11117 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
11118 icon: more_vertical,
11119 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
11120 className: "edit-site-template-card__actions",
11121 toggleProps: {
11122 isSmall: true
11123 }
11124 }, _ref2 => {
11125 let {
11126 onClose
11127 } = _ref2;
11128 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
11129 info: (0,external_wp_i18n_namespaceObject.__)('Use the template as supplied by the theme.'),
11130 onClick: () => {
11131 revertTemplate(template);
11132 onClose();
11133 }
11134 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations')));
11135 });
11136 }
11137
11138 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/template-card/template-areas.js
11139
11140
11141 /**
11142 * WordPress dependencies
11143 */
11144
11145
11146
11147
11148
11149 /**
11150 * Internal dependencies
11151 */
11152
11153
11154
11155 function TemplateAreaItem(_ref) {
11156 let {
11157 area,
11158 clientId
11159 } = _ref;
11160 const {
11161 selectBlock,
11162 toggleBlockHighlight
11163 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
11164 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => {
11165 const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas();
11166
11167 return defaultAreas.find(defaultArea => defaultArea.area === area);
11168 }, [area]);
11169
11170 const highlightBlock = () => toggleBlockHighlight(clientId, true);
11171
11172 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
11173
11174 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11175 className: "edit-site-template-card__template-areas-item",
11176 icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
11177 onMouseOver: highlightBlock,
11178 onMouseLeave: cancelHighlightBlock,
11179 onFocus: highlightBlock,
11180 onBlur: cancelHighlightBlock,
11181 onClick: () => {
11182 selectBlock(clientId);
11183 }
11184 }, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label);
11185 }
11186
11187 function template_areas_TemplateAreas() {
11188 const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentTemplateTemplateParts(), []);
11189
11190 if (!templateParts.length) {
11191 return null;
11192 }
11193
11194 return (0,external_wp_element_namespaceObject.createElement)("section", {
11195 className: "edit-site-template-card__template-areas"
11196 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
11197 level: 3,
11198 className: "edit-site-template-card__template-areas-title"
11199 }, (0,external_wp_i18n_namespaceObject.__)('Areas')), (0,external_wp_element_namespaceObject.createElement)("ul", {
11200 className: "edit-site-template-card__template-areas-list"
11201 }, templateParts.map(_ref2 => {
11202 let {
11203 templatePart,
11204 block
11205 } = _ref2;
11206 return (0,external_wp_element_namespaceObject.createElement)("li", {
11207 key: templatePart.slug
11208 }, (0,external_wp_element_namespaceObject.createElement)(TemplateAreaItem, {
11209 area: templatePart.area,
11210 clientId: block.clientId
11211 }));
11212 })));
11213 }
11214
11215 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/template-card/index.js
11216
11217
11218 /**
11219 * WordPress dependencies
11220 */
11221
11222
11223
11224
11225
11226 /**
11227 * Internal dependencies
11228 */
11229
11230
11231
11232
11233 function TemplateCard() {
11234 const {
11235 info: {
11236 title,
11237 description,
11238 icon
11239 },
11240 template
11241 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11242 const {
11243 getEditedPostType,
11244 getEditedPostId
11245 } = select(store_store);
11246 const {
11247 getEditedEntityRecord
11248 } = select(external_wp_coreData_namespaceObject.store);
11249 const {
11250 __experimentalGetTemplateInfo: getTemplateInfo
11251 } = select(external_wp_editor_namespaceObject.store);
11252 const postType = getEditedPostType();
11253 const postId = getEditedPostId();
11254 const record = getEditedEntityRecord('postType', postType, postId);
11255 const info = record ? getTemplateInfo(record) : {};
11256 return {
11257 info,
11258 template: record
11259 };
11260 }, []);
11261
11262 if (!title && !description) {
11263 return null;
11264 }
11265
11266 return (0,external_wp_element_namespaceObject.createElement)("div", {
11267 className: "edit-site-template-card"
11268 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
11269 className: "edit-site-template-card__icon",
11270 icon: icon
11271 }), (0,external_wp_element_namespaceObject.createElement)("div", {
11272 className: "edit-site-template-card__content"
11273 }, (0,external_wp_element_namespaceObject.createElement)("div", {
11274 className: "edit-site-template-card__header"
11275 }, (0,external_wp_element_namespaceObject.createElement)("h2", {
11276 className: "edit-site-template-card__title"
11277 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)), (0,external_wp_element_namespaceObject.createElement)(Actions, {
11278 template: template
11279 })), (0,external_wp_element_namespaceObject.createElement)("div", {
11280 className: "edit-site-template-card__description"
11281 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(description)), (0,external_wp_element_namespaceObject.createElement)(template_areas_TemplateAreas, null)));
11282 }
11283
11284 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/index.js
11285
11286
11287 /**
11288 * WordPress dependencies
11289 */
11290
11291
11292
11293
11294
11295
11296
11297 /**
11298 * Internal dependencies
11299 */
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309 const {
11310 Slot: InspectorSlot,
11311 Fill: InspectorFill
11312 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteSidebarInspector');
11313 const SidebarInspectorFill = InspectorFill;
11314 function SidebarComplementaryAreaFills() {
11315 const {
11316 sidebar,
11317 isEditorSidebarOpened,
11318 hasBlockSelection,
11319 supportsGlobalStyles
11320 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11321 const _sidebar = select(store).getActiveComplementaryArea(constants_STORE_NAME);
11322
11323 const _isEditorSidebarOpened = [SIDEBAR_BLOCK, SIDEBAR_TEMPLATE].includes(_sidebar);
11324
11325 const settings = select(store_store).getSettings();
11326 return {
11327 sidebar: _sidebar,
11328 isEditorSidebarOpened: _isEditorSidebarOpened,
11329 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(),
11330 supportsGlobalStyles: !(settings !== null && settings !== void 0 && settings.supportsTemplatePartsMode)
11331 };
11332 }, []);
11333 const {
11334 enableComplementaryArea
11335 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
11336 (0,external_wp_element_namespaceObject.useEffect)(() => {
11337 if (!isEditorSidebarOpened) return;
11338
11339 if (hasBlockSelection) {
11340 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK);
11341 } else {
11342 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_TEMPLATE);
11343 }
11344 }, [hasBlockSelection, isEditorSidebarOpened]);
11345 let sidebarName = sidebar;
11346
11347 if (!isEditorSidebarOpened) {
11348 sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;
11349 } // Conditionally include NavMenu sidebar in Plugin only.
11350 // Optimise for dead code elimination.
11351 // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
11352
11353
11354 let MaybeNavigationMenuSidebar = external_wp_element_namespaceObject.Fragment;
11355
11356 if (true) {
11357 MaybeNavigationMenuSidebar = NavigationMenuSidebar;
11358 }
11359
11360 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
11361 identifier: sidebarName,
11362 title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
11363 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
11364 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings sidebar'),
11365 header: (0,external_wp_element_namespaceObject.createElement)(settings_header, {
11366 sidebarName: sidebarName
11367 }),
11368 headerClassName: "edit-site-sidebar-edit-mode__panel-tabs"
11369 }, sidebarName === SIDEBAR_TEMPLATE && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)(TemplateCard, null)), sidebarName === SIDEBAR_BLOCK && (0,external_wp_element_namespaceObject.createElement)(InspectorSlot, {
11370 bubblesVirtually: true
11371 })), supportsGlobalStyles && (0,external_wp_element_namespaceObject.createElement)(GlobalStylesSidebar, null), (0,external_wp_element_namespaceObject.createElement)(MaybeNavigationMenuSidebar, null));
11372 }
11373
11374 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/home.js
11375
11376
11377 /**
11378 * WordPress dependencies
11379 */
11380
11381 const home = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11382 xmlns: "http://www.w3.org/2000/svg",
11383 viewBox: "0 0 24 24"
11384 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11385 d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z"
11386 }));
11387 /* harmony default export */ var library_home = (home);
11388
11389 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol-filled.js
11390
11391
11392 /**
11393 * WordPress dependencies
11394 */
11395
11396 const symbolFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11397 xmlns: "http://www.w3.org/2000/svg",
11398 viewBox: "0 0 24 24"
11399 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11400 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
11401 }));
11402 /* harmony default export */ var symbol_filled = (symbolFilled);
11403
11404 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/index.js
11405
11406
11407
11408 /**
11409 * External dependencies
11410 */
11411
11412 /**
11413 * WordPress dependencies
11414 */
11415
11416
11417
11418
11419
11420
11421
11422
11423 /**
11424 * Internal dependencies
11425 */
11426
11427
11428
11429 const SITE_EDITOR_KEY = 'site-editor';
11430
11431 function NavLink(_ref) {
11432 let {
11433 params,
11434 replace,
11435 ...props
11436 } = _ref;
11437 const linkProps = useLink(params, replace);
11438 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationItem, extends_extends({}, linkProps, props));
11439 }
11440
11441 const NavigationPanel = _ref2 => {
11442 let {
11443 activeItem
11444 } = _ref2;
11445 const {
11446 homeTemplate,
11447 isNavigationOpen,
11448 isTemplatePartsMode,
11449 siteTitle,
11450 dashboardLink
11451 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11452 const {
11453 getEntityRecord
11454 } = select(external_wp_coreData_namespaceObject.store);
11455 const {
11456 getSettings,
11457 isNavigationOpened
11458 } = select(store_store);
11459 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
11460 const {
11461 supportsTemplatePartsMode,
11462 __unstableHomeTemplate,
11463 __experimentalDashboardLink
11464 } = getSettings();
11465 return {
11466 siteTitle: siteData.name,
11467 homeTemplate: __unstableHomeTemplate,
11468 dashboardLink: __experimentalDashboardLink,
11469 isNavigationOpen: isNavigationOpened(),
11470 isTemplatePartsMode: !!supportsTemplatePartsMode
11471 };
11472 }, []);
11473 const {
11474 setIsNavigationPanelOpened
11475 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11476
11477 const closeOnEscape = event => {
11478 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
11479 event.preventDefault();
11480 setIsNavigationPanelOpened(false);
11481 }
11482 };
11483
11484 return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
11485 (0,external_wp_element_namespaceObject.createElement)("div", {
11486 className: classnames_default()(`edit-site-navigation-panel`, {
11487 'is-open': isNavigationOpen
11488 }),
11489 onKeyDown: closeOnEscape
11490 }, (0,external_wp_element_namespaceObject.createElement)("div", {
11491 className: "edit-site-navigation-panel__inner"
11492 }, (0,external_wp_element_namespaceObject.createElement)("div", {
11493 className: "edit-site-navigation-panel__site-title-container"
11494 }, (0,external_wp_element_namespaceObject.createElement)("div", {
11495 className: "edit-site-navigation-panel__site-title"
11496 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle))), (0,external_wp_element_namespaceObject.createElement)("div", {
11497 className: "edit-site-navigation-panel__scroll-container"
11498 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigation, {
11499 activeItem: activeItem
11500 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationBackButton, {
11501 backButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Dashboard'),
11502 className: "edit-site-navigation-panel__back-to-dashboard",
11503 href: dashboardLink !== null && dashboardLink !== void 0 ? dashboardLink : 'index.php'
11504 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationMenu, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationGroup, {
11505 title: (0,external_wp_i18n_namespaceObject.__)('Editor')
11506 }, !isTemplatePartsMode && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(NavLink, {
11507 icon: library_home,
11508 title: (0,external_wp_i18n_namespaceObject.__)('Site'),
11509 item: SITE_EDITOR_KEY,
11510 params: {
11511 postId: homeTemplate === null || homeTemplate === void 0 ? void 0 : homeTemplate.postId,
11512 postType: homeTemplate === null || homeTemplate === void 0 ? void 0 : homeTemplate.postType
11513 }
11514 }), (0,external_wp_element_namespaceObject.createElement)(NavLink, {
11515 icon: library_layout,
11516 title: (0,external_wp_i18n_namespaceObject.__)('Templates'),
11517 item: "wp_template",
11518 params: {
11519 postId: undefined,
11520 postType: 'wp_template'
11521 }
11522 })), (0,external_wp_element_namespaceObject.createElement)(NavLink, {
11523 icon: symbol_filled,
11524 title: (0,external_wp_i18n_namespaceObject.__)('Template Parts'),
11525 item: "wp_template_part",
11526 params: {
11527 postId: undefined,
11528 postType: 'wp_template_part'
11529 }
11530 })))))))
11531 );
11532 };
11533
11534 /* harmony default export */ var navigation_panel = (NavigationPanel);
11535
11536 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/wordpress.js
11537
11538
11539 /**
11540 * WordPress dependencies
11541 */
11542
11543 const wordpress = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11544 xmlns: "http://www.w3.org/2000/svg",
11545 viewBox: "-2 -2 24 24"
11546 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11547 d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"
11548 }));
11549 /* harmony default export */ var library_wordpress = (wordpress);
11550
11551 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-toggle/index.js
11552
11553
11554 /**
11555 * External dependencies
11556 */
11557
11558 /**
11559 * WordPress dependencies
11560 */
11561
11562
11563
11564
11565
11566
11567
11568
11569 /**
11570 * Internal dependencies
11571 */
11572
11573
11574
11575 function NavigationToggle(_ref) {
11576 let {
11577 icon
11578 } = _ref;
11579 const {
11580 isNavigationOpen,
11581 isRequestingSiteIcon,
11582 siteIconUrl
11583 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11584 const {
11585 getEntityRecord,
11586 isResolving
11587 } = select(external_wp_coreData_namespaceObject.store);
11588 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
11589 return {
11590 isNavigationOpen: select(store_store).isNavigationOpened(),
11591 isRequestingSiteIcon: isResolving('core', 'getEntityRecord', ['root', '__unstableBase', undefined]),
11592 siteIconUrl: siteData.site_icon_url
11593 };
11594 }, []);
11595 const {
11596 setIsNavigationPanelOpened
11597 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11598 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
11599 const navigationToggleRef = (0,external_wp_element_namespaceObject.useRef)();
11600 (0,external_wp_element_namespaceObject.useEffect)(() => {
11601 // TODO: Remove this effect when alternative solution is merged.
11602 // See: https://github.com/WordPress/gutenberg/pull/37314
11603 if (!isNavigationOpen) {
11604 navigationToggleRef.current.focus();
11605 }
11606 }, [isNavigationOpen]);
11607
11608 const toggleNavigationPanel = () => setIsNavigationPanelOpened(!isNavigationOpen);
11609
11610 let buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
11611 size: "36px",
11612 icon: library_wordpress
11613 });
11614 const effect = {
11615 expand: {
11616 scale: 1.25,
11617 transition: {
11618 type: 'tween',
11619 duration: '0.3'
11620 }
11621 }
11622 };
11623
11624 if (siteIconUrl) {
11625 buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.img, {
11626 variants: !disableMotion && effect,
11627 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
11628 className: "edit-site-navigation-toggle__site-icon",
11629 src: siteIconUrl
11630 });
11631 } else if (isRequestingSiteIcon) {
11632 buttonIcon = null;
11633 } else if (icon) {
11634 buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
11635 size: "36px",
11636 icon: icon
11637 });
11638 }
11639
11640 const classes = classnames_default()({
11641 'edit-site-navigation-toggle__button': true,
11642 'has-icon': siteIconUrl
11643 });
11644 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
11645 className: 'edit-site-navigation-toggle' + (isNavigationOpen ? ' is-open' : ''),
11646 whileHover: "expand"
11647 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11648 className: classes,
11649 label: (0,external_wp_i18n_namespaceObject.__)('Toggle navigation'),
11650 ref: navigationToggleRef // isPressed will add unwanted styles.
11651 ,
11652 "aria-pressed": isNavigationOpen,
11653 onClick: toggleNavigationPanel,
11654 showTooltip: true
11655 }, buttonIcon));
11656 }
11657
11658 /* harmony default export */ var navigation_toggle = (NavigationToggle);
11659
11660 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/index.js
11661
11662
11663 /**
11664 * WordPress dependencies
11665 */
11666
11667
11668
11669
11670 /**
11671 * Internal dependencies
11672 */
11673
11674
11675
11676
11677 const {
11678 Fill: NavigationPanelPreviewFill,
11679 Slot: NavigationPanelPreviewSlot
11680 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteNavigationPanelPreview');
11681 const {
11682 Fill: NavigationSidebarFill,
11683 Slot: NavigationSidebarSlot
11684 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteNavigationSidebar');
11685
11686 function NavigationSidebar(_ref) {
11687 let {
11688 isDefaultOpen = false,
11689 activeTemplateType
11690 } = _ref;
11691 const isDesktopViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
11692 const {
11693 setIsNavigationPanelOpened
11694 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11695 (0,external_wp_element_namespaceObject.useEffect)(function autoOpenNavigationPanelOnViewportChange() {
11696 setIsNavigationPanelOpened(isDefaultOpen && isDesktopViewport);
11697 }, [isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened]);
11698 return (0,external_wp_element_namespaceObject.createElement)(NavigationSidebarFill, null, (0,external_wp_element_namespaceObject.createElement)(navigation_toggle, null), (0,external_wp_element_namespaceObject.createElement)(navigation_panel, {
11699 activeItem: activeTemplateType
11700 }), (0,external_wp_element_namespaceObject.createElement)(NavigationPanelPreviewSlot, null));
11701 }
11702
11703 NavigationSidebar.Slot = NavigationSidebarSlot;
11704 /* harmony default export */ var navigation_sidebar = (NavigationSidebar);
11705
11706 ;// CONCATENATED MODULE: external ["wp","reusableBlocks"]
11707 var external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"];
11708 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/convert-to-regular.js
11709
11710
11711 /**
11712 * WordPress dependencies
11713 */
11714
11715
11716
11717
11718 function ConvertToRegularBlocks(_ref) {
11719 let {
11720 clientId
11721 } = _ref;
11722 const {
11723 getBlocks
11724 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
11725 const {
11726 replaceBlocks
11727 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
11728 const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]);
11729
11730 if (!canRemove) {
11731 return null;
11732 }
11733
11734 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, _ref2 => {
11735 let {
11736 onClose
11737 } = _ref2;
11738 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
11739 onClick: () => {
11740 replaceBlocks(clientId, getBlocks(clientId));
11741 onClose();
11742 }
11743 }, (0,external_wp_i18n_namespaceObject.__)('Detach blocks from template part'));
11744 });
11745 }
11746
11747 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/create-template-part-modal/index.js
11748
11749
11750 /**
11751 * WordPress dependencies
11752 */
11753
11754
11755
11756
11757
11758
11759
11760 /**
11761 * Internal dependencies
11762 */
11763
11764
11765 function CreateTemplatePartModal(_ref) {
11766 let {
11767 closeModal,
11768 onCreate
11769 } = _ref;
11770 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
11771 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(TEMPLATE_PART_AREA_GENERAL);
11772 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false);
11773 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal);
11774 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []);
11775 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
11776 title: (0,external_wp_i18n_namespaceObject.__)('Create a template part'),
11777 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
11778 onRequestClose: closeModal,
11779 overlayClassName: "edit-site-create-template-part-modal"
11780 }, (0,external_wp_element_namespaceObject.createElement)("form", {
11781 onSubmit: async event => {
11782 event.preventDefault();
11783
11784 if (!title) {
11785 return;
11786 }
11787
11788 setIsSubmitting(true);
11789 await onCreate({
11790 title,
11791 area
11792 });
11793 }
11794 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
11795 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
11796 value: title,
11797 onChange: setTitle,
11798 required: true
11799 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, {
11800 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
11801 id: `edit-site-create-template-part-modal__area-selection-${instanceId}`,
11802 className: "edit-site-create-template-part-modal__area-base-control"
11803 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalRadioGroup, {
11804 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
11805 className: "edit-site-create-template-part-modal__area-radio-group",
11806 id: `edit-site-create-template-part-modal__area-selection-${instanceId}`,
11807 onChange: setArea,
11808 checked: area
11809 }, templatePartAreas.map(_ref2 => {
11810 let {
11811 icon,
11812 label,
11813 area: value,
11814 description
11815 } = _ref2;
11816 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalRadio, {
11817 key: label,
11818 value: value,
11819 className: "edit-site-create-template-part-modal__area-radio"
11820 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
11821 align: "start",
11822 justify: "start"
11823 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
11824 icon: icon
11825 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, {
11826 className: "edit-site-create-template-part-modal__option-label"
11827 }, label, (0,external_wp_element_namespaceObject.createElement)("div", null, description)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
11828 className: "edit-site-create-template-part-modal__checkbox"
11829 }, area === value && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
11830 icon: library_check
11831 }))));
11832 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
11833 className: "edit-site-create-template-part-modal__modal-actions",
11834 justify: "flex-end"
11835 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11836 variant: "secondary",
11837 onClick: () => {
11838 closeModal();
11839 }
11840 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11841 variant: "primary",
11842 type: "submit",
11843 disabled: !title,
11844 isBusy: isSubmitting
11845 }, (0,external_wp_i18n_namespaceObject.__)('Create'))))));
11846 }
11847
11848 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/convert-to-template-part.js
11849
11850
11851 /**
11852 * External dependencies
11853 */
11854
11855 /**
11856 * WordPress dependencies
11857 */
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868 /**
11869 * Internal dependencies
11870 */
11871
11872
11873
11874 function ConvertToTemplatePart(_ref) {
11875 let {
11876 clientIds,
11877 blocks
11878 } = _ref;
11879 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
11880 const {
11881 replaceBlocks
11882 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
11883 const {
11884 saveEntityRecord
11885 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11886 const {
11887 createSuccessNotice
11888 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
11889 const {
11890 canCreate
11891 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11892 const {
11893 supportsTemplatePartsMode
11894 } = select(store_store).getSettings();
11895 return {
11896 canCreate: !supportsTemplatePartsMode
11897 };
11898 }, []);
11899
11900 if (!canCreate) {
11901 return null;
11902 }
11903
11904 const onConvert = async _ref2 => {
11905 let {
11906 title,
11907 area
11908 } = _ref2;
11909 // Currently template parts only allow latin chars.
11910 // Fallback slug will receive suffix by default.
11911 const cleanSlug = (0,external_lodash_namespaceObject.kebabCase)(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
11912 const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
11913 slug: cleanSlug,
11914 title,
11915 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks),
11916 area
11917 });
11918 replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', {
11919 slug: templatePart.slug,
11920 theme: templatePart.theme
11921 }));
11922 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), {
11923 type: 'snackbar'
11924 }); // The modal and this component will be unmounted because of `replaceBlocks` above,
11925 // so no need to call `closeModal` or `onClose`.
11926 };
11927
11928 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
11929 icon: symbol_filled,
11930 onClick: () => {
11931 setIsModalOpen(true);
11932 }
11933 }, (0,external_wp_i18n_namespaceObject.__)('Create Template part'))), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, {
11934 closeModal: () => {
11935 setIsModalOpen(false);
11936 },
11937 onCreate: onConvert
11938 }));
11939 }
11940
11941 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/index.js
11942
11943
11944 /**
11945 * WordPress dependencies
11946 */
11947
11948
11949 /**
11950 * Internal dependencies
11951 */
11952
11953
11954
11955 function TemplatePartConverter() {
11956 var _blocks$;
11957
11958 const {
11959 clientIds,
11960 blocks
11961 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11962 const {
11963 getSelectedBlockClientIds,
11964 getBlocksByClientId
11965 } = select(external_wp_blockEditor_namespaceObject.store);
11966 const selectedBlockClientIds = getSelectedBlockClientIds();
11967 return {
11968 clientIds: selectedBlockClientIds,
11969 blocks: getBlocksByClientId(selectedBlockClientIds)
11970 };
11971 }, []); // Allow converting a single template part to standard blocks.
11972
11973 if (blocks.length === 1 && ((_blocks$ = blocks[0]) === null || _blocks$ === void 0 ? void 0 : _blocks$.name) === 'core/template-part') {
11974 return (0,external_wp_element_namespaceObject.createElement)(ConvertToRegularBlocks, {
11975 clientId: clientIds[0]
11976 });
11977 }
11978
11979 return (0,external_wp_element_namespaceObject.createElement)(ConvertToTemplatePart, {
11980 clientIds: clientIds,
11981 blocks: blocks
11982 });
11983 }
11984
11985 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/pencil.js
11986
11987
11988 /**
11989 * WordPress dependencies
11990 */
11991
11992 const pencil = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11993 xmlns: "http://www.w3.org/2000/svg",
11994 viewBox: "0 0 24 24"
11995 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11996 d: "M20.1 5.1L16.9 2 6.2 12.7l-1.3 4.4 4.5-1.3L20.1 5.1zM4 20.8h8v-1.5H4v1.5z"
11997 }));
11998 /* harmony default export */ var library_pencil = (pencil);
11999
12000 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/edit.js
12001 /**
12002 * Internal dependencies
12003 */
12004
12005 /* harmony default export */ var edit = (library_pencil);
12006
12007 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigate-to-link/index.js
12008
12009
12010 /**
12011 * WordPress dependencies
12012 */
12013
12014
12015
12016
12017
12018
12019
12020 function NavigateToLink(_ref) {
12021 let {
12022 type,
12023 id,
12024 activePage,
12025 onActivePageChange
12026 } = _ref;
12027 const post = (0,external_wp_data_namespaceObject.useSelect)(select => type && id && type !== 'URL' && select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', type, id), [type, id]);
12028 const onClick = (0,external_wp_element_namespaceObject.useMemo)(() => {
12029 if (!(post !== null && post !== void 0 && post.link)) return null;
12030 const path = (0,external_wp_url_namespaceObject.getPathAndQueryString)(post.link);
12031 if (path === (activePage === null || activePage === void 0 ? void 0 : activePage.path)) return null;
12032 return () => onActivePageChange({
12033 type,
12034 slug: post.slug,
12035 path,
12036 context: {
12037 postType: post.type,
12038 postId: post.id
12039 }
12040 });
12041 }, [post, activePage === null || activePage === void 0 ? void 0 : activePage.path, onActivePageChange]);
12042 return onClick && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12043 icon: edit,
12044 label: (0,external_wp_i18n_namespaceObject.__)('Edit Page Template'),
12045 onClick: onClick
12046 });
12047 }
12048
12049 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/block-inspector-button.js
12050
12051
12052 /**
12053 * WordPress dependencies
12054 */
12055
12056
12057
12058
12059
12060
12061 /**
12062 * Internal dependencies
12063 */
12064
12065
12066
12067
12068 function BlockInspectorButton(_ref) {
12069 let {
12070 onClick = () => {}
12071 } = _ref;
12072 const {
12073 shortcut,
12074 isBlockInspectorOpen
12075 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
12076 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-block-settings-sidebar'),
12077 isBlockInspectorOpen: select(store).getActiveComplementaryArea(store_store.name) === SIDEBAR_BLOCK
12078 }), []);
12079 const {
12080 enableComplementaryArea,
12081 disableComplementaryArea
12082 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
12083 const label = isBlockInspectorOpen ? (0,external_wp_i18n_namespaceObject.__)('Hide more settings') : (0,external_wp_i18n_namespaceObject.__)('Show more settings');
12084 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
12085 onClick: () => {
12086 if (isBlockInspectorOpen) {
12087 disableComplementaryArea(constants_STORE_NAME);
12088 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Block settings closed'));
12089 } else {
12090 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK);
12091 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Additional settings are now available in the Editor block settings sidebar'));
12092 } // Close dropdown menu.
12093
12094
12095 onClick();
12096 },
12097 shortcut: shortcut
12098 }, label);
12099 }
12100
12101 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/arrow-left.js
12102
12103
12104 /**
12105 * WordPress dependencies
12106 */
12107
12108 const arrowLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12109 xmlns: "http://www.w3.org/2000/svg",
12110 viewBox: "0 0 24 24"
12111 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12112 d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"
12113 }));
12114 /* harmony default export */ var arrow_left = (arrowLeft);
12115
12116 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/back-button.js
12117
12118
12119 /**
12120 * WordPress dependencies
12121 */
12122
12123
12124
12125 /**
12126 * Internal dependencies
12127 */
12128
12129
12130
12131 function BackButton() {
12132 var _location$state;
12133
12134 const location = useLocation();
12135 const history = useHistory();
12136 const isTemplatePart = location.params.postType === 'wp_template_part';
12137 const previousTemplateId = (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.fromTemplateId;
12138
12139 if (!isTemplatePart || !previousTemplateId) {
12140 return null;
12141 }
12142
12143 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12144 className: "edit-site-visual-editor__back-button",
12145 icon: arrow_left,
12146 onClick: () => {
12147 history.back();
12148 }
12149 }, (0,external_wp_i18n_namespaceObject.__)('Back'));
12150 }
12151
12152 /* harmony default export */ var back_button = (BackButton);
12153
12154 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/resize-handle.js
12155
12156
12157 /**
12158 * WordPress dependencies
12159 */
12160
12161
12162
12163 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
12164
12165 function ResizeHandle(_ref) {
12166 let {
12167 direction,
12168 resizeWidthBy
12169 } = _ref;
12170
12171 function handleKeyDown(event) {
12172 const {
12173 keyCode
12174 } = event;
12175
12176 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) {
12177 resizeWidthBy(DELTA_DISTANCE);
12178 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) {
12179 resizeWidthBy(-DELTA_DISTANCE);
12180 }
12181 }
12182
12183 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("button", {
12184 className: `resizable-editor__drag-handle is-${direction}`,
12185 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
12186 "aria-describedby": `resizable-editor__resize-help-${direction}`,
12187 onKeyDown: handleKeyDown
12188 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
12189 id: `resizable-editor__resize-help-${direction}`
12190 }, (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.')));
12191 }
12192
12193 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/resizable-editor.js
12194
12195
12196
12197 /**
12198 * WordPress dependencies
12199 */
12200
12201
12202
12203
12204
12205 /**
12206 * Internal dependencies
12207 */
12208
12209
12210 // Removes the inline styles in the drag handles.
12211
12212 const HANDLE_STYLES_OVERRIDE = {
12213 position: undefined,
12214 userSelect: undefined,
12215 cursor: undefined,
12216 width: undefined,
12217 height: undefined,
12218 top: undefined,
12219 right: undefined,
12220 bottom: undefined,
12221 left: undefined
12222 };
12223
12224 function ResizableEditor(_ref) {
12225 let {
12226 enableResizing,
12227 settings,
12228 children,
12229 ...props
12230 } = _ref;
12231 const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
12232 const {
12233 deviceType,
12234 isZoomOutMode
12235 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
12236 deviceType: select(store_store).__experimentalGetPreviewDeviceType(),
12237 isZoomOutMode: select(external_wp_blockEditor_namespaceObject.store).__unstableGetEditorMode() === 'zoom-out'
12238 }), []);
12239 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType);
12240 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)('100%');
12241 const iframeRef = (0,external_wp_element_namespaceObject.useRef)();
12242 const mouseMoveTypingResetRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseMouseMoveTypingReset)();
12243 const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([iframeRef, mouseMoveTypingResetRef]);
12244 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => {
12245 if (iframeRef.current) {
12246 setWidth(iframeRef.current.offsetWidth + deltaPixels);
12247 }
12248 }, []);
12249 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ResizableBox, {
12250 size: {
12251 width: enableResizing ? width : '100%',
12252 height: enableResizing && sizes.height ? sizes.height : '100%'
12253 },
12254 onResizeStop: (event, direction, element) => {
12255 setWidth(element.style.width);
12256 },
12257 minWidth: 300,
12258 maxWidth: "100%",
12259 maxHeight: "100%",
12260 enable: {
12261 right: enableResizing,
12262 left: enableResizing
12263 },
12264 showHandle: enableResizing // The editor is centered horizontally, resizing it only
12265 // moves half the distance. Hence double the ratio to correctly
12266 // align the cursor to the resizer handle.
12267 ,
12268 resizeRatio: 2,
12269 handleComponent: {
12270 left: (0,external_wp_element_namespaceObject.createElement)(ResizeHandle, {
12271 direction: "left",
12272 resizeWidthBy: resizeWidthBy
12273 }),
12274 right: (0,external_wp_element_namespaceObject.createElement)(ResizeHandle, {
12275 direction: "right",
12276 resizeWidthBy: resizeWidthBy
12277 })
12278 },
12279 handleClasses: undefined,
12280 handleStyles: {
12281 left: HANDLE_STYLES_OVERRIDE,
12282 right: HANDLE_STYLES_OVERRIDE
12283 }
12284 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, extends_extends({
12285 isZoomedOut: isZoomOutMode,
12286 style: enableResizing ? {} : deviceStyles,
12287 head: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
12288 styles: settings.styles
12289 }), (0,external_wp_element_namespaceObject.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing.
12290 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
12291 `.is-root-container { display: flow-root; }
12292 body { position: relative; }`), enableResizing && (0,external_wp_element_namespaceObject.createElement)("style", null, // Some themes will have `min-height: 100vh` for the root container,
12293 // which isn't a requirement in auto resize mode.
12294 `.is-root-container { min-height: 0 !important; }`)),
12295 assets: settings.__unstableResolvedAssets,
12296 ref: ref,
12297 name: "editor-canvas",
12298 className: "edit-site-visual-editor__editor-canvas"
12299 }, props), settings.svgFilters, resizeObserver, children));
12300 }
12301
12302 /* harmony default export */ var resizable_editor = (ResizableEditor);
12303
12304 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/index.js
12305
12306
12307
12308 /**
12309 * External dependencies
12310 */
12311
12312 /**
12313 * WordPress dependencies
12314 */
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326 /**
12327 * Internal dependencies
12328 */
12329
12330
12331
12332
12333
12334
12335
12336
12337 const LAYOUT = {
12338 type: 'default',
12339 // At the root level of the site editor, no alignments should be allowed.
12340 alignments: []
12341 };
12342 const NAVIGATION_SIDEBAR_NAME = 'edit-site/navigation-menu';
12343 function BlockEditor(_ref) {
12344 var _storedSettings$__exp, _storedSettings$__exp2;
12345
12346 let {
12347 setIsInserterOpen
12348 } = _ref;
12349 const {
12350 storedSettings,
12351 templateType,
12352 templateId,
12353 page,
12354 isNavigationSidebarOpen
12355 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12356 const {
12357 getSettings,
12358 getEditedPostType,
12359 getEditedPostId,
12360 getPage
12361 } = select(store_store);
12362 return {
12363 storedSettings: getSettings(setIsInserterOpen),
12364 templateType: getEditedPostType(),
12365 templateId: getEditedPostId(),
12366 page: getPage(),
12367 isNavigationSidebarOpen: select(store).getActiveComplementaryArea(store_store.name) === NAVIGATION_SIDEBAR_NAME
12368 };
12369 }, [setIsInserterOpen]);
12370 const settingsBlockPatterns = (_storedSettings$__exp = storedSettings.__experimentalAdditionalBlockPatterns) !== null && _storedSettings$__exp !== void 0 ? _storedSettings$__exp : // WP 6.0
12371 storedSettings.__experimentalBlockPatterns; // WP 5.9
12372
12373 const settingsBlockPatternCategories = (_storedSettings$__exp2 = storedSettings.__experimentalAdditionalBlockPatternCategories) !== null && _storedSettings$__exp2 !== void 0 ? _storedSettings$__exp2 : // WP 6.0
12374 storedSettings.__experimentalBlockPatternCategories; // WP 5.9
12375
12376 const {
12377 restBlockPatterns,
12378 restBlockPatternCategories
12379 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
12380 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
12381 restBlockPatternCategories: select(external_wp_coreData_namespaceObject.store).getBlockPatternCategories()
12382 }), []);
12383 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || []), ...(restBlockPatterns || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)).filter(_ref2 => {
12384 let {
12385 postTypes
12386 } = _ref2;
12387 return !postTypes || Array.isArray(postTypes) && postTypes.includes(templateType);
12388 }), [settingsBlockPatterns, restBlockPatterns, templateType]);
12389 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]);
12390 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => {
12391 const {
12392 __experimentalAdditionalBlockPatterns,
12393 __experimentalAdditionalBlockPatternCategories,
12394 ...restStoredSettings
12395 } = storedSettings;
12396 return { ...restStoredSettings,
12397 __unstableFetchMedia: external_wp_coreData_namespaceObject.__experimentalFetchMedia,
12398 __experimentalBlockPatterns: blockPatterns,
12399 __experimentalBlockPatternCategories: blockPatternCategories
12400 };
12401 }, [storedSettings, blockPatterns, blockPatternCategories]);
12402 const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', templateType);
12403 const {
12404 setPage
12405 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12406 const {
12407 enableComplementaryArea,
12408 disableComplementaryArea
12409 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
12410 const toggleNavigationSidebar = (0,external_wp_element_namespaceObject.useCallback)(() => {
12411 const toggleComplementaryArea = isNavigationSidebarOpen ? disableComplementaryArea : enableComplementaryArea;
12412 toggleComplementaryArea(store_store.name, NAVIGATION_SIDEBAR_NAME);
12413 }, [isNavigationSidebarOpen]);
12414 const contentRef = (0,external_wp_element_namespaceObject.useRef)();
12415 const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([contentRef, (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)()]);
12416 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
12417 const {
12418 clearSelectedBlock
12419 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
12420 const isTemplatePart = templateType === 'wp_template_part';
12421 const hasBlocks = blocks.length !== 0;
12422
12423 const NavMenuSidebarToggle = () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
12424 className: "components-toolbar__control",
12425 label: isNavigationSidebarOpen ? (0,external_wp_i18n_namespaceObject.__)('Close list view') : (0,external_wp_i18n_namespaceObject.__)('Open list view'),
12426 onClick: toggleNavigationSidebar,
12427 icon: list_view,
12428 isActive: isNavigationSidebarOpen
12429 })); // Conditionally include NavMenu sidebar in Plugin only.
12430 // Optimise for dead code elimination.
12431 // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
12432
12433
12434 let MaybeNavMenuSidebarToggle = external_wp_element_namespaceObject.Fragment;
12435
12436 if (true) {
12437 MaybeNavMenuSidebarToggle = NavMenuSidebarToggle;
12438 }
12439
12440 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
12441 settings: settings,
12442 value: blocks,
12443 onInput: onInput,
12444 onChange: onChange,
12445 useSubRegistry: false
12446 }, (0,external_wp_element_namespaceObject.createElement)(TemplatePartConverter, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLinkControl.ViewerFill, null, (0,external_wp_element_namespaceObject.useCallback)(fillProps => (0,external_wp_element_namespaceObject.createElement)(NavigateToLink, extends_extends({}, fillProps, {
12447 activePage: page,
12448 onActivePageChange: setPage
12449 })), [page])), (0,external_wp_element_namespaceObject.createElement)(SidebarInspectorFill, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, {
12450 className: classnames_default()('edit-site-visual-editor', {
12451 'is-focus-mode': isTemplatePart
12452 }),
12453 __unstableContentRef: contentRef,
12454 onClick: event => {
12455 // Clear selected block when clicking on the gray background.
12456 if (event.target === event.currentTarget) {
12457 clearSelectedBlock();
12458 }
12459 }
12460 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(back_button, null), (0,external_wp_element_namespaceObject.createElement)(resizable_editor // Reinitialize the editor and reset the states when the template changes.
12461 , {
12462 key: templateId,
12463 enableResizing: isTemplatePart && // Disable resizing in mobile viewport.
12464 !isMobileViewport,
12465 settings: settings,
12466 contentRef: mergedRefs
12467 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, {
12468 className: "edit-site-block-editor__block-list wp-site-blocks",
12469 __experimentalLayout: LAYOUT,
12470 renderAppender: isTemplatePart && hasBlocks ? false : undefined
12471 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, null, _ref3 => {
12472 let {
12473 onClose
12474 } = _ref3;
12475 return (0,external_wp_element_namespaceObject.createElement)(BlockInspectorButton, {
12476 onClick: onClose
12477 });
12478 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockToolbarLastItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockNameContext.Consumer, null, blockName => blockName === 'core/navigation' && (0,external_wp_element_namespaceObject.createElement)(MaybeNavMenuSidebarToggle, null)))), (0,external_wp_element_namespaceObject.createElement)(external_wp_reusableBlocks_namespaceObject.ReusableBlocksMenuItems, null));
12479 }
12480
12481 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
12482 var lib = __webpack_require__(773);
12483 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/code-editor/code-editor-text-area.js
12484
12485
12486 /**
12487 * External dependencies
12488 */
12489
12490 /**
12491 * WordPress dependencies
12492 */
12493
12494
12495
12496
12497
12498 function CodeEditorTextArea(_ref) {
12499 let {
12500 value,
12501 onChange,
12502 onInput
12503 } = _ref;
12504 const [stateValue, setStateValue] = (0,external_wp_element_namespaceObject.useState)(value);
12505 const [isDirty, setIsDirty] = (0,external_wp_element_namespaceObject.useState)(false);
12506 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CodeEditorTextArea);
12507 const valueRef = (0,external_wp_element_namespaceObject.useRef)();
12508
12509 if (!isDirty && stateValue !== value) {
12510 setStateValue(value);
12511 }
12512 /**
12513 * Handles a textarea change event to notify the onChange prop callback and
12514 * reflect the new value in the component's own state. This marks the start
12515 * of the user's edits, if not already changed, preventing future props
12516 * changes to value from replacing the rendered value. This is expected to
12517 * be followed by a reset to dirty state via `stopEditing`.
12518 *
12519 * @see stopEditing
12520 *
12521 * @param {Event} event Change event.
12522 */
12523
12524
12525 const onChangeHandler = event => {
12526 const newValue = event.target.value;
12527 onInput(newValue);
12528 setStateValue(newValue);
12529 setIsDirty(true);
12530 valueRef.current = newValue;
12531 };
12532 /**
12533 * Function called when the user has completed their edits, responsible for
12534 * ensuring that changes, if made, are surfaced to the onPersist prop
12535 * callback and resetting dirty state.
12536 */
12537
12538
12539 const stopEditing = () => {
12540 if (isDirty) {
12541 onChange(stateValue);
12542 setIsDirty(false);
12543 }
12544 }; // Ensure changes aren't lost when component unmounts.
12545
12546
12547 (0,external_wp_element_namespaceObject.useEffect)(() => {
12548 return () => {
12549 if (valueRef.current) {
12550 onChange(valueRef.current);
12551 }
12552 };
12553 }, []);
12554 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
12555 as: "label",
12556 htmlFor: `code-editor-text-area-${instanceId}`
12557 }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
12558 autoComplete: "off",
12559 dir: "auto",
12560 value: stateValue,
12561 onChange: onChangeHandler,
12562 onBlur: stopEditing,
12563 className: "edit-site-code-editor-text-area",
12564 id: `code-editor-text-area-${instanceId}`,
12565 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
12566 }));
12567 }
12568
12569 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/code-editor/index.js
12570
12571
12572 /**
12573 * WordPress dependencies
12574 */
12575
12576
12577
12578
12579
12580
12581 /**
12582 * Internal dependencies
12583 */
12584
12585
12586
12587 function CodeEditor() {
12588 const {
12589 templateType,
12590 shortcut
12591 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12592 const {
12593 getEditedPostType
12594 } = select(store_store);
12595 const {
12596 getShortcutRepresentation
12597 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
12598 return {
12599 templateType: getEditedPostType(),
12600 shortcut: getShortcutRepresentation('core/edit-site/toggle-mode')
12601 };
12602 }, []);
12603 const [contentStructure, setContent] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', templateType, 'content');
12604 const [blocks,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', templateType); // Replicates the logic found in getEditedPostContent().
12605
12606 let content;
12607
12608 if (contentStructure instanceof Function) {
12609 content = contentStructure({
12610 blocks
12611 });
12612 } else if (blocks) {
12613 // If we have parsed blocks already, they should be our source of truth.
12614 // Parsing applies block deprecations and legacy block conversions that
12615 // unparsed content will not have.
12616 content = (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocks);
12617 } else {
12618 content = contentStructure;
12619 }
12620
12621 const {
12622 switchEditorMode
12623 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12624 return (0,external_wp_element_namespaceObject.createElement)("div", {
12625 className: "edit-site-code-editor"
12626 }, (0,external_wp_element_namespaceObject.createElement)("div", {
12627 className: "edit-site-code-editor__toolbar"
12628 }, (0,external_wp_element_namespaceObject.createElement)("h2", null, (0,external_wp_i18n_namespaceObject.__)('Editing code')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12629 variant: "tertiary",
12630 onClick: () => switchEditorMode('visual'),
12631 shortcut: shortcut
12632 }, (0,external_wp_i18n_namespaceObject.__)('Exit code editor'))), (0,external_wp_element_namespaceObject.createElement)("div", {
12633 className: "edit-site-code-editor__body"
12634 }, (0,external_wp_element_namespaceObject.createElement)(CodeEditorTextArea, {
12635 value: content,
12636 onChange: newContent => {
12637 onChange((0,external_wp_blocks_namespaceObject.parse)(newContent), {
12638 selection: undefined
12639 });
12640 },
12641 onInput: setContent
12642 })));
12643 }
12644
12645 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcuts/index.js
12646 /**
12647 * WordPress dependencies
12648 */
12649
12650
12651
12652
12653
12654
12655 /**
12656 * Internal dependencies
12657 */
12658
12659
12660
12661
12662
12663 function KeyboardShortcuts() {
12664 const {
12665 __experimentalGetDirtyEntityRecords,
12666 isSavingEntityRecord
12667 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
12668 const {
12669 getEditorMode
12670 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
12671 const isListViewOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).isListViewOpened(), []);
12672 const isBlockInspectorOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(store_store.name) === SIDEBAR_BLOCK, []);
12673 const {
12674 redo,
12675 undo
12676 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
12677 const {
12678 setIsListViewOpened,
12679 switchEditorMode
12680 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12681 const {
12682 enableComplementaryArea,
12683 disableComplementaryArea
12684 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
12685 const {
12686 setIsSaveViewOpened
12687 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12688 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/save', event => {
12689 event.preventDefault();
12690
12691 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
12692
12693 const isDirty = !!dirtyEntityRecords.length;
12694 const isSaving = dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key));
12695
12696 if (!isSaving && isDirty) {
12697 setIsSaveViewOpened(true);
12698 }
12699 });
12700 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/undo', event => {
12701 undo();
12702 event.preventDefault();
12703 });
12704 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/redo', event => {
12705 redo();
12706 event.preventDefault();
12707 });
12708 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-list-view', () => {
12709 setIsListViewOpened(!isListViewOpen);
12710 });
12711 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-block-settings-sidebar', event => {
12712 // This shortcut has no known clashes, but use preventDefault to prevent any
12713 // obscure shortcuts from triggering.
12714 event.preventDefault();
12715
12716 if (isBlockInspectorOpen) {
12717 disableComplementaryArea(constants_STORE_NAME);
12718 } else {
12719 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK);
12720 }
12721 });
12722 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-mode', () => {
12723 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
12724 });
12725 return null;
12726 }
12727
12728 function KeyboardShortcutsRegister() {
12729 // Registering the shortcuts.
12730 const {
12731 registerShortcut
12732 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
12733 (0,external_wp_element_namespaceObject.useEffect)(() => {
12734 registerShortcut({
12735 name: 'core/edit-site/save',
12736 category: 'global',
12737 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
12738 keyCombination: {
12739 modifier: 'primary',
12740 character: 's'
12741 }
12742 });
12743 registerShortcut({
12744 name: 'core/edit-site/undo',
12745 category: 'global',
12746 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
12747 keyCombination: {
12748 modifier: 'primary',
12749 character: 'z'
12750 }
12751 });
12752 registerShortcut({
12753 name: 'core/edit-site/redo',
12754 category: 'global',
12755 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
12756 keyCombination: {
12757 modifier: 'primaryShift',
12758 character: 'z'
12759 }
12760 });
12761 registerShortcut({
12762 name: 'core/edit-site/toggle-list-view',
12763 category: 'global',
12764 description: (0,external_wp_i18n_namespaceObject.__)('Open the block list view.'),
12765 keyCombination: {
12766 modifier: 'access',
12767 character: 'o'
12768 }
12769 });
12770 registerShortcut({
12771 name: 'core/edit-site/toggle-block-settings-sidebar',
12772 category: 'global',
12773 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the block settings sidebar.'),
12774 keyCombination: {
12775 modifier: 'primaryShift',
12776 character: ','
12777 }
12778 });
12779 registerShortcut({
12780 name: 'core/edit-site/keyboard-shortcuts',
12781 category: 'main',
12782 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
12783 keyCombination: {
12784 modifier: 'access',
12785 character: 'h'
12786 }
12787 });
12788 registerShortcut({
12789 name: 'core/edit-site/next-region',
12790 category: 'global',
12791 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
12792 keyCombination: {
12793 modifier: 'ctrl',
12794 character: '`'
12795 },
12796 aliases: [{
12797 modifier: 'access',
12798 character: 'n'
12799 }]
12800 });
12801 registerShortcut({
12802 name: 'core/edit-site/previous-region',
12803 category: 'global',
12804 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
12805 keyCombination: {
12806 modifier: 'ctrlShift',
12807 character: '`'
12808 },
12809 aliases: [{
12810 modifier: 'access',
12811 character: 'p'
12812 }, {
12813 modifier: 'ctrlShift',
12814 character: '~'
12815 }]
12816 });
12817 registerShortcut({
12818 name: 'core/edit-site/toggle-mode',
12819 category: 'global',
12820 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
12821 keyCombination: {
12822 modifier: 'secondary',
12823 character: 'm'
12824 }
12825 });
12826 }, [registerShortcut]);
12827 return null;
12828 }
12829
12830 KeyboardShortcuts.Register = KeyboardShortcutsRegister;
12831 /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
12832
12833 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/url-query-controller/index.js
12834 /**
12835 * WordPress dependencies
12836 */
12837
12838
12839 /**
12840 * Internal dependencies
12841 */
12842
12843
12844
12845 function URLQueryController() {
12846 const {
12847 setTemplate,
12848 setTemplatePart,
12849 setPage
12850 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12851 const {
12852 params: {
12853 postId,
12854 postType
12855 }
12856 } = useLocation(); // Set correct entity on page navigation.
12857
12858 (0,external_wp_element_namespaceObject.useEffect)(() => {
12859 if ('page' === postType || 'post' === postType) {
12860 setPage({
12861 context: {
12862 postType,
12863 postId
12864 }
12865 }); // Resolves correct template based on ID.
12866 } else if ('wp_template' === postType) {
12867 setTemplate(postId);
12868 } else if ('wp_template_part' === postType) {
12869 setTemplatePart(postId);
12870 }
12871 }, [postId, postType]);
12872 return null;
12873 }
12874
12875 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close.js
12876
12877
12878 /**
12879 * WordPress dependencies
12880 */
12881
12882 const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12883 xmlns: "http://www.w3.org/2000/svg",
12884 viewBox: "0 0 24 24"
12885 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12886 d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
12887 }));
12888 /* harmony default export */ var library_close = (close_close);
12889
12890 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/secondary-sidebar/inserter-sidebar.js
12891
12892
12893
12894 /**
12895 * WordPress dependencies
12896 */
12897
12898
12899
12900
12901
12902
12903
12904 /**
12905 * Internal dependencies
12906 */
12907
12908
12909 function InserterSidebar() {
12910 const {
12911 setIsInserterOpened
12912 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12913 const insertionPoint = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetInsertionPoint(), []);
12914 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
12915 const TagName = !isMobile ? external_wp_components_namespaceObject.VisuallyHidden : 'div';
12916 const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
12917 onClose: () => setIsInserterOpened(false),
12918 focusOnMount: null
12919 });
12920 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
12921 (0,external_wp_element_namespaceObject.useEffect)(() => {
12922 libraryRef.current.focusSearch();
12923 }, []);
12924 return (0,external_wp_element_namespaceObject.createElement)("div", extends_extends({
12925 ref: inserterDialogRef
12926 }, inserterDialogProps, {
12927 className: "edit-site-editor__inserter-panel"
12928 }), (0,external_wp_element_namespaceObject.createElement)(TagName, {
12929 className: "edit-site-editor__inserter-panel-header"
12930 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12931 icon: library_close,
12932 label: (0,external_wp_i18n_namespaceObject.__)('Close block inserter'),
12933 onClick: () => setIsInserterOpened(false)
12934 })), (0,external_wp_element_namespaceObject.createElement)("div", {
12935 className: "edit-site-editor__inserter-panel-content"
12936 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, {
12937 showInserterHelpPanel: true,
12938 shouldFocusBlock: isMobile,
12939 rootClientId: insertionPoint.rootClientId,
12940 __experimentalInsertionIndex: insertionPoint.insertionIndex,
12941 __experimentalFilterValue: insertionPoint.filterValue,
12942 ref: libraryRef
12943 })));
12944 }
12945
12946 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/secondary-sidebar/list-view-sidebar.js
12947
12948
12949 /**
12950 * WordPress dependencies
12951 */
12952
12953
12954
12955
12956
12957
12958
12959 /**
12960 * Internal dependencies
12961 */
12962
12963
12964 function ListViewSidebar() {
12965 const {
12966 setIsListViewOpened
12967 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12968 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
12969 const headerFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
12970 const contentFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
12971
12972 function closeOnEscape(event) {
12973 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
12974 setIsListViewOpened(false);
12975 }
12976 }
12977
12978 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewSidebar);
12979 const labelId = `edit-site-editor__list-view-panel-label-${instanceId}`;
12980 return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
12981 (0,external_wp_element_namespaceObject.createElement)("div", {
12982 "aria-labelledby": labelId,
12983 className: "edit-site-editor__list-view-panel",
12984 onKeyDown: closeOnEscape
12985 }, (0,external_wp_element_namespaceObject.createElement)("div", {
12986 className: "edit-site-editor__list-view-panel-header",
12987 ref: headerFocusReturnRef
12988 }, (0,external_wp_element_namespaceObject.createElement)("strong", {
12989 id: labelId
12990 }, (0,external_wp_i18n_namespaceObject.__)('List View')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12991 icon: close_small,
12992 label: (0,external_wp_i18n_namespaceObject.__)('Close List View Sidebar'),
12993 onClick: () => setIsListViewOpened(false)
12994 })), (0,external_wp_element_namespaceObject.createElement)("div", {
12995 className: "edit-site-editor__list-view-panel-content",
12996 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([contentFocusReturnRef, focusOnMountRef])
12997 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, null)))
12998 );
12999 }
13000
13001 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/error-boundary/warning.js
13002
13003
13004 /**
13005 * WordPress dependencies
13006 */
13007
13008
13009
13010
13011
13012 function CopyButton(_ref) {
13013 let {
13014 text,
13015 children
13016 } = _ref;
13017 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
13018 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
13019 variant: "secondary",
13020 ref: ref
13021 }, children);
13022 }
13023
13024 function ErrorBoundaryWarning(_ref2) {
13025 let {
13026 message,
13027 error,
13028 reboot,
13029 dashboardLink
13030 } = _ref2;
13031 const actions = [];
13032
13033 if (reboot) {
13034 actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
13035 key: "recovery",
13036 onClick: reboot,
13037 variant: "secondary"
13038 }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery')));
13039 }
13040
13041 if (error) {
13042 actions.push((0,external_wp_element_namespaceObject.createElement)(CopyButton, {
13043 key: "copy-error",
13044 text: error.stack
13045 }, (0,external_wp_i18n_namespaceObject.__)('Copy Error')));
13046 }
13047
13048 if (dashboardLink) {
13049 actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
13050 key: "back-to-dashboard",
13051 variant: "secondary",
13052 href: dashboardLink
13053 }, (0,external_wp_i18n_namespaceObject.__)('Back to dashboard')));
13054 }
13055
13056 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
13057 className: "editor-error-boundary",
13058 actions: actions
13059 }, message);
13060 }
13061
13062 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/error-boundary/index.js
13063
13064
13065 /**
13066 * WordPress dependencies
13067 */
13068
13069
13070
13071 /**
13072 * Internal dependencies
13073 */
13074
13075
13076 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
13077 constructor() {
13078 super(...arguments);
13079 this.reboot = this.reboot.bind(this);
13080 this.state = {
13081 error: null
13082 };
13083 }
13084
13085 componentDidCatch(error) {
13086 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error);
13087 }
13088
13089 static getDerivedStateFromError(error) {
13090 return {
13091 error
13092 };
13093 }
13094
13095 reboot() {
13096 this.props.onError();
13097 }
13098
13099 render() {
13100 const {
13101 error
13102 } = this.state;
13103
13104 if (!error) {
13105 return this.props.children;
13106 }
13107
13108 return (0,external_wp_element_namespaceObject.createElement)(ErrorBoundaryWarning, {
13109 message: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'),
13110 error: error,
13111 reboot: this.reboot
13112 });
13113 }
13114
13115 }
13116
13117 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/image.js
13118
13119 function WelcomeGuideImage(_ref) {
13120 let {
13121 nonAnimatedSrc,
13122 animatedSrc
13123 } = _ref;
13124 return (0,external_wp_element_namespaceObject.createElement)("picture", {
13125 className: "edit-site-welcome-guide__image"
13126 }, (0,external_wp_element_namespaceObject.createElement)("source", {
13127 srcSet: nonAnimatedSrc,
13128 media: "(prefers-reduced-motion: reduce)"
13129 }), (0,external_wp_element_namespaceObject.createElement)("img", {
13130 src: animatedSrc,
13131 width: "312",
13132 height: "240",
13133 alt: ""
13134 }));
13135 }
13136
13137 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/editor.js
13138
13139
13140 /**
13141 * WordPress dependencies
13142 */
13143
13144
13145
13146
13147
13148 /**
13149 * Internal dependencies
13150 */
13151
13152
13153 function WelcomeGuideEditor() {
13154 const {
13155 toggle
13156 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
13157 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'), []);
13158
13159 if (!isActive) {
13160 return null;
13161 }
13162
13163 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
13164 className: "edit-site-welcome-guide",
13165 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the site editor'),
13166 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get Started'),
13167 onFinish: () => toggle('core/edit-site', 'welcomeGuide'),
13168 pages: [{
13169 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
13170 nonAnimatedSrc: "https://s.w.org/images/block-editor/edit-your-site.svg?1",
13171 animatedSrc: "https://s.w.org/images/block-editor/edit-your-site.gif?1"
13172 }),
13173 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
13174 className: "edit-site-welcome-guide__heading"
13175 }, (0,external_wp_i18n_namespaceObject.__)('Edit your site')), (0,external_wp_element_namespaceObject.createElement)("p", {
13176 className: "edit-site-welcome-guide__text"
13177 }, (0,external_wp_i18n_namespaceObject.__)('Design everything on your site — from the header right down to the footer — using blocks.')), (0,external_wp_element_namespaceObject.createElement)("p", {
13178 className: "edit-site-welcome-guide__text"
13179 }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors.'), {
13180 StylesIconImage: (0,external_wp_element_namespaceObject.createElement)("img", {
13181 alt: (0,external_wp_i18n_namespaceObject.__)('styles'),
13182 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z' fill='%231E1E1E'/%3E%3C/svg%3E%0A"
13183 })
13184 })))
13185 }]
13186 });
13187 }
13188
13189 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/styles.js
13190
13191
13192 /**
13193 * WordPress dependencies
13194 */
13195
13196
13197
13198
13199
13200 /**
13201 * Internal dependencies
13202 */
13203
13204
13205
13206 function WelcomeGuideStyles() {
13207 const {
13208 toggle
13209 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
13210 const {
13211 isActive,
13212 isStylesOpen
13213 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13214 const sidebar = select(store).getActiveComplementaryArea(store_store.name);
13215 return {
13216 isActive: !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuideStyles'),
13217 isStylesOpen: sidebar === 'edit-site/global-styles'
13218 };
13219 }, []);
13220
13221 if (!isActive || !isStylesOpen) {
13222 return null;
13223 }
13224
13225 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
13226 className: "edit-site-welcome-guide",
13227 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to styles'),
13228 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get Started'),
13229 onFinish: () => toggle('core/edit-site', 'welcomeGuideStyles'),
13230 pages: [{
13231 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
13232 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1",
13233 animatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.gif?1"
13234 }),
13235 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
13236 className: "edit-site-welcome-guide__heading"
13237 }, (0,external_wp_i18n_namespaceObject.__)('Welcome to Styles')), (0,external_wp_element_namespaceObject.createElement)("p", {
13238 className: "edit-site-welcome-guide__text"
13239 }, (0,external_wp_i18n_namespaceObject.__)('Tweak your site, or give it a whole new look! Get creative — how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here.')))
13240 }, {
13241 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
13242 nonAnimatedSrc: "https://s.w.org/images/block-editor/set-the-design.svg?1",
13243 animatedSrc: "https://s.w.org/images/block-editor/set-the-design.gif?1"
13244 }),
13245 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
13246 className: "edit-site-welcome-guide__heading"
13247 }, (0,external_wp_i18n_namespaceObject.__)('Set the design')), (0,external_wp_element_namespaceObject.createElement)("p", {
13248 className: "edit-site-welcome-guide__text"
13249 }, (0,external_wp_i18n_namespaceObject.__)('You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle! ')))
13250 }, {
13251 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
13252 nonAnimatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.svg?1",
13253 animatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.gif?1"
13254 }),
13255 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
13256 className: "edit-site-welcome-guide__heading"
13257 }, (0,external_wp_i18n_namespaceObject.__)('Personalize blocks')), (0,external_wp_element_namespaceObject.createElement)("p", {
13258 className: "edit-site-welcome-guide__text"
13259 }, (0,external_wp_i18n_namespaceObject.__)('You can adjust your blocks to ensure a cohesive experience across your site — add your unique colors to a branded Button block, or adjust the Heading block to your preferred size.')))
13260 }, {
13261 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
13262 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
13263 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
13264 }),
13265 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
13266 className: "edit-site-welcome-guide__heading"
13267 }, (0,external_wp_i18n_namespaceObject.__)('Learn more')), (0,external_wp_element_namespaceObject.createElement)("p", {
13268 className: "edit-site-welcome-guide__text"
13269 }, (0,external_wp_i18n_namespaceObject.__)('New to block themes and styling your site? '), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
13270 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/styles-overview/')
13271 }, (0,external_wp_i18n_namespaceObject.__)('Here’s a detailed guide to learn how to make the most of it.'))))
13272 }]
13273 });
13274 }
13275
13276 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/index.js
13277
13278
13279 /**
13280 * Internal dependencies
13281 */
13282
13283
13284 function WelcomeGuide() {
13285 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideEditor, null), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideStyles, null));
13286 }
13287
13288 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/editor/global-styles-renderer.js
13289 /**
13290 * WordPress dependencies
13291 */
13292
13293
13294 /**
13295 * Internal dependencies
13296 */
13297
13298
13299 /**
13300 * Internal dependencies
13301 */
13302
13303
13304
13305 function useGlobalStylesRenderer() {
13306 const [styles, settings, svgFilters] = useGlobalStylesOutput();
13307 const {
13308 getSettings
13309 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
13310 const {
13311 updateSettings
13312 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13313 (0,external_wp_element_namespaceObject.useEffect)(() => {
13314 var _currentStoreSettings;
13315
13316 if (!styles || !settings) {
13317 return;
13318 }
13319
13320 const currentStoreSettings = getSettings();
13321 const nonGlobalStyles = Object.values((_currentStoreSettings = currentStoreSettings.styles) !== null && _currentStoreSettings !== void 0 ? _currentStoreSettings : []).filter(style => !style.isGlobalStyles);
13322 updateSettings({ ...currentStoreSettings,
13323 styles: [...nonGlobalStyles, ...styles],
13324 svgFilters,
13325 __experimentalFeatures: settings
13326 });
13327 }, [styles, settings]);
13328 }
13329
13330 function GlobalStylesRenderer() {
13331 useGlobalStylesRenderer();
13332 return null;
13333 }
13334
13335 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/use-title.js
13336 /**
13337 * WordPress dependencies
13338 */
13339
13340
13341
13342
13343
13344
13345 /**
13346 * Internal dependencies
13347 */
13348
13349
13350 function useTitle(title) {
13351 const location = useLocation();
13352 const siteTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
13353 var _select$getEntityReco;
13354
13355 return (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', 'site')) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.title;
13356 }, []);
13357 const isInitialLocationRef = (0,external_wp_element_namespaceObject.useRef)(true);
13358 (0,external_wp_element_namespaceObject.useEffect)(() => {
13359 isInitialLocationRef.current = false;
13360 }, [location]);
13361 (0,external_wp_element_namespaceObject.useEffect)(() => {
13362 // Don't update or announce the title for initial page load.
13363 if (isInitialLocationRef.current) {
13364 return;
13365 }
13366
13367 if (title && siteTitle) {
13368 // @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68
13369 const formattedTitle = (0,external_wp_i18n_namespaceObject.sprintf)(
13370 /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
13371 (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s — WordPress'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle));
13372 document.title = formattedTitle; // Announce title on route change for screen readers.
13373
13374 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)(
13375 /* translators: The page title that is currently displaying. */
13376 (0,external_wp_i18n_namespaceObject.__)('Now displaying: %s'), document.title), 'assertive');
13377 }
13378 }, [title, siteTitle, location]);
13379 }
13380
13381 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/editor/index.js
13382
13383
13384 /**
13385 * WordPress dependencies
13386 */
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397 /**
13398 * Internal dependencies
13399 */
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416 const interfaceLabels = {
13417 /* translators: accessibility text for the editor top bar landmark region. */
13418 header: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'),
13419
13420 /* translators: accessibility text for the editor content landmark region. */
13421 body: (0,external_wp_i18n_namespaceObject.__)('Editor content'),
13422
13423 /* translators: accessibility text for the editor settings landmark region. */
13424 sidebar: (0,external_wp_i18n_namespaceObject.__)('Editor settings'),
13425
13426 /* translators: accessibility text for the editor publish landmark region. */
13427 actions: (0,external_wp_i18n_namespaceObject.__)('Editor publish'),
13428
13429 /* translators: accessibility text for the editor footer landmark region. */
13430 footer: (0,external_wp_i18n_namespaceObject.__)('Editor footer'),
13431
13432 /* translators: accessibility text for the navigation sidebar landmark region. */
13433 drawer: (0,external_wp_i18n_namespaceObject.__)('Navigation Sidebar')
13434 };
13435
13436 function Editor(_ref) {
13437 let {
13438 onError
13439 } = _ref;
13440 const {
13441 isInserterOpen,
13442 isListViewOpen,
13443 isSaveViewOpen,
13444 sidebarIsOpened,
13445 settings,
13446 entityId,
13447 templateType,
13448 page,
13449 template,
13450 templateResolved,
13451 isNavigationOpen,
13452 previousShortcut,
13453 nextShortcut,
13454 editorMode,
13455 showIconLabels,
13456 blockEditorMode
13457 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13458 const {
13459 isInserterOpened,
13460 isListViewOpened,
13461 isSaveViewOpened,
13462 getSettings,
13463 getEditedPostType,
13464 getEditedPostId,
13465 getPage,
13466 isNavigationOpened,
13467 getEditorMode
13468 } = select(store_store);
13469 const {
13470 hasFinishedResolution,
13471 getEntityRecord
13472 } = select(external_wp_coreData_namespaceObject.store);
13473 const {
13474 __unstableGetEditorMode
13475 } = select(external_wp_blockEditor_namespaceObject.store);
13476 const postType = getEditedPostType();
13477 const postId = getEditedPostId(); // The currently selected entity to display. Typically template or template part.
13478
13479 return {
13480 isInserterOpen: isInserterOpened(),
13481 isListViewOpen: isListViewOpened(),
13482 isSaveViewOpen: isSaveViewOpened(),
13483 sidebarIsOpened: !!select(store).getActiveComplementaryArea(store_store.name),
13484 settings: getSettings(),
13485 templateType: postType,
13486 page: getPage(),
13487 template: postId ? getEntityRecord('postType', postType, postId) : null,
13488 templateResolved: postId ? hasFinishedResolution('getEntityRecord', ['postType', postType, postId]) : false,
13489 entityId: postId,
13490 isNavigationOpen: isNavigationOpened(),
13491 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
13492 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/next-region'),
13493 editorMode: getEditorMode(),
13494 showIconLabels: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showIconLabels'),
13495 blockEditorMode: __unstableGetEditorMode()
13496 };
13497 }, []);
13498 const {
13499 setPage,
13500 setIsInserterOpened,
13501 setIsSaveViewOpened
13502 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13503 const {
13504 enableComplementaryArea
13505 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
13506 const blockContext = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...(page === null || page === void 0 ? void 0 : page.context),
13507 queryContext: [(page === null || page === void 0 ? void 0 : page.context.queryContext) || {
13508 page: 1
13509 }, newQueryContext => setPage({ ...page,
13510 context: { ...(page === null || page === void 0 ? void 0 : page.context),
13511 queryContext: { ...(page === null || page === void 0 ? void 0 : page.context.queryContext),
13512 ...newQueryContext
13513 }
13514 }
13515 })]
13516 }), [page === null || page === void 0 ? void 0 : page.context]);
13517 (0,external_wp_element_namespaceObject.useEffect)(() => {
13518 if (isNavigationOpen) {
13519 document.body.classList.add('is-navigation-sidebar-open');
13520 } else {
13521 document.body.classList.remove('is-navigation-sidebar-open');
13522 }
13523 }, [isNavigationOpen]);
13524 (0,external_wp_element_namespaceObject.useEffect)(function openGlobalStylesOnLoad() {
13525 const searchParams = new URLSearchParams(window.location.search);
13526
13527 if (searchParams.get('styles') === 'open') {
13528 enableComplementaryArea('core/edit-site', 'edit-site/global-styles');
13529 }
13530 }, [enableComplementaryArea]); // Don't render the Editor until the settings are set and loaded.
13531
13532 const isReady = (settings === null || settings === void 0 ? void 0 : settings.siteUrl) && templateType !== undefined && entityId !== undefined;
13533 const secondarySidebarLabel = isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
13534
13535 const secondarySidebar = () => {
13536 if (editorMode === 'visual' && isInserterOpen) {
13537 return (0,external_wp_element_namespaceObject.createElement)(InserterSidebar, null);
13538 }
13539
13540 if (editorMode === 'visual' && isListViewOpen) {
13541 return (0,external_wp_element_namespaceObject.createElement)(ListViewSidebar, null);
13542 }
13543
13544 return null;
13545 }; // Only announce the title once the editor is ready to prevent "Replace"
13546 // action in <URlQueryController> from double-announcing.
13547
13548
13549 useTitle(isReady && (0,external_wp_i18n_namespaceObject.__)('Editor (beta)'));
13550 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(URLQueryController, null), isReady && (0,external_wp_element_namespaceObject.createElement)(external_wp_keyboardShortcuts_namespaceObject.ShortcutProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
13551 kind: "root",
13552 type: "site"
13553 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
13554 kind: "postType",
13555 type: templateType,
13556 id: entityId
13557 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
13558 value: blockContext
13559 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesRenderer, null), (0,external_wp_element_namespaceObject.createElement)(ErrorBoundary, {
13560 onError: onError
13561 }, (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(SidebarComplementaryAreaFills, null), (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
13562 labels: { ...interfaceLabels,
13563 secondarySidebar: secondarySidebarLabel
13564 },
13565 className: showIconLabels && 'show-icon-labels',
13566 secondarySidebar: secondarySidebar(),
13567 sidebar: sidebarIsOpened && (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, {
13568 scope: "core/edit-site"
13569 }),
13570 drawer: (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar.Slot, null),
13571 header: (0,external_wp_element_namespaceObject.createElement)(Header, {
13572 showIconLabels: showIconLabels
13573 }),
13574 notices: (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null),
13575 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorNotices, null), editorMode === 'visual' && template && (0,external_wp_element_namespaceObject.createElement)(BlockEditor, {
13576 setIsInserterOpen: setIsInserterOpened
13577 }), editorMode === 'text' && template && (0,external_wp_element_namespaceObject.createElement)(CodeEditor, null), templateResolved && !template && (settings === null || settings === void 0 ? void 0 : settings.siteUrl) && entityId && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
13578 status: "warning",
13579 isDismissible: false
13580 }, (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")), (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts, null)),
13581 actions: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isSaveViewOpen ? (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EntitiesSavedStates, {
13582 close: () => setIsSaveViewOpened(false)
13583 }) : (0,external_wp_element_namespaceObject.createElement)("div", {
13584 className: "edit-site-editor__toggle-save-panel"
13585 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
13586 variant: "secondary",
13587 className: "edit-site-editor__toggle-save-panel-button",
13588 onClick: () => setIsSaveViewOpened(true),
13589 "aria-expanded": false
13590 }, (0,external_wp_i18n_namespaceObject.__)('Open save panel')))),
13591 footer: blockEditorMode !== 'zoom-out' ? (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
13592 rootLabelText: (0,external_wp_i18n_namespaceObject.__)('Template')
13593 }) : undefined,
13594 shortcuts: {
13595 previous: previousShortcut,
13596 next: nextShortcut
13597 }
13598 }), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuide, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null))))))));
13599 }
13600
13601 /* harmony default export */ var editor = (Editor);
13602
13603 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/use-register-shortcuts.js
13604 /**
13605 * WordPress dependencies
13606 */
13607
13608
13609
13610
13611 function useRegisterShortcuts() {
13612 const {
13613 registerShortcut
13614 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
13615 (0,external_wp_element_namespaceObject.useEffect)(() => {
13616 registerShortcut({
13617 name: 'core/edit-site/next-region',
13618 category: 'global',
13619 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
13620 keyCombination: {
13621 modifier: 'ctrl',
13622 character: '`'
13623 },
13624 aliases: [{
13625 modifier: 'access',
13626 character: 'n'
13627 }]
13628 });
13629 registerShortcut({
13630 name: 'core/edit-site/previous-region',
13631 category: 'global',
13632 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
13633 keyCombination: {
13634 modifier: 'ctrlShift',
13635 character: '`'
13636 },
13637 aliases: [{
13638 modifier: 'access',
13639 character: 'p'
13640 }, {
13641 modifier: 'ctrlShift',
13642 character: '~'
13643 }]
13644 });
13645 }, []);
13646 }
13647
13648 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post.js
13649
13650
13651 /**
13652 * WordPress dependencies
13653 */
13654
13655 const post = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13656 xmlns: "http://www.w3.org/2000/svg",
13657 viewBox: "0 0 24 24"
13658 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13659 d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z"
13660 }));
13661 /* harmony default export */ var library_post = (post);
13662
13663 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/page.js
13664
13665
13666 /**
13667 * WordPress dependencies
13668 */
13669
13670 const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13671 xmlns: "http://www.w3.org/2000/svg",
13672 viewBox: "0 0 24 24"
13673 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13674 d: "M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"
13675 }));
13676 /* harmony default export */ var library_page = (page);
13677
13678 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/archive.js
13679
13680
13681 /**
13682 * WordPress dependencies
13683 */
13684
13685 const archive = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13686 viewBox: "0 0 24 24",
13687 xmlns: "http://www.w3.org/2000/svg"
13688 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13689 d: "M19 6.2h-5.9l-.6-1.1c-.3-.7-1-1.1-1.8-1.1H5c-1.1 0-2 .9-2 2v11.8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8.2c0-1.1-.9-2-2-2zm.5 11.6c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h5.8c.2 0 .4.1.4.3l1 2H19c.3 0 .5.2.5.5v9.5zM8 12.8h8v-1.5H8v1.5zm0 3h8v-1.5H8v1.5z"
13690 }));
13691 /* harmony default export */ var library_archive = (archive);
13692
13693 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/search.js
13694
13695
13696 /**
13697 * WordPress dependencies
13698 */
13699
13700 const search = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13701 xmlns: "http://www.w3.org/2000/svg",
13702 viewBox: "0 0 24 24"
13703 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13704 d: "M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"
13705 }));
13706 /* harmony default export */ var library_search = (search);
13707
13708 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/not-found.js
13709
13710
13711 /**
13712 * WordPress dependencies
13713 */
13714
13715 const notFound = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13716 xmlns: "http://www.w3.org/2000/svg",
13717 viewBox: "0 0 24 24"
13718 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13719 d: "M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm.5 12c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v10zm-11-7.6h-.7l-3.1 4.3h2.8V15h1v-1.3h.7v-.8h-.7V9.4zm-.9 3.5H6.3l1.2-1.7v1.7zm5.6-3.2c-.4-.2-.8-.4-1.2-.4-.5 0-.9.1-1.2.4-.4.2-.6.6-.8 1-.2.4-.3.9-.3 1.5s.1 1.1.3 1.6c.2.4.5.8.8 1 .4.2.8.4 1.2.4.5 0 .9-.1 1.2-.4.4-.2.6-.6.8-1 .2-.4.3-1 .3-1.6 0-.6-.1-1.1-.3-1.5-.1-.5-.4-.8-.8-1zm0 3.6c-.1.3-.3.5-.5.7-.2.1-.4.2-.7.2-.3 0-.5-.1-.7-.2-.2-.1-.4-.4-.5-.7-.1-.3-.2-.7-.2-1.2 0-.7.1-1.2.4-1.5.3-.3.6-.5 1-.5s.7.2 1 .5c.3.3.4.8.4 1.5-.1.5-.1.9-.2 1.2zm5-3.9h-.7l-3.1 4.3h2.8V15h1v-1.3h.7v-.8h-.7V9.4zm-1 3.5H16l1.2-1.7v1.7z"
13720 }));
13721 /* harmony default export */ var not_found = (notFound);
13722
13723 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list.js
13724
13725
13726 /**
13727 * WordPress dependencies
13728 */
13729
13730 const list = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13731 viewBox: "0 0 24 24",
13732 xmlns: "http://www.w3.org/2000/svg"
13733 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13734 d: "M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"
13735 }));
13736 /* harmony default export */ var library_list = (list);
13737
13738 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/category.js
13739
13740
13741 /**
13742 * WordPress dependencies
13743 */
13744
13745 const category = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13746 viewBox: "0 0 24 24",
13747 xmlns: "http://www.w3.org/2000/svg"
13748 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13749 d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z",
13750 fillRule: "evenodd",
13751 clipRule: "evenodd"
13752 }));
13753 /* harmony default export */ var library_category = (category);
13754
13755 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post-author.js
13756
13757
13758 /**
13759 * WordPress dependencies
13760 */
13761
13762 const postAuthor = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13763 viewBox: "0 0 24 24",
13764 xmlns: "http://www.w3.org/2000/svg"
13765 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13766 d: "M10 4.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0zm2.25 7.5v-1A2.75 2.75 0 0011 8.25H7A2.75 2.75 0 004.25 11v1h1.5v-1c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v1h1.5zM4 20h9v-1.5H4V20zm16-4H4v-1.5h16V16z",
13767 fillRule: "evenodd",
13768 clipRule: "evenodd"
13769 }));
13770 /* harmony default export */ var post_author = (postAuthor);
13771
13772 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-meta.js
13773
13774
13775 /**
13776 * WordPress dependencies
13777 */
13778
13779 const blockMeta = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13780 xmlns: "http://www.w3.org/2000/svg",
13781 viewBox: "0 0 24 24"
13782 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13783 fillRule: "evenodd",
13784 d: "M8.95 11.25H4v1.5h4.95v4.5H13V18c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2v-3c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75h-2.55v-7.5H13V9c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75H8.95v4.5ZM14.5 15v3c0 .3.2.5.5.5h3c.3 0 .5-.2.5-.5v-3c0-.3-.2-.5-.5-.5h-3c-.3 0-.5.2-.5.5Zm0-6V6c0-.3.2-.5.5-.5h3c.3 0 .5.2.5.5v3c0 .3-.2.5-.5.5h-3c-.3 0-.5-.2-.5-.5Z",
13785 clipRule: "evenodd"
13786 }));
13787 /* harmony default export */ var block_meta = (blockMeta);
13788
13789 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post-date.js
13790
13791
13792 /**
13793 * WordPress dependencies
13794 */
13795
13796 const postDate = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13797 xmlns: "http://www.w3.org/2000/svg",
13798 viewBox: "0 0 24 24"
13799 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13800 d: "M11.696 13.972c.356-.546.599-.958.728-1.235a1.79 1.79 0 00.203-.783c0-.264-.077-.47-.23-.618-.148-.153-.354-.23-.618-.23-.295 0-.569.07-.82.212a3.413 3.413 0 00-.738.571l-.147-1.188c.289-.234.59-.41.903-.526.313-.117.66-.175 1.041-.175.375 0 .695.08.959.24.264.153.46.362.59.626.135.265.203.556.203.876 0 .362-.08.734-.24 1.115-.154.381-.427.87-.82 1.466l-.756 1.152H14v1.106h-4l1.696-2.609z"
13801 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13802 d: "M19.5 7h-15v12a.5.5 0 00.5.5h14a.5.5 0 00.5-.5V7zM3 7V5a2 2 0 012-2h14a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"
13803 }));
13804 /* harmony default export */ var post_date = (postDate);
13805
13806 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/tag.js
13807
13808
13809 /**
13810 * WordPress dependencies
13811 */
13812
13813 const tag = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13814 xmlns: "http://www.w3.org/2000/svg",
13815 viewBox: "0 0 24 24"
13816 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13817 d: "M20.1 11.2l-6.7-6.7c-.1-.1-.3-.2-.5-.2H5c-.4-.1-.8.3-.8.7v7.8c0 .2.1.4.2.5l6.7 6.7c.2.2.5.4.7.5s.6.2.9.2c.3 0 .6-.1.9-.2.3-.1.5-.3.8-.5l5.6-5.6c.4-.4.7-1 .7-1.6.1-.6-.2-1.2-.6-1.6zM19 13.4L13.4 19c-.1.1-.2.1-.3.2-.2.1-.4.1-.6 0-.1 0-.2-.1-.3-.2l-6.5-6.5V5.8h6.8l6.5 6.5c.2.2.2.4.2.6 0 .1 0 .3-.2.5zM9 8c-.6 0-1 .4-1 1s.4 1 1 1 1-.4 1-1-.4-1-1-1z"
13818 }));
13819 /* harmony default export */ var library_tag = (tag);
13820
13821 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/media.js
13822
13823
13824 /**
13825 * WordPress dependencies
13826 */
13827
13828 const media = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
13829 xmlns: "http://www.w3.org/2000/svg",
13830 viewBox: "0 0 24 24"
13831 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
13832 d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z"
13833 }));
13834 /* harmony default export */ var library_media = (media);
13835
13836 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/template-actions-loading-screen.js
13837
13838
13839 /**
13840 * WordPress dependencies
13841 */
13842
13843 function TemplateActionsLoadingScreen() {
13844 const baseCssClass = 'edit-site-template-actions-loading-screen-modal';
13845 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
13846 isFullScreen: true,
13847 isDismissible: false,
13848 shouldCloseOnClickOutside: false,
13849 shouldCloseOnEsc: false,
13850 onRequestClose: () => {},
13851 __experimentalHideHeader: true,
13852 className: baseCssClass
13853 }, (0,external_wp_element_namespaceObject.createElement)("div", {
13854 className: `${baseCssClass}__content`
13855 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)));
13856 }
13857
13858 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/utils.js
13859 /**
13860 * External dependencies
13861 */
13862
13863 /**
13864 * WordPress dependencies
13865 */
13866
13867
13868
13869
13870
13871
13872
13873
13874 /**
13875 * @typedef IHasNameAndId
13876 * @property {string|number} id The entity's id.
13877 * @property {string} name The entity's name.
13878 */
13879
13880 /**
13881 * Helper util to map records to add a `name` prop from a
13882 * provided path, in order to handle all entities in the same
13883 * fashion(implementing`IHasNameAndId` interface).
13884 *
13885 * @param {Object[]} entities The array of entities.
13886 * @param {string} path The path to map a `name` property from the entity.
13887 * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.
13888 */
13889
13890 const mapToIHasNameAndId = (entities, path) => {
13891 return (entities || []).map(entity => ({ ...entity,
13892 name: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)((0,external_lodash_namespaceObject.get)(entity, path))
13893 }));
13894 };
13895 /**
13896 * @typedef {Object} EntitiesInfo
13897 * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).
13898 * @property {number[]} existingEntitiesIds An array of the existing entities ids.
13899 */
13900
13901 const useExistingTemplates = () => {
13902 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
13903 per_page: -1
13904 }), []);
13905 };
13906 const useDefaultTemplateTypes = () => {
13907 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplateTypes(), []);
13908 };
13909
13910 const usePublicPostTypes = () => {
13911 const postTypes = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostTypes({
13912 per_page: -1
13913 }), []);
13914 return (0,external_wp_element_namespaceObject.useMemo)(() => {
13915 const excludedPostTypes = ['attachment'];
13916 return postTypes === null || postTypes === void 0 ? void 0 : postTypes.filter(_ref => {
13917 let {
13918 viewable,
13919 slug
13920 } = _ref;
13921 return viewable && !excludedPostTypes.includes(slug);
13922 });
13923 }, [postTypes]);
13924 };
13925
13926 const usePublicTaxonomies = () => {
13927 const taxonomies = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getTaxonomies({
13928 per_page: -1
13929 }), []);
13930 return (0,external_wp_element_namespaceObject.useMemo)(() => {
13931 return taxonomies === null || taxonomies === void 0 ? void 0 : taxonomies.filter(_ref2 => {
13932 let {
13933 visibility
13934 } = _ref2;
13935 return visibility === null || visibility === void 0 ? void 0 : visibility.publicly_queryable;
13936 });
13937 }, [taxonomies]);
13938 };
13939
13940 function usePostTypeNeedsUniqueIdentifier(publicPostTypes) {
13941 const postTypeLabels = (0,external_wp_element_namespaceObject.useMemo)(() => publicPostTypes === null || publicPostTypes === void 0 ? void 0 : publicPostTypes.reduce((accumulator, _ref3) => {
13942 let {
13943 labels
13944 } = _ref3;
13945 const singularName = labels.singular_name.toLowerCase();
13946 accumulator[singularName] = (accumulator[singularName] || 0) + 1;
13947 return accumulator;
13948 }, {}));
13949 return (0,external_wp_element_namespaceObject.useCallback)(_ref4 => {
13950 let {
13951 labels,
13952 slug
13953 } = _ref4;
13954 const singularName = labels.singular_name.toLowerCase();
13955 return postTypeLabels[singularName] > 1 && singularName !== slug;
13956 }, [postTypeLabels]);
13957 }
13958
13959 function usePostTypeArchiveMenuItems() {
13960 const publicPostTypes = usePublicPostTypes();
13961 const postTypesWithArchives = (0,external_wp_element_namespaceObject.useMemo)(() => publicPostTypes === null || publicPostTypes === void 0 ? void 0 : publicPostTypes.filter(postType => postType.has_archive), [publicPostTypes]);
13962 const existingTemplates = useExistingTemplates();
13963 const needsUniqueIdentifier = usePostTypeNeedsUniqueIdentifier(postTypesWithArchives);
13964 return (0,external_wp_element_namespaceObject.useMemo)(() => (postTypesWithArchives === null || postTypesWithArchives === void 0 ? void 0 : postTypesWithArchives.filter(postType => !(existingTemplates || []).some(existingTemplate => existingTemplate.slug === 'archive-' + postType.slug)).map(postType => {
13965 var _postType$icon;
13966
13967 let title;
13968
13969 if (needsUniqueIdentifier(postType)) {
13970 title = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book".
13971 (0,external_wp_i18n_namespaceObject.__)('Archive: %1$s (%2$s)'), postType.labels.singular_name, postType.slug);
13972 } else {
13973 title = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of the post type e.g: "Post".
13974 (0,external_wp_i18n_namespaceObject.__)('Archive: %s'), postType.labels.singular_name);
13975 }
13976
13977 return {
13978 slug: 'archive-' + postType.slug,
13979 description: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of the post type e.g: "Post".
13980 (0,external_wp_i18n_namespaceObject.__)('Displays an archive with the latests posts of type: %s.'), postType.labels.singular_name),
13981 title,
13982 // `icon` is the `menu_icon` property of a post type. We
13983 // only handle `dashicons` for now, even if the `menu_icon`
13984 // also supports urls and svg as values.
13985 icon: (_postType$icon = postType.icon) !== null && _postType$icon !== void 0 && _postType$icon.startsWith('dashicons-') ? postType.icon.slice(10) : library_archive,
13986 templatePrefix: 'archive'
13987 };
13988 })) || [], [postTypesWithArchives, existingTemplates, needsUniqueIdentifier]);
13989 }
13990 const usePostTypeMenuItems = onClickMenuItem => {
13991 const publicPostTypes = usePublicPostTypes();
13992 const existingTemplates = useExistingTemplates();
13993 const defaultTemplateTypes = useDefaultTemplateTypes();
13994 const needsUniqueIdentifier = usePostTypeNeedsUniqueIdentifier(publicPostTypes); // `page`is a special case in template hierarchy.
13995
13996 const templatePrefixes = (0,external_wp_element_namespaceObject.useMemo)(() => publicPostTypes === null || publicPostTypes === void 0 ? void 0 : publicPostTypes.reduce((accumulator, _ref5) => {
13997 let {
13998 slug
13999 } = _ref5;
14000 let suffix = slug;
14001
14002 if (slug !== 'page') {
14003 suffix = `single-${suffix}`;
14004 }
14005
14006 accumulator[slug] = suffix;
14007 return accumulator;
14008 }, {}), [publicPostTypes]);
14009 const postTypesInfo = useEntitiesInfo('postType', templatePrefixes);
14010 const existingTemplateSlugs = (existingTemplates || []).map(_ref6 => {
14011 let {
14012 slug
14013 } = _ref6;
14014 return slug;
14015 });
14016 const menuItems = (publicPostTypes || []).reduce((accumulator, postType) => {
14017 var _postTypesInfo$slug;
14018
14019 const {
14020 slug,
14021 labels,
14022 icon
14023 } = postType; // We need to check if the general template is part of the
14024 // defaultTemplateTypes. If it is, just use that info and
14025 // augment it with the specific template functionality.
14026
14027 const generalTemplateSlug = templatePrefixes[slug];
14028 const defaultTemplateType = defaultTemplateTypes === null || defaultTemplateTypes === void 0 ? void 0 : defaultTemplateTypes.find(_ref7 => {
14029 let {
14030 slug: _slug
14031 } = _ref7;
14032 return _slug === generalTemplateSlug;
14033 });
14034 const hasGeneralTemplate = existingTemplateSlugs === null || existingTemplateSlugs === void 0 ? void 0 : existingTemplateSlugs.includes(generalTemplateSlug);
14035
14036 const _needsUniqueIdentifier = needsUniqueIdentifier(postType);
14037
14038 let menuItemTitle = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of the post type e.g: "Post".
14039 (0,external_wp_i18n_namespaceObject.__)('Single item: %s'), labels.singular_name);
14040
14041 if (_needsUniqueIdentifier) {
14042 menuItemTitle = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book".
14043 (0,external_wp_i18n_namespaceObject.__)('Single item: %1$s (%2$s)'), labels.singular_name, slug);
14044 }
14045
14046 const menuItem = defaultTemplateType ? { ...defaultTemplateType,
14047 templatePrefix: templatePrefixes[slug]
14048 } : {
14049 slug: generalTemplateSlug,
14050 title: menuItemTitle,
14051 description: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of the post type e.g: "Post".
14052 (0,external_wp_i18n_namespaceObject.__)('Displays a single item: %s.'), labels.singular_name),
14053 // `icon` is the `menu_icon` property of a post type. We
14054 // only handle `dashicons` for now, even if the `menu_icon`
14055 // also supports urls and svg as values.
14056 icon: icon !== null && icon !== void 0 && icon.startsWith('dashicons-') ? icon.slice(10) : library_post,
14057 templatePrefix: templatePrefixes[slug]
14058 };
14059 const hasEntities = postTypesInfo === null || postTypesInfo === void 0 ? void 0 : (_postTypesInfo$slug = postTypesInfo[slug]) === null || _postTypesInfo$slug === void 0 ? void 0 : _postTypesInfo$slug.hasEntities; // We have a different template creation flow only if they have entities.
14060
14061 if (hasEntities) {
14062 menuItem.onClick = template => {
14063 onClickMenuItem({
14064 type: 'postType',
14065 slug,
14066 config: {
14067 recordNamePath: 'title.rendered',
14068 queryArgs: _ref8 => {
14069 let {
14070 search
14071 } = _ref8;
14072 return {
14073 _fields: 'id,title,slug,link',
14074 orderBy: search ? 'relevance' : 'modified',
14075 exclude: postTypesInfo[slug].existingEntitiesIds
14076 };
14077 },
14078 getSpecificTemplate: suggestion => {
14079 const templateSlug = `${templatePrefixes[slug]}-${suggestion.slug}`;
14080 return {
14081 title: templateSlug,
14082 slug: templateSlug,
14083 templatePrefix: templatePrefixes[slug]
14084 };
14085 }
14086 },
14087 labels,
14088 hasGeneralTemplate,
14089 template
14090 });
14091 };
14092 } // We don't need to add the menu item if there are no
14093 // entities and the general template exists.
14094
14095
14096 if (!hasGeneralTemplate || hasEntities) {
14097 accumulator.push(menuItem);
14098 }
14099
14100 return accumulator;
14101 }, []); // Split menu items into two groups: one for the default post types
14102 // and one for the rest.
14103
14104 const postTypesMenuItems = (0,external_wp_element_namespaceObject.useMemo)(() => menuItems.reduce((accumulator, postType) => {
14105 const {
14106 slug
14107 } = postType;
14108 let key = 'postTypesMenuItems';
14109
14110 if (slug === 'page') {
14111 key = 'defaultPostTypesMenuItems';
14112 }
14113
14114 accumulator[key].push(postType);
14115 return accumulator;
14116 }, {
14117 defaultPostTypesMenuItems: [],
14118 postTypesMenuItems: []
14119 }), [menuItems]);
14120 return postTypesMenuItems;
14121 };
14122 const useTaxonomiesMenuItems = onClickMenuItem => {
14123 const publicTaxonomies = usePublicTaxonomies();
14124 const existingTemplates = useExistingTemplates();
14125 const defaultTemplateTypes = useDefaultTemplateTypes(); // `category` and `post_tag` are special cases in template hierarchy.
14126
14127 const templatePrefixes = (0,external_wp_element_namespaceObject.useMemo)(() => publicTaxonomies === null || publicTaxonomies === void 0 ? void 0 : publicTaxonomies.reduce((accumulator, _ref9) => {
14128 let {
14129 slug
14130 } = _ref9;
14131 let suffix = slug;
14132
14133 if (!['category', 'post_tag'].includes(slug)) {
14134 suffix = `taxonomy-${suffix}`;
14135 }
14136
14137 if (slug === 'post_tag') {
14138 suffix = `tag`;
14139 }
14140
14141 accumulator[slug] = suffix;
14142 return accumulator;
14143 }, {}), [publicTaxonomies]); // We need to keep track of naming conflicts. If a conflict
14144 // occurs, we need to add slug.
14145
14146 const taxonomyLabels = publicTaxonomies === null || publicTaxonomies === void 0 ? void 0 : publicTaxonomies.reduce((accumulator, _ref10) => {
14147 let {
14148 labels
14149 } = _ref10;
14150 const singularName = labels.singular_name.toLowerCase();
14151 accumulator[singularName] = (accumulator[singularName] || 0) + 1;
14152 return accumulator;
14153 }, {});
14154
14155 const needsUniqueIdentifier = (labels, slug) => {
14156 if (['category', 'post_tag'].includes(slug)) {
14157 return false;
14158 }
14159
14160 const singularName = labels.singular_name.toLowerCase();
14161 return taxonomyLabels[singularName] > 1 && singularName !== slug;
14162 };
14163
14164 const taxonomiesInfo = useEntitiesInfo('taxonomy', templatePrefixes);
14165 const existingTemplateSlugs = (existingTemplates || []).map(_ref11 => {
14166 let {
14167 slug
14168 } = _ref11;
14169 return slug;
14170 });
14171 const menuItems = (publicTaxonomies || []).reduce((accumulator, taxonomy) => {
14172 var _taxonomiesInfo$slug;
14173
14174 const {
14175 slug,
14176 labels
14177 } = taxonomy; // We need to check if the general template is part of the
14178 // defaultTemplateTypes. If it is, just use that info and
14179 // augment it with the specific template functionality.
14180
14181 const generalTemplateSlug = templatePrefixes[slug];
14182 const defaultTemplateType = defaultTemplateTypes === null || defaultTemplateTypes === void 0 ? void 0 : defaultTemplateTypes.find(_ref12 => {
14183 let {
14184 slug: _slug
14185 } = _ref12;
14186 return _slug === generalTemplateSlug;
14187 });
14188 const hasGeneralTemplate = existingTemplateSlugs === null || existingTemplateSlugs === void 0 ? void 0 : existingTemplateSlugs.includes(generalTemplateSlug);
14189
14190 const _needsUniqueIdentifier = needsUniqueIdentifier(labels, slug);
14191
14192 let menuItemTitle = labels.singular_name;
14193
14194 if (_needsUniqueIdentifier) {
14195 menuItemTitle = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %1s: Name of the taxonomy e.g: "Category"; %2s: Slug of the taxonomy e.g: "product_cat".
14196 (0,external_wp_i18n_namespaceObject.__)('%1$s (%2$s)'), labels.singular_name, slug);
14197 }
14198
14199 const menuItem = defaultTemplateType ? { ...defaultTemplateType,
14200 templatePrefix: templatePrefixes[slug]
14201 } : {
14202 slug: generalTemplateSlug,
14203 title: menuItemTitle,
14204 description: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of the taxonomy e.g: "Product Categories".
14205 (0,external_wp_i18n_namespaceObject.__)('Displays taxonomy: %s.'), labels.singular_name),
14206 icon: block_meta,
14207 templatePrefix: templatePrefixes[slug]
14208 };
14209 const hasEntities = taxonomiesInfo === null || taxonomiesInfo === void 0 ? void 0 : (_taxonomiesInfo$slug = taxonomiesInfo[slug]) === null || _taxonomiesInfo$slug === void 0 ? void 0 : _taxonomiesInfo$slug.hasEntities; // We have a different template creation flow only if they have entities.
14210
14211 if (hasEntities) {
14212 menuItem.onClick = template => {
14213 onClickMenuItem({
14214 type: 'taxonomy',
14215 slug,
14216 config: {
14217 queryArgs: _ref13 => {
14218 let {
14219 search
14220 } = _ref13;
14221 return {
14222 _fields: 'id,name,slug,link',
14223 orderBy: search ? 'name' : 'count',
14224 exclude: taxonomiesInfo[slug].existingEntitiesIds
14225 };
14226 },
14227 getSpecificTemplate: suggestion => {
14228 const templateSlug = `${templatePrefixes[slug]}-${suggestion.slug}`;
14229 return {
14230 title: templateSlug,
14231 slug: templateSlug,
14232 templatePrefix: templatePrefixes[slug]
14233 };
14234 }
14235 },
14236 labels,
14237 hasGeneralTemplate,
14238 template
14239 });
14240 };
14241 } // We don't need to add the menu item if there are no
14242 // entities and the general template exists.
14243
14244
14245 if (!hasGeneralTemplate || hasEntities) {
14246 accumulator.push(menuItem);
14247 }
14248
14249 return accumulator;
14250 }, []); // Split menu items into two groups: one for the default taxonomies
14251 // and one for the rest.
14252
14253 const taxonomiesMenuItems = (0,external_wp_element_namespaceObject.useMemo)(() => menuItems.reduce((accumulator, taxonomy) => {
14254 const {
14255 slug
14256 } = taxonomy;
14257 let key = 'taxonomiesMenuItems';
14258
14259 if (['category', 'tag'].includes(slug)) {
14260 key = 'defaultTaxonomiesMenuItems';
14261 }
14262
14263 accumulator[key].push(taxonomy);
14264 return accumulator;
14265 }, {
14266 defaultTaxonomiesMenuItems: [],
14267 taxonomiesMenuItems: []
14268 }), [menuItems]);
14269 return taxonomiesMenuItems;
14270 };
14271 const USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = {
14272 user: 'author'
14273 };
14274 const USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = {
14275 user: {
14276 who: 'authors'
14277 }
14278 };
14279 function useAuthorMenuItem(onClickMenuItem) {
14280 var _authorInfo$user, _authorInfo$user2;
14281
14282 const existingTemplates = useExistingTemplates();
14283 const defaultTemplateTypes = useDefaultTemplateTypes();
14284 const authorInfo = useEntitiesInfo('root', USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX, USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS);
14285 let authorMenuItem = defaultTemplateTypes === null || defaultTemplateTypes === void 0 ? void 0 : defaultTemplateTypes.find(_ref14 => {
14286 let {
14287 slug
14288 } = _ref14;
14289 return slug === 'author';
14290 });
14291
14292 if (!authorMenuItem) {
14293 authorMenuItem = {
14294 description: (0,external_wp_i18n_namespaceObject.__)('Displays latest posts written by a single author.'),
14295 slug: 'author',
14296 title: 'Author'
14297 };
14298 }
14299
14300 const hasGeneralTemplate = !!(existingTemplates !== null && existingTemplates !== void 0 && existingTemplates.find(_ref15 => {
14301 let {
14302 slug
14303 } = _ref15;
14304 return slug === 'author';
14305 }));
14306
14307 if ((_authorInfo$user = authorInfo.user) !== null && _authorInfo$user !== void 0 && _authorInfo$user.hasEntities) {
14308 authorMenuItem = { ...authorMenuItem,
14309 templatePrefix: 'author'
14310 };
14311
14312 authorMenuItem.onClick = template => {
14313 onClickMenuItem({
14314 type: 'root',
14315 slug: 'user',
14316 config: {
14317 queryArgs: _ref16 => {
14318 let {
14319 search
14320 } = _ref16;
14321 return {
14322 _fields: 'id,name,slug,link',
14323 orderBy: search ? 'name' : 'registered_date',
14324 exclude: authorInfo.user.existingEntitiesIds,
14325 who: 'authors'
14326 };
14327 },
14328 getSpecificTemplate: suggestion => {
14329 const templateSlug = `author-${suggestion.slug}`;
14330 return {
14331 title: templateSlug,
14332 slug: templateSlug,
14333 templatePrefix: 'author'
14334 };
14335 }
14336 },
14337 labels: {
14338 singular_name: (0,external_wp_i18n_namespaceObject.__)('Author'),
14339 search_items: (0,external_wp_i18n_namespaceObject.__)('Search Authors'),
14340 not_found: (0,external_wp_i18n_namespaceObject.__)('No authors found.'),
14341 all_items: (0,external_wp_i18n_namespaceObject.__)('All Authors')
14342 },
14343 hasGeneralTemplate,
14344 template
14345 });
14346 };
14347 }
14348
14349 if (!hasGeneralTemplate || (_authorInfo$user2 = authorInfo.user) !== null && _authorInfo$user2 !== void 0 && _authorInfo$user2.hasEntities) {
14350 return authorMenuItem;
14351 }
14352 }
14353 /**
14354 * Helper hook that filters all the existing templates by the given
14355 * object with the entity's slug as key and the template prefix as value.
14356 *
14357 * Example:
14358 * `existingTemplates` is: [ { slug: 'tag-apple' }, { slug: 'page-about' }, { slug: 'tag' } ]
14359 * `templatePrefixes` is: { post_tag: 'tag' }
14360 * It will return: { post_tag: ['apple'] }
14361 *
14362 * Note: We append the `-` to the given template prefix in this function for our checks.
14363 *
14364 * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.
14365 * @return {Record<string,string[]>} An object with the entity's slug as key and an array with the existing template slugs as value.
14366 */
14367
14368 const useExistingTemplateSlugs = templatePrefixes => {
14369 const existingTemplates = useExistingTemplates();
14370 const existingSlugs = (0,external_wp_element_namespaceObject.useMemo)(() => {
14371 return Object.entries(templatePrefixes || {}).reduce((accumulator, _ref17) => {
14372 let [slug, prefix] = _ref17;
14373 const slugsWithTemplates = (existingTemplates || []).reduce((_accumulator, existingTemplate) => {
14374 const _prefix = `${prefix}-`;
14375
14376 if (existingTemplate.slug.startsWith(_prefix)) {
14377 _accumulator.push(existingTemplate.slug.substring(_prefix.length));
14378 }
14379
14380 return _accumulator;
14381 }, []);
14382
14383 if (slugsWithTemplates.length) {
14384 accumulator[slug] = slugsWithTemplates;
14385 }
14386
14387 return accumulator;
14388 }, {});
14389 }, [templatePrefixes, existingTemplates]);
14390 return existingSlugs;
14391 };
14392 /**
14393 * Helper hook that finds the existing records with an associated template,
14394 * as they need to be excluded from the template suggestions.
14395 *
14396 * @param {string} entityName The entity's name.
14397 * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.
14398 * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.
14399 * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the existing records as value.
14400 */
14401
14402
14403 const useTemplatesToExclude = function (entityName, templatePrefixes) {
14404 let additionalQueryParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
14405 const slugsToExcludePerEntity = useExistingTemplateSlugs(templatePrefixes);
14406 const recordsToExcludePerEntity = (0,external_wp_data_namespaceObject.useSelect)(select => {
14407 return Object.entries(slugsToExcludePerEntity || {}).reduce((accumulator, _ref18) => {
14408 let [slug, slugsWithTemplates] = _ref18;
14409 const entitiesWithTemplates = select(external_wp_coreData_namespaceObject.store).getEntityRecords(entityName, slug, {
14410 _fields: 'id',
14411 context: 'view',
14412 slug: slugsWithTemplates,
14413 ...additionalQueryParameters[slug]
14414 });
14415
14416 if (entitiesWithTemplates !== null && entitiesWithTemplates !== void 0 && entitiesWithTemplates.length) {
14417 accumulator[slug] = entitiesWithTemplates;
14418 }
14419
14420 return accumulator;
14421 }, {});
14422 }, [slugsToExcludePerEntity]);
14423 return recordsToExcludePerEntity;
14424 };
14425 /**
14426 * Helper hook that returns information about an entity having
14427 * records that we can create a specific template for.
14428 *
14429 * For example we can search for `terms` in `taxonomy` entity or
14430 * `posts` in `postType` entity.
14431 *
14432 * First we need to find the existing records with an associated template,
14433 * to query afterwards for any remaining record, by excluding them.
14434 *
14435 * @param {string} entityName The entity's name.
14436 * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.
14437 * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.
14438 * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.
14439 */
14440
14441
14442 const useEntitiesInfo = function (entityName, templatePrefixes) {
14443 let additionalQueryParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
14444 const recordsToExcludePerEntity = useTemplatesToExclude(entityName, templatePrefixes, additionalQueryParameters);
14445 const entitiesInfo = (0,external_wp_data_namespaceObject.useSelect)(select => {
14446 return Object.keys(templatePrefixes || {}).reduce((accumulator, slug) => {
14447 var _recordsToExcludePerE, _select$getEntityReco;
14448
14449 const existingEntitiesIds = (recordsToExcludePerEntity === null || recordsToExcludePerEntity === void 0 ? void 0 : (_recordsToExcludePerE = recordsToExcludePerEntity[slug]) === null || _recordsToExcludePerE === void 0 ? void 0 : _recordsToExcludePerE.map(_ref19 => {
14450 let {
14451 id
14452 } = _ref19;
14453 return id;
14454 })) || [];
14455 accumulator[slug] = {
14456 hasEntities: !!((_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecords(entityName, slug, {
14457 per_page: 1,
14458 _fields: 'id',
14459 context: 'view',
14460 exclude: existingEntitiesIds,
14461 ...additionalQueryParameters[slug]
14462 })) !== null && _select$getEntityReco !== void 0 && _select$getEntityReco.length),
14463 existingEntitiesIds
14464 };
14465 return accumulator;
14466 }, {});
14467 }, [templatePrefixes, recordsToExcludePerEntity]);
14468 return entitiesInfo;
14469 };
14470
14471 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/add-custom-template-modal.js
14472
14473
14474
14475 /**
14476 * WordPress dependencies
14477 */
14478
14479
14480
14481
14482
14483
14484 /**
14485 * Internal dependencies
14486 */
14487
14488
14489
14490 const EMPTY_ARRAY = [];
14491
14492 function SuggestionListItem(_ref) {
14493 let {
14494 suggestion,
14495 search,
14496 onSelect,
14497 entityForSuggestions,
14498 composite
14499 } = _ref;
14500 const baseCssClass = 'edit-site-custom-template-modal__suggestions_list__list-item';
14501 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, extends_extends({
14502 role: "option",
14503 as: external_wp_components_namespaceObject.Button
14504 }, composite, {
14505 className: baseCssClass,
14506 onClick: () => onSelect(entityForSuggestions.config.getSpecificTemplate(suggestion))
14507 }), (0,external_wp_element_namespaceObject.createElement)("span", {
14508 className: `${baseCssClass}__title`
14509 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextHighlight, {
14510 text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(suggestion.name),
14511 highlight: search
14512 })), suggestion.link && (0,external_wp_element_namespaceObject.createElement)("span", {
14513 className: `${baseCssClass}__info`
14514 }, suggestion.link));
14515 }
14516
14517 function useDebouncedInput() {
14518 const [input, setInput] = (0,external_wp_element_namespaceObject.useState)('');
14519 const [debounced, setter] = (0,external_wp_element_namespaceObject.useState)('');
14520 const setDebounced = (0,external_wp_compose_namespaceObject.useDebounce)(setter, 250);
14521 (0,external_wp_element_namespaceObject.useEffect)(() => {
14522 if (debounced !== input) {
14523 setDebounced(input);
14524 }
14525 }, [debounced, input]);
14526 return [input, setInput, debounced];
14527 }
14528
14529 function useSearchSuggestions(entityForSuggestions, search) {
14530 const {
14531 config
14532 } = entityForSuggestions;
14533 const query = (0,external_wp_element_namespaceObject.useMemo)(() => ({
14534 order: 'asc',
14535 context: 'view',
14536 search,
14537 per_page: search ? 20 : 10,
14538 ...config.queryArgs(search)
14539 }), [search, config]);
14540 const {
14541 records: searchResults,
14542 hasResolved: searchHasResolved
14543 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)(entityForSuggestions.type, entityForSuggestions.slug, query);
14544 const [suggestions, setSuggestions] = (0,external_wp_element_namespaceObject.useState)(EMPTY_ARRAY);
14545 (0,external_wp_element_namespaceObject.useEffect)(() => {
14546 if (!searchHasResolved) return;
14547 let newSuggestions = EMPTY_ARRAY;
14548
14549 if (searchResults !== null && searchResults !== void 0 && searchResults.length) {
14550 newSuggestions = searchResults;
14551
14552 if (config.recordNamePath) {
14553 newSuggestions = mapToIHasNameAndId(newSuggestions, config.recordNamePath);
14554 }
14555 } // Update suggestions only when the query has resolved, so as to keep
14556 // the previous results in the UI.
14557
14558
14559 setSuggestions(newSuggestions);
14560 }, [searchResults, searchHasResolved]);
14561 return suggestions;
14562 }
14563
14564 function SuggestionList(_ref2) {
14565 let {
14566 entityForSuggestions,
14567 onSelect
14568 } = _ref2;
14569 const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({
14570 orientation: 'vertical'
14571 });
14572 const [search, setSearch, debouncedSearch] = useDebouncedInput();
14573 const suggestions = useSearchSuggestions(entityForSuggestions, debouncedSearch);
14574 const {
14575 labels
14576 } = entityForSuggestions;
14577 const [showSearchControl, setShowSearchControl] = (0,external_wp_element_namespaceObject.useState)(false);
14578
14579 if (!showSearchControl && (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 9) {
14580 setShowSearchControl(true);
14581 }
14582
14583 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, showSearchControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
14584 __nextHasNoMarginBottom: true,
14585 onChange: setSearch,
14586 value: search,
14587 label: labels.search_items,
14588 placeholder: labels.search_items
14589 }), !!(suggestions !== null && suggestions !== void 0 && suggestions.length) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, extends_extends({}, composite, {
14590 role: "listbox",
14591 className: "edit-site-custom-template-modal__suggestions_list",
14592 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Suggestions list')
14593 }), suggestions.map(suggestion => (0,external_wp_element_namespaceObject.createElement)(SuggestionListItem, {
14594 key: suggestion.slug,
14595 suggestion: suggestion,
14596 search: debouncedSearch,
14597 onSelect: onSelect,
14598 entityForSuggestions: entityForSuggestions,
14599 composite: composite
14600 }))), debouncedSearch && !(suggestions !== null && suggestions !== void 0 && suggestions.length) && (0,external_wp_element_namespaceObject.createElement)("p", {
14601 className: "edit-site-custom-template-modal__no-results"
14602 }, labels.not_found));
14603 }
14604
14605 function AddCustomTemplateModal(_ref3) {
14606 let {
14607 onClose,
14608 onSelect,
14609 entityForSuggestions,
14610 isCreatingTemplate
14611 } = _ref3;
14612 const [showSearchEntities, setShowSearchEntities] = (0,external_wp_element_namespaceObject.useState)(entityForSuggestions.hasGeneralTemplate);
14613 const baseCssClass = 'edit-site-custom-template-modal';
14614 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
14615 title: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of the post type e.g: "Post".
14616 (0,external_wp_i18n_namespaceObject.__)('Add template: %s'), entityForSuggestions.labels.singular_name),
14617 className: baseCssClass,
14618 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
14619 onRequestClose: onClose
14620 }, isCreatingTemplate && (0,external_wp_element_namespaceObject.createElement)(TemplateActionsLoadingScreen, null), !showSearchEntities && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Select whether to create a single template for all items or a specific one.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
14621 className: `${baseCssClass}__contents`,
14622 gap: "4",
14623 align: "initial"
14624 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
14625 isBlock: true,
14626 as: external_wp_components_namespaceObject.Button,
14627 onClick: () => {
14628 const {
14629 slug,
14630 title,
14631 description,
14632 templatePrefix
14633 } = entityForSuggestions.template;
14634 onSelect({
14635 slug,
14636 title,
14637 description,
14638 templatePrefix
14639 });
14640 }
14641 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
14642 as: "span",
14643 weight: 600
14644 }, entityForSuggestions.labels.all_items), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
14645 as: "span"
14646 }, // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.
14647 (0,external_wp_i18n_namespaceObject.__)('For all items'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
14648 isBlock: true,
14649 as: external_wp_components_namespaceObject.Button,
14650 onClick: () => {
14651 setShowSearchEntities(true);
14652 }
14653 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
14654 as: "span",
14655 weight: 600
14656 }, entityForSuggestions.labels.singular_name), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
14657 as: "span"
14658 }, // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.
14659 (0,external_wp_i18n_namespaceObject.__)('For a specific item'))))), showSearchEntities && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('This template will be used only for the specific item chosen.')), (0,external_wp_element_namespaceObject.createElement)(SuggestionList, {
14660 entityForSuggestions: entityForSuggestions,
14661 onSelect: onSelect
14662 })));
14663 }
14664
14665 /* harmony default export */ var add_custom_template_modal = (AddCustomTemplateModal);
14666
14667 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/add-custom-generic-template-modal.js
14668
14669
14670 /**
14671 * External dependencies
14672 */
14673
14674 /**
14675 * WordPress dependencies
14676 */
14677
14678
14679
14680
14681 /**
14682 * Internal dependencies
14683 */
14684
14685
14686
14687 function AddCustomGenericTemplateModal(_ref) {
14688 let {
14689 onClose,
14690 createTemplate,
14691 isCreatingTemplate
14692 } = _ref;
14693 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
14694
14695 const defaultTitle = (0,external_wp_i18n_namespaceObject.__)('Custom Template');
14696
14697 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
14698
14699 async function onCreateTemplate(event) {
14700 event.preventDefault();
14701
14702 if (isBusy) {
14703 return;
14704 }
14705
14706 setIsBusy(true);
14707
14708 try {
14709 await createTemplate({
14710 slug: 'wp-custom-template-' + (0,external_lodash_namespaceObject.kebabCase)(title || defaultTitle),
14711 title: title || defaultTitle
14712 }, false);
14713 } finally {
14714 setIsBusy(false);
14715 }
14716 }
14717
14718 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
14719 title: (0,external_wp_i18n_namespaceObject.__)('Create custom template'),
14720 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
14721 onRequestClose: () => {
14722 onClose();
14723 },
14724 overlayClassName: "edit-site-custom-generic-template__modal"
14725 }, isCreatingTemplate && (0,external_wp_element_namespaceObject.createElement)(TemplateActionsLoadingScreen, null), (0,external_wp_element_namespaceObject.createElement)("form", {
14726 onSubmit: onCreateTemplate
14727 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
14728 align: "flex-start",
14729 gap: 8
14730 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
14731 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
14732 value: title,
14733 onChange: setTitle,
14734 placeholder: defaultTitle,
14735 disabled: isBusy,
14736 help: (0,external_wp_i18n_namespaceObject.__)('Describe the template, e.g. "Post with sidebar".')
14737 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
14738 className: "edit-site-custom-generic-template__modal-actions",
14739 justify: "flex-end",
14740 expanded: false
14741 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
14742 variant: "tertiary",
14743 onClick: () => {
14744 onClose();
14745 }
14746 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
14747 variant: "primary",
14748 type: "submit",
14749 isBusy: isBusy,
14750 "aria-disabled": isBusy
14751 }, (0,external_wp_i18n_namespaceObject.__)('Create'))))));
14752 }
14753
14754 /* harmony default export */ var add_custom_generic_template_modal = (AddCustomGenericTemplateModal);
14755
14756 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/new-template.js
14757
14758
14759 /**
14760 * WordPress dependencies
14761 */
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771 /**
14772 * Internal dependencies
14773 */
14774
14775
14776
14777
14778
14779
14780
14781 const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'single', 'page', 'index', 'archive', 'author', 'category', 'date', 'tag', 'taxonomy', 'search', '404'];
14782 const TEMPLATE_ICONS = {
14783 'front-page': library_home,
14784 single: library_post,
14785 page: library_page,
14786 archive: library_archive,
14787 search: library_search,
14788 404: not_found,
14789 index: library_list,
14790 category: library_category,
14791 author: post_author,
14792 taxonomy: block_meta,
14793 date: post_date,
14794 tag: library_tag,
14795 attachment: library_media
14796 };
14797 function NewTemplate(_ref) {
14798 let {
14799 postType
14800 } = _ref;
14801 const [showCustomTemplateModal, setShowCustomTemplateModal] = (0,external_wp_element_namespaceObject.useState)(false);
14802 const [showCustomGenericTemplateModal, setShowCustomGenericTemplateModal] = (0,external_wp_element_namespaceObject.useState)(false);
14803 const [entityForSuggestions, setEntityForSuggestions] = (0,external_wp_element_namespaceObject.useState)({});
14804 const [isCreatingTemplate, setIsCreatingTemplate] = (0,external_wp_element_namespaceObject.useState)(false);
14805 const history = useHistory();
14806 const {
14807 saveEntityRecord
14808 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
14809 const {
14810 createErrorNotice,
14811 createSuccessNotice
14812 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
14813 const {
14814 setTemplate
14815 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14816
14817 async function createTemplate(template) {
14818 let isWPSuggestion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
14819
14820 if (isCreatingTemplate) {
14821 return;
14822 }
14823
14824 setIsCreatingTemplate(true);
14825
14826 try {
14827 const {
14828 title,
14829 description,
14830 slug,
14831 templatePrefix
14832 } = template;
14833 let templateContent = template.content; // Try to find fallback content from existing templates.
14834
14835 if (!templateContent) {
14836 const fallbackTemplate = await external_wp_apiFetch_default()({
14837 path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/templates/lookup', {
14838 slug,
14839 is_custom: !isWPSuggestion,
14840 template_prefix: templatePrefix
14841 })
14842 });
14843 templateContent = fallbackTemplate.content.raw;
14844 }
14845
14846 const newTemplate = await saveEntityRecord('postType', 'wp_template', {
14847 description,
14848 // Slugs need to be strings, so this is for template `404`
14849 slug: slug.toString(),
14850 status: 'publish',
14851 title,
14852 content: templateContent,
14853 // This adds a post meta field in template that is part of `is_custom` value calculation.
14854 is_wp_suggestion: isWPSuggestion
14855 }, {
14856 throwOnError: true
14857 }); // Set template before navigating away to avoid initial stale value.
14858
14859 setTemplate(newTemplate.id, newTemplate.slug); // Navigate to the created template editor.
14860
14861 history.push({
14862 postId: newTemplate.id,
14863 postType: newTemplate.type
14864 });
14865 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Title of the created template e.g: "Category".
14866 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), title), {
14867 type: 'snackbar'
14868 });
14869 } catch (error) {
14870 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template.');
14871 createErrorNotice(errorMessage, {
14872 type: 'snackbar'
14873 });
14874 } finally {
14875 setIsCreatingTemplate(false);
14876 }
14877 }
14878
14879 const missingTemplates = useMissingTemplates(setEntityForSuggestions, setShowCustomTemplateModal);
14880
14881 if (!missingTemplates.length) {
14882 return null;
14883 }
14884
14885 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
14886 className: "edit-site-new-template-dropdown",
14887 icon: null,
14888 text: postType.labels.add_new,
14889 label: postType.labels.add_new_item,
14890 popoverProps: {
14891 noArrow: false
14892 },
14893 toggleProps: {
14894 variant: 'primary'
14895 }
14896 }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isCreatingTemplate && (0,external_wp_element_namespaceObject.createElement)(TemplateActionsLoadingScreen, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, {
14897 className: "edit-site-new-template-dropdown__popover"
14898 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
14899 label: postType.labels.add_new_item
14900 }, missingTemplates.map(template => {
14901 const {
14902 title,
14903 description,
14904 slug,
14905 onClick,
14906 icon
14907 } = template;
14908 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
14909 icon: icon || TEMPLATE_ICONS[slug] || library_post,
14910 iconPosition: "left",
14911 info: description,
14912 key: slug,
14913 onClick: () => onClick ? onClick(template) : createTemplate(template)
14914 }, title);
14915 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
14916 icon: library_layout,
14917 iconPosition: "left",
14918 info: (0,external_wp_i18n_namespaceObject.__)('Custom templates can be applied to any post or page.'),
14919 key: "custom-template",
14920 onClick: () => setShowCustomGenericTemplateModal(true)
14921 }, (0,external_wp_i18n_namespaceObject.__)('Custom template')))))), showCustomTemplateModal && (0,external_wp_element_namespaceObject.createElement)(add_custom_template_modal, {
14922 onClose: () => setShowCustomTemplateModal(false),
14923 onSelect: createTemplate,
14924 entityForSuggestions: entityForSuggestions,
14925 isCreatingTemplate: isCreatingTemplate
14926 }), showCustomGenericTemplateModal && (0,external_wp_element_namespaceObject.createElement)(add_custom_generic_template_modal, {
14927 onClose: () => setShowCustomGenericTemplateModal(false),
14928 createTemplate: createTemplate,
14929 isCreatingTemplate: isCreatingTemplate
14930 }));
14931 }
14932
14933 function useMissingTemplates(setEntityForSuggestions, setShowCustomTemplateModal) {
14934 const existingTemplates = useExistingTemplates();
14935 const defaultTemplateTypes = useDefaultTemplateTypes();
14936 const existingTemplateSlugs = (existingTemplates || []).map(_ref2 => {
14937 let {
14938 slug
14939 } = _ref2;
14940 return slug;
14941 });
14942 const missingDefaultTemplates = (defaultTemplateTypes || []).filter(template => DEFAULT_TEMPLATE_SLUGS.includes(template.slug) && !existingTemplateSlugs.includes(template.slug));
14943
14944 const onClickMenuItem = _entityForSuggestions => {
14945 setShowCustomTemplateModal(true);
14946 setEntityForSuggestions(_entityForSuggestions);
14947 }; // We need to replace existing default template types with
14948 // the create specific template functionality. The original
14949 // info (title, description, etc.) is preserved in the
14950 // used hooks.
14951
14952
14953 const enhancedMissingDefaultTemplateTypes = [...missingDefaultTemplates];
14954 const {
14955 defaultTaxonomiesMenuItems,
14956 taxonomiesMenuItems
14957 } = useTaxonomiesMenuItems(onClickMenuItem);
14958 const {
14959 defaultPostTypesMenuItems,
14960 postTypesMenuItems
14961 } = usePostTypeMenuItems(onClickMenuItem);
14962 const authorMenuItem = useAuthorMenuItem(onClickMenuItem);
14963 [...defaultTaxonomiesMenuItems, ...defaultPostTypesMenuItems, authorMenuItem].forEach(menuItem => {
14964 if (!menuItem) {
14965 return;
14966 }
14967
14968 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(template => template.slug === menuItem.slug); // Some default template types might have been filtered above from
14969 // `missingDefaultTemplates` because they only check for the general
14970 // template. So here we either replace or append the item, augmented
14971 // with the check if it has available specific item to create a
14972 // template for.
14973
14974 if (matchIndex > -1) {
14975 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem;
14976 } else {
14977 enhancedMissingDefaultTemplateTypes.push(menuItem);
14978 }
14979 }); // Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.
14980
14981 enhancedMissingDefaultTemplateTypes === null || enhancedMissingDefaultTemplateTypes === void 0 ? void 0 : enhancedMissingDefaultTemplateTypes.sort((template1, template2) => {
14982 return DEFAULT_TEMPLATE_SLUGS.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS.indexOf(template2.slug);
14983 });
14984 const missingTemplates = [...enhancedMissingDefaultTemplateTypes, ...usePostTypeArchiveMenuItems(), ...postTypesMenuItems, ...taxonomiesMenuItems];
14985 return missingTemplates;
14986 }
14987
14988 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/new-template-part.js
14989
14990
14991 /**
14992 * External dependencies
14993 */
14994
14995 /**
14996 * WordPress dependencies
14997 */
14998
14999
15000
15001
15002
15003
15004
15005 /**
15006 * Internal dependencies
15007 */
15008
15009
15010
15011 function NewTemplatePart(_ref) {
15012 let {
15013 postType
15014 } = _ref;
15015 const history = useHistory();
15016 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
15017 const {
15018 createErrorNotice
15019 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15020 const {
15021 saveEntityRecord
15022 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15023
15024 async function createTemplatePart(_ref2) {
15025 let {
15026 title,
15027 area
15028 } = _ref2;
15029
15030 if (!title) {
15031 createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Title is not defined.'), {
15032 type: 'snackbar'
15033 });
15034 return;
15035 }
15036
15037 try {
15038 // Currently template parts only allow latin chars.
15039 // Fallback slug will receive suffix by default.
15040 const cleanSlug = (0,external_lodash_namespaceObject.kebabCase)(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
15041 const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
15042 slug: cleanSlug,
15043 title,
15044 content: '',
15045 area
15046 }, {
15047 throwOnError: true
15048 });
15049 setIsModalOpen(false); // Navigate to the created template part editor.
15050
15051 history.push({
15052 postId: templatePart.id,
15053 postType: templatePart.type
15054 }); // TODO: Add a success notice?
15055 } catch (error) {
15056 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.');
15057 createErrorNotice(errorMessage, {
15058 type: 'snackbar'
15059 });
15060 setIsModalOpen(false);
15061 }
15062 }
15063
15064 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
15065 variant: "primary",
15066 onClick: () => {
15067 setIsModalOpen(true);
15068 }
15069 }, postType.labels.add_new), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, {
15070 closeModal: () => setIsModalOpen(false),
15071 onCreate: createTemplatePart
15072 }));
15073 }
15074
15075 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/index.js
15076
15077
15078 /**
15079 * WordPress dependencies
15080 */
15081
15082
15083 /**
15084 * Internal dependencies
15085 */
15086
15087
15088
15089 function AddNewTemplate(_ref) {
15090 let {
15091 templateType = 'wp_template'
15092 } = _ref;
15093 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
15094
15095 if (!postType) {
15096 return null;
15097 }
15098
15099 if (templateType === 'wp_template') {
15100 return (0,external_wp_element_namespaceObject.createElement)(NewTemplate, {
15101 postType: postType
15102 });
15103 } else if (templateType === 'wp_template_part') {
15104 return (0,external_wp_element_namespaceObject.createElement)(NewTemplatePart, {
15105 postType: postType
15106 });
15107 }
15108
15109 return null;
15110 }
15111
15112 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/header.js
15113
15114
15115 /**
15116 * WordPress dependencies
15117 */
15118
15119
15120
15121 /**
15122 * Internal dependencies
15123 */
15124
15125
15126
15127 function header_Header(_ref) {
15128 var _postType$labels;
15129
15130 let {
15131 templateType
15132 } = _ref;
15133 const {
15134 canCreate,
15135 postType
15136 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15137 const {
15138 supportsTemplatePartsMode
15139 } = select(store_store).getSettings();
15140 return {
15141 postType: select(external_wp_coreData_namespaceObject.store).getPostType(templateType),
15142 canCreate: !supportsTemplatePartsMode
15143 };
15144 }, [templateType]);
15145
15146 if (!postType) {
15147 return null;
15148 }
15149
15150 return (0,external_wp_element_namespaceObject.createElement)("header", {
15151 className: "edit-site-list-header"
15152 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
15153 level: 1,
15154 className: "edit-site-list-header__title"
15155 }, (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.name), canCreate && (0,external_wp_element_namespaceObject.createElement)("div", {
15156 className: "edit-site-list-header__right"
15157 }, (0,external_wp_element_namespaceObject.createElement)(AddNewTemplate, {
15158 templateType: templateType
15159 })));
15160 }
15161
15162 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/is-template-removable.js
15163 /**
15164 * Check if a template is removable.
15165 *
15166 * @param {Object} template The template entity to check.
15167 * @return {boolean} Whether the template is revertable.
15168 */
15169 function isTemplateRemovable(template) {
15170 if (!template) {
15171 return false;
15172 }
15173
15174 return template.source === 'custom' && !template.has_theme_file;
15175 }
15176
15177 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/actions/rename-menu-item.js
15178
15179
15180 /**
15181 * WordPress dependencies
15182 */
15183
15184
15185
15186
15187
15188
15189 function RenameMenuItem(_ref) {
15190 let {
15191 template,
15192 onClose
15193 } = _ref;
15194 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => template.title.rendered);
15195 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
15196 const {
15197 editEntityRecord,
15198 saveEditedEntityRecord
15199 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15200 const {
15201 createSuccessNotice,
15202 createErrorNotice
15203 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15204
15205 if (!template.is_custom) {
15206 return null;
15207 }
15208
15209 async function onTemplateRename(event) {
15210 event.preventDefault();
15211
15212 try {
15213 await editEntityRecord('postType', template.type, template.id, {
15214 title
15215 }); // Update state before saving rerenders the list.
15216
15217 setTitle('');
15218 setIsModalOpen(false);
15219 onClose(); // Persist edited entity.
15220
15221 await saveEditedEntityRecord('postType', template.type, template.id, {
15222 throwOnError: true
15223 });
15224 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Entity renamed.'), {
15225 type: 'snackbar'
15226 });
15227 } catch (error) {
15228 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the entity.');
15229 createErrorNotice(errorMessage, {
15230 type: 'snackbar'
15231 });
15232 }
15233 }
15234
15235 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
15236 onClick: () => {
15237 setIsModalOpen(true);
15238 setTitle(template.title.rendered);
15239 }
15240 }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
15241 title: (0,external_wp_i18n_namespaceObject.__)('Rename'),
15242 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
15243 onRequestClose: () => {
15244 setIsModalOpen(false);
15245 },
15246 overlayClassName: "edit-site-list__rename-modal"
15247 }, (0,external_wp_element_namespaceObject.createElement)("form", {
15248 onSubmit: onTemplateRename
15249 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
15250 align: "flex-start",
15251 gap: 8
15252 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
15253 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
15254 value: title,
15255 onChange: setTitle,
15256 required: true
15257 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
15258 className: "edit-site-list__rename-modal-actions",
15259 justify: "flex-end",
15260 expanded: false
15261 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
15262 variant: "tertiary",
15263 onClick: () => {
15264 setIsModalOpen(false);
15265 }
15266 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
15267 variant: "primary",
15268 type: "submit"
15269 }, (0,external_wp_i18n_namespaceObject.__)('Save')))))));
15270 }
15271
15272 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/actions/index.js
15273
15274
15275 /**
15276 * WordPress dependencies
15277 */
15278
15279
15280
15281
15282
15283
15284 /**
15285 * Internal dependencies
15286 */
15287
15288
15289
15290
15291
15292 function actions_Actions(_ref) {
15293 let {
15294 template
15295 } = _ref;
15296 const {
15297 removeTemplate,
15298 revertTemplate
15299 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15300 const {
15301 saveEditedEntityRecord
15302 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15303 const {
15304 createSuccessNotice,
15305 createErrorNotice
15306 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15307 const isRemovable = isTemplateRemovable(template);
15308 const isRevertable = isTemplateRevertable(template);
15309
15310 if (!isRemovable && !isRevertable) {
15311 return null;
15312 }
15313
15314 async function revertAndSaveTemplate() {
15315 try {
15316 await revertTemplate(template, {
15317 allowUndo: false
15318 });
15319 await saveEditedEntityRecord('postType', template.type, template.id);
15320 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Entity reverted.'), {
15321 type: 'snackbar'
15322 });
15323 } catch (error) {
15324 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the entity.');
15325 createErrorNotice(errorMessage, {
15326 type: 'snackbar'
15327 });
15328 }
15329 }
15330
15331 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
15332 icon: more_vertical,
15333 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
15334 className: "edit-site-list-table__actions"
15335 }, _ref2 => {
15336 let {
15337 onClose
15338 } = _ref2;
15339 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, isRemovable && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(RenameMenuItem, {
15340 template: template,
15341 onClose: onClose
15342 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
15343 isDestructive: true,
15344 isTertiary: true,
15345 onClick: () => {
15346 removeTemplate(template);
15347 onClose();
15348 }
15349 }, (0,external_wp_i18n_namespaceObject.__)('Delete'))), isRevertable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
15350 info: (0,external_wp_i18n_namespaceObject.__)('Use the template as supplied by the theme.'),
15351 onClick: () => {
15352 revertAndSaveTemplate();
15353 onClose();
15354 }
15355 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations')));
15356 });
15357 }
15358
15359 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plugins.js
15360
15361
15362 /**
15363 * WordPress dependencies
15364 */
15365
15366 const plugins = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
15367 xmlns: "http://www.w3.org/2000/svg",
15368 viewBox: "0 0 24 24"
15369 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
15370 d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"
15371 }));
15372 /* harmony default export */ var library_plugins = (plugins);
15373
15374 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/comment-author-avatar.js
15375
15376
15377 /**
15378 * WordPress dependencies
15379 */
15380
15381 const commentAuthorAvatar = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
15382 xmlns: "http://www.w3.org/2000/svg",
15383 viewBox: "0 0 24 24"
15384 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
15385 fillRule: "evenodd",
15386 d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z",
15387 clipRule: "evenodd"
15388 }));
15389 /* harmony default export */ var comment_author_avatar = (commentAuthorAvatar);
15390
15391 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/globe.js
15392
15393
15394 /**
15395 * WordPress dependencies
15396 */
15397
15398 const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
15399 xmlns: "http://www.w3.org/2000/svg",
15400 viewBox: "0 0 24 24"
15401 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
15402 d: "M12 3.3c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8s-4-8.8-8.8-8.8zm6.5 5.5h-2.6C15.4 7.3 14.8 6 14 5c2 .6 3.6 2 4.5 3.8zm.7 3.2c0 .6-.1 1.2-.2 1.8h-2.9c.1-.6.1-1.2.1-1.8s-.1-1.2-.1-1.8H19c.2.6.2 1.2.2 1.8zM12 18.7c-1-.7-1.8-1.9-2.3-3.5h4.6c-.5 1.6-1.3 2.9-2.3 3.5zm-2.6-4.9c-.1-.6-.1-1.1-.1-1.8 0-.6.1-1.2.1-1.8h5.2c.1.6.1 1.1.1 1.8s-.1 1.2-.1 1.8H9.4zM4.8 12c0-.6.1-1.2.2-1.8h2.9c-.1.6-.1 1.2-.1 1.8 0 .6.1 1.2.1 1.8H5c-.2-.6-.2-1.2-.2-1.8zM12 5.3c1 .7 1.8 1.9 2.3 3.5H9.7c.5-1.6 1.3-2.9 2.3-3.5zM10 5c-.8 1-1.4 2.3-1.8 3.8H5.5C6.4 7 8 5.6 10 5zM5.5 15.3h2.6c.4 1.5 1 2.8 1.8 3.7-1.8-.6-3.5-2-4.4-3.7zM14 19c.8-1 1.4-2.2 1.8-3.7h2.6C17.6 17 16 18.4 14 19z"
15403 }));
15404 /* harmony default export */ var library_globe = (globe);
15405
15406 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/added-by.js
15407
15408
15409 /**
15410 * External dependencies
15411 */
15412
15413 /**
15414 * WordPress dependencies
15415 */
15416
15417
15418
15419
15420
15421
15422
15423 const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
15424
15425 function CustomizedTooltip(_ref) {
15426 let {
15427 isCustomized,
15428 children
15429 } = _ref;
15430
15431 if (!isCustomized) {
15432 return children;
15433 }
15434
15435 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
15436 text: (0,external_wp_i18n_namespaceObject.__)('This template has been customized')
15437 }, children);
15438 }
15439
15440 function BaseAddedBy(_ref2) {
15441 let {
15442 text,
15443 icon,
15444 imageUrl,
15445 isCustomized
15446 } = _ref2;
15447 const [isImageLoaded, setIsImageLoaded] = (0,external_wp_element_namespaceObject.useState)(false);
15448 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
15449 alignment: "left"
15450 }, (0,external_wp_element_namespaceObject.createElement)(CustomizedTooltip, {
15451 isCustomized: isCustomized
15452 }, imageUrl ? (0,external_wp_element_namespaceObject.createElement)("div", {
15453 className: classnames_default()('edit-site-list-added-by__avatar', {
15454 'is-loaded': isImageLoaded
15455 })
15456 }, (0,external_wp_element_namespaceObject.createElement)("img", {
15457 onLoad: () => setIsImageLoaded(true),
15458 alt: "",
15459 src: imageUrl
15460 })) : (0,external_wp_element_namespaceObject.createElement)("div", {
15461 className: classnames_default()('edit-site-list-added-by__icon', {
15462 'is-customized': isCustomized
15463 })
15464 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
15465 icon: icon
15466 }))), (0,external_wp_element_namespaceObject.createElement)("span", null, text));
15467 }
15468
15469 function AddedByTheme(_ref3) {
15470 var _theme$name;
15471
15472 let {
15473 slug,
15474 isCustomized
15475 } = _ref3;
15476 const theme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getTheme(slug), [slug]);
15477 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
15478 icon: library_layout,
15479 text: (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug,
15480 isCustomized: isCustomized
15481 });
15482 }
15483
15484 function AddedByPlugin(_ref4) {
15485 let {
15486 slug,
15487 isCustomized
15488 } = _ref4;
15489 const plugin = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPlugin(slug), [slug]);
15490 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
15491 icon: library_plugins,
15492 text: (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug,
15493 isCustomized: isCustomized
15494 });
15495 }
15496
15497 function AddedByAuthor(_ref5) {
15498 var _user$avatar_urls;
15499
15500 let {
15501 id
15502 } = _ref5;
15503 const user = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getUser(id), [id]);
15504 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
15505 icon: comment_author_avatar,
15506 imageUrl: user === null || user === void 0 ? void 0 : (_user$avatar_urls = user.avatar_urls) === null || _user$avatar_urls === void 0 ? void 0 : _user$avatar_urls[48],
15507 text: user === null || user === void 0 ? void 0 : user.nickname
15508 });
15509 }
15510
15511 function AddedBySite() {
15512 const {
15513 name,
15514 logoURL
15515 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15516 var _getMedia;
15517
15518 const {
15519 getEntityRecord,
15520 getMedia
15521 } = select(external_wp_coreData_namespaceObject.store);
15522 const siteData = getEntityRecord('root', '__unstableBase');
15523 return {
15524 name: siteData === null || siteData === void 0 ? void 0 : siteData.name,
15525 logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
15526 };
15527 }, []);
15528 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
15529 icon: library_globe,
15530 imageUrl: logoURL,
15531 text: name
15532 });
15533 }
15534
15535 function AddedBy(_ref6) {
15536 let {
15537 templateType,
15538 template
15539 } = _ref6;
15540
15541 if (!template) {
15542 return;
15543 }
15544
15545 if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
15546 // Template originally provided by a theme, but customized by a user.
15547 // Templates originally didn't have the 'origin' field so identify
15548 // older customized templates by checking for no origin and a 'theme'
15549 // or 'custom' source.
15550 if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
15551 return (0,external_wp_element_namespaceObject.createElement)(AddedByTheme, {
15552 slug: template.theme,
15553 isCustomized: template.source === 'custom'
15554 });
15555 } // Template originally provided by a plugin, but customized by a user.
15556
15557
15558 if (template.has_theme_file && template.origin === 'plugin') {
15559 return (0,external_wp_element_namespaceObject.createElement)(AddedByPlugin, {
15560 slug: template.theme,
15561 isCustomized: template.source === 'custom'
15562 });
15563 } // Template was created from scratch, but has no author. Author support
15564 // was only added to templates in WordPress 5.9. Fallback to showing the
15565 // site logo and title.
15566
15567
15568 if (!template.has_theme_file && template.source === 'custom' && !template.author) {
15569 return (0,external_wp_element_namespaceObject.createElement)(AddedBySite, null);
15570 }
15571 } // Simply show the author for templates created from scratch that have an
15572 // author or for any other post type.
15573
15574
15575 return (0,external_wp_element_namespaceObject.createElement)(AddedByAuthor, {
15576 id: template.author
15577 });
15578 }
15579
15580 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/table.js
15581
15582
15583 /**
15584 * WordPress dependencies
15585 */
15586
15587
15588
15589
15590
15591 /**
15592 * Internal dependencies
15593 */
15594
15595
15596
15597
15598 function Table(_ref) {
15599 let {
15600 templateType
15601 } = _ref;
15602 const {
15603 records: templates,
15604 isResolving: isLoading
15605 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', templateType, {
15606 per_page: -1
15607 });
15608 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
15609
15610 if (!templates || isLoading) {
15611 return null;
15612 }
15613
15614 if (!templates.length) {
15615 var _postType$labels, _postType$labels$name;
15616
15617 return (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_i18n_namespaceObject.sprintf)( // translators: The template type name, should be either "templates" or "template parts".
15618 (0,external_wp_i18n_namespaceObject.__)('No %s found.'), postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : (_postType$labels$name = _postType$labels.name) === null || _postType$labels$name === void 0 ? void 0 : _postType$labels$name.toLowerCase()));
15619 }
15620
15621 return (// These explicit aria roles are needed for Safari.
15622 // See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
15623 (0,external_wp_element_namespaceObject.createElement)("table", {
15624 className: "edit-site-list-table",
15625 role: "table"
15626 }, (0,external_wp_element_namespaceObject.createElement)("thead", null, (0,external_wp_element_namespaceObject.createElement)("tr", {
15627 className: "edit-site-list-table-head",
15628 role: "row"
15629 }, (0,external_wp_element_namespaceObject.createElement)("th", {
15630 className: "edit-site-list-table-column",
15631 role: "columnheader"
15632 }, (0,external_wp_i18n_namespaceObject.__)('Template')), (0,external_wp_element_namespaceObject.createElement)("th", {
15633 className: "edit-site-list-table-column",
15634 role: "columnheader"
15635 }, (0,external_wp_i18n_namespaceObject.__)('Added by')), (0,external_wp_element_namespaceObject.createElement)("th", {
15636 className: "edit-site-list-table-column",
15637 role: "columnheader"
15638 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Actions'))))), (0,external_wp_element_namespaceObject.createElement)("tbody", null, templates.map(template => {
15639 var _template$title;
15640
15641 return (0,external_wp_element_namespaceObject.createElement)("tr", {
15642 key: template.id,
15643 className: "edit-site-list-table-row",
15644 role: "row"
15645 }, (0,external_wp_element_namespaceObject.createElement)("td", {
15646 className: "edit-site-list-table-column",
15647 role: "cell"
15648 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
15649 level: 4
15650 }, (0,external_wp_element_namespaceObject.createElement)(Link, {
15651 params: {
15652 postId: template.id,
15653 postType: template.type
15654 }
15655 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug))), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.description)), (0,external_wp_element_namespaceObject.createElement)("td", {
15656 className: "edit-site-list-table-column",
15657 role: "cell"
15658 }, (0,external_wp_element_namespaceObject.createElement)(AddedBy, {
15659 templateType: templateType,
15660 template: template
15661 })), (0,external_wp_element_namespaceObject.createElement)("td", {
15662 className: "edit-site-list-table-column",
15663 role: "cell"
15664 }, (0,external_wp_element_namespaceObject.createElement)(actions_Actions, {
15665 template: template
15666 })));
15667 })))
15668 );
15669 }
15670
15671 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/index.js
15672
15673
15674 /**
15675 * External dependencies
15676 */
15677
15678 /**
15679 * WordPress dependencies
15680 */
15681
15682
15683
15684
15685
15686
15687
15688 /**
15689 * Internal dependencies
15690 */
15691
15692
15693
15694
15695
15696
15697
15698
15699 function List() {
15700 var _postType$labels, _postType$labels2;
15701
15702 const {
15703 params: {
15704 postType: templateType
15705 }
15706 } = useLocation();
15707 useRegisterShortcuts();
15708 const {
15709 previousShortcut,
15710 nextShortcut,
15711 isNavigationOpen
15712 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15713 return {
15714 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
15715 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/next-region'),
15716 isNavigationOpen: select(store_store).isNavigationOpened()
15717 };
15718 }, []);
15719 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
15720 useTitle(postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.name); // `postType` could load in asynchronously. Only provide the detailed region labels if
15721 // the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
15722
15723 const itemsListLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels2 = postType.labels) === null || _postType$labels2 === void 0 ? void 0 : _postType$labels2.items_list;
15724 const detailedRegionLabels = postType ? {
15725 header: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s - the name of the page, 'Header' as in the header area of that page.
15726 (0,external_wp_i18n_namespaceObject.__)('%s - Header'), itemsListLabel),
15727 body: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s - the name of the page, 'Content' as in the content area of that page.
15728 (0,external_wp_i18n_namespaceObject.__)('%s - Content'), itemsListLabel)
15729 } : undefined;
15730 return (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
15731 className: classnames_default()('edit-site-list', {
15732 'is-navigation-open': isNavigationOpen
15733 }),
15734 labels: {
15735 drawer: (0,external_wp_i18n_namespaceObject.__)('Navigation Sidebar'),
15736 ...detailedRegionLabels
15737 },
15738 header: (0,external_wp_element_namespaceObject.createElement)(header_Header, {
15739 templateType: templateType
15740 }),
15741 drawer: (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar.Slot, null),
15742 notices: (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null),
15743 content: (0,external_wp_element_namespaceObject.createElement)(Table, {
15744 templateType: templateType
15745 }),
15746 shortcuts: {
15747 previous: previousShortcut,
15748 next: nextShortcut
15749 }
15750 });
15751 }
15752
15753 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/get-is-list-page.js
15754 /**
15755 * Returns if the params match the list page route.
15756 *
15757 * @param {Object} params The search params.
15758 * @param {string} params.postId The post ID.
15759 * @param {string} params.postType The post type.
15760 * @return {boolean} Is list page or not.
15761 */
15762 function getIsListPage(_ref) {
15763 let {
15764 postId,
15765 postType
15766 } = _ref;
15767 return !!(!postId && postType);
15768 }
15769
15770 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/app/index.js
15771
15772
15773 /**
15774 * WordPress dependencies
15775 */
15776
15777
15778
15779
15780
15781
15782 /**
15783 * Internal dependencies
15784 */
15785
15786
15787
15788
15789
15790
15791 function EditSiteApp(_ref) {
15792 let {
15793 reboot,
15794 homeTemplate
15795 } = _ref;
15796 const {
15797 createErrorNotice
15798 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15799
15800 function onPluginAreaError(name) {
15801 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)(
15802 /* translators: %s: plugin name */
15803 (0,external_wp_i18n_namespaceObject.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name));
15804 }
15805
15806 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.UnsavedChangesWarning, null), (0,external_wp_element_namespaceObject.createElement)(Routes, null, _ref2 => {
15807 var _params$postId;
15808
15809 let {
15810 params
15811 } = _ref2;
15812 const isListPage = getIsListPage(params); // The existence of a 'front-page' supersedes every other setting.
15813
15814 const homeTemplateType = (_params$postId = params.postId) !== null && _params$postId !== void 0 && _params$postId.includes('front-page') || params.postId === (homeTemplate === null || homeTemplate === void 0 ? void 0 : homeTemplate.postId) ? 'site-editor' : undefined;
15815 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isListPage ? (0,external_wp_element_namespaceObject.createElement)(List, null) : (0,external_wp_element_namespaceObject.createElement)(editor, {
15816 onError: reboot
15817 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, {
15818 onError: onPluginAreaError
15819 }), (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar // Open the navigation sidebar by default when in the list page.
15820 , {
15821 isDefaultOpen: !!isListPage,
15822 activeTemplateType: isListPage ? params.postType : homeTemplateType
15823 }));
15824 }));
15825 }
15826
15827 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js
15828
15829
15830
15831 /**
15832 * WordPress dependencies
15833 */
15834
15835
15836 /**
15837 * Internal dependencies
15838 */
15839
15840
15841 /**
15842 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
15843 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
15844 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
15845 *
15846 * ```js
15847 * wp.data.dispatch( 'core/edit-site' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
15848 * ```
15849 *
15850 * @see PluginSidebarMoreMenuItem
15851 *
15852 * @param {Object} props Element props.
15853 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
15854 * @param {string} [props.className] An optional class name added to the sidebar body.
15855 * @param {string} props.title Title displayed at the top of the sidebar.
15856 * @param {boolean} [props.isPinnable=true] Whether to allow to pin sidebar to the toolbar. When set to `true` it also automatically renders a corresponding menu item.
15857 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
15858 *
15859 * @example
15860 * ```js
15861 * // Using ES5 syntax
15862 * var __ = wp.i18n.__;
15863 * var el = wp.element.createElement;
15864 * var PanelBody = wp.components.PanelBody;
15865 * var PluginSidebar = wp.editSite.PluginSidebar;
15866 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
15867 *
15868 * function MyPluginSidebar() {
15869 * return el(
15870 * PluginSidebar,
15871 * {
15872 * name: 'my-sidebar',
15873 * title: 'My sidebar title',
15874 * icon: moreIcon,
15875 * },
15876 * el(
15877 * PanelBody,
15878 * {},
15879 * __( 'My sidebar content' )
15880 * )
15881 * );
15882 * }
15883 * ```
15884 *
15885 * @example
15886 * ```jsx
15887 * // Using ESNext syntax
15888 * import { __ } from '@wordpress/i18n';
15889 * import { PanelBody } from '@wordpress/components';
15890 * import { PluginSidebar } from '@wordpress/edit-site';
15891 * import { more } from '@wordpress/icons';
15892 *
15893 * const MyPluginSidebar = () => (
15894 * <PluginSidebar
15895 * name="my-sidebar"
15896 * title="My sidebar title"
15897 * icon={ more }
15898 * >
15899 * <PanelBody>
15900 * { __( 'My sidebar content' ) }
15901 * </PanelBody>
15902 * </PluginSidebar>
15903 * );
15904 * ```
15905 */
15906
15907 function PluginSidebarEditSite(_ref) {
15908 let {
15909 className,
15910 ...props
15911 } = _ref;
15912 const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getSettings().showIconLabels, []);
15913 return (0,external_wp_element_namespaceObject.createElement)(complementary_area, extends_extends({
15914 panelClassName: className,
15915 className: "edit-site-sidebar-edit-mode",
15916 scope: "core/edit-site",
15917 showIconLabels: showIconLabels
15918 }, props));
15919 }
15920
15921 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js
15922
15923
15924
15925 /**
15926 * WordPress dependencies
15927 */
15928
15929 /**
15930 * Renders a menu item in `Plugins` group in `More Menu` drop down,
15931 * and can be used to activate the corresponding `PluginSidebar` component.
15932 * The text within the component appears as the menu item label.
15933 *
15934 * @param {Object} props Component props.
15935 * @param {string} props.target A string identifying the target sidebar you wish to be activated by this menu item. Must be the same as the `name` prop you have given to that sidebar.
15936 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
15937 *
15938 * @example
15939 * ```js
15940 * // Using ES5 syntax
15941 * var __ = wp.i18n.__;
15942 * var PluginSidebarMoreMenuItem = wp.editSite.PluginSidebarMoreMenuItem;
15943 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
15944 *
15945 * function MySidebarMoreMenuItem() {
15946 * return wp.element.createElement(
15947 * PluginSidebarMoreMenuItem,
15948 * {
15949 * target: 'my-sidebar',
15950 * icon: moreIcon,
15951 * },
15952 * __( 'My sidebar title' )
15953 * )
15954 * }
15955 * ```
15956 *
15957 * @example
15958 * ```jsx
15959 * // Using ESNext syntax
15960 * import { __ } from '@wordpress/i18n';
15961 * import { PluginSidebarMoreMenuItem } from '@wordpress/edit-site';
15962 * import { more } from '@wordpress/icons';
15963 *
15964 * const MySidebarMoreMenuItem = () => (
15965 * <PluginSidebarMoreMenuItem
15966 * target="my-sidebar"
15967 * icon={ more }
15968 * >
15969 * { __( 'My sidebar title' ) }
15970 * </PluginSidebarMoreMenuItem>
15971 * );
15972 * ```
15973 *
15974 * @return {WPComponent} The component to be rendered.
15975 */
15976
15977 function PluginSidebarMoreMenuItem(props) {
15978 return (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem // Menu item is marked with unstable prop for backward compatibility.
15979 // @see https://github.com/WordPress/gutenberg/issues/14457
15980 , extends_extends({
15981 __unstableExplicitMenuItem: true,
15982 scope: "core/edit-site"
15983 }, props));
15984 }
15985
15986 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header-edit-mode/plugin-more-menu-item/index.js
15987 /**
15988 * WordPress dependencies
15989 */
15990
15991
15992
15993
15994 /**
15995 * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.
15996 * The text within the component appears as the menu item label.
15997 *
15998 * @param {Object} props Component properties.
15999 * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
16000 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
16001 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
16002 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.
16003 *
16004 * @example
16005 * ```js
16006 * // Using ES5 syntax
16007 * var __ = wp.i18n.__;
16008 * var PluginMoreMenuItem = wp.editSite.PluginMoreMenuItem;
16009 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
16010 *
16011 * function onButtonClick() {
16012 * alert( 'Button clicked.' );
16013 * }
16014 *
16015 * function MyButtonMoreMenuItem() {
16016 * return wp.element.createElement(
16017 * PluginMoreMenuItem,
16018 * {
16019 * icon: moreIcon,
16020 * onClick: onButtonClick,
16021 * },
16022 * __( 'My button title' )
16023 * );
16024 * }
16025 * ```
16026 *
16027 * @example
16028 * ```jsx
16029 * // Using ESNext syntax
16030 * import { __ } from '@wordpress/i18n';
16031 * import { PluginMoreMenuItem } from '@wordpress/edit-site';
16032 * import { more } from '@wordpress/icons';
16033 *
16034 * function onButtonClick() {
16035 * alert( 'Button clicked.' );
16036 * }
16037 *
16038 * const MyButtonMoreMenuItem = () => (
16039 * <PluginMoreMenuItem
16040 * icon={ more }
16041 * onClick={ onButtonClick }
16042 * >
16043 * { __( 'My button title' ) }
16044 * </PluginMoreMenuItem>
16045 * );
16046 * ```
16047 *
16048 * @return {WPComponent} The component to be rendered.
16049 */
16050
16051 /* harmony default export */ var plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
16052 var _ownProps$as;
16053
16054 return {
16055 as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : external_wp_components_namespaceObject.MenuItem,
16056 icon: ownProps.icon || context.icon,
16057 name: 'core/edit-site/plugin-more-menu'
16058 };
16059 }))(action_item));
16060
16061 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/index.js
16062
16063
16064 /**
16065 * WordPress dependencies
16066 */
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079 /**
16080 * Internal dependencies
16081 */
16082
16083
16084
16085
16086
16087
16088 /**
16089 * Reinitializes the editor after the user chooses to reboot the editor after
16090 * an unhandled error occurs, replacing previously mounted editor element using
16091 * an initial state from prior to the crash.
16092 *
16093 * @param {Element} target DOM node in which editor is rendered.
16094 * @param {?Object} settings Editor settings object.
16095 */
16096
16097 function reinitializeEditor(target, settings) {
16098 // Display warning if editor wasn't able to resolve homepage template.
16099 if (!settings.__unstableHomeTemplate) {
16100 var _settings$__experimen;
16101
16102 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(ErrorBoundaryWarning, {
16103 message: (0,external_wp_i18n_namespaceObject.__)('The editor is unable to find a block template for the homepage.'),
16104 dashboardLink: (_settings$__experimen = settings.__experimentalDashboardLink) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : 'index.php'
16105 }), target);
16106 return;
16107 }
16108 /*
16109 * Prevent adding the Clasic block in the site editor.
16110 * Only add the filter when the site editor is initialized, not imported.
16111 * Also only add the filter(s) after registerCoreBlocks()
16112 * so that common filters in the block library are not overwritten.
16113 *
16114 * This usage here is inspired by previous usage of the filter in the post editor:
16115 * https://github.com/WordPress/gutenberg/pull/37157
16116 */
16117
16118
16119 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeClassicBlockFromInserter', (canInsert, blockType) => {
16120 if (blockType.name === 'core/freeform') {
16121 return false;
16122 }
16123
16124 return canInsert;
16125 }); // This will be a no-op if the target doesn't have any React nodes.
16126
16127 (0,external_wp_element_namespaceObject.unmountComponentAtNode)(target);
16128 const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
16129 // so that we won't trigger unnecessary re-renders with useEffect.
16130
16131 {
16132 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/edit-site', {
16133 editorMode: 'visual',
16134 fixedToolbar: false,
16135 focusMode: false,
16136 keepCaretInsideBlock: false,
16137 welcomeGuide: true,
16138 welcomeGuideStyles: true,
16139 showListViewByDefault: false
16140 }); // Check if the block list view should be open by default.
16141
16142 if ((0,external_wp_data_namespaceObject.select)(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showListViewByDefault')) {
16143 (0,external_wp_data_namespaceObject.dispatch)(store_store).setIsListViewOpened(true);
16144 }
16145
16146 (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultComplementaryArea('core/edit-site', 'edit-site/template');
16147 (0,external_wp_data_namespaceObject.dispatch)(store_store).updateSettings(settings); // Keep the defaultTemplateTypes in the core/editor settings too,
16148 // so that they can be selected with core/editor selectors in any editor.
16149 // This is needed because edit-site doesn't initialize with EditorProvider,
16150 // which internally uses updateEditorSettings as well.
16151
16152 (0,external_wp_data_namespaceObject.dispatch)(external_wp_editor_namespaceObject.store).updateEditorSettings({
16153 defaultTemplateTypes: settings.defaultTemplateTypes,
16154 defaultTemplatePartAreas: settings.defaultTemplatePartAreas
16155 });
16156 const isLandingOnListPage = getIsListPage((0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href));
16157
16158 if (isLandingOnListPage) {
16159 // Default the navigation panel to be opened when we're in a bigger
16160 // screen and land in the list screen.
16161 (0,external_wp_data_namespaceObject.dispatch)(store_store).setIsNavigationPanelOpened((0,external_wp_data_namespaceObject.select)(external_wp_viewport_namespaceObject.store).isViewportMatch('medium'));
16162 }
16163 } // Prevent the default browser action for files dropped outside of dropzones.
16164
16165 window.addEventListener('dragover', e => e.preventDefault(), false);
16166 window.addEventListener('drop', e => e.preventDefault(), false);
16167 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(EditSiteApp, {
16168 reboot: reboot,
16169 homeTemplate: settings.__unstableHomeTemplate
16170 }), target);
16171 }
16172 /**
16173 * Initializes the site editor screen.
16174 *
16175 * @param {string} id ID of the root element to render the screen in.
16176 * @param {Object} settings Editor settings.
16177 */
16178
16179 function initializeEditor(id, settings) {
16180 settings.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings);
16181
16182 settings.__experimentalFetchRichUrlData = external_wp_coreData_namespaceObject.__experimentalFetchUrlData;
16183 const target = document.getElementById(id);
16184
16185 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters();
16186
16187 (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)();
16188
16189 if (true) {
16190 (0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)({
16191 enableFSEBlocks: true
16192 });
16193 }
16194
16195 reinitializeEditor(target, settings);
16196 }
16197
16198
16199
16200
16201
16202 }();
16203 (window.wp = window.wp || {}).editSite = __webpack_exports__;
16204 /******/ })()
16205 ;