From d013290ef9c1a66dc2e59feb85c4e43a92eff510 Mon Sep 17 00:00:00 2001 From: Jake Fletcher Date: Thu, 4 Jun 2026 14:56:46 -0400 Subject: [PATCH] refactor(ui): remove deprecated ParamsProvider and SearchParamsProvider --- packages/ui/src/exports/client/index.ts | 4 +- packages/ui/src/providers/Params/index.tsx | 25 ------- packages/ui/src/providers/Root/index.tsx | 74 ++++++++----------- .../ui/src/providers/SearchParams/index.tsx | 62 ---------------- 4 files changed, 34 insertions(+), 131 deletions(-) delete mode 100644 packages/ui/src/providers/Params/index.tsx delete mode 100644 packages/ui/src/providers/SearchParams/index.tsx diff --git a/packages/ui/src/exports/client/index.ts b/packages/ui/src/exports/client/index.ts index 99fdb652e41..df141998e0c 100644 --- a/packages/ui/src/exports/client/index.ts +++ b/packages/ui/src/exports/client/index.ts @@ -421,14 +421,15 @@ export { export { ListQueryProvider, useListQuery } from '../../providers/ListQuery/index.js' export { LocaleProvider, useLocale } from '../../providers/Locale/index.js' export { OperationProvider, useOperation } from '../../providers/Operation/index.js' -export { ParamsProvider, useParams } from '../../providers/Params/index.js' export { PreferencesProvider, usePreferences } from '../../providers/Preferences/index.js' export { RootProvider } from '../../providers/Root/index.js' export { PayloadLink, RouterAdapterContext, + useParams, usePathname, useRouter, + useSearchParams, } from '../../providers/RouterAdapter/index.js' export type { RouterAdapterContextValue } from '../../providers/RouterAdapter/index.js' export { @@ -436,7 +437,6 @@ export { useRouteCache, } from '../../providers/RouteCache/index.js' export { ScrollInfoProvider, useScrollInfo } from '../../providers/ScrollInfo/index.js' -export { SearchParamsProvider, useSearchParams } from '../../providers/SearchParams/index.js' export { SelectionProvider, useSelection } from '../../providers/Selection/index.js' export { DocumentSelectionProvider, diff --git a/packages/ui/src/providers/Params/index.tsx b/packages/ui/src/providers/Params/index.tsx deleted file mode 100644 index f9a7503f019..00000000000 --- a/packages/ui/src/providers/Params/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -'use client' - -import React, { createContext, use } from 'react' - -import { useParams as useNextParams } from '../RouterAdapter/index.js' - -export type Params = ReturnType -interface IParamsContext extends Params {} - -const Context = createContext({} as IParamsContext) - -/** - * @deprecated - * The ParamsProvider is deprecated and will be removed in the next major release. Instead, use the `useParams` hook from `@payloadcms/ui` directly. See https://github.com/payloadcms/payload/pull/9581. - */ -export const ParamsProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => { - const params = useNextParams() - return {children} -} - -/** - * @deprecated - * The `useParams` hook is deprecated and will be removed in the next major release. Instead, use the `useParams` hook from `@payloadcms/ui` directly. See https://github.com/payloadcms/payload/pull/9581. - */ -export const useParams = (): IParamsContext => use(Context) diff --git a/packages/ui/src/providers/Root/index.tsx b/packages/ui/src/providers/Root/index.tsx index cadfcd5392c..b9b7643e3ba 100644 --- a/packages/ui/src/providers/Root/index.tsx +++ b/packages/ui/src/providers/Root/index.tsx @@ -30,11 +30,9 @@ import { ConfigProvider } from '../Config/index.js' import { DocumentEventsProvider } from '../DocumentEvents/index.js' import { HierarchyProvider } from '../Hierarchy/index.js' import { LocaleProvider } from '../Locale/index.js' -import { ParamsProvider } from '../Params/index.js' import { PreferencesProvider } from '../Preferences/index.js' import { RouteCache } from '../RouteCache/index.js' import { RouteTransitionProvider } from '../RouteTransition/index.js' -import { SearchParamsProvider } from '../SearchParams/index.js' import { ServerFunctionsProvider } from '../ServerFunctions/index.js' import { ThemeProvider } from '../Theme/index.js' import { ToastContainer } from '../ToastContainer/index.js' @@ -104,46 +102,38 @@ export const RootProvider: React.FC = ({ }} > - - - - - - - - - - - - - - - - {children} - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + {children} + + + + + + + + + + + + + + diff --git a/packages/ui/src/providers/SearchParams/index.tsx b/packages/ui/src/providers/SearchParams/index.tsx deleted file mode 100644 index 708a0b030cb..00000000000 --- a/packages/ui/src/providers/SearchParams/index.tsx +++ /dev/null @@ -1,62 +0,0 @@ -'use client' - -import * as qs from 'qs-esm' -import React, { createContext, use } from 'react' - -import { useSearchParams as useNextSearchParams } from '../RouterAdapter/index.js' - -export type SearchParamsContext = { - searchParams: qs.ParsedQs - stringifyParams: ({ params, replace }: { params: qs.ParsedQs; replace?: boolean }) => string -} - -const initialContext: SearchParamsContext = { - searchParams: {}, - stringifyParams: () => '', -} - -const Context = createContext(initialContext) - -/** - * @deprecated - * The SearchParamsProvider is deprecated and will be removed in the next major release. Instead, use the `useSearchParams` hook from `@payloadcms/ui` directly. See https://github.com/payloadcms/payload/pull/9581. - */ -export const SearchParamsProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => { - const nextSearchParams = useNextSearchParams() - const searchString = nextSearchParams.toString() - - const searchParams = React.useMemo( - () => - qs.parse(searchString, { - depth: 10, - ignoreQueryPrefix: true, - }), - [searchString], - ) - - const stringifyParams = React.useCallback( - ({ params, replace = false }: { params: qs.ParsedQs; replace?: boolean }) => { - return qs.stringify( - { - ...(replace ? {} : searchParams), - ...params, - }, - { addQueryPrefix: true }, - ) - }, - [searchParams], - ) - - return {children} -} - -/** - * @deprecated - * The `useSearchParams` hook is deprecated and will be removed in the next major release. Instead, use the `useSearchParams` hook from `@payloadcms/ui` directly. See https://github.com/payloadcms/payload/pull/9581. - * If you need to parse the `where` query, you can do so with the `parseSearchParams` utility. - * ```tsx - * import { parseSearchParams } from '@payloadcms/ui' - * const parsedSearchParams = parseSearchParams(searchParams) - * ``` - */ -export const useSearchParams = (): SearchParamsContext => use(Context)