@pantheon-systems/puck-css 0.12.0 → 0.14.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 (559) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/components/AgentActionButton.js +0 -13
  3. package/dist/agent/components/AgentActionButton.js.map +1 -1
  4. package/dist/agent/components/AgentActionModal.js +0 -13
  5. package/dist/agent/components/AgentActionModal.js.map +1 -1
  6. package/dist/agent/components/AgentStatusPanel.js +0 -10
  7. package/dist/agent/components/AgentStatusPanel.js.map +1 -1
  8. package/dist/agent/components/index.js +0 -5
  9. package/dist/agent/components/index.js.map +1 -1
  10. package/dist/agent/useAgentEdit.js +0 -12
  11. package/dist/agent/useAgentEdit.js.map +1 -1
  12. package/dist/agent/useAgentTrigger.js +0 -29
  13. package/dist/agent/useAgentTrigger.js.map +1 -1
  14. package/dist/auth/P1AuthProvider.d.ts +9 -2
  15. package/dist/auth/P1AuthProvider.d.ts.map +1 -1
  16. package/dist/auth/P1AuthProvider.js +21 -44
  17. package/dist/auth/P1AuthProvider.js.map +1 -1
  18. package/dist/auth/P1LoginPage.js +0 -18
  19. package/dist/auth/P1LoginPage.js.map +1 -1
  20. package/dist/auth/index.d.ts +2 -0
  21. package/dist/auth/index.d.ts.map +1 -1
  22. package/dist/auth/index.js +1 -9
  23. package/dist/auth/index.js.map +1 -1
  24. package/dist/auth/logout.d.ts +23 -0
  25. package/dist/auth/logout.d.ts.map +1 -0
  26. package/dist/auth/logout.js +14 -0
  27. package/dist/auth/logout.js.map +1 -0
  28. package/dist/auth/storage-keys.d.ts +5 -0
  29. package/dist/auth/storage-keys.d.ts.map +1 -0
  30. package/dist/auth/storage-keys.js +3 -0
  31. package/dist/auth/storage-keys.js.map +1 -0
  32. package/dist/collaboration/components/AgentActivityBanner.js +0 -15
  33. package/dist/collaboration/components/AgentActivityBanner.js.map +1 -1
  34. package/dist/collaboration/components/CollaboratorAvatars.js +0 -17
  35. package/dist/collaboration/components/CollaboratorAvatars.js.map +1 -1
  36. package/dist/collaboration/components/FocusRegionHighlight.js +0 -9
  37. package/dist/collaboration/components/FocusRegionHighlight.js.map +1 -1
  38. package/dist/collaboration/components/PresenceIndicator.js +0 -9
  39. package/dist/collaboration/components/PresenceIndicator.js.map +1 -1
  40. package/dist/collaboration/useBranchPresence.js +0 -36
  41. package/dist/collaboration/useBranchPresence.js.map +1 -1
  42. package/dist/collaboration/useFocusRegionReporting.js +0 -75
  43. package/dist/collaboration/useFocusRegionReporting.js.map +1 -1
  44. package/dist/collaboration/usePresence.js +0 -37
  45. package/dist/collaboration/usePresence.js.map +1 -1
  46. package/dist/collaboration/useSitePresence.js +0 -36
  47. package/dist/collaboration/useSitePresence.js.map +1 -1
  48. package/dist/collaboration/utils/avatarColor.js +0 -3
  49. package/dist/collaboration/utils/avatarColor.js.map +1 -1
  50. package/dist/collaboration/utils/focusHighlightConfig.js +0 -61
  51. package/dist/collaboration/utils/focusHighlightConfig.js.map +1 -1
  52. package/dist/collaboration/utils/focusRegionMap.js +1 -80
  53. package/dist/collaboration/utils/focusRegionMap.js.map +1 -1
  54. package/dist/collaboration/utils/initials.js +0 -14
  55. package/dist/collaboration/utils/initials.js.map +1 -1
  56. package/dist/collaboration/utils/presenceIdentity.js +0 -26
  57. package/dist/collaboration/utils/presenceIdentity.js.map +1 -1
  58. package/dist/core/FocusHighlightContext.js +0 -31
  59. package/dist/core/FocusHighlightContext.js.map +1 -1
  60. package/dist/core/NotificationContext.js +2 -67
  61. package/dist/core/NotificationContext.js.map +1 -1
  62. package/dist/core/P1PuckContext.js +0 -31
  63. package/dist/core/P1PuckContext.js.map +1 -1
  64. package/dist/core/PresenceContext.js +0 -18
  65. package/dist/core/PresenceContext.js.map +1 -1
  66. package/dist/core/config.js +0 -11
  67. package/dist/core/config.js.map +1 -1
  68. package/dist/core/featureConfig.js +0 -32
  69. package/dist/core/featureConfig.js.map +1 -1
  70. package/dist/core/index.d.ts +1 -1
  71. package/dist/core/index.d.ts.map +1 -1
  72. package/dist/core/plugin-types.d.ts +9 -0
  73. package/dist/core/plugin-types.d.ts.map +1 -1
  74. package/dist/core/types.d.ts +7 -1
  75. package/dist/core/types.d.ts.map +1 -1
  76. package/dist/core/types.js +0 -3
  77. package/dist/core/types.js.map +1 -1
  78. package/dist/core/utils/debounce.js +0 -18
  79. package/dist/core/utils/debounce.js.map +1 -1
  80. package/dist/core/utils/requestError.js +0 -5
  81. package/dist/core/utils/requestError.js.map +1 -1
  82. package/dist/core/utils/retry.js +0 -31
  83. package/dist/core/utils/retry.js.map +1 -1
  84. package/dist/core/utils/throttle.js +0 -24
  85. package/dist/core/utils/throttle.js.map +1 -1
  86. package/dist/data/cross-reference-resolve.js +0 -6
  87. package/dist/data/cross-reference-resolve.js.map +1 -1
  88. package/dist/data/cross-reference.js +0 -15
  89. package/dist/data/cross-reference.js.map +1 -1
  90. package/dist/data/css-queries/css-query-registry.d.ts +2 -2
  91. package/dist/data/css-queries/css-query-registry.js +1 -1
  92. package/dist/data/css-queries/css-query-registry.js.map +1 -1
  93. package/dist/data/dal/index.js +0 -21
  94. package/dist/data/dal/index.js.map +1 -1
  95. package/dist/data/dal/init.js +0 -40
  96. package/dist/data/dal/init.js.map +1 -1
  97. package/dist/data/dal/p1-store.d.ts.map +1 -1
  98. package/dist/data/dal/p1-store.js +11 -41
  99. package/dist/data/dal/p1-store.js.map +1 -1
  100. package/dist/data/data-list-block/builtin-components/cards.d.ts +1 -0
  101. package/dist/data/data-list-block/builtin-components/cards.d.ts.map +1 -1
  102. package/dist/data/data-list-block/builtin-components/cards.js +16 -16
  103. package/dist/data/data-list-block/builtin-components/cards.js.map +1 -1
  104. package/dist/data/data-list-block/builtin-components/listing.d.ts +1 -0
  105. package/dist/data/data-list-block/builtin-components/listing.d.ts.map +1 -1
  106. package/dist/data/data-list-block/builtin-components/listing.js +4 -3
  107. package/dist/data/data-list-block/builtin-components/listing.js.map +1 -1
  108. package/dist/data/data-list-block/builtin-components/rows.d.ts +1 -0
  109. package/dist/data/data-list-block/builtin-components/rows.d.ts.map +1 -1
  110. package/dist/data/data-list-block/builtin-components/rows.js +3 -3
  111. package/dist/data/data-list-block/builtin-components/rows.js.map +1 -1
  112. package/dist/data/data-list-block/create-data-list-block.d.ts +1 -0
  113. package/dist/data/data-list-block/create-data-list-block.d.ts.map +1 -1
  114. package/dist/data/data-list-block/create-data-list-block.js +7 -11
  115. package/dist/data/data-list-block/create-data-list-block.js.map +1 -1
  116. package/dist/data/data-list-block/data-list.css +314 -0
  117. package/dist/data/data-list-block/utils.js +0 -1
  118. package/dist/data/data-list-block/utils.js.map +1 -1
  119. package/dist/data/fields/pds-field-helpers.js +1 -4
  120. package/dist/data/fields/pds-field-helpers.js.map +1 -1
  121. package/dist/data/fields/visible-when.js +0 -5
  122. package/dist/data/fields/visible-when.js.map +1 -1
  123. package/dist/data/fields.d.ts.map +1 -1
  124. package/dist/data/fields.js +7 -14
  125. package/dist/data/fields.js.map +1 -1
  126. package/dist/data/get-page.js +0 -1
  127. package/dist/data/get-page.js.map +1 -1
  128. package/dist/data/page-editor-meta.js +0 -7
  129. package/dist/data/page-editor-meta.js.map +1 -1
  130. package/dist/data/page-store.js +0 -32
  131. package/dist/data/page-store.js.map +1 -1
  132. package/dist/data/page-structure.js +0 -3
  133. package/dist/data/page-structure.js.map +1 -1
  134. package/dist/data/paths.d.ts +6 -0
  135. package/dist/data/paths.d.ts.map +1 -1
  136. package/dist/data/paths.js +3 -16
  137. package/dist/data/paths.js.map +1 -1
  138. package/dist/data/query-provider.d.ts +14 -0
  139. package/dist/data/query-provider.d.ts.map +1 -1
  140. package/dist/data/query-provider.js +20 -9
  141. package/dist/data/query-provider.js.map +1 -1
  142. package/dist/data/remote-datasources/fetch-http-json.js +0 -5
  143. package/dist/data/remote-datasources/fetch-http-json.js.map +1 -1
  144. package/dist/data/remote-datasources/loader.js +0 -21
  145. package/dist/data/remote-datasources/loader.js.map +1 -1
  146. package/dist/data/remote-datasources/remote-datasource-registry.js +0 -4
  147. package/dist/data/remote-datasources/remote-datasource-registry.js.map +1 -1
  148. package/dist/data/resolve-data-templates.js +0 -24
  149. package/dist/data/resolve-data-templates.js.map +1 -1
  150. package/dist/data/route-templates.js +0 -29
  151. package/dist/data/route-templates.js.map +1 -1
  152. package/dist/data/semantic-ops.js +0 -11
  153. package/dist/data/semantic-ops.js.map +1 -1
  154. package/dist/data/styles.js +0 -2
  155. package/dist/data/styles.js.map +1 -1
  156. package/dist/data/template-autocomplete.js +0 -8
  157. package/dist/data/template-autocomplete.js.map +1 -1
  158. package/dist/data/utils.d.ts +16 -0
  159. package/dist/data/utils.d.ts.map +1 -1
  160. package/dist/data/utils.js +21 -1
  161. package/dist/data/utils.js.map +1 -1
  162. package/dist/editor/P1App.d.ts.map +1 -1
  163. package/dist/editor/P1App.js +6 -45
  164. package/dist/editor/P1App.js.map +1 -1
  165. package/dist/editor/P1PuckProvider.d.ts +1 -1
  166. package/dist/editor/P1PuckProvider.d.ts.map +1 -1
  167. package/dist/editor/P1PuckProvider.js +54 -561
  168. package/dist/editor/P1PuckProvider.js.map +1 -1
  169. package/dist/editor/aiPanelStore.js +0 -7
  170. package/dist/editor/aiPanelStore.js.map +1 -1
  171. package/dist/editor/components/BranchSelector.js +0 -21
  172. package/dist/editor/components/BranchSelector.js.map +1 -1
  173. package/dist/editor/components/CollapsibleSectionHeader.js +1 -4
  174. package/dist/editor/components/CollapsibleSectionHeader.js.map +1 -1
  175. package/dist/editor/components/DraggableRow.js +0 -1
  176. package/dist/editor/components/DraggableRow.js.map +1 -1
  177. package/dist/editor/components/EditorReloadOverlay.d.ts +16 -0
  178. package/dist/editor/components/EditorReloadOverlay.d.ts.map +1 -0
  179. package/dist/editor/components/EditorReloadOverlay.js +13 -0
  180. package/dist/editor/components/EditorReloadOverlay.js.map +1 -0
  181. package/dist/editor/components/NotificationContainer.js +0 -20
  182. package/dist/editor/components/NotificationContainer.js.map +1 -1
  183. package/dist/editor/components/OutlinePanel.js +1 -12
  184. package/dist/editor/components/OutlinePanel.js.map +1 -1
  185. package/dist/editor/components/P1InspectorFields.d.ts.map +1 -1
  186. package/dist/editor/components/P1InspectorFields.js +12 -14
  187. package/dist/editor/components/P1InspectorFields.js.map +1 -1
  188. package/dist/editor/components/P1TemplateFields.js +6 -12
  189. package/dist/editor/components/P1TemplateFields.js.map +1 -1
  190. package/dist/editor/components/PanelHeader.d.ts.map +1 -1
  191. package/dist/editor/components/PanelHeader.js +3 -2
  192. package/dist/editor/components/PanelHeader.js.map +1 -1
  193. package/dist/editor/components/PublishButton.js +0 -21
  194. package/dist/editor/components/PublishButton.js.map +1 -1
  195. package/dist/editor/components/PuckDataCapture.js +0 -14
  196. package/dist/editor/components/PuckDataCapture.js.map +1 -1
  197. package/dist/editor/components/PuckDataSynchronizer.js +0 -67
  198. package/dist/editor/components/PuckDataSynchronizer.js.map +1 -1
  199. package/dist/editor/components/PuckSelectionTracker.js +0 -62
  200. package/dist/editor/components/PuckSelectionTracker.js.map +1 -1
  201. package/dist/editor/components/SaveIndicator.js +0 -41
  202. package/dist/editor/components/SaveIndicator.js.map +1 -1
  203. package/dist/editor/components/Toast.js +1 -32
  204. package/dist/editor/components/Toast.js.map +1 -1
  205. package/dist/editor/components/VersionBannerOverride.d.ts +7 -1
  206. package/dist/editor/components/VersionBannerOverride.d.ts.map +1 -1
  207. package/dist/editor/components/VersionBannerOverride.js +17 -24
  208. package/dist/editor/components/VersionBannerOverride.js.map +1 -1
  209. package/dist/editor/components/collapsibleSectionContext.js +0 -10
  210. package/dist/editor/components/collapsibleSectionContext.js.map +1 -1
  211. package/dist/editor/components/componentIconName.js +0 -23
  212. package/dist/editor/components/componentIconName.js.map +1 -1
  213. package/dist/editor/components/connectable.js +0 -5
  214. package/dist/editor/components/connectable.js.map +1 -1
  215. package/dist/editor/components/merge-preview/MergePreviewRenderer.js +2 -74
  216. package/dist/editor/components/merge-preview/MergePreviewRenderer.js.map +1 -1
  217. package/dist/editor/components/merge-preview/ScaledContent.js +0 -6
  218. package/dist/editor/components/merge-preview/ScaledContent.js.map +1 -1
  219. package/dist/editor/components/merge-preview/index.js +0 -5
  220. package/dist/editor/components/merge-preview/index.js.map +1 -1
  221. package/dist/editor/components/outlineTree.js +0 -31
  222. package/dist/editor/components/outlineTree.js.map +1 -1
  223. package/dist/editor/components/useDragReorder.js +0 -1
  224. package/dist/editor/components/useDragReorder.js.map +1 -1
  225. package/dist/editor/composePlugins.d.ts +9 -3
  226. package/dist/editor/composePlugins.d.ts.map +1 -1
  227. package/dist/editor/composePlugins.js +3 -8
  228. package/dist/editor/composePlugins.js.map +1 -1
  229. package/dist/editor/defaultPlugins.d.ts +1 -1
  230. package/dist/editor/defaultPlugins.d.ts.map +1 -1
  231. package/dist/editor/defaultPlugins.js +3 -1
  232. package/dist/editor/defaultPlugins.js.map +1 -1
  233. package/dist/editor/freshFieldTypes.d.ts +12 -0
  234. package/dist/editor/freshFieldTypes.d.ts.map +1 -0
  235. package/dist/editor/freshFieldTypes.js +11 -0
  236. package/dist/editor/freshFieldTypes.js.map +1 -0
  237. package/dist/editor/logout-store.d.ts +13 -0
  238. package/dist/editor/logout-store.d.ts.map +1 -0
  239. package/dist/editor/logout-store.js +23 -0
  240. package/dist/editor/logout-store.js.map +1 -0
  241. package/dist/editor/plugin/P1Plugin.d.ts +16 -3
  242. package/dist/editor/plugin/P1Plugin.d.ts.map +1 -1
  243. package/dist/editor/plugin/P1Plugin.js +21 -171
  244. package/dist/editor/plugin/P1Plugin.js.map +1 -1
  245. package/dist/editor/plugin/context-sync-key.js +0 -19
  246. package/dist/editor/plugin/context-sync-key.js.map +1 -1
  247. package/dist/editor/plugin/createP1Overrides.js +1 -49
  248. package/dist/editor/plugin/createP1Overrides.js.map +1 -1
  249. package/dist/editor/plugin/document-sync-plugin.js +0 -50
  250. package/dist/editor/plugin/document-sync-plugin.js.map +1 -1
  251. package/dist/editor/plugin/fieldGuidance.js +0 -5
  252. package/dist/editor/plugin/fieldGuidance.js.map +1 -1
  253. package/dist/editor/plugin/index.js +0 -6
  254. package/dist/editor/plugin/index.js.map +1 -1
  255. package/dist/editor/plugin/selectHeaderCollaborators.js +0 -8
  256. package/dist/editor/plugin/selectHeaderCollaborators.js.map +1 -1
  257. package/dist/editor/presets.js +2 -2
  258. package/dist/editor/stablePluginDeps.d.ts +9 -0
  259. package/dist/editor/stablePluginDeps.d.ts.map +1 -0
  260. package/dist/editor/stablePluginDeps.js +15 -0
  261. package/dist/editor/stablePluginDeps.js.map +1 -0
  262. package/dist/editor/thumbnails/LiveThumbnail.js +1 -49
  263. package/dist/editor/thumbnails/LiveThumbnail.js.map +1 -1
  264. package/dist/editor/thumbnails/ThumbnailCard.js +0 -25
  265. package/dist/editor/thumbnails/ThumbnailCard.js.map +1 -1
  266. package/dist/editor/thumbnails/buildLiveThumbnailDrawer.js +0 -21
  267. package/dist/editor/thumbnails/buildLiveThumbnailDrawer.js.map +1 -1
  268. package/dist/editor/thumbnails/humanizeComponentName.js +0 -17
  269. package/dist/editor/thumbnails/humanizeComponentName.js.map +1 -1
  270. package/dist/editor/thumbnails/resolveLiveThumbnailDrawer.js +0 -11
  271. package/dist/editor/thumbnails/resolveLiveThumbnailDrawer.js.map +1 -1
  272. package/dist/editor/thumbnails/thumbnailCache.js +0 -38
  273. package/dist/editor/thumbnails/thumbnailCache.js.map +1 -1
  274. package/dist/editor/useAutoSave.js +0 -32
  275. package/dist/editor/useAutoSave.js.map +1 -1
  276. package/dist/editor/useBranches.js +0 -30
  277. package/dist/editor/useBranches.js.map +1 -1
  278. package/dist/editor/useComponentRegistry.d.ts +1 -1
  279. package/dist/editor/useComponentRegistry.js +0 -28
  280. package/dist/editor/useComponentRegistry.js.map +1 -1
  281. package/dist/editor/useDocuments.js +0 -51
  282. package/dist/editor/useDocuments.js.map +1 -1
  283. package/dist/editor/useMergePreview.js +8 -12
  284. package/dist/editor/useMergePreview.js.map +1 -1
  285. package/dist/editor/useP1Editor.d.ts +35 -7
  286. package/dist/editor/useP1Editor.d.ts.map +1 -1
  287. package/dist/editor/useP1Editor.js +146 -243
  288. package/dist/editor/useP1Editor.js.map +1 -1
  289. package/dist/editor/useP1Overrides.js +15 -50
  290. package/dist/editor/useP1Overrides.js.map +1 -1
  291. package/dist/editor/useP1Plugin.d.ts +10 -4
  292. package/dist/editor/useP1Plugin.d.ts.map +1 -1
  293. package/dist/editor/useP1Plugin.js +34 -56
  294. package/dist/editor/useP1Plugin.js.map +1 -1
  295. package/dist/editor/useRealtime.d.ts +15 -3
  296. package/dist/editor/useRealtime.d.ts.map +1 -1
  297. package/dist/editor/useRealtime.js +12 -91
  298. package/dist/editor/useRealtime.js.map +1 -1
  299. package/dist/editor/useResponsivePanels.js +2 -35
  300. package/dist/editor/useResponsivePanels.js.map +1 -1
  301. package/dist/editor/useSidebarScrollPreservation.js +0 -14
  302. package/dist/editor/useSidebarScrollPreservation.js.map +1 -1
  303. package/dist/editor/utils/buildThumbnailOverride.js +0 -9
  304. package/dist/editor/utils/buildThumbnailOverride.js.map +1 -1
  305. package/dist/editor/utils/componentRegistry.d.ts +6 -11
  306. package/dist/editor/utils/componentRegistry.d.ts.map +1 -1
  307. package/dist/editor/utils/componentRegistry.js +1 -71
  308. package/dist/editor/utils/componentRegistry.js.map +1 -1
  309. package/dist/editor/utils/createStablePluginArray.js +0 -27
  310. package/dist/editor/utils/createStablePluginArray.js.map +1 -1
  311. package/dist/editor/utils/path.js +0 -6
  312. package/dist/editor/utils/path.js.map +1 -1
  313. package/dist/editor/utils/puckYjsBinding.d.ts +1 -1
  314. package/dist/editor/utils/puckYjsBinding.js +0 -99
  315. package/dist/editor/utils/puckYjsBinding.js.map +1 -1
  316. package/dist/editor/utils/restoreDocumentVersion.js +0 -12
  317. package/dist/editor/utils/restoreDocumentVersion.js.map +1 -1
  318. package/dist/editor/utils/sanitizeRichtextDefaults.js +0 -26
  319. package/dist/editor/utils/sanitizeRichtextDefaults.js.map +1 -1
  320. package/dist/editor/utils/snapshotToPuckData.js +0 -8
  321. package/dist/editor/utils/snapshotToPuckData.js.map +1 -1
  322. package/dist/editor/utils/syncComponentRegistry.d.ts +2 -2
  323. package/dist/editor/utils/syncComponentRegistry.js +1 -76
  324. package/dist/editor/utils/syncComponentRegistry.js.map +1 -1
  325. package/dist/editor/utils/syncComponentRegistryWriteOnly.d.ts +7 -7
  326. package/dist/editor/utils/syncComponentRegistryWriteOnly.js +0 -22
  327. package/dist/editor/utils/syncComponentRegistryWriteOnly.js.map +1 -1
  328. package/dist/editor/utils/templatePath.js +0 -5
  329. package/dist/editor/utils/templatePath.js.map +1 -1
  330. package/dist/features/content-type-templates/editor/useTemplatePermissions.js +0 -3
  331. package/dist/features/content-type-templates/editor/useTemplatePermissions.js.map +1 -1
  332. package/dist/features/content-type-templates/hooks/useTemplateList.js +0 -30
  333. package/dist/features/content-type-templates/hooks/useTemplateList.js.map +1 -1
  334. package/dist/features/content-type-templates/index.js +0 -8
  335. package/dist/features/content-type-templates/index.js.map +1 -1
  336. package/dist/features/content-type-templates/permissions/createPuckPermissions.js +1 -43
  337. package/dist/features/content-type-templates/permissions/createPuckPermissions.js.map +1 -1
  338. package/dist/features/content-type-templates/permissions/role-permissions.d.ts +8 -0
  339. package/dist/features/content-type-templates/permissions/role-permissions.d.ts.map +1 -1
  340. package/dist/features/content-type-templates/permissions/role-permissions.js +3 -29
  341. package/dist/features/content-type-templates/permissions/role-permissions.js.map +1 -1
  342. package/dist/features/content-type-templates/permissions/useContentRole.js +0 -24
  343. package/dist/features/content-type-templates/permissions/useContentRole.js.map +1 -1
  344. package/dist/features/content-type-templates/permissions/useResolveContentRole.d.ts +5 -5
  345. package/dist/features/content-type-templates/permissions/useResolveContentRole.js +2 -22
  346. package/dist/features/content-type-templates/permissions/useResolveContentRole.js.map +1 -1
  347. package/dist/features/content-type-templates/stores/index.js +0 -5
  348. package/dist/features/content-type-templates/stores/index.js.map +1 -1
  349. package/dist/features/content-type-templates/stores/template-store-api.js +0 -14
  350. package/dist/features/content-type-templates/stores/template-store-api.js.map +1 -1
  351. package/dist/features/content-type-templates/stores/template-store.d.ts +1 -1
  352. package/dist/features/content-type-templates/stores/template-store.js +0 -12
  353. package/dist/features/content-type-templates/stores/template-store.js.map +1 -1
  354. package/dist/features/content-type-templates/types.js +0 -5
  355. package/dist/features/content-type-templates/types.js.map +1 -1
  356. package/dist/features/content-type-templates/ui/ActionBarPinButton.js +12 -21
  357. package/dist/features/content-type-templates/ui/ActionBarPinButton.js.map +1 -1
  358. package/dist/features/content-type-templates/ui/TemplateDetailsPanel.js +0 -23
  359. package/dist/features/content-type-templates/ui/TemplateDetailsPanel.js.map +1 -1
  360. package/dist/features/content-type-templates/ui/TemplateSelector.js +0 -19
  361. package/dist/features/content-type-templates/ui/TemplateSelector.js.map +1 -1
  362. package/dist/features/content-type-templates/validation/structural-validation.js +0 -40
  363. package/dist/features/content-type-templates/validation/structural-validation.js.map +1 -1
  364. package/dist/features/localization/authority.d.ts +26 -0
  365. package/dist/features/localization/authority.d.ts.map +1 -0
  366. package/dist/features/localization/authority.js +17 -0
  367. package/dist/features/localization/authority.js.map +1 -0
  368. package/dist/features/localization/index.d.ts +11 -0
  369. package/dist/features/localization/index.d.ts.map +1 -0
  370. package/dist/features/localization/index.js +7 -0
  371. package/dist/features/localization/index.js.map +1 -0
  372. package/dist/features/localization/prop-target.d.ts +26 -0
  373. package/dist/features/localization/prop-target.d.ts.map +1 -0
  374. package/dist/features/localization/prop-target.js +15 -0
  375. package/dist/features/localization/prop-target.js.map +1 -0
  376. package/dist/features/localization/puck-overrides.d.ts +12 -0
  377. package/dist/features/localization/puck-overrides.d.ts.map +1 -0
  378. package/dist/features/localization/puck-overrides.js +12 -0
  379. package/dist/features/localization/puck-overrides.js.map +1 -0
  380. package/dist/features/localization/relation.d.ts +14 -0
  381. package/dist/features/localization/relation.d.ts.map +1 -0
  382. package/dist/features/localization/relation.js +7 -0
  383. package/dist/features/localization/relation.js.map +1 -0
  384. package/dist/features/localization/translatable.d.ts +24 -0
  385. package/dist/features/localization/translatable.d.ts.map +1 -0
  386. package/dist/features/localization/translatable.js +30 -0
  387. package/dist/features/localization/translatable.js.map +1 -0
  388. package/dist/features/localization/types.d.ts +17 -0
  389. package/dist/features/localization/types.d.ts.map +1 -0
  390. package/dist/features/localization/types.js +2 -0
  391. package/dist/features/localization/types.js.map +1 -0
  392. package/dist/features/localization/ui/AuthorityFieldControl.d.ts +32 -0
  393. package/dist/features/localization/ui/AuthorityFieldControl.d.ts.map +1 -0
  394. package/dist/features/localization/ui/AuthorityFieldControl.js +36 -0
  395. package/dist/features/localization/ui/AuthorityFieldControl.js.map +1 -0
  396. package/dist/features/localization/ui/TranslatabilityToggle.d.ts +17 -0
  397. package/dist/features/localization/ui/TranslatabilityToggle.d.ts.map +1 -0
  398. package/dist/features/localization/ui/TranslatabilityToggle.js +16 -0
  399. package/dist/features/localization/ui/TranslatabilityToggle.js.map +1 -0
  400. package/dist/features/localization/useLocalizationData.d.ts +37 -0
  401. package/dist/features/localization/useLocalizationData.d.ts.map +1 -0
  402. package/dist/features/localization/useLocalizationData.js +88 -0
  403. package/dist/features/localization/useLocalizationData.js.map +1 -0
  404. package/dist/index.d.ts +6 -4
  405. package/dist/index.d.ts.map +1 -1
  406. package/dist/index.js +2 -43
  407. package/dist/index.js.map +1 -1
  408. package/dist/merge/components/conflict-notifications/ConflictNotificationToast.js +0 -19
  409. package/dist/merge/components/conflict-notifications/ConflictNotificationToast.js.map +1 -1
  410. package/dist/merge/components/conflict-notifications/index.js +0 -5
  411. package/dist/merge/components/conflict-notifications/index.js.map +1 -1
  412. package/dist/merge/components/conflict-notifications/useConflictNotifications.js +0 -48
  413. package/dist/merge/components/conflict-notifications/useConflictNotifications.js.map +1 -1
  414. package/dist/merge/components/conflict-resolution/ComponentConflictGroup.js +0 -36
  415. package/dist/merge/components/conflict-resolution/ComponentConflictGroup.js.map +1 -1
  416. package/dist/merge/components/conflict-resolution/PuckFieldResolutionPanel.js +0 -40
  417. package/dist/merge/components/conflict-resolution/PuckFieldResolutionPanel.js.map +1 -1
  418. package/dist/merge/components/conflict-resolution/RenderedResolutionPreview.js +0 -21
  419. package/dist/merge/components/conflict-resolution/RenderedResolutionPreview.js.map +1 -1
  420. package/dist/merge/components/conflict-resolution/index.js +0 -5
  421. package/dist/merge/components/conflict-resolution/index.js.map +1 -1
  422. package/dist/merge/components/merge-resolution/CherryPickVisualPanel.js +0 -44
  423. package/dist/merge/components/merge-resolution/CherryPickVisualPanel.js.map +1 -1
  424. package/dist/merge/components/merge-resolution/ComponentClickOverlay.js +0 -24
  425. package/dist/merge/components/merge-resolution/ComponentClickOverlay.js.map +1 -1
  426. package/dist/merge/components/merge-resolution/DocumentResolutionDetail.d.ts.map +1 -1
  427. package/dist/merge/components/merge-resolution/DocumentResolutionDetail.js +6 -31
  428. package/dist/merge/components/merge-resolution/DocumentResolutionDetail.js.map +1 -1
  429. package/dist/merge/components/merge-resolution/index.js +0 -3
  430. package/dist/merge/components/merge-resolution/index.js.map +1 -1
  431. package/dist/merge/useMergeResolution.d.ts +1 -1
  432. package/dist/merge/useMergeResolution.d.ts.map +1 -1
  433. package/dist/merge/useMergeResolution.js +6 -75
  434. package/dist/merge/useMergeResolution.js.map +1 -1
  435. package/dist/merge/utils/namespacePuckData.d.ts.map +1 -1
  436. package/dist/merge/utils/namespacePuckData.js +8 -8
  437. package/dist/merge/utils/namespacePuckData.js.map +1 -1
  438. package/dist/merge/utils/puckFieldClassifier.js +0 -183
  439. package/dist/merge/utils/puckFieldClassifier.js.map +1 -1
  440. package/dist/p1/editor/connect/connect-preview-config.js +0 -5
  441. package/dist/p1/editor/connect/connect-preview-config.js.map +1 -1
  442. package/dist/p1/editor/connect/field-connect-plugin.js +0 -6
  443. package/dist/p1/editor/connect/field-connect-plugin.js.map +1 -1
  444. package/dist/p1/editor/editor-preview-resolve.js +0 -13
  445. package/dist/p1/editor/editor-preview-resolve.js.map +1 -1
  446. package/dist/p1/editor/hooks/api-hooks.js +0 -7
  447. package/dist/p1/editor/hooks/api-hooks.js.map +1 -1
  448. package/dist/p1/editor/hooks/useLiveEditorContext.d.ts.map +1 -1
  449. package/dist/p1/editor/hooks/useLiveEditorContext.js +2 -13
  450. package/dist/p1/editor/hooks/useLiveEditorContext.js.map +1 -1
  451. package/dist/p1/editor/hooks/useLiveRemoteDatasources.js +0 -22
  452. package/dist/p1/editor/hooks/useLiveRemoteDatasources.js.map +1 -1
  453. package/dist/p1/editor/hooks/useP1Plugins.js +0 -5
  454. package/dist/p1/editor/hooks/useP1Plugins.js.map +1 -1
  455. package/dist/p1/editor/remote-datasources/remote-datasource-explorer-plugin.js +0 -7
  456. package/dist/p1/editor/remote-datasources/remote-datasource-explorer-plugin.js.map +1 -1
  457. package/dist/p1/editor/template-autocomplete-layer.js +0 -4
  458. package/dist/p1/editor/template-autocomplete-layer.js.map +1 -1
  459. package/dist/pds/components/AgentChip.js +0 -3
  460. package/dist/pds/components/AgentChip.js.map +1 -1
  461. package/dist/pds/components/CreatePageModal.js +1 -97
  462. package/dist/pds/components/CreatePageModal.js.map +1 -1
  463. package/dist/pds/components/LoadingMessage.d.ts.map +1 -1
  464. package/dist/pds/components/LoadingMessage.js +2 -1
  465. package/dist/pds/components/LoadingMessage.js.map +1 -1
  466. package/dist/pds/components/LoadingMessage.module.css +2 -21
  467. package/dist/pds/components/LoadingOverlay.d.ts +17 -0
  468. package/dist/pds/components/LoadingOverlay.d.ts.map +1 -0
  469. package/dist/pds/components/LoadingOverlay.js +7 -0
  470. package/dist/pds/components/LoadingOverlay.js.map +1 -0
  471. package/dist/pds/components/LoadingOverlay.module.css +28 -0
  472. package/dist/pds/components/P1EditorHeader.d.ts +9 -2
  473. package/dist/pds/components/P1EditorHeader.d.ts.map +1 -1
  474. package/dist/pds/components/P1EditorHeader.js +6 -26
  475. package/dist/pds/components/P1EditorHeader.js.map +1 -1
  476. package/dist/pds/components/P1EditorHeader.module.css +26 -0
  477. package/dist/pds/components/PageNavigator.js +0 -16
  478. package/dist/pds/components/PageNavigator.js.map +1 -1
  479. package/dist/pds/components/PageNotFound.d.ts +27 -0
  480. package/dist/pds/components/PageNotFound.d.ts.map +1 -0
  481. package/dist/pds/components/PageNotFound.js +24 -0
  482. package/dist/pds/components/PageNotFound.js.map +1 -0
  483. package/dist/pds/components/PageNotFound.module.css +51 -0
  484. package/dist/pds/components/PresenceStack.js +0 -9
  485. package/dist/pds/components/PresenceStack.js.map +1 -1
  486. package/dist/pds/components/PublishControl.js +0 -6
  487. package/dist/pds/components/PublishControl.js.map +1 -1
  488. package/dist/pds/components/WorkstreamSwitcher.js +1 -25
  489. package/dist/pds/components/WorkstreamSwitcher.js.map +1 -1
  490. package/dist/pds/index.d.ts +4 -0
  491. package/dist/pds/index.d.ts.map +1 -1
  492. package/dist/pds/index.js +2 -29
  493. package/dist/pds/index.js.map +1 -1
  494. package/dist/pds/theme/pds-core-content.js +0 -5
  495. package/dist/pds/theme/pds-core-content.js.map +1 -1
  496. package/dist/pds/utils/deriveDocState.js +0 -1
  497. package/dist/pds/utils/deriveDocState.js.map +1 -1
  498. package/dist/pds/utils/deriveLiveDocState.js +0 -13
  499. package/dist/pds/utils/deriveLiveDocState.js.map +1 -1
  500. package/dist/registry-sync.js +0 -4
  501. package/dist/registry-sync.js.map +1 -1
  502. package/dist/server.js +0 -7
  503. package/dist/server.js.map +1 -1
  504. package/dist/versioning/components/ReadOnlyFieldsGuard.js +0 -3
  505. package/dist/versioning/components/ReadOnlyFieldsGuard.js.map +1 -1
  506. package/dist/versioning/components/VersionBannerActions.js +0 -1
  507. package/dist/versioning/components/VersionBannerActions.js.map +1 -1
  508. package/dist/versioning/components/version-compare/BranchDiffHeader.js +0 -7
  509. package/dist/versioning/components/version-compare/BranchDiffHeader.js.map +1 -1
  510. package/dist/versioning/components/version-compare/BranchMergeCompare.js +0 -19
  511. package/dist/versioning/components/version-compare/BranchMergeCompare.js.map +1 -1
  512. package/dist/versioning/components/version-compare/ComponentNode.js +0 -8
  513. package/dist/versioning/components/version-compare/ComponentNode.js.map +1 -1
  514. package/dist/versioning/components/version-compare/ComponentTree.js +0 -10
  515. package/dist/versioning/components/version-compare/ComponentTree.js.map +1 -1
  516. package/dist/versioning/components/version-compare/DiffHeader.js +0 -3
  517. package/dist/versioning/components/version-compare/DiffHeader.js.map +1 -1
  518. package/dist/versioning/components/version-compare/DocumentDiffList.js +0 -14
  519. package/dist/versioning/components/version-compare/DocumentDiffList.js.map +1 -1
  520. package/dist/versioning/components/version-compare/PropDiffPanel.js +0 -7
  521. package/dist/versioning/components/version-compare/PropDiffPanel.js.map +1 -1
  522. package/dist/versioning/components/version-compare/PropDiffRow.js +0 -3
  523. package/dist/versioning/components/version-compare/PropDiffRow.js.map +1 -1
  524. package/dist/versioning/components/version-compare/PropValueDisplay.js +0 -22
  525. package/dist/versioning/components/version-compare/PropValueDisplay.js.map +1 -1
  526. package/dist/versioning/components/version-compare/VersionComparePage.js +0 -13
  527. package/dist/versioning/components/version-compare/VersionComparePage.js.map +1 -1
  528. package/dist/versioning/components/version-compare/VisualBranchCompare.js +0 -17
  529. package/dist/versioning/components/version-compare/VisualBranchCompare.js.map +1 -1
  530. package/dist/versioning/components/version-compare/VisualVersionCompare.js +0 -23
  531. package/dist/versioning/components/version-compare/VisualVersionCompare.js.map +1 -1
  532. package/dist/versioning/components/version-compare/index.js +0 -5
  533. package/dist/versioning/components/version-compare/index.js.map +1 -1
  534. package/dist/versioning/components/version-history/AgentCheckpointBadge.js +0 -14
  535. package/dist/versioning/components/version-history/AgentCheckpointBadge.js.map +1 -1
  536. package/dist/versioning/components/version-history/VersionItem.js +0 -7
  537. package/dist/versioning/components/version-history/VersionItem.js.map +1 -1
  538. package/dist/versioning/components/version-history/index.js +0 -5
  539. package/dist/versioning/components/version-history/index.js.map +1 -1
  540. package/dist/versioning/useCheckpoints.js +0 -28
  541. package/dist/versioning/useCheckpoints.js.map +1 -1
  542. package/dist/versioning/useVersions.js +0 -31
  543. package/dist/versioning/useVersions.js.map +1 -1
  544. package/dist/versioning/utils/branchDiff.js +0 -93
  545. package/dist/versioning/utils/branchDiff.js.map +1 -1
  546. package/dist/versioning/utils/diff.js +0 -79
  547. package/dist/versioning/utils/diff.js.map +1 -1
  548. package/dist/versioning/utils/formatVersionDate.js +0 -12
  549. package/dist/versioning/utils/formatVersionDate.js.map +1 -1
  550. package/dist/versioning/utils/highlightConfig.js +0 -42
  551. package/dist/versioning/utils/highlightConfig.js.map +1 -1
  552. package/dist/versioning/utils/versionKind.js +0 -10
  553. package/dist/versioning/utils/versionKind.js.map +1 -1
  554. package/package.json +7 -7
  555. package/src/data/data-list-block/data-list.css +314 -0
  556. package/src/pds/theme/PuckEditorTheme.css +5 -5
  557. package/src/styles.css +1 -1
  558. package/src/pds/theme/PuckEditorTheme.test.ts +0 -195
  559. package/src/pds/theme/pds-core-content.ts +0 -8
