@payloadcms/next 3.83.0-internal.ddc1147 → 3.84.0-canary.0

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.
@@ -0,0 +1,12 @@
1
+ import type { SanitizedCollectionConfig } from 'payload';
2
+ import type { ViewFromConfig } from './getRouteData.js';
3
+ export declare const getCustomCollectionViewByRoute: ({ adminRoute, baseRoute, currentRoute: currentRouteWithAdmin, views, }: {
4
+ adminRoute: string;
5
+ baseRoute: string;
6
+ currentRoute: string;
7
+ views: SanitizedCollectionConfig["admin"]["components"]["views"];
8
+ }) => {
9
+ view: ViewFromConfig;
10
+ viewKey: null | string;
11
+ };
12
+ //# sourceMappingURL=getCustomCollectionViewByRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCustomCollectionViewByRoute.d.ts","sourceRoot":"","sources":["../../../src/views/Root/getCustomCollectionViewByRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAIvD,eAAO,MAAM,8BAA8B,2EAKxC;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAA;CACjE,KAAG;IACF,IAAI,EAAE,cAAc,CAAA;IACpB,OAAO,EAAE,IAAI,GAAG,MAAM,CAAA;CA0DvB,CAAA"}
@@ -0,0 +1,48 @@
1
+ import { isPathMatchingRoute } from './isPathMatchingRoute.js';
2
+ export const getCustomCollectionViewByRoute = ({
3
+ adminRoute,
4
+ baseRoute,
5
+ currentRoute: currentRouteWithAdmin,
6
+ views
7
+ }) => {
8
+ const currentRoute = adminRoute === '/' ? currentRouteWithAdmin : currentRouteWithAdmin.startsWith(adminRoute) ? currentRouteWithAdmin.slice(adminRoute.length) : currentRouteWithAdmin;
9
+ if (views && typeof views === 'object') {
10
+ const foundEntry = Object.entries(views).find(([key, view]) => {
11
+ // Skip the known collection view types: edit and list
12
+ if (key === 'edit' || key === 'list') {
13
+ return false;
14
+ }
15
+ // Type guard: custom views should be AdminViewConfig with path and Component
16
+ const isAdminViewConfig = typeof view === 'object' && view !== null && 'path' in view && 'Component' in view && typeof view.path === 'string';
17
+ if (isAdminViewConfig) {
18
+ const adminView = view;
19
+ const viewPath = `${baseRoute}${adminView.path}`;
20
+ return isPathMatchingRoute({
21
+ currentRoute,
22
+ exact: adminView.exact,
23
+ path: viewPath,
24
+ sensitive: adminView.sensitive,
25
+ strict: adminView.strict
26
+ });
27
+ }
28
+ return false;
29
+ });
30
+ if (foundEntry) {
31
+ const [viewKey, foundViewConfig] = foundEntry;
32
+ const adminView = foundViewConfig;
33
+ return {
34
+ view: {
35
+ payloadComponent: adminView.Component
36
+ },
37
+ viewKey
38
+ };
39
+ }
40
+ }
41
+ return {
42
+ view: {
43
+ Component: null
44
+ },
45
+ viewKey: null
46
+ };
47
+ };
48
+ //# sourceMappingURL=getCustomCollectionViewByRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCustomCollectionViewByRoute.js","names":["isPathMatchingRoute","getCustomCollectionViewByRoute","adminRoute","baseRoute","currentRoute","currentRouteWithAdmin","views","startsWith","slice","length","foundEntry","Object","entries","find","key","view","isAdminViewConfig","path","adminView","viewPath","exact","sensitive","strict","viewKey","foundViewConfig","payloadComponent","Component"],"sources":["../../../src/views/Root/getCustomCollectionViewByRoute.ts"],"sourcesContent":["import type {\n AdminViewConfig,\n AdminViewServerProps,\n PayloadComponent,\n SanitizedCollectionConfig,\n} from 'payload'\n\nimport type { ViewFromConfig } from './getRouteData.js'\n\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\nexport const getCustomCollectionViewByRoute = ({\n adminRoute,\n baseRoute,\n currentRoute: currentRouteWithAdmin,\n views,\n}: {\n adminRoute: string\n baseRoute: string\n currentRoute: string\n views: SanitizedCollectionConfig['admin']['components']['views']\n}): {\n view: ViewFromConfig\n viewKey: null | string\n} => {\n const currentRoute =\n adminRoute === '/'\n ? currentRouteWithAdmin\n : currentRouteWithAdmin.startsWith(adminRoute)\n ? currentRouteWithAdmin.slice(adminRoute.length)\n : currentRouteWithAdmin\n\n if (views && typeof views === 'object') {\n const foundEntry = Object.entries(views).find(([key, view]) => {\n // Skip the known collection view types: edit and list\n if (key === 'edit' || key === 'list') {\n return false\n }\n\n // Type guard: custom views should be AdminViewConfig with path and Component\n const isAdminViewConfig =\n typeof view === 'object' &&\n view !== null &&\n 'path' in view &&\n 'Component' in view &&\n typeof view.path === 'string'\n\n if (isAdminViewConfig) {\n const adminView = view as AdminViewConfig\n const viewPath = `${baseRoute}${adminView.path}`\n\n return isPathMatchingRoute({\n currentRoute,\n exact: adminView.exact,\n path: viewPath,\n sensitive: adminView.sensitive,\n strict: adminView.strict,\n })\n }\n\n return false\n })\n\n if (foundEntry) {\n const [viewKey, foundViewConfig] = foundEntry\n const adminView = foundViewConfig as AdminViewConfig\n return {\n view: {\n payloadComponent: adminView.Component as PayloadComponent<AdminViewServerProps>,\n },\n viewKey,\n }\n }\n }\n\n return {\n view: {\n Component: null,\n },\n viewKey: null,\n }\n}\n"],"mappings":"AASA,SAASA,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,8BAAA,GAAiCA,CAAC;EAC7CC,UAAU;EACVC,SAAS;EACTC,YAAA,EAAcC,qBAAqB;EACnCC;AAAK,CAMN;EAIC,MAAMF,YAAA,GACJF,UAAA,KAAe,MACXG,qBAAA,GACAA,qBAAA,CAAsBE,UAAU,CAACL,UAAA,IAC/BG,qBAAA,CAAsBG,KAAK,CAACN,UAAA,CAAWO,MAAM,IAC7CJ,qBAAA;EAER,IAAIC,KAAA,IAAS,OAAOA,KAAA,KAAU,UAAU;IACtC,MAAMI,UAAA,GAAaC,MAAA,CAAOC,OAAO,CAACN,KAAA,EAAOO,IAAI,CAAC,CAAC,CAACC,GAAA,EAAKC,IAAA,CAAK;MACxD;MACA,IAAID,GAAA,KAAQ,UAAUA,GAAA,KAAQ,QAAQ;QACpC,OAAO;MACT;MAEA;MACA,MAAME,iBAAA,GACJ,OAAOD,IAAA,KAAS,YAChBA,IAAA,KAAS,QACT,UAAUA,IAAA,IACV,eAAeA,IAAA,IACf,OAAOA,IAAA,CAAKE,IAAI,KAAK;MAEvB,IAAID,iBAAA,EAAmB;QACrB,MAAME,SAAA,GAAYH,IAAA;QAClB,MAAMI,QAAA,GAAW,GAAGhB,SAAA,GAAYe,SAAA,CAAUD,IAAI,EAAE;QAEhD,OAAOjB,mBAAA,CAAoB;UACzBI,YAAA;UACAgB,KAAA,EAAOF,SAAA,CAAUE,KAAK;UACtBH,IAAA,EAAME,QAAA;UACNE,SAAA,EAAWH,SAAA,CAAUG,SAAS;UAC9BC,MAAA,EAAQJ,SAAA,CAAUI;QACpB;MACF;MAEA,OAAO;IACT;IAEA,IAAIZ,UAAA,EAAY;MACd,MAAM,CAACa,OAAA,EAASC,eAAA,CAAgB,GAAGd,UAAA;MACnC,MAAMQ,SAAA,GAAYM,eAAA;MAClB,OAAO;QACLT,IAAA,EAAM;UACJU,gBAAA,EAAkBP,SAAA,CAAUQ;QAC9B;QACAH;MACF;IACF;EACF;EAEA,OAAO;IACLR,IAAA,EAAM;MACJW,SAAA,EAAW;IACb;IACAH,OAAA,EAAS;EACX;AACF","ignoreList":[]}
@@ -0,0 +1,168 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { getCustomCollectionViewByRoute } from './getCustomCollectionViewByRoute.js';
3
+ const gridView = {
4
+ grid: {
5
+ Component: '/components/views/GridView/index.js#GridView',
6
+ exact: true,
7
+ path: '/grid'
8
+ }
9
+ };
10
+ const gridViewPrefixMatch = {
11
+ grid: {
12
+ Component: '/components/views/GridView/index.js#GridView',
13
+ exact: false,
14
+ path: '/grid'
15
+ }
16
+ };
17
+ describe('getCustomCollectionViewByRoute', () => {
18
+ describe('route matching with default /admin prefix', () => {
19
+ it('should match a custom view at the correct path', () => {
20
+ const result = getCustomCollectionViewByRoute({
21
+ adminRoute: '/admin',
22
+ baseRoute: '/collections/my-collection',
23
+ currentRoute: '/admin/collections/my-collection/grid',
24
+ views: gridView
25
+ });
26
+ expect(result.viewKey).toBe('grid');
27
+ expect(result.view.payloadComponent).toBeDefined();
28
+ });
29
+ it('should not match when the path segment does not correspond to any custom view', () => {
30
+ const result = getCustomCollectionViewByRoute({
31
+ adminRoute: '/admin',
32
+ baseRoute: '/collections/my-collection',
33
+ currentRoute: '/admin/collections/my-collection/abc123',
34
+ views: gridView
35
+ });
36
+ expect(result.viewKey).toBeNull();
37
+ expect(result.view.payloadComponent).toBeUndefined();
38
+ });
39
+ });
40
+ describe('route matching with custom adminRoute prefix', () => {
41
+ it('should match when adminRoute is a non-default prefix', () => {
42
+ const result = getCustomCollectionViewByRoute({
43
+ adminRoute: '/cms',
44
+ baseRoute: '/collections/my-collection',
45
+ currentRoute: '/cms/collections/my-collection/grid',
46
+ views: gridView
47
+ });
48
+ expect(result.viewKey).toBe('grid');
49
+ expect(result.view.payloadComponent).toBeDefined();
50
+ });
51
+ it('should match when adminRoute is /', () => {
52
+ const result = getCustomCollectionViewByRoute({
53
+ adminRoute: '/',
54
+ baseRoute: '/collections/my-collection',
55
+ currentRoute: '/collections/my-collection/grid',
56
+ views: gridView
57
+ });
58
+ expect(result.viewKey).toBe('grid');
59
+ expect(result.view.payloadComponent).toBeDefined();
60
+ });
61
+ });
62
+ describe('route matching with exact: false (prefix matching)', () => {
63
+ it('should match a sub-path when exact is false', () => {
64
+ const result = getCustomCollectionViewByRoute({
65
+ adminRoute: '/admin',
66
+ baseRoute: '/collections/my-collection',
67
+ currentRoute: '/admin/collections/my-collection/grid/detail',
68
+ views: gridViewPrefixMatch
69
+ });
70
+ expect(result.viewKey).toBe('grid');
71
+ expect(result.view.payloadComponent).toBeDefined();
72
+ });
73
+ it('should match the exact path when exact is false', () => {
74
+ const result = getCustomCollectionViewByRoute({
75
+ adminRoute: '/admin',
76
+ baseRoute: '/collections/my-collection',
77
+ currentRoute: '/admin/collections/my-collection/grid',
78
+ views: gridViewPrefixMatch
79
+ });
80
+ expect(result.viewKey).toBe('grid');
81
+ expect(result.view.payloadComponent).toBeDefined();
82
+ });
83
+ it('should not match an unrelated path when exact is false', () => {
84
+ const result = getCustomCollectionViewByRoute({
85
+ adminRoute: '/admin',
86
+ baseRoute: '/collections/my-collection',
87
+ currentRoute: '/admin/collections/my-collection/map',
88
+ views: gridViewPrefixMatch
89
+ });
90
+ expect(result.viewKey).toBeNull();
91
+ expect(result.view.payloadComponent).toBeUndefined();
92
+ });
93
+ });
94
+ describe('edge cases', () => {
95
+ it('should return no match when views is undefined', () => {
96
+ const result = getCustomCollectionViewByRoute({
97
+ adminRoute: '/admin',
98
+ baseRoute: '/collections/my-collection',
99
+ currentRoute: '/admin/collections/my-collection/grid',
100
+ views: undefined
101
+ });
102
+ expect(result.viewKey).toBeNull();
103
+ expect(result.view.payloadComponent).toBeUndefined();
104
+ });
105
+ it('should not match built-in "edit" or "list" keys', () => {
106
+ const viewsWithBuiltins = {
107
+ edit: {
108
+ default: {
109
+ Component: '/components/views/Edit/index.js#EditView'
110
+ }
111
+ },
112
+ list: {
113
+ Component: '/components/views/List/index.js#ListView'
114
+ }
115
+ };
116
+ const result = getCustomCollectionViewByRoute({
117
+ adminRoute: '/admin',
118
+ baseRoute: '/collections/my-collection',
119
+ currentRoute: '/admin/collections/my-collection/edit',
120
+ views: viewsWithBuiltins
121
+ });
122
+ expect(result.viewKey).toBeNull();
123
+ });
124
+ it('should not match a custom view that has no path defined', () => {
125
+ const viewsWithNoPath = {
126
+ grid: {
127
+ Component: '/components/views/GridView/index.js#GridView'
128
+ }
129
+ };
130
+ const result = getCustomCollectionViewByRoute({
131
+ adminRoute: '/admin',
132
+ baseRoute: '/collections/my-collection',
133
+ currentRoute: '/admin/collections/my-collection/grid',
134
+ views: viewsWithNoPath
135
+ });
136
+ expect(result.viewKey).toBeNull();
137
+ });
138
+ it('should match the correct view when multiple custom views are defined', () => {
139
+ const multipleViews = {
140
+ grid: {
141
+ Component: '/components/views/GridView/index.js#GridView',
142
+ exact: true,
143
+ path: '/grid'
144
+ },
145
+ map: {
146
+ Component: '/components/views/MapView/index.js#MapView',
147
+ exact: true,
148
+ path: '/map'
149
+ }
150
+ };
151
+ const gridResult = getCustomCollectionViewByRoute({
152
+ adminRoute: '/admin',
153
+ baseRoute: '/collections/my-collection',
154
+ currentRoute: '/admin/collections/my-collection/grid',
155
+ views: multipleViews
156
+ });
157
+ expect(gridResult.viewKey).toBe('grid');
158
+ const mapResult = getCustomCollectionViewByRoute({
159
+ adminRoute: '/admin',
160
+ baseRoute: '/collections/my-collection',
161
+ currentRoute: '/admin/collections/my-collection/map',
162
+ views: multipleViews
163
+ });
164
+ expect(mapResult.viewKey).toBe('map');
165
+ });
166
+ });
167
+ });
168
+ //# sourceMappingURL=getCustomCollectionViewByRoute.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCustomCollectionViewByRoute.spec.js","names":["describe","expect","it","getCustomCollectionViewByRoute","gridView","grid","Component","exact","path","gridViewPrefixMatch","result","adminRoute","baseRoute","currentRoute","views","viewKey","toBe","view","payloadComponent","toBeDefined","toBeNull","toBeUndefined","undefined","viewsWithBuiltins","edit","default","list","viewsWithNoPath","multipleViews","map","gridResult","mapResult"],"sources":["../../../src/views/Root/getCustomCollectionViewByRoute.spec.ts"],"sourcesContent":["import type { AdminViewConfig, SanitizedCollectionConfig } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { getCustomCollectionViewByRoute } from './getCustomCollectionViewByRoute.js'\n\ntype Views = SanitizedCollectionConfig['admin']['components']['views']\n\nconst gridView: Views = {\n grid: {\n Component: '/components/views/GridView/index.js#GridView',\n exact: true,\n path: '/grid',\n },\n}\n\nconst gridViewPrefixMatch: Views = {\n grid: {\n Component: '/components/views/GridView/index.js#GridView',\n exact: false,\n path: '/grid',\n },\n}\n\ndescribe('getCustomCollectionViewByRoute', () => {\n describe('route matching with default /admin prefix', () => {\n it('should match a custom view at the correct path', () => {\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/grid',\n views: gridView,\n })\n\n expect(result.viewKey).toBe('grid')\n expect(result.view.payloadComponent).toBeDefined()\n })\n\n it('should not match when the path segment does not correspond to any custom view', () => {\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/abc123',\n views: gridView,\n })\n\n expect(result.viewKey).toBeNull()\n expect(result.view.payloadComponent).toBeUndefined()\n })\n })\n\n describe('route matching with custom adminRoute prefix', () => {\n it('should match when adminRoute is a non-default prefix', () => {\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/cms',\n baseRoute: '/collections/my-collection',\n currentRoute: '/cms/collections/my-collection/grid',\n views: gridView,\n })\n\n expect(result.viewKey).toBe('grid')\n expect(result.view.payloadComponent).toBeDefined()\n })\n\n it('should match when adminRoute is /', () => {\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/',\n baseRoute: '/collections/my-collection',\n currentRoute: '/collections/my-collection/grid',\n views: gridView,\n })\n\n expect(result.viewKey).toBe('grid')\n expect(result.view.payloadComponent).toBeDefined()\n })\n })\n\n describe('route matching with exact: false (prefix matching)', () => {\n it('should match a sub-path when exact is false', () => {\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/grid/detail',\n views: gridViewPrefixMatch,\n })\n\n expect(result.viewKey).toBe('grid')\n expect(result.view.payloadComponent).toBeDefined()\n })\n\n it('should match the exact path when exact is false', () => {\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/grid',\n views: gridViewPrefixMatch,\n })\n\n expect(result.viewKey).toBe('grid')\n expect(result.view.payloadComponent).toBeDefined()\n })\n\n it('should not match an unrelated path when exact is false', () => {\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/map',\n views: gridViewPrefixMatch,\n })\n\n expect(result.viewKey).toBeNull()\n expect(result.view.payloadComponent).toBeUndefined()\n })\n })\n\n describe('edge cases', () => {\n it('should return no match when views is undefined', () => {\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/grid',\n views: undefined,\n })\n\n expect(result.viewKey).toBeNull()\n expect(result.view.payloadComponent).toBeUndefined()\n })\n\n it('should not match built-in \"edit\" or \"list\" keys', () => {\n const viewsWithBuiltins: Views = {\n edit: {\n default: { Component: '/components/views/Edit/index.js#EditView' },\n },\n list: {\n Component: '/components/views/List/index.js#ListView',\n },\n }\n\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/edit',\n views: viewsWithBuiltins,\n })\n\n expect(result.viewKey).toBeNull()\n })\n\n it('should not match a custom view that has no path defined', () => {\n const viewsWithNoPath: Views = {\n grid: {\n Component: '/components/views/GridView/index.js#GridView',\n } as unknown as AdminViewConfig,\n }\n\n const result = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/grid',\n views: viewsWithNoPath,\n })\n\n expect(result.viewKey).toBeNull()\n })\n\n it('should match the correct view when multiple custom views are defined', () => {\n const multipleViews: Views = {\n grid: {\n Component: '/components/views/GridView/index.js#GridView',\n exact: true,\n path: '/grid',\n },\n map: {\n Component: '/components/views/MapView/index.js#MapView',\n exact: true,\n path: '/map',\n },\n }\n\n const gridResult = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/grid',\n views: multipleViews,\n })\n\n expect(gridResult.viewKey).toBe('grid')\n\n const mapResult = getCustomCollectionViewByRoute({\n adminRoute: '/admin',\n baseRoute: '/collections/my-collection',\n currentRoute: '/admin/collections/my-collection/map',\n views: multipleViews,\n })\n\n expect(mapResult.viewKey).toBe('map')\n })\n })\n})\n"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,8BAA8B,QAAQ;AAI/C,MAAMC,QAAA,GAAkB;EACtBC,IAAA,EAAM;IACJC,SAAA,EAAW;IACXC,KAAA,EAAO;IACPC,IAAA,EAAM;EACR;AACF;AAEA,MAAMC,mBAAA,GAA6B;EACjCJ,IAAA,EAAM;IACJC,SAAA,EAAW;IACXC,KAAA,EAAO;IACPC,IAAA,EAAM;EACR;AACF;AAEAR,QAAA,CAAS,kCAAkC;EACzCA,QAAA,CAAS,6CAA6C;IACpDE,EAAA,CAAG,kDAAkD;MACnD,MAAMQ,MAAA,GAASP,8BAAA,CAA+B;QAC5CQ,UAAA,EAAY;QACZC,SAAA,EAAW;QACXC,YAAA,EAAc;QACdC,KAAA,EAAOV;MACT;MAEAH,MAAA,CAAOS,MAAA,CAAOK,OAAO,EAAEC,IAAI,CAAC;MAC5Bf,MAAA,CAAOS,MAAA,CAAOO,IAAI,CAACC,gBAAgB,EAAEC,WAAW;IAClD;IAEAjB,EAAA,CAAG,iFAAiF;MAClF,MAAMQ,MAAA,GAASP,8BAAA,CAA+B;QAC5CQ,UAAA,EAAY;QACZC,SAAA,EAAW;QACXC,YAAA,EAAc;QACdC,KAAA,EAAOV;MACT;MAEAH,MAAA,CAAOS,MAAA,CAAOK,OAAO,EAAEK,QAAQ;MAC/BnB,MAAA,CAAOS,MAAA,CAAOO,IAAI,CAACC,gBAAgB,EAAEG,aAAa;IACpD;EACF;EAEArB,QAAA,CAAS,gDAAgD;IACvDE,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,GAAuB;QAC3BvB,IAAA,EAAM;UACJC,SAAA,EAAW;UACXC,KAAA,EAAO;UACPC,IAAA,EAAM;QACR;QACAqB,GAAA,EAAK;UACHvB,SAAA,EAAW;UACXC,KAAA,EAAO;UACPC,IAAA,EAAM;QACR;MACF;MAEA,MAAMsB,UAAA,GAAa3B,8BAAA,CAA+B;QAChDQ,UAAA,EAAY;QACZC,SAAA,EAAW;QACXC,YAAA,EAAc;QACdC,KAAA,EAAOc;MACT;MAEA3B,MAAA,CAAO6B,UAAA,CAAWf,OAAO,EAAEC,IAAI,CAAC;MAEhC,MAAMe,SAAA,GAAY5B,8BAAA,CAA+B;QAC/CQ,UAAA,EAAY;QACZC,SAAA,EAAW;QACXC,YAAA,EAAc;QACdC,KAAA,EAAOc;MACT;MAEA3B,MAAA,CAAO8B,SAAA,CAAUhB,OAAO,EAAEC,IAAI,CAAC;IACjC;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"getRouteData.d.ts","sourceRoot":"","sources":["../../../src/views/Root/getRouteData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,OAAO,EACP,gBAAgB,EAChB,yBAAyB,EAEzB,qBAAqB,EACrB,SAAS,EACV,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAsC9B,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAA;IAC1C,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAA;CAC1D,CAAA;AAaD,KAAK,kBAAkB,GAAG;IACxB,mBAAmB,EAAE,cAAc,EAAE,CAAA;IACrC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,WAAW,EAAE,cAAc,CAAA;IAC3B,mBAAmB,CAAC,EAAE,oBAA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C,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAA;IACD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,YAAY,4GAQtB,gBAAgB,KAAG,kBAgYrB,CAAA"}
@@ -15,6 +15,7 @@ import { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js
15
15
  import { UnauthorizedView } from '../Unauthorized/index.js';
16
16
  import { Verify, verifyBaseClass } from '../Verify/index.js';
17
17
  import { getSubViewActions, getViewActions } from './attachViewActions.js';
18
+ import { getCustomCollectionViewByRoute } from './getCustomCollectionViewByRoute.js';
18
19
  import { getCustomViewByKey } from './getCustomViewByKey.js';
19
20
  import { getCustomViewByRoute } from './getCustomViewByRoute.js';
20
21
  import { getDocumentViewInfo } from './getDocumentViewInfo.js';
@@ -264,26 +265,42 @@ export const getRouteData = ({
264
265
  viewType = 'collection-folders';
265
266
  viewActions.push(...(collectionConfig.admin.components?.views?.list?.actions || []));
266
267
  } else {
267
- // Collection Edit Views
268
- // --> /collections/:collectionSlug/create
269
- // --> /collections/:collectionSlug/:id
270
- // --> /collections/:collectionSlug/:id/api
271
- // --> /collections/:collectionSlug/:id/versions
272
- // --> /collections/:collectionSlug/:id/versions/:versionID
273
- routeParams.id = segmentThree === 'create' ? undefined : segmentThree;
274
- routeParams.versionID = segmentFive;
275
- ViewToRender = {
276
- Component: DocumentView
277
- };
278
- templateClassName = `collection-default-edit`;
279
- templateType = 'default';
280
- const viewInfo = getDocumentViewInfo([segmentFour, segmentFive]);
281
- viewType = viewInfo.viewType;
282
- documentSubViewType = viewInfo.documentSubViewType;
283
- viewActions.push(...getSubViewActions({
284
- collectionOrGlobal: collectionConfig,
285
- viewKeyArg: documentSubViewType
286
- }));
268
+ // Check for custom collection views before assuming it's an edit view
269
+ const baseRoute = `/${segmentOne}/${segmentTwo}`;
270
+ const customCollectionView = getCustomCollectionViewByRoute({
271
+ adminRoute,
272
+ baseRoute,
273
+ currentRoute,
274
+ views: collectionConfig.admin.components?.views
275
+ });
276
+ if (customCollectionView.viewKey && customCollectionView.view.payloadComponent) {
277
+ // --> /collections/:collectionSlug/:customViewPath
278
+ ViewToRender = customCollectionView.view;
279
+ templateClassName = `collection-${customCollectionView.viewKey}`;
280
+ templateType = 'default';
281
+ viewType = customCollectionView.viewKey;
282
+ } else {
283
+ // Collection Edit Views
284
+ // --> /collections/:collectionSlug/create
285
+ // --> /collections/:collectionSlug/:id
286
+ // --> /collections/:collectionSlug/:id/api
287
+ // --> /collections/:collectionSlug/:id/versions
288
+ // --> /collections/:collectionSlug/:id/versions/:versionID
289
+ routeParams.id = segmentThree === 'create' ? undefined : segmentThree;
290
+ routeParams.versionID = segmentFive;
291
+ ViewToRender = {
292
+ Component: DocumentView
293
+ };
294
+ templateClassName = `collection-default-edit`;
295
+ templateType = 'default';
296
+ const viewInfo = getDocumentViewInfo([segmentFour, segmentFive]);
297
+ viewType = viewInfo.viewType;
298
+ documentSubViewType = viewInfo.documentSubViewType;
299
+ viewActions.push(...getSubViewActions({
300
+ collectionOrGlobal: collectionConfig,
301
+ viewKeyArg: documentSubViewType
302
+ }));
303
+ }
287
304
  }
288
305
  }
289
306
  } else if (globalConfig) {
@@ -1 +1 @@
1
- {"version":3,"file":"getRouteData.js","names":["parseDocumentID","formatAdminURL","isNumber","AccountView","BrowseByFolder","CollectionFolderView","TrashView","CreateFirstUserView","DashboardView","DocumentView","forgotPasswordBaseClass","ForgotPasswordView","ListView","loginBaseClass","LoginView","LogoutInactivity","LogoutView","ResetPassword","resetPasswordBaseClass","UnauthorizedView","Verify","verifyBaseClass","getSubViewActions","getViewActions","getCustomViewByKey","getCustomViewByRoute","getDocumentViewInfo","isPathMatchingRoute","baseClasses","account","folders","forgot","login","reset","verify","oneSegmentViews","browseByFolder","createFirstUser","inactivity","logout","unauthorized","getRouteData","adminRoute","collectionConfig","collectionPreferences","undefined","currentRoute","globalConfig","payload","segments","config","ViewToRender","templateClassName","templateType","documentSubViewType","viewType","routeParams","segmentOne","segmentTwo","segmentThree","segmentFour","segmentFive","segmentSix","isBrowseByFolderEnabled","browseByFolderSlugs","collections","reduce","acc","slug","viewActions","admin","components","actions","length","Component","viewKey","routes","matchedRoute","Object","entries","find","route","exact","path","customView","view","payloadComponent","folderID","collection","listViewType","push","views","list","global","editConfig","edit","token","id","versionID","viewInfo","collectionOrGlobal","viewKeyArg","folderCollection","collectionSlug","db","defaultIDType","Number","reverse","DefaultView"],"sources":["../../../src/views/Root/getRouteData.ts"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n CollectionSlug,\n CustomComponent,\n DocumentSubViewTypes,\n Payload,\n PayloadComponent,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n ViewTypes,\n} from 'payload'\nimport type React from 'react'\n\nimport { parseDocumentID } from 'payload'\nimport { formatAdminURL, isNumber } from 'payload/shared'\n\nimport { AccountView } from '../Account/index.js'\nimport { BrowseByFolder } from '../BrowseByFolder/index.js'\nimport { CollectionFolderView } from '../CollectionFolders/index.js'\nimport { TrashView } from '../CollectionTrash/index.js'\nimport { CreateFirstUserView } from '../CreateFirstUser/index.js'\nimport { DashboardView } from '../Dashboard/index.js'\nimport { DocumentView } from '../Document/index.js'\nimport { forgotPasswordBaseClass, ForgotPasswordView } from '../ForgotPassword/index.js'\nimport { ListView } from '../List/index.js'\nimport { loginBaseClass, LoginView } from '../Login/index.js'\nimport { LogoutInactivity, LogoutView } from '../Logout/index.js'\nimport { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { Verify, verifyBaseClass } from '../Verify/index.js'\nimport { getSubViewActions, getViewActions } from './attachViewActions.js'\nimport { getCustomViewByKey } from './getCustomViewByKey.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { getDocumentViewInfo } from './getDocumentViewInfo.js'\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\nconst baseClasses = {\n account: 'account',\n folders: 'folders',\n forgot: forgotPasswordBaseClass,\n login: loginBaseClass,\n reset: resetPasswordBaseClass,\n verify: verifyBaseClass,\n}\n\ntype OneSegmentViews = {\n [K in Exclude<keyof SanitizedConfig['admin']['routes'], 'reset'>]: React.FC<AdminViewServerProps>\n}\n\nexport type ViewFromConfig = {\n Component?: React.FC<AdminViewServerProps>\n payloadComponent?: PayloadComponent<AdminViewServerProps>\n}\n\nconst oneSegmentViews: OneSegmentViews = {\n account: AccountView,\n browseByFolder: BrowseByFolder,\n createFirstUser: CreateFirstUserView,\n forgot: ForgotPasswordView,\n inactivity: LogoutInactivity,\n login: LoginView,\n logout: LogoutView,\n unauthorized: UnauthorizedView,\n}\n\ntype GetRouteDataResult = {\n browseByFolderSlugs: CollectionSlug[]\n collectionConfig?: SanitizedCollectionConfig\n DefaultView: ViewFromConfig\n documentSubViewType?: DocumentSubViewTypes\n globalConfig?: SanitizedGlobalConfig\n routeParams: {\n collection?: string\n folderCollection?: string\n folderID?: number | string\n global?: string\n id?: number | string\n token?: string\n versionID?: number | string\n }\n templateClassName: string\n templateType: 'default' | 'minimal'\n viewActions?: CustomComponent[]\n viewType?: ViewTypes\n}\n\ntype GetRouteDataArgs = {\n adminRoute: string\n collectionConfig?: SanitizedCollectionConfig\n /**\n * User preferences for a collection.\n *\n * These preferences are normally undefined\n * unless the user is on the list view and the\n * collection is folder enabled.\n */\n collectionPreferences?: CollectionPreferences\n currentRoute: string\n globalConfig?: SanitizedGlobalConfig\n payload: Payload\n searchParams: {\n [key: string]: string | string[]\n }\n segments: string[]\n}\n\nexport const getRouteData = ({\n adminRoute,\n collectionConfig,\n collectionPreferences = undefined,\n currentRoute,\n globalConfig,\n payload,\n segments,\n}: GetRouteDataArgs): GetRouteDataResult => {\n const { config } = payload\n let ViewToRender: ViewFromConfig = null\n let templateClassName: string\n let templateType: 'default' | 'minimal' | undefined\n let documentSubViewType: DocumentSubViewTypes\n let viewType: ViewTypes\n const routeParams: GetRouteDataResult['routeParams'] = {}\n\n const [segmentOne, segmentTwo, segmentThree, segmentFour, segmentFive, segmentSix] = segments\n\n const isBrowseByFolderEnabled = config.folders && config.folders.browseByFolder\n const browseByFolderSlugs =\n (isBrowseByFolderEnabled &&\n config.collections.reduce((acc, { slug, folders }) => {\n if (folders && folders.browseByFolder) {\n return [...acc, slug]\n }\n return acc\n }, [])) ||\n []\n\n const viewActions: CustomComponent[] = [...(config?.admin?.components?.actions || [])]\n\n switch (segments.length) {\n case 0: {\n if (currentRoute === adminRoute) {\n ViewToRender = {\n Component: DashboardView,\n }\n templateClassName = 'dashboard'\n templateType = 'default'\n viewType = 'dashboard'\n }\n break\n }\n case 1: {\n // users can override the default routes via `admin.routes` config\n // i.e.{ admin: { routes: { logout: '/sign-out', inactivity: '/idle' }}}\n let viewKey: keyof typeof oneSegmentViews\n\n if (config.admin.routes) {\n const matchedRoute = Object.entries(config.admin.routes).find(([, route]) => {\n return isPathMatchingRoute({\n currentRoute,\n exact: true,\n path: formatAdminURL({\n adminRoute,\n path: route,\n }),\n })\n })\n\n if (matchedRoute) {\n viewKey = matchedRoute[0] as keyof typeof oneSegmentViews\n }\n }\n\n // Check if a custom view is configured for this viewKey\n // First try to get custom view by the known viewKey, then fallback to route matching\n const customView =\n (viewKey && getCustomViewByKey({ config, viewKey })) ||\n getCustomViewByRoute({ config, currentRoute })\n\n if (customView?.view?.payloadComponent || customView?.view?.Component) {\n // User has configured a custom view (either overriding a built-in or a new custom view)\n ViewToRender = customView.view\n\n // If this custom view is overriding a built-in view (viewKey matches a built-in),\n // use the built-in's template settings and viewType\n if (viewKey && oneSegmentViews[viewKey]) {\n viewType = viewKey as ViewTypes\n templateClassName = baseClasses[viewKey] || viewKey\n templateType = 'minimal'\n\n if (viewKey === 'account') {\n templateType = 'default'\n }\n\n if (isBrowseByFolderEnabled && viewKey === 'browseByFolder') {\n templateType = 'default'\n viewType = 'folders'\n }\n }\n } else if (oneSegmentViews[viewKey]) {\n // --> /account\n // --> /create-first-user\n // --> /browse-by-folder\n // --> /forgot\n // --> /login\n // --> /logout\n // --> /logout-inactivity\n // --> /unauthorized\n\n ViewToRender = {\n Component: oneSegmentViews[viewKey],\n }\n\n viewType = viewKey as ViewTypes\n\n templateClassName = baseClasses[viewKey]\n templateType = 'minimal'\n\n if (viewKey === 'account') {\n templateType = 'default'\n }\n\n if (isBrowseByFolderEnabled && viewKey === 'browseByFolder') {\n templateType = 'default'\n viewType = 'folders'\n }\n }\n break\n }\n case 2: {\n if (`/${segmentOne}` === config.admin.routes.reset) {\n // --> /reset/:token\n ViewToRender = {\n Component: ResetPassword,\n }\n templateClassName = baseClasses[segmentTwo]\n templateType = 'minimal'\n viewType = 'reset'\n } else if (\n isBrowseByFolderEnabled &&\n `/${segmentOne}` === config.admin.routes.browseByFolder\n ) {\n // --> /browse-by-folder/:folderID\n routeParams.folderID = segmentTwo\n\n ViewToRender = {\n Component: oneSegmentViews.browseByFolder,\n }\n templateClassName = baseClasses.folders\n templateType = 'default'\n viewType = 'folders'\n } else if (collectionConfig) {\n // --> /collections/:collectionSlug'\n routeParams.collection = collectionConfig.slug\n\n if (\n collectionPreferences?.listViewType &&\n collectionPreferences.listViewType === 'folders'\n ) {\n // Render folder view by default if set in preferences\n ViewToRender = {\n Component: CollectionFolderView,\n }\n\n templateClassName = `collection-folders`\n templateType = 'default'\n viewType = 'collection-folders'\n } else {\n ViewToRender = {\n Component: ListView,\n }\n\n templateClassName = `${segmentTwo}-list`\n templateType = 'default'\n viewType = 'list'\n }\n\n viewActions.push(...(collectionConfig.admin.components?.views?.list?.actions || []))\n } else if (globalConfig) {\n // --> /globals/:globalSlug\n routeParams.global = globalConfig.slug\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = 'global-edit'\n templateType = 'default'\n viewType = 'document'\n\n // add default view actions\n viewActions.push(\n ...getViewActions({\n editConfig: globalConfig.admin?.components?.views?.edit,\n viewKey: 'default',\n }),\n )\n }\n break\n }\n default:\n if (segmentTwo === 'verify') {\n // --> /:collectionSlug/verify/:token\n routeParams.collection = segmentOne\n routeParams.token = segmentThree\n\n ViewToRender = {\n Component: Verify,\n }\n\n templateClassName = 'verify'\n templateType = 'minimal'\n viewType = 'verify'\n } else if (collectionConfig) {\n routeParams.collection = collectionConfig.slug\n\n if (segmentThree === 'trash' && typeof segmentFour === 'string') {\n // --> /collections/:collectionSlug/trash/:id (read-only)\n // --> /collections/:collectionSlug/trash/:id/api\n // --> /collections/:collectionSlug/trash/:id/preview\n // --> /collections/:collectionSlug/trash/:id/versions\n // --> /collections/:collectionSlug/trash/:id/versions/:versionID\n routeParams.id = segmentFour\n routeParams.versionID = segmentSix\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `collection-default-edit`\n templateType = 'default'\n\n const viewInfo = getDocumentViewInfo([segmentFive, segmentSix])\n viewType = viewInfo.viewType\n documentSubViewType = viewInfo.documentSubViewType\n\n viewActions.push(\n ...getSubViewActions({\n collectionOrGlobal: collectionConfig,\n viewKeyArg: documentSubViewType,\n }),\n )\n } else if (segmentThree === 'trash') {\n // --> /collections/:collectionSlug/trash\n ViewToRender = {\n Component: TrashView,\n }\n\n templateClassName = `${segmentTwo}-trash`\n templateType = 'default'\n viewType = 'trash'\n\n viewActions.push(...(collectionConfig.admin.components?.views?.list?.actions || []))\n } else {\n if (config.folders && segmentThree === config.folders.slug && collectionConfig.folders) {\n // Collection Folder Views\n // --> /collections/:collectionSlug/:folderCollectionSlug\n // --> /collections/:collectionSlug/:folderCollectionSlug/:folderID\n routeParams.folderCollection = segmentThree\n routeParams.folderID = segmentFour\n\n ViewToRender = {\n Component: CollectionFolderView,\n }\n\n templateClassName = `collection-folders`\n templateType = 'default'\n viewType = 'collection-folders'\n\n viewActions.push(...(collectionConfig.admin.components?.views?.list?.actions || []))\n } else {\n // Collection Edit Views\n // --> /collections/:collectionSlug/create\n // --> /collections/:collectionSlug/:id\n // --> /collections/:collectionSlug/:id/api\n // --> /collections/:collectionSlug/:id/versions\n // --> /collections/:collectionSlug/:id/versions/:versionID\n routeParams.id = segmentThree === 'create' ? undefined : segmentThree\n routeParams.versionID = segmentFive\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `collection-default-edit`\n templateType = 'default'\n\n const viewInfo = getDocumentViewInfo([segmentFour, segmentFive])\n viewType = viewInfo.viewType\n documentSubViewType = viewInfo.documentSubViewType\n\n viewActions.push(\n ...getSubViewActions({\n collectionOrGlobal: collectionConfig,\n viewKeyArg: documentSubViewType,\n }),\n )\n }\n }\n } else if (globalConfig) {\n // Global Edit Views\n // --> /globals/:globalSlug/versions\n // --> /globals/:globalSlug/versions/:versionID\n // --> /globals/:globalSlug/api\n routeParams.global = globalConfig.slug\n routeParams.versionID = segmentFour\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `global-edit`\n templateType = 'default'\n\n const viewInfo = getDocumentViewInfo([segmentThree, segmentFour])\n viewType = viewInfo.viewType\n documentSubViewType = viewInfo.documentSubViewType\n\n viewActions.push(\n ...getSubViewActions({\n collectionOrGlobal: globalConfig,\n viewKeyArg: documentSubViewType,\n }),\n )\n }\n break\n }\n\n if (!ViewToRender) {\n ViewToRender = getCustomViewByRoute({ config, currentRoute })?.view\n }\n\n if (collectionConfig) {\n if (routeParams.id) {\n routeParams.id = parseDocumentID({\n id: routeParams.id,\n collectionSlug: collectionConfig.slug,\n payload,\n })\n }\n\n if (routeParams.versionID) {\n routeParams.versionID = parseDocumentID({\n id: routeParams.versionID,\n collectionSlug: collectionConfig.slug,\n payload,\n })\n }\n }\n\n if (config.folders && routeParams.folderID) {\n routeParams.folderID = parseDocumentID({\n id: routeParams.folderID,\n collectionSlug: config.folders.slug,\n payload,\n })\n }\n\n if (globalConfig && routeParams.versionID) {\n routeParams.versionID =\n payload.db.defaultIDType === 'number' && isNumber(routeParams.versionID)\n ? Number(routeParams.versionID)\n : routeParams.versionID\n }\n\n if (viewActions.length) {\n viewActions.reverse()\n }\n\n return {\n browseByFolderSlugs,\n collectionConfig,\n DefaultView: ViewToRender,\n documentSubViewType,\n globalConfig,\n routeParams,\n templateClassName,\n templateType,\n viewActions: viewActions.length ? viewActions : undefined,\n viewType,\n }\n}\n"],"mappings":"AAeA,SAASA,eAAe,QAAQ;AAChC,SAASC,cAAc,EAAEC,QAAQ,QAAQ;AAEzC,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,aAAa,QAAQ;AAC9B,SAASC,YAAY,QAAQ;AAC7B,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ;AAC5D,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,EAAEC,SAAS,QAAQ;AAC1C,SAASC,gBAAgB,EAAEC,UAAU,QAAQ;AAC7C,SAASC,aAAa,EAAEC,sBAAsB,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AACjC,SAASC,MAAM,EAAEC,eAAe,QAAQ;AACxC,SAASC,iBAAiB,EAAEC,cAAc,QAAQ;AAClD,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,mBAAmB,QAAQ;AAEpC,MAAMC,WAAA,GAAc;EAClBC,OAAA,EAAS;EACTC,OAAA,EAAS;EACTC,MAAA,EAAQrB,uBAAA;EACRsB,KAAA,EAAOnB,cAAA;EACPoB,KAAA,EAAOf,sBAAA;EACPgB,MAAA,EAAQb;AACV;AAWA,MAAMc,eAAA,GAAmC;EACvCN,OAAA,EAAS1B,WAAA;EACTiC,cAAA,EAAgBhC,cAAA;EAChBiC,eAAA,EAAiB9B,mBAAA;EACjBwB,MAAA,EAAQpB,kBAAA;EACR2B,UAAA,EAAYvB,gBAAA;EACZiB,KAAA,EAAOlB,SAAA;EACPyB,MAAA,EAAQvB,UAAA;EACRwB,YAAA,EAAcrB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A,CAAiByB,IAAI;QACrCpB;MACF;IACF;EACF;EAEA,IAAIE,MAAA,CAAOpB,OAAO,IAAI0B,WAAA,CAAY+B,QAAQ,EAAE;IAC1C/B,WAAA,CAAY+B,QAAQ,GAAGvF,eAAA,CAAgB;MACrCiG,EAAA,EAAIzC,WAAA,CAAY+B,QAAQ;MACxBgB,cAAA,EAAgBrD,MAAA,CAAOpB,OAAO,CAACsC,IAAI;MACnCpB;IACF;EACF;EAEA,IAAID,YAAA,IAAgBS,WAAA,CAAY0C,SAAS,EAAE;IACzC1C,WAAA,CAAY0C,SAAS,GACnBlD,OAAA,CAAQwD,EAAE,CAACC,aAAa,KAAK,YAAYvG,QAAA,CAASsD,WAAA,CAAY0C,SAAS,IACnEQ,MAAA,CAAOlD,WAAA,CAAY0C,SAAS,IAC5B1C,WAAA,CAAY0C,SAAS;EAC7B;EAEA,IAAI7B,WAAA,CAAYI,MAAM,EAAE;IACtBJ,WAAA,CAAYsC,OAAO;EACrB;EAEA,OAAO;IACL3C,mBAAA;IACArB,gBAAA;IACAiE,WAAA,EAAazD,YAAA;IACbG,mBAAA;IACAP,YAAA;IACAS,WAAA;IACAJ,iBAAA;IACAC,YAAA;IACAgB,WAAA,EAAaA,WAAA,CAAYI,MAAM,GAAGJ,WAAA,GAAcxB,SAAA;IAChDU;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"getRouteData.js","names":["parseDocumentID","formatAdminURL","isNumber","AccountView","BrowseByFolder","CollectionFolderView","TrashView","CreateFirstUserView","DashboardView","DocumentView","forgotPasswordBaseClass","ForgotPasswordView","ListView","loginBaseClass","LoginView","LogoutInactivity","LogoutView","ResetPassword","resetPasswordBaseClass","UnauthorizedView","Verify","verifyBaseClass","getSubViewActions","getViewActions","getCustomCollectionViewByRoute","getCustomViewByKey","getCustomViewByRoute","getDocumentViewInfo","isPathMatchingRoute","baseClasses","account","folders","forgot","login","reset","verify","oneSegmentViews","browseByFolder","createFirstUser","inactivity","logout","unauthorized","getRouteData","adminRoute","collectionConfig","collectionPreferences","undefined","currentRoute","globalConfig","payload","segments","config","ViewToRender","templateClassName","templateType","documentSubViewType","viewType","routeParams","segmentOne","segmentTwo","segmentThree","segmentFour","segmentFive","segmentSix","isBrowseByFolderEnabled","browseByFolderSlugs","collections","reduce","acc","slug","viewActions","admin","components","actions","length","Component","viewKey","routes","matchedRoute","Object","entries","find","route","exact","path","customView","view","payloadComponent","folderID","collection","listViewType","push","views","list","global","editConfig","edit","token","id","versionID","viewInfo","collectionOrGlobal","viewKeyArg","folderCollection","baseRoute","customCollectionView","collectionSlug","db","defaultIDType","Number","reverse","DefaultView"],"sources":["../../../src/views/Root/getRouteData.ts"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n CollectionSlug,\n CustomComponent,\n DocumentSubViewTypes,\n Payload,\n PayloadComponent,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n ViewTypes,\n} from 'payload'\nimport type React from 'react'\n\nimport { parseDocumentID } from 'payload'\nimport { formatAdminURL, isNumber } from 'payload/shared'\n\nimport { AccountView } from '../Account/index.js'\nimport { BrowseByFolder } from '../BrowseByFolder/index.js'\nimport { CollectionFolderView } from '../CollectionFolders/index.js'\nimport { TrashView } from '../CollectionTrash/index.js'\nimport { CreateFirstUserView } from '../CreateFirstUser/index.js'\nimport { DashboardView } from '../Dashboard/index.js'\nimport { DocumentView } from '../Document/index.js'\nimport { forgotPasswordBaseClass, ForgotPasswordView } from '../ForgotPassword/index.js'\nimport { ListView } from '../List/index.js'\nimport { loginBaseClass, LoginView } from '../Login/index.js'\nimport { LogoutInactivity, LogoutView } from '../Logout/index.js'\nimport { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { Verify, verifyBaseClass } from '../Verify/index.js'\nimport { getSubViewActions, getViewActions } from './attachViewActions.js'\nimport { getCustomCollectionViewByRoute } from './getCustomCollectionViewByRoute.js'\nimport { getCustomViewByKey } from './getCustomViewByKey.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { getDocumentViewInfo } from './getDocumentViewInfo.js'\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\nconst baseClasses = {\n account: 'account',\n folders: 'folders',\n forgot: forgotPasswordBaseClass,\n login: loginBaseClass,\n reset: resetPasswordBaseClass,\n verify: verifyBaseClass,\n}\n\ntype OneSegmentViews = {\n [K in Exclude<keyof SanitizedConfig['admin']['routes'], 'reset'>]: React.FC<AdminViewServerProps>\n}\n\nexport type ViewFromConfig = {\n Component?: React.FC<AdminViewServerProps>\n payloadComponent?: PayloadComponent<AdminViewServerProps>\n}\n\nconst oneSegmentViews: OneSegmentViews = {\n account: AccountView,\n browseByFolder: BrowseByFolder,\n createFirstUser: CreateFirstUserView,\n forgot: ForgotPasswordView,\n inactivity: LogoutInactivity,\n login: LoginView,\n logout: LogoutView,\n unauthorized: UnauthorizedView,\n}\n\ntype GetRouteDataResult = {\n browseByFolderSlugs: CollectionSlug[]\n collectionConfig?: SanitizedCollectionConfig\n DefaultView: ViewFromConfig\n documentSubViewType?: DocumentSubViewTypes\n globalConfig?: SanitizedGlobalConfig\n routeParams: {\n collection?: string\n folderCollection?: string\n folderID?: number | string\n global?: string\n id?: number | string\n token?: string\n versionID?: number | string\n }\n templateClassName: string\n templateType: 'default' | 'minimal'\n viewActions?: CustomComponent[]\n viewType?: ViewTypes\n}\n\ntype GetRouteDataArgs = {\n adminRoute: string\n collectionConfig?: SanitizedCollectionConfig\n /**\n * User preferences for a collection.\n *\n * These preferences are normally undefined\n * unless the user is on the list view and the\n * collection is folder enabled.\n */\n collectionPreferences?: CollectionPreferences\n currentRoute: string\n globalConfig?: SanitizedGlobalConfig\n payload: Payload\n searchParams: {\n [key: string]: string | string[]\n }\n segments: string[]\n}\n\nexport const getRouteData = ({\n adminRoute,\n collectionConfig,\n collectionPreferences = undefined,\n currentRoute,\n globalConfig,\n payload,\n segments,\n}: GetRouteDataArgs): GetRouteDataResult => {\n const { config } = payload\n let ViewToRender: ViewFromConfig = null\n let templateClassName: string\n let templateType: 'default' | 'minimal' | undefined\n let documentSubViewType: DocumentSubViewTypes\n let viewType: ViewTypes\n const routeParams: GetRouteDataResult['routeParams'] = {}\n\n const [segmentOne, segmentTwo, segmentThree, segmentFour, segmentFive, segmentSix] = segments\n\n const isBrowseByFolderEnabled = config.folders && config.folders.browseByFolder\n const browseByFolderSlugs =\n (isBrowseByFolderEnabled &&\n config.collections.reduce((acc, { slug, folders }) => {\n if (folders && folders.browseByFolder) {\n return [...acc, slug]\n }\n return acc\n }, [])) ||\n []\n\n const viewActions: CustomComponent[] = [...(config?.admin?.components?.actions || [])]\n\n switch (segments.length) {\n case 0: {\n if (currentRoute === adminRoute) {\n ViewToRender = {\n Component: DashboardView,\n }\n templateClassName = 'dashboard'\n templateType = 'default'\n viewType = 'dashboard'\n }\n break\n }\n case 1: {\n // users can override the default routes via `admin.routes` config\n // i.e.{ admin: { routes: { logout: '/sign-out', inactivity: '/idle' }}}\n let viewKey: keyof typeof oneSegmentViews\n\n if (config.admin.routes) {\n const matchedRoute = Object.entries(config.admin.routes).find(([, route]) => {\n return isPathMatchingRoute({\n currentRoute,\n exact: true,\n path: formatAdminURL({\n adminRoute,\n path: route,\n }),\n })\n })\n\n if (matchedRoute) {\n viewKey = matchedRoute[0] as keyof typeof oneSegmentViews\n }\n }\n\n // Check if a custom view is configured for this viewKey\n // First try to get custom view by the known viewKey, then fallback to route matching\n const customView =\n (viewKey && getCustomViewByKey({ config, viewKey })) ||\n getCustomViewByRoute({ config, currentRoute })\n\n if (customView?.view?.payloadComponent || customView?.view?.Component) {\n // User has configured a custom view (either overriding a built-in or a new custom view)\n ViewToRender = customView.view\n\n // If this custom view is overriding a built-in view (viewKey matches a built-in),\n // use the built-in's template settings and viewType\n if (viewKey && oneSegmentViews[viewKey]) {\n viewType = viewKey as ViewTypes\n templateClassName = baseClasses[viewKey] || viewKey\n templateType = 'minimal'\n\n if (viewKey === 'account') {\n templateType = 'default'\n }\n\n if (isBrowseByFolderEnabled && viewKey === 'browseByFolder') {\n templateType = 'default'\n viewType = 'folders'\n }\n }\n } else if (oneSegmentViews[viewKey]) {\n // --> /account\n // --> /create-first-user\n // --> /browse-by-folder\n // --> /forgot\n // --> /login\n // --> /logout\n // --> /logout-inactivity\n // --> /unauthorized\n\n ViewToRender = {\n Component: oneSegmentViews[viewKey],\n }\n\n viewType = viewKey as ViewTypes\n\n templateClassName = baseClasses[viewKey]\n templateType = 'minimal'\n\n if (viewKey === 'account') {\n templateType = 'default'\n }\n\n if (isBrowseByFolderEnabled && viewKey === 'browseByFolder') {\n templateType = 'default'\n viewType = 'folders'\n }\n }\n break\n }\n case 2: {\n if (`/${segmentOne}` === config.admin.routes.reset) {\n // --> /reset/:token\n ViewToRender = {\n Component: ResetPassword,\n }\n templateClassName = baseClasses[segmentTwo]\n templateType = 'minimal'\n viewType = 'reset'\n } else if (\n isBrowseByFolderEnabled &&\n `/${segmentOne}` === config.admin.routes.browseByFolder\n ) {\n // --> /browse-by-folder/:folderID\n routeParams.folderID = segmentTwo\n\n ViewToRender = {\n Component: oneSegmentViews.browseByFolder,\n }\n templateClassName = baseClasses.folders\n templateType = 'default'\n viewType = 'folders'\n } else if (collectionConfig) {\n // --> /collections/:collectionSlug'\n routeParams.collection = collectionConfig.slug\n\n if (\n collectionPreferences?.listViewType &&\n collectionPreferences.listViewType === 'folders'\n ) {\n // Render folder view by default if set in preferences\n ViewToRender = {\n Component: CollectionFolderView,\n }\n\n templateClassName = `collection-folders`\n templateType = 'default'\n viewType = 'collection-folders'\n } else {\n ViewToRender = {\n Component: ListView,\n }\n\n templateClassName = `${segmentTwo}-list`\n templateType = 'default'\n viewType = 'list'\n }\n\n viewActions.push(...(collectionConfig.admin.components?.views?.list?.actions || []))\n } else if (globalConfig) {\n // --> /globals/:globalSlug\n routeParams.global = globalConfig.slug\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = 'global-edit'\n templateType = 'default'\n viewType = 'document'\n\n // add default view actions\n viewActions.push(\n ...getViewActions({\n editConfig: globalConfig.admin?.components?.views?.edit,\n viewKey: 'default',\n }),\n )\n }\n break\n }\n default:\n if (segmentTwo === 'verify') {\n // --> /:collectionSlug/verify/:token\n routeParams.collection = segmentOne\n routeParams.token = segmentThree\n\n ViewToRender = {\n Component: Verify,\n }\n\n templateClassName = 'verify'\n templateType = 'minimal'\n viewType = 'verify'\n } else if (collectionConfig) {\n routeParams.collection = collectionConfig.slug\n\n if (segmentThree === 'trash' && typeof segmentFour === 'string') {\n // --> /collections/:collectionSlug/trash/:id (read-only)\n // --> /collections/:collectionSlug/trash/:id/api\n // --> /collections/:collectionSlug/trash/:id/preview\n // --> /collections/:collectionSlug/trash/:id/versions\n // --> /collections/:collectionSlug/trash/:id/versions/:versionID\n routeParams.id = segmentFour\n routeParams.versionID = segmentSix\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `collection-default-edit`\n templateType = 'default'\n\n const viewInfo = getDocumentViewInfo([segmentFive, segmentSix])\n viewType = viewInfo.viewType\n documentSubViewType = viewInfo.documentSubViewType\n\n viewActions.push(\n ...getSubViewActions({\n collectionOrGlobal: collectionConfig,\n viewKeyArg: documentSubViewType,\n }),\n )\n } else if (segmentThree === 'trash') {\n // --> /collections/:collectionSlug/trash\n ViewToRender = {\n Component: TrashView,\n }\n\n templateClassName = `${segmentTwo}-trash`\n templateType = 'default'\n viewType = 'trash'\n\n viewActions.push(...(collectionConfig.admin.components?.views?.list?.actions || []))\n } else {\n if (config.folders && segmentThree === config.folders.slug && collectionConfig.folders) {\n // Collection Folder Views\n // --> /collections/:collectionSlug/:folderCollectionSlug\n // --> /collections/:collectionSlug/:folderCollectionSlug/:folderID\n routeParams.folderCollection = segmentThree\n routeParams.folderID = segmentFour\n\n ViewToRender = {\n Component: CollectionFolderView,\n }\n\n templateClassName = `collection-folders`\n templateType = 'default'\n viewType = 'collection-folders'\n\n viewActions.push(...(collectionConfig.admin.components?.views?.list?.actions || []))\n } else {\n // Check for custom collection views before assuming it's an edit view\n const baseRoute = `/${segmentOne}/${segmentTwo}`\n const customCollectionView = getCustomCollectionViewByRoute({\n adminRoute,\n baseRoute,\n currentRoute,\n views: collectionConfig.admin.components?.views,\n })\n\n if (customCollectionView.viewKey && customCollectionView.view.payloadComponent) {\n // --> /collections/:collectionSlug/:customViewPath\n ViewToRender = customCollectionView.view\n\n templateClassName = `collection-${customCollectionView.viewKey}`\n templateType = 'default'\n viewType = customCollectionView.viewKey\n } else {\n // Collection Edit Views\n // --> /collections/:collectionSlug/create\n // --> /collections/:collectionSlug/:id\n // --> /collections/:collectionSlug/:id/api\n // --> /collections/:collectionSlug/:id/versions\n // --> /collections/:collectionSlug/:id/versions/:versionID\n routeParams.id = segmentThree === 'create' ? undefined : segmentThree\n routeParams.versionID = segmentFive\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `collection-default-edit`\n templateType = 'default'\n\n const viewInfo = getDocumentViewInfo([segmentFour, segmentFive])\n viewType = viewInfo.viewType\n documentSubViewType = viewInfo.documentSubViewType\n\n viewActions.push(\n ...getSubViewActions({\n collectionOrGlobal: collectionConfig,\n viewKeyArg: documentSubViewType,\n }),\n )\n }\n }\n }\n } else if (globalConfig) {\n // Global Edit Views\n // --> /globals/:globalSlug/versions\n // --> /globals/:globalSlug/versions/:versionID\n // --> /globals/:globalSlug/api\n routeParams.global = globalConfig.slug\n routeParams.versionID = segmentFour\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `global-edit`\n templateType = 'default'\n\n const viewInfo = getDocumentViewInfo([segmentThree, segmentFour])\n viewType = viewInfo.viewType\n documentSubViewType = viewInfo.documentSubViewType\n\n viewActions.push(\n ...getSubViewActions({\n collectionOrGlobal: globalConfig,\n viewKeyArg: documentSubViewType,\n }),\n )\n }\n break\n }\n\n if (!ViewToRender) {\n ViewToRender = getCustomViewByRoute({ config, currentRoute })?.view\n }\n\n if (collectionConfig) {\n if (routeParams.id) {\n routeParams.id = parseDocumentID({\n id: routeParams.id,\n collectionSlug: collectionConfig.slug,\n payload,\n })\n }\n\n if (routeParams.versionID) {\n routeParams.versionID = parseDocumentID({\n id: routeParams.versionID,\n collectionSlug: collectionConfig.slug,\n payload,\n })\n }\n }\n\n if (config.folders && routeParams.folderID) {\n routeParams.folderID = parseDocumentID({\n id: routeParams.folderID,\n collectionSlug: config.folders.slug,\n payload,\n })\n }\n\n if (globalConfig && routeParams.versionID) {\n routeParams.versionID =\n payload.db.defaultIDType === 'number' && isNumber(routeParams.versionID)\n ? Number(routeParams.versionID)\n : routeParams.versionID\n }\n\n if (viewActions.length) {\n viewActions.reverse()\n }\n\n return {\n browseByFolderSlugs,\n collectionConfig,\n DefaultView: ViewToRender,\n documentSubViewType,\n globalConfig,\n routeParams,\n templateClassName,\n templateType,\n viewActions: viewActions.length ? viewActions : undefined,\n viewType,\n }\n}\n"],"mappings":"AAeA,SAASA,eAAe,QAAQ;AAChC,SAASC,cAAc,EAAEC,QAAQ,QAAQ;AAEzC,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,aAAa,QAAQ;AAC9B,SAASC,YAAY,QAAQ;AAC7B,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ;AAC5D,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,EAAEC,SAAS,QAAQ;AAC1C,SAASC,gBAAgB,EAAEC,UAAU,QAAQ;AAC7C,SAASC,aAAa,EAAEC,sBAAsB,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AACjC,SAASC,MAAM,EAAEC,eAAe,QAAQ;AACxC,SAASC,iBAAiB,EAAEC,cAAc,QAAQ;AAClD,SAASC,8BAA8B,QAAQ;AAC/C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AAC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,CAACsC,IAAI;MACnCpB;IACF;EACF;EAEA,IAAID,YAAA,IAAgBS,WAAA,CAAY0C,SAAS,EAAE;IACzC1C,WAAA,CAAY0C,SAAS,GACnBlD,OAAA,CAAQ0D,EAAE,CAACC,aAAa,KAAK,YAAY1G,QAAA,CAASuD,WAAA,CAAY0C,SAAS,IACnEU,MAAA,CAAOpD,WAAA,CAAY0C,SAAS,IAC5B1C,WAAA,CAAY0C,SAAS;EAC7B;EAEA,IAAI7B,WAAA,CAAYI,MAAM,EAAE;IACtBJ,WAAA,CAAYwC,OAAO;EACrB;EAEA,OAAO;IACL7C,mBAAA;IACArB,gBAAA;IACAmE,WAAA,EAAa3D,YAAA;IACbG,mBAAA;IACAP,YAAA;IACAS,WAAA;IACAJ,iBAAA;IACAC,YAAA;IACAgB,WAAA,EAAaA,WAAA,CAAYI,MAAM,GAAGJ,WAAA,GAAcxB,SAAA;IAChDU;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"isPathMatchingRoute.d.ts","sourceRoot":"","sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,gEAM7B;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,YAyBA,CAAA"}
1
+ {"version":3,"file":"isPathMatchingRoute.d.ts","sourceRoot":"","sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,gEAM7B;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,YA+BA,CAAA"}
@@ -23,7 +23,11 @@ export const isPathMatchingRoute = ({
23
23
  return currentRoute === viewRoute;
24
24
  }
25
25
  if (!exact) {
26
- return viewRoute.startsWith(currentRoute);
26
+ if (!currentRoute.startsWith(viewRoute)) {
27
+ return false;
28
+ }
29
+ const remainingPath = currentRoute.slice(viewRoute.length);
30
+ return remainingPath === '' || remainingPath.startsWith('/');
27
31
  }
28
32
  };
29
33
  //# sourceMappingURL=isPathMatchingRoute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isPathMatchingRoute.js","names":["pathToRegexp","isPathMatchingRoute","currentRoute","exact","path","viewPath","sensitive","strict","keys","regex","match","exec","viewRoute","startsWith"],"sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"sourcesContent":["import { pathToRegexp } from 'path-to-regexp'\n\nexport const isPathMatchingRoute = ({\n currentRoute,\n exact,\n path: viewPath,\n sensitive,\n strict,\n}: {\n currentRoute: string\n exact?: boolean\n path?: string\n sensitive?: boolean\n strict?: boolean\n}) => {\n // if no path is defined, we cannot match it so return false early\n if (!viewPath) {\n return false\n }\n\n const keys = []\n\n // run the view path through `pathToRegexp` to resolve any dynamic segments\n // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123`\n const regex = pathToRegexp(viewPath, keys, {\n sensitive,\n strict,\n })\n\n const match = regex.exec(currentRoute)\n const viewRoute = match?.[0] || viewPath\n\n if (exact) {\n return currentRoute === viewRoute\n }\n\n if (!exact) {\n return viewRoute.startsWith(currentRoute)\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ;AAE7B,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC,YAAY;EACZC,KAAK;EACLC,IAAA,EAAMC,QAAQ;EACdC,SAAS;EACTC;AAAM,CAOP;EACC;EACA,IAAI,CAACF,QAAA,EAAU;IACb,OAAO;EACT;EAEA,MAAMG,IAAA,GAAO,EAAE;EAEf;EACA;EACA,MAAMC,KAAA,GAAQT,YAAA,CAAaK,QAAA,EAAUG,IAAA,EAAM;IACzCF,SAAA;IACAC;EACF;EAEA,MAAMG,KAAA,GAAQD,KAAA,CAAME,IAAI,CAACT,YAAA;EACzB,MAAMU,SAAA,GAAYF,KAAA,GAAQ,EAAE,IAAIL,QAAA;EAEhC,IAAIF,KAAA,EAAO;IACT,OAAOD,YAAA,KAAiBU,SAAA;EAC1B;EAEA,IAAI,CAACT,KAAA,EAAO;IACV,OAAOS,SAAA,CAAUC,UAAU,CAACX,YAAA;EAC9B;AACF","ignoreList":[]}
1
+ {"version":3,"file":"isPathMatchingRoute.js","names":["pathToRegexp","isPathMatchingRoute","currentRoute","exact","path","viewPath","sensitive","strict","keys","regex","match","exec","viewRoute","startsWith","remainingPath","slice","length"],"sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"sourcesContent":["import { pathToRegexp } from 'path-to-regexp'\n\nexport const isPathMatchingRoute = ({\n currentRoute,\n exact,\n path: viewPath,\n sensitive,\n strict,\n}: {\n currentRoute: string\n exact?: boolean\n path?: string\n sensitive?: boolean\n strict?: boolean\n}) => {\n // if no path is defined, we cannot match it so return false early\n if (!viewPath) {\n return false\n }\n\n const keys = []\n\n // run the view path through `pathToRegexp` to resolve any dynamic segments\n // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123`\n const regex = pathToRegexp(viewPath, keys, {\n sensitive,\n strict,\n })\n\n const match = regex.exec(currentRoute)\n const viewRoute = match?.[0] || viewPath\n\n if (exact) {\n return currentRoute === viewRoute\n }\n\n if (!exact) {\n if (!currentRoute.startsWith(viewRoute)) {\n return false\n }\n\n const remainingPath = currentRoute.slice(viewRoute.length)\n\n return remainingPath === '' || remainingPath.startsWith('/')\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ;AAE7B,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC,YAAY;EACZC,KAAK;EACLC,IAAA,EAAMC,QAAQ;EACdC,SAAS;EACTC;AAAM,CAOP;EACC;EACA,IAAI,CAACF,QAAA,EAAU;IACb,OAAO;EACT;EAEA,MAAMG,IAAA,GAAO,EAAE;EAEf;EACA;EACA,MAAMC,KAAA,GAAQT,YAAA,CAAaK,QAAA,EAAUG,IAAA,EAAM;IACzCF,SAAA;IACAC;EACF;EAEA,MAAMG,KAAA,GAAQD,KAAA,CAAME,IAAI,CAACT,YAAA;EACzB,MAAMU,SAAA,GAAYF,KAAA,GAAQ,EAAE,IAAIL,QAAA;EAEhC,IAAIF,KAAA,EAAO;IACT,OAAOD,YAAA,KAAiBU,SAAA;EAC1B;EAEA,IAAI,CAACT,KAAA,EAAO;IACV,IAAI,CAACD,YAAA,CAAaW,UAAU,CAACD,SAAA,GAAY;MACvC,OAAO;IACT;IAEA,MAAME,aAAA,GAAgBZ,YAAA,CAAaa,KAAK,CAACH,SAAA,CAAUI,MAAM;IAEzD,OAAOF,aAAA,KAAkB,MAAMA,aAAA,CAAcD,UAAU,CAAC;EAC1D;AACF","ignoreList":[]}
@@ -0,0 +1,178 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { isPathMatchingRoute } from './isPathMatchingRoute.js';
3
+ describe('isPathMatchingRoute', () => {
4
+ describe('no path defined', () => {
5
+ it('should return false when path is undefined', () => {
6
+ expect(isPathMatchingRoute({
7
+ currentRoute: '/anything',
8
+ path: undefined
9
+ })).toBe(false);
10
+ });
11
+ it('should return false when path is empty string', () => {
12
+ expect(isPathMatchingRoute({
13
+ currentRoute: '/anything',
14
+ path: ''
15
+ })).toBe(false);
16
+ });
17
+ });
18
+ describe('exact matching', () => {
19
+ it('should match when currentRoute exactly equals the static path', () => {
20
+ expect(isPathMatchingRoute({
21
+ currentRoute: '/dashboard',
22
+ exact: true,
23
+ path: '/dashboard'
24
+ })).toBe(true);
25
+ });
26
+ it('should not match when currentRoute differs from the path', () => {
27
+ expect(isPathMatchingRoute({
28
+ currentRoute: '/settings',
29
+ exact: true,
30
+ path: '/dashboard'
31
+ })).toBe(false);
32
+ });
33
+ it('should not match a sub-path when exact is true', () => {
34
+ expect(isPathMatchingRoute({
35
+ currentRoute: '/dashboard/settings',
36
+ exact: true,
37
+ path: '/dashboard'
38
+ })).toBe(false);
39
+ });
40
+ it('should match a parameterized path exactly', () => {
41
+ expect(isPathMatchingRoute({
42
+ currentRoute: '/custom/123',
43
+ exact: true,
44
+ path: '/custom/:id'
45
+ })).toBe(true);
46
+ });
47
+ it('should not match a parameterized path with extra segments', () => {
48
+ expect(isPathMatchingRoute({
49
+ currentRoute: '/custom/123/edit',
50
+ exact: true,
51
+ path: '/custom/:id'
52
+ })).toBe(false);
53
+ });
54
+ it('should match root path exactly', () => {
55
+ expect(isPathMatchingRoute({
56
+ currentRoute: '/',
57
+ exact: true,
58
+ path: '/'
59
+ })).toBe(true);
60
+ });
61
+ it('should not match root path against other routes when exact', () => {
62
+ expect(isPathMatchingRoute({
63
+ currentRoute: '/login',
64
+ exact: true,
65
+ path: '/'
66
+ })).toBe(false);
67
+ });
68
+ });
69
+ describe('non-exact (prefix) matching', () => {
70
+ it('should match when currentRoute equals the path', () => {
71
+ expect(isPathMatchingRoute({
72
+ currentRoute: '/dashboard',
73
+ path: '/dashboard'
74
+ })).toBe(true);
75
+ });
76
+ it('should match a sub-path at a segment boundary', () => {
77
+ expect(isPathMatchingRoute({
78
+ currentRoute: '/dashboard/settings',
79
+ path: '/dashboard'
80
+ })).toBe(true);
81
+ });
82
+ it('should match deeply nested sub-paths', () => {
83
+ expect(isPathMatchingRoute({
84
+ currentRoute: '/dashboard/settings/advanced/debug',
85
+ path: '/dashboard'
86
+ })).toBe(true);
87
+ });
88
+ it('should not match when route shares a prefix but not at a segment boundary', () => {
89
+ expect(isPathMatchingRoute({
90
+ currentRoute: '/dashboard-extra',
91
+ path: '/dashboard'
92
+ })).toBe(false);
93
+ });
94
+ it('should not match a completely different route', () => {
95
+ expect(isPathMatchingRoute({
96
+ currentRoute: '/settings',
97
+ path: '/dashboard'
98
+ })).toBe(false);
99
+ });
100
+ it('should match a parameterized path with a sub-path', () => {
101
+ expect(isPathMatchingRoute({
102
+ currentRoute: '/custom/123/edit',
103
+ path: '/custom/:id'
104
+ })).toBe(false);
105
+ // pathToRegexp is end-anchored by default, so /custom/:id does not match /custom/123/edit.
106
+ // The literal fallback '/custom/:id' also won't startsWith-match.
107
+ // Parameterized views should use exact: true or include all segments in the pattern.
108
+ });
109
+ it('should match when :id captures the full segment including non-slash characters', () => {
110
+ expect(isPathMatchingRoute({
111
+ currentRoute: '/custom/123extra',
112
+ path: '/custom/:id'
113
+ })).toBe(true);
114
+ // :id captures everything up to the next / — '123extra' is a valid :id value
115
+ });
116
+ });
117
+ describe('root path / without exact — regression for route shadowing bug', () => {
118
+ it('should match root path against itself', () => {
119
+ expect(isPathMatchingRoute({
120
+ currentRoute: '/',
121
+ path: '/'
122
+ })).toBe(true);
123
+ });
124
+ it('should not match root path against /login', () => {
125
+ expect(isPathMatchingRoute({
126
+ currentRoute: '/login',
127
+ path: '/'
128
+ })).toBe(false);
129
+ });
130
+ it('should not match root path against /collections/posts', () => {
131
+ expect(isPathMatchingRoute({
132
+ currentRoute: '/collections/posts',
133
+ path: '/'
134
+ })).toBe(false);
135
+ });
136
+ it('should not match root path against /collections/posts/123', () => {
137
+ expect(isPathMatchingRoute({
138
+ currentRoute: '/collections/posts/123',
139
+ path: '/'
140
+ })).toBe(false);
141
+ });
142
+ });
143
+ describe('sensitive option', () => {
144
+ it('should match case-insensitively by default', () => {
145
+ expect(isPathMatchingRoute({
146
+ currentRoute: '/Dashboard',
147
+ exact: true,
148
+ path: '/dashboard'
149
+ })).toBe(true);
150
+ });
151
+ it('should not match different cases when sensitive is true', () => {
152
+ expect(isPathMatchingRoute({
153
+ currentRoute: '/Dashboard',
154
+ exact: true,
155
+ path: '/dashboard',
156
+ sensitive: true
157
+ })).toBe(false);
158
+ });
159
+ });
160
+ describe('strict option', () => {
161
+ it('should match with or without trailing slash by default', () => {
162
+ expect(isPathMatchingRoute({
163
+ currentRoute: '/dashboard/',
164
+ exact: true,
165
+ path: '/dashboard'
166
+ })).toBe(true);
167
+ });
168
+ it('should not match trailing slash mismatch when strict is true', () => {
169
+ expect(isPathMatchingRoute({
170
+ currentRoute: '/dashboard/',
171
+ exact: true,
172
+ path: '/dashboard',
173
+ strict: true
174
+ })).toBe(false);
175
+ });
176
+ });
177
+ });
178
+ //# sourceMappingURL=isPathMatchingRoute.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPathMatchingRoute.spec.js","names":["describe","expect","it","isPathMatchingRoute","currentRoute","path","undefined","toBe","exact","sensitive","strict"],"sources":["../../../src/views/Root/isPathMatchingRoute.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\ndescribe('isPathMatchingRoute', () => {\n describe('no path defined', () => {\n it('should return false when path is undefined', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: undefined })).toBe(false)\n })\n\n it('should return false when path is empty string', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: '' })).toBe(false)\n })\n })\n\n describe('exact matching', () => {\n it('should match when currentRoute exactly equals the static path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/dashboard', exact: true, path: '/dashboard' }),\n ).toBe(true)\n })\n\n it('should not match when currentRoute differs from the path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/settings', exact: true, path: '/dashboard' }),\n ).toBe(false)\n })\n\n it('should not match a sub-path when exact is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(false)\n })\n\n it('should match a parameterized path exactly', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(true)\n })\n\n it('should not match a parameterized path with extra segments', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(false)\n })\n\n it('should match root path exactly', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', exact: true, path: '/' })).toBe(true)\n })\n\n it('should not match root path against other routes when exact', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', exact: true, path: '/' })).toBe(false)\n })\n })\n\n describe('non-exact (prefix) matching', () => {\n it('should match when currentRoute equals the path', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard', path: '/dashboard' })).toBe(true)\n })\n\n it('should match a sub-path at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard/settings', path: '/dashboard' })).toBe(\n true,\n )\n })\n\n it('should match deeply nested sub-paths', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings/advanced/debug',\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match when route shares a prefix but not at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard-extra', path: '/dashboard' })).toBe(\n false,\n )\n })\n\n it('should not match a completely different route', () => {\n expect(isPathMatchingRoute({ currentRoute: '/settings', path: '/dashboard' })).toBe(false)\n })\n\n it('should match a parameterized path with a sub-path', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n path: '/custom/:id',\n }),\n ).toBe(false)\n // pathToRegexp is end-anchored by default, so /custom/:id does not match /custom/123/edit.\n // The literal fallback '/custom/:id' also won't startsWith-match.\n // Parameterized views should use exact: true or include all segments in the pattern.\n })\n\n it('should match when :id captures the full segment including non-slash characters', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123extra',\n path: '/custom/:id',\n }),\n ).toBe(true)\n // :id captures everything up to the next / — '123extra' is a valid :id value\n })\n })\n\n describe('root path / without exact — regression for route shadowing bug', () => {\n it('should match root path against itself', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', path: '/' })).toBe(true)\n })\n\n it('should not match root path against /login', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts/123', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts/123', path: '/' })).toBe(false)\n })\n })\n\n describe('sensitive option', () => {\n it('should match case-insensitively by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match different cases when sensitive is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n sensitive: true,\n }),\n ).toBe(false)\n })\n })\n\n describe('strict option', () => {\n it('should match with or without trailing slash by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match trailing slash mismatch when strict is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n strict: true,\n }),\n ).toBe(false)\n })\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,mBAAmB,QAAQ;AAEpCH,QAAA,CAAS,uBAAuB;EAC9BA,QAAA,CAAS,mBAAmB;IAC1BE,EAAA,CAAG,8CAA8C;MAC/CD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAaC,IAAA,EAAMC;MAAU,IAAIC,IAAI,CAAC;IACnF;IAEAL,EAAA,CAAG,iDAAiD;MAClDD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAaC,IAAA,EAAM;MAAG,IAAIE,IAAI,CAAC;IAC5E;EACF;EAEAP,QAAA,CAAS,kBAAkB;IACzBE,EAAA,CAAG,iEAAiE;MAClED,MAAA,CACEE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAcI,KAAA,EAAO;QAAMH,IAAA,EAAM;MAAa,IAClFE,IAAI,CAAC;IACT;IAEAL,EAAA,C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AG,8CAA8C;MAC/CD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;MACR,IACAE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,2DAA2D;MAC5DD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNI,SAAA,EAAW;MACb,IACAF,IAAI,CAAC;IACT;EACF;EAEAP,QAAA,CAAS,iBAAiB;IACxBE,EAAA,CAAG,0DAA0D;MAC3DD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;MACR,IACAE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,gEAAgE;MACjED,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNK,MAAA,EAAQ;MACV,IACAH,IAAI,CAAC;IACT;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.83.0-internal.ddc1147",
3
+ "version": "3.84.0-canary.0",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -99,9 +99,9 @@
99
99
  "qs-esm": "8.0.1",
100
100
  "sass": "1.77.4",
101
101
  "uuid": "11.1.0",
102
- "@payloadcms/graphql": "3.83.0-internal.ddc1147",
103
- "@payloadcms/translations": "3.83.0-internal.ddc1147",
104
- "@payloadcms/ui": "3.83.0-internal.ddc1147"
102
+ "@payloadcms/graphql": "3.84.0-canary.0",
103
+ "@payloadcms/translations": "3.84.0-canary.0",
104
+ "@payloadcms/ui": "3.84.0-canary.0"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@babel/cli": "7.27.2",
@@ -117,13 +117,13 @@
117
117
  "esbuild": "0.27.1",
118
118
  "esbuild-sass-plugin": "3.3.1",
119
119
  "swc-plugin-transform-remove-imports": "8.3.0",
120
- "@payloadcms/eslint-config": "3.28.0",
121
- "payload": "3.83.0-internal.ddc1147"
120
+ "payload": "3.84.0-canary.0",
121
+ "@payloadcms/eslint-config": "3.28.0"
122
122
  },
123
123
  "peerDependencies": {
124
124
  "graphql": "^16.8.1",
125
125
  "next": ">=15.2.9 <15.3.0 || >=15.3.9 <15.4.0 || >=15.4.11 <15.5.0 || >=16.2.2 <17.0.0",
126
- "payload": "3.83.0-internal.ddc1147"
126
+ "payload": "3.84.0-canary.0"
127
127
  },
128
128
  "engines": {
129
129
  "node": "^18.20.2 || >=20.9.0"