@wordpress/interface 9.37.0 → 10.0.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 +24 -0
- package/build/components/action-item/index.cjs +17 -41
- package/build/components/action-item/index.cjs.map +2 -2
- package/build/components/complementary-area/index.cjs +34 -28
- package/build/components/complementary-area/index.cjs.map +3 -3
- package/build/components/complementary-area-header/index.cjs.map +2 -2
- package/build/components/complementary-area-more-menu-item/index.cjs +52 -24
- package/build/components/complementary-area-more-menu-item/index.cjs.map +2 -2
- package/build/components/complementary-area-toggle/index.cjs.map +2 -2
- package/build/components/fullscreen-mode/index.cjs.map +2 -2
- package/build/components/interface-skeleton/index.cjs +5 -11
- package/build/components/interface-skeleton/index.cjs.map +2 -2
- package/build/components/pinned-items/index.cjs.map +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/deprecated.cjs.map +2 -2
- package/build/store/index.cjs.map +2 -2
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/action-item/index.mjs +18 -42
- package/build-module/components/action-item/index.mjs.map +2 -2
- package/build-module/components/complementary-area/index.mjs +44 -29
- package/build-module/components/complementary-area/index.mjs.map +2 -2
- package/build-module/components/complementary-area-header/index.mjs.map +2 -2
- package/build-module/components/complementary-area-more-menu-item/index.mjs +47 -24
- package/build-module/components/complementary-area-more-menu-item/index.mjs.map +2 -2
- package/build-module/components/complementary-area-toggle/index.mjs.map +2 -2
- package/build-module/components/fullscreen-mode/index.mjs.map +2 -2
- package/build-module/components/interface-skeleton/index.mjs +6 -16
- package/build-module/components/interface-skeleton/index.mjs.map +2 -2
- package/build-module/components/pinned-items/index.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/deprecated.mjs.map +2 -2
- package/build-module/store/index.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/style-rtl.css +3 -2
- package/build-style/style.css +3 -2
- package/package.json +15 -15
- package/src/components/action-item/README.md +17 -10
- package/src/components/action-item/index.js +27 -48
- package/src/components/complementary-area/index.js +61 -49
- package/src/components/complementary-area/style.scss +1 -0
- package/src/components/complementary-area-header/index.js +0 -11
- package/src/components/complementary-area-more-menu-item/index.js +51 -31
- package/src/components/complementary-area-toggle/index.js +0 -7
- package/src/components/fullscreen-mode/index.js +0 -3
- package/src/components/fullscreen-mode/test/index.js +0 -6
- package/src/components/interface-skeleton/index.js +8 -19
- package/src/components/interface-skeleton/style.scss +2 -2
- package/src/components/pinned-items/index.js +0 -7
- package/src/store/actions.js +0 -7
- package/src/store/deprecated.js +0 -3
- package/src/store/index.js +0 -7
- package/src/store/reducer.js +0 -3
- package/src/store/selectors.js +0 -7
- package/src/store/test/actions.js +0 -7
- package/src/store/test/reducer.js +0 -3
- package/src/store/test/selectors.js +0 -3
|
@@ -1,75 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { MenuGroup, Button, Slot, Fill } from '@wordpress/components';
|
|
1
|
+
import { MenuGroup, MenuItem, Slot, Fill } from '@wordpress/components';
|
|
5
2
|
import { Children } from '@wordpress/element';
|
|
6
3
|
|
|
7
|
-
const noop = () => {};
|
|
8
|
-
|
|
9
4
|
function ActionItemSlot( {
|
|
10
5
|
name,
|
|
11
6
|
as: Component = MenuGroup,
|
|
12
7
|
fillProps = {},
|
|
13
|
-
|
|
8
|
+
children,
|
|
14
9
|
...props
|
|
15
10
|
} ) {
|
|
16
11
|
return (
|
|
17
|
-
<Slot
|
|
18
|
-
name={ name }
|
|
19
|
-
bubblesVirtually={ bubblesVirtually }
|
|
20
|
-
fillProps={ fillProps }
|
|
21
|
-
>
|
|
12
|
+
<Slot name={ name } fillProps={ fillProps }>
|
|
22
13
|
{ ( fills ) => {
|
|
23
|
-
|
|
14
|
+
// Each fill renders an array of its own, so flatten them into a
|
|
15
|
+
// single list before handing them over.
|
|
16
|
+
const items = Children.toArray( fills );
|
|
17
|
+
|
|
18
|
+
if ( ! items.length ) {
|
|
24
19
|
return null;
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// from pinnable plugin sidebars.
|
|
31
|
-
// @see https://github.com/WordPress/gutenberg/issues/14457
|
|
32
|
-
const initializedByPlugins = [];
|
|
33
|
-
Children.forEach(
|
|
34
|
-
fills,
|
|
35
|
-
( {
|
|
36
|
-
props: { __unstableExplicitMenuItem, __unstableTarget },
|
|
37
|
-
} ) => {
|
|
38
|
-
if ( __unstableTarget && __unstableExplicitMenuItem ) {
|
|
39
|
-
initializedByPlugins.push( __unstableTarget );
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
const children = Children.map( fills, ( child ) => {
|
|
44
|
-
if (
|
|
45
|
-
! child.props.__unstableExplicitMenuItem &&
|
|
46
|
-
initializedByPlugins.includes(
|
|
47
|
-
child.props.__unstableTarget
|
|
48
|
-
)
|
|
49
|
-
) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return child;
|
|
53
|
-
} );
|
|
22
|
+
if ( typeof children === 'function' ) {
|
|
23
|
+
return children( items );
|
|
24
|
+
}
|
|
54
25
|
|
|
55
|
-
return <Component { ...props }>{
|
|
26
|
+
return <Component { ...props }>{ items }</Component>;
|
|
56
27
|
} }
|
|
57
28
|
</Slot>
|
|
58
29
|
);
|
|
59
30
|
}
|
|
60
31
|
|
|
61
|
-
function ActionItem( { name, as
|
|
32
|
+
function ActionItem( { name, as, onClick, ...props } ) {
|
|
62
33
|
return (
|
|
63
34
|
<Fill name={ name }>
|
|
64
|
-
{ ( { onClick:
|
|
35
|
+
{ ( { as: slotAs = MenuItem, onClick: slotOnClick } ) => {
|
|
36
|
+
// The slot provides the component to render the item with, so
|
|
37
|
+
// that it fits the menu it ends up in, and an onClick handler,
|
|
38
|
+
// for example one that closes that menu. The `as` prop
|
|
39
|
+
// replaces the component. The `onClick` prop does not replace
|
|
40
|
+
// the handler: both run.
|
|
41
|
+
const Component = as ?? slotAs;
|
|
42
|
+
const handlers = [ onClick, slotOnClick ].filter( Boolean );
|
|
43
|
+
|
|
65
44
|
return (
|
|
66
45
|
<Component
|
|
67
46
|
onClick={
|
|
68
|
-
|
|
69
|
-
? ( ...args ) =>
|
|
70
|
-
(
|
|
71
|
-
|
|
72
|
-
|
|
47
|
+
handlers.length
|
|
48
|
+
? ( ...args ) =>
|
|
49
|
+
handlers.forEach( ( handler ) =>
|
|
50
|
+
handler( ...args )
|
|
51
|
+
)
|
|
73
52
|
: undefined
|
|
74
53
|
}
|
|
75
54
|
{ ...props }
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import {
|
|
10
3
|
Button,
|
|
11
4
|
Panel,
|
|
@@ -17,7 +10,13 @@ import {
|
|
|
17
10
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
18
11
|
import { __ } from '@wordpress/i18n';
|
|
19
12
|
import { check, starEmpty, starFilled } from '@wordpress/icons';
|
|
20
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
cloneElement,
|
|
15
|
+
isValidElement,
|
|
16
|
+
useEffect,
|
|
17
|
+
useRef,
|
|
18
|
+
useState,
|
|
19
|
+
} from '@wordpress/element';
|
|
21
20
|
import { store as viewportStore } from '@wordpress/viewport';
|
|
22
21
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
23
22
|
import {
|
|
@@ -26,12 +25,11 @@ import {
|
|
|
26
25
|
usePrevious,
|
|
27
26
|
} from '@wordpress/compose';
|
|
28
27
|
import { usePluginContext } from '@wordpress/plugins';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Internal dependencies
|
|
32
|
-
*/
|
|
33
28
|
import ComplementaryAreaHeader from '../complementary-area-header';
|
|
34
|
-
import
|
|
29
|
+
import {
|
|
30
|
+
DefaultComplementaryAreaMoreMenuItem,
|
|
31
|
+
useHasComplementaryAreaMenuItem,
|
|
32
|
+
} from '../complementary-area-more-menu-item';
|
|
35
33
|
import ComplementaryAreaToggle from '../complementary-area-toggle';
|
|
36
34
|
import PinnedItems from '../pinned-items';
|
|
37
35
|
import { store as interfaceStore } from '../../store';
|
|
@@ -42,13 +40,38 @@ function ComplementaryAreaSlot( { scope, ...props } ) {
|
|
|
42
40
|
return <Slot name={ `ComplementaryArea/${ scope }` } { ...props } />;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
const SIDEBAR_WIDTH = 280;
|
|
46
43
|
const variants = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
// `auto` leaves the width to the area's own stylesheet, so it stays in one
|
|
45
|
+
// place. framer-motion measures the element to animate, then restores
|
|
46
|
+
// `auto`.
|
|
47
|
+
open: { width: 'auto' },
|
|
48
|
+
// Resolved with the `custom` value passed to `AnimatePresence`, which is
|
|
49
|
+
// the only way an already removed element can be given a fresh transition.
|
|
50
|
+
closed: ( transition ) => ( { width: 0, transition } ),
|
|
50
51
|
};
|
|
51
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Renders the complementary area container, replacing the default `div` with
|
|
55
|
+
* the element given via the `render` prop.
|
|
56
|
+
*
|
|
57
|
+
* `className` and `style` are composed rather than overwritten, since the
|
|
58
|
+
* container is also the scroll container for the sidebar.
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} [render] Replacement element.
|
|
61
|
+
* @param {Object} props Props for the container.
|
|
62
|
+
*/
|
|
63
|
+
function renderContainer( render, props ) {
|
|
64
|
+
if ( isValidElement( render ) ) {
|
|
65
|
+
return cloneElement( render, {
|
|
66
|
+
...props,
|
|
67
|
+
className: clsx( render.props.className, props.className ),
|
|
68
|
+
style: { ...render.props.style, ...props.style },
|
|
69
|
+
} );
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return <div { ...props } />;
|
|
73
|
+
}
|
|
74
|
+
|
|
52
75
|
function ComplementaryAreaFill( {
|
|
53
76
|
activeArea,
|
|
54
77
|
isActive,
|
|
@@ -56,27 +79,20 @@ function ComplementaryAreaFill( {
|
|
|
56
79
|
children,
|
|
57
80
|
className,
|
|
58
81
|
id,
|
|
82
|
+
render,
|
|
59
83
|
} ) {
|
|
60
84
|
const disableMotion = useReducedMotion();
|
|
61
85
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
62
|
-
//
|
|
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.
|
|
86
|
+
// Swapping one open area straight for another should not animate.
|
|
66
87
|
const previousActiveArea = usePrevious( activeArea );
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}, [ isActive ] );
|
|
88
|
+
const isSwitchingAreas =
|
|
89
|
+
!! previousActiveArea &&
|
|
90
|
+
!! activeArea &&
|
|
91
|
+
activeArea !== previousActiveArea;
|
|
72
92
|
const transition = {
|
|
73
93
|
type: 'tween',
|
|
74
94
|
duration:
|
|
75
|
-
disableMotion ||
|
|
76
|
-
isMobileViewport ||
|
|
77
|
-
( !! previousActiveArea &&
|
|
78
|
-
!! activeArea &&
|
|
79
|
-
activeArea !== previousActiveArea )
|
|
95
|
+
disableMotion || isMobileViewport || isSwitchingAreas
|
|
80
96
|
? 0
|
|
81
97
|
: ANIMATION_DURATION,
|
|
82
98
|
ease: [ 0.6, 0, 0.4, 1 ],
|
|
@@ -84,27 +100,21 @@ function ComplementaryAreaFill( {
|
|
|
84
100
|
|
|
85
101
|
return (
|
|
86
102
|
<Fill name={ `ComplementaryArea/${ scope }` }>
|
|
87
|
-
<AnimatePresence initial={ false }>
|
|
88
|
-
{
|
|
103
|
+
<AnimatePresence initial={ false } custom={ transition }>
|
|
104
|
+
{ isActive && (
|
|
89
105
|
<motion.div
|
|
90
106
|
variants={ variants }
|
|
91
107
|
initial="closed"
|
|
92
|
-
animate=
|
|
108
|
+
animate="open"
|
|
93
109
|
exit="closed"
|
|
94
110
|
transition={ transition }
|
|
95
111
|
className="interface-complementary-area__fill"
|
|
96
112
|
>
|
|
97
|
-
|
|
98
|
-
id
|
|
99
|
-
className
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
? '100vw'
|
|
103
|
-
: SIDEBAR_WIDTH,
|
|
104
|
-
} }
|
|
105
|
-
>
|
|
106
|
-
{ children }
|
|
107
|
-
</div>
|
|
113
|
+
{ renderContainer( render, {
|
|
114
|
+
id,
|
|
115
|
+
className,
|
|
116
|
+
children,
|
|
117
|
+
} ) }
|
|
108
118
|
</motion.div>
|
|
109
119
|
) }
|
|
110
120
|
</AnimatePresence>
|
|
@@ -177,6 +187,7 @@ function ComplementaryArea( {
|
|
|
177
187
|
icon: iconProp,
|
|
178
188
|
isPinnable = true,
|
|
179
189
|
panelClassName,
|
|
190
|
+
render,
|
|
180
191
|
scope,
|
|
181
192
|
name,
|
|
182
193
|
title,
|
|
@@ -224,6 +235,7 @@ function ComplementaryArea( {
|
|
|
224
235
|
[ identifier, scope ]
|
|
225
236
|
);
|
|
226
237
|
|
|
238
|
+
const hasMenuItem = useHasComplementaryAreaMenuItem( scope, name );
|
|
227
239
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
228
240
|
|
|
229
241
|
useAdjustComplementaryListener(
|
|
@@ -286,15 +298,15 @@ function ComplementaryArea( {
|
|
|
286
298
|
) }
|
|
287
299
|
</PinnedItems>
|
|
288
300
|
) }
|
|
289
|
-
{ name && isPinnable && (
|
|
290
|
-
<
|
|
301
|
+
{ name && isPinnable && ! hasMenuItem && (
|
|
302
|
+
<DefaultComplementaryAreaMoreMenuItem
|
|
291
303
|
target={ name }
|
|
292
304
|
scope={ scope }
|
|
293
305
|
icon={ icon }
|
|
294
306
|
identifier={ identifier }
|
|
295
307
|
>
|
|
296
308
|
{ title }
|
|
297
|
-
</
|
|
309
|
+
</DefaultComplementaryAreaMoreMenuItem>
|
|
298
310
|
) }
|
|
299
311
|
<ComplementaryAreaFill
|
|
300
312
|
activeArea={ activeArea }
|
|
@@ -302,6 +314,7 @@ function ComplementaryArea( {
|
|
|
302
314
|
className={ clsx( 'interface-complementary-area', className ) }
|
|
303
315
|
scope={ scope }
|
|
304
316
|
id={ identifier.replace( '/', ':' ) }
|
|
317
|
+
render={ render }
|
|
305
318
|
>
|
|
306
319
|
<ComplementaryAreaHeader
|
|
307
320
|
className={ headerClassName }
|
|
@@ -336,7 +349,6 @@ function ComplementaryArea( {
|
|
|
336
349
|
)
|
|
337
350
|
}
|
|
338
351
|
isPressed={ isPinned }
|
|
339
|
-
aria-expanded={ isPinned }
|
|
340
352
|
size="compact"
|
|
341
353
|
/>
|
|
342
354
|
) }
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { closeSmall } from '@wordpress/icons';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
3
|
import ComplementaryAreaToggle from '../complementary-area-toggle';
|
|
15
4
|
|
|
16
5
|
const ComplementaryAreaHeader = ( {
|
|
@@ -1,45 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import { observableMap, useObservableValue } from '@wordpress/compose';
|
|
2
|
+
import { useLayoutEffect } from '@wordpress/element';
|
|
4
3
|
import { check } from '@wordpress/icons';
|
|
5
|
-
import { MenuItem } from '@wordpress/components';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
4
|
import ComplementaryAreaToggle from '../complementary-area-toggle';
|
|
11
5
|
import ActionItem from '../action-item';
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// @see https://github.com/WordPress/gutenberg/issues/14457
|
|
17
|
-
__unstableExplicitMenuItem,
|
|
18
|
-
__unstableTarget,
|
|
19
|
-
...restProps
|
|
20
|
-
} ) => <MenuItem { ...restProps } />;
|
|
7
|
+
// How many more menu items are rendered for a complementary area, by
|
|
8
|
+
// `scope/target`.
|
|
9
|
+
const menuItems = observableMap();
|
|
21
10
|
|
|
22
|
-
export
|
|
11
|
+
export function useHasComplementaryAreaMenuItem( scope, target ) {
|
|
12
|
+
return !! useObservableValue( menuItems, `${ scope }/${ target }` );
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// The more menu item `ComplementaryArea` injects for every pinnable area. It is
|
|
16
|
+
// left out while a plugin renders one of its own for the same area.
|
|
17
|
+
// @see https://github.com/WordPress/gutenberg/issues/14457
|
|
18
|
+
export function DefaultComplementaryAreaMoreMenuItem( {
|
|
23
19
|
scope,
|
|
24
20
|
target,
|
|
25
|
-
__unstableExplicitMenuItem,
|
|
26
21
|
...props
|
|
27
22
|
} ) {
|
|
28
23
|
return (
|
|
29
24
|
<ComplementaryAreaToggle
|
|
30
|
-
as={ ( toggleProps ) =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
__unstableTarget={ `${ scope }/${ target }` }
|
|
37
|
-
as={ PluginsMenuItem }
|
|
38
|
-
name={ `${ scope }/plugin-more-menu` }
|
|
39
|
-
{ ...toggleProps }
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
} }
|
|
25
|
+
as={ ( toggleProps ) => (
|
|
26
|
+
<ActionItem
|
|
27
|
+
name={ `${ scope }/plugin-more-menu` }
|
|
28
|
+
{ ...toggleProps }
|
|
29
|
+
/>
|
|
30
|
+
) }
|
|
43
31
|
role="menuitemcheckbox"
|
|
44
32
|
selectedIcon={ check }
|
|
45
33
|
name={ target }
|
|
@@ -48,3 +36,35 @@ export default function ComplementaryAreaMoreMenuItem( {
|
|
|
48
36
|
/>
|
|
49
37
|
);
|
|
50
38
|
}
|
|
39
|
+
|
|
40
|
+
export default function ComplementaryAreaMoreMenuItem( {
|
|
41
|
+
scope,
|
|
42
|
+
target,
|
|
43
|
+
// Accepted so they don't leak to DOM elements. Registering the menu item is
|
|
44
|
+
// what keeps `ComplementaryArea` from injecting a second one.
|
|
45
|
+
__unstableExplicitMenuItem,
|
|
46
|
+
__unstableTarget,
|
|
47
|
+
...props
|
|
48
|
+
} ) {
|
|
49
|
+
useLayoutEffect( () => {
|
|
50
|
+
const key = `${ scope }/${ target }`;
|
|
51
|
+
menuItems.set( key, ( menuItems.get( key ) ?? 0 ) + 1 );
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
const count = menuItems.get( key ) - 1;
|
|
55
|
+
if ( count ) {
|
|
56
|
+
menuItems.set( key, count );
|
|
57
|
+
} else {
|
|
58
|
+
menuItems.delete( key );
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}, [ scope, target ] );
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<DefaultComplementaryAreaMoreMenuItem
|
|
65
|
+
scope={ scope }
|
|
66
|
+
target={ target }
|
|
67
|
+
{ ...props }
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { Button } from '@wordpress/components';
|
|
5
2
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
3
|
import { usePluginContext } from '@wordpress/plugins';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
4
|
import { store as interfaceStore } from '../../store';
|
|
12
5
|
|
|
13
6
|
/**
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { NavigableRegion } from '@wordpress/admin-ui';
|
|
10
3
|
import { forwardRef, useEffect } from '@wordpress/element';
|
|
11
4
|
import {
|
|
@@ -13,11 +6,7 @@ import {
|
|
|
13
6
|
__unstableAnimatePresence as AnimatePresence,
|
|
14
7
|
} from '@wordpress/components';
|
|
15
8
|
import { __, _x } from '@wordpress/i18n';
|
|
16
|
-
import {
|
|
17
|
-
useReducedMotion,
|
|
18
|
-
useViewportMatch,
|
|
19
|
-
useResizeObserver,
|
|
20
|
-
} from '@wordpress/compose';
|
|
9
|
+
import { useReducedMotion, useViewportMatch } from '@wordpress/compose';
|
|
21
10
|
|
|
22
11
|
const ANIMATION_DURATION = 0.25;
|
|
23
12
|
const commonTransition = {
|
|
@@ -82,8 +71,6 @@ function InterfaceSkeleton(
|
|
|
82
71
|
},
|
|
83
72
|
ref
|
|
84
73
|
) {
|
|
85
|
-
const [ secondarySidebarResizeListener, secondarySidebarSize ] =
|
|
86
|
-
useResizeObserver();
|
|
87
74
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
88
75
|
const disableMotion = useReducedMotion();
|
|
89
76
|
const defaultTransition = {
|
|
@@ -168,20 +155,23 @@ function InterfaceSkeleton(
|
|
|
168
155
|
initial="closed"
|
|
169
156
|
animate="open"
|
|
170
157
|
exit="closed"
|
|
158
|
+
// `auto` leaves the open width to the panel, so a
|
|
159
|
+
// sidebar that is already open on page load is
|
|
160
|
+
// at its full width on the first paint instead
|
|
161
|
+
// of animating there. framer-motion measures
|
|
162
|
+
// the element to animate, then restores `auto`.
|
|
171
163
|
variants={ {
|
|
172
|
-
open: { width:
|
|
164
|
+
open: { width: 'auto' },
|
|
173
165
|
closed: { width: 0 },
|
|
174
166
|
} }
|
|
175
167
|
transition={ defaultTransition }
|
|
176
168
|
>
|
|
177
169
|
<motion.div
|
|
178
170
|
style={ {
|
|
179
|
-
position: 'absolute',
|
|
180
171
|
width: isMobileViewport
|
|
181
172
|
? '100vw'
|
|
182
|
-
: '
|
|
173
|
+
: 'max-content',
|
|
183
174
|
height: '100%',
|
|
184
|
-
left: 0,
|
|
185
175
|
} }
|
|
186
176
|
variants={ {
|
|
187
177
|
open: { x: 0 },
|
|
@@ -189,7 +179,6 @@ function InterfaceSkeleton(
|
|
|
189
179
|
} }
|
|
190
180
|
transition={ defaultTransition }
|
|
191
181
|
>
|
|
192
|
-
{ secondarySidebarResizeListener }
|
|
193
182
|
{ secondarySidebar }
|
|
194
183
|
</motion.div>
|
|
195
184
|
</NavigableRegion>
|
|
@@ -75,7 +75,7 @@ html.interface-interface-skeleton__html-container {
|
|
|
75
75
|
// Footer overlap prevention
|
|
76
76
|
.has-footer & {
|
|
77
77
|
@include break-medium() {
|
|
78
|
-
padding-bottom:
|
|
78
|
+
padding-bottom: calc(var(--wpds-dimension-size-md) + #{$border-width});
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -174,7 +174,7 @@ html.interface-interface-skeleton__html-container {
|
|
|
174
174
|
z-index: z-index(".edit-post-layout__footer");
|
|
175
175
|
display: flex;
|
|
176
176
|
background: $white;
|
|
177
|
-
height:
|
|
177
|
+
height: var(--wpds-dimension-size-md);
|
|
178
178
|
align-items: center;
|
|
179
179
|
font-size: $default-font-size;
|
|
180
180
|
padding: 0 ($grid-unit-15 + 6px);
|
package/src/store/actions.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import deprecated from '@wordpress/deprecated';
|
|
5
2
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
3
|
import {
|
|
11
4
|
normalizeComplementaryAreaScope,
|
|
12
5
|
normalizeComplementaryAreaName,
|
package/src/store/deprecated.js
CHANGED
package/src/store/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { createReduxStore, register } from '@wordpress/data';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
2
|
import * as actions from './actions';
|
|
10
3
|
import * as selectors from './selectors';
|
|
11
4
|
import reducer from './reducer';
|
package/src/store/reducer.js
CHANGED
package/src/store/selectors.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { createRegistrySelector } from '@wordpress/data';
|
|
5
2
|
import deprecated from '@wordpress/deprecated';
|
|
6
3
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
4
|
import {
|
|
12
5
|
normalizeComplementaryAreaScope,
|
|
13
6
|
normalizeComplementaryAreaName,
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { createRegistry } from '@wordpress/data';
|
|
5
2
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
3
|
import { store as interfaceStore } from '../';
|
|
11
4
|
|
|
12
5
|
function createRegistryWithStores() {
|