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
@@ -4,30 +4,27 @@ export const DISCLOSURE_BLOCK = 'disclosure';
4
4
  export const ACCORDION_BLOCK = 'accordion';
5
5
  /**
6
6
  * Classes the disclosure component adds itself. `animate`: the browser animates the content box
7
- * (`::details-content`) to `height: auto`; off with reduced motion and in browsers without it.
7
+ * (`::details-content`) to `height: auto` and fades it in, in 200 ms, close to the fades of the
8
+ * tabs and the popup; off with reduced motion and in browsers without it.
8
9
  */
9
10
  export const DISCLOSURE_CLASS_MAP = classMap({
10
11
  summary: 'cursor-pointer list-none [&::-webkit-details-marker]:hidden',
11
- animate: '[interpolate-size:allow-keywords] details-content:h-0 details-content:overflow-clip ' +
12
- 'details-content:transition-[height,content-visibility] details-content:duration-300 ' +
13
- 'details-content:[transition-behavior:allow-discrete] open:details-content:h-auto motion-reduce:details-content:transition-none',
12
+ animate: '[interpolate-size:allow-keywords] details-content:h-0 details-content:overflow-clip details-content:opacity-0 ' +
13
+ 'details-content:transition-[height,opacity,content-visibility] details-content:duration-200 details-content:ease-out ' +
14
+ 'details-content:[transition-behavior:allow-discrete] open:details-content:h-auto open:details-content:opacity-100 ' +
15
+ 'motion-reduce:details-content:transition-none',
14
16
  });
15
17
  const DISCLOSURE_CLASS = 'group [&>summary]:flex [&>summary]:items-center [&>summary]:justify-between [&>summary]:gap-4 [&>summary]:py-4 [&>div]:pb-4';
