PluginProbe
Gutenberg / 13.5.1
Gutenberg v13.5.1
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
gutenberg / build / customize-widgets / index.js

index.js in Gutenberg 13.5.1, at build/customize-widgets/index.js

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