@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,42 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useState,
|
|
5
|
+
useEffect,
|
|
6
|
+
useContext,
|
|
7
|
+
useCallback,
|
|
8
|
+
useMemo
|
|
9
|
+
} from "@wordpress/element";
|
|
10
|
+
import { settingIdToWidgetId } from "../../utils";
|
|
11
11
|
const FocusControlContext = createContext();
|
|
12
|
-
FocusControlContext.displayName =
|
|
13
|
-
|
|
14
|
-
api,
|
|
15
|
-
sidebarControls,
|
|
16
|
-
children
|
|
17
|
-
}) {
|
|
12
|
+
FocusControlContext.displayName = "FocusControlContext";
|
|
13
|
+
function FocusControl({ api, sidebarControls, children }) {
|
|
18
14
|
const [focusedWidgetIdRef, setFocusedWidgetIdRef] = useState({
|
|
19
15
|
current: null
|
|
20
16
|
});
|
|
21
|
-
const focusWidget = useCallback(
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
break;
|
|
17
|
+
const focusWidget = useCallback(
|
|
18
|
+
(widgetId) => {
|
|
19
|
+
for (const sidebarControl of sidebarControls) {
|
|
20
|
+
const widgets = sidebarControl.setting.get();
|
|
21
|
+
if (widgets.includes(widgetId)) {
|
|
22
|
+
sidebarControl.sectionInstance.expand({
|
|
23
|
+
// Schedule it after the complete callback so that
|
|
24
|
+
// it won't be overridden by the "Back" button focus.
|
|
25
|
+
completeCallback() {
|
|
26
|
+
setFocusedWidgetIdRef({ current: widgetId });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
37
31
|
}
|
|
38
|
-
}
|
|
39
|
-
|
|
32
|
+
},
|
|
33
|
+
[sidebarControls]
|
|
34
|
+
);
|
|
40
35
|
useEffect(() => {
|
|
41
36
|
function handleFocus(settingId) {
|
|
42
37
|
const widgetId = settingIdToWidgetId(settingId);
|
|
@@ -44,22 +39,32 @@ export default function FocusControl({
|
|
|
44
39
|
}
|
|
45
40
|
let previewBound = false;
|
|
46
41
|
function handleReady() {
|
|
47
|
-
api.previewer.preview.bind(
|
|
42
|
+
api.previewer.preview.bind(
|
|
43
|
+
"focus-control-for-setting",
|
|
44
|
+
handleFocus
|
|
45
|
+
);
|
|
48
46
|
previewBound = true;
|
|
49
47
|
}
|
|
50
|
-
api.previewer.bind(
|
|
48
|
+
api.previewer.bind("ready", handleReady);
|
|
51
49
|
return () => {
|
|
52
|
-
api.previewer.unbind(
|
|
50
|
+
api.previewer.unbind("ready", handleReady);
|
|
53
51
|
if (previewBound) {
|
|
54
|
-
api.previewer.preview.unbind(
|
|
52
|
+
api.previewer.preview.unbind(
|
|
53
|
+
"focus-control-for-setting",
|
|
54
|
+
handleFocus
|
|
55
|
+
);
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
}, [api, focusWidget]);
|
|
58
|
-
const context = useMemo(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
59
|
+
const context = useMemo(
|
|
60
|
+
() => [focusedWidgetIdRef, focusWidget],
|
|
61
|
+
[focusedWidgetIdRef, focusWidget]
|
|
62
|
+
);
|
|
63
|
+
return /* @__PURE__ */ jsx(FocusControlContext.Provider, { value: context, children });
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const useFocusControl = () => useContext(FocusControlContext);
|
|
66
|
+
export {
|
|
67
|
+
FocusControl as default,
|
|
68
|
+
useFocusControl
|
|
69
|
+
};
|
|
70
|
+
//# 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": "AAoFE;AAjFF;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,2BAA2B;AAEpC,MAAM,sBAAsB,cAAc;AAC1C,oBAAoB,cAAc;AAEnB,SAAR,aAA+B,EAAE,KAAK,iBAAiB,SAAS,GAAI;AAC1E,QAAM,CAAE,oBAAoB,qBAAsB,IAAI,SAAU;AAAA,IAC/D,SAAS;AAAA,EACV,CAAE;AAEF,QAAM,cAAc;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,YAAW,MAAM;AAChB,aAAS,YAAa,WAAY;AACjC,YAAM,WAAW,oBAAqB,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,UAAU;AAAA,IACf,MAAM,CAAE,oBAAoB,WAAY;AAAA,IACxC,CAAE,oBAAoB,WAAY;AAAA,EACnC;AAEA,SACC,oBAAC,oBAAoB,UAApB,EAA6B,OAAQ,SACnC,UACH;AAEF;AAEO,MAAM,kBAAkB,MAAM,WAAY,mBAAoB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import { useFocusControl } from '.';
|
|
13
|
-
export default function useBlocksFocusControl(blocks) {
|
|
14
|
-
const {
|
|
15
|
-
selectBlock
|
|
16
|
-
} = useDispatch(blockEditorStore);
|
|
1
|
+
import { useRef, useEffect } from "@wordpress/element";
|
|
2
|
+
import { useDispatch } from "@wordpress/data";
|
|
3
|
+
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
4
|
+
import { getWidgetIdFromBlock } from "@wordpress/widgets";
|
|
5
|
+
import { useFocusControl } from ".";
|
|
6
|
+
function useBlocksFocusControl(blocks) {
|
|
7
|
+
const { selectBlock } = useDispatch(blockEditorStore);
|
|
17
8
|
const [focusedWidgetIdRef] = useFocusControl();
|
|
18
9
|
const blocksRef = useRef(blocks);
|
|
19
10
|
useEffect(() => {
|
|
@@ -21,16 +12,20 @@ export default function useBlocksFocusControl(blocks) {
|
|
|
21
12
|
}, [blocks]);
|
|
22
13
|
useEffect(() => {
|
|
23
14
|
if (focusedWidgetIdRef.current) {
|
|
24
|
-
const focusedBlock = blocksRef.current.find(
|
|
15
|
+
const focusedBlock = blocksRef.current.find(
|
|
16
|
+
(block) => getWidgetIdFromBlock(block) === focusedWidgetIdRef.current
|
|
17
|
+
);
|
|
25
18
|
if (focusedBlock) {
|
|
26
19
|
selectBlock(focusedBlock.clientId);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const blockNode = document.querySelector(`[data-block="${focusedBlock.clientId}"]`);
|
|
20
|
+
const blockNode = document.querySelector(
|
|
21
|
+
`[data-block="${focusedBlock.clientId}"]`
|
|
22
|
+
);
|
|
31
23
|
blockNode?.focus();
|
|
32
24
|
}
|
|
33
25
|
}
|
|
34
26
|
}, [focusedWidgetIdRef, selectBlock]);
|
|
35
27
|
}
|
|
36
|
-
|
|
28
|
+
export {
|
|
29
|
+
useBlocksFocusControl as default
|
|
30
|
+
};
|
|
31
|
+
//# 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": "AAGA,SAAS,QAAQ,iBAAiB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,4BAA4B;AAKrC,SAAS,uBAAuB;AAEjB,SAAR,sBAAwC,QAAS;AACvD,QAAM,EAAE,YAAY,IAAI,YAAa,gBAAiB;AACtD,QAAM,CAAE,kBAAmB,IAAI,gBAAgB;AAE/C,QAAM,YAAY,OAAQ,MAAO;AAEjC,YAAW,MAAM;AAChB,cAAU,UAAU;AAAA,EACrB,GAAG,CAAE,MAAO,CAAE;AAEd,YAAW,MAAM;AAChB,QAAK,mBAAmB,SAAU;AACjC,YAAM,eAAe,UAAU,QAAQ;AAAA,QACtC,CAAE,UACD,qBAAsB,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": []
|
|
7
|
+
}
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { createPortal, useEffect, useState } from '@wordpress/element';
|
|
12
|
-
import { displayShortcut, isAppleOS } from '@wordpress/keycodes';
|
|
13
|
-
import { __, _x, isRTL } from '@wordpress/i18n';
|
|
14
|
-
import { plus, undo as undoIcon, redo as redoIcon } from '@wordpress/icons';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
import Inserter from '../inserter';
|
|
20
|
-
import MoreMenu from '../more-menu';
|
|
21
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { ToolbarButton } from "@wordpress/components";
|
|
4
|
+
import { NavigableToolbar } from "@wordpress/block-editor";
|
|
5
|
+
import { createPortal, useEffect, useState } from "@wordpress/element";
|
|
6
|
+
import { displayShortcut, isAppleOS } from "@wordpress/keycodes";
|
|
7
|
+
import { __, _x, isRTL } from "@wordpress/i18n";
|
|
8
|
+
import { plus, undo as undoIcon, redo as redoIcon } from "@wordpress/icons";
|
|
9
|
+
import Inserter from "../inserter";
|
|
10
|
+
import MoreMenu from "../more-menu";
|
|
22
11
|
function Header({
|
|
23
12
|
sidebar,
|
|
24
13
|
inserter,
|
|
@@ -26,52 +15,81 @@ function Header({
|
|
|
26
15
|
setIsInserterOpened,
|
|
27
16
|
isFixedToolbarActive
|
|
28
17
|
}) {
|
|
29
|
-
const [[hasUndo, hasRedo], setUndoRedo] = useState([
|
|
30
|
-
|
|
18
|
+
const [[hasUndo, hasRedo], setUndoRedo] = useState([
|
|
19
|
+
sidebar.hasUndo(),
|
|
20
|
+
sidebar.hasRedo()
|
|
21
|
+
]);
|
|
22
|
+
const shortcut = isAppleOS() ? displayShortcut.primaryShift("z") : displayShortcut.primary("y");
|
|
31
23
|
useEffect(() => {
|
|
32
24
|
return sidebar.subscribeHistory(() => {
|
|
33
25
|
setUndoRedo([sidebar.hasUndo(), sidebar.hasRedo()]);
|
|
34
26
|
});
|
|
35
27
|
}, [sidebar]);
|
|
36
|
-
return
|
|
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
|
-
|
|
28
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
className: clsx("customize-widgets-header", {
|
|
33
|
+
"is-fixed-toolbar-active": isFixedToolbarActive
|
|
34
|
+
}),
|
|
35
|
+
children: /* @__PURE__ */ jsxs(
|
|
36
|
+
NavigableToolbar,
|
|
37
|
+
{
|
|
38
|
+
className: "customize-widgets-header-toolbar",
|
|
39
|
+
"aria-label": __("Document tools"),
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
42
|
+
ToolbarButton,
|
|
43
|
+
{
|
|
44
|
+
icon: !isRTL() ? undoIcon : redoIcon,
|
|
45
|
+
label: __("Undo"),
|
|
46
|
+
shortcut: displayShortcut.primary("z"),
|
|
47
|
+
disabled: !hasUndo,
|
|
48
|
+
onClick: sidebar.undo,
|
|
49
|
+
className: "customize-widgets-editor-history-button undo-button"
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
ToolbarButton,
|
|
54
|
+
{
|
|
55
|
+
icon: !isRTL() ? redoIcon : undoIcon,
|
|
56
|
+
label: __("Redo"),
|
|
57
|
+
shortcut,
|
|
58
|
+
disabled: !hasRedo,
|
|
59
|
+
onClick: sidebar.redo,
|
|
60
|
+
className: "customize-widgets-editor-history-button redo-button"
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
ToolbarButton,
|
|
65
|
+
{
|
|
66
|
+
className: "customize-widgets-header-toolbar__inserter-toggle",
|
|
67
|
+
isPressed: isInserterOpened,
|
|
68
|
+
variant: "primary",
|
|
69
|
+
icon: plus,
|
|
70
|
+
label: _x(
|
|
71
|
+
"Add block",
|
|
72
|
+
"Generic label for block inserter button"
|
|
73
|
+
),
|
|
74
|
+
onClick: () => {
|
|
75
|
+
setIsInserterOpened((isOpen) => !isOpen);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsx(MoreMenu, {})
|
|
80
|
+
]
|
|
68
81
|
}
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
createPortal(
|
|
86
|
+
/* @__PURE__ */ jsx(Inserter, { setIsOpened: setIsInserterOpened }),
|
|
87
|
+
inserter.contentContainer[0]
|
|
88
|
+
)
|
|
89
|
+
] });
|
|
75
90
|
}
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
var header_default = Header;
|
|
92
|
+
export {
|
|
93
|
+
header_default as default
|
|
94
|
+
};
|
|
95
|
+
//# 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": "AA4CE,mBAUG,KAJD,YANF;AAzCF,OAAO,UAAU;AAKjB,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,cAAc,WAAW,gBAAgB;AAClD,SAAS,iBAAiB,iBAAiB;AAC3C,SAAS,IAAI,IAAI,aAAa;AAC9B,SAAS,MAAM,QAAQ,UAAU,QAAQ,gBAAgB;AAKzD,OAAO,cAAc;AACrB,OAAO,cAAc;AAErB,SAAS,OAAQ;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,CAAE,SAAS,OAAQ,GAAG,WAAY,IAAI,SAAU;AAAA,IACvD,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,EACjB,CAAE;AAEF,QAAM,WAAW,UAAU,IACxB,gBAAgB,aAAc,GAAI,IAClC,gBAAgB,QAAS,GAAI;AAEhC,YAAW,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,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,WAAY,KAAM,4BAA4B;AAAA,UAC7C,2BAA2B;AAAA,QAC5B,CAAE;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,cAAa,GAAI,gBAAiB;AAAA,YAElC;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,MAAO,CAAE,MAAM,IAAI,WAAW;AAAA,kBAE9B,OAAQ,GAAI,MAAO;AAAA,kBACnB,UAAW,gBAAgB,QAAS,GAAI;AAAA,kBACxC,UAAW,CAAE;AAAA,kBACb,SAAU,QAAQ;AAAA,kBAClB,WAAU;AAAA;AAAA,cACX;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACA,MAAO,CAAE,MAAM,IAAI,WAAW;AAAA,kBAE9B,OAAQ,GAAI,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,OAAQ;AAAA,oBACP;AAAA,oBACA;AAAA,kBACD;AAAA,kBACA,SAAU,MAAM;AACf,wCAAqB,CAAE,WAAY,CAAE,MAAO;AAAA,kBAC7C;AAAA;AAAA,cACD;AAAA,cACA,oBAAC,YAAS;AAAA;AAAA;AAAA,QACX;AAAA;AAAA,IACD;AAAA,IAEE;AAAA,MACD,oBAAC,YAAS,aAAc,qBAAsB;AAAA,MAC9C,SAAS,iBAAkB,CAAE;AAAA,IAC9B;AAAA,KACD;AAEF;AAEA,IAAO,iBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,48 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { __experimentalLibrary as Library } from "@wordpress/block-editor";
|
|
4
|
+
import { Button } from "@wordpress/components";
|
|
5
|
+
import { useInstanceId } from "@wordpress/compose";
|
|
6
|
+
import { useSelect } from "@wordpress/data";
|
|
7
|
+
import { closeSmall } from "@wordpress/icons";
|
|
8
|
+
import { store as customizeWidgetsStore } from "../../store";
|
|
9
|
+
function Inserter({ setIsOpened }) {
|
|
10
|
+
const inserterTitleId = useInstanceId(
|
|
11
|
+
Inserter,
|
|
12
|
+
"customize-widget-layout__inserter-panel-title"
|
|
13
|
+
);
|
|
14
|
+
const insertionPoint = useSelect(
|
|
15
|
+
(select) => select(customizeWidgetsStore).__experimentalGetInsertionPoint(),
|
|
16
|
+
[]
|
|
17
|
+
);
|
|
18
|
+
return /* @__PURE__ */ jsxs(
|
|
19
|
+
"div",
|
|
20
|
+
{
|
|
21
|
+
className: "customize-widgets-layout__inserter-panel",
|
|
22
|
+
"aria-labelledby": inserterTitleId,
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ jsxs("div", { className: "customize-widgets-layout__inserter-panel-header", children: [
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
"h2",
|
|
27
|
+
{
|
|
28
|
+
id: inserterTitleId,
|
|
29
|
+
className: "customize-widgets-layout__inserter-panel-header-title",
|
|
30
|
+
children: __("Add a block")
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
Button,
|
|
35
|
+
{
|
|
36
|
+
size: "small",
|
|
37
|
+
icon: closeSmall,
|
|
38
|
+
onClick: () => setIsOpened(false),
|
|
39
|
+
"aria-label": __("Close inserter")
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
] }),
|
|
43
|
+
/* @__PURE__ */ jsx("div", { className: "customize-widgets-layout__inserter-panel-content", children: /* @__PURE__ */ jsx(
|
|
44
|
+
Library,
|
|
45
|
+
{
|
|
46
|
+
rootClientId: insertionPoint.rootClientId,
|
|
47
|
+
__experimentalInsertionIndex: insertionPoint.insertionIndex,
|
|
48
|
+
showInserterHelpPanel: true,
|
|
49
|
+
onSelect: () => setIsOpened(false)
|
|
50
|
+
}
|
|
51
|
+
) })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
46
55
|
}
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
var inserter_default = Inserter;
|
|
57
|
+
export {
|
|
58
|
+
inserter_default as default
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/inserter/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../../store';\n\nfunction Inserter( { setIsOpened } ) {\n\tconst inserterTitleId = useInstanceId(\n\t\tInserter,\n\t\t'customize-widget-layout__inserter-panel-title'\n\t);\n\tconst insertionPoint = useSelect(\n\t\t( select ) =>\n\t\t\tselect( customizeWidgetsStore ).__experimentalGetInsertionPoint(),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"customize-widgets-layout__inserter-panel\"\n\t\t\taria-labelledby={ inserterTitleId }\n\t\t>\n\t\t\t<div className=\"customize-widgets-layout__inserter-panel-header\">\n\t\t\t\t<h2\n\t\t\t\t\tid={ inserterTitleId }\n\t\t\t\t\tclassName=\"customize-widgets-layout__inserter-panel-header-title\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add a block' ) }\n\t\t\t\t</h2>\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tonClick={ () => setIsOpened( false ) }\n\t\t\t\t\taria-label={ __( 'Close inserter' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div className=\"customize-widgets-layout__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\trootClientId={ insertionPoint.rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\tinsertionPoint.insertionIndex\n\t\t\t\t\t}\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tonSelect={ () => setIsOpened( false ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default Inserter;\n"],
|
|
5
|
+
"mappings": "AA+BG,SACC,KADD;AA5BH,SAAS,UAAU;AACnB,SAAS,yBAAyB,eAAe;AACjD,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAK3B,SAAS,SAAS,6BAA6B;AAE/C,SAAS,SAAU,EAAE,YAAY,GAAI;AACpC,QAAM,kBAAkB;AAAA,IACvB;AAAA,IACA;AAAA,EACD;AACA,QAAM,iBAAiB;AAAA,IACtB,CAAE,WACD,OAAQ,qBAAsB,EAAE,gCAAgC;AAAA,IACjE,CAAC;AAAA,EACF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,mBAAkB;AAAA,MAElB;AAAA,6BAAC,SAAI,WAAU,mDACd;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,IAAK;AAAA,cACL,WAAU;AAAA,cAER,aAAI,aAAc;AAAA;AAAA,UACrB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,MAAK;AAAA,cACL,MAAO;AAAA,cACP,SAAU,MAAM,YAAa,KAAM;AAAA,cACnC,cAAa,GAAI,gBAAiB;AAAA;AAAA,UACnC;AAAA,WACD;AAAA,QACA,oBAAC,SAAI,WAAU,oDACd;AAAA,UAAC;AAAA;AAAA,YACA,cAAe,eAAe;AAAA,YAC9B,8BACC,eAAe;AAAA,YAEhB,uBAAqB;AAAA,YACrB,UAAW,MAAM,YAAa,KAAM;AAAA;AAAA,QACrC,GACD;AAAA;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,mBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { store as customizeWidgetsStore } from '../../store';
|
|
11
|
-
export default function useInserter(inserter) {
|
|
12
|
-
const isInserterOpened = useSelect(select => select(customizeWidgetsStore).isInserterOpened(), []);
|
|
13
|
-
const {
|
|
14
|
-
setIsInserterOpened
|
|
15
|
-
} = useDispatch(customizeWidgetsStore);
|
|
1
|
+
import { useEffect, useCallback } from "@wordpress/element";
|
|
2
|
+
import { useSelect, useDispatch, select as selectStore } from "@wordpress/data";
|
|
3
|
+
import { store as customizeWidgetsStore } from "../../store";
|
|
4
|
+
function useInserter(inserter) {
|
|
5
|
+
const isInserterOpened = useSelect(
|
|
6
|
+
(select) => select(customizeWidgetsStore).isInserterOpened(),
|
|
7
|
+
[]
|
|
8
|
+
);
|
|
9
|
+
const { setIsInserterOpened } = useDispatch(customizeWidgetsStore);
|
|
16
10
|
useEffect(() => {
|
|
17
11
|
if (isInserterOpened) {
|
|
18
12
|
inserter.open();
|
|
@@ -20,12 +14,23 @@ export default function useInserter(inserter) {
|
|
|
20
14
|
inserter.close();
|
|
21
15
|
}
|
|
22
16
|
}, [inserter, isInserterOpened]);
|
|
23
|
-
return [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
return [
|
|
18
|
+
isInserterOpened,
|
|
19
|
+
useCallback(
|
|
20
|
+
(updater) => {
|
|
21
|
+
let isOpen = updater;
|
|
22
|
+
if (typeof updater === "function") {
|
|
23
|
+
isOpen = updater(
|
|
24
|
+
selectStore(customizeWidgetsStore).isInserterOpened()
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
setIsInserterOpened(isOpen);
|
|
28
|
+
},
|
|
29
|
+
[setIsInserterOpened]
|
|
30
|
+
)
|
|
31
|
+
];
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
export {
|
|
34
|
+
useInserter as default
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=use-inserter.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/inserter/use-inserter.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch, select as selectStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../../store';\n\nexport default function useInserter( inserter ) {\n\tconst isInserterOpened = useSelect(\n\t\t( select ) => select( customizeWidgetsStore ).isInserterOpened(),\n\t\t[]\n\t);\n\tconst { setIsInserterOpened } = useDispatch( customizeWidgetsStore );\n\n\tuseEffect( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\tinserter.open();\n\t\t} else {\n\t\t\tinserter.close();\n\t\t}\n\t}, [ inserter, isInserterOpened ] );\n\n\treturn [\n\t\tisInserterOpened,\n\t\tuseCallback(\n\t\t\t( updater ) => {\n\t\t\t\tlet isOpen = updater;\n\t\t\t\tif ( typeof updater === 'function' ) {\n\t\t\t\t\tisOpen = updater(\n\t\t\t\t\t\tselectStore( customizeWidgetsStore ).isInserterOpened()\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsetIsInserterOpened( isOpen );\n\t\t\t},\n\t\t\t[ setIsInserterOpened ]\n\t\t),\n\t];\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,WAAW,aAAa,UAAU,mBAAmB;AAK9D,SAAS,SAAS,6BAA6B;AAEhC,SAAR,YAA8B,UAAW;AAC/C,QAAM,mBAAmB;AAAA,IACxB,CAAE,WAAY,OAAQ,qBAAsB,EAAE,iBAAiB;AAAA,IAC/D,CAAC;AAAA,EACF;AACA,QAAM,EAAE,oBAAoB,IAAI,YAAa,qBAAsB;AAEnE,YAAW,MAAM;AAChB,QAAK,kBAAmB;AACvB,eAAS,KAAK;AAAA,IACf,OAAO;AACN,eAAS,MAAM;AAAA,IAChB;AAAA,EACD,GAAG,CAAE,UAAU,gBAAiB,CAAE;AAElC,SAAO;AAAA,IACN;AAAA,IACA;AAAA,MACC,CAAE,YAAa;AACd,YAAI,SAAS;AACb,YAAK,OAAO,YAAY,YAAa;AACpC,mBAAS;AAAA,YACR,YAAa,qBAAsB,EAAE,iBAAiB;AAAA,UACvD;AAAA,QACD;AAEA,4BAAqB,MAAO;AAAA,MAC7B;AAAA,MACA,CAAE,mBAAoB;AAAA,IACvB;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|