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,381 @@
1
+ // The classes field of the Styles panel, the class banner, the custom CSS box and the class
2
+ // dialogs. Payload CSS variables only, no Tailwind (it would leak into the admin).
3
+
4
+ @layer payload-default {
5
+ .builder-classes {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: 6px;
9
+ margin: 0 0 10px;
10
+
11
+ .builder-styles__raw-input {
12
+ min-height: 52px;
13
+ }
14
+ }
15
+
16
+ .builder-classes__head {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: space-between;
20
+ min-height: 20px;
21
+ }
22
+
23
+ .builder-classes__menu {
24
+ display: grid;
25
+ place-items: center;
26
+ width: 22px;
27
+ height: 20px;
28
+ margin-right: -3px;
29
+ padding: 0;
30
+ border: 0;
31
+ border-radius: var(--style-radius-s, 4px);
32
+ background: none;
33
+ color: var(--bs-muted);
34
+ cursor: pointer;
35
+
36
+ &:hover,
37
+ &[data-popup-open] {
38
+ background: var(--theme-elevation-100);
39
+ color: var(--theme-text);
40
+ }
41
+
42
+ &:focus-visible {
43
+ outline: 2px solid var(--bs-accent);
44
+ outline-offset: 1px;
45
+ }
46
+ }
47
+
48
+ // -------------------------------------------------------------------------
49
+ // The classes field: chips and an input in one box that looks like an input
50
+ // -------------------------------------------------------------------------
51
+
52
+ .builder-classfield {
53
+ display: flex;
54
+ flex-wrap: wrap;
55
+ align-items: center;
56
+ gap: 4px;
57
+ min-height: var(--bs-h);
58
+ padding: 2px;
59
+ border: 1px solid var(--bs-border);
60
+ border-radius: var(--style-radius-s, 4px);
61
+ background: var(--theme-input-bg, var(--theme-elevation-0));
62
+
63
+ &:hover {
64
+ border-color: var(--theme-elevation-250);
65
+ }
66
+
67
+ &:focus-within {
68
+ border-color: var(--bs-accent);
69
+ box-shadow: 0 0 0 1px var(--bs-accent);
70
+ }
71
+ }
72
+
73
+ .builder-classfield__chip {
74
+ display: inline-flex;
75
+ align-items: center;
76
+ min-width: 0;
77
+ max-width: 100%;
78
+ height: 20px;
79
+ border-radius: 3px;
80
+ font-size: var(--be-text-s);
81
+ line-height: 1;
82
+ }
83
+
84
+ .builder-classfield__chip-main {
85
+ display: inline-flex;
86
+ align-items: center;
87
+ gap: 5px;
88
+ min-width: 0;
89
+ height: 100%;
90
+ padding: 0 2px 0 6px;
91
+ border: 0;
92
+ border-radius: inherit;
93
+ background: none;
94
+ color: inherit;
95
+ font: inherit;
96
+ cursor: pointer;
97
+
98
+ &:focus-visible {
99
+ outline: 2px solid var(--bs-accent);
100
+ outline-offset: 0;
101
+ }
102
+ }
103
+
104
+ .builder-classfield__chip-name {
105
+ overflow: hidden;
106
+ text-overflow: ellipsis;
107
+ white-space: nowrap;
108
+ }
109
+
110
+ .builder-classfield__chip-code {
111
+ color: var(--bs-muted);
112
+ font-family: var(--font-mono, ui-monospace, monospace);
113
+ }
114
+
115
+ .builder-classfield__remove {
116
+ display: grid;
117
+ flex: none;
118
+ place-items: center;
119
+ width: 18px;
120
+ height: 100%;
121
+ padding: 0;
122
+ border: 0;
123
+ border-radius: 0 3px 3px 0;
124
+ background: none;
125
+ color: inherit;
126
+ opacity: 0.55;
127
+ cursor: pointer;
128
+
129
+ svg {
130
+ width: 12px;
131
+ height: 12px;
132
+ }
133
+
134
+ &:hover,
135
+ &:focus-visible {
136
+ opacity: 1;
137
+ }
138
+
139
+ &:focus-visible {
140
+ outline: 2px solid var(--bs-accent);
141
+ outline-offset: -2px;
142
+ }
143
+ }
144
+
145
+ // An editable class: a solid chip in the text font. Chosen (the controls edit it): the accent.
146
+ .builder-classfield__chip--class {
147
+ background: var(--theme-elevation-150);
148
+ color: var(--theme-text);
149
+ font-weight: var(--be-weight-strong);
150
+
151
+ &:hover {
152
+ background: var(--theme-elevation-200);
153
+ }
154
+
155
+ &[data-selected] {
156
+ background: var(--bs-accent);
157
+ color: var(--theme-elevation-0);
158
+ }
159
+ }
160
+
161
+ .builder-classfield__draft-dot {
162
+ flex: none;
163
+ width: 6px;
164
+ height: 6px;
165
+ border-radius: 50%;
166
+ background: var(--theme-warning-500, #d97706);
167
+ box-shadow: 0 0 0 1.5px var(--theme-elevation-0);
168
+ }
169
+
170
+ // A class no control shows: quiet, in monospace, as the code writes it.
171
+ .builder-classfield__chip--raw {
172
+ box-shadow: inset 0 0 0 1px var(--bs-border);
173
+ color: var(--theme-elevation-700, var(--bs-muted));
174
+ font-family: var(--font-mono, ui-monospace, monospace);
175
+
176
+ &:hover {
177
+ background: var(--theme-elevation-50);
178
+ color: var(--theme-text);
179
+ }
180
+
181
+ // Not in the theme's class list: probably a typo.
182
+ &[data-unknown] {
183
+ background: color-mix(in srgb, var(--theme-warning-500, #b7791f) 10%, transparent);
184
+ box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--theme-warning-500, #b7791f) 60%, transparent);
185
+
186
+ .builder-classfield__chip-name {
187
+ text-decoration: wavy underline var(--theme-warning-500, #b7791f);
188
+ text-underline-offset: 3px;
189
+ }
190
+ }
191
+ }
192
+
193
+ .builder-classfield__input,
194
+ .builder-classfield__edit {
195
+ height: 20px;
196
+ padding: 0 4px;
197
+ border: 0;
198
+ background: none;
199
+ color: var(--theme-text);
200
+ font-family: var(--font-mono, ui-monospace, monospace);
201
+ font-size: var(--be-text-s);
202
+ outline: 0;
203
+
204
+ &::placeholder {
205
+ color: var(--bs-dim);
206
+ font-family: var(--font-body, inherit);
207
+ }
208
+ }
209
+
210
+ .builder-classfield__input {
211
+ flex: 1 0 56px;
212
+ min-width: 56px;
213
+ }
214
+
215
+ // A quiet chip while it is edited in place.
216
+ .builder-classfield__edit {
217
+ field-sizing: content;
218
+ min-width: 40px;
219
+ max-width: 100%;
220
+ border-radius: 3px;
221
+ box-shadow: inset 0 0 0 1px var(--bs-accent);
222
+ }
223
+
224
+ // While a class is edited: the classes in it that no control shows.
225
+ .builder-classes__extras {
226
+ display: flex;
227
+ flex-direction: column;
228
+ gap: 4px;
229
+ margin-top: 14px;
230
+ }
231
+
232
+ // -------------------------------------------------------------------------
233
+ // The class being edited
234
+ // -------------------------------------------------------------------------
235
+
236
+ .builder-classes__banner {
237
+ display: flex;
238
+ flex-direction: column;
239
+ gap: 3px;
240
+ padding: 8px 10px;
241
+ border: 1px solid color-mix(in srgb, var(--bs-accent) 45%, var(--bs-border));
242
+ border-radius: var(--style-radius-m, 6px);
243
+ background: color-mix(in srgb, var(--bs-accent) 7%, var(--theme-elevation-0));
244
+ }
245
+
246
+ .builder-classes__banner-head {
247
+ display: flex;
248
+ align-items: center;
249
+ justify-content: space-between;
250
+ gap: 6px;
251
+ }
252
+
253
+ .builder-classes__title {
254
+ margin: 0;
255
+ font-weight: var(--be-weight-strong);
256
+
257
+ code {
258
+ color: var(--bs-accent-text);
259
+ font-size: var(--be-text-m);
260
+ }
261
+ }
262
+
263
+ .builder-classes__close {
264
+ display: grid;
265
+ flex: none;
266
+ place-items: center;
267
+ width: 20px;
268
+ height: 20px;
269
+ margin: -2px -4px -2px 0;
270
+ padding: 0;
271
+ border: 0;
272
+ border-radius: var(--style-radius-s, 4px);
273
+ background: none;
274
+ color: var(--bs-muted);
275
+ cursor: pointer;
276
+
277
+ svg {
278
+ width: 14px;
279
+ height: 14px;
280
+ }
281
+
282
+ &:hover {
283
+ background: color-mix(in srgb, var(--bs-accent) 12%, transparent);
284
+ color: var(--theme-text);
285
+ }
286
+
287
+ &:focus-visible {
288
+ outline: 2px solid var(--bs-accent);
289
+ outline-offset: 1px;
290
+ }
291
+ }
292
+
293
+ .builder-classes__text {
294
+ margin: 0;
295
+ color: var(--theme-elevation-750, var(--theme-text));
296
+ }
297
+
298
+ .builder-classes__foot {
299
+ display: flex;
300
+ align-items: center;
301
+ gap: 6px;
302
+ margin-top: 4px;
303
+
304
+ .builder-styles__button--primary:disabled {
305
+ opacity: 0.45;
306
+ cursor: default;
307
+ }
308
+ }
309
+
310
+ .builder-classes__state {
311
+ flex: 1;
312
+ min-width: 0;
313
+ color: var(--bs-muted);
314
+ font-size: var(--be-text-s);
315
+ line-height: 1.35;
316
+
317
+ &[data-state='error'] {
318
+ color: var(--theme-error-500);
319
+ }
320
+ }
321
+
322
+ .builder-classes__css {
323
+ display: flex;
324
+ flex-direction: column;
325
+ gap: 4px;
326
+ margin-top: 14px;
327
+
328
+ .builder-styles__hint {
329
+ margin: 0;
330
+ font-size: var(--be-text-s);
331
+ }
332
+ }
333
+
334
+ .builder-styles__raw-input.builder-classes__css-input {
335
+ height: auto;
336
+ min-height: 104px;
337
+ padding: 6px 8px;
338
+ font-family: var(--font-mono, ui-monospace, monospace);
339
+ font-size: var(--be-text-s);
340
+ line-height: 1.5;
341
+ white-space: pre;
342
+ tab-size: 2;
343
+ resize: vertical;
344
+
345
+ &[aria-invalid='true'] {
346
+ border-color: var(--theme-error-500);
347
+ }
348
+ }
349
+
350
+ // -------------------------------------------------------------------------
351
+ // Dialogs (Payload's modal: outside the editor root, so no editor variables)
352
+ // -------------------------------------------------------------------------
353
+
354
+ .builder-classes__dialog-fields {
355
+ display: flex;
356
+ flex-direction: column;
357
+ gap: 16px;
358
+ width: 100%;
359
+ min-width: min(420px, 80vw);
360
+ }
361
+
362
+ .builder-classes__dialog-intro {
363
+ margin: 0;
364
+ color: var(--theme-elevation-600);
365
+ }
366
+
367
+ .builder-classes__dialog-styles {
368
+ display: block;
369
+ padding: 6px 8px;
370
+ border-radius: var(--style-radius-s, 4px);
371
+ background: var(--theme-elevation-50);
372
+ font-family: var(--font-mono, ui-monospace, monospace);
373
+ font-size: 12px;
374
+ overflow-wrap: anywhere;
375
+ }
376
+
377
+ .builder-classes__dialog-error {
378
+ margin: -8px 0 0;
379
+ color: var(--theme-error-500);
380
+ }
381
+ }
@@ -1,18 +1,26 @@
1
1
  import { type Breakpoint, type StyleTokens, type Variant } from '../../../core/index.js';
2
+ import type { BuilderClass } from '../../../classes/shared.js';
3
+ import type { ClassesController } from '../classes/controller.js';
2
4
  import type { ValueStore } from '../valueStore.js';
3
5
  import type { Runtime } from '../runtime.js';
4
6
  import { type StyleReader } from './model.js';
5
- /** What the Styles panel edits: a block's `className`, or with `slot`, that slot's `slotClassName`. */
7
+ /** What the Styles panel edits: a block's `className`, or with `part`, that part's `partClassName` (`blockParts`). */
6
8
  export type StyleTarget = {
7
9
  blockId: string;
8
- slot?: string | null;
10
+ part?: string | null;
9
11
  };
10
12
  export type StylesContextValue = {
11
13
  blockId: string;
12
- /** The slot whose own classes the panel edits. Null: the block's `className`. */
13
- slot: string | null;
14
+ /** The part (a styled slot or a `parts` entry) whose classes the panel edits. Null: the block's `className`. */
15
+ part: string | null;
14
16
  /** The block type: it picks the style groups that open by default. */
15
17
  blockType: string;
18
+ /**
19
+ * The editable class the panel edits instead of the block (its `styles`), or null. Every
20
+ * control then reads and writes the class: every block that uses it changes.
21
+ */
22
+ editingClass: BuilderClass | null;
23
+ /** The classes the panel edits: the block's (or part's), or the edited class's `styles`. */
16
24
  className: string;
17
25
  variant: Variant;
18
26
  tokens: StyleTokens;
@@ -28,8 +36,6 @@ export type StylesContextValue = {
28
36
  set: (property: string, value: string | null, options?: {
29
37
  negative?: boolean;
30
38
  }) => void;
31
- /** Replaces the whole className (raw classes field). */
32
- setClassName: (className: string, mergeKey?: string) => void;
33
39
  /** Last refused value ("lg" is not a text color), shown under the variant bar. */
34
40
  error: ValueStore<string | null>;
35
41
  };
@@ -40,3 +46,10 @@ export declare function writeClassName(runtime: Runtime, target: StyleTarget, ne
40
46
  export declare function writeStyle(runtime: Runtime, target: StyleTarget, variant: Variant, tokens: StyleTokens, property: string, value: string | null, options?: {
41
47
  negative?: boolean;
42
48
  }): string | null;
49
+ /**
50
+ * Sets one property of an editable class's styles at a variant, like `writeStyle` does for a
51
+ * block. Returns an error message when the class model refuses the value.
52
+ */
53
+ export declare function writeClassStyle(classes: ClassesController, id: string | number, variant: Variant, tokens: StyleTokens, property: string, value: string | null, options?: {
54
+ negative?: boolean;
55
+ }): string | null;
@@ -10,18 +10,18 @@ export function useStyles() {
10
10
  return value;
11
11
  }
12
12
  /** Reads the latest classes from the store, so two edits in one frame never overwrite each other. */
13
- function currentClassName(runtime, { blockId, slot }) {
13
+ function currentClassName(runtime, { blockId, part }) {
14
14
  const block = findBlock(runtime.store.getState().layout, blockId);
15
- return (slot ? block?.slotClassName?.[slot] : block?.className) ?? '';
15
+ return (part ? block?.partClassName?.[part] : block?.className) ?? '';
16
16
  }
17
17
  export function writeClassName(runtime, target, next, mergeKey) {
18
18
  // One space between classes: double spaces from typing never reach the stored value.
19
19
  const normalized = next.trim().replace(/\s+/g, ' ');
20
20
  if (normalized === currentClassName(runtime, target))
21
21
  return;
22
- const { blockId, slot } = target;
23
- const op = slot
24
- ? { type: 'update', id: blockId, slotClassName: { [slot]: normalized || null } }
22
+ const { blockId, part } = target;
23
+ const op = part
24
+ ? { type: 'update', id: blockId, partClassName: { [part]: normalized || null } }
25
25
  : { type: 'update', id: blockId, className: normalized || null };
26
26
  runtime.store.apply(op, { mergeKey });
27
27
  }
@@ -38,6 +38,24 @@ export function writeStyle(runtime, target, variant, tokens, property, value, op
38
38
  if (next === before)
39
39
  return null;
40
40
  // Edits to one property at one variant within a second become one undo step (sliders, typing).
41
- writeClassName(runtime, target, next, `style:${target.blockId}:${target.slot ?? ''}:${property}:${variantKey(variant)}`);
41
+ writeClassName(runtime, target, next, `style:${target.blockId}:${target.part ?? ''}:${property}:${variantKey(variant)}`);
42
+ return null;
43
+ }
44
+ /**
45
+ * Sets one property of an editable class's styles at a variant, like `writeStyle` does for a
46
+ * block. Returns an error message when the class model refuses the value.
47
+ */
48
+ export function writeClassStyle(classes, id, variant, tokens, property, value, options) {
49
+ const before = classes.byId(id)?.styles ?? '';
50
+ let next;
51
+ try {
52
+ next = setStyleValue(before, property, variant, value, { ...options, tokens });
53
+ }
54
+ catch (error) {
55
+ return error instanceof Error ? error.message : String(error);
56
+ }
57
+ if (next === before)
58
+ return null;
59
+ classes.edit(id, 'styles', next || null, `class:${id}:${property}:${variantKey(variant)}`);
42
60
  return null;
43
61
  }
@@ -49,7 +49,9 @@ export declare function AutoControl({ prop }: {
49
49
  }): import("react").JSX.Element | null;
50
50
  /** Suggestions for a value input, from the property kind. */
51
51
  export declare function suggestionsFor(def: StylePropertyDef, tokens: StyleTokens): Suggestion[];
52
- /** Spacing scale keys with their pixel size: "4 · 16px". */
52
+ /** The theme's design variables of one type, with their values, under "Variables". */
53
+ export declare function variableSuggestions(tokens: StyleTokens, type: 'color' | 'size' | 'font'): Suggestion[];
54
+ /** Spacing scale keys with their pixel size: "4 · 16px". The size variables come first. */
53
55
  export declare function spacingSuggestions(tokens: StyleTokens): Suggestion[];
54
56
  export declare function tokenSuggestions(tokens: StyleTokens, def: StylePropertyDef): Suggestion[];
55
57
  /** Width and height values: keywords, fractions, then the spacing scale. Max width adds containers. */
@@ -47,7 +47,7 @@ function useEditBreakpoint() {
47
47
  */
48
48
  export function OverrideMark({ prop }) {
49
49
  const runtime = useRuntime();
50
- const { blockId, slot, tokens, error } = useStyles();
50
+ const { blockId, part, tokens, error } = useStyles();
51
51
  const { def, override } = useProp(prop);
52
52
  const edit = useEditBreakpoint();
53
53
  const pop = usePopover('auto');
@@ -60,7 +60,7 @@ export function OverrideMark({ prop }) {
60
60
  edit(breakpoint);
61
61
  }, children: ["Edit ", breakpoint] }), _jsxs("button", { type: "button", className: "builder-styles__button", onClick: () => {
62
62
  pop.hide();
63
- error.set(writeStyle(runtime, { blockId, slot }, override.variant, tokens, prop, null));
63
+ error.set(writeStyle(runtime, { blockId, part }, override.variant, tokens, prop, null));
64
64
  }, children: ["Remove ", override.className] })] })] })] }));
