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
@@ -0,0 +1,72 @@
1
+ export type ThemeVariableType = 'color' | 'size' | 'font';
2
+ /** One design variable as the theme global stores it. */
3
+ export type ThemeVariable = {
4
+ /** The name classes use: `brand` gives `bg-brand`, `text-brand`. */
5
+ name: string;
6
+ type: ThemeVariableType;
7
+ /** Color: a hex color or a CSS color. Size: a CSS length (`1.5rem`, `24px`, `clamp(…)`). Font: a Google Fonts family. */
8
+ value?: string | null;
9
+ /** The value under the `.dark` class (colors and sizes). Empty: the same as `value`. */
10
+ darkValue?: string | null;
11
+ id?: string | null;
12
+ };
13
+ /** What the editor, the AI and the MCP tools see of a variable. */
14
+ export type VariableToken = {
15
+ name: string;
16
+ type: ThemeVariableType;
17
+ /** The CSS custom property, e.g. "--color-brand". */
18
+ property: string;
19
+ value: string;
20
+ darkValue?: string;
21
+ };
22
+ export declare const VARIABLE_TYPES: ReadonlyArray<{
23
+ value: ThemeVariableType;
24
+ label: string;
25
+ }>;
26
+ /** Example classes per type, for help text and the AI. */
27
+ export declare const VARIABLE_CLASS_EXAMPLES: Record<ThemeVariableType, string[]>;
28
+ export declare const VARIABLE_NAME_MAX = 40;
29
+ /** The CSS custom property of a variable: `--color-brand`. */
30
+ export declare const variableProperty: (variable: Pick<ThemeVariable, 'name' | 'type'>) => string;
31
+ /** Why a variable name is not usable for this type, or null. */
32
+ export declare function variableNameProblem(name: unknown, type: ThemeVariableType): string | null;
33
+ /** Why a value is not usable for this type, or null. Empty values are allowed (the variable is left out). */
34
+ export declare function variableValueProblem(value: unknown, type: ThemeVariableType): string | null;
35
+ /** A Google Fonts family name with only letters, digits, spaces and dashes. */
36
+ export declare function cleanVariableFamily(family: string | null | undefined): string | null;
37
+ /**
38
+ * The usable variables: a valid name and type, a valid non-empty value, the first of each name.
39
+ * Invalid rows are left out (the save validation reports them), so the output never breaks the CSS.
40
+ */
41
+ export declare function cleanVariables(list: unknown): ThemeVariable[];
42
+ /** Problems of a variables list, by row index: names and values. For the global's validation. */
43
+ export declare function variablesProblems(list: unknown): string | true;
44
+ /** The CSS value of a variable. Fonts get a fallback stack. */
45
+ export declare function variableCssValue(variable: Pick<ThemeVariable, 'type'>, value: string): string;
46
+ /** The font families the variables choose, by font name (`{ display: 'Fraunces' }`). */
47
+ export declare function variableFontFamilies(list: unknown): Record<string, string>;
48
+ /** Light values by custom property, colors and sizes only (fonts come with the theme's fonts). */
49
+ export declare function variableDeclarations(list: unknown, mode?: 'light' | 'dark'): Record<string, string>;
50
+ /**
51
+ * The dark values as a rule under the `.dark` class, on the root element and on any element inside
52
+ * it. Empty string without dark values. The selectors beat the theme's `:root:root` rule.
53
+ */
54
+ export declare function variablesDarkCss(list: unknown): string;
55
+ /**
56
+ * The `@theme` block both Tailwind compiles add after the app's CSS entry, so `bg-brand`,
57
+ * `p-gutter` and `font-display` exist. Empty string without variables.
58
+ */
59
+ export declare function variablesThemeCss(list: unknown): string;
60
+ /** The variables as the editor, the AI and the MCP tools see them. */
61
+ export declare function variableTokens(list: unknown): VariableToken[];
62
+ /** True when one class token (any variant prefix, `-` sign, `!` mark, `/opacity`) uses the variable. */
63
+ export declare function tokenUsesVariable(token: string, variable: Pick<ThemeVariable, 'name' | 'type'>): boolean;
64
+ /** True when a class string or a CSS text uses the variable (its classes or `var(--color-brand)`). */
65
+ export declare function textUsesVariable(text: string | null | undefined, variable: Pick<ThemeVariable, 'name' | 'type'>): boolean;
66
+ /** Example classes of a variable: "bg-brand text-brand border-brand". */
67
+ export declare const variableClasses: (variable: Pick<ThemeVariable, 'name' | 'type'>) => string;
68
+ export declare const VARIABLES_NOTE = "The site's design variables (Theme > Variables): named colors, sizes and fonts. Prefer them over raw values so the site keeps one look: colors as bg-<name>, text-<name>, border-<name>; sizes as p-<name>, m-<name>, gap-<name>, w-<name>; fonts as font-<name>. In custom CSS use var(<property>). darkValue applies under the .dark class.";
69
+ /** The variables for a tool result: name, type, value, dark value and example classes. */
70
+ export declare function describeVariables(tokens: readonly VariableToken[]): Array<VariableToken & {
71
+ classes: string;
72
+ }>;
@@ -0,0 +1,231 @@
1
+ // Design variables of the theme: named colors, sizes and fonts that blocks and classes use by name
2
+ // (`bg-brand`, `p-gutter`, `font-display`). Pure and client-safe. See the README section "Design
3
+ // variables".
4
+ //
5
+ // - Output: CSS custom properties in Tailwind's names (`--color-brand`, `--spacing-gutter`,
6
+ // `--font-display`), set by `ThemeStyle` in `:root:root`, with dark values under the `.dark` class.
7
+ // - Compile: `variablesThemeCss` registers the names in a `@theme inline reference` block after the
8
+ // app's CSS entry. Utilities then read the variable (`.bg-brand { background-color:
9
+ // var(--color-brand) }`) and the compile outputs no value, so the compiled CSS depends only on the
10
+ // names and types, never on the values.
11
+ export const VARIABLE_TYPES = [
12
+ { value: 'color', label: 'Color' },
13
+ { value: 'size', label: 'Size' },
14
+ { value: 'font', label: 'Font' },
15
+ ];
16
+ /** Tailwind's theme namespace of each type. */
17
+ const NAMESPACE = { color: '--color', size: '--spacing', font: '--font' };
18
+ /** Example classes per type, for help text and the AI. */
19
+ export const VARIABLE_CLASS_EXAMPLES = {
20
+ color: ['bg', 'text', 'border'],
21
+ size: ['p', 'm', 'gap', 'w'],
22
+ font: ['font'],
23
+ };
24
+ export const VARIABLE_NAME_MAX = 40;
25
+ const NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
26
+ /** Names the theme or Tailwind already uses, per type. A variable with one of them would replace it. */
27
+ const RESERVED = {
28
+ color: new Set([
29
+ 'inherit', 'current', 'transparent', 'black', 'white',
30
+ 'background', 'foreground', 'card', 'card-foreground', 'popover', 'popover-foreground',
31
+ 'primary', 'primary-foreground', 'secondary', 'secondary-foreground', 'muted', 'muted-foreground',
32
+ 'accent', 'accent-foreground', 'destructive', 'destructive-foreground', 'border', 'input', 'ring',
33
+ 'sidebar', 'sidebar-foreground', 'sidebar-primary', 'sidebar-primary-foreground', 'sidebar-accent',
34
+ 'sidebar-accent-foreground', 'sidebar-border', 'sidebar-ring',
35
+ ]),
36
+ size: new Set(['px', 'full', 'auto', 'screen', 'svh', 'dvh', 'lvh', 'svw', 'dvw', 'lvw', 'fit', 'min', 'max', 'none', 'prose']),
37
+ font: new Set(['sans', 'serif', 'mono', 'heading']),
38
+ };
39
+ /** A palette shade (`red-500`) or a chart color (`chart-2`). */
40
+ const PALETTE_NAME = /^(?:[a-z]+-(?:50|[1-9]00|950)|chart-\d+)$/;
41
+ /** The CSS custom property of a variable: `--color-brand`. */
42
+ export const variableProperty = (variable) => `${NAMESPACE[variable.type]}-${variable.name}`;
43
+ /** Why a variable name is not usable for this type, or null. */
44
+ export function variableNameProblem(name, type) {
45
+ if (typeof name !== 'string' || !name.trim())
46
+ return 'Enter a name.';
47
+ const value = name.trim();
48
+ if (value.length > VARIABLE_NAME_MAX)
49
+ return `Use at most ${VARIABLE_NAME_MAX} characters.`;
50
+ if (!NAME.test(value))
51
+ return 'Use lower-case letters, digits and single dashes, and start with a letter. For example "brand" or "space-lg".';
52
+ if (RESERVED[type].has(value) || (type === 'color' && PALETTE_NAME.test(value)))
53
+ return `“${value}” is taken by the theme. Pick another name.`;
54
+ return null;
55
+ }
56
+ const UNSAFE = /[;{}<>\\"`]|\/\*/;
57
+ const COLOR = /^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|oklch|oklab|lab|lch|color|color-mix|light-dark)\(.*\)|var\(--[\w-]+\))$/i;
58
+ const SIZE = /^(?:-?(?:\d+\.?\d*|\.\d+)(?:px|rem|em|%|vw|vh|svh|dvh|lvh|ch|ex|lh|cqw|cqh)?|(?:calc|clamp|min|max)\(.*\)|var\(--[\w-]+\))$/i;
59
+ /** Why a value is not usable for this type, or null. Empty values are allowed (the variable is left out). */
60
+ export function variableValueProblem(value, type) {
61
+ if (value == null || value === '')
62
+ return null;
63
+ if (typeof value !== 'string')
64
+ return 'Enter text.';
65
+ const text = value.trim();
66
+ if (!text)
67
+ return null;
68
+ if (UNSAFE.test(text) || text.length > 200)
69
+ return 'This value has characters CSS does not allow here.';
70
+ if (type === 'color' && !COLOR.test(text))
71
+ return 'Enter a color, for example #1f4536.';
72
+ if (type === 'size' && !SIZE.test(text))
73
+ return 'Enter a size, for example 24px, 1.5rem or clamp(1rem, 4vw, 3rem).';
74
+ if (type === 'font' && !cleanVariableFamily(text))
75
+ return 'Enter a Google Fonts family, for example Inter.';
76
+ return null;
77
+ }
78
+ /** A Google Fonts family name with only letters, digits, spaces and dashes. */
79
+ export function cleanVariableFamily(family) {
80
+ const clean = family?.replace(/[^\p{L}\p{N} -]/gu, '').replace(/\s+/g, ' ').trim();
81
+ return clean || null;
82
+ }
83
+ const isType = (value) => value === 'color' || value === 'size' || value === 'font';
84
+ /**
85
+ * The usable variables: a valid name and type, a valid non-empty value, the first of each name.
86
+ * Invalid rows are left out (the save validation reports them), so the output never breaks the CSS.
87
+ */
88
+ export function cleanVariables(list) {
89
+ if (!Array.isArray(list))
90
+ return [];
91
+ const seen = new Set();
92
+ const out = [];
93
+ for (const item of list) {
94
+ if (!item || !isType(item.type) || typeof item.name !== 'string')
95
+ continue;
96
+ const name = item.name.trim();
97
+ if (seen.has(name) || variableNameProblem(name, item.type))
98
+ continue;
99
+ const value = typeof item.value === 'string' ? item.value.trim() : '';
100
+ if (!value || variableValueProblem(value, item.type))
101
+ continue;
102
+ const dark = item.type !== 'font' && typeof item.darkValue === 'string' ? item.darkValue.trim() : '';
103
+ seen.add(name);
104
+ out.push({ name, type: item.type, value, ...(dark && !variableValueProblem(dark, item.type) ? { darkValue: dark } : {}) });
105
+ }
106
+ return out;
107
+ }
108
+ /** Problems of a variables list, by row index: names and values. For the global's validation. */
109
+ export function variablesProblems(list) {
110
+ if (list == null)
111
+ return true;
112
+ if (!Array.isArray(list))
113
+ return 'Variables must be a list.';
114
+ const seen = new Set();
115
+ for (const [index, item] of list.entries()) {
116
+ const row = `Variable ${index + 1}`;
117
+ if (!item || !isType(item.type))
118
+ return `${row}: choose a type.`;
119
+ const nameProblem = variableNameProblem(item.name, item.type);
120
+ if (nameProblem)
121
+ return `${row}: ${nameProblem}`;
122
+ const name = String(item.name).trim();
123
+ if (seen.has(name))
124
+ return `${row}: “${name}” is used twice. Each variable needs its own name.`;
125
+ seen.add(name);
126
+ const valueProblem = variableValueProblem(item.value, item.type) ?? (item.type === 'font' ? null : variableValueProblem(item.darkValue, item.type));
127
+ if (valueProblem)
128
+ return `${row} (${name}): ${valueProblem}`;
129
+ }
130
+ return true;
131
+ }
132
+ /** The CSS value of a variable. Fonts get a fallback stack. */
133
+ export function variableCssValue(variable, value) {
134
+ if (variable.type !== 'font')
135
+ return value;
136
+ return `'${cleanVariableFamily(value)}', sans-serif`;
137
+ }
138
+ /** The font families the variables choose, by font name (`{ display: 'Fraunces' }`). */
139
+ export function variableFontFamilies(list) {
140
+ const out = {};
141
+ for (const variable of cleanVariables(list)) {
142
+ if (variable.type !== 'font')
143
+ continue;
144
+ const family = cleanVariableFamily(variable.value);
145
+ if (family)
146
+ out[variable.name] = family;
147
+ }
148
+ return out;
149
+ }
150
+ /** Light values by custom property, colors and sizes only (fonts come with the theme's fonts). */
151
+ export function variableDeclarations(list, mode = 'light') {
152
+ const out = {};
153
+ for (const variable of cleanVariables(list)) {
154
+ if (variable.type === 'font')
155
+ continue;
156
+ const value = mode === 'dark' ? variable.darkValue : variable.value;
157
+ if (value)
158
+ out[variableProperty(variable)] = variableCssValue(variable, value);
159
+ }
160
+ return out;
161
+ }
162
+ /**
163
+ * The dark values as a rule under the `.dark` class, on the root element and on any element inside
164
+ * it. Empty string without dark values. The selectors beat the theme's `:root:root` rule.
165
+ */
166
+ export function variablesDarkCss(list) {
167
+ const entries = Object.entries(variableDeclarations(list, 'dark'));
168
+ if (entries.length === 0)
169
+ return '';
170
+ return `:root:root.dark, :root:root .dark { ${entries.map(([k, v]) => `${k}: ${v};`).join(' ')} }`;
171
+ }
172
+ /**
173
+ * The `@theme` block both Tailwind compiles add after the app's CSS entry, so `bg-brand`,
174
+ * `p-gutter` and `font-display` exist. Empty string without variables.
175
+ */
176
+ export function variablesThemeCss(list) {
177
+ const variables = cleanVariables(list).toSorted((a, b) => variableProperty(a).localeCompare(variableProperty(b)));
178
+ if (variables.length === 0)
179
+ return '';
180
+ const lines = variables.map((v) => ` ${variableProperty(v)}: var(${variableProperty(v)});`);
181
+ return `\n/* Design variables of the theme (payload-canvas). */\n@theme inline reference {\n${lines.join('\n')}\n}\n`;
182
+ }
183
+ /** The variables as the editor, the AI and the MCP tools see them. */
184
+ export function variableTokens(list) {
185
+ return cleanVariables(list).map((v) => ({
186
+ name: v.name,
187
+ type: v.type,
188
+ property: variableProperty(v),
189
+ value: v.value,
190
+ ...(v.darkValue ? { darkValue: v.darkValue } : {}),
191
+ }));
192
+ }
193
+ // ---------------------------------------------------------------------------------------------
194
+ // Where a variable is used: class strings and custom CSS
195
+ /** Utility roots that take a color, a size or a font. */
196
+ const ROOTS = {
197
+ color: 'bg|text|border(?:-[xytrblse])?|outline|ring|ring-offset|fill|stroke|from|via|to|shadow|inset-shadow|inset-ring|drop-shadow|decoration|accent|caret|divide|placeholder|scrollbar',
198
+ size: '(?:p|m|scroll-p|scroll-m)[xytrblse]?|gap(?:-[xy])?|space-[xy]|w|h|size|min-w|min-h|max-w|max-h|inset(?:-[xy])?|top|right|bottom|left|start|end|basis|indent|translate-[xy]|scroll-[mp][xytrblse]?',
199
+ font: 'font',
200
+ };
201
+ const escape = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
202
+ const patternCache = new Map();
203
+ /** True when one class token (any variant prefix, `-` sign, `!` mark, `/opacity`) uses the variable. */
204
+ export function tokenUsesVariable(token, variable) {
205
+ const key = `${variable.type}:${variable.name}`;
206
+ let pattern = patternCache.get(key);
207
+ if (!pattern) {
208
+ const name = escape(variable.name);
209
+ const property = escape(variableProperty(variable));
210
+ pattern = new RegExp(`^(?:[^\\s:]+:)*!?-?(?:(?:${ROOTS[variable.type]})-${name}(?:\\/[^\\s]+)?!?$|.*${property}(?![\\w-]))`);
211
+ patternCache.set(key, pattern);
212
+ }
213
+ return pattern.test(token);
214
+ }
215
+ /** True when a class string or a CSS text uses the variable (its classes or `var(--color-brand)`). */
216
+ export function textUsesVariable(text, variable) {
217
+ if (!text)
218
+ return false;
219
+ if (new RegExp(`${escape(variableProperty(variable))}(?![\\w-])`).test(text))
220
+ return true;
221
+ return text.split(/\s+/).some((token) => token && tokenUsesVariable(token, variable));
222
+ }
223
+ // ---------------------------------------------------------------------------------------------
224
+ // For the AI assistant and the MCP tools
225
+ /** Example classes of a variable: "bg-brand text-brand border-brand". */
226
+ export const variableClasses = (variable) => VARIABLE_CLASS_EXAMPLES[variable.type].map((root) => `${root}-${variable.name}`).join(' ');
227
+ export const VARIABLES_NOTE = "The site's design variables (Theme > Variables): named colors, sizes and fonts. Prefer them over raw values so the site keeps one look: colors as bg-<name>, text-<name>, border-<name>; sizes as p-<name>, m-<name>, gap-<name>, w-<name>; fonts as font-<name>. In custom CSS use var(<property>). darkValue applies under the .dark class.";
228
+ /** The variables for a tool result: name, type, value, dark value and example classes. */
229
+ export function describeVariables(tokens) {
230
+ return tokens.map((token) => ({ ...token, classes: variableClasses(token) }));
231
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload-canvas",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Payload Canvas: a visual drag-and-drop website builder for Payload CMS 3. Nested layout blocks, Tailwind styling, sections, templates, live AI editing over MCP, and the React renderer for your site.",
5
5
  "keywords": [
6
6
  "payload",
@@ -158,6 +158,8 @@
158
158
  "@lexical/rich-text": "0.50.0",
159
159
  "@lexical/selection": "0.50.0",
160
160
  "@lexical/utils": "0.50.0",
161
+ "embla-carousel-fade": "^8.6.0",
162
+ "embla-carousel-react": "^8.6.0",
161
163
  "lexical": "0.50.0",
162
164
  "motion": "^14.0.0",
163
165
  "react-colorful": "^5.8.1"
@@ -210,7 +212,7 @@
210
212
  "build": "node ../../scripts/build-package.mjs",
211
213
  "typecheck": "tsc --noEmit",
212
214
  "lint": "oxlint",
213
- "test": "node --import tsx --test \"src/**/*.test.ts\"",
215
+ "test": "node --import tsx --import ./test/setup.mjs --test \"src/**/*.test.ts\"",
214
216
  "generate:fonts": "node scripts/generate-google-fonts.mjs"
215
217
  }
216
218
  }
