Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update misc types and revert WPCompleter export from components #67599

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/block-editor/src/autocompleters/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import { orderInserterBlockItems } from '../utils/order-inserter-block-items';
const noop = () => {};
const SHOWN_BLOCK_TYPES = 9;

/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */

/**
* Creates a blocks repeater for replacing the current block with a selected block type.
*
* @return {WPCompleter} A blocks completer.
* @return {Object} A blocks completer.
*/
function createBlockCompleter() {
return {
Expand Down Expand Up @@ -157,6 +155,6 @@ function createBlockCompleter() {
/**
* Creates a blocks repeater for replacing the current block with a selected block type.
*
* @return {WPCompleter} A blocks completer.
* @return {Object} A blocks completer.
*/
export default createBlockCompleter();
6 changes: 2 additions & 4 deletions packages/block-editor/src/autocompleters/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import { decodeEntities } from '@wordpress/html-entities';

const SHOWN_SUGGESTIONS = 10;

/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this as WPCompleter was never exported from the components package until #67410, where it was advised that it shouldn't be exported.


/**
* Creates a suggestion list for links to posts or pages.
*
* @return {WPCompleter} A links completer.
* @return {Object} A links completer.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to have something there. This PR is only meant to avoid type compilation errors for now.

*/
function createLinkCompleter() {
return {
Expand Down Expand Up @@ -60,6 +58,6 @@ function createLinkCompleter() {
/**
* Creates a suggestion list for links to posts or pages..
*
* @return {WPCompleter} A link completer.
* @return {Object} A link completer.
*/
export default createLinkCompleter();
1 change: 0 additions & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
- Upgraded `@ariakit/react` (v0.4.13) and `@ariakit/test` (v0.4.5) ([#65907](https://github.com/WordPress/gutenberg/pull/65907)).
- Upgraded `@ariakit/react` (v0.4.15) and `@ariakit/test` (v0.4.7) ([#67404](https://github.com/WordPress/gutenberg/pull/67404)).
- `ToolbarButton`: Set size to "compact" ([#67440](https://github.com/WordPress/gutenberg/pull/67440)).
- Exported the `WPCompleter` type as it was being used in block-editor/autocompleters ([#67410](https://github.com/WordPress/gutenberg/pull/67410)).
- `SlotFill`: remove manual rerenders from the portal `Fill` component ([#67471](https://github.com/WordPress/gutenberg/pull/67471)).

### Bug Fixes
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export { Heading as __experimentalHeading } from './heading';
export { HStack as __experimentalHStack } from './h-stack';
export { default as Icon } from './icon';
export type { IconType } from './icon';
export type { WPCompleter } from './autocomplete/types.ts';
export { default as IconButton } from './button/deprecated';
export {
ItemGroup as __experimentalItemGroup,
Expand Down
10 changes: 5 additions & 5 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1457,16 +1457,16 @@ _Returns_

### PostTrashCheck

Wrapper component that renders its children only if the post can trashed.
Wrapper component that renders its children only if the post can be trashed.

_Parameters_

- _props_ `Object`: - The component props.
- _props.children_ `React.ReactNode`: - The child components to render.
- _props_ `Object`: The component props.
- _props.children_ `React.ReactElement`: The child components.

_Returns_

- `React.ReactNode`: The rendered child components or null if the post can not trashed.
- `React.ReactElement | null`: The rendered child components or null if the post can't be trashed.

### PostTypeSupportCheck

Expand Down Expand Up @@ -1762,7 +1762,7 @@ A user mentions completer.

_Type_

- `WPCompleter`
- `Object`

### VisualEditorGlobalKeyboardShortcuts

Expand Down
4 changes: 1 addition & 3 deletions packages/editor/src/components/autocompleters/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { useMemo } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';

/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */

export function getUserLabel( user ) {
const avatar =
user.avatar_urls && user.avatar_urls[ 24 ] ? (
Expand Down Expand Up @@ -35,7 +33,7 @@ export function getUserLabel( user ) {
/**
* A user mentions completer.
*
* @type {WPCompleter}
* @type {Object}
*/
export default {
name: 'users',
Expand Down
8 changes: 4 additions & 4 deletions packages/editor/src/components/post-trash/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { store as editorStore } from '../../store';
import { GLOBAL_POST_TYPES } from '../../store/constants';

/**
* Wrapper component that renders its children only if the post can trashed.
* Wrapper component that renders its children only if the post can be trashed.
*
* @param {Object} props - The component props.
* @param {React.ReactNode} props.children - The child components to render.
* @param {Object} props The component props.
* @param {React.ReactElement} props.children The child components.
*
* @return {React.ReactNode} The rendered child components or null if the post can not trashed.
* @return {React.ReactElement | null} The rendered child components or null if the post can't be trashed.
*/
export default function PostTrashCheck( { children } ) {
const { canTrashPost } = useSelect( ( select ) => {
Expand Down
Loading