@wordpress/interface 5.31.0 → 5.33.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 +4 -0
- package/README.md +10 -10
- package/build/components/action-item/index.js.map +1 -1
- package/build/components/complementary-area/index.js +58 -3
- package/build/components/complementary-area/index.js.map +1 -1
- package/build/components/complementary-area-context/index.js.map +1 -1
- package/build/components/complementary-area-header/index.js.map +1 -1
- package/build/components/complementary-area-more-menu-item/index.js.map +1 -1
- package/build/components/complementary-area-toggle/index.js.map +1 -1
- package/build/components/fullscreen-mode/index.js.map +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/interface-skeleton/index.js +36 -2
- package/build/components/interface-skeleton/index.js.map +1 -1
- package/build/components/navigable-region/index.js.map +1 -1
- package/build/components/pinned-items/index.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/store/actions.js +21 -5
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/deprecated.js +42 -0
- package/build/store/deprecated.js.map +1 -0
- package/build/store/index.js +1 -1
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -0
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/action-item/index.js.map +1 -1
- package/build-module/components/complementary-area/index.js +60 -5
- package/build-module/components/complementary-area/index.js.map +1 -1
- package/build-module/components/complementary-area-context/index.js.map +1 -1
- package/build-module/components/complementary-area-header/index.js.map +1 -1
- package/build-module/components/complementary-area-more-menu-item/index.js.map +1 -1
- package/build-module/components/complementary-area-toggle/index.js.map +1 -1
- package/build-module/components/fullscreen-mode/index.js.map +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/interface-skeleton/index.js +38 -4
- package/build-module/components/interface-skeleton/index.js.map +1 -1
- package/build-module/components/navigable-region/index.js.map +1 -1
- package/build-module/components/pinned-items/index.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +21 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/deprecated.js +33 -0
- package/build-module/store/deprecated.js.map +1 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +7 -5
- package/build-style/style.css +7 -5
- package/package.json +14 -14
- package/src/components/complementary-area/README.md +2 -2
- package/src/components/complementary-area/index.js +139 -58
- package/src/components/complementary-area-more-menu-item/README.md +1 -1
- package/src/components/complementary-area-toggle/README.md +1 -1
- package/src/components/interface-skeleton/index.js +50 -10
- package/src/components/interface-skeleton/style.scss +3 -3
- package/src/components/pinned-items/README.md +2 -2
- package/src/components/pinned-items/style.scss +1 -2
- package/src/store/actions.js +24 -5
- package/src/store/deprecated.js +37 -0
- package/src/store/selectors.js +12 -0
|
@@ -6,13 +6,25 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
Button,
|
|
11
|
+
Panel,
|
|
12
|
+
Slot,
|
|
13
|
+
Fill,
|
|
14
|
+
__unstableMotion as motion,
|
|
15
|
+
__unstableAnimatePresence as AnimatePresence,
|
|
16
|
+
} from '@wordpress/components';
|
|
10
17
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
18
|
import { __ } from '@wordpress/i18n';
|
|
12
19
|
import { check, starEmpty, starFilled } from '@wordpress/icons';
|
|
13
|
-
import { useEffect, useRef } from '@wordpress/element';
|
|
20
|
+
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
14
21
|
import { store as viewportStore } from '@wordpress/viewport';
|
|
15
22
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
23
|
+
import {
|
|
24
|
+
useReducedMotion,
|
|
25
|
+
useViewportMatch,
|
|
26
|
+
usePrevious,
|
|
27
|
+
} from '@wordpress/compose';
|
|
16
28
|
|
|
17
29
|
/**
|
|
18
30
|
* Internal dependencies
|
|
@@ -24,16 +36,77 @@ import withComplementaryAreaContext from '../complementary-area-context';
|
|
|
24
36
|
import PinnedItems from '../pinned-items';
|
|
25
37
|
import { store as interfaceStore } from '../../store';
|
|
26
38
|
|
|
39
|
+
const ANIMATION_DURATION = 0.3;
|
|
40
|
+
|
|
27
41
|
function ComplementaryAreaSlot( { scope, ...props } ) {
|
|
28
42
|
return <Slot name={ `ComplementaryArea/${ scope }` } { ...props } />;
|
|
29
43
|
}
|
|
30
44
|
|
|
31
|
-
|
|
45
|
+
const SIDEBAR_WIDTH = 280;
|
|
46
|
+
const variants = {
|
|
47
|
+
open: { width: SIDEBAR_WIDTH },
|
|
48
|
+
closed: { width: 0 },
|
|
49
|
+
mobileOpen: { width: '100vw' },
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function ComplementaryAreaFill( {
|
|
53
|
+
activeArea,
|
|
54
|
+
isActive,
|
|
55
|
+
scope,
|
|
56
|
+
children,
|
|
57
|
+
className,
|
|
58
|
+
id,
|
|
59
|
+
} ) {
|
|
60
|
+
const disableMotion = useReducedMotion();
|
|
61
|
+
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
62
|
+
// This is used to delay the exit animation to the next tick.
|
|
63
|
+
// The reason this is done is to allow us to apply the right transition properties
|
|
64
|
+
// When we switch from an open sidebar to another open sidebar.
|
|
65
|
+
// we don't want to animate in this case.
|
|
66
|
+
const previousActiveArea = usePrevious( activeArea );
|
|
67
|
+
const previousIsActive = usePrevious( isActive );
|
|
68
|
+
const [ , setState ] = useState( {} );
|
|
69
|
+
useEffect( () => {
|
|
70
|
+
setState( {} );
|
|
71
|
+
}, [ isActive ] );
|
|
72
|
+
const transition = {
|
|
73
|
+
type: 'tween',
|
|
74
|
+
duration:
|
|
75
|
+
disableMotion ||
|
|
76
|
+
isMobileViewport ||
|
|
77
|
+
( !! previousActiveArea &&
|
|
78
|
+
!! activeArea &&
|
|
79
|
+
activeArea !== previousActiveArea )
|
|
80
|
+
? 0
|
|
81
|
+
: ANIMATION_DURATION,
|
|
82
|
+
ease: [ 0.6, 0, 0.4, 1 ],
|
|
83
|
+
};
|
|
84
|
+
|
|
32
85
|
return (
|
|
33
86
|
<Fill name={ `ComplementaryArea/${ scope }` }>
|
|
34
|
-
<
|
|
35
|
-
{
|
|
36
|
-
|
|
87
|
+
<AnimatePresence initial={ false }>
|
|
88
|
+
{ ( previousIsActive || isActive ) && (
|
|
89
|
+
<motion.div
|
|
90
|
+
variants={ variants }
|
|
91
|
+
initial="closed"
|
|
92
|
+
animate={ isMobileViewport ? 'mobileOpen' : 'open' }
|
|
93
|
+
exit="closed"
|
|
94
|
+
transition={ transition }
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
id={ id }
|
|
98
|
+
className={ className }
|
|
99
|
+
style={ {
|
|
100
|
+
width: isMobileViewport
|
|
101
|
+
? '100vw'
|
|
102
|
+
: SIDEBAR_WIDTH,
|
|
103
|
+
} }
|
|
104
|
+
>
|
|
105
|
+
{ children }
|
|
106
|
+
</div>
|
|
107
|
+
</motion.div>
|
|
108
|
+
) }
|
|
109
|
+
</AnimatePresence>
|
|
37
110
|
</Fill>
|
|
38
111
|
);
|
|
39
112
|
}
|
|
@@ -110,6 +183,11 @@ function ComplementaryArea( {
|
|
|
110
183
|
toggleShortcut,
|
|
111
184
|
isActiveByDefault,
|
|
112
185
|
} ) {
|
|
186
|
+
// This state is used to delay the rendering of the Fill
|
|
187
|
+
// until the initial effect runs.
|
|
188
|
+
// This prevents the animation from running on mount if
|
|
189
|
+
// the complementary area is active by default.
|
|
190
|
+
const [ isReady, setIsReady ] = useState( false );
|
|
113
191
|
const {
|
|
114
192
|
isLoading,
|
|
115
193
|
isActive,
|
|
@@ -163,6 +241,7 @@ function ComplementaryArea( {
|
|
|
163
241
|
} else if ( activeArea === undefined && isSmall ) {
|
|
164
242
|
disableComplementaryArea( scope, identifier );
|
|
165
243
|
}
|
|
244
|
+
setIsReady( true );
|
|
166
245
|
}, [
|
|
167
246
|
activeArea,
|
|
168
247
|
isActiveByDefault,
|
|
@@ -173,6 +252,10 @@ function ComplementaryArea( {
|
|
|
173
252
|
disableComplementaryArea,
|
|
174
253
|
] );
|
|
175
254
|
|
|
255
|
+
if ( ! isReady ) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
176
259
|
return (
|
|
177
260
|
<>
|
|
178
261
|
{ isPinnable && (
|
|
@@ -204,59 +287,57 @@ function ComplementaryArea( {
|
|
|
204
287
|
{ title }
|
|
205
288
|
</ComplementaryAreaMoreMenuItem>
|
|
206
289
|
) }
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
290
|
+
<ComplementaryAreaFill
|
|
291
|
+
activeArea={ activeArea }
|
|
292
|
+
isActive={ isActive }
|
|
293
|
+
className={ classnames(
|
|
294
|
+
'interface-complementary-area',
|
|
295
|
+
className
|
|
296
|
+
) }
|
|
297
|
+
scope={ scope }
|
|
298
|
+
id={ identifier.replace( '/', ':' ) }
|
|
299
|
+
>
|
|
300
|
+
<ComplementaryAreaHeader
|
|
301
|
+
className={ headerClassName }
|
|
302
|
+
closeLabel={ closeLabel }
|
|
303
|
+
onClose={ () => disableComplementaryArea( scope ) }
|
|
304
|
+
smallScreenTitle={ smallScreenTitle }
|
|
305
|
+
toggleButtonProps={ {
|
|
306
|
+
label: closeLabel,
|
|
307
|
+
shortcut: toggleShortcut,
|
|
308
|
+
scope,
|
|
309
|
+
identifier,
|
|
310
|
+
} }
|
|
215
311
|
>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
( isPinned ? unpinItem : pinItem )(
|
|
246
|
-
scope,
|
|
247
|
-
identifier
|
|
248
|
-
)
|
|
249
|
-
}
|
|
250
|
-
isPressed={ isPinned }
|
|
251
|
-
aria-expanded={ isPinned }
|
|
252
|
-
/>
|
|
253
|
-
) }
|
|
254
|
-
</>
|
|
255
|
-
) }
|
|
256
|
-
</ComplementaryAreaHeader>
|
|
257
|
-
<Panel className={ panelClassName }>{ children }</Panel>
|
|
258
|
-
</ComplementaryAreaFill>
|
|
259
|
-
) }
|
|
312
|
+
{ header || (
|
|
313
|
+
<>
|
|
314
|
+
<h2 className="interface-complementary-area-header__title">
|
|
315
|
+
{ title }
|
|
316
|
+
</h2>
|
|
317
|
+
{ isPinnable && (
|
|
318
|
+
<Button
|
|
319
|
+
className="interface-complementary-area__pin-unpin-item"
|
|
320
|
+
icon={ isPinned ? starFilled : starEmpty }
|
|
321
|
+
label={
|
|
322
|
+
isPinned
|
|
323
|
+
? __( 'Unpin from toolbar' )
|
|
324
|
+
: __( 'Pin to toolbar' )
|
|
325
|
+
}
|
|
326
|
+
onClick={ () =>
|
|
327
|
+
( isPinned ? unpinItem : pinItem )(
|
|
328
|
+
scope,
|
|
329
|
+
identifier
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
isPressed={ isPinned }
|
|
333
|
+
aria-expanded={ isPinned }
|
|
334
|
+
/>
|
|
335
|
+
) }
|
|
336
|
+
</>
|
|
337
|
+
) }
|
|
338
|
+
</ComplementaryAreaHeader>
|
|
339
|
+
<Panel className={ panelClassName }>{ children }</Panel>
|
|
340
|
+
</ComplementaryAreaFill>
|
|
260
341
|
</>
|
|
261
342
|
);
|
|
262
343
|
}
|
|
@@ -5,7 +5,7 @@ Props not referenced here are passed to the component used to render the menu it
|
|
|
5
5
|
|
|
6
6
|
### scope
|
|
7
7
|
|
|
8
|
-
The scope of the complementary area e.g: "core
|
|
8
|
+
The scope of the complementary area e.g: "core", "myplugin/custom-screen-a",
|
|
9
9
|
|
|
10
10
|
- Type: `String`
|
|
11
11
|
- Required: Yes
|
|
@@ -10,15 +10,23 @@ import { forwardRef, useEffect } from '@wordpress/element';
|
|
|
10
10
|
import {
|
|
11
11
|
__unstableUseNavigateRegions as useNavigateRegions,
|
|
12
12
|
__unstableMotion as motion,
|
|
13
|
+
__unstableAnimatePresence as AnimatePresence,
|
|
13
14
|
} from '@wordpress/components';
|
|
14
15
|
import { __, _x } from '@wordpress/i18n';
|
|
15
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
useMergeRefs,
|
|
18
|
+
useReducedMotion,
|
|
19
|
+
useViewportMatch,
|
|
20
|
+
useResizeObserver,
|
|
21
|
+
} from '@wordpress/compose';
|
|
16
22
|
|
|
17
23
|
/**
|
|
18
24
|
* Internal dependencies
|
|
19
25
|
*/
|
|
20
26
|
import NavigableRegion from '../navigable-region';
|
|
21
27
|
|
|
28
|
+
const ANIMATION_DURATION = 0.25;
|
|
29
|
+
|
|
22
30
|
function useHTMLClass( className ) {
|
|
23
31
|
useEffect( () => {
|
|
24
32
|
const element =
|
|
@@ -62,8 +70,16 @@ function InterfaceSkeleton(
|
|
|
62
70
|
},
|
|
63
71
|
ref
|
|
64
72
|
) {
|
|
73
|
+
const [ secondarySidebarResizeListener, secondarySidebarSize ] =
|
|
74
|
+
useResizeObserver();
|
|
75
|
+
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
76
|
+
const disableMotion = useReducedMotion();
|
|
77
|
+
const defaultTransition = {
|
|
78
|
+
type: 'tween',
|
|
79
|
+
duration: disableMotion ? 0 : ANIMATION_DURATION,
|
|
80
|
+
ease: [ 0.6, 0, 0.4, 1 ],
|
|
81
|
+
};
|
|
65
82
|
const navigateRegionsProps = useNavigateRegions( shortcuts );
|
|
66
|
-
|
|
67
83
|
useHTMLClass( 'interface-interface-skeleton__html-container' );
|
|
68
84
|
|
|
69
85
|
const defaultLabels = {
|
|
@@ -134,14 +150,38 @@ function InterfaceSkeleton(
|
|
|
134
150
|
</div>
|
|
135
151
|
) }
|
|
136
152
|
<div className="interface-interface-skeleton__body">
|
|
137
|
-
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
<AnimatePresence initial={ false }>
|
|
154
|
+
{ !! secondarySidebar && (
|
|
155
|
+
<NavigableRegion
|
|
156
|
+
className="interface-interface-skeleton__secondary-sidebar"
|
|
157
|
+
ariaLabel={ mergedLabels.secondarySidebar }
|
|
158
|
+
as={ motion.div }
|
|
159
|
+
initial="closed"
|
|
160
|
+
animate={
|
|
161
|
+
isMobileViewport ? 'mobileOpen' : 'open'
|
|
162
|
+
}
|
|
163
|
+
exit="closed"
|
|
164
|
+
variants={ {
|
|
165
|
+
open: { width: secondarySidebarSize.width },
|
|
166
|
+
closed: { width: 0 },
|
|
167
|
+
mobileOpen: { width: '100vw' },
|
|
168
|
+
} }
|
|
169
|
+
transition={ defaultTransition }
|
|
170
|
+
>
|
|
171
|
+
<div
|
|
172
|
+
style={ {
|
|
173
|
+
position: 'absolute',
|
|
174
|
+
width: 'fit-content',
|
|
175
|
+
height: '100%',
|
|
176
|
+
right: 0,
|
|
177
|
+
} }
|
|
178
|
+
>
|
|
179
|
+
{ secondarySidebarResizeListener }
|
|
180
|
+
{ secondarySidebar }
|
|
181
|
+
</div>
|
|
182
|
+
</NavigableRegion>
|
|
183
|
+
) }
|
|
184
|
+
</AnimatePresence>
|
|
145
185
|
{ !! notices && (
|
|
146
186
|
<div className="interface-interface-skeleton__notices">
|
|
147
187
|
{ notices }
|
|
@@ -102,16 +102,15 @@ html.interface-interface-skeleton__html-container {
|
|
|
102
102
|
position: absolute;
|
|
103
103
|
z-index: z-index(".interface-interface-skeleton__sidebar");
|
|
104
104
|
top: 0;
|
|
105
|
-
right: 0;
|
|
106
|
-
bottom: 0;
|
|
107
105
|
left: 0;
|
|
106
|
+
bottom: 0;
|
|
108
107
|
background: $white;
|
|
109
108
|
color: $gray-900;
|
|
109
|
+
width: auto; // Keep the sidebar width flexible.
|
|
110
110
|
|
|
111
111
|
// On Mobile the header is fixed to keep HTML as scrollable.
|
|
112
112
|
@include break-medium() {
|
|
113
113
|
position: relative !important;
|
|
114
|
-
width: auto; // Keep the sidebar width flexible.
|
|
115
114
|
|
|
116
115
|
// Set this z-index only when the sidebar is opened. When it's closed, the
|
|
117
116
|
// button to open the sidebar that is shown when navigating regions needs to
|
|
@@ -131,6 +130,7 @@ html.interface-interface-skeleton__html-container {
|
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
.interface-interface-skeleton__secondary-sidebar {
|
|
133
|
+
right: 0;
|
|
134
134
|
@include break-medium() {
|
|
135
135
|
border-right: $border-width solid $gray-200;
|
|
136
136
|
}
|
|
@@ -15,7 +15,7 @@ The content to be displayed for the pinned items. Most of the time, a button wit
|
|
|
15
15
|
|
|
16
16
|
### scope
|
|
17
17
|
|
|
18
|
-
The scope of the pinned items area e.g: "core
|
|
18
|
+
The scope of the pinned items area e.g: "core", "myplugin/custom-screen-a",
|
|
19
19
|
|
|
20
20
|
- Type: `String`
|
|
21
21
|
- Required: Yes
|
|
@@ -28,7 +28,7 @@ A slot that renders the pinned items.
|
|
|
28
28
|
|
|
29
29
|
### scope
|
|
30
30
|
|
|
31
|
-
The scope of the pinned items area e.g: "core
|
|
31
|
+
The scope of the pinned items area e.g: "core", "myplugin/custom-screen-a",
|
|
32
32
|
|
|
33
33
|
- Type: `String`
|
|
34
34
|
- Required: Yes
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
&[aria-controls="edit-post:document"],
|
|
11
11
|
&[aria-controls="edit-post:block"],
|
|
12
12
|
&[aria-controls="edit-site:template"],
|
|
13
|
-
&[aria-controls="edit-site:block-inspector"]
|
|
14
|
-
&[aria-controls="edit-site:global-styles"] {
|
|
13
|
+
&[aria-controls="edit-site:block-inspector"] {
|
|
15
14
|
display: flex;
|
|
16
15
|
}
|
|
17
16
|
|
package/src/store/actions.js
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
import deprecated from '@wordpress/deprecated';
|
|
5
5
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
normalizeComplementaryAreaScope,
|
|
12
|
+
normalizeComplementaryAreaName,
|
|
13
|
+
} from './deprecated';
|
|
14
|
+
|
|
7
15
|
/**
|
|
8
16
|
* Set a default complementary area.
|
|
9
17
|
*
|
|
@@ -12,11 +20,15 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
12
20
|
*
|
|
13
21
|
* @return {Object} Action object.
|
|
14
22
|
*/
|
|
15
|
-
export const setDefaultComplementaryArea = ( scope, area ) =>
|
|
16
|
-
|
|
17
|
-
scope,
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
export const setDefaultComplementaryArea = ( scope, area ) => {
|
|
24
|
+
scope = normalizeComplementaryAreaScope( scope );
|
|
25
|
+
area = normalizeComplementaryAreaName( scope, area );
|
|
26
|
+
return {
|
|
27
|
+
type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
|
|
28
|
+
scope,
|
|
29
|
+
area,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
20
32
|
|
|
21
33
|
/**
|
|
22
34
|
* Enable the complementary area.
|
|
@@ -31,6 +43,8 @@ export const enableComplementaryArea =
|
|
|
31
43
|
if ( ! area ) {
|
|
32
44
|
return;
|
|
33
45
|
}
|
|
46
|
+
scope = normalizeComplementaryAreaScope( scope );
|
|
47
|
+
area = normalizeComplementaryAreaName( scope, area );
|
|
34
48
|
|
|
35
49
|
const isComplementaryAreaVisible = registry
|
|
36
50
|
.select( preferencesStore )
|
|
@@ -57,6 +71,7 @@ export const enableComplementaryArea =
|
|
|
57
71
|
export const disableComplementaryArea =
|
|
58
72
|
( scope ) =>
|
|
59
73
|
( { registry } ) => {
|
|
74
|
+
scope = normalizeComplementaryAreaScope( scope );
|
|
60
75
|
const isComplementaryAreaVisible = registry
|
|
61
76
|
.select( preferencesStore )
|
|
62
77
|
.get( scope, 'isComplementaryAreaVisible' );
|
|
@@ -84,6 +99,8 @@ export const pinItem =
|
|
|
84
99
|
return;
|
|
85
100
|
}
|
|
86
101
|
|
|
102
|
+
scope = normalizeComplementaryAreaScope( scope );
|
|
103
|
+
item = normalizeComplementaryAreaName( scope, item );
|
|
87
104
|
const pinnedItems = registry
|
|
88
105
|
.select( preferencesStore )
|
|
89
106
|
.get( scope, 'pinnedItems' );
|
|
@@ -113,6 +130,8 @@ export const unpinItem =
|
|
|
113
130
|
return;
|
|
114
131
|
}
|
|
115
132
|
|
|
133
|
+
scope = normalizeComplementaryAreaScope( scope );
|
|
134
|
+
item = normalizeComplementaryAreaName( scope, item );
|
|
116
135
|
const pinnedItems = registry
|
|
117
136
|
.select( preferencesStore )
|
|
118
137
|
.get( scope, 'pinnedItems' );
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import deprecated from '@wordpress/deprecated';
|
|
5
|
+
|
|
6
|
+
export function normalizeComplementaryAreaScope( scope ) {
|
|
7
|
+
if ( [ 'core/edit-post', 'core/edit-site' ].includes( scope ) ) {
|
|
8
|
+
deprecated( `${ scope } interface scope`, {
|
|
9
|
+
alternative: 'core interface scope',
|
|
10
|
+
hint: 'core/edit-post and core/edit-site are merging.',
|
|
11
|
+
version: '6.6',
|
|
12
|
+
} );
|
|
13
|
+
return 'core';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return scope;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function normalizeComplementaryAreaName( scope, name ) {
|
|
20
|
+
if ( scope === 'core' && name === 'edit-site/template' ) {
|
|
21
|
+
deprecated( `edit-site/template sidebar`, {
|
|
22
|
+
alternative: 'edit-post/document',
|
|
23
|
+
version: '6.6',
|
|
24
|
+
} );
|
|
25
|
+
return 'edit-post/document';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ( scope === 'core' && name === 'edit-site/block-inspector' ) {
|
|
29
|
+
deprecated( `edit-site/block-inspector sidebar`, {
|
|
30
|
+
alternative: 'edit-post/block',
|
|
31
|
+
version: '6.6',
|
|
32
|
+
} );
|
|
33
|
+
return 'edit-post/block';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return name;
|
|
37
|
+
}
|
package/src/store/selectors.js
CHANGED
|
@@ -5,6 +5,14 @@ import { createRegistrySelector } from '@wordpress/data';
|
|
|
5
5
|
import deprecated from '@wordpress/deprecated';
|
|
6
6
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
normalizeComplementaryAreaScope,
|
|
13
|
+
normalizeComplementaryAreaName,
|
|
14
|
+
} from './deprecated';
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* Returns the complementary area that is active in a given scope.
|
|
10
18
|
*
|
|
@@ -15,6 +23,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
15
23
|
*/
|
|
16
24
|
export const getActiveComplementaryArea = createRegistrySelector(
|
|
17
25
|
( select ) => ( state, scope ) => {
|
|
26
|
+
scope = normalizeComplementaryAreaScope( scope );
|
|
18
27
|
const isComplementaryAreaVisible = select( preferencesStore ).get(
|
|
19
28
|
scope,
|
|
20
29
|
'isComplementaryAreaVisible'
|
|
@@ -38,6 +47,7 @@ export const getActiveComplementaryArea = createRegistrySelector(
|
|
|
38
47
|
|
|
39
48
|
export const isComplementaryAreaLoading = createRegistrySelector(
|
|
40
49
|
( select ) => ( state, scope ) => {
|
|
50
|
+
scope = normalizeComplementaryAreaScope( scope );
|
|
41
51
|
const isVisible = select( preferencesStore ).get(
|
|
42
52
|
scope,
|
|
43
53
|
'isComplementaryAreaVisible'
|
|
@@ -59,6 +69,8 @@ export const isComplementaryAreaLoading = createRegistrySelector(
|
|
|
59
69
|
*/
|
|
60
70
|
export const isItemPinned = createRegistrySelector(
|
|
61
71
|
( select ) => ( state, scope, item ) => {
|
|
72
|
+
scope = normalizeComplementaryAreaScope( scope );
|
|
73
|
+
item = normalizeComplementaryAreaName( scope, item );
|
|
62
74
|
const pinnedItems = select( preferencesStore ).get(
|
|
63
75
|
scope,
|
|
64
76
|
'pinnedItems'
|