@wordpress/edit-widgets 5.25.0 → 5.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +1 -1
- package/build/blocks/widget-area/index.js +1 -0
- package/build/blocks/widget-area/index.js.map +1 -1
- package/build/components/header/document-tools/index.js +12 -16
- package/build/components/header/document-tools/index.js.map +1 -1
- package/build/components/header/index.js +2 -6
- package/build/components/header/index.js.map +1 -1
- package/build/components/layout/interface.js +2 -7
- package/build/components/layout/interface.js.map +1 -1
- package/build/components/secondary-sidebar/index.js +2 -6
- package/build/components/secondary-sidebar/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/store/index.js +3 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-selectors.js +10 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +14 -0
- package/build/store/reducer.js.map +1 -1
- package/build-module/blocks/widget-area/index.js +1 -0
- package/build-module/blocks/widget-area/index.js.map +1 -1
- package/build-module/components/header/document-tools/index.js +12 -16
- package/build-module/components/header/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +2 -6
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/layout/interface.js +3 -8
- package/build-module/components/layout/interface.js.map +1 -1
- package/build-module/components/secondary-sidebar/index.js +2 -6
- package/build-module/components/secondary-sidebar/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +8 -6
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/store/index.js +3 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-selectors.js +4 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +13 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +4 -0
- package/build-style/style.css +4 -0
- package/package.json +30 -29
- package/src/blocks/widget-area/block.json +1 -0
- package/src/components/header/document-tools/index.js +16 -21
- package/src/components/header/index.js +2 -4
- package/src/components/layout/interface.js +3 -14
- package/src/components/secondary-sidebar/index.js +2 -4
- package/src/components/secondary-sidebar/list-view-sidebar.js +6 -4
- package/src/store/index.js +4 -0
- package/src/store/private-selectors.js +3 -0
- package/src/store/reducer.js +11 -0
|
@@ -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() {
|
|
17
17
|
const { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {
|
|
18
18
|
const { isInserterOpened, isListViewOpened } =
|
|
19
19
|
select( editWidgetsStore );
|
|
@@ -27,9 +27,7 @@ export default function SecondarySidebar( { listViewToggleElement } ) {
|
|
|
27
27
|
return <InserterSidebar />;
|
|
28
28
|
}
|
|
29
29
|
if ( isListViewOpen ) {
|
|
30
|
-
return
|
|
31
|
-
<ListViewSidebar listViewToggleElement={ listViewToggleElement } />
|
|
32
|
-
);
|
|
30
|
+
return <ListViewSidebar />;
|
|
33
31
|
}
|
|
34
32
|
return null;
|
|
35
33
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { __experimentalListView as ListView } from '@wordpress/block-editor';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
6
|
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
|
|
7
|
-
import { useDispatch } from '@wordpress/data';
|
|
7
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
8
|
import { useCallback, useState } from '@wordpress/element';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { closeSmall } from '@wordpress/icons';
|
|
@@ -14,9 +14,11 @@ import { ESCAPE } from '@wordpress/keycodes';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import { store as editWidgetsStore } from '../../store';
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
17
18
|
|
|
18
|
-
export default function ListViewSidebar(
|
|
19
|
+
export default function ListViewSidebar() {
|
|
19
20
|
const { setIsListViewOpened } = useDispatch( editWidgetsStore );
|
|
21
|
+
const { getListViewToggleRef } = unlock( useSelect( editWidgetsStore ) );
|
|
20
22
|
|
|
21
23
|
// Use internal state instead of a ref to make sure that the component
|
|
22
24
|
// re-renders when the dropZoneElement updates.
|
|
@@ -27,8 +29,8 @@ export default function ListViewSidebar( { listViewToggleElement } ) {
|
|
|
27
29
|
// When closing the list view, focus should return to the toggle button.
|
|
28
30
|
const closeListView = useCallback( () => {
|
|
29
31
|
setIsListViewOpened( false );
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
+
getListViewToggleRef().current?.focus();
|
|
33
|
+
}, [ getListViewToggleRef, setIsListViewOpened ] );
|
|
32
34
|
|
|
33
35
|
const closeOnEscape = useCallback(
|
|
34
36
|
( event ) => {
|
package/src/store/index.js
CHANGED
|
@@ -11,7 +11,9 @@ import reducer from './reducer';
|
|
|
11
11
|
import * as resolvers from './resolvers';
|
|
12
12
|
import * as selectors from './selectors';
|
|
13
13
|
import * as actions from './actions';
|
|
14
|
+
import * as privateSelectors from './private-selectors';
|
|
14
15
|
import { STORE_NAME } from './constants';
|
|
16
|
+
import { unlock } from '../lock-unlock';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Block editor data store configuration.
|
|
@@ -47,3 +49,5 @@ apiFetch.use( function ( options, next ) {
|
|
|
47
49
|
|
|
48
50
|
return next( options );
|
|
49
51
|
} );
|
|
52
|
+
|
|
53
|
+
unlock( store ).registerPrivateSelectors( privateSelectors );
|
package/src/store/reducer.js
CHANGED
|
@@ -68,6 +68,17 @@ export function listViewPanel( state = false, action ) {
|
|
|
68
68
|
return state;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* This reducer does nothing aside initializing a ref to the list view toggle.
|
|
73
|
+
* We will have a unique ref per "editor" instance.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} state
|
|
76
|
+
* @return {Object} Reference to the list view toggle button.
|
|
77
|
+
*/
|
|
78
|
+
export function listViewToggleRef( state = { current: null } ) {
|
|
79
|
+
return state;
|
|
80
|
+
}
|
|
81
|
+
|
|
71
82
|
export default combineReducers( {
|
|
72
83
|
blockInserterPanel,
|
|
73
84
|
listViewPanel,
|