payload-canvas 0.3.0-next.1 → 0.4.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 (236) hide show
  1. package/README.md +522 -39
  2. package/dist/admin/BuilderTab.js +1 -1
  3. package/dist/admin/diff/LayoutDiff.js +3 -3
  4. package/dist/admin/diff/changes.js +8 -0
  5. package/dist/admin/diff/layoutDiff.scss +48 -48
  6. package/dist/admin/editor/DragLayer.js +1 -1
  7. package/dist/admin/editor/InlineToolbar.js +1 -1
  8. package/dist/admin/editor/Inspector.js +50 -5
  9. package/dist/admin/editor/Outline.js +13 -11
  10. package/dist/admin/editor/Overlay.js +1 -1
  11. package/dist/admin/editor/actions.d.ts +9 -1
  12. package/dist/admin/editor/actions.js +38 -3
  13. package/dist/admin/editor/assistant/AssistantPanel.js +1 -1
  14. package/dist/admin/editor/assistant/ConnectAgents.js +1 -1
  15. package/dist/admin/editor/assistant/assistant.scss +65 -65
  16. package/dist/admin/editor/dnd/dnd.scss +2 -2
  17. package/dist/admin/editor/editor.scss +134 -134
  18. package/dist/admin/editor/empty/EmptyStart.js +32 -6
  19. package/dist/admin/editor/empty/empty.scss +3 -3
  20. package/dist/admin/editor/fields/ArrayField.js +2 -2
  21. package/dist/admin/editor/fields/GroupField.d.ts +5 -2
  22. package/dist/admin/editor/fields/GroupField.js +6 -2
  23. package/dist/admin/editor/fields/WhereField.d.ts +17 -0
  24. package/dist/admin/editor/fields/WhereField.js +67 -0
  25. package/dist/admin/editor/fields/access.d.ts +1 -1
  26. package/dist/admin/editor/fields/fields.scss +122 -33
  27. package/dist/admin/editor/fields/whereRows.d.ts +28 -0
  28. package/dist/admin/editor/fields/whereRows.js +118 -0
  29. package/dist/admin/editor/generate/GenerateImage.js +1 -1
  30. package/dist/admin/editor/generate/generate.scss +48 -48
  31. package/dist/admin/editor/icons.d.ts +1 -0
  32. package/dist/admin/editor/icons.js +3 -1
  33. package/dist/admin/editor/insert/InsertHandle.js +1 -1
  34. package/dist/admin/editor/layout/FrameResize.js +1 -1
  35. package/dist/admin/editor/layout/LeftPanel.js +1 -1
  36. package/dist/admin/editor/layout/layout.scss +4 -4
  37. package/dist/admin/editor/live/PresenceUI.js +1 -1
  38. package/dist/admin/editor/live/presence.scss +1 -1
  39. package/dist/admin/editor/locale/LocaleField.d.ts +2 -2
  40. package/dist/admin/editor/locale/LocaleField.js +4 -2
  41. package/dist/admin/editor/locale/locale.scss +12 -12
  42. package/dist/admin/editor/media/ImageEditor.js +1 -1
  43. package/dist/admin/editor/media/media.scss +23 -23
  44. package/dist/admin/editor/menu/Menu.js +1 -1
  45. package/dist/admin/editor/menu/blockMenu.js +5 -1
  46. package/dist/admin/editor/menu/menu.scss +16 -16
  47. package/dist/admin/editor/motion/MotionPanel.js +2 -2
  48. package/dist/admin/editor/motion/model.d.ts +2 -2
  49. package/dist/admin/editor/motion/model.js +2 -2
  50. package/dist/admin/editor/motion/motion.scss +2 -2
  51. package/dist/admin/editor/regions/RegionOverlay.js +1 -1
  52. package/dist/admin/editor/regions/RegionPane.js +1 -1
  53. package/dist/admin/editor/renderField.d.ts +3 -1
  54. package/dist/admin/editor/renderField.js +14 -5
  55. package/dist/admin/editor/runtime.js +1 -0
  56. package/dist/admin/editor/styles/ColorPicker.js +1 -1
  57. package/dist/admin/editor/styles/SiteClasses.d.ts +9 -0
  58. package/dist/admin/editor/styles/SiteClasses.js +31 -0
  59. package/dist/admin/editor/styles/StylesPanel.d.ts +3 -1
  60. package/dist/admin/editor/styles/StylesPanel.js +9 -6
  61. package/dist/admin/editor/styles/VariantBar.js +1 -1
  62. package/dist/admin/editor/styles/context.d.ts +9 -2
  63. package/dist/admin/editor/styles/context.js +14 -9
  64. package/dist/admin/editor/styles/controls.js +3 -3
  65. package/dist/admin/editor/styles/sections.js +2 -2
  66. package/dist/admin/editor/styles/styles.scss +147 -93
  67. package/dist/admin/editor/templates/Bindable.d.ts +14 -6
  68. package/dist/admin/editor/templates/Bindable.js +74 -18
  69. package/dist/admin/editor/templates/SamplePicker.js +1 -1
  70. package/dist/admin/editor/templates/binding.d.ts +11 -4
  71. package/dist/admin/editor/templates/binding.js +23 -3
  72. package/dist/admin/editor/templates/templates.scss +90 -90
  73. package/dist/admin/editor/tooltip/tooltip.scss +4 -4
  74. package/dist/admin/editor/topbar/DocumentActions.js +1 -1
  75. package/dist/admin/editor/topbar/DocumentTitle.js +1 -1
  76. package/dist/admin/editor/topbar/screens/DrawerRouter.d.ts +1 -1
  77. package/dist/admin/editor/topbar/screens/ScreenDrawer.js +1 -1
  78. package/dist/admin/editor/topbar/screens/drawerRouterSupport.d.ts +1 -1
  79. package/dist/admin/editor/topbar/screens/screens.scss +20 -20
  80. package/dist/admin/editor/topbar/settingsDrawer.js +3 -3
  81. package/dist/admin/editor/topbar/settingsDrawer.scss +7 -7
  82. package/dist/admin/editor/topbar/topbar.scss +47 -47
  83. package/dist/admin/editor/ui/Select.js +1 -1
  84. package/dist/admin/editor/ui/controls.scss +26 -26
  85. package/dist/admin/screen/BuilderScreen.js +1 -1
  86. package/dist/ai/adapters/anthropic.d.ts +2 -2
  87. package/dist/ai/images/service.js +1 -1
  88. package/dist/ai/loop.d.ts +5 -5
  89. package/dist/ai/prompt.js +8 -2
  90. package/dist/ai/tools.js +11 -2
  91. package/dist/blocks/builtins/carousel.d.ts +32 -0
  92. package/dist/blocks/builtins/carousel.js +122 -0
  93. package/dist/blocks/builtins/disclosure.d.ts +13 -0
  94. package/dist/blocks/builtins/disclosure.js +107 -0
  95. package/dist/blocks/builtins/faq.d.ts +17 -0
  96. package/dist/blocks/builtins/faq.js +88 -0
  97. package/dist/blocks/builtins/filterLink.d.ts +22 -0
  98. package/dist/blocks/builtins/filterLink.js +76 -0
  99. package/dist/blocks/builtins/headingId.d.ts +15 -0
  100. package/dist/blocks/builtins/headingId.js +36 -0
  101. package/dist/blocks/builtins/icon.d.ts +8 -0
  102. package/dist/blocks/builtins/icon.js +45 -0
  103. package/dist/blocks/builtins/index.d.ts +35 -0
  104. package/dist/blocks/builtins/index.js +50 -0
  105. package/dist/blocks/builtins/lightbox.d.ts +43 -0
  106. package/dist/blocks/builtins/lightbox.js +93 -0
  107. package/dist/blocks/builtins/mediaBackdrop.d.ts +11 -0
  108. package/dist/blocks/builtins/mediaBackdrop.js +79 -0
  109. package/dist/blocks/builtins/sectionRef.d.ts +26 -0
  110. package/dist/blocks/builtins/sectionRef.js +78 -0
  111. package/dist/blocks/builtins/shared.d.ts +33 -0
  112. package/dist/blocks/builtins/shared.js +70 -0
  113. package/dist/blocks/builtins/tableOfContents.d.ts +3 -0
  114. package/dist/blocks/builtins/tableOfContents.js +44 -0
  115. package/dist/blocks/defaults.d.ts +28 -10
  116. package/dist/blocks/defaults.js +413 -20
  117. package/dist/blocks/index.d.ts +4 -2
  118. package/dist/blocks/index.js +3 -1
  119. package/dist/core/attrs.d.ts +27 -0
  120. package/dist/core/attrs.js +132 -0
  121. package/dist/core/bindings.d.ts +123 -12
  122. package/dist/core/bindings.js +504 -19
  123. package/dist/core/blocks.d.ts +46 -1
  124. package/dist/core/blocks.js +136 -0
  125. package/dist/core/classes.d.ts +10 -2
  126. package/dist/core/classes.js +34 -5
  127. package/dist/core/fieldAccess.js +1 -1
  128. package/dist/core/fieldHooks.d.ts +1 -1
  129. package/dist/core/headings.d.ts +21 -0
  130. package/dist/core/headings.js +47 -0
  131. package/dist/core/index.d.ts +4 -2
  132. package/dist/core/index.js +4 -2
  133. package/dist/core/motion.d.ts +24 -15
  134. package/dist/core/motion.js +20 -12
  135. package/dist/core/operations.js +59 -2
  136. package/dist/core/payloadBlocks.js +3 -1
  137. package/dist/core/schema.js +20 -0
  138. package/dist/core/tree.js +24 -1
  139. package/dist/core/types.d.ts +87 -0
  140. package/dist/core/validate.js +29 -4
  141. package/dist/css/tokens.d.ts +6 -3
  142. package/dist/css/tokens.js +48 -2
  143. package/dist/index.d.ts +3 -3
  144. package/dist/index.js +2 -2
  145. package/dist/live/draftAccess.js +1 -1
  146. package/dist/live/session.d.ts +1 -1
  147. package/dist/live/storage.js +4 -2
  148. package/dist/mcp/index.d.ts +2 -0
  149. package/dist/mcp/index.js +50 -13
  150. package/dist/mcp/shared.d.ts +34 -31
  151. package/dist/mcp/shared.js +23 -8
  152. package/dist/plugin/index.d.ts +8 -0
  153. package/dist/plugin/index.js +30 -12
  154. package/dist/plugin/listCollections.d.ts +17 -2
  155. package/dist/plugin/listCollections.js +44 -7
  156. package/dist/plugin/references.d.ts +5 -0
  157. package/dist/plugin/references.js +1 -1
  158. package/dist/plugin/templates.d.ts +4 -0
  159. package/dist/plugin/templates.js +24 -9
  160. package/dist/protocol/index.d.ts +3 -1
  161. package/dist/react/canvas/BuilderCanvas.js +6 -4
  162. package/dist/react/canvas/fetchDocs.d.ts +16 -2
  163. package/dist/react/canvas/fetchDocs.js +42 -9
  164. package/dist/react/canvas/inline/rich/editor.js +1 -6
  165. package/dist/react/canvas/measure.d.ts +3 -1
  166. package/dist/react/canvas/measure.js +26 -2
  167. package/dist/react/canvas/resolveLayout.d.ts +1 -1
  168. package/dist/react/canvas/resolveLayout.js +17 -6
  169. package/dist/react/canvas/serverBlocks.d.ts +11 -0
  170. package/dist/react/canvas/serverBlocks.js +28 -1
  171. package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +1 -1
  172. package/dist/react/components/Button.d.ts +11 -2
  173. package/dist/react/components/Button.js +43 -6
  174. package/dist/react/components/CollectionList.d.ts +6 -3
  175. package/dist/react/components/CollectionList.js +21 -7
  176. package/dist/react/components/Container.js +4 -1
  177. package/dist/react/components/Field.js +13 -2
  178. package/dist/react/components/Heading.js +9 -2
  179. package/dist/react/components/Image.d.ts +9 -0
  180. package/dist/react/components/Image.js +16 -1
  181. package/dist/react/components/List.d.ts +1 -0
  182. package/dist/react/components/List.js +6 -0
  183. package/dist/react/components/Menu.d.ts +16 -0
  184. package/dist/react/components/Menu.js +83 -19
  185. package/dist/react/components/RichText.d.ts +8 -3
  186. package/dist/react/components/RichText.js +25 -4
  187. package/dist/react/components/builtins/Accordion.d.ts +9 -0
  188. package/dist/react/components/builtins/Accordion.js +37 -0
  189. package/dist/react/components/builtins/BackdropVideo.d.ts +13 -0
  190. package/dist/react/components/builtins/BackdropVideo.js +16 -0
  191. package/dist/react/components/builtins/Carousel.d.ts +13 -0
  192. package/dist/react/components/builtins/Carousel.js +134 -0
  193. package/dist/react/components/builtins/Disclosure.d.ts +7 -0
  194. package/dist/react/components/builtins/Disclosure.js +13 -0
  195. package/dist/react/components/builtins/FilterLink.d.ts +8 -0
  196. package/dist/react/components/builtins/FilterLink.js +30 -0
  197. package/dist/react/components/builtins/Icon.d.ts +14 -0
  198. package/dist/react/components/builtins/Icon.js +28 -0
  199. package/dist/react/components/builtins/Lightbox.d.ts +45 -0
  200. package/dist/react/components/builtins/Lightbox.js +252 -0
  201. package/dist/react/components/builtins/MediaBackdrop.d.ts +14 -0
  202. package/dist/react/components/builtins/MediaBackdrop.js +61 -0
  203. package/dist/react/components/builtins/SectionRef.d.ts +7 -0
  204. package/dist/react/components/builtins/SectionRef.js +17 -0
  205. package/dist/react/components/builtins/TableOfContents.d.ts +7 -0
  206. package/dist/react/components/builtins/TableOfContents.js +21 -0
  207. package/dist/react/components/builtins/glyphs.d.ts +8 -0
  208. package/dist/react/components/builtins/glyphs.js +7 -0
  209. package/dist/react/components/builtins/index.d.ts +32 -0
  210. package/dist/react/components/builtins/index.js +36 -0
  211. package/dist/react/components/index.js +2 -0
  212. package/dist/react/index.d.ts +3 -1
  213. package/dist/react/index.js +3 -1
  214. package/dist/react/motion/runtime.js +10 -6
  215. package/dist/react/motion/style.js +1 -1
  216. package/dist/react/render/PayloadRoot.js +1 -1
  217. package/dist/react/render/RenderLayout.d.ts +1 -1
  218. package/dist/react/render/RenderLayout.js +77 -24
  219. package/dist/react/render/lists.d.ts +107 -5
  220. package/dist/react/render/lists.js +284 -9
  221. package/dist/react/render/resolve.d.ts +22 -2
  222. package/dist/react/render/resolve.js +45 -24
  223. package/dist/react/render/sections.d.ts +9 -0
  224. package/dist/react/render/sections.js +51 -0
  225. package/dist/react/render/types.d.ts +6 -1
  226. package/dist/react/server.d.ts +4 -4
  227. package/dist/react/server.js +55 -7
  228. package/dist/react/theme/ThemeStyle.d.ts +13 -2
  229. package/dist/react/theme/ThemeStyle.js +13 -3
  230. package/dist/theme/admin/ColorField.d.ts +2 -2
  231. package/dist/theme/admin/ColorField.js +2 -2
  232. package/dist/theme/admin/FontField.d.ts +2 -2
  233. package/dist/theme/admin/FontField.js +2 -2
  234. package/dist/theme/admin/SaveSignal.js +2 -2
  235. package/dist/theme/admin/fields.scss +48 -48
  236. package/package.json +23 -28
