@payloadcms/next 3.81.0-internal-debug.1a0f4d0 → 3.81.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 (466) hide show
  1. package/dist/auth/login.js +58 -52
  2. package/dist/auth/login.js.map +1 -1
  3. package/dist/auth/logout.js +44 -39
  4. package/dist/auth/logout.js.map +1 -1
  5. package/dist/auth/refresh.js +47 -45
  6. package/dist/auth/refresh.js.map +1 -1
  7. package/dist/cjs/withPayload.cjs +27 -65
  8. package/dist/cjs/withPayload.cjs.map +3 -3
  9. package/dist/config.js +0 -1
  10. package/dist/config.js.map +1 -1
  11. package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.js +15 -9
  12. package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.js.map +1 -1
  13. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +71 -40
  14. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +1 -1
  15. package/dist/elements/DocumentHeader/Tabs/Tab/index.js +59 -65
  16. package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
  17. package/dist/elements/DocumentHeader/Tabs/index.js +70 -80
  18. package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
  19. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +23 -16
  20. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
  21. package/dist/elements/DocumentHeader/Tabs/tabs/index.js +69 -61
  22. package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
  23. package/dist/elements/DocumentHeader/index.js +28 -48
  24. package/dist/elements/DocumentHeader/index.js.map +1 -1
  25. package/dist/elements/FormHeader/index.js +16 -30
  26. package/dist/elements/FormHeader/index.js.map +1 -1
  27. package/dist/elements/Logo/index.js +34 -19
  28. package/dist/elements/Logo/index.js.map +1 -1
  29. package/dist/elements/Nav/NavHamburger/index.js +44 -23
  30. package/dist/elements/Nav/NavHamburger/index.js.map +1 -1
  31. package/dist/elements/Nav/NavWrapper/index.js +54 -28
  32. package/dist/elements/Nav/NavWrapper/index.js.map +1 -1
  33. package/dist/elements/Nav/SettingsMenuButton/index.js +39 -33
  34. package/dist/elements/Nav/SettingsMenuButton/index.js.map +1 -1
  35. package/dist/elements/Nav/getNavPrefs.js +22 -27
  36. package/dist/elements/Nav/getNavPrefs.js.map +1 -1
  37. package/dist/elements/Nav/index.client.js +118 -97
  38. package/dist/elements/Nav/index.client.js.map +1 -1
  39. package/dist/elements/Nav/index.js +170 -191
  40. package/dist/elements/Nav/index.js.map +1 -1
  41. package/dist/exports/auth.js +0 -1
  42. package/dist/exports/auth.js.map +1 -1
  43. package/dist/exports/client.js +1 -1
  44. package/dist/exports/client.js.map +1 -1
  45. package/dist/exports/layouts.js +0 -1
  46. package/dist/exports/layouts.js.map +1 -1
  47. package/dist/exports/routes.js +0 -1
  48. package/dist/exports/routes.js.map +1 -1
  49. package/dist/exports/rsc.js +0 -1
  50. package/dist/exports/rsc.js.map +1 -1
  51. package/dist/exports/templates.js +0 -1
  52. package/dist/exports/templates.js.map +1 -1
  53. package/dist/exports/utilities.js +12 -7
  54. package/dist/exports/utilities.js.map +1 -1
  55. package/dist/exports/views.js +0 -1
  56. package/dist/exports/views.js.map +1 -1
  57. package/dist/index.js +0 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/layouts/Root/NestProviders.js +20 -21
  60. package/dist/layouts/Root/NestProviders.js.map +1 -1
  61. package/dist/layouts/Root/checkDependencies.js +41 -49
  62. package/dist/layouts/Root/checkDependencies.js.map +1 -1
  63. package/dist/layouts/Root/index.d.ts +4 -2
  64. package/dist/layouts/Root/index.d.ts.map +1 -1
  65. package/dist/layouts/Root/index.js +125 -128
  66. package/dist/layouts/Root/index.js.map +1 -1
  67. package/dist/prod/styles.css +1 -5
  68. package/dist/routes/graphql/handler.js +122 -114
  69. package/dist/routes/graphql/handler.js.map +1 -1
  70. package/dist/routes/graphql/index.js +0 -1
  71. package/dist/routes/graphql/index.js.map +1 -1
  72. package/dist/routes/graphql/playground.js +27 -28
  73. package/dist/routes/graphql/playground.js.map +1 -1
  74. package/dist/routes/index.js +0 -1
  75. package/dist/routes/index.js.map +1 -1
  76. package/dist/routes/rest/index.js +22 -23
  77. package/dist/routes/rest/index.js.map +1 -1
  78. package/dist/routes/rest/og/image.js +79 -103
  79. package/dist/routes/rest/og/image.js.map +1 -1
  80. package/dist/routes/rest/og/index.js +54 -59
  81. package/dist/routes/rest/og/index.js.map +1 -1
  82. package/dist/templates/Default/NavHamburger/index.js +20 -12
  83. package/dist/templates/Default/NavHamburger/index.js.map +1 -1
  84. package/dist/templates/Default/Wrapper/index.js +44 -20
  85. package/dist/templates/Default/Wrapper/index.js.map +1 -1
  86. package/dist/templates/Default/index.js +116 -147
  87. package/dist/templates/Default/index.js.map +1 -1
  88. package/dist/templates/Minimal/index.js +17 -26
  89. package/dist/templates/Minimal/index.js.map +1 -1
  90. package/dist/utilities/getExistingAuthToken.js +2 -3
  91. package/dist/utilities/getExistingAuthToken.js.map +1 -1
  92. package/dist/utilities/getNextRequestI18n.js +13 -12
  93. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  94. package/dist/utilities/getPayloadHMR.js +5 -5
  95. package/dist/utilities/getPayloadHMR.js.map +1 -1
  96. package/dist/utilities/getPreferences.js +22 -27
  97. package/dist/utilities/getPreferences.js.map +1 -1
  98. package/dist/utilities/getRequestLocale.js +14 -13
  99. package/dist/utilities/getRequestLocale.js.map +1 -1
  100. package/dist/utilities/getRequestTheme.js +19 -19
  101. package/dist/utilities/getRequestTheme.js.map +1 -1
  102. package/dist/utilities/getRouteWithoutAdmin.js +5 -3
  103. package/dist/utilities/getRouteWithoutAdmin.js.map +1 -1
  104. package/dist/utilities/handleAuthRedirect.js +36 -22
  105. package/dist/utilities/handleAuthRedirect.js.map +1 -1
  106. package/dist/utilities/handleServerFunctions.js +43 -33
  107. package/dist/utilities/handleServerFunctions.js.map +1 -1
  108. package/dist/utilities/initReq.js +96 -78
  109. package/dist/utilities/initReq.js.map +1 -1
  110. package/dist/utilities/isCustomAdminView.d.ts.map +1 -1
  111. package/dist/utilities/isCustomAdminView.js +26 -22
  112. package/dist/utilities/isCustomAdminView.js.map +1 -1
  113. package/dist/utilities/isCustomAdminView.spec.js +90 -0
  114. package/dist/utilities/isCustomAdminView.spec.js.map +1 -0
  115. package/dist/utilities/isPublicAdminRoute.js +20 -26
  116. package/dist/utilities/isPublicAdminRoute.js.map +1 -1
  117. package/dist/utilities/meta.js +63 -68
  118. package/dist/utilities/meta.js.map +1 -1
  119. package/dist/utilities/selectiveCache.js +26 -25
  120. package/dist/utilities/selectiveCache.js.map +1 -1
  121. package/dist/utilities/setPayloadAuthCookie.js +22 -19
  122. package/dist/utilities/setPayloadAuthCookie.js.map +1 -1
  123. package/dist/utilities/slugify.js +33 -24
  124. package/dist/utilities/slugify.js.map +1 -1
  125. package/dist/utilities/timestamp.js +6 -7
  126. package/dist/utilities/timestamp.js.map +1 -1
  127. package/dist/views/API/LocaleSelector/index.js +39 -17
  128. package/dist/views/API/LocaleSelector/index.js.map +1 -1
  129. package/dist/views/API/RenderJSON/index.js +126 -171
  130. package/dist/views/API/RenderJSON/index.js.map +1 -1
  131. package/dist/views/API/index.client.d.ts.map +1 -1
  132. package/dist/views/API/index.client.js +205 -290
  133. package/dist/views/API/index.client.js.map +1 -1
  134. package/dist/views/API/index.js +2 -7
  135. package/dist/views/API/index.js.map +1 -1
  136. package/dist/views/API/metadata.js +23 -18
  137. package/dist/views/API/metadata.js.map +1 -1
  138. package/dist/views/Account/ResetPreferences/index.js +100 -76
  139. package/dist/views/Account/ResetPreferences/index.js.map +1 -1
  140. package/dist/views/Account/Settings/LanguageSelector.js +47 -18
  141. package/dist/views/Account/Settings/LanguageSelector.js.map +1 -1
  142. package/dist/views/Account/Settings/index.js +25 -60
  143. package/dist/views/Account/Settings/index.js.map +1 -1
  144. package/dist/views/Account/ToggleTheme/index.js +55 -38
  145. package/dist/views/Account/ToggleTheme/index.js.map +1 -1
  146. package/dist/views/Account/index.client.js +32 -16
  147. package/dist/views/Account/index.client.js.map +1 -1
  148. package/dist/views/Account/index.js +162 -149
  149. package/dist/views/Account/index.js.map +1 -1
  150. package/dist/views/Account/metadata.js +12 -8
  151. package/dist/views/Account/metadata.js.map +1 -1
  152. package/dist/views/BrowseByFolder/buildView.js +157 -138
  153. package/dist/views/BrowseByFolder/buildView.js.map +1 -1
  154. package/dist/views/BrowseByFolder/index.js +16 -16
  155. package/dist/views/BrowseByFolder/index.js.map +1 -1
  156. package/dist/views/BrowseByFolder/metadata.js +15 -13
  157. package/dist/views/BrowseByFolder/metadata.js.map +1 -1
  158. package/dist/views/CollectionFolders/buildView.js +142 -122
  159. package/dist/views/CollectionFolders/buildView.js.map +1 -1
  160. package/dist/views/CollectionFolders/index.js +16 -16
  161. package/dist/views/CollectionFolders/index.js.map +1 -1
  162. package/dist/views/CollectionFolders/metadata.js +21 -18
  163. package/dist/views/CollectionFolders/metadata.js.map +1 -1
  164. package/dist/views/CollectionFolders/renderFolderViewSlots.js +61 -58
  165. package/dist/views/CollectionFolders/renderFolderViewSlots.js.map +1 -1
  166. package/dist/views/CollectionTrash/index.js +17 -17
  167. package/dist/views/CollectionTrash/index.js.map +1 -1
  168. package/dist/views/CollectionTrash/metadata.js +21 -18
  169. package/dist/views/CollectionTrash/metadata.js.map +1 -1
  170. package/dist/views/CreateFirstUser/index.client.js +103 -117
  171. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  172. package/dist/views/CreateFirstUser/index.js +81 -87
  173. package/dist/views/CreateFirstUser/index.js.map +1 -1
  174. package/dist/views/CreateFirstUser/metadata.js +12 -8
  175. package/dist/views/CreateFirstUser/metadata.js.map +1 -1
  176. package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js +170 -145
  177. package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js.map +1 -1
  178. package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.js +118 -144
  179. package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.js.map +1 -1
  180. package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.js +72 -59
  181. package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.js.map +1 -1
  182. package/dist/views/Dashboard/Default/ModularDashboard/index.client.js +414 -435
  183. package/dist/views/Dashboard/Default/ModularDashboard/index.client.js.map +1 -1
  184. package/dist/views/Dashboard/Default/ModularDashboard/index.js +63 -54
  185. package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
  186. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js +96 -65
  187. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js.map +1 -1
  188. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +54 -44
  189. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
  190. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +72 -65
  191. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
  192. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js +175 -193
  193. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js.map +1 -1
  194. package/dist/views/Dashboard/Default/ModularDashboard/utils/collisionDetection.js +30 -31
  195. package/dist/views/Dashboard/Default/ModularDashboard/utils/collisionDetection.js.map +1 -1
  196. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromConfig.js +17 -18
  197. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromConfig.js.map +1 -1
  198. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.js +5 -6
  199. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.js.map +1 -1
  200. package/dist/views/Dashboard/Default/ModularDashboard/utils/localeUtils.js +74 -69
  201. package/dist/views/Dashboard/Default/ModularDashboard/utils/localeUtils.js.map +1 -1
  202. package/dist/views/Dashboard/Default/ModularDashboard/utils/sensors.js +234 -228
  203. package/dist/views/Dashboard/Default/ModularDashboard/utils/sensors.js.map +1 -1
  204. package/dist/views/Dashboard/Default/index.js +45 -59
  205. package/dist/views/Dashboard/Default/index.js.map +1 -1
  206. package/dist/views/Dashboard/index.js +42 -46
  207. package/dist/views/Dashboard/index.js.map +1 -1
  208. package/dist/views/Dashboard/metadata.js +14 -10
  209. package/dist/views/Dashboard/metadata.js.map +1 -1
  210. package/dist/views/Document/getCustomDocumentViewByKey.js +2 -3
  211. package/dist/views/Document/getCustomDocumentViewByKey.js.map +1 -1
  212. package/dist/views/Document/getCustomViewByRoute.js +30 -27
  213. package/dist/views/Document/getCustomViewByRoute.js.map +1 -1
  214. package/dist/views/Document/getDocPreferences.js +41 -40
  215. package/dist/views/Document/getDocPreferences.js.map +1 -1
  216. package/dist/views/Document/getDocumentData.js +55 -44
  217. package/dist/views/Document/getDocumentData.js.map +1 -1
  218. package/dist/views/Document/getDocumentPermissions.js +117 -114
  219. package/dist/views/Document/getDocumentPermissions.js.map +1 -1
  220. package/dist/views/Document/getDocumentView.js +283 -313
  221. package/dist/views/Document/getDocumentView.js.map +1 -1
  222. package/dist/views/Document/getIsLocked.js +73 -73
  223. package/dist/views/Document/getIsLocked.js.map +1 -1
  224. package/dist/views/Document/getMetaBySegment.js +136 -130
  225. package/dist/views/Document/getMetaBySegment.js.map +1 -1
  226. package/dist/views/Document/getVersions.js +213 -220
  227. package/dist/views/Document/getVersions.js.map +1 -1
  228. package/dist/views/Document/handleServerFunction.js +127 -100
  229. package/dist/views/Document/handleServerFunction.js.map +1 -1
  230. package/dist/views/Document/index.js +359 -319
  231. package/dist/views/Document/index.js.map +1 -1
  232. package/dist/views/Document/metadata.js +1 -2
  233. package/dist/views/Document/metadata.js.map +1 -1
  234. package/dist/views/Document/renderDocumentSlots.js +155 -141
  235. package/dist/views/Document/renderDocumentSlots.js.map +1 -1
  236. package/dist/views/Edit/index.js +6 -10
  237. package/dist/views/Edit/index.js.map +1 -1
  238. package/dist/views/Edit/metadata.js +46 -36
  239. package/dist/views/Edit/metadata.js.map +1 -1
  240. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
  241. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +169 -132
  242. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
  243. package/dist/views/ForgotPassword/index.js +62 -79
  244. package/dist/views/ForgotPassword/index.js.map +1 -1
  245. package/dist/views/ForgotPassword/metadata.js +12 -8
  246. package/dist/views/ForgotPassword/metadata.js.map +1 -1
  247. package/dist/views/List/createSerializableValue.js +11 -12
  248. package/dist/views/List/createSerializableValue.js.map +1 -1
  249. package/dist/views/List/enrichDocsWithVersionStatus.js +86 -86
  250. package/dist/views/List/enrichDocsWithVersionStatus.js.map +1 -1
  251. package/dist/views/List/extractRelationshipDisplayValue.js +14 -15
  252. package/dist/views/List/extractRelationshipDisplayValue.js.map +1 -1
  253. package/dist/views/List/extractValueOrRelationshipID.js +15 -16
  254. package/dist/views/List/extractValueOrRelationshipID.js.map +1 -1
  255. package/dist/views/List/handleGroupBy.js +150 -133
  256. package/dist/views/List/handleGroupBy.js.map +1 -1
  257. package/dist/views/List/handleServerFunction.js +122 -96
  258. package/dist/views/List/handleServerFunction.js.map +1 -1
  259. package/dist/views/List/index.js +325 -306
  260. package/dist/views/List/index.js.map +1 -1
  261. package/dist/views/List/metadata.js +20 -17
  262. package/dist/views/List/metadata.js.map +1 -1
  263. package/dist/views/List/renderListViewSlots.js +75 -82
  264. package/dist/views/List/renderListViewSlots.js.map +1 -1
  265. package/dist/views/List/resolveAllFilterOptions.js +45 -43
  266. package/dist/views/List/resolveAllFilterOptions.js.map +1 -1
  267. package/dist/views/List/transformColumnsToSelect.js +8 -9
  268. package/dist/views/List/transformColumnsToSelect.js.map +1 -1
  269. package/dist/views/Login/LoginField/index.js +89 -57
  270. package/dist/views/Login/LoginField/index.js.map +1 -1
  271. package/dist/views/Login/LoginForm/index.js +160 -107
  272. package/dist/views/Login/LoginForm/index.js.map +1 -1
  273. package/dist/views/Login/index.js +85 -82
  274. package/dist/views/Login/index.js.map +1 -1
  275. package/dist/views/Login/metadata.js +12 -8
  276. package/dist/views/Login/metadata.js.map +1 -1
  277. package/dist/views/Logout/LogoutClient.js +120 -84
  278. package/dist/views/Logout/LogoutClient.js.map +1 -1
  279. package/dist/views/Logout/index.js +29 -29
  280. package/dist/views/Logout/index.js.map +1 -1
  281. package/dist/views/Logout/metadata.js +11 -7
  282. package/dist/views/Logout/metadata.js.map +1 -1
  283. package/dist/views/NotFound/index.client.js +82 -71
  284. package/dist/views/NotFound/index.client.js.map +1 -1
  285. package/dist/views/NotFound/index.js +73 -72
  286. package/dist/views/NotFound/index.js.map +1 -1
  287. package/dist/views/NotFound/metadata.js +9 -7
  288. package/dist/views/NotFound/metadata.js.map +1 -1
  289. package/dist/views/ResetPassword/ResetPasswordForm/index.js +108 -97
  290. package/dist/views/ResetPassword/ResetPasswordForm/index.js.map +1 -1
  291. package/dist/views/ResetPassword/index.js +73 -93
  292. package/dist/views/ResetPassword/index.js.map +1 -1
  293. package/dist/views/ResetPassword/metadata.js +12 -8
  294. package/dist/views/ResetPassword/metadata.js.map +1 -1
  295. package/dist/views/Root/attachViewActions.js +23 -18
  296. package/dist/views/Root/attachViewActions.js.map +1 -1
  297. package/dist/views/Root/generateCustomViewMetadata.js +21 -19
  298. package/dist/views/Root/generateCustomViewMetadata.js.map +1 -1
  299. package/dist/views/Root/getCustomViewByKey.js +14 -12
  300. package/dist/views/Root/getCustomViewByKey.js.map +1 -1
  301. package/dist/views/Root/getCustomViewByRoute.js +42 -31
  302. package/dist/views/Root/getCustomViewByRoute.js.map +1 -1
  303. package/dist/views/Root/getDocumentViewInfo.js +23 -24
  304. package/dist/views/Root/getDocumentViewInfo.js.map +1 -1
  305. package/dist/views/Root/getRouteData.js +325 -333
  306. package/dist/views/Root/getRouteData.js.map +1 -1
  307. package/dist/views/Root/index.js +270 -248
  308. package/dist/views/Root/index.js.map +1 -1
  309. package/dist/views/Root/isPathMatchingRoute.js +26 -21
  310. package/dist/views/Root/isPathMatchingRoute.js.map +1 -1
  311. package/dist/views/Root/metadata.js +181 -176
  312. package/dist/views/Root/metadata.js.map +1 -1
  313. package/dist/views/Unauthorized/index.js +46 -54
  314. package/dist/views/Unauthorized/index.js.map +1 -1
  315. package/dist/views/Unauthorized/metadata.js +12 -8
  316. package/dist/views/Unauthorized/metadata.js.map +1 -1
  317. package/dist/views/Verify/index.client.js +43 -25
  318. package/dist/views/Verify/index.client.js.map +1 -1
  319. package/dist/views/Verify/index.js +64 -69
  320. package/dist/views/Verify/index.js.map +1 -1
  321. package/dist/views/Verify/metadata.js +12 -8
  322. package/dist/views/Verify/metadata.js.map +1 -1
  323. package/dist/views/Version/Default/SelectedLocalesContext.js +4 -4
  324. package/dist/views/Version/Default/SelectedLocalesContext.js.map +1 -1
  325. package/dist/views/Version/Default/SetStepNav.js +127 -86
  326. package/dist/views/Version/Default/SetStepNav.js.map +1 -1
  327. package/dist/views/Version/Default/index.js +236 -380
  328. package/dist/views/Version/Default/index.js.map +1 -1
  329. package/dist/views/Version/Default/types.js +1 -2
  330. package/dist/views/Version/Default/types.js.map +1 -1
  331. package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js +119 -102
  332. package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js.map +1 -1
  333. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js +73 -78
  334. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js.map +1 -1
  335. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +408 -363
  336. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -1
  337. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js +51 -40
  338. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js.map +1 -1
  339. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.js +70 -38
  340. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.js.map +1 -1
  341. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js +56 -59
  342. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js.map +1 -1
  343. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +117 -139
  344. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
  345. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js +61 -56
  346. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js.map +1 -1
  347. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +206 -224
  348. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
  349. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js +11 -17
  350. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js.map +1 -1
  351. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +74 -49
  352. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
  353. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +146 -135
  354. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
  355. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +82 -57
  356. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
  357. package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js +211 -252
  358. package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js.map +1 -1
  359. package/dist/views/Version/RenderFieldsToDiff/fields/index.js +22 -23
  360. package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
  361. package/dist/views/Version/RenderFieldsToDiff/index.js +9 -12
  362. package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
  363. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js +228 -213
  364. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js.map +1 -1
  365. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js +826 -1005
  366. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js.map +1 -1
  367. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.js +1 -2
  368. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.js.map +1 -1
  369. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js +43 -44
  370. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js.map +1 -1
  371. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js +36 -32
  372. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js.map +1 -1
  373. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +129 -145
  374. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +1 -1
  375. package/dist/views/Version/Restore/index.js +92 -117
  376. package/dist/views/Version/Restore/index.js.map +1 -1
  377. package/dist/views/Version/SelectComparison/VersionDrawer/CreatedAtCell.js +50 -33
  378. package/dist/views/Version/SelectComparison/VersionDrawer/CreatedAtCell.js.map +1 -1
  379. package/dist/views/Version/SelectComparison/VersionDrawer/index.js +226 -170
  380. package/dist/views/Version/SelectComparison/VersionDrawer/index.js.map +1 -1
  381. package/dist/views/Version/SelectComparison/index.js +50 -73
  382. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  383. package/dist/views/Version/SelectComparison/types.js +1 -2
  384. package/dist/views/Version/SelectComparison/types.js.map +1 -1
  385. package/dist/views/Version/SelectLocales/index.js +32 -34
  386. package/dist/views/Version/SelectLocales/index.js.map +1 -1
  387. package/dist/views/Version/VersionPillLabel/VersionPillLabel.js +100 -106
  388. package/dist/views/Version/VersionPillLabel/VersionPillLabel.js.map +1 -1
  389. package/dist/views/Version/VersionPillLabel/getVersionLabel.js +35 -30
  390. package/dist/views/Version/VersionPillLabel/getVersionLabel.js.map +1 -1
  391. package/dist/views/Version/fetchVersions.js +138 -113
  392. package/dist/views/Version/fetchVersions.js.map +1 -1
  393. package/dist/views/Version/index.js +326 -328
  394. package/dist/views/Version/index.js.map +1 -1
  395. package/dist/views/Version/metadata.js +50 -43
  396. package/dist/views/Version/metadata.js.map +1 -1
  397. package/dist/views/Versions/buildColumns.js +79 -95
  398. package/dist/views/Versions/buildColumns.js.map +1 -1
  399. package/dist/views/Versions/cells/AutosaveCell/index.js +38 -34
  400. package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
  401. package/dist/views/Versions/cells/CreatedAt/index.js +53 -32
  402. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  403. package/dist/views/Versions/cells/ID/index.js +8 -10
  404. package/dist/views/Versions/cells/ID/index.js.map +1 -1
  405. package/dist/views/Versions/index.client.js +83 -106
  406. package/dist/views/Versions/index.client.js.map +1 -1
  407. package/dist/views/Versions/index.js +164 -164
  408. package/dist/views/Versions/index.js.map +1 -1
  409. package/dist/views/Versions/metadata.js +44 -37
  410. package/dist/views/Versions/metadata.js.map +1 -1
  411. package/dist/views/Versions/types.js +1 -2
  412. package/dist/views/Versions/types.js.map +1 -1
  413. package/dist/withPayload/withPayload.d.ts.map +1 -1
  414. package/dist/withPayload/withPayload.js +180 -236
  415. package/dist/withPayload/withPayload.js.map +1 -1
  416. package/dist/withPayload/withPayload.spec.js +35 -36
  417. package/dist/withPayload/withPayload.spec.js.map +1 -1
  418. package/dist/withPayload/withPayload.utils.js +73 -65
  419. package/dist/withPayload/withPayload.utils.js.map +1 -1
  420. package/dist/withPayload/withPayloadLegacy.js +40 -41
  421. package/dist/withPayload/withPayloadLegacy.js.map +1 -1
  422. package/package.json +8 -8
  423. package/dist/elements/DocumentHeader/Tabs/Tab/index.scss +0 -38
  424. package/dist/elements/DocumentHeader/Tabs/index.scss +0 -54
  425. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.scss +0 -10
  426. package/dist/elements/DocumentHeader/index.scss +0 -64
  427. package/dist/elements/FormHeader/index.scss +0 -8
  428. package/dist/elements/Nav/NavWrapper/index.scss +0 -27
  429. package/dist/elements/Nav/SettingsMenuButton/index.scss +0 -11
  430. package/dist/elements/Nav/index.scss +0 -173
  431. package/dist/esbuildEntry.d.ts +0 -5
  432. package/dist/esbuildEntry.d.ts.map +0 -1
  433. package/dist/esbuildEntry.js +0 -6
  434. package/dist/esbuildEntry.js.map +0 -1
  435. package/dist/templates/Default/Wrapper/index.scss +0 -58
  436. package/dist/templates/Default/index.scss +0 -79
  437. package/dist/templates/Minimal/index.scss +0 -30
  438. package/dist/views/API/RenderJSON/index.scss +0 -129
  439. package/dist/views/API/index.scss +0 -119
  440. package/dist/views/Account/Settings/index.scss +0 -48
  441. package/dist/views/CreateFirstUser/index.scss +0 -21
  442. package/dist/views/Dashboard/Default/ModularDashboard/index.scss +0 -318
  443. package/dist/views/Login/LoginForm/index.scss +0 -10
  444. package/dist/views/Login/index.scss +0 -10
  445. package/dist/views/Logout/index.scss +0 -25
  446. package/dist/views/NotFound/index.scss +0 -57
  447. package/dist/views/ResetPassword/index.scss +0 -11
  448. package/dist/views/Unauthorized/index.scss +0 -14
  449. package/dist/views/Verify/index.scss +0 -16
  450. package/dist/views/Version/Default/index.scss +0 -170
  451. package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.scss +0 -81
  452. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.scss +0 -12
  453. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.scss +0 -9
  454. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.scss +0 -59
  455. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.scss +0 -91
  456. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.scss +0 -4
  457. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.scss +0 -9
  458. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.scss +0 -4
  459. package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.scss +0 -121
  460. package/dist/views/Version/RenderFieldsToDiff/index.scss +0 -24
  461. package/dist/views/Version/Restore/index.scss +0 -84
  462. package/dist/views/Version/SelectComparison/VersionDrawer/index.scss +0 -18
  463. package/dist/views/Version/SelectComparison/index.scss +0 -9
  464. package/dist/views/Version/VersionPillLabel/index.scss +0 -26
  465. package/dist/views/Versions/cells/AutosaveCell/index.scss +0 -9
  466. package/dist/views/Versions/index.scss +0 -110