65
65
  }
66
66
  /** True when any of `props` has a value at the current variant (set, from a shorthand, or inherited). */
@@ -153,31 +153,49 @@ function cached(owner, key, build) {
153
153
  map.set(key, (list = build()));
154
154
  return list;
155
155
  }
156
- /** Spacing scale keys with their pixel size: "4 · 16px". */
156
+ /** The theme's design variables of one type, with their values, under "Variables". */
157
+ export function variableSuggestions(tokens, type) {
158
+ return (tokens.variables ?? []).filter((v) => v.type === type).map((v) => ({ value: v.name, hint: shortValue(v.value), group: 'Variables' }));
159
+ }
160
+ /** The variables first, then the other values (without the variables) under `group`. */
161
+ function variablesFirst(variables, rest, group) {
162
+ if (variables.length === 0)
163
+ return rest;
164
+ const names = new Set(variables.map((v) => v.value));
165
+ return [...variables, ...rest.filter((s) => !names.has(s.value)).map((s) => ({ ...s, group: s.group ?? group }))];
166
+ }
167
+ /** Spacing scale keys with their pixel size: "4 · 16px". The size variables come first. */
157
168
  export function spacingSuggestions(tokens) {
158
- return cached(tokens, 'spacing', () => tokens.spacing.map((key) => {
169
+ return cached(tokens, 'spacing', () => variablesFirst(variableSuggestions(tokens, 'size'), tokens.spacing.map((key) => {
159
170
  if (key === 'px')
160
171
  return { value: key, hint: '1px' };
161
172
  const n = Number(key);
162
173
  return { value: key, hint: Number.isFinite(n) ? `${n * 4}px` : undefined };
163
- }));
174
+ }), 'Scale'));
164
175
  }
