@wordpress/interface 5.32.0 → 5.34.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 +59 -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 +61 -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 +14 -5
- package/build-style/style.css +14 -5
- package/package.json +14 -14
- package/src/components/complementary-area/README.md +2 -2
- package/src/components/complementary-area/index.js +140 -58
- package/src/components/complementary-area/style.scss +6 -0
- 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 +52 -10
- package/src/components/interface-skeleton/style.scss +6 -5
- package/src/components/pinned-items/README.md +2 -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,78 @@ 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
|
+
className="interface-complementary-area__fill"
|
|
96
|
+
>
|
|
97
|
+
<div
|
|
98
|
+
id={ id }
|
|
99
|
+
className={ className }
|
|
100
|
+
style={ {
|
|
101
|
+
width: isMobileViewport
|
|
102
|
+
? '100vw'
|
|
103
|
+
: SIDEBAR_WIDTH,
|
|
104
|
+
} }
|
|
105
|
+
>
|
|
106
|
+
{ children }
|
|
107
|
+
</div>
|
|
108
|
+
</motion.div>
|
|
109
|
+
) }
|
|
110
|
+
</AnimatePresence>
|
|
37
111
|
</Fill>
|
|
38
112
|
);
|
|
39
113
|
}
|
|
@@ -110,6 +184,11 @@ function ComplementaryArea( {
|
|
|
110
184
|
toggleShortcut,
|
|
111
185
|
isActiveByDefault,
|
|
112
186
|
} ) {
|
|
187
|
+
// This state is used to delay the rendering of the Fill
|
|
188
|
+
// until the initial effect runs.
|
|
189
|
+
// This prevents the animation from running on mount if
|
|
190
|
+
// the complementary area is active by default.
|
|
191
|
+
const [ isReady, setIsReady ] = useState( false );
|
|
113
192
|
const {
|
|
114
193
|
isLoading,
|
|
115
194
|
isActive,
|
|
@@ -163,6 +242,7 @@ function ComplementaryArea( {
|
|
|
163
242
|
} else if ( activeArea === undefined && isSmall ) {
|
|
164
243
|
disableComplementaryArea( scope, identifier );
|
|
165
244
|
}
|
|
245
|
+
setIsReady( true );
|
|
166
246
|
}, [
|
|
167
247
|
activeArea,
|
|
168
248
|
isActiveByDefault,
|
|
@@ -173,6 +253,10 @@ function ComplementaryArea( {
|
|
|
173
253
|
disableComplementaryArea,
|
|
174
254
|
] );
|
|
175
255
|
|
|
256
|
+
if ( ! isReady ) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
176
260
|
return (
|
|
177
261
|
<>
|
|
178
262
|
{ isPinnable && (
|
|
@@ -204,59 +288,57 @@ function ComplementaryArea( {
|
|
|
204
288
|
{ title }
|
|
205
289
|
</ComplementaryAreaMoreMenuItem>
|
|
206
290
|
) }
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
291
|
+
<ComplementaryAreaFill
|
|
292
|
+
activeArea={ activeArea }
|
|
293
|
+
isActive={ isActive }
|
|
294
|
+
className={ classnames(
|
|
295
|
+
'interface-complementary-area',
|
|
296
|
+
className
|
|
297
|
+
) }
|
|
298
|
+
scope={ scope }
|
|
299
|
+
id={ identifier.replace( '/', ':' ) }
|
|
300
|
+
>
|
|
301
|
+
<ComplementaryAreaHeader
|
|
302
|
+
className={ headerClassName }
|
|
303
|
+
closeLabel={ closeLabel }
|
|
304
|
+
onClose={ () => disableComplementaryArea( scope ) }
|
|
305
|
+
smallScreenTitle={ smallScreenTitle }
|
|
306
|
+
toggleButtonProps={ {
|
|
307
|
+
label: closeLabel,
|
|
308
|
+
shortcut: toggleShortcut,
|
|
309
|
+
scope,
|
|
310
|
+
identifier,
|
|
311
|
+
} }
|
|
215
312
|
>
|
|
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
|
-
) }
|
|
313
|
+
{ header || (
|
|
314
|
+
<>
|
|
315
|
+
<h2 className="interface-complementary-area-header__title">
|
|
316
|
+
{ title }
|
|
317
|
+
</h2>
|
|
318
|
+
{ isPinnable && (
|
|
319
|
+
<Button
|
|
320
|
+
className="interface-complementary-area__pin-unpin-item"
|
|
321
|
+
icon={ isPinned ? starFilled : starEmpty }
|
|
322
|
+
label={
|
|
323
|
+
isPinned
|
|
324
|
+
? __( 'Unpin from toolbar' )
|
|
325
|
+
: __( 'Pin to toolbar' )
|
|
326
|
+
}
|
|
327
|
+
onClick={ () =>
|
|
328
|
+
( isPinned ? unpinItem : pinItem )(
|
|
329
|
+
scope,
|
|
330
|
+
identifier
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
isPressed={ isPinned }
|
|
334
|
+
aria-expanded={ isPinned }
|
|
335
|
+
/>
|
|
336
|
+
) }
|
|
337
|
+
</>
|
|
338
|
+
) }
|
|
339
|
+
</ComplementaryAreaHeader>
|
|
340
|
+
<Panel className={ panelClassName }>{ children }</Panel>
|
|
341
|
+
</ComplementaryAreaFill>
|
|
260
342
|
</>
|
|
261
343
|
);
|
|
262
344
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
.interface-complementary-area {
|
|
2
2
|
background: $white;
|
|
3
3
|
color: $gray-900;
|
|
4
|
+
height: 100%;
|
|
5
|
+
overflow: auto;
|
|
4
6
|
|
|
5
7
|
@include break-small() {
|
|
6
8
|
-webkit-overflow-scrolling: touch;
|
|
@@ -72,3 +74,7 @@
|
|
|
72
74
|
left: auto;
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
|
|
78
|
+
.interface-complementary-area__fill {
|
|
79
|
+
height: 100%;
|
|
80
|
+
}
|
|
@@ -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,40 @@ 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: isMobileViewport
|
|
175
|
+
? '100vw'
|
|
176
|
+
: 'fit-content',
|
|
177
|
+
height: '100%',
|
|
178
|
+
right: 0,
|
|
179
|
+
} }
|
|
180
|
+
>
|
|
181
|
+
{ secondarySidebarResizeListener }
|
|
182
|
+
{ secondarySidebar }
|
|
183
|
+
</div>
|
|
184
|
+
</NavigableRegion>
|
|
185
|
+
) }
|
|
186
|
+
</AnimatePresence>
|
|
145
187
|
{ !! notices && (
|
|
146
188
|
<div className="interface-interface-skeleton__notices">
|
|
147
189
|
{ notices }
|
|
@@ -43,6 +43,7 @@ html.interface-interface-skeleton__html-container {
|
|
|
43
43
|
@include editor-left(".interface-interface-skeleton");
|
|
44
44
|
|
|
45
45
|
.interface-interface-skeleton__body {
|
|
46
|
+
position: relative;
|
|
46
47
|
flex-grow: 1;
|
|
47
48
|
display: flex;
|
|
48
49
|
|
|
@@ -102,20 +103,19 @@ html.interface-interface-skeleton__html-container {
|
|
|
102
103
|
position: absolute;
|
|
103
104
|
z-index: z-index(".interface-interface-skeleton__sidebar");
|
|
104
105
|
top: 0;
|
|
105
|
-
right: 0;
|
|
106
|
-
bottom: 0;
|
|
107
106
|
left: 0;
|
|
107
|
+
bottom: 0;
|
|
108
108
|
background: $white;
|
|
109
109
|
color: $gray-900;
|
|
110
|
+
width: auto; // Keep the sidebar width flexible.
|
|
110
111
|
|
|
111
112
|
// On Mobile the header is fixed to keep HTML as scrollable.
|
|
112
113
|
@include break-medium() {
|
|
113
114
|
position: relative !important;
|
|
114
|
-
width: auto; // Keep the sidebar width flexible.
|
|
115
115
|
|
|
116
116
|
// Set this z-index only when the sidebar is opened. When it's closed, the
|
|
117
117
|
// button to open the sidebar that is shown when navigating regions needs to
|
|
118
|
-
// be above the footer. See `
|
|
118
|
+
// be above the footer. See `editor-layout__toggle-sidebar-panel`.
|
|
119
119
|
.is-sidebar-opened & {
|
|
120
120
|
z-index: z-index(".interface-interface-skeleton__sidebar {greater than small}");
|
|
121
121
|
}
|
|
@@ -123,7 +123,7 @@ html.interface-interface-skeleton__html-container {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
.interface-interface-skeleton__sidebar {
|
|
126
|
-
overflow:
|
|
126
|
+
overflow: hidden;
|
|
127
127
|
|
|
128
128
|
@include break-medium() {
|
|
129
129
|
border-left: $border-width solid $gray-200;
|
|
@@ -131,6 +131,7 @@ html.interface-interface-skeleton__html-container {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
.interface-interface-skeleton__secondary-sidebar {
|
|
134
|
+
right: 0;
|
|
134
135
|
@include break-medium() {
|
|
135
136
|
border-right: $border-width solid $gray-200;
|
|
136
137
|
}
|
|
@@ -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
|
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'
|