@payloadcms/next 3.74.0 → 3.75.0-internal.880861f
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.
- package/dist/auth/login.d.ts +9 -12
- package/dist/auth/login.d.ts.map +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.d.ts +2 -2
- package/dist/auth/logout.d.ts.map +1 -1
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js.map +1 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +7 -5
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/initReq.d.ts +2 -13
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.js +6 -0
- package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +6 -0
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +7 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js +7 -1
- package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js.map +1 -1
- package/package.json +7 -7
package/dist/auth/login.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type LoginWithEmail = {
|
|
3
|
-
collection:
|
|
4
|
-
config:
|
|
1
|
+
import type { AuthCollectionSlug, LoginResult, MaybePromise, SanitizedConfig } from 'payload';
|
|
2
|
+
type LoginWithEmail<TSlug extends AuthCollectionSlug> = {
|
|
3
|
+
collection: TSlug;
|
|
4
|
+
config: MaybePromise<SanitizedConfig>;
|
|
5
5
|
email: string;
|
|
6
6
|
password: string;
|
|
7
7
|
username?: never;
|
|
8
8
|
};
|
|
9
|
-
type LoginWithUsername = {
|
|
10
|
-
collection:
|
|
11
|
-
config:
|
|
9
|
+
type LoginWithUsername<TSlug extends AuthCollectionSlug> = {
|
|
10
|
+
collection: TSlug;
|
|
11
|
+
config: MaybePromise<SanitizedConfig>;
|
|
12
12
|
email?: never;
|
|
13
13
|
password: string;
|
|
14
14
|
username: string;
|
|
15
15
|
};
|
|
16
|
-
type LoginArgs = LoginWithEmail | LoginWithUsername
|
|
17
|
-
export declare function login({ collection, config, email, password, username }: LoginArgs): Promise<
|
|
18
|
-
token?: string;
|
|
19
|
-
user: any;
|
|
20
|
-
}>;
|
|
16
|
+
type LoginArgs<TSlug extends AuthCollectionSlug> = LoginWithEmail<TSlug> | LoginWithUsername<TSlug>;
|
|
17
|
+
export declare function login<TSlug extends AuthCollectionSlug>({ collection, config, email, password, username, }: LoginArgs<TSlug>): Promise<LoginResult<TSlug>>;
|
|
21
18
|
export {};
|
|
22
19
|
//# sourceMappingURL=login.d.ts.map
|
package/dist/auth/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM7F,KAAK,cAAc,CAAC,KAAK,SAAS,kBAAkB,IAAI;IACtD,UAAU,EAAE,KAAK,CAAA;IACjB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB,CAAA;AAED,KAAK,iBAAiB,CAAC,KAAK,SAAS,kBAAkB,IAAI;IACzD,UAAU,EAAE,KAAK,CAAA;IACjB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IACrC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AACD,KAAK,SAAS,CAAC,KAAK,SAAS,kBAAkB,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAEnG,wBAAsB,KAAK,CAAC,KAAK,SAAS,kBAAkB,EAAE,EAC5D,UAAU,EACV,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAqDhD"}
|
package/dist/auth/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { AuthCollectionSlug, LoginResult, MaybePromise, SanitizedConfig } from 'payload'\n\nimport { getPayload } from 'payload'\n\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\ntype LoginWithEmail<TSlug extends AuthCollectionSlug> = {\n collection: TSlug\n config: MaybePromise<SanitizedConfig>\n email: string\n password: string\n username?: never\n}\n\ntype LoginWithUsername<TSlug extends AuthCollectionSlug> = {\n collection: TSlug\n config: MaybePromise<SanitizedConfig>\n email?: never\n password: string\n username: string\n}\ntype LoginArgs<TSlug extends AuthCollectionSlug> = LoginWithEmail<TSlug> | LoginWithUsername<TSlug>\n\nexport async function login<TSlug extends AuthCollectionSlug>({\n collection,\n config,\n email,\n password,\n username,\n}: LoginArgs<TSlug>): Promise<LoginResult<TSlug>> {\n const payload = await getPayload({ config, cron: true })\n\n const authConfig = payload.collections[collection]?.config.auth\n\n if (!authConfig) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const loginWithUsername = authConfig?.loginWithUsername ?? false\n\n if (loginWithUsername) {\n if (loginWithUsername.allowEmailLogin) {\n if (!email && !username) {\n throw new Error('Email or username is required.')\n }\n } else {\n if (!username) {\n throw new Error('Username is required.')\n }\n }\n } else {\n if (!email) {\n throw new Error('Email is required.')\n }\n }\n\n let loginData\n\n if (loginWithUsername) {\n loginData = username ? { password, username } : { email, password }\n } else {\n loginData = { email, password }\n }\n\n const result = await payload.login({\n collection,\n data: loginData,\n })\n\n if (result.token) {\n await setPayloadAuthCookie({\n authConfig,\n cookiePrefix: payload.config.cookiePrefix,\n token: result.token,\n })\n }\n\n if ('removeTokenFromResponses' in config && config.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n"],"mappings":"AAAA;;AAIA,SAASA,UAAU,QAAQ;AAE3B,SAASC,oBAAoB,QAAQ;AAmBrC,OAAO,eAAeC,MAAwC;EAC5DC,UAAU;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AE;IAC3E,OAAOJ,MAAA,CAAOE,KAAK;EACrB;EAEA,OAAOF,MAAA;AACT","ignoreList":[]}
|
package/dist/auth/logout.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SanitizedConfig } from 'payload';
|
|
1
|
+
import type { MaybePromise, SanitizedConfig } from 'payload';
|
|
2
2
|
export declare function logout({ allSessions, config, }: {
|
|
3
3
|
allSessions?: boolean;
|
|
4
|
-
config:
|
|
4
|
+
config: MaybePromise<SanitizedConfig>;
|
|
5
5
|
}): Promise<{
|
|
6
6
|
message: string;
|
|
7
7
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO5D,wBAAsB,MAAM,CAAC,EAC3B,WAAmB,EACnB,MAAM,GACP,EAAE;IACD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;CACtC;;;GA8BA"}
|
package/dist/auth/logout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { SanitizedConfig } from 'payload'\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config:
|
|
1
|
+
{"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { MaybePromise, SanitizedConfig } from 'payload'\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config: MaybePromise<SanitizedConfig>\n}) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const authResult = await payload.auth({ headers })\n\n if (!authResult.user) {\n return { message: 'User already logged out', success: true }\n }\n\n const { user } = authResult\n const req = await createLocalReq({ user }, payload)\n const collection = payload.collections[user.collection]\n\n const logoutResult = await logoutOperation({\n allSessions,\n collection,\n req,\n })\n\n if (!logoutResult) {\n return { message: 'Logout failed', success: false }\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (existingCookie) {\n const cookies = await getCookies()\n cookies.delete(existingCookie.name)\n }\n\n return { message: 'User logged out successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,UAAU,EAAEC,OAAA,IAAWC,WAAW,QAAQ;AAC9D,SAASC,cAAc,EAAEC,UAAU,EAAEC,eAAe,QAAQ;AAE5D,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,OAAO;EAC3BC,WAAA,GAAc,KAAK;EACnBC;AAAM,CAIP;EACC,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,UAAA,GAAa,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAEhD,IAAI,CAACW,UAAA,CAAWE,IAAI,EAAE;IACpB,OAAO;MAAEC,OAAA,EAAS;MAA2BC,OAAA,EAAS;IAAK;EAC7D;EAEA,MAAM;IAAEF;EAAI,CAAE,GAAGF,UAAA;EACjB,MAAMK,GAAA,GAAM,MAAMd,cAAA,CAAe;IAAEW;EAAK,GAAGJ,OAAA;EAC3C,MAAMQ,UAAA,GAAaR,OAAA,CAAQS,WAAW,CAACL,IAAA,CAAKI,UAAU,CAAC;EAEvD,MAAME,YAAA,GAAe,MAAMf,eAAA,CAAgB;IACzCG,WAAA;IACAU,UAAA;IACAD;EACF;EAEA,IAAI,CAACG,YAAA,EAAc;IACjB,OAAO;MAAEL,OAAA,EAAS;MAAiBC,OAAA,EAAS;IAAM;EACpD;EAEA,MAAMK,cAAA,GAAiB,MAAMf,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACa,YAAY;EAC7E,IAAID,cAAA,EAAgB;IAClB,MAAMtB,OAAA,GAAU,MAAMC,UAAA;IACtBD,OAAA,CAAQwB,MAAM,CAACF,cAAA,CAAeG,IAAI;EACpC;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
|
package/dist/auth/refresh.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAQ5E,wBAAsB,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;CAAE;;;GAuClF"}
|
package/dist/auth/refresh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config:
|
|
1
|
+
{"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug, MaybePromise, SanitizedConfig } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config: MaybePromise<SanitizedConfig> }) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const result = await payload.auth({ headers })\n\n if (!result.user) {\n throw new Error('Cannot refresh token: user not authenticated')\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (!existingCookie) {\n return { message: 'No valid token found to refresh', success: false }\n }\n\n const collection: CollectionSlug | undefined = result.user.collection\n const collectionConfig = payload.collections[collection]\n\n if (!collectionConfig?.config.auth) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const req = await createLocalReq({ user: result.user }, payload)\n\n const refreshResult = await refreshOperation({\n collection: collectionConfig,\n req,\n })\n\n if (!refreshResult) {\n return { message: 'Token refresh failed', success: false }\n }\n\n await setPayloadAuthCookie({\n authConfig: collectionConfig.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n token: refreshResult.refreshedToken,\n })\n\n return { message: 'Token refreshed successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,WAAW,QAAQ;AACvC,SAASC,cAAc,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ;AAE7D,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,QAAQ;EAAEC;AAAM,CAA6C;EACjF,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,MAAA,GAAS,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAE5C,IAAI,CAACW,MAAA,CAAOE,IAAI,EAAE;IAChB,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAMC,cAAA,GAAiB,MAAMV,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACQ,YAAY;EAC7E,IAAI,CAACD,cAAA,EAAgB;IACnB,OAAO;MAAEE,OAAA,EAAS;MAAmCC,OAAA,EAAS;IAAM;EACtE;EAEA,MAAMC,UAAA,GAAyCR,MAAA,CAAOE,IAAI,CAACM,UAAU;EACrE,MAAMC,gBAAA,GAAmBX,OAAA,CAAQY,WAAW,CAACF,UAAA,CAAW;EAExD,IAAI,CAACC,gBAAA,EAAkBZ,MAAA,CAAOI,IAAA,EAAM;IAClC,MAAM,IAAIE,KAAA,CAAM,wCAAwCK,UAAA,EAAY;EACtE;EAEA,MAAMG,GAAA,GAAM,MAAMpB,cAAA,CAAe;IAAEW,IAAA,EAAMF,MAAA,CAAOE;EAAK,GAAGJ,OAAA;EAExD,MAAMc,aAAA,GAAgB,MAAMnB,gBAAA,CAAiB;IAC3Ce,UAAA,EAAYC,gBAAA;IACZE;EACF;EAEA,IAAI,CAACC,aAAA,EAAe;IAClB,OAAO;MAAEN,OAAA,EAAS;MAAwBC,OAAA,EAAS;IAAM;EAC3D;EAEA,MAAMZ,oBAAA,CAAqB;IACzBkB,UAAA,EAAYJ,gBAAA,CAAiBZ,MAAM,CAACI,IAAI;IACxCI,YAAA,EAAcP,OAAA,CAAQD,MAAM,CAACQ,YAAY;IACzCS,KAAA,EAAOF,aAAA,CAAcG;EACvB;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,qBAAqB,EAAE,MAAM,SAAS,CAAA;AA+B/F,eAAO,MAAM,qBAAqB,EAAE,qBA+BnC,CAAA"}
|
|
@@ -33,6 +33,9 @@ export const handleServerFunctions = async args => {
|
|
|
33
33
|
serverFunctions: extraServerFunctions
|
|
34
34
|
} = args;
|
|
35
35
|
const {
|
|
36
|
+
cookies,
|
|
37
|
+
locale,
|
|
38
|
+
permissions,
|
|
36
39
|
req
|
|
37
40
|
} = await initReq({
|
|
38
41
|
configPromise,
|
|
@@ -41,14 +44,13 @@ export const handleServerFunctions = async args => {
|
|
|
41
44
|
});
|
|
42
45
|
const augmentedArgs = {
|
|
43
46
|
...fnArgs,
|
|
47
|
+
cookies,
|
|
44
48
|
importMap,
|
|
49
|
+
locale,
|
|
50
|
+
permissions,
|
|
45
51
|
req
|
|
46
52
|
};
|
|
47
|
-
const
|
|
48
|
-
...baseServerFunctions,
|
|
49
|
-
...(extraServerFunctions || {})
|
|
50
|
-
};
|
|
51
|
-
const fn = serverFunctions[fnKey];
|
|
53
|
+
const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey];
|
|
52
54
|
if (!fn) {
|
|
53
55
|
throw new Error(`Unknown Server Function: ${fnKey}`);
|
|
54
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.js","names":["_internal_renderFieldHandler","copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","getFolderResultsComponentAndDataHandler","schedulePublishHandler","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","slugifyHandler","baseServerFunctions","slugify","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","req","key","augmentedArgs","fn","Error"],"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { _internal_renderFieldHandler, copyDataFromLocaleHandler } from '@payloadcms/ui/rsc'\nimport { buildFormStateHandler } from '@payloadcms/ui/utilities/buildFormState'\nimport { buildTableStateHandler } from '@payloadcms/ui/utilities/buildTableState'\nimport { getFolderResultsComponentAndDataHandler } from '@payloadcms/ui/utilities/getFolderResultsComponentAndData'\nimport { schedulePublishHandler } from '@payloadcms/ui/utilities/schedulePublishHandler'\n\nimport { getDefaultLayoutHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js'\nimport { renderWidgetHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js'\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { initReq } from './initReq.js'\nimport { slugifyHandler } from './slugify.js'\n\nconst baseServerFunctions: Record<string, ServerFunction<any, any>> = {\n 'copy-data-from-locale': copyDataFromLocaleHandler,\n 'form-state': buildFormStateHandler,\n 'get-default-layout': getDefaultLayoutHandler,\n 'get-folder-results-component-and-data': getFolderResultsComponentAndDataHandler,\n 'render-document': renderDocumentHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-list': renderListHandler,\n 'render-widget': renderWidgetHandler,\n 'schedule-publish': schedulePublishHandler,\n slugify: slugifyHandler,\n 'table-state': buildTableStateHandler,\n}\n\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { req } = await initReq({\n configPromise,\n importMap,\n key: 'RootLayout',\n })\n\n const augmentedArgs:
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.js","names":["_internal_renderFieldHandler","copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","getFolderResultsComponentAndDataHandler","schedulePublishHandler","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","slugifyHandler","baseServerFunctions","slugify","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","cookies","locale","permissions","req","key","augmentedArgs","fn","Error"],"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { DefaultServerFunctionArgs, ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { _internal_renderFieldHandler, copyDataFromLocaleHandler } from '@payloadcms/ui/rsc'\nimport { buildFormStateHandler } from '@payloadcms/ui/utilities/buildFormState'\nimport { buildTableStateHandler } from '@payloadcms/ui/utilities/buildTableState'\nimport { getFolderResultsComponentAndDataHandler } from '@payloadcms/ui/utilities/getFolderResultsComponentAndData'\nimport { schedulePublishHandler } from '@payloadcms/ui/utilities/schedulePublishHandler'\n\nimport { getDefaultLayoutHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js'\nimport { renderWidgetHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js'\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { initReq } from './initReq.js'\nimport { slugifyHandler } from './slugify.js'\n\nconst baseServerFunctions: Record<string, ServerFunction<any, any>> = {\n 'copy-data-from-locale': copyDataFromLocaleHandler,\n 'form-state': buildFormStateHandler,\n 'get-default-layout': getDefaultLayoutHandler,\n 'get-folder-results-component-and-data': getFolderResultsComponentAndDataHandler,\n 'render-document': renderDocumentHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-list': renderListHandler,\n 'render-widget': renderWidgetHandler,\n 'schedule-publish': schedulePublishHandler,\n slugify: slugifyHandler,\n 'table-state': buildTableStateHandler,\n}\n\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { cookies, locale, permissions, req } = await initReq({\n configPromise,\n importMap,\n key: 'RootLayout',\n })\n\n const augmentedArgs: DefaultServerFunctionArgs = {\n ...fnArgs,\n cookies,\n importMap,\n locale,\n permissions,\n req,\n }\n\n const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey]\n\n if (!fn) {\n throw new Error(`Unknown Server Function: ${fnKey}`)\n }\n\n return fn(augmentedArgs)\n}\n"],"mappings":"AAEA,SAASA,4BAA4B,EAAEC,yBAAyB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,uCAAuC,QAAQ;AACxD,SA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
|
-
import type { ImportMap, Locale, PayloadRequest, SanitizedConfig, SanitizedPermissions } from 'payload';
|
|
3
|
-
import { headers as getHeaders } from 'next/headers.js';
|
|
1
|
+
import type { ImportMap, InitReqResult, SanitizedConfig } from 'payload';
|
|
4
2
|
import { createLocalReq } from 'payload';
|
|
5
|
-
type Result = {
|
|
6
|
-
cookies: Map<string, string>;
|
|
7
|
-
headers: Awaited<ReturnType<typeof getHeaders>>;
|
|
8
|
-
languageCode: AcceptedLanguages;
|
|
9
|
-
locale?: Locale;
|
|
10
|
-
permissions: SanitizedPermissions;
|
|
11
|
-
req: PayloadRequest;
|
|
12
|
-
};
|
|
13
3
|
/**
|
|
14
4
|
* Initializes a full request object, including the `req` object and access control.
|
|
15
5
|
* As access control and getting the request locale is dependent on the current URL and
|
|
@@ -20,6 +10,5 @@ export declare const initReq: ({ canSetHeaders, configPromise, importMap, key, o
|
|
|
20
10
|
importMap: ImportMap;
|
|
21
11
|
key: string;
|
|
22
12
|
overrides?: Parameters<typeof createLocalReq>[0];
|
|
23
|
-
}) => Promise<
|
|
24
|
-
export {};
|
|
13
|
+
}) => Promise<InitReqResult>;
|
|
25
14
|
//# sourceMappingURL=initReq.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initReq.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initReq.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAA;AAIxF,OAAO,EACL,cAAc,EAMf,MAAM,SAAS,CAAA;AAchB;;;GAGG;AACH,eAAO,MAAM,OAAO,iEAMjB;IACD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;CACjD,KAAG,OAAO,CAAC,aAAa,CA0FxB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initReq.js","names":["initI18n","headers","getHeaders","createLocalReq","executeAuthStrategies","getAccessResults","getPayload","getRequestLanguage","parseCookies","getRequestLocale","selectiveCache","partialReqCache","reqCache","initReq","canSetHeaders","configPromise","importMap","key","overrides","cookies","partialResult","get","config","payload","cron","languageCode","i18n","context","language","responseHeaders","user","req","reqOverrides","optionsOverrides","host","locale","code","permissions","then","result"],"sources":["../../src/utilities/initReq.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"initReq.js","names":["initI18n","headers","getHeaders","createLocalReq","executeAuthStrategies","getAccessResults","getPayload","getRequestLanguage","parseCookies","getRequestLocale","selectiveCache","partialReqCache","reqCache","initReq","canSetHeaders","configPromise","importMap","key","overrides","cookies","partialResult","get","config","payload","cron","languageCode","i18n","context","language","responseHeaders","user","req","reqOverrides","optionsOverrides","host","locale","code","permissions","then","result"],"sources":["../../src/utilities/initReq.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type { ImportMap, InitReqResult, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { headers as getHeaders } from 'next/headers.js'\nimport {\n createLocalReq,\n executeAuthStrategies,\n getAccessResults,\n getPayload,\n getRequestLanguage,\n parseCookies,\n} from 'payload'\n\nimport { getRequestLocale } from './getRequestLocale.js'\nimport { selectiveCache } from './selectiveCache.js'\n\ntype PartialResult = {\n i18n: I18nClient\n} & Pick<InitReqResult, 'languageCode'> &\n Pick<PayloadRequest, 'payload' | 'responseHeaders' | 'user'>\n\n// Create cache instances for different parts of our application\nconst partialReqCache = selectiveCache<PartialResult>('partialReq')\nconst reqCache = selectiveCache<InitReqResult>('req')\n\n/**\n * Initializes a full request object, including the `req` object and access control.\n * As access control and getting the request locale is dependent on the current URL and\n */\nexport const initReq = async function ({\n canSetHeaders,\n configPromise,\n importMap,\n key,\n overrides,\n}: {\n canSetHeaders?: boolean\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n key: string\n overrides?: Parameters<typeof createLocalReq>[0]\n}): Promise<InitReqResult> {\n const headers = await getHeaders()\n const cookies = parseCookies(headers)\n\n const partialResult = await partialReqCache.get(async () => {\n const config = await configPromise\n const payload = await getPayload({ config, cron: true, importMap })\n const languageCode = getRequestLanguage({\n config,\n cookies,\n headers,\n })\n\n const i18n: I18nClient = await initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n\n const { responseHeaders, user } = await executeAuthStrategies({\n canSetHeaders,\n headers,\n payload,\n })\n\n return {\n i18n,\n languageCode,\n payload,\n responseHeaders,\n user,\n }\n }, 'global')\n\n return reqCache\n .get(async () => {\n const { i18n, languageCode, payload, responseHeaders, user } = partialResult\n\n const { req: reqOverrides, ...optionsOverrides } = overrides || {}\n\n const req = await createLocalReq(\n {\n req: {\n headers,\n host: headers.get('host'),\n i18n: i18n as I18n,\n responseHeaders,\n user,\n ...(reqOverrides || {}),\n },\n ...(optionsOverrides || {}),\n },\n payload,\n )\n\n const locale = await getRequestLocale({\n req,\n })\n\n req.locale = locale?.code\n\n const permissions = await getAccessResults({\n req,\n })\n\n return {\n cookies,\n headers,\n languageCode,\n locale,\n permissions,\n req,\n }\n }, key)\n .then((result) => {\n // CRITICAL: Create a shallow copy of req before returning to prevent\n // mutations from propagating to the cached req object.\n // This ensures parallel operations using the same cache key don't affect each other.\n return {\n ...result,\n req: {\n ...result.req,\n ...(result.req?.context\n ? {\n context: { ...result.req.context },\n }\n : {}),\n },\n }\n })\n}\n"],"mappings":"AAGA,SAASA,QAAQ,QAAQ;AACzB,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SACEC,cAAc,EACdC,qBA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a,CAAC;IAEjE,MAAMa,GAAA,GAAM,MAAM5B,cAAA,CAChB;MACE4B,GAAA,EAAK;QACH9B,OAAA;QACAiC,IAAA,EAAMjC,OAAA,CAAQoB,GAAG,CAAC;QAClBK,IAAA,EAAMA,IAAA;QACNG,eAAA;QACAC,IAAA;QACA,IAAIE,YAAA,IAAgB,CAAC,CAAC;MACxB;MACA,IAAIC,gBAAA,IAAoB,CAAC,CAAC;IAC5B,GACAV,OAAA;IAGF,MAAMY,MAAA,GAAS,MAAM1B,gBAAA,CAAiB;MACpCsB;IACF;IAEAA,GAAA,CAAII,MAAM,GAAGA,MAAA,EAAQC,IAAA;IAErB,MAAMC,WAAA,GAAc,MAAMhC,gBAAA,CAAiB;MACzC0B;IACF;IAEA,OAAO;MACLZ,OAAA;MACAlB,OAAA;MACAwB,YAAA;MACAU,MAAA;MACAE,WAAA;MACAN;IACF;EACF,GAAGd,GAAA,EACFqB,IAAI,CAAEC,MAAA;IACL;IACA;IACA;IACA,OAAO;MACL,GAAGA,MAAM;MACTR,GAAA,EAAK;QACH,GAAGQ,MAAA,CAAOR,GAAG;QACb,IAAIQ,MAAA,CAAOR,GAAG,EAAEJ,OAAA,GACZ;UACEA,OAAA,EAAS;YAAE,GAAGY,MAAA,CAAOR,GAAG,CAACJ;UAAQ;QACnC,IACA,CAAC,CAAC;MACR;IACF;EACF;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,OAAO,cAAc,CAAA;AAIrB,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,OAAO,cAAc,CAAA;AAIrB,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,8BA6CrE"}
|
|
@@ -15,6 +15,9 @@ export async function ModularDashboard(props) {
|
|
|
15
15
|
user
|
|
16
16
|
} = props;
|
|
17
17
|
const {
|
|
18
|
+
cookies,
|
|
19
|
+
locale,
|
|
20
|
+
permissions,
|
|
18
21
|
req
|
|
19
22
|
} = props.initPageResult;
|
|
20
23
|
const {
|
|
@@ -28,6 +31,9 @@ export async function ModularDashboard(props) {
|
|
|
28
31
|
Component: widgets.find(widget => widget.slug === widgetSlug)?.ComponentPath,
|
|
29
32
|
importMap,
|
|
30
33
|
serverProps: {
|
|
34
|
+
cookies,
|
|
35
|
+
locale,
|
|
36
|
+
permissions,
|
|
31
37
|
req,
|
|
32
38
|
widgetSlug
|
|
33
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RenderServerComponent","React","getPreferences","ModularDashboardClient","ModularDashboard","props","defaultLayout","widgets","payload","config","admin","dashboard","importMap","user","req","initPageResult","i18n","layout","getItemsFromPreferences","getItemsFromConfig","serverLayout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","ComponentPath","serverProps","item","clientWidgets","_","label","rest","t","_jsx","clientLayout","savedPreferences","collection","value","layouts","widgetInstances","widgetInstance","index","maxWidth","minWidth","width"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type {\n BasePayload,\n ClientWidget,\n DashboardConfig,\n PayloadRequest,\n TypedUser,\n Widget,\n WidgetInstance,\n WidgetServerProps,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport type { DashboardViewServerProps } from '../index.js'\nimport type { WidgetInstanceClient, WidgetItem } from './index.client.js'\n\nimport { getPreferences } from '../../../../utilities/getPreferences.js'\nimport { ModularDashboardClient } from './index.client.js'\nimport './index.scss'\n\ntype ServerLayout = WidgetInstanceClient[]\n\nexport async function ModularDashboard(props: DashboardViewServerProps) {\n const { defaultLayout = [], widgets = [] } = props.payload.config.admin.dashboard || {}\n const { importMap } = props.payload\n const { user } = props\n const { req } = props.initPageResult\n const { i18n } = req\n\n const layout =\n (await getItemsFromPreferences(props.payload, user)) ??\n (await getItemsFromConfig(defaultLayout, req, widgets))\n\n const serverLayout: ServerLayout = layout.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.ComponentPath,\n importMap,\n serverProps: {\n req,\n widgetSlug,\n // TODO: widgets will support state in the future\n // widgetData: layoutItem.data,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n // Resolve function labels to static labels for client components\n const clientWidgets: ClientWidget[] = widgets.map((widget) => {\n const { ComponentPath: _, label, ...rest } = widget\n return {\n ...rest,\n label: typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n })\n\n return (\n <div>\n <ModularDashboardClient clientLayout={serverLayout} widgets={clientWidgets} />\n </div>\n )\n}\n\nasync function getItemsFromPreferences(\n payload: BasePayload,\n user: TypedUser,\n): Promise<null | WidgetItem[]> {\n const savedPreferences = await getPreferences(\n 'dashboard-layout',\n payload,\n user.id,\n user.collection,\n )\n if (\n !savedPreferences?.value ||\n typeof savedPreferences.value !== 'object' ||\n !('layouts' in savedPreferences.value)\n ) {\n return null\n }\n return savedPreferences.value.layouts as null | WidgetItem[]\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Widget[],\n): Promise<WidgetItem[]> {\n // Handle function format\n let widgetInstances: WidgetInstance[]\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((widget) => widget.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":";AAYA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAKlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,sBAAsB,QAAQ;AAKvC,OAAO,eAAeC,iBAAiBC,KAA+B;EACpE,MAAM;IAAEC,aAAA,GAAgB,EAAE;IAAEC,OAAA,GAAU;EAAE,CAAE,GAAGF,KAAA,CAAMG,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS,IAAI,CAAC;EACtF,MAAM;IAAEC;EAAS,CAAE,GAAGP,KAAA,CAAMG,OAAO;EACnC,MAAM;IAAEK;EAAI,CAAE,GAAGR,KAAA;EACjB,MAAM;IAAES;EAAG,CAAE,
|
|
1
|
+
{"version":3,"file":"index.js","names":["RenderServerComponent","React","getPreferences","ModularDashboardClient","ModularDashboard","props","defaultLayout","widgets","payload","config","admin","dashboard","importMap","user","cookies","locale","permissions","req","initPageResult","i18n","layout","getItemsFromPreferences","getItemsFromConfig","serverLayout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","ComponentPath","serverProps","item","clientWidgets","_","label","rest","t","_jsx","clientLayout","savedPreferences","collection","value","layouts","widgetInstances","widgetInstance","index","maxWidth","minWidth","width"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type {\n BasePayload,\n ClientWidget,\n DashboardConfig,\n PayloadRequest,\n TypedUser,\n Widget,\n WidgetInstance,\n WidgetServerProps,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport type { DashboardViewServerProps } from '../index.js'\nimport type { WidgetInstanceClient, WidgetItem } from './index.client.js'\n\nimport { getPreferences } from '../../../../utilities/getPreferences.js'\nimport { ModularDashboardClient } from './index.client.js'\nimport './index.scss'\n\ntype ServerLayout = WidgetInstanceClient[]\n\nexport async function ModularDashboard(props: DashboardViewServerProps) {\n const { defaultLayout = [], widgets = [] } = props.payload.config.admin.dashboard || {}\n const { importMap } = props.payload\n const { user } = props\n const { cookies, locale, permissions, req } = props.initPageResult\n const { i18n } = req\n\n const layout =\n (await getItemsFromPreferences(props.payload, user)) ??\n (await getItemsFromConfig(defaultLayout, req, widgets))\n\n const serverLayout: ServerLayout = layout.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.ComponentPath,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n widgetSlug,\n // TODO: widgets will support state in the future\n // widgetData: layoutItem.data,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n // Resolve function labels to static labels for client components\n const clientWidgets: ClientWidget[] = widgets.map((widget) => {\n const { ComponentPath: _, label, ...rest } = widget\n return {\n ...rest,\n label: typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n })\n\n return (\n <div>\n <ModularDashboardClient clientLayout={serverLayout} widgets={clientWidgets} />\n </div>\n )\n}\n\nasync function getItemsFromPreferences(\n payload: BasePayload,\n user: TypedUser,\n): Promise<null | WidgetItem[]> {\n const savedPreferences = await getPreferences(\n 'dashboard-layout',\n payload,\n user.id,\n user.collection,\n )\n if (\n !savedPreferences?.value ||\n typeof savedPreferences.value !== 'object' ||\n !('layouts' in savedPreferences.value)\n ) {\n return null\n }\n return savedPreferences.value.layouts as null | WidgetItem[]\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Widget[],\n): Promise<WidgetItem[]> {\n // Handle function format\n let widgetInstances: WidgetInstance[]\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((widget) => widget.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":";AAYA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAKlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,sBAAsB,QAAQ;AAKvC,OAAO,eAAeC,iBAAiBC,KAA+B;EACpE,MAAM;IAAEC,aAAA,GAAgB,EAAE;IAAEC,OAAA,GAAU;EAAE,CAAE,GAAGF,KAAA,CAAMG,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS,IAAI,CAAC;EACtF,MAAM;IAAEC;EAAS,CAAE,GAAGP,KAAA,CAAMG,OAAO;EACnC,MAAM;IAAEK;EAAI,CAAE,GAAGR,KAAA;EACjB,MAAM;IAAES,OAAO;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGZ,KAAA,CAAMa,cAAc;EAClE,MAAM;IAAEC;EAAI,CAAE,GAAGF,GAAA;EAEjB,MAAMG,MAAA,GACJ,OAAOC,uBAAA,CAAwBhB,KAAA,CAAMG,OAAO,EAAEK,IAAA,OAC7C,MAAMS,kBAAA,CAAmBhB,aAAA,EAAeW,GAAA,EAAKV,OAAA;EAEhD,MAAMgB,YAAA,GAA6BH,MAAA,CAAOI,GAAG,CAAEC,UAAA;IAC7C,MAAMC,UAAA,GAAaD,UAAA,CAAWE,EAAE,CAAC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,IAAI,OAAO3C,aAAA,KAAkB,YAAY;IACvC2C,eAAA,GAAkB,MAAM3C,aAAA,CAAc;MAAEW;IAAI;EAC9C,OAAO;IACLgC,eAAA,GAAkB3C,aAAA;EACpB;EAEA,OAAO2C,eAAA,CAAgBzB,GAAG,CAAC,CAAC0B,cAAA,EAAgBC,KAAA;IAC1C,MAAMlB,MAAA,GAAS1B,OAAA,CAAQyB,IAAI,CAAEC,MAAA,IAAWA,MAAA,CAAOC,IAAI,KAAKgB,cAAA,CAAexB,UAAU;IACjF,OAAO;MACLC,EAAA,EAAI,GAAGuB,cAAA,CAAexB,UAAU,IAAIyB,KAAA,EAAO;MAC3CC,QAAA,EAAUnB,MAAA,EAAQmB,QAAA,IAAY;MAC9BC,QAAA,EAAUpB,MAAA,EAAQoB,QAAA,IAAY;MAC9BC,KAAA,EAAOJ,cAAA,CAAeI,KAAK,IAAI;IACjC;EACF;AACF","ignoreList":[]}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLayoutServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,oBAAoB,CAAA;AAE1E,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,oBAAoB,EAAE,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,4BAA4B,EAC5B,OAAO,CAAC,kCAAkC,CAAC,
|
|
1
|
+
{"version":3,"file":"getDefaultLayoutServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,oBAAoB,CAAA;AAE1E,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,oBAAoB,EAAE,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,4BAA4B,EAC5B,OAAO,CAAC,kCAAkC,CAAC,CA8B5C,CAAA"}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js
CHANGED
|
@@ -4,6 +4,9 @@ import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerCompo
|
|
|
4
4
|
* Used when resetting the dashboard to its default configuration.
|
|
5
5
|
*/
|
|
6
6
|
export const getDefaultLayoutHandler = async ({
|
|
7
|
+
cookies,
|
|
8
|
+
locale,
|
|
9
|
+
permissions,
|
|
7
10
|
req
|
|
8
11
|
}) => {
|
|
9
12
|
if (!req.user) {
|
|
@@ -24,6 +27,9 @@ export const getDefaultLayoutHandler = async ({
|
|
|
24
27
|
Component: widgets.find(widget => widget.slug === widgetSlug)?.ComponentPath,
|
|
25
28
|
importMap,
|
|
26
29
|
serverProps: {
|
|
30
|
+
cookies,
|
|
31
|
+
locale,
|
|
32
|
+
permissions,
|
|
27
33
|
req,
|
|
28
34
|
widgetSlug
|
|
29
35
|
}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLayoutServerFn.js","names":["RenderServerComponent","getDefaultLayoutHandler","req","user","Error","defaultLayout","widgets","payload","config","admin","dashboard","importMap","layoutItems","getItemsFromConfig","layout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","ComponentPath","serverProps","item","widgetInstances","widgetInstance","index","w","maxWidth","minWidth","width"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"sourcesContent":["import type {\n DashboardConfig,\n PayloadRequest,\n ServerFunction,\n Widget,\n WidgetServerProps,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\n\nimport type { WidgetInstanceClient, WidgetItem } from '../index.client.js'\n\nexport type GetDefaultLayoutServerFnArgs = Record<string, never>\n\nexport type GetDefaultLayoutServerFnReturnType = {\n layout: WidgetInstanceClient[]\n}\n\n/**\n * Server function to get the default dashboard layout on-demand.\n * Used when resetting the dashboard to its default configuration.\n */\nexport const getDefaultLayoutHandler: ServerFunction<\n GetDefaultLayoutServerFnArgs,\n Promise<GetDefaultLayoutServerFnReturnType>\n> = async ({ req }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { defaultLayout = [], widgets = [] } = req.payload.config.admin.dashboard || {}\n const { importMap } = req.payload\n\n const layoutItems = await getItemsFromConfig(defaultLayout, req, widgets)\n\n const layout: WidgetInstanceClient[] = layoutItems.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.ComponentPath,\n importMap,\n serverProps: {\n req,\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n return { layout }\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Widget[],\n): Promise<WidgetItem[]> {\n // Handle function format\n let widgetInstances\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((w) => w.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":"AAQA,SAASA,qBAAqB,QAAQ;AAUtC;;;;AAIA,OAAO,MAAMC,uBAAA,GAGT,MAAAA,CAAO;EAAEC;AAAG,CAAE;
|
|
1
|
+
{"version":3,"file":"getDefaultLayoutServerFn.js","names":["RenderServerComponent","getDefaultLayoutHandler","cookies","locale","permissions","req","user","Error","defaultLayout","widgets","payload","config","admin","dashboard","importMap","layoutItems","getItemsFromConfig","layout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","ComponentPath","serverProps","item","widgetInstances","widgetInstance","index","w","maxWidth","minWidth","width"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"sourcesContent":["import type {\n DashboardConfig,\n PayloadRequest,\n ServerFunction,\n Widget,\n WidgetServerProps,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\n\nimport type { WidgetInstanceClient, WidgetItem } from '../index.client.js'\n\nexport type GetDefaultLayoutServerFnArgs = Record<string, never>\n\nexport type GetDefaultLayoutServerFnReturnType = {\n layout: WidgetInstanceClient[]\n}\n\n/**\n * Server function to get the default dashboard layout on-demand.\n * Used when resetting the dashboard to its default configuration.\n */\nexport const getDefaultLayoutHandler: ServerFunction<\n GetDefaultLayoutServerFnArgs,\n Promise<GetDefaultLayoutServerFnReturnType>\n> = async ({ cookies, locale, permissions, req }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { defaultLayout = [], widgets = [] } = req.payload.config.admin.dashboard || {}\n const { importMap } = req.payload\n\n const layoutItems = await getItemsFromConfig(defaultLayout, req, widgets)\n\n const layout: WidgetInstanceClient[] = layoutItems.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.ComponentPath,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n return { layout }\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Widget[],\n): Promise<WidgetItem[]> {\n // Handle function format\n let widgetInstances\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((w) => w.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":"AAQA,SAASA,qBAAqB,QAAQ;AAUtC;;;;AAIA,OAAO,MAAMC,uBAAA,GAGT,MAAAA,CAAO;EAAEC,OAAO;EAAEC,MAAM;EAAEC,WAAW;EAAEC;AAAG,CAAE;EAC9C,IAAI,CAACA,GAAA,CAAIC,IAAI,EAAE;IACb,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAM;IAAEC,aAAA,GAAgB,EAAE;IAAEC,OAAA,GAAU;EAAE,CAAE,GAAGJ,GAAA,CAAIK,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS,IAAI,CAAC;EACpF,MAAM;IAAEC;EAAS,CAAE,GAAGT,GAAA,CAAIK,OAAO;EAEjC,MAAMK,WAAA,GAAc,MAAMC,kBAAA,CAAmBR,aAAA,EAAeH,GAAA,EAAKI,OAAA;EAEjE,MAAMQ,MAAA,GAAiCF,WAAA,CAAYG,GAAG,CAAEC,UAAA;IACtD,MAAMC,UAAA,GAAaD,UAAA,CAAWE,EAAE,CAACC,KAAK,CAAC,GAAGH,UAAA,CAAWE,EAAE,CAACE,WAAW,CAAC;IACpE,OAAO;MACLC,SAAA,EAAWxB,qBAAA,CAAsB;QAC/ByB,SAAA,EAAWhB,OAAA,CAAQiB,IAAI,CAAEC,MAAA,IAAWA,MAAA,CAAOC,IAAI,KAAKR,UAAA,GAAaS,aAAA;QACjEf,SAAA;QACAgB,WAAA,EAAa;UACX5B,OAAA;UACAC,MAAA;UACAC,WAAA;UACAC,GAAA;UACAe;QACF;MACF;MACAW,IAAA,EAAMZ;IACR;EACF;EAEA,OAAO;IAAEF;EAAO;AAClB;AAEA,eAAeD,mBACbR,aAA4D,EAC5DH,GAAmB,EACnBI,OAAiB;EAEjB;EACA,IAAIuB,eAAA;EACJ,IAAI,OAAOxB,aAAA,KAAkB,YAAY;IACvCwB,eAAA,GAAkB,MAAMxB,aAAA,CAAc;MAAEH;IAAI;EAC9C,OAAO;IACL2B,eAAA,GAAkBxB,aAAA;EACpB;EAEA,OAAOwB,eAAA,CAAgBd,GAAG,CAAC,CAACe,cAAA,EAAgBC,KAAA;IAC1C,MAAMP,MAAA,GAASlB,OAAA,CAAQiB,IAAI,CAAES,CAAA,IAAMA,CAAA,CAAEP,IAAI,KAAKK,cAAA,CAAeb,UAAU;IACvE,OAAO;MACLC,EAAA,EAAI,GAAGY,cAAA,CAAeb,UAAU,IAAIc,KAAA,EAAO;MAC3CE,QAAA,EAAUT,MAAA,EAAQS,QAAA,IAAY;MAC9BC,QAAA,EAAUV,MAAA,EAAQU,QAAA,IAAY;MAC9BC,KAAA,EAAOL,cAAA,CAAeK,KAAK,IAAI;IACjC;EACF;AACF","ignoreList":[]}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWidgetServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,SAAS,CAAA;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IAGH;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAC9C,wBAAwB,EACxB,8BAA8B,
|
|
1
|
+
{"version":3,"file":"renderWidgetServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,SAAS,CAAA;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IAGH;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAC9C,wBAAwB,EACxB,8BAA8B,CA2E/B,CAAA"}
|
|
@@ -5,8 +5,11 @@ import React from 'react';
|
|
|
5
5
|
* Similar to render-field but specifically for dashboard widgets.
|
|
6
6
|
*/
|
|
7
7
|
export const renderWidgetHandler = ({
|
|
8
|
+
cookies,
|
|
9
|
+
locale,
|
|
10
|
+
permissions,
|
|
8
11
|
req,
|
|
9
|
-
|
|
12
|
+
widgetSlug
|
|
10
13
|
}) => {
|
|
11
14
|
if (!req.user) {
|
|
12
15
|
throw new Error('Unauthorized');
|
|
@@ -38,6 +41,9 @@ export const renderWidgetHandler = ({
|
|
|
38
41
|
const serverProps = {
|
|
39
42
|
req,
|
|
40
43
|
// TODO: widgetData: widgetData || {},
|
|
44
|
+
cookies,
|
|
45
|
+
locale,
|
|
46
|
+
permissions,
|
|
41
47
|
widgetSlug
|
|
42
48
|
};
|
|
43
49
|
// Render the widget server component
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWidgetServerFn.js","names":["RenderServerComponent","React","renderWidgetHandler","req","widgetSlug","user","Error","widgets","payload","config","admin","dashboard","importMap","widgetConfig","find","widget","slug","component","createElement","style","background","border","borderRadius","color","padding","textAlign","serverProps","Component","ComponentPath","error","errorMessage","message","String","logger","err","msg"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"sourcesContent":["import type { ServerFunction, WidgetServerProps } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nexport type RenderWidgetServerFnArgs = {\n /**\n * Instance-specific data for this widget\n */\n // TODO: widgets will support state in the future\n // widgetData?: Record<string, unknown>\n /**\n * The slug of the widget to render\n */\n widgetSlug: string\n}\n\nexport type RenderWidgetServerFnReturnType = {\n component: React.ReactNode\n}\n\n/**\n * Server function to render a widget on-demand.\n * Similar to render-field but specifically for dashboard widgets.\n */\nexport const renderWidgetHandler: ServerFunction<\n RenderWidgetServerFnArgs,\n RenderWidgetServerFnReturnType\n> = ({
|
|
1
|
+
{"version":3,"file":"renderWidgetServerFn.js","names":["RenderServerComponent","React","renderWidgetHandler","cookies","locale","permissions","req","widgetSlug","user","Error","widgets","payload","config","admin","dashboard","importMap","widgetConfig","find","widget","slug","component","createElement","style","background","border","borderRadius","color","padding","textAlign","serverProps","Component","ComponentPath","error","errorMessage","message","String","logger","err","msg"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"sourcesContent":["import type { ServerFunction, WidgetServerProps } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nexport type RenderWidgetServerFnArgs = {\n /**\n * Instance-specific data for this widget\n */\n // TODO: widgets will support state in the future\n // widgetData?: Record<string, unknown>\n /**\n * The slug of the widget to render\n */\n widgetSlug: string\n}\n\nexport type RenderWidgetServerFnReturnType = {\n component: React.ReactNode\n}\n\n/**\n * Server function to render a widget on-demand.\n * Similar to render-field but specifically for dashboard widgets.\n */\nexport const renderWidgetHandler: ServerFunction<\n RenderWidgetServerFnArgs,\n RenderWidgetServerFnReturnType\n> = ({ cookies, locale, permissions, req, widgetSlug }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { widgets } = req.payload.config.admin.dashboard\n const { importMap } = req.payload\n\n // Find the widget configuration\n const widgetConfig = widgets.find((widget) => widget.slug === widgetSlug)\n\n if (!widgetConfig) {\n return {\n component: React.createElement(\n 'div',\n {\n style: {\n background: 'var(--theme-elevation-50)',\n border: '1px solid var(--theme-elevation-200)',\n borderRadius: '4px',\n color: 'var(--theme-text)',\n padding: '20px',\n textAlign: 'center',\n },\n },\n `Widget \"${widgetSlug}\" not found`,\n ),\n }\n }\n\n try {\n // Create server props for the widget\n const serverProps: WidgetServerProps = {\n req,\n // TODO: widgetData: widgetData || {},\n cookies,\n locale,\n permissions,\n widgetSlug,\n }\n\n // Render the widget server component\n const component = RenderServerComponent({\n Component: widgetConfig.ComponentPath,\n importMap,\n serverProps,\n })\n\n return { component }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n\n req.payload.logger.error({\n err: error,\n msg: `Error rendering widget \"${widgetSlug}\": ${errorMessage}`,\n })\n\n return {\n component: React.createElement(\n 'div',\n {\n style: {\n background: 'var(--theme-error-50)',\n border: '1px solid var(--theme-error-200)',\n borderRadius: '4px',\n color: 'var(--theme-error-text)',\n padding: '20px',\n textAlign: 'center',\n },\n },\n 'Error loading widget',\n ),\n }\n }\n}\n"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAkBlB;;;;AAIA,OAAO,MAAMC,mBAAA,GAGTA,CAAC;EAAEC,OAAO;EAAEC,MAAM;EAAEC,WAAW;EAAEC,GAAG;EAAEC;AAAU,CAAE;EACpD,IAAI,CAACD,GAAA,CAAIE,IAAI,EAAE;IACb,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAM;IAAEC;EAAO,CAAE,GAAGJ,GAAA,CAAIK,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS;EACtD,MAAM;IAAEC;EAAS,CAAE,GAAGT,GAAA,CAAIK,OAAO;EAEjC;EACA,MAAMK,YAAA,GAAeN,OAAA,CAAQO,IAAI,CAAEC,MAAA,IAAWA,MAAA,CAAOC,IAAI,KAAKZ,UAAA;EAE9D,IAAI,CAACS,YAAA,EAAc;IACjB,OAAO;MACLI,SAAA,EAAWnB,KAAA,CAAMoB,aAAa,CAC5B,OACA;QACEC,KAAA,EAAO;UACLC,UAAA,EAAY;UACZC,MAAA,EAAQ;UACRC,YAAA,EAAc;UACdC,KAAA,EAAO;UACPC,OAAA,EAAS;UACTC,SAAA,EAAW;QACb;MACF,GACA,WAAWrB,UAAA,aAAuB;IAEtC;EACF;EAEA,IAAI;IACF;IACA,MAAMsB,WAAA,GAAiC;MACrCvB,GAAA;MACA;MACAH,OAAA;MACAC,MAAA;MACAC,WAAA;MACAE;IACF;IAEA;IACA,MAAMa,SAAA,GAAYpB,qBAAA,CAAsB;MACtC8B,SAAA,EAAWd,YAAA,CAAae,aAAa;MACrChB,SAAA;MACAc;IACF;IAEA,OAAO;MAAET;IAAU;EACrB,EAAE,OAAOY,KAAA,EAAO;IACd,MAAMC,YAAA,GAAeD,KAAA,YAAiBvB,KAAA,GAAQuB,KAAA,CAAME,OAAO,GAAGC,MAAA,CAAOH,KAAA;IAErE1B,GAAA,CAAIK,OAAO,CAACyB,MAAM,CAACJ,KAAK,CAAC;MACvBK,GAAA,EAAKL,KAAA;MACLM,GAAA,EAAK,2BAA2B/B,UAAA,MAAgB0B,YAAA;IAClD;IAEA,OAAO;MACLb,SAAA,EAAWnB,KAAA,CAAMoB,aAAa,CAC5B,OACA;QACEC,KAAA,EAAO;UACLC,UAAA,EAAY;UACZC,MAAA,EAAQ;UACRC,YAAA,EAAc;UACdC,KAAA,EAAO;UACPC,OAAA,EAAS;UACTC,SAAA,EAAW;QACb;MACF,GACA;IAEJ;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboardLayout.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/useDashboardLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAW1C,OAAO,
|
|
1
|
+
{"version":3,"file":"useDashboardLayout.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/useDashboardLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAW1C,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,mBAAmB,CAAA;AAKzE,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,oBAAoB,EAAE;4BAmFvD,MAAM;;;;6BAiDR,MAAM;;iDA9DgB;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;;6BAwEpE,MAAM,YAAY,WAAW;;;EA0C3C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { arrayMove } from '@dnd-kit/sortable';
|
|
2
2
|
import { ConfirmationModal, toast, useConfig, useModal, usePreferences, useServerFunctions } from '@payloadcms/ui';
|
|
3
|
-
import React, { useCallback, useState } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
4
|
import { RenderWidget } from './renderWidget/RenderWidget.js';
|
|
5
5
|
export function useDashboardLayout(initialLayout) {
|
|
6
6
|
const setLayoutPreference = useSetLayoutPreference();
|
|
@@ -16,6 +16,12 @@ export function useDashboardLayout(initialLayout) {
|
|
|
16
16
|
const {
|
|
17
17
|
serverFunction
|
|
18
18
|
} = useServerFunctions();
|
|
19
|
+
// Sync state when initialLayout prop changes (e.g., when query params change and server component re-renders)
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!isEditing) {
|
|
22
|
+
setCurrentLayout(initialLayout);
|
|
23
|
+
}
|
|
24
|
+
}, [initialLayout, isEditing]);
|
|
19
25
|
const saveLayout = useCallback(async () => {
|
|
20
26
|
try {
|
|
21
27
|
const layoutData = currentLayout.map(item => item.item);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboardLayout.js","names":["arrayMove","ConfirmationModal","toast","useConfig","useModal","usePreferences","useServerFunctions","React","useCallback","useState","RenderWidget","useDashboardLayout","initialLayout","setLayoutPreference","useSetLayoutPreference","isEditing","setIsEditing","widgets","config","admin","dashboard","currentLayout","setCurrentLayout","openModal","cancelModalSlug","serverFunction","saveLayout","layoutData","map","item","error","resetLayout","result","name","args","layout","performCancel","cancel","hasChanges","length","some","widget","index","initialWidget","id","width","moveWidget","moveFromIndex","moveToIndex","prev","addWidget","widgetSlug","widgetId","Date","now","find","slug","newWidgetInstance","component","createElement","maxWidth","minWidth","setTimeout","element","document","getElementById","scrollIntoView","behavior","block","closest","classList","add","remove","deleteWidget","filter","resizeWidget","newWidth","cancelModal","body","confirmLabel","heading","modalSlug","onConfirm","setPreference","layouts"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/useDashboardLayout.ts"],"sourcesContent":["import type { WidgetWidth } from 'payload'\n\nimport { arrayMove } from '@dnd-kit/sortable'\nimport {\n ConfirmationModal,\n toast,\n useConfig,\n useModal,\n usePreferences,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useState } from 'react'\n\nimport type { WidgetInstanceClient, WidgetItem } from './index.client.js'\nimport type { GetDefaultLayoutServerFnReturnType } from './renderWidget/getDefaultLayoutServerFn.js'\n\nimport { RenderWidget } from './renderWidget/RenderWidget.js'\n\nexport function useDashboardLayout(initialLayout: WidgetInstanceClient[]) {\n const setLayoutPreference = useSetLayoutPreference()\n const [isEditing, setIsEditing] = useState(false)\n const { widgets = [] } = useConfig().config.admin.dashboard ?? {}\n const [currentLayout, setCurrentLayout] = useState<WidgetInstanceClient[]>(initialLayout)\n const { openModal } = useModal()\n const cancelModalSlug = 'cancel-dashboard-changes'\n const { serverFunction } = useServerFunctions()\n\n const saveLayout = useCallback(async () => {\n try {\n const layoutData: WidgetItem[] = currentLayout.map((item) => item.item)\n setIsEditing(false)\n await setLayoutPreference(layoutData)\n } catch {\n setIsEditing(true)\n toast.error('Failed to save layout')\n }\n }, [setLayoutPreference, currentLayout])\n\n const resetLayout = useCallback(async () => {\n try {\n await setLayoutPreference(null)\n\n const result = (await serverFunction({\n name: 'get-default-layout',\n args: {},\n })) as GetDefaultLayoutServerFnReturnType\n\n setCurrentLayout(result.layout)\n setIsEditing(false)\n } catch {\n toast.error('Failed to reset layout')\n }\n }, [setLayoutPreference, serverFunction])\n\n const performCancel = useCallback(() => {\n setCurrentLayout(initialLayout)\n setIsEditing(false)\n }, [initialLayout])\n\n const cancel = useCallback(() => {\n // Check if layout has changed\n const hasChanges =\n currentLayout.length !== initialLayout.length ||\n currentLayout.some((widget, index) => {\n const initialWidget = initialLayout[index]\n return (\n !initialWidget ||\n widget.item.id !== initialWidget.item.id ||\n widget.item.width !== initialWidget.item.width\n )\n })\n\n // If there are changes, show confirmation modal\n if (hasChanges) {\n openModal(cancelModalSlug)\n } else {\n performCancel()\n }\n }, [currentLayout, initialLayout, openModal, cancelModalSlug, performCancel])\n\n const moveWidget = useCallback(\n ({ moveFromIndex, moveToIndex }: { moveFromIndex: number; moveToIndex: number }) => {\n if (moveFromIndex === moveToIndex || moveFromIndex < 0 || moveToIndex < 0) {\n return\n }\n\n setCurrentLayout((prev) => {\n return arrayMove(prev, moveFromIndex, moveToIndex)\n })\n },\n [],\n )\n\n const addWidget = useCallback(\n (widgetSlug: string) => {\n if (!isEditing) {\n return\n }\n\n const widgetId = `${widgetSlug}-${Date.now()}`\n const widget = widgets.find((widget) => widget.slug === widgetSlug)\n\n // Create a new widget instance using RenderWidget\n const newWidgetInstance: WidgetInstanceClient = {\n component: React.createElement(RenderWidget, {\n widgetId,\n // TODO: widgetData can be added here for custom props\n }),\n item: {\n id: widgetId,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widget?.minWidth ?? 'x-small',\n },\n }\n\n setCurrentLayout((prev) => [...prev, newWidgetInstance])\n\n // Scroll to the newly added widget after it's rendered and highlight it\n setTimeout(() => {\n const element = document.getElementById(widgetId)\n if (element) {\n element.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n })\n\n // Add highlight animation to the widget element\n const widget = element.closest('.widget')\n if (widget) {\n widget.classList.add('widget--highlight')\n // Remove the class after animation completes (1.5s fade out)\n setTimeout(() => {\n widget.classList.remove('widget--highlight')\n }, 1500)\n }\n }\n }, 100)\n },\n [isEditing, widgets],\n )\n\n const deleteWidget = useCallback(\n (widgetId: string) => {\n if (!isEditing) {\n return\n }\n setCurrentLayout((prev) => prev.filter((item) => item.item.id !== widgetId))\n },\n [isEditing],\n )\n\n const resizeWidget = useCallback(\n (widgetId: string, newWidth: WidgetWidth) => {\n if (!isEditing) {\n return\n }\n setCurrentLayout((prev) =>\n prev.map((item) =>\n item.item.id === widgetId\n ? {\n ...item,\n item: {\n ...item.item,\n width: newWidth,\n } satisfies WidgetItem,\n }\n : item,\n ),\n )\n },\n [isEditing],\n )\n\n const cancelModal = React.createElement(ConfirmationModal, {\n body: 'You have unsaved changes to your dashboard layout. Are you sure you want to discard them?',\n confirmLabel: 'Discard',\n heading: 'Discard changes?',\n modalSlug: cancelModalSlug,\n onConfirm: performCancel,\n })\n\n return {\n addWidget,\n cancel,\n cancelModal,\n currentLayout,\n deleteWidget,\n isEditing,\n moveWidget,\n resetLayout,\n resizeWidget,\n saveLayout,\n setIsEditing,\n }\n}\n\nfunction useSetLayoutPreference() {\n const { setPreference } = usePreferences()\n return useCallback(\n async (layout: null | WidgetItem[]) => {\n await setPreference('dashboard-layout', { layouts: layout }, false)\n },\n [setPreference],\n )\n}\n"],"mappings":"AAEA,SAASA,SAAS,QAAQ;AAC1B,SACEC,iBAAiB,EACjBC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,cAAc,EACdC,kBAAkB,QACb;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,QAAQ,QAAQ;AAK7C,SAASC,YAAY,QAAQ;AAE7B,OAAO,SAASC,mBAAmBC,aAAqC;EACtE,MAAMC,mBAAA,GAAsBC,sBAAA;EAC5B,MAAM,CAACC,SAAA,EAAWC,YAAA,CAAa,GAAGP,QAAA,CAAS;EAC3C,MAAM;IAAEQ,OAAA,GAAU;EAAE,CAAE,GAAGd,SAAA,GAAYe,MAAM,CAACC,KAAK,CAACC,SAAS,IAAI,CAAC;EAChE,MAAM,CAACC,aAAA,EAAeC,gBAAA,CAAiB,GAAGb,QAAA,CAAiCG,aAAA;EAC3E,MAAM;IAAEW;EAAS,CAAE,GAAGnB,QAAA;EACtB,MAAMoB,eAAA,GAAkB;EACxB,MAAM;IAAEC;EAAc,CAAE,GAAGnB,kBAAA;EAE3B,MAAMoB,UAAA,GAAalB,WAAA,CAAY;IAC7B,IAAI;MACF,MAAMmB,UAAA,GAA2BN,aAAA,CAAcO,GAAG,CAAEC,IAAA,IAASA,IAAA,CAAKA,IAAI;MACtEb,YAAA,CAAa;MACb,MAAMH,mBAAA,CAAoBc,UAAA;IAC5B,EAAE,MAAM;MACNX,YAAA,CAAa;MACbd,KAAA,CAAM4B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|
1
|
+
{"version":3,"file":"useDashboardLayout.js","names":["arrayMove","ConfirmationModal","toast","useConfig","useModal","usePreferences","useServerFunctions","React","useCallback","useEffect","useState","RenderWidget","useDashboardLayout","initialLayout","setLayoutPreference","useSetLayoutPreference","isEditing","setIsEditing","widgets","config","admin","dashboard","currentLayout","setCurrentLayout","openModal","cancelModalSlug","serverFunction","saveLayout","layoutData","map","item","error","resetLayout","result","name","args","layout","performCancel","cancel","hasChanges","length","some","widget","index","initialWidget","id","width","moveWidget","moveFromIndex","moveToIndex","prev","addWidget","widgetSlug","widgetId","Date","now","find","slug","newWidgetInstance","component","createElement","maxWidth","minWidth","setTimeout","element","document","getElementById","scrollIntoView","behavior","block","closest","classList","add","remove","deleteWidget","filter","resizeWidget","newWidth","cancelModal","body","confirmLabel","heading","modalSlug","onConfirm","setPreference","layouts"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/useDashboardLayout.ts"],"sourcesContent":["import type { WidgetWidth } from 'payload'\n\nimport { arrayMove } from '@dnd-kit/sortable'\nimport {\n ConfirmationModal,\n toast,\n useConfig,\n useModal,\n usePreferences,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { WidgetInstanceClient, WidgetItem } from './index.client.js'\nimport type { GetDefaultLayoutServerFnReturnType } from './renderWidget/getDefaultLayoutServerFn.js'\n\nimport { RenderWidget } from './renderWidget/RenderWidget.js'\n\nexport function useDashboardLayout(initialLayout: WidgetInstanceClient[]) {\n const setLayoutPreference = useSetLayoutPreference()\n const [isEditing, setIsEditing] = useState(false)\n const { widgets = [] } = useConfig().config.admin.dashboard ?? {}\n const [currentLayout, setCurrentLayout] = useState<WidgetInstanceClient[]>(initialLayout)\n const { openModal } = useModal()\n const cancelModalSlug = 'cancel-dashboard-changes'\n const { serverFunction } = useServerFunctions()\n\n // Sync state when initialLayout prop changes (e.g., when query params change and server component re-renders)\n useEffect(() => {\n if (!isEditing) {\n setCurrentLayout(initialLayout)\n }\n }, [initialLayout, isEditing])\n\n const saveLayout = useCallback(async () => {\n try {\n const layoutData: WidgetItem[] = currentLayout.map((item) => item.item)\n setIsEditing(false)\n await setLayoutPreference(layoutData)\n } catch {\n setIsEditing(true)\n toast.error('Failed to save layout')\n }\n }, [setLayoutPreference, currentLayout])\n\n const resetLayout = useCallback(async () => {\n try {\n await setLayoutPreference(null)\n\n const result = (await serverFunction({\n name: 'get-default-layout',\n args: {},\n })) as GetDefaultLayoutServerFnReturnType\n\n setCurrentLayout(result.layout)\n setIsEditing(false)\n } catch {\n toast.error('Failed to reset layout')\n }\n }, [setLayoutPreference, serverFunction])\n\n const performCancel = useCallback(() => {\n setCurrentLayout(initialLayout)\n setIsEditing(false)\n }, [initialLayout])\n\n const cancel = useCallback(() => {\n // Check if layout has changed\n const hasChanges =\n currentLayout.length !== initialLayout.length ||\n currentLayout.some((widget, index) => {\n const initialWidget = initialLayout[index]\n return (\n !initialWidget ||\n widget.item.id !== initialWidget.item.id ||\n widget.item.width !== initialWidget.item.width\n )\n })\n\n // If there are changes, show confirmation modal\n if (hasChanges) {\n openModal(cancelModalSlug)\n } else {\n performCancel()\n }\n }, [currentLayout, initialLayout, openModal, cancelModalSlug, performCancel])\n\n const moveWidget = useCallback(\n ({ moveFromIndex, moveToIndex }: { moveFromIndex: number; moveToIndex: number }) => {\n if (moveFromIndex === moveToIndex || moveFromIndex < 0 || moveToIndex < 0) {\n return\n }\n\n setCurrentLayout((prev) => {\n return arrayMove(prev, moveFromIndex, moveToIndex)\n })\n },\n [],\n )\n\n const addWidget = useCallback(\n (widgetSlug: string) => {\n if (!isEditing) {\n return\n }\n\n const widgetId = `${widgetSlug}-${Date.now()}`\n const widget = widgets.find((widget) => widget.slug === widgetSlug)\n\n // Create a new widget instance using RenderWidget\n const newWidgetInstance: WidgetInstanceClient = {\n component: React.createElement(RenderWidget, {\n widgetId,\n // TODO: widgetData can be added here for custom props\n }),\n item: {\n id: widgetId,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widget?.minWidth ?? 'x-small',\n },\n }\n\n setCurrentLayout((prev) => [...prev, newWidgetInstance])\n\n // Scroll to the newly added widget after it's rendered and highlight it\n setTimeout(() => {\n const element = document.getElementById(widgetId)\n if (element) {\n element.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n })\n\n // Add highlight animation to the widget element\n const widget = element.closest('.widget')\n if (widget) {\n widget.classList.add('widget--highlight')\n // Remove the class after animation completes (1.5s fade out)\n setTimeout(() => {\n widget.classList.remove('widget--highlight')\n }, 1500)\n }\n }\n }, 100)\n },\n [isEditing, widgets],\n )\n\n const deleteWidget = useCallback(\n (widgetId: string) => {\n if (!isEditing) {\n return\n }\n setCurrentLayout((prev) => prev.filter((item) => item.item.id !== widgetId))\n },\n [isEditing],\n )\n\n const resizeWidget = useCallback(\n (widgetId: string, newWidth: WidgetWidth) => {\n if (!isEditing) {\n return\n }\n setCurrentLayout((prev) =>\n prev.map((item) =>\n item.item.id === widgetId\n ? {\n ...item,\n item: {\n ...item.item,\n width: newWidth,\n } satisfies WidgetItem,\n }\n : item,\n ),\n )\n },\n [isEditing],\n )\n\n const cancelModal = React.createElement(ConfirmationModal, {\n body: 'You have unsaved changes to your dashboard layout. Are you sure you want to discard them?',\n confirmLabel: 'Discard',\n heading: 'Discard changes?',\n modalSlug: cancelModalSlug,\n onConfirm: performCancel,\n })\n\n return {\n addWidget,\n cancel,\n cancelModal,\n currentLayout,\n deleteWidget,\n isEditing,\n moveWidget,\n resetLayout,\n resizeWidget,\n saveLayout,\n setIsEditing,\n }\n}\n\nfunction useSetLayoutPreference() {\n const { setPreference } = usePreferences()\n return useCallback(\n async (layout: null | WidgetItem[]) => {\n await setPreference('dashboard-layout', { layouts: layout }, false)\n },\n [setPreference],\n )\n}\n"],"mappings":"AAEA,SAASA,SAAS,QAAQ;AAC1B,SACEC,iBAAiB,EACjBC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,cAAc,E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,YAAA,GAAepE,WAAA,CACnB,CAAC6C,QAAA,EAAkBwB,QAAA;IACjB,IAAI,CAAC7D,SAAA,EAAW;MACd;IACF;IACAO,gBAAA,CAAkB2B,IAAA,IAChBA,IAAA,CAAKrB,GAAG,CAAEC,IAAA,IACRA,IAAA,CAAKA,IAAI,CAACe,EAAE,KAAKQ,QAAA,GACb;MACE,GAAGvB,IAAI;MACPA,IAAA,EAAM;QACJ,GAAGA,IAAA,CAAKA,IAAI;QACZgB,KAAA,EAAO+B;MACT;IACF,IACA/C,IAAA;EAGV,GACA,CAACd,SAAA,CAAU;EAGb,MAAM8D,WAAA,GAAcvE,KAAA,CAAMqD,aAAa,CAAC3D,iBAAA,EAAmB;IACzD8E,IAAA,EAAM;IACNC,YAAA,EAAc;IACdC,OAAA,EAAS;IACTC,SAAA,EAAWzD,eAAA;IACX0D,SAAA,EAAW9C;EACb;EAEA,OAAO;IACLc,SAAA;IACAb,MAAA;IACAwC,WAAA;IACAxD,aAAA;IACAoD,YAAA;IACA1D,SAAA;IACA+B,UAAA;IACAf,WAAA;IACA4C,YAAA;IACAjD,UAAA;IACAV;EACF;AACF;AAEA,SAASF,uBAAA;EACP,MAAM;IAAEqE;EAAa,CAAE,GAAG/E,cAAA;EAC1B,OAAOG,WAAA,CACL,MAAO4B,MAAA;IACL,MAAMgD,aAAA,CAAc,oBAAoB;MAAEC,OAAA,EAASjD;IAAO,GAAG;EAC/D,GACA,CAACgD,aAAA,CAAc;AAEnB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.75.0-internal.880861f",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"qs-esm": "7.0.2",
|
|
100
100
|
"sass": "1.77.4",
|
|
101
101
|
"uuid": "10.0.0",
|
|
102
|
-
"@payloadcms/graphql": "3.
|
|
103
|
-
"@payloadcms/translations": "3.
|
|
104
|
-
"@payloadcms/ui": "3.
|
|
102
|
+
"@payloadcms/graphql": "3.75.0-internal.880861f",
|
|
103
|
+
"@payloadcms/translations": "3.75.0-internal.880861f",
|
|
104
|
+
"@payloadcms/ui": "3.75.0-internal.880861f"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@babel/cli": "7.27.2",
|
|
@@ -118,13 +118,13 @@
|
|
|
118
118
|
"esbuild": "0.27.1",
|
|
119
119
|
"esbuild-sass-plugin": "3.3.1",
|
|
120
120
|
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
121
|
-
"
|
|
122
|
-
"
|
|
121
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
122
|
+
"payload": "3.75.0-internal.880861f"
|
|
123
123
|
},
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"graphql": "^16.8.1",
|
|
126
126
|
"next": "^15.4.10 || >=16.1.1-canary.35 <16.2.0 || ^16.2.0",
|
|
127
|
-
"payload": "3.
|
|
127
|
+
"payload": "3.75.0-internal.880861f"
|
|
128
128
|
},
|
|
129
129
|
"engines": {
|
|
130
130
|
"node": "^18.20.2 || >=20.9.0"
|