165
176
  export function tokenSuggestions(tokens, def) {
166
177
  const list = def.tokens ? tokens[def.tokens] : undefined;
167
178
  if (!list)
168
179
  return [];
169
- return cached(tokens, `token:${def.tokens}`, () => list.map((t) => ({ value: t.name, hint: shortValue(t.value) })));
180
+ return cached(tokens, `token:${def.tokens}`, () => {
181
+ const all = list.map((t) => ({ value: t.name, hint: shortValue(t.value) }));
182
+ return def.tokens === 'fonts' ? variablesFirst(variableSuggestions(tokens, 'font'), all, 'Theme') : all;
183
+ });
170
184
  }
171
185
  const SIZE_KEYWORDS = ['auto', 'full', 'screen', 'svh', 'dvh', 'fit', 'min', 'max', 'px'];
172
186
  const FRACTIONS = ['1/2', '1/3', '2/3', '1/4', '3/4', '1/5', '2/5', '3/5', '4/5', '1/6', '5/6'];
173
187
  /** Width and height values: keywords, fractions, then the spacing scale. Max width adds containers. */
174
188
  export function sizeSuggestions(tokens, withContainers) {
175
- return cached(tokens, `size:${withContainers}`, () => [
176
- ...SIZE_KEYWORDS.map((value) => ({ value })),
177
- ...(withContainers ? tokens.containers.map((t) => ({ value: t.name, hint: shortValue(t.value) })) : []),
178
- ...FRACTIONS.map((value) => ({ value })),
179
- ...spacingSuggestions(tokens).filter((s) => s.value !== 'px'),
180
- ]);
189
+ return cached(tokens, `size:${withContainers}`, () => {
190
+ const variables = variableSuggestions(tokens, 'size');
191
+ const names = new Set(variables.map((v) => v.value));
192
+ return variablesFirst(variables, [
193
+ ...SIZE_KEYWORDS.map((value) => ({ value })),
194
+ ...(withContainers ? tokens.containers.map((t) => ({ value: t.name, hint: shortValue(t.value) })) : []),
195
+ ...FRACTIONS.map((value) => ({ value })),
196
+ ...spacingSuggestions(tokens).filter((s) => s.value !== 'px' && !names.has(s.value)).map(({ group: _group, ...s }) => s),
197
+ ], 'Sizes');
198
+ });
181
199
  }