@@ -1,18 +1,13 @@
1
1
  "use client";
2
- /**
3
- * useP1Editor Hook
4
- *
5
- * All-in-one hook for setting up a P1-enabled Puck editor.
6
- * Composes useP1Plugin and useP1Overrides internally, handles
7
- * document loading, version management, historical version protection,
8
- * and provides everything needed to render <Puck>.
9
- */
10
2
  import { useState, useEffect, useRef, useMemo, useCallback } from 'react';
11
3
  import { useP1Puck } from '../core/P1PuckContext.js';
12
4
  import { useVersions } from '../versioning/useVersions.js';
13
5
  import { useP1Auth } from '../auth/index.js';
6
+ import { isDocumentGoneError, isDocumentNotFoundError } from '../data/utils.js';
7
+ import { canCreatePages } from '../features/content-type-templates/permissions/role-permissions.js';
14
8
  import { useP1Plugin } from './useP1Plugin.js';
15
9
  import { useP1Overrides } from './useP1Overrides.js';
10
+ import { withFreshFieldTypes } from './freshFieldTypes.js';
16
11
  import { useComponentRegistry } from './useComponentRegistry.js';
17
12
  import { buildThumbnailOverride } from './utils/buildThumbnailOverride.js';
18
13
  import { makeEagerVersionHandler } from './utils/makeEagerVersionHandler.js';
