Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
3.6 KiB
Plaintext
1 line
3.6 KiB
Plaintext
{"version":3,"file":"index.js","names":["useSearchParams","useNextSearchParams","qs","React","createContext","use","initialContext","searchParams","stringifyParams","Context","SearchParamsProvider","children","nextSearchParams","searchString","toString","useMemo","parse","depth","ignoreQueryPrefix","useCallback","params","replace","stringify","addQueryPrefix","_jsx","value"],"sources":["../../../src/providers/SearchParams/index.tsx"],"sourcesContent":["'use client'\n\nimport { useSearchParams as useNextSearchParams } from 'next/navigation.js'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use } from 'react'\n\nexport type SearchParamsContext = {\n searchParams: qs.ParsedQs\n stringifyParams: ({ params, replace }: { params: qs.ParsedQs; replace?: boolean }) => string\n}\n\nconst initialContext: SearchParamsContext = {\n searchParams: {},\n stringifyParams: () => '',\n}\n\nconst Context = createContext(initialContext)\n\n/**\n * @deprecated\n * The SearchParamsProvider is deprecated and will be removed in the next major release. Instead, use the `useSearchParams` hook from `next/navigation` directly. See https://github.com/payloadcms/payload/pull/9581.\n * @example\n * ```tsx\n * import { useSearchParams } from 'next/navigation'\n * ```\n */\nexport const SearchParamsProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => {\n const nextSearchParams = useNextSearchParams()\n const searchString = nextSearchParams.toString()\n\n const searchParams = React.useMemo(\n () =>\n qs.parse(searchString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n [searchString],\n )\n\n const stringifyParams = React.useCallback(\n ({ params, replace = false }: { params: qs.ParsedQs; replace?: boolean }) => {\n return qs.stringify(\n {\n ...(replace ? {} : searchParams),\n ...params,\n },\n { addQueryPrefix: true },\n )\n },\n [searchParams],\n )\n\n return <Context value={{ searchParams, stringifyParams }}>{children}</Context>\n}\n\n/**\n * @deprecated\n * The `useSearchParams` hook is deprecated and will be removed in the next major release. Instead, use the `useSearchParams` hook from `next/navigation` directly. See https://github.com/payloadcms/payload/pull/9581.\n * @example\n * ```tsx\n * import { useSearchParams } from 'next/navigation'\n * ```\n * If you need to parse the `where` query, you can do so with the `parseSearchParams` utility.\n * ```tsx\n * import { parseSearchParams } from '@payloadcms/ui'\n * const parsedSearchParams = parseSearchParams(searchParams)\n * ```\n */\nexport const useSearchParams = (): SearchParamsContext => use(Context)\n"],"mappings":"AAAA;;;AAEA,SAASA,eAAA,IAAmBC,mBAAmB,QAAQ;AACvD,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,QAAQ;AAO1C,MAAMC,cAAA,GAAsC;EAC1CC,YAAA,EAAc,CAAC;EACfC,eAAA,EAAiBA,CAAA,KAAM;AACzB;AAEA,MAAMC,OAAA,gBAAUL,aAAA,CAAcE,cAAA;AAE9B;;;;;;;;AAQA,OAAO,MAAMI,oBAAA,GAAiEA,CAAC;EAAEC;AAAQ,CAAE;EACzF,MAAMC,gBAAA,GAAmBX,mBAAA;EACzB,MAAMY,YAAA,GAAeD,gBAAA,CAAiBE,QAAQ;EAE9C,MAAMP,YAAA,GAAeJ,KAAA,CAAMY,OAAO,CAChC,MACEb,EAAA,CAAGc,KAAK,CAACH,YAAA,EAAc;IACrBI,KAAA,EAAO;IACPC,iBAAA,EAAmB;EACrB,IACF,CAACL,YAAA,CAAa;EAGhB,MAAML,eAAA,GAAkBL,KAAA,CAAMgB,WAAW,CACvC,CAAC;IAAEC,MAAM;IAAEC,OAAA,GAAU;EAAK,CAA8C;IACtE,OAAOnB,EAAA,CAAGoB,SAAS,CACjB;MACE,IAAID,OAAA,GAAU,CAAC,IAAId,YAAY;MAC/B,GAAGa;IACL,GACA;MAAEG,cAAA,EAAgB;IAAK;EAE3B,GACA,CAAChB,YAAA,CAAa;EAGhB,oBAAOiB,IAAA,CAACf,OAAA;IAAQgB,KAAA,EAAO;MAAElB,YAAA;MAAcC;IAAgB;cAAIG;;AAC7D;AAEA;;;;;;;;;;;;;AAaA,OAAO,MAAMX,eAAA,GAAkBA,CAAA,KAA2BK,GAAA,CAAII,OAAA","ignoreList":[]} |