@wordpress/customize-widgets 5.57.0 → 6.1.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/build/components/block-appender/index.cjs +24 -41
- package/build/components/block-appender/index.cjs.map +1 -7
- package/build/components/block-inspector-button/index.cjs +24 -52
- package/build/components/block-inspector-button/index.cjs.map +1 -7
- package/build/components/customize-widgets/index.cjs +76 -95
- package/build/components/customize-widgets/index.cjs.map +1 -7
- package/build/components/customize-widgets/use-clear-selected-block.cjs +58 -67
- package/build/components/customize-widgets/use-clear-selected-block.cjs.map +1 -7
- package/build/components/error-boundary/index.cjs +115 -155
- package/build/components/error-boundary/index.cjs.map +1 -7
- package/build/components/focus-control/index.cjs +44 -84
- package/build/components/focus-control/index.cjs.map +1 -7
- package/build/components/focus-control/use-blocks-focus-control.cjs +28 -49
- package/build/components/focus-control/use-blocks-focus-control.cjs.map +1 -7
- package/build/components/header/index.cjs +84 -122
- package/build/components/header/index.cjs.map +1 -7
- package/build/components/inserter/index.cjs +43 -78
- package/build/components/inserter/index.cjs.map +1 -7
- package/build/components/inserter/use-inserter.cjs +22 -54
- package/build/components/inserter/use-inserter.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
- package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/index.cjs +103 -165
- package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -76
- package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
- package/build/components/keyboard-shortcuts/index.cjs +70 -100
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
- package/build/components/more-menu/index.cjs +103 -151
- package/build/components/more-menu/index.cjs.map +1 -7
- package/build/components/sidebar-block-editor/index.cjs +122 -155
- package/build/components/sidebar-block-editor/index.cjs.map +1 -7
- package/build/components/sidebar-block-editor/sidebar-adapter.cjs +207 -270
- package/build/components/sidebar-block-editor/sidebar-adapter.cjs.map +1 -7
- package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs +40 -50
- package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs.map +1 -7
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs +75 -110
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs.map +1 -7
- package/build/components/sidebar-controls/index.cjs +27 -53
- package/build/components/sidebar-controls/index.cjs.map +1 -7
- package/build/components/welcome-guide/index.cjs +70 -94
- package/build/components/welcome-guide/index.cjs.map +1 -7
- package/build/controls/inserter-outer-section.cjs +68 -110
- package/build/controls/inserter-outer-section.cjs.map +1 -7
- package/build/controls/inspector-section.cjs +57 -90
- package/build/controls/inspector-section.cjs.map +1 -7
- package/build/controls/sidebar-control.cjs +55 -69
- package/build/controls/sidebar-control.cjs.map +1 -7
- package/build/controls/sidebar-section.cjs +79 -103
- package/build/controls/sidebar-section.cjs.map +1 -7
- package/build/filters/index.cjs +8 -5
- package/build/filters/move-to-sidebar.cjs +62 -78
- package/build/filters/move-to-sidebar.cjs.map +1 -7
- package/build/filters/replace-media-upload.cjs +11 -9
- package/build/filters/replace-media-upload.cjs.map +1 -7
- package/build/filters/wide-widget-display.cjs +20 -20
- package/build/filters/wide-widget-display.cjs.map +1 -7
- package/build/index.cjs +84 -91
- package/build/index.cjs.map +1 -7
- package/build/lock-unlock.cjs +10 -35
- package/build/lock-unlock.cjs.map +1 -7
- package/build/store/actions.cjs +49 -32
- package/build/store/actions.cjs.map +1 -7
- package/build/store/constants.cjs +12 -29
- package/build/store/constants.cjs.map +1 -7
- package/build/store/index.cjs +49 -41
- package/build/store/index.cjs.map +1 -7
- package/build/store/reducer.cjs +20 -33
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/selectors.cjs +47 -38
- package/build/store/selectors.cjs.map +1 -7
- package/build/utils.cjs +81 -108
- package/build/utils.cjs.map +1 -7
- package/build-module/components/block-appender/index.mjs +18 -23
- package/build-module/components/block-appender/index.mjs.map +1 -7
- package/build-module/components/block-inspector-button/index.mjs +15 -28
- package/build-module/components/block-inspector-button/index.mjs.map +1 -7
- package/build-module/components/customize-widgets/index.mjs +46 -72
- package/build-module/components/customize-widgets/index.mjs.map +1 -7
- package/build-module/components/customize-widgets/use-clear-selected-block.mjs +52 -46
- package/build-module/components/customize-widgets/use-clear-selected-block.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +103 -128
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/focus-control/index.mjs +37 -66
- package/build-module/components/focus-control/index.mjs.map +1 -7
- package/build-module/components/focus-control/use-blocks-focus-control.mjs +21 -27
- package/build-module/components/focus-control/use-blocks-focus-control.mjs.map +1 -7
- package/build-module/components/header/index.mjs +55 -92
- package/build-module/components/header/index.mjs.map +1 -7
- package/build-module/components/inserter/index.mjs +33 -53
- package/build-module/components/inserter/index.mjs.map +1 -7
- package/build-module/components/inserter/use-inserter.mjs +17 -34
- package/build-module/components/inserter/use-inserter.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
- package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs +75 -139
- package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -55
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
- package/build-module/components/keyboard-shortcuts/index.mjs +62 -79
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
- package/build-module/components/more-menu/index.mjs +76 -128
- package/build-module/components/more-menu/index.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/index.mjs +86 -128
- package/build-module/components/sidebar-block-editor/index.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs +202 -250
- package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs +17 -25
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs.map +1 -7
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs +54 -86
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs.map +1 -7
- package/build-module/components/sidebar-controls/index.mjs +19 -27
- package/build-module/components/sidebar-controls/index.mjs.map +1 -7
- package/build-module/components/welcome-guide/index.mjs +62 -71
- package/build-module/components/welcome-guide/index.mjs.map +1 -7
- package/build-module/controls/inserter-outer-section.mjs +61 -88
- package/build-module/controls/inserter-outer-section.mjs.map +1 -7
- package/build-module/controls/inspector-section.mjs +52 -70
- package/build-module/controls/inspector-section.mjs.map +1 -7
- package/build-module/controls/sidebar-control.mjs +33 -45
- package/build-module/controls/sidebar-control.mjs.map +1 -7
- package/build-module/controls/sidebar-section.mjs +59 -80
- package/build-module/controls/sidebar-section.mjs.map +1 -7
- package/build-module/filters/index.mjs +0 -2
- package/build-module/filters/move-to-sidebar.mjs +52 -79
- package/build-module/filters/move-to-sidebar.mjs.map +1 -7
- package/build-module/filters/replace-media-upload.mjs +5 -8
- package/build-module/filters/replace-media-upload.mjs.map +1 -7
- package/build-module/filters/wide-widget-display.mjs +13 -18
- package/build-module/filters/wide-widget-display.mjs.map +1 -7
- package/build-module/index.mjs +53 -71
- package/build-module/index.mjs.map +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +44 -8
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/constants.mjs +7 -5
- package/build-module/store/constants.mjs.map +1 -7
- package/build-module/store/index.mjs +15 -11
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +15 -13
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +41 -13
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/utils.mjs +74 -82
- package/build-module/utils.mjs.map +1 -7
- package/package.json +30 -31
- package/src/components/customize-widgets/index.jsx +5 -2
- package/src/components/customize-widgets/use-clear-selected-block.js +2 -1
- package/src/components/welcome-guide/index.jsx +6 -2
- package/CHANGELOG.md +0 -289
- package/build/filters/index.cjs.map +0 -7
- package/build-module/filters/index.mjs.map +0 -7
|
@@ -1,44 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/customize-widgets/src/components/block-appender/index.jsx
|
|
20
|
-
var block_appender_exports = {};
|
|
21
|
-
__export(block_appender_exports, {
|
|
22
|
-
default: () => BlockAppender
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
6
|
+
let _wordpress_element = require("@wordpress/element");
|
|
7
|
+
let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
8
|
+
let _wordpress_data = require("@wordpress/data");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
// packages/customize-widgets/src/components/block-appender/index.jsx
|
|
29
11
|
function BlockAppender(props) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.ButtonBlockAppender, { ...props, ref });
|
|
12
|
+
const ref = (0, _wordpress_element.useRef)();
|
|
13
|
+
const isBlocksListEmpty = (0, _wordpress_data.useSelect)((select) => select(_wordpress_block_editor.store).getBlockCount() === 0);
|
|
14
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
15
|
+
if (isBlocksListEmpty && ref.current) {
|
|
16
|
+
const { ownerDocument } = ref.current;
|
|
17
|
+
if (!ownerDocument.activeElement || ownerDocument.activeElement === ownerDocument.body) ref.current.focus();
|
|
18
|
+
}
|
|
19
|
+
}, [isBlocksListEmpty]);
|
|
20
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.ButtonBlockAppender, {
|
|
21
|
+
...props,
|
|
22
|
+
ref
|
|
23
|
+
});
|
|
43
24
|
}
|
|
44
|
-
|
|
25
|
+
exports.default = BlockAppender;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-appender/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { 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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkC;AAClC,0BAGO;AACP,kBAA0B;AAuBlB;AArBO,SAAR,cAAgC,OAAQ;AAC9C,QAAM,UAAM,uBAAO;AACnB,QAAM,wBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,oBAAAA,KAAiB,EAAE,cAAc,MAAM;AAAA,EAC9D;AAIA,gCAAW,MAAM;AAChB,QAAK,qBAAqB,IAAI,SAAU;AACvC,YAAM,EAAE,cAAc,IAAI,IAAI;AAE9B,UACC,CAAE,cAAc,iBAChB,cAAc,kBAAkB,cAAc,MAC7C;AACD,YAAI,QAAQ,MAAM;AAAA,MACnB;AAAA,IACD;AAAA,EACD,GAAG,CAAE,iBAAkB,CAAE;AAEzB,SAAO,4CAAC,2CAAsB,GAAG,OAAQ,KAAY;AACtD;",
|
|
6
|
-
"names": ["blockEditorStore"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useRef","useSelect","blockEditorStore","ButtonBlockAppender"],"sources":["../../../src/components/block-appender/index.jsx"],"sourcesContent":["import { 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":";;;;;;;;;;AAOA,SAAwB,cAAe,OAAQ;CAC9C,MAAM,OAAA,GAAMA,mBAAAA,OAAAA,CAAO;CACnB,MAAM,qBAAA,GAAoBC,gBAAAA,UAAAA,EACvB,WAAY,OAAQC,wBAAAA,KAAiB,CAAC,CAAC,cAAc,MAAM,CAC9D;CAIA,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,qBAAqB,IAAI,SAAU;GACvC,MAAM,EAAE,kBAAkB,IAAI;GAE9B,IACC,CAAE,cAAc,iBAChB,cAAc,kBAAkB,cAAc,MAE9C,IAAI,QAAQ,MAAM;EAEpB;CACD,GAAG,CAAE,iBAAkB,CAAE;CAEzB,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,qBAAD;EAAqB,GAAK;EAAc;CAAO,CAAA;AACvD"}
|
|
@@ -1,55 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/customize-widgets/src/components/block-inspector-button/index.jsx
|
|
20
|
-
var block_inspector_button_exports = {};
|
|
21
|
-
__export(block_inspector_button_exports, {
|
|
22
|
-
default: () => block_inspector_button_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
6
|
+
let _wordpress_element = require("@wordpress/element");
|
|
7
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
8
|
+
let _wordpress_components = require("@wordpress/components");
|
|
9
|
+
let _wordpress_data = require("@wordpress/data");
|
|
10
|
+
let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
// packages/customize-widgets/src/components/block-inspector-button/index.jsx
|
|
31
13
|
function BlockInspectorButton({ inspector, closeMenu, ...props }) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
onClick: () => {
|
|
44
|
-
inspector.open({
|
|
45
|
-
returnFocusWhenClose: selectedBlock
|
|
46
|
-
});
|
|
47
|
-
closeMenu();
|
|
48
|
-
},
|
|
49
|
-
...props,
|
|
50
|
-
children: (0, import_i18n.__)("Show more settings")
|
|
51
|
-
}
|
|
52
|
-
);
|
|
14
|
+
const selectedBlockClientId = (0, _wordpress_data.useSelect)((select) => select(_wordpress_block_editor.store).getSelectedBlockClientId(), []);
|
|
15
|
+
const selectedBlock = (0, _wordpress_element.useMemo)(() => document.getElementById(`block-${selectedBlockClientId}`), [selectedBlockClientId]);
|
|
16
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
|
|
17
|
+
onClick: () => {
|
|
18
|
+
inspector.open({ returnFocusWhenClose: selectedBlock });
|
|
19
|
+
closeMenu();
|
|
20
|
+
},
|
|
21
|
+
...props,
|
|
22
|
+
children: (0, _wordpress_i18n.__)("Show more settings")
|
|
23
|
+
});
|
|
53
24
|
}
|
|
54
|
-
|
|
55
|
-
|
|
25
|
+
exports.default = BlockInspectorButton;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-inspector-button/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { 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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AACxB,kBAAmB;AACnB,wBAAyB;AACzB,kBAA0B;AAC1B,0BAA0C;AAcxC;AAZF,SAAS,qBAAsB,EAAE,WAAW,WAAW,GAAG,MAAM,GAAI;AACnE,QAAM,4BAAwB;AAAA,IAC7B,CAAE,WAAY,OAAQ,oBAAAA,KAAiB,EAAE,yBAAyB;AAAA,IAClE,CAAC;AAAA,EACF;AAEA,QAAM,oBAAgB;AAAA,IACrB,MAAM,SAAS,eAAgB,SAAU,qBAAsB,EAAG;AAAA,IAClE,CAAE,qBAAsB;AAAA,EACzB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM;AAEf,kBAAU,KAAM;AAAA,UACf,sBAAsB;AAAA,QACvB,CAAE;AAEF,kBAAU;AAAA,MACX;AAAA,MACE,GAAG;AAAA,MAEH,8BAAI,oBAAqB;AAAA;AAAA,EAC5B;AAEF;AAEA,IAAO,iCAAQ;",
|
|
6
|
-
"names": ["blockEditorStore"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useSelect","blockEditorStore","useMemo","MenuItem","__"],"sources":["../../../src/components/block-inspector-button/index.jsx"],"sourcesContent":["import { 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":";;;;;;;;;;;;AAMA,SAAS,qBAAsB,EAAE,WAAW,WAAW,GAAG,SAAU;CACnE,MAAM,yBAAA,GAAwBA,gBAAAA,UAAAA,EAC3B,WAAY,OAAQC,wBAAAA,KAAiB,CAAC,CAAC,yBAAyB,GAClE,CAAC,CACF;CAEA,MAAM,iBAAA,GAAgBC,mBAAAA,QAAAA,OACf,SAAS,eAAgB,SAAU,uBAAyB,GAClE,CAAE,qBAAsB,CACzB;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,UAAD;EACC,eAAgB;GAEf,UAAU,KAAM,EACf,sBAAsB,cACvB,CAAE;GAEF,UAAU;EACX;EACA,GAAK;EAEHC,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,oBAAqB;CAClB,CAAA;AAEZ"}
|
|
@@ -1,105 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
1
7
|
var __create = Object.create;
|
|
2
8
|
var __defProp = Object.defineProperty;
|
|
3
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
13
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
18
22
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let _wordpress_admin_ui = require("@wordpress/admin-ui");
|
|
28
|
+
let _wordpress_element = require("@wordpress/element");
|
|
29
|
+
let _wordpress_components = require("@wordpress/components");
|
|
30
|
+
let _wordpress_theme = require("@wordpress/theme");
|
|
31
|
+
let _wordpress_ui = require("@wordpress/ui");
|
|
32
|
+
let ___error_boundary_index_jsx = require("../error-boundary/index.cjs");
|
|
33
|
+
___error_boundary_index_jsx = __toESM(___error_boundary_index_jsx);
|
|
34
|
+
let ___sidebar_block_editor_index_jsx = require("../sidebar-block-editor/index.cjs");
|
|
35
|
+
___sidebar_block_editor_index_jsx = __toESM(___sidebar_block_editor_index_jsx);
|
|
36
|
+
let ___focus_control_index_jsx = require("../focus-control/index.cjs");
|
|
37
|
+
___focus_control_index_jsx = __toESM(___focus_control_index_jsx);
|
|
38
|
+
let ___sidebar_controls_index_jsx = require("../sidebar-controls/index.cjs");
|
|
39
|
+
___sidebar_controls_index_jsx = __toESM(___sidebar_controls_index_jsx);
|
|
40
|
+
let __use_clear_selected_block_js = require("./use-clear-selected-block.cjs");
|
|
41
|
+
__use_clear_selected_block_js = __toESM(__use_clear_selected_block_js);
|
|
42
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
29
43
|
// packages/customize-widgets/src/components/customize-widgets/index.jsx
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const activeSidebar = activeSidebarControl && (0, import_element.createPortal)(
|
|
70
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_error_boundary.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
71
|
-
import_sidebar_block_editor.default,
|
|
72
|
-
{
|
|
73
|
-
blockEditorSettings,
|
|
74
|
-
sidebar: activeSidebarControl.sidebarAdapter,
|
|
75
|
-
inserter: activeSidebarControl.inserter,
|
|
76
|
-
inspector: activeSidebarControl.inspector
|
|
77
|
-
},
|
|
78
|
-
activeSidebarControl.id
|
|
79
|
-
) }),
|
|
80
|
-
activeSidebarControl.container[0]
|
|
81
|
-
);
|
|
82
|
-
const popover = parentContainer && (0, import_element.createPortal)(
|
|
83
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "customize-widgets-popover", ref: popoverRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Popover.Slot, {}) }),
|
|
84
|
-
parentContainer
|
|
85
|
-
);
|
|
86
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.SlotFillProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_theme.ThemeProvider, { isRoot: true, color: { primary: adminPrimary }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
87
|
-
import_sidebar_controls.default,
|
|
88
|
-
{
|
|
89
|
-
sidebarControls,
|
|
90
|
-
activeSidebarControl,
|
|
91
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
92
|
-
import_focus_control.default,
|
|
93
|
-
{
|
|
94
|
-
api,
|
|
95
|
-
sidebarControls,
|
|
96
|
-
children: [
|
|
97
|
-
activeSidebar,
|
|
98
|
-
popover
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
) }) });
|
|
44
|
+
function CustomizeWidgets({ api, sidebarControls, blockEditorSettings }) {
|
|
45
|
+
const [activeSidebarControl, setActiveSidebarControl] = (0, _wordpress_element.useState)(null);
|
|
46
|
+
const parentContainer = document.getElementById("customize-theme-controls");
|
|
47
|
+
const popoverRef = (0, _wordpress_element.useRef)();
|
|
48
|
+
const adminPrimary = (0, _wordpress_element.useMemo)(() => (0, _wordpress_admin_ui.getAdminThemeColors)().primary, []);
|
|
49
|
+
(0, _wordpress_ui.useEnableWpCompatOverlaySlot)();
|
|
50
|
+
(0, __use_clear_selected_block_js.default)(activeSidebarControl, popoverRef);
|
|
51
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
52
|
+
const unsubscribers = sidebarControls.map((sidebarControl) => sidebarControl.subscribe((expanded) => {
|
|
53
|
+
if (expanded) setActiveSidebarControl(sidebarControl);
|
|
54
|
+
}));
|
|
55
|
+
return () => {
|
|
56
|
+
unsubscribers.forEach((unsubscriber) => unsubscriber());
|
|
57
|
+
};
|
|
58
|
+
}, [sidebarControls]);
|
|
59
|
+
const activeSidebar = activeSidebarControl && (0, _wordpress_element.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(___error_boundary_index_jsx.default, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___sidebar_block_editor_index_jsx.default, {
|
|
60
|
+
blockEditorSettings,
|
|
61
|
+
sidebar: activeSidebarControl.sidebarAdapter,
|
|
62
|
+
inserter: activeSidebarControl.inserter,
|
|
63
|
+
inspector: activeSidebarControl.inspector
|
|
64
|
+
}, activeSidebarControl.id) }), activeSidebarControl.container[0]);
|
|
65
|
+
const popover = parentContainer && (0, _wordpress_element.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
66
|
+
className: "customize-widgets-popover",
|
|
67
|
+
ref: popoverRef,
|
|
68
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Popover.Slot, {})
|
|
69
|
+
}), parentContainer);
|
|
70
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.SlotFillProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_theme.ThemeProvider, {
|
|
71
|
+
isRoot: true,
|
|
72
|
+
color: { primary: adminPrimary },
|
|
73
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___sidebar_controls_index_jsx.default, {
|
|
74
|
+
sidebarControls,
|
|
75
|
+
activeSidebarControl,
|
|
76
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(___focus_control_index_jsx.default, {
|
|
77
|
+
api,
|
|
78
|
+
sidebarControls,
|
|
79
|
+
children: [activeSidebar, popover]
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
}) });
|
|
104
83
|
}
|
|
105
|
-
|
|
84
|
+
exports.default = CustomizeWidgets;
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/customize-widgets/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreatePortal,\n\tuseMemo,\n} from '@wordpress/element';\nimport { SlotFillProvider, Popover } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\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\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\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<SlotFillProvider>\n\t\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\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</ThemeProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoC;AACpC,qBAMO;AACP,wBAA0C;AAC1C,mBAA8B;AAC9B,4BAA0B;AAC1B,kCAA+B;AAC/B,2BAAyB;AACzB,8BAA4B;AAC5B,sCAAkC;AAkC9B;AAhCW,SAAR,iBAAmC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,sBAAsB,uBAAwB,QAAI,yBAAU,IAAK;AACzE,QAAM,kBAAkB,SAAS;AAAA,IAChC;AAAA,EACD;AACA,QAAM,iBAAa,uBAAO;AAC1B,QAAM,mBAAe,wBAAS,UAAM,qCAAoB,EAAE,SAAS,CAAC,CAAE;AAEtE,sCAAAA,SAAuB,sBAAsB,UAAW;AAExD,gCAAW,MAAM;AAChB,UAAM,gBAAgB,gBAAgB;AAAA,MAAK,CAAE,mBAC5C,eAAe,UAAW,CAAE,aAAc;AACzC,YAAK,UAAW;AACf,kCAAyB,cAAe;AAAA,QACzC;AAAA,MACD,CAAE;AAAA,IACH;AAEA,WAAO,MAAM;AACZ,oBAAc,QAAS,CAAE,iBAAkB,aAAa,CAAE;AAAA,IAC3D;AAAA,EACD,GAAG,CAAE,eAAgB,CAAE;AAEvB,QAAM,gBACL,4BACA;AAAA,IACC,4CAAC,sBAAAC,SAAA,EACA;AAAA,MAAC,4BAAAC;AAAA,MAAA;AAAA,QAEA;AAAA,QACA,SAAU,qBAAqB;AAAA,QAC/B,UAAW,qBAAqB;AAAA,QAChC,WAAY,qBAAqB;AAAA;AAAA,MAJ3B,qBAAqB;AAAA,IAK5B,GACD;AAAA,IACA,qBAAqB,UAAW,CAAE;AAAA,EACnC;AAID,QAAM,UACL,uBACA;AAAA,IACC,4CAAC,SAAI,WAAU,6BAA4B,KAAM,YAChD,sDAAC,0BAAQ,MAAR,EAAa,GACf;AAAA,IACA;AAAA,EACD;AAED,SACC,4CAAC,sCACA,sDAAC,8BAAc,QAAM,MAAC,OAAQ,EAAE,SAAS,aAAa,GACrD;AAAA,IAAC,wBAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC,qBAAAC;AAAA,QAAA;AAAA,UACA;AAAA,UACA;AAAA,UAEE;AAAA;AAAA,YACA;AAAA;AAAA;AAAA,MACH;AAAA;AAAA,EACD,GACD,GACD;AAEF;",
|
|
6
|
-
"names": ["useClearSelectedBlock", "ErrorBoundary", "SidebarBlockEditor", "SidebarControls", "FocusControl"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useState","useRef","useMemo","getAdminThemeColors","createPortal","ErrorBoundary","SidebarBlockEditor","WCPopover","SlotFillProvider","ThemeProvider","SidebarControls","FocusControl"],"sources":["../../../src/components/customize-widgets/index.jsx"],"sourcesContent":["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreatePortal,\n\tuseMemo,\n} from '@wordpress/element';\nimport { SlotFillProvider, Popover as WCPopover } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport { useEnableWpCompatOverlaySlot } from '@wordpress/ui';\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\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\t// `useClearSelectedBlock` relies on the slot marker to spot overlays.\n\tuseEnableWpCompatOverlaySlot();\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<WCPopover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\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</ThemeProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAwB,iBAAkB,EACzC,KACA,iBACA,uBACG;CACH,MAAM,CAAE,sBAAsB,4BAAA,GAA4BA,mBAAAA,SAAAA,CAAU,IAAK;CACzE,MAAM,kBAAkB,SAAS,eAChC,0BACD;CACA,MAAM,cAAA,GAAaC,mBAAAA,OAAAA,CAAO;CAC1B,MAAM,gBAAA,GAAeC,mBAAAA,QAAAA,QAAAA,GAAeC,oBAAAA,oBAAAA,CAAoB,CAAC,CAAC,SAAS,CAAC,CAAE;CAGtE,CAAA,GAAA,cAAA,6BAAA,CAA6B;CAC7B,CAAA,GAAA,8BAAA,QAAA,CAAuB,sBAAsB,UAAW;CAExD,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,MAAM,gBAAgB,gBAAgB,KAAO,mBAC5C,eAAe,WAAa,aAAc;GACzC,IAAK,UACJ,wBAAyB,cAAe;EAE1C,CAAE,CACH;EAEA,aAAa;GACZ,cAAc,SAAW,iBAAkB,aAAa,CAAE;EAC3D;CACD,GAAG,CAAE,eAAgB,CAAE;CAEvB,MAAM,gBACL,yBAAA,GACAC,mBAAAA,aAAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,SAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,SAAD;EAEuB;EACtB,SAAU,qBAAqB;EAC/B,UAAW,qBAAqB;EAChC,WAAY,qBAAqB;CACjC,GALM,qBAAqB,EAK3B,EACa,CAAA,GACf,qBAAqB,UAAW,EACjC;CAID,MAAM,UACL,oBAAA,GACAF,mBAAAA,aAAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EAA4B,KAAM;EAChD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACG,sBAAAA,QAAU,MAAX,CAAiB,CAAA;CACb,CAAA,GACL,eACD;CAED,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,kBAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,iBAAAA,eAAD;EAAe,QAAA;EAAO,OAAQ,EAAE,SAAS,aAAa;EACrD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,SAAD;GACmB;GACK;GAEvB,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAACC,2BAAAA,SAAD;IACO;IACY;IAFnB,UAAA,CAIG,eACA,OACW;;EACE,CAAA;CACH,CAAA,EACE,CAAA;AAEpB"}
|
|
@@ -1,70 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/customize-widgets/src/components/customize-widgets/use-clear-selected-block.js
|
|
20
|
-
var use_clear_selected_block_exports = {};
|
|
21
|
-
__export(use_clear_selected_block_exports, {
|
|
22
|
-
default: () => useClearSelectedBlock
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
let _wordpress_element = require("@wordpress/element");
|
|
7
|
+
let _wordpress_data = require("@wordpress/data");
|
|
8
|
+
let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
9
|
+
// packages/customize-widgets/src/components/customize-widgets/use-clear-selected-block.js
|
|
10
|
+
/**
|
|
11
|
+
* We can't just use <BlockSelectionClearer> because the customizer has
|
|
12
|
+
* many root nodes rather than just one in the post editor.
|
|
13
|
+
* We need to listen to the focus events in all those roots, and also in
|
|
14
|
+
* the preview iframe.
|
|
15
|
+
* This hook will clear the selected block when focusing outside the editor,
|
|
16
|
+
* with a few exceptions:
|
|
17
|
+
* 1. Focusing on popovers, including `@wordpress/ui` overlays.
|
|
18
|
+
* 2. Focusing on the inspector.
|
|
19
|
+
* 3. Focusing on any modals/dialogs.
|
|
20
|
+
* These cases are normally triggered by user interactions from the editor,
|
|
21
|
+
* not by explicitly focusing outside the editor, hence no need for clearing.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} sidebarControl The sidebar control instance.
|
|
24
|
+
* @param {Object} popoverRef The ref object of the popover node container.
|
|
25
|
+
*/
|
|
28
26
|
function useClearSelectedBlock(sidebarControl, popoverRef) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}, [
|
|
63
|
-
popoverRef,
|
|
64
|
-
sidebarControl,
|
|
65
|
-
hasSelectedBlock,
|
|
66
|
-
hasMultiSelection,
|
|
67
|
-
clearSelectedBlock
|
|
68
|
-
]);
|
|
27
|
+
const { hasSelectedBlock, hasMultiSelection } = (0, _wordpress_data.useSelect)(_wordpress_block_editor.store);
|
|
28
|
+
const { clearSelectedBlock } = (0, _wordpress_data.useDispatch)(_wordpress_block_editor.store);
|
|
29
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
30
|
+
if (popoverRef.current && sidebarControl) {
|
|
31
|
+
const inspector = sidebarControl.inspector;
|
|
32
|
+
const container = sidebarControl.container[0];
|
|
33
|
+
const ownerDocument = container.ownerDocument;
|
|
34
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
35
|
+
function handleClearSelectedBlock(element) {
|
|
36
|
+
if ((hasSelectedBlock() || hasMultiSelection()) && element && ownerDocument.contains(element) && !container.contains(element) && !popoverRef.current.contains(element) && !element.closest("[data-wp-compat-overlay-slot]") && !element.closest("[role=\"dialog\"]") && !inspector.expanded()) clearSelectedBlock();
|
|
37
|
+
}
|
|
38
|
+
function handleMouseDown(event) {
|
|
39
|
+
handleClearSelectedBlock(event.target);
|
|
40
|
+
}
|
|
41
|
+
function handleBlur() {
|
|
42
|
+
handleClearSelectedBlock(ownerDocument.activeElement);
|
|
43
|
+
}
|
|
44
|
+
ownerDocument.addEventListener("mousedown", handleMouseDown);
|
|
45
|
+
ownerWindow.addEventListener("blur", handleBlur);
|
|
46
|
+
return () => {
|
|
47
|
+
ownerDocument.removeEventListener("mousedown", handleMouseDown);
|
|
48
|
+
ownerWindow.removeEventListener("blur", handleBlur);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}, [
|
|
52
|
+
popoverRef,
|
|
53
|
+
sidebarControl,
|
|
54
|
+
hasSelectedBlock,
|
|
55
|
+
hasMultiSelection,
|
|
56
|
+
clearSelectedBlock
|
|
57
|
+
]);
|
|
69
58
|
}
|
|
70
|
-
|
|
59
|
+
exports.default = useClearSelectedBlock;
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=use-clear-selected-block.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/customize-widgets/use-clear-selected-block.js"],
|
|
4
|
-
"sourcesContent": ["import { 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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,kBAAuC;AACvC,0BAA0C;AAkB3B,SAAR,sBAAwC,gBAAgB,YAAa;AAC3E,QAAM,EAAE,kBAAkB,kBAAkB,QAC3C,uBAAW,oBAAAA,KAAiB;AAC7B,QAAM,EAAE,mBAAmB,QAAI,yBAAa,oBAAAA,KAAiB;AAE7D,gCAAW,MAAM;AAChB,QAAK,WAAW,WAAW,gBAAiB;AAM3C,UAAS,2BAAT,SAAmC,SAAU;AAC5C;AAAA;AAAA,WAEG,iBAAiB,KAAK,kBAAkB;AAAA,UAE1C,WACA,cAAc,SAAU,OAAQ;AAAA,UAEhC,CAAE,UAAU,SAAU,OAAQ,KAC9B,CAAE,WAAW,QAAQ,SAAU,OAAQ,KACvC,CAAE,QAAQ,QAAS,iBAAkB;AAAA,UAErC,CAAE,UAAU,SAAS;AAAA,UACpB;AACD,6BAAmB;AAAA,QACpB;AAAA,MACD,GAGS,kBAAT,SAA0B,OAAQ;AACjC,iCAA0B,MAAM,MAAO;AAAA,MACxC,GAES,aAAT,WAAsB;AACrB,iCAA0B,cAAc,aAAc;AAAA,MACvD;AA9BA,YAAM,YAAY,eAAe;AACjC,YAAM,YAAY,eAAe,UAAW,CAAE;AAC9C,YAAM,gBAAgB,UAAU;AAChC,YAAM,cAAc,cAAc;AA6BlC,oBAAc,iBAAkB,aAAa,eAAgB;AAC7D,kBAAY,iBAAkB,QAAQ,UAAW;AAEjD,aAAO,MAAM;AACZ,sBAAc;AAAA,UACb;AAAA,UACA;AAAA,QACD;AACA,oBAAY,oBAAqB,QAAQ,UAAW;AAAA,MACrD;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
|
-
"names": ["blockEditorStore"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"use-clear-selected-block.cjs","names":["useSelect","blockEditorStore","useDispatch"],"sources":["../../../src/components/customize-widgets/use-clear-selected-block.js"],"sourcesContent":["import { 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, including `@wordpress/ui` overlays.\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( '[data-wp-compat-overlay-slot]' ) &&\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":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAwB,sBAAuB,gBAAgB,YAAa;CAC3E,MAAM,EAAE,kBAAkB,uBAAA,GACzBA,gBAAAA,UAAAA,CAAWC,wBAAAA,KAAiB;CAC7B,MAAM,EAAE,wBAAA,GAAuBC,gBAAAA,YAAAA,CAAaD,wBAAAA,KAAiB;CAE7D,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,WAAW,WAAW,gBAAiB;GAC3C,MAAM,YAAY,eAAe;GACjC,MAAM,YAAY,eAAe,UAAW;GAC5C,MAAM,gBAAgB,UAAU;GAChC,MAAM,cAAc,cAAc;GAElC,SAAS,yBAA0B,SAAU;IAC5C,KAEG,iBAAiB,KAAK,kBAAkB,MAE1C,WACA,cAAc,SAAU,OAAQ,KAEhC,CAAE,UAAU,SAAU,OAAQ,KAC9B,CAAE,WAAW,QAAQ,SAAU,OAAQ,KACvC,CAAE,QAAQ,QAAS,+BAAgC,KACnD,CAAE,QAAQ,QAAS,mBAAkB,KAErC,CAAE,UAAU,SAAS,GAErB,mBAAmB;GAErB;GAGA,SAAS,gBAAiB,OAAQ;IACjC,yBAA0B,MAAM,MAAO;GACxC;GAEA,SAAS,aAAa;IACrB,yBAA0B,cAAc,aAAc;GACvD;GAEA,cAAc,iBAAkB,aAAa,eAAgB;GAC7D,YAAY,iBAAkB,QAAQ,UAAW;GAEjD,aAAa;IACZ,cAAc,oBACb,aACA,eACD;IACA,YAAY,oBAAqB,QAAQ,UAAW;GACrD;EACD;CACD,GAAG;EACF;EACA;EACA;EACA;EACA;CACD,CAAE;AACH"}
|