diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:57:26 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:57:26 +0000 |
commit | 30883c26bdceb9eaf32c8d4a1b0c1bce223b5226 (patch) | |
tree | 39a02e2aeb21ab5b7923c6f5757d66d55b708912 /wp-includes/js/dist/edit-site.js | |
parent | Adding upstream version 6.4.3+dfsg1. (diff) | |
download | wordpress-30883c26bdceb9eaf32c8d4a1b0c1bce223b5226.tar.xz wordpress-30883c26bdceb9eaf32c8d4a1b0c1bce223b5226.zip |
Adding upstream version 6.5+dfsg1.upstream/6.5+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/js/dist/edit-site.js')
-rw-r--r-- | wp-includes/js/dist/edit-site.js | 27751 |
1 files changed, 17981 insertions, 9770 deletions
diff --git a/wp-includes/js/dist/edit-site.js b/wp-includes/js/dist/edit-site.js index c41668f..2e302dd 100644 --- a/wp-includes/js/dist/edit-site.js +++ b/wp-includes/js/dist/edit-site.js @@ -1,8 +1,8 @@ -/******/ (function() { // webpackBootstrap +/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 2591: -/***/ (function(module) { +/***/ 4660: +/***/ ((module) => { /* eslint eslint-comments/no-unlimited-disable: 0 */ /* eslint-disable */ @@ -4076,8 +4076,8 @@ /***/ }), -/***/ 5723: -/***/ (function(module) { +/***/ 8572: +/***/ ((module) => { /* eslint eslint-comments/no-unlimited-disable: 0 */ /* eslint-disable */ @@ -6748,7 +6748,7 @@ /***/ }), -/***/ 6411: +/***/ 4306: /***/ (function(module, exports) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @@ -7037,8 +7037,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /***/ }), -/***/ 4403: -/***/ (function(module, exports) { +/***/ 5755: +/***/ ((module, exports) => { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! Copyright (c) 2018 Jed Watson. @@ -7103,8 +7103,8 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! /***/ }), -/***/ 4827: -/***/ (function(module) { +/***/ 6109: +/***/ ((module) => { // This code has been refactored for 140 bytes // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js @@ -7137,8 +7137,8 @@ module.exports = computedStyle; /***/ }), -/***/ 1919: -/***/ (function(module) { +/***/ 66: +/***/ ((module) => { "use strict"; @@ -7278,180 +7278,11 @@ module.exports = deepmerge_1; /***/ }), -/***/ 8981: -/***/ (function(module, exports) { - -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 -// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime -// v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs -// 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. -// v4 adds AMD/UMD, commonJS, and plain browser support -// v4.1 adds url download capability via solo URL argument (same domain/CORS only) -// v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors -// https://github.com/rndme/download - -(function (root, factory) { - if (true) { - // AMD. Register as an anonymous module. - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), - __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? - (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}(this, function () { - - return function download(data, strFileName, strMimeType) { - - var self = window, // this script is only for browsers anyway... - defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads - mimeType = strMimeType || defaultMime, - payload = data, - url = !strFileName && !strMimeType && payload, - anchor = document.createElement("a"), - toString = function(a){return String(a);}, - myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString), - fileName = strFileName || "download", - blob, - reader; - myBlob= myBlob.call ? myBlob.bind(self) : Blob ; - - if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback - payload=[payload, mimeType]; - mimeType=payload[0]; - payload=payload[1]; - } - - - if(url && url.length< 2048){ // if no filename and no mime, assume a url was passed as the only argument - fileName = url.split("/").pop().split("?")[0]; - anchor.href = url; // assign href prop to temp anchor - if(anchor.href.indexOf(url) !== -1){ // if the browser determines that it's a potentially valid url path: - var ajax=new XMLHttpRequest(); - ajax.open( "GET", url, true); - ajax.responseType = 'blob'; - ajax.onload= function(e){ - download(e.target.response, fileName, defaultMime); - }; - setTimeout(function(){ ajax.send();}, 0); // allows setting custom ajax headers using the return: - return ajax; - } // end if valid url? - } // end if url? - - - //go ahead and download dataURLs right away - if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)){ - - if(payload.length > (1024*1024*1.999) && myBlob !== toString ){ - payload=dataUrlToBlob(payload); - mimeType=payload.type || defaultMime; - }else{ - return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs: - navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : - saver(payload) ; // everyone else can save dataURLs un-processed - } - - }else{//not data url, is it a string with special needs? - if(/([\x80-\xff])/.test(payload)){ - var i=0, tempUiArr= new Uint8Array(payload.length), mx=tempUiArr.length; - for(i;i<mx;++i) tempUiArr[i]= payload.charCodeAt(i); - payload=new myBlob([tempUiArr], {type: mimeType}); - } - } - blob = payload instanceof myBlob ? - payload : - new myBlob([payload], {type: mimeType}) ; - - - function dataUrlToBlob(strUrl) { - var parts= strUrl.split(/[:;,]/), - type= parts[1], - decoder= parts[2] == "base64" ? atob : decodeURIComponent, - binData= decoder( parts.pop() ), - mx= binData.length, - i= 0, - uiArr= new Uint8Array(mx); - - for(i;i<mx;++i) uiArr[i]= binData.charCodeAt(i); - - return new myBlob([uiArr], {type: type}); - } - - function saver(url, winMode){ - - if ('download' in anchor) { //html5 A[download] - anchor.href = url; - anchor.setAttribute("download", fileName); - anchor.className = "download-js-link"; - anchor.innerHTML = "downloading..."; - anchor.style.display = "none"; - document.body.appendChild(anchor); - setTimeout(function() { - anchor.click(); - document.body.removeChild(anchor); - if(winMode===true){setTimeout(function(){ self.URL.revokeObjectURL(anchor.href);}, 250 );} - }, 66); - return true; - } - - // handle non-a[download] safari as best we can: - if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) { - if(/^data:/.test(url)) url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime); - if(!window.open(url)){ // popup blocked, offer direct download: - if(confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")){ location.href=url; } - } - return true; - } - - //do iframe dataURL download (old ch+FF): - var f = document.createElement("iframe"); - document.body.appendChild(f); - - if(!winMode && /^data:/.test(url)){ // force a mime that will download: - url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime); - } - f.src=url; - setTimeout(function(){ document.body.removeChild(f); }, 333); - - }//end saver - - - - - if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL) - return navigator.msSaveBlob(blob, fileName); - } - - if(self.URL){ // simple fast and modern way using Blob and URL: - saver(self.URL.createObjectURL(blob), true); - }else{ - // handle non-Blob()+non-URL browsers: - if(typeof blob === "string" || blob.constructor===toString ){ - try{ - return saver( "data:" + mimeType + ";base64," + self.btoa(blob) ); - }catch(y){ - return saver( "data:" + mimeType + "," + encodeURIComponent(blob) ); - } - } - - // Blob but not URL support: - reader=new FileReader(); - reader.onload=function(e){ - saver(this.result); - }; - reader.readAsDataURL(blob); - } - return true; - }; /* end download() */ -})); - - -/***/ }), - -/***/ 9894: -/***/ (function(module, __unused_webpack_exports, __webpack_require__) { +/***/ 461: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { // Load in dependencies -var computedStyle = __webpack_require__(4827); +var computedStyle = __webpack_require__(6109); /** * Calculate the `line-height` of a given node @@ -7551,8 +7382,8 @@ module.exports = lineHeight; /***/ }), -/***/ 5372: -/***/ (function(module, __unused_webpack_exports, __webpack_require__) { +/***/ 628: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /** @@ -7564,7 +7395,7 @@ module.exports = lineHeight; -var ReactPropTypesSecret = __webpack_require__(9567); +var ReactPropTypesSecret = __webpack_require__(4067); function emptyFunction() {} function emptyFunctionWithReset() {} @@ -7624,8 +7455,8 @@ module.exports = function() { /***/ }), -/***/ 2652: -/***/ (function(module, __unused_webpack_exports, __webpack_require__) { +/***/ 5826: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Copyright (c) 2013-present, Facebook, Inc. @@ -7637,14 +7468,14 @@ module.exports = function() { if (false) { var throwOnDirectAccess, ReactIs; } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod - module.exports = __webpack_require__(5372)(); + module.exports = __webpack_require__(628)(); } /***/ }), -/***/ 9567: -/***/ (function(module) { +/***/ 4067: +/***/ ((module) => { "use strict"; /** @@ -7663,7 +7494,7 @@ module.exports = ReactPropTypesSecret; /***/ }), -/***/ 5438: +/***/ 4462: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; @@ -7696,10 +7527,10 @@ var __rest = (this && this.__rest) || function (s, e) { return t; }; exports.__esModule = true; -var React = __webpack_require__(9196); -var PropTypes = __webpack_require__(2652); -var autosize = __webpack_require__(6411); -var _getLineHeight = __webpack_require__(9894); +var React = __webpack_require__(1609); +var PropTypes = __webpack_require__(5826); +var autosize = __webpack_require__(4306); +var _getLineHeight = __webpack_require__(461); var getLineHeight = _getLineHeight; var RESIZED = "autosize:resized"; /** @@ -7797,21 +7628,54 @@ exports.TextareaAutosize = React.forwardRef(function (props, ref) { /***/ }), -/***/ 773: -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { +/***/ 4132: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; var __webpack_unused_export__; __webpack_unused_export__ = true; -var TextareaAutosize_1 = __webpack_require__(5438); -exports.Z = TextareaAutosize_1.TextareaAutosize; +var TextareaAutosize_1 = __webpack_require__(4462); +exports.A = TextareaAutosize_1.TextareaAutosize; + + +/***/ }), + +/***/ 3394: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; +var __webpack_unused_export__; +/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var f=__webpack_require__(1609),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0}; +function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__webpack_unused_export__=l;exports.jsx=q;__webpack_unused_export__=q; /***/ }), -/***/ 4793: -/***/ (function(module) { +/***/ 4922: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +if (true) { + module.exports = __webpack_require__(3394); +} else {} + + +/***/ }), + +/***/ 9681: +/***/ ((module) => { var characterMap = { "À": "A", @@ -8298,8 +8162,40 @@ module.exports.remove = removeAccents; /***/ }), -/***/ 9196: -/***/ (function(module) { +/***/ 8477: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; +/** + * @license React + * use-sync-external-store-shim.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var e=__webpack_require__(1609);function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d} +function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u; + + +/***/ }), + +/***/ 422: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +if (true) { + module.exports = __webpack_require__(8477); +} else {} + + +/***/ }), + +/***/ 1609: +/***/ ((module) => { "use strict"; module.exports = window["React"]; @@ -8334,204 +8230,233 @@ module.exports = window["React"]; /******/ /************************************************************************/ /******/ /* webpack/runtime/compat get default export */ -/******/ !function() { +/******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { +/******/ __webpack_require__.n = (module) => { /******/ var getter = module && module.__esModule ? -/******/ function() { return module['default']; } : -/******/ function() { return module; }; +/******/ () => (module['default']) : +/******/ () => (module); /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; -/******/ }(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/create fake namespace object */ +/******/ (() => { +/******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__); +/******/ var leafPrototypes; +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 16: return value when it's Promise-like +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = this(value); +/******/ if(mode & 8) return value; +/******/ if(typeof value === 'object' && value) { +/******/ if((mode & 4) && value.__esModule) return value; +/******/ if((mode & 16) && typeof value.then === 'function') return value; +/******/ } +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ var def = {}; +/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; +/******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { +/******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key]))); +/******/ } +/******/ def['default'] = () => (value); +/******/ __webpack_require__.d(ns, def); +/******/ return ns; +/******/ }; +/******/ })(); /******/ /******/ /* webpack/runtime/define property getters */ -/******/ !function() { +/******/ (() => { /******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = function(exports, definition) { +/******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; -/******/ }(); +/******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ !function() { -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } -/******/ }(); +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ -/******/ !function() { +/******/ (() => { /******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { +/******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; -/******/ }(); +/******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be in strict mode. -!function() { +(() => { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { - PluginMoreMenuItem: function() { return /* reexport */ plugin_more_menu_item; }, - PluginSidebar: function() { return /* reexport */ PluginSidebarEditSite; }, - PluginSidebarMoreMenuItem: function() { return /* reexport */ PluginSidebarMoreMenuItem; }, - PluginTemplateSettingPanel: function() { return /* reexport */ plugin_template_setting_panel; }, - initializeEditor: function() { return /* binding */ initializeEditor; }, - reinitializeEditor: function() { return /* binding */ reinitializeEditor; }, - store: function() { return /* reexport */ store_store; } + PluginMoreMenuItem: () => (/* reexport */ plugin_more_menu_item), + PluginSidebar: () => (/* reexport */ PluginSidebarEditSite), + PluginSidebarMoreMenuItem: () => (/* reexport */ PluginSidebarMoreMenuItem), + PluginTemplateSettingPanel: () => (/* reexport */ plugin_template_setting_panel), + initializeEditor: () => (/* binding */ initializeEditor), + reinitializeEditor: () => (/* binding */ reinitializeEditor), + store: () => (/* reexport */ store_store) }); // NAMESPACE OBJECT: ./node_modules/@wordpress/interface/build-module/store/actions.js var actions_namespaceObject = {}; __webpack_require__.r(actions_namespaceObject); __webpack_require__.d(actions_namespaceObject, { - closeModal: function() { return closeModal; }, - disableComplementaryArea: function() { return disableComplementaryArea; }, - enableComplementaryArea: function() { return enableComplementaryArea; }, - openModal: function() { return openModal; }, - pinItem: function() { return pinItem; }, - setDefaultComplementaryArea: function() { return setDefaultComplementaryArea; }, - setFeatureDefaults: function() { return setFeatureDefaults; }, - setFeatureValue: function() { return setFeatureValue; }, - toggleFeature: function() { return toggleFeature; }, - unpinItem: function() { return unpinItem; } + closeModal: () => (closeModal), + disableComplementaryArea: () => (disableComplementaryArea), + enableComplementaryArea: () => (enableComplementaryArea), + openModal: () => (openModal), + pinItem: () => (pinItem), + setDefaultComplementaryArea: () => (setDefaultComplementaryArea), + setFeatureDefaults: () => (setFeatureDefaults), + setFeatureValue: () => (setFeatureValue), + toggleFeature: () => (toggleFeature), + unpinItem: () => (unpinItem) }); // NAMESPACE OBJECT: ./node_modules/@wordpress/interface/build-module/store/selectors.js var selectors_namespaceObject = {}; __webpack_require__.r(selectors_namespaceObject); __webpack_require__.d(selectors_namespaceObject, { - getActiveComplementaryArea: function() { return getActiveComplementaryArea; }, - isComplementaryAreaLoading: function() { return isComplementaryAreaLoading; }, - isFeatureActive: function() { return isFeatureActive; }, - isItemPinned: function() { return isItemPinned; }, - isModalActive: function() { return isModalActive; } -}); - -// NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/actions.js -var store_actions_namespaceObject = {}; -__webpack_require__.r(store_actions_namespaceObject); -__webpack_require__.d(store_actions_namespaceObject, { - __experimentalSetPreviewDeviceType: function() { return __experimentalSetPreviewDeviceType; }, - addTemplate: function() { return addTemplate; }, - closeGeneralSidebar: function() { return closeGeneralSidebar; }, - openGeneralSidebar: function() { return openGeneralSidebar; }, - openNavigationPanelToMenu: function() { return openNavigationPanelToMenu; }, - removeTemplate: function() { return removeTemplate; }, - revertTemplate: function() { return revertTemplate; }, - setEditedEntity: function() { return setEditedEntity; }, - setEditedPostContext: function() { return setEditedPostContext; }, - setHasPageContentFocus: function() { return setHasPageContentFocus; }, - setHomeTemplateId: function() { return setHomeTemplateId; }, - setIsInserterOpened: function() { return setIsInserterOpened; }, - setIsListViewOpened: function() { return setIsListViewOpened; }, - setIsNavigationPanelOpened: function() { return setIsNavigationPanelOpened; }, - setIsSaveViewOpened: function() { return setIsSaveViewOpened; }, - setNavigationMenu: function() { return setNavigationMenu; }, - setNavigationPanelActiveMenu: function() { return setNavigationPanelActiveMenu; }, - setPage: function() { return setPage; }, - setTemplate: function() { return setTemplate; }, - setTemplatePart: function() { return setTemplatePart; }, - switchEditorMode: function() { return switchEditorMode; }, - toggleDistractionFree: function() { return toggleDistractionFree; }, - toggleFeature: function() { return actions_toggleFeature; }, - updateSettings: function() { return updateSettings; } + getActiveComplementaryArea: () => (getActiveComplementaryArea), + isComplementaryAreaLoading: () => (isComplementaryAreaLoading), + isFeatureActive: () => (isFeatureActive), + isItemPinned: () => (isItemPinned), + isModalActive: () => (isModalActive) }); // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/private-actions.js var private_actions_namespaceObject = {}; __webpack_require__.r(private_actions_namespaceObject); __webpack_require__.d(private_actions_namespaceObject, { - setCanvasMode: function() { return setCanvasMode; }, - setEditorCanvasContainerView: function() { return setEditorCanvasContainerView; }, - setPageContentFocusType: function() { return setPageContentFocusType; } + removeTemplates: () => (removeTemplates), + setCanvasMode: () => (setCanvasMode), + setEditorCanvasContainerView: () => (setEditorCanvasContainerView) +}); + +// NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/actions.js +var store_actions_namespaceObject = {}; +__webpack_require__.r(store_actions_namespaceObject); +__webpack_require__.d(store_actions_namespaceObject, { + __experimentalSetPreviewDeviceType: () => (__experimentalSetPreviewDeviceType), + addTemplate: () => (addTemplate), + closeGeneralSidebar: () => (closeGeneralSidebar), + openGeneralSidebar: () => (openGeneralSidebar), + openNavigationPanelToMenu: () => (openNavigationPanelToMenu), + removeTemplate: () => (removeTemplate), + revertTemplate: () => (revertTemplate), + setEditedEntity: () => (setEditedEntity), + setEditedPostContext: () => (setEditedPostContext), + setHasPageContentFocus: () => (setHasPageContentFocus), + setHomeTemplateId: () => (setHomeTemplateId), + setIsInserterOpened: () => (setIsInserterOpened), + setIsListViewOpened: () => (setIsListViewOpened), + setIsNavigationPanelOpened: () => (setIsNavigationPanelOpened), + setIsSaveViewOpened: () => (setIsSaveViewOpened), + setNavigationMenu: () => (setNavigationMenu), + setNavigationPanelActiveMenu: () => (setNavigationPanelActiveMenu), + setPage: () => (setPage), + setTemplate: () => (setTemplate), + setTemplatePart: () => (setTemplatePart), + switchEditorMode: () => (switchEditorMode), + toggleDistractionFree: () => (toggleDistractionFree), + toggleFeature: () => (actions_toggleFeature), + updateSettings: () => (updateSettings) }); // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/selectors.js var store_selectors_namespaceObject = {}; __webpack_require__.r(store_selectors_namespaceObject); __webpack_require__.d(store_selectors_namespaceObject, { - __experimentalGetInsertionPoint: function() { return __experimentalGetInsertionPoint; }, - __experimentalGetPreviewDeviceType: function() { return __experimentalGetPreviewDeviceType; }, - __unstableGetPreference: function() { return __unstableGetPreference; }, - getCanUserCreateMedia: function() { return getCanUserCreateMedia; }, - getCurrentTemplateNavigationPanelSubMenu: function() { return getCurrentTemplateNavigationPanelSubMenu; }, - getCurrentTemplateTemplateParts: function() { return getCurrentTemplateTemplateParts; }, - getEditedPostContext: function() { return getEditedPostContext; }, - getEditedPostId: function() { return getEditedPostId; }, - getEditedPostType: function() { return getEditedPostType; }, - getEditorMode: function() { return getEditorMode; }, - getHomeTemplateId: function() { return getHomeTemplateId; }, - getNavigationPanelActiveMenu: function() { return getNavigationPanelActiveMenu; }, - getPage: function() { return getPage; }, - getReusableBlocks: function() { return getReusableBlocks; }, - getSettings: function() { return getSettings; }, - hasPageContentFocus: function() { return selectors_hasPageContentFocus; }, - isFeatureActive: function() { return selectors_isFeatureActive; }, - isInserterOpened: function() { return isInserterOpened; }, - isListViewOpened: function() { return isListViewOpened; }, - isNavigationOpened: function() { return isNavigationOpened; }, - isPage: function() { return isPage; }, - isSaveViewOpened: function() { return isSaveViewOpened; } + __experimentalGetInsertionPoint: () => (__experimentalGetInsertionPoint), + __experimentalGetPreviewDeviceType: () => (__experimentalGetPreviewDeviceType), + getCanUserCreateMedia: () => (getCanUserCreateMedia), + getCurrentTemplateNavigationPanelSubMenu: () => (getCurrentTemplateNavigationPanelSubMenu), + getCurrentTemplateTemplateParts: () => (getCurrentTemplateTemplateParts), + getEditedPostContext: () => (getEditedPostContext), + getEditedPostId: () => (getEditedPostId), + getEditedPostType: () => (getEditedPostType), + getEditorMode: () => (getEditorMode), + getHomeTemplateId: () => (getHomeTemplateId), + getNavigationPanelActiveMenu: () => (getNavigationPanelActiveMenu), + getPage: () => (getPage), + getReusableBlocks: () => (getReusableBlocks), + getSettings: () => (getSettings), + hasPageContentFocus: () => (hasPageContentFocus), + isFeatureActive: () => (selectors_isFeatureActive), + isInserterOpened: () => (isInserterOpened), + isListViewOpened: () => (isListViewOpened), + isNavigationOpened: () => (isNavigationOpened), + isPage: () => (isPage), + isSaveViewOpened: () => (isSaveViewOpened) }); // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/private-selectors.js var private_selectors_namespaceObject = {}; __webpack_require__.r(private_selectors_namespaceObject); __webpack_require__.d(private_selectors_namespaceObject, { - getCanvasMode: function() { return getCanvasMode; }, - getEditorCanvasContainerView: function() { return getEditorCanvasContainerView; }, - getPageContentFocusType: function() { return getPageContentFocusType; } + getCanvasMode: () => (getCanvasMode), + getEditorCanvasContainerView: () => (getEditorCanvasContainerView) }); -;// CONCATENATED MODULE: external ["wp","element"] -var external_wp_element_namespaceObject = window["wp"]["element"]; +// EXTERNAL MODULE: external "React" +var external_React_ = __webpack_require__(1609); +var external_React_namespaceObject = /*#__PURE__*/__webpack_require__.t(external_React_, 2); ;// CONCATENATED MODULE: external ["wp","blocks"] -var external_wp_blocks_namespaceObject = window["wp"]["blocks"]; +const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; ;// CONCATENATED MODULE: external ["wp","blockLibrary"] -var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"]; +const external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"]; ;// CONCATENATED MODULE: external ["wp","data"] -var external_wp_data_namespaceObject = window["wp"]["data"]; +const external_wp_data_namespaceObject = window["wp"]["data"]; ;// CONCATENATED MODULE: external ["wp","deprecated"] -var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; +const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); -;// CONCATENATED MODULE: external ["wp","coreData"] -var external_wp_coreData_namespaceObject = window["wp"]["coreData"]; +;// CONCATENATED MODULE: external ["wp","element"] +const external_wp_element_namespaceObject = window["wp"]["element"]; ;// CONCATENATED MODULE: external ["wp","editor"] -var external_wp_editor_namespaceObject = window["wp"]["editor"]; +const external_wp_editor_namespaceObject = window["wp"]["editor"]; // EXTERNAL MODULE: ./node_modules/classnames/index.js -var classnames = __webpack_require__(4403); +var classnames = __webpack_require__(5755); var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); ;// CONCATENATED MODULE: external ["wp","components"] -var external_wp_components_namespaceObject = window["wp"]["components"]; +const external_wp_components_namespaceObject = window["wp"]["components"]; ;// CONCATENATED MODULE: external ["wp","i18n"] -var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; +const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; ;// CONCATENATED MODULE: external ["wp","primitives"] -var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; +const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js /** * WordPress dependencies */ -const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const check = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z" })); -/* harmony default export */ var library_check = (check); +/* harmony default export */ const library_check = (check); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-filled.js @@ -8539,13 +8464,13 @@ const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_ * WordPress dependencies */ -const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const starFilled = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var star_filled = (starFilled); +/* harmony default export */ const star_filled = (starFilled); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-empty.js @@ -8553,34 +8478,34 @@ const starFilled = (0,external_wp_element_namespaceObject.createElement)(externa * WordPress dependencies */ -const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const starEmpty = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { fillRule: "evenodd", 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", clipRule: "evenodd" })); -/* harmony default export */ var star_empty = (starEmpty); +/* harmony default export */ const star_empty = (starEmpty); ;// CONCATENATED MODULE: external ["wp","viewport"] -var external_wp_viewport_namespaceObject = window["wp"]["viewport"]; +const external_wp_viewport_namespaceObject = window["wp"]["viewport"]; +;// CONCATENATED MODULE: external ["wp","preferences"] +const external_wp_preferences_namespaceObject = window["wp"]["preferences"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js /** * WordPress dependencies */ -const close_small_closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const closeSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var close_small = (close_small_closeSmall); +/* harmony default export */ const close_small = (closeSmall); -;// CONCATENATED MODULE: external ["wp","preferences"] -var external_wp_preferences_namespaceObject = window["wp"]["preferences"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/actions.js /** * WordPress dependencies @@ -8911,7 +8836,7 @@ function activeModal(state = null, action) { } return state; } -/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ +/* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ complementaryAreas, activeModal })); @@ -8956,13 +8881,13 @@ const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, (0,external_wp_data_namespaceObject.register)(store); ;// CONCATENATED MODULE: external ["wp","plugins"] -var external_wp_plugins_namespaceObject = window["wp"]["plugins"]; +const external_wp_plugins_namespaceObject = window["wp"]["plugins"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-context/index.js /** * WordPress dependencies */ -/* harmony default export */ var complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => { +/* harmony default export */ const complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => { return { icon: ownProps.icon || context.icon, identifier: ownProps.identifier || `${context.name}/${ownProps.name}` @@ -8997,7 +8922,7 @@ function ComplementaryAreaToggle({ enableComplementaryArea, disableComplementaryArea } = (0,external_wp_data_namespaceObject.useDispatch)(store); - return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, { + return (0,external_React_.createElement)(ComponentToUse, { icon: selectedIcon && isSelected ? selectedIcon : icon, "aria-controls": identifier.replace('/', ':'), onClick: () => { @@ -9010,7 +8935,7 @@ function ComplementaryAreaToggle({ ...props }); } -/* harmony default export */ var complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle)); +/* harmony default export */ const complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle)); ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-header/index.js @@ -9034,20 +8959,20 @@ const ComplementaryAreaHeader = ({ className, toggleButtonProps }) => { - const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, { + const toggleButton = (0,external_React_.createElement)(complementary_area_toggle, { icon: close_small, ...toggleButtonProps }); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { className: "components-panel__header interface-complementary-area-header__small" - }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", { + }, smallScreenTitle && (0,external_React_.createElement)("span", { className: "interface-complementary-area-header__small-title" - }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", { + }, smallScreenTitle), toggleButton), (0,external_React_.createElement)("div", { className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className), tabIndex: -1 }, children, toggleButton)); }; -/* harmony default export */ var complementary_area_header = (ComplementaryAreaHeader); +/* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader); ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/action-item/index.js @@ -9064,7 +8989,7 @@ function ActionItemSlot({ bubblesVirtually, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Slot, { name: name, bubblesVirtually: bubblesVirtually, fillProps: fillProps @@ -9095,7 +9020,7 @@ function ActionItemSlot({ } return child; }); - return (0,external_wp_element_namespaceObject.createElement)(Component, { + return (0,external_React_.createElement)(Component, { ...props }, children); }); @@ -9106,12 +9031,12 @@ function ActionItem({ onClick, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Fill, { name: name }, ({ onClick: fpOnClick }) => { - return (0,external_wp_element_namespaceObject.createElement)(Component, { + return (0,external_React_.createElement)(Component, { onClick: onClick || fpOnClick ? (...args) => { (onClick || noop)(...args); (fpOnClick || noop)(...args); @@ -9121,7 +9046,7 @@ function ActionItem({ }); } ActionItem.Slot = ActionItemSlot; -/* harmony default export */ var action_item = (ActionItem); +/* harmony default export */ const action_item = (ActionItem); ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-more-menu-item/index.js @@ -9143,7 +9068,7 @@ const PluginsMenuItem = ({ __unstableExplicitMenuItem, __unstableTarget, ...restProps -}) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { +}) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { ...restProps }); function ComplementaryAreaMoreMenuItem({ @@ -9152,9 +9077,9 @@ function ComplementaryAreaMoreMenuItem({ __unstableExplicitMenuItem, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, { + return (0,external_React_.createElement)(complementary_area_toggle, { as: toggleProps => { - return (0,external_wp_element_namespaceObject.createElement)(action_item, { + return (0,external_React_.createElement)(action_item, { __unstableExplicitMenuItem: __unstableExplicitMenuItem, __unstableTarget: `${scope}/${target}`, as: PluginsMenuItem, @@ -9185,7 +9110,7 @@ function PinnedItems({ scope, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Fill, { name: `PinnedItems/${scope}`, ...props }); @@ -9195,15 +9120,15 @@ function PinnedItemsSlot({ className, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Slot, { name: `PinnedItems/${scope}`, ...props - }, fills => fills?.length > 0 && (0,external_wp_element_namespaceObject.createElement)("div", { + }, fills => fills?.length > 0 && (0,external_React_.createElement)("div", { className: classnames_default()(className, 'interface-pinned-items') }, fills)); } PinnedItems.Slot = PinnedItemsSlot; -/* harmony default export */ var pinned_items = (PinnedItems); +/* harmony default export */ const pinned_items = (PinnedItems); ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area/index.js @@ -9222,6 +9147,7 @@ PinnedItems.Slot = PinnedItemsSlot; + /** * Internal dependencies */ @@ -9235,7 +9161,7 @@ function ComplementaryAreaSlot({ scope, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Slot, { name: `ComplementaryArea/${scope}`, ...props }); @@ -9246,9 +9172,9 @@ function ComplementaryAreaFill({ className, id }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Fill, { name: `ComplementaryArea/${scope}` - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { id: id, className: className }, children)); @@ -9304,8 +9230,7 @@ function ComplementaryArea({ smallScreenTitle, title, toggleShortcut, - isActiveByDefault, - showIconLabels = false + isActiveByDefault }) { const { isLoading, @@ -9313,13 +9238,17 @@ function ComplementaryArea({ isPinned, activeArea, isSmall, - isLarge + isLarge, + showIconLabels } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { getActiveComplementaryArea, isComplementaryAreaLoading, isItemPinned } = select(store); + const { + get + } = select(external_wp_preferences_namespaceObject.store); const _activeArea = getActiveComplementaryArea(scope); return { isLoading: isComplementaryAreaLoading(scope), @@ -9327,7 +9256,8 @@ function ComplementaryArea({ isPinned: isItemPinned(scope, identifier), activeArea: _activeArea, isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'), - isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large') + isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large'), + showIconLabels: get('core', 'showIconLabels') }; }, [identifier, scope]); useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall); @@ -9346,9 +9276,9 @@ function ComplementaryArea({ disableComplementaryArea(scope, identifier); } }, [activeArea, isActiveByDefault, scope, identifier, isSmall, enableComplementaryArea, disableComplementaryArea]); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, { + return (0,external_React_.createElement)(external_React_.Fragment, null, isPinnable && (0,external_React_.createElement)(pinned_items, { scope: scope - }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, { + }, isPinned && (0,external_React_.createElement)(complementary_area_toggle, { scope: scope, identifier: identifier, isPressed: isActive && (!showIconLabels || isLarge), @@ -9357,16 +9287,17 @@ function ComplementaryArea({ label: title, icon: showIconLabels ? library_check : icon, showTooltip: !showIconLabels, - variant: showIconLabels ? 'tertiary' : undefined - })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, { + variant: showIconLabels ? 'tertiary' : undefined, + size: "compact" + })), name && isPinnable && (0,external_React_.createElement)(ComplementaryAreaMoreMenuItem, { target: name, scope: scope, icon: icon - }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, { + }, title), isActive && (0,external_React_.createElement)(ComplementaryAreaFill, { className: classnames_default()('interface-complementary-area', className), scope: scope, id: identifier.replace('/', ':') - }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, { + }, (0,external_React_.createElement)(complementary_area_header, { className: headerClassName, closeLabel: closeLabel, onClose: () => disableComplementaryArea(scope), @@ -9377,23 +9308,23 @@ function ComplementaryArea({ scope, identifier } - }, 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, { + }, header || (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("strong", null, title), isPinnable && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { className: "interface-complementary-area__pin-unpin-item", icon: isPinned ? star_filled : star_empty, label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'), onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier), isPressed: isPinned, "aria-expanded": isPinned - }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, { + }))), (0,external_React_.createElement)(external_wp_components_namespaceObject.Panel, { className: panelClassName }, children))); } const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea); ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot; -/* harmony default export */ var complementary_area = (ComplementaryAreaWrapped); +/* harmony default export */ const complementary_area = (ComplementaryAreaWrapped); ;// CONCATENATED MODULE: external ["wp","compose"] -var external_wp_compose_namespaceObject = window["wp"]["compose"]; +const external_wp_compose_namespaceObject = window["wp"]["compose"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/navigable-region/index.js /** @@ -9407,7 +9338,7 @@ function NavigableRegion({ as: Tag = 'div', ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(Tag, { + return (0,external_React_.createElement)(Tag, { className: classnames_default()('interface-navigable-region', className), "aria-label": ariaLabel, role: "region", @@ -9475,7 +9406,6 @@ function InterfaceSkeleton({ secondarySidebar, notices, content, - contentProps, actions, labels, className, @@ -9488,7 +9418,7 @@ function InterfaceSkeleton({ useHTMLClass('interface-interface-skeleton__html-container'); const defaultLabels = { /* translators: accessibility text for the top bar landmark region. */ - header: (0,external_wp_i18n_namespaceObject.__)('Header'), + header: (0,external_wp_i18n_namespaceObject._x)('Header', 'header landmark area'), /* translators: accessibility text for the content landmark region. */ body: (0,external_wp_i18n_namespaceObject.__)('Content'), /* translators: accessibility text for the secondary sidebar landmark region. */ @@ -9504,13 +9434,13 @@ function InterfaceSkeleton({ ...defaultLabels, ...labels }; - return (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)("div", { ...(enableRegionNavigation ? navigateRegionsProps : {}), ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, enableRegionNavigation ? navigateRegionsProps.ref : undefined]), className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer') - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "interface-interface-skeleton__editor" - }, !!header && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + }, !!header && (0,external_React_.createElement)(NavigableRegion, { as: external_wp_components_namespaceObject.__unstableMotion.div, className: "interface-interface-skeleton__header", "aria-label": mergedLabels.header, @@ -9522,31 +9452,30 @@ function InterfaceSkeleton({ type: 'tween', delay: 0.8 } : undefined - }, header), isDistractionFree && (0,external_wp_element_namespaceObject.createElement)("div", { + }, header), isDistractionFree && (0,external_React_.createElement)("div", { className: "interface-interface-skeleton__header" - }, editorNotices), (0,external_wp_element_namespaceObject.createElement)("div", { + }, editorNotices), (0,external_React_.createElement)("div", { className: "interface-interface-skeleton__body" - }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + }, !!secondarySidebar && (0,external_React_.createElement)(NavigableRegion, { className: "interface-interface-skeleton__secondary-sidebar", ariaLabel: mergedLabels.secondarySidebar - }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", { + }, secondarySidebar), !!notices && (0,external_React_.createElement)("div", { className: "interface-interface-skeleton__notices" - }, notices), (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + }, notices), (0,external_React_.createElement)(NavigableRegion, { className: "interface-interface-skeleton__content", - ariaLabel: mergedLabels.body, - ...contentProps - }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + ariaLabel: mergedLabels.body + }, content), !!sidebar && (0,external_React_.createElement)(NavigableRegion, { className: "interface-interface-skeleton__sidebar", ariaLabel: mergedLabels.sidebar - }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + }, sidebar), !!actions && (0,external_React_.createElement)(NavigableRegion, { className: "interface-interface-skeleton__actions", ariaLabel: mergedLabels.actions - }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + }, actions))), !!footer && (0,external_React_.createElement)(NavigableRegion, { className: "interface-interface-skeleton__footer", ariaLabel: mergedLabels.footer }, footer)); } -/* harmony default export */ var interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton)); +/* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton)); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js @@ -9554,13 +9483,13 @@ function InterfaceSkeleton({ * WordPress dependencies */ -const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const moreVertical = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" })); -/* harmony default export */ var more_vertical = (moreVertical); +/* harmony default export */ const more_vertical = (moreVertical); ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/more-menu-dropdown/index.js @@ -9584,7 +9513,7 @@ function MoreMenuDropdown({ toggleProps, children }) { - return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, { + return (0,external_React_.createElement)(DropdownComponent, { className: classnames_default()('interface-more-menu-dropdown', className), icon: more_vertical, label: label, @@ -9595,236 +9524,12 @@ function MoreMenuDropdown({ }, toggleProps: { tooltipPosition: 'bottom', - ...toggleProps + ...toggleProps, + size: 'compact' } }, onClose => children(onClose)); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/preferences-modal/index.js - -/** - * WordPress dependencies - */ - - -function PreferencesModal({ - closeModal, - children -}) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { - className: "interface-preferences-modal", - title: (0,external_wp_i18n_namespaceObject.__)('Preferences'), - onRequestClose: closeModal - }, children); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js -/** - * WordPress dependencies - */ - - -/** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ - -/** - * Return an SVG icon. - * - * @param {IconProps} props icon is the SVG component to render - * size is a number specifiying the icon size in pixels - * Other props will be passed to wrapped SVG component - * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element. - * - * @return {JSX.Element} Icon component - */ -function icon_Icon({ - icon, - size = 24, - ...props -}, ref) { - return (0,external_wp_element_namespaceObject.cloneElement)(icon, { - width: size, - height: size, - ...props, - ref - }); -} -/* harmony default export */ var build_module_icon = ((0,external_wp_element_namespaceObject.forwardRef)(icon_Icon)); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js - -/** - * WordPress dependencies - */ - -const chevron_left_chevronLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" -})); -/* harmony default export */ var chevron_left = (chevron_left_chevronLeft); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js - -/** - * WordPress dependencies - */ - -const chevron_right_chevronRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" -})); -/* harmony default export */ var chevron_right = (chevron_right_chevronRight); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/preferences-modal-tabs/index.js - -/** - * WordPress dependencies - */ - - - - - -const PREFERENCES_MENU = 'preferences-menu'; -function PreferencesModalTabs({ - sections -}) { - const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); - - // This is also used to sync the two different rendered components - // between small and large viewports. - const [activeMenu, setActiveMenu] = (0,external_wp_element_namespaceObject.useState)(PREFERENCES_MENU); - /** - * Create helper objects from `sections` for easier data handling. - * `tabs` is used for creating the `TabPanel` and `sectionsContentMap` - * is used for easier access to active tab's content. - */ - const { - tabs, - sectionsContentMap - } = (0,external_wp_element_namespaceObject.useMemo)(() => { - let mappedTabs = { - tabs: [], - sectionsContentMap: {} - }; - if (sections.length) { - mappedTabs = sections.reduce((accumulator, { - name, - tabLabel: title, - content - }) => { - accumulator.tabs.push({ - name, - title - }); - accumulator.sectionsContentMap[name] = content; - return accumulator; - }, { - tabs: [], - sectionsContentMap: {} - }); - } - return mappedTabs; - }, [sections]); - const getCurrentTab = (0,external_wp_element_namespaceObject.useCallback)(tab => sectionsContentMap[tab.name] || null, [sectionsContentMap]); - let modalContent; - // We render different components based on the viewport size. - if (isLargeViewport) { - modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, { - className: "interface-preferences__tabs", - tabs: tabs, - initialTabName: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined, - onSelect: setActiveMenu, - orientation: "vertical" - }, getCurrentTab); - } else { - modalContent = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { - initialPath: "/", - className: "interface-preferences__provider" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { - path: "/" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, { - isBorderless: true, - size: "small" - }, (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 => { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { - key: tab.name, - path: tab.name, - as: external_wp_components_namespaceObject.__experimentalItem, - isAction: true - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - justify: "space-between" - }, (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)(build_module_icon, { - icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right - })))); - }))))), sections.length && sections.map(section => { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { - key: `${section.name}-menu`, - path: section.name - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, { - isBorderless: true, - size: "large" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardHeader, { - isBorderless: false, - justify: "left", - size: "small", - gap: "6" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorBackButton, { - icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left, - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - size: "16" - }, section.tabLabel)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, section.content))); - })); - } - return modalContent; -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/preferences-modal-section/index.js - -const Section = ({ - description, - title, - children -}) => (0,external_wp_element_namespaceObject.createElement)("fieldset", { - className: "interface-preferences-modal__section" -}, (0,external_wp_element_namespaceObject.createElement)("legend", { - className: "interface-preferences-modal__section-legend" -}, (0,external_wp_element_namespaceObject.createElement)("h2", { - className: "interface-preferences-modal__section-title" -}, title), description && (0,external_wp_element_namespaceObject.createElement)("p", { - className: "interface-preferences-modal__section-description" -}, description)), children); -/* harmony default export */ var preferences_modal_section = (Section); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/preferences-modal-base-option/index.js - -/** - * WordPress dependencies - */ - -function BaseOption({ - help, - label, - isChecked, - onChange, - children -}) { - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: "interface-preferences-modal__option" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { - __nextHasNoMarginBottom: true, - help: help, - label: label, - checked: isChecked, - onChange: onChange - }), children); -} -/* harmony default export */ var preferences_modal_base_option = (BaseOption); - ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/index.js @@ -9836,20 +9541,16 @@ function BaseOption({ - - - - ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/index.js ;// CONCATENATED MODULE: external ["wp","widgets"] -var external_wp_widgets_namespaceObject = window["wp"]["widgets"]; +const external_wp_widgets_namespaceObject = window["wp"]["widgets"]; ;// CONCATENATED MODULE: external ["wp","hooks"] -var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; +const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; ;// CONCATENATED MODULE: external ["wp","mediaUtils"] -var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"]; +const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/components.js /** * WordPress dependencies @@ -9859,9 +9560,11 @@ var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"]; (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-site/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload); ;// CONCATENATED MODULE: external ["wp","blockEditor"] -var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; +const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; ;// CONCATENATED MODULE: external ["wp","notices"] -var external_wp_notices_namespaceObject = window["wp"]["notices"]; +const external_wp_notices_namespaceObject = window["wp"]["notices"]; +;// CONCATENATED MODULE: external ["wp","coreData"] +const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,colord_p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||colord_p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; @@ -9869,7 +9572,7 @@ var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeo var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}} ;// CONCATENATED MODULE: external ["wp","privateApis"] -var external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; +const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/lock-unlock.js /** * WordPress dependencies @@ -9970,6 +9673,7 @@ function useSupportedStyles(name, element) { + /** * Internal dependencies */ @@ -10283,32 +9987,40 @@ function PushChangesToGlobalStylesControl({ }); } }, [__unstableMarkNextChangeAsNotPersistent, attributes, changes, createSuccessNotice, name, setAttributes, setUserConfig, userConfig]); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.BaseControl, { className: "edit-site-push-changes-to-global-styles-control", help: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Title of the block e.g. 'Heading'. (0,external_wp_i18n_namespaceObject.__)('Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'), (0,external_wp_blocks_namespaceObject.getBlockType)(name).title) - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, null, (0,external_wp_i18n_namespaceObject.__)('Styles')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, null, (0,external_wp_i18n_namespaceObject.__)('Styles')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", disabled: changes.length === 0, onClick: pushChanges }, (0,external_wp_i18n_namespaceObject.__)('Apply globally'))); } -const withPushChangesToGlobalStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { +function PushChangesToGlobalStyles(props) { const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)(); + const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, []); const supportsStyles = SUPPORTED_STYLES.some(feature => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, feature)); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, { - ...props - }), blockEditingMode === 'default' && supportsStyles && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, null, (0,external_wp_element_namespaceObject.createElement)(PushChangesToGlobalStylesControl, { + const isDisplayed = blockEditingMode === 'default' && supportsStyles && isBlockBasedTheme; + if (!isDisplayed) { + return null; + } + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, null, (0,external_React_.createElement)(PushChangesToGlobalStylesControl, { ...props - }))); -}); + })); +} +const withPushChangesToGlobalStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(BlockEdit, { + ...props +}), props.isSelected && (0,external_React_.createElement)(PushChangesToGlobalStyles, { + ...props +}))); (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-site/push-changes-to-global-styles', withPushChangesToGlobalStyles); ;// CONCATENATED MODULE: external ["wp","router"] -var external_wp_router_namespaceObject = window["wp"]["router"]; +const external_wp_router_namespaceObject = window["wp"]["router"]; ;// CONCATENATED MODULE: external ["wp","url"] -var external_wp_url_namespaceObject = window["wp"]["url"]; +const external_wp_url_namespaceObject = window["wp"]["url"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/is-previewing-theme.js /** * WordPress dependencies @@ -10340,10 +10052,10 @@ function currentlyPreviewingTheme() { const { useHistory } = unlock(external_wp_router_namespaceObject.privateApis); -function useLink(params = {}, state, shouldReplace = false) { +function useLink(params, state, shouldReplace = false) { const history = useHistory(); function onClick(event) { - event.preventDefault(); + event?.preventDefault(); if (shouldReplace) { history.replace(params, state); } else { @@ -10375,7 +10087,7 @@ function Link({ href, onClick } = useLink(params, state, shouldReplace); - return (0,external_wp_element_namespaceObject.createElement)("a", { + return (0,external_React_.createElement)("a", { href: href, onClick: onClick, ...props @@ -10383,7 +10095,7 @@ function Link({ } ;// CONCATENATED MODULE: external ["wp","patterns"] -var external_wp_patterns_namespaceObject = window["wp"]["patterns"]; +const external_wp_patterns_namespaceObject = window["wp"]["patterns"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/constants.js /** * WordPress dependencies @@ -10400,7 +10112,7 @@ var external_wp_patterns_namespaceObject = window["wp"]["patterns"]; const NAVIGATION_POST_TYPE = 'wp_navigation'; // Templates. -const TEMPLATE_POST_TYPE = 'wp_template'; +const constants_TEMPLATE_POST_TYPE = 'wp_template'; const TEMPLATE_PART_POST_TYPE = 'wp_template_part'; const TEMPLATE_ORIGINS = { custom: 'custom', @@ -10414,29 +10126,27 @@ const { PATTERN_TYPES, PATTERN_DEFAULT_CATEGORY, PATTERN_USER_CATEGORY, - PATTERN_CORE_SOURCES, + EXCLUDED_PATTERN_SOURCES, PATTERN_SYNC_TYPES } = unlock(external_wp_patterns_namespaceObject.privateApis); // Entities that are editable in focus mode. const FOCUSABLE_ENTITIES = [TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, PATTERN_TYPES.user]; - -/** - * Block types that are considered to be page content. These are the only blocks - * editable when hasPageContentFocus() is true. - */ -const PAGE_CONTENT_BLOCK_TYPES = { - 'core/post-title': true, - 'core/post-featured-image': true, - 'core/post-content': true -}; const POST_TYPE_LABELS = { - [TEMPLATE_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Template'), + [constants_TEMPLATE_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Template'), [TEMPLATE_PART_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Template part'), [PATTERN_TYPES.user]: (0,external_wp_i18n_namespaceObject.__)('Pattern'), [NAVIGATION_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Navigation') }; +// DataViews constants +const LAYOUT_GRID = 'grid'; +const LAYOUT_TABLE = 'table'; +const LAYOUT_LIST = 'list'; +const ENUMERATION_TYPE = 'enumeration'; +const OPERATOR_IN = 'in'; +const OPERATOR_NOT_IN = 'notIn'; + ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/template-part-edit.js /** @@ -10471,28 +10181,30 @@ function EditTemplatePartMenuItem({ params } = useLocation(); const templatePart = (0,external_wp_data_namespaceObject.useSelect)(select => { - return select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', TEMPLATE_PART_POST_TYPE, + const { + getCurrentTheme, + getEntityRecord + } = select(external_wp_coreData_namespaceObject.store); + return getEntityRecord('postType', TEMPLATE_PART_POST_TYPE, // Ideally this should be an official public API. - `${theme}//${slug}`); + `${theme || getCurrentTheme()?.stylesheet}//${slug}`); }, [theme, slug]); const linkProps = useLink({ postId: templatePart?.id, postType: templatePart?.type, canvas: 'edit' }, { - fromTemplateId: params.postId + fromTemplateId: params.postId || templatePart?.id }); if (!templatePart) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, { - group: "other" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarButton, { ...linkProps, onClick: event => { linkProps.onClick(event); } - }, (0,external_wp_i18n_namespaceObject.__)('Edit'))); + }, (0,external_wp_i18n_namespaceObject.__)('Edit')); } const withEditBlockControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { const { @@ -10500,11 +10212,14 @@ const withEditBlockControls = (0,external_wp_compose_namespaceObject.createHighe name } = props; const isDisplayed = name === 'core/template-part' && attributes.slug; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(BlockEdit, { + key: "edit", ...props - }), isDisplayed && (0,external_wp_element_namespaceObject.createElement)(EditTemplatePartMenuItem, { + }), isDisplayed && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, { + group: "other" + }, (0,external_React_.createElement)(EditTemplatePartMenuItem, { attributes: attributes - })); + }))); }, 'withEditBlockControls'); (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-site/template-part-edit-button', withEditBlockControls); @@ -10552,7 +10267,7 @@ function NavigationMenuEdit({ canvas: 'edit' }, { // this applies to Navigation Menus as well. - fromTemplateId: params.postId + fromTemplateId: params.postId || navigationMenu?.id }); // A non-default setting for block editing mode indicates that the @@ -10561,9 +10276,9 @@ function NavigationMenuEdit({ if (!navigationMenu || blockEditingMode !== 'default') { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, { + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, { group: "other" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarButton, { ...linkProps, onClick: event => { linkProps.onClick(event); @@ -10576,9 +10291,9 @@ const navigation_menu_edit_withEditBlockControls = (0,external_wp_compose_namesp name } = props; const isDisplayed = name === 'core/navigation' && attributes.ref; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(BlockEdit, { ...props - }), isDisplayed && (0,external_wp_element_namespaceObject.createElement)(NavigationMenuEdit, { + }), isDisplayed && (0,external_React_.createElement)(NavigationMenuEdit, { attributes: attributes })); }, 'withEditBlockControls'); @@ -10600,22 +10315,6 @@ const navigation_menu_edit_withEditBlockControls = (0,external_wp_compose_namesp /** - * Reducer returning the editing canvas device type. - * - * @param {Object} state Current state. - * @param {Object} action Dispatched action. - * - * @return {Object} Updated state. - */ -function deviceType(state = 'Desktop', action) { - switch (action.type) { - case 'SET_PREVIEW_DEVICE_TYPE': - return action.deviceType; - } - return state; -} - -/** * Reducer returning the settings. * * @param {Object} state Current state. @@ -10661,48 +10360,6 @@ function editedPost(state = {}, action) { } /** - * Reducer to set the block inserter panel open or closed. - * - * Note: this reducer interacts with the navigation and list view panels reducers - * to make sure that only one of the three panels is open at the same time. - * - * @param {boolean|Object} state Current state. - * @param {Object} action Dispatched action. - */ -function blockInserterPanel(state = false, action) { - switch (action.type) { - case 'SET_IS_LIST_VIEW_OPENED': - return action.isOpen ? false : state; - case 'SET_IS_INSERTER_OPENED': - return action.value; - case 'SET_CANVAS_MODE': - return false; - } - return state; -} - -/** - * Reducer to set the list view panel open or closed. - * - * Note: this reducer interacts with the navigation and inserter panels reducers - * to make sure that only one of the three panels is open at the same time. - * - * @param {Object} state Current state. - * @param {Object} action Dispatched action. - */ -function listViewPanel(state = false, action) { - switch (action.type) { - case 'SET_IS_INSERTER_OPENED': - return action.value ? false : state; - case 'SET_IS_LIST_VIEW_OPENED': - return action.isOpen; - case 'SET_CANVAS_MODE': - return false; - } - return state; -} - -/** * Reducer to set the save view panel open or closed. * * @param {Object} state Current state. @@ -10747,61 +10404,19 @@ function editorCanvasContainerView(state = undefined, action) { } return state; } - -/** - * Reducer used to track whether the editor allows only page content to be - * edited. - * - * @param {boolean} state Current state. - * @param {Object} action Dispatched action. - * - * @return {boolean} Updated state. - */ -function hasPageContentFocus(state = false, action) { - switch (action.type) { - case 'SET_EDITED_POST': - return !!action.context?.postId; - case 'SET_HAS_PAGE_CONTENT_FOCUS': - return action.hasPageContentFocus; - } - return state; -} - -/** - * Reducer used to track the type of page content focus. - * - * @param {string} state Current state. - * @param {Object} action Dispatched action. - * - * @return {string} Updated state. - */ -function pageContentFocusType(state = 'disableTemplate', action) { - switch (action.type) { - case 'SET_PAGE_CONTENT_FOCUS_TYPE': - return action.pageContentFocusType; - } - return state; -} -/* harmony default export */ var store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ - deviceType, +/* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ settings, editedPost, - blockInserterPanel, - listViewPanel, saveViewPanel, canvasMode, - editorCanvasContainerView, - hasPageContentFocus, - pageContentFocusType + editorCanvasContainerView })); ;// CONCATENATED MODULE: external ["wp","apiFetch"] -var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; +const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); ;// CONCATENATED MODULE: external ["wp","a11y"] -var external_wp_a11y_namespaceObject = window["wp"]["a11y"]; -;// CONCATENATED MODULE: external ["wp","htmlEntities"] -var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; +const external_wp_a11y_namespaceObject = window["wp"]["a11y"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/constants.js /** * The identifier for the data store. @@ -10831,6 +10446,139 @@ function isTemplateRevertable(template) { /* eslint-enable camelcase */ } +;// CONCATENATED MODULE: external ["wp","htmlEntities"] +const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/private-actions.js +/** + * WordPress dependencies + */ + + + + + + + + +/** + * Internal dependencies + */ + + +/** + * Action that switches the canvas mode. + * + * @param {?string} mode Canvas mode. + */ +const setCanvasMode = mode => ({ + registry, + dispatch +}) => { + const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches; + registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableSetEditorMode('edit'); + dispatch({ + type: 'SET_CANVAS_MODE', + mode + }); + // Check if the block list view should be open by default. + // If `distractionFree` mode is enabled, the block list view should not be open. + // This behavior is disabled for small viewports. + if (isMediumOrBigger && mode === 'edit' && registry.select(external_wp_preferences_namespaceObject.store).get('core', 'showListViewByDefault') && !registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree')) { + registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(true); + } else { + registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(false); + } + registry.dispatch(external_wp_editor_namespaceObject.store).setIsInserterOpened(false); +}; + +/** + * Action that switches the editor canvas container view. + * + * @param {?string} view Editor canvas container view. + */ +const setEditorCanvasContainerView = view => ({ + dispatch +}) => { + dispatch({ + type: 'SET_EDITOR_CANVAS_CONTAINER_VIEW', + view + }); +}; + +/** + * Action that removes an array of templates. + * + * @param {Array} items An array of template or template part objects to remove. + */ +const removeTemplates = items => async ({ + registry +}) => { + const isTemplate = items[0].type === constants_TEMPLATE_POST_TYPE; + const promiseResult = await Promise.allSettled(items.map(item => { + return registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', item.type, item.id, { + force: true + }, { + throwOnError: true + }); + })); + + // If all the promises were fulfilled with sucess. + if (promiseResult.every(({ + status + }) => status === 'fulfilled')) { + let successMessage; + if (items.length === 1) { + // Depending on how the entity was retrieved its title might be + // an object or simple string. + const title = typeof items[0].title === 'string' ? items[0].title : items[0].title?.rendered; + successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */ + (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); + } else { + successMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.__)('Templates deleted.') : (0,external_wp_i18n_namespaceObject.__)('Template parts deleted.'); + } + registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(successMessage, { + type: 'snackbar', + id: 'site-editor-template-deleted-success' + }); + } else { + // If there was at lease one failure. + let errorMessage; + // If we were trying to delete a single template. + if (promiseResult.length === 1) { + if (promiseResult[0].reason?.message) { + errorMessage = promiseResult[0].reason.message; + } else { + errorMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template part.'); + } + // If we were trying to delete a multiple templates + } else { + const errorMessages = new Set(); + const failedPromises = promiseResult.filter(({ + status + }) => status === 'rejected'); + for (const failedPromise of failedPromises) { + if (failedPromise.reason?.message) { + errorMessages.add(failedPromise.reason.message); + } + } + if (errorMessages.size === 0) { + errorMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the templates.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template parts.'); + } else if (errorMessages.size === 1) { + errorMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ + (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the templates: %s'), [...errorMessages][0]) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ + (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template parts: %s'), [...errorMessages][0]); + } else { + errorMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ + (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the templates: %s'), [...errorMessages].join(',')) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ + (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the template parts: %s'), [...errorMessages].join(',')); + } + } + registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } +}; + ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/actions.js /** * WordPress dependencies @@ -10854,6 +10602,8 @@ function isTemplateRevertable(template) { + + /** * Dispatches an action that toggles a feature flag. * @@ -10863,9 +10613,9 @@ function actions_toggleFeature(featureName) { return function ({ registry }) { - external_wp_deprecated_default()("select( 'core/edit-site' ).toggleFeature( featureName )", { + external_wp_deprecated_default()("dispatch( 'core/edit-site' ).toggleFeature( featureName )", { since: '6.0', - alternative: "select( 'core/preferences').toggle( 'core/edit-site', featureName )" + alternative: "dispatch( 'core/preferences').toggle( 'core/edit-site', featureName )" }); registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core/edit-site', featureName); }; @@ -10874,58 +10624,60 @@ function actions_toggleFeature(featureName) { /** * Action that changes the width of the editing canvas. * + * @deprecated + * * @param {string} deviceType * * @return {Object} Action object. */ -function __experimentalSetPreviewDeviceType(deviceType) { - return { - type: 'SET_PREVIEW_DEVICE_TYPE', - deviceType - }; -} +const __experimentalSetPreviewDeviceType = deviceType => ({ + registry +}) => { + external_wp_deprecated_default()("dispatch( 'core/edit-site' ).__experimentalSetPreviewDeviceType", { + since: '6.5', + version: '6.7', + hint: 'registry.dispatch( editorStore ).setDeviceType' + }); + registry.dispatch(external_wp_editor_namespaceObject.store).setDeviceType(deviceType); +}; /** * Action that sets a template, optionally fetching it from REST API. * - * @param {number} templateId The template ID. - * @param {string} templateSlug The template slug. * @return {Object} Action object. */ -const setTemplate = (templateId, templateSlug) => async ({ - dispatch, - registry -}) => { - if (!templateSlug) { - try { - const template = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId); - templateSlug = template?.slug; - } catch (error) {} - } - dispatch({ - type: 'SET_EDITED_POST', - postType: TEMPLATE_POST_TYPE, - id: templateId, - context: { - templateSlug - } +function setTemplate() { + external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setTemplate", { + since: '6.5', + version: '6.8', + hint: 'The setTemplate is not needed anymore, the correct entity is resolved from the URL automatically.' }); -}; + return { + type: 'NOTHING' + }; +} /** * Action that adds a new template and sets it as the current template. * * @param {Object} template The template. * + * @deprecated + * * @return {Object} Action object used to set the current template. */ const addTemplate = template => async ({ dispatch, registry }) => { - const newTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', TEMPLATE_POST_TYPE, template); + external_wp_deprecated_default()("dispatch( 'core/edit-site' ).addTemplate", { + since: '6.5', + version: '6.8', + hint: 'use saveEntityRecord directly' + }); + const newTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', constants_TEMPLATE_POST_TYPE, template); if (template.content) { - registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', TEMPLATE_POST_TYPE, newTemplate.id, { + registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', constants_TEMPLATE_POST_TYPE, newTemplate.id, { blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content) }, { undoIgnore: true @@ -10933,11 +10685,8 @@ const addTemplate = template => async ({ } dispatch({ type: 'SET_EDITED_POST', - postType: TEMPLATE_POST_TYPE, - id: newTemplate.id, - context: { - templateSlug: newTemplate.slug - } + postType: constants_TEMPLATE_POST_TYPE, + id: newTemplate.id }); }; @@ -10946,32 +10695,8 @@ const addTemplate = template => async ({ * * @param {Object} template The template object. */ -const removeTemplate = template => async ({ - registry -}) => { - try { - await registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', template.type, template.id, { - force: true - }); - const lastError = registry.select(external_wp_coreData_namespaceObject.store).getLastEntityDeleteError('postType', template.type, template.id); - if (lastError) { - throw lastError; - } - - // Depending on how the entity was retrieved it's title might be - // an object or simple string. - const templateTitle = typeof template.title === 'string' ? template.title : template.title?.rendered; - registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */ - (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(templateTitle)), { - type: 'snackbar', - id: 'site-editor-template-deleted-success' - }); - } catch (error) { - const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template.'); - registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, { - type: 'snackbar' - }); - } +const removeTemplate = template => { + return removeTemplates([template]); }; /** @@ -11009,14 +10734,16 @@ function setNavigationMenu(navigationMenuId) { * * @param {string} postType The entity's post type. * @param {string} postId The entity's ID. + * @param {Object} context The entity's context. * * @return {Object} Action object. */ -function setEditedEntity(postType, postId) { +function setEditedEntity(postType, postId, context) { return { type: 'SET_EDITED_POST', postType, - id: postId + id: postId, + context }; } @@ -11051,61 +10778,20 @@ function setEditedPostContext(context) { * Resolves the template for a page and displays both. If no path is given, attempts * to use the postId to generate a path like `?p=${ postId }`. * - * @param {Object} page The page object. - * @param {string} page.type The page type. - * @param {string} page.slug The page slug. - * @param {string} page.path The page path. - * @param {Object} page.context The page context. + * @deprecated * * @return {number} The resolved template ID for the page route. */ -const setPage = page => async ({ - dispatch, - registry -}) => { - let template; - const getDefaultTemplate = async slug => external_wp_apiFetch_default()({ - path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/templates/lookup', { - slug: `page-${slug}` - }) +function setPage() { + external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setPage", { + since: '6.5', + version: '6.8', + hint: 'The setPage is not needed anymore, the correct entity is resolved from the URL automatically.' }); - if (page.path) { - template = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).__experimentalGetTemplateForLink(page.path); - } else { - const editedEntity = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', page.context?.postType || 'post', page.context?.postId); - const currentTemplateSlug = editedEntity?.template; - if (currentTemplateSlug) { - const currentTemplate = (await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_POST_TYPE, { - per_page: -1 - }))?.find(({ - slug - }) => slug === currentTemplateSlug); - if (currentTemplate) { - template = currentTemplate; - } else { - // If a page has a `template` set and is not included in the list - // of the current theme's templates, query for current theme's default template. - template = await getDefaultTemplate(editedEntity?.slug); - } - } else { - // Page's `template` is empty, that indicates we need to use the default template for the page. - template = await getDefaultTemplate(editedEntity?.slug); - } - } - if (!template) { - return; - } - dispatch({ - type: 'SET_EDITED_POST', - postType: TEMPLATE_POST_TYPE, - id: template.id, - context: { - ...page.context, - templateSlug: template.slug - } - }); - return template.id; -}; + return { + type: 'NOTHING' + }; +} /** * Action that sets the active navigation panel menu. @@ -11155,23 +10841,38 @@ function setIsNavigationPanelOpened() { } /** - * Opens or closes the inserter. + * Returns an action object used to open/close the inserter. * - * @param {boolean|Object} value Whether the inserter should be - * opened (true) or closed (false). - * To specify an insertion point, - * use an object. - * @param {string} value.rootClientId The root client ID to insert at. - * @param {number} value.insertionIndex The index to insert at. + * @deprecated * - * @return {Object} Action object. + * @param {boolean|Object} value Whether the inserter should be opened (true) or closed (false). */ -function setIsInserterOpened(value) { - return { - type: 'SET_IS_INSERTER_OPENED', - value - }; -} +const setIsInserterOpened = value => ({ + registry +}) => { + external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setIsInserterOpened", { + since: '6.5', + alternative: "dispatch( 'core/editor').setIsInserterOpened" + }); + registry.dispatch(external_wp_editor_namespaceObject.store).setIsInserterOpened(value); +}; + +/** + * Returns an action object used to open/close the list view. + * + * @deprecated + * + * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed. + */ +const setIsListViewOpened = isOpen => ({ + registry +}) => { + external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setIsListViewOpened", { + since: '6.5', + alternative: "dispatch( 'core/editor').setIsListViewOpened" + }); + registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(isOpen); +}; /** * Returns an action object used to update the settings. @@ -11188,26 +10889,6 @@ function updateSettings(settings) { } /** - * Sets whether the list view panel should be open. - * - * @param {boolean} isOpen If true, opens the list view. If false, closes it. - * It does not toggle the state, but sets it directly. - */ -const setIsListViewOpened = isOpen => ({ - dispatch, - registry -}) => { - const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'distractionFree'); - if (isDistractionFree && isOpen) { - dispatch.toggleDistractionFree(); - } - dispatch({ - type: 'SET_IS_LIST_VIEW_OPENED', - isOpen - }); -}; - -/** * Sets whether the save view panel should be open. * * @param {boolean} isOpen If true, opens the save view. If false, closes it. @@ -11278,7 +10959,6 @@ const revertTemplate = (template, { }, { undoIgnore: true // Required to merge this edit with the last undo level. }); - const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw); registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, { content: serializeBlocks, @@ -11318,7 +10998,7 @@ const openGeneralSidebar = name => ({ dispatch, registry }) => { - const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'distractionFree'); + const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree'); if (isDistractionFree) { dispatch.toggleDistractionFree(); } @@ -11337,7 +11017,7 @@ const switchEditorMode = mode => ({ dispatch, registry }) => { - registry.dispatch('core/preferences').set('core/edit-site', 'editorMode', mode); + registry.dispatch('core/preferences').set('core', 'editorMode', mode); // Unselect blocks when we switch to a non visual mode. if (mode !== 'visual') { @@ -11346,7 +11026,7 @@ const switchEditorMode = mode => ({ if (mode === 'visual') { (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive'); } else if (mode === 'text') { - const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'distractionFree'); + const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree'); if (isDistractionFree) { dispatch.toggleDistractionFree(); } @@ -11365,6 +11045,9 @@ const setHasPageContentFocus = hasPageContentFocus => ({ dispatch, registry }) => { + external_wp_deprecated_default()(`dispatch( 'core/edit-site' ).setHasPageContentFocus`, { + since: '6.5' + }); if (hasPageContentFocus) { registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock(); } @@ -11383,388 +11066,36 @@ const toggleDistractionFree = () => ({ dispatch, registry }) => { - const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'distractionFree'); + const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree'); + if (isDistractionFree) { + registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', false); + } if (!isDistractionFree) { registry.batch(() => { - registry.dispatch(external_wp_preferences_namespaceObject.store).set('core/edit-site', 'fixedToolbar', false); - dispatch.setIsInserterOpened(false); - dispatch.setIsListViewOpened(false); + registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', true); + registry.dispatch(external_wp_editor_namespaceObject.store).setIsInserterOpened(false); + registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(false); dispatch.closeGeneralSidebar(); }); } registry.batch(() => { - registry.dispatch(external_wp_preferences_namespaceObject.store).set('core/edit-site', 'distractionFree', !isDistractionFree); + registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'distractionFree', !isDistractionFree); registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Distraction free off.') : (0,external_wp_i18n_namespaceObject.__)('Distraction free on.'), { id: 'core/edit-site/distraction-free-mode/notice', - type: 'snackbar' + type: 'snackbar', + actions: [{ + label: (0,external_wp_i18n_namespaceObject.__)('Undo'), + onClick: () => { + registry.batch(() => { + registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', isDistractionFree ? true : false); + registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'distractionFree'); + }); + } + }] }); }); }; -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/private-actions.js -/** - * WordPress dependencies - */ - - - -/** - * Action that switches the canvas mode. - * - * @param {?string} mode Canvas mode. - */ -const setCanvasMode = mode => ({ - registry, - dispatch, - select -}) => { - registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableSetEditorMode('edit'); - dispatch({ - type: 'SET_CANVAS_MODE', - mode - }); - // Check if the block list view should be open by default. - // If `distractionFree` mode is enabled, the block list view should not be open. - if (mode === 'edit' && registry.select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showListViewByDefault') && !registry.select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'distractionFree')) { - dispatch.setIsListViewOpened(true); - } - // Switch focus away from editing the template when switching to view mode. - if (mode === 'view' && select.isPage()) { - dispatch.setHasPageContentFocus(true); - } -}; - -/** - * Action that switches the editor canvas container view. - * - * @param {?string} view Editor canvas container view. - */ -const setEditorCanvasContainerView = view => ({ - dispatch -}) => { - dispatch({ - type: 'SET_EDITOR_CANVAS_CONTAINER_VIEW', - view - }); -}; - -/** - * Sets the type of page content focus. Can be one of: - * - * - `'disableTemplate'`: Disable the blocks belonging to the page's template. - * - `'hideTemplate'`: Hide the blocks belonging to the page's template. - * - * @param {'disableTemplate'|'hideTemplate'} pageContentFocusType The type of page content focus. - * - * @return {Object} Action object. - */ -const setPageContentFocusType = pageContentFocusType => ({ - dispatch -}) => { - dispatch({ - type: 'SET_PAGE_CONTENT_FOCUS_TYPE', - pageContentFocusType - }); -}; - -;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js - - -/** @typedef {(...args: any[]) => *[]} GetDependants */ - -/** @typedef {() => void} Clear */ - -/** - * @typedef {{ - * getDependants: GetDependants, - * clear: Clear - * }} EnhancedSelector - */ - -/** - * Internal cache entry. - * - * @typedef CacheNode - * - * @property {?CacheNode|undefined} [prev] Previous node. - * @property {?CacheNode|undefined} [next] Next node. - * @property {*[]} args Function arguments for cache entry. - * @property {*} val Function result. - */ - -/** - * @typedef Cache - * - * @property {Clear} clear Function to clear cache. - * @property {boolean} [isUniqueByDependants] Whether dependants are valid in - * considering cache uniqueness. A cache is unique if dependents are all arrays - * or objects. - * @property {CacheNode?} [head] Cache head. - * @property {*[]} [lastDependants] Dependants from previous invocation. - */ - -/** - * Arbitrary value used as key for referencing cache object in WeakMap tree. - * - * @type {{}} - */ -var LEAF_KEY = {}; - -/** - * Returns the first argument as the sole entry in an array. - * - * @template T - * - * @param {T} value Value to return. - * - * @return {[T]} Value returned as entry in array. - */ -function arrayOf(value) { - return [value]; -} - -/** - * Returns true if the value passed is object-like, or false otherwise. A value - * is object-like if it can support property assignment, e.g. object or array. - * - * @param {*} value Value to test. - * - * @return {boolean} Whether value is object-like. - */ -function isObjectLike(value) { - return !!value && 'object' === typeof value; -} - -/** - * Creates and returns a new cache object. - * - * @return {Cache} Cache object. - */ -function createCache() { - /** @type {Cache} */ - var cache = { - clear: function () { - cache.head = null; - }, - }; - - return cache; -} - -/** - * Returns true if entries within the two arrays are strictly equal by - * reference from a starting index. - * - * @param {*[]} a First array. - * @param {*[]} b Second array. - * @param {number} fromIndex Index from which to start comparison. - * - * @return {boolean} Whether arrays are shallowly equal. - */ -function isShallowEqual(a, b, fromIndex) { - var i; - - if (a.length !== b.length) { - return false; - } - - for (i = fromIndex; i < a.length; i++) { - if (a[i] !== b[i]) { - return false; - } - } - - return true; -} - -/** - * Returns a memoized selector function. The getDependants function argument is - * called before the memoized selector and is expected to return an immutable - * reference or array of references on which the selector depends for computing - * its own return value. The memoize cache is preserved only as long as those - * dependant references remain the same. If getDependants returns a different - * reference(s), the cache is cleared and the selector value regenerated. - * - * @template {(...args: *[]) => *} S - * - * @param {S} selector Selector function. - * @param {GetDependants=} getDependants Dependant getter returning an array of - * references used in cache bust consideration. - */ -/* harmony default export */ function rememo(selector, getDependants) { - /** @type {WeakMap<*,*>} */ - var rootCache; - - /** @type {GetDependants} */ - var normalizedGetDependants = getDependants ? getDependants : arrayOf; - - /** - * Returns the cache for a given dependants array. When possible, a WeakMap - * will be used to create a unique cache for each set of dependants. This - * is feasible due to the nature of WeakMap in allowing garbage collection - * to occur on entries where the key object is no longer referenced. Since - * WeakMap requires the key to be an object, this is only possible when the - * dependant is object-like. The root cache is created as a hierarchy where - * each top-level key is the first entry in a dependants set, the value a - * WeakMap where each key is the next dependant, and so on. This continues - * so long as the dependants are object-like. If no dependants are object- - * like, then the cache is shared across all invocations. - * - * @see isObjectLike - * - * @param {*[]} dependants Selector dependants. - * - * @return {Cache} Cache object. - */ - function getCache(dependants) { - var caches = rootCache, - isUniqueByDependants = true, - i, - dependant, - map, - cache; - - for (i = 0; i < dependants.length; i++) { - dependant = dependants[i]; - - // Can only compose WeakMap from object-like key. - if (!isObjectLike(dependant)) { - isUniqueByDependants = false; - break; - } - - // Does current segment of cache already have a WeakMap? - if (caches.has(dependant)) { - // Traverse into nested WeakMap. - caches = caches.get(dependant); - } else { - // Create, set, and traverse into a new one. - map = new WeakMap(); - caches.set(dependant, map); - caches = map; - } - } - - // We use an arbitrary (but consistent) object as key for the last item - // in the WeakMap to serve as our running cache. - if (!caches.has(LEAF_KEY)) { - cache = createCache(); - cache.isUniqueByDependants = isUniqueByDependants; - caches.set(LEAF_KEY, cache); - } - - return caches.get(LEAF_KEY); - } - - /** - * Resets root memoization cache. - */ - function clear() { - rootCache = new WeakMap(); - } - - /* eslint-disable jsdoc/check-param-names */ - /** - * The augmented selector call, considering first whether dependants have - * changed before passing it to underlying memoize function. - * - * @param {*} source Source object for derivation. - * @param {...*} extraArgs Additional arguments to pass to selector. - * - * @return {*} Selector result. - */ - /* eslint-enable jsdoc/check-param-names */ - function callSelector(/* source, ...extraArgs */) { - var len = arguments.length, - cache, - node, - i, - args, - dependants; - - // Create copy of arguments (avoid leaking deoptimization). - args = new Array(len); - for (i = 0; i < len; i++) { - args[i] = arguments[i]; - } - - dependants = normalizedGetDependants.apply(null, args); - cache = getCache(dependants); - - // If not guaranteed uniqueness by dependants (primitive type), shallow - // compare against last dependants and, if references have changed, - // destroy cache to recalculate result. - if (!cache.isUniqueByDependants) { - if ( - cache.lastDependants && - !isShallowEqual(dependants, cache.lastDependants, 0) - ) { - cache.clear(); - } - - cache.lastDependants = dependants; - } - - node = cache.head; - while (node) { - // Check whether node arguments match arguments - if (!isShallowEqual(node.args, args, 1)) { - node = node.next; - continue; - } - - // At this point we can assume we've found a match - - // Surface matched node to head if not already - if (node !== cache.head) { - // Adjust siblings to point to each other. - /** @type {CacheNode} */ (node.prev).next = node.next; - if (node.next) { - node.next.prev = node.prev; - } - - node.next = cache.head; - node.prev = null; - /** @type {CacheNode} */ (cache.head).prev = node; - cache.head = node; - } - - // Return immediately - return node.val; - } - - // No cached value found. Continue to insertion phase: - - node = /** @type {CacheNode} */ ({ - // Generate the result from original function - val: selector.apply(null, args), - }); - - // Avoid including the source object in the cache. - args[0] = null; - node.args = args; - - // Don't need to check whether node is already head, since it would - // have been returned above already if it was - - // Shift existing head down list - if (cache.head) { - cache.head.prev = node; - node.next = cache.head; - } - - cache.head = node; - - return node.val; - } - - callSelector.getDependants = normalizedGetDependants; - callSelector.clear = clear; - clear(); - - return /** @type {S & EnhancedSelector} */ (callSelector); -} - ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js /** * Memize options object. @@ -11994,11 +11325,6 @@ const memoizedGetFilteredTemplatePartBlocks = memize(getFilteredTemplatePartBloc ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/selectors.js /** - * External dependencies - */ - - -/** * WordPress dependencies */ @@ -12014,20 +11340,11 @@ const memoizedGetFilteredTemplatePartBlocks = memize(getFilteredTemplatePartBloc */ -/** - * @typedef {'template'|'template_type'} TemplateType Template type. - */ + /** - * Helper for getting a preference from the preferences store. - * - * This is only present so that `getSettings` doesn't need to be made a - * registry selector. - * - * It's unstable because the selector needs to be exported and so part of the - * public API to work. + * @typedef {'template'|'template_type'} TemplateType Template type. */ -const __unstableGetPreference = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, name) => select(external_wp_preferences_namespaceObject.store).get('core/edit-site', name)); /** * Returns whether the given feature is enabled or not. @@ -12038,24 +11355,31 @@ const __unstableGetPreference = (0,external_wp_data_namespaceObject.createRegist * * @return {boolean} Is active. */ -function selectors_isFeatureActive(state, featureName) { +const selectors_isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (_, featureName) => { external_wp_deprecated_default()(`select( 'core/edit-site' ).isFeatureActive`, { since: '6.0', alternative: `select( 'core/preferences' ).get` }); - return !!__unstableGetPreference(state, featureName); -} + return !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', featureName); +}); /** * Returns the current editing canvas device type. * + * @deprecated + * * @param {Object} state Global application state. * * @return {string} Device type. */ -function __experimentalGetPreviewDeviceType(state) { - return state.deviceType; -} +const __experimentalGetPreviewDeviceType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { + external_wp_deprecated_default()(`select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`, { + since: '6.5', + version: '6.7', + alternative: `select( 'core/editor' ).getDeviceType` + }); + return select(external_wp_editor_namespaceObject.store).getDeviceType(); +}); /** * Returns whether the current user can create media or not. @@ -12074,6 +11398,10 @@ const getCanUserCreateMedia = (0,external_wp_data_namespaceObject.createRegistry * @return {Array} The available reusable blocks. */ const getReusableBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { + external_wp_deprecated_default()("select( 'core/core' ).getEntityRecords( 'postType', 'wp_block' )", { + since: '6.5', + version: '6.8' + }); const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web'; return isWeb ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', { per_page: -1 @@ -12081,44 +11409,18 @@ const getReusableBlocks = (0,external_wp_data_namespaceObject.createRegistrySele }); /** - * Returns the settings, taking into account active features and permissions. + * Returns the site editor settings. * - * @param {Object} state Global application state. - * @param {Function} setIsInserterOpen Setter for the open state of the global inserter. + * @param {Object} state Global application state. * * @return {Object} Settings. */ -const getSettings = rememo((state, setIsInserterOpen) => { - const settings = { - ...state.settings, - outlineMode: true, - focusMode: !!__unstableGetPreference(state, 'focusMode'), - isDistractionFree: !!__unstableGetPreference(state, 'distractionFree'), - hasFixedToolbar: !!__unstableGetPreference(state, 'fixedToolbar'), - keepCaretInsideBlock: !!__unstableGetPreference(state, 'keepCaretInsideBlock'), - showIconLabels: !!__unstableGetPreference(state, 'showIconLabels'), - __experimentalSetIsInserterOpened: setIsInserterOpen, - __experimentalReusableBlocks: getReusableBlocks(state), - __experimentalPreferPatternsOnRoot: TEMPLATE_POST_TYPE === getEditedPostType(state) - }; - const canUserCreateMedia = getCanUserCreateMedia(state); - if (!canUserCreateMedia) { - return settings; - } - settings.mediaUpload = ({ - onError, - ...rest - }) => { - (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({ - wpAllowedMimeTypes: state.settings.allowedMimeTypes, - onError: ({ - message - }) => onError(message), - ...rest - }); - }; - return settings; -}, state => [getCanUserCreateMedia(state), state.settings, __unstableGetPreference(state, 'focusMode'), __unstableGetPreference(state, 'distractionFree'), __unstableGetPreference(state, 'fixedToolbar'), __unstableGetPreference(state, 'keepCaretInsideBlock'), __unstableGetPreference(state, 'showIconLabels'), getReusableBlocks(state), getEditedPostType(state)]); +function getSettings(state) { + // It is important that we don't inject anything into these settings locally. + // The reason for this is that we have an effect in place that calls setSettings based on the previous value of getSettings. + // If we add computed settings here, we'll be adding these computed settings to the state which is very unexpected. + return state.settings; +} /** * @deprecated @@ -12179,63 +11481,53 @@ function getPage(state) { } /** - * Returns the current opened/closed state of the inserter panel. + * Returns true if the inserter is opened. + * + * @deprecated * * @param {Object} state Global application state. * - * @return {boolean} True if the inserter panel should be open; false if closed. + * @return {boolean} Whether the inserter is opened. */ -function isInserterOpened(state) { - return !!state.blockInserterPanel; -} +const isInserterOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { + external_wp_deprecated_default()(`select( 'core/edit-site' ).isInserterOpened`, { + since: '6.5', + alternative: `select( 'core/editor' ).isInserterOpened` + }); + return select(external_wp_editor_namespaceObject.store).isInserterOpened(); +}); /** * Get the insertion point for the inserter. * + * @deprecated + * * @param {Object} state Global application state. * * @return {Object} The root client ID, index to insert at and starting filter value. */ -const __experimentalGetInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { - if (typeof state.blockInserterPanel === 'object') { - const { - rootClientId, - insertionIndex, - filterValue - } = state.blockInserterPanel; - return { - rootClientId, - insertionIndex, - filterValue - }; - } - if (selectors_hasPageContentFocus(state)) { - const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).__experimentalGetGlobalBlocksByName('core/post-content'); - if (postContentClientId) { - return { - rootClientId: postContentClientId, - insertionIndex: undefined, - filterValue: undefined - }; - } - } - return { - rootClientId: undefined, - insertionIndex: undefined, - filterValue: undefined - }; +const __experimentalGetInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { + external_wp_deprecated_default()(`select( 'core/edit-site' ).__experimentalGetInsertionPoint`, { + since: '6.5', + version: '6.7' + }); + return unlock(select(external_wp_editor_namespaceObject.store)).getInsertionPoint(); }); /** - * Returns the current opened/closed state of the list view panel. + * Returns true if the list view is opened. * * @param {Object} state Global application state. * - * @return {boolean} True if the list view panel should be open; false if closed. + * @return {boolean} Whether the list view is opened. */ -function isListViewOpened(state) { - return state.listViewPanel; -} +const isListViewOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { + external_wp_deprecated_default()(`select( 'core/edit-site' ).isListViewOpened`, { + since: '6.5', + alternative: `select( 'core/editor' ).isListViewOpened` + }); + return select(external_wp_editor_namespaceObject.store).isListViewOpened(); +}); /** * Returns the current opened/closed state of the save panel. @@ -12258,7 +11550,7 @@ const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.crea const templateParts = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, { per_page: -1 }); - const clientIds = select(external_wp_blockEditor_namespaceObject.store).__experimentalGetGlobalBlocksByName('core/template-part'); + const clientIds = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/template-part'); const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds); return memoizedGetFilteredTemplatePartBlocks(blocks, templateParts); }); @@ -12270,9 +11562,9 @@ const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.crea * * @return {string} Editing mode. */ -function getEditorMode(state) { - return __unstableGetPreference(state, 'editorMode'); -} +const getEditorMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { + return select(external_wp_preferences_namespaceObject.store).get('core', 'editorMode'); +}); /** * @deprecated @@ -12320,21 +11612,19 @@ function isPage(state) { /** * Whether or not the editor allows only page content to be edited. * - * @param {Object} state Global application state. + * @deprecated * * @return {boolean} Whether or not focus is on editing page content. */ -function selectors_hasPageContentFocus(state) { - return isPage(state) ? state.hasPageContentFocus : false; +function hasPageContentFocus() { + external_wp_deprecated_default()(`select( 'core/edit-site' ).hasPageContentFocus`, { + since: '6.5' + }); + return false; } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/private-selectors.js /** - * Internal dependencies - */ - - -/** * Returns the current canvas mode. * * @param {Object} state Global application state. @@ -12356,23 +11646,6 @@ function getEditorCanvasContainerView(state) { return state.editorCanvasContainerView; } -/** - * Returns the type of the current page content focus, or null if there is no - * page content focus. - * - * Possible values are: - * - * - `'disableTemplate'`: Disable the blocks belonging to the page's template. - * - `'hideTemplate'`: Hide the blocks belonging to the page's template. - * - * @param {Object} state Global application state. - * - * @return {'disableTemplate'|'hideTemplate'|null} Type of the current page content focus. - */ -function getPageContentFocusType(state) { - return selectors_hasPageContentFocus(state) ? state.pageContentFocusType : null; -} - ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/index.js /** * WordPress dependencies @@ -12400,24 +11673,24 @@ unlock(store_store).registerPrivateSelectors(private_selectors_namespaceObject); unlock(store_store).registerPrivateActions(private_actions_namespaceObject); ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"] -var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"]; +const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"]; ;// CONCATENATED MODULE: external ["wp","commands"] -var external_wp_commands_namespaceObject = window["wp"]["commands"]; +const external_wp_commands_namespaceObject = window["wp"]["commands"]; ;// CONCATENATED MODULE: external ["wp","coreCommands"] -var external_wp_coreCommands_namespaceObject = window["wp"]["coreCommands"]; +const external_wp_coreCommands_namespaceObject = window["wp"]["coreCommands"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/navigation.js /** * WordPress dependencies */ -const navigation = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const navigation = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_navigation = (navigation); +/* harmony default export */ const library_navigation = (navigation); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/styles.js @@ -12425,13 +11698,13 @@ const navigation = (0,external_wp_element_namespaceObject.createElement)(externa * WordPress dependencies */ -const styles = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const styles = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_styles = (styles); +/* harmony default export */ const library_styles = (styles); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js @@ -12439,13 +11712,15 @@ const styles = (0,external_wp_element_namespaceObject.createElement)(external_wp * WordPress dependencies */ -const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const page = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" +}), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z" })); -/* harmony default export */ var library_page = (page); +/* harmony default export */ const library_page = (page); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js @@ -12453,13 +11728,13 @@ const page = (0,external_wp_element_namespaceObject.createElement)(external_wp_p * WordPress dependencies */ -const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const layout = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_layout = (layout); +/* harmony default export */ const library_layout = (layout); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js @@ -12467,13 +11742,41 @@ const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp * WordPress dependencies */ -const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const symbol = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 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" })); -/* harmony default export */ var library_symbol = (symbol); +/* harmony default export */ const library_symbol = (symbol); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js + +/** + * WordPress dependencies + */ + +const chevronRight = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" +})); +/* harmony default export */ const chevron_right = (chevronRight); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js + +/** + * WordPress dependencies + */ + +const chevronLeft = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" +})); +/* harmony default export */ const chevron_left = (chevronLeft); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-button/index.js @@ -12487,7 +11790,7 @@ const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp */ function SidebarButton(props) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { ...props, className: classnames_default()('edit-site-sidebar-button', props.className) }); @@ -12532,34 +11835,35 @@ function SidebarNavigationScreen({ }) { const { dashboardLink, - dashboardLinkText + dashboardLinkText, + previewingThemeName } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { getSettings } = unlock(select(store_store)); + const currentlyPreviewingThemeId = currentlyPreviewingTheme(); return { dashboardLink: getSettings().__experimentalDashboardLink, - dashboardLinkText: getSettings().__experimentalDashboardLinkText + dashboardLinkText: getSettings().__experimentalDashboardLinkText, + // Do not call `getTheme` with null, it will cause a request to + // the server. + previewingThemeName: currentlyPreviewingThemeId ? select(external_wp_coreData_namespaceObject.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : undefined }; }, []); - const { - getTheme - } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); const location = sidebar_navigation_screen_useLocation(); const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); - const theme = getTheme(currentlyPreviewingTheme()); const icon = (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { className: classnames_default()('edit-site-sidebar-navigation-screen__main', { 'has-footer': !!footer }), spacing: 0, justify: "flex-start" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { spacing: 4, alignment: "flex-start", className: "edit-site-sidebar-navigation-screen__title-icon" - }, !isRoot && (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + }, !isRoot && (0,external_React_.createElement)(SidebarButton, { onClick: () => { const backPath = backPathProp !== null && backPathProp !== void 0 ? backPathProp : location.state?.backPath; if (backPath) { @@ -12573,41 +11877,73 @@ function SidebarNavigationScreen({ icon: icon, label: (0,external_wp_i18n_namespaceObject.__)('Back'), showTooltip: false - }), isRoot && (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + }), isRoot && (0,external_React_.createElement)(SidebarButton, { icon: icon, label: dashboardLinkText || (0,external_wp_i18n_namespaceObject.__)('Go to the Dashboard'), href: dashboardLink || 'index.php' - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { className: "edit-site-sidebar-navigation-screen__title", color: '#e0e0e0' /* $gray-200 */, level: 1, size: 20 - }, !isPreviewingTheme() ? title : (0,external_wp_i18n_namespaceObject.sprintf)('Previewing %1$s: %2$s', theme?.name?.rendered, title)), actions && (0,external_wp_element_namespaceObject.createElement)("div", { + }, !isPreviewingTheme() ? title : (0,external_wp_i18n_namespaceObject.sprintf)('Previewing %1$s: %2$s', previewingThemeName, title)), actions && (0,external_React_.createElement)("div", { className: "edit-site-sidebar-navigation-screen__actions" - }, actions)), meta && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { + }, actions)), meta && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { className: "edit-site-sidebar-navigation-screen__meta" - }, meta)), (0,external_wp_element_namespaceObject.createElement)("div", { + }, meta)), (0,external_React_.createElement)("div", { className: "edit-site-sidebar-navigation-screen__content" - }, description && (0,external_wp_element_namespaceObject.createElement)("p", { + }, description && (0,external_React_.createElement)("p", { className: "edit-site-sidebar-navigation-screen__description" - }, description), content)), footer && (0,external_wp_element_namespaceObject.createElement)("footer", { + }, description), content)), footer && (0,external_React_.createElement)("footer", { className: "edit-site-sidebar-navigation-screen__footer" }, footer)); } +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js +/** + * WordPress dependencies + */ + + +/** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ + +/** + * Return an SVG icon. + * + * @param {IconProps} props icon is the SVG component to render + * size is a number specifiying the icon size in pixels + * Other props will be passed to wrapped SVG component + * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element. + * + * @return {JSX.Element} Icon component + */ +function icon_Icon({ + icon, + size = 24, + ...props +}, ref) { + return (0,external_wp_element_namespaceObject.cloneElement)(icon, { + width: size, + height: size, + ...props, + ref + }); +} +/* harmony default export */ const build_module_icon = ((0,external_wp_element_namespaceObject.forwardRef)(icon_Icon)); + ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left-small.js /** * WordPress dependencies */ -const chevronLeftSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const chevronLeftSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" })); -/* harmony default export */ var chevron_left_small = (chevronLeftSmall); +/* harmony default export */ const chevron_left_small = (chevronLeftSmall); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right-small.js @@ -12615,13 +11951,13 @@ const chevronLeftSmall = (0,external_wp_element_namespaceObject.createElement)(e * WordPress dependencies */ -const chevronRightSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const chevronRightSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" })); -/* harmony default export */ var chevron_right_small = (chevronRightSmall); +/* harmony default export */ const chevron_right_small = (chevronRightSmall); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-item/index.js @@ -12644,20 +11980,20 @@ function SidebarNavigationItem({ children, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, { className: classnames_default()('edit-site-sidebar-navigation-item', { 'with-suffix': !withChevron && suffix }, className), ...props - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "flex-start" - }, icon && (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { + }, icon && (0,external_React_.createElement)(build_module_icon, { style: { fill: 'currentcolor' }, icon: icon, size: 24 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, null, children), withChevron && (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, null, children), withChevron && (0,external_React_.createElement)(build_module_icon, { icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left_small : chevron_right_small, className: "edit-site-sidebar-navigation-item__drilldown-indicator", size: 24 @@ -12670,13 +12006,13 @@ function SidebarNavigationItem({ * WordPress dependencies */ -const seen = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const seen = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" })); -/* harmony default export */ var library_seen = (seen); +/* harmony default export */ const library_seen = (seen); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pencil.js @@ -12684,13 +12020,13 @@ const seen = (0,external_wp_element_namespaceObject.createElement)(external_wp_p * WordPress dependencies */ -const pencil = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const pencil = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" })); -/* harmony default export */ var library_pencil = (pencil); +/* harmony default export */ const library_pencil = (pencil); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js /** @@ -12698,12 +12034,12 @@ const pencil = (0,external_wp_element_namespaceObject.createElement)(external_wp */ -/* harmony default export */ var edit = (library_pencil); +/* harmony default export */ const edit = (library_pencil); ;// CONCATENATED MODULE: external ["wp","keycodes"] -var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; +const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js -var cjs = __webpack_require__(1919); +var cjs = __webpack_require__(66); var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs); ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs /*! @@ -12857,7 +12193,7 @@ function GlobalStylesProvider({ if (!context.isReady) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(global_styles_provider_GlobalStylesContext.Provider, { + return (0,external_React_.createElement)(global_styles_provider_GlobalStylesContext.Provider, { value: context }, children); } @@ -12912,6 +12248,13 @@ const secondFrame = { const normalizedWidth = 248; const normalizedHeight = 152; const normalizedColorSwatchSize = 32; + +// Throttle options for useThrottle. Must be defined outside of the component, +// so that the object reference is the same on each render. +const THROTTLE_OPTIONS = { + leading: true, + trailing: true +}; const StylesPreview = ({ label, isFocused, @@ -12931,7 +12274,41 @@ const StylesPreview = ({ const [containerResizeListener, { width }] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); - const ratio = width ? width / normalizedWidth : 1; + const [throttledWidth, setThrottledWidthState] = (0,external_wp_element_namespaceObject.useState)(width); + const [ratioState, setRatioState] = (0,external_wp_element_namespaceObject.useState)(); + const setThrottledWidth = (0,external_wp_compose_namespaceObject.useThrottle)(setThrottledWidthState, 250, THROTTLE_OPTIONS); + + // Must use useLayoutEffect to avoid a flash of the iframe at the wrong + // size before the width is set. + (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { + if (width) { + setThrottledWidth(width); + } + }, [width, setThrottledWidth]); + + // Must use useLayoutEffect to avoid a flash of the iframe at the wrong + // size before the width is set. + (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { + const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1; + const ratioDiff = newRatio - (ratioState || 0); + + // Only update the ratio state if the difference is big enough + // or if the ratio state is not yet set. This is to avoid an + // endless loop of updates at particular viewport heights when the + // presence of a scrollbar causes the width to change slightly. + const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1; + if (isRatioDiffBigEnough || !ratioState) { + setRatioState(newRatio); + } + }, [throttledWidth, ratioState]); + + // Set a fallbackRatio to use before the throttled ratio has been set. + const fallbackRatio = width ? width / normalizedWidth : 1; + // Use the throttled ratio if it has been calculated, otherwise + // use the fallback ratio. The throttled ratio is used to avoid + // an endless loop of updates at particular viewport heights. + // See: https://github.com/WordPress/gutenberg/issues/55112 + const ratio = ratioState ? ratioState : fallbackRatio; const { paletteColors, highlightedColors @@ -12948,21 +12325,22 @@ const StylesPreview = ({ return styles; }, [styles]); const isReady = !!width; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { style: { position: 'relative' } - }, containerResizeListener), isReady && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { + }, containerResizeListener), isReady && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { className: "edit-site-global-styles-preview__iframe", style: { + width: '100%', height: normalizedHeight * ratio }, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), tabIndex: -1 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { styles: editorStyles - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { style: { height: normalizedHeight * ratio, width: '100%', @@ -12971,20 +12349,20 @@ const StylesPreview = ({ }, initial: "start", animate: (isHovered || isFocused) && !disableMotion && label ? 'hover' : 'start' - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { variants: firstFrame, style: { height: '100%', overflow: 'hidden' } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { spacing: 10 * ratio, justify: "center", style: { height: '100%', overflow: 'hidden' } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { style: { fontFamily: headingFontFamily, fontSize: 65 * ratio, @@ -13003,12 +12381,12 @@ const StylesPreview = ({ delay: 0.3, type: 'tween' } - }, "Aa"), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, "Aa"), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 4 * ratio }, highlightedColors.map(({ slug, color - }, index) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + }, index) => (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { key: slug, style: { height: normalizedColorSwatchSize * ratio, @@ -13027,7 +12405,7 @@ const StylesPreview = ({ transition: { delay: index === 1 ? 0.2 : 0.1 } - }))))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + }))))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { variants: withHoverView && midFrame, style: { height: '100%', @@ -13038,7 +12416,7 @@ const StylesPreview = ({ filter: 'blur(60px)', opacity: 0.1 } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { spacing: 0, justify: "flex-start", style: { @@ -13047,14 +12425,14 @@ const StylesPreview = ({ } }, paletteColors.slice(0, 4).map(({ color - }, index) => (0,external_wp_element_namespaceObject.createElement)("div", { + }, index) => (0,external_React_.createElement)("div", { key: index, style: { height: '100%', background: color, flexGrow: 1 } - })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + })))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { variants: secondFrame, style: { height: '100%', @@ -13063,7 +12441,7 @@ const StylesPreview = ({ position: 'absolute', top: 0 } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 3 * ratio, justify: "center", style: { @@ -13072,7 +12450,7 @@ const StylesPreview = ({ padding: 10 * ratio, boxSizing: 'border-box' } - }, label && (0,external_wp_element_namespaceObject.createElement)("div", { + }, label && (0,external_React_.createElement)("div", { style: { fontSize: 40 * ratio, fontFamily: headingFontFamily, @@ -13083,7 +12461,7 @@ const StylesPreview = ({ } }, label)))))); }; -/* harmony default export */ var preview = (StylesPreview); +/* harmony default export */ const preview = (StylesPreview); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/style-variations-container.js @@ -13156,9 +12534,9 @@ function Variation({ label = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1$s: variation title. %2$s variation description. */ (0,external_wp_i18n_namespaceObject.__)('%1$s (%2$s)'), variation?.title, variation?.description); } - return (0,external_wp_element_namespaceObject.createElement)(style_variations_container_GlobalStylesContext.Provider, { + return (0,external_React_.createElement)(style_variations_container_GlobalStylesContext.Provider, { value: context - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: classnames_default()('edit-site-global-styles-variations_item', { 'is-active': isActive }), @@ -13170,9 +12548,9 @@ function Variation({ "aria-current": isActive, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false) - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-global-styles-variations_item-preview" - }, (0,external_wp_element_namespaceObject.createElement)(preview, { + }, (0,external_React_.createElement)(preview, { label: variation?.title, isFocused: isFocused, withHoverView: true @@ -13196,10 +12574,10 @@ function StyleVariationsContainer() { }; })]; }, [variations]); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalGrid, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalGrid, { columns: 2, className: "edit-site-global-styles-style-variations-container" - }, withEmptyVariation.map((variation, index) => (0,external_wp_element_namespaceObject.createElement)(Variation, { + }, withEmptyVariation.map((variation, index) => (0,external_React_.createElement)(Variation, { key: index, variation: variation }))); @@ -13230,12 +12608,13 @@ function ResizeHandle({ resizeWidthBy(-DELTA_DISTANCE); } } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("button", { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("button", { className: `resizable-editor__drag-handle is-${direction} is-variation-${variation}`, "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'), "aria-describedby": `resizable-editor__resize-help-${direction}`, - onKeyDown: handleKeyDown - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { + onKeyDown: handleKeyDown, + type: "button" + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { id: `resizable-editor__resize-help-${direction}` }, (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.'))); } @@ -13277,7 +12656,7 @@ function ResizableEditor({ setWidth(resizableRef.current.offsetWidth + deltaPixels); } }, []); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ResizableBox, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.ResizableBox, { ref: api => { resizableRef.current = api?.resizable; }, @@ -13292,8 +12671,8 @@ function ResizableEditor({ maxWidth: "100%", maxHeight: "100%", enable: { - right: enableResizing, - left: enableResizing + left: enableResizing, + right: enableResizing }, showHandle: enableResizing // The editor is centered horizontally, resizing it only @@ -13302,11 +12681,11 @@ function ResizableEditor({ , resizeRatio: 2, handleComponent: { - left: (0,external_wp_element_namespaceObject.createElement)(ResizeHandle, { + left: (0,external_React_.createElement)(ResizeHandle, { direction: "left", resizeWidthBy: resizeWidthBy }), - right: (0,external_wp_element_namespaceObject.createElement)(ResizeHandle, { + right: (0,external_React_.createElement)(ResizeHandle, { direction: "right", resizeWidthBy: resizeWidthBy }) @@ -13318,7 +12697,7 @@ function ResizableEditor({ } }, children); } -/* harmony default export */ var resizable_editor = (ResizableEditor); +/* harmony default export */ const resizable_editor = (ResizableEditor); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/editor-canvas-container/index.js @@ -13334,6 +12713,7 @@ function ResizableEditor({ + /** * Internal dependencies */ @@ -13353,7 +12733,8 @@ function getEditorCanvasContainerTitle(view) { case 'style-book': return (0,external_wp_i18n_namespaceObject.__)('Style Book'); case 'global-styles-revisions': - return (0,external_wp_i18n_namespaceObject.__)('Global styles revisions'); + case 'global-styles-revisions:style-book': + return (0,external_wp_i18n_namespaceObject.__)('Style Revisions'); default: return ''; } @@ -13380,7 +12761,7 @@ function EditorCanvasContainer({ showListViewByDefault } = (0,external_wp_data_namespaceObject.useSelect)(select => { const _editorCanvasContainerView = unlock(select(store_store)).getEditorCanvasContainerView(); - const _showListViewByDefault = select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showListViewByDefault'); + const _showListViewByDefault = select(external_wp_preferences_namespaceObject.store).get('core', 'showListViewByDefault'); return { editorCanvasContainerView: _editorCanvasContainerView, showListViewByDefault: _showListViewByDefault @@ -13390,19 +12771,19 @@ function EditorCanvasContainer({ const { setEditorCanvasContainerView } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const { + setIsListViewOpened + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement'); const sectionFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)(); const title = (0,external_wp_element_namespaceObject.useMemo)(() => getEditorCanvasContainerTitle(editorCanvasContainerView), [editorCanvasContainerView]); - const { - setIsListViewOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); function onCloseContainer() { - if (typeof onClose === 'function') { - onClose(); - } setIsListViewOpened(showListViewByDefault); setEditorCanvasContainerView(undefined); setIsClosed(true); + if (typeof onClose === 'function') { + onClose(); + } } function closeOnEscape(event) { if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) { @@ -13419,14 +12800,14 @@ function EditorCanvasContainer({ return null; } const shouldShowCloseButton = onClose || closeButtonLabel; - return (0,external_wp_element_namespaceObject.createElement)(EditorCanvasContainerFill, null, (0,external_wp_element_namespaceObject.createElement)(resizable_editor, { + return (0,external_React_.createElement)(EditorCanvasContainerFill, null, (0,external_React_.createElement)(resizable_editor, { enableResizing: enableResizing - }, (0,external_wp_element_namespaceObject.createElement)("section", { + }, (0,external_React_.createElement)("section", { className: "edit-site-editor-canvas-container", ref: shouldShowCloseButton ? focusOnMountRef : null, onKeyDown: closeOnEscape, "aria-label": title - }, shouldShowCloseButton && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, shouldShowCloseButton && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { className: "edit-site-editor-canvas-container__close-button", icon: close_small, label: closeButtonLabel || (0,external_wp_i18n_namespaceObject.__)('Close'), @@ -13439,7 +12820,7 @@ function useHasEditorCanvasContainer() { return !!fills?.length; } EditorCanvasContainer.Slot = EditorCanvasContainerSlot; -/* harmony default export */ var editor_canvas_container = (EditorCanvasContainer); +/* harmony default export */ const editor_canvas_container = (EditorCanvasContainer); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/style-book/index.js @@ -13466,10 +12847,19 @@ EditorCanvasContainer.Slot = EditorCanvasContainerSlot; */ + const { ExperimentalBlockEditorProvider, - useGlobalStyle: style_book_useGlobalStyle + useGlobalStyle: style_book_useGlobalStyle, + GlobalStylesContext: style_book_GlobalStylesContext, + useGlobalStylesOutputWithConfig } = unlock(external_wp_blockEditor_namespaceObject.privateApis); +const { + CompositeV2: Composite, + CompositeItemV2: CompositeItem, + useCompositeStoreV2: useCompositeStore, + Tabs +} = unlock(external_wp_components_namespaceObject.privateApis); // The content area of the Style Book is rendered within an iframe so that global styles // are applied to elements within the entire content area. To support elements that are @@ -13494,6 +12884,8 @@ const STYLE_BOOK_IFRAME_STYLES = ` padding: 16px; width: 100%; box-sizing: border-box; + scroll-margin-top: 32px; + scroll-margin-bottom: 32px; } .edit-site-style-book__example.is-selected { @@ -13540,6 +12932,9 @@ const STYLE_BOOK_IFRAME_STYLES = ` margin-bottom: 0; } `; +function isObjectEmpty(object) { + return !object || Object.keys(object).length === 0; +} function getExamples() { // Use our own example for the Heading block so that we can show multiple // heading levels. @@ -13585,7 +12980,9 @@ function StyleBook({ onClick, onSelect, showCloseButton = true, - showTabs = true + onClose, + showTabs = true, + userConfig = {} }) { const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); const [textColor] = style_book_useGlobalStyle('color.text'); @@ -13596,15 +12993,30 @@ function StyleBook({ title: category.title, icon: category.icon })), [examples]); + const { + base: baseConfig + } = (0,external_wp_element_namespaceObject.useContext)(style_book_GlobalStylesContext); + const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) { + return mergeBaseAndUserConfigs(baseConfig, userConfig); + } + return {}; + }, [baseConfig, userConfig]); + + // Copied from packages/edit-site/src/components/revisions/index.js + // could we create a shared hook? const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getSettings(), []); const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...originalSettings, __unstableIsPreviewMode: true }), [originalSettings]); - return (0,external_wp_element_namespaceObject.createElement)(editor_canvas_container, { + const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig); + settings.styles = !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : settings.styles; + return (0,external_React_.createElement)(editor_canvas_container, { + onClose: onClose, enableResizing: enableResizing, closeButtonLabel: showCloseButton ? (0,external_wp_i18n_namespaceObject.__)('Close Style Book') : null - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: classnames_default()('edit-site-style-book', { 'is-wide': sizes.width > 600, 'is-button': !!onClick @@ -13613,10 +13025,16 @@ function StyleBook({ color: textColor, background: backgroundColor } - }, resizeObserver, showTabs ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, { - className: "edit-site-style-book__tab-panel", - tabs: tabs - }, tab => (0,external_wp_element_namespaceObject.createElement)(StyleBookBody, { + }, resizeObserver, showTabs ? (0,external_React_.createElement)("div", { + className: "edit-site-style-book__tabs" + }, (0,external_React_.createElement)(Tabs, null, (0,external_React_.createElement)(Tabs.TabList, null, tabs.map(tab => (0,external_React_.createElement)(Tabs.Tab, { + tabId: tab.name, + key: tab.name + }, tab.title))), tabs.map(tab => (0,external_React_.createElement)(Tabs.TabPanel, { + key: tab.name, + tabId: tab.name, + focusable: false + }, (0,external_React_.createElement)(StyleBookBody, { category: tab.name, examples: examples, isSelected: isSelected, @@ -13624,7 +13042,7 @@ function StyleBook({ settings: settings, sizes: sizes, title: tab.title - })) : (0,external_wp_element_namespaceObject.createElement)(StyleBookBody, { + }))))) : (0,external_React_.createElement)(StyleBookBody, { examples: examples, isSelected: isSelected, onClick: onClick, @@ -13675,7 +13093,7 @@ const StyleBookBody = ({ readonly: true }; const buttonModeStyles = onClick ? 'body { cursor: pointer; } body * { pointer-events: none; }' : ''; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { className: classnames_default()('edit-site-style-book__iframe', { 'is-focused': isFocused && !!onClick, 'is-button': !!onClick @@ -13683,13 +13101,13 @@ const StyleBookBody = ({ name: "style-book-canvas", tabIndex: 0, ...(onClick ? buttonModeProps : {}) - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { styles: settings.styles - }), (0,external_wp_element_namespaceObject.createElement)("style", null, + }), (0,external_React_.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing. // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context `.is-root-container { display: flow-root; } - body { position: relative; padding: 32px !important; }` + STYLE_BOOK_IFRAME_STYLES + buttonModeStyles), (0,external_wp_element_namespaceObject.createElement)(Examples, { + body { position: relative; padding: 32px !important; }` + STYLE_BOOK_IFRAME_STYLES + buttonModeStyles), (0,external_React_.createElement)(Examples, { className: classnames_default()('edit-site-style-book__examples', { 'is-wide': sizes.width > 600 }), @@ -13699,7 +13117,8 @@ const StyleBookBody = ({ // translators: %s: Category of blocks, e.g. Text. (0,external_wp_i18n_namespaceObject.__)('Examples of blocks in the %s category'), title) : (0,external_wp_i18n_namespaceObject.__)('Examples of blocks'), isSelected: isSelected, - onSelect: onSelect + onSelect: onSelect, + key: category })); }; const Examples = (0,external_wp_element_namespaceObject.memo)(({ @@ -13710,17 +13129,17 @@ const Examples = (0,external_wp_element_namespaceObject.memo)(({ isSelected, onSelect }) => { - const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({ + const compositeStore = useCompositeStore({ orientation: 'vertical' }); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, { - ...composite, + return (0,external_React_.createElement)(Composite, { + store: compositeStore, className: className, - "aria-label": label - }, examples.filter(example => category ? example.category === category : true).map(example => (0,external_wp_element_namespaceObject.createElement)(Example, { + "aria-label": label, + role: "grid" + }, examples.filter(example => category ? example.category === category : true).map(example => (0,external_React_.createElement)(Example, { key: example.name, id: `example-${example.name}`, - composite: composite, title: example.title, blocks: example.blocks, isSelected: isSelected(example.name), @@ -13730,7 +13149,6 @@ const Examples = (0,external_wp_element_namespaceObject.memo)(({ }))); }); const Example = ({ - composite, id, title, blocks, @@ -13740,13 +13158,18 @@ const Example = ({ const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getSettings(), []); const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...originalSettings, + focusMode: false, + // Disable "Spotlight mode". __unstableIsPreviewMode: true }), [originalSettings]); // Cache the list of blocks to avoid additional processing when the component is re-rendered. const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => Array.isArray(blocks) ? blocks : [blocks], [blocks]); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, { - ...composite, + return (0,external_React_.createElement)("div", { + role: "row" + }, (0,external_React_.createElement)("div", { + role: "gridcell" + }, (0,external_React_.createElement)(CompositeItem, { className: classnames_default()('edit-site-style-book__example', { 'is-selected': isSelected }), @@ -13754,24 +13177,24 @@ const Example = ({ "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Title of a block, e.g. Heading. (0,external_wp_i18n_namespaceObject.__)('Open %s styles in Styles panel'), title), - onClick: onClick, + render: (0,external_React_.createElement)("div", null), role: "button", - as: "div" - }, (0,external_wp_element_namespaceObject.createElement)("span", { + onClick: onClick + }, (0,external_React_.createElement)("span", { className: "edit-site-style-book__example-title" - }, title), (0,external_wp_element_namespaceObject.createElement)("div", { + }, title), (0,external_React_.createElement)("div", { className: "edit-site-style-book__example-preview", "aria-hidden": true - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Disabled, { className: "edit-site-style-book__example-preview__content" - }, (0,external_wp_element_namespaceObject.createElement)(ExperimentalBlockEditorProvider, { + }, (0,external_React_.createElement)(ExperimentalBlockEditorProvider, { value: renderedBlocks, settings: settings - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { renderAppender: false - }))))); + }))))))); }; -/* harmony default export */ var style_book = (StyleBook); +/* harmony default export */ const style_book = (StyleBook); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js /** @@ -13792,66 +13215,86 @@ const SITE_EDITOR_AUTHORS_QUERY = { context: 'view', capabilities: ['edit_theme_options'] }; +const DEFAULT_QUERY = { + per_page: 100, + page: 1 +}; const use_global_styles_revisions_EMPTY_ARRAY = []; const { GlobalStylesContext: use_global_styles_revisions_GlobalStylesContext } = unlock(external_wp_blockEditor_namespaceObject.privateApis); -function useGlobalStylesRevisions() { +function useGlobalStylesRevisions({ + query +} = {}) { const { user: userConfig } = (0,external_wp_element_namespaceObject.useContext)(use_global_styles_revisions_GlobalStylesContext); + const _query = { + ...DEFAULT_QUERY, + ...query + }; const { authors, currentUser, isDirty, revisions, - isLoadingGlobalStylesRevisions + isLoadingGlobalStylesRevisions, + revisionsCount } = (0,external_wp_data_namespaceObject.useSelect)(select => { + var _globalStyles$_links$; const { __experimentalGetDirtyEntityRecords, getCurrentUser, getUsers, - getCurrentThemeGlobalStylesRevisions, + getRevisions, + __experimentalGetCurrentGlobalStylesId, + getEntityRecord, isResolving } = select(external_wp_coreData_namespaceObject.store); const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); const _currentUser = getCurrentUser(); const _isDirty = dirtyEntityRecords.length > 0; - const globalStylesRevisions = getCurrentThemeGlobalStylesRevisions() || use_global_styles_revisions_EMPTY_ARRAY; + const globalStylesId = __experimentalGetCurrentGlobalStylesId(); + const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; + const _revisionsCount = (_globalStyles$_links$ = globalStyles?._links?.['version-history']?.[0]?.count) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : 0; + const globalStylesRevisions = getRevisions('root', 'globalStyles', globalStylesId, _query) || use_global_styles_revisions_EMPTY_ARRAY; const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || use_global_styles_revisions_EMPTY_ARRAY; + const _isResolving = isResolving('getRevisions', ['root', 'globalStyles', globalStylesId, _query]); return { authors: _authors, currentUser: _currentUser, isDirty: _isDirty, revisions: globalStylesRevisions, - isLoadingGlobalStylesRevisions: isResolving('getCurrentThemeGlobalStylesRevisions') + isLoadingGlobalStylesRevisions: _isResolving, + revisionsCount: _revisionsCount }; - }, []); + }, [query]); return (0,external_wp_element_namespaceObject.useMemo)(() => { - let _modifiedRevisions = []; if (!authors.length || isLoadingGlobalStylesRevisions) { return { - revisions: _modifiedRevisions, + revisions: use_global_styles_revisions_EMPTY_ARRAY, hasUnsavedChanges: isDirty, - isLoading: true + isLoading: true, + revisionsCount }; } // Adds author details to each revision. - _modifiedRevisions = revisions.map(revision => { + const _modifiedRevisions = revisions.map(revision => { return { ...revision, author: authors.find(author => author.id === revision.author) }; }); - if (_modifiedRevisions.length) { + const fetchedRevisionsCount = revisions.length; + if (fetchedRevisionsCount) { // Flags the most current saved revision. - if (_modifiedRevisions[0].id !== 'unsaved') { + if (_modifiedRevisions[0].id !== 'unsaved' && _query.page === 1) { _modifiedRevisions[0].isLatest = true; } // Adds an item for unsaved changes. - if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser) { + if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) { const unsavedRevision = { id: 'unsaved', styles: userConfig?.styles, @@ -13864,35 +13307,39 @@ function useGlobalStylesRevisions() { }; _modifiedRevisions.unshift(unsavedRevision); } - _modifiedRevisions.push({ - id: 'parent', - styles: {}, - settings: {} - }); + if (_query.page === Math.ceil(revisionsCount / _query.per_page)) { + // Adds an item for the default theme styles. + _modifiedRevisions.push({ + id: 'parent', + styles: {}, + settings: {} + }); + } } return { revisions: _modifiedRevisions, hasUnsavedChanges: isDirty, - isLoading: false + isLoading: false, + revisionsCount }; }, [isDirty, revisions, currentUser, authors, userConfig, isLoadingGlobalStylesRevisions]); } ;// CONCATENATED MODULE: external ["wp","date"] -var external_wp_date_namespaceObject = window["wp"]["date"]; +const external_wp_date_namespaceObject = window["wp"]["date"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/backup.js /** * WordPress dependencies */ -const backup = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const backup = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z" })); -/* harmony default export */ var library_backup = (backup); +/* harmony default export */ const library_backup = (backup); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-label.js @@ -13903,7 +13350,7 @@ const backup = (0,external_wp_element_namespaceObject.createElement)(external_wp function SidebarNavigationScreenDetailsPanelLabel({ children }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { className: "edit-site-sidebar-navigation-details-screen-panel__label" }, children); } @@ -13925,7 +13372,7 @@ function SidebarNavigationScreenDetailsPanelRow({ className, ...extraProps }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { key: label, spacing: 5, alignment: "left", @@ -13943,7 +13390,7 @@ function SidebarNavigationScreenDetailsPanelRow({ function SidebarNavigationScreenDetailsPanelValue({ children }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { className: "edit-site-sidebar-navigation-details-screen-panel__value" }, children); } @@ -13966,10 +13413,10 @@ function SidebarNavigationScreenDetailsPanel({ children, spacing }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { className: "edit-site-sidebar-navigation-details-screen-panel", spacing: spacing - }, title && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + }, title && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { className: "edit-site-sidebar-navigation-details-screen-panel__heading", level: 2 }, title), children); @@ -14010,20 +13457,20 @@ function SidebarNavigationScreenDetailsFooter({ }); hrefProps.as = 'a'; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-details-footer" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { - label: (0,external_wp_i18n_namespaceObject.__)('Revisions'), + }, (0,external_React_.createElement)(SidebarNavigationItem, { + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Revisions'), ...hrefProps, ...otherProps - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelRow, { + }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, { justify: "space-between" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, (0,external_wp_i18n_namespaceObject.__)('Last modified')), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelValue, null, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is the relative time when the post was last modified. */ + }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, (0,external_wp_i18n_namespaceObject.__)('Last modified')), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelValue, null, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is the relative time when the post was last modified. */ (0,external_wp_i18n_namespaceObject.__)('<time>%s</time>'), (0,external_wp_date_namespaceObject.humanTimeDiff)(record.modified)), { - time: (0,external_wp_element_namespaceObject.createElement)("time", { + time: (0,external_React_.createElement)("time", { dateTime: record.modified }) - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { className: "edit-site-sidebar-navigation-screen-details-footer__icon", icon: library_backup })))); @@ -14043,6 +13490,7 @@ function SidebarNavigationScreenDetailsFooter({ + /** * Internal dependencies */ @@ -14065,13 +13513,13 @@ function SidebarNavigationItemGlobalStyles(props) { } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); const hasGlobalStyleVariations = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations()?.length, []); if (hasGlobalStyleVariations) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { ...props, as: SidebarNavigationItem, path: "/wp_global_styles" }); } - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + return (0,external_React_.createElement)(SidebarNavigationItem, { ...props, onClick: () => { // Switch to edit mode. @@ -14089,7 +13537,7 @@ function SidebarNavigationScreenGlobalStylesContent() { getSettings } = unlock(select(store_store)); return { - storedSettings: getSettings(false) + storedSettings: getSettings() }; }, []); @@ -14098,11 +13546,11 @@ function SidebarNavigationScreenGlobalStylesContent() { // the block editor store's `__internalIsInitialized` is true before // rendering the iframe. Without this, the iframe previews will not render // in mobile viewport sizes, where the editor canvas is hidden. - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, { + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, { settings: storedSettings, onChange: sidebar_navigation_screen_global_styles_noop, onInput: sidebar_navigation_screen_global_styles_noop - }, (0,external_wp_element_namespaceObject.createElement)(StyleVariationsContainer, null)); + }, (0,external_React_.createElement)(StyleVariationsContainer, null)); } function SidebarNavigationScreenGlobalStyles() { const { @@ -14110,9 +13558,11 @@ function SidebarNavigationScreenGlobalStyles() { isLoading: isLoadingRevisions } = useGlobalStylesRevisions(); const { - openGeneralSidebar, - setIsListViewOpened + openGeneralSidebar } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + const { + setIsListViewOpened + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); const { setCanvasMode, @@ -14164,25 +13614,25 @@ function SidebarNavigationScreenGlobalStyles() { const hasRevisions = revisionsCount > 0; const modifiedDateTime = revisions?.[0]?.modified; const shouldShowGlobalStylesFooter = hasRevisions && !isLoadingRevisions && modifiedDateTime; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(SidebarNavigationScreen, { title: (0,external_wp_i18n_namespaceObject.__)('Styles'), description: (0,external_wp_i18n_namespaceObject.__)('Choose a different style combination for the theme styles.'), - content: (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenGlobalStylesContent, null), - footer: shouldShowGlobalStylesFooter && (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsFooter, { + content: (0,external_React_.createElement)(SidebarNavigationScreenGlobalStylesContent, null), + footer: shouldShowGlobalStylesFooter && (0,external_React_.createElement)(SidebarNavigationScreenDetailsFooter, { record: revisions?.[0], onClick: openRevisions }), - actions: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !isMobileViewport && (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + actions: (0,external_React_.createElement)(external_React_.Fragment, null, !isMobileViewport && (0,external_React_.createElement)(SidebarButton, { icon: library_seen, label: (0,external_wp_i18n_namespaceObject.__)('Style Book'), onClick: () => setEditorCanvasContainerView(!isStyleBookOpened ? 'style-book' : undefined), isPressed: isStyleBookOpened - }), (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + }), (0,external_React_.createElement)(SidebarButton, { icon: edit, label: (0,external_wp_i18n_namespaceObject.__)('Edit styles'), onClick: async () => await openGlobalStyles() })) - }), isStyleBookOpened && !isMobileViewport && isViewMode && (0,external_wp_element_namespaceObject.createElement)(style_book, { + }), isStyleBookOpened && !isMobileViewport && isViewMode && (0,external_React_.createElement)(style_book, { enableResizing: false, isSelected: () => false, onClick: openStyleBook, @@ -14213,7 +13663,7 @@ function TemplatePartHint() { if (!showTemplatePartHint) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { politeness: "polite", className: "edit-site-sidebar__notice", onRemove: () => { @@ -14256,34 +13706,34 @@ function SidebarNavigationScreenMain() { setEditorCanvasContainerView(undefined); } }, [setEditorCanvasContainerView, location?.path]); - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { + return (0,external_React_.createElement)(SidebarNavigationScreen, { isRoot: true, title: (0,external_wp_i18n_namespaceObject.__)('Design'), description: (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of your website using the block editor.'), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { as: SidebarNavigationItem, path: "/navigation", withChevron: true, icon: library_navigation - }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItemGlobalStyles, { + }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_React_.createElement)(SidebarNavigationItemGlobalStyles, { withChevron: true, icon: library_styles - }, (0,external_wp_i18n_namespaceObject.__)('Styles')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { + }, (0,external_wp_i18n_namespaceObject.__)('Styles')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { as: SidebarNavigationItem, path: "/page", withChevron: true, icon: library_page - }, (0,external_wp_i18n_namespaceObject.__)('Pages')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { + }, (0,external_wp_i18n_namespaceObject.__)('Pages')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { as: SidebarNavigationItem, path: "/wp_template", withChevron: true, icon: library_layout - }, (0,external_wp_i18n_namespaceObject.__)('Templates')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { + }, (0,external_wp_i18n_namespaceObject.__)('Templates')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { as: SidebarNavigationItem, path: "/patterns", withChevron: true, icon: library_symbol - }, (0,external_wp_i18n_namespaceObject.__)('Patterns'))), (0,external_wp_element_namespaceObject.createElement)(TemplatePartHint, null)) + }, (0,external_wp_i18n_namespaceObject.__)('Patterns'))), (0,external_React_.createElement)(TemplatePartHint, null)) }); } @@ -14293,13 +13743,13 @@ function SidebarNavigationScreenMain() { * WordPress dependencies */ -const home = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const home = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z" })); -/* harmony default export */ var library_home = (home); +/* harmony default export */ const library_home = (home); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/verse.js @@ -14307,13 +13757,13 @@ const home = (0,external_wp_element_namespaceObject.createElement)(external_wp_p * WordPress dependencies */ -const verse = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const verse = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z" })); -/* harmony default export */ var library_verse = (verse); +/* harmony default export */ const library_verse = (verse); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pin.js @@ -14321,13 +13771,13 @@ const verse = (0,external_wp_element_namespaceObject.createElement)(external_wp_ * WordPress dependencies */ -const pin = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const pin = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z" })); -/* harmony default export */ var library_pin = (pin); +/* harmony default export */ const library_pin = (pin); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/archive.js @@ -14335,13 +13785,15 @@ const pin = (0,external_wp_element_namespaceObject.createElement)(external_wp_pr * WordPress dependencies */ -const archive = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const archive = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M11.934 7.406a1 1 0 0 0 .914.594H19a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5h5.764a.5.5 0 0 1 .447.276l.723 1.63Zm1.064-1.216a.5.5 0 0 0 .462.31H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h5.764a2 2 0 0 1 1.789 1.106l.445 1.084ZM8.5 10.5h7V12h-7v-1.5Zm7 3.5h-7v1.5h7V14Z" })); -/* harmony default export */ var library_archive = (archive); +/* harmony default export */ const library_archive = (archive); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/search.js @@ -14349,13 +13801,13 @@ const archive = (0,external_wp_element_namespaceObject.createElement)(external_w * WordPress dependencies */ -const search_search = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const search = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" })); -/* harmony default export */ var library_search = (search_search); +/* harmony default export */ const library_search = (search); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/not-found.js @@ -14363,13 +13815,13 @@ const search_search = (0,external_wp_element_namespaceObject.createElement)(exte * WordPress dependencies */ -const notFound = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const notFound = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var not_found = (notFound); +/* harmony default export */ const not_found = (notFound); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list.js @@ -14377,13 +13829,13 @@ const notFound = (0,external_wp_element_namespaceObject.createElement)(external_ * WordPress dependencies */ -const list = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const list = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_list = (list); +/* harmony default export */ const library_list = (list); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/category.js @@ -14391,15 +13843,15 @@ const list = (0,external_wp_element_namespaceObject.createElement)(external_wp_p * WordPress dependencies */ -const category = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const category = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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", fillRule: "evenodd", clipRule: "evenodd" })); -/* harmony default export */ var library_category = (category); +/* harmony default export */ const library_category = (category); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/comment-author-avatar.js @@ -14407,15 +13859,15 @@ const category = (0,external_wp_element_namespaceObject.createElement)(external_ * WordPress dependencies */ -const commentAuthorAvatar = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const commentAuthorAvatar = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { fillRule: "evenodd", 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", clipRule: "evenodd" })); -/* harmony default export */ var comment_author_avatar = (commentAuthorAvatar); +/* harmony default export */ const comment_author_avatar = (commentAuthorAvatar); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-meta.js @@ -14423,15 +13875,15 @@ const commentAuthorAvatar = (0,external_wp_element_namespaceObject.createElement * WordPress dependencies */ -const blockMeta = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const blockMeta = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { fillRule: "evenodd", 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", clipRule: "evenodd" })); -/* harmony default export */ var block_meta = (blockMeta); +/* harmony default export */ const block_meta = (blockMeta); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/calendar.js @@ -14439,13 +13891,13 @@ const blockMeta = (0,external_wp_element_namespaceObject.createElement)(external * WordPress dependencies */ -const calendar = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const calendar = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z" })); -/* harmony default export */ var library_calendar = (calendar); +/* harmony default export */ const library_calendar = (calendar); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/tag.js @@ -14453,13 +13905,13 @@ const calendar = (0,external_wp_element_namespaceObject.createElement)(external_ * WordPress dependencies */ -const tag = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const tag = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M4.75 4a.75.75 0 0 0-.75.75v7.826c0 .2.08.39.22.53l6.72 6.716a2.313 2.313 0 0 0 3.276-.001l5.61-5.611-.531-.53.532.528a2.315 2.315 0 0 0 0-3.264L13.104 4.22a.75.75 0 0 0-.53-.22H4.75ZM19 12.576a.815.815 0 0 1-.236.574l-5.61 5.611a.814.814 0 0 1-1.153 0L5.5 12.264V5.5h6.763l6.5 6.502a.816.816 0 0 1 .237.574ZM8.75 9.75a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" })); -/* harmony default export */ var library_tag = (tag); +/* harmony default export */ const library_tag = (tag); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/media.js @@ -14467,17 +13919,17 @@ const tag = (0,external_wp_element_namespaceObject.createElement)(external_wp_pr * WordPress dependencies */ -const media = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const media = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "m7 6.5 4 2.5-4 2.5z" -}), (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "m5 3c-1.10457 0-2 .89543-2 2v14c0 1.1046.89543 2 2 2h14c1.1046 0 2-.8954 2-2v-14c0-1.10457-.8954-2-2-2zm14 1.5h-14c-.27614 0-.5.22386-.5.5v10.7072l3.62953-2.6465c.25108-.1831.58905-.1924.84981-.0234l2.92666 1.8969 3.5712-3.4719c.2911-.2831.7545-.2831 1.0456 0l2.9772 2.8945v-9.3568c0-.27614-.2239-.5-.5-.5zm-14.5 14.5v-1.4364l4.09643-2.987 2.99567 1.9417c.2936.1903.6798.1523.9307-.0917l3.4772-3.3806 3.4772 3.3806.0228-.0234v2.5968c0 .2761-.2239.5-.5.5h-14c-.27614 0-.5-.2239-.5-.5z" })); -/* harmony default export */ var library_media = (media); +/* harmony default export */ const library_media = (media); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js @@ -14485,29 +13937,13 @@ const media = (0,external_wp_element_namespaceObject.createElement)(external_wp_ * WordPress dependencies */ -const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const plus = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" })); -/* harmony default export */ var library_plus = (plus); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/use-debounced-input.js -/** - * WordPress dependencies - */ - - -function useDebouncedInput(defaultValue = '') { - const [input, setInput] = (0,external_wp_element_namespaceObject.useState)(defaultValue); - const [debouncedInput, setDebouncedState] = (0,external_wp_element_namespaceObject.useState)(defaultValue); - const setDebouncedInput = (0,external_wp_compose_namespaceObject.useDebounce)(setDebouncedState, 250); - (0,external_wp_element_namespaceObject.useEffect)(() => { - setDebouncedInput(input); - }, [input]); - return [input, setInput, debouncedInput]; -} +/* harmony default export */ const library_plus = (plus); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js @@ -14515,13 +13951,13 @@ function useDebouncedInput(defaultValue = '') { * WordPress dependencies */ -const post = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const post = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_post = (post); +/* harmony default export */ const library_post = (post); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/utils.js /** @@ -14577,7 +14013,7 @@ const mapToIHasNameAndId = (entities, path) => { */ const useExistingTemplates = () => { - return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_POST_TYPE, { + return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', constants_TEMPLATE_POST_TYPE, { per_page: -1 }), []); }; @@ -15076,36 +14512,41 @@ const useEntitiesInfo = (entityName, templatePrefixes, additionalQueryParameters + /** * Internal dependencies */ +const { + CompositeV2: add_custom_template_modal_content_Composite, + CompositeItemV2: add_custom_template_modal_content_CompositeItem, + useCompositeStoreV2: add_custom_template_modal_content_useCompositeStore +} = unlock(external_wp_components_namespaceObject.privateApis); const add_custom_template_modal_content_EMPTY_ARRAY = []; function SuggestionListItem({ suggestion, search, onSelect, - entityForSuggestions, - composite + entityForSuggestions }) { const baseCssClass = 'edit-site-custom-template-modal__suggestions_list__list-item'; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, { - role: "option", - as: external_wp_components_namespaceObject.Button, - ...composite, - className: baseCssClass, - onClick: () => onSelect(entityForSuggestions.config.getSpecificTemplate(suggestion)) - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + return (0,external_React_.createElement)(add_custom_template_modal_content_CompositeItem, { + render: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + role: "option", + className: baseCssClass, + onClick: () => onSelect(entityForSuggestions.config.getSpecificTemplate(suggestion)) + }) + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { size: "body", lineHeight: 1.53846153846 // 20px , weight: 500, className: `${baseCssClass}__title` - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextHighlight, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextHighlight, { text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(suggestion.name), highlight: search - })), suggestion.link && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + })), suggestion.link && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { size: "body", lineHeight: 1.53846153846 // 20px , @@ -15147,10 +14588,10 @@ function SuggestionList({ entityForSuggestions, onSelect }) { - const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)({ + const composite = add_custom_template_modal_content_useCompositeStore({ orientation: 'vertical' }); - const [search, setSearch, debouncedSearch] = useDebouncedInput(); + const [search, setSearch, debouncedSearch] = (0,external_wp_compose_namespaceObject.useDebouncedInput)(); const suggestions = useSearchSuggestions(entityForSuggestions, debouncedSearch); const { labels @@ -15159,25 +14600,24 @@ function SuggestionList({ if (!showSearchControl && suggestions?.length > 9) { setShowSearchControl(true); } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, showSearchControl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, { + return (0,external_React_.createElement)(external_React_.Fragment, null, showSearchControl && (0,external_React_.createElement)(external_wp_components_namespaceObject.SearchControl, { __nextHasNoMarginBottom: true, onChange: setSearch, value: search, label: labels.search_items, placeholder: labels.search_items - }), !!suggestions?.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, { - ...composite, + }), !!suggestions?.length && (0,external_React_.createElement)(add_custom_template_modal_content_Composite, { + store: composite, role: "listbox", className: "edit-site-custom-template-modal__suggestions_list", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Suggestions list') - }, suggestions.map(suggestion => (0,external_wp_element_namespaceObject.createElement)(SuggestionListItem, { + }, suggestions.map(suggestion => (0,external_React_.createElement)(SuggestionListItem, { key: suggestion.slug, suggestion: suggestion, search: debouncedSearch, onSelect: onSelect, - entityForSuggestions: entityForSuggestions, - composite: composite - }))), debouncedSearch && !suggestions?.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + entityForSuggestions: entityForSuggestions + }))), debouncedSearch && !suggestions?.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "p", className: "edit-site-custom-template-modal__no-results" }, labels.not_found)); @@ -15187,17 +14627,17 @@ function AddCustomTemplateModalContent({ entityForSuggestions }) { const [showSearchEntities, setShowSearchEntities] = (0,external_wp_element_namespaceObject.useState)(entityForSuggestions.hasGeneralTemplate); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 4, className: "edit-site-custom-template-modal__contents-wrapper", alignment: "left" - }, !showSearchEntities && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, !showSearchEntities && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "p" - }, (0,external_wp_i18n_namespaceObject.__)('Select whether to create a single template for all items or a specific one.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { + }, (0,external_wp_i18n_namespaceObject.__)('Select whether to create a single template for all items or a specific one.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { className: "edit-site-custom-template-modal__contents", gap: "4", align: "initial" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { isBlock: true, as: external_wp_components_namespaceObject.Button, onClick: () => { @@ -15214,38 +14654,38 @@ function AddCustomTemplateModalContent({ templatePrefix }); } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "span", weight: 500, lineHeight: 1.53846153846 // 20px - }, entityForSuggestions.labels.all_items), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, entityForSuggestions.labels.all_items), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "span", lineHeight: 1.53846153846 // 20px }, // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. - (0,external_wp_i18n_namespaceObject.__)('For all items'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, { + (0,external_wp_i18n_namespaceObject.__)('For all items'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { isBlock: true, as: external_wp_components_namespaceObject.Button, onClick: () => { setShowSearchEntities(true); } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "span", weight: 500, lineHeight: 1.53846153846 // 20px - }, entityForSuggestions.labels.singular_name), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, entityForSuggestions.labels.singular_name), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "span", lineHeight: 1.53846153846 // 20px }, // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. - (0,external_wp_i18n_namespaceObject.__)('For a specific item'))))), showSearchEntities && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + (0,external_wp_i18n_namespaceObject.__)('For a specific item'))))), showSearchEntities && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "p" - }, (0,external_wp_i18n_namespaceObject.__)('This template will be used only for the specific item chosen.')), (0,external_wp_element_namespaceObject.createElement)(SuggestionList, { + }, (0,external_wp_i18n_namespaceObject.__)('This template will be used only for the specific item chosen.')), (0,external_React_.createElement)(SuggestionList, { entityForSuggestions: entityForSuggestions, onSelect: onSelect }))); } -/* harmony default export */ var add_custom_template_modal_content = (AddCustomTemplateModalContent); +/* harmony default export */ const add_custom_template_modal_content = (AddCustomTemplateModalContent); ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs /****************************************************************************** @@ -15589,7 +15029,7 @@ function __disposeResources(env) { return next(); } -/* harmony default export */ var tslib_es6 = ({ +/* harmony default export */ const tslib_es6 = ({ __extends, __assign, __rest, @@ -15751,11 +15191,11 @@ function AddCustomGenericTemplateModalContent({ setIsBusy(false); } } - return (0,external_wp_element_namespaceObject.createElement)("form", { + return (0,external_React_.createElement)("form", { onSubmit: onCreateTemplate - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 6 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { __nextHasNoMarginBottom: true, label: (0,external_wp_i18n_namespaceObject.__)('Name'), value: title, @@ -15763,22 +15203,22 @@ function AddCustomGenericTemplateModalContent({ placeholder: defaultTitle, disabled: isBusy, help: (0,external_wp_i18n_namespaceObject.__)('Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { className: "edit-site-custom-generic-template__modal-actions", justify: "right" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "tertiary", onClick: () => { onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", type: "submit", isBusy: isBusy, "aria-disabled": isBusy }, (0,external_wp_i18n_namespaceObject.__)('Create'))))); } -/* harmony default export */ var add_custom_generic_template_modal_content = (AddCustomGenericTemplateModalContent); +/* harmony default export */ const add_custom_generic_template_modal_content = (AddCustomGenericTemplateModalContent); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/template-actions-loading-screen.js @@ -15788,7 +15228,7 @@ function AddCustomGenericTemplateModalContent({ function TemplateActionsLoadingScreen() { const baseCssClass = 'edit-site-template-actions-loading-screen-modal'; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { isFullScreen: true, isDismissible: false, shouldCloseOnClickOutside: false, @@ -15796,9 +15236,9 @@ function TemplateActionsLoadingScreen() { onRequestClose: () => {}, __experimentalHideHeader: true, className: baseCssClass - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: `${baseCssClass}__content` - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null))); + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null))); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/new-template.js @@ -15834,7 +15274,6 @@ function TemplateActionsLoadingScreen() { - const { useHistory: new_template_useHistory } = unlock(external_wp_router_namespaceObject.privateApis); @@ -15864,12 +15303,12 @@ function TemplateListItem({ onClick, children }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { className: className, onClick: onClick, label: description, showTooltip: !!description - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { as: "span", spacing: 2, align: "center", @@ -15878,15 +15317,15 @@ function TemplateListItem({ width: '100%' }, direction: direction - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-add-new-template__template-icon" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { icon: icon - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { className: "edit-site-add-new-template__template-name", alignment: "center", spacing: 0 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { weight: 500, lineHeight: 1.53846153846 // 20px }, title), children))); @@ -15914,9 +15353,6 @@ function NewTemplate({ createSuccessNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); const { - setTemplate - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const { homeUrl } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { @@ -15943,7 +15379,7 @@ function NewTemplate({ description, slug } = template; - const newTemplate = await saveEntityRecord('postType', TEMPLATE_POST_TYPE, { + const newTemplate = await saveEntityRecord('postType', constants_TEMPLATE_POST_TYPE, { description, // Slugs need to be strings, so this is for template `404` slug: slug.toString(), @@ -15955,9 +15391,6 @@ function NewTemplate({ throwOnError: true }); - // Set template before navigating away to avoid initial stale value. - setTemplate(newTemplate.id, newTemplate.slug); - // Navigate to the created template editor. history.push({ postId: newTemplate.id, @@ -15998,12 +15431,12 @@ function NewTemplate({ } else if (modalContent === modalContentMap.customGenericTemplate) { modalTitle = (0,external_wp_i18n_namespaceObject.__)('Create custom template'); } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isCreatingTemplate && (0,external_wp_element_namespaceObject.createElement)(TemplateActionsLoadingScreen, null), (0,external_wp_element_namespaceObject.createElement)(Toggle, { + return (0,external_React_.createElement)(external_React_.Fragment, null, isCreatingTemplate && (0,external_React_.createElement)(TemplateActionsLoadingScreen, null), (0,external_React_.createElement)(Toggle, { ...restToggleProps, onClick: () => setShowModal(true), icon: showIcon ? library_plus : null, label: postType.labels.add_new_item - }, showIcon ? null : postType.labels.add_new_item), showModal && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { + }, showIcon ? null : postType.labels.add_new_item), showModal && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { title: modalTitle, className: classnames_default()('edit-site-add-new-template__modal', { 'edit-site-add-new-template__modal_template_list': modalContent === modalContentMap.templatesList, @@ -16011,13 +15444,13 @@ function NewTemplate({ }), onRequestClose: onModalClose, overlayClassName: modalContent === modalContentMap.customGenericTemplate ? 'edit-site-custom-generic-template__modal' : undefined - }, modalContent === modalContentMap.templatesList && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalGrid, { + }, modalContent === modalContentMap.templatesList && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalGrid, { columns: 3, gap: 4, align: "flex-start", justify: "center", className: "edit-site-add-new-template__template-list__contents" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { className: "edit-site-add-new-template__template-list__prompt" }, (0,external_wp_i18n_namespaceObject.__)('Select what the new template should apply to:')), missingTemplates.map(template => { const { @@ -16025,7 +15458,7 @@ function NewTemplate({ slug, onClick } = template; - return (0,external_wp_element_namespaceObject.createElement)(TemplateListItem, { + return (0,external_React_.createElement)(TemplateListItem, { key: slug, title: title, direction: "column", @@ -16034,18 +15467,18 @@ function NewTemplate({ icon: TEMPLATE_ICONS[slug] || library_layout, onClick: () => onClick ? onClick(template) : createTemplate(template) }); - }), (0,external_wp_element_namespaceObject.createElement)(TemplateListItem, { + }), (0,external_React_.createElement)(TemplateListItem, { title: (0,external_wp_i18n_namespaceObject.__)('Custom template'), direction: "row", className: "edit-site-add-new-template__custom-template-button", icon: edit, onClick: () => setModalContent(modalContentMap.customGenericTemplate) - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { lineHeight: 1.53846153846 // 20px - }, (0,external_wp_i18n_namespaceObject.__)('A custom template can be manually applied to any post or page.')))), modalContent === modalContentMap.customTemplate && (0,external_wp_element_namespaceObject.createElement)(add_custom_template_modal_content, { + }, (0,external_wp_i18n_namespaceObject.__)('A custom template can be manually applied to any post or page.')))), modalContent === modalContentMap.customTemplate && (0,external_React_.createElement)(add_custom_template_modal_content, { onSelect: createTemplate, entityForSuggestions: entityForSuggestions - }), modalContent === modalContentMap.customGenericTemplate && (0,external_wp_element_namespaceObject.createElement)(add_custom_generic_template_modal_content, { + }), modalContent === modalContentMap.customGenericTemplate && (0,external_React_.createElement)(add_custom_generic_template_modal_content, { onClose: onModalClose, createTemplate: createTemplate }))); @@ -16113,15 +15546,15 @@ function useMissingTemplates(setEntityForSuggestions, onClick) { function AddNewTemplate({ - templateType = TEMPLATE_POST_TYPE, + templateType = constants_TEMPLATE_POST_TYPE, ...props }) { const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]); if (!postType) { return null; } - if (templateType === TEMPLATE_POST_TYPE) { - return (0,external_wp_element_namespaceObject.createElement)(NewTemplate, { + if (templateType === constants_TEMPLATE_POST_TYPE) { + return (0,external_React_.createElement)(NewTemplate, { ...props, postType: postType }); @@ -16158,7 +15591,7 @@ const TemplateItem = ({ postType, postId }); - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + return (0,external_React_.createElement)(SidebarNavigationItem, { ...linkInfo, ...props }); @@ -16168,36 +15601,201 @@ function SidebarNavigationScreenTemplates() { const { records: templates, isResolving: isLoading - } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', TEMPLATE_POST_TYPE, { + } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', constants_TEMPLATE_POST_TYPE, { per_page: -1 }); - const sortedTemplates = templates ? [...templates] : []; - sortedTemplates.sort((a, b) => a.title.rendered.localeCompare(b.title.rendered)); const browseAllLink = useLink({ path: '/wp_template/all' }); const canCreate = !isMobileViewport; - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { + return (0,external_React_.createElement)(SidebarNavigationScreen, { title: (0,external_wp_i18n_namespaceObject.__)('Templates'), description: (0,external_wp_i18n_namespaceObject.__)('Express the layout of your site with templates.'), - actions: canCreate && (0,external_wp_element_namespaceObject.createElement)(AddNewTemplate, { - templateType: TEMPLATE_POST_TYPE, + actions: canCreate && (0,external_React_.createElement)(AddNewTemplate, { + templateType: constants_TEMPLATE_POST_TYPE, toggleProps: { as: SidebarButton } }), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isLoading && (0,external_wp_i18n_namespaceObject.__)('Loading templates…'), !isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, !templates?.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No templates found')), sortedTemplates.map(template => (0,external_wp_element_namespaceObject.createElement)(TemplateItem, { - postType: TEMPLATE_POST_TYPE, - postId: template.id, - key: template.id, - withChevron: true - }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title?.rendered || template.slug))))), - footer: !isMobileViewport && (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + content: (0,external_React_.createElement)(external_React_.Fragment, null, isLoading && (0,external_wp_i18n_namespaceObject.__)('Loading templates…'), !isLoading && (0,external_React_.createElement)(SidebarTemplatesList, { + templates: templates + })), + footer: !isMobileViewport && (0,external_React_.createElement)(SidebarNavigationItem, { withChevron: true, ...browseAllLink }, (0,external_wp_i18n_namespaceObject.__)('Manage all templates')) }); } +function TemplatesGroup({ + title, + templates +}) { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, !!title && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, { + className: "edit-site-sidebar-navigation-screen-templates__templates-group-title" + }, title), templates.map(template => (0,external_React_.createElement)(TemplateItem, { + postType: constants_TEMPLATE_POST_TYPE, + postId: template.id, + key: template.id, + withChevron: true + }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title?.rendered || template.slug)))); +} +function SidebarTemplatesList({ + templates +}) { + if (!templates?.length) { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No templates found'))); + } + const sortedTemplates = templates ? [...templates] : []; + sortedTemplates.sort((a, b) => a.title.rendered.localeCompare(b.title.rendered)); + const { + hierarchyTemplates, + customTemplates, + ...plugins + } = sortedTemplates.reduce((accumulator, template) => { + const { + original_source: originalSource, + author_text: authorText + } = template; + if (originalSource === 'plugin') { + if (!accumulator[authorText]) { + accumulator[authorText] = []; + } + accumulator[authorText].push(template); + } else if (template.is_custom) { + accumulator.customTemplates.push(template); + } else { + accumulator.hierarchyTemplates.push(template); + } + return accumulator; + }, { + hierarchyTemplates: [], + customTemplates: [] + }); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: 3 + }, !!hierarchyTemplates.length && (0,external_React_.createElement)(TemplatesGroup, { + templates: hierarchyTemplates + }), !!customTemplates.length && (0,external_React_.createElement)(TemplatesGroup, { + title: (0,external_wp_i18n_namespaceObject.__)('Custom'), + templates: customTemplates + }), Object.entries(plugins).map(([plugin, pluginTemplates]) => { + return (0,external_React_.createElement)(TemplatesGroup, { + key: plugin, + title: plugin, + templates: pluginTemplates + }); + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-template/template-areas.js + +/** + * WordPress dependencies + */ + + + + + + + +/** + * Internal dependencies + */ + + + + + + +function TemplateAreaButton({ + postId, + area, + title +}) { + const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => { + const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(); + return defaultAreas.find(defaultArea => defaultArea.area === area); + }, [area]); + const linkInfo = useLink({ + postType: TEMPLATE_PART_POST_TYPE, + postId + }); + return (0,external_React_.createElement)(SidebarNavigationItem, { + className: "edit-site-sidebar-navigation-screen-template__template-area-button", + ...linkInfo, + icon: templatePartArea?.icon, + withChevron: true + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { + limit: 20, + ellipsizeMode: "tail", + numberOfLines: 1, + className: "edit-site-sidebar-navigation-screen-template__template-area-label-text" + }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title))); +} +function TemplateAreas() { + const { + templatePartAreas, + currentTemplateParts + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getSettings, + getCurrentTemplateTemplateParts + } = unlock(select(store_store)); + return { + templatePartAreas: getSettings()?.defaultTemplatePartAreas, + currentTemplateParts: getCurrentTemplateTemplateParts() + }; + }, []); + + /* + * Merge data in currentTemplateParts with templatePartAreas, + * which contains the template icon and fallback labels + */ + const templateAreas = (0,external_wp_element_namespaceObject.useMemo)(() => { + // Keep track of template part IDs that have already been added to the array. + const templatePartIds = new Set(); + const filterOutDuplicateTemplateParts = currentTemplatePart => { + // If the template part has already been added to the array, skip it. + if (templatePartIds.has(currentTemplatePart.templatePart.id)) { + return; + } + // Add to the array of template part IDs. + templatePartIds.add(currentTemplatePart.templatePart.id); + return currentTemplatePart; + }; + return currentTemplateParts.length && templatePartAreas ? currentTemplateParts.filter(filterOutDuplicateTemplateParts).map(({ + templatePart, + block + }) => ({ + ...templatePartAreas?.find(({ + area + }) => area === templatePart?.area), + ...templatePart, + clientId: block.clientId + })) : []; + }, [currentTemplateParts, templatePartAreas]); + if (!templateAreas.length) { + return null; + } + return (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { + title: (0,external_wp_i18n_namespaceObject.__)('Areas'), + spacing: 3 + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, templateAreas.map(({ + clientId, + label, + area, + theme, + slug, + title + }) => (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, { + key: clientId + }, (0,external_React_.createElement)(TemplateAreaButton, { + postId: `${theme}//${slug}`, + title: title?.rendered || label, + area: area + }))))); +} ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/use-edited-entity-record/index.js /** @@ -16259,13 +15857,13 @@ function useEditedEntityRecord(postType, postId) { * WordPress dependencies */ -const plugins = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const plugins = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_plugins = (plugins); +/* harmony default export */ const library_plugins = (plugins); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/globe.js @@ -16273,13 +15871,13 @@ const plugins = (0,external_wp_element_namespaceObject.createElement)(external_w * WordPress dependencies */ -const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const globe = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_globe = (globe); +/* harmony default export */ const library_globe = (globe); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/list/added-by.js @@ -16306,9 +15904,6 @@ const globe = (0,external_wp_element_namespaceObject.createElement)(external_wp_ /** @typedef {'wp_template'|'wp_template_part'} TemplateType */ -/** @type {TemplateType} */ -const TEMPLATE_POST_TYPE_NAMES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE]; - /** * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType * @@ -16327,64 +15922,56 @@ const TEMPLATE_POST_TYPE_NAMES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE]; function useAddedBy(postType, postId) { return (0,external_wp_data_namespaceObject.useSelect)(select => { const { - getTheme, - getPlugin, getEntityRecord, getMedia, getUser, getEditedEntityRecord } = select(external_wp_coreData_namespaceObject.store); const template = getEditedEntityRecord('postType', postType, postId); - if (TEMPLATE_POST_TYPE_NAMES.includes(template.type)) { - // Added by theme. - // Template originally provided by a theme, but customized by a user. - // Templates originally didn't have the 'origin' field so identify - // older customized templates by checking for no origin and a 'theme' - // or 'custom' source. - if (template.has_theme_file && (template.origin === TEMPLATE_ORIGINS.theme || !template.origin && [TEMPLATE_ORIGINS.theme, TEMPLATE_ORIGINS.custom].includes(template.source))) { - return { - type: 'theme', - icon: library_layout, - text: getTheme(template.theme)?.name?.rendered || template.theme, - isCustomized: template.source === TEMPLATE_ORIGINS.custom - }; - } - - // Added by plugin. - if (template.has_theme_file && template.origin === TEMPLATE_ORIGINS.plugin) { - return { - type: TEMPLATE_ORIGINS.plugin, - icon: library_plugins, - text: getPlugin(template.theme)?.name || template.theme, - isCustomized: template.source === TEMPLATE_ORIGINS.custom - }; - } - - // Added by site. - // Template was created from scratch, but has no author. Author support - // was only added to templates in WordPress 5.9. Fallback to showing the - // site logo and title. - if (!template.has_theme_file && template.source === TEMPLATE_ORIGINS.custom && !template.author) { - const siteData = getEntityRecord('root', '__unstableBase'); - return { - type: 'site', - icon: library_globe, - imageUrl: siteData?.site_logo ? getMedia(siteData.site_logo)?.source_url : undefined, - text: siteData?.name, - isCustomized: false - }; - } + const originalSource = template?.original_source; + const authorText = template?.author_text; + switch (originalSource) { + case 'theme': + { + return { + type: originalSource, + icon: library_layout, + text: authorText, + isCustomized: template.source === TEMPLATE_ORIGINS.custom + }; + } + case 'plugin': + { + return { + type: originalSource, + icon: library_plugins, + text: authorText, + isCustomized: template.source === TEMPLATE_ORIGINS.custom + }; + } + case 'site': + { + const siteData = getEntityRecord('root', '__unstableBase'); + return { + type: originalSource, + icon: library_globe, + imageUrl: siteData?.site_logo ? getMedia(siteData.site_logo)?.source_url : undefined, + text: authorText, + isCustomized: false + }; + } + default: + { + const user = getUser(template.author); + return { + type: 'user', + icon: comment_author_avatar, + imageUrl: user?.avatar_urls?.[48], + text: authorText, + isCustomized: false + }; + } } - - // Added by user. - const user = getUser(template.author); - return { - type: 'user', - icon: comment_author_avatar, - imageUrl: user?.avatar_urls?.[48], - text: user?.nickname, - isCustomized: false - }; }, [postType, postId]); } @@ -16396,11 +15983,11 @@ function AvatarImage({ imageUrl }) { const [isImageLoaded, setIsImageLoaded] = (0,external_wp_element_namespaceObject.useState)(false); - return (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)("div", { className: classnames_default()('edit-site-list-added-by__avatar', { 'is-loaded': isImageLoaded }) - }, (0,external_wp_element_namespaceObject.createElement)("img", { + }, (0,external_React_.createElement)("img", { onLoad: () => setIsImageLoaded(true), alt: "", src: imageUrl @@ -16422,17 +16009,17 @@ function AddedBy({ imageUrl, isCustomized } = useAddedBy(postType, postId); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + return createElement(HStack, { alignment: "left" - }, imageUrl ? (0,external_wp_element_namespaceObject.createElement)(AvatarImage, { + }, imageUrl ? createElement(AvatarImage, { imageUrl: imageUrl - }) : (0,external_wp_element_namespaceObject.createElement)("div", { + }) : createElement("div", { className: "edit-site-list-added-by__icon" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { + }, createElement(Icon, { icon: icon - })), (0,external_wp_element_namespaceObject.createElement)("span", null, text, isCustomized && (0,external_wp_element_namespaceObject.createElement)("span", { + })), createElement("span", null, text, isCustomized && createElement("span", { className: "edit-site-list-added-by__customized-info" - }, postType === TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject._x)('Customized', 'template') : (0,external_wp_i18n_namespaceObject._x)('Customized', 'template part')))); + }, postType === TEMPLATE_POST_TYPE ? _x('Customized', 'template') : _x('Customized', 'template part')))); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/is-template-removable.js @@ -16486,7 +16073,7 @@ function RenameMenuItem({ createSuccessNotice, createErrorNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - if (template.type === TEMPLATE_POST_TYPE && !template.is_custom) { + if (template.type === constants_TEMPLATE_POST_TYPE && !template.is_custom) { return null; } async function onTemplateRename(event) { @@ -16507,46 +16094,49 @@ function RenameMenuItem({ { throwOnError: true }); - createSuccessNotice(template.type === TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template renamed.') : (0,external_wp_i18n_namespaceObject.__)('Template part renamed.'), { + createSuccessNotice(template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template renamed.') : (0,external_wp_i18n_namespaceObject.__)('Template part renamed.'), { type: 'snackbar' }); } catch (error) { - const fallbackErrorMessage = template.type === TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template part.'); + const fallbackErrorMessage = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template part.'); const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; createErrorNotice(errorMessage, { type: 'snackbar' }); } } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { setIsModalOpen(true); setEditedTitle(title); } - }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { + }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { title: (0,external_wp_i18n_namespaceObject.__)('Rename'), onRequestClose: () => { setIsModalOpen(false); }, overlayClassName: "edit-site-list__rename-modal" - }, (0,external_wp_element_namespaceObject.createElement)("form", { + }, (0,external_React_.createElement)("form", { onSubmit: onTemplateRename - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: "5" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { __nextHasNoMarginBottom: true, + __next40pxDefaultSize: true, label: (0,external_wp_i18n_namespaceObject.__)('Name'), value: editedTitle, onChange: setEditedTitle, required: true - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "right" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + __next40pxDefaultSize: true, variant: "tertiary", onClick: () => { setIsModalOpen(false); } - }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + __next40pxDefaultSize: true, variant: "primary", type: "submit" }, (0,external_wp_i18n_namespaceObject.__)('Save'))))))); @@ -16610,31 +16200,31 @@ function TemplateActions({ id: 'edit-site-template-reverted' }); } catch (error) { - const fallbackErrorMessage = template.type === TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.'); + const fallbackErrorMessage = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.'); const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; createErrorNotice(errorMessage, { type: 'snackbar' }); } } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { icon: more_vertical, label: (0,external_wp_i18n_namespaceObject.__)('Actions'), className: className, toggleProps: toggleProps }, ({ onClose - }) => (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, { + }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, isRemovable && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(RenameMenuItem, { template: template, onClose: onClose - }), (0,external_wp_element_namespaceObject.createElement)(DeleteMenuItem, { + }), (0,external_React_.createElement)(DeleteMenuItem, { onRemove: () => { removeTemplate(template); onRemove?.(); onClose(); }, title: template.title.rendered - })), isRevertable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + })), isRevertable && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { info: (0,external_wp_i18n_namespaceObject.__)('Use the template as supplied by the theme.'), onClick: () => { revertAndSaveTemplate(); @@ -16647,10 +16237,10 @@ function DeleteMenuItem({ title }) { const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { isDestructive: true, onClick: () => setIsModalOpen(true) - }, (0,external_wp_i18n_namespaceObject.__)('Delete')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { + }, (0,external_wp_i18n_namespaceObject.__)('Delete')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { isOpen: isModalOpen, onConfirm: onRemove, onCancel: () => setIsModalOpen(false), @@ -16660,35 +16250,6 @@ function DeleteMenuItem({ (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)))); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/header.js - -/** - * WordPress dependencies - */ - -const header = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M18.5 10.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" -})); -/* harmony default export */ var library_header = (header); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/footer.js - -/** - * WordPress dependencies - */ - -const footer = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - fillRule: "evenodd", - d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" -})); -/* harmony default export */ var library_footer = (footer); - ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-template/home-template-details.js /** @@ -16701,72 +16262,31 @@ const footer = (0,external_wp_element_namespaceObject.createElement)(external_wp - - /** * Internal dependencies */ - - - - - const EMPTY_OBJECT = {}; -function TemplateAreaButton({ - postId, - icon, - title -}) { - var _icons$icon; - const icons = { - header: library_header, - footer: library_footer - }; - const linkInfo = useLink({ - postType: TEMPLATE_PART_POST_TYPE, - postId - }); - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { - className: "edit-site-sidebar-navigation-screen-template__template-area-button", - ...linkInfo, - icon: (_icons$icon = icons[icon]) !== null && _icons$icon !== void 0 ? _icons$icon : library_layout, - withChevron: true - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { - limit: 20, - ellipsizeMode: "tail", - numberOfLines: 1, - className: "edit-site-sidebar-navigation-screen-template__template-area-label-text" - }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title))); -} function HomeTemplateDetails() { const { editEntityRecord } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); const { allowCommentsOnNewPosts, - templatePartAreas, postsPerPage, postsPageTitle, - postsPageId, - currentTemplateParts + postsPageId } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { getEntityRecord } = select(external_wp_coreData_namespaceObject.store); - const { - getSettings, - getCurrentTemplateTemplateParts - } = unlock(select(store_store)); const siteSettings = getEntityRecord('root', 'site'); const _postsPageRecord = siteSettings?.page_for_posts ? getEntityRecord('postType', 'page', siteSettings?.page_for_posts) : EMPTY_OBJECT; return { allowCommentsOnNewPosts: siteSettings?.default_comment_status === 'open', postsPageTitle: _postsPageRecord?.title?.rendered, postsPageId: _postsPageRecord?.id, - postsPerPage: siteSettings?.posts_per_page, - templatePartAreas: getSettings()?.defaultTemplatePartAreas, - currentTemplateParts: getCurrentTemplateTemplateParts() + postsPerPage: siteSettings?.posts_per_page }; }, []); const [commentsOnNewPostsValue, setCommentsOnNewPostsValue] = (0,external_wp_element_namespaceObject.useState)(''); @@ -16783,23 +16303,6 @@ function HomeTemplateDetails() { setPostsPageTitleValue(postsPageTitle); setPostsCountValue(postsPerPage); }, [postsPageTitle, allowCommentsOnNewPosts, postsPerPage]); - - /* - * Merge data in currentTemplateParts with templatePartAreas, - * which contains the template icon and fallback labels - */ - const templateAreas = (0,external_wp_element_namespaceObject.useMemo)(() => { - return currentTemplateParts.length && templatePartAreas ? currentTemplateParts.map(({ - templatePart, - block - }) => ({ - ...templatePartAreas?.find(({ - area - }) => area === templatePart?.area), - ...templatePart, - clientId: block.clientId - })) : []; - }, [currentTemplateParts, templatePartAreas]); const setAllowCommentsOnNewPosts = newValue => { setCommentsOnNewPostsValue(newValue); editEntityRecord('root', 'site', undefined, { @@ -16818,9 +16321,9 @@ function HomeTemplateDetails() { posts_per_page: newValue }); }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanel, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { spacing: 6 - }, postsPageId && (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalInputControl, { + }, postsPageId && (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalInputControl, { className: "edit-site-sidebar-navigation-screen__input-control", placeholder: (0,external_wp_i18n_namespaceObject.__)('No Title'), size: '__unstable-large', @@ -16828,7 +16331,7 @@ function HomeTemplateDetails() { onChange: (0,external_wp_compose_namespaceObject.debounce)(setPostsPageTitle, 300), label: (0,external_wp_i18n_namespaceObject.__)('Blog title'), help: (0,external_wp_i18n_namespaceObject.__)('Set the Posts Page title. Appears in search results, and when the page is shared on social media.') - })), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, { + })), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, { className: "edit-site-sidebar-navigation-screen__input-control", placeholder: 0, value: postsCountValue, @@ -16839,32 +16342,16 @@ function HomeTemplateDetails() { onChange: setPostsPerPage, label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'), help: (0,external_wp_i18n_namespaceObject.__)('Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting.') - }))), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanel, { + }))), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { title: (0,external_wp_i18n_namespaceObject.__)('Discussion'), spacing: 3 - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, { + }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { className: "edit-site-sidebar-navigation-screen__input-control", label: (0,external_wp_i18n_namespaceObject.__)('Allow comments on new posts'), help: (0,external_wp_i18n_namespaceObject.__)('Changes will apply to new posts only. Individual posts may override these settings.'), checked: commentsOnNewPostsValue, onChange: setAllowCommentsOnNewPosts - }))), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanel, { - title: (0,external_wp_i18n_namespaceObject.__)('Areas'), - spacing: 3 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, templateAreas.map(({ - clientId, - label, - icon, - theme, - slug, - title - }) => (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelRow, { - key: clientId - }, (0,external_wp_element_namespaceObject.createElement)(TemplateAreaButton, { - postId: `${theme}//${slug}`, - title: title?.rendered || label, - icon: icon - })))))); + })))); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-template/index.js @@ -16889,6 +16376,7 @@ function HomeTemplateDetails() { + function useTemplateDetails(postType, postId) { const { getDescription, @@ -16903,24 +16391,24 @@ function useTemplateDetails(postType, postId) { if (!descriptionText && addedBy.text) { descriptionText = (0,external_wp_i18n_namespaceObject.__)('This is a custom template that can be applied manually to any Post or Page.'); } - const content = record?.slug === 'home' || record?.slug === 'index' ? (0,external_wp_element_namespaceObject.createElement)(HomeTemplateDetails, null) : null; - const footer = record?.modified ? (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsFooter, { + const content = record?.slug === 'home' || record?.slug === 'index' ? (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(HomeTemplateDetails, null), (0,external_React_.createElement)(TemplateAreas, null)) : (0,external_React_.createElement)(TemplateAreas, null); + const footer = record?.modified ? (0,external_React_.createElement)(SidebarNavigationScreenDetailsFooter, { record: record }) : null; - const description = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, descriptionText, addedBy.text && !isAddedByActiveTheme && (0,external_wp_element_namespaceObject.createElement)("span", { + const description = (0,external_React_.createElement)(external_React_.Fragment, null, descriptionText, addedBy.text && !isAddedByActiveTheme && (0,external_React_.createElement)("span", { className: "edit-site-sidebar-navigation-screen-template__added-by-description" - }, (0,external_wp_element_namespaceObject.createElement)("span", { + }, (0,external_React_.createElement)("span", { className: "edit-site-sidebar-navigation-screen-template__added-by-description-author" - }, (0,external_wp_element_namespaceObject.createElement)("span", { + }, (0,external_React_.createElement)("span", { className: "edit-site-sidebar-navigation-screen-template__added-by-description-author-icon" - }, addedBy.imageUrl ? (0,external_wp_element_namespaceObject.createElement)("img", { + }, addedBy.imageUrl ? (0,external_React_.createElement)("img", { src: addedBy.imageUrl, alt: "", width: "24", height: "24" - }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { + }) : (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { icon: addedBy.icon - })), addedBy.text), addedBy.isCustomized && (0,external_wp_element_namespaceObject.createElement)("span", { + })), addedBy.text), addedBy.isCustomized && (0,external_React_.createElement)("span", { className: "edit-site-sidebar-navigation-screen-template__added-by-description-customized" }, (0,external_wp_i18n_namespaceObject._x)('(Customized)', 'template')))); return { @@ -16947,9 +16435,9 @@ function SidebarNavigationScreenTemplate() { description, footer } = useTemplateDetails(postType, postId); - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { + return (0,external_React_.createElement)(SidebarNavigationScreen, { title: title, - actions: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(TemplateActions, { + actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(TemplateActions, { postType: postType, postId: postId, toggleProps: { @@ -16958,7 +16446,7 @@ function SidebarNavigationScreenTemplate() { onRemove: () => { navigator.goTo(`/${postType}/all`); } - }), (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + }), (0,external_React_.createElement)(SidebarButton, { onClick: () => setCanvasMode('edit'), label: (0,external_wp_i18n_namespaceObject.__)('Edit'), icon: library_pencil @@ -16975,13 +16463,15 @@ function SidebarNavigationScreenTemplate() { * WordPress dependencies */ -const file = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const file = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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.5z" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" })); -/* harmony default export */ var library_file = (file); +/* harmony default export */ const library_file = (file); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol-filled.js @@ -16989,13 +16479,13 @@ const file = (0,external_wp_element_namespaceObject.createElement)(external_wp_p * WordPress dependencies */ -const symbolFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const symbolFilled = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var symbol_filled = (symbolFilled); +/* harmony default export */ const symbol_filled = (symbolFilled); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js @@ -17003,13 +16493,13 @@ const symbolFilled = (0,external_wp_element_namespaceObject.createElement)(exter * WordPress dependencies */ -const upload = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const upload = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" })); -/* harmony default export */ var library_upload = (upload); +/* harmony default export */ const library_upload = (upload); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/template-part-create.js /** @@ -17088,10 +16578,25 @@ const getCleanTemplatePartSlug = title => { function CreateTemplatePartModal({ - closeModal, + modalTitle = (0,external_wp_i18n_namespaceObject.__)('Create template part'), + ...restProps +}) { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { + title: modalTitle, + onRequestClose: restProps.closeModal, + overlayClassName: "edit-site-create-template-part-modal" + }, (0,external_React_.createElement)(CreateTemplatePartModalContents, { + ...restProps + })); +} +function CreateTemplatePartModalContents({ + defaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY, blocks = [], + confirmLabel = (0,external_wp_i18n_namespaceObject.__)('Create'), + closeModal, onCreate, - onError + onError, + defaultTitle = '' }) { const { createErrorNotice @@ -17100,8 +16605,8 @@ function CreateTemplatePartModal({ saveEntityRecord } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); const existingTemplateParts = useExistingTemplateParts(); - const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); - const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(TEMPLATE_PART_AREA_DEFAULT_CATEGORY); + const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(defaultTitle); + const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(defaultArea); const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false); const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal); const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []); @@ -17134,28 +16639,24 @@ function CreateTemplatePartModal({ setIsSubmitting(false); } } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { - title: (0,external_wp_i18n_namespaceObject.__)('Create template part'), - onRequestClose: closeModal, - overlayClassName: "edit-site-create-template-part-modal" - }, (0,external_wp_element_namespaceObject.createElement)("form", { + return (0,external_React_.createElement)("form", { onSubmit: async event => { event.preventDefault(); await createTemplatePart(); } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: "4" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { __nextHasNoMarginBottom: true, label: (0,external_wp_i18n_namespaceObject.__)('Name'), value: title, onChange: setTitle, required: true - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.BaseControl, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.BaseControl, { label: (0,external_wp_i18n_namespaceObject.__)('Area'), id: `edit-site-create-template-part-modal__area-selection-${instanceId}`, className: "edit-site-create-template-part-modal__area-base-control" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalRadioGroup, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalRadioGroup, { label: (0,external_wp_i18n_namespaceObject.__)('Area'), className: "edit-site-create-template-part-modal__area-radio-group", id: `edit-site-create-template-part-modal__area-selection-${instanceId}`, @@ -17166,34 +16667,227 @@ function CreateTemplatePartModal({ label, area: value, description - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalRadio, { + }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalRadio, { key: label, value: value, className: "edit-site-create-template-part-modal__area-radio" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { align: "start", justify: "start" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { icon: icon - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, { + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, { className: "edit-site-create-template-part-modal__option-label" - }, label, (0,external_wp_element_namespaceObject.createElement)("div", null, description)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, { + }, label, (0,external_React_.createElement)("div", null, description)), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { className: "edit-site-create-template-part-modal__checkbox" - }, area === value && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { + }, area === value && (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { icon: library_check - }))))))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }))))))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "right" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "tertiary", onClick: () => { closeModal(); } - }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", type: "submit", "aria-disabled": !title || isSubmitting, isBusy: isSubmitting - }, (0,external_wp_i18n_namespaceObject.__)('Create')))))); + }, confirmLabel)))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-pattern/index.js + +/** + * WordPress dependencies + */ + + + + + + + + + + +/** + * Internal dependencies + */ + + + + +const { + useHistory: add_new_pattern_useHistory, + useLocation: add_new_pattern_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); +const { + CreatePatternModal, + useAddPatternCategory +} = unlock(external_wp_patterns_namespaceObject.privateApis); +function AddNewPattern() { + const history = add_new_pattern_useHistory(); + const { + params + } = add_new_pattern_useLocation(); + const [showPatternModal, setShowPatternModal] = (0,external_wp_element_namespaceObject.useState)(false); + const [showTemplatePartModal, setShowTemplatePartModal] = (0,external_wp_element_namespaceObject.useState)(false); + const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { + return select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme; + }, []); + const { + createPatternFromFile + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_patterns_namespaceObject.store)); + const { + createSuccessNotice, + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const patternUploadInputRef = (0,external_wp_element_namespaceObject.useRef)(); + function handleCreatePattern({ + pattern, + categoryId + }) { + setShowPatternModal(false); + history.push({ + postId: pattern.id, + postType: PATTERN_TYPES.user, + categoryType: PATTERN_TYPES.theme, + categoryId, + canvas: 'edit' + }); + } + function handleCreateTemplatePart(templatePart) { + setShowTemplatePartModal(false); + + // Navigate to the created template part editor. + history.push({ + postId: templatePart.id, + postType: TEMPLATE_PART_POST_TYPE, + canvas: 'edit' + }); + } + function handleError() { + setShowPatternModal(false); + setShowTemplatePartModal(false); + } + const controls = [{ + icon: library_symbol, + onClick: () => setShowPatternModal(true), + title: (0,external_wp_i18n_namespaceObject.__)('Create pattern') + }]; + if (isBlockBasedTheme) { + controls.push({ + icon: symbol_filled, + onClick: () => setShowTemplatePartModal(true), + title: (0,external_wp_i18n_namespaceObject.__)('Create template part') + }); + } + controls.push({ + icon: library_upload, + onClick: () => { + patternUploadInputRef.current.click(); + }, + title: (0,external_wp_i18n_namespaceObject.__)('Import pattern from JSON') + }); + const { + categoryMap, + findOrCreateTerm + } = useAddPatternCategory(); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + controls: controls, + toggleProps: { + as: SidebarButton + }, + icon: library_plus, + label: (0,external_wp_i18n_namespaceObject.__)('Create pattern') + }), showPatternModal && (0,external_React_.createElement)(CreatePatternModal, { + onClose: () => setShowPatternModal(false), + onSuccess: handleCreatePattern, + onError: handleError + }), showTemplatePartModal && (0,external_React_.createElement)(CreateTemplatePartModal, { + closeModal: () => setShowTemplatePartModal(false), + blocks: [], + onCreate: handleCreateTemplatePart, + onError: handleError + }), (0,external_React_.createElement)("input", { + type: "file", + accept: ".json", + hidden: true, + ref: patternUploadInputRef, + onChange: async event => { + const file = event.target.files?.[0]; + if (!file) return; + try { + let currentCategoryId; + // When we're not handling template parts, we should + // add or create the proper pattern category. + if (params.categoryType !== TEMPLATE_PART_POST_TYPE) { + const currentCategory = categoryMap.values().find(term => term.name === params.categoryId); + if (!!currentCategory) { + currentCategoryId = currentCategory.id || (await findOrCreateTerm(currentCategory.label)); + } + } + const pattern = await createPatternFromFile(file, currentCategoryId ? [currentCategoryId] : undefined); + + // Navigate to the All patterns category for the newly created pattern + // if we're not on that page already and if we're not in the `my-patterns` + // category. + if (!currentCategoryId && params.categoryId !== 'my-patterns') { + history.push({ + path: `/patterns`, + categoryType: PATTERN_TYPES.theme, + categoryId: PATTERN_DEFAULT_CATEGORY + }); + } + createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %s: The imported pattern's title. + (0,external_wp_i18n_namespaceObject.__)('Imported "%s" from JSON.'), pattern.title.raw), { + type: 'snackbar', + id: 'import-pattern-success' + }); + } catch (err) { + createErrorNotice(err.message, { + type: 'snackbar', + id: 'import-pattern-error' + }); + } finally { + event.target.value = ''; + } + } + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/category-item.js + +/** + * Internal dependencies + */ + + +function CategoryItem({ + count, + icon, + id, + isActive, + label, + type +}) { + const linkInfo = useLink({ + path: '/patterns', + categoryType: type, + categoryId: id + }); + if (!count) { + return; + } + return (0,external_React_.createElement)(SidebarNavigationItem, { + ...linkInfo, + icon: icon, + suffix: (0,external_React_.createElement)("span", null, count), + "aria-current": isActive ? 'true' : undefined + }, label); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js @@ -17248,12 +16942,310 @@ function useThemePatterns() { return (_getSettings$__experi = getSettings().__experimentalAdditionalBlockPatterns) !== null && _getSettings$__experi !== void 0 ? _getSettings$__experi : getSettings().__experimentalBlockPatterns; }); const restBlockPatterns = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getBlockPatterns()); - const patterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !PATTERN_CORE_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false), [blockPatterns, restBlockPatterns]); + const patterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false), [blockPatterns, restBlockPatterns]); return patterns; } +;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js + + +/** @typedef {(...args: any[]) => *[]} GetDependants */ + +/** @typedef {() => void} Clear */ + +/** + * @typedef {{ + * getDependants: GetDependants, + * clear: Clear + * }} EnhancedSelector + */ + +/** + * Internal cache entry. + * + * @typedef CacheNode + * + * @property {?CacheNode|undefined} [prev] Previous node. + * @property {?CacheNode|undefined} [next] Next node. + * @property {*[]} args Function arguments for cache entry. + * @property {*} val Function result. + */ + +/** + * @typedef Cache + * + * @property {Clear} clear Function to clear cache. + * @property {boolean} [isUniqueByDependants] Whether dependants are valid in + * considering cache uniqueness. A cache is unique if dependents are all arrays + * or objects. + * @property {CacheNode?} [head] Cache head. + * @property {*[]} [lastDependants] Dependants from previous invocation. + */ + +/** + * Arbitrary value used as key for referencing cache object in WeakMap tree. + * + * @type {{}} + */ +var LEAF_KEY = {}; + +/** + * Returns the first argument as the sole entry in an array. + * + * @template T + * + * @param {T} value Value to return. + * + * @return {[T]} Value returned as entry in array. + */ +function arrayOf(value) { + return [value]; +} + +/** + * Returns true if the value passed is object-like, or false otherwise. A value + * is object-like if it can support property assignment, e.g. object or array. + * + * @param {*} value Value to test. + * + * @return {boolean} Whether value is object-like. + */ +function isObjectLike(value) { + return !!value && 'object' === typeof value; +} + +/** + * Creates and returns a new cache object. + * + * @return {Cache} Cache object. + */ +function createCache() { + /** @type {Cache} */ + var cache = { + clear: function () { + cache.head = null; + }, + }; + + return cache; +} + +/** + * Returns true if entries within the two arrays are strictly equal by + * reference from a starting index. + * + * @param {*[]} a First array. + * @param {*[]} b Second array. + * @param {number} fromIndex Index from which to start comparison. + * + * @return {boolean} Whether arrays are shallowly equal. + */ +function isShallowEqual(a, b, fromIndex) { + var i; + + if (a.length !== b.length) { + return false; + } + + for (i = fromIndex; i < a.length; i++) { + if (a[i] !== b[i]) { + return false; + } + } + + return true; +} + +/** + * Returns a memoized selector function. The getDependants function argument is + * called before the memoized selector and is expected to return an immutable + * reference or array of references on which the selector depends for computing + * its own return value. The memoize cache is preserved only as long as those + * dependant references remain the same. If getDependants returns a different + * reference(s), the cache is cleared and the selector value regenerated. + * + * @template {(...args: *[]) => *} S + * + * @param {S} selector Selector function. + * @param {GetDependants=} getDependants Dependant getter returning an array of + * references used in cache bust consideration. + */ +/* harmony default export */ function rememo(selector, getDependants) { + /** @type {WeakMap<*,*>} */ + var rootCache; + + /** @type {GetDependants} */ + var normalizedGetDependants = getDependants ? getDependants : arrayOf; + + /** + * Returns the cache for a given dependants array. When possible, a WeakMap + * will be used to create a unique cache for each set of dependants. This + * is feasible due to the nature of WeakMap in allowing garbage collection + * to occur on entries where the key object is no longer referenced. Since + * WeakMap requires the key to be an object, this is only possible when the + * dependant is object-like. The root cache is created as a hierarchy where + * each top-level key is the first entry in a dependants set, the value a + * WeakMap where each key is the next dependant, and so on. This continues + * so long as the dependants are object-like. If no dependants are object- + * like, then the cache is shared across all invocations. + * + * @see isObjectLike + * + * @param {*[]} dependants Selector dependants. + * + * @return {Cache} Cache object. + */ + function getCache(dependants) { + var caches = rootCache, + isUniqueByDependants = true, + i, + dependant, + map, + cache; + + for (i = 0; i < dependants.length; i++) { + dependant = dependants[i]; + + // Can only compose WeakMap from object-like key. + if (!isObjectLike(dependant)) { + isUniqueByDependants = false; + break; + } + + // Does current segment of cache already have a WeakMap? + if (caches.has(dependant)) { + // Traverse into nested WeakMap. + caches = caches.get(dependant); + } else { + // Create, set, and traverse into a new one. + map = new WeakMap(); + caches.set(dependant, map); + caches = map; + } + } + + // We use an arbitrary (but consistent) object as key for the last item + // in the WeakMap to serve as our running cache. + if (!caches.has(LEAF_KEY)) { + cache = createCache(); + cache.isUniqueByDependants = isUniqueByDependants; + caches.set(LEAF_KEY, cache); + } + + return caches.get(LEAF_KEY); + } + + /** + * Resets root memoization cache. + */ + function clear() { + rootCache = new WeakMap(); + } + + /* eslint-disable jsdoc/check-param-names */ + /** + * The augmented selector call, considering first whether dependants have + * changed before passing it to underlying memoize function. + * + * @param {*} source Source object for derivation. + * @param {...*} extraArgs Additional arguments to pass to selector. + * + * @return {*} Selector result. + */ + /* eslint-enable jsdoc/check-param-names */ + function callSelector(/* source, ...extraArgs */) { + var len = arguments.length, + cache, + node, + i, + args, + dependants; + + // Create copy of arguments (avoid leaking deoptimization). + args = new Array(len); + for (i = 0; i < len; i++) { + args[i] = arguments[i]; + } + + dependants = normalizedGetDependants.apply(null, args); + cache = getCache(dependants); + + // If not guaranteed uniqueness by dependants (primitive type), shallow + // compare against last dependants and, if references have changed, + // destroy cache to recalculate result. + if (!cache.isUniqueByDependants) { + if ( + cache.lastDependants && + !isShallowEqual(dependants, cache.lastDependants, 0) + ) { + cache.clear(); + } + + cache.lastDependants = dependants; + } + + node = cache.head; + while (node) { + // Check whether node arguments match arguments + if (!isShallowEqual(node.args, args, 1)) { + node = node.next; + continue; + } + + // At this point we can assume we've found a match + + // Surface matched node to head if not already + if (node !== cache.head) { + // Adjust siblings to point to each other. + /** @type {CacheNode} */ (node.prev).next = node.next; + if (node.next) { + node.next.prev = node.prev; + } + + node.next = cache.head; + node.prev = null; + /** @type {CacheNode} */ (cache.head).prev = node; + cache.head = node; + } + + // Return immediately + return node.val; + } + + // No cached value found. Continue to insertion phase: + + node = /** @type {CacheNode} */ ({ + // Generate the result from original function + val: selector.apply(null, args), + }); + + // Avoid including the source object in the cache. + args[0] = null; + node.args = args; + + // Don't need to check whether node is already head, since it would + // have been returned above already if it was + + // Shift existing head down list + if (cache.head) { + cache.head.prev = node; + node.next = cache.head; + } + + cache.head = node; + + return node.val; + } + + callSelector.getDependants = normalizedGetDependants; + callSelector.clear = clear; + clear(); + + return /** @type {S & EnhancedSelector} */ (callSelector); +} + // EXTERNAL MODULE: ./node_modules/remove-accents/index.js -var remove_accents = __webpack_require__(4793); +var remove_accents = __webpack_require__(9681); var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/search-items.js /** @@ -17287,7 +17279,6 @@ function extractWords(input = '') { // One lowercase or digit, followed by one uppercase. /([\p{Lu}\p{Lt}])([\p{Lu}\p{Lt}][\p{Ll}\p{Lo}])/gu // One uppercase followed by one uppercase and one lowercase. ], - stripRegexp: /(\p{C}|\p{P}|\p{S})+/giu // Anything that's not a punctuation, symbol or control/format character. }).split(' ').filter(Boolean); } @@ -17498,10 +17489,13 @@ const selectThemePatterns = rememo(select => { const { getSettings } = unlock(select(store_store)); + const { + getIsResolving + } = select(external_wp_coreData_namespaceObject.store); const settings = getSettings(); const blockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns; const restBlockPatterns = select(external_wp_coreData_namespaceObject.store).getBlockPatterns(); - const patterns = [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !PATTERN_CORE_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false).map(pattern => ({ + const patterns = [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false).map(pattern => ({ ...pattern, keywords: pattern.keywords || [], type: PATTERN_TYPES.theme, @@ -17511,22 +17505,24 @@ const selectThemePatterns = rememo(select => { })); return { patterns, - isResolving: false + isResolving: getIsResolving('getBlockPatterns') }; -}, select => [select(external_wp_coreData_namespaceObject.store).getBlockPatterns(), unlock(select(store_store)).getSettings()]); +}, select => [select(external_wp_coreData_namespaceObject.store).getBlockPatterns(), select(external_wp_coreData_namespaceObject.store).getIsResolving('getBlockPatterns'), unlock(select(store_store)).getSettings()]); const selectPatterns = rememo((select, categoryId, syncStatus, search = '') => { const { - patterns: themePatterns + patterns: themePatterns, + isResolving: isResolvingThemePatterns } = selectThemePatterns(select); const { - patterns: userPatterns + patterns: userPatterns, + isResolving: isResolvingUserPatterns } = selectUserPatterns(select); let patterns = [...(themePatterns || []), ...(userPatterns || [])]; if (syncStatus) { // User patterns can have their sync statuses checked directly // Non-user patterns are all unsynced for the time being. patterns = patterns.filter(pattern => { - return pattern.id ? pattern.syncStatus === syncStatus : syncStatus === PATTERN_SYNC_TYPES.unsynced; + return pattern.type === PATTERN_TYPES.user ? pattern.syncStatus === syncStatus : syncStatus === PATTERN_SYNC_TYPES.unsynced; }); } if (categoryId) { @@ -17541,22 +17537,33 @@ const selectPatterns = rememo((select, categoryId, syncStatus, search = '') => { } return { patterns, - isResolving: false + isResolving: isResolvingThemePatterns || isResolvingUserPatterns }; }, select => [selectThemePatterns(select), selectUserPatterns(select)]); -const patternBlockToPattern = (patternBlock, categories) => ({ - blocks: (0,external_wp_blocks_namespaceObject.parse)(patternBlock.content.raw, { + +/** + * Converts a post of type `wp_block` to a 'pattern item' that more closely + * matches the structure of theme provided patterns. + * + * @param {Object} patternPost The `wp_block` record being normalized. + * @param {Map} categories A Map of user created categories. + * + * @return {Object} The normalized item. + */ +const convertPatternPostToItem = (patternPost, categories) => ({ + blocks: (0,external_wp_blocks_namespaceObject.parse)(patternPost.content.raw, { __unstableSkipMigrationLogs: true }), - ...(patternBlock.wp_pattern_category.length > 0 && { - categories: patternBlock.wp_pattern_category.map(patternCategoryId => categories && categories.get(patternCategoryId) ? categories.get(patternCategoryId).slug : patternCategoryId) + ...(patternPost.wp_pattern_category.length > 0 && { + categories: patternPost.wp_pattern_category.map(patternCategoryId => categories && categories.get(patternCategoryId) ? categories.get(patternCategoryId).slug : patternCategoryId) }), - id: patternBlock.id, - name: patternBlock.slug, - syncStatus: patternBlock.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full, - title: patternBlock.title.raw, - type: PATTERN_TYPES.user, - patternBlock + termLabels: patternPost.wp_pattern_category.map(patternCategoryId => categories?.get(patternCategoryId) ? categories.get(patternCategoryId).label : patternCategoryId), + id: patternPost.id, + name: patternPost.slug, + syncStatus: patternPost.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full, + title: patternPost.title.raw, + type: patternPost.type, + patternPost }); const selectUserPatterns = rememo((select, syncStatus, search = '') => { const { @@ -17567,11 +17574,11 @@ const selectUserPatterns = rememo((select, syncStatus, search = '') => { const query = { per_page: -1 }; - const records = getEntityRecords('postType', PATTERN_TYPES.user, query); + const patternPosts = getEntityRecords('postType', PATTERN_TYPES.user, query); const userPatternCategories = getUserPatternCategories(); const categories = new Map(); userPatternCategories.forEach(userCategory => categories.set(userCategory.id, userCategory)); - let patterns = records ? records.map(record => patternBlockToPattern(record, categories)) : EMPTY_PATTERN_LIST; + let patterns = patternPosts ? patternPosts.map(record => convertPatternPostToItem(record, categories)) : EMPTY_PATTERN_LIST; const isResolving = getIsResolving('getEntityRecords', ['postType', PATTERN_TYPES.user, query]); if (syncStatus) { patterns = patterns.filter(pattern => pattern.syncStatus === syncStatus); @@ -17610,7 +17617,7 @@ const usePatterns = (categoryType, categoryId, { }; }, [categoryId, categoryType, search, syncStatus]); }; -/* harmony default export */ var use_patterns = (usePatterns); +/* harmony default export */ const use_patterns = (usePatterns); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js /** @@ -17700,7 +17707,7 @@ function usePatternCategories() { sortedCategories.unshift({ name: PATTERN_DEFAULT_CATEGORY, label: (0,external_wp_i18n_namespaceObject.__)('All patterns'), - description: (0,external_wp_i18n_namespaceObject.__)('A list of all patterns from all sources'), + description: (0,external_wp_i18n_namespaceObject.__)('A list of all patterns from all sources.'), count: themePatterns.length + userPatterns.length }); return sortedCategories; @@ -17711,189 +17718,6 @@ function usePatternCategories() { }; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-pattern/index.js - -/** - * WordPress dependencies - */ - - - - - - - - - - -/** - * Internal dependencies - */ - - - - - -const { - useHistory: add_new_pattern_useHistory, - useLocation: add_new_pattern_useLocation -} = unlock(external_wp_router_namespaceObject.privateApis); -const { - CreatePatternModal -} = unlock(external_wp_patterns_namespaceObject.privateApis); -function AddNewPattern() { - const history = add_new_pattern_useHistory(); - const { - params - } = add_new_pattern_useLocation(); - const [showPatternModal, setShowPatternModal] = (0,external_wp_element_namespaceObject.useState)(false); - const [showTemplatePartModal, setShowTemplatePartModal] = (0,external_wp_element_namespaceObject.useState)(false); - const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { - return select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme; - }, []); - const { - createPatternFromFile - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_patterns_namespaceObject.store)); - const { - createSuccessNotice, - createErrorNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - const patternUploadInputRef = (0,external_wp_element_namespaceObject.useRef)(); - const { - patternCategories - } = usePatternCategories(); - function handleCreatePattern({ - pattern, - categoryId - }) { - setShowPatternModal(false); - history.push({ - postId: pattern.id, - postType: PATTERN_TYPES.user, - categoryType: PATTERN_TYPES.theme, - categoryId, - canvas: 'edit' - }); - } - function handleCreateTemplatePart(templatePart) { - setShowTemplatePartModal(false); - - // Navigate to the created template part editor. - history.push({ - postId: templatePart.id, - postType: TEMPLATE_PART_POST_TYPE, - canvas: 'edit' - }); - } - function handleError() { - setShowPatternModal(false); - setShowTemplatePartModal(false); - } - const controls = [{ - icon: library_symbol, - onClick: () => setShowPatternModal(true), - title: (0,external_wp_i18n_namespaceObject.__)('Create pattern') - }]; - if (isBlockBasedTheme) { - controls.push({ - icon: symbol_filled, - onClick: () => setShowTemplatePartModal(true), - title: (0,external_wp_i18n_namespaceObject.__)('Create template part') - }); - } - controls.push({ - icon: library_upload, - onClick: () => { - patternUploadInputRef.current.click(); - }, - title: (0,external_wp_i18n_namespaceObject.__)('Import pattern from JSON') - }); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { - controls: controls, - toggleProps: { - as: SidebarButton - }, - icon: library_plus, - label: (0,external_wp_i18n_namespaceObject.__)('Create pattern') - }), showPatternModal && (0,external_wp_element_namespaceObject.createElement)(CreatePatternModal, { - onClose: () => setShowPatternModal(false), - onSuccess: handleCreatePattern, - onError: handleError - }), showTemplatePartModal && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, { - closeModal: () => setShowTemplatePartModal(false), - blocks: [], - onCreate: handleCreateTemplatePart, - onError: handleError - }), (0,external_wp_element_namespaceObject.createElement)("input", { - type: "file", - accept: ".json", - hidden: true, - ref: patternUploadInputRef, - onChange: async event => { - const file = event.target.files?.[0]; - if (!file) return; - try { - const currentCategoryId = params.categoryType !== TEMPLATE_PART_POST_TYPE && patternCategories.find(category => category.name === params.categoryId)?.id; - const pattern = await createPatternFromFile(file, currentCategoryId ? [currentCategoryId] : undefined); - - // Navigate to the All patterns category for the newly created pattern - // if we're not on that page already. - if (!currentCategoryId) { - history.push({ - path: `/patterns`, - categoryType: PATTERN_TYPES.theme, - categoryId: PATTERN_DEFAULT_CATEGORY - }); - } - createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %s: The imported pattern's title. - (0,external_wp_i18n_namespaceObject.__)('Imported "%s" from JSON.'), pattern.title.raw), { - type: 'snackbar', - id: 'import-pattern-success' - }); - } catch (err) { - createErrorNotice(err.message, { - type: 'snackbar', - id: 'import-pattern-error' - }); - } finally { - event.target.value = ''; - } - } - })); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/category-item.js - -/** - * Internal dependencies - */ - - -function CategoryItem({ - count, - icon, - id, - isActive, - label, - type -}) { - const linkInfo = useLink({ - path: '/patterns', - categoryType: type, - categoryId: id - }); - if (!count) { - return; - } - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { - ...linkInfo, - icon: icon, - suffix: (0,external_wp_element_namespaceObject.createElement)("span", null, count), - "aria-current": isActive ? 'true' : undefined - }, label); -} - ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js /** * WordPress dependencies @@ -17974,16 +17798,16 @@ function TemplatePartGroup({ currentArea, currentType }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { className: "edit-site-sidebar-navigation-screen-patterns__group-header" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { level: 2 - }, (0,external_wp_i18n_namespaceObject.__)('Template parts'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { + }, (0,external_wp_i18n_namespaceObject.__)('Template parts'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group" }, Object.entries(areas).map(([area, { label, templateParts - }]) => (0,external_wp_element_namespaceObject.createElement)(CategoryItem, { + }]) => (0,external_React_.createElement)(CategoryItem, { key: area, count: templateParts?.length, icon: (0,external_wp_editor_namespaceObject.getTemplatePartIcon)(area), @@ -17998,9 +17822,9 @@ function PatternCategoriesGroup({ currentCategory, currentType }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group" - }, categories.map(category => (0,external_wp_element_namespaceObject.createElement)(CategoryItem, { + }, categories.map(category => (0,external_React_.createElement)(CategoryItem, { key: category.name, count: category.count, label: category.label, @@ -18038,27 +17862,27 @@ function SidebarNavigationScreenPatterns() { // the Patterns page directly, preserve that state in the URL. didAccessPatternsPage: !isBlockBasedTheme && isTemplatePartsMode ? 1 : undefined }); - const footer = !isMobileViewport ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + const footer = !isMobileViewport ? (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(SidebarNavigationItem, { as: "a", href: "edit.php?post_type=wp_block", withChevron: true - }, (0,external_wp_i18n_namespaceObject.__)('Manage all of my patterns')), (isBlockBasedTheme || isTemplatePartsMode) && (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Manage all of my patterns')), (isBlockBasedTheme || isTemplatePartsMode) && (0,external_React_.createElement)(SidebarNavigationItem, { withChevron: true, ...templatePartsLink }, (0,external_wp_i18n_namespaceObject.__)('Manage all template parts'))) : undefined; - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { + return (0,external_React_.createElement)(SidebarNavigationScreen, { isRoot: !isBlockBasedTheme, title: (0,external_wp_i18n_namespaceObject.__)('Patterns'), description: (0,external_wp_i18n_namespaceObject.__)('Manage what patterns are available when editing the site.'), - actions: (0,external_wp_element_namespaceObject.createElement)(AddNewPattern, null), + actions: (0,external_React_.createElement)(AddNewPattern, null), footer: footer, - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isLoading && (0,external_wp_i18n_namespaceObject.__)('Loading patterns…'), !isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !hasTemplateParts && !hasPatterns && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { + content: (0,external_React_.createElement)(external_React_.Fragment, null, isLoading && (0,external_wp_i18n_namespaceObject.__)('Loading patterns…'), !isLoading && (0,external_React_.createElement)(external_React_.Fragment, null, !hasTemplateParts && !hasPatterns && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-patterns__group" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No template parts or patterns found'))), hasPatterns && (0,external_wp_element_namespaceObject.createElement)(PatternCategoriesGroup, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No template parts or patterns found'))), hasPatterns && (0,external_React_.createElement)(PatternCategoriesGroup, { categories: patternCategories, currentCategory: currentCategory, currentType: currentType - }), hasTemplateParts && (0,external_wp_element_namespaceObject.createElement)(TemplatePartGroup, { + }), hasTemplateParts && (0,external_React_.createElement)(TemplatePartGroup, { areas: templatePartAreas, currentArea: currentCategory, currentType: currentType @@ -18084,77 +17908,207 @@ function SidebarNavigationScreenPatterns() { const { useLocation: use_init_edited_entity_from_url_useLocation } = unlock(external_wp_router_namespaceObject.privateApis); -function useInitEditedEntityFromURL() { - const { - params: { - postId, - postType - } = {} - } = use_init_edited_entity_from_url_useLocation(); +const postTypesWithoutParentTemplate = [constants_TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, PATTERN_TYPES.user]; +function useResolveEditedEntityAndContext({ + path, + postId, + postType +}) { const { - isRequestingSite, + hasLoadedAllDependencies, homepageId, - url + url, + frontPageTemplateId } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { getSite, - getUnstableBase + getUnstableBase, + getEntityRecords } = select(external_wp_coreData_namespaceObject.store); const siteData = getSite(); const base = getUnstableBase(); + const templates = getEntityRecords('postType', constants_TEMPLATE_POST_TYPE, { + per_page: -1 + }); + let _frontPateTemplateId; + if (templates) { + const frontPageTemplate = templates.find(t => t.slug === 'front-page'); + _frontPateTemplateId = frontPageTemplate ? frontPageTemplate.id : false; + } return { - isRequestingSite: !base, - homepageId: siteData?.show_on_front === 'page' ? siteData.page_on_front : null, - url: base?.home + hasLoadedAllDependencies: !!base && !!siteData, + homepageId: siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_on_front) ? siteData.page_on_front.toString() : null, + url: base?.home, + frontPageTemplateId: _frontPateTemplateId }; }, []); - const { - setEditedEntity, - setTemplate, - setTemplatePart, - setPage, - setNavigationMenu - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (postType && postId) { - switch (postType) { - case TEMPLATE_POST_TYPE: - setTemplate(postId); - break; - case TEMPLATE_PART_POST_TYPE: - setTemplatePart(postId); - break; - case NAVIGATION_POST_TYPE: - setNavigationMenu(postId); - break; - case PATTERN_TYPES.user: - setEditedEntity(postType, postId); - break; - default: - setPage({ - context: { - postType, - postId - } - }); + + /** + * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId + * in order to match the frontend as closely as possible in the site editor. + * + * It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution. + */ + const resolvedTemplateId = (0,external_wp_data_namespaceObject.useSelect)(select => { + // If we're rendering a post type that doesn't have a template + // no need to resolve its template. + if (postTypesWithoutParentTemplate.includes(postType)) { + return undefined; + } + const { + getEditedEntityRecord, + getEntityRecords, + getDefaultTemplateId, + __experimentalGetTemplateForLink + } = select(external_wp_coreData_namespaceObject.store); + function resolveTemplateForPostTypeAndId(postTypeToResolve, postIdToResolve) { + // For the front page, we always use the front page template if existing. + if (postTypeToResolve === 'page' && homepageId === postIdToResolve) { + // We're still checking whether the front page template exists. + // Don't resolve the template yet. + if (frontPageTemplateId === undefined) { + return undefined; + } + if (!!frontPageTemplateId) { + return frontPageTemplateId; + } } - return; + const editedEntity = getEditedEntityRecord('postType', postTypeToResolve, postIdToResolve); + if (!editedEntity) { + return undefined; + } + // First see if the post/page has an assigned template and fetch it. + const currentTemplateSlug = editedEntity.template; + if (currentTemplateSlug) { + const currentTemplate = getEntityRecords('postType', constants_TEMPLATE_POST_TYPE, { + per_page: -1 + })?.find(({ + slug + }) => slug === currentTemplateSlug); + if (currentTemplate) { + return currentTemplate.id; + } + } + // If no template is assigned, use the default template. + let slugToCheck; + // In `draft` status we might not have a slug available, so we use the `single` + // post type templates slug(ex page, single-post, single-product etc..). + // Pages do not need the `single` prefix in the slug to be prioritized + // through template hierarchy. + if (editedEntity.slug) { + slugToCheck = postTypeToResolve === 'page' ? `${postTypeToResolve}-${editedEntity.slug}` : `single-${postTypeToResolve}-${editedEntity.slug}`; + } else { + slugToCheck = postTypeToResolve === 'page' ? 'page' : `single-${postTypeToResolve}`; + } + return getDefaultTemplateId({ + slug: slugToCheck + }); + } + if (!hasLoadedAllDependencies) { + return undefined; + } + + // If we're rendering a specific page, post... we need to resolve its template. + if (postType && postId) { + return resolveTemplateForPostTypeAndId(postType, postId); } - // In all other cases, we need to set the home page in the site editor view. + // Some URLs in list views are different + if (path === '/pages' && postId) { + return resolveTemplateForPostTypeAndId('page', postId); + } + + // If we're rendering the home page, and we have a static home page, resolve its template. if (homepageId) { - setPage({ - context: { - postType: 'page', - postId: homepageId - } - }); - } else if (!isRequestingSite) { - setPage({ - path: url - }); + return resolveTemplateForPostTypeAndId('page', homepageId); + } + + // If we're not rendering a specific page, use the front page template. + if (url) { + const template = __experimentalGetTemplateForLink(url); + return template?.id; + } + }, [homepageId, hasLoadedAllDependencies, url, postId, postType, path, frontPageTemplateId]); + const context = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (postTypesWithoutParentTemplate.includes(postType)) { + return {}; + } + if (postType && postId) { + return { + postType, + postId + }; + } + + // Some URLs in list views are different + if (path === '/pages' && postId) { + return { + postType: 'page', + postId + }; + } + if (homepageId) { + return { + postType: 'page', + postId: homepageId + }; } - }, [url, postId, postType, homepageId, isRequestingSite, setEditedEntity, setPage, setTemplate, setTemplatePart, setNavigationMenu]); + return {}; + }, [homepageId, postType, postId, path]); + if (path === '/wp_template/all' && postId) { + return { + isReady: true, + postType: 'wp_template', + postId, + context + }; + } + if (path === '/wp_template_part/all' && postId) { + return { + isReady: true, + postType: 'wp_template_part', + postId, + context + }; + } + if (postTypesWithoutParentTemplate.includes(postType)) { + return { + isReady: true, + postType, + postId, + context + }; + } + if (hasLoadedAllDependencies) { + return { + isReady: resolvedTemplateId !== undefined, + postType: constants_TEMPLATE_POST_TYPE, + postId: resolvedTemplateId, + context + }; + } + return { + isReady: false + }; +} +function useInitEditedEntityFromURL() { + const { + params = {} + } = use_init_edited_entity_from_url_useLocation(); + const { + postType, + postId, + context, + isReady + } = useResolveEditedEntityAndContext(params); + const { + setEditedEntity + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (isReady) { + setEditedEntity(postType, postId, context); + } + }, [isReady, postType, postId, context, setEditedEntity]); } ;// CONCATENATED MODULE: ./node_modules/upper-case-first/dist.es2015/index.js @@ -18186,13 +18140,13 @@ function sentenceCase(input, options) { * WordPress dependencies */ -const chevronUp = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const chevronUp = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" })); -/* harmony default export */ var chevron_up = (chevronUp); +/* harmony default export */ const chevron_up = (chevronUp); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-down.js @@ -18200,13 +18154,13 @@ const chevronUp = (0,external_wp_element_namespaceObject.createElement)(external * WordPress dependencies */ -const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const chevronDown = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" })); -/* harmony default export */ var chevron_down = (chevronDown); +/* harmony default export */ const chevron_down = (chevronDown); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sync-state-with-url/use-sync-path-with-url.js /** @@ -18233,7 +18187,7 @@ function getPathFromURL(urlParams) { if (urlParams?.postType && urlParams?.postId) { switch (urlParams.postType) { case PATTERN_TYPES.user: - case TEMPLATE_POST_TYPE: + case constants_TEMPLATE_POST_TYPE: case TEMPLATE_PART_POST_TYPE: case 'page': path = `/${encodeURIComponent(urlParams.postType)}/${encodeURIComponent(urlParams.postId)}`; @@ -18281,13 +18235,15 @@ function useSyncPathWithURL() { updateUrlParams({ postType: navigatorParams?.postType, postId: navigatorParams?.postId, - path: undefined + path: undefined, + layout: undefined }); } else if (navigatorLocation.path.startsWith('/page/') && navigatorParams?.postId) { updateUrlParams({ postType: 'page', postId: navigatorParams?.postId, - path: undefined + path: undefined, + layout: undefined }); } else if (navigatorLocation.path === '/patterns') { updateUrlParams({ @@ -18296,12 +18252,33 @@ function useSyncPathWithURL() { canvas: undefined, path: navigatorLocation.path }); + } else if (navigatorLocation.path === '/wp_template/all' && !window?.__experimentalAdminViews) { + // When the experiment is disabled, we only support table layout. + // Clear it out from the URL, so layouts other than table cannot be accessed. + updateUrlParams({ + postType: undefined, + categoryType: undefined, + categoryId: undefined, + path: navigatorLocation.path, + layout: undefined + }); + } else if ( + // These sidebar paths are special in the sense that the url in these pages may or may not have a postId and we need to retain it if it has. + // The "type" property should be kept as well. + navigatorLocation.path === '/pages' && window?.__experimentalAdminViews || navigatorLocation.path === '/wp_template/all' && window?.__experimentalAdminViews || navigatorLocation.path === '/wp_template_part/all' && window?.__experimentalAdminViews) { + updateUrlParams({ + postType: undefined, + categoryType: undefined, + categoryId: undefined, + path: navigatorLocation.path + }); } else { updateUrlParams({ postType: undefined, postId: undefined, categoryType: undefined, categoryId: undefined, + layout: undefined, path: navigatorLocation.path === '/' ? undefined : navigatorLocation.path }); } @@ -18406,7 +18383,7 @@ function LeafMoreMenu(props) { }); } }, [history]); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { icon: more_vertical, label: (0,external_wp_i18n_namespaceObject.__)('Options'), className: "block-editor-block-settings-menu", @@ -18415,24 +18392,24 @@ function LeafMoreMenu(props) { ...props }, ({ onClose - }) => (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, { + }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { icon: chevron_up, onClick: () => { moveBlocksUp([clientId], rootClientId); onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Move up')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Move up')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { icon: chevron_down, onClick: () => { moveBlocksDown([clientId], rootClientId); onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Move down')), block.attributes?.type === 'page' && block.attributes?.id && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Move down')), block.attributes?.type === 'page' && block.attributes?.id && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { onGoToPage(block); onClose(); } - }, goToLabel)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }, goToLabel)), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { removeBlocks([clientId], false); onClose(); @@ -18511,14 +18488,14 @@ function NavigationMenuContent({ // The hidden block is needed because it makes block edit side effects trigger. // For example a navigation page list load its items has an effect on edit to load its items. - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !isLoading && (0,external_wp_element_namespaceObject.createElement)(PrivateListView, { + return (0,external_React_.createElement)(external_React_.Fragment, null, !isLoading && (0,external_React_.createElement)(PrivateListView, { rootClientId: listViewRootClientId, onSelect: offCanvasOnselect, blockSettingsMenu: LeafMoreMenu, showAppender: false - }), (0,external_wp_element_namespaceObject.createElement)("div", { + }), (0,external_React_.createElement)("div", { className: "edit-site-sidebar-navigation-screen-navigation-menus__helper-block-editor" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, null))); + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockList, null))); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js @@ -18548,7 +18525,7 @@ function NavigationMenuEditor({ getSettings } = unlock(select(store_store)); return { - storedSettings: getSettings(false) + storedSettings: getSettings() }; }, []); const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => { @@ -18562,14 +18539,14 @@ function NavigationMenuEditor({ if (!navigationMenuId || !blocks?.length) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, { + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, { settings: storedSettings, value: blocks, onChange: navigation_menu_editor_noop, onInput: navigation_menu_editor_noop - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-sidebar-navigation-screen-navigation-menus__content" - }, (0,external_wp_element_namespaceObject.createElement)(NavigationMenuContent, { + }, (0,external_React_.createElement)(NavigationMenuContent, { rootClientId: blocks[0].clientId }))); } @@ -18617,12 +18594,12 @@ function TemplatePartNavigationMenu({ if (!id || title === undefined) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { className: "edit-site-sidebar-navigation-screen-template-part-navigation-menu__title", size: "11", upperCase: true, weight: 500 - }, title || (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_wp_element_namespaceObject.createElement)(NavigationMenuEditor, { + }, title || (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_React_.createElement)(NavigationMenuEditor, { navigationMenuId: id })); } @@ -18652,7 +18629,7 @@ function TemplatePartNavigationMenuListItem({ if (!id || title === undefined) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + return (0,external_React_.createElement)(SidebarNavigationItem, { withChevron: true, ...linkInfo }, title || (0,external_wp_i18n_namespaceObject.__)('(no title)')); @@ -18671,9 +18648,9 @@ function TemplatePartNavigationMenuListItem({ function TemplatePartNavigationMenuList({ menus }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { className: "edit-site-sidebar-navigation-screen-template-part-navigation-menu-list" - }, menus.map(menuId => (0,external_wp_element_namespaceObject.createElement)(TemplatePartNavigationMenuListItem, { + }, menus.map(menuId => (0,external_React_.createElement)(TemplatePartNavigationMenuListItem, { key: menuId, id: menuId }))); @@ -18698,18 +18675,18 @@ function TemplatePartNavigationMenus({ // if there is a single menu then render TemplatePartNavigationMenu if (menus.length === 1) { - return (0,external_wp_element_namespaceObject.createElement)(TemplatePartNavigationMenu, { + return (0,external_React_.createElement)(TemplatePartNavigationMenu, { id: menus[0] }); } // if there are multiple menus then render TemplatePartNavigationMenuList - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { className: "edit-site-sidebar-navigation-screen-template-part-navigation-menu__title", size: "11", upperCase: true, weight: 500 - }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_wp_element_namespaceObject.createElement)(TemplatePartNavigationMenuList, { + }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_React_.createElement)(TemplatePartNavigationMenuList, { menus: menus })); } @@ -18790,7 +18767,7 @@ function useNavigationMenuContent(postType, postId) { if (!uniqueNavigationMenuIds?.length) { return; } - return (0,external_wp_element_namespaceObject.createElement)(TemplatePartNavigationMenus, { + return (0,external_React_.createElement)(TemplatePartNavigationMenus, { menus: uniqueNavigationMenuIds }); } @@ -18855,14 +18832,14 @@ function usePatternDetails(postType, postId) { // translators: %s: user created pattern title e.g. "Footer". (0,external_wp_i18n_namespaceObject.__)('This is the %s pattern.'), record.title); } - const footer = record?.modified ? (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsFooter, { + const footer = record?.modified ? (0,external_React_.createElement)(SidebarNavigationScreenDetailsFooter, { record: record }) : null; const details = []; if (postType === PATTERN_TYPES.user || postType === TEMPLATE_PART_POST_TYPE) { details.push({ label: (0,external_wp_i18n_namespaceObject.__)('Syncing'), - value: record.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ? (0,external_wp_i18n_namespaceObject.__)('Not synced') : (0,external_wp_i18n_namespaceObject.__)('Fully synced') + value: record.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ? (0,external_wp_i18n_namespaceObject._x)('Not synced', 'Text that indicates that the pattern is not synchronized') : (0,external_wp_i18n_namespaceObject._x)('Synced', 'Text that indicates that the pattern is synchronized') }); if (record.wp_pattern_category?.length === 0) { details.push({ @@ -18896,7 +18873,7 @@ function usePatternDetails(postType, postId) { if (postType === TEMPLATE_PART_POST_TYPE && addedBy.text && !isAddedByActiveTheme) { details.push({ label: (0,external_wp_i18n_namespaceObject.__)('Added by'), - value: (0,external_wp_element_namespaceObject.createElement)("span", { + value: (0,external_React_.createElement)("span", { className: "edit-site-sidebar-navigation-screen-pattern__added-by-description-author" }, addedBy.text) }); @@ -18904,20 +18881,20 @@ function usePatternDetails(postType, postId) { if (postType === TEMPLATE_PART_POST_TYPE && addedBy.text && (record.origin === TEMPLATE_ORIGINS.plugin || record.has_theme_file === true)) { details.push({ label: (0,external_wp_i18n_namespaceObject.__)('Customized'), - value: (0,external_wp_element_namespaceObject.createElement)("span", { + value: (0,external_React_.createElement)("span", { className: "edit-site-sidebar-navigation-screen-pattern__added-by-description-customized" }, addedBy.isCustomized ? (0,external_wp_i18n_namespaceObject.__)('Yes') : (0,external_wp_i18n_namespaceObject.__)('No')) }); } - const content = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, useNavigationMenuContent(postType, postId), !!details.length && (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanel, { + const content = (0,external_React_.createElement)(external_React_.Fragment, null, useNavigationMenuContent(postType, postId), !!details.length && (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { spacing: 5, title: (0,external_wp_i18n_namespaceObject.__)('Details') }, details.map(({ label, value - }) => (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelRow, { + }) => (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, { key: label - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, label), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelValue, null, value))))); + }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, label), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelValue, null, value))))); return { title, description, @@ -18969,8 +18946,8 @@ function SidebarNavigationScreenPattern() { // indicates the user has arrived at the template part via the "manage all" // page and the back button should return them to that list page. const backPath = !categoryType && postType === TEMPLATE_PART_POST_TYPE ? '/wp_template_part/all' : '/patterns'; - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { - actions: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(TemplateActions, { + return (0,external_React_.createElement)(SidebarNavigationScreen, { + actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(TemplateActions, { postType: postType, postId: postId, toggleProps: { @@ -18979,7 +18956,7 @@ function SidebarNavigationScreenPattern() { onRemove: () => { navigator.goTo(backPath); } - }), (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + }), (0,external_React_.createElement)(SidebarButton, { onClick: () => setCanvasMode('edit'), label: (0,external_wp_i18n_namespaceObject.__)('Edit'), icon: library_pencil @@ -19021,24 +18998,27 @@ function RenameModal({ const [editedMenuTitle, setEditedMenuTitle] = (0,external_wp_element_namespaceObject.useState)(menuTitle); const titleHasChanged = editedMenuTitle !== menuTitle; const isEditedMenuTitleValid = titleHasChanged && notEmptyString(editedMenuTitle); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { title: (0,external_wp_i18n_namespaceObject.__)('Rename'), onRequestClose: onClose - }, (0,external_wp_element_namespaceObject.createElement)("form", { + }, (0,external_React_.createElement)("form", { className: "sidebar-navigation__rename-modal-form" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: "3" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { __nextHasNoMarginBottom: true, + __next40pxDefaultSize: true, value: editedMenuTitle, placeholder: (0,external_wp_i18n_namespaceObject.__)('Navigation title'), onChange: setEditedMenuTitle - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "right" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + __next40pxDefaultSize: true, variant: "tertiary", onClick: onClose - }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + __next40pxDefaultSize: true, disabled: !isEditedMenuTitleValid, variant: "primary", type: "submit", @@ -19068,7 +19048,7 @@ function delete_modal_RenameModal({ onClose, onConfirm }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { isOpen: true, onConfirm: e => { e.preventDefault(); @@ -19115,25 +19095,25 @@ function ScreenNavigationMoreMenu(props) { }; const openRenameModal = () => setRenameModalOpen(true); const openDeleteModal = () => setDeleteModalOpen(true); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { className: "sidebar-navigation__more-menu", label: (0,external_wp_i18n_namespaceObject.__)('Actions'), icon: more_vertical, popoverProps: more_menu_POPOVER_PROPS }, ({ onClose - }) => (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }) => (0,external_React_.createElement)("div", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { openRenameModal(); // Close the dropdown after opening the modal. onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Rename')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Rename')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { onDuplicate(); onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Duplicate')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Duplicate')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { isDestructive: true, onClick: () => { openDeleteModal(); @@ -19141,10 +19121,10 @@ function ScreenNavigationMoreMenu(props) { // Close the dropdown after opening the modal. onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Delete'))))), deleteModalOpen && (0,external_wp_element_namespaceObject.createElement)(delete_modal_RenameModal, { + }, (0,external_wp_i18n_namespaceObject.__)('Delete'))))), deleteModalOpen && (0,external_React_.createElement)(delete_modal_RenameModal, { onClose: closeModals, onConfirm: onDelete - }), renameModalOpen && (0,external_wp_element_namespaceObject.createElement)(RenameModal, { + }), renameModalOpen && (0,external_React_.createElement)(RenameModal, { onClose: closeModals, menuTitle: menuTitle, onSave: onSave @@ -19193,7 +19173,7 @@ function EditButton({ postType: NAVIGATION_POST_TYPE, canvas: 'edit' }); - return (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + return (0,external_React_.createElement)(SidebarButton, { ...linkInfo, label: (0,external_wp_i18n_namespaceObject.__)('Edit'), icon: library_pencil @@ -19222,18 +19202,18 @@ function SingleNavigationMenu({ handleSave }) { const menuTitle = navigationMenu?.title?.rendered; - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenWrapper, { - actions: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ScreenNavigationMoreMenu, { + return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { + actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(ScreenNavigationMoreMenu, { menuTitle: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuTitle), onDelete: handleDelete, onSave: handleSave, onDuplicate: handleDuplicate - }), (0,external_wp_element_namespaceObject.createElement)(EditButton, { + }), (0,external_React_.createElement)(EditButton, { postId: navigationMenu?.id })), title: buildNavigationLabel(navigationMenu?.title, navigationMenu?.id, navigationMenu?.status), description: (0,external_wp_i18n_namespaceObject.__)('Navigation menus are a curated collection of blocks that allow visitors to get around your site.') - }, (0,external_wp_element_namespaceObject.createElement)(NavigationMenuEditor, { + }, (0,external_React_.createElement)(NavigationMenuEditor, { navigationMenuId: navigationMenu?.id })); } @@ -19292,20 +19272,20 @@ function SidebarNavigationScreenNavigationMenu() { const _handleSave = edits => handleSave(navigationMenu, edits); const _handleDuplicate = () => handleDuplicate(navigationMenu); if (isLoading) { - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenWrapper, { + return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { description: (0,external_wp_i18n_namespaceObject.__)('Navigation menus are a curated collection of blocks that allow visitors to get around your site.') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, { className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" })); } if (!isLoading && !navigationMenu) { - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenWrapper, { + return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { description: (0,external_wp_i18n_namespaceObject.__)('Navigation Menu missing.') }); } if (!navigationMenu?.content?.raw) { - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenWrapper, { - actions: (0,external_wp_element_namespaceObject.createElement)(ScreenNavigationMoreMenu, { + return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { + actions: (0,external_React_.createElement)(ScreenNavigationMoreMenu, { menuTitle: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuTitle), onDelete: _handleDelete, onSave: _handleSave, @@ -19315,7 +19295,7 @@ function SidebarNavigationScreenNavigationMenu() { description: (0,external_wp_i18n_namespaceObject.__)('This Navigation Menu is empty.') }); } - return (0,external_wp_element_namespaceObject.createElement)(SingleNavigationMenu, { + return (0,external_React_.createElement)(SingleNavigationMenu, { navigationMenu: navigationMenu, handleDelete: _handleDelete, handleSave: _handleSave, @@ -19534,30 +19514,30 @@ function SidebarNavigationScreenNavigationMenus() { } = useNavigationMenuHandlers(); const hasNavigationMenus = !!navigationMenus?.length; if (isLoading) { - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenWrapper, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, { + return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, { className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" })); } if (!isLoading && !hasNavigationMenus) { - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenWrapper, { + return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { description: (0,external_wp_i18n_namespaceObject.__)('No Navigation Menus found.') }); } // if single menu then render it if (navigationMenus?.length === 1) { - return (0,external_wp_element_namespaceObject.createElement)(SingleNavigationMenu, { + return (0,external_React_.createElement)(SingleNavigationMenu, { navigationMenu: firstNavigationMenu, handleDelete: () => handleDelete(firstNavigationMenu), handleDuplicate: () => handleDuplicate(firstNavigationMenu), handleSave: edits => handleSave(firstNavigationMenu, edits) }); } - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenWrapper, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, navigationMenus?.map(({ + return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, navigationMenus?.map(({ id, title, status - }, index) => (0,external_wp_element_namespaceObject.createElement)(NavMenuItem, { + }, index) => (0,external_React_.createElement)(NavMenuItem, { postId: id, key: id, withChevron: true, @@ -19570,7 +19550,7 @@ function SidebarNavigationScreenWrapper({ title, description }) { - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { + return (0,external_React_.createElement)(SidebarNavigationScreen, { title: title || (0,external_wp_i18n_namespaceObject.__)('Navigation'), actions: actions, description: description || (0,external_wp_i18n_namespaceObject.__)('Manage your Navigation menus.'), @@ -19585,12 +19565,1363 @@ const NavMenuItem = ({ postId, postType: NAVIGATION_POST_TYPE }); - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + return (0,external_React_.createElement)(SidebarNavigationItem, { ...linkInfo, ...props }); }; +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-table.js + +/** + * WordPress dependencies + */ + +const blockTable = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + viewBox: "0 0 24 24", + xmlns: "http://www.w3.org/2000/svg" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" +})); +/* harmony default export */ const block_table = (blockTable); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-list-bullets-rtl.js + +/** + * WordPress dependencies + */ + +const formatListBulletsRTL = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" +})); +/* harmony default export */ const format_list_bullets_rtl = (formatListBulletsRTL); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-list-bullets.js + +/** + * WordPress dependencies + */ + +const formatListBullets = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" +})); +/* harmony default export */ const format_list_bullets = (formatListBullets); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/funnel.js + +/** + * WordPress dependencies + */ + +const funnel = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + viewBox: "0 0 24 24", + xmlns: "http://www.w3.org/2000/svg" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" +})); +/* harmony default export */ const library_funnel = (funnel); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/unseen.js + +/** + * WordPress dependencies + */ + +const unseen = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + viewBox: "0 0 24 24", + xmlns: "http://www.w3.org/2000/svg" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M4.67 10.664s-2.09 1.11-2.917 1.582l.494.87 1.608-.914.002.002c.343.502.86 1.17 1.563 1.84.348.33.742.663 1.185.976L5.57 16.744l.858.515 1.02-1.701a9.1 9.1 0 0 0 4.051 1.18V19h1v-2.263a9.1 9.1 0 0 0 4.05-1.18l1.021 1.7.858-.514-1.034-1.723c.442-.313.837-.646 1.184-.977.703-.669 1.22-1.337 1.563-1.839l.002-.003 1.61.914.493-.87c-1.75-.994-2.918-1.58-2.918-1.58l-.003.005a8.29 8.29 0 0 1-.422.689 10.097 10.097 0 0 1-1.36 1.598c-1.218 1.16-3.042 2.293-5.544 2.293-2.503 0-4.327-1.132-5.546-2.293a10.099 10.099 0 0 1-1.359-1.599 8.267 8.267 0 0 1-.422-.689l-.003-.005Z" +})); +/* harmony default export */ const library_unseen = (unseen); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/single-selection-checkbox.js + +/** + * WordPress dependencies + */ + + +function SingleSelectionCheckbox({ + selection, + onSelectionChange, + item, + data, + getItemId, + primaryField, + disabled +}) { + const id = getItemId(item); + const isSelected = selection.includes(id); + let selectionLabel; + if (primaryField?.getValue && item) { + // eslint-disable-next-line @wordpress/valid-sprintf + selectionLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: item title. */ + isSelected ? (0,external_wp_i18n_namespaceObject.__)('Deselect item: %s') : (0,external_wp_i18n_namespaceObject.__)('Select item: %s'), primaryField.getValue({ + item + })); + } else { + selectionLabel = isSelected ? (0,external_wp_i18n_namespaceObject.__)('Select a new item') : (0,external_wp_i18n_namespaceObject.__)('Deselect item'); + } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { + className: "dataviews-view-table-selection-checkbox", + __nextHasNoMarginBottom: true, + label: selectionLabel, + "aria-disabled": disabled, + checked: isSelected, + onChange: () => { + if (disabled) { + return; + } + if (!isSelected) { + onSelectionChange(data.filter(_item => { + const itemId = getItemId?.(_item); + return itemId === id || selection.includes(itemId); + })); + } else { + onSelectionChange(data.filter(_item => { + const itemId = getItemId?.(_item); + return itemId !== id && selection.includes(itemId); + })); + } + } + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/lock-unlock.js +/** + * WordPress dependencies + */ + +const { + lock: lock_unlock_lock, + unlock: lock_unlock_unlock +} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/dataviews'); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/item-actions.js + +/** + * WordPress dependencies + */ + + + + + +/** + * Internal dependencies + */ + +const { + DropdownMenuV2: DropdownMenu, + DropdownMenuGroupV2: DropdownMenuGroup, + DropdownMenuItemV2: DropdownMenuItem, + DropdownMenuItemLabelV2: DropdownMenuItemLabel, + kebabCase +} = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); +function ButtonTrigger({ + action, + onClick +}) { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + label: action.label, + icon: action.icon, + isDestructive: action.isDestructive, + size: "compact", + onClick: onClick + }); +} +function DropdownMenuItemTrigger({ + action, + onClick +}) { + return (0,external_React_.createElement)(DropdownMenuItem, { + onClick: onClick, + hideOnClick: !action.RenderModal + }, (0,external_React_.createElement)(DropdownMenuItemLabel, null, action.label)); +} +function ActionWithModal({ + action, + item, + ActionTrigger +}) { + const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); + const actionTriggerProps = { + action, + onClick: () => setIsModalOpen(true) + }; + const { + RenderModal, + hideModalHeader + } = action; + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(ActionTrigger, { + ...actionTriggerProps + }), isModalOpen && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { + title: action.modalHeader || action.label, + __experimentalHideHeader: !!hideModalHeader, + onRequestClose: () => { + setIsModalOpen(false); + }, + overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(action.id)}` + }, (0,external_React_.createElement)(RenderModal, { + items: [item], + closeModal: () => setIsModalOpen(false) + }))); +} +function ActionsDropdownMenuGroup({ + actions, + item +}) { + return (0,external_React_.createElement)(DropdownMenuGroup, null, actions.map(action => { + if (!!action.RenderModal) { + return (0,external_React_.createElement)(ActionWithModal, { + key: action.id, + action: action, + item: item, + ActionTrigger: DropdownMenuItemTrigger + }); + } + return (0,external_React_.createElement)(DropdownMenuItemTrigger, { + key: action.id, + action: action, + onClick: () => action.callback([item]) + }); + })); +} +function ItemActions({ + item, + actions, + isCompact +}) { + const { + primaryActions, + secondaryActions + } = (0,external_wp_element_namespaceObject.useMemo)(() => { + return actions.reduce((accumulator, action) => { + // If an action is eligible for all items, doesn't need + // to provide the `isEligible` function. + if (action.isEligible && !action.isEligible(item)) { + return accumulator; + } + if (action.isPrimary && !!action.icon) { + accumulator.primaryActions.push(action); + } else { + accumulator.secondaryActions.push(action); + } + return accumulator; + }, { + primaryActions: [], + secondaryActions: [] + }); + }, [actions, item]); + if (isCompact) { + return (0,external_React_.createElement)(CompactItemActions, { + item: item, + primaryActions: primaryActions, + secondaryActions: secondaryActions + }); + } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + spacing: 1, + justify: "flex-end", + style: { + flexShrink: '0', + width: 'auto' + } + }, !!primaryActions.length && primaryActions.map(action => { + if (!!action.RenderModal) { + return (0,external_React_.createElement)(ActionWithModal, { + key: action.id, + action: action, + item: item, + ActionTrigger: ButtonTrigger + }); + } + return (0,external_React_.createElement)(ButtonTrigger, { + key: action.id, + action: action, + onClick: () => action.callback([item]) + }); + }), (0,external_React_.createElement)(DropdownMenu, { + trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + size: "compact", + icon: more_vertical, + label: (0,external_wp_i18n_namespaceObject.__)('Actions'), + disabled: !secondaryActions.length + }), + placement: "bottom-end" + }, (0,external_React_.createElement)(ActionsDropdownMenuGroup, { + actions: secondaryActions, + item: item + }))); +} +function CompactItemActions({ + item, + primaryActions, + secondaryActions +}) { + return (0,external_React_.createElement)(DropdownMenu, { + trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + size: "compact", + icon: more_vertical, + label: (0,external_wp_i18n_namespaceObject.__)('Actions'), + disabled: !primaryActions.length && !secondaryActions.length + }), + placement: "bottom-end" + }, !!primaryActions.length && (0,external_React_.createElement)(ActionsDropdownMenuGroup, { + actions: primaryActions, + item: item + }), !!secondaryActions.length && (0,external_React_.createElement)(ActionsDropdownMenuGroup, { + actions: secondaryActions, + item: item + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/utils.js +/** + * Internal dependencies + */ + + +/** + * Helper util to sort data by text fields, when sorting is done client side. + * + * @param {Object} params Function params. + * @param {Object[]} params.data Data to sort. + * @param {Object} params.view Current view object. + * @param {Object[]} params.fields Array of available fields. + * @param {string[]} params.textFields Array of the field ids to sort. + * + * @return {Object[]} Sorted data. + */ +const sortByTextFields = ({ + data, + view, + fields, + textFields +}) => { + const sortedData = [...data]; + const fieldId = view.sort.field; + if (textFields.includes(fieldId)) { + const fieldToSort = fields.find(field => { + return field.id === fieldId; + }); + sortedData.sort((a, b) => { + var _fieldToSort$getValue, _fieldToSort$getValue2; + const valueA = (_fieldToSort$getValue = fieldToSort.getValue({ + item: a + })) !== null && _fieldToSort$getValue !== void 0 ? _fieldToSort$getValue : ''; + const valueB = (_fieldToSort$getValue2 = fieldToSort.getValue({ + item: b + })) !== null && _fieldToSort$getValue2 !== void 0 ? _fieldToSort$getValue2 : ''; + return view.sort.direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA); + }); + } + return sortedData; +}; + +/** + * Helper util to get the paginated data and the paginateInfo needed, + * when pagination is done client side. + * + * @param {Object} params Function params. + * @param {Object[]} params.data Available data. + * @param {Object} params.view Current view object. + * + * @return {Object} Paginated data and paginationInfo. + */ +function getPaginationResults({ + data, + view +}) { + const start = (view.page - 1) * view.perPage; + const totalItems = data?.length || 0; + data = data?.slice(start, start + view.perPage); + return { + data, + paginationInfo: { + totalItems, + totalPages: Math.ceil(totalItems / view.perPage) + } + }; +} +const sanitizeOperators = field => { + let operators = field.filterBy?.operators; + if (!operators || !Array.isArray(operators)) { + operators = Object.keys(OPERATORS); + } + return operators.filter(operator => Object.keys(OPERATORS).includes(operator)); +}; + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/bulk-actions.js + +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + +const { + DropdownMenuV2: bulk_actions_DropdownMenu, + DropdownMenuGroupV2: bulk_actions_DropdownMenuGroup, + DropdownMenuItemV2: bulk_actions_DropdownMenuItem, + DropdownMenuSeparatorV2: DropdownMenuSeparator +} = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); +function useHasAPossibleBulkAction(actions, item) { + return (0,external_wp_element_namespaceObject.useMemo)(() => { + return actions.some(action => { + return action.supportsBulk && action.isEligible(item); + }); + }, [actions, item]); +} +function useSomeItemHasAPossibleBulkAction(actions, data) { + return (0,external_wp_element_namespaceObject.useMemo)(() => { + return data.some(item => { + return actions.some(action => { + return action.supportsBulk && action.isEligible(item); + }); + }); + }, [actions, data]); +} +function bulk_actions_ActionWithModal({ + action, + selectedItems, + setActionWithModal, + onMenuOpenChange +}) { + const eligibleItems = (0,external_wp_element_namespaceObject.useMemo)(() => { + return selectedItems.filter(item => action.isEligible(item)); + }, [action, selectedItems]); + const { + RenderModal, + hideModalHeader + } = action; + const onCloseModal = (0,external_wp_element_namespaceObject.useCallback)(() => { + setActionWithModal(undefined); + }, [setActionWithModal]); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { + title: !hideModalHeader && action.label, + __experimentalHideHeader: !!hideModalHeader, + onRequestClose: onCloseModal, + overlayClassName: "dataviews-action-modal" + }, (0,external_React_.createElement)(RenderModal, { + items: eligibleItems, + closeModal: onCloseModal, + onPerform: () => onMenuOpenChange(false) + })); +} +function BulkActionItem({ + action, + selectedItems, + setActionWithModal +}) { + const eligibleItems = (0,external_wp_element_namespaceObject.useMemo)(() => { + return selectedItems.filter(item => action.isEligible(item)); + }, [action, selectedItems]); + const shouldShowModal = !!action.RenderModal; + return (0,external_React_.createElement)(bulk_actions_DropdownMenuItem, { + key: action.id, + disabled: eligibleItems.length === 0, + hideOnClick: !shouldShowModal, + onClick: async () => { + if (shouldShowModal) { + setActionWithModal(action); + } else { + await action.callback(eligibleItems); + } + }, + suffix: eligibleItems.length > 0 ? eligibleItems.length : undefined + }, action.label); +} +function ActionsMenuGroup({ + actions, + selectedItems, + setActionWithModal +}) { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(bulk_actions_DropdownMenuGroup, null, actions.map(action => (0,external_React_.createElement)(BulkActionItem, { + key: action.id, + action: action, + selectedItems: selectedItems, + setActionWithModal: setActionWithModal + }))), (0,external_React_.createElement)(DropdownMenuSeparator, null)); +} +function BulkActions({ + data, + actions, + selection, + onSelectionChange, + getItemId +}) { + const bulkActions = (0,external_wp_element_namespaceObject.useMemo)(() => actions.filter(action => action.supportsBulk), [actions]); + const [isMenuOpen, onMenuOpenChange] = (0,external_wp_element_namespaceObject.useState)(false); + const [actionWithModal, setActionWithModal] = (0,external_wp_element_namespaceObject.useState)(); + const selectableItems = (0,external_wp_element_namespaceObject.useMemo)(() => { + return data.filter(item => { + return bulkActions.some(action => action.isEligible(item)); + }); + }, [data, bulkActions]); + const numberSelectableItems = selectableItems.length; + const areAllSelected = selection && selection.length === numberSelectableItems; + const selectedItems = (0,external_wp_element_namespaceObject.useMemo)(() => { + return data.filter(item => selection.includes(getItemId(item))); + }, [selection, data, getItemId]); + const hasNonSelectableItemSelected = (0,external_wp_element_namespaceObject.useMemo)(() => { + return selectedItems.some(item => { + return !selectableItems.includes(item); + }); + }, [selectedItems, selectableItems]); + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (hasNonSelectableItemSelected) { + onSelectionChange(selectedItems.filter(selectedItem => { + return selectableItems.some(item => { + return getItemId(selectedItem) === getItemId(item); + }); + })); + } + }, [hasNonSelectableItemSelected, selectedItems, selectableItems, getItemId, onSelectionChange]); + if (bulkActions.length === 0) { + return null; + } + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(bulk_actions_DropdownMenu, { + open: isMenuOpen, + onOpenChange: onMenuOpenChange, + label: (0,external_wp_i18n_namespaceObject.__)('Bulk actions'), + style: { + minWidth: '240px' + }, + trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + className: "dataviews-bulk-edit-button", + __next40pxDefaultSize: true, + variant: "tertiary", + size: "compact" + }, selection.length ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: Number of items. */ + (0,external_wp_i18n_namespaceObject._n)('Edit %d item', 'Edit %d items', selection.length), selection.length) : (0,external_wp_i18n_namespaceObject.__)('Bulk edit')) + }, (0,external_React_.createElement)(ActionsMenuGroup, { + actions: bulkActions, + setActionWithModal: setActionWithModal, + selectedItems: selectedItems + }), (0,external_React_.createElement)(bulk_actions_DropdownMenuGroup, null, (0,external_React_.createElement)(bulk_actions_DropdownMenuItem, { + disabled: areAllSelected, + hideOnClick: false, + onClick: () => { + onSelectionChange(selectableItems); + }, + suffix: numberSelectableItems + }, (0,external_wp_i18n_namespaceObject.__)('Select all')), (0,external_React_.createElement)(bulk_actions_DropdownMenuItem, { + disabled: selection.length === 0, + hideOnClick: false, + onClick: () => { + onSelectionChange([]); + } + }, (0,external_wp_i18n_namespaceObject.__)('Deselect')))), actionWithModal && (0,external_React_.createElement)(bulk_actions_ActionWithModal, { + action: actionWithModal, + selectedItems: selectedItems, + setActionWithModal: setActionWithModal, + onMenuOpenChange: onMenuOpenChange + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/view-table.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + +/** + * Internal dependencies + */ + + + + + + +const { + DropdownMenuV2: view_table_DropdownMenu, + DropdownMenuGroupV2: view_table_DropdownMenuGroup, + DropdownMenuItemV2: view_table_DropdownMenuItem, + DropdownMenuRadioItemV2: DropdownMenuRadioItem, + DropdownMenuItemLabelV2: view_table_DropdownMenuItemLabel, + DropdownMenuSeparatorV2: view_table_DropdownMenuSeparator +} = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); +function WithSeparators({ + children +}) { + return external_wp_element_namespaceObject.Children.toArray(children).filter(Boolean).map((child, i) => (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, { + key: i + }, i > 0 && (0,external_React_.createElement)(view_table_DropdownMenuSeparator, null), child)); +} +const sortArrows = { + asc: '↑', + desc: '↓' +}; +const HeaderMenu = (0,external_wp_element_namespaceObject.forwardRef)(function HeaderMenu({ + field, + view, + onChangeView, + onHide, + setOpenedFilter +}, ref) { + const isHidable = field.enableHiding !== false; + const isSortable = field.enableSorting !== false; + const isSorted = view.sort?.field === field.id; + const operators = sanitizeOperators(field); + // Filter can be added: + // 1. If the field is not already part of a view's filters. + // 2. If the field meets the type and operator requirements. + // 3. If it's not primary. If it is, it should be already visible. + const canAddFilter = !view.filters?.some(_filter => field.id === _filter.field) && field.type === constants_ENUMERATION_TYPE && !!operators.length && !field.filterBy?.isPrimary; + if (!isSortable && !isHidable && !canAddFilter) { + return field.header; + } + return (0,external_React_.createElement)(view_table_DropdownMenu, { + align: "start", + trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + size: "compact", + className: "dataviews-view-table-header-button", + ref: ref, + variant: "tertiary" + }, field.header, isSorted && (0,external_React_.createElement)("span", { + "aria-hidden": "true" + }, isSorted && sortArrows[view.sort.direction])), + style: { + minWidth: '240px' + } + }, (0,external_React_.createElement)(WithSeparators, null, isSortable && (0,external_React_.createElement)(view_table_DropdownMenuGroup, null, Object.entries(SORTING_DIRECTIONS).map(([direction, info]) => { + const isChecked = isSorted && view.sort.direction === direction; + const value = `${field.id}-${direction}`; + return (0,external_React_.createElement)(DropdownMenuRadioItem, { + key: value + // All sorting radio items share the same name, so that + // selecting a sorting option automatically deselects the + // previously selected one, even if it is displayed in + // another submenu. The field and direction are passed via + // the `value` prop. + , + name: "view-table-sorting", + value: value, + checked: isChecked, + onChange: () => { + onChangeView({ + ...view, + sort: { + field: field.id, + direction + } + }); + } + }, (0,external_React_.createElement)(view_table_DropdownMenuItemLabel, null, info.label)); + })), canAddFilter && (0,external_React_.createElement)(view_table_DropdownMenuGroup, null, (0,external_React_.createElement)(view_table_DropdownMenuItem, { + prefix: (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: library_funnel + }), + onClick: () => { + setOpenedFilter(field.id); + onChangeView({ + ...view, + page: 1, + filters: [...(view.filters || []), { + field: field.id, + value: undefined, + operator: operators[0] + }] + }); + } + }, (0,external_React_.createElement)(view_table_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Add filter')))), isHidable && (0,external_React_.createElement)(view_table_DropdownMenuItem, { + prefix: (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: library_unseen + }), + onClick: () => { + onHide(field); + onChangeView({ + ...view, + hiddenFields: view.hiddenFields.concat(field.id) + }); + } + }, (0,external_React_.createElement)(view_table_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Hide'))))); +}); +function BulkSelectionCheckbox({ + selection, + onSelectionChange, + data, + actions +}) { + const selectableItems = (0,external_wp_element_namespaceObject.useMemo)(() => { + return data.filter(item => { + return actions.some(action => action.supportsBulk && action.isEligible(item)); + }); + }, [data, actions]); + const areAllSelected = selection.length === selectableItems.length; + return (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { + className: "dataviews-view-table-selection-checkbox", + __nextHasNoMarginBottom: true, + checked: areAllSelected, + indeterminate: !areAllSelected && selection.length, + onChange: () => { + if (areAllSelected) { + onSelectionChange([]); + } else { + onSelectionChange(selectableItems); + } + }, + label: areAllSelected ? (0,external_wp_i18n_namespaceObject.__)('Deselect all') : (0,external_wp_i18n_namespaceObject.__)('Select all') + }); +} +function TableRow({ + hasBulkActions, + item, + actions, + id, + visibleFields, + primaryField, + selection, + getItemId, + onSelectionChange, + data +}) { + const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); + return (0,external_React_.createElement)("tr", { + className: classnames_default()('dataviews-view-table__row', { + 'is-selected': hasPossibleBulkAction && selection.includes(id) + }) + }, hasBulkActions && (0,external_React_.createElement)("td", { + className: "dataviews-view-table__checkbox-column", + style: { + width: 20, + minWidth: 20 + } + }, (0,external_React_.createElement)("div", { + className: "dataviews-view-table__cell-content-wrapper" + }, (0,external_React_.createElement)(SingleSelectionCheckbox, { + id: id, + item: item, + selection: selection, + onSelectionChange: onSelectionChange, + getItemId: getItemId, + data: data, + primaryField: primaryField, + disabled: !hasPossibleBulkAction + }))), visibleFields.map(field => (0,external_React_.createElement)("td", { + key: field.id, + style: { + width: field.width || undefined, + minWidth: field.minWidth || undefined, + maxWidth: field.maxWidth || undefined + } + }, (0,external_React_.createElement)("div", { + className: classnames_default()('dataviews-view-table__cell-content-wrapper', { + 'dataviews-view-table__primary-field': primaryField?.id === field.id + }) + }, field.render({ + item + })))), !!actions?.length && (0,external_React_.createElement)("td", { + className: "dataviews-view-table__actions-column" + }, (0,external_React_.createElement)(ItemActions, { + item: item, + actions: actions + }))); +} +function ViewTable({ + view, + onChangeView, + fields, + actions, + data, + getItemId, + isLoading = false, + deferredRendering, + selection, + onSelectionChange, + setOpenedFilter +}) { + const headerMenuRefs = (0,external_wp_element_namespaceObject.useRef)(new Map()); + const headerMenuToFocusRef = (0,external_wp_element_namespaceObject.useRef)(); + const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0,external_wp_element_namespaceObject.useState)(); + const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (headerMenuToFocusRef.current) { + headerMenuToFocusRef.current.focus(); + headerMenuToFocusRef.current = undefined; + } + }); + const asyncData = (0,external_wp_compose_namespaceObject.useAsyncList)(data); + const tableNoticeId = (0,external_wp_element_namespaceObject.useId)(); + if (nextHeaderMenuToFocus) { + // If we need to force focus, we short-circuit rendering here + // to prevent any additional work while we handle that. + // Clearing out the focus directive is necessary to make sure + // future renders don't cause unexpected focus jumps. + headerMenuToFocusRef.current = nextHeaderMenuToFocus; + setNextHeaderMenuToFocus(); + return; + } + const onHide = field => { + const hidden = headerMenuRefs.current.get(field.id); + const fallback = headerMenuRefs.current.get(hidden.fallback); + setNextHeaderMenuToFocus(fallback?.node); + }; + const visibleFields = fields.filter(field => !view.hiddenFields.includes(field.id) && ![view.layout.mediaField].includes(field.id)); + const usedData = deferredRendering ? asyncData : data; + const hasData = !!usedData?.length; + const sortValues = { + asc: 'ascending', + desc: 'descending' + }; + const primaryField = fields.find(field => field.id === view.layout.primaryField); + return (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_React_.createElement)("table", { + className: "dataviews-view-table", + "aria-busy": isLoading, + "aria-describedby": tableNoticeId + }, (0,external_React_.createElement)("thead", null, (0,external_React_.createElement)("tr", { + className: "dataviews-view-table__row" + }, hasBulkActions && (0,external_React_.createElement)("th", { + className: "dataviews-view-table__checkbox-column", + style: { + width: 20, + minWidth: 20 + }, + "data-field-id": "selection", + scope: "col" + }, (0,external_React_.createElement)(BulkSelectionCheckbox, { + selection: selection, + onSelectionChange: onSelectionChange, + data: data, + actions: actions + })), visibleFields.map((field, index) => (0,external_React_.createElement)("th", { + key: field.id, + style: { + width: field.width || undefined, + minWidth: field.minWidth || undefined, + maxWidth: field.maxWidth || undefined + }, + "data-field-id": field.id, + "aria-sort": view.sort?.field === field.id && sortValues[view.sort.direction], + scope: "col" + }, (0,external_React_.createElement)(HeaderMenu, { + ref: node => { + if (node) { + headerMenuRefs.current.set(field.id, { + node, + fallback: visibleFields[index > 0 ? index - 1 : 1]?.id + }); + } else { + headerMenuRefs.current.delete(field.id); + } + }, + field: field, + view: view, + onChangeView: onChangeView, + onHide: onHide, + setOpenedFilter: setOpenedFilter + }))), !!actions?.length && (0,external_React_.createElement)("th", { + "data-field-id": "actions", + className: "dataviews-view-table__actions-column" + }, (0,external_React_.createElement)("span", { + className: "dataviews-view-table-header" + }, (0,external_wp_i18n_namespaceObject.__)('Actions'))))), (0,external_React_.createElement)("tbody", null, hasData && usedData.map((item, index) => (0,external_React_.createElement)(TableRow, { + key: getItemId(item), + item: item, + hasBulkActions: hasBulkActions, + actions: actions, + id: getItemId(item) || index, + visibleFields: visibleFields, + primaryField: primaryField, + selection: selection, + getItemId: getItemId, + onSelectionChange: onSelectionChange, + data: data + })))), (0,external_React_.createElement)("div", { + className: classnames_default()({ + 'dataviews-loading': isLoading, + 'dataviews-no-results': !hasData && !isLoading + }), + id: tableNoticeId + }, !hasData && (0,external_React_.createElement)("p", null, isLoading ? (0,external_wp_i18n_namespaceObject.__)('Loading…') : (0,external_wp_i18n_namespaceObject.__)('No results')))); +} +/* harmony default export */ const view_table = (ViewTable); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/view-grid.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + +/** + * Internal dependencies + */ + + + +function GridItem({ + selection, + data, + onSelectionChange, + getItemId, + item, + actions, + mediaField, + primaryField, + visibleFields +}) { + const [hasNoPointerEvents, setHasNoPointerEvents] = (0,external_wp_element_namespaceObject.useState)(false); + const hasBulkAction = useHasAPossibleBulkAction(actions, item); + const id = getItemId(item); + const isSelected = selection.includes(id); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: 0, + key: id, + className: classnames_default()('dataviews-view-grid__card', { + 'is-selected': hasBulkAction && isSelected, + 'has-no-pointer-events': hasNoPointerEvents + }), + onMouseDown: event => { + if (hasBulkAction && (event.ctrlKey || event.metaKey)) { + setHasNoPointerEvents(true); + if (!isSelected) { + onSelectionChange(data.filter(_item => { + const itemId = getItemId?.(_item); + return itemId === id || selection.includes(itemId); + })); + } else { + onSelectionChange(data.filter(_item => { + const itemId = getItemId?.(_item); + return itemId !== id && selection.includes(itemId); + })); + } + } + }, + onClick: () => { + if (hasNoPointerEvents) { + setHasNoPointerEvents(false); + } + } + }, (0,external_React_.createElement)("div", { + className: "dataviews-view-grid__media" + }, mediaField?.render({ + item + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "space-between", + className: "dataviews-view-grid__title-actions" + }, (0,external_React_.createElement)(SingleSelectionCheckbox, { + id: id, + item: item, + selection: selection, + onSelectionChange: onSelectionChange, + getItemId: getItemId, + data: data, + primaryField: primaryField, + disabled: !hasBulkAction + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + className: "dataviews-view-grid__primary-field" + }, primaryField?.render({ + item + })), (0,external_React_.createElement)(ItemActions, { + item: item, + actions: actions, + isCompact: true + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + className: "dataviews-view-grid__fields", + spacing: 3 + }, visibleFields.map(field => { + const renderedValue = field.render({ + item + }); + if (!renderedValue) { + return null; + } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + className: "dataviews-view-grid__field", + key: field.id, + spacing: 1 + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { + text: field.header, + placement: "left" + }, (0,external_React_.createElement)("div", { + className: "dataviews-view-grid__field-value" + }, renderedValue))); + }))); +} +function ViewGrid({ + data, + fields, + view, + actions, + isLoading, + getItemId, + deferredRendering, + selection, + onSelectionChange +}) { + const mediaField = fields.find(field => field.id === view.layout.mediaField); + const primaryField = fields.find(field => field.id === view.layout.primaryField); + const visibleFields = fields.filter(field => !view.hiddenFields.includes(field.id) && ![view.layout.mediaField, view.layout.primaryField].includes(field.id)); + const shownData = (0,external_wp_compose_namespaceObject.useAsyncList)(data, { + step: 3 + }); + const usedData = deferredRendering ? shownData : data; + const hasData = !!usedData?.length; + return (0,external_React_.createElement)(external_React_.Fragment, null, hasData && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalGrid, { + gap: 6, + columns: 2, + alignment: "top", + className: "dataviews-view-grid", + "aria-busy": isLoading + }, usedData.map(item => { + return (0,external_React_.createElement)(GridItem, { + key: getItemId(item), + selection: selection, + data: data, + onSelectionChange: onSelectionChange, + getItemId: getItemId, + item: item, + actions: actions, + mediaField: mediaField, + primaryField: primaryField, + visibleFields: visibleFields + }); + })), !hasData && (0,external_React_.createElement)("div", { + className: classnames_default()({ + 'dataviews-loading': isLoading, + 'dataviews-no-results': !isLoading + }) + }, (0,external_React_.createElement)("p", null, isLoading ? (0,external_wp_i18n_namespaceObject.__)('Loading…') : (0,external_wp_i18n_namespaceObject.__)('No results')))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/info.js + +/** + * WordPress dependencies + */ + +const info = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M12 3.2c-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.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z" +})); +/* harmony default export */ const library_info = (info); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/view-list.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + +function ViewList({ + view, + fields, + data, + isLoading, + getItemId, + onSelectionChange, + onDetailsChange, + selection, + deferredRendering +}) { + const shownData = (0,external_wp_compose_namespaceObject.useAsyncList)(data, { + step: 3 + }); + const usedData = deferredRendering ? shownData : data; + const mediaField = fields.find(field => field.id === view.layout.mediaField); + const primaryField = fields.find(field => field.id === view.layout.primaryField); + const visibleFields = fields.filter(field => !view.hiddenFields.includes(field.id) && ![view.layout.primaryField, view.layout.mediaField].includes(field.id)); + const onEnter = item => event => { + const { + keyCode + } = event; + if ([external_wp_keycodes_namespaceObject.ENTER, external_wp_keycodes_namespaceObject.SPACE].includes(keyCode)) { + onSelectionChange([item]); + } + }; + const hasData = usedData?.length; + if (!hasData) { + return (0,external_React_.createElement)("div", { + className: classnames_default()({ + 'dataviews-loading': isLoading, + 'dataviews-no-results': !hasData && !isLoading + }) + }, !hasData && (0,external_React_.createElement)("p", null, isLoading ? (0,external_wp_i18n_namespaceObject.__)('Loading…') : (0,external_wp_i18n_namespaceObject.__)('No results'))); + } + return (0,external_React_.createElement)("ul", { + className: "dataviews-view-list" + }, usedData.map(item => { + return (0,external_React_.createElement)("li", { + key: getItemId(item), + className: classnames_default()({ + 'is-selected': selection.includes(item.id) + }) + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + className: "dataviews-view-list__item-wrapper" + }, (0,external_React_.createElement)("div", { + role: "button", + tabIndex: 0, + "aria-pressed": selection.includes(item.id), + onKeyDown: onEnter(item), + className: "dataviews-view-list__item", + onClick: () => onSelectionChange([item]) + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + spacing: 3, + justify: "start", + alignment: "flex-start" + }, (0,external_React_.createElement)("div", { + className: "dataviews-view-list__media-wrapper" + }, mediaField?.render({ + item + }) || (0,external_React_.createElement)("div", { + className: "dataviews-view-list__media-placeholder" + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: 1 + }, (0,external_React_.createElement)("span", { + className: "dataviews-view-list__primary-field" + }, primaryField?.render({ + item + })), (0,external_React_.createElement)("div", { + className: "dataviews-view-list__fields" + }, visibleFields.map(field => { + return (0,external_React_.createElement)("span", { + key: field.id, + className: "dataviews-view-list__field" + }, field.render({ + item + })); + }))))), onDetailsChange && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + className: "dataviews-view-list__details-button", + onClick: () => onDetailsChange([item]), + icon: library_info, + label: (0,external_wp_i18n_namespaceObject.__)('View details'), + size: "compact" + }))); + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/constants.js +/** + * WordPress dependencies + */ + + + +/** + * Internal dependencies + */ + + + + +// Field types. +const constants_ENUMERATION_TYPE = 'enumeration'; + +// Filter operators. +const constants_OPERATOR_IN = 'in'; +const constants_OPERATOR_NOT_IN = 'notIn'; +const OPERATORS = { + [constants_OPERATOR_IN]: { + key: 'in-filter', + label: (0,external_wp_i18n_namespaceObject.__)('Is') + }, + [constants_OPERATOR_NOT_IN]: { + key: 'not-in-filter', + label: (0,external_wp_i18n_namespaceObject.__)('Is not') + } +}; + +// Sorting +const SORTING_DIRECTIONS = { + asc: { + label: (0,external_wp_i18n_namespaceObject.__)('Sort ascending') + }, + desc: { + label: (0,external_wp_i18n_namespaceObject.__)('Sort descending') + } +}; + +// View layouts. +const constants_LAYOUT_TABLE = 'table'; +const constants_LAYOUT_GRID = 'grid'; +const constants_LAYOUT_LIST = 'list'; +const VIEW_LAYOUTS = [{ + type: constants_LAYOUT_TABLE, + label: (0,external_wp_i18n_namespaceObject.__)('Table'), + component: view_table, + icon: block_table +}, { + type: constants_LAYOUT_GRID, + label: (0,external_wp_i18n_namespaceObject.__)('Grid'), + component: ViewGrid, + icon: library_category +}, { + type: constants_LAYOUT_LIST, + label: (0,external_wp_i18n_namespaceObject.__)('List'), + component: ViewList, + icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? format_list_bullets_rtl : format_list_bullets +}]; + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/dataview-item.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + + + +const { + useLocation: dataview_item_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); +function DataViewItem({ + title, + slug, + customViewId, + type, + icon, + isActive, + isCustom, + suffix +}) { + const { + params: { + path, + layout + } + } = dataview_item_useLocation(); + const iconToUse = icon || VIEW_LAYOUTS.find(v => v.type === type).icon; + const linkInfo = useLink({ + path, + layout, + activeView: isCustom === 'true' ? customViewId : slug, + isCustom + }); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "flex-start", + className: classnames_default()('edit-site-sidebar-dataviews-dataview-item', { + 'is-selected': isActive + }) + }, (0,external_React_.createElement)(SidebarNavigationItem, { + icon: iconToUse, + ...linkInfo, + "aria-current": isActive ? 'true' : undefined + }, title), suffix); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content.js + +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + + + +const content_EMPTY_ARRAY = []; +function TemplateDataviewItem({ + template, + isActive +}) { + const { + text, + icon + } = useAddedBy(template.type, template.id); + return (0,external_React_.createElement)(DataViewItem, { + key: text, + slug: text, + title: text, + icon: icon, + isActive: isActive, + isCustom: "false" + }); +} +function DataviewsTemplatesSidebarContent({ + activeView, + postType, + title +}) { + const { + records + } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', postType, { + per_page: -1 + }); + const firstItemPerAuthorText = (0,external_wp_element_namespaceObject.useMemo)(() => { + var _ref; + const firstItemPerAuthor = records?.reduce((acc, template) => { + const author = template.author_text; + if (author && !acc[author]) { + acc[author] = template; + } + return acc; + }, {}); + return (_ref = firstItemPerAuthor && Object.values(firstItemPerAuthor)) !== null && _ref !== void 0 ? _ref : content_EMPTY_ARRAY; + }, [records]); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(DataViewItem, { + slug: 'all', + title: title, + icon: library_layout, + isActive: activeView === 'all', + isCustom: "false" + }), firstItemPerAuthorText.map(template => { + return (0,external_React_.createElement)(TemplateDataviewItem, { + key: template.author_text, + template: template, + isActive: activeView === template.author_text + }); + })); +} + ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/index.js /** @@ -19608,15 +20939,18 @@ const NavMenuItem = ({ + const config = { - [TEMPLATE_POST_TYPE]: { - title: (0,external_wp_i18n_namespaceObject.__)('All templates'), - description: (0,external_wp_i18n_namespaceObject.__)('Create new templates, or reset any customizations made to the templates supplied by your theme.') + [constants_TEMPLATE_POST_TYPE]: { + title: (0,external_wp_i18n_namespaceObject.__)('Manage templates'), + description: (0,external_wp_i18n_namespaceObject.__)('Create new templates, or reset any customizations made to the templates supplied by your theme.'), + contentTitle: (0,external_wp_i18n_namespaceObject.__)('All templates') }, [TEMPLATE_PART_POST_TYPE]: { - title: (0,external_wp_i18n_namespaceObject.__)('All template parts'), + title: (0,external_wp_i18n_namespaceObject.__)('Manage template parts'), description: (0,external_wp_i18n_namespaceObject.__)('Create new template parts, or reset any customizations made to the template parts supplied by your theme.'), - backPath: '/patterns' + backPath: '/patterns', + contentTitle: (0,external_wp_i18n_namespaceObject.__)('All template parts') } }; const { @@ -19630,20 +20964,26 @@ function SidebarNavigationScreenTemplatesBrowse() { } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); const { params: { - didAccessPatternsPage + didAccessPatternsPage, + activeView = 'all' } } = sidebar_navigation_screen_templates_browse_useLocation(); const isTemplatePartsMode = (0,external_wp_data_namespaceObject.useSelect)(select => { return !!select(store_store).getSettings().supportsTemplatePartsMode; }, []); - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen + return (0,external_React_.createElement)(SidebarNavigationScreen // If a classic theme that supports template parts has never // accessed the Patterns page, return to the dashboard. , { isRoot: isTemplatePartsMode && !didAccessPatternsPage, title: config[postType].title, description: config[postType].description, - backPath: config[postType].backPath + backPath: config[postType].backPath, + content: (0,external_React_.createElement)(DataviewsTemplatesSidebarContent, { + activeView: activeView, + postType: postType, + title: config[postType].contentTitle + }) }); } @@ -19674,20 +21014,27 @@ function SaveButton({ const { isDirty, isSaving, - isSaveViewOpen + isSaveViewOpen, + previewingThemeName } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { __experimentalGetDirtyEntityRecords, - isSavingEntityRecord + isSavingEntityRecord, + isResolving } = select(external_wp_coreData_namespaceObject.store); const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); const { isSaveViewOpened } = select(store_store); + const isActivatingTheme = isResolving('activateTheme'); + const currentlyPreviewingThemeId = currentlyPreviewingTheme(); return { isDirty: dirtyEntityRecords.length > 0, - isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)), - isSaveViewOpen: isSaveViewOpened() + isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)) || isActivatingTheme, + isSaveViewOpen: isSaveViewOpened(), + // Do not call `getTheme` with null, it will cause a request to + // the server. + previewingThemeName: currentlyPreviewingThemeId ? select(external_wp_coreData_namespaceObject.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : undefined }; }, []); const { @@ -19698,13 +21045,16 @@ function SaveButton({ const getLabel = () => { if (isPreviewingTheme()) { if (isSaving) { - return (0,external_wp_i18n_namespaceObject.__)('Activating'); + return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: The name of theme to be activated. */ + (0,external_wp_i18n_namespaceObject.__)('Activating %s'), previewingThemeName); } else if (disabled) { return (0,external_wp_i18n_namespaceObject.__)('Saved'); } else if (isDirty) { - return (0,external_wp_i18n_namespaceObject.__)('Activate & Save'); + return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: The name of theme to be activated. */ + (0,external_wp_i18n_namespaceObject.__)('Activate %s & Save'), previewingThemeName); } - return (0,external_wp_i18n_namespaceObject.__)('Activate'); + return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: The name of theme to be activated. */ + (0,external_wp_i18n_namespaceObject.__)('Activate %s'), previewingThemeName); } if (isSaving) { return (0,external_wp_i18n_namespaceObject.__)('Saving'); @@ -19716,7 +21066,7 @@ function SaveButton({ return (0,external_wp_i18n_namespaceObject.__)('Save'); }; const label = getLabel(); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: variant, className: className, "aria-disabled": disabled, @@ -19733,11 +21083,12 @@ function SaveButton({ * Displaying the keyboard shortcut conditionally makes the tooltip * itself show conditionally. This would trigger a full-rerendering * of the button that we want to avoid. By setting `showTooltip`, - & the tooltip is always rendered even when there's no keyboard shortcut. + * the tooltip is always rendered even when there's no keyboard shortcut. */, showTooltip: showTooltip, icon: icon, - __next40pxDefaultSize: __next40pxDefaultSize + __next40pxDefaultSize: __next40pxDefaultSize, + size: "compact" }, label); } @@ -19825,6 +21176,16 @@ function SaveHub() { if (isSaving) { label = (0,external_wp_i18n_namespaceObject.__)('Saving'); } + const { + homeUrl + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getUnstableBase // Site index. + } = select(external_wp_coreData_namespaceObject.store); + return { + homeUrl: getUnstableBase()?.home + }; + }, []); const saveCurrentEntity = async () => { if (!dirtyCurrentEntity) return; removeNotice(saveNoticeId); @@ -19848,17 +21209,21 @@ function SaveHub() { __unstableMarkLastChangeAsPersistent(); createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), { type: 'snackbar', + actions: [{ + label: (0,external_wp_i18n_namespaceObject.__)('View site'), + url: homeUrl + }], id: saveNoticeId }); } catch (error) { createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`); } }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { className: "edit-site-save-hub", alignment: "right", spacing: 4 - }, dirtyCurrentEntity ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, dirtyCurrentEntity ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", onClick: saveCurrentEntity, isBusy: isSaving, @@ -19866,7 +21231,7 @@ function SaveHub() { "aria-disabled": isSaving, className: "edit-site-save-hub__button", __next40pxDefaultSize: true - }, label) : (0,external_wp_element_namespaceObject.createElement)(SaveButton, { + }, label) : (0,external_React_.createElement)(SaveButton, { className: "edit-site-save-hub__button", variant: disabled ? null : 'primary', showTooltip: false, @@ -19929,25 +21294,25 @@ function AddNewPageModal({ setIsCreatingPage(false); } } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { title: (0,external_wp_i18n_namespaceObject.__)('Draft a new page'), onRequestClose: onClose - }, (0,external_wp_element_namespaceObject.createElement)("form", { + }, (0,external_React_.createElement)("form", { onSubmit: createPage - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 3 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { label: (0,external_wp_i18n_namespaceObject.__)('Page title'), onChange: setTitle, placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'), value: title - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { spacing: 2, justify: "end" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "tertiary", onClick: onClose - }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", type: "submit", isBusy: isCreatingPage, @@ -19969,6 +21334,7 @@ function AddNewPageModal({ + /** * Internal dependencies */ @@ -19993,12 +21359,13 @@ const PageItem = ({ }, { backPath: '/page' }); - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + return (0,external_React_.createElement)(SidebarNavigationItem, { ...linkInfo, ...props }); }; function SidebarNavigationScreenPages() { + const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); const { records: pages, isResolving: isLoadingPages @@ -20009,7 +21376,7 @@ function SidebarNavigationScreenPages() { const { records: templates, isResolving: isLoadingTemplates - } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', TEMPLATE_POST_TYPE, { + } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', constants_TEMPLATE_POST_TYPE, { per_page: -1 }); const dynamicPageTemplates = templates?.filter(({ @@ -20068,65 +21435,539 @@ function SidebarNavigationScreenPages() { } return { icon: itemIcon, - postType: postsPageTemplateId ? TEMPLATE_POST_TYPE : 'page', + postType: postsPageTemplateId ? constants_TEMPLATE_POST_TYPE : 'page', postId: postsPageTemplateId || id }; }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, showAddPage && (0,external_wp_element_namespaceObject.createElement)(AddNewPageModal, { + const pagesLink = useLink({ + path: '/pages' + }); + return (0,external_React_.createElement)(external_React_.Fragment, null, showAddPage && (0,external_React_.createElement)(AddNewPageModal, { onSave: handleNewPage, onClose: () => setShowAddPage(false) - }), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { + }), (0,external_React_.createElement)(SidebarNavigationScreen, { title: (0,external_wp_i18n_namespaceObject.__)('Pages'), - description: (0,external_wp_i18n_namespaceObject.__)('Browse and edit pages on your site.'), - actions: (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + description: (0,external_wp_i18n_namespaceObject.__)('Browse and manage pages.'), + actions: (0,external_React_.createElement)(SidebarButton, { icon: library_plus, label: (0,external_wp_i18n_namespaceObject.__)('Draft a new page'), onClick: () => setShowAddPage(true) }), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (isLoadingPages || isLoadingTemplates) && (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.__)('Loading pages…'))), !(isLoadingPages || isLoadingTemplates) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, !pagesAndTemplates?.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No page found')), isHomePageBlog && homeTemplate && (0,external_wp_element_namespaceObject.createElement)(PageItem, { - postType: TEMPLATE_POST_TYPE, + content: (0,external_React_.createElement)(external_React_.Fragment, null, (isLoadingPages || isLoadingTemplates) && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('Loading pages…'))), !(isLoadingPages || isLoadingTemplates) && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, !pagesAndTemplates?.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No page found')), isHomePageBlog && homeTemplate && (0,external_React_.createElement)(PageItem, { + postType: constants_TEMPLATE_POST_TYPE, postId: homeTemplate.id, key: homeTemplate.id, icon: library_home, withChevron: true - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { numberOfLines: 1 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(homeTemplate.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)')))), reorderedPages?.map(({ id, title - }) => (0,external_wp_element_namespaceObject.createElement)(PageItem, { + }) => (0,external_React_.createElement)(PageItem, { ...getPageProps(id), key: id, withChevron: true - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { numberOfLines: 1 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)'))))))), - footer: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + footer: (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 0 - }, dynamicPageTemplates?.map(item => (0,external_wp_element_namespaceObject.createElement)(PageItem, { - postType: TEMPLATE_POST_TYPE, + }, dynamicPageTemplates?.map(item => (0,external_React_.createElement)(PageItem, { + postType: constants_TEMPLATE_POST_TYPE, postId: item.id, key: item.id, icon: library_layout, withChevron: true - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { numberOfLines: 1 - }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)'))))), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationItem, { + }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)'))))), !isMobileViewport && (0,external_React_.createElement)(SidebarNavigationItem, { className: "edit-site-sidebar-navigation-screen-pages__see-all", - href: "edit.php?post_type=page", + ...pagesLink + }, (0,external_wp_i18n_namespaceObject.__)('Manage all pages'))) + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pages.js + +/** + * WordPress dependencies + */ + +const pages = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M14.5 5.5h-7V7h7V5.5ZM7.5 9h7v1.5h-7V9Zm7 3.5h-7V14h7v-1.5Z" +}), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M16 2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2ZM6 3.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5Z" +}), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M20 8v11c0 .69-.31 1-.999 1H6v1.5h13.001c1.52 0 2.499-.982 2.499-2.5V8H20Z" +})); +/* harmony default export */ const library_pages = (pages); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drafts.js + +/** + * WordPress dependencies + */ + +const drafts = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M8 2H6a2 2 0 0 0-2 2v2.4h1.5V4a.5.5 0 0 1 .5-.5h2V2ZM4 13.6V16a2 2 0 0 0 2 2h2v-1.5H6a.5.5 0 0 1-.5-.5v-2.4H4Zm0-1.2h1.5V7.6H4v4.8ZM9 2v1.5h4V2H9Zm5 0v1.5h2a.5.5 0 0 1 .5.5v2.4H18V4a2 2 0 0 0-2-2h-2Zm4 5.6h-1.5v4.8H18V7.6Zm0 6h-1.5V16a.5.5 0 0 1-.5.5h-2V18h2a2 2 0 0 0 2-2v-2.4ZM13 18v-1.5H9V18h4ZM7 7.25h8v-1.5H7v1.5Zm0 3.25h6V9H7v1.5ZM21.75 19V6h-1.5v13c0 .69-.56 1.25-1.25 1.25H8v1.5h11A2.75 2.75 0 0 0 21.75 19Z" +})); +/* harmony default export */ const library_drafts = (drafts); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/trash.js + +/** + * WordPress dependencies + */ + +const trash = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" +})); +/* harmony default export */ const library_trash = (trash); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/default-views.js +/** + * WordPress dependencies + */ + + + +/** + * Internal dependencies + */ + +const DEFAULT_CONFIG_PER_VIEW_TYPE = { + [LAYOUT_TABLE]: { + primaryField: 'title' + }, + [LAYOUT_GRID]: { + mediaField: 'featured-image', + primaryField: 'title' + }, + [LAYOUT_LIST]: { + primaryField: 'title', + mediaField: 'featured-image' + } +}; +const DEFAULT_PAGE_BASE = { + type: LAYOUT_TABLE, + search: '', + filters: [], + page: 1, + perPage: 20, + sort: { + field: 'date', + direction: 'desc' + }, + // All fields are visible by default, so it's + // better to keep track of the hidden ones. + hiddenFields: ['date', 'featured-image'], + layout: { + ...DEFAULT_CONFIG_PER_VIEW_TYPE[LAYOUT_TABLE] + } +}; +const DEFAULT_VIEWS = { + page: [{ + title: (0,external_wp_i18n_namespaceObject.__)('All pages'), + slug: 'all', + icon: library_pages, + view: DEFAULT_PAGE_BASE + }, { + title: (0,external_wp_i18n_namespaceObject.__)('Drafts'), + slug: 'drafts', + icon: library_drafts, + view: { + ...DEFAULT_PAGE_BASE, + filters: [{ + field: 'status', + operator: OPERATOR_IN, + value: 'draft' + }] + } + }, { + title: (0,external_wp_i18n_namespaceObject.__)('Trash'), + slug: 'trash', + icon: library_trash, + view: { + ...DEFAULT_PAGE_BASE, + filters: [{ + field: 'status', + operator: OPERATOR_IN, + value: 'trash' + }] + } + }] +}; + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/add-new-view.js + +/** + * WordPress dependencies + */ + + + + + + + + +/** + * Internal dependencies + */ + + + +const { + useHistory: add_new_view_useHistory, + useLocation: add_new_view_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); +function AddNewItemModalContent({ + type, + setIsAdding +}) { + const { + params: { + path + } + } = add_new_view_useLocation(); + const history = add_new_view_useHistory(); + const { + saveEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); + const [isSaving, setIsSaving] = (0,external_wp_element_namespaceObject.useState)(false); + return (0,external_React_.createElement)("form", { + onSubmit: async event => { + event.preventDefault(); + setIsSaving(true); + const { + getEntityRecords + } = (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store); + let dataViewTaxonomyId; + const dataViewTypeRecords = await getEntityRecords('taxonomy', 'wp_dataviews_type', { + slug: type + }); + if (dataViewTypeRecords && dataViewTypeRecords.length > 0) { + dataViewTaxonomyId = dataViewTypeRecords[0].id; + } else { + const record = await saveEntityRecord('taxonomy', 'wp_dataviews_type', { + name: type + }); + if (record && record.id) { + dataViewTaxonomyId = record.id; + } + } + const savedRecord = await saveEntityRecord('postType', 'wp_dataviews', { + title, + status: 'publish', + wp_dataviews_type: dataViewTaxonomyId, + content: JSON.stringify(DEFAULT_VIEWS[type][0].view) + }); + history.push({ + path, + activeView: savedRecord.id, + isCustom: 'true' + }); + setIsSaving(false); + setIsAdding(false); + } + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: "5" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { + __nextHasNoMarginBottom: true, + label: (0,external_wp_i18n_namespaceObject.__)('Name'), + value: title, + onChange: setTitle, + placeholder: (0,external_wp_i18n_namespaceObject.__)('My view'), + className: "patterns-create-modal__name-input" + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "right" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "tertiary", + onClick: () => { + setIsAdding(false); + } + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "primary", + type: "submit", + "aria-disabled": !title || isSaving, + isBusy: isSaving + }, (0,external_wp_i18n_namespaceObject.__)('Create'))))); +} +function AddNewItem({ + type +}) { + const [isAdding, setIsAdding] = (0,external_wp_element_namespaceObject.useState)(false); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(SidebarNavigationItem, { + icon: library_plus, + onClick: () => { + setIsAdding(true); + }, + className: "dataviews__siderbar-content-add-new-item" + }, (0,external_wp_i18n_namespaceObject.__)('New view')), isAdding && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { + title: (0,external_wp_i18n_namespaceObject.__)('Add new view'), + onRequestClose: () => { + setIsAdding(false); + } + }, (0,external_React_.createElement)(AddNewItemModalContent, { + type: type, + setIsAdding: setIsAdding + }))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/custom-dataviews-list.js + +/** + * WordPress dependencies + */ + + + + + + + + +/** + * Internal dependencies + */ + + + +const { + useHistory: custom_dataviews_list_useHistory, + useLocation: custom_dataviews_list_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); +const custom_dataviews_list_EMPTY_ARRAY = []; +function RenameItemModalContent({ + dataviewId, + currentTitle, + setIsRenaming +}) { + const { + editEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(currentTitle); + return (0,external_React_.createElement)("form", { + onSubmit: async event => { + event.preventDefault(); + await editEntityRecord('postType', 'wp_dataviews', dataviewId, { + title + }); + setIsRenaming(false); + } + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: "5" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { + __nextHasNoMarginBottom: true, + label: (0,external_wp_i18n_namespaceObject.__)('Name'), + value: title, + onChange: setTitle, + placeholder: (0,external_wp_i18n_namespaceObject.__)('My view'), + className: "patterns-create-modal__name-input" + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "right" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "tertiary", + onClick: () => { + setIsRenaming(false); + } + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "primary", + type: "submit", + "aria-disabled": !title + }, (0,external_wp_i18n_namespaceObject.__)('Rename'))))); +} +function CustomDataViewItem({ + dataviewId, + isActive +}) { + const { + params: { + path + } + } = custom_dataviews_list_useLocation(); + const history = custom_dataviews_list_useHistory(); + const { + dataview + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEditedEntityRecord + } = select(external_wp_coreData_namespaceObject.store); + return { + dataview: getEditedEntityRecord('postType', 'wp_dataviews', dataviewId) + }; + }, [dataviewId]); + const { + deleteEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + const type = (0,external_wp_element_namespaceObject.useMemo)(() => { + const viewContent = JSON.parse(dataview.content); + return viewContent.type; + }, [dataview.content]); + const [isRenaming, setIsRenaming] = (0,external_wp_element_namespaceObject.useState)(false); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(DataViewItem, { + title: dataview.title, + type: type, + isActive: isActive, + isCustom: "true", + customViewId: dataviewId, + suffix: (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + icon: more_vertical, + label: (0,external_wp_i18n_namespaceObject.__)('Actions'), + className: "edit-site-sidebar-dataviews-dataview-item__dropdown-menu", + toggleProps: { + style: { + color: 'inherit' + }, + size: 'small' + } + }, ({ + onClose + }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { - document.location = 'edit.php?post_type=page'; + setIsRenaming(true); + onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Manage all pages'))) + }, (0,external_wp_i18n_namespaceObject.__)('Rename')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + onClick: async () => { + await deleteEntityRecord('postType', 'wp_dataviews', dataview.id, { + force: true + }); + if (isActive) { + history.replace({ + path + }); + } + onClose(); + }, + isDestructive: true + }, (0,external_wp_i18n_namespaceObject.__)('Delete')))) + }), isRenaming && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { + title: (0,external_wp_i18n_namespaceObject.__)('Rename view'), + onRequestClose: () => { + setIsRenaming(false); + } + }, (0,external_React_.createElement)(RenameItemModalContent, { + dataviewId: dataviewId, + setIsRenaming: setIsRenaming, + currentTitle: dataview.title + }))); +} +function useCustomDataViews(type) { + const customDataViews = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEntityRecords + } = select(external_wp_coreData_namespaceObject.store); + const dataViewTypeRecords = getEntityRecords('taxonomy', 'wp_dataviews_type', { + slug: type + }); + if (!dataViewTypeRecords || dataViewTypeRecords.length === 0) { + return custom_dataviews_list_EMPTY_ARRAY; + } + const dataViews = getEntityRecords('postType', 'wp_dataviews', { + wp_dataviews_type: dataViewTypeRecords[0].id, + orderby: 'date', + order: 'asc' + }); + if (!dataViews) { + return custom_dataviews_list_EMPTY_ARRAY; + } + return dataViews; + }); + return customDataViews; +} +function CustomDataViewsList({ + type, + activeView, + isCustom +}) { + const customDataViews = useCustomDataViews(type); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { + className: "edit-site-sidebar-navigation-screen-dataviews__group-header" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + level: 2 + }, (0,external_wp_i18n_namespaceObject.__)('Custom Views'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, customDataViews.map(customViewRecord => { + return (0,external_React_.createElement)(CustomDataViewItem, { + key: customViewRecord.id, + dataviewId: customViewRecord.id, + isActive: isCustom === 'true' && Number(activeView) === customViewRecord.id + }); + }), (0,external_React_.createElement)(AddNewItem, { + type: type + }))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/index.js + +/** + * WordPress dependencies + */ + + +/** + * Internal dependencies + */ + + + +const { + useLocation: sidebar_dataviews_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); + + +const PATH_TO_TYPE = { + '/pages': 'page' +}; +function DataViewsSidebarContent() { + const { + params: { + path, + activeView = 'all', + isCustom = 'false' + } + } = sidebar_dataviews_useLocation(); + if (!path || !PATH_TO_TYPE[path]) { + return null; + } + const type = PATH_TO_TYPE[path]; + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, DEFAULT_VIEWS[type].map(dataview => { + return (0,external_React_.createElement)(DataViewItem, { + key: dataview.slug, + slug: dataview.slug, + title: dataview.title, + icon: dataview.icon, + type: dataview.view.type, + isActive: isCustom === 'false' && dataview.slug === activeView, + isCustom: "false" + }); + })), window?.__experimentalAdminViews && (0,external_React_.createElement)(CustomDataViewsList, { + activeView: activeView, + type: type, + isCustom: "true" })); } ;// CONCATENATED MODULE: external ["wp","dom"] -var external_wp_dom_namespaceObject = window["wp"]["dom"]; +const external_wp_dom_namespaceObject = window["wp"]["dom"]; ;// CONCATENATED MODULE: external ["wp","escapeHtml"] -var external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"]; +const external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"]; ;// CONCATENATED MODULE: external ["wp","wordcount"] -var external_wp_wordcount_namespaceObject = window["wp"]["wordcount"]; +const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-page/status-label.js /** @@ -20151,7 +21992,7 @@ function StatusLabel({ case 'publish': statusLabel = date ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is the relative time when the post was published. */ (0,external_wp_i18n_namespaceObject.__)('Published <time>%s</time>'), relateToNow), { - time: (0,external_wp_element_namespaceObject.createElement)("time", { + time: (0,external_React_.createElement)("time", { dateTime: date }) }) : (0,external_wp_i18n_namespaceObject.__)('Published'); @@ -20160,7 +22001,7 @@ function StatusLabel({ const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)(short ? 'M j' : 'F j', (0,external_wp_date_namespaceObject.getDate)(date)); statusLabel = date ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is the formatted date and time on which the post is scheduled to be published. */ (0,external_wp_i18n_namespaceObject.__)('Scheduled: <time>%s</time>'), formattedDate), { - time: (0,external_wp_element_namespaceObject.createElement)("time", { + time: (0,external_React_.createElement)("time", { dateTime: date }) }) : (0,external_wp_i18n_namespaceObject.__)('Scheduled'); @@ -20178,7 +22019,7 @@ function StatusLabel({ statusLabel = (0,external_wp_i18n_namespaceObject.__)('Password protected'); break; } - return (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)("div", { className: classnames_default()('edit-site-sidebar-navigation-screen-page__status', { [`has-status has-${status}-status`]: !!status }) @@ -20215,16 +22056,16 @@ function getPageDetails(page) { } const details = [{ label: (0,external_wp_i18n_namespaceObject.__)('Status'), - value: (0,external_wp_element_namespaceObject.createElement)(StatusLabel, { + value: (0,external_React_.createElement)(StatusLabel, { status: page?.password ? 'protected' : page.status, date: page?.date, short: true }) }, { label: (0,external_wp_i18n_namespaceObject.__)('Slug'), - value: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { + value: (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { numberOfLines: 1 - }, (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(page.slug)) + }, (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(page.slug || page.generated_slug)) }]; if (page?.templateTitle) { details.push({ @@ -20271,18 +22112,10 @@ function PageDetails({ isPostsPage } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { - getEditedPostContext + getEditedPostId } = unlock(select(store_store)); - const postContext = getEditedPostContext(); - const templates = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_POST_TYPE, { - per_page: -1 - }); - // Template title. - const templateSlug = - // Checks that the post type matches the current theme's post type, otherwise - // the templateSlug returns 'home'. - postContext?.postType === 'page' ? postContext?.templateSlug : null; - const _templateTitle = templates && templateSlug ? templates.find(template => template.slug === templateSlug)?.title?.rendered : null; + const template = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', constants_TEMPLATE_POST_TYPE, getEditedPostId()); + const _templateTitle = template?.title?.rendered; // Parent page title. const _parentTitle = record?.parent ? select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'page', record.parent, { @@ -20298,7 +22131,7 @@ function PageDetails({ isPostsPage: record?.id === siteSettings?.page_for_posts }; }, [record?.parent, record?.id]); - return (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanel, { + return (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { spacing: 5, title: (0,external_wp_i18n_namespaceObject.__)('Details') }, getPageDetails({ @@ -20309,9 +22142,9 @@ function PageDetails({ }).map(({ label, value - }) => (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelRow, { + }) => (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, { key: label - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, label), (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsPanelValue, null, value)))); + }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, label), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelValue, null, value)))); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-actions/trash-page-menu-item.js @@ -20355,7 +22188,7 @@ function TrashPageMenuItem({ }); } } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => removePage(), isDestructive: true, variant: "secondary" @@ -20377,16 +22210,14 @@ function TrashPageMenuItem({ function PageActions({ postId, - className, toggleProps, onRemove }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { icon: more_vertical, label: (0,external_wp_i18n_namespaceObject.__)('Actions'), - className: className, toggleProps: toggleProps - }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(TrashPageMenuItem, { + }, () => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(TrashPageMenuItem, { postId: postId, onRemove: onRemove }))); @@ -20407,6 +22238,8 @@ function PageActions({ + + /** * Internal dependencies */ @@ -20417,18 +22250,25 @@ function PageActions({ -function SidebarNavigationScreenPage() { - const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); +const { + useHistory: sidebar_navigation_screen_page_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +function SidebarNavigationScreenPage({ + backPath +}) { const { setCanvasMode } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const history = sidebar_navigation_screen_page_useHistory(); const { params: { postId - } + }, + goTo } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); const { - record + record, + hasResolved } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'page', postId); const { featuredMediaAltText, @@ -20444,42 +22284,55 @@ function SidebarNavigationScreenPage() { featuredMediaAltText: (0,external_wp_escapeHtml_namespaceObject.escapeAttribute)(attachedMedia?.alt_text || attachedMedia?.description?.raw || '') }; }, [record]); + + // Redirect to the main pages navigation screen if the page is not found or has been deleted. + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (hasResolved && !record) { + history.push({ + path: '/page', + postId: undefined, + postType: undefined, + canvas: 'view' + }); + } + }, [hasResolved, history]); const featureImageAltText = featuredMediaAltText ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(featuredMediaAltText) : (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(record?.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('Featured image')); - return record ? (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreen, { + return record ? (0,external_React_.createElement)(SidebarNavigationScreen, { + backPath: backPath, title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(record?.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)')), - actions: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(PageActions, { + actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(PageActions, { postId: postId, toggleProps: { as: SidebarButton }, onRemove: () => { - navigator.goTo('/page'); + goTo('/page'); } - }), (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { + }), (0,external_React_.createElement)(SidebarButton, { onClick: () => setCanvasMode('edit'), label: (0,external_wp_i18n_namespaceObject.__)('Edit'), icon: library_pencil })), - meta: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { + meta: (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { className: "edit-site-sidebar-navigation-screen__page-link", href: record.link }, (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURIComponent)(record.link))), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !!featuredMediaSourceUrl && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + content: (0,external_React_.createElement)(external_React_.Fragment, null, !!featuredMediaSourceUrl && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { className: "edit-site-sidebar-navigation-screen-page__featured-image-wrapper", alignment: "left", spacing: 2 - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-sidebar-navigation-screen-page__featured-image has-image" - }, (0,external_wp_element_namespaceObject.createElement)("img", { + }, (0,external_React_.createElement)("img", { alt: featureImageAltText, src: featuredMediaSourceUrl - }))), !!record?.excerpt?.rendered && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { + }))), !!record?.excerpt?.rendered && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { className: "edit-site-sidebar-navigation-screen-page__excerpt", numberOfLines: 3 - }, (0,external_wp_dom_namespaceObject.__unstableStripHTML)(record.excerpt.rendered)), (0,external_wp_element_namespaceObject.createElement)(PageDetails, { + }, (0,external_wp_dom_namespaceObject.__unstableStripHTML)(record.excerpt.rendered)), (0,external_React_.createElement)(PageDetails, { id: postId })), - footer: record?.modified ? (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenDetailsFooter, { + footer: record?.modified ? (0,external_React_.createElement)(SidebarNavigationScreenDetailsFooter, { record: record }) : null }) : null; @@ -20488,12 +22341,19 @@ function SidebarNavigationScreenPage() { ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar/index.js /** + * External dependencies + */ + + +/** * WordPress dependencies */ + + /** * Internal dependencies */ @@ -20511,46 +22371,2343 @@ function SidebarNavigationScreenPage() { + + const { useLocation: sidebar_useLocation } = unlock(external_wp_router_namespaceObject.privateApis); +function SidebarScreenWrapper({ + className, + ...props +}) { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + className: classnames_default()('edit-site-sidebar__screen-wrapper', className), + ...props + }); +} function SidebarScreens() { useSyncPathWithURL(); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenMain, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenMain, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/navigation" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenNavigationMenus, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenNavigationMenus, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/navigation/:postType/:postId" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenNavigationMenu, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenNavigationMenu, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/wp_global_styles" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenGlobalStyles, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenGlobalStyles, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/page" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenPages, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenPages, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { + path: "/pages" + }, (0,external_React_.createElement)(SidebarNavigationScreen, { + title: (0,external_wp_i18n_namespaceObject.__)('Manage pages'), + content: (0,external_React_.createElement)(DataViewsSidebarContent, null), + backPath: "/page" + })), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/page/:postId" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenPage, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenPage, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/:postType(wp_template)" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenTemplates, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenTemplates, null)), !isMobileViewport && (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/patterns" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenPatterns, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenPatterns, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/:postType(wp_template|wp_template_part)/all" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenTemplatesBrowse, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenTemplatesBrowse, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/:postType(wp_template_part|wp_block)/:postId" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenPattern, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + }, (0,external_React_.createElement)(SidebarNavigationScreenPattern, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { path: "/:postType(wp_template)/:postId" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarNavigationScreenTemplate, null))); + }, (0,external_React_.createElement)(SidebarNavigationScreenTemplate, null))); } function Sidebar() { const { params: urlParams } = sidebar_useLocation(); const initialPath = (0,external_wp_element_namespaceObject.useRef)(getPathFromURL(urlParams)); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { className: "edit-site-sidebar__content", initialPath: initialPath.current - }, (0,external_wp_element_namespaceObject.createElement)(SidebarScreens, null)), (0,external_wp_element_namespaceObject.createElement)(SaveHub, null)); + }, (0,external_React_.createElement)(SidebarScreens, null)), (0,external_React_.createElement)(SaveHub, null)); +} +/* harmony default export */ const sidebar = ((0,external_wp_element_namespaceObject.memo)(Sidebar)); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/error-boundary/warning.js + +/** + * WordPress dependencies + */ + + + + +function CopyButton({ + text, + children +}) { + const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "secondary", + ref: ref + }, children); +} +function ErrorBoundaryWarning({ + message, + error +}) { + const actions = [(0,external_React_.createElement)(CopyButton, { + key: "copy-error", + text: error.stack + }, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))]; + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.Warning, { + className: "editor-error-boundary", + actions: actions + }, message); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/error-boundary/index.js + +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + +class ErrorBoundary extends external_wp_element_namespaceObject.Component { + constructor() { + super(...arguments); + this.state = { + error: null + }; + } + componentDidCatch(error) { + (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error); + } + static getDerivedStateFromError(error) { + return { + error + }; + } + render() { + if (!this.state.error) { + return this.props.children; + } + return (0,external_React_.createElement)(ErrorBoundaryWarning, { + message: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'), + error: this.state.error + }); + } +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/next.js + +/** + * WordPress dependencies + */ + +const next = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" +})); +/* harmony default export */ const library_next = (next); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/previous.js + +/** + * WordPress dependencies + */ + +const previous = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" +})); +/* harmony default export */ const library_previous = (previous); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/external.js + +/** + * WordPress dependencies + */ + +const external = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" +})); +/* harmony default export */ const library_external = (external); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/config.js +/** + * WordPress dependencies + */ + +const textFormattingShortcuts = [{ + keyCombination: { + modifier: 'primary', + character: 'b' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.') +}, { + keyCombination: { + modifier: 'primary', + character: 'i' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.') +}, { + keyCombination: { + modifier: 'primary', + character: 'k' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.') +}, { + keyCombination: { + modifier: 'primaryShift', + character: 'k' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.') +}, { + keyCombination: { + character: '[[' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.') +}, { + keyCombination: { + modifier: 'primary', + character: 'u' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.') +}, { + keyCombination: { + modifier: 'access', + character: 'd' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.') +}, { + keyCombination: { + modifier: 'access', + character: 'x' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.') +}, { + keyCombination: { + modifier: 'access', + character: '0' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.') +}, { + keyCombination: { + modifier: 'access', + character: '1-6' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.') +}]; + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/shortcut.js + +/** + * WordPress dependencies + */ + + +function KeyCombination({ + keyCombination, + forceAriaLabel +}) { + const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character; + const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character; + return (0,external_React_.createElement)("kbd", { + className: "edit-site-keyboard-shortcut-help-modal__shortcut-key-combination", + "aria-label": forceAriaLabel || ariaLabel + }, (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => { + if (character === '+') { + return (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, { + key: index + }, character); + } + return (0,external_React_.createElement)("kbd", { + key: index, + className: "edit-site-keyboard-shortcut-help-modal__shortcut-key" + }, character); + })); +} +function Shortcut({ + description, + keyCombination, + aliases = [], + ariaLabel +}) { + return (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_React_.createElement)("div", { + className: "edit-site-keyboard-shortcut-help-modal__shortcut-description" + }, description), (0,external_React_.createElement)("div", { + className: "edit-site-keyboard-shortcut-help-modal__shortcut-term" + }, (0,external_React_.createElement)(KeyCombination, { + keyCombination: keyCombination, + forceAriaLabel: ariaLabel + }), aliases.map((alias, index) => (0,external_React_.createElement)(KeyCombination, { + keyCombination: alias, + forceAriaLabel: ariaLabel, + key: index + })))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js + +/** + * WordPress dependencies + */ + + + +/** + * Internal dependencies + */ + +function DynamicShortcut({ + name +}) { + const { + keyCombination, + description, + aliases + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getShortcutKeyCombination, + getShortcutDescription, + getShortcutAliases + } = select(external_wp_keyboardShortcuts_namespaceObject.store); + return { + keyCombination: getShortcutKeyCombination(name), + aliases: getShortcutAliases(name), + description: getShortcutDescription(name) + }; + }, [name]); + if (!keyCombination) { + return null; + } + return (0,external_React_.createElement)(Shortcut, { + keyCombination: keyCombination, + description: description, + aliases: aliases + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/index.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + +/** + * Internal dependencies + */ + + + +const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'edit-site/keyboard-shortcut-help'; +const ShortcutList = ({ + shortcuts +}) => +/* + * Disable reason: The `list` ARIA role is redundant but + * Safari+VoiceOver won't announce the list otherwise. + */ +/* eslint-disable jsx-a11y/no-redundant-roles */ +(0,external_React_.createElement)("ul", { + className: "edit-site-keyboard-shortcut-help-modal__shortcut-list", + role: "list" +}, shortcuts.map((shortcut, index) => (0,external_React_.createElement)("li", { + className: "edit-site-keyboard-shortcut-help-modal__shortcut", + key: index +}, typeof shortcut === 'string' ? (0,external_React_.createElement)(DynamicShortcut, { + name: shortcut +}) : (0,external_React_.createElement)(Shortcut, { + ...shortcut +})))) +/* eslint-enable jsx-a11y/no-redundant-roles */; +const ShortcutSection = ({ + title, + shortcuts, + className +}) => (0,external_React_.createElement)("section", { + className: classnames_default()('edit-site-keyboard-shortcut-help-modal__section', className) +}, !!title && (0,external_React_.createElement)("h2", { + className: "edit-site-keyboard-shortcut-help-modal__section-title" +}, title), (0,external_React_.createElement)(ShortcutList, { + shortcuts: shortcuts +})); +const ShortcutCategorySection = ({ + title, + categoryName, + additionalShortcuts = [] +}) => { + const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => { + return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName); + }, [categoryName]); + return (0,external_React_.createElement)(ShortcutSection, { + title: title, + shortcuts: categoryShortcuts.concat(additionalShortcuts) + }); +}; +function KeyboardShortcutHelpModal() { + const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME)); + const { + closeModal, + openModal + } = (0,external_wp_data_namespaceObject.useDispatch)(store); + const toggleModal = () => isModalActive ? closeModal() : openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME); + (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/keyboard-shortcuts', toggleModal); + if (!isModalActive) { + return null; + } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { + className: "edit-site-keyboard-shortcut-help-modal", + title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'), + onRequestClose: toggleModal + }, (0,external_React_.createElement)(ShortcutSection, { + className: "edit-site-keyboard-shortcut-help-modal__main-shortcuts", + shortcuts: ['core/edit-site/keyboard-shortcuts'] + }), (0,external_React_.createElement)(ShortcutCategorySection, { + title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'), + categoryName: "global" + }), (0,external_React_.createElement)(ShortcutCategorySection, { + title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'), + categoryName: "selection" + }), (0,external_React_.createElement)(ShortcutCategorySection, { + title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'), + categoryName: "block", + additionalShortcuts: [{ + keyCombination: { + character: '/' + }, + description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'), + /* translators: The forward-slash character. e.g. '/'. */ + ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash') + }] + }), (0,external_React_.createElement)(ShortcutSection, { + title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'), + shortcuts: textFormattingShortcuts + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/preferences-modal/index.js + +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + +const { + PreferencesModal +} = unlock(external_wp_editor_namespaceObject.privateApis); +const PREFERENCES_MODAL_NAME = 'edit-site/preferences'; +function EditSitePreferencesModal() { + const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(PREFERENCES_MODAL_NAME)); + const { + closeModal + } = (0,external_wp_data_namespaceObject.useDispatch)(store); + if (!isModalActive) { + return null; + } + return (0,external_React_.createElement)(PreferencesModal, { + isActive: isModalActive, + onClose: closeModal + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/tools-more-menu-group/index.js + +/** + * WordPress dependencies + */ + +const { + Fill: ToolsMoreMenuGroup, + Slot +} = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteToolsMoreMenuGroup'); +ToolsMoreMenuGroup.Slot = ({ + fillProps +}) => (0,external_React_.createElement)(Slot, { + fillProps: fillProps +}, fills => fills && fills.length > 0); +/* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/download.js + +/** + * WordPress dependencies + */ + +const download = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + 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" +})); +/* harmony default export */ const library_download = (download); + +;// CONCATENATED MODULE: external ["wp","blob"] +const external_wp_blob_namespaceObject = window["wp"]["blob"]; +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/site-export.js + +/** + * WordPress dependencies + */ + + + + + + + +function SiteExport() { + const { + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + async function handleExport() { + try { + const response = await external_wp_apiFetch_default()({ + path: '/wp-block-editor/v1/export', + parse: false, + headers: { + Accept: 'application/zip' + } + }); + const blob = await response.blob(); + const contentDisposition = response.headers.get('content-disposition'); + const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/); + const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : 'edit-site-export'; + (0,external_wp_blob_namespaceObject.downloadBlob)(fileName + '.zip', blob, 'application/zip'); + } catch (errorResponse) { + let error = {}; + try { + error = await errorResponse.json(); + } catch (e) {} + const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the site export.'); + createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } + } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + role: "menuitem", + icon: library_download, + onClick: handleExport, + info: (0,external_wp_i18n_namespaceObject.__)('Download your theme with updated templates and styles.') + }, (0,external_wp_i18n_namespaceObject._x)('Export', 'site exporter menu item')); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/welcome-guide-menu-item.js + +/** + * WordPress dependencies + */ + + + + +function WelcomeGuideMenuItem() { + const { + toggle + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + onClick: () => toggle('core/edit-site', 'welcomeGuide') + }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide')); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js + +/** + * WordPress dependencies + */ + + + + + + + + +/** + * Internal dependencies + */ + +function CopyContentMenuItem() { + const { + createNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const { + getEditedPostId, + getEditedPostType + } = (0,external_wp_data_namespaceObject.useSelect)(store_store); + const { + getEditedEntityRecord + } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); + function getText() { + const record = getEditedEntityRecord('postType', getEditedPostType(), getEditedPostId()); + if (!record) { + return ''; + } + if (typeof record.content === 'function') { + return record.content(record); + } else if (record.blocks) { + return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks); + } else if (record.content) { + return record.content; + } + } + function onSuccess() { + createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), { + isDismissible: true, + type: 'snackbar' + }); + } + const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + ref: ref + }, (0,external_wp_i18n_namespaceObject.__)('Copy all blocks')); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/mode-switcher/index.js + +/** + * WordPress dependencies + */ + + + + + +/** + * Internal dependencies + */ + + +/** + * Set of available mode options. + * + * @type {Array} + */ +const MODES = [{ + value: 'visual', + label: (0,external_wp_i18n_namespaceObject.__)('Visual editor') +}, { + value: 'text', + label: (0,external_wp_i18n_namespaceObject.__)('Code editor') +}]; +function ModeSwitcher() { + const { + shortcut, + mode + } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ + shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-mode'), + mode: select(store_store).getEditorMode() + }), []); + const { + switchEditorMode + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + const choices = MODES.map(choice => { + if (choice.value !== mode) { + return { + ...choice, + shortcut + }; + } + return choice; + }); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, { + label: (0,external_wp_i18n_namespaceObject.__)('Editor') + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, { + choices: choices, + value: mode, + onSelect: switchEditorMode + })); +} +/* harmony default export */ const mode_switcher = (ModeSwitcher); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/index.js + +/** + * WordPress dependencies + */ + + + + + + + + + +/** + * Internal dependencies + */ + + + + + + + + +function MoreMenu({ + showIconLabels +}) { + const { + openModal + } = (0,external_wp_data_namespaceObject.useDispatch)(store); + const { + set: setPreference + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); + const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { + return select(external_wp_coreData_namespaceObject.store).getCurrentTheme().is_block_theme; + }, []); + const { + toggleDistractionFree + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + const turnOffDistractionFree = () => { + setPreference('core', 'distractionFree', false); + }; + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(MoreMenuDropdown, { + toggleProps: { + showTooltip: !showIconLabels, + ...(showIconLabels && { + variant: 'tertiary' + }) + } + }, ({ + onClose + }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, { + label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun') + }, (0,external_React_.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { + scope: "core", + name: "fixedToolbar", + onToggle: turnOffDistractionFree, + label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'), + info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'), + messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'), + messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated') + }), (0,external_React_.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { + scope: "core", + name: "distractionFree", + label: (0,external_wp_i18n_namespaceObject.__)('Distraction free'), + info: (0,external_wp_i18n_namespaceObject.__)('Write with calmness'), + handleToggling: false, + onToggle: toggleDistractionFree, + messageActivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated'), + messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated'), + shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('\\') + }), (0,external_React_.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { + scope: "core", + name: "focusMode", + label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'), + info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'), + messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'), + messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated') + })), (0,external_React_.createElement)(mode_switcher, null), (0,external_React_.createElement)(action_item.Slot, { + name: "core/edit-site/plugin-more-menu", + label: (0,external_wp_i18n_namespaceObject.__)('Plugins'), + as: external_wp_components_namespaceObject.MenuGroup, + fillProps: { + onClick: onClose + } + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, { + label: (0,external_wp_i18n_namespaceObject.__)('Tools') + }, isBlockBasedTheme && (0,external_React_.createElement)(SiteExport, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + onClick: () => openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME), + shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h') + }, (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')), (0,external_React_.createElement)(WelcomeGuideMenuItem, null), (0,external_React_.createElement)(CopyContentMenuItem, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + icon: library_external, + role: "menuitem", + href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/site-editor/'), + target: "_blank", + rel: "noopener noreferrer" + }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { + as: "span" + }, /* translators: accessibility text */ + (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_React_.createElement)(tools_more_menu_group.Slot, { + fillProps: { + onClose + } + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + onClick: () => openModal(PREFERENCES_MODAL_NAME) + }, (0,external_wp_i18n_namespaceObject.__)('Preferences'))))), (0,external_React_.createElement)(KeyboardShortcutHelpModal, null), (0,external_React_.createElement)(EditSitePreferencesModal, null)); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up-down.js + +/** + * WordPress dependencies + */ + +const chevronUpDown = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "m12 20-4.5-3.6-.9 1.2L12 22l5.5-4.4-.9-1.2L12 20zm0-16 4.5 3.6.9-1.2L12 2 6.5 6.4l.9 1.2L12 4z" +})); +/* harmony default export */ const chevron_up_down = (chevronUpDown); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/document-tools/index.js + +/** + * WordPress dependencies + */ + + + + + + + + +/** + * Internal dependencies + */ + + +const { + DocumentTools: EditorDocumentTools +} = unlock(external_wp_editor_namespaceObject.privateApis); +function DocumentTools({ + blockEditorMode, + hasFixedToolbar, + isDistractionFree +}) { + const { + isVisualMode + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEditorMode + } = select(store_store); + return { + isVisualMode: getEditorMode() === 'visual' + }; + }, []); + const { + __unstableSetEditorMode + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); + const { + setDeviceType + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); + const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); + const isZoomedOutViewExperimentEnabled = window?.__experimentalEnableZoomedOutView && isVisualMode; + const isZoomedOutView = blockEditorMode === 'zoom-out'; + return (0,external_React_.createElement)(EditorDocumentTools, { + disableBlockTools: !isVisualMode, + listViewLabel: (0,external_wp_i18n_namespaceObject.__)('List View') + }, isZoomedOutViewExperimentEnabled && isLargeViewport && !isDistractionFree && !hasFixedToolbar && (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, { + as: external_wp_components_namespaceObject.Button, + className: "edit-site-header-edit-mode__zoom-out-view-toggle", + icon: chevron_up_down, + isPressed: isZoomedOutView + /* translators: button label text should, if possible, be under 16 characters. */, + label: (0,external_wp_i18n_namespaceObject.__)('Zoom-out View'), + onClick: () => { + setDeviceType('Desktop'); + __unstableSetEditorMode(isZoomedOutView ? 'edit' : 'zoom-out'); + }, + size: "compact" + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/index.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + + + + + + +/** + * Internal dependencies + */ + + + + + + + +const { + PostViewLink, + PreviewDropdown +} = unlock(external_wp_editor_namespaceObject.privateApis); +function HeaderEditMode() { + const { + templateType, + isDistractionFree, + blockEditorMode, + blockSelectionStart, + showIconLabels, + editorCanvasView, + hasFixedToolbar, + isZoomOutMode + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEditedPostType + } = select(store_store); + const { + getBlockSelectionStart, + __unstableGetEditorMode + } = select(external_wp_blockEditor_namespaceObject.store); + const { + get: getPreference + } = select(external_wp_preferences_namespaceObject.store); + const { + getDeviceType + } = select(external_wp_editor_namespaceObject.store); + return { + deviceType: getDeviceType(), + templateType: getEditedPostType(), + blockEditorMode: __unstableGetEditorMode(), + blockSelectionStart: getBlockSelectionStart(), + showIconLabels: getPreference('core', 'showIconLabels'), + editorCanvasView: unlock(select(store_store)).getEditorCanvasContainerView(), + hasFixedToolbar: getPreference('core', 'fixedToolbar'), + isDistractionFree: getPreference('core', 'distractionFree'), + isZoomOutMode: __unstableGetEditorMode() === 'zoom-out' + }; + }, []); + const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); + const isTopToolbar = !isZoomOutMode && hasFixedToolbar && isLargeViewport; + const blockToolbarRef = (0,external_wp_element_namespaceObject.useRef)(); + const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); + const hasDefaultEditorCanvasView = !useHasEditorCanvasContainer(); + const isFocusMode = FOCUSABLE_ENTITIES.includes(templateType); + const isZoomedOutView = blockEditorMode === 'zoom-out'; + const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0,external_wp_element_namespaceObject.useState)(true); + const hasBlockSelected = !!blockSelectionStart; + (0,external_wp_element_namespaceObject.useEffect)(() => { + // If we have a new block selection, show the block tools + if (blockSelectionStart) { + setIsBlockToolsCollapsed(false); + } + }, [blockSelectionStart]); + const toolbarVariants = { + isDistractionFree: { + y: '-50px' + }, + isDistractionFreeHovering: { + y: 0 + }, + view: { + y: 0 + }, + edit: { + y: 0 + } + }; + const toolbarTransition = { + type: 'tween', + duration: disableMotion ? 0 : 0.2, + ease: 'easeOut' + }; + return (0,external_React_.createElement)("div", { + className: classnames_default()('edit-site-header-edit-mode', { + 'show-icon-labels': showIconLabels + }) + }, hasDefaultEditorCanvasView && (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + className: "edit-site-header-edit-mode__start", + variants: toolbarVariants, + transition: toolbarTransition + }, (0,external_React_.createElement)(DocumentTools, { + blockEditorMode: blockEditorMode, + isDistractionFree: isDistractionFree + }), isTopToolbar && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { + className: classnames_default()('selected-block-tools-wrapper', { + 'is-collapsed': isBlockToolsCollapsed || !hasBlockSelected + }) + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockToolbar, { + hideDragHandle: true + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.Popover.Slot, { + ref: blockToolbarRef, + name: "block-toolbar" + }), hasBlockSelected && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + className: "edit-site-header-edit-mode__block-tools-toggle", + icon: isBlockToolsCollapsed ? library_next : library_previous, + onClick: () => { + setIsBlockToolsCollapsed(collapsed => !collapsed); + }, + label: isBlockToolsCollapsed ? (0,external_wp_i18n_namespaceObject.__)('Show block tools') : (0,external_wp_i18n_namespaceObject.__)('Hide block tools') + }))), !isDistractionFree && (0,external_React_.createElement)("div", { + className: classnames_default()('edit-site-header-edit-mode__center', { + 'is-collapsed': !isBlockToolsCollapsed && isLargeViewport + }) + }, !hasDefaultEditorCanvasView ? getEditorCanvasContainerTitle(editorCanvasView) : (0,external_React_.createElement)(external_wp_editor_namespaceObject.DocumentBar, null)), (0,external_React_.createElement)("div", { + className: "edit-site-header-edit-mode__end" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + className: "edit-site-header-edit-mode__actions", + variants: toolbarVariants, + transition: toolbarTransition + }, isLargeViewport && (0,external_React_.createElement)("div", { + className: classnames_default()('edit-site-header-edit-mode__preview-options', { + 'is-zoomed-out': isZoomedOutView + }) + }, (0,external_React_.createElement)(PreviewDropdown, { + disabled: isFocusMode || !hasDefaultEditorCanvasView + })), (0,external_React_.createElement)(PostViewLink, null), (0,external_React_.createElement)(SaveButton, null), !isDistractionFree && (0,external_React_.createElement)(pinned_items.Slot, { + scope: "core/edit-site" + }), (0,external_React_.createElement)(MoreMenu, { + showIconLabels: showIconLabels + })))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/wordpress.js + +/** + * WordPress dependencies + */ + +const wordpress = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "-2 -2 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + 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" +})); +/* harmony default export */ const library_wordpress = (wordpress); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/site-icon/index.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + +function SiteIcon({ + className +}) { + const { + isRequestingSite, + siteIconUrl + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEntityRecord + } = select(external_wp_coreData_namespaceObject.store); + const siteData = getEntityRecord('root', '__unstableBase', undefined); + return { + isRequestingSite: !siteData, + siteIconUrl: siteData?.site_icon_url + }; + }, []); + if (isRequestingSite && !siteIconUrl) { + return (0,external_React_.createElement)("div", { + className: "edit-site-site-icon__image" + }); + } + const icon = siteIconUrl ? (0,external_React_.createElement)("img", { + className: "edit-site-site-icon__image", + alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'), + src: siteIconUrl + }) : (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + className: "edit-site-site-icon__icon", + icon: library_wordpress, + size: 48 + }); + return (0,external_React_.createElement)("div", { + className: classnames_default()(className, 'edit-site-site-icon') + }, icon); +} +/* harmony default export */ const site_icon = (SiteIcon); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/site-hub/index.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + + + + + + + + +/** + * Internal dependencies + */ + + + +const HUB_ANIMATION_DURATION = 0.3; +const SiteHub = (0,external_wp_element_namespaceObject.memo)(({ + isTransparent, + className +}) => { + const { + canvasMode, + dashboardLink, + homeUrl, + siteTitle + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getCanvasMode, + getSettings + } = unlock(select(store_store)); + const { + getSite, + getUnstableBase // Site index. + } = select(external_wp_coreData_namespaceObject.store); + return { + canvasMode: getCanvasMode(), + dashboardLink: getSettings().__experimentalDashboardLink || 'index.php', + homeUrl: getUnstableBase()?.home, + siteTitle: getSite()?.title + }; + }, []); + const { + open: openCommandCenter + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store); + const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); + const { + setCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const { + clearSelectedBlock + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); + const { + setDeviceType + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); + const isBackToDashboardButton = canvasMode === 'view'; + const siteIconButtonProps = isBackToDashboardButton ? { + href: dashboardLink, + label: (0,external_wp_i18n_namespaceObject.__)('Go to the Dashboard') + } : { + href: dashboardLink, + // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation. + role: 'button', + label: (0,external_wp_i18n_namespaceObject.__)('Open Navigation'), + onClick: event => { + event.preventDefault(); + if (canvasMode === 'edit') { + clearSelectedBlock(); + setDeviceType('Desktop'); + setCanvasMode('view'); + } + } + }; + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + className: classnames_default()('edit-site-site-hub', className), + variants: { + isDistractionFree: { + x: '-100%' + }, + isDistractionFreeHovering: { + x: 0 + }, + view: { + x: 0 + }, + edit: { + x: 0 + } + }, + initial: false, + transition: { + type: 'tween', + duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, + ease: 'easeOut' + } + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "space-between", + alignment: "center", + className: "edit-site-site-hub__container" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "flex-start", + className: "edit-site-site-hub__text-content", + spacing: "0" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + className: classnames_default()('edit-site-site-hub__view-mode-toggle-container', { + 'has-transparent-background': isTransparent + }), + layout: true, + transition: { + type: 'tween', + duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, + ease: 'easeOut' + } + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + ...siteIconButtonProps, + className: "edit-site-layout__view-mode-toggle" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + initial: false, + animate: { + scale: canvasMode === 'view' ? 0.5 : 1 + }, + whileHover: { + scale: canvasMode === 'view' ? 0.5 : 0.96 + }, + transition: { + type: 'tween', + duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, + ease: 'easeOut' + } + }, (0,external_React_.createElement)(site_icon, { + className: "edit-site-layout__view-mode-toggle-icon" + })))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + layout: canvasMode === 'edit', + animate: { + opacity: canvasMode === 'view' ? 1 : 0 + }, + exit: { + opacity: 0 + }, + className: classnames_default()('edit-site-site-hub__site-title', { + 'is-transparent': isTransparent + }), + transition: { + type: 'tween', + duration: disableMotion ? 0 : 0.2, + ease: 'easeOut', + delay: canvasMode === 'view' ? 0.1 : 0 + } + }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle))), canvasMode === 'view' && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + href: homeUrl, + target: "_blank", + label: (0,external_wp_i18n_namespaceObject.__)('View site (opens in a new tab)'), + "aria-label": (0,external_wp_i18n_namespaceObject.__)('View site (opens in a new tab)'), + icon: library_external, + className: classnames_default()('edit-site-site-hub__site-view-link', { + 'is-transparent': isTransparent + }) + })), canvasMode === 'view' && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + className: classnames_default()('edit-site-site-hub_toggle-command-center', { + 'is-transparent': isTransparent + }), + icon: library_search, + onClick: () => openCommandCenter(), + label: (0,external_wp_i18n_namespaceObject.__)('Open command palette'), + shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('k') + }))); +}); +/* harmony default export */ const site_hub = (SiteHub); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/resizable-frame/index.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + +/** + * Internal dependencies + */ + + + +// Removes the inline styles in the drag handles. +const resizable_frame_HANDLE_STYLES_OVERRIDE = { + position: undefined, + userSelect: undefined, + cursor: undefined, + width: undefined, + height: undefined, + top: undefined, + right: undefined, + bottom: undefined, + left: undefined +}; + +// The minimum width of the frame (in px) while resizing. +const FRAME_MIN_WIDTH = 320; +// The reference width of the frame (in px) used to calculate the aspect ratio. +const FRAME_REFERENCE_WIDTH = 1300; +// 9 : 19.5 is the target aspect ratio enforced (when possible) while resizing. +const FRAME_TARGET_ASPECT_RATIO = 9 / 19.5; +// The minimum distance (in px) between the frame resize handle and the +// viewport's edge. If the frame is resized to be closer to the viewport's edge +// than this distance, then "canvas mode" will be enabled. +const SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200; +// Default size for the `frameSize` state. +const INITIAL_FRAME_SIZE = { + width: '100%', + height: '100%' +}; +function calculateNewHeight(width, initialAspectRatio) { + const lerp = (a, b, amount) => { + return a + (b - a) * amount; + }; + + // Calculate the intermediate aspect ratio based on the current width. + const lerpFactor = 1 - Math.max(0, Math.min(1, (width - FRAME_MIN_WIDTH) / (FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH))); + + // Calculate the height based on the intermediate aspect ratio + // ensuring the frame arrives at the target aspect ratio. + const intermediateAspectRatio = lerp(initialAspectRatio, FRAME_TARGET_ASPECT_RATIO, lerpFactor); + return width / intermediateAspectRatio; +} +function ResizableFrame({ + isFullWidth, + isOversized, + setIsOversized, + isReady, + children, + /** The default (unresized) width/height of the frame, based on the space availalbe in the viewport. */ + defaultSize, + innerContentStyle +}) { + const [frameSize, setFrameSize] = (0,external_wp_element_namespaceObject.useState)(INITIAL_FRAME_SIZE); + // The width of the resizable frame when a new resize gesture starts. + const [startingWidth, setStartingWidth] = (0,external_wp_element_namespaceObject.useState)(); + const [isResizing, setIsResizing] = (0,external_wp_element_namespaceObject.useState)(false); + const [shouldShowHandle, setShouldShowHandle] = (0,external_wp_element_namespaceObject.useState)(false); + const [resizeRatio, setResizeRatio] = (0,external_wp_element_namespaceObject.useState)(1); + const canvasMode = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getCanvasMode(), []); + const { + setCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const FRAME_TRANSITION = { + type: 'tween', + duration: isResizing ? 0 : 0.5 + }; + const frameRef = (0,external_wp_element_namespaceObject.useRef)(null); + const resizableHandleHelpId = (0,external_wp_compose_namespaceObject.useInstanceId)(ResizableFrame, 'edit-site-resizable-frame-handle-help'); + const defaultAspectRatio = defaultSize.width / defaultSize.height; + const handleResizeStart = (_event, _direction, ref) => { + // Remember the starting width so we don't have to get `ref.offsetWidth` on + // every resize event thereafter, which will cause layout thrashing. + setStartingWidth(ref.offsetWidth); + setIsResizing(true); + }; + + // Calculate the frame size based on the window width as its resized. + const handleResize = (_event, _direction, _ref, delta) => { + const normalizedDelta = delta.width / resizeRatio; + const deltaAbs = Math.abs(normalizedDelta); + const maxDoubledDelta = delta.width < 0 // is shrinking + ? deltaAbs : (defaultSize.width - startingWidth) / 2; + const deltaToDouble = Math.min(deltaAbs, maxDoubledDelta); + const doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs; + const singleSegment = 1 - doubleSegment; + setResizeRatio(singleSegment + doubleSegment * 2); + const updatedWidth = startingWidth + delta.width; + setIsOversized(updatedWidth > defaultSize.width); + + // Width will be controlled by the library (via `resizeRatio`), + // so we only need to update the height. + setFrameSize({ + height: isOversized ? '100%' : calculateNewHeight(updatedWidth, defaultAspectRatio) + }); + }; + const handleResizeStop = (_event, _direction, ref) => { + setIsResizing(false); + if (!isOversized) { + return; + } + setIsOversized(false); + const remainingWidth = ref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth; + if (remainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD) { + // Reset the initial aspect ratio if the frame is resized slightly + // above the sidebar but not far enough to trigger full screen. + setFrameSize(INITIAL_FRAME_SIZE); + } else { + // Trigger full screen if the frame is resized far enough to the left. + setCanvasMode('edit'); + } + }; + + // Handle resize by arrow keys + const handleResizableHandleKeyDown = event => { + if (!['ArrowLeft', 'ArrowRight'].includes(event.key)) { + return; + } + event.preventDefault(); + const step = 20 * (event.shiftKey ? 5 : 1); + const delta = step * (event.key === 'ArrowLeft' ? 1 : -1); + const newWidth = Math.min(Math.max(FRAME_MIN_WIDTH, frameRef.current.resizable.offsetWidth + delta), defaultSize.width); + setFrameSize({ + width: newWidth, + height: calculateNewHeight(newWidth, defaultAspectRatio) + }); + }; + const frameAnimationVariants = { + default: { + flexGrow: 0, + height: frameSize.height + }, + fullWidth: { + flexGrow: 1, + height: frameSize.height + } + }; + const resizeHandleVariants = { + hidden: { + opacity: 0, + left: 0 + }, + visible: { + opacity: 1, + left: -16 + }, + active: { + opacity: 1, + left: -16, + scaleY: 1.3 + } + }; + const currentResizeHandleVariant = (() => { + if (isResizing) { + return 'active'; + } + return shouldShowHandle ? 'visible' : 'hidden'; + })(); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.ResizableBox, { + as: external_wp_components_namespaceObject.__unstableMotion.div, + ref: frameRef, + initial: false, + variants: frameAnimationVariants, + animate: isFullWidth ? 'fullWidth' : 'default', + onAnimationComplete: definition => { + if (definition === 'fullWidth') setFrameSize({ + width: '100%', + height: '100%' + }); + }, + transition: FRAME_TRANSITION, + size: frameSize, + enable: { + top: false, + right: false, + bottom: false, + // Resizing will be disabled until the editor content is loaded. + left: isReady, + topRight: false, + bottomRight: false, + bottomLeft: false, + topLeft: false + }, + resizeRatio: resizeRatio, + handleClasses: undefined, + handleStyles: { + left: resizable_frame_HANDLE_STYLES_OVERRIDE, + right: resizable_frame_HANDLE_STYLES_OVERRIDE + }, + minWidth: FRAME_MIN_WIDTH, + maxWidth: isFullWidth ? '100%' : '150%', + maxHeight: '100%', + onFocus: () => setShouldShowHandle(true), + onBlur: () => setShouldShowHandle(false), + onMouseOver: () => setShouldShowHandle(true), + onMouseOut: () => setShouldShowHandle(false), + handleComponent: { + left: canvasMode === 'view' && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { + text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize') + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.button, { + key: "handle", + role: "separator", + "aria-orientation": "vertical", + className: classnames_default()('edit-site-resizable-frame__handle', { + 'is-resizing': isResizing + }), + variants: resizeHandleVariants, + animate: currentResizeHandleVariant, + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'), + "aria-describedby": resizableHandleHelpId, + "aria-valuenow": frameRef.current?.resizable?.offsetWidth || undefined, + "aria-valuemin": FRAME_MIN_WIDTH, + "aria-valuemax": defaultSize.width, + onKeyDown: handleResizableHandleKeyDown, + initial: "hidden", + exit: "hidden", + whileFocus: "active", + whileHover: "active" + })), (0,external_React_.createElement)("div", { + hidden: true, + id: resizableHandleHelpId + }, (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas. Hold shift to resize in larger increments.'))) + }, + onResizeStart: handleResizeStart, + onResize: handleResize, + onResizeStop: handleResizeStop, + className: classnames_default()('edit-site-resizable-frame__inner', { + 'is-resizing': isResizing + }), + showHandle: false // Do not show the default handle, as we're using a custom one. + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + className: "edit-site-resizable-frame__inner-content", + animate: { + borderRadius: isFullWidth ? 0 : 8 + }, + transition: FRAME_TRANSITION, + style: innerContentStyle + }, children)); +} +/* harmony default export */ const resizable_frame = (ResizableFrame); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + + +const { + useLocation: use_sync_canvas_mode_with_url_useLocation, + useHistory: use_sync_canvas_mode_with_url_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +function useSyncCanvasModeWithURL() { + const history = use_sync_canvas_mode_with_url_useHistory(); + const { + params + } = use_sync_canvas_mode_with_url_useLocation(); + const canvasMode = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getCanvasMode(), []); + const { + setCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const currentCanvasMode = (0,external_wp_element_namespaceObject.useRef)(canvasMode); + const { + canvas: canvasInUrl + } = params; + const currentCanvasInUrl = (0,external_wp_element_namespaceObject.useRef)(canvasInUrl); + const currentUrlParams = (0,external_wp_element_namespaceObject.useRef)(params); + (0,external_wp_element_namespaceObject.useEffect)(() => { + currentUrlParams.current = params; + }, [params]); + (0,external_wp_element_namespaceObject.useEffect)(() => { + currentCanvasMode.current = canvasMode; + if (canvasMode === 'init') { + return; + } + if (canvasMode === 'edit' && currentCanvasInUrl.current !== canvasMode) { + history.push({ + ...currentUrlParams.current, + canvas: 'edit' + }); + } + if (canvasMode === 'view' && currentCanvasInUrl.current !== undefined) { + history.push({ + ...currentUrlParams.current, + canvas: undefined + }); + } + }, [canvasMode, history]); + (0,external_wp_element_namespaceObject.useEffect)(() => { + currentCanvasInUrl.current = canvasInUrl; + if (canvasInUrl !== 'edit' && currentCanvasMode.current !== 'view') { + setCanvasMode('view'); + } else if (canvasInUrl === 'edit' && currentCanvasMode.current !== 'edit') { + setCanvasMode('edit'); + } + }, [canvasInUrl, setCanvasMode]); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/use-activate-theme.js +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + + +const { + useHistory: use_activate_theme_useHistory, + useLocation: use_activate_theme_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); + +/** + * This should be refactored to use the REST API, once the REST API can activate themes. + * + * @return {Function} A function that activates the theme. + */ +function useActivateTheme() { + const history = use_activate_theme_useHistory(); + const location = use_activate_theme_useLocation(); + const { + startResolution, + finishResolution + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + return async () => { + if (isPreviewingTheme()) { + const activationURL = 'themes.php?action=activate&stylesheet=' + currentlyPreviewingTheme() + '&_wpnonce=' + window.WP_BLOCK_THEME_ACTIVATE_NONCE; + startResolution('activateTheme'); + await window.fetch(activationURL); + finishResolution('activateTheme'); + const { + wp_theme_preview: themePreview, + ...params + } = location.params; + history.replace(params); + } + }; +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/use-actual-current-theme.js +/** + * WordPress dependencies + */ + + + +const ACTIVE_THEMES_URL = '/wp/v2/themes?status=active'; +function useActualCurrentTheme() { + const [currentTheme, setCurrentTheme] = (0,external_wp_element_namespaceObject.useState)(); + (0,external_wp_element_namespaceObject.useEffect)(() => { + // Set the `wp_theme_preview` to empty string to bypass the createThemePreviewMiddleware. + const path = (0,external_wp_url_namespaceObject.addQueryArgs)(ACTIVE_THEMES_URL, { + context: 'edit', + wp_theme_preview: '' + }); + external_wp_apiFetch_default()({ + path + }).then(activeThemes => setCurrentTheme(activeThemes[0])) + // Do nothing + .catch(() => {}); + }, []); + return currentTheme; +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/save-panel/index.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + + +/** + * Internal dependencies + */ + + + + + +const { + EntitiesSavedStatesExtensible +} = unlock(external_wp_editor_namespaceObject.privateApis); +const EntitiesSavedStatesForPreview = ({ + onClose +}) => { + var _currentTheme$name$re, _previewingTheme$name; + const isDirtyProps = (0,external_wp_editor_namespaceObject.useEntitiesSavedStatesIsDirty)(); + let activateSaveLabel; + if (isDirtyProps.isDirty) { + activateSaveLabel = (0,external_wp_i18n_namespaceObject.__)('Activate & Save'); + } else { + activateSaveLabel = (0,external_wp_i18n_namespaceObject.__)('Activate'); + } + const currentTheme = useActualCurrentTheme(); + const previewingTheme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme(), []); + const additionalPrompt = (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1$s: The name of active theme, %2$s: The name of theme to be activated. */ + (0,external_wp_i18n_namespaceObject.__)('Saving your changes will change your active theme from %1$s to %2$s.'), (_currentTheme$name$re = currentTheme?.name?.rendered) !== null && _currentTheme$name$re !== void 0 ? _currentTheme$name$re : '...', (_previewingTheme$name = previewingTheme?.name?.rendered) !== null && _previewingTheme$name !== void 0 ? _previewingTheme$name : '...')); + const activateTheme = useActivateTheme(); + const onSave = async values => { + await activateTheme(); + return values; + }; + return (0,external_React_.createElement)(EntitiesSavedStatesExtensible, { + ...isDirtyProps, + additionalPrompt, + close: onClose, + onSave, + saveEnabled: true, + saveLabel: activateSaveLabel + }); +}; +const _EntitiesSavedStates = ({ + onClose +}) => { + if (isPreviewingTheme()) { + return (0,external_React_.createElement)(EntitiesSavedStatesForPreview, { + onClose: onClose + }); + } + return (0,external_React_.createElement)(external_wp_editor_namespaceObject.EntitiesSavedStates, { + close: onClose + }); +}; +function SavePanel() { + const { + isSaveViewOpen, + canvasMode + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + isSaveViewOpened, + getCanvasMode + } = unlock(select(store_store)); + + // The currently selected entity to display. + // Typically template or template part in the site editor. + return { + isSaveViewOpen: isSaveViewOpened(), + canvasMode: getCanvasMode() + }; + }, []); + const { + setIsSaveViewOpened + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + const onClose = () => setIsSaveViewOpened(false); + if (canvasMode === 'view') { + return isSaveViewOpen ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { + className: "edit-site-save-panel__modal", + onRequestClose: onClose, + __experimentalHideHeader: true, + contentLabel: (0,external_wp_i18n_namespaceObject.__)('Save site, content, and template changes') + }, (0,external_React_.createElement)(_EntitiesSavedStates, { + onClose: onClose + })) : null; + } + return (0,external_React_.createElement)(NavigableRegion, { + className: classnames_default()('edit-site-layout__actions', { + 'is-entity-save-view-open': isSaveViewOpen + }), + ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Save panel') + }, isSaveViewOpen ? (0,external_React_.createElement)(_EntitiesSavedStates, { + onClose: onClose + }) : (0,external_React_.createElement)("div", { + className: "edit-site-editor__toggle-save-panel" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "secondary", + className: "edit-site-editor__toggle-save-panel-button", + onClick: () => setIsSaveViewOpened(true), + "aria-expanded": false + }, (0,external_wp_i18n_namespaceObject.__)('Open save panel')))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcuts/register.js +/** + * WordPress dependencies + */ + + + + +function KeyboardShortcutsRegister() { + // Registering the shortcuts. + const { + registerShortcut + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); + (0,external_wp_element_namespaceObject.useEffect)(() => { + registerShortcut({ + name: 'core/edit-site/save', + category: 'global', + description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'), + keyCombination: { + modifier: 'primary', + character: 's' + } + }); + registerShortcut({ + name: 'core/edit-site/toggle-block-settings-sidebar', + category: 'global', + description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings sidebar.'), + keyCombination: { + modifier: 'primaryShift', + character: ',' + } + }); + registerShortcut({ + name: 'core/edit-site/keyboard-shortcuts', + category: 'main', + description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'), + keyCombination: { + modifier: 'access', + character: 'h' + } + }); + registerShortcut({ + name: 'core/edit-site/next-region', + category: 'global', + description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'), + keyCombination: { + modifier: 'ctrl', + character: '`' + }, + aliases: [{ + modifier: 'access', + character: 'n' + }] + }); + registerShortcut({ + name: 'core/edit-site/previous-region', + category: 'global', + description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'), + keyCombination: { + modifier: 'ctrlShift', + character: '`' + }, + aliases: [{ + modifier: 'access', + character: 'p' + }, { + modifier: 'ctrlShift', + character: '~' + }] + }); + registerShortcut({ + name: 'core/edit-site/toggle-mode', + category: 'global', + description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'), + keyCombination: { + modifier: 'secondary', + character: 'm' + } + }); + registerShortcut({ + name: 'core/edit-site/transform-heading-to-paragraph', + category: 'block-library', + description: (0,external_wp_i18n_namespaceObject.__)('Transform heading to paragraph.'), + keyCombination: { + modifier: 'access', + character: `0` + } + }); + [1, 2, 3, 4, 5, 6].forEach(level => { + registerShortcut({ + name: `core/edit-site/transform-paragraph-to-heading-${level}`, + category: 'block-library', + description: (0,external_wp_i18n_namespaceObject.__)('Transform paragraph to heading.'), + keyCombination: { + modifier: 'access', + character: `${level}` + } + }); + }); + registerShortcut({ + name: 'core/edit-site/toggle-distraction-free', + category: 'global', + description: (0,external_wp_i18n_namespaceObject.__)('Toggle distraction free mode.'), + keyCombination: { + modifier: 'primaryShift', + character: '\\' + } + }); + }, [registerShortcut]); + return null; } -/* harmony default export */ var sidebar = ((0,external_wp_element_namespaceObject.memo)(Sidebar)); +/* harmony default export */ const register = (KeyboardShortcutsRegister); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcuts/global.js +/** + * WordPress dependencies + */ + + + + + +/** + * Internal dependencies + */ + + +function KeyboardShortcutsGlobal() { + const { + __experimentalGetDirtyEntityRecords, + isSavingEntityRecord + } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); + const { + hasNonPostEntityChanges + } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_editor_namespaceObject.store); + const { + getCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); + const { + setIsSaveViewOpened + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/save', event => { + event.preventDefault(); + const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); + const hasDirtyEntities = !!dirtyEntityRecords.length; + const isSaving = dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)); + const _hasNonPostEntityChanges = hasNonPostEntityChanges(); + const isViewMode = getCanvasMode() === 'view'; + if ((!hasDirtyEntities || !_hasNonPostEntityChanges || isSaving) && !isViewMode) { + return; + } + // At this point, we know that there are dirty entities, other than + // the edited post, and we're not in the process of saving, so open + // save view. + setIsSaveViewOpened(true); + }); + return null; +} +/* harmony default export */ const global = (KeyboardShortcutsGlobal); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/help.js + +/** + * WordPress dependencies + */ + +const help = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zM3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 8.75a1.5 1.5 0 01.167 2.99c-.465.052-.917.44-.917 1.01V14h1.5v-.845A3 3 0 109 10.25h1.5a1.5 1.5 0 011.5-1.5zM11.25 15v1.5h1.5V15h-1.5z" +})); +/* harmony default export */ const library_help = (help); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-right.js + +/** + * WordPress dependencies + */ + +const rotateRight = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M15.1 4.8l-3-2.5V4c-4.4 0-8 3.6-8 8 0 3.7 2.5 6.9 6 7.7.3.1.6.1 1 .2l.2-1.5c-.4 0-.7-.1-1.1-.2l-.1.2v-.2c-2.6-.8-4.5-3.3-4.5-6.2 0-3.6 2.9-6.5 6.5-6.5v1.8l3-2.5zM20 11c-.2-1.4-.7-2.7-1.6-3.8l-1.2.8c.7.9 1.1 2 1.3 3.1L20 11zm-1.5 1.8c-.1.5-.2 1.1-.4 1.6s-.5 1-.8 1.5l1.2.9c.4-.5.8-1.1 1-1.8s.5-1.3.5-2l-1.5-.2zm-5.6 5.6l.2 1.5c1.4-.2 2.7-.7 3.8-1.6l-.9-1.1c-.9.7-2 1.1-3.1 1.2z" +})); +/* harmony default export */ const rotate_right = (rotateRight); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-left.js + +/** + * WordPress dependencies + */ + +const rotateLeft = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M12 4V2.2L9 4.8l3 2.5V5.5c3.6 0 6.5 2.9 6.5 6.5 0 2.9-1.9 5.3-4.5 6.2v.2l-.1-.2c-.4.1-.7.2-1.1.2l.2 1.5c.3 0 .6-.1 1-.2 3.5-.9 6-4 6-7.7 0-4.4-3.6-8-8-8zm-7.9 7l1.5.2c.1-1.2.5-2.3 1.2-3.2l-1.1-.9C4.8 8.2 4.3 9.6 4.1 11zm1.5 1.8l-1.5.2c.1.7.3 1.4.5 2 .3.7.6 1.3 1 1.8l1.2-.8c-.3-.5-.6-1-.8-1.5s-.4-1.1-.4-1.7zm1.5 5.5c1.1.9 2.4 1.4 3.8 1.6l.2-1.5c-1.1-.1-2.2-.5-3.1-1.2l-.9 1.1z" +})); +/* harmony default export */ const rotate_left = (rotateLeft); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/brush.js + +/** + * WordPress dependencies + */ + +const brush = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z" +})); +/* harmony default export */ const library_brush = (brush); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/get-is-list-page.js +/** + * Returns if the params match the list page route. + * + * @param {Object} params The url params. + * @param {string} params.path The current path. + * @param {string} [params.categoryType] The current category type. + * @param {string} [params.categoryId] The current category id. + * @param {boolean} isMobileViewport Is mobile viewport. + * + * @return {boolean} Is list page or not. + */ +function getIsListPage({ + path, + categoryType, + categoryId +}, isMobileViewport) { + return ['/wp_template/all', '/wp_template_part/all', '/pages'].includes(path) || path === '/patterns' && ( + // Don't treat "/patterns" without categoryType and categoryId as a + // list page in mobile because the sidebar covers the whole page. + !isMobileViewport || !!categoryType && !!categoryId); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/commands/use-common-commands.js +/** + * WordPress dependencies + */ + + + + + + + + + + + +/** + * Internal dependencies + */ + + + +const { + useGlobalStylesReset +} = unlock(external_wp_blockEditor_namespaceObject.privateApis); +const { + useHistory: use_common_commands_useHistory, + useLocation: use_common_commands_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); +function useGlobalStylesOpenStylesCommands() { + const { + openGeneralSidebar, + setCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const { + params + } = use_common_commands_useLocation(); + const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); + const isEditorPage = !getIsListPage(params, isMobileViewport); + const { + getCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); + const history = use_common_commands_useHistory(); + const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { + return select(external_wp_coreData_namespaceObject.store).getCurrentTheme().is_block_theme; + }, []); + const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!isBlockBasedTheme) { + return []; + } + return [{ + name: 'core/edit-site/open-styles', + label: (0,external_wp_i18n_namespaceObject.__)('Open styles'), + callback: ({ + close + }) => { + close(); + if (!isEditorPage) { + history.push({ + path: '/wp_global_styles', + canvas: 'edit' + }); + } + if (isEditorPage && getCanvasMode() !== 'edit') { + setCanvasMode('edit'); + } + openGeneralSidebar('edit-site/global-styles'); + }, + icon: library_styles + }]; + }, [history, openGeneralSidebar, setCanvasMode, isEditorPage, getCanvasMode, isBlockBasedTheme]); + return { + isLoading: false, + commands + }; +} +function useGlobalStylesToggleWelcomeGuideCommands() { + const { + openGeneralSidebar, + setCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const { + params + } = use_common_commands_useLocation(); + const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); + const isEditorPage = !getIsListPage(params, isMobileViewport); + const { + getCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); + const { + set + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); + const history = use_common_commands_useHistory(); + const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { + return select(external_wp_coreData_namespaceObject.store).getCurrentTheme().is_block_theme; + }, []); + const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!isBlockBasedTheme) { + return []; + } + return [{ + name: 'core/edit-site/toggle-styles-welcome-guide', + label: (0,external_wp_i18n_namespaceObject.__)('Learn about styles'), + callback: ({ + close + }) => { + close(); + if (!isEditorPage) { + history.push({ + path: '/wp_global_styles', + canvas: 'edit' + }); + } + if (isEditorPage && getCanvasMode() !== 'edit') { + setCanvasMode('edit'); + } + openGeneralSidebar('edit-site/global-styles'); + set('core/edit-site', 'welcomeGuideStyles', true); + // sometimes there's a focus loss that happens after some time + // that closes the modal, we need to force reopening it. + setTimeout(() => { + set('core/edit-site', 'welcomeGuideStyles', true); + }, 500); + }, + icon: library_help + }]; + }, [history, openGeneralSidebar, setCanvasMode, isEditorPage, getCanvasMode, isBlockBasedTheme, set]); + return { + isLoading: false, + commands + }; +} +function useGlobalStylesResetCommands() { + const [canReset, onReset] = useGlobalStylesReset(); + const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!canReset) { + return []; + } + return [{ + name: 'core/edit-site/reset-global-styles', + label: (0,external_wp_i18n_namespaceObject.__)('Reset styles'), + icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? rotate_right : rotate_left, + callback: ({ + close + }) => { + close(); + onReset(); + } + }]; + }, [canReset, onReset]); + return { + isLoading: false, + commands + }; +} +function useGlobalStylesOpenCssCommands() { + const { + openGeneralSidebar, + setEditorCanvasContainerView, + setCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const { + params + } = use_common_commands_useLocation(); + const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); + const isListPage = getIsListPage(params, isMobileViewport); + const isEditorPage = !isListPage; + const history = use_common_commands_useHistory(); + const { + canEditCSS + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEntityRecord, + __experimentalGetCurrentGlobalStylesId + } = select(external_wp_coreData_namespaceObject.store); + const globalStylesId = __experimentalGetCurrentGlobalStylesId(); + const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; + return { + canEditCSS: !!globalStyles?._links?.['wp:action-edit-css'] + }; + }, []); + const { + getCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); + const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!canEditCSS) { + return []; + } + return [{ + name: 'core/edit-site/open-styles-css', + label: (0,external_wp_i18n_namespaceObject.__)('Customize CSS'), + icon: library_brush, + callback: ({ + close + }) => { + close(); + if (!isEditorPage) { + history.push({ + path: '/wp_global_styles', + canvas: 'edit' + }); + } + if (isEditorPage && getCanvasMode() !== 'edit') { + setCanvasMode('edit'); + } + openGeneralSidebar('edit-site/global-styles'); + setEditorCanvasContainerView('global-styles-css'); + } + }]; + }, [history, openGeneralSidebar, setEditorCanvasContainerView, canEditCSS, isEditorPage, getCanvasMode, setCanvasMode]); + return { + isLoading: false, + commands + }; +} +function useGlobalStylesOpenRevisionsCommands() { + const { + openGeneralSidebar, + setEditorCanvasContainerView, + setCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const { + getCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); + const { + params + } = use_common_commands_useLocation(); + const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); + const isEditorPage = !getIsListPage(params, isMobileViewport); + const history = use_common_commands_useHistory(); + const hasRevisions = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEntityRecord, + __experimentalGetCurrentGlobalStylesId + } = select(external_wp_coreData_namespaceObject.store); + const globalStylesId = __experimentalGetCurrentGlobalStylesId(); + const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; + return !!globalStyles?._links?.['version-history']?.[0]?.count; + }, []); + const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!hasRevisions) { + return []; + } + return [{ + name: 'core/edit-site/open-global-styles-revisions', + label: (0,external_wp_i18n_namespaceObject.__)('Style revisions'), + icon: library_backup, + callback: ({ + close + }) => { + close(); + if (!isEditorPage) { + history.push({ + path: '/wp_global_styles', + canvas: 'edit' + }); + } + if (isEditorPage && getCanvasMode() !== 'edit') { + setCanvasMode('edit'); + } + openGeneralSidebar('edit-site/global-styles'); + setEditorCanvasContainerView('global-styles-revisions'); + } + }]; + }, [hasRevisions, history, openGeneralSidebar, setEditorCanvasContainerView, isEditorPage, getCanvasMode, setCanvasMode]); + return { + isLoading: false, + commands + }; +} +function useCommonCommands() { + const homeUrl = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getUnstableBase // Site index. + } = select(external_wp_coreData_namespaceObject.store); + return getUnstableBase()?.home; + }, []); + (0,external_wp_commands_namespaceObject.useCommand)({ + name: 'core/edit-site/view-site', + label: (0,external_wp_i18n_namespaceObject.__)('View site'), + callback: ({ + close + }) => { + close(); + window.open(homeUrl, '_blank'); + }, + icon: library_external + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/open-styles', + hook: useGlobalStylesOpenStylesCommands + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/toggle-styles-welcome-guide', + hook: useGlobalStylesToggleWelcomeGuideCommands + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/reset-global-styles', + hook: useGlobalStylesResetCommands + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/open-styles-css', + hook: useGlobalStylesOpenCssCommands + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/open-styles-revisions', + hook: useGlobalStylesOpenRevisionsCommands + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/code.js + +/** + * WordPress dependencies + */ + +const code = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + viewBox: "0 0 24 24", + xmlns: "http://www.w3.org/2000/svg" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z" +})); +/* harmony default export */ const library_code = (code); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drawer-left.js @@ -20558,17 +24715,17 @@ function Sidebar() { * WordPress dependencies */ -const drawerLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const drawerLeft = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { width: "24", height: "24", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z" })); -/* harmony default export */ var drawer_left = (drawerLeft); +/* harmony default export */ const drawer_left = (drawerLeft); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drawer-right.js @@ -20576,30 +24733,706 @@ const drawerLeft = (0,external_wp_element_namespaceObject.createElement)(externa * WordPress dependencies */ -const drawerRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const drawerRight = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { width: "24", height: "24", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z" })); -/* harmony default export */ var drawer_right = (drawerRight); +/* harmony default export */ const drawer_right = (drawerRight); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/default-sidebar.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js + +/** + * WordPress dependencies + */ + +const blockDefault = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" +})); +/* harmony default export */ const block_default = (blockDefault); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard.js + +/** + * WordPress dependencies + */ + +const keyboard = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "m16 15.5h-8v-1.5h8zm-7.5-2.5h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm-9-3h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2z" +}), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "m18.5 6.5h-13a.5.5 0 0 0 -.5.5v9.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9.5a.5.5 0 0 0 -.5-.5zm-13-1.5h13a2 2 0 0 1 2 2v9.5a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2-2v-9.5a2 2 0 0 1 2-2z" +})); +/* harmony default export */ const library_keyboard = (keyboard); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js + +/** + * WordPress dependencies + */ + +const listView = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + viewBox: "0 0 24 24", + xmlns: "http://www.w3.org/2000/svg" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" +})); +/* harmony default export */ const list_view = (listView); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/pattern-modal/rename.js + +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + + + +const { + RenamePatternModal +} = unlock(external_wp_patterns_namespaceObject.privateApis); +function PatternRenameModal() { + const { + record: pattern + } = useEditedEntityRecord(); + const { + closeModal + } = (0,external_wp_data_namespaceObject.useDispatch)(store); + const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(PATTERN_MODALS.rename)); + if (!isActive) { + return null; + } + return (0,external_React_.createElement)(RenamePatternModal, { + onClose: closeModal, + pattern: pattern + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/pattern-modal/duplicate.js + +/** + * WordPress dependencies + */ + + + + + + +/** + * Internal dependencies + */ + + + + +const { + DuplicatePatternModal +} = unlock(external_wp_patterns_namespaceObject.privateApis); +const { + useHistory: duplicate_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +function PatternDuplicateModal() { + const { + record + } = useEditedEntityRecord(); + const { + categoryType, + categoryId + } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); + const { + closeModal + } = (0,external_wp_data_namespaceObject.useDispatch)(store); + const history = duplicate_useHistory(); + const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(PATTERN_MODALS.duplicate)); + if (!isActive) { + return null; + } + function onSuccess({ + pattern: newPattern + }) { + history.push({ + categoryType, + categoryId, + postType: PATTERN_TYPES.user, + postId: newPattern.id + }); + closeModal(); + } + return (0,external_React_.createElement)(DuplicatePatternModal, { + onClose: closeModal, + onSuccess: onSuccess, + pattern: record + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/pattern-modal/index.js + +/** + * Internal dependencies + */ + +const PATTERN_MODALS = { + rename: 'edit-site/pattern-rename', + duplicate: 'edit-site/pattern-duplicate' +}; +function PatternModal() { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(PatternDuplicateModal, null), (0,external_React_.createElement)(PatternRenameModal, null)); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/commands/use-edit-mode-commands.js /** * WordPress dependencies */ + + + + + + + + /** * Internal dependencies */ + + + + + + + + + +const { + useHistory: use_edit_mode_commands_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +function usePageContentFocusCommands() { + const { + record: template + } = useEditedEntityRecord(); + const { + isPage, + canvasMode, + templateId, + currentPostType + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + isPage: _isPage, + getCanvasMode + } = unlock(select(store_store)); + const { + getCurrentPostType, + getCurrentTemplateId + } = select(external_wp_editor_namespaceObject.store); + return { + isPage: _isPage(), + canvasMode: getCanvasMode(), + templateId: getCurrentTemplateId(), + currentPostType: getCurrentPostType() + }; + }, []); + const { + onClick: editTemplate + } = useLink({ + postType: 'wp_template', + postId: templateId + }); + const { + setRenderingMode + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); + if (!isPage || canvasMode !== 'edit') { + return { + isLoading: false, + commands: [] + }; + } + const commands = []; + if (currentPostType !== 'wp_template') { + commands.push({ + name: 'core/switch-to-template-focus', + label: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template title */ + (0,external_wp_i18n_namespaceObject.__)('Edit template: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)), + icon: library_layout, + callback: ({ + close + }) => { + editTemplate(); + close(); + } + }); + } else { + commands.push({ + name: 'core/switch-to-page-focus', + label: (0,external_wp_i18n_namespaceObject.__)('Back to page'), + icon: library_page, + callback: ({ + close + }) => { + setRenderingMode('template-locked'); + close(); + } + }); + } + return { + isLoading: false, + commands + }; +} +function useEditorModeCommands() { + const { + switchEditorMode + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + const { + canvasMode, + editorMode + } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ + canvasMode: unlock(select(store_store)).getCanvasMode(), + editorMode: select(store_store).getEditorMode() + }), []); + if (canvasMode !== 'edit' || editorMode !== 'text') { + return { + isLoading: false, + commands: [] + }; + } + const commands = []; + if (editorMode === 'text') { + commands.push({ + name: 'core/exit-code-editor', + label: (0,external_wp_i18n_namespaceObject.__)('Exit code editor'), + icon: library_code, + callback: ({ + close + }) => { + switchEditorMode('visual'); + close(); + } + }); + } + return { + isLoading: false, + commands + }; +} +function useManipulateDocumentCommands() { + const { + isLoaded, + record: template + } = useEditedEntityRecord(); + const { + removeTemplate, + revertTemplate + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + const history = use_edit_mode_commands_useHistory(); + const isEditingPage = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).isPage() && select(external_wp_editor_namespaceObject.store).getCurrentPostType() !== 'wp_template', []); + if (!isLoaded) { + return { + isLoading: true, + commands: [] + }; + } + const commands = []; + if (isTemplateRevertable(template) && !isEditingPage) { + const label = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template title */ + (0,external_wp_i18n_namespaceObject.__)('Reset template: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template part title */ + (0,external_wp_i18n_namespaceObject.__)('Reset template part: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)); + commands.push({ + name: 'core/reset-template', + label, + icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? rotate_right : rotate_left, + callback: ({ + close + }) => { + revertTemplate(template); + close(); + } + }); + } + if (isTemplateRemovable(template) && !isEditingPage) { + const label = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template title */ + (0,external_wp_i18n_namespaceObject.__)('Delete template: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template part title */ + (0,external_wp_i18n_namespaceObject.__)('Delete template part: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)); + const path = template.type === constants_TEMPLATE_POST_TYPE ? '/wp_template' : '/wp_template_part/all'; + commands.push({ + name: 'core/remove-template', + label, + icon: library_trash, + callback: ({ + close + }) => { + removeTemplate(template); + // Navigate to the template list + history.push({ + path + }); + close(); + } + }); + } + return { + isLoading: !isLoaded, + commands + }; +} +function useEditUICommands() { + const { + openGeneralSidebar, + closeGeneralSidebar, + toggleDistractionFree, + setIsListViewOpened, + switchEditorMode + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + const { + canvasMode, + editorMode, + activeSidebar, + showBlockBreadcrumbs, + isListViewOpen, + isDistractionFree, + isTopToolbar, + isFocusMode + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + get + } = select(external_wp_preferences_namespaceObject.store); + const { + getEditorMode + } = select(store_store); + const { + isListViewOpened + } = select(external_wp_editor_namespaceObject.store); + return { + canvasMode: unlock(select(store_store)).getCanvasMode(), + editorMode: getEditorMode(), + activeSidebar: select(store).getActiveComplementaryArea(store_store.name), + showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'), + isListViewOpen: isListViewOpened(), + isDistractionFree: get('core', 'distractionFree'), + isFocusMode: get('core', 'focusMode'), + isTopToolbar: get('core', 'fixedToolbar') + }; + }, []); + const { + openModal + } = (0,external_wp_data_namespaceObject.useDispatch)(store); + const { + toggle + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); + const { + createInfoNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + if (canvasMode !== 'edit') { + return { + isLoading: false, + commands: [] + }; + } + const commands = []; + commands.push({ + name: 'core/open-settings-sidebar', + label: (0,external_wp_i18n_namespaceObject.__)('Toggle settings sidebar'), + icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right, + callback: ({ + close + }) => { + close(); + if (activeSidebar === 'edit-site/template') { + closeGeneralSidebar(); + } else { + openGeneralSidebar('edit-site/template'); + } + } + }); + commands.push({ + name: 'core/open-block-inspector', + label: (0,external_wp_i18n_namespaceObject.__)('Toggle block inspector'), + icon: block_default, + callback: ({ + close + }) => { + close(); + if (activeSidebar === 'edit-site/block-inspector') { + closeGeneralSidebar(); + } else { + openGeneralSidebar('edit-site/block-inspector'); + } + } + }); + commands.push({ + name: 'core/toggle-spotlight-mode', + label: (0,external_wp_i18n_namespaceObject.__)('Toggle spotlight'), + callback: ({ + close + }) => { + toggle('core', 'focusMode'); + close(); + createInfoNotice(isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Spotlight off.') : (0,external_wp_i18n_namespaceObject.__)('Spotlight on.'), { + id: 'core/edit-site/toggle-spotlight-mode/notice', + type: 'snackbar', + actions: [{ + label: (0,external_wp_i18n_namespaceObject.__)('Undo'), + onClick: () => { + toggle('core', 'focusMode'); + } + }] + }); + } + }); + commands.push({ + name: 'core/toggle-distraction-free', + label: isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Exit Distraction Free') : (0,external_wp_i18n_namespaceObject.__)('Enter Distraction Free '), + callback: ({ + close + }) => { + toggleDistractionFree(); + close(); + } + }); + commands.push({ + name: 'core/toggle-top-toolbar', + label: (0,external_wp_i18n_namespaceObject.__)('Toggle top toolbar'), + callback: ({ + close + }) => { + toggle('core', 'fixedToolbar'); + if (isDistractionFree) { + toggleDistractionFree(); + } + close(); + createInfoNotice(isTopToolbar ? (0,external_wp_i18n_namespaceObject.__)('Top toolbar off.') : (0,external_wp_i18n_namespaceObject.__)('Top toolbar on.'), { + id: 'core/edit-site/toggle-top-toolbar/notice', + type: 'snackbar', + actions: [{ + label: (0,external_wp_i18n_namespaceObject.__)('Undo'), + onClick: () => { + toggle('core', 'fixedToolbar'); + } + }] + }); + } + }); + if (editorMode === 'visual') { + commands.push({ + name: 'core/toggle-code-editor', + label: (0,external_wp_i18n_namespaceObject.__)('Open code editor'), + icon: library_code, + callback: ({ + close + }) => { + switchEditorMode('text'); + close(); + } + }); + } + commands.push({ + name: 'core/open-preferences', + label: (0,external_wp_i18n_namespaceObject.__)('Editor preferences'), + callback: () => { + openModal(PREFERENCES_MODAL_NAME); + } + }); + commands.push({ + name: 'core/open-shortcut-help', + label: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'), + icon: library_keyboard, + callback: () => { + openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME); + } + }); + commands.push({ + name: 'core/toggle-breadcrumbs', + label: showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Hide block breadcrumbs') : (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs'), + callback: ({ + close + }) => { + toggle('core', 'showBlockBreadcrumbs'); + close(); + createInfoNotice(showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs hidden.') : (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs visible.'), { + id: 'core/edit-site/toggle-breadcrumbs/notice', + type: 'snackbar' + }); + } + }); + commands.push({ + name: 'core/toggle-list-view', + label: isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('Close List View') : (0,external_wp_i18n_namespaceObject.__)('Open List View'), + icon: list_view, + callback: ({ + close + }) => { + setIsListViewOpened(!isListViewOpen); + close(); + createInfoNotice(isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View off.') : (0,external_wp_i18n_namespaceObject.__)('List View on.'), { + id: 'core/edit-site/toggle-list-view/notice', + type: 'snackbar' + }); + } + }); + return { + isLoading: false, + commands + }; +} +function usePatternCommands() { + const { + isLoaded, + record: pattern + } = useEditedEntityRecord(); + const { + openModal + } = (0,external_wp_data_namespaceObject.useDispatch)(store); + if (!isLoaded) { + return { + isLoading: true, + commands: [] + }; + } + const commands = []; + if (pattern?.type === 'wp_block') { + commands.push({ + name: 'core/rename-pattern', + label: (0,external_wp_i18n_namespaceObject.__)('Rename pattern'), + icon: edit, + callback: ({ + close + }) => { + openModal(PATTERN_MODALS.rename); + close(); + } + }); + commands.push({ + name: 'core/duplicate-pattern', + label: (0,external_wp_i18n_namespaceObject.__)('Duplicate pattern'), + icon: library_symbol, + callback: ({ + close + }) => { + openModal(PATTERN_MODALS.duplicate); + close(); + } + }); + } + return { + isLoading: false, + commands + }; +} +function useEditModeCommands() { + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/exit-code-editor', + hook: useEditorModeCommands, + context: 'site-editor-edit' + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/page-content-focus', + hook: usePageContentFocusCommands, + context: 'site-editor-edit' + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/manipulate-document', + hook: useManipulateDocumentCommands + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/patterns', + hook: usePatternCommands, + context: 'site-editor-edit' + }); + (0,external_wp_commands_namespaceObject.useCommandLoader)({ + name: 'core/edit-site/edit-ui', + hook: useEditUICommands + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/layout/hooks.js +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + +const MAX_LOADING_TIME = 10000; // 10 seconds + +function useIsSiteEditorLoading() { + const { + isLoaded: hasLoadedPost + } = useEditedEntityRecord(); + const [loaded, setLoaded] = (0,external_wp_element_namespaceObject.useState)(false); + const inLoadingPause = (0,external_wp_data_namespaceObject.useSelect)(select => { + const hasResolvingSelectors = select(external_wp_coreData_namespaceObject.store).hasResolvingSelectors(); + return !loaded && !hasResolvingSelectors; + }, [loaded]); + + /* + * If the maximum expected loading time has passed, we're marking the + * editor as loaded, in order to prevent any failed requests from blocking + * the editor canvas from appearing. + */ + (0,external_wp_element_namespaceObject.useEffect)(() => { + let timeout; + if (!loaded) { + timeout = setTimeout(() => { + setLoaded(true); + }, MAX_LOADING_TIME); + } + return () => { + clearTimeout(timeout); + }; + }, [loaded]); + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (inLoadingPause) { + /* + * We're using an arbitrary 100ms timeout here to catch brief + * moments without any resolving selectors that would result in + * displaying brief flickers of loading state and loaded state. + * + * It's worth experimenting with different values, since this also + * adds 100ms of artificial delay after loading has finished. + */ + const ARTIFICIAL_DELAY = 100; + const timeout = setTimeout(() => { + setLoaded(true); + }, ARTIFICIAL_DELAY); + return () => { + clearTimeout(timeout); + }; + } + }, [inLoadingPause]); + return !loaded || !hasLoadedPost; +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/default-sidebar.js + +/** + * WordPress dependencies + */ + function DefaultSidebar({ className, identifier, @@ -20611,8 +25444,7 @@ function DefaultSidebar({ headerClassName, panelClassName }) { - const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getSettings().showIconLabels, []); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(complementary_area, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(complementary_area, { className: className, scope: "core/edit-site", identifier: identifier, @@ -20622,9 +25454,8 @@ function DefaultSidebar({ closeLabel: closeLabel, header: header, headerClassName: headerClassName, - panelClassName: panelClassName, - showIconLabels: showIconLabels - }, children), (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, { + panelClassName: panelClassName + }, children), (0,external_React_.createElement)(ComplementaryAreaMoreMenuItem, { scope: "core/edit-site", identifier: identifier, icon: icon @@ -20646,7 +25477,7 @@ function IconWithCurrentColor({ className, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { className: classnames_default()(className, 'edit-site-global-styles-icon-with-current-color'), ...props }); @@ -20668,17 +25499,17 @@ function GenericNavigationButton({ children, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItem, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, { ...props - }, icon && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, icon && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "flex-start" - }, (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, { + }, (0,external_React_.createElement)(IconWithCurrentColor, { icon: icon, size: 24 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, children)), !icon && children); + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, children)), !icon && children); } function NavigationButtonAsItem(props) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { as: GenericNavigationButton, ...props }); @@ -20697,13 +25528,13 @@ function NavigationBackButtonAsItem(props) { * WordPress dependencies */ -const typography_typography = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const typography = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_typography = (typography_typography); +/* harmony default export */ const library_typography = (typography); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/color.js @@ -20711,13 +25542,13 @@ const typography_typography = (0,external_wp_element_namespaceObject.createEleme * WordPress dependencies */ -const color = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const color = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); -/* harmony default export */ var library_color = (color); +/* harmony default export */ const library_color = (color); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/root-menu.js @@ -20748,21 +25579,21 @@ function RootMenu() { const hasColorPanel = useHasColorPanel(settings); const hasDimensionsPanel = useHasDimensionsPanel(settings); const hasLayoutPanel = hasDimensionsPanel; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, hasTypographyPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, hasTypographyPanel && (0,external_React_.createElement)(NavigationButtonAsItem, { icon: library_typography, path: "/typography", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Typography styles') - }, (0,external_wp_i18n_namespaceObject.__)('Typography')), hasColorPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Typography')), hasColorPanel && (0,external_React_.createElement)(NavigationButtonAsItem, { icon: library_color, path: "/colors", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Colors styles') - }, (0,external_wp_i18n_namespaceObject.__)('Colors')), hasLayoutPanel && (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Colors')), hasLayoutPanel && (0,external_React_.createElement)(NavigationButtonAsItem, { icon: library_layout, path: "/layout", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Layout styles') }, (0,external_wp_i18n_namespaceObject.__)('Layout')))); } -/* harmony default export */ var root_menu = (RootMenu); +/* harmony default export */ const root_menu = (RootMenu); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-root.js @@ -20784,16 +25615,15 @@ function RootMenu() { +const { + useGlobalStyle: screen_root_useGlobalStyle +} = unlock(external_wp_blockEditor_namespaceObject.privateApis); function ScreenRoot() { - const { - useGlobalStyle - } = unlock(external_wp_blockEditor_namespaceObject.privateApis); - const [customCSS] = useGlobalStyle('css'); + const [customCSS] = screen_root_useGlobalStyle('css'); const { hasVariations, canEditCSS } = (0,external_wp_data_namespaceObject.useSelect)(select => { - var _globalStyles$_links$; const { getEntityRecord, __experimentalGetCurrentGlobalStylesId, @@ -20803,22 +25633,22 @@ function ScreenRoot() { const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; return { hasVariations: !!__experimentalGetCurrentThemeGlobalStylesVariations()?.length, - canEditCSS: (_globalStyles$_links$ = !!globalStyles?._links?.['wp:action-edit-css']) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : false + canEditCSS: !!globalStyles?._links?.['wp:action-edit-css'] }; }, []); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Card, { size: "small", className: "edit-site-global-styles-screen-root" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 4 - }, (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))), hasVariations && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Card, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardMedia, null, (0,external_React_.createElement)(preview, null))), hasVariations && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(NavigationButtonAsItem, { path: "/variations", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Browse styles') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "space-between" - }, (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, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Browse styles')), (0,external_React_.createElement)(IconWithCurrentColor, { icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right - })))), (0,external_wp_element_namespaceObject.createElement)(root_menu, null))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardDivider, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + })))), (0,external_React_.createElement)(root_menu, null))), (0,external_React_.createElement)(external_wp_components_namespaceObject.CardDivider, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { as: "p", paddingTop: 2 /* @@ -20828,28 +25658,28 @@ function ScreenRoot() { */, paddingX: "13px", marginBottom: 4 - }, (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks for the whole site.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks for the whole site.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(NavigationButtonAsItem, { path: "/blocks", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Blocks styles') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "space-between" - }, (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, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Blocks')), (0,external_React_.createElement)(IconWithCurrentColor, { icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right - }))))), canEditCSS && !!customCSS && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardDivider, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + }))))), canEditCSS && !!customCSS && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardDivider, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { as: "p", paddingTop: 2, paddingX: "13px", marginBottom: 4 - }, (0,external_wp_i18n_namespaceObject.__)('Add your own CSS to customize the appearance and layout of your site.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Add your own CSS to customize the appearance and layout of your site.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(NavigationButtonAsItem, { path: "/css", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Additional CSS') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "space-between" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Additional CSS')), (0,external_wp_element_namespaceObject.createElement)(IconWithCurrentColor, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Additional CSS')), (0,external_React_.createElement)(IconWithCurrentColor, { icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right }))))))); } -/* harmony default export */ var screen_root = (ScreenRoot); +/* harmony default export */ const screen_root = (ScreenRoot); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/variations-panel.js @@ -20881,14 +25711,14 @@ function VariationsPanel({ name }) { const coreBlockStyles = useBlockVariations(name); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { isBordered: true, isSeparated: true }, coreBlockStyles.map((style, index) => { if (style?.isDefault) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + return (0,external_React_.createElement)(NavigationButtonAsItem, { key: index, path: '/blocks/' + encodeURIComponent(name) + '/variations/' + encodeURIComponent(style.name), "aria-label": style.label @@ -20906,17 +25736,18 @@ function VariationsPanel({ function ScreenHeader({ title, - description + description, + onBack }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 0 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalView, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalView, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { marginBottom: 0, paddingX: 4, paddingY: 3 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { spacing: 2 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorToParentButton, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorToParentButton, { style: // TODO: This style override is also used in ToolsPanelHeader. // It should be supported out-of-the-box by Button. @@ -20926,16 +25757,17 @@ function ScreenHeader({ }, icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left, isSmall: true, - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view'), + onClick: onBack + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { className: "edit-site-global-styles-header", level: 2, size: 13 - }, title))))), description && (0,external_wp_element_namespaceObject.createElement)("p", { + }, title))))), description && (0,external_React_.createElement)("p", { className: "edit-site-global-styles-header__description" }, description)); } -/* harmony default export */ var global_styles_header = (ScreenHeader); +/* harmony default export */ const header = (ScreenHeader); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-block-list.js @@ -21013,26 +25845,24 @@ function BlockMenuItem({ const navigationButtonLabel = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: is the name of a block e.g., 'Image' or 'Table'. (0,external_wp_i18n_namespaceObject.__)('%s block styles'), block.title); - return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + return (0,external_React_.createElement)(NavigationButtonAsItem, { path: '/blocks/' + encodeURIComponent(block.name), "aria-label": navigationButtonLabel - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "flex-start" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { icon: block.icon - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, block.title))); + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, block.title))); } -function ScreenBlockList() { +function BlockList({ + filterValue +}) { const sortedBlockTypes = useSortedBlockTypes(); - const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(''); const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500); - const isMatchingSearchTerm = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).isMatchingSearchTerm, []); - const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => { - if (!filterValue) { - return sortedBlockTypes; - } - return sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue)); - }, [filterValue, sortedBlockTypes, isMatchingSearchTerm]); + const { + isMatchingSearchTerm + } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store); + const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue)); const blockTypesListRef = (0,external_wp_element_namespaceObject.useRef)(); // Announce search results on change @@ -21053,25 +25883,33 @@ function ScreenBlockList() { (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count); debouncedSpeak(resultsFoundMessage, count); }, [filterValue, debouncedSpeak]); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + return (0,external_React_.createElement)("div", { + ref: blockTypesListRef, + className: "edit-site-block-types-item-list" + }, filteredBlockTypes.map(block => (0,external_React_.createElement)(BlockMenuItem, { + block: block, + key: 'menu-itemblock-' + block.name + }))); +} +const MemoizedBlockList = (0,external_wp_element_namespaceObject.memo)(BlockList); +function ScreenBlockList() { + const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(''); + const deferredFilterValue = (0,external_wp_element_namespaceObject.useDeferredValue)(filterValue); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { title: (0,external_wp_i18n_namespaceObject.__)('Blocks'), description: (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks and for the whole site.') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.SearchControl, { __nextHasNoMarginBottom: true, className: "edit-site-block-types-search", onChange: setFilterValue, value: filterValue, label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks'), placeholder: (0,external_wp_i18n_namespaceObject.__)('Search') - }), (0,external_wp_element_namespaceObject.createElement)("div", { - ref: blockTypesListRef, - className: "edit-site-block-types-item-list" - }, filteredBlockTypes.map(block => (0,external_wp_element_namespaceObject.createElement)(BlockMenuItem, { - block: block, - key: 'menu-itemblock-' + block.name - })))); + }), (0,external_React_.createElement)(MemoizedBlockList, { + filterValue: deferredFilterValue + })); } -/* harmony default export */ var screen_block_list = (ScreenBlockList); +/* harmony default export */ const screen_block_list = (ScreenBlockList); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/block-preview-panel.js @@ -21105,34 +25943,34 @@ const BlockPreviewPanel = ({ return (0,external_wp_blocks_namespaceObject.getBlockFromExample)(name, example); }, [name, blockExample, variation]); const viewportWidth = (_blockExample$viewpor = blockExample?.viewportWidth) !== null && _blockExample$viewpor !== void 0 ? _blockExample$viewpor : null; - const previewHeight = '150px'; + const previewHeight = 150; if (!blockExample) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { marginX: 4, marginBottom: 4 - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-global-styles__block-preview-panel", style: { maxHeight: previewHeight, boxSizing: 'initial' } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { blocks: blocks, viewportWidth: viewportWidth, minHeight: previewHeight, additionalStyles: [{ css: ` body{ - min-height:${previewHeight}; + min-height:${previewHeight}px; display:flex;align-items:center;justify-content:center; } ` }] }))); }; -/* harmony default export */ var block_preview_panel = (BlockPreviewPanel); +/* harmony default export */ const block_preview_panel = (BlockPreviewPanel); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/subtitle.js @@ -21140,16 +25978,16 @@ const BlockPreviewPanel = ({ * WordPress dependencies */ -function subtitle_Subtitle({ +function Subtitle({ children, level }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { className: "edit-site-global-styles-subtitle", level: level !== null && level !== void 0 ? level : 2 }, children); } -/* harmony default export */ var subtitle = (subtitle_Subtitle); +/* harmony default export */ const subtitle = (Subtitle); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-block.js @@ -21209,7 +26047,6 @@ const { useGlobalSetting: screen_block_useGlobalSetting, useSettingsForBlockElement: screen_block_useSettingsForBlockElement, useHasColorPanel: screen_block_useHasColorPanel, - useHasEffectsPanel, useHasFiltersPanel, useHasImageSettingsPanel, useGlobalStyle: screen_block_useGlobalStyle, @@ -21217,7 +26054,6 @@ const { ColorPanel: StylesColorPanel, TypographyPanel: StylesTypographyPanel, DimensionsPanel: StylesDimensionsPanel, - EffectsPanel: StylesEffectsPanel, FiltersPanel: StylesFiltersPanel, ImageSettingsPanel, AdvancedPanel: StylesAdvancedPanel @@ -21246,19 +26082,27 @@ function ScreenBlock({ if (settings?.spacing?.blockGap && blockType?.supports?.spacing?.blockGap && (blockType?.supports?.spacing?.__experimentalSkipSerialization === true || blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(spacingType => spacingType === 'blockGap'))) { settings.spacing.blockGap = false; } + + // Only allow `aspectRatio` support if the block is not the grouping block. + // The grouping block allows the user to use Group, Row and Stack variations, + // and it is highly likely that the user will not want to set an aspect ratio + // for all three at once. Until there is the ability to set a different aspect + // ratio for each variation, we disable the aspect ratio controls for the + // grouping block in global styles. + if (settings?.dimensions?.aspectRatio && name === 'core/group') { + settings.dimensions.aspectRatio = false; + } const blockVariations = useBlockVariations(name); const hasTypographyPanel = screen_block_useHasTypographyPanel(settings); const hasColorPanel = screen_block_useHasColorPanel(settings); const hasBorderPanel = screen_block_useHasBorderPanel(settings); const hasDimensionsPanel = screen_block_useHasDimensionsPanel(settings); - const hasEffectsPanel = useHasEffectsPanel(settings); const hasFiltersPanel = useHasFiltersPanel(settings); const hasImageSettingsPanel = useHasImageSettingsPanel(name, userSettings, settings); const hasVariationsPanel = !!blockVariations?.length && !variation; const { canEditCSS } = (0,external_wp_data_namespaceObject.useSelect)(select => { - var _globalStyles$_links$; const { getEntityRecord, __experimentalGetCurrentGlobalStylesId @@ -21266,7 +26110,7 @@ function ScreenBlock({ const globalStylesId = __experimentalGetCurrentGlobalStylesId(); const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; return { - canEditCSS: (_globalStyles$_links$ = !!globalStyles?._links?.['wp:action-edit-css']) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : false + canEditCSS: !!globalStyles?._links?.['wp:action-edit-css'] }; }, []); const currentBlockStyle = variation ? blockVariations.find(s => s.name === variation) : null; @@ -21360,66 +26204,60 @@ function ScreenBlock({ } }); }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { title: variation ? currentBlockStyle.label : blockType.title - }), (0,external_wp_element_namespaceObject.createElement)(block_preview_panel, { + }), (0,external_React_.createElement)(block_preview_panel, { name: name, variation: variation - }), hasVariationsPanel && (0,external_wp_element_namespaceObject.createElement)("div", { + }), hasVariationsPanel && (0,external_React_.createElement)("div", { className: "edit-site-global-styles-screen-variations" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 3 - }, (0,external_wp_element_namespaceObject.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Style Variations')), (0,external_wp_element_namespaceObject.createElement)(VariationsPanel, { + }, (0,external_React_.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Style Variations')), (0,external_React_.createElement)(VariationsPanel, { name: name - }))), hasColorPanel && (0,external_wp_element_namespaceObject.createElement)(StylesColorPanel, { + }))), hasColorPanel && (0,external_React_.createElement)(StylesColorPanel, { inheritedValue: inheritedStyle, value: style, onChange: setStyle, settings: settings - }), hasTypographyPanel && (0,external_wp_element_namespaceObject.createElement)(StylesTypographyPanel, { + }), hasTypographyPanel && (0,external_React_.createElement)(StylesTypographyPanel, { inheritedValue: inheritedStyle, value: style, onChange: setStyle, settings: settings - }), hasDimensionsPanel && (0,external_wp_element_namespaceObject.createElement)(StylesDimensionsPanel, { + }), hasDimensionsPanel && (0,external_React_.createElement)(StylesDimensionsPanel, { inheritedValue: inheritedStyleWithLayout, value: styleWithLayout, onChange: onChangeDimensions, settings: settings, includeLayoutControls: true - }), hasBorderPanel && (0,external_wp_element_namespaceObject.createElement)(StylesBorderPanel, { + }), hasBorderPanel && (0,external_React_.createElement)(StylesBorderPanel, { inheritedValue: inheritedStyle, value: style, onChange: onChangeBorders, settings: settings - }), hasEffectsPanel && (0,external_wp_element_namespaceObject.createElement)(StylesEffectsPanel, { - inheritedValue: inheritedStyleWithLayout, - value: styleWithLayout, - onChange: setStyle, - settings: settings, - includeLayoutControls: true - }), hasFiltersPanel && (0,external_wp_element_namespaceObject.createElement)(StylesFiltersPanel, { + }), hasFiltersPanel && (0,external_React_.createElement)(StylesFiltersPanel, { inheritedValue: inheritedStyleWithLayout, value: styleWithLayout, onChange: setStyle, settings: settings, includeLayoutControls: true - }), hasImageSettingsPanel && (0,external_wp_element_namespaceObject.createElement)(ImageSettingsPanel, { + }), hasImageSettingsPanel && (0,external_React_.createElement)(ImageSettingsPanel, { onChange: onChangeLightbox, value: userSettings, inheritedValue: settings - }), canEditCSS && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { + }), canEditCSS && (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { title: (0,external_wp_i18n_namespaceObject.__)('Advanced'), initialOpen: false - }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.sprintf)( + }, (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: is the name of a block e.g., 'Image' or 'Table'. - (0,external_wp_i18n_namespaceObject.__)('Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value.'), blockType?.title)), (0,external_wp_element_namespaceObject.createElement)(StylesAdvancedPanel, { + (0,external_wp_i18n_namespaceObject.__)('Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value.'), blockType?.title)), (0,external_React_.createElement)(StylesAdvancedPanel, { value: style, onChange: setStyle, inheritedValue: inheritedStyle }))); } -/* harmony default export */ var screen_block = (ScreenBlock); +/* harmony default export */ const screen_block = (ScreenBlock); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/typogrphy-elements.js @@ -21458,12 +26296,12 @@ function ElementItem({ const navigationButtonLabel = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: is a subset of Typography, e.g., 'text' or 'links'. (0,external_wp_i18n_namespaceObject.__)('Typography %s styles'), label); - return (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + return (0,external_React_.createElement)(NavigationButtonAsItem, { path: parentMenu + '/typography/' + element, "aria-label": navigationButtonLabel - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "flex-start" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { className: "edit-site-global-styles-screen-typography__indicator", style: { fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif', @@ -21474,82 +26312,125 @@ function ElementItem({ letterSpacing, ...extraStyles } - }, (0,external_wp_i18n_namespaceObject.__)('Aa')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, label))); + }, (0,external_wp_i18n_namespaceObject.__)('Aa')), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, label))); } function TypographyElements() { const parentMenu = ''; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 3 - }, (0,external_wp_element_namespaceObject.createElement)(subtitle, { + }, (0,external_React_.createElement)(subtitle, { level: 3 - }, (0,external_wp_i18n_namespaceObject.__)('Elements')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { + }, (0,external_wp_i18n_namespaceObject.__)('Elements')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { isBordered: true, isSeparated: true - }, (0,external_wp_element_namespaceObject.createElement)(ElementItem, { + }, (0,external_React_.createElement)(ElementItem, { parentMenu: parentMenu, element: "text", label: (0,external_wp_i18n_namespaceObject.__)('Text') - }), (0,external_wp_element_namespaceObject.createElement)(ElementItem, { + }), (0,external_React_.createElement)(ElementItem, { parentMenu: parentMenu, element: "link", label: (0,external_wp_i18n_namespaceObject.__)('Links') - }), (0,external_wp_element_namespaceObject.createElement)(ElementItem, { + }), (0,external_React_.createElement)(ElementItem, { parentMenu: parentMenu, element: "heading", label: (0,external_wp_i18n_namespaceObject.__)('Headings') - }), (0,external_wp_element_namespaceObject.createElement)(ElementItem, { + }), (0,external_React_.createElement)(ElementItem, { parentMenu: parentMenu, element: "caption", label: (0,external_wp_i18n_namespaceObject.__)('Captions') - }), (0,external_wp_element_namespaceObject.createElement)(ElementItem, { + }), (0,external_React_.createElement)(ElementItem, { parentMenu: parentMenu, element: "button", label: (0,external_wp_i18n_namespaceObject.__)('Buttons') }))); } -/* harmony default export */ var typogrphy_elements = (TypographyElements); +/* harmony default export */ const typogrphy_elements = (TypographyElements); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/settings.js -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/resolvers.js /** * WordPress dependencies - * */ + +const settings_settings = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z" +}), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z" +})); +/* harmony default export */ const library_settings = (settings_settings); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/resolvers.js /** * WordPress dependencies */ -async function resolvers_fetchInstallFonts(data) { +const FONT_FAMILIES_URL = '/wp/v2/font-families'; +const FONT_COLLECTIONS_URL = '/wp/v2/font-collections'; +async function fetchInstallFontFamily(data) { const config = { - path: '/wp/v2/fonts', + path: FONT_FAMILIES_URL, method: 'POST', body: data }; - return apiFetch(config); + const response = await external_wp_apiFetch_default()(config); + return { + id: response.id, + ...response.font_family_settings, + fontFace: [] + }; } -async function resolvers_fetchUninstallFonts(fonts) { - const data = { - font_families: fonts +async function fetchInstallFontFace(fontFamilyId, data) { + const config = { + path: `${FONT_FAMILIES_URL}/${fontFamilyId}/font-faces`, + method: 'POST', + body: data + }; + const response = await external_wp_apiFetch_default()(config); + return { + id: response.id, + ...response.font_face_settings }; +} +async function fetchGetFontFamilyBySlug(slug) { const config = { - path: '/wp/v2/fonts', - method: 'DELETE', - data + path: `${FONT_FAMILIES_URL}?slug=${slug}&_embed=true`, + method: 'GET' }; - return apiFetch(config); + const response = await external_wp_apiFetch_default()(config); + if (!response || response.length === 0) { + return null; + } + const fontFamilyPost = response[0]; + return { + id: fontFamilyPost.id, + ...fontFamilyPost.font_family_settings, + fontFace: fontFamilyPost?._embedded?.font_faces.map(face => face.font_face_settings) || [] + }; +} +async function fetchUninstallFontFamily(fontFamilyId) { + const config = { + path: `${FONT_FAMILIES_URL}/${fontFamilyId}?force=true`, + method: 'DELETE' + }; + return await external_wp_apiFetch_default()(config); } -async function resolvers_fetchFontCollections() { +async function fetchFontCollections() { const config = { - path: '/wp/v2/fonts/collections', + path: `${FONT_COLLECTIONS_URL}?_fields=slug,name,description`, method: 'GET' }; - return apiFetch(config); + return await external_wp_apiFetch_default()(config); } -async function resolvers_fetchFontCollection(id) { +async function fetchFontCollection(id) { const config = { - path: `/wp/v2/fonts/collections/${id}`, + path: `${FONT_COLLECTIONS_URL}/${id}`, method: 'GET' }; - return apiFetch(config); + return await external_wp_apiFetch_default()(config); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/constants.js @@ -21557,8 +26438,8 @@ async function resolvers_fetchFontCollection(id) { * WordPress dependencies */ -const constants_ALLOWED_FILE_EXTENSIONS = (/* unused pure expression or super */ null && (['otf', 'ttf', 'woff', 'woff2'])); -const constants_FONT_WEIGHTS = { +const ALLOWED_FILE_EXTENSIONS = ['otf', 'ttf', 'woff', 'woff2']; +const FONT_WEIGHTS = { 100: (0,external_wp_i18n_namespaceObject._x)('Thin', 'font weight'), 200: (0,external_wp_i18n_namespaceObject._x)('Extra-light', 'font weight'), 300: (0,external_wp_i18n_namespaceObject._x)('Light', 'font weight'), @@ -21569,18 +26450,160 @@ const constants_FONT_WEIGHTS = { 800: (0,external_wp_i18n_namespaceObject._x)('Extra-bold', 'font weight'), 900: (0,external_wp_i18n_namespaceObject._x)('Black', 'font weight') }; -const constants_FONT_STYLES = { +const FONT_STYLES = { normal: (0,external_wp_i18n_namespaceObject._x)('Normal', 'font style'), italic: (0,external_wp_i18n_namespaceObject._x)('Italic', 'font style') }; +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +function findNearest(input, numbers) { + // If the numbers array is empty, return null + if (numbers.length === 0) { + return null; + } + // Sort the array based on the absolute difference with the input + numbers.sort((a, b) => Math.abs(input - a) - Math.abs(input - b)); + // Return the first element (which will be the nearest) from the sorted array + return numbers[0]; +} +function extractFontWeights(fontFaces) { + const result = []; + fontFaces.forEach(face => { + const weights = String(face.fontWeight).split(' '); + if (weights.length === 2) { + const start = parseInt(weights[0]); + const end = parseInt(weights[1]); + for (let i = start; i <= end; i += 100) { + result.push(i); + } + } else if (weights.length === 1) { + result.push(parseInt(weights[0])); + } + }); + return result; +} + +/* + * Format the font family to use in the CSS font-family property of a CSS rule. + * + * The input can be a string with the font family name or a string with multiple font family names separated by commas. + * It follows the recommendations from the CSS Fonts Module Level 4. + * https://www.w3.org/TR/css-fonts-4/#font-family-prop + * + * @param {string} input - The font family. + * @return {string} The formatted font family. + * + * Example: + * formatFontFamily( "Open Sans, Font+Name, sans-serif" ) => '"Open Sans", "Font+Name", sans-serif' + * formatFontFamily( "'Open Sans', generic(kai), sans-serif" ) => '"Open Sans", sans-serif' + * formatFontFamily( "DotGothic16, Slabo 27px, serif" ) => '"DotGothic16","Slabo 27px",serif' + * formatFontFamily( "Mine's, Moe's Typography" ) => `"mine's","Moe's Typography"` + */ +function formatFontFamily(input) { + // Matches strings that are not exclusively alphabetic characters or hyphens, and do not exactly follow the pattern generic(alphabetic characters or hyphens). + const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/; + const output = input.trim(); + const formatItem = item => { + item = item.trim(); + if (item.match(regex)) { + // removes leading and trailing quotes. + item = item.replace(/^["']|["']$/g, ''); + return `"${item}"`; + } + return item; + }; + if (output.includes(',')) { + return output.split(',').map(formatItem).filter(item => item !== '').join(', '); + } + return formatItem(output); +} + +/* + * Format the font face name to use in the font-family property of a font face. + * + * The input can be a string with the font face name or a string with multiple font face names separated by commas. + * It removes the leading and trailing quotes from the font face name. + * + * @param {string} input - The font face name. + * @return {string} The formatted font face name. + * + * Example: + * formatFontFaceName("Open Sans") => "Open Sans" + * formatFontFaceName("'Open Sans', sans-serif") => "Open Sans" + * formatFontFaceName(", 'Open Sans', 'Helvetica Neue', sans-serif") => "Open Sans" + */ +function formatFontFaceName(input) { + if (!input) { + return ''; + } + let output = input.trim(); + if (output.includes(',')) { + output = output.split(',') + // finds the first item that is not an empty string. + .find(item => item.trim() !== '').trim(); + } + // removes leading and trailing quotes. + output = output.replace(/^["']|["']$/g, ''); + + // Firefox needs the font name to be wrapped in double quotes meanwhile other browsers don't. + if (window.navigator.userAgent.toLowerCase().includes('firefox')) { + output = `"${output}"`; + } + return output; +} +function getFamilyPreviewStyle(family) { + const style = { + fontFamily: formatFontFamily(family.fontFamily) + }; + if (!Array.isArray(family.fontFace)) { + style.fontWeight = '400'; + style.fontStyle = 'normal'; + return style; + } + if (family.fontFace) { + //get all the font faces with normal style + const normalFaces = family.fontFace.filter(face => face.fontStyle.toLowerCase() === 'normal'); + if (normalFaces.length > 0) { + style.fontStyle = 'normal'; + const normalWeights = extractFontWeights(normalFaces); + const nearestWeight = findNearest(400, normalWeights); + style.fontWeight = String(nearestWeight) || '400'; + } else { + style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || 'normal'; + style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || '400'; + } + } + return style; +} +function getFacePreviewStyle(face) { + return { + fontFamily: formatFontFamily(face.fontFamily), + fontStyle: face.fontStyle || 'normal', + fontWeight: face.fontWeight || '400' + }; +} + ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/index.js /** + * WordPress dependencies + */ + + +/** * Internal dependencies */ -function utils_setUIValuesNeeded(font, extraValues = {}) { + + + +/** + * Browser dependencies + */ +const { + File +} = window; +function setUIValuesNeeded(font, extraValues = {}) { if (!font.name && (font.fontFamily || font.slug)) { font.name = font.fontFamily || font.slug; } @@ -21595,7 +26618,7 @@ function isUrlEncoded(url) { } return url !== decodeURIComponent(url); } -function utils_getFontFaceVariantName(face) { +function getFontFaceVariantName(face) { const weightName = FONT_WEIGHTS[face.fontWeight] || face.fontWeight; const styleName = face.fontStyle === 'normal' ? '' : FONT_STYLES[face.fontStyle] || face.fontStyle; return `${weightName} ${styleName}`; @@ -21611,7 +26634,7 @@ function mergeFontFaces(existing = [], incoming = []) { } return Array.from(map.values()); } -function utils_mergeFontFamilies(existing = [], incoming = []) { +function mergeFontFamilies(existing = [], incoming = []) { const map = new Map(); // Add the existing array to the map. for (const font of existing) { @@ -21647,17 +26670,17 @@ function utils_mergeFontFamilies(existing = [], incoming = []) { * Loads the font face from a URL and adds it to the browser. * It also adds it to the iframe document. */ -async function utils_loadFontFaceInBrowser(fontFace, source, addTo = 'all') { +async function loadFontFaceInBrowser(fontFace, source, addTo = 'all') { let dataSource; if (typeof source === 'string') { dataSource = `url(${source})`; // eslint-disable-next-line no-undef } else if (source instanceof File) { dataSource = await source.arrayBuffer(); + } else { + return; } - - // eslint-disable-next-line no-undef - const newFont = new FontFace(formatFontFamily(fontFace.fontFamily), dataSource, { + const newFont = new window.FontFace(formatFontFaceName(fontFace.fontFamily), dataSource, { style: fontFace.fontStyle, weight: fontFace.fontWeight }); @@ -21670,7 +26693,40 @@ async function utils_loadFontFaceInBrowser(fontFace, source, addTo = 'all') { iframeDocument.fonts.add(loadedFace); } } -function utils_getDisplaySrcFromFontFace(input, urlPrefix) { + +/* + * Unloads the font face and remove it from the browser. + * It also removes it from the iframe document. + * + * Note that Font faces that were added to the set using the CSS @font-face rule + * remain connected to the corresponding CSS, and cannot be deleted. + * + * @see https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/delete. + */ +function unloadFontFaceInBrowser(fontFace, removeFrom = 'all') { + const unloadFontFace = fonts => { + fonts.forEach(f => { + if (f.family === formatFontFaceName(fontFace?.fontFamily) && f.weight === fontFace?.fontWeight && f.style === fontFace?.fontStyle) { + fonts.delete(f); + } + }); + }; + if (removeFrom === 'document' || removeFrom === 'all') { + unloadFontFace(document.fonts); + } + if (removeFrom === 'iframe' || removeFrom === 'all') { + const iframeDocument = document.querySelector('iframe[name="editor-canvas"]').contentDocument; + unloadFontFace(iframeDocument.fonts); + } +} + +/** + * Retrieves the display source from a font face src. + * + * @param {string|string[]} input - The font face src. + * @return {string|undefined} The display source or undefined if the input is invalid. + */ +function getDisplaySrcFromFontFace(input) { if (!input) { return; } @@ -21680,43 +26736,232 @@ function utils_getDisplaySrcFromFontFace(input, urlPrefix) { } else { src = input; } - // If it is a theme font, we need to make the url absolute - if (src.startsWith('file:.') && urlPrefix) { - src = src.replace('file:.', urlPrefix); + // It's expected theme fonts will already be loaded in the browser. + if (src.startsWith('file:.')) { + return; } if (!isUrlEncoded(src)) { src = encodeURI(src); } return src; } -function utils_makeFormDataFromFontFamilies(fontFamilies) { +function makeFontFamilyFormData(fontFamily) { const formData = new FormData(); - const newFontFamilies = fontFamilies.map((family, familyIndex) => { - if (family?.fontFace) { - family.fontFace = family.fontFace.map((face, faceIndex) => { - if (face.file) { + const { + kebabCase + } = unlock(external_wp_components_namespaceObject.privateApis); + const { + fontFace, + category, + ...familyWithValidParameters + } = fontFamily; + const fontFamilySettings = { + ...familyWithValidParameters, + slug: kebabCase(fontFamily.slug) + }; + formData.append('font_family_settings', JSON.stringify(fontFamilySettings)); + return formData; +} +function makeFontFacesFormData(font) { + if (font?.fontFace) { + const fontFacesFormData = font.fontFace.map((item, faceIndex) => { + const face = { + ...item + }; + const formData = new FormData(); + if (face.file) { + // Normalize to an array, since face.file may be a single file or an array of files. + const files = Array.isArray(face.file) ? face.file : [face.file]; + const src = []; + files.forEach((file, key) => { // Slugified file name because the it might contain spaces or characters treated differently on the server. - const fileId = `file-${familyIndex}-${faceIndex}`; + const fileId = `file-${faceIndex}-${key}`; // Add the files to the formData - formData.append(fileId, face.file, face.file.name); - // remove the file object from the face object the file is referenced by the uploadedFile key - const { - file, - ...faceWithoutFileProperty - } = face; - const newFace = { - ...faceWithoutFileProperty, - uploadedFile: fileId - }; - return newFace; - } - return face; + formData.append(fileId, file, file.name); + src.push(fileId); + }); + face.src = src.length === 1 ? src[0] : src; + delete face.file; + formData.append('font_face_settings', JSON.stringify(face)); + } else { + formData.append('font_face_settings', JSON.stringify(face)); + } + return formData; + }); + return fontFacesFormData; + } +} +async function batchInstallFontFaces(fontFamilyId, fontFacesData) { + const responses = []; + + /* + * Uses the same response format as Promise.allSettled, but executes requests in sequence to work + * around a race condition that can cause an error when the fonts directory doesn't exist yet. + */ + for (const faceData of fontFacesData) { + try { + const response = await fetchInstallFontFace(fontFamilyId, faceData); + responses.push({ + status: 'fulfilled', + value: response + }); + } catch (error) { + responses.push({ + status: 'rejected', + reason: error + }); + } + } + const results = { + errors: [], + successes: [] + }; + responses.forEach((result, index) => { + if (result.status === 'fulfilled') { + const response = result.value; + if (response.id) { + results.successes.push(response); + } else { + results.errors.push({ + data: fontFacesData[index], + message: `Error: ${response.message}` + }); + } + } else { + // Handle network errors or other fetch-related errors + results.errors.push({ + data: fontFacesData[index], + message: result.reason.message }); } - return family; }); - formData.append('font_families', JSON.stringify(newFontFamilies)); - return formData; + return results; +} + +/* + * Downloads a font face asset from a URL to the client and returns a File object. + */ +async function downloadFontFaceAssets(src) { + // Normalize to an array, since `src` could be a string or array. + src = Array.isArray(src) ? src : [src]; + const files = await Promise.all(src.map(async url => { + return fetch(new Request(url)).then(response => { + if (!response.ok) { + throw new Error(`Error downloading font face asset from ${url}. Server responded with status: ${response.status}`); + } + return response.blob(); + }).then(blob => { + const filename = url.split('/').pop(); + const file = new File([blob], filename, { + type: blob.type + }); + return file; + }); + })); + + // If we only have one file return it (not the array). Otherwise return all of them in the array. + return files.length === 1 ? files[0] : files; +} + +/* + * Determine if a given Font Face is present in a given collection. + * We determine that a font face has been installed by comparing the fontWeight and fontStyle + * + * @param {Object} fontFace The Font Face to seek + * @param {Array} collection The Collection to seek in + * @returns True if the font face is found in the collection. Otherwise False. + */ +function checkFontFaceInstalled(fontFace, collection) { + return -1 !== collection.findIndex(collectionFontFace => { + return collectionFontFace.fontWeight === fontFace.fontWeight && collectionFontFace.fontStyle === fontFace.fontStyle; + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/toggleFont.js +/** + * Toggles the activation of a given font or font variant within a list of custom fonts. + * + * - If only the font is provided (without face), the entire font family's activation is toggled. + * - If both font and face are provided, the activation of the specific font variant is toggled. + * + * @param {Object} font - The font to be toggled. + * @param {string} font.slug - The unique identifier for the font. + * @param {Array} [font.fontFace] - The list of font variants (faces) associated with the font. + * + * @param {Object} [face] - The specific font variant to be toggled. + * @param {string} face.fontWeight - The weight of the font variant. + * @param {string} face.fontStyle - The style of the font variant. + * + * @param {Array} initialfonts - The initial list of custom fonts. + * + * @return {Array} - The updated list of custom fonts with the font/font variant toggled. + * + * @example + * const customFonts = [ + * { slug: 'roboto', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] } + * ]; + * + * toggleFont({ slug: 'roboto' }, null, customFonts); + * // This will remove 'roboto' from customFonts + * + * toggleFont({ slug: 'roboto' }, { fontWeight: '400', fontStyle: 'normal' }, customFonts); + * // This will remove the specified face from 'roboto' in customFonts + * + * toggleFont({ slug: 'roboto' }, { fontWeight: '500', fontStyle: 'normal' }, customFonts); + * // This will add the specified face to 'roboto' in customFonts + */ +function toggleFont(font, face, initialfonts) { + // Helper to check if a font is activated based on its slug + const isFontActivated = f => f.slug === font.slug; + + // Helper to get the activated font from a list of fonts + const getActivatedFont = fonts => fonts.find(isFontActivated); + + // Toggle the activation status of an entire font family + const toggleEntireFontFamily = activatedFont => { + if (!activatedFont) { + // If the font is not active, activate the entire font family + return [...initialfonts, font]; + } + // If the font is already active, deactivate the entire font family + return initialfonts.filter(f => !isFontActivated(f)); + }; + + // Toggle the activation status of a specific font variant + const toggleFontVariant = activatedFont => { + const isFaceActivated = f => f.fontWeight === face.fontWeight && f.fontStyle === face.fontStyle; + if (!activatedFont) { + // If the font family is not active, activate the font family with the font variant + return [...initialfonts, { + ...font, + fontFace: [face] + }]; + } + let newFontFaces = activatedFont.fontFace || []; + if (newFontFaces.find(isFaceActivated)) { + // If the font variant is active, deactivate it + newFontFaces = newFontFaces.filter(f => !isFaceActivated(f)); + } else { + // If the font variant is not active, activate it + newFontFaces = [...newFontFaces, face]; + } + + // If there are no more font faces, deactivate the font family + if (newFontFaces.length === 0) { + return initialfonts.filter(f => !isFontActivated(f)); + } + + // Return updated fonts list with toggled font variant + return initialfonts.map(f => isFontActivated(f) ? { + ...f, + fontFace: newFontFaces + } : f); + }; + const activatedFont = getActivatedFont(initialfonts); + if (!face) { + return toggleEntireFontFamily(activatedFont); + } + return toggleFontVariant(activatedFont); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/context.js @@ -21729,6 +26974,7 @@ function utils_makeFormDataFromFontFamilies(fontFamilies) { + /** * Internal dependencies */ @@ -21739,28 +26985,28 @@ const { } = unlock(external_wp_blockEditor_namespaceObject.privateApis); - -const context_FontLibraryContext = (0,external_wp_element_namespaceObject.createContext)({}); -function context_FontLibraryProvider({ +const FontLibraryContext = (0,external_wp_element_namespaceObject.createContext)({}); +function FontLibraryProvider({ children }) { const { __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits - } = useDispatch(coreStore); + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); const { globalStylesId - } = useSelect(select => { + } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { __experimentalGetCurrentGlobalStylesId - } = select(coreStore); + } = select(external_wp_coreData_namespaceObject.store); return { globalStylesId: __experimentalGetCurrentGlobalStylesId() }; }); - const globalStyles = useEntityRecord('root', 'globalStyles', globalStylesId); + const globalStyles = (0,external_wp_coreData_namespaceObject.useEntityRecord)('root', 'globalStyles', globalStylesId); const fontFamiliesHasChanges = !!globalStyles?.edits?.settings?.typography?.fontFamilies; - const [isInstalling, setIsInstalling] = useState(false); - const [refreshKey, setRefreshKey] = useState(0); + const [isInstalling, setIsInstalling] = (0,external_wp_element_namespaceObject.useState)(false); + const [refreshKey, setRefreshKey] = (0,external_wp_element_namespaceObject.useState)(0); + const [notice, setNotice] = (0,external_wp_element_namespaceObject.useState)(null); const refreshLibrary = () => { setRefreshKey(Date.now()); }; @@ -21768,10 +27014,17 @@ function context_FontLibraryProvider({ records: libraryPosts = [], isResolving: isResolvingLibrary, hasResolved: hasResolvedLibrary - } = useEntityRecords('postType', 'wp_font_family', { - refreshKey + } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', 'wp_font_family', { + refreshKey, + _embed: true }); - const libraryFonts = (libraryPosts || []).map(post => JSON.parse(post.content.raw)) || []; + const libraryFonts = (libraryPosts || []).map(fontFamilyPost => { + return { + id: fontFamilyPost.id, + ...fontFamilyPost.font_family_settings, + fontFace: fontFamilyPost?._embedded?.font_faces.map(face => face.font_face_settings) || [] + }; + }) || []; // Global Styles (settings) font families const [fontFamilies, setFontFamilies] = context_useGlobalSetting('typography.fontFamilies'); @@ -21784,32 +27037,45 @@ function context_FontLibraryProvider({ }; // Library Fonts - const [modalTabOpen, setModalTabOpen] = useState(false); - const [libraryFontSelected, setLibraryFontSelected] = useState(null); - const baseThemeFonts = baseFontFamilies?.theme ? baseFontFamilies.theme.map(f => setUIValuesNeeded(f, { - source: 'theme' - })).sort((a, b) => a.name.localeCompare(b.name)) : []; + const [modalTabOpen, setModalTabOpen] = (0,external_wp_element_namespaceObject.useState)(false); + const [libraryFontSelected, setLibraryFontSelected] = (0,external_wp_element_namespaceObject.useState)(null); + + // Themes Fonts are the fonts defined in the global styles (database persisted theme.json data). const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map(f => setUIValuesNeeded(f, { source: 'theme' })).sort((a, b) => a.name.localeCompare(b.name)) : []; + const themeFontsSlugs = new Set(themeFonts.map(f => f.slug)); + + /* + * Base Theme Fonts are the fonts defined in the theme.json *file*. + * + * Uses the fonts from global styles + the ones from the theme.json file that hasn't repeated slugs. + * Avoids incosistencies with the fonts listed in the font library modal as base (unactivated). + * These inconsistencies can happen when the active theme fonts in global styles aren't defined in theme.json file as when a theme style variation is applied. + */ + const baseThemeFonts = baseFontFamilies?.theme ? themeFonts.concat(baseFontFamilies.theme.filter(f => !themeFontsSlugs.has(f.slug)).map(f => setUIValuesNeeded(f, { + source: 'theme' + })).sort((a, b) => a.name.localeCompare(b.name))) : []; const customFonts = fontFamilies?.custom ? fontFamilies.custom.map(f => setUIValuesNeeded(f, { source: 'custom' })).sort((a, b) => a.name.localeCompare(b.name)) : []; const baseCustomFonts = libraryFonts ? libraryFonts.map(f => setUIValuesNeeded(f, { source: 'custom' })).sort((a, b) => a.name.localeCompare(b.name)) : []; - useEffect(() => { + (0,external_wp_element_namespaceObject.useEffect)(() => { if (!modalTabOpen) { setLibraryFontSelected(null); } }, [modalTabOpen]); const handleSetLibraryFontSelected = font => { + setNotice(null); + // If font is null, reset the selected font if (!font) { setLibraryFontSelected(null); return; } - const fonts = font.source === 'theme' ? baseThemeFonts : baseCustomFonts; + const fonts = font.source === 'theme' ? themeFonts : baseCustomFonts; // Tries to find the font in the installed fonts const fontSelected = fonts.find(f => f.slug === font.slug); @@ -21824,22 +27090,10 @@ function context_FontLibraryProvider({ }; // Demo - const [loadedFontUrls] = useState(new Set()); - - // Theme data - const { - site, - currentTheme - } = useSelect(select => { - return { - site: select(coreStore).getSite(), - currentTheme: select(coreStore).getCurrentTheme() - }; - }); - const themeUrl = site?.url + '/wp-content/themes/' + currentTheme?.stylesheet; + const [loadedFontUrls] = (0,external_wp_element_namespaceObject.useState)(new Set()); const getAvailableFontsOutline = availableFontFamilies => { const outline = availableFontFamilies.reduce((acc, font) => { - const availableFontFaces = Array.isArray(font?.fontFace) ? font?.fontFace.map(face => `${face.fontStyle + face.fontWeight}`) : ['normal400']; // If the font doesn't have fontFace, we assume it is a system font and we add the defaults: normal 400 + const availableFontFaces = font?.fontFace && font.fontFace?.length > 0 ? font?.fontFace.map(face => `${face.fontStyle + face.fontWeight}`) : ['normal400']; // If the font doesn't have fontFace, we assume it is a system font and we add the defaults: normal 400 acc[font.slug] = availableFontFaces; return acc; @@ -21864,50 +27118,100 @@ function context_FontLibraryProvider({ const getFontFacesActivated = (slug, source) => { return getActivatedFontsOutline(source)[slug] || []; }; - async function installFonts(fonts) { + async function installFonts(fontFamiliesToInstall) { setIsInstalling(true); try { - // Prepare formData to install. - const formData = makeFormDataFromFontFamilies(fonts); - // Install the fonts (upload the font files to the server and create the post in the database). - const response = await fetchInstallFonts(formData); - const fontsInstalled = response?.successes || []; - // Get intersecting font faces between the fonts we tried to installed and the fonts that were installed - // (to avoid activating a non installed font). - const fontToBeActivated = getIntersectingFontFaces(fontsInstalled, fonts); - // Activate the font families (add the font families to the global styles). - activateCustomFontFamilies(fontToBeActivated); - // Save the global styles to the database. - saveSpecifiedEntityEdits('root', 'globalStyles', globalStylesId, ['settings.typography.fontFamilies']); - refreshLibrary(); - setIsInstalling(false); - return response; - } catch (error) { + const fontFamiliesToActivate = []; + let installationErrors = []; + for (const fontFamilyToInstall of fontFamiliesToInstall) { + let isANewFontFamily = false; + + // Get the font family if it already exists. + let installedFontFamily = await fetchGetFontFamilyBySlug(fontFamilyToInstall.slug); + + // Otherwise create it. + if (!installedFontFamily) { + isANewFontFamily = true; + // Prepare font family form data to install. + installedFontFamily = await fetchInstallFontFamily(makeFontFamilyFormData(fontFamilyToInstall)); + } + + // Collect font faces that have already been installed (to be activated later) + const alreadyInstalledFontFaces = installedFontFamily.fontFace && fontFamilyToInstall.fontFace ? installedFontFamily.fontFace.filter(fontFaceToInstall => checkFontFaceInstalled(fontFaceToInstall, fontFamilyToInstall.fontFace)) : []; + + // Filter out Font Faces that have already been installed (so that they are not re-installed) + if (installedFontFamily.fontFace && fontFamilyToInstall.fontFace) { + fontFamilyToInstall.fontFace = fontFamilyToInstall.fontFace.filter(fontFaceToInstall => !checkFontFaceInstalled(fontFaceToInstall, installedFontFamily.fontFace)); + } + + // Install the fonts (upload the font files to the server and create the post in the database). + let sucessfullyInstalledFontFaces = []; + let unsucessfullyInstalledFontFaces = []; + if (fontFamilyToInstall?.fontFace?.length > 0) { + const response = await batchInstallFontFaces(installedFontFamily.id, makeFontFacesFormData(fontFamilyToInstall)); + sucessfullyInstalledFontFaces = response?.successes; + unsucessfullyInstalledFontFaces = response?.errors; + } + + // Use the sucessfully installed font faces + // As well as any font faces that were already installed (those will be activated) + if (sucessfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) { + // Use font data from REST API not from client to ensure + // correct font information is used. + installedFontFamily.fontFace = [...sucessfullyInstalledFontFaces]; + fontFamiliesToActivate.push(installedFontFamily); + } + + // If it's a system font but was installed successfully, activate it. + if (installedFontFamily && !fontFamilyToInstall?.fontFace?.length) { + fontFamiliesToActivate.push(installedFontFamily); + } + + // If the font family is new and is not a system font, delete it to avoid having font families without font faces. + if (isANewFontFamily && fontFamilyToInstall?.fontFace?.length > 0 && sucessfullyInstalledFontFaces?.length === 0) { + await fetchUninstallFontFamily(installedFontFamily.id); + } + installationErrors = installationErrors.concat(unsucessfullyInstalledFontFaces); + } + installationErrors = installationErrors.reduce((unique, item) => unique.includes(item.message) ? unique : [...unique, item.message], []); + if (fontFamiliesToActivate.length > 0) { + // Activate the font family (add the font family to the global styles). + activateCustomFontFamilies(fontFamiliesToActivate); + + // Save the global styles to the database. + await saveSpecifiedEntityEdits('root', 'globalStyles', globalStylesId, ['settings.typography.fontFamilies']); + refreshLibrary(); + } + if (installationErrors.length > 0) { + const installError = new Error((0,external_wp_i18n_namespaceObject.__)('There was an error installing fonts.')); + installError.installationErrors = installationErrors; + throw installError; + } + } finally { setIsInstalling(false); - return { - errors: [error] - }; } } - async function uninstallFont(font) { + async function uninstallFontFamily(fontFamilyToUninstall) { try { - // Uninstall the font (remove the font files from the server and the post from the database). - const response = await fetchUninstallFonts([font]); - // Deactivate the font family (remove the font family from the global styles). - if (!response.errors) { - deactivateFontFamily(font); + // Uninstall the font family. + // (Removes the font files from the server and the posts from the database). + const uninstalledFontFamily = await fetchUninstallFontFamily(fontFamilyToUninstall.id); + + // Deactivate the font family if delete request is successful + // (Removes the font family from the global styles). + if (uninstalledFontFamily.deleted) { + deactivateFontFamily(fontFamilyToUninstall); // Save the global styles to the database. await saveSpecifiedEntityEdits('root', 'globalStyles', globalStylesId, ['settings.typography.fontFamilies']); } - // Refresh the library (the the library font families from database). + + // Refresh the library (the library font families from database). refreshLibrary(); - return response; + return uninstalledFontFamily; } catch (error) { // eslint-disable-next-line no-console - console.error(error); - return { - errors: [error] - }; + console.error(`There was an error uninstalling the font family:`, error); + throw error; } } const deactivateFontFamily = font => { @@ -21920,21 +27224,41 @@ function context_FontLibraryProvider({ ...fontFamilies, [font.source]: newCustomFonts }); + if (font.fontFace) { + font.fontFace.forEach(face => { + unloadFontFaceInBrowser(face, 'all'); + }); + } }; const activateCustomFontFamilies = fontsToAdd => { - // Merge the existing custom fonts with the new fonts. - const newCustomFonts = mergeFontFamilies(fontFamilies?.custom, fontsToAdd); + // Removes the id from the families and faces to avoid saving that to global styles post content. + const fontsToActivate = fontsToAdd.map(({ + id: _familyDbId, + fontFace, + ...font + }) => ({ + ...font, + ...(fontFace && fontFace.length > 0 ? { + fontFace: fontFace.map(({ + id: _faceDbId, + ...face + }) => face) + } : {}) + })); + // Activate the fonts by set the new custom fonts array. setFontFamilies({ ...fontFamilies, - custom: newCustomFonts + // Merge the existing custom fonts with the new fonts. + custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate) }); + // Add custom fonts to the browser. - fontsToAdd.forEach(font => { + fontsToActivate.forEach(font => { if (font.fontFace) { font.fontFace.forEach(face => { // Load font faces just in the iframe because they already are in the document. - loadFontFaceInBrowser(face, getDisplaySrcFromFontFace(face.src), 'iframe'); + loadFontFaceInBrowser(face, getDisplaySrcFromFontFace(face.src), 'all'); }); } }); @@ -21951,12 +27275,18 @@ function context_FontLibraryProvider({ ...fontFamilies, [font.source]: newFonts }); + const isFaceActivated = isFontActivated(font.slug, face?.fontStyle, face?.fontWeight, font.source); + if (isFaceActivated) { + loadFontFaceInBrowser(face, getDisplaySrcFromFontFace(face?.src), 'all'); + } else { + unloadFontFaceInBrowser(face, 'all'); + } }; const loadFontFaceAsset = async fontFace => { // If the font doesn't have a src, don't load it. if (!fontFace.src) return; // Get the src of the font. - const src = getDisplaySrcFromFontFace(fontFace.src, themeUrl); + const src = getDisplaySrcFromFontFace(fontFace.src); // If the font is already loaded, don't load it again. if (!src || loadedFontUrls.has(src)) return; // Load the font in the browser. @@ -21966,27 +27296,31 @@ function context_FontLibraryProvider({ }; // Font Collections - const [collections, setFontCollections] = useState([]); + const [collections, setFontCollections] = (0,external_wp_element_namespaceObject.useState)([]); const getFontCollections = async () => { const response = await fetchFontCollections(); setFontCollections(response); }; - const getFontCollection = async id => { - const hasData = !!collections.find(collection => collection.id === id)?.data; - if (hasData) return; - const response = await fetchFontCollection(id); - const updatedCollections = collections.map(collection => collection.id === id ? { - ...collection, - data: { - ...response?.data - } - } : collection); - setFontCollections(updatedCollections); + const getFontCollection = async slug => { + try { + const hasData = !!collections.find(collection => collection.slug === slug)?.font_families; + if (hasData) return; + const response = await fetchFontCollection(slug); + const updatedCollections = collections.map(collection => collection.slug === slug ? { + ...collection, + ...response + } : collection); + setFontCollections(updatedCollections); + } catch (e) { + // eslint-disable-next-line no-console + console.error(e); + throw e; + } }; - useEffect(() => { + (0,external_wp_element_namespaceObject.useEffect)(() => { getFontCollections(); }, []); - return createElement(context_FontLibraryContext.Provider, { + return (0,external_React_.createElement)(FontLibraryContext.Provider, { value: { libraryFontSelected, handleSetLibraryFontSelected, @@ -21998,12 +27332,14 @@ function context_FontLibraryProvider({ getFontFacesActivated, loadFontFaceAsset, installFonts, - uninstallFont, + uninstallFontFamily, toggleActivateFont, getAvailableFontsOutline, modalTabOpen, toggleModal, refreshLibrary, + notice, + setNotice, saveFontFamilies, fontFamiliesHasChanges, isResolvingLibrary, @@ -22014,93 +27350,7 @@ function context_FontLibraryProvider({ } }, children); } -/* harmony default export */ var context = ((/* unused pure expression or super */ null && (context_FontLibraryProvider))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/tab-layout.js - -/** - * WordPress dependencies - */ - - -function tab_layout_TabLayout({ - title, - description, - handleBack, - children, - footer -}) { - return createElement("div", { - className: "font-library-modal__tab-layout" - }, createElement(Spacer, { - margin: 4 - }), createElement(VStack, { - spacing: 4, - justify: "space-between" - }, createElement("header", null, createElement(VStack, { - spacing: 2 - }, createElement(HStack, { - justify: "flex-start" - }, !!handleBack && createElement(Button, { - variant: "tertiary", - onClick: handleBack, - icon: chevronLeft, - size: "small" - }), title && createElement(Heading, { - level: 2, - size: 13, - className: "edit-site-global-styles-header" - }, title)), description && createElement(Text, null, description))), createElement("main", null, children), footer && createElement("footer", null, footer))); -} -/* harmony default export */ var tab_layout = ((/* unused pure expression or super */ null && (tab_layout_TabLayout))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/fonts-grid.js - -/** - * WordPress dependencies - */ - - -function fonts_grid_FontsGrid({ - title, - children, - pageSize = 32 -}) { - const [lastItem, setLastItem] = useState(null); - const [page, setPage] = useState(1); - const itemsLimit = page * pageSize; - const items = children.slice(0, itemsLimit); - useEffect(() => { - if (lastItem) { - const observer = new window.IntersectionObserver(([entry]) => { - if (entry.isIntersecting) { - setPage(prevPage => prevPage + 1); - } - }); - observer.observe(lastItem); - return () => observer.disconnect(); - } - }, [lastItem]); - return createElement("div", { - className: "font-library-modal__fonts-grid" - }, createElement(VStack, { - spacing: 0 - }, title && createElement(Fragment, null, createElement(Text, { - className: "font-library-modal__subtitle" - }, title), createElement(Spacer, { - margin: 2 - })), createElement("div", { - className: "font-library-modal__fonts-grid__main" - }, items.map((child, i) => { - if (i === itemsLimit - 1) { - return createElement("div", { - ref: setLastItem - }, child); - } - return child; - })))); -} -/* harmony default export */ var fonts_grid = ((/* unused pure expression or super */ null && (fonts_grid_FontsGrid))); +/* harmony default export */ const context = (FontLibraryProvider); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/font-demo.js @@ -22123,42 +27373,57 @@ function getPreviewUrl(fontFace) { return Array.isArray(fontFace.src) ? fontFace.src[0] : fontFace.src; } } -function font_demo_FontFaceDemo({ - customPreviewUrl, - fontFace, - text, - style = {} +function getDisplayFontFace(font) { + // if this IS a font face return it + if (font.fontStyle || font.fontWeight) { + return font; + } + // if this is a font family with a collection of font faces + // return the first one that is normal and 400 OR just the first one + if (font.fontFace && font.fontFace.length) { + return font.fontFace.find(face => face.fontStyle === 'normal' && face.fontWeight === '400') || font.fontFace[0]; + } + // This must be a font family with no font faces + // return a fake font face + return { + fontStyle: 'normal', + fontWeight: '400', + fontFamily: font.fontFamily, + fake: true + }; +} +function FontDemo({ + font, + text }) { - const ref = useRef(null); - const [isIntersecting, setIsIntersecting] = useState(false); - const [isAssetLoaded, setIsAssetLoaded] = useState(false); + const ref = (0,external_wp_element_namespaceObject.useRef)(null); + const fontFace = getDisplayFontFace(font); + const style = getFamilyPreviewStyle(font); + text = text || font.name; + const customPreviewUrl = font.preview; + const [isIntersecting, setIsIntersecting] = (0,external_wp_element_namespaceObject.useState)(false); + const [isAssetLoaded, setIsAssetLoaded] = (0,external_wp_element_namespaceObject.useState)(false); const { loadFontFaceAsset - } = useContext(FontLibraryContext); + } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); const previewUrl = customPreviewUrl !== null && customPreviewUrl !== void 0 ? customPreviewUrl : getPreviewUrl(fontFace); const isPreviewImage = previewUrl && previewUrl.match(/\.(png|jpg|jpeg|gif|svg)$/i); const faceStyles = getFacePreviewStyle(fontFace); const textDemoStyle = { - whiteSpace: 'nowrap', - flexShrink: 0, fontSize: '18px', + lineHeight: 1, opacity: isAssetLoaded ? '1' : '0', - transition: 'opacity 0.3s ease-in-out', - ...faceStyles, - ...style - }; - const imageDemoStyle = { - height: '23px', - width: 'auto' + ...style, + ...faceStyles }; - useEffect(() => { + (0,external_wp_element_namespaceObject.useEffect)(() => { const observer = new window.IntersectionObserver(([entry]) => { setIsIntersecting(entry.isIntersecting); }, {}); observer.observe(ref.current); return () => observer.disconnect(); }, [ref]); - useEffect(() => { + (0,external_wp_element_namespaceObject.useEffect)(() => { const loadAsset = async () => { if (isIntersecting) { if (!isPreviewImage && fontFace.src) { @@ -22168,106 +27433,20 @@ function font_demo_FontFaceDemo({ } }; loadAsset(); - }, [fontFace, isIntersecting, loadFontFaceAsset]); - return createElement("div", { + }, [fontFace, isIntersecting, loadFontFaceAsset, isPreviewImage]); + return (0,external_React_.createElement)("div", { ref: ref - }, isPreviewImage ? createElement("img", { + }, isPreviewImage ? (0,external_React_.createElement)("img", { src: previewUrl, loading: "lazy", alt: text, - style: imageDemoStyle - }) : createElement(Text, { - style: textDemoStyle + className: "font-library-modal__font-variant_demo-image" + }) : (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { + style: textDemoStyle, + className: "font-library-modal__font-variant_demo-text" }, text)); } -/* harmony default export */ var font_demo = ((/* unused pure expression or super */ null && (font_demo_FontFaceDemo))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/library-font-variant.js - -/** - * WordPress dependencies - */ - - -/** - * Internal dependencies - */ - - -/** - * Internal dependencies - */ - - -function library_font_variant_LibraryFontVariant({ - face, - font -}) { - const { - isFontActivated, - toggleActivateFont - } = useContext(FontLibraryContext); - const isIstalled = font?.fontFace ? isFontActivated(font.slug, face.fontStyle, face.fontWeight, font.source) : isFontActivated(font.slug, null, null, font.source); - const handleToggleActivation = () => { - if (font?.fontFace) { - toggleActivateFont(font, face); - return; - } - toggleActivateFont(font); - }; - const displayName = font.name + ' ' + getFontFaceVariantName(face); - return createElement("div", { - className: "font-library-modal__library-font-variant" - }, createElement(Flex, { - justify: "space-between", - align: "center", - gap: "1rem" - }, createElement(FontFaceDemo, { - fontFace: face, - text: displayName - }), createElement(CheckboxControl, { - checked: isIstalled, - onChange: handleToggleActivation, - __nextHasNoMarginBottom: true - }))); -} -/* harmony default export */ var library_font_variant = ((/* unused pure expression or super */ null && (library_font_variant_LibraryFontVariant))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/library-font-details.js - -/** - * WordPress dependencies - */ - - -/** - * Internal dependencies - */ - - -function library_font_details_LibraryFontDetails({ - font -}) { - const fontFaces = font.fontFace && font.fontFace.length ? sortFontFaces(font.fontFace) : [{ - fontFamily: font.fontFamily, - fontStyle: 'normal', - fontWeight: '400' - }]; - return createElement(Fragment, null, createElement(Spacer, { - margin: 4 - }), createElement(VStack, { - spacing: 0 - }, createElement(Spacer, { - margin: 8 - }), fontFaces.map((face, i) => createElement(LibraryFontVariant, { - font: font, - face: face, - key: `face${i}` - }))), createElement(Spacer, { - margin: 8 - })); -} -/* harmony default export */ var library_font_details = ((/* unused pure expression or super */ null && (library_font_details_LibraryFontDetails))); +/* harmony default export */ const font_demo = (FontDemo); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/font-card.js @@ -22282,47 +27461,43 @@ function library_font_details_LibraryFontDetails({ */ - -function font_card_FontCard({ +function FontCard({ font, onClick, - variantsText + variantsText, + navigatorPath }) { - const fakeFontFace = { - fontStyle: 'normal', - fontWeight: '400', - fontFamily: font.fontFamily, - fake: true - }; - const displayFontFace = font.fontFace && font.fontFace.length ? font?.fontFace?.find(face => face.fontStyle === 'normal' && face.fontWeight === '400') || font.fontFace[0] : fakeFontFace; - const demoStyle = getFamilyPreviewStyle(font); const variantsCount = font.fontFace?.length || 1; const style = { cursor: !!onClick ? 'pointer' : 'default' }; - return createElement(Button, { - onClick: onClick, + const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + onClick: () => { + onClick(); + if (navigatorPath) { + navigator.goTo(navigatorPath); + } + }, style: style, className: "font-library-modal__font-card" - }, createElement(Flex, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { justify: "space-between", wrap: false - }, createElement(FontDemo, { - customPreviewUrl: font.preview, - fontFace: displayFontFace, - text: font.name, - style: demoStyle - }), createElement(Flex, { + }, (0,external_React_.createElement)(font_demo, { + font: font + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { justify: "flex-end" - }, createElement(FlexItem, null, createElement(Text, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { className: "font-library-modal__font-card__count" - }, variantsText || variantsCount + ' ' + _n('variant', 'variants', variantsCount))), createElement(FlexItem, null, createElement(Icon, { - icon: chevronRight + }, variantsText || (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: Number of font variants. */ + (0,external_wp_i18n_namespaceObject._n)('%d variant', '%d variants', variantsCount), variantsCount))), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: chevron_right }))))); } -/* harmony default export */ var font_card = ((/* unused pure expression or super */ null && (font_card_FontCard))); +/* harmony default export */ const font_card = (FontCard); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/library-font-card.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/library-font-variant.js /** * WordPress dependencies @@ -22335,111 +27510,79 @@ function font_card_FontCard({ */ -function library_font_card_LibraryFontCard({ - font, - ...props -}) { - const { - getFontFacesActivated - } = useContext(FontLibraryContext); - const variantsInstalled = font.fontFace?.length || 1; - const variantsActive = getFontFacesActivated(font.slug, font.source).length; - const variantsText = sprintf( /* translators: %1$d: Active font variants, %2$d: Total font variants */ - __('%1$s/%2$s variants active'), variantsActive, variantsInstalled); - return createElement(FontCard, { - font: font, - variantsText: variantsText, - ...props - }); -} -/* harmony default export */ var library_font_card = ((/* unused pure expression or super */ null && (library_font_card_LibraryFontCard))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js -/** - * WordPress dependencies - */ - -function confirm_delete_dialog_ConfirmDeleteDialog({ - font, - isConfirmDeleteOpen, - handleConfirmUninstall, - handleCancelUninstall +function LibraryFontVariant({ + face, + font }) { - return createElement(ConfirmDialog, { - isOpen: isConfirmDeleteOpen, - cancelButtonText: __('No, keep the font'), - confirmButtonText: __('Yes, uninstall'), - onCancel: handleCancelUninstall, - onConfirm: handleConfirmUninstall - }, font && sprintf( /* translators: %s: Name of the font. */ - __('Would you like to remove %s and all its variants and assets?'), font.name)); -} -/* harmony default export */ var confirm_delete_dialog = ((/* unused pure expression or super */ null && (confirm_delete_dialog_ConfirmDeleteDialog))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/get-notice-from-response.js -/** - * WordPress dependencies - */ - -function get_notice_from_response_getNoticeFromInstallResponse(response) { const { - errors = [], - successes = [] - } = response; - // Everything failed. - if (errors.length && !successes.length) { - return { - type: 'error', - message: __('Error installing the fonts.') - }; - } - - // Eveerything succeeded. - if (!errors.length && successes.length) { - return { - type: 'success', - message: __('Fonts were installed successfully.') - }; - } - - // Some succeeded, some failed. - if (errors.length && successes.length) { - return { - type: 'warning', - message: __('Some fonts were installed successfully and some failed.') - }; - } -} -function get_notice_from_response_getNoticeFromUninstallResponse(response) { + isFontActivated, + toggleActivateFont + } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); + const isInstalled = font?.fontFace?.length > 0 ? isFontActivated(font.slug, face.fontStyle, face.fontWeight, font.source) : isFontActivated(font.slug, null, null, font.source); + const handleToggleActivation = () => { + if (font?.fontFace?.length > 0) { + toggleActivateFont(font, face); + return; + } + toggleActivateFont(font); + }; + const displayName = font.name + ' ' + getFontFaceVariantName(face); const { - errors = [], - successes = [] - } = response; - // Everything failed. - if (errors.length && !successes.length) { - return { - type: 'error', - message: __('Error uninstalling the fonts.') - }; + kebabCase + } = unlock(external_wp_components_namespaceObject.privateApis); + const checkboxId = kebabCase(`${font.slug}-${getFontFaceVariantName(face)}`); + return (0,external_React_.createElement)("div", { + className: "font-library-modal__font-card" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { + justify: "flex-start", + align: "center", + gap: "1rem" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { + checked: isInstalled, + onChange: handleToggleActivation, + __nextHasNoMarginBottom: true, + id: checkboxId + }), (0,external_React_.createElement)("label", { + htmlFor: checkboxId + }, (0,external_React_.createElement)(font_demo, { + font: face, + text: displayName, + onClick: handleToggleActivation + })))); +} +/* harmony default export */ const library_font_variant = (LibraryFontVariant); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js +function getNumericFontWeight(value) { + switch (value) { + case 'normal': + return 400; + case 'bold': + return 700; + case 'bolder': + return 500; + case 'lighter': + return 300; + default: + return parseInt(value, 10); } +} +function sortFontFaces(faces) { + return faces.sort((a, b) => { + // Ensure 'normal' fontStyle is always first + if (a.fontStyle === 'normal' && b.fontStyle !== 'normal') return -1; + if (b.fontStyle === 'normal' && a.fontStyle !== 'normal') return 1; - // Everything succeeded. - if (!errors.length && successes.length) { - return { - type: 'success', - message: __('Fonts were uninstalled successfully.') - }; - } + // If both fontStyles are the same, sort by fontWeight + if (a.fontStyle === b.fontStyle) { + return getNumericFontWeight(a.fontWeight) - getNumericFontWeight(b.fontWeight); + } - // Some succeeded, some failed. - if (errors.length && successes.length) { - return { - type: 'warning', - message: __('Some fonts were uninstalled successfully and some failed.') - }; - } + // Sort other fontStyles alphabetically + return a.fontStyle.localeCompare(b.fontStyle); + }); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/installed-fonts.js @@ -22451,12 +27594,12 @@ function get_notice_from_response_getNoticeFromUninstallResponse(response) { -/** - * Internal dependencies - */ +/** + * Internal dependencies + */ @@ -22465,212 +27608,243 @@ function get_notice_from_response_getNoticeFromUninstallResponse(response) { const { ProgressBar } = unlock(external_wp_components_namespaceObject.privateApis); -function installed_fonts_InstalledFonts() { +function InstalledFonts() { const { baseCustomFonts, libraryFontSelected, baseThemeFonts, handleSetLibraryFontSelected, refreshLibrary, - uninstallFont, - isResolvingLibrary - } = useContext(FontLibraryContext); - const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = useState(false); - const handleUnselectFont = () => { - handleSetLibraryFontSelected(null); - }; - const handleSelectFont = font => { - handleSetLibraryFontSelected(font); - }; - const [notice, setNotice] = useState(null); - const handleConfirmUninstall = async () => { - const response = await uninstallFont(libraryFontSelected); - const uninstallNotice = getNoticeFromUninstallResponse(response); - setNotice(uninstallNotice); - // If the font was succesfully uninstalled it is unselected - if (!response?.errors?.length) { - handleUnselectFont(); - } - setIsConfirmDeleteOpen(false); - }; - const handleUninstallClick = async () => { + uninstallFontFamily, + isResolvingLibrary, + isInstalling, + saveFontFamilies, + getFontFacesActivated, + fontFamiliesHasChanges, + notice, + setNotice + } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); + const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = (0,external_wp_element_namespaceObject.useState)(false); + const customFontFamilyId = libraryFontSelected?.source === 'custom' && libraryFontSelected?.id; + const canUserDelete = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + canUser + } = select(external_wp_coreData_namespaceObject.store); + return customFontFamilyId && canUser('delete', 'font-families', customFontFamilyId); + }, [customFontFamilyId]); + const shouldDisplayDeleteButton = !!libraryFontSelected && libraryFontSelected?.source !== 'theme' && canUserDelete; + const handleUninstallClick = () => { setIsConfirmDeleteOpen(true); }; - const handleCancelUninstall = () => { - setIsConfirmDeleteOpen(false); + const getFontFacesToDisplay = font => { + if (!font) { + return []; + } + if (!font.fontFace || !font.fontFace.length) { + return [{ + fontFamily: font.fontFamily, + fontStyle: 'normal', + fontWeight: '400' + }]; + } + return sortFontFaces(font.fontFace); }; - const tabDescription = !!libraryFontSelected ? __('Choose font variants. Keep in mind that too many variants could make your site slower.') : null; - const shouldDisplayDeleteButton = !!libraryFontSelected && libraryFontSelected?.source !== 'theme'; - useEffect(() => { + const getFontCardVariantsText = font => { + const variantsInstalled = font?.fontFace?.length > 0 ? font.fontFace.length : 1; + const variantsActive = getFontFacesActivated(font.slug, font.source).length; + return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Active font variants, 2: Total font variants. */ + (0,external_wp_i18n_namespaceObject.__)('%1$s/%2$s variants active'), variantsActive, variantsInstalled); + }; + (0,external_wp_element_namespaceObject.useEffect)(() => { + handleSetLibraryFontSelected(libraryFontSelected); refreshLibrary(); - // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - - // Reset notice after 5 seconds - useEffect(() => { - if (notice) { - const timeout = setTimeout(() => { - setNotice(null); - }, 5000); - return () => clearTimeout(timeout); - } - }, [notice]); - return createElement(TabLayout, { - title: libraryFontSelected?.name || '', - description: tabDescription, - handleBack: !!libraryFontSelected && handleUnselectFont, - footer: createElement(Footer, { - shouldDisplayDeleteButton: shouldDisplayDeleteButton, - handleUninstallClick: handleUninstallClick - }) - }, createElement(ConfirmDeleteDialog, { - font: libraryFontSelected, - isConfirmDeleteOpen: isConfirmDeleteOpen, - handleConfirmUninstall: handleConfirmUninstall, - handleCancelUninstall: handleCancelUninstall - }), notice && createElement(Fragment, null, createElement(FlexItem, null, createElement(Spacer, { - margin: 2 - }), createElement(Notice, { - isDismissible: false, + return (0,external_React_.createElement)("div", { + className: "font-library-modal__tabpanel-layout" + }, isResolvingLibrary && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + align: "center" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { + initialPath: libraryFontSelected ? '/fontFamily' : '/' + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + path: "/" + }, notice && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 1 + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { status: notice.type, - className: "font-library-modal__font-collection__notice" - }, notice.message)), createElement(Spacer, { - margin: 4 - })), !libraryFontSelected && createElement(Fragment, null, isResolvingLibrary && createElement(Spinner, null), baseCustomFonts.length > 0 && createElement(Fragment, null, createElement(Spacer, { + onRemove: () => setNotice(null) + }, notice.message), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 1 + })), baseCustomFonts.length > 0 && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { + className: "font-library-modal__subtitle" + }, (0,external_wp_i18n_namespaceObject.__)('Installed Fonts')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { margin: 2 - }), createElement(FontsGrid, null, baseCustomFonts.map(font => createElement(LibraryFontCard, { + }), baseCustomFonts.map(font => (0,external_React_.createElement)(font_card, { font: font, key: font.slug, + navigatorPath: '/fontFamily', + variantsText: getFontCardVariantsText(font), onClick: () => { - handleSelectFont(font); + handleSetLibraryFontSelected(font); } - }))), createElement(Spacer, { + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { margin: 8 - })), baseThemeFonts.length > 0 && createElement(Fragment, null, createElement(FontsGrid, { - title: __('Theme Fonts') - }, baseThemeFonts.map(font => createElement(LibraryFontCard, { + })), baseThemeFonts.length > 0 && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { + className: "font-library-modal__subtitle" + }, (0,external_wp_i18n_namespaceObject.__)('Theme Fonts')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 2 + }), baseThemeFonts.map(font => (0,external_React_.createElement)(font_card, { font: font, key: font.slug, + navigatorPath: '/fontFamily', + variantsText: getFontCardVariantsText(font), onClick: () => { - handleSelectFont(font); + handleSetLibraryFontSelected(font); } - }))))), libraryFontSelected && createElement(LibraryFontDetails, { + }))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 16 + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + path: "/fontFamily" + }, (0,external_React_.createElement)(ConfirmDeleteDialog, { font: libraryFontSelected, - isConfirmDeleteOpen: isConfirmDeleteOpen, - handleConfirmUninstall: handleConfirmUninstall, - handleCancelUninstall: handleCancelUninstall - })); -} -function Footer({ - shouldDisplayDeleteButton, - handleUninstallClick -}) { - const { - saveFontFamilies, - fontFamiliesHasChanges, - isInstalling - } = useContext(FontLibraryContext); - return createElement(HStack, { - justify: "space-between" - }, isInstalling && createElement(ProgressBar, null), createElement("div", null, shouldDisplayDeleteButton && createElement(Button, { + isOpen: isConfirmDeleteOpen, + setIsOpen: setIsConfirmDeleteOpen, + setNotice: setNotice, + uninstallFontFamily: uninstallFontFamily, + handleSetLibraryFontSelected: handleSetLibraryFontSelected + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { + justify: "flex-start" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorToParentButton, { + icon: chevron_left, + isSmall: true, + onClick: () => { + handleSetLibraryFontSelected(null); + }, + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view') + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + level: 2, + size: 13, + className: "edit-site-global-styles-header" + }, libraryFontSelected?.name)), notice && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 1 + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { + status: notice.type, + onRemove: () => setNotice(null) + }, notice.message), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 1 + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 4 + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('Choose font variants. Keep in mind that too many variants could make your site slower.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 4 + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: 0 + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 8 + }), getFontFacesToDisplay(libraryFontSelected).map((face, i) => (0,external_React_.createElement)(library_font_variant, { + font: libraryFontSelected, + face: face, + key: `face${i}` + }))))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "flex-end", + className: "font-library-modal__tabpanel-layout__footer" + }, isInstalling && (0,external_React_.createElement)(ProgressBar, null), shouldDisplayDeleteButton && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + isDestructive: true, variant: "tertiary", onClick: handleUninstallClick - }, __('Delete'))), createElement(Button, { - disabled: !fontFamiliesHasChanges, + }, (0,external_wp_i18n_namespaceObject.__)('Delete')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", - onClick: saveFontFamilies - }, __('Update'))); + onClick: saveFontFamilies, + disabled: !fontFamiliesHasChanges, + __experimentalIsFocusable: true + }, (0,external_wp_i18n_namespaceObject.__)('Update')))); } -/* harmony default export */ var installed_fonts = ((/* unused pure expression or super */ null && (installed_fonts_InstalledFonts))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/collection-font-variant.js - -/** - * WordPress dependencies - */ - -/** - * Internal dependencies - */ - - -/** - * Internal dependencies - */ - -function collection_font_variant_CollectionFontVariant({ - face, +function ConfirmDeleteDialog({ font, - handleToggleVariant, - selected + isOpen, + setIsOpen, + setNotice, + uninstallFontFamily, + handleSetLibraryFontSelected }) { - const handleToggleActivation = () => { - if (font?.fontFace) { - handleToggleVariant(font, face); - return; + const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); + const handleConfirmUninstall = async () => { + setNotice(null); + setIsOpen(false); + try { + await uninstallFontFamily(font); + navigator.goBack(); + handleSetLibraryFontSelected(null); + setNotice({ + type: 'success', + message: (0,external_wp_i18n_namespaceObject.__)('Font family uninstalled successfully.') + }); + } catch (error) { + setNotice({ + type: 'error', + message: (0,external_wp_i18n_namespaceObject.__)('There was an error uninstalling the font family. ') + error.message + }); } - handleToggleVariant(font); }; - const displayName = font.name + ' ' + getFontFaceVariantName(face); - return createElement("div", { - className: "font-library-modal__library-font-variant" - }, createElement(Flex, { - justify: "space-between", - align: "center", - gap: "1rem" - }, createElement(FontFaceDemo, { - fontFace: face, - text: displayName - }), createElement(CheckboxControl, { - checked: selected, - onChange: handleToggleActivation, - __nextHasNoMarginBottom: true - }))); + const handleCancelUninstall = () => { + setIsOpen(false); + }; + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { + isOpen: isOpen, + cancelButtonText: (0,external_wp_i18n_namespaceObject.__)('Cancel'), + confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Delete'), + onCancel: handleCancelUninstall, + onConfirm: handleConfirmUninstall + }, font && (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Name of the font. */ + (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s" font and all its variants and assets?'), font.name)); } -/* harmony default export */ var collection_font_variant = ((/* unused pure expression or super */ null && (collection_font_variant_CollectionFontVariant))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/collection-font-details.js +/* harmony default export */ const installed_fonts = (InstalledFonts); +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js /** - * WordPress dependencies - */ - - -/** - * Internal dependencies + * Filters a list of fonts based on the specified filters. + * + * This function filters a given array of fonts based on the criteria provided in the filters object. + * It supports filtering by category and a search term. If the category is provided and not equal to 'all', + * the function filters the fonts array to include only those fonts that belong to the specified category. + * Additionally, if a search term is provided, it filters the fonts array to include only those fonts + * whose name includes the search term, case-insensitively. + * + * @param {Array} fonts Array of font objects in font-collection schema fashion to be filtered. Each font object should have a 'categories' property and a 'font_family_settings' property with a 'name' key. + * @param {Object} filters Object containing the filter criteria. It should have a 'category' key and/or a 'search' key. + * The 'category' key is a string representing the category to filter by. + * The 'search' key is a string representing the search term to filter by. + * @return {Array} Array of filtered font objects based on the provided criteria. */ +function filterFonts(fonts, filters) { + const { + category, + search + } = filters; + let filteredFonts = fonts || []; + if (category && category !== 'all') { + filteredFonts = filteredFonts.filter(font => font.categories.indexOf(category) !== -1); + } + if (search) { + filteredFonts = filteredFonts.filter(font => font.font_family_settings.name.toLowerCase().includes(search.toLowerCase())); + } + return filteredFonts; +} - - -function collection_font_details_CollectionFontDetails({ - font, - handleToggleVariant, - fontToInstallOutline -}) { - const fontFaces = font.fontFace && font.fontFace.length ? sortFontFaces(font.fontFace) : [{ - fontFamily: font.fontFamily, - fontStyle: 'normal', - fontWeight: '400' - }]; - return createElement(Fragment, null, createElement(Spacer, { - margin: 4 - }), createElement(VStack, { - spacing: 0 - }, createElement(Spacer, { - margin: 8 - }), fontFaces.map((face, i) => createElement(CollectionFontVariant, { - font: font, - face: face, - key: `face${i}`, - handleToggleVariant: handleToggleVariant, - selected: isFontFontFaceInOutline(font.slug, font.fontFace ? face : null, - // If the font has no fontFace, we want to check if the font is in the outline - fontToInstallOutline) - }))), createElement(Spacer, { - margin: 8 - })); +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/fonts-outline.js +function getFontsOutline(fonts) { + return fonts.reduce((acc, font) => ({ + ...acc, + [font.slug]: (font?.fontFace || []).reduce((faces, face) => ({ + ...faces, + [`${face.fontStyle}-${face.fontWeight}`]: true + }), {}) + }), {}); +} +function isFontFontFaceInOutline(slug, face, outline) { + if (!face) { + return !!outline[slug]; + } + return !!outline[slug]?.[`${face.fontStyle}-${face.fontWeight}`]; } -/* harmony default export */ var collection_font_details = ((/* unused pure expression or super */ null && (collection_font_details_CollectionFontDetails))); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js @@ -22679,32 +27853,84 @@ function collection_font_details_CollectionFontDetails({ */ -function google_fonts_confirm_dialog_GoogleFontsConfirmDialog() { +function GoogleFontsConfirmDialog() { const handleConfirm = () => { // eslint-disable-next-line no-undef - window.localStorage.setItem('wp-font-library-default-font-collection-permission', 'true'); + window.localStorage.setItem('wp-font-library-google-fonts-permission', 'true'); window.dispatchEvent(new Event('storage')); }; - return createElement("div", { + return (0,external_React_.createElement)("div", { className: "font-library__google-fonts-confirm" - }, createElement(Card, null, createElement(CardBody, null, createElement(Text, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Card, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "h3" - }, "Connect to Google Fonts"), createElement(Spacer, { + }, (0,external_wp_i18n_namespaceObject.__)('Connect to Google Fonts')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { margin: 6 - }), createElement(Text, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "p" - }, __('To install fonts from Google you must give permission to connect directly to Google servers. The fonts you install will be downloaded from Google and stored on your site. Your site will then use these locally-hosted fonts.')), createElement(Spacer, { + }, (0,external_wp_i18n_namespaceObject.__)('To install fonts from Google you must give permission to connect directly to Google servers. The fonts you install will be downloaded from Google and stored on your site. Your site will then use these locally-hosted fonts.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { margin: 3 - }), createElement(Text, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "p" - }, __('You can alternatively upload files directly on the Library tab.')), createElement(Spacer, { + }, (0,external_wp_i18n_namespaceObject.__)('You can alternatively upload files directly on the Upload tab.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { margin: 6 - }), createElement(Button, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", onClick: handleConfirm - }, __('Allow access to Google Fonts'))))); + }, (0,external_wp_i18n_namespaceObject.__)('Allow access to Google Fonts'))))); } -/* harmony default export */ var google_fonts_confirm_dialog = ((/* unused pure expression or super */ null && (google_fonts_confirm_dialog_GoogleFontsConfirmDialog))); +/* harmony default export */ const google_fonts_confirm_dialog = (GoogleFontsConfirmDialog); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/collection-font-variant.js + +/** + * WordPress dependencies + */ + + +/** + * Internal dependencies + */ + + + +function CollectionFontVariant({ + face, + font, + handleToggleVariant, + selected +}) { + const handleToggleActivation = () => { + if (font?.fontFace) { + handleToggleVariant(font, face); + return; + } + handleToggleVariant(font); + }; + const displayName = font.name + ' ' + getFontFaceVariantName(face); + const { + kebabCase + } = unlock(external_wp_components_namespaceObject.privateApis); + const checkboxId = kebabCase(`${font.slug}-${getFontFaceVariantName(face)}`); + return (0,external_React_.createElement)("div", { + className: "font-library-modal__font-card" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { + justify: "flex-start", + align: "center", + gap: "1rem" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { + checked: selected, + onChange: handleToggleActivation, + __nextHasNoMarginBottom: true, + id: checkboxId + }), (0,external_React_.createElement)("label", { + htmlFor: checkboxId + }, (0,external_React_.createElement)(font_demo, { + font: face, + text: displayName, + onClick: handleToggleActivation + })))); +} +/* harmony default export */ const collection_font_variant = (CollectionFontVariant); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/font-collection.js @@ -22729,86 +27955,111 @@ function google_fonts_confirm_dialog_GoogleFontsConfirmDialog() { - const DEFAULT_CATEGORY = { - id: 'all', - name: (0,external_wp_i18n_namespaceObject.__)('All') + slug: 'all', + name: (0,external_wp_i18n_namespaceObject._x)('All', 'font categories') }; -function font_collection_FontCollection({ - id +const LOCAL_STORAGE_ITEM = 'wp-font-library-google-fonts-permission'; +const MIN_WINDOW_HEIGHT = 500; +function FontCollection({ + slug }) { - var _selectedCollection$d2; - const requiresPermission = id === 'default-font-collection'; + var _selectedCollection$c; + const requiresPermission = slug === 'google-fonts'; const getGoogleFontsPermissionFromStorage = () => { - return window.localStorage.getItem('wp-font-library-default-font-collection-permission') === 'true'; + return window.localStorage.getItem(LOCAL_STORAGE_ITEM) === 'true'; }; - const [notice, setNotice] = useState(null); - const [selectedFont, setSelectedFont] = useState(null); - const [fontsToInstall, setFontsToInstall] = useState([]); - const [filters, setFilters] = useState({}); - const [renderConfirmDialog, setRenderConfirmDialog] = useState(requiresPermission && !getGoogleFontsPermissionFromStorage()); + const [selectedFont, setSelectedFont] = (0,external_wp_element_namespaceObject.useState)(null); + const [fontsToInstall, setFontsToInstall] = (0,external_wp_element_namespaceObject.useState)([]); + const [page, setPage] = (0,external_wp_element_namespaceObject.useState)(1); + const [filters, setFilters] = (0,external_wp_element_namespaceObject.useState)({}); + const [renderConfirmDialog, setRenderConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(requiresPermission && !getGoogleFontsPermissionFromStorage()); const { collections, getFontCollection, - installFonts - } = useContext(FontLibraryContext); - const selectedCollection = collections.find(collection => collection.id === id); - useEffect(() => { + installFonts, + isInstalling, + notice, + setNotice + } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); + const selectedCollection = collections.find(collection => collection.slug === slug); + (0,external_wp_element_namespaceObject.useEffect)(() => { const handleStorage = () => { setRenderConfirmDialog(requiresPermission && !getGoogleFontsPermissionFromStorage()); }; handleStorage(); window.addEventListener('storage', handleStorage); return () => window.removeEventListener('storage', handleStorage); - }, [id, requiresPermission]); - useEffect(() => { - getFontCollection(id); - resetFilters(); - }, [id, getFontCollection]); - useEffect(() => { + }, [slug, requiresPermission]); + const revokeAccess = () => { + window.localStorage.setItem(LOCAL_STORAGE_ITEM, 'false'); + window.dispatchEvent(new Event('storage')); + }; + (0,external_wp_element_namespaceObject.useEffect)(() => { + const fetchFontCollection = async () => { + try { + await getFontCollection(slug); + resetFilters(); + } catch (e) { + if (!notice) { + setNotice({ + type: 'error', + message: e?.message + }); + } + } + }; + fetchFontCollection(); + }, [slug, getFontCollection, setNotice, notice]); + (0,external_wp_element_namespaceObject.useEffect)(() => { setSelectedFont(null); - }, [id]); - - // Reset notice after 5 seconds - useEffect(() => { - if (notice) { - const timeout = setTimeout(() => { - setNotice(null); - }, 5000); - return () => clearTimeout(timeout); - } - }, [notice]); - const collectionFonts = useMemo(() => { - var _selectedCollection$d; - return (_selectedCollection$d = selectedCollection?.data?.fontFamilies) !== null && _selectedCollection$d !== void 0 ? _selectedCollection$d : []; + setNotice(null); + }, [slug, setNotice]); + (0,external_wp_element_namespaceObject.useEffect)(() => { + // If the selected fonts change, reset the selected fonts to install + setFontsToInstall([]); + }, [selectedFont]); + const collectionFonts = (0,external_wp_element_namespaceObject.useMemo)(() => { + var _selectedCollection$f; + return (_selectedCollection$f = selectedCollection?.font_families) !== null && _selectedCollection$f !== void 0 ? _selectedCollection$f : []; }, [selectedCollection]); - const collectionCategories = (_selectedCollection$d2 = selectedCollection?.data?.categories) !== null && _selectedCollection$d2 !== void 0 ? _selectedCollection$d2 : []; + const collectionCategories = (_selectedCollection$c = selectedCollection?.categories) !== null && _selectedCollection$c !== void 0 ? _selectedCollection$c : []; const categories = [DEFAULT_CATEGORY, ...collectionCategories]; - const fonts = useMemo(() => filterFonts(collectionFonts, filters), [collectionFonts, filters]); + const fonts = (0,external_wp_element_namespaceObject.useMemo)(() => filterFonts(collectionFonts, filters), [collectionFonts, filters]); + + // NOTE: The height of the font library modal unavailable to use for rendering font family items is roughly 417px + // The height of each font family item is 61px. + const windowHeight = Math.max(window.innerHeight, MIN_WINDOW_HEIGHT); + const pageSize = Math.floor((windowHeight - 417) / 61); + const totalPages = Math.ceil(fonts.length / pageSize); + const itemsStart = (page - 1) * pageSize; + const itemsLimit = page * pageSize; + const items = fonts.slice(itemsStart, itemsLimit); const handleCategoryFilter = category => { setFilters({ ...filters, category }); + setPage(1); }; const handleUpdateSearchInput = value => { setFilters({ ...filters, search: value }); + setPage(1); }; - const debouncedUpdateSearchInput = debounce(handleUpdateSearchInput, 300); + const debouncedUpdateSearchInput = (0,external_wp_compose_namespaceObject.debounce)(handleUpdateSearchInput, 300); const resetFilters = () => { setFilters({}); + setPage(1); }; const resetSearch = () => { setFilters({ ...filters, search: '' }); - }; - const handleUnselectFont = () => { - setSelectedFont(null); + setPage(1); }; const handleToggleVariant = (font, face) => { const newFontsToInstall = toggleFont(font, face, fontsToInstall); @@ -22819,83 +28070,220 @@ function font_collection_FontCollection({ setFontsToInstall([]); }; const handleInstall = async () => { - const response = await installFonts(fontsToInstall); - const installNotice = getNoticeFromInstallResponse(response); - setNotice(installNotice); + setNotice(null); + const fontFamily = fontsToInstall[0]; + try { + if (fontFamily?.fontFace) { + await Promise.all(fontFamily.fontFace.map(async fontFace => { + if (fontFace.src) { + fontFace.file = await downloadFontFaceAssets(fontFace.src); + } + })); + } + } catch (error) { + // If any of the fonts fail to download, + // show an error notice and stop the request from being sent. + setNotice({ + type: 'error', + message: (0,external_wp_i18n_namespaceObject.__)('Error installing the fonts, could not be downloaded.') + }); + return; + } + try { + await installFonts([fontFamily]); + setNotice({ + type: 'success', + message: (0,external_wp_i18n_namespaceObject.__)('Fonts were installed successfully.') + }); + } catch (error) { + setNotice({ + type: 'error', + message: error.message + }); + } resetFontsToInstall(); }; - return createElement(TabLayout, { - title: !selectedFont ? selectedCollection.name : selectedFont.name, - description: !selectedFont ? selectedCollection.description : __('Select font variants to install.'), - handleBack: !!selectedFont && handleUnselectFont, - footer: fontsToInstall.length > 0 && createElement(font_collection_Footer, { - handleInstall: handleInstall - }) - }, renderConfirmDialog && createElement(Fragment, null, createElement(Spacer, { - margin: 8 - }), createElement(GoogleFontsConfirmDialog, null)), !renderConfirmDialog && !selectedCollection.data && createElement(Spinner, null), notice && createElement(Fragment, null, createElement(FlexItem, null, createElement(Spacer, { - margin: 2 - }), createElement(Notice, { - isDismissible: false, - status: notice.type, - className: "font-library-modal__font-collection__notice" - }, notice.message)), createElement(Spacer, { - margin: 2 - })), !renderConfirmDialog && !selectedFont && createElement(Flex, null, createElement(FlexItem, null, createElement(InputControl, { + const getSortedFontFaces = fontFamily => { + if (!fontFamily) { + return []; + } + if (!fontFamily.fontFace || !fontFamily.fontFace.length) { + return [{ + fontFamily: fontFamily.fontFamily, + fontStyle: 'normal', + fontWeight: '400' + }]; + } + return sortFontFaces(fontFamily.fontFace); + }; + if (renderConfirmDialog) { + return (0,external_React_.createElement)(google_fonts_confirm_dialog, null); + } + const ActionsComponent = () => { + if (slug !== 'google-fonts' || renderConfirmDialog || selectedFont) { + return null; + } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + icon: more_vertical, + label: (0,external_wp_i18n_namespaceObject.__)('Actions'), + popoverProps: { + position: 'bottom left' + }, + controls: [{ + title: (0,external_wp_i18n_namespaceObject.__)('Revoke access to Google Fonts'), + onClick: revokeAccess + }] + }); + }; + return (0,external_React_.createElement)("div", { + className: "font-library-modal__tabpanel-layout" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { + initialPath: "/", + className: "font-library-modal__tabpanel-layout" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + path: "/" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "space-between" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + level: 2, + size: 13 + }, selectedCollection.name), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, selectedCollection.description)), (0,external_React_.createElement)(ActionsComponent, null)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 4 + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalInputControl, { value: filters.search, - placeholder: __('Font name…'), - label: __('Search'), + placeholder: (0,external_wp_i18n_namespaceObject.__)('Font name…'), + label: (0,external_wp_i18n_namespaceObject.__)('Search'), onChange: debouncedUpdateSearchInput, - prefix: createElement(Icon, { - icon: search + prefix: (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: library_search }), - suffix: filters?.search ? createElement(Icon, { - icon: closeSmall, + suffix: filters?.search ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: close_small, onClick: resetSearch }) : null - })), createElement(FlexItem, null, createElement(SelectControl, { - label: __('Category'), + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { + label: (0,external_wp_i18n_namespaceObject.__)('Category'), value: filters.category, onChange: handleCategoryFilter - }, categories && categories.map(category => createElement("option", { - value: category.id, - key: category.id - }, category.name))))), createElement(Spacer, { + }, categories && categories.map(category => (0,external_React_.createElement)("option", { + value: category.slug, + key: category.slug + }, category.name))))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { margin: 4 - }), !renderConfirmDialog && !selectedCollection?.data?.fontFamilies && createElement(Spinner, null), !renderConfirmDialog && !!selectedCollection?.data?.fontFamilies?.length && !fonts.length && createElement(Text, null, __('No fonts found. Try with a different seach term')), !renderConfirmDialog && selectedFont && createElement(CollectionFontDetails, { - font: selectedFont, - handleToggleVariant: handleToggleVariant, - fontToInstallOutline: fontToInstallOutline - }), !renderConfirmDialog && !selectedFont && createElement(FontsGrid, null, fonts.map(font => createElement(FontCard, { - key: font.slug, - font: font, + }), !selectedCollection?.font_families && !notice && (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null), !!selectedCollection?.font_families?.length && !fonts.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('No fonts found. Try with a different search term')), (0,external_React_.createElement)("div", { + className: "font-library-modal__fonts-grid__main" + }, items.map(font => (0,external_React_.createElement)(font_card, { + key: font.font_family_settings.slug, + font: font.font_family_settings, + navigatorPath: '/fontFamily', onClick: () => { - setSelectedFont(font); + setSelectedFont(font.font_family_settings); } - })))); -} -function font_collection_Footer({ - handleInstall -}) { - const { - isInstalling - } = useContext(FontLibraryContext); - return createElement(Flex, { - justify: "flex-end" - }, createElement(Button, { + })))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + path: "/fontFamily" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { + justify: "flex-start" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorToParentButton, { + icon: chevron_left, + isSmall: true, + onClick: () => { + setSelectedFont(null); + }, + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view') + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + level: 2, + size: 13, + className: "edit-site-global-styles-header" + }, selectedFont?.name)), notice && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 1 + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { + status: notice.type, + onRemove: () => setNotice(null) + }, notice.message), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 1 + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 4 + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, " ", (0,external_wp_i18n_namespaceObject.__)('Select font variants to install.'), " "), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 4 + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: 0 + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 8 + }), getSortedFontFaces(selectedFont).map((face, i) => (0,external_React_.createElement)(collection_font_variant, { + font: selectedFont, + face: face, + key: `face${i}`, + handleToggleVariant: handleToggleVariant, + selected: isFontFontFaceInOutline(selectedFont.slug, selectedFont.fontFace ? face : null, + // If the font has no fontFace, we want to check if the font is in the outline + fontToInstallOutline) + }))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + margin: 16 + }))), selectedFont && (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { + justify: "flex-end", + className: "font-library-modal__tabpanel-layout__footer" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", onClick: handleInstall, isBusy: isInstalling, - disabled: isInstalling - }, __('Install'))); + disabled: fontsToInstall.length === 0 || isInstalling, + __experimentalIsFocusable: true + }, (0,external_wp_i18n_namespaceObject.__)('Install'))), !selectedFont && (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { + justify: "center", + className: "font-library-modal__tabpanel-layout__footer" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + label: (0,external_wp_i18n_namespaceObject.__)('First page'), + size: "compact", + onClick: () => setPage(1), + disabled: page === 1, + __experimentalIsFocusable: true + }, (0,external_React_.createElement)("span", null, "\xAB")), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + label: (0,external_wp_i18n_namespaceObject.__)('Previous page'), + size: "compact", + onClick: () => setPage(page - 1), + disabled: page === 1, + __experimentalIsFocusable: true + }, (0,external_React_.createElement)("span", null, "\u2039")), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "flex-start", + expanded: false, + spacing: 2 + }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %s: Total number of pages. + (0,external_wp_i18n_namespaceObject._x)('Page <CurrentPageControl /> of %s', 'paging'), totalPages), { + CurrentPageControl: (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Current page'), + value: page, + options: [...Array(totalPages)].map((e, i) => { + return { + label: i + 1, + value: i + 1 + }; + }), + onChange: newPage => setPage(parseInt(newPage)), + size: 'compact', + __nextHasNoMarginBottom: true + }) + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + label: (0,external_wp_i18n_namespaceObject.__)('Next page'), + size: "compact", + onClick: () => setPage(page + 1), + disabled: page === totalPages, + __experimentalIsFocusable: true + }, (0,external_React_.createElement)("span", null, "\u203A")), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + label: (0,external_wp_i18n_namespaceObject.__)('Last page'), + size: "compact", + onClick: () => setPage(totalPages), + disabled: page === totalPages, + __experimentalIsFocusable: true + }, (0,external_React_.createElement)("span", null, "\xBB")))); } -/* harmony default export */ var font_collection = ((/* unused pure expression or super */ null && (font_collection_FontCollection))); +/* harmony default export */ const font_collection = (FontCollection); // EXTERNAL MODULE: ./node_modules/@wordpress/edit-site/lib/unbrotli.js -var unbrotli = __webpack_require__(5723); +var unbrotli = __webpack_require__(8572); var unbrotli_default = /*#__PURE__*/__webpack_require__.n(unbrotli); // EXTERNAL MODULE: ./node_modules/@wordpress/edit-site/lib/inflate.js -var inflate = __webpack_require__(2591); +var inflate = __webpack_require__(4660); var inflate_default = /*#__PURE__*/__webpack_require__.n(inflate); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/lib/lib-font.browser.js /* eslint eslint-comments/no-unlimited-disable: 0 */ @@ -23664,7 +29052,7 @@ function checkFetchResponseStatus( response ) { } return response; } -class lib_font_browser_Font extends EventManager { +class Font extends EventManager { constructor( name, options = {} ) { super(); this.name = name; @@ -23786,7 +29174,7 @@ class lib_font_browser_Font extends EventManager { } } } -globalThis.Font = lib_font_browser_Font; +globalThis.Font = Font; class Subtable extends ParsedData { constructor( p, plaformID, encodingID ) { super( p ); @@ -26730,7 +32118,36 @@ var vmtx$1 = Object.freeze( { __proto__: null, vmtx: vmtx } ); /* eslint-enable */ -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/local-fonts.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/make-families-from-faces.js +/** + * WordPress dependencies + */ + + +/** + * Internal dependencies + */ + +const { + kebabCase: make_families_from_faces_kebabCase +} = unlock(external_wp_components_namespaceObject.privateApis); +function makeFamiliesFromFaces(fontFaces) { + const fontFamiliesObject = fontFaces.reduce((acc, item) => { + if (!acc[item.fontFamily]) { + acc[item.fontFamily] = { + name: item.fontFamily, + fontFamily: item.fontFamily, + slug: make_families_from_faces_kebabCase(item.fontFamily.toLowerCase()), + fontFace: [] + }; + } + acc[item.fontFamily].fontFace.push(item); + return acc; + }, {}); + return Object.values(fontFamiliesObject); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/upload-fonts.js /** * WordPress dependencies @@ -26748,12 +32165,16 @@ var vmtx$1 = Object.freeze( { __proto__: null, vmtx: vmtx } ); -function local_fonts_LocalFonts() { +const { + ProgressBar: upload_fonts_ProgressBar +} = unlock(external_wp_components_namespaceObject.privateApis); +function UploadFonts() { const { - installFonts - } = useContext(FontLibraryContext); - const [notice, setNotice] = useState(null); - const supportedFormats = ALLOWED_FILE_EXTENSIONS.slice(0, -1).map(extension => `.${extension}`).join(', ') + ` ${__('and')} .${ALLOWED_FILE_EXTENSIONS.slice(-1)}`; + installFonts, + notice, + setNotice + } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); + const [isUploading, setIsUploading] = (0,external_wp_element_namespaceObject.useState)(false); const handleDropZone = files => { handleFilesUpload(files); }; @@ -26761,42 +32182,50 @@ function local_fonts_LocalFonts() { handleFilesUpload(event.target.files); }; - // Reset notice after 5 seconds - useEffect(() => { - if (notice) { - const timeout = setTimeout(() => { - setNotice(null); - }, 5000); - return () => clearTimeout(timeout); - } - }, [notice]); - /** * Filters the selected files to only allow the ones with the allowed extensions * * @param {Array} files The files to be filtered * @return {void} */ - const handleFilesUpload = files => { + const handleFilesUpload = async files => { setNotice(null); + setIsUploading(true); const uniqueFilenames = new Set(); const selectedFiles = [...files]; - const allowedFiles = selectedFiles.filter(file => { + let hasInvalidFiles = false; + + // Use map to create a promise for each file check, then filter with Promise.all. + const checkFilesPromises = selectedFiles.map(async file => { + const isFont = await isFontFile(file); + if (!isFont) { + hasInvalidFiles = true; + return null; // Return null for invalid files. + } + // Check for duplicates if (uniqueFilenames.has(file.name)) { - return false; // Discard duplicates + return null; // Return null for duplicates. } - // Eliminates files that are not allowed + // Check if the file extension is allowed. const fileExtension = file.name.split('.').pop().toLowerCase(); if (ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) { uniqueFilenames.add(file.name); - return true; // Keep file if the extension is allowed + return file; // Return the file if it passes all checks. } - - return false; // Discard file extension not allowed + return null; // Return null for disallowed file extensions. }); + // Filter out the nulls after all promises have resolved. + const allowedFiles = (await Promise.all(checkFilesPromises)).filter(file => null !== file); if (allowedFiles.length > 0) { loadFiles(allowedFiles); + } else { + const message = hasInvalidFiles ? (0,external_wp_i18n_namespaceObject.__)('Sorry, you are not allowed to upload this file type.') : (0,external_wp_i18n_namespaceObject.__)('No fonts found to install.'); + setNotice({ + type: 'error', + message + }); + setIsUploading(false); } }; @@ -26812,9 +32241,26 @@ function local_fonts_LocalFonts() { await loadFontFaceInBrowser(fontFaceData, fontFaceData.file, 'all'); return fontFaceData; })); - await handleInstall(fontFacesLoaded); + handleInstall(fontFacesLoaded); }; + /** + * Checks if a file is a valid Font file. + * + * @param {File} file The file to be checked. + * @return {boolean} Whether the file is a valid font file. + */ + async function isFontFile(file) { + const font = new Font('Uploaded Font'); + try { + const buffer = await readFileAsArrayBuffer(file); + await font.fromDataBuffer(buffer, 'font'); + return true; + } catch (error) { + return false; + } + } + // Create a function to read the file as array buffer async function readFileAsArrayBuffer(file) { return new Promise((resolve, reject) => { @@ -26858,64 +32304,60 @@ function local_fonts_LocalFonts() { */ const handleInstall = async fontFaces => { const fontFamilies = makeFamiliesFromFaces(fontFaces); - const response = await installFonts(fontFamilies); - const installNotice = getNoticeFromInstallResponse(response); - setNotice(installNotice); + try { + await installFonts(fontFamilies); + setNotice({ + type: 'success', + message: (0,external_wp_i18n_namespaceObject.__)('Fonts were installed successfully.') + }); + } catch (error) { + setNotice({ + type: 'error', + message: error.message, + errors: error?.installationErrors + }); + } + setIsUploading(false); }; - return createElement(Fragment, null, createElement(Spacer, { - margin: 16 - }), createElement(DropZone, { + return (0,external_React_.createElement)("div", { + className: "font-library-modal__tabpanel-layout" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.DropZone, { onFilesDrop: handleDropZone - }), createElement(VStack, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { className: "font-library-modal__local-fonts" - }, createElement(FormFileUpload, { + }, notice && (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { + status: notice.type, + __unstableHTML: true, + onRemove: () => setNotice(null) + }, notice.message, notice.errors && (0,external_React_.createElement)("ul", null, notice.errors.map((error, index) => (0,external_React_.createElement)("li", { + key: index + }, error)))), isUploading && (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)("div", { + className: "font-library-modal__upload-area" + }, (0,external_React_.createElement)(upload_fonts_ProgressBar, null))), !isUploading && (0,external_React_.createElement)(external_wp_components_namespaceObject.FormFileUpload, { accept: ALLOWED_FILE_EXTENSIONS.map(ext => `.${ext}`).join(','), multiple: true, onChange: onFilesUpload, render: ({ openFileDialog - }) => createElement(Button, { + }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { className: "font-library-modal__upload-area", onClick: openFileDialog - }, createElement("span", null, __('Upload font'))) - }), notice && createElement(FlexItem, null, createElement(Spacer, { - margin: 2 - }), createElement(Notice, { - isDismissible: false, - status: notice.type, - className: "font-library-modal__upload-area__notice" - }, notice.message)), createElement(Spacer, { + }, (0,external_wp_i18n_namespaceObject.__)('Upload font')) + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { margin: 2 - }), createElement(Text, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { className: "font-library-modal__upload-area__text" - }, sprintf( /* translators: %s: supported font formats: ex: .ttf, .woff and .woff2 */ - __('Uploaded fonts appear in your library and can be used in your theme. Supported formats: %s.'), supportedFormats)))); + }, (0,external_wp_i18n_namespaceObject.__)('Uploaded fonts appear in your library and can be used in your theme. Supported formats: .ttf, .otf, .woff, and .woff2.')))); } -/* harmony default export */ var local_fonts = ((/* unused pure expression or super */ null && (local_fonts_LocalFonts))); +/* harmony default export */ const upload_fonts = (UploadFonts); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/upload-fonts.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/index.js /** * WordPress dependencies */ -/** - * Internal dependencies - */ - -function upload_fonts_UploadFonts() { - return createElement(Fragment, null, createElement(Spacer, { - margin: 8 - }), createElement(LocalFonts, null)); -} -/* harmony default export */ var upload_fonts = ((/* unused pure expression or super */ null && (upload_fonts_UploadFonts))); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/index.js - -/** - * WordPress dependencies - */ @@ -26927,54 +32369,89 @@ function upload_fonts_UploadFonts() { -const DEFAULT_TABS = [{ - name: 'installed-fonts', - title: (0,external_wp_i18n_namespaceObject.__)('Library'), - className: 'installed-fonts' -}, { - name: 'upload-fonts', - title: (0,external_wp_i18n_namespaceObject.__)('Upload'), - className: 'upload-fonts' -}]; + +const { + Tabs: font_library_modal_Tabs +} = unlock(external_wp_components_namespaceObject.privateApis); +const DEFAULT_TAB = { + id: 'installed-fonts', + title: (0,external_wp_i18n_namespaceObject.__)('Library') +}; +const UPLOAD_TAB = { + id: 'upload-fonts', + title: (0,external_wp_i18n_namespaceObject.__)('Upload') +}; const tabsFromCollections = collections => collections.map(({ - id, + slug, name }) => ({ - name: id, - title: collections.length === 1 && id === 'default-font-collection' ? __('Install Fonts') : name, - className: 'collection' + id: slug, + title: collections.length === 1 && slug === 'google-fonts' ? (0,external_wp_i18n_namespaceObject.__)('Install Fonts') : name })); -function font_library_modal_FontLibraryModal({ +function FontLibraryModal({ onRequestClose, - initialTabName = 'installed-fonts' + initialTabId = 'installed-fonts' }) { const { - collections - } = useContext(FontLibraryContext); - const tabs = [...DEFAULT_TABS, ...tabsFromCollections(collections || [])]; - return createElement(Modal, { - title: __('Fonts'), + collections, + setNotice + } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); + const canUserCreate = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + canUser + } = select(external_wp_coreData_namespaceObject.store); + return canUser('create', 'font-families'); + }, []); + const tabs = [DEFAULT_TAB]; + if (canUserCreate) { + tabs.push(UPLOAD_TAB); + tabs.push(...tabsFromCollections(collections || [])); + } + + // Reset notice when new tab is selected. + const onSelect = () => { + setNotice(null); + }; + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { + title: (0,external_wp_i18n_namespaceObject.__)('Fonts'), onRequestClose: onRequestClose, isFullScreen: true, className: "font-library-modal" - }, createElement(TabPanel, { - className: "font-library-modal__tab-panel", - initialTabName: initialTabName, - tabs: tabs - }, tab => { - switch (tab.name) { + }, (0,external_React_.createElement)("div", { + className: "font-library-modal__tabs" + }, (0,external_React_.createElement)(font_library_modal_Tabs, { + initialTabId: initialTabId, + onSelect: onSelect + }, (0,external_React_.createElement)(font_library_modal_Tabs.TabList, null, tabs.map(({ + id, + title + }) => (0,external_React_.createElement)(font_library_modal_Tabs.Tab, { + key: id, + tabId: id + }, title))), tabs.map(({ + id + }) => { + let contents; + switch (id) { case 'upload-fonts': - return createElement(UploadFonts, null); + contents = (0,external_React_.createElement)(upload_fonts, null); + break; case 'installed-fonts': - return createElement(InstalledFonts, null); + contents = (0,external_React_.createElement)(installed_fonts, null); + break; default: - return createElement(FontCollection, { - id: tab.name + contents = (0,external_React_.createElement)(font_collection, { + slug: id }); } - })); + return (0,external_React_.createElement)(font_library_modal_Tabs.TabPanel, { + key: id, + tabId: id, + focusable: false + }, contents); + })))); } -/* harmony default export */ var font_library_modal = ((/* unused pure expression or super */ null && (font_library_modal_FontLibraryModal))); +/* harmony default export */ const font_library_modal = (FontLibraryModal); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-family-item.js @@ -26990,32 +32467,31 @@ function font_library_modal_FontLibraryModal({ */ -function font_family_item_FontFamilyItem({ +function FontFamilyItem({ font }) { const { handleSetLibraryFontSelected, toggleModal - } = useContext(FontLibraryContext); + } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); const variantsCount = font?.fontFace?.length || 1; const handleClick = () => { handleSetLibraryFontSelected(font); toggleModal('installed-fonts'); }; const previewStyle = getFamilyPreviewStyle(font); - return createElement(Item, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, { onClick: handleClick - }, createElement(HStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "space-between" - }, createElement(FlexItem, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { style: previewStyle - }, font.name), createElement(FlexItem, { - style: { - color: '#9e9e9e' - } - }, variantsCount, ' ', _n('variant', 'variants', variantsCount)))); + }, font.name), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { + className: "edit-site-global-styles-screen-typography__font-variants-count" + }, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: Number of font variants. */ + (0,external_wp_i18n_namespaceObject._n)('%d variant', '%d variants', variantsCount), variantsCount)))); } -/* harmony default export */ var font_family_item = ((/* unused pure expression or super */ null && (font_family_item_FontFamilyItem))); +/* harmony default export */ const font_family_item = (FontFamilyItem); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-families.js @@ -27040,42 +32516,46 @@ function FontFamilies() { toggleModal, themeFonts, customFonts - } = useContext(FontLibraryContext); - return createElement(Fragment, null, !!modalTabOpen && createElement(FontLibraryModal, { + } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); + const hasFonts = 0 < customFonts.length || 0 < themeFonts.length; + return (0,external_React_.createElement)(external_React_.Fragment, null, !!modalTabOpen && (0,external_React_.createElement)(font_library_modal, { onRequestClose: () => toggleModal(), - initialTabName: modalTabOpen - }), createElement(VStack, { + initialTabId: modalTabOpen + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 3 - }, createElement(HStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "space-between" - }, createElement(Subtitle, { + }, (0,external_React_.createElement)(subtitle, { level: 3 - }, __('Fonts')), createElement(HStack, { + }, (0,external_wp_i18n_namespaceObject.__)('Fonts')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "flex-end" - }, createElement(Tooltip, { - text: __('Manage fonts') - }, createElement(Button, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { + text: (0,external_wp_i18n_namespaceObject.__)('Manage fonts') + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { onClick: () => toggleModal('installed-fonts'), - "aria-label": __('Manage fonts'), - icon: typography, + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Manage fonts'), + icon: library_settings, size: 'small' - })))), createElement(ItemGroup, { + })))), hasFonts ? (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { isBordered: true, isSeparated: true - }, customFonts.map(font => createElement(FontFamilyItem, { + }, customFonts.map(font => (0,external_React_.createElement)(font_family_item, { key: font.slug, font: font - })), themeFonts.map(font => createElement(FontFamilyItem, { + })), themeFonts.map(font => (0,external_React_.createElement)(font_family_item, { key: font.slug, font: font - }))))); + }))) : (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('No fonts installed.'), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + className: "edit-site-global-styles-font-families__add-fonts", + variant: "secondary", + onClick: () => toggleModal('upload-fonts') + }, (0,external_wp_i18n_namespaceObject.__)('Add fonts'))))); } -const FontFamiliesComponent = ({ +/* harmony default export */ const font_families = (({ ...props -}) => createElement(FontLibraryProvider, null, createElement(FontFamilies, { +}) => (0,external_React_.createElement)(context, null, (0,external_React_.createElement)(FontFamilies, { ...props -})); -/* harmony default export */ var font_families = ( false ? 0 : undefined); +}))); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-typography.js @@ -27085,6 +32565,8 @@ const FontFamiliesComponent = ({ + + /** * Internal dependencies */ @@ -27092,16 +32574,17 @@ const FontFamiliesComponent = ({ function ScreenTypography() { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + const fontLibraryEnabled = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).getEditorSettings().fontLibraryEnabled, []); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { title: (0,external_wp_i18n_namespaceObject.__)('Typography'), description: (0,external_wp_i18n_namespaceObject.__)('Manage the typography settings for different elements.') - }), (0,external_wp_element_namespaceObject.createElement)("div", { + }), (0,external_React_.createElement)("div", { className: "edit-site-global-styles-screen-typography" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 6 - }, font_families && !window.__experimentalDisableFontLibrary && (0,external_wp_element_namespaceObject.createElement)(font_families, null), (0,external_wp_element_namespaceObject.createElement)(typogrphy_elements, null)))); + }, fontLibraryEnabled && (0,external_React_.createElement)(font_families, null), (0,external_React_.createElement)(typogrphy_elements, null)))); } -/* harmony default export */ var screen_typography = (ScreenTypography); +/* harmony default export */ const screen_typography = (ScreenTypography); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/typography-panel.js @@ -27140,7 +32623,7 @@ function TypographyPanel({ const [rawSettings] = typography_panel_useGlobalSetting(''); const usedElement = element === 'heading' ? headingLevel : element; const settings = typography_panel_useSettingsForBlockElement(rawSettings, undefined, usedElement); - return (0,external_wp_element_namespaceObject.createElement)(typography_panel_StylesTypographyPanel, { + return (0,external_React_.createElement)(typography_panel_StylesTypographyPanel, { inheritedValue: inheritedStyle, value: style, onChange: setStyle, @@ -27184,7 +32667,7 @@ function TypographyPreview({ const extraStyles = element === 'link' ? { textDecoration: 'underline' } : {}; - return (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)("div", { className: "edit-site-typography-preview", style: { fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif', @@ -27240,18 +32723,18 @@ function ScreenTypographyElement({ element }) { const [headingLevel, setHeadingLevel] = (0,external_wp_element_namespaceObject.useState)('heading'); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { title: screen_typography_element_elements[element].title, description: screen_typography_element_elements[element].description - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { marginX: 4 - }, (0,external_wp_element_namespaceObject.createElement)(TypographyPreview, { + }, (0,external_React_.createElement)(TypographyPreview, { element: element, headingLevel: headingLevel - })), element === 'heading' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + })), element === 'heading' && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { marginX: 4, marginBottom: "1em" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, { label: (0,external_wp_i18n_namespaceObject.__)('Select heading level'), hideLabelFromVision: true, value: headingLevel, @@ -27259,35 +32742,33 @@ function ScreenTypographyElement({ isBlock: true, size: "__unstable-large", __nextHasNoMarginBottom: true - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { - value: "heading" - /* translators: 'All' refers to selecting all heading levels - and applying the same style to h1-h6. */, - label: (0,external_wp_i18n_namespaceObject.__)('All') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { + value: "heading", + label: (0,external_wp_i18n_namespaceObject._x)('All', 'heading levels') + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { value: "h1", label: (0,external_wp_i18n_namespaceObject.__)('H1') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { value: "h2", label: (0,external_wp_i18n_namespaceObject.__)('H2') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { value: "h3", label: (0,external_wp_i18n_namespaceObject.__)('H3') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { value: "h4", label: (0,external_wp_i18n_namespaceObject.__)('H4') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { value: "h5", label: (0,external_wp_i18n_namespaceObject.__)('H5') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { value: "h6", label: (0,external_wp_i18n_namespaceObject.__)('H6') - }))), (0,external_wp_element_namespaceObject.createElement)(TypographyPanel, { + }))), (0,external_React_.createElement)(TypographyPanel, { element: element, headingLevel: headingLevel })); } -/* harmony default export */ var screen_typography_element = (ScreenTypographyElement); +/* harmony default export */ const screen_typography_element = (ScreenTypographyElement); ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/shuffle.js @@ -27295,13 +32776,13 @@ function ScreenTypographyElement({ * WordPress dependencies */ -const shuffle = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { +const shuffle = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/SVG" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M17.192 6.75L15.47 5.03l1.06-1.06 3.537 3.53-3.537 3.53-1.06-1.06 1.723-1.72h-3.19c-.602 0-.993.202-1.28.498-.309.319-.538.792-.695 1.383-.13.488-.222 1.023-.296 1.508-.034.664-.116 1.413-.303 2.117-.193.721-.513 1.467-1.068 2.04-.575.594-1.359.954-2.357.954H4v-1.5h4.003c.601 0 .993-.202 1.28-.498.308-.319.538-.792.695-1.383.149-.557.216-1.093.288-1.662l.039-.31a9.653 9.653 0 0 1 .272-1.653c.193-.722.513-1.467 1.067-2.04.576-.594 1.36-.954 2.358-.954h3.19zM8.004 6.75c.8 0 1.46.23 1.988.628a6.24 6.24 0 0 0-.684 1.396 1.725 1.725 0 0 0-.024-.026c-.287-.296-.679-.498-1.28-.498H4v-1.5h4.003zM12.699 14.726c-.161.459-.38.94-.684 1.396.527.397 1.188.628 1.988.628h3.19l-1.722 1.72 1.06 1.06L20.067 16l-3.537-3.53-1.06 1.06 1.723 1.72h-3.19c-.602 0-.993-.202-1.28-.498a1.96 1.96 0 0 1-.024-.026z" })); -/* harmony default export */ var library_shuffle = (shuffle); +/* harmony default export */ const library_shuffle = (shuffle); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/color-indicator-wrapper.js @@ -27318,12 +32799,12 @@ function ColorIndicatorWrapper({ className, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { className: classnames_default()('edit-site-global-styles__color-indicator-wrapper', className), ...props }); } -/* harmony default export */ var color_indicator_wrapper = (ColorIndicatorWrapper); +/* harmony default export */ const color_indicator_wrapper = (ColorIndicatorWrapper); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/palette.js @@ -27361,34 +32842,34 @@ function Palette({ const paletteButtonText = colors.length > 0 ? (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %d: Number of palette colors. (0,external_wp_i18n_namespaceObject._n)('%d color', '%d colors', colors.length), colors.length) : (0,external_wp_i18n_namespaceObject.__)('Add custom colors'); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 3 - }, (0,external_wp_element_namespaceObject.createElement)(subtitle, { + }, (0,external_React_.createElement)(subtitle, { level: 3 - }, (0,external_wp_i18n_namespaceObject.__)('Palette')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { + }, (0,external_wp_i18n_namespaceObject.__)('Palette')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { isBordered: true, isSeparated: true - }, (0,external_wp_element_namespaceObject.createElement)(NavigationButtonAsItem, { + }, (0,external_React_.createElement)(NavigationButtonAsItem, { path: screenPath, "aria-label": (0,external_wp_i18n_namespaceObject.__)('Color palettes') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { direction: colors.length === 0 ? 'row-reverse' : 'row' - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalZStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalZStack, { isLayered: false, offset: -8 }, colors.slice(0, 5).map(({ color - }, index) => (0,external_wp_element_namespaceObject.createElement)(color_indicator_wrapper, { + }, index) => (0,external_React_.createElement)(color_indicator_wrapper, { key: `${color}-${index}` - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ColorIndicator, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.ColorIndicator, { colorValue: color - })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, paletteButtonText)))), window.__experimentalEnableColorRandomizer && themeColors?.length > 0 && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + })))), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, paletteButtonText)))), window.__experimentalEnableColorRandomizer && themeColors?.length > 0 && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "secondary", icon: library_shuffle, onClick: randomizeThemeColors }, (0,external_wp_i18n_namespaceObject.__)('Randomize colors'))); } -/* harmony default export */ var palette = (Palette); +/* harmony default export */ const palette = (Palette); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-colors.js @@ -27420,21 +32901,21 @@ function ScreenColors() { }); const [rawSettings] = screen_colors_useGlobalSetting(''); const settings = screen_colors_useSettingsForBlockElement(rawSettings); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { title: (0,external_wp_i18n_namespaceObject.__)('Colors'), description: (0,external_wp_i18n_namespaceObject.__)('Manage palettes and the default color of different global elements on the site.') - }), (0,external_wp_element_namespaceObject.createElement)("div", { + }), (0,external_React_.createElement)("div", { className: "edit-site-global-styles-screen-colors" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 10 - }, (0,external_wp_element_namespaceObject.createElement)(palette, null), (0,external_wp_element_namespaceObject.createElement)(screen_colors_StylesColorPanel, { + }, (0,external_React_.createElement)(palette, null), (0,external_React_.createElement)(screen_colors_StylesColorPanel, { inheritedValue: inheritedStyle, value: style, onChange: setStyle, settings: settings })))); } -/* harmony default export */ var screen_colors = (ScreenColors); +/* harmony default export */ const screen_colors = (ScreenColors); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/color-palette-panel.js @@ -27468,10 +32949,10 @@ function ColorPalettePanel({ const [defaultPaletteEnabled] = color_palette_panel_useGlobalSetting('color.defaultPalette', name); const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<'); const popoverProps = isMobileViewport ? mobilePopoverProps : undefined; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { className: "edit-site-global-styles-color-palette-panel", spacing: 10 - }, !!themeColors && !!themeColors.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { + }, !!themeColors && !!themeColors.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { canReset: themeColors !== baseThemeColors, canOnlyChangeValues: true, colors: themeColors, @@ -27479,7 +32960,7 @@ function ColorPalettePanel({ paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme'), paletteLabelHeadingLevel: 3, popoverProps: popoverProps - }), !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { + }), !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { canReset: defaultColors !== baseDefaultColors, canOnlyChangeValues: true, colors: defaultColors, @@ -27487,7 +32968,7 @@ function ColorPalettePanel({ paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default'), paletteLabelHeadingLevel: 3, popoverProps: popoverProps - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { colors: customColors, onChange: setCustomColors, paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'), @@ -27537,10 +33018,10 @@ function GradientPalettePanel({ const duotonePalette = [...(customDuotone || []), ...(themeDuotone || []), ...(defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : [])]; const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<'); const popoverProps = isMobileViewport ? gradients_palette_panel_mobilePopoverProps : undefined; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { className: "edit-site-global-styles-gradient-palette-panel", spacing: 10 - }, !!themeGradients && !!themeGradients.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { + }, !!themeGradients && !!themeGradients.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { canReset: themeGradients !== baseThemeGradients, canOnlyChangeValues: true, gradients: themeGradients, @@ -27548,7 +33029,7 @@ function GradientPalettePanel({ paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme'), paletteLabelHeadingLevel: 3, popoverProps: popoverProps - }), !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { + }), !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { canReset: defaultGradients !== baseDefaultGradients, canOnlyChangeValues: true, gradients: defaultGradients, @@ -27556,7 +33037,7 @@ function GradientPalettePanel({ paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default'), paletteLabelLevel: 3, popoverProps: popoverProps - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { gradients: customGradients, onChange: setCustomGradients, paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'), @@ -27564,11 +33045,11 @@ function GradientPalettePanel({ emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom gradients are empty! Add some gradients to create your own palette.'), slugPrefix: "custom-", popoverProps: popoverProps - }), !!duotonePalette && !!duotonePalette.length && (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)(subtitle, { + }), !!duotonePalette && !!duotonePalette.length && (0,external_React_.createElement)("div", null, (0,external_React_.createElement)(subtitle, { level: 3 - }, (0,external_wp_i18n_namespaceObject.__)('Duotone')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { + }, (0,external_wp_i18n_namespaceObject.__)('Duotone')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { margin: 3 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DuotonePicker, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.DuotonePicker, { duotonePalette: duotonePalette, disableCustomDuotone: true, disableCustomColors: true, @@ -27591,29 +33072,33 @@ function GradientPalettePanel({ + +const { + Tabs: screen_color_palette_Tabs +} = unlock(external_wp_components_namespaceObject.privateApis); function ScreenColorPalette({ name }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { title: (0,external_wp_i18n_namespaceObject.__)('Palette'), 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.') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, { - tabs: [{ - name: 'solid', - title: 'Solid', - value: 'solid' - }, { - name: 'gradient', - title: 'Gradient', - value: 'gradient' - }] - }, tab => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, tab.value === 'solid' && (0,external_wp_element_namespaceObject.createElement)(ColorPalettePanel, { + }), (0,external_React_.createElement)(screen_color_palette_Tabs, null, (0,external_React_.createElement)(screen_color_palette_Tabs.TabList, null, (0,external_React_.createElement)(screen_color_palette_Tabs.Tab, { + tabId: "solid" + }, "Solid"), (0,external_React_.createElement)(screen_color_palette_Tabs.Tab, { + tabId: "gradient" + }, "Gradient")), (0,external_React_.createElement)(screen_color_palette_Tabs.TabPanel, { + tabId: "solid", + focusable: false + }, (0,external_React_.createElement)(ColorPalettePanel, { name: name - }), tab.value === 'gradient' && (0,external_wp_element_namespaceObject.createElement)(GradientPalettePanel, { + })), (0,external_React_.createElement)(screen_color_palette_Tabs.TabPanel, { + tabId: "gradient", + focusable: false + }, (0,external_React_.createElement)(GradientPalettePanel, { name: name })))); } -/* harmony default export */ var screen_color_palette = (ScreenColorPalette); +/* harmony default export */ const screen_color_palette = (ScreenColorPalette); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/dimensions-panel.js @@ -27686,7 +33171,7 @@ function DimensionsPanel() { setSettings(updatedSettings); } }; - return (0,external_wp_element_namespaceObject.createElement)(dimensions_panel_StylesDimensionsPanel, { + return (0,external_React_.createElement)(dimensions_panel_StylesDimensionsPanel, { inheritedValue: inheritedStyleWithLayout, value: styleWithLayout, onChange: onChange, @@ -27719,11 +33204,11 @@ function ScreenLayout() { const [rawSettings] = screen_layout_useGlobalSetting(''); const settings = screen_layout_useSettingsForBlockElement(rawSettings); const hasDimensionsPanel = screen_layout_useHasDimensionsPanel(settings); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { title: (0,external_wp_i18n_namespaceObject.__)('Layout') - }), hasDimensionsPanel && (0,external_wp_element_namespaceObject.createElement)(DimensionsPanel, null)); + }), hasDimensionsPanel && (0,external_React_.createElement)(DimensionsPanel, null)); } -/* harmony default export */ var screen_layout = (ScreenLayout); +/* harmony default export */ const screen_layout = (ScreenLayout); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-style-variations.js @@ -27776,17 +33261,17 @@ function ScreenStyleVariations() { const { __unstableSetEditorMode } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { back: "/", title: (0,external_wp_i18n_namespaceObject.__)('Browse styles'), description: (0,external_wp_i18n_namespaceObject.__)('Choose a variation to change the look of the site.') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Card, { size: "small", isBorderless: true, className: "edit-site-global-styles-screen-style-variations" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_wp_element_namespaceObject.createElement)(StyleVariationsContainer, null)))); + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(StyleVariationsContainer, null)))); } -/* harmony default export */ var screen_style_variations = (ScreenStyleVariations); +/* harmony default export */ const screen_style_variations = (ScreenStyleVariations); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-css.js @@ -27814,21 +33299,21 @@ function ScreenCSS() { const [inheritedStyle, setStyle] = screen_css_useGlobalStyle('', undefined, 'all', { shouldDecodeEncode: false }); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { title: (0,external_wp_i18n_namespaceObject.__)('CSS'), - description: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, description, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { + description: (0,external_React_.createElement)(external_React_.Fragment, null, description, (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { href: "https://wordpress.org/documentation/article/css/", className: "edit-site-global-styles-screen-css-help-link" }, (0,external_wp_i18n_namespaceObject.__)('Learn more about CSS'))) - }), (0,external_wp_element_namespaceObject.createElement)("div", { + }), (0,external_React_.createElement)("div", { className: "edit-site-global-styles-screen-css" - }, (0,external_wp_element_namespaceObject.createElement)(screen_css_StylesAdvancedPanel, { + }, (0,external_React_.createElement)(screen_css_StylesAdvancedPanel, { value: style, onChange: setStyle, inheritedValue: inheritedStyle }))); } -/* harmony default export */ var screen_css = (ScreenCSS); +/* harmony default export */ const screen_css = (ScreenCSS); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/revisions/index.js @@ -27841,7 +33326,6 @@ function ScreenCSS() { - /** * Internal dependencies */ @@ -27851,23 +33335,21 @@ function ScreenCSS() { const { ExperimentalBlockEditorProvider: revisions_ExperimentalBlockEditorProvider, - useGlobalStylesOutputWithConfig + GlobalStylesContext: revisions_GlobalStylesContext, + useGlobalStylesOutputWithConfig: revisions_useGlobalStylesOutputWithConfig } = unlock(external_wp_blockEditor_namespaceObject.privateApis); -function isObjectEmpty(object) { +function revisions_isObjectEmpty(object) { return !object || Object.keys(object).length === 0; } function Revisions({ - onClose, userConfig, blocks }) { const { - baseConfig - } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ - baseConfig: select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles() - }), []); + base: baseConfig + } = (0,external_wp_element_namespaceObject.useContext)(revisions_GlobalStylesContext); const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => { - if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) { + if (!revisions_isObjectEmpty(userConfig) && !revisions_isObjectEmpty(baseConfig)) { return mergeBaseAndUserConfigs(baseConfig, userConfig); } return {}; @@ -27878,96 +33360,97 @@ function Revisions({ ...originalSettings, __unstableIsPreviewMode: true }), [originalSettings]); - const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig); - const editorStyles = !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : settings.styles; - return (0,external_wp_element_namespaceObject.createElement)(editor_canvas_container, { + const [globalStyles] = revisions_useGlobalStylesOutputWithConfig(mergedConfig); + const editorStyles = !revisions_isObjectEmpty(globalStyles) && !revisions_isObjectEmpty(userConfig) ? globalStyles : settings.styles; + return (0,external_React_.createElement)(editor_canvas_container, { title: (0,external_wp_i18n_namespaceObject.__)('Revisions'), - onClose: onClose, closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close revisions'), enableResizing: true - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { className: "edit-site-revisions__iframe", name: "revisions", tabIndex: 0 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { styles: editorStyles - }), (0,external_wp_element_namespaceObject.createElement)("style", null, + }), (0,external_React_.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing. // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context - `.is-root-container { display: flow-root; } body { position: relative; padding: 32px; }`), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Disabled, { + `.is-root-container { display: flow-root; }`), (0,external_React_.createElement)(external_wp_components_namespaceObject.Disabled, { className: "edit-site-revisions__example-preview__content" - }, (0,external_wp_element_namespaceObject.createElement)(revisions_ExperimentalBlockEditorProvider, { + }, (0,external_React_.createElement)(revisions_ExperimentalBlockEditorProvider, { value: renderedBlocksArray, settings: settings - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { + }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { renderAppender: false }))))); } -/* harmony default export */ var components_revisions = (Revisions); +/* harmony default export */ const components_revisions = (Revisions); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-revisions/revisions-buttons.js /** - * WordPress dependencies + * External dependencies */ /** - * Internal dependencies + * WordPress dependencies */ -const { - createPrivateSlotFill: sidebar_fixed_bottom_createPrivateSlotFill -} = unlock(external_wp_components_namespaceObject.privateApis); -const SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME = 'SidebarFixedBottom'; -const { - Slot: SidebarFixedBottomSlot, - Fill: SidebarFixedBottomFill -} = sidebar_fixed_bottom_createPrivateSlotFill(SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME); -function SidebarFixedBottom({ - children -}) { - return (0,external_wp_element_namespaceObject.createElement)(SidebarFixedBottomFill, null, (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-sidebar-fixed-bottom-slot" - }, children)); -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-revisions/revisions-buttons.js -/** - * External dependencies - */ + /** - * WordPress dependencies + * Internal dependencies */ - - - - +const DAY_IN_MILLISECONDS = 60 * 60 * 1000 * 24; +const { + getGlobalStylesChanges +} = unlock(external_wp_blockEditor_namespaceObject.privateApis); +function ChangesSummary({ + revision, + previousRevision +}) { + const changes = getGlobalStylesChanges(revision, previousRevision, { + maxResults: 7 + }); + if (!changes.length) { + return null; + } + return (0,external_React_.createElement)("ul", { + "data-testid": "global-styles-revision-changes", + className: "edit-site-global-styles-screen-revisions__changes" + }, changes.map(change => (0,external_React_.createElement)("li", { + key: change + }, change))); +} /** * Returns a button label for the revision. * - * @param {Object} revision A revision object. + * @param {string|number} id A revision object. + * @param {string} authorDisplayName Author name. + * @param {string} formattedModifiedDate Revision modified date formatted. + * @param {boolean} areStylesEqual Whether the revision matches the current editor styles. * @return {string} Translated label. */ -function getRevisionLabel(revision) { - const authorDisplayName = revision?.author?.name || (0,external_wp_i18n_namespaceObject.__)('User'); - if ('parent' === revision?.id) { +function getRevisionLabel(id, authorDisplayName, formattedModifiedDate, areStylesEqual) { + if ('parent' === id) { return (0,external_wp_i18n_namespaceObject.__)('Reset the styles to the theme defaults'); } - if ('unsaved' === revision?.id) { - return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s author display name */ + if ('unsaved' === id) { + return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: author display name */ (0,external_wp_i18n_namespaceObject.__)('Unsaved changes by %s'), authorDisplayName); } - const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_date_namespaceObject.getSettings)().formats.datetimeAbbreviated, (0,external_wp_date_namespaceObject.getDate)(revision?.modified)); - return revision?.isLatest ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1$s author display name, %2$s: revision creation date */ - (0,external_wp_i18n_namespaceObject.__)('Changes saved by %1$s on %2$s (current)'), authorDisplayName, formattedDate) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1$s author display name, %2$s: revision creation date */ - (0,external_wp_i18n_namespaceObject.__)('Changes saved by %1$s on %2$s'), authorDisplayName, formattedDate); + return areStylesEqual ? (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %1$s: author display name, %2$s: revision creation date. + (0,external_wp_i18n_namespaceObject.__)('Changes saved by %1$s on %2$s. This revision matches current editor styles.'), authorDisplayName, formattedModifiedDate) : (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %1$s: author display name, %2$s: revision creation date. + (0,external_wp_i18n_namespaceObject.__)('Changes saved by %1$s on %2$s'), authorDisplayName, formattedModifiedDate); } /** @@ -27984,12 +33467,31 @@ function getRevisionLabel(revision) { function RevisionsButtons({ userRevisions, selectedRevisionId, - onChange + onChange, + canApplyRevision, + onApplyRevision }) { - const currentTheme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme(), []); - return (0,external_wp_element_namespaceObject.createElement)("ol", { + const { + currentThemeName, + currentUser + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getCurrentTheme, + getCurrentUser + } = select(external_wp_coreData_namespaceObject.store); + const currentTheme = getCurrentTheme(); + return { + currentThemeName: currentTheme?.name?.rendered || currentTheme?.stylesheet, + currentUser: getCurrentUser() + }; + }, []); + const dateNowInMs = (0,external_wp_date_namespaceObject.getDate)().getTime(); + const { + datetimeAbbreviated + } = (0,external_wp_date_namespaceObject.getSettings)().formats; + return (0,external_React_.createElement)("ol", { className: "edit-site-global-styles-screen-revisions__revisions-list", - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Global styles revisions'), + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Global styles revisions list'), role: "group" }, userRevisions.map((revision, index) => { const { @@ -27997,43 +33499,133 @@ function RevisionsButtons({ author, modified } = revision; - const authorDisplayName = author?.name || (0,external_wp_i18n_namespaceObject.__)('User'); - const authorAvatar = author?.avatar_urls?.['48']; - const isUnsaved = 'unsaved' === revision?.id; - const isSelected = selectedRevisionId ? selectedRevisionId === revision?.id : index === 0; - const isReset = 'parent' === revision?.id; - return (0,external_wp_element_namespaceObject.createElement)("li", { + const isUnsaved = 'unsaved' === id; + // Unsaved changes are created by the current user. + const revisionAuthor = isUnsaved ? currentUser : author; + const authorDisplayName = revisionAuthor?.name || (0,external_wp_i18n_namespaceObject.__)('User'); + const authorAvatar = revisionAuthor?.avatar_urls?.['48']; + const isFirstItem = index === 0; + const isSelected = selectedRevisionId ? selectedRevisionId === id : isFirstItem; + const areStylesEqual = !canApplyRevision && isSelected; + const isReset = 'parent' === id; + const modifiedDate = (0,external_wp_date_namespaceObject.getDate)(modified); + const displayDate = modified && dateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS ? (0,external_wp_date_namespaceObject.dateI18n)(datetimeAbbreviated, modifiedDate) : (0,external_wp_date_namespaceObject.humanTimeDiff)(modified); + const revisionLabel = getRevisionLabel(id, authorDisplayName, (0,external_wp_date_namespaceObject.dateI18n)(datetimeAbbreviated, modifiedDate), areStylesEqual); + return (0,external_React_.createElement)("li", { className: classnames_default()('edit-site-global-styles-screen-revisions__revision-item', { 'is-selected': isSelected, + 'is-active': areStylesEqual, 'is-reset': isReset }), - key: id - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + key: id, + "aria-current": isSelected + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { className: "edit-site-global-styles-screen-revisions__revision-button", disabled: isSelected, onClick: () => { onChange(revision); }, - label: getRevisionLabel(revision) - }, isReset ? (0,external_wp_element_namespaceObject.createElement)("span", { + "aria-label": revisionLabel + }, isReset ? (0,external_React_.createElement)("span", { className: "edit-site-global-styles-screen-revisions__description" - }, (0,external_wp_i18n_namespaceObject.__)('Default styles'), (0,external_wp_element_namespaceObject.createElement)("span", { + }, (0,external_wp_i18n_namespaceObject.__)('Default styles'), (0,external_React_.createElement)("span", { className: "edit-site-global-styles-screen-revisions__meta" - }, currentTheme?.name?.rendered || currentTheme?.stylesheet)) : (0,external_wp_element_namespaceObject.createElement)("span", { + }, currentThemeName)) : (0,external_React_.createElement)("span", { className: "edit-site-global-styles-screen-revisions__description" - }, (0,external_wp_element_namespaceObject.createElement)("time", { + }, isUnsaved ? (0,external_React_.createElement)("span", { + className: "edit-site-global-styles-screen-revisions__date" + }, (0,external_wp_i18n_namespaceObject.__)('(Unsaved)')) : (0,external_React_.createElement)("time", { + className: "edit-site-global-styles-screen-revisions__date", dateTime: modified - }, (0,external_wp_date_namespaceObject.humanTimeDiff)(modified)), (0,external_wp_element_namespaceObject.createElement)("span", { + }, displayDate), (0,external_React_.createElement)("span", { className: "edit-site-global-styles-screen-revisions__meta" - }, isUnsaved ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s author display name */ - (0,external_wp_i18n_namespaceObject.__)('Unsaved changes by %s'), authorDisplayName) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s author display name */ - (0,external_wp_i18n_namespaceObject.__)('Changes saved by %s'), authorDisplayName), (0,external_wp_element_namespaceObject.createElement)("img", { - alt: author?.name, + }, (0,external_React_.createElement)("img", { + alt: authorDisplayName, src: authorAvatar - }))))); + }), authorDisplayName), isSelected && (0,external_React_.createElement)(ChangesSummary, { + revision: revision, + previousRevision: index < userRevisions.length ? userRevisions[index + 1] : {} + }))), isSelected && (areStylesEqual ? (0,external_React_.createElement)("p", { + className: "edit-site-global-styles-screen-revisions__applied-text" + }, (0,external_wp_i18n_namespaceObject.__)('These styles are already applied to your site.')) : (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + disabled: areStylesEqual, + size: "compact", + variant: "primary", + className: "edit-site-global-styles-screen-revisions__apply-button", + onClick: onApplyRevision + }, isReset ? (0,external_wp_i18n_namespaceObject.__)('Reset to defaults') : (0,external_wp_i18n_namespaceObject.__)('Apply')))); })); } -/* harmony default export */ var revisions_buttons = (RevisionsButtons); +/* harmony default export */ const revisions_buttons = (RevisionsButtons); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/pagination/index.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + +function Pagination({ + currentPage, + numPages, + changePage, + totalItems, + className, + disabled = false, + buttonVariant = 'tertiary', + label = (0,external_wp_i18n_namespaceObject.__)('Pagination Navigation') +}) { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + expanded: false, + as: "nav", + "aria-label": label, + spacing: 3, + justify: "flex-start", + className: classnames_default()('edit-site-pagination', className) + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { + variant: "muted", + className: "edit-site-pagination__total" + }, + // translators: %s: Total number of patterns. + (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %s: Total number of patterns. + (0,external_wp_i18n_namespaceObject._n)('%s item', '%s items', totalItems), totalItems)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + expanded: false, + spacing: 1 + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: buttonVariant, + onClick: () => changePage(1), + disabled: disabled || currentPage === 1, + "aria-label": (0,external_wp_i18n_namespaceObject.__)('First page') + }, "\xAB"), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: buttonVariant, + onClick: () => changePage(currentPage - 1), + disabled: disabled || currentPage === 1, + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Previous page') + }, "\u2039")), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { + variant: "muted" + }, (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %1$s: Current page number, %2$s: Total number of pages. + (0,external_wp_i18n_namespaceObject._x)('%1$s of %2$s', 'paging'), currentPage, numPages)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + expanded: false, + spacing: 1 + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: buttonVariant, + onClick: () => changePage(currentPage + 1), + disabled: disabled || currentPage === numPages, + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Next page') + }, "\u203A"), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: buttonVariant, + onClick: () => changePage(numPages), + disabled: disabled || currentPage === numPages, + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Last page') + }, "\xBB"))); +} ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-revisions/index.js @@ -28056,46 +33648,51 @@ function RevisionsButtons({ + const { GlobalStylesContext: screen_revisions_GlobalStylesContext, areGlobalStyleConfigsEqual: screen_revisions_areGlobalStyleConfigsEqual } = unlock(external_wp_blockEditor_namespaceObject.privateApis); +const PAGE_SIZE = 10; function ScreenRevisions() { const { - goBack + goTo } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); const { - user: userConfig, + user: currentEditorGlobalStyles, setUserConfig } = (0,external_wp_element_namespaceObject.useContext)(screen_revisions_GlobalStylesContext); const { blocks, editorCanvasContainerView - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - return { - editorCanvasContainerView: unlock(select(store_store)).getEditorCanvasContainerView(), - blocks: select(external_wp_blockEditor_namespaceObject.store).getBlocks() - }; - }, []); + } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ + editorCanvasContainerView: unlock(select(store_store)).getEditorCanvasContainerView(), + blocks: select(external_wp_blockEditor_namespaceObject.store).getBlocks() + }), []); + const [currentPage, setCurrentPage] = (0,external_wp_element_namespaceObject.useState)(1); + const [currentRevisions, setCurrentRevisions] = (0,external_wp_element_namespaceObject.useState)([]); const { revisions, isLoading, - hasUnsavedChanges - } = useGlobalStylesRevisions(); - const [selectedRevisionId, setSelectedRevisionId] = (0,external_wp_element_namespaceObject.useState)(); - const [globalStylesRevision, setGlobalStylesRevision] = (0,external_wp_element_namespaceObject.useState)(userConfig); + hasUnsavedChanges, + revisionsCount + } = useGlobalStylesRevisions({ + query: { + per_page: PAGE_SIZE, + page: currentPage + } + }); + const numPages = Math.ceil(revisionsCount / PAGE_SIZE); + const [currentlySelectedRevision, setCurrentlySelectedRevision] = (0,external_wp_element_namespaceObject.useState)(currentEditorGlobalStyles); const [isLoadingRevisionWithUnsavedChanges, setIsLoadingRevisionWithUnsavedChanges] = (0,external_wp_element_namespaceObject.useState)(false); const { setEditorCanvasContainerView } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (editorCanvasContainerView !== 'global-styles-revisions') { - goBack(); - setEditorCanvasContainerView(editorCanvasContainerView); - } - }, [editorCanvasContainerView]); + const selectedRevisionMatchesEditorStyles = screen_revisions_areGlobalStyleConfigsEqual(currentlySelectedRevision, currentEditorGlobalStyles); const onCloseRevisions = () => { - goBack(); + goTo('/'); // Return to global styles main panel. + const canvasContainerView = editorCanvasContainerView === 'global-styles-revisions:style-book' ? 'style-book' : undefined; + setEditorCanvasContainerView(canvasContainerView); }; const restoreRevision = revision => { setUserConfig(() => ({ @@ -28106,64 +33703,92 @@ function ScreenRevisions() { onCloseRevisions(); }; const selectRevision = revision => { - setGlobalStylesRevision({ + setCurrentlySelectedRevision({ styles: revision?.styles || {}, settings: revision?.settings || {}, id: revision?.id }); - setSelectedRevisionId(revision?.id); }; - const isLoadButtonEnabled = !!globalStylesRevision?.id && !screen_revisions_areGlobalStyleConfigsEqual(globalStylesRevision, userConfig); - const shouldShowRevisions = !isLoading && revisions.length; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(global_styles_header, { - title: (0,external_wp_i18n_namespaceObject.__)('Revisions'), - description: (0,external_wp_i18n_namespaceObject.__)('Revisions are added to the timeline when style changes are saved.') - }), isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, { + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (!editorCanvasContainerView || !editorCanvasContainerView.startsWith('global-styles-revisions')) { + goTo('/'); // Return to global styles main panel. + } + }, [editorCanvasContainerView]); + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (!isLoading && revisions.length) { + setCurrentRevisions(revisions); + } + }, [revisions, isLoading]); + const firstRevision = revisions[0]; + const currentlySelectedRevisionId = currentlySelectedRevision?.id; + const shouldSelectFirstItem = !!firstRevision?.id && !selectedRevisionMatchesEditorStyles && !currentlySelectedRevisionId; + (0,external_wp_element_namespaceObject.useEffect)(() => { + /* + * Ensure that the first item is selected and loaded into the preview pane + * when no revision is selected and the selected styles don't match the current editor styles. + * This is required in case editor styles are changed outside the revisions panel, + * e.g., via the reset styles function of useGlobalStylesReset(). + * See: https://github.com/WordPress/gutenberg/issues/55866 + */ + if (shouldSelectFirstItem) { + setCurrentlySelectedRevision({ + styles: firstRevision?.styles || {}, + settings: firstRevision?.settings || {}, + id: firstRevision?.id + }); + } + }, [shouldSelectFirstItem, firstRevision]); + + // Only display load button if there is a revision to load, + // and it is different from the current editor styles. + const isLoadButtonEnabled = !!currentlySelectedRevisionId && currentlySelectedRevisionId !== 'unsaved' && !selectedRevisionMatchesEditorStyles; + const hasRevisions = !!currentRevisions.length; + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { + title: revisionsCount && + // translators: %s: number of revisions. + (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Revisions (%s)'), revisionsCount), + description: (0,external_wp_i18n_namespaceObject.__)('Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you\'re ready, use the Save button to save your changes.'), + onBack: onCloseRevisions + }), !hasRevisions && (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, { className: "edit-site-global-styles-screen-revisions__loading" - }), shouldShowRevisions ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(components_revisions, { + }), hasRevisions && (editorCanvasContainerView === 'global-styles-revisions:style-book' ? (0,external_React_.createElement)(style_book, { + userConfig: currentlySelectedRevision, + isSelected: () => {}, + onClose: () => { + setEditorCanvasContainerView('global-styles-revisions'); + } + }) : (0,external_React_.createElement)(components_revisions, { blocks: blocks, - userConfig: globalStylesRevision, - onClose: onCloseRevisions - }), (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-global-styles-screen-revisions" - }, (0,external_wp_element_namespaceObject.createElement)(revisions_buttons, { + userConfig: currentlySelectedRevision, + closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close revisions') + })), (0,external_React_.createElement)(revisions_buttons, { onChange: selectRevision, - selectedRevisionId: selectedRevisionId, - userRevisions: revisions - }), isLoadButtonEnabled && (0,external_wp_element_namespaceObject.createElement)(SidebarFixedBottom, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "primary", - className: "edit-site-global-styles-screen-revisions__button", - disabled: !globalStylesRevision?.id || globalStylesRevision?.id === 'unsaved', - onClick: () => { - if (hasUnsavedChanges) { - setIsLoadingRevisionWithUnsavedChanges(true); - } else { - restoreRevision(globalStylesRevision); - } - } - }, globalStylesRevision?.id === 'parent' ? (0,external_wp_i18n_namespaceObject.__)('Reset to defaults') : (0,external_wp_i18n_namespaceObject.__)('Apply')))), isLoadingRevisionWithUnsavedChanges && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { + selectedRevisionId: currentlySelectedRevisionId, + userRevisions: currentRevisions, + canApplyRevision: isLoadButtonEnabled, + onApplyRevision: () => hasUnsavedChanges ? setIsLoadingRevisionWithUnsavedChanges(true) : restoreRevision(currentlySelectedRevision) + }), numPages > 1 && (0,external_React_.createElement)("div", { + className: "edit-site-global-styles-screen-revisions__footer" + }, (0,external_React_.createElement)(Pagination, { + className: "edit-site-global-styles-screen-revisions__pagination", + currentPage: currentPage, + numPages: numPages, + changePage: setCurrentPage, + totalItems: revisionsCount, + disabled: isLoading, + label: (0,external_wp_i18n_namespaceObject.__)('Global Styles pagination navigation') + })), isLoadingRevisionWithUnsavedChanges && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { isOpen: isLoadingRevisionWithUnsavedChanges, confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Apply'), - onConfirm: () => restoreRevision(globalStylesRevision), + onConfirm: () => restoreRevision(currentlySelectedRevision), onCancel: () => setIsLoadingRevisionWithUnsavedChanges(false) - }, (0,external_wp_i18n_namespaceObject.__)('Any unsaved changes will be lost when you apply this revision.'))) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { - marginX: 4, - "data-testid": "global-styles-no-revisions" - }, - // Adding an existing translation here in case these changes are shipped to WordPress 6.3. - // Later we could update to something better, e.g., "There are currently no style revisions.". - (0,external_wp_i18n_namespaceObject.__)('No results found.'))); + }, (0,external_wp_i18n_namespaceObject.__)('Any unsaved changes will be lost when you apply this revision.'))); } -/* harmony default export */ var screen_revisions = (ScreenRevisions); +/* harmony default export */ const screen_revisions = (ScreenRevisions); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/ui.js /** - * External dependencies - */ - - -/** * WordPress dependencies */ @@ -28195,17 +33820,20 @@ function ScreenRevisions() { const ui_SLOT_FILL_NAME = 'GlobalStylesMenu'; const { + useGlobalStylesReset: ui_useGlobalStylesReset +} = unlock(external_wp_blockEditor_namespaceObject.privateApis); +const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } = (0,external_wp_components_namespaceObject.createSlotFill)(ui_SLOT_FILL_NAME); function GlobalStylesActionMenu() { + const [canReset, onReset] = ui_useGlobalStylesReset(); const { toggle } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); const { canEditCSS } = (0,external_wp_data_namespaceObject.useSelect)(select => { - var _globalStyles$_links$; const { getEntityRecord, __experimentalGetCurrentGlobalStylesId @@ -28213,95 +33841,44 @@ function GlobalStylesActionMenu() { const globalStylesId = __experimentalGetCurrentGlobalStylesId(); const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; return { - canEditCSS: (_globalStyles$_links$ = !!globalStyles?._links?.['wp:action-edit-css']) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : false + canEditCSS: !!globalStyles?._links?.['wp:action-edit-css'] }; }, []); const { + setEditorCanvasContainerView + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const { goTo } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); - const loadCustomCSS = () => goTo('/css'); - return (0,external_wp_element_namespaceObject.createElement)(GlobalStylesMenuFill, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + const loadCustomCSS = () => { + setEditorCanvasContainerView('global-styles-css'); + goTo('/css'); + }; + return (0,external_React_.createElement)(GlobalStylesMenuFill, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { icon: more_vertical, label: (0,external_wp_i18n_namespaceObject.__)('More') }, ({ onClose - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, canEditCSS && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, canEditCSS && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: loadCustomCSS - }, (0,external_wp_i18n_namespaceObject.__)('Additional CSS')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Additional CSS')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { toggle('core/edit-site', 'welcomeGuideStyles'); onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'))))); -} -function RevisionsCountBadge({ - className, - children -}) { - return (0,external_wp_element_namespaceObject.createElement)("span", { - className: classnames_default()(className, 'edit-site-global-styles-sidebar__revisions-count-badge') - }, children); -} -function GlobalStylesRevisionsMenu() { - const { - setIsListViewOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const { - revisionsCount - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - var _globalStyles$_links$2; - const { - getEntityRecord, - __experimentalGetCurrentGlobalStylesId - } = select(external_wp_coreData_namespaceObject.store); - const globalStylesId = __experimentalGetCurrentGlobalStylesId(); - const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; - return { - revisionsCount: (_globalStyles$_links$2 = globalStyles?._links?.['version-history']?.[0]?.count) !== null && _globalStyles$_links$2 !== void 0 ? _globalStyles$_links$2 : 0 - }; - }, []); - const { - useGlobalStylesReset - } = unlock(external_wp_blockEditor_namespaceObject.privateApis); - const [canReset, onReset] = useGlobalStylesReset(); - const { - goTo - } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); - const { - setEditorCanvasContainerView - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const loadRevisions = () => { - setIsListViewOpened(false); - goTo('/revisions'); - setEditorCanvasContainerView('global-styles-revisions'); - }; - const hasRevisions = revisionsCount > 0; - return (0,external_wp_element_namespaceObject.createElement)(GlobalStylesMenuFill, null, canReset || hasRevisions ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { - icon: library_backup, - label: (0,external_wp_i18n_namespaceObject.__)('Revisions') - }, ({ - onClose - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, hasRevisions && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: loadRevisions, - icon: (0,external_wp_element_namespaceObject.createElement)(RevisionsCountBadge, null, revisionsCount) - }, (0,external_wp_i18n_namespaceObject.__)('Revision history')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { onReset(); onClose(); }, disabled: !canReset - }, (0,external_wp_i18n_namespaceObject.__)('Reset to defaults')))) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - label: (0,external_wp_i18n_namespaceObject.__)('Revisions'), - icon: library_backup, - disabled: true, - __experimentalIsFocusable: true - })); + }, (0,external_wp_i18n_namespaceObject.__)('Reset styles')))))); } function GlobalStylesNavigationScreen({ className, ...props }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { className: ['edit-site-global-styles-sidebar__navigator-screen', className].filter(Boolean).join(' '), ...props }); @@ -28311,10 +33888,10 @@ function BlockStylesNavigationScreens({ blockStyles, blockName }) { - return blockStyles.map((style, index) => (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + return blockStyles.map((style, index) => (0,external_React_.createElement)(GlobalStylesNavigationScreen, { key: index, path: parentMenu + '/variations/' + style.name - }, (0,external_wp_element_namespaceObject.createElement)(screen_block, { + }, (0,external_React_.createElement)(screen_block, { name: blockName, variation: style.name }))); @@ -28329,11 +33906,11 @@ function ContextScreens({ } = select(external_wp_blocks_namespaceObject.store); return getBlockStyles(name); }, [name]); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: parentMenu + '/colors/palette' - }, (0,external_wp_element_namespaceObject.createElement)(screen_color_palette, { + }, (0,external_React_.createElement)(screen_color_palette, { name: name - })), !!blockStyleVariations?.length && (0,external_wp_element_namespaceObject.createElement)(BlockStylesNavigationScreens, { + })), !!blockStyleVariations?.length && (0,external_React_.createElement)(BlockStylesNavigationScreens, { parentMenu: parentMenu, blockStyles: blockStyleVariations, blockName: name @@ -28344,7 +33921,7 @@ function GlobalStylesStyleBook() { const { path } = navigator.location; - return (0,external_wp_element_namespaceObject.createElement)(style_book, { + return (0,external_React_.createElement)(style_book, { isSelected: blockName => // Match '/blocks/core%2Fbutton' and // '/blocks/core%2Fbutton/typography', but not @@ -28398,84 +33975,104 @@ function GlobalStylesEditorCanvasContainerLink() { location } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); const editorCanvasContainerView = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getEditorCanvasContainerView(), []); + const path = location?.path; + const isRevisionsOpen = path === '/revisions'; // If the user switches the editor canvas container view, redirect // to the appropriate screen. This effectively allows deep linking to the // desired screens from outside the global styles navigation provider. (0,external_wp_element_namespaceObject.useEffect)(() => { - if (editorCanvasContainerView === 'global-styles-revisions') { - // Switching to the revisions container view should - // redirect to the revisions screen. - goTo('/revisions'); - } else if (!!editorCanvasContainerView && location?.path === '/revisions') { - // Switching to any container other than revisions should - // redirect from the revisions screen to the root global styles screen. - goTo('/'); - } else if (editorCanvasContainerView === 'global-styles-css') { - goTo('/css'); + switch (editorCanvasContainerView) { + case 'global-styles-revisions': + case 'global-styles-revisions:style-book': + goTo('/revisions'); + break; + case 'global-styles-css': + goTo('/css'); + break; + case 'style-book': + /* + * The stand-alone style book is open + * and the revisions panel is open, + * close the revisions panel. + * Otherwise keep the style book open while + * browsing global styles panel. + */ + if (isRevisionsOpen) { + goTo('/'); + } + break; + default: + /* + * Example: the user has navigated to "Browse styles" or elsewhere + * and changes the editorCanvasContainerView, e.g., closes the style book. + * The panel should not be affected. + * Exclude revisions panel from this behavior, + * as it should close when the editorCanvasContainerView doesn't correspond. + */ + if (path !== '/' && !isRevisionsOpen) { + return; + } + goTo('/'); + break; } - - // location?.path is not a dependency because we don't want to track it. - // Doing so will cause an infinite loop. We could abstract logic to avoid - // having to disable the check later. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [editorCanvasContainerView, goTo]); + }, [editorCanvasContainerView, isRevisionsOpen, goTo]); } function GlobalStylesUI() { const blocks = (0,external_wp_blocks_namespaceObject.getBlockTypes)(); const editorCanvasContainerView = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getEditorCanvasContainerView(), []); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { className: "edit-site-global-styles-sidebar__navigator-provider", initialPath: "/" - }, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/" - }, (0,external_wp_element_namespaceObject.createElement)(screen_root, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(screen_root, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/variations" - }, (0,external_wp_element_namespaceObject.createElement)(screen_style_variations, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(screen_style_variations, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/blocks" - }, (0,external_wp_element_namespaceObject.createElement)(screen_block_list, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(screen_block_list, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/typography" - }, (0,external_wp_element_namespaceObject.createElement)(screen_typography, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(screen_typography, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/typography/text" - }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, { + }, (0,external_React_.createElement)(screen_typography_element, { element: "text" - })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/typography/link" - }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, { + }, (0,external_React_.createElement)(screen_typography_element, { element: "link" - })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/typography/heading" - }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, { + }, (0,external_React_.createElement)(screen_typography_element, { element: "heading" - })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/typography/caption" - }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, { + }, (0,external_React_.createElement)(screen_typography_element, { element: "caption" - })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/typography/button" - }, (0,external_wp_element_namespaceObject.createElement)(screen_typography_element, { + }, (0,external_React_.createElement)(screen_typography_element, { element: "button" - })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/colors" - }, (0,external_wp_element_namespaceObject.createElement)(screen_colors, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(screen_colors, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/layout" - }, (0,external_wp_element_namespaceObject.createElement)(screen_layout, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(screen_layout, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: "/css" - }, (0,external_wp_element_namespaceObject.createElement)(screen_css, null)), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(screen_css, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { path: '/revisions' - }, (0,external_wp_element_namespaceObject.createElement)(screen_revisions, null)), blocks.map(block => (0,external_wp_element_namespaceObject.createElement)(GlobalStylesNavigationScreen, { + }, (0,external_React_.createElement)(screen_revisions, null)), blocks.map(block => (0,external_React_.createElement)(GlobalStylesNavigationScreen, { key: 'menu-block-' + block.name, path: '/blocks/' + encodeURIComponent(block.name) - }, (0,external_wp_element_namespaceObject.createElement)(screen_block, { + }, (0,external_React_.createElement)(screen_block, { name: block.name - }))), (0,external_wp_element_namespaceObject.createElement)(ContextScreens, null), blocks.map(block => (0,external_wp_element_namespaceObject.createElement)(ContextScreens, { + }))), (0,external_React_.createElement)(ContextScreens, null), blocks.map(block => (0,external_React_.createElement)(ContextScreens, { key: 'screens-block-' + block.name, name: block.name, parentMenu: '/blocks/' + encodeURIComponent(block.name) - })), 'style-book' === editorCanvasContainerView && (0,external_wp_element_namespaceObject.createElement)(GlobalStylesStyleBook, null), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesRevisionsMenu, null), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesActionMenu, null), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesBlockLink, null), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesEditorCanvasContainerLink, null)); + })), 'style-book' === editorCanvasContainerView && (0,external_React_.createElement)(GlobalStylesStyleBook, null), (0,external_React_.createElement)(GlobalStylesActionMenu, null), (0,external_React_.createElement)(GlobalStylesBlockLink, null), (0,external_React_.createElement)(GlobalStylesEditorCanvasContainerLink, null)); } -/* harmony default export */ var ui = (GlobalStylesUI); +/* harmony default export */ const ui = (GlobalStylesUI); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/index.js @@ -28493,6 +34090,7 @@ function GlobalStylesUI() { + /** * Internal dependencies */ @@ -28501,11 +34099,15 @@ function GlobalStylesUI() { + function GlobalStylesSidebar() { const { shouldClearCanvasContainerView, isStyleBookOpened, - showListViewByDefault + showListViewByDefault, + hasRevisions, + isRevisionsOpened, + isRevisionsStyleBookOpened } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { getActiveComplementaryArea @@ -28514,13 +34116,23 @@ function GlobalStylesSidebar() { getEditorCanvasContainerView, getCanvasMode } = unlock(select(store_store)); + const canvasContainerView = getEditorCanvasContainerView(); const _isVisualEditorMode = 'visual' === select(store_store).getEditorMode(); const _isEditCanvasMode = 'edit' === getCanvasMode(); - const _showListViewByDefault = select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showListViewByDefault'); + const _showListViewByDefault = select(external_wp_preferences_namespaceObject.store).get('core', 'showListViewByDefault'); + const { + getEntityRecord, + __experimentalGetCurrentGlobalStylesId + } = select(external_wp_coreData_namespaceObject.store); + const globalStylesId = __experimentalGetCurrentGlobalStylesId(); + const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; return { - isStyleBookOpened: 'style-book' === getEditorCanvasContainerView(), + isStyleBookOpened: 'style-book' === canvasContainerView, shouldClearCanvasContainerView: 'edit-site/global-styles' !== getActiveComplementaryArea('core/edit-site') || !_isVisualEditorMode || !_isEditCanvasMode, - showListViewByDefault: _showListViewByDefault + showListViewByDefault: _showListViewByDefault, + hasRevisions: !!globalStyles?._links?.['version-history']?.[0]?.count, + isRevisionsStyleBookOpened: 'global-styles-revisions:style-book' === canvasContainerView, + isRevisionsOpened: 'global-styles-revisions' === canvasContainerView }; }, []); const { @@ -28533,33 +34145,70 @@ function GlobalStylesSidebar() { }, [shouldClearCanvasContainerView]); const { setIsListViewOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - return (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, { + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); + const { + goTo + } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); + const toggleRevisions = () => { + setIsListViewOpened(false); + if (isRevisionsStyleBookOpened) { + goTo('/'); + setEditorCanvasContainerView('style-book'); + return; + } + if (isRevisionsOpened) { + goTo('/'); + setEditorCanvasContainerView(undefined); + return; + } + goTo('/revisions'); + if (isStyleBookOpened) { + setEditorCanvasContainerView('global-styles-revisions:style-book'); + } else { + setEditorCanvasContainerView('global-styles-revisions'); + } + }; + const toggleStyleBook = () => { + if (isRevisionsOpened) { + setEditorCanvasContainerView('global-styles-revisions:style-book'); + return; + } + if (isRevisionsStyleBookOpened) { + setEditorCanvasContainerView('global-styles-revisions'); + return; + } + setIsListViewOpened(isStyleBookOpened && showListViewByDefault); + setEditorCanvasContainerView(isStyleBookOpened ? undefined : 'style-book'); + }; + return (0,external_React_.createElement)(DefaultSidebar, { className: "edit-site-global-styles-sidebar", identifier: "edit-site/global-styles", title: (0,external_wp_i18n_namespaceObject.__)('Styles'), icon: library_styles, closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Styles'), panelClassName: "edit-site-global-styles-sidebar__panel", - header: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { + header: (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { className: "edit-site-global-styles-sidebar__header", role: "menubar", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Styles actions') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, { style: { minWidth: 'min-content' } - }, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Styles'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_React_.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Styles'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { icon: library_seen, label: (0,external_wp_i18n_namespaceObject.__)('Style Book'), - isPressed: isStyleBookOpened, + isPressed: isStyleBookOpened || isRevisionsStyleBookOpened, disabled: shouldClearCanvasContainerView, - onClick: () => { - setIsListViewOpened(isStyleBookOpened && showListViewByDefault); - setEditorCanvasContainerView(isStyleBookOpened ? undefined : 'style-book'); - } - })), (0,external_wp_element_namespaceObject.createElement)(GlobalStylesMenuSlot, null)) - }, (0,external_wp_element_namespaceObject.createElement)(ui, null)); + onClick: toggleStyleBook + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + label: (0,external_wp_i18n_namespaceObject.__)('Revisions'), + icon: library_backup, + onClick: toggleRevisions, + disabled: !hasRevisions, + isPressed: isRevisionsOpened || isRevisionsStyleBookOpened + })), (0,external_React_.createElement)(GlobalStylesMenuSlot, null)) + }, (0,external_React_.createElement)(ui, null)); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/constants.js @@ -28569,11 +34218,6 @@ const SIDEBAR_BLOCK = 'edit-site/block-inspector'; ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/settings-header/index.js /** - * External dependencies - */ - - -/** * WordPress dependencies */ @@ -28581,72 +34225,32 @@ const SIDEBAR_BLOCK = 'edit-site/block-inspector'; + /** * Internal dependencies */ - - -const SettingsHeader = ({ - sidebarName -}) => { - const { - hasPageContentFocus, - entityType - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getEditedPostType, - hasPageContentFocus: _hasPageContentFocus - } = select(store_store); - return { - hasPageContentFocus: _hasPageContentFocus(), - entityType: getEditedPostType() - }; - }); - const entityLabel = POST_TYPE_LABELS[entityType] || POST_TYPE_LABELS[TEMPLATE_POST_TYPE]; - const { - enableComplementaryArea - } = (0,external_wp_data_namespaceObject.useDispatch)(store); - const openTemplateSettings = () => enableComplementaryArea(constants_STORE_NAME, SIDEBAR_TEMPLATE); - const openBlockSettings = () => enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK); - let templateAriaLabel; - if (hasPageContentFocus) { - templateAriaLabel = sidebarName === SIDEBAR_TEMPLATE ? - // translators: ARIA label for the Template sidebar tab, selected. - (0,external_wp_i18n_namespaceObject.__)('Page (selected)') : - // translators: ARIA label for the Template Settings Sidebar tab, not selected. - (0,external_wp_i18n_namespaceObject.__)('Page'); - } else { - templateAriaLabel = sidebarName === SIDEBAR_TEMPLATE ? - // translators: ARIA label for the Template sidebar tab, selected. - (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('%s (selected)'), entityLabel) : - // translators: ARIA label for the Template Settings Sidebar tab, not selected. - entityLabel; - } - - /* Use a list so screen readers will announce how many tabs there are. */ - 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, { - onClick: openTemplateSettings, - className: classnames_default()('edit-site-sidebar-edit-mode__panel-tab', { - 'is-active': sidebarName === SIDEBAR_TEMPLATE - }), - "aria-label": templateAriaLabel, - "data-label": hasPageContentFocus ? (0,external_wp_i18n_namespaceObject.__)('Page') : entityLabel - }, hasPageContentFocus ? (0,external_wp_i18n_namespaceObject.__)('Page') : entityLabel)), (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - onClick: openBlockSettings, - className: classnames_default()('edit-site-sidebar-edit-mode__panel-tab', { - 'is-active': sidebarName === SIDEBAR_BLOCK - }), - "aria-label": sidebarName === SIDEBAR_BLOCK ? - // translators: ARIA label for the Block Settings Sidebar tab, selected. - (0,external_wp_i18n_namespaceObject.__)('Block (selected)') : - // translators: ARIA label for the Block Settings Sidebar tab, not selected. - (0,external_wp_i18n_namespaceObject.__)('Block'), - "data-label": (0,external_wp_i18n_namespaceObject.__)('Block') - }, (0,external_wp_i18n_namespaceObject.__)('Block')))); +const { + Tabs: settings_header_Tabs +} = unlock(external_wp_components_namespaceObject.privateApis); +const SettingsHeader = (_, ref) => { + const postTypeLabel = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).getPostTypeLabel(), []); + return (0,external_React_.createElement)(settings_header_Tabs.TabList, { + ref: ref + }, (0,external_React_.createElement)(settings_header_Tabs.Tab, { + tabId: SIDEBAR_TEMPLATE + // Used for focus management in the SettingsSidebar component. + , + "data-tab-id": SIDEBAR_TEMPLATE + }, postTypeLabel), (0,external_React_.createElement)(settings_header_Tabs.Tab, { + tabId: SIDEBAR_BLOCK + // Used for focus management in the SettingsSidebar component. + , + "data-tab-id": SIDEBAR_BLOCK + }, (0,external_wp_i18n_namespaceObject.__)('Block'))); }; -/* harmony default export */ var settings_header = (SettingsHeader); +/* harmony default export */ const settings_header = ((0,external_wp_element_namespaceObject.forwardRef)(SettingsHeader)); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/sidebar-card/index.js @@ -28667,18 +34271,18 @@ function SidebarCard({ actions, children }) { - return (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)("div", { className: classnames_default()('edit-site-sidebar-card', className) - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { className: "edit-site-sidebar-card__icon", icon: icon - }), (0,external_wp_element_namespaceObject.createElement)("div", { + }), (0,external_React_.createElement)("div", { className: "edit-site-sidebar-card__content" - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-sidebar-card__header" - }, (0,external_wp_element_namespaceObject.createElement)("h2", { + }, (0,external_React_.createElement)("h2", { className: "edit-site-sidebar-card__title" - }, title), actions), (0,external_wp_element_namespaceObject.createElement)("div", { + }, title), actions), (0,external_React_.createElement)("div", { className: "edit-site-sidebar-card__description" }, description), children)); } @@ -28704,7 +34308,7 @@ function PageContent() { const clientIds = (0,external_wp_element_namespaceObject.useMemo)(() => clientIdsTree.map(({ clientId }) => clientId), [clientIdsTree]); - return (0,external_wp_element_namespaceObject.createElement)(BlockQuickNavigation, { + return (0,external_React_.createElement)(BlockQuickNavigation, { clientIds: clientIds }); } @@ -28723,32 +34327,37 @@ function PageContent() { + /** * Internal dependencies */ + +const { + PostPanelRow +} = unlock(external_wp_editor_namespaceObject.privateApis); const STATUS_OPTIONS = [{ - label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Draft'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Draft'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { variant: "muted" }, (0,external_wp_i18n_namespaceObject.__)('Not ready to publish.'))), value: 'draft' }, { - label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Pending'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Pending'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { variant: "muted" }, (0,external_wp_i18n_namespaceObject.__)('Waiting for review before publishing.'))), value: 'pending' }, { - label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Private'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Private'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { variant: "muted" }, (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.'))), value: 'private' }, { - label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Scheduled'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Scheduled'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { variant: "muted" }, (0,external_wp_i18n_namespaceObject.__)('Publish automatically on a chosen date.'))), value: 'future' }, { - label: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Published'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Published'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { variant: "muted" }, (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.'))), value: 'publish' @@ -28825,57 +34434,55 @@ function PageStatus({ password: newPassword }); }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - className: "edit-site-summary-field" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - className: "edit-site-summary-field__label" - }, (0,external_wp_i18n_namespaceObject.__)('Status')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { + return (0,external_React_.createElement)(PostPanelRow, { + label: (0,external_wp_i18n_namespaceObject.__)('Status') + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Dropdown, { contentClassName: "edit-site-change-status__content", popoverProps: popoverProps, focusOnMount: true, ref: setPopoverAnchor, renderToggle: ({ onToggle - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { className: "edit-site-summary-field__trigger", variant: "tertiary", onClick: onToggle - }, (0,external_wp_element_namespaceObject.createElement)(StatusLabel, { + }, (0,external_React_.createElement)(StatusLabel, { status: password ? 'protected' : status })), renderContent: ({ onClose - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, { + }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, { title: (0,external_wp_i18n_namespaceObject.__)('Status'), onClose: onClose - }), (0,external_wp_element_namespaceObject.createElement)("form", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + }), (0,external_React_.createElement)("form", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: 5 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.RadioControl, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.RadioControl, { className: "edit-site-change-status__options", hideLabelFromVision: true, label: (0,external_wp_i18n_namespaceObject.__)('Status'), options: STATUS_OPTIONS, onChange: handleStatus, selected: status - }), status !== 'private' && (0,external_wp_element_namespaceObject.createElement)("fieldset", { + }), status !== 'private' && (0,external_React_.createElement)("fieldset", { className: "edit-site-change-status__password-fieldset" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "legend", className: "edit-site-change-status__password-legend", size: "11", lineHeight: 1.4, weight: 500, upperCase: true - }, (0,external_wp_i18n_namespaceObject.__)('Password')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { + }, (0,external_wp_i18n_namespaceObject.__)('Password')), (0,external_React_.createElement)(external_wp_components_namespaceObject.ToggleControl, { label: (0,external_wp_i18n_namespaceObject.__)('Hide this page behind a password'), checked: showPassword, onChange: handleTogglePassword - }), showPassword && (0,external_wp_element_namespaceObject.createElement)("div", { + }), showPassword && (0,external_React_.createElement)("div", { className: "edit-site-change-status__password-input" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { as: "label", htmlFor: `edit-site-change-status__password-input-${instanceId}` - }, (0,external_wp_i18n_namespaceObject.__)('Create password')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { + }, (0,external_wp_i18n_namespaceObject.__)('Create password')), (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { onChange: value => saveStatus({ password: value }), @@ -28887,280 +34494,7 @@ function PageStatus({ })); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/publish-date.js - -/** - * WordPress dependencies - */ - - - - - - - - -function ChangeStatus({ - postType, - postId, - status, - date -}) { - const { - editEntityRecord - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); - const { - createErrorNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null); - // Memoize popoverProps to avoid returning a new object every time. - const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({ - // Anchor the popover to the middle of the entire row so that it doesn't - // move around when the label changes. - anchor: popoverAnchor, - 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Change publish date'), - placement: 'bottom-end' - }), [popoverAnchor]); - const saveDate = async newDate => { - try { - let newStatus = status; - if (status === 'future' && new Date(newDate) < new Date()) { - newStatus = 'publish'; - } else if (status === 'publish' && new Date(newDate) > new Date()) { - newStatus = 'future'; - } - await editEntityRecord('postType', postType, postId, { - status: newStatus, - date: newDate - }); - } catch (error) { - const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the status'); - createErrorNotice(errorMessage, { - type: 'snackbar' - }); - } - }; - const relateToNow = date ? (0,external_wp_date_namespaceObject.humanTimeDiff)(date) : (0,external_wp_i18n_namespaceObject.__)('Immediately'); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - className: "edit-site-summary-field" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - className: "edit-site-summary-field__label" - }, (0,external_wp_i18n_namespaceObject.__)('Publish')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, { - contentClassName: "edit-site-change-status__content", - popoverProps: popoverProps, - focusOnMount: true, - ref: setPopoverAnchor, - renderToggle: ({ - onToggle - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - className: "edit-site-summary-field__trigger", - variant: "tertiary", - onClick: onToggle - }, relateToNow), - renderContent: ({ - onClose - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalPublishDateTimePicker, { - currentDate: date, - is12Hour: true, - onClose: onClose, - onChange: saveDate - }) - })); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/hooks.js -/** - * WordPress dependencies - */ - - - - -/** - * Internal dependencies - */ - - -function useEditedPostContext() { - return (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostContext(), []); -} -function useIsPostsPage() { - const { - postId - } = useEditedPostContext(); - return (0,external_wp_data_namespaceObject.useSelect)(select => +postId === select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', 'site')?.page_for_posts, [postId]); -} -function useTemplates() { - return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_POST_TYPE, { - per_page: -1, - post_type: 'page' - }), []); -} -function useAvailableTemplates() { - const currentTemplateSlug = useCurrentTemplateSlug(); - const isPostsPage = useIsPostsPage(); - const templates = useTemplates(); - return (0,external_wp_element_namespaceObject.useMemo)(() => - // The posts page template cannot be changed. - !isPostsPage && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates. - ), [templates, currentTemplateSlug, isPostsPage]); -} -function useCurrentTemplateSlug() { - const { - postType, - postId - } = useEditedPostContext(); - const templates = useTemplates(); - const entityTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => { - const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId); - return post?.template; - }, [postType, postId]); - if (!entityTemplate) { - return; - } - // If a page has a `template` set and is not included in the list - // of the theme's templates, do not return it, in order to resolve - // to the current theme's default template. - return templates?.find(template => template.slug === entityTemplate)?.slug; -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js - -/** - * WordPress dependencies - */ - - - - - - - - - - -/** - * Internal dependencies - */ - - -function SwapTemplateButton({ - onClick -}) { - const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false); - const availableTemplates = useAvailableTemplates(); - const onClose = (0,external_wp_element_namespaceObject.useCallback)(() => { - setShowModal(false); - }, []); - const { - postType, - postId - } = useEditedPostContext(); - const entitiy = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', postType, postId); - const { - setPage - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - if (!availableTemplates?.length) { - return null; - } - const onTemplateSelect = async template => { - entitiy.edit({ - template: template.name - }, { - undoIgnore: true - }); - await setPage({ - context: { - postType, - postId - } - }); - onClose(); // Close the template suggestions modal first. - onClick(); - }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: () => setShowModal(true) - }, (0,external_wp_i18n_namespaceObject.__)('Swap template')), showModal && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { - title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'), - onRequestClose: onClose, - overlayClassName: "edit-site-swap-template-modal", - isFullScreen: true - }, (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-page-panels__swap-template__modal-content" - }, (0,external_wp_element_namespaceObject.createElement)(TemplatesList, { - onSelect: onTemplateSelect - })))); -} -function TemplatesList({ - onSelect -}) { - const availableTemplates = useAvailableTemplates(); - const templatesAsPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => availableTemplates.map(template => ({ - name: template.slug, - blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content.raw), - title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered), - id: template.id - })), [availableTemplates]); - const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(templatesAsPatterns); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, { - label: (0,external_wp_i18n_namespaceObject.__)('Templates'), - blockPatterns: templatesAsPatterns, - shownPatterns: shownTemplates, - onClickPattern: onSelect - }); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js - -/** - * WordPress dependencies - */ - - - - - -/** - * Internal dependencies - */ - - -function ResetDefaultTemplate({ - onClick -}) { - const currentTemplateSlug = useCurrentTemplateSlug(); - const isPostsPage = useIsPostsPage(); - const { - postType, - postId - } = useEditedPostContext(); - const entity = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', postType, postId); - const { - setPage - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - // The default template in a post is indicated by an empty string. - if (!currentTemplateSlug || isPostsPage) { - return null; - } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: async () => { - entity.edit({ - template: '' - }, { - undoIgnore: true - }); - onClick(); - await setPage({ - context: { - postType, - postId - } - }); - } - }, (0,external_wp_i18n_namespaceObject.__)('Use default template'))); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/page-summary.js /** * WordPress dependencies @@ -29168,105 +34502,10 @@ function ResetDefaultTemplate({ - - - - /** * Internal dependencies */ - - - -const edit_template_POPOVER_PROPS = { - className: 'edit-site-page-panels-edit-template__dropdown', - placement: 'bottom-start' -}; -function EditTemplate() { - const { - hasResolved, - template, - isTemplateHidden - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getEditedPostContext, - getEditedPostType, - getEditedPostId - } = select(store_store); - const { - getCanvasMode, - getPageContentFocusType - } = unlock(select(store_store)); - const { - getEditedEntityRecord, - hasFinishedResolution - } = select(external_wp_coreData_namespaceObject.store); - const _context = getEditedPostContext(); - const queryArgs = ['postType', getEditedPostType(), getEditedPostId()]; - return { - context: _context, - hasResolved: hasFinishedResolution('getEditedEntityRecord', queryArgs), - template: getEditedEntityRecord(...queryArgs), - isTemplateHidden: getCanvasMode() === 'edit' && getPageContentFocusType() === 'hideTemplate' - }; - }, []); - const { - setHasPageContentFocus - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - // Disable reason: `useDispatch` can't be called conditionally. - // eslint-disable-next-line @wordpress/no-unused-vars-before-return - const { - setPageContentFocusType - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - if (!hasResolved) { - return null; - } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - className: "edit-site-summary-field" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - className: "edit-site-summary-field__label" - }, (0,external_wp_i18n_namespaceObject.__)('Template')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { - popoverProps: edit_template_POPOVER_PROPS, - focusOnMount: true, - toggleProps: { - variant: 'tertiary', - className: 'edit-site-summary-field__trigger' - }, - label: (0,external_wp_i18n_namespaceObject.__)('Template options'), - text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title), - icon: null - }, ({ - onClose - }) => (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, { - onClick: () => { - setHasPageContentFocus(false); - onClose(); - } - }, (0,external_wp_i18n_namespaceObject.__)('Edit template')), (0,external_wp_element_namespaceObject.createElement)(SwapTemplateButton, { - onClick: onClose - })), (0,external_wp_element_namespaceObject.createElement)(ResetDefaultTemplate, { - onClick: onClose - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - icon: !isTemplateHidden ? library_check : undefined, - onClick: () => { - setPageContentFocusType(isTemplateHidden ? 'disableTemplate' : 'hideTemplate'); - } - }, (0,external_wp_i18n_namespaceObject.__)('Template preview')))))); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/page-summary.js - -/** - * WordPress dependencies - */ - -/** - * Internal dependencies - */ - - - function PageSummary({ status, date, @@ -29274,18 +34513,15 @@ function PageSummary({ postId, postType }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, null, (0,external_wp_element_namespaceObject.createElement)(PageStatus, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: 0 + }, (0,external_React_.createElement)(PageStatus, { status: status, date: date, password: password, postId: postId, postType: postType - }), (0,external_wp_element_namespaceObject.createElement)(ChangeStatus, { - status: status, - date: date, - postId: postId, - postType: postType - }), (0,external_wp_element_namespaceObject.createElement)(EditTemplate, null)); + }), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostSchedulePanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostTemplatePanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostURLPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostAuthorPanel, null)); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/index.js @@ -29301,6 +34537,7 @@ function PageSummary({ + /** * Internal dependencies */ @@ -29317,7 +34554,8 @@ function PagePanels() { date, password, title, - modified + modified, + renderingMode } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { getEditedPostContext @@ -29326,6 +34564,9 @@ function PagePanels() { getEditedEntityRecord, hasFinishedResolution } = select(external_wp_coreData_namespaceObject.store); + const { + getRenderingMode + } = select(external_wp_editor_namespaceObject.store); const context = getEditedPostContext(); const queryArgs = ['postType', context.postType, context.postId]; const page = getEditedEntityRecord(...queryArgs); @@ -29337,29 +34578,30 @@ function PagePanels() { status: page?.status, date: page?.date, password: page?.password, - modified: page?.modified + modified: page?.modified, + renderingMode: getRenderingMode() }; }, []); if (!hasResolved) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)(SidebarCard, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_React_.createElement)(SidebarCard, { title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), icon: library_page, - description: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.sprintf)( + description: (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Human-readable time difference, e.g. "2 days ago". (0,external_wp_i18n_namespaceObject.__)('Last edited %s'), (0,external_wp_date_namespaceObject.humanTimeDiff)(modified)))) - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { title: (0,external_wp_i18n_namespaceObject.__)('Summary') - }, (0,external_wp_element_namespaceObject.createElement)(PageSummary, { + }, (0,external_React_.createElement)(PageSummary, { status: status, date: date, password: password, postId: id, postType: type - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { + })), renderingMode !== 'post-only' && (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { title: (0,external_wp_i18n_namespaceObject.__)('Content') - }, (0,external_wp_element_namespaceObject.createElement)(PageContent, null))); + }, (0,external_React_.createElement)(PageContent, null)), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostLastRevisionPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostTaxonomiesPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostFeaturedImagePanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostExcerptPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostDiscussionPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PageAttributesPanel, null)); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/replace-template-button.js @@ -29411,27 +34653,27 @@ function ReplaceTemplateButton({ if (!availableTemplates.length || availableTemplates.length < 1) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { info: (0,external_wp_i18n_namespaceObject.__)('Replace the contents of this template with another.'), onClick: () => setShowModal(true) - }, (0,external_wp_i18n_namespaceObject.__)('Replace template')), showModal && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { + }, (0,external_wp_i18n_namespaceObject.__)('Replace template')), showModal && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'), onRequestClose: onClose, overlayClassName: "edit-site-template-panel__replace-template-modal", isFullScreen: true - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-template-panel__replace-template-modal__content" - }, (0,external_wp_element_namespaceObject.createElement)(replace_template_button_TemplatesList, { + }, (0,external_React_.createElement)(TemplatesList, { availableTemplates: availableTemplates, onSelect: onTemplateSelect })))); } -function replace_template_button_TemplatesList({ +function TemplatesList({ availableTemplates, onSelect }) { const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(availableTemplates); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, { + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, { label: (0,external_wp_i18n_namespaceObject.__)('Templates'), blockPatterns: availableTemplates, shownPatterns: shownTemplates, @@ -29467,12 +34709,12 @@ function preparePatterns(patterns, template, currentThemeStylesheet) { // Filter out duplicates. const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex(item => currentItem.name === item.name); - // Filter out core patterns. - const filterOutCorePatterns = pattern => !PATTERN_CORE_SOURCES.includes(pattern.source); + // Filter out core/directory patterns not included in theme.json. + const filterOutExcludedPatternSources = pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source); // Filter only the patterns that are compatible with the current template. const filterCompatiblePatterns = pattern => pattern.templateTypes?.includes(template.slug); - return patterns.filter(filterOutCorePatterns && filterOutDuplicatesByName && filterCompatiblePatterns).map(pattern => ({ + return patterns.filter((pattern, index, items) => filterOutExcludedPatternSources(pattern) && filterOutDuplicatesByName(pattern, index, items) && filterCompatiblePatterns(pattern)).map(pattern => ({ ...pattern, keywords: pattern.keywords || [], type: PATTERN_TYPES.theme, @@ -29532,7 +34774,7 @@ function Actions({ if (!isRevertable && (!availablePatterns.length || availablePatterns.length < 1)) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { icon: more_vertical, label: (0,external_wp_i18n_namespaceObject.__)('Actions'), className: "edit-site-template-card__actions", @@ -29541,13 +34783,13 @@ function Actions({ } }, ({ onClose - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, isRevertable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { + }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, isRevertable && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { info: (0,external_wp_i18n_namespaceObject.__)('Use the template as supplied by the theme.'), onClick: () => { revertTemplate(template); onClose(); } - }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations')), (0,external_wp_element_namespaceObject.createElement)(ReplaceTemplateButton, { + }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations')), (0,external_React_.createElement)(ReplaceTemplateButton, { availableTemplates: availablePatterns, template: template, onClick: onClose @@ -29583,7 +34825,7 @@ function TemplateAreaItem({ }, [area]); const highlightBlock = () => toggleBlockHighlight(clientId, true); const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { className: "edit-site-template-card__template-areas-item", icon: templatePartArea?.icon, onMouseOver: highlightBlock, @@ -29595,305 +34837,29 @@ function TemplateAreaItem({ } }, templatePartArea?.label); } -function TemplateAreas() { +function template_areas_TemplateAreas() { const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentTemplateTemplateParts(), []); if (!templateParts.length) { return null; } - return (0,external_wp_element_namespaceObject.createElement)("section", { + return (0,external_React_.createElement)("section", { className: "edit-site-template-card__template-areas" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { level: 3, className: "edit-site-template-card__template-areas-title" - }, (0,external_wp_i18n_namespaceObject.__)('Areas')), (0,external_wp_element_namespaceObject.createElement)("ul", { + }, (0,external_wp_i18n_namespaceObject.__)('Areas')), (0,external_React_.createElement)("ul", { className: "edit-site-template-card__template-areas-list" }, templateParts.map(({ templatePart, block - }) => (0,external_wp_element_namespaceObject.createElement)("li", { + }) => (0,external_React_.createElement)("li", { key: block.clientId - }, (0,external_wp_element_namespaceObject.createElement)(TemplateAreaItem, { + }, (0,external_React_.createElement)(TemplateAreaItem, { area: templatePart.area, clientId: block.clientId }))))); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/last-revision.js - -/** - * WordPress dependencies - */ - - - - - - -/** - * Internal dependencies - */ - -const useRevisionData = () => { - var _currentTemplate$_lin, _currentTemplate$_lin2; - const { - record: currentTemplate - } = useEditedEntityRecord(); - const lastRevisionId = (_currentTemplate$_lin = currentTemplate?._links?.['predecessor-version']?.[0]?.id) !== null && _currentTemplate$_lin !== void 0 ? _currentTemplate$_lin : null; - const revisionsCount = (_currentTemplate$_lin2 = currentTemplate?._links?.['version-history']?.[0]?.count) !== null && _currentTemplate$_lin2 !== void 0 ? _currentTemplate$_lin2 : 0; - return { - currentTemplate, - lastRevisionId, - revisionsCount - }; -}; -function PostLastRevisionCheck({ - children -}) { - const { - lastRevisionId, - revisionsCount - } = useRevisionData(); - if (true) { - return null; - } - if (!lastRevisionId || revisionsCount < 2) { - return null; - } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.PostTypeSupportCheck, { - supportKeys: "revisions" - }, children); -} -const PostLastRevision = () => { - const { - lastRevisionId, - revisionsCount - } = useRevisionData(); - return (0,external_wp_element_namespaceObject.createElement)(PostLastRevisionCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, { - header: (0,external_wp_i18n_namespaceObject.__)('Editing history'), - className: "edit-site-template-revisions" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', { - revision: lastRevisionId - }), - className: "edit-site-template-last-revision__title", - icon: library_backup - }, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of revisions */ - (0,external_wp_i18n_namespaceObject._n)('%d Revision', '%d Revisions', revisionsCount), revisionsCount)))); -}; -function LastRevision() { - return (0,external_wp_element_namespaceObject.createElement)(PostLastRevisionCheck, null, (0,external_wp_element_namespaceObject.createElement)(PostLastRevision, null)); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js - -/** - * WordPress dependencies - */ - - - - - - - - - -/** - * Internal dependencies - */ - -const unescapeString = arg => { - return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg); -}; - -/** - * Returns a term object with name unescaped. - * - * @param {Object} term The term object to unescape. - * - * @return {Object} Term object with name property unescaped. - */ -const unescapeTerm = term => { - return { - ...term, - name: unescapeString(term.name) - }; -}; - -/** - * Shared reference to an empty array for cases where it is important to avoid - * returning a new array reference on every invocation. - * - * @type {Array<any>} - */ -const pattern_categories_EMPTY_ARRAY = []; - -/** - * Module constants - */ -const MAX_TERMS_SUGGESTIONS = 20; -const DEFAULT_QUERY = { - per_page: MAX_TERMS_SUGGESTIONS, - _fields: 'id,name', - context: 'view' -}; -const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase(); -const termNamesToIds = (names, terms) => { - return names.map(termName => terms.find(term => isSameTermName(term.name, termName)).id); -}; -function PatternCategories({ - post -}) { - var _taxonomy$labels$sing; - const slug = 'wp_pattern_category'; - const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]); - const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)(''); - const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500); - const { - terms, - taxonomy, - hasAssignAction, - hasCreateAction, - hasResolvedTerms - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - var _post$_links, _post$_links2; - const { - getEntityRecords, - getTaxonomy, - hasFinishedResolution - } = select(external_wp_coreData_namespaceObject.store); - const _taxonomy = getTaxonomy(slug); - const _termIds = post?.wp_pattern_category?.length > 0 ? post?.wp_pattern_category : pattern_categories_EMPTY_ARRAY; - const query = { - ...DEFAULT_QUERY, - include: _termIds?.join(','), - per_page: -1 - }; - return { - hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false, - hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false, - taxonomy: _taxonomy, - termIds: _termIds, - terms: _termIds?.length ? getEntityRecords('taxonomy', slug, query) : pattern_categories_EMPTY_ARRAY, - hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query]) - }; - }, [slug, post]); - const { - searchResults - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getEntityRecords - } = select(external_wp_coreData_namespaceObject.store); - return { - searchResults: !!search ? getEntityRecords('taxonomy', slug, { - ...DEFAULT_QUERY, - search - }) : pattern_categories_EMPTY_ARRAY - }; - }, [search, slug]); - - // Update terms state only after the selectors are resolved. - // We're using this to avoid terms temporarily disappearing on slow networks - // while core data makes REST API requests. - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (hasResolvedTerms) { - const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name)); - setValues(newValues); - } - }, [terms, hasResolvedTerms]); - const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => { - return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name)); - }, [searchResults]); - const { - saveEntityRecord, - editEntityRecord, - invalidateResolution - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); - const { - createErrorNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - if (!hasAssignAction) { - return null; - } - async function findOrCreateTerm(term) { - try { - const newTerm = await saveEntityRecord('taxonomy', slug, term, { - throwOnError: true - }); - invalidateResolution('getUserPatternCategories'); - return unescapeTerm(newTerm); - } catch (error) { - if (error.code !== 'term_exists') { - throw error; - } - return { - id: error.data.term_id, - name: term.name - }; - } - } - function onUpdateTerms(newTermIds) { - editEntityRecord('postType', PATTERN_TYPES.user, post.id, { - wp_pattern_category: newTermIds - }); - } - function onChange(termNames) { - const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])]; - const uniqueTerms = termNames.reduce((acc, name) => { - if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) { - acc.push(name); - } - return acc; - }, []); - const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName))); - - // Optimistically update term values. - // The selector will always re-fetch terms later. - setValues(uniqueTerms); - if (newTermNames.length === 0) { - return onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms)); - } - if (!hasCreateAction) { - return; - } - Promise.all(newTermNames.map(termName => findOrCreateTerm({ - name: termName - }))).then(newTerms => { - const newAvailableTerms = availableTerms.concat(newTerms); - return onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms)); - }).catch(error => { - createErrorNotice(error.message, { - type: 'snackbar' - }); - }); - } - const singularName = (_taxonomy$labels$sing = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term'); - const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */ - (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName); - const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */ - (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName); - const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */ - (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, { - initialOpen: true, - title: (0,external_wp_i18n_namespaceObject.__)('Categories') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormTokenField, { - __next40pxDefaultSize: true, - value: values, - suggestions: suggestions, - onChange: onChange, - onInputChange: debouncedSearch, - maxSuggestions: MAX_TERMS_SUGGESTIONS, - label: (0,external_wp_i18n_namespaceObject.__)('Pattern categories'), - messages: { - added: termAddedLabel, - removed: termRemovedLabel, - remove: removeTermLabel - }, - tokenizeOnBlur: true - }))); -} - ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/index.js /** @@ -29913,9 +34879,6 @@ function PatternCategories({ - - - const CARD_ICONS = { wp_block: library_symbol, wp_navigation: library_navigation @@ -29926,8 +34889,7 @@ function TemplatePanel() { title, description, icon, - record, - postType + record } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { getEditedPostType, @@ -29947,26 +34909,21 @@ function TemplatePanel() { title: info.title, description: info.description, icon: info.icon, - record: _record, - postType: type + record: _record }; }, []); if (!title && !description) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { - className: "edit-site-template-panel" - }, (0,external_wp_element_namespaceObject.createElement)(SidebarCard, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_React_.createElement)(SidebarCard, { className: "edit-site-template-card", title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), icon: (_CARD_ICONS$record$ty = CARD_ICONS[record?.type]) !== null && _CARD_ICONS$record$ty !== void 0 ? _CARD_ICONS$record$ty : icon, description: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(description), - actions: (0,external_wp_element_namespaceObject.createElement)(Actions, { + actions: (0,external_React_.createElement)(Actions, { template: record }) - }, (0,external_wp_element_namespaceObject.createElement)(TemplateAreas, null)), (0,external_wp_element_namespaceObject.createElement)(LastRevision, null), postType === PATTERN_TYPES.user && (0,external_wp_element_namespaceObject.createElement)(PatternCategories, { - post: record - })); + }, (0,external_React_.createElement)(template_areas_TemplateAreas, null))), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostLastRevisionPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostTaxonomiesPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostFeaturedImagePanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostExcerptPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostDiscussionPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PageAttributesPanel, null)); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/plugin-template-setting-panel/index.js @@ -29980,10 +34937,10 @@ function TemplatePanel() { const { Fill, - Slot + Slot: plugin_template_setting_panel_Slot } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginTemplateSettingPanel'); const PluginTemplateSettingPanel = Fill; -PluginTemplateSettingPanel.Slot = Slot; +PluginTemplateSettingPanel.Slot = plugin_template_setting_panel_Slot; /** * Renders items in the Template Sidebar below the main information @@ -30001,9 +34958,9 @@ PluginTemplateSettingPanel.Slot = Slot; * ); * ``` * - * @return {WPComponent} The component to be rendered. + * @return {Component} The component to be rendered. */ -/* harmony default export */ var plugin_template_setting_panel = (PluginTemplateSettingPanel); +/* harmony default export */ const plugin_template_setting_panel = (PluginTemplateSettingPanel); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/index.js @@ -30018,6 +34975,7 @@ PluginTemplateSettingPanel.Slot = Slot; + /** * Internal dependencies */ @@ -30030,28 +34988,94 @@ PluginTemplateSettingPanel.Slot = Slot; + +const { + Tabs: sidebar_edit_mode_Tabs +} = unlock(external_wp_components_namespaceObject.privateApis); const { Slot: InspectorSlot, Fill: InspectorFill } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteSidebarInspector'); const SidebarInspectorFill = InspectorFill; +const FillContents = ({ + sidebarName, + isEditingPage, + supportsGlobalStyles +}) => { + const tabListRef = (0,external_wp_element_namespaceObject.useRef)(null); + // Because `DefaultSidebar` renders a `ComplementaryArea`, we + // need to forward the `Tabs` context so it can be passed through the + // underlying slot/fill. + const tabsContextValue = (0,external_wp_element_namespaceObject.useContext)(sidebar_edit_mode_Tabs.Context); + + // This effect addresses a race condition caused by tabbing from the last + // block in the editor into the settings sidebar. Without this effect, the + // selected tab and browser focus can become separated in an unexpected way. + // (e.g the "block" tab is focused, but the "post" tab is selected). + (0,external_wp_element_namespaceObject.useEffect)(() => { + const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []); + const selectedTabElement = tabsElements.find( + // We are purposefully using a custom `data-tab-id` attribute here + // because we don't want rely on any assumptions about `Tabs` + // component internals. + element => element.getAttribute('data-tab-id') === sidebarName); + const activeElement = selectedTabElement?.ownerDocument.activeElement; + const tabsHasFocus = tabsElements.some(element => { + return activeElement && activeElement.id === element.id; + }); + if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) { + selectedTabElement?.focus(); + } + }, [sidebarName]); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(DefaultSidebar, { + identifier: sidebarName, + title: (0,external_wp_i18n_namespaceObject.__)('Settings'), + icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right, + closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Settings'), + header: (0,external_React_.createElement)(sidebar_edit_mode_Tabs.Context.Provider, { + value: tabsContextValue + }, (0,external_React_.createElement)(settings_header, { + ref: tabListRef + })), + headerClassName: "edit-site-sidebar-edit-mode__panel-tabs" + // This classname is added so we can apply a corrective negative + // margin to the panel. + // see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049 + , + className: "edit-site-sidebar__panel" + }, (0,external_React_.createElement)(sidebar_edit_mode_Tabs.Context.Provider, { + value: tabsContextValue + }, (0,external_React_.createElement)(sidebar_edit_mode_Tabs.TabPanel, { + tabId: SIDEBAR_TEMPLATE, + focusable: false + }, isEditingPage ? (0,external_React_.createElement)(PagePanels, null) : (0,external_React_.createElement)(TemplatePanel, null), (0,external_React_.createElement)(plugin_template_setting_panel.Slot, null)), (0,external_React_.createElement)(sidebar_edit_mode_Tabs.TabPanel, { + tabId: SIDEBAR_BLOCK, + focusable: false + }, (0,external_React_.createElement)(InspectorSlot, { + bubblesVirtually: true + })))), supportsGlobalStyles && (0,external_React_.createElement)(GlobalStylesSidebar, null)); +}; function SidebarComplementaryAreaFills() { const { sidebar, isEditorSidebarOpened, hasBlockSelection, supportsGlobalStyles, - hasPageContentFocus + isEditingPage, + isEditorOpen } = (0,external_wp_data_namespaceObject.useSelect)(select => { const _sidebar = select(store).getActiveComplementaryArea(constants_STORE_NAME); const _isEditorSidebarOpened = [SIDEBAR_BLOCK, SIDEBAR_TEMPLATE].includes(_sidebar); - const settings = select(store_store).getSettings(); + const { + getCanvasMode + } = unlock(select(store_store)); return { sidebar: _sidebar, isEditorSidebarOpened: _isEditorSidebarOpened, hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(), - supportsGlobalStyles: !settings?.supportsTemplatePartsMode, - hasPageContentFocus: select(store_store).hasPageContentFocus() + supportsGlobalStyles: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, + isEditingPage: select(store_store).isPage(), + isEditorOpen: getCanvasMode() === 'edit' }; }, []); const { @@ -30064,1281 +35088,46 @@ function SidebarComplementaryAreaFills() { return; } if (hasBlockSelection) { - if (!hasPageContentFocus) { + if (!isEditingPage) { enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK); } } else { enableComplementaryArea(constants_STORE_NAME, SIDEBAR_TEMPLATE); } - }, [hasBlockSelection, isEditorSidebarOpened, hasPageContentFocus]); + }, [hasBlockSelection, isEditorSidebarOpened, isEditingPage, enableComplementaryArea]); let sidebarName = sidebar; if (!isEditorSidebarOpened) { sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(DefaultSidebar, { - identifier: sidebarName, - title: (0,external_wp_i18n_namespaceObject.__)('Settings'), - icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right, - closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Settings'), - header: (0,external_wp_element_namespaceObject.createElement)(settings_header, { - sidebarName: sidebarName - }), - headerClassName: "edit-site-sidebar-edit-mode__panel-tabs" - }, sidebarName === SIDEBAR_TEMPLATE && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, hasPageContentFocus ? (0,external_wp_element_namespaceObject.createElement)(PagePanels, null) : (0,external_wp_element_namespaceObject.createElement)(TemplatePanel, null), (0,external_wp_element_namespaceObject.createElement)(plugin_template_setting_panel.Slot, null)), sidebarName === SIDEBAR_BLOCK && (0,external_wp_element_namespaceObject.createElement)(InspectorSlot, { - bubblesVirtually: true - })), supportsGlobalStyles && (0,external_wp_element_namespaceObject.createElement)(GlobalStylesSidebar, null)); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/convert-to-regular.js - -/** - * WordPress dependencies - */ - - - - -function ConvertToRegularBlocks({ - clientId, - onClose -}) { - const { - getBlocks - } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store); - const { - replaceBlocks - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); - const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]); - if (!canRemove) { - return null; - } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: () => { - replaceBlocks(clientId, getBlocks(clientId)); - onClose(); - } - }, (0,external_wp_i18n_namespaceObject.__)('Detach blocks from template part')); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/convert-to-template-part.js - -/** - * WordPress dependencies - */ - - - - - - - - - -/** - * Internal dependencies - */ - - -function ConvertToTemplatePart({ - clientIds, - blocks -}) { - const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); - const { - replaceBlocks - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); - const { - createSuccessNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - const { - canCreate - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - supportsTemplatePartsMode - } = select(store_store).getSettings(); - return { - canCreate: !supportsTemplatePartsMode - }; - }, []); - if (!canCreate) { - return null; - } - const onConvert = async templatePart => { - replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', { - slug: templatePart.slug, - theme: templatePart.theme - })); - createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), { - type: 'snackbar' - }); - - // The modal and this component will be unmounted because of `replaceBlocks` above, - // so no need to call `closeModal` or `onClose`. - }; - - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - icon: symbol_filled, - onClick: () => { - setIsModalOpen(true); - }, - "aria-expanded": isModalOpen, - "aria-haspopup": "dialog" - }, (0,external_wp_i18n_namespaceObject.__)('Create template part')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, { - closeModal: () => { - setIsModalOpen(false); - }, - blocks: blocks, - onCreate: onConvert - })); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/index.js - -/** - * WordPress dependencies - */ - - - -/** - * Internal dependencies - */ - - -function TemplatePartConverter() { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, ({ - selectedClientIds, - onClose - }) => (0,external_wp_element_namespaceObject.createElement)(TemplatePartConverterMenuItem, { - clientIds: selectedClientIds, - onClose: onClose - })); -} -function TemplatePartConverterMenuItem({ - clientIds, - onClose -}) { - const blocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds), [clientIds]); - - // Allow converting a single template part to standard blocks. - if (blocks.length === 1 && blocks[0]?.name === 'core/template-part') { - return (0,external_wp_element_namespaceObject.createElement)(ConvertToRegularBlocks, { - clientId: clientIds[0], - onClose: onClose - }); - } - return (0,external_wp_element_namespaceObject.createElement)(ConvertToTemplatePart, { - clientIds: clientIds, - blocks: blocks - }); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-left.js - -/** - * WordPress dependencies - */ - -const arrowLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" -})); -/* harmony default export */ var arrow_left = (arrowLeft); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/back-button.js - -/** - * WordPress dependencies - */ - - - - - -/** - * Internal dependencies - */ - - -const { - useLocation: back_button_useLocation, - useHistory: back_button_useHistory -} = unlock(external_wp_router_namespaceObject.privateApis); -function BackButton() { - const location = back_button_useLocation(); - const history = back_button_useHistory(); - const isTemplatePart = location.params.postType === TEMPLATE_PART_POST_TYPE; - const isNavigationMenu = location.params.postType === NAVIGATION_POST_TYPE; - const previousTemplateId = location.state?.fromTemplateId; - const isFocusMode = isTemplatePart || isNavigationMenu; - if (!isFocusMode || !previousTemplateId) { - return null; - } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - className: "edit-site-visual-editor__back-button", - icon: arrow_left, - onClick: () => { - history.back(); - } - }, (0,external_wp_i18n_namespaceObject.__)('Back')); -} -/* harmony default export */ var back_button = (BackButton); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/editor-canvas.js - -/** - * External dependencies - */ - - -/** - * WordPress dependencies - */ - - - - - - -/** - * Internal dependencies - */ - - -const { - ExperimentalBlockCanvas: BlockCanvas -} = unlock(external_wp_blockEditor_namespaceObject.privateApis); -function EditorCanvas({ - enableResizing, - settings, - children, - contentRef, - ...props -}) { - const { - canvasMode, - deviceType, - isZoomOutMode - } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ - deviceType: select(store_store).__experimentalGetPreviewDeviceType(), - isZoomOutMode: select(external_wp_blockEditor_namespaceObject.store).__unstableGetEditorMode() === 'zoom-out', - canvasMode: unlock(select(store_store)).getCanvasMode() - }), []); - const { - setCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType); - const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false); - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (canvasMode === 'edit') { - setIsFocused(false); - } - }, [canvasMode]); - const viewModeProps = { - 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Editor Canvas'), - role: 'button', - tabIndex: 0, - onFocus: () => setIsFocused(true), - onBlur: () => setIsFocused(false), - onKeyDown: event => { - const { - keyCode - } = event; - if (keyCode === external_wp_keycodes_namespaceObject.ENTER || keyCode === external_wp_keycodes_namespaceObject.SPACE) { - event.preventDefault(); - setCanvasMode('edit'); - } - }, - onClick: () => setCanvasMode('edit'), - readonly: true - }; - return (0,external_wp_element_namespaceObject.createElement)(BlockCanvas, { - height: "100%", - iframeProps: { - expand: isZoomOutMode, - scale: isZoomOutMode ? 0.45 : undefined, - frameSize: isZoomOutMode ? 100 : undefined, - style: enableResizing ? {} : deviceStyles, - className: classnames_default()('edit-site-visual-editor__editor-canvas', { - 'is-focused': isFocused && canvasMode === 'view' - }), - ...props, - ...(canvasMode === 'view' ? viewModeProps : {}) - }, - styles: settings.styles, - contentRef: contentRef - }, (0,external_wp_element_namespaceObject.createElement)("style", null, - // Forming a "block formatting context" to prevent margin collapsing. - // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context - `.is-root-container{display:flow-root;${ - // Some themes will have `min-height: 100vh` for the root container, - // which isn't a requirement in auto resize mode. - enableResizing ? 'min-height:0!important;' : ''}}body{position:relative; ${canvasMode === 'view' ? 'cursor: pointer; min-height: 100vh;' : ''}}}`), children); -} -/* harmony default export */ var editor_canvas = (EditorCanvas); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/inserter-media-categories.js -/** - * The `edit-site` settings here need to be in sync with the corresponding ones in `site-editor` package. - * See `packages/edit-site/src/components/block-editor/inserter-media-categories.js`. - * - * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`. - * The rest of the settings would still need to be in sync though. - */ - -/** - * WordPress dependencies - */ - - - - -/** - * Internal dependencies - */ - - -/** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */ -/** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */ -/** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */ - -const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`; -const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`; -const getOpenverseLicense = (license, licenseVersion) => { - let licenseName = license.trim(); - // PDM has no abbreviation - if (license !== 'pdm') { - licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling'); - } - // If version is known, append version to the name. - // The license has to have a version to be valid. Only - // PDM (public domain mark) doesn't have a version. - if (licenseVersion) { - licenseName += ` ${licenseVersion}`; - } - // For licenses other than public-domain marks, prepend 'CC' to the name. - if (!['pdm', 'cc0'].includes(license)) { - licenseName = `CC ${licenseName}`; - } - return licenseName; -}; -const getOpenverseCaption = item => { - const { - title, - foreign_landing_url: foreignLandingUrl, - creator, - creator_url: creatorUrl, - license, - license_version: licenseVersion, - license_url: licenseUrl - } = item; - const fullLicense = getOpenverseLicense(license, licenseVersion); - const _creator = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(creator); - let _caption; - if (_creator) { - _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0". - (0,external_wp_i18n_namespaceObject._x)('"%1$s" by %2$s/ %3$s', 'caption'), getExternalLink(foreignLandingUrl, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : (0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0". - (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a> by %2$s/ %3$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense); - } else { - _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0". - (0,external_wp_i18n_namespaceObject._x)('"%1$s"/ %2$s', 'caption'), getExternalLink(foreignLandingUrl, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : (0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0". - (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a>/ %3$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense); - } - return _caption.replace(/\s{2}/g, ' '); -}; -const coreMediaFetch = async (query = {}) => { - const mediaItems = await (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store).getMediaItems({ - ...query, - orderBy: !!query?.search ? 'relevance' : 'date' - }); - return mediaItems.map(mediaItem => ({ - ...mediaItem, - alt: mediaItem.alt_text, - url: mediaItem.source_url, - previewUrl: mediaItem.media_details?.sizes?.medium?.source_url, - caption: mediaItem.caption?.raw - })); -}; - -/** @type {InserterMediaCategory[]} */ -const inserterMediaCategories = [{ - name: 'images', - labels: { - name: (0,external_wp_i18n_namespaceObject.__)('Images'), - search_items: (0,external_wp_i18n_namespaceObject.__)('Search images') - }, - mediaType: 'image', - async fetch(query = {}) { - return coreMediaFetch({ - ...query, - media_type: 'image' - }); - } -}, { - name: 'videos', - labels: { - name: (0,external_wp_i18n_namespaceObject.__)('Videos'), - search_items: (0,external_wp_i18n_namespaceObject.__)('Search videos') - }, - mediaType: 'video', - async fetch(query = {}) { - return coreMediaFetch({ - ...query, - media_type: 'video' - }); - } -}, { - name: 'audio', - labels: { - name: (0,external_wp_i18n_namespaceObject.__)('Audio'), - search_items: (0,external_wp_i18n_namespaceObject.__)('Search audio') - }, - mediaType: 'audio', - async fetch(query = {}) { - return coreMediaFetch({ - ...query, - media_type: 'audio' - }); - } -}, { - name: 'openverse', - labels: { - name: (0,external_wp_i18n_namespaceObject.__)('Openverse'), - search_items: (0,external_wp_i18n_namespaceObject.__)('Search Openverse') - }, - mediaType: 'image', - async fetch(query = {}) { - const defaultArgs = { - mature: false, - excluded_source: 'flickr,inaturalist,wikimedia', - license: 'pdm,cc0' - }; - const finalQuery = { - ...query, - ...defaultArgs - }; - const mapFromInserterMediaRequest = { - per_page: 'page_size', - search: 'q' - }; - const url = new URL('https://api.openverse.engineering/v1/images/'); - Object.entries(finalQuery).forEach(([key, value]) => { - const queryKey = mapFromInserterMediaRequest[key] || key; - url.searchParams.set(queryKey, value); - }); - const response = await window.fetch(url, { - headers: { - 'User-Agent': 'WordPress/inserter-media-fetch' - } - }); - const jsonResponse = await response.json(); - const results = jsonResponse.results; - return results.map(result => ({ - ...result, - // This is a temp solution for better titles, until Openverse API - // completes the cleaning up of some titles of their upstream data. - title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title, - sourceId: result.id, - id: undefined, - caption: getOpenverseCaption(result), - previewUrl: result.thumbnail - })); - }, - getReportUrl: ({ - sourceId - }) => `https://wordpress.org/openverse/image/${sourceId}/report/`, - isExternalResource: true -}]; -/* harmony default export */ var inserter_media_categories = (inserterMediaCategories); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/use-site-editor-settings.js -/** - * WordPress dependencies - */ - - - -/** - * Internal dependencies - */ - - - -function useArchiveLabel(templateSlug) { - const taxonomyMatches = templateSlug?.match(/^(category|tag|taxonomy-([^-]+))$|^(((category|tag)|taxonomy-([^-]+))-(.+))$/); - let taxonomy; - let term; - let isAuthor = false; - let authorSlug; - if (taxonomyMatches) { - // If is for a all taxonomies of a type - if (taxonomyMatches[1]) { - taxonomy = taxonomyMatches[2] ? taxonomyMatches[2] : taxonomyMatches[1]; - } - // If is for a all taxonomies of a type - else if (taxonomyMatches[3]) { - taxonomy = taxonomyMatches[6] ? taxonomyMatches[6] : taxonomyMatches[4]; - term = taxonomyMatches[7]; - } - taxonomy = taxonomy === 'tag' ? 'post_tag' : taxonomy; - - //getTaxonomy( 'category' ); - //wp.data.select('core').getEntityRecords( 'taxonomy', 'category', {slug: 'newcat'} ); - } else { - const authorMatches = templateSlug?.match(/^(author)$|^author-(.+)$/); - if (authorMatches) { - isAuthor = true; - if (authorMatches[2]) { - authorSlug = authorMatches[2]; - } - } - } - return (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getEntityRecords, - getTaxonomy, - getAuthors - } = select(external_wp_coreData_namespaceObject.store); - let archiveTypeLabel; - let archiveNameLabel; - if (taxonomy) { - archiveTypeLabel = getTaxonomy(taxonomy)?.labels?.singular_name; - } - if (term) { - const records = getEntityRecords('taxonomy', taxonomy, { - slug: term, - per_page: 1 - }); - if (records && records[0]) { - archiveNameLabel = records[0].name; - } - } - if (isAuthor) { - archiveTypeLabel = 'Author'; - if (authorSlug) { - const authorRecords = getAuthors({ - slug: authorSlug - }); - if (authorRecords && authorRecords[0]) { - archiveNameLabel = authorRecords[0].name; - } - } - } - return { - archiveTypeLabel, - archiveNameLabel - }; - }, [authorSlug, isAuthor, taxonomy, term]); -} -function useSiteEditorSettings() { - var _storedSettings$__exp, _storedSettings$__exp2; - const { - setIsInserterOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const { - storedSettings, - canvasMode, - templateType - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getSettings, - getCanvasMode, - getEditedPostType - } = unlock(select(store_store)); - return { - storedSettings: getSettings(setIsInserterOpened), - canvasMode: getCanvasMode(), - templateType: getEditedPostType() - }; - }, [setIsInserterOpened]); - const settingsBlockPatterns = (_storedSettings$__exp = storedSettings.__experimentalAdditionalBlockPatterns) !== null && _storedSettings$__exp !== void 0 ? _storedSettings$__exp : - // WP 6.0 - storedSettings.__experimentalBlockPatterns; // WP 5.9 - const settingsBlockPatternCategories = (_storedSettings$__exp2 = storedSettings.__experimentalAdditionalBlockPatternCategories) !== null && _storedSettings$__exp2 !== void 0 ? _storedSettings$__exp2 : - // WP 6.0 - storedSettings.__experimentalBlockPatternCategories; // WP 5.9 - - const { - restBlockPatterns, - restBlockPatternCategories, - templateSlug, - userPatternCategories - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getEditedPostType, - getEditedPostId - } = select(store_store); - const { - getEditedEntityRecord, - getUserPatternCategories - } = select(external_wp_coreData_namespaceObject.store); - const usedPostType = getEditedPostType(); - const usedPostId = getEditedPostId(); - const _record = getEditedEntityRecord('postType', usedPostType, usedPostId); - return { - restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(), - restBlockPatternCategories: select(external_wp_coreData_namespaceObject.store).getBlockPatternCategories(), - templateSlug: _record.slug, - userPatternCategories: getUserPatternCategories() - }; - }, []); - const archiveLabels = useArchiveLabel(templateSlug); - const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || []), ...(restBlockPatterns || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)).filter(({ - postTypes - }) => { - return !postTypes || Array.isArray(postTypes) && postTypes.includes(templateType); - }), [settingsBlockPatterns, restBlockPatterns, templateType]); - const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]); - return (0,external_wp_element_namespaceObject.useMemo)(() => { - const { - __experimentalAdditionalBlockPatterns, - __experimentalAdditionalBlockPatternCategories, - focusMode, - ...restStoredSettings - } = storedSettings; - return { - ...restStoredSettings, - inserterMediaCategories: inserter_media_categories, - __experimentalBlockPatterns: blockPatterns, - __experimentalBlockPatternCategories: blockPatternCategories, - __experimentalUserPatternCategories: userPatternCategories, - focusMode: canvasMode === 'view' && focusMode ? false : focusMode, - __experimentalArchiveTitleTypeLabel: archiveLabels.archiveTypeLabel, - __experimentalArchiveTitleNameLabel: archiveLabels.archiveNameLabel - }; - }, [storedSettings, blockPatterns, blockPatternCategories, userPatternCategories, canvasMode, archiveLabels.archiveTypeLabel, archiveLabels.archiveNameLabel]); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js - -/** - * WordPress dependencies - */ - - - - - -/** - * Internal dependencies - */ - - -/** - * Component that when rendered, makes it so that the site editor allows only - * page content to be edited. - */ -function DisableNonPageContentBlocks() { - useDisableNonPageContentBlocks(); - return null; -} - -/** - * Disables non-content blocks using the `useBlockEditingMode` hook. - */ -function useDisableNonPageContentBlocks() { - (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)('disabled'); - (0,external_wp_element_namespaceObject.useEffect)(() => { - (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-site/disable-non-content-blocks', withDisableNonPageContentBlocks); - return () => (0,external_wp_hooks_namespaceObject.removeFilter)('editor.BlockEdit', 'core/edit-site/disable-non-content-blocks'); - }, []); -} -const withDisableNonPageContentBlocks = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { - const isDescendentOfQueryLoop = props.context.queryId !== undefined; - const isPageContent = PAGE_CONTENT_BLOCK_TYPES[props.name] && !isDescendentOfQueryLoop; - const mode = isPageContent ? 'contentOnly' : undefined; - (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)(mode); - return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, { - ...props - }); -}, 'withDisableNonPageContentBlocks'); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-content-focus-manager/edit-template-notification.js - -/** - * WordPress dependencies - */ - - - - - - -/** - * Internal dependencies - */ - - -/** - * Component that: - * - * - Displays a 'Edit your template to edit this block' notification when the - * user is focusing on editing page content and clicks on a disabled template - * block. - * - Displays a 'Edit your template to edit this block' dialog when the user - * is focusing on editing page conetnt and double clicks on a disabled - * template block. - * - * @param {Object} props - * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block - * editor iframe canvas. - */ -function EditTemplateNotification({ - contentRef -}) { - const hasPageContentFocus = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasPageContentFocus(), []); - const { - getNotices - } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_notices_namespaceObject.store); - const { - createInfoNotice, - removeNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - const { - setHasPageContentFocus - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const [isDialogOpen, setIsDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false); - const lastNoticeId = (0,external_wp_element_namespaceObject.useRef)(0); - (0,external_wp_element_namespaceObject.useEffect)(() => { - const handleClick = async event => { - if (!hasPageContentFocus) { - return; - } - if (!event.target.classList.contains('is-root-container')) { - return; - } - const isNoticeAlreadyShowing = getNotices().some(notice => notice.id === lastNoticeId.current); - if (isNoticeAlreadyShowing) { - return; - } - const { - notice - } = await createInfoNotice((0,external_wp_i18n_namespaceObject.__)('Edit your template to edit this block.'), { - isDismissible: true, - type: 'snackbar', - actions: [{ - label: (0,external_wp_i18n_namespaceObject.__)('Edit template'), - onClick: () => setHasPageContentFocus(false) - }] - }); - lastNoticeId.current = notice.id; - }; - const handleDblClick = event => { - if (!hasPageContentFocus) { - return; - } - if (!event.target.classList.contains('is-root-container')) { - return; - } - if (lastNoticeId.current) { - removeNotice(lastNoticeId.current); - } - setIsDialogOpen(true); - }; - const canvas = contentRef.current; - canvas?.addEventListener('click', handleClick); - canvas?.addEventListener('dblclick', handleDblClick); - return () => { - canvas?.removeEventListener('click', handleClick); - canvas?.removeEventListener('dblclick', handleDblClick); - }; - }, [lastNoticeId, hasPageContentFocus, contentRef.current]); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { - isOpen: isDialogOpen, - confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Edit template'), - onConfirm: () => { - setIsDialogOpen(false); - setHasPageContentFocus(false); - }, - onCancel: () => setIsDialogOpen(false) - }, (0,external_wp_i18n_namespaceObject.__)('Edit your template to edit this block.')); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-content-focus-manager/back-to-page-notification.js -/** - * WordPress dependencies - */ - - - - - -/** - * Internal dependencies - */ - - -/** - * Component that displays a 'You are editing a template' notification when the - * user switches from focusing on editing page content to editing a template. - */ -function BackToPageNotification() { - useBackToPageNotification(); - return null; -} - -/** - * Hook that displays a 'You are editing a template' notification when the user - * switches from focusing on editing page content to editing a template. - */ -function useBackToPageNotification() { - const { - isPage, - hasPageContentFocus - } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ - isPage: select(store_store).isPage(), - hasPageContentFocus: select(store_store).hasPageContentFocus() - }), []); - const alreadySeen = (0,external_wp_element_namespaceObject.useRef)(false); - const prevHasPageContentFocus = (0,external_wp_element_namespaceObject.useRef)(false); - const { - createInfoNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - const { - setHasPageContentFocus - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (!alreadySeen.current && isPage && prevHasPageContentFocus.current && !hasPageContentFocus) { - createInfoNotice((0,external_wp_i18n_namespaceObject.__)('You are editing a template.'), { - isDismissible: true, - type: 'snackbar', - actions: [{ - label: (0,external_wp_i18n_namespaceObject.__)('Back to page'), - onClick: () => setHasPageContentFocus(true) - }] - }); - alreadySeen.current = true; - } - prevHasPageContentFocus.current = hasPageContentFocus; - }, [alreadySeen, isPage, prevHasPageContentFocus, hasPageContentFocus, createInfoNotice, setHasPageContentFocus]); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-content-focus-manager/index.js - -/** - * WordPress dependencies - */ - - -/** - * Internal dependencies - */ - - - - -function PageContentFocusManager({ - contentRef -}) { - const hasPageContentFocus = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasPageContentFocus(), []); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, hasPageContentFocus && (0,external_wp_element_namespaceObject.createElement)(DisableNonPageContentBlocks, null), (0,external_wp_element_namespaceObject.createElement)(EditTemplateNotification, { - contentRef: contentRef - }), (0,external_wp_element_namespaceObject.createElement)(BackToPageNotification, null)); -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/site-editor-canvas.js - -/** - * External dependencies - */ - -/** - * WordPress dependencies - */ - - - - -/** - * Internal dependencies - */ - - - - - - - - - -const LAYOUT = { - type: 'default', - // At the root level of the site editor, no alignments should be allowed. - alignments: [] -}; -function SiteEditorCanvas() { - const { - clearSelectedBlock - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); - const { - templateType, - isFocusMode, - isViewMode - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getEditedPostType, - getCanvasMode - } = unlock(select(store_store)); - const _templateType = getEditedPostType(); - return { - templateType: _templateType, - isFocusMode: FOCUSABLE_ENTITIES.includes(_templateType), - isViewMode: getCanvasMode() === 'view' - }; - }, []); - const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); - const settings = useSiteEditorSettings(); - const { - hasBlocks - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getBlockCount - } = select(external_wp_blockEditor_namespaceObject.store); - const blocks = getBlockCount(); - return { - hasBlocks: !!blocks - }; - }, []); - const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<'); - const enableResizing = isFocusMode && !isViewMode && - // Disable resizing in mobile viewport. - !isMobileViewport; - const contentRef = (0,external_wp_element_namespaceObject.useRef)(); - const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE; - const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode; - - // Hide the appender when: - // - In navigation focus mode (should only allow the root Nav block). - // - In view mode (i.e. not editing). - const showBlockAppender = isNavigationFocusMode && hasBlocks || isViewMode ? false : undefined; - const forceFullHeight = isNavigationFocusMode; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(editor_canvas_container.Slot, null, ([editorCanvasView]) => editorCanvasView ? (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-visual-editor is-focus-mode" - }, editorCanvasView) : (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, { - className: classnames_default()('edit-site-visual-editor', { - 'is-focus-mode': isFocusMode || !!editorCanvasView, - 'is-view-mode': isViewMode - }), - __unstableContentRef: contentRef, - onClick: event => { - // Clear selected block when clicking on the gray background. - if (event.target === event.currentTarget) { - clearSelectedBlock(); - } - } - }, (0,external_wp_element_namespaceObject.createElement)(back_button, null), (0,external_wp_element_namespaceObject.createElement)(resizable_editor, { - enableResizing: enableResizing, - height: sizes.height && !forceFullHeight ? sizes.height : '100%' - }, (0,external_wp_element_namespaceObject.createElement)(editor_canvas, { - enableResizing: enableResizing, - settings: settings, - contentRef: contentRef - }, resizeObserver, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { - className: classnames_default()('edit-site-block-editor__block-list wp-site-blocks', { - 'is-navigation-block': isTemplateTypeNavigation - }), - layout: LAYOUT, - renderAppender: showBlockAppender - }))))), (0,external_wp_element_namespaceObject.createElement)(PageContentFocusManager, { - contentRef: contentRef + // `newSelectedTabId` could technically be falsey if no tab is selected (i.e. + // the initial render) or when we don't want a tab displayed (i.e. the + // sidebar is closed). These cases should both be covered by the `!!` check + // below, so we shouldn't need any additional falsey handling. + const onTabSelect = (0,external_wp_element_namespaceObject.useCallback)(newSelectedTabId => { + if (!!newSelectedTabId) { + enableComplementaryArea(constants_STORE_NAME, newSelectedTabId); + } + }, [enableComplementaryArea]); + return (0,external_React_.createElement)(sidebar_edit_mode_Tabs + // Due to how this component is controlled (via a value from the + // edit-site store), when the sidebar closes the currently selected + // tab can't be found. This causes the component to continuously reset + // the selection to `null` in an infinite loop. Proactively setting + // the selected tab to `null` avoids that. + , { + selectedTabId: isEditorOpen && isEditorSidebarOpened ? sidebarName : null, + onSelect: onTabSelect, + selectOnMove: false + }, (0,external_React_.createElement)(FillContents, { + sidebarName: sidebarName, + isEditingPage: isEditingPage, + supportsGlobalStyles: supportsGlobalStyles })); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js -/** - * WordPress dependencies - */ - - - -/** - * Internal dependencies - */ - - -/** - * Helper method to iterate through all blocks, recursing into allowed inner blocks. - * Returns a flattened object of transformed blocks. - * - * @param {Array} blocks Blocks to flatten. - * @param {Function} transform Transforming function to be applied to each block. If transform returns `undefined`, the block is skipped. - * - * @return {Array} Flattened object. - */ -function flattenBlocks(blocks, transform) { - const result = []; - for (let i = 0; i < blocks.length; i++) { - // Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types, - // we skip it because we only want to render stand-alone page content blocks in the block list. - if (['core/query'].includes(blocks[i].name)) { - continue; - } - const transformedBlock = transform(blocks[i]); - if (transformedBlock) { - result.push(transformedBlock); - } - result.push(...flattenBlocks(blocks[i].innerBlocks, transform)); - } - return result; -} - -/** - * Returns a memoized array of blocks that contain only page content blocks, - * surrounded by a group block to mimic the post editor. - * - * @param {Array} blocks Block list. - * @param {boolean} isPageContentFocused Whether the page content has focus. If `true` return page content blocks. Default `false`. - * - * @return {Array} Page content blocks. - */ -function usePageContentBlocks(blocks, isPageContentFocused = false) { - return (0,external_wp_element_namespaceObject.useMemo)(() => { - if (!isPageContentFocused || !blocks || !blocks.length) { - return []; - } - return [(0,external_wp_blocks_namespaceObject.createBlock)('core/group', { - layout: { - type: 'constrained' - }, - style: { - spacing: { - margin: { - top: '4em' // Mimics the post editor. - } - } - } - }, flattenBlocks(blocks, block => { - if (PAGE_CONTENT_BLOCK_TYPES[block.name]) { - return (0,external_wp_blocks_namespaceObject.createBlock)(block.name); - } - }))]; - }, [blocks, isPageContentFocused]); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js - -/** - * WordPress dependencies - */ - - - - -/** - * Internal dependencies - */ - - - - -const { - ExperimentalBlockEditorProvider: default_block_editor_provider_ExperimentalBlockEditorProvider -} = unlock(external_wp_blockEditor_namespaceObject.privateApis); -const default_block_editor_provider_noop = () => {}; - -/** - * The default block editor provider for the site editor. Typically used when - * the post type is `'wp_template_part'` or `'wp_template'` and allows editing - * of the template and its nested entities. - * - * If the page content focus type is `'hideTemplate'`, the provider will provide - * a set of page content blocks wrapped in a container that, together, - * mimic the look and feel of the post editor and - * allow editing of the page content only. - * - * @param {Object} props - * @param {WPElement} props.children - */ -function DefaultBlockEditorProvider({ - children -}) { - const settings = useSiteEditorSettings(); - const { - templateType, - isTemplateHidden - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getEditedPostType - } = select(store_store); - const { - getPageContentFocusType, - getCanvasMode - } = unlock(select(store_store)); - return { - templateType: getEditedPostType(), - isTemplateHidden: getCanvasMode() === 'edit' && getPageContentFocusType() === 'hideTemplate', - canvasMode: unlock(select(store_store)).getCanvasMode() - }; - }, []); - const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', templateType); - const pageContentBlock = usePageContentBlocks(blocks, isTemplateHidden); - return (0,external_wp_element_namespaceObject.createElement)(default_block_editor_provider_ExperimentalBlockEditorProvider, { - settings: settings, - value: isTemplateHidden && pageContentBlock.length ? pageContentBlock : blocks, - onInput: isTemplateHidden ? default_block_editor_provider_noop : onInput, - onChange: isTemplateHidden ? default_block_editor_provider_noop : onChange, - useSubRegistry: false - }, children); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/block-editor-provider/navigation-block-editor-provider.js - -/** - * WordPress dependencies - */ - - - - - - -/** - * Internal dependencies - */ - - - - -const { - ExperimentalBlockEditorProvider: navigation_block_editor_provider_ExperimentalBlockEditorProvider -} = unlock(external_wp_blockEditor_namespaceObject.privateApis); -const navigation_block_editor_provider_noop = () => {}; - -/** - * Block editor component for editing navigation menus. - * - * Note: Navigation entities require a wrapping Navigation block to provide - * them with some basic layout and styling. Therefore we create a "ghost" block - * and provide it will a reference to the navigation entity ID being edited. - * - * In this scenario it is the **block** that handles syncing the entity content - * whereas for other entities this is handled by entity block editor. - * - * @param {number} navigationMenuId the navigation menu ID - * @return {[WPBlock[], Function, Function]} The block array and setters. - */ -function NavigationBlockEditorProvider({ - children -}) { - const defaultSettings = useSiteEditorSettings(); - const navigationMenuId = (0,external_wp_coreData_namespaceObject.useEntityId)('postType', NAVIGATION_POST_TYPE); - const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => { - return [(0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', { - ref: navigationMenuId, - // As the parent editor is locked with `templateLock`, the template locking - // must be explicitly "unset" on the block itself to allow the user to modify - // the block's content. - templateLock: false - })]; - }, [navigationMenuId]); - const { - isEditMode - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getCanvasMode - } = unlock(select(store_store)); - return { - isEditMode: getCanvasMode() === 'edit' - }; - }, []); - const { - selectBlock, - setBlockEditingMode, - unsetBlockEditingMode - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); - const navigationBlockClientId = blocks && blocks[0]?.clientId; - const settings = (0,external_wp_element_namespaceObject.useMemo)(() => { - return { - ...defaultSettings, - // Lock the editor to allow the root ("ghost") Navigation block only. - templateLock: 'insert', - template: [['core/navigation', {}, []]] - }; - }, [defaultSettings]); - - // Auto-select the Navigation block when entering Navigation focus mode. - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (navigationBlockClientId && isEditMode) { - selectBlock(navigationBlockClientId); - } - }, [navigationBlockClientId, isEditMode, selectBlock]); - - // Set block editing mode to contentOnly when entering Navigation focus mode. - // This ensures that non-content controls on the block will be hidden and thus - // the user can focus on editing the Navigation Menu content only. - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (!navigationBlockClientId) { - return; - } - setBlockEditingMode(navigationBlockClientId, 'contentOnly'); - return () => { - unsetBlockEditingMode(navigationBlockClientId); - }; - }, [navigationBlockClientId, unsetBlockEditingMode, setBlockEditingMode]); - return (0,external_wp_element_namespaceObject.createElement)(navigation_block_editor_provider_ExperimentalBlockEditorProvider, { - settings: settings, - value: blocks, - onInput: navigation_block_editor_provider_noop, - onChange: navigation_block_editor_provider_noop, - useSubRegistry: false - }, children); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/block-editor-provider/index.js - -/** - * WordPress dependencies - */ - - -/** - * Internal dependencies - */ - - - - -function BlockEditorProvider({ - children -}) { - const entityType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostType(), []); - if (entityType === NAVIGATION_POST_TYPE) { - return (0,external_wp_element_namespaceObject.createElement)(NavigationBlockEditorProvider, null, children); - } - return (0,external_wp_element_namespaceObject.createElement)(DefaultBlockEditorProvider, null, children); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/index.js - -/** - * WordPress dependencies - */ - - - -/** - * Internal dependencies - */ - - - - - -const { - PatternsMenuItems -} = unlock(external_wp_patterns_namespaceObject.privateApis); -function BlockEditor() { - return (0,external_wp_element_namespaceObject.createElement)(BlockEditorProvider, null, (0,external_wp_element_namespaceObject.createElement)(TemplatePartConverter, null), (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)(SiteEditorCanvas, null), (0,external_wp_element_namespaceObject.createElement)(PatternsMenuItems, null)); -} - // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js -var lib = __webpack_require__(773); +var lib = __webpack_require__(4132); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/code-editor/index.js /** @@ -31412,20 +35201,20 @@ function CodeEditor() { const { switchEditorMode } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - return (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)("div", { className: "edit-site-code-editor" - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-code-editor__toolbar" - }, (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, { + }, (0,external_React_.createElement)("h2", null, (0,external_wp_i18n_namespaceObject.__)('Editing code')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "tertiary", onClick: () => switchEditorMode('visual'), shortcut: shortcut - }, (0,external_wp_i18n_namespaceObject.__)('Exit code editor'))), (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_wp_i18n_namespaceObject.__)('Exit code editor'))), (0,external_React_.createElement)("div", { className: "edit-site-code-editor__body" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { as: "label", htmlFor: `code-editor-text-area-${instanceId}` - }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, { + }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_React_.createElement)(lib/* default */.A, { autoComplete: "off", dir: "auto", value: realContent, @@ -31452,7 +35241,6 @@ function CodeEditor() { - /** * Internal dependencies */ @@ -31463,14 +35251,8 @@ function KeyboardShortcutsEditMode() { const { getEditorMode } = (0,external_wp_data_namespaceObject.useSelect)(store_store); - const isListViewOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).isListViewOpened(), []); const isBlockInspectorOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(store_store.name) === SIDEBAR_BLOCK, []); const { - redo, - undo - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); - const { - setIsListViewOpened, switchEditorMode, toggleDistractionFree } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); @@ -31508,22 +35290,6 @@ function KeyboardShortcutsEditMode() { } })); }; - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/undo', event => { - undo(); - event.preventDefault(); - }); - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/redo', event => { - redo(); - event.preventDefault(); - }); - - // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar. - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-list-view', () => { - if (isListViewOpen) { - return; - } - setIsListViewOpened(true); - }); (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-block-settings-sidebar', event => { // This shortcut has no known clashes, but use preventDefault to prevent any // obscure shortcuts from triggering. @@ -31549,178 +35315,7 @@ function KeyboardShortcutsEditMode() { }); return null; } -/* harmony default export */ var edit_mode = (KeyboardShortcutsEditMode); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js - -/** - * WordPress dependencies - */ - -const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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" -})); -/* harmony default export */ var library_close = (close_close); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/secondary-sidebar/inserter-sidebar.js - -/** - * WordPress dependencies - */ - - - - - - - - -/** - * Internal dependencies - */ - -function InserterSidebar() { - const { - setIsInserterOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const insertionPoint = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetInsertionPoint(), []); - const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); - const TagName = !isMobile ? external_wp_components_namespaceObject.VisuallyHidden : 'div'; - const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({ - onClose: () => setIsInserterOpened(false), - focusOnMount: null - }); - const libraryRef = (0,external_wp_element_namespaceObject.useRef)(); - (0,external_wp_element_namespaceObject.useEffect)(() => { - libraryRef.current.focusSearch(); - }, []); - return (0,external_wp_element_namespaceObject.createElement)("div", { - ref: inserterDialogRef, - ...inserterDialogProps, - className: "edit-site-editor__inserter-panel" - }, (0,external_wp_element_namespaceObject.createElement)(TagName, { - className: "edit-site-editor__inserter-panel-header" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - icon: library_close, - label: (0,external_wp_i18n_namespaceObject.__)('Close block inserter'), - onClick: () => setIsInserterOpened(false) - })), (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-editor__inserter-panel-content" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, { - showInserterHelpPanel: true, - shouldFocusBlock: isMobile, - rootClientId: insertionPoint.rootClientId, - __experimentalInsertionIndex: insertionPoint.insertionIndex, - __experimentalFilterValue: insertionPoint.filterValue, - ref: libraryRef - }))); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/secondary-sidebar/list-view-sidebar.js - -/** - * WordPress dependencies - */ - - - - - - - - - - - -/** - * Internal dependencies - */ - - -const { - PrivateListView: list_view_sidebar_PrivateListView -} = unlock(external_wp_blockEditor_namespaceObject.privateApis); -function ListViewSidebar({ - listViewToggleElement -}) { - const { - setIsListViewOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - - // This hook handles focus when the sidebar first renders. - const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement'); - - // When closing the list view, focus should return to the toggle button. - const closeListView = (0,external_wp_element_namespaceObject.useCallback)(() => { - setIsListViewOpened(false); - listViewToggleElement?.focus(); - }, [listViewToggleElement, setIsListViewOpened]); - const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => { - if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) { - event.preventDefault(); - closeListView(); - } - }, [closeListView]); - - // Use internal state instead of a ref to make sure that the component - // re-renders when the dropZoneElement updates. - const [dropZoneElement, setDropZoneElement] = (0,external_wp_element_namespaceObject.useState)(null); - - // This ref refers to the sidebar as a whole. - const sidebarRef = (0,external_wp_element_namespaceObject.useRef)(); - // This ref refers to the close button. - const sidebarCloseButtonRef = (0,external_wp_element_namespaceObject.useRef)(); - // This ref refers to the list view application area. - const listViewRef = (0,external_wp_element_namespaceObject.useRef)(); - - /* - * Callback function to handle list view or close button focus. - * - * @return void - */ - function handleSidebarFocus() { - // Either focus the list view or the sidebar close button. Must have a fallback because the list view does not render when there are no blocks. - const listViewApplicationFocus = external_wp_dom_namespaceObject.focus.tabbable.find(listViewRef.current)[0]; - const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : sidebarCloseButtonRef.current; - listViewFocusArea.focus(); - } - const handleToggleListViewShortcut = (0,external_wp_element_namespaceObject.useCallback)(() => { - // If the sidebar has focus, it is safe to close. - if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) { - closeListView(); - } else { - // If the list view or close button does not have focus, focus should be moved to it. - handleSidebarFocus(); - } - }, [closeListView]); - - // This only fires when the sidebar is open because of the conditional rendering. - // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed. - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-list-view', handleToggleListViewShortcut); - return ( - // eslint-disable-next-line jsx-a11y/no-static-element-interactions - (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-editor__list-view-panel", - onKeyDown: closeOnEscape, - ref: sidebarRef - }, (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-editor__list-view-panel-header" - }, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('List View')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - icon: close_small, - label: (0,external_wp_i18n_namespaceObject.__)('Close'), - onClick: closeListView, - ref: sidebarCloseButtonRef - })), (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-editor__list-view-panel-content", - ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([focusOnMountRef, setDropZoneElement, listViewRef]) - }, (0,external_wp_element_namespaceObject.createElement)(list_view_sidebar_PrivateListView, { - dropZoneElement: dropZoneElement - }))) - ); -} +/* harmony default export */ const edit_mode = (KeyboardShortcutsEditMode); ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/welcome-guide/image.js @@ -31728,12 +35323,12 @@ function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) { - return (0,external_wp_element_namespaceObject.createElement)("picture", { + return (0,external_React_.createElement)("picture", { className: "edit-site-welcome-guide__image" - }, (0,external_wp_element_namespaceObject.createElement)("source", { + }, (0,external_React_.createElement)("source", { srcSet: nonAnimatedSrc, media: "(prefers-reduced-motion: reduce)" - }), (0,external_wp_element_namespaceObject.createElement)("img", { + }), (0,external_React_.createElement)("img", { src: animatedSrc, width: "312", height: "240", @@ -31764,24 +35359,24 @@ function WelcomeGuideEditor() { if (!isActive) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Guide, { className: "edit-site-welcome-guide guide-editor", contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the site editor'), finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'), onFinish: () => toggle('core/edit-site', 'welcomeGuide'), pages: [{ - image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { + image: (0,external_React_.createElement)(WelcomeGuideImage, { nonAnimatedSrc: "https://s.w.org/images/block-editor/edit-your-site.svg?1", animatedSrc: "https://s.w.org/images/block-editor/edit-your-site.gif?1" }), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { className: "edit-site-welcome-guide__heading" - }, (0,external_wp_i18n_namespaceObject.__)('Edit your site')), (0,external_wp_element_namespaceObject.createElement)("p", { + }, (0,external_wp_i18n_namespaceObject.__)('Edit your site')), (0,external_React_.createElement)("p", { className: "edit-site-welcome-guide__text" - }, (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", { + }, (0,external_wp_i18n_namespaceObject.__)('Design everything on your site — from the header right down to the footer — using blocks.')), (0,external_React_.createElement)("p", { className: "edit-site-welcome-guide__text" }, (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.'), { - StylesIconImage: (0,external_wp_element_namespaceObject.createElement)("img", { + StylesIconImage: (0,external_React_.createElement)("img", { alt: (0,external_wp_i18n_namespaceObject.__)('styles'), 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" }) @@ -31824,51 +35419,51 @@ function WelcomeGuideStyles() { return null; } const welcomeLabel = (0,external_wp_i18n_namespaceObject.__)('Welcome to Styles'); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Guide, { className: "edit-site-welcome-guide guide-styles", contentLabel: welcomeLabel, finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'), onFinish: () => toggle('core/edit-site', 'welcomeGuideStyles'), pages: [{ - image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { + image: (0,external_React_.createElement)(WelcomeGuideImage, { nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1", animatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.gif?1" }), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { className: "edit-site-welcome-guide__heading" - }, welcomeLabel), (0,external_wp_element_namespaceObject.createElement)("p", { + }, welcomeLabel), (0,external_React_.createElement)("p", { className: "edit-site-welcome-guide__text" }, (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.'))) }, { - image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { + image: (0,external_React_.createElement)(WelcomeGuideImage, { nonAnimatedSrc: "https://s.w.org/images/block-editor/set-the-design.svg?1", animatedSrc: "https://s.w.org/images/block-editor/set-the-design.gif?1" }), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { className: "edit-site-welcome-guide__heading" - }, (0,external_wp_i18n_namespaceObject.__)('Set the design')), (0,external_wp_element_namespaceObject.createElement)("p", { + }, (0,external_wp_i18n_namespaceObject.__)('Set the design')), (0,external_React_.createElement)("p", { className: "edit-site-welcome-guide__text" }, (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!'))) }, { - image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { + image: (0,external_React_.createElement)(WelcomeGuideImage, { nonAnimatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.svg?1", animatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.gif?1" }), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { className: "edit-site-welcome-guide__heading" - }, (0,external_wp_i18n_namespaceObject.__)('Personalize blocks')), (0,external_wp_element_namespaceObject.createElement)("p", { + }, (0,external_wp_i18n_namespaceObject.__)('Personalize blocks')), (0,external_React_.createElement)("p", { className: "edit-site-welcome-guide__text" }, (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.'))) }, { - image: (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideImage, { + image: (0,external_React_.createElement)(WelcomeGuideImage, { nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg", animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif" }), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { className: "edit-site-welcome-guide__heading" - }, (0,external_wp_i18n_namespaceObject.__)('Learn more')), (0,external_wp_element_namespaceObject.createElement)("p", { + }, (0,external_wp_i18n_namespaceObject.__)('Learn more')), (0,external_React_.createElement)("p", { className: "edit-site-welcome-guide__text" - }, (0,external_wp_i18n_namespaceObject.__)('New to block themes and styling your site?'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, { + }, (0,external_wp_i18n_namespaceObject.__)('New to block themes and styling your site?'), ' ', (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/styles-overview/') }, (0,external_wp_i18n_namespaceObject.__)('Here’s a detailed guide to learn how to make the most of it.')))) }] @@ -31897,34 +35492,34 @@ function WelcomeGuidePage() { const isPageActive = !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuidePage'); const isEditorActive = !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'); const { - hasPageContentFocus + isPage } = select(store_store); - return isPageActive && !isEditorActive && hasPageContentFocus(); + return isPageActive && !isEditorActive && isPage(); }, []); if (!isVisible) { return null; } const heading = (0,external_wp_i18n_namespaceObject.__)('Editing a page'); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Guide, { className: "edit-site-welcome-guide guide-page", contentLabel: heading, finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Continue'), onFinish: () => toggle('core/edit-site', 'welcomeGuidePage'), pages: [{ - image: (0,external_wp_element_namespaceObject.createElement)("video", { + image: (0,external_React_.createElement)("video", { className: "edit-site-welcome-guide__video", autoPlay: true, loop: true, muted: true, width: "312", height: "240" - }, (0,external_wp_element_namespaceObject.createElement)("source", { + }, (0,external_React_.createElement)("source", { src: "https://s.w.org/images/block-editor/editing-your-page.mp4", type: "video/mp4" })), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { className: "edit-site-welcome-guide__heading" - }, heading), (0,external_wp_element_namespaceObject.createElement)("p", { + }, heading), (0,external_React_.createElement)("p", { className: "edit-site-welcome-guide__text" }, (0,external_wp_i18n_namespaceObject.__)('It’s now possible to edit page content in the site editor. To customise other parts of the page like the header and footer switch to editing the template using the settings sidebar.'))) }] @@ -31941,6 +35536,7 @@ function WelcomeGuidePage() { + /** * Internal dependencies */ @@ -31953,35 +35549,37 @@ function WelcomeGuideTemplate() { const isTemplateActive = !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuideTemplate'); const isEditorActive = !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'); const { - isPage, - hasPageContentFocus + isPage } = select(store_store); - return isTemplateActive && !isEditorActive && isPage() && !hasPageContentFocus(); + const { + getCurrentPostType + } = select(external_wp_editor_namespaceObject.store); + return isTemplateActive && !isEditorActive && isPage() && getCurrentPostType() === 'wp_template'; }, []); if (!isVisible) { return null; } const heading = (0,external_wp_i18n_namespaceObject.__)('Editing a template'); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Guide, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Guide, { className: "edit-site-welcome-guide guide-template", contentLabel: heading, finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Continue'), onFinish: () => toggle('core/edit-site', 'welcomeGuideTemplate'), pages: [{ - image: (0,external_wp_element_namespaceObject.createElement)("video", { + image: (0,external_React_.createElement)("video", { className: "edit-site-welcome-guide__video", autoPlay: true, loop: true, muted: true, width: "312", height: "240" - }, (0,external_wp_element_namespaceObject.createElement)("source", { + }, (0,external_React_.createElement)("source", { src: "https://s.w.org/images/block-editor/editing-your-template.mp4", type: "video/mp4" })), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("h1", { + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { className: "edit-site-welcome-guide__heading" - }, heading), (0,external_wp_element_namespaceObject.createElement)("p", { + }, heading), (0,external_React_.createElement)("p", { className: "edit-site-welcome-guide__text" }, (0,external_wp_i18n_namespaceObject.__)('Note that the same template can be used by multiple pages, so any changes made here may affect other pages on the site. To switch back to editing the page content click the ‘Back’ button in the toolbar.'))) }] @@ -31998,7 +35596,7 @@ function WelcomeGuideTemplate() { function WelcomeGuide() { - 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), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuidePage, null), (0,external_wp_element_namespaceObject.createElement)(WelcomeGuideTemplate, null)); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(WelcomeGuideEditor, null), (0,external_React_.createElement)(WelcomeGuideStyles, null), (0,external_React_.createElement)(WelcomeGuidePage, null), (0,external_React_.createElement)(WelcomeGuideTemplate, null)); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/start-template-options/index.js @@ -32015,28 +35613,25 @@ function WelcomeGuide() { + /** * Internal dependencies */ - - - function useFallbackTemplateContent(slug, isCustom = false) { - const [templateContent, setTemplateContent] = (0,external_wp_element_namespaceObject.useState)(''); - (0,external_wp_element_namespaceObject.useEffect)(() => { - external_wp_apiFetch_default()({ - path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/templates/lookup', { - slug, - is_custom: isCustom, - ignore_empty: true - }) - }).then(({ - content - }) => setTemplateContent(content.raw)); - }, [isCustom, slug]); - return templateContent; + return (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEntityRecord, + getDefaultTemplateId + } = select(external_wp_coreData_namespaceObject.store); + const templateId = getDefaultTemplateId({ + slug, + is_custom: isCustom, + ignore_empty: true + }); + return templateId ? getEntityRecord('postType', constants_TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined; + }, [slug, isCustom]); } function useStartPatterns(fallbackContent) { const { @@ -32048,17 +35643,15 @@ function useStartPatterns(fallbackContent) { getEditedPostId } = select(store_store); const { - getEntityRecord + getEntityRecord, + getBlockPatterns } = select(external_wp_coreData_namespaceObject.store); const postId = getEditedPostId(); const postType = getEditedPostType(); const record = getEntityRecord('postType', postType, postId); - const { - getSettings - } = select(external_wp_blockEditor_namespaceObject.store); return { slug: record.slug, - patterns: getSettings().__experimentalBlockPatterns + patterns: getBlockPatterns() }; }, []); const currentThemeStylesheet = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet); @@ -32102,7 +35695,7 @@ function PatternSelection({ const [,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', postType); const blockPatterns = useStartPatterns(fallbackContent); const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, { + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, { blockPatterns: blockPatterns, shownPatterns: shownBlockPatterns, onClickPattern: (pattern, blocks) => { @@ -32123,16 +35716,16 @@ function StartModal({ if (!fallbackContent) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { className: "edit-site-start-template-options__modal", title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'), closeLabel: (0,external_wp_i18n_namespaceObject.__)('Cancel'), focusOnMount: "firstElement", onRequestClose: onClose, isFullScreen: true - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-start-template-options__modal-content" - }, (0,external_wp_element_namespaceObject.createElement)(PatternSelection, { + }, (0,external_React_.createElement)(PatternSelection, { fallbackContent: fallbackContent, slug: slug, isCustom: isCustom, @@ -32140,11 +35733,11 @@ function StartModal({ onChoosePattern: () => { onClose(); } - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { className: "edit-site-start-template-options__modal__actions", justify: "flex-end", expanded: false - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "tertiary", onClick: onClose }, (0,external_wp_i18n_namespaceObject.__)('Skip'))))); @@ -32174,7 +35767,7 @@ function StartTemplateOptions() { const templateRecord = getEditedEntityRecord('postType', _postType, postId); const hasEdits = hasEditsForEntityRecord('postType', _postType, postId); return { - shouldOpenModal: !hasEdits && '' === templateRecord.content && TEMPLATE_POST_TYPE === _postType && !select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'), + shouldOpenModal: !hasEdits && '' === templateRecord.content && constants_TEMPLATE_POST_TYPE === _postType && !select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'), slug: templateRecord.slug, isCustom: templateRecord.is_custom, postType: _postType @@ -32183,7 +35776,7 @@ function StartTemplateOptions() { if (modalState === START_TEMPLATE_MODAL_STATES.INITIAL && !shouldOpenModal || modalState === START_TEMPLATE_MODAL_STATES.CLOSED) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(StartModal, { + return (0,external_React_.createElement)(StartModal, { slug: slug, isCustom: isCustom, postType: postType, @@ -32227,7 +35820,7 @@ function useGlobalStylesRenderer() { styles: [...nonGlobalStyles, ...styles], __experimentalFeatures: settings }); - }, [styles, settings]); + }, [styles, settings, updateSettings, getSettings]); } function GlobalStylesRenderer() { useGlobalStylesRenderer(); @@ -32267,13 +35860,12 @@ function useTitle(title) { } if (title && siteTitle) { // @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68 - const formattedTitle = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */ - (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s — WordPress'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle)); + const formattedTitle = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: Admin document title. 1: Admin screen name, 2: Network or site name. */ + (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s ‹ Editor — WordPress'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle)); document.title = formattedTitle; // Announce title on route change for screen readers. - (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The page title that is currently displaying. */ - (0,external_wp_i18n_namespaceObject.__)('Now displaying: %s'), document.title), 'assertive'); + (0,external_wp_a11y_namespaceObject.speak)(title, 'assertive'); } }, [title, siteTitle, location]); } @@ -32323,24 +35915,512 @@ function CanvasLoader({ total: finished + resolving }; }, []); - return (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)("div", { className: "edit-site-canvas-loader" - }, (0,external_wp_element_namespaceObject.createElement)(Theme, { + }, (0,external_React_.createElement)(Theme, { accent: indicatorColor, background: backgroundColor - }, (0,external_wp_element_namespaceObject.createElement)(canvas_loader_ProgressBar, { + }, (0,external_React_.createElement)(canvas_loader_ProgressBar, { id: id, max: total, value: elapsed }))); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/editor/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/editor-canvas.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + + +/** + * Internal dependencies + */ + + + +const { + EditorCanvas: EditorCanvasRoot +} = unlock(external_wp_editor_namespaceObject.privateApis); +function EditorCanvas({ + enableResizing, + settings, + children, + ...props +}) { + const { + hasBlocks, + isFocusMode, + templateType, + canvasMode, + isZoomOutMode + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getBlockCount, + __unstableGetEditorMode + } = select(external_wp_blockEditor_namespaceObject.store); + const { + getEditedPostType, + getCanvasMode + } = unlock(select(store_store)); + const _templateType = getEditedPostType(); + return { + templateType: _templateType, + isFocusMode: FOCUSABLE_ENTITIES.includes(_templateType), + isZoomOutMode: __unstableGetEditorMode() === 'zoom-out', + canvasMode: getCanvasMode(), + hasBlocks: !!getBlockCount() + }; + }, []); + const { + setCanvasMode + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false); + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (canvasMode === 'edit') { + setIsFocused(false); + } + }, [canvasMode]); + const viewModeProps = { + 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Editor Canvas'), + role: 'button', + tabIndex: 0, + onFocus: () => setIsFocused(true), + onBlur: () => setIsFocused(false), + onKeyDown: event => { + const { + keyCode + } = event; + if (keyCode === external_wp_keycodes_namespaceObject.ENTER || keyCode === external_wp_keycodes_namespaceObject.SPACE) { + event.preventDefault(); + setCanvasMode('edit'); + } + }, + onClick: () => setCanvasMode('edit'), + readonly: true + }; + const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE; + const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode; + // Hide the appender when: + // - In navigation focus mode (should only allow the root Nav block). + // - In view mode (i.e. not editing). + const showBlockAppender = isNavigationFocusMode && hasBlocks || canvasMode === 'view' ? false : undefined; + const styles = (0,external_wp_element_namespaceObject.useMemo)(() => [...settings.styles, { + // Forming a "block formatting context" to prevent margin collapsing. + // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context + + css: `.is-root-container{display:flow-root;${ + // Some themes will have `min-height: 100vh` for the root container, + // which isn't a requirement in auto resize mode. + enableResizing ? 'min-height:0!important;' : ''}}body{position:relative; ${canvasMode === 'view' ? 'cursor: pointer; min-height: 100vh;' : ''}}}` + }], [settings.styles, enableResizing, canvasMode]); + return (0,external_React_.createElement)(EditorCanvasRoot, { + className: classnames_default()('edit-site-editor-canvas__block-list', { + 'is-navigation-block': isTemplateTypeNavigation + }), + renderAppender: showBlockAppender, + styles: styles, + iframeProps: { + expand: isZoomOutMode, + scale: isZoomOutMode ? 0.45 : undefined, + frameSize: isZoomOutMode ? 100 : undefined, + className: classnames_default()('edit-site-visual-editor__editor-canvas', { + 'is-focused': isFocused && canvasMode === 'view' + }), + ...props, + ...(canvasMode === 'view' ? viewModeProps : {}) + } + }, children); +} +/* harmony default export */ const editor_canvas = (EditorCanvas); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/use-navigate-to-entity-record.js +/** + * WordPress dependencies + */ + + + +/** + * Internal dependencies + */ + +const { + useHistory: use_navigate_to_entity_record_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +function useNavigateToEntityRecord() { + const history = use_navigate_to_entity_record_useHistory(); + const onNavigateToEntityRecord = (0,external_wp_element_namespaceObject.useCallback)(params => { + history.push({ + ...params, + focusMode: true, + canvas: 'edit' + }); + }, [history]); + return onNavigateToEntityRecord; +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/use-site-editor-settings.js +/** + * WordPress dependencies + */ + + + + + + + +/** + * Internal dependencies + */ + + + + +const { + useBlockEditorSettings +} = unlock(external_wp_editor_namespaceObject.privateApis); +const { + useLocation: use_site_editor_settings_useLocation, + useHistory: use_site_editor_settings_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +function useArchiveLabel(templateSlug) { + const taxonomyMatches = templateSlug?.match(/^(category|tag|taxonomy-([^-]+))$|^(((category|tag)|taxonomy-([^-]+))-(.+))$/); + let taxonomy; + let term; + let isAuthor = false; + let authorSlug; + if (taxonomyMatches) { + // If is for a all taxonomies of a type + if (taxonomyMatches[1]) { + taxonomy = taxonomyMatches[2] ? taxonomyMatches[2] : taxonomyMatches[1]; + } + // If is for a all taxonomies of a type + else if (taxonomyMatches[3]) { + taxonomy = taxonomyMatches[6] ? taxonomyMatches[6] : taxonomyMatches[4]; + term = taxonomyMatches[7]; + } + taxonomy = taxonomy === 'tag' ? 'post_tag' : taxonomy; + + //getTaxonomy( 'category' ); + //wp.data.select('core').getEntityRecords( 'taxonomy', 'category', {slug: 'newcat'} ); + } else { + const authorMatches = templateSlug?.match(/^(author)$|^author-(.+)$/); + if (authorMatches) { + isAuthor = true; + if (authorMatches[2]) { + authorSlug = authorMatches[2]; + } + } + } + return (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEntityRecords, + getTaxonomy, + getAuthors + } = select(external_wp_coreData_namespaceObject.store); + let archiveTypeLabel; + let archiveNameLabel; + if (taxonomy) { + archiveTypeLabel = getTaxonomy(taxonomy)?.labels?.singular_name; + } + if (term) { + const records = getEntityRecords('taxonomy', taxonomy, { + slug: term, + per_page: 1 + }); + if (records && records[0]) { + archiveNameLabel = records[0].name; + } + } + if (isAuthor) { + archiveTypeLabel = 'Author'; + if (authorSlug) { + const authorRecords = getAuthors({ + slug: authorSlug + }); + if (authorRecords && authorRecords[0]) { + archiveNameLabel = authorRecords[0].name; + } + } + } + return { + archiveTypeLabel, + archiveNameLabel + }; + }, [authorSlug, isAuthor, taxonomy, term]); +} +function useNavigateToPreviousEntityRecord() { + const location = use_site_editor_settings_useLocation(); + const previousLocation = (0,external_wp_compose_namespaceObject.usePrevious)(location); + const history = use_site_editor_settings_useHistory(); + const goBack = (0,external_wp_element_namespaceObject.useMemo)(() => { + const isFocusMode = location.params.focusMode || location.params.postId && FOCUSABLE_ENTITIES.includes(location.params.postType); + const didComeFromEditorCanvas = previousLocation?.params.canvas === 'edit'; + const showBackButton = isFocusMode && didComeFromEditorCanvas; + return showBackButton ? () => history.back() : undefined; + // Disable reason: previousLocation changes when the component updates for any reason, not + // just when location changes. Until this is fixed we can't add it to deps. See + // https://github.com/WordPress/gutenberg/pull/58710#discussion_r1479219465. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [location, history]); + return goBack; +} +function useSpecificEditorSettings() { + const onNavigateToEntityRecord = useNavigateToEntityRecord(); + const { + templateSlug, + canvasMode, + settings, + postWithTemplate + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEditedPostType, + getEditedPostId, + getEditedPostContext, + getCanvasMode, + getSettings + } = unlock(select(store_store)); + const { + getEditedEntityRecord + } = select(external_wp_coreData_namespaceObject.store); + const usedPostType = getEditedPostType(); + const usedPostId = getEditedPostId(); + const _record = getEditedEntityRecord('postType', usedPostType, usedPostId); + const _context = getEditedPostContext(); + return { + templateSlug: _record.slug, + canvasMode: getCanvasMode(), + settings: getSettings(), + postWithTemplate: _context?.postId + }; + }, []); + const archiveLabels = useArchiveLabel(templateSlug); + const defaultRenderingMode = postWithTemplate ? 'template-locked' : 'post-only'; + const onNavigateToPreviousEntityRecord = useNavigateToPreviousEntityRecord(); + const defaultEditorSettings = (0,external_wp_element_namespaceObject.useMemo)(() => { + return { + ...settings, + richEditingEnabled: true, + supportsTemplateMode: true, + focusMode: canvasMode !== 'view', + defaultRenderingMode, + onNavigateToEntityRecord, + onNavigateToPreviousEntityRecord, + // I wonder if they should be set in the post editor too + __experimentalArchiveTitleTypeLabel: archiveLabels.archiveTypeLabel, + __experimentalArchiveTitleNameLabel: archiveLabels.archiveNameLabel + }; + }, [settings, canvasMode, defaultRenderingMode, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, archiveLabels.archiveTypeLabel, archiveLabels.archiveNameLabel]); + return defaultEditorSettings; +} +function useSiteEditorSettings() { + const defaultEditorSettings = useSpecificEditorSettings(); + const { + postType, + postId + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEditedPostType, + getEditedPostId + } = unlock(select(store_store)); + const usedPostType = getEditedPostType(); + const usedPostId = getEditedPostId(); + return { + postType: usedPostType, + postId: usedPostId + }; + }, []); + return useBlockEditorSettings(defaultEditorSettings, postType, postId); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/site-editor-canvas.js /** * External dependencies */ +/** + * WordPress dependencies + */ + + + +/** + * Internal dependencies + */ + + + + + + + + +const { + useLocation: site_editor_canvas_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); +function SiteEditorCanvas() { + const location = site_editor_canvas_useLocation(); + const { + templateType, + isFocusableEntity, + isViewMode + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getEditedPostType, + getCanvasMode + } = unlock(select(store_store)); + const _templateType = getEditedPostType(); + return { + templateType: _templateType, + isFocusableEntity: FOCUSABLE_ENTITIES.includes(_templateType), + isViewMode: getCanvasMode() === 'view' + }; + }, []); + const isFocusMode = location.params.focusMode || isFocusableEntity; + const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); + const settings = useSiteEditorSettings(); + const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<'); + const enableResizing = isFocusMode && !isViewMode && + // Disable resizing in mobile viewport. + !isMobileViewport && + // Disable resizing when editing a template in focus mode. + templateType !== constants_TEMPLATE_POST_TYPE; + const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE; + const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode; + const forceFullHeight = isNavigationFocusMode; + return (0,external_React_.createElement)(editor_canvas_container.Slot, null, ([editorCanvasView]) => editorCanvasView ? (0,external_React_.createElement)("div", { + className: "edit-site-visual-editor is-focus-mode" + }, editorCanvasView) : (0,external_React_.createElement)("div", { + className: classnames_default()('edit-site-visual-editor', { + 'is-focus-mode': isFocusMode || !!editorCanvasView, + 'is-view-mode': isViewMode + }) + }, (0,external_React_.createElement)(resizable_editor, { + enableResizing: enableResizing, + height: sizes.height && !forceFullHeight ? sizes.height : '100%' + }, (0,external_React_.createElement)(editor_canvas, { + enableResizing: enableResizing, + settings: settings + }, resizeObserver)))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/convert-to-regular.js + +/** + * WordPress dependencies + */ + + + + +function ConvertToRegularBlocks({ + clientId, + onClose +}) { + const { + getBlocks + } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store); + const { + replaceBlocks + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); + const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]); + if (!canRemove) { + return null; + } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + onClick: () => { + replaceBlocks(clientId, getBlocks(clientId)); + onClose(); + } + }, (0,external_wp_i18n_namespaceObject.__)('Detach')); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/convert-to-template-part.js + +/** + * WordPress dependencies + */ + + + + + + + + + +/** + * Internal dependencies + */ + + +function ConvertToTemplatePart({ + clientIds, + blocks +}) { + const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); + const { + replaceBlocks + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); + const { + createSuccessNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const { + canCreate + } = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + supportsTemplatePartsMode + } = select(store_store).getSettings(); + return { + canCreate: !supportsTemplatePartsMode + }; + }, []); + if (!canCreate) { + return null; + } + const onConvert = async templatePart => { + replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', { + slug: templatePart.slug, + theme: templatePart.theme + })); + createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), { + type: 'snackbar' + }); + + // The modal and this component will be unmounted because of `replaceBlocks` above, + // so no need to call `closeModal` or `onClose`. + }; + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + icon: symbol_filled, + onClick: () => { + setIsModalOpen(true); + }, + "aria-expanded": isModalOpen, + "aria-haspopup": "dialog" + }, (0,external_wp_i18n_namespaceObject.__)('Create template part')), isModalOpen && (0,external_React_.createElement)(CreateTemplatePartModal, { + closeModal: () => { + setIsModalOpen(false); + }, + blocks: blocks, + onCreate: onConvert + })); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/index.js /** * WordPress dependencies @@ -32348,6 +36428,51 @@ function CanvasLoader({ +/** + * Internal dependencies + */ + + +function TemplatePartConverter() { + return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, ({ + selectedClientIds, + onClose + }) => (0,external_React_.createElement)(TemplatePartConverterMenuItem, { + clientIds: selectedClientIds, + onClose: onClose + })); +} +function TemplatePartConverterMenuItem({ + clientIds, + onClose +}) { + const blocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds), [clientIds]); + + // Allow converting a single template part to standard blocks. + if (blocks.length === 1 && blocks[0]?.name === 'core/template-part') { + return (0,external_React_.createElement)(ConvertToRegularBlocks, { + clientId: clientIds[0], + onClose: onClose + }); + } + return (0,external_React_.createElement)(ConvertToTemplatePart, { + clientIds: clientIds, + blocks: blocks + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/editor/index.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + @@ -32378,6 +36503,11 @@ function CanvasLoader({ const { BlockRemovalWarningModal } = unlock(external_wp_blockEditor_namespaceObject.privateApis); +const { + ExperimentalEditorProvider: EditorProvider, + InserterSidebar, + ListViewSidebar +} = unlock(external_wp_editor_namespaceObject.privateApis); const interfaceLabels = { /* translators: accessibility text for the editor content landmark region. */ body: (0,external_wp_i18n_namespaceObject.__)('Editor content'), @@ -32394,10 +36524,10 @@ const interfaceLabels = { const blockRemovalRules = { 'core/query': (0,external_wp_i18n_namespaceObject.__)('Query Loop displays a list of posts or pages.'), 'core/post-content': (0,external_wp_i18n_namespaceObject.__)('Post Content displays the content of a post or page.'), - 'core/post-template': (0,external_wp_i18n_namespaceObject.__)('Post Template displays each post or page in a Query Loop.') + 'core/post-template': (0,external_wp_i18n_namespaceObject.__)('Post Template displays each post or page in a Query Loop.'), + 'bindings/core/pattern-overrides': (0,external_wp_i18n_namespaceObject.__)('Blocks from synced patterns that can have overriden content.') }; function Editor({ - listViewToggleElement, isLoading }) { const { @@ -32406,28 +36536,30 @@ function Editor({ isLoaded: hasLoadedPost } = useEditedEntityRecord(); const { - id: editedPostId, type: editedPostType } = editedPost; + const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); const { context, + contextPost, editorMode, canvasMode, blockEditorMode, isRightSidebarOpen, isInserterOpen, isListViewOpen, + isDistractionFree, showIconLabels, showBlockBreadcrumbs, - hasPageContentFocus + postTypeLabel } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { + get + } = select(external_wp_preferences_namespaceObject.store); + const { getEditedPostContext, getEditorMode, - getCanvasMode, - isInserterOpened, - isListViewOpened, - hasPageContentFocus: _hasPageContentFocus + getCanvasMode } = unlock(select(store_store)); const { __unstableGetEditorMode @@ -32435,110 +36567,92 @@ function Editor({ const { getActiveComplementaryArea } = select(store); + const { + getEntityRecord + } = select(external_wp_coreData_namespaceObject.store); + const { + isInserterOpened, + isListViewOpened, + getPostTypeLabel + } = select(external_wp_editor_namespaceObject.store); + const _context = getEditedPostContext(); // The currently selected entity to display. // Typically template or template part in the site editor. return { - context: getEditedPostContext(), + context: _context, + contextPost: _context?.postId ? getEntityRecord('postType', _context.postType, _context.postId) : undefined, editorMode: getEditorMode(), canvasMode: getCanvasMode(), blockEditorMode: __unstableGetEditorMode(), isInserterOpen: isInserterOpened(), isListViewOpen: isListViewOpened(), isRightSidebarOpen: getActiveComplementaryArea(store_store.name), - showIconLabels: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showIconLabels'), - showBlockBreadcrumbs: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showBlockBreadcrumbs'), - hasPageContentFocus: _hasPageContentFocus() + isDistractionFree: get('core', 'distractionFree'), + showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'), + showIconLabels: get('core', 'showIconLabels'), + postTypeLabel: getPostTypeLabel() }; }, []); - const { - setEditedPostContext - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); const isViewMode = canvasMode === 'view'; const isEditMode = canvasMode === 'edit'; const showVisualEditor = isViewMode || editorMode === 'visual'; - const shouldShowBlockBreadcrumbs = showBlockBreadcrumbs && isEditMode && showVisualEditor && blockEditorMode !== 'zoom-out'; + const shouldShowBlockBreadcrumbs = !isDistractionFree && showBlockBreadcrumbs && isEditMode && showVisualEditor && blockEditorMode !== 'zoom-out'; const shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen; const shouldShowListView = isEditMode && showVisualEditor && isListViewOpen; const secondarySidebarLabel = isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View') : (0,external_wp_i18n_namespaceObject.__)('Block Library'); - const blockContext = (0,external_wp_element_namespaceObject.useMemo)(() => { - const { - postType, - postId, - ...nonPostFields - } = context !== null && context !== void 0 ? context : {}; - return { - ...(hasPageContentFocus ? context : nonPostFields), - queryContext: [context?.queryContext || { - page: 1 - }, newQueryContext => setEditedPostContext({ - ...context, - queryContext: { - ...context?.queryContext, - ...newQueryContext - } - })] - }; - }, [hasPageContentFocus, context, setEditedPostContext]); + const postWithTemplate = !!context?.postId; let title; if (hasLoadedPost) { var _POST_TYPE_LABELS$edi; title = (0,external_wp_i18n_namespaceObject.sprintf)( - // translators: A breadcrumb trail in browser tab. %1$s: title of template being edited, %2$s: type of template (Template or Template Part). - (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s ‹ Editor'), getTitle(), (_POST_TYPE_LABELS$edi = POST_TYPE_LABELS[editedPostType]) !== null && _POST_TYPE_LABELS$edi !== void 0 ? _POST_TYPE_LABELS$edi : POST_TYPE_LABELS[TEMPLATE_POST_TYPE]); + // translators: A breadcrumb trail for the Admin document title. %1$s: title of template being edited, %2$s: type of template (Template or Template Part). + (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s'), getTitle(), (_POST_TYPE_LABELS$edi = POST_TYPE_LABELS[editedPostType]) !== null && _POST_TYPE_LABELS$edi !== void 0 ? _POST_TYPE_LABELS$edi : POST_TYPE_LABELS[constants_TEMPLATE_POST_TYPE]); } // Only announce the title once the editor is ready to prevent "Replace" // action in <URLQueryController> from double-announcing. useTitle(hasLoadedPost && title); const loadingProgressId = (0,external_wp_compose_namespaceObject.useInstanceId)(CanvasLoader, 'edit-site-editor__loading-progress'); - const contentProps = isLoading ? { - 'aria-busy': 'true', - 'aria-describedby': loadingProgressId - } : undefined; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isLoading ? (0,external_wp_element_namespaceObject.createElement)(CanvasLoader, { + const settings = useSpecificEditorSettings(); + const isReady = !isLoading && (postWithTemplate && !!contextPost && !!editedPost || !postWithTemplate && !!editedPost); + return (0,external_React_.createElement)(external_React_.Fragment, null, !isReady ? (0,external_React_.createElement)(CanvasLoader, { id: loadingProgressId - }) : null, isEditMode && (0,external_wp_element_namespaceObject.createElement)(WelcomeGuide, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, { - kind: "root", - type: "site" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, { - kind: "postType", - type: editedPostType, - id: editedPostId - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockContextProvider, { - value: blockContext - }, (0,external_wp_element_namespaceObject.createElement)(SidebarComplementaryAreaFills, null), isEditMode && (0,external_wp_element_namespaceObject.createElement)(StartTemplateOptions, null), (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, { - isDistractionFree: true, + }) : null, isEditMode && (0,external_React_.createElement)(WelcomeGuide, null), hasLoadedPost && !editedPost && (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { + status: "warning", + isDismissible: false + }, (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")), isReady && (0,external_React_.createElement)(EditorProvider, { + post: postWithTemplate ? contextPost : editedPost, + __unstableTemplate: postWithTemplate ? editedPost : undefined, + settings: settings, + useSubRegistry: false + }, (0,external_React_.createElement)(SidebarComplementaryAreaFills, null), isEditMode && (0,external_React_.createElement)(StartTemplateOptions, null), (0,external_React_.createElement)(interface_skeleton, { + isDistractionFree: isDistractionFree, enableRegionNavigation: false, className: classnames_default()('edit-site-editor__interface-skeleton', { - 'show-icon-labels': showIconLabels, - 'is-loading': isLoading + 'show-icon-labels': showIconLabels }), - notices: (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null), - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesRenderer, null), isEditMode && (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorNotices, null), showVisualEditor && editedPost && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEditor, null), (0,external_wp_element_namespaceObject.createElement)(BlockRemovalWarningModal, { + notices: (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null), + content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(GlobalStylesRenderer, null), isEditMode && (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorNotices, null), showVisualEditor && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(TemplatePartConverter, null), (0,external_React_.createElement)(SidebarInspectorFill, null, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null)), !isLargeViewport && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockToolbar, { + hideDragHandle: true + }), (0,external_React_.createElement)(SiteEditorCanvas, null), (0,external_React_.createElement)(BlockRemovalWarningModal, { rules: blockRemovalRules - })), editorMode === 'text' && editedPost && isEditMode && (0,external_wp_element_namespaceObject.createElement)(CodeEditor, null), hasLoadedPost && !editedPost && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, { - status: "warning", - isDismissible: false - }, (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")), isEditMode && (0,external_wp_element_namespaceObject.createElement)(edit_mode, null)), - contentProps: contentProps, - secondarySidebar: isEditMode && (shouldShowInserter && (0,external_wp_element_namespaceObject.createElement)(InserterSidebar, null) || shouldShowListView && (0,external_wp_element_namespaceObject.createElement)(ListViewSidebar, { - listViewToggleElement: listViewToggleElement - })), - sidebar: isEditMode && isRightSidebarOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, { + }), (0,external_React_.createElement)(PatternModal, null)), editorMode === 'text' && isEditMode && (0,external_React_.createElement)(CodeEditor, null), isEditMode && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(edit_mode, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorKeyboardShortcutsRegister, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorKeyboardShortcuts, null))), + secondarySidebar: isEditMode && (shouldShowInserter && (0,external_React_.createElement)(InserterSidebar, null) || shouldShowListView && (0,external_React_.createElement)(ListViewSidebar, null)), + sidebar: !isDistractionFree && isEditMode && isRightSidebarOpen && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(complementary_area.Slot, { scope: "core/edit-site" - }), (0,external_wp_element_namespaceObject.createElement)(SidebarFixedBottomSlot, null)), - footer: shouldShowBlockBreadcrumbs && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, { - rootLabelText: hasPageContentFocus ? (0,external_wp_i18n_namespaceObject.__)('Page') : (0,external_wp_i18n_namespaceObject.__)('Template') + })), + footer: shouldShowBlockBreadcrumbs && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, { + rootLabelText: postTypeLabel }), labels: { ...interfaceLabels, secondarySidebar: secondarySidebarLabel } - }))))); + }))); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/error-boundary/warning.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/pagination.js /** * WordPress dependencies @@ -32547,31 +36661,81 @@ function Editor({ -function CopyButton({ - text, - children -}) { - const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "secondary", - ref: ref - }, children); -} -function ErrorBoundaryWarning({ - message, - error +const pagination_Pagination = (0,external_wp_element_namespaceObject.memo)(function Pagination({ + view, + onChangeView, + paginationInfo: { + totalItems = 0, + totalPages + } }) { - const actions = [(0,external_wp_element_namespaceObject.createElement)(CopyButton, { - key: "copy-error", - text: error.stack - }, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))]; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, { - className: "editor-error-boundary", - actions: actions - }, message); -} + if (!totalItems || !totalPages) { + return null; + } + return !!totalItems && totalPages !== 1 && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + expanded: false, + spacing: 6, + justify: "end", + className: "dataviews-pagination" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "flex-start", + expanded: false, + spacing: 2, + className: "dataviews-pagination__page-selection" + }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %s: Total number of pages. + (0,external_wp_i18n_namespaceObject._x)('Page <CurrentPageControl /> of %s', 'paging'), totalPages), { + CurrentPageControl: (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { + "aria-label": (0,external_wp_i18n_namespaceObject.__)('Current page'), + value: view.page, + options: Array.from(Array(totalPages)).map((_, i) => { + const page = i + 1; + return { + value: page, + label: page + }; + }), + onChange: newValue => { + onChangeView({ + ...view, + page: +newValue + }); + }, + size: 'compact', + __nextHasNoMarginBottom: true + }) + })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + expanded: false, + spacing: 1 + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + onClick: () => onChangeView({ + ...view, + page: view.page - 1 + }), + disabled: view.page === 1, + __experimentalIsFocusable: true, + label: (0,external_wp_i18n_namespaceObject.__)('Previous page'), + icon: chevron_left, + showTooltip: true, + size: "compact", + tooltipPosition: "top" + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + onClick: () => onChangeView({ + ...view, + page: view.page + 1 + }), + disabled: view.page >= totalPages, + __experimentalIsFocusable: true, + label: (0,external_wp_i18n_namespaceObject.__)('Next page'), + icon: chevron_right, + showTooltip: true, + size: "compact", + tooltipPosition: "top" + }))); +}); +/* harmony default export */ const pagination = (pagination_Pagination); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/error-boundary/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/view-actions.js /** * WordPress dependencies @@ -32580,1393 +36744,2484 @@ function ErrorBoundaryWarning({ + /** * Internal dependencies */ -class ErrorBoundary extends external_wp_element_namespaceObject.Component { - constructor() { - super(...arguments); - this.state = { - error: null - }; + +const { + DropdownMenuV2: view_actions_DropdownMenu, + DropdownMenuGroupV2: view_actions_DropdownMenuGroup, + DropdownMenuItemV2: view_actions_DropdownMenuItem, + DropdownMenuRadioItemV2: view_actions_DropdownMenuRadioItem, + DropdownMenuCheckboxItemV2: DropdownMenuCheckboxItem, + DropdownMenuItemLabelV2: view_actions_DropdownMenuItemLabel +} = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); +function ViewTypeMenu({ + view, + onChangeView, + supportedLayouts +}) { + let _availableViews = VIEW_LAYOUTS; + if (supportedLayouts) { + _availableViews = _availableViews.filter(_view => supportedLayouts.includes(_view.type)); } - componentDidCatch(error) { - (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error); + if (_availableViews.length === 1) { + return null; } - static getDerivedStateFromError(error) { - return { - error - }; + const activeView = _availableViews.find(v => view.type === v.type); + return (0,external_React_.createElement)(view_actions_DropdownMenu, { + trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, { + suffix: (0,external_React_.createElement)("span", { + "aria-hidden": "true" + }, activeView.label) + }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Layout'))) + }, _availableViews.map(availableView => { + return (0,external_React_.createElement)(view_actions_DropdownMenuRadioItem, { + key: availableView.type, + value: availableView.type, + name: "view-actions-available-view", + checked: availableView.type === view.type, + hideOnClick: true, + onChange: e => { + onChangeView({ + ...view, + type: e.target.value + }); + } + }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, availableView.label)); + })); +} +const PAGE_SIZE_VALUES = [10, 20, 50, 100]; +function PageSizeMenu({ + view, + onChangeView +}) { + return (0,external_React_.createElement)(view_actions_DropdownMenu, { + trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, { + suffix: (0,external_React_.createElement)("span", { + "aria-hidden": "true" + }, view.perPage) + }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Items per page'))) + }, PAGE_SIZE_VALUES.map(size => { + return (0,external_React_.createElement)(view_actions_DropdownMenuRadioItem, { + key: size, + value: size, + name: "view-actions-page-size", + checked: view.perPage === size, + onChange: () => { + onChangeView({ + ...view, + // `e.target.value` holds the same value as `size` but as a string, + // so we use `size` directly to avoid parsing to int. + perPage: size, + page: 1 + }); + } + }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, size)); + })); +} +function FieldsVisibilityMenu({ + view, + onChangeView, + fields +}) { + const hidableFields = fields.filter(field => field.enableHiding !== false && field.id !== view.layout.mediaField); + if (!hidableFields?.length) { + return null; } - render() { - if (!this.state.error) { - return this.props.children; - } - return (0,external_wp_element_namespaceObject.createElement)(ErrorBoundaryWarning, { - message: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'), - error: this.state.error - }); + return (0,external_React_.createElement)(view_actions_DropdownMenu, { + trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, null, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Fields'))) + }, hidableFields?.map(field => { + return (0,external_React_.createElement)(DropdownMenuCheckboxItem, { + key: field.id, + value: field.id, + checked: !view.hiddenFields?.includes(field.id), + onChange: () => { + onChangeView({ + ...view, + hiddenFields: view.hiddenFields?.includes(field.id) ? view.hiddenFields.filter(id => id !== field.id) : [...(view.hiddenFields || []), field.id] + }); + } + }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, field.header)); + })); +} +function SortMenu({ + fields, + view, + onChangeView +}) { + const sortableFields = fields.filter(field => field.enableSorting !== false); + if (!sortableFields?.length) { + return null; } + const currentSortedField = fields.find(field => field.id === view.sort?.field); + return (0,external_React_.createElement)(view_actions_DropdownMenu, { + trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, { + suffix: (0,external_React_.createElement)("span", { + "aria-hidden": "true" + }, currentSortedField?.header) + }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Sort by'))) + }, sortableFields?.map(field => { + const sortedDirection = view.sort?.direction; + return (0,external_React_.createElement)(view_actions_DropdownMenu, { + key: field.id, + trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, null, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, field.header)), + style: { + minWidth: '220px' + } + }, Object.entries(SORTING_DIRECTIONS).map(([direction, info]) => { + const isChecked = currentSortedField !== undefined && sortedDirection === direction && field.id === currentSortedField.id; + const value = `${field.id}-${direction}`; + return (0,external_React_.createElement)(view_actions_DropdownMenuRadioItem, { + key: value + // All sorting radio items share the same name, so that + // selecting a sorting option automatically deselects the + // previously selected one, even if it is displayed in + // another submenu. The field and direction are passed via + // the `value` prop. + , + name: "view-actions-sorting", + value: value, + checked: isChecked, + onChange: () => { + onChangeView({ + ...view, + sort: { + field: field.id, + direction + } + }); + } + }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, info.label)); + })); + })); } +const ViewActions = (0,external_wp_element_namespaceObject.memo)(function ViewActions({ + fields, + view, + onChangeView, + supportedLayouts +}) { + return (0,external_React_.createElement)(view_actions_DropdownMenu, { + trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + size: "compact", + icon: library_settings, + label: (0,external_wp_i18n_namespaceObject.__)('View options') + }) + }, (0,external_React_.createElement)(view_actions_DropdownMenuGroup, null, (0,external_React_.createElement)(ViewTypeMenu, { + view: view, + onChangeView: onChangeView, + supportedLayouts: supportedLayouts + }), (0,external_React_.createElement)(SortMenu, { + fields: fields, + view: view, + onChangeView: onChangeView + }), (0,external_React_.createElement)(FieldsVisibilityMenu, { + fields: fields, + view: view, + onChangeView: onChangeView + }), (0,external_React_.createElement)(PageSizeMenu, { + view: view, + onChangeView: onChangeView + }))); +}); +/* harmony default export */ const view_actions = (ViewActions); + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/4R3V3JGP.js +"use client"; +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var _4R3V3JGP_spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var _4R3V3JGP_spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); +var __objRest = (source, exclude) => { + var target = {}; + for (var prop in source) + if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) + target[prop] = source[prop]; + if (source != null && __getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(source)) { + if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) + target[prop] = source[prop]; + } + return target; +}; -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/get-is-list-page.js -/** - * Returns if the params match the list page route. - * - * @param {Object} params The url params. - * @param {string} params.path The current path. - * @param {string} [params.categoryType] The current category type. - * @param {string} [params.categoryId] The current category id. - * @param {boolean} isMobileViewport Is mobile viewport. - * - * @return {boolean} Is list page or not. - */ -function getIsListPage({ - path, - categoryType, - categoryId -}, isMobileViewport) { - return path === '/wp_template/all' || path === '/wp_template_part/all' || path === '/patterns' && ( - // Don't treat "/patterns" without categoryType and categoryId as a - // list page in mobile because the sidebar covers the whole page. - !isMobileViewport || !!categoryType && !!categoryId); -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/4R3V3JGP.js +"use client"; +var _4R3V3JGP_defProp = Object.defineProperty; +var _4R3V3JGP_defProps = Object.defineProperties; +var _4R3V3JGP_getOwnPropDescs = Object.getOwnPropertyDescriptors; +var _4R3V3JGP_getOwnPropSymbols = Object.getOwnPropertySymbols; +var _4R3V3JGP_hasOwnProp = Object.prototype.hasOwnProperty; +var _4R3V3JGP_propIsEnum = Object.prototype.propertyIsEnumerable; +var _4R3V3JGP_defNormalProp = (obj, key, value) => key in obj ? _4R3V3JGP_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var _chunks_4R3V3JGP_spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (_4R3V3JGP_hasOwnProp.call(b, prop)) + _4R3V3JGP_defNormalProp(a, prop, b[prop]); + if (_4R3V3JGP_getOwnPropSymbols) + for (var prop of _4R3V3JGP_getOwnPropSymbols(b)) { + if (_4R3V3JGP_propIsEnum.call(b, prop)) + _4R3V3JGP_defNormalProp(a, prop, b[prop]); + } + return a; +}; +var _chunks_4R3V3JGP_spreadProps = (a, b) => _4R3V3JGP_defProps(a, _4R3V3JGP_getOwnPropDescs(b)); +var _4R3V3JGP_objRest = (source, exclude) => { + var target = {}; + for (var prop in source) + if (_4R3V3JGP_hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) + target[prop] = source[prop]; + if (source != null && _4R3V3JGP_getOwnPropSymbols) + for (var prop of _4R3V3JGP_getOwnPropSymbols(source)) { + if (exclude.indexOf(prop) < 0 && _4R3V3JGP_propIsEnum.call(source, prop)) + target[prop] = source[prop]; + } + return target; +}; -const listView = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - viewBox: "0 0 24 24", - xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" -})); -/* harmony default export */ var list_view = (listView); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up-down.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/Y3OOHFCN.js +"use client"; -const chevronUpDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "m12 20-4.5-3.6-.9 1.2L12 22l5.5-4.4-.9-1.2L12 20zm0-16 4.5 3.6.9-1.2L12 2 6.5 6.4l.9 1.2L12 4z" -})); -/* harmony default export */ var chevron_up_down = (chevronUpDown); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/external.js +// src/utils/misc.ts +function Y3OOHFCN_noop(..._) { +} +function shallowEqual(a, b) { + if (a === b) + return true; + if (!a) + return false; + if (!b) + return false; + if (typeof a !== "object") + return false; + if (typeof b !== "object") + return false; + const aKeys = Object.keys(a); + const bKeys = Object.keys(b); + const { length } = aKeys; + if (bKeys.length !== length) + return false; + for (const key of aKeys) { + if (a[key] !== b[key]) { + return false; + } + } + return true; +} +function Y3OOHFCN_applyState(argument, currentValue) { + if (isUpdater(argument)) { + const value = isLazyValue(currentValue) ? currentValue() : currentValue; + return argument(value); + } + return argument; +} +function isUpdater(argument) { + return typeof argument === "function"; +} +function isLazyValue(value) { + return typeof value === "function"; +} +function Y3OOHFCN_isObject(arg) { + return typeof arg === "object" && arg != null; +} +function isEmpty(arg) { + if (Array.isArray(arg)) + return !arg.length; + if (Y3OOHFCN_isObject(arg)) + return !Object.keys(arg).length; + if (arg == null) + return true; + if (arg === "") + return true; + return false; +} +function isInteger(arg) { + if (typeof arg === "number") { + return Math.floor(arg) === arg; + } + return String(Math.floor(Number(arg))) === arg; +} +function Y3OOHFCN_hasOwnProperty(object, prop) { + if (typeof Object.hasOwn === "function") { + return Object.hasOwn(object, prop); + } + return Object.prototype.hasOwnProperty.call(object, prop); +} +function chain(...fns) { + return (...args) => { + for (const fn of fns) { + if (typeof fn === "function") { + fn(...args); + } + } + }; +} +function cx(...args) { + return args.filter(Boolean).join(" ") || void 0; +} +function normalizeString(str) { + return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); +} +function omit(object, keys) { + const result = _chunks_4R3V3JGP_spreadValues({}, object); + for (const key of keys) { + if (Y3OOHFCN_hasOwnProperty(result, key)) { + delete result[key]; + } + } + return result; +} +function pick(object, paths) { + const result = {}; + for (const key of paths) { + if (Y3OOHFCN_hasOwnProperty(object, key)) { + result[key] = object[key]; + } + } + return result; +} +function identity(value) { + return value; +} +function beforePaint(cb = Y3OOHFCN_noop) { + const raf = requestAnimationFrame(cb); + return () => cancelAnimationFrame(raf); +} +function afterPaint(cb = Y3OOHFCN_noop) { + let raf = requestAnimationFrame(() => { + raf = requestAnimationFrame(cb); + }); + return () => cancelAnimationFrame(raf); +} +function invariant(condition, message) { + if (condition) + return; + if (typeof message !== "string") + throw new Error("Invariant failed"); + throw new Error(message); +} +function getKeys(obj) { + return Object.keys(obj); +} +function isFalsyBooleanCallback(booleanOrCallback, ...args) { + const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; + if (result == null) + return false; + return !result; +} +function disabledFromProps(props) { + return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; +} +function defaultValue(...values) { + for (const value of values) { + if (value !== void 0) + return value; + } + return void 0; +} -/** - * WordPress dependencies - */ -const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" -})); -/* harmony default export */ var library_external = (external); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/config.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/XM66DUTO.js +"use client"; -const textFormattingShortcuts = [{ - keyCombination: { - modifier: 'primary', - character: 'b' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.') -}, { - keyCombination: { - modifier: 'primary', - character: 'i' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.') -}, { - keyCombination: { - modifier: 'primary', - character: 'k' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.') -}, { - keyCombination: { - modifier: 'primaryShift', - character: 'k' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.') -}, { - keyCombination: { - character: '[[' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.') -}, { - keyCombination: { - modifier: 'primary', - character: 'u' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.') -}, { - keyCombination: { - modifier: 'access', - character: 'd' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.') -}, { - keyCombination: { - modifier: 'access', - character: 'x' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.') -}, { - keyCombination: { - modifier: 'access', - character: '0' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.') -}, { - keyCombination: { - modifier: 'access', - character: '1-6' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.') -}]; -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/shortcut.js +// src/utils/misc.ts -/** - * WordPress dependencies - */ + +function setRef(ref, value) { + if (typeof ref === "function") { + ref(value); + } else if (ref) { + ref.current = value; + } +} +function isValidElementWithRef(element) { + if (!element) + return false; + if (!(0,external_React_.isValidElement)(element)) + return false; + if (!("ref" in element)) + return false; + return true; +} +function getRefProperty(element) { + if (!isValidElementWithRef(element)) + return null; + return element.ref; +} +function mergeProps(base, overrides) { + const props = _4R3V3JGP_spreadValues({}, base); + for (const key in overrides) { + if (!Y3OOHFCN_hasOwnProperty(overrides, key)) + continue; + if (key === "className") { + const prop = "className"; + props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop]; + continue; + } + if (key === "style") { + const prop = "style"; + props[prop] = base[prop] ? _4R3V3JGP_spreadValues(_4R3V3JGP_spreadValues({}, base[prop]), overrides[prop]) : overrides[prop]; + continue; + } + const overrideValue = overrides[key]; + if (typeof overrideValue === "function" && key.startsWith("on")) { + const baseValue = base[key]; + if (typeof baseValue === "function") { + props[key] = (...args) => { + overrideValue(...args); + baseValue(...args); + }; + continue; + } + } + props[key] = overrideValue; + } + return props; +} -function KeyCombination({ - keyCombination, - forceAriaLabel -}) { - const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character; - const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character; - return (0,external_wp_element_namespaceObject.createElement)("kbd", { - className: "edit-site-keyboard-shortcut-help-modal__shortcut-key-combination", - "aria-label": forceAriaLabel || ariaLabel - }, (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => { - if (character === '+') { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, { - key: index - }, character); + +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/DLOEKDPY.js +"use client"; + +// src/utils/dom.ts +var DLOEKDPY_canUseDOM = checkIsBrowser(); +function checkIsBrowser() { + var _a; + return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement); +} +function DLOEKDPY_getDocument(node) { + return node ? node.ownerDocument || node : document; +} +function getWindow(node) { + return DLOEKDPY_getDocument(node).defaultView || window; +} +function DLOEKDPY_getActiveElement(node, activeDescendant = false) { + const { activeElement } = DLOEKDPY_getDocument(node); + if (!(activeElement == null ? void 0 : activeElement.nodeName)) { + return null; + } + if (DLOEKDPY_isFrame(activeElement) && activeElement.contentDocument) { + return DLOEKDPY_getActiveElement( + activeElement.contentDocument.body, + activeDescendant + ); + } + if (activeDescendant) { + const id = activeElement.getAttribute("aria-activedescendant"); + if (id) { + const element = DLOEKDPY_getDocument(activeElement).getElementById(id); + if (element) { + return element; + } } - return (0,external_wp_element_namespaceObject.createElement)("kbd", { - key: index, - className: "edit-site-keyboard-shortcut-help-modal__shortcut-key" - }, character); - })); + } + return activeElement; } -function Shortcut({ - description, - keyCombination, - aliases = [], - ariaLabel -}) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-keyboard-shortcut-help-modal__shortcut-description" - }, description), (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-keyboard-shortcut-help-modal__shortcut-term" - }, (0,external_wp_element_namespaceObject.createElement)(KeyCombination, { - keyCombination: keyCombination, - forceAriaLabel: ariaLabel - }), aliases.map((alias, index) => (0,external_wp_element_namespaceObject.createElement)(KeyCombination, { - keyCombination: alias, - forceAriaLabel: ariaLabel, - key: index - })))); +function contains(parent, child) { + return parent === child || parent.contains(child); +} +function DLOEKDPY_isFrame(element) { + return element.tagName === "IFRAME"; +} +function isButton(element) { + const tagName = element.tagName.toLowerCase(); + if (tagName === "button") + return true; + if (tagName === "input" && element.type) { + return buttonInputTypes.indexOf(element.type) !== -1; + } + return false; +} +var buttonInputTypes = [ + "button", + "color", + "file", + "image", + "reset", + "submit" +]; +function matches(element, selectors) { + if ("matches" in element) { + return element.matches(selectors); + } + if ("msMatchesSelector" in element) { + return element.msMatchesSelector(selectors); + } + return element.webkitMatchesSelector(selectors); +} +function isVisible(element) { + const htmlElement = element; + return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; +} +function DLOEKDPY_closest(element, selectors) { + if ("closest" in element) + return element.closest(selectors); + do { + if (matches(element, selectors)) + return element; + element = element.parentElement || element.parentNode; + } while (element !== null && element.nodeType === 1); + return null; +} +function DLOEKDPY_isTextField(element) { + try { + const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null; + const isTextArea = element.tagName === "TEXTAREA"; + return isTextInput || isTextArea || false; + } catch (error) { + return false; + } +} +function getPopupRole(element, fallback) { + const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"]; + const role = element == null ? void 0 : element.getAttribute("role"); + if (role && allowedPopupRoles.indexOf(role) !== -1) { + return role; + } + return fallback; +} +function getPopupItemRole(element, fallback) { + var _a; + const itemRoleByPopupRole = { + menu: "menuitem", + listbox: "option", + tree: "treeitem", + grid: "gridcell" + }; + const popupRole = getPopupRole(element); + if (!popupRole) + return fallback; + const key = popupRole; + return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback; +} +function getTextboxSelection(element) { + let start = 0; + let end = 0; + if (DLOEKDPY_isTextField(element)) { + start = element.selectionStart || 0; + end = element.selectionEnd || 0; + } else if (element.isContentEditable) { + const selection = DLOEKDPY_getDocument(element).getSelection(); + if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) { + const range = selection.getRangeAt(0); + const nextRange = range.cloneRange(); + nextRange.selectNodeContents(element); + nextRange.setEnd(range.startContainer, range.startOffset); + start = nextRange.toString().length; + nextRange.setEnd(range.endContainer, range.endOffset); + end = nextRange.toString().length; + } + } + return { start, end }; +} +function scrollIntoViewIfNeeded(element, arg) { + if (isPartiallyHidden(element) && "scrollIntoView" in element) { + element.scrollIntoView(arg); + } +} +function getScrollingElement(element) { + if (!element) + return null; + if (element.clientHeight && element.scrollHeight > element.clientHeight) { + const { overflowY } = getComputedStyle(element); + const isScrollable = overflowY !== "visible" && overflowY !== "hidden"; + if (isScrollable) + return element; + } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { + const { overflowX } = getComputedStyle(element); + const isScrollable = overflowX !== "visible" && overflowX !== "hidden"; + if (isScrollable) + return element; + } + return getScrollingElement(element.parentElement) || document.scrollingElement || document.body; +} +function isPartiallyHidden(element) { + const elementRect = element.getBoundingClientRect(); + const scroller = getScrollingElement(element); + if (!scroller) + return false; + const scrollerRect = scroller.getBoundingClientRect(); + const isHTML = scroller.tagName === "HTML"; + const scrollerTop = isHTML ? scrollerRect.top + scroller.scrollTop : scrollerRect.top; + const scrollerBottom = isHTML ? scroller.clientHeight : scrollerRect.bottom; + const scrollerLeft = isHTML ? scrollerRect.left + scroller.scrollLeft : scrollerRect.left; + const scrollerRight = isHTML ? scroller.clientWidth : scrollerRect.right; + const top = elementRect.top < scrollerTop; + const left = elementRect.left < scrollerLeft; + const bottom = elementRect.bottom > scrollerBottom; + const right = elementRect.right > scrollerRight; + return top || left || bottom || right; +} +function setSelectionRange(element, ...args) { + if (/text|search|password|tel|url/i.test(element.type)) { + element.setSelectionRange(...args); + } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js - -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/MHPO2BXA.js +"use client"; -/** - * Internal dependencies - */ -function DynamicShortcut({ - name -}) { - const { - keyCombination, - description, - aliases - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getShortcutKeyCombination, - getShortcutDescription, - getShortcutAliases - } = select(external_wp_keyboardShortcuts_namespaceObject.store); - return { - keyCombination: getShortcutKeyCombination(name), - aliases: getShortcutAliases(name), - description: getShortcutDescription(name) - }; - }, [name]); - if (!keyCombination) { - return null; - } - return (0,external_wp_element_namespaceObject.createElement)(Shortcut, { - keyCombination: keyCombination, - description: description, - aliases: aliases - }); +// src/utils/platform.ts +function isTouchDevice() { + return DLOEKDPY_canUseDOM && !!navigator.maxTouchPoints; +} +function isApple() { + if (!DLOEKDPY_canUseDOM) + return false; + return /mac|iphone|ipad|ipod/i.test(navigator.platform); +} +function isSafari() { + return DLOEKDPY_canUseDOM && isApple() && /apple/i.test(navigator.vendor); +} +function isFirefox() { + return DLOEKDPY_canUseDOM && /firefox\//i.test(navigator.userAgent); +} +function isMac() { + return canUseDOM && navigator.platform.startsWith("Mac") && !isTouchDevice(); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/index.js -/** - * External dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/utils/events.js +"use client"; -/** - * WordPress dependencies - */ +// src/utils/events.ts +function isPortalEvent(event) { + return Boolean( + event.currentTarget && !contains(event.currentTarget, event.target) + ); +} +function isSelfTarget(event) { + return event.target === event.currentTarget; +} +function isOpeningInNewTab(event) { + const element = event.currentTarget; + if (!element) + return false; + const isAppleDevice = isApple(); + if (isAppleDevice && !event.metaKey) + return false; + if (!isAppleDevice && !event.ctrlKey) + return false; + const tagName = element.tagName.toLowerCase(); + if (tagName === "a") + return true; + if (tagName === "button" && element.type === "submit") + return true; + if (tagName === "input" && element.type === "submit") + return true; + return false; +} +function isDownloading(event) { + const element = event.currentTarget; + if (!element) + return false; + const tagName = element.tagName.toLowerCase(); + if (!event.altKey) + return false; + if (tagName === "a") + return true; + if (tagName === "button" && element.type === "submit") + return true; + if (tagName === "input" && element.type === "submit") + return true; + return false; +} +function fireEvent(element, type, eventInit) { + const event = new Event(type, eventInit); + return element.dispatchEvent(event); +} +function fireBlurEvent(element, eventInit) { + const event = new FocusEvent("blur", eventInit); + const defaultAllowed = element.dispatchEvent(event); + const bubbleInit = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, eventInit), { bubbles: true }); + element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); + return defaultAllowed; +} +function fireFocusEvent(element, eventInit) { + const event = new FocusEvent("focus", eventInit); + const defaultAllowed = element.dispatchEvent(event); + const bubbleInit = __spreadProps(__spreadValues({}, eventInit), { bubbles: true }); + element.dispatchEvent(new FocusEvent("focusin", bubbleInit)); + return defaultAllowed; +} +function fireKeyboardEvent(element, type, eventInit) { + const event = new KeyboardEvent(type, eventInit); + return element.dispatchEvent(event); +} +function fireClickEvent(element, eventInit) { + const event = new MouseEvent("click", eventInit); + return element.dispatchEvent(event); +} +function isFocusEventOutside(event, container) { + const containerElement = container || event.currentTarget; + const relatedTarget = event.relatedTarget; + return !relatedTarget || !contains(containerElement, relatedTarget); +} +function queueBeforeEvent(element, type, callback) { + const raf = requestAnimationFrame(() => { + element.removeEventListener(type, callImmediately, true); + callback(); + }); + const callImmediately = () => { + cancelAnimationFrame(raf); + callback(); + }; + element.addEventListener(type, callImmediately, { + once: true, + capture: true + }); + return raf; +} +function addGlobalEventListener(type, listener, options, scope = window) { + const children = []; + try { + scope.document.addEventListener(type, listener, options); + for (const frame of Array.from(scope.frames)) { + children.push(addGlobalEventListener(type, listener, options, frame)); + } + } catch (e) { + } + const removeEventListener = () => { + try { + scope.document.removeEventListener(type, listener, options); + } catch (e) { + } + children.forEach((remove) => remove()); + }; + return removeEventListener; +} +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/6O5OEQGF.js +"use client"; -/** - * Internal dependencies - */ +// src/utils/hooks.ts -const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'edit-site/keyboard-shortcut-help'; -const ShortcutList = ({ - shortcuts -}) => -/* - * Disable reason: The `list` ARIA role is redundant but - * Safari+VoiceOver won't announce the list otherwise. - */ -/* eslint-disable jsx-a11y/no-redundant-roles */ -(0,external_wp_element_namespaceObject.createElement)("ul", { - className: "edit-site-keyboard-shortcut-help-modal__shortcut-list", - role: "list" -}, shortcuts.map((shortcut, index) => (0,external_wp_element_namespaceObject.createElement)("li", { - className: "edit-site-keyboard-shortcut-help-modal__shortcut", - key: index -}, typeof shortcut === 'string' ? (0,external_wp_element_namespaceObject.createElement)(DynamicShortcut, { - name: shortcut -}) : (0,external_wp_element_namespaceObject.createElement)(Shortcut, { - ...shortcut -})))) -/* eslint-enable jsx-a11y/no-redundant-roles */; -const ShortcutSection = ({ - title, - shortcuts, - className -}) => (0,external_wp_element_namespaceObject.createElement)("section", { - className: classnames_default()('edit-site-keyboard-shortcut-help-modal__section', className) -}, !!title && (0,external_wp_element_namespaceObject.createElement)("h2", { - className: "edit-site-keyboard-shortcut-help-modal__section-title" -}, title), (0,external_wp_element_namespaceObject.createElement)(ShortcutList, { - shortcuts: shortcuts -})); -const ShortcutCategorySection = ({ - title, - categoryName, - additionalShortcuts = [] -}) => { - const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => { - return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName); - }, [categoryName]); - return (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, { - title: title, - shortcuts: categoryShortcuts.concat(additionalShortcuts) + + + +var _React = _4R3V3JGP_spreadValues({}, external_React_namespaceObject); +var useReactId = _React.useId; +var useReactDeferredValue = _React.useDeferredValue; +var useReactInsertionEffect = _React.useInsertionEffect; +var useSafeLayoutEffect = DLOEKDPY_canUseDOM ? external_React_.useLayoutEffect : external_React_.useEffect; +function useInitialValue(value) { + const [initialValue] = useState(value); + return initialValue; +} +function useLazyValue(init) { + const ref = useRef(); + if (ref.current === void 0) { + ref.current = init(); + } + return ref.current; +} +function useLiveRef(value) { + const ref = (0,external_React_.useRef)(value); + useSafeLayoutEffect(() => { + ref.current = value; }); -}; -function KeyboardShortcutHelpModal() { - const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME)); - const { - closeModal, - openModal - } = (0,external_wp_data_namespaceObject.useDispatch)(store); - const toggleModal = () => isModalActive ? closeModal() : openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME); - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/keyboard-shortcuts', toggleModal); - if (!isModalActive) { - return null; + return ref; +} +function usePreviousValue(value) { + const [previousValue, setPreviousValue] = useState(value); + if (value !== previousValue) { + setPreviousValue(value); } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { - className: "edit-site-keyboard-shortcut-help-modal", - title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'), - onRequestClose: toggleModal - }, (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, { - className: "edit-site-keyboard-shortcut-help-modal__main-shortcuts", - shortcuts: ['core/edit-site/keyboard-shortcuts'] - }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, { - title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'), - categoryName: "global" - }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, { - title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'), - categoryName: "selection" - }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, { - title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'), - categoryName: "block", - additionalShortcuts: [{ - keyCombination: { - character: '/' - }, - description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'), - /* translators: The forward-slash character. e.g. '/'. */ - ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash') - }] - }), (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, { - title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'), - shortcuts: textFormattingShortcuts - })); + return previousValue; +} +function useEvent(callback) { + const ref = (0,external_React_.useRef)(() => { + throw new Error("Cannot call an event handler while rendering."); + }); + if (useReactInsertionEffect) { + useReactInsertionEffect(() => { + ref.current = callback; + }); + } else { + ref.current = callback; + } + return (0,external_React_.useCallback)((...args) => { + var _a; + return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args); + }, []); +} +function useMergeRefs(...refs) { + return (0,external_React_.useMemo)(() => { + if (!refs.some(Boolean)) + return; + return (value) => { + refs.forEach((ref) => setRef(ref, value)); + }; + }, refs); +} +function useRefId(ref, deps) { + const [id, setId] = useState(void 0); + useSafeLayoutEffect(() => { + var _a; + setId((_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.id); + }, deps); + return id; +} +function useId(defaultId) { + if (useReactId) { + const reactId = useReactId(); + if (defaultId) + return defaultId; + return reactId; + } + const [id, setId] = (0,external_React_.useState)(defaultId); + useSafeLayoutEffect(() => { + if (defaultId || id) + return; + const random = Math.random().toString(36).substr(2, 6); + setId(`id-${random}`); + }, [defaultId, id]); + return defaultId || id; +} +function useDeferredValue(value) { + if (useReactDeferredValue) { + return useReactDeferredValue(value); + } + const [deferredValue, setDeferredValue] = useState(value); + useEffect(() => { + const raf = requestAnimationFrame(() => setDeferredValue(value)); + return () => cancelAnimationFrame(raf); + }, [value]); + return deferredValue; +} +function useTagName(refOrElement, type) { + const stringOrUndefined = (type2) => { + if (typeof type2 !== "string") + return; + return type2; + }; + const [tagName, setTagName] = (0,external_React_.useState)(() => stringOrUndefined(type)); + useSafeLayoutEffect(() => { + const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; + setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type)); + }, [refOrElement, type]); + return tagName; +} +function useAttribute(refOrElement, attributeName, defaultValue) { + const [attribute, setAttribute] = (0,external_React_.useState)(defaultValue); + useSafeLayoutEffect(() => { + const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; + const value = element == null ? void 0 : element.getAttribute(attributeName); + if (value == null) + return; + setAttribute(value); + }, [refOrElement, attributeName]); + return attribute; +} +function useUpdateEffect(effect, deps) { + const mounted = (0,external_React_.useRef)(false); + (0,external_React_.useEffect)(() => { + if (mounted.current) { + return effect(); + } + mounted.current = true; + }, deps); + (0,external_React_.useEffect)( + () => () => { + mounted.current = false; + }, + [] + ); +} +function useUpdateLayoutEffect(effect, deps) { + const mounted = (0,external_React_.useRef)(false); + useSafeLayoutEffect(() => { + if (mounted.current) { + return effect(); + } + mounted.current = true; + }, deps); + useSafeLayoutEffect( + () => () => { + mounted.current = false; + }, + [] + ); +} +function useControlledState(defaultState, state, setState) { + const [localState, setLocalState] = useState(defaultState); + const nextState = state !== void 0 ? state : localState; + const stateRef = useLiveRef(state); + const setStateRef = useLiveRef(setState); + const nextStateRef = useLiveRef(nextState); + const setNextState = useCallback((prevValue) => { + const setStateProp = setStateRef.current; + if (setStateProp) { + if (isSetNextState(setStateProp)) { + setStateProp(prevValue); + } else { + const nextValue = applyState(prevValue, nextStateRef.current); + nextStateRef.current = nextValue; + setStateProp(nextValue); + } + } + if (stateRef.current === void 0) { + setLocalState(prevValue); + } + }, []); + defineSetNextState(setNextState); + return [nextState, setNextState]; +} +var SET_NEXT_STATE = Symbol("setNextState"); +function isSetNextState(arg) { + return arg[SET_NEXT_STATE] === true; +} +function defineSetNextState(arg) { + if (!isSetNextState(arg)) { + Object.defineProperty(arg, SET_NEXT_STATE, { value: true }); + } +} +function useForceUpdate() { + return (0,external_React_.useReducer)(() => [], []); +} +function useBooleanEvent(booleanOrCallback) { + return useEvent( + typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback + ); +} +function useWrapElement(props, callback, deps = []) { + const wrapElement = (0,external_React_.useCallback)( + (element) => { + if (props.wrapElement) { + element = props.wrapElement(element); + } + return callback(element); + }, + [...deps, props.wrapElement] + ); + return _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { wrapElement }); +} +function usePortalRef(portalProp = false, portalRefProp) { + const [portalNode, setPortalNode] = useState(null); + const portalRef = useMergeRefs(setPortalNode, portalRefProp); + const domReady = !portalProp || portalNode; + return { portalRef, portalNode, domReady }; +} +function useMetadataProps(props, key, value) { + const parent = props.onLoadedMetadataCapture; + const onLoadedMetadataCapture = (0,external_React_.useMemo)(() => { + return Object.assign(() => { + }, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, parent), { [key]: value })); + }, [parent, key, value]); + return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }]; +} +function useIsMouseMoving() { + (0,external_React_.useEffect)(() => { + addGlobalEventListener("mousemove", setMouseMoving, true); + addGlobalEventListener("mousedown", resetMouseMoving, true); + addGlobalEventListener("mouseup", resetMouseMoving, true); + addGlobalEventListener("keydown", resetMouseMoving, true); + addGlobalEventListener("scroll", resetMouseMoving, true); + }, []); + const isMouseMoving = useEvent(() => mouseMoving); + return isMouseMoving; +} +var mouseMoving = false; +var previousScreenX = 0; +var previousScreenY = 0; +function hasMouseMovement(event) { + const movementX = event.movementX || event.screenX - previousScreenX; + const movementY = event.movementY || event.screenY - previousScreenY; + previousScreenX = event.screenX; + previousScreenY = event.screenY; + return movementX || movementY || "production" === "test"; +} +function setMouseMoving(event) { + if (!hasMouseMovement(event)) + return; + mouseMoving = true; +} +function resetMouseMoving() { + mouseMoving = false; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/preferences-modal/enable-feature.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/EAHJFCU4.js +"use client"; -function EnableFeature(props) { - const { - featureName, - onToggle = () => {}, - ...remainingProps - } = props; - const isChecked = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', featureName), [featureName]); - const { - toggle - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); - const onChange = () => { - onToggle(); - toggle('core/edit-site', featureName); + +// src/utils/store.ts +function getInternal(store, key) { + const internals = store.__unstableInternals; + invariant(internals, "Invalid store"); + return internals[key]; +} +function createStore(initialState, ...stores) { + let state = initialState; + let prevStateBatch = state; + let lastUpdate = Symbol(); + let destroy = Y3OOHFCN_noop; + const instances = /* @__PURE__ */ new Set(); + const updatedKeys = /* @__PURE__ */ new Set(); + const setups = /* @__PURE__ */ new Set(); + const listeners = /* @__PURE__ */ new Set(); + const batchListeners = /* @__PURE__ */ new Set(); + const disposables = /* @__PURE__ */ new WeakMap(); + const listenerKeys = /* @__PURE__ */ new WeakMap(); + const storeSetup = (callback) => { + setups.add(callback); + return () => setups.delete(callback); }; - return (0,external_wp_element_namespaceObject.createElement)(preferences_modal_base_option, { - onChange: onChange, - isChecked: isChecked, - ...remainingProps + const storeInit = () => { + const initialized = instances.size; + const instance = Symbol(); + instances.add(instance); + const maybeDestroy = () => { + instances.delete(instance); + if (instances.size) + return; + destroy(); + }; + if (initialized) + return maybeDestroy; + const desyncs = getKeys(state).map( + (key) => chain( + ...stores.map((store) => { + var _a; + const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store); + if (!storeState) + return; + if (!Y3OOHFCN_hasOwnProperty(storeState, key)) + return; + return sync(store, [key], (state2) => { + setState( + key, + state2[key], + // @ts-expect-error - Not public API. This is just to prevent + // infinite loops. + true + ); + }); + }) + ) + ); + const teardowns = []; + setups.forEach((setup2) => teardowns.push(setup2())); + const cleanups = stores.map(init); + destroy = chain(...desyncs, ...teardowns, ...cleanups); + return maybeDestroy; + }; + const sub = (keys, listener, set = listeners) => { + set.add(listener); + listenerKeys.set(listener, keys); + return () => { + var _a; + (_a = disposables.get(listener)) == null ? void 0 : _a(); + disposables.delete(listener); + listenerKeys.delete(listener); + set.delete(listener); + }; + }; + const storeSubscribe = (keys, listener) => sub(keys, listener); + const storeSync = (keys, listener) => { + disposables.set(listener, listener(state, state)); + return sub(keys, listener); + }; + const storeBatch = (keys, listener) => { + disposables.set(listener, listener(state, prevStateBatch)); + return sub(keys, listener, batchListeners); + }; + const storePick = (keys) => createStore(pick(state, keys), finalStore); + const storeOmit = (keys) => createStore(omit(state, keys), finalStore); + const getState = () => state; + const setState = (key, value, fromStores = false) => { + if (!Y3OOHFCN_hasOwnProperty(state, key)) + return; + const nextValue = Y3OOHFCN_applyState(value, state[key]); + if (nextValue === state[key]) + return; + if (!fromStores) { + stores.forEach((store) => { + var _a; + (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue); + }); + } + const prevState = state; + state = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, state), { [key]: nextValue }); + const thisUpdate = Symbol(); + lastUpdate = thisUpdate; + updatedKeys.add(key); + const run = (listener, prev, uKeys) => { + var _a; + const keys = listenerKeys.get(listener); + const updated = (k) => uKeys ? uKeys.has(k) : k === key; + if (!keys || keys.some(updated)) { + (_a = disposables.get(listener)) == null ? void 0 : _a(); + disposables.set(listener, listener(state, prev)); + } + }; + listeners.forEach((listener) => { + run(listener, prevState); + }); + queueMicrotask(() => { + if (lastUpdate !== thisUpdate) + return; + const snapshot = state; + batchListeners.forEach((listener) => { + run(listener, prevStateBatch, updatedKeys); + }); + prevStateBatch = snapshot; + updatedKeys.clear(); + }); + }; + const finalStore = { + getState, + setState, + __unstableInternals: { + setup: storeSetup, + init: storeInit, + subscribe: storeSubscribe, + sync: storeSync, + batch: storeBatch, + pick: storePick, + omit: storeOmit + } + }; + return finalStore; +} +function setup(store, ...args) { + if (!store) + return; + return getInternal(store, "setup")(...args); +} +function init(store, ...args) { + if (!store) + return; + return getInternal(store, "init")(...args); +} +function subscribe(store, ...args) { + if (!store) + return; + return getInternal(store, "subscribe")(...args); +} +function sync(store, ...args) { + if (!store) + return; + return getInternal(store, "sync")(...args); +} +function batch(store, ...args) { + if (!store) + return; + return getInternal(store, "batch")(...args); +} +function omit2(store, ...args) { + if (!store) + return; + return getInternal(store, "omit")(...args); +} +function pick2(store, ...args) { + if (!store) + return; + return getInternal(store, "pick")(...args); +} +function mergeStore(...stores) { + const initialState = stores.reduce((state, store2) => { + var _a; + const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2); + if (!nextState) + return state; + return _chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, state), nextState); + }, {}); + const store = createStore(initialState, ...stores); + return store; +} +function throwOnConflictingProps(props, store) { + if (true) + return; + if (!store) + return; + const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { + var _a; + const stateKey = key.replace("default", ""); + return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`; }); + if (!defaultKeys.length) + return; + const storeState = store.getState(); + const conflictingProps = defaultKeys.filter( + (key) => Y3OOHFCN_hasOwnProperty(storeState, key) + ); + if (!conflictingProps.length) + return; + throw new Error( + `Passing a store prop in conjunction with a default state is not supported. + +const store = useSelectStore(); +<SelectProvider store={store} defaultValue="Apple" /> + ^ ^ + +Instead, pass the default state to the topmost store: + +const store = useSelectStore({ defaultValue: "Apple" }); +<SelectProvider store={store} /> + +See https://github.com/ariakit/ariakit/pull/2745 for more details. + +If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit +` + ); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/preferences-modal/index.js -/** - * WordPress dependencies - */ +// EXTERNAL MODULE: ./node_modules/use-sync-external-store/shim/index.js +var shim = __webpack_require__(422); +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/EKQEJRUF.js +"use client"; +// src/utils/store.tsx -/** - * Internal dependencies - */ -const PREFERENCES_MODAL_NAME = 'edit-site/preferences'; -function EditSitePreferencesModal() { - const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(PREFERENCES_MODAL_NAME)); - const { - closeModal, - openModal - } = (0,external_wp_data_namespaceObject.useDispatch)(store); - const toggleModal = () => isModalActive ? closeModal() : openModal(PREFERENCES_MODAL_NAME); - const registry = (0,external_wp_data_namespaceObject.useRegistry)(); - const { - closeGeneralSidebar, - setIsListViewOpened, - setIsInserterOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const { - set: setPreference - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); - const toggleDistractionFree = () => { - registry.batch(() => { - setPreference('core/edit-site', 'fixedToolbar', false); - setIsInserterOpened(false); - setIsListViewOpened(false); - closeGeneralSidebar(); - }); +var { useSyncExternalStore } = shim; +var noopSubscribe = () => () => { +}; +function useStoreState(store, keyOrSelector = identity) { + const storeSubscribe = external_React_.useCallback( + (callback) => { + if (!store) + return noopSubscribe(); + return subscribe(store, null, callback); + }, + [store] + ); + const getSnapshot = () => { + const key = typeof keyOrSelector === "string" ? keyOrSelector : null; + const selector = typeof keyOrSelector === "function" ? keyOrSelector : null; + const state = store == null ? void 0 : store.getState(); + if (selector) + return selector(state); + if (!state) + return; + if (!key) + return; + if (!Y3OOHFCN_hasOwnProperty(state, key)) + return; + return state[key]; }; - const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{ - name: 'general', - tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'), - content: (0,external_wp_element_namespaceObject.createElement)(preferences_modal_section, { - title: (0,external_wp_i18n_namespaceObject.__)('Appearance'), - description: (0,external_wp_i18n_namespaceObject.__)('Customize options related to the block editor interface and editing flow.') - }, (0,external_wp_element_namespaceObject.createElement)(EnableFeature, { - featureName: "distractionFree", - onToggle: toggleDistractionFree, - help: (0,external_wp_i18n_namespaceObject.__)('Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'), - label: (0,external_wp_i18n_namespaceObject.__)('Distraction free') - }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, { - featureName: "focusMode", - help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'), - label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode') - }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, { - featureName: "showIconLabels", - label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'), - help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons.') - }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, { - featureName: "showListViewByDefault", - help: (0,external_wp_i18n_namespaceObject.__)('Opens the block list view sidebar by default.'), - label: (0,external_wp_i18n_namespaceObject.__)('Always open list view') - }), (0,external_wp_element_namespaceObject.createElement)(EnableFeature, { - featureName: "showBlockBreadcrumbs", - help: (0,external_wp_i18n_namespaceObject.__)('Shows block breadcrumbs at the bottom of the editor.'), - label: (0,external_wp_i18n_namespaceObject.__)('Display block breadcrumbs') - })) - }, { - name: 'blocks', - tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'), - content: (0,external_wp_element_namespaceObject.createElement)(preferences_modal_section, { - title: (0,external_wp_i18n_namespaceObject.__)('Block interactions'), - description: (0,external_wp_i18n_namespaceObject.__)('Customize how you interact with blocks in the block library and editing canvas.') - }, (0,external_wp_element_namespaceObject.createElement)(EnableFeature, { - featureName: "keepCaretInsideBlock", - help: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'), - label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block') - })) - }]); - if (!isModalActive) { - return null; - } - return (0,external_wp_element_namespaceObject.createElement)(PreferencesModal, { - closeModal: toggleModal - }, (0,external_wp_element_namespaceObject.createElement)(PreferencesModalTabs, { - sections: sections - })); + return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); +} +function useStoreProps(store, props, key, setKey) { + const value = Y3OOHFCN_hasOwnProperty(props, key) ? props[key] : void 0; + const setValue = setKey ? props[setKey] : void 0; + const propsRef = useLiveRef({ value, setValue }); + useSafeLayoutEffect(() => { + return sync(store, [key], (state, prev) => { + const { value: value2, setValue: setValue2 } = propsRef.current; + if (!setValue2) + return; + if (state[key] === prev[key]) + return; + if (state[key] === value2) + return; + setValue2(state[key]); + }); + }, [store, key]); + useSafeLayoutEffect(() => { + if (value === void 0) + return; + store.setState(key, value); + return batch(store, [key], () => { + if (value === void 0) + return; + store.setState(key, value); + }); + }); +} +function EKQEJRUF_useStore(createStore, props) { + const [store, setStore] = external_React_.useState(() => createStore(props)); + useSafeLayoutEffect(() => init(store), [store]); + const useState2 = external_React_.useCallback( + (keyOrSelector) => useStoreState(store, keyOrSelector), + [store] + ); + const memoizedStore = external_React_.useMemo( + () => _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, store), { useState: useState2 }), + [store, useState2] + ); + const updateStore = useEvent(() => { + setStore((store2) => createStore(_4R3V3JGP_spreadValues(_4R3V3JGP_spreadValues({}, props), store2.getState()))); + }); + return [memoizedStore, updateStore]; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/tools-more-menu-group/index.js - -/** - * WordPress dependencies - */ - -const { - Fill: ToolsMoreMenuGroup, - Slot: tools_more_menu_group_Slot -} = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteToolsMoreMenuGroup'); -ToolsMoreMenuGroup.Slot = ({ - fillProps -}) => (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group_Slot, { - fillProps: fillProps -}, fills => fills && fills.length > 0); -/* harmony default export */ var tools_more_menu_group = (ToolsMoreMenuGroup); -// EXTERNAL MODULE: ./node_modules/downloadjs/download.js -var download = __webpack_require__(8981); -var download_default = /*#__PURE__*/__webpack_require__.n(download); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/download.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/Y6GYTNQ2.js +"use client"; -const download_download = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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" -})); -/* harmony default export */ var library_download = (download_download); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/site-export.js -/** - * External dependencies - */ +// src/collection/collection-store.ts +function useCollectionStoreProps(store, update, props) { + useUpdateEffect(update, [props.store]); + useStoreProps(store, props, "items", "setItems"); + return store; +} +function useCollectionStore(props = {}) { + const [store, update] = useStore(Core.createCollectionStore, props); + return useCollectionStoreProps(store, update, props); +} -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/7GBW5FLS.js +"use client"; +// src/composite/composite-store.ts -function SiteExport() { - const { - createErrorNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - async function handleExport() { - try { - const response = await external_wp_apiFetch_default()({ - path: '/wp-block-editor/v1/export', - parse: false, - headers: { - Accept: 'application/zip' - } - }); - const blob = await response.blob(); - const contentDisposition = response.headers.get('content-disposition'); - const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/); - const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : 'edit-site-export'; - download_default()(blob, fileName + '.zip', 'application/zip'); - } catch (errorResponse) { - let error = {}; - try { - error = await errorResponse.json(); - } catch (e) {} - const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the site export.'); - createErrorNotice(errorMessage, { - type: 'snackbar' - }); - } - } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - role: "menuitem", - icon: library_download, - onClick: handleExport, - info: (0,external_wp_i18n_namespaceObject.__)('Download your theme with updated templates and styles.') - }, (0,external_wp_i18n_namespaceObject._x)('Export', 'site exporter menu item')); +function useCompositeStoreProps(store, update, props) { + store = useCollectionStoreProps(store, update, props); + useStoreProps(store, props, "activeId", "setActiveId"); + useStoreProps(store, props, "includesBaseElement"); + useStoreProps(store, props, "virtualFocus"); + useStoreProps(store, props, "orientation"); + useStoreProps(store, props, "rtl"); + useStoreProps(store, props, "focusLoop"); + useStoreProps(store, props, "focusWrap"); + useStoreProps(store, props, "focusShift"); + return store; +} +function _7GBW5FLS_useCompositeStore(props = {}) { + const [store, update] = useStore(Core.createCompositeStore, props); + return useCompositeStoreProps(store, update, props); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/welcome-guide-menu-item.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/SFCBA2JZ.js +"use client"; -function WelcomeGuideMenuItem() { - const { - toggle - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: () => toggle('core/edit-site', 'welcomeGuide') - }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide')); +// src/disclosure/disclosure-store.ts + +function useDisclosureStoreProps(store, update, props) { + useUpdateEffect(update, [props.store, props.disclosure]); + useStoreProps(store, props, "open", "setOpen"); + useStoreProps(store, props, "mounted", "setMounted"); + useStoreProps(store, props, "animated"); + return store; +} +function useDisclosureStore(props = {}) { + const [store, update] = useStore(Core.createDisclosureStore, props); + return useDisclosureStoreProps(store, update, props); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/ZSELSBRM.js +"use client"; +// src/dialog/dialog-store.ts +function useDialogStoreProps(store, update, props) { + return useDisclosureStoreProps(store, update, props); +} +function useDialogStore(props = {}) { + const [store, update] = useStore(Core.createDialogStore, props); + return useDialogStoreProps(store, update, props); +} -/** - * Internal dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/MG4P3223.js +"use client"; -function CopyContentMenuItem() { - const { - createNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - const { - getEditedPostId, - getEditedPostType - } = (0,external_wp_data_namespaceObject.useSelect)(store_store); - const { - getEditedEntityRecord - } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); - function getText() { - const record = getEditedEntityRecord('postType', getEditedPostType(), getEditedPostId()); - if (!record) { - return ''; - } - if (typeof record.content === 'function') { - return record.content(record); - } else if (record.blocks) { - return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks); - } else if (record.content) { - return record.content; - } - } - function onSuccess() { - createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), { - isDismissible: true, - type: 'snackbar' - }); - } - const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - ref: ref - }, (0,external_wp_i18n_namespaceObject.__)('Copy all blocks')); -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/mode-switcher/index.js -/** - * WordPress dependencies - */ +// src/popover/popover-store.ts +function usePopoverStoreProps(store, update, props) { + useUpdateEffect(update, [props.popover]); + store = useDialogStoreProps(store, update, props); + useStoreProps(store, props, "placement"); + return store; +} +function usePopoverStore(props = {}) { + const [store, update] = useStore(Core.createPopoverStore, props); + return usePopoverStoreProps(store, update, props); +} -/** - * Internal dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/Z5IGYIPT.js +"use client"; -/** - * Set of available mode options. - * - * @type {Array} - */ -const MODES = [{ - value: 'visual', - label: (0,external_wp_i18n_namespaceObject.__)('Visual editor') -}, { - value: 'text', - label: (0,external_wp_i18n_namespaceObject.__)('Code editor') -}]; -function ModeSwitcher() { - const { - shortcut, - mode - } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ - shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-mode'), - isRichEditingEnabled: select(store_store).getSettings().richEditingEnabled, - isCodeEditingEnabled: select(store_store).getSettings().codeEditingEnabled, - mode: select(store_store).getEditorMode() - }), []); - const { - switchEditorMode - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const choices = MODES.map(choice => { - if (choice.value !== mode) { - return { - ...choice, - shortcut - }; - } - return choice; + + +// src/disclosure/disclosure-store.ts +function createDisclosureStore(props = {}) { + const store = mergeStore( + props.store, + omit2(props.disclosure, ["contentElement", "disclosureElement"]) + ); + throwOnConflictingProps(props, store); + const syncState = store == null ? void 0 : store.getState(); + const open = defaultValue( + props.open, + syncState == null ? void 0 : syncState.open, + props.defaultOpen, + false + ); + const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false); + const initialState = { + open, + animated, + animating: !!animated && open, + mounted: open, + contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null), + disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null) + }; + const disclosure = createStore(initialState, store); + setup( + disclosure, + () => sync(disclosure, ["animated", "animating"], (state) => { + if (state.animated) + return; + disclosure.setState("animating", false); + }) + ); + setup( + disclosure, + () => subscribe(disclosure, ["open"], () => { + if (!disclosure.getState().animated) + return; + disclosure.setState("animating", true); + }) + ); + setup( + disclosure, + () => sync(disclosure, ["open", "animating"], (state) => { + disclosure.setState("mounted", state.open || state.animating); + }) + ); + return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, disclosure), { + setOpen: (value) => disclosure.setState("open", value), + show: () => disclosure.setState("open", true), + hide: () => disclosure.setState("open", false), + toggle: () => disclosure.setState("open", (open2) => !open2), + stopAnimation: () => disclosure.setState("animating", false), + setContentElement: (value) => disclosure.setState("contentElement", value), + setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) }); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { - label: (0,external_wp_i18n_namespaceObject.__)('Editor') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, { - choices: choices, - value: mode, - onSelect: switchEditorMode - })); } -/* harmony default export */ var mode_switcher = (ModeSwitcher); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/index.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/SX2XFD6A.js +"use client"; +// src/dialog/dialog-store.ts +function createDialogStore(props = {}) { + return createDisclosureStore(props); +} +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/AF6IUUFN.js +"use client"; -/** - * Internal dependencies - */ +// src/popover/popover-store.ts +function createPopoverStore(_a = {}) { + var _b = _a, { + popover: otherPopover + } = _b, props = _4R3V3JGP_objRest(_b, [ + "popover" + ]); + const store = mergeStore( + props.store, + omit2(otherPopover, [ + "arrowElement", + "anchorElement", + "contentElement", + "popoverElement", + "disclosureElement" + ]) + ); + throwOnConflictingProps(props, store); + const syncState = store == null ? void 0 : store.getState(); + const dialog = createDialogStore(_chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, props), { store })); + const placement = defaultValue( + props.placement, + syncState == null ? void 0 : syncState.placement, + "bottom" + ); + const initialState = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, dialog.getState()), { + placement, + currentPlacement: placement, + anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null), + popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null), + arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null), + rendered: Symbol("rendered") + }); + const popover = createStore(initialState, dialog, store); + return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, dialog), popover), { + setAnchorElement: (element) => popover.setState("anchorElement", element), + setPopoverElement: (element) => popover.setState("popoverElement", element), + setArrowElement: (element) => popover.setState("arrowElement", element), + render: () => popover.setState("rendered", Symbol("rendered")) + }); +} +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/22K762VQ.js +"use client"; -function MoreMenu({ - showIconLabels -}) { - const registry = (0,external_wp_data_namespaceObject.useRegistry)(); - const isDistractionFree = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'distractionFree'), []); - const { - setIsInserterOpened, - setIsListViewOpened, - closeGeneralSidebar - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const { - openModal - } = (0,external_wp_data_namespaceObject.useDispatch)(store); - const { - set: setPreference - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); - const toggleDistractionFree = () => { - registry.batch(() => { - setPreference('core/edit-site', 'fixedToolbar', false); - setIsInserterOpened(false); - setIsListViewOpened(false); - closeGeneralSidebar(); - }); - }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, { - toggleProps: { - showTooltip: !showIconLabels, - ...(showIconLabels && { - variant: 'tertiary' - }) - } - }, ({ - onClose - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { - label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { - scope: "core/edit-site", - name: "fixedToolbar", - disabled: isDistractionFree, - label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'), - info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'), - messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'), - messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { - scope: "core/edit-site", - name: "focusMode", - label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'), - info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'), - messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'), - messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated') - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { - scope: "core/edit-site", - name: "distractionFree", - onToggle: toggleDistractionFree, - label: (0,external_wp_i18n_namespaceObject.__)('Distraction free'), - info: (0,external_wp_i18n_namespaceObject.__)('Write with calmness'), - messageActivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated'), - messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated'), - shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('\\') - })), (0,external_wp_element_namespaceObject.createElement)(mode_switcher, null), (0,external_wp_element_namespaceObject.createElement)(action_item.Slot, { - name: "core/edit-site/plugin-more-menu", - label: (0,external_wp_i18n_namespaceObject.__)('Plugins'), - as: external_wp_components_namespaceObject.MenuGroup, - fillProps: { - onClick: onClose + + + +// src/collection/collection-store.ts +function isElementPreceding(a, b) { + return Boolean( + b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING + ); +} +function sortBasedOnDOMPosition(items) { + const pairs = items.map((item, index) => [index, item]); + let isOrderDifferent = false; + pairs.sort(([indexA, a], [indexB, b]) => { + const elementA = a.element; + const elementB = b.element; + if (elementA === elementB) + return 0; + if (!elementA || !elementB) + return 0; + if (isElementPreceding(elementA, elementB)) { + if (indexA > indexB) { + isOrderDifferent = true; + } + return -1; } - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { - label: (0,external_wp_i18n_namespaceObject.__)('Tools') - }, (0,external_wp_element_namespaceObject.createElement)(SiteExport, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: () => openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME), - shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h') - }, (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, { - icon: library_external, - role: "menuitem", - href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/site-editor/'), - target: "_blank", - rel: "noopener noreferrer" - }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { - as: "span" - }, /* translators: accessibility text */ - (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group.Slot, { - fillProps: { - onClose + if (indexA < indexB) { + isOrderDifferent = true; } - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: () => openModal(PREFERENCES_MODAL_NAME) - }, (0,external_wp_i18n_namespaceObject.__)('Preferences'))))), (0,external_wp_element_namespaceObject.createElement)(KeyboardShortcutHelpModal, null), (0,external_wp_element_namespaceObject.createElement)(EditSitePreferencesModal, null)); + return 1; + }); + if (isOrderDifferent) { + return pairs.map(([_, item]) => item); + } + return items; +} +function getCommonParent(items) { + var _a; + const firstItem = items.find((item) => !!item.element); + const lastItem = [...items].reverse().find((item) => !!item.element); + let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement; + while (parentElement && (lastItem == null ? void 0 : lastItem.element)) { + const parent = parentElement; + if (lastItem && parent.contains(lastItem.element)) { + return parentElement; + } + parentElement = parentElement.parentElement; + } + return DLOEKDPY_getDocument(parentElement).body; +} +function getPrivateStore(store) { + return store == null ? void 0 : store.__unstablePrivateStore; +} +function createCollectionStore(props = {}) { + var _a; + throwOnConflictingProps(props, props.store); + const syncState = (_a = props.store) == null ? void 0 : _a.getState(); + const items = defaultValue( + props.items, + syncState == null ? void 0 : syncState.items, + props.defaultItems, + [] + ); + const itemsMap = new Map(items.map((item) => [item.id, item])); + const initialState = { + items, + renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, []) + }; + const syncPrivateStore = getPrivateStore(props.store); + const privateStore = createStore( + { items, renderedItems: initialState.renderedItems }, + syncPrivateStore + ); + const collection = createStore(initialState, props.store); + const sortItems = (renderedItems) => { + const sortedItems = sortBasedOnDOMPosition(renderedItems); + privateStore.setState("renderedItems", sortedItems); + collection.setState("renderedItems", sortedItems); + }; + setup(collection, () => init(privateStore)); + setup(privateStore, () => { + return batch(privateStore, ["items"], (state) => { + collection.setState("items", state.items); + }); + }); + setup(privateStore, () => { + return batch(privateStore, ["renderedItems"], (state) => { + let firstRun = true; + let raf = requestAnimationFrame(() => { + const { renderedItems } = collection.getState(); + if (state.renderedItems === renderedItems) + return; + sortItems(state.renderedItems); + }); + if (typeof IntersectionObserver !== "function") { + return () => cancelAnimationFrame(raf); + } + const ioCallback = () => { + if (firstRun) { + firstRun = false; + return; + } + cancelAnimationFrame(raf); + raf = requestAnimationFrame(() => sortItems(state.renderedItems)); + }; + const root = getCommonParent(state.renderedItems); + const observer = new IntersectionObserver(ioCallback, { root }); + for (const item of state.renderedItems) { + if (!item.element) + continue; + observer.observe(item.element); + } + return () => { + cancelAnimationFrame(raf); + observer.disconnect(); + }; + }); + }); + const mergeItem = (item, setItems, canDeleteFromMap = false) => { + let prevItem; + setItems((items2) => { + const index = items2.findIndex(({ id }) => id === item.id); + const nextItems = items2.slice(); + if (index !== -1) { + prevItem = items2[index]; + const nextItem = _chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, prevItem), item); + nextItems[index] = nextItem; + itemsMap.set(item.id, nextItem); + } else { + nextItems.push(item); + itemsMap.set(item.id, item); + } + return nextItems; + }); + const unmergeItem = () => { + setItems((items2) => { + if (!prevItem) { + if (canDeleteFromMap) { + itemsMap.delete(item.id); + } + return items2.filter(({ id }) => id !== item.id); + } + const index = items2.findIndex(({ id }) => id === item.id); + if (index === -1) + return items2; + const nextItems = items2.slice(); + nextItems[index] = prevItem; + itemsMap.set(item.id, prevItem); + return nextItems; + }); + }; + return unmergeItem; + }; + const registerItem = (item) => mergeItem( + item, + (getItems) => privateStore.setState("items", getItems), + true + ); + return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, collection), { + registerItem, + renderItem: (item) => chain( + registerItem(item), + mergeItem( + item, + (getItems) => privateStore.setState("renderedItems", getItems) + ) + ), + item: (id) => { + if (!id) + return null; + let item = itemsMap.get(id); + if (!item) { + const { items: items2 } = collection.getState(); + item = items2.find((item2) => item2.id === id); + if (item) { + itemsMap.set(id, item); + } + } + return item || null; + }, + // @ts-expect-error Internal + __unstablePrivateStore: privateStore + }); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/undo.js -/** - * WordPress dependencies - */ -const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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" -})); -/* harmony default export */ var library_undo = (undo); +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js +"use client"; -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/redo.js - -/** - * WordPress dependencies - */ - -const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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" -})); -/* harmony default export */ var library_redo = (redo); +// src/utils/array.ts +function toArray(arg) { + if (Array.isArray(arg)) { + return arg; + } + return typeof arg !== "undefined" ? [arg] : []; +} +function addItemToArray(array, item, index = -1) { + if (!(index in array)) { + return [...array, item]; + } + return [...array.slice(0, index), item, ...array.slice(index)]; +} +function flatten2DArray(array) { + const flattened = []; + for (const row of array) { + flattened.push(...row); + } + return flattened; +} +function reverseArray(array) { + return array.slice().reverse(); +} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/undo-redo/undo.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/IERTEJ3A.js +"use client"; -function UndoButton(props, ref) { - const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []); - const { - undo - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - ...props, - ref: ref, - icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo, - label: (0,external_wp_i18n_namespaceObject.__)('Undo'), - shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') - // If there are no undo levels we don't want to actually disable this - // button, because it will remove focus for keyboard users. - // See: https://github.com/WordPress/gutenberg/issues/3486 - , - "aria-disabled": !hasUndo, - onClick: hasUndo ? undo : undefined +// src/composite/composite-store.ts +var NULL_ITEM = { id: null }; +function findFirstEnabledItem(items, excludeId) { + return items.find((item) => { + if (excludeId) { + return !item.disabled && item.id !== excludeId; + } + return !item.disabled; + }); +} +function getEnabledItems(items, excludeId) { + return items.filter((item) => { + if (excludeId) { + return !item.disabled && item.id !== excludeId; + } + return !item.disabled; + }); +} +function getOppositeOrientation(orientation) { + if (orientation === "vertical") + return "horizontal"; + if (orientation === "horizontal") + return "vertical"; + return; +} +function getItemsInRow(items, rowId) { + return items.filter((item) => item.rowId === rowId); +} +function flipItems(items, activeId, shouldInsertNullItem = false) { + const index = items.findIndex((item) => item.id === activeId); + return [ + ...items.slice(index + 1), + ...shouldInsertNullItem ? [NULL_ITEM] : [], + ...items.slice(0, index) + ]; +} +function groupItemsByRows(items) { + const rows = []; + for (const item of items) { + const row = rows.find((currentRow) => { + var _a; + return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; + }); + if (row) { + row.push(item); + } else { + rows.push([item]); + } + } + return rows; +} +function getMaxRowLength(array) { + let maxLength = 0; + for (const { length } of array) { + if (length > maxLength) { + maxLength = length; + } + } + return maxLength; +} +function createEmptyItem(rowId) { + return { + id: "__EMPTY_ITEM__", + disabled: true, + rowId + }; +} +function normalizeRows(rows, activeId, focusShift) { + const maxLength = getMaxRowLength(rows); + for (const row of rows) { + for (let i = 0; i < maxLength; i += 1) { + const item = row[i]; + if (!item || focusShift && item.disabled) { + const isFirst = i === 0; + const previousItem = isFirst && focusShift ? findFirstEnabledItem(row) : row[i - 1]; + row[i] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId); + } + } + } + return rows; +} +function verticalizeItems(items) { + const rows = groupItemsByRows(items); + const maxLength = getMaxRowLength(rows); + const verticalized = []; + for (let i = 0; i < maxLength; i += 1) { + for (const row of rows) { + const item = row[i]; + if (item) { + verticalized.push(_chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, item), { + // If there's no rowId, it means that it's not a grid composite, but + // a single row instead. So, instead of verticalizing it, that is, + // assigning a different rowId based on the column index, we keep it + // undefined so they will be part of the same row. This is useful + // when using up/down on one-dimensional composites. + rowId: item.rowId ? `${i}` : void 0 + })); + } + } + } + return verticalized; +} +function createCompositeStore(props = {}) { + var _a; + const syncState = (_a = props.store) == null ? void 0 : _a.getState(); + const collection = createCollectionStore(props); + const activeId = defaultValue( + props.activeId, + syncState == null ? void 0 : syncState.activeId, + props.defaultActiveId + ); + const initialState = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, collection.getState()), { + activeId, + baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null), + includesBaseElement: defaultValue( + props.includesBaseElement, + syncState == null ? void 0 : syncState.includesBaseElement, + activeId === null + ), + moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0), + orientation: defaultValue( + props.orientation, + syncState == null ? void 0 : syncState.orientation, + "both" + ), + rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false), + virtualFocus: defaultValue( + props.virtualFocus, + syncState == null ? void 0 : syncState.virtualFocus, + false + ), + focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false), + focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false), + focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false) + }); + const composite = createStore(initialState, collection, props.store); + setup( + composite, + () => sync(composite, ["renderedItems", "activeId"], (state) => { + composite.setState("activeId", (activeId2) => { + var _a2; + if (activeId2 !== void 0) + return activeId2; + return (_a2 = findFirstEnabledItem(state.renderedItems)) == null ? void 0 : _a2.id; + }); + }) + ); + const getNextId = (items, orientation, hasNullItem, skip) => { + var _a2, _b; + const { activeId: activeId2, rtl, focusLoop, focusWrap, includesBaseElement } = composite.getState(); + const isHorizontal = orientation !== "vertical"; + const isRTL = rtl && isHorizontal; + const allItems = isRTL ? reverseArray(items) : items; + if (activeId2 == null) { + return (_a2 = findFirstEnabledItem(allItems)) == null ? void 0 : _a2.id; + } + const activeItem = allItems.find((item) => item.id === activeId2); + if (!activeItem) { + return (_b = findFirstEnabledItem(allItems)) == null ? void 0 : _b.id; + } + const isGrid = !!activeItem.rowId; + const activeIndex = allItems.indexOf(activeItem); + const nextItems = allItems.slice(activeIndex + 1); + const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); + if (skip !== void 0) { + const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); + const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one. + nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1]; + return nextItem2 == null ? void 0 : nextItem2.id; + } + const oppositeOrientation = getOppositeOrientation( + // If it's a grid and orientation is not set, it's a next/previous call, + // which is inherently horizontal. up/down will call next with orientation + // set to vertical by default (see below on up/down methods). + isGrid ? orientation || "horizontal" : orientation + ); + const canLoop = focusLoop && focusLoop !== oppositeOrientation; + const canWrap = isGrid && focusWrap && focusWrap !== oppositeOrientation; + hasNullItem = hasNullItem || !isGrid && canLoop && includesBaseElement; + if (canLoop) { + const loopItems = canWrap && !hasNullItem ? allItems : getItemsInRow(allItems, activeItem.rowId); + const sortedItems = flipItems(loopItems, activeId2, hasNullItem); + const nextItem2 = findFirstEnabledItem(sortedItems, activeId2); + return nextItem2 == null ? void 0 : nextItem2.id; + } + if (canWrap) { + const nextItem2 = findFirstEnabledItem( + // We can use nextItems, which contains all the next items, including + // items from other rows, to wrap between rows. However, if there is a + // null item (the composite container), we'll only use the next items in + // the row. So moving next from the last item will focus on the + // composite container. On grid composites, horizontal navigation never + // focuses on the composite container, only vertical. + hasNullItem ? nextItemsInRow : nextItems, + activeId2 + ); + const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id; + return nextId; + } + const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2); + if (!nextItem && hasNullItem) { + return null; + } + return nextItem == null ? void 0 : nextItem.id; + }; + return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, collection), composite), { + setBaseElement: (element) => composite.setState("baseElement", element), + setActiveId: (id) => composite.setState("activeId", id), + move: (id) => { + if (id === void 0) + return; + composite.setState("activeId", id); + composite.setState("moves", (moves) => moves + 1); + }, + first: () => { + var _a2; + return (_a2 = findFirstEnabledItem(composite.getState().renderedItems)) == null ? void 0 : _a2.id; + }, + last: () => { + var _a2; + return (_a2 = findFirstEnabledItem(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id; + }, + next: (skip) => { + const { renderedItems, orientation } = composite.getState(); + return getNextId(renderedItems, orientation, false, skip); + }, + previous: (skip) => { + var _a2; + const { renderedItems, orientation, includesBaseElement } = composite.getState(); + const isGrid = !!((_a2 = findFirstEnabledItem(renderedItems)) == null ? void 0 : _a2.rowId); + const hasNullItem = !isGrid && includesBaseElement; + return getNextId( + reverseArray(renderedItems), + orientation, + hasNullItem, + skip + ); + }, + down: (skip) => { + const { + activeId: activeId2, + renderedItems, + focusShift, + focusLoop, + includesBaseElement + } = composite.getState(); + const shouldShift = focusShift && !skip; + const verticalItems = verticalizeItems( + flatten2DArray( + normalizeRows(groupItemsByRows(renderedItems), activeId2, shouldShift) + ) + ); + const canLoop = focusLoop && focusLoop !== "horizontal"; + const hasNullItem = canLoop && includesBaseElement; + return getNextId(verticalItems, "vertical", hasNullItem, skip); + }, + up: (skip) => { + const { activeId: activeId2, renderedItems, focusShift, includesBaseElement } = composite.getState(); + const shouldShift = focusShift && !skip; + const verticalItems = verticalizeItems( + reverseArray( + flatten2DArray( + normalizeRows( + groupItemsByRows(renderedItems), + activeId2, + shouldShift + ) + ) + ) + ); + const hasNullItem = includesBaseElement; + return getNextId(verticalItems, "vertical", hasNullItem, skip); + } }); } -/* harmony default export */ var undo_redo_undo = ((0,external_wp_element_namespaceObject.forwardRef)(UndoButton)); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/undo-redo/redo.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/combobox/combobox-store.js +"use client"; -function RedoButton(props, ref) { - const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y'); - const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []); - const { - redo - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - ...props, - ref: ref, - icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo, - label: (0,external_wp_i18n_namespaceObject.__)('Redo'), - shortcut: shortcut - // If there are no undo levels we don't want to actually disable this - // button, because it will remove focus for keyboard users. - // See: https://github.com/WordPress/gutenberg/issues/3486 - , - "aria-disabled": !hasRedo, - onClick: hasRedo ? redo : undefined + + + + + + +// src/combobox/combobox-store.ts +var isSafariOnMobile = isSafari() && isTouchDevice(); +function createComboboxStore(props = {}) { + var _a; + throwOnConflictingProps(props, props.store); + const syncState = (_a = props.store) == null ? void 0 : _a.getState(); + const activeId = defaultValue( + props.activeId, + syncState == null ? void 0 : syncState.activeId, + props.defaultActiveId, + null + ); + const composite = createCompositeStore(_chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, props), { + activeId, + includesBaseElement: defaultValue( + props.includesBaseElement, + syncState == null ? void 0 : syncState.includesBaseElement, + true + ), + orientation: defaultValue( + props.orientation, + syncState == null ? void 0 : syncState.orientation, + "vertical" + ), + focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true), + focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true), + virtualFocus: defaultValue( + props.virtualFocus, + syncState == null ? void 0 : syncState.virtualFocus, + !isSafariOnMobile + ) + })); + const popover = createPopoverStore(_chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, props), { + placement: defaultValue( + props.placement, + syncState == null ? void 0 : syncState.placement, + "bottom-start" + ) + })); + const value = defaultValue( + props.value, + syncState == null ? void 0 : syncState.value, + props.defaultValue, + "" + ); + const selectedValue = defaultValue( + props.selectedValue, + syncState == null ? void 0 : syncState.selectedValue, + props.defaultSelectedValue, + "" + ); + const multiSelectable = Array.isArray(selectedValue); + const initialState = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, composite.getState()), popover.getState()), { + value, + selectedValue, + resetValueOnSelect: defaultValue( + props.resetValueOnSelect, + syncState == null ? void 0 : syncState.resetValueOnSelect, + multiSelectable + ), + resetValueOnHide: defaultValue( + props.resetValueOnHide, + syncState == null ? void 0 : syncState.resetValueOnHide, + multiSelectable + ), + activeValue: syncState == null ? void 0 : syncState.activeValue + }); + const combobox = createStore(initialState, composite, popover, props.store); + setup( + combobox, + () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => { + if (!state.resetValueOnHide) + return; + if (state.mounted) + return; + combobox.setState("value", value); + }) + ); + setup( + combobox, + () => sync(combobox, ["resetValueOnSelect", "selectedValue"], (state) => { + if (!state.resetValueOnSelect) + return; + combobox.setState("value", value); + }) + ); + setup( + combobox, + () => batch(combobox, ["mounted"], (state) => { + if (state.mounted) + return; + combobox.setState("activeId", activeId); + combobox.setState("moves", 0); + }) + ); + setup( + combobox, + () => sync(combobox, ["moves", "activeId"], (state, prevState) => { + if (state.moves === prevState.moves) { + combobox.setState("activeValue", void 0); + } + }) + ); + setup( + combobox, + () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { + if (state.moves === prev.moves) + return; + const { activeId: activeId2 } = combobox.getState(); + const activeItem = composite.item(activeId2); + combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value); + }) + ); + return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, popover), composite), combobox), { + setValue: (value2) => combobox.setState("value", value2), + setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) }); } -/* harmony default export */ var undo_redo_redo = ((0,external_wp_element_namespaceObject.forwardRef)(RedoButton)); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/document-actions/index.js -/** - * External dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/ZKJ2WLF7.js +"use client"; -/** - * WordPress dependencies - */ +// src/combobox/combobox-store.ts +function useComboboxStoreProps(store, update, props) { + store = usePopoverStoreProps(store, update, props); + store = useCompositeStoreProps(store, update, props); + useStoreProps(store, props, "value", "setValue"); + useStoreProps(store, props, "selectedValue", "setSelectedValue"); + useStoreProps(store, props, "resetValueOnHide"); + useStoreProps(store, props, "resetValueOnSelect"); + return store; +} +function useComboboxStore(props = {}) { + const [store, update] = EKQEJRUF_useStore(createComboboxStore, props); + return useComboboxStoreProps(store, update, props); +} +// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js +var jsx_runtime = __webpack_require__(4922); +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/3ORBWXWF.js +"use client"; -/** - * Internal dependencies - */ +// src/utils/system.tsx -const typeLabels = { - [PATTERN_TYPES.user]: (0,external_wp_i18n_namespaceObject.__)('Editing pattern:'), - [NAVIGATION_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Editing navigation menu:'), - [TEMPLATE_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Editing template:'), - [TEMPLATE_PART_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Editing template part:') -}; -function DocumentActions() { - const isPage = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).isPage(), []); - return isPage ? (0,external_wp_element_namespaceObject.createElement)(PageDocumentActions, null) : (0,external_wp_element_namespaceObject.createElement)(TemplateDocumentActions, null); +function isRenderProp(children) { + return typeof children === "function"; } -function PageDocumentActions() { - const { - hasPageContentFocus, - hasResolved, - isFound, - title - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - hasPageContentFocus: _hasPageContentFocus, - getEditedPostContext - } = select(store_store); - const { - getEditedEntityRecord, - hasFinishedResolution - } = select(external_wp_coreData_namespaceObject.store); - const context = getEditedPostContext(); - const queryArgs = ['postType', context.postType, context.postId]; - const page = getEditedEntityRecord(...queryArgs); - return { - hasPageContentFocus: _hasPageContentFocus(), - hasResolved: hasFinishedResolution('getEditedEntityRecord', queryArgs), - isFound: !!page, - title: page?.title - }; - }, []); - const { - setHasPageContentFocus - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const [hasEditedTemplate, setHasEditedTemplate] = (0,external_wp_element_namespaceObject.useState)(false); - const prevHasPageContentFocus = (0,external_wp_element_namespaceObject.useRef)(false); - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (prevHasPageContentFocus.current && !hasPageContentFocus) { - setHasEditedTemplate(true); - } - prevHasPageContentFocus.current = hasPageContentFocus; - }, [hasPageContentFocus]); - if (!hasResolved) { - return null; - } - if (!isFound) { - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-document-actions" - }, (0,external_wp_i18n_namespaceObject.__)('Document not found')); - } - return hasPageContentFocus ? (0,external_wp_element_namespaceObject.createElement)(BaseDocumentActions, { - className: classnames_default()('is-page', { - 'is-animated': hasEditedTemplate - }), - icon: library_page - }, title) : (0,external_wp_element_namespaceObject.createElement)(TemplateDocumentActions, { - className: "is-animated", - onBack: () => setHasPageContentFocus(true) - }); +function forwardRef2(render) { + const Role = React.forwardRef((props, ref) => render(__spreadProps(__spreadValues({}, props), { ref }))); + Role.displayName = render.displayName || render.name; + return Role; } -function TemplateDocumentActions({ - className, - onBack -}) { - var _typeLabels$record$ty; - const { - isLoaded, - record, - getTitle, - icon - } = useEditedEntityRecord(); - if (!isLoaded) { - return null; - } - if (!record) { - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-document-actions" - }, (0,external_wp_i18n_namespaceObject.__)('Document not found')); +function memo2(Component, propsAreEqual) { + const Role = React.memo(Component, propsAreEqual); + Role.displayName = Component.displayName || Component.name; + return Role; +} +function createComponent(render) { + const Role = (props, ref) => render(_4R3V3JGP_spreadValues({ ref }, props)); + return external_React_.forwardRef(Role); +} +function createMemoComponent(render) { + const Role = createComponent(render); + return external_React_.memo(Role); +} +function _3ORBWXWF_createElement(Type, props) { + const _a = props, { as: As, wrapElement, render } = _a, rest = __objRest(_a, ["as", "wrapElement", "render"]); + let element; + const mergedRef = useMergeRefs(props.ref, getRefProperty(render)); + if (false) {} + if (As && typeof As !== "string") { + element = /* @__PURE__ */ (0,jsx_runtime.jsx)(As, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, rest), { render })); + } else if (external_React_.isValidElement(render)) { + const renderProps = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, render.props), { ref: mergedRef }); + element = external_React_.cloneElement(render, mergeProps(rest, renderProps)); + } else if (render) { + element = render(rest); + } else if (isRenderProp(props.children)) { + if (false) {} + const _b = rest, { children } = _b, otherProps = __objRest(_b, ["children"]); + element = props.children(otherProps); + } else if (As) { + element = /* @__PURE__ */ (0,jsx_runtime.jsx)(As, _4R3V3JGP_spreadValues({}, rest)); + } else { + element = /* @__PURE__ */ (0,jsx_runtime.jsx)(Type, _4R3V3JGP_spreadValues({}, rest)); } - let typeIcon = icon; - if (record.type === NAVIGATION_POST_TYPE) { - typeIcon = library_navigation; - } else if (record.type === PATTERN_TYPES.user) { - typeIcon = library_symbol; + if (wrapElement) { + return wrapElement(element); } - return (0,external_wp_element_namespaceObject.createElement)(BaseDocumentActions, { - className: classnames_default()(className, { - 'is-synced-entity': record.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced - }), - icon: typeIcon, - onBack: onBack - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { - as: "span" - }, (_typeLabels$record$ty = typeLabels[record.type]) !== null && _typeLabels$record$ty !== void 0 ? _typeLabels$record$ty : typeLabels[TEMPLATE_POST_TYPE]), getTitle()); + return element; } -function BaseDocumentActions({ - className, - icon, - children, - onBack -}) { - const { - open: openCommandCenter - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store); - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: classnames_default()('edit-site-document-actions', className) - }, onBack && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - className: "edit-site-document-actions__back", - icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right_small : chevron_left_small, - onClick: event => { - event.stopPropagation(); - onBack(); +function createHook(useProps) { + const useRole = (props = {}) => { + const htmlProps = useProps(props); + const copy = {}; + for (const prop in htmlProps) { + if (Y3OOHFCN_hasOwnProperty(htmlProps, prop) && htmlProps[prop] !== void 0) { + copy[prop] = htmlProps[prop]; + } } - }, (0,external_wp_i18n_namespaceObject.__)('Back')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - className: "edit-site-document-actions__command", - onClick: () => openCommandCenter() - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - className: "edit-site-document-actions__title", - spacing: 1, - justify: "center" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { - icon: icon - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - size: "body", - as: "h1" - }, children)), (0,external_wp_element_namespaceObject.createElement)("span", { - className: "edit-site-document-actions__shortcut" - }, external_wp_keycodes_namespaceObject.displayShortcut.primary('k')))); + return copy; + }; + return useRole; +} +function createStoreContext(providers = [], scopedProviders = []) { + const context = external_React_.createContext(void 0); + const scopedContext = external_React_.createContext(void 0); + const useContext2 = () => external_React_.useContext(context); + const useScopedContext = (onlyScoped = false) => { + const scoped = external_React_.useContext(scopedContext); + const store = useContext2(); + if (onlyScoped) + return scoped; + return scoped || store; + }; + const useProviderContext = () => { + const scoped = external_React_.useContext(scopedContext); + const store = useContext2(); + if (scoped && scoped === store) + return; + return store; + }; + const ContextProvider = (props) => { + return providers.reduceRight( + (children, Provider) => /* @__PURE__ */ (0,jsx_runtime.jsx)(Provider, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { children })), + /* @__PURE__ */ (0,jsx_runtime.jsx)(context.Provider, _4R3V3JGP_spreadValues({}, props)) + ); + }; + const ScopedContextProvider = (props) => { + return /* @__PURE__ */ (0,jsx_runtime.jsx)(ContextProvider, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { children: scopedProviders.reduceRight( + (children, Provider) => /* @__PURE__ */ (0,jsx_runtime.jsx)(Provider, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { children })), + /* @__PURE__ */ (0,jsx_runtime.jsx)(scopedContext.Provider, _4R3V3JGP_spreadValues({}, props)) + ) })); + }; + return { + context, + scopedContext, + useContext: useContext2, + useScopedContext, + useProviderContext, + ContextProvider, + ScopedContextProvider + }; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/index.js -/** - * External dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/4UUKJZ4V.js +"use client"; -/** - * WordPress dependencies - */ +// src/collection/collection-context.tsx +var ctx = createStoreContext(); +var useCollectionContext = ctx.useContext; +var useCollectionScopedContext = ctx.useScopedContext; +var useCollectionProviderContext = ctx.useProviderContext; +var CollectionContextProvider = ctx.ContextProvider; +var CollectionScopedContextProvider = ctx.ScopedContextProvider; +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/IB7YUKH5.js +"use client"; +// src/composite/composite-context.tsx +var IB7YUKH5_ctx = createStoreContext( + [CollectionContextProvider], + [CollectionScopedContextProvider] +); +var useCompositeContext = IB7YUKH5_ctx.useContext; +var useCompositeScopedContext = IB7YUKH5_ctx.useScopedContext; +var useCompositeProviderContext = IB7YUKH5_ctx.useProviderContext; +var CompositeContextProvider = IB7YUKH5_ctx.ContextProvider; +var CompositeScopedContextProvider = IB7YUKH5_ctx.ScopedContextProvider; +var CompositeItemContext = (0,external_React_.createContext)( + void 0 +); +var CompositeRowContext = (0,external_React_.createContext)( + void 0 +); +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/OAYFXAQ2.js +"use client"; -/** - * Internal dependencies - */ +// src/disclosure/disclosure-context.tsx +var OAYFXAQ2_ctx = createStoreContext(); +var useDisclosureContext = OAYFXAQ2_ctx.useContext; +var useDisclosureScopedContext = OAYFXAQ2_ctx.useScopedContext; +var useDisclosureProviderContext = OAYFXAQ2_ctx.useProviderContext; +var DisclosureContextProvider = OAYFXAQ2_ctx.ContextProvider; +var DisclosureScopedContextProvider = OAYFXAQ2_ctx.ScopedContextProvider; +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/G6BJYYBK.js +"use client"; +// src/dialog/dialog-context.tsx +var G6BJYYBK_ctx = createStoreContext( + [DisclosureContextProvider], + [DisclosureScopedContextProvider] +); +var useDialogContext = G6BJYYBK_ctx.useContext; +var useDialogScopedContext = G6BJYYBK_ctx.useScopedContext; +var useDialogProviderContext = G6BJYYBK_ctx.useProviderContext; +var DialogContextProvider = G6BJYYBK_ctx.ContextProvider; +var DialogScopedContextProvider = G6BJYYBK_ctx.ScopedContextProvider; +var DialogHeadingContext = (0,external_React_.createContext)(void 0); +var DialogDescriptionContext = (0,external_React_.createContext)(void 0); -const { - useShouldContextualToolbarShow -} = unlock(external_wp_blockEditor_namespaceObject.privateApis); -const preventDefault = event => { - event.preventDefault(); -}; -function HeaderEditMode({ - setListViewToggleElement -}) { - const inserterButton = (0,external_wp_element_namespaceObject.useRef)(); - const { - deviceType, - templateType, - isInserterOpen, - isListViewOpen, - listViewShortcut, - isVisualMode, - isDistractionFree, - blockEditorMode, - homeUrl, - showIconLabels, - editorCanvasView, - hasFixedToolbar - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - __experimentalGetPreviewDeviceType, - getEditedPostType, - isInserterOpened, - isListViewOpened, - getEditorMode - } = select(store_store); - const { - getShortcutRepresentation - } = select(external_wp_keyboardShortcuts_namespaceObject.store); - const { - __unstableGetEditorMode - } = select(external_wp_blockEditor_namespaceObject.store); - const postType = getEditedPostType(); - const { - getUnstableBase // Site index. - } = select(external_wp_coreData_namespaceObject.store); - const { - get: getPreference - } = select(external_wp_preferences_namespaceObject.store); - return { - deviceType: __experimentalGetPreviewDeviceType(), - templateType: postType, - isInserterOpen: isInserterOpened(), - isListViewOpen: isListViewOpened(), - listViewShortcut: getShortcutRepresentation('core/edit-site/toggle-list-view'), - isVisualMode: getEditorMode() === 'visual', - blockEditorMode: __unstableGetEditorMode(), - homeUrl: getUnstableBase()?.home, - showIconLabels: getPreference(store_store.name, 'showIconLabels'), - editorCanvasView: unlock(select(store_store)).getEditorCanvasContainerView(), - isDistractionFree: getPreference(store_store.name, 'distractionFree'), - hasFixedToolbar: getPreference(store_store.name, 'fixedToolbar') - }; - }, []); - const { - __experimentalSetPreviewDeviceType: setPreviewDeviceType, - setIsInserterOpened, - setIsListViewOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const { - __unstableSetEditorMode - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); - const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); - const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); - const toggleInserter = (0,external_wp_element_namespaceObject.useCallback)(() => { - if (isInserterOpen) { - // Focusing the inserter button should close the inserter popover. - // However, there are some cases it won't close when the focus is lost. - // See https://github.com/WordPress/gutenberg/issues/43090 for more details. - inserterButton.current.focus(); - setIsInserterOpened(false); - } else { - setIsInserterOpened(true); - } - }, [isInserterOpen, setIsInserterOpened]); - const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]); - const { - shouldShowContextualToolbar, - canFocusHiddenToolbar, - fixedToolbarCanBeFocused - } = useShouldContextualToolbarShow(); - // If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar. - // There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport. - const blockToolbarCanBeFocused = shouldShowContextualToolbar || canFocusHiddenToolbar || fixedToolbarCanBeFocused; - const hasDefaultEditorCanvasView = !useHasEditorCanvasContainer(); - const isFocusMode = FOCUSABLE_ENTITIES.includes(templateType); - /* translators: button label text should, if possible, be under 16 characters. */ - const longLabel = (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button'); - const shortLabel = !isInserterOpen ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close'); - const isZoomedOutViewExperimentEnabled = window?.__experimentalEnableZoomedOutView && isVisualMode; - const isZoomedOutView = blockEditorMode === 'zoom-out'; - const toolbarVariants = { - isDistractionFree: { - y: '-50px' - }, - isDistractionFreeHovering: { - y: 0 - }, - view: { - y: 0 - }, - edit: { - y: 0 - } - }; - const toolbarTransition = { - type: 'tween', - duration: disableMotion ? 0 : 0.2, - ease: 'easeOut' - }; - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: classnames_default()('edit-site-header-edit-mode', { - 'show-icon-labels': showIconLabels - }) - }, hasDefaultEditorCanvasView && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, { - as: external_wp_components_namespaceObject.__unstableMotion.div, - className: "edit-site-header-edit-mode__start", - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools'), - shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused, - variants: toolbarVariants, - transition: toolbarTransition - }, (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-header-edit-mode__toolbar" - }, !isDistractionFree && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { - ref: inserterButton, - as: external_wp_components_namespaceObject.Button, - className: "edit-site-header-edit-mode__inserter-toggle", - variant: "primary", - isPressed: isInserterOpen, - onMouseDown: preventDefault, - onClick: toggleInserter, - disabled: !isVisualMode, - icon: library_plus, - label: showIconLabels ? shortLabel : longLabel, - showTooltip: !showIconLabels, - "aria-expanded": isInserterOpen - }), isLargeViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !hasFixedToolbar && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { - as: external_wp_blockEditor_namespaceObject.ToolSelector, - showTooltip: !showIconLabels, - variant: showIconLabels ? 'tertiary' : undefined, - disabled: !isVisualMode - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { - as: undo_redo_undo, - showTooltip: !showIconLabels, - variant: showIconLabels ? 'tertiary' : undefined - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { - as: undo_redo_redo, - showTooltip: !showIconLabels, - variant: showIconLabels ? 'tertiary' : undefined - }), !isDistractionFree && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { - as: external_wp_components_namespaceObject.Button, - className: "edit-site-header-edit-mode__list-view-toggle", - disabled: !isVisualMode || isZoomedOutView, - icon: list_view, - isPressed: isListViewOpen - /* translators: button label text should, if possible, be under 16 characters. */, - label: (0,external_wp_i18n_namespaceObject.__)('List View'), - onClick: toggleListView, - ref: setListViewToggleElement, - shortcut: listViewShortcut, - showTooltip: !showIconLabels, - variant: showIconLabels ? 'tertiary' : undefined, - "aria-expanded": isListViewOpen - }), isZoomedOutViewExperimentEnabled && !isDistractionFree && !hasFixedToolbar && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { - as: external_wp_components_namespaceObject.Button, - className: "edit-site-header-edit-mode__zoom-out-view-toggle", - icon: chevron_up_down, - isPressed: isZoomedOutView - /* translators: button label text should, if possible, be under 16 characters. */, - label: (0,external_wp_i18n_namespaceObject.__)('Zoom-out View'), - onClick: () => { - setPreviewDeviceType('Desktop'); - __unstableSetEditorMode(isZoomedOutView ? 'edit' : 'zoom-out'); - } - })))), !isDistractionFree && (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-header-edit-mode__center" - }, !hasDefaultEditorCanvasView ? getEditorCanvasContainerTitle(editorCanvasView) : (0,external_wp_element_namespaceObject.createElement)(DocumentActions, null)), (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-header-edit-mode__end" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { - className: "edit-site-header-edit-mode__actions", - variants: toolbarVariants, - transition: toolbarTransition - }, (0,external_wp_element_namespaceObject.createElement)("div", { - className: classnames_default()('edit-site-header-edit-mode__preview-options', { - 'is-zoomed-out': isZoomedOutView - }) - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalPreviewOptions, { - deviceType: deviceType, - setDeviceType: setPreviewDeviceType, - label: (0,external_wp_i18n_namespaceObject.__)('View'), - isEnabled: !isFocusMode && hasDefaultEditorCanvasView - }, ({ - onClose - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - href: homeUrl, - target: "_blank", - icon: library_external, - onClick: onClose - }, (0,external_wp_i18n_namespaceObject.__)('View site'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { - as: "span" - }, /* translators: accessibility text */ - (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')))))), (0,external_wp_element_namespaceObject.createElement)(SaveButton, null), !isDistractionFree && (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, { - scope: "core/edit-site" - }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, { - showIconLabels: showIconLabels - })))); -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/wordpress.js +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/7H5KSHHF.js +"use client"; -/** - * WordPress dependencies - */ -const wordpress = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "-2 -2 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - 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" -})); -/* harmony default export */ var library_wordpress = (wordpress); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/site-icon/index.js +// src/popover/popover-context.tsx +var _7H5KSHHF_ctx = createStoreContext( + [DialogContextProvider], + [DialogScopedContextProvider] +); +var usePopoverContext = _7H5KSHHF_ctx.useContext; +var usePopoverScopedContext = _7H5KSHHF_ctx.useScopedContext; +var usePopoverProviderContext = _7H5KSHHF_ctx.useProviderContext; +var PopoverContextProvider = _7H5KSHHF_ctx.ContextProvider; +var PopoverScopedContextProvider = _7H5KSHHF_ctx.ScopedContextProvider; -/** - * External dependencies - */ -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/W76OTZCC.js +"use client"; +// src/combobox/combobox-context.tsx -function SiteIcon({ - className -}) { - const { - isRequestingSite, - siteIconUrl - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getEntityRecord - } = select(external_wp_coreData_namespaceObject.store); - const siteData = getEntityRecord('root', '__unstableBase', undefined); - return { - isRequestingSite: !siteData, - siteIconUrl: siteData?.site_icon_url - }; - }, []); - if (isRequestingSite && !siteIconUrl) { - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-site-icon__image" - }); - } - const icon = siteIconUrl ? (0,external_wp_element_namespaceObject.createElement)("img", { - className: "edit-site-site-icon__image", - alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'), - src: siteIconUrl - }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, { - className: "edit-site-site-icon__icon", - size: "48px", - icon: library_wordpress - }); - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: classnames_default()(className, 'edit-site-site-icon') - }, icon); -} -/* harmony default export */ var site_icon = (SiteIcon); +var W76OTZCC_ctx = createStoreContext( + [PopoverContextProvider, CompositeContextProvider], + [PopoverScopedContextProvider, CompositeScopedContextProvider] +); +var useComboboxContext = W76OTZCC_ctx.useContext; +var useComboboxScopedContext = W76OTZCC_ctx.useScopedContext; +var useComboboxProviderContext = W76OTZCC_ctx.useProviderContext; +var ComboboxContextProvider = W76OTZCC_ctx.ContextProvider; +var ComboboxScopedContextProvider = W76OTZCC_ctx.ScopedContextProvider; +var ComboboxItemValueContext = (0,external_React_.createContext)( + void 0 +); +var ComboboxItemCheckedContext = (0,external_React_.createContext)(false); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/site-hub/index.js -/** - * External dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js +"use client"; -/** - * WordPress dependencies - */ @@ -33979,519 +39234,1098 @@ function SiteIcon({ -/** - * Internal dependencies - */ -const HUB_ANIMATION_DURATION = 0.3; -const SiteHub = (0,external_wp_element_namespaceObject.forwardRef)(({ - isTransparent, - ...restProps -}, ref) => { - const { - canvasMode, - dashboardLink, - homeUrl, - siteTitle - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getCanvasMode, - getSettings - } = unlock(select(store_store)); - const { - getSite, - getUnstableBase // Site index. - } = select(external_wp_coreData_namespaceObject.store); - return { - canvasMode: getCanvasMode(), - dashboardLink: getSettings().__experimentalDashboardLink || 'index.php', - homeUrl: getUnstableBase()?.home, - siteTitle: getSite()?.title - }; - }, []); - const { - open: openCommandCenter - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store); - const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); - const { - setCanvasMode, - __experimentalSetPreviewDeviceType: setPreviewDeviceType - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const { - clearSelectedBlock - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); - const isBackToDashboardButton = canvasMode === 'view'; - const siteIconButtonProps = isBackToDashboardButton ? { - href: dashboardLink, - label: (0,external_wp_i18n_namespaceObject.__)('Go to the Dashboard') - } : { - href: dashboardLink, - // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation. - role: 'button', - label: (0,external_wp_i18n_namespaceObject.__)('Open Navigation'), - onClick: event => { - event.preventDefault(); - if (canvasMode === 'edit') { - clearSelectedBlock(); - setPreviewDeviceType('Desktop'); - setCanvasMode('view'); - } - } - }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { - ref: ref, - ...restProps, - className: classnames_default()('edit-site-site-hub', restProps.className), - initial: false, - transition: { - type: 'tween', - duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, - ease: 'easeOut' - } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - justify: "space-between", - alignment: "center", - className: "edit-site-site-hub__container" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - justify: "flex-start", - className: "edit-site-site-hub__text-content", - spacing: "0" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { - className: classnames_default()('edit-site-site-hub__view-mode-toggle-container', { - 'has-transparent-background': isTransparent - }), - layout: true, - transition: { - type: 'tween', - duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, - ease: 'easeOut' - } - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - ...siteIconButtonProps, - className: "edit-site-layout__view-mode-toggle" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { - initial: false, - animate: { - scale: canvasMode === 'view' ? 0.5 : 1 - }, - whileHover: { - scale: canvasMode === 'view' ? 0.5 : 0.96 - }, - transition: { - type: 'tween', - duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, - ease: 'easeOut' - } - }, (0,external_wp_element_namespaceObject.createElement)(site_icon, { - className: "edit-site-layout__view-mode-toggle-icon" - })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { - layout: canvasMode === 'edit', - animate: { - opacity: canvasMode === 'view' ? 1 : 0 - }, - exit: { - opacity: 0 - }, - className: classnames_default()('edit-site-site-hub__site-title', { - 'is-transparent': isTransparent - }), - transition: { - type: 'tween', - duration: disableMotion ? 0 : 0.2, - ease: 'easeOut', - delay: canvasMode === 'view' ? 0.1 : 0 - } - }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle))), canvasMode === 'view' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - href: homeUrl, - target: "_blank", - label: (0,external_wp_i18n_namespaceObject.__)('View site (opens in a new tab)'), - "aria-label": (0,external_wp_i18n_namespaceObject.__)('View site (opens in a new tab)'), - icon: library_external, - className: "edit-site-site-hub__site-view-link" - })), canvasMode === 'view' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - className: classnames_default()('edit-site-site-hub_toggle-command-center', { - 'is-transparent': isTransparent - }), - icon: library_search, - onClick: () => openCommandCenter(), - label: (0,external_wp_i18n_namespaceObject.__)('Open command palette'), - shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('k') - }))); -}); -/* harmony default export */ var site_hub = (SiteHub); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/resizable-frame/index.js -/** - * External dependencies - */ +// src/combobox/combobox-provider.tsx +function ComboboxProvider(props = {}) { + const store = useComboboxStore(props); + return /* @__PURE__ */ (0,jsx_runtime.jsx)(ComboboxContextProvider, { value: store, children: props.children }); +} -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox-label.js +"use client"; -/** - * Internal dependencies - */ -// Removes the inline styles in the drag handles. -const resizable_frame_HANDLE_STYLES_OVERRIDE = { - position: undefined, - userSelect: undefined, - cursor: undefined, - width: undefined, - height: undefined, - top: undefined, - right: undefined, - bottom: undefined, - left: undefined -}; -// The minimum width of the frame (in px) while resizing. -const FRAME_MIN_WIDTH = 320; -// The reference width of the frame (in px) used to calculate the aspect ratio. -const FRAME_REFERENCE_WIDTH = 1300; -// 9 : 19.5 is the target aspect ratio enforced (when possible) while resizing. -const FRAME_TARGET_ASPECT_RATIO = 9 / 19.5; -// The minimum distance (in px) between the frame resize handle and the -// viewport's edge. If the frame is resized to be closer to the viewport's edge -// than this distance, then "canvas mode" will be enabled. -const SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200; -// Default size for the `frameSize` state. -const INITIAL_FRAME_SIZE = { - width: '100%', - height: '100%' -}; -function calculateNewHeight(width, initialAspectRatio) { - const lerp = (a, b, amount) => { - return a + (b - a) * amount; - }; - // Calculate the intermediate aspect ratio based on the current width. - const lerpFactor = 1 - Math.max(0, Math.min(1, (width - FRAME_MIN_WIDTH) / (FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH))); - // Calculate the height based on the intermediate aspect ratio - // ensuring the frame arrives at the target aspect ratio. - const intermediateAspectRatio = lerp(initialAspectRatio, FRAME_TARGET_ASPECT_RATIO, lerpFactor); - return width / intermediateAspectRatio; -} -function ResizableFrame({ - isFullWidth, - isOversized, - setIsOversized, - isReady, - children, - /** The default (unresized) width/height of the frame, based on the space availalbe in the viewport. */ - defaultSize, - innerContentStyle -}) { - const [frameSize, setFrameSize] = (0,external_wp_element_namespaceObject.useState)(INITIAL_FRAME_SIZE); - // The width of the resizable frame when a new resize gesture starts. - const [startingWidth, setStartingWidth] = (0,external_wp_element_namespaceObject.useState)(); - const [isResizing, setIsResizing] = (0,external_wp_element_namespaceObject.useState)(false); - const [shouldShowHandle, setShouldShowHandle] = (0,external_wp_element_namespaceObject.useState)(false); - const [resizeRatio, setResizeRatio] = (0,external_wp_element_namespaceObject.useState)(1); - const canvasMode = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getCanvasMode(), []); - const { - setCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const FRAME_TRANSITION = { - type: 'tween', - duration: isResizing ? 0 : 0.5 - }; - const frameRef = (0,external_wp_element_namespaceObject.useRef)(null); - const resizableHandleHelpId = (0,external_wp_compose_namespaceObject.useInstanceId)(ResizableFrame, 'edit-site-resizable-frame-handle-help'); - const defaultAspectRatio = defaultSize.width / defaultSize.height; - const handleResizeStart = (_event, _direction, ref) => { - // Remember the starting width so we don't have to get `ref.offsetWidth` on - // every resize event thereafter, which will cause layout thrashing. - setStartingWidth(ref.offsetWidth); - setIsResizing(true); - }; +// src/combobox/combobox-label.ts - // Calculate the frame size based on the window width as its resized. - const handleResize = (_event, _direction, _ref, delta) => { - const normalizedDelta = delta.width / resizeRatio; - const deltaAbs = Math.abs(normalizedDelta); - const maxDoubledDelta = delta.width < 0 // is shrinking - ? deltaAbs : (defaultSize.width - startingWidth) / 2; - const deltaToDouble = Math.min(deltaAbs, maxDoubledDelta); - const doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs; - const singleSegment = 1 - doubleSegment; - setResizeRatio(singleSegment + doubleSegment * 2); - const updatedWidth = startingWidth + delta.width; - setIsOversized(updatedWidth > defaultSize.width); +var useComboboxLabel = createHook( + (_a) => { + var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); + const context = useComboboxProviderContext(); + store = store || context; + invariant( + store, + false && 0 + ); + const comboboxId = store.useState((state) => { + var _a2; + return (_a2 = state.baseElement) == null ? void 0 : _a2.id; + }); + props = _4R3V3JGP_spreadValues({ + htmlFor: comboboxId + }, props); + return props; + } +); +var ComboboxLabel = createMemoComponent( + (props) => { + const htmlProps = useComboboxLabel(props); + return _3ORBWXWF_createElement("label", htmlProps); + } +); +if (false) {} - // Width will be controlled by the library (via `resizeRatio`), - // so we only need to update the height. - setFrameSize({ - height: isOversized ? '100%' : calculateNewHeight(updatedWidth, defaultAspectRatio) + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/JCH6MLL2.js +"use client"; + + + + + +// src/popover/popover-anchor.ts +var usePopoverAnchor = createHook( + (_a) => { + var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); + const context = usePopoverProviderContext(); + store = store || context; + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { + ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref) }); - }; - const handleResizeStop = (_event, _direction, ref) => { - setIsResizing(false); - if (!isOversized) { - return; + return props; + } +); +var PopoverAnchor = createComponent((props) => { + const htmlProps = usePopoverAnchor(props); + return _3ORBWXWF_createElement("div", htmlProps); +}); +if (false) {} + + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/3IEDWLST.js +"use client"; + +// src/composite/utils.ts + +var _3IEDWLST_NULL_ITEM = { id: null }; +function _3IEDWLST_flipItems(items, activeId, shouldInsertNullItem = false) { + const index = items.findIndex((item) => item.id === activeId); + return [ + ...items.slice(index + 1), + ...shouldInsertNullItem ? [_3IEDWLST_NULL_ITEM] : [], + ...items.slice(0, index) + ]; +} +function _3IEDWLST_findFirstEnabledItem(items, excludeId) { + return items.find((item) => { + if (excludeId) { + return !item.disabled && item.id !== excludeId; } - setIsOversized(false); - const remainingWidth = ref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth; - if (remainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD) { - // Reset the initial aspect ratio if the frame is resized slightly - // above the sidebar but not far enough to trigger full screen. - setFrameSize(INITIAL_FRAME_SIZE); + return !item.disabled; + }); +} +function getEnabledItem(store, id) { + if (!id) + return null; + return store.item(id) || null; +} +function _3IEDWLST_groupItemsByRows(items) { + const rows = []; + for (const item of items) { + const row = rows.find((currentRow) => { + var _a; + return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; + }); + if (row) { + row.push(item); } else { - // Trigger full screen if the frame is resized far enough to the left. - setCanvasMode('edit'); + rows.push([item]); } - }; + } + return rows; +} +function selectTextField(element, collapseToEnd = false) { + if (isTextField(element)) { + element.setSelectionRange( + collapseToEnd ? element.value.length : 0, + element.value.length + ); + } else if (element.isContentEditable) { + const selection = getDocument(element).getSelection(); + selection == null ? void 0 : selection.selectAllChildren(element); + if (collapseToEnd) { + selection == null ? void 0 : selection.collapseToEnd(); + } + } +} +var FOCUS_SILENTLY = Symbol("FOCUS_SILENTLY"); +function focusSilently(element) { + element[FOCUS_SILENTLY] = true; + element.focus({ preventScroll: true }); +} +function silentlyFocused(element) { + const isSilentlyFocused = element[FOCUS_SILENTLY]; + delete element[FOCUS_SILENTLY]; + return isSilentlyFocused; +} +function isItem(store, element, exclude) { + if (!element) + return false; + if (element === exclude) + return false; + const item = store.item(element.id); + if (!item) + return false; + if (exclude && item.element === exclude) + return false; + return true; +} - // Handle resize by arrow keys - const handleResizableHandleKeyDown = event => { - if (!['ArrowLeft', 'ArrowRight'].includes(event.key)) { - return; + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/SHA3WOPI.js +"use client"; + +// src/focusable/focusable-context.ts + +var FocusableContext = (0,external_React_.createContext)(true); + + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/utils/focus.js +"use client"; + + + +// src/utils/focus.ts +var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])"; +function hasNegativeTabIndex(element) { + const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10); + return tabIndex < 0; +} +function isFocusable(element) { + if (!matches(element, selector)) + return false; + if (!isVisible(element)) + return false; + if (DLOEKDPY_closest(element, "[inert]")) + return false; + return true; +} +function isTabbable(element) { + if (!isFocusable(element)) + return false; + if (hasNegativeTabIndex(element)) + return false; + if (!("form" in element)) + return true; + if (!element.form) + return true; + if (element.checked) + return true; + if (element.type !== "radio") + return true; + const radioGroup = element.form.elements.namedItem(element.name); + if (!radioGroup) + return true; + if (!("length" in radioGroup)) + return true; + const activeElement = getActiveElement(element); + if (!activeElement) + return true; + if (activeElement === element) + return true; + if (!("form" in activeElement)) + return true; + if (activeElement.form !== element.form) + return true; + if (activeElement.name !== element.name) + return true; + return false; +} +function getAllFocusableIn(container, includeContainer) { + const elements = Array.from( + container.querySelectorAll(selector) + ); + if (includeContainer) { + elements.unshift(container); + } + const focusableElements = elements.filter(isFocusable); + focusableElements.forEach((element, i) => { + if (isFrame(element) && element.contentDocument) { + const frameBody = element.contentDocument.body; + focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody)); } - event.preventDefault(); - const step = 20 * (event.shiftKey ? 5 : 1); - const delta = step * (event.key === 'ArrowLeft' ? 1 : -1); - const newWidth = Math.min(Math.max(FRAME_MIN_WIDTH, frameRef.current.resizable.offsetWidth + delta), defaultSize.width); - setFrameSize({ - width: newWidth, - height: calculateNewHeight(newWidth, defaultAspectRatio) - }); - }; - const frameAnimationVariants = { - default: { - flexGrow: 0, - height: frameSize.height - }, - fullWidth: { - flexGrow: 1, - height: frameSize.height + }); + return focusableElements; +} +function getAllFocusable(includeBody) { + return getAllFocusableIn(document.body, includeBody); +} +function getFirstFocusableIn(container, includeContainer) { + const [first] = getAllFocusableIn(container, includeContainer); + return first || null; +} +function getFirstFocusable(includeBody) { + return getFirstFocusableIn(document.body, includeBody); +} +function getAllTabbableIn(container, includeContainer, fallbackToFocusable) { + const elements = Array.from( + container.querySelectorAll(selector) + ); + const tabbableElements = elements.filter(isTabbable); + if (includeContainer && isTabbable(container)) { + tabbableElements.unshift(container); + } + tabbableElements.forEach((element, i) => { + if (isFrame(element) && element.contentDocument) { + const frameBody = element.contentDocument.body; + const allFrameTabbable = getAllTabbableIn( + frameBody, + false, + fallbackToFocusable + ); + tabbableElements.splice(i, 1, ...allFrameTabbable); } - }; - const resizeHandleVariants = { - hidden: { - opacity: 0, - left: 0 - }, - visible: { - opacity: 1, - left: -16 - }, - active: { - opacity: 1, - left: -16, - scaleY: 1.3 + }); + if (!tabbableElements.length && fallbackToFocusable) { + return elements; + } + return tabbableElements; +} +function getAllTabbable(fallbackToFocusable) { + return getAllTabbableIn(document.body, false, fallbackToFocusable); +} +function getFirstTabbableIn(container, includeContainer, fallbackToFocusable) { + const [first] = getAllTabbableIn( + container, + includeContainer, + fallbackToFocusable + ); + return first || null; +} +function getFirstTabbable(fallbackToFocusable) { + return getFirstTabbableIn(document.body, false, fallbackToFocusable); +} +function getLastTabbableIn(container, includeContainer, fallbackToFocusable) { + const allTabbable = getAllTabbableIn( + container, + includeContainer, + fallbackToFocusable + ); + return allTabbable[allTabbable.length - 1] || null; +} +function getLastTabbable(fallbackToFocusable) { + return getLastTabbableIn(document.body, false, fallbackToFocusable); +} +function getNextTabbableIn(container, includeContainer, fallbackToFirst, fallbackToFocusable) { + const activeElement = getActiveElement(container); + const allFocusable = getAllFocusableIn(container, includeContainer); + const activeIndex = allFocusable.indexOf(activeElement); + const nextFocusableElements = allFocusable.slice(activeIndex + 1); + return nextFocusableElements.find(isTabbable) || (fallbackToFirst ? allFocusable.find(isTabbable) : null) || (fallbackToFocusable ? nextFocusableElements[0] : null) || null; +} +function getNextTabbable(fallbackToFirst, fallbackToFocusable) { + return getNextTabbableIn( + document.body, + false, + fallbackToFirst, + fallbackToFocusable + ); +} +function getPreviousTabbableIn(container, includeContainer, fallbackToLast, fallbackToFocusable) { + const activeElement = getActiveElement(container); + const allFocusable = getAllFocusableIn(container, includeContainer).reverse(); + const activeIndex = allFocusable.indexOf(activeElement); + const previousFocusableElements = allFocusable.slice(activeIndex + 1); + return previousFocusableElements.find(isTabbable) || (fallbackToLast ? allFocusable.find(isTabbable) : null) || (fallbackToFocusable ? previousFocusableElements[0] : null) || null; +} +function getPreviousTabbable(fallbackToFirst, fallbackToFocusable) { + return getPreviousTabbableIn( + document.body, + false, + fallbackToFirst, + fallbackToFocusable + ); +} +function getClosestFocusable(element) { + while (element && !isFocusable(element)) { + element = closest(element, selector); + } + return element || null; +} +function hasFocus(element) { + const activeElement = DLOEKDPY_getActiveElement(element); + if (!activeElement) + return false; + if (activeElement === element) + return true; + const activeDescendant = activeElement.getAttribute("aria-activedescendant"); + if (!activeDescendant) + return false; + return activeDescendant === element.id; +} +function hasFocusWithin(element) { + const activeElement = DLOEKDPY_getActiveElement(element); + if (!activeElement) + return false; + if (contains(element, activeElement)) + return true; + const activeDescendant = activeElement.getAttribute("aria-activedescendant"); + if (!activeDescendant) + return false; + if (!("id" in element)) + return false; + if (activeDescendant === element.id) + return true; + return !!element.querySelector(`#${CSS.escape(activeDescendant)}`); +} +function focusIfNeeded(element) { + if (!hasFocusWithin(element) && isFocusable(element)) { + element.focus(); + } +} +function disableFocus(element) { + var _a; + const currentTabindex = (_a = element.getAttribute("tabindex")) != null ? _a : ""; + element.setAttribute("data-tabindex", currentTabindex); + element.setAttribute("tabindex", "-1"); +} +function disableFocusIn(container, includeContainer) { + const tabbableElements = getAllTabbableIn(container, includeContainer); + tabbableElements.forEach(disableFocus); +} +function restoreFocusIn(container) { + const elements = container.querySelectorAll("[data-tabindex]"); + const restoreTabIndex = (element) => { + const tabindex = element.getAttribute("data-tabindex"); + element.removeAttribute("data-tabindex"); + if (tabindex) { + element.setAttribute("tabindex", tabindex); + } else { + element.removeAttribute("tabindex"); } }; - const currentResizeHandleVariant = (() => { - if (isResizing) { - return 'active'; - } - return shouldShowHandle ? 'visible' : 'hidden'; - })(); - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ResizableBox, { - as: external_wp_components_namespaceObject.__unstableMotion.div, - ref: frameRef, - initial: false, - variants: frameAnimationVariants, - animate: isFullWidth ? 'fullWidth' : 'default', - onAnimationComplete: definition => { - if (definition === 'fullWidth') setFrameSize({ - width: '100%', - height: '100%' - }); - }, - transition: FRAME_TRANSITION, - size: frameSize, - enable: { - top: false, - right: false, - bottom: false, - // Resizing will be disabled until the editor content is loaded. - left: isReady, - topRight: false, - bottomRight: false, - bottomLeft: false, - topLeft: false - }, - resizeRatio: resizeRatio, - handleClasses: undefined, - handleStyles: { - left: resizable_frame_HANDLE_STYLES_OVERRIDE, - right: resizable_frame_HANDLE_STYLES_OVERRIDE - }, - minWidth: FRAME_MIN_WIDTH, - maxWidth: isFullWidth ? '100%' : '150%', - maxHeight: '100%', - onFocus: () => setShouldShowHandle(true), - onBlur: () => setShouldShowHandle(false), - onMouseOver: () => setShouldShowHandle(true), - onMouseOut: () => setShouldShowHandle(false), - handleComponent: { - left: canvasMode === 'view' && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, { - text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize') - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.button, { - key: "handle", - role: "separator", - "aria-orientation": "vertical", - className: classnames_default()('edit-site-resizable-frame__handle', { - 'is-resizing': isResizing - }), - variants: resizeHandleVariants, - animate: currentResizeHandleVariant, - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'), - "aria-describedby": resizableHandleHelpId, - "aria-valuenow": frameRef.current?.resizable?.offsetWidth || undefined, - "aria-valuemin": FRAME_MIN_WIDTH, - "aria-valuemax": defaultSize.width, - onKeyDown: handleResizableHandleKeyDown, - initial: "hidden", - exit: "hidden", - whileFocus: "active", - whileHover: "active" - })), (0,external_wp_element_namespaceObject.createElement)("div", { - hidden: true, - id: resizableHandleHelpId - }, (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas. Hold shift to resize in larger increments.'))) - }, - onResizeStart: handleResizeStart, - onResize: handleResize, - onResizeStop: handleResizeStop, - className: classnames_default()('edit-site-resizable-frame__inner', { - 'is-resizing': isResizing - }) - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { - className: "edit-site-resizable-frame__inner-content", - animate: { - borderRadius: isFullWidth ? 0 : 8 - }, - transition: FRAME_TRANSITION, - style: innerContentStyle - }, children)); + if (container.hasAttribute("data-tabindex")) { + restoreTabIndex(container); + } + elements.forEach(restoreTabIndex); +} +function focusIntoView(element, options) { + if (!("scrollIntoView" in element)) { + element.focus(); + } else { + element.focus({ preventScroll: true }); + element.scrollIntoView(_chunks_4R3V3JGP_spreadValues({ block: "nearest", inline: "nearest" }, options)); + } } -/* harmony default export */ var resizable_frame = (ResizableFrame); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/KK7H3W2B.js +"use client"; -/** - * Internal dependencies - */ -const { - useLocation: use_sync_canvas_mode_with_url_useLocation, - useHistory: use_sync_canvas_mode_with_url_useHistory -} = unlock(external_wp_router_namespaceObject.privateApis); -function useSyncCanvasModeWithURL() { - const history = use_sync_canvas_mode_with_url_useHistory(); - const { - params - } = use_sync_canvas_mode_with_url_useLocation(); - const canvasMode = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getCanvasMode(), []); - const { - setCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const currentCanvasMode = (0,external_wp_element_namespaceObject.useRef)(canvasMode); - const { - canvas: canvasInUrl - } = params; - const currentCanvasInUrl = (0,external_wp_element_namespaceObject.useRef)(canvasInUrl); - const currentUrlParams = (0,external_wp_element_namespaceObject.useRef)(params); - (0,external_wp_element_namespaceObject.useEffect)(() => { - currentUrlParams.current = params; - }, [params]); - (0,external_wp_element_namespaceObject.useEffect)(() => { - currentCanvasMode.current = canvasMode; - if (canvasMode === 'init') { +// src/focusable/focusable.ts + + + + + + +var isSafariBrowser = isSafari(); +var alwaysFocusVisibleInputTypes = [ + "text", + "search", + "url", + "tel", + "email", + "password", + "number", + "date", + "month", + "week", + "time", + "datetime", + "datetime-local" +]; +function isAlwaysFocusVisible(element) { + const { tagName, readOnly, type } = element; + if (tagName === "TEXTAREA" && !readOnly) + return true; + if (tagName === "SELECT" && !readOnly) + return true; + if (tagName === "INPUT" && !readOnly) { + return alwaysFocusVisibleInputTypes.includes(type); + } + if (element.isContentEditable) + return true; + return false; +} +function isAlwaysFocusVisibleDelayed(element) { + const role = element.getAttribute("role"); + if (role !== "combobox") + return false; + return !!element.dataset.name; +} +function getLabels(element) { + if ("labels" in element) { + return element.labels; + } + return null; +} +function isNativeCheckboxOrRadio(element) { + const tagName = element.tagName.toLowerCase(); + if (tagName === "input" && element.type) { + return element.type === "radio" || element.type === "checkbox"; + } + return false; +} +function isNativeTabbable(tagName) { + if (!tagName) + return true; + return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; +} +function supportsDisabledAttribute(tagName) { + if (!tagName) + return true; + return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; +} +function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) { + if (!focusable) { + return tabIndexProp; + } + if (trulyDisabled) { + if (nativeTabbable && !supportsDisabled) { + return -1; + } + return; + } + if (nativeTabbable) { + return tabIndexProp; + } + return tabIndexProp || 0; +} +function useDisableEvent(onEvent, disabled) { + return useEvent((event) => { + onEvent == null ? void 0 : onEvent(event); + if (event.defaultPrevented) return; + if (disabled) { + event.stopPropagation(); + event.preventDefault(); } - if (canvasMode === 'edit' && currentCanvasInUrl.current !== canvasMode) { - history.push({ - ...currentUrlParams.current, - canvas: 'edit' - }); + }); +} +var isKeyboardModality = true; +function onGlobalMouseDown(event) { + const target = event.target; + if (target && "hasAttribute" in target) { + if (!target.hasAttribute("data-focus-visible")) { + isKeyboardModality = false; } - if (canvasMode === 'view' && currentCanvasInUrl.current !== undefined) { - history.push({ - ...currentUrlParams.current, - canvas: undefined + } +} +function onGlobalKeyDown(event) { + if (event.metaKey) + return; + if (event.ctrlKey) + return; + if (event.altKey) + return; + isKeyboardModality = true; +} +var useFocusable = createHook( + (_a) => { + var _b = _a, { + focusable = true, + accessibleWhenDisabled, + autoFocus, + onFocusVisible + } = _b, props = __objRest(_b, [ + "focusable", + "accessibleWhenDisabled", + "autoFocus", + "onFocusVisible" + ]); + const ref = (0,external_React_.useRef)(null); + (0,external_React_.useEffect)(() => { + if (!focusable) + return; + addGlobalEventListener("mousedown", onGlobalMouseDown, true); + addGlobalEventListener("keydown", onGlobalKeyDown, true); + }, [focusable]); + if (isSafariBrowser) { + (0,external_React_.useEffect)(() => { + if (!focusable) + return; + const element = ref.current; + if (!element) + return; + if (!isNativeCheckboxOrRadio(element)) + return; + const labels = getLabels(element); + if (!labels) + return; + const onMouseUp = () => queueMicrotask(() => element.focus()); + labels.forEach((label) => label.addEventListener("mouseup", onMouseUp)); + return () => { + labels.forEach( + (label) => label.removeEventListener("mouseup", onMouseUp) + ); + }; + }, [focusable]); + } + const disabled = focusable && disabledFromProps(props); + const trulyDisabled = !!disabled && !accessibleWhenDisabled; + const [focusVisible, setFocusVisible] = (0,external_React_.useState)(false); + (0,external_React_.useEffect)(() => { + if (!focusable) + return; + if (trulyDisabled && focusVisible) { + setFocusVisible(false); + } + }, [focusable, trulyDisabled, focusVisible]); + (0,external_React_.useEffect)(() => { + if (!focusable) + return; + if (!focusVisible) + return; + const element = ref.current; + if (!element) + return; + if (typeof IntersectionObserver === "undefined") + return; + const observer = new IntersectionObserver(() => { + if (!isFocusable(element)) { + setFocusVisible(false); + } }); + observer.observe(element); + return () => observer.disconnect(); + }, [focusable, focusVisible]); + const onKeyPressCapture = useDisableEvent( + props.onKeyPressCapture, + disabled + ); + const onMouseDownCapture = useDisableEvent( + props.onMouseDownCapture, + disabled + ); + const onClickCapture = useDisableEvent(props.onClickCapture, disabled); + const onMouseDownProp = props.onMouseDown; + const onMouseDown = useEvent((event) => { + onMouseDownProp == null ? void 0 : onMouseDownProp(event); + if (event.defaultPrevented) + return; + if (!focusable) + return; + const element = event.currentTarget; + if (!isSafariBrowser) + return; + if (isPortalEvent(event)) + return; + if (!isButton(element) && !isNativeCheckboxOrRadio(element)) + return; + let receivedFocus = false; + const onFocus = () => { + receivedFocus = true; + }; + const options = { capture: true, once: true }; + element.addEventListener("focusin", onFocus, options); + queueBeforeEvent(element, "mouseup", () => { + element.removeEventListener("focusin", onFocus, true); + if (receivedFocus) + return; + focusIfNeeded(element); + }); + }); + const handleFocusVisible = (event, currentTarget) => { + if (currentTarget) { + event.currentTarget = currentTarget; + } + if (!focusable) + return; + const element = event.currentTarget; + if (!element) + return; + if (!hasFocus(element)) + return; + onFocusVisible == null ? void 0 : onFocusVisible(event); + if (event.defaultPrevented) + return; + setFocusVisible(true); + }; + const onKeyDownCaptureProp = props.onKeyDownCapture; + const onKeyDownCapture = useEvent( + (event) => { + onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event); + if (event.defaultPrevented) + return; + if (!focusable) + return; + if (focusVisible) + return; + if (event.metaKey) + return; + if (event.altKey) + return; + if (event.ctrlKey) + return; + if (!isSelfTarget(event)) + return; + const element = event.currentTarget; + queueMicrotask(() => handleFocusVisible(event, element)); + } + ); + const onFocusCaptureProp = props.onFocusCapture; + const onFocusCapture = useEvent((event) => { + onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); + if (event.defaultPrevented) + return; + if (!focusable) + return; + if (!isSelfTarget(event)) { + setFocusVisible(false); + return; + } + const element = event.currentTarget; + const applyFocusVisible = () => handleFocusVisible(event, element); + if (isKeyboardModality || isAlwaysFocusVisible(event.target)) { + queueMicrotask(applyFocusVisible); + } else if (isAlwaysFocusVisibleDelayed(event.target)) { + queueBeforeEvent(event.target, "focusout", applyFocusVisible); + } else { + setFocusVisible(false); + } + }); + const onBlurProp = props.onBlur; + const onBlur = useEvent((event) => { + onBlurProp == null ? void 0 : onBlurProp(event); + if (!focusable) + return; + if (!isFocusEventOutside(event)) + return; + setFocusVisible(false); + }); + const autoFocusOnShow = (0,external_React_.useContext)(FocusableContext); + const autoFocusRef = useEvent((element) => { + if (!focusable) + return; + if (!autoFocus) + return; + if (!element) + return; + if (!autoFocusOnShow) + return; + queueMicrotask(() => { + if (hasFocus(element)) + return; + if (!isFocusable(element)) + return; + element.focus(); + }); + }); + const tagName = useTagName(ref, props.as); + const nativeTabbable = focusable && isNativeTabbable(tagName); + const supportsDisabled = focusable && supportsDisabledAttribute(tagName); + const style = trulyDisabled ? _4R3V3JGP_spreadValues({ pointerEvents: "none" }, props.style) : props.style; + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + "data-focus-visible": focusable && focusVisible ? "" : void 0, + "data-autofocus": autoFocus ? true : void 0, + "aria-disabled": disabled ? true : void 0 + }, props), { + ref: useMergeRefs(ref, autoFocusRef, props.ref), + style, + tabIndex: getTabIndex( + focusable, + trulyDisabled, + nativeTabbable, + supportsDisabled, + props.tabIndex + ), + disabled: supportsDisabled && trulyDisabled ? true : void 0, + // TODO: Test Focusable contentEditable. + contentEditable: disabled ? void 0 : props.contentEditable, + onKeyPressCapture, + onClickCapture, + onMouseDownCapture, + onMouseDown, + onKeyDownCapture, + onFocusCapture, + onBlur + }); + return props; + } +); +var Focusable = createComponent((props) => { + props = useFocusable(props); + return _3ORBWXWF_createElement("div", props); +}); +if (false) {} + + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/7QTPYGNZ.js +"use client"; + + + + + + + +// src/composite/composite.tsx + + + + + + + +function isGrid(items) { + return items.some((item) => !!item.rowId); +} +function isPrintableKey(event) { + const target = event.target; + if (target && !DLOEKDPY_isTextField(target)) + return false; + return event.key.length === 1 && !event.ctrlKey && !event.metaKey; +} +function isModifierKey(event) { + return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; +} +function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) { + return useEvent((event) => { + var _a; + onKeyboardEvent == null ? void 0 : onKeyboardEvent(event); + if (event.defaultPrevented) + return; + if (event.isPropagationStopped()) + return; + if (!isSelfTarget(event)) + return; + if (isModifierKey(event)) + return; + if (isPrintableKey(event)) + return; + const state = store.getState(); + const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element; + if (!activeElement) + return; + const _b = event, { view } = _b, eventInit = __objRest(_b, ["view"]); + const previousElement = previousElementRef == null ? void 0 : previousElementRef.current; + if (activeElement !== previousElement) { + activeElement.focus(); } - }, [canvasMode, history]); - (0,external_wp_element_namespaceObject.useEffect)(() => { - currentCanvasInUrl.current = canvasInUrl; - if (canvasInUrl !== 'edit' && currentCanvasMode.current !== 'view') { - setCanvasMode('view'); - } else if (canvasInUrl === 'edit' && currentCanvasMode.current !== 'edit') { - setCanvasMode('edit'); + if (!fireKeyboardEvent(activeElement, event.type, eventInit)) { + event.preventDefault(); } - }, [canvasInUrl, setCanvasMode]); + if (event.currentTarget.contains(activeElement)) { + event.stopPropagation(); + } + }); +} +function findFirstEnabledItemInTheLastRow(items) { + return _3IEDWLST_findFirstEnabledItem( + flatten2DArray(reverseArray(_3IEDWLST_groupItemsByRows(items))) + ); } +function useScheduleFocus(store) { + const [scheduled, setScheduled] = (0,external_React_.useState)(false); + const schedule = (0,external_React_.useCallback)(() => setScheduled(true), []); + const activeItem = store.useState( + (state) => getEnabledItem(store, state.activeId) + ); + (0,external_React_.useEffect)(() => { + const activeElement = activeItem == null ? void 0 : activeItem.element; + if (!scheduled) + return; + if (!activeElement) + return; + setScheduled(false); + activeElement.focus({ preventScroll: true }); + }, [activeItem, scheduled]); + return schedule; +} +var useComposite = createHook( + (_a) => { + var _b = _a, { + store, + composite = true, + focusOnMove = composite, + moveOnKeyPress = true + } = _b, props = __objRest(_b, [ + "store", + "composite", + "focusOnMove", + "moveOnKeyPress" + ]); + const context = useCompositeProviderContext(); + store = store || context; + invariant( + store, + false && 0 + ); + const previousElementRef = (0,external_React_.useRef)(null); + const scheduleFocus = useScheduleFocus(store); + const moves = store.useState("moves"); + (0,external_React_.useEffect)(() => { + var _a2; + if (!store) + return; + if (!moves) + return; + if (!composite) + return; + if (!focusOnMove) + return; + const { activeId: activeId2 } = store.getState(); + const itemElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; + if (!itemElement) + return; + focusIntoView(itemElement); + }, [store, moves, composite, focusOnMove]); + useSafeLayoutEffect(() => { + if (!store) + return; + if (!moves) + return; + if (!composite) + return; + const { baseElement, activeId: activeId2 } = store.getState(); + const isSelfAcive = activeId2 === null; + if (!isSelfAcive) + return; + if (!baseElement) + return; + const previousElement = previousElementRef.current; + previousElementRef.current = null; + if (previousElement) { + fireBlurEvent(previousElement, { relatedTarget: baseElement }); + } + if (!hasFocus(baseElement)) { + baseElement.focus(); + } + }, [store, moves, composite]); + const activeId = store.useState("activeId"); + const virtualFocus = store.useState("virtualFocus"); + useSafeLayoutEffect(() => { + var _a2; + if (!store) + return; + if (!composite) + return; + if (!virtualFocus) + return; + const previousElement = previousElementRef.current; + previousElementRef.current = null; + if (!previousElement) + return; + const activeElement = (_a2 = getEnabledItem(store, activeId)) == null ? void 0 : _a2.element; + const relatedTarget = activeElement || DLOEKDPY_getActiveElement(previousElement); + if (relatedTarget === previousElement) + return; + fireBlurEvent(previousElement, { relatedTarget }); + }, [store, activeId, virtualFocus, composite]); + const onKeyDownCapture = useKeyboardEventProxy( + store, + props.onKeyDownCapture, + previousElementRef + ); + const onKeyUpCapture = useKeyboardEventProxy( + store, + props.onKeyUpCapture, + previousElementRef + ); + const onFocusCaptureProp = props.onFocusCapture; + const onFocusCapture = useEvent((event) => { + onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); + if (event.defaultPrevented) + return; + if (!store) + return; + const { virtualFocus: virtualFocus2 } = store.getState(); + if (!virtualFocus2) + return; + const previousActiveElement = event.relatedTarget; + const isSilentlyFocused = silentlyFocused(event.currentTarget); + if (isSelfTarget(event) && isSilentlyFocused) { + event.stopPropagation(); + previousElementRef.current = previousActiveElement; + } + }); + const onFocusProp = props.onFocus; + const onFocus = useEvent((event) => { + onFocusProp == null ? void 0 : onFocusProp(event); + if (event.defaultPrevented) + return; + if (!composite) + return; + if (!store) + return; + const { relatedTarget } = event; + const { virtualFocus: virtualFocus2 } = store.getState(); + if (virtualFocus2) { + if (isSelfTarget(event) && !isItem(store, relatedTarget)) { + queueMicrotask(scheduleFocus); + } + } else if (isSelfTarget(event)) { + store.setActiveId(null); + } + }); + const onBlurCaptureProp = props.onBlurCapture; + const onBlurCapture = useEvent((event) => { + var _a2; + onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); + if (event.defaultPrevented) + return; + if (!store) + return; + const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState(); + if (!virtualFocus2) + return; + const activeElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; + const nextActiveElement = event.relatedTarget; + const nextActiveElementIsItem = isItem(store, nextActiveElement); + const previousElement = previousElementRef.current; + previousElementRef.current = null; + if (isSelfTarget(event) && nextActiveElementIsItem) { + if (nextActiveElement === activeElement) { + if (previousElement && previousElement !== nextActiveElement) { + fireBlurEvent(previousElement, event); + } + } else if (activeElement) { + fireBlurEvent(activeElement, event); + } else if (previousElement) { + fireBlurEvent(previousElement, event); + } + event.stopPropagation(); + } else { + const targetIsItem = isItem(store, event.target); + if (!targetIsItem && activeElement) { + fireBlurEvent(activeElement, event); + } + } + }); + const onKeyDownProp = props.onKeyDown; + const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); + const onKeyDown = useEvent((event) => { + var _a2; + onKeyDownProp == null ? void 0 : onKeyDownProp(event); + if (event.defaultPrevented) + return; + if (!store) + return; + if (!isSelfTarget(event)) + return; + const { orientation, items, renderedItems, activeId: activeId2 } = store.getState(); + const activeItem = getEnabledItem(store, activeId2); + if ((_a2 = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a2.isConnected) + return; + const isVertical = orientation !== "horizontal"; + const isHorizontal = orientation !== "vertical"; + const grid = isGrid(renderedItems); + const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End"; + if (isHorizontalKey && DLOEKDPY_isTextField(event.currentTarget)) + return; + const up = () => { + if (grid) { + const item = items && findFirstEnabledItemInTheLastRow(items); + return item == null ? void 0 : item.id; + } + return store == null ? void 0 : store.last(); + }; + const keyMap = { + ArrowUp: (grid || isVertical) && up, + ArrowRight: (grid || isHorizontal) && store.first, + ArrowDown: (grid || isVertical) && store.first, + ArrowLeft: (grid || isHorizontal) && store.last, + Home: store.first, + End: store.last, + PageUp: store.first, + PageDown: store.last + }; + const action = keyMap[event.key]; + if (action) { + const id = action(); + if (id !== void 0) { + if (!moveOnKeyPressProp(event)) + return; + event.preventDefault(); + store.move(id); + } + } + }); + props = useWrapElement( + props, + (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(CompositeContextProvider, { value: store, children: element }), + [store] + ); + const activeDescendant = store.useState((state) => { + var _a2; + if (!store) + return; + if (!composite) + return; + if (!state.virtualFocus) + return; + return (_a2 = getEnabledItem(store, state.activeId)) == null ? void 0 : _a2.id; + }); + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + "aria-activedescendant": activeDescendant + }, props), { + ref: useMergeRefs(composite ? store.setBaseElement : null, props.ref), + onKeyDownCapture, + onKeyUpCapture, + onFocusCapture, + onFocus, + onBlurCapture, + onKeyDown + }); + const focusable = store.useState( + (state) => composite && (state.virtualFocus || state.activeId === null) + ); + props = useFocusable(_4R3V3JGP_spreadValues({ focusable }, props)); + return props; + } +); +var _7QTPYGNZ_Composite = createComponent((props) => { + const htmlProps = useComposite(props); + return _3ORBWXWF_createElement("div", htmlProps); +}); +if (false) {} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/use-activate-theme.js -/** - * WordPress dependencies - */ -/** - * Internal dependencies - */ +;// CONCATENATED MODULE: external "ReactDOM" +const external_ReactDOM_namespaceObject = window["ReactDOM"]; +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox.js +"use client"; -const { - useHistory: use_activate_theme_useHistory, - useLocation: use_activate_theme_useLocation -} = unlock(external_wp_router_namespaceObject.privateApis); -/** - * This should be refactored to use the REST API, once the REST API can activate themes. - * - * @return {Function} A function that activates the theme. - */ -function useActivateTheme() { - const history = use_activate_theme_useHistory(); - const location = use_activate_theme_useLocation(); - return async () => { - if (isPreviewingTheme()) { - const activationURL = 'themes.php?action=activate&stylesheet=' + currentlyPreviewingTheme() + '&_wpnonce=' + window.WP_BLOCK_THEME_ACTIVATE_NONCE; - await window.fetch(activationURL); - const { - wp_theme_preview: themePreview, - ...params - } = location.params; - history.replace(params); - } - }; -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/save-panel/index.js -/** - * External dependencies - */ -/** - * WordPress dependencies - */ @@ -34499,333 +40333,1338 @@ function useActivateTheme() { -/** - * Internal dependencies - */ +// src/combobox/combobox.ts -const { - EntitiesSavedStatesExtensible -} = unlock(external_wp_editor_namespaceObject.privateApis); -const EntitiesSavedStatesForPreview = ({ - onClose -}) => { - const isDirtyProps = (0,external_wp_editor_namespaceObject.useEntitiesSavedStatesIsDirty)(); - let activateSaveLabel; - if (isDirtyProps.isDirty) { - activateSaveLabel = (0,external_wp_i18n_namespaceObject.__)('Activate & Save'); - } else { - activateSaveLabel = (0,external_wp_i18n_namespaceObject.__)('Activate'); + + + + +function isFirstItemAutoSelected(items, activeValue, autoSelect) { + if (!autoSelect) + return false; + const firstItem = items.find((item) => !item.disabled && item.value); + return (firstItem == null ? void 0 : firstItem.value) === activeValue; +} +function hasCompletionString(value, activeValue) { + if (!activeValue) + return false; + if (value == null) + return false; + value = normalizeString(value); + return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0; +} +function isInputEvent(event) { + return event.type === "input"; +} +function isAriaAutoCompleteValue(value) { + return value === "inline" || value === "list" || value === "both" || value === "none"; +} +var useCombobox = createHook( + (_a) => { + var _b = _a, { + store, + focusable = true, + autoSelect: autoSelectProp = false, + getAutoSelectId, + showOnChange = true, + setValueOnChange = true, + showOnMouseDown = true, + setValueOnClick = true, + showOnKeyDown = true, + moveOnKeyPress = true, + autoComplete = "list" + } = _b, props = __objRest(_b, [ + "store", + "focusable", + "autoSelect", + "getAutoSelectId", + "showOnChange", + "setValueOnChange", + "showOnMouseDown", + "setValueOnClick", + "showOnKeyDown", + "moveOnKeyPress", + "autoComplete" + ]); + const context = useComboboxProviderContext(); + store = store || context; + invariant( + store, + false && 0 + ); + const ref = (0,external_React_.useRef)(null); + const [valueUpdated, forceValueUpdate] = useForceUpdate(); + const canAutoSelectRef = (0,external_React_.useRef)(false); + const composingRef = (0,external_React_.useRef)(false); + const autoSelect = store.useState( + (state) => !!autoSelectProp && state.virtualFocus + ); + const inline = autoComplete === "inline" || autoComplete === "both"; + const [canInline, setCanInline] = (0,external_React_.useState)(inline); + useUpdateLayoutEffect(() => { + if (!inline) + return; + setCanInline(true); + }, [inline]); + const storeValue = store.useState("value"); + const activeValue = store.useState( + (state) => inline && canInline ? state.activeValue : void 0 + ); + const items = store.useState("renderedItems"); + const open = store.useState("open"); + const contentElement = store.useState("contentElement"); + const value = (0,external_React_.useMemo)(() => { + if (!inline) + return storeValue; + if (!canInline) + return storeValue; + const firstItemAutoSelected = isFirstItemAutoSelected( + items, + activeValue, + autoSelect + ); + if (firstItemAutoSelected) { + if (hasCompletionString(storeValue, activeValue)) { + const slice = (activeValue == null ? void 0 : activeValue.slice(storeValue.length)) || ""; + return storeValue + slice; + } + return storeValue; + } + return activeValue || storeValue; + }, [inline, canInline, items, activeValue, autoSelect, storeValue]); + (0,external_React_.useEffect)(() => { + const element = ref.current; + if (!element) + return; + const onCompositeItemMove = () => setCanInline(true); + element.addEventListener("combobox-item-move", onCompositeItemMove); + return () => { + element.removeEventListener("combobox-item-move", onCompositeItemMove); + }; + }, []); + (0,external_React_.useEffect)(() => { + if (!inline) + return; + if (!canInline) + return; + if (!activeValue) + return; + const firstItemAutoSelected = isFirstItemAutoSelected( + items, + activeValue, + autoSelect + ); + if (!firstItemAutoSelected) + return; + if (!hasCompletionString(storeValue, activeValue)) + return; + queueMicrotask(() => { + const element = ref.current; + if (!element) + return; + setSelectionRange(element, storeValue.length, activeValue.length); + }); + }, [ + valueUpdated, + inline, + canInline, + activeValue, + items, + autoSelect, + storeValue + ]); + const scrollingElementRef = (0,external_React_.useRef)(null); + const getAutoSelectIdProp = useEvent(getAutoSelectId); + const autoSelectIdRef = (0,external_React_.useRef)(null); + (0,external_React_.useEffect)(() => { + if (!open) + return; + if (!contentElement) + return; + const scrollingElement = getScrollingElement(contentElement); + if (!scrollingElement) + return; + scrollingElementRef.current = scrollingElement; + const onWheel = () => { + canAutoSelectRef.current = false; + }; + const onScroll = () => { + if (!store) + return; + if (!canAutoSelectRef.current) + return; + const { activeId } = store.getState(); + if (activeId === null) + return; + if (activeId === autoSelectIdRef.current) + return; + canAutoSelectRef.current = false; + }; + const options = { passive: true, capture: true }; + scrollingElement.addEventListener("wheel", onWheel, options); + scrollingElement.addEventListener("scroll", onScroll, options); + return () => { + scrollingElement.removeEventListener("wheel", onWheel, true); + scrollingElement.removeEventListener("scroll", onScroll, true); + }; + }, [open, contentElement, store]); + useSafeLayoutEffect(() => { + if (!storeValue) + return; + if (composingRef.current) + return; + canAutoSelectRef.current = true; + }, [storeValue]); + useSafeLayoutEffect(() => { + if (open) + return; + canAutoSelectRef.current = false; + }, [open]); + const resetValueOnSelect = store.useState("resetValueOnSelect"); + useUpdateEffect(() => { + var _a2; + const canAutoSelect = canAutoSelectRef.current; + if (!store) + return; + if ((!autoSelect || !canAutoSelect) && !resetValueOnSelect) + return; + const { baseElement, contentElement: contentElement2, activeId } = store.getState(); + if (baseElement && !hasFocus(baseElement)) + return; + if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) { + const observer = new MutationObserver(forceValueUpdate); + observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); + return () => observer.disconnect(); + } + if (autoSelect && canAutoSelect) { + const userAutoSelectId = getAutoSelectIdProp(items); + const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : store.first(); + autoSelectIdRef.current = autoSelectId; + store.move(autoSelectId != null ? autoSelectId : null); + } else { + const element = (_a2 = store.item(activeId)) == null ? void 0 : _a2.element; + if (element && "scrollIntoView" in element) { + element.scrollIntoView({ block: "nearest", inline: "nearest" }); + } + } + return; + }, [ + store, + valueUpdated, + storeValue, + autoSelect, + resetValueOnSelect, + getAutoSelectIdProp, + items + ]); + (0,external_React_.useEffect)(() => { + if (!inline) + return; + const combobox = ref.current; + if (!combobox) + return; + const elements = [combobox, contentElement].filter( + (value2) => !!value2 + ); + const onBlur2 = (event) => { + if (elements.every((el) => isFocusEventOutside(event, el))) { + store == null ? void 0 : store.setValue(value); + } + }; + elements.forEach((el) => el.addEventListener("focusout", onBlur2)); + return () => { + elements.forEach((el) => el.removeEventListener("focusout", onBlur2)); + }; + }, [inline, contentElement, store, value]); + const onChangeProp = props.onChange; + const showOnChangeProp = useBooleanEvent(showOnChange); + const setValueOnChangeProp = useBooleanEvent(setValueOnChange); + const onChange = useEvent((event) => { + onChangeProp == null ? void 0 : onChangeProp(event); + if (event.defaultPrevented) + return; + if (!store) + return; + const { value: value2, selectionStart, selectionEnd } = event.target; + const nativeEvent = event.nativeEvent; + canAutoSelectRef.current = true; + if (isInputEvent(nativeEvent)) { + if (nativeEvent.isComposing) { + canAutoSelectRef.current = false; + composingRef.current = true; + } + if (inline) { + const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; + const caretAtEnd = selectionStart === value2.length; + setCanInline(textInserted && caretAtEnd); + } + } + if (setValueOnChangeProp(event)) { + const isSameValue = value2 === store.getState().value; + (0,external_ReactDOM_namespaceObject.flushSync)(() => store == null ? void 0 : store.setValue(value2)); + setSelectionRange(event.currentTarget, selectionStart, selectionEnd); + if (inline && autoSelect && isSameValue) { + forceValueUpdate(); + } + } + if (showOnChangeProp(event)) { + store.show(); + } + if (!autoSelect || !canAutoSelectRef.current) { + store.setActiveId(null); + } + }); + const onCompositionEndProp = props.onCompositionEnd; + const onCompositionEnd = useEvent( + (event) => { + canAutoSelectRef.current = true; + composingRef.current = false; + onCompositionEndProp == null ? void 0 : onCompositionEndProp(event); + if (event.defaultPrevented) + return; + if (!autoSelect) + return; + forceValueUpdate(); + } + ); + const onMouseDownProp = props.onMouseDown; + const setValueOnClickProp = useBooleanEvent(setValueOnClick); + const showOnMouseDownProp = useBooleanEvent(showOnMouseDown); + const onMouseDown = useEvent((event) => { + onMouseDownProp == null ? void 0 : onMouseDownProp(event); + if (event.defaultPrevented) + return; + if (event.button) + return; + if (event.ctrlKey) + return; + if (!store) + return; + store.setActiveId(null); + if (setValueOnClickProp(event)) { + store.setValue(value); + } + if (showOnMouseDownProp(event)) { + queueBeforeEvent(event.currentTarget, "mouseup", store.show); + } + }); + const onKeyDownProp = props.onKeyDown; + const showOnKeyDownProp = useBooleanEvent(showOnKeyDown); + const onKeyDown = useEvent( + (event) => { + onKeyDownProp == null ? void 0 : onKeyDownProp(event); + if (!event.repeat) { + canAutoSelectRef.current = false; + } + if (event.defaultPrevented) + return; + if (event.ctrlKey) + return; + if (event.altKey) + return; + if (event.shiftKey) + return; + if (event.metaKey) + return; + if (!store) + return; + const { open: open2, activeId } = store.getState(); + if (open2) + return; + if (activeId !== null) + return; + if (event.key === "ArrowUp" || event.key === "ArrowDown") { + if (showOnKeyDownProp(event)) { + event.preventDefault(); + store.show(); + } + } + } + ); + const onBlurProp = props.onBlur; + const onBlur = useEvent((event) => { + canAutoSelectRef.current = false; + onBlurProp == null ? void 0 : onBlurProp(event); + if (event.defaultPrevented) + return; + }); + const id = useId(props.id); + const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; + const isActiveItem = store.useState((state) => state.activeId === null); + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + id, + role: "combobox", + "aria-autocomplete": ariaAutoComplete, + "aria-haspopup": getPopupRole(contentElement, "listbox"), + "aria-expanded": open, + "aria-controls": contentElement == null ? void 0 : contentElement.id, + "data-active-item": isActiveItem || void 0, + value + }, props), { + ref: useMergeRefs(ref, props.ref), + onChange, + onCompositionEnd, + onMouseDown, + onKeyDown, + onBlur + }); + props = useComposite(_4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + store, + focusable + }, props), { + // Enable inline autocomplete when the user moves from the combobox input + // to an item. + moveOnKeyPress: (event) => { + if (isFalsyBooleanCallback(moveOnKeyPress, event)) + return false; + if (inline) + setCanInline(true); + return true; + } + })); + props = usePopoverAnchor(_4R3V3JGP_spreadValues({ store }, props)); + return _4R3V3JGP_spreadValues({ autoComplete: "off" }, props); } - const themeName = (0,external_wp_data_namespaceObject.useSelect)(select => { - const theme = select(external_wp_coreData_namespaceObject.store).getTheme(currentlyPreviewingTheme()); - return theme?.name?.rendered; - }, []); - const additionalPrompt = (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.sprintf)('Saving your changes will change your active theme to %s.', themeName)); - const activateTheme = useActivateTheme(); - const onSave = async values => { - await activateTheme(); - return values; - }; - return (0,external_wp_element_namespaceObject.createElement)(EntitiesSavedStatesExtensible, { - ...isDirtyProps, - additionalPrompt, - close: onClose, - onSave, - saveEnabled: true, - saveLabel: activateSaveLabel +); +var Combobox = createComponent((props) => { + const htmlProps = useCombobox(props); + return _3ORBWXWF_createElement("input", htmlProps); +}); +if (false) {} + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/CLE7NTOY.js +"use client"; + + + + + + + +// src/disclosure/disclosure-content.tsx + + + +function afterTimeout(timeoutMs, cb) { + const timeoutId = setTimeout(cb, timeoutMs); + return () => clearTimeout(timeoutId); +} +function CLE7NTOY_afterPaint(cb) { + let raf = requestAnimationFrame(() => { + raf = requestAnimationFrame(cb); }); -}; -const _EntitiesSavedStates = ({ - onClose -}) => { - if (isPreviewingTheme()) { - return (0,external_wp_element_namespaceObject.createElement)(EntitiesSavedStatesForPreview, { - onClose: onClose + return () => cancelAnimationFrame(raf); +} +function parseCSSTime(...times) { + return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => { + const currentTime = parseFloat(currentTimeString || "0s") * 1e3; + if (currentTime > longestTime) + return currentTime; + return longestTime; + }, 0); +} +function isHidden(mounted, hidden, alwaysVisible) { + return !alwaysVisible && hidden !== false && (!mounted || !!hidden); +} +var useDisclosureContent = createHook( + (_a) => { + var _b = _a, { store, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); + const context = useDisclosureProviderContext(); + store = store || context; + invariant( + store, + false && 0 + ); + const id = useId(props.id); + const [transition, setTransition] = (0,external_React_.useState)(null); + const open = store.useState("open"); + const mounted = store.useState("mounted"); + const animated = store.useState("animated"); + const contentElement = store.useState("contentElement"); + useSafeLayoutEffect(() => { + if (!animated) + return; + if (!(contentElement == null ? void 0 : contentElement.isConnected)) { + setTransition(null); + return; + } + return CLE7NTOY_afterPaint(() => { + setTransition(open ? "enter" : "leave"); + }); + }, [animated, contentElement, open]); + useSafeLayoutEffect(() => { + if (!store) + return; + if (!animated) + return; + if (!contentElement) + return; + if (!transition) + return; + if (transition === "enter" && !open) + return; + if (transition === "leave" && open) + return; + if (typeof animated === "number") { + const timeoutMs2 = animated; + return afterTimeout(timeoutMs2, store.stopAnimation); + } + const { + transitionDuration, + animationDuration, + transitionDelay, + animationDelay + } = getComputedStyle(contentElement); + const delay = parseCSSTime(transitionDelay, animationDelay); + const duration = parseCSSTime(transitionDuration, animationDuration); + const timeoutMs = delay + duration; + if (!timeoutMs) + return; + return afterTimeout(timeoutMs, store.stopAnimation); + }, [store, animated, contentElement, open, transition]); + props = useWrapElement( + props, + (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(DialogScopedContextProvider, { value: store, children: element }), + [store] + ); + const hidden = isHidden(mounted, props.hidden, alwaysVisible); + const style = hidden ? _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props.style), { display: "none" }) : props.style; + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + id, + "data-enter": transition === "enter" ? "" : void 0, + "data-leave": transition === "leave" ? "" : void 0, + hidden + }, props), { + ref: useMergeRefs(id ? store.setContentElement : null, props.ref), + style }); + return props; + } +); +var DisclosureContentImpl = createComponent( + (props) => { + const htmlProps = useDisclosureContent(props); + return _3ORBWXWF_createElement("div", htmlProps); + } +); +var DisclosureContent = createComponent( + (_a) => { + var _b = _a, { unmountOnHide } = _b, props = __objRest(_b, ["unmountOnHide"]); + const context = useDisclosureProviderContext(); + const store = props.store || context; + const mounted = useStoreState( + store, + (state) => !unmountOnHide || (state == null ? void 0 : state.mounted) + ); + if (mounted === false) + return null; + return /* @__PURE__ */ (0,jsx_runtime.jsx)(DisclosureContentImpl, _4R3V3JGP_spreadValues({}, props)); } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EntitiesSavedStates, { - close: onClose - }); -}; -function SavePanel() { - const { - isSaveViewOpen, - canvasMode - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - isSaveViewOpened, - getCanvasMode - } = unlock(select(store_store)); +); +if (false) {} - // The currently selected entity to display. - // Typically template or template part in the site editor. - return { - isSaveViewOpen: isSaveViewOpened(), - canvasMode: getCanvasMode() - }; - }, []); - const { - setIsSaveViewOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const onClose = () => setIsSaveViewOpened(false); - if (canvasMode === 'view') { - return isSaveViewOpen ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { - className: "edit-site-save-panel__modal", - onRequestClose: onClose, - __experimentalHideHeader: true, - contentLabel: (0,external_wp_i18n_namespaceObject.__)('Save site, content, and template changes') - }, (0,external_wp_element_namespaceObject.createElement)(_EntitiesSavedStates, { - onClose: onClose - })) : null; - } - return (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { - className: classnames_default()('edit-site-layout__actions', { - 'is-entity-save-view-open': isSaveViewOpen - }), - ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Save panel') - }, isSaveViewOpen ? (0,external_wp_element_namespaceObject.createElement)(_EntitiesSavedStates, { - onClose: onClose - }) : (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-editor__toggle-save-panel" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "secondary", - className: "edit-site-editor__toggle-save-panel-button", - onClick: () => setIsSaveViewOpened(true), - "aria-expanded": false - }, (0,external_wp_i18n_namespaceObject.__)('Open save panel')))); -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcuts/register.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/ZEXNX5JH.js +"use client"; -function KeyboardShortcutsRegister() { - // Registering the shortcuts. - const { - registerShortcut - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); - (0,external_wp_element_namespaceObject.useEffect)(() => { - registerShortcut({ - name: 'core/edit-site/save', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'), - keyCombination: { - modifier: 'primary', - character: 's' + + + +// src/combobox/combobox-list.tsx + + + + +var useComboboxList = createHook( + (_a) => { + var _b = _a, { store, focusable = true, alwaysVisible } = _b, props = __objRest(_b, ["store", "focusable", "alwaysVisible"]); + const context = useComboboxProviderContext(); + store = store || context; + invariant( + store, + false && 0 + ); + const ref = (0,external_React_.useRef)(null); + const id = useId(props.id); + const onKeyDownProp = props.onKeyDown; + const onKeyDown = useEvent((event) => { + onKeyDownProp == null ? void 0 : onKeyDownProp(event); + if (event.defaultPrevented) + return; + if (event.key === "Escape") { + store == null ? void 0 : store.move(null); } }); - registerShortcut({ - name: 'core/edit-site/undo', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'), - keyCombination: { - modifier: 'primary', - character: 'z' - } + const restoreVirtualFocus = (0,external_React_.useRef)(false); + const onFocusVisibleProp = props.onFocusVisible; + const onFocusVisible = useEvent((event) => { + onFocusVisibleProp == null ? void 0 : onFocusVisibleProp(event); + if (event.defaultPrevented) + return; + if (event.type !== "focus") + return; + if (!store) + return; + const { virtualFocus } = store.getState(); + if (!virtualFocus) + return; + const { relatedTarget, currentTarget } = event; + if (relatedTarget && currentTarget.contains(relatedTarget)) + return; + restoreVirtualFocus.current = true; + store.setState("virtualFocus", false); }); - registerShortcut({ - name: 'core/edit-site/redo', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'), - keyCombination: { - modifier: 'primaryShift', - character: 'z' - }, - // Disable on Apple OS because it conflicts with the browser's - // history shortcut. It's a fine alias for both Windows and Linux. - // Since there's no conflict for Ctrl+Shift+Z on both Windows and - // Linux, we keep it as the default for consistency. - aliases: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? [] : [{ - modifier: 'primary', - character: 'y' - }] + const onBlurProp = props.onBlur; + const onBlur = useEvent((event) => { + onBlurProp == null ? void 0 : onBlurProp(event); + if (event.defaultPrevented) + return; + if (!restoreVirtualFocus.current) + return; + if (!isFocusEventOutside(event)) + return; + restoreVirtualFocus.current = false; + store == null ? void 0 : store.setState("virtualFocus", true); }); - registerShortcut({ - name: 'core/edit-site/toggle-list-view', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Open the block list view.'), - keyCombination: { - modifier: 'access', - character: 'o' + props = useWrapElement( + props, + (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(ComboboxScopedContextProvider, { value: store, children: element }), + [store] + ); + const mounted = store.useState("mounted"); + const hidden = isHidden(mounted, props.hidden, alwaysVisible); + const style = hidden ? _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props.style), { display: "none" }) : props.style; + const multiSelectable = store.useState( + (state) => Array.isArray(state.selectedValue) + ); + const role = useAttribute(ref, "role", props.role); + const isCompositeRole = role === "listbox" || role === "tree" || role === "grid"; + const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0; + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + id, + hidden, + role: "listbox", + tabIndex: focusable ? -1 : void 0, + "aria-multiselectable": ariaMultiSelectable + }, props), { + ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref), + style, + onKeyDown, + onFocusVisible, + onBlur + }); + props = useFocusable(_4R3V3JGP_spreadValues({ focusable }, props)); + return props; + } +); +var ComboboxList = createComponent((props) => { + const htmlProps = useComboboxList(props); + return _3ORBWXWF_createElement("div", htmlProps); +}); +if (false) {} + + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/G6ONQ5EH.js +"use client"; + + + + + +// src/composite/composite-hover.ts + + + + +function getMouseDestination(event) { + const relatedTarget = event.relatedTarget; + if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) { + return relatedTarget; + } + return null; +} +function hoveringInside(event) { + const nextElement = getMouseDestination(event); + if (!nextElement) + return false; + return contains(event.currentTarget, nextElement); +} +var G6ONQ5EH_symbol = Symbol("composite-hover"); +function movingToAnotherItem(event) { + let dest = getMouseDestination(event); + if (!dest) + return false; + do { + if (Y3OOHFCN_hasOwnProperty(dest, G6ONQ5EH_symbol) && dest[G6ONQ5EH_symbol]) + return true; + dest = dest.parentElement; + } while (dest); + return false; +} +var useCompositeHover = createHook( + (_a) => { + var _b = _a, { + store, + focusOnHover = true, + blurOnHoverEnd = !!focusOnHover + } = _b, props = __objRest(_b, [ + "store", + "focusOnHover", + "blurOnHoverEnd" + ]); + const context = useCompositeContext(); + store = store || context; + invariant( + store, + false && 0 + ); + const isMouseMoving = useIsMouseMoving(); + const onMouseMoveProp = props.onMouseMove; + const focusOnHoverProp = useBooleanEvent(focusOnHover); + const onMouseMove = useEvent((event) => { + onMouseMoveProp == null ? void 0 : onMouseMoveProp(event); + if (event.defaultPrevented) + return; + if (!isMouseMoving()) + return; + if (!focusOnHoverProp(event)) + return; + if (!hasFocusWithin(event.currentTarget)) { + const baseElement = store == null ? void 0 : store.getState().baseElement; + if (baseElement && !hasFocus(baseElement)) { + baseElement.focus(); + } } + store == null ? void 0 : store.setActiveId(event.currentTarget.id); }); - registerShortcut({ - name: 'core/edit-site/toggle-block-settings-sidebar', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings sidebar.'), - keyCombination: { - modifier: 'primaryShift', - character: ',' + const onMouseLeaveProp = props.onMouseLeave; + const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); + const onMouseLeave = useEvent((event) => { + var _a2; + onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event); + if (event.defaultPrevented) + return; + if (!isMouseMoving()) + return; + if (hoveringInside(event)) + return; + if (movingToAnotherItem(event)) + return; + if (!focusOnHoverProp(event)) + return; + if (!blurOnHoverEndProp(event)) + return; + store == null ? void 0 : store.setActiveId(null); + (_a2 = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a2.focus(); + }); + const ref = (0,external_React_.useCallback)((element) => { + if (!element) + return; + element[G6ONQ5EH_symbol] = true; + }, []); + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { + ref: useMergeRefs(ref, props.ref), + onMouseMove, + onMouseLeave + }); + return props; + } +); +var CompositeHover = createMemoComponent( + (props) => { + const htmlProps = useCompositeHover(props); + return _3ORBWXWF_createElement("div", htmlProps); + } +); +if (false) {} + + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/NWCBQ4CV.js +"use client"; + + + + + +// src/command/command.ts + + + + + +function isNativeClick(event) { + if (!event.isTrusted) + return false; + const element = event.currentTarget; + if (event.key === "Enter") { + return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; + } + if (event.key === " ") { + return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; + } + return false; +} +var NWCBQ4CV_symbol = Symbol("command"); +var useCommand = createHook( + (_a) => { + var _b = _a, { clickOnEnter = true, clickOnSpace = true } = _b, props = __objRest(_b, ["clickOnEnter", "clickOnSpace"]); + const ref = (0,external_React_.useRef)(null); + const tagName = useTagName(ref, props.as); + const type = props.type; + const [isNativeButton, setIsNativeButton] = (0,external_React_.useState)( + () => !!tagName && isButton({ tagName, type }) + ); + (0,external_React_.useEffect)(() => { + if (!ref.current) + return; + setIsNativeButton(isButton(ref.current)); + }, []); + const [active, setActive] = (0,external_React_.useState)(false); + const activeRef = (0,external_React_.useRef)(false); + const disabled = disabledFromProps(props); + const [isDuplicate, metadataProps] = useMetadataProps(props, NWCBQ4CV_symbol, true); + const onKeyDownProp = props.onKeyDown; + const onKeyDown = useEvent((event) => { + onKeyDownProp == null ? void 0 : onKeyDownProp(event); + const element = event.currentTarget; + if (event.defaultPrevented) + return; + if (isDuplicate) + return; + if (disabled) + return; + if (!isSelfTarget(event)) + return; + if (DLOEKDPY_isTextField(element)) + return; + if (element.isContentEditable) + return; + const isEnter = clickOnEnter && event.key === "Enter"; + const isSpace = clickOnSpace && event.key === " "; + const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; + const shouldPreventSpace = event.key === " " && !clickOnSpace; + if (shouldPreventEnter || shouldPreventSpace) { + event.preventDefault(); + return; + } + if (isEnter || isSpace) { + const nativeClick = isNativeClick(event); + if (isEnter) { + if (!nativeClick) { + event.preventDefault(); + const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); + const click = () => fireClickEvent(element, eventInit); + if (isFirefox()) { + queueBeforeEvent(element, "keyup", click); + } else { + queueMicrotask(click); + } + } + } else if (isSpace) { + activeRef.current = true; + if (!nativeClick) { + event.preventDefault(); + setActive(true); + } + } } }); - registerShortcut({ - name: 'core/edit-site/keyboard-shortcuts', - category: 'main', - description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'), - keyCombination: { - modifier: 'access', - character: 'h' + const onKeyUpProp = props.onKeyUp; + const onKeyUp = useEvent((event) => { + onKeyUpProp == null ? void 0 : onKeyUpProp(event); + if (event.defaultPrevented) + return; + if (isDuplicate) + return; + if (disabled) + return; + if (event.metaKey) + return; + const isSpace = clickOnSpace && event.key === " "; + if (activeRef.current && isSpace) { + activeRef.current = false; + if (!isNativeClick(event)) { + event.preventDefault(); + setActive(false); + const element = event.currentTarget; + const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); + queueMicrotask(() => fireClickEvent(element, eventInit)); + } } }); - registerShortcut({ - name: 'core/edit-site/next-region', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'), - keyCombination: { - modifier: 'ctrl', - character: '`' - }, - aliases: [{ - modifier: 'access', - character: 'n' - }] + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues(_4R3V3JGP_spreadValues({ + "data-active": active ? "" : void 0, + type: isNativeButton ? "button" : void 0 + }, metadataProps), props), { + ref: useMergeRefs(ref, props.ref), + onKeyDown, + onKeyUp }); - registerShortcut({ - name: 'core/edit-site/previous-region', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'), - keyCombination: { - modifier: 'ctrlShift', - character: '`' - }, - aliases: [{ - modifier: 'access', - character: 'p' - }, { - modifier: 'ctrlShift', - character: '~' - }] + props = useFocusable(props); + return props; + } +); +var Command = createComponent((props) => { + props = useCommand(props); + return _3ORBWXWF_createElement("button", props); +}); +if (false) {} + + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/UH3I23HL.js +"use client"; + + + + + +// src/collection/collection-item.ts + + +var useCollectionItem = createHook( + (_a) => { + var _b = _a, { + store, + shouldRegisterItem = true, + getItem = identity, + element: element + } = _b, props = __objRest(_b, [ + "store", + "shouldRegisterItem", + "getItem", + // @ts-expect-error This prop may come from a collection renderer. + "element" + ]); + const context = useCollectionContext(); + store = store || context; + const id = useId(props.id); + const ref = (0,external_React_.useRef)(element); + (0,external_React_.useEffect)(() => { + const element2 = ref.current; + if (!id) + return; + if (!element2) + return; + if (!shouldRegisterItem) + return; + const item = getItem({ id, element: element2 }); + return store == null ? void 0 : store.renderItem(item); + }, [id, shouldRegisterItem, getItem, store]); + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { + ref: useMergeRefs(ref, props.ref) }); - registerShortcut({ - name: 'core/edit-site/toggle-mode', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'), - keyCombination: { - modifier: 'secondary', - character: 'm' + return props; + } +); +var CollectionItem = createComponent( + (props) => { + const htmlProps = useCollectionItem(props); + return _3ORBWXWF_createElement("div", htmlProps); + } +); +if (false) {} + + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/QZLXIDNP.js +"use client"; + + + + + + + + + +// src/composite/composite-item.tsx + + + + + +function isEditableElement(element) { + if (element.isContentEditable) + return true; + if (DLOEKDPY_isTextField(element)) + return true; + return element.tagName === "INPUT" && !isButton(element); +} +function getNextPageOffset(scrollingElement, pageUp = false) { + const height = scrollingElement.clientHeight; + const { top } = scrollingElement.getBoundingClientRect(); + const pageSize = Math.max(height * 0.875, height - 40) * 1.5; + const pageOffset = pageUp ? height - pageSize + top : pageSize + top; + if (scrollingElement.tagName === "HTML") { + return pageOffset + scrollingElement.scrollTop; + } + return pageOffset; +} +function getItemOffset(itemElement, pageUp = false) { + const { top } = itemElement.getBoundingClientRect(); + if (pageUp) { + return top + itemElement.clientHeight; + } + return top; +} +function findNextPageItemId(element, store, next, pageUp = false) { + var _a; + if (!store) + return; + if (!next) + return; + const { renderedItems } = store.getState(); + const scrollingElement = getScrollingElement(element); + if (!scrollingElement) + return; + const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); + let id; + let prevDifference; + for (let i = 0; i < renderedItems.length; i += 1) { + const previousId = id; + id = next(i); + if (!id) + break; + if (id === previousId) + continue; + const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element; + if (!itemElement) + continue; + const itemOffset = getItemOffset(itemElement, pageUp); + const difference = itemOffset - nextPageOffset; + const absDifference = Math.abs(difference); + if (pageUp && difference <= 0 || !pageUp && difference >= 0) { + if (prevDifference !== void 0 && prevDifference < absDifference) { + id = previousId; } + break; + } + prevDifference = absDifference; + } + return id; +} +function targetIsAnotherItem(event, store) { + if (isSelfTarget(event)) + return false; + return isItem(store, event.target); +} +function useRole(ref, props) { + const roleProp = props.role; + const [role, setRole] = (0,external_React_.useState)(roleProp); + useSafeLayoutEffect(() => { + const element = ref.current; + if (!element) + return; + setRole(element.getAttribute("role") || roleProp); + }, [roleProp]); + return role; +} +function requiresAriaSelected(role) { + return role === "option" || role === "treeitem"; +} +function supportsAriaSelected(role) { + if (role === "option") + return true; + if (role === "tab") + return true; + if (role === "treeitem") + return true; + if (role === "gridcell") + return true; + if (role === "row") + return true; + if (role === "columnheader") + return true; + if (role === "rowheader") + return true; + return false; +} +var useCompositeItem = createHook( + (_a) => { + var _b = _a, { + store, + rowId: rowIdProp, + preventScrollOnKeyDown = false, + moveOnKeyPress = true, + tabbable = false, + getItem: getItemProp, + "aria-setsize": ariaSetSizeProp, + "aria-posinset": ariaPosInSetProp + } = _b, props = __objRest(_b, [ + "store", + "rowId", + "preventScrollOnKeyDown", + "moveOnKeyPress", + "tabbable", + "getItem", + "aria-setsize", + "aria-posinset" + ]); + const context = useCompositeContext(); + store = store || context; + const id = useId(props.id); + const ref = (0,external_React_.useRef)(null); + const row = (0,external_React_.useContext)(CompositeRowContext); + const rowId = useStoreState(store, (state) => { + if (rowIdProp) + return rowIdProp; + if (!state) + return; + if (!(row == null ? void 0 : row.baseElement)) + return; + if (row.baseElement !== state.baseElement) + return; + return row.id; }); - registerShortcut({ - name: 'core/edit-site/transform-heading-to-paragraph', - category: 'block-library', - description: (0,external_wp_i18n_namespaceObject.__)('Transform heading to paragraph.'), - keyCombination: { - modifier: 'access', - character: `0` + const disabled = disabledFromProps(props); + const trulyDisabled = disabled && !props.accessibleWhenDisabled; + const getItem = (0,external_React_.useCallback)( + (item) => { + const nextItem = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, item), { + id: id || item.id, + rowId, + disabled: !!trulyDisabled + }); + if (getItemProp) { + return getItemProp(nextItem); + } + return nextItem; + }, + [id, rowId, trulyDisabled, getItemProp] + ); + const onFocusProp = props.onFocus; + const hasFocusedComposite = (0,external_React_.useRef)(false); + const onFocus = useEvent((event) => { + onFocusProp == null ? void 0 : onFocusProp(event); + if (event.defaultPrevented) + return; + if (isPortalEvent(event)) + return; + if (!id) + return; + if (!store) + return; + const { activeId, virtualFocus: virtualFocus2, baseElement: baseElement2 } = store.getState(); + if (targetIsAnotherItem(event, store)) + return; + if (activeId !== id) { + store.setActiveId(id); + } + if (!virtualFocus2) + return; + if (!isSelfTarget(event)) + return; + if (isEditableElement(event.currentTarget)) + return; + if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) + return; + hasFocusedComposite.current = true; + const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget); + if (fromComposite) { + focusSilently(baseElement2); + } else { + baseElement2.focus(); } }); - [1, 2, 3, 4, 5, 6].forEach(level => { - registerShortcut({ - name: `core/edit-site/transform-paragraph-to-heading-${level}`, - category: 'block-library', - description: (0,external_wp_i18n_namespaceObject.__)('Transform paragraph to heading.'), - keyCombination: { - modifier: 'access', - character: `${level}` + const onBlurCaptureProp = props.onBlurCapture; + const onBlurCapture = useEvent((event) => { + onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); + if (event.defaultPrevented) + return; + const state = store == null ? void 0 : store.getState(); + if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) { + hasFocusedComposite.current = false; + event.preventDefault(); + event.stopPropagation(); + } + }); + const onKeyDownProp = props.onKeyDown; + const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); + const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); + const onKeyDown = useEvent((event) => { + onKeyDownProp == null ? void 0 : onKeyDownProp(event); + if (event.defaultPrevented) + return; + if (!isSelfTarget(event)) + return; + if (!store) + return; + const { currentTarget } = event; + const state = store.getState(); + const item = store.item(id); + const isGrid = !!(item == null ? void 0 : item.rowId); + const isVertical = state.orientation !== "horizontal"; + const isHorizontal = state.orientation !== "vertical"; + const canHomeEnd = () => { + if (isGrid) + return true; + if (isHorizontal) + return true; + if (!state.baseElement) + return true; + if (!DLOEKDPY_isTextField(state.baseElement)) + return true; + return false; + }; + const keyMap = { + ArrowUp: (isGrid || isVertical) && store.up, + ArrowRight: (isGrid || isHorizontal) && store.next, + ArrowDown: (isGrid || isVertical) && store.down, + ArrowLeft: (isGrid || isHorizontal) && store.previous, + Home: () => { + if (!canHomeEnd()) + return; + if (!isGrid || event.ctrlKey) { + return store == null ? void 0 : store.first(); + } + return store == null ? void 0 : store.previous(-1); + }, + End: () => { + if (!canHomeEnd()) + return; + if (!isGrid || event.ctrlKey) { + return store == null ? void 0 : store.last(); + } + return store == null ? void 0 : store.next(-1); + }, + PageUp: () => { + return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true); + }, + PageDown: () => { + return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down); } - }); + }; + const action = keyMap[event.key]; + if (action) { + const nextId = action(); + if (preventScrollOnKeyDownProp(event) || nextId !== void 0) { + if (!moveOnKeyPressProp(event)) + return; + event.preventDefault(); + store.move(nextId); + } + } }); - registerShortcut({ - name: 'core/edit-site/toggle-distraction-free', - category: 'global', - description: (0,external_wp_i18n_namespaceObject.__)('Toggle distraction free mode.'), - keyCombination: { - modifier: 'primaryShift', - character: '\\' + const baseElement = useStoreState( + store, + (state) => (state == null ? void 0 : state.baseElement) || void 0 + ); + const providerValue = (0,external_React_.useMemo)( + () => ({ id, baseElement }), + [id, baseElement] + ); + props = useWrapElement( + props, + (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }), + [providerValue] + ); + const isActiveItem = useStoreState( + store, + (state) => !!state && state.activeId === id + ); + const virtualFocus = useStoreState(store, "virtualFocus"); + const role = useRole(ref, props); + let ariaSelected; + if (isActiveItem) { + if (requiresAriaSelected(role)) { + ariaSelected = true; + } else if (virtualFocus && supportsAriaSelected(role)) { + ariaSelected = true; } + } + const ariaSetSize = useStoreState(store, (state) => { + if (ariaSetSizeProp != null) + return ariaSetSizeProp; + if (!state) + return; + if (!(row == null ? void 0 : row.ariaSetSize)) + return; + if (row.baseElement !== state.baseElement) + return; + return row.ariaSetSize; }); - }, [registerShortcut]); - return null; -} -/* harmony default export */ var register = (KeyboardShortcutsRegister); + const ariaPosInSet = useStoreState(store, (state) => { + if (ariaPosInSetProp != null) + return ariaPosInSetProp; + if (!state) + return; + if (!(row == null ? void 0 : row.ariaPosInSet)) + return; + if (row.baseElement !== state.baseElement) + return; + const itemsInRow = state.renderedItems.filter( + (item) => item.rowId === rowId + ); + return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); + }); + const isTabbable = useStoreState(store, (state) => { + if (!(state == null ? void 0 : state.renderedItems.length)) + return true; + if (state.virtualFocus) + return false; + if (tabbable) + return true; + return state.activeId === id; + }); + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + id, + "aria-selected": ariaSelected, + "data-active-item": isActiveItem ? "" : void 0 + }, props), { + ref: useMergeRefs(ref, props.ref), + tabIndex: isTabbable ? props.tabIndex : -1, + onFocus, + onBlurCapture, + onKeyDown + }); + props = useCommand(props); + props = useCollectionItem(_4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + store + }, props), { + getItem, + shouldRegisterItem: !!id ? props.shouldRegisterItem : false + })); + return _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { + "aria-setsize": ariaSetSize, + "aria-posinset": ariaPosInSet + }); + } +); +var QZLXIDNP_CompositeItem = createMemoComponent( + (props) => { + const htmlProps = useCompositeItem(props); + return _3ORBWXWF_createElement("button", htmlProps); + } +); +if (false) {} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcuts/global.js -/** - * WordPress dependencies - */ +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox-item.js +"use client"; -/** - * Internal dependencies - */ -function KeyboardShortcutsGlobal() { - const { - __experimentalGetDirtyEntityRecords, - isSavingEntityRecord - } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); - const { - setIsSaveViewOpened - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/save', event => { - event.preventDefault(); - const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); - const isDirty = !!dirtyEntityRecords.length; - const isSaving = dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)); - if (!isSaving && isDirty) { - setIsSaveViewOpened(true); - } - }); - return null; -} -/* harmony default export */ var global = (KeyboardShortcutsGlobal); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/help.js -/** - * WordPress dependencies - */ -const help = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zM3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 8.75a1.5 1.5 0 01.167 2.99c-.465.052-.917.44-.917 1.01V14h1.5v-.845A3 3 0 109 10.25h1.5a1.5 1.5 0 011.5-1.5zM11.25 15v1.5h1.5V15h-1.5z" -})); -/* harmony default export */ var library_help = (help); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/trash.js -/** - * WordPress dependencies - */ -const trash = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M20 5h-5.7c0-1.3-1-2.3-2.3-2.3S9.7 3.7 9.7 5H4v2h1.5v.3l1.7 11.1c.1 1 1 1.7 2 1.7h5.7c1 0 1.8-.7 2-1.7l1.7-11.1V7H20V5zm-3.2 2l-1.7 11.1c0 .1-.1.2-.3.2H9.1c-.1 0-.3-.1-.3-.2L7.2 7h9.6z" -})); -/* harmony default export */ var library_trash = (trash); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/brush.js -/** - * WordPress dependencies - */ -const brush = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z" -})); -/* harmony default export */ var library_brush = (brush); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/commands/use-common-commands.js -/** - * WordPress dependencies - */ @@ -34833,370 +41672,533 @@ const brush = (0,external_wp_element_namespaceObject.createElement)(external_wp_ +// src/combobox/combobox-item.tsx -/** - * Internal dependencies - */ - -const { - useGlobalStylesReset -} = unlock(external_wp_blockEditor_namespaceObject.privateApis); -const { - useHistory: use_common_commands_useHistory, - useLocation: use_common_commands_useLocation -} = unlock(external_wp_router_namespaceObject.privateApis); -function useGlobalStylesOpenStylesCommands() { - const { - openGeneralSidebar, - setCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const { - params - } = use_common_commands_useLocation(); - const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); - const isEditorPage = !getIsListPage(params, isMobileViewport); - const { - getCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); - const history = use_common_commands_useHistory(); - const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { - return select(external_wp_coreData_namespaceObject.store).getCurrentTheme().is_block_theme; - }, []); - const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { - if (!isBlockBasedTheme) { - return []; - } - return [{ - name: 'core/edit-site/open-styles', - label: (0,external_wp_i18n_namespaceObject.__)('Open styles'), - callback: ({ - close - }) => { - close(); - if (!isEditorPage) { - history.push({ - path: '/wp_global_styles', - canvas: 'edit' - }); - } - if (isEditorPage && getCanvasMode() !== 'edit') { - setCanvasMode('edit'); +function isSelected(storeValue, itemValue) { + if (itemValue == null) + return; + if (storeValue == null) + return false; + if (Array.isArray(storeValue)) { + return storeValue.includes(itemValue); + } + return storeValue === itemValue; +} +var useComboboxItem = createHook( + (_a) => { + var _b = _a, { + store, + value, + hideOnClick, + selectValueOnClick = true, + setValueOnClick, + focusOnHover = false, + moveOnKeyPress = true, + getItem: getItemProp + } = _b, props = __objRest(_b, [ + "store", + "value", + "hideOnClick", + "selectValueOnClick", + "setValueOnClick", + "focusOnHover", + "moveOnKeyPress", + "getItem" + ]); + const context = useComboboxScopedContext(); + store = store || context; + invariant( + store, + false && 0 + ); + const getItem = (0,external_React_.useCallback)( + (item) => { + const nextItem = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, item), { value }); + if (getItemProp) { + return getItemProp(nextItem); } - openGeneralSidebar('edit-site/global-styles'); + return nextItem; }, - icon: library_styles - }]; - }, [history, openGeneralSidebar, setCanvasMode, isEditorPage, getCanvasMode, isBlockBasedTheme]); - return { - isLoading: false, - commands - }; -} -function useGlobalStylesToggleWelcomeGuideCommands() { - const { - openGeneralSidebar, - setCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const { - params - } = use_common_commands_useLocation(); - const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); - const isEditorPage = !getIsListPage(params, isMobileViewport); - const { - getCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); - const { - set - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); - const history = use_common_commands_useHistory(); - const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { - return select(external_wp_coreData_namespaceObject.store).getCurrentTheme().is_block_theme; - }, []); - const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { - if (!isBlockBasedTheme) { - return []; - } - return [{ - name: 'core/edit-site/toggle-styles-welcome-guide', - label: (0,external_wp_i18n_namespaceObject.__)('Learn about styles'), - callback: ({ - close - }) => { - close(); - if (!isEditorPage) { - history.push({ - path: '/wp_global_styles', - canvas: 'edit' + [value, getItemProp] + ); + const multiSelectable = store.useState( + (state) => Array.isArray(state.selectedValue) + ); + setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable; + hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable; + const onClickProp = props.onClick; + const setValueOnClickProp = useBooleanEvent(setValueOnClick); + const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); + const hideOnClickProp = useBooleanEvent(hideOnClick); + const onClick = useEvent((event) => { + onClickProp == null ? void 0 : onClickProp(event); + if (event.defaultPrevented) + return; + if (isDownloading(event)) + return; + if (isOpeningInNewTab(event)) + return; + if (value != null) { + if (selectValueOnClickProp(event)) { + store == null ? void 0 : store.setSelectedValue((prevValue) => { + if (!Array.isArray(prevValue)) + return value; + if (prevValue.includes(value)) { + return prevValue.filter((v) => v !== value); + } + return [...prevValue, value]; }); } - if (isEditorPage && getCanvasMode() !== 'edit') { - setCanvasMode('edit'); + if (setValueOnClickProp(event)) { + store == null ? void 0 : store.setValue(value); } - openGeneralSidebar('edit-site/global-styles'); - set('core/edit-site', 'welcomeGuideStyles', true); - // sometimes there's a focus loss that happens after some time - // that closes the modal, we need to force reopening it. - setTimeout(() => { - set('core/edit-site', 'welcomeGuideStyles', true); - }, 500); - }, - icon: library_help - }]; - }, [history, openGeneralSidebar, setCanvasMode, isEditorPage, getCanvasMode, isBlockBasedTheme, set]); - return { - isLoading: false, - commands - }; -} -function useGlobalStylesResetCommands() { - const [canReset, onReset] = useGlobalStylesReset(); - const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { - if (!canReset) { - return []; - } - return [{ - name: 'core/edit-site/reset-global-styles', - label: (0,external_wp_i18n_namespaceObject.__)('Reset styles to defaults'), - icon: library_trash, - callback: ({ - close - }) => { - close(); - onReset(); } - }]; - }, [canReset, onReset]); - return { - isLoading: false, - commands - }; -} -function useGlobalStylesOpenCssCommands() { - const { - openGeneralSidebar, - setEditorCanvasContainerView, - setCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const { - params - } = use_common_commands_useLocation(); - const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); - const isListPage = getIsListPage(params, isMobileViewport); - const isEditorPage = !isListPage; - const history = use_common_commands_useHistory(); - const { - canEditCSS - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - var _globalStyles$_links$; - const { - getEntityRecord, - __experimentalGetCurrentGlobalStylesId - } = select(external_wp_coreData_namespaceObject.store); - const globalStylesId = __experimentalGetCurrentGlobalStylesId(); - const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; - return { - canEditCSS: (_globalStyles$_links$ = !!globalStyles?._links?.['wp:action-edit-css']) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : false - }; - }, []); - const { - getCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); - const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { - if (!canEditCSS) { - return []; - } - return [{ - name: 'core/edit-site/open-styles-css', - label: (0,external_wp_i18n_namespaceObject.__)('Customize CSS'), - icon: library_brush, - callback: ({ - close - }) => { - close(); - if (!isEditorPage) { - history.push({ - path: '/wp_global_styles', - canvas: 'edit' - }); - } - if (isEditorPage && getCanvasMode() !== 'edit') { - setCanvasMode('edit'); - } - openGeneralSidebar('edit-site/global-styles'); - setEditorCanvasContainerView('global-styles-css'); + if (hideOnClickProp(event)) { + store == null ? void 0 : store.move(null); + store == null ? void 0 : store.hide(); } - }]; - }, [history, openGeneralSidebar, setEditorCanvasContainerView, canEditCSS, isEditorPage, getCanvasMode, setCanvasMode]); - return { - isLoading: false, - commands - }; -} -function useGlobalStylesOpenRevisionsCommands() { - const { - openGeneralSidebar, - setEditorCanvasContainerView, - setCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); - const { - getCanvasMode - } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); - const { - params - } = use_common_commands_useLocation(); - const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); - const isEditorPage = !getIsListPage(params, isMobileViewport); - const history = use_common_commands_useHistory(); - const hasRevisions = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentThemeGlobalStylesRevisions()?.length, []); - const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { - if (!hasRevisions) { - return []; - } - return [{ - name: 'core/edit-site/open-global-styles-revisions', - label: (0,external_wp_i18n_namespaceObject.__)('Style revisions'), - icon: library_backup, - callback: ({ - close - }) => { - close(); - if (!isEditorPage) { - history.push({ - path: '/wp_global_styles', - canvas: 'edit' - }); - } - if (isEditorPage && getCanvasMode() !== 'edit') { - setCanvasMode('edit'); + }); + const onKeyDownProp = props.onKeyDown; + const onKeyDown = useEvent((event) => { + onKeyDownProp == null ? void 0 : onKeyDownProp(event); + if (event.defaultPrevented) + return; + const baseElement = store == null ? void 0 : store.getState().baseElement; + if (!baseElement) + return; + if (hasFocus(baseElement)) + return; + const printable = event.key.length === 1; + if (printable || event.key === "Backspace" || event.key === "Delete") { + queueMicrotask(() => baseElement.focus()); + if (DLOEKDPY_isTextField(baseElement)) { + store == null ? void 0 : store.setValue(baseElement.value); } - openGeneralSidebar('edit-site/global-styles'); - setEditorCanvasContainerView('global-styles-revisions'); } - }]; - }, [hasRevisions, history, openGeneralSidebar, setEditorCanvasContainerView, isEditorPage, getCanvasMode, setCanvasMode]); - return { - isLoading: false, - commands - }; -} -function useCommonCommands() { - const homeUrl = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getUnstableBase // Site index. - } = select(external_wp_coreData_namespaceObject.store); - return getUnstableBase()?.home; - }, []); - (0,external_wp_commands_namespaceObject.useCommand)({ - name: 'core/edit-site/view-site', - label: (0,external_wp_i18n_namespaceObject.__)('View site'), - callback: ({ - close - }) => { - close(); - window.open(homeUrl, '_blank'); - }, - icon: library_external - }); - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/edit-site/open-styles', - hook: useGlobalStylesOpenStylesCommands - }); - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/edit-site/toggle-styles-welcome-guide', - hook: useGlobalStylesToggleWelcomeGuideCommands - }); - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/edit-site/reset-global-styles', - hook: useGlobalStylesResetCommands - }); - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/edit-site/open-styles-css', - hook: useGlobalStylesOpenCssCommands - }); - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/edit-site/open-styles-revisions', - hook: useGlobalStylesOpenRevisionsCommands - }); + }); + const selected = store.useState( + (state) => isSelected(state.selectedValue, value) + ); + if (multiSelectable && selected != null) { + props = _4R3V3JGP_spreadValues({ + "aria-selected": selected + }, props); + } + props = useWrapElement( + props, + (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0,jsx_runtime.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }), + [value, selected] + ); + const contentElement = store.useState("contentElement"); + props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + role: getPopupItemRole(contentElement), + children: value + }, props), { + onClick, + onKeyDown + }); + const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); + props = useCompositeItem(_4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ + store + }, props), { + getItem, + // Dispatch a custom event on the combobox input when moving to an item + // with the keyboard so the Combobox component can enable inline + // autocompletion. + moveOnKeyPress: (event) => { + if (!moveOnKeyPressProp(event)) + return false; + const moveEvent = new Event("combobox-item-move"); + const baseElement = store == null ? void 0 : store.getState().baseElement; + baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent); + return true; + } + })); + props = useCompositeHover(_4R3V3JGP_spreadValues({ store, focusOnHover }, props)); + return props; + } +); +var ComboboxItem = createMemoComponent( + (props) => { + const htmlProps = useComboboxItem(props); + return _3ORBWXWF_createElement("div", htmlProps); + } +); +if (false) {} + + +;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js +"use client"; + + + + + + + + + + + +// src/combobox/combobox-item-value.tsx + + + +function normalizeValue(value) { + return normalizeString(value).toLowerCase(); } +function splitValue(itemValue, userValue) { + userValue = normalizeValue(userValue); + let index = normalizeValue(itemValue).indexOf(userValue); + const parts = []; + while (index !== -1) { + if (index !== 0) { + parts.push( + /* @__PURE__ */ (0,jsx_runtime.jsx)("span", { "data-autocomplete-value": "", children: itemValue.substr(0, index) }, parts.length) + ); + } + parts.push( + /* @__PURE__ */ (0,jsx_runtime.jsx)("span", { "data-user-value": "", children: itemValue.substr(index, userValue.length) }, parts.length) + ); + itemValue = itemValue.substr(index + userValue.length); + index = normalizeValue(itemValue).indexOf(userValue); + } + if (itemValue) { + parts.push( + /* @__PURE__ */ (0,jsx_runtime.jsx)("span", { "data-autocomplete-value": "", children: itemValue }, parts.length) + ); + } + return parts; +} +var useComboboxItemValue = createHook( + (_a) => { + var _b = _a, { store, value } = _b, props = __objRest(_b, ["store", "value"]); + const context = useComboboxScopedContext(); + store = store || context; + const itemContext = (0,external_React_.useContext)(ComboboxItemValueContext); + const itemValue = value != null ? value : itemContext; + invariant( + store, + false && 0 + ); + const stateValue = store.useState( + (state) => itemValue && state.value ? state.value : void 0 + ); + const children = (0,external_React_.useMemo)( + () => itemValue && stateValue ? splitValue(itemValue, stateValue) : itemValue, + [itemValue, stateValue] + ); + props = _4R3V3JGP_spreadValues({ + children + }, props); + return props; + } +); +var ComboboxItemValue = createComponent( + (props) => { + const htmlProps = useComboboxItemValue(props); + return _3ORBWXWF_createElement("span", htmlProps); + } +); +if (false) {} -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/code.js + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/search-widget.js /** - * WordPress dependencies + * External dependencies */ +// eslint-disable-next-line no-restricted-imports -const code = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - viewBox: "0 0 24 24", - xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z" -})); -/* harmony default export */ var library_code = (code); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-right.js /** * WordPress dependencies */ -const rotateRight = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M15.1 4.8l-3-2.5V4c-4.4 0-8 3.6-8 8 0 3.7 2.5 6.9 6 7.7.3.1.6.1 1 .2l.2-1.5c-.4 0-.7-.1-1.1-.2l-.1.2v-.2c-2.6-.8-4.5-3.3-4.5-6.2 0-3.6 2.9-6.5 6.5-6.5v1.8l3-2.5zM20 11c-.2-1.4-.7-2.7-1.6-3.8l-1.2.8c.7.9 1.1 2 1.3 3.1L20 11zm-1.5 1.8c-.1.5-.2 1.1-.4 1.6s-.5 1-.8 1.5l1.2.9c.4-.5.8-1.1 1-1.8s.5-1.3.5-2l-1.5-.2zm-5.6 5.6l.2 1.5c1.4-.2 2.7-.7 3.8-1.6l-.9-1.1c-.9.7-2 1.1-3.1 1.2z" -})); -/* harmony default export */ var rotate_right = (rotateRight); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-left.js -/** - * WordPress dependencies - */ -const rotateLeft = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { + +const radioCheck = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M12 4V2.2L9 4.8l3 2.5V5.5c3.6 0 6.5 2.9 6.5 6.5 0 2.9-1.9 5.3-4.5 6.2v.2l-.1-.2c-.4.1-.7.2-1.1.2l.2 1.5c.3 0 .6-.1 1-.2 3.5-.9 6-4 6-7.7 0-4.4-3.6-8-8-8zm-7.9 7l1.5.2c.1-1.2.5-2.3 1.2-3.2l-1.1-.9C4.8 8.2 4.3 9.6 4.1 11zm1.5 1.8l-1.5.2c.1.7.3 1.4.5 2 .3.7.6 1.3 1 1.8l1.2-.8c-.3-.5-.6-1-.8-1.5s-.4-1.1-.4-1.7zm1.5 5.5c1.1.9 2.4 1.4 3.8 1.6l.2-1.5c-1.1-.1-2.2-.5-3.1-1.2l-.9 1.1z" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Circle, { + cx: 12, + cy: 12, + r: 3 })); -/* harmony default export */ var rotate_left = (rotateLeft); +function search_widget_normalizeSearchInput(input = '') { + return remove_accents_default()(input.trim().toLowerCase()); +} +function SearchWidget({ + filter, + view, + onChangeView +}) { + const [searchValue, setSearchValue] = (0,external_wp_element_namespaceObject.useState)(''); + const deferredSearchValue = (0,external_wp_element_namespaceObject.useDeferredValue)(searchValue); + const selectedFilter = view.filters.find(_filter => _filter.field === filter.field); + const selectedValues = selectedFilter?.value; + const matches = (0,external_wp_element_namespaceObject.useMemo)(() => { + const normalizedSearch = search_widget_normalizeSearchInput(deferredSearchValue); + return filter.elements.filter(item => search_widget_normalizeSearchInput(item.label).includes(normalizedSearch)); + }, [filter.elements, deferredSearchValue]); + return (0,external_React_.createElement)(ComboboxProvider, { + value: searchValue, + setSelectedValue: value => { + const currentFilter = view.filters.find(_filter => _filter.field === filter.field); + const newFilters = currentFilter ? [...view.filters.map(_filter => { + if (_filter.field === filter.field) { + return { + ..._filter, + operator: currentFilter.operator || filter.operators[0], + value + }; + } + return _filter; + })] : [...view.filters, { + field: filter.field, + operator: filter.operators[0], + value + }]; + onChangeView({ + ...view, + page: 1, + filters: newFilters + }); + }, + setValue: setSearchValue + }, (0,external_React_.createElement)("div", { + className: "dataviews-search-widget-filter-combobox__wrapper" + }, (0,external_React_.createElement)(ComboboxLabel, { + render: (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null) + }, (0,external_wp_i18n_namespaceObject.__)('Search items')), (0,external_React_.createElement)(Combobox, { + autoSelect: "always", + placeholder: (0,external_wp_i18n_namespaceObject.__)('Search'), + className: "dataviews-search-widget-filter-combobox__input" + }), (0,external_React_.createElement)("div", { + className: "dataviews-search-widget-filter-combobox__icon" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: library_search + }))), (0,external_React_.createElement)(ComboboxList, { + className: "dataviews-search-widget-filter-combobox-list", + alwaysVisible: true + }, matches.map(element => { + return (0,external_React_.createElement)(ComboboxItem, { + key: element.value, + value: element.value, + className: "dataviews-search-widget-filter-combobox-item", + hideOnClick: false, + setValueOnClick: false, + focusOnHover: true + }, (0,external_React_.createElement)("span", { + className: "dataviews-search-widget-filter-combobox-item-check" + }, selectedValues === element.value && (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: radioCheck + })), (0,external_React_.createElement)("span", null, (0,external_React_.createElement)(ComboboxItemValue, { + className: "dataviews-search-widget-filter-combobox-item-value", + value: element.label + }), !!element.description && (0,external_React_.createElement)("span", { + className: "dataviews-search-widget-filter-combobox-item-description" + }, element.description))); + }), !matches.length && (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found')))); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/filter-summary.js + +/** + * External dependencies + */ -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js /** * WordPress dependencies */ -const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" -})); -/* harmony default export */ var block_default = (blockDefault); -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard.js + + + /** - * WordPress dependencies + * Internal dependencies */ -const keyboard = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 24 24" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "m16 15.5h-8v-1.5h8zm-7.5-2.5h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm-9-3h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2z" -}), (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - d: "m18.5 6.5h-13a.5.5 0 0 0 -.5.5v9.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9.5a.5.5 0 0 0 -.5-.5zm-13-1.5h13a2 2 0 0 1 2 2v9.5a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2-2v-9.5a2 2 0 0 1 2-2z" -})); -/* harmony default export */ var library_keyboard = (keyboard); -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/commands/use-edit-mode-commands.js +const FilterText = ({ + activeElement, + filterInView, + filter +}) => { + if (activeElement === undefined) { + return filter.name; + } + const filterTextWrappers = { + Span1: (0,external_React_.createElement)("span", { + className: "dataviews-filter-summary__filter-text-name" + }), + Span2: (0,external_React_.createElement)("span", { + className: "dataviews-filter-summary__filter-text-value" + }) + }; + if (activeElement !== undefined && filterInView?.operator === constants_OPERATOR_IN) { + return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Filter name. 2: Filter value. e.g.: "Author is Admin". */ + (0,external_wp_i18n_namespaceObject.__)('<Span1>%1$s </Span1><Span2>is %2$s</Span2>'), filter.name, activeElement.label), filterTextWrappers); + } + if (activeElement !== undefined && filterInView?.operator === constants_OPERATOR_NOT_IN) { + return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Filter name. 2: Filter value. e.g.: "Author is not Admin". */ + (0,external_wp_i18n_namespaceObject.__)('<Span1>%1$s </Span1><Span2>is not %2$s</Span2>'), filter.name, activeElement.label), filterTextWrappers); + } + return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Filter name e.g.: "Unknown status for Author". */ + (0,external_wp_i18n_namespaceObject.__)('Unknown status for %1$s'), filter.name); +}; +function OperatorSelector({ + filter, + view, + onChangeView +}) { + const operatorOptions = filter.operators?.map(operator => ({ + value: operator, + label: OPERATORS[operator]?.label + })); + const currentFilter = view.filters.find(_filter => _filter.field === filter.field); + const value = currentFilter?.operator || filter.operators[0]; + return operatorOptions.length > 1 && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + spacing: 2, + justify: "flex-start", + className: "dataviews-filter-summary__operators-container" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { + className: "dataviews-filter-summary__operators-filter-name" + }, filter.name), (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { + label: (0,external_wp_i18n_namespaceObject.__)('Conditions'), + value: value, + options: operatorOptions, + onChange: newValue => { + const newFilters = currentFilter ? [...view.filters.map(_filter => { + if (_filter.field === filter.field) { + return { + ..._filter, + operator: newValue + }; + } + return _filter; + })] : [...view.filters, { + field: filter.field, + operator: newValue + }]; + onChangeView({ + ...view, + page: 1, + filters: newFilters + }); + }, + size: "small", + __nextHasNoMarginBottom: true, + hideLabelFromVision: true + })); +} +function FilterSummary({ + addFilterRef, + openedFilter, + ...commonProps +}) { + const toggleRef = (0,external_wp_element_namespaceObject.useRef)(); + const { + filter, + view, + onChangeView + } = commonProps; + const filterInView = view.filters.find(f => f.field === filter.field); + const activeElement = filter.elements.find(element => element.value === filterInView?.value); + const isPrimary = filter.isPrimary; + const hasValues = filterInView?.value !== undefined; + const canResetOrRemove = !isPrimary || hasValues; + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Dropdown, { + defaultOpen: openedFilter === filter.field, + contentClassName: "dataviews-filter-summary__popover", + popoverProps: { + placement: 'bottom-start', + role: 'dialog' + }, + onClose: () => { + toggleRef.current?.focus(); + }, + renderToggle: ({ + isOpen, + onToggle + }) => (0,external_React_.createElement)("div", { + className: "dataviews-filter-summary__chip-container" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { + text: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Filter name. */ + (0,external_wp_i18n_namespaceObject.__)('Filter by: %1$s'), filter.name.toLowerCase()), + placement: "top" + }, (0,external_React_.createElement)("div", { + className: classnames_default()('dataviews-filter-summary__chip', { + 'has-reset': canResetOrRemove, + 'has-values': hasValues + }), + role: "button", + tabIndex: 0, + onClick: onToggle, + onKeyDown: event => { + if ([external_wp_keycodes_namespaceObject.ENTER, external_wp_keycodes_namespaceObject.SPACE].includes(event.keyCode)) { + onToggle(); + event.preventDefault(); + } + }, + "aria-pressed": isOpen, + "aria-expanded": isOpen, + ref: toggleRef + }, (0,external_React_.createElement)(FilterText, { + activeElement: activeElement, + filterInView: filterInView, + filter: filter + }))), canResetOrRemove && (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { + text: isPrimary ? (0,external_wp_i18n_namespaceObject.__)('Reset') : (0,external_wp_i18n_namespaceObject.__)('Remove'), + placement: "top" + }, (0,external_React_.createElement)("button", { + className: classnames_default()('dataviews-filter-summary__chip-remove', { + 'has-values': hasValues + }), + onClick: () => { + onChangeView({ + ...view, + page: 1, + filters: view.filters.filter(_filter => _filter.field !== filter.field) + }); + // If the filter is not primary and can be removed, it will be added + // back to the available filters from `Add filter` component. + if (!isPrimary) { + addFilterRef.current?.focus(); + } else { + // If is primary, focus the toggle button. + toggleRef.current?.focus(); + } + } + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: close_small + })))), + renderContent: () => { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: 0, + justify: "flex-start" + }, (0,external_React_.createElement)(OperatorSelector, { + ...commonProps + }), (0,external_React_.createElement)(SearchWidget, { + ...commonProps + })); + } + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/add-filter.js + /** * WordPress dependencies */ @@ -35205,360 +42207,341 @@ const keyboard = (0,external_wp_element_namespaceObject.createElement)(external_ +/** + * Internal dependencies + */ +const { + DropdownMenuV2: add_filter_DropdownMenu, + DropdownMenuItemV2: add_filter_DropdownMenuItem, + DropdownMenuItemLabelV2: add_filter_DropdownMenuItemLabel +} = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); +function AddFilter({ + filters, + view, + onChangeView, + setOpenedFilter +}, ref) { + if (!filters.length || filters.every(({ + isPrimary + }) => isPrimary)) { + return null; + } + const inactiveFilters = filters.filter(filter => !filter.isVisible); + return (0,external_React_.createElement)(add_filter_DropdownMenu, { + trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + __experimentalIsFocusable: true, + size: "compact", + icon: library_plus, + className: "dataviews-filters-button", + variant: "tertiary", + disabled: !inactiveFilters.length, + ref: ref + }, (0,external_wp_i18n_namespaceObject.__)('Add filter')) + }, inactiveFilters.map(filter => { + return (0,external_React_.createElement)(add_filter_DropdownMenuItem, { + key: filter.field, + onClick: () => { + setOpenedFilter(filter.field); + onChangeView({ + ...view, + page: 1, + filters: [...(view.filters || []), { + field: filter.field, + value: undefined, + operator: filter.operators[0] + }] + }); + } + }, (0,external_React_.createElement)(add_filter_DropdownMenuItemLabel, null, filter.name)); + })); +} +/* harmony default export */ const add_filter = ((0,external_wp_element_namespaceObject.forwardRef)(AddFilter)); +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/reset-filters.js +/** + * WordPress dependencies + */ + + +function ResetFilter({ + filters, + view, + onChangeView +}) { + const isPrimary = field => filters.some(_filter => _filter.field === field && _filter.isPrimary); + const isDisabled = !view.search && !view.filters?.some(_filter => _filter.value !== undefined || !isPrimary(_filter.field)); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + disabled: isDisabled, + __experimentalIsFocusable: true, + size: "compact", + variant: "tertiary", + onClick: () => { + onChangeView({ + ...view, + page: 1, + search: '', + filters: [] + }); + } + }, (0,external_wp_i18n_namespaceObject.__)('Reset filters')); +} +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/filters.js /** - * Internal dependencies + * WordPress dependencies */ +/** + * Internal dependencies + */ -const { - useHistory: use_edit_mode_commands_useHistory -} = unlock(external_wp_router_namespaceObject.privateApis); -function usePageContentFocusCommands() { - const { - record: template - } = useEditedEntityRecord(); - const { - isPage, - canvasMode, - hasPageContentFocus - } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ - isPage: select(store_store).isPage(), - canvasMode: unlock(select(store_store)).getCanvasMode(), - hasPageContentFocus: select(store_store).hasPageContentFocus() - }), []); - const { - setHasPageContentFocus - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - if (!isPage || canvasMode !== 'edit') { - return { - isLoading: false, - commands: [] - }; - } - const commands = []; - if (hasPageContentFocus) { - commands.push({ - name: 'core/switch-to-template-focus', - /* translators: %1$s: template title */ - label: (0,external_wp_i18n_namespaceObject.sprintf)('Edit template: %s', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)), - icon: library_layout, - callback: ({ - close - }) => { - setHasPageContentFocus(false); - close(); - } - }); - } else { - commands.push({ - name: 'core/switch-to-page-focus', - label: (0,external_wp_i18n_namespaceObject.__)('Back to page'), - icon: library_page, - callback: ({ - close - }) => { - setHasPageContentFocus(true); - close(); - } - }); - } - return { - isLoading: false, - commands - }; -} -function useEditorModeCommands() { - const { - switchEditorMode - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const { - canvasMode, - editorMode - } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ - canvasMode: unlock(select(store_store)).getCanvasMode(), - editorMode: select(store_store).getEditorMode() - }), []); - if (canvasMode !== 'edit' || editorMode !== 'text') { - return { - isLoading: false, - commands: [] - }; - } - const commands = []; - if (editorMode === 'text') { - commands.push({ - name: 'core/exit-code-editor', - label: (0,external_wp_i18n_namespaceObject.__)('Exit code editor'), - icon: library_code, - callback: ({ - close - }) => { - switchEditorMode('visual'); - close(); - } - }); - } - return { - isLoading: false, - commands - }; -} -function useManipulateDocumentCommands() { - const { - isLoaded, - record: template - } = useEditedEntityRecord(); - const { - removeTemplate, - revertTemplate - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const history = use_edit_mode_commands_useHistory(); - const hasPageContentFocus = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasPageContentFocus(), []); - if (!isLoaded) { - return { - isLoading: true, - commands: [] - }; - } - const commands = []; - if (isTemplateRevertable(template) && !hasPageContentFocus) { - const label = template.type === TEMPLATE_POST_TYPE ? /* translators: %1$s: template title */ - (0,external_wp_i18n_namespaceObject.sprintf)('Reset template: %s', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)) : /* translators: %1$s: template part title */ - (0,external_wp_i18n_namespaceObject.sprintf)('Reset template part: %s', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)); - commands.push({ - name: 'core/reset-template', - label, - icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? rotate_right : rotate_left, - callback: ({ - close - }) => { - revertTemplate(template); - close(); - } - }); - } - if (isTemplateRemovable(template) && !hasPageContentFocus) { - const label = template.type === TEMPLATE_POST_TYPE ? /* translators: %1$s: template title */ - (0,external_wp_i18n_namespaceObject.sprintf)('Delete template: %s', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)) : /* translators: %1$s: template part title */ - (0,external_wp_i18n_namespaceObject.sprintf)('Delete template part: %s', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)); - const path = template.type === TEMPLATE_POST_TYPE ? '/wp_template' : '/wp_template_part/all'; - commands.push({ - name: 'core/remove-template', - label, - icon: library_trash, - callback: ({ - close - }) => { - removeTemplate(template); - // Navigate to the template list - history.push({ - path +const Filters = (0,external_wp_element_namespaceObject.memo)(function Filters({ + fields, + view, + onChangeView, + openedFilter, + setOpenedFilter +}) { + const addFilterRef = (0,external_wp_element_namespaceObject.useRef)(); + const filters = []; + fields.forEach(field => { + if (!field.type) { + return; + } + const operators = sanitizeOperators(field); + if (operators.length === 0) { + return; + } + switch (field.type) { + case constants_ENUMERATION_TYPE: + if (!field.elements?.length) { + return; + } + const isPrimary = !!field.filterBy?.isPrimary; + filters.push({ + field: field.id, + name: field.header, + elements: field.elements, + operators, + isVisible: isPrimary || view.filters.some(f => f.field === field.id && [constants_OPERATOR_IN, constants_OPERATOR_NOT_IN].includes(f.operator)), + isPrimary }); - close(); - } - }); - } - return { - isLoading: !isLoaded, - commands - }; -} -function useEditUICommands() { - const { - openGeneralSidebar, - closeGeneralSidebar, - toggleDistractionFree, - setIsListViewOpened, - switchEditorMode - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const { - canvasMode, - editorMode, - activeSidebar, - showBlockBreadcrumbs, - isListViewOpen, - isDistractionFree - } = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - isListViewOpened, - getEditorMode - } = select(store_store); - return { - canvasMode: unlock(select(store_store)).getCanvasMode(), - editorMode: getEditorMode(), - activeSidebar: select(store).getActiveComplementaryArea(store_store.name), - showBlockBreadcrumbs: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'showBlockBreadcrumbs'), - isListViewOpen: isListViewOpened(), - isDistractionFree: select(external_wp_preferences_namespaceObject.store).get(store_store.name, 'distractionFree') - }; - }, []); - const { - openModal - } = (0,external_wp_data_namespaceObject.useDispatch)(store); - const { - toggle - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); - const { - createInfoNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - if (canvasMode !== 'edit') { - return { - isLoading: false, - commands: [] - }; - } - const commands = []; - commands.push({ - name: 'core/open-settings-sidebar', - label: (0,external_wp_i18n_namespaceObject.__)('Toggle settings sidebar'), - icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right, - callback: ({ - close - }) => { - close(); - if (activeSidebar === 'edit-site/template') { - closeGeneralSidebar(); - } else { - openGeneralSidebar('edit-site/template'); - } } }); - commands.push({ - name: 'core/open-block-inspector', - label: (0,external_wp_i18n_namespaceObject.__)('Toggle block inspector'), - icon: block_default, - callback: ({ - close - }) => { - close(); - if (activeSidebar === 'edit-site/block-inspector') { - closeGeneralSidebar(); - } else { - openGeneralSidebar('edit-site/block-inspector'); - } + // Sort filters by primary property. We need the primary filters to be first. + // Then we sort by name. + filters.sort((a, b) => { + if (a.isPrimary && !b.isPrimary) { + return -1; } - }); - commands.push({ - name: 'core/toggle-spotlight-mode', - label: (0,external_wp_i18n_namespaceObject.__)('Toggle spotlight mode'), - callback: ({ - close - }) => { - toggle('core/edit-site', 'focusMode'); - close(); + if (!a.isPrimary && b.isPrimary) { + return 1; } + return a.name.localeCompare(b.name); }); - commands.push({ - name: 'core/toggle-distraction-free', - label: (0,external_wp_i18n_namespaceObject.__)('Toggle distraction free'), - callback: ({ - close - }) => { - toggleDistractionFree(); - close(); - } + const addFilter = (0,external_React_.createElement)(add_filter, { + key: "add-filter", + filters: filters, + view: view, + onChangeView: onChangeView, + ref: addFilterRef, + setOpenedFilter: setOpenedFilter }); - commands.push({ - name: 'core/toggle-top-toolbar', - label: (0,external_wp_i18n_namespaceObject.__)('Toggle top toolbar'), - callback: ({ - close - }) => { - toggle('core/edit-site', 'fixedToolbar'); - if (isDistractionFree) { - toggleDistractionFree(); - } - close(); + const filterComponents = [...filters.map(filter => { + if (!filter.isVisible) { + return null; } - }); - if (editorMode === 'visual') { - commands.push({ - name: 'core/toggle-code-editor', - label: (0,external_wp_i18n_namespaceObject.__)('Open code editor'), - icon: library_code, - callback: ({ - close - }) => { - switchEditorMode('text'); - close(); - } + return (0,external_React_.createElement)(FilterSummary, { + key: filter.field, + filter: filter, + view: view, + onChangeView: onChangeView, + addFilterRef: addFilterRef, + openedFilter: openedFilter }); + }), addFilter]; + if (filterComponents.length > 1) { + filterComponents.push((0,external_React_.createElement)(ResetFilter, { + key: "reset-filters", + filters: filters, + view: view, + onChangeView: onChangeView + })); } - commands.push({ - name: 'core/open-preferences', - label: (0,external_wp_i18n_namespaceObject.__)('Editor preferences'), - callback: () => { - openModal(PREFERENCES_MODAL_NAME); - } - }); - commands.push({ - name: 'core/open-shortcut-help', - label: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'), - icon: library_keyboard, - callback: () => { - openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME); - } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "flex-start", + style: { + width: 'fit-content' + }, + wrap: true + }, filterComponents); +}); +/* harmony default export */ const filters = (Filters); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/search.js + +/** + * WordPress dependencies + */ + + + + +const Search = (0,external_wp_element_namespaceObject.memo)(function Search({ + label, + view, + onChangeView +}) { + const [search, setSearch, debouncedSearch] = (0,external_wp_compose_namespaceObject.useDebouncedInput)(view.search); + (0,external_wp_element_namespaceObject.useEffect)(() => { + setSearch(view.search); + }, [view]); + const onChangeViewRef = (0,external_wp_element_namespaceObject.useRef)(onChangeView); + (0,external_wp_element_namespaceObject.useEffect)(() => { + onChangeViewRef.current = onChangeView; + }, [onChangeView]); + (0,external_wp_element_namespaceObject.useEffect)(() => { + onChangeViewRef.current({ + ...view, + page: 1, + search: debouncedSearch + }); + }, [debouncedSearch]); + const searchLabel = label || (0,external_wp_i18n_namespaceObject.__)('Search'); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.SearchControl, { + __nextHasNoMarginBottom: true, + onChange: setSearch, + value: search, + label: searchLabel, + placeholder: searchLabel, + size: "compact" }); - commands.push({ - name: 'core/toggle-breadcrumbs', - label: showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Hide block breadcrumbs') : (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs'), - callback: ({ - close - }) => { - toggle('core/edit-site', 'showBlockBreadcrumbs'); - close(); - createInfoNotice(showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs hidden.') : (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs visible.'), { - id: 'core/edit-site/toggle-breadcrumbs/notice', - type: 'snackbar' +}); +/* harmony default export */ const build_module_search = (Search); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/dataviews.js + +/** + * WordPress dependencies + */ + + + +/** + * Internal dependencies + */ + + + + + + +const defaultGetItemId = item => item.id; +const defaultOnSelectionChange = () => {}; +function dataviews_useSomeItemHasAPossibleBulkAction(actions, data) { + return (0,external_wp_element_namespaceObject.useMemo)(() => { + return data.some(item => { + return actions.some(action => { + return action.supportsBulk && action.isEligible(item); }); - } - }); - commands.push({ - name: 'core/toggle-list-view', - label: (0,external_wp_i18n_namespaceObject.__)('Toggle list view'), - icon: list_view, - callback: ({ - close - }) => { - setIsListViewOpened(!isListViewOpen); - close(); - } - }); - return { - isLoading: false, - commands - }; -} -function useEditModeCommands() { - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/exit-code-editor', - hook: useEditorModeCommands, - context: 'site-editor-edit' - }); - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/edit-site/page-content-focus', - hook: usePageContentFocusCommands, - context: 'site-editor-edit' - }); - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/edit-site/manipulate-document', - hook: useManipulateDocumentCommands - }); - (0,external_wp_commands_namespaceObject.useCommandLoader)({ - name: 'core/edit-site/edit-ui', - hook: useEditUICommands - }); + }); + }, [actions, data]); +} +function DataViews({ + view, + onChangeView, + fields, + search = true, + searchLabel = undefined, + actions, + data, + getItemId = defaultGetItemId, + isLoading = false, + paginationInfo, + supportedLayouts, + onSelectionChange = defaultOnSelectionChange, + onDetailsChange = null, + deferredRendering = false +}) { + const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)([]); + const [openedFilter, setOpenedFilter] = (0,external_wp_element_namespaceObject.useState)(null); + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (selection.length > 0 && selection.some(id => !data.some(item => getItemId(item) === id))) { + const newSelection = selection.filter(id => data.some(item => getItemId(item) === id)); + setSelection(newSelection); + onSelectionChange(data.filter(item => newSelection.includes(getItemId(item)))); + } + }, [selection, data, getItemId, onSelectionChange]); + const onSetSelection = (0,external_wp_element_namespaceObject.useCallback)(items => { + setSelection(items.map(item => getItemId(item))); + onSelectionChange(items); + }, [setSelection, getItemId, onSelectionChange]); + const ViewComponent = VIEW_LAYOUTS.find(v => v.type === view.type).component; + const _fields = (0,external_wp_element_namespaceObject.useMemo)(() => { + return fields.map(field => ({ + ...field, + render: field.render || field.getValue + })); + }, [fields]); + const hasPossibleBulkAction = dataviews_useSomeItemHasAPossibleBulkAction(actions, data); + return (0,external_React_.createElement)("div", { + className: "dataviews-wrapper" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + alignment: "top", + justify: "start", + className: "dataviews-filters__view-actions" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "start", + className: "dataviews-filters__container", + wrap: true + }, search && (0,external_React_.createElement)(build_module_search, { + label: searchLabel, + view: view, + onChangeView: onChangeView + }), (0,external_React_.createElement)(filters, { + fields: _fields, + view: view, + onChangeView: onChangeView, + openedFilter: openedFilter, + setOpenedFilter: setOpenedFilter + })), [constants_LAYOUT_TABLE, constants_LAYOUT_GRID].includes(view.type) && hasPossibleBulkAction && (0,external_React_.createElement)(BulkActions, { + actions: actions, + data: data, + onSelectionChange: onSetSelection, + selection: selection, + getItemId: getItemId + }), (0,external_React_.createElement)(view_actions, { + fields: _fields, + view: view, + onChangeView: onChangeView, + supportedLayouts: supportedLayouts + })), (0,external_React_.createElement)(ViewComponent, { + fields: _fields, + view: view, + onChangeView: onChangeView, + actions: actions, + data: data, + getItemId: getItemId, + isLoading: isLoading, + onSelectionChange: onSetSelection, + onDetailsChange: onDetailsChange, + selection: selection, + deferredRendering: deferredRendering, + setOpenedFilter: setOpenedFilter + }), (0,external_React_.createElement)(pagination, { + view: view, + onChangeView: onChangeView, + paginationInfo: paginationInfo + })); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page/header.js @@ -35577,20 +42560,21 @@ function Header({ subTitle, actions }) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { as: "header", alignment: "left", className: "edit-site-page-header" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, { className: "edit-site-page-header__page-title" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { as: "h2", - level: 4, + level: 3, + weight: 500, className: "edit-site-page-header__title" - }, title), subTitle && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { + }, title), subTitle && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { as: "p", className: "edit-site-page-header__sub-title" - }, subTitle)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, { + }, subTitle)), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { className: "edit-site-page-header__actions" }, actions)); } @@ -35621,19 +42605,19 @@ function Page({ hideTitleFromUI = false }) { const classes = classnames_default()('edit-site-page', className); - return (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + return (0,external_React_.createElement)(NavigableRegion, { className: classes, ariaLabel: title - }, (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)("div", { className: "edit-site-page-content" - }, !hideTitleFromUI && title && (0,external_wp_element_namespaceObject.createElement)(Header, { + }, !hideTitleFromUI && title && (0,external_React_.createElement)(Header, { title: title, subTitle: subTitle, actions: actions - }), children), (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null)); + }), children), (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null)); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/header.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/actions/index.js /** * WordPress dependencies @@ -35642,64 +42626,341 @@ function Page({ + + + + + + + /** * Internal dependencies */ - -function PatternsHeader({ - categoryId, - type, - titleId, - descriptionId -}) { +const { + useHistory: actions_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +const trashPostAction = { + id: 'move-to-trash', + label: (0,external_wp_i18n_namespaceObject.__)('Move to Trash'), + isPrimary: true, + icon: library_trash, + isEligible({ + status + }) { + return status !== 'trash'; + }, + supportsBulk: true, + hideModalHeader: true, + RenderModal: ({ + items: posts, + closeModal, + onPerform + }) => { + const { + createSuccessNotice, + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const { + deleteEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: "5" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, posts.length === 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %s: The page's title. + (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(posts[0].title.rendered)) : (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %d: The number of pages (2 or more). + (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete %d pages?'), posts.length)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "right" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "tertiary", + onClick: closeModal + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "primary", + onClick: async () => { + const promiseResult = await Promise.allSettled(posts.map(post => { + return deleteEntityRecord('postType', post.type, post.id, {}, { + throwOnError: true + }); + })); + // If all the promises were fulfilled with success. + if (promiseResult.every(({ + status + }) => status === 'fulfilled')) { + let successMessage; + if (promiseResult.length === 1) { + successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */ + (0,external_wp_i18n_namespaceObject.__)('"%s" moved to the Trash.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(posts[0].title.rendered)); + } else { + successMessage = (0,external_wp_i18n_namespaceObject.__)('Pages moved to the Trash.'); + } + createSuccessNotice(successMessage, { + type: 'snackbar', + id: 'edit-site-page-trashed' + }); + } else { + // If there was at lease one failure. + let errorMessage; + // If we were trying to move a single post to the trash. + if (promiseResult.length === 1) { + if (promiseResult[0].reason?.message) { + errorMessage = promiseResult[0].reason.message; + } else { + errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the post to the trash.'); + } + // If we were trying to move multiple posts to the trash + } else { + const errorMessages = new Set(); + const failedPromises = promiseResult.filter(({ + status + }) => status === 'rejected'); + for (const failedPromise of failedPromises) { + if (failedPromise.reason?.message) { + errorMessages.add(failedPromise.reason.message); + } + } + if (errorMessages.size === 0) { + errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the posts to the trash.'); + } else if (errorMessages.size === 1) { + errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ + (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the posts to the trash: %s'), [...errorMessages][0]); + } else { + errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ + (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while moving the pages to the trash: %s'), [...errorMessages].join(',')); + } + createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } + } + if (onPerform) { + onPerform(); + } + closeModal(); + } + }, (0,external_wp_i18n_namespaceObject.__)('Delete')))); + } +}; +function usePermanentlyDeletePostAction() { const { - patternCategories - } = usePatternCategories(); - const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []); - let title, description; - if (type === TEMPLATE_PART_POST_TYPE) { - const templatePartArea = templatePartAreas.find(area => area.area === categoryId); - title = templatePartArea?.label; - description = templatePartArea?.description; - } else if (type === PATTERN_TYPES.theme) { - const patternCategory = patternCategories.find(category => category.name === categoryId); - title = patternCategory?.label; - description = patternCategory?.description; + createSuccessNotice, + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const { + deleteEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + return (0,external_wp_element_namespaceObject.useMemo)(() => ({ + id: 'permanently-delete', + label: (0,external_wp_i18n_namespaceObject.__)('Permanently delete'), + isPrimary: true, + icon: library_trash, + supportsBulk: true, + isEligible({ + status + }) { + return status === 'trash'; + }, + async callback(posts) { + const promiseResult = await Promise.allSettled(posts.map(post => { + return deleteEntityRecord('postType', post.type, post.id, { + force: true + }, { + throwOnError: true + }); + })); + // If all the promises were fulfilled with success. + if (promiseResult.every(({ + status + }) => status === 'fulfilled')) { + let successMessage; + if (promiseResult.length === 1) { + successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */ + (0,external_wp_i18n_namespaceObject.__)('"%s" permanently deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(posts[0].title.rendered)); + } else { + successMessage = (0,external_wp_i18n_namespaceObject.__)('The posts were permanently deleted.'); + } + createSuccessNotice(successMessage, { + type: 'snackbar', + id: 'edit-site-post-permanently-deleted' + }); + } else { + // If there was at lease one failure. + let errorMessage; + // If we were trying to permanently delete a single post. + if (promiseResult.length === 1) { + if (promiseResult[0].reason?.message) { + errorMessage = promiseResult[0].reason.message; + } else { + errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the post.'); + } + // If we were trying to permanently delete multiple posts + } else { + const errorMessages = new Set(); + const failedPromises = promiseResult.filter(({ + status + }) => status === 'rejected'); + for (const failedPromise of failedPromises) { + if (failedPromise.reason?.message) { + errorMessages.add(failedPromise.reason.message); + } + } + if (errorMessages.size === 0) { + errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts.'); + } else if (errorMessages.size === 1) { + errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ + (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts: %s'), [...errorMessages][0]); + } else { + errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ + (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while permanently deleting the posts: %s'), [...errorMessages].join(',')); + } + createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } + } + } + }), [createSuccessNotice, createErrorNotice, deleteEntityRecord]); +} +function useRestorePostAction() { + const { + createSuccessNotice, + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const { + editEntityRecord, + saveEditedEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + return (0,external_wp_element_namespaceObject.useMemo)(() => ({ + id: 'restore', + label: (0,external_wp_i18n_namespaceObject.__)('Restore'), + isPrimary: true, + icon: library_backup, + supportsBulk: true, + isEligible({ + status + }) { + return status === 'trash'; + }, + async callback(posts) { + try { + for (const post of posts) { + await editEntityRecord('postType', post.type, post.id, { + status: 'draft' + }); + await saveEditedEntityRecord('postType', post.type, post.id, { + throwOnError: true + }); + } + createSuccessNotice(posts.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */ + (0,external_wp_i18n_namespaceObject.__)('%d posts have been restored.'), posts.length) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */ + (0,external_wp_i18n_namespaceObject.__)('"%s" has been restored.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(posts[0].title.rendered)), { + type: 'snackbar', + id: 'edit-site-post-restored' + }); + } catch (error) { + let errorMessage; + if (error.message && error.code !== 'unknown_error' && error.message) { + errorMessage = error.message; + } else if (posts.length > 1) { + errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts.'); + } else { + errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the post.'); + } + createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } + } + }), [createSuccessNotice, createErrorNotice, editEntityRecord, saveEditedEntityRecord]); +} +const viewPostAction = { + id: 'view-post', + label: (0,external_wp_i18n_namespaceObject.__)('View'), + isPrimary: true, + icon: library_external, + isEligible(post) { + return post.status !== 'trash'; + }, + callback(posts) { + const post = posts[0]; + document.location.href = post.link; } - if (!title) return null; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { - className: "edit-site-patterns__section-header" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { - as: "h2", - level: 4, - id: titleId - }, title), description ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - variant: "muted", - as: "p", - id: descriptionId - }, description) : null); +}; +function useEditPostAction() { + const history = actions_useHistory(); + return (0,external_wp_element_namespaceObject.useMemo)(() => ({ + id: 'edit-post', + label: (0,external_wp_i18n_namespaceObject.__)('Edit'), + isEligible({ + status + }) { + return status !== 'trash'; + }, + callback(posts) { + const post = posts[0]; + history.push({ + postId: post.id, + postType: post.type, + canvas: 'edit' + }); + } + }), [history]); } +const postRevisionsAction = { + id: 'view-post-revisions', + label: (0,external_wp_i18n_namespaceObject.__)('View revisions'), + isPrimary: false, + isEligible: post => { + var _post$_links$predeces, _post$_links$version; + if (post.status === 'trash') { + return false; + } + const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null; + const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0; + return lastRevisionId && revisionsCount > 1; + }, + callback(posts) { + const post = posts[0]; + const href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', { + revision: post?._links?.['predecessor-version']?.[0]?.id + }); + document.location.href = href; + } +}; -;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/lock-small.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/media/index.js /** * WordPress dependencies */ -const lockSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { - viewBox: "0 0 24 24", - xmlns: "http://www.w3.org/2000/svg" -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { - fillRule: "evenodd", - clipRule: "evenodd", - d: "M15 11h-.2V9c0-1.5-1.2-2.8-2.8-2.8S9.2 7.5 9.2 9v2H9c-.6 0-1 .4-1 1v4c0 .6.4 1 1 1h6c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1zm-1.8 0h-2.5V9c0-.7.6-1.2 1.2-1.2s1.2.6 1.2 1.2v2z" -})); -/* harmony default export */ var lock_small = (lockSmall); +function Media({ + id, + size = ['large', 'medium', 'thumbnail'], + ...props +}) { + const { + record: media + } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('root', 'media', id); + const currentSize = size.find(s => !!media?.media_details?.sizes[s]); + const mediaUrl = media?.media_details?.sizes[currentSize]?.source_url || media?.source_url; + if (!mediaUrl) { + return null; + } + return (0,external_React_.createElement)("img", { + ...props, + src: mediaUrl, + alt: media.alt_text + }); +} +/* harmony default export */ const components_media = (Media); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-pages/index.js + +/** + * External dependencies + */ -;// CONCATENATED MODULE: external ["wp","reusableBlocks"] -var external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"]; -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/rename-menu-item.js /** * WordPress dependencies @@ -35711,96 +42972,419 @@ var external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"]; + + + /** * Internal dependencies */ -function rename_menu_item_RenameMenuItem({ - item, - onClose -}) { - const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => item.title); - const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); + + + + + + + +const { + useLocation: page_pages_useLocation, + useHistory: page_pages_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +const page_pages_EMPTY_ARRAY = []; +const SUPPORTED_LAYOUTS = window?.__experimentalAdminViews ? [LAYOUT_GRID, LAYOUT_TABLE, LAYOUT_LIST] : [LAYOUT_GRID, LAYOUT_TABLE]; +function useView(postType) { const { - editEntityRecord, - saveEditedEntityRecord - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + params + } = page_pages_useLocation(); const { - createSuccessNotice, - createErrorNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - if (item.type === TEMPLATE_PART_POST_TYPE && !item.isCustom) { - return null; - } - async function onRename(event) { - event.preventDefault(); - try { - await editEntityRecord('postType', item.type, item.id, { - title + activeView = 'all', + isCustom = 'false', + layout + } = params; + const history = page_pages_useHistory(); + const selectedDefaultView = (0,external_wp_element_namespaceObject.useMemo)(() => { + const defaultView = isCustom === 'false' && DEFAULT_VIEWS[postType].find(({ + slug + }) => slug === activeView)?.view; + if (isCustom === 'false' && layout) { + return { + ...defaultView, + type: layout, + layout: { + ...(DEFAULT_CONFIG_PER_VIEW_TYPE[layout] || {}) + } + }; + } + return defaultView; + }, [isCustom, activeView, layout, postType]); + const [view, setView] = (0,external_wp_element_namespaceObject.useState)(selectedDefaultView); + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (selectedDefaultView) { + setView(selectedDefaultView); + } + }, [selectedDefaultView]); + const editedViewRecord = (0,external_wp_data_namespaceObject.useSelect)(select => { + if (isCustom !== 'true') { + return; + } + const { + getEditedEntityRecord + } = select(external_wp_coreData_namespaceObject.store); + const dataviewRecord = getEditedEntityRecord('postType', 'wp_dataviews', Number(activeView)); + return dataviewRecord; + }, [activeView, isCustom]); + const { + editEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + const customView = (0,external_wp_element_namespaceObject.useMemo)(() => { + const storedView = editedViewRecord?.content && JSON.parse(editedViewRecord?.content); + if (!storedView) { + return storedView; + } + return { + ...storedView, + layout: { + ...(DEFAULT_CONFIG_PER_VIEW_TYPE[storedView?.type] || {}) + } + }; + }, [editedViewRecord?.content]); + const setCustomView = (0,external_wp_element_namespaceObject.useCallback)(viewToSet => { + editEntityRecord('postType', 'wp_dataviews', editedViewRecord?.id, { + content: JSON.stringify(viewToSet) + }); + }, [editEntityRecord, editedViewRecord?.id]); + const setDefaultViewAndUpdateUrl = (0,external_wp_element_namespaceObject.useCallback)(viewToSet => { + if (viewToSet.type !== view?.type) { + history.push({ + ...params, + layout: viewToSet.type }); + } + setView(viewToSet); + }, [params, view?.type, history]); + if (isCustom === 'false') { + return [view, setDefaultViewAndUpdateUrl]; + } else if (isCustom === 'true' && customView) { + return [customView, setCustomView]; + } + // Loading state where no the view was not found on custom views or default views. + return [DEFAULT_VIEWS[postType][0].view, setDefaultViewAndUpdateUrl]; +} - // Update state before saving rerenders the list. - setTitle(''); - setIsModalOpen(false); - onClose(); +// See https://github.com/WordPress/gutenberg/issues/55886 +// We do not support custom statutes at the moment. +const STATUSES = [{ + value: 'draft', + label: (0,external_wp_i18n_namespaceObject.__)('Draft') +}, { + value: 'future', + label: (0,external_wp_i18n_namespaceObject.__)('Scheduled') +}, { + value: 'pending', + label: (0,external_wp_i18n_namespaceObject.__)('Pending Review') +}, { + value: 'private', + label: (0,external_wp_i18n_namespaceObject.__)('Private') +}, { + value: 'publish', + label: (0,external_wp_i18n_namespaceObject.__)('Published') +}, { + value: 'trash', + label: (0,external_wp_i18n_namespaceObject.__)('Trash') +}]; +const DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'. - // Persist edited entity. - await saveEditedEntityRecord('postType', item.type, item.id, { - throwOnError: true - }); - createSuccessNotice(item.type === TEMPLATE_PART_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template part renamed.') : (0,external_wp_i18n_namespaceObject.__)('Pattern renamed.'), { - type: 'snackbar' - }); - } catch (error) { - const fallbackErrorMessage = item.type === TEMPLATE_PART_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the pattern.'); - const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; - createErrorNotice(errorMessage, { - type: 'snackbar' +function FeaturedImage({ + item, + viewType +}) { + const { + onClick + } = useLink({ + postId: item.id, + postType: item.type, + canvas: 'edit' + }); + const hasMedia = !!item.featured_media; + const size = viewType === LAYOUT_GRID ? ['large', 'full', 'medium', 'thumbnail'] : ['thumbnail', 'medium', 'large', 'full']; + const media = hasMedia ? (0,external_React_.createElement)(components_media, { + className: "edit-site-page-pages__featured-image", + id: item.featured_media, + size: size + }) : null; + if (viewType === LAYOUT_LIST) { + return media; + } + return (0,external_React_.createElement)("button", { + className: classnames_default()('page-pages-preview-field__button', { + 'edit-site-page-pages__media-wrapper': viewType === LAYOUT_TABLE + }), + type: "button", + onClick: onClick, + "aria-label": item.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)') + }, media); +} +function PagePages() { + const postType = 'page'; + const [view, setView] = useView(postType); + const history = page_pages_useHistory(); + const { + params + } = page_pages_useLocation(); + const { + isCustom = 'false' + } = params; + const onSelectionChange = (0,external_wp_element_namespaceObject.useCallback)(items => { + if (isCustom === 'false' && view?.type === LAYOUT_LIST) { + history.push({ + ...params, + postId: items.length === 1 ? items[0].id : undefined }); } - } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: () => { - setIsModalOpen(true); - setTitle(item.title); + }, [history, params, view?.type, isCustom]); + const queryArgs = (0,external_wp_element_namespaceObject.useMemo)(() => { + const filters = {}; + view.filters.forEach(filter => { + if (filter.field === 'status' && filter.operator === OPERATOR_IN) { + filters.status = filter.value; + } + if (filter.field === 'author' && filter.operator === OPERATOR_IN) { + filters.author = filter.value; + } else if (filter.field === 'author' && filter.operator === OPERATOR_NOT_IN) { + filters.author_exclude = filter.value; + } + }); + // We want to provide a different default item for the status filter + // than the REST API provides. + if (!filters.status || filters.status === '') { + filters.status = DEFAULT_STATUSES; } - }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { - title: (0,external_wp_i18n_namespaceObject.__)('Rename'), - onRequestClose: () => { - setIsModalOpen(false); - onClose(); + return { + per_page: view.perPage, + page: view.page, + _embed: 'author', + order: view.sort?.direction, + orderby: view.sort?.field, + search: view.search, + ...filters + }; + }, [view]); + const { + records: pages, + isResolving: isLoadingPages, + totalItems, + totalPages + } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', postType, queryArgs); + const { + records: authors, + isResolving: isLoadingAuthors + } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('root', 'user'); + const paginationInfo = (0,external_wp_element_namespaceObject.useMemo)(() => ({ + totalItems, + totalPages + }), [totalItems, totalPages]); + const fields = (0,external_wp_element_namespaceObject.useMemo)(() => [{ + id: 'featured-image', + header: (0,external_wp_i18n_namespaceObject.__)('Featured Image'), + getValue: ({ + item + }) => item.featured_media, + render: ({ + item + }) => (0,external_React_.createElement)(FeaturedImage, { + item: item, + viewType: view.type + }), + enableSorting: false, + width: '1%' + }, { + header: (0,external_wp_i18n_namespaceObject.__)('Title'), + id: 'title', + getValue: ({ + item + }) => item.title?.rendered, + render: ({ + item + }) => { + return [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type) ? (0,external_React_.createElement)(Link, { + params: { + postId: item.id, + postType: item.type, + canvas: 'edit' + } + }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered) || (0,external_wp_i18n_namespaceObject.__)('(no title)')) : (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered) || (0,external_wp_i18n_namespaceObject.__)('(no title)'); }, - overlayClassName: "edit-site-list__rename-modal" - }, (0,external_wp_element_namespaceObject.createElement)("form", { - onSubmit: onRename - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { - spacing: "5" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { - __nextHasNoMarginBottom: true, - label: (0,external_wp_i18n_namespaceObject.__)('Name'), - value: title, - onChange: setTitle, - required: true - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - justify: "right" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "tertiary", - onClick: () => { - setIsModalOpen(false); - onClose(); + maxWidth: 300, + enableHiding: false + }, { + header: (0,external_wp_i18n_namespaceObject.__)('Author'), + id: 'author', + getValue: ({ + item + }) => item._embedded?.author[0]?.name, + type: ENUMERATION_TYPE, + elements: authors?.map(({ + id, + name + }) => ({ + value: id, + label: name + })) || [] + }, { + header: (0,external_wp_i18n_namespaceObject.__)('Status'), + id: 'status', + getValue: ({ + item + }) => { + var _STATUSES$find$label; + return (_STATUSES$find$label = STATUSES.find(({ + value + }) => value === item.status)?.label) !== null && _STATUSES$find$label !== void 0 ? _STATUSES$find$label : item.status; + }, + type: ENUMERATION_TYPE, + elements: STATUSES, + enableSorting: false, + filterBy: { + operators: [OPERATOR_IN] } - }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "primary", - type: "submit" - }, (0,external_wp_i18n_namespaceObject.__)('Save'))))))); + }, { + header: (0,external_wp_i18n_namespaceObject.__)('Date'), + id: 'date', + getValue: ({ + item + }) => item.date, + render: ({ + item + }) => { + const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_date_namespaceObject.getSettings)().formats.datetimeAbbreviated, (0,external_wp_date_namespaceObject.getDate)(item.date)); + return (0,external_React_.createElement)("time", null, formattedDate); + } + }], [authors, view.type]); + const permanentlyDeletePostAction = usePermanentlyDeletePostAction(); + const restorePostAction = useRestorePostAction(); + const editPostAction = useEditPostAction(); + const actions = (0,external_wp_element_namespaceObject.useMemo)(() => [viewPostAction, trashPostAction, restorePostAction, permanentlyDeletePostAction, editPostAction, postRevisionsAction], [permanentlyDeletePostAction, restorePostAction, editPostAction]); + const onChangeView = (0,external_wp_element_namespaceObject.useCallback)(newView => { + if (newView.type !== view.type) { + newView = { + ...newView, + layout: { + ...DEFAULT_CONFIG_PER_VIEW_TYPE[newView.type] + } + }; + } + setView(newView); + }, [view.type, setView]); + const [showAddPageModal, setShowAddPageModal] = (0,external_wp_element_namespaceObject.useState)(false); + const openModal = (0,external_wp_element_namespaceObject.useCallback)(() => { + if (!showAddPageModal) { + setShowAddPageModal(true); + } + }, [showAddPageModal]); + const closeModal = (0,external_wp_element_namespaceObject.useCallback)(() => { + if (showAddPageModal) { + setShowAddPageModal(false); + } + }, [showAddPageModal]); + const handleNewPage = (0,external_wp_element_namespaceObject.useCallback)(({ + type, + id + }) => { + history.push({ + postId: id, + postType: type, + canvas: 'edit' + }); + closeModal(); + }, [history]); + + // TODO: we need to handle properly `data={ data || EMPTY_ARRAY }` for when `isLoading`. + return (0,external_React_.createElement)(Page, { + title: (0,external_wp_i18n_namespaceObject.__)('Pages'), + actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "primary", + onClick: openModal + }, (0,external_wp_i18n_namespaceObject.__)('Add new page')), showAddPageModal && (0,external_React_.createElement)(AddNewPageModal, { + onSave: handleNewPage, + onClose: closeModal + })) + }, (0,external_React_.createElement)(DataViews, { + paginationInfo: paginationInfo, + fields: fields, + actions: actions, + data: pages || page_pages_EMPTY_ARRAY, + isLoading: isLoadingPages || isLoadingAuthors, + view: view, + onChangeView: onChangeView, + onSelectionChange: onSelectionChange, + supportedLayouts: SUPPORTED_LAYOUTS + })); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/duplicate-menu-item.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/header.js /** * WordPress dependencies */ +const header_header = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + d: "M18.5 10.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" +})); +/* harmony default export */ const library_header = (header_header); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/footer.js + +/** + * WordPress dependencies + */ + +const footer = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 24 24" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + fillRule: "evenodd", + d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" +})); +/* harmony default export */ const library_footer = (footer); + +;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/lock-small.js + +/** + * WordPress dependencies + */ + +const lockSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { + viewBox: "0 0 24 24", + xmlns: "http://www.w3.org/2000/svg" +}, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M15 11h-.2V9c0-1.5-1.2-2.8-2.8-2.8S9.2 7.5 9.2 9v2H9c-.6 0-1 .4-1 1v4c0 .6.4 1 1 1h6c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1zm-1.8 0h-2.5V9c0-.7.6-1.2 1.2-1.2s1.2.6 1.2 1.2v2z" +})); +/* harmony default export */ const lock_small = (lockSmall); + +;// CONCATENATED MODULE: external ["wp","reusableBlocks"] +const external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"]; +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/dataviews-pattern-actions.js + +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + + @@ -35815,58 +43399,308 @@ function rename_menu_item_RenameMenuItem({ const { - useHistory: duplicate_menu_item_useHistory + useHistory: dataviews_pattern_actions_useHistory } = unlock(external_wp_router_namespaceObject.privateApis); -function getPatternMeta(item) { - if (item.type === PATTERN_TYPES.theme) { - return { - wp_pattern_sync_status: PATTERN_SYNC_TYPES.unsynced +const { + CreatePatternModalContents, + useDuplicatePatternProps +} = unlock(external_wp_patterns_namespaceObject.privateApis); +const exportJSONaction = { + id: 'export-pattern', + label: (0,external_wp_i18n_namespaceObject.__)('Export as JSON'), + isEligible: item => item.type === PATTERN_TYPES.user, + callback: ([item]) => { + const json = { + __file: item.type, + title: item.title || item.name, + content: item.patternPost.content.raw, + syncStatus: item.patternPost.wp_pattern_sync_status }; + return (0,external_wp_blob_namespaceObject.downloadBlob)(`${paramCase(item.title || item.name)}.json`, JSON.stringify(json, null, 2), 'application/json'); } - const syncStatus = item.patternBlock.wp_pattern_sync_status; - const isUnsynced = syncStatus === PATTERN_SYNC_TYPES.unsynced; - return { - ...item.patternBlock.meta, - wp_pattern_sync_status: isUnsynced ? syncStatus : undefined - }; -} -function DuplicateMenuItem({ - categoryId, - item, - label = (0,external_wp_i18n_namespaceObject.__)('Duplicate'), - onClose -}) { - const { - saveEntityRecord, - invalidateResolution - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); - const { - createErrorNotice, - createSuccessNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); - const history = duplicate_menu_item_useHistory(); - const existingTemplateParts = useExistingTemplateParts(); - const { - patternCategories - } = usePatternCategories(); - async function createTemplatePart() { - try { - const copiedTitle = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing template part title */ - (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), item.title); - const title = getUniqueTemplatePartTitle(copiedTitle, existingTemplateParts); - const slug = getCleanTemplatePartSlug(title); - const { - area, - content - } = item.templatePart; - const result = await saveEntityRecord('postType', TEMPLATE_PART_POST_TYPE, { - slug, - title, - content, - area - }, { - throwOnError: true +}; +const renameAction = { + id: 'rename-pattern', + label: (0,external_wp_i18n_namespaceObject.__)('Rename'), + isEligible: item => { + const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; + const isUserPattern = item.type === PATTERN_TYPES.user; + const isCustomPattern = isUserPattern || isTemplatePart && item.isCustom; + const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file; + return isCustomPattern && !hasThemeFile; + }, + RenderModal: ({ + items, + closeModal + }) => { + const [item] = items; + const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => item.title); + const { + editEntityRecord, + saveEditedEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + const { + createSuccessNotice, + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + async function onRename(event) { + event.preventDefault(); + try { + await editEntityRecord('postType', item.type, item.id, { + title + }); + // Update state before saving rerenders the list. + setTitle(''); + closeModal(); + // Persist edited entity. + await saveEditedEntityRecord('postType', item.type, item.id, { + throwOnError: true + }); + createSuccessNotice(item.type === TEMPLATE_PART_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template part renamed.') : (0,external_wp_i18n_namespaceObject.__)('Pattern renamed.'), { + type: 'snackbar' + }); + } catch (error) { + const fallbackErrorMessage = item.type === TEMPLATE_PART_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template part.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the pattern.'); + const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; + createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } + } + return (0,external_React_.createElement)("form", { + onSubmit: onRename + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: "5" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { + __nextHasNoMarginBottom: true, + __next40pxDefaultSize: true, + label: (0,external_wp_i18n_namespaceObject.__)('Name'), + value: title, + onChange: setTitle, + required: true + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "right" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + __next40pxDefaultSize: true, + variant: "tertiary", + onClick: () => { + closeModal(); + } + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + __next40pxDefaultSize: true, + variant: "primary", + type: "submit" + }, (0,external_wp_i18n_namespaceObject.__)('Save'))))); + } +}; +const canDeleteOrReset = item => { + const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; + const isUserPattern = item.type === PATTERN_TYPES.user; + return isUserPattern || isTemplatePart && item.isCustom; +}; +const deleteAction = { + id: 'delete-pattern', + label: (0,external_wp_i18n_namespaceObject.__)('Delete'), + isEligible: item => { + const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; + const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file; + return canDeleteOrReset(item) && !hasThemeFile; + }, + hideModalHeader: true, + supportsBulk: true, + RenderModal: ({ + items, + closeModal, + onPerform + }) => { + const { + __experimentalDeleteReusableBlock + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_reusableBlocks_namespaceObject.store); + const { + createErrorNotice, + createSuccessNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const { + removeTemplates + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + const deletePattern = async () => { + const promiseResult = await Promise.allSettled(items.map(item => { + return __experimentalDeleteReusableBlock(item.id); + })); + // If all the promises were fulfilled with success. + if (promiseResult.every(({ + status + }) => status === 'fulfilled')) { + let successMessage; + if (promiseResult.length === 1) { + successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */ + (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), items[0].title); + } else { + successMessage = (0,external_wp_i18n_namespaceObject.__)('The patterns were deleted.'); + } + createSuccessNotice(successMessage, { + type: 'snackbar', + id: 'edit-site-page-trashed' + }); + } else { + // If there was at lease one failure. + let errorMessage; + // If we were trying to delete a single pattern. + if (promiseResult.length === 1) { + if (promiseResult[0].reason?.message) { + errorMessage = promiseResult[0].reason.message; + } else { + errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the pattern.'); + } + // If we were trying to delete multiple patterns. + } else { + const errorMessages = new Set(); + const failedPromises = promiseResult.filter(({ + status + }) => status === 'rejected'); + for (const failedPromise of failedPromises) { + if (failedPromise.reason?.message) { + errorMessages.add(failedPromise.reason.message); + } + } + if (errorMessages.size === 0) { + errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the patterns.'); + } else if (errorMessages.size === 1) { + errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ + (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the patterns: %s'), [...errorMessages][0]); + } else { + errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ + (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the patterns: %s'), [...errorMessages].join(',')); + } + createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } + } + }; + const deleteItem = () => { + if (items[0].type === TEMPLATE_PART_POST_TYPE) { + removeTemplates(items); + } else { + deletePattern(); + } + if (onPerform) { + onPerform(); + } + closeModal(); + }; + let questionMessage; + if (items.length === 1) { + questionMessage = (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %s: The page's title. + (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(items[0].title || items[0].name)); + } else if (items.length > 1 && items[0].type === TEMPLATE_PART_POST_TYPE) { + questionMessage = (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %d: The number of template parts (2 or more). + (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete %d template parts?'), items.length); + } else { + questionMessage = (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %d: The number of patterns (2 or more). + (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete %d patterns?'), items.length); + } + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: "5" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, questionMessage), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "right" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "tertiary", + onClick: closeModal + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "primary", + onClick: deleteItem + }, (0,external_wp_i18n_namespaceObject.__)('Delete')))); + } +}; +const resetAction = { + id: 'reset-action', + label: (0,external_wp_i18n_namespaceObject.__)('Clear customizations'), + isEligible: item => { + const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; + const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file; + return canDeleteOrReset(item) && hasThemeFile; + }, + hideModalHeader: true, + RenderModal: ({ + items, + closeModal + }) => { + const [item] = items; + const { + removeTemplate + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: "5" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to clear these customizations?')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "right" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "tertiary", + onClick: closeModal + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "primary", + onClick: () => removeTemplate(item) + }, (0,external_wp_i18n_namespaceObject.__)('Clear')))); + } +}; +const duplicatePatternAction = { + id: 'duplicate-pattern', + label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'), + isEligible: item => item.type !== TEMPLATE_PART_POST_TYPE, + modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate pattern', 'action label'), + RenderModal: ({ + items, + closeModal + }) => { + const [item] = items; + const { + categoryId = PATTERN_DEFAULT_CATEGORY + } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); + const isThemePattern = item.type === PATTERN_TYPES.theme; + const history = dataviews_pattern_actions_useHistory(); + function onPatternSuccess({ + pattern + }) { + history.push({ + categoryType: PATTERN_TYPES.theme, + categoryId, + postType: PATTERN_TYPES.user, + postId: pattern.id }); + closeModal(); + } + const duplicatedProps = useDuplicatePatternProps({ + pattern: isThemePattern ? item : item.patternPost, + onSuccess: onPatternSuccess + }); + return (0,external_React_.createElement)(CreatePatternModalContents, { + onClose: closeModal, + confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'), + ...duplicatedProps + }); + } +}; +const duplicateTemplatePartAction = { + id: 'duplicate-template-part', + label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'), + isEligible: item => item.type === TEMPLATE_PART_POST_TYPE, + modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate template part', 'action label'), + RenderModal: ({ + items, + closeModal + }) => { + const [item] = items; + const { + createSuccessNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const { + categoryId = PATTERN_DEFAULT_CATEGORY + } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); + const history = dataviews_pattern_actions_useHistory(); + async function onTemplatePartSuccess(templatePart) { createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: The new template part's title e.g. 'Call to action (copy)'. (0,external_wp_i18n_namespaceObject.__)('"%s" duplicated.'), item.title), { @@ -35875,99 +43709,280 @@ function DuplicateMenuItem({ }); history.push({ postType: TEMPLATE_PART_POST_TYPE, - postId: result?.id, + postId: templatePart?.id, categoryType: TEMPLATE_PART_POST_TYPE, categoryId }); - onClose(); - } catch (error) { - const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.'); - createErrorNotice(errorMessage, { - type: 'snackbar', - id: 'edit-site-patterns-error' - }); - onClose(); - } - } - async function findOrCreateTerm(term) { - try { - const newTerm = await saveEntityRecord('taxonomy', 'wp_pattern_category', { - name: term.label, - slug: term.name, - description: term.description - }, { - throwOnError: true - }); - invalidateResolution('getUserPatternCategories'); - return newTerm.id; - } catch (error) { - if (error.code !== 'term_exists') { - throw error; - } - return error.data.term_id; + closeModal(); } - } - async function getCategories(categories) { - const terms = categories.map(category => { - const fullCategory = patternCategories.find(cat => cat.name === category); - if (fullCategory.id) { - return fullCategory.id; - } - return findOrCreateTerm(fullCategory); + return (0,external_React_.createElement)(CreateTemplatePartModalContents, { + blocks: item.blocks, + defaultArea: item.templatePart.area, + defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing template part title */ + (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), item.title), + onCreate: onTemplatePartSuccess, + onError: closeModal, + confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label') }); - return Promise.all(terms); } - async function createPattern() { +}; + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/use-pattern-settings.js +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + + + +function usePatternSettings() { + var _storedSettings$__exp; + const storedSettings = (0,external_wp_data_namespaceObject.useSelect)(select => { + const { + getSettings + } = unlock(select(store_store)); + return getSettings(); + }, []); + const settingsBlockPatterns = (_storedSettings$__exp = storedSettings.__experimentalAdditionalBlockPatterns) !== null && _storedSettings$__exp !== void 0 ? _storedSettings$__exp : + // WP 6.0 + storedSettings.__experimentalBlockPatterns; // WP 5.9 + + const restBlockPatterns = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getBlockPatterns(), []); + const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || []), ...(restBlockPatterns || [])].filter(filterOutDuplicatesByName), [settingsBlockPatterns, restBlockPatterns]); + const settings = (0,external_wp_element_namespaceObject.useMemo)(() => { + const { + __experimentalAdditionalBlockPatterns, + ...restStoredSettings + } = storedSettings; + return { + ...restStoredSettings, + __experimentalBlockPatterns: blockPatterns, + __unstableIsPreviewMode: true + }; + }, [storedSettings, blockPatterns]); + return settings; +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/rename-category-menu-item.js + +/** + * WordPress dependencies + */ + + + + +/** + * Internal dependencies + */ + + +/** + * Internal dependencies + */ + +const { + RenamePatternCategoryModal +} = unlock(external_wp_patterns_namespaceObject.privateApis); +function RenameCategoryMenuItem({ + category, + onClose +}) { + const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + onClick: () => setIsModalOpen(true) + }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_React_.createElement)(rename_category_menu_item_RenameModal, { + category: category, + onClose: () => { + setIsModalOpen(false); + onClose(); + } + })); +} +function rename_category_menu_item_RenameModal({ + category, + onClose +}) { + // User created pattern categories have their properties updated when + // retrieved via `getUserPatternCategories`. The rename modal expects an + // object that will match the pattern category entity. + const normalizedCategory = { + id: category.id, + slug: category.slug, + name: category.label + }; + + // Optimization - only use pattern categories when the modal is open. + const existingCategories = usePatternCategories(); + return (0,external_React_.createElement)(RenamePatternCategoryModal, { + category: normalizedCategory, + existingCategories: existingCategories, + onClose: onClose, + overlayClassName: "edit-site-list__rename-modal" + }); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/delete-category-menu-item.js + +/** + * WordPress dependencies + */ + + + + + + + + + +/** + * Internal dependencies + */ + + +const { + useHistory: delete_category_menu_item_useHistory +} = unlock(external_wp_router_namespaceObject.privateApis); +function DeleteCategoryMenuItem({ + category, + onClose +}) { + const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); + const history = delete_category_menu_item_useHistory(); + const { + createSuccessNotice, + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + const { + deleteEntityRecord, + invalidateResolution + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + const onDelete = async () => { try { - const isThemePattern = item.type === PATTERN_TYPES.theme; - const title = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing pattern title */ - (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), item.title || item.name); - const categories = await getCategories(item.categories || []); - const result = await saveEntityRecord('postType', PATTERN_TYPES.user, { - content: isThemePattern ? item.content : item.patternBlock.content, - meta: getPatternMeta(item), - status: 'publish', - title, - wp_pattern_category: categories + await deleteEntityRecord('taxonomy', 'wp_pattern_category', category.id, { + force: true }, { throwOnError: true }); - createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %s: The new pattern's title e.g. 'Call to action (copy)'. - (0,external_wp_i18n_namespaceObject.__)('"%s" duplicated.'), item.title || item.name), { + + // Prevent the need to refresh the page to get up-to-date categories + // and pattern categorization. + invalidateResolution('getUserPatternCategories'); + invalidateResolution('getEntityRecords', ['postType', PATTERN_TYPES.user, { + per_page: -1 + }]); + createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The pattern category's name */ + (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), category.label), { type: 'snackbar', - id: 'edit-site-patterns-success' + id: 'pattern-category-delete' }); + onClose?.(); history.push({ + path: `/patterns`, categoryType: PATTERN_TYPES.theme, - categoryId, - postType: PATTERN_TYPES.user, - postId: result?.id + categoryId: PATTERN_DEFAULT_CATEGORY }); - onClose(); } catch (error) { - const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the pattern.'); + const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the pattern category.'); createErrorNotice(errorMessage, { type: 'snackbar', - id: 'edit-site-patterns-error' + id: 'pattern-category-delete' }); - onClose(); } - } - const createItem = item.type === TEMPLATE_PART_POST_TYPE ? createTemplatePart : createPattern; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: createItem - }, label); + }; + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { + isDestructive: true, + onClick: () => setIsModalOpen(true) + }, (0,external_wp_i18n_namespaceObject.__)('Delete')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { + isOpen: isModalOpen, + onConfirm: onDelete, + onCancel: () => setIsModalOpen(false), + confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Delete'), + className: "edit-site-patterns__delete-modal" + }, (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %s: The pattern category's name. + (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete the category "%s"? The patterns will not be deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(category.label)))); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/grid-item.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/header.js /** - * External dependencies + * WordPress dependencies + */ + + + + + + +/** + * Internal dependencies */ + +function PatternsHeader({ + categoryId, + type, + titleId, + descriptionId +}) { + const { + patternCategories + } = usePatternCategories(); + const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []); + let title, description, patternCategory; + if (type === TEMPLATE_PART_POST_TYPE) { + const templatePartArea = templatePartAreas.find(area => area.area === categoryId); + title = templatePartArea?.label; + description = templatePartArea?.description; + } else if (type === PATTERN_TYPES.theme) { + patternCategory = patternCategories.find(category => category.name === categoryId); + title = patternCategory?.label; + description = patternCategory?.description; + } + if (!title) return null; + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + className: "edit-site-patterns__section-header" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "space-between" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { + as: "h2", + level: 4, + id: titleId + }, title), !!patternCategory?.id && (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { + icon: more_vertical, + label: (0,external_wp_i18n_namespaceObject.__)('Actions'), + toggleProps: { + className: 'edit-site-patterns__button', + describedBy: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: pattern category name */ + (0,external_wp_i18n_namespaceObject.__)('Action menu for %s pattern category'), title) + } + }, ({ + onClose + }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(RenameCategoryMenuItem, { + category: patternCategory, + onClose: onClose + }), (0,external_React_.createElement)(DeleteCategoryMenuItem, { + category: patternCategory, + onClose: onClose + })))), description ? (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { + variant: "muted", + as: "p", + id: descriptionId + }, description) : null); +} + +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/index.js + /** * WordPress dependencies */ @@ -35990,101 +44005,72 @@ function DuplicateMenuItem({ -/** - * Downloads a file. - * Also used in packages/list-reusable-blocks/src/utils/file.js. - * - * @param {string} fileName File Name. - * @param {string} content File Content. - * @param {string} contentType File mime type. - */ -function grid_item_download(fileName, content, contentType) { - const file = new window.Blob([content], { - type: contentType - }); - const a = document.createElement('a'); - a.href = URL.createObjectURL(file); - a.download = fileName; - a.style.display = 'none'; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); -} + const { - useGlobalStyle: grid_item_useGlobalStyle + ExperimentalBlockEditorProvider: page_patterns_ExperimentalBlockEditorProvider, + useGlobalStyle: page_patterns_useGlobalStyle } = unlock(external_wp_blockEditor_namespaceObject.privateApis); const templatePartIcons = { header: library_header, footer: library_footer, uncategorized: symbol_filled }; -function GridItem({ - categoryId, +const page_patterns_EMPTY_ARRAY = []; +const defaultConfigPerViewType = { + [LAYOUT_GRID]: { + mediaField: 'preview', + primaryField: 'title' + } +}; +const DEFAULT_VIEW = { + type: LAYOUT_GRID, + search: '', + page: 1, + perPage: 20, + hiddenFields: ['sync-status'], + layout: { + ...defaultConfigPerViewType[LAYOUT_GRID] + }, + filters: [] +}; +const SYNC_FILTERS = [{ + value: PATTERN_SYNC_TYPES.full, + label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'Option that shows all synchronized patterns'), + description: (0,external_wp_i18n_namespaceObject.__)('Patterns that are kept in sync across the site.') +}, { + value: PATTERN_SYNC_TYPES.unsynced, + label: (0,external_wp_i18n_namespaceObject._x)('Not synced', 'Option that shows all patterns that are not synchronized'), + description: (0,external_wp_i18n_namespaceObject.__)('Patterns that can be changed freely without affecting the site.') +}]; +function PreviewWrapper({ item, - ...props + onClick, + ariaDescribedBy, + children +}) { + if (item.type === PATTERN_TYPES.theme) { + return children; + } + return (0,external_React_.createElement)("button", { + className: "page-patterns-preview-field__button", + type: "button", + onClick: onClick, + "aria-label": item.title, + "aria-describedby": ariaDescribedBy + }, children); +} +function Preview({ + item, + categoryId, + viewType }) { const descriptionId = (0,external_wp_element_namespaceObject.useId)(); - const [isDeleteDialogOpen, setIsDeleteDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false); - const [backgroundColor] = grid_item_useGlobalStyle('color.background'); - const { - removeTemplate - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); - const { - __experimentalDeleteReusableBlock - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_reusableBlocks_namespaceObject.store); - const { - createErrorNotice, - createSuccessNotice - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); const isUserPattern = item.type === PATTERN_TYPES.user; const isNonUserPattern = item.type === PATTERN_TYPES.theme; const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; - const { - onClick - } = useLink({ - postType: item.type, - postId: isUserPattern ? item.id : item.name, - categoryId, - categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme - }); const isEmpty = !item.blocks?.length; - const patternClassNames = classnames_default()('edit-site-patterns__pattern', { - 'is-placeholder': isEmpty - }); - const previewClassNames = classnames_default()('edit-site-patterns__preview', { - 'is-inactive': isNonUserPattern - }); - const deletePattern = async () => { - try { - await __experimentalDeleteReusableBlock(item.id); - createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %s: The pattern's title e.g. 'Call to action'. - (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), item.title), { - type: 'snackbar', - id: 'edit-site-patterns-success' - }); - } catch (error) { - const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the pattern.'); - createErrorNotice(errorMessage, { - type: 'snackbar', - id: 'edit-site-patterns-error' - }); - } - }; - const deleteItem = () => isTemplatePart ? removeTemplate(item) : deletePattern(); - const exportAsJSON = () => { - const json = { - __file: item.type, - title: item.title || item.name, - content: item.patternBlock.content.raw, - syncStatus: item.patternBlock.wp_pattern_sync_status - }; - return grid_item_download(`${paramCase(item.title || item.name)}.json`, JSON.stringify(json, null, 2), 'application/json'); - }; - // Only custom patterns or custom template parts can be renamed or deleted. const isCustomPattern = isUserPattern || isTemplatePart && item.isCustom; - const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file; const ariaDescriptions = []; if (isCustomPattern) { // User patterns don't have descriptions, but can be edited and deleted, so include some help text. @@ -36095,409 +44081,244 @@ function GridItem({ if (isNonUserPattern) { ariaDescriptions.push((0,external_wp_i18n_namespaceObject.__)('Theme & plugin patterns cannot be edited.')); } + const [backgroundColor] = page_patterns_useGlobalStyle('color.background'); + const { + onClick + } = useLink({ + postType: item.type, + postId: isUserPattern ? item.id : item.name, + categoryId, + categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme + }); + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { + className: `page-patterns-preview-field is-viewtype-${viewType}`, + style: { + backgroundColor + } + }, (0,external_React_.createElement)(PreviewWrapper, { + item: item, + onClick: onClick, + ariaDescribedBy: ariaDescriptions.length ? ariaDescriptions.map((_, index) => `${descriptionId}-${index}`).join(' ') : undefined + }, isEmpty && isTemplatePart && (0,external_wp_i18n_namespaceObject.__)('Empty template part'), isEmpty && !isTemplatePart && (0,external_wp_i18n_namespaceObject.__)('Empty pattern'), !isEmpty && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { + blocks: item.blocks + }))), ariaDescriptions.map((ariaDescription, index) => (0,external_React_.createElement)("div", { + key: index, + hidden: true, + id: `${descriptionId}-${index}` + }, ariaDescription))); +} +function Title({ + item, + categoryId +}) { + const isUserPattern = item.type === PATTERN_TYPES.user; + const isNonUserPattern = item.type === PATTERN_TYPES.theme; + const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; let itemIcon; + const { + onClick + } = useLink({ + postType: item.type, + postId: isUserPattern ? item.id : item.name, + categoryId, + categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme + }); if (!isUserPattern && templatePartIcons[categoryId]) { itemIcon = templatePartIcons[categoryId]; } else { itemIcon = item.syncStatus === PATTERN_SYNC_TYPES.full ? library_symbol : undefined; } - const confirmButtonText = hasThemeFile ? (0,external_wp_i18n_namespaceObject.__)('Clear') : (0,external_wp_i18n_namespaceObject.__)('Delete'); - const confirmPrompt = hasThemeFile ? (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to clear these customizations?') : (0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %s: The pattern or template part's title e.g. 'Call to action'. - (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s"?'), item.title || item.name); - const additionalStyles = !backgroundColor ? [{ - css: 'body { background: #fff; }' - }] : undefined; - return (0,external_wp_element_namespaceObject.createElement)("li", { - className: patternClassNames - }, (0,external_wp_element_namespaceObject.createElement)("button", { - className: previewClassNames - // Even though still incomplete, passing ids helps performance. - // @see https://reakit.io/docs/composite/#performance. - , - id: `edit-site-patterns-${item.name}`, - ...props, - onClick: item.type !== PATTERN_TYPES.theme ? onClick : undefined, - "aria-disabled": item.type !== PATTERN_TYPES.theme ? 'false' : 'true', - "aria-label": item.title, - "aria-describedby": ariaDescriptions.length ? ariaDescriptions.map((_, index) => `${descriptionId}-${index}`).join(' ') : undefined - }, isEmpty && isTemplatePart && (0,external_wp_i18n_namespaceObject.__)('Empty template part'), isEmpty && !isTemplatePart && (0,external_wp_i18n_namespaceObject.__)('Empty pattern'), !isEmpty && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { - blocks: item.blocks, - additionalStyles: additionalStyles - })), ariaDescriptions.map((ariaDescription, index) => (0,external_wp_element_namespaceObject.createElement)("div", { - key: index, - hidden: true, - id: `${descriptionId}-${index}` - }, ariaDescription)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - className: "edit-site-patterns__footer", - justify: "space-between" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { alignment: "center", + justify: "flex-start", + spacing: 2 + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { + as: "div", + gap: 0, justify: "left", - spacing: 3, className: "edit-site-patterns__pattern-title" - }, itemIcon && !isNonUserPattern && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, { - placement: "top", - text: (0,external_wp_i18n_namespaceObject.__)('Editing this pattern will also update anywhere it is used') - }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { - className: "edit-site-patterns__pattern-icon", - icon: itemIcon - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { - as: "span", - gap: 0, - justify: "left" - }, item.type === PATTERN_TYPES.theme ? item.title : (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { - level: 5 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + }, item.type === PATTERN_TYPES.theme ? item.title : (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "link", onClick: onClick // Required for the grid's roving tab index system. // See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243. , tabIndex: "-1" - }, item.title || item.name)), item.type === PATTERN_TYPES.theme && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Tooltip, { + }, item.title || item.name)), itemIcon && !isNonUserPattern && (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { + placement: "top", + text: (0,external_wp_i18n_namespaceObject.__)('Editing this pattern will also update anywhere it is used') + }, (0,external_React_.createElement)(build_module_icon, { + className: "edit-site-patterns__pattern-icon", + icon: itemIcon + })), item.type === PATTERN_TYPES.theme && (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { placement: "top", text: (0,external_wp_i18n_namespaceObject.__)('This pattern cannot be edited.') - }, (0,external_wp_element_namespaceObject.createElement)(build_module_icon, { + }, (0,external_React_.createElement)(build_module_icon, { className: "edit-site-patterns__pattern-lock-icon", icon: lock_small, size: 24 - })))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { - icon: more_vertical, - label: (0,external_wp_i18n_namespaceObject.__)('Actions'), - className: "edit-site-patterns__dropdown", - popoverProps: { - placement: 'bottom-end' - }, - toggleProps: { - className: 'edit-site-patterns__button', - describedBy: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: pattern name */ - (0,external_wp_i18n_namespaceObject.__)('Action menu for %s pattern'), item.title) - } - }, ({ - onClose - }) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, isCustomPattern && !hasThemeFile && (0,external_wp_element_namespaceObject.createElement)(rename_menu_item_RenameMenuItem, { - item: item, - onClose: onClose - }), (0,external_wp_element_namespaceObject.createElement)(DuplicateMenuItem, { - categoryId: categoryId, - item: item, - onClose: onClose, - label: (0,external_wp_i18n_namespaceObject.__)('Duplicate') - }), item.type === PATTERN_TYPES.user && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - onClick: () => exportAsJSON() - }, (0,external_wp_i18n_namespaceObject.__)('Export as JSON')), isCustomPattern && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { - isDestructive: !hasThemeFile, - onClick: () => setIsDeleteDialogOpen(true) - }, hasThemeFile ? (0,external_wp_i18n_namespaceObject.__)('Clear customizations') : (0,external_wp_i18n_namespaceObject.__)('Delete'))))), isDeleteDialogOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { - confirmButtonText: confirmButtonText, - onConfirm: deleteItem, - onCancel: () => setIsDeleteDialogOpen(false) - }, confirmPrompt)); -} -/* harmony default export */ var grid_item = ((0,external_wp_element_namespaceObject.memo)(GridItem)); - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/grid.js - -/** - * Internal dependencies - */ - -function Grid({ - categoryId, - items, - ...props -}) { - if (!items?.length) { - return null; - } - return (0,external_wp_element_namespaceObject.createElement)("ul", { - className: "edit-site-patterns__grid", - ...props - }, items.map(item => (0,external_wp_element_namespaceObject.createElement)(grid_item, { - key: item.name, - item: item, - categoryId: categoryId }))); } - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/no-patterns.js - -/** - * WordPress dependencies - */ - -function NoPatterns() { - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-patterns__no-results" - }, (0,external_wp_i18n_namespaceObject.__)('No patterns found.')); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/pagination.js - -/** - * WordPress dependencies - */ - - -function Pagination({ - currentPage, - numPages, - changePage, - totalItems -}) { - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - expanded: false, - spacing: 3, - justify: "flex-start", - className: "edit-site-patterns__grid-pagination" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - variant: "muted" - }, - // translators: %s: Total number of patterns. - (0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %s: Total number of patterns. - (0,external_wp_i18n_namespaceObject._n)('%s item', '%s items', totalItems), totalItems)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - expanded: false, - spacing: 1 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "tertiary", - onClick: () => changePage(1), - disabled: currentPage === 1, - "aria-label": (0,external_wp_i18n_namespaceObject.__)('First page') - }, "\xAB"), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "tertiary", - onClick: () => changePage(currentPage - 1), - disabled: currentPage === 1, - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Previous page') - }, "\u2039")), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - variant: "muted" - }, (0,external_wp_i18n_namespaceObject.sprintf)( - // translators: %1$s: Current page number, %2$s: Total number of pages. - (0,external_wp_i18n_namespaceObject._x)('%1$s of %2$s', 'paging'), currentPage, numPages)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { - expanded: false, - spacing: 1 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "tertiary", - onClick: () => changePage(currentPage + 1), - disabled: currentPage === numPages, - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Next page') - }, "\u203A"), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { - variant: "tertiary", - onClick: () => changePage(numPages), - disabled: currentPage === numPages, - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Last page') - }, "\xBB"))); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/patterns-list.js - -/** - * WordPress dependencies - */ - - - - - - - -/** - * Internal dependencies - */ - - - - - - - - - -const { - useLocation: patterns_list_useLocation, - useHistory: patterns_list_useHistory -} = unlock(external_wp_router_namespaceObject.privateApis); -const SYNC_FILTERS = { - all: (0,external_wp_i18n_namespaceObject._x)('All', 'Option that shows all patterns'), - [PATTERN_SYNC_TYPES.full]: (0,external_wp_i18n_namespaceObject._x)('Synced', 'Option that shows all synchronized patterns'), - [PATTERN_SYNC_TYPES.unsynced]: (0,external_wp_i18n_namespaceObject._x)('Not synced', 'Option that shows all patterns that are not synchronized') -}; -const SYNC_DESCRIPTIONS = { - all: '', - [PATTERN_SYNC_TYPES.full]: (0,external_wp_i18n_namespaceObject.__)('Patterns that are kept in sync across the site.'), - [PATTERN_SYNC_TYPES.unsynced]: (0,external_wp_i18n_namespaceObject.__)('Patterns that can be changed freely without affecting the site.') -}; -const PAGE_SIZE = 20; -function PatternsList({ - categoryId, - type -}) { - const location = patterns_list_useLocation(); - const history = patterns_list_useHistory(); - const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); - const [filterValue, setFilterValue, delayedFilterValue] = useDebouncedInput(''); - const deferredFilterValue = (0,external_wp_element_namespaceObject.useDeferredValue)(delayedFilterValue); - const [syncFilter, setSyncFilter] = (0,external_wp_element_namespaceObject.useState)('all'); - const [currentPage, setCurrentPage] = (0,external_wp_element_namespaceObject.useState)(1); - const deferredSyncedFilter = (0,external_wp_element_namespaceObject.useDeferredValue)(syncFilter); +function DataviewsPatterns() { + const { + categoryType, + categoryId = PATTERN_DEFAULT_CATEGORY + } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); + const type = categoryType || PATTERN_TYPES.theme; + const [view, setView] = (0,external_wp_element_namespaceObject.useState)(DEFAULT_VIEW); const isUncategorizedThemePatterns = type === PATTERN_TYPES.theme && categoryId === 'uncategorized'; + const previousCategoryId = (0,external_wp_compose_namespaceObject.usePrevious)(categoryId); + const viewSyncStatus = view.filters?.find(({ + field + }) => field === 'sync-status')?.value; const { patterns, isResolving } = use_patterns(type, isUncategorizedThemePatterns ? '' : categoryId, { - search: deferredFilterValue, - syncStatus: deferredSyncedFilter === 'all' ? undefined : deferredSyncedFilter + search: view.search, + syncStatus: viewSyncStatus }); - const updateSearchFilter = value => { - setCurrentPage(1); - setFilterValue(value); - }; - const updateSyncFilter = value => { - setCurrentPage(1); - setSyncFilter(value); - }; + const fields = (0,external_wp_element_namespaceObject.useMemo)(() => { + const _fields = [{ + header: (0,external_wp_i18n_namespaceObject.__)('Preview'), + id: 'preview', + render: ({ + item + }) => (0,external_React_.createElement)(Preview, { + item: item, + categoryId: categoryId, + viewType: view.type + }), + enableSorting: false, + enableHiding: false + }, { + header: (0,external_wp_i18n_namespaceObject.__)('Title'), + id: 'title', + getValue: ({ + item + }) => item.title, + render: ({ + item + }) => (0,external_React_.createElement)(Title, { + item: item, + categoryId: categoryId + }), + enableHiding: false + }]; + if (type === PATTERN_TYPES.theme) { + _fields.push({ + header: (0,external_wp_i18n_namespaceObject.__)('Sync Status'), + id: 'sync-status', + render: ({ + item + }) => { + // User patterns can have their sync statuses checked directly. + // Non-user patterns are all unsynced for the time being. + return SYNC_FILTERS.find(({ + value + }) => value === item.syncStatus)?.label || SYNC_FILTERS.find(({ + value + }) => value === PATTERN_SYNC_TYPES.unsynced).label; + }, + type: ENUMERATION_TYPE, + elements: SYNC_FILTERS, + filterBy: { + operators: [OPERATOR_IN], + isPrimary: true + }, + enableSorting: false + }); + } + return _fields; + }, [view.type, categoryId, type]); + // Reset the page number when the category changes. + (0,external_wp_element_namespaceObject.useEffect)(() => { + if (previousCategoryId !== categoryId) { + setView(DEFAULT_VIEW); + } + }, [categoryId, previousCategoryId]); + const { + data, + paginationInfo + } = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!patterns) { + return { + data: page_patterns_EMPTY_ARRAY, + paginationInfo: { + totalItems: 0, + totalPages: 0 + } + }; + } + let filteredData = [...patterns]; + // Handle sorting. + if (view.sort) { + filteredData = sortByTextFields({ + data: filteredData, + view, + fields, + textFields: ['title', 'author'] + }); + } + // Handle pagination. + return getPaginationResults({ + data: filteredData, + view + }); + }, [patterns, view, fields]); + const actions = (0,external_wp_element_namespaceObject.useMemo)(() => [renameAction, duplicatePatternAction, duplicateTemplatePartAction, exportJSONaction, resetAction, deleteAction], []); + const onChangeView = (0,external_wp_element_namespaceObject.useCallback)(newView => { + if (newView.type !== view.type) { + newView = { + ...newView, + layout: { + ...defaultConfigPerViewType[newView.type] + } + }; + } + setView(newView); + }, [view.type, setView]); const id = (0,external_wp_element_namespaceObject.useId)(); - const titleId = `${id}-title`; - const descriptionId = `${id}-description`; - const hasPatterns = patterns.length; - const title = SYNC_FILTERS[syncFilter]; - const description = SYNC_DESCRIPTIONS[syncFilter]; - const totalItems = patterns.length; - const pageIndex = currentPage - 1; - const numPages = Math.ceil(patterns.length / PAGE_SIZE); - const list = (0,external_wp_element_namespaceObject.useMemo)(() => { - return patterns.slice(pageIndex * PAGE_SIZE, pageIndex * PAGE_SIZE + PAGE_SIZE); - }, [pageIndex, patterns]); - const asyncList = (0,external_wp_compose_namespaceObject.useAsyncList)(list, { - step: 10 - }); - const changePage = page => { - const scrollContainer = document.querySelector('.edit-site-patterns'); - scrollContainer?.scrollTo(0, 0); - setCurrentPage(page); - }; - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { - className: "edit-site-patterns__header", - spacing: 6 - }, (0,external_wp_element_namespaceObject.createElement)(PatternsHeader, { + const settings = usePatternSettings(); + // Wrap everything in a block editor provider. + // This ensures 'styles' that are needed for the previews are synced + // from the site editor store to the block editor store. + // TODO: check if I add the provider in every preview like in templates... + return (0,external_React_.createElement)(page_patterns_ExperimentalBlockEditorProvider, { + settings: settings + }, (0,external_React_.createElement)(Page, { + title: (0,external_wp_i18n_namespaceObject.__)('Patterns content'), + className: "edit-site-page-patterns-dataviews", + hideTitleFromUI: true + }, (0,external_React_.createElement)(PatternsHeader, { categoryId: categoryId, type: type, - titleId: titleId, - descriptionId: descriptionId - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { - alignment: "stretch", - wrap: true - }, isMobileViewport && (0,external_wp_element_namespaceObject.createElement)(SidebarButton, { - icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left, - label: (0,external_wp_i18n_namespaceObject.__)('Back'), - onClick: () => { - // Go back in history if we came from the Patterns page. - // Otherwise push a stack onto the history. - if (location.state?.backPath === '/patterns') { - history.back(); - } else { - history.push({ - path: '/patterns' - }); - } - } - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexBlock, { - className: "edit-site-patterns__search-block" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SearchControl, { - className: "edit-site-patterns__search", - onChange: value => updateSearchFilter(value), - placeholder: (0,external_wp_i18n_namespaceObject.__)('Search patterns'), - label: (0,external_wp_i18n_namespaceObject.__)('Search patterns'), - value: filterValue, - __nextHasNoMarginBottom: true - })), type === PATTERN_TYPES.theme && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, { - className: "edit-site-patterns__sync-status-filter", - hideLabelFromVision: true, - label: (0,external_wp_i18n_namespaceObject.__)('Filter by sync status'), - value: syncFilter, - isBlock: true, - onChange: value => updateSyncFilter(value), - __nextHasNoMarginBottom: true - }, Object.entries(SYNC_FILTERS).map(([key, label]) => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { - className: "edit-site-patterns__sync-status-filter-option", - key: key, - value: key, - label: label - }))))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { - className: "edit-site-patterns__section", - justify: "flex-start", - spacing: 6 - }, syncFilter !== 'all' && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { - className: "edit-site-patterns__section-header" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { - as: "h3", - level: 5, - id: titleId - }, title), description ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - variant: "muted", - as: "p", - id: descriptionId - }, description) : null), hasPatterns && (0,external_wp_element_namespaceObject.createElement)(Grid, { - categoryId: categoryId, - items: asyncList, - "aria-labelledby": titleId, - "aria-describedby": descriptionId - }), !isResolving && !hasPatterns && (0,external_wp_element_namespaceObject.createElement)(NoPatterns, null)), numPages > 1 && (0,external_wp_element_namespaceObject.createElement)(Pagination, { - currentPage: currentPage, - numPages: numPages, - changePage: changePage, - totalItems: totalItems - })); + titleId: `${id}-title`, + descriptionId: `${id}-description` + }), (0,external_React_.createElement)(DataViews, { + paginationInfo: paginationInfo, + fields: fields, + actions: actions, + data: data || page_patterns_EMPTY_ARRAY, + getItemId: item => item.name, + isLoading: isResolving, + view: view, + onChangeView: onChangeView, + deferredRendering: true, + supportedLayouts: [LAYOUT_GRID] + }))); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/use-pattern-settings.js -/** - * WordPress dependencies - */ - - - +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-templates-template-parts/actions.js /** - * Internal dependencies + * WordPress dependencies */ -function usePatternSettings() { - var _storedSettings$__exp; - const storedSettings = (0,external_wp_data_namespaceObject.useSelect)(select => { - const { - getSettings - } = unlock(select(store_store)); - return getSettings(); - }, []); - const settingsBlockPatterns = (_storedSettings$__exp = storedSettings.__experimentalAdditionalBlockPatterns) !== null && _storedSettings$__exp !== void 0 ? _storedSettings$__exp : - // WP 6.0 - storedSettings.__experimentalBlockPatterns; // WP 5.9 - - const restBlockPatterns = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getBlockPatterns(), []); - const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || []), ...(restBlockPatterns || [])].filter(filterOutDuplicatesByName), [settingsBlockPatterns, restBlockPatterns]); - const settings = (0,external_wp_element_namespaceObject.useMemo)(() => { - const { - __experimentalAdditionalBlockPatterns, - ...restStoredSettings - } = storedSettings; - return { - ...restStoredSettings, - __experimentalBlockPatterns: blockPatterns, - __unstableIsPreviewMode: true - }; - }, [storedSettings, blockPatterns]); - return settings; -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/index.js -/** - * WordPress dependencies - */ @@ -36510,59 +44331,171 @@ function usePatternSettings() { -const { - ExperimentalBlockEditorProvider: page_patterns_ExperimentalBlockEditorProvider -} = unlock(external_wp_blockEditor_namespaceObject.privateApis); -function PagePatterns() { +function useResetTemplateAction() { const { - categoryType, - categoryId - } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); - const type = categoryType || PATTERN_TYPES.theme; - const category = categoryId || PATTERN_DEFAULT_CATEGORY; - const settings = usePatternSettings(); - - // Wrap everything in a block editor provider. - // This ensures 'styles' that are needed for the previews are synced - // from the site editor store to the block editor store. - return (0,external_wp_element_namespaceObject.createElement)(page_patterns_ExperimentalBlockEditorProvider, { - settings: settings - }, (0,external_wp_element_namespaceObject.createElement)(Page, { - className: "edit-site-patterns", - title: (0,external_wp_i18n_namespaceObject.__)('Patterns content'), - hideTitleFromUI: true - }, (0,external_wp_element_namespaceObject.createElement)(PatternsList - // Reset the states when switching between categories and types. - , { - key: `${type}-${category}`, - type: type, - categoryId: category - }))); -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/table/index.js - -function Table({ - data, - columns -}) { - return (0,external_wp_element_namespaceObject.createElement)("div", { - className: "edit-site-table-wrapper" - }, (0,external_wp_element_namespaceObject.createElement)("table", { - className: "edit-site-table" - }, (0,external_wp_element_namespaceObject.createElement)("thead", null, (0,external_wp_element_namespaceObject.createElement)("tr", null, columns.map(column => (0,external_wp_element_namespaceObject.createElement)("th", { - key: column.header - }, column.header)))), (0,external_wp_element_namespaceObject.createElement)("tbody", null, data.map((row, rowIndex) => (0,external_wp_element_namespaceObject.createElement)("tr", { - key: rowIndex - }, columns.map((column, columnIndex) => (0,external_wp_element_namespaceObject.createElement)("td", { - style: { - maxWidth: column.maxWidth ? column.maxWidth : undefined - }, - key: columnIndex - }, column.cell(row)))))))); -} + revertTemplate + } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); + const { + saveEditedEntityRecord + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + const { + createSuccessNotice, + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + return (0,external_wp_element_namespaceObject.useMemo)(() => ({ + id: 'reset-template', + label: (0,external_wp_i18n_namespaceObject.__)('Reset'), + isPrimary: true, + icon: library_backup, + isEligible: isTemplateRevertable, + supportsBulk: true, + async callback(templates) { + try { + for (const template of templates) { + await revertTemplate(template, { + allowUndo: false + }); + await saveEditedEntityRecord('postType', template.type, template.id); + } + createSuccessNotice(templates.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */ + (0,external_wp_i18n_namespaceObject.__)('%s items reverted.'), templates.length) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */ + (0,external_wp_i18n_namespaceObject.__)('"%s" reverted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(templates[0].title.rendered)), { + type: 'snackbar', + id: 'edit-site-template-reverted' + }); + } catch (error) { + let fallbackErrorMessage; + if (templates[0].type === constants_TEMPLATE_POST_TYPE) { + fallbackErrorMessage = templates.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the templates.'); + } else { + fallbackErrorMessage = templates.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template parts.'); + } + const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; + createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } + } + }), [createErrorNotice, createSuccessNotice, revertTemplate, saveEditedEntityRecord]); +} +const deleteTemplateAction = { + id: 'delete-template', + label: (0,external_wp_i18n_namespaceObject.__)('Delete'), + isPrimary: true, + icon: library_trash, + isEligible: isTemplateRemovable, + supportsBulk: true, + hideModalHeader: true, + RenderModal: ({ + items: templates, + closeModal, + onPerform + }) => { + const { + removeTemplates + } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: "5" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, templates.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %d: number of items to delete. + (0,external_wp_i18n_namespaceObject._n)('Delete %d item?', 'Delete %d items?', templates.length), templates.length) : (0,external_wp_i18n_namespaceObject.sprintf)( + // translators: %s: The template or template part's titles + (0,external_wp_i18n_namespaceObject.__)('Delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(templates?.[0]?.title?.rendered))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "right" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "tertiary", + onClick: closeModal + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "primary", + onClick: async () => { + await removeTemplates(templates, { + allowUndo: false + }); + if (onPerform) { + onPerform(); + } + closeModal(); + } + }, (0,external_wp_i18n_namespaceObject.__)('Delete')))); + } +}; +const renameTemplateAction = { + id: 'rename-template', + label: (0,external_wp_i18n_namespaceObject.__)('Rename'), + isEligible: template => { + // We can only remove templates or template parts that can be removed. + // Additionally in the case of templates, we can only remove custom templates. + if (!isTemplateRemovable(template) || template.type === constants_TEMPLATE_POST_TYPE && !template.is_custom) { + return false; + } + return true; + }, + RenderModal: ({ + items: templates, + closeModal + }) => { + const template = templates[0]; + const title = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered); + const [editedTitle, setEditedTitle] = (0,external_wp_element_namespaceObject.useState)(title); + const { + editEntityRecord, + __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); + const { + createSuccessNotice, + createErrorNotice + } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); + async function onTemplateRename(event) { + event.preventDefault(); + try { + await editEntityRecord('postType', template.type, template.id, { + title: editedTitle + }); + // Update state before saving rerenders the list. + setEditedTitle(''); + closeModal(); + // Persist edited entity. + await saveSpecifiedEntityEdits('postType', template.type, template.id, ['title'], + // Only save title to avoid persisting other edits. + { + throwOnError: true + }); + // TODO: this action will be reused in template parts list, so + // let's keep this for a bit, even it's always a `template` now. + createSuccessNotice(template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template renamed.') : (0,external_wp_i18n_namespaceObject.__)('Template part renamed.'), { + type: 'snackbar' + }); + } catch (error) { + const fallbackErrorMessage = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template part.'); + const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; + createErrorNotice(errorMessage, { + type: 'snackbar' + }); + } + } + return (0,external_React_.createElement)("form", { + onSubmit: onTemplateRename + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { + spacing: "5" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { + __nextHasNoMarginBottom: true, + label: (0,external_wp_i18n_namespaceObject.__)('Name'), + value: editedTitle, + onChange: setEditedTitle, + required: true + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + justify: "right" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "tertiary", + onClick: closeModal + }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { + variant: "primary", + type: "submit" + }, (0,external_wp_i18n_namespaceObject.__)('Save'))))); + } +}; -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-template-parts/add-new-template-part.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-templates-template-parts/add-new-template-part.js /** * WordPress dependencies @@ -36601,10 +44534,10 @@ function AddNewTemplatePart() { if (!canCreate || !postType) { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { variant: "primary", onClick: () => setIsModalOpen(true) - }, postType.labels.add_new_item), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(CreateTemplatePartModal, { + }, postType.labels.add_new_item), isModalOpen && (0,external_React_.createElement)(CreateTemplatePartModal, { closeModal: () => setIsModalOpen(false), blocks: [], onCreate: templatePart => { @@ -36619,19 +44552,15 @@ function AddNewTemplatePart() { })); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-template-parts/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-templates-template-parts/index.js /** - * WordPress dependencies + * External dependencies */ - - - - /** - * Internal dependencies + * WordPress dependencies */ @@ -36641,128 +44570,379 @@ function AddNewTemplatePart() { -const { - useLocation: page_template_parts_useLocation -} = unlock(external_wp_router_namespaceObject.privateApis); -function PageTemplateParts() { - const { - params: { - didAccessPatternsPage - } - } = page_template_parts_useLocation(); - const { - records: templateParts - } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', TEMPLATE_PART_POST_TYPE, { - per_page: -1 - }); - const columns = [{ - header: (0,external_wp_i18n_namespaceObject.__)('Template Part'), - cell: templatePart => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { - as: "h3", - level: 5 - }, (0,external_wp_element_namespaceObject.createElement)(Link, { - params: { - postId: templatePart.id, - postType: templatePart.type, - didAccessPatternsPage: !!didAccessPatternsPage ? 1 : undefined - }, - state: { - backPath: '/wp_template_part/all' - } - }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(templatePart.title?.rendered || templatePart.slug)))), - maxWidth: 400 - }, { - header: (0,external_wp_i18n_namespaceObject.__)('Added by'), - cell: templatePart => (0,external_wp_element_namespaceObject.createElement)(AddedBy, { - postType: templatePart.type, - postId: templatePart.id - }) - }, { - header: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Actions')), - cell: templatePart => (0,external_wp_element_namespaceObject.createElement)(TemplateActions, { - postType: templatePart.type, - postId: templatePart.id - }) - }]; - return (0,external_wp_element_namespaceObject.createElement)(Page, { - title: (0,external_wp_i18n_namespaceObject.__)('Template Parts'), - actions: (0,external_wp_element_namespaceObject.createElement)(AddNewTemplatePart, null) - }, templateParts && (0,external_wp_element_namespaceObject.createElement)(Table, { - data: templateParts, - columns: columns - })); -} -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-templates/index.js /** - * WordPress dependencies + * Internal dependencies */ -/** - * Internal dependencies - */ - - -function PageTemplates() { +const { + ExperimentalBlockEditorProvider: page_templates_template_parts_ExperimentalBlockEditorProvider, + useGlobalStyle: page_templates_template_parts_useGlobalStyle +} = unlock(external_wp_blockEditor_namespaceObject.privateApis); +const { + useHistory: page_templates_template_parts_useHistory, + useLocation: page_templates_template_parts_useLocation +} = unlock(external_wp_router_namespaceObject.privateApis); +const page_templates_template_parts_EMPTY_ARRAY = []; +const page_templates_template_parts_SUPPORTED_LAYOUTS = window?.__experimentalAdminViews ? [LAYOUT_TABLE, LAYOUT_GRID, LAYOUT_LIST] : [LAYOUT_TABLE, LAYOUT_GRID]; +const page_templates_template_parts_defaultConfigPerViewType = { + [LAYOUT_TABLE]: { + primaryField: 'title' + }, + [LAYOUT_GRID]: { + mediaField: 'preview', + primaryField: 'title' + }, + [LAYOUT_LIST]: { + primaryField: 'title', + mediaField: 'preview' + } +}; +const page_templates_template_parts_DEFAULT_VIEW = { + type: LAYOUT_TABLE, + search: '', + page: 1, + perPage: 20, + sort: { + field: 'title', + direction: 'asc' + }, + // All fields are visible by default, so it's + // better to keep track of the hidden ones. + hiddenFields: ['preview'], + layout: page_templates_template_parts_defaultConfigPerViewType[LAYOUT_TABLE], + filters: [] +}; +function page_templates_template_parts_normalizeSearchInput(input = '') { + return remove_accents_default()(input.trim().toLowerCase()); +} +function page_templates_template_parts_Title({ + item, + viewType +}) { + if (viewType === LAYOUT_LIST) { + return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered) || (0,external_wp_i18n_namespaceObject.__)('(no title)'); + } + const linkProps = { + params: { + postId: item.id, + postType: item.type, + canvas: 'edit' + } + }; + if (item.type === TEMPLATE_PART_POST_TYPE) { + linkProps.state = { + backPath: '/wp_template_part/all' + }; + } + return (0,external_React_.createElement)(Link, { + ...linkProps + }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered) || (0,external_wp_i18n_namespaceObject.__)('(no title)')); +} +function AuthorField({ + item, + viewType +}) { + const { + text, + icon, + imageUrl + } = useAddedBy(item.type, item.id); + const withIcon = viewType !== LAYOUT_LIST; + return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { + alignment: "left", + spacing: 1 + }, withIcon && imageUrl && (0,external_React_.createElement)(AvatarImage, { + imageUrl: imageUrl + }), withIcon && !imageUrl && (0,external_React_.createElement)("div", { + className: "edit-site-list-added-by__icon" + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { + icon: icon + })), (0,external_React_.createElement)("span", null, text)); +} +function page_templates_template_parts_Preview({ + item, + viewType +}) { + const settings = usePatternSettings(); + const [backgroundColor = 'white'] = page_templates_template_parts_useGlobalStyle('color.background'); + const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => { + return (0,external_wp_blocks_namespaceObject.parse)(item.content.raw); + }, [item.content.raw]); const { - records: templates - } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', TEMPLATE_POST_TYPE, { + onClick + } = useLink({ + postId: item.id, + postType: item.type, + canvas: 'edit' + }); + const isEmpty = !blocks?.length; + // Wrap everything in a block editor provider to ensure 'styles' that are needed + // for the previews are synced between the site editor store and the block editor store. + // Additionally we need to have the `__experimentalBlockPatterns` setting in order to + // render patterns inside the previews. + // TODO: Same approach is used in the patterns list and it becomes obvious that some of + // the block editor settings are needed in context where we don't have the block editor. + // Explore how we can solve this in a better way. + return (0,external_React_.createElement)(page_templates_template_parts_ExperimentalBlockEditorProvider, { + settings: settings + }, (0,external_React_.createElement)("div", { + className: `page-templates-preview-field is-viewtype-${viewType}`, + style: { + backgroundColor + } + }, viewType === LAYOUT_LIST && !isEmpty && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { + blocks: blocks + }), viewType !== LAYOUT_LIST && (0,external_React_.createElement)("button", { + className: "page-templates-preview-field__button", + type: "button", + onClick: onClick, + "aria-label": item.title?.rendered || item.title + }, isEmpty && (item.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Empty template') : (0,external_wp_i18n_namespaceObject.__)('Empty template part')), !isEmpty && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { + blocks: blocks + })))); +} +function PageTemplatesTemplateParts({ + postType +}) { + const { + params + } = page_templates_template_parts_useLocation(); + const { + activeView = 'all', + layout + } = params; + const defaultView = (0,external_wp_element_namespaceObject.useMemo)(() => { + const usedType = window?.__experimentalAdminViews ? layout !== null && layout !== void 0 ? layout : page_templates_template_parts_DEFAULT_VIEW.type : page_templates_template_parts_DEFAULT_VIEW.type; + return { + ...page_templates_template_parts_DEFAULT_VIEW, + type: usedType, + layout: page_templates_template_parts_defaultConfigPerViewType[usedType], + filters: activeView !== 'all' ? [{ + field: 'author', + operator: 'in', + value: activeView + }] : [] + }; + }, [layout, activeView]); + const [view, setView] = (0,external_wp_element_namespaceObject.useState)(defaultView); + (0,external_wp_element_namespaceObject.useEffect)(() => { + setView(currentView => ({ + ...currentView, + filters: activeView !== 'all' ? [{ + field: 'author', + operator: 'in', + value: activeView + }] : [] + })); + }, [activeView]); + const { + records, + isResolving: isLoadingData + } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', postType, { per_page: -1 }); - const columns = [{ - header: (0,external_wp_i18n_namespaceObject.__)('Template'), - cell: template => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalVStack, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { - as: "h3", - level: 5 - }, (0,external_wp_element_namespaceObject.createElement)(Link, { - params: { - postId: template.id, - postType: template.type, - canvas: 'edit' - } - }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title?.rendered || template.slug))), template.description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { - variant: "muted" - }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.description))), - maxWidth: 400 - }, { - header: (0,external_wp_i18n_namespaceObject.__)('Added by'), - cell: template => (0,external_wp_element_namespaceObject.createElement)(AddedBy, { - postType: template.type, - postId: template.id - }) - }, { - header: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Actions')), - cell: template => (0,external_wp_element_namespaceObject.createElement)(TemplateActions, { - postType: template.type, - postId: template.id - }) - }]; - return (0,external_wp_element_namespaceObject.createElement)(Page, { - title: (0,external_wp_i18n_namespaceObject.__)('Templates'), - actions: (0,external_wp_element_namespaceObject.createElement)(AddNewTemplate, { - templateType: TEMPLATE_POST_TYPE, + const history = page_templates_template_parts_useHistory(); + const onSelectionChange = (0,external_wp_element_namespaceObject.useCallback)(items => { + if (view?.type === LAYOUT_LIST) { + history.push({ + ...params, + postId: items.length === 1 ? items[0].id : undefined + }); + } + }, [history, params, view?.type]); + const authors = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!records) { + return page_templates_template_parts_EMPTY_ARRAY; + } + const authorsSet = new Set(); + records.forEach(template => { + authorsSet.add(template.author_text); + }); + return Array.from(authorsSet).map(author => ({ + value: author, + label: author + })); + }, [records]); + const fields = (0,external_wp_element_namespaceObject.useMemo)(() => { + const _fields = [{ + header: (0,external_wp_i18n_namespaceObject.__)('Preview'), + id: 'preview', + render: ({ + item + }) => { + return (0,external_React_.createElement)(page_templates_template_parts_Preview, { + item: item, + viewType: view.type + }); + }, + minWidth: 120, + maxWidth: 120, + enableSorting: false + }, { + header: postType === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template') : (0,external_wp_i18n_namespaceObject.__)('Template Part'), + id: 'title', + getValue: ({ + item + }) => item.title?.rendered, + render: ({ + item + }) => (0,external_React_.createElement)(page_templates_template_parts_Title, { + item: item, + viewType: view.type + }), + maxWidth: 400, + enableHiding: false + }]; + if (postType === constants_TEMPLATE_POST_TYPE) { + _fields.push({ + header: (0,external_wp_i18n_namespaceObject.__)('Description'), + id: 'description', + getValue: ({ + item + }) => item.description, + render: ({ + item + }) => { + return item.description ? (0,external_React_.createElement)("span", { + className: "page-templates-description" + }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.description)) : view.type === LAYOUT_TABLE && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { + variant: "muted", + "aria-hidden": "true" + }, "\u2014"), (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('No description.'))); + }, + maxWidth: 400, + minWidth: 320, + enableSorting: false + }); + } + // TODO: The plan is to support fields reordering, which would require an API like `order` or something + // similar. With the aforementioned API we wouldn't need to construct the fields array like this. + _fields.push({ + header: (0,external_wp_i18n_namespaceObject.__)('Author'), + id: 'author', + getValue: ({ + item + }) => item.author_text, + render: ({ + item + }) => { + return (0,external_React_.createElement)(AuthorField, { + viewType: view.type, + item: item + }); + }, + type: ENUMERATION_TYPE, + elements: authors, + width: '1%' + }); + return _fields; + }, [postType, authors, view.type]); + const { + data, + paginationInfo + } = (0,external_wp_element_namespaceObject.useMemo)(() => { + if (!records) { + return { + data: page_templates_template_parts_EMPTY_ARRAY, + paginationInfo: { + totalItems: 0, + totalPages: 0 + } + }; + } + let filteredData = [...records]; + // Handle global search. + if (view.search) { + const normalizedSearch = page_templates_template_parts_normalizeSearchInput(view.search); + filteredData = filteredData.filter(item => { + const title = item.title?.rendered || item.slug; + return page_templates_template_parts_normalizeSearchInput(title).includes(normalizedSearch) || page_templates_template_parts_normalizeSearchInput(item.description).includes(normalizedSearch); + }); + } + + // Handle filters. + if (view.filters.length > 0) { + view.filters.forEach(filter => { + if (filter.field === 'author' && filter.operator === OPERATOR_IN && !!filter.value) { + filteredData = filteredData.filter(item => { + return item.author_text === filter.value; + }); + } else if (filter.field === 'author' && filter.operator === OPERATOR_NOT_IN && !!filter.value) { + filteredData = filteredData.filter(item => { + return item.author_text !== filter.value; + }); + } + }); + } + + // Handle sorting. + if (view.sort) { + filteredData = sortByTextFields({ + data: filteredData, + view, + fields, + textFields: ['title', 'author'] + }); + } + // Handle pagination. + return getPaginationResults({ + data: filteredData, + view + }); + }, [records, view, fields]); + const resetTemplateAction = useResetTemplateAction(); + const actions = (0,external_wp_element_namespaceObject.useMemo)(() => [resetTemplateAction, deleteTemplateAction, renameTemplateAction, postRevisionsAction], [resetTemplateAction]); + const onChangeView = (0,external_wp_element_namespaceObject.useCallback)(newView => { + if (newView.type !== view.type) { + newView = { + ...newView, + layout: { + ...page_templates_template_parts_defaultConfigPerViewType[newView.type] + } + }; + history.push({ + ...params, + layout: newView.type + }); + } + setView(newView); + }, [view.type, setView, history, params]); + return (0,external_React_.createElement)(Page, { + className: "edit-site-page-template-template-parts-dataviews", + title: postType === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Templates') : (0,external_wp_i18n_namespaceObject.__)('Template Parts'), + actions: postType === constants_TEMPLATE_POST_TYPE ? (0,external_React_.createElement)(AddNewTemplate, { + templateType: postType, showIcon: false, toggleProps: { variant: 'primary' } - }) - }, templates && (0,external_wp_element_namespaceObject.createElement)(Table, { - data: templates, - columns: columns + }) : (0,external_React_.createElement)(AddNewTemplatePart, null) + }, (0,external_React_.createElement)(DataViews, { + paginationInfo: paginationInfo, + fields: fields, + actions: actions, + data: data, + isLoading: isLoadingData, + view: view, + onChangeView: onChangeView, + onSelectionChange: onSelectionChange, + deferredRendering: !view.hiddenFields?.includes('preview'), + supportedLayouts: page_templates_template_parts_SUPPORTED_LAYOUTS })); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-main/index.js +;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/layout/router.js /** * WordPress dependencies @@ -36776,84 +44956,139 @@ function PageTemplates() { + + + const { - useLocation: page_main_useLocation + useLocation: router_useLocation } = unlock(external_wp_router_namespaceObject.privateApis); -function PageMain() { +function useLayoutAreas() { + const isSiteEditorLoading = useIsSiteEditorLoading(); const { - params: { - path - } - } = page_main_useLocation(); - if (path === '/wp_template/all') { - return (0,external_wp_element_namespaceObject.createElement)(PageTemplates, null); - } else if (path === '/wp_template_part/all') { - return (0,external_wp_element_namespaceObject.createElement)(PageTemplateParts, null); - } else if (path === '/patterns') { - return (0,external_wp_element_namespaceObject.createElement)(PagePatterns, null); - } - return null; -} - -;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/layout/hooks.js -/** - * WordPress dependencies - */ + params + } = router_useLocation(); + const { + postType, + postId, + path, + layout, + isCustom, + canvas + } = params !== null && params !== void 0 ? params : {}; + // Note: Since "sidebar" is not yet supported here, + // returning undefined from "mobile" means show the sidebar. + // Regular page + if (path === '/page') { + return { + areas: { + content: undefined, + preview: (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }), + mobile: canvas === 'edit' ? (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }) : undefined + }, + widths: { + content: undefined + } + }; + } + // List layout is still experimental. + // Extracted it here out of the conditionals so it doesn't unintentionally becomes stable. + const isListLayout = isCustom !== 'true' && layout === 'list' && window?.__experimentalAdminViews; + if (path === '/pages') { + return { + areas: { + content: (0,external_React_.createElement)(PagePages, null), + preview: isListLayout && (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }) + }, + widths: { + content: isListLayout ? 380 : undefined + } + }; + } -/** - * Internal dependencies - */ + // Regular other post types + if (postType && postId) { + return { + areas: { + preview: (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }), + mobile: canvas === 'edit' ? (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }) : undefined + } + }; + } -const MAX_LOADING_TIME = 10000; // 10 seconds + // Templates + if (path === '/wp_template/all') { + return { + areas: { + content: (0,external_React_.createElement)(PageTemplatesTemplateParts, { + postType: constants_TEMPLATE_POST_TYPE + }), + preview: isListLayout && (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }), + mobile: (0,external_React_.createElement)(PageTemplatesTemplateParts, { + postType: constants_TEMPLATE_POST_TYPE + }) + }, + widths: { + content: isListLayout ? 380 : undefined + } + }; + } -function useIsSiteEditorLoading() { - const { - isLoaded: hasLoadedPost - } = useEditedEntityRecord(); - const [loaded, setLoaded] = (0,external_wp_element_namespaceObject.useState)(false); - const inLoadingPause = (0,external_wp_data_namespaceObject.useSelect)(select => { - const hasResolvingSelectors = select(external_wp_coreData_namespaceObject.store).hasResolvingSelectors(); - return !loaded && !hasResolvingSelectors; - }, [loaded]); + // Template parts + if (path === '/wp_template_part/all') { + return { + areas: { + content: (0,external_React_.createElement)(PageTemplatesTemplateParts, { + postType: TEMPLATE_PART_POST_TYPE + }), + preview: isListLayout && (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }), + mobile: (0,external_React_.createElement)(PageTemplatesTemplateParts, { + postType: TEMPLATE_PART_POST_TYPE + }) + }, + widths: { + content: isListLayout ? 380 : undefined + } + }; + } - /* - * If the maximum expected loading time has passed, we're marking the - * editor as loaded, in order to prevent any failed requests from blocking - * the editor canvas from appearing. - */ - (0,external_wp_element_namespaceObject.useEffect)(() => { - let timeout; - if (!loaded) { - timeout = setTimeout(() => { - setLoaded(true); - }, MAX_LOADING_TIME); - } - return () => { - clearTimeout(timeout); + // Patterns + if (path === '/patterns') { + return { + areas: { + content: (0,external_React_.createElement)(DataviewsPatterns, null), + mobile: (0,external_React_.createElement)(DataviewsPatterns, null) + } }; - }, [loaded]); - (0,external_wp_element_namespaceObject.useEffect)(() => { - if (inLoadingPause) { - /* - * We're using an arbitrary 1s timeout here to catch brief moments - * without any resolving selectors that would result in displaying - * brief flickers of loading state and loaded state. - * - * It's worth experimenting with different values, since this also - * adds 1s of artificial delay after loading has finished. - */ - const timeout = setTimeout(() => { - setLoaded(true); - }, 1000); - return () => { - clearTimeout(timeout); - }; + } + + // Fallback shows the home page preview + return { + areas: { + preview: (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }), + mobile: canvas === 'edit' ? (0,external_React_.createElement)(Editor, { + isLoading: isSiteEditorLoading + }) : undefined } - }, [inLoadingPause]); - return !loaded || !hasLoadedPost; + }; } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/layout/index.js @@ -36878,7 +45113,6 @@ function useIsSiteEditorLoading() { - /** * Internal dependencies */ @@ -36898,8 +45132,6 @@ function useIsSiteEditorLoading() { - - const { useCommands } = unlock(external_wp_coreCommands_namespaceObject.privateApis); @@ -36907,9 +45139,6 @@ const { useCommandContext } = unlock(external_wp_commands_namespaceObject.privateApis); const { - useLocation: layout_useLocation -} = unlock(external_wp_router_namespaceObject.privateApis); -const { useGlobalStyle: layout_useGlobalStyle } = unlock(external_wp_blockEditor_namespaceObject.privateApis); const ANIMATION_DURATION = 0.5; @@ -36921,16 +45150,11 @@ function Layout() { useEditModeCommands(); useCommonCommands(); (0,external_wp_blockEditor_namespaceObject.useBlockCommands)(); - const hubRef = (0,external_wp_element_namespaceObject.useRef)(); - const { - params - } = layout_useLocation(); const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); - const isListPage = getIsListPage(params, isMobileViewport); - const isEditorPage = !isListPage; const { isDistractionFree, hasFixedToolbar, + hasBlockSelected, canvasMode, previousShortcut, nextShortcut @@ -36945,25 +45169,24 @@ function Layout() { canvasMode: getCanvasMode(), previousShortcut: getAllShortcutKeyCombinations('core/edit-site/previous-region'), nextShortcut: getAllShortcutKeyCombinations('core/edit-site/next-region'), - hasFixedToolbar: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'fixedToolbar'), - isDistractionFree: select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'distractionFree') + hasFixedToolbar: select(external_wp_preferences_namespaceObject.store).get('core', 'fixedToolbar'), + isDistractionFree: select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree'), + hasBlockSelected: select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart() }; }, []); - const isEditing = canvasMode === 'edit'; const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)({ previous: previousShortcut, next: nextShortcut }); const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); - const showSidebar = isMobileViewport && !isListPage || !isMobileViewport && (canvasMode === 'view' || !isEditorPage); - const showCanvas = isMobileViewport && isEditorPage && isEditing || !isMobileViewport || !isEditorPage; - const isFullCanvas = isMobileViewport && isListPage || isEditorPage && isEditing; const [canvasResizer, canvasSize] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); const [fullResizer] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); - const [isResizing] = (0,external_wp_element_namespaceObject.useState)(false); const isEditorLoading = useIsSiteEditorLoading(); const [isResizableFrameOversized, setIsResizableFrameOversized] = (0,external_wp_element_namespaceObject.useState)(false); - const [listViewToggleElement, setListViewToggleElement] = (0,external_wp_element_namespaceObject.useState)(null); + const { + areas, + widths + } = useLayoutAreas(); // This determines which animation variant should apply to the header. // There is also a `isDistractionFreeHovering` state that gets priority @@ -36986,7 +45209,13 @@ function Layout() { } // Sets the right context for the command palette - const commandContext = canvasMode === 'edit' && isEditorPage ? 'site-editor-edit' : 'site-editor'; + let commandContext = 'site-editor'; + if (canvasMode === 'edit') { + commandContext = 'site-editor-edit'; + } + if (hasBlockSelected) { + commandContext = 'block-selection-edit'; + } useCommandContext(commandContext); const [backgroundColor] = layout_useGlobalStyle('color.background'); const [gradientValue] = layout_useGlobalStyle('color.gradient'); @@ -36997,16 +45226,16 @@ function Layout() { if (canvasMode === 'init') { return null; } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_commands_namespaceObject.CommandMenu, null), (0,external_wp_element_namespaceObject.createElement)(register, null), (0,external_wp_element_namespaceObject.createElement)(global, null), fullResizer, (0,external_wp_element_namespaceObject.createElement)("div", { + return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_commands_namespaceObject.CommandMenu, null), (0,external_React_.createElement)(register, null), (0,external_React_.createElement)(global, null), fullResizer, (0,external_React_.createElement)("div", { ...navigateRegionsProps, ref: navigateRegionsProps.ref, className: classnames_default()('edit-site-layout', navigateRegionsProps.className, { - 'is-distraction-free': isDistractionFree && isEditing, - 'is-full-canvas': isFullCanvas, - 'is-edit-mode': isEditing, - 'has-fixed-toolbar': hasFixedToolbar + 'is-distraction-free': isDistractionFree && canvasMode === 'edit', + 'is-full-canvas': canvasMode === 'edit', + 'has-fixed-toolbar': hasFixedToolbar, + 'is-block-toolbar-visible': hasBlockSelected }) - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { className: "edit-site-layout__header-container", variants: { isDistractionFree: { @@ -37017,7 +45246,6 @@ function Layout() { delayChildren: 0.8 } // How long to wait before the header exits }, - isDistractionFreeHovering: { opacity: 1, transition: { @@ -37026,7 +45254,6 @@ function Layout() { delayChildren: 0.2 } // How long to wait before the header shows }, - view: { opacity: 1 }, @@ -37036,27 +45263,12 @@ function Layout() { }, whileHover: isDistractionFree ? 'isDistractionFreeHovering' : undefined, animate: headerAnimationState - }, (0,external_wp_element_namespaceObject.createElement)(site_hub, { - variants: { - isDistractionFree: { - x: '-100%' - }, - isDistractionFreeHovering: { - x: 0 - }, - view: { - x: 0 - }, - edit: { - x: 0 - } - }, - ref: hubRef, + }, (0,external_React_.createElement)(site_hub, { isTransparent: isResizableFrameOversized, className: "edit-site-layout__hub" - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, { + }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, { initial: false - }, isEditorPage && isEditing && (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + }, canvasMode === 'edit' && (0,external_React_.createElement)(NavigableRegion, { key: "header", className: "edit-site-layout__header", ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'), @@ -37091,21 +45303,20 @@ function Layout() { duration: disableMotion ? 0 : 0.2, ease: 'easeOut' } - }, (0,external_wp_element_namespaceObject.createElement)(HeaderEditMode, { - setListViewToggleElement: setListViewToggleElement - })))), (0,external_wp_element_namespaceObject.createElement)("div", { + }, (0,external_React_.createElement)(HeaderEditMode, null)))), (0,external_React_.createElement)("div", { className: "edit-site-layout__content" - }, (0,external_wp_element_namespaceObject.createElement)(NavigableRegion, { + }, (!isMobileViewport || isMobileViewport && !areas.mobile) && (0,external_React_.createElement)(NavigableRegion, { ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Navigation'), className: "edit-site-layout__sidebar-region" - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { - // The sidebar is needed for routing on mobile - // (https://github.com/WordPress/gutenberg/pull/51558/files#r1231763003), - // so we can't remove the element entirely. Using `inert` will make - // it inaccessible to screen readers and keyboard navigation. - inert: showSidebar ? undefined : 'inert', + }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, null, canvasMode === 'view' && (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + initial: { + opacity: 0 + }, animate: { - opacity: showSidebar ? 1 : 0 + opacity: 1 + }, + exit: { + opacity: 0 }, transition: { type: 'tween', @@ -37115,15 +45326,23 @@ function Layout() { ease: 'easeOut' }, className: "edit-site-layout__sidebar" - }, (0,external_wp_element_namespaceObject.createElement)(sidebar, null))), (0,external_wp_element_namespaceObject.createElement)(SavePanel, null), showCanvas && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isListPage && (0,external_wp_element_namespaceObject.createElement)(PageMain, null), isEditorPage && (0,external_wp_element_namespaceObject.createElement)("div", { - className: classnames_default()('edit-site-layout__canvas-container', { - 'is-resizing': isResizing - }) - }, canvasResizer, !!canvasSize.width && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { - whileHover: isEditorPage && canvasMode === 'view' ? { + }, (0,external_React_.createElement)(sidebar, null)))), (0,external_React_.createElement)(SavePanel, null), isMobileViewport && areas.mobile && (0,external_React_.createElement)("div", { + className: "edit-site-layout__mobile", + style: { + maxWidth: widths?.content + } + }, areas.mobile), !isMobileViewport && areas.content && canvasMode !== 'edit' && (0,external_React_.createElement)("div", { + className: "edit-site-layout__area", + style: { + maxWidth: widths?.content + } + }, areas.content), !isMobileViewport && areas.preview && (0,external_React_.createElement)("div", { + className: "edit-site-layout__canvas-container" + }, canvasResizer, !!canvasSize.width && (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { + whileHover: canvasMode === 'view' ? { scale: 1.005, transition: { - duration: disableMotion || isResizing ? 0 : 0.5, + duration: disableMotion ? 0 : 0.5, ease: 'easeOut' } } : {}, @@ -37134,12 +45353,12 @@ function Layout() { }), transition: { type: 'tween', - duration: disableMotion || isResizing ? 0 : ANIMATION_DURATION, + duration: disableMotion ? 0 : ANIMATION_DURATION, ease: 'easeOut' } - }, (0,external_wp_element_namespaceObject.createElement)(ErrorBoundary, null, (0,external_wp_element_namespaceObject.createElement)(resizable_frame, { + }, (0,external_React_.createElement)(ErrorBoundary, null, (0,external_React_.createElement)(resizable_frame, { isReady: !isEditorLoading, - isFullWidth: isEditing, + isFullWidth: canvasMode === 'edit', defaultSize: { width: canvasSize.width - 24 /* $canvas-padding */, height: canvasSize.height @@ -37149,10 +45368,7 @@ function Layout() { innerContentStyle: { background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor } - }, (0,external_wp_element_namespaceObject.createElement)(Editor, { - listViewToggleElement: listViewToggleElement, - isLoading: isEditorLoading - }))))))))); + }, areas.preview))))))); } ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/app/index.js @@ -37185,7 +45401,7 @@ function App() { createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: plugin name */ (0,external_wp_i18n_namespaceObject.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name)); } - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(GlobalStylesProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_editor_namespaceObject.UnsavedChangesWarning, null), (0,external_wp_element_namespaceObject.createElement)(RouterProvider, null, (0,external_wp_element_namespaceObject.createElement)(Layout, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, { + return (0,external_React_.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_React_.createElement)(GlobalStylesProvider, null, (0,external_React_.createElement)(external_wp_editor_namespaceObject.UnsavedChangesWarning, null), (0,external_React_.createElement)(RouterProvider, null, (0,external_React_.createElement)(Layout, null), (0,external_React_.createElement)(external_wp_plugins_namespaceObject.PluginArea, { onError: onPluginAreaError })))); } @@ -37197,12 +45413,6 @@ function App() { */ - -/** - * Internal dependencies - */ - - /** * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar. * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`. @@ -37272,12 +45482,10 @@ function PluginSidebarEditSite({ className, ...props }) { - const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getSettings().showIconLabels, []); - return (0,external_wp_element_namespaceObject.createElement)(complementary_area, { + return (0,external_React_.createElement)(complementary_area, { panelClassName: className, className: "edit-site-sidebar-edit-mode", scope: "core/edit-site", - showIconLabels: showIconLabels, ...props }); } @@ -37334,11 +45542,11 @@ function PluginSidebarEditSite({ * ); * ``` * - * @return {WPComponent} The component to be rendered. + * @return {Component} The component to be rendered. */ function PluginSidebarMoreMenuItem(props) { - return (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem + return (0,external_React_.createElement)(ComplementaryAreaMoreMenuItem // Menu item is marked with unstable prop for backward compatibility. // @see https://github.com/WordPress/gutenberg/issues/14457 , { @@ -37411,9 +45619,9 @@ function PluginSidebarMoreMenuItem(props) { * ); * ``` * - * @return {WPComponent} The component to be rendered. + * @return {Component} The component to be rendered. */ -/* harmony default export */ var plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => { +/* harmony default export */ const plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => { var _ownProps$as; return { as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : external_wp_components_namespaceObject.MenuItem, @@ -37437,7 +45645,6 @@ function PluginSidebarMoreMenuItem(props) { - /** * Internal dependencies */ @@ -37454,8 +45661,6 @@ function PluginSidebarMoreMenuItem(props) { function initializeEditor(id, settings) { const target = document.getElementById(id); const root = (0,external_wp_element_namespaceObject.createRoot)(target); - settings.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings); - settings.__experimentalFetchRichUrlData = external_wp_coreData_namespaceObject.__experimentalFetchUrlData; (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).reapplyBlockTypeFilters(); const coreBlocks = (0,external_wp_blockLibrary_namespaceObject.__experimentalGetCoreBlocks)().filter(({ name @@ -37473,17 +45678,22 @@ function initializeEditor(id, settings) { // We dispatch actions and update the store synchronously before rendering // so that we won't trigger unnecessary re-renders with useEffect. (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/edit-site', { + welcomeGuide: true, + welcomeGuideStyles: true, + welcomeGuidePage: true, + welcomeGuideTemplate: true + }); + (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core', { + allowRightClickOverrides: true, + distractionFree: false, editorMode: 'visual', fixedToolbar: false, focusMode: false, - distractionFree: false, + inactivePanels: [], keepCaretInsideBlock: false, - welcomeGuide: true, - welcomeGuideStyles: true, - welcomeGuidePage: true, - welcomeGuideTemplate: true, - showListViewByDefault: false, - showBlockBreadcrumbs: true + openPanels: ['post-status'], + showBlockBreadcrumbs: true, + showListViewByDefault: false }); (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultComplementaryArea('core/edit-site', 'edit-site/template'); (0,external_wp_data_namespaceObject.dispatch)(store_store).updateSettings(settings); @@ -37500,7 +45710,7 @@ function initializeEditor(id, settings) { // Prevent the default browser action for files dropped outside of dropzones. window.addEventListener('dragover', e => e.preventDefault(), false); window.addEventListener('drop', e => e.preventDefault(), false); - root.render((0,external_wp_element_namespaceObject.createElement)(App, null)); + root.render((0,external_React_.createElement)(App, null)); return root; } function reinitializeEditor() { @@ -37515,7 +45725,8 @@ function reinitializeEditor() { -}(); +})(); + (window.wp = window.wp || {}).editSite = __webpack_exports__; /******/ })() ;
\ No newline at end of file |