@@ -20,67 +15,45 @@ import { restoreDocumentVersion } from './utils/restoreDocumentVersion.js';
20
15
  import { initialPanelUi } from './useResponsivePanels.js';
21
16
  import { createDocumentSyncStore, createDocumentSyncPlugin, documentSyncKey, BLANK_SYNC_KEY, } from './plugin/document-sync-plugin.js';
22
17
  import { resolveLiveThumbnailDrawer } from './thumbnails/resolveLiveThumbnailDrawer.js';
23
- /**
24
- * All-in-one hook for setting up a P1-enabled Puck editor.
25
- *
26
- * Handles document loading, version management, plugin/overrides creation,
27
- * safe data, historical version protection, and plugin array assembly.
28
- * Returns everything needed to render <Puck> with minimal boilerplate.
29
- *
30
- * Must be used inside a P1PuckProvider.
31
- *
32
- * @param options - Editor configuration
33
- * @returns Loading state, puck props, and P1 context
34
- *
35
- * @example
36
- * ```tsx
37
- * function Editor() {
38
- * const { loading, error, puckProps } = useP1Editor({
39
- * documentPath: '/home',
40
- * puckConfig: config,
41
- * });
42
- *
43
- * if (loading) return <Loading />;
44
- * if (error) return <Error error={error} />;
45
- *
46
- * return <Puck {...puckProps} />;
47
- * }
48
- * ```
49
- */
18
+ function titleFromPath(path) {
19
+ const slug = path.split('/').filter(Boolean).pop();
20
+ if (!slug)
21
+ return 'Home';
22
+ const words = slug.replace(/[-_]+/g, ' ').trim();
23
+ return words.charAt(0).toUpperCase() + words.slice(1);
24
+ }
50
25
  export function useP1Editor(options) {
51
26
  const { documentPath, puckConfig, additionalPlugins, additionalOverrides, thumbnails, liveThumbnailDrawer, overrideOptions, pluginOptions, onSelectionChange, onDocumentNotFound, } = options;
52
- const css = useP1Puck();
27
+ const ccr = useP1Puck();
53
28
  const { user, logout } = useP1Auth();
54
- // =========================================================================
55
- // Document Loading
56
- // =========================================================================
57
29
  const [loading, setLoading] = useState(true);
58
30
  const [error, setError] = useState(null);
59
31
  const [needsRedirect, setNeedsRedirect] = useState(false);
32
+ const [notFound, setNotFound] = useState(false);
33
+ const [loadAttempt, setLoadAttempt] = useState(0);
60
34
  const loadedPathRef = useRef(null);
61
- // Reset loaded path when branch changes so document reloads on the new branch
62
- const prevBranchRef = useRef(css.branchId);
63
- if (prevBranchRef.current !== css.branchId) {
64
- prevBranchRef.current = css.branchId;
35
+ const loadedBranchRef = useRef(null);
36
+ const prevBranchRef = useRef(ccr.branchId);
37
+ if (prevBranchRef.current !== ccr.branchId) {
38
+ prevBranchRef.current = ccr.branchId;
65
39
  loadedPathRef.current = null;
66
40
  }
67
- // Keep callback in a ref so the effect doesn't re-run when it changes
68
41
  const onDocumentNotFoundRef = useRef(onDocumentNotFound);
69
42
  onDocumentNotFoundRef.current = onDocumentNotFound;
70
43
  useEffect(() => {
71
- // Wait for branch resolution before loading documents
72
- if (!css.branchId)
44
+ if (!ccr.branchId)
73
45
  return;
74
- // Skip if already loaded this path on this branch
75
46
  if (loadedPathRef.current === documentPath)
76
47
  return;
77
48
  let cancelled = false;
78
49
  setLoading(true);
79
50
  setError(null);
80
- css.loadDocument(documentPath)
51
+ setNotFound(false);
52
+ ccr.loadDocument(documentPath)
81
53
  .then(() => {
82
54
  if (!cancelled) {
83
55
  loadedPathRef.current = documentPath;
56
+ loadedBranchRef.current = ccr.branchId;
84
57
  setNeedsRedirect(false);
85
58
  setLoading(false);
86
59
  }
@@ -89,101 +62,87 @@ export function useP1Editor(options) {
89
62
  if (cancelled)
90
63
  return;
91
64
  const loadErr = err instanceof Error ? err : new Error(String(err));
92
- // Give the consumer a chance to handle the error (e.g. auto-create)
65
+ if (isDocumentGoneError(loadErr)) {
66
+ setNeedsRedirect(true);
67
+ return;
68
+ }
93
69
  if (onDocumentNotFoundRef.current) {
94
70
  try {
95
71
  const shouldRetry = await onDocumentNotFoundRef.current(documentPath, loadErr);
96
72
  if (!cancelled && shouldRetry) {
97
- await css.loadDocument(documentPath);
73
+ await ccr.loadDocument(documentPath);
98
74
  if (!cancelled) {
99
75
  loadedPathRef.current = documentPath;
76
+ loadedBranchRef.current = ccr.branchId;
100
77
  setNeedsRedirect(false);
101
78
  setLoading(false);
102
- void css.refreshDocuments();
79
+ void ccr.refreshDocuments();
103
80
  }
104
81
  return;
105
82
  }
106
83
  }
107
84
  catch {
108
- // callback itself failed — fall through to unload
109
85
  }
110
86
  }
111
- // Unload the editor; recovery effect will set an error if no docs exist
112
- if (!cancelled) {
113
- setNeedsRedirect(true);
87
+ if (cancelled)
88
+ return;
89
+ if (isDocumentNotFoundError(loadErr)) {
90
+ loadedPathRef.current = null;
91
+ setNotFound(true);
92
+ setLoading(false);
93
+ return;
114
94
  }
95
+ setNeedsRedirect(true);
115
96
  });
116
97
  return () => {
117
98
  cancelled = true;
118
99
  };
119
- }, [documentPath, css.branchId, css.loadDocument]);
120
- // No branch means nothing can be opened, so an unresolved branch is fatal.
121
- // Derived rather than copied into state: a retry that clears the failure has
122
- // to stop being reported, which a mirrored copy would keep showing.
123
- const branchBootError = css.branchId ? null : css.branchResolutionError ?? null;
124
- // Recovery: document not found on this branch unload the editor and let
125
- // the preview empty state guide the user to pick a page.
100
+ }, [documentPath, ccr.branchId, ccr.loadDocument, loadAttempt]);
101
+ const retry = useCallback(() => {
102
+ loadedPathRef.current = null;
103
+ setLoadAttempt((n) => n + 1);
104
+ }, []);
105
+ const branchBootError = ccr.branchId ? null : ccr.branchResolutionError ?? null;
126
106
  useEffect(() => {
127
107
  if (!needsRedirect)
128
108
  return;
129
- if (css.documentsLoading)
109
+ if (ccr.documentsLoading)
130
110
  return;
131
111
  setNeedsRedirect(false);
132
- if (css.documents.length === 0) {
133
- // An empty list because the request was refused is a different story from
134
- // a branch that genuinely holds nothing; saying "no documents" for the
135
- // former is how the real failure stays hidden.
136
- setError(css.documentsError ?? new Error('No documents found on this branch'));
112
+ if (ccr.documents.length === 0) {
113
+ setError(ccr.documentsError ?? new Error('No documents found on this branch'));
137
114
  }
138
115
  setLoading(false);
139
- }, [needsRedirect, css.documentsLoading, css.documents.length, css.documentsError]);
140
- // =========================================================================
141
- // Version Management
142
- // =========================================================================
116
+ }, [needsRedirect, ccr.documentsLoading, ccr.documents.length, ccr.documentsError]);
143
117
  const { versions, loading: versionsLoading, refresh: refreshVersions, } = useVersions({
144
- client: css.client,
145
- siteId: css.siteId,
146
- branchId: css.branchId,
147
- documentId: css.currentDocument?.id ?? null,
118
+ client: ccr.client,
119
+ siteId: ccr.siteId,
120
+ branchId: ccr.branchId,
121
+ documentId: ccr.currentDocument?.id ?? null,
148
122
  });
149
- // Refresh versions when document changes; also reset eager-version flag so a
150
- // stale post-publish signal from the previous document never fires on the new one.
151
123
  useEffect(() => {
152
124
  needsVersionRef.current = false;
153
- if (css.currentDocument?.id)
125
+ if (ccr.currentDocument?.id)
154
126
  void refreshVersions();
155
- }, [css.currentDocument?.id, refreshVersions]);
156
- // Refresh versions after a successful save so the publish badge reflects the
157
- // new unpublished draft (publishedStatus flips 'published' → 'unpublished-changes').
158
- // Without this the badge would keep reading "Live" after an edit on the Live branch.
127
+ }, [ccr.currentDocument?.id, refreshVersions]);
159
128
  useEffect(() => {
160
- if (css.saveStatus === 'saved')
129
+ if (ccr.saveStatus === 'saved')
161
130
  void refreshVersions();
162
- }, [css.saveStatus, refreshVersions]);
163
- // Select a version — latest returns to live editing, others load historical
131
+ }, [ccr.saveStatus, refreshVersions]);
164
132
  const handleVersionSelect = useCallback((version) => {
165
133
  const latestVersion = versions[0];
166
134
  if (latestVersion && version.id === latestVersion.id) {
167
- void css.returnToLatest();
135
+ void ccr.returnToLatest();
168
136
  }
169
137
  else {
170
- void css.loadVersion(version);
138
+ void ccr.loadVersion(version);
171
139
  }
172
- }, [versions, css.loadVersion, css.returnToLatest]);
173
- // Revert to a prior version.
174
- const handleRestoreVersion = useCallback((version) => restoreDocumentVersion(version, css, refreshVersions, () => { }), [css, refreshVersions]);
175
- // =========================================================================
176
- // Published Status (derived from version data)
177
- // =========================================================================
178
- // The backend includes isPublished on each DocumentVersion via an EXISTS
179
- // subquery against checkpoint_documents. No additional API calls needed.
180
- const currentVersionId = css.viewingVersion?.id ?? versions[0]?.id;
140
+ }, [versions, ccr.loadVersion, ccr.returnToLatest]);
141
+ const handleRestoreVersion = useCallback((version) => restoreDocumentVersion(version, ccr, refreshVersions, () => { }), [ccr, refreshVersions]);
142
+ const currentVersionId = ccr.viewingVersion?.id ?? versions[0]?.id;
181
143
  const currentVersionIsPublished = versions.find(v => v.id === currentVersionId)?.isPublished ?? false;
