@payloadcms/next 3.29.0 → 3.30.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,10 +5,11 @@ export declare const metadata: {
|
|
|
5
5
|
description: string;
|
|
6
6
|
title: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const RootLayout: ({ children, config: configPromise, importMap, serverFunction, }: {
|
|
8
|
+
export declare const RootLayout: ({ children, config: configPromise, importMap, serverFunction, htmlProps, }: {
|
|
9
9
|
readonly children: React.ReactNode;
|
|
10
10
|
readonly config: Promise<SanitizedConfig>;
|
|
11
11
|
readonly importMap: ImportMap;
|
|
12
12
|
readonly serverFunction: ServerFunctionClient;
|
|
13
|
+
readonly htmlProps?: React.HtmlHTMLAttributes<HTMLHtmlElement>;
|
|
13
14
|
}) => Promise<React.JSX.Element>;
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAmB,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAMhG,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,8BAA8B,CAAA;AAErC,eAAO,MAAM,QAAQ;;;CAGpB,CAAA;AAED,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAmB,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAMhG,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,8BAA8B,CAAA;AAErC,eAAO,MAAM,QAAQ;;;CAGpB,CAAA;AAED,eAAO,MAAM,UAAU,+EAMpB;IACD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAA;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;CAC/D,+BAuHA,CAAA"}
|
|
@@ -17,7 +17,8 @@ export const RootLayout = async ({
|
|
|
17
17
|
children,
|
|
18
18
|
config: configPromise,
|
|
19
19
|
importMap,
|
|
20
|
-
serverFunction
|
|
20
|
+
serverFunction,
|
|
21
|
+
htmlProps = {}
|
|
21
22
|
}) => {
|
|
22
23
|
checkDependencies();
|
|
23
24
|
const {
|
|
@@ -84,6 +85,7 @@ export const RootLayout = async ({
|
|
|
84
85
|
dir: dir,
|
|
85
86
|
lang: languageCode,
|
|
86
87
|
suppressHydrationWarning: config?.admin?.suppressHydrationWarning ?? false,
|
|
88
|
+
...htmlProps,
|
|
87
89
|
children: [/*#__PURE__*/_jsx("head", {
|
|
88
90
|
children: /*#__PURE__*/_jsx("style", {
|
|
89
91
|
children: `@layer payload-default, payload;`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["rtlLanguages","ProgressBar","RootProvider","getClientConfig","cookies","nextCookies","React","getNavPrefs","getRequestTheme","initReq","checkDependencies","NestProviders","metadata","description","title","RootLayout","children","config","configPromise","importMap","serverFunction","headers","languageCode","permissions","req","payload","key","theme","dir","includes","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","push","label","translations","general","thisLanguage","value","switchLanguageServerAction","lang","set","name","cookiePrefix","path","navPrefs","user","id","collection","clientConfig","localization","filterAvailableLocales","locales","map","toString","rest","localeCodes","code","_jsxs","suppressHydrationWarning","admin","_jsx","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale","Array","isArray","components","providers","length","serverProps"],"sources":["../../../src/layouts/Root/index.tsx"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ImportMap, LanguageOptions, SanitizedConfig, ServerFunctionClient } from 'payload'\n\nimport { rtlLanguages } from '@payloadcms/translations'\nimport { ProgressBar, RootProvider } from '@payloadcms/ui'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { cookies as nextCookies } from 'next/headers.js'\nimport React from 'react'\n\nimport { getNavPrefs } from '../../elements/Nav/getNavPrefs.js'\nimport { getRequestTheme } from '../../utilities/getRequestTheme.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { checkDependencies } from './checkDependencies.js'\nimport { NestProviders } from './NestProviders.js'\n\nimport '@payloadcms/ui/scss/app.scss'\n\nexport const metadata = {\n description: 'Generated by Next.js',\n title: 'Next.js',\n}\n\nexport const RootLayout = async ({\n children,\n config: configPromise,\n importMap,\n serverFunction,\n}: {\n readonly children: React.ReactNode\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly serverFunction: ServerFunctionClient\n}) => {\n checkDependencies()\n\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap, key: 'RootLayout' })\n\n const theme = getRequestTheme({\n config,\n cookies,\n headers,\n })\n\n const dir = (rtlLanguages as unknown as AcceptedLanguages[]).includes(languageCode)\n ? 'RTL'\n : 'LTR'\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n }, [])\n\n async function switchLanguageServerAction(lang: string): Promise<void> {\n 'use server'\n const cookies = await nextCookies()\n cookies.set({\n name: `${config.cookiePrefix || 'payload'}-lng`,\n path: '/',\n value: lang,\n })\n }\n\n const navPrefs = await getNavPrefs(req.payload, req.user?.id, req.user?.collection)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n })\n\n if (\n clientConfig.localization &&\n config.localization &&\n typeof config.localization.filterAvailableLocales === 'function'\n ) {\n clientConfig.localization.locales = (\n await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n ).map(({ toString, ...rest }) => rest)\n clientConfig.localization.localeCodes = config.localization.locales.map(({ code }) => code)\n }\n\n return (\n <html\n data-theme={theme}\n dir={dir}\n lang={languageCode}\n suppressHydrationWarning={config?.admin?.suppressHydrationWarning ?? false}\n >\n <head>\n <style>{`@layer payload-default, payload;`}</style>\n </head>\n <body>\n <RootProvider\n config={clientConfig}\n dateFNSKey={req.i18n.dateFNSKey}\n fallbackLang={config.i18n.fallbackLanguage}\n isNavOpen={navPrefs?.open ?? true}\n languageCode={languageCode}\n languageOptions={languageOptions}\n locale={req.locale}\n permissions={permissions}\n serverFunction={serverFunction}\n switchLanguageServerAction={switchLanguageServerAction}\n theme={theme}\n translations={req.i18n.translations}\n user={req.user}\n >\n <ProgressBar />\n {Array.isArray(config.admin?.components?.providers) &&\n config.admin?.components?.providers.length > 0 ? (\n <NestProviders\n importMap={req.payload.importMap}\n providers={config.admin?.components?.providers}\n serverProps={{\n i18n: req.i18n,\n payload: req.payload,\n permissions,\n user: req.user,\n }}\n >\n {children}\n </NestProviders>\n ) : (\n children\n )}\n </RootProvider>\n <div id=\"portal\" />\n </body>\n </html>\n )\n}\n"],"mappings":";AAGA,SAASA,YAAY,QAAQ;AAC7B,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAC1C,SAASC,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,WAAW,QAAQ;AACvC,OAAOC,KAAA,MAAW;AAElB,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,QAAQ;AAChC,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,aAAa,QAAQ;AAI9B,OAAO,MAAMC,QAAA,GAAW;EACtBC,WAAA,EAAa;EACbC,KAAA,EAAO;AACT;AAEA,OAAO,MAAMC,UAAA,GAAa,MAAAA,CAAO;EAC/BC,QAAQ;EACRC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC;
|
|
1
|
+
{"version":3,"file":"index.js","names":["rtlLanguages","ProgressBar","RootProvider","getClientConfig","cookies","nextCookies","React","getNavPrefs","getRequestTheme","initReq","checkDependencies","NestProviders","metadata","description","title","RootLayout","children","config","configPromise","importMap","serverFunction","htmlProps","headers","languageCode","permissions","req","payload","key","theme","dir","includes","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","push","label","translations","general","thisLanguage","value","switchLanguageServerAction","lang","set","name","cookiePrefix","path","navPrefs","user","id","collection","clientConfig","localization","filterAvailableLocales","locales","map","toString","rest","localeCodes","code","_jsxs","suppressHydrationWarning","admin","_jsx","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale","Array","isArray","components","providers","length","serverProps"],"sources":["../../../src/layouts/Root/index.tsx"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ImportMap, LanguageOptions, SanitizedConfig, ServerFunctionClient } from 'payload'\n\nimport { rtlLanguages } from '@payloadcms/translations'\nimport { ProgressBar, RootProvider } from '@payloadcms/ui'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { cookies as nextCookies } from 'next/headers.js'\nimport React from 'react'\n\nimport { getNavPrefs } from '../../elements/Nav/getNavPrefs.js'\nimport { getRequestTheme } from '../../utilities/getRequestTheme.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { checkDependencies } from './checkDependencies.js'\nimport { NestProviders } from './NestProviders.js'\n\nimport '@payloadcms/ui/scss/app.scss'\n\nexport const metadata = {\n description: 'Generated by Next.js',\n title: 'Next.js',\n}\n\nexport const RootLayout = async ({\n children,\n config: configPromise,\n importMap,\n serverFunction,\n htmlProps = {},\n}: {\n readonly children: React.ReactNode\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly serverFunction: ServerFunctionClient\n readonly htmlProps?: React.HtmlHTMLAttributes<HTMLHtmlElement>\n}) => {\n checkDependencies()\n\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap, key: 'RootLayout' })\n\n const theme = getRequestTheme({\n config,\n cookies,\n headers,\n })\n\n const dir = (rtlLanguages as unknown as AcceptedLanguages[]).includes(languageCode)\n ? 'RTL'\n : 'LTR'\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n }, [])\n\n async function switchLanguageServerAction(lang: string): Promise<void> {\n 'use server'\n const cookies = await nextCookies()\n cookies.set({\n name: `${config.cookiePrefix || 'payload'}-lng`,\n path: '/',\n value: lang,\n })\n }\n\n const navPrefs = await getNavPrefs(req.payload, req.user?.id, req.user?.collection)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n })\n\n if (\n clientConfig.localization &&\n config.localization &&\n typeof config.localization.filterAvailableLocales === 'function'\n ) {\n clientConfig.localization.locales = (\n await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n ).map(({ toString, ...rest }) => rest)\n clientConfig.localization.localeCodes = config.localization.locales.map(({ code }) => code)\n }\n\n return (\n <html\n data-theme={theme}\n dir={dir}\n lang={languageCode}\n suppressHydrationWarning={config?.admin?.suppressHydrationWarning ?? false}\n {...htmlProps}\n >\n <head>\n <style>{`@layer payload-default, payload;`}</style>\n </head>\n <body>\n <RootProvider\n config={clientConfig}\n dateFNSKey={req.i18n.dateFNSKey}\n fallbackLang={config.i18n.fallbackLanguage}\n isNavOpen={navPrefs?.open ?? true}\n languageCode={languageCode}\n languageOptions={languageOptions}\n locale={req.locale}\n permissions={permissions}\n serverFunction={serverFunction}\n switchLanguageServerAction={switchLanguageServerAction}\n theme={theme}\n translations={req.i18n.translations}\n user={req.user}\n >\n <ProgressBar />\n {Array.isArray(config.admin?.components?.providers) &&\n config.admin?.components?.providers.length > 0 ? (\n <NestProviders\n importMap={req.payload.importMap}\n providers={config.admin?.components?.providers}\n serverProps={{\n i18n: req.i18n,\n payload: req.payload,\n permissions,\n user: req.user,\n }}\n >\n {children}\n </NestProviders>\n ) : (\n children\n )}\n </RootProvider>\n <div id=\"portal\" />\n </body>\n </html>\n )\n}\n"],"mappings":";AAGA,SAASA,YAAY,QAAQ;AAC7B,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAC1C,SAASC,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,WAAW,QAAQ;AACvC,OAAOC,KAAA,MAAW;AAElB,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,QAAQ;AAChC,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,aAAa,QAAQ;AAI9B,OAAO,MAAMC,QAAA,GAAW;EACtBC,WAAA,EAAa;EACbC,KAAA,EAAO;AACT;AAEA,OAAO,MAAMC,UAAA,GAAa,MAAAA,CAAO;EAC/BC,QAAQ;EACRC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC,cAAc;EACdC,SAAA,GAAY,CAAC;AAAC,CAOf;EACCX,iBAAA;EAEA,MAAM;IACJN,OAAO;IACPkB,OAAO;IACPC,YAAY;IACZC,WAAW;IACXC,GAAG;IACHA,GAAA,EAAK;MACHC,OAAA,EAAS;QAAET;MAAM;IAAE;EACpB,CACF,GAAG,MAAMR,OAAA,CAAQ;IAAES,aAAA;IAAeC,SAAA;IAAWQ,GAAA,EAAK;EAAa;EAEhE,MAAMC,KAAA,GAAQpB,eAAA,CAAgB;IAC5BS,MAAA;IACAb,OAAA;IACAkB;EACF;EAEA,MAAMO,GAAA,GAAM7B,YAAC,CAAgD8B,QAAQ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