payload-canvas 0.4.0 → 0.5.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 (468) hide show
  1. package/README.md +625 -153
  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 -2
  234. package/dist/blocks/index.js +1 -2
  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
@@ -1,110 +1,50 @@
1
1
  import { defineBlock } from '../core/blocks.js';
2
2
  import { COLLECTION_LIST_BLOCK, FIELD_BLOCK, INDEX_PATH, ITEM_PATH, LIST_EMPTY_SLOT, LIST_ITEM_SLOT, PAGE_PATH, PARENT_PATH, REPEAT_BLOCK } from '../core/bindings.js';
3
3
  import { TEXT_LIST_BLOCK, TEXT_LIST_ITEM_BLOCK, TEXT_LIST_SLOT } from '../core/textList.js';
4
- import { BUILDER_CSS_CLASS } from '../css/marker.js';
4
+ import { classesOf, INTERACTIVE, labelField } from './builtins/shared.js';
5
5
  import { linkField, when } from './link.js';
6
- /** "arrowUpRight" -> "arrow up right". */
7
- export const iconLabel = (name) => name.replace(/([A-Z])/g, ' $1').toLowerCase();
8
- /** The button's icon props, for a site with an icon set (`defaultBlocks({ icons })`). */
9
- function buttonIconFields(names) {
10
- return [
11
- {
12
- name: 'icon',
13
- type: 'select',
14
- label: 'Icon',
15
- options: names.map((value) => ({ label: iconLabel(value), value })),
16
- admin: { description: "Optional. An icon of the site's icon set next to the label. Screen readers skip it." },
17
- },
18
- {
19
- name: 'iconPosition',
20
- type: 'select',
21
- label: 'Icon position',
22
- defaultValue: 'end',
23
- options: [
24
- { label: 'Before the label', value: 'start' },
25
- { label: 'After the label', value: 'end' },
26
- ],
27
- },
28
- {
29
- name: 'iconClassName',
30
- type: 'text',
31
- label: 'Icon classes',
32
- defaultValue: 'size-4 shrink-0',
33
- admin: { description: 'Tailwind classes of the icon, for example "size-5".', custom: { builderClasses: true } },
34
- },
35
- ];
36
- }
6
+ import { FIELD_CLASS_MAP } from './client/field.js';
7
+ import { MENU_CLASS_MAP, MENU_LABELS } from './client/menu.js';
8
+ // The class maps and labels the components use live in leaf modules (no block definitions), so
9
+ // client components can import them alone.
10
+ export { FIELD_CLASS_MAP, MENU_CLASS_MAP, MENU_LABELS };
37
11
  /** Block types a Link block may hold directly: content without its own links or controls. */
38
- const LINK_CONTENT = ['stack', 'grid', 'heading', 'text', 'image', 'list', 'quote', 'divider', 'spacer', 'field'];
12
+ const LINK_CONTENT = ['stack', 'grid', 'heading', 'text', 'image', 'list', 'divider', 'field'];
13
+ /** The HTML tags a stack can render as (the Container component accepts the same list). */
14
+ const STACK_TAGS = ['div', 'section', 'header', 'footer', 'main', 'nav', 'article', 'aside', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'figure', 'figcaption'];
15
+ const MENU_CLASSES = [...classesOf(MENU_CLASS_MAP), 'group'];
16
+ const FIELD_CLASSES = classesOf(FIELD_CLASS_MAP);
39
17
  /**
40
- * Interactive block types: never inside a Link block, at any depth. `form` is the starter's custom
41
- * form block; a type that does not exist is ignored.
18
+ * The `collection` field of the collection list and repeat blocks: a select of `slugs`, or a text
19
+ * field when there are none. The plugin's `listCollectionsOf` uses it too.
42
20
  */