@@ -11,5 +11,5 @@ export function BuilderTab() {
11
11
  const { config: { routes }, } = useConfig();
12
12
  if (id === undefined || id === null || !collectionSlug)
13
13
  return null;
14
- return (_jsx(Button, { buttonStyle: "ghost", className: "doc-tab", el: "link", margin: false, size: "medium", to: builderViewPath(routes.admin, collectionSlug, id), children: _jsx("span", { className: "doc-tab__label", children: "Builder" }) }));
14
+ return (_jsx(Button, { buttonStyle: "tab", className: "doc-tab", el: "link", margin: false, size: "medium", to: builderViewPath(routes.admin, collectionSlug, id), children: _jsx("span", { className: "doc-tab__label", children: "Builder" }) }));
15
15
  }
@@ -51,12 +51,12 @@ function ChangeRow({ change, settings }) {
51
51
  return (_jsxs("li", { className: `${base}__change ${base}__change--${change.kind}`, children: [_jsxs("div", { className: `${base}__head`, children: [_jsx("span", { className: `${base}__pill ${base}__pill--${change.kind}`, children: KIND_LABELS[change.kind] }), _jsx("strong", { className: `${base}__name`, children: change.name }), (change.kind === 'added' || change.kind === 'removed') && change.where ? (_jsxs("span", { className: `${base}__where`, children: ["in ", change.where] })) : null, (change.kind === 'added' || change.kind === 'removed') && change.inside > 0 ? (_jsxs("span", { className: `${base}__where`, children: ["with ", change.inside, " ", change.inside === 1 ? 'block' : 'blocks', " inside"] })) : null, change.kind === 'moved' ? (_jsxs("span", { className: `${base}__where`, children: ["from ", change.from, " to ", change.to] })) : null] }), change.kind === 'changed' ? (_jsx("ul", { className: `${base}__details`, children: change.details.map((detail, index) => (_jsx(Detail, { detail: detail, settings: settings }, index))) })) : null] }));
52
52
  }
