@payloadcms/next 3.69.0-internal.5029b68 → 3.70.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.
Files changed (146) hide show
  1. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.d.ts.map +1 -1
  2. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +19 -24
  3. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +1 -1
  4. package/dist/elements/Nav/index.client.d.ts.map +1 -1
  5. package/dist/elements/Nav/index.client.js +15 -21
  6. package/dist/elements/Nav/index.client.js.map +1 -1
  7. package/dist/prod/styles.css +1 -1
  8. package/dist/routes/graphql/playground.d.ts.map +1 -1
  9. package/dist/routes/graphql/playground.js +6 -1
  10. package/dist/routes/graphql/playground.js.map +1 -1
  11. package/dist/routes/rest/index.d.ts.map +1 -1
  12. package/dist/routes/rest/index.js +5 -1
  13. package/dist/routes/rest/index.js.map +1 -1
  14. package/dist/utilities/handleAuthRedirect.d.ts.map +1 -1
  15. package/dist/utilities/handleAuthRedirect.js +1 -2
  16. package/dist/utilities/handleAuthRedirect.js.map +1 -1
  17. package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
  18. package/dist/utilities/handleServerFunctions.js +4 -0
  19. package/dist/utilities/handleServerFunctions.js.map +1 -1
  20. package/dist/views/API/index.client.d.ts.map +1 -1
  21. package/dist/views/API/index.client.js +7 -5
  22. package/dist/views/API/index.client.js.map +1 -1
  23. package/dist/views/Account/ResetPreferences/index.d.ts +0 -1
  24. package/dist/views/Account/ResetPreferences/index.d.ts.map +1 -1
  25. package/dist/views/Account/ResetPreferences/index.js +32 -25
  26. package/dist/views/Account/ResetPreferences/index.js.map +1 -1
  27. package/dist/views/Account/Settings/index.d.ts.map +1 -1
  28. package/dist/views/Account/Settings/index.js +0 -3
  29. package/dist/views/Account/Settings/index.js.map +1 -1
  30. package/dist/views/Account/index.d.ts.map +1 -1
  31. package/dist/views/Account/index.js +5 -1
  32. package/dist/views/Account/index.js.map +1 -1
  33. package/dist/views/BrowseByFolder/buildView.d.ts.map +1 -1
  34. package/dist/views/BrowseByFolder/buildView.js +1 -2
  35. package/dist/views/BrowseByFolder/buildView.js.map +1 -1
  36. package/dist/views/CollectionFolders/buildView.d.ts.map +1 -1
  37. package/dist/views/CollectionFolders/buildView.js +1 -2
  38. package/dist/views/CollectionFolders/buildView.js.map +1 -1
  39. package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
  40. package/dist/views/CreateFirstUser/index.client.js +4 -6
  41. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  42. package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.d.ts +19 -0
  43. package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.d.ts.map +1 -0
  44. package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js +147 -0
  45. package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js.map +1 -0
  46. package/dist/views/Dashboard/Default/ModularDashboard/index.client.d.ts +21 -0
  47. package/dist/views/Dashboard/Default/ModularDashboard/index.client.d.ts.map +1 -0
  48. package/dist/views/Dashboard/Default/ModularDashboard/index.client.js +431 -0
  49. package/dist/views/Dashboard/Default/ModularDashboard/index.client.js.map +1 -0
  50. package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts +5 -0
  51. package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -0
  52. package/dist/views/Dashboard/Default/ModularDashboard/index.js +87 -0
  53. package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -0
  54. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.d.ts +14 -0
  55. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.d.ts.map +1 -0
  56. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js +99 -0
  57. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js.map +1 -0
  58. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts +12 -0
  59. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -0
  60. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +58 -0
  61. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -0
  62. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts +20 -0
  63. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -0
  64. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +72 -0
  65. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -0
  66. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.d.ts +20 -0
  67. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.d.ts.map +1 -0
  68. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js +158 -0
  69. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js.map +1 -0
  70. package/dist/views/Dashboard/Default/ModularDashboard/utils/collisionDetection.d.ts +7 -0
  71. package/dist/views/Dashboard/Default/ModularDashboard/utils/collisionDetection.d.ts.map +1 -0
  72. package/dist/views/Dashboard/Default/ModularDashboard/utils/collisionDetection.js +38 -0
  73. package/dist/views/Dashboard/Default/ModularDashboard/utils/collisionDetection.js.map +1 -0
  74. package/dist/views/Dashboard/Default/ModularDashboard/utils/sensors.d.ts +2 -0
  75. package/dist/views/Dashboard/Default/ModularDashboard/utils/sensors.d.ts.map +1 -0
  76. package/dist/views/Dashboard/Default/ModularDashboard/utils/sensors.js +264 -0
  77. package/dist/views/Dashboard/Default/ModularDashboard/utils/sensors.js.map +1 -0
  78. package/dist/views/Dashboard/Default/index.d.ts +0 -1
  79. package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
  80. package/dist/views/Dashboard/Default/index.js +35 -149
  81. package/dist/views/Dashboard/Default/index.js.map +1 -1
  82. package/dist/views/Dashboard/index.d.ts.map +1 -1
  83. package/dist/views/Dashboard/index.js +3 -52
  84. package/dist/views/Dashboard/index.js.map +1 -1
  85. package/dist/views/Document/getVersions.d.ts.map +1 -1
  86. package/dist/views/Document/getVersions.js +2 -1
  87. package/dist/views/Document/getVersions.js.map +1 -1
  88. package/dist/views/Document/index.d.ts.map +1 -1
  89. package/dist/views/Document/index.js +5 -8
  90. package/dist/views/Document/index.js.map +1 -1
  91. package/dist/views/ForgotPassword/index.d.ts.map +1 -1
  92. package/dist/views/ForgotPassword/index.js +3 -6
  93. package/dist/views/ForgotPassword/index.js.map +1 -1
  94. package/dist/views/List/index.d.ts.map +1 -1
  95. package/dist/views/List/index.js +1 -2
  96. package/dist/views/List/index.js.map +1 -1
  97. package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
  98. package/dist/views/Login/LoginForm/index.js +18 -22
  99. package/dist/views/Login/LoginForm/index.js.map +1 -1
  100. package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
  101. package/dist/views/Logout/LogoutClient.js +36 -40
  102. package/dist/views/Logout/LogoutClient.js.map +1 -1
  103. package/dist/views/NotFound/index.d.ts.map +1 -1
  104. package/dist/views/NotFound/index.js +3 -3
  105. package/dist/views/NotFound/index.js.map +1 -1
  106. package/dist/views/ResetPassword/ResetPasswordForm/index.d.ts.map +1 -1
  107. package/dist/views/ResetPassword/ResetPasswordForm/index.js +17 -22
  108. package/dist/views/ResetPassword/ResetPasswordForm/index.js.map +1 -1
  109. package/dist/views/ResetPassword/index.d.ts.map +1 -1
  110. package/dist/views/ResetPassword/index.js +2 -4
  111. package/dist/views/ResetPassword/index.js.map +1 -1
  112. package/dist/views/Root/getRouteData.d.ts.map +1 -1
  113. package/dist/views/Root/getRouteData.js +1 -2
  114. package/dist/views/Root/getRouteData.js.map +1 -1
  115. package/dist/views/Root/index.d.ts.map +1 -1
  116. package/dist/views/Root/index.js +7 -8
  117. package/dist/views/Root/index.js.map +1 -1
  118. package/dist/views/Root/isPathMatchingRoute.d.ts.map +1 -1
  119. package/dist/views/Root/isPathMatchingRoute.js.map +1 -1
  120. package/dist/views/Unauthorized/index.d.ts.map +1 -1
  121. package/dist/views/Unauthorized/index.js +2 -4
  122. package/dist/views/Unauthorized/index.js.map +1 -1
  123. package/dist/views/Verify/index.js +1 -2
  124. package/dist/views/Verify/index.js.map +1 -1
  125. package/dist/views/Version/Default/SetStepNav.d.ts.map +1 -1
  126. package/dist/views/Version/Default/SetStepNav.js +7 -14
  127. package/dist/views/Version/Default/SetStepNav.js.map +1 -1
  128. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js +1 -0
  129. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js.map +1 -1
  130. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js +1 -0
  131. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js.map +1 -1
  132. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +1 -0
  133. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +1 -1
  134. package/dist/views/Version/Restore/index.js +7 -6
  135. package/dist/views/Version/Restore/index.js.map +1 -1
  136. package/dist/views/Versions/cells/CreatedAt/index.d.ts.map +1 -1
  137. package/dist/views/Versions/cells/CreatedAt/index.js +3 -6
  138. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  139. package/dist/views/Versions/index.d.ts.map +1 -1
  140. package/dist/views/Versions/index.js +3 -4
  141. package/dist/views/Versions/index.js.map +1 -1
  142. package/package.json +10 -8
  143. package/dist/utilities/getVisibleEntities.d.ts +0 -5
  144. package/dist/utilities/getVisibleEntities.d.ts.map +0 -1
  145. package/dist/utilities/getVisibleEntities.js +0 -26
  146. package/dist/utilities/getVisibleEntities.js.map +0 -1
