From 1b76327d7dad2dba9b7c71ba10292e18914502d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:33:48 +0100 Subject: [PATCH] Move usePostFields to editor package --- .../src/components/post-edit/index.js | 3 +-- .../src/components/post-list/index.js | 3 +-- .../src/components/post-fields}/index.ts | 26 +++++++++---------- packages/editor/src/private-apis.js | 2 ++ packages/fields/README.md | 4 --- packages/fields/src/fields/index.ts | 1 - packages/fields/src/index.ts | 1 + 7 files changed, 17 insertions(+), 23 deletions(-) rename packages/{fields/src/fields/use-post-fields => editor/src/components/post-fields}/index.ts (70%) diff --git a/packages/edit-site/src/components/post-edit/index.js b/packages/edit-site/src/components/post-edit/index.js index 6a8d2322b2f87c..a535eef4ce7878 100644 --- a/packages/edit-site/src/components/post-edit/index.js +++ b/packages/edit-site/src/components/post-edit/index.js @@ -13,7 +13,6 @@ import { store as coreDataStore } from '@wordpress/core-data'; import { __experimentalVStack as VStack } from '@wordpress/components'; import { useState, useMemo, useEffect } from '@wordpress/element'; import { privateApis as editorPrivateApis } from '@wordpress/editor'; -import { usePostFields } from '@wordpress/fields'; /** * Internal dependencies @@ -21,7 +20,7 @@ import { usePostFields } from '@wordpress/fields'; import Page from '../page'; import { unlock } from '../../lock-unlock'; -const { PostCardPanel } = unlock( editorPrivateApis ); +const { PostCardPanel, usePostFields } = unlock( editorPrivateApis ); const fieldsWithBulkEditSupport = [ 'title', diff --git a/packages/edit-site/src/components/post-list/index.js b/packages/edit-site/src/components/post-list/index.js index 26a3621da9ee60..975809b2ad6106 100644 --- a/packages/edit-site/src/components/post-list/index.js +++ b/packages/edit-site/src/components/post-list/index.js @@ -13,7 +13,6 @@ import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews'; import { privateApis as editorPrivateApis } from '@wordpress/editor'; import { __ } from '@wordpress/i18n'; import { drawerRight } from '@wordpress/icons'; -import { usePostFields } from '@wordpress/fields'; /** * Internal dependencies @@ -34,7 +33,7 @@ import { unlock } from '../../lock-unlock'; import { useEditPostAction } from '../dataviews-actions'; import { usePrevious } from '@wordpress/compose'; -const { usePostActions } = unlock( editorPrivateApis ); +const { usePostActions, usePostFields } = unlock( editorPrivateApis ); const { useLocation, useHistory } = unlock( routerPrivateApis ); const { useEntityRecordsWithPermissions } = unlock( coreDataPrivateApis ); const EMPTY_ARRAY = []; diff --git a/packages/fields/src/fields/use-post-fields/index.ts b/packages/editor/src/components/post-fields/index.ts similarity index 70% rename from packages/fields/src/fields/use-post-fields/index.ts rename to packages/editor/src/components/post-fields/index.ts index 7a812d88ba5116..3d675ab763d64c 100644 --- a/packages/fields/src/fields/use-post-fields/index.ts +++ b/packages/editor/src/components/post-fields/index.ts @@ -4,20 +4,18 @@ import { useMemo } from '@wordpress/element'; import { useEntityRecords } from '@wordpress/core-data'; import type { Field } from '@wordpress/dataviews'; - -/** - * Internal dependencies - */ -import featuredImageField from '../featured-image'; -import slugField from '../slug'; -import parentField from '../parent'; -import passwordField from '../password'; -import statusField from '../status'; -import commentStatusField from '../comment-status'; -import titleField from '../title'; -import dateField from '../date'; -import authorField from '../author'; -import type { BasePostWithEmbeddedAuthor } from '../../types'; +import { + featuredImageField, + slugField, + parentField, + passwordField, + statusField, + commentStatusField, + titleField, + dateField, + authorField, +} from '@wordpress/fields'; +import type { BasePostWithEmbeddedAuthor } from '@wordpress/fields'; interface UsePostFieldsReturn { isLoading: boolean; diff --git a/packages/editor/src/private-apis.js b/packages/editor/src/private-apis.js index f9a6d4d17904ee..b49b2a69a3bf2b 100644 --- a/packages/editor/src/private-apis.js +++ b/packages/editor/src/private-apis.js @@ -16,6 +16,7 @@ import PluginPostExcerpt from './components/post-excerpt/plugin'; import PostCardPanel from './components/post-card-panel'; import PreferencesModal from './components/preferences-modal'; import { usePostActions } from './components/post-actions/actions'; +import usePostFields from './components/post-fields'; import ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group'; import ViewMoreMenuGroup from './components/more-menu/view-more-menu-group'; import ResizableEditor from './components/resizable-editor'; @@ -40,6 +41,7 @@ lock( privateApis, { PostCardPanel, PreferencesModal, usePostActions, + usePostFields, ToolsMoreMenuGroup, ViewMoreMenuGroup, ResizableEditor, diff --git a/packages/fields/README.md b/packages/fields/README.md index 8bcf4d2e91a0fc..e6cf6d3007ed97 100644 --- a/packages/fields/README.md +++ b/packages/fields/README.md @@ -106,10 +106,6 @@ Undocumented declaration. Undocumented declaration. -### usePostFields - -Hook to get the fields for a post (BasePost or BasePostWithEmbeddedAuthor). - ### viewPost Undocumented declaration. diff --git a/packages/fields/src/fields/index.ts b/packages/fields/src/fields/index.ts index 5333d03371e3c2..5ea4235af1d964 100644 --- a/packages/fields/src/fields/index.ts +++ b/packages/fields/src/fields/index.ts @@ -8,4 +8,3 @@ export { default as statusField } from './status'; export { default as commentStatusField } from './comment-status'; export { default as dateField } from './date'; export { default as authorField } from './author'; -export { default as usePostFields } from './use-post-fields'; diff --git a/packages/fields/src/index.ts b/packages/fields/src/index.ts index 4c721b85b61a40..41879a86e76bed 100644 --- a/packages/fields/src/index.ts +++ b/packages/fields/src/index.ts @@ -1,2 +1,3 @@ export * from './fields'; export * from './actions'; +export type * from './types';