8.3.0 • Published 14 days ago

@wordpress/interface v8.3.0

Weekly downloads
5,240
License
GPL-2.0-or-later
Repository
github
Last release
14 days ago

(Experimental) Interface

The Interface Package contains the basis to start a new WordPress screen as Edit Post or Edit Site. The package offers a data store and a set of components. The store is useful to contain common data required by a screen (e.g., active areas). The information is persisted across screen reloads. The components allow one to implement functionality like a sidebar or menu items. Third-party plugins can extend them by default.

Installation

Install the module

npm install @wordpress/interface --save

This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for such language features and APIs, you should include the polyfill shipped in @wordpress/babel-preset-default in your code.

API Usage

Complementary Areas

This component was named after a complementary landmark – a supporting section of the document, designed to be complementary to the main content at a similar level in the DOM hierarchy, but remains meaningful when separated from the main content.

ComplementaryArea and ComplementaryArea.Slot form a slot fill pair to render complementary areas. Multiple ComplementaryArea components representing different complementary areas may be rendered at the same time, but only one appears on the slot depending on which complementary area is enabled.

It is possible to control which complementary is enabled by using the store:

Below are some examples of how to control the active complementary area using the store:

wp.data
	.select( 'core/interface' )
	.getActiveComplementaryArea( 'core' );
// -> "edit-post/document"

wp.data
	.dispatch( 'core/interface' )
	.enableComplementaryArea( 'core', 'edit-post/block' );

wp.data
	.select( 'core/interface' )
	.getActiveComplementaryArea( 'core' );
// -> "edit-post/block"

wp.data
	.dispatch( 'core/interface' )
	.disableComplementaryArea( 'core' );

wp.data
	.select( 'core/interface' )
	.getActiveComplementaryArea( 'core' );
// -> null

Pinned Items

PinnedItems and PinnedItems.Slot form a slot fill pair to render pinned items (or areas) that act as a list of favorites similar to browser extensions listed in the Chrome Menu.

Example usage: ComplementaryArea component makes use of PinnedItems and automatically adds a pinned item for the complementary areas marked as a favorite.

wp.data.select( 'core/interface' ).isItemPinned( 'core', 'edit-post-block-patterns/block-patterns-sidebar' );
// -> false

wp.data.dispatch( 'core/interface' ).pinItem( 'core', 'edit-post-block-patterns/block-patterns-sidebar' );

wp.data.select( 'core/interface' ).isItemPinned( 'core', 'edit-post-block-patterns/block-patterns-sidebar' );
// -> true

wp.data.dispatch( 'core/interface' ).unpinItem( 'core', 'edit-post-block-patterns/block-patterns-sidebar' );

wp.data.select( 'core/interface' ).isItemPinned( 'core', 'edit-post-block-patterns/block-patterns-sidebar' ); -> false

Preferences

The interface package provides some helpers for implementing editor preferences.

Features

Features are boolean values used for toggling specific editor features on or off.

Set the default values for any features on editor initialization:

import { dispatch } from '@wordpress/data';
import { store as interfaceStore } from '@wordpress/interface';

function initialize() {
	// ...

	dispatch( interfaceStore ).setFeatureDefaults(
		'namespace/editor-or-plugin-name',
		{
			myFeatureName: true,
		}
	);

	// ...
}

Use the toggleFeature action and the isFeatureActive selector to toggle features within your app:

wp.data
	.select( 'core/interface' )
	.isFeatureActive( 'namespace/editor-or-plugin-name', 'myFeatureName' ); // true
wp.data
	.dispatch( 'core/interface' )
	.toggleFeature( 'namespace/editor-or-plugin-name', 'myFeatureName' );
wp.data
	.select( 'core/interface' )
	.isFeatureActive( 'namespace/editor-or-plugin-name', 'myFeatureName' ); // false

Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main contributor guide.

8.3.0

14 days ago

8.2.0

28 days ago

6.8.11

1 month ago

8.1.0

1 month ago

6.8.10

2 months ago

6.8.9

2 months ago

6.8.8

2 months ago

8.0.0

2 months ago

6.8.7

2 months ago

7.0.0

2 months ago

6.8.6

2 months ago

6.8.3

3 months ago

6.8.5

3 months ago

6.8.4

3 months ago

6.9.0

3 months ago

6.7.0

4 months ago

6.8.1

3 months ago

6.8.0

3 months ago

6.8.2

3 months ago

6.6.0

4 months ago

6.5.0

5 months ago

6.4.0

5 months ago

6.0.3

6 months ago

6.0.2

6 months ago

6.1.0

6 months ago

6.2.0

6 months ago

6.3.0

6 months ago

6.0.1

7 months ago

6.0.0

7 months ago

5.35.0

7 months ago

5.34.0

