@payloadcms/next 3.43.0-canary.7 → 3.43.0-internal.693bd81

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.
Files changed (57) hide show
  1. package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +1 -1
  2. package/dist/elements/DocumentHeader/Tabs/Tab/index.js +36 -26
  3. package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
  4. package/dist/elements/DocumentHeader/Tabs/getCustomViews.d.ts +6 -0
  5. package/dist/elements/DocumentHeader/Tabs/getCustomViews.d.ts.map +1 -0
  6. package/dist/elements/DocumentHeader/Tabs/getCustomViews.js +34 -0
  7. package/dist/elements/DocumentHeader/Tabs/getCustomViews.js.map +1 -0
  8. package/dist/elements/DocumentHeader/Tabs/getViewConfig.d.ts +7 -0
  9. package/dist/elements/DocumentHeader/Tabs/getViewConfig.d.ts.map +1 -0
  10. package/dist/elements/DocumentHeader/Tabs/getViewConfig.js +17 -0
  11. package/dist/elements/DocumentHeader/Tabs/getViewConfig.js.map +1 -0
  12. package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +1 -1
  13. package/dist/elements/DocumentHeader/Tabs/index.js +81 -35
  14. package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
  15. package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts +6 -8
  16. package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts.map +1 -1
  17. package/dist/elements/DocumentHeader/Tabs/tabs/index.js +61 -91
  18. package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
  19. package/dist/elements/DocumentHeader/index.d.ts.map +1 -1
  20. package/dist/elements/DocumentHeader/index.js.map +1 -1
  21. package/dist/prod/styles.css +1 -1
  22. package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
  23. package/dist/utilities/handleServerFunctions.js +0 -2
  24. package/dist/utilities/handleServerFunctions.js.map +1 -1
  25. package/dist/views/BrowseByFolder/buildView.d.ts.map +1 -1
  26. package/dist/views/BrowseByFolder/buildView.js +61 -40
  27. package/dist/views/BrowseByFolder/buildView.js.map +1 -1
  28. package/dist/views/CollectionFolders/buildView.d.ts.map +1 -1
  29. package/dist/views/CollectionFolders/buildView.js +59 -45
  30. package/dist/views/CollectionFolders/buildView.js.map +1 -1
  31. package/dist/views/Document/getMetaBySegment.d.ts.map +1 -1
  32. package/dist/views/Document/getMetaBySegment.js +3 -10
  33. package/dist/views/Document/getMetaBySegment.js.map +1 -1
  34. package/dist/views/Document/getViewsFromConfig.d.ts +27 -0
  35. package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -0
  36. package/dist/views/Document/getViewsFromConfig.js +330 -0
  37. package/dist/views/Document/getViewsFromConfig.js.map +1 -0
  38. package/dist/views/Document/index.d.ts +1 -2
  39. package/dist/views/Document/index.d.ts.map +1 -1
  40. package/dist/views/Document/index.js +76 -34
  41. package/dist/views/Document/index.js.map +1 -1
  42. package/dist/views/LivePreview/index.client.js +1 -3
  43. package/dist/views/LivePreview/index.client.js.map +1 -1
  44. package/dist/views/Unauthorized/index.d.ts +0 -1
  45. package/dist/views/Unauthorized/index.d.ts.map +1 -1
  46. package/dist/views/Unauthorized/index.js +1 -9
  47. package/dist/views/Unauthorized/index.js.map +1 -1
  48. package/dist/views/Unauthorized/index.scss +0 -4
  49. package/dist/views/Version/SelectComparison/index.js +0 -1
  50. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  51. package/dist/views/Versions/cells/AutosaveCell/index.js +0 -2
  52. package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
  53. package/package.json +6 -6
  54. package/dist/views/Document/getDocumentView.d.ts +0 -18
  55. package/dist/views/Document/getDocumentView.d.ts.map +0 -1
  56. package/dist/views/Document/getDocumentView.js +0 -264
  57. package/dist/views/Document/getDocumentView.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/DocumentHeader/Tabs/Tab/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAe,MAAM,SAAS,CAAA;AACrF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,YAAY,CAAA;AAElC,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAChC;IAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;CAAE,GAAG,iBAAiB,GAAG,sBAAsB,CA0EpF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/DocumentHeader/Tabs/Tab/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAe,MAAM,SAAS,CAAA;AACrF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,YAAY,CAAA;AAElC,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAChC;IAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;CAAE,GAAG,iBAAiB,GAAG,sBAAsB,CAmFpF,CAAA"}
@@ -7,6 +7,7 @@ export const DocumentTab = props => {
7
7
  const {
8
8
  apiURL,
9
9
  collectionConfig,
10
+ condition,
10
11
  globalConfig,
11
12
  href: tabHref,
12
13
  i18n,
@@ -39,31 +40,40 @@ export const DocumentTab = props => {
39
40
  href
40
41
  });
41
42
  }
42
- const labelToRender = typeof label === 'function' ? label({
43
- t: i18n.t
44
- }) : label;
45
- return /*#__PURE__*/_jsx(DocumentTabLink, {
46
- adminRoute: routes.admin,
47
- ariaLabel: labelToRender,
48
- baseClass: baseClass,
49
- href: href,
50
- isActive: isActive,
51
- newTab: newTab,
52
- children: /*#__PURE__*/_jsxs("span", {
53
- className: `${baseClass}__label`,
54
- children: [labelToRender, Pill || Pill_Component ? /*#__PURE__*/_jsxs(Fragment, {
55
- children: [" ", RenderServerComponent({
56
- Component: Pill,
57
- Fallback: Pill_Component,
58
- importMap: payload.importMap,
59
- serverProps: {
60
- i18n,
61
- payload,
62
- permissions
63
- }
64
- })]
65
- }) : null]
66
- })
67
- });
43
+ const meetsCondition = !condition || condition && Boolean(condition({
44
+ collectionConfig,
45
+ config,
46
+ globalConfig,
47
+ permissions
48
+ }));
49
+ if (meetsCondition) {
50
+ const labelToRender = typeof label === 'function' ? label({
51
+ t: i18n.t
52
+ }) : label;
53
+ return /*#__PURE__*/_jsx(DocumentTabLink, {
54
+ adminRoute: routes.admin,
55
+ ariaLabel: labelToRender,
56
+ baseClass: baseClass,
57
+ href: href,
58
+ isActive: isActive,
59
+ newTab: newTab,
60
+ children: /*#__PURE__*/_jsxs("span", {
61
+ className: `${baseClass}__label`,
62
+ children: [labelToRender, Pill || Pill_Component ? /*#__PURE__*/_jsxs(Fragment, {
63
+ children: [" ", RenderServerComponent({
64
+ Component: Pill,
65
+ Fallback: Pill_Component,
66
+ importMap: payload.importMap,
67
+ serverProps: {
68
+ i18n,
69
+ payload,
70
+ permissions
71
+ }
72
+ })]
73
+ }) : null]
74
+ })
75
+ });
76
+ }
77
+ return null;
68
78
  };