53
53
  export function LayoutDiff(props) {
54
- const { valueFrom, valueTo, field, clientField, i18n, locale, nestingLevel, selectedLocales } = props;
54
+ const { comparisonValue, versionValue, field, clientField, i18n, locale, nestingLevel, selectedLocales } = props;
55
55
  const builder = field.admin?.custom?.builder;
56
56
  const settings = builder?.localization ?? null;
57
57
  // Translations follow the locales picked in the compare view; all of them when none are picked.
58
58
  const locales = settings && selectedLocales?.length ? selectedLocales : undefined;
59
- const changes = diffLayouts(valueFrom, valueTo, { blocks: builder?.blocks ?? [], ...(locales ? { locales } : {}) });
59
+ const changes = diffLayouts(comparisonValue, versionValue, { blocks: builder?.blocks ?? [], ...(locales ? { locales } : {}) });
60
60
  const label = fieldLabel(clientField?.label ?? field.label, i18n?.language ?? 'en', field.name);
61
- return (_jsxs("div", { className: `${base} nested-level-${nestingLevel ?? 0}`, children: [_jsxs(FieldDiffLabel, { children: [locale ? _jsx("span", { className: "field-diff__locale-label", children: locale }) : null, label] }), _jsxs("div", { className: `${base}__content`, children: [_jsx("p", { className: `${base}__summary`, children: summarizeLayoutChanges(changes) }), changes.length > 0 ? (_jsx("ul", { className: `${base}__list`, children: changes.map((change) => (_jsx(ChangeRow, { change: change, settings: settings }, `${change.kind}:${change.id}`))) })) : null, _jsx(LayoutJsonDiff, { from: valueFrom, to: valueTo })] })] }));
61
+ return (_jsxs("div", { className: `${base} nested-level-${nestingLevel ?? 0}`, children: [_jsxs(FieldDiffLabel, { children: [locale ? _jsx("span", { className: "field-diff__locale-label", children: locale }) : null, label] }), _jsxs("div", { className: `${base}__content`, children: [_jsx("p", { className: `${base}__summary`, children: summarizeLayoutChanges(changes) }), changes.length > 0 ? (_jsx("ul", { className: `${base}__list`, children: changes.map((change) => (_jsx(ChangeRow, { change: change, settings: settings }, `${change.kind}:${change.id}`))) })) : null, _jsx(LayoutJsonDiff, { from: comparisonValue, to: versionValue })] })] }));
62
62
  }