8 months ago

5.33.0

8 months ago

4.5.7

9 months ago

5.28.6

9 months ago

5.32.0

9 months ago

5.31.0

9 months ago

5.28.5

10 months ago

5.30.0

10 months ago

5.28.4

10 months ago

5.28.3

10 months ago

5.29.0

10 months ago

5.28.2

10 months ago

5.28.1

11 months ago

5.28.0

11 months ago

5.27.0

11 months ago

5.26.0

11 months ago

5.19.14

12 months ago

5.25.0

1 year ago

5.15.0

1 year ago

5.16.0

1 year ago

5.17.1

1 year ago

5.17.0

1 year ago

5.20.1

1 year ago

5.20.0

1 year ago

5.18.0

1 year ago

5.21.0

1 year ago

5.19.9

1 year ago

5.19.8

1 year ago

5.19.7

1 year ago

5.19.6

1 year ago

5.19.5

1 year ago

5.19.4

1 year ago

5.19.3

1 year ago

5.19.2

1 year ago

5.19.1

1 year ago

5.19.0

1 year ago

5.22.0

1 year ago

5.3.9

1 year ago

5.12.11

1 year ago

5.12.12

1 year ago

5.12.10

1 year ago

5.12.9

1 year ago

5.12.8

1 year ago

5.12.7

1 year ago

5.12.6

1 year ago

5.12.5

1 year ago

5.12.4

1 year ago

5.23.0

1 year ago

5.24.0

1 year ago

5.13.0

1 year ago

5.19.11

1 year ago

5.19.10

1 year ago

5.19.13

1 year ago

5.19.12

1 year ago

5.14.0

1 year ago

5.12.3

1 year ago

5.12.2

1 year ago

5.11.0

2 years ago

5.12.1

2 years ago

5.12.0

2 years ago

5.10.0

2 years ago

5.3.8

2 years ago

5.8.0

2 years ago

5.9.0

2 years ago

5.5.0

2 years ago

5.6.0

2 years ago

5.3.7

2 years ago

5.3.6

2 years ago

5.7.0

2 years ago

5.3.3

2 years ago

5.3.2

2 years ago

5.3.1

2 years ago

5.3.0

2 years ago

4.18.0

2 years ago

4.9.0

3 years ago

4.5.4

3 years ago

4.5.3

3 years ago

4.5.6

2 years ago

4.5.5

3 years ago

4.21.0

2 years ago

4.4.0

3 years ago

4.14.0

2 years ago

4.10.0

3 years ago

5.4.0

2 years ago

5.0.0

2 years ago

4.17.0

2 years ago

4.8.0

3 years ago

4.20.0

2 years ago

4.3.1

3 years ago

4.7.0

3 years ago

4.3.0

3 years ago

4.13.0

2 years ago

4.16.3

2 years ago

4.16.4

2 years ago

4.16.5

2 years ago

4.16.6

2 years ago

5.1.0

2 years ago

4.16.0

2 years ago

4.16.1

2 years ago

4.16.2

2 years ago

4.16.7

2 years ago

4.6.0

3 years ago

4.12.0

2 years ago

4.19.0

2 years ago

5.2.0

2 years ago

4.15.0

2 years ago

4.5.0

3 years ago

4.5.2

3 years ago

4.5.1

3 years ago

4.11.0

2 years ago

5.3.5

2 years ago

5.3.4

2 years ago

4.1.8

3 years ago

4.1.7

3 years ago

4.1.9

3 years ago

4.2.3

3 years ago

4.2.2

3 years ago

4.2.1

3 years ago

4.2.0

3 years ago

4.1.10

3 years ago

4.1.11

3 years ago

4.1.16

3 years ago

4.1.17

3 years ago

4.1.18

3 years ago

4.1.12

3 years ago

4.1.13

3 years ago

4.1.14

3 years ago

4.1.15

3 years ago

4.1.4

3 years ago

4.1.3

3 years ago

4.1.6

3 years ago

4.1.5

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

1.0.7

3 years ago

0.7.8

3 years ago

0.10.9

3 years ago

4.1.0

3 years ago

3.1.12

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.2.0

3 years ago

3.1.11

3 years ago

3.1.10

3 years ago

3.1.8

3 years ago

3.1.7

3 years ago

3.1.6

3 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

2.0.2

4 years ago

3.0.0

4 years ago

3.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.0-next.1

4 years ago

1.0.5

4 years ago

0.10.8

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

0.10.7

4 years ago

1.0.0

4 years ago

1.0.0-next.0

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.10.6

4 years ago

0.10.5

4 years ago

0.10.4

4 years ago

0.10.3

4 years ago

0.10.2

4 years ago

0.7.7

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.6

4 years ago

0.7.5

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.5.1-rc.0

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago