payload-canvas 0.4.0 → 0.5.1

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 (468) hide show
  1. package/README.md +626 -154
  2. package/dist/admin/AiKeyField.d.ts +8 -0
  3. package/dist/admin/AiKeyField.js +54 -0
  4. package/dist/admin/BuilderTab.js +4 -1
  5. package/dist/admin/DocumentEditView.d.ts +9 -0
  6. package/dist/admin/DocumentEditView.js +45 -0
  7. package/dist/admin/LayoutField.d.ts +2 -2
  8. package/dist/admin/LayoutField.js +10 -7
  9. package/dist/admin/TemplateConditionsField.d.ts +9 -0
  10. package/dist/admin/TemplateConditionsField.js +22 -0
  11. package/dist/admin/aiKeyField.scss +58 -0
  12. package/dist/admin/client.d.ts +3 -0
  13. package/dist/admin/client.js +6 -0
  14. package/dist/admin/diff/changes.js +5 -0
  15. package/dist/admin/editor/Canvas.js +20 -5
  16. package/dist/admin/editor/Editor.d.ts +3 -1
  17. package/dist/admin/editor/Editor.js +6 -3
  18. package/dist/admin/editor/Inspector.js +75 -28
  19. package/dist/admin/editor/Library.js +40 -15
  20. package/dist/admin/editor/Outline.js +21 -16
  21. package/dist/admin/editor/Overlay.js +8 -3
  22. package/dist/admin/editor/actions.d.ts +10 -2
  23. package/dist/admin/editor/actions.js +18 -3
  24. package/dist/admin/editor/assistant/AssistantPanel.js +3 -1
  25. package/dist/admin/editor/classes/ClassManager.d.ts +4 -0
  26. package/dist/admin/editor/classes/ClassManager.js +56 -0
  27. package/dist/admin/editor/classes/controller.d.ts +112 -0
  28. package/dist/admin/editor/classes/controller.js +326 -0
  29. package/dist/admin/editor/classes/manager.scss +262 -0
  30. package/dist/admin/editor/classes/managerModel.d.ts +5 -0
  31. package/dist/admin/editor/classes/managerModel.js +27 -0
  32. package/dist/admin/editor/comments/CommentLayer.d.ts +2 -0
  33. package/dist/admin/editor/comments/CommentLayer.js +143 -0
  34. package/dist/admin/editor/comments/CommentsPanel.d.ts +8 -0
  35. package/dist/admin/editor/comments/CommentsPanel.js +73 -0
  36. package/dist/admin/editor/comments/Thread.d.ts +26 -0
  37. package/dist/admin/editor/comments/Thread.js +84 -0
  38. package/dist/admin/editor/comments/comments.scss +539 -0
  39. package/dist/admin/editor/comments/controller.d.ts +48 -0
  40. package/dist/admin/editor/comments/controller.js +142 -0
  41. package/dist/admin/editor/contentMode.d.ts +17 -0
  42. package/dist/admin/editor/contentMode.js +37 -0
  43. package/dist/admin/editor/dnd/DropOutlines.d.ts +1 -0
  44. package/dist/admin/editor/dnd/DropOutlines.js +73 -0
  45. package/dist/admin/editor/dnd/dnd.scss +43 -0
  46. package/dist/admin/editor/dnd/mode.d.ts +4 -0
  47. package/dist/admin/editor/dnd/mode.js +39 -0
  48. package/dist/admin/editor/editor.scss +13 -58
  49. package/dist/admin/editor/empty/EmptyStart.js +18 -66
  50. package/dist/admin/editor/fields/AddButton.d.ts +15 -0
  51. package/dist/admin/editor/fields/AddButton.js +14 -0
  52. package/dist/admin/editor/fields/ArrayField.js +3 -2
  53. package/dist/admin/editor/fields/CheckedInputs.d.ts +1 -0
  54. package/dist/admin/editor/fields/ConditionRows.d.ts +19 -0
  55. package/dist/admin/editor/fields/ConditionRows.js +137 -0
  56. package/dist/admin/editor/fields/ListWhereField.d.ts +8 -0
  57. package/dist/admin/editor/fields/ListWhereField.js +20 -0
  58. package/dist/admin/editor/fields/QueryFiltersField.d.ts +18 -0
  59. package/dist/admin/editor/fields/QueryFiltersField.js +41 -0
  60. package/dist/admin/editor/fields/RelatedField.d.ts +19 -0
  61. package/dist/admin/editor/fields/RelatedField.js +44 -0
  62. package/dist/admin/editor/fields/SortField.d.ts +13 -0
  63. package/dist/admin/editor/fields/SortField.js +37 -0
  64. package/dist/admin/editor/fields/WhereField.d.ts +12 -4
  65. package/dist/admin/editor/fields/WhereField.js +33 -53
  66. package/dist/admin/editor/fields/collectionFields.d.ts +6 -0
  67. package/dist/admin/editor/fields/collectionFields.js +15 -0
  68. package/dist/admin/editor/fields/conditions.d.ts +99 -0
  69. package/dist/admin/editor/fields/conditions.js +339 -0
  70. package/dist/admin/editor/fields/fields.scss +232 -9
  71. package/dist/admin/editor/fields/listOptions.d.ts +44 -0
  72. package/dist/admin/editor/fields/listOptions.js +111 -0
  73. package/dist/admin/editor/fields/queryFilterRows.d.ts +8 -0
  74. package/dist/admin/editor/fields/queryFilterRows.js +29 -0
  75. package/dist/admin/editor/fields/whereRows.d.ts +11 -12
  76. package/dist/admin/editor/fields/whereRows.js +83 -34
  77. package/dist/admin/editor/icons.d.ts +16 -1
  78. package/dist/admin/editor/icons.js +30 -1
  79. package/dist/admin/editor/inline.js +9 -0
  80. package/dist/admin/editor/insert/InsertHandle.js +4 -1
  81. package/dist/admin/editor/insert/picker.d.ts +3 -1
  82. package/dist/admin/editor/insert/picker.js +17 -10
  83. package/dist/admin/editor/insert/spots.d.ts +12 -1
  84. package/dist/admin/editor/insert/spots.js +49 -10
  85. package/dist/admin/editor/layout/LeftPanel.js +11 -6
  86. package/dist/admin/editor/live/useMultiplayer.js +9 -1
  87. package/dist/admin/editor/menu/blockMenu.js +27 -17
  88. package/dist/admin/editor/names.js +11 -3
  89. package/dist/admin/editor/renderField.d.ts +3 -1
  90. package/dist/admin/editor/renderField.js +63 -12
  91. package/dist/admin/editor/runtime.d.ts +14 -0
  92. package/dist/admin/editor/runtime.js +67 -6
  93. package/dist/admin/editor/sections/ComponentFields.d.ts +8 -0
  94. package/dist/admin/editor/sections/ComponentFields.js +116 -0
  95. package/dist/admin/editor/sections/PropertyControls.d.ts +18 -0
  96. package/dist/admin/editor/sections/PropertyControls.js +65 -0
  97. package/dist/admin/editor/sections/components.d.ts +29 -0
  98. package/dist/admin/editor/sections/components.js +112 -0
  99. package/dist/admin/editor/sections/components.scss +238 -0
  100. package/dist/admin/editor/sections/variants.d.ts +32 -0
  101. package/dist/admin/editor/sections/variants.js +59 -0
  102. package/dist/admin/editor/sections/variants.scss +90 -0
  103. package/dist/admin/editor/shortcuts.d.ts +4 -1
  104. package/dist/admin/editor/shortcuts.js +19 -3
  105. package/dist/admin/editor/store.d.ts +18 -0
  106. package/dist/admin/editor/store.js +46 -0
  107. package/dist/admin/editor/styles/ClassBar.d.ts +14 -0
  108. package/dist/admin/editor/styles/ClassBar.js +90 -0
  109. package/dist/admin/editor/styles/ClassCss.d.ts +4 -0
  110. package/dist/admin/editor/styles/ClassCss.js +28 -0
  111. package/dist/admin/editor/styles/ClassDialog.d.ts +2 -0
  112. package/dist/admin/editor/styles/ClassDialog.js +151 -0
  113. package/dist/admin/editor/styles/ColorPicker.js +5 -2
  114. package/dist/admin/editor/styles/RawClasses.d.ts +26 -1
  115. package/dist/admin/editor/styles/RawClasses.js +184 -32
  116. package/dist/admin/editor/styles/StylesPanel.d.ts +3 -3
  117. package/dist/admin/editor/styles/StylesPanel.js +53 -14
  118. package/dist/admin/editor/styles/VariantBar.js +2 -2
  119. package/dist/admin/editor/styles/classEdit.d.ts +4 -0
  120. package/dist/admin/editor/styles/classEdit.js +20 -0
  121. package/dist/admin/editor/styles/classes.scss +381 -0
  122. package/dist/admin/editor/styles/context.d.ts +19 -6
  123. package/dist/admin/editor/styles/context.js +24 -6
  124. package/dist/admin/editor/styles/controls.d.ts +3 -1
  125. package/dist/admin/editor/styles/controls.js +30 -12
  126. package/dist/admin/editor/styles/popover.d.ts +6 -0
  127. package/dist/admin/editor/styles/popover.js +5 -5
  128. package/dist/admin/editor/styles/styles.scss +26 -104
  129. package/dist/admin/editor/styles/suggestions.d.ts +22 -0
  130. package/dist/admin/editor/styles/suggestions.js +77 -0
  131. package/dist/admin/editor/styles/tokens.js +14 -0
  132. package/dist/admin/editor/templates/Bindable.js +86 -57
  133. package/dist/admin/editor/templates/SamplePicker.js +1 -1
  134. package/dist/admin/editor/templates/Visibility.d.ts +9 -0
  135. package/dist/admin/editor/templates/Visibility.js +54 -0
  136. package/dist/admin/editor/templates/binding.d.ts +2 -2
  137. package/dist/admin/editor/templates/binding.js +2 -2
  138. package/dist/admin/editor/templates/templates.scss +27 -0
  139. package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
  140. package/dist/admin/editor/templates/visibilityRows.js +83 -0
  141. package/dist/admin/editor/topbar/ContentModeToggle.d.ts +5 -0
  142. package/dist/admin/editor/topbar/ContentModeToggle.js +26 -0
  143. package/dist/admin/editor/topbar/DocumentActions.d.ts +1 -1
  144. package/dist/admin/editor/topbar/DocumentActions.js +5 -4
  145. package/dist/admin/editor/topbar/DocumentTitle.js +7 -2
  146. package/dist/admin/editor/topbar/TopBar.js +15 -3
  147. package/dist/admin/editor/topbar/contentMode.scss +35 -0
  148. package/dist/admin/editor/topbar/topbar.scss +3 -1
  149. package/dist/admin/formChoice.d.ts +3 -0
  150. package/dist/admin/formChoice.js +10 -0
  151. package/dist/admin/layoutField.scss +69 -0
  152. package/dist/admin/screen/BuilderScreen.d.ts +6 -1
  153. package/dist/admin/screen/BuilderScreen.js +4 -3
  154. package/dist/admin/server/BuilderView.js +10 -3
  155. package/dist/admin/templateConditions.scss +24 -0
  156. package/dist/ai/adapters/anthropic.js +17 -4
  157. package/dist/ai/adapters/cloudflare-gateway.js +7 -1
  158. package/dist/ai/adapters/cloudflare-workers-ai.js +2 -0
  159. package/dist/ai/adapters/openai-compatible.js +1 -0
  160. package/dist/ai/adapters/openrouter.js +2 -0
  161. package/dist/ai/config.d.ts +24 -4
  162. package/dist/ai/config.js +27 -8
  163. package/dist/ai/endpoint.d.ts +5 -2
  164. package/dist/ai/endpoint.js +31 -26
  165. package/dist/ai/images/cloudflare-workers-ai.js +6 -2
  166. package/dist/ai/images/openai.js +8 -3
  167. package/dist/ai/images/openrouter.js +6 -2
  168. package/dist/ai/images/service.d.ts +10 -4
  169. package/dist/ai/images/service.js +23 -7
  170. package/dist/ai/openai-format.d.ts +7 -0
  171. package/dist/ai/openai-format.js +17 -5
  172. package/dist/ai/prompt.d.ts +8 -0
  173. package/dist/ai/prompt.js +25 -5
  174. package/dist/ai/settings/index.d.ts +62 -0
  175. package/dist/ai/settings/index.js +264 -0
  176. package/dist/ai/settings/secret.d.ts +11 -0
  177. package/dist/ai/settings/secret.js +46 -0
  178. package/dist/ai/settings/shared.d.ts +22 -0
  179. package/dist/ai/settings/shared.js +3 -0
  180. package/dist/ai/tools.d.ts +3 -0
  181. package/dist/ai/tools.js +79 -15
  182. package/dist/ai/types.d.ts +43 -0
  183. package/dist/blocks/builtins/adjacentLinks.d.ts +5 -0
  184. package/dist/blocks/builtins/adjacentLinks.js +76 -0
  185. package/dist/blocks/builtins/carousel.d.ts +2 -29
  186. package/dist/blocks/builtins/carousel.js +44 -51
  187. package/dist/blocks/builtins/disclosure.d.ts +2 -1
  188. package/dist/blocks/builtins/disclosure.js +22 -32
  189. package/dist/blocks/builtins/embed.d.ts +15 -0
  190. package/dist/blocks/builtins/embed.js +47 -0
  191. package/dist/blocks/builtins/faq.d.ts +1 -1
  192. package/dist/blocks/builtins/faq.js +2 -2
  193. package/dist/blocks/builtins/filterLink.d.ts +1 -19
  194. package/dist/blocks/builtins/filterLink.js +9 -50
  195. package/dist/blocks/builtins/icon.d.ts +2 -0
  196. package/dist/blocks/builtins/icon.js +8 -8
  197. package/dist/blocks/builtins/index.d.ts +18 -13
  198. package/dist/blocks/builtins/index.js +43 -22
  199. package/dist/blocks/builtins/marquee.d.ts +5 -0
  200. package/dist/blocks/builtins/marquee.js +68 -0
  201. package/dist/blocks/builtins/popup.d.ts +5 -0
  202. package/dist/blocks/builtins/popup.js +83 -0
  203. package/dist/blocks/builtins/sectionRef.d.ts +16 -2
  204. package/dist/blocks/builtins/sectionRef.js +34 -12
  205. package/dist/blocks/builtins/shared.d.ts +18 -23
  206. package/dist/blocks/builtins/shared.js +34 -42
  207. package/dist/blocks/builtins/tableOfContents.d.ts +4 -0
  208. package/dist/blocks/builtins/tableOfContents.js +12 -18
  209. package/dist/blocks/builtins/tabs.d.ts +6 -0
  210. package/dist/blocks/builtins/tabs.js +87 -0
  211. package/dist/blocks/client/adjacentLinks.d.ts +4 -0
  212. package/dist/blocks/client/adjacentLinks.js +4 -0
  213. package/dist/blocks/client/carousel.d.ts +45 -0
  214. package/dist/blocks/client/carousel.js +53 -0
  215. package/dist/blocks/client/embed.d.ts +21 -0
  216. package/dist/blocks/client/embed.js +23 -0
  217. package/dist/blocks/client/field.d.ts +7 -0
  218. package/dist/blocks/client/field.js +8 -0
  219. package/dist/blocks/client/filterLink.d.ts +19 -0
  220. package/dist/blocks/client/filterLink.js +30 -0
  221. package/dist/blocks/client/helpers.d.ts +21 -0
  222. package/dist/blocks/client/helpers.js +24 -0
  223. package/dist/blocks/client/marquee.d.ts +14 -0
  224. package/dist/blocks/client/marquee.js +25 -0
  225. package/dist/blocks/client/menu.d.ts +46 -0
  226. package/dist/blocks/client/menu.js +49 -0
  227. package/dist/blocks/client/popup.d.ts +15 -0
  228. package/dist/blocks/client/popup.js +16 -0
  229. package/dist/blocks/client/tabs.d.ts +10 -0
  230. package/dist/blocks/client/tabs.js +11 -0
  231. package/dist/blocks/defaults.d.ts +15 -52
  232. package/dist/blocks/defaults.js +203 -437
  233. package/dist/blocks/index.d.ts +1 -1
  234. package/dist/blocks/index.js +2 -1
  235. package/dist/classes/actions.d.ts +97 -0
  236. package/dist/classes/actions.js +296 -0
  237. package/dist/classes/collection.d.ts +5 -0
  238. package/dist/classes/collection.js +189 -0
  239. package/dist/classes/config.d.ts +34 -0
  240. package/dist/classes/config.js +8 -0
  241. package/dist/classes/endpoints.d.ts +2 -0
  242. package/dist/classes/endpoints.js +120 -0
  243. package/dist/classes/index.d.ts +36 -0
  244. package/dist/classes/index.js +42 -0
  245. package/dist/classes/mcp.d.ts +6 -0
  246. package/dist/classes/mcp.js +161 -0
  247. package/dist/classes/shared.d.ts +131 -0
  248. package/dist/classes/shared.js +300 -0
  249. package/dist/classes/sheet.d.ts +34 -0
  250. package/dist/classes/sheet.js +126 -0
  251. package/dist/classes/usage.d.ts +57 -0
  252. package/dist/classes/usage.js +208 -0
  253. package/dist/comments/collection.d.ts +38 -0
  254. package/dist/comments/collection.js +226 -0
  255. package/dist/comments/config.d.ts +15 -0
  256. package/dist/comments/config.js +2 -0
  257. package/dist/comments/index.d.ts +20 -0
  258. package/dist/comments/index.js +22 -0
  259. package/dist/comments/shared.d.ts +54 -0
  260. package/dist/comments/shared.js +104 -0
  261. package/dist/core/bindings.d.ts +77 -32
  262. package/dist/core/bindings.js +319 -134
  263. package/dist/core/blockNames.d.ts +9 -0
  264. package/dist/core/blockNames.js +11 -0
  265. package/dist/core/blocks.d.ts +21 -8
  266. package/dist/core/blocks.js +37 -16
  267. package/dist/core/classes.d.ts +16 -8
  268. package/dist/core/classes.js +31 -27
  269. package/dist/core/components.d.ts +72 -0
  270. package/dist/core/components.js +294 -0
  271. package/dist/core/contentMode.d.ts +27 -0
  272. package/dist/core/contentMode.js +0 -0
  273. package/dist/core/dropTarget.d.ts +11 -0
  274. package/dist/core/dropTarget.js +24 -1
  275. package/dist/core/fields.d.ts +5 -0
  276. package/dist/core/fields.js +11 -0
  277. package/dist/core/headings.d.ts +5 -2
  278. package/dist/core/headings.js +14 -6
  279. package/dist/core/index.d.ts +8 -3
  280. package/dist/core/index.js +8 -3
  281. package/dist/core/layers.d.ts +9 -0
  282. package/dist/core/layers.js +29 -0
  283. package/dist/core/operations.d.ts +6 -0
  284. package/dist/core/operations.js +85 -24
  285. package/dist/core/payloadBlocks.js +5 -1
  286. package/dist/core/references.js +28 -0
  287. package/dist/core/schema.js +20 -6
  288. package/dist/core/sectionOrigin.d.ts +6 -0
  289. package/dist/core/sectionOrigin.js +21 -0
  290. package/dist/core/sections.d.ts +72 -0
  291. package/dist/core/sections.js +331 -0
  292. package/dist/core/templateChoice.d.ts +24 -0
  293. package/dist/core/templateChoice.js +43 -0
  294. package/dist/core/tree.js +18 -6
  295. package/dist/core/types.d.ts +148 -18
  296. package/dist/core/validate.d.ts +4 -1
  297. package/dist/core/validate.js +28 -11
  298. package/dist/core/visibility.d.ts +63 -0
  299. package/dist/core/visibility.js +214 -0
  300. package/dist/core/whereValues.d.ts +22 -0
  301. package/dist/core/whereValues.js +43 -0
  302. package/dist/css/classes.d.ts +16 -0
  303. package/dist/css/classes.js +172 -0
  304. package/dist/css/index.d.ts +32 -1
  305. package/dist/css/index.js +64 -5
  306. package/dist/css/tokens.d.ts +10 -0
  307. package/dist/css/tokens.js +23 -10
  308. package/dist/index.d.ts +5 -2
  309. package/dist/index.js +6 -1
  310. package/dist/live/contentMode.d.ts +24 -0
  311. package/dist/live/contentMode.js +39 -0
  312. package/dist/live/endpoints.js +3 -0
  313. package/dist/live/session.d.ts +5 -0
  314. package/dist/live/session.js +8 -0
  315. package/dist/live/types.d.ts +16 -1
  316. package/dist/mcp/index.d.ts +10 -1
  317. package/dist/mcp/index.js +146 -54
  318. package/dist/mcp/shared.d.ts +93 -3
  319. package/dist/mcp/shared.js +211 -15
  320. package/dist/plugin/hook.d.ts +7 -1
  321. package/dist/plugin/hook.js +30 -4
  322. package/dist/plugin/index.d.ts +19 -8
  323. package/dist/plugin/index.js +89 -20
  324. package/dist/plugin/links.d.ts +24 -0
  325. package/dist/plugin/links.js +27 -0
  326. package/dist/plugin/listCollections.d.ts +9 -7
  327. package/dist/plugin/listCollections.js +30 -21
  328. package/dist/plugin/sections.d.ts +14 -7
  329. package/dist/plugin/sections.js +69 -23
  330. package/dist/plugin/sectionsUsedIn.d.ts +6 -0
  331. package/dist/plugin/sectionsUsedIn.js +24 -0
  332. package/dist/plugin/templateEndpoint.d.ts +9 -0
  333. package/dist/plugin/templateEndpoint.js +49 -0
  334. package/dist/plugin/templates.js +23 -8
  335. package/dist/protocol/index.d.ts +16 -1
  336. package/dist/react/canvas/BuilderCanvas.js +144 -21
  337. package/dist/react/canvas/classes.d.ts +17 -0
  338. package/dist/react/canvas/classes.js +102 -0
  339. package/dist/react/canvas/controls.d.ts +31 -0
  340. package/dist/react/canvas/controls.js +75 -0
  341. package/dist/react/canvas/fetchDocs.d.ts +2 -2
  342. package/dist/react/canvas/fetchDocs.js +16 -8
  343. package/dist/react/canvas/measure.d.ts +9 -0
  344. package/dist/react/canvas/measure.js +106 -7
  345. package/dist/react/canvas/resolveLayout.d.ts +1 -1
  346. package/dist/react/canvas/resolveLayout.js +4 -3
  347. package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +17 -4
  348. package/dist/react/classes/ClassesStyle.d.ts +27 -0
  349. package/dist/react/classes/ClassesStyle.js +27 -0
  350. package/dist/react/components/Button.d.ts +2 -11
  351. package/dist/react/components/Button.js +8 -43
  352. package/dist/react/components/CollectionList.d.ts +4 -1
  353. package/dist/react/components/CollectionList.js +10 -3
  354. package/dist/react/components/Container.d.ts +5 -2
  355. package/dist/react/components/Container.js +7 -4
  356. package/dist/react/components/Field.js +3 -14
  357. package/dist/react/components/Link.d.ts +1 -1
  358. package/dist/react/components/Link.js +5 -3
  359. package/dist/react/components/List.d.ts +1 -1
  360. package/dist/react/components/List.js +2 -2
  361. package/dist/react/components/Menu.d.ts +10 -1
  362. package/dist/react/components/Menu.js +39 -12
  363. package/dist/react/components/RichText.d.ts +3 -4
  364. package/dist/react/components/RichText.js +5 -5
  365. package/dist/react/components/builtins/Accordion.d.ts +4 -3
  366. package/dist/react/components/builtins/Accordion.js +6 -5
  367. package/dist/react/components/builtins/AdjacentLinks.d.ts +11 -0
  368. package/dist/react/components/builtins/AdjacentLinks.js +20 -0
  369. package/dist/react/components/builtins/Carousel.d.ts +21 -10
  370. package/dist/react/components/builtins/Carousel.js +175 -100
  371. package/dist/react/components/builtins/Disclosure.d.ts +4 -3
  372. package/dist/react/components/builtins/Disclosure.js +6 -5
  373. package/dist/react/components/builtins/Embed.d.ts +11 -0
  374. package/dist/react/components/builtins/Embed.js +23 -0
  375. package/dist/react/components/builtins/EmbedHtml.d.ts +15 -0
  376. package/dist/react/components/builtins/EmbedHtml.js +51 -0
  377. package/dist/react/components/builtins/EmbedPreview.d.ts +34 -0
  378. package/dist/react/components/builtins/EmbedPreview.js +105 -0
  379. package/dist/react/components/builtins/FilterLink.d.ts +1 -1
  380. package/dist/react/components/builtins/FilterLink.js +4 -4
  381. package/dist/react/components/builtins/Marquee.d.ts +8 -0
  382. package/dist/react/components/builtins/Marquee.js +15 -0
  383. package/dist/react/components/builtins/Popup.d.ts +26 -0
  384. package/dist/react/components/builtins/Popup.js +146 -0
  385. package/dist/react/components/builtins/SectionRef.d.ts +4 -3
  386. package/dist/react/components/builtins/SectionRef.js +9 -5
  387. package/dist/react/components/builtins/Tab.d.ts +7 -0
  388. package/dist/react/components/builtins/Tab.js +21 -0
  389. package/dist/react/components/builtins/TableOfContents.d.ts +17 -3
  390. package/dist/react/components/builtins/TableOfContents.js +22 -7
  391. package/dist/react/components/builtins/Tabs.d.ts +17 -0
  392. package/dist/react/components/builtins/Tabs.js +71 -0
  393. package/dist/react/components/builtins/index.d.ts +37 -20
  394. package/dist/react/components/builtins/index.js +54 -20
  395. package/dist/react/components/builtins/tabsContext.d.ts +12 -0
  396. package/dist/react/components/builtins/tabsContext.js +6 -0
  397. package/dist/react/components/index.js +11 -8
  398. package/dist/react/components/lazy.d.ts +32 -0
  399. package/dist/react/components/lazy.js +20 -0
  400. package/dist/react/components/lazyBlock.d.ts +17 -0
  401. package/dist/react/components/lazyBlock.js +23 -0
  402. package/dist/react/index.d.ts +6 -3
  403. package/dist/react/index.js +5 -2
  404. package/dist/react/render/RenderLayout.d.ts +9 -7
  405. package/dist/react/render/RenderLayout.js +96 -45
  406. package/dist/react/render/canvasMode.d.ts +13 -0
  407. package/dist/react/render/canvasMode.js +13 -0
  408. package/dist/react/render/canvasServer.js +4 -3
  409. package/dist/react/render/canvasServerTypes.d.ts +5 -0
  410. package/dist/react/render/lists.d.ts +36 -4
  411. package/dist/react/render/lists.js +132 -15
  412. package/dist/react/render/marks.d.ts +15 -0
  413. package/dist/react/render/marks.js +23 -0
  414. package/dist/react/render/payload.d.ts +8 -1
  415. package/dist/react/render/payload.js +12 -3
  416. package/dist/react/render/preview.d.ts +11 -0
  417. package/dist/react/render/preview.js +13 -0
  418. package/dist/react/render/relations.d.ts +10 -0
  419. package/dist/react/render/relations.js +39 -0
  420. package/dist/react/render/resolve.d.ts +8 -4
  421. package/dist/react/render/resolve.js +11 -5
  422. package/dist/react/render/reveal.d.ts +17 -0
  423. package/dist/react/render/reveal.js +39 -0
  424. package/dist/react/render/sections.d.ts +11 -5
  425. package/dist/react/render/sections.js +52 -24
  426. package/dist/react/render/templates.d.ts +47 -0
  427. package/dist/react/render/templates.js +139 -0
  428. package/dist/react/render/types.d.ts +62 -5
  429. package/dist/react/server.d.ts +2 -37
  430. package/dist/react/server.js +8 -133
  431. package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
  432. package/dist/react/theme/ThemeLiveLoader.js +5 -0
  433. package/dist/react/theme/ThemeStyle.js +1 -1
  434. package/dist/theme/admin/Variables.d.ts +11 -0
  435. package/dist/theme/admin/Variables.js +115 -0
  436. package/dist/theme/admin/fields.scss +113 -0
  437. package/dist/theme/client.d.ts +1 -0
  438. package/dist/theme/client.js +2 -0
  439. package/dist/theme/css.d.ts +6 -1
  440. package/dist/theme/css.js +12 -4
  441. package/dist/theme/global.js +83 -0
  442. package/dist/theme/index.d.ts +1 -0
  443. package/dist/theme/index.js +1 -0
  444. package/dist/theme/server.d.ts +15 -0
  445. package/dist/theme/server.js +43 -0
  446. package/dist/theme/usage.d.ts +23 -0
  447. package/dist/theme/usage.js +68 -0
  448. package/dist/theme/variables.d.ts +72 -0
  449. package/dist/theme/variables.js +231 -0
  450. package/package.json +4 -2
  451. package/dist/admin/editor/styles/SiteClasses.d.ts +0 -9
  452. package/dist/admin/editor/styles/SiteClasses.js +0 -31
  453. package/dist/blocks/builtins/headingId.d.ts +0 -15
  454. package/dist/blocks/builtins/headingId.js +0 -36
  455. package/dist/blocks/builtins/lightbox.d.ts +0 -43
  456. package/dist/blocks/builtins/lightbox.js +0 -93
  457. package/dist/blocks/builtins/mediaBackdrop.d.ts +0 -11
  458. package/dist/blocks/builtins/mediaBackdrop.js +0 -79
  459. package/dist/react/components/Quote.d.ts +0 -3
  460. package/dist/react/components/Quote.js +0 -12
  461. package/dist/react/components/Spacer.d.ts +0 -3
  462. package/dist/react/components/Spacer.js +0 -6
  463. package/dist/react/components/builtins/BackdropVideo.d.ts +0 -13
  464. package/dist/react/components/builtins/BackdropVideo.js +0 -16
  465. package/dist/react/components/builtins/Lightbox.d.ts +0 -45
  466. package/dist/react/components/builtins/Lightbox.js +0 -252
  467. package/dist/react/components/builtins/MediaBackdrop.d.ts +0 -14
  468. package/dist/react/components/builtins/MediaBackdrop.js +0 -61
@@ -2,8 +2,9 @@
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { CheckboxInput, TextInput } from '@payloadcms/ui';
4
4
  import { useDeferredValue, useEffect, useState } from 'react';
5
- import { findBlock, getBlockDefinition, htmlIdProblem, htmlIdsOf } from '../../core/index.js';
5
+ import { blockParts, findBlock, getBlockDefinition, htmlIdProblem, htmlIdsOf } from '../../core/index.js';
6
6
  import { BlockIcon, Icon } from './icons.js';
7
+ import { useContentMode } from './contentMode.js';
7
8
  import { blockMenuEntries } from './menu/blockMenu.js';
8
9
  import { MenuButton } from './menu/Menu.js';
9
10
  import { renameRequest } from './menu/requests.js';
@@ -25,6 +26,8 @@ import { Select } from './ui/Select.js';
25
26
  import { usePayloadControlNames } from './ui/payloadA11y.js';
26
27
  import { useOptionalValue, useValue, useValueSelector } from './valueStore.js';
27
28
  import { RegionPane } from './regions/RegionPane.js';
29
+ import { SECTION_REF_BLOCK } from '../../blocks/builtins/sectionRef.js';
30
+ import { ComponentBanner, ComponentValuesPanel } from './sections/ComponentFields.js';
28
31
  function Tabs({ value, options, onChange, variant = 'underline' }) {
29
32
  return (_jsx("div", { className: variant === 'segmented' ? 'builder-editor__segmented builder-editor__segmented--full' : 'builder-editor__tabs', role: "tablist", children: options.map((option) => (_jsxs("button", { type: "button", role: "tab", "aria-selected": value === option.id, className: variant === 'segmented' ? 'builder-editor__segment' : 'builder-editor__tab', onClick: () => onChange(option.id), children: [option.icon && _jsx(Icon, { name: option.icon, size: 13 }), option.label] }, option.id))) }));
30
33
  }