@@ -212,8 +212,16 @@ function blockDetails(ctx, from, to) {
212
212
  }
213
213
  if (!sameValue(from.motion, to.motion))
214
214
  out.push({ kind: 'note', label: 'Animation', text: motionNote(from.motion, to.motion) });
215
+ for (const key of Object.keys(ATTR_NAMES)) {
216
+ const before = from.attrs?.[key];
217
+ const after = to.attrs?.[key];
218
+ if (before !== after)
219
+ out.push({ kind: 'value', label: ATTR_NAMES[key], from: attrText(before), to: attrText(after) });
220
+ }
215
221
  return out;
216
222
  }
223
+ const ATTR_NAMES = { id: 'HTML id', ariaLabel: 'ARIA label', ariaHidden: 'Hidden from screen readers' };
224
+ const attrText = (value) => (value === true ? 'Yes' : value === undefined ? '' : String(value));
217
225
  /** Ids of `list` that keep their relative order (longest common subsequence with `other`). */
218
226
  function stableIds(list, other) {
219
227
  const n = list.length;
@@ -9,14 +9,14 @@
9
9
  &__content {
10
10
  display: flex;
11
11
  flex-direction: column;
12
- gap: calc(var(--spacer-3) * 0.5);
13
- background: var(--color-bg-secondary);
14
- padding: calc(var(--spacer-3) * 0.5);
12
+ gap: calc(var(--base) * 0.5);
13
+ background: var(--theme-elevation-50);
14
+ padding: calc(var(--base) * 0.5);
15
15
  }
16
16
 
17
17
  &__summary {
18
18
  margin: 0;
19
- color: var(--color-text);
19
+ color: var(--theme-elevation-800);
20
20
  font-weight: 500;
21
21
  }
22
22
 
@@ -30,47 +30,47 @@
30
30
  &__list {
31
31
  display: flex;
32
32
  flex-direction: column;
33
- gap: calc(var(--spacer-3) * 0.25);
33
+ gap: calc(var(--base) * 0.25);
34
34
  }
35
35
 
36
36
  &__change {
37
- padding: calc(var(--spacer-3) * 0.4) calc(var(--spacer-3) * 0.5);
38
- border: 1px solid var(--color-bg-hover);
39
- border-radius: var(--radius-medium);
40
- background: var(--color-bg);
37
+ padding: calc(var(--base) * 0.4) calc(var(--base) * 0.5);
38
+ border: 1px solid var(--theme-elevation-100);
39
+ border-radius: var(--style-radius-s);
40
+ background: var(--theme-elevation-0);
41
41
  }
42
42
 
43
43
  &__head {
44
44
  display: flex;
45
45
  flex-wrap: wrap;
46
46
  align-items: baseline;
47
- gap: calc(var(--spacer-3) * 0.3);
47
+ gap: calc(var(--base) * 0.3);
48
48
  min-width: 0;
49
49
  }
50
50
 
51
51
  &__pill {
52
52
  flex: none;
53
- padding: 0 calc(var(--spacer-3) * 0.25);
54
- border: 1px solid var(--color-border);
55
- border-radius: var(--radius-medium);
56
- background: var(--color-bg-hover);
57
- color: var(--color-text);
58
- font-size: calc(var(--spacer-3) * 0.55);
53
+ padding: 0 calc(var(--base) * 0.25);
54
+ border: 1px solid var(--theme-elevation-150);
55
+ border-radius: var(--style-radius-s);
56
+ background: var(--theme-elevation-100);
57
+ color: var(--theme-elevation-800);
58
+ font-size: calc(var(--base) * 0.55);
59
59
  font-weight: 600;
60
60
  line-height: 1.6;
61
61
  text-transform: uppercase;
62
62
  letter-spacing: 0.04em;
63
63
 
64
64
  &--added {
65
- border-color: var(--diff-create-pill-border, var(--color-border-success-strong));
66
- background: var(--diff-create-pill-bg, var(--color-border-success));
67
- color: var(--diff-create-pill-color, var(--color-text-success));
65
+ border-color: var(--diff-create-pill-border, var(--theme-success-400));
66
+ background: var(--diff-create-pill-bg, var(--theme-success-200));
67
+ color: var(--diff-create-pill-color, var(--theme-success-600));
68
68
  }
69
69
 
70
70
  &--removed {
71
- border-color: var(--diff-delete-pill-border, var(--color-border-danger-strong));
72
- background: var(--diff-delete-pill-bg, var(--color-border-danger));
73
- color: var(--diff-delete-pill-color, var(--color-text-danger));
71
+ border-color: var(--diff-delete-pill-border, var(--theme-error-400));
72
+ background: var(--diff-delete-pill-bg, var(--theme-error-200));
73
+ color: var(--diff-delete-pill-color, var(--theme-error-600));
74
74
  }
75
75
  }
76
76
 
@@ -80,31 +80,31 @@
80
80
  }