182
200
  function shortValue(value) {
183
201
  return value.length > 28 ? `${value.slice(0, 26)}…` : value;
@@ -30,9 +30,15 @@ export declare function Popover({ ref, mode, onOpenChange, className, children,
30
30
  children: ReactNode;
31
31
  label?: string;
32
32
  }): import("react").JSX.Element;
33
+ /**
34
+ * `label`: shown instead of the value, which then shows small next to it (a site class's label).
35
+ * `group`: a heading over a run of items with the same group.
36
+ */
33
37
  export type Suggestion = {
34
38
  value: string;
35
39
  hint?: string;
40
+ label?: string;
41
+ group?: string;
36
42
  };
37
43
  /** Listbox under a combobox input. Items use `onMouseDown` so the input keeps focus. */
38
44
  export declare function SuggestList({ items, active, onPick, onHover, }: {
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  // For a list of actions, use `MenuButton` from `../menu/Menu` instead: it adds keyboard
7
7
  // navigation. This hook is for popovers with their own content (pickers, forms, combobox lists).
8
8
  /* oxlint-disable jsx-a11y/prefer-tag-over-role, jsx-a11y/no-noninteractive-element-to-interactive-role -- a native select cannot be a combobox popup, so the list uses listbox/option roles */
9
- import { useCallback, useEffect, useRef, useState } from 'react';
9
+ import { Fragment, useCallback, useEffect, useRef, useState } from 'react';
10
10
  import { onDismissMenus } from '../menu/dismiss.js';
11
11
  const GAP = 4;
12
12
  const MARGIN = 8;
@@ -134,10 +134,10 @@ const scrollIntoView = (el) => el?.scrollIntoView({ block: 'nearest' });
134
134
  export function SuggestList({ items, active, onPick, onHover, }) {
135
135
  if (items.length === 0)
136
136
  return _jsx("p", { className: "builder-styles__suggest-empty", children: "No matches" });
137
- return (_jsx("ul", { className: "builder-styles__suggest", role: "listbox", children: items.map((item, i) => (_jsxs("li", { ref: i === active ? scrollIntoView : undefined, role: "option", "aria-selected": i === active, className: "builder-styles__suggest-item", onMouseDown: (e) => {
138
- e.preventDefault();
139
- onPick(item);
140
- }, onMouseEnter: () => onHover(i), children: [_jsx("span", { children: item.value }), item.hint && _jsx("span", { className: "builder-styles__suggest-hint", children: item.hint })] }, item.value))) }));
137
+ return (_jsx("ul", { className: "builder-styles__suggest", role: "listbox", children: items.map((item, i) => (_jsxs(Fragment, { children: [item.group !== undefined && item.group !== items[i - 1]?.group && (_jsx("li", { role: "presentation", className: "builder-styles__suggest-group", children: item.group })), _jsxs("li", { ref: i === active ? scrollIntoView : undefined, role: "option", "aria-selected": i === active, className: "builder-styles__suggest-item", onMouseDown: (e) => {
138
+ e.preventDefault();
139
+ onPick(item);
140
+ }, onMouseEnter: () => onHover(i), children: [item.label ? (_jsxs("span", { className: "builder-styles__suggest-label", children: [item.label, " ", _jsx("code", { className: "builder-styles__suggest-name", children: item.value })] })) : (_jsx("span", { children: item.value })), item.hint && _jsx("span", { className: "builder-styles__suggest-hint", children: item.hint })] })] }, item.value))) }));
141
141
  }
142
142
  /** Prefix matches first, then substring matches. All items when the query is empty. */
143
143
  export function filterSuggestions(items, query, limit = 200) {