PluginProbe
Gutenberg / 13.0.0
Gutenberg v13.0.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 13.0.0, at build/edit-site/index.js

12,972 lines 447.6 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 "__experimentalMainDashboardButton": function() { return /* reexport */ main_dashboard_button; },
1011 "__experimentalNavigationToggle": function() { return /* reexport */ navigation_toggle; },
1012 "initializeEditor": function() { return /* binding */ initializeEditor; },
1013 "reinitializeEditor": function() { return /* binding */ reinitializeEditor; }
1014 });
1015
1016 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
1017 var actions_namespaceObject = {};
1018 __webpack_require__.r(actions_namespaceObject);
1019 __webpack_require__.d(actions_namespaceObject, {
1020 "disableComplementaryArea": function() { return disableComplementaryArea; },
1021 "enableComplementaryArea": function() { return enableComplementaryArea; },
1022 "pinItem": function() { return pinItem; },
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 "setNavigationPanelActiveMenu": function() { return setNavigationPanelActiveMenu; },
1054 "setPage": function() { return setPage; },
1055 "setTemplate": function() { return setTemplate; },
1056 "setTemplatePart": function() { return setTemplatePart; },
1057 "switchEditorMode": function() { return switchEditorMode; },
1058 "toggleFeature": function() { return actions_toggleFeature; },
1059 "updateSettings": function() { return updateSettings; }
1060 });
1061
1062 // NAMESPACE OBJECT: ./packages/edit-site/build-module/store/selectors.js
1063 var store_selectors_namespaceObject = {};
1064 __webpack_require__.r(store_selectors_namespaceObject);
1065 __webpack_require__.d(store_selectors_namespaceObject, {
1066 "__experimentalGetInsertionPoint": function() { return __experimentalGetInsertionPoint; },
1067 "__experimentalGetPreviewDeviceType": function() { return __experimentalGetPreviewDeviceType; },
1068 "__unstableGetPreference": function() { return __unstableGetPreference; },
1069 "getCanUserCreateMedia": function() { return getCanUserCreateMedia; },
1070 "getCurrentTemplateNavigationPanelSubMenu": function() { return getCurrentTemplateNavigationPanelSubMenu; },
1071 "getCurrentTemplateTemplateParts": function() { return getCurrentTemplateTemplateParts; },
1072 "getEditedPostId": function() { return getEditedPostId; },
1073 "getEditedPostType": function() { return getEditedPostType; },
1074 "getEditorMode": function() { return getEditorMode; },
1075 "getHomeTemplateId": function() { return getHomeTemplateId; },
1076 "getNavigationPanelActiveMenu": function() { return getNavigationPanelActiveMenu; },
1077 "getPage": function() { return getPage; },
1078 "getReusableBlocks": function() { return getReusableBlocks; },
1079 "getSettings": function() { return getSettings; },
1080 "isFeatureActive": function() { return selectors_isFeatureActive; },
1081 "isInserterOpened": function() { return isInserterOpened; },
1082 "isListViewOpened": function() { return isListViewOpened; },
1083 "isNavigationOpened": function() { return isNavigationOpened; }
1084 });
1085
1086 ;// CONCATENATED MODULE: external ["wp","element"]
1087 var external_wp_element_namespaceObject = window["wp"]["element"];
1088 ;// CONCATENATED MODULE: external ["wp","blocks"]
1089 var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
1090 ;// CONCATENATED MODULE: external ["wp","blockLibrary"]
1091 var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
1092 ;// CONCATENATED MODULE: external ["wp","data"]
1093 var external_wp_data_namespaceObject = window["wp"]["data"];
1094 ;// CONCATENATED MODULE: external ["wp","coreData"]
1095 var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1096 ;// CONCATENATED MODULE: external ["wp","editor"]
1097 var external_wp_editor_namespaceObject = window["wp"]["editor"];
1098 ;// CONCATENATED MODULE: external ["wp","preferences"]
1099 var external_wp_preferences_namespaceObject = window["wp"]["preferences"];
1100 ;// CONCATENATED MODULE: external ["wp","i18n"]
1101 var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
1102 ;// CONCATENATED MODULE: external ["wp","viewport"]
1103 var external_wp_viewport_namespaceObject = window["wp"]["viewport"];
1104 ;// CONCATENATED MODULE: external ["wp","url"]
1105 var external_wp_url_namespaceObject = window["wp"]["url"];
1106 ;// CONCATENATED MODULE: external ["wp","hooks"]
1107 var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
1108 ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
1109 var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
1110 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/hooks/components.js
1111 /**
1112 * WordPress dependencies
1113 */
1114
1115
1116 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-site/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload);
1117
1118 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/hooks/index.js
1119 /**
1120 * Internal dependencies
1121 */
1122
1123
1124 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/constants.js
1125 /**
1126 * The identifier for the data store.
1127 *
1128 * @type {string}
1129 */
1130 const STORE_NAME = 'core/edit-site';
1131 const TEMPLATE_PART_AREA_HEADER = 'header';
1132 const TEMPLATE_PART_AREA_FOOTER = 'footer';
1133 const TEMPLATE_PART_AREA_SIDEBAR = 'sidebar';
1134 const TEMPLATE_PART_AREA_GENERAL = 'uncategorized';
1135
1136 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/constants.js
1137 /**
1138 * WordPress dependencies
1139 */
1140
1141 /**
1142 * Internal dependencies
1143 */
1144
1145
1146 const TEMPLATES_PRIMARY = ['index', 'singular', 'archive', 'single', 'page', 'home', '404', 'search'];
1147 const TEMPLATES_SECONDARY = ['author', 'category', 'taxonomy', 'date', 'tag', 'attachment', 'single-post', 'front-page'];
1148 const TEMPLATES_TOP_LEVEL = [...TEMPLATES_PRIMARY, ...TEMPLATES_SECONDARY];
1149 const TEMPLATES_GENERAL = ['page-home'];
1150 const TEMPLATES_POSTS_PREFIXES = ['post-', 'author-', 'single-post-', 'tag-'];
1151 const TEMPLATES_PAGES_PREFIXES = ['page-'];
1152 const TEMPLATE_OVERRIDES = {
1153 singular: ['single', 'page'],
1154 index: ['archive', '404', 'search', 'singular', 'home'],
1155 home: ['front-page']
1156 };
1157 const MENU_ROOT = 'root';
1158 const MENU_TEMPLATE_PARTS = 'template-parts';
1159 const MENU_TEMPLATES = 'templates';
1160 const MENU_TEMPLATES_GENERAL = 'templates-general';
1161 const MENU_TEMPLATES_PAGES = 'templates-pages';
1162 const MENU_TEMPLATES_POSTS = 'templates-posts';
1163 const MENU_TEMPLATES_UNUSED = 'templates-unused';
1164 const MENU_TEMPLATE_PARTS_HEADERS = 'template-parts-headers';
1165 const MENU_TEMPLATE_PARTS_FOOTERS = 'template-parts-footers';
1166 const MENU_TEMPLATE_PARTS_SIDEBARS = 'template-parts-sidebars';
1167 const MENU_TEMPLATE_PARTS_GENERAL = 'template-parts-general';
1168 const TEMPLATE_PARTS_SUB_MENUS = [{
1169 area: TEMPLATE_PART_AREA_HEADER,
1170 menu: MENU_TEMPLATE_PARTS_HEADERS,
1171 title: (0,external_wp_i18n_namespaceObject.__)('headers')
1172 }, {
1173 area: TEMPLATE_PART_AREA_FOOTER,
1174 menu: MENU_TEMPLATE_PARTS_FOOTERS,
1175 title: (0,external_wp_i18n_namespaceObject.__)('footers')
1176 }, {
1177 area: TEMPLATE_PART_AREA_SIDEBAR,
1178 menu: MENU_TEMPLATE_PARTS_SIDEBARS,
1179 title: (0,external_wp_i18n_namespaceObject.__)('sidebars')
1180 }, {
1181 area: TEMPLATE_PART_AREA_GENERAL,
1182 menu: MENU_TEMPLATE_PARTS_GENERAL,
1183 title: (0,external_wp_i18n_namespaceObject.__)('general')
1184 }];
1185
1186 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/reducer.js
1187 /**
1188 * WordPress dependencies
1189 */
1190
1191 /**
1192 * Internal dependencies
1193 */
1194
1195
1196 /**
1197 * Reducer returning the editing canvas device type.
1198 *
1199 * @param {Object} state Current state.
1200 * @param {Object} action Dispatched action.
1201 *
1202 * @return {Object} Updated state.
1203 */
1204
1205 function deviceType() {
1206 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Desktop';
1207 let action = arguments.length > 1 ? arguments[1] : undefined;
1208
1209 switch (action.type) {
1210 case 'SET_PREVIEW_DEVICE_TYPE':
1211 return action.deviceType;
1212 }
1213
1214 return state;
1215 }
1216 /**
1217 * Reducer returning the settings.
1218 *
1219 * @param {Object} state Current state.
1220 * @param {Object} action Dispatched action.
1221 *
1222 * @return {Object} Updated state.
1223 */
1224
1225 function settings() {
1226 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1227 let action = arguments.length > 1 ? arguments[1] : undefined;
1228
1229 switch (action.type) {
1230 case 'UPDATE_SETTINGS':
1231 return { ...state,
1232 ...action.settings
1233 };
1234 }
1235
1236 return state;
1237 }
1238 /**
1239 * Reducer keeping track of the currently edited Post Type,
1240 * Post Id and the context provided to fill the content of the block editor.
1241 *
1242 * @param {Object} state Current edited post.
1243 * @param {Object} action Dispatched action.
1244 *
1245 * @return {Object} Updated state.
1246 */
1247
1248 function editedPost() {
1249 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1250 let action = arguments.length > 1 ? arguments[1] : undefined;
1251
1252 switch (action.type) {
1253 case 'SET_TEMPLATE':
1254 case 'SET_PAGE':
1255 return {
1256 type: 'wp_template',
1257 id: action.templateId,
1258 page: action.page
1259 };
1260
1261 case 'SET_TEMPLATE_PART':
1262 return {
1263 type: 'wp_template_part',
1264 id: action.templatePartId
1265 };
1266 }
1267
1268 return state;
1269 }
1270 /**
1271 * Reducer for information about the site's homepage.
1272 *
1273 * @param {Object} state Current state.
1274 * @param {Object} action Dispatched action.
1275 *
1276 * @return {Object} Updated state.
1277 */
1278
1279 function homeTemplateId(state, action) {
1280 switch (action.type) {
1281 case 'SET_HOME_TEMPLATE':
1282 return action.homeTemplateId;
1283 }
1284
1285 return state;
1286 }
1287 /**
1288 * Reducer for information about the navigation panel, such as its active menu
1289 * and whether it should be opened or closed.
1290 *
1291 * Note: this reducer interacts with the inserter and list view panels reducers
1292 * to make sure that only one of the three panels is open at the same time.
1293 *
1294 * @param {Object} state Current state.
1295 * @param {Object} action Dispatched action.
1296 */
1297
1298 function navigationPanel() {
1299 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
1300 menu: MENU_ROOT,
1301 isOpen: false
1302 };
1303 let action = arguments.length > 1 ? arguments[1] : undefined;
1304
1305 switch (action.type) {
1306 case 'SET_NAVIGATION_PANEL_ACTIVE_MENU':
1307 return { ...state,
1308 menu: action.menu
1309 };
1310
1311 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
1312 return { ...state,
1313 isOpen: true,
1314 menu: action.menu
1315 };
1316
1317 case 'SET_IS_NAVIGATION_PANEL_OPENED':
1318 return { ...state,
1319 menu: !action.isOpen ? MENU_ROOT : state.menu,
1320 // Set menu to root when closing panel.
1321 isOpen: action.isOpen
1322 };
1323
1324 case 'SET_IS_LIST_VIEW_OPENED':
1325 return { ...state,
1326 menu: state.isOpen && action.isOpen ? MENU_ROOT : state.menu,
1327 // Set menu to root when closing panel.
1328 isOpen: action.isOpen ? false : state.isOpen
1329 };
1330
1331 case 'SET_IS_INSERTER_OPENED':
1332 return { ...state,
1333 menu: state.isOpen && action.value ? MENU_ROOT : state.menu,
1334 // Set menu to root when closing panel.
1335 isOpen: action.value ? false : state.isOpen
1336 };
1337 }
1338
1339 return state;
1340 }
1341 /**
1342 * Reducer to set the block inserter panel open or closed.
1343 *
1344 * Note: this reducer interacts with the navigation and list view panels reducers
1345 * to make sure that only one of the three panels is open at the same time.
1346 *
1347 * @param {boolean|Object} state Current state.
1348 * @param {Object} action Dispatched action.
1349 */
1350
1351 function blockInserterPanel() {
1352 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1353 let action = arguments.length > 1 ? arguments[1] : undefined;
1354
1355 switch (action.type) {
1356 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
1357 return false;
1358
1359 case 'SET_IS_NAVIGATION_PANEL_OPENED':
1360 case 'SET_IS_LIST_VIEW_OPENED':
1361 return action.isOpen ? false : state;
1362
1363 case 'SET_IS_INSERTER_OPENED':
1364 return action.value;
1365 }
1366
1367 return state;
1368 }
1369 /**
1370 * Reducer to set the list view panel open or closed.
1371 *
1372 * Note: this reducer interacts with the navigation and inserter panels reducers
1373 * to make sure that only one of the three panels is open at the same time.
1374 *
1375 * @param {Object} state Current state.
1376 * @param {Object} action Dispatched action.
1377 */
1378
1379 function listViewPanel() {
1380 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1381 let action = arguments.length > 1 ? arguments[1] : undefined;
1382
1383 switch (action.type) {
1384 case 'OPEN_NAVIGATION_PANEL_TO_MENU':
1385 return false;
1386
1387 case 'SET_IS_NAVIGATION_PANEL_OPENED':
1388 return action.isOpen ? false : state;
1389
1390 case 'SET_IS_INSERTER_OPENED':
1391 return action.value ? false : state;
1392
1393 case 'SET_IS_LIST_VIEW_OPENED':
1394 return action.isOpen;
1395 }
1396
1397 return state;
1398 }
1399 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
1400 deviceType,
1401 settings,
1402 editedPost,
1403 homeTemplateId,
1404 navigationPanel,
1405 blockInserterPanel,
1406 listViewPanel
1407 }));
1408
1409 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
1410 var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
1411 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
1412 ;// CONCATENATED MODULE: external ["wp","deprecated"]
1413 var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
1414 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
1415 ;// CONCATENATED MODULE: external ["wp","notices"]
1416 var external_wp_notices_namespaceObject = window["wp"]["notices"];
1417 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
1418 function extends_extends() {
1419 extends_extends = Object.assign || function (target) {
1420 for (var i = 1; i < arguments.length; i++) {
1421 var source = arguments[i];
1422
1423 for (var key in source) {
1424 if (Object.prototype.hasOwnProperty.call(source, key)) {
1425 target[key] = source[key];
1426 }
1427 }
1428 }
1429
1430 return target;
1431 };
1432
1433 return extends_extends.apply(this, arguments);
1434 }
1435 // EXTERNAL MODULE: ./node_modules/classnames/index.js
1436 var classnames = __webpack_require__(4403);
1437 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
1438 ;// CONCATENATED MODULE: external ["wp","components"]
1439 var external_wp_components_namespaceObject = window["wp"]["components"];
1440 ;// CONCATENATED MODULE: external ["wp","primitives"]
1441 var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
1442 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
1443
1444
1445 /**
1446 * WordPress dependencies
1447 */
1448
1449 const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1450 xmlns: "http://www.w3.org/2000/svg",
1451 viewBox: "0 0 24 24"
1452 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1453 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
1454 }));
1455 /* harmony default export */ var library_check = (check);
1456
1457 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
1458
1459
1460 /**
1461 * WordPress dependencies
1462 */
1463
1464 const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1465 xmlns: "http://www.w3.org/2000/svg",
1466 viewBox: "0 0 24 24"
1467 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1468 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"
1469 }));
1470 /* harmony default export */ var star_filled = (starFilled);
1471
1472 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
1473
1474
1475 /**
1476 * WordPress dependencies
1477 */
1478
1479 const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1480 xmlns: "http://www.w3.org/2000/svg",
1481 viewBox: "0 0 24 24"
1482 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1483 fillRule: "evenodd",
1484 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",
1485 clipRule: "evenodd"
1486 }));
1487 /* harmony default export */ var star_empty = (starEmpty);
1488
1489 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
1490
1491
1492 /**
1493 * WordPress dependencies
1494 */
1495
1496 const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1497 xmlns: "http://www.w3.org/2000/svg",
1498 viewBox: "0 0 24 24"
1499 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1500 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"
1501 }));
1502 /* harmony default export */ var close_small = (closeSmall);
1503
1504 ;// CONCATENATED MODULE: external "lodash"
1505 var external_lodash_namespaceObject = window["lodash"];
1506 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
1507 /**
1508 * WordPress dependencies
1509 */
1510
1511
1512 /**
1513 * Enable the complementary area.
1514 *
1515 * @param {string} scope Complementary area scope.
1516 * @param {string} area Area identifier.
1517 */
1518
1519 const enableComplementaryArea = (scope, area) => _ref => {
1520 let {
1521 registry
1522 } = _ref;
1523
1524 // Return early if there's no area.
1525 if (!area) {
1526 return;
1527 }
1528
1529 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'complementaryArea', area);
1530 };
1531 /**
1532 * Disable the complementary area.
1533 *
1534 * @param {string} scope Complementary area scope.
1535 */
1536
1537 const disableComplementaryArea = scope => _ref2 => {
1538 let {
1539 registry
1540 } = _ref2;
1541 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'complementaryArea', null);
1542 };
1543 /**
1544 * Pins an item.
1545 *
1546 * @param {string} scope Item scope.
1547 * @param {string} item Item identifier.
1548 *
1549 * @return {Object} Action object.
1550 */
1551
1552 const pinItem = (scope, item) => _ref3 => {
1553 let {
1554 registry
1555 } = _ref3;
1556
1557 // Return early if there's no item.
1558 if (!item) {
1559 return;
1560 }
1561
1562 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
1563
1564 if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
1565 return;
1566 }
1567
1568 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
1569 [item]: true
1570 });
1571 };
1572 /**
1573 * Unpins an item.
1574 *
1575 * @param {string} scope Item scope.
1576 * @param {string} item Item identifier.
1577 */
1578
1579 const unpinItem = (scope, item) => _ref4 => {
1580 let {
1581 registry
1582 } = _ref4;
1583
1584 // Return early if there's no item.
1585 if (!item) {
1586 return;
1587 }
1588
1589 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
1590 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
1591 [item]: false
1592 });
1593 };
1594 /**
1595 * Returns an action object used in signalling that a feature should be toggled.
1596 *
1597 * @param {string} scope The feature scope (e.g. core/edit-post).
1598 * @param {string} featureName The feature name.
1599 */
1600
1601 function toggleFeature(scope, featureName) {
1602 return function (_ref5) {
1603 let {
1604 registry
1605 } = _ref5;
1606 external_wp_deprecated_default()(`wp.dispatch( 'core/interface' ).toggleFeature`, {
1607 since: '6.0',
1608 alternative: `wp.dispatch( 'core/preferences' ).toggle`
1609 });
1610 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
1611 };
1612 }
1613 /**
1614 * Returns an action object used in signalling that a feature should be set to
1615 * a true or false value
1616 *
1617 * @param {string} scope The feature scope (e.g. core/edit-post).
1618 * @param {string} featureName The feature name.
1619 * @param {boolean} value The value to set.
1620 *
1621 * @return {Object} Action object.
1622 */
1623
1624 function setFeatureValue(scope, featureName, value) {
1625 return function (_ref6) {
1626 let {
1627 registry
1628 } = _ref6;
1629 external_wp_deprecated_default()(`wp.dispatch( 'core/interface' ).setFeatureValue`, {
1630 since: '6.0',
1631 alternative: `wp.dispatch( 'core/preferences' ).set`
1632 });
1633 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
1634 };
1635 }
1636 /**
1637 * Returns an action object used in signalling that defaults should be set for features.
1638 *
1639 * @param {string} scope The feature scope (e.g. core/edit-post).
1640 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
1641 *
1642 * @return {Object} Action object.
1643 */
1644
1645 function setFeatureDefaults(scope, defaults) {
1646 return function (_ref7) {
1647 let {
1648 registry
1649 } = _ref7;
1650 external_wp_deprecated_default()(`wp.dispatch( 'core/interface' ).setFeatureDefaults`, {
1651 since: '6.0',
1652 alternative: `wp.dispatch( 'core/preferences' ).setDefaults`
1653 });
1654 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
1655 };
1656 }
1657
1658 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
1659 /**
1660 * WordPress dependencies
1661 */
1662
1663
1664
1665 /**
1666 * Returns the complementary area that is active in a given scope.
1667 *
1668 * @param {Object} state Global application state.
1669 * @param {string} scope Item scope.
1670 *
1671 * @return {string} The complementary area that is active in the given scope.
1672 */
1673
1674 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
1675 return select(external_wp_preferences_namespaceObject.store).get(scope, 'complementaryArea');
1676 });
1677 /**
1678 * Returns a boolean indicating if an item is pinned or not.
1679 *
1680 * @param {Object} state Global application state.
1681 * @param {string} scope Scope.
1682 * @param {string} item Item to check.
1683 *
1684 * @return {boolean} True if the item is pinned and false otherwise.
1685 */
1686
1687 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
1688 var _pinnedItems$item;
1689
1690 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
1691 return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
1692 });
1693 /**
1694 * Returns a boolean indicating whether a feature is active for a particular
1695 * scope.
1696 *
1697 * @param {Object} state The store state.
1698 * @param {string} scope The scope of the feature (e.g. core/edit-post).
1699 * @param {string} featureName The name of the feature.
1700 *
1701 * @return {boolean} Is the feature enabled?
1702 */
1703
1704 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
1705 external_wp_deprecated_default()(`wp.select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
1706 since: '6.0',
1707 alternative: `!! wp.select( 'core/preferences' ).isFeatureActive( scope, featureName )`
1708 });
1709 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
1710 });
1711
1712 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
1713 /**
1714 * The identifier for the data store.
1715 *
1716 * @type {string}
1717 */
1718 const constants_STORE_NAME = 'core/interface';
1719
1720 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
1721 /**
1722 * WordPress dependencies
1723 */
1724
1725 /**
1726 * Internal dependencies
1727 */
1728
1729
1730
1731
1732 /**
1733 * Store definition for the interface namespace.
1734 *
1735 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
1736 *
1737 * @type {Object}
1738 */
1739
1740 const store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
1741 reducer: () => {},
1742 actions: actions_namespaceObject,
1743 selectors: selectors_namespaceObject
1744 }); // Once we build a more generic persistence plugin that works across types of stores
1745 // we'd be able to replace this with a register call.
1746
1747 (0,external_wp_data_namespaceObject.register)(store);
1748
1749 ;// CONCATENATED MODULE: external ["wp","plugins"]
1750 var external_wp_plugins_namespaceObject = window["wp"]["plugins"];
1751 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
1752 /**
1753 * WordPress dependencies
1754 */
1755
1756 /* harmony default export */ var complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
1757 return {
1758 icon: ownProps.icon || context.icon,
1759 identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
1760 };
1761 }));
1762
1763 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
1764
1765
1766
1767 /**
1768 * External dependencies
1769 */
1770
1771 /**
1772 * WordPress dependencies
1773 */
1774
1775
1776
1777 /**
1778 * Internal dependencies
1779 */
1780
1781
1782
1783
1784 function ComplementaryAreaToggle(_ref) {
1785 let {
1786 as = external_wp_components_namespaceObject.Button,
1787 scope,
1788 identifier,
1789 icon,
1790 selectedIcon,
1791 ...props
1792 } = _ref;
1793 const ComponentToUse = as;
1794 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier]);
1795 const {
1796 enableComplementaryArea,
1797 disableComplementaryArea
1798 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1799 return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, extends_extends({
1800 icon: selectedIcon && isSelected ? selectedIcon : icon,
1801 onClick: () => {
1802 if (isSelected) {
1803 disableComplementaryArea(scope);
1804 } else {
1805 enableComplementaryArea(scope, identifier);
1806 }
1807 }
1808 }, (0,external_lodash_namespaceObject.omit)(props, ['name'])));
1809 }
1810
1811 /* harmony default export */ var complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
1812
1813 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
1814
1815
1816
1817 /**
1818 * External dependencies
1819 */
1820
1821 /**
1822 * WordPress dependencies
1823 */
1824
1825
1826 /**
1827 * Internal dependencies
1828 */
1829
1830
1831
1832 const ComplementaryAreaHeader = _ref => {
1833 let {
1834 smallScreenTitle,
1835 children,
1836 className,
1837 toggleButtonProps
1838 } = _ref;
1839 const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, extends_extends({
1840 icon: close_small
1841 }, toggleButtonProps));
1842 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
1843 className: "components-panel__header interface-complementary-area-header__small"
1844 }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", {
1845 className: "interface-complementary-area-header__small-title"
1846 }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", {
1847 className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className),
1848 tabIndex: -1
1849 }, children, toggleButton));
1850 };
1851
1852 /* harmony default export */ var complementary_area_header = (ComplementaryAreaHeader);
1853
1854 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
1855
1856
1857
1858 /**
1859 * External dependencies
1860 */
1861
1862 /**
1863 * WordPress dependencies
1864 */
1865
1866
1867
1868
1869 function ActionItemSlot(_ref) {
1870 let {
1871 name,
1872 as: Component = external_wp_components_namespaceObject.ButtonGroup,
1873 fillProps = {},
1874 bubblesVirtually,
1875 ...props
1876 } = _ref;
1877 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
1878 name: name,
1879 bubblesVirtually: bubblesVirtually,
1880 fillProps: fillProps
1881 }, fills => {
1882 if ((0,external_lodash_namespaceObject.isEmpty)(external_wp_element_namespaceObject.Children.toArray(fills))) {
1883 return null;
1884 } // Special handling exists for backward compatibility.
1885 // It ensures that menu items created by plugin authors aren't
1886 // duplicated with automatically injected menu items coming
1887 // from pinnable plugin sidebars.
1888 // @see https://github.com/WordPress/gutenberg/issues/14457
1889
1890
1891 const initializedByPlugins = [];
1892 external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => {
1893 let {
1894 props: {
1895 __unstableExplicitMenuItem,
1896 __unstableTarget
1897 }
1898 } = _ref2;
1899
1900 if (__unstableTarget && __unstableExplicitMenuItem) {
1901 initializedByPlugins.push(__unstableTarget);
1902 }
1903 });
1904 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
1905 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
1906 return null;
1907 }
1908
1909 return child;
1910 });
1911 return (0,external_wp_element_namespaceObject.createElement)(Component, props, children);
1912 });
1913 }
1914
1915 function ActionItem(_ref3) {
1916 let {
1917 name,
1918 as: Component = external_wp_components_namespaceObject.Button,
1919 onClick,
1920 ...props
1921 } = _ref3;
1922 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
1923 name: name
1924 }, _ref4 => {
1925 let {
1926 onClick: fpOnClick
1927 } = _ref4;
1928 return (0,external_wp_element_namespaceObject.createElement)(Component, extends_extends({
1929 onClick: onClick || fpOnClick ? function () {
1930 (onClick || external_lodash_namespaceObject.noop)(...arguments);
1931 (fpOnClick || external_lodash_namespaceObject.noop)(...arguments);
1932 } : undefined
1933 }, props));
1934 });
1935 }
1936
1937 ActionItem.Slot = ActionItemSlot;
1938 /* harmony default export */ var action_item = (ActionItem);
1939
1940 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
1941
1942
1943
1944 /**
1945 * External dependencies
1946 */
1947
1948 /**
1949 * WordPress dependencies
1950 */
1951
1952
1953
1954 /**
1955 * Internal dependencies
1956 */
1957
1958
1959
1960
1961 const PluginsMenuItem = props => // Menu item is marked with unstable prop for backward compatibility.
1962 // They are removed so they don't leak to DOM elements.
1963 // @see https://github.com/WordPress/gutenberg/issues/14457
1964 (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, (0,external_lodash_namespaceObject.omit)(props, ['__unstableExplicitMenuItem', '__unstableTarget']));
1965
1966 function ComplementaryAreaMoreMenuItem(_ref) {
1967 let {
1968 scope,
1969 target,
1970 __unstableExplicitMenuItem,
1971 ...props
1972 } = _ref;
1973 return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, extends_extends({
1974 as: toggleProps => {
1975 return (0,external_wp_element_namespaceObject.createElement)(action_item, extends_extends({
1976 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
1977 __unstableTarget: `${scope}/${target}`,
1978 as: PluginsMenuItem,
1979 name: `${scope}/plugin-more-menu`
1980 }, toggleProps));
1981 },
1982 role: "menuitemcheckbox",
1983 selectedIcon: library_check,
1984 name: target,
1985 scope: scope
1986 }, props));
1987 }
1988
1989 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
1990
1991
1992
1993 /**
1994 * External dependencies
1995 */
1996
1997
1998 /**
1999 * WordPress dependencies
2000 */
2001
2002
2003
2004 function PinnedItems(_ref) {
2005 let {
2006 scope,
2007 ...props
2008 } = _ref;
2009 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, extends_extends({
2010 name: `PinnedItems/${scope}`
2011 }, props));
2012 }
2013
2014 function PinnedItemsSlot(_ref2) {
2015 let {
2016 scope,
2017 className,
2018 ...props
2019 } = _ref2;
2020 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, extends_extends({
2021 name: `PinnedItems/${scope}`
2022 }, props), fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && (0,external_wp_element_namespaceObject.createElement)("div", {
2023 className: classnames_default()(className, 'interface-pinned-items')
2024 }, fills));
2025 }
2026
2027 PinnedItems.Slot = PinnedItemsSlot;
2028 /* harmony default export */ var pinned_items = (PinnedItems);
2029
2030 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
2031
2032
2033
2034 /**
2035 * External dependencies
2036 */
2037
2038 /**
2039 * WordPress dependencies
2040 */
2041
2042
2043
2044
2045
2046
2047
2048 /**
2049 * Internal dependencies
2050 */
2051
2052
2053
2054
2055
2056
2057
2058
2059 function ComplementaryAreaSlot(_ref) {
2060 let {
2061 scope,
2062 ...props
2063 } = _ref;
2064 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, extends_extends({
2065 name: `ComplementaryArea/${scope}`
2066 }, props));
2067 }
2068
2069 function ComplementaryAreaFill(_ref2) {
2070 let {
2071 scope,
2072 children,
2073 className
2074 } = _ref2;
2075 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
2076 name: `ComplementaryArea/${scope}`
2077 }, (0,external_wp_element_namespaceObject.createElement)("div", {
2078 className: className
2079 }, children));
2080 }
2081
2082 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
2083 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
2084 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
2085 const {
2086 enableComplementaryArea,
2087 disableComplementaryArea
2088 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
2089 (0,external_wp_element_namespaceObject.useEffect)(() => {
2090 // If the complementary area is active and the editor is switching from a big to a small window size.
2091 if (isActive && isSmall && !previousIsSmall.current) {
2092 // Disable the complementary area.
2093 disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big.
2094
2095 shouldOpenWhenNotSmall.current = true;
2096 } else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size
2097 // and we are going from a small to big window size.
2098 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
2099 // Remove the flag indicating the complementary area should be enabled.
2100 shouldOpenWhenNotSmall.current = false; // Enable the complementary area.
2101
2102 enableComplementaryArea(scope, identifier);
2103 } else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active,
2104 // remove the flag.
2105 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
2106 shouldOpenWhenNotSmall.current = false;
2107 }
2108
2109 if (isSmall !== previousIsSmall.current) {
2110 previousIsSmall.current = isSmall;
2111 }
2112 }, [isActive, isSmall, scope, identifier, activeArea]);
2113 }
2114
2115 function ComplementaryArea(_ref3) {
2116 let {
2117 children,
2118 className,
2119 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
2120 identifier,
2121 header,
2122 headerClassName,
2123 icon,
2124 isPinnable = true,
2125 panelClassName,
2126 scope,
2127 name,
2128 smallScreenTitle,
2129 title,
2130 toggleShortcut,
2131 isActiveByDefault,
2132 showIconLabels = false
2133 } = _ref3;
2134 const {
2135 isActive,
2136 isPinned,
2137 activeArea,
2138 isSmall,
2139 isLarge
2140 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
2141 const {
2142 getActiveComplementaryArea,
2143 isItemPinned
2144 } = select(store);
2145
2146 const _activeArea = getActiveComplementaryArea(scope);
2147
2148 return {
2149 isActive: _activeArea === identifier,
2150 isPinned: isItemPinned(scope, identifier),
2151 activeArea: _activeArea,
2152 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
2153 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large')
2154 };
2155 }, [identifier, scope]);
2156 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
2157 const {
2158 enableComplementaryArea,
2159 disableComplementaryArea,
2160 pinItem,
2161 unpinItem
2162 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
2163 (0,external_wp_element_namespaceObject.useEffect)(() => {
2164 if (isActiveByDefault && activeArea === undefined && !isSmall) {
2165 enableComplementaryArea(scope, identifier);
2166 }
2167 }, [activeArea, isActiveByDefault, scope, identifier, isSmall]);
2168 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, {
2169 scope: scope
2170 }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, {
2171 scope: scope,
2172 identifier: identifier,
2173 isPressed: isActive && (!showIconLabels || isLarge),
2174 "aria-expanded": isActive,
2175 label: title,
2176 icon: showIconLabels ? library_check : icon,
2177 showTooltip: !showIconLabels,
2178 variant: showIconLabels ? 'tertiary' : undefined
2179 })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
2180 target: name,
2181 scope: scope,
2182 icon: icon
2183 }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, {
2184 className: classnames_default()('interface-complementary-area', className),
2185 scope: scope
2186 }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, {
2187 className: headerClassName,
2188 closeLabel: closeLabel,
2189 onClose: () => disableComplementaryArea(scope),
2190 smallScreenTitle: smallScreenTitle,
2191 toggleButtonProps: {
2192 label: closeLabel,
2193 shortcut: toggleShortcut,
2194 scope,
2195 identifier
2196 }
2197 }, 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, {
2198 className: "interface-complementary-area__pin-unpin-item",
2199 icon: isPinned ? star_filled : star_empty,
2200 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
2201 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
2202 isPressed: isPinned,
2203 "aria-expanded": isPinned
2204 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, {
2205 className: panelClassName
2206 }, children)));
2207 }
2208
2209 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
2210 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
2211 /* harmony default export */ var complementary_area = (ComplementaryAreaWrapped);
2212
2213 ;// CONCATENATED MODULE: external ["wp","compose"]
2214 var external_wp_compose_namespaceObject = window["wp"]["compose"];
2215 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
2216
2217
2218
2219 /**
2220 * External dependencies
2221 */
2222
2223 /**
2224 * WordPress dependencies
2225 */
2226
2227 /**
2228 * WordPress dependencies
2229 */
2230
2231
2232
2233
2234
2235
2236 function useHTMLClass(className) {
2237 (0,external_wp_element_namespaceObject.useEffect)(() => {
2238 const element = document && document.querySelector(`html:not(.${className})`);
2239
2240 if (!element) {
2241 return;
2242 }
2243
2244 element.classList.toggle(className);
2245 return () => {
2246 element.classList.toggle(className);
2247 };
2248 }, [className]);
2249 }
2250
2251 function InterfaceSkeleton(_ref, ref) {
2252 let {
2253 footer,
2254 header,
2255 sidebar,
2256 secondarySidebar,
2257 notices,
2258 content,
2259 drawer,
2260 actions,
2261 labels,
2262 className,
2263 shortcuts
2264 } = _ref;
2265 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
2266 useHTMLClass('interface-interface-skeleton__html-container');
2267 const defaultLabels = {
2268 /* translators: accessibility text for the nav bar landmark region. */
2269 drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'),
2270
2271 /* translators: accessibility text for the top bar landmark region. */
2272 header: (0,external_wp_i18n_namespaceObject.__)('Header'),
2273
2274 /* translators: accessibility text for the content landmark region. */
2275 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
2276
2277 /* translators: accessibility text for the secondary sidebar landmark region. */
2278 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
2279
2280 /* translators: accessibility text for the settings landmark region. */
2281 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
2282
2283 /* translators: accessibility text for the publish landmark region. */
2284 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
2285
2286 /* translators: accessibility text for the footer landmark region. */
2287 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
2288 };
2289 const mergedLabels = { ...defaultLabels,
2290 ...labels
2291 };
2292 return (0,external_wp_element_namespaceObject.createElement)("div", extends_extends({}, navigateRegionsProps, {
2293 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]),
2294 className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer')
2295 }), !!drawer && (0,external_wp_element_namespaceObject.createElement)("div", {
2296 className: "interface-interface-skeleton__drawer",
2297 role: "region",
2298 "aria-label": mergedLabels.drawer,
2299 tabIndex: "-1"
2300 }, drawer), (0,external_wp_element_namespaceObject.createElement)("div", {
2301 className: "interface-interface-skeleton__editor"
2302 }, !!header && (0,external_wp_element_namespaceObject.createElement)("div", {
2303 className: "interface-interface-skeleton__header",
2304 role: "region",
2305 "aria-label": mergedLabels.header,
2306 tabIndex: "-1"
2307 }, header), (0,external_wp_element_namespaceObject.createElement)("div", {
2308 className: "interface-interface-skeleton__body"
2309 }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
2310 className: "interface-interface-skeleton__secondary-sidebar",
2311 role: "region",
2312 "aria-label": mergedLabels.secondarySidebar,
2313 tabIndex: "-1"
2314 }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", {
2315 className: "interface-interface-skeleton__notices"
2316 }, notices), (0,external_wp_element_namespaceObject.createElement)("div", {
2317 className: "interface-interface-skeleton__content",
2318 role: "region",
2319 "aria-label": mergedLabels.body,
2320 tabIndex: "-1"
2321 }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
2322 className: "interface-interface-skeleton__sidebar",
2323 role: "region",
2324 "aria-label": mergedLabels.sidebar,
2325 tabIndex: "-1"
2326 }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)("div", {
2327 className: "interface-interface-skeleton__actions",
2328 role: "region",
2329 "aria-label": mergedLabels.actions,
2330 tabIndex: "-1"
2331 }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)("div", {
2332 className: "interface-interface-skeleton__footer",
2333 role: "region",
2334 "aria-label": mergedLabels.footer,
2335 tabIndex: "-1"
2336 }, footer));
2337 }
2338
2339 /* harmony default export */ var interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
2340
2341 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
2342
2343
2344 /**
2345 * WordPress dependencies
2346 */
2347
2348 const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2349 xmlns: "http://www.w3.org/2000/svg",
2350 viewBox: "0 0 24 24"
2351 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2352 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
2353 }));
2354 /* harmony default export */ var more_vertical = (moreVertical);
2355
2356 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-dropdown/index.js
2357
2358
2359 /**
2360 * External dependencies
2361 */
2362
2363 /**
2364 * WordPress dependencies
2365 */
2366
2367
2368
2369
2370 function MoreMenuDropdown(_ref) {
2371 let {
2372 as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu,
2373 className,
2374
2375 /* translators: button label text should, if possible, be under 16 characters. */
2376 label = (0,external_wp_i18n_namespaceObject.__)('Options'),
2377 popoverProps,
2378 toggleProps,
2379 children
2380 } = _ref;
2381 return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, {
2382 className: classnames_default()('interface-more-menu-dropdown', className),
2383 icon: more_vertical,
2384 label: label,
2385 popoverProps: {
2386 position: 'bottom left',
2387 ...popoverProps,
2388 className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
2389 },
2390 toggleProps: {
2391 tooltipPosition: 'bottom',
2392 ...toggleProps
2393 }
2394 }, onClose => children(onClose));
2395 }
2396
2397 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal/index.js
2398
2399
2400 /**
2401 * WordPress dependencies
2402 */
2403
2404
2405 function PreferencesModal(_ref) {
2406 let {
2407 closeModal,
2408 children
2409 } = _ref;
2410 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
2411 className: "interface-preferences-modal",
2412 title: (0,external_wp_i18n_namespaceObject.__)('Preferences'),
2413 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
2414 onRequestClose: closeModal
2415 }, children);
2416 }
2417
2418 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
2419 /**
2420 * WordPress dependencies
2421 */
2422
2423 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
2424
2425 /**
2426 * Return an SVG icon.
2427 *
2428 * @param {IconProps} props icon is the SVG component to render
2429 * size is a number specifiying the icon size in pixels
2430 * Other props will be passed to wrapped SVG component
2431 *
2432 * @return {JSX.Element} Icon component
2433 */
2434
2435 function Icon(_ref) {
2436 let {
2437 icon,
2438 size = 24,
2439 ...props
2440 } = _ref;
2441 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
2442 width: size,
2443 height: size,
2444 ...props
2445 });
2446 }
2447
2448 /* harmony default export */ var icon = (Icon);
2449
2450 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left.js
2451
2452
2453 /**
2454 * WordPress dependencies
2455 */
2456
2457 const chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2458 xmlns: "http://www.w3.org/2000/svg",
2459 viewBox: "0 0 24 24"
2460 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2461 d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
2462 }));
2463 /* harmony default export */ var chevron_left = (chevronLeft);
2464
2465 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right.js
2466
2467
2468 /**
2469 * WordPress dependencies
2470 */
2471
2472 const chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2473 xmlns: "http://www.w3.org/2000/svg",
2474 viewBox: "0 0 24 24"
2475 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2476 d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
2477 }));
2478 /* harmony default export */ var chevron_right = (chevronRight);
2479
2480 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-tabs/index.js
2481
2482
2483 /**
2484 * WordPress dependencies
2485 */
2486
2487
2488
2489
2490
2491 const PREFERENCES_MENU = 'preferences-menu';
2492 function PreferencesModalTabs(_ref) {
2493 let {
2494 sections
2495 } = _ref;
2496 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); // This is also used to sync the two different rendered components
2497 // between small and large viewports.
2498
2499 const [activeMenu, setActiveMenu] = (0,external_wp_element_namespaceObject.useState)(PREFERENCES_MENU);
2500 /**
2501 * Create helper objects from `sections` for easier data handling.
2502 * `tabs` is used for creating the `TabPanel` and `sectionsContentMap`
2503 * is used for easier access to active tab's content.
2504 */
2505
2506 const {
2507 tabs,
2508 sectionsContentMap
2509 } = (0,external_wp_element_namespaceObject.useMemo)(() => {
2510 let mappedTabs = {
2511 tabs: [],
2512 sectionsContentMap: {}
2513 };
2514
2515 if (sections.length) {
2516 mappedTabs = sections.reduce((accumulator, _ref2) => {
2517 let {
2518 name,
2519 tabLabel: title,
2520 content
2521 } = _ref2;
2522 accumulator.tabs.push({
2523 name,
2524 title
2525 });
2526 accumulator.sectionsContentMap[name] = content;
2527 return accumulator;
2528 }, {
2529 tabs: [],
2530 sectionsContentMap: {}
2531 });
2532 }
2533
2534 return mappedTabs;
2535 }, [sections]);
2536 const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => sectionsContentMap[tab.name] || null, [sectionsContentMap]);
2537 let modalContent; // We render different components based on the viewport size.
2538
2539 if (isLargeViewport) {
2540 modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
2541 className: "interface-preferences__tabs",
2542 tabs: tabs,
2543 initialTabName: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined,
2544 onSelect: setActiveMenu,
2545 orientation: "vertical"
2546 }, getCurrentTab);
2547 } else {
2548 modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, {
2549 initialPath: "/",
2550 className: "interface-preferences__provider"
2551 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
2552 path: "/"
2553 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
2554 isBorderless: true,
2555 size: "small"
2556 }, (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 => {
2557 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, {
2558 key: tab.name,
2559 path: tab.name,
2560 as: external_wp_components_namespaceObject.__experimentalItem,
2561 isAction: true
2562 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
2563 justify: "space-between"
2564 }, (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, {
2565 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
2566 }))));
2567 }))))), sections.length && sections.map(section => {
2568 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, {
2569 key: `${section.name}-menu`,
2570 path: section.name
2571 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
2572 isBorderless: true,
2573 size: "large"
2574 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardHeader, {
2575 isBorderless: false,
2576 justify: "left",
2577 size: "small",
2578 gap: "6"
2579 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, {
2580 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
2581 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view')
2582 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
2583 size: "16"
2584 }, section.tabLabel)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, section.content)));
2585 }));
2586 }
2587
2588 return modalContent;
2589 }
2590
2591 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-section/index.js
2592
2593
2594 const Section = _ref => {
2595 let {
2596 description,
2597 title,
2598 children
2599 } = _ref;
2600 return (0,external_wp_element_namespaceObject.createElement)("fieldset", {
2601 className: "interface-preferences-modal__section"
2602 }, (0,external_wp_element_namespaceObject.createElement)("legend", null, (0,external_wp_element_namespaceObject.createElement)("h2", {
2603 className: "interface-preferences-modal__section-title"
2604 }, title), description && (0,external_wp_element_namespaceObject.createElement)("p", {
2605 className: "interface-preferences-modal__section-description"
2606 }, description)), children);
2607 };
2608
2609 /* harmony default export */ var preferences_modal_section = (Section);
2610
2611 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/preferences-modal-base-option/index.js
2612
2613
2614 /**
2615 * WordPress dependencies
2616 */
2617
2618
2619 function BaseOption(_ref) {
2620 let {
2621 help,
2622 label,
2623 isChecked,
2624 onChange,
2625 children
2626 } = _ref;
2627 return (0,external_wp_element_namespaceObject.createElement)("div", {
2628 className: "interface-preferences-modal__option"
2629 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
2630 help: help,
2631 label: label,
2632 checked: isChecked,
2633 onChange: onChange
2634 }), children);
2635 }
2636
2637 /* harmony default export */ var preferences_modal_base_option = (BaseOption);
2638
2639 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653 ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
2654
2655
2656
2657 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
2658 var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
2659 ;// CONCATENATED MODULE: external ["wp","a11y"]
2660 var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
2661 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/is-template-revertable.js
2662 /**
2663 * Check if a template is revertable to its original theme-provided template file.
2664 *
2665 * @param {Object} template The template entity to check.
2666 * @return {boolean} Whether the template is revertable.
2667 */
2668 function isTemplateRevertable(template) {
2669 if (!template) {
2670 return false;
2671 }
2672 /* eslint-disable camelcase */
2673
2674
2675 return (template === null || template === void 0 ? void 0 : template.source) === 'custom' && (template === null || template === void 0 ? void 0 : template.has_theme_file);
2676 /* eslint-enable camelcase */
2677 }
2678
2679 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/actions.js
2680 /**
2681 * WordPress dependencies
2682 */
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694 /**
2695 * Internal dependencies
2696 */
2697
2698
2699
2700 /**
2701 * Dispatches an action that toggles a feature flag.
2702 *
2703 * @param {string} featureName Feature name.
2704 */
2705
2706 function actions_toggleFeature(featureName) {
2707 return function (_ref) {
2708 let {
2709 registry
2710 } = _ref;
2711 external_wp_deprecated_default()("select( 'core/edit-site' ).toggleFeature( featureName )", {
2712 since: '6.0',
2713 alternative: "select( 'core/preferences').toggle( 'core/edit-site', featureName )"
2714 });
2715 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core/edit-site', featureName);
2716 };
2717 }
2718 /**
2719 * Action that changes the width of the editing canvas.
2720 *
2721 * @param {string} deviceType
2722 *
2723 * @return {Object} Action object.
2724 */
2725
2726 function __experimentalSetPreviewDeviceType(deviceType) {
2727 return {
2728 type: 'SET_PREVIEW_DEVICE_TYPE',
2729 deviceType
2730 };
2731 }
2732 /**
2733 * Action that sets a template, optionally fetching it from REST API.
2734 *
2735 * @param {number} templateId The template ID.
2736 * @param {string} templateSlug The template slug.
2737 * @return {Object} Action object.
2738 */
2739
2740 const setTemplate = (templateId, templateSlug) => async _ref2 => {
2741 let {
2742 dispatch,
2743 registry
2744 } = _ref2;
2745
2746 if (!templateSlug) {
2747 const template = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', templateId);
2748 templateSlug = template === null || template === void 0 ? void 0 : template.slug;
2749 }
2750
2751 dispatch({
2752 type: 'SET_TEMPLATE',
2753 templateId,
2754 page: {
2755 context: {
2756 templateSlug
2757 }
2758 }
2759 });
2760 };
2761 /**
2762 * Action that adds a new template and sets it as the current template.
2763 *
2764 * @param {Object} template The template.
2765 *
2766 * @return {Object} Action object used to set the current template.
2767 */
2768
2769 const addTemplate = template => async _ref3 => {
2770 let {
2771 dispatch,
2772 registry
2773 } = _ref3;
2774 const newTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
2775
2776 if (template.content) {
2777 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', 'wp_template', newTemplate.id, {
2778 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content)
2779 }, {
2780 undoIgnore: true
2781 });
2782 }
2783
2784 dispatch({
2785 type: 'SET_TEMPLATE',
2786 templateId: newTemplate.id,
2787 page: {
2788 context: {
2789 templateSlug: newTemplate.slug
2790 }
2791 }
2792 });
2793 };
2794 /**
2795 * Action that removes a template.
2796 *
2797 * @param {Object} template The template object.
2798 */
2799
2800 const removeTemplate = template => async _ref4 => {
2801 let {
2802 registry
2803 } = _ref4;
2804
2805 try {
2806 await registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', template.type, template.id, {
2807 force: true
2808 });
2809 const lastError = registry.select(external_wp_coreData_namespaceObject.store).getLastEntityDeleteError('postType', template.type, template.id);
2810
2811 if (lastError) {
2812 throw lastError;
2813 }
2814
2815 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
2816 /* translators: The template/part's name. */
2817 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), template.title.rendered), {
2818 type: 'snackbar'
2819 });
2820 } catch (error) {
2821 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template.');
2822 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
2823 type: 'snackbar'
2824 });
2825 }
2826 };
2827 /**
2828 * Action that sets a template part.
2829 *
2830 * @param {string} templatePartId The template part ID.
2831 *
2832 * @return {Object} Action object.
2833 */
2834
2835 function setTemplatePart(templatePartId) {
2836 return {
2837 type: 'SET_TEMPLATE_PART',
2838 templatePartId
2839 };
2840 }
2841 /**
2842 * Action that sets the home template ID to the template ID of the page resolved
2843 * from a given path.
2844 *
2845 * @param {number} homeTemplateId The template ID for the homepage.
2846 */
2847
2848 function setHomeTemplateId(homeTemplateId) {
2849 return {
2850 type: 'SET_HOME_TEMPLATE',
2851 homeTemplateId
2852 };
2853 }
2854 /**
2855 * Resolves the template for a page and displays both. If no path is given, attempts
2856 * to use the postId to generate a path like `?p=${ postId }`.
2857 *
2858 * @param {Object} page The page object.
2859 * @param {string} page.type The page type.
2860 * @param {string} page.slug The page slug.
2861 * @param {string} page.path The page path.
2862 * @param {Object} page.context The page context.
2863 *
2864 * @return {number} The resolved template ID for the page route.
2865 */
2866
2867 const setPage = page => async _ref5 => {
2868 var _page$context;
2869
2870 let {
2871 dispatch,
2872 registry
2873 } = _ref5;
2874
2875 if (!page.path && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId) {
2876 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 "/"
2877
2878 page.path = (0,external_wp_url_namespaceObject.getPathAndQueryString)(entity === null || entity === void 0 ? void 0 : entity.link);
2879 }
2880
2881 const template = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).__experimentalGetTemplateForLink(page.path);
2882
2883 if (!template) {
2884 return;
2885 }
2886
2887 dispatch({
2888 type: 'SET_PAGE',
2889 page: template.slug ? { ...page,
2890 context: { ...page.context,
2891 templateSlug: template.slug
2892 }
2893 } : page,
2894 templateId: template.id
2895 });
2896 return template.id;
2897 };
2898 /**
2899 * Action that sets the active navigation panel menu.
2900 *
2901 * @param {string} menu Menu prop of active menu.
2902 *
2903 * @return {Object} Action object.
2904 */
2905
2906 function setNavigationPanelActiveMenu(menu) {
2907 return {
2908 type: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',
2909 menu
2910 };
2911 }
2912 /**
2913 * Opens the navigation panel and sets its active menu at the same time.
2914 *
2915 * @param {string} menu Identifies the menu to open.
2916 */
2917
2918 function openNavigationPanelToMenu(menu) {
2919 return {
2920 type: 'OPEN_NAVIGATION_PANEL_TO_MENU',
2921 menu
2922 };
2923 }
2924 /**
2925 * Sets whether the navigation panel should be open.
2926 *
2927 * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It
2928 * does not toggle the state, but sets it directly.
2929 */
2930
2931 function setIsNavigationPanelOpened(isOpen) {
2932 return {
2933 type: 'SET_IS_NAVIGATION_PANEL_OPENED',
2934 isOpen
2935 };
2936 }
2937 /**
2938 * Opens or closes the inserter.
2939 *
2940 * @param {boolean|Object} value Whether the inserter should be
2941 * opened (true) or closed (false).
2942 * To specify an insertion point,
2943 * use an object.
2944 * @param {string} value.rootClientId The root client ID to insert at.
2945 * @param {number} value.insertionIndex The index to insert at.
2946 *
2947 * @return {Object} Action object.
2948 */
2949
2950 function setIsInserterOpened(value) {
2951 return {
2952 type: 'SET_IS_INSERTER_OPENED',
2953 value
2954 };
2955 }
2956 /**
2957 * Returns an action object used to update the settings.
2958 *
2959 * @param {Object} settings New settings.
2960 *
2961 * @return {Object} Action object.
2962 */
2963
2964 function updateSettings(settings) {
2965 return {
2966 type: 'UPDATE_SETTINGS',
2967 settings
2968 };
2969 }
2970 /**
2971 * Sets whether the list view panel should be open.
2972 *
2973 * @param {boolean} isOpen If true, opens the list view. If false, closes it.
2974 * It does not toggle the state, but sets it directly.
2975 */
2976
2977 function setIsListViewOpened(isOpen) {
2978 return {
2979 type: 'SET_IS_LIST_VIEW_OPENED',
2980 isOpen
2981 };
2982 }
2983 /**
2984 * Reverts a template to its original theme-provided file.
2985 *
2986 * @param {Object} template The template to revert.
2987 * @param {Object} [options]
2988 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
2989 * reverting the template. Default true.
2990 */
2991
2992 const revertTemplate = function (template) {
2993 let {
2994 allowUndo = true
2995 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2996 return async _ref6 => {
2997 let {
2998 registry
2999 } = _ref6;
3000
3001 if (!isTemplateRevertable(template)) {
3002 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
3003 type: 'snackbar'
3004 });
3005 return;
3006 }
3007
3008 try {
3009 var _fileTemplate$content;
3010
3011 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
3012
3013 if (!templateEntityConfig) {
3014 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
3015 type: 'snackbar'
3016 });
3017 return;
3018 }
3019
3020 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
3021 context: 'edit',
3022 source: 'theme'
3023 });
3024 const fileTemplate = await external_wp_apiFetch_default()({
3025 path: fileTemplatePath
3026 });
3027
3028 if (!fileTemplate) {
3029 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
3030 type: 'snackbar'
3031 });
3032 return;
3033 }
3034
3035 const serializeBlocks = _ref7 => {
3036 let {
3037 blocks: blocksForSerialization = []
3038 } = _ref7;
3039 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
3040 };
3041
3042 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
3043 // the revert in the header toolbar correctly.
3044
3045 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
3046 content: serializeBlocks,
3047 // Required to make the `undo` behave correctly.
3048 blocks: edited.blocks,
3049 // Required to revert the blocks in the editor.
3050 source: 'custom' // required to avoid turning the editor into a dirty state
3051
3052 }, {
3053 undoIgnore: true // Required to merge this edit with the last undo level.
3054
3055 });
3056 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);
3057 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
3058 content: serializeBlocks,
3059 blocks,
3060 source: 'theme'
3061 });
3062
3063 if (allowUndo) {
3064 const undoRevert = () => {
3065 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
3066 content: serializeBlocks,
3067 blocks: edited.blocks,
3068 source: 'custom'
3069 });
3070 };
3071
3072 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reverted.'), {
3073 type: 'snackbar',
3074 actions: [{
3075 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
3076 onClick: undoRevert
3077 }]
3078 });
3079 } else {
3080 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reverted.'));
3081 }
3082 } catch (error) {
3083 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
3084 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
3085 type: 'snackbar'
3086 });
3087 }
3088 };
3089 };
3090 /**
3091 * Action that opens an editor sidebar.
3092 *
3093 * @param {?string} name Sidebar name to be opened.
3094 */
3095
3096 const openGeneralSidebar = name => _ref8 => {
3097 let {
3098 registry
3099 } = _ref8;
3100 registry.dispatch(store).enableComplementaryArea(STORE_NAME, name);
3101 };
3102 /**
3103 * Action that closes the sidebar.
3104 */
3105
3106 const closeGeneralSidebar = () => _ref9 => {
3107 let {
3108 registry
3109 } = _ref9;
3110 registry.dispatch(store).disableComplementaryArea(STORE_NAME);
3111 };
3112 const switchEditorMode = mode => _ref10 => {
3113 let {
3114 registry
3115 } = _ref10;
3116 registry.dispatch('core/preferences').set('core/edit-site', 'editorMode', mode); // Unselect blocks when we switch to a non visual mode.
3117
3118 if (mode !== 'visual') {
3119 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
3120 }
3121
3122 if (mode === 'visual') {
3123 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
3124 } else if (mode === 'mosaic') {
3125 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Mosaic view selected'), 'assertive');
3126 }
3127 };
3128
3129 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
3130
3131
3132 var LEAF_KEY, hasWeakMap;
3133
3134 /**
3135 * Arbitrary value used as key for referencing cache object in WeakMap tree.
3136 *
3137 * @type {Object}
3138 */
3139 LEAF_KEY = {};
3140
3141 /**
3142 * Whether environment supports WeakMap.
3143 *
3144 * @type {boolean}
3145 */
3146 hasWeakMap = typeof WeakMap !== 'undefined';
3147
3148 /**
3149 * Returns the first argument as the sole entry in an array.
3150 *
3151 * @param {*} value Value to return.
3152 *
3153 * @return {Array} Value returned as entry in array.
3154 */
3155 function arrayOf( value ) {
3156 return [ value ];
3157 }
3158
3159 /**
3160 * Returns true if the value passed is object-like, or false otherwise. A value
3161 * is object-like if it can support property assignment, e.g. object or array.
3162 *
3163 * @param {*} value Value to test.
3164 *
3165 * @return {boolean} Whether value is object-like.
3166 */
3167 function isObjectLike( value ) {
3168 return !! value && 'object' === typeof value;
3169 }
3170
3171 /**
3172 * Creates and returns a new cache object.
3173 *
3174 * @return {Object} Cache object.
3175 */
3176 function createCache() {
3177 var cache = {
3178 clear: function() {
3179 cache.head = null;
3180 },
3181 };
3182
3183 return cache;
3184 }
3185
3186 /**
3187 * Returns true if entries within the two arrays are strictly equal by
3188 * reference from a starting index.
3189 *
3190 * @param {Array} a First array.
3191 * @param {Array} b Second array.
3192 * @param {number} fromIndex Index from which to start comparison.
3193 *
3194 * @return {boolean} Whether arrays are shallowly equal.
3195 */
3196 function isShallowEqual( a, b, fromIndex ) {
3197 var i;
3198
3199 if ( a.length !== b.length ) {
3200 return false;
3201 }
3202
3203 for ( i = fromIndex; i < a.length; i++ ) {
3204 if ( a[ i ] !== b[ i ] ) {
3205 return false;
3206 }
3207 }
3208
3209 return true;
3210 }
3211
3212 /**
3213 * Returns a memoized selector function. The getDependants function argument is
3214 * called before the memoized selector and is expected to return an immutable
3215 * reference or array of references on which the selector depends for computing
3216 * its own return value. The memoize cache is preserved only as long as those
3217 * dependant references remain the same. If getDependants returns a different
3218 * reference(s), the cache is cleared and the selector value regenerated.
3219 *
3220 * @param {Function} selector Selector function.
3221 * @param {Function} getDependants Dependant getter returning an immutable
3222 * reference or array of reference used in
3223 * cache bust consideration.
3224 *
3225 * @return {Function} Memoized selector.
3226 */
3227 /* harmony default export */ function rememo(selector, getDependants ) {
3228 var rootCache, getCache;
3229
3230 // Use object source as dependant if getter not provided
3231 if ( ! getDependants ) {
3232 getDependants = arrayOf;
3233 }
3234
3235 /**
3236 * Returns the root cache. If WeakMap is supported, this is assigned to the
3237 * root WeakMap cache set, otherwise it is a shared instance of the default
3238 * cache object.
3239 *
3240 * @return {(WeakMap|Object)} Root cache object.
3241 */
3242 function getRootCache() {
3243 return rootCache;
3244 }
3245
3246 /**
3247 * Returns the cache for a given dependants array. When possible, a WeakMap
3248 * will be used to create a unique cache for each set of dependants. This
3249 * is feasible due to the nature of WeakMap in allowing garbage collection
3250 * to occur on entries where the key object is no longer referenced. Since
3251 * WeakMap requires the key to be an object, this is only possible when the
3252 * dependant is object-like. The root cache is created as a hierarchy where
3253 * each top-level key is the first entry in a dependants set, the value a
3254 * WeakMap where each key is the next dependant, and so on. This continues
3255 * so long as the dependants are object-like. If no dependants are object-
3256 * like, then the cache is shared across all invocations.
3257 *
3258 * @see isObjectLike
3259 *
3260 * @param {Array} dependants Selector dependants.
3261 *
3262 * @return {Object} Cache object.
3263 */
3264 function getWeakMapCache( dependants ) {
3265 var caches = rootCache,
3266 isUniqueByDependants = true,
3267 i, dependant, map, cache;
3268
3269 for ( i = 0; i < dependants.length; i++ ) {
3270 dependant = dependants[ i ];
3271
3272 // Can only compose WeakMap from object-like key.
3273 if ( ! isObjectLike( dependant ) ) {
3274 isUniqueByDependants = false;
3275 break;
3276 }
3277
3278 // Does current segment of cache already have a WeakMap?
3279 if ( caches.has( dependant ) ) {
3280 // Traverse into nested WeakMap.
3281 caches = caches.get( dependant );
3282 } else {
3283 // Create, set, and traverse into a new one.
3284 map = new WeakMap();
3285 caches.set( dependant, map );
3286 caches = map;
3287 }
3288 }
3289
3290 // We use an arbitrary (but consistent) object as key for the last item
3291 // in the WeakMap to serve as our running cache.
3292 if ( ! caches.has( LEAF_KEY ) ) {
3293 cache = createCache();
3294 cache.isUniqueByDependants = isUniqueByDependants;
3295 caches.set( LEAF_KEY, cache );
3296 }
3297
3298 return caches.get( LEAF_KEY );
3299 }
3300
3301 // Assign cache handler by availability of WeakMap
3302 getCache = hasWeakMap ? getWeakMapCache : getRootCache;
3303
3304 /**
3305 * Resets root memoization cache.
3306 */
3307 function clear() {
3308 rootCache = hasWeakMap ? new WeakMap() : createCache();
3309 }
3310
3311 // eslint-disable-next-line jsdoc/check-param-names
3312 /**
3313 * The augmented selector call, considering first whether dependants have
3314 * changed before passing it to underlying memoize function.
3315 *
3316 * @param {Object} source Source object for derivation.
3317 * @param {...*} extraArgs Additional arguments to pass to selector.
3318 *
3319 * @return {*} Selector result.
3320 */
3321 function callSelector( /* source, ...extraArgs */ ) {
3322 var len = arguments.length,
3323 cache, node, i, args, dependants;
3324
3325 // Create copy of arguments (avoid leaking deoptimization).
3326 args = new Array( len );
3327 for ( i = 0; i < len; i++ ) {
3328 args[ i ] = arguments[ i ];
3329 }
3330
3331 dependants = getDependants.apply( null, args );
3332 cache = getCache( dependants );
3333
3334 // If not guaranteed uniqueness by dependants (primitive type or lack
3335 // of WeakMap support), shallow compare against last dependants and, if
3336 // references have changed, destroy cache to recalculate result.
3337 if ( ! cache.isUniqueByDependants ) {
3338 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
3339 cache.clear();
3340 }
3341
3342 cache.lastDependants = dependants;
3343 }
3344
3345 node = cache.head;
3346 while ( node ) {
3347 // Check whether node arguments match arguments
3348 if ( ! isShallowEqual( node.args, args, 1 ) ) {
3349 node = node.next;
3350 continue;
3351 }
3352
3353 // At this point we can assume we've found a match
3354
3355 // Surface matched node to head if not already
3356 if ( node !== cache.head ) {
3357 // Adjust siblings to point to each other.
3358 node.prev.next = node.next;
3359 if ( node.next ) {
3360 node.next.prev = node.prev;
3361 }
3362
3363 node.next = cache.head;
3364 node.prev = null;
3365 cache.head.prev = node;
3366 cache.head = node;
3367 }
3368
3369 // Return immediately
3370 return node.val;
3371 }
3372
3373 // No cached value found. Continue to insertion phase:
3374
3375 node = {
3376 // Generate the result from original function
3377 val: selector.apply( null, args ),
3378 };
3379
3380 // Avoid including the source object in the cache.
3381 args[ 0 ] = null;
3382 node.args = args;
3383
3384 // Don't need to check whether node is already head, since it would
3385 // have been returned above already if it was
3386
3387 // Shift existing head down list
3388 if ( cache.head ) {
3389 cache.head.prev = node;
3390 node.next = cache.head;
3391 }
3392
3393 cache.head = node;
3394
3395 return node.val;
3396 }
3397
3398 callSelector.getDependants = getDependants;
3399 callSelector.clear = clear;
3400 clear();
3401
3402 return callSelector;
3403 }
3404
3405 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js
3406 /**
3407 * External dependencies
3408 */
3409
3410 /**
3411 * Internal dependencies
3412 */
3413
3414
3415 function isTemplateSuperseded(slug, existingSlugs, showOnFront) {
3416 if (!TEMPLATE_OVERRIDES[slug]) {
3417 return false;
3418 } // `home` template is unused if it is superseded by `front-page`
3419 // or "show on front" is set to show a page rather than blog posts.
3420
3421
3422 if (slug === 'home' && showOnFront !== 'posts') {
3423 return true;
3424 }
3425
3426 return TEMPLATE_OVERRIDES[slug].every(overrideSlug => existingSlugs.includes(overrideSlug) || isTemplateSuperseded(overrideSlug, existingSlugs, showOnFront));
3427 }
3428 function getTemplateLocation(slug) {
3429 const isTopLevelTemplate = TEMPLATES_TOP_LEVEL.includes(slug);
3430
3431 if (isTopLevelTemplate) {
3432 return MENU_TEMPLATES;
3433 }
3434
3435 const isGeneralTemplate = TEMPLATES_GENERAL.includes(slug);
3436
3437 if (isGeneralTemplate) {
3438 return MENU_TEMPLATES_GENERAL;
3439 }
3440
3441 const isPostsTemplate = TEMPLATES_POSTS_PREFIXES.some(prefix => slug.startsWith(prefix));
3442
3443 if (isPostsTemplate) {
3444 return MENU_TEMPLATES_POSTS;
3445 }
3446
3447 const isPagesTemplate = TEMPLATES_PAGES_PREFIXES.some(prefix => slug.startsWith(prefix));
3448
3449 if (isPagesTemplate) {
3450 return MENU_TEMPLATES_PAGES;
3451 }
3452
3453 return MENU_TEMPLATES_GENERAL;
3454 }
3455 function getUnusedTemplates(templates, showOnFront) {
3456 const templateSlugs = map(templates, 'slug');
3457 const supersededTemplates = templates.filter(_ref => {
3458 let {
3459 slug
3460 } = _ref;
3461 return isTemplateSuperseded(slug, templateSlugs, showOnFront);
3462 });
3463 return supersededTemplates;
3464 }
3465 function getTemplatesLocationMap(templates) {
3466 return templates.reduce((obj, template) => {
3467 obj[template.slug] = getTemplateLocation(template.slug);
3468 return obj;
3469 }, {});
3470 }
3471
3472 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/selectors.js
3473 /**
3474 * External dependencies
3475 */
3476
3477
3478 /**
3479 * WordPress dependencies
3480 */
3481
3482
3483
3484
3485
3486
3487
3488
3489 /**
3490 * Internal dependencies
3491 */
3492
3493
3494
3495 /**
3496 * @typedef {'template'|'template_type'} TemplateType Template type.
3497 */
3498
3499 /**
3500 * Helper for getting a preference from the preferences store.
3501 *
3502 * This is only present so that `getSettings` doesn't need to be made a
3503 * registry selector.
3504 *
3505 * It's unstable because the selector needs to be exported and so part of the
3506 * public API to work.
3507 */
3508
3509 const __unstableGetPreference = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, name) => select(external_wp_preferences_namespaceObject.store).get('core/edit-site', name));
3510 /**
3511 * Returns whether the given feature is enabled or not.
3512 *
3513 * @param {Object} state Global application state.
3514 * @param {string} featureName Feature slug.
3515 *
3516 * @return {boolean} Is active.
3517 */
3518
3519 function selectors_isFeatureActive(state, featureName) {
3520 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive`, {
3521 since: '6.0',
3522 alternative: `select( 'core/preferences' ).get`
3523 });
3524 return !!__unstableGetPreference(state, featureName);
3525 }
3526 /**
3527 * Returns the current editing canvas device type.
3528 *
3529 * @param {Object} state Global application state.
3530 *
3531 * @return {string} Device type.
3532 */
3533
3534 function __experimentalGetPreviewDeviceType(state) {
3535 return state.deviceType;
3536 }
3537 /**
3538 * Returns whether the current user can create media or not.
3539 *
3540 * @param {Object} state Global application state.
3541 *
3542 * @return {Object} Whether the current user can create media or not.
3543 */
3544
3545 const getCanUserCreateMedia = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => select(external_wp_coreData_namespaceObject.store).canUser('create', 'media'));
3546 /**
3547 * Returns any available Reusable blocks.
3548 *
3549 * @param {Object} state Global application state.
3550 *
3551 * @return {Array} The available reusable blocks.
3552 */
3553
3554 const getReusableBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3555 const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web';
3556 return isWeb ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', {
3557 per_page: -1
3558 }) : [];
3559 });
3560 /**
3561 * Returns the settings, taking into account active features and permissions.
3562 *
3563 * @param {Object} state Global application state.
3564 * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.
3565 *
3566 * @return {Object} Settings.
3567 */
3568
3569 const getSettings = rememo((state, setIsInserterOpen) => {
3570 const settings = { ...state.settings,
3571 outlineMode: true,
3572 focusMode: !!__unstableGetPreference(state, 'focusMode'),
3573 hasFixedToolbar: !!__unstableGetPreference(state, 'fixedToolbar'),
3574 keepCaretInsideBlock: !!__unstableGetPreference(state, 'keepCaretInsideBlock'),
3575 showIconLabels: !!__unstableGetPreference(state, 'showIconLabels'),
3576 __experimentalSetIsInserterOpened: setIsInserterOpen,
3577 __experimentalReusableBlocks: getReusableBlocks(state),
3578 __experimentalPreferPatternsOnRoot: 'wp_template' === getEditedPostType(state)
3579 };
3580 const canUserCreateMedia = getCanUserCreateMedia(state);
3581
3582 if (!canUserCreateMedia) {
3583 return settings;
3584 }
3585
3586 settings.mediaUpload = _ref => {
3587 let {
3588 onError,
3589 ...rest
3590 } = _ref;
3591 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
3592 wpAllowedMimeTypes: state.settings.allowedMimeTypes,
3593 onError: _ref2 => {
3594 let {
3595 message
3596 } = _ref2;
3597 return onError(message);
3598 },
3599 ...rest
3600 });
3601 };
3602
3603 return settings;
3604 }, state => [getCanUserCreateMedia(state), state.settings, __unstableGetPreference(state, 'focusMode'), __unstableGetPreference(state, 'fixedToolbar'), __unstableGetPreference(state, 'keepCaretInsideBlock'), __unstableGetPreference(state, 'showIconLabels'), getReusableBlocks(state), getEditedPostType(state)]);
3605 /**
3606 * Returns the current home template ID.
3607 *
3608 * @param {Object} state Global application state.
3609 *
3610 * @return {number?} Home template ID.
3611 */
3612
3613 function getHomeTemplateId(state) {
3614 return state.homeTemplateId;
3615 }
3616
3617 function getCurrentEditedPost(state) {
3618 return state.editedPost;
3619 }
3620 /**
3621 * Returns the current edited post type (wp_template or wp_template_part).
3622 *
3623 * @param {Object} state Global application state.
3624 *
3625 * @return {TemplateType?} Template type.
3626 */
3627
3628
3629 function getEditedPostType(state) {
3630 return getCurrentEditedPost(state).type;
3631 }
3632 /**
3633 * Returns the ID of the currently edited template or template part.
3634 *
3635 * @param {Object} state Global application state.
3636 *
3637 * @return {string?} Post ID.
3638 */
3639
3640 function getEditedPostId(state) {
3641 return getCurrentEditedPost(state).id;
3642 }
3643 /**
3644 * Returns the current page object.
3645 *
3646 * @param {Object} state Global application state.
3647 *
3648 * @return {Object} Page.
3649 */
3650
3651 function getPage(state) {
3652 return getCurrentEditedPost(state).page;
3653 }
3654 /**
3655 * Returns the active menu in the navigation panel.
3656 *
3657 * @param {Object} state Global application state.
3658 *
3659 * @return {string} Active menu.
3660 */
3661
3662 function getNavigationPanelActiveMenu(state) {
3663 return state.navigationPanel.menu;
3664 }
3665 /**
3666 * Returns the current template or template part's corresponding
3667 * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.
3668 *
3669 * @param {Object} state Global application state.
3670 *
3671 * @return {string} The current template or template part's sub menu.
3672 */
3673
3674 const getCurrentTemplateNavigationPanelSubMenu = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3675 const templateType = getEditedPostType(state);
3676 const templateId = getEditedPostId(state);
3677 const template = templateId ? select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', templateType, templateId) : null;
3678
3679 if (!template) {
3680 return MENU_ROOT;
3681 }
3682
3683 if ('wp_template_part' === templateType) {
3684 var _TEMPLATE_PARTS_SUB_M;
3685
3686 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;
3687 }
3688
3689 const templates = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template');
3690 const showOnFront = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('root', 'site').show_on_front;
3691
3692 if (isTemplateSuperseded(template.slug, (0,external_lodash_namespaceObject.map)(templates, 'slug'), showOnFront)) {
3693 return MENU_TEMPLATES_UNUSED;
3694 }
3695
3696 return getTemplateLocation(template.slug);
3697 });
3698 /**
3699 * Returns the current opened/closed state of the navigation panel.
3700 *
3701 * @param {Object} state Global application state.
3702 *
3703 * @return {boolean} True if the navigation panel should be open; false if closed.
3704 */
3705
3706 function isNavigationOpened(state) {
3707 return state.navigationPanel.isOpen;
3708 }
3709 /**
3710 * Returns the current opened/closed state of the inserter panel.
3711 *
3712 * @param {Object} state Global application state.
3713 *
3714 * @return {boolean} True if the inserter panel should be open; false if closed.
3715 */
3716
3717 function isInserterOpened(state) {
3718 return !!state.blockInserterPanel;
3719 }
3720 /**
3721 * Get the insertion point for the inserter.
3722 *
3723 * @param {Object} state Global application state.
3724 *
3725 * @return {Object} The root client ID, index to insert at and starting filter value.
3726 */
3727
3728 function __experimentalGetInsertionPoint(state) {
3729 const {
3730 rootClientId,
3731 insertionIndex,
3732 filterValue
3733 } = state.blockInserterPanel;
3734 return {
3735 rootClientId,
3736 insertionIndex,
3737 filterValue
3738 };
3739 }
3740 /**
3741 * Returns the current opened/closed state of the list view panel.
3742 *
3743 * @param {Object} state Global application state.
3744 *
3745 * @return {boolean} True if the list view panel should be open; false if closed.
3746 */
3747
3748 function isListViewOpened(state) {
3749 return state.listViewPanel;
3750 }
3751 /**
3752 * Returns the template parts and their blocks for the current edited template.
3753 *
3754 * @param {Object} state Global application state.
3755 * @return {Array} Template parts and their blocks in an array.
3756 */
3757
3758 const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3759 var _template$blocks;
3760
3761 const templateType = getEditedPostType(state);
3762 const templateId = getEditedPostId(state);
3763 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', templateType, templateId);
3764 const templateParts = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template_part', {
3765 per_page: -1
3766 });
3767 const templatePartsById = (0,external_lodash_namespaceObject.keyBy)(templateParts, templatePart => templatePart.id);
3768 return ((_template$blocks = template.blocks) !== null && _template$blocks !== void 0 ? _template$blocks : []).filter(block => (0,external_wp_blocks_namespaceObject.isTemplatePart)(block)).map(block => {
3769 const {
3770 attributes: {
3771 theme,
3772 slug
3773 }
3774 } = block;
3775 const templatePartId = `${theme}//${slug}`;
3776 const templatePart = templatePartsById[templatePartId];
3777 return {
3778 templatePart,
3779 block
3780 };
3781 }).filter(_ref3 => {
3782 let {
3783 templatePart
3784 } = _ref3;
3785 return !!templatePart;
3786 });
3787 });
3788 /**
3789 * Returns the current editing mode.
3790 *
3791 * @param {Object} state Global application state.
3792 *
3793 * @return {string} Editing mode.
3794 */
3795
3796 function getEditorMode(state) {
3797 return __unstableGetPreference(state, 'editorMode');
3798 }
3799
3800 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/store/index.js
3801 /**
3802 * WordPress dependencies
3803 */
3804
3805 /**
3806 * Internal dependencies
3807 */
3808
3809
3810
3811
3812
3813 const storeConfig = {
3814 reducer: reducer,
3815 actions: store_actions_namespaceObject,
3816 selectors: store_selectors_namespaceObject
3817 };
3818 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig);
3819 (0,external_wp_data_namespaceObject.register)(store_store);
3820
3821 ;// CONCATENATED MODULE: ./node_modules/history/index.js
3822 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=""}
3823 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)}
3824 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}
3825 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,
3826 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",
3827 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:
3828 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)}}}};
3829 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:
3830 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?
3831 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},
3832 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)}}}};
3833 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:
3834 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===
3835 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"===
3836 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)}}};
3837
3838 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/history.js
3839 /**
3840 * External dependencies
3841 */
3842
3843 /**
3844 * WordPress dependencies
3845 */
3846
3847
3848 const history_history = createBrowserHistory();
3849 const originalHistoryPush = history_history.push;
3850 const originalHistoryReplace = history_history.replace;
3851
3852 function push(params, state) {
3853 return originalHistoryPush.call(history_history, (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params), state);
3854 }
3855
3856 function replace(params, state) {
3857 return originalHistoryReplace.call(history_history, (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params), state);
3858 }
3859
3860 history_history.push = push;
3861 history_history.replace = replace;
3862 /* harmony default export */ var utils_history = (history_history);
3863
3864 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/index.js
3865
3866
3867 /**
3868 * WordPress dependencies
3869 */
3870
3871 /**
3872 * Internal dependencies
3873 */
3874
3875
3876 const RoutesContext = (0,external_wp_element_namespaceObject.createContext)();
3877 const HistoryContext = (0,external_wp_element_namespaceObject.createContext)();
3878 function useLocation() {
3879 return (0,external_wp_element_namespaceObject.useContext)(RoutesContext);
3880 }
3881 function useHistory() {
3882 return (0,external_wp_element_namespaceObject.useContext)(HistoryContext);
3883 }
3884
3885 function getLocationWithParams(location) {
3886 const searchParams = new URLSearchParams(location.search);
3887 return { ...location,
3888 params: Object.fromEntries(searchParams.entries())
3889 };
3890 }
3891
3892 function Routes(_ref) {
3893 let {
3894 children
3895 } = _ref;
3896 const [location, setLocation] = (0,external_wp_element_namespaceObject.useState)(() => getLocationWithParams(utils_history.location));
3897 (0,external_wp_element_namespaceObject.useEffect)(() => {
3898 return utils_history.listen(_ref2 => {
3899 let {
3900 location: updatedLocation
3901 } = _ref2;
3902 setLocation(getLocationWithParams(updatedLocation));
3903 });
3904 }, []);
3905 return (0,external_wp_element_namespaceObject.createElement)(HistoryContext.Provider, {
3906 value: utils_history
3907 }, (0,external_wp_element_namespaceObject.createElement)(RoutesContext.Provider, {
3908 value: location
3909 }, children(location)));
3910 }
3911
3912 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
3913 var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
3914 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
3915
3916
3917 /**
3918 * WordPress dependencies
3919 */
3920
3921 const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
3922 xmlns: "http://www.w3.org/2000/svg",
3923 viewBox: "0 0 24 24"
3924 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
3925 d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
3926 }));
3927 /* harmony default export */ var library_plus = (plus);
3928
3929 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
3930
3931
3932 /**
3933 * WordPress dependencies
3934 */
3935
3936 const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
3937 viewBox: "0 0 24 24",
3938 xmlns: "http://www.w3.org/2000/svg"
3939 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
3940 d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
3941 }));
3942 /* harmony default export */ var list_view = (listView);
3943
3944 ;// CONCATENATED MODULE: external ["wp","keycodes"]
3945 var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
3946 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
3947
3948
3949 /**
3950 * WordPress dependencies
3951 */
3952
3953 const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
3954 xmlns: "http://www.w3.org/2000/svg",
3955 viewBox: "0 0 24 24"
3956 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
3957 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"
3958 }));
3959 /* harmony default export */ var library_external = (external);
3960
3961 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/config.js
3962 /**
3963 * WordPress dependencies
3964 */
3965
3966 const textFormattingShortcuts = [{
3967 keyCombination: {
3968 modifier: 'primary',
3969 character: 'b'
3970 },
3971 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
3972 }, {
3973 keyCombination: {
3974 modifier: 'primary',
3975 character: 'i'
3976 },
3977 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
3978 }, {
3979 keyCombination: {
3980 modifier: 'primary',
3981 character: 'k'
3982 },
3983 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
3984 }, {
3985 keyCombination: {
3986 modifier: 'primaryShift',
3987 character: 'k'
3988 },
3989 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
3990 }, {
3991 keyCombination: {
3992 modifier: 'primary',
3993 character: 'u'
3994 },
3995 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
3996 }];
3997
3998 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/shortcut.js
3999
4000
4001 /**
4002 * External dependencies
4003 */
4004
4005 /**
4006 * WordPress dependencies
4007 */
4008
4009
4010
4011
4012 function KeyCombination(_ref) {
4013 let {
4014 keyCombination,
4015 forceAriaLabel
4016 } = _ref;
4017 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
4018 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
4019 return (0,external_wp_element_namespaceObject.createElement)("kbd", {
4020 className: "edit-site-keyboard-shortcut-help-modal__shortcut-key-combination",
4021 "aria-label": forceAriaLabel || ariaLabel
4022 }, (0,external_lodash_namespaceObject.castArray)(shortcut).map((character, index) => {
4023 if (character === '+') {
4024 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
4025 key: index
4026 }, character);
4027 }
4028
4029 return (0,external_wp_element_namespaceObject.createElement)("kbd", {
4030 key: index,
4031 className: "edit-site-keyboard-shortcut-help-modal__shortcut-key"
4032 }, character);
4033 }));
4034 }
4035
4036 function Shortcut(_ref2) {
4037 let {
4038 description,
4039 keyCombination,
4040 aliases = [],
4041 ariaLabel
4042 } = _ref2;
4043 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
4044 className: "edit-site-keyboard-shortcut-help-modal__shortcut-description"
4045 }, description), (0,external_wp_element_namespaceObject.createElement)("div", {
4046 className: "edit-site-keyboard-shortcut-help-modal__shortcut-term"
4047 }, (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
4048 keyCombination: keyCombination,
4049 forceAriaLabel: ariaLabel
4050 }), aliases.map((alias, index) => (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
4051 keyCombination: alias,
4052 forceAriaLabel: ariaLabel,
4053 key: index
4054 }))));
4055 }
4056
4057 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
4058
4059
4060 /**
4061 * WordPress dependencies
4062 */
4063
4064
4065 /**
4066 * Internal dependencies
4067 */
4068
4069
4070 function DynamicShortcut(_ref) {
4071 let {
4072 name
4073 } = _ref;
4074 const {
4075 keyCombination,
4076 description,
4077 aliases
4078 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4079 const {
4080 getShortcutKeyCombination,
4081 getShortcutDescription,
4082 getShortcutAliases
4083 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
4084 return {
4085 keyCombination: getShortcutKeyCombination(name),
4086 aliases: getShortcutAliases(name),
4087 description: getShortcutDescription(name)
4088 };
4089 }, [name]);
4090
4091 if (!keyCombination) {
4092 return null;
4093 }
4094
4095 return (0,external_wp_element_namespaceObject.createElement)(Shortcut, {
4096 keyCombination: keyCombination,
4097 description: description,
4098 aliases: aliases
4099 });
4100 }
4101
4102 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcut-help-modal/index.js
4103
4104
4105 /**
4106 * External dependencies
4107 */
4108
4109
4110 /**
4111 * WordPress dependencies
4112 */
4113
4114
4115
4116
4117
4118 /**
4119 * Internal dependencies
4120 */
4121
4122
4123
4124
4125
4126 const ShortcutList = _ref => {
4127 let {
4128 shortcuts
4129 } = _ref;
4130 return (
4131 /*
4132 * Disable reason: The `list` ARIA role is redundant but
4133 * Safari+VoiceOver won't announce the list otherwise.
4134 */
4135
4136 /* eslint-disable jsx-a11y/no-redundant-roles */
4137 (0,external_wp_element_namespaceObject.createElement)("ul", {
4138 className: "edit-site-keyboard-shortcut-help-modal__shortcut-list",
4139 role: "list"
4140 }, shortcuts.map((shortcut, index) => (0,external_wp_element_namespaceObject.createElement)("li", {
4141 className: "edit-site-keyboard-shortcut-help-modal__shortcut",
4142 key: index
4143 }, (0,external_lodash_namespaceObject.isString)(shortcut) ? (0,external_wp_element_namespaceObject.createElement)(DynamicShortcut, {
4144 name: shortcut
4145 }) : (0,external_wp_element_namespaceObject.createElement)(Shortcut, shortcut))))
4146 /* eslint-enable jsx-a11y/no-redundant-roles */
4147
4148 );
4149 };
4150
4151 const ShortcutSection = _ref2 => {
4152 let {
4153 title,
4154 shortcuts,
4155 className
4156 } = _ref2;
4157 return (0,external_wp_element_namespaceObject.createElement)("section", {
4158 className: classnames_default()('edit-site-keyboard-shortcut-help-modal__section', className)
4159 }, !!title && (0,external_wp_element_namespaceObject.createElement)("h2", {
4160 className: "edit-site-keyboard-shortcut-help-modal__section-title"
4161 }, title), (0,external_wp_element_namespaceObject.createElement)(ShortcutList, {
4162 shortcuts: shortcuts
4163 }));
4164 };
4165
4166 const ShortcutCategorySection = _ref3 => {
4167 let {
4168 title,
4169 categoryName,
4170 additionalShortcuts = []
4171 } = _ref3;
4172 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
4173 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
4174 }, [categoryName]);
4175 return (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4176 title: title,
4177 shortcuts: categoryShortcuts.concat(additionalShortcuts)
4178 });
4179 };
4180
4181 function KeyboardShortcutHelpModal(_ref4) {
4182 let {
4183 isModalActive,
4184 toggleModal
4185 } = _ref4;
4186
4187 if (!isModalActive) {
4188 return null;
4189 }
4190
4191 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
4192 className: "edit-site-keyboard-shortcut-help-modal",
4193 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
4194 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
4195 onRequestClose: toggleModal
4196 }, (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4197 className: "edit-site-keyboard-shortcut-help-modal__main-shortcuts",
4198 shortcuts: ['core/edit-site/keyboard-shortcuts']
4199 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4200 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
4201 categoryName: "global"
4202 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4203 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
4204 categoryName: "selection"
4205 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
4206 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
4207 categoryName: "block",
4208 additionalShortcuts: [{
4209 keyCombination: {
4210 character: '/'
4211 },
4212 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
4213
4214 /* translators: The forward-slash character. e.g. '/'. */
4215 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
4216 }]
4217 }), (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
4218 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
4219 shortcuts: textFormattingShortcuts
4220 }));
4221 }
4222
4223 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/preferences-modal/enable-feature.js
4224
4225
4226
4227 /**
4228 * WordPress dependencies
4229 */
4230
4231
4232
4233 function EnableFeature(props) {
4234 const {
4235 featureName,
4236 ...remainingProps
4237 } = props;
4238 const isChecked = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', featureName), [featureName]);
4239 const {
4240 toggle
4241 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
4242
4243 const onChange = () => toggle('core/edit-site', featureName);
4244
4245 return (0,external_wp_element_namespaceObject.createElement)(preferences_modal_base_option, extends_extends({
4246 onChange: onChange,
4247 isChecked: isChecked
4248 }, remainingProps));
4249 }
4250
4251 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/preferences-modal/index.js
4252
4253
4254 /**
4255 * WordPress dependencies
4256 */
4257
4258
4259
4260 /**
4261 * Internal dependencies
4262 */
4263
4264
4265 function EditSitePreferencesModal(_ref) {
4266 let {
4267 isModalActive,
4268 toggleModal
4269 } = _ref;
4270 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
4271 name: 'general',
4272 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
4273 content: (0,external_wp_element_namespaceObject.createElement)(preferences_modal_section, {
4274 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
4275 description: (0,external_wp_i18n_namespaceObject.__)('Customize options related to the block editor interface and editing flow.')
4276 }, (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4277 featureName: "focusMode",
4278 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
4279 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
4280 }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4281 featureName: "showIconLabels",
4282 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'),
4283 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons')
4284 }))
4285 }, {
4286 name: 'blocks',
4287 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
4288 content: (0,external_wp_element_namespaceObject.createElement)(preferences_modal_section, {
4289 title: (0,external_wp_i18n_namespaceObject.__)('Block interactions'),
4290 description: (0,external_wp_i18n_namespaceObject.__)('Customize how you interact with blocks in the block library and editing canvas.')
4291 }, (0,external_wp_element_namespaceObject.createElement)(EnableFeature, {
4292 featureName: "keepCaretInsideBlock",
4293 help: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'),
4294 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
4295 }))
4296 }]);
4297
4298 if (!isModalActive) {
4299 return null;
4300 }
4301
4302 return (0,external_wp_element_namespaceObject.createElement)(PreferencesModal, {
4303 closeModal: toggleModal
4304 }, (0,external_wp_element_namespaceObject.createElement)(PreferencesModalTabs, {
4305 sections: sections
4306 }));
4307 }
4308
4309 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/tools-more-menu-group/index.js
4310
4311
4312 /**
4313 * External dependencies
4314 */
4315
4316 /**
4317 * WordPress dependencies
4318 */
4319
4320
4321 const {
4322 Fill: ToolsMoreMenuGroup,
4323 Slot
4324 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteToolsMoreMenuGroup');
4325
4326 ToolsMoreMenuGroup.Slot = _ref => {
4327 let {
4328 fillProps
4329 } = _ref;
4330 return (0,external_wp_element_namespaceObject.createElement)(Slot, {
4331 fillProps: fillProps
4332 }, fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && fills);
4333 };
4334
4335 /* harmony default export */ var tools_more_menu_group = (ToolsMoreMenuGroup);
4336
4337 // EXTERNAL MODULE: ./node_modules/downloadjs/download.js
4338 var download = __webpack_require__(8981);
4339 var download_default = /*#__PURE__*/__webpack_require__.n(download);
4340 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/download.js
4341
4342
4343 /**
4344 * WordPress dependencies
4345 */
4346
4347 const download_download = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4348 xmlns: "http://www.w3.org/2000/svg",
4349 viewBox: "0 0 24 24"
4350 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4351 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"
4352 }));
4353 /* harmony default export */ var library_download = (download_download);
4354
4355 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/more-menu/site-export.js
4356
4357
4358 /**
4359 * External dependencies
4360 */
4361
4362 /**
4363 * WordPress dependencies
4364 */
4365
4366
4367
4368
4369
4370
4371
4372 function SiteExport() {
4373 const {
4374 createErrorNotice
4375 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
4376
4377 async function handleExport() {
4378 try {
4379 const response = await external_wp_apiFetch_default()({
4380 path: '/wp-block-editor/v1/export',
4381 parse: false
4382 });
4383 const blob = await response.blob();
4384 const contentDisposition = response.headers.get('content-disposition');
4385 const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/);
4386 const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : 'edit-site-export';
4387 download_default()(blob, fileName + '.zip', 'application/zip');
4388 } catch (errorResponse) {
4389 let error = {};
4390
4391 try {
4392 error = await errorResponse.json();
4393 } catch (e) {}
4394
4395 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the site export.');
4396 createErrorNotice(errorMessage, {
4397 type: 'snackbar'
4398 });
4399 }
4400 }
4401
4402 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4403 role: "menuitem",
4404 icon: library_download,
4405 onClick: handleExport,
4406 info: (0,external_wp_i18n_namespaceObject.__)('Download your theme with updated templates and styles.')
4407 }, (0,external_wp_i18n_namespaceObject._x)('Export', 'site exporter menu item'));
4408 }
4409
4410 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/more-menu/welcome-guide-menu-item.js
4411
4412
4413 /**
4414 * WordPress dependencies
4415 */
4416
4417
4418
4419
4420 function WelcomeGuideMenuItem() {
4421 const {
4422 toggle
4423 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
4424 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4425 onClick: () => toggle('core/edit-site', 'welcomeGuide')
4426 }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'));
4427 }
4428
4429 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/more-menu/copy-content-menu-item.js
4430
4431
4432 /**
4433 * WordPress dependencies
4434 */
4435
4436
4437
4438
4439
4440
4441
4442 /**
4443 * Internal dependencies
4444 */
4445
4446
4447 function CopyContentMenuItem() {
4448 const {
4449 createNotice
4450 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
4451 const getText = (0,external_wp_data_namespaceObject.useSelect)(select => {
4452 return () => {
4453 const {
4454 getEditedPostId,
4455 getEditedPostType
4456 } = select(store_store);
4457 const {
4458 getEditedEntityRecord
4459 } = select(external_wp_coreData_namespaceObject.store);
4460 const record = getEditedEntityRecord('postType', getEditedPostType(), getEditedPostId());
4461
4462 if (record) {
4463 if (typeof record.content === 'function') {
4464 return record.content(record);
4465 } else if (record.blocks) {
4466 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
4467 } else if (record.content) {
4468 return record.content;
4469 }
4470 }
4471
4472 return '';
4473 };
4474 }, []);
4475
4476 function onSuccess() {
4477 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
4478 isDismissible: true,
4479 type: 'snackbar'
4480 });
4481 }
4482
4483 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
4484 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4485 ref: ref
4486 }, (0,external_wp_i18n_namespaceObject.__)('Copy all content'));
4487 }
4488
4489 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/mode-switcher/index.js
4490
4491
4492 /**
4493 * WordPress dependencies
4494 */
4495
4496
4497
4498
4499 /**
4500 * Internal dependencies
4501 */
4502
4503 /**
4504 * Internal dependencies
4505 */
4506
4507
4508 /**
4509 * Set of available mode options.
4510 *
4511 * @type {Array}
4512 */
4513
4514 const MODES = [{
4515 value: 'visual',
4516 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
4517 }, {
4518 value: 'text',
4519 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
4520 }];
4521
4522 function ModeSwitcher() {
4523 const {
4524 shortcut,
4525 mode
4526 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
4527 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-mode'),
4528 isRichEditingEnabled: select(store_store).getSettings().richEditingEnabled,
4529 isCodeEditingEnabled: select(store_store).getSettings().codeEditingEnabled,
4530 mode: select(store_store).getEditorMode()
4531 }), []);
4532 const {
4533 switchEditorMode
4534 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4535 const choices = MODES.map(choice => {
4536 if (choice.value !== mode) {
4537 return { ...choice,
4538 shortcut
4539 };
4540 }
4541
4542 return choice;
4543 });
4544 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4545 label: (0,external_wp_i18n_namespaceObject.__)('Editor')
4546 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
4547 choices: choices,
4548 value: mode,
4549 onSelect: switchEditorMode
4550 }));
4551 }
4552
4553 /* harmony default export */ var mode_switcher = (ModeSwitcher);
4554
4555 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/more-menu/index.js
4556
4557
4558 /**
4559 * WordPress dependencies
4560 */
4561
4562
4563
4564
4565
4566
4567
4568
4569 /**
4570 * Internal dependencies
4571 */
4572
4573
4574
4575
4576
4577
4578
4579
4580 function MoreMenu() {
4581 const [isModalActive, toggleModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
4582 const [isPreferencesModalActive, togglePreferencesModal] = (0,external_wp_element_namespaceObject.useReducer)(isActive => !isActive, false);
4583 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/keyboard-shortcuts', toggleModal);
4584 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, null, _ref => {
4585 let {
4586 onClose
4587 } = _ref;
4588 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4589 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun')
4590 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
4591 scope: "core/edit-site",
4592 name: "fixedToolbar",
4593 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
4594 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
4595 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
4596 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
4597 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
4598 scope: "core/edit-site",
4599 name: "focusMode",
4600 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
4601 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
4602 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'),
4603 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated')
4604 }), (0,external_wp_element_namespaceObject.createElement)(mode_switcher, null), (0,external_wp_element_namespaceObject.createElement)(action_item.Slot, {
4605 name: "core/edit-site/plugin-more-menu",
4606 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
4607 as: external_wp_components_namespaceObject.MenuGroup,
4608 fillProps: {
4609 onClick: onClose
4610 }
4611 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4612 label: (0,external_wp_i18n_namespaceObject.__)('Tools')
4613 }, (0,external_wp_element_namespaceObject.createElement)(SiteExport, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4614 onClick: toggleModal,
4615 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h')
4616 }, (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, {
4617 icon: library_external,
4618 role: "menuitem",
4619 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/site-editor/'),
4620 target: "_blank",
4621 rel: "noopener noreferrer"
4622 }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
4623 as: "span"
4624 },
4625 /* translators: accessibility text */
4626 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group.Slot, {
4627 fillProps: {
4628 onClose
4629 }
4630 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4631 onClick: togglePreferencesModal
4632 }, (0,external_wp_i18n_namespaceObject.__)('Preferences'))));
4633 }), (0,external_wp_element_namespaceObject.createElement)(KeyboardShortcutHelpModal, {
4634 isModalActive: isModalActive,
4635 toggleModal: toggleModal
4636 }), (0,external_wp_element_namespaceObject.createElement)(EditSitePreferencesModal, {
4637 isModalActive: isPreferencesModalActive,
4638 toggleModal: togglePreferencesModal
4639 }));
4640 }
4641
4642 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/save-button/index.js
4643
4644
4645 /**
4646 * External dependencies
4647 */
4648
4649 /**
4650 * WordPress dependencies
4651 */
4652
4653
4654
4655
4656
4657 function SaveButton(_ref) {
4658 let {
4659 openEntitiesSavedStates,
4660 isEntitiesSavedStatesOpen
4661 } = _ref;
4662 const {
4663 isDirty,
4664 isSaving
4665 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4666 const {
4667 __experimentalGetDirtyEntityRecords,
4668 isSavingEntityRecord
4669 } = select(external_wp_coreData_namespaceObject.store);
4670
4671 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
4672
4673 return {
4674 isDirty: dirtyEntityRecords.length > 0,
4675 isSaving: (0,external_lodash_namespaceObject.some)(dirtyEntityRecords, record => isSavingEntityRecord(record.kind, record.name, record.key))
4676 };
4677 }, []);
4678 const disabled = !isDirty || isSaving;
4679 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4680 variant: "primary",
4681 className: "edit-site-save-button__button",
4682 "aria-disabled": disabled,
4683 "aria-expanded": isEntitiesSavedStatesOpen,
4684 disabled: disabled,
4685 isBusy: isSaving,
4686 onClick: disabled ? undefined : openEntitiesSavedStates
4687 }, (0,external_wp_i18n_namespaceObject.__)('Save')));
4688 }
4689
4690 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
4691
4692
4693 /**
4694 * WordPress dependencies
4695 */
4696
4697 const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4698 xmlns: "http://www.w3.org/2000/svg",
4699 viewBox: "0 0 24 24"
4700 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4701 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"
4702 }));
4703 /* harmony default export */ var library_undo = (undo);
4704
4705 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
4706
4707
4708 /**
4709 * WordPress dependencies
4710 */
4711
4712 const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4713 xmlns: "http://www.w3.org/2000/svg",
4714 viewBox: "0 0 24 24"
4715 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4716 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"
4717 }));
4718 /* harmony default export */ var library_redo = (redo);
4719
4720 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/undo-redo/undo.js
4721
4722
4723 /**
4724 * WordPress dependencies
4725 */
4726
4727
4728
4729
4730
4731
4732 function UndoButton() {
4733 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []);
4734 const {
4735 undo
4736 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
4737 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4738 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo,
4739 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
4740 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
4741 // button, because it will remove focus for keyboard users.
4742 // See: https://github.com/WordPress/gutenberg/issues/3486
4743 ,
4744 "aria-disabled": !hasUndo,
4745 onClick: hasUndo ? undo : undefined
4746 });
4747 }
4748
4749 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/undo-redo/redo.js
4750
4751
4752 /**
4753 * WordPress dependencies
4754 */
4755
4756
4757
4758
4759
4760
4761 function RedoButton() {
4762 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []);
4763 const {
4764 redo
4765 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
4766 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4767 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo,
4768 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
4769 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') // If there are no undo levels we don't want to actually disable this
4770 // button, because it will remove focus for keyboard users.
4771 // See: https://github.com/WordPress/gutenberg/issues/3486
4772 ,
4773 "aria-disabled": !hasRedo,
4774 onClick: hasRedo ? redo : undefined
4775 });
4776 }
4777
4778 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js
4779
4780
4781 /**
4782 * WordPress dependencies
4783 */
4784
4785 const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4786 viewBox: "0 0 24 24",
4787 xmlns: "http://www.w3.org/2000/svg"
4788 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4789 d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
4790 }));
4791 /* harmony default export */ var chevron_down = (chevronDown);
4792
4793 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/document-actions/index.js
4794
4795
4796 /**
4797 * External dependencies
4798 */
4799
4800 /**
4801 * WordPress dependencies
4802 */
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812 function getBlockDisplayText(block) {
4813 if (block) {
4814 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name);
4815 return blockType ? (0,external_wp_blocks_namespaceObject.__experimentalGetBlockLabel)(blockType, block.attributes) : null;
4816 }
4817
4818 return null;
4819 }
4820
4821 function useSecondaryText() {
4822 const {
4823 getBlock
4824 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
4825 const activeEntityBlockId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).__experimentalGetActiveBlockIdByBlockNames(['core/template-part']), []);
4826
4827 if (activeEntityBlockId) {
4828 return {
4829 label: getBlockDisplayText(getBlock(activeEntityBlockId)),
4830 isActive: true
4831 };
4832 }
4833
4834 return {};
4835 }
4836 /**
4837 * @param {Object} props Props for the DocumentActions component.
4838 * @param {string} props.entityTitle The title to display.
4839 * @param {string} props.entityLabel A label to use for entity-related options.
4840 * E.g. "template" would be used for "edit
4841 * template" and "show template details".
4842 * @param {boolean} props.isLoaded Whether the data is available.
4843 * @param {Function} props.children React component to use for the
4844 * information dropdown area. Should be a
4845 * function which accepts dropdown props.
4846 * @param {boolean} props.showIconLabels Whether buttons display icons or text labels.
4847 */
4848
4849
4850 function DocumentActions(_ref) {
4851 let {
4852 entityTitle,
4853 entityLabel,
4854 isLoaded,
4855 children: dropdownContent,
4856 showIconLabels
4857 } = _ref;
4858 const {
4859 label
4860 } = useSecondaryText(); // The title ref is passed to the popover as the anchorRef so that the
4861 // dropdown is centered over the whole title area rather than just one
4862 // part of it.
4863
4864 const titleRef = (0,external_wp_element_namespaceObject.useRef)(); // Return a simple loading indicator until we have information to show.
4865
4866 if (!isLoaded) {
4867 return (0,external_wp_element_namespaceObject.createElement)("div", {
4868 className: "edit-site-document-actions"
4869 }, (0,external_wp_i18n_namespaceObject.__)('Loading…'));
4870 } // Return feedback that the template does not seem to exist.
4871
4872
4873 if (!entityTitle) {
4874 return (0,external_wp_element_namespaceObject.createElement)("div", {
4875 className: "edit-site-document-actions"
4876 }, (0,external_wp_i18n_namespaceObject.__)('Template not found'));
4877 }
4878
4879 return (0,external_wp_element_namespaceObject.createElement)("div", {
4880 className: classnames_default()('edit-site-document-actions', {
4881 'has-secondary-label': !!label
4882 })
4883 }, (0,external_wp_element_namespaceObject.createElement)("div", {
4884 ref: titleRef,
4885 className: "edit-site-document-actions__title-wrapper"
4886 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
4887 size: "body",
4888 className: "edit-site-document-actions__title",
4889 as: "h1"
4890 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
4891 as: "span"
4892 }, (0,external_wp_i18n_namespaceObject.sprintf)(
4893 /* translators: %s: the entity being edited, like "template"*/
4894 (0,external_wp_i18n_namespaceObject.__)('Editing %s: '), entityLabel)), entityTitle), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
4895 size: "body",
4896 className: "edit-site-document-actions__secondary-item"
4897 }, label !== null && label !== void 0 ? label : ''), dropdownContent && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
4898 popoverProps: {
4899 anchorRef: titleRef.current
4900 },
4901 position: "bottom center",
4902 renderToggle: _ref2 => {
4903 let {
4904 isOpen,
4905 onToggle
4906 } = _ref2;
4907 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4908 className: "edit-site-document-actions__get-info",
4909 icon: chevron_down,
4910 "aria-expanded": isOpen,
4911 "aria-haspopup": "true",
4912 onClick: onToggle,
4913 label: (0,external_wp_i18n_namespaceObject.sprintf)(
4914 /* translators: %s: the entity to see details about, like "template"*/
4915 (0,external_wp_i18n_namespaceObject.__)('Show %s details'), entityLabel)
4916 }, showIconLabels && (0,external_wp_i18n_namespaceObject.__)('Details'));
4917 },
4918 contentClassName: "edit-site-document-actions__info-dropdown",
4919 renderContent: dropdownContent
4920 })));
4921 }
4922
4923 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/link.js
4924
4925
4926
4927 /**
4928 * WordPress dependencies
4929 */
4930
4931 /**
4932 * Internal dependencies
4933 */
4934
4935
4936 function useLink() {
4937 let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4938 let state = arguments.length > 1 ? arguments[1] : undefined;
4939 let shouldReplace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4940 const history = useHistory();
4941
4942 function onClick(event) {
4943 event.preventDefault();
4944
4945 if (shouldReplace) {
4946 history.replace(params, state);
4947 } else {
4948 history.push(params, state);
4949 }
4950 }
4951
4952 return {
4953 href: (0,external_wp_url_namespaceObject.addQueryArgs)(window.location.href, params),
4954 onClick
4955 };
4956 }
4957 function Link(_ref) {
4958 let {
4959 params = {},
4960 state,
4961 replace: shouldReplace = false,
4962 children,
4963 ...props
4964 } = _ref;
4965 const {
4966 href,
4967 onClick
4968 } = useLink(params, state, shouldReplace);
4969 return (0,external_wp_element_namespaceObject.createElement)("a", extends_extends({
4970 href: href,
4971 onClick: onClick
4972 }, props), children);
4973 }
4974
4975 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/template-areas.js
4976
4977
4978
4979 /**
4980 * WordPress dependencies
4981 */
4982
4983
4984
4985
4986
4987
4988 /**
4989 * Internal dependencies
4990 */
4991
4992
4993
4994
4995
4996
4997 function TemplatePartItemMore(_ref) {
4998 var _templatePart$title;
4999
5000 let {
5001 onClose,
5002 templatePart,
5003 closeTemplateDetailsDropdown
5004 } = _ref;
5005 const {
5006 revertTemplate
5007 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5008 const {
5009 params
5010 } = useLocation();
5011 const editLinkProps = useLink({
5012 postId: templatePart.id,
5013 postType: templatePart.type
5014 }, {
5015 fromTemplateId: params.postId
5016 });
5017
5018 function editTemplatePart(event) {
5019 editLinkProps.onClick(event);
5020 onClose();
5021 closeTemplateDetailsDropdown();
5022 }
5023
5024 function clearCustomizations() {
5025 revertTemplate(templatePart);
5026 onClose();
5027 closeTemplateDetailsDropdown();
5028 }
5029
5030 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, {
5031 onClick: editTemplatePart
5032 }), (0,external_wp_i18n_namespaceObject.sprintf)(
5033 /* translators: %s: template part title */
5034 (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, {
5035 info: (0,external_wp_i18n_namespaceObject.__)('Restore template to default state'),
5036 onClick: clearCustomizations
5037 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations'))));
5038 }
5039
5040 function TemplatePartItem(_ref2) {
5041 let {
5042 templatePart,
5043 clientId,
5044 closeTemplateDetailsDropdown
5045 } = _ref2;
5046 const {
5047 selectBlock,
5048 toggleBlockHighlight
5049 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
5050 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => {
5051 const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas();
5052
5053 return defaultAreas.find(defaultArea => defaultArea.area === templatePart.area);
5054 }, [templatePart.area]);
5055
5056 const highlightBlock = () => toggleBlockHighlight(clientId, true);
5057
5058 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
5059
5060 return (0,external_wp_element_namespaceObject.createElement)("div", {
5061 role: "menuitem",
5062 className: "edit-site-template-details__template-areas-item"
5063 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5064 role: "button",
5065 icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
5066 iconPosition: "left",
5067 onClick: () => {
5068 selectBlock(clientId);
5069 },
5070 onMouseOver: highlightBlock,
5071 onMouseLeave: cancelHighlightBlock,
5072 onFocus: highlightBlock,
5073 onBlur: cancelHighlightBlock
5074 }, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
5075 icon: more_vertical,
5076 label: (0,external_wp_i18n_namespaceObject.__)('More options'),
5077 className: "edit-site-template-details__template-areas-item-more"
5078 }, _ref3 => {
5079 let {
5080 onClose
5081 } = _ref3;
5082 return (0,external_wp_element_namespaceObject.createElement)(TemplatePartItemMore, {
5083 onClose: onClose,
5084 templatePart: templatePart,
5085 closeTemplateDetailsDropdown: closeTemplateDetailsDropdown
5086 });
5087 }));
5088 }
5089
5090 function TemplateAreas(_ref4) {
5091 let {
5092 closeTemplateDetailsDropdown
5093 } = _ref4;
5094 const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentTemplateTemplateParts(), []);
5095
5096 if (!templateParts.length) {
5097 return null;
5098 }
5099
5100 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
5101 label: (0,external_wp_i18n_namespaceObject.__)('Areas'),
5102 className: "edit-site-template-details__group edit-site-template-details__template-areas"
5103 }, templateParts.map(_ref5 => {
5104 let {
5105 templatePart,
5106 block
5107 } = _ref5;
5108 return (0,external_wp_element_namespaceObject.createElement)(TemplatePartItem, {
5109 key: templatePart.slug,
5110 clientId: block.clientId,
5111 templatePart: templatePart,
5112 closeTemplateDetailsDropdown: closeTemplateDetailsDropdown
5113 });
5114 }));
5115 }
5116
5117 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/edit-template-title.js
5118
5119
5120 /**
5121 * WordPress dependencies
5122 */
5123
5124
5125
5126 function EditTemplateTitle(_ref) {
5127 let {
5128 template
5129 } = _ref;
5130 const [title, setTitle] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', template.type, 'title', template.id);
5131 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
5132 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
5133 value: title,
5134 help: (0,external_wp_i18n_namespaceObject.__)('Give the template a title that indicates its purpose, e.g. "Full Width".'),
5135 onChange: newTitle => {
5136 setTitle(newTitle || template.slug);
5137 }
5138 });
5139 }
5140
5141 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-details/index.js
5142
5143
5144
5145 /**
5146 * WordPress dependencies
5147 */
5148
5149
5150
5151
5152
5153 /**
5154 * Internal dependencies
5155 */
5156
5157
5158
5159
5160
5161
5162
5163 function TemplateDetails(_ref) {
5164 let {
5165 template,
5166 onClose
5167 } = _ref;
5168 const {
5169 title,
5170 description
5171 } = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetTemplateInfo(template), []);
5172 const {
5173 revertTemplate
5174 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5175 const templateSubMenu = (0,external_wp_element_namespaceObject.useMemo)(() => {
5176 if ((template === null || template === void 0 ? void 0 : template.type) === 'wp_template') {
5177 return {
5178 title: (0,external_wp_i18n_namespaceObject.__)('templates'),
5179 menu: MENU_TEMPLATES
5180 };
5181 }
5182
5183 return TEMPLATE_PARTS_SUB_MENUS.find(_ref2 => {
5184 let {
5185 area
5186 } = _ref2;
5187 return area === (template === null || template === void 0 ? void 0 : template.area);
5188 });
5189 }, [template]);
5190 const browseAllLinkProps = useLink({
5191 // TODO: We should update this to filter by template part's areas as well.
5192 postType: template.type,
5193 postId: undefined
5194 });
5195
5196 if (!template) {
5197 return null;
5198 }
5199
5200 const revert = () => {
5201 revertTemplate(template);
5202 onClose();
5203 };
5204
5205 return (0,external_wp_element_namespaceObject.createElement)("div", {
5206 className: "edit-site-template-details"
5207 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5208 className: "edit-site-template-details__group"
5209 }, template.is_custom ? (0,external_wp_element_namespaceObject.createElement)(EditTemplateTitle, {
5210 template: template
5211 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
5212 level: 4,
5213 weight: 600,
5214 className: "edit-site-template-details__title"
5215 }, title), description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
5216 size: "body",
5217 className: "edit-site-template-details__description",
5218 as: "p"
5219 }, description)), (0,external_wp_element_namespaceObject.createElement)(TemplateAreas, {
5220 closeTemplateDetailsDropdown: onClose
5221 }), isTemplateRevertable(template) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
5222 className: "edit-site-template-details__group edit-site-template-details__revert"
5223 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
5224 className: "edit-site-template-details__revert-button",
5225 info: (0,external_wp_i18n_namespaceObject.__)('Restore template to default state'),
5226 onClick: revert
5227 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, extends_extends({
5228 className: "edit-site-template-details__show-all-button"
5229 }, browseAllLinkProps), (0,external_wp_i18n_namespaceObject.sprintf)(
5230 /* translators: the template part's area name ("Headers", "Sidebars") or "templates". */
5231 (0,external_wp_i18n_namespaceObject.__)('Browse all %s'), templateSubMenu.title)));
5232 }
5233
5234 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/index.js
5235
5236
5237 /**
5238 * WordPress dependencies
5239 */
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251 /**
5252 * Internal dependencies
5253 */
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263 const preventDefault = event => {
5264 event.preventDefault();
5265 };
5266
5267 function Header(_ref) {
5268 let {
5269 openEntitiesSavedStates,
5270 isEntitiesSavedStatesOpen,
5271 showIconLabels
5272 } = _ref;
5273 const inserterButton = (0,external_wp_element_namespaceObject.useRef)();
5274 const {
5275 deviceType,
5276 entityTitle,
5277 template,
5278 templateType,
5279 isInserterOpen,
5280 isListViewOpen,
5281 listViewShortcut,
5282 isLoaded,
5283 isVisualMode
5284 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5285 const {
5286 __experimentalGetPreviewDeviceType,
5287 getEditedPostType,
5288 getEditedPostId,
5289 isInserterOpened,
5290 isListViewOpened,
5291 getEditorMode
5292 } = select(store_store);
5293 const {
5294 getEditedEntityRecord
5295 } = select(external_wp_coreData_namespaceObject.store);
5296 const {
5297 __experimentalGetTemplateInfo: getTemplateInfo
5298 } = select(external_wp_editor_namespaceObject.store);
5299 const {
5300 getShortcutRepresentation
5301 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
5302 const postType = getEditedPostType();
5303 const postId = getEditedPostId();
5304 const record = getEditedEntityRecord('postType', postType, postId);
5305
5306 const _isLoaded = !!postId;
5307
5308 return {
5309 deviceType: __experimentalGetPreviewDeviceType(),
5310 entityTitle: getTemplateInfo(record).title,
5311 isLoaded: _isLoaded,
5312 template: record,
5313 templateType: postType,
5314 isInserterOpen: isInserterOpened(),
5315 isListViewOpen: isListViewOpened(),
5316 listViewShortcut: getShortcutRepresentation('core/edit-site/toggle-list-view'),
5317 isVisualMode: getEditorMode() === 'visual'
5318 };
5319 }, []);
5320 const {
5321 __experimentalSetPreviewDeviceType: setPreviewDeviceType,
5322 setIsInserterOpened,
5323 setIsListViewOpened
5324 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5325 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
5326 const openInserter = (0,external_wp_element_namespaceObject.useCallback)(() => {
5327 if (isInserterOpen) {
5328 // Focusing the inserter button closes the inserter popover.
5329 inserterButton.current.focus();
5330 } else {
5331 setIsInserterOpened(true);
5332 }
5333 }, [isInserterOpen, setIsInserterOpened]);
5334 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
5335 const isFocusMode = templateType === 'wp_template_part';
5336 return (0,external_wp_element_namespaceObject.createElement)("div", {
5337 className: "edit-site-header"
5338 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5339 className: "edit-site-header_start"
5340 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5341 className: "edit-site-header__toolbar"
5342 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5343 ref: inserterButton,
5344 variant: "primary",
5345 isPressed: isInserterOpen,
5346 className: "edit-site-header-toolbar__inserter-toggle",
5347 disabled: !isVisualMode,
5348 onMouseDown: preventDefault,
5349 onClick: openInserter,
5350 icon: library_plus,
5351 label: (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button')
5352 }, showIconLabels && (!isInserterOpen ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close'))), isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
5353 as: external_wp_blockEditor_namespaceObject.ToolSelector,
5354 disabled: !isVisualMode
5355 }), (0,external_wp_element_namespaceObject.createElement)(UndoButton, null), (0,external_wp_element_namespaceObject.createElement)(RedoButton, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5356 className: "edit-site-header-toolbar__list-view-toggle",
5357 disabled: !isVisualMode,
5358 icon: list_view,
5359 isPressed: isListViewOpen
5360 /* translators: button label text should, if possible, be under 16 characters. */
5361 ,
5362 label: (0,external_wp_i18n_namespaceObject.__)('List View'),
5363 onClick: toggleListView,
5364 shortcut: listViewShortcut
5365 })))), (0,external_wp_element_namespaceObject.createElement)("div", {
5366 className: "edit-site-header_center"
5367 }, (0,external_wp_element_namespaceObject.createElement)(DocumentActions, {
5368 entityTitle: entityTitle,
5369 entityLabel: templateType === 'wp_template_part' ? 'template part' : 'template',
5370 isLoaded: isLoaded,
5371 showIconLabels: showIconLabels
5372 }, _ref2 => {
5373 let {
5374 onClose
5375 } = _ref2;
5376 return (0,external_wp_element_namespaceObject.createElement)(TemplateDetails, {
5377 template: template,
5378 onClose: onClose
5379 });
5380 })), (0,external_wp_element_namespaceObject.createElement)("div", {
5381 className: "edit-site-header_end"
5382 }, (0,external_wp_element_namespaceObject.createElement)("div", {
5383 className: "edit-site-header__actions"
5384 }, !isFocusMode && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalPreviewOptions, {
5385 deviceType: deviceType,
5386 setDeviceType: setPreviewDeviceType
5387 }), (0,external_wp_element_namespaceObject.createElement)(SaveButton, {
5388 openEntitiesSavedStates: openEntitiesSavedStates,
5389 isEntitiesSavedStatesOpen: isEntitiesSavedStatesOpen
5390 }), (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, {
5391 scope: "core/edit-site"
5392 }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, null))));
5393 }
5394
5395 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cog.js
5396
5397
5398 /**
5399 * WordPress dependencies
5400 */
5401
5402 const cog = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5403 xmlns: "http://www.w3.org/2000/svg",
5404 viewBox: "0 0 24 24"
5405 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5406 fillRule: "evenodd",
5407 d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",
5408 clipRule: "evenodd"
5409 }));
5410 /* harmony default export */ var library_cog = (cog);
5411
5412 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/default-sidebar.js
5413
5414
5415 /**
5416 * WordPress dependencies
5417 */
5418
5419 function DefaultSidebar(_ref) {
5420 let {
5421 className,
5422 identifier,
5423 title,
5424 icon,
5425 children,
5426 closeLabel,
5427 header,
5428 headerClassName,
5429 panelClassName
5430 } = _ref;
5431 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(complementary_area, {
5432 className: className,
5433 scope: "core/edit-site",
5434 identifier: identifier,
5435 title: title,
5436 icon: icon,
5437 closeLabel: closeLabel,
5438 header: header,
5439 headerClassName: headerClassName,
5440 panelClassName: panelClassName
5441 }, children), (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
5442 scope: "core/edit-site",
5443 identifier: identifier,
5444 icon: icon
5445 }, title));
5446 }
5447
5448 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/styles.js
5449
5450
5451 /**
5452 * WordPress dependencies
5453 */
5454
5455 const styles = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5456 viewBox: "0 0 24 24",
5457 xmlns: "http://www.w3.org/2000/svg"
5458 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5459 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"
5460 }));
5461 /* harmony default export */ var library_styles = (styles);
5462
5463 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/icon-with-current-color.js
5464
5465
5466
5467 /**
5468 * External dependencies
5469 */
5470
5471 /**
5472 * WordPress dependencies
5473 */
5474
5475
5476 function IconWithCurrentColor(_ref) {
5477 let {
5478 className,
5479 ...props
5480 } = _ref;
5481 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, extends_extends({
5482 className: classnames_default()(className, 'edit-site-global-styles-icon-with-current-color')
5483 }, props));
5484 }
5485
5486 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/navigation-button.js
5487
5488
5489
5490 /**
5491 * WordPress dependencies
5492 */
5493
5494 /**
5495 * Internal dependencies
5496 */
5497
5498
5499
5500 function GenericNavigationButton(_ref) {
5501 let {
5502 icon,
5503 children,
5504 ...props
5505 } = _ref;
5506 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, {
5507 justify: "flex-start"
5508 }, (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, {
5509 icon: icon,
5510 size: 24
5511 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, children)), !icon && children);
5512 }
5513
5514 function NavigationButton(props) {
5515 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, extends_extends({
5516 as: GenericNavigationButton
5517 }, props));
5518 }
5519
5520 function NavigationBackButton(props) {
5521 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, extends_extends({
5522 as: GenericNavigationButton
5523 }, props));
5524 }
5525
5526
5527
5528 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/typography.js
5529
5530
5531 /**
5532 * WordPress dependencies
5533 */
5534
5535 const typography = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5536 xmlns: "http://www.w3.org/2000/svg",
5537 viewBox: "0 0 24 24"
5538 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5539 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"
5540 }));
5541 /* harmony default export */ var library_typography = (typography);
5542
5543 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/color.js
5544
5545
5546 /**
5547 * WordPress dependencies
5548 */
5549
5550 const color = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5551 viewBox: "0 0 24 24",
5552 xmlns: "http://www.w3.org/2000/svg"
5553 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5554 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"
5555 }));
5556 /* harmony default export */ var library_color = (color);
5557
5558 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
5559
5560
5561 /**
5562 * WordPress dependencies
5563 */
5564
5565 const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5566 xmlns: "http://www.w3.org/2000/svg",
5567 viewBox: "0 0 24 24"
5568 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5569 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"
5570 }));
5571 /* harmony default export */ var library_layout = (layout);
5572
5573 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/utils.js
5574 /**
5575 * External dependencies
5576 */
5577
5578 /* Supporting data. */
5579
5580 const ROOT_BLOCK_NAME = 'root';
5581 const ROOT_BLOCK_SELECTOR = 'body';
5582 const ROOT_BLOCK_SUPPORTS = (/* unused pure expression or super */ null && (['background', 'backgroundColor', 'color', 'linkColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform', 'padding']));
5583 const PRESET_METADATA = [{
5584 path: ['color', 'palette'],
5585 valueKey: 'color',
5586 cssVarInfix: 'color',
5587 classes: [{
5588 classSuffix: 'color',
5589 propertyName: 'color'
5590 }, {
5591 classSuffix: 'background-color',
5592 propertyName: 'background-color'
5593 }, {
5594 classSuffix: 'border-color',
5595 propertyName: 'border-color'
5596 }]
5597 }, {
5598 path: ['color', 'gradients'],
5599 valueKey: 'gradient',
5600 cssVarInfix: 'gradient',
5601 classes: [{
5602 classSuffix: 'gradient-background',
5603 propertyName: 'background'
5604 }]
5605 }, {
5606 path: ['typography', 'fontSizes'],
5607 valueKey: 'size',
5608 cssVarInfix: 'font-size',
5609 classes: [{
5610 classSuffix: 'font-size',
5611 propertyName: 'font-size'
5612 }]
5613 }, {
5614 path: ['typography', 'fontFamilies'],
5615 valueKey: 'fontFamily',
5616 cssVarInfix: 'font-family',
5617 classes: [{
5618 classSuffix: 'font-family',
5619 propertyName: 'font-family'
5620 }]
5621 }];
5622 const STYLE_PATH_TO_CSS_VAR_INFIX = {
5623 'color.background': 'color',
5624 'color.text': 'color',
5625 'elements.link.color.text': 'color',
5626 'color.gradient': 'gradient',
5627 'typography.fontSize': 'font-size',
5628 'typography.fontFamily': 'font-family'
5629 };
5630
5631 function findInPresetsBy(features, blockName, presetPath, presetProperty, presetValueValue) {
5632 // Block presets take priority above root level presets.
5633 const orderedPresetsByOrigin = [(0,external_lodash_namespaceObject.get)(features, ['blocks', blockName, ...presetPath]), (0,external_lodash_namespaceObject.get)(features, presetPath)];
5634
5635 for (const presetByOrigin of orderedPresetsByOrigin) {
5636 if (presetByOrigin) {
5637 // Preset origins ordered by priority.
5638 const origins = ['custom', 'theme', 'default'];
5639
5640 for (const origin of origins) {
5641 const presets = presetByOrigin[origin];
5642
5643 if (presets) {
5644 const presetObject = (0,external_lodash_namespaceObject.find)(presets, preset => preset[presetProperty] === presetValueValue);
5645
5646 if (presetObject) {
5647 if (presetProperty === 'slug') {
5648 return presetObject;
5649 } // If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
5650
5651
5652 const highestPresetObjectWithSameSlug = findInPresetsBy(features, blockName, presetPath, 'slug', presetObject.slug);
5653
5654 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) {
5655 return presetObject;
5656 }
5657
5658 return undefined;
5659 }
5660 }
5661 }
5662 }
5663 }
5664 }
5665
5666 function getPresetVariableFromValue(features, blockName, variableStylePath, presetPropertyValue) {
5667 if (!presetPropertyValue) {
5668 return presetPropertyValue;
5669 }
5670
5671 const cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[variableStylePath];
5672 const metadata = (0,external_lodash_namespaceObject.find)(PRESET_METADATA, ['cssVarInfix', cssVarInfix]);
5673
5674 if (!metadata) {
5675 // The property doesn't have preset data
5676 // so the value should be returned as it is.
5677 return presetPropertyValue;
5678 }
5679
5680 const {
5681 valueKey,
5682 path
5683 } = metadata;
5684 const presetObject = findInPresetsBy(features, blockName, path, valueKey, presetPropertyValue);
5685
5686 if (!presetObject) {
5687 // Value wasn't found in the presets,
5688 // so it must be a custom value.
5689 return presetPropertyValue;
5690 }
5691
5692 return `var:preset|${cssVarInfix}|${presetObject.slug}`;
5693 }
5694
5695 function getValueFromPresetVariable(features, blockName, variable, _ref) {
5696 let [presetType, slug] = _ref;
5697 const metadata = (0,external_lodash_namespaceObject.find)(PRESET_METADATA, ['cssVarInfix', presetType]);
5698
5699 if (!metadata) {
5700 return variable;
5701 }
5702
5703 const presetObject = findInPresetsBy(features, blockName, metadata.path, 'slug', slug);
5704
5705 if (presetObject) {
5706 const {
5707 valueKey
5708 } = metadata;
5709 const result = presetObject[valueKey];
5710 return getValueFromVariable(features, blockName, result);
5711 }
5712
5713 return variable;
5714 }
5715
5716 function getValueFromCustomVariable(features, blockName, variable, path) {
5717 var _get;
5718
5719 const result = (_get = (0,external_lodash_namespaceObject.get)(features, ['blocks', blockName, 'custom', ...path])) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(features, ['custom', ...path]);
5720
5721 if (!result) {
5722 return variable;
5723 } // A variable may reference another variable so we need recursion until we find the value.
5724
5725
5726 return getValueFromVariable(features, blockName, result);
5727 }
5728
5729 function getValueFromVariable(features, blockName, variable) {
5730 if (!variable || !(0,external_lodash_namespaceObject.isString)(variable)) {
5731 return variable;
5732 }
5733
5734 const USER_VALUE_PREFIX = 'var:';
5735 const THEME_VALUE_PREFIX = 'var(--wp--';
5736 const THEME_VALUE_SUFFIX = ')';
5737 let parsedVar;
5738
5739 if (variable.startsWith(USER_VALUE_PREFIX)) {
5740 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split('|');
5741 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) {
5742 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split('--');
5743 } else {
5744 // We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`
5745 return variable;
5746 }
5747
5748 const [type, ...path] = parsedVar;
5749
5750 if (type === 'preset') {
5751 return getValueFromPresetVariable(features, blockName, variable, path);
5752 }
5753
5754 if (type === 'custom') {
5755 return getValueFromCustomVariable(features, blockName, variable, path);
5756 }
5757
5758 return variable;
5759 }
5760
5761 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/context.js
5762 /**
5763 * WordPress dependencies
5764 */
5765
5766 const DEFAULT_GLOBAL_STYLES_CONTEXT = {
5767 user: {},
5768 base: {},
5769 merged: {},
5770 setUserConfig: () => {}
5771 };
5772 const GlobalStylesContext = (0,external_wp_element_namespaceObject.createContext)(DEFAULT_GLOBAL_STYLES_CONTEXT);
5773
5774 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/hooks.js
5775 /**
5776 * External dependencies
5777 */
5778
5779 /**
5780 * WordPress dependencies
5781 */
5782
5783
5784
5785
5786 /**
5787 * Internal dependencies
5788 */
5789
5790
5791
5792 const EMPTY_CONFIG = {
5793 isGlobalStylesUserThemeJSON: true,
5794 version: 1
5795 };
5796 const useGlobalStylesReset = () => {
5797 const {
5798 user: config,
5799 setUserConfig
5800 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
5801 const canReset = !!config && !(0,external_lodash_namespaceObject.isEqual)(config, EMPTY_CONFIG);
5802 return [canReset, (0,external_wp_element_namespaceObject.useCallback)(() => setUserConfig(() => EMPTY_CONFIG), [setUserConfig])];
5803 };
5804 function useSetting(path, blockName) {
5805 var _getSettingValueForCo;
5806
5807 let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
5808 const {
5809 merged: mergedConfig,
5810 base: baseConfig,
5811 user: userConfig,
5812 setUserConfig
5813 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
5814 const fullPath = !blockName ? `settings.${path}` : `settings.blocks.${blockName}.${path}`;
5815
5816 const setSetting = newValue => {
5817 setUserConfig(currentConfig => {
5818 const newUserConfig = (0,external_lodash_namespaceObject.cloneDeep)(currentConfig);
5819 const pathToSet = external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[path] ? fullPath + '.custom' : fullPath;
5820 (0,external_lodash_namespaceObject.set)(newUserConfig, pathToSet, newValue);
5821 return newUserConfig;
5822 });
5823 };
5824
5825 const getSettingValueForContext = name => {
5826 const currentPath = !name ? `settings.${path}` : `settings.blocks.${name}.${path}`;
5827
5828 const getSettingValue = configToUse => {
5829 const result = (0,external_lodash_namespaceObject.get)(configToUse, currentPath);
5830
5831 if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_PATHS_WITH_MERGE[path]) {
5832 var _ref, _result$custom;
5833
5834 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;
5835 }
5836
5837 return result;
5838 };
5839
5840 let result;
5841
5842 switch (source) {
5843 case 'all':
5844 result = getSettingValue(mergedConfig);
5845 break;
5846
5847 case 'user':
5848 result = getSettingValue(userConfig);
5849 break;
5850
5851 case 'base':
5852 result = getSettingValue(baseConfig);
5853 break;
5854
5855 default:
5856 throw 'Unsupported source';
5857 }
5858
5859 return result;
5860 }; // Unlike styles settings get inherited from top level settings.
5861
5862
5863 const resultWithFallback = (_getSettingValueForCo = getSettingValueForContext(blockName)) !== null && _getSettingValueForCo !== void 0 ? _getSettingValueForCo : getSettingValueForContext();
5864 return [resultWithFallback, setSetting];
5865 }
5866 function useStyle(path, blockName) {
5867 var _get;
5868
5869 let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
5870 const {
5871 merged: mergedConfig,
5872 base: baseConfig,
5873 user: userConfig,
5874 setUserConfig
5875 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
5876 const finalPath = !blockName ? `styles.${path}` : `styles.blocks.${blockName}.${path}`;
5877
5878 const setStyle = newValue => {
5879 setUserConfig(currentConfig => {
5880 const newUserConfig = (0,external_lodash_namespaceObject.cloneDeep)(currentConfig);
5881 (0,external_lodash_namespaceObject.set)(newUserConfig, finalPath, getPresetVariableFromValue(mergedConfig.settings, blockName, path, newValue));
5882 return newUserConfig;
5883 });
5884 };
5885
5886 let result;
5887
5888 switch (source) {
5889 case 'all':
5890 result = getValueFromVariable(mergedConfig.settings, blockName, (_get = (0,external_lodash_namespaceObject.get)(userConfig, finalPath)) !== null && _get !== void 0 ? _get : (0,external_lodash_namespaceObject.get)(baseConfig, finalPath));
5891 break;
5892
5893 case 'user':
5894 result = getValueFromVariable(mergedConfig.settings, blockName, (0,external_lodash_namespaceObject.get)(userConfig, finalPath));
5895 break;
5896
5897 case 'base':
5898 result = getValueFromVariable(baseConfig.settings, blockName, (0,external_lodash_namespaceObject.get)(baseConfig, finalPath));
5899 break;
5900
5901 default:
5902 throw 'Unsupported source';
5903 }
5904
5905 return [result, setStyle];
5906 }
5907 const hooks_ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textDecoration', 'textTransform', 'padding'];
5908 function getSupportedGlobalStylesPanels(name) {
5909 if (!name) {
5910 return hooks_ROOT_BLOCK_SUPPORTS;
5911 }
5912
5913 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
5914
5915 if (!blockType) {
5916 return [];
5917 }
5918
5919 const supportKeys = [];
5920 Object.keys(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY).forEach(styleName => {
5921 if (!external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) {
5922 return;
5923 } // Opting out means that, for certain support keys like background color,
5924 // blocks have to explicitly set the support value false. If the key is
5925 // unset, we still enable it.
5926
5927
5928 if (external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].requiresOptOut) {
5929 if ((0,external_lodash_namespaceObject.has)(blockType.supports, external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support[0]) && (0,external_lodash_namespaceObject.get)(blockType.supports, external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) !== false) {
5930 return supportKeys.push(styleName);
5931 }
5932 }
5933
5934 if ((0,external_lodash_namespaceObject.get)(blockType.supports, external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY[styleName].support, false)) {
5935 return supportKeys.push(styleName);
5936 }
5937 });
5938 return supportKeys;
5939 }
5940 function useColorsPerOrigin(name) {
5941 const [customColors] = useSetting('color.palette.custom', name);
5942 const [themeColors] = useSetting('color.palette.theme', name);
5943 const [defaultColors] = useSetting('color.palette.default', name);
5944 const [shouldDisplayDefaultColors] = useSetting('color.defaultPalette');
5945 return (0,external_wp_element_namespaceObject.useMemo)(() => {
5946 const result = [];
5947
5948 if (themeColors && themeColors.length) {
5949 result.push({
5950 name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
5951 colors: themeColors
5952 });
5953 }
5954
5955 if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) {
5956 result.push({
5957 name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
5958 colors: defaultColors
5959 });
5960 }
5961
5962 if (customColors && customColors.length) {
5963 result.push({
5964 name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'),
5965 colors: customColors
5966 });
5967 }
5968
5969 return result;
5970 }, [customColors, themeColors, defaultColors]);
5971 }
5972 function useGradientsPerOrigin(name) {
5973 const [customGradients] = useSetting('color.gradients.custom', name);
5974 const [themeGradients] = useSetting('color.gradients.theme', name);
5975 const [defaultGradients] = useSetting('color.gradients.default', name);
5976 const [shouldDisplayDefaultGradients] = useSetting('color.defaultGradients');
5977 return (0,external_wp_element_namespaceObject.useMemo)(() => {
5978 const result = [];
5979
5980 if (themeGradients && themeGradients.length) {
5981 result.push({
5982 name: (0,external_wp_i18n_namespaceObject._x)('Theme', 'Indicates this palette comes from the theme.'),
5983 gradients: themeGradients
5984 });
5985 }
5986
5987 if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) {
5988 result.push({
5989 name: (0,external_wp_i18n_namespaceObject._x)('Default', 'Indicates this palette comes from WordPress.'),
5990 gradients: defaultGradients
5991 });
5992 }
5993
5994 if (customGradients && customGradients.length) {
5995 result.push({
5996 name: (0,external_wp_i18n_namespaceObject._x)('Custom', 'Indicates this palette is created by the user.'),
5997 gradients: customGradients
5998 });
5999 }
6000
6001 return result;
6002 }, [customGradients, themeGradients, defaultGradients]);
6003 }
6004
6005 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/border-panel.js
6006
6007
6008 /**
6009 * WordPress dependencies
6010 */
6011
6012
6013
6014 /**
6015 * Internal dependencies
6016 */
6017
6018
6019 const MIN_BORDER_WIDTH = 0;
6020 function useHasBorderPanel(name) {
6021 const controls = [useHasBorderColorControl(name), useHasBorderRadiusControl(name), useHasBorderStyleControl(name), useHasBorderWidthControl(name)];
6022 return controls.some(Boolean);
6023 }
6024
6025 function useHasBorderColorControl(name) {
6026 const supports = getSupportedGlobalStylesPanels(name);
6027 return useSetting('border.color', name)[0] && supports.includes('borderColor');
6028 }
6029
6030 function useHasBorderRadiusControl(name) {
6031 const supports = getSupportedGlobalStylesPanels(name);
6032 return useSetting('border.radius', name)[0] && supports.includes('borderRadius');
6033 }
6034
6035 function useHasBorderStyleControl(name) {
6036 const supports = getSupportedGlobalStylesPanels(name);
6037 return useSetting('border.style', name)[0] && supports.includes('borderStyle');
6038 }
6039
6040 function useHasBorderWidthControl(name) {
6041 const supports = getSupportedGlobalStylesPanels(name);
6042 return useSetting('border.width', name)[0] && supports.includes('borderWidth');
6043 }
6044
6045 function BorderPanel(_ref) {
6046 let {
6047 name
6048 } = _ref;
6049 // To better reflect if the user has customized a value we need to
6050 // ensure the style value being checked is from the `user` origin.
6051 const [userBorderStyles] = useStyle('border', name, 'user');
6052
6053 const createHasValueCallback = feature => () => !!(userBorderStyles !== null && userBorderStyles !== void 0 && userBorderStyles[feature]);
6054
6055 const createResetCallback = setStyle => () => setStyle(undefined);
6056
6057 const handleOnChange = setStyle => value => {
6058 setStyle(value || undefined);
6059 };
6060
6061 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
6062 availableUnits: useSetting('spacing.units')[0] || ['px', 'em', 'rem']
6063 }); // Border width.
6064
6065 const showBorderWidth = useHasBorderWidthControl(name);
6066 const [borderWidthValue, setBorderWidth] = useStyle('border.width', name); // Border style.
6067
6068 const showBorderStyle = useHasBorderStyleControl(name);
6069 const [borderStyle, setBorderStyle] = useStyle('border.style', name); // When we set a border color or width ensure we have a style so the user
6070 // can see a visible border.
6071
6072 const handleOnChangeWithStyle = setStyle => value => {
6073 if (!!value && !borderStyle) {
6074 setBorderStyle('solid');
6075 }
6076
6077 setStyle(value || undefined);
6078 }; // Border color.
6079
6080
6081 const showBorderColor = useHasBorderColorControl(name);
6082 const [borderColor, setBorderColor] = useStyle('border.color', name);
6083 const disableCustomColors = !useSetting('color.custom')[0];
6084 const disableCustomGradients = !useSetting('color.customGradient')[0];
6085 const borderColorSettings = [{
6086 label: (0,external_wp_i18n_namespaceObject.__)('Color'),
6087 colors: useColorsPerOrigin(name),
6088 colorValue: borderColor,
6089 onColorChange: handleOnChangeWithStyle(setBorderColor),
6090 clearable: false
6091 }]; // Border radius.
6092
6093 const showBorderRadius = useHasBorderRadiusControl(name);
6094 const [borderRadiusValues, setBorderRadius] = useStyle('border.radius', name);
6095
6096 const hasBorderRadius = () => {
6097 const borderValues = userBorderStyles === null || userBorderStyles === void 0 ? void 0 : userBorderStyles.radius;
6098
6099 if (typeof borderValues === 'object') {
6100 return Object.entries(borderValues).some(Boolean);
6101 }
6102
6103 return !!borderValues;
6104 };
6105
6106 const resetAll = () => {
6107 setBorderColor(undefined);
6108 setBorderRadius(undefined);
6109 setBorderStyle(undefined);
6110 setBorderWidth(undefined);
6111 };
6112
6113 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
6114 label: (0,external_wp_i18n_namespaceObject.__)('Border'),
6115 resetAll: resetAll
6116 }, showBorderWidth && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6117 className: "single-column",
6118 hasValue: createHasValueCallback('width'),
6119 label: (0,external_wp_i18n_namespaceObject.__)('Width'),
6120 onDeselect: createResetCallback(setBorderWidth),
6121 isShownByDefault: true
6122 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
6123 value: borderWidthValue,
6124 label: (0,external_wp_i18n_namespaceObject.__)('Width'),
6125 min: MIN_BORDER_WIDTH,
6126 onChange: handleOnChangeWithStyle(setBorderWidth),
6127 units: units
6128 })), showBorderStyle && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6129 className: "single-column",
6130 hasValue: createHasValueCallback('style'),
6131 label: (0,external_wp_i18n_namespaceObject.__)('Style'),
6132 onDeselect: createResetCallback(setBorderStyle),
6133 isShownByDefault: true
6134 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBorderStyleControl, {
6135 value: borderStyle,
6136 onChange: handleOnChange(setBorderStyle)
6137 })), showBorderColor && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6138 hasValue: createHasValueCallback('color'),
6139 label: (0,external_wp_i18n_namespaceObject.__)('Color'),
6140 onDeselect: createResetCallback(setBorderColor),
6141 isShownByDefault: true
6142 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientSettingsDropdown, {
6143 __experimentalHasMultipleOrigins: true,
6144 __experimentalIsRenderedInSidebar: true,
6145 disableCustomColors: disableCustomColors,
6146 disableCustomGradients: disableCustomGradients,
6147 enableAlpha: true,
6148 settings: borderColorSettings
6149 })), showBorderRadius && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6150 hasValue: hasBorderRadius,
6151 label: (0,external_wp_i18n_namespaceObject.__)('Radius'),
6152 onDeselect: createResetCallback(setBorderRadius),
6153 isShownByDefault: true
6154 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBorderRadiusControl, {
6155 values: borderRadiusValues,
6156 onChange: handleOnChange(setBorderRadius)
6157 })));
6158 }
6159
6160 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-utils.js
6161 /**
6162 * Internal dependencies
6163 */
6164
6165 function useHasColorPanel(name) {
6166 const supports = getSupportedGlobalStylesPanels(name);
6167 return supports.includes('color') || supports.includes('backgroundColor') || supports.includes('background') || supports.includes('linkColor');
6168 }
6169
6170 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/dimensions-panel.js
6171
6172
6173 /**
6174 * WordPress dependencies
6175 */
6176
6177
6178
6179 /**
6180 * Internal dependencies
6181 */
6182
6183
6184 const AXIAL_SIDES = ['horizontal', 'vertical'];
6185 function useHasDimensionsPanel(name) {
6186 const hasPadding = useHasPadding(name);
6187 const hasMargin = useHasMargin(name);
6188 const hasGap = useHasGap(name);
6189 return hasPadding || hasMargin || hasGap;
6190 }
6191
6192 function useHasPadding(name) {
6193 const supports = getSupportedGlobalStylesPanels(name);
6194 const [settings] = useSetting('spacing.padding', name);
6195 return settings && supports.includes('padding');
6196 }
6197
6198 function useHasMargin(name) {
6199 const supports = getSupportedGlobalStylesPanels(name);
6200 const [settings] = useSetting('spacing.margin', name);
6201 return settings && supports.includes('margin');
6202 }
6203
6204 function useHasGap(name) {
6205 const supports = getSupportedGlobalStylesPanels(name);
6206 const [settings] = useSetting('spacing.blockGap', name); // Do not show the gap control panel for block-level global styles
6207 // as they do not work on the frontend.
6208 // See: https://github.com/WordPress/gutenberg/pull/39845.
6209 // We can revert this condition when they're working again.
6210
6211 return !!name ? false : settings && supports.includes('--wp--style--block-gap');
6212 }
6213
6214 function filterValuesBySides(values, sides) {
6215 if (!sides) {
6216 // If no custom side configuration all sides are opted into by default.
6217 return values;
6218 } // Only include sides opted into within filtered values.
6219
6220
6221 const filteredValues = {};
6222 sides.forEach(side => {
6223 if (side === 'vertical') {
6224 filteredValues.top = values.top;
6225 filteredValues.bottom = values.bottom;
6226 }
6227
6228 if (side === 'horizontal') {
6229 filteredValues.left = values.left;
6230 filteredValues.right = values.right;
6231 }
6232
6233 filteredValues[side] = values[side];
6234 });
6235 return filteredValues;
6236 }
6237
6238 function splitStyleValue(value) {
6239 // Check for shorthand value ( a string value ).
6240 if (value && typeof value === 'string') {
6241 // Convert to value for individual sides for BoxControl.
6242 return {
6243 top: value,
6244 right: value,
6245 bottom: value,
6246 left: value
6247 };
6248 }
6249
6250 return value;
6251 }
6252
6253 function DimensionsPanel(_ref) {
6254 let {
6255 name
6256 } = _ref;
6257 const showPaddingControl = useHasPadding(name);
6258 const showMarginControl = useHasMargin(name);
6259 const showGapControl = useHasGap(name);
6260 const units = (0,external_wp_components_namespaceObject.__experimentalUseCustomUnits)({
6261 availableUnits: useSetting('spacing.units', name)[0] || ['%', 'px', 'em', 'rem', 'vw']
6262 });
6263 const [rawPadding, setRawPadding] = useStyle('spacing.padding', name);
6264 const paddingValues = splitStyleValue(rawPadding);
6265 const paddingSides = (0,external_wp_blockEditor_namespaceObject.__experimentalUseCustomSides)(name, 'padding');
6266 const isAxialPadding = paddingSides && paddingSides.some(side => AXIAL_SIDES.includes(side));
6267
6268 const setPaddingValues = newPaddingValues => {
6269 const padding = filterValuesBySides(newPaddingValues, paddingSides);
6270 setRawPadding(padding);
6271 };
6272
6273 const resetPaddingValue = () => setPaddingValues({});
6274
6275 const hasPaddingValue = () => !!paddingValues && Object.keys(paddingValues).length;
6276
6277 const [rawMargin, setRawMargin] = useStyle('spacing.margin', name);
6278 const marginValues = splitStyleValue(rawMargin);
6279 const marginSides = (0,external_wp_blockEditor_namespaceObject.__experimentalUseCustomSides)(name, 'margin');
6280 const isAxialMargin = marginSides && marginSides.some(side => AXIAL_SIDES.includes(side));
6281
6282 const setMarginValues = newMarginValues => {
6283 const margin = filterValuesBySides(newMarginValues, marginSides);
6284 setRawMargin(margin);
6285 };
6286
6287 const resetMarginValue = () => setMarginValues({});
6288
6289 const hasMarginValue = () => !!marginValues && Object.keys(marginValues).length;
6290
6291 const [gapValue, setGapValue] = useStyle('spacing.blockGap', name);
6292
6293 const resetGapValue = () => setGapValue(undefined);
6294
6295 const hasGapValue = () => !!gapValue;
6296
6297 const resetAll = () => {
6298 resetPaddingValue();
6299 resetMarginValue();
6300 resetGapValue();
6301 };
6302
6303 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanel, {
6304 label: (0,external_wp_i18n_namespaceObject.__)('Dimensions'),
6305 resetAll: resetAll
6306 }, showPaddingControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6307 hasValue: hasPaddingValue,
6308 label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
6309 onDeselect: resetPaddingValue,
6310 isShownByDefault: true
6311 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
6312 values: paddingValues,
6313 onChange: setPaddingValues,
6314 label: (0,external_wp_i18n_namespaceObject.__)('Padding'),
6315 sides: paddingSides,
6316 units: units,
6317 allowReset: false,
6318 splitOnAxis: isAxialPadding
6319 })), showMarginControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6320 hasValue: hasMarginValue,
6321 label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
6322 onDeselect: resetMarginValue,
6323 isShownByDefault: true
6324 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalBoxControl, {
6325 values: marginValues,
6326 onChange: setMarginValues,
6327 label: (0,external_wp_i18n_namespaceObject.__)('Margin'),
6328 sides: marginSides,
6329 units: units,
6330 allowReset: false,
6331 splitOnAxis: isAxialMargin
6332 })), showGapControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToolsPanelItem, {
6333 hasValue: hasGapValue,
6334 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
6335 onDeselect: resetGapValue,
6336 isShownByDefault: true
6337 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalUnitControl, {
6338 label: (0,external_wp_i18n_namespaceObject.__)('Block spacing'),
6339 __unstableInputWidth: "80px",
6340 min: 0,
6341 onChange: setGapValue,
6342 units: units,
6343 value: gapValue
6344 })));
6345 }
6346
6347 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/typography-panel.js
6348
6349
6350 /**
6351 * WordPress dependencies
6352 */
6353
6354
6355 /**
6356 * Internal dependencies
6357 */
6358
6359
6360 function useHasTypographyPanel(name) {
6361 const hasLineHeight = useHasLineHeightControl(name);
6362 const hasFontAppearance = useHasAppearanceControl(name);
6363 const hasLetterSpacing = useHasLetterSpacingControl(name);
6364 const supports = getSupportedGlobalStylesPanels(name);
6365 return hasLineHeight || hasFontAppearance || hasLetterSpacing || supports.includes('fontSize');
6366 }
6367
6368 function useHasLineHeightControl(name) {
6369 const supports = getSupportedGlobalStylesPanels(name);
6370 return useSetting('typography.lineHeight', name)[0] && supports.includes('lineHeight');
6371 }
6372
6373 function useHasAppearanceControl(name) {
6374 const supports = getSupportedGlobalStylesPanels(name);
6375 const hasFontStyles = useSetting('typography.fontStyle', name)[0] && supports.includes('fontStyle');
6376 const hasFontWeights = useSetting('typography.fontWeight', name)[0] && supports.includes('fontWeight');
6377 return hasFontStyles || hasFontWeights;
6378 }
6379
6380 function useHasLetterSpacingControl(name) {
6381 const supports = getSupportedGlobalStylesPanels(name);
6382 return useSetting('typography.letterSpacing', name)[0] && supports.includes('letterSpacing');
6383 }
6384
6385 function TypographyPanel(_ref) {
6386 let {
6387 name,
6388 element
6389 } = _ref;
6390 const supports = getSupportedGlobalStylesPanels(name);
6391 const prefix = element === 'text' || !element ? '' : `elements.${element}.`;
6392 const [fontSizes] = useSetting('typography.fontSizes', name);
6393 const disableCustomFontSizes = !useSetting('typography.customFontSize', name)[0];
6394 const [fontFamilies] = useSetting('typography.fontFamilies', name);
6395 const hasFontStyles = useSetting('typography.fontStyle', name)[0] && supports.includes('fontStyle');
6396 const hasFontWeights = useSetting('typography.fontWeight', name)[0] && supports.includes('fontWeight');
6397 const hasLineHeightEnabled = useHasLineHeightControl(name);
6398 const hasAppearanceControl = useHasAppearanceControl(name);
6399 const hasLetterSpacingControl = useHasLetterSpacingControl(name);
6400 const [fontFamily, setFontFamily] = useStyle(prefix + 'typography.fontFamily', name);
6401 const [fontSize, setFontSize] = useStyle(prefix + 'typography.fontSize', name);
6402 const [fontStyle, setFontStyle] = useStyle(prefix + 'typography.fontStyle', name);
6403 const [fontWeight, setFontWeight] = useStyle(prefix + 'typography.fontWeight', name);
6404 const [lineHeight, setLineHeight] = useStyle(prefix + 'typography.lineHeight', name);
6405 const [letterSpacing, setLetterSpacing] = useStyle(prefix + 'typography.letterSpacing', name);
6406 const [backgroundColor] = useStyle(prefix + 'color.background', name);
6407 const [gradientValue] = useStyle(prefix + 'color.gradient', name);
6408 const [color] = useStyle(prefix + 'color.text', name);
6409 const extraStyles = element === 'link' ? {
6410 textDecoration: 'underline'
6411 } : {};
6412 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
6413 className: "edit-site-typography-panel",
6414 initialOpen: true
6415 }, (0,external_wp_element_namespaceObject.createElement)("div", {
6416 className: "edit-site-typography-panel__preview",
6417 style: {
6418 fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif',
6419 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
6420 color,
6421 fontSize,
6422 fontStyle,
6423 fontWeight,
6424 letterSpacing,
6425 ...extraStyles
6426 }
6427 }, "Aa"), supports.includes('fontFamily') && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalFontFamilyControl, {
6428 fontFamilies: fontFamilies,
6429 value: fontFamily,
6430 onChange: setFontFamily
6431 }), supports.includes('fontSize') && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FontSizePicker, {
6432 value: fontSize,
6433 onChange: setFontSize,
6434 fontSizes: fontSizes,
6435 disableCustomFontSizes: disableCustomFontSizes
6436 }), hasLineHeightEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, {
6437 marginBottom: 6
6438 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.LineHeightControl, {
6439 __nextHasNoMarginBottom: true,
6440 value: lineHeight,
6441 onChange: setLineHeight
6442 })), hasAppearanceControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalFontAppearanceControl, {
6443 value: {
6444 fontStyle,
6445 fontWeight
6446 },
6447 onChange: _ref2 => {
6448 let {
6449 fontStyle: newFontStyle,
6450 fontWeight: newFontWeight
6451 } = _ref2;
6452 setFontStyle(newFontStyle);
6453 setFontWeight(newFontWeight);
6454 },
6455 hasFontStyles: hasFontStyles,
6456 hasFontWeights: hasFontWeights
6457 }), hasLetterSpacingControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLetterSpacingControl, {
6458 value: letterSpacing,
6459 onChange: setLetterSpacing
6460 }));
6461 }
6462
6463 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/context-menu.js
6464
6465
6466 /**
6467 * WordPress dependencies
6468 */
6469
6470
6471
6472 /**
6473 * Internal dependencies
6474 */
6475
6476
6477
6478
6479
6480
6481
6482 function ContextMenu(_ref) {
6483 let {
6484 name,
6485 parentMenu = ''
6486 } = _ref;
6487 const hasTypographyPanel = useHasTypographyPanel(name);
6488 const hasColorPanel = useHasColorPanel(name);
6489 const hasBorderPanel = useHasBorderPanel(name);
6490 const hasDimensionsPanel = useHasDimensionsPanel(name);
6491 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
6492 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, hasTypographyPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
6493 icon: library_typography,
6494 path: parentMenu + '/typography'
6495 }, (0,external_wp_i18n_namespaceObject.__)('Typography')), hasColorPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
6496 icon: library_color,
6497 path: parentMenu + '/colors'
6498 }, (0,external_wp_i18n_namespaceObject.__)('Colors')), hasLayoutPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
6499 icon: library_layout,
6500 path: parentMenu + '/layout'
6501 }, (0,external_wp_i18n_namespaceObject.__)('Layout')));
6502 }
6503
6504 /* harmony default export */ var context_menu = (ContextMenu);
6505
6506 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/utils.js
6507 /**
6508 * External dependencies
6509 */
6510
6511 /**
6512 * Internal dependencies
6513 */
6514
6515 function generateBoxRules(style, options, path, ruleKey) {
6516 const boxStyle = (0,external_lodash_namespaceObject.get)(style, path);
6517
6518 if (!boxStyle) {
6519 return [];
6520 }
6521
6522 const rules = [];
6523
6524 if (typeof boxStyle === 'string') {
6525 rules.push({
6526 selector: options.selector,
6527 key: ruleKey,
6528 value: boxStyle
6529 });
6530 } else {
6531 const sideRules = ['top', 'right', 'bottom', 'left'].reduce((acc, side) => {
6532 const value = (0,external_lodash_namespaceObject.get)(boxStyle, [side]);
6533
6534 if (value) {
6535 acc.push({
6536 selector: options.selector,
6537 key: `${ruleKey}${(0,external_lodash_namespaceObject.upperFirst)(side)}`,
6538 value
6539 });
6540 }
6541
6542 return acc;
6543 }, []);
6544 rules.push(...sideRules);
6545 }
6546
6547 return rules;
6548 }
6549
6550 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/padding.js
6551 /**
6552 * Internal dependencies
6553 */
6554
6555 const padding = {
6556 name: 'padding',
6557 generate: (style, options) => {
6558 return generateBoxRules(style, options, ['spacing', 'padding'], 'padding');
6559 }
6560 };
6561 /* harmony default export */ var styles_padding = (padding);
6562
6563 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/margin.js
6564 /**
6565 * Internal dependencies
6566 */
6567
6568 const margin = {
6569 name: 'margin',
6570 generate: (style, options) => {
6571 return generateBoxRules(style, options, ['spacing', 'margin'], 'margin');
6572 }
6573 };
6574 /* harmony default export */ var styles_margin = (margin);
6575
6576 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/styles/index.js
6577 /**
6578 * Internal dependencies
6579 */
6580
6581
6582 const styleDefinitions = [styles_margin, styles_padding];
6583
6584 ;// CONCATENATED MODULE: ./packages/style-engine/build-module/index.js
6585 /**
6586 * External dependencies
6587 */
6588
6589 /**
6590 * Internal dependencies
6591 */
6592
6593
6594 /**
6595 * Generates a stylesheet for a given style object and selector.
6596 *
6597 * @param style Style object.
6598 * @param options Options object with settings to adjust how the styles are generated.
6599 *
6600 * @return generated stylesheet.
6601 */
6602
6603 function generate(style, options) {
6604 const rules = getCSSRules(style, options);
6605 const groupedRules = groupBy(rules, 'selector');
6606 const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => {
6607 acc.push(`${subSelector} { ${groupedRules[subSelector].map(rule => `${kebabCase(rule.key)}: ${rule.value};`).join(' ')} }`);
6608 return acc;
6609 }, []);
6610 return selectorRules.join('\n');
6611 }
6612 /**
6613 * Returns a JSON representation of the generated CSS rules.
6614 *
6615 * @param style Style object.
6616 * @param options Options object with settings to adjust how the styles are generated.
6617 *
6618 * @return generated styles.
6619 */
6620
6621 function getCSSRules(style, options) {
6622 const rules = [];
6623 styleDefinitions.forEach(definition => {
6624 rules.push(...definition.generate(style, options));
6625 });
6626 return rules;
6627 }
6628
6629 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/use-global-styles-output.js
6630 /**
6631 * External dependencies
6632 */
6633
6634 /**
6635 * WordPress dependencies
6636 */
6637
6638
6639
6640
6641 /**
6642 * Internal dependencies
6643 */
6644
6645 /**
6646 * Internal dependencies
6647 */
6648
6649
6650
6651
6652 function compileStyleValue(uncompiledValue) {
6653 const VARIABLE_REFERENCE_PREFIX = 'var:';
6654 const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
6655 const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
6656
6657 if ((0,external_lodash_namespaceObject.startsWith)(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
6658 const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
6659 return `var(--wp--${variable})`;
6660 }
6661
6662 return uncompiledValue;
6663 }
6664 /**
6665 * Transform given preset tree into a set of style declarations.
6666 *
6667 * @param {Object} blockPresets
6668 *
6669 * @return {Array} An array of style declarations.
6670 */
6671
6672
6673 function getPresetsDeclarations() {
6674 let blockPresets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6675 return (0,external_lodash_namespaceObject.reduce)(PRESET_METADATA, (declarations, _ref) => {
6676 let {
6677 path,
6678 valueKey,
6679 cssVarInfix
6680 } = _ref;
6681 const presetByOrigin = (0,external_lodash_namespaceObject.get)(blockPresets, path, []);
6682 ['default', 'theme', 'custom'].forEach(origin => {
6683 if (presetByOrigin[origin]) {
6684 presetByOrigin[origin].forEach(value => {
6685 declarations.push(`--wp--preset--${cssVarInfix}--${(0,external_lodash_namespaceObject.kebabCase)(value.slug)}: ${value[valueKey]}`);
6686 });
6687 }
6688 });
6689 return declarations;
6690 }, []);
6691 }
6692 /**
6693 * Transform given preset tree into a set of preset class declarations.
6694 *
6695 * @param {string} blockSelector
6696 * @param {Object} blockPresets
6697 * @return {string} CSS declarations for the preset classes.
6698 */
6699
6700
6701 function getPresetsClasses(blockSelector) {
6702 let blockPresets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6703 return (0,external_lodash_namespaceObject.reduce)(PRESET_METADATA, (declarations, _ref2) => {
6704 let {
6705 path,
6706 cssVarInfix,
6707 classes
6708 } = _ref2;
6709
6710 if (!classes) {
6711 return declarations;
6712 }
6713
6714 const presetByOrigin = (0,external_lodash_namespaceObject.get)(blockPresets, path, []);
6715 ['default', 'theme', 'custom'].forEach(origin => {
6716 if (presetByOrigin[origin]) {
6717 presetByOrigin[origin].forEach(_ref3 => {
6718 let {
6719 slug
6720 } = _ref3;
6721 classes.forEach(_ref4 => {
6722 let {
6723 classSuffix,
6724 propertyName
6725 } = _ref4;
6726 const classSelectorToUse = `.has-${(0,external_lodash_namespaceObject.kebabCase)(slug)}-${classSuffix}`;
6727 const selectorToUse = blockSelector.split(',') // Selector can be "h1, h2, h3"
6728 .map(selector => `${selector}${classSelectorToUse}`).join(',');
6729 const value = `var(--wp--preset--${cssVarInfix}--${(0,external_lodash_namespaceObject.kebabCase)(slug)})`;
6730 declarations += `${selectorToUse}{${propertyName}: ${value} !important;}`;
6731 });
6732 });
6733 }
6734 });
6735 return declarations;
6736 }, '');
6737 }
6738
6739 function flattenTree() {
6740 let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6741 let prefix = arguments.length > 1 ? arguments[1] : undefined;
6742 let token = arguments.length > 2 ? arguments[2] : undefined;
6743 let result = [];
6744 Object.keys(input).forEach(key => {
6745 const newKey = prefix + (0,external_lodash_namespaceObject.kebabCase)(key.replace('/', '-'));
6746 const newLeaf = input[key];
6747
6748 if (newLeaf instanceof Object) {
6749 const newPrefix = newKey + token;
6750 result = [...result, ...flattenTree(newLeaf, newPrefix, token)];
6751 } else {
6752 result.push(`${newKey}: ${newLeaf}`);
6753 }
6754 });
6755 return result;
6756 }
6757 /**
6758 * Transform given style tree into a set of style declarations.
6759 *
6760 * @param {Object} blockStyles Block styles.
6761 *
6762 * @return {Array} An array of style declarations.
6763 */
6764
6765
6766 function getStylesDeclarations() {
6767 let blockStyles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6768 const output = (0,external_lodash_namespaceObject.reduce)(external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY, (declarations, _ref5, key) => {
6769 let {
6770 value,
6771 properties,
6772 useEngine
6773 } = _ref5;
6774 const pathToValue = value;
6775
6776 if ((0,external_lodash_namespaceObject.first)(pathToValue) === 'elements' || useEngine) {
6777 return declarations;
6778 }
6779
6780 const styleValue = (0,external_lodash_namespaceObject.get)(blockStyles, pathToValue);
6781
6782 if (!!properties && !(0,external_lodash_namespaceObject.isString)(styleValue)) {
6783 Object.entries(properties).forEach(entry => {
6784 const [name, prop] = entry;
6785
6786 if (!(0,external_lodash_namespaceObject.get)(styleValue, [prop], false)) {
6787 // Do not create a declaration
6788 // for sub-properties that don't have any value.
6789 return;
6790 }
6791
6792 const cssProperty = (0,external_lodash_namespaceObject.kebabCase)(name);
6793 declarations.push(`${cssProperty}: ${compileStyleValue((0,external_lodash_namespaceObject.get)(styleValue, [prop]))}`);
6794 });
6795 } else if ((0,external_lodash_namespaceObject.get)(blockStyles, pathToValue, false)) {
6796 const cssProperty = key.startsWith('--') ? key : (0,external_lodash_namespaceObject.kebabCase)(key);
6797 declarations.push(`${cssProperty}: ${compileStyleValue((0,external_lodash_namespaceObject.get)(blockStyles, pathToValue))}`);
6798 }
6799
6800 return declarations;
6801 }, []); // The goal is to move everything to server side generated engine styles
6802 // This is temporary as we absorb more and more styles into the engine.
6803
6804 const extraRules = getCSSRules(blockStyles, {
6805 selector: 'self'
6806 });
6807 extraRules.forEach(rule => {
6808 if (rule.selector !== 'self') {
6809 throw "This style can't be added as inline style";
6810 }
6811
6812 const cssProperty = rule.key.startsWith('--') ? rule.key : (0,external_lodash_namespaceObject.kebabCase)(rule.key);
6813 output.push(`${cssProperty}: ${compileStyleValue(rule.value)}`);
6814 });
6815 return output;
6816 }
6817
6818 const getNodesWithStyles = (tree, blockSelectors) => {
6819 var _tree$styles, _tree$styles2;
6820
6821 const nodes = [];
6822
6823 if (!(tree !== null && tree !== void 0 && tree.styles)) {
6824 return nodes;
6825 }
6826
6827 const pickStyleKeys = treeToPickFrom => (0,external_lodash_namespaceObject.pickBy)(treeToPickFrom, (value, key) => ['border', 'color', 'spacing', 'typography'].includes(key)); // Top-level.
6828
6829
6830 const styles = pickStyleKeys(tree.styles);
6831
6832 if (!!styles) {
6833 nodes.push({
6834 styles,
6835 selector: ROOT_BLOCK_SELECTOR
6836 });
6837 }
6838
6839 (0,external_lodash_namespaceObject.forEach)((_tree$styles = tree.styles) === null || _tree$styles === void 0 ? void 0 : _tree$styles.elements, (value, key) => {
6840 if (!!value && !!external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[key]) {
6841 nodes.push({
6842 styles: value,
6843 selector: external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[key]
6844 });
6845 }
6846 }); // Iterate over blocks: they can have styles & elements.
6847
6848 (0,external_lodash_namespaceObject.forEach)((_tree$styles2 = tree.styles) === null || _tree$styles2 === void 0 ? void 0 : _tree$styles2.blocks, (node, blockName) => {
6849 var _blockSelectors$block;
6850
6851 const blockStyles = pickStyleKeys(node);
6852
6853 if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
6854 nodes.push({
6855 styles: blockStyles,
6856 selector: blockSelectors[blockName].selector
6857 });
6858 }
6859
6860 (0,external_lodash_namespaceObject.forEach)(node === null || node === void 0 ? void 0 : node.elements, (value, elementName) => {
6861 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])) {
6862 nodes.push({
6863 styles: value,
6864 selector: blockSelectors[blockName].selector.split(',').map(sel => sel + ' ' + external_wp_blocks_namespaceObject.__EXPERIMENTAL_ELEMENTS[elementName]).join(',')
6865 });
6866 }
6867 });
6868 });
6869 return nodes;
6870 };
6871 const getNodesWithSettings = (tree, blockSelectors) => {
6872 var _tree$settings, _tree$settings2;
6873
6874 const nodes = [];
6875
6876 if (!(tree !== null && tree !== void 0 && tree.settings)) {
6877 return nodes;
6878 }
6879
6880 const pickPresets = treeToPickFrom => {
6881 const presets = {};
6882 PRESET_METADATA.forEach(_ref6 => {
6883 let {
6884 path
6885 } = _ref6;
6886 const value = (0,external_lodash_namespaceObject.get)(treeToPickFrom, path, false);
6887
6888 if (value !== false) {
6889 (0,external_lodash_namespaceObject.set)(presets, path, value);
6890 }
6891 });
6892 return presets;
6893 }; // Top-level.
6894
6895
6896 const presets = pickPresets(tree.settings);
6897 const custom = (_tree$settings = tree.settings) === null || _tree$settings === void 0 ? void 0 : _tree$settings.custom;
6898
6899 if (!(0,external_lodash_namespaceObject.isEmpty)(presets) || !!custom) {
6900 nodes.push({
6901 presets,
6902 custom,
6903 selector: ROOT_BLOCK_SELECTOR
6904 });
6905 } // Blocks.
6906
6907
6908 (0,external_lodash_namespaceObject.forEach)((_tree$settings2 = tree.settings) === null || _tree$settings2 === void 0 ? void 0 : _tree$settings2.blocks, (node, blockName) => {
6909 const blockPresets = pickPresets(node);
6910 const blockCustom = node.custom;
6911
6912 if (!(0,external_lodash_namespaceObject.isEmpty)(blockPresets) || !!blockCustom) {
6913 nodes.push({
6914 presets: blockPresets,
6915 custom: blockCustom,
6916 selector: blockSelectors[blockName].selector
6917 });
6918 }
6919 });
6920 return nodes;
6921 };
6922 const toCustomProperties = (tree, blockSelectors) => {
6923 const settings = getNodesWithSettings(tree, blockSelectors);
6924 let ruleset = '';
6925 settings.forEach(_ref7 => {
6926 let {
6927 presets,
6928 custom,
6929 selector
6930 } = _ref7;
6931 const declarations = getPresetsDeclarations(presets);
6932 const customProps = flattenTree(custom, '--wp--custom--', '--');
6933
6934 if (customProps.length > 0) {
6935 declarations.push(...customProps);
6936 }
6937
6938 if (declarations.length > 0) {
6939 ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
6940 }
6941 });
6942 return ruleset;
6943 };
6944 const toStyles = (tree, blockSelectors) => {
6945 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
6946 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
6947 let ruleset = '.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }';
6948 nodesWithStyles.forEach(_ref8 => {
6949 let {
6950 selector,
6951 styles
6952 } = _ref8;
6953 const declarations = getStylesDeclarations(styles);
6954
6955 if (declarations.length === 0) {
6956 return;
6957 }
6958
6959 ruleset = ruleset + `${selector}{${declarations.join(';')};}`;
6960 });
6961 nodesWithSettings.forEach(_ref9 => {
6962 let {
6963 selector,
6964 presets
6965 } = _ref9;
6966
6967 if (ROOT_BLOCK_SELECTOR === selector) {
6968 // Do not add extra specificity for top-level classes.
6969 selector = '';
6970 }
6971
6972 const classes = getPresetsClasses(selector, presets);
6973
6974 if (!(0,external_lodash_namespaceObject.isEmpty)(classes)) {
6975 ruleset = ruleset + classes;
6976 }
6977 });
6978 return ruleset;
6979 };
6980
6981 const getBlockSelectors = blockTypes => {
6982 const result = {};
6983 blockTypes.forEach(blockType => {
6984 var _blockType$supports$_, _blockType$supports;
6985
6986 const name = blockType.name;
6987 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('/', '-');
6988 result[name] = {
6989 name,
6990 selector
6991 };
6992 });
6993 return result;
6994 };
6995
6996 function useGlobalStylesOutput() {
6997 const [stylesheets, setStylesheets] = (0,external_wp_element_namespaceObject.useState)([]);
6998 const [settings, setSettings] = (0,external_wp_element_namespaceObject.useState)({});
6999 const {
7000 merged: mergedConfig
7001 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
7002 (0,external_wp_element_namespaceObject.useEffect)(() => {
7003 if (!(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.styles) || !(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.settings)) {
7004 return;
7005 }
7006
7007 const blockSelectors = getBlockSelectors((0,external_wp_blocks_namespaceObject.getBlockTypes)());
7008 const customProperties = toCustomProperties(mergedConfig, blockSelectors);
7009 const globalStyles = toStyles(mergedConfig, blockSelectors);
7010 setStylesheets([{
7011 css: customProperties,
7012 isGlobalStyles: true
7013 }, {
7014 css: globalStyles,
7015 isGlobalStyles: true
7016 }]);
7017 setSettings(mergedConfig.settings);
7018 }, [mergedConfig]);
7019 return [stylesheets, settings];
7020 }
7021
7022 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/preview.js
7023
7024
7025 /**
7026 * WordPress dependencies
7027 */
7028
7029
7030
7031
7032 /**
7033 * Internal dependencies
7034 */
7035
7036
7037
7038 const firstFrame = {
7039 start: {
7040 opacity: 1,
7041 display: 'block'
7042 },
7043 hover: {
7044 opacity: 0,
7045 display: 'none'
7046 }
7047 };
7048 const secondFrame = {
7049 hover: {
7050 opacity: 1,
7051 display: 'block'
7052 },
7053 start: {
7054 opacity: 0,
7055 display: 'none'
7056 }
7057 };
7058 const normalizedWidth = 248;
7059 const normalizedHeight = 152;
7060 const normalizedColorSwatchSize = 32;
7061
7062 const StylesPreview = _ref => {
7063 let {
7064 label,
7065 isFocused
7066 } = _ref;
7067 const [fontWeight] = useStyle('typography.fontWeight');
7068 const [fontFamily = 'serif'] = useStyle('typography.fontFamily');
7069 const [headingFontFamily = fontFamily] = useStyle('elements.h1.typography.fontFamily');
7070 const [headingFontWeight = fontWeight] = useStyle('elements.h1.typography.fontWeight');
7071 const [textColor = 'black'] = useStyle('color.text');
7072 const [headingColor = textColor] = useStyle('elements.h1.color.text');
7073 const [linkColor = 'blue'] = useStyle('elements.link.color.text');
7074 const [backgroundColor = 'white'] = useStyle('color.background');
7075 const [gradientValue] = useStyle('color.gradient');
7076 const [styles] = useGlobalStylesOutput();
7077 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
7078 const [coreColors] = useSetting('color.palette.core');
7079 const [themeColors] = useSetting('color.palette.theme');
7080 const [customColors] = useSetting('color.palette.custom');
7081 const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false);
7082 const [containerResizeListener, {
7083 width
7084 }] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
7085 const ratio = width ? width / normalizedWidth : 1;
7086 const paletteColors = (themeColors !== null && themeColors !== void 0 ? themeColors : []).concat(customColors !== null && customColors !== void 0 ? customColors : []).concat(coreColors !== null && coreColors !== void 0 ? coreColors : []);
7087 const highlightedColors = paletteColors.filter( // we exclude these two colors because they are already visible in the preview.
7088 _ref2 => {
7089 let {
7090 color
7091 } = _ref2;
7092 return color !== backgroundColor && color !== headingColor;
7093 }).slice(0, 2);
7094 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, {
7095 className: "edit-site-global-styles-preview__iframe",
7096 head: (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
7097 styles: styles
7098 }),
7099 style: {
7100 height: normalizedHeight * ratio,
7101 visibility: !width ? 'hidden' : 'visible'
7102 },
7103 onMouseEnter: () => setIsHovered(true),
7104 onMouseLeave: () => setIsHovered(false),
7105 tabIndex: -1
7106 }, containerResizeListener, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
7107 style: {
7108 height: normalizedHeight * ratio,
7109 width: '100%',
7110 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
7111 cursor: 'pointer'
7112 },
7113 initial: "start",
7114 animate: (isHovered || isFocused) && !disableMotion ? 'hover' : 'start'
7115 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
7116 variants: firstFrame,
7117 style: {
7118 height: '100%',
7119 overflow: 'hidden'
7120 }
7121 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7122 spacing: 10 * ratio,
7123 justify: "center",
7124 style: {
7125 height: '100%',
7126 overflow: 'hidden'
7127 }
7128 }, (0,external_wp_element_namespaceObject.createElement)("div", {
7129 style: {
7130 fontFamily: headingFontFamily,
7131 fontSize: 65 * ratio,
7132 color: headingColor,
7133 fontWeight: headingFontWeight
7134 }
7135 }, "Aa"), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7136 spacing: 4 * ratio
7137 }, highlightedColors.map(_ref3 => {
7138 let {
7139 slug,
7140 color
7141 } = _ref3;
7142 return (0,external_wp_element_namespaceObject.createElement)("div", {
7143 key: slug,
7144 style: {
7145 height: normalizedColorSwatchSize * ratio,
7146 width: normalizedColorSwatchSize * ratio,
7147 background: color,
7148 borderRadius: normalizedColorSwatchSize * ratio / 2
7149 }
7150 });
7151 })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
7152 variants: secondFrame,
7153 style: {
7154 height: '100%',
7155 overflow: 'hidden'
7156 }
7157 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7158 spacing: 3 * ratio,
7159 justify: "center",
7160 style: {
7161 height: '100%',
7162 overflow: 'hidden',
7163 padding: 10 * ratio,
7164 boxSizing: 'border-box'
7165 }
7166 }, label && (0,external_wp_element_namespaceObject.createElement)("div", {
7167 style: {
7168 fontSize: 35 * ratio,
7169 fontFamily: headingFontFamily,
7170 color: headingColor,
7171 fontWeight: headingFontWeight,
7172 lineHeight: '1em'
7173 }
7174 }, label), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7175 spacing: 2 * ratio,
7176 justify: "flex-start"
7177 }, (0,external_wp_element_namespaceObject.createElement)("div", {
7178 style: {
7179 fontFamily,
7180 fontSize: 24 * ratio,
7181 color: textColor
7182 }
7183 }, "Aa"), (0,external_wp_element_namespaceObject.createElement)("div", {
7184 style: {
7185 fontFamily,
7186 fontSize: 24 * ratio,
7187 color: linkColor
7188 }
7189 }, "Aa")), paletteColors && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7190 spacing: 0
7191 }, paletteColors.slice(0, 4).map((_ref4, index) => {
7192 let {
7193 color
7194 } = _ref4;
7195 return (0,external_wp_element_namespaceObject.createElement)("div", {
7196 key: index,
7197 style: {
7198 height: 10 * ratio,
7199 width: 30 * ratio,
7200 background: color,
7201 flexGrow: 1
7202 }
7203 });
7204 }))))));
7205 };
7206
7207 /* harmony default export */ var preview = (StylesPreview);
7208
7209 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-root.js
7210
7211
7212 /**
7213 * WordPress dependencies
7214 */
7215
7216
7217
7218
7219
7220 /**
7221 * Internal dependencies
7222 */
7223
7224
7225
7226
7227
7228
7229 function ScreenRoot() {
7230 const {
7231 variations
7232 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7233 return {
7234 variations: select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations()
7235 };
7236 }, []);
7237 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
7238 size: "small"
7239 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7240 spacing: 2
7241 }, (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)(NavigationButton, {
7242 path: "/variations"
7243 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7244 justify: "space-between"
7245 }, (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, {
7246 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
7247 }))))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (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.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks for the whole site.')), (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
7248 path: "/blocks"
7249 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7250 justify: "space-between"
7251 }, (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, {
7252 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
7253 }))))));
7254 }
7255
7256 /* harmony default export */ var screen_root = (ScreenRoot);
7257
7258 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/header.js
7259
7260
7261 /**
7262 * WordPress dependencies
7263 */
7264
7265
7266
7267 /**
7268 * Internal dependencies
7269 */
7270
7271
7272
7273 function ScreenHeader(_ref) {
7274 let {
7275 title,
7276 description
7277 } = _ref;
7278 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7279 spacing: 2
7280 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7281 spacing: 2
7282 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalView, null, (0,external_wp_element_namespaceObject.createElement)(NavigationBackButton, {
7283 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
7284 size: "small",
7285 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view')
7286 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
7287 level: 5
7288 }, title))), description && (0,external_wp_element_namespaceObject.createElement)("p", {
7289 className: "edit-site-global-styles-header__description"
7290 }, description));
7291 }
7292
7293 /* harmony default export */ var header = (ScreenHeader);
7294
7295 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-block-list.js
7296
7297
7298 /**
7299 * WordPress dependencies
7300 */
7301
7302
7303
7304
7305
7306
7307
7308
7309 /**
7310 * Internal dependencies
7311 */
7312
7313
7314
7315
7316
7317
7318
7319
7320 function useSortedBlockTypes() {
7321 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,
7322 // because third party blocks can be registered earlier than
7323 // the core blocks (usually by using the `init` action),
7324 // thus affecting the display order.
7325 // We don't sort reusable blocks as they are handled differently.
7326
7327 const groupByType = (blocks, block) => {
7328 const {
7329 core,
7330 noncore
7331 } = blocks;
7332 const type = block.name.startsWith('core/') ? core : noncore;
7333 type.push(block);
7334 return blocks;
7335 };
7336
7337 const {
7338 core: coreItems,
7339 noncore: nonCoreItems
7340 } = blockItems.reduce(groupByType, {
7341 core: [],
7342 noncore: []
7343 });
7344 return [...coreItems, ...nonCoreItems];
7345 }
7346
7347 function BlockMenuItem(_ref) {
7348 let {
7349 block
7350 } = _ref;
7351 const hasTypographyPanel = useHasTypographyPanel(block.name);
7352 const hasColorPanel = useHasColorPanel(block.name);
7353 const hasBorderPanel = useHasBorderPanel(block.name);
7354 const hasDimensionsPanel = useHasDimensionsPanel(block.name);
7355 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
7356 const hasBlockMenuItem = hasTypographyPanel || hasColorPanel || hasLayoutPanel;
7357
7358 if (!hasBlockMenuItem) {
7359 return null;
7360 }
7361
7362 return (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
7363 path: '/blocks/' + block.name
7364 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7365 justify: "flex-start"
7366 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, {
7367 icon: block.icon
7368 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, block.title)));
7369 }
7370
7371 function ScreenBlockList() {
7372 const sortedBlockTypes = useSortedBlockTypes();
7373 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
7374 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
7375 const isMatchingSearchTerm = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).isMatchingSearchTerm, []);
7376 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
7377 if (!filterValue) {
7378 return sortedBlockTypes;
7379 }
7380
7381 return sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue));
7382 }, [filterValue, sortedBlockTypes, isMatchingSearchTerm]);
7383 const blockTypesListRef = (0,external_wp_element_namespaceObject.useRef)(); // Announce search results on change
7384
7385 (0,external_wp_element_namespaceObject.useEffect)(() => {
7386 if (!filterValue) {
7387 return;
7388 } // We extract the results from the wrapper div's `ref` because
7389 // filtered items can contain items that will eventually not
7390 // render and there is no reliable way to detect when a child
7391 // will return `null`.
7392 // TODO: We should find a better way of handling this as it's
7393 // fragile and depends on the number of rendered elements of `BlockMenuItem`,
7394 // which is now one.
7395 // @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116
7396
7397
7398 const count = blockTypesListRef.current.childElementCount;
7399 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
7400 /* translators: %d: number of results. */
7401 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
7402 debouncedSpeak(resultsFoundMessage, count);
7403 }, [filterValue, debouncedSpeak]);
7404 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7405 title: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
7406 description: (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks and for the whole site.')
7407 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, {
7408 className: "edit-site-block-types-search",
7409 onChange: setFilterValue,
7410 value: filterValue,
7411 label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks'),
7412 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search')
7413 }), (0,external_wp_element_namespaceObject.createElement)("div", {
7414 ref: blockTypesListRef,
7415 className: "edit-site-block-types-item-list"
7416 }, filteredBlockTypes.map(block => (0,external_wp_element_namespaceObject.createElement)(BlockMenuItem, {
7417 block: block,
7418 key: 'menu-itemblock-' + block.name
7419 }))));
7420 }
7421
7422 /* harmony default export */ var screen_block_list = (ScreenBlockList);
7423
7424 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-block.js
7425
7426
7427 /**
7428 * WordPress dependencies
7429 */
7430
7431 /**
7432 * Internal dependencies
7433 */
7434
7435
7436
7437
7438 function ScreenBlock(_ref) {
7439 let {
7440 name
7441 } = _ref;
7442 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name);
7443 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7444 title: blockType.title
7445 }), (0,external_wp_element_namespaceObject.createElement)(context_menu, {
7446 parentMenu: '/blocks/' + name,
7447 name: name
7448 }));
7449 }
7450
7451 /* harmony default export */ var screen_block = (ScreenBlock);
7452
7453 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/subtitle.js
7454
7455
7456 /**
7457 * WordPress dependencies
7458 */
7459
7460
7461 function Subtitle(_ref) {
7462 let {
7463 children
7464 } = _ref;
7465 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
7466 className: "edit-site-global-styles-subtitle",
7467 level: 2
7468 }, children);
7469 }
7470
7471 /* harmony default export */ var subtitle = (Subtitle);
7472
7473 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-typography.js
7474
7475
7476 /**
7477 * WordPress dependencies
7478 */
7479
7480
7481 /**
7482 * Internal dependencies
7483 */
7484
7485
7486
7487
7488
7489
7490
7491 function Item(_ref) {
7492 let {
7493 name,
7494 parentMenu,
7495 element,
7496 label
7497 } = _ref;
7498 const hasSupport = !name;
7499 const prefix = element === 'text' || !element ? '' : `elements.${element}.`;
7500 const extraStyles = element === 'link' ? {
7501 textDecoration: 'underline'
7502 } : {};
7503 const [fontFamily] = useStyle(prefix + 'typography.fontFamily', name);
7504 const [fontStyle] = useStyle(prefix + 'typography.fontStyle', name);
7505 const [fontWeight] = useStyle(prefix + 'typography.fontWeight', name);
7506 const [letterSpacing] = useStyle(prefix + 'typography.letterSpacing', name);
7507 const [backgroundColor] = useStyle(prefix + 'color.background', name);
7508 const [gradientValue] = useStyle(prefix + 'color.gradient', name);
7509 const [color] = useStyle(prefix + 'color.text', name);
7510
7511 if (!hasSupport) {
7512 return null;
7513 }
7514
7515 return (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
7516 path: parentMenu + '/typography/' + element
7517 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7518 justify: "flex-start"
7519 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
7520 className: "edit-site-global-styles-screen-typography__indicator",
7521 style: {
7522 fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif',
7523 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor,
7524 color,
7525 fontStyle,
7526 fontWeight,
7527 letterSpacing,
7528 ...extraStyles
7529 }
7530 }, (0,external_wp_i18n_namespaceObject.__)('Aa')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, label)));
7531 }
7532
7533 function ScreenTypography(_ref2) {
7534 let {
7535 name
7536 } = _ref2;
7537 const parentMenu = name === undefined ? '' : '/blocks/' + name;
7538 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7539 title: (0,external_wp_i18n_namespaceObject.__)('Typography'),
7540 description: (0,external_wp_i18n_namespaceObject.__)('Manage the typography settings for different elements.')
7541 }), !name && (0,external_wp_element_namespaceObject.createElement)("div", {
7542 className: "edit-site-global-styles-screen-typography"
7543 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7544 spacing: 3
7545 }, (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, {
7546 isBordered: true,
7547 isSeparated: true
7548 }, (0,external_wp_element_namespaceObject.createElement)(Item, {
7549 name: name,
7550 parentMenu: parentMenu,
7551 element: "text",
7552 label: (0,external_wp_i18n_namespaceObject.__)('Text')
7553 }), (0,external_wp_element_namespaceObject.createElement)(Item, {
7554 name: name,
7555 parentMenu: parentMenu,
7556 element: "link",
7557 label: (0,external_wp_i18n_namespaceObject.__)('Links')
7558 })))), !!name && (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, {
7559 name: name,
7560 element: "text"
7561 }));
7562 }
7563
7564 /* harmony default export */ var screen_typography = (ScreenTypography);
7565
7566 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-typography-element.js
7567
7568
7569 /**
7570 * WordPress dependencies
7571 */
7572
7573 /**
7574 * Internal dependencies
7575 */
7576
7577
7578
7579 const screen_typography_element_elements = {
7580 text: {
7581 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts used on the site.'),
7582 title: (0,external_wp_i18n_namespaceObject.__)('Text')
7583 },
7584 link: {
7585 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on the links.'),
7586 title: (0,external_wp_i18n_namespaceObject.__)('Links')
7587 }
7588 };
7589
7590 function ScreenTypographyElement(_ref) {
7591 let {
7592 name,
7593 element
7594 } = _ref;
7595 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7596 title: screen_typography_element_elements[element].title,
7597 description: screen_typography_element_elements[element].description
7598 }), (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, {
7599 name: name,
7600 element: element
7601 }));
7602 }
7603
7604 /* harmony default export */ var screen_typography_element = (ScreenTypographyElement);
7605
7606 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-indicator-wrapper.js
7607
7608
7609
7610 /**
7611 * External dependencies
7612 */
7613
7614 /**
7615 * WordPress dependencies
7616 */
7617
7618
7619
7620 function ColorIndicatorWrapper(_ref) {
7621 let {
7622 className,
7623 ...props
7624 } = _ref;
7625 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, extends_extends({
7626 className: classnames_default()('edit-site-global-styles__color-indicator-wrapper', className)
7627 }, props));
7628 }
7629
7630 /* harmony default export */ var color_indicator_wrapper = (ColorIndicatorWrapper);
7631
7632 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/palette.js
7633
7634
7635 /**
7636 * WordPress dependencies
7637 */
7638
7639
7640
7641 /**
7642 * Internal dependencies
7643 */
7644
7645
7646
7647
7648
7649 const EMPTY_COLORS = [];
7650
7651 function Palette(_ref) {
7652 let {
7653 name
7654 } = _ref;
7655 const [customColors] = useSetting('color.palette.custom');
7656 const [themeColors] = useSetting('color.palette.theme');
7657 const [defaultColors] = useSetting('color.palette.default');
7658 const [defaultPaletteEnabled] = useSetting('color.defaultPalette', name);
7659 const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(customColors || EMPTY_COLORS), ...(themeColors || EMPTY_COLORS), ...(defaultColors && defaultPaletteEnabled ? defaultColors : EMPTY_COLORS)], [customColors, themeColors, defaultColors, defaultPaletteEnabled]);
7660 const screenPath = !name ? '/colors/palette' : '/blocks/' + name + '/colors/palette';
7661 const paletteButtonText = colors.length > 0 ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of palette colors.
7662 (0,external_wp_i18n_namespaceObject._n)('%d color', '%d colors', colors.length), colors.length) : (0,external_wp_i18n_namespaceObject.__)('Add custom colors');
7663 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7664 spacing: 3
7665 }, (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, {
7666 isBordered: true,
7667 isSeparated: true
7668 }, (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
7669 path: screenPath
7670 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7671 direction: colors.length === 0 ? 'row-reverse' : 'row'
7672 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalZStack, {
7673 isLayered: false,
7674 offset: -8
7675 }, colors.slice(0, 5).map(_ref2 => {
7676 let {
7677 color
7678 } = _ref2;
7679 return (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
7680 key: color
7681 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
7682 colorValue: color
7683 }));
7684 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, paletteButtonText)))));
7685 }
7686
7687 /* harmony default export */ var palette = (Palette);
7688
7689 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-colors.js
7690
7691
7692 /**
7693 * WordPress dependencies
7694 */
7695
7696
7697 /**
7698 * Internal dependencies
7699 */
7700
7701
7702
7703
7704
7705
7706
7707
7708 function BackgroundColorItem(_ref) {
7709 let {
7710 name,
7711 parentMenu
7712 } = _ref;
7713 const supports = getSupportedGlobalStylesPanels(name);
7714 const hasSupport = supports.includes('backgroundColor') || supports.includes('background');
7715 const [backgroundColor] = useStyle('color.background', name);
7716 const [gradientValue] = useStyle('color.gradient', name);
7717
7718 if (!hasSupport) {
7719 return null;
7720 }
7721
7722 return (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
7723 path: parentMenu + '/colors/background'
7724 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7725 justify: "flex-start"
7726 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
7727 expanded: false
7728 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
7729 colorValue: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor
7730 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Background'))));
7731 }
7732
7733 function TextColorItem(_ref2) {
7734 let {
7735 name,
7736 parentMenu
7737 } = _ref2;
7738 const supports = getSupportedGlobalStylesPanels(name);
7739 const hasSupport = supports.includes('color');
7740 const [color] = useStyle('color.text', name);
7741
7742 if (!hasSupport) {
7743 return null;
7744 }
7745
7746 return (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
7747 path: parentMenu + '/colors/text'
7748 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7749 justify: "flex-start"
7750 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
7751 expanded: false
7752 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
7753 colorValue: color
7754 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Text'))));
7755 }
7756
7757 function LinkColorItem(_ref3) {
7758 let {
7759 name,
7760 parentMenu
7761 } = _ref3;
7762 const supports = getSupportedGlobalStylesPanels(name);
7763 const hasSupport = supports.includes('linkColor');
7764 const [color] = useStyle('elements.link.color.text', name);
7765
7766 if (!hasSupport) {
7767 return null;
7768 }
7769
7770 return (0,external_wp_element_namespaceObject.createElement)(NavigationButton, {
7771 path: parentMenu + '/colors/link'
7772 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
7773 justify: "flex-start"
7774 }, (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, {
7775 expanded: false
7776 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, {
7777 colorValue: color
7778 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Links'))));
7779 }
7780
7781 function ScreenColors(_ref4) {
7782 let {
7783 name
7784 } = _ref4;
7785 const parentMenu = name === undefined ? '' : '/blocks/' + name;
7786 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7787 title: (0,external_wp_i18n_namespaceObject.__)('Colors'),
7788 description: (0,external_wp_i18n_namespaceObject.__)('Manage palettes and the default color of different global elements on the site.')
7789 }), (0,external_wp_element_namespaceObject.createElement)("div", {
7790 className: "edit-site-global-styles-screen-colors"
7791 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7792 spacing: 10
7793 }, (0,external_wp_element_namespaceObject.createElement)(palette, {
7794 name: name
7795 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7796 spacing: 3
7797 }, (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, {
7798 isBordered: true,
7799 isSeparated: true
7800 }, (0,external_wp_element_namespaceObject.createElement)(BackgroundColorItem, {
7801 name: name,
7802 parentMenu: parentMenu
7803 }), (0,external_wp_element_namespaceObject.createElement)(TextColorItem, {
7804 name: name,
7805 parentMenu: parentMenu
7806 }), (0,external_wp_element_namespaceObject.createElement)(LinkColorItem, {
7807 name: name,
7808 parentMenu: parentMenu
7809 }))))));
7810 }
7811
7812 /* harmony default export */ var screen_colors = (ScreenColors);
7813
7814 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/color-palette-panel.js
7815
7816
7817 /**
7818 * WordPress dependencies
7819 */
7820
7821
7822 /**
7823 * Internal dependencies
7824 */
7825
7826
7827 function ColorPalettePanel(_ref) {
7828 let {
7829 name
7830 } = _ref;
7831 const [themeColors, setThemeColors] = useSetting('color.palette.theme', name);
7832 const [baseThemeColors] = useSetting('color.palette.theme', name, 'base');
7833 const [defaultColors, setDefaultColors] = useSetting('color.palette.default', name);
7834 const [baseDefaultColors] = useSetting('color.palette.default', name, 'base');
7835 const [customColors, setCustomColors] = useSetting('color.palette.custom', name);
7836 const [defaultPaletteEnabled] = useSetting('color.defaultPalette', name);
7837 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7838 className: "edit-site-global-styles-color-palette-panel",
7839 spacing: 10
7840 }, !!themeColors && !!themeColors.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
7841 canReset: themeColors !== baseThemeColors,
7842 canOnlyChangeValues: true,
7843 colors: themeColors,
7844 onChange: setThemeColors,
7845 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme')
7846 }), !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
7847 canReset: defaultColors !== baseDefaultColors,
7848 canOnlyChangeValues: true,
7849 colors: defaultColors,
7850 onChange: setDefaultColors,
7851 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default')
7852 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
7853 colors: customColors,
7854 onChange: setCustomColors,
7855 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'),
7856 emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom colors are empty! Add some colors to create your own color palette.'),
7857 slugPrefix: "custom-"
7858 }));
7859 }
7860
7861 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/gradients-palette-panel.js
7862
7863
7864 /**
7865 * External dependencies
7866 */
7867
7868 /**
7869 * WordPress dependencies
7870 */
7871
7872
7873
7874 /**
7875 * Internal dependencies
7876 */
7877
7878
7879
7880 function GradientPalettePanel(_ref) {
7881 let {
7882 name
7883 } = _ref;
7884 const [themeGradients, setThemeGradients] = useSetting('color.gradients.theme', name);
7885 const [baseThemeGradients] = useSetting('color.gradients.theme', name, 'base');
7886 const [defaultGradients, setDefaultGradients] = useSetting('color.gradients.default', name);
7887 const [baseDefaultGradients] = useSetting('color.gradients.default', name, 'base');
7888 const [customGradients, setCustomGradients] = useSetting('color.gradients.custom', name);
7889 const [defaultPaletteEnabled] = useSetting('color.defaultGradients', name);
7890 const [duotonePalette] = useSetting('color.duotone') || [];
7891 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, {
7892 className: "edit-site-global-styles-gradient-palette-panel",
7893 spacing: 10
7894 }, !!themeGradients && !!themeGradients.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
7895 canReset: themeGradients !== baseThemeGradients,
7896 canOnlyChangeValues: true,
7897 gradients: themeGradients,
7898 onChange: setThemeGradients,
7899 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme')
7900 }), !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
7901 canReset: defaultGradients !== baseDefaultGradients,
7902 canOnlyChangeValues: true,
7903 gradients: defaultGradients,
7904 onChange: setDefaultGradients,
7905 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default')
7906 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, {
7907 gradients: customGradients,
7908 onChange: setCustomGradients,
7909 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'),
7910 emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom gradients are empty! Add some gradients to create your own palette.'),
7911 slugPrefix: "custom-"
7912 }), (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, {
7913 margin: 3
7914 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotonePicker, {
7915 duotonePalette: duotonePalette,
7916 disableCustomDuotone: true,
7917 disableCustomColors: true,
7918 clearable: false,
7919 onChange: external_lodash_namespaceObject.noop
7920 })));
7921 }
7922
7923 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-color-palette.js
7924
7925
7926 /**
7927 * WordPress dependencies
7928 */
7929
7930
7931
7932 /**
7933 * Internal dependencies
7934 */
7935
7936
7937
7938
7939
7940 function ScreenColorPalette(_ref) {
7941 let {
7942 name
7943 } = _ref;
7944 const [currentTab, setCurrentTab] = (0,external_wp_element_namespaceObject.useState)('solid');
7945 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
7946 title: (0,external_wp_i18n_namespaceObject.__)('Palette'),
7947 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.')
7948 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, {
7949 className: "edit-site-screen-color-palette-toggle",
7950 value: currentTab,
7951 onChange: setCurrentTab,
7952 label: (0,external_wp_i18n_namespaceObject.__)('Select palette type'),
7953 hideLabelFromVision: true,
7954 isBlock: true
7955 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
7956 value: "solid",
7957 label: (0,external_wp_i18n_namespaceObject.__)('Solid')
7958 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, {
7959 value: "gradient",
7960 label: (0,external_wp_i18n_namespaceObject.__)('Gradient')
7961 })), currentTab === 'solid' && (0,external_wp_element_namespaceObject.createElement)(ColorPalettePanel, {
7962 name: name
7963 }), currentTab === 'gradient' && (0,external_wp_element_namespaceObject.createElement)(GradientPalettePanel, {
7964 name: name
7965 }));
7966 }
7967
7968 /* harmony default export */ var screen_color_palette = (ScreenColorPalette);
7969
7970 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-background-color.js
7971
7972
7973
7974 /**
7975 * WordPress dependencies
7976 */
7977
7978
7979 /**
7980 * Internal dependencies
7981 */
7982
7983
7984
7985
7986 function ScreenBackgroundColor(_ref) {
7987 let {
7988 name
7989 } = _ref;
7990 const supports = getSupportedGlobalStylesPanels(name);
7991 const [solids] = useSetting('color.palette', name);
7992 const [gradients] = useSetting('color.gradients', name);
7993 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
7994 const [areCustomGradientsEnabled] = useSetting('color.customGradient', name);
7995 const colorsPerOrigin = useColorsPerOrigin(name);
7996 const gradientsPerOrigin = useGradientsPerOrigin(name);
7997 const [isBackgroundEnabled] = useSetting('color.background', name);
7998 const hasBackgroundColor = supports.includes('backgroundColor') && isBackgroundEnabled && (solids.length > 0 || areCustomSolidsEnabled);
7999 const hasGradientColor = supports.includes('background') && (gradients.length > 0 || areCustomGradientsEnabled);
8000 const [backgroundColor, setBackgroundColor] = useStyle('color.background', name);
8001 const [userBackgroundColor] = useStyle('color.background', name, 'user');
8002 const [gradient, setGradient] = useStyle('color.gradient', name);
8003 const [userGradient] = useStyle('color.gradient', name, 'user');
8004
8005 if (!hasBackgroundColor && !hasGradientColor) {
8006 return null;
8007 }
8008
8009 let backgroundSettings = {};
8010
8011 if (hasBackgroundColor) {
8012 backgroundSettings = {
8013 colorValue: backgroundColor,
8014 onColorChange: setBackgroundColor
8015 };
8016
8017 if (backgroundColor) {
8018 backgroundSettings.clearable = backgroundColor === userBackgroundColor;
8019 }
8020 }
8021
8022 let gradientSettings = {};
8023
8024 if (hasGradientColor) {
8025 gradientSettings = {
8026 gradientValue: gradient,
8027 onGradientChange: setGradient
8028 };
8029
8030 if (gradient) {
8031 gradientSettings.clearable = gradient === userGradient;
8032 }
8033 }
8034
8035 const controlProps = { ...backgroundSettings,
8036 ...gradientSettings
8037 };
8038 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8039 title: (0,external_wp_i18n_namespaceObject.__)('Background'),
8040 description: (0,external_wp_i18n_namespaceObject.__)('Set a background color or gradient for the whole site.')
8041 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, extends_extends({
8042 className: "edit-site-screen-background-color__control",
8043 colors: colorsPerOrigin,
8044 gradients: gradientsPerOrigin,
8045 disableCustomColors: !areCustomSolidsEnabled,
8046 disableCustomGradients: !areCustomGradientsEnabled,
8047 __experimentalHasMultipleOrigins: true,
8048 showTitle: false,
8049 enableAlpha: true,
8050 __experimentalIsRenderedInSidebar: true
8051 }, controlProps)));
8052 }
8053
8054 /* harmony default export */ var screen_background_color = (ScreenBackgroundColor);
8055
8056 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-text-color.js
8057
8058
8059 /**
8060 * WordPress dependencies
8061 */
8062
8063
8064 /**
8065 * Internal dependencies
8066 */
8067
8068
8069
8070
8071 function ScreenTextColor(_ref) {
8072 let {
8073 name
8074 } = _ref;
8075 const supports = getSupportedGlobalStylesPanels(name);
8076 const [solids] = useSetting('color.palette', name);
8077 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
8078 const [isTextEnabled] = useSetting('color.text', name);
8079 const colorsPerOrigin = useColorsPerOrigin(name);
8080 const hasTextColor = supports.includes('color') && isTextEnabled && (solids.length > 0 || areCustomSolidsEnabled);
8081 const [color, setColor] = useStyle('color.text', name);
8082 const [userColor] = useStyle('color.text', name, 'user');
8083
8084 if (!hasTextColor) {
8085 return null;
8086 }
8087
8088 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8089 title: (0,external_wp_i18n_namespaceObject.__)('Text'),
8090 description: (0,external_wp_i18n_namespaceObject.__)('Set the default color used for text across the site.')
8091 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
8092 className: "edit-site-screen-text-color__control",
8093 colors: colorsPerOrigin,
8094 disableCustomColors: !areCustomSolidsEnabled,
8095 __experimentalHasMultipleOrigins: true,
8096 showTitle: false,
8097 enableAlpha: true,
8098 __experimentalIsRenderedInSidebar: true,
8099 colorValue: color,
8100 onColorChange: setColor,
8101 clearable: color === userColor
8102 }));
8103 }
8104
8105 /* harmony default export */ var screen_text_color = (ScreenTextColor);
8106
8107 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-link-color.js
8108
8109
8110 /**
8111 * WordPress dependencies
8112 */
8113
8114
8115 /**
8116 * Internal dependencies
8117 */
8118
8119
8120
8121
8122 function ScreenLinkColor(_ref) {
8123 let {
8124 name
8125 } = _ref;
8126 const supports = getSupportedGlobalStylesPanels(name);
8127 const [solids] = useSetting('color.palette', name);
8128 const [areCustomSolidsEnabled] = useSetting('color.custom', name);
8129 const colorsPerOrigin = useColorsPerOrigin(name);
8130 const [isLinkEnabled] = useSetting('color.link', name);
8131 const hasLinkColor = supports.includes('linkColor') && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
8132 const [linkColor, setLinkColor] = useStyle('elements.link.color.text', name);
8133 const [userLinkColor] = useStyle('elements.link.color.text', name, 'user');
8134
8135 if (!hasLinkColor) {
8136 return null;
8137 }
8138
8139 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8140 title: (0,external_wp_i18n_namespaceObject.__)('Links'),
8141 description: (0,external_wp_i18n_namespaceObject.__)('Set the default color used for links across the site.')
8142 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalColorGradientControl, {
8143 className: "edit-site-screen-link-color__control",
8144 colors: colorsPerOrigin,
8145 disableCustomColors: !areCustomSolidsEnabled,
8146 __experimentalHasMultipleOrigins: true,
8147 showTitle: false,
8148 enableAlpha: true,
8149 __experimentalIsRenderedInSidebar: true,
8150 colorValue: linkColor,
8151 onColorChange: setLinkColor,
8152 clearable: linkColor === userLinkColor
8153 }));
8154 }
8155
8156 /* harmony default export */ var screen_link_color = (ScreenLinkColor);
8157
8158 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-layout.js
8159
8160
8161 /**
8162 * WordPress dependencies
8163 */
8164
8165 /**
8166 * Internal dependencies
8167 */
8168
8169
8170
8171
8172
8173 function ScreenLayout(_ref) {
8174 let {
8175 name
8176 } = _ref;
8177 const hasBorderPanel = useHasBorderPanel(name);
8178 const hasDimensionsPanel = useHasDimensionsPanel(name);
8179 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8180 title: (0,external_wp_i18n_namespaceObject.__)('Layout')
8181 }), hasDimensionsPanel && (0,external_wp_element_namespaceObject.createElement)(DimensionsPanel, {
8182 name: name
8183 }), hasBorderPanel && (0,external_wp_element_namespaceObject.createElement)(BorderPanel, {
8184 name: name
8185 }));
8186 }
8187
8188 /* harmony default export */ var screen_layout = (ScreenLayout);
8189
8190 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/global-styles-provider.js
8191
8192
8193 /**
8194 * External dependencies
8195 */
8196
8197 /**
8198 * WordPress dependencies
8199 */
8200
8201
8202
8203
8204 /**
8205 * Internal dependencies
8206 */
8207
8208
8209
8210 function mergeTreesCustomizer(_, srcValue) {
8211 // We only pass as arrays the presets,
8212 // in which case we want the new array of values
8213 // to override the old array (no merging).
8214 if (Array.isArray(srcValue)) {
8215 return srcValue;
8216 }
8217 }
8218
8219 function mergeBaseAndUserConfigs(base, user) {
8220 return (0,external_lodash_namespaceObject.mergeWith)({}, base, user, mergeTreesCustomizer);
8221 }
8222
8223 const cleanEmptyObject = object => {
8224 if (!(0,external_lodash_namespaceObject.isObject)(object) || Array.isArray(object)) {
8225 return object;
8226 }
8227
8228 const cleanedNestedObjects = (0,external_lodash_namespaceObject.pickBy)((0,external_lodash_namespaceObject.mapValues)(object, cleanEmptyObject), external_lodash_namespaceObject.identity);
8229 return (0,external_lodash_namespaceObject.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
8230 };
8231
8232 function useGlobalStylesUserConfig() {
8233 const {
8234 globalStylesId,
8235 settings,
8236 styles
8237 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8238 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId();
8239
8240 const record = _globalStylesId ? select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined;
8241 return {
8242 globalStylesId: _globalStylesId,
8243 settings: record === null || record === void 0 ? void 0 : record.settings,
8244 styles: record === null || record === void 0 ? void 0 : record.styles
8245 };
8246 }, []);
8247 const {
8248 getEditedEntityRecord
8249 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
8250 const {
8251 editEntityRecord
8252 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
8253 const config = (0,external_wp_element_namespaceObject.useMemo)(() => {
8254 return {
8255 settings: settings !== null && settings !== void 0 ? settings : {},
8256 styles: styles !== null && styles !== void 0 ? styles : {}
8257 };
8258 }, [settings, styles]);
8259 const setConfig = (0,external_wp_element_namespaceObject.useCallback)(callback => {
8260 var _record$styles, _record$settings;
8261
8262 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
8263 const currentConfig = {
8264 styles: (_record$styles = record === null || record === void 0 ? void 0 : record.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
8265 settings: (_record$settings = record === null || record === void 0 ? void 0 : record.settings) !== null && _record$settings !== void 0 ? _record$settings : {}
8266 };
8267 const updatedConfig = callback(currentConfig);
8268 editEntityRecord('root', 'globalStyles', globalStylesId, {
8269 styles: cleanEmptyObject(updatedConfig.styles) || {},
8270 settings: cleanEmptyObject(updatedConfig.settings) || {}
8271 });
8272 }, [globalStylesId]);
8273 return [!!settings || !!styles, config, setConfig];
8274 }
8275
8276 function useGlobalStylesBaseConfig() {
8277 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => {
8278 return select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles();
8279 }, []);
8280 return [!!baseConfig, baseConfig];
8281 }
8282
8283 function useGlobalStylesContext() {
8284 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
8285 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
8286 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
8287 if (!baseConfig || !userConfig) {
8288 return {};
8289 }
8290
8291 return mergeBaseAndUserConfigs(baseConfig, userConfig);
8292 }, [userConfig, baseConfig]);
8293 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
8294 return {
8295 isReady: isUserConfigReady && isBaseConfigReady,
8296 user: userConfig,
8297 base: baseConfig,
8298 merged: mergedConfig,
8299 setUserConfig
8300 };
8301 }, [mergedConfig, userConfig, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]);
8302 return context;
8303 }
8304
8305 function GlobalStylesProvider(_ref) {
8306 let {
8307 children
8308 } = _ref;
8309 const context = useGlobalStylesContext();
8310
8311 if (!context.isReady) {
8312 return null;
8313 }
8314
8315 return (0,external_wp_element_namespaceObject.createElement)(GlobalStylesContext.Provider, {
8316 value: context
8317 }, children);
8318 }
8319
8320 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/screen-style-variations.js
8321
8322
8323 /**
8324 * External dependencies
8325 */
8326
8327
8328 /**
8329 * WordPress dependencies
8330 */
8331
8332
8333
8334
8335
8336
8337
8338 /**
8339 * Internal dependencies
8340 */
8341
8342
8343
8344
8345
8346
8347 function compareVariations(a, b) {
8348 return (0,external_lodash_namespaceObject.isEqual)(a.styles, b.styles) && (0,external_lodash_namespaceObject.isEqual)(a.settings, b.settings);
8349 }
8350
8351 function Variation(_ref) {
8352 let {
8353 variation
8354 } = _ref;
8355 const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false);
8356 const {
8357 base,
8358 user,
8359 setUserConfig
8360 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
8361 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
8362 var _variation$settings, _variation$styles;
8363
8364 return {
8365 user: {
8366 settings: (_variation$settings = variation.settings) !== null && _variation$settings !== void 0 ? _variation$settings : {},
8367 styles: (_variation$styles = variation.styles) !== null && _variation$styles !== void 0 ? _variation$styles : {}
8368 },
8369 base,
8370 merged: mergeBaseAndUserConfigs(base, variation),
8371 setUserConfig: () => {}
8372 };
8373 }, [variation, base]);
8374
8375 const selectVariation = () => {
8376 setUserConfig(() => {
8377 return {
8378 settings: variation.settings,
8379 styles: variation.styles
8380 };
8381 });
8382 };
8383
8384 const selectOnEnter = event => {
8385 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
8386 event.preventDefault();
8387 selectVariation();
8388 }
8389 };
8390
8391 const isActive = (0,external_wp_element_namespaceObject.useMemo)(() => {
8392 return compareVariations(user, variation);
8393 }, [user, variation]);
8394 return (0,external_wp_element_namespaceObject.createElement)(GlobalStylesContext.Provider, {
8395 value: context
8396 }, (0,external_wp_element_namespaceObject.createElement)("div", {
8397 className: classnames_default()('edit-site-global-styles-variations_item', {
8398 'is-active': isActive
8399 }),
8400 role: "button",
8401 onClick: selectVariation,
8402 onKeyDown: selectOnEnter,
8403 tabIndex: "0",
8404 "aria-label": variation === null || variation === void 0 ? void 0 : variation.title,
8405 onFocus: () => setIsFocused(true),
8406 onBlur: () => setIsFocused(false)
8407 }, (0,external_wp_element_namespaceObject.createElement)("div", {
8408 className: "edit-site-global-styles-variations_item-preview"
8409 }, (0,external_wp_element_namespaceObject.createElement)(preview, {
8410 label: variation === null || variation === void 0 ? void 0 : variation.title,
8411 isFocused: isFocused
8412 }))));
8413 }
8414
8415 function ScreenStyleVariations() {
8416 const {
8417 variations
8418 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8419 return {
8420 variations: select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations()
8421 };
8422 }, []);
8423 const withEmptyVariation = (0,external_wp_element_namespaceObject.useMemo)(() => {
8424 return [{
8425 title: (0,external_wp_i18n_namespaceObject.__)('Default'),
8426 settings: {},
8427 styles: {}
8428 }, ...variations];
8429 }, [variations]);
8430 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(header, {
8431 back: "/",
8432 title: (0,external_wp_i18n_namespaceObject.__)('Browse styles'),
8433 description: (0,external_wp_i18n_namespaceObject.__)('Choose a different style combination for the theme styles')
8434 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, {
8435 size: "small",
8436 isBorderless: true
8437 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalGrid, {
8438 columns: 2
8439 }, withEmptyVariation === null || withEmptyVariation === void 0 ? void 0 : withEmptyVariation.map((variation, index) => (0,external_wp_element_namespaceObject.createElement)(Variation, {
8440 key: index,
8441 variation: variation
8442 }))))));
8443 }
8444
8445 /* harmony default export */ var screen_style_variations = (ScreenStyleVariations);
8446
8447 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/ui.js
8448
8449
8450
8451 /**
8452 * WordPress dependencies
8453 */
8454
8455
8456 /**
8457 * Internal dependencies
8458 */
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473 function GlobalStylesNavigationScreen(_ref) {
8474 let {
8475 className,
8476 ...props
8477 } = _ref;
8478 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, extends_extends({
8479 className: ['edit-site-global-styles-sidebar__navigator-screen', className].filter(Boolean).join(' ')
8480 }, props));
8481 }
8482
8483 function ContextScreens(_ref2) {
8484 let {
8485 name
8486 } = _ref2;
8487 const parentMenu = name === undefined ? '' : '/blocks/' + name;
8488 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8489 path: parentMenu + '/typography'
8490 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography, {
8491 name: name
8492 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8493 path: parentMenu + '/typography/text'
8494 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, {
8495 name: name,
8496 element: "text"
8497 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8498 path: parentMenu + '/typography/link'
8499 }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, {
8500 name: name,
8501 element: "link"
8502 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8503 path: parentMenu + '/colors'
8504 }, (0,external_wp_element_namespaceObject.createElement)(screen_colors, {
8505 name: name
8506 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8507 path: parentMenu + '/colors/palette'
8508 }, (0,external_wp_element_namespaceObject.createElement)(screen_color_palette, {
8509 name: name
8510 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8511 path: parentMenu + '/colors/background'
8512 }, (0,external_wp_element_namespaceObject.createElement)(screen_background_color, {
8513 name: name
8514 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8515 path: parentMenu + '/colors/text'
8516 }, (0,external_wp_element_namespaceObject.createElement)(screen_text_color, {
8517 name: name
8518 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8519 path: parentMenu + '/colors/link'
8520 }, (0,external_wp_element_namespaceObject.createElement)(screen_link_color, {
8521 name: name
8522 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8523 path: parentMenu + '/layout'
8524 }, (0,external_wp_element_namespaceObject.createElement)(screen_layout, {
8525 name: name
8526 })));
8527 }
8528
8529 function GlobalStylesUI() {
8530 const blocks = (0,external_wp_blocks_namespaceObject.getBlockTypes)();
8531 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, {
8532 className: "edit-site-global-styles-sidebar__navigator-provider",
8533 initialPath: "/"
8534 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8535 path: "/"
8536 }, (0,external_wp_element_namespaceObject.createElement)(screen_root, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8537 path: "/variations"
8538 }, (0,external_wp_element_namespaceObject.createElement)(screen_style_variations, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8539 path: "/blocks"
8540 }, (0,external_wp_element_namespaceObject.createElement)(screen_block_list, null)), blocks.map(block => (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, {
8541 key: 'menu-block-' + block.name,
8542 path: '/blocks/' + block.name
8543 }, (0,external_wp_element_namespaceObject.createElement)(screen_block, {
8544 name: block.name
8545 }))), (0,external_wp_element_namespaceObject.createElement)(ContextScreens, null), blocks.map(block => (0,external_wp_element_namespaceObject.createElement)(ContextScreens, {
8546 key: 'screens-block-' + block.name,
8547 name: block.name
8548 })));
8549 }
8550
8551 /* harmony default export */ var ui = (GlobalStylesUI);
8552
8553 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/global-styles/index.js
8554
8555
8556
8557
8558 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/global-styles-sidebar.js
8559
8560
8561 /**
8562 * WordPress dependencies
8563 */
8564
8565
8566
8567
8568
8569 /**
8570 * Internal dependencies
8571 */
8572
8573
8574
8575 function GlobalStylesSidebar() {
8576 const [canReset, onReset] = useGlobalStylesReset();
8577 const {
8578 toggle
8579 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
8580 return (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
8581 className: "edit-site-global-styles-sidebar",
8582 identifier: "edit-site/global-styles",
8583 title: (0,external_wp_i18n_namespaceObject.__)('Styles'),
8584 icon: library_styles,
8585 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close global styles sidebar'),
8586 panelClassName: "edit-site-global-styles-sidebar__panel",
8587 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)("span", {
8588 className: "edit-site-global-styles-sidebar__beta"
8589 }, (0,external_wp_i18n_namespaceObject.__)('Beta'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
8590 icon: more_vertical,
8591 label: (0,external_wp_i18n_namespaceObject.__)('More Global Styles Actions'),
8592 toggleProps: {
8593 disabled: !canReset
8594 },
8595 controls: [{
8596 title: (0,external_wp_i18n_namespaceObject.__)('Reset to defaults'),
8597 onClick: onReset
8598 }, {
8599 title: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'),
8600 onClick: () => toggle('core/edit-site', 'welcomeGuideStyles')
8601 }]
8602 })))
8603 }, (0,external_wp_element_namespaceObject.createElement)(ui, null));
8604 }
8605
8606 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/navigation.js
8607
8608
8609 /**
8610 * WordPress dependencies
8611 */
8612
8613 const navigation = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
8614 viewBox: "0 0 24 24",
8615 xmlns: "http://www.w3.org/2000/svg"
8616 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
8617 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"
8618 }));
8619 /* harmony default export */ var library_navigation = (navigation);
8620
8621 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js
8622
8623
8624 /**
8625 * WordPress dependencies
8626 */
8627
8628
8629
8630 const ALLOWED_BLOCKS = {
8631 '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'],
8632 'core/social-links': ['core/social-link'],
8633 'core/navigation-submenu': ['core/navigation-link', 'core/navigation-submenu'],
8634 'core/navigation-link': ['core/navigation-link', 'core/navigation-submenu']
8635 };
8636 function NavigationMenu(_ref) {
8637 let {
8638 innerBlocks,
8639 id
8640 } = _ref;
8641 const {
8642 updateBlockListSettings
8643 } = (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
8644 //Think through a better way of doing this, possible with adding allowed blocks to block library metadata
8645
8646 (0,external_wp_element_namespaceObject.useEffect)(() => {
8647 updateBlockListSettings('', {
8648 allowedBlocks: ALLOWED_BLOCKS['core/navigation']
8649 });
8650 innerBlocks.forEach(block => {
8651 if (ALLOWED_BLOCKS[block.name]) {
8652 updateBlockListSettings(block.clientId, {
8653 allowedBlocks: ALLOWED_BLOCKS[block.name]
8654 });
8655 }
8656 });
8657 }, [updateBlockListSettings, innerBlocks]);
8658 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
8659 id: id,
8660 showNestedBlocks: true,
8661 expandNested: false,
8662 __experimentalFeatures: true,
8663 __experimentalPersistentListViewFeatures: true
8664 }));
8665 }
8666
8667 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js
8668
8669
8670 /**
8671 * WordPress dependencies
8672 */
8673
8674
8675
8676
8677
8678
8679
8680
8681 /**
8682 * Internal dependencies
8683 */
8684
8685
8686 const NAVIGATION_MENUS_QUERY = [{
8687 per_page: -1,
8688 status: 'publish'
8689 }];
8690 function NavigationInspector() {
8691 var _navigationMenus$;
8692
8693 const {
8694 selectedNavigationBlockId,
8695 clientIdToRef,
8696 navigationMenus,
8697 isResolvingNavigationMenus,
8698 hasResolvedNavigationMenus,
8699 firstNavigationBlockId
8700 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8701 const {
8702 __experimentalGetActiveBlockIdByBlockNames,
8703 __experimentalGetGlobalBlocksByName,
8704 getBlock
8705 } = select(external_wp_blockEditor_namespaceObject.store);
8706 const {
8707 getEntityRecords,
8708 hasFinishedResolution,
8709 isResolving
8710 } = select(external_wp_coreData_namespaceObject.store);
8711 const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY[0]]; // Get the active Navigation block (if present).
8712
8713 const selectedNavId = __experimentalGetActiveBlockIdByBlockNames('core/navigation'); // Get all Navigation blocks currently within the editor canvas.
8714
8715
8716 const navBlockIds = __experimentalGetGlobalBlocksByName('core/navigation');
8717
8718 const idToRef = {};
8719 navBlockIds.forEach(id => {
8720 var _getBlock, _getBlock$attributes;
8721
8722 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;
8723 });
8724 return {
8725 selectedNavigationBlockId: selectedNavId,
8726 firstNavigationBlockId: navBlockIds === null || navBlockIds === void 0 ? void 0 : navBlockIds[0],
8727 clientIdToRef: idToRef,
8728 navigationMenus: getEntityRecords(...navigationMenusQuery),
8729 isResolvingNavigationMenus: isResolving('getEntityRecords', navigationMenusQuery),
8730 hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
8731 };
8732 }, []);
8733 const navMenuListId = (0,external_wp_compose_namespaceObject.useInstanceId)(NavigationMenu, 'edit-site-navigation-inspector-menu');
8734 const firstNavRefInTemplate = clientIdToRef[firstNavigationBlockId];
8735 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:
8736 // - the Navigation Menu referenced by the first Nav block within the template.
8737 // - the first of the available Navigation Menus (`wp_navigation`) posts.
8738
8739 const defaultNavigationMenuId = firstNavRefInTemplate || firstNavigationMenuRef; // The Navigation Menu manually selected by the user within the Nav inspector.
8740
8741 const [currentMenuId, setCurrentMenuId] = (0,external_wp_element_namespaceObject.useState)(firstNavRefInTemplate); // If a Nav block is selected within the canvas then set the
8742 // Navigation Menu referenced by it's `ref` attribute to be
8743 // active within the Navigation sidebar.
8744
8745 (0,external_wp_element_namespaceObject.useEffect)(() => {
8746 if (selectedNavigationBlockId) {
8747 setCurrentMenuId(clientIdToRef[selectedNavigationBlockId]);
8748 }
8749 }, [selectedNavigationBlockId]);
8750 let options = [];
8751
8752 if (navigationMenus) {
8753 options = navigationMenus.map(_ref => {
8754 let {
8755 id,
8756 title
8757 } = _ref;
8758 return {
8759 value: id,
8760 label: title.rendered
8761 };
8762 });
8763 }
8764
8765 const [innerBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', 'wp_navigation', {
8766 id: currentMenuId || defaultNavigationMenuId
8767 });
8768 const {
8769 isLoadingInnerBlocks,
8770 hasLoadedInnerBlocks
8771 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8772 const {
8773 isResolving,
8774 hasFinishedResolution
8775 } = select(external_wp_coreData_namespaceObject.store);
8776 return {
8777 isLoadingInnerBlocks: isResolving('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId]),
8778 hasLoadedInnerBlocks: hasFinishedResolution('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId])
8779 };
8780 }, [currentMenuId, defaultNavigationMenuId]);
8781 const isLoading = !(hasResolvedNavigationMenus && hasLoadedInnerBlocks);
8782 const hasMoreThanOneNavigationMenu = (navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.length) > 1;
8783 const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length); // Entity block editor will return entities that are not currently published.
8784 // Guard by only allowing their usage if there are published Nav Menus.
8785
8786 const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
8787 const hasInnerBlocks = !!(publishedInnerBlocks !== null && publishedInnerBlocks !== void 0 && publishedInnerBlocks.length);
8788 (0,external_wp_element_namespaceObject.useEffect)(() => {
8789 if (isResolvingNavigationMenus) {
8790 (0,external_wp_a11y_namespaceObject.speak)('Loading Navigation sidebar menus.');
8791 }
8792
8793 if (hasResolvedNavigationMenus) {
8794 (0,external_wp_a11y_namespaceObject.speak)('Navigation sidebar menus have loaded.');
8795 }
8796 }, [isResolvingNavigationMenus, hasResolvedNavigationMenus]);
8797 (0,external_wp_element_namespaceObject.useEffect)(() => {
8798 if (isLoadingInnerBlocks) {
8799 (0,external_wp_a11y_namespaceObject.speak)('Loading Navigation sidebar selected menu items.');
8800 }
8801
8802 if (hasLoadedInnerBlocks) {
8803 (0,external_wp_a11y_namespaceObject.speak)('Navigation sidebar selected menu items have loaded.');
8804 }
8805 }, [isLoadingInnerBlocks, hasLoadedInnerBlocks]);
8806 return (0,external_wp_element_namespaceObject.createElement)("div", {
8807 className: "edit-site-navigation-inspector"
8808 }, hasResolvedNavigationMenus && !hasNavigationMenus && (0,external_wp_element_namespaceObject.createElement)("p", {
8809 className: "edit-site-navigation-inspector__empty-msg"
8810 }, (0,external_wp_i18n_namespaceObject.__)('There are no Navigation Menus.')), !hasResolvedNavigationMenus && (0,external_wp_element_namespaceObject.createElement)("div", {
8811 className: "edit-site-navigation-inspector__placeholder"
8812 }), hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
8813 "aria-controls": // aria-controls should only apply when referenced element is in DOM
8814 hasLoadedInnerBlocks ? navMenuListId : undefined,
8815 value: currentMenuId || defaultNavigationMenuId,
8816 options: options,
8817 onChange: newMenuId => setCurrentMenuId(Number(newMenuId))
8818 }), isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
8819 className: "edit-site-navigation-inspector__placeholder is-child"
8820 }), (0,external_wp_element_namespaceObject.createElement)("div", {
8821 className: "edit-site-navigation-inspector__placeholder is-child"
8822 }), (0,external_wp_element_namespaceObject.createElement)("div", {
8823 className: "edit-site-navigation-inspector__placeholder is-child"
8824 })), hasInnerBlocks && !isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
8825 value: publishedInnerBlocks,
8826 onChange: onChange,
8827 onInput: onInput
8828 }, (0,external_wp_element_namespaceObject.createElement)(NavigationMenu, {
8829 id: navMenuListId,
8830 innerBlocks: publishedInnerBlocks
8831 })), !hasInnerBlocks && !isLoading && (0,external_wp_element_namespaceObject.createElement)("p", {
8832 className: "edit-site-navigation-inspector__empty-msg"
8833 }, (0,external_wp_i18n_namespaceObject.__)('Navigation Menu is empty.')));
8834 }
8835
8836 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/navigation-menu-sidebar/index.js
8837
8838
8839 /**
8840 * WordPress dependencies
8841 */
8842
8843
8844
8845 /**
8846 * Internal dependencies
8847 */
8848
8849
8850
8851 function NavigationMenuSidebar() {
8852 return (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
8853 className: "edit-site-navigation-menu-sidebar",
8854 identifier: "edit-site/navigation-menu",
8855 title: (0,external_wp_i18n_namespaceObject.__)('Navigation Menus'),
8856 icon: library_navigation,
8857 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close navigation menu sidebar'),
8858 panelClassName: "edit-site-navigation-menu-sidebar__panel",
8859 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'))))
8860 }, (0,external_wp_element_namespaceObject.createElement)(NavigationInspector, null));
8861 }
8862
8863 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/constants.js
8864 const SIDEBAR_TEMPLATE = 'edit-site/template';
8865 const SIDEBAR_BLOCK = 'edit-site/block-inspector';
8866
8867 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/settings-header/index.js
8868
8869
8870 /**
8871 * WordPress dependencies
8872 */
8873
8874
8875
8876
8877 /**
8878 * Internal dependencies
8879 */
8880
8881
8882
8883
8884 const SettingsHeader = _ref => {
8885 let {
8886 sidebarName
8887 } = _ref;
8888 const {
8889 enableComplementaryArea
8890 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
8891
8892 const openTemplateSettings = () => enableComplementaryArea(STORE_NAME, SIDEBAR_TEMPLATE);
8893
8894 const openBlockSettings = () => enableComplementaryArea(STORE_NAME, SIDEBAR_BLOCK);
8895
8896 const [templateAriaLabel, templateActiveClass] = sidebarName === SIDEBAR_TEMPLATE ? // translators: ARIA label for the Template sidebar tab, selected.
8897 [(0,external_wp_i18n_namespaceObject.__)('Template (selected)'), 'is-active'] : // translators: ARIA label for the Template Settings Sidebar tab, not selected.
8898 [(0,external_wp_i18n_namespaceObject.__)('Template'), ''];
8899 const [blockAriaLabel, blockActiveClass] = sidebarName === SIDEBAR_BLOCK ? // translators: ARIA label for the Block Settings Sidebar tab, selected.
8900 [(0,external_wp_i18n_namespaceObject.__)('Block (selected)'), 'is-active'] : // translators: ARIA label for the Block Settings Sidebar tab, not selected.
8901 [(0,external_wp_i18n_namespaceObject.__)('Block'), ''];
8902 /* Use a list so screen readers will announce how many tabs there are. */
8903
8904 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, {
8905 onClick: openTemplateSettings,
8906 className: `edit-site-sidebar__panel-tab ${templateActiveClass}`,
8907 "aria-label": templateAriaLabel // translators: Data label for the Template Settings Sidebar tab.
8908 ,
8909 "data-label": (0,external_wp_i18n_namespaceObject.__)('Template')
8910 }, // translators: Text label for the Template Settings Sidebar tab.
8911 (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, {
8912 onClick: openBlockSettings,
8913 className: `edit-site-sidebar__panel-tab ${blockActiveClass}`,
8914 "aria-label": blockAriaLabel // translators: Data label for the Block Settings Sidebar tab.
8915 ,
8916 "data-label": (0,external_wp_i18n_namespaceObject.__)('Block')
8917 }, // translators: Text label for the Block Settings Sidebar tab.
8918 (0,external_wp_i18n_namespaceObject.__)('Block'))));
8919 };
8920
8921 /* harmony default export */ var settings_header = (SettingsHeader);
8922
8923 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/template-card/template-areas.js
8924
8925
8926 /**
8927 * WordPress dependencies
8928 */
8929
8930
8931
8932
8933
8934 /**
8935 * Internal dependencies
8936 */
8937
8938
8939
8940 function TemplateAreaItem(_ref) {
8941 let {
8942 area,
8943 clientId
8944 } = _ref;
8945 const {
8946 selectBlock,
8947 toggleBlockHighlight
8948 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
8949 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => {
8950 const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas();
8951
8952 return defaultAreas.find(defaultArea => defaultArea.area === area);
8953 }, [area]);
8954
8955 const highlightBlock = () => toggleBlockHighlight(clientId, true);
8956
8957 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
8958
8959 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
8960 className: "edit-site-template-card__template-areas-item",
8961 icon: templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.icon,
8962 onMouseOver: highlightBlock,
8963 onMouseLeave: cancelHighlightBlock,
8964 onFocus: highlightBlock,
8965 onBlur: cancelHighlightBlock,
8966 onClick: () => {
8967 selectBlock(clientId);
8968 }
8969 }, templatePartArea === null || templatePartArea === void 0 ? void 0 : templatePartArea.label);
8970 }
8971
8972 function template_areas_TemplateAreas() {
8973 const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentTemplateTemplateParts(), []);
8974
8975 if (!templateParts.length) {
8976 return null;
8977 }
8978
8979 return (0,external_wp_element_namespaceObject.createElement)("section", {
8980 className: "edit-site-template-card__template-areas"
8981 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
8982 level: 3,
8983 className: "edit-site-template-card__template-areas-title"
8984 }, (0,external_wp_i18n_namespaceObject.__)('Areas')), (0,external_wp_element_namespaceObject.createElement)("ul", {
8985 className: "edit-site-template-card__template-areas-list"
8986 }, templateParts.map(_ref2 => {
8987 let {
8988 templatePart,
8989 block
8990 } = _ref2;
8991 return (0,external_wp_element_namespaceObject.createElement)("li", {
8992 key: templatePart.slug
8993 }, (0,external_wp_element_namespaceObject.createElement)(TemplateAreaItem, {
8994 area: templatePart.area,
8995 clientId: block.clientId
8996 }));
8997 })));
8998 }
8999
9000 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/template-card/index.js
9001
9002
9003 /**
9004 * WordPress dependencies
9005 */
9006
9007
9008
9009
9010 /**
9011 * Internal dependencies
9012 */
9013
9014
9015
9016 function TemplateCard() {
9017 const {
9018 title,
9019 description,
9020 icon
9021 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9022 const {
9023 getEditedPostType,
9024 getEditedPostId
9025 } = select(store_store);
9026 const {
9027 getEntityRecord
9028 } = select(external_wp_coreData_namespaceObject.store);
9029 const {
9030 __experimentalGetTemplateInfo: getTemplateInfo
9031 } = select(external_wp_editor_namespaceObject.store);
9032 const postType = getEditedPostType();
9033 const postId = getEditedPostId();
9034 const record = getEntityRecord('postType', postType, postId);
9035 const info = record ? getTemplateInfo(record) : {};
9036 return info;
9037 }, []);
9038
9039 if (!title && !description) {
9040 return null;
9041 }
9042
9043 return (0,external_wp_element_namespaceObject.createElement)("div", {
9044 className: "edit-site-template-card"
9045 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9046 className: "edit-site-template-card__icon",
9047 icon: icon
9048 }), (0,external_wp_element_namespaceObject.createElement)("div", {
9049 className: "edit-site-template-card__content"
9050 }, (0,external_wp_element_namespaceObject.createElement)("h2", {
9051 className: "edit-site-template-card__title"
9052 }, title), (0,external_wp_element_namespaceObject.createElement)("div", {
9053 className: "edit-site-template-card__description"
9054 }, description), (0,external_wp_element_namespaceObject.createElement)(template_areas_TemplateAreas, null)));
9055 }
9056
9057 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/index.js
9058
9059
9060 /**
9061 * WordPress dependencies
9062 */
9063
9064
9065
9066
9067
9068
9069
9070 /**
9071 * Internal dependencies
9072 */
9073
9074
9075
9076
9077
9078
9079
9080
9081 const {
9082 Slot: InspectorSlot,
9083 Fill: InspectorFill
9084 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteSidebarInspector');
9085 const SidebarInspectorFill = InspectorFill;
9086 function SidebarComplementaryAreaFills() {
9087 const {
9088 sidebar,
9089 isEditorSidebarOpened,
9090 hasBlockSelection
9091 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9092 const _sidebar = select(store).getActiveComplementaryArea(STORE_NAME);
9093
9094 const _isEditorSidebarOpened = [SIDEBAR_BLOCK, SIDEBAR_TEMPLATE].includes(_sidebar);
9095
9096 return {
9097 sidebar: _sidebar,
9098 isEditorSidebarOpened: _isEditorSidebarOpened,
9099 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
9100 };
9101 }, []);
9102 const {
9103 enableComplementaryArea
9104 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
9105 (0,external_wp_element_namespaceObject.useEffect)(() => {
9106 if (!isEditorSidebarOpened) return;
9107
9108 if (hasBlockSelection) {
9109 enableComplementaryArea(STORE_NAME, SIDEBAR_BLOCK);
9110 } else {
9111 enableComplementaryArea(STORE_NAME, SIDEBAR_TEMPLATE);
9112 }
9113 }, [hasBlockSelection, isEditorSidebarOpened]);
9114 let sidebarName = sidebar;
9115
9116 if (!isEditorSidebarOpened) {
9117 sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;
9118 } // Conditionally include NavMenu sidebar in Plugin only.
9119 // Optimise for dead code elimination.
9120 // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
9121
9122
9123 let MaybeNavigationMenuSidebar = 'Fragment';
9124
9125 if (true) {
9126 MaybeNavigationMenuSidebar = NavigationMenuSidebar;
9127 }
9128
9129 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, {
9130 identifier: sidebarName,
9131 title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
9132 icon: library_cog,
9133 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings sidebar'),
9134 header: (0,external_wp_element_namespaceObject.createElement)(settings_header, {
9135 sidebarName: sidebarName
9136 }),
9137 headerClassName: "edit-site-sidebar__panel-tabs"
9138 }, 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, {
9139 bubblesVirtually: true
9140 })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesSidebar, null), (0,external_wp_element_namespaceObject.createElement)(MaybeNavigationMenuSidebar, null));
9141 }
9142
9143 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
9144 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
9145 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/home.js
9146
9147
9148 /**
9149 * WordPress dependencies
9150 */
9151
9152 const home = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9153 xmlns: "http://www.w3.org/2000/svg",
9154 viewBox: "0 0 24 24"
9155 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9156 d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z"
9157 }));
9158 /* harmony default export */ var library_home = (home);
9159
9160 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol-filled.js
9161
9162
9163 /**
9164 * WordPress dependencies
9165 */
9166
9167 const symbolFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9168 xmlns: "http://www.w3.org/2000/svg",
9169 viewBox: "0 0 24 24"
9170 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9171 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"
9172 }));
9173 /* harmony default export */ var symbol_filled = (symbolFilled);
9174
9175 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/main-dashboard-button/index.js
9176
9177
9178 /**
9179 * WordPress dependencies
9180 */
9181
9182 const slotName = '__experimentalMainDashboardButton';
9183 const {
9184 Fill,
9185 Slot: MainDashboardButtonSlot
9186 } = (0,external_wp_components_namespaceObject.createSlotFill)(slotName);
9187 const MainDashboardButton = Fill;
9188
9189 const main_dashboard_button_Slot = _ref => {
9190 let {
9191 children
9192 } = _ref;
9193 const slot = (0,external_wp_components_namespaceObject.__experimentalUseSlot)(slotName);
9194 const hasFills = Boolean(slot.fills && slot.fills.length);
9195
9196 if (!hasFills) {
9197 return children;
9198 }
9199
9200 return (0,external_wp_element_namespaceObject.createElement)(MainDashboardButtonSlot, {
9201 bubblesVirtually: true
9202 });
9203 };
9204
9205 MainDashboardButton.Slot = main_dashboard_button_Slot;
9206 /* harmony default export */ var main_dashboard_button = (MainDashboardButton);
9207
9208 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-panel/index.js
9209
9210
9211
9212 /**
9213 * External dependencies
9214 */
9215
9216 /**
9217 * WordPress dependencies
9218 */
9219
9220
9221
9222
9223
9224
9225
9226
9227 /**
9228 * Internal dependencies
9229 */
9230
9231
9232
9233
9234 const SITE_EDITOR_KEY = 'site-editor';
9235
9236 function NavLink(_ref) {
9237 let {
9238 params,
9239 replace,
9240 ...props
9241 } = _ref;
9242 const linkProps = useLink(params, replace);
9243 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationItem, extends_extends({}, linkProps, props));
9244 }
9245
9246 const NavigationPanel = _ref2 => {
9247 let {
9248 activeItem = SITE_EDITOR_KEY
9249 } = _ref2;
9250 const {
9251 homeTemplate,
9252 isNavigationOpen,
9253 siteTitle
9254 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9255 const {
9256 getEntityRecord
9257 } = select(external_wp_coreData_namespaceObject.store);
9258 const {
9259 getSettings,
9260 isNavigationOpened
9261 } = select(store_store);
9262 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
9263 return {
9264 siteTitle: siteData.name,
9265 homeTemplate: getSettings().__unstableHomeTemplate,
9266 isNavigationOpen: isNavigationOpened()
9267 };
9268 }, []);
9269 const {
9270 setIsNavigationPanelOpened
9271 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9272
9273 const closeOnEscape = event => {
9274 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
9275 event.preventDefault();
9276 setIsNavigationPanelOpened(false);
9277 }
9278 };
9279
9280 return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
9281 (0,external_wp_element_namespaceObject.createElement)("div", {
9282 className: classnames_default()(`edit-site-navigation-panel`, {
9283 'is-open': isNavigationOpen
9284 }),
9285 onKeyDown: closeOnEscape
9286 }, (0,external_wp_element_namespaceObject.createElement)("div", {
9287 className: "edit-site-navigation-panel__inner"
9288 }, (0,external_wp_element_namespaceObject.createElement)("div", {
9289 className: "edit-site-navigation-panel__site-title-container"
9290 }, (0,external_wp_element_namespaceObject.createElement)("div", {
9291 className: "edit-site-navigation-panel__site-title"
9292 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle))), (0,external_wp_element_namespaceObject.createElement)("div", {
9293 className: "edit-site-navigation-panel__scroll-container"
9294 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigation, {
9295 activeItem: activeItem
9296 }, (0,external_wp_element_namespaceObject.createElement)(main_dashboard_button.Slot, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationBackButton, {
9297 backButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Dashboard'),
9298 className: "edit-site-navigation-panel__back-to-dashboard",
9299 href: "index.php"
9300 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationMenu, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigationGroup, {
9301 title: (0,external_wp_i18n_namespaceObject.__)('Editor')
9302 }, (0,external_wp_element_namespaceObject.createElement)(NavLink, {
9303 icon: library_home,
9304 title: (0,external_wp_i18n_namespaceObject.__)('Site'),
9305 item: SITE_EDITOR_KEY,
9306 params: {
9307 postId: homeTemplate === null || homeTemplate === void 0 ? void 0 : homeTemplate.postId,
9308 postType: homeTemplate === null || homeTemplate === void 0 ? void 0 : homeTemplate.postType
9309 }
9310 }), (0,external_wp_element_namespaceObject.createElement)(NavLink, {
9311 icon: library_layout,
9312 title: (0,external_wp_i18n_namespaceObject.__)('Templates'),
9313 item: "wp_template",
9314 params: {
9315 postId: undefined,
9316 postType: 'wp_template'
9317 }
9318 }), (0,external_wp_element_namespaceObject.createElement)(NavLink, {
9319 icon: symbol_filled,
9320 title: (0,external_wp_i18n_namespaceObject.__)('Template Parts'),
9321 item: "wp_template_part",
9322 params: {
9323 postId: undefined,
9324 postType: 'wp_template_part'
9325 }
9326 })))))))
9327 );
9328 };
9329
9330 /* harmony default export */ var navigation_panel = (NavigationPanel);
9331
9332 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/wordpress.js
9333
9334
9335 /**
9336 * WordPress dependencies
9337 */
9338
9339 const wordpress = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9340 xmlns: "http://www.w3.org/2000/svg",
9341 viewBox: "-2 -2 24 24"
9342 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9343 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"
9344 }));
9345 /* harmony default export */ var library_wordpress = (wordpress);
9346
9347 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/navigation-toggle/index.js
9348
9349
9350 /**
9351 * External dependencies
9352 */
9353
9354 /**
9355 * WordPress dependencies
9356 */
9357
9358
9359
9360
9361
9362
9363
9364
9365 /**
9366 * Internal dependencies
9367 */
9368
9369
9370
9371 function NavigationToggle(_ref) {
9372 let {
9373 icon
9374 } = _ref;
9375 const {
9376 isNavigationOpen,
9377 isRequestingSiteIcon,
9378 siteIconUrl
9379 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9380 const {
9381 getEntityRecord,
9382 isResolving
9383 } = select(external_wp_coreData_namespaceObject.store);
9384 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
9385 return {
9386 isNavigationOpen: select(store_store).isNavigationOpened(),
9387 isRequestingSiteIcon: isResolving('core', 'getEntityRecord', ['root', '__unstableBase', undefined]),
9388 siteIconUrl: siteData.site_icon_url
9389 };
9390 }, []);
9391 const {
9392 setIsNavigationPanelOpened
9393 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9394 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
9395 const navigationToggleRef = (0,external_wp_element_namespaceObject.useRef)();
9396 (0,external_wp_element_namespaceObject.useEffect)(() => {
9397 // TODO: Remove this effect when alternative solution is merged.
9398 // See: https://github.com/WordPress/gutenberg/pull/37314
9399 if (!isNavigationOpen) {
9400 navigationToggleRef.current.focus();
9401 }
9402 }, [isNavigationOpen]);
9403
9404 const toggleNavigationPanel = () => setIsNavigationPanelOpened(!isNavigationOpen);
9405
9406 let buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9407 size: "36px",
9408 icon: library_wordpress
9409 });
9410 const effect = {
9411 expand: {
9412 scale: 1.25,
9413 transition: {
9414 type: 'tween',
9415 duration: '0.3'
9416 }
9417 }
9418 };
9419
9420 if (siteIconUrl) {
9421 buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.img, {
9422 variants: !disableMotion && effect,
9423 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
9424 className: "edit-site-navigation-toggle__site-icon",
9425 src: siteIconUrl
9426 });
9427 } else if (isRequestingSiteIcon) {
9428 buttonIcon = null;
9429 } else if (icon) {
9430 buttonIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9431 size: "36px",
9432 icon: icon
9433 });
9434 }
9435
9436 const classes = classnames_default()({
9437 'edit-site-navigation-toggle__button': true,
9438 'has-icon': siteIconUrl
9439 });
9440 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, {
9441 className: 'edit-site-navigation-toggle' + (isNavigationOpen ? ' is-open' : ''),
9442 whileHover: "expand"
9443 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9444 className: classes,
9445 label: (0,external_wp_i18n_namespaceObject.__)('Toggle navigation'),
9446 ref: navigationToggleRef // isPressed will add unwanted styles.
9447 ,
9448 "aria-pressed": isNavigationOpen,
9449 onClick: toggleNavigationPanel,
9450 showTooltip: true
9451 }, buttonIcon));
9452 }
9453
9454 /* harmony default export */ var navigation_toggle = (NavigationToggle);
9455
9456 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigation-sidebar/index.js
9457
9458
9459 /**
9460 * WordPress dependencies
9461 */
9462
9463
9464
9465
9466 /**
9467 * Internal dependencies
9468 */
9469
9470
9471
9472
9473 const {
9474 Fill: NavigationPanelPreviewFill,
9475 Slot: NavigationPanelPreviewSlot
9476 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteNavigationPanelPreview');
9477 const {
9478 Fill: NavigationSidebarFill,
9479 Slot: NavigationSidebarSlot
9480 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteNavigationSidebar');
9481
9482 function NavigationSidebar(_ref) {
9483 let {
9484 isDefaultOpen = false,
9485 activeTemplateType
9486 } = _ref;
9487 const isDesktopViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
9488 const {
9489 setIsNavigationPanelOpened
9490 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9491 (0,external_wp_element_namespaceObject.useEffect)(function autoOpenNavigationPanelOnViewportChange() {
9492 setIsNavigationPanelOpened(isDefaultOpen && isDesktopViewport);
9493 }, [isDefaultOpen, isDesktopViewport, setIsNavigationPanelOpened]);
9494 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, {
9495 activeItem: activeTemplateType
9496 }), (0,external_wp_element_namespaceObject.createElement)(NavigationPanelPreviewSlot, null));
9497 }
9498
9499 NavigationSidebar.Slot = NavigationSidebarSlot;
9500 /* harmony default export */ var navigation_sidebar = (NavigationSidebar);
9501
9502 ;// CONCATENATED MODULE: external ["wp","reusableBlocks"]
9503 var external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"];
9504 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/convert-to-regular.js
9505
9506
9507 /**
9508 * WordPress dependencies
9509 */
9510
9511
9512
9513
9514 function ConvertToRegularBlocks(_ref) {
9515 let {
9516 clientId
9517 } = _ref;
9518 const {
9519 getBlocks
9520 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
9521 const {
9522 replaceBlocks
9523 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
9524 const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]);
9525
9526 if (!canRemove) {
9527 return null;
9528 }
9529
9530 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, _ref2 => {
9531 let {
9532 onClose
9533 } = _ref2;
9534 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
9535 onClick: () => {
9536 replaceBlocks(clientId, getBlocks(clientId));
9537 onClose();
9538 }
9539 }, (0,external_wp_i18n_namespaceObject.__)('Detach blocks from template part'));
9540 });
9541 }
9542
9543 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/create-template-part-modal/index.js
9544
9545
9546 /**
9547 * WordPress dependencies
9548 */
9549
9550
9551
9552
9553
9554
9555
9556 /**
9557 * Internal dependencies
9558 */
9559
9560
9561 function CreateTemplatePartModal(_ref) {
9562 let {
9563 closeModal,
9564 onCreate
9565 } = _ref;
9566 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
9567 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(TEMPLATE_PART_AREA_GENERAL);
9568 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false);
9569 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal);
9570 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []);
9571 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
9572 title: (0,external_wp_i18n_namespaceObject.__)('Create a template part'),
9573 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
9574 onRequestClose: closeModal,
9575 overlayClassName: "edit-site-create-template-part-modal"
9576 }, (0,external_wp_element_namespaceObject.createElement)("form", {
9577 onSubmit: async event => {
9578 event.preventDefault();
9579
9580 if (!title) {
9581 return;
9582 }
9583
9584 setIsSubmitting(true);
9585 await onCreate({
9586 title,
9587 area
9588 });
9589 }
9590 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
9591 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
9592 value: title,
9593 onChange: setTitle,
9594 required: true
9595 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, {
9596 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
9597 id: `edit-site-create-template-part-modal__area-selection-${instanceId}`,
9598 className: "edit-site-create-template-part-modal__area-base-control"
9599 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalRadioGroup, {
9600 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
9601 className: "edit-site-create-template-part-modal__area-radio-group",
9602 id: `edit-site-create-template-part-modal__area-selection-${instanceId}`,
9603 onChange: setArea,
9604 checked: area
9605 }, templatePartAreas.map(_ref2 => {
9606 let {
9607 icon,
9608 label,
9609 area: value,
9610 description
9611 } = _ref2;
9612 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalRadio, {
9613 key: label,
9614 value: value,
9615 className: "edit-site-create-template-part-modal__area-radio"
9616 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
9617 align: "start",
9618 justify: "start"
9619 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9620 icon: icon
9621 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, {
9622 className: "edit-site-create-template-part-modal__option-label"
9623 }, label, (0,external_wp_element_namespaceObject.createElement)("div", null, description)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
9624 className: "edit-site-create-template-part-modal__checkbox"
9625 }, area === value && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9626 icon: library_check
9627 }))));
9628 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
9629 className: "edit-site-create-template-part-modal__modal-actions",
9630 justify: "flex-end"
9631 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9632 variant: "secondary",
9633 onClick: () => {
9634 closeModal();
9635 }
9636 }, (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, {
9637 variant: "primary",
9638 type: "submit",
9639 disabled: !title,
9640 isBusy: isSubmitting
9641 }, (0,external_wp_i18n_namespaceObject.__)('Create'))))));
9642 }
9643
9644 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/convert-to-template-part.js
9645
9646
9647 /**
9648 * External dependencies
9649 */
9650
9651 /**
9652 * WordPress dependencies
9653 */
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663 /**
9664 * Internal dependencies
9665 */
9666
9667
9668 function ConvertToTemplatePart(_ref) {
9669 let {
9670 clientIds,
9671 blocks
9672 } = _ref;
9673 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
9674 const {
9675 replaceBlocks
9676 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
9677 const {
9678 saveEntityRecord
9679 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
9680 const {
9681 createSuccessNotice
9682 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
9683
9684 const onConvert = async _ref2 => {
9685 let {
9686 title,
9687 area
9688 } = _ref2;
9689 // Currently template parts only allow latin chars.
9690 // Fallback slug will receive suffix by default.
9691 const cleanSlug = (0,external_lodash_namespaceObject.kebabCase)(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
9692 const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
9693 slug: cleanSlug,
9694 title,
9695 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks),
9696 area
9697 });
9698 replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', {
9699 slug: templatePart.slug,
9700 theme: templatePart.theme
9701 }));
9702 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), {
9703 type: 'snackbar'
9704 }); // The modal and this component will be unmounted because of `replaceBlocks` above,
9705 // so no need to call `closeModal` or `onClose`.
9706 };
9707
9708 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, {
9709 onClick: () => {
9710 setIsModalOpen(true);
9711 }
9712 }, (0,external_wp_i18n_namespaceObject.__)('Make template part'))), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, {
9713 closeModal: () => {
9714 setIsModalOpen(false);
9715 },
9716 onCreate: onConvert
9717 }));
9718 }
9719
9720 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/template-part-converter/index.js
9721
9722
9723 /**
9724 * WordPress dependencies
9725 */
9726
9727
9728 /**
9729 * Internal dependencies
9730 */
9731
9732
9733
9734 function TemplatePartConverter() {
9735 var _blocks$;
9736
9737 const {
9738 clientIds,
9739 blocks
9740 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9741 const {
9742 getSelectedBlockClientIds,
9743 getBlocksByClientId
9744 } = select(external_wp_blockEditor_namespaceObject.store);
9745 const selectedBlockClientIds = getSelectedBlockClientIds();
9746 return {
9747 clientIds: selectedBlockClientIds,
9748 blocks: getBlocksByClientId(selectedBlockClientIds)
9749 };
9750 }, []); // Allow converting a single template part to standard blocks.
9751
9752 if (blocks.length === 1 && ((_blocks$ = blocks[0]) === null || _blocks$ === void 0 ? void 0 : _blocks$.name) === 'core/template-part') {
9753 return (0,external_wp_element_namespaceObject.createElement)(ConvertToRegularBlocks, {
9754 clientId: clientIds[0]
9755 });
9756 }
9757
9758 return (0,external_wp_element_namespaceObject.createElement)(ConvertToTemplatePart, {
9759 clientIds: clientIds,
9760 blocks: blocks
9761 });
9762 }
9763
9764 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/pencil.js
9765
9766
9767 /**
9768 * WordPress dependencies
9769 */
9770
9771 const pencil = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9772 xmlns: "http://www.w3.org/2000/svg",
9773 viewBox: "0 0 24 24"
9774 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9775 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"
9776 }));
9777 /* harmony default export */ var library_pencil = (pencil);
9778
9779 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/edit.js
9780 /**
9781 * Internal dependencies
9782 */
9783
9784 /* harmony default export */ var edit = (library_pencil);
9785
9786 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/navigate-to-link/index.js
9787
9788
9789 /**
9790 * WordPress dependencies
9791 */
9792
9793
9794
9795
9796
9797
9798
9799 function NavigateToLink(_ref) {
9800 let {
9801 type,
9802 id,
9803 activePage,
9804 onActivePageChange
9805 } = _ref;
9806 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]);
9807 const onClick = (0,external_wp_element_namespaceObject.useMemo)(() => {
9808 if (!(post !== null && post !== void 0 && post.link)) return null;
9809 const path = (0,external_wp_url_namespaceObject.getPathAndQueryString)(post.link);
9810 if (path === (activePage === null || activePage === void 0 ? void 0 : activePage.path)) return null;
9811 return () => onActivePageChange({
9812 type,
9813 slug: post.slug,
9814 path,
9815 context: {
9816 postType: post.type,
9817 postId: post.id
9818 }
9819 });
9820 }, [post, activePage === null || activePage === void 0 ? void 0 : activePage.path, onActivePageChange]);
9821 return onClick && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9822 icon: edit,
9823 label: (0,external_wp_i18n_namespaceObject.__)('Edit Page Template'),
9824 onClick: onClick
9825 });
9826 }
9827
9828 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/block-inspector-button.js
9829
9830
9831 /**
9832 * WordPress dependencies
9833 */
9834
9835
9836
9837
9838
9839
9840 /**
9841 * Internal dependencies
9842 */
9843
9844
9845
9846
9847 function BlockInspectorButton(_ref) {
9848 let {
9849 onClick = () => {}
9850 } = _ref;
9851 const {
9852 shortcut,
9853 isBlockInspectorOpen
9854 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
9855 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-block-settings-sidebar'),
9856 isBlockInspectorOpen: select(store).getActiveComplementaryArea(store_store.name) === SIDEBAR_BLOCK
9857 }), []);
9858 const {
9859 enableComplementaryArea,
9860 disableComplementaryArea
9861 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
9862 const label = isBlockInspectorOpen ? (0,external_wp_i18n_namespaceObject.__)('Hide more settings') : (0,external_wp_i18n_namespaceObject.__)('Show more settings');
9863 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
9864 onClick: () => {
9865 if (isBlockInspectorOpen) {
9866 disableComplementaryArea(STORE_NAME);
9867 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Block settings closed'));
9868 } else {
9869 enableComplementaryArea(STORE_NAME, SIDEBAR_BLOCK);
9870 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Additional settings are now available in the Editor block settings sidebar'));
9871 } // Close dropdown menu.
9872
9873
9874 onClick();
9875 },
9876 shortcut: shortcut
9877 }, label);
9878 }
9879
9880 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/edit-template-part-menu-button/index.js
9881
9882
9883
9884 /**
9885 * WordPress dependencies
9886 */
9887
9888
9889
9890
9891
9892
9893 /**
9894 * Internal dependencies
9895 */
9896
9897
9898
9899 function EditTemplatePartMenuButton() {
9900 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, _ref => {
9901 let {
9902 selectedClientIds,
9903 onClose
9904 } = _ref;
9905 return (0,external_wp_element_namespaceObject.createElement)(EditTemplatePartMenuItem, {
9906 selectedClientId: selectedClientIds[0],
9907 onClose: onClose
9908 });
9909 });
9910 }
9911
9912 function EditTemplatePartMenuItem(_ref2) {
9913 let {
9914 selectedClientId,
9915 onClose
9916 } = _ref2;
9917 const {
9918 params
9919 } = useLocation();
9920 const selectedTemplatePart = (0,external_wp_data_namespaceObject.useSelect)(select => {
9921 const block = select(external_wp_blockEditor_namespaceObject.store).getBlock(selectedClientId);
9922
9923 if (block && (0,external_wp_blocks_namespaceObject.isTemplatePart)(block)) {
9924 const {
9925 theme,
9926 slug
9927 } = block.attributes;
9928 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template_part', // Ideally this should be an official public API.
9929 `${theme}//${slug}`);
9930 }
9931 }, [selectedClientId]);
9932 const linkProps = useLink({
9933 postId: selectedTemplatePart === null || selectedTemplatePart === void 0 ? void 0 : selectedTemplatePart.id,
9934 postType: selectedTemplatePart === null || selectedTemplatePart === void 0 ? void 0 : selectedTemplatePart.type
9935 }, {
9936 fromTemplateId: params.postId
9937 });
9938
9939 if (!selectedTemplatePart) {
9940 return null;
9941 }
9942
9943 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, extends_extends({}, linkProps, {
9944 onClick: event => {
9945 linkProps.onClick(event);
9946 onClose();
9947 }
9948 }),
9949 /* translators: %s: template part title */
9950 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Edit %s'), selectedTemplatePart.slug));
9951 }
9952
9953 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/arrow-left.js
9954
9955
9956 /**
9957 * WordPress dependencies
9958 */
9959
9960 const arrowLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9961 xmlns: "http://www.w3.org/2000/svg",
9962 viewBox: "0 0 24 24"
9963 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9964 d: "M20 10.8H6.7l4.1-4.5-1.1-1.1-5.8 6.3 5.8 5.8 1.1-1.1-4-3.9H20z"
9965 }));
9966 /* harmony default export */ var arrow_left = (arrowLeft);
9967
9968 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/back-button.js
9969
9970
9971 /**
9972 * WordPress dependencies
9973 */
9974
9975
9976
9977 /**
9978 * Internal dependencies
9979 */
9980
9981
9982
9983 function BackButton() {
9984 var _location$state;
9985
9986 const location = useLocation();
9987 const history = useHistory();
9988 const isTemplatePart = location.params.postType === 'wp_template_part';
9989 const previousTemplateId = (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.fromTemplateId;
9990
9991 if (!isTemplatePart || !previousTemplateId) {
9992 return null;
9993 }
9994
9995 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9996 className: "edit-site-visual-editor__back-button",
9997 icon: arrow_left,
9998 onClick: () => {
9999 history.back();
10000 }
10001 }, (0,external_wp_i18n_namespaceObject.__)('Back'));
10002 }
10003
10004 /* harmony default export */ var back_button = (BackButton);
10005
10006 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/resize-handle.js
10007
10008
10009 /**
10010 * WordPress dependencies
10011 */
10012
10013
10014
10015 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
10016
10017 function ResizeHandle(_ref) {
10018 let {
10019 direction,
10020 resizeWidthBy
10021 } = _ref;
10022
10023 function handleKeyDown(event) {
10024 const {
10025 keyCode
10026 } = event;
10027
10028 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) {
10029 resizeWidthBy(DELTA_DISTANCE);
10030 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) {
10031 resizeWidthBy(-DELTA_DISTANCE);
10032 }
10033 }
10034
10035 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("button", {
10036 className: `resizable-editor__drag-handle is-${direction}`,
10037 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
10038 "aria-describedby": `resizable-editor__resize-help-${direction}`,
10039 onKeyDown: handleKeyDown
10040 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
10041 id: `resizable-editor__resize-help-${direction}`
10042 }, (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.')));
10043 }
10044
10045 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/resizable-editor.js
10046
10047
10048
10049 /**
10050 * WordPress dependencies
10051 */
10052
10053
10054
10055
10056
10057 /**
10058 * Internal dependencies
10059 */
10060
10061
10062
10063 const DEFAULT_STYLES = {
10064 width: '100%',
10065 height: '100%'
10066 }; // Removes the inline styles in the drag handles.
10067
10068 const HANDLE_STYLES_OVERRIDE = {
10069 position: undefined,
10070 userSelect: undefined,
10071 cursor: undefined,
10072 width: undefined,
10073 height: undefined,
10074 top: undefined,
10075 right: undefined,
10076 bottom: undefined,
10077 left: undefined
10078 };
10079
10080 function ResizableEditor(_ref) {
10081 let {
10082 enableResizing,
10083 settings,
10084 ...props
10085 } = _ref;
10086 const deviceType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetPreviewDeviceType(), []);
10087 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType);
10088 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)(DEFAULT_STYLES.width);
10089 const [height, setHeight] = (0,external_wp_element_namespaceObject.useState)(DEFAULT_STYLES.height);
10090 const iframeRef = (0,external_wp_element_namespaceObject.useRef)();
10091 const mouseMoveTypingResetRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseMouseMoveTypingReset)();
10092 const ref = (0,external_wp_compose_namespaceObject.useMergeRefs)([iframeRef, mouseMoveTypingResetRef]);
10093 (0,external_wp_element_namespaceObject.useEffect)(function autoResizeIframeHeight() {
10094 const iframe = iframeRef.current;
10095
10096 if (!iframe || !enableResizing) {
10097 return;
10098 }
10099
10100 let animationFrame = null;
10101
10102 function resizeHeight() {
10103 if (!animationFrame) {
10104 // Throttle the updates on animation frame.
10105 animationFrame = iframe.contentWindow.requestAnimationFrame(() => {
10106 setHeight(iframe.contentDocument.documentElement.scrollHeight);
10107 animationFrame = null;
10108 });
10109 }
10110 }
10111
10112 let resizeObserver;
10113
10114 function registerObserver() {
10115 var _resizeObserver;
10116
10117 (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.disconnect();
10118 resizeObserver = new iframe.contentWindow.ResizeObserver(resizeHeight); // Observing the <html> rather than the <body> because the latter
10119 // gets destroyed and remounted after initialization in <Iframe>.
10120
10121 resizeObserver.observe(iframe.contentDocument.documentElement);
10122 resizeHeight();
10123 } // This is only required in Firefox for some unknown reasons.
10124
10125
10126 iframe.addEventListener('load', registerObserver); // This is required in Chrome and Safari.
10127
10128 registerObserver();
10129 return () => {
10130 var _iframe$contentWindow, _resizeObserver2;
10131
10132 (_iframe$contentWindow = iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : _iframe$contentWindow.cancelAnimationFrame(animationFrame);
10133 (_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : _resizeObserver2.disconnect();
10134 iframe.removeEventListener('load', registerObserver);
10135 };
10136 }, [enableResizing]);
10137 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => {
10138 if (iframeRef.current) {
10139 setWidth(iframeRef.current.offsetWidth + deltaPixels);
10140 }
10141 }, []);
10142 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ResizableBox, {
10143 size: {
10144 width,
10145 height
10146 },
10147 onResizeStop: (event, direction, element) => {
10148 setWidth(element.style.width);
10149 },
10150 minWidth: 300,
10151 maxWidth: "100%",
10152 maxHeight: "100%",
10153 enable: {
10154 right: enableResizing,
10155 left: enableResizing
10156 },
10157 showHandle: enableResizing // The editor is centered horizontally, resizing it only
10158 // moves half the distance. Hence double the ratio to correctly
10159 // align the cursor to the resizer handle.
10160 ,
10161 resizeRatio: 2,
10162 handleComponent: {
10163 left: (0,external_wp_element_namespaceObject.createElement)(ResizeHandle, {
10164 direction: "left",
10165 resizeWidthBy: resizeWidthBy
10166 }),
10167 right: (0,external_wp_element_namespaceObject.createElement)(ResizeHandle, {
10168 direction: "right",
10169 resizeWidthBy: resizeWidthBy
10170 })
10171 },
10172 handleClasses: undefined,
10173 handleStyles: {
10174 left: HANDLE_STYLES_OVERRIDE,
10175 right: HANDLE_STYLES_OVERRIDE
10176 }
10177 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, extends_extends({
10178 style: enableResizing ? undefined : deviceStyles,
10179 head: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
10180 styles: settings.styles
10181 }), (0,external_wp_element_namespaceObject.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing.
10182 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
10183 `.is-root-container { display: flow-root; }`), enableResizing && (0,external_wp_element_namespaceObject.createElement)("style", null, // Force the <html> and <body>'s heights to fit the content.
10184 `html, body { height: -moz-fit-content !important; height: fit-content !important; min-height: 0 !important; }`, // Some themes will have `min-height: 100vh` for the root container,
10185 // which isn't a requirement in auto resize mode.
10186 `.is-root-container { min-height: 0 !important; }`)),
10187 assets: settings.__unstableResolvedAssets,
10188 ref: ref,
10189 name: "editor-canvas",
10190 className: "edit-site-visual-editor__editor-canvas"
10191 }, props)));
10192 }
10193
10194 /* harmony default export */ var resizable_editor = (ResizableEditor);
10195
10196 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/block-editor/index.js
10197
10198
10199
10200 /**
10201 * External dependencies
10202 */
10203
10204 /**
10205 * WordPress dependencies
10206 */
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218 /**
10219 * Internal dependencies
10220 */
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230 const LAYOUT = {
10231 type: 'default',
10232 // At the root level of the site editor, no alignments should be allowed.
10233 alignments: []
10234 };
10235 function BlockEditor(_ref) {
10236 let {
10237 setIsInserterOpen
10238 } = _ref;
10239 const {
10240 settings
10241 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10242 let storedSettings = select(store_store).getSettings(setIsInserterOpen);
10243
10244 if (!storedSettings.__experimentalBlockPatterns) {
10245 storedSettings = { ...storedSettings,
10246 __experimentalBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns()
10247 };
10248 }
10249
10250 if (!storedSettings.__experimentalBlockPatternCategories) {
10251 storedSettings = { ...storedSettings,
10252 __experimentalBlockPatternCategories: select(external_wp_coreData_namespaceObject.store).getBlockPatternCategories()
10253 };
10254 }
10255
10256 return {
10257 settings: storedSettings
10258 };
10259 }, [setIsInserterOpen]);
10260 const {
10261 templateType,
10262 templateId,
10263 page
10264 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10265 const {
10266 getEditedPostType,
10267 getEditedPostId,
10268 getPage
10269 } = select(store_store);
10270 return {
10271 templateType: getEditedPostType(),
10272 templateId: getEditedPostId(),
10273 page: getPage()
10274 };
10275 }, [setIsInserterOpen]);
10276 const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', templateType);
10277 const {
10278 setPage
10279 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10280 const {
10281 enableComplementaryArea
10282 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
10283 const openNavigationSidebar = (0,external_wp_element_namespaceObject.useCallback)(() => {
10284 enableComplementaryArea('core/edit-site', 'edit-site/navigation-menu');
10285 }, [enableComplementaryArea]);
10286 const contentRef = (0,external_wp_element_namespaceObject.useRef)();
10287 const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([contentRef, (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)()]);
10288 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
10289 const {
10290 clearSelectedBlock
10291 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
10292 const isTemplatePart = templateType === 'wp_template_part';
10293
10294 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, {
10295 className: "components-toolbar__control",
10296 label: (0,external_wp_i18n_namespaceObject.__)('Open list view'),
10297 onClick: openNavigationSidebar,
10298 icon: list_view
10299 })); // Conditionally include NavMenu sidebar in Plugin only.
10300 // Optimise for dead code elimination.
10301 // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
10302
10303
10304 let MaybeNavMenuSidebarToggle = 'Fragment';
10305
10306 if (true) {
10307 MaybeNavMenuSidebarToggle = NavMenuSidebarToggle;
10308 }
10309
10310 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
10311 settings: settings,
10312 value: blocks,
10313 onInput: onInput,
10314 onChange: onChange,
10315 useSubRegistry: false
10316 }, (0,external_wp_element_namespaceObject.createElement)(EditTemplatePartMenuButton, null), (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, {
10317 activePage: page,
10318 onActivePageChange: setPage
10319 })), [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, {
10320 className: classnames_default()('edit-site-visual-editor', {
10321 'is-focus-mode': isTemplatePart
10322 }),
10323 __unstableContentRef: contentRef,
10324 onClick: event => {
10325 // Clear selected block when clicking on the gray background.
10326 if (event.target === event.currentTarget) {
10327 clearSelectedBlock();
10328 }
10329 }
10330 }, (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.
10331 , {
10332 key: templateId,
10333 enableResizing: isTemplatePart && // Disable resizing in mobile viewport.
10334 !isMobileViewport,
10335 settings: settings,
10336 contentRef: mergedRefs
10337 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, {
10338 className: "edit-site-block-editor__block-list wp-site-blocks",
10339 __experimentalLayout: LAYOUT,
10340 renderAppender: isTemplatePart ? false : undefined
10341 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, null, _ref2 => {
10342 let {
10343 onClose
10344 } = _ref2;
10345 return (0,external_wp_element_namespaceObject.createElement)(BlockInspectorButton, {
10346 onClick: onClose
10347 });
10348 }), (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));
10349 }
10350
10351 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
10352 var lib = __webpack_require__(773);
10353 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/code-editor/code-editor-text-area.js
10354
10355
10356 /**
10357 * External dependencies
10358 */
10359
10360 /**
10361 * WordPress dependencies
10362 */
10363
10364 /**
10365 * WordPress dependencies
10366 */
10367
10368 /**
10369 * WordPress dependencies
10370 */
10371
10372
10373
10374
10375
10376 function CodeEditorTextArea(_ref) {
10377 let {
10378 value,
10379 onChange,
10380 onInput
10381 } = _ref;
10382 const [stateValue, setStateValue] = (0,external_wp_element_namespaceObject.useState)(value);
10383 const [isDirty, setIsDirty] = (0,external_wp_element_namespaceObject.useState)(false);
10384 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CodeEditorTextArea);
10385
10386 if (!isDirty && stateValue !== value) {
10387 setStateValue(value);
10388 }
10389 /**
10390 * Handles a textarea change event to notify the onChange prop callback and
10391 * reflect the new value in the component's own state. This marks the start
10392 * of the user's edits, if not already changed, preventing future props
10393 * changes to value from replacing the rendered value. This is expected to
10394 * be followed by a reset to dirty state via `stopEditing`.
10395 *
10396 * @see stopEditing
10397 *
10398 * @param {Event} event Change event.
10399 */
10400
10401
10402 const onChangeHandler = event => {
10403 const newValue = event.target.value;
10404 onInput(newValue);
10405 setStateValue(newValue);
10406 setIsDirty(true);
10407 };
10408 /**
10409 * Function called when the user has completed their edits, responsible for
10410 * ensuring that changes, if made, are surfaced to the onPersist prop
10411 * callback and resetting dirty state.
10412 */
10413
10414
10415 const stopEditing = () => {
10416 if (isDirty) {
10417 onChange(stateValue);
10418 setIsDirty(false);
10419 }
10420 };
10421
10422 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
10423 as: "label",
10424 htmlFor: `code-editor-text-area-${instanceId}`
10425 }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
10426 autoComplete: "off",
10427 dir: "auto",
10428 value: stateValue,
10429 onChange: onChangeHandler,
10430 onBlur: stopEditing,
10431 className: "edit-site-code-editor-text-area",
10432 id: `code-editor-text-area-${instanceId}`,
10433 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
10434 }));
10435 }
10436
10437 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/code-editor/index.js
10438
10439
10440 /**
10441 * WordPress dependencies
10442 */
10443
10444
10445
10446
10447
10448
10449 /**
10450 * Internal dependencies
10451 */
10452
10453
10454
10455 function CodeEditor() {
10456 const {
10457 templateType,
10458 shortcut
10459 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10460 const {
10461 getEditedPostType
10462 } = select(store_store);
10463 const {
10464 getShortcutRepresentation
10465 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
10466 return {
10467 templateType: getEditedPostType(),
10468 shortcut: getShortcutRepresentation('core/edit-site/toggle-mode')
10469 };
10470 }, []);
10471 const [contentStructure, setContent] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', templateType, 'content');
10472 const [blocks,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', templateType);
10473 const content = contentStructure instanceof Function ? contentStructure({
10474 blocks
10475 }) : contentStructure;
10476 const {
10477 switchEditorMode
10478 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10479 return (0,external_wp_element_namespaceObject.createElement)("div", {
10480 className: "edit-site-code-editor"
10481 }, (0,external_wp_element_namespaceObject.createElement)("div", {
10482 className: "edit-site-code-editor__toolbar"
10483 }, (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, {
10484 variant: "tertiary",
10485 onClick: () => switchEditorMode('visual'),
10486 shortcut: shortcut
10487 }, (0,external_wp_i18n_namespaceObject.__)('Exit code editor'))), (0,external_wp_element_namespaceObject.createElement)("div", {
10488 className: "edit-site-code-editor__body"
10489 }, (0,external_wp_element_namespaceObject.createElement)(CodeEditorTextArea, {
10490 value: content,
10491 onChange: newContent => {
10492 onChange((0,external_wp_blocks_namespaceObject.parse)(newContent), {
10493 selection: undefined
10494 });
10495 },
10496 onInput: setContent
10497 })));
10498 }
10499
10500 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/keyboard-shortcuts/index.js
10501 /**
10502 * WordPress dependencies
10503 */
10504
10505
10506
10507
10508
10509
10510 /**
10511 * Internal dependencies
10512 */
10513
10514
10515
10516
10517
10518 function KeyboardShortcuts(_ref) {
10519 let {
10520 openEntitiesSavedStates
10521 } = _ref;
10522 const {
10523 __experimentalGetDirtyEntityRecords,
10524 isSavingEntityRecord
10525 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
10526 const {
10527 getEditorMode
10528 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
10529 const isListViewOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).isListViewOpened(), []);
10530 const isBlockInspectorOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(store_store.name) === SIDEBAR_BLOCK, []);
10531 const {
10532 redo,
10533 undo
10534 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
10535 const {
10536 setIsListViewOpened,
10537 switchEditorMode
10538 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10539 const {
10540 enableComplementaryArea,
10541 disableComplementaryArea
10542 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
10543 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/save', event => {
10544 event.preventDefault();
10545
10546 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
10547
10548 const isDirty = !!dirtyEntityRecords.length;
10549 const isSaving = dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key));
10550
10551 if (!isSaving && isDirty) {
10552 openEntitiesSavedStates();
10553 }
10554 });
10555 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/undo', event => {
10556 undo();
10557 event.preventDefault();
10558 });
10559 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/redo', event => {
10560 redo();
10561 event.preventDefault();
10562 });
10563 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-list-view', () => {
10564 setIsListViewOpened(!isListViewOpen);
10565 });
10566 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-block-settings-sidebar', event => {
10567 // This shortcut has no known clashes, but use preventDefault to prevent any
10568 // obscure shortcuts from triggering.
10569 event.preventDefault();
10570
10571 if (isBlockInspectorOpen) {
10572 disableComplementaryArea(STORE_NAME);
10573 } else {
10574 enableComplementaryArea(STORE_NAME, SIDEBAR_BLOCK);
10575 }
10576 });
10577 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-mode', () => {
10578 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
10579 });
10580 return null;
10581 }
10582
10583 function KeyboardShortcutsRegister() {
10584 // Registering the shortcuts.
10585 const {
10586 registerShortcut
10587 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
10588 (0,external_wp_element_namespaceObject.useEffect)(() => {
10589 registerShortcut({
10590 name: 'core/edit-site/save',
10591 category: 'global',
10592 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
10593 keyCombination: {
10594 modifier: 'primary',
10595 character: 's'
10596 }
10597 });
10598 registerShortcut({
10599 name: 'core/edit-site/undo',
10600 category: 'global',
10601 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
10602 keyCombination: {
10603 modifier: 'primary',
10604 character: 'z'
10605 }
10606 });
10607 registerShortcut({
10608 name: 'core/edit-site/redo',
10609 category: 'global',
10610 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
10611 keyCombination: {
10612 modifier: 'primaryShift',
10613 character: 'z'
10614 }
10615 });
10616 registerShortcut({
10617 name: 'core/edit-site/toggle-list-view',
10618 category: 'global',
10619 description: (0,external_wp_i18n_namespaceObject.__)('Open the block list view.'),
10620 keyCombination: {
10621 modifier: 'access',
10622 character: 'o'
10623 }
10624 });
10625 registerShortcut({
10626 name: 'core/edit-site/toggle-block-settings-sidebar',
10627 category: 'global',
10628 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the block settings sidebar.'),
10629 keyCombination: {
10630 modifier: 'primaryShift',
10631 character: ','
10632 }
10633 });
10634 registerShortcut({
10635 name: 'core/edit-site/keyboard-shortcuts',
10636 category: 'main',
10637 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
10638 keyCombination: {
10639 modifier: 'access',
10640 character: 'h'
10641 }
10642 });
10643 registerShortcut({
10644 name: 'core/edit-site/next-region',
10645 category: 'global',
10646 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
10647 keyCombination: {
10648 modifier: 'ctrl',
10649 character: '`'
10650 },
10651 aliases: [{
10652 modifier: 'access',
10653 character: 'n'
10654 }]
10655 });
10656 registerShortcut({
10657 name: 'core/edit-site/previous-region',
10658 category: 'global',
10659 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
10660 keyCombination: {
10661 modifier: 'ctrlShift',
10662 character: '`'
10663 },
10664 aliases: [{
10665 modifier: 'access',
10666 character: 'p'
10667 }]
10668 });
10669 registerShortcut({
10670 name: 'core/edit-site/toggle-mode',
10671 category: 'global',
10672 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
10673 keyCombination: {
10674 modifier: 'secondary',
10675 character: 'm'
10676 }
10677 });
10678 }, [registerShortcut]);
10679 return null;
10680 }
10681
10682 KeyboardShortcuts.Register = KeyboardShortcutsRegister;
10683 /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
10684
10685 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/url-query-controller/index.js
10686 /**
10687 * WordPress dependencies
10688 */
10689
10690
10691 /**
10692 * Internal dependencies
10693 */
10694
10695
10696
10697 function URLQueryController() {
10698 const {
10699 setTemplate,
10700 setTemplatePart,
10701 setPage
10702 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10703 const {
10704 params: {
10705 postId,
10706 postType
10707 }
10708 } = useLocation(); // Set correct entity on page navigation.
10709
10710 (0,external_wp_element_namespaceObject.useEffect)(() => {
10711 if ('page' === postType || 'post' === postType) {
10712 setPage({
10713 context: {
10714 postType,
10715 postId
10716 }
10717 }); // Resolves correct template based on ID.
10718 } else if ('wp_template' === postType) {
10719 setTemplate(postId);
10720 } else if ('wp_template_part' === postType) {
10721 setTemplatePart(postId);
10722 }
10723 }, [postId, postType]);
10724 return null;
10725 }
10726
10727 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close.js
10728
10729
10730 /**
10731 * WordPress dependencies
10732 */
10733
10734 const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
10735 xmlns: "http://www.w3.org/2000/svg",
10736 viewBox: "0 0 24 24"
10737 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
10738 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"
10739 }));
10740 /* harmony default export */ var library_close = (close_close);
10741
10742 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/secondary-sidebar/inserter-sidebar.js
10743
10744
10745
10746 /**
10747 * WordPress dependencies
10748 */
10749
10750
10751
10752
10753
10754
10755
10756 /**
10757 * Internal dependencies
10758 */
10759
10760
10761 function InserterSidebar() {
10762 const {
10763 setIsInserterOpened
10764 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10765 const insertionPoint = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetInsertionPoint(), []);
10766 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
10767 const TagName = !isMobile ? external_wp_components_namespaceObject.VisuallyHidden : 'div';
10768 const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
10769 onClose: () => setIsInserterOpened(false),
10770 focusOnMount: null
10771 });
10772 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
10773 (0,external_wp_element_namespaceObject.useEffect)(() => {
10774 libraryRef.current.focusSearch();
10775 }, []);
10776 return (0,external_wp_element_namespaceObject.createElement)("div", extends_extends({
10777 ref: inserterDialogRef
10778 }, inserterDialogProps, {
10779 className: "edit-site-editor__inserter-panel"
10780 }), (0,external_wp_element_namespaceObject.createElement)(TagName, {
10781 className: "edit-site-editor__inserter-panel-header"
10782 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10783 icon: library_close,
10784 label: (0,external_wp_i18n_namespaceObject.__)('Close block inserter'),
10785 onClick: () => setIsInserterOpened(false)
10786 })), (0,external_wp_element_namespaceObject.createElement)("div", {
10787 className: "edit-site-editor__inserter-panel-content"
10788 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, {
10789 showInserterHelpPanel: true,
10790 shouldFocusBlock: isMobile,
10791 rootClientId: insertionPoint.rootClientId,
10792 __experimentalInsertionIndex: insertionPoint.insertionIndex,
10793 __experimentalFilterValue: insertionPoint.filterValue,
10794 ref: libraryRef
10795 })));
10796 }
10797
10798 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/secondary-sidebar/list-view-sidebar.js
10799
10800
10801 /**
10802 * WordPress dependencies
10803 */
10804
10805
10806
10807
10808
10809
10810
10811 /**
10812 * Internal dependencies
10813 */
10814
10815
10816 function ListViewSidebar() {
10817 const {
10818 setIsListViewOpened
10819 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10820 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
10821 const headerFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
10822 const contentFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)();
10823
10824 function closeOnEscape(event) {
10825 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
10826 setIsListViewOpened(false);
10827 }
10828 }
10829
10830 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(ListViewSidebar);
10831 const labelId = `edit-site-editor__list-view-panel-label-${instanceId}`;
10832 return (// eslint-disable-next-line jsx-a11y/no-static-element-interactions
10833 (0,external_wp_element_namespaceObject.createElement)("div", {
10834 "aria-labelledby": labelId,
10835 className: "edit-site-editor__list-view-panel",
10836 onKeyDown: closeOnEscape
10837 }, (0,external_wp_element_namespaceObject.createElement)("div", {
10838 className: "edit-site-editor__list-view-panel-header",
10839 ref: headerFocusReturnRef
10840 }, (0,external_wp_element_namespaceObject.createElement)("strong", {
10841 id: labelId
10842 }, (0,external_wp_i18n_namespaceObject.__)('List View')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10843 icon: close_small,
10844 label: (0,external_wp_i18n_namespaceObject.__)('Close List View Sidebar'),
10845 onClick: () => setIsListViewOpened(false)
10846 })), (0,external_wp_element_namespaceObject.createElement)("div", {
10847 className: "edit-site-editor__list-view-panel-content",
10848 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([contentFocusReturnRef, focusOnMountRef])
10849 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
10850 showNestedBlocks: true,
10851 __experimentalFeatures: true,
10852 __experimentalPersistentListViewFeatures: true
10853 })))
10854 );
10855 }
10856
10857 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/error-boundary/warning.js
10858
10859
10860 /**
10861 * WordPress dependencies
10862 */
10863
10864
10865
10866
10867
10868 function CopyButton(_ref) {
10869 let {
10870 text,
10871 children
10872 } = _ref;
10873 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
10874 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10875 variant: "secondary",
10876 ref: ref
10877 }, children);
10878 }
10879
10880 function ErrorBoundaryWarning(_ref2) {
10881 let {
10882 message,
10883 error,
10884 reboot,
10885 dashboardLink
10886 } = _ref2;
10887 const actions = [];
10888
10889 if (reboot) {
10890 actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10891 key: "recovery",
10892 onClick: reboot,
10893 variant: "secondary"
10894 }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery')));
10895 }
10896
10897 if (error) {
10898 actions.push((0,external_wp_element_namespaceObject.createElement)(CopyButton, {
10899 key: "copy-error",
10900 text: error.stack
10901 }, (0,external_wp_i18n_namespaceObject.__)('Copy Error')));
10902 }
10903
10904 if (dashboardLink) {
10905 actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10906 key: "back-to-dashboard",
10907 variant: "secondary",
10908 href: dashboardLink
10909 }, (0,external_wp_i18n_namespaceObject.__)('Back to dashboard')));
10910 }
10911
10912 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
10913 className: "editor-error-boundary",
10914 actions: actions
10915 }, message);
10916 }
10917
10918 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/error-boundary/index.js
10919
10920
10921 /**
10922 * WordPress dependencies
10923 */
10924
10925
10926 /**
10927 * Internal dependencies
10928 */
10929
10930
10931 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
10932 constructor() {
10933 super(...arguments);
10934 this.reboot = this.reboot.bind(this);
10935 this.state = {
10936 error: null
10937 };
10938 }
10939
10940 static getDerivedStateFromError(error) {
10941 return {
10942 error
10943 };
10944 }
10945
10946 reboot() {
10947 this.props.onError();
10948 }
10949
10950 render() {
10951 const {
10952 error
10953 } = this.state;
10954
10955 if (!error) {
10956 return this.props.children;
10957 }
10958
10959 return (0,external_wp_element_namespaceObject.createElement)(ErrorBoundaryWarning, {
10960 message: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'),
10961 error: error,
10962 reboot: this.reboot
10963 });
10964 }
10965
10966 }
10967
10968 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/image.js
10969
10970 function WelcomeGuideImage(_ref) {
10971 let {
10972 nonAnimatedSrc,
10973 animatedSrc
10974 } = _ref;
10975 return (0,external_wp_element_namespaceObject.createElement)("picture", {
10976 className: "edit-site-welcome-guide__image"
10977 }, (0,external_wp_element_namespaceObject.createElement)("source", {
10978 srcSet: nonAnimatedSrc,
10979 media: "(prefers-reduced-motion: reduce)"
10980 }), (0,external_wp_element_namespaceObject.createElement)("img", {
10981 src: animatedSrc,
10982 width: "312",
10983 height: "240",
10984 alt: ""
10985 }));
10986 }
10987
10988 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/editor.js
10989
10990
10991 /**
10992 * WordPress dependencies
10993 */
10994
10995
10996
10997
10998
10999 /**
11000 * Internal dependencies
11001 */
11002
11003
11004 function WelcomeGuideEditor() {
11005 const {
11006 toggle
11007 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
11008 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'), []);
11009
11010 if (!isActive) {
11011 return null;
11012 }
11013
11014 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
11015 className: "edit-site-welcome-guide",
11016 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the site editor'),
11017 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get Started'),
11018 onFinish: () => toggle('core/edit-site', 'welcomeGuide'),
11019 pages: [{
11020 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11021 nonAnimatedSrc: "https://s.w.org/images/block-editor/edit-your-site.svg?1",
11022 animatedSrc: "https://s.w.org/images/block-editor/edit-your-site.gif?1"
11023 }),
11024 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11025 className: "edit-site-welcome-guide__heading"
11026 }, (0,external_wp_i18n_namespaceObject.__)('Edit your site')), (0,external_wp_element_namespaceObject.createElement)("p", {
11027 className: "edit-site-welcome-guide__text"
11028 }, (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", {
11029 className: "edit-site-welcome-guide__text"
11030 }, (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.'), {
11031 StylesIconImage: (0,external_wp_element_namespaceObject.createElement)("img", {
11032 alt: (0,external_wp_i18n_namespaceObject.__)('styles'),
11033 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"
11034 })
11035 })))
11036 }]
11037 });
11038 }
11039
11040 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/styles.js
11041
11042
11043 /**
11044 * WordPress dependencies
11045 */
11046
11047
11048
11049
11050
11051 /**
11052 * Internal dependencies
11053 */
11054
11055
11056
11057 function WelcomeGuideStyles() {
11058 const {
11059 toggle
11060 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
11061 const {
11062 isActive,
11063 isStylesOpen
11064 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11065 const sidebar = select(store).getActiveComplementaryArea(store_store.name);
11066 return {
11067 isActive: !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuideStyles'),
11068 isStylesOpen: sidebar === 'edit-site/global-styles'
11069 };
11070 }, []);
11071
11072 if (!isActive || !isStylesOpen) {
11073 return null;
11074 }
11075
11076 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, {
11077 className: "edit-site-welcome-guide",
11078 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to styles'),
11079 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get Started'),
11080 onFinish: () => toggle('core/edit-site', 'welcomeGuideStyles'),
11081 pages: [{
11082 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11083 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1",
11084 animatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.gif?1"
11085 }),
11086 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11087 className: "edit-site-welcome-guide__heading"
11088 }, (0,external_wp_i18n_namespaceObject.__)('Welcome to Styles')), (0,external_wp_element_namespaceObject.createElement)("p", {
11089 className: "edit-site-welcome-guide__text"
11090 }, (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.')))
11091 }, {
11092 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11093 nonAnimatedSrc: "https://s.w.org/images/block-editor/set-the-design.svg?1",
11094 animatedSrc: "https://s.w.org/images/block-editor/set-the-design.gif?1"
11095 }),
11096 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11097 className: "edit-site-welcome-guide__heading"
11098 }, (0,external_wp_i18n_namespaceObject.__)('Set the design')), (0,external_wp_element_namespaceObject.createElement)("p", {
11099 className: "edit-site-welcome-guide__text"
11100 }, (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! ')))
11101 }, {
11102 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11103 nonAnimatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.svg?1",
11104 animatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.gif?1"
11105 }),
11106 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11107 className: "edit-site-welcome-guide__heading"
11108 }, (0,external_wp_i18n_namespaceObject.__)('Personalize blocks')), (0,external_wp_element_namespaceObject.createElement)("p", {
11109 className: "edit-site-welcome-guide__text"
11110 }, (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.')))
11111 }, {
11112 image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, {
11113 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
11114 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
11115 }),
11116 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", {
11117 className: "edit-site-welcome-guide__heading"
11118 }, (0,external_wp_i18n_namespaceObject.__)('Learn more')), (0,external_wp_element_namespaceObject.createElement)("p", {
11119 className: "edit-site-welcome-guide__text"
11120 }, (0,external_wp_i18n_namespaceObject.__)('New to block themes and styling your site? '), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
11121 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/styles-overview/')
11122 }, (0,external_wp_i18n_namespaceObject.__)('Here’s a detailed guide to learn how to make the most of it.'))))
11123 }]
11124 });
11125 }
11126
11127 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/welcome-guide/index.js
11128
11129
11130 /**
11131 * Internal dependencies
11132 */
11133
11134
11135 function WelcomeGuide() {
11136 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));
11137 }
11138
11139 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/editor/global-styles-renderer.js
11140 /**
11141 * External dependencies
11142 */
11143
11144 /**
11145 * WordPress dependencies
11146 */
11147
11148
11149
11150 /**
11151 * Internal dependencies
11152 */
11153
11154
11155 /**
11156 * Internal dependencies
11157 */
11158
11159
11160
11161 function useGlobalStylesRenderer() {
11162 const [styles, settings] = useGlobalStylesOutput();
11163 const {
11164 getSettings
11165 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
11166 const {
11167 updateSettings
11168 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11169 (0,external_wp_element_namespaceObject.useEffect)(() => {
11170 if (!styles || !settings) {
11171 return;
11172 }
11173
11174 const currentStoreSettings = getSettings();
11175 const nonGlobalStyles = (0,external_lodash_namespaceObject.filter)(currentStoreSettings.styles, style => !style.isGlobalStyles);
11176 updateSettings({ ...currentStoreSettings,
11177 styles: [...nonGlobalStyles, ...styles],
11178 __experimentalFeatures: settings
11179 });
11180 }, [styles, settings]);
11181 }
11182
11183 function GlobalStylesRenderer() {
11184 useGlobalStylesRenderer();
11185 return null;
11186 }
11187
11188 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/routes/use-title.js
11189 /**
11190 * WordPress dependencies
11191 */
11192
11193
11194
11195
11196
11197 /**
11198 * Internal dependencies
11199 */
11200
11201
11202 function useTitle(title) {
11203 const location = useLocation();
11204 const siteTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
11205 var _select$getEntityReco;
11206
11207 return (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', 'site')) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.title;
11208 }, []);
11209 const isInitialLocationRef = (0,external_wp_element_namespaceObject.useRef)(true);
11210 (0,external_wp_element_namespaceObject.useEffect)(() => {
11211 isInitialLocationRef.current = false;
11212 }, [location]);
11213 (0,external_wp_element_namespaceObject.useEffect)(() => {
11214 // Don't update or announce the title for initial page load.
11215 if (isInitialLocationRef.current) {
11216 return;
11217 }
11218
11219 if (title && siteTitle) {
11220 // @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68
11221 const formattedTitle = (0,external_wp_i18n_namespaceObject.sprintf)(
11222 /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */
11223 (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s — WordPress'), title, siteTitle);
11224 document.title = formattedTitle; // Announce title on route change for screen readers.
11225
11226 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)(
11227 /* translators: The page title that is currently displaying. */
11228 (0,external_wp_i18n_namespaceObject.__)('Now displaying: %s'), document.title), 'assertive');
11229 }
11230 }, [title, siteTitle, location]);
11231 }
11232
11233 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/editor/index.js
11234
11235
11236 /**
11237 * WordPress dependencies
11238 */
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249 /**
11250 * Internal dependencies
11251 */
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268 const interfaceLabels = {
11269 drawer: (0,external_wp_i18n_namespaceObject.__)('Navigation Sidebar')
11270 };
11271
11272 function Editor(_ref) {
11273 let {
11274 onError
11275 } = _ref;
11276 const {
11277 isInserterOpen,
11278 isListViewOpen,
11279 sidebarIsOpened,
11280 settings,
11281 entityId,
11282 templateType,
11283 page,
11284 template,
11285 templateResolved,
11286 isNavigationOpen,
11287 previousShortcut,
11288 nextShortcut,
11289 editorMode,
11290 showIconLabels
11291 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11292 const {
11293 isInserterOpened,
11294 isListViewOpened,
11295 getSettings,
11296 getEditedPostType,
11297 getEditedPostId,
11298 getPage,
11299 isNavigationOpened,
11300 getEditorMode
11301 } = select(store_store);
11302 const {
11303 hasFinishedResolution,
11304 getEntityRecord
11305 } = select(external_wp_coreData_namespaceObject.store);
11306 const postType = getEditedPostType();
11307 const postId = getEditedPostId(); // The currently selected entity to display. Typically template or template part.
11308
11309 return {
11310 isInserterOpen: isInserterOpened(),
11311 isListViewOpen: isListViewOpened(),
11312 sidebarIsOpened: !!select(store).getActiveComplementaryArea(store_store.name),
11313 settings: getSettings(),
11314 templateType: postType,
11315 page: getPage(),
11316 template: postId ? getEntityRecord('postType', postType, postId) : null,
11317 templateResolved: postId ? hasFinishedResolution('getEntityRecord', ['postType', postType, postId]) : false,
11318 entityId: postId,
11319 isNavigationOpen: isNavigationOpened(),
11320 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
11321 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/next-region'),
11322 editorMode: getEditorMode(),
11323 showIconLabels: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showIconLabels')
11324 };
11325 }, []);
11326 const {
11327 setPage,
11328 setIsInserterOpened
11329 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11330 const {
11331 enableComplementaryArea
11332 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
11333 const [isEntitiesSavedStatesOpen, setIsEntitiesSavedStatesOpen] = (0,external_wp_element_namespaceObject.useState)(false);
11334 const openEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => setIsEntitiesSavedStatesOpen(true), []);
11335 const closeEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => {
11336 setIsEntitiesSavedStatesOpen(false);
11337 }, []);
11338 const blockContext = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...(page === null || page === void 0 ? void 0 : page.context),
11339 queryContext: [(page === null || page === void 0 ? void 0 : page.context.queryContext) || {
11340 page: 1
11341 }, newQueryContext => setPage({ ...page,
11342 context: { ...(page === null || page === void 0 ? void 0 : page.context),
11343 queryContext: { ...(page === null || page === void 0 ? void 0 : page.context.queryContext),
11344 ...newQueryContext
11345 }
11346 }
11347 })]
11348 }), [page === null || page === void 0 ? void 0 : page.context]);
11349 (0,external_wp_element_namespaceObject.useEffect)(() => {
11350 if (isNavigationOpen) {
11351 document.body.classList.add('is-navigation-sidebar-open');
11352 } else {
11353 document.body.classList.remove('is-navigation-sidebar-open');
11354 }
11355 }, [isNavigationOpen]);
11356 (0,external_wp_element_namespaceObject.useEffect)(function openGlobalStylesOnLoad() {
11357 const searchParams = new URLSearchParams(window.location.search);
11358
11359 if (searchParams.get('styles') === 'open') {
11360 enableComplementaryArea('core/edit-site', 'edit-site/global-styles');
11361 }
11362 }, [enableComplementaryArea]); // Don't render the Editor until the settings are set and loaded.
11363
11364 const isReady = (settings === null || settings === void 0 ? void 0 : settings.siteUrl) && templateType !== undefined && entityId !== undefined;
11365 const secondarySidebarLabel = isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
11366
11367 const secondarySidebar = () => {
11368 if (isInserterOpen) {
11369 return (0,external_wp_element_namespaceObject.createElement)(InserterSidebar, null);
11370 }
11371
11372 if (isListViewOpen) {
11373 return (0,external_wp_element_namespaceObject.createElement)(ListViewSidebar, null);
11374 }
11375
11376 return null;
11377 }; // Only announce the title once the editor is ready to prevent "Replace"
11378 // action in <URlQueryController> from double-announcing.
11379
11380
11381 useTitle(isReady && (0,external_wp_i18n_namespaceObject.__)('Editor (beta)'));
11382 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, {
11383 kind: "root",
11384 type: "site"
11385 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
11386 kind: "postType",
11387 type: templateType,
11388 id: entityId
11389 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
11390 value: blockContext
11391 }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesRenderer, null), (0,external_wp_element_namespaceObject.createElement)(ErrorBoundary, {
11392 onError: onError
11393 }, (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, {
11394 labels: { ...interfaceLabels,
11395 secondarySidebar: secondarySidebarLabel
11396 },
11397 className: showIconLabels && 'show-icon-labels',
11398 secondarySidebar: secondarySidebar(),
11399 sidebar: sidebarIsOpened && (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, {
11400 scope: "core/edit-site"
11401 }),
11402 drawer: (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar.Slot, null),
11403 header: (0,external_wp_element_namespaceObject.createElement)(Header, {
11404 openEntitiesSavedStates: openEntitiesSavedStates,
11405 showIconLabels: showIconLabels
11406 }),
11407 notices: (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null),
11408 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), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockStyles.Slot, {
11409 scope: "core/block-inspector"
11410 }), editorMode === 'visual' && template && (0,external_wp_element_namespaceObject.createElement)(BlockEditor, {
11411 setIsInserterOpen: setIsInserterOpened
11412 }), 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, {
11413 status: "warning",
11414 isDismissible: false
11415 }, (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, {
11416 openEntitiesSavedStates: openEntitiesSavedStates
11417 })),
11418 actions: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isEntitiesSavedStatesOpen ? (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EntitiesSavedStates, {
11419 close: closeEntitiesSavedStates
11420 }) : (0,external_wp_element_namespaceObject.createElement)("div", {
11421 className: "edit-site-editor__toggle-save-panel"
11422 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11423 variant: "secondary",
11424 className: "edit-site-editor__toggle-save-panel-button",
11425 onClick: openEntitiesSavedStates,
11426 "aria-expanded": false
11427 }, (0,external_wp_i18n_namespaceObject.__)('Open save panel')))),
11428 footer: (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
11429 rootLabelText: (0,external_wp_i18n_namespaceObject.__)('Template')
11430 }),
11431 shortcuts: {
11432 previous: previousShortcut,
11433 next: nextShortcut
11434 }
11435 }), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuide, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null))))))));
11436 }
11437
11438 /* harmony default export */ var editor = (Editor);
11439
11440 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/use-register-shortcuts.js
11441 /**
11442 * WordPress dependencies
11443 */
11444
11445
11446
11447
11448 function useRegisterShortcuts() {
11449 const {
11450 registerShortcut
11451 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
11452 (0,external_wp_element_namespaceObject.useEffect)(() => {
11453 registerShortcut({
11454 name: 'core/edit-site/next-region',
11455 category: 'global',
11456 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
11457 keyCombination: {
11458 modifier: 'ctrl',
11459 character: '`'
11460 },
11461 aliases: [{
11462 modifier: 'access',
11463 character: 'n'
11464 }]
11465 });
11466 registerShortcut({
11467 name: 'core/edit-site/previous-region',
11468 category: 'global',
11469 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
11470 keyCombination: {
11471 modifier: 'ctrlShift',
11472 character: '`'
11473 },
11474 aliases: [{
11475 modifier: 'access',
11476 character: 'p'
11477 }]
11478 });
11479 }, []);
11480 }
11481
11482 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post.js
11483
11484
11485 /**
11486 * WordPress dependencies
11487 */
11488
11489 const post = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11490 xmlns: "http://www.w3.org/2000/svg",
11491 viewBox: "0 0 24 24"
11492 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11493 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"
11494 }));
11495 /* harmony default export */ var library_post = (post);
11496
11497 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/page.js
11498
11499
11500 /**
11501 * WordPress dependencies
11502 */
11503
11504 const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11505 xmlns: "http://www.w3.org/2000/svg",
11506 viewBox: "0 0 24 24"
11507 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11508 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"
11509 }));
11510 /* harmony default export */ var library_page = (page);
11511
11512 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/archive.js
11513
11514
11515 /**
11516 * WordPress dependencies
11517 */
11518
11519 const archive = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11520 viewBox: "0 0 24 24",
11521 xmlns: "http://www.w3.org/2000/svg"
11522 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11523 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"
11524 }));
11525 /* harmony default export */ var library_archive = (archive);
11526
11527 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/search.js
11528
11529
11530 /**
11531 * WordPress dependencies
11532 */
11533
11534 const search = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11535 xmlns: "http://www.w3.org/2000/svg",
11536 viewBox: "0 0 24 24"
11537 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11538 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"
11539 }));
11540 /* harmony default export */ var library_search = (search);
11541
11542 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/not-found.js
11543
11544
11545 /**
11546 * WordPress dependencies
11547 */
11548
11549 const notFound = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11550 xmlns: "http://www.w3.org/2000/svg",
11551 viewBox: "0 0 24 24"
11552 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11553 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"
11554 }));
11555 /* harmony default export */ var not_found = (notFound);
11556
11557 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list.js
11558
11559
11560 /**
11561 * WordPress dependencies
11562 */
11563
11564 const list = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11565 viewBox: "0 0 24 24",
11566 xmlns: "http://www.w3.org/2000/svg"
11567 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11568 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"
11569 }));
11570 /* harmony default export */ var library_list = (list);
11571
11572 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/category.js
11573
11574
11575 /**
11576 * WordPress dependencies
11577 */
11578
11579 const category = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11580 viewBox: "0 0 24 24",
11581 xmlns: "http://www.w3.org/2000/svg"
11582 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11583 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",
11584 fillRule: "evenodd",
11585 clipRule: "evenodd"
11586 }));
11587 /* harmony default export */ var library_category = (category);
11588
11589 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post-author.js
11590
11591
11592 /**
11593 * WordPress dependencies
11594 */
11595
11596 const postAuthor = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11597 viewBox: "0 0 24 24",
11598 xmlns: "http://www.w3.org/2000/svg"
11599 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11600 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",
11601 fillRule: "evenodd",
11602 clipRule: "evenodd"
11603 }));
11604 /* harmony default export */ var post_author = (postAuthor);
11605
11606 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-meta.js
11607
11608
11609 /**
11610 * WordPress dependencies
11611 */
11612
11613 const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11614 xmlns: "http://www.w3.org/2000/svg",
11615 viewBox: "0 0 24 24"
11616 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11617 "fill-rule": "evenodd",
11618 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",
11619 "clip-rule": "evenodd"
11620 }));
11621 /* harmony default export */ var block_meta = (blockDefault);
11622
11623 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/post-date.js
11624
11625
11626 /**
11627 * WordPress dependencies
11628 */
11629
11630 const postDate = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11631 xmlns: "http://www.w3.org/2000/svg",
11632 viewBox: "0 0 24 24"
11633 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11634 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"
11635 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11636 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"
11637 }));
11638 /* harmony default export */ var post_date = (postDate);
11639
11640 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/tag.js
11641
11642
11643 /**
11644 * WordPress dependencies
11645 */
11646
11647 const tag = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11648 xmlns: "http://www.w3.org/2000/svg",
11649 viewBox: "0 0 24 24"
11650 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11651 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"
11652 }));
11653 /* harmony default export */ var library_tag = (tag);
11654
11655 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/media.js
11656
11657
11658 /**
11659 * WordPress dependencies
11660 */
11661
11662 const media = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11663 xmlns: "http://www.w3.org/2000/svg",
11664 viewBox: "0 0 24 24"
11665 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11666 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"
11667 }));
11668 /* harmony default export */ var library_media = (media);
11669
11670 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/new-template.js
11671
11672
11673 /**
11674 * External dependencies
11675 */
11676
11677 /**
11678 * WordPress dependencies
11679 */
11680
11681
11682
11683
11684
11685
11686
11687
11688 /**
11689 * Internal dependencies
11690 */
11691
11692
11693 const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'single-post', 'page', 'index', 'archive', 'author', 'category', 'date', 'tag', 'taxonomy', 'search', '404'];
11694 const TEMPLATE_ICONS = {
11695 'front-page': library_home,
11696 'single-post': library_post,
11697 page: library_page,
11698 archive: library_archive,
11699 search: library_search,
11700 404: not_found,
11701 index: library_list,
11702 category: library_category,
11703 author: post_author,
11704 taxonomy: block_meta,
11705 date: post_date,
11706 tag: library_tag,
11707 attachment: library_media
11708 };
11709 function NewTemplate(_ref) {
11710 let {
11711 postType
11712 } = _ref;
11713 const history = useHistory();
11714 const {
11715 templates,
11716 defaultTemplateTypes
11717 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
11718 templates: select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
11719 per_page: -1
11720 }),
11721 defaultTemplateTypes: select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplateTypes()
11722 }), []);
11723 const {
11724 saveEntityRecord
11725 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11726 const {
11727 createErrorNotice
11728 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
11729
11730 async function createTemplate(_ref2) {
11731 let {
11732 slug
11733 } = _ref2;
11734
11735 try {
11736 const {
11737 title,
11738 description
11739 } = (0,external_lodash_namespaceObject.find)(defaultTemplateTypes, {
11740 slug
11741 });
11742 const template = await saveEntityRecord('postType', 'wp_template', {
11743 excerpt: description,
11744 // Slugs need to be strings, so this is for template `404`
11745 slug: slug.toString(),
11746 status: 'publish',
11747 title
11748 }, {
11749 throwOnError: true
11750 }); // Navigate to the created template editor.
11751
11752 history.push({
11753 postId: template.id,
11754 postType: template.type
11755 }); // TODO: Add a success notice?
11756 } catch (error) {
11757 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template.');
11758 createErrorNotice(errorMessage, {
11759 type: 'snackbar'
11760 });
11761 }
11762 }
11763
11764 const existingTemplateSlugs = (0,external_lodash_namespaceObject.map)(templates, 'slug');
11765 const missingTemplates = (0,external_lodash_namespaceObject.filter)(defaultTemplateTypes, template => (0,external_lodash_namespaceObject.includes)(DEFAULT_TEMPLATE_SLUGS, template.slug) && !(0,external_lodash_namespaceObject.includes)(existingTemplateSlugs, template.slug));
11766
11767 if (!missingTemplates.length) {
11768 return null;
11769 } // Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.
11770
11771
11772 missingTemplates.sort((template1, template2) => {
11773 return DEFAULT_TEMPLATE_SLUGS.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS.indexOf(template2.slug);
11774 });
11775 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
11776 className: "edit-site-new-template-dropdown",
11777 icon: null,
11778 text: postType.labels.add_new,
11779 label: postType.labels.add_new_item,
11780 popoverProps: {
11781 noArrow: false
11782 },
11783 toggleProps: {
11784 variant: 'primary'
11785 }
11786 }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, {
11787 className: "edit-site-new-template-dropdown__popover"
11788 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
11789 label: postType.labels.add_new_item
11790 }, (0,external_lodash_namespaceObject.map)(missingTemplates, _ref3 => {
11791 let {
11792 title,
11793 description,
11794 slug
11795 } = _ref3;
11796 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
11797 icon: TEMPLATE_ICONS[slug],
11798 iconPosition: "left",
11799 info: description,
11800 key: slug,
11801 onClick: () => {
11802 createTemplate({
11803 slug
11804 }); // We will be navigated way so no need to close the dropdown.
11805 }
11806 }, title);
11807 }))));
11808 }
11809
11810 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/new-template-part.js
11811
11812
11813 /**
11814 * External dependencies
11815 */
11816
11817 /**
11818 * WordPress dependencies
11819 */
11820
11821
11822
11823
11824
11825
11826
11827 /**
11828 * Internal dependencies
11829 */
11830
11831
11832
11833 function NewTemplatePart(_ref) {
11834 let {
11835 postType
11836 } = _ref;
11837 const history = useHistory();
11838 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
11839 const {
11840 createErrorNotice
11841 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
11842 const {
11843 saveEntityRecord
11844 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11845
11846 async function createTemplatePart(_ref2) {
11847 let {
11848 title,
11849 area
11850 } = _ref2;
11851
11852 if (!title) {
11853 createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Title is not defined.'), {
11854 type: 'snackbar'
11855 });
11856 return;
11857 }
11858
11859 try {
11860 // Currently template parts only allow latin chars.
11861 // Fallback slug will receive suffix by default.
11862 const cleanSlug = (0,external_lodash_namespaceObject.kebabCase)(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
11863 const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
11864 slug: cleanSlug,
11865 title,
11866 content: '',
11867 area
11868 }, {
11869 throwOnError: true
11870 });
11871 setIsModalOpen(false); // Navigate to the created template part editor.
11872
11873 history.push({
11874 postId: templatePart.id,
11875 postType: templatePart.type
11876 }); // TODO: Add a success notice?
11877 } catch (error) {
11878 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.');
11879 createErrorNotice(errorMessage, {
11880 type: 'snackbar'
11881 });
11882 setIsModalOpen(false);
11883 }
11884 }
11885
11886 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
11887 variant: "primary",
11888 onClick: () => {
11889 setIsModalOpen(true);
11890 }
11891 }, postType.labels.add_new), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, {
11892 closeModal: () => setIsModalOpen(false),
11893 onCreate: createTemplatePart
11894 }));
11895 }
11896
11897 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/add-new-template/index.js
11898
11899
11900 /**
11901 * WordPress dependencies
11902 */
11903
11904
11905 /**
11906 * Internal dependencies
11907 */
11908
11909
11910
11911 function AddNewTemplate(_ref) {
11912 let {
11913 templateType = 'wp_template'
11914 } = _ref;
11915 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
11916
11917 if (!postType) {
11918 return null;
11919 }
11920
11921 if (templateType === 'wp_template') {
11922 return (0,external_wp_element_namespaceObject.createElement)(NewTemplate, {
11923 postType: postType
11924 });
11925 } else if (templateType === 'wp_template_part') {
11926 return (0,external_wp_element_namespaceObject.createElement)(NewTemplatePart, {
11927 postType: postType
11928 });
11929 }
11930
11931 return null;
11932 }
11933
11934 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/header.js
11935
11936
11937 /**
11938 * WordPress dependencies
11939 */
11940
11941
11942
11943 /**
11944 * Internal dependencies
11945 */
11946
11947
11948 function header_Header(_ref) {
11949 var _postType$labels;
11950
11951 let {
11952 templateType
11953 } = _ref;
11954 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
11955
11956 if (!postType) {
11957 return null;
11958 }
11959
11960 return (0,external_wp_element_namespaceObject.createElement)("header", {
11961 className: "edit-site-list-header"
11962 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
11963 level: 1,
11964 className: "edit-site-list-header__title"
11965 }, (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.name), (0,external_wp_element_namespaceObject.createElement)("div", {
11966 className: "edit-site-list-header__right"
11967 }, (0,external_wp_element_namespaceObject.createElement)(AddNewTemplate, {
11968 templateType: templateType
11969 })));
11970 }
11971
11972 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/is-template-removable.js
11973 /**
11974 * Check if a template is removable.
11975 *
11976 * @param {Object} template The template entity to check.
11977 * @return {boolean} Whether the template is revertable.
11978 */
11979 function isTemplateRemovable(template) {
11980 if (!template) {
11981 return false;
11982 }
11983
11984 return template.source === 'custom' && !template.has_theme_file;
11985 }
11986
11987 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/actions/rename-menu-item.js
11988
11989
11990 /**
11991 * WordPress dependencies
11992 */
11993
11994
11995
11996
11997
11998
11999 function RenameMenuItem(_ref) {
12000 let {
12001 template,
12002 onClose
12003 } = _ref;
12004 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => template.title.rendered);
12005 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
12006 const {
12007 editEntityRecord,
12008 saveEditedEntityRecord
12009 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
12010 const {
12011 createSuccessNotice,
12012 createErrorNotice
12013 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
12014
12015 if (!template.is_custom) {
12016 return null;
12017 }
12018
12019 async function onTemplateRename(event) {
12020 event.preventDefault();
12021
12022 try {
12023 await editEntityRecord('postType', template.type, template.id, {
12024 title
12025 }); // Update state before saving rerenders the list.
12026
12027 setTitle('');
12028 setIsModalOpen(false);
12029 onClose(); // Persist edited entity.
12030
12031 await saveEditedEntityRecord('postType', template.type, template.id, {
12032 throwOnError: true
12033 });
12034 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Entity renamed.'), {
12035 type: 'snackbar'
12036 });
12037 } catch (error) {
12038 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the entity.');
12039 createErrorNotice(errorMessage, {
12040 type: 'snackbar'
12041 });
12042 }
12043 }
12044
12045 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
12046 onClick: () => {
12047 setIsModalOpen(true);
12048 setTitle(template.title.rendered);
12049 }
12050 }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
12051 title: (0,external_wp_i18n_namespaceObject.__)('Rename'),
12052 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
12053 onRequestClose: () => {
12054 setIsModalOpen(false);
12055 },
12056 overlayClassName: "edit-site-list__rename-modal"
12057 }, (0,external_wp_element_namespaceObject.createElement)("form", {
12058 onSubmit: onTemplateRename
12059 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
12060 align: "flex-start",
12061 gap: 8
12062 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
12063 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
12064 value: title,
12065 onChange: setTitle,
12066 required: true
12067 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
12068 className: "edit-site-list__rename-modal-actions",
12069 justify: "flex-end",
12070 expanded: false
12071 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
12072 variant: "tertiary",
12073 onClick: () => {
12074 setIsModalOpen(false);
12075 }
12076 }, (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, {
12077 variant: "primary",
12078 type: "submit"
12079 }, (0,external_wp_i18n_namespaceObject.__)('Save')))))));
12080 }
12081
12082 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/actions/index.js
12083
12084
12085 /**
12086 * WordPress dependencies
12087 */
12088
12089
12090
12091
12092
12093
12094 /**
12095 * Internal dependencies
12096 */
12097
12098
12099
12100
12101
12102 function Actions(_ref) {
12103 let {
12104 template
12105 } = _ref;
12106 const {
12107 removeTemplate,
12108 revertTemplate
12109 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12110 const {
12111 saveEditedEntityRecord
12112 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
12113 const {
12114 createSuccessNotice,
12115 createErrorNotice
12116 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
12117 const isRemovable = isTemplateRemovable(template);
12118 const isRevertable = isTemplateRevertable(template);
12119
12120 if (!isRemovable && !isRevertable) {
12121 return null;
12122 }
12123
12124 async function revertAndSaveTemplate() {
12125 try {
12126 await revertTemplate(template, {
12127 allowUndo: false
12128 });
12129 await saveEditedEntityRecord('postType', template.type, template.id);
12130 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Entity reverted.'), {
12131 type: 'snackbar'
12132 });
12133 } catch (error) {
12134 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the entity.');
12135 createErrorNotice(errorMessage, {
12136 type: 'snackbar'
12137 });
12138 }
12139 }
12140
12141 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
12142 icon: more_vertical,
12143 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
12144 className: "edit-site-list-table__actions"
12145 }, _ref2 => {
12146 let {
12147 onClose
12148 } = _ref2;
12149 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, {
12150 template: template,
12151 onClose: onClose
12152 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
12153 isDestructive: true,
12154 isTertiary: true,
12155 onClick: () => {
12156 removeTemplate(template);
12157 onClose();
12158 }
12159 }, (0,external_wp_i18n_namespaceObject.__)('Delete'))), isRevertable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
12160 info: (0,external_wp_i18n_namespaceObject.__)('Restore to default state'),
12161 onClick: () => {
12162 revertAndSaveTemplate();
12163 onClose();
12164 }
12165 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations')));
12166 });
12167 }
12168
12169 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plugins.js
12170
12171
12172 /**
12173 * WordPress dependencies
12174 */
12175
12176 const plugins = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12177 xmlns: "http://www.w3.org/2000/svg",
12178 viewBox: "0 0 24 24"
12179 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12180 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"
12181 }));
12182 /* harmony default export */ var library_plugins = (plugins);
12183
12184 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/comment-author-avatar.js
12185
12186
12187 /**
12188 * WordPress dependencies
12189 */
12190
12191 const commentAuthorAvatar = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12192 xmlns: "http://www.w3.org/2000/svg",
12193 viewBox: "0 0 24 24"
12194 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12195 fillRule: "evenodd",
12196 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",
12197 clipRule: "evenodd"
12198 }));
12199 /* harmony default export */ var comment_author_avatar = (commentAuthorAvatar);
12200
12201 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/globe.js
12202
12203
12204 /**
12205 * WordPress dependencies
12206 */
12207
12208 const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
12209 xmlns: "http://www.w3.org/2000/svg",
12210 viewBox: "0 0 24 24"
12211 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
12212 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"
12213 }));
12214 /* harmony default export */ var library_globe = (globe);
12215
12216 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/added-by.js
12217
12218
12219 /**
12220 * External dependencies
12221 */
12222
12223 /**
12224 * WordPress dependencies
12225 */
12226
12227
12228
12229
12230
12231
12232
12233 const TEMPLATE_POST_TYPE_NAMES = ['wp_template', 'wp_template_part'];
12234
12235 function CustomizedTooltip(_ref) {
12236 let {
12237 isCustomized,
12238 children
12239 } = _ref;
12240
12241 if (!isCustomized) {
12242 return children;
12243 }
12244
12245 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, {
12246 text: (0,external_wp_i18n_namespaceObject.__)('This template has been customized')
12247 }, children);
12248 }
12249
12250 function BaseAddedBy(_ref2) {
12251 let {
12252 text,
12253 icon,
12254 imageUrl,
12255 isCustomized
12256 } = _ref2;
12257 const [isImageLoaded, setIsImageLoaded] = (0,external_wp_element_namespaceObject.useState)(false);
12258 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
12259 alignment: "left"
12260 }, (0,external_wp_element_namespaceObject.createElement)(CustomizedTooltip, {
12261 isCustomized: isCustomized
12262 }, imageUrl ? (0,external_wp_element_namespaceObject.createElement)("div", {
12263 className: classnames_default()('edit-site-list-added-by__avatar', {
12264 'is-loaded': isImageLoaded
12265 })
12266 }, (0,external_wp_element_namespaceObject.createElement)("img", {
12267 onLoad: () => setIsImageLoaded(true),
12268 alt: "",
12269 src: imageUrl
12270 })) : (0,external_wp_element_namespaceObject.createElement)("div", {
12271 className: classnames_default()('edit-site-list-added-by__icon', {
12272 'is-customized': isCustomized
12273 })
12274 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
12275 icon: icon
12276 }))), (0,external_wp_element_namespaceObject.createElement)("span", null, text));
12277 }
12278
12279 function AddedByTheme(_ref3) {
12280 var _theme$name;
12281
12282 let {
12283 slug,
12284 isCustomized
12285 } = _ref3;
12286 const theme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getTheme(slug), [slug]);
12287 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
12288 icon: library_layout,
12289 text: (theme === null || theme === void 0 ? void 0 : (_theme$name = theme.name) === null || _theme$name === void 0 ? void 0 : _theme$name.rendered) || slug,
12290 isCustomized: isCustomized
12291 });
12292 }
12293
12294 function AddedByPlugin(_ref4) {
12295 let {
12296 slug,
12297 isCustomized
12298 } = _ref4;
12299 const plugin = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPlugin(slug), [slug]);
12300 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
12301 icon: library_plugins,
12302 text: (plugin === null || plugin === void 0 ? void 0 : plugin.name) || slug,
12303 isCustomized: isCustomized
12304 });
12305 }
12306
12307 function AddedByAuthor(_ref5) {
12308 var _user$avatar_urls;
12309
12310 let {
12311 id
12312 } = _ref5;
12313 const user = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getUser(id), [id]);
12314 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
12315 icon: comment_author_avatar,
12316 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],
12317 text: user === null || user === void 0 ? void 0 : user.nickname
12318 });
12319 }
12320
12321 function AddedBySite() {
12322 const {
12323 name,
12324 logoURL
12325 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12326 var _getMedia;
12327
12328 const {
12329 getEntityRecord,
12330 getMedia
12331 } = select(external_wp_coreData_namespaceObject.store);
12332 const siteData = getEntityRecord('root', '__unstableBase');
12333 return {
12334 name: siteData === null || siteData === void 0 ? void 0 : siteData.name,
12335 logoURL: siteData !== null && siteData !== void 0 && siteData.site_logo ? (_getMedia = getMedia(siteData.site_logo)) === null || _getMedia === void 0 ? void 0 : _getMedia.source_url : undefined
12336 };
12337 }, []);
12338 return (0,external_wp_element_namespaceObject.createElement)(BaseAddedBy, {
12339 icon: library_globe,
12340 imageUrl: logoURL,
12341 text: name
12342 });
12343 }
12344
12345 function AddedBy(_ref6) {
12346 let {
12347 templateType,
12348 template
12349 } = _ref6;
12350
12351 if (!template) {
12352 return;
12353 }
12354
12355 if (TEMPLATE_POST_TYPE_NAMES.includes(templateType)) {
12356 // Template originally provided by a theme, but customized by a user.
12357 // Templates originally didn't have the 'origin' field so identify
12358 // older customized templates by checking for no origin and a 'theme'
12359 // or 'custom' source.
12360 if (template.has_theme_file && (template.origin === 'theme' || !template.origin && ['theme', 'custom'].includes(template.source))) {
12361 return (0,external_wp_element_namespaceObject.createElement)(AddedByTheme, {
12362 slug: template.theme,
12363 isCustomized: template.source === 'custom'
12364 });
12365 } // Template originally provided by a plugin, but customized by a user.
12366
12367
12368 if (template.has_theme_file && template.origin === 'plugin') {
12369 return (0,external_wp_element_namespaceObject.createElement)(AddedByPlugin, {
12370 slug: template.theme,
12371 isCustomized: template.source === 'custom'
12372 });
12373 } // Template was created from scratch, but has no author. Author support
12374 // was only added to templates in WordPress 5.9. Fallback to showing the
12375 // site logo and title.
12376
12377
12378 if (!template.has_theme_file && template.source === 'custom' && !template.author) {
12379 return (0,external_wp_element_namespaceObject.createElement)(AddedBySite, null);
12380 }
12381 } // Simply show the author for templates created from scratch that have an
12382 // author or for any other post type.
12383
12384
12385 return (0,external_wp_element_namespaceObject.createElement)(AddedByAuthor, {
12386 id: template.author
12387 });
12388 }
12389
12390 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/table.js
12391
12392
12393 /**
12394 * WordPress dependencies
12395 */
12396
12397
12398
12399
12400
12401 /**
12402 * Internal dependencies
12403 */
12404
12405
12406
12407
12408 function Table(_ref) {
12409 let {
12410 templateType
12411 } = _ref;
12412 const {
12413 records: templates,
12414 isResolving: isLoading
12415 } = (0,external_wp_coreData_namespaceObject.__experimentalUseEntityRecords)('postType', templateType, {
12416 per_page: -1
12417 });
12418 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
12419
12420 if (!templates || isLoading) {
12421 return null;
12422 }
12423
12424 if (!templates.length) {
12425 var _postType$labels, _postType$labels$name;
12426
12427 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".
12428 (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()));
12429 }
12430
12431 return (// These explicit aria roles are needed for Safari.
12432 // See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
12433 (0,external_wp_element_namespaceObject.createElement)("table", {
12434 className: "edit-site-list-table",
12435 role: "table"
12436 }, (0,external_wp_element_namespaceObject.createElement)("thead", null, (0,external_wp_element_namespaceObject.createElement)("tr", {
12437 className: "edit-site-list-table-head",
12438 role: "row"
12439 }, (0,external_wp_element_namespaceObject.createElement)("th", {
12440 className: "edit-site-list-table-column",
12441 role: "columnheader"
12442 }, (0,external_wp_i18n_namespaceObject.__)('Template')), (0,external_wp_element_namespaceObject.createElement)("th", {
12443 className: "edit-site-list-table-column",
12444 role: "columnheader"
12445 }, (0,external_wp_i18n_namespaceObject.__)('Added by')), (0,external_wp_element_namespaceObject.createElement)("th", {
12446 className: "edit-site-list-table-column",
12447 role: "columnheader"
12448 }, (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 => {
12449 var _template$title;
12450
12451 return (0,external_wp_element_namespaceObject.createElement)("tr", {
12452 key: template.id,
12453 className: "edit-site-list-table-row",
12454 role: "row"
12455 }, (0,external_wp_element_namespaceObject.createElement)("td", {
12456 className: "edit-site-list-table-column",
12457 role: "cell"
12458 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, {
12459 level: 4
12460 }, (0,external_wp_element_namespaceObject.createElement)(Link, {
12461 params: {
12462 postId: template.id,
12463 postType: template.type
12464 }
12465 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(((_template$title = template.title) === null || _template$title === void 0 ? void 0 : _template$title.rendered) || template.slug))), template.description), (0,external_wp_element_namespaceObject.createElement)("td", {
12466 className: "edit-site-list-table-column",
12467 role: "cell"
12468 }, (0,external_wp_element_namespaceObject.createElement)(AddedBy, {
12469 templateType: templateType,
12470 template: template
12471 })), (0,external_wp_element_namespaceObject.createElement)("td", {
12472 className: "edit-site-list-table-column",
12473 role: "cell"
12474 }, (0,external_wp_element_namespaceObject.createElement)(Actions, {
12475 template: template
12476 })));
12477 })))
12478 );
12479 }
12480
12481 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/list/index.js
12482
12483
12484 /**
12485 * External dependencies
12486 */
12487
12488 /**
12489 * WordPress dependencies
12490 */
12491
12492
12493
12494
12495
12496
12497
12498 /**
12499 * Internal dependencies
12500 */
12501
12502
12503
12504
12505
12506
12507
12508
12509 function List() {
12510 var _postType$labels, _postType$labels2;
12511
12512 const {
12513 params: {
12514 postType: templateType
12515 }
12516 } = useLocation();
12517 useRegisterShortcuts();
12518 const {
12519 previousShortcut,
12520 nextShortcut,
12521 isNavigationOpen
12522 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12523 return {
12524 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/previous-region'),
12525 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/edit-site/next-region'),
12526 isNavigationOpen: select(store_store).isNavigationOpened()
12527 };
12528 }, []);
12529 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]);
12530 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
12531 // the postType has loaded, otherwise `InterfaceSkeleton` will fallback to the defaults.
12532
12533 const itemsListLabel = postType === null || postType === void 0 ? void 0 : (_postType$labels2 = postType.labels) === null || _postType$labels2 === void 0 ? void 0 : _postType$labels2.items_list;
12534 const detailedRegionLabels = postType ? {
12535 header: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s - the name of the page, 'Header' as in the header area of that page.
12536 (0,external_wp_i18n_namespaceObject.__)('%s - Header'), itemsListLabel),
12537 body: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s - the name of the page, 'Content' as in the content area of that page.
12538 (0,external_wp_i18n_namespaceObject.__)('%s - Content'), itemsListLabel)
12539 } : undefined;
12540 return (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
12541 className: classnames_default()('edit-site-list', {
12542 'is-navigation-open': isNavigationOpen
12543 }),
12544 labels: {
12545 drawer: (0,external_wp_i18n_namespaceObject.__)('Navigation Sidebar'),
12546 ...detailedRegionLabels
12547 },
12548 header: (0,external_wp_element_namespaceObject.createElement)(header_Header, {
12549 templateType: templateType
12550 }),
12551 drawer: (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar.Slot, null),
12552 notices: (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null),
12553 content: (0,external_wp_element_namespaceObject.createElement)(Table, {
12554 templateType: templateType
12555 }),
12556 shortcuts: {
12557 previous: previousShortcut,
12558 next: nextShortcut
12559 }
12560 });
12561 }
12562
12563 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/utils/get-is-list-page.js
12564 /**
12565 * Returns if the params match the list page route.
12566 *
12567 * @param {Object} params The search params.
12568 * @param {string} params.postId The post ID.
12569 * @param {string} params.postType The post type.
12570 * @return {boolean} Is list page or not.
12571 */
12572 function getIsListPage(_ref) {
12573 let {
12574 postId,
12575 postType
12576 } = _ref;
12577 return !!(!postId && postType);
12578 }
12579
12580 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/app/index.js
12581
12582
12583 /**
12584 * WordPress dependencies
12585 */
12586
12587
12588
12589
12590
12591
12592 /**
12593 * Internal dependencies
12594 */
12595
12596
12597
12598
12599
12600
12601 function EditSiteApp(_ref) {
12602 let {
12603 reboot
12604 } = _ref;
12605 const {
12606 createErrorNotice
12607 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
12608
12609 function onPluginAreaError(name) {
12610 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)(
12611 /* translators: %s: plugin name */
12612 (0,external_wp_i18n_namespaceObject.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name));
12613 }
12614
12615 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 => {
12616 let {
12617 params
12618 } = _ref2;
12619 const isListPage = getIsListPage(params);
12620 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, {
12621 onError: reboot
12622 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, {
12623 onError: onPluginAreaError
12624 }), (0,external_wp_element_namespaceObject.createElement)(navigation_sidebar // Open the navigation sidebar by default when in the list page.
12625 , {
12626 isDefaultOpen: !!isListPage,
12627 activeTemplateType: isListPage ? params.postType : undefined
12628 }));
12629 }));
12630 }
12631
12632 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/sidebar/plugin-sidebar/index.js
12633
12634
12635
12636 /**
12637 * WordPress dependencies
12638 */
12639
12640 /**
12641 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
12642 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
12643 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
12644 *
12645 * ```js
12646 * wp.data.dispatch( 'core/edit-site' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
12647 * ```
12648 *
12649 * @see PluginSidebarMoreMenuItem
12650 *
12651 * @param {Object} props Element props.
12652 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
12653 * @param {string} [props.className] An optional class name added to the sidebar body.
12654 * @param {string} props.title Title displayed at the top of the sidebar.
12655 * @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.
12656 * @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.
12657 *
12658 * @example
12659 * ```js
12660 * // Using ES5 syntax
12661 * var __ = wp.i18n.__;
12662 * var el = wp.element.createElement;
12663 * var PanelBody = wp.components.PanelBody;
12664 * var PluginSidebar = wp.editSite.PluginSidebar;
12665 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
12666 *
12667 * function MyPluginSidebar() {
12668 * return el(
12669 * PluginSidebar,
12670 * {
12671 * name: 'my-sidebar',
12672 * title: 'My sidebar title',
12673 * icon: moreIcon,
12674 * },
12675 * el(
12676 * PanelBody,
12677 * {},
12678 * __( 'My sidebar content' )
12679 * )
12680 * );
12681 * }
12682 * ```
12683 *
12684 * @example
12685 * ```jsx
12686 * // Using ESNext syntax
12687 * import { __ } from '@wordpress/i18n';
12688 * import { PanelBody } from '@wordpress/components';
12689 * import { PluginSidebar } from '@wordpress/edit-site';
12690 * import { more } from '@wordpress/icons';
12691 *
12692 * const MyPluginSidebar = () => (
12693 * <PluginSidebar
12694 * name="my-sidebar"
12695 * title="My sidebar title"
12696 * icon={ more }
12697 * >
12698 * <PanelBody>
12699 * { __( 'My sidebar content' ) }
12700 * </PanelBody>
12701 * </PluginSidebar>
12702 * );
12703 * ```
12704 */
12705
12706 function PluginSidebarEditSite(_ref) {
12707 let {
12708 className,
12709 ...props
12710 } = _ref;
12711 return (0,external_wp_element_namespaceObject.createElement)(complementary_area, extends_extends({
12712 panelClassName: className,
12713 className: "edit-site-sidebar",
12714 scope: "core/edit-site"
12715 }, props));
12716 }
12717
12718 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/plugin-sidebar-more-menu-item/index.js
12719
12720
12721
12722 /**
12723 * WordPress dependencies
12724 */
12725
12726 /**
12727 * Renders a menu item in `Plugins` group in `More Menu` drop down,
12728 * and can be used to activate the corresponding `PluginSidebar` component.
12729 * The text within the component appears as the menu item label.
12730 *
12731 * @param {Object} props Component props.
12732 * @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.
12733 * @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.
12734 *
12735 * @example
12736 * ```js
12737 * // Using ES5 syntax
12738 * var __ = wp.i18n.__;
12739 * var PluginSidebarMoreMenuItem = wp.editSite.PluginSidebarMoreMenuItem;
12740 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
12741 *
12742 * function MySidebarMoreMenuItem() {
12743 * return wp.element.createElement(
12744 * PluginSidebarMoreMenuItem,
12745 * {
12746 * target: 'my-sidebar',
12747 * icon: moreIcon,
12748 * },
12749 * __( 'My sidebar title' )
12750 * )
12751 * }
12752 * ```
12753 *
12754 * @example
12755 * ```jsx
12756 * // Using ESNext syntax
12757 * import { __ } from '@wordpress/i18n';
12758 * import { PluginSidebarMoreMenuItem } from '@wordpress/edit-site';
12759 * import { more } from '@wordpress/icons';
12760 *
12761 * const MySidebarMoreMenuItem = () => (
12762 * <PluginSidebarMoreMenuItem
12763 * target="my-sidebar"
12764 * icon={ more }
12765 * >
12766 * { __( 'My sidebar title' ) }
12767 * </PluginSidebarMoreMenuItem>
12768 * );
12769 * ```
12770 *
12771 * @return {WPComponent} The component to be rendered.
12772 */
12773
12774 function PluginSidebarMoreMenuItem(props) {
12775 return (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem // Menu item is marked with unstable prop for backward compatibility.
12776 // @see https://github.com/WordPress/gutenberg/issues/14457
12777 , extends_extends({
12778 __unstableExplicitMenuItem: true,
12779 scope: "core/edit-site"
12780 }, props));
12781 }
12782
12783 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/components/header/plugin-more-menu-item/index.js
12784 /**
12785 * WordPress dependencies
12786 */
12787
12788
12789
12790
12791 /**
12792 * 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.
12793 * The text within the component appears as the menu item label.
12794 *
12795 * @param {Object} props Component properties.
12796 * @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.
12797 * @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.
12798 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
12799 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.
12800 *
12801 * @example
12802 * ```js
12803 * // Using ES5 syntax
12804 * var __ = wp.i18n.__;
12805 * var PluginMoreMenuItem = wp.editSite.PluginMoreMenuItem;
12806 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
12807 *
12808 * function onButtonClick() {
12809 * alert( 'Button clicked.' );
12810 * }
12811 *
12812 * function MyButtonMoreMenuItem() {
12813 * return wp.element.createElement(
12814 * PluginMoreMenuItem,
12815 * {
12816 * icon: moreIcon,
12817 * onClick: onButtonClick,
12818 * },
12819 * __( 'My button title' )
12820 * );
12821 * }
12822 * ```
12823 *
12824 * @example
12825 * ```jsx
12826 * // Using ESNext syntax
12827 * import { __ } from '@wordpress/i18n';
12828 * import { PluginMoreMenuItem } from '@wordpress/edit-site';
12829 * import { more } from '@wordpress/icons';
12830 *
12831 * function onButtonClick() {
12832 * alert( 'Button clicked.' );
12833 * }
12834 *
12835 * const MyButtonMoreMenuItem = () => (
12836 * <PluginMoreMenuItem
12837 * icon={ more }
12838 * onClick={ onButtonClick }
12839 * >
12840 * { __( 'My button title' ) }
12841 * </PluginMoreMenuItem>
12842 * );
12843 * ```
12844 *
12845 * @return {WPComponent} The component to be rendered.
12846 */
12847
12848 /* harmony default export */ var plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
12849 var _ownProps$as;
12850
12851 return {
12852 as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : external_wp_components_namespaceObject.MenuItem,
12853 icon: ownProps.icon || context.icon,
12854 name: 'core/edit-site/plugin-more-menu'
12855 };
12856 }))(action_item));
12857
12858 ;// CONCATENATED MODULE: ./packages/edit-site/build-module/index.js
12859
12860
12861 /**
12862 * WordPress dependencies
12863 */
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874 /**
12875 * Internal dependencies
12876 */
12877
12878
12879
12880
12881
12882
12883 /**
12884 * Reinitializes the editor after the user chooses to reboot the editor after
12885 * an unhandled error occurs, replacing previously mounted editor element using
12886 * an initial state from prior to the crash.
12887 *
12888 * @param {Element} target DOM node in which editor is rendered.
12889 * @param {?Object} settings Editor settings object.
12890 */
12891
12892 function reinitializeEditor(target, settings) {
12893 // Display warning if editor wasn't able to resolve homepage template.
12894 if (!settings.__unstableHomeTemplate) {
12895 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(ErrorBoundaryWarning, {
12896 message: (0,external_wp_i18n_namespaceObject.__)('The editor is unable to find a block template for the homepage.'),
12897 dashboardLink: "index.php"
12898 }), target);
12899 return;
12900 } // This will be a no-op if the target doesn't have any React nodes.
12901
12902
12903 (0,external_wp_element_namespaceObject.unmountComponentAtNode)(target);
12904 const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
12905 // so that we won't trigger unnecessary re-renders with useEffect.
12906
12907 {
12908 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/edit-site', {
12909 editorMode: 'visual',
12910 fixedToolbar: false,
12911 focusMode: false,
12912 keepCaretInsideBlock: false,
12913 welcomeGuide: true,
12914 welcomeGuideStyles: true
12915 });
12916 (0,external_wp_data_namespaceObject.dispatch)(store_store).updateSettings(settings); // Keep the defaultTemplateTypes in the core/editor settings too,
12917 // so that they can be selected with core/editor selectors in any editor.
12918 // This is needed because edit-site doesn't initialize with EditorProvider,
12919 // which internally uses updateEditorSettings as well.
12920
12921 (0,external_wp_data_namespaceObject.dispatch)(external_wp_editor_namespaceObject.store).updateEditorSettings({
12922 defaultTemplateTypes: settings.defaultTemplateTypes,
12923 defaultTemplatePartAreas: settings.defaultTemplatePartAreas
12924 });
12925 const isLandingOnListPage = getIsListPage((0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href));
12926
12927 if (isLandingOnListPage) {
12928 // Default the navigation panel to be opened when we're in a bigger
12929 // screen and land in the list screen.
12930 (0,external_wp_data_namespaceObject.dispatch)(store_store).setIsNavigationPanelOpened((0,external_wp_data_namespaceObject.select)(external_wp_viewport_namespaceObject.store).isViewportMatch('medium'));
12931 }
12932 }
12933 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(EditSiteApp, {
12934 reboot: reboot
12935 }), target);
12936 }
12937 /**
12938 * Initializes the site editor screen.
12939 *
12940 * @param {string} id ID of the root element to render the screen in.
12941 * @param {Object} settings Editor settings.
12942 */
12943
12944 function initializeEditor(id, settings) {
12945 settings.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings);
12946
12947 settings.__experimentalFetchRichUrlData = external_wp_coreData_namespaceObject.__experimentalFetchUrlData;
12948 settings.__experimentalSpotlightEntityBlocks = ['core/template-part'];
12949 const target = document.getElementById(id);
12950
12951 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters();
12952
12953 (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)();
12954
12955 if (true) {
12956 (0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)({
12957 enableFSEBlocks: true
12958 });
12959 }
12960
12961 reinitializeEditor(target, settings);
12962 }
12963
12964
12965
12966
12967
12968
12969 }();
12970 (window.wp = window.wp || {}).editSite = __webpack_exports__;
12971 /******/ })()
12972 ;