81
81
 
82
82
  &__where {
83
- color: var(--color-text-secondary);
83
+ color: var(--theme-elevation-600);
84
84
  }
85
85
 
86
86
  &__details {
87
87
  display: flex;
88
88
  flex-direction: column;
89
- gap: calc(var(--spacer-3) * 0.2);
90
- margin-top: calc(var(--spacer-3) * 0.3);
91
- padding-inline-start: calc(var(--spacer-3) * 0.5);
92
- border-inline-start: 2px solid var(--color-bg-hover);
89
+ gap: calc(var(--base) * 0.2);
90
+ margin-top: calc(var(--base) * 0.3);
91
+ padding-inline-start: calc(var(--base) * 0.5);
92
+ border-inline-start: 2px solid var(--theme-elevation-100);
93
93
  }
94
94
 
95
95
  &__detail {
96
96
  display: flex;
97
97
  flex-wrap: wrap;
98
98
  align-items: baseline;
99
- gap: calc(var(--spacer-3) * 0.25);
99
+ gap: calc(var(--base) * 0.25);
100
100
  min-width: 0;
101
101
  }
102
102
 
103
103
  &__detail-label {
104
104
  display: inline-flex;
105
105
  align-items: baseline;
106
- gap: calc(var(--spacer-3) * 0.2);
107
- color: var(--color-text-secondary);
106
+ gap: calc(var(--base) * 0.2);
107
+ color: var(--theme-elevation-600);
108
108
 
109
109
  &::after {
110
110
  content: ':';
@@ -117,59 +117,59 @@
117
117
 
118
118
  &__value,
119
119
  &__class {
120
- padding: 0 calc(var(--spacer-3) * 0.15);
121
- border-radius: var(--radius-medium);
120
+ padding: 0 calc(var(--base) * 0.15);
121
+ border-radius: var(--style-radius-s);
122
122
  text-decoration: none;
123
123
  overflow-wrap: anywhere;
124
124
  }
125
125
 
126
126
  &__value--del {
127
- background: var(--diff-delete-parent-bg, var(--color-bg-danger-tertiary));
128
- color: var(--diff-delete-parent-color, var(--color-text-danger));
127
+ background: var(--diff-delete-parent-bg, var(--theme-error-100));
128
+ color: var(--diff-delete-parent-color, var(--theme-error-800));
129
129
  text-decoration: line-through;
130
- text-decoration-color: var(--diff-delete-pill-border, var(--color-border-danger-strong));
130
+ text-decoration-color: var(--diff-delete-pill-border, var(--theme-error-400));
131
131
  }
132
132
 
133
133
  &__value--ins {
134
- background: var(--diff-create-parent-bg, var(--color-bg-success-tertiary));
135
- color: var(--diff-create-parent-color, var(--color-text-success));
134
+ background: var(--diff-create-parent-bg, var(--theme-success-100));
135
+ color: var(--diff-create-parent-color, var(--theme-success-800));
136
136
  }
137
137
 
138
138
  &__class {
139
- font-family: var(--text-mono-family, ui-monospace, monospace);
140
- font-size: calc(var(--spacer-3) * 0.55);
139
+ font-family: var(--font-mono, ui-monospace, monospace);
140
+ font-size: calc(var(--base) * 0.55);
141
141
  }
142
142
 
143
143
  &__empty {
144
- color: var(--color-text-tertiary);
144
+ color: var(--theme-elevation-400);
145
145
  font-style: italic;
146
146
  }
147
147
 
148
148
  &__arrow {
149
- color: var(--color-text-tertiary);
149
+ color: var(--theme-elevation-400);
150
150
  }
151
151
 
152
152
  &__json {
153
- border-top: 1px solid var(--color-bg-hover);
154
- padding-top: calc(var(--spacer-3) * 0.4);
153
+ border-top: 1px solid var(--theme-elevation-100);
154
+ padding-top: calc(var(--base) * 0.4);
155
155
  }
156
156
 
157
157
  &__json-summary {
158
158
  cursor: pointer;
159
- color: var(--color-text-secondary);
159
+ color: var(--theme-elevation-600);
160
160
  width: fit-content;
161
161
 
162
162
  &:hover {
163
- color: var(--color-text);
163
+ color: var(--theme-elevation-900);
164
164
  }
165
165
  }
166
166
 
167
167
  &__json-content {
168
168
  display: grid;
169
169
  // Same columns as Payload's field diffs: old on the left, new on the right.
170
- grid-template-columns: calc(50% - var(--spacer-3) * 0.5) calc(50% - var(--spacer-3) * 0.5);
171
- gap: var(--spacer-3);
172
- margin-top: calc(var(--spacer-3) * 0.5);
170
+ grid-template-columns: calc(50% - var(--base) * 0.5) calc(50% - var(--base) * 0.5);
171
+ gap: var(--base);
172
+ margin-top: calc(var(--base) * 0.5);
173
173
  overflow-x: auto;
174
174
 
175
175
  pre {
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useCallback } from 'react';
4
4
  import { registerGhost, smoothView } from './dnd/smooth.js';
5
5
  import { BlockIcon } from './icons.js';
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  // The rich text toolbar shown over a rich text block while it is edited on the canvas. It lives
4
4
  // in the admin overlay (Payload's look, never the site's CSS) and sends commands to the Lexical
5
5
  // editor in the canvas iframe. Buttons keep the keyboard focus in the iframe (no focus on press).
@@ -1,8 +1,8 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { CheckboxInput } from '@payloadcms/ui';
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { CheckboxInput, TextInput } from '@payloadcms/ui';
4
4
  import { useDeferredValue, useEffect, useState } from 'react';
5
- import { findBlock, getBlockDefinition } from '../../core/index.js';
5
+ import { findBlock, getBlockDefinition, htmlIdProblem, htmlIdsOf } from '../../core/index.js';
6
6
  import { BlockIcon, Icon } from './icons.js';
7
7
  import { blockMenuEntries } from './menu/blockMenu.js';
8
8
  import { MenuButton } from './menu/Menu.js';
@@ -14,12 +14,14 @@ import { LocaleNote } from './locale/LocaleField.js';
14
14
  import { MotionPanel } from './motion/MotionPanel.js';
15
15
  import { AssistantPanel } from './assistant/AssistantPanel.js';
16
16
  import { useAccessRefresh } from './fields/access.js';
17
+ import { InputError } from './fields/CheckedInputs.js';
17
18
  import { BlockContentFields } from './renderField.js';
18
19
  import { useRuntime } from './runtime.js';
19
20
  import { storesBuilderData } from './actions.js';
20
21
  import { shortcutList } from './shortcuts.js';
21
22
  import { useEditor } from './store.js';
22
23
  import { StylesPanel } from './styles/StylesPanel.js';
24
+ import { Select } from './ui/Select.js';
23
25
  import { usePayloadControlNames } from './ui/payloadA11y.js';
24
26
  import { useOptionalValue, useValue, useValueSelector } from './valueStore.js';
25
27
  import { RegionPane } from './regions/RegionPane.js';
@@ -99,9 +101,10 @@ function BlockPane() {
99
101
  { id: 'content', label: 'Content' },
100
102
  { id: 'styles', label: 'Styles' },
101
103
  { id: 'motion', label: 'Motion' },
104
+ { id: 'advanced', label: 'Advanced' },
102
105
  ]
103
106
  : // A Payload blocks field holds the blocks' own fields only.
104
- [{ id: 'content', label: 'Content' }] }), tab === 'content' && _jsx(BlockContentFields, { block: block }), tab === 'styles' && storesBuilderData(runtime) && _jsx(StyleFields, { block: block }), tab === 'motion' && storesBuilderData(runtime) && _jsx(MotionPanel, { blockId: block.id, blockType: block.type, motion: block.motion })] }, block.id));
107
+ [{ id: 'content', label: 'Content' }] }), tab === 'content' && _jsx(BlockContentFields, { block: block }), tab === 'styles' && storesBuilderData(runtime) && _jsx(StyleFields, { block: block }), tab === 'motion' && storesBuilderData(runtime) && _jsx(MotionPanel, { blockId: block.id, blockType: block.type, motion: block.motion }), tab === 'advanced' && storesBuilderData(runtime) && _jsx(AdvancedFields, { block: block })] }, block.id));
105
108
  }
