payload-canvas 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (468) hide show
  1. package/README.md +626 -154
  2. package/dist/admin/AiKeyField.d.ts +8 -0
  3. package/dist/admin/AiKeyField.js +54 -0
  4. package/dist/admin/BuilderTab.js +4 -1
  5. package/dist/admin/DocumentEditView.d.ts +9 -0
  6. package/dist/admin/DocumentEditView.js +45 -0
  7. package/dist/admin/LayoutField.d.ts +2 -2
  8. package/dist/admin/LayoutField.js +10 -7
  9. package/dist/admin/TemplateConditionsField.d.ts +9 -0
  10. package/dist/admin/TemplateConditionsField.js +22 -0
  11. package/dist/admin/aiKeyField.scss +58 -0
  12. package/dist/admin/client.d.ts +3 -0
  13. package/dist/admin/client.js +6 -0
  14. package/dist/admin/diff/changes.js +5 -0
  15. package/dist/admin/editor/Canvas.js +20 -5
  16. package/dist/admin/editor/Editor.d.ts +3 -1
  17. package/dist/admin/editor/Editor.js +6 -3
  18. package/dist/admin/editor/Inspector.js +75 -28
  19. package/dist/admin/editor/Library.js +40 -15
  20. package/dist/admin/editor/Outline.js +21 -16
  21. package/dist/admin/editor/Overlay.js +8 -3
  22. package/dist/admin/editor/actions.d.ts +10 -2
  23. package/dist/admin/editor/actions.js +18 -3
  24. package/dist/admin/editor/assistant/AssistantPanel.js +3 -1
  25. package/dist/admin/editor/classes/ClassManager.d.ts +4 -0
  26. package/dist/admin/editor/classes/ClassManager.js +56 -0
  27. package/dist/admin/editor/classes/controller.d.ts +112 -0
  28. package/dist/admin/editor/classes/controller.js +326 -0
  29. package/dist/admin/editor/classes/manager.scss +262 -0
  30. package/dist/admin/editor/classes/managerModel.d.ts +5 -0
  31. package/dist/admin/editor/classes/managerModel.js +27 -0
  32. package/dist/admin/editor/comments/CommentLayer.d.ts +2 -0
  33. package/dist/admin/editor/comments/CommentLayer.js +143 -0
  34. package/dist/admin/editor/comments/CommentsPanel.d.ts +8 -0
  35. package/dist/admin/editor/comments/CommentsPanel.js +73 -0
  36. package/dist/admin/editor/comments/Thread.d.ts +26 -0
  37. package/dist/admin/editor/comments/Thread.js +84 -0
  38. package/dist/admin/editor/comments/comments.scss +539 -0
  39. package/dist/admin/editor/comments/controller.d.ts +48 -0
  40. package/dist/admin/editor/comments/controller.js +142 -0
  41. package/dist/admin/editor/contentMode.d.ts +17 -0
  42. package/dist/admin/editor/contentMode.js +37 -0
  43. package/dist/admin/editor/dnd/DropOutlines.d.ts +1 -0
  44. package/dist/admin/editor/dnd/DropOutlines.js +73 -0
  45. package/dist/admin/editor/dnd/dnd.scss +43 -0
  46. package/dist/admin/editor/dnd/mode.d.ts +4 -0
  47. package/dist/admin/editor/dnd/mode.js +39 -0
  48. package/dist/admin/editor/editor.scss +13 -58
  49. package/dist/admin/editor/empty/EmptyStart.js +18 -66
  50. package/dist/admin/editor/fields/AddButton.d.ts +15 -0
  51. package/dist/admin/editor/fields/AddButton.js +14 -0
  52. package/dist/admin/editor/fields/ArrayField.js +3 -2
  53. package/dist/admin/editor/fields/CheckedInputs.d.ts +1 -0
  54. package/dist/admin/editor/fields/ConditionRows.d.ts +19 -0
  55. package/dist/admin/editor/fields/ConditionRows.js +137 -0
  56. package/dist/admin/editor/fields/ListWhereField.d.ts +8 -0
  57. package/dist/admin/editor/fields/ListWhereField.js +20 -0
  58. package/dist/admin/editor/fields/QueryFiltersField.d.ts +18 -0
  59. package/dist/admin/editor/fields/QueryFiltersField.js +41 -0
  60. package/dist/admin/editor/fields/RelatedField.d.ts +19 -0
  61. package/dist/admin/editor/fields/RelatedField.js +44 -0
  62. package/dist/admin/editor/fields/SortField.d.ts +13 -0
  63. package/dist/admin/editor/fields/SortField.js +37 -0
  64. package/dist/admin/editor/fields/WhereField.d.ts +12 -4
  65. package/dist/admin/editor/fields/WhereField.js +33 -53
  66. package/dist/admin/editor/fields/collectionFields.d.ts +6 -0
  67. package/dist/admin/editor/fields/collectionFields.js +15 -0
  68. package/dist/admin/editor/fields/conditions.d.ts +99 -0
  69. package/dist/admin/editor/fields/conditions.js +339 -0
  70. package/dist/admin/editor/fields/fields.scss +232 -9
  71. package/dist/admin/editor/fields/listOptions.d.ts +44 -0
  72. package/dist/admin/editor/fields/listOptions.js +111 -0
  73. package/dist/admin/editor/fields/queryFilterRows.d.ts +8 -0
  74. package/dist/admin/editor/fields/queryFilterRows.js +29 -0
  75. package/dist/admin/editor/fields/whereRows.d.ts +11 -12
  76. package/dist/admin/editor/fields/whereRows.js +83 -34
  77. package/dist/admin/editor/icons.d.ts +16 -1
  78. package/dist/admin/editor/icons.js +30 -1
  79. package/dist/admin/editor/inline.js +9 -0
  80. package/dist/admin/editor/insert/InsertHandle.js +4 -1
  81. package/dist/admin/editor/insert/picker.d.ts +3 -1
  82. package/dist/admin/editor/insert/picker.js +17 -10
  83. package/dist/admin/editor/insert/spots.d.ts +12 -1
  84. package/dist/admin/editor/insert/spots.js +49 -10
  85. package/dist/admin/editor/layout/LeftPanel.js +11 -6
  86. package/dist/admin/editor/live/useMultiplayer.js +9 -1
  87. package/dist/admin/editor/menu/blockMenu.js +27 -17
  88. package/dist/admin/editor/names.js +11 -3
  89. package/dist/admin/editor/renderField.d.ts +3 -1
  90. package/dist/admin/editor/renderField.js +63 -12
  91. package/dist/admin/editor/runtime.d.ts +14 -0
  92. package/dist/admin/editor/runtime.js +67 -6
  93. package/dist/admin/editor/sections/ComponentFields.d.ts +8 -0
  94. package/dist/admin/editor/sections/ComponentFields.js +116 -0
  95. package/dist/admin/editor/sections/PropertyControls.d.ts +18 -0
  96. package/dist/admin/editor/sections/PropertyControls.js +65 -0
  97. package/dist/admin/editor/sections/components.d.ts +29 -0
  98. package/dist/admin/editor/sections/components.js +112 -0
  99. package/dist/admin/editor/sections/components.scss +238 -0
  100. package/dist/admin/editor/sections/variants.d.ts +32 -0
  101. package/dist/admin/editor/sections/variants.js +59 -0
  102. package/dist/admin/editor/sections/variants.scss +90 -0
  103. package/dist/admin/editor/shortcuts.d.ts +4 -1
  104. package/dist/admin/editor/shortcuts.js +19 -3
  105. package/dist/admin/editor/store.d.ts +18 -0
  106. package/dist/admin/editor/store.js +46 -0
  107. package/dist/admin/editor/styles/ClassBar.d.ts +14 -0
  108. package/dist/admin/editor/styles/ClassBar.js +90 -0
  109. package/dist/admin/editor/styles/ClassCss.d.ts +4 -0
  110. package/dist/admin/editor/styles/ClassCss.js +28 -0
  111. package/dist/admin/editor/styles/ClassDialog.d.ts +2 -0
  112. package/dist/admin/editor/styles/ClassDialog.js +151 -0
  113. package/dist/admin/editor/styles/ColorPicker.js +5 -2
  114. package/dist/admin/editor/styles/RawClasses.d.ts +26 -1
  115. package/dist/admin/editor/styles/RawClasses.js +184 -32
  116. package/dist/admin/editor/styles/StylesPanel.d.ts +3 -3
  117. package/dist/admin/editor/styles/StylesPanel.js +53 -14
  118. package/dist/admin/editor/styles/VariantBar.js +2 -2
  119. package/dist/admin/editor/styles/classEdit.d.ts +4 -0
  120. package/dist/admin/editor/styles/classEdit.js +20 -0
  121. package/dist/admin/editor/styles/classes.scss +381 -0
  122. package/dist/admin/editor/styles/context.d.ts +19 -6
  123. package/dist/admin/editor/styles/context.js +24 -6
  124. package/dist/admin/editor/styles/controls.d.ts +3 -1
  125. package/dist/admin/editor/styles/controls.js +30 -12
  126. package/dist/admin/editor/styles/popover.d.ts +6 -0
  127. package/dist/admin/editor/styles/popover.js +5 -5
  128. package/dist/admin/editor/styles/styles.scss +26 -104
  129. package/dist/admin/editor/styles/suggestions.d.ts +22 -0
  130. package/dist/admin/editor/styles/suggestions.js +77 -0
  131. package/dist/admin/editor/styles/tokens.js +14 -0
  132. package/dist/admin/editor/templates/Bindable.js +86 -57
  133. package/dist/admin/editor/templates/SamplePicker.js +1 -1
  134. package/dist/admin/editor/templates/Visibility.d.ts +9 -0
  135. package/dist/admin/editor/templates/Visibility.js +54 -0
  136. package/dist/admin/editor/templates/binding.d.ts +2 -2
  137. package/dist/admin/editor/templates/binding.js +2 -2
  138. package/dist/admin/editor/templates/templates.scss +27 -0
  139. package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
  140. package/dist/admin/editor/templates/visibilityRows.js +83 -0
  141. package/dist/admin/editor/topbar/ContentModeToggle.d.ts +5 -0
  142. package/dist/admin/editor/topbar/ContentModeToggle.js +26 -0
  143. package/dist/admin/editor/topbar/DocumentActions.d.ts +1 -1
  144. package/dist/admin/editor/topbar/DocumentActions.js +5 -4
  145. package/dist/admin/editor/topbar/DocumentTitle.js +7 -2
  146. package/dist/admin/editor/topbar/TopBar.js +15 -3
  147. package/dist/admin/editor/topbar/contentMode.scss +35 -0
  148. package/dist/admin/editor/topbar/topbar.scss +3 -1
  149. package/dist/admin/formChoice.d.ts +3 -0
  150. package/dist/admin/formChoice.js +10 -0
  151. package/dist/admin/layoutField.scss +69 -0
  152. package/dist/admin/screen/BuilderScreen.d.ts +6 -1
  153. package/dist/admin/screen/BuilderScreen.js +4 -3
  154. package/dist/admin/server/BuilderView.js +10 -3
  155. package/dist/admin/templateConditions.scss +24 -0
  156. package/dist/ai/adapters/anthropic.js +17 -4
  157. package/dist/ai/adapters/cloudflare-gateway.js +7 -1
  158. package/dist/ai/adapters/cloudflare-workers-ai.js +2 -0
  159. package/dist/ai/adapters/openai-compatible.js +1 -0
  160. package/dist/ai/adapters/openrouter.js +2 -0
  161. package/dist/ai/config.d.ts +24 -4
  162. package/dist/ai/config.js +27 -8
  163. package/dist/ai/endpoint.d.ts +5 -2
  164. package/dist/ai/endpoint.js +31 -26
  165. package/dist/ai/images/cloudflare-workers-ai.js +6 -2
  166. package/dist/ai/images/openai.js +8 -3
  167. package/dist/ai/images/openrouter.js +6 -2
  168. package/dist/ai/images/service.d.ts +10 -4
  169. package/dist/ai/images/service.js +23 -7
  170. package/dist/ai/openai-format.d.ts +7 -0
  171. package/dist/ai/openai-format.js +17 -5
  172. package/dist/ai/prompt.d.ts +8 -0
  173. package/dist/ai/prompt.js +25 -5
  174. package/dist/ai/settings/index.d.ts +62 -0
  175. package/dist/ai/settings/index.js +264 -0
  176. package/dist/ai/settings/secret.d.ts +11 -0
  177. package/dist/ai/settings/secret.js +46 -0
  178. package/dist/ai/settings/shared.d.ts +22 -0
  179. package/dist/ai/settings/shared.js +3 -0
  180. package/dist/ai/tools.d.ts +3 -0
  181. package/dist/ai/tools.js +79 -15
  182. package/dist/ai/types.d.ts +43 -0
  183. package/dist/blocks/builtins/adjacentLinks.d.ts +5 -0
  184. package/dist/blocks/builtins/adjacentLinks.js +76 -0
  185. package/dist/blocks/builtins/carousel.d.ts +2 -29
  186. package/dist/blocks/builtins/carousel.js +44 -51
  187. package/dist/blocks/builtins/disclosure.d.ts +2 -1
  188. package/dist/blocks/builtins/disclosure.js +22 -32
  189. package/dist/blocks/builtins/embed.d.ts +15 -0
  190. package/dist/blocks/builtins/embed.js +47 -0
  191. package/dist/blocks/builtins/faq.d.ts +1 -1
  192. package/dist/blocks/builtins/faq.js +2 -2
  193. package/dist/blocks/builtins/filterLink.d.ts +1 -19
  194. package/dist/blocks/builtins/filterLink.js +9 -50
  195. package/dist/blocks/builtins/icon.d.ts +2 -0
  196. package/dist/blocks/builtins/icon.js +8 -8
  197. package/dist/blocks/builtins/index.d.ts +18 -13
  198. package/dist/blocks/builtins/index.js +43 -22
  199. package/dist/blocks/builtins/marquee.d.ts +5 -0
  200. package/dist/blocks/builtins/marquee.js +68 -0
  201. package/dist/blocks/builtins/popup.d.ts +5 -0
  202. package/dist/blocks/builtins/popup.js +83 -0
  203. package/dist/blocks/builtins/sectionRef.d.ts +16 -2
  204. package/dist/blocks/builtins/sectionRef.js +34 -12
  205. package/dist/blocks/builtins/shared.d.ts +18 -23
  206. package/dist/blocks/builtins/shared.js +34 -42
  207. package/dist/blocks/builtins/tableOfContents.d.ts +4 -0
  208. package/dist/blocks/builtins/tableOfContents.js +12 -18
  209. package/dist/blocks/builtins/tabs.d.ts +6 -0
  210. package/dist/blocks/builtins/tabs.js +87 -0
  211. package/dist/blocks/client/adjacentLinks.d.ts +4 -0
  212. package/dist/blocks/client/adjacentLinks.js +4 -0
  213. package/dist/blocks/client/carousel.d.ts +45 -0
  214. package/dist/blocks/client/carousel.js +53 -0
  215. package/dist/blocks/client/embed.d.ts +21 -0
  216. package/dist/blocks/client/embed.js +23 -0
  217. package/dist/blocks/client/field.d.ts +7 -0
  218. package/dist/blocks/client/field.js +8 -0
  219. package/dist/blocks/client/filterLink.d.ts +19 -0
  220. package/dist/blocks/client/filterLink.js +30 -0
  221. package/dist/blocks/client/helpers.d.ts +21 -0
  222. package/dist/blocks/client/helpers.js +24 -0
  223. package/dist/blocks/client/marquee.d.ts +14 -0
  224. package/dist/blocks/client/marquee.js +25 -0
  225. package/dist/blocks/client/menu.d.ts +46 -0
  226. package/dist/blocks/client/menu.js +49 -0
  227. package/dist/blocks/client/popup.d.ts +15 -0
  228. package/dist/blocks/client/popup.js +16 -0
  229. package/dist/blocks/client/tabs.d.ts +10 -0
  230. package/dist/blocks/client/tabs.js +11 -0
  231. package/dist/blocks/defaults.d.ts +15 -52
  232. package/dist/blocks/defaults.js +203 -437
  233. package/dist/blocks/index.d.ts +1 -1
  234. package/dist/blocks/index.js +2 -1
  235. package/dist/classes/actions.d.ts +97 -0
  236. package/dist/classes/actions.js +296 -0
  237. package/dist/classes/collection.d.ts +5 -0
  238. package/dist/classes/collection.js +189 -0
  239. package/dist/classes/config.d.ts +34 -0
  240. package/dist/classes/config.js +8 -0
  241. package/dist/classes/endpoints.d.ts +2 -0
  242. package/dist/classes/endpoints.js +120 -0
  243. package/dist/classes/index.d.ts +36 -0
  244. package/dist/classes/index.js +42 -0
  245. package/dist/classes/mcp.d.ts +6 -0
  246. package/dist/classes/mcp.js +161 -0
  247. package/dist/classes/shared.d.ts +131 -0
  248. package/dist/classes/shared.js +300 -0
  249. package/dist/classes/sheet.d.ts +34 -0
  250. package/dist/classes/sheet.js +126 -0
  251. package/dist/classes/usage.d.ts +57 -0
  252. package/dist/classes/usage.js +208 -0
  253. package/dist/comments/collection.d.ts +38 -0
  254. package/dist/comments/collection.js +226 -0
  255. package/dist/comments/config.d.ts +15 -0
  256. package/dist/comments/config.js +2 -0
  257. package/dist/comments/index.d.ts +20 -0
  258. package/dist/comments/index.js +22 -0
  259. package/dist/comments/shared.d.ts +54 -0
  260. package/dist/comments/shared.js +104 -0
  261. package/dist/core/bindings.d.ts +77 -32
  262. package/dist/core/bindings.js +319 -134
  263. package/dist/core/blockNames.d.ts +9 -0
  264. package/dist/core/blockNames.js +11 -0
  265. package/dist/core/blocks.d.ts +21 -8
  266. package/dist/core/blocks.js +37 -16
  267. package/dist/core/classes.d.ts +16 -8
  268. package/dist/core/classes.js +31 -27
  269. package/dist/core/components.d.ts +72 -0
  270. package/dist/core/components.js +294 -0
  271. package/dist/core/contentMode.d.ts +27 -0
  272. package/dist/core/contentMode.js +0 -0
  273. package/dist/core/dropTarget.d.ts +11 -0
  274. package/dist/core/dropTarget.js +24 -1
  275. package/dist/core/fields.d.ts +5 -0
  276. package/dist/core/fields.js +11 -0
  277. package/dist/core/headings.d.ts +5 -2
  278. package/dist/core/headings.js +14 -6
  279. package/dist/core/index.d.ts +8 -3
  280. package/dist/core/index.js +8 -3
  281. package/dist/core/layers.d.ts +9 -0
  282. package/dist/core/layers.js +29 -0
  283. package/dist/core/operations.d.ts +6 -0
  284. package/dist/core/operations.js +85 -24
  285. package/dist/core/payloadBlocks.js +5 -1
  286. package/dist/core/references.js +28 -0
  287. package/dist/core/schema.js +20 -6
  288. package/dist/core/sectionOrigin.d.ts +6 -0
  289. package/dist/core/sectionOrigin.js +21 -0
  290. package/dist/core/sections.d.ts +72 -0
  291. package/dist/core/sections.js +331 -0
  292. package/dist/core/templateChoice.d.ts +24 -0
  293. package/dist/core/templateChoice.js +43 -0
  294. package/dist/core/tree.js +18 -6
  295. package/dist/core/types.d.ts +148 -18
  296. package/dist/core/validate.d.ts +4 -1
  297. package/dist/core/validate.js +28 -11
  298. package/dist/core/visibility.d.ts +63 -0
  299. package/dist/core/visibility.js +214 -0
  300. package/dist/core/whereValues.d.ts +22 -0
  301. package/dist/core/whereValues.js +43 -0
  302. package/dist/css/classes.d.ts +16 -0
  303. package/dist/css/classes.js +172 -0
  304. package/dist/css/index.d.ts +32 -1
  305. package/dist/css/index.js +64 -5
  306. package/dist/css/tokens.d.ts +10 -0
  307. package/dist/css/tokens.js +23 -10
  308. package/dist/index.d.ts +5 -2
  309. package/dist/index.js +6 -1
  310. package/dist/live/contentMode.d.ts +24 -0
  311. package/dist/live/contentMode.js +39 -0
  312. package/dist/live/endpoints.js +3 -0
  313. package/dist/live/session.d.ts +5 -0
  314. package/dist/live/session.js +8 -0
  315. package/dist/live/types.d.ts +16 -1
  316. package/dist/mcp/index.d.ts +10 -1
  317. package/dist/mcp/index.js +146 -54
  318. package/dist/mcp/shared.d.ts +93 -3
  319. package/dist/mcp/shared.js +211 -15
  320. package/dist/plugin/hook.d.ts +7 -1
  321. package/dist/plugin/hook.js +30 -4
  322. package/dist/plugin/index.d.ts +19 -8
  323. package/dist/plugin/index.js +89 -20
  324. package/dist/plugin/links.d.ts +24 -0
  325. package/dist/plugin/links.js +27 -0
  326. package/dist/plugin/listCollections.d.ts +9 -7
  327. package/dist/plugin/listCollections.js +30 -21
  328. package/dist/plugin/sections.d.ts +14 -7
  329. package/dist/plugin/sections.js +69 -23
  330. package/dist/plugin/sectionsUsedIn.d.ts +6 -0
  331. package/dist/plugin/sectionsUsedIn.js +24 -0
  332. package/dist/plugin/templateEndpoint.d.ts +9 -0
  333. package/dist/plugin/templateEndpoint.js +49 -0
  334. package/dist/plugin/templates.js +23 -8
  335. package/dist/protocol/index.d.ts +16 -1
  336. package/dist/react/canvas/BuilderCanvas.js +144 -21
  337. package/dist/react/canvas/classes.d.ts +17 -0
  338. package/dist/react/canvas/classes.js +102 -0
  339. package/dist/react/canvas/controls.d.ts +31 -0
  340. package/dist/react/canvas/controls.js +75 -0
  341. package/dist/react/canvas/fetchDocs.d.ts +2 -2
  342. package/dist/react/canvas/fetchDocs.js +16 -8
  343. package/dist/react/canvas/measure.d.ts +9 -0
  344. package/dist/react/canvas/measure.js +106 -7
  345. package/dist/react/canvas/resolveLayout.d.ts +1 -1
  346. package/dist/react/canvas/resolveLayout.js +4 -3
  347. package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +17 -4
  348. package/dist/react/classes/ClassesStyle.d.ts +27 -0
  349. package/dist/react/classes/ClassesStyle.js +27 -0
  350. package/dist/react/components/Button.d.ts +2 -11
  351. package/dist/react/components/Button.js +8 -43
  352. package/dist/react/components/CollectionList.d.ts +4 -1
  353. package/dist/react/components/CollectionList.js +10 -3
  354. package/dist/react/components/Container.d.ts +5 -2
  355. package/dist/react/components/Container.js +7 -4
  356. package/dist/react/components/Field.js +3 -14
  357. package/dist/react/components/Link.d.ts +1 -1
  358. package/dist/react/components/Link.js +5 -3
  359. package/dist/react/components/List.d.ts +1 -1
  360. package/dist/react/components/List.js +2 -2
  361. package/dist/react/components/Menu.d.ts +10 -1
  362. package/dist/react/components/Menu.js +39 -12
  363. package/dist/react/components/RichText.d.ts +3 -4
  364. package/dist/react/components/RichText.js +5 -5
  365. package/dist/react/components/builtins/Accordion.d.ts +4 -3
  366. package/dist/react/components/builtins/Accordion.js +6 -5
  367. package/dist/react/components/builtins/AdjacentLinks.d.ts +11 -0
  368. package/dist/react/components/builtins/AdjacentLinks.js +20 -0
  369. package/dist/react/components/builtins/Carousel.d.ts +21 -10
  370. package/dist/react/components/builtins/Carousel.js +175 -100
  371. package/dist/react/components/builtins/Disclosure.d.ts +4 -3
  372. package/dist/react/components/builtins/Disclosure.js +6 -5
  373. package/dist/react/components/builtins/Embed.d.ts +11 -0
  374. package/dist/react/components/builtins/Embed.js +23 -0
  375. package/dist/react/components/builtins/EmbedHtml.d.ts +15 -0
  376. package/dist/react/components/builtins/EmbedHtml.js +51 -0
  377. package/dist/react/components/builtins/EmbedPreview.d.ts +34 -0
  378. package/dist/react/components/builtins/EmbedPreview.js +105 -0
  379. package/dist/react/components/builtins/FilterLink.d.ts +1 -1
  380. package/dist/react/components/builtins/FilterLink.js +4 -4
  381. package/dist/react/components/builtins/Marquee.d.ts +8 -0
  382. package/dist/react/components/builtins/Marquee.js +15 -0
  383. package/dist/react/components/builtins/Popup.d.ts +26 -0
  384. package/dist/react/components/builtins/Popup.js +146 -0
  385. package/dist/react/components/builtins/SectionRef.d.ts +4 -3
  386. package/dist/react/components/builtins/SectionRef.js +9 -5
  387. package/dist/react/components/builtins/Tab.d.ts +7 -0
  388. package/dist/react/components/builtins/Tab.js +21 -0
  389. package/dist/react/components/builtins/TableOfContents.d.ts +17 -3
  390. package/dist/react/components/builtins/TableOfContents.js +22 -7
  391. package/dist/react/components/builtins/Tabs.d.ts +17 -0
  392. package/dist/react/components/builtins/Tabs.js +71 -0
  393. package/dist/react/components/builtins/index.d.ts +37 -20
  394. package/dist/react/components/builtins/index.js +54 -20
  395. package/dist/react/components/builtins/tabsContext.d.ts +12 -0
  396. package/dist/react/components/builtins/tabsContext.js +6 -0
  397. package/dist/react/components/index.js +11 -8
  398. package/dist/react/components/lazy.d.ts +32 -0
  399. package/dist/react/components/lazy.js +20 -0
  400. package/dist/react/components/lazyBlock.d.ts +17 -0
  401. package/dist/react/components/lazyBlock.js +23 -0
  402. package/dist/react/index.d.ts +6 -3
  403. package/dist/react/index.js +5 -2
  404. package/dist/react/render/RenderLayout.d.ts +9 -7
  405. package/dist/react/render/RenderLayout.js +96 -45
  406. package/dist/react/render/canvasMode.d.ts +13 -0
  407. package/dist/react/render/canvasMode.js +13 -0
  408. package/dist/react/render/canvasServer.js +4 -3
  409. package/dist/react/render/canvasServerTypes.d.ts +5 -0
  410. package/dist/react/render/lists.d.ts +36 -4
  411. package/dist/react/render/lists.js +132 -15
  412. package/dist/react/render/marks.d.ts +15 -0
  413. package/dist/react/render/marks.js +23 -0
  414. package/dist/react/render/payload.d.ts +8 -1
  415. package/dist/react/render/payload.js +12 -3
  416. package/dist/react/render/preview.d.ts +11 -0
  417. package/dist/react/render/preview.js +13 -0
  418. package/dist/react/render/relations.d.ts +10 -0
  419. package/dist/react/render/relations.js +39 -0
  420. package/dist/react/render/resolve.d.ts +8 -4
  421. package/dist/react/render/resolve.js +11 -5
  422. package/dist/react/render/reveal.d.ts +17 -0
  423. package/dist/react/render/reveal.js +39 -0
  424. package/dist/react/render/sections.d.ts +11 -5
  425. package/dist/react/render/sections.js +52 -24
  426. package/dist/react/render/templates.d.ts +47 -0
  427. package/dist/react/render/templates.js +139 -0
  428. package/dist/react/render/types.d.ts +62 -5
  429. package/dist/react/server.d.ts +2 -37
  430. package/dist/react/server.js +8 -133
  431. package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
  432. package/dist/react/theme/ThemeLiveLoader.js +5 -0
  433. package/dist/react/theme/ThemeStyle.js +1 -1
  434. package/dist/theme/admin/Variables.d.ts +11 -0
  435. package/dist/theme/admin/Variables.js +115 -0
  436. package/dist/theme/admin/fields.scss +113 -0
  437. package/dist/theme/client.d.ts +1 -0
  438. package/dist/theme/client.js +2 -0
  439. package/dist/theme/css.d.ts +6 -1
  440. package/dist/theme/css.js +12 -4
  441. package/dist/theme/global.js +83 -0
  442. package/dist/theme/index.d.ts +1 -0
  443. package/dist/theme/index.js +1 -0
  444. package/dist/theme/server.d.ts +15 -0
  445. package/dist/theme/server.js +43 -0
  446. package/dist/theme/usage.d.ts +23 -0
  447. package/dist/theme/usage.js +68 -0
  448. package/dist/theme/variables.d.ts +72 -0
  449. package/dist/theme/variables.js +231 -0
  450. package/package.json +4 -2
  451. package/dist/admin/editor/styles/SiteClasses.d.ts +0 -9
  452. package/dist/admin/editor/styles/SiteClasses.js +0 -31
  453. package/dist/blocks/builtins/headingId.d.ts +0 -15
  454. package/dist/blocks/builtins/headingId.js +0 -36
  455. package/dist/blocks/builtins/lightbox.d.ts +0 -43
  456. package/dist/blocks/builtins/lightbox.js +0 -93
  457. package/dist/blocks/builtins/mediaBackdrop.d.ts +0 -11
  458. package/dist/blocks/builtins/mediaBackdrop.js +0 -79
  459. package/dist/react/components/Quote.d.ts +0 -3
  460. package/dist/react/components/Quote.js +0 -12
  461. package/dist/react/components/Spacer.d.ts +0 -3
  462. package/dist/react/components/Spacer.js +0 -6
  463. package/dist/react/components/builtins/BackdropVideo.d.ts +0 -13
  464. package/dist/react/components/builtins/BackdropVideo.js +0 -16
  465. package/dist/react/components/builtins/Lightbox.d.ts +0 -45
  466. package/dist/react/components/builtins/Lightbox.js +0 -252
  467. package/dist/react/components/builtins/MediaBackdrop.d.ts +0 -14
  468. package/dist/react/components/builtins/MediaBackdrop.js +0 -61