@@ -9,386 +9,431 @@ import { diffComponents } from './fields/index.js';
9
9
  *
10
10
  * Here, the server is responsible for traversing through the document data and building up this
11
11
  * version state object.
12
- */ export const buildVersionFields = ({ clientSchemaMap, customDiffComponents, entitySlug, fields, fieldsPermissions, i18n, modifiedOnly, nestingLevel = 0, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, selectedLocales, versionFromSiblingData, versionToSiblingData })=>{
13
- const versionFields = [];
14
- let fieldIndex = -1;
15
- for (const field of fields){
16
- fieldIndex++;
17
- if (fieldIsID(field)) {
18
- continue;
19
- }
20
- const { indexPath, path, schemaPath } = getFieldPaths({
21
- field,
22
- index: fieldIndex,
23
- parentIndexPath,
24
- parentPath,
25
- parentSchemaPath
26
- });
27
- const clientField = clientSchemaMap.get(entitySlug + '.' + schemaPath);
28
- if (!clientField) {
29
- req.payload.logger.error({
30
- clientFieldKey: entitySlug + '.' + schemaPath,
31
- clientSchemaMapKeys: Array.from(clientSchemaMap.keys()),
32
- msg: 'No client field found for ' + entitySlug + '.' + schemaPath,
33
- parentPath,
34
- parentSchemaPath,
35
- path,
36
- schemaPath
37
- });
38
- throw new Error('No client field found for ' + entitySlug + '.' + schemaPath);
39
- }
40
- const versionField = {};
41
- const isLocalized = fieldShouldBeLocalized({
42
- field,
43
- parentIsLocalized
12
+ */
13
+ export const buildVersionFields = ({
14
+ clientSchemaMap,
15
+ customDiffComponents,
16
+ entitySlug,
17
+ fields,
18
+ fieldsPermissions,
19
+ i18n,
20
+ modifiedOnly,
21
+ nestingLevel = 0,
22
+ parentIndexPath,
23
+ parentIsLocalized,
24
+ parentPath,
25
+ parentSchemaPath,
26
+ req,
27
+ selectedLocales,
28
+ versionFromSiblingData,
29
+ versionToSiblingData
30
+ }) => {
31
+ const versionFields = [];
32
+ let fieldIndex = -1;
33
+ for (const field of fields) {
34
+ fieldIndex++;
35
+ if (fieldIsID(field)) {
36
+ continue;
37
+ }
38
+ const {
39
+ indexPath,
40
+ path,
41
+ schemaPath
42
+ } = getFieldPaths({
43
+ field,
44
+ index: fieldIndex,
45
+ parentIndexPath,
46
+ parentPath,
47
+ parentSchemaPath
48
+ });
49
+ const clientField = clientSchemaMap.get(entitySlug + '.' + schemaPath);
50
+ if (!clientField) {
51
+ req.payload.logger.error({
52
+ clientFieldKey: entitySlug + '.' + schemaPath,
53
+ clientSchemaMapKeys: Array.from(clientSchemaMap.keys()),
54
+ msg: 'No client field found for ' + entitySlug + '.' + schemaPath,
55
+ parentPath,
56
+ parentSchemaPath,
57
+ path,
58
+ schemaPath
59
+ });
60
+ throw new Error('No client field found for ' + entitySlug + '.' + schemaPath);
61
+ }
62
+ const versionField = {};
63
+ const isLocalized = fieldShouldBeLocalized({
64
+ field,
65
+ parentIsLocalized
66
+ });
67
+ const fieldName = 'name' in field ? field.name : null;
68
+ const valueFrom = fieldName ? versionFromSiblingData?.[fieldName] : versionFromSiblingData;
69
+ const valueTo = fieldName ? versionToSiblingData?.[fieldName] : versionToSiblingData;
70
+ if (isLocalized) {
71
+ versionField.fieldByLocale = {};
72
+ for (const locale of selectedLocales) {
73
+ const localizedVersionField = buildVersionField({
74
+ clientField: clientField,
75
+ clientSchemaMap,
76
+ customDiffComponents,
77
+ entitySlug,
78
+ field,
79
+ i18n,
80
+ indexPath,
81
+ locale,
82
+ modifiedOnly,
83
+ nestingLevel,
84
+ parentFieldsPermissions: fieldsPermissions,
85
+ parentIsLocalized: true,
86
+ parentPath,
87
+ parentSchemaPath,
88
+ path,
89
+ req,
90
+ schemaPath,
91
+ selectedLocales,
92
+ valueFrom: valueFrom?.[locale],
93
+ valueTo: valueTo?.[locale]
44
94
  });
45
- const fieldName = 'name' in field ? field.name : null;
46
- const valueFrom = fieldName ? versionFromSiblingData?.[fieldName] : versionFromSiblingData;
47
- const valueTo = fieldName ? versionToSiblingData?.[fieldName] : versionToSiblingData;
48
- if (isLocalized) {
49
- versionField.fieldByLocale = {};
50
- for (const locale of selectedLocales){
51
- const localizedVersionField = buildVersionField({
52
- clientField: clientField,
53
- clientSchemaMap,
54
- customDiffComponents,
55
- entitySlug,
56
- field,
57
- i18n,
58
- indexPath,
59
- locale,
60
- modifiedOnly,
61
- nestingLevel,
62
- parentFieldsPermissions: fieldsPermissions,
63
- parentIsLocalized: true,
64
- parentPath,
65
- parentSchemaPath,
66
- path,
67
- req,
68
- schemaPath,
69
- selectedLocales,
70
- valueFrom: valueFrom?.[locale],
71
- valueTo: valueTo?.[locale]
72
- });
73
- if (localizedVersionField) {
74
- versionField.fieldByLocale[locale] = localizedVersionField;
75
- }
76
- }
77
- } else {
78
- const baseVersionField = buildVersionField({
79
- clientField: clientField,
80
- clientSchemaMap,
81
- customDiffComponents,
82
- entitySlug,
83
- field,
84
- i18n,
85
- indexPath,
86
- modifiedOnly,
87
- nestingLevel,
88
- parentFieldsPermissions: fieldsPermissions,
89
- parentIsLocalized: parentIsLocalized || 'localized' in field && field.localized,
90
- parentPath,
91
- parentSchemaPath,
92
- path,
93
- req,
94
- schemaPath,
95
- selectedLocales,
96
- valueFrom,
97
- valueTo
98
- });
99
- if (baseVersionField) {
100
- versionField.field = baseVersionField;
101
- }
102
- }
103
- if (versionField.field || versionField.fieldByLocale && Object.keys(versionField.fieldByLocale).length) {
104
- versionFields.push(versionField);
95
+ if (localizedVersionField) {
96
+ versionField.fieldByLocale[locale] = localizedVersionField;
105
97
  }
98
+ }
99
+ } else {
100
+ const baseVersionField = buildVersionField({
101
+ clientField: clientField,
102
+ clientSchemaMap,
103
+ customDiffComponents,
104
+ entitySlug,
105
+ field,
106
+ i18n,
107
+ indexPath,
108
+ modifiedOnly,
109
+ nestingLevel,
110
+ parentFieldsPermissions: fieldsPermissions,
111
+ parentIsLocalized: parentIsLocalized || 'localized' in field && field.localized,
112
+ parentPath,
113
+ parentSchemaPath,
114
+ path,
115
+ req,
116
+ schemaPath,
117
+ selectedLocales,
118
+ valueFrom,
119
+ valueTo
120
+ });
121
+ if (baseVersionField) {
122
+ versionField.field = baseVersionField;
123
+ }
124
+ }
125
+ if (versionField.field || versionField.fieldByLocale && Object.keys(versionField.fieldByLocale).length) {
126
+ versionFields.push(versionField);
106
127
  }
107
- return {
108
- versionFields
109
- };
128
+ }
129
+ return {
130
+ versionFields
131
+ };
110
132
  };
111
- const buildVersionField = ({ clientField, clientSchemaMap, customDiffComponents, entitySlug, field, i18n, indexPath, locale, modifiedOnly, nestingLevel, parentFieldsPermissions, parentIsLocalized, parentPath, parentSchemaPath, path, req, schemaPath, selectedLocales, valueFrom, valueTo })=>{
112
- let hasReadPermission = false;
113
- let fieldPermissions = undefined;
114
- if (typeof parentFieldsPermissions === 'boolean') {
115
- hasReadPermission = parentFieldsPermissions;
116
- fieldPermissions = parentFieldsPermissions;
133
+ const buildVersionField = ({
134
+ clientField,
135
+ clientSchemaMap,
136
+ customDiffComponents,
137
+ entitySlug,
138
+ field,
139
+ i18n,
140
+ indexPath,
141
+ locale,
142
+ modifiedOnly,
143
+ nestingLevel,
144
+ parentFieldsPermissions,
145
+ parentIsLocalized,
146
+ parentPath,
147
+ parentSchemaPath,
148
+ path,
149
+ req,
150
+ schemaPath,
151
+ selectedLocales,
152
+ valueFrom,
153
+ valueTo
154
+ }) => {
155
+ let hasReadPermission = false;
156
+ let fieldPermissions = undefined;
157
+ if (typeof parentFieldsPermissions === 'boolean') {
158
+ hasReadPermission = parentFieldsPermissions;
159
+ fieldPermissions = parentFieldsPermissions;
160
+ } else {
161
+ if ('name' in field) {
162
+ fieldPermissions = parentFieldsPermissions?.[field.name];
163
+ if (typeof fieldPermissions === 'boolean') {
164
+ hasReadPermission = fieldPermissions;
165
+ } else if (typeof fieldPermissions?.read === 'boolean') {
166
+ hasReadPermission = fieldPermissions.read;
167
+ }
117
168
  } else {
118
- if ('name' in field) {
119
- fieldPermissions = parentFieldsPermissions?.[field.name];
120
- if (typeof fieldPermissions === 'boolean') {
121
- hasReadPermission = fieldPermissions;
122
- } else if (typeof fieldPermissions?.read === 'boolean') {
123
- hasReadPermission = fieldPermissions.read;
124
- }
125
- } else {
126
- // If the field is unnamed and parentFieldsPermissions is an object, its sub-fields will decide their read permissions state.
127
- // As far as this field is concerned, we are allowed to read it, as we need to reach its sub-fields to determine their read permissions.
128
- hasReadPermission = true;
129
- }
169
+ // If the field is unnamed and parentFieldsPermissions is an object, its sub-fields will decide their read permissions state.
170
+ // As far as this field is concerned, we are allowed to read it, as we need to reach its sub-fields to determine their read permissions.
171
+ hasReadPermission = true;
130
172
  }
131
- if (!hasReadPermission) {
132
- // HasReadPermission is only valid if the field has a name. E.g. for a tabs field it would incorrectly return `false`.
133
- return null;
173
+ }
174
+ if (!hasReadPermission) {
175
+ // HasReadPermission is only valid if the field has a name. E.g. for a tabs field it would incorrectly return `false`.
176
+ return null;
177
+ }
178
+ if (modifiedOnly && dequal(valueFrom, valueTo)) {
179
+ return null;
180
+ }
181
+ let CustomComponent = customDiffComponents?.[field.type];
182
+ if (field?.type === 'richText') {
183
+ if (!field?.editor) {
184
+ throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor
185
+ ;
134
186
  }
135
- if (modifiedOnly && dequal(valueFrom, valueTo)) {
136
- return null;
187
+ if (typeof field?.editor === 'function') {
188
+ throw new Error('Attempted to access unsanitized rich text editor.');
137
189
  }
138
- let CustomComponent = customDiffComponents?.[field.type];
139
- if (field?.type === 'richText') {
140
- if (!field?.editor) {
141
- throw new MissingEditorProp(field);
142
- }
143
- // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor
144
- if (typeof field?.editor === 'function') {
145
- throw new Error('Attempted to access unsanitized rich text editor.');
146
- }
147
- if (field.editor.CellComponent) {
148
- CustomComponent = field.editor.DiffComponent;
190
+ if (field.editor.CellComponent) {
191
+ CustomComponent = field.editor.DiffComponent;
192
+ }
193
+ }
194
+ if (field?.admin?.components?.Diff) {
195
+ CustomComponent = field.admin.components.Diff;
196
+ }
197
+ const DefaultComponent = diffComponents?.[field.type];
198
+ const baseVersionField = {
199
+ type: field.type,
200
+ fields: [],
201
+ path,
202
+ schemaPath
203
+ };
204
+ if (field.type === 'tabs' && 'tabs' in field) {
205
+ baseVersionField.tabs = [];
206
+ let tabIndex = -1;
207
+ for (const tab of field.tabs) {
208
+ tabIndex++;
209
+ const isNamedTab = tabHasName(tab);
210
+ const tabAsField = {
211
+ ...tab,
212
+ type: 'tab'
213
+ };
214
+ const {
215
+ indexPath: tabIndexPath,
216
+ path: tabPath,
217
+ schemaPath: tabSchemaPath
218
+ } = getFieldPaths({
219
+ field: tabAsField,
220
+ index: tabIndex,
221
+ parentIndexPath: indexPath,
222
+ parentPath: path,
223
+ parentSchemaPath: schemaPath
224
+ });
225
+ let tabFieldsPermissions = undefined;
226
+ // The tabs field does not have its own permissions as it's unnamed => use parentFieldsPermissions
227
+ if (typeof parentFieldsPermissions === 'boolean') {
228
+ tabFieldsPermissions = parentFieldsPermissions;
229
+ } else {
230
+ if ('name' in tab) {
231
+ const tabPermissions = parentFieldsPermissions?.[tab.name];
232
+ if (typeof tabPermissions === 'boolean') {
233
+ tabFieldsPermissions = tabPermissions;
234
+ } else {
235
+ tabFieldsPermissions = tabPermissions?.fields;
236
+ }
237
+ } else {
238
+ tabFieldsPermissions = parentFieldsPermissions;
149
239
  }
240
+ }
241
+ const tabVersion = {
242
+ name: 'name' in tab ? tab.name : null,
243
+ fields: buildVersionFields({
244
+ clientSchemaMap,
245
+ customDiffComponents,
246
+ entitySlug,
247
+ fields: tab.fields,
248
+ fieldsPermissions: tabFieldsPermissions,
249
+ i18n,
250
+ modifiedOnly,
251
+ nestingLevel: nestingLevel + 1,
252
+ parentIndexPath: isNamedTab ? '' : tabIndexPath,
253
+ parentIsLocalized: parentIsLocalized || tab.localized,
254
+ parentPath: isNamedTab ? tabPath : 'name' in field ? path : parentPath,
255
+ parentSchemaPath: tabSchemaPath,
256
+ req,
257
+ selectedLocales,
258
+ versionFromSiblingData: 'name' in tab ? valueFrom?.[tab.name] : valueFrom,
259
+ versionToSiblingData: 'name' in tab ? valueTo?.[tab.name] : valueTo
260
+ }).versionFields,
261
+ label: typeof tab.label === 'function' ? tab.label({
262
+ i18n,
263
+ t: i18n.t
264
+ }) : tab.label
265
+ };
266
+ if (tabVersion?.fields?.length) {
267
+ baseVersionField.tabs.push(tabVersion);
268
+ }
150
269
  }
151
- if (field?.admin?.components?.Diff) {
152
- CustomComponent = field.admin.components.Diff;
270
+ if (modifiedOnly && !baseVersionField.tabs.length) {
271
+ return null;
153
272
  }
154
- const DefaultComponent = diffComponents?.[field.type];
155
- const baseVersionField = {
156
- type: field.type,
157
- fields: [],
158
- path,
159
- schemaPath
160
- };
161
- if (field.type === 'tabs' && 'tabs' in field) {
162
- baseVersionField.tabs = [];
163
- let tabIndex = -1;
164
- for (const tab of field.tabs){
165
- tabIndex++;
166
- const isNamedTab = tabHasName(tab);
167
- const tabAsField = {
168
- ...tab,
169
- type: 'tab'
170
- };
171
- const { indexPath: tabIndexPath, path: tabPath, schemaPath: tabSchemaPath } = getFieldPaths({
172
- field: tabAsField,
173
- index: tabIndex,
174
- parentIndexPath: indexPath,
175
- parentPath: path,
176
- parentSchemaPath: schemaPath
177
- });
178
- let tabFieldsPermissions = undefined;
179
- // The tabs field does not have its own permissions as it's unnamed => use parentFieldsPermissions
180
- if (typeof parentFieldsPermissions === 'boolean') {
181
- tabFieldsPermissions = parentFieldsPermissions;
182
- } else {
183
- if ('name' in tab) {
184
- const tabPermissions = parentFieldsPermissions?.[tab.name];
185
- if (typeof tabPermissions === 'boolean') {
186
- tabFieldsPermissions = tabPermissions;
187
- } else {
188
- tabFieldsPermissions = tabPermissions?.fields;
189
- }
190
- } else {
191
- tabFieldsPermissions = parentFieldsPermissions;
192
- }
193
- }
194
- const tabVersion = {
195
- name: 'name' in tab ? tab.name : null,
196
- fields: buildVersionFields({
197
- clientSchemaMap,
198
- customDiffComponents,
199
- entitySlug,
200
- fields: tab.fields,
201
- fieldsPermissions: tabFieldsPermissions,
202
- i18n,
203
- modifiedOnly,
204
- nestingLevel: nestingLevel + 1,
205
- parentIndexPath: isNamedTab ? '' : tabIndexPath,
206
- parentIsLocalized: parentIsLocalized || tab.localized,
207
- parentPath: isNamedTab ? tabPath : 'name' in field ? path : parentPath,
208
- parentSchemaPath: tabSchemaPath,
209
- req,
210
- selectedLocales,
211
- versionFromSiblingData: 'name' in tab ? valueFrom?.[tab.name] : valueFrom,
212
- versionToSiblingData: 'name' in tab ? valueTo?.[tab.name] : valueTo
213
- }).versionFields,
214
- label: typeof tab.label === 'function' ? tab.label({
215
- i18n,
216
- t: i18n.t
217
- }) : tab.label
218
- };
219
- if (tabVersion?.fields?.length) {
220
- baseVersionField.tabs.push(tabVersion);
221
- }
222
- }
223
- if (modifiedOnly && !baseVersionField.tabs.length) {
224
- return null;
273
+ } else if ('fields' in field) {
274
+ let subFieldsPermissions = undefined;
275
+ if ('name' in field && typeof fieldPermissions !== 'undefined') {
276
+ // Named fields like arrays
277
+ subFieldsPermissions = typeof fieldPermissions === 'boolean' ? fieldPermissions : fieldPermissions.fields;
278
+ } else {
279
+ // Unnamed fields like collapsible and row inherit directly from parent permissions
280
+ subFieldsPermissions = parentFieldsPermissions;
281
+ }
282
+ if (field.type === 'array' && (valueTo || valueFrom)) {
283
+ const maxLength = Math.max(Array.isArray(valueTo) ? valueTo.length : 0, Array.isArray(valueFrom) ? valueFrom.length : 0);
284
+ baseVersionField.rows = [];
285
+ for (let i = 0; i < maxLength; i++) {
286
+ const fromRow = Array.isArray(valueFrom) && valueFrom?.[i] || {};
287
+ const toRow = Array.isArray(valueTo) && valueTo?.[i] || {};
288
+ const versionFields = buildVersionFields({
289
+ clientSchemaMap,
290
+ customDiffComponents,
291
+ entitySlug,
292
+ fields: field.fields,
293
+ fieldsPermissions: subFieldsPermissions,
294
+ i18n,
295
+ modifiedOnly,
296
+ nestingLevel: nestingLevel + 1,
297
+ parentIndexPath: 'name' in field ? '' : indexPath,
298
+ parentIsLocalized: parentIsLocalized || field.localized,
299
+ parentPath: ('name' in field ? path : parentPath) + '.' + i,
300
+ parentSchemaPath: schemaPath,
301
+ req,
302
+ selectedLocales,
303
+ versionFromSiblingData: fromRow,
304
+ versionToSiblingData: toRow
305
+ }).versionFields;
306
+ if (versionFields?.length) {
307
+ baseVersionField.rows[i] = versionFields;
225
308
  }
226
- } else // At this point, we are dealing with a `row`, `collapsible`, array`, etc
227
- if ('fields' in field) {
228
- let subFieldsPermissions = undefined;
229
- if ('name' in field && typeof fieldPermissions !== 'undefined') {
230
- // Named fields like arrays
231
- subFieldsPermissions = typeof fieldPermissions === 'boolean' ? fieldPermissions : fieldPermissions.fields;
309
+ }
310
+ if (!baseVersionField.rows?.length && modifiedOnly) {
311
+ return null;
312
+ }
313
+ } else {
314
+ baseVersionField.fields = buildVersionFields({
315
+ clientSchemaMap,
316
+ customDiffComponents,
317
+ entitySlug,
318
+ fields: field.fields,
319
+ fieldsPermissions: subFieldsPermissions,
320
+ i18n,
321
+ modifiedOnly,
322
+ nestingLevel: field.type !== 'row' ? nestingLevel + 1 : nestingLevel,
323
+ parentIndexPath: 'name' in field ? '' : indexPath,
324
+ parentIsLocalized: parentIsLocalized || 'localized' in field && field.localized,
325
+ parentPath: 'name' in field ? path : parentPath,
326
+ parentSchemaPath: schemaPath,
327
+ req,
328
+ selectedLocales,
329
+ versionFromSiblingData: valueFrom,
330
+ versionToSiblingData: valueTo
331
+ }).versionFields;
332
+ if (modifiedOnly && !baseVersionField.fields?.length) {
333
+ return null;
334
+ }
335
+ }
336
+ } else if (field.type === 'blocks') {
337
+ baseVersionField.rows = [];
338
+ const maxLength = Math.max(Array.isArray(valueTo) ? valueTo.length : 0, Array.isArray(valueFrom) ? valueFrom.length : 0);
339
+ for (let i = 0; i < maxLength; i++) {
340
+ const fromRow = Array.isArray(valueFrom) && valueFrom?.[i] || {};
341
+ const toRow = Array.isArray(valueTo) && valueTo?.[i] || {};
342
+ const blockSlugToMatch = toRow?.blockType ?? fromRow?.blockType;
343
+ const toBlock = req.payload.blocks[blockSlugToMatch] ?? (field.blockReferences ?? field.blocks).find(block => typeof block !== 'string' && block.slug === blockSlugToMatch);
344
+ let fields = [];
345
+ if (toRow.blockType === fromRow.blockType) {
346
+ fields = toBlock.fields;
347
+ } else {
348
+ const fromBlockSlugToMatch = toRow?.blockType ?? fromRow?.blockType;
349
+ const fromBlock = req.payload.blocks[fromBlockSlugToMatch] ?? (field.blockReferences ?? field.blocks).find(block => typeof block !== 'string' && block.slug === fromBlockSlugToMatch);
350
+ if (fromBlock) {
351
+ fields = getUniqueListBy([...toBlock.fields, ...fromBlock.fields], 'name');
232
352
  } else {
233
- // Unnamed fields like collapsible and row inherit directly from parent permissions
234
- subFieldsPermissions = parentFieldsPermissions;
353
+ fields = toBlock.fields;
235
354
  }
236
- if (field.type === 'array' && (valueTo || valueFrom)) {
237
- const maxLength = Math.max(Array.isArray(valueTo) ? valueTo.length : 0, Array.isArray(valueFrom) ? valueFrom.length : 0);
238
- baseVersionField.rows = [];
239
- for(let i = 0; i < maxLength; i++){
240
- const fromRow = Array.isArray(valueFrom) && valueFrom?.[i] || {};
241
- const toRow = Array.isArray(valueTo) && valueTo?.[i] || {};
242
- const versionFields = buildVersionFields({
243
- clientSchemaMap,
244
- customDiffComponents,
245
- entitySlug,
246
- fields: field.fields,
247
- fieldsPermissions: subFieldsPermissions,
248
- i18n,
249
- modifiedOnly,
250
- nestingLevel: nestingLevel + 1,
251
- parentIndexPath: 'name' in field ? '' : indexPath,
252
- parentIsLocalized: parentIsLocalized || field.localized,
253
- parentPath: ('name' in field ? path : parentPath) + '.' + i,
254
- parentSchemaPath: schemaPath,
255
- req,
256
- selectedLocales,
257
- versionFromSiblingData: fromRow,
258
- versionToSiblingData: toRow
259
- }).versionFields;
260
- if (versionFields?.length) {
261
- baseVersionField.rows[i] = versionFields;
262
- }
263
- }
264
- if (!baseVersionField.rows?.length && modifiedOnly) {
265
- return null;
266
- }
355
+ }
356
+ let blockFieldsPermissions = undefined;
357
+ // fieldPermissions will be set here, as the blocks field has a name
358
+ if (typeof fieldPermissions === 'boolean') {
359
+ blockFieldsPermissions = fieldPermissions;
360
+ } else if (typeof fieldPermissions?.blocks === 'boolean') {
361
+ blockFieldsPermissions = fieldPermissions.blocks;
362
+ } else {
363
+ const permissionsBlockSpecific = fieldPermissions?.blocks?.[blockSlugToMatch];
364
+ if (typeof permissionsBlockSpecific === 'boolean') {
365
+ blockFieldsPermissions = permissionsBlockSpecific;
267
366
  } else {
268
- baseVersionField.fields = buildVersionFields({
269
- clientSchemaMap,
270
- customDiffComponents,
271
- entitySlug,
272
- fields: field.fields,
273
- fieldsPermissions: subFieldsPermissions,
274
- i18n,
275
- modifiedOnly,
276
- nestingLevel: field.type !== 'row' ? nestingLevel + 1 : nestingLevel,
277
- parentIndexPath: 'name' in field ? '' : indexPath,
278
- parentIsLocalized: parentIsLocalized || 'localized' in field && field.localized,
279
- parentPath: 'name' in field ? path : parentPath,
280
- parentSchemaPath: schemaPath,
281
- req,
282
- selectedLocales,
283
- versionFromSiblingData: valueFrom,
284
- versionToSiblingData: valueTo
285
- }).versionFields;
286
- if (modifiedOnly && !baseVersionField.fields?.length) {
287
- return null;
288
- }
367
+ blockFieldsPermissions = permissionsBlockSpecific?.fields;
289
368
  }
290
- } else if (field.type === 'blocks') {
291
- baseVersionField.rows = [];
292
- const maxLength = Math.max(Array.isArray(valueTo) ? valueTo.length : 0, Array.isArray(valueFrom) ? valueFrom.length : 0);
293
- for(let i = 0; i < maxLength; i++){
294
- const fromRow = Array.isArray(valueFrom) && valueFrom?.[i] || {};
295
- const toRow = Array.isArray(valueTo) && valueTo?.[i] || {};
296
- const blockSlugToMatch = toRow?.blockType ?? fromRow?.blockType;
297
- const toBlock = req.payload.blocks[blockSlugToMatch] ?? (field.blockReferences ?? field.blocks).find((block)=>typeof block !== 'string' && block.slug === blockSlugToMatch);
298
- let fields = [];
299
- if (toRow.blockType === fromRow.blockType) {
300
- fields = toBlock.fields;
301
- } else {
302
- const fromBlockSlugToMatch = toRow?.blockType ?? fromRow?.blockType;
303
- const fromBlock = req.payload.blocks[fromBlockSlugToMatch] ?? (field.blockReferences ?? field.blocks).find((block)=>typeof block !== 'string' && block.slug === fromBlockSlugToMatch);
304
- if (fromBlock) {
305
- fields = getUniqueListBy([
306
- ...toBlock.fields,
307
- ...fromBlock.fields
308
- ], 'name');
309
- } else {
310
- fields = toBlock.fields;
311
- }
312
- }
313
- let blockFieldsPermissions = undefined;
314
- // fieldPermissions will be set here, as the blocks field has a name
315
- if (typeof fieldPermissions === 'boolean') {
316
- blockFieldsPermissions = fieldPermissions;
317
- } else if (typeof fieldPermissions?.blocks === 'boolean') {
318
- blockFieldsPermissions = fieldPermissions.blocks;
319
- } else {
320
- const permissionsBlockSpecific = fieldPermissions?.blocks?.[blockSlugToMatch];
321
- if (typeof permissionsBlockSpecific === 'boolean') {
322
- blockFieldsPermissions = permissionsBlockSpecific;
323
- } else {
324
- blockFieldsPermissions = permissionsBlockSpecific?.fields;
325
- }
326
- }
327
- const versionFields = buildVersionFields({
328
- clientSchemaMap,
329
- customDiffComponents,
330
- entitySlug,
331
- fields,
332
- fieldsPermissions: blockFieldsPermissions,
333
- i18n,
334
- modifiedOnly,
335
- nestingLevel: nestingLevel + 1,
336
- parentIndexPath: 'name' in field ? '' : indexPath,
337
- parentIsLocalized: parentIsLocalized || 'localized' in field && field.localized,
338
- parentPath: ('name' in field ? path : parentPath) + '.' + i,
339
- parentSchemaPath: schemaPath + '.' + toBlock.slug,
340
- req,
341
- selectedLocales,
342
- versionFromSiblingData: fromRow,
343
- versionToSiblingData: toRow
344
- }).versionFields;
345
- if (versionFields?.length) {
346
- baseVersionField.rows[i] = versionFields;
347
- }
348
- }
349
- if (!baseVersionField.rows?.length && modifiedOnly) {
350
- return null;
351
- }
352
- }
353
- const clientDiffProps = {
354
- baseVersionField: {
355
- ...baseVersionField,
356
- CustomComponent: undefined
357
- },
358
- /**
359
- * TODO: Change to valueFrom in 4.0
360
- */ comparisonValue: valueFrom,
361
- /**
362
- * @deprecated remove in 4.0. Each field should handle its own diffing logic
363
- */ diffMethod: 'diffWordsWithSpace',
364
- field: clientField,
365
- fieldPermissions: typeof fieldPermissions === 'undefined' ? parentFieldsPermissions : fieldPermissions,
366
- parentIsLocalized,
367
- nestingLevel: nestingLevel ? nestingLevel : undefined,
368
- /**
369
- * TODO: Change to valueTo in 4.0
370
- */ versionValue: valueTo
371
- };
372
- if (locale) {
373
- clientDiffProps.locale = locale;
374
- }
375
- const serverDiffProps = {
376
- ...clientDiffProps,
377
- clientField,
378
- field,
369
+ }
370
+ const versionFields = buildVersionFields({
371
+ clientSchemaMap,
372
+ customDiffComponents,
373
+ entitySlug,
374
+ fields,
375
+ fieldsPermissions: blockFieldsPermissions,
379
376
  i18n,
377
+ modifiedOnly,
378
+ nestingLevel: nestingLevel + 1,
379
+ parentIndexPath: 'name' in field ? '' : indexPath,
380
+ parentIsLocalized: parentIsLocalized || 'localized' in field && field.localized,
381
+ parentPath: ('name' in field ? path : parentPath) + '.' + i,
382
+ parentSchemaPath: schemaPath + '.' + toBlock.slug,
380
383
  req,
381
- selectedLocales
382
- };
383
- baseVersionField.CustomComponent = RenderServerComponent({
384
- clientProps: clientDiffProps,
385
- Component: CustomComponent,
386
- Fallback: DefaultComponent,
387
- importMap: req.payload.importMap,
388
- key: 'diff component',
389
- serverProps: serverDiffProps
390
- });
391
- return baseVersionField;
384
+ selectedLocales,
385
+ versionFromSiblingData: fromRow,
386
+ versionToSiblingData: toRow
387
+ }).versionFields;
388
+ if (versionFields?.length) {
389
+ baseVersionField.rows[i] = versionFields;
390
+ }
391
+ }
392
+ if (!baseVersionField.rows?.length && modifiedOnly) {
393
+ return null;
394
+ }
395
+ }
396
+ const clientDiffProps = {
397
+ baseVersionField: {
398
+ ...baseVersionField,
399
+ CustomComponent: undefined
400
+ },
401
+ /**
402
+ * TODO: Change to valueFrom in 4.0
403
+ */
404
+ comparisonValue: valueFrom,
405
+ /**
406
+ * @deprecated remove in 4.0. Each field should handle its own diffing logic
407
+ */
408
+ diffMethod: 'diffWordsWithSpace',
409
+ field: clientField,
410
+ fieldPermissions: typeof fieldPermissions === 'undefined' ? parentFieldsPermissions : fieldPermissions,
411
+ parentIsLocalized,
412
+ nestingLevel: nestingLevel ? nestingLevel : undefined,
413
+ /**
414
+ * TODO: Change to valueTo in 4.0
415
+ */
416
+ versionValue: valueTo
417
+ };
418
+ if (locale) {
419
+ clientDiffProps.locale = locale;
420
+ }
421
+ const serverDiffProps = {
422
+ ...clientDiffProps,
423
+ clientField,
424
+ field,
425
+ i18n,
426
+ req,
427
+ selectedLocales
428
+ };
429
+ baseVersionField.CustomComponent = RenderServerComponent({
430
+ clientProps: clientDiffProps,
431
+ Component: CustomComponent,
432
+ Fallback: DefaultComponent,
433
+ importMap: req.payload.importMap,
434
+ key: 'diff component',
435
+ serverProps: serverDiffProps
436
+ });
437
+ return baseVersionField;
392
438
  };
393
-
394
439
  //# sourceMappingURL=buildVersionFields.js.map