@wordpress/customize-widgets 5.32.0 → 5.32.1-next.ff1cebbba.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.js +33 -27
- package/build/components/block-appender/index.js.map +7 -1
- package/build/components/block-inspector-button/index.js +51 -36
- package/build/components/block-inspector-button/index.js.map +7 -1
- package/build/components/customize-widgets/index.js +83 -61
- package/build/components/customize-widgets/index.js.map +7 -1
- package/build/components/customize-widgets/use-clear-selected-block.js +56 -63
- package/build/components/customize-widgets/use-clear-selected-block.js.map +7 -1
- package/build/components/error-boundary/index.js +46 -45
- package/build/components/error-boundary/index.js.map +7 -1
- package/build/components/focus-control/index.js +69 -57
- package/build/components/focus-control/index.js.map +7 -1
- package/build/components/focus-control/use-blocks-focus-control.js +38 -31
- package/build/components/focus-control/use-blocks-focus-control.js.map +7 -1
- package/build/components/header/index.js +110 -71
- package/build/components/header/index.js.map +7 -1
- package/build/components/inserter/index.js +77 -53
- package/build/components/inserter/index.js.map +7 -1
- package/build/components/inserter/use-inserter.js +46 -29
- package/build/components/inserter/use-inserter.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +74 -71
- package/build/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +61 -44
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +155 -110
- package/build/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +76 -56
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build/components/keyboard-shortcuts/index.js +60 -51
- package/build/components/keyboard-shortcuts/index.js.map +7 -1
- package/build/components/more-menu/index.js +151 -90
- package/build/components/more-menu/index.js.map +7 -1
- package/build/components/sidebar-block-editor/index.js +133 -105
- package/build/components/sidebar-block-editor/index.js.map +7 -1
- package/build/components/sidebar-block-editor/sidebar-adapter.js +73 -67
- package/build/components/sidebar-block-editor/sidebar-adapter.js.map +7 -1
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js +51 -33
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js.map +7 -1
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js +100 -79
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js.map +7 -1
- package/build/components/sidebar-controls/index.js +45 -31
- package/build/components/sidebar-controls/index.js.map +7 -1
- package/build/components/welcome-guide/index.js +86 -58
- package/build/components/welcome-guide/index.js.map +7 -1
- package/build/controls/inserter-outer-section.js +49 -58
- package/build/controls/inserter-outer-section.js.map +7 -1
- package/build/controls/inspector-section.js +30 -36
- package/build/controls/inspector-section.js.map +7 -1
- package/build/controls/sidebar-control.js +51 -30
- package/build/controls/sidebar-control.js.map +7 -1
- package/build/controls/sidebar-section.js +71 -39
- package/build/controls/sidebar-section.js.map +7 -1
- package/build/filters/index.js +4 -6
- package/build/filters/index.js.map +7 -1
- package/build/filters/move-to-sidebar.js +77 -79
- package/build/filters/move-to-sidebar.js.map +7 -1
- package/build/filters/replace-media-upload.js +9 -11
- package/build/filters/replace-media-upload.js.map +7 -1
- package/build/filters/wide-widget-display.js +20 -25
- package/build/filters/wide-widget-display.js.map +7 -1
- package/build/index.js +81 -70
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/store/actions.js +27 -44
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -10
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +44 -40
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +25 -19
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +31 -44
- package/build/store/selectors.js.map +7 -1
- package/build/utils.js +45 -73
- package/build/utils.js.map +7 -1
- package/build-module/components/block-appender/index.js +17 -20
- package/build-module/components/block-appender/index.js.map +7 -1
- package/build-module/components/block-inspector-button/index.js +33 -30
- package/build-module/components/block-inspector-button/index.js.map +7 -1
- package/build-module/components/customize-widgets/index.js +52 -51
- package/build-module/components/customize-widgets/index.js.map +7 -1
- package/build-module/components/customize-widgets/use-clear-selected-block.js +38 -58
- package/build-module/components/customize-widgets/use-clear-selected-block.js.map +7 -1
- package/build-module/components/error-boundary/index.js +27 -37
- package/build-module/components/error-boundary/index.js.map +7 -1
- package/build-module/components/focus-control/index.js +50 -45
- package/build-module/components/focus-control/index.js.map +7 -1
- package/build-module/components/focus-control/use-blocks-focus-control.js +17 -22
- package/build-module/components/focus-control/use-blocks-focus-control.js.map +7 -1
- package/build-module/components/header/index.js +81 -63
- package/build-module/components/header/index.js.map +7 -1
- package/build-module/components/inserter/index.js +59 -47
- package/build-module/components/inserter/index.js.map +7 -1
- package/build-module/components/inserter/use-inserter.js +28 -23
- package/build-module/components/inserter/use-inserter.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +62 -75
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +33 -37
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +130 -103
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -50
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcuts/index.js +44 -44
- package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
- package/build-module/components/more-menu/index.js +129 -84
- package/build-module/components/more-menu/index.js.map +7 -1
- package/build-module/components/sidebar-block-editor/index.js +109 -96
- package/build-module/components/sidebar-block-editor/index.js.map +7 -1
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js +54 -59
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js.map +7 -1
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js +22 -25
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js.map +7 -1
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js +70 -70
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js.map +7 -1
- package/build-module/components/sidebar-controls/index.js +24 -25
- package/build-module/components/sidebar-controls/index.js.map +7 -1
- package/build-module/components/welcome-guide/index.js +68 -52
- package/build-module/components/welcome-guide/index.js.map +7 -1
- package/build-module/controls/inserter-outer-section.js +31 -52
- package/build-module/controls/inserter-outer-section.js.map +7 -1
- package/build-module/controls/inspector-section.js +13 -32
- package/build-module/controls/inspector-section.js.map +7 -1
- package/build-module/controls/sidebar-control.js +22 -22
- package/build-module/controls/sidebar-control.js.map +7 -1
- package/build-module/controls/sidebar-section.js +43 -32
- package/build-module/controls/sidebar-section.js.map +7 -1
- package/build-module/filters/index.js +4 -7
- package/build-module/filters/index.js.map +7 -1
- package/build-module/filters/move-to-sidebar.js +83 -76
- package/build-module/filters/move-to-sidebar.js.map +7 -1
- package/build-module/filters/replace-media-upload.js +8 -7
- package/build-module/filters/replace-media-upload.js.map +7 -1
- package/build-module/filters/wide-widget-display.js +20 -22
- package/build-module/filters/wide-widget-display.js.map +7 -1
- package/build-module/index.js +53 -51
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/store/actions.js +6 -40
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -5
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +10 -30
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +7 -14
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +10 -40
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/utils.js +21 -66
- package/build-module/utils.js.map +7 -1
- package/build-style/style-rtl.css +14 -149
- package/build-style/style.css +14 -149
- package/package.json +30 -23
- package/src/components/block-inspector-button/style.scss +3 -0
- package/src/components/header/style.scss +5 -0
- package/src/components/inserter/style.scss +3 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +2 -0
- package/src/components/more-menu/style.scss +2 -0
- package/src/components/sidebar-block-editor/style.scss +2 -0
- package/src/components/welcome-guide/style.scss +2 -0
- package/src/controls/style.scss +2 -0
- package/src/style.scss +10 -8
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
|
+
var error_boundary_exports = {};
|
|
19
|
+
__export(error_boundary_exports, {
|
|
20
|
+
default: () => ErrorBoundary
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
function CopyButton({
|
|
19
|
-
text,
|
|
20
|
-
children
|
|
21
|
-
}) {
|
|
22
|
-
const ref = (0, _compose.useCopyToClipboard)(text);
|
|
23
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
24
|
-
size: "compact",
|
|
25
|
-
variant: "secondary",
|
|
26
|
-
ref: ref,
|
|
27
|
-
children: children
|
|
28
|
-
});
|
|
22
|
+
module.exports = __toCommonJS(error_boundary_exports);
|
|
23
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
|
+
var import_element = require("@wordpress/element");
|
|
25
|
+
var import_i18n = require("@wordpress/i18n");
|
|
26
|
+
var import_components = require("@wordpress/components");
|
|
27
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
28
|
+
var import_compose = require("@wordpress/compose");
|
|
29
|
+
var import_hooks = require("@wordpress/hooks");
|
|
30
|
+
function CopyButton({ text, children }) {
|
|
31
|
+
const ref = (0, import_compose.useCopyToClipboard)(text);
|
|
32
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, { size: "compact", variant: "secondary", ref, children });
|
|
29
33
|
}
|
|
30
|
-
class ErrorBoundary extends
|
|
34
|
+
class ErrorBoundary extends import_element.Component {
|
|
31
35
|
constructor() {
|
|
32
36
|
super(...arguments);
|
|
33
37
|
this.state = {
|
|
@@ -35,27 +39,24 @@ class ErrorBoundary extends _element.Component {
|
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
componentDidCatch(error) {
|
|
38
|
-
this.setState({
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
(0, _hooks.doAction)('editor.ErrorBoundary.errorLogged', error);
|
|
42
|
+
this.setState({ error });
|
|
43
|
+
(0, import_hooks.doAction)("editor.ErrorBoundary.errorLogged", error);
|
|
42
44
|
}
|
|
43
45
|
render() {
|
|
44
|
-
const {
|
|
45
|
-
error
|
|
46
|
-
} = this.state;
|
|
46
|
+
const { error } = this.state;
|
|
47
47
|
if (!error) {
|
|
48
48
|
return this.props.children;
|
|
49
49
|
}
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
+
import_block_editor.Warning,
|
|
52
|
+
{
|
|
53
|
+
className: "customize-widgets-error-boundary",
|
|
54
|
+
actions: [
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyButton, { text: error.stack, children: (0, import_i18n.__)("Copy Error") }, "copy-error")
|
|
56
|
+
],
|
|
57
|
+
children: (0, import_i18n.__)("The editor has encountered an unexpected error.")
|
|
58
|
+
}
|
|
59
|
+
);
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=index.js.map
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/error-boundary/index.js"],
|
|
4
|
+
"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 size=\"compact\" 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaE;AAVF,qBAA0B;AAC1B,kBAAmB;AACnB,wBAAuB;AACvB,0BAAwB;AACxB,qBAAmC;AACnC,mBAAyB;AAEzB,SAAS,WAAY,EAAE,MAAM,SAAS,GAAI;AACzC,QAAM,UAAM,mCAAoB,IAAK;AACrC,SACC,4CAAC,4BAAO,MAAK,WAAU,SAAQ,aAAY,KACxC,UACH;AAEF;AAEA,MAAO,sBAAoC,yBAAU;AAAA,EACpD,cAAc;AACb,UAAO,GAAG,SAAU;AACpB,SAAK,QAAQ;AAAA,MACZ,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EAEA,kBAAmB,OAAQ;AAC1B,SAAK,SAAU,EAAE,MAAM,CAAE;AAEzB,+BAAU,oCAAoC,KAAM;AAAA,EACrD;AAAA,EAEA,SAAS;AACR,UAAM,EAAE,MAAM,IAAI,KAAK;AACvB,QAAK,CAAE,OAAQ;AACd,aAAO,KAAK,MAAM;AAAA,IACnB;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,SAAU;AAAA,UACT,4CAAC,cAA4B,MAAO,MAAM,OACvC,8BAAI,YAAa,KADJ,YAEhB;AAAA,QACD;AAAA,QAEE,8BAAI,iDAAkD;AAAA;AAAA,IACzD;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,74 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
|
+
var focus_control_exports = {};
|
|
19
|
+
__export(focus_control_exports, {
|
|
20
|
+
default: () => FocusControl,
|
|
21
|
+
useFocusControl: () => useFocusControl
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const FocusControlContext = (0, _element.createContext)();
|
|
20
|
-
FocusControlContext.displayName = 'FocusControlContext';
|
|
21
|
-
function FocusControl({
|
|
22
|
-
api,
|
|
23
|
-
sidebarControls,
|
|
24
|
-
children
|
|
25
|
-
}) {
|
|
26
|
-
const [focusedWidgetIdRef, setFocusedWidgetIdRef] = (0, _element.useState)({
|
|
23
|
+
module.exports = __toCommonJS(focus_control_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_element = require("@wordpress/element");
|
|
26
|
+
var import_utils = require("../../utils");
|
|
27
|
+
const FocusControlContext = (0, import_element.createContext)();
|
|
28
|
+
FocusControlContext.displayName = "FocusControlContext";
|
|
29
|
+
function FocusControl({ api, sidebarControls, children }) {
|
|
30
|
+
const [focusedWidgetIdRef, setFocusedWidgetIdRef] = (0, import_element.useState)({
|
|
27
31
|
current: null
|
|
28
32
|
});
|
|
29
|
-
const focusWidget = (0,
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
break;
|
|
33
|
+
const focusWidget = (0, import_element.useCallback)(
|
|
34
|
+
(widgetId) => {
|
|
35
|
+
for (const sidebarControl of sidebarControls) {
|
|
36
|
+
const widgets = sidebarControl.setting.get();
|
|
37
|
+
if (widgets.includes(widgetId)) {
|
|
38
|
+
sidebarControl.sectionInstance.expand({
|
|
39
|
+
// Schedule it after the complete callback so that
|
|
40
|
+
// it won't be overridden by the "Back" button focus.
|
|
41
|
+
completeCallback() {
|
|
42
|
+
setFocusedWidgetIdRef({ current: widgetId });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
},
|
|
49
|
+
[sidebarControls]
|
|
50
|
+
);
|
|
51
|
+
(0, import_element.useEffect)(() => {
|
|
49
52
|
function handleFocus(settingId) {
|
|
50
|
-
const widgetId = (0,
|
|
53
|
+
const widgetId = (0, import_utils.settingIdToWidgetId)(settingId);
|
|
51
54
|
focusWidget(widgetId);
|
|
52
55
|
}
|
|
53
56
|
let previewBound = false;
|
|
54
57
|
function handleReady() {
|
|
55
|
-
api.previewer.preview.bind(
|
|
58
|
+
api.previewer.preview.bind(
|
|
59
|
+
"focus-control-for-setting",
|
|
60
|
+
handleFocus
|
|
61
|
+
);
|
|
56
62
|
previewBound = true;
|
|
57
63
|
}
|
|
58
|
-
api.previewer.bind(
|
|
64
|
+
api.previewer.bind("ready", handleReady);
|
|
59
65
|
return () => {
|
|
60
|
-
api.previewer.unbind(
|
|
66
|
+
api.previewer.unbind("ready", handleReady);
|
|
61
67
|
if (previewBound) {
|
|
62
|
-
api.previewer.preview.unbind(
|
|
68
|
+
api.previewer.preview.unbind(
|
|
69
|
+
"focus-control-for-setting",
|
|
70
|
+
handleFocus
|
|
71
|
+
);
|
|
63
72
|
}
|
|
64
73
|
};
|
|
65
74
|
}, [api, focusWidget]);
|
|
66
|
-
const context = (0,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
75
|
+
const context = (0, import_element.useMemo)(
|
|
76
|
+
() => [focusedWidgetIdRef, focusWidget],
|
|
77
|
+
[focusedWidgetIdRef, focusWidget]
|
|
78
|
+
);
|
|
79
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusControlContext.Provider, { value: context, children });
|
|
71
80
|
}
|
|
72
|
-
const useFocusControl = () => (0,
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
const useFocusControl = () => (0, import_element.useContext)(FocusControlContext);
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
useFocusControl
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/focus-control/index.js"],
|
|
4
|
+
"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();\nFocusControlContext.displayName = 'FocusControlContext';\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoFE;AAjFF,qBAOO;AAKP,mBAAoC;AAEpC,MAAM,0BAAsB,8BAAc;AAC1C,oBAAoB,cAAc;AAEnB,SAAR,aAA+B,EAAE,KAAK,iBAAiB,SAAS,GAAI;AAC1E,QAAM,CAAE,oBAAoB,qBAAsB,QAAI,yBAAU;AAAA,IAC/D,SAAS;AAAA,EACV,CAAE;AAEF,QAAM,kBAAc;AAAA,IACnB,CAAE,aAAc;AACf,iBAAY,kBAAkB,iBAAkB;AAC/C,cAAM,UAAU,eAAe,QAAQ,IAAI;AAE3C,YAAK,QAAQ,SAAU,QAAS,GAAI;AACnC,yBAAe,gBAAgB,OAAQ;AAAA;AAAA;AAAA,YAGtC,mBAAmB;AAGlB,oCAAuB,EAAE,SAAS,SAAS,CAAE;AAAA,YAC9C;AAAA,UACD,CAAE;AAEF;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,eAAgB;AAAA,EACnB;AAEA,gCAAW,MAAM;AAChB,aAAS,YAAa,WAAY;AACjC,YAAM,eAAW,kCAAqB,SAAU;AAEhD,kBAAa,QAAS;AAAA,IACvB;AAEA,QAAI,eAAe;AAEnB,aAAS,cAAc;AACtB,UAAI,UAAU,QAAQ;AAAA,QACrB;AAAA,QACA;AAAA,MACD;AACA,qBAAe;AAAA,IAChB;AAEA,QAAI,UAAU,KAAM,SAAS,WAAY;AAEzC,WAAO,MAAM;AACZ,UAAI,UAAU,OAAQ,SAAS,WAAY;AAC3C,UAAK,cAAe;AACnB,YAAI,UAAU,QAAQ;AAAA,UACrB;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAE,KAAK,WAAY,CAAE;AAExB,QAAM,cAAU;AAAA,IACf,MAAM,CAAE,oBAAoB,WAAY;AAAA,IACxC,CAAE,oBAAoB,WAAY;AAAA,EACnC;AAEA,SACC,4CAAC,oBAAoB,UAApB,EAA6B,OAAQ,SACnC,UACH;AAEF;AAEO,MAAM,kBAAkB,UAAM,2BAAY,mBAAoB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,43 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
|
+
var use_blocks_focus_control_exports = {};
|
|
19
|
+
__export(use_blocks_focus_control_exports, {
|
|
20
|
+
default: () => useBlocksFocusControl
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
22
|
+
module.exports = __toCommonJS(use_blocks_focus_control_exports);
|
|
23
|
+
var import_element = require("@wordpress/element");
|
|
24
|
+
var import_data = require("@wordpress/data");
|
|
25
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
26
|
+
var import_widgets = require("@wordpress/widgets");
|
|
27
|
+
var import__ = require(".");
|
|
20
28
|
function useBlocksFocusControl(blocks) {
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const blocksRef = (0, _element.useRef)(blocks);
|
|
26
|
-
(0, _element.useEffect)(() => {
|
|
29
|
+
const { selectBlock } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
30
|
+
const [focusedWidgetIdRef] = (0, import__.useFocusControl)();
|
|
31
|
+
const blocksRef = (0, import_element.useRef)(blocks);
|
|
32
|
+
(0, import_element.useEffect)(() => {
|
|
27
33
|
blocksRef.current = blocks;
|
|
28
34
|
}, [blocks]);
|
|
29
|
-
(0,
|
|
35
|
+
(0, import_element.useEffect)(() => {
|
|
30
36
|
if (focusedWidgetIdRef.current) {
|
|
31
|
-
const focusedBlock = blocksRef.current.find(
|
|
37
|
+
const focusedBlock = blocksRef.current.find(
|
|
38
|
+
(block) => (0, import_widgets.getWidgetIdFromBlock)(block) === focusedWidgetIdRef.current
|
|
39
|
+
);
|
|
32
40
|
if (focusedBlock) {
|
|
33
41
|
selectBlock(focusedBlock.clientId);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const blockNode = document.querySelector(`[data-block="${focusedBlock.clientId}"]`);
|
|
42
|
+
const blockNode = document.querySelector(
|
|
43
|
+
`[data-block="${focusedBlock.clientId}"]`
|
|
44
|
+
);
|
|
38
45
|
blockNode?.focus();
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
}, [focusedWidgetIdRef, selectBlock]);
|
|
42
49
|
}
|
|
43
|
-
//# sourceMappingURL=use-blocks-focus-control.js.map
|
|
50
|
+
//# sourceMappingURL=use-blocks-focus-control.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/focus-control/use-blocks-focus-control.js"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAkC;AAClC,kBAA4B;AAC5B,0BAA0C;AAC1C,qBAAqC;AAKrC,eAAgC;AAEjB,SAAR,sBAAwC,QAAS;AACvD,QAAM,EAAE,YAAY,QAAI,yBAAa,oBAAAA,KAAiB;AACtD,QAAM,CAAE,kBAAmB,QAAI,0BAAgB;AAE/C,QAAM,gBAAY,uBAAQ,MAAO;AAEjC,gCAAW,MAAM;AAChB,cAAU,UAAU;AAAA,EACrB,GAAG,CAAE,MAAO,CAAE;AAEd,gCAAW,MAAM;AAChB,QAAK,mBAAmB,SAAU;AACjC,YAAM,eAAe,UAAU,QAAQ;AAAA,QACtC,CAAE,cACD,qCAAsB,KAAM,MAAM,mBAAmB;AAAA,MACvD;AAEA,UAAK,cAAe;AACnB,oBAAa,aAAa,QAAS;AAInC,cAAM,YAAY,SAAS;AAAA,UAC1B,gBAAiB,aAAa,QAAS;AAAA,QACxC;AACA,mBAAW,MAAM;AAAA,MAClB;AAAA,IACD;AAAA,EACD,GAAG,CAAE,oBAAoB,WAAY,CAAE;AACxC;",
|
|
6
|
+
"names": ["blockEditorStore"]
|
|
7
|
+
}
|
|
@@ -1,32 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
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
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var header_exports = {};
|
|
29
|
+
__export(header_exports, {
|
|
30
|
+
default: () => header_default
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
/**
|
|
19
|
-
* External dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* WordPress dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Internal dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
32
|
+
module.exports = __toCommonJS(header_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_clsx = __toESM(require("clsx"));
|
|
35
|
+
var import_components = require("@wordpress/components");
|
|
36
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
37
|
+
var import_element = require("@wordpress/element");
|
|
38
|
+
var import_keycodes = require("@wordpress/keycodes");
|
|
39
|
+
var import_i18n = require("@wordpress/i18n");
|
|
40
|
+
var import_icons = require("@wordpress/icons");
|
|
41
|
+
var import_inserter = __toESM(require("../inserter"));
|
|
42
|
+
var import_more_menu = __toESM(require("../more-menu"));
|
|
30
43
|
function Header({
|
|
31
44
|
sidebar,
|
|
32
45
|
inserter,
|
|
@@ -34,52 +47,78 @@ function Header({
|
|
|
34
47
|
setIsInserterOpened,
|
|
35
48
|
isFixedToolbarActive
|
|
36
49
|
}) {
|
|
37
|
-
const [[hasUndo, hasRedo], setUndoRedo] = (0,
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
const [[hasUndo, hasRedo], setUndoRedo] = (0, import_element.useState)([
|
|
51
|
+
sidebar.hasUndo(),
|
|
52
|
+
sidebar.hasRedo()
|
|
53
|
+
]);
|
|
54
|
+
const shortcut = (0, import_keycodes.isAppleOS)() ? import_keycodes.displayShortcut.primaryShift("z") : import_keycodes.displayShortcut.primary("y");
|
|
55
|
+
(0, import_element.useEffect)(() => {
|
|
40
56
|
return sidebar.subscribeHistory(() => {
|
|
41
57
|
setUndoRedo([sidebar.hasUndo(), sidebar.hasRedo()]);
|
|
42
58
|
});
|
|
43
59
|
}, [sidebar]);
|
|
44
|
-
return
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
61
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: (0, import_clsx.default)("customize-widgets-header", {
|
|
65
|
+
"is-fixed-toolbar-active": isFixedToolbarActive
|
|
66
|
+
}),
|
|
67
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
68
|
+
import_block_editor.NavigableToolbar,
|
|
69
|
+
{
|
|
70
|
+
className: "customize-widgets-header-toolbar",
|
|
71
|
+
"aria-label": (0, import_i18n.__)("Document tools"),
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
import_components.ToolbarButton,
|
|
75
|
+
{
|
|
76
|
+
icon: !(0, import_i18n.isRTL)() ? import_icons.undo : import_icons.redo,
|
|
77
|
+
label: (0, import_i18n.__)("Undo"),
|
|
78
|
+
shortcut: import_keycodes.displayShortcut.primary("z"),
|
|
79
|
+
disabled: !hasUndo,
|
|
80
|
+
onClick: sidebar.undo,
|
|
81
|
+
className: "customize-widgets-editor-history-button undo-button"
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
+
import_components.ToolbarButton,
|
|
86
|
+
{
|
|
87
|
+
icon: !(0, import_i18n.isRTL)() ? import_icons.redo : import_icons.undo,
|
|
88
|
+
label: (0, import_i18n.__)("Redo"),
|
|
89
|
+
shortcut,
|
|
90
|
+
disabled: !hasRedo,
|
|
91
|
+
onClick: sidebar.redo,
|
|
92
|
+
className: "customize-widgets-editor-history-button redo-button"
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
+
import_components.ToolbarButton,
|
|
97
|
+
{
|
|
98
|
+
className: "customize-widgets-header-toolbar__inserter-toggle",
|
|
99
|
+
isPressed: isInserterOpened,
|
|
100
|
+
variant: "primary",
|
|
101
|
+
icon: import_icons.plus,
|
|
102
|
+
label: (0, import_i18n._x)(
|
|
103
|
+
"Add block",
|
|
104
|
+
"Generic label for block inserter button"
|
|
105
|
+
),
|
|
106
|
+
onClick: () => {
|
|
107
|
+
setIsInserterOpened((isOpen) => !isOpen);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_more_menu.default, {})
|
|
112
|
+
]
|
|
76
113
|
}
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
(0, import_element.createPortal)(
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_inserter.default, { setIsOpened: setIsInserterOpened }),
|
|
119
|
+
inserter.contentContainer[0]
|
|
120
|
+
)
|
|
121
|
+
] });
|
|
83
122
|
}
|
|
84
|
-
var
|
|
85
|
-
//# sourceMappingURL=index.js.map
|
|
123
|
+
var header_default = Header;
|
|
124
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/header/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { ToolbarButton } from '@wordpress/components';\nimport { NavigableToolbar } from '@wordpress/block-editor';\nimport { createPortal, useEffect, useState } from '@wordpress/element';\nimport { displayShortcut, isAppleOS } from '@wordpress/keycodes';\nimport { __, _x, isRTL } from '@wordpress/i18n';\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={ clsx( '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\tdisabled={ ! 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\tdisabled={ ! 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CE;AAzCF,kBAAiB;AAKjB,wBAA8B;AAC9B,0BAAiC;AACjC,qBAAkD;AAClD,sBAA2C;AAC3C,kBAA8B;AAC9B,mBAAyD;AAKzD,sBAAqB;AACrB,uBAAqB;AAErB,SAAS,OAAQ;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,CAAE,SAAS,OAAQ,GAAG,WAAY,QAAI,yBAAU;AAAA,IACvD,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,EACjB,CAAE;AAEF,QAAM,eAAW,2BAAU,IACxB,gCAAgB,aAAc,GAAI,IAClC,gCAAgB,QAAS,GAAI;AAEhC,gCAAW,MAAM;AAChB,WAAO,QAAQ,iBAAkB,MAAM;AACtC,kBAAa,CAAE,QAAQ,QAAQ,GAAG,QAAQ,QAAQ,CAAE,CAAE;AAAA,IACvD,CAAE;AAAA,EACH,GAAG,CAAE,OAAQ,CAAE;AAEf,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAA,SAAM,4BAA4B;AAAA,UAC7C,2BAA2B;AAAA,QAC5B,CAAE;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,kBAAa,gBAAI,gBAAiB;AAAA,YAElC;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,MAAO,KAAE,mBAAM,IAAI,aAAAC,OAAW,aAAAC;AAAA,kBAE9B,WAAQ,gBAAI,MAAO;AAAA,kBACnB,UAAW,gCAAgB,QAAS,GAAI;AAAA,kBACxC,UAAW,CAAE;AAAA,kBACb,SAAU,QAAQ;AAAA,kBAClB,WAAU;AAAA;AAAA,cACX;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACA,MAAO,KAAE,mBAAM,IAAI,aAAAA,OAAW,aAAAD;AAAA,kBAE9B,WAAQ,gBAAI,MAAO;AAAA,kBACnB;AAAA,kBACA,UAAW,CAAE;AAAA,kBACb,SAAU,QAAQ;AAAA,kBAClB,WAAU;AAAA;AAAA,cACX;AAAA,cAEA;AAAA,gBAAC;AAAA;AAAA,kBACA,WAAU;AAAA,kBACV,WAAY;AAAA,kBACZ,SAAQ;AAAA,kBACR,MAAO;AAAA,kBACP,WAAQ;AAAA,oBACP;AAAA,oBACA;AAAA,kBACD;AAAA,kBACA,SAAU,MAAM;AACf,wCAAqB,CAAE,WAAY,CAAE,MAAO;AAAA,kBAC7C;AAAA;AAAA,cACD;AAAA,cACA,4CAAC,iBAAAE,SAAA,EAAS;AAAA;AAAA;AAAA,QACX;AAAA;AAAA,IACD;AAAA,QAEE;AAAA,MACD,4CAAC,gBAAAC,SAAA,EAAS,aAAc,qBAAsB;AAAA,MAC9C,SAAS,iBAAkB,CAAE;AAAA,IAC9B;AAAA,KACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
|
+
"names": ["clsx", "undoIcon", "redoIcon", "MoreMenu", "Inserter"]
|
|
7
|
+
}
|