182
144
  const hasPublishedVersion = versions.some(v => v.isPublished);
183
- // Look up the current document from the branch document list, which includes
184
- // inherited and isPublished fields from the branch-level listing endpoint.
185
- // css.currentDocument comes from the site-level getByPath endpoint and lacks these.
186
- const branchDocument = css.documents.find(d => d.id === css.currentDocument?.id);
145
+ const branchDocument = ccr.documents.find(d => d.id === ccr.currentDocument?.id);
187
146
  const inheritedAndPublished = branchDocument?.inherited && branchDocument?.isPublished;
188
147
  const publishedStatus = versionsLoading
189
148
  ? undefined
@@ -194,60 +153,68 @@ export function useP1Editor(options) {
194
153
  : hasPublishedVersion
195
154
  ? 'unpublished-changes'
196
155
  : 'draft';
197
- // =========================================================================
198
- // Focus Region Reporting (outgoing — report local selection to server)
199
- // =========================================================================
200
- // Report selection changes to the presence system via WebSocket.
201
- // Wraps the consumer's onSelectionChange so both reporting and
202
- // the consumer callback are called.
203
156
  const onSelectionChangeRef = useRef(onSelectionChange);
204
157
  onSelectionChangeRef.current = onSelectionChange;
205
158
  const handleSelectionChange = useCallback((path, itemId) => {
206
- // Report to presence system via WebSocket (instant broadcast to other clients)
207
159
  const regions = path ? [path] : [];
208
- css.sendFocusRegions(regions);
209
- // Forward to consumer callback
160
+ ccr.sendFocusRegions(regions);
210
161
  onSelectionChangeRef.current?.(path, itemId);
211
- }, [css.sendFocusRegions]);
212
- // =========================================================================
213
- // Component Registry (runs at editor startup, writes descriptors to P1 backend)
214
- // =========================================================================
162
+ }, [ccr.sendFocusRegions]);
215
163
  useComponentRegistry({ puckConfig });
