customize-widgets.js 105 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 4403:
  4. /***/ (function(module, exports) {
  5. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  6. Copyright (c) 2018 Jed Watson.
  7. Licensed under the MIT License (MIT), see
  8. http://jedwatson.github.io/classnames
  9. */
  10. /* global define */
  11. (function () {
  12. 'use strict';
  13. var hasOwn = {}.hasOwnProperty;
  14. var nativeCodeString = '[native code]';
  15. function classNames() {
  16. var classes = [];
  17. for (var i = 0; i < arguments.length; i++) {
  18. var arg = arguments[i];
  19. if (!arg) continue;
  20. var argType = typeof arg;
  21. if (argType === 'string' || argType === 'number') {
  22. classes.push(arg);
  23. } else if (Array.isArray(arg)) {
  24. if (arg.length) {
  25. var inner = classNames.apply(null, arg);
  26. if (inner) {
  27. classes.push(inner);
  28. }
  29. }
  30. } else if (argType === 'object') {
  31. if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
  32. classes.push(arg.toString());
  33. continue;
  34. }
  35. for (var key in arg) {
  36. if (hasOwn.call(arg, key) && arg[key]) {
  37. classes.push(key);
  38. }
  39. }
  40. }
  41. }
  42. return classes.join(' ');
  43. }
  44. if ( true && module.exports) {
  45. classNames.default = classNames;
  46. module.exports = classNames;
  47. } else if (true) {
  48. // register as 'classnames', consistent with npm package name
  49. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  50. return classNames;
  51. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  52. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  53. } else {}
  54. }());
  55. /***/ })
  56. /******/ });
  57. /************************************************************************/
  58. /******/ // The module cache
  59. /******/ var __webpack_module_cache__ = {};
  60. /******/
  61. /******/ // The require function
  62. /******/ function __webpack_require__(moduleId) {
  63. /******/ // Check if module is in cache
  64. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  65. /******/ if (cachedModule !== undefined) {
  66. /******/ return cachedModule.exports;
  67. /******/ }
  68. /******/ // Create a new module (and put it into the cache)
  69. /******/ var module = __webpack_module_cache__[moduleId] = {
  70. /******/ // no module.id needed
  71. /******/ // no module.loaded needed
  72. /******/ exports: {}
  73. /******/ };
  74. /******/
  75. /******/ // Execute the module function
  76. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  77. /******/
  78. /******/ // Return the exports of the module
  79. /******/ return module.exports;
  80. /******/ }
  81. /******/
  82. /************************************************************************/
  83. /******/ /* webpack/runtime/compat get default export */
  84. /******/ !function() {
  85. /******/ // getDefaultExport function for compatibility with non-harmony modules
  86. /******/ __webpack_require__.n = function(module) {
  87. /******/ var getter = module && module.__esModule ?
  88. /******/ function() { return module['default']; } :
  89. /******/ function() { return module; };
  90. /******/ __webpack_require__.d(getter, { a: getter });
  91. /******/ return getter;
  92. /******/ };
  93. /******/ }();
  94. /******/
  95. /******/ /* webpack/runtime/define property getters */
  96. /******/ !function() {
  97. /******/ // define getter functions for harmony exports
  98. /******/ __webpack_require__.d = function(exports, definition) {
  99. /******/ for(var key in definition) {
  100. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  101. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  102. /******/ }
  103. /******/ }
  104. /******/ };
  105. /******/ }();
  106. /******/
  107. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  108. /******/ !function() {
  109. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  110. /******/ }();
  111. /******/
  112. /******/ /* webpack/runtime/make namespace object */
  113. /******/ !function() {
  114. /******/ // define __esModule on exports
  115. /******/ __webpack_require__.r = function(exports) {
  116. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  117. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  118. /******/ }
  119. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  120. /******/ };
  121. /******/ }();
  122. /******/
  123. /************************************************************************/
  124. var __webpack_exports__ = {};
  125. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  126. !function() {
  127. "use strict";
  128. // ESM COMPAT FLAG
  129. __webpack_require__.r(__webpack_exports__);
  130. // EXPORTS
  131. __webpack_require__.d(__webpack_exports__, {
  132. "initialize": function() { return /* binding */ initialize; }
  133. });
  134. // NAMESPACE OBJECT: ./node_modules/@wordpress/customize-widgets/build-module/store/selectors.js
  135. var selectors_namespaceObject = {};
  136. __webpack_require__.r(selectors_namespaceObject);
  137. __webpack_require__.d(selectors_namespaceObject, {
  138. "__experimentalGetInsertionPoint": function() { return __experimentalGetInsertionPoint; },
  139. "isInserterOpened": function() { return isInserterOpened; }
  140. });
  141. // NAMESPACE OBJECT: ./node_modules/@wordpress/customize-widgets/build-module/store/actions.js
  142. var actions_namespaceObject = {};
  143. __webpack_require__.r(actions_namespaceObject);
  144. __webpack_require__.d(actions_namespaceObject, {
  145. "setIsInserterOpened": function() { return setIsInserterOpened; }
  146. });
  147. // NAMESPACE OBJECT: ./node_modules/@wordpress/interface/build-module/store/actions.js
  148. var store_actions_namespaceObject = {};
  149. __webpack_require__.r(store_actions_namespaceObject);
  150. __webpack_require__.d(store_actions_namespaceObject, {
  151. "disableComplementaryArea": function() { return disableComplementaryArea; },
  152. "enableComplementaryArea": function() { return enableComplementaryArea; },
  153. "pinItem": function() { return pinItem; },
  154. "setDefaultComplementaryArea": function() { return setDefaultComplementaryArea; },
  155. "setFeatureDefaults": function() { return setFeatureDefaults; },
  156. "setFeatureValue": function() { return setFeatureValue; },
  157. "toggleFeature": function() { return toggleFeature; },
  158. "unpinItem": function() { return unpinItem; }
  159. });
  160. // NAMESPACE OBJECT: ./node_modules/@wordpress/interface/build-module/store/selectors.js
  161. var store_selectors_namespaceObject = {};
  162. __webpack_require__.r(store_selectors_namespaceObject);
  163. __webpack_require__.d(store_selectors_namespaceObject, {
  164. "getActiveComplementaryArea": function() { return getActiveComplementaryArea; },
  165. "isFeatureActive": function() { return isFeatureActive; },
  166. "isItemPinned": function() { return isItemPinned; }
  167. });
  168. ;// CONCATENATED MODULE: external ["wp","element"]
  169. var external_wp_element_namespaceObject = window["wp"]["element"];
  170. ;// CONCATENATED MODULE: external ["wp","blockLibrary"]
  171. var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
  172. ;// CONCATENATED MODULE: external ["wp","widgets"]
  173. var external_wp_widgets_namespaceObject = window["wp"]["widgets"];
  174. ;// CONCATENATED MODULE: external ["wp","blocks"]
  175. var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
  176. ;// CONCATENATED MODULE: external ["wp","data"]
  177. var external_wp_data_namespaceObject = window["wp"]["data"];
  178. ;// CONCATENATED MODULE: external ["wp","preferences"]
  179. var external_wp_preferences_namespaceObject = window["wp"]["preferences"];
  180. ;// CONCATENATED MODULE: external ["wp","components"]
  181. var external_wp_components_namespaceObject = window["wp"]["components"];
  182. ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
  183. var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
  184. ;// CONCATENATED MODULE: external ["wp","i18n"]
  185. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  186. ;// CONCATENATED MODULE: external ["wp","blockEditor"]
  187. var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
  188. ;// CONCATENATED MODULE: external ["wp","compose"]
  189. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  190. ;// CONCATENATED MODULE: external ["wp","hooks"]
  191. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  192. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/error-boundary/index.js
  193. /**
  194. * WordPress dependencies
  195. */
  196. function CopyButton(_ref) {
  197. let {
  198. text,
  199. children
  200. } = _ref;
  201. const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
  202. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  203. variant: "secondary",
  204. ref: ref
  205. }, children);
  206. }
  207. class ErrorBoundary extends external_wp_element_namespaceObject.Component {
  208. constructor() {
  209. super(...arguments);
  210. this.state = {
  211. error: null
  212. };
  213. }
  214. componentDidCatch(error) {
  215. this.setState({
  216. error
  217. });
  218. (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error);
  219. }
  220. render() {
  221. const {
  222. error
  223. } = this.state;
  224. if (!error) {
  225. return this.props.children;
  226. }
  227. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
  228. className: "customize-widgets-error-boundary",
  229. actions: [(0,external_wp_element_namespaceObject.createElement)(CopyButton, {
  230. key: "copy-error",
  231. text: error.stack
  232. }, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))]
  233. }, (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'));
  234. }
  235. }
  236. ;// CONCATENATED MODULE: external ["wp","coreData"]
  237. var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
  238. ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
  239. var external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
  240. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  241. function _extends() {
  242. _extends = Object.assign ? Object.assign.bind() : function (target) {
  243. for (var i = 1; i < arguments.length; i++) {
  244. var source = arguments[i];
  245. for (var key in source) {
  246. if (Object.prototype.hasOwnProperty.call(source, key)) {
  247. target[key] = source[key];
  248. }
  249. }
  250. }
  251. return target;
  252. };
  253. return _extends.apply(this, arguments);
  254. }
  255. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/block-inspector-button/index.js
  256. /**
  257. * WordPress dependencies
  258. */
  259. function BlockInspectorButton(_ref) {
  260. let {
  261. inspector,
  262. closeMenu,
  263. ...props
  264. } = _ref;
  265. const selectedBlockClientId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getSelectedBlockClientId(), []);
  266. const selectedBlock = (0,external_wp_element_namespaceObject.useMemo)(() => document.getElementById(`block-${selectedBlockClientId}`), [selectedBlockClientId]);
  267. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, _extends({
  268. onClick: () => {
  269. // Open the inspector.
  270. inspector.open({
  271. returnFocusWhenClose: selectedBlock
  272. }); // Then close the dropdown menu.
  273. closeMenu();
  274. }
  275. }, props), (0,external_wp_i18n_namespaceObject.__)('Show more settings'));
  276. }
  277. /* harmony default export */ var block_inspector_button = (BlockInspectorButton);
  278. // EXTERNAL MODULE: ./node_modules/classnames/index.js
  279. var classnames = __webpack_require__(4403);
  280. var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
  281. ;// CONCATENATED MODULE: external ["wp","keycodes"]
  282. var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
  283. ;// CONCATENATED MODULE: external ["wp","primitives"]
  284. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  285. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/undo.js
  286. /**
  287. * WordPress dependencies
  288. */
  289. const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  290. xmlns: "http://www.w3.org/2000/svg",
  291. viewBox: "0 0 24 24"
  292. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  293. 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"
  294. }));
  295. /* harmony default export */ var library_undo = (undo);
  296. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/redo.js
  297. /**
  298. * WordPress dependencies
  299. */
  300. const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  301. xmlns: "http://www.w3.org/2000/svg",
  302. viewBox: "0 0 24 24"
  303. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  304. 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"
  305. }));
  306. /* harmony default export */ var library_redo = (redo);
  307. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js
  308. /**
  309. * WordPress dependencies
  310. */
  311. const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  312. xmlns: "http://www.w3.org/2000/svg",
  313. viewBox: "0 0 24 24"
  314. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  315. d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
  316. }));
  317. /* harmony default export */ var library_plus = (plus);
  318. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js
  319. /**
  320. * WordPress dependencies
  321. */
  322. const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  323. xmlns: "http://www.w3.org/2000/svg",
  324. viewBox: "0 0 24 24"
  325. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  326. 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"
  327. }));
  328. /* harmony default export */ var close_small = (closeSmall);
  329. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/reducer.js
  330. /**
  331. * WordPress dependencies
  332. */
  333. /**
  334. * Reducer tracking whether the inserter is open.
  335. *
  336. * @param {boolean|Object} state
  337. * @param {Object} action
  338. */
  339. function blockInserterPanel() {
  340. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  341. let action = arguments.length > 1 ? arguments[1] : undefined;
  342. switch (action.type) {
  343. case 'SET_IS_INSERTER_OPENED':
  344. return action.value;
  345. }
  346. return state;
  347. }
  348. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  349. blockInserterPanel
  350. }));
  351. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/selectors.js
  352. /**
  353. * Returns true if the inserter is opened.
  354. *
  355. * @param {Object} state Global application state.
  356. *
  357. * @return {boolean} Whether the inserter is opened.
  358. */
  359. function isInserterOpened(state) {
  360. return !!state.blockInserterPanel;
  361. }
  362. /**
  363. * Get the insertion point for the inserter.
  364. *
  365. * @param {Object} state Global application state.
  366. *
  367. * @return {Object} The root client ID and index to insert at.
  368. */
  369. function __experimentalGetInsertionPoint(state) {
  370. const {
  371. rootClientId,
  372. insertionIndex
  373. } = state.blockInserterPanel;
  374. return {
  375. rootClientId,
  376. insertionIndex
  377. };
  378. }
  379. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/actions.js
  380. /**
  381. * Returns an action object used to open/close the inserter.
  382. *
  383. * @param {boolean|Object} value Whether the inserter should be
  384. * opened (true) or closed (false).
  385. * To specify an insertion point,
  386. * use an object.
  387. * @param {string} value.rootClientId The root client ID to insert at.
  388. * @param {number} value.insertionIndex The index to insert at.
  389. *
  390. * @return {Object} Action object.
  391. */
  392. function setIsInserterOpened(value) {
  393. return {
  394. type: 'SET_IS_INSERTER_OPENED',
  395. value
  396. };
  397. }
  398. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/constants.js
  399. /**
  400. * Module Constants
  401. */
  402. const STORE_NAME = 'core/customize-widgets';
  403. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/store/index.js
  404. /**
  405. * WordPress dependencies
  406. */
  407. /**
  408. * Internal dependencies
  409. */
  410. /**
  411. * Block editor data store configuration.
  412. *
  413. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registering-a-store
  414. *
  415. * @type {Object}
  416. */
  417. const storeConfig = {
  418. reducer: reducer,
  419. selectors: selectors_namespaceObject,
  420. actions: actions_namespaceObject
  421. };
  422. /**
  423. * Store definition for the edit widgets namespace.
  424. *
  425. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  426. *
  427. * @type {Object}
  428. */
  429. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig);
  430. (0,external_wp_data_namespaceObject.register)(store);
  431. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/inserter/index.js
  432. /**
  433. * WordPress dependencies
  434. */
  435. /**
  436. * Internal dependencies
  437. */
  438. function Inserter(_ref) {
  439. let {
  440. setIsOpened
  441. } = _ref;
  442. const inserterTitleId = (0,external_wp_compose_namespaceObject.useInstanceId)(Inserter, 'customize-widget-layout__inserter-panel-title');
  443. const insertionPoint = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).__experimentalGetInsertionPoint(), []);
  444. return (0,external_wp_element_namespaceObject.createElement)("div", {
  445. className: "customize-widgets-layout__inserter-panel",
  446. "aria-labelledby": inserterTitleId
  447. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  448. className: "customize-widgets-layout__inserter-panel-header"
  449. }, (0,external_wp_element_namespaceObject.createElement)("h2", {
  450. id: inserterTitleId,
  451. className: "customize-widgets-layout__inserter-panel-header-title"
  452. }, (0,external_wp_i18n_namespaceObject.__)('Add a block')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  453. className: "customize-widgets-layout__inserter-panel-header-close-button",
  454. icon: close_small,
  455. onClick: () => setIsOpened(false),
  456. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Close inserter')
  457. })), (0,external_wp_element_namespaceObject.createElement)("div", {
  458. className: "customize-widgets-layout__inserter-panel-content"
  459. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary, {
  460. rootClientId: insertionPoint.rootClientId,
  461. __experimentalInsertionIndex: insertionPoint.insertionIndex,
  462. showInserterHelpPanel: true,
  463. onSelect: () => setIsOpened(false)
  464. })));
  465. }
  466. /* harmony default export */ var components_inserter = (Inserter);
  467. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/external.js
  468. /**
  469. * WordPress dependencies
  470. */
  471. const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  472. xmlns: "http://www.w3.org/2000/svg",
  473. viewBox: "0 0 24 24"
  474. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  475. d: "M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"
  476. }));
  477. /* harmony default export */ var library_external = (external);
  478. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js
  479. /**
  480. * WordPress dependencies
  481. */
  482. const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  483. xmlns: "http://www.w3.org/2000/svg",
  484. viewBox: "0 0 24 24"
  485. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  486. d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
  487. }));
  488. /* harmony default export */ var more_vertical = (moreVertical);
  489. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/more-menu-dropdown/index.js
  490. /**
  491. * External dependencies
  492. */
  493. /**
  494. * WordPress dependencies
  495. */
  496. function MoreMenuDropdown(_ref) {
  497. let {
  498. as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu,
  499. className,
  500. /* translators: button label text should, if possible, be under 16 characters. */
  501. label = (0,external_wp_i18n_namespaceObject.__)('Options'),
  502. popoverProps,
  503. toggleProps,
  504. children
  505. } = _ref;
  506. return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, {
  507. className: classnames_default()('interface-more-menu-dropdown', className),
  508. icon: more_vertical,
  509. label: label,
  510. popoverProps: {
  511. position: 'bottom left',
  512. ...popoverProps,
  513. className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
  514. },
  515. toggleProps: {
  516. tooltipPosition: 'bottom',
  517. ...toggleProps
  518. }
  519. }, onClose => children(onClose));
  520. }
  521. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/index.js
  522. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  523. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  524. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  525. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/actions.js
  526. /**
  527. * WordPress dependencies
  528. */
  529. /**
  530. * Set a default complementary area.
  531. *
  532. * @param {string} scope Complementary area scope.
  533. * @param {string} area Area identifier.
  534. *
  535. * @return {Object} Action object.
  536. */
  537. const setDefaultComplementaryArea = (scope, area) => ({
  538. type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
  539. scope,
  540. area
  541. });
  542. /**
  543. * Enable the complementary area.
  544. *
  545. * @param {string} scope Complementary area scope.
  546. * @param {string} area Area identifier.
  547. */
  548. const enableComplementaryArea = (scope, area) => _ref => {
  549. let {
  550. registry,
  551. dispatch
  552. } = _ref;
  553. // Return early if there's no area.
  554. if (!area) {
  555. return;
  556. }
  557. const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
  558. if (!isComplementaryAreaVisible) {
  559. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true);
  560. }
  561. dispatch({
  562. type: 'ENABLE_COMPLEMENTARY_AREA',
  563. scope,
  564. area
  565. });
  566. };
  567. /**
  568. * Disable the complementary area.
  569. *
  570. * @param {string} scope Complementary area scope.
  571. */
  572. const disableComplementaryArea = scope => _ref2 => {
  573. let {
  574. registry
  575. } = _ref2;
  576. const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
  577. if (isComplementaryAreaVisible) {
  578. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false);
  579. }
  580. };
  581. /**
  582. * Pins an item.
  583. *
  584. * @param {string} scope Item scope.
  585. * @param {string} item Item identifier.
  586. *
  587. * @return {Object} Action object.
  588. */
  589. const pinItem = (scope, item) => _ref3 => {
  590. let {
  591. registry
  592. } = _ref3;
  593. // Return early if there's no item.
  594. if (!item) {
  595. return;
  596. }
  597. const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do.
  598. if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) {
  599. return;
  600. }
  601. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
  602. [item]: true
  603. });
  604. };
  605. /**
  606. * Unpins an item.
  607. *
  608. * @param {string} scope Item scope.
  609. * @param {string} item Item identifier.
  610. */
  611. const unpinItem = (scope, item) => _ref4 => {
  612. let {
  613. registry
  614. } = _ref4;
  615. // Return early if there's no item.
  616. if (!item) {
  617. return;
  618. }
  619. const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
  620. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems,
  621. [item]: false
  622. });
  623. };
  624. /**
  625. * Returns an action object used in signalling that a feature should be toggled.
  626. *
  627. * @param {string} scope The feature scope (e.g. core/edit-post).
  628. * @param {string} featureName The feature name.
  629. */
  630. function toggleFeature(scope, featureName) {
  631. return function (_ref5) {
  632. let {
  633. registry
  634. } = _ref5;
  635. external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
  636. since: '6.0',
  637. alternative: `dispatch( 'core/preferences' ).toggle`
  638. });
  639. registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
  640. };
  641. }
  642. /**
  643. * Returns an action object used in signalling that a feature should be set to
  644. * a true or false value
  645. *
  646. * @param {string} scope The feature scope (e.g. core/edit-post).
  647. * @param {string} featureName The feature name.
  648. * @param {boolean} value The value to set.
  649. *
  650. * @return {Object} Action object.
  651. */
  652. function setFeatureValue(scope, featureName, value) {
  653. return function (_ref6) {
  654. let {
  655. registry
  656. } = _ref6;
  657. external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
  658. since: '6.0',
  659. alternative: `dispatch( 'core/preferences' ).set`
  660. });
  661. registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
  662. };
  663. }
  664. /**
  665. * Returns an action object used in signalling that defaults should be set for features.
  666. *
  667. * @param {string} scope The feature scope (e.g. core/edit-post).
  668. * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
  669. *
  670. * @return {Object} Action object.
  671. */
  672. function setFeatureDefaults(scope, defaults) {
  673. return function (_ref7) {
  674. let {
  675. registry
  676. } = _ref7;
  677. external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
  678. since: '6.0',
  679. alternative: `dispatch( 'core/preferences' ).setDefaults`
  680. });
  681. registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
  682. };
  683. }
  684. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/selectors.js
  685. /**
  686. * WordPress dependencies
  687. */
  688. /**
  689. * Returns the complementary area that is active in a given scope.
  690. *
  691. * @param {Object} state Global application state.
  692. * @param {string} scope Item scope.
  693. *
  694. * @return {string | null | undefined} The complementary area that is active in the given scope.
  695. */
  696. const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
  697. var _state$complementaryA;
  698. const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); // Return `undefined` to indicate that the user has never toggled
  699. // visibility, this is the vanilla default. Other code relies on this
  700. // nuance in the return value.
  701. if (isComplementaryAreaVisible === undefined) {
  702. return undefined;
  703. } // Return `null` to indicate the user hid the complementary area.
  704. if (!isComplementaryAreaVisible) {
  705. return null;
  706. }
  707. return state === null || state === void 0 ? void 0 : (_state$complementaryA = state.complementaryAreas) === null || _state$complementaryA === void 0 ? void 0 : _state$complementaryA[scope];
  708. });
  709. /**
  710. * Returns a boolean indicating if an item is pinned or not.
  711. *
  712. * @param {Object} state Global application state.
  713. * @param {string} scope Scope.
  714. * @param {string} item Item to check.
  715. *
  716. * @return {boolean} True if the item is pinned and false otherwise.
  717. */
  718. const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
  719. var _pinnedItems$item;
  720. const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
  721. return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
  722. });
  723. /**
  724. * Returns a boolean indicating whether a feature is active for a particular
  725. * scope.
  726. *
  727. * @param {Object} state The store state.
  728. * @param {string} scope The scope of the feature (e.g. core/edit-post).
  729. * @param {string} featureName The name of the feature.
  730. *
  731. * @return {boolean} Is the feature enabled?
  732. */
  733. const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
  734. external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
  735. since: '6.0',
  736. alternative: `select( 'core/preferences' ).get( scope, featureName )`
  737. });
  738. return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
  739. });
  740. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/reducer.js
  741. /**
  742. * WordPress dependencies
  743. */
  744. function complementaryAreas() {
  745. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  746. let action = arguments.length > 1 ? arguments[1] : undefined;
  747. switch (action.type) {
  748. case 'SET_DEFAULT_COMPLEMENTARY_AREA':
  749. {
  750. const {
  751. scope,
  752. area
  753. } = action; // If there's already an area, don't overwrite it.
  754. if (state[scope]) {
  755. return state;
  756. }
  757. return { ...state,
  758. [scope]: area
  759. };
  760. }
  761. case 'ENABLE_COMPLEMENTARY_AREA':
  762. {
  763. const {
  764. scope,
  765. area
  766. } = action;
  767. return { ...state,
  768. [scope]: area
  769. };
  770. }
  771. }
  772. return state;
  773. }
  774. /* harmony default export */ var store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  775. complementaryAreas
  776. }));
  777. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/constants.js
  778. /**
  779. * The identifier for the data store.
  780. *
  781. * @type {string}
  782. */
  783. const constants_STORE_NAME = 'core/interface';
  784. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/index.js
  785. /**
  786. * WordPress dependencies
  787. */
  788. /**
  789. * Internal dependencies
  790. */
  791. /**
  792. * Store definition for the interface namespace.
  793. *
  794. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  795. *
  796. * @type {Object}
  797. */
  798. const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
  799. reducer: store_reducer,
  800. actions: store_actions_namespaceObject,
  801. selectors: store_selectors_namespaceObject
  802. }); // Once we build a more generic persistence plugin that works across types of stores
  803. // we'd be able to replace this with a register call.
  804. (0,external_wp_data_namespaceObject.register)(store_store);
  805. ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/index.js
  806. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcut-help-modal/config.js
  807. /**
  808. * WordPress dependencies
  809. */
  810. const textFormattingShortcuts = [{
  811. keyCombination: {
  812. modifier: 'primary',
  813. character: 'b'
  814. },
  815. description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
  816. }, {
  817. keyCombination: {
  818. modifier: 'primary',
  819. character: 'i'
  820. },
  821. description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
  822. }, {
  823. keyCombination: {
  824. modifier: 'primary',
  825. character: 'k'
  826. },
  827. description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
  828. }, {
  829. keyCombination: {
  830. modifier: 'primaryShift',
  831. character: 'k'
  832. },
  833. description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
  834. }, {
  835. keyCombination: {
  836. character: '[['
  837. },
  838. description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page')
  839. }, {
  840. keyCombination: {
  841. modifier: 'primary',
  842. character: 'u'
  843. },
  844. description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
  845. }, {
  846. keyCombination: {
  847. modifier: 'access',
  848. character: 'd'
  849. },
  850. description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.')
  851. }, {
  852. keyCombination: {
  853. modifier: 'access',
  854. character: 'x'
  855. },
  856. description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.')
  857. }];
  858. ;// CONCATENATED MODULE: external "lodash"
  859. var external_lodash_namespaceObject = window["lodash"];
  860. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.js
  861. /**
  862. * External dependencies
  863. */
  864. /**
  865. * WordPress dependencies
  866. */
  867. function KeyCombination(_ref) {
  868. let {
  869. keyCombination,
  870. forceAriaLabel
  871. } = _ref;
  872. const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
  873. const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
  874. return (0,external_wp_element_namespaceObject.createElement)("kbd", {
  875. className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination",
  876. "aria-label": forceAriaLabel || ariaLabel
  877. }, (0,external_lodash_namespaceObject.castArray)(shortcut).map((character, index) => {
  878. if (character === '+') {
  879. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
  880. key: index
  881. }, character);
  882. }
  883. return (0,external_wp_element_namespaceObject.createElement)("kbd", {
  884. key: index,
  885. className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key"
  886. }, character);
  887. }));
  888. }
  889. function Shortcut(_ref2) {
  890. let {
  891. description,
  892. keyCombination,
  893. aliases = [],
  894. ariaLabel
  895. } = _ref2;
  896. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  897. className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-description"
  898. }, description), (0,external_wp_element_namespaceObject.createElement)("div", {
  899. className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-term"
  900. }, (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
  901. keyCombination: keyCombination,
  902. forceAriaLabel: ariaLabel
  903. }), aliases.map((alias, index) => (0,external_wp_element_namespaceObject.createElement)(KeyCombination, {
  904. keyCombination: alias,
  905. forceAriaLabel: ariaLabel,
  906. key: index
  907. }))));
  908. }
  909. /* harmony default export */ var keyboard_shortcut_help_modal_shortcut = (Shortcut);
  910. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
  911. /**
  912. * WordPress dependencies
  913. */
  914. /**
  915. * Internal dependencies
  916. */
  917. function DynamicShortcut(_ref) {
  918. let {
  919. name
  920. } = _ref;
  921. const {
  922. keyCombination,
  923. description,
  924. aliases
  925. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  926. const {
  927. getShortcutKeyCombination,
  928. getShortcutDescription,
  929. getShortcutAliases
  930. } = select(external_wp_keyboardShortcuts_namespaceObject.store);
  931. return {
  932. keyCombination: getShortcutKeyCombination(name),
  933. aliases: getShortcutAliases(name),
  934. description: getShortcutDescription(name)
  935. };
  936. }, [name]);
  937. if (!keyCombination) {
  938. return null;
  939. }
  940. return (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal_shortcut, {
  941. keyCombination: keyCombination,
  942. description: description,
  943. aliases: aliases
  944. });
  945. }
  946. /* harmony default export */ var dynamic_shortcut = (DynamicShortcut);
  947. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcut-help-modal/index.js
  948. /**
  949. * External dependencies
  950. */
  951. /**
  952. * WordPress dependencies
  953. */
  954. /**
  955. * Internal dependencies
  956. */
  957. const ShortcutList = _ref => {
  958. let {
  959. shortcuts
  960. } = _ref;
  961. return (
  962. /*
  963. * Disable reason: The `list` ARIA role is redundant but
  964. * Safari+VoiceOver won't announce the list otherwise.
  965. */
  966. /* eslint-disable jsx-a11y/no-redundant-roles */
  967. (0,external_wp_element_namespaceObject.createElement)("ul", {
  968. className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-list",
  969. role: "list"
  970. }, shortcuts.map((shortcut, index) => (0,external_wp_element_namespaceObject.createElement)("li", {
  971. className: "customize-widgets-keyboard-shortcut-help-modal__shortcut",
  972. key: index
  973. }, typeof shortcut === 'string' ? (0,external_wp_element_namespaceObject.createElement)(dynamic_shortcut, {
  974. name: shortcut
  975. }) : (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcut_help_modal_shortcut, shortcut))))
  976. /* eslint-enable jsx-a11y/no-redundant-roles */
  977. );
  978. };
  979. const ShortcutSection = _ref2 => {
  980. let {
  981. title,
  982. shortcuts,
  983. className
  984. } = _ref2;
  985. return (0,external_wp_element_namespaceObject.createElement)("section", {
  986. className: classnames_default()('customize-widgets-keyboard-shortcut-help-modal__section', className)
  987. }, !!title && (0,external_wp_element_namespaceObject.createElement)("h2", {
  988. className: "customize-widgets-keyboard-shortcut-help-modal__section-title"
  989. }, title), (0,external_wp_element_namespaceObject.createElement)(ShortcutList, {
  990. shortcuts: shortcuts
  991. }));
  992. };
  993. const ShortcutCategorySection = _ref3 => {
  994. let {
  995. title,
  996. categoryName,
  997. additionalShortcuts = []
  998. } = _ref3;
  999. const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
  1000. return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
  1001. }, [categoryName]);
  1002. return (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
  1003. title: title,
  1004. shortcuts: categoryShortcuts.concat(additionalShortcuts)
  1005. });
  1006. };
  1007. function KeyboardShortcutHelpModal(_ref4) {
  1008. let {
  1009. isModalActive,
  1010. toggleModal
  1011. } = _ref4;
  1012. const {
  1013. registerShortcut
  1014. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
  1015. registerShortcut({
  1016. name: 'core/customize-widgets/keyboard-shortcuts',
  1017. category: 'main',
  1018. description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
  1019. keyCombination: {
  1020. modifier: 'access',
  1021. character: 'h'
  1022. }
  1023. });
  1024. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/keyboard-shortcuts', toggleModal);
  1025. if (!isModalActive) {
  1026. return null;
  1027. }
  1028. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
  1029. className: "customize-widgets-keyboard-shortcut-help-modal",
  1030. title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
  1031. closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
  1032. onRequestClose: toggleModal
  1033. }, (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
  1034. className: "customize-widgets-keyboard-shortcut-help-modal__main-shortcuts",
  1035. shortcuts: ['core/customize-widgets/keyboard-shortcuts']
  1036. }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
  1037. title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
  1038. categoryName: "global"
  1039. }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
  1040. title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
  1041. categoryName: "selection"
  1042. }), (0,external_wp_element_namespaceObject.createElement)(ShortcutCategorySection, {
  1043. title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
  1044. categoryName: "block",
  1045. additionalShortcuts: [{
  1046. keyCombination: {
  1047. character: '/'
  1048. },
  1049. description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
  1050. /* translators: The forward-slash character. e.g. '/'. */
  1051. ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
  1052. }]
  1053. }), (0,external_wp_element_namespaceObject.createElement)(ShortcutSection, {
  1054. title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
  1055. shortcuts: textFormattingShortcuts
  1056. }));
  1057. }
  1058. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/more-menu/index.js
  1059. /**
  1060. * WordPress dependencies
  1061. */
  1062. /**
  1063. * Internal dependencies
  1064. */
  1065. function MoreMenu() {
  1066. const [isKeyboardShortcutsModalActive, setIsKeyboardShortcutsModalVisible] = (0,external_wp_element_namespaceObject.useState)(false);
  1067. const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive);
  1068. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/keyboard-shortcuts', toggleKeyboardShortcutsModal);
  1069. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, {
  1070. as: external_wp_components_namespaceObject.ToolbarDropdownMenu
  1071. }, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  1072. label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun')
  1073. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
  1074. scope: "core/customize-widgets",
  1075. name: "fixedToolbar",
  1076. label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
  1077. info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
  1078. messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
  1079. messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
  1080. })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  1081. label: (0,external_wp_i18n_namespaceObject.__)('Tools')
  1082. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  1083. onClick: () => {
  1084. setIsKeyboardShortcutsModalVisible(true);
  1085. },
  1086. shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h')
  1087. }, (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')), (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
  1088. scope: "core/customize-widgets",
  1089. name: "welcomeGuide",
  1090. label: (0,external_wp_i18n_namespaceObject.__)('Welcome Guide')
  1091. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
  1092. role: "menuitem",
  1093. icon: library_external,
  1094. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/block-based-widgets-editor/'),
  1095. target: "_blank",
  1096. rel: "noopener noreferrer"
  1097. }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
  1098. as: "span"
  1099. },
  1100. /* translators: accessibility text */
  1101. (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
  1102. label: (0,external_wp_i18n_namespaceObject.__)('Preferences')
  1103. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
  1104. scope: "core/customize-widgets",
  1105. name: "keepCaretInsideBlock",
  1106. label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block'),
  1107. info: (0,external_wp_i18n_namespaceObject.__)('Aids screen readers by stopping text caret from leaving blocks.'),
  1108. messageActivated: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block activated'),
  1109. messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block deactivated')
  1110. })))), (0,external_wp_element_namespaceObject.createElement)(KeyboardShortcutHelpModal, {
  1111. isModalActive: isKeyboardShortcutsModalActive,
  1112. toggleModal: toggleKeyboardShortcutsModal
  1113. }));
  1114. }
  1115. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/header/index.js
  1116. /**
  1117. * External dependencies
  1118. */
  1119. /**
  1120. * WordPress dependencies
  1121. */
  1122. /**
  1123. * Internal dependencies
  1124. */
  1125. function Header(_ref) {
  1126. let {
  1127. sidebar,
  1128. inserter,
  1129. isInserterOpened,
  1130. setIsInserterOpened,
  1131. isFixedToolbarActive
  1132. } = _ref;
  1133. const [[hasUndo, hasRedo], setUndoRedo] = (0,external_wp_element_namespaceObject.useState)([sidebar.hasUndo(), sidebar.hasRedo()]);
  1134. const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y');
  1135. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1136. return sidebar.subscribeHistory(() => {
  1137. setUndoRedo([sidebar.hasUndo(), sidebar.hasRedo()]);
  1138. });
  1139. }, [sidebar]);
  1140. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
  1141. className: classnames_default()('customize-widgets-header', {
  1142. 'is-fixed-toolbar-active': isFixedToolbarActive
  1143. })
  1144. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
  1145. className: "customize-widgets-header-toolbar",
  1146. "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools')
  1147. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  1148. icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo
  1149. /* translators: button label text should, if possible, be under 16 characters. */
  1150. ,
  1151. label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
  1152. shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
  1153. // button, because it will remove focus for keyboard users.
  1154. // See: https://github.com/WordPress/gutenberg/issues/3486
  1155. ,
  1156. "aria-disabled": !hasUndo,
  1157. onClick: sidebar.undo,
  1158. className: "customize-widgets-editor-history-button undo-button"
  1159. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  1160. icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo
  1161. /* translators: button label text should, if possible, be under 16 characters. */
  1162. ,
  1163. label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
  1164. shortcut: shortcut // If there are no undo levels we don't want to actually disable this
  1165. // button, because it will remove focus for keyboard users.
  1166. // See: https://github.com/WordPress/gutenberg/issues/3486
  1167. ,
  1168. "aria-disabled": !hasRedo,
  1169. onClick: sidebar.redo,
  1170. className: "customize-widgets-editor-history-button redo-button"
  1171. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
  1172. className: "customize-widgets-header-toolbar__inserter-toggle",
  1173. isPressed: isInserterOpened,
  1174. variant: "primary",
  1175. icon: library_plus,
  1176. label: (0,external_wp_i18n_namespaceObject._x)('Add block', 'Generic label for block inserter button'),
  1177. onClick: () => {
  1178. setIsInserterOpened(isOpen => !isOpen);
  1179. }
  1180. }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, null))), (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(components_inserter, {
  1181. setIsOpened: setIsInserterOpened
  1182. }), inserter.contentContainer[0]));
  1183. }
  1184. /* harmony default export */ var header = (Header);
  1185. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/inserter/use-inserter.js
  1186. /**
  1187. * WordPress dependencies
  1188. */
  1189. /**
  1190. * Internal dependencies
  1191. */
  1192. function useInserter(inserter) {
  1193. const isInserterOpened = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isInserterOpened(), []);
  1194. const {
  1195. setIsInserterOpened
  1196. } = (0,external_wp_data_namespaceObject.useDispatch)(store);
  1197. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1198. if (isInserterOpened) {
  1199. inserter.open();
  1200. } else {
  1201. inserter.close();
  1202. }
  1203. }, [inserter, isInserterOpened]);
  1204. return [isInserterOpened, (0,external_wp_element_namespaceObject.useCallback)(updater => {
  1205. let isOpen = updater;
  1206. if (typeof updater === 'function') {
  1207. isOpen = updater((0,external_wp_data_namespaceObject.select)(store).isInserterOpened());
  1208. }
  1209. setIsInserterOpened(isOpen);
  1210. }, [setIsInserterOpened])];
  1211. }
  1212. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  1213. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  1214. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  1215. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/utils.js
  1216. // @ts-check
  1217. /**
  1218. * WordPress dependencies
  1219. */
  1220. /**
  1221. * Convert settingId to widgetId.
  1222. *
  1223. * @param {string} settingId The setting id.
  1224. * @return {string} The widget id.
  1225. */
  1226. function settingIdToWidgetId(settingId) {
  1227. const matches = settingId.match(/^widget_(.+)(?:\[(\d+)\])$/);
  1228. if (matches) {
  1229. const idBase = matches[1];
  1230. const number = parseInt(matches[2], 10);
  1231. return `${idBase}-${number}`;
  1232. }
  1233. return settingId;
  1234. }
  1235. /**
  1236. * Transform a block to a customizable widget.
  1237. *
  1238. * @param {WPBlock} block The block to be transformed from.
  1239. * @param {Object} existingWidget The widget to be extended from.
  1240. * @return {Object} The transformed widget.
  1241. */
  1242. function blockToWidget(block) {
  1243. let existingWidget = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1244. let widget;
  1245. const isValidLegacyWidgetBlock = block.name === 'core/legacy-widget' && (block.attributes.id || block.attributes.instance);
  1246. if (isValidLegacyWidgetBlock) {
  1247. if (block.attributes.id) {
  1248. // Widget that does not extend WP_Widget.
  1249. widget = {
  1250. id: block.attributes.id
  1251. };
  1252. } else {
  1253. const {
  1254. encoded,
  1255. hash,
  1256. raw,
  1257. ...rest
  1258. } = block.attributes.instance; // Widget that extends WP_Widget.
  1259. widget = {
  1260. idBase: block.attributes.idBase,
  1261. instance: { ...(existingWidget === null || existingWidget === void 0 ? void 0 : existingWidget.instance),
  1262. // Required only for the customizer.
  1263. is_widget_customizer_js_value: true,
  1264. encoded_serialized_instance: encoded,
  1265. instance_hash_key: hash,
  1266. raw_instance: raw,
  1267. ...rest
  1268. }
  1269. };
  1270. }
  1271. } else {
  1272. const instance = {
  1273. content: (0,external_wp_blocks_namespaceObject.serialize)(block)
  1274. };
  1275. widget = {
  1276. idBase: 'block',
  1277. widgetClass: 'WP_Widget_Block',
  1278. instance: {
  1279. raw_instance: instance
  1280. }
  1281. };
  1282. }
  1283. const {
  1284. form,
  1285. rendered,
  1286. ...restExistingWidget
  1287. } = existingWidget || {};
  1288. return { ...restExistingWidget,
  1289. ...widget
  1290. };
  1291. }
  1292. /**
  1293. * Transform a widget to a block.
  1294. *
  1295. * @param {Object} widget The widget to be transformed from.
  1296. * @param {string} widget.id The widget id.
  1297. * @param {string} widget.idBase The id base of the widget.
  1298. * @param {number} widget.number The number/index of the widget.
  1299. * @param {Object} widget.instance The instance of the widget.
  1300. * @return {WPBlock} The transformed block.
  1301. */
  1302. function widgetToBlock(_ref) {
  1303. let {
  1304. id,
  1305. idBase,
  1306. number,
  1307. instance
  1308. } = _ref;
  1309. let block;
  1310. const {
  1311. encoded_serialized_instance: encoded,
  1312. instance_hash_key: hash,
  1313. raw_instance: raw,
  1314. ...rest
  1315. } = instance;
  1316. if (idBase === 'block') {
  1317. const parsedBlocks = (0,external_wp_blocks_namespaceObject.parse)(raw.content, {
  1318. __unstableSkipAutop: true
  1319. });
  1320. block = parsedBlocks.length ? parsedBlocks[0] : (0,external_wp_blocks_namespaceObject.createBlock)('core/paragraph', {});
  1321. } else if (number) {
  1322. // Widget that extends WP_Widget.
  1323. block = (0,external_wp_blocks_namespaceObject.createBlock)('core/legacy-widget', {
  1324. idBase,
  1325. instance: {
  1326. encoded,
  1327. hash,
  1328. raw,
  1329. ...rest
  1330. }
  1331. });
  1332. } else {
  1333. // Widget that does not extend WP_Widget.
  1334. block = (0,external_wp_blocks_namespaceObject.createBlock)('core/legacy-widget', {
  1335. id
  1336. });
  1337. }
  1338. return (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)(block, id);
  1339. }
  1340. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js
  1341. /**
  1342. * External dependencies
  1343. */
  1344. /**
  1345. * WordPress dependencies
  1346. */
  1347. /**
  1348. * Internal dependencies
  1349. */
  1350. function widgetsToBlocks(widgets) {
  1351. return widgets.map(widget => widgetToBlock(widget));
  1352. }
  1353. function useSidebarBlockEditor(sidebar) {
  1354. const [blocks, setBlocks] = (0,external_wp_element_namespaceObject.useState)(() => widgetsToBlocks(sidebar.getWidgets()));
  1355. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1356. return sidebar.subscribe((prevWidgets, nextWidgets) => {
  1357. setBlocks(prevBlocks => {
  1358. const prevWidgetsMap = new Map(prevWidgets.map(widget => [widget.id, widget]));
  1359. const prevBlocksMap = new Map(prevBlocks.map(block => [(0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block), block]));
  1360. const nextBlocks = nextWidgets.map(nextWidget => {
  1361. const prevWidget = prevWidgetsMap.get(nextWidget.id); // Bail out updates.
  1362. if (prevWidget && prevWidget === nextWidget) {
  1363. return prevBlocksMap.get(nextWidget.id);
  1364. }
  1365. return widgetToBlock(nextWidget);
  1366. }); // Bail out updates.
  1367. if (external_wp_isShallowEqual_default()(prevBlocks, nextBlocks)) {
  1368. return prevBlocks;
  1369. }
  1370. return nextBlocks;
  1371. });
  1372. });
  1373. }, [sidebar]);
  1374. const onChangeBlocks = (0,external_wp_element_namespaceObject.useCallback)(nextBlocks => {
  1375. setBlocks(prevBlocks => {
  1376. if (external_wp_isShallowEqual_default()(prevBlocks, nextBlocks)) {
  1377. return prevBlocks;
  1378. }
  1379. const prevBlocksMap = new Map(prevBlocks.map(block => [(0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block), block]));
  1380. const nextWidgets = nextBlocks.map(nextBlock => {
  1381. const widgetId = (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(nextBlock); // Update existing widgets.
  1382. if (widgetId && prevBlocksMap.has(widgetId)) {
  1383. const prevBlock = prevBlocksMap.get(widgetId);
  1384. const prevWidget = sidebar.getWidget(widgetId); // Bail out updates by returning the previous widgets.
  1385. // Deep equality is necessary until the block editor's internals changes.
  1386. if ((0,external_lodash_namespaceObject.isEqual)(nextBlock, prevBlock) && prevWidget) {
  1387. return prevWidget;
  1388. }
  1389. return blockToWidget(nextBlock, prevWidget);
  1390. } // Add a new widget.
  1391. return blockToWidget(nextBlock);
  1392. }); // Bail out updates if the updated widgets are the same.
  1393. if (external_wp_isShallowEqual_default()(sidebar.getWidgets(), nextWidgets)) {
  1394. return prevBlocks;
  1395. }
  1396. const addedWidgetIds = sidebar.setWidgets(nextWidgets);
  1397. return nextBlocks.reduce((updatedNextBlocks, nextBlock, index) => {
  1398. const addedWidgetId = addedWidgetIds[index];
  1399. if (addedWidgetId !== null) {
  1400. // Only create a new instance if necessary to prevent
  1401. // the whole editor from re-rendering on every edit.
  1402. if (updatedNextBlocks === nextBlocks) {
  1403. updatedNextBlocks = nextBlocks.slice();
  1404. }
  1405. updatedNextBlocks[index] = (0,external_wp_widgets_namespaceObject.addWidgetIdToBlock)(nextBlock, addedWidgetId);
  1406. }
  1407. return updatedNextBlocks;
  1408. }, nextBlocks);
  1409. });
  1410. }, [sidebar]);
  1411. return [blocks, onChangeBlocks, onChangeBlocks];
  1412. }
  1413. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/focus-control/index.js
  1414. /**
  1415. * WordPress dependencies
  1416. */
  1417. /**
  1418. * Internal dependencies
  1419. */
  1420. const FocusControlContext = (0,external_wp_element_namespaceObject.createContext)();
  1421. function FocusControl(_ref) {
  1422. let {
  1423. api,
  1424. sidebarControls,
  1425. children
  1426. } = _ref;
  1427. const [focusedWidgetIdRef, setFocusedWidgetIdRef] = (0,external_wp_element_namespaceObject.useState)({
  1428. current: null
  1429. });
  1430. const focusWidget = (0,external_wp_element_namespaceObject.useCallback)(widgetId => {
  1431. for (const sidebarControl of sidebarControls) {
  1432. const widgets = sidebarControl.setting.get();
  1433. if (widgets.includes(widgetId)) {
  1434. sidebarControl.sectionInstance.expand({
  1435. // Schedule it after the complete callback so that
  1436. // it won't be overridden by the "Back" button focus.
  1437. completeCallback() {
  1438. // Create a "ref-like" object every time to ensure
  1439. // the same widget id can also triggers the focus control.
  1440. setFocusedWidgetIdRef({
  1441. current: widgetId
  1442. });
  1443. }
  1444. });
  1445. break;
  1446. }
  1447. }
  1448. }, [sidebarControls]);
  1449. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1450. function handleFocus(settingId) {
  1451. const widgetId = settingIdToWidgetId(settingId);
  1452. focusWidget(widgetId);
  1453. }
  1454. function handleReady() {
  1455. api.previewer.preview.bind('focus-control-for-setting', handleFocus);
  1456. }
  1457. api.previewer.bind('ready', handleReady);
  1458. return () => {
  1459. api.previewer.unbind('ready', handleReady);
  1460. api.previewer.preview.unbind('focus-control-for-setting', handleFocus);
  1461. };
  1462. }, [api, focusWidget]);
  1463. const context = (0,external_wp_element_namespaceObject.useMemo)(() => [focusedWidgetIdRef, focusWidget], [focusedWidgetIdRef, focusWidget]);
  1464. return (0,external_wp_element_namespaceObject.createElement)(FocusControlContext.Provider, {
  1465. value: context
  1466. }, children);
  1467. }
  1468. const useFocusControl = () => (0,external_wp_element_namespaceObject.useContext)(FocusControlContext);
  1469. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/focus-control/use-blocks-focus-control.js
  1470. /**
  1471. * WordPress dependencies
  1472. */
  1473. /**
  1474. * Internal dependencies
  1475. */
  1476. function useBlocksFocusControl(blocks) {
  1477. const {
  1478. selectBlock
  1479. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  1480. const [focusedWidgetIdRef] = useFocusControl();
  1481. const blocksRef = (0,external_wp_element_namespaceObject.useRef)(blocks);
  1482. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1483. blocksRef.current = blocks;
  1484. }, [blocks]);
  1485. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1486. if (focusedWidgetIdRef.current) {
  1487. const focusedBlock = blocksRef.current.find(block => (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(block) === focusedWidgetIdRef.current);
  1488. if (focusedBlock) {
  1489. selectBlock(focusedBlock.clientId); // If the block is already being selected, the DOM node won't
  1490. // get focused again automatically.
  1491. // We select the DOM and focus it manually here.
  1492. const blockNode = document.querySelector(`[data-block="${focusedBlock.clientId}"]`);
  1493. blockNode === null || blockNode === void 0 ? void 0 : blockNode.focus();
  1494. }
  1495. }
  1496. }, [focusedWidgetIdRef, selectBlock]);
  1497. }
  1498. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/sidebar-editor-provider.js
  1499. /**
  1500. * WordPress dependencies
  1501. */
  1502. /**
  1503. * Internal dependencies
  1504. */
  1505. function SidebarEditorProvider(_ref) {
  1506. let {
  1507. sidebar,
  1508. settings,
  1509. children
  1510. } = _ref;
  1511. const [blocks, onInput, onChange] = useSidebarBlockEditor(sidebar);
  1512. useBlocksFocusControl(blocks);
  1513. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
  1514. value: blocks,
  1515. onInput: onInput,
  1516. onChange: onChange,
  1517. settings: settings,
  1518. useSubRegistry: false
  1519. }, children);
  1520. }
  1521. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/welcome-guide/index.js
  1522. /**
  1523. * WordPress dependencies
  1524. */
  1525. function WelcomeGuide(_ref) {
  1526. let {
  1527. sidebar
  1528. } = _ref;
  1529. const {
  1530. toggle
  1531. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
  1532. const isEntirelyBlockWidgets = sidebar.getWidgets().every(widget => widget.id.startsWith('block-'));
  1533. return (0,external_wp_element_namespaceObject.createElement)("div", {
  1534. className: "customize-widgets-welcome-guide"
  1535. }, (0,external_wp_element_namespaceObject.createElement)("div", {
  1536. className: "customize-widgets-welcome-guide__image__wrapper"
  1537. }, (0,external_wp_element_namespaceObject.createElement)("picture", null, (0,external_wp_element_namespaceObject.createElement)("source", {
  1538. srcSet: "https://s.w.org/images/block-editor/welcome-editor.svg",
  1539. media: "(prefers-reduced-motion: reduce)"
  1540. }), (0,external_wp_element_namespaceObject.createElement)("img", {
  1541. className: "customize-widgets-welcome-guide__image",
  1542. src: "https://s.w.org/images/block-editor/welcome-editor.gif",
  1543. width: "312",
  1544. height: "240",
  1545. alt: ""
  1546. }))), (0,external_wp_element_namespaceObject.createElement)("h1", {
  1547. className: "customize-widgets-welcome-guide__heading"
  1548. }, (0,external_wp_i18n_namespaceObject.__)('Welcome to block Widgets')), (0,external_wp_element_namespaceObject.createElement)("p", {
  1549. className: "customize-widgets-welcome-guide__text"
  1550. }, isEntirelyBlockWidgets ? (0,external_wp_i18n_namespaceObject.__)('Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.') : (0,external_wp_i18n_namespaceObject.__)('You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  1551. className: "customize-widgets-welcome-guide__button",
  1552. variant: "primary",
  1553. onClick: () => toggle('core/customize-widgets', 'welcomeGuide')
  1554. }, (0,external_wp_i18n_namespaceObject.__)('Got it')), (0,external_wp_element_namespaceObject.createElement)("hr", {
  1555. className: "customize-widgets-welcome-guide__separator"
  1556. }), !isEntirelyBlockWidgets && (0,external_wp_element_namespaceObject.createElement)("p", {
  1557. className: "customize-widgets-welcome-guide__more-info"
  1558. }, (0,external_wp_i18n_namespaceObject.__)('Want to stick with the old widgets?'), (0,external_wp_element_namespaceObject.createElement)("br", null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  1559. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/plugins/classic-widgets/')
  1560. }, (0,external_wp_i18n_namespaceObject.__)('Get the Classic Widgets plugin.'))), (0,external_wp_element_namespaceObject.createElement)("p", {
  1561. className: "customize-widgets-welcome-guide__more-info"
  1562. }, (0,external_wp_i18n_namespaceObject.__)('New to the block editor?'), (0,external_wp_element_namespaceObject.createElement)("br", null), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
  1563. href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/wordpress-editor/')
  1564. }, (0,external_wp_i18n_namespaceObject.__)("Here's a detailed guide."))));
  1565. }
  1566. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/keyboard-shortcuts/index.js
  1567. /**
  1568. * WordPress dependencies
  1569. */
  1570. function KeyboardShortcuts(_ref) {
  1571. let {
  1572. undo,
  1573. redo,
  1574. save
  1575. } = _ref;
  1576. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/undo', event => {
  1577. undo();
  1578. event.preventDefault();
  1579. });
  1580. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/redo', event => {
  1581. redo();
  1582. event.preventDefault();
  1583. });
  1584. (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/customize-widgets/save', event => {
  1585. event.preventDefault();
  1586. save();
  1587. });
  1588. return null;
  1589. }
  1590. function KeyboardShortcutsRegister() {
  1591. const {
  1592. registerShortcut,
  1593. unregisterShortcut
  1594. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
  1595. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1596. registerShortcut({
  1597. name: 'core/customize-widgets/undo',
  1598. category: 'global',
  1599. description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
  1600. keyCombination: {
  1601. modifier: 'primary',
  1602. character: 'z'
  1603. }
  1604. });
  1605. registerShortcut({
  1606. name: 'core/customize-widgets/redo',
  1607. category: 'global',
  1608. description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
  1609. keyCombination: {
  1610. modifier: 'primaryShift',
  1611. character: 'z'
  1612. }
  1613. });
  1614. registerShortcut({
  1615. name: 'core/customize-widgets/save',
  1616. category: 'global',
  1617. description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
  1618. keyCombination: {
  1619. modifier: 'primary',
  1620. character: 's'
  1621. }
  1622. });
  1623. return () => {
  1624. unregisterShortcut('core/customize-widgets/undo');
  1625. unregisterShortcut('core/customize-widgets/redo');
  1626. unregisterShortcut('core/customize-widgets/save');
  1627. };
  1628. }, [registerShortcut]);
  1629. return null;
  1630. }
  1631. KeyboardShortcuts.Register = KeyboardShortcutsRegister;
  1632. /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
  1633. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/block-appender/index.js
  1634. /**
  1635. * WordPress dependencies
  1636. */
  1637. function BlockAppender(props) {
  1638. const ref = (0,external_wp_element_namespaceObject.useRef)();
  1639. const isBlocksListEmpty = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlockCount() === 0); // Move the focus to the block appender to prevent focus from
  1640. // being lost when emptying the widget area.
  1641. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1642. if (isBlocksListEmpty && ref.current) {
  1643. const {
  1644. ownerDocument
  1645. } = ref.current;
  1646. if (!ownerDocument.activeElement || ownerDocument.activeElement === ownerDocument.body) {
  1647. ref.current.focus();
  1648. }
  1649. }
  1650. }, [isBlocksListEmpty]);
  1651. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ButtonBlockAppender, _extends({}, props, {
  1652. ref: ref
  1653. }));
  1654. }
  1655. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/index.js
  1656. /**
  1657. * WordPress dependencies
  1658. */
  1659. /**
  1660. * Internal dependencies
  1661. */
  1662. function SidebarBlockEditor(_ref) {
  1663. let {
  1664. blockEditorSettings,
  1665. sidebar,
  1666. inserter,
  1667. inspector
  1668. } = _ref;
  1669. const [isInserterOpened, setIsInserterOpened] = useInserter(inserter);
  1670. const {
  1671. hasUploadPermissions,
  1672. isFixedToolbarActive,
  1673. keepCaretInsideBlock,
  1674. isWelcomeGuideActive
  1675. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  1676. var _select$canUser;
  1677. const {
  1678. get
  1679. } = select(external_wp_preferences_namespaceObject.store);
  1680. return {
  1681. hasUploadPermissions: (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', 'media')) !== null && _select$canUser !== void 0 ? _select$canUser : true,
  1682. isFixedToolbarActive: !!get('core/customize-widgets', 'fixedToolbar'),
  1683. keepCaretInsideBlock: !!get('core/customize-widgets', 'keepCaretInsideBlock'),
  1684. isWelcomeGuideActive: !!get('core/customize-widgets', 'welcomeGuide')
  1685. };
  1686. }, []);
  1687. const settings = (0,external_wp_element_namespaceObject.useMemo)(() => {
  1688. let mediaUploadBlockEditor;
  1689. if (hasUploadPermissions) {
  1690. mediaUploadBlockEditor = _ref2 => {
  1691. let {
  1692. onError,
  1693. ...argumentsObject
  1694. } = _ref2;
  1695. (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
  1696. wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
  1697. onError: _ref3 => {
  1698. let {
  1699. message
  1700. } = _ref3;
  1701. return onError(message);
  1702. },
  1703. ...argumentsObject
  1704. });
  1705. };
  1706. }
  1707. return { ...blockEditorSettings,
  1708. __experimentalSetIsInserterOpened: setIsInserterOpened,
  1709. mediaUpload: mediaUploadBlockEditor,
  1710. hasFixedToolbar: isFixedToolbarActive,
  1711. keepCaretInsideBlock,
  1712. __unstableHasCustomAppender: true
  1713. };
  1714. }, [hasUploadPermissions, blockEditorSettings, isFixedToolbarActive, keepCaretInsideBlock, setIsInserterOpened]);
  1715. if (isWelcomeGuideActive) {
  1716. return (0,external_wp_element_namespaceObject.createElement)(WelcomeGuide, {
  1717. sidebar: sidebar
  1718. });
  1719. }
  1720. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(SidebarEditorProvider, {
  1721. sidebar: sidebar,
  1722. settings: settings
  1723. }, (0,external_wp_element_namespaceObject.createElement)(keyboard_shortcuts, {
  1724. undo: sidebar.undo,
  1725. redo: sidebar.redo,
  1726. save: sidebar.save
  1727. }), (0,external_wp_element_namespaceObject.createElement)(header, {
  1728. sidebar: sidebar,
  1729. inserter: inserter,
  1730. isInserterOpened: isInserterOpened,
  1731. setIsInserterOpened: setIsInserterOpened,
  1732. isFixedToolbarActive: isFixedToolbarActive
  1733. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.CopyHandler, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, {
  1734. styles: settings.defaultEditorStyles
  1735. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSelectionClearer, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.WritingFlow, {
  1736. className: "editor-styles-wrapper"
  1737. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ObserveTyping, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, {
  1738. renderAppender: BlockAppender
  1739. })))))), (0,external_wp_element_namespaceObject.createPortal)( // This is a temporary hack to prevent button component inside <BlockInspector>
  1740. // from submitting form when type="button" is not specified.
  1741. (0,external_wp_element_namespaceObject.createElement)("form", {
  1742. onSubmit: event => event.preventDefault()
  1743. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null)), inspector.contentContainer[0])), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, null, _ref4 => {
  1744. let {
  1745. onClose
  1746. } = _ref4;
  1747. return (0,external_wp_element_namespaceObject.createElement)(block_inspector_button, {
  1748. inspector: inspector,
  1749. closeMenu: onClose
  1750. });
  1751. }));
  1752. }
  1753. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-controls/index.js
  1754. /**
  1755. * WordPress dependencies
  1756. */
  1757. const SidebarControlsContext = (0,external_wp_element_namespaceObject.createContext)();
  1758. function SidebarControls(_ref) {
  1759. let {
  1760. sidebarControls,
  1761. activeSidebarControl,
  1762. children
  1763. } = _ref;
  1764. const context = (0,external_wp_element_namespaceObject.useMemo)(() => ({
  1765. sidebarControls,
  1766. activeSidebarControl
  1767. }), [sidebarControls, activeSidebarControl]);
  1768. return (0,external_wp_element_namespaceObject.createElement)(SidebarControlsContext.Provider, {
  1769. value: context
  1770. }, children);
  1771. }
  1772. function useSidebarControls() {
  1773. const {
  1774. sidebarControls
  1775. } = (0,external_wp_element_namespaceObject.useContext)(SidebarControlsContext);
  1776. return sidebarControls;
  1777. }
  1778. function useActiveSidebarControl() {
  1779. const {
  1780. activeSidebarControl
  1781. } = (0,external_wp_element_namespaceObject.useContext)(SidebarControlsContext);
  1782. return activeSidebarControl;
  1783. }
  1784. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/customize-widgets/use-clear-selected-block.js
  1785. /**
  1786. * WordPress dependencies
  1787. */
  1788. /**
  1789. * We can't just use <BlockSelectionClearer> because the customizer has
  1790. * many root nodes rather than just one in the post editor.
  1791. * We need to listen to the focus events in all those roots, and also in
  1792. * the preview iframe.
  1793. * This hook will clear the selected block when focusing outside the editor,
  1794. * with a few exceptions:
  1795. * 1. Focusing on popovers.
  1796. * 2. Focusing on the inspector.
  1797. * 3. Focusing on any modals/dialogs.
  1798. * These cases are normally triggered by user interactions from the editor,
  1799. * not by explicitly focusing outside the editor, hence no need for clearing.
  1800. *
  1801. * @param {Object} sidebarControl The sidebar control instance.
  1802. * @param {Object} popoverRef The ref object of the popover node container.
  1803. */
  1804. function useClearSelectedBlock(sidebarControl, popoverRef) {
  1805. const {
  1806. hasSelectedBlock,
  1807. hasMultiSelection
  1808. } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
  1809. const {
  1810. clearSelectedBlock
  1811. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  1812. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1813. if (popoverRef.current && sidebarControl) {
  1814. const inspector = sidebarControl.inspector;
  1815. const container = sidebarControl.container[0];
  1816. const ownerDocument = container.ownerDocument;
  1817. const ownerWindow = ownerDocument.defaultView;
  1818. function handleClearSelectedBlock(element) {
  1819. if ( // 1. Make sure there are blocks being selected.
  1820. (hasSelectedBlock() || hasMultiSelection()) && // 2. The element should exist in the DOM (not deleted).
  1821. element && ownerDocument.contains(element) && // 3. It should also not exist in the container, the popover, nor the dialog.
  1822. !container.contains(element) && !popoverRef.current.contains(element) && !element.closest('[role="dialog"]') && // 4. The inspector should not be opened.
  1823. !inspector.expanded()) {
  1824. clearSelectedBlock();
  1825. }
  1826. } // Handle mouse down in the same document.
  1827. function handleMouseDown(event) {
  1828. handleClearSelectedBlock(event.target);
  1829. } // Handle focusing outside the current document, like to iframes.
  1830. function handleBlur() {
  1831. handleClearSelectedBlock(ownerDocument.activeElement);
  1832. }
  1833. ownerDocument.addEventListener('mousedown', handleMouseDown);
  1834. ownerWindow.addEventListener('blur', handleBlur);
  1835. return () => {
  1836. ownerDocument.removeEventListener('mousedown', handleMouseDown);
  1837. ownerWindow.removeEventListener('blur', handleBlur);
  1838. };
  1839. }
  1840. }, [popoverRef, sidebarControl, hasSelectedBlock, hasMultiSelection, clearSelectedBlock]);
  1841. }
  1842. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/customize-widgets/index.js
  1843. /**
  1844. * WordPress dependencies
  1845. */
  1846. /**
  1847. * Internal dependencies
  1848. */
  1849. function CustomizeWidgets(_ref) {
  1850. let {
  1851. api,
  1852. sidebarControls,
  1853. blockEditorSettings
  1854. } = _ref;
  1855. const [activeSidebarControl, setActiveSidebarControl] = (0,external_wp_element_namespaceObject.useState)(null);
  1856. const parentContainer = document.getElementById('customize-theme-controls');
  1857. const popoverRef = (0,external_wp_element_namespaceObject.useRef)();
  1858. useClearSelectedBlock(activeSidebarControl, popoverRef);
  1859. (0,external_wp_element_namespaceObject.useEffect)(() => {
  1860. const unsubscribers = sidebarControls.map(sidebarControl => sidebarControl.subscribe(expanded => {
  1861. if (expanded) {
  1862. setActiveSidebarControl(sidebarControl);
  1863. }
  1864. }));
  1865. return () => {
  1866. unsubscribers.forEach(unsubscriber => unsubscriber());
  1867. };
  1868. }, [sidebarControls]);
  1869. const activeSidebar = activeSidebarControl && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)(ErrorBoundary, null, (0,external_wp_element_namespaceObject.createElement)(SidebarBlockEditor, {
  1870. key: activeSidebarControl.id,
  1871. blockEditorSettings: blockEditorSettings,
  1872. sidebar: activeSidebarControl.sidebarAdapter,
  1873. inserter: activeSidebarControl.inserter,
  1874. inspector: activeSidebarControl.inspector
  1875. })), activeSidebarControl.container[0]); // We have to portal this to the parent of both the editor and the inspector,
  1876. // so that the popovers will appear above both of them.
  1877. const popover = parentContainer && (0,external_wp_element_namespaceObject.createPortal)((0,external_wp_element_namespaceObject.createElement)("div", {
  1878. className: "customize-widgets-popover",
  1879. ref: popoverRef
  1880. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null)), parentContainer);
  1881. return (0,external_wp_element_namespaceObject.createElement)(external_wp_keyboardShortcuts_namespaceObject.ShortcutProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(SidebarControls, {
  1882. sidebarControls: sidebarControls,
  1883. activeSidebarControl: activeSidebarControl
  1884. }, (0,external_wp_element_namespaceObject.createElement)(FocusControl, {
  1885. api: api,
  1886. sidebarControls: sidebarControls
  1887. }, activeSidebar, popover))));
  1888. }
  1889. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/inspector-section.js
  1890. function getInspectorSection() {
  1891. const {
  1892. wp: {
  1893. customize
  1894. }
  1895. } = window;
  1896. return class InspectorSection extends customize.Section {
  1897. constructor(id, options) {
  1898. super(id, options);
  1899. this.parentSection = options.parentSection;
  1900. this.returnFocusWhenClose = null;
  1901. this._isOpen = false;
  1902. }
  1903. get isOpen() {
  1904. return this._isOpen;
  1905. }
  1906. set isOpen(value) {
  1907. this._isOpen = value;
  1908. this.triggerActiveCallbacks();
  1909. }
  1910. ready() {
  1911. this.contentContainer[0].classList.add('customize-widgets-layout__inspector');
  1912. }
  1913. isContextuallyActive() {
  1914. return this.isOpen;
  1915. }
  1916. onChangeExpanded(expanded, args) {
  1917. super.onChangeExpanded(expanded, args);
  1918. if (this.parentSection && !args.unchanged) {
  1919. if (expanded) {
  1920. this.parentSection.collapse({
  1921. manualTransition: true
  1922. });
  1923. } else {
  1924. this.parentSection.expand({
  1925. manualTransition: true,
  1926. completeCallback: () => {
  1927. // Return focus after finishing the transition.
  1928. if (this.returnFocusWhenClose && !this.contentContainer[0].contains(this.returnFocusWhenClose)) {
  1929. this.returnFocusWhenClose.focus();
  1930. }
  1931. }
  1932. });
  1933. }
  1934. }
  1935. }
  1936. open() {
  1937. let {
  1938. returnFocusWhenClose
  1939. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1940. this.isOpen = true;
  1941. this.returnFocusWhenClose = returnFocusWhenClose;
  1942. this.expand({
  1943. allowMultiple: true
  1944. });
  1945. }
  1946. close() {
  1947. this.collapse({
  1948. allowMultiple: true
  1949. });
  1950. }
  1951. collapse(options) {
  1952. // Overridden collapse() function. Mostly call the parent collapse(), but also
  1953. // move our .isOpen to false.
  1954. // Initially, I tried tracking this with onChangeExpanded(), but it doesn't work
  1955. // because the block settings sidebar is a layer "on top of" the G editor sidebar.
  1956. //
  1957. // For example, when closing the block settings sidebar, the G
  1958. // editor sidebar would display, and onChangeExpanded in
  1959. // inspector-section would run with expanded=true, but I want
  1960. // isOpen to be false when the block settings is closed.
  1961. this.isOpen = false;
  1962. super.collapse(options);
  1963. }
  1964. triggerActiveCallbacks() {
  1965. // Manually fire the callbacks associated with moving this.active
  1966. // from false to true. "active" is always true for this section,
  1967. // and "isContextuallyActive" reflects if the block settings
  1968. // sidebar is currently visible, that is, it has replaced the main
  1969. // Gutenberg view.
  1970. // The WP customizer only checks ".isContextuallyActive()" when
  1971. // ".active" changes values. But our ".active" never changes value.
  1972. // The WP customizer never foresaw a section being used a way we
  1973. // fit the block settings sidebar into a section. By manually
  1974. // triggering the "this.active" callbacks, we force the WP
  1975. // customizer to query our .isContextuallyActive() function and
  1976. // update its view of our status.
  1977. this.active.callbacks.fireWith(this.active, [false, true]);
  1978. }
  1979. };
  1980. }
  1981. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/sidebar-section.js
  1982. /**
  1983. * WordPress dependencies
  1984. */
  1985. /**
  1986. * Internal dependencies
  1987. */
  1988. const getInspectorSectionId = sidebarId => `widgets-inspector-${sidebarId}`;
  1989. function getSidebarSection() {
  1990. const {
  1991. wp: {
  1992. customize
  1993. }
  1994. } = window;
  1995. const reduceMotionMediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
  1996. let isReducedMotion = reduceMotionMediaQuery.matches;
  1997. reduceMotionMediaQuery.addEventListener('change', event => {
  1998. isReducedMotion = event.matches;
  1999. });
  2000. return class SidebarSection extends customize.Section {
  2001. ready() {
  2002. const InspectorSection = getInspectorSection();
  2003. this.inspector = new InspectorSection(getInspectorSectionId(this.id), {
  2004. title: (0,external_wp_i18n_namespaceObject.__)('Block Settings'),
  2005. parentSection: this,
  2006. customizeAction: [(0,external_wp_i18n_namespaceObject.__)('Customizing'), (0,external_wp_i18n_namespaceObject.__)('Widgets'), this.params.title].join(' ▸ ')
  2007. });
  2008. customize.section.add(this.inspector);
  2009. this.contentContainer[0].classList.add('customize-widgets__sidebar-section');
  2010. }
  2011. hasSubSectionOpened() {
  2012. return this.inspector.expanded();
  2013. }
  2014. onChangeExpanded(expanded, _args) {
  2015. const controls = this.controls();
  2016. const args = { ..._args,
  2017. completeCallback() {
  2018. var _args$completeCallbac;
  2019. controls.forEach(control => {
  2020. var _control$onChangeSect;
  2021. (_control$onChangeSect = control.onChangeSectionExpanded) === null || _control$onChangeSect === void 0 ? void 0 : _control$onChangeSect.call(control, expanded, args);
  2022. });
  2023. (_args$completeCallbac = _args.completeCallback) === null || _args$completeCallbac === void 0 ? void 0 : _args$completeCallbac.call(_args);
  2024. }
  2025. };
  2026. if (args.manualTransition) {
  2027. if (expanded) {
  2028. this.contentContainer.addClass(['busy', 'open']);
  2029. this.contentContainer.removeClass('is-sub-section-open');
  2030. this.contentContainer.closest('.wp-full-overlay').addClass('section-open');
  2031. } else {
  2032. this.contentContainer.addClass(['busy', 'is-sub-section-open']);
  2033. this.contentContainer.closest('.wp-full-overlay').addClass('section-open');
  2034. this.contentContainer.removeClass('open');
  2035. }
  2036. const handleTransitionEnd = () => {
  2037. this.contentContainer.removeClass('busy');
  2038. args.completeCallback();
  2039. };
  2040. if (isReducedMotion) {
  2041. handleTransitionEnd();
  2042. } else {
  2043. this.contentContainer.one('transitionend', handleTransitionEnd);
  2044. }
  2045. } else {
  2046. super.onChangeExpanded(expanded, args);
  2047. }
  2048. }
  2049. };
  2050. }
  2051. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/components/sidebar-block-editor/sidebar-adapter.js
  2052. /**
  2053. * Internal dependencies
  2054. */
  2055. const {
  2056. wp
  2057. } = window;
  2058. function parseWidgetId(widgetId) {
  2059. const matches = widgetId.match(/^(.+)-(\d+)$/);
  2060. if (matches) {
  2061. return {
  2062. idBase: matches[1],
  2063. number: parseInt(matches[2], 10)
  2064. };
  2065. } // Likely an old single widget.
  2066. return {
  2067. idBase: widgetId
  2068. };
  2069. }
  2070. function widgetIdToSettingId(widgetId) {
  2071. const {
  2072. idBase,
  2073. number
  2074. } = parseWidgetId(widgetId);
  2075. if (number) {
  2076. return `widget_${idBase}[${number}]`;
  2077. }
  2078. return `widget_${idBase}`;
  2079. }
  2080. /**
  2081. * This is a custom debounce function to call different callbacks depending on
  2082. * whether it's the _leading_ call or not.
  2083. *
  2084. * @param {Function} leading The callback that gets called first.
  2085. * @param {Function} callback The callback that gets called after the first time.
  2086. * @param {number} timeout The debounced time in milliseconds.
  2087. * @return {Function} The debounced function.
  2088. */
  2089. function debounce(leading, callback, timeout) {
  2090. let isLeading = false;
  2091. let timerID;
  2092. function debounced() {
  2093. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2094. args[_key] = arguments[_key];
  2095. }
  2096. const result = (isLeading ? callback : leading).apply(this, args);
  2097. isLeading = true;
  2098. clearTimeout(timerID);
  2099. timerID = setTimeout(() => {
  2100. isLeading = false;
  2101. }, timeout);
  2102. return result;
  2103. }
  2104. debounced.cancel = () => {
  2105. isLeading = false;
  2106. clearTimeout(timerID);
  2107. };
  2108. return debounced;
  2109. }
  2110. class SidebarAdapter {
  2111. constructor(setting, api) {
  2112. this.setting = setting;
  2113. this.api = api;
  2114. this.locked = false;
  2115. this.widgetsCache = new WeakMap();
  2116. this.subscribers = new Set();
  2117. this.history = [this._getWidgetIds().map(widgetId => this.getWidget(widgetId))];
  2118. this.historyIndex = 0;
  2119. this.historySubscribers = new Set(); // Debounce the input for 1 second.
  2120. this._debounceSetHistory = debounce(this._pushHistory, this._replaceHistory, 1000);
  2121. this.setting.bind(this._handleSettingChange.bind(this));
  2122. this.api.bind('change', this._handleAllSettingsChange.bind(this));
  2123. this.undo = this.undo.bind(this);
  2124. this.redo = this.redo.bind(this);
  2125. this.save = this.save.bind(this);
  2126. }
  2127. subscribe(callback) {
  2128. this.subscribers.add(callback);
  2129. return () => {
  2130. this.subscribers.delete(callback);
  2131. };
  2132. }
  2133. getWidgets() {
  2134. return this.history[this.historyIndex];
  2135. }
  2136. _emit() {
  2137. for (const callback of this.subscribers) {
  2138. callback(...arguments);
  2139. }
  2140. }
  2141. _getWidgetIds() {
  2142. return this.setting.get();
  2143. }
  2144. _pushHistory() {
  2145. this.history = [...this.history.slice(0, this.historyIndex + 1), this._getWidgetIds().map(widgetId => this.getWidget(widgetId))];
  2146. this.historyIndex += 1;
  2147. this.historySubscribers.forEach(listener => listener());
  2148. }
  2149. _replaceHistory() {
  2150. this.history[this.historyIndex] = this._getWidgetIds().map(widgetId => this.getWidget(widgetId));
  2151. }
  2152. _handleSettingChange() {
  2153. if (this.locked) {
  2154. return;
  2155. }
  2156. const prevWidgets = this.getWidgets();
  2157. this._pushHistory();
  2158. this._emit(prevWidgets, this.getWidgets());
  2159. }
  2160. _handleAllSettingsChange(setting) {
  2161. if (this.locked) {
  2162. return;
  2163. }
  2164. if (!setting.id.startsWith('widget_')) {
  2165. return;
  2166. }
  2167. const widgetId = settingIdToWidgetId(setting.id);
  2168. if (!this.setting.get().includes(widgetId)) {
  2169. return;
  2170. }
  2171. const prevWidgets = this.getWidgets();
  2172. this._pushHistory();
  2173. this._emit(prevWidgets, this.getWidgets());
  2174. }
  2175. _createWidget(widget) {
  2176. const widgetModel = wp.customize.Widgets.availableWidgets.findWhere({
  2177. id_base: widget.idBase
  2178. });
  2179. let number = widget.number;
  2180. if (widgetModel.get('is_multi') && !number) {
  2181. widgetModel.set('multi_number', widgetModel.get('multi_number') + 1);
  2182. number = widgetModel.get('multi_number');
  2183. }
  2184. const settingId = number ? `widget_${widget.idBase}[${number}]` : `widget_${widget.idBase}`;
  2185. const settingArgs = {
  2186. transport: wp.customize.Widgets.data.selectiveRefreshableWidgets[widgetModel.get('id_base')] ? 'postMessage' : 'refresh',
  2187. previewer: this.setting.previewer
  2188. };
  2189. const setting = this.api.create(settingId, settingId, '', settingArgs);
  2190. setting.set(widget.instance);
  2191. const widgetId = settingIdToWidgetId(settingId);
  2192. return widgetId;
  2193. }
  2194. _removeWidget(widget) {
  2195. const settingId = widgetIdToSettingId(widget.id);
  2196. const setting = this.api(settingId);
  2197. if (setting) {
  2198. const instance = setting.get();
  2199. this.widgetsCache.delete(instance);
  2200. }
  2201. this.api.remove(settingId);
  2202. }
  2203. _updateWidget(widget) {
  2204. const prevWidget = this.getWidget(widget.id); // Bail out update if nothing changed.
  2205. if (prevWidget === widget) {
  2206. return widget.id;
  2207. } // Update existing setting if only the widget's instance changed.
  2208. if (prevWidget.idBase && widget.idBase && prevWidget.idBase === widget.idBase) {
  2209. const settingId = widgetIdToSettingId(widget.id);
  2210. this.api(settingId).set(widget.instance);
  2211. return widget.id;
  2212. } // Otherwise delete and re-create.
  2213. this._removeWidget(widget);
  2214. return this._createWidget(widget);
  2215. }
  2216. getWidget(widgetId) {
  2217. if (!widgetId) {
  2218. return null;
  2219. }
  2220. const {
  2221. idBase,
  2222. number
  2223. } = parseWidgetId(widgetId);
  2224. const settingId = widgetIdToSettingId(widgetId);
  2225. const setting = this.api(settingId);
  2226. if (!setting) {
  2227. return null;
  2228. }
  2229. const instance = setting.get();
  2230. if (this.widgetsCache.has(instance)) {
  2231. return this.widgetsCache.get(instance);
  2232. }
  2233. const widget = {
  2234. id: widgetId,
  2235. idBase,
  2236. number,
  2237. instance
  2238. };
  2239. this.widgetsCache.set(instance, widget);
  2240. return widget;
  2241. }
  2242. _updateWidgets(nextWidgets) {
  2243. this.locked = true;
  2244. const addedWidgetIds = [];
  2245. const nextWidgetIds = nextWidgets.map(nextWidget => {
  2246. if (nextWidget.id && this.getWidget(nextWidget.id)) {
  2247. addedWidgetIds.push(null);
  2248. return this._updateWidget(nextWidget);
  2249. }
  2250. const widgetId = this._createWidget(nextWidget);
  2251. addedWidgetIds.push(widgetId);
  2252. return widgetId;
  2253. });
  2254. const deletedWidgets = this.getWidgets().filter(widget => !nextWidgetIds.includes(widget.id));
  2255. deletedWidgets.forEach(widget => this._removeWidget(widget));
  2256. this.setting.set(nextWidgetIds);
  2257. this.locked = false;
  2258. return addedWidgetIds;
  2259. }
  2260. setWidgets(nextWidgets) {
  2261. const addedWidgetIds = this._updateWidgets(nextWidgets);
  2262. this._debounceSetHistory();
  2263. return addedWidgetIds;
  2264. }
  2265. /**
  2266. * Undo/Redo related features
  2267. */
  2268. hasUndo() {
  2269. return this.historyIndex > 0;
  2270. }
  2271. hasRedo() {
  2272. return this.historyIndex < this.history.length - 1;
  2273. }
  2274. _seek(historyIndex) {
  2275. const currentWidgets = this.getWidgets();
  2276. this.historyIndex = historyIndex;
  2277. const widgets = this.history[this.historyIndex];
  2278. this._updateWidgets(widgets);
  2279. this._emit(currentWidgets, this.getWidgets());
  2280. this.historySubscribers.forEach(listener => listener());
  2281. this._debounceSetHistory.cancel();
  2282. }
  2283. undo() {
  2284. if (!this.hasUndo()) {
  2285. return;
  2286. }
  2287. this._seek(this.historyIndex - 1);
  2288. }
  2289. redo() {
  2290. if (!this.hasRedo()) {
  2291. return;
  2292. }
  2293. this._seek(this.historyIndex + 1);
  2294. }
  2295. subscribeHistory(listener) {
  2296. this.historySubscribers.add(listener);
  2297. return () => {
  2298. this.historySubscribers.delete(listener);
  2299. };
  2300. }
  2301. save() {
  2302. this.api.previewer.save();
  2303. }
  2304. }
  2305. ;// CONCATENATED MODULE: external ["wp","dom"]
  2306. var external_wp_dom_namespaceObject = window["wp"]["dom"];
  2307. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/inserter-outer-section.js
  2308. /**
  2309. * WordPress dependencies
  2310. */
  2311. /**
  2312. * Internal dependencies
  2313. */
  2314. function getInserterOuterSection() {
  2315. const {
  2316. wp: {
  2317. customize
  2318. }
  2319. } = window;
  2320. const OuterSection = customize.OuterSection; // Override the OuterSection class to handle multiple outer sections.
  2321. // It closes all the other outer sections whenever one is opened.
  2322. // The result is that at most one outer section can be opened at the same time.
  2323. customize.OuterSection = class extends OuterSection {
  2324. onChangeExpanded(expanded, args) {
  2325. if (expanded) {
  2326. customize.section.each(section => {
  2327. if (section.params.type === 'outer' && section.id !== this.id) {
  2328. if (section.expanded()) {
  2329. section.collapse();
  2330. }
  2331. }
  2332. });
  2333. }
  2334. return super.onChangeExpanded(expanded, args);
  2335. }
  2336. }; // Handle constructor so that "params.type" can be correctly pointed to "outer".
  2337. customize.sectionConstructor.outer = customize.OuterSection;
  2338. return class InserterOuterSection extends customize.OuterSection {
  2339. constructor() {
  2340. super(...arguments); // This is necessary since we're creating a new class which is not identical to the original OuterSection.
  2341. // @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
  2342. this.params.type = 'outer';
  2343. this.activeElementBeforeExpanded = null;
  2344. const ownerWindow = this.contentContainer[0].ownerDocument.defaultView; // Handle closing the inserter when pressing the Escape key.
  2345. ownerWindow.addEventListener('keydown', event => {
  2346. if (this.expanded() && (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE || event.code === 'Escape') && !event.defaultPrevented) {
  2347. event.preventDefault();
  2348. event.stopPropagation();
  2349. (0,external_wp_data_namespaceObject.dispatch)(store).setIsInserterOpened(false);
  2350. }
  2351. }, // Use capture mode to make this run before other event listeners.
  2352. true);
  2353. this.contentContainer.addClass('widgets-inserter'); // Set a flag if the state is being changed from open() or close().
  2354. // Don't propagate the event if it's an internal action to prevent infinite loop.
  2355. this.isFromInternalAction = false;
  2356. this.expanded.bind(() => {
  2357. if (!this.isFromInternalAction) {
  2358. // Propagate the event to React to sync the state.
  2359. (0,external_wp_data_namespaceObject.dispatch)(store).setIsInserterOpened(this.expanded());
  2360. }
  2361. this.isFromInternalAction = false;
  2362. });
  2363. }
  2364. open() {
  2365. if (!this.expanded()) {
  2366. const contentContainer = this.contentContainer[0];
  2367. this.activeElementBeforeExpanded = contentContainer.ownerDocument.activeElement;
  2368. this.isFromInternalAction = true;
  2369. this.expand({
  2370. completeCallback() {
  2371. // We have to do this in a "completeCallback" or else the elements will not yet be visible/tabbable.
  2372. // The first one should be the close button,
  2373. // we want to skip it and choose the second one instead, which is the search box.
  2374. const searchBox = external_wp_dom_namespaceObject.focus.tabbable.find(contentContainer)[1];
  2375. if (searchBox) {
  2376. searchBox.focus();
  2377. }
  2378. }
  2379. });
  2380. }
  2381. }
  2382. close() {
  2383. if (this.expanded()) {
  2384. const contentContainer = this.contentContainer[0];
  2385. const activeElement = contentContainer.ownerDocument.activeElement;
  2386. this.isFromInternalAction = true;
  2387. this.collapse({
  2388. completeCallback() {
  2389. // Return back the focus when closing the inserter.
  2390. // Only do this if the active element which triggers the action is inside the inserter,
  2391. // (the close button for instance). In that case the focus will be lost.
  2392. // Otherwise, we don't hijack the focus when the user is focusing on other elements
  2393. // (like the quick inserter).
  2394. if (contentContainer.contains(activeElement)) {
  2395. // Return back the focus when closing the inserter.
  2396. if (this.activeElementBeforeExpanded) {
  2397. this.activeElementBeforeExpanded.focus();
  2398. }
  2399. }
  2400. }
  2401. });
  2402. }
  2403. }
  2404. };
  2405. }
  2406. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/controls/sidebar-control.js
  2407. /**
  2408. * WordPress dependencies
  2409. */
  2410. /**
  2411. * Internal dependencies
  2412. */
  2413. const getInserterId = controlId => `widgets-inserter-${controlId}`;
  2414. function getSidebarControl() {
  2415. const {
  2416. wp: {
  2417. customize
  2418. }
  2419. } = window;
  2420. return class SidebarControl extends customize.Control {
  2421. constructor() {
  2422. super(...arguments);
  2423. this.subscribers = new Set();
  2424. }
  2425. ready() {
  2426. const InserterOuterSection = getInserterOuterSection();
  2427. this.inserter = new InserterOuterSection(getInserterId(this.id), {});
  2428. customize.section.add(this.inserter);
  2429. this.sectionInstance = customize.section(this.section());
  2430. this.inspector = this.sectionInstance.inspector;
  2431. this.sidebarAdapter = new SidebarAdapter(this.setting, customize);
  2432. }
  2433. subscribe(callback) {
  2434. this.subscribers.add(callback);
  2435. return () => {
  2436. this.subscribers.delete(callback);
  2437. };
  2438. }
  2439. onChangeSectionExpanded(expanded, args) {
  2440. if (!args.unchanged) {
  2441. // Close the inserter when the section collapses.
  2442. if (!expanded) {
  2443. (0,external_wp_data_namespaceObject.dispatch)(store).setIsInserterOpened(false);
  2444. }
  2445. this.subscribers.forEach(subscriber => subscriber(expanded, args));
  2446. }
  2447. }
  2448. };
  2449. }
  2450. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/filters/move-to-sidebar.js
  2451. /**
  2452. * External dependencies
  2453. */
  2454. /**
  2455. * WordPress dependencies
  2456. */
  2457. /**
  2458. * Internal dependencies
  2459. */
  2460. const withMoveToSidebarToolbarItem = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  2461. let widgetId = (0,external_wp_widgets_namespaceObject.getWidgetIdFromBlock)(props);
  2462. const sidebarControls = useSidebarControls();
  2463. const activeSidebarControl = useActiveSidebarControl();
  2464. const hasMultipleSidebars = (sidebarControls === null || sidebarControls === void 0 ? void 0 : sidebarControls.length) > 1;
  2465. const blockName = props.name;
  2466. const clientId = props.clientId;
  2467. const canInsertBlockInSidebar = (0,external_wp_data_namespaceObject.useSelect)(select => {
  2468. // Use an empty string to represent the root block list, which
  2469. // in the customizer editor represents a sidebar/widget area.
  2470. return select(external_wp_blockEditor_namespaceObject.store).canInsertBlockType(blockName, '');
  2471. }, [blockName]);
  2472. const block = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId), [clientId]);
  2473. const {
  2474. removeBlock
  2475. } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
  2476. const [, focusWidget] = useFocusControl();
  2477. function moveToSidebar(sidebarControlId) {
  2478. const newSidebarControl = sidebarControls.find(sidebarControl => sidebarControl.id === sidebarControlId);
  2479. if (widgetId) {
  2480. /**
  2481. * If there's a widgetId, move it to the other sidebar.
  2482. */
  2483. const oldSetting = activeSidebarControl.setting;
  2484. const newSetting = newSidebarControl.setting;
  2485. oldSetting((0,external_lodash_namespaceObject.without)(oldSetting(), widgetId));
  2486. newSetting([...newSetting(), widgetId]);
  2487. } else {
  2488. /**
  2489. * If there isn't a widgetId, it's most likely a inner block.
  2490. * First, remove the block in the original sidebar,
  2491. * then, create a new widget in the new sidebar and get back its widgetId.
  2492. */
  2493. const sidebarAdapter = newSidebarControl.sidebarAdapter;
  2494. removeBlock(clientId);
  2495. const addedWidgetIds = sidebarAdapter.setWidgets([...sidebarAdapter.getWidgets(), blockToWidget(block)]); // The last non-null id is the added widget's id.
  2496. widgetId = addedWidgetIds.reverse().find(id => !!id);
  2497. } // Move focus to the moved widget and expand the sidebar.
  2498. focusWidget(widgetId);
  2499. }
  2500. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props), hasMultipleSidebars && canInsertBlockInSidebar && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_widgets_namespaceObject.MoveToWidgetArea, {
  2501. widgetAreas: sidebarControls.map(sidebarControl => ({
  2502. id: sidebarControl.id,
  2503. name: sidebarControl.params.label,
  2504. description: sidebarControl.params.description
  2505. })),
  2506. currentWidgetAreaId: activeSidebarControl === null || activeSidebarControl === void 0 ? void 0 : activeSidebarControl.id,
  2507. onSelect: moveToSidebar
  2508. })));
  2509. }, 'withMoveToSidebarToolbarItem');
  2510. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/customize-widgets/block-edit', withMoveToSidebarToolbarItem);
  2511. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/filters/replace-media-upload.js
  2512. /**
  2513. * WordPress dependencies
  2514. */
  2515. const replaceMediaUpload = () => external_wp_mediaUtils_namespaceObject.MediaUpload;
  2516. (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-widgets/replace-media-upload', replaceMediaUpload);
  2517. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/filters/wide-widget-display.js
  2518. /**
  2519. * WordPress dependencies
  2520. */
  2521. const {
  2522. wp: wide_widget_display_wp
  2523. } = window;
  2524. const withWideWidgetDisplay = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
  2525. var _wp$customize$Widgets, _wp$customize$Widgets2;
  2526. const {
  2527. idBase
  2528. } = props.attributes;
  2529. const isWide = (_wp$customize$Widgets = (_wp$customize$Widgets2 = wide_widget_display_wp.customize.Widgets.data.availableWidgets.find(widget => widget.id_base === idBase)) === null || _wp$customize$Widgets2 === void 0 ? void 0 : _wp$customize$Widgets2.is_wide) !== null && _wp$customize$Widgets !== void 0 ? _wp$customize$Widgets : false;
  2530. return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, {
  2531. isWide: isWide
  2532. }));
  2533. }, 'withWideWidgetDisplay');
  2534. (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/customize-widgets/wide-widget-display', withWideWidgetDisplay);
  2535. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/filters/index.js
  2536. /**
  2537. * Internal dependencies
  2538. */
  2539. ;// CONCATENATED MODULE: ./node_modules/@wordpress/customize-widgets/build-module/index.js
  2540. /**
  2541. * WordPress dependencies
  2542. */
  2543. /**
  2544. * Internal dependencies
  2545. */
  2546. const {
  2547. wp: build_module_wp
  2548. } = window;
  2549. const DISABLED_BLOCKS = ['core/more', 'core/block', 'core/freeform', 'core/template-part'];
  2550. const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
  2551. /**
  2552. * Initializes the widgets block editor in the customizer.
  2553. *
  2554. * @param {string} editorName The editor name.
  2555. * @param {Object} blockEditorSettings Block editor settings.
  2556. */
  2557. function initialize(editorName, blockEditorSettings) {
  2558. (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/customize-widgets', {
  2559. fixedToolbar: false,
  2560. welcomeGuide: true
  2561. });
  2562. (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters();
  2563. const coreBlocks = (0,external_wp_blockLibrary_namespaceObject.__experimentalGetCoreBlocks)().filter(block => {
  2564. return !(DISABLED_BLOCKS.includes(block.name) || block.name.startsWith('core/post') || block.name.startsWith('core/query') || block.name.startsWith('core/site') || block.name.startsWith('core/navigation'));
  2565. });
  2566. (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)(coreBlocks);
  2567. (0,external_wp_widgets_namespaceObject.registerLegacyWidgetBlock)();
  2568. if (false) {}
  2569. (0,external_wp_widgets_namespaceObject.registerLegacyWidgetVariations)(blockEditorSettings);
  2570. (0,external_wp_widgets_namespaceObject.registerWidgetGroupBlock)(); // As we are unregistering `core/freeform` to avoid the Classic block, we must
  2571. // replace it with something as the default freeform content handler. Failure to
  2572. // do this will result in errors in the default block parser.
  2573. // see: https://github.com/WordPress/gutenberg/issues/33097
  2574. (0,external_wp_blocks_namespaceObject.setFreeformContentHandlerName)('core/html');
  2575. const SidebarControl = getSidebarControl(blockEditorSettings);
  2576. build_module_wp.customize.sectionConstructor.sidebar = getSidebarSection();
  2577. build_module_wp.customize.controlConstructor.sidebar_block_editor = SidebarControl;
  2578. const container = document.createElement('div');
  2579. document.body.appendChild(container);
  2580. build_module_wp.customize.bind('ready', () => {
  2581. const sidebarControls = [];
  2582. build_module_wp.customize.control.each(control => {
  2583. if (control instanceof SidebarControl) {
  2584. sidebarControls.push(control);
  2585. }
  2586. });
  2587. (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(CustomizeWidgets, {
  2588. api: build_module_wp.customize,
  2589. sidebarControls: sidebarControls,
  2590. blockEditorSettings: blockEditorSettings
  2591. }), container);
  2592. });
  2593. }
  2594. }();
  2595. (window.wp = window.wp || {}).customizeWidgets = __webpack_exports__;
  2596. /******/ })()
  2597. ;