From aef2a52cea6fa7923f71cb0620ae6a38089ada7a Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Wed, 19 Jun 2024 14:16:31 -0400 Subject: [PATCH] fix: fix all ui imports in our plugins, and get rid of ui subpath exports within monorepo (#6854) --- .../next/src/elements/Nav/index.client.tsx | 2 +- packages/next/src/layouts/Root/index.tsx | 2 +- .../Account/Settings/LanguageSelector.tsx | 4 +- packages/next/src/views/Dashboard/index.tsx | 2 +- .../src/views/LivePreview/index.client.tsx | 2 +- .../src/views/Version/Default/SetStepNav.tsx | 2 +- .../fields/Select/index.tsx | 2 +- .../Forms/DynamicFieldSelector.tsx | 7 +- .../Forms/DynamicPriceSelector.tsx | 8 +- .../src/Search/ui/index.client.tsx | 3 +- .../plugin-seo/src/fields/MetaDescription.tsx | 21 +-- packages/plugin-seo/src/fields/MetaImage.tsx | 21 +-- packages/plugin-seo/src/fields/MetaTitle.tsx | 21 +-- packages/plugin-seo/src/index.tsx | 2 +- packages/plugin-seo/src/types.ts | 2 +- .../plugin-seo/src/ui/LengthIndicator.tsx | 2 +- packages/plugin-seo/src/ui/Overview.tsx | 3 +- packages/plugin-seo/src/ui/Preview.tsx | 5 +- packages/plugin-seo/tsconfig.json | 3 +- packages/plugin-stripe/src/ui/LinkToDoc.tsx | 4 +- packages/richtext-lexical/src/field/Field.tsx | 4 +- .../blocks/component/BlockContent.tsx | 2 +- .../field/features/blocks/component/index.tsx | 2 +- .../src/field/features/link/drawer/index.tsx | 2 +- .../component/ExtraFieldsDrawer/index.tsx | 2 +- packages/richtext-lexical/src/field/index.tsx | 2 +- .../src/field/lexical/LexicalProvider.tsx | 2 +- .../config/client/EditorConfigProvider.tsx | 2 +- packages/richtext-lexical/src/index.ts | 2 +- .../richtext-slate/src/field/RichText.tsx | 2 +- .../field/elements/link/LinkDrawer/index.tsx | 2 +- .../field/elements/link/LinkDrawer/types.ts | 2 +- .../elements/relationship/Element/index.tsx | 2 +- .../upload/Element/UploadDrawer/index.tsx | 5 +- .../field/elements/upload/Element/index.tsx | 4 +- packages/richtext-slate/src/field/index.tsx | 2 +- .../field/providers/ElementButtonProvider.tsx | 2 +- .../src/field/providers/ElementProvider.tsx | 2 +- .../field/providers/LeafButtonProvider.tsx | 2 +- .../src/field/providers/LeafProvider.tsx | 2 +- packages/ui/package.json | 70 +++----- .../ReactSelect/DropdownIndicator/index.tsx | 2 +- packages/ui/src/elements/StepNav/index.tsx | 3 +- packages/ui/src/exports/client/index.ts | 38 ++++- packages/ui/src/exports/shared/index.ts | 8 +- test/access-control/TestButton.tsx | 5 +- test/admin/components/AfterNavLinks/index.tsx | 2 +- test/admin/components/BeforeLogin/index.tsx | 2 +- test/admin/components/CustomCell/index.tsx | 2 +- .../components/CustomTabComponent/client.tsx | 2 +- .../components/FieldDescription/index.tsx | 3 +- test/admin/components/Logout/index.tsx | 3 +- .../components/views/CustomDefault/index.tsx | 3 +- .../components/views/CustomEdit/index.tsx | 2 +- .../views/CustomEditDefault/index.tsx | 6 +- .../components/views/CustomMinimal/index.tsx | 2 +- .../views/CustomTabComponent/index.tsx | 6 +- .../components/views/CustomTabLabel/index.tsx | 2 +- .../views/CustomTabNested/index.tsx | 2 +- .../components/views/CustomVersions/index.tsx | 2 +- .../views/CustomView/index.client.tsx | 16 +- .../components/views/CustomView/index.tsx | 2 +- .../views/CustomViewNested/index.tsx | 6 +- .../views/CustomViewWithParam/index.tsx | 6 +- test/auth/AuthDebug.tsx | 2 +- test/auth/ui/AuthDebug.tsx | 2 +- .../PrePopulateFieldUI/index.tsx | 2 +- test/fields-relationship/config.ts | 2 +- .../collections/Array/LabelComponent.tsx | 2 +- .../components/AddCustomBlocks/index.tsx | 3 +- .../Collapsible/CustomLabel/index.tsx | 2 +- .../Collapsible/NestedCustomLabel/index.tsx | 2 +- test/fields/collections/Text/CustomError.tsx | 3 +- test/fields/collections/Text/CustomLabel.tsx | 2 +- test/fields/collections/UI/UICustomClient.tsx | 2 +- test/i18n/ComponentWithCustomI18n.tsx | 2 +- test/i18n/ComponentWithDefaultI18n.tsx | 2 +- .../(pages)/posts/[slug]/page.client.tsx | 2 +- .../(pages)/ssr-autosave/[slug]/page.tsx | 2 +- .../live-preview/(pages)/ssr/[slug]/page.tsx | 2 +- test/plugin-seo/payload-types.ts | 149 +++++++++--------- test/tsconfig.json | 26 ++- .../elements/CustomSaveButton/index.tsx | 2 +- tsconfig.json | 34 +--- 84 files changed, 287 insertions(+), 318 deletions(-) diff --git a/packages/next/src/elements/Nav/index.client.tsx b/packages/next/src/elements/Nav/index.client.tsx index 56abf720ce..ff8940cb33 100644 --- a/packages/next/src/elements/Nav/index.client.tsx +++ b/packages/next/src/elements/Nav/index.client.tsx @@ -1,6 +1,6 @@ 'use client' -import type { EntityToGroup } from '@payloadcms/ui/utilities/groupNavItems' +import type { EntityToGroup } from '@payloadcms/ui/shared' import { getTranslation } from '@payloadcms/translations' import { diff --git a/packages/next/src/layouts/Root/index.tsx b/packages/next/src/layouts/Root/index.tsx index e024760867..8d440c75e7 100644 --- a/packages/next/src/layouts/Root/index.tsx +++ b/packages/next/src/layouts/Root/index.tsx @@ -3,8 +3,8 @@ import type { SanitizedConfig } from 'payload' import { initI18n, rtlLanguages } from '@payloadcms/translations' import { RootProvider } from '@payloadcms/ui' -import { buildComponentMap } from '@payloadcms/ui/providers/ComponentMap/buildComponentMap' import '@payloadcms/ui/scss/app.scss' +import { buildComponentMap } from '@payloadcms/ui/utilities/buildComponentMap' import { Merriweather } from 'next/font/google' import { headers as getHeaders, cookies as nextCookies } from 'next/headers.js' import { createClientConfig, parseCookies } from 'payload' diff --git a/packages/next/src/views/Account/Settings/LanguageSelector.tsx b/packages/next/src/views/Account/Settings/LanguageSelector.tsx index b8a4e2e22e..1bea75fdec 100644 --- a/packages/next/src/views/Account/Settings/LanguageSelector.tsx +++ b/packages/next/src/views/Account/Settings/LanguageSelector.tsx @@ -1,6 +1,6 @@ 'use client' import type { AcceptedLanguages } from '@payloadcms/translations' -import type { Option } from '@payloadcms/ui/elements/ReactSelect' +import type { ReactSelectOption } from '@payloadcms/ui' import type { LanguageOptions } from 'payload' import { ReactSelect, useTranslation } from '@payloadcms/ui' @@ -17,7 +17,7 @@ export const LanguageSelector: React.FC<{ ) => { + onChange={async (option: ReactSelectOption) => { await switchLanguage(option.value) }} options={languageOptions} diff --git a/packages/next/src/views/Dashboard/index.tsx b/packages/next/src/views/Dashboard/index.tsx index a122b2efb1..ea7ded6772 100644 --- a/packages/next/src/views/Dashboard/index.tsx +++ b/packages/next/src/views/Dashboard/index.tsx @@ -1,4 +1,4 @@ -import type { EntityToGroup } from '@payloadcms/ui/utilities/groupNavItems' +import type { EntityToGroup } from '@payloadcms/ui/shared' import type { AdminViewProps } from 'payload' import { HydrateClientUser } from '@payloadcms/ui' diff --git a/packages/next/src/views/LivePreview/index.client.tsx b/packages/next/src/views/LivePreview/index.client.tsx index 2f6ea77bb4..688de86fc3 100644 --- a/packages/next/src/views/LivePreview/index.client.tsx +++ b/packages/next/src/views/LivePreview/index.client.tsx @@ -1,5 +1,5 @@ 'use client' -import type { FormProps } from '@payloadcms/ui/forms/Form' +import type { FormProps } from '@payloadcms/ui' import type { FieldMap } from '@payloadcms/ui/utilities/buildComponentMap' import type { ClientCollectionConfig, diff --git a/packages/next/src/views/Version/Default/SetStepNav.tsx b/packages/next/src/views/Version/Default/SetStepNav.tsx index 832e505a7a..0216f0ec8a 100644 --- a/packages/next/src/views/Version/Default/SetStepNav.tsx +++ b/packages/next/src/views/Version/Default/SetStepNav.tsx @@ -1,4 +1,4 @@ -import type { StepNavItem } from '@payloadcms/ui/elements/StepNav' +import type { StepNavItem } from '@payloadcms/ui' import type { FieldMap } from '@payloadcms/ui/utilities/buildComponentMap' import type { ClientCollectionConfig, ClientGlobalConfig } from 'payload' import type React from 'react' diff --git a/packages/next/src/views/Version/RenderFieldsToDiff/fields/Select/index.tsx b/packages/next/src/views/Version/RenderFieldsToDiff/fields/Select/index.tsx index ac48b59de7..febb9ba466 100644 --- a/packages/next/src/views/Version/RenderFieldsToDiff/fields/Select/index.tsx +++ b/packages/next/src/views/Version/RenderFieldsToDiff/fields/Select/index.tsx @@ -1,5 +1,5 @@ import type { I18nClient } from '@payloadcms/translations' -import type { SelectFieldProps } from '@payloadcms/ui/fields/Select' +import type { SelectFieldProps } from '@payloadcms/ui' import type { MappedField } from '@payloadcms/ui/utilities/buildComponentMap' import type { OptionObject, SelectField } from 'payload' diff --git a/packages/plugin-form-builder/src/collections/Forms/DynamicFieldSelector.tsx b/packages/plugin-form-builder/src/collections/Forms/DynamicFieldSelector.tsx index db03aa9f14..90dfdab224 100644 --- a/packages/plugin-form-builder/src/collections/Forms/DynamicFieldSelector.tsx +++ b/packages/plugin-form-builder/src/collections/Forms/DynamicFieldSelector.tsx @@ -1,9 +1,8 @@ 'use client' -import type { TextFieldProps } from '@payloadcms/ui/fields/Text' +import type { TextFieldProps } from '@payloadcms/ui' -import { Select } from '@payloadcms/ui/fields/Select' -import { useForm } from '@payloadcms/ui/forms/Form' +import { SelectField, useForm } from '@payloadcms/ui' import React, { useEffect, useState } from 'react' import type { SelectFieldOption } from '../../types.js' @@ -37,5 +36,5 @@ export const DynamicFieldSelector: React.FC = (props) => { // TODO: label from config is Record | false | string // but the FormFieldBase type has only label?: string, changing FormFieldBase breaks other ui components - return