69
79
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["RenderServerComponent","Fragment","DocumentTabLink","baseClass","DocumentTab","props","apiURL","collectionConfig","globalConfig","href","tabHref","i18n","isActive","tabIsActive","label","newTab","payload","permissions","Pill","Pill_Component","config","routes","collection","global","labelToRender","t","_jsx","adminRoute","admin","ariaLabel","_jsxs","className","Component","Fallback","importMap","serverProps"],"sources":["../../../../../src/elements/DocumentHeader/Tabs/Tab/index.tsx"],"sourcesContent":["import type { DocumentTabConfig, DocumentTabServerProps, ServerProps } from 'payload'\nimport type React from 'react'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { Fragment } from 'react'\n\nimport { DocumentTabLink } from './TabLink.js'\nimport './index.scss'\n\nexport const baseClass = 'doc-tab'\n\nexport const DocumentTab: React.FC<\n { readonly Pill_Component?: React.FC } & DocumentTabConfig & DocumentTabServerProps\n> = (props) => {\n const {\n apiURL,\n collectionConfig,\n globalConfig,\n href: tabHref,\n i18n,\n isActive: tabIsActive,\n label,\n newTab,\n payload,\n permissions,\n Pill,\n Pill_Component,\n } = props\n\n const { config } = payload\n const { routes } = config\n\n let href = typeof tabHref === 'string' ? tabHref : ''\n let isActive = typeof tabIsActive === 'boolean' ? tabIsActive : false\n\n if (typeof tabHref === 'function') {\n href = tabHref({\n apiURL,\n collection: collectionConfig,\n global: globalConfig,\n routes,\n })\n }\n\n if (typeof tabIsActive === 'function') {\n isActive = tabIsActive({\n href,\n })\n }\n\n const labelToRender =\n typeof label === 'function'\n ? label({\n t: i18n.t,\n })\n : label\n\n return (\n <DocumentTabLink\n adminRoute={routes.admin}\n ariaLabel={labelToRender}\n baseClass={baseClass}\n href={href}\n isActive={isActive}\n newTab={newTab}\n >\n <span className={`${baseClass}__label`}>\n {labelToRender}\n {Pill || Pill_Component ? (\n <Fragment>\n &nbsp;\n {RenderServerComponent({\n Component: Pill,\n Fallback: Pill_Component,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n payload,\n permissions,\n } satisfies ServerProps,\n })}\n </Fragment>\n ) : null}\n </span>\n </DocumentTabLink>\n )\n}\n"],"mappings":";AAGA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AAEzB,SAASC,eAAe,QAAQ;AAGhC,OAAO,MAAMC,SAAA,GAAY;AAEzB,OAAO,MAAMC,WAAA,GAERC,KAAA;EACH,MAAM;IACJC,MAAM;IACNC,gBAAgB;IAChBC,YAAY;IACZC,IAAA,EAAMC,OAAO;IACbC,IAAI;IACJC,QAAA,EAAUC,WAAW;IACrBC,KAAK;IACLC,MAAM;IACNC,OAAO;IACPC,WAAW;IACXC,IAAI;IACJC;EAAc,CACf,GAAGd,KAAA;EAEJ,MAAM;IAAEe;EAAM,CAAE,GAAGJ,OAAA;EACnB,MAAM;IAAEK;EAAM,CAAE,GAAGD,MAAA;EAEnB,IAAIX,IAAA,GAAO,OAAOC,OAAA,KAAY,WAAWA,OAAA,GAAU;EACnD,IAAIE,QAAA,GAAW,OAAOC,WAAA,KAAgB,YAAYA,WAAA,GAAc;EAEhE,IAAI,OAAOH,OAAA,KAAY,YAAY;IACjCD,IAAA,GAAOC,OAAA,CAAQ;MACbJ,MAAA;MACAgB,UAAA,EAAYf,gBAAA;MACZgB,MAAA,EAAQf,YAAA;MACRa;IACF;EACF;EAEA,IAAI,OAAOR,WAAA,KAAgB,YAAY;IACrCD,QAAA,GAAWC,WAAA,CAAY;MACrBJ;IACF;EACF;EAEA,MAAMe,aAAA,GACJ,OAAOV,KAAA,KAAU,aACbA,KAAA,CAAM;IACJW,CAAA,EAAGd,IAAA,CAAKc;EACV,KACAX,KAAA;EAEN,oBACEY,IAAA,CAACxB,eAAA;IACCyB,UAAA,EAAYN,MAAA,CAAOO,KAAK;IACxBC,SAAA,EAAWL,aAAA;IACXrB,SAAA,EAAWA,SAAA;IACXM,IAAA,EAAMA,IAAA;IACNG,QAAA,EAAUA,QAAA;IACVG,MAAA,EAAQA,MAAA;cAER,aAAAe,KAAA,CAAC;MAAKC,SAAA,EAAW,GAAG5B,SAAA,SAAkB;iBACnCqB,aAAA,EACAN,IAAA,IAAQC,cAAA,gBACPW,KAAA,CAAC7B,QAAA;mBAAS,KAEPD,qBAAA,CAAsB;UACrBgC,SAAA,EAAWd,IAAA;UACXe,QAAA,EAAUd,cAAA;UACVe,SAAA,EAAWlB,OAAA,CAAQkB,SAAS;UAC5BC,WAAA,EAAa;YACXxB,IAAA;YACAK,OAAA;YACAC;UACF;QACF;WAEA;;;AAIZ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["RenderServerComponent","Fragment","DocumentTabLink","baseClass","DocumentTab","props","apiURL","collectionConfig","condition","globalConfig","href","tabHref","i18n","isActive","tabIsActive","label","newTab","payload","permissions","Pill","Pill_Component","config","routes","collection","global","meetsCondition","Boolean","labelToRender","t","_jsx","adminRoute","admin","ariaLabel","_jsxs","className","Component","Fallback","importMap","serverProps"],"sources":["../../../../../src/elements/DocumentHeader/Tabs/Tab/index.tsx"],"sourcesContent":["import type { DocumentTabConfig, DocumentTabServerProps, ServerProps } from 'payload'\nimport type React from 'react'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { Fragment } from 'react'\n\nimport { DocumentTabLink } from './TabLink.js'\nimport './index.scss'\n\nexport const baseClass = 'doc-tab'\n\nexport const DocumentTab: React.FC<\n { readonly Pill_Component?: React.FC } & DocumentTabConfig & DocumentTabServerProps\n> = (props) => {\n const {\n apiURL,\n collectionConfig,\n condition,\n globalConfig,\n href: tabHref,\n i18n,\n isActive: tabIsActive,\n label,\n newTab,\n payload,\n permissions,\n Pill,\n Pill_Component,\n } = props\n\n const { config } = payload\n const { routes } = config\n\n let href = typeof tabHref === 'string' ? tabHref : ''\n let isActive = typeof tabIsActive === 'boolean' ? tabIsActive : false\n\n if (typeof tabHref === 'function') {\n href = tabHref({\n apiURL,\n collection: collectionConfig,\n global: globalConfig,\n routes,\n })\n }\n\n if (typeof tabIsActive === 'function') {\n isActive = tabIsActive({\n href,\n })\n }\n\n const meetsCondition =\n !condition ||\n (condition && Boolean(condition({ collectionConfig, config, globalConfig, permissions })))\n\n if (meetsCondition) {\n const labelToRender =\n typeof label === 'function'\n ? label({\n t: i18n.t,\n })\n : label\n\n return (\n <DocumentTabLink\n adminRoute={routes.admin}\n ariaLabel={labelToRender}\n baseClass={baseClass}\n href={href}\n isActive={isActive}\n newTab={newTab}\n >\n <span className={`${baseClass}__label`}>\n {labelToRender}\n {Pill || Pill_Component ? (\n <Fragment>\n &nbsp;\n {RenderServerComponent({\n Component: Pill,\n Fallback: Pill_Component,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n payload,\n permissions,\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AAA;MACC4B,UAAA,EAAYR,MAAA,CAAOS,KAAK;MACxBC,SAAA,EAAWL,aAAA;MACXxB,SAAA,EAAWA,SAAA;MACXO,IAAA,EAAMA,IAAA;MACNG,QAAA,EAAUA,QAAA;MACVG,MAAA,EAAQA,MAAA;gBAER,aAAAiB,KAAA,CAAC;QAAKC,SAAA,EAAW,GAAG/B,SAAA,SAAkB;mBACnCwB,aAAA,EACAR,IAAA,IAAQC,cAAA,gBACPa,KAAA,CAAChC,QAAA;qBAAS,KAEPD,qBAAA,CAAsB;YACrBmC,SAAA,EAAWhB,IAAA;YACXiB,QAAA,EAAUhB,cAAA;YACViB,SAAA,EAAWpB,OAAA,CAAQoB,SAAS;YAC5BC,WAAA,EAAa;cACX1B,IAAA;cACAK,OAAA;cACAC;YACF;UACF;aAEA;;;EAIZ;EAEA,OAAO;AACT","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { EditViewConfig, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload';
2
+ export declare const getCustomViews: (args: {
3
+ collectionConfig: SanitizedCollectionConfig;
4
+ globalConfig: SanitizedGlobalConfig;
5
+ }) => EditViewConfig[];
6
+ //# sourceMappingURL=getCustomViews.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCustomViews.d.ts","sourceRoot":"","sources":["../../../../src/elements/DocumentHeader/Tabs/getCustomViews.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAI/F,eAAO,MAAM,cAAc,SAAU;IACnC,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,YAAY,EAAE,qBAAqB,CAAA;CACpC,KAAG,cAAc,EAsCjB,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { documentViewKeys } from './tabs/index.js';
2
+ export const getCustomViews = args => {
3
+ const {
4
+ collectionConfig,
5
+ globalConfig
6
+ } = args;
7
+ let customViews;
8
+ if (collectionConfig) {
9
+ const collectionViewsConfig = typeof collectionConfig?.admin?.components?.views?.edit === 'object' && typeof collectionConfig?.admin?.components?.views?.edit !== 'function' ? collectionConfig?.admin?.components?.views?.edit : undefined;
10
+ customViews = Object.entries(collectionViewsConfig || {}).reduce((prev, [key, view]) => {
11
+ if (documentViewKeys.includes(key)) {
12
+ return prev;
13
+ }
14
+ return [...prev, {
15
+ ...view,
16
+ key
17
+ }];
18
+ }, []);
19
+ }
20
+ if (globalConfig) {
21
+ const globalViewsConfig = typeof globalConfig?.admin?.components?.views?.edit === 'object' && typeof globalConfig?.admin?.components?.views?.edit !== 'function' ? globalConfig?.admin?.components?.views?.edit : undefined;
22
+ customViews = Object.entries(globalViewsConfig || {}).reduce((prev, [key, view]) => {
23
+ if (documentViewKeys.includes(key)) {
24
+ return prev;
25
+ }
26
+ return [...prev, {
27
+ ...view,
28
+ key
29
+ }];
30
+ }, []);
31
+ }
32
+ return customViews;
33
+ };
34
+ //# sourceMappingURL=getCustomViews.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCustomViews.js","names":["documentViewKeys","getCustomViews","args","collectionConfig","globalConfig","customViews","collectionViewsConfig","admin","components","views","edit","undefined","Object","entries","reduce","prev","key","view","includes","globalViewsConfig"],"sources":["../../../../src/elements/DocumentHeader/Tabs/getCustomViews.ts"],"sourcesContent":["import type { EditViewConfig, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { documentViewKeys } from './tabs/index.js'\n\nexport const getCustomViews = (args: {\n collectionConfig: SanitizedCollectionConfig\n globalConfig: SanitizedGlobalConfig\n}): EditViewConfig[] => {\n const { collectionConfig, globalConfig } = args\n\n let customViews: EditViewConfig[]\n\n if (collectionConfig) {\n const collectionViewsConfig =\n typeof collectionConfig?.admin?.components?.views?.edit === 'object' &&\n typeof collectionConfig?.admin?.components?.views?.edit !== 'function'\n ? collectionConfig?.admin?.components?.views?.edit\n : undefined\n\n customViews = Object.entries(collectionViewsConfig || {}).reduce((prev, [key, view]) => {\n if (documentViewKeys.includes(key)) {\n return prev\n }\n\n return [...prev, { ...view, key }]\n }, [])\n }\n\n if (globalConfig) {\n const globalViewsConfig =\n typeof globalConfig?.admin?.components?.views?.edit === 'object' &&\n typeof globalConfig?.admin?.components?.views?.edit !== 'function'\n ? globalConfig?.admin?.components?.views?.edit\n : undefined\n\n customViews = Object.entries(globalViewsConfig || {}).reduce((prev, [key, view]) => {\n if (documentViewKeys.includes(key)) {\n return prev\n }\n\n return [...prev, { ...view, key }]\n }, [])\n }\n\n return customViews\n}\n"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ;AAEjC,OAAO,MAAMC,cAAA,GAAkBC,IAAA;EAI7B,MAAM;IAAEC,gBAAgB;IAAEC;EAAY,CAAE,GAAGF,IAAA;EAE3C,IAAIG,WAAA;EAEJ,IAAIF,gBAAA,EAAkB;IACpB,MAAMG,qBAAA,GACJ,OAAOH,gBAAA,EAAkBI,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,KAAS,YAC5D,OAAOP,gBAAA,EAAkBI,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,KAAS,aACxDP,gBAAA,EAAkBI,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,GAC5CC,SAAA;IAENN,WAAA,GAAcO,MAAA,CAAOC,OAAO,CAACP,qBAAA,IAAyB,CAAC,GAAGQ,MAAM,CAAC,CAACC,IAAA,EAAM,CAACC,GAAA,EAAKC,IAAA,CAAK;MACjF,IAAIjB,gBAAA,CAAiBkB,QAAQ,CAACF,GAAA,GAAM;QAClC,OAAOD,IAAA;MACT;MAEA,OAAO,C,GAAIA,IAAA,EAAM;QAAE,GAAGE,IAAI;QAAED;MAAI,EAAE;IACpC,GAAG,EAAE;EACP;EAEA,IAAIZ,YAAA,EAAc;IAChB,MAAMe,iBAAA,GACJ,OAAOf,YAAA,EAAcG,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,KAAS,YACxD,OAAON,YAAA,EAAcG,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,KAAS,aACpDN,YAAA,EAAcG,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,GACxCC,SAAA;IAENN,WAAA,GAAcO,MAAA,CAAOC,OAAO,CAACM,iBAAA,IAAqB,CAAC,GAAGL,MAAM,CAAC,CAACC,IAAA,EAAM,CAACC,GAAA,EAAKC,IAAA,CAAK;MAC7E,IAAIjB,gBAAA,CAAiBkB,QAAQ,CAACF,GAAA,GAAM;QAClC,OAAOD,IAAA;MACT;MAEA,OAAO,C,GAAIA,IAAA,EAAM;QAAE,GAAGE,IAAI;QAAED;MAAI,EAAE;IACpC,GAAG,EAAE;EACP;EAEA,OAAOX,WAAA;AACT","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import type { EditViewConfig, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload';
2
+ export declare const getViewConfig: (args: {
3
+ collectionConfig: SanitizedCollectionConfig;
4
+ globalConfig: SanitizedGlobalConfig;
5
+ name: string;
6
+ }) => EditViewConfig;
7
+ //# sourceMappingURL=getViewConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getViewConfig.d.ts","sourceRoot":"","sources":["../../../../src/elements/DocumentHeader/Tabs/getViewConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE/F,eAAO,MAAM,aAAa,SAAU;IAClC,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,YAAY,EAAE,qBAAqB,CAAA;IACnC,IAAI,EAAE,MAAM,CAAA;CACb,KAAG,cAwBH,CAAA"}
@@ -0,0 +1,17 @@
1
+ export const getViewConfig = args => {
2
+ const {
3
+ name,
4
+ collectionConfig,
5
+ globalConfig
6
+ } = args;
7
+ if (collectionConfig) {
8
+ const collectionConfigViewsConfig = typeof collectionConfig?.admin?.components?.views?.edit === 'object' && typeof collectionConfig?.admin?.components?.views?.edit !== 'function' ? collectionConfig?.admin?.components?.views?.edit : undefined;
9
+ return collectionConfigViewsConfig?.[name];
10
+ }
11
+ if (globalConfig) {
12
+ const globalConfigViewsConfig = typeof globalConfig?.admin?.components?.views?.edit === 'object' && typeof globalConfig?.admin?.components?.views?.edit !== 'function' ? globalConfig?.admin?.components?.views?.edit : undefined;
13
+ return globalConfigViewsConfig?.[name];
14
+ }
15
+ return null;
16
+ };
17
+ //# sourceMappingURL=getViewConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getViewConfig.js","names":["getViewConfig","args","name","collectionConfig","globalConfig","collectionConfigViewsConfig","admin","components","views","edit","undefined","globalConfigViewsConfig"],"sources":["../../../../src/elements/DocumentHeader/Tabs/getViewConfig.ts"],"sourcesContent":["import type { EditViewConfig, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nexport const getViewConfig = (args: {\n collectionConfig: SanitizedCollectionConfig\n globalConfig: SanitizedGlobalConfig\n name: string\n}): EditViewConfig => {\n const { name, collectionConfig, globalConfig } = args\n\n if (collectionConfig) {\n const collectionConfigViewsConfig =\n typeof collectionConfig?.admin?.components?.views?.edit === 'object' &&\n typeof collectionConfig?.admin?.components?.views?.edit !== 'function'\n ? collectionConfig?.admin?.components?.views?.edit\n : undefined\n\n return collectionConfigViewsConfig?.[name]\n }\n\n if (globalConfig) {\n const globalConfigViewsConfig =\n typeof globalConfig?.admin?.components?.views?.edit === 'object' &&\n typeof globalConfig?.admin?.components?.views?.edit !== 'function'\n ? globalConfig?.admin?.components?.views?.edit\n : undefined\n\n return globalConfigViewsConfig?.[name]\n }\n\n return null\n}\n"],"mappings":"AAEA,OAAO,MAAMA,aAAA,GAAiBC,IAAA;EAK5B,MAAM;IAAEC,IAAI;IAAEC,gBAAgB;IAAEC;EAAY,CAAE,GAAGH,IAAA;EAEjD,IAAIE,gBAAA,EAAkB;IACpB,MAAME,2BAAA,GACJ,OAAOF,gBAAA,EAAkBG,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,KAAS,YAC5D,OAAON,gBAAA,EAAkBG,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,KAAS,aACxDN,gBAAA,EAAkBG,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,GAC5CC,SAAA;IAEN,OAAOL,2BAAA,GAA8BH,IAAA,CAAK;EAC5C;EAEA,IAAIE,YAAA,EAAc;IAChB,MAAMO,uBAAA,GACJ,OAAOP,YAAA,EAAcE,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,KAAS,YACxD,OAAOL,YAAA,EAAcE,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,KAAS,aACpDL,YAAA,EAAcE,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,GACxCC,SAAA;IAEN,OAAOC,uBAAA,GAA0BT,IAAA,CAAK;EACxC;EAEA,OAAO;AACT","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/DocumentHeader/Tabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAGV,OAAO,EACP,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,YAAY,EAAE,qBAAqB,CAAA;IACnC,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,oBAAoB,CAAA;CAClC,CA0DA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/DocumentHeader/Tabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAGV,OAAO,EACP,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,cAAc,CAAA;AAOrB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,YAAY,EAAE,qBAAqB,CAAA;IACnC,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,oBAAoB,CAAA;CAClC,CAiHA,CAAA"}
@@ -1,9 +1,11 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
3
3
  import React from 'react';
4
+ import { getCustomViews } from './getCustomViews.js';
5
+ import { getViewConfig } from './getViewConfig.js';
4
6
  import { ShouldRenderTabs } from './ShouldRenderTabs.js';
5
7
  import { DocumentTab } from './Tab/index.js';
6
- import { getTabs } from './tabs/index.js';
8
+ import { tabs as defaultTabs } from './tabs/index.js';
7
9
  const baseClass = 'doc-tabs';
8
10
  export const DocumentTabs = props => {
9
11
  const {
@@ -16,7 +18,7 @@ export const DocumentTabs = props => {
16
18
  const {
17
19
  config
18
20
  } = payload;
19
- const tabs = getTabs({
21
+ const customViews = getCustomViews({
20
22
  collectionConfig,
21
23
  globalConfig
22
24
  });
@@ -25,47 +27,91 @@ export const DocumentTabs = props => {
25
27
  className: baseClass,
26
28
  children: /*#__PURE__*/_jsx("div", {
27
29
  className: `${baseClass}__tabs-container`,
28
- children: /*#__PURE__*/_jsx("ul", {
30
+ children: /*#__PURE__*/_jsxs("ul", {
29
31
  className: `${baseClass}__tabs`,
30
- children: tabs?.map(({
31
- tab,
32
- viewPath
33
- }, index) => {
32
+ children: [Object.entries(defaultTabs)?.sort(([, a], [, b]) => {
33
+ if (a.order === undefined && b.order === undefined) {
34
+ return 0;
35
+ } else if (a.order === undefined) {
36
+ return 1;
37
+ } else if (b.order === undefined) {
38
+ return -1;
39
+ }
40
+ return a.order - b.order;
41
+ })?.map(([name, tab], index) => {
42
+ const viewConfig = getViewConfig({
43
+ name,
44
+ collectionConfig,
45
+ globalConfig
46
+ });
47
+ const tabFromConfig = viewConfig && 'tab' in viewConfig ? viewConfig.tab : undefined;
34
48
  const {
35
49
  condition
36
- } = tab || {};
37
- const meetsCondition = !condition || condition({
50
+ } = tabFromConfig || {};
51
+ const meetsCondition = !condition || condition && Boolean(condition({
38
52
  collectionConfig,
39
53
  config,
40
54
  globalConfig,
41
55
  permissions
42
- });
43
- if (!meetsCondition) {
44
- return null;
56
+ }));
57
+ const path = viewConfig && 'path' in viewConfig ? viewConfig.path : '';
58
+ if (meetsCondition) {
59
+ if (tabFromConfig?.Component) {
60
+ return RenderServerComponent({
61
+ clientProps: {
62
+ path
63
+ },
64
+ Component: tabFromConfig.Component,
65
+ importMap: payload.importMap,
66
+ key: `tab-${index}`,
67
+ serverProps: {
68
+ collectionConfig,
69
+ globalConfig,
70
+ i18n,
71
+ payload,
72
+ permissions
73
+ }
74
+ });
75
+ }
76
+ return /*#__PURE__*/_jsx(DocumentTab, {
77
+ path: path,
78
+ ...props,
79
+ ...(tab || {}),
80
+ ...(tabFromConfig || {})
81
+ }, `tab-${index}`);
45
82
  }
46
- if (tab?.Component) {
47
- return RenderServerComponent({
48
- clientProps: {
49
- path: viewPath
50
- },
51
- Component: tab.Component,
52
- importMap: payload.importMap,
53
- key: `tab-${index}`,
54
- serverProps: {
55
- collectionConfig,
56
- globalConfig,
57
- i18n,
58
- payload,
59
- permissions
60
- }
61
- });
83
+ return null;
84
+ }), customViews?.map((CustomView, index) => {
85
+ if ('tab' in CustomView) {
86
+ const {
87
+ path,
88
+ tab
89
+ } = CustomView;
90
+ if (tab.Component) {
91
+ return RenderServerComponent({
92
+ clientProps: {
93
+ path
94
+ },
95
+ Component: tab.Component,
96
+ importMap: payload.importMap,
97
+ key: `tab-custom-${index}`,
98
+ serverProps: {
99
+ collectionConfig,
100
+ globalConfig,
101
+ i18n,
102
+ payload,
103
+ permissions
104
+ }
105
+ });
106
+ }
107
+ return /*#__PURE__*/_jsx(DocumentTab, {
108
+ path: path,
109
+ ...props,
110
+ ...tab
111
+ }, `tab-custom-${index}`);
62
112
  }
63
- return /*#__PURE__*/_jsx(DocumentTab, {
64
- path: viewPath,
65
- ...props,
66
- ...tab
67
- }, `tab-${index}`);
68
- })
113
+ return null;
114
+ })]
69
115
  })
70
116
  })
71
117
  })
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["RenderServerComponent","React","ShouldRenderTabs","DocumentTab","getTabs","baseClass","DocumentTabs","props","collectionConfig","globalConfig","i18n","payload","permissions","config","tabs","_jsx","className","map","tab","viewPath","index","condition","meetsCondition","Component","clientProps","path","importMap","key","serverProps"],"sources":["../../../../src/elements/DocumentHeader/Tabs/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n DocumentTabClientProps,\n DocumentTabServerPropsOnly,\n Payload,\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport { ShouldRenderTabs } from './ShouldRenderTabs.js'\nimport { DocumentTab } from './Tab/index.js'\nimport { getTabs } from './tabs/index.js'\nimport './index.scss'\n\nconst baseClass = 'doc-tabs'\n\nexport const DocumentTabs: React.FC<{\n collectionConfig: SanitizedCollectionConfig\n globalConfig: SanitizedGlobalConfig\n i18n: I18n\n payload: Payload\n permissions: SanitizedPermissions\n}> = (props) => {\n const { collectionConfig, globalConfig, i18n, payload, permissions } = props\n const { config } = payload\n\n const tabs = getTabs({\n collectionConfig,\n globalConfig,\n })\n\n return (\n <ShouldRenderTabs>\n <div className={baseClass}>\n <div className={`${baseClass}__tabs-container`}>\n <ul className={`${baseClass}__tabs`}>\n {tabs?.map(({ tab, viewPath }, index) => {\n const { condition } = tab || {}\n\n const meetsCondition =\n !condition || condition({ collectionConfig, config, globalConfig, permissions })\n\n if (!meetsCondition) {\n return null\n }\n\n if (tab?.Component) {\n return RenderServerComponent({\n clientProps: {\n path: viewPath,\n } satisfies DocumentTabClientProps,\n Component: tab.Component,\n importMap: payload.importMap,\n key: `tab-${index}`,\n serverProps: {\n collectionConfig,\n globalConfig,\n i18n,\n payload,\n permissions,\n } satisfies DocumentTabServerPropsOnly,\n })\n }\n\n return (\n <DocumentTab\n key={`tab-${index}`}\n path={viewPath}\n {...{\n ...props,\n ...tab,\n }}\n />\n )\n })}\n </ul>\n </div>\n </div>\n </ShouldRenderTabs>\n )\n}\n"],"mappings":";AAUA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAElB,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,OAAO,QAAQ;AAGxB,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,YAAA,GAMPC,KAAA;EACJ,MAAM;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAW,CAAE,GAAGL,KAAA;EACvE,MAAM;IAAEM;EAAM,CAAE,GAAGF,OAAA;EAEnB,MAAMG,IAAA,GAAOV,OAAA,CAAQ;IACnBI,gBAAA;IACAC;EACF;EAEA,oBACEM,IAAA,CAACb,gBAAA;cACC,aAAAa,IAAA,CAAC;MAAIC,SAAA,EAAWX,SAAA;gBACd,aAAAU,IAAA,CAAC;QAAIC,SAAA,EAAW,GAAGX,SAAA,kBAA2B;kBAC5C,aAAAU,IAAA,CAAC;UAAGC,SAAA,EAAW,GAAGX,SAAA,QAAiB;oBAChCS,IAAA,EAAMG,GAAA,CAAI,CAAC;YAAEC,GAAG;YAAEC;UAAQ,CAAE,EAAEC,KAAA;YAC7B,MAAM;cAAEC;YAAS,CAAE,GAAGH,GAAA,IAAO,CAAC;YAE9B,MAAMI,cAAA,GACJ,CAACD,SAAA,IAAaA,SAAA,CAAU;cAAEb,gBAAA;cAAkBK,MAAA;cAAQJ,YAAA;cAAcG;YAAY;YAEhF,IAAI,CAACU,cAAA,EAAgB;cACnB,OAAO;YACT;YAEA,IAAIJ,GAAA,EAAKK,SAAA,EAAW;cAClB,OAAOvB,qBAAA,CAAsB;gBAC3BwB,WAAA,EAAa;kBACXC,IAAA,EAAMN;gBACR;gBACAI,SAAA,EAAWL,GAAA,CAAIK,SAAS;gBACxBG,SAAA,EAAWf,OAAA,CAAQe,SAAS;gBAC5BC,GAAA,EAAK,OAAOP,KAAA,EAAO;gBACnBQ,WAAA,EAAa;kBACXpB,gBAAA;kBACAC,YAAA;kBACAC,IAAA;kBACAC,OAAA;kBACAC;gBACF;cACF;YACF;YAEA,oBACEG,IAAA,CAACZ,WAAA;cAECsB,IAAA,EAAMN,QAAA;cAEJ,GAAGZ,KAAK;cACR,GAAGW;eAJA,OAAOE,KAAA,EAAO;UAQzB;;;;;AAMZ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["RenderServerComponent","React","getCustomViews","getViewConfig","ShouldRenderTabs","DocumentTab","tabs","defaultTabs","baseClass","DocumentTabs","props","collectionConfig","globalConfig","i18n","payload","permissions","config","customViews","_jsx","className","_jsxs","Object","entries","sort","a","b","order","undefined","map","name","tab","index","viewConfig","tabFromConfig","condition","meetsCondition","Boolean","path","Component","clientProps","importMap","key","serverProps","CustomView"],"sources":["../../../../src/elements/DocumentHeader/Tabs/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n DocumentTabClientProps,\n DocumentTabServerPropsOnly,\n Payload,\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport { getCustomViews } from './getCustomViews.js'\nimport { getViewConfig } from './getViewConfig.js'\nimport './index.scss'\nimport { ShouldRenderTabs } from './ShouldRenderTabs.js'\nimport { DocumentTab } from './Tab/index.js'\nimport { tabs as defaultTabs } from './tabs/index.js'\n\nconst baseClass = 'doc-tabs'\n\nexport const DocumentTabs: React.FC<{\n collectionConfig: SanitizedCollectionConfig\n globalConfig: SanitizedGlobalConfig\n i18n: I18n\n payload: Payload\n permissions: SanitizedPermissions\n}> = (props) => {\n const { collectionConfig, globalConfig, i18n, payload, permissions } = props\n const { config } = payload\n\n const customViews = getCustomViews({ collectionConfig, globalConfig })\n\n return (\n <ShouldRenderTabs>\n <div className={baseClass}>\n <div className={`${baseClass}__tabs-container`}>\n <ul className={`${baseClass}__tabs`}>\n {Object.entries(defaultTabs)\n // sort `defaultViews` based on `order` property from smallest to largest\n // if no `order`, append the view to the end\n // TODO: open `order` to the config and merge `defaultViews` with `customViews`\n ?.sort(([, a], [, b]) => {\n if (a.order === undefined && b.order === undefined) {\n return 0\n } else if (a.order === undefined) {\n return 1\n } else if (b.order === undefined) {\n return -1\n }\n return a.order - b.order\n })\n ?.map(([name, tab], index) => {\n const viewConfig = getViewConfig({ name, collectionConfig, globalConfig })\n const tabFromConfig = viewConfig && 'tab' in viewConfig ? viewConfig.tab : undefined\n\n const { condition } = tabFromConfig || {}\n\n const meetsCondition =\n !condition ||\n (condition &&\n Boolean(condition({ collectionConfig, config, globalConfig, permissions })))\n\n const path = viewConfig && 'path' in viewConfig ? viewConfig.path : ''\n\n if (meetsCondition) {\n if (tabFromConfig?.Component) {\n return RenderServerComponent({\n clientProps: {\n path,\n } satisfies DocumentTabClientProps,\n Component: tabFromConfig.Component,\n importMap: payload.importMap,\n key: `tab-${index}`,\n serverProps: {\n collectionConfig,\n globalConfig,\n i18n,\n payload,\n permissions,\n } satisfies DocumentTabServerPropsOnly,\n })\n }\n\n return (\n <DocumentTab\n key={`tab-${index}`}\n path={path}\n {...{\n ...props,\n ...(tab || {}),\n ...(tabFromConfig || {}),\n }}\n />\n )\n }\n\n return null\n })}\n {customViews?.map((CustomView, index) => {\n if ('tab' in CustomView) {\n const { path, tab } = CustomView\n\n if (tab.Component) {\n return RenderServerComponent({\n clientProps: {\n path,\n } satisfies DocumentTabClientProps,\n Component: tab.Component,\n importMap: payload.importMap,\n key: `tab-custom-${index}`,\n serverProps: {\n collectionConfig,\n globalConfig,\n i18n,\n payload,\n permissions,\n } satisfies DocumentTabServerPropsOnly,\n })\n }\n\n return (\n <DocumentTab\n key={`tab-custom-${index}`}\n path={path}\n {...{\n ...props,\n ...tab,\n }}\n />\n )\n }\n\n return null\n })}\n </ul>\n </div>\n </div>\n </ShouldRenderTabs>\n )\n}\n"],"mappings":";AAUA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAE9B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,IAAA,IAAQC,WAAW,QAAQ;AAEpC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,YAAA,GAMPC,KAAA;EACJ,MAAM;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAW,CAAE,GAAGL,KAAA;EACvE,MAAM;IAAEM;EAAM,CAAE,GAAGF,OAAA;EAEnB,MAAMG,WAAA,GAAcf,cAAA,CAAe;IAAES,gBAAA;IAAkBC;EAAa;EAEpE,oBACEM,IAAA,CAACd,gBAAA;cACC,aAAAc,IAAA,CAAC;MAAIC,SAAA,EAAWX,SAAA;gBACd,aAAAU,IAAA,CAAC;QAAIC,SAAA,EAAW,GAAGX,SAAA,kBAA2B;kBAC5C,aAAAY,KAAA,CAAC;UAAGD,SAAA,EAAW,GAAGX,SAAA,QAAiB;qB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BACX/B,gBAAA;oBACAC,YAAA;oBACAC,IAAA;oBACAC,OAAA;oBACAC;kBACF;gBACF;cACF;cAEA,oBACEG,IAAA,CAACb,WAAA;gBAECgC,IAAA,EAAMA,IAAA;gBAEJ,GAAG3B,KAAK;gBACR,IAAIoB,GAAA,IAAO,CAAC,CAAC;gBACb,IAAIG,aAAA,IAAiB,CAAC,CAAC;iBALpB,OAAOF,KAAA,EAAO;YASzB;YAEA,OAAO;UACT,IACDd,WAAA,EAAaW,GAAA,CAAI,CAACe,UAAA,EAAYZ,KAAA;YAC7B,IAAI,SAASY,UAAA,EAAY;cACvB,MAAM;gBAAEN,IAAI;gBAAEP;cAAG,CAAE,GAAGa,UAAA;cAEtB,IAAIb,GAAA,CAAIQ,SAAS,EAAE;gBACjB,OAAOtC,qBAAA,CAAsB;kBAC3BuC,WAAA,EAAa;oBACXF;kBACF;kBACAC,SAAA,EAAWR,GAAA,CAAIQ,SAAS;kBACxBE,SAAA,EAAW1B,OAAA,CAAQ0B,SAAS;kBAC5BC,GAAA,EAAK,cAAcV,KAAA,EAAO;kBAC1BW,WAAA,EAAa;oBACX/B,gBAAA;oBACAC,YAAA;oBACAC,IAAA;oBACAC,OAAA;oBACAC;kBACF;gBACF;cACF;cAEA,oBACEG,IAAA,CAACb,WAAA;gBAECgC,IAAA,EAAMA,IAAA;gBAEJ,GAAG3B,KAAK;gBACR,GAAGoB;iBAJA,cAAcC,KAAA,EAAO;YAQhC;YAEA,OAAO;UACT;;;;;AAMZ","ignoreList":[]}
@@ -1,11 +1,9 @@
1
- import type { DocumentTabConfig, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload';
1
+ import type { DocumentTabConfig } from 'payload';
2
+ import type React from 'react';
2
3
  export declare const documentViewKeys: string[];
3
4
  export type DocumentViewKey = (typeof documentViewKeys)[number];
4
- export declare const getTabs: ({ collectionConfig, globalConfig, }: {
5
- collectionConfig?: SanitizedCollectionConfig;
6
- globalConfig?: SanitizedGlobalConfig;
7
- }) => {
8
- tab: DocumentTabConfig;
9
- viewPath: string;
10
- }[];
5
+ export declare const tabs: Record<DocumentViewKey, {
6
+ order?: number;
7
+ Pill_Component?: React.FC;
8
+ } & DocumentTabConfig>;
11
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/DocumentHeader/Tabs/tabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAIlG,eAAO,MAAM,gBAAgB,UAAgD,CAAA;AAE7E,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/D,eAAO,MAAM,OAAO,wCAGjB;IACD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;CACrC,KAAG;IAAE,GAAG,EAAE,iBAAiB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAkG/C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/DocumentHeader/Tabs/tabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,eAAO,MAAM,gBAAgB,UAQ5B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/D,eAAO,MAAM,IAAI,EAAE,MAAM,CACvB,eAAe,EACf;IACE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;CAC1B,GAAG,iBAAiB,CA4DtB,CAAA"}
@@ -1,95 +1,65 @@
1
1
  import { VersionsPill } from './VersionsPill/index.js';
2
- export const documentViewKeys = ['api', 'default', 'livePreview', 'versions'];
3
- export const getTabs = ({
4
- collectionConfig,
5
- globalConfig
6
- }) => {
7
- const customViews = collectionConfig?.admin?.components?.views?.edit || globalConfig?.admin?.components?.views?.edit || {};
8
- return [{
9
- tab: {
10
- href: '',
11
- label: ({
12
- t
13
- }) => t('general:edit'),
14
- order: 100,
15
- ...(customViews?.['default']?.tab || {})
2
+ export const documentViewKeys = ['api', 'default', 'livePreview', 'references', 'relationships', 'version', 'versions'];
3
+ export const tabs = {
4
+ api: {
5
+ condition: ({
6
+ collectionConfig,
7
+ globalConfig
8
+ }) => collectionConfig && !collectionConfig?.admin?.hideAPIURL || globalConfig && !globalConfig?.admin?.hideAPIURL,
9
+ href: '/api',
10
+ label: 'API',
11
+ order: 1000
12
+ },
13
+ default: {
14
+ href: '',
15
+ // isActive: ({ href, location }) =>
16
+ // location.pathname === href || location.pathname === `${href}/create`,
17
+ label: ({
18
+ t
19
+ }) => t('general:edit'),
20
+ order: 0
21
+ },
22
+ livePreview: {
23
+ condition: ({
24
+ collectionConfig,
25
+ config,
26
+ globalConfig
27
+ }) => {
28
+ if (collectionConfig) {
29
+ return Boolean(config?.admin?.livePreview?.collections?.includes(collectionConfig.slug) || collectionConfig?.admin?.livePreview);
30
+ }
31
+ if (globalConfig) {
32
+ return Boolean(config?.admin?.livePreview?.globals?.includes(globalConfig.slug) || globalConfig?.admin?.livePreview);
33
+ }
34
+ return false;
16
35
  },
17
- viewPath: '/'
18
- }, {
19
- tab: {
20
- condition: ({
21
- collectionConfig,
22
- config,
23
- globalConfig
24
- }) => {
25
- if (collectionConfig) {
26
- return Boolean(config?.admin?.livePreview?.collections?.includes(collectionConfig.slug) || collectionConfig?.admin?.livePreview);
27
- }
28
- if (globalConfig) {
29
- return Boolean(config?.admin?.livePreview?.globals?.includes(globalConfig.slug) || globalConfig?.admin?.livePreview);
30
- }
31
- return false;
32
- },
33
- href: '/preview',
34
- label: ({
35
- t
36
- }) => t('general:livePreview'),
37
- order: 200,
38
- ...(customViews?.['livePreview']?.tab || {})
39
- },
40
- viewPath: '/preview'
41
- }, {
42
- tab: {
43
- condition: ({
44
- collectionConfig,
45
- globalConfig,
46
- permissions
47
- }) => Boolean(collectionConfig?.versions && permissions?.collections?.[collectionConfig?.slug]?.readVersions || globalConfig?.versions && permissions?.globals?.[globalConfig?.slug]?.readVersions),
48
- href: '/versions',
49
- label: ({
50
- t
51
- }) => t('version:versions'),
52
- order: 300,
53
- Pill_Component: VersionsPill,
54
- ...(customViews?.['versions']?.tab || {})
55
- },
56
- viewPath: '/versions'
57
- }, {
58
- tab: {
59
- condition: ({
60
- collectionConfig,
61
- globalConfig
62
- }) => collectionConfig && !collectionConfig?.admin?.hideAPIURL || globalConfig && !globalConfig?.admin?.hideAPIURL,
63
- href: '/api',
64
- label: 'API',
65
- order: 400,
66
- ...(customViews?.['api']?.tab || {})
67
- },
68
- viewPath: '/api'
69
- }].concat(Object.entries(customViews).reduce((acc, [key, value]) => {
70
- if (documentViewKeys.includes(key)) {
71
- return acc;
72
- }
73
- if (value?.tab) {
74
- acc.push({
75
- tab: value.tab,
76
- viewPath: 'path' in value ? value.path : ''
77
- });
78
- }
79
- return acc;
80
- }, []))?.sort(({
81
- tab: a
82
- }, {
83
- tab: b
84
- }) => {
85
- if (a.order === undefined && b.order === undefined) {
86
- return 0;
87
- } else if (a.order === undefined) {
88
- return 1;
89
- } else if (b.order === undefined) {
90
- return -1;
91
- }
92
- return a.order - b.order;
93
- });
36
+ href: '/preview',
37
+ label: ({
38
+ t
39
+ }) => t('general:livePreview'),
40
+ order: 100
41
+ },
42
+ references: {
43
+ condition: () => false
44
+ },
45
+ relationships: {
46
+ condition: () => false
47
+ },
48
+ version: {
49
+ condition: () => false
50
+ },
51
+ versions: {
52
+ condition: ({
53
+ collectionConfig,
54
+ globalConfig,
55
+ permissions
56
+ }) => Boolean(collectionConfig?.versions && permissions?.collections?.[collectionConfig?.slug]?.readVersions || globalConfig?.versions && permissions?.globals?.[globalConfig?.slug]?.readVersions),
57
+ href: '/versions',
58
+ label: ({
59
+ t
60
+ }) => t('version:versions'),
61
+ order: 200,
62
+ Pill_Component: VersionsPill
63
+ }
94
64
  };
95
65
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["VersionsPill","documentViewKeys","getTabs","collectionConfig","globalConfig","customViews","admin","components","views","edit","tab","href","label","t","order","viewPath","condition","config","Boolean","livePreview","collections","includes","slug","globals","permissions","versions","readVersions","Pill_Component","hideAPIURL","concat","Object","entries","reduce","acc","key","value","push","path","sort","a","b","undefined"],"sources":["../../../../../src/elements/DocumentHeader/Tabs/tabs/index.tsx"],"sourcesContent":["import type { DocumentTabConfig, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { VersionsPill } from './VersionsPill/index.js'\n\nexport const documentViewKeys = ['api', 'default', 'livePreview', 'versions']\n\nexport type DocumentViewKey = (typeof documentViewKeys)[number]\n\nexport const getTabs = ({\n collectionConfig,\n globalConfig,\n}: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n}): { tab: DocumentTabConfig; viewPath: string }[] => {\n const customViews =\n collectionConfig?.admin?.components?.views?.edit ||\n globalConfig?.admin?.components?.views?.edit ||\n {}\n\n return [\n {\n tab: {\n href: '',\n label: ({ t }) => t('general:edit'),\n order: 100,\n ...(customViews?.['default']?.tab || {}),\n },\n viewPath: '/',\n },\n {\n tab: {\n condition: ({ collectionConfig, config, globalConfig }) => {\n if (collectionConfig) {\n return Boolean(\n config?.admin?.livePreview?.collections?.includes(collectionConfig.slug) ||\n collectionConfig?.admin?.livePreview,\n )\n }\n\n if (globalConfig) {\n return Boolean(\n config?.admin?.livePreview?.globals?.includes(globalConfig.slug) ||\n globalConfig?.admin?.livePreview,\n )\n }\n\n return false\n },\n href: '/preview',\n label: ({ t }) => t('general:livePreview'),\n order: 200,\n ...(customViews?.['livePreview']?.tab || {}),\n },\n viewPath: '/preview',\n },\n {\n tab: {\n condition: ({ collectionConfig, globalConfig, permissions }) =>\n Boolean(\n (collectionConfig?.versions &&\n permissions?.collections?.[collectionConfig?.slug]?.readVersions) ||\n (globalConfig?.versions && permissions?.globals?.[globalConfig?.slug]?.readVersions),\n ),\n href: '/versions',\n label: ({ t }) => t('version:versions'),\n order: 300,\n Pill_Component: VersionsPill,\n ...(customViews?.['versions']?.tab || {}),\n },\n viewPath: '/versions',\n },\n {\n tab: {\n condition: ({ collectionConfig, globalConfig }) =>\n (collectionConfig && !collectionConfig?.admin?.hideAPIURL) ||\n (globalConfig && !globalConfig?.admin?.hideAPIURL),\n href: '/api',\n label: 'API',\n order: 400,\n ...(customViews?.['api']?.tab || {}),\n },\n viewPath: '/api',\n },\n ]\n .concat(\n Object.entries(customViews).reduce((acc, [key, value]) => {\n if (documentViewKeys.includes(key)) {\n return acc\n }\n\n if (value?.tab) {\n acc.push({\n tab: value.tab,\n viewPath: 'path' in value ? value.path : '',\n })\n }\n\n return acc\n }, []),\n )\n ?.sort(({ tab: a }, { tab: b }) => {\n if (a.order === undefined && b.order === undefined) {\n return 0\n } else if (a.order === undefined) {\n return 1\n } else if (b.order === undefined) {\n return -1\n }\n\n return a.order - b.order\n })\n}\n"],"mappings":"AAEA,SAASA,YAAY,QAAQ;AAE7B,OAAO,MAAMC,gBAAA,GAAmB,CAAC,OAAO,WAAW,eAAe,WAAW;AAI7E,OAAO,MAAMC,OAAA,GAAUA,CAAC;EACtBC,gBAAgB;EAChBC;AAAY,CAIb;EACC,MAAMC,WAAA,GACJF,gBAAA,EAAkBG,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,IAC5CL,YAAA,EAAcE,KAAA,EAAOC,UAAA,EAAYC,KAAA,EAAOC,IAAA,IACxC,CAAC;EAEH,OAAO,CACL;IACEC,GAAA,EAAK;MACHC,IAAA,EAAM;MACNC,KAAA,EAAOA,CAAC;QAAEC;MAAC,CAAE,KAAKA,CAAA,CAAE;MACpBC,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C,OAAO,CAAC;IACV;IAEA,OAAOF,CAAA,CAAEzB,KAAK,GAAG0B,CAAA,CAAE1B,KAAK;EAC1B;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["VersionsPill","documentViewKeys","tabs","api","condition","collectionConfig","globalConfig","admin","hideAPIURL","href","label","order","default","t","livePreview","config","Boolean","collections","includes","slug","globals","references","relationships","version","versions","permissions","readVersions","Pill_Component"],"sources":["../../../../../src/elements/DocumentHeader/Tabs/tabs/index.tsx"],"sourcesContent":["import type { DocumentTabConfig } from 'payload'\nimport type React from 'react'\n\nimport { VersionsPill } from './VersionsPill/index.js'\n\nexport const documentViewKeys = [\n 'api',\n 'default',\n 'livePreview',\n 'references',\n 'relationships',\n 'version',\n 'versions',\n]\n\nexport type DocumentViewKey = (typeof documentViewKeys)[number]\n\nexport const tabs: Record<\n DocumentViewKey,\n {\n order?: number // TODO: expose this to the globalConfig config\n Pill_Component?: React.FC\n } & DocumentTabConfig\n> = {\n api: {\n condition: ({ collectionConfig, globalConfig }) =>\n (collectionConfig && !collectionConfig?.admin?.hideAPIURL) ||\n (globalConfig && !globalConfig?.admin?.hideAPIURL),\n href: '/api',\n label: 'API',\n order: 1000,\n },\n default: {\n href: '',\n // isActive: ({ href, location }) =>\n // location.pathname === href || location.pathname === `${href}/create`,\n label: ({ t }) => t('general:edit'),\n order: 0,\n },\n livePreview: {\n condition: ({ collectionConfig, config, globalConfig }) => {\n if (collectionConfig) {\n return Boolean(\n config?.admin?.livePreview?.collections?.includes(collectionConfig.slug) ||\n collectionConfig?.admin?.livePreview,\n )\n }\n\n if (globalConfig) {\n return Boolean(\n config?.admin?.livePreview?.globals?.includes(globalConfig.slug) ||\n globalConfig?.admin?.livePreview,\n )\n }\n\n return false\n },\n href: '/preview',\n label: ({ t }) => t('general:livePreview'),\n order: 100,\n },\n references: {\n condition: () => false,\n },\n relationships: {\n condition: () => false,\n },\n version: {\n condition: () => false,\n },\n versions: {\n condition: ({ collectionConfig, globalConfig, permissions }) =>\n Boolean(\n (collectionConfig?.versions &&\n permissions?.collections?.[collectionConfig?.slug]?.readVersions) ||\n (globalConfig?.versions && permissions?.globals?.[globalConfig?.slug]?.readVersions),\n ),\n href: '/versions',\n label: ({ t }) => t('version:versions'),\n order: 200,\n Pill_Component: VersionsPill,\n },\n}\n"],"mappings":"AAGA,SAASA,YAAY,QAAQ;AAE7B,OAAO,MAAMC,gBAAA,GAAmB,CAC9B,OACA,WACA,eACA,cACA,iBACA,WACA,WACD;AAID,OAAO,MAAMC,IAAA,GAMT;EACFC,GAAA,EAAK;IACHC,SAAA,EAAWA,CAAC;MAAEC,gBAAgB;MAAEC;IAAY,CAAE,KAC5CD,gBAAC,IAAoB,CAACA,gBAAA,EAAkBE,KAAA,EAAOC,UAAA,IAC9CF,YAAA,IAAgB,CAACA,YAAA,EAAcC,KAAA,EAAOC,UAAA;IACzCC,IAAA,EAAM;IACNC,KAAA,EAAO;IACPC,KAAA,EAAO;EACT;EACAC,OAAA,EAAS;IACPH,IAAA,EAAM;IACN;IACA;IACAC,KAAA,EAAOA,CAAC;MAAEG;IAAC,CAAE,KAAKA,CAAA,CAAE;IACpBF,KAAA,EAAO;EACT;EACAG,WAAA,EAAa;IACXV,SAAA,EAAWA,CAAC;MAAEC,gBAAgB;MAAEU,MAAM;MAAET;IAAY,CAAE;MACpD,IAAID,gBAAA,EAAkB;QACpB,OAAOW,OAAA,CACLD,MAAA,EAAQR,KAAA,EAAOO,WAAA,EAAaG,WAAA,EAAaC,QAAA,CAASb,gBAAA,CAAiBc,IAAI,KACrEd,gBAAA,EAAkBE,KAAA,EAAOO,WAAA;MAE/B;MAEA,IAAIR,YAAA,EAAc;QAChB,OAAOU,OAAA,CACLD,MAAA,EAAQR,KAAA,EAAOO,WAAA,EAAaM,OAAA,EAASF,QAAA,CAASZ,YAAA,CAAaa,IAAI,KAC7Db,YAAA,EAAcC,KAAA,EAAOO,WAAA;MAE3B;MAEA,OAAO;IACT;IACAL,IAAA,EAAM;IACNC,KAAA,EAAOA,CAAC;MAAEG;IAAC,CAAE,KAAKA,CAAA,CAAE;IACpBF,KAAA,EAAO;EACT;EACAU,UAAA,EAAY;IACVjB,SAAA,EAAWA,CAAA,KAAM;EACnB;EACAkB,aAAA,EAAe;IACblB,SAAA,EAAWA,CAAA,KAAM;EACnB;EACAmB,OAAA,EAAS;IACPnB,SAAA,EAAWA,CAAA,KAAM;EACnB;EACAoB,QAAA,EAAU;IACRpB,SAAA,EAAWA,CAAC;MAAEC,gBAAgB;MAAEC,YAAY;MAAEmB;IAAW,CAAE,KACzDT,OAAA,CACEX,gBAAC,EAAkBmB,QAAA,IACjBC,WAAA,EAAaR,WAAA,GAAcZ,gBAAA,EAAkBc,IAAA,CAAK,EAAEO,YAAA,IACnDpB,YAAA,EAAckB,QAAA,IAAYC,WAAA,EAAaL,OAAA,GAAUd,YAAA,EAAca,IAAA,CAAK,EAAEO,YAAA;IAE7EjB,IAAA,EAAM;IACNC,KAAA,EAAOA,CAAC;MAAEG;IAAC,CAAE,KAAKA,CAAA,CAAE;IACpBF,KAAA,EAAO;IACPgB,cAAA,EAAgB3B;EAClB;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/DocumentHeader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EACV,OAAO,EACP,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IACpC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,oBAAoB,CAAA;CAClC,CAiBA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/DocumentHeader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EACV,OAAO,EACP,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAKrB,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IACpC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,oBAAoB,CAAA;CAClC,CAiBA,CAAA"}