216
- // =========================================================================
217
- // Plugin & Overrides (composed hooks)
218
- // =========================================================================
219
- // Set true after a successful publish; the next onChange fires the eager
220
- // version create and clears this immediately.
221
164
  const needsVersionRef = useRef(false);
222
- const eagerVersionParamsRef = useRef({ siteId: css.siteId, branchId: css.branchId, documentId: css.currentDocument?.id ?? null });
223
- eagerVersionParamsRef.current = { siteId: css.siteId, branchId: css.branchId, documentId: css.currentDocument?.id ?? null };
224
- // Wrap publish to refresh version list and call consumer callback after success.
165
+ const eagerVersionParamsRef = useRef({ siteId: ccr.siteId, branchId: ccr.branchId, documentId: ccr.currentDocument?.id ?? null });
166
+ eagerVersionParamsRef.current = { siteId: ccr.siteId, branchId: ccr.branchId, documentId: ccr.currentDocument?.id ?? null };
225
167
  const consumerOnPublishSuccessRef = useRef(overrideOptions?.onPublishSuccess);
226
168
  consumerOnPublishSuccessRef.current = overrideOptions?.onPublishSuccess;
227
169
  const handlePublish = useCallback(async () => {
228
- const checkpoint = await css.publishDocument();
170
+ const checkpoint = await ccr.publishDocument();
229
171
  needsVersionRef.current = true;
230
172
  void refreshVersions();
231
173
  consumerOnPublishSuccessRef.current?.(checkpoint);
232
- }, [css, refreshVersions]);
233
- const canRevert = css.userRole === 'admin' || css.userRole === 'editor' || css.userRole === 'author';
234
- // Pushes freshly loaded documents into the live Puck instance, replacing
235
- // the remount-on-document-switch behavior the old document-scoped puckKey
236
- // provided (see document-sync-plugin.tsx). Handed to the P1 plugin as well
237
- // so its context sync defers document switches to this store.
174
+ }, [ccr, refreshVersions]);
175
+ const canRevert = ccr.userRole === 'admin' || ccr.userRole === 'editor' || ccr.userRole === 'author';
238
176
  const [documentSyncStore] = useState(createDocumentSyncStore);
