@wordpress/customize-widgets 4.15.0 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/block-appender/index.js +6 -8
- package/build/components/block-appender/index.js.map +1 -1
- package/build/components/block-inspector-button/index.js +3 -9
- package/build/components/block-inspector-button/index.js.map +1 -1
- package/build/components/customize-widgets/index.js +4 -12
- package/build/components/customize-widgets/index.js.map +1 -1
- package/build/components/customize-widgets/use-clear-selected-block.js +12 -15
- package/build/components/customize-widgets/use-clear-selected-block.js.map +1 -1
- package/build/components/error-boundary/index.js +1 -14
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/focus-control/index.js +1 -12
- package/build/components/focus-control/index.js.map +1 -1
- package/build/components/focus-control/use-blocks-focus-control.js +3 -9
- package/build/components/focus-control/use-blocks-focus-control.js.map +1 -1
- package/build/components/header/index.js +7 -18
- package/build/components/header/index.js.map +1 -1
- package/build/components/inserter/index.js +1 -10
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/use-inserter.js +1 -6
- package/build/components/inserter/use-inserter.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +1 -2
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -9
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +4 -20
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -16
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/more-menu/index.js +2 -15
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/sidebar-block-editor/index.js +5 -22
- package/build/components/sidebar-block-editor/index.js.map +1 -1
- package/build/components/sidebar-block-editor/sidebar-adapter.js +13 -75
- package/build/components/sidebar-block-editor/sidebar-adapter.js.map +1 -1
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js +1 -8
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js.map +1 -1
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js +14 -24
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js.map +1 -1
- package/build/components/sidebar-controls/index.js +1 -5
- package/build/components/sidebar-controls/index.js.map +1 -1
- package/build/components/welcome-guide/index.js +1 -6
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/controls/inserter-outer-section.js +15 -24
- package/build/controls/inserter-outer-section.js.map +1 -1
- package/build/controls/inspector-section.js +0 -12
- package/build/controls/inspector-section.js.map +1 -1
- package/build/controls/sidebar-control.js +1 -12
- package/build/controls/sidebar-control.js.map +1 -1
- package/build/controls/sidebar-section.js +3 -14
- package/build/controls/sidebar-section.js.map +1 -1
- package/build/filters/index.js +0 -2
- package/build/filters/index.js.map +1 -1
- package/build/filters/move-to-sidebar.js +7 -17
- package/build/filters/move-to-sidebar.js.map +1 -1
- package/build/filters/replace-media-upload.js +1 -3
- package/build/filters/replace-media-upload.js.map +1 -1
- package/build/filters/wide-widget-display.js +3 -5
- package/build/filters/wide-widget-display.js.map +1 -1
- package/build/index.js +5 -20
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +0 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +0 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +1 -10
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -5
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -10
- package/build/store/selectors.js.map +1 -1
- package/build/utils.js +8 -18
- package/build/utils.js.map +1 -1
- package/build-module/components/block-appender/index.js +5 -5
- package/build-module/components/block-appender/index.js.map +1 -1
- package/build-module/components/block-inspector-button/index.js +2 -5
- package/build-module/components/block-inspector-button/index.js.map +1 -1
- package/build-module/components/customize-widgets/index.js +4 -4
- package/build-module/components/customize-widgets/index.js.map +1 -1
- package/build-module/components/customize-widgets/use-clear-selected-block.js +13 -12
- package/build-module/components/customize-widgets/use-clear-selected-block.js.map +1 -1
- package/build-module/components/error-boundary/index.js +0 -8
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/focus-control/index.js +1 -8
- package/build-module/components/focus-control/index.js.map +1 -1
- package/build-module/components/focus-control/use-blocks-focus-control.js +3 -4
- package/build-module/components/focus-control/use-blocks-focus-control.js.map +1 -1
- package/build-module/components/header/index.js +8 -11
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/inserter/index.js +1 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/use-inserter.js +1 -3
- package/build-module/components/inserter/use-inserter.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -6
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -13
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -5
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -9
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/more-menu/index.js +2 -6
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/sidebar-block-editor/index.js +5 -9
- package/build-module/components/sidebar-block-editor/index.js.map +1 -1
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js +12 -72
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js.map +1 -1
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js +1 -2
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js.map +1 -1
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js +15 -20
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js.map +1 -1
- package/build-module/components/sidebar-controls/index.js +0 -1
- package/build-module/components/sidebar-controls/index.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +0 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/controls/inserter-outer-section.js +15 -20
- package/build-module/controls/inserter-outer-section.js.map +1 -1
- package/build-module/controls/inspector-section.js +0 -11
- package/build-module/controls/inspector-section.js.map +1 -1
- package/build-module/controls/sidebar-control.js +1 -8
- package/build-module/controls/sidebar-control.js.map +1 -1
- package/build-module/controls/sidebar-section.js +3 -12
- package/build-module/controls/sidebar-section.js.map +1 -1
- package/build-module/filters/index.js.map +1 -1
- package/build-module/filters/move-to-sidebar.js +7 -10
- package/build-module/filters/move-to-sidebar.js.map +1 -1
- package/build-module/filters/replace-media-upload.js +0 -2
- package/build-module/filters/replace-media-upload.js.map +1 -1
- package/build-module/filters/wide-widget-display.js +2 -3
- package/build-module/filters/wide-widget-display.js.map +1 -1
- package/build-module/index.js +5 -10
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +3 -3
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +10 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils.js +9 -14
- package/build-module/utils.js.map +1 -1
- package/package.json +22 -22
- package/src/store/selectors.js +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,33 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = BlockAppender;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
-
|
|
12
9
|
var _data = require("@wordpress/data");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* WordPress dependencies
|
|
16
12
|
*/
|
|
13
|
+
|
|
17
14
|
function BlockAppender(props) {
|
|
18
15
|
const ref = (0, _element.useRef)();
|
|
19
|
-
const isBlocksListEmpty = (0, _data.useSelect)(select => select(_blockEditor.store).getBlockCount() === 0);
|
|
20
|
-
// being lost when emptying the widget area.
|
|
16
|
+
const isBlocksListEmpty = (0, _data.useSelect)(select => select(_blockEditor.store).getBlockCount() === 0);
|
|
21
17
|
|
|
18
|
+
// Move the focus to the block appender to prevent focus from
|
|
19
|
+
// being lost when emptying the widget area.
|
|
22
20
|
(0, _element.useEffect)(() => {
|
|
23
21
|
if (isBlocksListEmpty && ref.current) {
|
|
24
22
|
const {
|
|
25
23
|
ownerDocument
|
|
26
24
|
} = ref.current;
|
|
27
|
-
|
|
28
25
|
if (!ownerDocument.activeElement || ownerDocument.activeElement === ownerDocument.body) {
|
|
29
26
|
ref.current.focus();
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
}, [isBlocksListEmpty]);
|
|
33
|
-
return (0, _element.createElement)(_blockEditor.ButtonBlockAppender, {
|
|
30
|
+
return (0, _element.createElement)(_blockEditor.ButtonBlockAppender, {
|
|
31
|
+
...props,
|
|
34
32
|
ref: ref
|
|
35
33
|
});
|
|
36
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_blockEditor","_data","BlockAppender","props","ref","useRef","isBlocksListEmpty","useSelect","select","blockEditorStore","getBlockCount","useEffect","current","ownerDocument","activeElement","body","focus","createElement","ButtonBlockAppender"],"sources":["@wordpress/customize-widgets/src/components/block-appender/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport {\n\tButtonBlockAppender,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function BlockAppender( props ) {\n\tconst ref = useRef();\n\tconst isBlocksListEmpty = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockCount() === 0\n\t);\n\n\t// Move the focus to the block appender to prevent focus from\n\t// being lost when emptying the widget area.\n\tuseEffect( () => {\n\t\tif ( isBlocksListEmpty && ref.current ) {\n\t\t\tconst { ownerDocument } = ref.current;\n\n\t\t\tif (\n\t\t\t\t! ownerDocument.activeElement ||\n\t\t\t\townerDocument.activeElement === ownerDocument.body\n\t\t\t) {\n\t\t\t\tref.current.focus();\n\t\t\t}\n\t\t}\n\t}, [ isBlocksListEmpty ] );\n\n\treturn <ButtonBlockAppender { ...props } ref={ ref } />;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAIA,IAAAE,KAAA,GAAAF,OAAA;AARA;AACA;AACA;;AAQe,SAASG,aAAaA,CAAEC,KAAK,EAAG;EAC9C,MAAMC,GAAG,GAAG,IAAAC,eAAM,EAAC,CAAC;EACpB,MAAMC,iBAAiB,GAAG,IAAAC,eAAS,EAChCC,MAAM,IAAMA,MAAM,CAAEC,kBAAiB,CAAC,CAACC,aAAa,CAAC,CAAC,KAAK,CAC9D,CAAC;;EAED;EACA;EACA,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKL,iBAAiB,IAAIF,GAAG,CAACQ,OAAO,EAAG;MACvC,MAAM;QAAEC;MAAc,CAAC,GAAGT,GAAG,CAACQ,OAAO;MAErC,IACC,CAAEC,aAAa,CAACC,aAAa,IAC7BD,aAAa,CAACC,aAAa,KAAKD,aAAa,CAACE,IAAI,EACjD;QACDX,GAAG,CAACQ,OAAO,CAACI,KAAK,CAAC,CAAC;MACpB;IACD;EACD,CAAC,EAAE,CAAEV,iBAAiB,CAAG,CAAC;EAE1B,OAAO,IAAAR,QAAA,CAAAmB,aAAA,EAACjB,YAAA,CAAAkB,mBAAmB;IAAA,GAAMf,KAAK;IAAGC,GAAG,EAAGA;EAAK,CAAE,CAAC;AACxD"}
|
|
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _i18n = require("@wordpress/i18n");
|
|
11
|
-
|
|
12
9
|
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
10
|
var _data = require("@wordpress/data");
|
|
15
|
-
|
|
16
11
|
var _blockEditor = require("@wordpress/block-editor");
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* WordPress dependencies
|
|
20
14
|
*/
|
|
15
|
+
|
|
21
16
|
function BlockInspectorButton({
|
|
22
17
|
inspector,
|
|
23
18
|
closeMenu,
|
|
@@ -30,14 +25,13 @@ function BlockInspectorButton({
|
|
|
30
25
|
// Open the inspector.
|
|
31
26
|
inspector.open({
|
|
32
27
|
returnFocusWhenClose: selectedBlock
|
|
33
|
-
});
|
|
34
|
-
|
|
28
|
+
});
|
|
29
|
+
// Then close the dropdown menu.
|
|
35
30
|
closeMenu();
|
|
36
31
|
},
|
|
37
32
|
...props
|
|
38
33
|
}, (0, _i18n.__)('Show more settings'));
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
var _default = BlockInspectorButton;
|
|
42
36
|
exports.default = _default;
|
|
43
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_components","_data","_blockEditor","BlockInspectorButton","inspector","closeMenu","props","selectedBlockClientId","useSelect","select","blockEditorStore","getSelectedBlockClientId","selectedBlock","useMemo","document","getElementById","createElement","MenuItem","onClick","open","returnFocusWhenClose","__","_default","exports","default"],"sources":["@wordpress/customize-widgets/src/components/block-inspector-button/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction BlockInspectorButton( { inspector, closeMenu, ...props } ) {\n\tconst selectedBlockClientId = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSelectedBlockClientId(),\n\t\t[]\n\t);\n\n\tconst selectedBlock = useMemo(\n\t\t() => document.getElementById( `block-${ selectedBlockClientId }` ),\n\t\t[ selectedBlockClientId ]\n\t);\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\t// Open the inspector.\n\t\t\t\tinspector.open( {\n\t\t\t\t\treturnFocusWhenClose: selectedBlock,\n\t\t\t\t} );\n\t\t\t\t// Then close the dropdown menu.\n\t\t\t\tcloseMenu();\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ __( 'Show more settings' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default BlockInspectorButton;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAPA;AACA;AACA;;AAOA,SAASK,oBAAoBA,CAAE;EAAEC,SAAS;EAAEC,SAAS;EAAE,GAAGC;AAAM,CAAC,EAAG;EACnE,MAAMC,qBAAqB,GAAG,IAAAC,eAAS,EACpCC,MAAM,IAAMA,MAAM,CAAEC,kBAAiB,CAAC,CAACC,wBAAwB,CAAC,CAAC,EACnE,EACD,CAAC;EAED,MAAMC,aAAa,GAAG,IAAAC,gBAAO,EAC5B,MAAMC,QAAQ,CAACC,cAAc,CAAG,SAASR,qBAAuB,EAAE,CAAC,EACnE,CAAEA,qBAAqB,CACxB,CAAC;EAED,OACC,IAAAV,QAAA,CAAAmB,aAAA,EAAChB,WAAA,CAAAiB,QAAQ;IACRC,OAAO,EAAGA,CAAA,KAAM;MACf;MACAd,SAAS,CAACe,IAAI,CAAE;QACfC,oBAAoB,EAAER;MACvB,CAAE,CAAC;MACH;MACAP,SAAS,CAAC,CAAC;IACZ,CAAG;IAAA,GACEC;EAAK,GAER,IAAAe,QAAE,EAAE,oBAAqB,CAClB,CAAC;AAEb;AAAC,IAAAC,QAAA,GAEcnB,oBAAoB;AAAAoB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = CustomizeWidgets;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
10
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
15
|
-
|
|
16
11
|
var _errorBoundary = _interopRequireDefault(require("../error-boundary"));
|
|
17
|
-
|
|
18
12
|
var _sidebarBlockEditor = _interopRequireDefault(require("../sidebar-block-editor"));
|
|
19
|
-
|
|
20
13
|
var _focusControl = _interopRequireDefault(require("../focus-control"));
|
|
21
|
-
|
|
22
14
|
var _sidebarControls = _interopRequireDefault(require("../sidebar-controls"));
|
|
23
|
-
|
|
24
15
|
var _useClearSelectedBlock = _interopRequireDefault(require("./use-clear-selected-block"));
|
|
25
|
-
|
|
26
16
|
/**
|
|
27
17
|
* WordPress dependencies
|
|
28
18
|
*/
|
|
@@ -30,6 +20,7 @@ var _useClearSelectedBlock = _interopRequireDefault(require("./use-clear-selecte
|
|
|
30
20
|
/**
|
|
31
21
|
* Internal dependencies
|
|
32
22
|
*/
|
|
23
|
+
|
|
33
24
|
function CustomizeWidgets({
|
|
34
25
|
api,
|
|
35
26
|
sidebarControls,
|
|
@@ -55,9 +46,10 @@ function CustomizeWidgets({
|
|
|
55
46
|
sidebar: activeSidebarControl.sidebarAdapter,
|
|
56
47
|
inserter: activeSidebarControl.inserter,
|
|
57
48
|
inspector: activeSidebarControl.inspector
|
|
58
|
-
})), activeSidebarControl.container[0]);
|
|
59
|
-
// so that the popovers will appear above both of them.
|
|
49
|
+
})), activeSidebarControl.container[0]);
|
|
60
50
|
|
|
51
|
+
// We have to portal this to the parent of both the editor and the inspector,
|
|
52
|
+
// so that the popovers will appear above both of them.
|
|
61
53
|
const popover = parentContainer && (0, _element.createPortal)((0, _element.createElement)("div", {
|
|
62
54
|
className: "customize-widgets-popover",
|
|
63
55
|
ref: popoverRef
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_components","_keyboardShortcuts","_errorBoundary","_interopRequireDefault","_sidebarBlockEditor","_focusControl","_sidebarControls","_useClearSelectedBlock","CustomizeWidgets","api","sidebarControls","blockEditorSettings","activeSidebarControl","setActiveSidebarControl","useState","parentContainer","document","getElementById","popoverRef","useRef","useClearSelectedBlock","useEffect","unsubscribers","map","sidebarControl","subscribe","expanded","forEach","unsubscriber","activeSidebar","createPortal","createElement","default","key","id","sidebar","sidebarAdapter","inserter","inspector","container","popover","className","ref","Popover","Slot","ShortcutProvider","SlotFillProvider"],"sources":["@wordpress/customize-widgets/src/components/customize-widgets/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef, createPortal } from '@wordpress/element';\nimport { SlotFillProvider, Popover } from '@wordpress/components';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport ErrorBoundary from '../error-boundary';\nimport SidebarBlockEditor from '../sidebar-block-editor';\nimport FocusControl from '../focus-control';\nimport SidebarControls from '../sidebar-controls';\nimport useClearSelectedBlock from './use-clear-selected-block';\n\nexport default function CustomizeWidgets( {\n\tapi,\n\tsidebarControls,\n\tblockEditorSettings,\n} ) {\n\tconst [ activeSidebarControl, setActiveSidebarControl ] = useState( null );\n\tconst parentContainer = document.getElementById(\n\t\t'customize-theme-controls'\n\t);\n\tconst popoverRef = useRef();\n\n\tuseClearSelectedBlock( activeSidebarControl, popoverRef );\n\n\tuseEffect( () => {\n\t\tconst unsubscribers = sidebarControls.map( ( sidebarControl ) =>\n\t\t\tsidebarControl.subscribe( ( expanded ) => {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tsetActiveSidebarControl( sidebarControl );\n\t\t\t\t}\n\t\t\t} )\n\t\t);\n\n\t\treturn () => {\n\t\t\tunsubscribers.forEach( ( unsubscriber ) => unsubscriber() );\n\t\t};\n\t}, [ sidebarControls ] );\n\n\tconst activeSidebar =\n\t\tactiveSidebarControl &&\n\t\tcreatePortal(\n\t\t\t<ErrorBoundary>\n\t\t\t\t<SidebarBlockEditor\n\t\t\t\t\tkey={ activeSidebarControl.id }\n\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\tsidebar={ activeSidebarControl.sidebarAdapter }\n\t\t\t\t\tinserter={ activeSidebarControl.inserter }\n\t\t\t\t\tinspector={ activeSidebarControl.inspector }\n\t\t\t\t/>\n\t\t\t</ErrorBoundary>,\n\t\t\tactiveSidebarControl.container[ 0 ]\n\t\t);\n\n\t// We have to portal this to the parent of both the editor and the inspector,\n\t// so that the popovers will appear above both of them.\n\tconst popover =\n\t\tparentContainer &&\n\t\tcreatePortal(\n\t\t\t<div className=\"customize-widgets-popover\" ref={ popoverRef }>\n\t\t\t\t<Popover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<ShortcutProvider>\n\t\t\t<SlotFillProvider>\n\t\t\t\t<SidebarControls\n\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\tactiveSidebarControl={ activeSidebarControl }\n\t\t\t\t>\n\t\t\t\t\t<FocusControl\n\t\t\t\t\t\tapi={ api }\n\t\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ activeSidebar }\n\t\t\t\t\t\t{ popover }\n\t\t\t\t\t</FocusControl>\n\t\t\t\t</SidebarControls>\n\t\t\t</SlotFillProvider>\n\t\t</ShortcutProvider>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAKA,IAAAG,cAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,aAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,gBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,sBAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AAdA;AACA;AACA;;AAKA;AACA;AACA;;AAOe,SAASS,gBAAgBA,CAAE;EACzCC,GAAG;EACHC,eAAe;EACfC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,oBAAoB,EAAEC,uBAAuB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,IAAK,CAAC;EAC1E,MAAMC,eAAe,GAAGC,QAAQ,CAACC,cAAc,CAC9C,0BACD,CAAC;EACD,MAAMC,UAAU,GAAG,IAAAC,eAAM,EAAC,CAAC;EAE3B,IAAAC,8BAAqB,EAAER,oBAAoB,EAAEM,UAAW,CAAC;EAEzD,IAAAG,kBAAS,EAAE,MAAM;IAChB,MAAMC,aAAa,GAAGZ,eAAe,CAACa,GAAG,CAAIC,cAAc,IAC1DA,cAAc,CAACC,SAAS,CAAIC,QAAQ,IAAM;MACzC,IAAKA,QAAQ,EAAG;QACfb,uBAAuB,CAAEW,cAAe,CAAC;MAC1C;IACD,CAAE,CACH,CAAC;IAED,OAAO,MAA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AAiB,GAEjCmB,aAAa,EACbW,OACW,CACE,CACA,CACD,CAAC;AAErB"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = useClearSelectedBlock;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
9
|
var _blockEditor = require("@wordpress/block-editor");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* WordPress dependencies
|
|
16
12
|
*/
|
|
@@ -45,27 +41,28 @@ function useClearSelectedBlock(sidebarControl, popoverRef) {
|
|
|
45
41
|
const container = sidebarControl.container[0];
|
|
46
42
|
const ownerDocument = container.ownerDocument;
|
|
47
43
|
const ownerWindow = ownerDocument.defaultView;
|
|
48
|
-
|
|
49
44
|
function handleClearSelectedBlock(element) {
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
if (
|
|
46
|
+
// 1. Make sure there are blocks being selected.
|
|
47
|
+
(hasSelectedBlock() || hasMultiSelection()) &&
|
|
48
|
+
// 2. The element should exist in the DOM (not deleted).
|
|
49
|
+
element && ownerDocument.contains(element) &&
|
|
50
|
+
// 3. It should also not exist in the container, the popover, nor the dialog.
|
|
51
|
+
!container.contains(element) && !popoverRef.current.contains(element) && !element.closest('[role="dialog"]') &&
|
|
52
|
+
// 4. The inspector should not be opened.
|
|
54
53
|
!inspector.expanded()) {
|
|
55
54
|
clearSelectedBlock();
|
|
56
55
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
56
|
+
}
|
|
59
57
|
|
|
58
|
+
// Handle mouse down in the same document.
|
|
60
59
|
function handleMouseDown(event) {
|
|
61
60
|
handleClearSelectedBlock(event.target);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
}
|
|
62
|
+
// Handle focusing outside the current document, like to iframes.
|
|
65
63
|
function handleBlur() {
|
|
66
64
|
handleClearSelectedBlock(ownerDocument.activeElement);
|
|
67
65
|
}
|
|
68
|
-
|
|
69
66
|
ownerDocument.addEventListener('mousedown', handleMouseDown);
|
|
70
67
|
ownerWindow.addEventListener('blur', handleBlur);
|
|
71
68
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_blockEditor","useClearSelectedBlock","sidebarControl","popoverRef","hasSelectedBlock","hasMultiSelection","useSelect","blockEditorStore","clearSelectedBlock","useDispatch","useEffect","current","inspector","container","ownerDocument","ownerWindow","defaultView","handleClearSelectedBlock","element","contains","closest","expanded","handleMouseDown","event","target","handleBlur","activeElement","addEventListener","removeEventListener"],"sources":["@wordpress/customize-widgets/src/components/customize-widgets/use-clear-selected-block.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * We can't just use <BlockSelectionClearer> because the customizer has\n * many root nodes rather than just one in the post editor.\n * We need to listen to the focus events in all those roots, and also in\n * the preview iframe.\n * This hook will clear the selected block when focusing outside the editor,\n * with a few exceptions:\n * 1. Focusing on popovers.\n * 2. Focusing on the inspector.\n * 3. Focusing on any modals/dialogs.\n * These cases are normally triggered by user interactions from the editor,\n * not by explicitly focusing outside the editor, hence no need for clearing.\n *\n * @param {Object} sidebarControl The sidebar control instance.\n * @param {Object} popoverRef The ref object of the popover node container.\n */\nexport default function useClearSelectedBlock( sidebarControl, popoverRef ) {\n\tconst { hasSelectedBlock, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( popoverRef.current && sidebarControl ) {\n\t\t\tconst inspector = sidebarControl.inspector;\n\t\t\tconst container = sidebarControl.container[ 0 ];\n\t\t\tconst ownerDocument = container.ownerDocument;\n\t\t\tconst ownerWindow = ownerDocument.defaultView;\n\n\t\t\tfunction handleClearSelectedBlock( element ) {\n\t\t\t\tif (\n\t\t\t\t\t// 1. Make sure there are blocks being selected.\n\t\t\t\t\t( hasSelectedBlock() || hasMultiSelection() ) &&\n\t\t\t\t\t// 2. The element should exist in the DOM (not deleted).\n\t\t\t\t\telement &&\n\t\t\t\t\townerDocument.contains( element ) &&\n\t\t\t\t\t// 3. It should also not exist in the container, the popover, nor the dialog.\n\t\t\t\t\t! container.contains( element ) &&\n\t\t\t\t\t! popoverRef.current.contains( element ) &&\n\t\t\t\t\t! element.closest( '[role=\"dialog\"]' ) &&\n\t\t\t\t\t// 4. The inspector should not be opened.\n\t\t\t\t\t! inspector.expanded()\n\t\t\t\t) {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle mouse down in the same document.\n\t\t\tfunction handleMouseDown( event ) {\n\t\t\t\thandleClearSelectedBlock( event.target );\n\t\t\t}\n\t\t\t// Handle focusing outside the current document, like to iframes.\n\t\t\tfunction handleBlur() {\n\t\t\t\thandleClearSelectedBlock( ownerDocument.activeElement );\n\t\t\t}\n\n\t\t\townerDocument.addEventListener( 'mousedown', handleMouseDown );\n\t\t\townerWindow.addEventListener( 'blur', handleBlur );\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\thandleMouseDown\n\t\t\t\t);\n\t\t\t\townerWindow.removeEventListener( 'blur', handleBlur );\n\t\t\t};\n\t\t}\n\t}, [\n\t\tpopoverRef,\n\t\tsidebarControl,\n\t\thasSelectedBlock,\n\t\thasMultiSelection,\n\t\tclearSelectedBlock,\n\t] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA;AACA;AACA;AAC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,WAAW,EAAEL,eAAgB,CAAC;MAC9DP,WAAW,CAACY,gBAAgB,CAAE,MAAM,EAAEF,UAAW,CAAC;MAElD,OAAO,MAAM;QACZX,aAAa,CAACc,mBAAmB,CAChC,WAAW,EACXN,eACD,CAAC;QACDP,WAAW,CAACa,mBAAmB,CAAE,MAAM,EAAEH,UAAW,CAAC;MACtD,CAAC;IACF;EACD,CAAC,EAAE,CACFtB,UAAU,EACVD,cAAc,EACdE,gBAAgB,EAChBC,iBAAiB,EACjBG,kBAAkB,CACjB,CAAC;AACJ"}
|
|
@@ -4,22 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _i18n = require("@wordpress/i18n");
|
|
11
|
-
|
|
12
9
|
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
10
|
var _blockEditor = require("@wordpress/block-editor");
|
|
15
|
-
|
|
16
11
|
var _compose = require("@wordpress/compose");
|
|
17
|
-
|
|
18
12
|
var _hooks = require("@wordpress/hooks");
|
|
19
|
-
|
|
20
13
|
/**
|
|
21
14
|
* WordPress dependencies
|
|
22
15
|
*/
|
|
16
|
+
|
|
23
17
|
function CopyButton({
|
|
24
18
|
text,
|
|
25
19
|
children
|
|
@@ -30,7 +24,6 @@ function CopyButton({
|
|
|
30
24
|
ref: ref
|
|
31
25
|
}, children);
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
class ErrorBoundary extends _element.Component {
|
|
35
28
|
constructor() {
|
|
36
29
|
super(...arguments);
|
|
@@ -38,23 +31,19 @@ class ErrorBoundary extends _element.Component {
|
|
|
38
31
|
error: null
|
|
39
32
|
};
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
componentDidCatch(error) {
|
|
43
35
|
this.setState({
|
|
44
36
|
error
|
|
45
37
|
});
|
|
46
38
|
(0, _hooks.doAction)('editor.ErrorBoundary.errorLogged', error);
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
render() {
|
|
50
41
|
const {
|
|
51
42
|
error
|
|
52
43
|
} = this.state;
|
|
53
|
-
|
|
54
44
|
if (!error) {
|
|
55
45
|
return this.props.children;
|
|
56
46
|
}
|
|
57
|
-
|
|
58
47
|
return (0, _element.createElement)(_blockEditor.Warning, {
|
|
59
48
|
className: "customize-widgets-error-boundary",
|
|
60
49
|
actions: [(0, _element.createElement)(CopyButton, {
|
|
@@ -63,8 +52,6 @@ class ErrorBoundary extends _element.Component {
|
|
|
63
52
|
}, (0, _i18n.__)('Copy Error'))]
|
|
64
53
|
}, (0, _i18n.__)('The editor has encountered an unexpected error.'));
|
|
65
54
|
}
|
|
66
|
-
|
|
67
55
|
}
|
|
68
|
-
|
|
69
56
|
exports.default = ErrorBoundary;
|
|
70
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_components","_blockEditor","_compose","_hooks","CopyButton","text","children","ref","useCopyToClipboard","createElement","Button","variant","ErrorBoundary","Component","constructor","arguments","state","error","componentDidCatch","setState","doAction","render","props","Warning","className","actions","key","stack","__","exports","default"],"sources":["@wordpress/customize-widgets/src/components/error-boundary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tthis.setState( { error } );\n\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error );\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tclassName=\"customize-widgets-error-boundary\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ __( 'The editor has encountered an unexpected error.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AARA;AACA;AACA;;AAQA,SAASM,UAAUA,CAAE;EAAEC,IAAI;EAAEC;AAAS,CAAC,EAAG;EACzC,MAAMC,GAAG,GAAG,IAAAC,2BAAkB,EAAEH,IAAK,CAAC;EACtC,OACC,IAAAR,QAAA,CAAAY,aAAA,EAACT,WAAA,CAAAU,MAAM;IAACC,OAAO,EAAC,WAAW;IAACJ,GAAG,EAAGA;EAAK,GACpCD,QACK,CAAC;AAEX;AAEe,MAAMM,aAAa,SAASC,kBAAS,CAAC;EACpDC,WAAWA,CAAA,EAAG;IACb,KAAK,CAAE,GAAGC,SAAU,CAAC;IACrB,IAAI,CAACC,KAAK,GAAG;MACZC,KAAK,EAAE;IACR,CAAC;EACF;EAEAC,iBAAiBA,CAAED,KAAK,EAAG;IAC1B,IAAI,CAACE,QAAQ,CAAE;MAAEF;IAAM,CAAE,CAAC;IAE1B,IAAAG,eAAQ,EAAE,kCAAkC,EAAEH,KAAM,CAAC;EACtD;EAEAI,MAAMA,CAAA,EAAG;IACR,MAAM;MAAEJ;IAAM,CAAC,GAAG,IAAI,CAACD,KAAK;IAC5B,IAAK,CAAEC,KAAK,EAAG;MACd,OAAO,IAAI,CAACK,KAAK,CAAChB,QAAQ;IAC3B;IAEA,OACC,IAAAT,QAAA,CAAAY,aAAA,EAACR,YAAA,CAAAsB,OAAO;MACPC,SAAS,EAAC,kCAAkC;MAC5CC,OAAO,EAAG,CACT,IAAA5B,QAAA,CAAAY,aAAA,EAACL,UAAU;QAACsB,GAAG,EAAC,YAAY;QAACrB,IAAI,EAAGY,KAAK,CAACU;MAAO,GAC9C,IAAAC,QAAE,EAAE,YAAa,CACR,CAAC;IACX,GAED,IAAAA,QAAE,EAAE,iDAAkD,CAChD,CAAC;EAEZ;AACD;AAACC,OAAA,CAAAC,OAAA,GAAAlB,aAAA"}
|
|
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = FocusControl;
|
|
7
7
|
exports.useFocusControl = void 0;
|
|
8
|
-
|
|
9
8
|
var _element = require("@wordpress/element");
|
|
10
|
-
|
|
11
9
|
var _utils = require("../../utils");
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* WordPress dependencies
|
|
15
12
|
*/
|
|
@@ -17,8 +14,8 @@ var _utils = require("../../utils");
|
|
|
17
14
|
/**
|
|
18
15
|
* Internal dependencies
|
|
19
16
|
*/
|
|
20
|
-
const FocusControlContext = (0, _element.createContext)();
|
|
21
17
|
|
|
18
|
+
const FocusControlContext = (0, _element.createContext)();
|
|
22
19
|
function FocusControl({
|
|
23
20
|
api,
|
|
24
21
|
sidebarControls,
|
|
@@ -30,7 +27,6 @@ function FocusControl({
|
|
|
30
27
|
const focusWidget = (0, _element.useCallback)(widgetId => {
|
|
31
28
|
for (const sidebarControl of sidebarControls) {
|
|
32
29
|
const widgets = sidebarControl.setting.get();
|
|
33
|
-
|
|
34
30
|
if (widgets.includes(widgetId)) {
|
|
35
31
|
sidebarControl.sectionInstance.expand({
|
|
36
32
|
// Schedule it after the complete callback so that
|
|
@@ -42,7 +38,6 @@ function FocusControl({
|
|
|
42
38
|
current: widgetId
|
|
43
39
|
});
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
});
|
|
47
42
|
break;
|
|
48
43
|
}
|
|
@@ -53,18 +48,14 @@ function FocusControl({
|
|
|
53
48
|
const widgetId = (0, _utils.settingIdToWidgetId)(settingId);
|
|
54
49
|
focusWidget(widgetId);
|
|
55
50
|
}
|
|
56
|
-
|
|
57
51
|
let previewBound = false;
|
|
58
|
-
|
|
59
52
|
function handleReady() {
|
|
60
53
|
api.previewer.preview.bind('focus-control-for-setting', handleFocus);
|
|
61
54
|
previewBound = true;
|
|
62
55
|
}
|
|
63
|
-
|
|
64
56
|
api.previewer.bind('ready', handleReady);
|
|
65
57
|
return () => {
|
|
66
58
|
api.previewer.unbind('ready', handleReady);
|
|
67
|
-
|
|
68
59
|
if (previewBound) {
|
|
69
60
|
api.previewer.preview.unbind('focus-control-for-setting', handleFocus);
|
|
70
61
|
}
|
|
@@ -75,8 +66,6 @@ function FocusControl({
|
|
|
75
66
|
value: context
|
|
76
67
|
}, children);
|
|
77
68
|
}
|
|
78
|
-
|
|
79
69
|
const useFocusControl = () => (0, _element.useContext)(FocusControlContext);
|
|
80
|
-
|
|
81
70
|
exports.useFocusControl = useFocusControl;
|
|
82
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_utils","FocusControlContext","createContext","FocusControl","api","sidebarControls","children","focusedWidgetIdRef","setFocusedWidgetIdRef","useState","current","focusWidget","useCallback","widgetId","sidebarControl","widgets","setting","get","includes","sectionInstance","expand","completeCallback","useEffect","handleFocus","settingId","settingIdToWidgetId","previewBound","handleReady","previewer","preview","bind","unbind","context","useMemo","createElement","Provider","value","useFocusControl","useContext","exports"],"sources":["@wordpress/customize-widgets/src/components/focus-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseState,\n\tuseEffect,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { settingIdToWidgetId } from '../../utils';\n\nconst FocusControlContext = createContext();\n\nexport default function FocusControl( { api, sidebarControls, children } ) {\n\tconst [ focusedWidgetIdRef, setFocusedWidgetIdRef ] = useState( {\n\t\tcurrent: null,\n\t} );\n\n\tconst focusWidget = useCallback(\n\t\t( widgetId ) => {\n\t\t\tfor ( const sidebarControl of sidebarControls ) {\n\t\t\t\tconst widgets = sidebarControl.setting.get();\n\n\t\t\t\tif ( widgets.includes( widgetId ) ) {\n\t\t\t\t\tsidebarControl.sectionInstance.expand( {\n\t\t\t\t\t\t// Schedule it after the complete callback so that\n\t\t\t\t\t\t// it won't be overridden by the \"Back\" button focus.\n\t\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t\t// Create a \"ref-like\" object every time to ensure\n\t\t\t\t\t\t\t// the same widget id can also triggers the focus control.\n\t\t\t\t\t\t\tsetFocusedWidgetIdRef( { current: widgetId } );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ sidebarControls ]\n\t);\n\n\tuseEffect( () => {\n\t\tfunction handleFocus( settingId ) {\n\t\t\tconst widgetId = settingIdToWidgetId( settingId );\n\n\t\t\tfocusWidget( widgetId );\n\t\t}\n\n\t\tlet previewBound = false;\n\n\t\tfunction handleReady() {\n\t\t\tapi.previewer.preview.bind(\n\t\t\t\t'focus-control-for-setting',\n\t\t\t\thandleFocus\n\t\t\t);\n\t\t\tpreviewBound = true;\n\t\t}\n\n\t\tapi.previewer.bind( 'ready', handleReady );\n\n\t\treturn () => {\n\t\t\tapi.previewer.unbind( 'ready', handleReady );\n\t\t\tif ( previewBound ) {\n\t\t\t\tapi.previewer.preview.unbind(\n\t\t\t\t\t'focus-control-for-setting',\n\t\t\t\t\thandleFocus\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}, [ api, focusWidget ] );\n\n\tconst context = useMemo(\n\t\t() => [ focusedWidgetIdRef, focusWidget ],\n\t\t[ focusedWidgetIdRef, focusWidget ]\n\t);\n\n\treturn (\n\t\t<FocusControlContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</FocusControlContext.Provider>\n\t);\n}\n\nexport const useFocusControl = () => useContext( FocusControlContext );\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAYA,IAAAC,MAAA,GAAAD,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA,MAAME,mBAAmB,GAAG,IAAAC,sBAAa,EAAC,CAAC;AAE5B,SAASC,YAAYA,CAAE;EAAEC,GAAG;EAAEC,eAAe;EAAEC;AAAS,CAAC,EAAG;EAC1E,MAAM,CAAEC,kBAAkB,EAAEC,qBAAqB,CAAE,GAAG,IAAAC,iBAAQ,EAAE;IAC/DC,OAAO,EAAE;EACV,CAAE,CAAC;EAEH,MAAMC,WAAW,GAAG,IAAAC,oBAAW,EAC5BC,QAAQ,IAAM;IACf,KAAM,MAAMC,cAAc,IAAIT,eAAe,EAAG;MAC/C,MAAMU,OAAO,GAAGD,cAAc,CAACE,OAAO,CAACC,GAAG,CAAC,CAAC;MAE5C,IAAKF,OAAO,CAACG,QAAQ,CAAEL,QAAS,CAAC,EAAG;QACnCC,cAAc,CAACK,eAAe,CAACC,MAAM,CAAE;UACtC;UACA;UACAC,gBAAgBA,CAAA,EAAG;YAClB;YACA;YACAb,qBAAqB,CAAE;cAAEE,OAAO,EAAEG;YAAS,CAAE,CAAC;UAC/C;QACD,CAAE,CAAC;QAEH;MACD;IACD;EACD,CAAC,EACD,CAAER,eAAe,CAClB,CAAC;EAED,IAAAiB,kBAAS,EAAE,MAAM;IAChB,SAASC,WAAWA,CAAEC,SAAS,EAAG;MACjC,MAAMX,QAAQ,GAAG,IAAAY,0BAAmB,EAAED,SAAU,CAAC;MAEjDb,WAAW,CAAEE,QAAS,CAAC;IACxB;IAEA,IAAIa,YAAY,GAAG,KAAK;IAExB,SAASC,WAAWA,CAAA,EAAG;MACtBvB,GAAG,CAACwB,SAAS,CAACC,OAAO,CAACC,IAAI,CACzB,2BAA2B,EAC3BP,WACD,CAAC;MACDG,YAAY,GAAG,IAAI;IACpB;IAEAtB,GAAG,CAACwB,SAAS,CAACE,IAAI,CAAE,OAAO,EAAEH,WAAY,CAAC;IAE1C,OAAO,MAAM;MACZvB,GAAG,CAACwB,SAAS,CAACG,MAAM,CAAE,OAAO,EAAEJ,WAAY,CAAC;MAC5C,IAAKD,YAAY,EAAG;QACnBtB,GAAG,CAACwB,SAAS,CAACC,OAAO,CAACE,MAAM,CAC3B,2BAA2B,EAC3BR,WACD,CAAC;MACF;IACD,CAAC;EACF,CAAC,EAAE,CAAEnB,GAAG,EAAEO,WAAW,CAAG,CAAC;EAEzB,MAAMqB,OAAO,GAAG,IAAAC,gBAAO,EACtB,MAAM,CAAE1B,kBAAkB,EAAEI,WAAW,CAAE,EACzC,CAAEJ,kBAAkB,EAAEI,WAAW,CAClC,CAAC;EAED,OACC,IAAAb,QAAA,CAAAoC,aAAA,EAACjC,mBAAmB,CAACkC,QAAQ;IAACC,KAAK,EAAGJ;EAAS,GAC5C1B,QAC2B,CAAC;AAEjC;AAEO,MAAM+B,eAAe,GAAGA,CAAA,KAAM,IAAAC,mBAAU,EAAErC,mBAAoB,CAAC;AAACsC,OAAA,CAAAF,eAAA,GAAAA,eAAA"}
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = useBlocksFocusControl;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
9
|
var _blockEditor = require("@wordpress/block-editor");
|
|
13
|
-
|
|
14
10
|
var _widgets = require("@wordpress/widgets");
|
|
15
|
-
|
|
16
11
|
var _ = require(".");
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* WordPress dependencies
|
|
20
14
|
*/
|
|
@@ -22,6 +16,7 @@ var _ = require(".");
|
|
|
22
16
|
/**
|
|
23
17
|
* Internal dependencies
|
|
24
18
|
*/
|
|
19
|
+
|
|
25
20
|
function useBlocksFocusControl(blocks) {
|
|
26
21
|
const {
|
|
27
22
|
selectBlock
|
|
@@ -34,12 +29,11 @@ function useBlocksFocusControl(blocks) {
|
|
|
34
29
|
(0, _element.useEffect)(() => {
|
|
35
30
|
if (focusedWidgetIdRef.current) {
|
|
36
31
|
const focusedBlock = blocksRef.current.find(block => (0, _widgets.getWidgetIdFromBlock)(block) === focusedWidgetIdRef.current);
|
|
37
|
-
|
|
38
32
|
if (focusedBlock) {
|
|
39
|
-
selectBlock(focusedBlock.clientId);
|
|
33
|
+
selectBlock(focusedBlock.clientId);
|
|
34
|
+
// If the block is already being selected, the DOM node won't
|
|
40
35
|
// get focused again automatically.
|
|
41
36
|
// We select the DOM and focus it manually here.
|
|
42
|
-
|
|
43
37
|
const blockNode = document.querySelector(`[data-block="${focusedBlock.clientId}"]`);
|
|
44
38
|
blockNode?.focus();
|
|
45
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_blockEditor","_widgets","_","useBlocksFocusControl","blocks","selectBlock","useDispatch","blockEditorStore","focusedWidgetIdRef","useFocusControl","blocksRef","useRef","useEffect","current","focusedBlock","find","block","getWidgetIdFromBlock","clientId","blockNode","document","querySelector","focus"],"sources":["@wordpress/customize-widgets/src/components/focus-control/use-blocks-focus-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport { useFocusControl } from '.';\n\nexport default function useBlocksFocusControl( blocks ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst [ focusedWidgetIdRef ] = useFocusControl();\n\n\tconst blocksRef = useRef( blocks );\n\n\tuseEffect( () => {\n\t\tblocksRef.current = blocks;\n\t}, [ blocks ] );\n\n\tuseEffect( () => {\n\t\tif ( focusedWidgetIdRef.current ) {\n\t\t\tconst focusedBlock = blocksRef.current.find(\n\t\t\t\t( block ) =>\n\t\t\t\t\tgetWidgetIdFromBlock( block ) === focusedWidgetIdRef.current\n\t\t\t);\n\n\t\t\tif ( focusedBlock ) {\n\t\t\t\tselectBlock( focusedBlock.clientId );\n\t\t\t\t// If the block is already being selected, the DOM node won't\n\t\t\t\t// get focused again automatically.\n\t\t\t\t// We select the DOM and focus it manually here.\n\t\t\t\tconst blockNode = document.querySelector(\n\t\t\t\t\t`[data-block=\"${ focusedBlock.clientId }\"]`\n\t\t\t\t);\n\t\t\t\tblockNode?.focus();\n\t\t\t}\n\t\t}\n\t}, [ focusedWidgetIdRef, selectBlock ] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,CAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAMA;AACA;AACA;;AAGe,SAASK,qBAAqBA,CAAEC,MAAM,EAAG;EACvD,MAAM;IAAEC;EAAY,CAAC,GAAG,IAAAC,iBAAW,EAAEC,kBAAiB,CAAC;EACvD,MAAM,CAAEC,kBAAkB,CAAE,GAAG,IAAAC,iBAAe,EAAC,CAAC;EAEhD,MAAMC,SAAS,GAAG,IAAAC,eAAM,EAAEP,MAAO,CAAC;EAElC,IAAAQ,kBAAS,EAAE,MAAM;IAChBF,SAAS,CAACG,OAAO,GAAGT,MAAM;EAC3B,CAAC,EAAE,CAAEA,MAAM,CAAG,CAAC;EAEf,IAAAQ,kBAAS,EAAE,MAAM;IAChB,IAAKJ,kBAAkB,CAACK,OAAO,EAAG;MACjC,MAAMC,YAAY,GAAGJ,SAAS,CAACG,OAAO,CAACE,IAAI,CACxCC,KAAK,IACN,IAAAC,6BAAoB,EAAED,KAAM,CAAC,KAAKR,kBAAkB,CAACK,OACvD,CAAC;MAED,IAAKC,YAAY,EAAG;QACnBT,WAAW,CAAES,YAAY,CAACI,QAAS,CAAC;QACpC;QACA;QACA;QACA,MAAMC,SAAS,GAAGC,QAAQ,CAACC,aAAa,CACtC,gBAAgBP,YAAY,CAACI,QAAU,IACzC,CAAC;QACDC,SAAS,EAAEG,KAAK,CAAC,CAAC;MACnB;IACD;EACD,CAAC,EAAE,CAAEd,kBAAkB,EAAEH,WAAW,CAAG,CAAC;AACzC"}
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
11
|
var _components = require("@wordpress/components");
|
|
17
|
-
|
|
18
12
|
var _blockEditor = require("@wordpress/block-editor");
|
|
19
|
-
|
|
20
13
|
var _keycodes = require("@wordpress/keycodes");
|
|
21
|
-
|
|
22
14
|
var _icons = require("@wordpress/icons");
|
|
23
|
-
|
|
24
15
|
var _inserter = _interopRequireDefault(require("../inserter"));
|
|
25
|
-
|
|
26
16
|
var _moreMenu = _interopRequireDefault(require("../more-menu"));
|
|
27
|
-
|
|
28
17
|
/**
|
|
29
18
|
* External dependencies
|
|
30
19
|
*/
|
|
@@ -36,6 +25,7 @@ var _moreMenu = _interopRequireDefault(require("../more-menu"));
|
|
|
36
25
|
/**
|
|
37
26
|
* Internal dependencies
|
|
38
27
|
*/
|
|
28
|
+
|
|
39
29
|
function Header({
|
|
40
30
|
sidebar,
|
|
41
31
|
inserter,
|
|
@@ -59,10 +49,10 @@ function Header({
|
|
|
59
49
|
"aria-label": (0, _i18n.__)('Document tools')
|
|
60
50
|
}, (0, _element.createElement)(_components.ToolbarButton, {
|
|
61
51
|
icon: !(0, _i18n.isRTL)() ? _icons.undo : _icons.redo
|
|
62
|
-
/* translators: button label text should, if possible, be under 16 characters.
|
|
63
|
-
,
|
|
52
|
+
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
64
53
|
label: (0, _i18n.__)('Undo'),
|
|
65
|
-
shortcut: _keycodes.displayShortcut.primary('z')
|
|
54
|
+
shortcut: _keycodes.displayShortcut.primary('z')
|
|
55
|
+
// If there are no undo levels we don't want to actually disable this
|
|
66
56
|
// button, because it will remove focus for keyboard users.
|
|
67
57
|
// See: https://github.com/WordPress/gutenberg/issues/3486
|
|
68
58
|
,
|
|
@@ -71,10 +61,10 @@ function Header({
|
|
|
71
61
|
className: "customize-widgets-editor-history-button undo-button"
|
|
72
62
|
}), (0, _element.createElement)(_components.ToolbarButton, {
|
|
73
63
|
icon: !(0, _i18n.isRTL)() ? _icons.redo : _icons.undo
|
|
74
|
-
/* translators: button label text should, if possible, be under 16 characters.
|
|
75
|
-
,
|
|
64
|
+
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
76
65
|
label: (0, _i18n.__)('Redo'),
|
|
77
|
-
shortcut: shortcut
|
|
66
|
+
shortcut: shortcut
|
|
67
|
+
// If there are no undo levels we don't want to actually disable this
|
|
78
68
|
// button, because it will remove focus for keyboard users.
|
|
79
69
|
// See: https://github.com/WordPress/gutenberg/issues/3486
|
|
80
70
|
,
|
|
@@ -94,7 +84,6 @@ function Header({
|
|
|
94
84
|
setIsOpened: setIsInserterOpened
|
|
95
85
|
}), inserter.contentContainer[0]));
|
|
96
86
|
}
|
|
97
|
-
|
|
98
87
|
var _default = Header;
|
|
99
88
|
exports.default = _default;
|
|
100
89
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_i18n","_components","_blockEditor","_keycodes","_icons","_inserter","_moreMenu","Header","sidebar","inserter","isInserterOpened","setIsInserterOpened","isFixedToolbarActive","hasUndo","hasRedo","setUndoRedo","useState","shortcut","isAppleOS","displayShortcut","primaryShift","primary","useEffect","subscribeHistory","createElement","Fragment","className","classnames","NavigableToolbar","__","ToolbarButton","icon","isRTL","undoIcon","redoIcon","label","onClick","undo","redo","isPressed","variant","plus","_x","isOpen","default","createPortal","setIsOpened","contentContainer","_default","exports"],"sources":["@wordpress/customize-widgets/src/components/header/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createPortal, useState, useEffect } from '@wordpress/element';\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { NavigableToolbar } from '@wordpress/block-editor';\nimport { displayShortcut, isAppleOS } from '@wordpress/keycodes';\nimport { plus, undo as undoIcon, redo as redoIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport MoreMenu from '../more-menu';\n\nfunction Header( {\n\tsidebar,\n\tinserter,\n\tisInserterOpened,\n\tsetIsInserterOpened,\n\tisFixedToolbarActive,\n} ) {\n\tconst [ [ hasUndo, hasRedo ], setUndoRedo ] = useState( [\n\t\tsidebar.hasUndo(),\n\t\tsidebar.hasRedo(),\n\t] );\n\n\tconst shortcut = isAppleOS()\n\t\t? displayShortcut.primaryShift( 'z' )\n\t\t: displayShortcut.primary( 'y' );\n\n\tuseEffect( () => {\n\t\treturn sidebar.subscribeHistory( () => {\n\t\t\tsetUndoRedo( [ sidebar.hasUndo(), sidebar.hasRedo() ] );\n\t\t} );\n\t}, [ sidebar ] );\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ classnames( 'customize-widgets-header', {\n\t\t\t\t\t'is-fixed-toolbar-active': isFixedToolbarActive,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<NavigableToolbar\n\t\t\t\t\tclassName=\"customize-widgets-header-toolbar\"\n\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ ! isRTL() ? undoIcon : redoIcon }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'Undo' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\t\t\t\taria-disabled={ ! hasUndo }\n\t\t\t\t\t\tonClick={ sidebar.undo }\n\t\t\t\t\t\tclassName=\"customize-widgets-editor-history-button undo-button\"\n\t\t\t\t\t/>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ticon={ ! isRTL() ? redoIcon : undoIcon }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'Redo' ) }\n\t\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\t\t\t\taria-disabled={ ! hasRedo }\n\t\t\t\t\t\tonClick={ sidebar.redo }\n\t\t\t\t\t\tclassName=\"customize-widgets-editor-history-button redo-button\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tclassName=\"customize-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t'Add block',\n\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsInserterOpened( ( isOpen ) => ! isOpen );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</NavigableToolbar>\n\t\t\t</div>\n\n\t\t\t{ createPortal(\n\t\t\t\t<Inserter setIsOpened={ setIsInserterOpened } />,\n\t\t\t\tinserter.contentContainer[ 0 ]\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],"mappings":";;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AALA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAMA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAKA,IAAAQ,SAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,SAAA,GAAAP,sBAAA,CAAAF,OAAA;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAIA,SAASU,MAAMA,CAAE;EAChBC,OAAO;EACPC,QAAQ;EACRC,gBAAgB;EAChBC,mBAAmB;EACnBC;AACD,CAAC,EAAG;EACH,MAAM,CAAE,CAAEC,OAAO,EAAEC,OAAO,CAAE,EAAEC,WAAW,CAAE,G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