@wordpress/edit-widgets 5.19.0 → 5.19.1
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/header/index.js +5 -2
- package/build/components/header/index.js.map +1 -1
- package/build/components/layout/interface.js +7 -2
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/secondary-sidebar/index.js +6 -2
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +15 -10
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/header/index.js +5 -2
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/layout/interface.js +8 -3
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js +6 -2
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +17 -12
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/package.json +28 -28
- package/src/components/header/index.js +2 -1
- package/src/components/layout/interface.js +14 -3
- package/src/components/secondary-sidebar/index.js +4 -2
- package/src/components/secondary-sidebar/list-view-sidebar.js +21 -25
|
@@ -31,7 +31,9 @@ var _lockUnlock = require("../../lock-unlock");
|
|
|
31
31
|
const {
|
|
32
32
|
useShouldContextualToolbarShow
|
|
33
33
|
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
34
|
-
function Header(
|
|
34
|
+
function Header({
|
|
35
|
+
setListViewToggleElement
|
|
36
|
+
}) {
|
|
35
37
|
const isMediumViewport = (0, _compose.useViewportMatch)('medium');
|
|
36
38
|
const inserterButton = (0, _element.useRef)();
|
|
37
39
|
const widgetAreaClientId = (0, _useLastSelectedWidgetArea.default)();
|
|
@@ -119,7 +121,8 @@ function Header() {
|
|
|
119
121
|
isPressed: isListViewOpen
|
|
120
122
|
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
121
123
|
label: (0, _i18n.__)('List View'),
|
|
122
|
-
onClick: toggleListView
|
|
124
|
+
onClick: toggleListView,
|
|
125
|
+
ref: setListViewToggleElement
|
|
123
126
|
})))), (0, _element.createElement)("div", {
|
|
124
127
|
className: "edit-widgets-header__actions"
|
|
125
128
|
}, (0, _element.createElement)(_saveButton.default, null), (0, _element.createElement)(_interface.PinnedItems.Slot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_i18n","_components","_blockEditor","_interface","_icons","_compose","_saveButton","_interopRequireDefault","_undo","_redo","_moreMenu","_useLastSelectedWidgetArea","_store","_lockUnlock","useShouldContextualToolbarShow","unlock","blockEditorPrivateApis","Header","isMediumViewport","useViewportMatch","inserterButton","useRef","widgetAreaClientId","useLastSelectedWidgetArea","isLastSelectedWidgetAreaOpen","useSelect","select","editWidgetsStore","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","isInserterOpened","isListViewOpened","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","useDispatch","selectBlock","blockEditorStore","handleClick","window","requestAnimationFrame","toggleListView","useCallback","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","createElement","Fragment","className","__","VisuallyHidden","as","NavigableToolbar","shouldUseKeyboardFocusShortcut","ToolbarItem","ref","Button","variant","isPressed","onMouseDown","event","preventDefault","onClick","icon","plus","label","_x","default","listView","PinnedItems","Slot","scope","_default","exports"],"sources":["@wordpress/edit-widgets/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem, VisuallyHidden } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { PinnedItems } from '@wordpress/interface';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport MoreMenu from '../more-menu';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nfunction Header() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\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\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMediumViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigableToolbar\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t\t\tshouldUseKeyboardFocusShortcut={\n\t\t\t\t\t\t\t! blockToolbarCanBeFocused\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ handleClick }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</NavigableToolbar>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<MoreMenu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BV,SAAS,EAAG9B;IACZ;IACAqC,KAAK,EAAG,IAAAhB,QAAE,EAAE,WAAY,CAAG;IAC3Ba,OAAO,EAAGtB;EAAgB,CAC1B,CACA,CAEc,CACd,CAAC,EACN,IAAA7C,QAAA,CAAAmD,aAAA;IAAKE,SAAS,EAAC;EAA8B,GAC5C,IAAArD,QAAA,CAAAmD,aAAA,EAAC1C,WAAA,CAAA+D,OAAU,MAAE,CAAC,EACd,IAAAxE,QAAA,CAAAmD,aAAA,EAAC7C,UAAA,CAAAoE,WAAW,CAACC,IAAI;IAACC,KAAK,EAAC;EAAmB,CAAE,CAAC,EAC9C,IAAA5E,QAAA,CAAAmD,aAAA,EAACtC,SAAA,CAAA2D,OAAQ,MAAE,CACP,CACD,CACJ,CAAC;AAEL;AAAC,IAAAK,QAAA,GAEczD,MAAM;AAAA0D,OAAA,CAAAN,OAAA,GAAAK,QAAA"}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_i18n","_components","_blockEditor","_interface","_icons","_compose","_saveButton","_interopRequireDefault","_undo","_redo","_moreMenu","_useLastSelectedWidgetArea","_store","_lockUnlock","useShouldContextualToolbarShow","unlock","blockEditorPrivateApis","Header","setListViewToggleElement","isMediumViewport","useViewportMatch","inserterButton","useRef","widgetAreaClientId","useLastSelectedWidgetArea","isLastSelectedWidgetAreaOpen","useSelect","select","editWidgetsStore","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","isInserterOpened","isListViewOpened","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","useDispatch","selectBlock","blockEditorStore","handleClick","window","requestAnimationFrame","toggleListView","useCallback","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","createElement","Fragment","className","__","VisuallyHidden","as","NavigableToolbar","shouldUseKeyboardFocusShortcut","ToolbarItem","ref","Button","variant","isPressed","onMouseDown","event","preventDefault","onClick","icon","plus","label","_x","default","listView","PinnedItems","Slot","scope","_default","exports"],"sources":["@wordpress/edit-widgets/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem, VisuallyHidden } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { PinnedItems } from '@wordpress/interface';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport MoreMenu from '../more-menu';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nfunction Header( { setListViewToggleElement } ) {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\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\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMediumViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigableToolbar\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t\t\tshouldUseKeyboardFocusShortcut={\n\t\t\t\t\t\t\t! blockToolbarCanBeFocused\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ handleClick }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\t\tref={ setListViewToggleElement }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</NavigableToolbar>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],"mappings":";;;;;;;AAaA,IAAAA,QAAA,GAAAC,OAAA;AAVA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,WAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,KAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,KAAA,GAAAF,sBAAA,CAAAT,OAAA;AACA,IAAAY,SAAA,GAAAH,sBAAA,CAAAT,OAAA;AACA,IAAAa,0BAAA,GAAAJ,sBAAA,CAAAT,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,WAAA,GAAAf,OAAA;AAzBA;AACA;AACA;;AAcA;AACA;AACA;;AASA,MAAM;EAAEgB;AAA+B,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAE3E,SAASC,MAAMA,CAAE;EAAEC;AAAyB,CAAC,EAAG;EAC/C,MAAMC,gBAAgB,GAAG,IAAAC,yBAAgB,EA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ACT,uBAAuB,EACvB,yCACD;EAAG,CACH,CAAC,EACAlD,gBAAgB,IACjB,IAAAtB,QAAA,CAAAoD,aAAA,EAAApD,QAAA,CAAAqD,QAAA,QACC,IAAArD,QAAA,CAAAoD,aAAA,EAACzC,KAAA,CAAA8D,OAAU,MAAE,CAAC,EACd,IAAAzE,QAAA,CAAAoD,aAAA,EAACxC,KAAA,CAAA6D,OAAU,MAAE,CAAC,EACd,IAAAzE,QAAA,CAAAoD,aAAA,EAAChD,WAAA,CAAAwD,WAAW;IACXH,EAAE,EAAGK,kBAAQ;IACbR,SAAS,EAAC,+CAA+C;IACzDe,IAAI,EAAGK,eAAU;IACjBV,SAAS,EAAG9B;IACZ;IACAqC,KAAK,EAAG,IAAAhB,QAAE,EAAE,WAAY,CAAG;IAC3Ba,OAAO,EAAGtB,cAAgB;IAC1Be,GAAG,EAAGxC;EAA0B,CAChC,CACA,CAEc,CACd,CAAC,EACN,IAAArB,QAAA,CAAAoD,aAAA;IAAKE,SAAS,EAAC;EAA8B,GAC5C,IAAAtD,QAAA,CAAAoD,aAAA,EAAC3C,WAAA,CAAAgE,OAAU,MAAE,CAAC,EACd,IAAAzE,QAAA,CAAAoD,aAAA,EAAC9C,UAAA,CAAAqE,WAAW,CAACC,IAAI;IAACC,KAAK,EAAC;EAAmB,CAAE,CAAC,EAC9C,IAAA7E,QAAA,CAAAoD,aAAA,EAACvC,SAAA,CAAA4D,OAAQ,MAAE,CACP,CACD,CACJ,CAAC;AAEL;AAAC,IAAAK,QAAA,GAEc1D,MAAM;AAAA2D,OAAA,CAAAN,OAAA,GAAAK,QAAA"}
|
|
@@ -60,6 +60,7 @@ function Interface({
|
|
|
60
60
|
previousShortcut: select(_keyboardShortcuts.store).getAllShortcutKeyCombinations('core/edit-widgets/previous-region'),
|
|
61
61
|
nextShortcut: select(_keyboardShortcuts.store).getAllShortcutKeyCombinations('core/edit-widgets/next-region')
|
|
62
62
|
}), []);
|
|
63
|
+
const [listViewToggleElement, setListViewToggleElement] = (0, _element.useState)(null);
|
|
63
64
|
|
|
64
65
|
// Inserter and Sidebars are mutually exclusive
|
|
65
66
|
(0, _element.useEffect)(() => {
|
|
@@ -80,8 +81,12 @@ function Interface({
|
|
|
80
81
|
...interfaceLabels,
|
|
81
82
|
secondarySidebar: secondarySidebarLabel
|
|
82
83
|
},
|
|
83
|
-
header: (0, _element.createElement)(_header.default,
|
|
84
|
-
|
|
84
|
+
header: (0, _element.createElement)(_header.default, {
|
|
85
|
+
setListViewToggleElement: setListViewToggleElement
|
|
86
|
+
}),
|
|
87
|
+
secondarySidebar: hasSecondarySidebar && (0, _element.createElement)(_secondarySidebar.default, {
|
|
88
|
+
listViewToggleElement: listViewToggleElement
|
|
89
|
+
}),
|
|
85
90
|
sidebar: hasSidebarEnabled && (0, _element.createElement)(_interface.ComplementaryArea.Slot, {
|
|
86
91
|
scope: "core/edit-widgets"
|
|
87
92
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_blockEditor","_data","_interface","_i18n","_keyboardShortcuts","_preferences","_header","_interopRequireDefault","_widgetAreasBlockEditorContent","_store","_secondarySidebar","interfaceLabels","header","__","body","sidebar","footer","Interface","blockEditorSettings","isMobileViewport","useViewportMatch","isHugeViewport","setIsInserterOpened","setIsListViewOpened","closeGeneralSidebar","useDispatch","editWidgetsStore","hasBlockBreadCrumbsEnabled","hasSidebarEnabled","isInserterOpened","isListViewOpened","previousShortcut","nextShortcut","useSelect","select","interfaceStore","getActiveComplementaryArea","name","preferencesStore","get","keyboardShortcutsStore","getAllShortcutKeyCombinations","useEffect","secondarySidebarLabel","hasSecondarySidebar","createElement","InterfaceSkeleton","labels","secondarySidebar","default","ComplementaryArea","Slot","scope","content","Fragment","className","BlockBreadcrumb","rootLabelText","shortcuts","previous","next","_default","exports"],"sources":["@wordpress/edit-widgets/src/components/layout/interface.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t\tpreviousShortcut,\n\t\tnextShortcut,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations(\n\t\t\t\t'core/edit-widgets/previous-region'\n\t\t\t),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-widgets/next-region' ),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_blockEditor","_data","_interface","_i18n","_keyboardShortcuts","_preferences","_header","_interopRequireDefault","_widgetAreasBlockEditorContent","_store","_secondarySidebar","interfaceLabels","header","__","body","sidebar","footer","Interface","blockEditorSettings","isMobileViewport","useViewportMatch","isHugeViewport","setIsInserterOpened","setIsListViewOpened","closeGeneralSidebar","useDispatch","editWidgetsStore","hasBlockBreadCrumbsEnabled","hasSidebarEnabled","isInserterOpened","isListViewOpened","previousShortcut","nextShortcut","useSelect","select","interfaceStore","getActiveComplementaryArea","name","preferencesStore","get","keyboardShortcutsStore","getAllShortcutKeyCombinations","listViewToggleElement","setListViewToggleElement","useState","useEffect","secondarySidebarLabel","hasSecondarySidebar","createElement","InterfaceSkeleton","labels","secondarySidebar","default","ComplementaryArea","Slot","scope","content","Fragment","className","BlockBreadcrumb","rootLabelText","shortcuts","previous","next","_default","exports"],"sources":["@wordpress/edit-widgets/src/components/layout/interface.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t\tpreviousShortcut,\n\t\tnextShortcut,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations(\n\t\t\t\t'core/edit-widgets/previous-region'\n\t\t\t),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-widgets/next-region' ),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ listViewToggleElement, setListViewToggleElement ] =\n\t\tuseState( null );\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={\n\t\t\t\t<Header setListViewToggleElement={ setListViewToggleElement } />\n\t\t\t}\n\t\t\tsecondarySidebar={\n\t\t\t\thasSecondarySidebar && (\n\t\t\t\t\t<SecondarySidebar\n\t\t\t\t\t\tlistViewToggleElement={ listViewToggleElement }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tsidebar={\n\t\t\t\thasSidebarEnabled && (\n\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t)\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<WidgetAreasBlockEditorContent\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\thasBlockBreadCrumbsEnabled &&\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<div className=\"edit-widgets-layout__footer\">\n\t\t\t\t\t\t<BlockBreadcrumb rootLabelText={ __( 'Widgets' ) } />\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nexport default Interface;\n"],"mappings":";;;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AAFA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAKA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAKA,IAAAQ,OAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,8BAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,iBAAA,GAAAH,sBAAA,CAAAT,OAAA;AAtBA;AACA;AACA;;AAcA;AACA;AACA;;AAM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mD,iBAAiB,CAACC,IAAI;MAACC,KAAK,EAAC;IAAmB,CAAE,CAEpD;IACDC,OAAO,EACN,IAAA3D,QAAA,CAAAmD,aAAA,EAAAnD,QAAA,CAAA4D,QAAA,QACC,IAAA5D,QAAA,CAAAmD,aAAA,EAACxC,8BAAA,CAAA4C,OAA6B;MAC7BlC,mBAAmB,EAAGA;IAAqB,CAC3C,CACA,CACF;IACDF,MAAM,EACLW,0BAA0B,IAC1B,CAAER,gBAAgB,IACjB,IAAAtB,QAAA,CAAAmD,aAAA;MAAKU,SAAS,EAAC;IAA6B,GAC3C,IAAA7D,QAAA,CAAAmD,aAAA,EAAChD,YAAA,CAAA2D,eAAe;MAACC,aAAa,EAAG,IAAA/C,QAAE,EAAE,SAAU;IAAG,CAAE,CAChD,CAEN;IACDgD,SAAS,EAAG;MACXC,QAAQ,EAAE/B,gBAAgB;MAC1BgC,IAAI,EAAE/B;IACP;EAAG,CACH,CAAC;AAEJ;AAAC,IAAAgC,QAAA,GAEc/C,SAAS;AAAAgD,OAAA,CAAAb,OAAA,GAAAY,QAAA"}
|
|
@@ -22,7 +22,9 @@ var _listViewSidebar = _interopRequireDefault(require("./list-view-sidebar"));
|
|
|
22
22
|
* Internal dependencies
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
function SecondarySidebar(
|
|
25
|
+
function SecondarySidebar({
|
|
26
|
+
listViewToggleElement
|
|
27
|
+
}) {
|
|
26
28
|
const {
|
|
27
29
|
isInserterOpen,
|
|
28
30
|
isListViewOpen
|
|
@@ -40,7 +42,9 @@ function SecondarySidebar() {
|
|
|
40
42
|
return (0, _element.createElement)(_inserterSidebar.default, null);
|
|
41
43
|
}
|
|
42
44
|
if (isListViewOpen) {
|
|
43
|
-
return (0, _element.createElement)(_listViewSidebar.default,
|
|
45
|
+
return (0, _element.createElement)(_listViewSidebar.default, {
|
|
46
|
+
listViewToggleElement: listViewToggleElement
|
|
47
|
+
});
|
|
44
48
|
}
|
|
45
49
|
return null;
|
|
46
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_store","_inserterSidebar","_interopRequireDefault","_listViewSidebar","SecondarySidebar","isInserterOpen","isListViewOpen","useSelect","select","isInserterOpened","isListViewOpened","editWidgetsStore","_element","createElement","default"],"sources":["@wordpress/edit-widgets/src/components/secondary-sidebar/index.js"],"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
|
|
1
|
+
{"version":3,"names":["_data","require","_store","_inserterSidebar","_interopRequireDefault","_listViewSidebar","SecondarySidebar","listViewToggleElement","isInserterOpen","isListViewOpen","useSelect","select","isInserterOpened","isListViewOpened","editWidgetsStore","_element","createElement","default"],"sources":["@wordpress/edit-widgets/src/components/secondary-sidebar/index.js"],"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( { listViewToggleElement } ) {\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 (\n\t\t\t<ListViewSidebar listViewToggleElement={ listViewToggleElement } />\n\t\t);\n\t}\n\treturn null;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAD,sBAAA,CAAAH,OAAA;AAbA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAIe,SAASK,gBAAgBA,CAAE;EAAEC;AAAsB,CAAC,EAAG;EACrE,MAAM;IAAEC,cAAc;IAAEC;EAAe,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACnE,MAAM;MAAEC,gBAAgB;MAAEC;IAAiB,CAAC,GAC3CF,MAAM,CAAEG,YAAiB,CAAC;IAC3B,OAAO;MACNN,cAAc,EAAEI,gBAAgB,CAAC,CAAC;MAClCH,cAAc,EAAEI,gBAAgB,CAAC;IAClC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAKL,cAAc,EAAG;IACrB,OAAO,IAAAO,QAAA,CAAAC,aAAA,EAACb,gBAAA,CAAAc,OAAe,MAAE,CAAC;EAC3B;EACA,IAAKR,cAAc,EAAG;IACrB,OACC,IAAAM,QAAA,CAAAC,aAAA,EAACX,gBAAA,CAAAY,OAAe;MAACV,qBAAqB,EAAGA;IAAuB,CAAE,CAAC;EAErE;EACA,OAAO,IAAI;AACZ"}
|
|
@@ -21,7 +21,9 @@ var _store = require("../../store");
|
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
function ListViewSidebar(
|
|
24
|
+
function ListViewSidebar({
|
|
25
|
+
listViewToggleElement
|
|
26
|
+
}) {
|
|
25
27
|
const {
|
|
26
28
|
setIsListViewOpened
|
|
27
29
|
} = (0, _data.useDispatch)(_store.store);
|
|
@@ -30,29 +32,32 @@ function ListViewSidebar() {
|
|
|
30
32
|
// re-renders when the dropZoneElement updates.
|
|
31
33
|
const [dropZoneElement, setDropZoneElement] = (0, _element.useState)(null);
|
|
32
34
|
const focusOnMountRef = (0, _compose.useFocusOnMount)('firstElement');
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
// When closing the list view, focus should return to the toggle button.
|
|
37
|
+
const closeListView = (0, _element.useCallback)(() => {
|
|
38
|
+
setIsListViewOpened(false);
|
|
39
|
+
listViewToggleElement?.focus();
|
|
40
|
+
}, [listViewToggleElement, setIsListViewOpened]);
|
|
41
|
+
const closeOnEscape = (0, _element.useCallback)(event => {
|
|
36
42
|
if (event.keyCode === _keycodes.ESCAPE && !event.defaultPrevented) {
|
|
37
43
|
event.preventDefault();
|
|
38
|
-
|
|
44
|
+
closeListView();
|
|
39
45
|
}
|
|
40
|
-
}
|
|
46
|
+
}, [closeListView]);
|
|
41
47
|
return (
|
|
42
48
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
43
49
|
(0, _element.createElement)("div", {
|
|
44
50
|
className: "edit-widgets-editor__list-view-panel",
|
|
45
51
|
onKeyDown: closeOnEscape
|
|
46
52
|
}, (0, _element.createElement)("div", {
|
|
47
|
-
className: "edit-widgets-editor__list-view-panel-header"
|
|
48
|
-
ref: headerFocusReturnRef
|
|
53
|
+
className: "edit-widgets-editor__list-view-panel-header"
|
|
49
54
|
}, (0, _element.createElement)("strong", null, (0, _i18n.__)('List View')), (0, _element.createElement)(_components.Button, {
|
|
50
55
|
icon: _icons.closeSmall,
|
|
51
56
|
label: (0, _i18n.__)('Close'),
|
|
52
|
-
onClick:
|
|
57
|
+
onClick: closeListView
|
|
53
58
|
})), (0, _element.createElement)("div", {
|
|
54
59
|
className: "edit-widgets-editor__list-view-panel-content",
|
|
55
|
-
ref: (0, _compose.useMergeRefs)([
|
|
60
|
+
ref: (0, _compose.useMergeRefs)([focusOnMountRef, setDropZoneElement])
|
|
56
61
|
}, (0, _element.createElement)(_blockEditor.__experimentalListView, {
|
|
57
62
|
dropZoneElement: dropZoneElement
|
|
58
63
|
})))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_blockEditor","_components","_compose","_data","_i18n","_icons","_keycodes","_store","ListViewSidebar","setIsListViewOpened","useDispatch","editWidgetsStore","dropZoneElement","setDropZoneElement","useState","focusOnMountRef","useFocusOnMount","
|
|
1
|
+
{"version":3,"names":["_element","require","_blockEditor","_components","_compose","_data","_i18n","_icons","_keycodes","_store","ListViewSidebar","listViewToggleElement","setIsListViewOpened","useDispatch","editWidgetsStore","dropZoneElement","setDropZoneElement","useState","focusOnMountRef","useFocusOnMount","closeListView","useCallback","focus","closeOnEscape","event","keyCode","ESCAPE","defaultPrevented","preventDefault","createElement","className","onKeyDown","__","Button","icon","closeSmall","label","onClick","ref","useMergeRefs","__experimentalListView"],"sources":["@wordpress/edit-widgets/src/components/secondary-sidebar/list-view-sidebar.js"],"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 } 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';\n\nexport default function ListViewSidebar( { listViewToggleElement } ) {\n\tconst { setIsListViewOpened } = useDispatch( 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\tlistViewToggleElement?.focus();\n\t}, [ listViewToggleElement, 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/>\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"],"mappings":";;;;;;AAOA,IAAAA,QAAA,GAAAC,OAAA;AAJA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGe,SAASS,eAAeA,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BAAY,EAAE,CAAErB,eAAe,EAAEF,kBAAkB,CAAG;IAAG,GAE/D,IAAAhB,QAAA,CAAA6B,aAAA,EAAC3B,YAAA,CAAAsC,sBAAQ;MAACzB,eAAe,EAAGA;IAAiB,CAAE,CAC3C,CACD;EAAC;AAER"}
|
|
@@ -24,7 +24,9 @@ import { unlock } from '../../lock-unlock';
|
|
|
24
24
|
const {
|
|
25
25
|
useShouldContextualToolbarShow
|
|
26
26
|
} = unlock(blockEditorPrivateApis);
|
|
27
|
-
function Header(
|
|
27
|
+
function Header({
|
|
28
|
+
setListViewToggleElement
|
|
29
|
+
}) {
|
|
28
30
|
const isMediumViewport = useViewportMatch('medium');
|
|
29
31
|
const inserterButton = useRef();
|
|
30
32
|
const widgetAreaClientId = useLastSelectedWidgetArea();
|
|
@@ -112,7 +114,8 @@ function Header() {
|
|
|
112
114
|
isPressed: isListViewOpen
|
|
113
115
|
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
114
116
|
label: __('List View'),
|
|
115
|
-
onClick: toggleListView
|
|
117
|
+
onClick: toggleListView,
|
|
118
|
+
ref: setListViewToggleElement
|
|
116
119
|
})))), createElement("div", {
|
|
117
120
|
className: "edit-widgets-header__actions"
|
|
118
121
|
}, createElement(SaveButton, null), createElement(PinnedItems.Slot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","VisuallyHidden","NavigableToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","PinnedItems","listView","plus","useCallback","useRef","useViewportMatch","SaveButton","UndoButton","RedoButton","MoreMenu","useLastSelectedWidgetArea","editWidgetsStore","unlock","useShouldContextualToolbarShow","Header","isMediumViewport","inserterButton","widgetAreaClientId","isLastSelectedWidgetAreaOpen","select","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","isInserterOpened","isListViewOpened","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","selectBlock","handleClick","window","requestAnimationFrame","toggleListView","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","createElement","Fragment","className","as","shouldUseKeyboardFocusShortcut","ref","variant","isPressed","onMouseDown","event","preventDefault","onClick","icon","label","Slot","scope"],"sources":["@wordpress/edit-widgets/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem, VisuallyHidden } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { PinnedItems } from '@wordpress/interface';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport MoreMenu from '../more-menu';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nfunction Header() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\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\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMediumViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigableToolbar\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t\t\tshouldUseKeyboardFocusShortcut={\n\t\t\t\t\t\t\t! blockToolbarCanBeFocused\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ handleClick }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</NavigableToolbar>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,MAAM,EAAEC,WAAW,EAAEC,cAAc,QAAQ,uBAAuB;AAC3E,SACCC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,QAAQ,EAAEC,IAAI,QAAQ,kBAAkB;AACjD,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,OAAOC,QAAQ,MAAM,cAAc;AACnC,OAAOC,yBAAyB,MAAM,2CAA2C;AACjF,SAASd,KAAK,IAAIe,gBAAgB,QAAQ,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,aAAA,CAAAC,QAAA,QACCD,aAAA,CAAC9B,UAAU,MAAE,CAAC,EACd8B,aAAA,CAAC7B,UAAU,MAAE,CAAC,EACd6B,aAAA,CAAC5C,WAAW;IACX+C,EAAE,EAAGhD,MAAQ;IACb+C,SAAS,EAAC,+CAA+C;IACzDU,IAAI,EAAGhD,QAAU;IACjB2C,SAAS,EAAGtB;IACZ;IACA4B,KAAK,EAAG5D,EAAE,CAAE,WAAY,CAAG;IAC3B0D,OAAO,EAAGhB;EAAgB,CAC1B,CACA,CAEc,CACd,CAAC,EACNK,aAAA;IAAKE,SAAS,EAAC;EAA8B,GAC5CF,aAAA,CAAC/B,UAAU,MAAE,CAAC,EACd+B,aAAA,CAACrC,WAAW,CAACmD,IAAI;IAACC,KAAK,EAAC;EAAmB,CAAE,CAAC,EAC9Cf,aAAA,CAAC5B,QAAQ,MAAE,CACP,CACD,CACJ,CAAC;AAEL;AAEA,eAAeK,MAAM"}
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","VisuallyHidden","NavigableToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","PinnedItems","listView","plus","useCallback","useRef","useViewportMatch","SaveButton","UndoButton","RedoButton","MoreMenu","useLastSelectedWidgetArea","editWidgetsStore","unlock","useShouldContextualToolbarShow","Header","setListViewToggleElement","isMediumViewport","inserterButton","widgetAreaClientId","isLastSelectedWidgetAreaOpen","select","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","isInserterOpened","isListViewOpened","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","selectBlock","handleClick","window","requestAnimationFrame","toggleListView","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","createElement","Fragment","className","as","shouldUseKeyboardFocusShortcut","ref","variant","isPressed","onMouseDown","event","preventDefault","onClick","icon","label","Slot","scope"],"sources":["@wordpress/edit-widgets/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem, VisuallyHidden } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { PinnedItems } from '@wordpress/interface';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport MoreMenu from '../more-menu';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nfunction Header( { setListViewToggleElement } ) {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\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\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMediumViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigableToolbar\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t\t\tshouldUseKeyboardFocusShortcut={\n\t\t\t\t\t\t\t! blockToolbarCanBeFocused\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ handleClick }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\t\tref={ setListViewToggleElement }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</NavigableToolbar>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,MAAM,EAAEC,WAAW,EAAEC,cAAc,QAAQ,uBAAuB;AAC3E,SACCC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,QAAQ,EAAEC,IAAI,QAAQ,kBAAkB;AACjD,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,OAAOC,QAAQ,MAAM,cAAc;AACnC,OAAOC,yBAAyB,MAAM,2CAA2C;AACjF,SAASd,KAAK,IAAIe,gBAAgB,QAAQ,aAAa;AACvD,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC;AAA+B,CAAC,GAAGD,MAAM,CAAEb,sBAAuB,CAAC;AAE3E,SAASe,MAAMA,CAAE;EAAEC;AAAyB,CAAC,EAAG;EAC/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AAQ;IACbgD,SAAS,EAAC,+CAA+C;IACzDU,IAAI,EAAGjD,QAAU;IACjB4C,SAAS,EAAGtB;IACZ;IACA4B,KAAK,EAAG7D,EAAE,CAAE,WAAY,CAAG;IAC3B2D,OAAO,EAAGhB,cAAgB;IAC1BU,GAAG,EAAG5B;EAA0B,CAChC,CACA,CAEc,CACd,CAAC,EACNuB,aAAA;IAAKE,SAAS,EAAC;EAA8B,GAC5CF,aAAA,CAAChC,UAAU,MAAE,CAAC,EACdgC,aAAA,CAACtC,WAAW,CAACoD,IAAI;IAACC,KAAK,EAAC;EAAmB,CAAE,CAAC,EAC9Cf,aAAA,CAAC7B,QAAQ,MAAE,CACP,CACD,CACJ,CAAC;AAEL;AAEA,eAAeK,MAAM"}
|
|
@@ -4,7 +4,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
*/
|
|
5
5
|
import { useViewportMatch } from '@wordpress/compose';
|
|
6
6
|
import { BlockBreadcrumb } from '@wordpress/block-editor';
|
|
7
|
-
import { useEffect } from '@wordpress/element';
|
|
7
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
8
8
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
9
9
|
import { InterfaceSkeleton, ComplementaryArea, store as interfaceStore } from '@wordpress/interface';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
@@ -53,6 +53,7 @@ function Interface({
|
|
|
53
53
|
previousShortcut: select(keyboardShortcutsStore).getAllShortcutKeyCombinations('core/edit-widgets/previous-region'),
|
|
54
54
|
nextShortcut: select(keyboardShortcutsStore).getAllShortcutKeyCombinations('core/edit-widgets/next-region')
|
|
55
55
|
}), []);
|
|
56
|
+
const [listViewToggleElement, setListViewToggleElement] = useState(null);
|
|
56
57
|
|
|
57
58
|
// Inserter and Sidebars are mutually exclusive
|
|
58
59
|
useEffect(() => {
|
|
@@ -73,8 +74,12 @@ function Interface({
|
|
|
73
74
|
...interfaceLabels,
|
|
74
75
|
secondarySidebar: secondarySidebarLabel
|
|
75
76
|
},
|
|
76
|
-
header: createElement(Header,
|
|
77
|
-
|
|
77
|
+
header: createElement(Header, {
|
|
78
|
+
setListViewToggleElement: setListViewToggleElement
|
|
79
|
+
}),
|
|
80
|
+
secondarySidebar: hasSecondarySidebar && createElement(SecondarySidebar, {
|
|
81
|
+
listViewToggleElement: listViewToggleElement
|
|
82
|
+
}),
|
|
78
83
|
sidebar: hasSidebarEnabled && createElement(ComplementaryArea.Slot, {
|
|
79
84
|
scope: "core/edit-widgets"
|
|
80
85
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useViewportMatch","BlockBreadcrumb","useEffect","useDispatch","useSelect","InterfaceSkeleton","ComplementaryArea","store","interfaceStore","__","keyboardShortcutsStore","preferencesStore","Header","WidgetAreasBlockEditorContent","editWidgetsStore","SecondarySidebar","interfaceLabels","header","body","sidebar","footer","Interface","blockEditorSettings","isMobileViewport","isHugeViewport","setIsInserterOpened","setIsListViewOpened","closeGeneralSidebar","hasBlockBreadCrumbsEnabled","hasSidebarEnabled","isInserterOpened","isListViewOpened","previousShortcut","nextShortcut","select","getActiveComplementaryArea","name","get","getAllShortcutKeyCombinations","secondarySidebarLabel","hasSecondarySidebar","createElement","labels","secondarySidebar","Slot","scope","content","Fragment","className","rootLabelText","shortcuts","previous","next"],"sources":["@wordpress/edit-widgets/src/components/layout/interface.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t\tpreviousShortcut,\n\t\tnextShortcut,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations(\n\t\t\t\t'core/edit-widgets/previous-region'\n\t\t\t),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-widgets/next-region' ),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={
|
|
1
|
+
{"version":3,"names":["useViewportMatch","BlockBreadcrumb","useEffect","useState","useDispatch","useSelect","InterfaceSkeleton","ComplementaryArea","store","interfaceStore","__","keyboardShortcutsStore","preferencesStore","Header","WidgetAreasBlockEditorContent","editWidgetsStore","SecondarySidebar","interfaceLabels","header","body","sidebar","footer","Interface","blockEditorSettings","isMobileViewport","isHugeViewport","setIsInserterOpened","setIsListViewOpened","closeGeneralSidebar","hasBlockBreadCrumbsEnabled","hasSidebarEnabled","isInserterOpened","isListViewOpened","previousShortcut","nextShortcut","select","getActiveComplementaryArea","name","get","getAllShortcutKeyCombinations","listViewToggleElement","setListViewToggleElement","secondarySidebarLabel","hasSecondarySidebar","createElement","labels","secondarySidebar","Slot","scope","content","Fragment","className","rootLabelText","shortcuts","previous","next"],"sources":["@wordpress/edit-widgets/src/components/layout/interface.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { BlockBreadcrumb } from '@wordpress/block-editor';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInterfaceSkeleton,\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport Header from '../header';\nimport WidgetAreasBlockEditorContent from '../widget-areas-block-editor-content';\nimport { store as editWidgetsStore } from '../../store';\nimport SecondarySidebar from '../secondary-sidebar';\n\nconst interfaceLabels = {\n\t/* translators: accessibility text for the widgets screen top bar landmark region. */\n\theader: __( 'Widgets top bar' ),\n\t/* translators: accessibility text for the widgets screen content landmark region. */\n\tbody: __( 'Widgets and blocks' ),\n\t/* translators: accessibility text for the widgets screen settings landmark region. */\n\tsidebar: __( 'Widgets settings' ),\n\t/* translators: accessibility text for the widgets screen footer landmark region. */\n\tfooter: __( 'Widgets footer' ),\n};\n\nfunction Interface( { blockEditorSettings } ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isHugeViewport = useViewportMatch( 'huge', '>=' );\n\tconst { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst {\n\t\thasBlockBreadCrumbsEnabled,\n\t\thasSidebarEnabled,\n\t\tisInserterOpened,\n\t\tisListViewOpened,\n\t\tpreviousShortcut,\n\t\tnextShortcut,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasSidebarEnabled: !! select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( editWidgetsStore.name ),\n\t\t\tisInserterOpened: !! select( editWidgetsStore ).isInserterOpened(),\n\t\t\tisListViewOpened: !! select( editWidgetsStore ).isListViewOpened(),\n\t\t\thasBlockBreadCrumbsEnabled: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'showBlockBreadcrumbs'\n\t\t\t),\n\t\t\tpreviousShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations(\n\t\t\t\t'core/edit-widgets/previous-region'\n\t\t\t),\n\t\t\tnextShortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getAllShortcutKeyCombinations( 'core/edit-widgets/next-region' ),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ listViewToggleElement, setListViewToggleElement ] =\n\t\tuseState( null );\n\n\t// Inserter and Sidebars are mutually exclusive\n\tuseEffect( () => {\n\t\tif ( hasSidebarEnabled && ! isHugeViewport ) {\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}, [ hasSidebarEnabled, isHugeViewport ] );\n\n\tuseEffect( () => {\n\t\tif ( ( isInserterOpened || isListViewOpened ) && ! isHugeViewport ) {\n\t\t\tcloseGeneralSidebar();\n\t\t}\n\t}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );\n\n\tconst secondarySidebarLabel = isListViewOpened\n\t\t? __( 'List View' )\n\t\t: __( 'Block Library' );\n\n\tconst hasSecondarySidebar = isListViewOpened || isInserterOpened;\n\n\treturn (\n\t\t<InterfaceSkeleton\n\t\t\tlabels={ {\n\t\t\t\t...interfaceLabels,\n\t\t\t\tsecondarySidebar: secondarySidebarLabel,\n\t\t\t} }\n\t\t\theader={\n\t\t\t\t<Header setListViewToggleElement={ setListViewToggleElement } />\n\t\t\t}\n\t\t\tsecondarySidebar={\n\t\t\t\thasSecondarySidebar && (\n\t\t\t\t\t<SecondarySidebar\n\t\t\t\t\t\tlistViewToggleElement={ listViewToggleElement }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tsidebar={\n\t\t\t\thasSidebarEnabled && (\n\t\t\t\t\t<ComplementaryArea.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t)\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t<WidgetAreasBlockEditorContent\n\t\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t}\n\t\t\tfooter={\n\t\t\t\thasBlockBreadCrumbsEnabled &&\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<div className=\"edit-widgets-layout__footer\">\n\t\t\t\t\t\t<BlockBreadcrumb rootLabelText={ __( 'Widgets' ) } />\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t}\n\t\t\tshortcuts={ {\n\t\t\t\tprevious: previousShortcut,\n\t\t\t\tnext: nextShortcut,\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nexport default Interface;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,iBAAiB,EACjBC,iBAAiB,EACjBC,KAAK,IAAIC,cAAc,QACjB,sBAAsB;AAC7B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASF,KAAK,IAAIG,sBAAsB,QAAQ,+BAA+B;AAC/E,SAASH,KAAK,IAAII,gBAAgB,QAAQ,wBAAwB;;AAElE;AACA;AACA;AACA,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,6BAA6B,MAAM,sCAAsC;AAChF,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,gBAAgB,MAAM,sBAAsB;AAEnD,MAAMC,eAAe,GAAG;EACvB;EACAC,MAAM,EAAER,EAAE,CAAE,iBAAkB,CAAC;EAC/B;EACAS,IAAI,EAAET,EAAE,CAAE,oBAAqB,CAAC;EAChC;EACAU,OAAO,EAAEV,EAAE,CAAE,kBAAmB,CAAC;EACjC;EACAW,MAAM,EAAEX,EAAE,CAAE,gBAAiB;AAC9B,CAAC;AAED,SAASY,SAASA,CAAE;EAAEC;AAAoB,CAAC,EAAG;EAC7C,MAAMC,gB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@ -13,7 +13,9 @@ import { store as editWidgetsStore } from '../../store';
|
|
|
13
13
|
*/
|
|
14
14
|
import InserterSidebar from './inserter-sidebar';
|
|
15
15
|
import ListViewSidebar from './list-view-sidebar';
|
|
16
|
-
export default function SecondarySidebar(
|
|
16
|
+
export default function SecondarySidebar({
|
|
17
|
+
listViewToggleElement
|
|
18
|
+
}) {
|
|
17
19
|
const {
|
|
18
20
|
isInserterOpen,
|
|
19
21
|
isListViewOpen
|
|
@@ -31,7 +33,9 @@ export default function SecondarySidebar() {
|
|
|
31
33
|
return createElement(InserterSidebar, null);
|
|
32
34
|
}
|
|
33
35
|
if (isListViewOpen) {
|
|
34
|
-
return createElement(ListViewSidebar,
|
|
36
|
+
return createElement(ListViewSidebar, {
|
|
37
|
+
listViewToggleElement: listViewToggleElement
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
40
|
return null;
|
|
37
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","store","editWidgetsStore","InserterSidebar","ListViewSidebar","SecondarySidebar","isInserterOpen","isListViewOpen","select","isInserterOpened","isListViewOpened","createElement"],"sources":["@wordpress/edit-widgets/src/components/secondary-sidebar/index.js"],"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
|
|
1
|
+
{"version":3,"names":["useSelect","store","editWidgetsStore","InserterSidebar","ListViewSidebar","SecondarySidebar","listViewToggleElement","isInserterOpen","isListViewOpen","select","isInserterOpened","isListViewOpened","createElement"],"sources":["@wordpress/edit-widgets/src/components/secondary-sidebar/index.js"],"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( { listViewToggleElement } ) {\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 (\n\t\t\t<ListViewSidebar listViewToggleElement={ listViewToggleElement } />\n\t\t);\n\t}\n\treturn null;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,oBAAoB;AAChD,OAAOC,eAAe,MAAM,qBAAqB;AAEjD,eAAe,SAASC,gBAAgBA,CAAE;EAAEC;AAAsB,CAAC,EAAG;EACrE,MAAM;IAAEC,cAAc;IAAEC;EAAe,CAAC,GAAGR,SAAS,CAAIS,MAAM,IAAM;IACnE,MAAM;MAAEC,gBAAgB;MAAEC;IAAiB,CAAC,GAC3CF,MAAM,CAAEP,gBAAiB,CAAC;IAC3B,OAAO;MACNK,cAAc,EAAEG,gBAAgB,CAAC,CAAC;MAClCF,cAAc,EAAEG,gBAAgB,CAAC;IAClC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAKJ,cAAc,EAAG;IACrB,OAAOK,aAAA,CAACT,eAAe,MAAE,CAAC;EAC3B;EACA,IAAKK,cAAc,EAAG;IACrB,OACCI,aAAA,CAACR,eAAe;MAACE,qBAAqB,EAAGA;IAAuB,CAAE,CAAC;EAErE;EACA,OAAO,IAAI;AACZ"}
|
|
@@ -4,9 +4,9 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
*/
|
|
5
5
|
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
6
6
|
import { Button } from '@wordpress/components';
|
|
7
|
-
import { useFocusOnMount,
|
|
7
|
+
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
|
|
8
8
|
import { useDispatch } from '@wordpress/data';
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
9
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { closeSmall } from '@wordpress/icons';
|
|
12
12
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
@@ -15,7 +15,9 @@ import { ESCAPE } from '@wordpress/keycodes';
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import { store as editWidgetsStore } from '../../store';
|
|
18
|
-
export default function ListViewSidebar(
|
|
18
|
+
export default function ListViewSidebar({
|
|
19
|
+
listViewToggleElement
|
|
20
|
+
}) {
|
|
19
21
|
const {
|
|
20
22
|
setIsListViewOpened
|
|
21
23
|
} = useDispatch(editWidgetsStore);
|
|
@@ -24,29 +26,32 @@ export default function ListViewSidebar() {
|
|
|
24
26
|
// re-renders when the dropZoneElement updates.
|
|
25
27
|
const [dropZoneElement, setDropZoneElement] = useState(null);
|
|
26
28
|
const focusOnMountRef = useFocusOnMount('firstElement');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
// When closing the list view, focus should return to the toggle button.
|
|
31
|
+
const closeListView = useCallback(() => {
|
|
32
|
+
setIsListViewOpened(false);
|
|
33
|
+
listViewToggleElement?.focus();
|
|
34
|
+
}, [listViewToggleElement, setIsListViewOpened]);
|
|
35
|
+
const closeOnEscape = useCallback(event => {
|
|
30
36
|
if (event.keyCode === ESCAPE && !event.defaultPrevented) {
|
|
31
37
|
event.preventDefault();
|
|
32
|
-
|
|
38
|
+
closeListView();
|
|
33
39
|
}
|
|
34
|
-
}
|
|
40
|
+
}, [closeListView]);
|
|
35
41
|
return (
|
|
36
42
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
37
43
|
createElement("div", {
|
|
38
44
|
className: "edit-widgets-editor__list-view-panel",
|
|
39
45
|
onKeyDown: closeOnEscape
|
|
40
46
|
}, createElement("div", {
|
|
41
|
-
className: "edit-widgets-editor__list-view-panel-header"
|
|
42
|
-
ref: headerFocusReturnRef
|
|
47
|
+
className: "edit-widgets-editor__list-view-panel-header"
|
|
43
48
|
}, createElement("strong", null, __('List View')), createElement(Button, {
|
|
44
49
|
icon: closeSmall,
|
|
45
50
|
label: __('Close'),
|
|
46
|
-
onClick:
|
|
51
|
+
onClick: closeListView
|
|
47
52
|
})), createElement("div", {
|
|
48
53
|
className: "edit-widgets-editor__list-view-panel-content",
|
|
49
|
-
ref: useMergeRefs([
|
|
54
|
+
ref: useMergeRefs([focusOnMountRef, setDropZoneElement])
|
|
50
55
|
}, createElement(ListView, {
|
|
51
56
|
dropZoneElement: dropZoneElement
|
|
52
57
|
})))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalListView","ListView","Button","useFocusOnMount","
|
|
1
|
+
{"version":3,"names":["__experimentalListView","ListView","Button","useFocusOnMount","useMergeRefs","useDispatch","useCallback","useState","__","closeSmall","ESCAPE","store","editWidgetsStore","ListViewSidebar","listViewToggleElement","setIsListViewOpened","dropZoneElement","setDropZoneElement","focusOnMountRef","closeListView","focus","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","createElement","className","onKeyDown","icon","label","onClick","ref"],"sources":["@wordpress/edit-widgets/src/components/secondary-sidebar/list-view-sidebar.js"],"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 } 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';\n\nexport default function ListViewSidebar( { listViewToggleElement } ) {\n\tconst { setIsListViewOpened } = useDispatch( 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\tlistViewToggleElement?.focus();\n\t}, [ listViewToggleElement, 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/>\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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,sBAAsB,IAAIC,QAAQ,QAAQ,yBAAyB;AAC5E,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,eAAe,EAAEC,YAAY,QAAQ,oBAAoB;AAClE,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,QAAQ,QAAQ,oBAAoB;AAC1D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,MAAM,QAAQ,qBAAqB;;AAE5C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,eAAe,SAASC,eAAeA,CAAE;EAAEC;AAAsB,CAAC,EAAG;EACpE,MAAM;IAAEC;EAAoB,CAAC,GAAGV,WAAW,CAAEO,gBAAiB,CAAC;;EAE/D;EACA;EACA,MAAM,CAAEI,eAAe,EAAEC,kBAAkB,CAAE,GAAGV,QAAQ,CAAE,IAAK,CAAC;EAEhE,MAAMW,eAAe,GAAGf,eAAe,CAAE,cAAe,CAAC;;EAEzD;EACA,MAAMgB,aAAa,GAAGb,WAAW,CAAE,MAAM;IACxCS,mBAAmB,CAAE,KAAM,CAAC;IAC5BD,qBAAqB,EAAEM,KAAK,CAAC,CAAC;EAC/B,CAAC,EAAE,CAAEN,qBAAqB,EAAEC,mBAAmB,CAAG,CAAC;EAEnD,MAAMM,aAAa,GAAGf,WAAW,CAC9BgB,KAAK,IAAM;IACZ,IAAKA,KAAK,CAACC,OAAO,KAAKb,MAAM,IAAI,CAAEY,KAAK,CAACE,gBAAgB,EAAG;MAC3DF,KAAK,CAACG,cAAc,CAAC,CAAC;MACtBN,aAAa,CAAC,CAAC;IAChB;EACD,CAAC,EACD,CAAEA,aAAa,CAChB,CAAC;EAED;IACC;IACAO,aAAA;MACCC,SAAS,EAAC,sCAAsC;MAChDC,SAAS,EAAGP;IAAe,GAE3BK,aAAA;MAAKC,SAAS,EAAC;IAA6C,GAC3DD,aAAA,iBAAUlB,EAAE,CAAE,WAAY,CAAW,CAAC,EACtCkB,aAAA,CAACxB,MAAM;MACN2B,IAAI,EAAGpB,UAAY;MACnBqB,KAAK,EAAGtB,EAAE,CAAE,OAAQ,CAAG;MACvBuB,OAAO,EAAGZ;IAAe,CACzB,CACG,CAAC,EACNO,aAAA;MACCC,SAAS,EAAC,8CAA8C;MACxDK,GAAG,EAAG5B,YAAY,CAAE,CAAEc,eAAe,EAAED,kBAAkB,CAAG;IAAG,GAE/DS,aAAA,CAACzB,QAAQ;MAACe,eAAe,EAAGA;IAAiB,CAAE,CAC3C,CACD;EAAC;AAER"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "5.19.
|
|
3
|
+
"version": "5.19.1",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,32 +27,32 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/api-fetch": "^6.39.
|
|
31
|
-
"@wordpress/block-editor": "^12.10.
|
|
32
|
-
"@wordpress/block-library": "^8.19.
|
|
33
|
-
"@wordpress/blocks": "^12.19.
|
|
34
|
-
"@wordpress/components": "^25.8.
|
|
35
|
-
"@wordpress/compose": "^6.19.
|
|
36
|
-
"@wordpress/core-data": "^6.19.
|
|
37
|
-
"@wordpress/data": "^9.12.
|
|
38
|
-
"@wordpress/deprecated": "^3.42.
|
|
39
|
-
"@wordpress/dom": "^3.42.
|
|
40
|
-
"@wordpress/element": "^5.19.
|
|
41
|
-
"@wordpress/hooks": "^3.42.
|
|
42
|
-
"@wordpress/i18n": "^4.42.
|
|
43
|
-
"@wordpress/icons": "^9.33.
|
|
44
|
-
"@wordpress/interface": "^5.19.
|
|
45
|
-
"@wordpress/keyboard-shortcuts": "^4.19.
|
|
46
|
-
"@wordpress/keycodes": "^3.42.
|
|
47
|
-
"@wordpress/media-utils": "^4.33.
|
|
48
|
-
"@wordpress/notices": "^4.10.
|
|
49
|
-
"@wordpress/patterns": "^1.3.
|
|
50
|
-
"@wordpress/plugins": "^6.10.
|
|
51
|
-
"@wordpress/preferences": "^3.19.
|
|
52
|
-
"@wordpress/private-apis": "^0.24.
|
|
53
|
-
"@wordpress/reusable-blocks": "^4.19.
|
|
54
|
-
"@wordpress/url": "^3.43.
|
|
55
|
-
"@wordpress/widgets": "^3.19.
|
|
30
|
+
"@wordpress/api-fetch": "^6.39.1",
|
|
31
|
+
"@wordpress/block-editor": "^12.10.1",
|
|
32
|
+
"@wordpress/block-library": "^8.19.1",
|
|
33
|
+
"@wordpress/blocks": "^12.19.1",
|
|
34
|
+
"@wordpress/components": "^25.8.1",
|
|
35
|
+
"@wordpress/compose": "^6.19.1",
|
|
36
|
+
"@wordpress/core-data": "^6.19.1",
|
|
37
|
+
"@wordpress/data": "^9.12.1",
|
|
38
|
+
"@wordpress/deprecated": "^3.42.1",
|
|
39
|
+
"@wordpress/dom": "^3.42.1",
|
|
40
|
+
"@wordpress/element": "^5.19.1",
|
|
41
|
+
"@wordpress/hooks": "^3.42.1",
|
|
42
|
+
"@wordpress/i18n": "^4.42.1",
|
|
43
|
+
"@wordpress/icons": "^9.33.1",
|
|
44
|
+
"@wordpress/interface": "^5.19.1",
|
|
45
|
+
"@wordpress/keyboard-shortcuts": "^4.19.1",
|
|
46
|
+
"@wordpress/keycodes": "^3.42.1",
|
|
47
|
+
"@wordpress/media-utils": "^4.33.1",
|
|
48
|
+
"@wordpress/notices": "^4.10.1",
|
|
49
|
+
"@wordpress/patterns": "^1.3.1",
|
|
50
|
+
"@wordpress/plugins": "^6.10.1",
|
|
51
|
+
"@wordpress/preferences": "^3.19.1",
|
|
52
|
+
"@wordpress/private-apis": "^0.24.1",
|
|
53
|
+
"@wordpress/reusable-blocks": "^4.19.1",
|
|
54
|
+
"@wordpress/url": "^3.43.1",
|
|
55
|
+
"@wordpress/widgets": "^3.19.1",
|
|
56
56
|
"classnames": "^2.3.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "4987d16acb5c41b62704dc4f88225acb97ddd698"
|
|
66
66
|
}
|
|
@@ -27,7 +27,7 @@ import { unlock } from '../../lock-unlock';
|
|
|
27
27
|
|
|
28
28
|
const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );
|
|
29
29
|
|
|
30
|
-
function Header() {
|
|
30
|
+
function Header( { setListViewToggleElement } ) {
|
|
31
31
|
const isMediumViewport = useViewportMatch( 'medium' );
|
|
32
32
|
const inserterButton = useRef();
|
|
33
33
|
const widgetAreaClientId = useLastSelectedWidgetArea();
|
|
@@ -140,6 +140,7 @@ function Header() {
|
|
|
140
140
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
141
141
|
label={ __( 'List View' ) }
|
|
142
142
|
onClick={ toggleListView }
|
|
143
|
+
ref={ setListViewToggleElement }
|
|
143
144
|
/>
|
|
144
145
|
</>
|
|
145
146
|
) }
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useViewportMatch } from '@wordpress/compose';
|
|
5
5
|
import { BlockBreadcrumb } from '@wordpress/block-editor';
|
|
6
|
-
import { useEffect } from '@wordpress/element';
|
|
6
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
7
7
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
8
|
import {
|
|
9
9
|
InterfaceSkeleton,
|
|
@@ -68,6 +68,9 @@ function Interface( { blockEditorSettings } ) {
|
|
|
68
68
|
[]
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
+
const [ listViewToggleElement, setListViewToggleElement ] =
|
|
72
|
+
useState( null );
|
|
73
|
+
|
|
71
74
|
// Inserter and Sidebars are mutually exclusive
|
|
72
75
|
useEffect( () => {
|
|
73
76
|
if ( hasSidebarEnabled && ! isHugeViewport ) {
|
|
@@ -94,8 +97,16 @@ function Interface( { blockEditorSettings } ) {
|
|
|
94
97
|
...interfaceLabels,
|
|
95
98
|
secondarySidebar: secondarySidebarLabel,
|
|
96
99
|
} }
|
|
97
|
-
header={
|
|
98
|
-
|
|
100
|
+
header={
|
|
101
|
+
<Header setListViewToggleElement={ setListViewToggleElement } />
|
|
102
|
+
}
|
|
103
|
+
secondarySidebar={
|
|
104
|
+
hasSecondarySidebar && (
|
|
105
|
+
<SecondarySidebar
|
|
106
|
+
listViewToggleElement={ listViewToggleElement }
|
|
107
|
+
/>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
99
110
|
sidebar={
|
|
100
111
|
hasSidebarEnabled && (
|
|
101
112
|
<ComplementaryArea.Slot scope="core/edit-widgets" />
|
|
@@ -13,7 +13,7 @@ import { store as editWidgetsStore } from '../../store';
|
|
|
13
13
|
import InserterSidebar from './inserter-sidebar';
|
|
14
14
|
import ListViewSidebar from './list-view-sidebar';
|
|
15
15
|
|
|
16
|
-
export default function SecondarySidebar() {
|
|
16
|
+
export default function SecondarySidebar( { listViewToggleElement } ) {
|
|
17
17
|
const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {
|
|
18
18
|
const { isInserterOpened, isListViewOpened } =
|
|
19
19
|
select( editWidgetsStore );
|
|
@@ -27,7 +27,9 @@ export default function SecondarySidebar() {
|
|
|
27
27
|
return <InserterSidebar />;
|
|
28
28
|
}
|
|
29
29
|
if ( isListViewOpen ) {
|
|
30
|
-
return
|
|
30
|
+
return (
|
|
31
|
+
<ListViewSidebar listViewToggleElement={ listViewToggleElement } />
|
|
32
|
+
);
|
|
31
33
|
}
|
|
32
34
|
return null;
|
|
33
35
|
}
|
|
@@ -3,13 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
|
-
import {
|
|
7
|
-
useFocusOnMount,
|
|
8
|
-
useFocusReturn,
|
|
9
|
-
useMergeRefs,
|
|
10
|
-
} from '@wordpress/compose';
|
|
6
|
+
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
|
|
11
7
|
import { useDispatch } from '@wordpress/data';
|
|
12
|
-
import { useState } from '@wordpress/element';
|
|
8
|
+
import { useCallback, useState } from '@wordpress/element';
|
|
13
9
|
import { __ } from '@wordpress/i18n';
|
|
14
10
|
import { closeSmall } from '@wordpress/icons';
|
|
15
11
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
@@ -19,7 +15,7 @@ import { ESCAPE } from '@wordpress/keycodes';
|
|
|
19
15
|
*/
|
|
20
16
|
import { store as editWidgetsStore } from '../../store';
|
|
21
17
|
|
|
22
|
-
export default function ListViewSidebar() {
|
|
18
|
+
export default function ListViewSidebar( { listViewToggleElement } ) {
|
|
23
19
|
const { setIsListViewOpened } = useDispatch( editWidgetsStore );
|
|
24
20
|
|
|
25
21
|
// Use internal state instead of a ref to make sure that the component
|
|
@@ -27,15 +23,22 @@ export default function ListViewSidebar() {
|
|
|
27
23
|
const [ dropZoneElement, setDropZoneElement ] = useState( null );
|
|
28
24
|
|
|
29
25
|
const focusOnMountRef = useFocusOnMount( 'firstElement' );
|
|
30
|
-
const headerFocusReturnRef = useFocusReturn();
|
|
31
|
-
const contentFocusReturnRef = useFocusReturn();
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
// When closing the list view, focus should return to the toggle button.
|
|
28
|
+
const closeListView = useCallback( () => {
|
|
29
|
+
setIsListViewOpened( false );
|
|
30
|
+
listViewToggleElement?.focus();
|
|
31
|
+
}, [ listViewToggleElement, setIsListViewOpened ] );
|
|
32
|
+
|
|
33
|
+
const closeOnEscape = useCallback(
|
|
34
|
+
( event ) => {
|
|
35
|
+
if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
closeListView();
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
[ closeListView ]
|
|
41
|
+
);
|
|
39
42
|
|
|
40
43
|
return (
|
|
41
44
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -43,24 +46,17 @@ export default function ListViewSidebar() {
|
|
|
43
46
|
className="edit-widgets-editor__list-view-panel"
|
|
44
47
|
onKeyDown={ closeOnEscape }
|
|
45
48
|
>
|
|
46
|
-
<div
|
|
47
|
-
className="edit-widgets-editor__list-view-panel-header"
|
|
48
|
-
ref={ headerFocusReturnRef }
|
|
49
|
-
>
|
|
49
|
+
<div className="edit-widgets-editor__list-view-panel-header">
|
|
50
50
|
<strong>{ __( 'List View' ) }</strong>
|
|
51
51
|
<Button
|
|
52
52
|
icon={ closeSmall }
|
|
53
53
|
label={ __( 'Close' ) }
|
|
54
|
-
onClick={
|
|
54
|
+
onClick={ closeListView }
|
|
55
55
|
/>
|
|
56
56
|
</div>
|
|
57
57
|
<div
|
|
58
58
|
className="edit-widgets-editor__list-view-panel-content"
|
|
59
|
-
ref={ useMergeRefs( [
|
|
60
|
-
contentFocusReturnRef,
|
|
61
|
-
focusOnMountRef,
|
|
62
|
-
setDropZoneElement,
|
|
63
|
-
] ) }
|
|
59
|
+
ref={ useMergeRefs( [ focusOnMountRef, setDropZoneElement ] ) }
|
|
64
60
|
>
|
|
65
61
|
<ListView dropZoneElement={ dropZoneElement } />
|
|
66
62
|
</div>
|