@@ -1,9 +0,0 @@
1
- import type { SiteClass } from '../../../core/types.js';
2
- /** The presets by group, in CSS order. Classes without a group go under "Other" (or no heading when no class has a group). */
3
- export declare function groupSiteClasses(list: readonly SiteClass[]): Array<{
4
- group: string | null;
5
- classes: SiteClass[];
6
- }>;
7
- /** The class list with `name` added at the end, or removed when it is there (without variants). */
8
- export declare function toggleClass(className: string, name: string): string;
9
- export declare function SiteClasses(): import("react").JSX.Element | null;
@@ -1,31 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- // "Site classes": the site's own `@utility` classes (StyleTokens.siteClasses) as presets. A click
4
- // adds the class to the block, or removes it when the block has it, like typing it in Classes.
5
- import { useState } from 'react';
6
- import { useStyles } from './context.js';
7
- import * as I from './icons.js';
8
- /** The presets by group, in CSS order. Classes without a group go under "Other" (or no heading when no class has a group). */
9
- export function groupSiteClasses(list) {
10
- const groups = new Map();
11
- const anyGroup = list.some((c) => c.group);
12
- for (const item of list) {
13
- const key = item.group ?? (anyGroup ? 'Other' : null);
14
- groups.set(key, [...(groups.get(key) ?? []), item]);
15
- }
16
- return [...groups].map(([group, classes]) => ({ group, classes }));
17
- }
18
- /** The class list with `name` added at the end, or removed when it is there (without variants). */
19
- export function toggleClass(className, name) {
20
- const list = className.split(/\s+/).filter(Boolean);
21
- return (list.includes(name) ? list.filter((c) => c !== name) : [...list, name]).join(' ');
22
- }
23
- export function SiteClasses() {
24
- const { tokens, className, setClassName } = useStyles();
25
- const list = tokens.siteClasses ?? [];
26
- const [open, setOpen] = useState(() => list.some((c) => className.split(/\s+/).includes(c.name)));
27
- if (list.length === 0)
28
- return null;
29
- const own = new Set(className.split(/\s+/));
30
- return (_jsxs("section", { className: "builder-styles__section", "data-open": open, children: [_jsxs("button", { type: "button", className: "builder-styles__section-head", "aria-expanded": open, onClick: () => setOpen(!open), children: [_jsx("span", { className: "builder-styles__chevron", children: _jsx(I.ChevronIcon, {}) }), "Site classes", list.some((c) => own.has(c.name)) && _jsx("span", { className: "builder-styles__dot", "data-tooltip": "The block uses a site class" })] }), open && (_jsx("div", { className: "builder-styles__section-body", children: groupSiteClasses(list).map(({ group, classes }) => (_jsxs("fieldset", { className: "builder-styles__presets", "aria-label": group ? undefined : 'Site classes', children: [group && _jsx("legend", { className: "builder-styles__presets-title", children: group }), _jsx("div", { className: "builder-styles__presets-list", children: classes.map((item) => (_jsxs("button", { type: "button", className: "builder-styles__preset", "aria-pressed": own.has(item.name), "data-tooltip": item.css ? `.${item.name} { ${item.css} }` : `.${item.name}`, onClick: () => setClassName(toggleClass(className, item.name)), children: [_jsx("span", { className: "builder-styles__preset-label", children: item.label ?? item.name }), item.label && _jsx("code", { className: "builder-styles__preset-name", children: item.name })] }, item.name))) })] }, group ?? ''))) }))] }));
31
- }
@@ -1,15 +0,0 @@
1
- import { headingId } from '../../core/headings.js';
2
- export { headingId };
3
- /** One entry of a table of contents. */
4
- export type RichTextHeading = {
5
- id: string;
6
- text: string;
7
- };
8
- /** The plain text of one Lexical node and its children, with whitespace runs as one space. */
9
- export declare function lexicalText(node: unknown): string;
10
- /**
11
- * The top-level headings of one level (default `h2`) of Lexical rich text, with the same ids the
12
- * rendered rich text gives them (`richTextHeadings`: repeated texts get "-2", "-3"). Headings
13
- * without letters or digits are left out.
14
- */
15
- export declare function lexicalHeadings(value: unknown, tag?: string): RichTextHeading[];
@@ -1,36 +0,0 @@
1
- // Heading ids shared by the tableOfContents block and the rich text that holds the headings, so a
2
- // table of contents link (`#id`) finds its heading. Pure and client-safe. The ids come from
3
- // `richTextHeadings` in core, which the field and richText blocks (`headingIds`) use too.
4
- import { headingId, richTextHeadings } from '../../core/headings.js';
5
- export { headingId };
6
- function collect(node, parts) {
7
- if (!node || typeof node !== 'object')
8
- return;
9
- const { text, children } = node;
10
- if (typeof text === 'string')
11
- parts.push(text);
12
- if (Array.isArray(children))
13
- for (const child of children)
14
- collect(child, parts);
15
- }
16
- /** The plain text of one Lexical node and its children, with whitespace runs as one space. */
17
- export function lexicalText(node) {
18
- const parts = [];
19
- collect(node, parts);
20
- return parts.join('').replace(/\s+/g, ' ').trim();
21
- }
22
- /**
23
- * The top-level headings of one level (default `h2`) of Lexical rich text, with the same ids the
24
- * rendered rich text gives them (`richTextHeadings`: repeated texts get "-2", "-3"). Headings
25
- * without letters or digits are left out.
26
- */
27
- export function lexicalHeadings(value, tag = 'h2') {
28
- const children = value?.root?.children;
29
- if (!Array.isArray(children))
30
- return [];
31
- const level = Number(tag.slice(1)) || 2;
32
- const topLevel = new Set(children);
33
- return richTextHeadings(value)
34
- .filter((heading) => heading.level === level && topLevel.has(heading.node) && headingId(heading.text))
35
- .map((heading) => ({ id: heading.id, text: lexicalText(heading.node) }));
36
- }
@@ -1,43 +0,0 @@
1
- import type { BlockDefinition } from '../../core/types.js';
2
- export declare const LIGHTBOX_BLOCK = "lightbox";
3
- /**
4
- * Leaves an image out of every lightbox set: put it on the image or on an element round it. A click
5
- * on a skipped image still opens the set, at the photo with the same `src`. Use it for a large
6
- * photo that repeats one of the set's thumbnails.
7
- */
8
- export declare const LIGHTBOX_SKIP_ATTRIBUTE = "data-lightbox-skip";
9
- /**
10
- * The event a lightbox sends when it closes, to the page image of the photo it showed last. It
11
- * bubbles; `detail.index` is the photo's place in the set. An image switcher can show that photo.
12
- */
13
- export declare const LIGHTBOX_CLOSE_EVENT = "lightbox-close";
14
- /**
15
- * Classes the lightbox component adds itself: the position and size of the dialog and its
16
- * controls. No colours: those come from the block's className (see `LIGHTBOX_CLASS`).
17
- */
18
- export declare const LIGHTBOX_CLASS_MAP: {
19
- root: string;
20
- /** `touch-pan-y`: a sideways swipe reaches the script as pointer events (pinch zoom still works). */
21
- dialog: string;
22
- /** One grid cell: the photo that leaves and the photo that comes in stack in it. */
23
- figure: string;
24
- photo: string;
25
- /** Shown when the photo takes longer than a moment to load. Its colour is the dialog's text colour. */
26
- loading: string;
27
- count: string;
28
- caption: string;
29
- hidden: string;
30
- button: string;
31
- close: string;
32
- previous: string;
33
- next: string;
34
- icon: string;
35
- };
36
- /** The lightbox's control labels and their English defaults. */
37
- export declare const LIGHTBOX_LABELS: {
38
- closeLabel: string;
39
- previousLabel: string;
40
- nextLabel: string;
41
- countLabel: string;
42
- };
43
- export declare function lightboxBlock(): BlockDefinition;
@@ -1,93 +0,0 @@
1
- import { defineBlock } from '../../core/blocks.js';
2
- import { classesOf, classMap, labelsField, labelsHelp } from './shared.js';
3
- export const LIGHTBOX_BLOCK = 'lightbox';
4
- /**
5
- * Leaves an image out of every lightbox set: put it on the image or on an element round it. A click
6
- * on a skipped image still opens the set, at the photo with the same `src`. Use it for a large
7
- * photo that repeats one of the set's thumbnails.
8
- */
9
- export const LIGHTBOX_SKIP_ATTRIBUTE = 'data-lightbox-skip';
10
- /**
11
- * The event a lightbox sends when it closes, to the page image of the photo it showed last. It
12
- * bubbles; `detail.index` is the photo's place in the set. An image switcher can show that photo.
13
- */
14
- export const LIGHTBOX_CLOSE_EVENT = 'lightbox-close';
15
- /**
16
- * Classes the lightbox component adds itself: the position and size of the dialog and its
17
- * controls. No colours: those come from the block's className (see `LIGHTBOX_CLASS`).
18
- */
19
- export const LIGHTBOX_CLASS_MAP = classMap({
20
- root: '[&_img:not([data-lightbox-photo])]:cursor-zoom-in',
21
- /** `touch-pan-y`: a sideways swipe reaches the script as pointer events (pinch zoom still works). */
22
- dialog: 'fixed inset-0 m-0 size-full max-h-none max-w-none touch-pan-y touch-pinch-zoom overflow-hidden bg-transparent p-0',
23
- /** One grid cell: the photo that leaves and the photo that comes in stack in it. */
24
- figure: 'm-0 box-border grid size-full grid-cols-1 grid-rows-1 place-items-center p-4 md:p-16',
25
- photo: 'col-start-1 row-start-1 max-h-full max-w-full object-contain',
26
- /** Shown when the photo takes longer than a moment to load. Its colour is the dialog's text colour. */
27
- loading: 'pointer-events-none absolute inset-0 m-auto size-8 animate-spin rounded-full border-2 border-current border-r-transparent',
28
- count: 'pointer-events-none absolute top-4 left-4 inline-flex min-h-11 items-center px-1',
29
- caption: 'absolute inset-x-0 bottom-4 px-16 text-center',
30
- hidden: 'sr-only',
31
- button: 'absolute inline-flex cursor-pointer items-center justify-center',
32
- close: 'top-4 right-4',
33
- previous: 'top-1/2 left-4 -translate-y-1/2',
34
- next: 'top-1/2 right-4 -translate-y-1/2',
35
- icon: 'size-5',
36
- });
37
- /** The lightbox's control labels and their English defaults. */
38
- export const LIGHTBOX_LABELS = {
39
- closeLabel: 'Close',
40
- previousLabel: 'Previous photo',
41
- nextLabel: 'Next photo',
42
- countLabel: '{n} of {count}',
43
- };
44
- const LABEL_NAMES = { closeLabel: 'Close button', previousLabel: 'Previous button', nextLabel: 'Next button', countLabel: 'Photo number' };
45
- const LIGHTBOX_CLASS = 'grid grid-cols-2 gap-3 md:grid-cols-3 [&_dialog]:text-white [&_dialog]:backdrop:bg-black/85 ' +
46
- '[&_[data-lightbox-button]]:size-11 [&_[data-lightbox-button]]:rounded-full [&_[data-lightbox-button]]:bg-black/50';
47
- export function lightboxBlock() {
48
- return defineBlock({
49
- type: LIGHTBOX_BLOCK,
50
- label: 'Lightbox',
51
- icon: 'image',
52
- category: 'Media',
53
- fields: [
54
- { name: 'label', type: 'text', label: 'Label for screen readers', defaultValue: 'Photos', localized: true },
55
- {
56
- name: 'group',
57
- type: 'text',
58
- label: 'Group',
59
- admin: { description: 'Lightboxes with the same group on a page open as one set. Optional.' },
60
- },
61
- { name: 'captions', type: 'checkbox', label: 'Show the alt text as a caption', defaultValue: false },
62
- { name: 'count', type: 'checkbox', label: 'Show the photo number', defaultValue: true },
63
- labelsField(LIGHTBOX_LABELS, LABEL_NAMES),
64
- ],
65
- slots: { children: { label: 'Content' } },
66
- defaultClassName: LIGHTBOX_CLASS,
67
- classes: classesOf(LIGHTBOX_CLASS_MAP),
68
- ai: {
69
- description: 'A container whose images open full screen in a modal dialog: a click, or Enter on a focused image. Arrow keys, a ' +
70
- 'sideways swipe on touch screens and the arrow buttons step through the images; Escape closes. Lightboxes with the same "group" open as one set; ' +
71
- 'each photo shows once in a set (by its src). The dialog fades in and out and the photos slide when they step (fades only under reduced motion). ' +
72
- '"count" (default on) shows "2 of 6" at the top left. Lay out the ' +
73
- 'images with its className (a grid), or put a repeat of images in it (path "galleryImages", image bound to "$item"). ' +
74
- 'Style the dialog from the className: [&_dialog]: for its text colour and backdrop ([&_dialog]:backdrop:bg-black/85), ' +
75
- '[&_[data-lightbox-button]]: for the close, previous and next buttons, [&_[data-lightbox-photo]]: for the large photo, ' +
76
- '[&_[data-lightbox-count]]: for the photo number, [&_[data-lightbox-loading]]: for the ring shown while a photo loads. ' +
77
- 'The canvas does not open it.' +
78
- labelsHelp(LIGHTBOX_LABELS) +
79
- ' In "countLabel", {n} is the photo number and {count} the number of photos.',
80
- example: {
81
- type: LIGHTBOX_BLOCK,
82
- props: { label: 'Gallery' },
83
- className: LIGHTBOX_CLASS,
84
- slots: {
85
- children: [
86
- { id: 'b_example_1', type: 'image', props: { image: 1, alt: 'The lounge' }, className: 'aspect-square w-full object-cover' },
87
- { id: 'b_example_2', type: 'image', props: { image: 2, alt: 'The terrace' }, className: 'aspect-square w-full object-cover' },
88
- ],
89
- },
90
- },
91
- },
92
- });
93
- }
@@ -1,11 +0,0 @@
1
- import type { BlockDefinition } from '../../core/types.js';
2
- export declare const MEDIA_BACKDROP_BLOCK = "mediaBackdrop";
3
- /**
4
- * Classes the backdrop component adds to the media and the overlay: they fill the block behind
5
- * its content. The block itself needs `relative isolate` (in its default className).
6
- */
7
- export declare const MEDIA_BACKDROP_CLASS_MAP: {
8
- media: string;
9
- overlay: string;
10
- };
11
- export declare function mediaBackdropBlock(mediaCollection?: string): BlockDefinition;