177
+ const [logoutError, setLogoutError] = useState(null);
178
+ const [isLoggingOut, setIsLoggingOut] = useState(false);
179
+ const handleLogout = useCallback(async () => {
180
+ setIsLoggingOut(true);
181
+ setLogoutError(null);
182
+ try {
183
+ const outcome = await logout();
184
+ if (outcome.status === 'error') {
185
+ setLogoutError(outcome.message);
186
+ setIsLoggingOut(false);
187
+ }
188
+ }
189
+ catch (err) {
190
+ setLogoutError(err instanceof Error ? err.message : 'Logout failed');
191
+ setIsLoggingOut(false);
192
+ }
193
+ }, [logout]);
194
+ const pageNotFound = useMemo(() => notFound
195
+ ? {
196
+ canCreate: canCreatePages(ccr.userRole),
197
+ onCreate: async () => {
198
+ await ccr.createDocument(documentPath, null, titleFromPath(documentPath));
199
+ retry();
200
+ },
201
+ }
202
+ : null, [notFound, documentPath, ccr.userRole, ccr.createDocument, retry]);
239
203
  const p1Plugin = useP1Plugin({
240
204
  documentSyncStore,
205
+ pageNotFound,
241
206
  onSelectionChange: handleSelectionChange,
242
- currentUser: user ? { id: css.userId, name: user.name, email: user.email, avatar: user.picture } : undefined,
243
- onLogout: logout,
207
+ currentUser: user ? { id: ccr.userId, name: user.name, email: user.email, avatar: user.picture } : undefined,
208
+ onLogout: handleLogout,
209
+ logoutError,
210
+ isLoggingOut,
244
211
  puckConfig,
245
212
  ...pluginOptions,
246
213
  onPublish: handlePublish,
247
214
  versions,
248
215
  versionsLoading,
249
216
  publishedStatus,
250
- selectedVersionId: css.viewingVersion?.id ?? undefined,
217
+ selectedVersionId: ccr.viewingVersion?.id ?? undefined,
251
218
  onVersionSelect: handleVersionSelect,
252
219
  onRestoreVersion: handleRestoreVersion,
253
220
  canRevert,
@@ -261,11 +228,7 @@ export function useP1Editor(options) {
261
228
  publishedStatus,
262
229
  ...(overrideOptions?.onPublishSuccess ? { onPublishSuccess: wrappedOnPublishSuccess } : {}),
263
230
  });
264
- // =========================================================================
265
- // Stable plugin array
266
- // =========================================================================
267
231
  if (process.env.NODE_ENV === "development") {
268
- // eslint-disable-next-line react-hooks/rules-of-hooks
269
232
  const prev = useRef(additionalPlugins);
270
233
  if (prev.current !== additionalPlugins) {
271
234
  const countChanged = (prev.current?.length ?? 0) !== (additionalPlugins?.length ?? 0);
@@ -280,77 +243,53 @@ export function useP1Editor(options) {
280
243
  additionalPluginsRef.current = additionalPlugins;
281
244
  const pluginCount = additionalPlugins?.length ?? 0;
282
245
  const documentSyncPlugin = useMemo(() => createDocumentSyncPlugin(documentSyncStore), [documentSyncStore]);
283
- // Publish the loaded document into the live Puck instance.
284
- //
285
- // Both the key and the data come from the payload's own origin, so a key can
286
- // never be paired with a different document's data. Keying off the live
287
- // branchId instead published the incoming branch's key beside the outgoing
288
- // branch's data the instant a switch began; the plugin applied that pairing,
289
- // recorded the new key as applied, and then ignored the correct document when
290
- // it arrived under the same key — leaving the canvas a workstream behind.
291
- //
292
- // safeData is read directly rather than through a ref: it only advances when
293
- // the provider loads a document (saveData deliberately never touches
294
- // currentData), so it cannot re-fire on every keystroke.
295
- const currentDocumentId = css.currentDocument?.id;
296
- const origin = css.currentDataOrigin;
246
+ const currentDocumentId = ccr.currentDocument?.id;
247
+ const origin = ccr.currentDataOrigin;
297
248
  useEffect(() => {
298
249
  if (loading || error || !origin)
299
250
  return;
300
- // Historical versions sync through ContextSyncBridge, which does not reset
301
- // the undo stack.
302
251
  if (origin.historical)
303
252
  return;
304
- // Mid-switch the payload still belongs to the outgoing branch or document.
305
- // Withholding it keeps the applied key naming what the canvas really shows.
306
- if (origin.branchId !== css.branchId)
253
+ if (origin.branchId !== ccr.branchId)
307
254
  return;
308
255
  if (origin.documentId !== currentDocumentId)
309
256
  return;
310
257
  documentSyncStore.publish({
311
258
  syncKey: documentSyncKey(origin.branchId, origin.documentId),
312
- data: css.safeData,
259
+ data: ccr.safeData,
313
260
  });
314
261
  }, [
315
262
  loading,
316
263
  error,
317
264
  origin,
318
- css.safeData,
319
- css.branchId,
265
+ ccr.safeData,
266
+ ccr.branchId,
320
267
  currentDocumentId,
321
268
  documentSyncStore,
322
269
  ]);
270
+ const featurePuckPlugins = ccr.featurePuckPlugins;
323
271
  const plugins = useMemo(() => {
324
272
  const result = [p1Plugin, documentSyncPlugin];
273
+ result.push(...featurePuckPlugins);
325
274
  if (additionalPluginsRef.current) {
326
275
  result.push(...additionalPluginsRef.current);
327
276
  }
328
277
  return result;
329
- }, [p1Plugin, documentSyncPlugin, pluginCount]);
330
- // =========================================================================
331
- // Stable onChange (disabled for historical versions, guarded across
332
- // document switches)
333
- // =========================================================================
334
- const isViewingHistoricalRef = useRef(css.isViewingHistoricalVersion);
335
- isViewingHistoricalRef.current = css.isViewingHistoricalVersion;
336
- // With Puck surviving document switches, onChange can fire while the canvas
337
- // still shows the previous document but css already targets the new one
338
- // (load in flight, or loaded but not yet pushed by the sync plugin). Saving
339
- // then would write the old page's content into the new page — drop instead.
278
+ }, [p1Plugin, documentSyncPlugin, featurePuckPlugins, pluginCount]);
279
+ const isViewingHistoricalRef = useRef(ccr.isViewingHistoricalVersion);
280
+ isViewingHistoricalRef.current = ccr.isViewingHistoricalVersion;
340
281
  const saveTargetKeyRef = useRef(null);
341
- saveTargetKeyRef.current = css.currentDocument?.id
342
- ? documentSyncKey(css.branchId, css.currentDocument.id)
282
+ saveTargetKeyRef.current = ccr.currentDocument?.id
283
+ ? documentSyncKey(ccr.branchId, ccr.currentDocument.id)
343
284
  : null;
344
285
  const eagerVersionHandler = useMemo(() => makeEagerVersionHandler(needsVersionRef, () => eagerVersionParamsRef.current, {
345
- createVersion: (siteId, params) => css.client.versions.create(siteId, params),
286
+ createVersion: (siteId, params) => ccr.client.versions.create(siteId, params),
346
287
  refreshVersions,
347
- }), [css.client, refreshVersions]);
348
- const { saveData } = css;
288
+ }), [ccr.client, refreshVersions]);
289
+ const { saveData } = ccr;
349
290
  const onChange = useCallback((data) => {
350
291
  if (isViewingHistoricalRef.current)
351
292
  return;
352
- // The blank sentinel stays permissive so a consumer running without the
353
- // document-sync plugin is not frozen read-only.
354
293
  const appliedKey = documentSyncStore.getAppliedKey();
355
294
  if (appliedKey !== BLANK_SYNC_KEY && appliedKey !== saveTargetKeyRef.current) {
356
295
  console.warn('[useP1Editor] save SKIPPED: canvas/document mismatch during switch.', 'canvas:', appliedKey, 'target:', saveTargetKeyRef.current);
@@ -359,44 +298,21 @@ export function useP1Editor(options) {
359
298
  eagerVersionHandler(data);
360
299
  saveData(data);
361
300
  }, [saveData, documentSyncStore, eagerVersionHandler]);
362
- // =========================================================================
363
- // Permissions (read-only for historical versions)
364
- // =========================================================================
365
301
  const permissions = useMemo(() => {
366
- if (css.isViewingHistoricalVersion) {
367
- // Omit edit:false so page/root fields are never locked by Puck's own
368
- // readonly rendering. Interaction is blocked by ReadOnlyFieldsGuard
369
- // (inert attribute) instead, which also covers root fields without
370
- // requiring resolvePermissions on config.root.
302
+ if (ccr.isViewingHistoricalVersion) {
371
303
  return { delete: false, drag: false, duplicate: false, insert: false };
372
304
  }
373
305
  return { delete: true, drag: true, duplicate: true, edit: true, insert: true };
374
- }, [css.isViewingHistoricalVersion]);
375
- // =========================================================================
376
- // Stable merged overrides
377
- // =========================================================================
378
- // Merge additional overrides (e.g. from media plugins) with P1 overrides.
379
- // Uses ref pattern to keep the merge stable — only recomputes when
380
- // p1Overrides changes, not when additionalOverrides reference changes
381
- // (which would happen every render if the consumer doesn't memoize).
306
+ }, [ccr.isViewingHistoricalVersion]);
382
307
  const additionalOverridesRef = useRef(additionalOverrides);
383
308
  additionalOverridesRef.current = additionalOverrides;
384
- // Thumbnail override — built from the thumbnails map and merged between
385
- // p1Overrides and additionalOverrides so the site can still fully override
386
- // componentItem if needed.
387
309
  const thumbnailsRef = useRef(thumbnails);
388
310
  thumbnailsRef.current = thumbnails;
389
- // Live thumbnail drawer — default ON for every consumer. Uses raw puckConfig
390
- // (not configWithPermissions) so previews show all components regardless of
391
- // role. Because useMemo deps on p1Overrides (stable after mount), changes to
392
- // puckConfig or liveThumbnailDrawer after mount are not picked up.
393
311
  const puckConfigRef = useRef(puckConfig);
394
312
  puckConfigRef.current = puckConfig;
395
313
  const liveThumbnailDrawerRef = useRef(liveThumbnailDrawer);
396
314
  liveThumbnailDrawerRef.current = liveThumbnailDrawer;
397
315
  const mergedOverrides = useMemo(() => {
398
- // Layer order (last wins):
399
- // p1Overrides → liveThumbnailDrawer → thumbnailOverride → additionalOverrides
400
316
  const layers = [
401
317
  p1Overrides,
402
318
  resolveLiveThumbnailDrawer(puckConfigRef.current, liveThumbnailDrawerRef.current),
@@ -418,35 +334,16 @@ export function useP1Editor(options) {
418
334
  }
419
335
  }
420
336
  }
421
- return merged;
337
+ return withFreshFieldTypes(merged);
422
338
  }, [p1Overrides]);
