diff --git a/package-lock.json b/package-lock.json index 77413a70d7913..090b671396589 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16644,6 +16644,7 @@ "@wordpress/autop": "file:packages/autop", "@wordpress/blob": "file:packages/blob", "@wordpress/block-serialization-default-parser": "file:packages/block-serialization-default-parser", + "@wordpress/components": "file:packages/components", "@wordpress/data": "file:packages/data", "@wordpress/deprecated": "file:packages/deprecated", "@wordpress/dom": "file:packages/dom", @@ -30558,7 +30559,7 @@ "css.escape": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", - "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "integrity": "sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=", "dev": true }, "cssesc": { @@ -43407,7 +43408,7 @@ "lz-string": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz", - "integrity": "sha512-0ckx7ZHRPqb0oUm8zNr+90mtf9DQB60H1wMCjBtfi62Kl3a7JbHob6gA2bC+xRvZoOL+1hzUK8jeuEIQE8svEQ==", + "integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=", "dev": true }, "macos-release": { diff --git a/packages/blocks/package.json b/packages/blocks/package.json index e7562b9158a8b..baf9702cf6a43 100644 --- a/packages/blocks/package.json +++ b/packages/blocks/package.json @@ -32,6 +32,7 @@ "@wordpress/autop": "file:../autop", "@wordpress/blob": "file:../blob", "@wordpress/block-serialization-default-parser": "file:../block-serialization-default-parser", + "@wordpress/components": "file:../components", "@wordpress/data": "file:../data", "@wordpress/deprecated": "file:../deprecated", "@wordpress/dom": "file:../dom", diff --git a/packages/blocks/src/api/categories.js b/packages/blocks/src/api/categories.ts similarity index 84% rename from packages/blocks/src/api/categories.js rename to packages/blocks/src/api/categories.ts index f73331066fed9..cf10847c47838 100644 --- a/packages/blocks/src/api/categories.js +++ b/packages/blocks/src/api/categories.ts @@ -2,13 +2,18 @@ * WordPress dependencies */ import { dispatch, select } from '@wordpress/data'; +import { Dashicon } from '@wordpress/components'; /** * Internal dependencies */ import { store as blocksStore } from '../store'; -/** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */ +export interface WPBlockCategory { + slug: string; + title: string; + icon?: JSX.Element | Dashicon.Icon | null | undefined; +} /** * Returns all the block categories. @@ -18,7 +23,7 @@ import { store as blocksStore } from '../store'; * * @return {WPBlockCategory[]} Block categories. */ -export function getCategories() { +export function getCategories(): WPBlockCategory[] { return select( blocksStore ).getCategories(); } @@ -57,7 +62,7 @@ export function getCategories() { * }; * ``` */ -export function setCategories( categories ) { +export function setCategories( categories: readonly WPBlockCategory[] ): void { dispatch( blocksStore ).setCategories( categories ); } @@ -87,6 +92,9 @@ export function setCategories( categories ) { * }; * ``` */ -export function updateCategory( slug, category ) { +export function updateCategory( + slug: string, + category: Partial< WPBlockCategory > +): void { dispatch( blocksStore ).updateCategory( slug, category ); }