16
18
  export function disclosureBlock() {
17
19
  return defineBlock({
18
20
  type: DISCLOSURE_BLOCK,
19
21
  label: 'Disclosure',
20
- icon: 'chevronDown',
22
+ description: 'A title that opens and closes the content below it.',
23
+ icon: 'disclosure',
21
24
  category: 'Interactive',
22
25
  fields: [
23
26
  { name: 'open', type: 'checkbox', label: 'Open at first', defaultValue: false },
24
- {
25
- name: 'animate',
26
- type: 'checkbox',
27
- label: 'Animate the height',
28
- defaultValue: true,
29
- admin: { description: 'Opens and closes in 300 ms. Off when the visitor asks for less motion.' },
30
- },
27
+ { name: 'animate', type: 'checkbox', label: 'Animate', defaultValue: true },
31
28
  ],
32
29
  slots: {
33
30
  // A <summary> is the button: links and controls inside it are invalid HTML.
@@ -39,15 +36,15 @@ export function disclosureBlock() {
39
36
  ai: {
40
37
  description: 'One show/hide item: an FAQ question and answer, a "read more". The "summary" slot is always visible (a heading or ' +
41
38
  'text, often with an icon); the "content" slot opens below it. A native <details>, so it works without script, opens ' +
42
- 'with the keyboard and closed content stays in the HTML for search engines. The canvas shows it open. Style the ' +
39
+ 'with the keyboard and closed content stays in the HTML for search engines. In the canvas, selecting a block inside opens it. Style the ' +
43
40
  'summary row with [&>summary]: classes and the content with [&>div]: classes on the disclosure; open: and ' +
44
41
  'group-open: classes style the open state (e.g. "group-open:rotate-45" on an icon in the summary).',
45
42
  example: {
46
43
  type: DISCLOSURE_BLOCK,
47
44
  className: DISCLOSURE_CLASS,
48
45
  slots: {
49
- summary: [{ id: 'b_example_1', type: 'heading', props: { text: 'How do I book?', level: '3' }, className: 'text-lg font-medium' }],
50
- content: [{ id: 'b_example_2', type: 'text', props: { text: 'Send us a message with a date and a time.' } }],
46
+ summary: [{ id: 'b_example_1', type: 'heading', props: { text: 'How do I reset my password?', level: '3' }, className: 'text-lg font-medium' }],
47
+ content: [{ id: 'b_example_2', type: 'text', props: { text: 'Use the "Forgot password" link on the sign-in page.' } }],
51
48
  },
52
49
  },
53
50
  },
@@ -57,36 +54,29 @@ export function accordionBlock() {
57
54
  return defineBlock({
58
55
  type: ACCORDION_BLOCK,
59
56
  label: 'Accordion',
60
- icon: 'list',
57
+ description: 'A stack of items that open and close, like an FAQ.',
58
+ icon: 'accordion',
61
59
  category: 'Interactive',
62
60
  fields: [
63
- {
64
- name: 'multiple',
65
- type: 'checkbox',
66
- label: 'Several open at a time',
67
- defaultValue: true,
68
- admin: { description: 'Off: opening one item closes the others.' },
69
- },
61
+ { name: 'multiple', type: 'checkbox', label: 'Several open at a time', defaultValue: true },
70
62
  {
71
63
  name: 'faqSchema',
72
64
  type: 'checkbox',
73
65
  label: 'FAQ for search engines',
74
- defaultValue: true,
75
- admin: {
76
- description: "The page's FAQPage JSON-LD lists this accordion's items: the summary text is the question, the content text the answer.",
77
- },
66
+ defaultValue: false,
67
+ admin: { description: 'Only for real questions and answers.' },
78
68
  },
79
69
  ],
80
70
  slots: { items: { label: 'Items', allow: [DISCLOSURE_BLOCK, 'repeat', 'collectionList'] } },
81
71
  defaultClassName: 'flex flex-col divide-y border-y',
82
72
  ai: {
83
- description: 'A list of disclosure blocks in its "items" slot. "multiple": false keeps one item open at a time. With "faqSchema" ' +
84
- '(on by default) its items feed the page\'s FAQPage JSON-LD: the summary text is the question, the content text the ' +
73
+ description: 'A list of disclosure blocks in its "items" slot. "multiple": false keeps one item open at a time. Set "faqSchema": true ' +
74
+ 'only when the items are questions and answers: the site then outputs FAQPage JSON-LD for them by itself (nothing else to do): the summary text is the question, the content text the ' +
85
75
  'answer. In a template, repeat one disclosure over the document\'s FAQs: the items slot holds a repeat with path ' +
86
76
  '"faqs" whose item is a disclosure with a text bound to "question" in "summary" and a text bound to "answer" in "content".',
87
77
  example: {
88
78
  type: ACCORDION_BLOCK,
89
- props: { multiple: false },
79
+ props: { multiple: false, faqSchema: true },
90
80
  className: 'flex flex-col divide-y border-y',
91
81
  slots: {
92
82
  items: [
@@ -95,8 +85,8 @@ export function accordionBlock() {
95
85
  type: DISCLOSURE_BLOCK,
96
86
  className: DISCLOSURE_CLASS,
97
87
  slots: {
98
- summary: [{ id: 'b_example_2', type: 'text', props: { text: 'How far ahead should I book?' } }],
99
- content: [{ id: 'b_example_3', type: 'text', props: { text: 'A day ahead is best.' } }],
88
+ summary: [{ id: 'b_example_2', type: 'text', props: { text: 'Do you ship abroad?' } }],
89
+ content: [{ id: 'b_example_3', type: 'text', props: { text: 'Yes, to most countries.' } }],
100
90
  },
101
91
  },
102
92
  ],
@@ -0,0 +1,15 @@
1
+ import type { FieldAccess } from 'payload';
2
+ import type { BlockDefinition } from '../../core/types.js';
3
+ import { EMBED_BLOCK, EMBED_CLASS_MAP, EMBED_LABELS, EMBED_MAX_LENGTH, EMBED_MODES, EMBED_SANDBOX, embedMode } from '../client/embed.js';
4
+ export { EMBED_BLOCK, EMBED_CLASS_MAP, EMBED_LABELS, EMBED_MAX_LENGTH, EMBED_MODES, EMBED_SANDBOX, embedMode };
5
+ export type EmbedOptions = {
6
+ /**
7
+ * Who may change the code and the mode: a Payload field access function, for example
8
+ * `({ req }) => req.user?.role === 'admin'`. Default: everyone who may edit the document.
9
+ * Inline code runs on the site as the site's own code, so give it only to people you trust.
10
+ */
11
+ canEdit?: FieldAccess;
12
+ /** The longest code, in characters. Default: `EMBED_MAX_LENGTH` (50,000). Longer code blocks Publish. */
13
+ maxLength?: number;
14
+ };
15
+ export declare function embedBlock(options?: EmbedOptions): BlockDefinition;
@@ -0,0 +1,47 @@
1
+ import { defineBlock } from '../../core/blocks.js';
2
+ import { EMBED_BLOCK, EMBED_CLASS_MAP, EMBED_LABELS, EMBED_MAX_LENGTH, EMBED_MODES, EMBED_SANDBOX, embedMode } from '../client/embed.js';
3
+ import { classesOf, labelField } from './shared.js';
4
+ export { EMBED_BLOCK, EMBED_CLASS_MAP, EMBED_LABELS, EMBED_MAX_LENGTH, EMBED_MODES, EMBED_SANDBOX, embedMode };
5
+ export function embedBlock(options = {}) {
6
+ const { canEdit } = options;
7
+ const access = canEdit ? { access: { create: canEdit, update: canEdit } } : {};
8
+ const maxLength = options.maxLength ?? EMBED_MAX_LENGTH;
9
+ return defineBlock({
10
+ type: EMBED_BLOCK,
11
+ label: 'Embed',
12
+ description: 'Your own HTML code, such as a widget, a map or a form from another service.',
13
+ icon: 'embed',
14
+ category: 'Media',
15
+ fields: [
16
+ { name: 'code', type: 'code', label: 'Code', maxLength, admin: { language: 'html' }, ...access },
17
+ {
18
+ name: 'mode',
19
+ type: 'select',
20
+ label: 'Runs',
21
+ defaultValue: 'inline',
22
+ options: [
23
+ { label: 'In the page', value: 'inline' },
24
+ { label: 'In its own frame', value: 'isolated' },
25
+ ],
26
+ ...access,
27
+ },
28
+ labelField('title', EMBED_LABELS.title, 'Frame name for screen readers'),
29
+ ],
30
+ defaultClassName: 'w-full',
31
+ classes: classesOf(EMBED_CLASS_MAP),
32
+ ai: {
33
+ description: 'Custom HTML code from another service: a booking widget, a map, a newsletter form, a social post. "code" is ' +
34
+ `the HTML, at most ${maxLength} characters. "mode": "inline" (default) puts the HTML in the page and runs its ` +
35
+ '<script> tags once the page loads; "isolated" runs it in a sandboxed frame (scripts and forms work, but it ' +
36
+ 'cannot reach the page). An isolated frame does not grow with its content: give the block a height with ' +
37
+ 'className ("h-96", "aspect-video"). "title": the frame\'s name for screen readers. The editor never runs the ' +
38
+ 'code: the canvas shows it without scripts. Use it only for code the site owner gave you; never invent ' +
39
+ 'third-party scripts. Prefer the built-in blocks (video, image, form) when one fits.',
40
+ example: {
41
+ type: EMBED_BLOCK,
42
+ props: { mode: 'isolated', title: 'Opening hours', code: '<p style="font: 16px system-ui">Open Monday to Friday, 9 to 5.</p>' },
43
+ className: 'w-full h-24',
44
+ },
45
+ },
46
+ });
47
+ }
@@ -4,7 +4,7 @@ export type FaqItem = {
4
4
  answer: string;
5
5
  };
6
6
  /**
7
- * The questions and answers of a layout's accordions with "FAQ for search engines" on: the summary
7
+ * The questions and answers of a layout's accordions with "Mark up as FAQ for search engines" on (`faqSchema`): the summary
8
8
  * text of each disclosure is the question, the content text the answer. Call it after
9
9
  * `loadLayoutData`, so bound props, Field blocks, collection lists and repeats hold the document's
10
10
  * values. `blocks` is the site's block list (it types bound values). Hidden blocks count as absent.
@@ -48,7 +48,7 @@ function plainText(list, blocks) {
48
48
  return parts.map((part) => part.trim()).filter(Boolean).join(' ').replace(/\s+/g, ' ');
49
49
  }
50
50
  /**
51
- * The questions and answers of a layout's accordions with "FAQ for search engines" on: the summary
51
+ * The questions and answers of a layout's accordions with "Mark up as FAQ for search engines" on (`faqSchema`): the summary
52
52
  * text of each disclosure is the question, the content text the answer. Call it after
53
53
  * `loadLayoutData`, so bound props, Field blocks, collection lists and repeats hold the document's
54
54
  * values. `blocks` is the site's block list (it types bound values). Hidden blocks count as absent.
@@ -56,7 +56,7 @@ function plainText(list, blocks) {
56
56
  export function faqItems(layout, blocks = []) {
57
57
  const items = [];
58
58
  for (const block of walk(normalizeLayout(layout).blocks, blocks)) {
59
- if (block.type !== ACCORDION_BLOCK || block.props?.faqSchema === false)
59
+ if (block.type !== ACCORDION_BLOCK || block.props?.faqSchema !== true)
60
60
  continue;
61
61
  for (const item of walk(block.slots?.items ?? [], blocks)) {
62
62
  if (item.type !== DISCLOSURE_BLOCK)
@@ -1,22 +1,4 @@
1
1
  import type { BlockDefinition } from '../../core/types.js';
2
+ export { filterHref, type FilterLinkTarget, type FilterQuery } from '../client/filterLink.js';
2
3
  export declare const FILTER_LINK_BLOCK = "filterLink";
3
- /** A URL query: `URLSearchParams`, or the `searchParams` object of a Next.js page. */
4
- export type FilterQuery = URLSearchParams | Record<string, string | string[] | undefined>;
5
- export type FilterLinkTarget = {
6
- param: string;
7
- value: string;
8
- multiple?: boolean;
9
- /** Page parameters of lists with their own `pageParam`, dropped like `page`. */
10
- pageParams?: readonly string[];
11
- };
12
- /**
13
- * Where a filter link goes and whether it is the current filter. An empty `param` clears every
14
- * query value ("All"). An empty `value` clears its param. `multiple` toggles the value in the
15
- * param's comma list; otherwise the value replaces the param's values. Other params stay.
16
- * `path` is the page path; with an empty path the href is relative (`?a=b`, or `?` for none).
17
- */
18
- export declare function filterHref(path: string, query: FilterQuery, { param, value, multiple, pageParams }: FilterLinkTarget): {
19
- href: string;
20
- active: boolean;
21
- };
22
4
  export declare function filterLinkBlock(): BlockDefinition;
@@ -1,75 +1,34 @@
1
- import { PAGE_PARAM } from '../../core/bindings.js';
2
1
  import { defineBlock } from '../../core/blocks.js';
3
2
  import { INTERACTIVE } from './shared.js';
3
+ export { filterHref } from '../client/filterLink.js';
4
4
  export const FILTER_LINK_BLOCK = 'filterLink';
5
- /** The values of one param: repeated params and comma lists both count. */
6
- function valuesOf(query, param) {
7
- const raw = query instanceof URLSearchParams ? query.getAll(param) : [].concat(query[param] ?? []);
8
- return raw.flatMap((value) => value.split(',')).map((value) => value.trim()).filter(Boolean);
9
- }
10
- const keysOf = (query) => [...new Set(query instanceof URLSearchParams ? query.keys() : Object.keys(query))];
11
- /**
12
- * Where a filter link goes and whether it is the current filter. An empty `param` clears every
13
- * query value ("All"). An empty `value` clears its param. `multiple` toggles the value in the
14
- * param's comma list; otherwise the value replaces the param's values. Other params stay.
15
- * `path` is the page path; with an empty path the href is relative (`?a=b`, or `?` for none).
16
- */
17
- export function filterHref(path, query, { param, value, multiple, pageParams = [] }) {
18
- // A new filter starts again at page 1, so the page numbers are dropped.
19
- const pages = new Set([PAGE_PARAM, ...pageParams]);
20
- const params = keysOf(query).filter((key) => !pages.has(key) && valuesOf(query, key).length > 0);
21
- const link = (search) => (search ? `${path}?${search}` : path || '?');
22
- if (!param)
23
- return { href: link(''), active: params.length === 0 };
24
- const current = valuesOf(query, param);
25
- const active = value ? current.includes(value) : current.length === 0;
26
- const next = !value ? [] : !multiple ? [value] : active ? current.filter((item) => item !== value) : [...current, value];
27
- const search = [...params.filter((key) => key !== param), ...(next.length > 0 ? [param] : [])]
28
- .map((key) => `${encodeURIComponent(key)}=${(key === param ? next : valuesOf(query, key)).map(encodeURIComponent).join(',')}`)
29
- .join('&');
30
- return { href: link(search), active };
31
- }
32
5
  const FILTER_CLASS = 'inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm aria-[current=true]:font-semibold';
33
6
  export function filterLinkBlock() {
34
7
  return defineBlock({
35
8
  type: FILTER_LINK_BLOCK,
36
9
  label: 'Filter link',
37
- icon: 'link',
10
+ description: 'A link that filters a collection list on this page.',
11
+ icon: 'filter',
38
12
  category: 'Dynamic',
39
13
  fields: [
40
- {
41
- name: 'param',
42
- type: 'text',
43
- label: 'URL parameter',
44
- admin: { description: 'The query parameter this link sets, for example "available". Empty: the link clears every filter ("All").' },
45
- },
46
- {
47
- name: 'value',
48
- type: 'text',
49
- label: 'Value',
50
- admin: { description: 'The value it sets, for example "today" (makes ?available=today). Empty: the link clears this parameter.' },
51
- },
52
- {
53
- name: 'multiple',
54
- type: 'checkbox',
55
- label: 'Several values',
56
- admin: { description: 'The link adds or removes its value in a comma list (?hair=blonde,red) instead of replacing it.' },
57
- },
14
+ { name: 'param', type: 'text', label: 'URL parameter', admin: { placeholder: 'Empty: clear all filters', custom: { builderContent: false } } },
15
+ { name: 'value', type: 'text', label: 'Value', admin: { placeholder: 'Empty: clear this filter', custom: { builderContent: false } } },
16
+ { name: 'multiple', type: 'checkbox', label: 'Add to the other values' },
58
17
  ],
59
18
  slots: { children: { label: 'Content', disallow: INTERACTIVE } },
60
19
  defaultClassName: FILTER_CLASS,
61
20
  ai: {
62
21
  description: 'A link to the current page with one URL query value set, toggled or cleared, for the "queryFilters" of a collection ' +
63
- 'list (a filterLink with param "available" and value "today" goes to ?available=today). Other query values stay. An ' +
22
+ 'list (a filterLink with param "category" and value "news" goes to ?category=news). Other query values stay. An ' +
64
23
  'empty param clears every filter (the "All" link); an empty value clears its param. "multiple" toggles the value in a ' +
65
24
  'comma list. It drops the page numbers of paginated lists ("page", and the "pageParam" of each list in the same ' +
66
25
  'layout). The current filter gets aria-current="true": style it with aria-[current=true]: classes. Its "children" ' +
67
26
  'slot holds the label (a text, an icon). Filtered URLs should be noindex, follow.',
68
27
  example: {
69
28
  type: FILTER_LINK_BLOCK,
70
- props: { param: 'available', value: 'today' },
29
+ props: { param: 'category', value: 'news' },
71
30
  className: FILTER_CLASS,
72
- slots: { children: [{ id: 'b_example_1', type: 'text', props: { text: 'Available today' } }] },
31
+ slots: { children: [{ id: 'b_example_1', type: 'text', props: { text: 'News' } }] },
73
32
  },
74
33
  },
75
34
  });
@@ -1,5 +1,7 @@
1
1
  import type { BlockDefinition } from '../../core/types.js';
2
2
  export declare const ICON_BLOCK = "icon";
3
+ /** "arrowUpRight" -> "arrow up right". */
4
+ export declare const iconLabel: (name: string) => string;
3
5
  /**
4
6
  * One icon from the site's own icon set. `names` are the keys of the site's icon map, as plain
5
7
  * strings, so the Payload config never loads the icon components. The components come from
@@ -1,6 +1,7 @@
1
1
  import { defineBlock } from '../../core/blocks.js';
2
- import { iconLabel } from '../defaults.js';
3
2
  export const ICON_BLOCK = 'icon';
3
+ /** "arrowUpRight" -> "arrow up right". */
4
+ export const iconLabel = (name) => name.replace(/([A-Z])/g, ' $1').toLowerCase();
4
5
  /**
5
6
  * One icon from the site's own icon set. `names` are the keys of the site's icon map, as plain
6
7
  * strings, so the Payload config never loads the icon components. The components come from
@@ -10,7 +11,8 @@ export function iconBlock(names) {
10
11
  return defineBlock({
11
12
  type: ICON_BLOCK,
12
13
  label: 'Icon',
13
- icon: 'image',
14
+ description: 'A small icon from the site’s icon set.',
15
+ icon: 'icon',
14
16
  category: 'Content',
15
17
  // An icon may go straight into a link (an arrow at the end of a linked row).
16
18
  inline: true,
@@ -26,19 +28,17 @@ export function iconBlock(names) {
26
28
  {
27
29
  name: 'label',
28
30
  type: 'text',
29
- label: 'Label for screen readers',
31
+ label: 'Name for screen readers',
30
32
  localized: true,
31
- admin: {
32
- description: 'Empty: the icon is decoration and screen readers skip it. Fill it when the icon says something on its own, ' +
33
- 'for example "Yes" for a check mark in a table.',
34
- },
33
+ admin: { placeholder: 'None: decoration only' },
35
34
  },
36
35
  ],
37
36
  defaultClassName: 'size-6',
38
37
  ai: {
39
38
  description: `One icon from the site's icon set, drawn in the current text colour. Its className sets the size and colour ` +
40
39
  `("size-5 text-primary"). Names: ${names.join(', ')}. Leave "label" empty when the icon is decoration; set it ` +
41
- '("Yes", "No") when the icon is the only thing that says something.',
40
+ '("Yes", "No") when the icon is the only thing that says something. It may go straight into a link block: ' +
41
+ 'a link with a text and an arrow icon is a button with an icon.',
42
42
  example: { type: ICON_BLOCK, props: { name: names[0] }, className: 'size-6' },
43
43
  },
44
44
  });
@@ -1,10 +1,12 @@
1
1
  import type { BlockDefinition } from '../../core/types.js';
2
- export declare const BUILTIN_TYPES: readonly ['icon', 'disclosure', 'accordion', 'lightbox', 'carousel', 'tableOfContents', 'filterLink', 'mediaBackdrop', 'sectionRef'];
2
+ import { type EmbedOptions } from './embed.js';
3
+ /** The built-ins you can include. `tabs` brings its child block type, `tab`. */
4
+ export declare const BUILTIN_TYPES: readonly ['icon', 'disclosure', 'accordion', 'popup', 'tabs', 'carousel', 'marquee', 'tableOfContents', 'filterLink', 'adjacentLinks', 'embed'];
3
5
  export type BuiltinType = (typeof BUILTIN_TYPES)[number];
4
6
  export type BuiltinBlocksOptions = {
5
7
  /**
6
- * The built-ins to add. Default: all of them, but `icon` only when `icons` is given and
7
- * `sectionRef` only when listed here (it needs the plugin's saved sections).
8
+ * The built-ins to add. Default: all of them, but `icon` only when `icons` is given and `embed`
9
+ * only when `embed` is given.
8
10
  */
9
11
  include?: readonly BuiltinType[];
10
12
  /**
@@ -12,10 +14,11 @@ export type BuiltinBlocksOptions = {
12
14
  * `builtinComponents({ icons })`. Plain strings, so the Payload config loads no React.
13
15
  */
14
16
  icons?: readonly string[];
15
- /** Upload collection for the mediaBackdrop block. Default "media". */
16
- mediaCollection?: string;
17
- /** The saved sections collection, for the sectionRef block. Default "builder-sections" (`websiteBuilder({ savedSections: { slug } })`). */
18
- sectionsCollection?: string;
17
+ /**
18
+ * Turns on the `embed` block (custom HTML) and sets who may change its code. `{}`: everyone who
19
+ * may edit the document. Custom code runs on the site, so it is never on by default.
20
+ */
21
+ embed?: EmbedOptions;
19
22
  };
20
23
  /**
21
24
  * The opt-in built-in blocks. Add them next to `defaultBlocks()`:
@@ -23,13 +26,15 @@ export type BuiltinBlocksOptions = {
23
26
  * own block of the same type, leave it out of `include`.
24
27
  */
25
28
  export declare function builtinBlocks(options?: BuiltinBlocksOptions): BlockDefinition[];
26
- export { CAROUSEL_BLOCK, CAROUSEL_CLASS_MAP, carouselBlock } from './carousel.js';
29
+ export { ADJACENT_LINKS_BLOCK, ADJACENT_LINKS_LABELS, adjacentLinksBlock } from './adjacentLinks.js';
30
+ export { CAROUSEL_BLOCK, CAROUSEL_CLASS_MAP, CAROUSEL_LABELS, carouselBlock } from './carousel.js';
27
31
  export { ACCORDION_BLOCK, accordionBlock, DISCLOSURE_BLOCK, DISCLOSURE_CLASS_MAP, disclosureBlock } from './disclosure.js';
28
32
  export { FILTER_LINK_BLOCK, filterHref, filterLinkBlock, type FilterLinkTarget, type FilterQuery } from './filterLink.js';
33
+ export { EMBED_BLOCK, EMBED_LABELS, EMBED_MAX_LENGTH, embedBlock, type EmbedOptions } from './embed.js';
29
34
  export { faqItems, faqJsonLd, type FaqItem } from './faq.js';
30
- export { headingId, lexicalHeadings, lexicalText, type RichTextHeading } from './headingId.js';
31
35
  export { ICON_BLOCK, iconBlock } from './icon.js';
32
- export { LIGHTBOX_BLOCK, LIGHTBOX_CLASS_MAP, LIGHTBOX_CLOSE_EVENT, LIGHTBOX_SKIP_ATTRIBUTE, lightboxBlock } from './lightbox.js';
33
- export { MEDIA_BACKDROP_BLOCK, MEDIA_BACKDROP_CLASS_MAP, mediaBackdropBlock } from './mediaBackdrop.js';
34
- export { SECTION_REF_BLOCK, SECTION_REF_SLOT, sectionDetachOps, sectionRefBlock, sectionRefBlocks, sectionRefId } from './sectionRef.js';
35
- export { TABLE_OF_CONTENTS_BLOCK, tableOfContentsBlock } from './tableOfContents.js';
36
+ export { MARQUEE_BLOCK, MARQUEE_CSS, MARQUEE_SECONDS, marqueeBlock } from './marquee.js';
37
+ export { POPUP_BLOCK, POPUP_CLASS_MAP, POPUP_LABELS, popupBlock } from './popup.js';
38
+ export { SECTION_REF_BLOCK, SECTION_REF_MISSING, SECTION_REF_SLOT, SECTION_REF_VALUES, sectionDetachOps, sectionRefBlock, sectionRefBlocks, sectionRefId } from './sectionRef.js';
39
+ export { TABLE_OF_CONTENTS_BLOCK, TABLE_OF_CONTENTS_LABELS, tableOfContentsBlock } from './tableOfContents.js';
40
+ export { TAB_BLOCK, tabBlock, TABS_BLOCK, TABS_CLASS_MAP, TABS_LABELS, tabsBlock } from './tabs.js';
@@ -1,15 +1,31 @@
1
1
  // Opt-in built-in blocks: `builtinBlocks()` from `payload-canvas/blocks`. Client-safe, like the
2
2
  // default blocks: plain data, no React. The components come from `builtinComponents()` in
3
- // `payload-canvas/react`.
3
+ // `payload-canvas/react`. The live saved section block (`sectionRef`) is not one of them: the
4
+ // plugin adds it when saved sections are on.
5
+ import { adjacentLinksBlock } from './adjacentLinks.js';
4
6
  import { carouselBlock } from './carousel.js';
5
7
  import { accordionBlock, disclosureBlock } from './disclosure.js';
8
+ import { embedBlock } from './embed.js';
6
9
  import { filterLinkBlock } from './filterLink.js';
7
10
  import { iconBlock } from './icon.js';
8
- import { lightboxBlock } from './lightbox.js';
9
- import { mediaBackdropBlock } from './mediaBackdrop.js';
10
- import { sectionRefBlock } from './sectionRef.js';
11
+ import { marqueeBlock } from './marquee.js';
12
+ import { popupBlock } from './popup.js';
11
13
  import { tableOfContentsBlock } from './tableOfContents.js';
12
- export const BUILTIN_TYPES = ['icon', 'disclosure', 'accordion', 'lightbox', 'carousel', 'tableOfContents', 'filterLink', 'mediaBackdrop', 'sectionRef'];
14
+ import { tabBlock, tabsBlock } from './tabs.js';
15
+ /** The built-ins you can include. `tabs` brings its child block type, `tab`. */
16
+ export const BUILTIN_TYPES = [
17
+ 'icon',
18
+ 'disclosure',
19
+ 'accordion',
20
+ 'popup',
21
+ 'tabs',
22
+ 'carousel',
23
+ 'marquee',
24
+ 'tableOfContents',
25
+ 'filterLink',
26
+ 'adjacentLinks',
27
+ 'embed',
28
+ ];
13
29
  /**
14
30
  * The opt-in built-in blocks. Add them next to `defaultBlocks()`:
15
31
  * `[...defaultBlocks(), ...builtinBlocks({ include: ['carousel'] })]`. To replace one with your
@@ -17,7 +33,8 @@ export const BUILTIN_TYPES = ['icon', 'disclosure', 'accordion', 'lightbox', 'ca
17
33
  */
18
34
  export function builtinBlocks(options = {}) {
19
35
  const icons = options.icons ?? [];
20
- const include = new Set(options.include ?? BUILTIN_TYPES.filter((type) => type !== 'sectionRef' && (type !== 'icon' || icons.length > 0)));
36
+ const byDefault = (type) => (type !== 'icon' || icons.length > 0) && (type !== 'embed' || options.embed !== undefined);
37
+ const include = new Set(options.include ?? BUILTIN_TYPES.filter(byDefault));
21
38
  for (const type of include) {
22
39
  if (!BUILTIN_TYPES.includes(type))
23
40
  throw new Error(`builtinBlocks: there is no built-in block "${type}".`);
@@ -26,25 +43,29 @@ export function builtinBlocks(options = {}) {
26
43
  throw new Error('builtinBlocks: the "icon" block needs `icons`, the names of your icon set.');
27
44
  }
28
45
  const make = {
29
- icon: () => iconBlock(icons),
30
- disclosure: disclosureBlock,
31
- accordion: accordionBlock,
32
- lightbox: lightboxBlock,
33
- carousel: carouselBlock,
34
- tableOfContents: tableOfContentsBlock,
35
- filterLink: filterLinkBlock,
36
- mediaBackdrop: () => mediaBackdropBlock(options.mediaCollection),
37
- sectionRef: () => sectionRefBlock(options.sectionsCollection),
46
+ icon: () => [iconBlock(icons)],
47
+ disclosure: () => [disclosureBlock()],
48
+ accordion: () => [accordionBlock()],
49
+ popup: () => [popupBlock()],
50
+ tabs: () => [tabsBlock(), tabBlock()],
51
+ carousel: () => [carouselBlock()],
52
+ marquee: () => [marqueeBlock()],
53
+ tableOfContents: () => [tableOfContentsBlock()],
54
+ filterLink: () => [filterLinkBlock()],
55
+ adjacentLinks: () => [adjacentLinksBlock()],
56
+ embed: () => [embedBlock(options.embed)],
38
57
  };
39
- return BUILTIN_TYPES.filter((type) => include.has(type)).map((type) => make[type]());
58
+ return BUILTIN_TYPES.filter((type) => include.has(type)).flatMap((type) => make[type]());
40
59
  }
41
- export { CAROUSEL_BLOCK, CAROUSEL_CLASS_MAP, carouselBlock } from './carousel.js';
60
+ export { ADJACENT_LINKS_BLOCK, ADJACENT_LINKS_LABELS, adjacentLinksBlock } from './adjacentLinks.js';
61
+ export { CAROUSEL_BLOCK, CAROUSEL_CLASS_MAP, CAROUSEL_LABELS, carouselBlock } from './carousel.js';
42
62
  export { ACCORDION_BLOCK, accordionBlock, DISCLOSURE_BLOCK, DISCLOSURE_CLASS_MAP, disclosureBlock } from './disclosure.js';
43
63
  export { FILTER_LINK_BLOCK, filterHref, filterLinkBlock } from './filterLink.js';
64
+ export { EMBED_BLOCK, EMBED_LABELS, EMBED_MAX_LENGTH, embedBlock } from './embed.js';
44
65
  export { faqItems, faqJsonLd } from './faq.js';
45
- export { headingId, lexicalHeadings, lexicalText } from './headingId.js';
46
66
  export { ICON_BLOCK, iconBlock } from './icon.js';
47
- export { LIGHTBOX_BLOCK, LIGHTBOX_CLASS_MAP, LIGHTBOX_CLOSE_EVENT, LIGHTBOX_SKIP_ATTRIBUTE, lightboxBlock } from './lightbox.js';
48
- export { MEDIA_BACKDROP_BLOCK, MEDIA_BACKDROP_CLASS_MAP, mediaBackdropBlock } from './mediaBackdrop.js';
49
- export { SECTION_REF_BLOCK, SECTION_REF_SLOT, sectionDetachOps, sectionRefBlock, sectionRefBlocks, sectionRefId } from './sectionRef.js';
50
- export { TABLE_OF_CONTENTS_BLOCK, tableOfContentsBlock } from './tableOfContents.js';
67
+ export { MARQUEE_BLOCK, MARQUEE_CSS, MARQUEE_SECONDS, marqueeBlock } from './marquee.js';
68
+ export { POPUP_BLOCK, POPUP_CLASS_MAP, POPUP_LABELS, popupBlock } from './popup.js';
69
+ export { SECTION_REF_BLOCK, SECTION_REF_MISSING, SECTION_REF_SLOT, SECTION_REF_VALUES, sectionDetachOps, sectionRefBlock, sectionRefBlocks, sectionRefId } from './sectionRef.js';
70
+ export { TABLE_OF_CONTENTS_BLOCK, TABLE_OF_CONTENTS_LABELS, tableOfContentsBlock } from './tableOfContents.js';
71
+ export { TAB_BLOCK, tabBlock, TABS_BLOCK, TABS_CLASS_MAP, TABS_LABELS, tabsBlock } from './tabs.js';
@@ -0,0 +1,5 @@
1
+ import type { BlockDefinition } from '../../core/types.js';
2
+ import { MARQUEE_CSS, MARQUEE_SECONDS } from '../client/marquee.js';
3
+ export { MARQUEE_CSS, MARQUEE_SECONDS };
4
+ export declare const MARQUEE_BLOCK = "marquee";
5
+ export declare function marqueeBlock(): BlockDefinition;
@@ -0,0 +1,68 @@
1
+ import { defineBlock } from '../../core/blocks.js';
2
+ import { MARQUEE_CSS, MARQUEE_SECONDS } from '../client/marquee.js';
3
+ export { MARQUEE_CSS, MARQUEE_SECONDS };
4
+ export const MARQUEE_BLOCK = 'marquee';
5
+ /** The edges fade out. A mask, not a colour, so it works on any background. */
6
+ const MARQUEE_CLASS = '[mask-image:linear-gradient(to_right,transparent,black_10%,black_90%,transparent)]';
7
+ /** The items' row. Margins (not a gap) space the items, so the loop has no jump between rounds. */
8
+ const ITEMS_CLASS = 'flex items-center *:mx-8';
9
+ export function marqueeBlock() {
10
+ return defineBlock({
11
+ type: MARQUEE_BLOCK,
12
+ label: 'Marquee',
13
+ description: 'A row of logos or words that scrolls without end.',
14
+ icon: 'marquee',
15
+ category: 'Media',
16
+ fields: [
17
+ {
18
+ name: 'speed',
19
+ type: 'select',
20
+ label: 'Speed',
21
+ defaultValue: 'normal',
22
+ options: [
23
+ { label: 'Slow', value: 'slow' },
24
+ { label: 'Normal', value: 'normal' },
25
+ { label: 'Fast', value: 'fast' },
26
+ ],
27
+ },
28
+ {
29
+ name: 'direction',
30
+ type: 'select',
31
+ label: 'Direction',
32
+ defaultValue: 'left',
33
+ options: [
34
+ { label: 'To the left', value: 'left' },
35
+ { label: 'To the right', value: 'right' },
36
+ ],
37
+ },
38
+ { name: 'pauseOnHover', type: 'checkbox', label: 'Stop under the pointer', defaultValue: true },
39
+ ],
40
+ slots: { children: { label: 'Items', styles: true, defaultClassName: ITEMS_CLASS } },
41
+ defaultClassName: MARQUEE_CLASS,
42
+ ai: {
43
+ description: 'A row of items (logos, words, short quotes) that scrolls sideways without end, in CSS only. Each direct child of ' +
44
+ 'the "children" slot is one item; give images a fixed height ("h-8 w-auto"). A repeat or collection list child is ' +
45
+ 'one item: lay out its items with "flex items-center gap-16" (twice the "*:mx-8" margin, so the spacing stays even). ' +
46
+ `"speed": "slow", "normal" or "fast" (${MARQUEE_SECONDS.slow}, ${MARQUEE_SECONDS.normal} or ` +
47
+ `${MARQUEE_SECONDS.fast} seconds per round), "direction": "left" or "right", "pauseOnHover" (default on; it also ` +
48
+ 'stops while a link in it has focus). The items show twice on the site (the copy is hidden from screen readers), ' +
49
+ 'so the row loops without a gap. Space the items with margins in the "children" part ("*:mx-8"), not a gap, so ' +
50
+ 'the loop does not jump. Keep the row wider than the screen: repeat a short list of items. When the visitor asks ' +
51
+ 'for less motion, and on the canvas, it stands still and the items wrap. The default className fades the edges ' +
52
+ 'with a mask.',
53
+ example: {
54
+ type: MARQUEE_BLOCK,
55
+ props: { speed: 'normal', direction: 'left', pauseOnHover: true },
56
+ className: MARQUEE_CLASS,
57
+ partClassName: { children: ITEMS_CLASS },
58
+ slots: {
59
+ children: [
60
+ { id: 'b_example_1', type: 'image', props: { image: 1, alt: 'Acme' }, className: 'h-8 w-auto' },
61
+ { id: 'b_example_2', type: 'image', props: { image: 2, alt: 'Globex' }, className: 'h-8 w-auto' },
62
+ { id: 'b_example_3', type: 'image', props: { image: 3, alt: 'Initech' }, className: 'h-8 w-auto' },
63
+ ],
64
+ },
65
+ },
66
+ },
67
+ });
68
+ }
@@ -0,0 +1,5 @@
1
+ import type { BlockDefinition } from '../../core/types.js';
2
+ import { POPUP_CLASS_MAP, POPUP_LABELS } from '../client/popup.js';
3
+ export { POPUP_CLASS_MAP, POPUP_LABELS };
4
+ export declare const POPUP_BLOCK = "popup";
5
+ export declare function popupBlock(): BlockDefinition;