@wordpress/edit-widgets 6.31.1-next.f56bd8138.0 → 6.32.1-next.47f435fc9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/blocks/widget-area/block.json +26 -0
- package/build/blocks/widget-area/edit/index.js +94 -87
- package/build/blocks/widget-area/edit/index.js.map +7 -1
- package/build/blocks/widget-area/edit/inner-blocks.js +68 -50
- package/build/blocks/widget-area/edit/inner-blocks.js.map +7 -1
- package/build/blocks/widget-area/edit/use-is-dragging-within.js +34 -40
- package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +7 -1
- package/build/blocks/widget-area/index.js +49 -52
- package/build/blocks/widget-area/index.js.map +7 -1
- package/build/components/error-boundary/index.js +49 -51
- package/build/components/error-boundary/index.js.map +7 -1
- package/build/components/header/document-tools/index.js +104 -74
- package/build/components/header/document-tools/index.js.map +7 -1
- package/build/components/header/index.js +81 -62
- package/build/components/header/index.js.map +7 -1
- package/build/components/header/undo-redo/redo.js +50 -38
- package/build/components/header/undo-redo/redo.js.map +7 -1
- package/build/components/header/undo-redo/undo.js +49 -37
- package/build/components/header/undo-redo/undo.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 +154 -103
- package/build/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +74 -56
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build/components/keyboard-shortcuts/index.js +89 -82
- package/build/components/keyboard-shortcuts/index.js.map +7 -1
- package/build/components/layout/index.js +75 -49
- package/build/components/layout/index.js.map +7 -1
- package/build/components/layout/interface.js +89 -75
- package/build/components/layout/interface.js.map +7 -1
- package/build/components/layout/unsaved-changes-warning.js +35 -42
- package/build/components/layout/unsaved-changes-warning.js.map +7 -1
- package/build/components/more-menu/index.js +189 -108
- package/build/components/more-menu/index.js.map +7 -1
- package/build/components/more-menu/tools-more-menu-group.js +29 -23
- package/build/components/more-menu/tools-more-menu-group.js.map +7 -1
- package/build/components/notices/index.js +62 -48
- package/build/components/notices/index.js.map +7 -1
- package/build/components/save-button/index.js +55 -47
- package/build/components/save-button/index.js.map +7 -1
- package/build/components/secondary-sidebar/index.js +41 -34
- package/build/components/secondary-sidebar/index.js.map +7 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +55 -46
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +7 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +76 -67
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +7 -1
- package/build/components/sidebar/index.js +149 -138
- package/build/components/sidebar/index.js.map +7 -1
- package/build/components/sidebar/widget-areas.js +73 -57
- package/build/components/sidebar/widget-areas.js.map +7 -1
- package/build/components/welcome-guide/index.js +182 -137
- package/build/components/welcome-guide/index.js.map +7 -1
- package/build/components/widget-areas-block-editor-content/index.js +64 -43
- package/build/components/widget-areas-block-editor-content/index.js.map +7 -1
- package/build/components/widget-areas-block-editor-provider/index.js +115 -92
- package/build/components/widget-areas-block-editor-provider/index.js.map +7 -1
- package/build/constants.js +30 -8
- package/build/constants.js.map +7 -1
- package/build/filters/index.js +3 -5
- package/build/filters/index.js.map +7 -1
- package/build/filters/move-to-widget-area.js +52 -59
- package/build/filters/move-to-widget-area.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/hooks/use-last-selected-widget-area.js +38 -44
- package/build/hooks/use-last-selected-widget-area.js.map +7 -1
- package/build/hooks/use-widget-library-insertion-point.js +60 -55
- package/build/hooks/use-widget-library-insertion-point.js.map +7 -1
- package/build/index.js +86 -93
- 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 +181 -313
- 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 +51 -51
- package/build/store/index.js.map +7 -1
- package/build/store/private-selectors.js +28 -7
- package/build/store/private-selectors.js.map +7 -1
- package/build/store/reducer.js +65 -118
- package/build/store/reducer.js.map +7 -1
- package/build/store/resolvers.js +64 -63
- package/build/store/resolvers.js.map +7 -1
- package/build/store/selectors.js +194 -231
- package/build/store/selectors.js.map +7 -1
- package/build/store/transformers.js +47 -41
- package/build/store/transformers.js.map +7 -1
- package/build/store/utils.js +47 -70
- package/build/store/utils.js.map +7 -1
- package/build-module/blocks/widget-area/block.json +26 -0
- package/build-module/blocks/widget-area/edit/index.js +63 -75
- package/build-module/blocks/widget-area/edit/index.js.map +7 -1
- package/build-module/blocks/widget-area/edit/inner-blocks.js +38 -41
- package/build-module/blocks/widget-area/edit/inner-blocks.js.map +7 -1
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +14 -33
- package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +7 -1
- package/build-module/blocks/widget-area/index.js +14 -46
- package/build-module/blocks/widget-area/index.js.map +7 -1
- package/build-module/components/error-boundary/index.js +30 -43
- package/build-module/components/error-boundary/index.js.map +7 -1
- package/build-module/components/header/document-tools/index.js +75 -66
- package/build-module/components/header/document-tools/index.js.map +7 -1
- package/build-module/components/header/index.js +52 -54
- package/build-module/components/header/index.js.map +7 -1
- package/build-module/components/header/undo-redo/redo.js +32 -32
- package/build-module/components/header/undo-redo/redo.js.map +7 -1
- package/build-module/components/header/undo-redo/undo.js +31 -31
- package/build-module/components/header/undo-redo/undo.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 -97
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +56 -50
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcuts/index.js +73 -75
- package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
- package/build-module/components/layout/index.js +46 -41
- package/build-module/components/layout/index.js.map +7 -1
- package/build-module/components/layout/interface.js +63 -66
- package/build-module/components/layout/interface.js.map +7 -1
- package/build-module/components/layout/unsaved-changes-warning.js +17 -37
- package/build-module/components/layout/unsaved-changes-warning.js.map +7 -1
- package/build-module/components/more-menu/index.js +167 -102
- package/build-module/components/more-menu/index.js.map +7 -1
- package/build-module/components/more-menu/tools-more-menu-group.js +11 -17
- package/build-module/components/more-menu/tools-more-menu-group.js.map +7 -1
- package/build-module/components/notices/index.js +43 -42
- package/build-module/components/notices/index.js.map +7 -1
- package/build-module/components/save-button/index.js +37 -41
- package/build-module/components/save-button/index.js.map +7 -1
- package/build-module/components/secondary-sidebar/index.js +14 -27
- package/build-module/components/secondary-sidebar/index.js.map +7 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +26 -38
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +7 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +57 -60
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +7 -1
- package/build-module/components/sidebar/index.js +129 -127
- package/build-module/components/sidebar/index.js.map +7 -1
- package/build-module/components/sidebar/widget-areas.js +53 -49
- package/build-module/components/sidebar/widget-areas.js.map +7 -1
- package/build-module/components/welcome-guide/index.js +165 -132
- package/build-module/components/welcome-guide/index.js.map +7 -1
- package/build-module/components/widget-areas-block-editor-content/index.js +43 -36
- package/build-module/components/widget-areas-block-editor-content/index.js.map +7 -1
- package/build-module/components/widget-areas-block-editor-provider/index.js +85 -83
- package/build-module/components/widget-areas-block-editor-provider/index.js.map +7 -1
- package/build-module/constants.js +7 -3
- package/build-module/constants.js.map +7 -1
- package/build-module/filters/index.js +3 -6
- package/build-module/filters/index.js.map +7 -1
- package/build-module/filters/move-to-widget-area.js +52 -57
- package/build-module/filters/move-to-widget-area.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/hooks/use-last-selected-widget-area.js +20 -39
- package/build-module/hooks/use-last-selected-widget-area.js.map +7 -1
- package/build-module/hooks/use-widget-library-insertion-point.js +42 -49
- package/build-module/hooks/use-widget-library-insertion-point.js.map +7 -1
- package/build-module/index.js +60 -72
- 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 +153 -293
- 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 +16 -40
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/private-selectors.js +7 -3
- package/build-module/store/private-selectors.js.map +7 -1
- package/build-module/store/reducer.js +42 -111
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/resolvers.js +43 -51
- package/build-module/store/resolvers.js.map +7 -1
- package/build-module/store/selectors.js +171 -224
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/store/transformers.js +23 -34
- package/build-module/store/transformers.js.map +7 -1
- package/build-module/store/utils.js +22 -63
- package/build-module/store/utils.js.map +7 -1
- package/build-style/style-rtl.css +216 -88
- package/build-style/style.css +216 -88
- package/package.json +36 -29
- package/src/blocks/widget-area/editor.scss +3 -0
- package/src/components/customizer-edit-widgets-initializer/style.scss +3 -0
- package/src/components/error-boundary/style.scss +2 -0
- package/src/components/header/style.scss +5 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +2 -0
- package/src/components/layout/style.scss +3 -0
- package/src/components/more-menu/style.scss +2 -0
- package/src/components/notices/style.scss +3 -0
- package/src/components/secondary-sidebar/style.scss +4 -0
- package/src/components/sidebar/style.scss +2 -0
- package/src/components/welcome-guide/style.scss +2 -0
- package/src/components/widget-areas-block-editor-content/style.scss +2 -0
- package/src/style.scss +16 -13
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/secondary-sidebar/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\n/**\n * Internal dependencies\n */\nimport InserterSidebar from './inserter-sidebar';\nimport ListViewSidebar from './list-view-sidebar';\n\nexport default function SecondarySidebar() {\n\tconst { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {\n\t\tconst { isInserterOpened, isListViewOpened } =\n\t\t\tselect( editWidgetsStore );\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t};\n\t}, [] );\n\n\tif ( isInserterOpen ) {\n\t\treturn <InserterSidebar />;\n\t}\n\tif ( isListViewOpen ) {\n\t\treturn <ListViewSidebar />;\n\t}\n\treturn null;\n}\n"],
|
|
5
|
+
"mappings": "AA0BS;AAvBT,SAAS,iBAAiB;AAI1B,SAAS,SAAS,wBAAwB;AAK1C,OAAO,qBAAqB;AAC5B,OAAO,qBAAqB;AAEb,SAAR,mBAAoC;AAC1C,QAAM,EAAE,gBAAgB,eAAe,IAAI,UAAW,CAAE,WAAY;AACnE,UAAM,EAAE,kBAAkB,iBAAiB,IAC1C,OAAQ,gBAAiB;AAC1B,WAAO;AAAA,MACN,gBAAgB,iBAAiB;AAAA,MACjC,gBAAgB,iBAAiB;AAAA,IAClC;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAK,gBAAiB;AACrB,WAAO,oBAAC,mBAAgB;AAAA,EACzB;AACA,MAAK,gBAAiB;AACrB,WAAO,oBAAC,mBAAgB;AAAA,EACzB;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,43 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import useWidgetLibraryInsertionPoint from '../../hooks/use-widget-library-insertion-point';
|
|
13
|
-
import { store as editWidgetsStore } from '../../store';
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
export default function InserterSidebar() {
|
|
16
|
-
const isMobileViewport = useViewportMatch('medium', '<');
|
|
17
|
-
const {
|
|
18
|
-
rootClientId,
|
|
19
|
-
insertionIndex
|
|
20
|
-
} = useWidgetLibraryInsertionPoint();
|
|
21
|
-
const {
|
|
22
|
-
setIsInserterOpened
|
|
23
|
-
} = useDispatch(editWidgetsStore);
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { __experimentalLibrary as Library } from "@wordpress/block-editor";
|
|
3
|
+
import { useViewportMatch } from "@wordpress/compose";
|
|
4
|
+
import { useCallback, useRef } from "@wordpress/element";
|
|
5
|
+
import { useDispatch } from "@wordpress/data";
|
|
6
|
+
import useWidgetLibraryInsertionPoint from "../../hooks/use-widget-library-insertion-point";
|
|
7
|
+
import { store as editWidgetsStore } from "../../store";
|
|
8
|
+
function InserterSidebar() {
|
|
9
|
+
const isMobileViewport = useViewportMatch("medium", "<");
|
|
10
|
+
const { rootClientId, insertionIndex } = useWidgetLibraryInsertionPoint();
|
|
11
|
+
const { setIsInserterOpened } = useDispatch(editWidgetsStore);
|
|
24
12
|
const closeInserter = useCallback(() => {
|
|
25
13
|
return setIsInserterOpened(false);
|
|
26
14
|
}, [setIsInserterOpened]);
|
|
27
15
|
const libraryRef = useRef();
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
});
|
|
16
|
+
return /* @__PURE__ */ jsx("div", { className: "edit-widgets-layout__inserter-panel", children: /* @__PURE__ */ jsx("div", { className: "edit-widgets-layout__inserter-panel-content", children: /* @__PURE__ */ jsx(
|
|
17
|
+
Library,
|
|
18
|
+
{
|
|
19
|
+
showInserterHelpPanel: true,
|
|
20
|
+
shouldFocusBlock: isMobileViewport,
|
|
21
|
+
rootClientId,
|
|
22
|
+
__experimentalInsertionIndex: insertionIndex,
|
|
23
|
+
ref: libraryRef,
|
|
24
|
+
onClose: closeInserter
|
|
25
|
+
}
|
|
26
|
+
) }) });
|
|
42
27
|
}
|
|
43
|
-
|
|
28
|
+
export {
|
|
29
|
+
InserterSidebar as default
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=inserter-sidebar.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/secondary-sidebar/inserter-sidebar.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport useWidgetLibraryInsertionPoint from '../../hooks/use-widget-library-insertion-point';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function InserterSidebar() {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst { rootClientId, insertionIndex } = useWidgetLibraryInsertionPoint();\n\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst closeInserter = useCallback( () => {\n\t\treturn setIsInserterOpened( false );\n\t}, [ setIsInserterOpened ] );\n\n\tconst libraryRef = useRef();\n\n\treturn (\n\t\t<div className=\"edit-widgets-layout__inserter-panel\">\n\t\t\t<div className=\"edit-widgets-layout__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobileViewport }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={ insertionIndex }\n\t\t\t\t\tref={ libraryRef }\n\t\t\t\t\tonClose={ closeInserter }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AA6BI;AA1BJ,SAAS,yBAAyB,eAAe;AACjD,SAAS,wBAAwB;AACjC,SAAS,aAAa,cAAc;AACpC,SAAS,mBAAmB;AAK5B,OAAO,oCAAoC;AAC3C,SAAS,SAAS,wBAAwB;AAE3B,SAAR,kBAAmC;AACzC,QAAM,mBAAmB,iBAAkB,UAAU,GAAI;AACzD,QAAM,EAAE,cAAc,eAAe,IAAI,+BAA+B;AAExE,QAAM,EAAE,oBAAoB,IAAI,YAAa,gBAAiB;AAE9D,QAAM,gBAAgB,YAAa,MAAM;AACxC,WAAO,oBAAqB,KAAM;AAAA,EACnC,GAAG,CAAE,mBAAoB,CAAE;AAE3B,QAAM,aAAa,OAAO;AAE1B,SACC,oBAAC,SAAI,WAAU,uCACd,8BAAC,SAAI,WAAU,+CACd;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,kBAAmB;AAAA,MACnB;AAAA,MACA,8BAA+B;AAAA,MAC/B,KAAM;AAAA,MACN,SAAU;AAAA;AAAA,EACX,GACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,69 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
import { store as editWidgetsStore } from '../../store';
|
|
17
|
-
import { unlock } from '../../lock-unlock';
|
|
18
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
export default function ListViewSidebar() {
|
|
20
|
-
const {
|
|
21
|
-
setIsListViewOpened
|
|
22
|
-
} = useDispatch(editWidgetsStore);
|
|
23
|
-
const {
|
|
24
|
-
getListViewToggleRef
|
|
25
|
-
} = unlock(useSelect(editWidgetsStore));
|
|
26
|
-
|
|
27
|
-
// Use internal state instead of a ref to make sure that the component
|
|
28
|
-
// re-renders when the dropZoneElement updates.
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { __experimentalListView as ListView } from "@wordpress/block-editor";
|
|
3
|
+
import { Button } from "@wordpress/components";
|
|
4
|
+
import { useFocusOnMount, useMergeRefs } from "@wordpress/compose";
|
|
5
|
+
import { useDispatch, useSelect } from "@wordpress/data";
|
|
6
|
+
import { useCallback, useState } from "@wordpress/element";
|
|
7
|
+
import { __ } from "@wordpress/i18n";
|
|
8
|
+
import { closeSmall } from "@wordpress/icons";
|
|
9
|
+
import { ESCAPE } from "@wordpress/keycodes";
|
|
10
|
+
import { store as editWidgetsStore } from "../../store";
|
|
11
|
+
import { unlock } from "../../lock-unlock";
|
|
12
|
+
function ListViewSidebar() {
|
|
13
|
+
const { setIsListViewOpened } = useDispatch(editWidgetsStore);
|
|
14
|
+
const { getListViewToggleRef } = unlock(useSelect(editWidgetsStore));
|
|
29
15
|
const [dropZoneElement, setDropZoneElement] = useState(null);
|
|
30
|
-
const focusOnMountRef = useFocusOnMount(
|
|
31
|
-
|
|
32
|
-
// When closing the list view, focus should return to the toggle button.
|
|
16
|
+
const focusOnMountRef = useFocusOnMount("firstElement");
|
|
33
17
|
const closeListView = useCallback(() => {
|
|
34
18
|
setIsListViewOpened(false);
|
|
35
19
|
getListViewToggleRef().current?.focus();
|
|
36
20
|
}, [getListViewToggleRef, setIsListViewOpened]);
|
|
37
|
-
const closeOnEscape = useCallback(
|
|
38
|
-
|
|
39
|
-
event.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
const closeOnEscape = useCallback(
|
|
22
|
+
(event) => {
|
|
23
|
+
if (event.keyCode === ESCAPE && !event.defaultPrevented) {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
closeListView();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
[closeListView]
|
|
29
|
+
);
|
|
43
30
|
return (
|
|
44
|
-
/*#__PURE__*/
|
|
45
31
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
children: [
|
|
52
|
-
children:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
32
|
+
/* @__PURE__ */ jsxs(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
className: "edit-widgets-editor__list-view-panel",
|
|
36
|
+
onKeyDown: closeOnEscape,
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsxs("div", { className: "edit-widgets-editor__list-view-panel-header", children: [
|
|
39
|
+
/* @__PURE__ */ jsx("strong", { children: __("List View") }),
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
Button,
|
|
42
|
+
{
|
|
43
|
+
icon: closeSmall,
|
|
44
|
+
label: __("Close"),
|
|
45
|
+
onClick: closeListView,
|
|
46
|
+
size: "compact"
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
] }),
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: "edit-widgets-editor__list-view-panel-content",
|
|
54
|
+
ref: useMergeRefs([focusOnMountRef, setDropZoneElement]),
|
|
55
|
+
children: /* @__PURE__ */ jsx(ListView, { dropZoneElement })
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
)
|
|
67
61
|
);
|
|
68
62
|
}
|
|
69
|
-
|
|
63
|
+
export {
|
|
64
|
+
ListViewSidebar as default
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=list-view-sidebar.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/secondary-sidebar/list-view-sidebar.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalListView as ListView } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editWidgetsStore );\n\tconst { getListViewToggleRef } = unlock( useSelect( editWidgetsStore ) );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the dropZoneElement updates.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// When closing the list view, focus should return to the toggle button.\n\tconst closeListView = useCallback( () => {\n\t\tsetIsListViewOpened( false );\n\t\tgetListViewToggleRef().current?.focus();\n\t}, [ getListViewToggleRef, setIsListViewOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseListView();\n\t\t\t}\n\t\t},\n\t\t[ closeListView ]\n\t);\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName=\"edit-widgets-editor__list-view-panel\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t>\n\t\t\t<div className=\"edit-widgets-editor__list-view-panel-header\">\n\t\t\t\t<strong>{ __( 'List View' ) }</strong>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ closeListView }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-widgets-editor__list-view-panel-content\"\n\t\t\t\tref={ useMergeRefs( [ focusOnMountRef, setDropZoneElement ] ) }\n\t\t\t>\n\t\t\t\t<ListView dropZoneElement={ dropZoneElement } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAkDG,SACC,KADD;AA/CH,SAAS,0BAA0B,gBAAgB;AACnD,SAAS,cAAc;AACvB,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,aAAa,iBAAiB;AACvC,SAAS,aAAa,gBAAgB;AACtC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAKvB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAER,SAAR,kBAAmC;AACzC,QAAM,EAAE,oBAAoB,IAAI,YAAa,gBAAiB;AAC9D,QAAM,EAAE,qBAAqB,IAAI,OAAQ,UAAW,gBAAiB,CAAE;AAIvE,QAAM,CAAE,iBAAiB,kBAAmB,IAAI,SAAU,IAAK;AAE/D,QAAM,kBAAkB,gBAAiB,cAAe;AAGxD,QAAM,gBAAgB,YAAa,MAAM;AACxC,wBAAqB,KAAM;AAC3B,yBAAqB,EAAE,SAAS,MAAM;AAAA,EACvC,GAAG,CAAE,sBAAsB,mBAAoB,CAAE;AAEjD,QAAM,gBAAgB;AAAA,IACrB,CAAE,UAAW;AACZ,UAAK,MAAM,YAAY,UAAU,CAAE,MAAM,kBAAmB;AAC3D,cAAM,eAAe;AACrB,sBAAc;AAAA,MACf;AAAA,IACD;AAAA,IACA,CAAE,aAAc;AAAA,EACjB;AAEA;AAAA;AAAA,IAEC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,WAAY;AAAA,QAEZ;AAAA,+BAAC,SAAI,WAAU,+CACd;AAAA,gCAAC,YAAS,aAAI,WAAY,GAAG;AAAA,YAC7B;AAAA,cAAC;AAAA;AAAA,gBACA,MAAO;AAAA,gBACP,OAAQ,GAAI,OAAQ;AAAA,gBACpB,SAAU;AAAA,gBACV,MAAK;AAAA;AAAA,YACN;AAAA,aACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,KAAM,aAAc,CAAE,iBAAiB,kBAAmB,CAAE;AAAA,cAE5D,8BAAC,YAAS,iBAAoC;AAAA;AAAA,UAC/C;AAAA;AAAA;AAAA,IACD;AAAA;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,45 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
useEffect,
|
|
4
|
+
Platform,
|
|
5
|
+
useContext,
|
|
6
|
+
useCallback
|
|
7
|
+
} from "@wordpress/element";
|
|
8
|
+
import { isRTL, __ } from "@wordpress/i18n";
|
|
9
|
+
import {
|
|
10
|
+
ComplementaryArea,
|
|
11
|
+
store as interfaceStore
|
|
12
|
+
} from "@wordpress/interface";
|
|
13
|
+
import {
|
|
14
|
+
BlockInspector,
|
|
15
|
+
store as blockEditorStore
|
|
16
|
+
} from "@wordpress/block-editor";
|
|
17
|
+
import { drawerLeft, drawerRight } from "@wordpress/icons";
|
|
18
|
+
import { privateApis as componentsPrivateApis } from "@wordpress/components";
|
|
19
|
+
import { useSelect, useDispatch } from "@wordpress/data";
|
|
11
20
|
const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select({
|
|
12
21
|
web: true,
|
|
13
22
|
native: false
|
|
14
23
|
});
|
|
15
|
-
const BLOCK_INSPECTOR_IDENTIFIER =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import { unlock } from '../../lock-unlock';
|
|
27
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
-
const {
|
|
29
|
-
Tabs
|
|
30
|
-
} = unlock(componentsPrivateApis);
|
|
31
|
-
function SidebarHeader({
|
|
32
|
-
selectedWidgetAreaBlock
|
|
33
|
-
}) {
|
|
34
|
-
return /*#__PURE__*/_jsxs(Tabs.TabList, {
|
|
35
|
-
children: [/*#__PURE__*/_jsx(Tabs.Tab, {
|
|
36
|
-
tabId: WIDGET_AREAS_IDENTIFIER,
|
|
37
|
-
children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : __('Widget Areas')
|
|
38
|
-
}), /*#__PURE__*/_jsx(Tabs.Tab, {
|
|
39
|
-
tabId: BLOCK_INSPECTOR_IDENTIFIER,
|
|
40
|
-
children: __('Block')
|
|
41
|
-
})]
|
|
42
|
-
});
|
|
24
|
+
const BLOCK_INSPECTOR_IDENTIFIER = "edit-widgets/block-inspector";
|
|
25
|
+
const WIDGET_AREAS_IDENTIFIER = "edit-widgets/block-areas";
|
|
26
|
+
import WidgetAreas from "./widget-areas";
|
|
27
|
+
import { store as editWidgetsStore } from "../../store";
|
|
28
|
+
import { unlock } from "../../lock-unlock";
|
|
29
|
+
const { Tabs } = unlock(componentsPrivateApis);
|
|
30
|
+
function SidebarHeader({ selectedWidgetAreaBlock }) {
|
|
31
|
+
return /* @__PURE__ */ jsxs(Tabs.TabList, { children: [
|
|
32
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { tabId: WIDGET_AREAS_IDENTIFIER, children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : __("Widget Areas") }),
|
|
33
|
+
/* @__PURE__ */ jsx(Tabs.Tab, { tabId: BLOCK_INSPECTOR_IDENTIFIER, children: __("Block") })
|
|
34
|
+
] });
|
|
43
35
|
}
|
|
44
36
|
function SidebarContent({
|
|
45
37
|
hasSelectedNonAreaBlock,
|
|
@@ -47,75 +39,78 @@ function SidebarContent({
|
|
|
47
39
|
isGeneralSidebarOpen,
|
|
48
40
|
selectedWidgetAreaBlock
|
|
49
41
|
}) {
|
|
50
|
-
const {
|
|
51
|
-
enableComplementaryArea
|
|
52
|
-
} = useDispatch(interfaceStore);
|
|
42
|
+
const { enableComplementaryArea } = useDispatch(interfaceStore);
|
|
53
43
|
useEffect(() => {
|
|
54
44
|
if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) {
|
|
55
|
-
enableComplementaryArea(
|
|
45
|
+
enableComplementaryArea(
|
|
46
|
+
"core/edit-widgets",
|
|
47
|
+
BLOCK_INSPECTOR_IDENTIFIER
|
|
48
|
+
);
|
|
56
49
|
}
|
|
57
50
|
if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) {
|
|
58
|
-
enableComplementaryArea(
|
|
51
|
+
enableComplementaryArea(
|
|
52
|
+
"core/edit-widgets",
|
|
53
|
+
WIDGET_AREAS_IDENTIFIER
|
|
54
|
+
);
|
|
59
55
|
}
|
|
60
|
-
// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`
|
|
61
|
-
// out of the dep array because we want this effect to run based on
|
|
62
|
-
// block selection changes, not sidebar state changes.
|
|
63
56
|
}, [hasSelectedNonAreaBlock, enableComplementaryArea]);
|
|
64
57
|
const tabsContextValue = useContext(Tabs.Context);
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
value: tabsContextValue,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
59
|
+
ComplementaryArea,
|
|
60
|
+
{
|
|
61
|
+
className: "edit-widgets-sidebar",
|
|
62
|
+
header: /* @__PURE__ */ jsx(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ jsx(
|
|
63
|
+
SidebarHeader,
|
|
64
|
+
{
|
|
65
|
+
selectedWidgetAreaBlock
|
|
66
|
+
}
|
|
67
|
+
) }),
|
|
68
|
+
headerClassName: "edit-widgets-sidebar__panel-tabs",
|
|
69
|
+
title: __("Settings"),
|
|
70
|
+
closeLabel: __("Close Settings"),
|
|
71
|
+
scope: "core/edit-widgets",
|
|
72
|
+
identifier: currentArea,
|
|
73
|
+
icon: isRTL() ? drawerLeft : drawerRight,
|
|
74
|
+
isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
|
|
75
|
+
children: /* @__PURE__ */ jsxs(Tabs.Context.Provider, { value: tabsContextValue, children: [
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
Tabs.TabPanel,
|
|
78
|
+
{
|
|
79
|
+
tabId: WIDGET_AREAS_IDENTIFIER,
|
|
80
|
+
focusable: false,
|
|
81
|
+
children: /* @__PURE__ */ jsx(
|
|
82
|
+
WidgetAreas,
|
|
83
|
+
{
|
|
84
|
+
selectedWidgetAreaId: selectedWidgetAreaBlock?.attributes.id
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
Tabs.TabPanel,
|
|
91
|
+
{
|
|
92
|
+
tabId: BLOCK_INSPECTOR_IDENTIFIER,
|
|
93
|
+
focusable: false,
|
|
94
|
+
children: hasSelectedNonAreaBlock ? /* @__PURE__ */ jsx(BlockInspector, {}) : (
|
|
95
|
+
// Pretend that Widget Areas are part of the UI by not
|
|
96
|
+
// showing the Block Inspector when one is selected.
|
|
97
|
+
/* @__PURE__ */ jsx("span", { className: "block-editor-block-inspector__no-blocks", children: __("No block selected.") })
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
] })
|
|
102
|
+
}
|
|
103
|
+
);
|
|
103
104
|
}
|
|
104
|
-
|
|
105
|
+
function Sidebar() {
|
|
105
106
|
const {
|
|
106
107
|
currentArea,
|
|
107
108
|
hasSelectedNonAreaBlock,
|
|
108
109
|
isGeneralSidebarOpen,
|
|
109
110
|
selectedWidgetAreaBlock
|
|
110
|
-
} = useSelect(select => {
|
|
111
|
-
const {
|
|
112
|
-
|
|
113
|
-
getBlock,
|
|
114
|
-
getBlockParentsByBlockName
|
|
115
|
-
} = select(blockEditorStore);
|
|
116
|
-
const {
|
|
117
|
-
getActiveComplementaryArea
|
|
118
|
-
} = select(interfaceStore);
|
|
111
|
+
} = useSelect((select) => {
|
|
112
|
+
const { getSelectedBlock, getBlock, getBlockParentsByBlockName } = select(blockEditorStore);
|
|
113
|
+
const { getActiveComplementaryArea } = select(interfaceStore);
|
|
119
114
|
const selectedBlock = getSelectedBlock();
|
|
120
115
|
const activeArea = getActiveComplementaryArea(editWidgetsStore.name);
|
|
121
116
|
let currentSelection = activeArea;
|
|
@@ -128,48 +123,55 @@ export default function Sidebar() {
|
|
|
128
123
|
}
|
|
129
124
|
let widgetAreaBlock;
|
|
130
125
|
if (selectedBlock) {
|
|
131
|
-
if (selectedBlock.name ===
|
|
126
|
+
if (selectedBlock.name === "core/widget-area") {
|
|
132
127
|
widgetAreaBlock = selectedBlock;
|
|
133
128
|
} else {
|
|
134
|
-
widgetAreaBlock = getBlock(
|
|
129
|
+
widgetAreaBlock = getBlock(
|
|
130
|
+
getBlockParentsByBlockName(
|
|
131
|
+
selectedBlock.clientId,
|
|
132
|
+
"core/widget-area"
|
|
133
|
+
)[0]
|
|
134
|
+
);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
return {
|
|
138
138
|
currentArea: currentSelection,
|
|
139
|
-
hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !==
|
|
139
|
+
hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== "core/widget-area"),
|
|
140
140
|
isGeneralSidebarOpen: !!activeArea,
|
|
141
141
|
selectedWidgetAreaBlock: widgetAreaBlock
|
|
142
142
|
};
|
|
143
143
|
}, []);
|
|
144
|
-
const {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
const { enableComplementaryArea } = useDispatch(interfaceStore);
|
|
145
|
+
const onTabSelect = useCallback(
|
|
146
|
+
(newSelectedTabId) => {
|
|
147
|
+
if (!!newSelectedTabId) {
|
|
148
|
+
enableComplementaryArea(
|
|
149
|
+
editWidgetsStore.name,
|
|
150
|
+
newSelectedTabId
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
[enableComplementaryArea]
|
|
155
|
+
);
|
|
156
|
+
return /* @__PURE__ */ jsx(
|
|
157
|
+
Tabs,
|
|
158
|
+
{
|
|
159
|
+
selectedTabId: isGeneralSidebarOpen ? currentArea : null,
|
|
160
|
+
onSelect: onTabSelect,
|
|
161
|
+
selectOnMove: false,
|
|
162
|
+
children: /* @__PURE__ */ jsx(
|
|
163
|
+
SidebarContent,
|
|
164
|
+
{
|
|
165
|
+
hasSelectedNonAreaBlock,
|
|
166
|
+
currentArea,
|
|
167
|
+
isGeneralSidebarOpen,
|
|
168
|
+
selectedWidgetAreaBlock
|
|
169
|
+
}
|
|
170
|
+
)
|
|
155
171
|
}
|
|
156
|
-
|
|
157
|
-
return /*#__PURE__*/_jsx(Tabs
|
|
158
|
-
// Due to how this component is controlled (via a value from the
|
|
159
|
-
// `interfaceStore`), when the sidebar closes the currently selected
|
|
160
|
-
// tab can't be found. This causes the component to continuously reset
|
|
161
|
-
// the selection to `null` in an infinite loop. Proactively setting
|
|
162
|
-
// the selected tab to `null` avoids that.
|
|
163
|
-
, {
|
|
164
|
-
selectedTabId: isGeneralSidebarOpen ? currentArea : null,
|
|
165
|
-
onSelect: onTabSelect,
|
|
166
|
-
selectOnMove: false,
|
|
167
|
-
children: /*#__PURE__*/_jsx(SidebarContent, {
|
|
168
|
-
hasSelectedNonAreaBlock: hasSelectedNonAreaBlock,
|
|
169
|
-
currentArea: currentArea,
|
|
170
|
-
isGeneralSidebarOpen: isGeneralSidebarOpen,
|
|
171
|
-
selectedWidgetAreaBlock: selectedWidgetAreaBlock
|
|
172
|
-
})
|
|
173
|
-
});
|
|
172
|
+
);
|
|
174
173
|
}
|
|
175
|
-
|
|
174
|
+
export {
|
|
175
|
+
Sidebar as default
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","Platform","useContext","useCallback","isRTL","__","ComplementaryArea","store","interfaceStore","BlockInspector","blockEditorStore","drawerLeft","drawerRight","privateApis","componentsPrivateApis","useSelect","useDispatch","SIDEBAR_ACTIVE_BY_DEFAULT","select","web","native","BLOCK_INSPECTOR_IDENTIFIER","WIDGET_AREAS_IDENTIFIER","WidgetAreas","editWidgetsStore","unlock","jsx","_jsx","jsxs","_jsxs","Tabs","SidebarHeader","selectedWidgetAreaBlock","TabList","children","Tab","tabId","attributes","name","SidebarContent","hasSelectedNonAreaBlock","currentArea","isGeneralSidebarOpen","enableComplementaryArea","tabsContextValue","Context","className","header","Provider","value","headerClassName","title","closeLabel","scope","identifier","icon","isActiveByDefault","TabPanel","focusable","selectedWidgetAreaId","id","Sidebar","getSelectedBlock","getBlock","getBlockParentsByBlockName","getActiveComplementaryArea","selectedBlock","activeArea","currentSelection","widgetAreaBlock","clientId","onTabSelect","newSelectedTabId","selectedTabId","onSelect","selectOnMove"],"sources":["@wordpress/edit-widgets/src/components/sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseEffect,\n\tPlatform,\n\tuseContext,\n\tuseCallback,\n} from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\n\nconst BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';\n\n// Widget areas were once called block areas, so use 'edit-widgets/block-areas'\n// for backwards compatibility.\nconst WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreas from './widget-areas';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nfunction SidebarHeader( { selectedWidgetAreaBlock } ) {\n\treturn (\n\t\t<Tabs.TabList>\n\t\t\t<Tabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>\n\t\t\t\t{ selectedWidgetAreaBlock\n\t\t\t\t\t? selectedWidgetAreaBlock.attributes.name\n\t\t\t\t\t: __( 'Widget Areas' ) }\n\t\t\t</Tabs.Tab>\n\t\t\t<Tabs.Tab tabId={ BLOCK_INSPECTOR_IDENTIFIER }>\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</Tabs.Tab>\n\t\t</Tabs.TabList>\n\t);\n}\n\nfunction SidebarContent( {\n\thasSelectedNonAreaBlock,\n\tcurrentArea,\n\tisGeneralSidebarOpen,\n\tselectedWidgetAreaBlock,\n} ) {\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\thasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === WIDGET_AREAS_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tBLOCK_INSPECTOR_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t! hasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === BLOCK_INSPECTOR_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tWIDGET_AREAS_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\t// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`\n\t\t// out of the dep array because we want this effect to run based on\n\t\t// block selection changes, not sidebar state changes.\n\t}, [ hasSelectedNonAreaBlock, enableComplementaryArea ] );\n\n\tconst tabsContextValue = useContext( Tabs.Context );\n\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tclassName=\"edit-widgets-sidebar\"\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader\n\t\t\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t\t\t/>\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\theaderClassName=\"edit-widgets-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\tscope=\"core/edit-widgets\"\n\t\t\tidentifier={ currentArea }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\ttabId={ WIDGET_AREAS_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<WidgetAreas\n\t\t\t\t\t\tselectedWidgetAreaId={\n\t\t\t\t\t\t\tselectedWidgetAreaBlock?.attributes.id\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\ttabId={ BLOCK_INSPECTOR_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t{ hasSelectedNonAreaBlock ? (\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// Pretend that Widget Areas are part of the UI by not\n\t\t\t\t\t\t// showing the Block Inspector when one is selected.\n\t\t\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\nexport default function Sidebar() {\n\tconst {\n\t\tcurrentArea,\n\t\thasSelectedNonAreaBlock,\n\t\tisGeneralSidebarOpen,\n\t\tselectedWidgetAreaBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock, getBlock, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\tconst selectedBlock = getSelectedBlock();\n\n\t\tconst activeArea = getActiveComplementaryArea( editWidgetsStore.name );\n\n\t\tlet currentSelection = activeArea;\n\t\tif ( ! currentSelection ) {\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tcurrentSelection = BLOCK_INSPECTOR_IDENTIFIER;\n\t\t\t} else {\n\t\t\t\tcurrentSelection = WIDGET_AREAS_IDENTIFIER;\n\t\t\t}\n\t\t}\n\n\t\tlet widgetAreaBlock;\n\t\tif ( selectedBlock ) {\n\t\t\tif ( selectedBlock.name === 'core/widget-area' ) {\n\t\t\t\twidgetAreaBlock = selectedBlock;\n\t\t\t} else {\n\t\t\t\twidgetAreaBlock = getBlock(\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\t\t'core/widget-area'\n\t\t\t\t\t)[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcurrentArea: currentSelection,\n\t\t\thasSelectedNonAreaBlock: !! (\n\t\t\t\tselectedBlock && selectedBlock.name !== 'core/widget-area'\n\t\t\t),\n\t\t\tisGeneralSidebarOpen: !! activeArea,\n\t\t\tselectedWidgetAreaBlock: widgetAreaBlock,\n\t\t};\n\t}, [] );\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\t// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.\n\t// the initial render) or when we don't want a tab displayed (i.e. the\n\t// sidebar is closed). These cases should both be covered by the `!!` check\n\t// below, so we shouldn't need any additional falsy handling.\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea(\n\t\t\t\t\teditWidgetsStore.name,\n\t\t\t\t\tnewSelectedTabId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop. Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isGeneralSidebarOpen ? currentArea : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\thasSelectedNonAreaBlock={ hasSelectedNonAreaBlock }\n\t\t\t\tcurrentArea={ currentArea }\n\t\t\t\tisGeneralSidebarOpen={ isGeneralSidebarOpen }\n\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,QAAQ,EACRC,UAAU,EACVC,WAAW,QACL,oBAAoB;AAC3B,SAASC,KAAK,EAAEC,EAAE,QAAQ,iBAAiB;AAC3C,SACCC,iBAAiB,EACjBC,KAAK,IAAIC,cAAc,QACjB,sBAAsB;AAC7B,SACCC,cAAc,EACdF,KAAK,IAAIG,gBAAgB,QACnB,yBAAyB;AAEhC,SAASC,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SAASC,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;AAC5E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AAExD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C1D;MACDI,oBAAoB,EAAE,CAAC,CAAEyB,UAAU;MACnCnC,uBAAuB,EAAEqC;IAC1B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM;IAAE1B;EAAwB,CAAC,GAAG3B,WAAW,CAAER,cAAe,CAAC;;EAEjE;EACA;EACA;EACA;EACA,MAAM+D,WAAW,GAAGpE,WAAW,CAC5BqE,gBAAgB,IAAM;IACvB,IAAK,CAAC,CAAEA,gBAAgB,EAAG;MAC1B7B,uBAAuB,CACtBnB,gBAAgB,CAACc,IAAI,EACrBkC,gBACD,CAAC;IACF;EACD,CAAC,EACD,CAAE7B,uBAAuB,CAC1B,CAAC;EAED,oBACChB,IAAA,CAACG;EACA;EACA;EACA;EACA;EACA;EAAA;IACA2C,aAAa,EAAG/B,oBAAoB,GAAGD,WAAW,GAAG,IAAM;IAC3DiC,QAAQ,EAAGH,WAAa;IACxBI,YAAY,EAAG,KAAO;IAAAzC,QAAA,eAEtBP,IAAA,CAACY,cAAc;MACdC,uBAAuB,EAAGA,uBAAyB;MACnDC,WAAW,EAAGA,WAAa;MAC3BC,oBAAoB,EAAGA,oBAAsB;MAC7CV,uBAAuB,EAAGA;IAAyB,CACnD;EAAC,CACG,CAAC;AAET","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/sidebar/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseEffect,\n\tPlatform,\n\tuseContext,\n\tuseCallback,\n} from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\n\nconst BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';\n\n// Widget areas were once called block areas, so use 'edit-widgets/block-areas'\n// for backwards compatibility.\nconst WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreas from './widget-areas';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nfunction SidebarHeader( { selectedWidgetAreaBlock } ) {\n\treturn (\n\t\t<Tabs.TabList>\n\t\t\t<Tabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>\n\t\t\t\t{ selectedWidgetAreaBlock\n\t\t\t\t\t? selectedWidgetAreaBlock.attributes.name\n\t\t\t\t\t: __( 'Widget Areas' ) }\n\t\t\t</Tabs.Tab>\n\t\t\t<Tabs.Tab tabId={ BLOCK_INSPECTOR_IDENTIFIER }>\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</Tabs.Tab>\n\t\t</Tabs.TabList>\n\t);\n}\n\nfunction SidebarContent( {\n\thasSelectedNonAreaBlock,\n\tcurrentArea,\n\tisGeneralSidebarOpen,\n\tselectedWidgetAreaBlock,\n} ) {\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\thasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === WIDGET_AREAS_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tBLOCK_INSPECTOR_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t! hasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === BLOCK_INSPECTOR_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tWIDGET_AREAS_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\t// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`\n\t\t// out of the dep array because we want this effect to run based on\n\t\t// block selection changes, not sidebar state changes.\n\t}, [ hasSelectedNonAreaBlock, enableComplementaryArea ] );\n\n\tconst tabsContextValue = useContext( Tabs.Context );\n\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tclassName=\"edit-widgets-sidebar\"\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader\n\t\t\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t\t\t/>\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\theaderClassName=\"edit-widgets-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\tscope=\"core/edit-widgets\"\n\t\t\tidentifier={ currentArea }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\ttabId={ WIDGET_AREAS_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<WidgetAreas\n\t\t\t\t\t\tselectedWidgetAreaId={\n\t\t\t\t\t\t\tselectedWidgetAreaBlock?.attributes.id\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\ttabId={ BLOCK_INSPECTOR_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t{ hasSelectedNonAreaBlock ? (\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// Pretend that Widget Areas are part of the UI by not\n\t\t\t\t\t\t// showing the Block Inspector when one is selected.\n\t\t\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\nexport default function Sidebar() {\n\tconst {\n\t\tcurrentArea,\n\t\thasSelectedNonAreaBlock,\n\t\tisGeneralSidebarOpen,\n\t\tselectedWidgetAreaBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock, getBlock, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\tconst selectedBlock = getSelectedBlock();\n\n\t\tconst activeArea = getActiveComplementaryArea( editWidgetsStore.name );\n\n\t\tlet currentSelection = activeArea;\n\t\tif ( ! currentSelection ) {\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tcurrentSelection = BLOCK_INSPECTOR_IDENTIFIER;\n\t\t\t} else {\n\t\t\t\tcurrentSelection = WIDGET_AREAS_IDENTIFIER;\n\t\t\t}\n\t\t}\n\n\t\tlet widgetAreaBlock;\n\t\tif ( selectedBlock ) {\n\t\t\tif ( selectedBlock.name === 'core/widget-area' ) {\n\t\t\t\twidgetAreaBlock = selectedBlock;\n\t\t\t} else {\n\t\t\t\twidgetAreaBlock = getBlock(\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\t\t'core/widget-area'\n\t\t\t\t\t)[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcurrentArea: currentSelection,\n\t\t\thasSelectedNonAreaBlock: !! (\n\t\t\t\tselectedBlock && selectedBlock.name !== 'core/widget-area'\n\t\t\t),\n\t\t\tisGeneralSidebarOpen: !! activeArea,\n\t\t\tselectedWidgetAreaBlock: widgetAreaBlock,\n\t\t};\n\t}, [] );\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\t// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.\n\t// the initial render) or when we don't want a tab displayed (i.e. the\n\t// sidebar is closed). These cases should both be covered by the `!!` check\n\t// below, so we shouldn't need any additional falsy handling.\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea(\n\t\t\t\t\teditWidgetsStore.name,\n\t\t\t\t\tnewSelectedTabId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop. Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isGeneralSidebarOpen ? currentArea : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\thasSelectedNonAreaBlock={ hasSelectedNonAreaBlock }\n\t\t\t\tcurrentArea={ currentArea }\n\t\t\t\tisGeneralSidebarOpen={ isGeneralSidebarOpen }\n\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AA6CE,SACC,KADD;AA1CF;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,UAAU;AAC1B;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA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