43
- const INTERACTIVE = ['link', 'button', 'menu', 'richText', 'video', 'collectionList', 'form'];
44
- /** Adds the marker class to every class string of a map (see `BUILDER_CSS_CLASS`). */
45
- function withMarker(map) {
46
- const entries = Object.entries(map).map(([key, value]) => [
47
- key,
48
- typeof value === 'string' ? `${value} ${BUILDER_CSS_CLASS}` : withMarker(value),
49
- ]);
50
- return Object.fromEntries(entries);
21
+ export function listCollectionField(slugs, args) {
22
+ // A setting, not content: content mode (core/contentMode.ts) does not offer it.
23
+ const admin = { admin: { ...(args.description ? { description: args.description } : {}), custom: { builderContent: false } } };
24
+ const required = args.required ? { required: true } : {};
25
+ return slugs && slugs.length > 0
26
+ ? { name: 'collection', type: 'select', label: args.label, options: [...slugs], ...required, ...admin }
27
+ : { name: 'collection', type: 'text', label: args.label, ...required, ...admin };
28
+ }
29
+ const PICKED_HELP = 'Shows only these, in this order.';
30
+ /** The collection list's picked documents: a relationship to `slugs`, or ids as text when there are none. */
31
+ export function pickedDocumentsField(slugs) {
32
+ if (!slugs || slugs.length === 0) {
33
+ return { name: 'ids', type: 'text', label: 'Only these ids', hasMany: true, admin: { description: PICKED_HELP, custom: { builderContent: false } } };
34
+ }
35
+ return {
36
+ name: 'ids',
37
+ type: 'relationship',
38
+ label: 'Only these documents',
39
+ // The slugs come from the app, so they cannot match Payload's generated slug type.
40
+ relationTo: (slugs.length === 1 ? slugs[0] : [...slugs]),
41
+ hasMany: true,
42
+ admin: { description: PICKED_HELP },
43
+ };
51
44
  }
52
45
  /**
53
- * Classes the menu component uses itself (the toggle, the panel and the links). They are listed in
54
- * the block's `classes`, so the generated CSS has them. Each string also holds `builder-css`:
55
- * the generated CSS only styles elements with that class. Keep in sync with `Menu.tsx` in
56
- * `payload-canvas/react`.
57
- */
58
- export const MENU_CLASS_MAP = withMarker({
59
- /** The inline list: its items become children of the <nav>, so the block's className lays them out. */
60
- list: { md: 'hidden md:contents', lg: 'hidden lg:contents', never: 'contents' },
61
- toggleWrap: { md: 'md:hidden', lg: 'lg:hidden' },
62
- link: 'inline-flex items-center py-2 opacity-75 transition-opacity hover:opacity-100 ' +
63
- 'aria-[current=page]:opacity-100 aria-[current=page]:underline decoration-1 underline-offset-8',
64
- toggle: 'flex min-h-11 min-w-11 cursor-pointer list-none items-center justify-center gap-2 rounded-md px-2 -mr-2 ' +
65
- '[&::-webkit-details-marker]:hidden',
66
- iconOpen: 'size-5 group-open:hidden',
67
- iconClose: 'hidden size-5 group-open:block',
68
- panel: 'absolute inset-x-0 top-full z-50 border-y border-border bg-background px-5 pt-2 pb-6 text-foreground ' +
69
- 'shadow-md',
70
- panelList: 'flex flex-col',
71
- panelLink: 'flex min-h-12 items-center border-b border-border py-3 text-lg ' +
72
- 'aria-[current=page]:font-semibold aria-[current=page]:underline decoration-1 underline-offset-8',
73
- /** A link with children (one level): a <details> dropdown next to, or in place of, the link. */
74
- submenu: 'relative flex items-center gap-1',
75
- submenuDetails: 'group/submenu',
76
- submenuToggle: 'inline-flex cursor-pointer list-none items-center gap-1 py-2 opacity-75 transition-opacity hover:opacity-100 ' +
77
- 'aria-[current=true]:opacity-100 [&::-webkit-details-marker]:hidden',
78
- submenuIcon: 'size-4 transition-transform group-open/submenu:rotate-180 motion-reduce:transition-none',
79
- submenuList: 'absolute top-full left-0 z-50 flex min-w-48 flex-col border border-border bg-background p-2 text-foreground shadow-md',
80
- submenuLink: 'flex min-h-10 items-center px-3 py-2 opacity-75 transition-opacity hover:opacity-100 ' +
81
- 'aria-[current=page]:opacity-100 aria-[current=page]:underline decoration-1 underline-offset-8',
82
- /** The children of a link in the small-screen panel: a nested list. */
83
- panelSubList: 'flex flex-col pl-4',
84
- panelSubLink: 'flex min-h-11 items-center py-2 text-base ' +
85
- 'aria-[current=page]:font-semibold aria-[current=page]:underline decoration-1 underline-offset-8',
86
- /** The optional button after the links in the panel. */
87
- panelCta: 'mt-5 flex min-h-12 items-center justify-center rounded-full bg-primary px-6 text-base font-medium ' +
88
- 'text-primary-foreground transition-colors hover:bg-[color-mix(in_oklch,var(--color-primary),black_14%)]',
89
- });
90
- /**
91
- * Classes the field component adds to rich text that has no `prose` class of its own (see `Field.tsx`),
92
- * so a post body looks right by default. Listed in the field block's `classes`.
93
- */
94
- export const FIELD_CLASS_MAP = withMarker({ richText: 'prose max-w-none' });
95
- const MENU_CLASSES = [
96
- ...new Set(Object.values(MENU_CLASS_MAP)
97
- .flatMap((value) => (typeof value === 'string' ? [value] : Object.values(value)))
98
- .flatMap((value) => value.split(' '))
99
- .filter((cls) => cls !== BUILDER_CSS_CLASS)),
100
- 'group',
101
- ];
102
- const FIELD_CLASSES = Object.values(FIELD_CLASS_MAP)
103
- .flatMap((value) => value.split(' '))
104
- .filter((cls) => cls !== BUILDER_CSS_CLASS);
105
- /**
106
- * The built-in blocks: stack, grid, heading, text, richText, image, button, link, menu, list (with
107
- * its listItem blocks), quote, divider, spacer, video, and the dynamic blocks field, collectionList and repeat.
46
+ * The default blocks: stack, grid, heading, text, richText, image, button, link, menu, list (with
47
+ * its listItem blocks), divider, video, and the dynamic blocks field, collectionList and repeat.
108
48
  */
109
49
  export function defaultBlocks(options) {
110
50
  const mediaCollection = (options?.mediaCollection ?? 'media');
@@ -115,37 +55,18 @@ export function defaultBlocks(options) {
115
55
  const stack = defineBlock({
116
56
  type: 'stack',
117
57
  label: 'Stack',
58
+ description: 'A box that holds blocks in a column or a row.',
118
59
  icon: 'stack',
119
60
  category: 'Layout',
120
61
  fields: [
121
62
  {
122
63
  name: 'as',
123
64
  type: 'select',
124
- label: 'Kind of area',
125
- options: [
126
- { label: 'Plain group (div)', value: 'div' },
127
- { label: 'Page section (section)', value: 'section' },
128
- { label: 'Site header (header)', value: 'header' },
129
- { label: 'Site footer (footer)', value: 'footer' },
130
- { label: 'Main content (main)', value: 'main' },
131
- { label: 'Navigation (nav)', value: 'nav' },
132
- { label: 'Article or post (article)', value: 'article' },
133
- { label: 'Side note (aside)', value: 'aside' },
134
- { label: 'Numbered list (ol)', value: 'ol' },
135
- { label: 'Bullet list (ul)', value: 'ul' },
136
- { label: 'List item (li)', value: 'li' },
137
- { label: 'Term list (dl)', value: 'dl' },
138
- { label: 'Term (dt)', value: 'dt' },
139
- { label: 'Term description (dd)', value: 'dd' },
140
- { label: 'Figure (figure)', value: 'figure' },
141
- { label: 'Figure caption (figcaption)', value: 'figcaption' },
142
- { label: 'Paragraph (p)', value: 'p' },
143
- { label: 'Inline group (span)', value: 'span' },
144
- ],
65
+ label: 'Tag',
66
+ options: [...STACK_TAGS],
145
67
  defaultValue: 'div',
146
- admin: {
147
- description: 'What this area is on the page. It does not change the look. Screen readers and search engines use it. ' +
148
- 'Use "Page section" for each section of a page.',
68
+ custom: {
69
+ ai: { description: 'The HTML tag. It does not change the look; screen readers and search engines use it. Use "section" for each section of a page.' },
149
70
  },
150
71
  },
151
72
  ],
@@ -154,7 +75,7 @@ export function defaultBlocks(options) {
154
75
  ai: {
155
76
  description: 'A container that lays out its children in a column (or a row with "flex-row"). ' +
156
77
  'Use it to group blocks and build sections. Set "as" to "section", "header", "footer" and so on for semantic HTML; ' +
157
- '"ol"/"ul" with "li" children for lists, "dl" with "dt"/"dd" for term lists, "figure" with "figcaption", "p" or "span" for text runs.',
78
+ '"ol"/"ul" with "li" children for lists, "dl" with "dt"/"dd" for term lists, "figure" with "figcaption".',
158
79
  example: {
159
80
  type: 'stack',
160
81
  props: { as: 'section' },
@@ -171,6 +92,7 @@ export function defaultBlocks(options) {
171
92
  const grid = defineBlock({
172
93
  type: 'grid',
173
94
  label: 'Grid',
95
+ description: 'Places blocks in columns and rows.',
174
96
  icon: 'grid',
175
97
  category: 'Layout',
176
98
  fields: [],
@@ -195,6 +117,7 @@ export function defaultBlocks(options) {
195
117
  const heading = defineBlock({
196
118
  type: 'heading',
197
119
  label: 'Heading',
120
+ description: 'A title for a page or a section.',
198
121
  icon: 'heading',
199
122
  category: 'Content',
200
123
  fields: [
@@ -203,30 +126,15 @@ export function defaultBlocks(options) {
203
126
  {
204
127
  name: 'level',
205
128
  type: 'select',
206
- label: 'Level',
207
- options: [
208
- { label: 'Heading 1 – page title', value: '1' },
209
- { label: 'Heading 2 – section', value: '2' },
210
- { label: 'Heading 3 – part of a section', value: '3' },
211
- { label: 'Heading 4', value: '4' },
212
- { label: 'Heading 5', value: '5' },
213
- { label: 'Heading 6', value: '6' },
214
- ],
129
+ label: 'Tag',
130
+ // The value is the level only ("2"); the label is the tag.
131
+ options: ['1', '2', '3', '4', '5', '6'].map((value) => ({ label: `h${value}`, value })),
215
132
  defaultValue: '2',
216
- admin: {
217
- description: 'Where the heading sits in the page outline. It does not set the size. Use Heading 1 once per page, ' +
218
- 'Heading 2 for each section, and Heading 3 inside a section.',
219
- },
220
- },
221
- {
222
- name: 'accent',
223
- type: 'text',
224
- label: 'Accent words',
225
- localized: true,
226
- admin: {
227
- description: 'Words of the heading to highlight, for example "Brisbane". They render as <em>; style them with classes like [&_em]:text-primary.',
133
+ custom: {
134
+ ai: { description: 'The level in the page outline, not the size: "1" once per page, "2" for sections, "3" inside a section.' },
228
135
  },
229
136
  },
137
+ { name: 'accent', type: 'text', label: 'Highlighted words', localized: true },
230
138
  ],
231
139
  // `break-words`: a long word (a URL, a product code) wraps instead of widening the page.
232
140
  defaultClassName: 'text-3xl font-bold break-words',
@@ -239,6 +147,7 @@ export function defaultBlocks(options) {
239
147
  const text = defineBlock({
240
148
  type: 'text',
241
149
  label: 'Text',
150
+ description: 'A paragraph of plain text.',
242
151
  icon: 'text',
243
152
  category: 'Content',
244
153
  fields: [{ name: 'text', type: 'textarea', label: 'Text', required: true, localized: true }],
@@ -251,22 +160,17 @@ export function defaultBlocks(options) {
251
160
  const richText = defineBlock({
252
161
  type: 'richText',
253
162
  label: 'Rich text',
163
+ description: 'Text with headings, links, lists and quotes.',
254
164
  icon: 'richText',
255
165
  category: 'Content',
256
166
  fields: [
257
167
  { name: 'content', type: 'richText', label: 'Content', required: true, localized: true },
258
- {
259
- name: 'headingIds',
260
- type: 'checkbox',
261
- label: 'Heading ids',
262
- admin: { description: 'Each heading gets an id from its text, so a table of contents can link to it ("#prices").' },
263
- },
264
168
  ],
265
169
  defaultClassName: 'prose',
266
170
  ai: {
267
171
  description: 'Formatted text (Lexical JSON): paragraphs, headings, bold and italic, links and lists. ' +
268
- 'Use it for articles and longer copy. The "prose" class styles the content. "headingIds": true gives each ' +
269
- 'heading an id from its text, for "#id" links.',
172
+ 'Use it for articles and longer copy. The "prose" class styles the content. Each heading gets an id ' +
173
+ 'from its text (e.g. "Our prices" -> "our-prices"; repeats get "-2"), for "#id" links and the tableOfContents block.',
270
174
  example: {
271
175
  type: 'richText',
272
176
  className: 'prose',
@@ -303,6 +207,7 @@ export function defaultBlocks(options) {
303
207
  const image = defineBlock({
304
208
  type: 'image',
305
209
  label: 'Image',
210
+ description: 'A picture from the media library.',
306
211
  icon: 'image',
307
212
  category: 'Media',
308
213
  fields: [
@@ -314,20 +219,11 @@ export function defaultBlocks(options) {
314
219
  type: 'text',
315
220
  label: 'Alt text',
316
221
  localized: true,
317
- admin: { description: 'Describes the image for people who cannot see it. Leave empty to use the alt text saved with the image.' },
318
- },
319
- {
320
- name: 'priority',
321
- type: 'checkbox',
322
- label: 'Load first',
323
- admin: { description: 'For the main image at the top of the page: it loads at once with high priority instead of lazily.' },
324
- },
325
- {
326
- name: 'sizes',
327
- type: 'text',
328
- label: 'Sizes',
329
- admin: { description: 'The width the image shows at, for the browser to pick a file, for example "(min-width: 768px) 50vw, 100vw". Empty: the full width.' },
222
+ admin: { placeholder: 'From the image' },
223
+ custom: { ai: { description: 'Empty: the alt text saved with the image.' } },
330
224
  },
225
+ { name: 'priority', type: 'checkbox', label: 'Load first', admin: { description: 'For the main image at the top.' } },
226
+ { name: 'sizes', type: 'text', label: 'Sizes', admin: { placeholder: '100vw', custom: { builderContent: false } } },
331
227
  ],
332
228
  ai: {
333
229
  description: `An image from the "${mediaCollection}" collection, stored by its document ID. ` +
@@ -337,26 +233,21 @@ export function defaultBlocks(options) {
337
233
  example: { type: 'image', props: { image: 1, alt: 'Team photo' }, className: 'w-full rounded-lg' },
338
234
  },
339
235
  });
340
- const icons = options?.icons ?? [];
341
236
  const button = defineBlock({
342
237
  type: 'button',
343
238
  label: 'Button',
239
+ description: 'A button that links to a page or a URL.',
344
240
  icon: 'button',
345
241
  category: 'Interactive',
346
242
  fields: [
347
243
  { name: 'label', type: 'text', label: 'Label', required: true, localized: true },
348
244
  linkField({ collections: linkCollections }),
349
- ...(icons.length > 0 ? buttonIconFields(icons) : []),
350
245
  ],
351
- defaultClassName: 'inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground' +
352
- (icons.length > 0 ? ' gap-2' : ''),
246
+ defaultClassName: 'inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground',
353
247
  ai: {
354
248
  description: 'A call-to-action button. "link.type" is "url" (set "link.url") or "reference" (set "link.reference" to ' +
355
- '{ relationTo, value }). Without a link it renders as plain text.' +
356
- (icons.length > 0
357
- ? ` Optional "icon" (one of: ${icons.join(', ')}) shows an icon before ("iconPosition": "start") or after ` +
358
- '("end", the default) the label; "iconClassName" sizes it (default "size-4 shrink-0").'
359
- : ''),
249
+ '{ relationTo, value }). Without a link it renders as plain text. For a button with an icon, use a link block ' +
250
+ 'that holds a text block and an icon block.',
360
251
  example: {
361
252
  type: 'button',
362
253
  props: { label: 'Contact us', link: exampleLink },
@@ -367,6 +258,7 @@ export function defaultBlocks(options) {
367
258
  const link = defineBlock({
368
259
  type: 'link',
369
260
  label: 'Link',
261
+ description: 'Makes all the blocks inside it one link.',
370
262
  icon: 'link',
371
263
  category: 'Interactive',
372
264
  fields: [linkField({ collections: linkCollections })],
@@ -395,6 +287,7 @@ export function defaultBlocks(options) {
395
287
  const menu = defineBlock({
396
288
  type: 'menu',
397
289
  label: 'Menu',
290
+ description: 'Navigation links for a header or a footer.',
398
291
  icon: 'menu',
399
292
  category: 'Interactive',
400
293
  fields: [
@@ -410,10 +303,6 @@ export function defaultBlocks(options) {
410
303
  name: 'children',
411
304
  type: 'array',
412
305
  label: 'Dropdown links',
413
- admin: {
414
- description: 'Optional. Links under this one (one level), shown in a dropdown. The link above is optional when it has ' +
415
- 'dropdown links: without it the label opens the dropdown.',
416
- },
417
306
  fields: [
418
307
  { name: 'label', type: 'text', label: 'Label', required: true, localized: true },
419
308
  linkField({ collections: linkCollections }),
@@ -421,57 +310,30 @@ export function defaultBlocks(options) {
421
310
  },
422
311
  ],
423
312
  },
424
- {
425
- name: 'label',
426
- type: 'text',
427
- label: 'Menu name',
428
- defaultValue: 'Main',
429
- localized: true,
430
- admin: { description: 'Read by screen readers, for example "Main" or "Footer".' },
431
- },
432
- {
433
- name: 'toggleLabel',
434
- type: 'text',
435
- label: 'Menu button text',
436
- defaultValue: 'Menu',
437
- localized: true,
438
- admin: { description: 'The text of the button that opens the links on small screens.' },
439
- },
440
- {
441
- name: 'submenuLabel',
442
- type: 'text',
443
- label: 'Dropdown button name',
444
- defaultValue: '{label} menu',
445
- localized: true,
446
- admin: {
447
- description: 'Read by screen readers on the small arrow button next to a link with dropdown links. {label} is the link label.',
448
- },
449
- },
313
+ labelField('label', MENU_LABELS.label, 'Menu name'),
314
+ labelField('toggleLabel', MENU_LABELS.toggleLabel, 'Menu button text'),
315
+ labelField('submenuLabel', MENU_LABELS.submenuLabel, 'Dropdown button name'),
450
316
  {
451
317
  name: 'collapse',
452
318
  type: 'select',
453
- label: 'Small screens',
319
+ label: 'Menu button',
454
320
  options: [
455
- { label: 'Menu button below tablet width', value: 'md' },
456
- { label: 'Menu button below laptop width', value: 'lg' },
457
- { label: 'Always show the links', value: 'never' },
321
+ { label: 'Below tablet width', value: 'md' },
322
+ { label: 'Below laptop width', value: 'lg' },
323
+ { label: 'Never', value: 'never' },
458
324
  ],
459
325
  defaultValue: 'md',
460
- admin: { description: 'On small screens the links fold into a "Menu" button with a panel.' },
461
- },
462
- {
463
- name: 'ctaLabel',
464
- type: 'text',
465
- label: 'Panel button text',
466
- localized: true,
467
- admin: {
468
- description: 'Optional. A button as the last row of the small-screen panel, for example the call to action the header ' +
469
- 'shows only on wide screens. Needs a link below. Not shown when the links are always visible.',
470
- },
471
326
  },
327
+ { name: 'ctaLabel', type: 'text', label: 'Panel button text', localized: true },
472
328
  linkField({ name: 'cta', label: 'Panel button link', collections: linkCollections }),
473
329
  ],
474
330
  defaultClassName: 'flex flex-row items-center gap-6 text-sm font-medium',
331
+ parts: {
332
+ link: { label: 'Links' },
333
+ submenu: { label: 'Dropdowns' },
334
+ submenuLink: { label: 'Dropdown links' },
335
+ panel: { label: 'Small-screen panel' },
336
+ },
475
337
  classes: MENU_CLASSES,
476
338
  ai: {
477
339
  description: 'Site navigation: a <nav> with a list of links. The link to the current page is marked. ' +
@@ -481,7 +343,9 @@ export function defaultBlocks(options) {
481
343
  'Optional "ctaLabel" and "cta" (a link) add a button as the last row of the small-screen panel. "toggleLabel" is the text of the menu button (default "Menu"; translate it per locale). ' +
482
344
  'An item may have "children" (one level of { label, link }): a dropdown. With its own link the item shows the link and a ' +
483
345
  'small arrow button that opens the dropdown ("submenuLabel" names that button, default "{label} menu"); without a link the ' +
484
- 'label itself opens it. On small screens the children show as a nested list in the panel.',
346
+ 'label itself opens it. On small screens the children show as a nested list in the panel. ' +
347
+ 'Style the inner elements with "partClassName": "link" (each link of the inline list), "submenu" (the dropdown box), ' +
348
+ '"submenuLink" (each dropdown link), "panel" (the small-screen panel). They add to the classes the menu sets itself.',
485
349
  example: {
486
350
  type: 'menu',
487
351
  props: {
@@ -492,8 +356,8 @@ export function defaultBlocks(options) {
492
356
  {
493
357
  label: 'Services',
494
358
  children: [
495
- { label: 'Dinner dates', link: { type: 'url', url: '/services/dinner' } },
496
- { label: 'Travel', link: { type: 'url', url: '/services/travel' } },
359
+ { label: 'Web design', link: { type: 'url', url: '/services/web-design' } },
360
+ { label: 'Hosting', link: { type: 'url', url: '/services/hosting' } },
497
361
  ],
498
362
  },
499
363
  { label: 'Contact', link: { type: 'url', url: '/contact' } },
@@ -506,6 +370,7 @@ export function defaultBlocks(options) {
506
370
  const list = defineBlock({
507
371
  type: TEXT_LIST_BLOCK,
508
372
  label: 'List',
373
+ description: 'A bulleted or numbered list.',
509
374
  icon: 'list',
510
375
  category: 'Content',
511
376
  fields: [{ name: 'ordered', type: 'checkbox', label: 'Numbered list' }],
@@ -531,18 +396,10 @@ export function defaultBlocks(options) {
531
396
  const listItem = defineBlock({
532
397
  type: TEXT_LIST_ITEM_BLOCK,
533
398
  label: 'List item',
399
+ description: 'One item of a list.',
534
400
  icon: 'text',
535
401
  category: 'Content',
536
- fields: [
537
- { name: 'text', type: 'text', label: 'Text', required: true, localized: true },
538
- {
539
- ...itemLink,
540
- admin: {
541
- ...itemLink.admin,
542
- description: 'Optional. The item text becomes a link. Leave it empty in a list inside a Link block: a link cannot hold another link.',
543
- },
544
- },
545
- ],
402
+ fields: [{ name: 'text', type: 'text', label: 'Text', required: true, localized: true }, itemLink],
546
403
  parents: [TEXT_LIST_BLOCK],
547
404
  ai: {
548
405
  description: `One item (<li>) of a "${TEXT_LIST_BLOCK}" block. It goes only in a list's "${TEXT_LIST_SLOT}" slot. ` +
@@ -551,28 +408,10 @@ export function defaultBlocks(options) {
551
408
  example: { type: TEXT_LIST_ITEM_BLOCK, props: { text: 'Pricing', link: exampleLink } },
552
409
  },
553
410
  });
554
- const quote = defineBlock({
555
- type: 'quote',
556
- label: 'Quote',
557
- icon: 'quote',
558
- category: 'Content',
559
- fields: [
560
- { name: 'quote', type: 'textarea', label: 'Quote', required: true, localized: true },
561
- { name: 'cite', type: 'text', label: 'Source', localized: true, admin: { description: 'Who said it, for example "Jane Doe, CEO".' } },
562
- ],
563
- defaultClassName: 'border-l-4 pl-4 italic',
564
- ai: {
565
- description: 'A quotation or testimonial, with an optional source.',
566
- example: {
567
- type: 'quote',
568
- props: { quote: 'They rebuilt our site in a week.', cite: 'Jane Doe, Acme' },
569
- className: 'border-l-4 pl-4 italic',
570
- },
571
- },
572
- });
573
411
  const divider = defineBlock({
574
412
  type: 'divider',
575
413
  label: 'Divider',
414
+ description: 'A line between parts of a page.',
576
415
  icon: 'divider',
577
416
  category: 'Layout',
578
417
  fields: [],
@@ -582,21 +421,10 @@ export function defaultBlocks(options) {
582
421
  example: { type: 'divider', className: 'my-8 border-t' },
583
422
  },
584
423
  });
585
- const spacer = defineBlock({
586
- type: 'spacer',
587
- label: 'Spacer',
588
- icon: 'spacer',
589
- category: 'Layout',
590
- fields: [],
591
- defaultClassName: 'h-8',
592
- ai: {
593
- description: 'Empty vertical space. Set the height with a class such as "h-16". Prefer gap and padding classes.',
594
- example: { type: 'spacer', className: 'h-16' },
595
- },
596
- });
597
424
  const video = defineBlock({
598
425
  type: 'video',
599
426
  label: 'Video',
427
+ description: 'A video from an upload, YouTube or Vimeo.',
600
428
  icon: 'video',
601
429
  category: 'Media',
602
430
  fields: [
@@ -606,7 +434,7 @@ export function defaultBlocks(options) {
606
434
  label: 'Source',
607
435
  options: [
608
436
  { label: 'Upload', value: 'upload' },
609
- { label: 'URL (YouTube, Vimeo or a video file)', value: 'url' },
437
+ { label: 'Link', value: 'url' },
610
438
  ],
611
439
  defaultValue: 'upload',
612
440
  },
@@ -614,15 +442,16 @@ export function defaultBlocks(options) {
614
442
  {
615
443
  name: 'url',
616
444
  type: 'text',
617
- label: 'URL',
445
+ label: 'Video link',
618
446
  admin: {
619
- description: 'A YouTube or Vimeo link, or a direct link to a video file.',
447
+ placeholder: 'YouTube, Vimeo or a video file',
620
448
  // Format `videoUrl` (core/formats.ts): the inspector shows the message, publishing needs a good link.
621
449
  custom: { ...when('source', 'url').custom, builderFormat: 'videoUrl' },
622
450
  },
451
+ custom: { ai: { description: 'A YouTube or Vimeo link, or a direct link to a video file.' } },
623
452
  },
624
453
  { name: 'poster', type: 'upload', label: 'Poster image', relationTo: mediaCollection },
625
- { name: 'autoplay', type: 'checkbox', label: 'Autoplay', admin: { description: 'Browsers only autoplay muted videos.' } },
454
+ { name: 'autoplay', type: 'checkbox', label: 'Autoplay', admin: { description: 'Works only when muted.' } },
626
455
  { name: 'loop', type: 'checkbox', label: 'Loop' },
627
456
  { name: 'muted', type: 'checkbox', label: 'Muted' },
628
457
  { name: 'controls', type: 'checkbox', label: 'Show controls', defaultValue: true },
@@ -641,47 +470,22 @@ export function defaultBlocks(options) {
641
470
  const field = defineBlock({
642
471
  type: FIELD_BLOCK,
643
472
  label: 'Field',
473
+ description: 'Shows one field of the page or of each list item.',
644
474
  icon: 'field',
645
475
  category: 'Dynamic',
646
476
  fields: [
647
- {
648
- name: 'path',
649
- type: 'text',
650
- label: 'Field',
651
- required: true,
652
- admin: { description: 'The name of the field to show, for example "content" or "featuredImage". For a field inside another, join the names with a dot: "author.name".' },
653
- },
654
- {
655
- name: 'fallback',
656
- type: 'text',
657
- label: 'Fallback',
658
- localized: true,
659
- admin: { description: 'Shown when this field is empty.' },
660
- },
661
- {
662
- name: 'format',
663
- type: 'text',
664
- label: 'Format',
665
- admin: {
666
- description: 'For a number, date or text: "currency:AUD" ($1,200), "number" (1,200), "date:en-AU:Australia/Brisbane" ' +
667
- '(a date in that language and time zone) or "firstSentence". Empty: the value as it is.',
668
- },
669
- },
670
- {
671
- name: 'headingIds',
672
- type: 'checkbox',
673
- label: 'Heading ids',
674
- admin: { description: 'For rich text: each heading gets an id from its text, so a table of contents can link to it ("#prices").' },
675
- },
477
+ // The inspector shows the field picker and the format of the bindings UI (templates/Bindable).
478
+ { name: 'path', type: 'text', label: 'Field', required: true, admin: { custom: { builderContent: false } } },
479
+ { name: 'fallback', type: 'text', label: 'Text when empty', localized: true },
676
480
  ],
677
481
  classes: FIELD_CLASSES,
678
482
  ai: {
679
483
  description: 'Shows one field of the current document in a template, rendered by its value: rich text as formatted ' +
680
484
  'text, an upload as an image, a date as a formatted date, a relationship as its title, text as text. ' +
681
485
  '"path" is a dot path from getBindingSources (e.g. "content", "author.name"). Only works in templates ' +
682
- 'and inside a collection list item. "format" formats a number, date or text with a binding formatter: ' +
683
- '"currency:AUD", "number", "date:en-AU:Australia/Brisbane" or "firstSentence". "headingIds": true gives each ' +
684
- 'rich-text heading an id from its text (e.g. "Our prices" -> "our-prices", repeats get "-2"), for "#id" links.',
486
+ 'and inside a collection list item. "path" takes binding formatters after a "|": "price|currency:USD", ' +
487
+ '"publishedAt|date:en-US", "summary|truncate:160". Rich-text headings get ids from their text (e.g. "Our prices" -> ' +
488
+ '"our-prices", repeats get "-2"), for "#id" links.',
685
489
  example: { type: FIELD_BLOCK, props: { path: 'content' }, className: 'prose max-w-none' },
686
490
  },
687
491
  });
@@ -689,54 +493,30 @@ export function defaultBlocks(options) {
689
493
  const collectionList = defineBlock({
690
494
  type: COLLECTION_LIST_BLOCK,
691
495
  label: 'Collection list',
496
+ description: 'Shows posts, products or other documents from a collection.',
692
497
  icon: 'collectionList',
693
498
  category: 'Dynamic',
499
+ // `builderHeading`: the inspector shows a small heading above the field, so the long list reads in groups.
694
500
  fields: [
695
- listCollections && listCollections.length > 0
696
- ? { name: 'collection', type: 'select', label: 'Collection', options: listCollections, required: true }
697
- : { name: 'collection', type: 'text', label: 'Collection', required: true },
698
- { name: 'limit', type: 'number', label: 'Number of items', defaultValue: 3, min: 1, max: 100 },
699
- {
700
- name: 'sort',
701
- type: 'text',
702
- label: 'Sort',
703
- defaultValue: '-createdAt',
704
- admin: {
705
- description: 'The field to sort by, for example "publishedAt". Put a "-" in front for newest or largest first: "-publishedAt". ' +
706
- '"$random" shuffles the newest 100 matches once per page build.',
707
- },
708
- },
709
- listCollections && listCollections.length > 0
710
- ? {
711
- name: 'ids',
712
- type: 'relationship',
713
- label: 'Picked documents',
714
- // The slugs come from the app, so they cannot match Payload's generated slug type.
715
- relationTo: (listCollections.length === 1 ? listCollections[0] : listCollections),
716
- hasMany: true,
717
- admin: { description: 'Only these documents, in this order. Limit, sort, skip and pages then do not apply.' },
718
- }
719
- : {
720
- name: 'ids',
721
- type: 'text',
722
- label: 'Picked document ids',
723
- hasMany: true,
724
- admin: { description: 'Only these documents, in this order. Limit, sort, skip and pages then do not apply.' },
725
- },
501
+ listCollectionField(listCollections, { label: 'Collection', required: true }),
502
+ pickedDocumentsField(listCollections),
726
503
  {
727
- name: 'excludeCurrent',
728
- type: 'checkbox',
729
- label: 'Leave out the current document',
730
- defaultValue: true,
731
- admin: { description: 'On a page made from a template, the item that the page shows is not listed again.' },
504
+ name: 'depth',
505
+ type: 'select',
506
+ label: 'Load related data',
507
+ defaultValue: '1',
508
+ options: [
509
+ { label: '1 level', value: '1' },
510
+ { label: '2 levels', value: '2' },
511
+ ],
732
512
  },
733
513
  {
734
514
  name: 'filterField',
735
515
  type: 'text',
736
- label: 'Filter by field',
516
+ label: 'Related to this page',
737
517
  admin: {
738
- description: 'Only documents related to the current document through this field, for example "services" or "category". ' +
739
- 'Works on pages made from a template. On other pages the list is not filtered.',
518
+ // The inspector shows one select of the fields that relate the two collections, and sets `filterBy` with it.
519
+ custom: { builderHeading: 'Filter', builderRelated: { collectionField: 'collection', modeField: 'filterBy' }, builderContent: false },
740
520
  },
741
521
  },
742
522
  {
@@ -745,120 +525,125 @@ export function defaultBlocks(options) {
745
525
  label: 'Relation',
746
526
  defaultValue: 'current',
747
527
  options: [
748
- { label: 'The listed documents\' field holds the current document', value: 'current' },
749
- { label: 'The listed documents share a value with the current document\'s field', value: 'shared' },
750
- { label: 'The current document\'s field points to the listed documents', value: 'linked' },
528
+ { label: 'Its field links to this page', value: 'current' },
529
+ { label: 'Same value as this page', value: 'shared' },
530
+ { label: 'This page links to it', value: 'linked' },
751
531
  ],
752
- admin: { description: 'How "Filter by field" relates the listed documents to the current document.' },
532
+ // Set by the "Related to this page" select.
533
+ admin: { hidden: true },
534
+ },
535
+ {
536
+ name: 'excludeCurrent',
537
+ type: 'checkbox',
538
+ label: 'Leave out the document this page shows',
539
+ defaultValue: true,
753
540
  },
754
541
  {
755
542
  name: 'where',
756
543
  type: 'json',
757
- label: 'Where',
544
+ label: 'Conditions',
758
545
  admin: {
759
- description: 'A Payload where query, added to the filter. Example: { "featured": { "equals": true } }. Dates may use ' +
760
- '"$now", "$now-30d" or "$now+12h".',
761
546
  // The inspector edits it as condition rows over the fields of the chosen collection.
762
547
  custom: { builderWhere: { collectionField: 'collection' } },
763
548
  },
549
+ custom: {
550
+ ai: {
551
+ description: 'A Payload where query, added to the filter. Dates may use "$now", "$now-30d" or "$now+12h". In a template, ' +
552
+ '"$page.<field>" uses a field of the page\'s document; "$query.<param>" uses a URL value (left out without one).',
553
+ },
554
+ },
764
555
  },
765
556
  {
766
557
  name: 'queryFilters',
767
558
  type: 'json',
768
559
  label: 'URL filters',
769
560
  admin: {
770
- description: 'Filters from the page URL: { "param": { "value": where } }. Example: { "available": { "today": { "availableToday": ' +
771
- '{ "equals": true } } } } filters on ?available=today. Several values of one parameter are OR-ed, parameters are AND-ed.',
561
+ // The inspector edits it as rows (parameter, field), with JSON for the full form.
562
+ custom: { builderQueryFilters: { collectionField: 'collection' } },
772
563
  },
564
+ custom: { ai: { description: 'Filters from the page URL: { "<param>": "<field>" }. The editor preview ignores them.' } },
773
565
  },
774
- { name: 'offset', type: 'number', label: 'Skip items', min: 0, admin: { description: 'Documents to leave out at the start.' } },
566
+ {
567
+ name: 'sort',
568
+ type: 'text',
569
+ label: 'Sort',
570
+ defaultValue: '-createdAt',
571
+ admin: {
572
+ // The inspector shows a select of the collection's fields, a direction and "Random".
573
+ custom: { builderHeading: 'Sort and count', builderSort: { collectionField: 'collection' }, builderContent: false },
574
+ },
575
+ custom: {
576
+ ai: {
577
+ description: 'A field name; a "-" in front sorts newest or largest first ("-publishedAt"). "$random" shuffles the newest 100 matches once per page build.',
578
+ },
579
+ },
580
+ },
581
+ { name: 'limit', type: 'number', label: 'Number of items', defaultValue: 3, min: 1, max: 100 },
582
+ { name: 'offset', type: 'number', label: 'Skip first', min: 0, admin: { placeholder: '0' } },
775
583
  {
776
584
  name: 'paginate',
777
585
  type: 'select',
778
- label: 'Pages',
586
+ label: 'Page links',
779
587
  defaultValue: 'none',
780
588
  options: [
781
- { label: 'None: only the first items', value: 'none' },
782
- { label: 'Pages with ?page=N links', value: 'pages' },
589
+ { label: 'None', value: 'none' },
590
+ { label: 'Under the list', value: 'pages' },
783
591
  ],
784
- admin: {
785
- description: 'Pages: "Number of items" per page, with page links under the list. Long lists show the first, the last and the ' +
786
- 'pages around the current one, with "…" between. "Skip items" does not apply.',
787
- },
592
+ admin: { custom: { builderHeading: 'Pages' } },
788
593
  },
789
594
  {
790
595
  name: 'pageParam',
791
596
  type: 'text',
792
- label: 'Page parameter',
793
- admin: {
794
- description: 'The URL parameter of the page number. Empty: "page". Give each paginated list on one page its own, for example ' +
795
- '"reviewsPage". Letters, digits, _ and -.',
796
- ...when('paginate', 'pages'),
597
+ label: 'URL parameter',
598
+ admin: { placeholder: 'page', custom: { ...when('paginate', 'pages').custom, builderContent: false } },
599
+ custom: {
600
+ ai: {
601
+ description: 'Empty: "page". Give each paginated list on one page its own, for example "reviewsPage". Letters, digits, _ and -.',
602
+ },
797
603
  },
798
604
  },
799
605
  {
800
606
  name: 'pagerLabel',
801
607
  type: 'text',
802
- label: 'Page links: label for screen readers',
803
- defaultValue: 'Pages',
608
+ label: 'Name for screen readers',
804
609
  localized: true,
805
- admin: when('paginate', 'pages'),
806
- },
807
- {
808
- name: 'pagerClassName',
809
- type: 'text',
810
- label: 'Page links: classes',
811
- defaultValue: 'flex flex-wrap gap-2',
812
- admin: {
813
- description: 'Classes of the element that holds the page links. A gap ("…") is a span with data-page-gap.',
814
- custom: { builderClasses: true },
815
- },
816
- },
817
- {
818
- name: 'pageLinkClassName',
819
- type: 'text',
820
- label: 'Page link: classes',
821
- admin: { description: 'Classes of each page link. The current page has aria-current="page", e.g. "aria-[current=page]:font-bold".', custom: { builderClasses: true } },
822
- },
823
- {
824
- name: 'depth',
825
- type: 'select',
826
- label: 'Related data depth',
827
- defaultValue: '1',
828
- options: [
829
- { label: '1: the related documents of each item', value: '1' },
830
- { label: '2: also their related documents (larger)', value: '2' },
831
- ],
832
- admin: { description: 'How far related documents of each item load, for example 2 to reach a category\'s image.' },
610
+ admin: { placeholder: 'Pages', ...when('paginate', 'pages') },
833
611
  },
834
612
  ],
835
613
  slots: { [LIST_ITEM_SLOT]: { label: 'Item' }, [LIST_EMPTY_SLOT]: { label: 'When empty', styles: true } },
614
+ // The page links: the <nav> that holds them (a gap "…" is a span with data-page-gap) and each link.
615
+ parts: { pager: { label: 'Page links', defaultClassName: 'flex flex-wrap gap-2' }, pageLink: { label: 'Each page link' } },
836
616
  defaultClassName: 'grid grid-cols-1 gap-6 md:grid-cols-3',
837
617
  ai: {
838
618
  description: 'Lists the latest documents of a collection (e.g. "latest posts"). The "item" slot is the design of ONE ' +
839
619
  'item: it repeats for every document. Blocks in it bind to the ITEM\'s fields with "bindings", e.g. a ' +
840
620
  'heading with bindings { "text": "title" } and a link with bindings { "link": "$url" } (the item\'s URL). ' +
841
621
  'Only published documents show on the site. ' +
842
- 'To list documents related to the current document (templates only; ignored on normal pages), set ' +
622
+ 'To list documents related to the current document (templates only; on normal pages the list is empty), set ' +
843
623
  '"filterField" (a field name) and "filterBy": "current" (default) lists documents whose filterField holds ' +
844
- 'the current document (e.g. on a service template, models whose "services" include this service); ' +
624
+ 'the current document (e.g. on a category template, posts whose "categories" include this category); ' +
845
625
  '"shared" lists documents whose filterField shares a value with the current document\'s filterField ' +
846
- '(e.g. similar models with a "category" in common, posts with the same "category" text); "linked" lists ' +
847
- 'the documents the current document\'s filterField points to (e.g. on a model template, the model\'s ' +
848
- '"services"). With "shared" or "linked" and an empty field, the list is empty. "where" is a static Payload ' +
849
- 'where query AND-ed with the rest, e.g. { "featured": { "equals": true } }; date values may be "$now", ' +
850
- '"$now-30d" or "$now+7d" (units d and h). "queryFilters" filters by the page URL: { "<param>": { "<value>": where } }, ' +
851
- 'e.g. { "available": { "today": { "availableToday": { "equals": true } } } } for ?available=today; values of one ' +
626
+ '(e.g. related posts with a "category" in common); "linked" lists ' +
627
+ 'the documents the current document\'s filterField points to (e.g. on a post template, the post\'s ' +
628
+ '"authors"). With "shared" or "linked" and an empty field, the list is empty. "where" is a static Payload ' +
629
+ 'where query AND-ed with the rest, e.g. { "featured": { "equals": true } }, with "or" for alternatives; date values may be "$now", ' +
630
+ '"$now-30d" or "$now+7d" (units d and h). A value "$page.<field>" is that field of the current document when the ' +
631
+ 'list loads (e.g. { "category": { "equals": "$page.category" } } on a post template; ids for relationships; ' +
632
+ 'without a value the list is empty, except for not_equals and not_in, which are left out). A value "$query.<param>" is ' +
633
+ 'the URL value (several values make equals an "in"); without one the condition is left out, and the canvas has none. "queryFilters" filters by the page URL: { "<param>": "<field path>" } ' +
634
+ 'means the field equals the URL value (e.g. { "category": "category" } for ?category=news); the full form ' +
635
+ '{ "<param>": { "<value>": where } } maps each value to a where (e.g. { "age": { "recent": { "publishedAt": ' +
636
+ '{ "greater_than": "$now-30d" } } } } for ?age=recent). Values of one ' +
852
637
  'param (repeated or comma-separated) are OR-ed, params are AND-ed; the canvas ignores them. "offset" skips ' +
853
638
  'documents. "depth" ("1" or "2") is how deep related documents load. "ids" picks documents by id and keeps the ' +
854
639
  'pick order (limit, sort, offset and pages then do not apply). "sort": "$random" shuffles the newest 100 ' +
855
640
  'matches once per page build. "paginate": "pages" shows "limit" items per page with crawlable ?page=N links ' +
856
- 'under the list ("pagerClassName" and "pageLinkClassName" style them; the current link has aria-current="page"; long ' +
641
+ 'under the list (style them with "partClassName" "pager" for the <nav> and "pageLink" for each link; the current link has aria-current="page"; long ' +
857
642
  'lists show "…" gaps as <span data-page-gap>). Two paginated lists on one page need their own "pageParam" ' +
858
643
  '(default "page"), for example "reviewsPage". "pagerLabel" names the page links for screen readers (default "Pages"). ' +
859
644
  'The "empty" slot shows instead of the ' +
860
- 'items when no document matches (e.g. a text "Nobody is available today"); it renders in its own div, styled ' +
861
- 'with "slotClassName": { "empty": "col-span-full ..." }.',
645
+ 'items when no document matches (e.g. a text "No posts yet"); it renders in its own div, styled ' +
646
+ 'with "partClassName": { "empty": "col-span-full ..." }.',
862
647
  example: {
863
648
  type: COLLECTION_LIST_BLOCK,
864
649
  props: { collection: 'posts', limit: 3, sort: '-createdAt' },
@@ -885,48 +670,29 @@ export function defaultBlocks(options) {
885
670
  const repeat = defineBlock({
886
671
  type: REPEAT_BLOCK,
887
672
  label: 'Repeat',
673
+ description: 'Repeats its blocks for each row of a list field.',
888
674
  icon: 'repeat',
889
675
  category: 'Dynamic',
890
676
  fields: [
891
- {
892
- name: 'path',
893
- type: 'text',
894
- label: 'Field',
895
- required: true,
896
- admin: {
897
- description: 'The list field of the current document to repeat, for example "faqs" (an array), "galleryImages" or "services" ' +
898
- '(many uploads or relationships) or "tags" (many values). Inside a collection list: a field of each item.',
899
- },
900
- },
901
- { name: 'limit', type: 'number', label: 'Number of rows', min: 1, admin: { description: 'Empty: every row.' } },
902
- { name: 'offset', type: 'number', label: 'Skip rows', min: 0, admin: { description: 'Rows to leave out at the start, for example 1 to skip the first photo.' } },
903
- listCollections && listCollections.length > 0
904
- ? {
905
- name: 'collection',
906
- type: 'select',
907
- label: 'Related collection',
908
- options: listCollections,
909
- admin: { description: 'For a relationship field: the collection of its documents, so "$url" links to each one.' },
910
- }
911
- : {
912
- name: 'collection',
913
- type: 'text',
914
- label: 'Related collection',
915
- admin: { description: 'For a relationship field: the collection of its documents, so "$url" links to each one.' },
916
- },
677
+ // The inspector shows the field picker of the bindings UI (templates/Bindable).
678
+ { name: 'path', type: 'text', label: 'Field', required: true, admin: { custom: { builderContent: false } } },
679
+ { name: 'limit', type: 'number', label: 'Number of rows', min: 1, admin: { placeholder: 'All' } },
680
+ { name: 'offset', type: 'number', label: 'Skip first', min: 0, admin: { placeholder: '0' } },
681
+ listCollectionField(listCollections, {
682
+ label: 'Linked collection',
683
+ required: false,
684
+ description: 'For links to each row.',
685
+ }),
917
686
  {
918
687
  name: 'as',
919
688
  type: 'select',
920
- label: 'Wrapper',
689
+ label: 'Tag',
921
690
  defaultValue: 'div',
922
691
  options: [
923
- { label: 'A div around the rows', value: 'div' },
924
- { label: 'None: the rows sit in the parent', value: 'none' },
692
+ { label: 'div', value: 'div' },
693
+ { label: 'none', value: 'none' },
925
694
  ],
926
- admin: {
927
- description: 'None: the rows become direct children of the parent block, for example the cells of a grid or the items of a list. ' +
928
- "The repeat's own classes and animations then do nothing.",
929
- },
695
+ admin: { description: 'None: the rows go straight into the parent.' },
930
696
  },
931
697
  ],
932
698
  slots: { [LIST_ITEM_SLOT]: { label: 'Row' } },
@@ -934,7 +700,7 @@ export function defaultBlocks(options) {
934
700
  ai: {
935
701
  description: 'Repeats its "item" slot once per row of a list field of the CURRENT document (templates; inside a collection ' +
936
702
  'list item, of each listed document; inside another repeat, of the row). "path" is the field: an array ' +
937
- '(e.g. FAQs, rates), a hasMany upload (e.g. a gallery), a hasMany relationship, or hasMany text/select. ' +
703
+ '(e.g. FAQs, prices), a hasMany upload (e.g. a gallery), a hasMany relationship, or hasMany text/select. ' +
938
704
  'Blocks in "item" bind to the ROW: the field names of an array row (e.g. "question", "price"), the related ' +
939
705
  `document's fields (e.g. "name"; "$url" when "collection" names its collection), "${ITEM_PATH}" (the row value ` +
940
706
  `itself: an upload for an image, a text for a text block), "${INDEX_PATH}" (the row number from 1), ` +
@@ -943,7 +709,7 @@ export function defaultBlocks(options) {
943
709
  'a div that takes the className; "none" renders the rows with no wrapper, as direct children of the parent ' +
944
710
  '(e.g. cells of a grid, items of a stack with as "ul"), and then className and motion do nothing. ' +
945
711
  'On a page without a current document ' +
946
- 'it shows nothing. Example 2 (photos): { "type": "repeat", "props": { "path": "galleryImages", "offset": 1 }, ' +
712
+ 'it shows nothing. Example 2 (photos): { "type": "repeat", "props": { "path": "gallery", "offset": 1 }, ' +
947
713
  `"slots": { "item": [{ "type": "image", "bindings": { "image": "${ITEM_PATH}" } }] } }.`,
948
714
  example: {
949
715
  type: REPEAT_BLOCK,
@@ -967,5 +733,5 @@ export function defaultBlocks(options) {
967
733
  },
968
734
  },
969
735
  });
970
- return [stack, grid, heading, text, richText, image, button, link, menu, list, listItem, quote, divider, spacer, video, field, collectionList, repeat];
736
+ return [stack, grid, heading, text, richText, image, button, link, menu, list, listItem, divider, video, field, collectionList, repeat];
971
737
  }