@@ -1,53 +1,18 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createElement } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
3
2
  import { editableText } from '../render/editable.js';
4
3
  import { linkAttributes } from '../render/link.js';
5
4
  import { asText, PlaceholderText } from './placeholder.js';
6
- /** An `<a>` when the link resolves to an href, otherwise a `<span>`. Icon props are ignored. */
7
- export function Button(props) {
8
- return renderButton(props);
9
- }
10
- function renderButton({ props, className, attributes, mode }, icons) {
5
+ /** An `<a>` when the link resolves to an href, otherwise a `<span>`. */
6
+ export function Button({ props, className, attributes, mode, linkComponent }) {
11
7
  const label = asText(props.label);
12
8
  if (!label && mode !== 'canvas')
13
9
  return null;
14
- const text = label || _jsx(PlaceholderText, { children: "Button" });
10
+ const content = label || _jsx(PlaceholderText, { children: "Button" });
15
11
  const link = linkAttributes(props.link);
16
- const name = asText(props.icon);
17
- const glyph = icons && name && Object.hasOwn(icons, name) ? icons[name] : undefined;
18
- // Without an icon the label is the element's only content, as in 0.3.0. With one, the label
19
- // gets its own span, so inline editing on the canvas edits the text and not the icon.
20
- let content = text;
21
- let editable = editableText(mode, 'label');
22
- if (glyph) {
23
- const icon = createElement(glyph, {
24
- 'aria-hidden': true,
25
- focusable: 'false',
26
- className: asText(props.iconClassName) || undefined,
27
- });
28
- const labelSpan = _jsx("span", { ...editable, children: text });
29
- content = props.iconPosition === 'start' ? _jsxs(_Fragment, { children: [icon, labelSpan] }) : _jsxs(_Fragment, { children: [labelSpan, icon] });
30
- editable = {};
31
- }
32
12
  if (!link) {
33
- return (_jsx("span", { ...attributes, ...editable, className: className, children: content }));
34
- }
35
- return (_jsx("a", { ...attributes, ...editable, ...link, className: className, children: content }));
36
- }
37
- const byMap = new WeakMap();
38
- /**
39
- * The `button` block's component for a site with an icon set: the `icon` prop
40
- * (`defaultBlocks({ icons })`) draws that icon before or after the label (`iconPosition`), with
41
- * the `iconClassName` classes. The icon is decoration: the label names the button.
42
- * `builtinComponents({ icons })` includes it. One component per map.
43
- */
44
- export function buttonComponent(icons) {
45
- const known = byMap.get(icons);
46
- if (known)
47
- return known;
48
- function IconButton(props) {
49
- return renderButton(props, icons);
13
+ return (_jsx("span", { ...attributes, ...editableText(mode, 'label'), className: className, children: content }));
50
14
  }
51
- byMap.set(icons, IconButton);
52
- return IconButton;
15
+ // The site's link component (`RenderLayout`'s `linkComponent`), else a plain <a>.
16
+ const A = linkComponent ?? 'a';
17
+ return (_jsx(A, { ...attributes, ...editableText(mode, 'label'), ...link, className: className, children: content }));
53
18
  }
@@ -5,5 +5,8 @@ import type { BlockComponentProps } from '../render/types.js';
5
5
  * slot instead. Nothing on the site when both are empty. A repeat with `as: 'none'` has no wrapper:
6
6
  * its rows sit in the parent. The canvas keeps an element with `display: contents` there, so the
7
7
  * editor can still find and measure the repeat.
8
+ *
9
+ * With page links, a plain wrapper (the block element, no classes) holds two elements: the items
10
+ * with the block's classes, and the pager. So a grid of items never makes the pager a grid cell.
8
11
  */
9
- export declare function CollectionList({ block, props, className, attributes, slots, slotAttributes, mode }: BlockComponentProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
12
+ export declare function CollectionList({ block, props, className, attributes, slots, partAttributes, mode }: BlockComponentProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
@@ -10,8 +10,11 @@ const CONTENTS = { display: 'contents' };
10
10
  * slot instead. Nothing on the site when both are empty. A repeat with `as: 'none'` has no wrapper:
11
11
  * its rows sit in the parent. The canvas keeps an element with `display: contents` there, so the
12
12
  * editor can still find and measure the repeat.
13
+ *
14
+ * With page links, a plain wrapper (the block element, no classes) holds two elements: the items
15
+ * with the block's classes, and the pager. So a grid of items never makes the pager a grid cell.
13
16
  */
14
- export function CollectionList({ block, props, className, attributes, slots, slotAttributes, mode }) {
17
+ export function CollectionList({ block, props, className, attributes, slots, partAttributes, mode }) {
15
18
  const items = slots[LIST_ITEM_SLOT];
16
19
  const empty = slots[LIST_EMPTY_SLOT];
17
20
  if (!items && !empty && mode !== 'canvas')
@@ -19,8 +22,12 @@ export function CollectionList({ block, props, className, attributes, slots, slo
19
22
  if (block.type === REPEAT_BLOCK && props.as === 'none') {
20
23
  if (mode !== 'canvas')
21
24
  return items;
22
- return createElement('div', { ...attributes, ...slotAttributes[LIST_ITEM_SLOT], style: CONTENTS }, items);
25
+ return createElement('div', { ...attributes, ...partAttributes[LIST_ITEM_SLOT], style: CONTENTS }, items);
23
26
  }
24
27
  const pages = props[LIST_PAGES_PROP];
25
- return (_jsxs("div", { ...attributes, ...slotAttributes[LIST_ITEM_SLOT], className: className, children: [items, empty && _jsx("div", { ...slotAttributes[LIST_EMPTY_SLOT], children: empty }), pages && pages.links.length > 1 && (_jsx("nav", { "aria-label": asText(props.pagerLabel).trim() || 'Pages', className: typeof props.pagerClassName === 'string' ? props.pagerClassName : undefined, children: pages.links.map((link) => (_jsxs(Fragment, { children: [link.gapBefore && _jsx("span", { "data-page-gap": "", "aria-hidden": "true", children: "\u2026" }), _jsx("a", { href: link.href, "aria-current": link.current ? 'page' : undefined, className: typeof props.pageLinkClassName === 'string' ? props.pageLinkClassName : undefined, children: link.page })] }, link.page))) }))] }));
28
+ const pager = pages && pages.links.length > 1;
29
+ const list = (_jsxs("div", { ...(pager ? {} : attributes), ...partAttributes[LIST_ITEM_SLOT], className: className, children: [items, empty && _jsx("div", { ...partAttributes[LIST_EMPTY_SLOT], children: empty })] }));
30
+ if (!pager)
31
+ return list;
32
+ return (_jsxs("div", { ...attributes, children: [list, _jsx("nav", { "aria-label": asText(props.pagerLabel).trim() || 'Pages', className: partAttributes.pager?.className, children: pages.links.map((link) => (_jsxs(Fragment, { children: [link.gapBefore && _jsx("span", { "data-page-gap": "", "aria-hidden": "true", children: "\u2026" }), _jsx("a", { href: link.href, "aria-current": link.current ? 'page' : undefined, className: partAttributes.pageLink?.className, children: link.page })] }, link.page))) })] }));
26
33
  }
@@ -1,5 +1,8 @@
1
1
  import type { BlockComponentProps } from '../render/types.js';
2
- /** Used for `stack` and `grid`. All layout comes from `className`. `as` picks the HTML tag. */
3
- export declare function Container({ props, className, attributes, slotAttributes, slots }: BlockComponentProps): import("react").ReactElement<{
2
+ /**
3
+ * Used for `stack` and `grid`. All layout comes from `className`. `as` picks the HTML tag: only tags
4
+ * that may hold blocks (no `p` or `span`, which cannot hold a heading or a div).
5
+ */
6
+ export declare function Container({ props, className, attributes, partAttributes, slots }: BlockComponentProps): import("react").ReactElement<{
4
7
  className: string | undefined;
5
8
  }, string | import("react").JSXElementConstructor<any>>;
@@ -1,10 +1,13 @@
1
1
  import { createElement } from 'react';
2
2
  const TAGS = new Set([
3
3
  'div', 'section', 'header', 'footer', 'main', 'nav', 'article', 'aside',
4
- 'ol', 'ul', 'li', 'dl', 'dt', 'dd', 'figure', 'figcaption', 'p', 'span',
4
+ 'ol', 'ul', 'li', 'dl', 'dt', 'dd', 'figure', 'figcaption',
5
5
  ]);
6
- /** Used for `stack` and `grid`. All layout comes from `className`. `as` picks the HTML tag. */
7
- export function Container({ props, className, attributes, slotAttributes, slots }) {
6
+ /**
7
+ * Used for `stack` and `grid`. All layout comes from `className`. `as` picks the HTML tag: only tags
8
+ * that may hold blocks (no `p` or `span`, which cannot hold a heading or a div).
9
+ */
10
+ export function Container({ props, className, attributes, partAttributes, slots }) {
8
11
  const tag = typeof props.as === 'string' && TAGS.has(props.as) ? props.as : 'div';
9
- return createElement(tag, { ...attributes, ...slotAttributes.children, className }, slots.children);
12
+ return createElement(tag, { ...attributes, ...partAttributes.children, className }, slots.children);
10
13
  }
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // The Field block: one field of the current document, rendered by the value's type.
3
- import { FIELD_CLASS_MAP } from '../../blocks/index.js';
4
- import { FIELD_VALUE_PROP, formatBindingValue, formatDate, isIsoDate, isMissing, isRichText, isUploadDoc, titleOf, toPlainText, } from '../../core/index.js';
3
+ import { FIELD_CLASS_MAP } from '../../blocks/client/field.js';
4
+ import { FIELD_VALUE_PROP, formatDate, isIsoDate, isMissing, isRichText, isUploadDoc, titleOf, toPlainText, } from '../../core/index.js';
5
5
  import { defaultResolveLink } from '../render/link.js';
6
6
  import { asText, PlaceholderText } from './placeholder.js';
7
7
  import { renderRichText } from './RichText.js';
@@ -29,19 +29,8 @@ function createField(resolveLink) {
29
29
  const path = asText(props.path);
30
30
  return (_jsx("div", { ...attributes, className: className, children: _jsx(PlaceholderText, { children: path ? `{${path}}` : 'Field' }) }));
31
31
  }
32
- // `format`: a binding formatter such as "currency:AUD" or "date:en-AU". Rich text and uploads keep their own rendering.
33
- const format = asText(props.format);
34
- if (format && !isRichText(value) && !isUploadDoc(value)) {
35
- const formatted = formatBindingValue(value, format);
36
- if (formatted !== undefined) {
37
- if (isIsoDate(value)) {
38
- return (_jsx("time", { ...attributes, className: className, dateTime: value, children: formatted }));
39
- }
40
- return _jsx("div", { ...attributes, className: className, children: lines(formatted) });
41
- }
42
- }
43
32
  if (isRichText(value)) {
44
- return (_jsx("div", { ...attributes, className: richTextClass(className), children: renderRichText(value, resolveLink, { headingIds: props.headingIds === true }) }));
33
+ return (_jsx("div", { ...attributes, className: richTextClass(className), children: renderRichText(value, resolveLink) }));
45
34
  }
46
35
  if (isUploadDoc(value)) {
47
36
  if (!isImage(value)) {
@@ -1,3 +1,3 @@
1
1
  import type { BlockComponentProps } from '../render/types.js';
2
2
  /** A clickable container: an `<a>` around its children, or a `<div>` when the link has no href. */
3
- export declare function Link({ props, className, attributes, slotAttributes, slots }: BlockComponentProps): import("react").JSX.Element;
3
+ export declare function Link({ props, className, attributes, partAttributes, slots, linkComponent }: BlockComponentProps): import("react").JSX.Element;
@@ -1,10 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { linkAttributes } from '../render/link.js';
3
3
  /** A clickable container: an `<a>` around its children, or a `<div>` when the link has no href. */
4
- export function Link({ props, className, attributes, slotAttributes, slots }) {
4
+ export function Link({ props, className, attributes, partAttributes, slots, linkComponent }) {
5
5
  const link = linkAttributes(props.link);
6
6
  if (!link) {
7
- return (_jsx("div", { ...attributes, ...slotAttributes.children, className: className, children: slots.children }));
7
+ return (_jsx("div", { ...attributes, ...partAttributes.children, className: className, children: slots.children }));
8
8
  }
9
- return (_jsx("a", { ...attributes, ...slotAttributes.children, ...link, className: className, children: slots.children }));
9
+ // The site's link component (`RenderLayout`'s `linkComponent`), else a plain <a>.
10
+ const A = linkComponent ?? 'a';
11
+ return (_jsx(A, { ...attributes, ...partAttributes.children, ...link, className: className, children: slots.children }));
10
12
  }
@@ -9,7 +9,7 @@ export declare function hasListTypeClass(className: string | undefined): boolean
9
9
  * a list-style class it shows bullets (disc) or numbers (decimal) inline, so an ordered list never
10
10
  * shows bullets. Nothing on the site when the list is empty.
11
11
  */
12
- export declare function List({ block, props, className, attributes, slots, slotAttributes, mode }: BlockComponentProps): import("react").DetailedReactHTMLElement<{
12
+ export declare function List({ block, props, className, attributes, slots, partAttributes, mode }: BlockComponentProps): import("react").DetailedReactHTMLElement<{
13
13
  className: string | undefined;
14
14
  style: {
15
15
  listStyleType: string;
@@ -37,14 +37,14 @@ function legacyItems(props, mode) {
37
37
  * a list-style class it shows bullets (disc) or numbers (decimal) inline, so an ordered list never
38
38
  * shows bullets. Nothing on the site when the list is empty.
39
39
  */
40
- export function List({ block, props, className, attributes, slots, slotAttributes, mode }) {
40
+ export function List({ block, props, className, attributes, slots, partAttributes, mode }) {
41
41
  const hasItems = (block.slots?.[TEXT_LIST_SLOT]?.length ?? 0) > 0;
42
42
  const children = (hasItems ? null : legacyItems(props, mode)) ?? slots[TEXT_LIST_SLOT];
43
43
  if (!children && mode !== 'canvas')
44
44
  return null;
45
45
  const ordered = props.ordered === true;
46
46
  const style = hasListTypeClass(className) ? undefined : { listStyleType: ordered ? 'decimal' : 'disc' };
47
- return createElement(ordered ? 'ol' : 'ul', { ...attributes, ...slotAttributes[TEXT_LIST_SLOT], className, style }, children);
47
+ return createElement(ordered ? 'ol' : 'ul', { ...attributes, ...partAttributes[TEXT_LIST_SLOT], className, style }, children);
48
48
  }
49
49
  /**
50
50
  * One `<li>` of a list. Its text is edited in place on the canvas; Enter adds the next item and
@@ -1,3 +1,4 @@
1
+ import { MENU_LABELS } from '../../blocks/client/menu.js';
1
2
  import { type LinkAttributes } from '../render/link.js';
2
3
  import type { BlockComponentProps } from '../render/types.js';
3
4
  /** `path` is the row's prop path: the canvas edits `<path>.label` (`items.2.label`, `items.2.children.0.label`). */
@@ -16,5 +17,13 @@ export declare function isCurrentLink(href: string, pathname: string | null, ori
16
17
  export declare function toItems(value: unknown, path?: string, depth?: number): Item[];
17
18
  /** `aria-current` of a menu row: `page` for the current page, `true` for a parent whose child is the current page. */
18
19
  export declare function currentOf(item: Item, pathname: string | null, origin?: string): Current;
19
- export declare function Menu({ props, className, attributes, mode }: BlockComponentProps): import("react").JSX.Element | null;
20
+ export type MenuLabels = Partial<typeof MENU_LABELS>;
21
+ /**
22
+ * `labels`: the site's labels (`builtinComponents({ labels: { menu } })`), used when a prop is empty.
23
+ * `clientLinks`: the site navigates on the client (`RenderLayout`'s `linkComponent`), so links are
24
+ * `next/link`. `linkComponent` is for direct use in client code; from the server only `clientLinks` arrives.
25
+ */
26
+ export declare function Menu({ props, className, attributes, partAttributes, mode, labels, linkComponent, clientLinks }: BlockComponentProps & {
27
+ labels?: MenuLabels;
28
+ }): import("react").JSX.Element | null;
20
29
  export {};
@@ -8,8 +8,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  // An item with `children` (one level) is a dropdown: a <details> in the inline list, beside the
9
9
  // item's own link or in its place, and a nested list in the panel. Escape, a click outside and
10
10
  // focus leaving close an open dropdown; opening one closes the others.
11
+ import NextLink from 'next/link';
12
+ import { usePathname } from 'next/navigation';
11
13
  import { useEffect, useRef, useSyncExternalStore } from 'react';
12
- import { MENU_CLASS_MAP as C } from '../../blocks/index.js';
14
+ import { joinClasses, labelOf } from '../../blocks/client/helpers.js';
15
+ import { MENU_CLASS_MAP as C, MENU_LABELS } from '../../blocks/client/menu.js';
13
16
  import { editableText } from '../render/editable.js';
14
17
  import { linkAttributes } from '../render/link.js';
15
18
  import { asText, PlaceholderText } from './placeholder.js';
@@ -67,12 +70,12 @@ export function toItems(value, path = 'items', depth = 0) {
67
70
  ];
68
71
  });
69
72
  }
70
- function MenuLink({ item, className, current, mode }) {
73
+ function MenuLink({ item, className, current, mode, as: A }) {
71
74
  const editable = editableText(mode, `${item.path}.label`);
72
75
  if (!item.link) {
73
76
  return (_jsx("span", { ...editable, className: className, children: item.label }));
74
77
  }
75
- return (_jsx("a", { ...item.link, ...editable, className: className, "aria-current": current, children: item.label }));
78
+ return (_jsx(A, { ...item.link, ...editable, className: className, "aria-current": current, children: item.label }));
76
79
  }
77
80
  function Icon({ className, open }) {
78
81
  return (_jsx("svg", { className: className, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", "aria-hidden": "true", children: open ? _jsx("path", { d: "M5 5l10 10M15 5L5 15" }) : _jsx("path", { d: "M3 6h14M3 10h14M3 14h14" }) }));
@@ -87,17 +90,29 @@ export function currentOf(item, pathname, origin) {
87
90
  return 'page';
88
91
  return item.children.some(is) ? 'true' : undefined;
89
92
  }
90
- export function Menu({ props, className, attributes, mode }) {
93
+ /**
94
+ * `labels`: the site's labels (`builtinComponents({ labels: { menu } })`), used when a prop is empty.
95
+ * `clientLinks`: the site navigates on the client (`RenderLayout`'s `linkComponent`), so links are
96
+ * `next/link`. `linkComponent` is for direct use in client code; from the server only `clientLinks` arrives.
97
+ */
98
+ export function Menu({ props, className, attributes, partAttributes, mode, labels, linkComponent, clientLinks }) {
99
+ const A = linkComponent ?? (clientLinks && mode === 'site' ? NextLink : 'a');
91
100
  const items = toItems(props.items);
92
101
  const collapse = props.collapse === 'lg' || props.collapse === 'never' ? props.collapse : 'md';
93
- const label = asText(props.label) || 'Main';
94
- const submenuLabel = asText(props.submenuLabel) || '{label} menu';
102
+ const L = labels ? { ...MENU_LABELS, ...labels } : MENU_LABELS;
103
+ const label = labelOf(props, L, 'label');
104
+ // `{label}` is filled in per link below.
105
+ const submenuLabel = labelOf(props, L, 'submenuLabel');
95
106
  // The panel button needs a label and a link; without both it is not shown.
96
107
  const ctaLink = linkAttributes(props.cta);
97
108
  const ctaLabel = asText(props.ctaLabel);
98
109
  const cta = ctaLink && ctaLabel ? { link: ctaLink, label: ctaLabel } : null;
99
- const pathname = useSyncExternalStore(subscribe, clientPath, serverPath);
100
- const origin = pathname === null ? undefined : window.location.origin;
110
+ // The browser's path once it hydrates (the server's path can differ after a rewrite). Next's
111
+ // path follows client-side navigation, which fires no popstate.
112
+ const routerPath = usePathname();
113
+ const browserPath = useSyncExternalStore(subscribe, clientPath, serverPath);
114
+ const pathname = browserPath !== null && routerPath ? routerPath : browserPath;
115
+ const origin = browserPath === null ? undefined : window.location.origin;
101
116
  const nav = useRef(null);
102
117
  // The panel and the dropdowns. Escape closes the one that holds the focus and focuses its
103
118
  // toggle. A click outside closes them all.
@@ -144,12 +159,22 @@ export function Menu({ props, className, attributes, mode }) {
144
159
  if (element !== opened)
145
160
  close(element, false);
146
161
  };
162
+ // A client-side navigation (`linkComponent`) keeps the page and this menu: a click on a link
163
+ // closes the panel and the dropdowns.
164
+ const onClick = (event) => {
165
+ if (!(event.target instanceof Element) || !event.target.closest('a[href]'))
166
+ return;
167
+ for (const element of root.querySelectorAll('details'))
168
+ close(element, false);
169
+ };
147
170
  root.addEventListener('keydown', onKeyDown);
171
+ root.addEventListener('click', onClick);
148
172
  root.addEventListener('focusout', onFocusOut);
149
173
  root.addEventListener('toggle', onToggle, true);
150
174
  document.addEventListener('pointerdown', onPointerDown);
151
175
  return () => {
152
176
  root.removeEventListener('keydown', onKeyDown);
177
+ root.removeEventListener('click', onClick);
153
178
  root.removeEventListener('focusout', onFocusOut);
154
179
  root.removeEventListener('toggle', onToggle, true);
155
180
  document.removeEventListener('pointerdown', onPointerDown);
@@ -161,14 +186,16 @@ export function Menu({ props, className, attributes, mode }) {
161
186
  return (_jsx("nav", { ...attributes, ref: nav, "aria-label": label, className: className, children: _jsx(PlaceholderText, { children: "Menu: add links in the Content tab" }) }));
162
187
  }
163
188
  const current = (item) => currentOf(item, pathname, origin);
164
- const childList = (item, listClass, linkClass) => (_jsx("ul", { className: listClass, children: item.children.map((child) => (_jsx("li", { children: _jsx(MenuLink, { item: child, className: linkClass, current: current(child), mode: mode }) }, child.key))) }));
189
+ // The parts' own classes (`block.partClassName`) join the menu's classes.
190
+ const part = (name) => partAttributes[name]?.className;
191
+ const childList = (item, listClass, linkClass) => (_jsx("ul", { className: listClass, children: item.children.map((child) => (_jsx("li", { children: _jsx(MenuLink, { item: child, className: linkClass, current: current(child), mode: mode, as: A }) }, child.key))) }));
165
192
  const list = (linkClass) => items.map((item) => {
166
193
  if (item.children.length === 0) {
167
- return (_jsx("li", { children: _jsx(MenuLink, { item: item, className: linkClass, current: current(item), mode: mode }) }, item.key));
194
+ return (_jsx("li", { children: _jsx(MenuLink, { item: item, className: linkClass, current: current(item), mode: mode, as: A }) }, item.key));
168
195
  }
169
196
  // With its own link: the link and a small toggle beside it, named by `submenuLabel`.
170
197
  // Without one: the label is the toggle.
171
- return (_jsxs("li", { className: C.submenu, children: [item.link ? _jsx(MenuLink, { item: item, className: linkClass, current: current(item), mode: mode }) : null, _jsxs("details", { className: C.submenuDetails, children: [_jsxs("summary", { className: C.submenuToggle, "aria-label": item.link ? submenuLabel.replaceAll('{label}', item.label) : undefined, "aria-current": item.link ? undefined : current(item), children: [item.link ? null : _jsx("span", { ...editableText(mode, `${item.path}.label`), children: item.label }), _jsx(Chevron, { className: C.submenuIcon })] }), childList(item, C.submenuList, C.submenuLink)] })] }, item.key));
198
+ return (_jsxs("li", { className: C.submenu, children: [item.link ? _jsx(MenuLink, { item: item, className: linkClass, current: current(item), mode: mode, as: A }) : null, _jsxs("details", { className: C.submenuDetails, children: [_jsxs("summary", { className: C.submenuToggle, "aria-label": item.link ? submenuLabel.replaceAll('{label}', item.label) : undefined, "aria-current": item.link ? undefined : current(item), children: [item.link ? null : _jsx("span", { ...editableText(mode, `${item.path}.label`), children: item.label }), _jsx(Chevron, { className: C.submenuIcon })] }), childList(item, joinClasses(C.submenuList, part('submenu')), joinClasses(C.submenuLink, part('submenuLink')))] })] }, item.key));
172
199
  });
173
- return (_jsxs("nav", { ...attributes, ref: nav, "aria-label": label, className: className, children: [_jsx("ul", { role: "list", className: C.list[collapse], children: list(C.link) }), collapse === 'never' ? null : (_jsxs("details", { className: `group ${C.toggleWrap[collapse]}`, children: [_jsxs("summary", { className: C.toggle, children: [_jsx("span", { children: asText(props.toggleLabel) || 'Menu' }), _jsx(Icon, { className: C.iconOpen, open: false }), _jsx(Icon, { className: C.iconClose, open: true })] }), _jsx("div", { className: C.panel, children: _jsxs("ul", { className: C.panelList, children: [items.map((item) => (_jsxs("li", { children: [_jsx(MenuLink, { item: item, className: C.panelLink, current: current(item), mode: mode }), item.children.length > 0 ? childList(item, C.panelSubList, C.panelSubLink) : null] }, item.key))), cta ? (_jsx("li", { children: _jsx("a", { ...cta.link, ...editableText(mode, 'ctaLabel'), className: C.panelCta, children: cta.label }) })) : null] }) })] }))] }));
200
+ return (_jsxs("nav", { ...attributes, ref: nav, "aria-label": label, className: className, children: [_jsx("ul", { role: "list", className: C.list[collapse], children: list(joinClasses(C.link, part('link'))) }), collapse === 'never' ? null : (_jsxs("details", { className: `group ${C.toggleWrap[collapse]}`, children: [_jsxs("summary", { className: C.toggle, children: [_jsx("span", { children: labelOf(props, L, 'toggleLabel') }), _jsx(Icon, { className: C.iconOpen, open: false }), _jsx(Icon, { className: C.iconClose, open: true })] }), _jsx("div", { className: joinClasses(C.panel, part('panel')), children: _jsxs("ul", { className: C.panelList, children: [items.map((item) => (_jsxs("li", { children: [_jsx(MenuLink, { item: item, className: C.panelLink, current: current(item), mode: mode, as: A }), item.children.length > 0 ? childList(item, C.panelSubList, C.panelSubLink) : null] }, item.key))), cta ? (_jsx("li", { children: _jsx(A, { ...cta.link, ...editableText(mode, 'ctaLabel'), className: C.panelCta, children: cta.label }) })) : null] }) })] }))] }));
174
201
  }
@@ -4,11 +4,10 @@ import type { BlockComponentProps, ResolveLink } from '../render/types.js';
4
4
  export declare function isEmptyRichText(value: unknown): boolean;
5
5
  /**
6
6
  * Lexical rich text as React elements, with internal links resolved by `resolveLink`. No wrapper.
7
- * `headingIds`: each heading gets an id from its text (`richTextHeadings`), for `#id` links.
7
+ * Each heading gets an id from its text (`richTextHeadings`), for `#id` links and the
8
+ * tableOfContents block.
8
9
  */
9
- export declare function renderRichText(content: unknown, resolveLink: ResolveLink, options?: {
10
- headingIds?: boolean;
11
- }): ReactNode;
10
+ export declare function renderRichText(content: unknown, resolveLink: ResolveLink): ReactNode;
12
11
  /** One component per resolver, so React keeps the same component type between renders. */
13
12
  export declare function richTextFor(resolveLink: ResolveLink): ComponentType<BlockComponentProps>;
14
13
  /** The rich text component with the default link resolver. */
@@ -57,16 +57,16 @@ function withHeadingIds(base, content) {
57
57
  }
58
58
  /**
59
59
  * Lexical rich text as React elements, with internal links resolved by `resolveLink`. No wrapper.
60
- * `headingIds`: each heading gets an id from its text (`richTextHeadings`), for `#id` links.
60
+ * Each heading gets an id from its text (`richTextHeadings`), for `#id` links and the
61
+ * tableOfContents block.
61
62
  */
62
- export function renderRichText(content, resolveLink, options) {
63
+ export function renderRichText(content, resolveLink) {
63
64
  let rendererConverters = convertersByResolver.get(resolveLink);
64
65
  if (!rendererConverters) {
65
66
  rendererConverters = converters(resolveLink);
66
67
  convertersByResolver.set(resolveLink, rendererConverters);
67
68
  }
68
- const used = options?.headingIds ? withHeadingIds(rendererConverters, content) : rendererConverters;
69
- return _jsx(LexicalRichText, { data: content, disableContainer: true, converters: used });
69
+ return _jsx(LexicalRichText, { data: content, disableContainer: true, converters: withHeadingIds(rendererConverters, content) });
70
70
  }
71
71
  /**
72
72
  * Makes the built-in rich text component for one link resolver. RenderLayout calls it with its
@@ -81,7 +81,7 @@ function createRichText(resolveLink) {
81
81
  return null;
82
82
  return (_jsx("div", { ...attributes, ...editableText(mode, 'content'), className: className, children: _jsx("p", { children: _jsx(PlaceholderText, { children: "Rich text" }) }) }));
83
83
  }
84
- return (_jsx("div", { ...attributes, ...editableText(mode, 'content'), className: className, children: renderRichText(content, resolveLink, { headingIds: props.headingIds === true }) }));
84
+ return (_jsx("div", { ...attributes, ...editableText(mode, 'content'), className: className, children: renderRichText(content, resolveLink) }));
85
85
  };
86
86
  }
87
87
  const byResolver = new WeakMap();
@@ -3,7 +3,8 @@ import type { BlockComponentProps } from '../../render/types.js';
3
3
  export declare function ownDetails(root: HTMLElement): HTMLDetailsElement[];
4
4
  /**
5
5
  * A list of disclosures. With "Several open at a time" off it gives its own disclosures one
6
- * `name`, so the browser keeps one open (exclusive <details>). Not on the canvas, where every
7
- * disclosure stays open for editing. The FAQ JSON-LD reads it with `faqItems`.
6
+ * `name`, so the browser keeps one open (exclusive <details>), on the canvas too: selecting a
7
+ * block in another item opens that item and closes the open one. `RenderLayout` outputs the FAQ
8
+ * JSON-LD (`faqItems`).
8
9
  */
9
- export declare function Accordion({ block, props, className, attributes, slotAttributes, slots, mode }: BlockComponentProps): import("react").JSX.Element;
10
+ export declare function Accordion({ block, props, className, attributes, partAttributes, slots }: BlockComponentProps): import("react").JSX.Element;
@@ -10,12 +10,13 @@ export function ownDetails(root) {
10
10
  }
11
11
  /**
12
12
  * A list of disclosures. With "Several open at a time" off it gives its own disclosures one
13
- * `name`, so the browser keeps one open (exclusive <details>). Not on the canvas, where every
14
- * disclosure stays open for editing. The FAQ JSON-LD reads it with `faqItems`.
13
+ * `name`, so the browser keeps one open (exclusive <details>), on the canvas too: selecting a
14
+ * block in another item opens that item and closes the open one. `RenderLayout` outputs the FAQ
15
+ * JSON-LD (`faqItems`).
15
16
  */
16
- export function Accordion({ block, props, className, attributes, slotAttributes, slots, mode }) {
17
+ export function Accordion({ block, props, className, attributes, partAttributes, slots }) {
17
18
  const ref = useRef(null);
18
- const single = props.multiple === false && mode !== 'canvas';
19
+ const single = props.multiple === false;
19
20
  useEffect(() => {
20
21
  const root = ref.current;
21
22
  if (!root)
@@ -33,5 +34,5 @@ export function Accordion({ block, props, className, attributes, slotAttributes,
33
34
  observer.observe(root, { childList: true, subtree: true });
34
35
  return () => observer.disconnect();
35
36
  }, [single, block.id]);
36
- return (_jsx("div", { ...attributes, ...slotAttributes.items, ref: ref, className: className, children: slots.items }));
37
+ return (_jsx("div", { ...attributes, ...partAttributes.items, ref: ref, className: className, children: slots.items }));
37
38
  }
@@ -0,0 +1,11 @@
1
+ import { ADJACENT_LINKS_LABELS } from '../../../blocks/client/adjacentLinks.js';
2
+ import type { BlockComponentProps } from '../../render/types.js';
3
+ export type AdjacentLinksLabels = Partial<typeof ADJACENT_LINKS_LABELS>;
4
+ /**
5
+ * A <nav> with the "previous" and "next" slots, each holding a collection list that finds the
6
+ * document before or after this one. On the site a side without a document renders nothing, and
7
+ * so does the whole block when both are empty. The canvas always shows both sides.
8
+ */
9
+ export declare function AdjacentLinks({ block, props, className, attributes, partAttributes, slots, mode, labels }: BlockComponentProps & {
10
+ labels?: AdjacentLinksLabels;
11
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ADJACENT_LINKS_LABELS } from '../../../blocks/client/adjacentLinks.js';
3
+ import { labelOf } from '../../../blocks/client/helpers.js';
4
+ import { listItemsOf } from '../../render/lists.js';
5
+ /** True when a side's collection list found a document (`loadLayoutData` puts it on the list). */
6
+ const found = (side) => (side ?? []).some((list) => !list.hidden && listItemsOf(list.props).length > 0);
7
+ /**
8
+ * A <nav> with the "previous" and "next" slots, each holding a collection list that finds the
9
+ * document before or after this one. On the site a side without a document renders nothing, and
10
+ * so does the whole block when both are empty. The canvas always shows both sides.
11
+ */
12
+ export function AdjacentLinks({ block, props, className, attributes, partAttributes, slots, mode, labels }) {
13
+ const canvas = mode === 'canvas';
14
+ const previous = canvas || found(block.slots?.previous);
15
+ const next = canvas || found(block.slots?.next);
16
+ if (!previous && !next)
17
+ return null;
18
+ const L = labels ? { ...ADJACENT_LINKS_LABELS, ...labels } : ADJACENT_LINKS_LABELS;
19
+ return (_jsxs("nav", { ...attributes, "aria-label": labelOf(props, L, 'label'), className: className, children: [previous ? _jsx("div", { ...partAttributes.previous, children: slots.previous }) : null, next ? _jsx("div", { ...partAttributes.next, children: slots.next }) : null] }));
20
+ }
@@ -1,13 +1,24 @@
1
+ import { CAROUSEL_LABELS } from '../../../blocks/client/carousel.js';
2
+ import type { Block } from '../../../core/types.js';
1
3
  import type { BlockComponentProps } from '../../render/types.js';
2
- /** The slide to show for `target`: wrapped around with `loop`, else kept in range. */
3
- export declare function slideIndex(target: number, count: number, loop: boolean): number;
4
- /** The slide whose start is nearest the scroll position. At the end of the track: the last one. */
5
- export declare function nearestSlide(offsets: number[], scrollLeft: number, maxScroll: number): number;
6
4
  /**
7
- * Slides from the "slides" slot in a scroll-snap track (or stacked, fading), with arrows, dots,
8
- * loop and autoplay. A region with `aria-roledescription="carousel"`; each slide is a group
9
- * labelled "i of n". Arrow keys on the track move one slide. Autoplay shows a pause button, stops
10
- * on hover and focus, and never runs with reduced motion. On the canvas the slides always scroll
11
- * and never autoplay, so each one can be selected.
5
+ * True when the slides slot holds one collection list or repeat that renders a wrapper: the track
6
+ * unwraps it, so its items are the slides. A repeat with `as: 'none'` has no wrapper.
12
7
  */
13
- export declare function Carousel({ block, props, className, attributes, slotAttributes, slots, mode }: BlockComponentProps): import("react").JSX.Element;
8
+ export declare function unwrapsList(slides: readonly Block[]): boolean;
9
+ export type CarouselLabels = Partial<typeof CAROUSEL_LABELS>;
10
+ /** The stop (Embla scroll snap) that shows slide `slide`: several slides can share one stop. */
11
+ export declare function stopOf(stops: readonly (readonly number[])[], slide: number): number;
12
+ /**
13
+ * Slides from the "slides" slot on Embla Carousel: they slide (swipe, drag, arrows, dots, arrow
14
+ * keys) or fade, with loop and autoplay. A region with `aria-roledescription="carousel"`; each
15
+ * slide is a group labelled "i of n". Autoplay shows a pause button, pauses on hover and focus,
16
+ * stops when the visitor swipes, and never runs with reduced motion.
17
+ *
18
+ * In the editor's canvas the arrows and dots work (they are canvas controls), slides do not drag
19
+ * (the editor drags blocks), fade shows as sliding so each slide can be selected, autoplay is
20
+ * off, and selecting a block in a slide brings that slide into view (`useCanvasReveal`).
21
+ */
22
+ export declare function Carousel({ block, props, className, attributes, partAttributes, slots, mode, labels }: BlockComponentProps & {
23
+ labels?: CarouselLabels;
24
+ }): import("react").JSX.Element;