You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3221 lines
110 KiB

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