@shefing/quickfilter 1.0.43 → 1.0.44
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/README.md +10 -3
- package/dist/Dashboard/index.d.ts +27 -2
- package/dist/Dashboard/index.d.ts.map +1 -1
- package/dist/Dashboard/index.js +139 -3
- package/dist/Dashboard/index.js.map +1 -1
- package/dist/ui/button.d.ts +2 -2
- package/package.json +1 -1
- package/dist/Dashboard/Default/index.d.ts +0 -28
- package/dist/Dashboard/Default/index.d.ts.map +0 -1
- package/dist/Dashboard/Default/index.js +0 -142
- package/dist/Dashboard/Default/index.js.map +0 -1
- package/dist/Dashboard/metadata.d.ts +0 -3
- package/dist/Dashboard/metadata.d.ts.map +0 -1
- package/dist/Dashboard/metadata.js +0 -12
- package/dist/Dashboard/metadata.js.map +0 -1
- package/dist/lib/meta.d.ts +0 -6
- package/dist/lib/meta.d.ts.map +0 -1
- package/dist/lib/meta.js +0 -74
- package/dist/lib/meta.js.map +0 -1
package/README.md
CHANGED
|
@@ -477,12 +477,13 @@ CollectionQuickFilterPlugin({
|
|
|
477
477
|
|
|
478
478
|
</details>
|
|
479
479
|
|
|
480
|
-
### 🧭
|
|
480
|
+
### 🧭 Default Filter from navigation in both Navigator and Dashboard
|
|
481
481
|
|
|
482
482
|
<details>
|
|
483
|
-
<summary>⚙️ <strong>Using
|
|
483
|
+
<summary>⚙️ <strong>Using Default Filter in your admin UI</strong></summary>
|
|
484
484
|
|
|
485
|
-
The NavDefaultFilter component allows you to apply default filters to collection views directly from the navigation menu
|
|
485
|
+
The NavDefaultFilter/DashBoard component allows you to apply default filters to collection views directly from the navigation menu or the dashboard.
|
|
486
|
+
This means users will see filtered data immediately when they click on a collection.
|
|
486
487
|
|
|
487
488
|
```typescript
|
|
488
489
|
// payload.config.ts
|
|
@@ -490,6 +491,11 @@ export default buildConfig({
|
|
|
490
491
|
admin: {
|
|
491
492
|
components: {
|
|
492
493
|
Nav: '@shefing/quickfilter/nav',
|
|
494
|
+
views: {
|
|
495
|
+
dashboard: {
|
|
496
|
+
Component: '@shefing/quickfilter/Dashboard',
|
|
497
|
+
},
|
|
498
|
+
},
|
|
493
499
|
},
|
|
494
500
|
},
|
|
495
501
|
// ... rest of your config
|
|
@@ -534,6 +540,7 @@ export const Tasks: CollectionConfig = {
|
|
|
534
540
|
- 🎯 **Context-aware navigation**: Users see the most relevant data immediately
|
|
535
541
|
- ⏱️ **Time-saving**: No need to manually apply filters after navigation
|
|
536
542
|
- 🧠 **Smart defaults**: Configure different default views for different collections
|
|
543
|
+
- 🔄 **Consistent experience**: Both Nav and Dashboard components are aligned with default filters for all collections
|
|
537
544
|
|
|
538
545
|
</details>
|
|
539
546
|
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { groupNavItems } from '@payloadcms/ui/shared';
|
|
2
|
+
import type { ClientUser, Locale, ServerProps } from 'payload';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export type DashboardViewClientProps = {
|
|
5
|
+
locale: Locale;
|
|
6
|
+
};
|
|
7
|
+
export type DashboardViewServerPropsOnly = {
|
|
8
|
+
globalData: Array<{
|
|
9
|
+
data: {
|
|
10
|
+
_isLocked: boolean;
|
|
11
|
+
_lastEditedAt: string;
|
|
12
|
+
_userEditing: ClientUser | number | string;
|
|
13
|
+
};
|
|
14
|
+
lockDuration?: number;
|
|
15
|
+
slug: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
* This prop is deprecated and will be removed in the next major version.
|
|
20
|
+
* Components now import their own `Link` directly from `next/link`.
|
|
21
|
+
*/
|
|
22
|
+
Link?: React.ComponentType;
|
|
23
|
+
navGroups?: ReturnType<typeof groupNavItems>;
|
|
24
|
+
} & ServerProps;
|
|
25
|
+
export type DashboardViewServerProps = DashboardViewClientProps & DashboardViewServerPropsOnly;
|
|
26
|
+
export declare function DefaultDashboard(props: DashboardViewServerProps): React.JSX.Element;
|
|
27
|
+
export default DefaultDashboard;
|
|
3
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Dashboard/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Dashboard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAO9D,OAAO,KAAmB,MAAM,OAAO,CAAA;AAOvC,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE;YAAE,SAAS,EAAE,OAAO,CAAC;YAAC,aAAa,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;QAC/F,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;IACF;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC1B,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;CAC7C,GAAG,WAAW,CAAA;AAEf,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,GAAG,4BAA4B,CAAA;AAG9F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,qBAkK/D;AAED,eAAe,gBAAgB,CAAA"}
|
package/dist/Dashboard/index.js
CHANGED
|
@@ -1,5 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
3
|
+
import { Button, Card, Gutter, Locked } from '@payloadcms/ui';
|
|
4
|
+
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
5
|
+
import { EntityType } from '@payloadcms/ui/shared';
|
|
6
|
+
import { formatAdminURL } from 'payload/shared';
|
|
7
|
+
import React, { Fragment } from 'react';
|
|
8
|
+
import { processNavGroups } from '../lib/utils';
|
|
9
|
+
const baseClass = 'dashboard';
|
|
10
|
+
export function DefaultDashboard(props) {
|
|
11
|
+
const { globalData, i18n, i18n: { t }, locale, navGroups: originalNavGroups, params, payload: { config: { admin: { components: { afterDashboard, beforeDashboard } }, routes: { admin: adminRoute }, collections } }, payload, permissions, searchParams, user } = props;
|
|
12
|
+
// Process navGroups to calculate href values
|
|
13
|
+
const navGroups = originalNavGroups ? processNavGroups(originalNavGroups, collections, payload, i18n) : [];
|
|
14
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
15
|
+
className: baseClass,
|
|
16
|
+
children: /*#__PURE__*/ _jsxs(Gutter, {
|
|
17
|
+
className: `${baseClass}__wrap`,
|
|
18
|
+
children: [
|
|
19
|
+
beforeDashboard && RenderServerComponent({
|
|
20
|
+
Component: beforeDashboard,
|
|
21
|
+
importMap: payload.importMap,
|
|
22
|
+
serverProps: {
|
|
23
|
+
i18n,
|
|
24
|
+
locale,
|
|
25
|
+
params,
|
|
26
|
+
payload,
|
|
27
|
+
permissions,
|
|
28
|
+
searchParams,
|
|
29
|
+
user
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
/*#__PURE__*/ _jsx(Fragment, {
|
|
33
|
+
children: !navGroups || navGroups?.length === 0 ? /*#__PURE__*/ _jsx("p", {
|
|
34
|
+
children: "no nav groups...."
|
|
35
|
+
}) : navGroups.map(({ entities, label }, groupIndex)=>{
|
|
36
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
37
|
+
className: `${baseClass}__group`,
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
40
|
+
className: `${baseClass}__label`,
|
|
41
|
+
children: label
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ _jsx("ul", {
|
|
44
|
+
className: `${baseClass}__card-list`,
|
|
45
|
+
children: entities.map(({ slug, type, label, href: entityHref }, entityIndex)=>{
|
|
46
|
+
let title;
|
|
47
|
+
let buttonAriaLabel;
|
|
48
|
+
let createHREF;
|
|
49
|
+
let href;
|
|
50
|
+
let hasCreatePermission;
|
|
51
|
+
let isLocked = null;
|
|
52
|
+
let userEditing = null;
|
|
53
|
+
if (type === EntityType.collection) {
|
|
54
|
+
title = getTranslation(label, i18n);
|
|
55
|
+
buttonAriaLabel = t('general:showAllLabel', {
|
|
56
|
+
label: title
|
|
57
|
+
});
|
|
58
|
+
// Use the processed href if available, otherwise use the default
|
|
59
|
+
href = entityHref || formatAdminURL({
|
|
60
|
+
adminRoute,
|
|
61
|
+
path: `/collections/${slug}`
|
|
62
|
+
});
|
|
63
|
+
createHREF = formatAdminURL({
|
|
64
|
+
adminRoute,
|
|
65
|
+
path: `/collections/${slug}/create`
|
|
66
|
+
});
|
|
67
|
+
hasCreatePermission = permissions?.collections?.[slug]?.create;
|
|
68
|
+
}
|
|
69
|
+
if (type === EntityType.global) {
|
|
70
|
+
buttonAriaLabel = t('general:editLabel', {
|
|
71
|
+
label: getTranslation(label, i18n)
|
|
72
|
+
});
|
|
73
|
+
href = formatAdminURL({
|
|
74
|
+
adminRoute,
|
|
75
|
+
path: `/globals/${slug}`
|
|
76
|
+
});
|
|
77
|
+
// Find the lock status for the global
|
|
78
|
+
const globalLockData = globalData.find((global)=>global.slug === slug);
|
|
79
|
+
if (globalLockData) {
|
|
80
|
+
isLocked = globalLockData.data._isLocked;
|
|
81
|
+
userEditing = globalLockData.data._userEditing;
|
|
82
|
+
// Check if the lock is expired
|
|
83
|
+
const lockDuration = globalLockData?.lockDuration;
|
|
84
|
+
const lastEditedAt = new Date(globalLockData.data?._lastEditedAt).getTime();
|
|
85
|
+
const lockDurationInMilliseconds = lockDuration * 1000;
|
|
86
|
+
const lockExpirationTime = lastEditedAt + lockDurationInMilliseconds;
|
|
87
|
+
if (new Date().getTime() > lockExpirationTime) {
|
|
88
|
+
isLocked = false;
|
|
89
|
+
userEditing = null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return /*#__PURE__*/ _jsx("li", {
|
|
94
|
+
children: /*#__PURE__*/ _jsx(Card, {
|
|
95
|
+
actions: isLocked && user?.id !== userEditing?.id ? /*#__PURE__*/ _jsx(Locked, {
|
|
96
|
+
className: `${baseClass}__locked`,
|
|
97
|
+
user: userEditing
|
|
98
|
+
}) : hasCreatePermission && type === EntityType.collection ? /*#__PURE__*/ _jsx(Button, {
|
|
99
|
+
"aria-label": t('general:createNewLabel', {
|
|
100
|
+
label
|
|
101
|
+
}),
|
|
102
|
+
buttonStyle: "icon-label",
|
|
103
|
+
el: "link",
|
|
104
|
+
icon: "plus",
|
|
105
|
+
iconStyle: "with-border",
|
|
106
|
+
round: true,
|
|
107
|
+
to: createHREF
|
|
108
|
+
}) : undefined,
|
|
109
|
+
buttonAriaLabel: buttonAriaLabel,
|
|
110
|
+
href: href,
|
|
111
|
+
id: `card-${slug}`,
|
|
112
|
+
title: getTranslation(label, i18n),
|
|
113
|
+
titleAs: "h3"
|
|
114
|
+
})
|
|
115
|
+
}, entityIndex);
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
}, groupIndex);
|
|
120
|
+
})
|
|
121
|
+
}),
|
|
122
|
+
afterDashboard && RenderServerComponent({
|
|
123
|
+
Component: afterDashboard,
|
|
124
|
+
importMap: payload.importMap,
|
|
125
|
+
serverProps: {
|
|
126
|
+
i18n,
|
|
127
|
+
locale,
|
|
128
|
+
params,
|
|
129
|
+
payload,
|
|
130
|
+
permissions,
|
|
131
|
+
searchParams,
|
|
132
|
+
user
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
export default DefaultDashboard;
|
|
4
140
|
|
|
5
141
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Dashboard/index.tsx"],"sourcesContent":["// Re-export DefaultDashboard from Default\nexport { DefaultDashboard, type DashboardViewClientProps, type DashboardViewServerProps, type DashboardViewServerPropsOnly } from './Default'\nexport { default } from './Default'\n\n"],"names":["DefaultDashboard","default"],"mappings":"AAAA,0CAA0C;AAC1C,SAASA,gBAAgB,QAAyG,YAAW;AAC7I,SAASC,OAAO,QAAQ,YAAW"}
|
|
1
|
+
{"version":3,"sources":["../../src/Dashboard/index.tsx"],"sourcesContent":["import type { groupNavItems } from '@payloadcms/ui/shared'\nimport type { ClientUser, Locale, ServerProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, Card, Gutter, Locked } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { EntityType } from '@payloadcms/ui/shared'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport {EntityWithHref} from \"../types\";\nimport { processNavGroups } from '../lib/utils';\n\nconst baseClass = 'dashboard'\n\nexport type DashboardViewClientProps = {\n locale: Locale\n}\n\nexport type DashboardViewServerPropsOnly = {\n globalData: Array<{\n data: { _isLocked: boolean; _lastEditedAt: string; _userEditing: ClientUser | number | string }\n lockDuration?: number\n slug: string\n }>\n /**\n * @deprecated\n * This prop is deprecated and will be removed in the next major version.\n * Components now import their own `Link` directly from `next/link`.\n */\n Link?: React.ComponentType\n navGroups?: ReturnType<typeof groupNavItems>\n} & ServerProps\n\nexport type DashboardViewServerProps = DashboardViewClientProps & DashboardViewServerPropsOnly\n\n\nexport function DefaultDashboard(props: DashboardViewServerProps) {\n const {\n globalData,\n i18n,\n i18n: { t },\n locale,\n navGroups: originalNavGroups,\n params,\n payload: {\n config: {\n admin: {\n components: { afterDashboard, beforeDashboard },\n },\n routes: { admin: adminRoute },\n collections,\n },\n },\n payload,\n permissions,\n searchParams,\n user,\n } = props\n\n // Process navGroups to calculate href values\n const navGroups = originalNavGroups ? processNavGroups(originalNavGroups, collections, payload, i18n) : []\n\n return (\n <div className={baseClass}>\n <Gutter className={`${baseClass}__wrap`}>\n {beforeDashboard &&\n RenderServerComponent({\n Component: beforeDashboard,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n\n <Fragment>\n {!navGroups || navGroups?.length === 0 ? (\n <p>no nav groups....</p>\n ) : (\n navGroups.map(({ entities, label }, groupIndex) => {\n return (\n <div className={`${baseClass}__group`} key={groupIndex}>\n <h2 className={`${baseClass}__label`}>{label}</h2>\n <ul className={`${baseClass}__card-list`}>\n {entities.map(({ slug, type, label, href: entityHref }:EntityWithHref, entityIndex) => {\n let title: string\n let buttonAriaLabel: string\n let createHREF: string\n let href: string\n let hasCreatePermission: boolean\n let isLocked = null\n let userEditing = null\n\n if (type === EntityType.collection) {\n title = getTranslation(label, i18n)\n\n buttonAriaLabel = t('general:showAllLabel', { label: title })\n\n // Use the processed href if available, otherwise use the default\n href = entityHref || formatAdminURL({ adminRoute, path: `/collections/${slug}` })\n\n createHREF = formatAdminURL({\n adminRoute,\n path: `/collections/${slug}/create`,\n })\n\n hasCreatePermission = permissions?.collections?.[slug]?.create\n }\n\n if (type === EntityType.global) {\n buttonAriaLabel = t('general:editLabel', {\n label: getTranslation(label, i18n),\n })\n\n href = formatAdminURL({\n adminRoute,\n path: `/globals/${slug}`,\n })\n\n // Find the lock status for the global\n const globalLockData = globalData.find((global) => global.slug === slug)\n if (globalLockData) {\n isLocked = globalLockData.data._isLocked\n userEditing = globalLockData.data._userEditing\n\n // Check if the lock is expired\n const lockDuration = globalLockData?.lockDuration\n const lastEditedAt = new Date(\n globalLockData.data?._lastEditedAt,\n ).getTime()\n\n const lockDurationInMilliseconds = lockDuration * 1000\n const lockExpirationTime = lastEditedAt + lockDurationInMilliseconds\n\n if (new Date().getTime() > lockExpirationTime) {\n isLocked = false\n userEditing = null\n }\n }\n }\n\n return (\n <li key={entityIndex}>\n <Card\n actions={\n isLocked && user?.id !== userEditing?.id ? (\n <Locked className={`${baseClass}__locked`} user={userEditing} />\n ) : hasCreatePermission && type === EntityType.collection ? (\n <Button\n aria-label={t('general:createNewLabel', {\n label,\n })}\n buttonStyle=\"icon-label\"\n el=\"link\"\n icon=\"plus\"\n iconStyle=\"with-border\"\n round\n to={createHREF}\n />\n ) : undefined\n }\n buttonAriaLabel={buttonAriaLabel}\n href={href}\n id={`card-${slug}`}\n title={getTranslation(label, i18n)}\n titleAs=\"h3\"\n />\n </li>\n )\n })}\n </ul>\n </div>\n )\n })\n )}\n </Fragment>\n {afterDashboard &&\n RenderServerComponent({\n Component: afterDashboard,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n </Gutter>\n </div>\n )\n}\n\nexport default DefaultDashboard\n"],"names":["getTranslation","Button","Card","Gutter","Locked","RenderServerComponent","EntityType","formatAdminURL","React","Fragment","processNavGroups","baseClass","DefaultDashboard","props","globalData","i18n","t","locale","navGroups","originalNavGroups","params","payload","config","admin","components","afterDashboard","beforeDashboard","routes","adminRoute","collections","permissions","searchParams","user","div","className","Component","importMap","serverProps","length","p","map","entities","label","groupIndex","h2","ul","slug","type","href","entityHref","entityIndex","title","buttonAriaLabel","createHREF","hasCreatePermission","isLocked","userEditing","collection","path","create","global","globalLockData","find","data","_isLocked","_userEditing","lockDuration","lastEditedAt","Date","_lastEditedAt","getTime","lockDurationInMilliseconds","lockExpirationTime","li","actions","id","aria-label","buttonStyle","el","icon","iconStyle","round","to","undefined","titleAs"],"mappings":";AAGA,SAASA,cAAc,QAAQ,2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MAAMC,6BAA6BL,eAAe;gDAClD,MAAMM,qBAAqBL,eAAeI;gDAE1C,IAAI,IAAIH,OAAOE,OAAO,KAAKE,oBAAoB;oDAC7CjB,WAAW;oDACXC,cAAc;gDAChB;4CACF;wCACF;wCAEA,qBACE,KAACiB;sDACC,cAAA,KAACvE;gDACCwE,SACEnB,YAAYvB,MAAM2C,OAAOnB,aAAamB,mBACpC,KAACvE;oDAAO8B,WAAW,GAAGvB,UAAU,QAAQ,CAAC;oDAAEqB,MAAMwB;qDAC/CF,uBAAuBP,SAASzC,WAAWmD,UAAU,iBACvD,KAACxD;oDACC2E,cAAY5D,EAAE,0BAA0B;wDACtC0B;oDACF;oDACAmC,aAAY;oDACZC,IAAG;oDACHC,MAAK;oDACLC,WAAU;oDACVC,KAAK;oDACLC,IAAI7B;qDAEJ8B;gDAEN/B,iBAAiBA;gDACjBJ,MAAMA;gDACN2B,IAAI,CAAC,KAAK,EAAE7B,MAAM;gDAClBK,OAAOnD,eAAe0C,OAAO3B;gDAC7BqE,SAAQ;;2CAvBHlC;oCA2Bb;;;2BAxFwCP;oBA4FhD;;gBAGHlB,kBACCpB,sBAAsB;oBACpB8B,WAAWV;oBACXW,WAAWf,QAAQe,SAAS;oBAC5BC,aAAa;wBACXtB;wBACAE;wBACAG;wBACAC;wBACAS;wBACAC;wBACAC;oBACF;gBACF;;;;AAIV;AAEA,eAAepB,iBAAgB"}
|
package/dist/ui/button.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
3
|
declare const buttonVariants: (props?: {
|
|
4
|
-
variant?: "link" | "
|
|
5
|
-
size?: "
|
|
4
|
+
variant?: "link" | "default" | "defaultHover" | "destructive" | "outline" | "secondary" | "ghost" | "icon";
|
|
5
|
+
size?: "sm" | "lg" | "default" | "icon";
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) => string;
|
|
7
7
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
8
8
|
asChild?: boolean;
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { groupNavItems } from '@payloadcms/ui/shared';
|
|
2
|
-
import type { ClientUser, Locale, ServerProps } from 'payload';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
export type DashboardViewClientProps = {
|
|
5
|
-
locale: Locale;
|
|
6
|
-
};
|
|
7
|
-
export type DashboardViewServerPropsOnly = {
|
|
8
|
-
globalData: Array<{
|
|
9
|
-
data: {
|
|
10
|
-
_isLocked: boolean;
|
|
11
|
-
_lastEditedAt: string;
|
|
12
|
-
_userEditing: ClientUser | number | string;
|
|
13
|
-
};
|
|
14
|
-
lockDuration?: number;
|
|
15
|
-
slug: string;
|
|
16
|
-
}>;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated
|
|
19
|
-
* This prop is deprecated and will be removed in the next major version.
|
|
20
|
-
* Components now import their own `Link` directly from `next/link`.
|
|
21
|
-
*/
|
|
22
|
-
Link?: React.ComponentType;
|
|
23
|
-
navGroups?: ReturnType<typeof groupNavItems>;
|
|
24
|
-
} & ServerProps;
|
|
25
|
-
export type DashboardViewServerProps = DashboardViewClientProps & DashboardViewServerPropsOnly;
|
|
26
|
-
export declare function DefaultDashboard(props: DashboardViewServerProps): React.JSX.Element;
|
|
27
|
-
export default DefaultDashboard;
|
|
28
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Dashboard/Default/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAO9D,OAAO,KAAmB,MAAM,OAAO,CAAA;AAOvC,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE;YAAE,SAAS,EAAE,OAAO,CAAC;YAAC,aAAa,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;QAC/F,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;IACF;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC1B,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;CAC7C,GAAG,WAAW,CAAA;AAEf,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,GAAG,4BAA4B,CAAA;AAG9F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,qBAoK/D;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getTranslation } from '@payloadcms/translations';
|
|
3
|
-
import { Button, Card, Gutter, Locked } from '@payloadcms/ui';
|
|
4
|
-
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
5
|
-
import { EntityType } from '@payloadcms/ui/shared';
|
|
6
|
-
import { formatAdminURL } from 'payload/shared';
|
|
7
|
-
import React, { Fragment } from 'react';
|
|
8
|
-
import { processNavGroups } from '../../lib/utils';
|
|
9
|
-
const baseClass = 'dashboard';
|
|
10
|
-
export function DefaultDashboard(props) {
|
|
11
|
-
const { globalData, i18n, i18n: { t }, locale, navGroups: originalNavGroups, params, payload: { config: { admin: { components: { afterDashboard, beforeDashboard } }, routes: { admin: adminRoute }, collections } }, payload, permissions, searchParams, user } = props;
|
|
12
|
-
// Process navGroups to calculate href values
|
|
13
|
-
const navGroups = originalNavGroups ? processNavGroups(originalNavGroups, collections, payload, i18n) : [];
|
|
14
|
-
return /*#__PURE__*/ _jsx("div", {
|
|
15
|
-
className: baseClass,
|
|
16
|
-
children: /*#__PURE__*/ _jsxs(Gutter, {
|
|
17
|
-
className: `${baseClass}__wrap`,
|
|
18
|
-
children: [
|
|
19
|
-
beforeDashboard && RenderServerComponent({
|
|
20
|
-
Component: beforeDashboard,
|
|
21
|
-
importMap: payload.importMap,
|
|
22
|
-
serverProps: {
|
|
23
|
-
i18n,
|
|
24
|
-
locale,
|
|
25
|
-
params,
|
|
26
|
-
payload,
|
|
27
|
-
permissions,
|
|
28
|
-
searchParams,
|
|
29
|
-
user
|
|
30
|
-
}
|
|
31
|
-
}),
|
|
32
|
-
/*#__PURE__*/ _jsx(Fragment, {
|
|
33
|
-
children: !navGroups || navGroups?.length === 0 ? /*#__PURE__*/ _jsx("p", {
|
|
34
|
-
children: "no nav groups...."
|
|
35
|
-
}) : navGroups.map(({ entities, label }, groupIndex)=>{
|
|
36
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
37
|
-
className: `${baseClass}__group`,
|
|
38
|
-
children: [
|
|
39
|
-
/*#__PURE__*/ _jsx("h2", {
|
|
40
|
-
className: `${baseClass}__label`,
|
|
41
|
-
children: label
|
|
42
|
-
}),
|
|
43
|
-
/*#__PURE__*/ _jsx("ul", {
|
|
44
|
-
className: `${baseClass}__card-list`,
|
|
45
|
-
children: entities.map(({ slug, type, label, href: entityHref }, entityIndex)=>{
|
|
46
|
-
let title;
|
|
47
|
-
let buttonAriaLabel;
|
|
48
|
-
let createHREF;
|
|
49
|
-
let href;
|
|
50
|
-
let hasCreatePermission;
|
|
51
|
-
let isLocked = null;
|
|
52
|
-
let userEditing = null;
|
|
53
|
-
if (type === EntityType.collection) {
|
|
54
|
-
title = getTranslation(label, i18n);
|
|
55
|
-
buttonAriaLabel = t('general:showAllLabel', {
|
|
56
|
-
label: title
|
|
57
|
-
});
|
|
58
|
-
// Use the processed href if available, otherwise use the default
|
|
59
|
-
href = entityHref || formatAdminURL({
|
|
60
|
-
adminRoute,
|
|
61
|
-
path: `/collections/${slug}`
|
|
62
|
-
});
|
|
63
|
-
createHREF = formatAdminURL({
|
|
64
|
-
adminRoute,
|
|
65
|
-
path: `/collections/${slug}/create`
|
|
66
|
-
});
|
|
67
|
-
hasCreatePermission = permissions?.collections?.[slug]?.create;
|
|
68
|
-
}
|
|
69
|
-
if (type === EntityType.global) {
|
|
70
|
-
title = getTranslation(label, i18n);
|
|
71
|
-
buttonAriaLabel = t('general:editLabel', {
|
|
72
|
-
label: getTranslation(label, i18n)
|
|
73
|
-
});
|
|
74
|
-
href = formatAdminURL({
|
|
75
|
-
adminRoute,
|
|
76
|
-
path: `/globals/${slug}`
|
|
77
|
-
});
|
|
78
|
-
// Find the lock status for the global
|
|
79
|
-
const globalLockData = globalData.find((global)=>global.slug === slug);
|
|
80
|
-
if (globalLockData) {
|
|
81
|
-
isLocked = globalLockData.data._isLocked;
|
|
82
|
-
userEditing = globalLockData.data._userEditing;
|
|
83
|
-
// Check if the lock is expired
|
|
84
|
-
const lockDuration = globalLockData?.lockDuration;
|
|
85
|
-
const lastEditedAt = new Date(globalLockData.data?._lastEditedAt).getTime();
|
|
86
|
-
const lockDurationInMilliseconds = lockDuration * 1000;
|
|
87
|
-
const lockExpirationTime = lastEditedAt + lockDurationInMilliseconds;
|
|
88
|
-
if (new Date().getTime() > lockExpirationTime) {
|
|
89
|
-
isLocked = false;
|
|
90
|
-
userEditing = null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return /*#__PURE__*/ _jsx("li", {
|
|
95
|
-
children: /*#__PURE__*/ _jsx(Card, {
|
|
96
|
-
actions: isLocked && user?.id !== userEditing?.id ? /*#__PURE__*/ _jsx(Locked, {
|
|
97
|
-
className: `${baseClass}__locked`,
|
|
98
|
-
user: userEditing
|
|
99
|
-
}) : hasCreatePermission && type === EntityType.collection ? /*#__PURE__*/ _jsx(Button, {
|
|
100
|
-
"aria-label": t('general:createNewLabel', {
|
|
101
|
-
label
|
|
102
|
-
}),
|
|
103
|
-
buttonStyle: "icon-label",
|
|
104
|
-
el: "link",
|
|
105
|
-
icon: "plus",
|
|
106
|
-
iconStyle: "with-border",
|
|
107
|
-
round: true,
|
|
108
|
-
to: createHREF
|
|
109
|
-
}) : undefined,
|
|
110
|
-
buttonAriaLabel: buttonAriaLabel,
|
|
111
|
-
href: href,
|
|
112
|
-
id: `card-${slug}`,
|
|
113
|
-
title: getTranslation(label, i18n),
|
|
114
|
-
titleAs: "h3"
|
|
115
|
-
})
|
|
116
|
-
}, entityIndex);
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
]
|
|
120
|
-
}, groupIndex);
|
|
121
|
-
})
|
|
122
|
-
}),
|
|
123
|
-
afterDashboard && RenderServerComponent({
|
|
124
|
-
Component: afterDashboard,
|
|
125
|
-
importMap: payload.importMap,
|
|
126
|
-
serverProps: {
|
|
127
|
-
i18n,
|
|
128
|
-
locale,
|
|
129
|
-
params,
|
|
130
|
-
payload,
|
|
131
|
-
permissions,
|
|
132
|
-
searchParams,
|
|
133
|
-
user
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
]
|
|
137
|
-
})
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
export default DefaultDashboard;
|
|
141
|
-
|
|
142
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Dashboard/Default/index.tsx"],"sourcesContent":["import type { groupNavItems } from '@payloadcms/ui/shared'\nimport type { ClientUser, Locale, ServerProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, Card, Gutter, Locked } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { EntityType } from '@payloadcms/ui/shared'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport {EntityWithHref} from \"../../types\";\nimport { processNavGroups } from '../../lib/utils';\n\nconst baseClass = 'dashboard'\n\nexport type DashboardViewClientProps = {\n locale: Locale\n}\n\nexport type DashboardViewServerPropsOnly = {\n globalData: Array<{\n data: { _isLocked: boolean; _lastEditedAt: string; _userEditing: ClientUser | number | string }\n lockDuration?: number\n slug: string\n }>\n /**\n * @deprecated\n * This prop is deprecated and will be removed in the next major version.\n * Components now import their own `Link` directly from `next/link`.\n */\n Link?: React.ComponentType\n navGroups?: ReturnType<typeof groupNavItems>\n} & ServerProps\n\nexport type DashboardViewServerProps = DashboardViewClientProps & DashboardViewServerPropsOnly\n\n\nexport function DefaultDashboard(props: DashboardViewServerProps) {\n const {\n globalData,\n i18n,\n i18n: { t },\n locale,\n navGroups: originalNavGroups,\n params,\n payload: {\n config: {\n admin: {\n components: { afterDashboard, beforeDashboard },\n },\n routes: { admin: adminRoute },\n collections,\n },\n },\n payload,\n permissions,\n searchParams,\n user,\n } = props\n\n // Process navGroups to calculate href values\n const navGroups = originalNavGroups ? processNavGroups(originalNavGroups, collections, payload, i18n) : []\n\n return (\n <div className={baseClass}>\n <Gutter className={`${baseClass}__wrap`}>\n {beforeDashboard &&\n RenderServerComponent({\n Component: beforeDashboard,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n\n <Fragment>\n {!navGroups || navGroups?.length === 0 ? (\n <p>no nav groups....</p>\n ) : (\n navGroups.map(({ entities, label }, groupIndex) => {\n return (\n <div className={`${baseClass}__group`} key={groupIndex}>\n <h2 className={`${baseClass}__label`}>{label}</h2>\n <ul className={`${baseClass}__card-list`}>\n {entities.map(({ slug, type, label, href: entityHref }:EntityWithHref, entityIndex) => {\n let title: string\n let buttonAriaLabel: string\n let createHREF: string\n let href: string\n let hasCreatePermission: boolean\n let isLocked = null\n let userEditing = null\n\n if (type === EntityType.collection) {\n title = getTranslation(label, i18n)\n\n buttonAriaLabel = t('general:showAllLabel', { label: title })\n\n // Use the processed href if available, otherwise use the default\n href = entityHref || formatAdminURL({ adminRoute, path: `/collections/${slug}` })\n\n createHREF = formatAdminURL({\n adminRoute,\n path: `/collections/${slug}/create`,\n })\n\n hasCreatePermission = permissions?.collections?.[slug]?.create\n }\n\n if (type === EntityType.global) {\n title = getTranslation(label, i18n)\n\n buttonAriaLabel = t('general:editLabel', {\n label: getTranslation(label, i18n),\n })\n\n href = formatAdminURL({\n adminRoute,\n path: `/globals/${slug}`,\n })\n\n // Find the lock status for the global\n const globalLockData = globalData.find((global) => global.slug === slug)\n if (globalLockData) {\n isLocked = globalLockData.data._isLocked\n userEditing = globalLockData.data._userEditing\n\n // Check if the lock is expired\n const lockDuration = globalLockData?.lockDuration\n const lastEditedAt = new Date(\n globalLockData.data?._lastEditedAt,\n ).getTime()\n\n const lockDurationInMilliseconds = lockDuration * 1000\n const lockExpirationTime = lastEditedAt + lockDurationInMilliseconds\n\n if (new Date().getTime() > lockExpirationTime) {\n isLocked = false\n userEditing = null\n }\n }\n }\n\n return (\n <li key={entityIndex}>\n <Card\n actions={\n isLocked && user?.id !== userEditing?.id ? (\n <Locked className={`${baseClass}__locked`} user={userEditing} />\n ) : hasCreatePermission && type === EntityType.collection ? (\n <Button\n aria-label={t('general:createNewLabel', {\n label,\n })}\n buttonStyle=\"icon-label\"\n el=\"link\"\n icon=\"plus\"\n iconStyle=\"with-border\"\n round\n to={createHREF}\n />\n ) : undefined\n }\n buttonAriaLabel={buttonAriaLabel}\n href={href}\n id={`card-${slug}`}\n title={getTranslation(label, i18n)}\n titleAs=\"h3\"\n />\n </li>\n )\n })}\n </ul>\n </div>\n )\n })\n )}\n </Fragment>\n {afterDashboard &&\n RenderServerComponent({\n Component: afterDashboard,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n </Gutter>\n </div>\n )\n}\n\nexport default DefaultDashboard\n"],"names":["getTranslation","Button","Card","Gutter","Locked","RenderServerComponent","EntityType","formatAdminURL","React","Fragment","processNavGroups","baseClass","DefaultDashboard","props","globalData","i18n","t","locale","navGroups","originalNavGroups","params","payload","config","admin","components","afterDashboard","beforeDashboard","routes","adminRoute","collections","permissions","searchParams","user","div","className","Component","importMap","serverProps","length","p","map","entities","label","groupIndex","h2","ul","slug","type","href","entityHref","entityIndex","title","buttonAriaLabel","createHREF","hasCreatePermission","isLocked","userEditing","collection","path","create","global","globalLockData","find","data","_isLocked","_userEditing","lockDuration","lastEditedAt","Date","_lastEditedAt","getTime","lockDurationInMilliseconds","lockExpirationTime","li","actions","id","aria-label","buttonStyle","el","icon","iconStyle","round","to","undefined","titleAs"],"mappings":";AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAEC,MAAM,QAAQ,iBAAgB;AAC7D,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,UAAU,QAAQ,wBAAuB;AAClD,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAGvC,SAASC,gBAAgB,QAAQ,kBAAkB;AAEnD,MAAMC,YAAY;AAwBlB,OAAO,SAASC,iBAAiBC,KAA+B;IAC9D,MAAM,EACJC,UAAU,EACVC,IAAI,EACJA,MAAM,EAAEC,CAAC,EAAE,EACXC,MAAM,EACNC,WAAWC,iBAAiB,EAC5BC,MAAM,EACNC,SAAS,EACPC,QAAQ,EACNC,OAAO,EACLC,YAAY,EAAEC,cAAc,EAAEC,eAAe,EAAE,EAChD,EACDC,QAAQ,EAAEJ,OAAOK,UAAU,EAAE,EAC7BC,WAAW,EACZ,EACF,EACDR,OAAO,EACPS,WAAW,EACXC,YAAY,EACZC,IAAI,EACL,GAAGnB;IAEJ,6CAA6C;IAC7C,MAAMK,YAAYC,oBAAoBT,iBAAiBS,mBAAmBU,aAAaR,SAASN,QAAQ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ACCpB,sBAAsB;oBACpB8B,WAAWV;oBACXW,WAAWf,QAAQe,SAAS;oBAC5BC,aAAa;wBACXtB;wBACAE;wBACAG;wBACAC;wBACAS;wBACAC;wBACAC;oBACF;gBACF;;;;AAIV;AAEA,eAAepB,iBAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/Dashboard/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAIlE,eAAO,MAAM,6BAA6B,EAAE,oBAYxC,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { generateMetadata } from '../lib/meta';
|
|
2
|
-
export const generateDashboardViewMetadata = async ({ config, i18n: { t } })=>generateMetadata({
|
|
3
|
-
serverURL: config.serverURL,
|
|
4
|
-
title: t('general:dashboard'),
|
|
5
|
-
...config.admin.meta,
|
|
6
|
-
openGraph: {
|
|
7
|
-
title: t('general:dashboard'),
|
|
8
|
-
...config.admin.meta?.openGraph || {}
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Dashboard/metadata.ts"],"sourcesContent":["import type { GenerateViewMetadata } from '@payloadcms/next/views'\n\nimport { generateMetadata } from '../lib/meta'\n\nexport const generateDashboardViewMetadata: GenerateViewMetadata = async ({\n config,\n i18n: { t },\n}) =>\n generateMetadata({\n serverURL: config.serverURL,\n title: t('general:dashboard'),\n ...config.admin.meta,\n openGraph: {\n title: t('general:dashboard'),\n ...(config.admin.meta?.openGraph || {}),\n },\n })\n"],"names":["generateMetadata","generateDashboardViewMetadata","config","i18n","t","serverURL","title","admin","meta","openGraph"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,cAAa;AAE9C,OAAO,MAAMC,gCAAsD,OAAO,EACxEC,MAAM,EACNC,MAAM,EAAEC,CAAC,EAAE,EACZ,GACCJ,iBAAiB;QACfK,WAAWH,OAAOG,SAAS;QAC3BC,OAAOF,EAAE;QACT,GAAGF,OAAOK,KAAK,CAACC,IAAI;QACpBC,WAAW;YACTH,OAAOF,EAAE;YACT,GAAIF,OAAOK,KAAK,CAACC,IAAI,EAAEC,aAAa,CAAC,CAAC;QACxC;IACF,GAAE"}
|
package/dist/lib/meta.d.ts
DELETED
package/dist/lib/meta.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/lib/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAYzC,eAAO,MAAM,gBAAgB,SACrB;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,KACvC,OAAO,CAAC,QAAQ,CAqFlB,CAAA"}
|
package/dist/lib/meta.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { payloadFaviconDark, payloadFaviconLight, staticOGImage } from '@payloadcms/ui/assets';
|
|
2
|
-
import * as qs from 'qs-esm';
|
|
3
|
-
const defaultOpenGraph = {
|
|
4
|
-
description: 'Payload is a headless CMS and application framework built with TypeScript, Node.js, and React.',
|
|
5
|
-
siteName: 'Payload App',
|
|
6
|
-
title: 'Payload App'
|
|
7
|
-
};
|
|
8
|
-
export const generateMetadata = async (args)=>{
|
|
9
|
-
const { defaultOGImageType, serverURL, titleSuffix, ...rest } = args;
|
|
10
|
-
/**
|
|
11
|
-
* @todo find a way to remove the type assertion here.
|
|
12
|
-
* It is a result of needing to `DeepCopy` the `MetaConfig` type from Payload.
|
|
13
|
-
* This is required for the `DeepRequired` from `Config` to `SanitizedConfig`.
|
|
14
|
-
*/ const incomingMetadata = rest;
|
|
15
|
-
const icons = incomingMetadata.icons || [
|
|
16
|
-
{
|
|
17
|
-
type: 'image/png',
|
|
18
|
-
rel: 'icon',
|
|
19
|
-
sizes: '32x32',
|
|
20
|
-
url: typeof payloadFaviconDark === 'object' ? payloadFaviconDark?.src : payloadFaviconDark
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: 'image/png',
|
|
24
|
-
media: '(prefers-color-scheme: dark)',
|
|
25
|
-
rel: 'icon',
|
|
26
|
-
sizes: '32x32',
|
|
27
|
-
url: typeof payloadFaviconLight === 'object' ? payloadFaviconLight?.src : payloadFaviconLight
|
|
28
|
-
}
|
|
29
|
-
];
|
|
30
|
-
const metaTitle = [
|
|
31
|
-
incomingMetadata.title,
|
|
32
|
-
titleSuffix
|
|
33
|
-
].filter(Boolean).join(' ');
|
|
34
|
-
const ogTitle = `${typeof incomingMetadata.openGraph?.title === 'string' ? incomingMetadata.openGraph.title : incomingMetadata.title} ${titleSuffix}`;
|
|
35
|
-
const mergedOpenGraph = {
|
|
36
|
-
...defaultOpenGraph || {},
|
|
37
|
-
...defaultOGImageType === 'dynamic' ? {
|
|
38
|
-
images: [
|
|
39
|
-
{
|
|
40
|
-
alt: ogTitle,
|
|
41
|
-
height: 630,
|
|
42
|
-
url: `/api/og${qs.stringify({
|
|
43
|
-
description: incomingMetadata.openGraph?.description || defaultOpenGraph.description,
|
|
44
|
-
title: ogTitle
|
|
45
|
-
}, {
|
|
46
|
-
addQueryPrefix: true
|
|
47
|
-
})}`,
|
|
48
|
-
width: 1200
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
} : {},
|
|
52
|
-
...defaultOGImageType === 'static' ? {
|
|
53
|
-
images: [
|
|
54
|
-
{
|
|
55
|
-
alt: ogTitle,
|
|
56
|
-
height: 480,
|
|
57
|
-
url: typeof staticOGImage === 'object' ? staticOGImage?.src : staticOGImage,
|
|
58
|
-
width: 640
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
} : {},
|
|
62
|
-
title: ogTitle,
|
|
63
|
-
...incomingMetadata.openGraph || {}
|
|
64
|
-
};
|
|
65
|
-
return Promise.resolve({
|
|
66
|
-
...incomingMetadata,
|
|
67
|
-
icons,
|
|
68
|
-
metadataBase: new URL(serverURL || process.env.PAYLOAD_PUBLIC_SERVER_URL || `http://localhost:${process.env.PORT || 3000}`),
|
|
69
|
-
openGraph: mergedOpenGraph,
|
|
70
|
-
title: metaTitle
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
//# sourceMappingURL=meta.js.map
|
package/dist/lib/meta.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/meta.ts"],"sourcesContent":["import type { Metadata } from 'next'\nimport type { Icon } from 'next/dist/lib/metadata/types/metadata-types.js'\nimport type { MetaConfig } from 'payload'\n\nimport { payloadFaviconDark, payloadFaviconLight, staticOGImage } from '@payloadcms/ui/assets'\nimport * as qs from 'qs-esm'\n\nconst defaultOpenGraph: Metadata['openGraph'] = {\n description:\n 'Payload is a headless CMS and application framework built with TypeScript, Node.js, and React.',\n siteName: 'Payload App',\n title: 'Payload App',\n}\n\nexport const generateMetadata = async (\n args: { serverURL: string } & MetaConfig,\n): Promise<Metadata> => {\n const { defaultOGImageType, serverURL, titleSuffix, ...rest } = args\n\n /**\n * @todo find a way to remove the type assertion here.\n * It is a result of needing to `DeepCopy` the `MetaConfig` type from Payload.\n * This is required for the `DeepRequired` from `Config` to `SanitizedConfig`.\n */\n const incomingMetadata = rest as unknown as Metadata;\n\n const icons: Metadata['icons'] =\n incomingMetadata.icons ||\n ([\n {\n type: 'image/png',\n rel: 'icon',\n sizes: '32x32',\n url: typeof payloadFaviconDark === 'object' ? payloadFaviconDark?.src : payloadFaviconDark,\n },\n {\n type: 'image/png',\n media: '(prefers-color-scheme: dark)',\n rel: 'icon',\n sizes: '32x32',\n url:\n typeof payloadFaviconLight === 'object' ? payloadFaviconLight?.src : payloadFaviconLight,\n },\n ] satisfies Array<Icon>)\n\n const metaTitle: Metadata['title'] = [incomingMetadata.title, titleSuffix]\n .filter(Boolean)\n .join(' ')\n\n const ogTitle = `${typeof incomingMetadata.openGraph?.title === 'string' ? incomingMetadata.openGraph.title : incomingMetadata.title} ${titleSuffix}`\n\n const mergedOpenGraph: Metadata['openGraph'] = {\n ...(defaultOpenGraph || {}),\n ...(defaultOGImageType === 'dynamic'\n ? {\n images: [\n {\n alt: ogTitle,\n height: 630,\n url: `/api/og${qs.stringify(\n {\n description:\n incomingMetadata.openGraph?.description || defaultOpenGraph.description,\n title: ogTitle,\n },\n {\n addQueryPrefix: true,\n },\n )}`,\n width: 1200,\n },\n ],\n }\n : {}),\n ...(defaultOGImageType === 'static'\n ? {\n images: [\n {\n alt: ogTitle,\n height: 480,\n url: typeof staticOGImage === 'object' ? staticOGImage?.src : staticOGImage,\n width: 640,\n },\n ],\n }\n : {}),\n title: ogTitle,\n ...(incomingMetadata.openGraph || {}),\n }\n\n return Promise.resolve({\n ...incomingMetadata,\n icons,\n metadataBase: new URL(\n serverURL ||\n process.env.PAYLOAD_PUBLIC_SERVER_URL ||\n `http://localhost:${process.env.PORT || 3000}`,\n ),\n openGraph: mergedOpenGraph,\n title: metaTitle,\n })\n}\n"],"names":["payloadFaviconDark","payloadFaviconLight","staticOGImage","qs","defaultOpenGraph","description","siteName","title","generateMetadata","args","defaultOGImageType","serverURL","titleSuffix","rest","incomingMetadata","icons","type","rel","sizes","url","src","media","metaTitle","filter","Boolean","join","ogTitle","openGraph","mergedOpenGraph","images","alt","height","stringify","addQueryPrefix","width","Promise","resolve","metadataBase","URL","process","env","PAYLOAD_PUBLIC_SERVER_URL","PORT"],"mappings":"AAIA,SAASA,kBAAkB,EAAEC,mBAAmB,EAAEC,aAAa,QAAQ,wBAAuB;AAC9F,YAAYC,QAAQ,SAAQ;AAE5B,MAAMC,mBAA0C;IAC9CC,aACE;IACFC,UAAU;IACVC,OAAO;AACT;AAEA,OAAO,MAAMC,mBAAmB,OAC9BC;IAEA,MAAM,EAA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