@payloadcms/next 3.78.0-internal-debug.f663370 → 3.78.0-internal.ab11ffa

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 (487) 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 +24 -65
  8. package/dist/cjs/withPayload.cjs.map +2 -2
  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.js +103 -128
  64. package/dist/layouts/Root/index.js.map +1 -1
  65. package/dist/prod/styles.css +1 -5
  66. package/dist/routes/graphql/handler.js +122 -114
  67. package/dist/routes/graphql/handler.js.map +1 -1
  68. package/dist/routes/graphql/index.js +0 -1
  69. package/dist/routes/graphql/index.js.map +1 -1
  70. package/dist/routes/graphql/playground.js +27 -28
  71. package/dist/routes/graphql/playground.js.map +1 -1
  72. package/dist/routes/index.js +0 -1
  73. package/dist/routes/index.js.map +1 -1
  74. package/dist/routes/rest/index.js +22 -23
  75. package/dist/routes/rest/index.js.map +1 -1
  76. package/dist/routes/rest/og/image.js +79 -103
  77. package/dist/routes/rest/og/image.js.map +1 -1
  78. package/dist/routes/rest/og/index.js +54 -59
  79. package/dist/routes/rest/og/index.js.map +1 -1
  80. package/dist/templates/Default/NavHamburger/index.js +20 -12
  81. package/dist/templates/Default/NavHamburger/index.js.map +1 -1
  82. package/dist/templates/Default/Wrapper/index.js +44 -20
  83. package/dist/templates/Default/Wrapper/index.js.map +1 -1
  84. package/dist/templates/Default/index.js +116 -147
  85. package/dist/templates/Default/index.js.map +1 -1
  86. package/dist/templates/Minimal/index.js +17 -26
  87. package/dist/templates/Minimal/index.js.map +1 -1
  88. package/dist/utilities/getExistingAuthToken.js +2 -3
  89. package/dist/utilities/getExistingAuthToken.js.map +1 -1
  90. package/dist/utilities/getNextRequestI18n.js +13 -12
  91. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  92. package/dist/utilities/getPayloadHMR.js +5 -5
  93. package/dist/utilities/getPayloadHMR.js.map +1 -1
  94. package/dist/utilities/getPreferences.js +22 -27
  95. package/dist/utilities/getPreferences.js.map +1 -1
  96. package/dist/utilities/getRequestLocale.js +14 -13
  97. package/dist/utilities/getRequestLocale.js.map +1 -1
  98. package/dist/utilities/getRequestTheme.js +19 -19
  99. package/dist/utilities/getRequestTheme.js.map +1 -1
  100. package/dist/utilities/getRouteWithoutAdmin.js +5 -3
  101. package/dist/utilities/getRouteWithoutAdmin.js.map +1 -1
  102. package/dist/utilities/handleAuthRedirect.js +36 -22
  103. package/dist/utilities/handleAuthRedirect.js.map +1 -1
  104. package/dist/utilities/handleServerFunctions.js +43 -33
  105. package/dist/utilities/handleServerFunctions.js.map +1 -1
  106. package/dist/utilities/initReq.js +96 -78
  107. package/dist/utilities/initReq.js.map +1 -1
  108. package/dist/utilities/isCustomAdminView.js +26 -22
  109. package/dist/utilities/isCustomAdminView.js.map +1 -1
  110. package/dist/utilities/isPublicAdminRoute.js +20 -26
  111. package/dist/utilities/isPublicAdminRoute.js.map +1 -1
  112. package/dist/utilities/meta.js +63 -68
  113. package/dist/utilities/meta.js.map +1 -1
  114. package/dist/utilities/selectiveCache.js +26 -25
  115. package/dist/utilities/selectiveCache.js.map +1 -1
  116. package/dist/utilities/setPayloadAuthCookie.js +22 -19
  117. package/dist/utilities/setPayloadAuthCookie.js.map +1 -1
  118. package/dist/utilities/slugify.js +33 -24
  119. package/dist/utilities/slugify.js.map +1 -1
  120. package/dist/utilities/timestamp.js +6 -7
  121. package/dist/utilities/timestamp.js.map +1 -1
  122. package/dist/views/API/LocaleSelector/index.js +39 -17
  123. package/dist/views/API/LocaleSelector/index.js.map +1 -1
  124. package/dist/views/API/RenderJSON/index.js +126 -171
  125. package/dist/views/API/RenderJSON/index.js.map +1 -1
  126. package/dist/views/API/index.client.js +199 -291
  127. package/dist/views/API/index.client.js.map +1 -1
  128. package/dist/views/API/index.js +2 -7
  129. package/dist/views/API/index.js.map +1 -1
  130. package/dist/views/API/metadata.js +23 -18
  131. package/dist/views/API/metadata.js.map +1 -1
  132. package/dist/views/Account/ResetPreferences/index.js +102 -78
  133. package/dist/views/Account/ResetPreferences/index.js.map +1 -1
  134. package/dist/views/Account/Settings/LanguageSelector.js +47 -18
  135. package/dist/views/Account/Settings/LanguageSelector.js.map +1 -1
  136. package/dist/views/Account/Settings/index.js +25 -60
  137. package/dist/views/Account/Settings/index.js.map +1 -1
  138. package/dist/views/Account/ToggleTheme/index.js +55 -38
  139. package/dist/views/Account/ToggleTheme/index.js.map +1 -1
  140. package/dist/views/Account/index.client.js +32 -16
  141. package/dist/views/Account/index.client.js.map +1 -1
  142. package/dist/views/Account/index.d.ts.map +1 -1
  143. package/dist/views/Account/index.js +162 -147
  144. package/dist/views/Account/index.js.map +1 -1
  145. package/dist/views/Account/metadata.js +12 -8
  146. package/dist/views/Account/metadata.js.map +1 -1
  147. package/dist/views/BrowseByFolder/buildView.js +157 -138
  148. package/dist/views/BrowseByFolder/buildView.js.map +1 -1
  149. package/dist/views/BrowseByFolder/index.js +16 -16
  150. package/dist/views/BrowseByFolder/index.js.map +1 -1
  151. package/dist/views/BrowseByFolder/metadata.js +15 -13
  152. package/dist/views/BrowseByFolder/metadata.js.map +1 -1
  153. package/dist/views/CollectionFolders/buildView.js +142 -122
  154. package/dist/views/CollectionFolders/buildView.js.map +1 -1
  155. package/dist/views/CollectionFolders/index.js +16 -16
  156. package/dist/views/CollectionFolders/index.js.map +1 -1
  157. package/dist/views/CollectionFolders/metadata.js +21 -18
  158. package/dist/views/CollectionFolders/metadata.js.map +1 -1
  159. package/dist/views/CollectionFolders/renderFolderViewSlots.js +61 -58
  160. package/dist/views/CollectionFolders/renderFolderViewSlots.js.map +1 -1
  161. package/dist/views/CollectionTrash/index.js +17 -17
  162. package/dist/views/CollectionTrash/index.js.map +1 -1
  163. package/dist/views/CollectionTrash/metadata.js +21 -18
  164. package/dist/views/CollectionTrash/metadata.js.map +1 -1
  165. package/dist/views/CreateFirstUser/index.client.js +103 -117
  166. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  167. package/dist/views/CreateFirstUser/index.js +81 -87
  168. package/dist/views/CreateFirstUser/index.js.map +1 -1
  169. package/dist/views/CreateFirstUser/metadata.js +12 -8
  170. package/dist/views/CreateFirstUser/metadata.js.map +1 -1
  171. package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js +174 -151
  172. package/dist/views/Dashboard/Default/ModularDashboard/DashboardStepNav.js.map +1 -1
  173. package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.d.ts +11 -0
  174. package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.d.ts.map +1 -0
  175. package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.js +128 -0
  176. package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.js.map +1 -0
  177. package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.d.ts +8 -0
  178. package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.d.ts.map +1 -0
  179. package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.js +78 -0
  180. package/dist/views/Dashboard/Default/ModularDashboard/WidgetEditControl.js.map +1 -0
  181. package/dist/views/Dashboard/Default/ModularDashboard/index.client.d.ts +1 -0
  182. package/dist/views/Dashboard/Default/ModularDashboard/index.client.d.ts.map +1 -1
  183. package/dist/views/Dashboard/Default/ModularDashboard/index.client.js +415 -423
  184. package/dist/views/Dashboard/Default/ModularDashboard/index.client.js.map +1 -1
  185. package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
  186. package/dist/views/Dashboard/Default/ModularDashboard/index.js +66 -82
  187. package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
  188. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.d.ts +1 -0
  189. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.d.ts.map +1 -1
  190. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js +95 -61
  191. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js.map +1 -1
  192. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
  193. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +54 -43
  194. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
  195. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts +1 -0
  196. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
  197. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +73 -67
  198. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
  199. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.d.ts +1 -0
  200. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.d.ts.map +1 -1
  201. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js +173 -173
  202. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js.map +1 -1
  203. package/dist/views/Dashboard/Default/ModularDashboard/utils/collisionDetection.js +30 -31
  204. package/dist/views/Dashboard/Default/ModularDashboard/utils/collisionDetection.js.map +1 -1
  205. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromConfig.d.ts +4 -0
  206. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromConfig.d.ts.map +1 -0
  207. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromConfig.js +21 -0
  208. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromConfig.js.map +1 -0
  209. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.d.ts +4 -0
  210. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.d.ts.map +1 -0
  211. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.js +10 -0
  212. package/dist/views/Dashboard/Default/ModularDashboard/utils/getItemsFromPreferences.js.map +1 -0
  213. package/dist/views/Dashboard/Default/ModularDashboard/utils/localeUtils.d.ts +23 -0
  214. package/dist/views/Dashboard/Default/ModularDashboard/utils/localeUtils.d.ts.map +1 -0
  215. package/dist/views/Dashboard/Default/ModularDashboard/utils/localeUtils.js +103 -0
  216. package/dist/views/Dashboard/Default/ModularDashboard/utils/localeUtils.js.map +1 -0
  217. package/dist/views/Dashboard/Default/ModularDashboard/utils/sensors.js +229 -223
  218. package/dist/views/Dashboard/Default/ModularDashboard/utils/sensors.js.map +1 -1
  219. package/dist/views/Dashboard/Default/index.js +45 -59
  220. package/dist/views/Dashboard/Default/index.js.map +1 -1
  221. package/dist/views/Dashboard/index.js +42 -46
  222. package/dist/views/Dashboard/index.js.map +1 -1
  223. package/dist/views/Dashboard/metadata.js +14 -10
  224. package/dist/views/Dashboard/metadata.js.map +1 -1
  225. package/dist/views/Document/getCustomDocumentViewByKey.js +2 -3
  226. package/dist/views/Document/getCustomDocumentViewByKey.js.map +1 -1
  227. package/dist/views/Document/getCustomViewByRoute.js +30 -27
  228. package/dist/views/Document/getCustomViewByRoute.js.map +1 -1
  229. package/dist/views/Document/getDocPreferences.js +41 -40
  230. package/dist/views/Document/getDocPreferences.js.map +1 -1
  231. package/dist/views/Document/getDocumentData.js +55 -44
  232. package/dist/views/Document/getDocumentData.js.map +1 -1
  233. package/dist/views/Document/getDocumentPermissions.d.ts +2 -0
  234. package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -1
  235. package/dist/views/Document/getDocumentPermissions.js +117 -77
  236. package/dist/views/Document/getDocumentPermissions.js.map +1 -1
  237. package/dist/views/Document/getDocumentView.js +283 -313
  238. package/dist/views/Document/getDocumentView.js.map +1 -1
  239. package/dist/views/Document/getIsLocked.js +73 -73
  240. package/dist/views/Document/getIsLocked.js.map +1 -1
  241. package/dist/views/Document/getMetaBySegment.js +136 -130
  242. package/dist/views/Document/getMetaBySegment.js.map +1 -1
  243. package/dist/views/Document/getVersions.js +213 -220
  244. package/dist/views/Document/getVersions.js.map +1 -1
  245. package/dist/views/Document/handleServerFunction.js +127 -100
  246. package/dist/views/Document/handleServerFunction.js.map +1 -1
  247. package/dist/views/Document/index.d.ts.map +1 -1
  248. package/dist/views/Document/index.js +359 -317
  249. package/dist/views/Document/index.js.map +1 -1
  250. package/dist/views/Document/metadata.js +1 -2
  251. package/dist/views/Document/metadata.js.map +1 -1
  252. package/dist/views/Document/renderDocumentSlots.js +155 -141
  253. package/dist/views/Document/renderDocumentSlots.js.map +1 -1
  254. package/dist/views/Edit/index.js +6 -10
  255. package/dist/views/Edit/index.js.map +1 -1
  256. package/dist/views/Edit/metadata.js +46 -36
  257. package/dist/views/Edit/metadata.js.map +1 -1
  258. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +164 -130
  259. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
  260. package/dist/views/ForgotPassword/index.js +62 -79
  261. package/dist/views/ForgotPassword/index.js.map +1 -1
  262. package/dist/views/ForgotPassword/metadata.js +12 -8
  263. package/dist/views/ForgotPassword/metadata.js.map +1 -1
  264. package/dist/views/List/createSerializableValue.js +11 -12
  265. package/dist/views/List/createSerializableValue.js.map +1 -1
  266. package/dist/views/List/enrichDocsWithVersionStatus.js +86 -86
  267. package/dist/views/List/enrichDocsWithVersionStatus.js.map +1 -1
  268. package/dist/views/List/extractRelationshipDisplayValue.js +14 -15
  269. package/dist/views/List/extractRelationshipDisplayValue.js.map +1 -1
  270. package/dist/views/List/extractValueOrRelationshipID.js +15 -16
  271. package/dist/views/List/extractValueOrRelationshipID.js.map +1 -1
  272. package/dist/views/List/handleGroupBy.js +150 -133
  273. package/dist/views/List/handleGroupBy.js.map +1 -1
  274. package/dist/views/List/handleServerFunction.js +122 -96
  275. package/dist/views/List/handleServerFunction.js.map +1 -1
  276. package/dist/views/List/index.d.ts.map +1 -1
  277. package/dist/views/List/index.js +328 -302
  278. package/dist/views/List/index.js.map +1 -1
  279. package/dist/views/List/metadata.js +20 -17
  280. package/dist/views/List/metadata.js.map +1 -1
  281. package/dist/views/List/renderListViewSlots.js +75 -82
  282. package/dist/views/List/renderListViewSlots.js.map +1 -1
  283. package/dist/views/List/resolveAllFilterOptions.js +45 -43
  284. package/dist/views/List/resolveAllFilterOptions.js.map +1 -1
  285. package/dist/views/List/transformColumnsToSelect.js +8 -9
  286. package/dist/views/List/transformColumnsToSelect.js.map +1 -1
  287. package/dist/views/Login/LoginField/index.js +89 -57
  288. package/dist/views/Login/LoginField/index.js.map +1 -1
  289. package/dist/views/Login/LoginForm/index.js +160 -107
  290. package/dist/views/Login/LoginForm/index.js.map +1 -1
  291. package/dist/views/Login/index.js +85 -82
  292. package/dist/views/Login/index.js.map +1 -1
  293. package/dist/views/Login/metadata.js +12 -8
  294. package/dist/views/Login/metadata.js.map +1 -1
  295. package/dist/views/Logout/LogoutClient.js +120 -84
  296. package/dist/views/Logout/LogoutClient.js.map +1 -1
  297. package/dist/views/Logout/index.js +29 -29
  298. package/dist/views/Logout/index.js.map +1 -1
  299. package/dist/views/Logout/metadata.js +11 -7
  300. package/dist/views/Logout/metadata.js.map +1 -1
  301. package/dist/views/NotFound/index.client.js +82 -71
  302. package/dist/views/NotFound/index.client.js.map +1 -1
  303. package/dist/views/NotFound/index.js +73 -72
  304. package/dist/views/NotFound/index.js.map +1 -1
  305. package/dist/views/NotFound/metadata.js +9 -7
  306. package/dist/views/NotFound/metadata.js.map +1 -1
  307. package/dist/views/ResetPassword/ResetPasswordForm/index.js +108 -97
  308. package/dist/views/ResetPassword/ResetPasswordForm/index.js.map +1 -1
  309. package/dist/views/ResetPassword/index.js +73 -93
  310. package/dist/views/ResetPassword/index.js.map +1 -1
  311. package/dist/views/ResetPassword/metadata.js +12 -8
  312. package/dist/views/ResetPassword/metadata.js.map +1 -1
  313. package/dist/views/Root/attachViewActions.js +23 -18
  314. package/dist/views/Root/attachViewActions.js.map +1 -1
  315. package/dist/views/Root/generateCustomViewMetadata.js +21 -19
  316. package/dist/views/Root/generateCustomViewMetadata.js.map +1 -1
  317. package/dist/views/Root/getCustomViewByKey.js +14 -12
  318. package/dist/views/Root/getCustomViewByKey.js.map +1 -1
  319. package/dist/views/Root/getCustomViewByRoute.js +42 -31
  320. package/dist/views/Root/getCustomViewByRoute.js.map +1 -1
  321. package/dist/views/Root/getDocumentViewInfo.js +23 -24
  322. package/dist/views/Root/getDocumentViewInfo.js.map +1 -1
  323. package/dist/views/Root/getRouteData.js +325 -333
  324. package/dist/views/Root/getRouteData.js.map +1 -1
  325. package/dist/views/Root/index.js +270 -248
  326. package/dist/views/Root/index.js.map +1 -1
  327. package/dist/views/Root/isPathMatchingRoute.js +26 -21
  328. package/dist/views/Root/isPathMatchingRoute.js.map +1 -1
  329. package/dist/views/Root/metadata.js +181 -176
  330. package/dist/views/Root/metadata.js.map +1 -1
  331. package/dist/views/Unauthorized/index.js +46 -54
  332. package/dist/views/Unauthorized/index.js.map +1 -1
  333. package/dist/views/Unauthorized/metadata.js +12 -8
  334. package/dist/views/Unauthorized/metadata.js.map +1 -1
  335. package/dist/views/Verify/index.client.js +43 -25
  336. package/dist/views/Verify/index.client.js.map +1 -1
  337. package/dist/views/Verify/index.js +64 -69
  338. package/dist/views/Verify/index.js.map +1 -1
  339. package/dist/views/Verify/metadata.js +12 -8
  340. package/dist/views/Verify/metadata.js.map +1 -1
  341. package/dist/views/Version/Default/SelectedLocalesContext.js +4 -4
  342. package/dist/views/Version/Default/SelectedLocalesContext.js.map +1 -1
  343. package/dist/views/Version/Default/SetStepNav.js +127 -86
  344. package/dist/views/Version/Default/SetStepNav.js.map +1 -1
  345. package/dist/views/Version/Default/index.js +236 -380
  346. package/dist/views/Version/Default/index.js.map +1 -1
  347. package/dist/views/Version/Default/types.js +1 -2
  348. package/dist/views/Version/Default/types.js.map +1 -1
  349. package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js +119 -102
  350. package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js.map +1 -1
  351. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js +73 -78
  352. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js.map +1 -1
  353. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +408 -363
  354. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -1
  355. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js +51 -40
  356. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js.map +1 -1
  357. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.d.ts.map +1 -1
  358. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.js +71 -36
  359. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.js.map +1 -1
  360. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js +56 -59
  361. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js.map +1 -1
  362. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +117 -139
  363. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
  364. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js +61 -56
  365. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js.map +1 -1
  366. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +206 -224
  367. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
  368. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js +11 -17
  369. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js.map +1 -1
  370. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts.map +1 -1
  371. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +75 -49
  372. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
  373. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +146 -135
  374. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
  375. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts.map +1 -1
  376. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +83 -57
  377. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
  378. package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js +211 -252
  379. package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js.map +1 -1
  380. package/dist/views/Version/RenderFieldsToDiff/fields/index.js +22 -23
  381. package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
  382. package/dist/views/Version/RenderFieldsToDiff/index.js +9 -12
  383. package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
  384. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js +228 -213
  385. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js.map +1 -1
  386. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js +826 -1005
  387. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js.map +1 -1
  388. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.js +1 -2
  389. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.js.map +1 -1
  390. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js +43 -44
  391. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js.map +1 -1
  392. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js +36 -32
  393. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js.map +1 -1
  394. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +129 -145
  395. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +1 -1
  396. package/dist/views/Version/Restore/index.d.ts.map +1 -1
  397. package/dist/views/Version/Restore/index.js +92 -117
  398. package/dist/views/Version/Restore/index.js.map +1 -1
  399. package/dist/views/Version/SelectComparison/VersionDrawer/CreatedAtCell.js +50 -33
  400. package/dist/views/Version/SelectComparison/VersionDrawer/CreatedAtCell.js.map +1 -1
  401. package/dist/views/Version/SelectComparison/VersionDrawer/index.js +226 -170
  402. package/dist/views/Version/SelectComparison/VersionDrawer/index.js.map +1 -1
  403. package/dist/views/Version/SelectComparison/index.js +50 -73
  404. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  405. package/dist/views/Version/SelectComparison/types.js +1 -2
  406. package/dist/views/Version/SelectComparison/types.js.map +1 -1
  407. package/dist/views/Version/SelectLocales/index.js +32 -34
  408. package/dist/views/Version/SelectLocales/index.js.map +1 -1
  409. package/dist/views/Version/VersionPillLabel/VersionPillLabel.js +100 -106
  410. package/dist/views/Version/VersionPillLabel/VersionPillLabel.js.map +1 -1
  411. package/dist/views/Version/VersionPillLabel/getVersionLabel.js +35 -30
  412. package/dist/views/Version/VersionPillLabel/getVersionLabel.js.map +1 -1
  413. package/dist/views/Version/fetchVersions.js +138 -113
  414. package/dist/views/Version/fetchVersions.js.map +1 -1
  415. package/dist/views/Version/index.js +326 -328
  416. package/dist/views/Version/index.js.map +1 -1
  417. package/dist/views/Version/metadata.js +50 -43
  418. package/dist/views/Version/metadata.js.map +1 -1
  419. package/dist/views/Versions/buildColumns.js +79 -95
  420. package/dist/views/Versions/buildColumns.js.map +1 -1
  421. package/dist/views/Versions/cells/AutosaveCell/index.js +38 -34
  422. package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
  423. package/dist/views/Versions/cells/CreatedAt/index.js +53 -32
  424. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  425. package/dist/views/Versions/cells/ID/index.js +8 -10
  426. package/dist/views/Versions/cells/ID/index.js.map +1 -1
  427. package/dist/views/Versions/index.client.js +83 -106
  428. package/dist/views/Versions/index.client.js.map +1 -1
  429. package/dist/views/Versions/index.js +164 -164
  430. package/dist/views/Versions/index.js.map +1 -1
  431. package/dist/views/Versions/metadata.js +44 -37
  432. package/dist/views/Versions/metadata.js.map +1 -1
  433. package/dist/views/Versions/types.js +1 -2
  434. package/dist/views/Versions/types.js.map +1 -1
  435. package/dist/withPayload/withPayload.js +177 -236
  436. package/dist/withPayload/withPayload.js.map +1 -1
  437. package/dist/withPayload/withPayload.spec.js +35 -36
  438. package/dist/withPayload/withPayload.spec.js.map +1 -1
  439. package/dist/withPayload/withPayload.utils.js +73 -65
  440. package/dist/withPayload/withPayload.utils.js.map +1 -1
  441. package/dist/withPayload/withPayloadLegacy.js +40 -41
  442. package/dist/withPayload/withPayloadLegacy.js.map +1 -1
  443. package/package.json +8 -8
  444. package/dist/elements/DocumentHeader/Tabs/Tab/index.scss +0 -38
  445. package/dist/elements/DocumentHeader/Tabs/index.scss +0 -54
  446. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.scss +0 -10
  447. package/dist/elements/DocumentHeader/index.scss +0 -64
  448. package/dist/elements/FormHeader/index.scss +0 -8
  449. package/dist/elements/Nav/NavWrapper/index.scss +0 -27
  450. package/dist/elements/Nav/SettingsMenuButton/index.scss +0 -11
  451. package/dist/elements/Nav/index.scss +0 -173
  452. package/dist/esbuildEntry.d.ts +0 -5
  453. package/dist/esbuildEntry.d.ts.map +0 -1
  454. package/dist/esbuildEntry.js +0 -6
  455. package/dist/esbuildEntry.js.map +0 -1
  456. package/dist/templates/Default/Wrapper/index.scss +0 -58
  457. package/dist/templates/Default/index.scss +0 -79
  458. package/dist/templates/Minimal/index.scss +0 -30
  459. package/dist/views/API/RenderJSON/index.scss +0 -129
  460. package/dist/views/API/index.scss +0 -119
  461. package/dist/views/Account/Settings/index.scss +0 -48
  462. package/dist/views/CreateFirstUser/index.scss +0 -21
  463. package/dist/views/Dashboard/Default/ModularDashboard/index.scss +0 -316
  464. package/dist/views/Login/LoginForm/index.scss +0 -10
  465. package/dist/views/Login/index.scss +0 -10
  466. package/dist/views/Logout/index.scss +0 -25
  467. package/dist/views/NotFound/index.scss +0 -57
  468. package/dist/views/ResetPassword/index.scss +0 -11
  469. package/dist/views/Unauthorized/index.scss +0 -14
  470. package/dist/views/Verify/index.scss +0 -16
  471. package/dist/views/Version/Default/index.scss +0 -170
  472. package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.scss +0 -81
  473. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.scss +0 -12
  474. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.scss +0 -9
  475. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.scss +0 -59
  476. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.scss +0 -91
  477. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.scss +0 -4
  478. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.scss +0 -9
  479. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.scss +0 -4
  480. package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.scss +0 -121
  481. package/dist/views/Version/RenderFieldsToDiff/index.scss +0 -24
  482. package/dist/views/Version/Restore/index.scss +0 -84
  483. package/dist/views/Version/SelectComparison/VersionDrawer/index.scss +0 -18
  484. package/dist/views/Version/SelectComparison/index.scss +0 -9
  485. package/dist/views/Version/VersionPillLabel/index.scss +0 -26
  486. package/dist/views/Versions/cells/AutosaveCell/index.scss +0 -9
  487. 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