423
- // =========================================================================
424
- // Assemble puckProps
425
- // =========================================================================
426
- // Key that forces Puck to remount on role change (let puck internally manage the change on document change),
427
- // ensuring clean undo history, sidebar state, and fresh permission cache.
428
- // Puck caches resolvePermissions results per component instance — the
429
- // cache is only invalidated when component data changes, not when the
430
- // resolver function changes. Including userRole in the key forces a
431
- // clean remount with an empty cache when roles switch.
432
- const puckKey = `css-${css.userRole}`;
433
- // Sidebar visibility for the initial mount. puckKey is the dependency on
434
- // purpose even though it is not read here: a new key remounts Puck, which
435
- // re-reads this as its initial `ui`, so the budget must be applied again.
436
- // eslint-disable-next-line react-hooks/exhaustive-deps
339
+ const puckKey = `p1-${ccr.userRole}`;
437
340
  const initialSidebarUi = useMemo(() => initialPanelUi(), [puckKey]);
438
- // Focus highlighting is handled via direct DOM manipulation in
439
- // PresenceFocusBridge (P1App.tsx) no config wrapping needed.
440
- // Inject per-component resolvePermissions into the Puck config.
441
- // Puck doesn't have a top-level resolvePermissions prop — permissions
442
- // must be resolved per-component via config[type].resolvePermissions.
443
- const resolvePermsRef = useRef(css.resolvePermissions);
444
- resolvePermsRef.current = css.resolvePermissions;
445
- // Template mode: editing a template document (path `_registry/templates/<name>`).
446
- const isTemplateMode = /^_registry\/templates\//.test(css.currentDocument?.path ?? '');
341
+ const resolvePermsRef = useRef(ccr.resolvePermissions);
342
+ resolvePermsRef.current = ccr.resolvePermissions;
343
+ const isTemplateMode = /^_registry\/templates\//.test(ccr.currentDocument?.path ?? '');
447
344
  const configWithPermissions = useMemo(() => {
448
345
  let cfg = puckConfig;
449
- if (css.resolvePermissions) {
346
+ if (ccr.resolvePermissions) {
450
347
  const components = (cfg.components ?? {});
451
348
  const wrapped = {};
452
349
  for (const [name, comp] of Object.entries(components)) {
@@ -457,12 +354,6 @@ export function useP1Editor(options) {
457
354
  if (!resolver)
458
355
  return params.permissions;
459
356
  const basePerms = resolver({ type: name, props: data?.props }, {});
460
- // Template-authoring mode: the context resolver only sees a
461
- // metadata summary (no pins), so the document's live _pinMap is the
462
- // pin source. On a bound page the resolver reads the live template
463
- // and already governs pins, so the page's own snapshot pinMap is
464
- // ignored — otherwise a stale pin would stay locked after the
465
- // template unpins it.
466
357
  if (isTemplateMode) {
467
358
  const pinMap = (params.appState?.data?.root?.props?._pinMap ?? {});
468
359
  const compId = data?.props?.id;
@@ -476,31 +367,43 @@ export function useP1Editor(options) {
476
367
  }
477
368
  cfg = { ...cfg, components: wrapped };
478
369
  }
479
- // In template mode, relabel the right-sidebar root header "Page" -> "Template".
480
- // Puck derives that heading from `config.root.label` (no override hook exists).
481
370
  if (isTemplateMode) {
482
371
  const root = (cfg.root ?? {});
483
372
  cfg = { ...cfg, root: { ...root, label: 'Template' } };
484
373
  }
485
374
  return cfg;
486
- }, [puckConfig, !!css.resolvePermissions, isTemplateMode]);
375
+ }, [puckConfig, !!ccr.resolvePermissions, isTemplateMode]);
487
376
  const puckProps = useMemo(() => ({
488
377
  config: configWithPermissions,
489
- data: css.safeData,
378
+ data: ccr.safeData,
490
379
  onChange,
491
380
  plugins,
492
381
  overrides: mergedOverrides,
493
382
  ui: initialSidebarUi,
494
383
  permissions,
495
- onAction: css.handleAction,
496
- }), [configWithPermissions, css.safeData, onChange, plugins, mergedOverrides, initialSidebarUi, permissions, css.handleAction]);
384
+ onAction: ccr.handleAction,
385
+ }), [configWithPermissions, ccr.safeData, onChange, plugins, mergedOverrides, initialSidebarUi, permissions, ccr.handleAction]);
386
+ const inFlight = branchBootError === null && loading;
387
+ const lastGoodRef = useRef(null);
388
+ const settled = loadedPathRef.current === documentPath && loadedBranchRef.current === ccr.branchId;
389
+ if (settled && !inFlight && !error && !branchBootError) {
390
+ lastGoodRef.current = { puckKey, puckProps };
391
+ }
392
+ const retained = lastGoodRef.current;
393
+ const hasContent = retained !== null;
394
+ const reloadKind = loadedBranchRef.current !== null && loadedBranchRef.current !== ccr.branchId
395
+ ? 'branch'
396
+ : 'document';
497
397
  return {
498
- loading: branchBootError === null && loading,
398
+ loading: inFlight && !hasContent,
399
+ reloading: inFlight && hasContent ? reloadKind : null,
400
+ hasContent,
499
401
  error: error ?? branchBootError,
500
- puckKey,
501
- puckProps,
502
- css,
503
- /** @deprecated No longer emitted — editor now shows an empty state when a document is not found on the current branch. */
402
+ notFound,
403
+ retry,
404
+ puckKey: retained?.puckKey ?? puckKey,
405
+ puckProps: retained?.puckProps ?? puckProps,
406
+ css: ccr,
504
407
  redirectPath: null,
505
408
  };
506
409
  }