@@ -0,0 +1,264 @@
1
+ import { KeyboardCode, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
2
+ /**
3
+ * Get all droppable widget positions, filtering out overlapping "before" droppables
4
+ * and assigning row numbers based on Y position.
5
+ */
6
+ function getDroppablePositions() {
7
+ const positionTolerance = 5;
8
+ const rowTolerance = 10;
9
+ const result = [];
10
+ let currentRow = 0;
11
+ let currentY = null;
12
+ const allDroppables = Array.from(document.querySelectorAll('.droppable-widget'));
13
+ for (let i = 0; i < allDroppables.length; i++) {
14
+ const element = allDroppables[i];
15
+ const rect = element.getBoundingClientRect();
16
+ // Skip hidden elements
17
+ if (rect.width === 0 || rect.height === 0) {
18
+ continue;
19
+ }
20
+ const centerX = rect.left + rect.width / 2;
21
+ const centerY = rect.top + rect.height / 2;
22
+ const testId = element.getAttribute('data-testid') || '';
23
+ const isBeforeDroppable = testId.endsWith('-before');
24
+ // Skip "before" droppables that overlap with another droppable
25
+ if (isBeforeDroppable) {
26
+ const hasOverlapping = allDroppables.some((other, otherIndex) => {
27
+ if (otherIndex === i) {
28
+ return false;
29
+ }
30
+ const otherRect = other.getBoundingClientRect();
31
+ const otherCenterX = otherRect.left + otherRect.width / 2;
32
+ const otherCenterY = otherRect.top + otherRect.height / 2;
33
+ return Math.abs(otherCenterX - centerX) < positionTolerance && Math.abs(otherCenterY - centerY) < positionTolerance;
34
+ });
35
+ if (hasOverlapping) {
36
+ continue;
37
+ }
38
+ }
39
+ // Assign row number based on Y position change
40
+ if (currentY === null) {
41
+ currentY = centerY;
42
+ } else if (Math.abs(centerY - currentY) >= rowTolerance) {
43
+ currentRow++;
44
+ currentY = centerY;
45
+ }
46
+ result.push({
47
+ centerX,
48
+ centerY,
49
+ element,
50
+ isBeforeDroppable,
51
+ rect,
52
+ row: currentRow
53
+ });
54
+ }
55
+ return result;
56
+ }
57
+ /**
58
+ * Find the row with the closest Y position to the given posY.
59
+ * Returns the row index, or null if no droppables exist.
60
+ */
61
+ function findClosestRow(droppables, posY) {
62
+ if (droppables.length === 0) {
63
+ return null;
64
+ }
65
+ let closestRow = droppables[0].row;
66
+ let minYDistance = Infinity;
67
+ for (const droppable of droppables) {
68
+ const yDistance = Math.abs(droppable.centerY - posY);
69
+ if (yDistance < minYDistance) {
70
+ minYDistance = yDistance;
71
+ closestRow = droppable.row;
72
+ }
73
+ }
74
+ return closestRow;
75
+ }
76
+ /**
77
+ * Find the closest droppable within a specific row by X position.
78
+ * Returns the droppable and its index, or null if no droppables in that row.
79
+ */
80
+ function findClosestDroppableInRow(droppables, rowIndex, posX) {
81
+ let closestIndex = -1;
82
+ let minXDistance = Infinity;
83
+ for (let i = 0; i < droppables.length; i++) {
84
+ const droppable = droppables[i];
85
+ if (droppable.row === rowIndex) {
86
+ const xDistance = Math.abs(droppable.centerX - posX);
87
+ if (xDistance < minXDistance) {
88
+ minXDistance = xDistance;
89
+ closestIndex = i;
90
+ }
91
+ }
92
+ }
93
+ if (closestIndex === -1) {
94
+ return null;
95
+ }
96
+ return {
97
+ droppable: droppables[closestIndex],
98
+ index: closestIndex
99
+ };
100
+ }
101
+ /**
102
+ * Find the target droppable based on direction
103
+ * - ArrowRight/Left: Next/previous in DOM order (now that overlapping droppables are filtered)
104
+ * - ArrowUp/Down: Closest in adjacent row (row +1 or -1) by X position
105
+ */
106
+ function findTargetDroppable(droppables, currentCenterX, currentCenterY, direction) {
107
+ // Find the closest row, then the closest droppable in that row
108
+ const currentRow = findClosestRow(droppables, currentCenterY);
109
+ if (currentRow === null) {
110
+ return null;
111
+ }
112
+ const currentDroppable = findClosestDroppableInRow(droppables, currentRow, currentCenterX);
113
+ if (!currentDroppable) {
114
+ return null;
115
+ }
116
+ const {
117
+ index: currentIndex
118
+ } = currentDroppable;
119
+ switch (direction) {
120
+ case 'ArrowDown':
121
+ {
122
+ const targetRow = currentRow + 1;
123
+ return findClosestDroppableInRow(droppables, targetRow, currentCenterX)?.droppable || null;
124
+ }
125
+ case 'ArrowLeft':
126
+ // Previous in DOM order
127
+ return droppables[currentIndex - 1] || null;
128
+ case 'ArrowRight':
129
+ // Next in DOM order
130
+ return droppables[currentIndex + 1] || null;
131
+ case 'ArrowUp':
132
+ {
133
+ const targetRow = currentRow - 1;
134
+ return findClosestDroppableInRow(droppables, targetRow, currentCenterX)?.droppable || null;
135
+ }
136
+ default:
137
+ return null;
138
+ }
139
+ }
140
+ /**
141
+ * Custom coordinate getter that jumps directly to droppable positions
142
+ * instead of moving in pixel increments. This works better with scrolling
143
+ * and provides more predictable navigation.
144
+ */
145
+ const droppableJumpKeyboardCoordinateGetter = (event, {
146
+ context,
147
+ currentCoordinates
148
+ }) => {
149
+ const {
150
+ collisionRect
151
+ } = context;
152
+ const {
153
+ code
154
+ } = event;
155
+ if (!collisionRect) {
156
+ return currentCoordinates;
157
+ }
158
+ // Only handle arrow keys
159
+ if (!['ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp'].includes(code)) {
160
+ return currentCoordinates;
161
+ }
162
+ // Prevent default browser scroll behavior for arrow keys
163
+ event.preventDefault();
164
+ // Clear scrollableAncestors to prevent dnd-kit from scrolling instead of moving
165
+ // This must be done on every keydown because context is updated by dnd-kit
166
+ if (context.scrollableAncestors) {
167
+ context.scrollableAncestors.length = 0;
168
+ }
169
+ // Get all droppable widgets and their positions
170
+ const droppables = getDroppablePositions();
171
+ if (droppables.length === 0) {
172
+ return currentCoordinates;
173
+ }
174
+ // Current position center (viewport coordinates from collisionRect)
175
+ const currentCenterX = collisionRect.left + collisionRect.width / 2;
176
+ const currentCenterY = collisionRect.top + collisionRect.height / 2;
177
+ // Find the target droppable based on direction
178
+ const targetDroppable = findTargetDroppable(droppables, currentCenterX, currentCenterY, code);
179
+ // If we found a target, scroll if needed and calculate the delta
180
+ if (targetDroppable) {
181
+ const viewportHeight = window.innerHeight;
182
+ const targetRect = targetDroppable.rect;
183
+ const scrollPadding = 20 // Extra padding to ensure element is fully visible
184
+ ;
185
+ // Check if target droppable is fully visible in viewport
186
+ const isAboveViewport = targetRect.top < scrollPadding;
187
+ const isBelowViewport = targetRect.bottom > viewportHeight - scrollPadding;
188
+ // Scroll to make target visible (using instant scroll for synchronous behavior)
189
+ if (isAboveViewport) {
190
+ const scrollAmount = targetRect.top - scrollPadding;
191
+ // don't use smooth scroll here, because it will mess up the delta calculation
192
+ window.scrollBy({
193
+ behavior: 'instant',
194
+ top: scrollAmount
195
+ });
196
+ } else if (isBelowViewport) {
197
+ const scrollAmount = targetRect.bottom - viewportHeight + scrollPadding;
198
+ window.scrollBy({
199
+ behavior: 'instant',
200
+ top: scrollAmount
201
+ });
202
+ }
203
+ // After scroll, recalculate target position (it may have changed due to scroll)
204
+ const newTargetRect = targetDroppable.element.getBoundingClientRect();
205
+ const newTargetCenterX = newTargetRect.left + newTargetRect.width / 2;
206
+ const newTargetCenterY = newTargetRect.top + newTargetRect.height / 2;
207
+ // Calculate delta using current overlay position (which didn't change) and new target position
208
+ const deltaX = newTargetCenterX - currentCenterX;
209
+ const deltaY = newTargetCenterY - currentCenterY;
210
+ // Add delta to currentCoordinates to position overlay's center at target's center
211
+ return {
212
+ x: currentCoordinates.x + deltaX,
213
+ y: currentCoordinates.y + deltaY
214
+ };
215
+ }
216
+ // No valid target found, stay in place
217
+ return currentCoordinates;
218
+ };
219
+ /**
220
+ * Custom KeyboardSensor that only activates when focus is directly on the
221
+ * draggable element, not on any of its descendants. This allows interactive
222
+ * elements inside draggables (like buttons) to work normally with the keyboard.
223
+ */
224
+ class DirectFocusKeyboardSensor extends KeyboardSensor {
225
+ static activators = [{
226
+ eventName: 'onKeyDown',
227
+ handler: (event, {
228
+ keyboardCodes = {
229
+ cancel: [KeyboardCode.Esc],
230
+ end: [KeyboardCode.Space, KeyboardCode.Enter],
231
+ start: [KeyboardCode.Space, KeyboardCode.Enter]
232
+ },
233
+ onActivation
234
+ }, {
235
+ active
236
+ }) => {
237
+ const {
238
+ code
239
+ } = event.nativeEvent;
240
+ // Only activate if focus is directly on the draggable node, not descendants
241
+ if (event.target !== active.node.current) {
242
+ return false;
243
+ }
244
+ if (keyboardCodes.start.includes(code)) {
245
+ event.preventDefault();
246
+ onActivation?.({
247
+ event: event.nativeEvent
248
+ });
249
+ return true;
250
+ }
251
+ return false;
252
+ }
253
+ }];
254
+ }
255
+ export function useDashboardSensors() {
256
+ return useSensors(useSensor(PointerSensor, {
257
+ activationConstraint: {
258
+ distance: 5
259
+ }
260
+ }), useSensor(DirectFocusKeyboardSensor, {
261
+ coordinateGetter: droppableJumpKeyboardCoordinateGetter
262
+ }));
263
+ }
264
+ //# sourceMappingURL=sensors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sensors.js","names":["KeyboardCode","KeyboardSensor","PointerSensor","useSensor","useSensors","getDroppablePositions","positionTolerance","rowTolerance","result","currentRow","currentY","allDroppables","Array","from","document","querySelectorAll","i","length","element","rect","getBoundingClientRect","width","height","centerX","left","centerY","top","testId","getAttribute","isBeforeDroppable","endsWith","hasOverlapping","some","other","otherIndex","otherRect","otherCenterX","otherCenterY","Math","abs","push","row","findClosestRow","droppables","posY","closestRow","minYDistance","Infinity","droppable","yDistance","findClosestDroppableInRow","rowIndex","posX","closestIndex","minXDistance","xDistance","index","findTargetDroppable","currentCenterX","currentCenterY","direction","currentDroppable","currentIndex","targetRow","droppableJumpKeyboardCoordinateGetter","event","context","currentCoordinates","collisionRect","code","includes","preventDefault","scrollableAncestors","targetDroppable","viewportHeight","window","innerHeight","targetRect","scrollPadding","isAboveViewport","isBelowViewport","bottom","scrollAmount","scrollBy","behavior","newTargetRect","newTargetCenterX","newTargetCenterY","deltaX","deltaY","x","y","DirectFocusKeyboardSensor","activators","eventName","handler","keyboardCodes","cancel","Esc","end","Space","Enter","start","onActivation","active","nativeEvent","target","node","current","useDashboardSensors","activationConstraint","distance","coordinateGetter"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/utils/sensors.ts"],"sourcesContent":["import type { KeyboardCoordinateGetter, KeyboardSensorOptions } from '@dnd-kit/core'\n\nimport { KeyboardCode, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core'\n\ntype DroppablePosition = {\n centerX: number\n centerY: number\n element: Element\n isBeforeDroppable: boolean\n rect: DOMRect\n row: number\n}\n\n/**\n * Get all droppable widget positions, filtering out overlapping \"before\" droppables\n * and assigning row numbers based on Y position.\n */\nfunction getDroppablePositions(): DroppablePosition[] {\n const positionTolerance = 5\n const rowTolerance = 10\n const result: DroppablePosition[] = []\n let currentRow = 0\n let currentY: null | number = null\n\n const allDroppables = Array.from(document.querySelectorAll('.droppable-widget'))\n\n for (let i = 0; i < allDroppables.length; i++) {\n const element = allDroppables[i]\n const rect = element.getBoundingClientRect()\n\n // Skip hidden elements\n if (rect.width === 0 || rect.height === 0) {\n continue\n }\n\n const centerX = rect.left + rect.width / 2\n const centerY = rect.top + rect.height / 2\n const testId = element.getAttribute('data-testid') || ''\n const isBeforeDroppable = testId.endsWith('-before')\n\n // Skip \"before\" droppables that overlap with another droppable\n if (isBeforeDroppable) {\n const hasOverlapping = allDroppables.some((other, otherIndex) => {\n if (otherIndex === i) {\n return false\n }\n const otherRect = other.getBoundingClientRect()\n const otherCenterX = otherRect.left + otherRect.width / 2\n const otherCenterY = otherRect.top + otherRect.height / 2\n return (\n Math.abs(otherCenterX - centerX) < positionTolerance &&\n Math.abs(otherCenterY - centerY) < positionTolerance\n )\n })\n if (hasOverlapping) {\n continue\n }\n }\n\n // Assign row number based on Y position change\n if (currentY === null) {\n currentY = centerY\n } else if (Math.abs(centerY - currentY) >= rowTolerance) {\n currentRow++\n currentY = centerY\n }\n\n result.push({\n centerX,\n centerY,\n element,\n isBeforeDroppable,\n rect,\n row: currentRow,\n })\n }\n\n return result\n}\n\n/**\n * Find the row with the closest Y position to the given posY.\n * Returns the row index, or null if no droppables exist.\n */\nfunction findClosestRow(droppables: DroppablePosition[], posY: number): null | number {\n if (droppables.length === 0) {\n return null\n }\n\n let closestRow = droppables[0].row\n let minYDistance = Infinity\n\n for (const droppable of droppables) {\n const yDistance = Math.abs(droppable.centerY - posY)\n if (yDistance < minYDistance) {\n minYDistance = yDistance\n closestRow = droppable.row\n }\n }\n\n return closestRow\n}\n\n/**\n * Find the closest droppable within a specific row by X position.\n * Returns the droppable and its index, or null if no droppables in that row.\n */\nfunction findClosestDroppableInRow(\n droppables: DroppablePosition[],\n rowIndex: number,\n posX: number,\n): { droppable: DroppablePosition; index: number } | null {\n let closestIndex = -1\n let minXDistance = Infinity\n\n for (let i = 0; i < droppables.length; i++) {\n const droppable = droppables[i]\n if (droppable.row === rowIndex) {\n const xDistance = Math.abs(droppable.centerX - posX)\n if (xDistance < minXDistance) {\n minXDistance = xDistance\n closestIndex = i\n }\n }\n }\n\n if (closestIndex === -1) {\n return null\n }\n\n return { droppable: droppables[closestIndex], index: closestIndex }\n}\n\n/**\n * Find the target droppable based on direction\n * - ArrowRight/Left: Next/previous in DOM order (now that overlapping droppables are filtered)\n * - ArrowUp/Down: Closest in adjacent row (row +1 or -1) by X position\n */\nfunction findTargetDroppable(\n droppables: DroppablePosition[],\n currentCenterX: number,\n currentCenterY: number,\n direction: string,\n): DroppablePosition | null {\n // Find the closest row, then the closest droppable in that row\n const currentRow = findClosestRow(droppables, currentCenterY)\n\n if (currentRow === null) {\n return null\n }\n\n const currentDroppable = findClosestDroppableInRow(droppables, currentRow, currentCenterX)\n\n if (!currentDroppable) {\n return null\n }\n\n const { index: currentIndex } = currentDroppable\n\n switch (direction) {\n case 'ArrowDown': {\n const targetRow = currentRow + 1\n return findClosestDroppableInRow(droppables, targetRow, currentCenterX)?.droppable || null\n }\n\n case 'ArrowLeft':\n // Previous in DOM order\n return droppables[currentIndex - 1] || null\n\n case 'ArrowRight':\n // Next in DOM order\n return droppables[currentIndex + 1] || null\n\n case 'ArrowUp': {\n const targetRow = currentRow - 1\n return findClosestDroppableInRow(droppables, targetRow, currentCenterX)?.droppable || null\n }\n\n default:\n return null\n }\n}\n\n/**\n * Custom coordinate getter that jumps directly to droppable positions\n * instead of moving in pixel increments. This works better with scrolling\n * and provides more predictable navigation.\n */\nconst droppableJumpKeyboardCoordinateGetter: KeyboardCoordinateGetter = (\n event,\n { context, currentCoordinates },\n) => {\n const { collisionRect } = context\n const { code } = event\n\n if (!collisionRect) {\n return currentCoordinates\n }\n\n // Only handle arrow keys\n if (!['ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp'].includes(code)) {\n return currentCoordinates\n }\n\n // Prevent default browser scroll behavior for arrow keys\n event.preventDefault()\n\n // Clear scrollableAncestors to prevent dnd-kit from scrolling instead of moving\n // This must be done on every keydown because context is updated by dnd-kit\n if (context.scrollableAncestors) {\n context.scrollableAncestors.length = 0\n }\n\n // Get all droppable widgets and their positions\n const droppables = getDroppablePositions()\n\n if (droppables.length === 0) {\n return currentCoordinates\n }\n\n // Current position center (viewport coordinates from collisionRect)\n const currentCenterX = collisionRect.left + collisionRect.width / 2\n const currentCenterY = collisionRect.top + collisionRect.height / 2\n\n // Find the target droppable based on direction\n const targetDroppable = findTargetDroppable(droppables, currentCenterX, currentCenterY, code)\n\n // If we found a target, scroll if needed and calculate the delta\n if (targetDroppable) {\n const viewportHeight = window.innerHeight\n const targetRect = targetDroppable.rect\n const scrollPadding = 20 // Extra padding to ensure element is fully visible\n\n // Check if target droppable is fully visible in viewport\n const isAboveViewport = targetRect.top < scrollPadding\n const isBelowViewport = targetRect.bottom > viewportHeight - scrollPadding\n\n // Scroll to make target visible (using instant scroll for synchronous behavior)\n if (isAboveViewport) {\n const scrollAmount = targetRect.top - scrollPadding\n // don't use smooth scroll here, because it will mess up the delta calculation\n window.scrollBy({ behavior: 'instant', top: scrollAmount })\n } else if (isBelowViewport) {\n const scrollAmount = targetRect.bottom - viewportHeight + scrollPadding\n window.scrollBy({ behavior: 'instant', top: scrollAmount })\n }\n\n // After scroll, recalculate target position (it may have changed due to scroll)\n const newTargetRect = targetDroppable.element.getBoundingClientRect()\n const newTargetCenterX = newTargetRect.left + newTargetRect.width / 2\n const newTargetCenterY = newTargetRect.top + newTargetRect.height / 2\n\n // Calculate delta using current overlay position (which didn't change) and new target position\n const deltaX = newTargetCenterX - currentCenterX\n const deltaY = newTargetCenterY - currentCenterY\n\n // Add delta to currentCoordinates to position overlay's center at target's center\n return {\n x: currentCoordinates.x + deltaX,\n y: currentCoordinates.y + deltaY,\n }\n }\n\n // No valid target found, stay in place\n return currentCoordinates\n}\n\n/**\n * Custom KeyboardSensor that only activates when focus is directly on the\n * draggable element, not on any of its descendants. This allows interactive\n * elements inside draggables (like buttons) to work normally with the keyboard.\n */\nclass DirectFocusKeyboardSensor extends KeyboardSensor {\n static override activators = [\n {\n eventName: 'onKeyDown' as const,\n handler: (\n event: React.KeyboardEvent,\n {\n keyboardCodes = {\n cancel: [KeyboardCode.Esc],\n end: [KeyboardCode.Space, KeyboardCode.Enter],\n start: [KeyboardCode.Space, KeyboardCode.Enter],\n },\n onActivation,\n }: KeyboardSensorOptions,\n { active }: { active: { node: React.MutableRefObject<HTMLElement | null> } },\n ) => {\n const { code } = event.nativeEvent\n\n // Only activate if focus is directly on the draggable node, not descendants\n if (event.target !== active.node.current) {\n return false\n }\n\n if (keyboardCodes.start.includes(code)) {\n event.preventDefault()\n onActivation?.({ event: event.nativeEvent })\n return true\n }\n\n return false\n },\n },\n ]\n}\n\nexport function useDashboardSensors() {\n return useSensors(\n useSensor(PointerSensor, {\n activationConstraint: {\n distance: 5,\n },\n }),\n useSensor(DirectFocusKeyboardSensor, {\n coordinateGetter: droppableJumpKeyboardCoordinateGetter,\n }),\n )\n}\n"],"mappings":"AAEA,SAASA,YAAY,EAAEC,cAAc,EAAEC,aAAa,EAAEC,SAAS,EAAEC,UAAU,QAAQ;AAWnF;;;;AAIA,SAASC,sBAAA;EACP,MAAMC,iBAAA,GAAoB;EAC1B,MAAMC,YAAA,GAAe;EACrB,MAAMC,MAAA,GAA8B,EAAE;EACtC,IAAIC,UAAA,GAAa;EACjB,IAAIC,QAAA,GAA0B;EAE9B,MAAMC,aAAA,GA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MAAA,CAAOG,IAAI,CAACC,OAAO,EAAE;QACxC,OAAO;MACT;MAEA,IAAIZ,aAAA,CAAcM,KAAK,CAAChC,QAAQ,CAACD,IAAA,GAAO;QACtCJ,KAAA,CAAMM,cAAc;QACpBgC,YAAA,GAAe;UAAEtC,KAAA,EAAOA,KAAA,CAAMwC;QAAY;QAC1C,OAAO;MACT;MAEA,OAAO;IACT;EACF,EACD;AACH;AAEA,OAAO,SAASI,oBAAA;EACd,OAAOzG,UAAA,CACLD,SAAA,CAAUD,aAAA,EAAe;IACvB4G,oBAAA,EAAsB;MACpBC,QAAA,EAAU;IACZ;EACF,IACA5G,SAAA,CAAUyF,yBAAA,EAA2B;IACnCoB,gBAAA,EAAkBhD;EACpB;AAEJ","ignoreList":[]}
@@ -1,7 +1,6 @@
1
1
  import type { groupNavItems } from '@payloadcms/ui/shared';
2
2
  import type { AdminViewServerPropsOnly, ClientUser, Locale } from 'payload';
3
3
  import React from 'react';
4
- import './index.scss';
5
4
  export type DashboardViewClientProps = {
6
5
  locale: Locale;
7
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Dashboard/Default/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,EAAe,MAAM,SAAS,CAAA;AAOxF,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,cAAc,CAAA;AAIrB,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE;YAAE,SAAS,EAAE,OAAO,CAAC;YAAC,aAAa,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;SAAE,CAA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AK,EAAE,wBAAwB,qBAqC/D"}
@@ -1,166 +1,52 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getTranslation } from '@payloadcms/translations';
3
- import { Button, Card, Gutter, Locked } from '@payloadcms/ui';
2
+ import { Gutter } from '@payloadcms/ui';
4
3
  import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
5
- import { EntityType } from '@payloadcms/ui/shared';
6
- import { formatAdminURL } from 'payload/shared';
7
- import React, { Fragment } from 'react';
4
+ import React from 'react';
5
+ import { ModularDashboard } from './ModularDashboard/index.js';
8
6
  const baseClass = 'dashboard';
9
7
  export function DefaultDashboard(props) {
10
8
  const {
11
- globalData,
12
9
  i18n,
13
- i18n: {
14
- t
15
- },
16
10
  locale,
17
- navGroups,
18
11
  params,
19
- payload: {
20
- config: {
21
- admin: {
22
- components: {
23
- afterDashboard,
24
- beforeDashboard
25
- }
26
- },
27
- routes: {
28
- admin: adminRoute
29
- },
30
- serverURL
31
- }
32
- },
33
12
  payload,
34
13
  permissions,
35
14
  searchParams,
36
15
  user
37
16
  } = props;
38
- return /*#__PURE__*/_jsx("div", {
17
+ const {
18
+ afterDashboard,
19
+ beforeDashboard
20
+ } = payload.config.admin.components;
21
+ return /*#__PURE__*/_jsxs(Gutter, {
39
22
  className: baseClass,
40
- children: /*#__PURE__*/_jsxs(Gutter, {
41
- className: `${baseClass}__wrap`,
42
- children: [beforeDashboard && RenderServerComponent({
43
- Component: beforeDashboard,
44
- importMap: payload.importMap,
45
- serverProps: {
46
- i18n,
47
- locale,
48
- params,
49
- payload,
50
- permissions,
51
- searchParams,
52
- user
53
- }
54
- }), /*#__PURE__*/_jsx(Fragment, {
55
- children: !navGroups || navGroups?.length === 0 ? /*#__PURE__*/_jsx("p", {
56
- children: "no nav groups...."
57
- }) : navGroups.map(({
58
- entities,
59
- label
60
- }, groupIndex) => {
61
- return /*#__PURE__*/_jsxs("div", {
62
- className: `${baseClass}__group`,
63
- children: [/*#__PURE__*/_jsx("h2", {
64
- className: `${baseClass}__label`,
65
- children: label
66
- }), /*#__PURE__*/_jsx("ul", {
67
- className: `${baseClass}__card-list`,
68
- children: entities.map(({
69
- slug,
70
- type,
71
- label
72
- }, entityIndex) => {
73
- let title;
74
- let buttonAriaLabel;
75
- let createHREF;
76
- let href;
77
- let hasCreatePermission;
78
- let isLocked = null;
79
- let userEditing = null;
80
- if (type === EntityType.collection) {
81
- title = getTranslation(label, i18n);
82
- buttonAriaLabel = t('general:showAllLabel', {
83
- label: title
84
- });
85
- href = formatAdminURL({
86
- adminRoute,
87
- path: `/collections/${slug}`,
88
- serverURL
89
- });
90
- createHREF = formatAdminURL({
91
- adminRoute,
92
- path: `/collections/${slug}/create`,
93
- serverURL
94
- });
95
- hasCreatePermission = permissions?.collections?.[slug]?.create;
96
- }
97
- if (type === EntityType.global) {
98
- title = getTranslation(label, i18n);
99
- buttonAriaLabel = t('general:editLabel', {
100
- label: getTranslation(label, i18n)
101
- });
102
- href = formatAdminURL({
103
- adminRoute,
104
- path: `/globals/${slug}`,
105
- serverURL
106
- });
107
- // Find the lock status for the global
108
- const globalLockData = globalData.find(global => global.slug === slug);
109
- if (globalLockData) {
110
- isLocked = globalLockData.data._isLocked;
111
- userEditing = globalLockData.data._userEditing;
112
- // Check if the lock is expired
113
- const lockDuration = globalLockData?.lockDuration;
114
- const lastEditedAt = new Date(globalLockData.data?._lastEditedAt).getTime();
115
- const lockDurationInMilliseconds = lockDuration * 1000;
116
- const lockExpirationTime = lastEditedAt + lockDurationInMilliseconds;
117
- if (new Date().getTime() > lockExpirationTime) {
118
- isLocked = false;
119
- userEditing = null;
120
- }
121
- }
122
- }
123
- return /*#__PURE__*/_jsx("li", {
124
- children: /*#__PURE__*/_jsx(Card, {
125
- actions: isLocked && user?.id !== userEditing?.id ? /*#__PURE__*/_jsx(Locked, {
126
- className: `${baseClass}__locked`,
127
- user: userEditing
128
- }) : hasCreatePermission && type === EntityType.collection ? /*#__PURE__*/_jsx(Button, {
129
- "aria-label": t('general:createNewLabel', {
130
- label
131
- }),
132
- buttonStyle: "icon-label",
133
- el: "link",
134
- icon: "plus",
135
- iconStyle: "with-border",
136
- round: true,
137
- to: createHREF
138
- }) : undefined,
139
- buttonAriaLabel: buttonAriaLabel,
140
- href: href,
141
- id: `card-${slug}`,
142
- title: getTranslation(label, i18n),
143
- titleAs: "h3"
144
- })
145
- }, entityIndex);
146
- })
147
- })]
148
- }, groupIndex);
149
- })
150
- }), afterDashboard && RenderServerComponent({
151
- Component: afterDashboard,
152
- importMap: payload.importMap,
153
- serverProps: {
154
- i18n,
155
- locale,
156
- params,
157
- payload,
158
- permissions,
159
- searchParams,
160
- user
161
- }
162
- })]
163
- })
23
+ children: [beforeDashboard && RenderServerComponent({
24
+ Component: beforeDashboard,
25
+ importMap: payload.importMap,
26
+ serverProps: {
27
+ i18n,
28
+ locale,
29
+ params,
30
+ payload,
31
+ permissions,
32
+ searchParams,
33
+ user
34
+ }
35
+ }), /*#__PURE__*/_jsx(ModularDashboard, {
36
+ ...props
37
+ }), afterDashboard && RenderServerComponent({
38
+ Component: afterDashboard,
39
+ importMap: payload.importMap,
40
+ serverProps: {
41
+ i18n,
42
+ locale,
43
+ params,
44
+ payload,
45
+ permissions,
46
+ searchParams,
47
+ user
48
+ }
49
+ })]
164
50
  });
165
51
  }
166
52
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getTranslation","Button","Card","Gutter","Locked","RenderServerComponent","EntityType","formatAdminURL","React","Fragment","baseClass","DefaultDashboard","props","globalData","i18n","t","locale","navGroups","params","payload","config","admin","components","afterDashboard","beforeDashboard","routes","adminRoute","serverURL","permissions","searchParams","user","_jsx","className","_jsxs","Component","importMap","serverProps","length","map","entities","label","groupIndex","slug","type","entityIndex","title","buttonAriaLabel","createHREF","href","hasCreatePermission","isLocked","userEditing","collection","path","collections","create","global","globalLockData","find","data","_isLocked","_userEditing","lockDuration","lastEditedAt","Date","_lastEditedAt","getTime","lockDurationInMilliseconds","lockExpirationTime","actions","id","buttonStyle","el","icon","iconStyle","round","to","undefined","titleAs"],"sources":["../../../../src/views/Dashboard/Default/index.tsx"],"sourcesContent":["import type { groupNavItems } from '@payloadcms/ui/shared'\nimport type { AdminViewServerPropsOnly, ClientUser, Locale, ServerProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, Card, Gutter, Locked } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { EntityType } from '@payloadcms/ui/shared'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'dashboard'\n\nexport type DashboardViewClientProps = {\n locale: Locale\n}\n\nexport type DashboardViewServerPropsOnly = {\n globalData: Array<{\n data: { _isLocked: boolean; _lastEditedAt: string; _userEditing: ClientUser | number | string }\n lockDuration?: number\n slug: string\n }>\n /**\n * @deprecated\n * This prop is deprecated and will be removed in the next major version.\n * Components now import their own `Link` directly from `next/link`.\n */\n Link?: React.ComponentType\n navGroups?: ReturnType<typeof groupNavItems>\n} & AdminViewServerPropsOnly\n\nexport type DashboardViewServerProps = DashboardViewClientProps & DashboardViewServerPropsOnly\n\nexport function DefaultDashboard(props: DashboardViewServerProps) {\n const {\n globalData,\n i18n,\n i18n: { t },\n locale,\n navGroups,\n params,\n payload: {\n config: {\n admin: {\n components: { afterDashboard, beforeDashboard },\n },\n routes: { admin: adminRoute },\n serverURL,\n },\n },\n payload,\n permissions,\n searchParams,\n user,\n } = props\n\n return (\n <div className={baseClass}>\n <Gutter className={`${baseClass}__wrap`}>\n {beforeDashboard &&\n RenderServerComponent({\n Component: beforeDashboard,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n\n <Fragment>\n {!navGroups || navGroups?.length === 0 ? (\n <p>no nav groups....</p>\n ) : (\n navGroups.map(({ entities, label }, groupIndex) => {\n return (\n <div className={`${baseClass}__group`} key={groupIndex}>\n <h2 className={`${baseClass}__label`}>{label}</h2>\n <ul className={`${baseClass}__card-list`}>\n {entities.map(({ slug, type, label }, entityIndex) => {\n let title: string\n let buttonAriaLabel: string\n let createHREF: string\n let href: string\n let hasCreatePermission: boolean\n let isLocked = null\n let userEditing = null\n\n if (type === EntityType.collection) {\n title = getTranslation(label, i18n)\n\n buttonAriaLabel = t('general:showAllLabel', { label: title })\n\n href = formatAdminURL({\n adminRoute,\n path: `/collections/${slug}`,\n serverURL,\n })\n\n createHREF = formatAdminURL({\n adminRoute,\n path: `/collections/${slug}/create`,\n serverURL,\n })\n\n hasCreatePermission = permissions?.collections?.[slug]?.create\n }\n\n if (type === EntityType.global) {\n title = getTranslation(label, i18n)\n\n buttonAriaLabel = t('general:editLabel', {\n label: getTranslation(label, i18n),\n })\n\n href = formatAdminURL({\n adminRoute,\n path: `/globals/${slug}`,\n serverURL,\n })\n\n // Find the lock status for the global\n const globalLockData = globalData.find((global) => global.slug === slug)\n if (globalLockData) {\n isLocked = globalLockData.data._isLocked\n userEditing = globalLockData.data._userEditing\n\n // Check if the lock is expired\n const lockDuration = globalLockData?.lockDuration\n const lastEditedAt = new Date(\n globalLockData.data?._lastEditedAt,\n ).getTime()\n\n const lockDurationInMilliseconds = lockDuration * 1000\n const lockExpirationTime = lastEditedAt + lockDurationInMilliseconds\n\n if (new Date().getTime() > lockExpirationTime) {\n isLocked = false\n userEditing = null\n }\n }\n }\n\n return (\n <li key={entityIndex}>\n <Card\n actions={\n isLocked && user?.id !== userEditing?.id ? (\n <Locked className={`${baseClass}__locked`} user={userEditing} />\n ) : hasCreatePermission && type === EntityType.collection ? (\n <Button\n aria-label={t('general:createNewLabel', {\n label,\n })}\n buttonStyle=\"icon-label\"\n el=\"link\"\n icon=\"plus\"\n iconStyle=\"with-border\"\n round\n to={createHREF}\n />\n ) : undefined\n }\n buttonAriaLabel={buttonAriaLabel}\n href={href}\n id={`card-${slug}`}\n title={getTranslation(label, i18n)}\n titleAs=\"h3\"\n />\n </li>\n )\n })}\n </ul>\n </div>\n )\n })\n )}\n </Fragment>\n {afterDashboard &&\n RenderServerComponent({\n Component: afterDashboard,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n </Gutter>\n </div>\n )\n}\n"],"mappings":";AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAEC,MAAM,QAAQ;AAC7C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAIhC,MAAMC,SAAA,GAAY;AAuBlB,OAAO,SAASC,iBAAiBC,KAA+B;EAC9D,MAAM;IACJC,UAAU;IACVC,IAAI;IACJA,IAAA,EAAM;MAAEC;IAAC,CAAE;IACXC,MAAM;IACNC,SAAS;IACTC,MAAM;IACNC,OAAA,EAAS;MACPC,MAAA,EAAQ;QACNC,KAAA,EAAO;UACLC,UAAA,EAAY;YAAEC,cAAc;YAAEC;UAAe;QAAE,CAChD;QACDC,MAAA,EAAQ;UAAEJ,KAAA,EAAOK;QAAU,CAAE;QAC7BC;MAAS;IACV,CACF;IACDR,OAAO;IACPS,WAAW;IACXC,YAAY;IACZC;EAAI,CACL,GAAGlB,KAAA;EAEJ,oBACEmB,IAAA,CAAC;IAAIC,SAAA,EAAWtB,SAAA;cACd,aAAAuB,KAAA,CAAC9B,MAAA;MAAO6B,SAAA,EAAW,GAAGtB,SAAA,QAAiB;iBACpCc,eAAA,IACCnB,qBAAA,CAAsB;QACpB6B,SAAA,EAAWV,eAAA;QACXW,SAAA,EAAWhB,OAAA,CAAQgB,SAAS;QAC5BC,WAAA,EAAa;UACXtB,IAAA;UACAE,MAAA;UACAE,MAAA;UACAC,OAAA;UACAS,WAAA;U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AA,CAAE,0BAA0B;wBACtCyB;sBACF;sBACA+B,WAAA,EAAY;sBACZC,EAAA,EAAG;sBACHC,IAAA,EAAK;sBACLC,SAAA,EAAU;sBACVC,KAAK;sBACLC,EAAA,EAAI7B;yBAEJ8B,SAAA;oBAEN/B,eAAA,EAAiBA,eAAA;oBACjBE,IAAA,EAAMA,IAAA;oBACNsB,EAAA,EAAI,QAAQ5B,IAAA,EAAM;oBAClBG,KAAA,EAAO7C,cAAA,CAAewC,KAAA,EAAO1B,IAAA;oBAC7BgE,OAAA,EAAQ;;mBAvBHlC,WAAA;cA2Bb;;aA/FwCH,UAAA;QAmGhD;UAGHlB,cAAA,IACClB,qBAAA,CAAsB;QACpB6B,SAAA,EAAWX,cAAA;QACXY,SAAA,EAAWhB,OAAA,CAAQgB,SAAS;QAC5BC,WAAA,EAAa;UACXtB,IAAA;UACAE,MAAA;UACAE,MAAA;UACAC,OAAA;UACAS,WAAA;UACAC,YAAA;UACAC;QACF;MACF;;;AAIV","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Gutter","RenderServerComponent","React","ModularDashboard","baseClass","DefaultDashboard","props","i18n","locale","params","payload","permissions","searchParams","user","afterDashboard","beforeDashboard","config","admin","components","_jsxs","className","Component","importMap","serverProps","_jsx"],"sources":["../../../../src/views/Dashboard/Default/index.tsx"],"sourcesContent":["import type { groupNavItems } from '@payloadcms/ui/shared'\nimport type { AdminViewServerPropsOnly, ClientUser, Locale, ServerProps } from 'payload'\n\nimport { Gutter } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport { ModularDashboard } from './ModularDashboard/index.js'\n\nconst baseClass = 'dashboard'\n\nexport type DashboardViewClientProps = {\n locale: Locale\n}\n\n// Neither DashboardViewClientProps, DashboardViewServerPropsOnly, nor\n// DashboardViewServerProps make much sense. They were created\n// before the modular dashboard existed, and they are tightly coupled to\n// the default layout of collection and global cards. All of their values\n// could have been derived from the req object, and the same likely applies\n// to other views. These types remain only for backward compatibility.\n// It is recommended to use the modular dashboard widgets, which have props\n// that are more agnostic to their content.\n\nexport type DashboardViewServerPropsOnly = {\n globalData: Array<{\n data: { _isLocked: boolean; _lastEditedAt: string; _userEditing: ClientUser | number | string }\n lockDuration?: number\n slug: string\n }>\n /**\n * @deprecated\n * This prop is deprecated and will be removed in the next major version.\n * Components now import their own `Link` directly from `next/link`.\n */\n Link?: React.ComponentType\n navGroups?: ReturnType<typeof groupNavItems>\n} & AdminViewServerPropsOnly\n\nexport type DashboardViewServerProps = DashboardViewClientProps & DashboardViewServerPropsOnly\n\nexport function DefaultDashboard(props: DashboardViewServerProps) {\n const { i18n, locale, params, payload, permissions, searchParams, user } = props\n const { afterDashboard, beforeDashboard } = payload.config.admin.components\n\n return (\n <Gutter className={baseClass}>\n {beforeDashboard &&\n RenderServerComponent({\n Component: beforeDashboard,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n <ModularDashboard {...props} />\n {afterDashboard &&\n RenderServerComponent({\n Component: afterDashboard,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n </Gutter>\n )\n}\n"],"mappings":";AAGA,SAASA,MAAM,QAAQ;AACvB,SAASC,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAElB,SAASC,gBAAgB,QAAQ;AAEjC,MAAMC,SAAA,GAAY;AAgClB,OAAO,SAASC,iBAAiBC,KAA+B;EAC9D,MAAM;IAAEC,IAAI;IAAEC,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC,YAAY;IAAEC;EAAI,CAAE,GAAGP,KAAA;EAC3E,MAAM;IAAEQ,cAAc;IAAEC;EAAe,CAAE,GAAGL,OAAA,CAAQM,MAAM,CAACC,KAAK,CAACC,UAAU;EAE3E,oBACEC,KAAA,CAACnB,MAAA;IAAOoB,SAAA,EAAWhB,SAAA;eAChBW,eAAA,IACCd,qBAAA,CAAsB;MACpBoB,SAAA,EAAWN,eAAA;MACXO,SAAA,EAAWZ,OAAA,CAAQY,SAAS;MAC5BC,WAAA,EAAa;QACXhB,IAAA;QACAC,MAAA;QACAC,MAAA;QACAC,OAAA;QACAC,WAAA;QACAC,YAAA;QACAC;MACF;IACF,I,aACFW,IAAA,CAACrB,gBAAA;MAAkB,GAAGG;QACrBQ,cAAA,IACCb,qBAAA,CAAsB;MACpBoB,SAAA,EAAWP,cAAA;MACXQ,SAAA,EAAWZ,OAAA,CAAQY,SAAS;MAC5BC,WAAA,EAAa;QACXhB,IAAA;QACAC,MAAA;QACAC,MAAA;QACAC,OAAA;QACAC,WAAA;QACAC,YAAA;QACAC;MACF;IACF;;AAGR","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Dashboard/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAa,MAAM,SAAS,CAAA;AAK9D,OAAO,KAAmB,MAAM,OAAO,CAAA;AAQvC,wBAAsB,aAAa,CAAC,KAAK,EAAE,oBAAoB,8BAmH9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Dashboard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAKnD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAMvC,wBAAsB,aAAa,CAAC,KAAK,EAAE,oBAAoB,8BA0C9D"}
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { HydrateAuthProvider, SetStepNav } from '@payloadcms/ui';
3
3
  import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
4
- import { EntityType, groupNavItems } from '@payloadcms/ui/shared';
4
+ import { getGlobalData, getNavGroups } from '@payloadcms/ui/shared';
5
5
  import React, { Fragment } from 'react';
6
6
  import { DefaultDashboard } from './Default/index.js';
7
- const globalLockDurationDefault = 300;
8
7
  export async function DashboardView(props) {
9
8
  const {
10
9
  locale,
@@ -20,56 +19,8 @@ export async function DashboardView(props) {
20
19
  req,
21
20
  visibleEntities
22
21
  } = props.initPageResult;
23
- const collections = config.collections.filter(collection => permissions?.collections?.[collection.slug]?.read && visibleEntities.collections.includes(collection.slug));
24
- const globals = config.globals.filter(global => permissions?.globals?.[global.slug]?.read && visibleEntities.globals.includes(global.slug));
25
- // Query locked global documents only if there are globals in the config
26
- let globalData = [];
27
- if (config.globals.length > 0) {
28
- const lockedDocuments = await payload.find({
29
- collection: 'payload-locked-documents',
30
- depth: 1,
31
- overrideAccess: false,
32
- pagination: false,
33
- req,
34
- select: {
35
- globalSlug: true,
36
- updatedAt: true,
37
- user: true
38
- },
39
- where: {
40
- globalSlug: {
41
- exists: true
42
- }
43
- }
44
- });
45
- // Map over globals to include `lockDuration` and lock data for each global slug
46
- globalData = config.globals.map(global => {
47
- const lockDuration = typeof global.lockDocuments === 'object' ? global.lockDocuments.duration : globalLockDurationDefault;
48
- const lockedDoc = lockedDocuments.docs.find(doc => doc.globalSlug === global.slug);
49
- return {
50
- slug: global.slug,
51
- data: {
52
- _isLocked: !!lockedDoc,
53
- _lastEditedAt: lockedDoc?.updatedAt ?? null,
54
- _userEditing: lockedDoc?.user?.value ?? null
55
- },
56
- lockDuration
57
- };
58
- });
59
- }
60
- const navGroups = groupNavItems([...(collections.map(collection => {
61
- const entityToGroup = {
62
- type: EntityType.collection,
63
- entity: collection
64
- };
65
- return entityToGroup;
66
- }) ?? []), ...(globals.map(global => {
67
- const entityToGroup = {
68
- type: EntityType.global,
69
- entity: global
70
- };
71
- return entityToGroup;
72
- }) ?? [])], permissions, i18n);
22
+ const globalData = await getGlobalData(req);
23
+ const navGroups = getNavGroups(permissions, visibleEntities, config, i18n);
73
24
  return /*#__PURE__*/_jsxs(Fragment, {
74
25
  children: [/*#__PURE__*/_jsx(HydrateAuthProvider, {
75
26
  permissions: permissions