@@ -41,7 +44,7 @@ export function Inspector() {
41
44
  return (_jsxs("div", { ref: inspectorRef, className: "builder-editor__inspector", children: [runtime.assistant && (_jsx("div", { className: "builder-editor__inspector-head", children: _jsx(Tabs, { value: tab, onChange: setTab, variant: "segmented", options: [
42
45
  { id: 'block', label: 'Block' },
43
46
  { id: 'assistant', label: 'Assistant', icon: 'sparkle' },
44
- ] }) })), _jsx("div", { className: "builder-editor__inspector-body", hidden: tab !== 'block', children: _jsx(BlockPane, {}) }), runtime.assistant && _jsx(AssistantPanel, { hidden: tab !== 'assistant' })] }));
47
+ ] }) })), _jsxs("div", { className: "builder-editor__inspector-body", hidden: tab !== 'block', children: [_jsx(ComponentBanner, {}), _jsx(BlockPane, {})] }), runtime.assistant && _jsx(AssistantPanel, { hidden: tab !== 'assistant' })] }));
45
48
  }
46
49
  const TIP_LABELS = {
47
50
  'Publish changes': 'Publish',
@@ -51,11 +54,48 @@ const TIP_LABELS = {
51
54
  Undo: 'Undo',
52
55
  'Show this list': 'All shortcuts',
53
56
  };
57
+ /** The tips content mode keeps: the others add, copy or paste blocks. */
58
+ const CONTENT_TIPS = new Set(['Publish changes', 'Open or close the AI assistant', 'Undo', 'Show this list']);
54
59
  function EmptyState() {
55
60
  const runtime = useRuntime();
56
61
  const drafts = useValueSelector(runtime.doc.meta, (meta) => meta.drafts);
57
- const tips = shortcutList({ ai: Boolean(runtime.assistant), publish: drafts }).filter((s) => s.label in TIP_LABELS);
58
- return (_jsxs("div", { className: "builder-editor__empty builder-editor__empty--inspector", children: [_jsx(Icon, { name: "cursor", size: 20 }), _jsx("p", { children: "No block selected" }), _jsx("p", { className: "builder-editor__hint", children: "Click a block on the canvas or in Layers to edit its content and styles. Drag blocks from the Blocks tab to build the page." }), _jsx("dl", { className: "builder-editor__tips", children: tips.map(({ keys, label }) => (_jsxs("div", { className: "builder-editor__help-row", children: [_jsx("dt", { children: TIP_LABELS[label] }), _jsx("dd", { children: keys.map((k) => (_jsx("kbd", { children: k }, k))) })] }, label))) })] }));
62
+ const contentMode = useContentMode(runtime);
63
+ const tips = shortcutList({ ai: Boolean(runtime.assistant), publish: drafts }).filter((s) => s.label in TIP_LABELS && (!contentMode || s.label in CONTENT_TIPS));
64
+ return (_jsxs("div", { className: "builder-editor__empty builder-editor__empty--inspector", children: [_jsx(Icon, { name: "cursor", size: 20 }), _jsx("p", { children: "No block selected" }), _jsx("p", { className: "builder-editor__hint", children: contentMode
65
+ ? 'Click a text, image or link on the canvas or in Layers to edit it.'
66
+ : 'Click a block on the canvas or in Layers to edit its content and styles. Drag blocks from the Blocks tab to build the page.' }), _jsx("dl", { className: "builder-editor__tips", children: tips.map(({ keys, label }) => (_jsxs("div", { className: "builder-editor__help-row", children: [_jsx("dt", { children: TIP_LABELS[label] }), _jsx("dd", { children: keys.map((k) => (_jsx("kbd", { children: k }, k))) })] }, label))) })] }));
67
+ }
68
+ const TAB_STORAGE_KEY = 'payload-builder:inspector-tab';
69
+ const BLOCK_TABS = ['content', 'styles', 'motion', 'advanced'];
70
+ /** The tab the user last chose, kept in this browser. Styles first, as in Webflow. */
71
+ function readTabChoice() {
72
+ try {
73
+ const value = localStorage.getItem(TAB_STORAGE_KEY);
74
+ return BLOCK_TABS.includes(value) ? value : 'styles';
75
+ }
76
+ catch {
77
+ return 'styles';
78
+ }
79
+ }
80
+ function saveTabChoice(tab) {
81
+ try {
82
+ localStorage.setItem(TAB_STORAGE_KEY, tab);
83
+ }
84
+ catch {
85
+ // Storage blocked: the choice lasts until the editor closes.
86
+ }
87
+ }
88
+ /** The tab a block opens on: the chosen tab, unless the block has nothing to show there. */
89
+ function tabFor(chosen, def, justAdded) {
90
+ const hasFields = (def?.fields.length ?? 0) > 0;
91
+ // A block that was just added opens on its content, so typing starts at once.
92
+ if (justAdded && hasFields)
93
+ return 'content';
94
+ if (chosen !== 'content' && def?.styles === false)
95
+ return 'content';
96
+ if (chosen === 'content' && !hasFields && def?.styles !== false)
97
+ return 'styles';
98
+ return chosen;
59
99
  }
60
100
  function BlockPane() {
61
101
  const runtime = useRuntime();
@@ -66,21 +106,25 @@ function BlockPane() {
66
106
  const shownId = useDeferredValue(selectedId);
67
107
  // The block in the editor's locale: the inspector shows and edits that locale's values.
68
108
  const block = useEditor(runtime.store, (s) => (shownId ? findBlock(s.view, shownId) : null));
69
- const [tab, setTab] = useState('content');
70
- const [shownType, setShownType] = useState(null);
109
+ // The user's tab stays chosen across blocks and visits, like Webflow's Style panel.
110
+ const [chosen, setChosen] = useState(() => (typeof window === 'undefined' ? 'styles' : readTabChoice()));
71
111
  const focusRequest = useValue(runtime.focusRequest);
72
112
  // A selected page region shows its own pane.
73
113
  const region = useOptionalValue(runtime.regions?.selected ?? null);
74
- // Styles and Motion stay open while the user edits blocks of one type. Another type opens its content,
75
- // so its fields never seem to vanish.
76
- if (block && block.type !== shownType) {
77
- setShownType(block.type);
78
- if (shownType !== null)
79
- setTab('content');
80
- }
81
- // A block that was just added opens on its content.
82
- if (block && focusRequest === block.id && tab !== 'content')
83
- setTab('content');
114
+ // A block that was just added keeps its content open while it stays selected, also after the
115
+ // focus request clears.
116
+ const [addedId, setAddedId] = useState(null);
117
+ if (block && focusRequest === block.id && addedId !== block.id)
118
+ setAddedId(block.id);
119
+ const def = block ? getBlockDefinition(runtime.config.blocks, block.type) : undefined;
120
+ // Content mode edits content only: no Styles, Motion or Advanced tab.
121
+ const contentMode = useContentMode(runtime);
122
+ const tab = storesBuilderData(runtime) && !contentMode ? tabFor(chosen, def, block !== null && block.id === addedId) : 'content';
123
+ const setTab = (next) => {
124
+ setAddedId(null);
125
+ setChosen(next);
126
+ saveTabChoice(next);
127
+ };
84
128
  // A block that was just added: focus its first content field.
85
129
  useEffect(() => {
86
130
  if (!block || focusRequest !== block.id)
@@ -96,7 +140,7 @@ function BlockPane() {
96
140
  }, [block, focusRequest, runtime]);
97
141
  if (!block)
98
142
  return region && runtime.regions ? _jsx(RegionPane, { regions: runtime.regions, name: region }, region) : _jsx(EmptyState, {});
99
- return (_jsxs("div", { className: "builder-editor__block-pane", children: [_jsx(BlockHeader, { block: block }), _jsx(BlockProblems, { blockId: block.id }), _jsx(EditingBanner, { blockId: block.id }), _jsx(LocaleNote, { blockId: block.id, tab: tab }), _jsx(Tabs, { value: tab, onChange: setTab, options: storesBuilderData(runtime)
143
+ return (_jsxs("div", { className: "builder-editor__block-pane", children: [_jsx(BlockHeader, { block: block }), _jsx(BlockProblems, { blockId: block.id }), _jsx(EditingBanner, { blockId: block.id }), _jsx(LocaleNote, { blockId: block.id, tab: tab }), !contentMode && (_jsx(Tabs, { value: tab, onChange: setTab, options: storesBuilderData(runtime)
100
144
  ? [
101
145
  { id: 'content', label: 'Content' },
102
146
  { id: 'styles', label: 'Styles' },
@@ -104,7 +148,7 @@ function BlockPane() {
104
148
  { id: 'advanced', label: 'Advanced' },
105
149
  ]
106
150
  : // A Payload blocks field holds the blocks' own fields only.
107
- [{ id: 'content', label: 'Content' }] }), tab === 'content' && _jsx(BlockContentFields, { block: block }), tab === 'styles' && storesBuilderData(runtime) && _jsx(StyleFields, { block: block }), tab === 'motion' && storesBuilderData(runtime) && _jsx(MotionPanel, { blockId: block.id, blockType: block.type, motion: block.motion }), tab === 'advanced' && storesBuilderData(runtime) && _jsx(AdvancedFields, { block: block })] }, block.id));
151
+ [{ id: 'content', label: 'Content' }] })), tab === 'content' && _jsx(BlockContentFields, { block: block }), tab === 'content' && block.type === SECTION_REF_BLOCK && _jsx(ComponentValuesPanel, { block: block }), tab === 'styles' && storesBuilderData(runtime) && _jsx(StyleFields, { block: block }), tab === 'motion' && storesBuilderData(runtime) && _jsx(MotionPanel, { blockId: block.id, blockType: block.type, motion: block.motion }), tab === 'advanced' && storesBuilderData(runtime) && _jsx(AdvancedFields, { block: block })] }, block.id));
108
152
  }
109
153
  /** What stopped the last publish, for this block. */
110
154
  function BlockProblems({ blockId }) {
@@ -119,7 +163,9 @@ function BlockHeader({ block }) {
119
163
  const [renamingHere, setRenaming] = useState(false);
120
164
  // "Rename" in a block menu (or F2 outside the outline) renames here.
121
165
  const requested = useValueSelector(renameRequest(runtime), (r) => r?.where === 'inspector' && r.id === block.id);
122
- const renaming = renamingHere || requested;
166
+ // Content mode does not rename blocks.
167
+ const contentMode = useContentMode(runtime);
168
+ const renaming = !contentMode && (renamingHere || requested);
123
169
  const endRename = () => {
124
170
  setRenaming(false);
125
171
  if (requested)
@@ -132,21 +178,21 @@ function BlockHeader({ block }) {
132
178
  // repeat the "Content" tab right below.
133
179
  const sub = block.label ? kind : null;
134
180
  const tag = typeof block.props?.as === 'string' && block.props.as !== 'div' ? `<${block.props.as}>` : null;
135
- return (_jsxs("div", { className: "builder-editor__block-head", children: [_jsx("span", { className: "builder-editor__block-icon", children: _jsx(BlockIcon, { name: runtime.blockIcon(block.type), size: 16 }) }), _jsxs("span", { className: "builder-editor__block-name", children: [renaming ? (_jsx(RenameInput, { block: block, placeholder: kind, onDone: endRename })) : (_jsx("button", { type: "button", className: "builder-editor__block-title", "aria-label": `${name}. Rename the block`, "data-tooltip": "Rename", onClick: () => setRenaming(true), children: name })), (sub || tag) && (_jsxs("span", { className: "builder-editor__block-sub", children: [sub, sub && tag ? ' · ' : '', tag && _jsx("code", { children: tag })] }))] }), block.hidden && (_jsxs("span", { className: "builder-editor__pill", "data-tooltip": "Hidden on the site", children: [_jsx(Icon, { name: "eyeOff", size: 12 }), " Hidden"] })), _jsx(MenuButton, { className: "builder-editor__icon-button", triggerLabel: "More actions", tooltip: "More actions", label: "Block actions", items: () => blockMenuEntries(runtime, block.id, 'inspector'), footer: _jsxs(_Fragment, { children: ["Block ID ", _jsx("code", { children: block.id })] }), children: _jsx(Icon, { name: "more" }) })] }));
181
+ return (_jsxs("div", { className: "builder-editor__block-head", children: [_jsx("span", { className: "builder-editor__block-icon", children: _jsx(BlockIcon, { name: runtime.blockIcon(block.type), size: 16 }) }), _jsxs("span", { className: "builder-editor__block-name", children: [renaming ? (_jsx(RenameInput, { block: block, placeholder: kind, onDone: endRename })) : contentMode ? (_jsx("span", { className: "builder-editor__block-title", children: name })) : (_jsx("button", { type: "button", className: "builder-editor__block-title", "aria-label": `${name}. Rename the block`, "data-tooltip": "Rename", onClick: () => setRenaming(true), children: name })), (sub || tag) && (_jsxs("span", { className: "builder-editor__block-sub", children: [sub, sub && tag ? ' · ' : '', tag && _jsx("code", { children: tag })] }))] }), block.hidden && (_jsxs("span", { className: "builder-editor__pill", "data-tooltip": "Hidden on the site", children: [_jsx(Icon, { name: "eyeOff", size: 12 }), " Hidden"] })), _jsx(MenuButton, { className: "builder-editor__icon-button", triggerLabel: "More actions", tooltip: "More actions", label: "Block actions", items: () => blockMenuEntries(runtime, block.id, 'inspector'), footer: _jsxs(_Fragment, { children: ["Block ID ", _jsx("code", { children: block.id })] }), children: _jsx(Icon, { name: "more" }) })] }));
136
182
  }
137
183
  function StyleFields({ block }) {
138
184
  const runtime = useRuntime();
139
185
  const def = getBlockDefinition(runtime.config.blocks, block.type);
140
- // Slots with an element of their own (`styles: true`) are style targets next to the block.
141
- const styledSlots = Object.entries(def?.slots ?? {}).filter(([, slot]) => slot.styles);
186
+ // The block's parts (styled slots and `parts` entries) are style targets next to the block.
187
+ const parts = blockParts(def);
142
188
  const [target, setTarget] = useState(null);
143
- const slot = target && styledSlots.some(([name]) => name === target) ? target : null;
189
+ const part = target && parts.some(({ name }) => name === target) ? target : null;
144
190
  const blockStyles = def?.styles !== false;
145
- return (_jsxs("div", { className: "builder-editor__fields", children: [styledSlots.length > 0 && (_jsx(Select, { "aria-label": "Style target", emptyLabel: blockStyles ? 'This block' : undefined, placeholder: "Pick a slot", value: slot, onValueChange: setTarget, options: styledSlots.map(([name, s]) => ({
191
+ return (_jsxs("div", { className: "builder-editor__fields", children: [parts.length > 0 && (_jsx(Select, { "aria-label": "Style target", emptyLabel: blockStyles ? 'This block' : undefined, placeholder: "Pick a part", value: part, onValueChange: setTarget, options: parts.map(({ name, label }) => ({
146
192
  value: name,
147
- label: `Slot: ${s.label?.trim() || name}`,
148
- ...(block.slotClassName?.[name] ? { suffix: _jsx("span", { className: "builder-styles__dot", "aria-label": "has classes" }) } : {}),
149
- })) })), slot ? (_jsx(StylesPanel, { block: block, slot: slot }, slot)) : !blockStyles ? (_jsx("p", { className: "builder-editor__hint", children: "This block has no style controls." })) : (_jsx(StylesPanel, { block: block })), _jsx(CheckboxInput, { id: `builder-${block.id}-hidden`, name: `builder.${block.id}.hidden`, label: "Hide on the site", checked: block.hidden === true, onToggle: (e) => runtime.store.apply({ type: 'update', id: block.id, hidden: e.target.checked }) })] }));
193
+ label,
194
+ ...(block.partClassName?.[name] ? { suffix: _jsx("span", { className: "builder-styles__dot", "aria-label": "has classes" }) } : {}),
195
+ })) })), part ? (_jsx(StylesPanel, { block: block, part: part }, part)) : !blockStyles ? (_jsx("p", { className: "builder-editor__hint", children: "This block has no style controls." })) : (_jsx(StylesPanel, { block: block }))] }));
150
196
  }
151
197
  /**
152
198
  * The block's HTML attributes (`block.attrs`): an id for "#id" links, an ARIA label and
@@ -154,6 +200,7 @@ function StyleFields({ block }) {
154
200
  */
155
201
  function AdvancedFields({ block }) {
156
202
  const runtime = useRuntime();
203
+ const def = getBlockDefinition(runtime.config.blocks, block.type);
157
204
  const layout = useEditor(runtime.store, (s) => s.layout);
158
205
  const stored = block.attrs?.id ?? '';
159
206
  // `source` is the stored id the draft belongs to: another stored id (undo, AI edit) replaces the draft.
@@ -179,5 +226,5 @@ function AdvancedFields({ block }) {
179
226
  }
180
227
  setDraft({ text, source: id });
181
228
  setAttr({ id: id || null });
182
- }, path: `builder.${block.id}.attrs.id`, showError: problem !== null, value: draft.text }), problem && _jsx(InputError, { children: problem })] }), _jsx(TextInput, { description: "The name screen readers read, for example for a link that shows only an icon.", label: "ARIA label", onChange: (e) => setAttr({ ariaLabel: e.target.value || null }), path: `builder.${block.id}.attrs.ariaLabel`, value: block.attrs?.ariaLabel ?? '' }), _jsx(CheckboxInput, { id: `builder-${block.id}-aria-hidden`, name: `builder.${block.id}.attrs.ariaHidden`, label: "Hide from screen readers", checked: block.attrs?.ariaHidden === true, onToggle: (e) => setAttr({ ariaHidden: e.target.checked || null }) })] }));
229
+ }, path: `builder.${block.id}.attrs.id`, showError: problem !== null, value: draft.text }), problem && _jsx(InputError, { children: problem })] }), _jsx(TextInput, { description: "The name screen readers read, for example for a link that shows only an icon.", label: "ARIA label", onChange: (e) => setAttr({ ariaLabel: e.target.value || null }), path: `builder.${block.id}.attrs.ariaLabel`, value: block.attrs?.ariaLabel ?? '' }), _jsxs("div", { children: [_jsx(CheckboxInput, { id: `builder-${block.id}-hidden`, name: `builder.${block.id}.hidden`, label: "Hide at all screen sizes", checked: block.hidden === true, onToggle: (e) => runtime.store.apply({ type: 'update', id: block.id, hidden: e.target.checked }) }), _jsx("p", { className: "field-description", children: "The site does not show this block. To hide it on some screens only, open Styles, pick a screen size, and set Display to Hidden. That hides it at this size and wider." })] }), def?.slots && Object.keys(def.slots).length > 0 && (_jsxs("div", { children: [_jsx(CheckboxInput, { id: `builder-${block.id}-editable-items`, name: `builder.${block.id}.editableItems`, label: "Editors can add, remove and reorder its items", checked: block.editableItems === true, onToggle: (e) => runtime.store.apply({ type: 'update', id: block.id, editableItems: e.target.checked }) }), _jsx("p", { className: "field-description", children: "For lists like FAQs or team cards. Editors can copy, delete and reorder the items, but not restyle them." })] })), _jsx(CheckboxInput, { id: `builder-${block.id}-aria-hidden`, name: `builder.${block.id}.attrs.ariaHidden`, label: "Hide from screen readers", checked: block.attrs?.ariaHidden === true, onToggle: (e) => setAttr({ ariaHidden: e.target.checked || null }) })] }));
183
230
  }