106
109
  /** What stopped the last publish, for this block. */
107
110
  function BlockProblems({ blockId }) {
@@ -134,5 +137,47 @@ function BlockHeader({ block }) {
134
137
  function StyleFields({ block }) {
135
138
  const runtime = useRuntime();
136
139
  const def = getBlockDefinition(runtime.config.blocks, block.type);
137
- return (_jsxs("div", { className: "builder-editor__fields", children: [def?.styles === false ? (_jsx("p", { className: "builder-editor__hint", children: "This block has no style controls." })) : (_jsx(StylesPanel, { block: block })), _jsx(CheckboxInput, { id: `builder-${block.id}-hidden`, name: `builder.${block.id}.hidden`, label: "Hide on the site", checked: block.hidden === true, onToggle: (e) => runtime.store.apply({ type: 'update', id: block.id, hidden: e.target.checked }) })] }));
140
+ // Slots with an element of their own (`styles: true`) are style targets next to the block.
141
+ const styledSlots = Object.entries(def?.slots ?? {}).filter(([, slot]) => slot.styles);
142
+ const [target, setTarget] = useState(null);
143
+ const slot = target && styledSlots.some(([name]) => name === target) ? target : null;
144
+ const blockStyles = def?.styles !== false;
145
+ return (_jsxs("div", { className: "builder-editor__fields", children: [styledSlots.length > 0 && (_jsx(Select, { "aria-label": "Style target", emptyLabel: blockStyles ? 'This block' : undefined, placeholder: "Pick a slot", value: slot, onValueChange: setTarget, options: styledSlots.map(([name, s]) => ({
146
+ value: name,
147
+ label: `Slot: ${s.label?.trim() || name}`,
148
+ ...(block.slotClassName?.[name] ? { suffix: _jsx("span", { className: "builder-styles__dot", "aria-label": "has classes" }) } : {}),
149
+ })) })), slot ? (_jsx(StylesPanel, { block: block, slot: slot }, slot)) : !blockStyles ? (_jsx("p", { className: "builder-editor__hint", children: "This block has no style controls." })) : (_jsx(StylesPanel, { block: block })), _jsx(CheckboxInput, { id: `builder-${block.id}-hidden`, name: `builder.${block.id}.hidden`, label: "Hide on the site", checked: block.hidden === true, onToggle: (e) => runtime.store.apply({ type: 'update', id: block.id, hidden: e.target.checked }) })] }));
150
+ }
151
+ /**
152
+ * The block's HTML attributes (`block.attrs`): an id for "#id" links, an ARIA label and
153
+ * aria-hidden. The id is stored only when it is valid and no other block of the page has it.
154
+ */
155
+ function AdvancedFields({ block }) {
156
+ const runtime = useRuntime();
157
+ const layout = useEditor(runtime.store, (s) => s.layout);
158
+ const stored = block.attrs?.id ?? '';
159
+ // `source` is the stored id the draft belongs to: another stored id (undo, AI edit) replaces the draft.
160
+ const [draft, setDraft] = useState({ text: stored, source: stored });
161
+ if (draft.source !== stored)
162
+ setDraft({ text: stored, source: stored });
163
+ const idProblem = (text) => {
164
+ if (!text)
165
+ return null;
166
+ const owner = htmlIdsOf(layout.blocks).get(text);
167
+ if (owner && owner !== block.id)
168
+ return `Another block of this page has the id "${text}".`;
169
+ return htmlIdProblem(text);
170
+ };
171
+ const problem = idProblem(draft.text.trim());
172
+ const setAttr = (attrs) => runtime.store.apply({ type: 'update', id: block.id, attrs });
173
+ return (_jsxs("div", { className: "builder-editor__fields", children: [_jsxs("div", { children: [_jsx(TextInput, { description: 'Links to this block with "#id", for example "contact".', label: "HTML id", onChange: (e) => {
174
+ const text = e.target.value;
175
+ const id = text.trim();
176
+ if (id === stored || idProblem(id)) {
177
+ setDraft({ text, source: stored });
178
+ return;
179
+ }
180
+ setDraft({ text, source: id });
181
+ setAttr({ id: id || null });
182
+ }, path: `builder.${block.id}.attrs.id`, showError: problem !== null, value: draft.text }), problem && _jsx(InputError, { children: problem })] }), _jsx(TextInput, { description: "The name screen readers read, for example for a link that shows only an icon.", label: "ARIA label", onChange: (e) => setAttr({ ariaLabel: e.target.value || null }), path: `builder.${block.id}.attrs.ariaLabel`, value: block.attrs?.ariaLabel ?? '' }), _jsx(CheckboxInput, { id: `builder-${block.id}-aria-hidden`, name: `builder.${block.id}.attrs.ariaHidden`, label: "Hide from screen readers", checked: block.attrs?.ariaHidden === true, onToggle: (e) => setAttr({ ariaHidden: e.target.checked || null }) })] }));
138
183
  }
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useDraggable } from '@dnd-kit/core';
4
4
  import { memo, useCallback, useEffect, useMemo, useRef, useState, } from 'react';
5
5
  import { describeMotion, findLocation, getBlockDefinition, slotNames, walkBlocks } from '../../core/index.js';
@@ -14,7 +14,8 @@ import { blockPreview, blockSummary, childrenOf, customLabel, typeName } from '.
14
14
  import { OUTLINE_INDENT, useRuntime } from './runtime.js';
15
15
  import { RegionRows } from './regions/RegionRows.js';
16
16
  import { useEditor } from './store.js';
17
- import { findBindingField, listAncestor, URL_PATH } from './templates/binding.js';
17
+ import { bindingPaths, scopeSources } from '../../core/bindings.js';
18
+ import { findBindingField } from './templates/binding.js';
18
19
  import { useValue, useValueSelector } from './valueStore.js';
19
20
  /** Visible rows, depth first. Children of collapsed containers are left out. */
20
21
  function visibleRows(runtime, layout, collapsed) {
@@ -82,18 +83,19 @@ function brokenBindingIds(runtime, layout, templateTarget) {
82
83
  return out;
83
84
  }
84
85
  const NO_ISSUES = [];
85
- /** True when a binding of the block reads a field its collection does not have (or there is no collection). */
86
+ /**
87
+ * True when a binding of the block reads a field its document does not have (or there is no
88
+ * document): the template's, each list item's, or each field list row's.
89
+ */
86
90
  function hasBrokenBinding(runtime, layout, block, templateTarget) {
87
- const paths = Object.values(block.bindings ?? {});
88
- if (paths.length === 0)
91
+ const bindings = Object.entries(block.bindings ?? {});
92
+ if (bindings.length === 0)
89
93
  return false;
90
- const list = listAncestor(layout, block.id);
91
- const listCollection = typeof list?.props?.collection === 'string' ? list.props.collection : null;
92
- const collection = list ? listCollection : templateTarget;
93
- if (!collection)
94
+ const fields = scopeSources(layout, block.id, runtime.config.templates?.sources ?? {}, templateTarget);
95
+ if (!fields)
94
96
  return true;
95
- const fields = runtime.config.templates?.sources?.[collection] ?? [];
96
- return paths.some((path) => path !== URL_PATH && !findBindingField(fields, path));
97
+ // Every plain path a binding reads (templates and fallback chains have several).
98
+ return bindings.some(([key, binding]) => bindingPaths(key, binding).some((path) => !findBindingField(fields, path)));
97
99
  }
98
100
  /**
99
101
  * The outline tree. Rows stay a flat list, which keeps them simple to measure for drop targets.
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useDraggable } from '@dnd-kit/core';
4
4
  import { findBlock, findLocation } from '../../core/index.js';
5
5
  import { smoothView } from './dnd/smooth.js';
@@ -27,8 +27,16 @@ export declare function insertNewBlockAt(runtime: Runtime, type: string, to: Pos
27
27
  * position was picked). Null when the parent block is gone.
28
28
  */
29
29
  export declare function currentPosition(layout: Layout, to: Position): Position | null;
30
- /** Inserts copies (new ids) of `blocks` as one undo step and selects the first one. */
30
+ /**
31
+ * Inserts copies (new ids) of `blocks` as one undo step and selects the first one. A copy leaves
32
+ * out the HTML ids (`attrs.id`) the page already uses, so a paste or a second section stays valid.
33
+ */
31
34
  export declare function insertBlocks(runtime: Runtime, blocks: Block[], to: Position): boolean;
35
+ /**
36
+ * "Detach section": replaces a live saved section (`sectionRef`) with a copy of its blocks, as one
37
+ * undo step. Later changes to the saved section no longer reach this page.
38
+ */
39
+ export declare function detachSection(runtime: Runtime, id: string): Promise<void>;
32
40
  export declare function duplicateBlock(runtime: Runtime, id: string): void;
33
41
  export declare function removeBlock(runtime: Runtime, id: string): void;
34
42
  export declare function toggleHidden(runtime: Runtime, id: string): void;
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
  // Editor actions shared by the toolbar, the overlay, the outline, the inspector, the menus and the
3
3
  // shortcuts: insert, duplicate, remove, hide, move, copy and paste (blocks and styles).
4
- import { createId, findBlock, findLocation, getBlockDefinition, slotAcceptsAt, slotNames } from '../../core/index.js';
4
+ import { sectionDetachOps, sectionRefId } from '../../blocks/builtins/sectionRef.js';
5
+ import { createId, findBlock, findLocation, getBlockDefinition, htmlIdsOf, slotAcceptsAt, slotNames, withoutTakenHtmlIds } from '../../core/index.js';
5
6
  import { normalizeClasses, parseStyles, setStylesOps, stylesText } from './menu/styleClipboard.js';
6
7
  import { countText } from './counts.js';
7
8
  /**
@@ -92,15 +93,49 @@ export function currentPosition(layout, to) {
92
93
  return null;
93
94
  return { ...to, index: Math.min(to.index, parent.slots?.[to.slot ?? 'children']?.length ?? 0) };
94
95
  }
95
- /** Inserts copies (new ids) of `blocks` as one undo step and selects the first one. */
96
+ /**
97
+ * Inserts copies (new ids) of `blocks` as one undo step and selects the first one. A copy leaves
98
+ * out the HTML ids (`attrs.id`) the page already uses, so a paste or a second section stays valid.
99
+ */
96
100
  export function insertBlocks(runtime, blocks, to) {
97
- const fresh = blocks.map(withNewIds);
101
+ const fresh = freshCopies(runtime, blocks);
98
102
  const first = fresh[0];
99
103
  if (!first)
100
104
  return false;
101
105
  const ops = fresh.map((block, i) => ({ type: 'insert', block, to: { ...to, index: to.index + i } }));
102
106
  return runtime.store.apply(ops, { select: first.id });
103
107
  }
108
+ /** Copies with new ids, without the HTML ids the page already uses. */
109
+ function freshCopies(runtime, blocks) {
110
+ const taken = htmlIdsOf(runtime.store.getState().layout.blocks);
111
+ return blocks.map((block) => {
112
+ const copy = withoutTakenHtmlIds(withNewIds(block), taken);
113
+ htmlIdsOf([copy], taken);
114
+ return copy;
115
+ });
116
+ }
117
+ /**
118
+ * "Detach section": replaces a live saved section (`sectionRef`) with a copy of its blocks, as one
119
+ * undo step. Later changes to the saved section no longer reach this page.
120
+ */
121
+ export async function detachSection(runtime, id) {
122
+ const ref = findBlock(runtime.store.getState().layout, id);
123
+ const sectionId = ref ? sectionRefId(ref.props?.section) : null;
124
+ if (sectionId === null)
125
+ return;
126
+ await runtime.sections.load();
127
+ const section = runtime.sections.saved.get()?.find((s) => s.savedId !== undefined && String(s.savedId) === String(sectionId));
128
+ if (!section) {
129
+ runtime.notify('This saved section cannot be loaded. It may be deleted.');
130
+ return;
131
+ }
132
+ const copies = freshCopies(runtime, section.blocks);
133
+ const ops = sectionDetachOps(runtime.store.getState().layout, id, copies);
134
+ if (ops && runtime.store.apply(ops, { select: copies[0].id }))
135
+ runtime.notify(`Detached "${section.label}": this page now has its own copy`);
136
+ else
137
+ runtime.notify("The section's blocks cannot go here.");
138
+ }
104
139
  export function duplicateBlock(runtime, id) {
105
140
  const newId = createId();
106
141
  if (runtime.store.apply({ type: 'duplicate', id, newId }, { select: newId }))
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  // The Assistant tab of the inspector: the chat with the AI that edits this layout.
4
4
  // State lives in the runtime's assistant controller; this file only renders it.
5
5
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  // "Use Claude Code or Codex": connect the official CLIs (signed in with a Claude Pro/Max or
4
4
  // ChatGPT plan) to this site's MCP endpoint. They edit pages through the live channel, so changes
5
5
  // appear in the open editor. Subscriptions are never used as API keys: the CLIs are the MCP clients.