@@ -4,13 +4,16 @@ import { useDraggable } from '@dnd-kit/core';
4
4
  import { useConfig, useRouteTransition } from '@payloadcms/ui';
5
5
  import { useRouter } from 'next/navigation';
6
6
  import { memo, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react';
7
+ import { isComponent } from '../../core/components.js';
8
+ import { sectionVersion, sectionVersions } from '../../core/sections.js';
7
9
  import { builderViewPath } from '../../plugin/links.js';
8
- import { insertBlocks, insertNewBlock, sectionPosition } from './actions.js';
10
+ import { componentCopy, insertBlocks, insertNewBlock, plainSectionBlocks, sectionPosition } from './actions.js';
9
11
  import { BlockIcon, Icon } from './icons.js';
10
12
  import { MenuButton } from './menu/Menu.js';
11
13
  import { useRuntime } from './runtime.js';
12
14
  import { requestDeleteSection, requestRenameSection } from './sections/SectionDialog.js';
13
15
  import { useSectionThumbnail } from './sections/useThumbnail.js';
16
+ import { VariantArrows } from './sections/variants.js';
14
17
  import { useValue } from './valueStore.js';
15
18
  const BLOCK_CATEGORIES = ['Layout', 'Content', 'Media', 'Interactive', 'Dynamic'];
16
19
  const SECTION_CATEGORIES = ['Heroes', 'Features', 'Content', 'Social proof', 'Calls to action', 'Contact', 'Navigation'];
@@ -62,7 +65,7 @@ const BlockList = memo(function BlockList({ query }) {
62
65
  const groups = useMemo(() => groupBy(
63
66
  // Blocks with `parents` (e.g. a list item) only fit inside their parent: the "+" picker
64
67
  // offers them there, so the library leaves them out.
65
- config.blocks.filter((def) => !def.parents && matches(query, def.label, def.type, def.category, def.ai?.description)), BLOCK_CATEGORIES), [config.blocks, query]);
68
+ config.blocks.filter((def) => !def.parents && matches(query, def.label, def.type, def.category, def.description, def.ai?.description)), BLOCK_CATEGORIES), [config.blocks, query]);
66
69
  if (groups.length === 0)
67
70
  return _jsx(NoMatches, { query: query });
68
71
  return groups.map(([category, defs]) => (_jsx(Group, { title: category, children: _jsx("div", { className: "builder-editor__tiles", children: defs.map((def) => (_jsx(BlockTile, { def: def }, def.type))) }) }, category)));
@@ -73,7 +76,7 @@ function BlockTile({ def }) {
73
76
  const data = { source: { kind: 'new', blockType: def.type }, label: def.label, icon };
74
77
  const { setNodeRef, listeners, attributes } = useDraggable({ id: `library:${def.type}`, data });
75
78
  const insert = () => insertNewBlock(runtime, def.type);
76
- return (_jsxs("button", { ref: setNodeRef, type: "button", className: "builder-editor__tile", "data-tooltip": def.ai?.description ?? `Add ${def.label}`, onClick: insert, ...listeners, ...attributes, children: [_jsx("span", { className: "builder-editor__tile-icon", children: _jsx(BlockIcon, { name: icon, size: 18 }) }), _jsx("span", { className: "builder-editor__tile-label", children: def.label })] }));
79
+ return (_jsxs("button", { ref: setNodeRef, type: "button", className: "builder-editor__tile", "data-tooltip": def.description ?? def.label, onClick: insert, ...listeners, ...attributes, children: [_jsx("span", { className: "builder-editor__tile-icon", children: _jsx(BlockIcon, { name: icon, size: 18 }) }), _jsx("span", { className: "builder-editor__tile-label", children: def.label })] }));
77
80
  }
78
81
  const SectionList = memo(function SectionList({ query }) {
79
82
  const { config, sections: controller } = useRuntime();
@@ -89,7 +92,7 @@ const SectionList = memo(function SectionList({ query }) {
89
92
  }, [controller]);
90
93
  const groups = useMemo(() => {
91
94
  const own = (saved ?? []).filter((s) => matches(query, s.label, s.category, SAVED));
92
- const rest = groupBy(builtIn.filter((s) => matches(query, s.label, s.description, s.category)), SECTION_CATEGORIES);
95
+ const rest = groupBy(builtIn.filter((s) => matches(query, s.label, s.description, s.category, ...(s.variants ?? []).map((v) => v.label))), SECTION_CATEGORIES);
93
96
  return own.length > 0 ? [[SAVED, own], ...rest] : rest;
94
97
  }, [builtIn, saved, query]);
95
98
  if (builtIn.length === 0 && (saved?.length ?? 0) === 0) {
@@ -105,44 +108,66 @@ export function SectionThumb({ section }) {
105
108
  const picture = useSectionThumbnail(section, thumbRef);
106
109
  return (_jsx("span", { ref: thumbRef, className: `builder-editor__thumb${picture ? ' builder-editor__thumb--picture' : ''}`, "aria-hidden": "true", children: picture ? (_jsx("img", { className: "builder-editor__thumb-img", src: picture, alt: "", draggable: false })) : (_jsx("span", { className: "builder-editor__thumb-inner", children: section.blocks.map((block) => (_jsx(Wire, { block: block }, block.id))) })) }));
107
110
  }
111
+ /**
112
+ * One card per section. A section with variants gets ‹ 2 / 3 › arrows that flip the card between
113
+ * its versions; a click or a drag inserts the version shown.
114
+ */
108
115
  function SectionCard({ section }) {
109
116
  const runtime = useRuntime();
110
- const root = section.blocks[0];
117
+ const versions = useMemo(() => sectionVersions(section), [section]);
118
+ const [index, setIndex] = useState(0);
119
+ const at = Math.min(index, versions.length - 1);
120
+ // The version shown, ready to insert: its root block remembers the section and the variant.
121
+ const shown = useMemo(() => sectionVersion(section, versions[at]?.variant) ?? section, [section, versions, at]);
111
122
  const isSaved = section.savedId !== undefined;
123
+ // A saved section with properties is a component: it goes in as a copy that stays in sync.
124
+ const copy = useMemo(() => (isComponent(section.blocks) ? componentCopy(section) : null), [section]);
125
+ const blocks = useMemo(() => (copy ? [copy] : isSaved ? plainSectionBlocks(runtime, shown.blocks) : shown.blocks), [copy, isSaved, runtime, shown.blocks]);
126
+ const root = blocks[0];
112
127
  const data = {
113
128
  // Drop rules check the root block's type.
114
129
  source: { kind: 'new', blockType: root?.type ?? 'stack' },
115
- label: section.label,
116
- icon: 'section',
117
- blocks: section.blocks,
130
+ label: shown.label,
131
+ icon: copy ? 'component' : 'section',
132
+ blocks,
118
133
  };
119
134
  const { setNodeRef, listeners, attributes } = useDraggable({ id: `section:${section.id}`, data, disabled: !root });
120
135
  const insert = () => {
121
- if (insertBlocks(runtime, section.blocks, sectionPosition(runtime)))
122
- runtime.notify(`Added ${section.label}`);
136
+ if (insertBlocks(runtime, blocks, sectionPosition(runtime)))
137
+ runtime.notify(`Added ${shown.label}`);
123
138
  };
124
- return (_jsxs("div", { className: "builder-editor__card-wrap", children: [_jsxs("button", { ref: setNodeRef, type: "button", className: "builder-editor__card", "data-tooltip": `Add ${section.label}`, onClick: insert, ...listeners, ...attributes, children: [_jsx(SectionThumb, { section: section }), _jsxs("span", { className: "builder-editor__card-text", children: [_jsx("span", { className: "builder-editor__card-label", children: section.label }), isSaved && section.category && _jsx("span", { className: "builder-editor__card-desc", children: section.category }), !isSaved && section.description && _jsx("span", { className: "builder-editor__card-desc", children: section.description })] })] }), isSaved && _jsx(SavedSectionMenu, { section: section })] }));
139
+ // Versions flip in place: the card keeps one height (one label line, two description lines).
140
+ const flips = versions.length > 1;
141
+ const description = isSaved ? section.category : shown.description;
142
+ return (_jsxs("div", { className: "builder-editor__card-wrap", "data-versions": flips || undefined, children: [_jsxs("button", { ref: setNodeRef, type: "button", className: "builder-editor__card", "data-tooltip": `Add ${shown.label}`, onClick: insert, ...listeners, ...attributes, children: [_jsx(SectionThumb, { section: shown }), _jsxs("span", { className: "builder-editor__card-text", children: [_jsxs("span", { className: "builder-editor__card-label", children: [copy && _jsx(Icon, { name: "component", size: 12, className: "builder-editor__card-component" }), shown.label] }), (description || copy || (flips && versions.some((v) => v.description))) && (_jsx("span", { className: "builder-editor__card-desc", children: description ?? (copy ? 'Component' : undefined) }))] })] }), flips && (_jsx(VariantArrows, { count: versions.length, index: at, text: `${at + 1} / ${versions.length}`, label: `${section.label} versions`, className: "builder-variants--card", onChange: setIndex })), isSaved && _jsx(SavedSectionMenu, { section: section, component: copy !== null })] }));
125
143
  }
126
144
  /** The builder URL that edits a saved section, with `from` (this page) for its Back button. */
127
145
  export function editSectionPath(adminRoute, collection, id, from) {
128
146
  return `${builderViewPath(adminRoute, collection, id)}?from=${encodeURIComponent(from)}`;
129
147
  }
130
148
  /** Edit, rename and delete for a saved section. */
131
- function SavedSectionMenu({ section }) {
149
+ function SavedSectionMenu({ section, component }) {
132
150
  const runtime = useRuntime();
133
151
  const router = useRouter();
134
152
  const { startRouteTransition } = useRouteTransition();
135
153
  const { config: { routes }, } = useConfig();
136
154
  const collection = runtime.config.savedSections?.collection;
137
- // Opens the section in the full-screen builder, like a page. Pages that use it keep their copy.
155
+ const addSaved = (blocks) => {
156
+ if (insertBlocks(runtime, blocks, sectionPosition(runtime)))
157
+ runtime.notify(`Added ${section.label}`);
158
+ };
159
+ // Opens the section in the full-screen builder, like a page.
138
160
  const edit = () => {
139
161
  if (!collection || section.savedId === undefined)
140
162
  return;
141
163
  const href = editSectionPath(routes.admin, collection, section.savedId, `${window.location.pathname}${window.location.search}`);
142
164
  startRouteTransition(() => router.push(href));
143
165
  };
144
- return (_jsx(MenuButton, { className: "builder-editor__icon-button builder-editor__icon-button--small builder-editor__card-more", triggerLabel: `Actions for ${section.label}`, tooltip: "Edit, rename or delete", label: "Saved section actions", footer: "Pages that use this section keep their own copy.", items: () => [
145
- ...(collection ? [{ icon: 'compose', label: 'Edit section', run: edit }] : []),
166
+ return (_jsx(MenuButton, { className: "builder-editor__icon-button builder-editor__icon-button--small builder-editor__card-more", triggerLabel: `Actions for ${section.label}`, tooltip: "Edit, rename or delete", label: "Saved section actions", footer: component ? 'Changes show on every copy.' : 'Pages that use this section keep their own copy.', items: () => [
167
+ ...(collection ? [{ icon: 'compose', label: component ? 'Edit component' : 'Edit section', run: edit }] : []),
168
+ component
169
+ ? { icon: 'section', label: 'Add as plain blocks', run: () => addSaved(plainSectionBlocks(runtime, section.blocks)) }
170
+ : { icon: 'sectionRef', label: 'Add a copy that stays in sync', run: () => addSaved([componentCopy(section)]) },
146
171
  { icon: 'rename', label: 'Rename…', ownFocus: true, run: () => requestRenameSection(runtime, section) },
147
172
  { icon: 'delete', label: 'Delete…', ownFocus: true, danger: true, run: () => requestDeleteSection(runtime, section) },
148
173
  ], children: _jsx(Icon, { name: "more", size: 14 }) }));
@@ -11,11 +11,14 @@ import { missingWords, useUntranslated } from './locale/locale.js';
11
11
  import { BLOCK_KEYS, keyText } from './menu/keys.js';
12
12
  import { openBlockMenu, renameRequest } from './menu/requests.js';
13
13
  import { blockPreview, blockSummary, childrenOf, customLabel, typeName } from './names.js';
14
+ import { useContentMode } from './contentMode.js';
14
15
  import { OUTLINE_INDENT, useRuntime } from './runtime.js';
15
16
  import { RegionRows } from './regions/RegionRows.js';
16
17
  import { useEditor } from './store.js';
17
- import { bindingPaths, scopeSources } from '../../core/bindings.js';
18
+ import { bindingPaths, scopeSources, visibilityFieldPaths } from '../../core/bindings.js';
18
19
  import { findBindingField } from './templates/binding.js';
20
+ import { visibilityRows } from './templates/visibilityRows.js';
21
+ import { conditionSummary } from './fields/conditions.js';
19
22
  import { useValue, useValueSelector } from './valueStore.js';
20
23
  /** Visible rows, depth first. Children of collapsed containers are left out. */
21
24
  function visibleRows(runtime, layout, collapsed) {
@@ -84,18 +87,18 @@ function brokenBindingIds(runtime, layout, templateTarget) {
84
87
  }
85
88
  const NO_ISSUES = [];
86
89
  /**
87
- * True when a binding of the block reads a field its document does not have (or there is no
88
- * document): the template's, each list item's, or each field list row's.
90
+ * True when a binding or a visibility condition of the block reads a field its document does not
91
+ * have (or there is no document): the template's, each list item's, or each repeat row's.
89
92
  */
90
93
  function hasBrokenBinding(runtime, layout, block, templateTarget) {
91
- const bindings = Object.entries(block.bindings ?? {});
92
- if (bindings.length === 0)
94
+ // Every plain path the bindings read (templates and fallback chains have several), and the conditions' fields.
95
+ const paths = [...Object.values(block.bindings ?? {}).flatMap(bindingPaths), ...visibilityFieldPaths(block.visibility)];
96
+ if (paths.length === 0)
93
97
  return false;
94
98
  const fields = scopeSources(layout, block.id, runtime.config.templates?.sources ?? {}, templateTarget);
95
99
  if (!fields)
96
- return true;
97
- // Every plain path a binding reads (templates and fallback chains have several).
98
- return bindings.some(([key, binding]) => bindingPaths(key, binding).some((path) => !findBindingField(fields, path)));
100
+ return Object.keys(block.bindings ?? {}).length > 0;
101
+ return paths.some((path) => !findBindingField(fields, path));
99
102
  }
100
103
  /**
101
104
  * The outline tree. Rows stay a flat list, which keeps them simple to measure for drop targets.
@@ -211,7 +214,7 @@ export function Outline() {
211
214
  selectRow(runtime, rows[index + 1]);
212
215
  return;
213
216
  case 'F2':
214
- if (!row)
217
+ if (!row || runtime.contentMode.get())
215
218
  return;
216
219
  e.preventDefault();
217
220
  runtime.store.select(row.block.id);
@@ -257,7 +260,9 @@ const OutlineRow = memo(function OutlineRow({ block, depth, container, open, chi
257
260
  const typeLabel = runtime.blockLabel(block.type);
258
261
  const icon = runtime.blockIcon(block.type);
259
262
  const data = { source: { kind: 'block', id: block.id }, label: typeLabel, icon };
260
- const { setNodeRef, listeners, attributes } = useDraggable({ id: `outline:${block.id}`, data, disabled: renaming });
263
+ // Content mode moves no blocks by dragging (items move with Move up and Move down).
264
+ const contentMode = useContentMode(runtime);
265
+ const { setNodeRef, listeners, attributes } = useDraggable({ id: `outline:${block.id}`, data, disabled: renaming || contentMode });
261
266
  const label = customLabel(block);
262
267
  const name = label ?? typeName(block, typeLabel);
263
268
  const bindingCount = Object.keys(block.bindings ?? {}).length;
@@ -275,7 +280,7 @@ const OutlineRow = memo(function OutlineRow({ block, depth, container, open, chi
275
280
  // Two hover actions, so the row keeps room for its name. Rename, duplicate and delete are in
276
281
  // the menu and on their keys.
277
282
  const actions = [
278
- ...(storesBuilderData(runtime)
283
+ ...(storesBuilderData(runtime) && !contentMode
279
284
  ? [
280
285
  {
281
286
  icon: (block.hidden ? 'eye' : 'eyeOff'),
@@ -295,10 +300,10 @@ const OutlineRow = memo(function OutlineRow({ block, depth, container, open, chi
295
300
  },
296
301
  },
297
302
  ];
298
- return (_jsxs("div", { ref: setNodeRef, "data-outline-row": block.id, "data-depth": depth, className: className, onClick: () => runtime.store.select(block.id), onDoubleClick: () => onRename(block.id), onContextMenu: (e) => openRowMenu(runtime, block.id, e),
303
+ return (_jsxs("div", { ref: setNodeRef, "data-outline-row": block.id, "data-depth": depth, className: className, onClick: () => runtime.store.select(block.id), onDoubleClick: () => !contentMode && onRename(block.id), onContextMenu: (e) => openRowMenu(runtime, block.id, e),
299
304
  // Not while dragging: the row actions would mount and unmount under the pointer, and every
300
305
  // DOM insert restyles the whole admin (Payload's `body:has(...)` rules).
301
- onPointerEnter: () => !runtime.drag.get() && runtime.store.hover(block.id), onPointerLeave: () => !runtime.drag.get() && runtime.store.hover(null), ...listeners, ...attributes, role: "treeitem", "aria-label": [
306
+ onPointerEnter: () => !runtime.drag.get() && runtime.store.hover(block.id), onPointerLeave: () => !runtime.drag.get() && runtime.store.hover(null), ...listeners, ...attributes, "aria-disabled": undefined, role: "treeitem", "aria-label": [
302
307
  blockSummary(block, typeLabel),
303
308
  block.hidden && 'hidden on the site',
304
309
  block.motion && 'animated',
@@ -306,11 +311,11 @@ const OutlineRow = memo(function OutlineRow({ block, depth, container, open, chi
306
311
  ...issues,
307
312
  ]
308
313
  .filter(Boolean)
309
- .join(', '), "aria-level": depth + 1, "aria-selected": selected, "aria-expanded": container && childCount > 0 ? open : undefined, "aria-roledescription": "block", tabIndex: selected || focusable ? 0 : -1, "data-tooltip": `${typeLabel}${tag}${label ? '' : ' · double-click to rename'}`, "data-tooltip-side": "right", children: [Array.from({ length: depth }, (_, i) => (_jsx("span", { className: "builder-editor__guide", style: { left: 15 + i * OUTLINE_INDENT } }, i))), _jsx("span", { className: "builder-editor__row-indent", style: { width: depth * OUTLINE_INDENT } }), container && childCount > 0 ? (_jsx("button", { type: "button", className: "builder-editor__caret", "aria-label": open ? 'Collapse' : 'Expand', tabIndex: -1, onPointerDown: stop, onClick: (e) => {
314
+ .join(', '), "aria-level": depth + 1, "aria-selected": selected, "aria-expanded": container && childCount > 0 ? open : undefined, "aria-roledescription": "block", tabIndex: selected || focusable ? 0 : -1, "data-tooltip": `${typeLabel}${tag}${label || contentMode ? '' : ' · double-click to rename'}`, "data-tooltip-side": "right", children: [Array.from({ length: depth }, (_, i) => (_jsx("span", { className: "builder-editor__guide", style: { left: 15 + i * OUTLINE_INDENT } }, i))), _jsx("span", { className: "builder-editor__row-indent", style: { width: depth * OUTLINE_INDENT } }), container && childCount > 0 ? (_jsx("button", { type: "button", className: "builder-editor__caret", "aria-label": open ? 'Collapse' : 'Expand', tabIndex: -1, onPointerDown: stop, onClick: (e) => {
310
315
  e.stopPropagation();
311
316
  setCollapsed(runtime, block.id, open);
312
- }, children: _jsx(Icon, { name: open ? 'chevronDown' : 'chevronRight', size: 12 }) })) : (_jsx("span", { className: "builder-editor__caret builder-editor__caret--empty" })), _jsx("span", { className: "builder-editor__row-icon", children: _jsx(BlockIcon, { name: icon, size: 14 }) }), renaming ? (_jsx(RenameInput, { block: block, placeholder: blockPreview(block) || name, onDone: () => onRename(null) })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "builder-editor__row-type", children: name }), text && _jsx("span", { className: "builder-editor__row-text", children: text })] })), _jsx(PeerDots, { blockId: block.id }), untranslated > 0 && (_jsx("span", { className: "builder-editor__row-untranslated", "aria-hidden": "true", "data-tooltip": `${untranslated} ${untranslated === 1 ? 'field is' : 'fields are'} ${missing}`, "data-tooltip-side": "right" })), issues.length > 0 && (_jsx("span", { className: "builder-editor__row-problem", "data-tooltip": issues.join('\n'), "data-tooltip-side": "right", children: _jsx(Icon, { name: "warning", size: 13 }) })), block.motion && (_jsx("span", { className: "builder-editor__row-motion", "data-tooltip": `Animation: ${describeMotion(block.motion)}`, "data-tooltip-side": "right", children: _jsx(Icon, { name: "motion", size: 12 }) })), bindingCount > 0 && (_jsx("span", { className: `builder-editor__row-bound${broken ? ' builder-editor__row-bound--broken' : ''}`, "aria-label": broken ? 'A bound field is missing' : `${bindingCount} bound ${bindingCount === 1 ? 'field' : 'fields'}`, "data-tooltip-side": "right", "data-tooltip": broken
313
- ? 'A bound field is missing from the collection. Select the block to fix it.'
317
+ }, children: _jsx(Icon, { name: open ? 'chevronDown' : 'chevronRight', size: 12 }) })) : (_jsx("span", { className: "builder-editor__caret builder-editor__caret--empty" })), _jsx("span", { className: "builder-editor__row-icon", children: _jsx(BlockIcon, { name: icon, size: 14 }) }), renaming ? (_jsx(RenameInput, { block: block, placeholder: blockPreview(block) || name, onDone: () => onRename(null) })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "builder-editor__row-type", children: name }), text && _jsx("span", { className: "builder-editor__row-text", children: text })] })), _jsx(PeerDots, { blockId: block.id }), untranslated > 0 && (_jsx("span", { className: "builder-editor__row-untranslated", "aria-hidden": "true", "data-tooltip": `${untranslated} ${untranslated === 1 ? 'field is' : 'fields are'} ${missing}`, "data-tooltip-side": "right" })), issues.length > 0 && (_jsx("span", { className: "builder-editor__row-problem", "data-tooltip": issues.join('\n'), "data-tooltip-side": "right", children: _jsx(Icon, { name: "warning", size: 13 }) })), block.motion && (_jsx("span", { className: "builder-editor__row-motion", "data-tooltip": `Animation: ${describeMotion(block.motion)}`, "data-tooltip-side": "right", children: _jsx(Icon, { name: "motion", size: 12 }) })), block.visibility && (_jsx("span", { className: "builder-editor__row-motion", "aria-label": "Shows only when its conditions match", "data-tooltip": `Shows only when ${conditionSummary(visibilityRows(block.visibility), [])}`, "data-tooltip-side": "right", children: _jsx(Icon, { name: "eye", size: 12 }) })), (bindingCount > 0 || broken) && (_jsx("span", { className: `builder-editor__row-bound${broken ? ' builder-editor__row-bound--broken' : ''}`, "aria-label": broken ? 'A bound field is missing' : `${bindingCount} bound ${bindingCount === 1 ? 'field' : 'fields'}`, "data-tooltip-side": "right", "data-tooltip": broken
318
+ ? 'A field a binding or a visibility condition reads is missing from the collection. Select the block to fix it.'
314
319
  : `Shows data: ${Object.entries(block.bindings ?? {})
315
320
  .map(([prop, field]) => `${prop} ← ${field}`)
316
321
  .join(', ')}`, children: _jsx(Icon, { name: broken ? 'unlink' : 'bind', size: 12 }) })), !open && childCount > 0 && _jsx("span", { className: "builder-editor__row-count", children: childCount }), !renaming && hovered && (_jsx("span", { className: "builder-editor__row-actions", children: actions.map((action) => (_jsx("button", { type: "button", tabIndex: -1, className: "builder-editor__row-action", "aria-label": action.label, "aria-haspopup": action.icon === 'more' ? 'menu' : undefined, "data-tooltip": action.tooltip, onPointerDown: stop, onClick: (e) => {
@@ -2,6 +2,7 @@
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useDraggable } from '@dnd-kit/core';
4
4
  import { findBlock, findLocation } from '../../core/index.js';
5
+ import { DropOutlines } from './dnd/DropOutlines.js';
5
6
  import { smoothView } from './dnd/smooth.js';
6
7
  import { BlockIcon, Icon } from './icons.js';
7
8
  import { inlineEditing } from './inline.js';
@@ -13,7 +14,9 @@ import { MenuButton } from './menu/Menu.js';
13
14
  import { blockName } from './names.js';
14
15
  import { PeerCursors, PeerSelections } from './live/PresenceUI.js';
15
16
  import { RegionOverlay } from './regions/RegionOverlay.js';
17
+ import { SectionVariantSwitch } from './sections/variants.js';
16
18
  import { shortName } from './live/presence.js';
19
+ import { useContentMode } from './contentMode.js';
17
20
  import { toRect, useRuntime } from './runtime.js';
18
21
  import { useEditor } from './store.js';
19
22
  import { Tooltips } from './tooltip/Tooltips.js';
@@ -121,7 +124,7 @@ export function Overlay() {
121
124
  if (!rect)
122
125
  return null;
123
126
  return (_jsx("div", { className: "builder-editor__problem-box", style: box(rect), children: _jsxs("span", { className: "builder-editor__problem-tag", "data-tooltip": problem.message, children: [_jsx(Icon, { name: "warning", size: 12 }), problem.message] }) }, `${problem.blockId}:${i}`));
124
- }), parentRect && _jsx("div", { className: "builder-editor__parent-hint", style: box(parentRect) }), smooth?.placeholder && (_jsx("div", { className: "builder-dnd-scroll", style: { transform: `translate3d(${-gapShift.x}px, ${-gapShift.y}px, 0)` }, children: _jsx("div", { className: "builder-dnd-gap", "data-settle": smooth.phase === 'settle' || undefined, style: {
127
+ }), parentRect && _jsx("div", { className: "builder-editor__parent-hint", style: box(parentRect) }), _jsx(DropOutlines, {}), smooth?.placeholder && (_jsx("div", { className: "builder-dnd-scroll", style: { transform: `translate3d(${-gapShift.x}px, ${-gapShift.y}px, 0)` }, children: _jsx("div", { className: "builder-dnd-gap", "data-settle": smooth.phase === 'settle' || undefined, style: {
125
128
  transform: `translate3d(${smooth.placeholder.x}px, ${smooth.placeholder.y}px, 0)`,
126
129
  width: smooth.placeholder.width,
127
130
  height: smooth.placeholder.height,
@@ -144,9 +147,11 @@ export function Overlay() {
144
147
  function ActionBar({ id, label, icon, parentId, rect, inside, below, hidden }) {
145
148
  const runtime = useRuntime();
146
149
  const data = { source: { kind: 'block', id }, label, icon };
147
- const { setNodeRef, listeners, attributes } = useDraggable({ id: `canvas:${id}`, data });
150
+ // Content mode moves no blocks by dragging and switches no section variants.
151
+ const contentMode = useContentMode(runtime);
152
+ const { setNodeRef, listeners, attributes } = useDraggable({ id: `canvas:${id}`, data, disabled: contentMode });
148
153
  const place = below ? 'below' : inside ? 'inside' : 'above';
149
154
  const visibility = hidden ? 'hidden' : undefined;
150
155
  const style = place === 'below' ? { left: rect.x, top: rect.y + rect.height, visibility } : { left: rect.x + rect.width, top: rect.y, visibility };
151
- return (_jsxs("div", { className: `builder-editor__actions builder-editor__actions--${place}`, style: style, children: [_jsx("button", { ref: setNodeRef, type: "button", className: "builder-editor__action builder-editor__handle", "aria-label": "Drag to move", "data-tooltip": "Drag to move", ...listeners, ...attributes, children: _jsx(Icon, { name: "drag", size: 14 }) }), _jsx("button", { type: "button", className: "builder-editor__action", "aria-label": "Select the parent block", "data-tooltip": "Select parent", disabled: !parentId, onClick: () => parentId && runtime.store.select(parentId), children: _jsx(Icon, { name: "parent", size: 14 }) }), _jsx(MenuButton, { className: "builder-editor__action", triggerLabel: "More block actions", tooltip: "More actions", label: "Block actions", items: () => blockMenuEntries(runtime, id, 'canvas'), children: _jsx(Icon, { name: "more", size: 14 }) })] }));
156
+ return (_jsxs("div", { className: `builder-editor__actions builder-editor__actions--${place}`, style: style, children: [!contentMode && _jsx(SectionVariantSwitch, { id: id }), !contentMode && (_jsx("button", { ref: setNodeRef, type: "button", className: "builder-editor__action builder-editor__handle", "aria-label": "Drag to move", "data-tooltip": "Drag to move", ...listeners, ...attributes, children: _jsx(Icon, { name: "drag", size: 14 }) })), _jsx("button", { type: "button", className: "builder-editor__action", "aria-label": "Select the parent block", "data-tooltip": "Select parent", disabled: !parentId, onClick: () => parentId && runtime.store.select(parentId), children: _jsx(Icon, { name: "parent", size: 14 }) }), _jsx(MenuButton, { className: "builder-editor__action", triggerLabel: "More block actions", tooltip: "More actions", label: "Block actions", items: () => blockMenuEntries(runtime, id, 'canvas'), children: _jsx(Icon, { name: "more", size: 14 }) })] }));
152
157
  }
@@ -1,4 +1,4 @@
1
- import type { Block, CanvasMeasurement, Layout, Position } from '../../core/types.js';
1
+ import type { Block, CanvasMeasurement, Layout, Position, SectionDefinition } from '../../core/types.js';
2
2
  import { type CopiedStyles } from './menu/styleClipboard.js';
3
3
  import type { Runtime } from './runtime.js';
4
4
  /**
@@ -32,9 +32,17 @@ export declare function currentPosition(layout: Layout, to: Position): Position
32
32
  * out the HTML ids (`attrs.id`) the page already uses, so a paste or a second section stays valid.
33
33
  */
34
34
  export declare function insertBlocks(runtime: Runtime, blocks: Block[], to: Position): boolean;
35
+ /**
36
+ * The blocks a saved section inserts as plain blocks: a component's own content, without its
37
+ * property bindings (they mean nothing outside a copy).
38
+ */
39
+ export declare function plainSectionBlocks(runtime: Runtime, blocks: readonly Block[]): Block[];
40
+ /** A new copy of a saved section that stays in sync (a `sectionRef` block), or null for built-in sections. */
41
+ export declare function componentCopy(section: SectionDefinition): Block | null;
35
42
  /**
36
43
  * "Detach section": replaces a live saved section (`sectionRef`) with a copy of its blocks, as one
37
- * undo step. Later changes to the saved section no longer reach this page.
44
+ * undo step. A component's copy keeps its own values in the blocks. Later changes to the saved
45
+ * section no longer reach this page.
38
46
  */
39
47
  export declare function detachSection(runtime: Runtime, id: string): Promise<void>;
40
48
  export declare function duplicateBlock(runtime: Runtime, id: string): void;
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
  // Editor actions shared by the toolbar, the overlay, the outline, the inspector, the menus and the
3
3
  // shortcuts: insert, duplicate, remove, hide, move, copy and paste (blocks and styles).
4
- import { sectionDetachOps, sectionRefId } from '../../blocks/builtins/sectionRef.js';
4
+ import { SECTION_REF_BLOCK, sectionDetachOps, sectionRefId } from '../../blocks/builtins/sectionRef.js';
5
+ import { applyComponentValues, componentValuesOf } from '../../core/components.js';
5
6
  import { createId, findBlock, findLocation, getBlockDefinition, htmlIdsOf, slotAcceptsAt, slotNames, withoutTakenHtmlIds } from '../../core/index.js';
6
7
  import { normalizeClasses, parseStyles, setStylesOps, stylesText } from './menu/styleClipboard.js';
7
8
  import { countText } from './counts.js';
@@ -114,9 +115,23 @@ function freshCopies(runtime, blocks) {
114
115
  return copy;
115
116
  });
116
117
  }
118
+ /**
119
+ * The blocks a saved section inserts as plain blocks: a component's own content, without its
120
+ * property bindings (they mean nothing outside a copy).
121
+ */
122
+ export function plainSectionBlocks(runtime, blocks) {
123
+ return applyComponentValues(blocks, {}, runtime.config.blocks);
124
+ }
125
+ /** A new copy of a saved section that stays in sync (a `sectionRef` block), or null for built-in sections. */
126
+ export function componentCopy(section) {
127
+ if (section.savedId === undefined)
128
+ return null;
129
+ return { id: createId(), type: SECTION_REF_BLOCK, props: { section: section.savedId } };
130
+ }
117
131
  /**
118
132
  * "Detach section": replaces a live saved section (`sectionRef`) with a copy of its blocks, as one
119
- * undo step. Later changes to the saved section no longer reach this page.
133
+ * undo step. A component's copy keeps its own values in the blocks. Later changes to the saved
134
+ * section no longer reach this page.
120
135
  */
121
136
  export async function detachSection(runtime, id) {
122
137
  const ref = findBlock(runtime.store.getState().layout, id);
@@ -129,7 +144,7 @@ export async function detachSection(runtime, id) {
129
144
  runtime.notify('This saved section cannot be loaded. It may be deleted.');
130
145
  return;
131
146
  }
132
- const copies = freshCopies(runtime, section.blocks);
147
+ const copies = freshCopies(runtime, applyComponentValues(section.blocks, componentValuesOf(ref?.props), runtime.config.blocks));
133
148
  const ops = sectionDetachOps(runtime.store.getState().layout, id, copies);
134
149
  if (ops && runtime.store.apply(ops, { select: copies[0].id }))
135
150
  runtime.notify(`Detached "${section.label}": this page now has its own copy`);
@@ -167,7 +167,9 @@ function SetupState({ assistant, message }) {
167
167
  const noAdapter = !ai || ai.adapter === 'none';
168
168
  const keyEnv = ai?.keyEnv ?? null;
169
169
  const keyPage = ai?.keyUrl ?? null;
170
- return (_jsxs(_Fragment, { children: [_jsxs("output", { className: "builder-assistant__card builder-assistant__card--setup", children: [_jsx("p", { className: "builder-assistant__card-title", children: "The AI assistant is not set up yet" }), _jsx("p", { className: "builder-assistant__card-text", children: "The AI assistant is not set up on this site yet. Ask your developer to add an API key." }), _jsxs("details", { className: "builder-assistant__details", children: [_jsx("summary", { children: "Details for developers" }), _jsxs("div", { className: "builder-assistant__details-body", children: [_jsx("p", { className: "builder-assistant__card-text", children: message }), keyEnv && _jsxs("pre", { className: "builder-assistant__card-code", children: [keyEnv, "=\u2026"] }), !noAdapter && (_jsxs("p", { className: "builder-assistant__card-text", children: ["The adapter is ", ai.label, ". To use another one, change ", _jsx("code", { children: "ai.adapter" }), " in ", _jsx("code", { children: "payload.config.ts" }), "."] })), _jsxs("div", { className: "builder-assistant__card-actions", children: [keyPage && (_jsxs("a", { className: "builder-assistant__link", href: keyPage, target: "_blank", rel: "noopener noreferrer", children: ["Get an API key ", _jsx(Icon, { name: "external", size: 12 })] })), _jsxs("a", { className: "builder-assistant__link", href: PROVIDER_DOCS, target: "_blank", rel: "noopener noreferrer", children: ["Provider guide ", _jsx(Icon, { name: "external", size: 12 })] })] })] })] }), _jsx("div", { className: "builder-assistant__card-actions", children: _jsxs("button", { type: "button", className: "builder-assistant__ghost", onClick: assistant.clearSetup, children: [_jsx(Icon, { name: "retry", size: 12 }), " Check again"] }) })] }), _jsx("p", { className: "builder-assistant__info", children: "Or use your own Claude or ChatGPT plan." }), _jsx(ConnectAgents, {})] }));
170
+ // The user may open the AI settings, where an API key makes the assistant work.
171
+ const settingsUrl = ai?.settingsUrl ?? null;
172
+ return (_jsxs(_Fragment, { children: [_jsxs("output", { className: "builder-assistant__card builder-assistant__card--setup", children: [_jsx("p", { className: "builder-assistant__card-title", children: "The AI assistant is not set up yet" }), settingsUrl ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "builder-assistant__card-text", children: "The AI assistant needs an API key. Paste one in the AI settings, then check again." }), _jsx("div", { className: "builder-assistant__card-actions", children: _jsxs("a", { className: "builder-assistant__link", href: settingsUrl, target: "_blank", rel: "noopener noreferrer", children: ["Open AI settings ", _jsx(Icon, { name: "external", size: 12 })] }) })] })) : (_jsx("p", { className: "builder-assistant__card-text", children: "The AI assistant is not set up on this site yet. Ask your developer to add an API key." })), _jsxs("details", { className: "builder-assistant__details", children: [_jsx("summary", { children: "Details for developers" }), _jsxs("div", { className: "builder-assistant__details-body", children: [_jsx("p", { className: "builder-assistant__card-text", children: message }), keyEnv && _jsxs("pre", { className: "builder-assistant__card-code", children: [keyEnv, "=\u2026"] }), !noAdapter && (_jsxs("p", { className: "builder-assistant__card-text", children: ["The adapter is ", ai.label, ". To use another one, change ", _jsx("code", { children: "ai.adapter" }), " in ", _jsx("code", { children: "payload.config.ts" }), "."] })), _jsxs("div", { className: "builder-assistant__card-actions", children: [keyPage && (_jsxs("a", { className: "builder-assistant__link", href: keyPage, target: "_blank", rel: "noopener noreferrer", children: ["Get an API key ", _jsx(Icon, { name: "external", size: 12 })] })), _jsxs("a", { className: "builder-assistant__link", href: PROVIDER_DOCS, target: "_blank", rel: "noopener noreferrer", children: ["Provider guide ", _jsx(Icon, { name: "external", size: 12 })] })] })] })] }), _jsx("div", { className: "builder-assistant__card-actions", children: _jsxs("button", { type: "button", className: "builder-assistant__ghost", onClick: assistant.clearSetup, children: [_jsx(Icon, { name: "retry", size: 12 }), " Check again"] }) })] }), _jsx("p", { className: "builder-assistant__info", children: "Or use your own Claude or ChatGPT plan." }), _jsx(ConnectAgents, {})] }));
171
173
  }
172
174
  const TEXT_BLOCKS = new Set(['heading', 'text', 'richText', 'quote']);
173
175
  const CONTAINER_BLOCKS = new Set(['stack', 'grid', 'section']);
@@ -0,0 +1,4 @@
1
+ import './manager.scss';
2
+ export declare const CLASS_MANAGER_SLUG = "builder-class-manager";
3
+ /** Mounted with the Styles panel. Renders the drawer; `openModal(CLASS_MANAGER_SLUG)` opens it. */
4
+ export declare function ClassManager(): import("react").JSX.Element;