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.
- package/README.md +522 -39
- package/dist/admin/BuilderTab.js +1 -1
- package/dist/admin/diff/LayoutDiff.js +3 -3
- package/dist/admin/diff/changes.js +8 -0
- package/dist/admin/diff/layoutDiff.scss +48 -48
- package/dist/admin/editor/DragLayer.js +1 -1
- package/dist/admin/editor/InlineToolbar.js +1 -1
- package/dist/admin/editor/Inspector.js +50 -5
- package/dist/admin/editor/Outline.js +13 -11
- package/dist/admin/editor/Overlay.js +1 -1
- package/dist/admin/editor/actions.d.ts +9 -1
- package/dist/admin/editor/actions.js +38 -3
- package/dist/admin/editor/assistant/AssistantPanel.js +1 -1
- package/dist/admin/editor/assistant/ConnectAgents.js +1 -1
- package/dist/admin/editor/assistant/assistant.scss +65 -65
- package/dist/admin/editor/dnd/dnd.scss +2 -2
- package/dist/admin/editor/editor.scss +134 -134
- package/dist/admin/editor/empty/EmptyStart.js +32 -6
- package/dist/admin/editor/empty/empty.scss +3 -3
- package/dist/admin/editor/fields/ArrayField.js +2 -2
- package/dist/admin/editor/fields/GroupField.d.ts +5 -2
- package/dist/admin/editor/fields/GroupField.js +6 -2
- package/dist/admin/editor/fields/WhereField.d.ts +17 -0
- package/dist/admin/editor/fields/WhereField.js +67 -0
- package/dist/admin/editor/fields/access.d.ts +1 -1
- package/dist/admin/editor/fields/fields.scss +122 -33
- package/dist/admin/editor/fields/whereRows.d.ts +28 -0
- package/dist/admin/editor/fields/whereRows.js +118 -0
- package/dist/admin/editor/generate/GenerateImage.js +1 -1
- package/dist/admin/editor/generate/generate.scss +48 -48
- package/dist/admin/editor/icons.d.ts +1 -0
- package/dist/admin/editor/icons.js +3 -1
- package/dist/admin/editor/insert/InsertHandle.js +1 -1
- package/dist/admin/editor/layout/FrameResize.js +1 -1
- package/dist/admin/editor/layout/LeftPanel.js +1 -1
- package/dist/admin/editor/layout/layout.scss +4 -4
- package/dist/admin/editor/live/PresenceUI.js +1 -1
- package/dist/admin/editor/live/presence.scss +1 -1
- package/dist/admin/editor/locale/LocaleField.d.ts +2 -2
- package/dist/admin/editor/locale/LocaleField.js +4 -2
- package/dist/admin/editor/locale/locale.scss +12 -12
- package/dist/admin/editor/media/ImageEditor.js +1 -1
- package/dist/admin/editor/media/media.scss +23 -23
- package/dist/admin/editor/menu/Menu.js +1 -1
- package/dist/admin/editor/menu/blockMenu.js +5 -1
- package/dist/admin/editor/menu/menu.scss +16 -16
- package/dist/admin/editor/motion/MotionPanel.js +2 -2
- package/dist/admin/editor/motion/model.d.ts +2 -2
- package/dist/admin/editor/motion/model.js +2 -2
- package/dist/admin/editor/motion/motion.scss +2 -2
- package/dist/admin/editor/regions/RegionOverlay.js +1 -1
- package/dist/admin/editor/regions/RegionPane.js +1 -1
- package/dist/admin/editor/renderField.d.ts +3 -1
- package/dist/admin/editor/renderField.js +14 -5
- package/dist/admin/editor/runtime.js +1 -0
- package/dist/admin/editor/styles/ColorPicker.js +1 -1
- package/dist/admin/editor/styles/SiteClasses.d.ts +9 -0
- package/dist/admin/editor/styles/SiteClasses.js +31 -0
- package/dist/admin/editor/styles/StylesPanel.d.ts +3 -1
- package/dist/admin/editor/styles/StylesPanel.js +9 -6
- package/dist/admin/editor/styles/VariantBar.js +1 -1
- package/dist/admin/editor/styles/context.d.ts +9 -2
- package/dist/admin/editor/styles/context.js +14 -9
- package/dist/admin/editor/styles/controls.js +3 -3
- package/dist/admin/editor/styles/sections.js +2 -2
- package/dist/admin/editor/styles/styles.scss +147 -93
- package/dist/admin/editor/templates/Bindable.d.ts +14 -6
- package/dist/admin/editor/templates/Bindable.js +74 -18
- package/dist/admin/editor/templates/SamplePicker.js +1 -1
- package/dist/admin/editor/templates/binding.d.ts +11 -4
- package/dist/admin/editor/templates/binding.js +23 -3
- package/dist/admin/editor/templates/templates.scss +90 -90
- package/dist/admin/editor/tooltip/tooltip.scss +4 -4
- package/dist/admin/editor/topbar/DocumentActions.js +1 -1
- package/dist/admin/editor/topbar/DocumentTitle.js +1 -1
- package/dist/admin/editor/topbar/screens/DrawerRouter.d.ts +1 -1
- package/dist/admin/editor/topbar/screens/ScreenDrawer.js +1 -1
- package/dist/admin/editor/topbar/screens/drawerRouterSupport.d.ts +1 -1
- package/dist/admin/editor/topbar/screens/screens.scss +20 -20
- package/dist/admin/editor/topbar/settingsDrawer.js +3 -3
- package/dist/admin/editor/topbar/settingsDrawer.scss +7 -7
- package/dist/admin/editor/topbar/topbar.scss +47 -47
- package/dist/admin/editor/ui/Select.js +1 -1
- package/dist/admin/editor/ui/controls.scss +26 -26
- package/dist/admin/screen/BuilderScreen.js +1 -1
- package/dist/ai/adapters/anthropic.d.ts +2 -2
- package/dist/ai/images/service.js +1 -1
- package/dist/ai/loop.d.ts +5 -5
- package/dist/ai/prompt.js +8 -2
- package/dist/ai/tools.js +11 -2
- package/dist/blocks/builtins/carousel.d.ts +32 -0
- package/dist/blocks/builtins/carousel.js +122 -0
- package/dist/blocks/builtins/disclosure.d.ts +13 -0
- package/dist/blocks/builtins/disclosure.js +107 -0
- package/dist/blocks/builtins/faq.d.ts +17 -0
- package/dist/blocks/builtins/faq.js +88 -0
- package/dist/blocks/builtins/filterLink.d.ts +22 -0
- package/dist/blocks/builtins/filterLink.js +76 -0
- package/dist/blocks/builtins/headingId.d.ts +15 -0
- package/dist/blocks/builtins/headingId.js +36 -0
- package/dist/blocks/builtins/icon.d.ts +8 -0
- package/dist/blocks/builtins/icon.js +45 -0
- package/dist/blocks/builtins/index.d.ts +35 -0
- package/dist/blocks/builtins/index.js +50 -0
- package/dist/blocks/builtins/lightbox.d.ts +43 -0
- package/dist/blocks/builtins/lightbox.js +93 -0
- package/dist/blocks/builtins/mediaBackdrop.d.ts +11 -0
- package/dist/blocks/builtins/mediaBackdrop.js +79 -0
- package/dist/blocks/builtins/sectionRef.d.ts +26 -0
- package/dist/blocks/builtins/sectionRef.js +78 -0
- package/dist/blocks/builtins/shared.d.ts +33 -0
- package/dist/blocks/builtins/shared.js +70 -0
- package/dist/blocks/builtins/tableOfContents.d.ts +3 -0
- package/dist/blocks/builtins/tableOfContents.js +44 -0
- package/dist/blocks/defaults.d.ts +28 -10
- package/dist/blocks/defaults.js +413 -20
- package/dist/blocks/index.d.ts +4 -2
- package/dist/blocks/index.js +3 -1
- package/dist/core/attrs.d.ts +27 -0
- package/dist/core/attrs.js +132 -0
- package/dist/core/bindings.d.ts +123 -12
- package/dist/core/bindings.js +504 -19
- package/dist/core/blocks.d.ts +46 -1
- package/dist/core/blocks.js +136 -0
- package/dist/core/classes.d.ts +10 -2
- package/dist/core/classes.js +34 -5
- package/dist/core/fieldAccess.js +1 -1
- package/dist/core/fieldHooks.d.ts +1 -1
- package/dist/core/headings.d.ts +21 -0
- package/dist/core/headings.js +47 -0
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +4 -2
- package/dist/core/motion.d.ts +24 -15
- package/dist/core/motion.js +20 -12
- package/dist/core/operations.js +59 -2
- package/dist/core/payloadBlocks.js +3 -1
- package/dist/core/schema.js +20 -0
- package/dist/core/tree.js +24 -1
- package/dist/core/types.d.ts +87 -0
- package/dist/core/validate.js +29 -4
- package/dist/css/tokens.d.ts +6 -3
- package/dist/css/tokens.js +48 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/live/draftAccess.js +1 -1
- package/dist/live/session.d.ts +1 -1
- package/dist/live/storage.js +4 -2
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +50 -13
- package/dist/mcp/shared.d.ts +34 -31
- package/dist/mcp/shared.js +23 -8
- package/dist/plugin/index.d.ts +8 -0
- package/dist/plugin/index.js +30 -12
- package/dist/plugin/listCollections.d.ts +17 -2
- package/dist/plugin/listCollections.js +44 -7
- package/dist/plugin/references.d.ts +5 -0
- package/dist/plugin/references.js +1 -1
- package/dist/plugin/templates.d.ts +4 -0
- package/dist/plugin/templates.js +24 -9
- package/dist/protocol/index.d.ts +3 -1
- package/dist/react/canvas/BuilderCanvas.js +6 -4
- package/dist/react/canvas/fetchDocs.d.ts +16 -2
- package/dist/react/canvas/fetchDocs.js +42 -9
- package/dist/react/canvas/inline/rich/editor.js +1 -6
- package/dist/react/canvas/measure.d.ts +3 -1
- package/dist/react/canvas/measure.js +26 -2
- package/dist/react/canvas/resolveLayout.d.ts +1 -1
- package/dist/react/canvas/resolveLayout.js +17 -6
- package/dist/react/canvas/serverBlocks.d.ts +11 -0
- package/dist/react/canvas/serverBlocks.js +28 -1
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +1 -1
- package/dist/react/components/Button.d.ts +11 -2
- package/dist/react/components/Button.js +43 -6
- package/dist/react/components/CollectionList.d.ts +6 -3
- package/dist/react/components/CollectionList.js +21 -7
- package/dist/react/components/Container.js +4 -1
- package/dist/react/components/Field.js +13 -2
- package/dist/react/components/Heading.js +9 -2
- package/dist/react/components/Image.d.ts +9 -0
- package/dist/react/components/Image.js +16 -1
- package/dist/react/components/List.d.ts +1 -0
- package/dist/react/components/List.js +6 -0
- package/dist/react/components/Menu.d.ts +16 -0
- package/dist/react/components/Menu.js +83 -19
- package/dist/react/components/RichText.d.ts +8 -3
- package/dist/react/components/RichText.js +25 -4
- package/dist/react/components/builtins/Accordion.d.ts +9 -0
- package/dist/react/components/builtins/Accordion.js +37 -0
- package/dist/react/components/builtins/BackdropVideo.d.ts +13 -0
- package/dist/react/components/builtins/BackdropVideo.js +16 -0
- package/dist/react/components/builtins/Carousel.d.ts +13 -0
- package/dist/react/components/builtins/Carousel.js +134 -0
- package/dist/react/components/builtins/Disclosure.d.ts +7 -0
- package/dist/react/components/builtins/Disclosure.js +13 -0
- package/dist/react/components/builtins/FilterLink.d.ts +8 -0
- package/dist/react/components/builtins/FilterLink.js +30 -0
- package/dist/react/components/builtins/Icon.d.ts +14 -0
- package/dist/react/components/builtins/Icon.js +28 -0
- package/dist/react/components/builtins/Lightbox.d.ts +45 -0
- package/dist/react/components/builtins/Lightbox.js +252 -0
- package/dist/react/components/builtins/MediaBackdrop.d.ts +14 -0
- package/dist/react/components/builtins/MediaBackdrop.js +61 -0
- package/dist/react/components/builtins/SectionRef.d.ts +7 -0
- package/dist/react/components/builtins/SectionRef.js +17 -0
- package/dist/react/components/builtins/TableOfContents.d.ts +7 -0
- package/dist/react/components/builtins/TableOfContents.js +21 -0
- package/dist/react/components/builtins/glyphs.d.ts +8 -0
- package/dist/react/components/builtins/glyphs.js +7 -0
- package/dist/react/components/builtins/index.d.ts +32 -0
- package/dist/react/components/builtins/index.js +36 -0
- package/dist/react/components/index.js +2 -0
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +3 -1
- package/dist/react/motion/runtime.js +10 -6
- package/dist/react/motion/style.js +1 -1
- package/dist/react/render/PayloadRoot.js +1 -1
- package/dist/react/render/RenderLayout.d.ts +1 -1
- package/dist/react/render/RenderLayout.js +77 -24
- package/dist/react/render/lists.d.ts +107 -5
- package/dist/react/render/lists.js +284 -9
- package/dist/react/render/resolve.d.ts +22 -2
- package/dist/react/render/resolve.js +45 -24
- package/dist/react/render/sections.d.ts +9 -0
- package/dist/react/render/sections.js +51 -0
- package/dist/react/render/types.d.ts +6 -1
- package/dist/react/server.d.ts +4 -4
- package/dist/react/server.js +55 -7
- package/dist/react/theme/ThemeStyle.d.ts +13 -2
- package/dist/react/theme/ThemeStyle.js +13 -3
- package/dist/theme/admin/ColorField.d.ts +2 -2
- package/dist/theme/admin/ColorField.js +2 -2
- package/dist/theme/admin/FontField.d.ts +2 -2
- package/dist/theme/admin/FontField.js +2 -2
- package/dist/theme/admin/SaveSignal.js +2 -2
- package/dist/theme/admin/fields.scss +48 -48
- package/package.json +23 -28
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
height: 24px;
|
|
28
28
|
margin: 0;
|
|
29
29
|
padding: 0 9px 0 7px;
|
|
30
|
-
border: 1px solid var(--
|
|
31
|
-
border-radius: var(--radius-
|
|
32
|
-
background: var(--
|
|
33
|
-
color: var(--
|
|
30
|
+
border: 1px solid var(--theme-elevation-150);
|
|
31
|
+
border-radius: var(--style-radius-s, 4px);
|
|
32
|
+
background: var(--theme-bg);
|
|
33
|
+
color: var(--theme-text);
|
|
34
34
|
font: inherit;
|
|
35
35
|
font-size: var(--be-text-s);
|
|
36
36
|
font-weight: var(--be-weight-medium);
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
.builder-media__spinner {
|
|
62
62
|
width: 10px;
|
|
63
63
|
height: 10px;
|
|
64
|
-
border: 2px solid var(--
|
|
64
|
+
border: 2px solid var(--theme-elevation-200);
|
|
65
65
|
border-top-color: var(--be-accent);
|
|
66
66
|
border-radius: 50%;
|
|
67
67
|
animation: builder-media-spin 0.8s linear infinite;
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
.builder-styles__popover.builder-media__popover {
|
|
83
|
-
--bs-border: var(--be-border, var(--
|
|
83
|
+
--bs-border: var(--be-border, var(--theme-elevation-150));
|
|
84
84
|
|
|
85
85
|
width: 300px;
|
|
86
86
|
max-height: min(560px, calc(100vh - 16px));
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
gap: 6px;
|
|
116
116
|
min-width: 0;
|
|
117
117
|
overflow: hidden;
|
|
118
|
-
color: var(--
|
|
118
|
+
color: var(--theme-text);
|
|
119
119
|
font-size: var(--be-text-m);
|
|
120
120
|
font-weight: var(--be-weight-strong);
|
|
121
121
|
white-space: nowrap;
|
|
@@ -130,14 +130,14 @@
|
|
|
130
130
|
height: 22px;
|
|
131
131
|
padding: 0;
|
|
132
132
|
border: 0;
|
|
133
|
-
border-radius: var(--radius-
|
|
133
|
+
border-radius: var(--style-radius-s, 4px);
|
|
134
134
|
background: none;
|
|
135
|
-
color: var(--
|
|
135
|
+
color: var(--theme-elevation-600);
|
|
136
136
|
cursor: pointer;
|
|
137
137
|
|
|
138
138
|
&:hover {
|
|
139
|
-
background: var(--
|
|
140
|
-
color: var(--
|
|
139
|
+
background: var(--theme-elevation-100);
|
|
140
|
+
color: var(--theme-text);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -152,8 +152,8 @@
|
|
|
152
152
|
flex: none;
|
|
153
153
|
width: 40px;
|
|
154
154
|
height: 40px;
|
|
155
|
-
border-radius: var(--radius-
|
|
156
|
-
background: var(--
|
|
155
|
+
border-radius: var(--style-radius-s, 4px);
|
|
156
|
+
background: var(--theme-elevation-100);
|
|
157
157
|
object-fit: cover;
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
.builder-media__file {
|
|
167
167
|
min-width: 0;
|
|
168
168
|
overflow: hidden;
|
|
169
|
-
color: var(--
|
|
169
|
+
color: var(--theme-elevation-700);
|
|
170
170
|
font-size: var(--be-text-s);
|
|
171
171
|
white-space: nowrap;
|
|
172
172
|
text-overflow: ellipsis;
|
|
@@ -183,11 +183,11 @@
|
|
|
183
183
|
flex-direction: column;
|
|
184
184
|
gap: 4px;
|
|
185
185
|
padding-top: 8px;
|
|
186
|
-
border-top: 1px solid var(--
|
|
186
|
+
border-top: 1px solid var(--theme-elevation-100);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
.builder-media__label {
|
|
190
|
-
color: var(--
|
|
190
|
+
color: var(--theme-elevation-600);
|
|
191
191
|
font-size: var(--be-text-s);
|
|
192
192
|
font-weight: var(--be-weight-medium);
|
|
193
193
|
}
|
|
@@ -196,28 +196,28 @@
|
|
|
196
196
|
width: 100%;
|
|
197
197
|
height: 30px;
|
|
198
198
|
padding: 0 8px;
|
|
199
|
-
border: 1px solid var(--
|
|
200
|
-
border-radius: var(--radius-
|
|
201
|
-
background: var(--
|
|
202
|
-
color: var(--
|
|
199
|
+
border: 1px solid var(--theme-elevation-150);
|
|
200
|
+
border-radius: var(--style-radius-s, 4px);
|
|
201
|
+
background: var(--theme-input-bg, var(--theme-elevation-0));
|
|
202
|
+
color: var(--theme-text);
|
|
203
203
|
font: inherit;
|
|
204
204
|
font-size: var(--be-text-m);
|
|
205
205
|
|
|
206
206
|
&:focus {
|
|
207
|
-
border-color: var(--
|
|
207
|
+
border-color: var(--theme-elevation-400);
|
|
208
208
|
outline: none;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
.builder-media__note {
|
|
213
213
|
margin: 0;
|
|
214
|
-
color: var(--
|
|
214
|
+
color: var(--theme-elevation-500);
|
|
215
215
|
font-size: var(--be-text-s);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
.builder-media__error {
|
|
219
219
|
margin: 0;
|
|
220
|
-
color: var(--
|
|
220
|
+
color: var(--theme-error-500);
|
|
221
221
|
font-size: var(--be-text-s);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// The editor's one menu primitive, on Base UI `Menu`. Use it for every "…" menu and context menu,
|
|
4
4
|
// so they all behave the same:
|
|
5
5
|
//
|
|
@@ -3,8 +3,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
// The block menu: one definition for the canvas action bar "…", the inspector header "…" and
|
|
4
4
|
// the right-click menu on the canvas and in the outline, so they never drift apart.
|
|
5
5
|
import { memo, useCallback } from 'react';
|
|
6
|
+
import { SECTION_REF_BLOCK, sectionRefId } from '../../../blocks/builtins/sectionRef.js';
|
|
6
7
|
import { findBlock, findLocation } from '../../../core/index.js';
|
|
7
|
-
import { copyBlock, copyStyles, duplicateBlock, inRow, moveBy, parseClipboard, pasteStoredBlocks, pasteStyles, removeBlock, resetStyles, siblingCount, storedClipboard, storedStyles, storesBuilderData, toggleHidden, } from '../actions.js';
|
|
8
|
+
import { copyBlock, copyStyles, detachSection, duplicateBlock, inRow, moveBy, parseClipboard, pasteStoredBlocks, pasteStyles, removeBlock, resetStyles, siblingCount, storedClipboard, storedStyles, storesBuilderData, toggleHidden, } from '../actions.js';
|
|
8
9
|
import { useRuntime } from '../runtime.js';
|
|
9
10
|
import { requestSaveSection } from '../sections/SectionDialog.js';
|
|
10
11
|
import { useEditor } from '../store.js';
|
|
@@ -91,6 +92,9 @@ export function blockMenuEntries(runtime, id, origin) {
|
|
|
91
92
|
...(runtime.sections.enabled
|
|
92
93
|
? [{ icon: 'section', label: 'Save as section…', ownFocus: true, run: () => requestSaveSection(runtime, block) }]
|
|
93
94
|
: []),
|
|
95
|
+
...(runtime.sections.enabled && block.type === SECTION_REF_BLOCK && sectionRefId(block.props?.section) !== null
|
|
96
|
+
? [{ icon: 'section', label: 'Detach section', run: () => void detachSection(runtime, id) }]
|
|
97
|
+
: []),
|
|
94
98
|
'separator',
|
|
95
99
|
{ icon: 'delete', label: 'Delete', keys: keys('delete'), danger: true, run: () => removeBlock(runtime, id) },
|
|
96
100
|
];
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
max-height: var(--available-height, 480px);
|
|
15
15
|
overflow: auto;
|
|
16
16
|
padding: 4px;
|
|
17
|
-
border: 1px solid var(--be-border, var(--
|
|
18
|
-
border-radius: var(--be-radius-m, var(--radius-
|
|
19
|
-
background: var(--
|
|
20
|
-
color: var(--
|
|
21
|
-
font-family: var(--
|
|
17
|
+
border: 1px solid var(--be-border, var(--theme-elevation-150));
|
|
18
|
+
border-radius: var(--be-radius-m, var(--style-radius-m, 6px));
|
|
19
|
+
background: var(--theme-bg);
|
|
20
|
+
color: var(--theme-text);
|
|
21
|
+
font-family: var(--font-body);
|
|
22
22
|
font-size: var(--be-text-m);
|
|
23
23
|
line-height: 1.3;
|
|
24
24
|
box-shadow: var(--be-shadow);
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
gap: 8px;
|
|
45
45
|
height: 30px;
|
|
46
46
|
padding: 0 8px;
|
|
47
|
-
border-radius: var(--be-radius, var(--radius-
|
|
48
|
-
color: var(--
|
|
47
|
+
border-radius: var(--be-radius, var(--style-radius-s, 4px));
|
|
48
|
+
color: var(--theme-text);
|
|
49
49
|
text-decoration: none;
|
|
50
50
|
white-space: nowrap;
|
|
51
51
|
cursor: default;
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
|
|
55
55
|
svg {
|
|
56
56
|
flex: none;
|
|
57
|
-
color: var(--be-muted, var(--
|
|
57
|
+
color: var(--be-muted, var(--theme-elevation-500));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
&[data-highlighted] {
|
|
61
|
-
background: var(--be-hover, var(--
|
|
61
|
+
background: var(--be-hover, var(--theme-elevation-100));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
&[data-disabled] {
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
|
|
69
69
|
// A disabled destructive item is neutral: red says "this acts", and it cannot act.
|
|
70
70
|
.builder-menu__item--danger:not([data-disabled]) {
|
|
71
|
-
color: var(--
|
|
71
|
+
color: var(--theme-error-500);
|
|
72
72
|
|
|
73
73
|
svg {
|
|
74
74
|
color: currentColor;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
&[data-highlighted] {
|
|
78
|
-
background: color-mix(in srgb, var(--
|
|
78
|
+
background: color-mix(in srgb, var(--theme-error-500) 12%, transparent);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -100,27 +100,27 @@
|
|
|
100
100
|
padding: 0 0 0 16px;
|
|
101
101
|
border: 0;
|
|
102
102
|
background: none;
|
|
103
|
-
color: var(--be-subtle, var(--
|
|
103
|
+
color: var(--be-subtle, var(--theme-elevation-400));
|
|
104
104
|
font: inherit;
|
|
105
105
|
font-size: var(--be-text-s);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
.builder-menu .builder-menu__check {
|
|
109
|
-
color: var(--be-accent, var(--
|
|
109
|
+
color: var(--be-accent, var(--theme-success-500));
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
.builder-menu__sep {
|
|
113
113
|
height: 1px;
|
|
114
114
|
margin: 4px 0;
|
|
115
115
|
border: 0;
|
|
116
|
-
background: var(--be-border-soft, var(--
|
|
116
|
+
background: var(--be-border-soft, var(--theme-elevation-100));
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
.builder-menu__note {
|
|
120
120
|
margin: 4px 0 0;
|
|
121
121
|
padding: 6px 8px 4px;
|
|
122
|
-
border-top: 1px solid var(--be-border-soft, var(--
|
|
123
|
-
color: var(--be-muted, var(--
|
|
122
|
+
border-top: 1px solid var(--be-border-soft, var(--theme-elevation-100));
|
|
123
|
+
color: var(--be-muted, var(--theme-elevation-500));
|
|
124
124
|
font-size: var(--be-text-s);
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// The Motion tab: a block's animations (`block.motion`). One section per kind, in the Styles
|
|
4
4
|
// panel's look. Every edit is an `update` operation that sends the whole kind (it replaces the
|
|
5
5
|
// kind), so undo, multiplayer and the AI see the same data. A slider drag is one undo step.
|
|
@@ -98,7 +98,7 @@ function HoverSection({ blockId, hover, press, edit }) {
|
|
|
98
98
|
}
|
|
99
99
|
function ScrollSection({ scroll, edit }) {
|
|
100
100
|
const n = scroll ? scrollValue(scroll) : 0;
|
|
101
|
-
return (_jsxs(Section, { title: "Scroll", set: Boolean(scroll), removeLabel: "Remove the scroll effect", onRemove: () => edit.remove(['scroll']), children: [_jsx(PresetRow, { label: "Effect", name: "Scroll effect", preset: scroll?.preset, options: OPTIONS.scroll, onChange: (p) => edit.preset('scroll', p) }), _jsx(Note, { children: scroll ? describePreset('scroll', scroll.preset) : 'Follows the scroll while the block passes through the window.' }), scroll?.preset === 'parallax' && (_jsx(NumberRow, { label: "Distance", value: n, min: -300, max: 300, step: 10, unit: "px", isSet: scroll.distance !== undefined, onChange: (value) => edit.value('scroll', 'distance', value), onReset: () => edit.value('scroll', 'distance', undefined) })), scroll?.preset === 'zoom' && (_jsx(NumberRow, { label: "Start size", value: toPercent(n), min: 50, max: 150, step: 5, unit: "%", isSet: scroll.scale !== undefined, onChange: (value) => edit.value('scroll', 'scale', fromPercent(value)), onReset: () => edit.value('scroll', 'scale', undefined) }))] }));
|
|
101
|
+
return (_jsxs(Section, { title: "Scroll", set: Boolean(scroll), removeLabel: "Remove the scroll effect", onRemove: () => edit.remove(['scroll']), children: [_jsx(PresetRow, { label: "Effect", name: "Scroll effect", preset: scroll?.preset, options: OPTIONS.scroll, onChange: (p) => edit.preset('scroll', p) }), _jsx(Note, { children: scroll ? describePreset('scroll', scroll.preset) : 'Follows the scroll while the block passes through the window.' }), scroll?.preset === 'parallax' && (_jsx(NumberRow, { label: "Distance", value: n, min: -300, max: 300, step: 10, unit: "px", isSet: scroll.distance !== undefined, onChange: (value) => edit.value('scroll', 'distance', value), onReset: () => edit.value('scroll', 'distance', undefined) })), scroll?.preset === 'zoom' && (_jsx(NumberRow, { label: "Start size", value: toPercent(n), min: 50, max: 150, step: 5, unit: "%", isSet: scroll.scale !== undefined, onChange: (value) => edit.value('scroll', 'scale', fromPercent(value)), onReset: () => edit.value('scroll', 'scale', undefined) })), scroll?.preset === 'recede' && (_jsx(NumberRow, { label: "End size", value: toPercent(n), min: 50, max: 100, step: 1, unit: "%", isSet: scroll.scale !== undefined, onChange: (value) => edit.value('scroll', 'scale', fromPercent(value)), onReset: () => edit.value('scroll', 'scale', undefined) }))] }));
|
|
102
102
|
}
|
|
103
103
|
function LoopSection({ loop, edit }) {
|
|
104
104
|
const v = loop ? loopValues(loop) : null;
|
|
@@ -12,9 +12,9 @@ export declare function replaceMotionPatch(motion: BlockMotion | undefined): Mot
|
|
|
12
12
|
export declare function enterValues(enter: EnterMotion): {
|
|
13
13
|
duration: number;
|
|
14
14
|
delay: number;
|
|
15
|
-
easing: "
|
|
15
|
+
easing: "bouncy" | "ease-in-out" | "ease-out" | "linear" | "spring";
|
|
16
16
|
distance: number;
|
|
17
|
-
trigger: "
|
|
17
|
+
trigger: "load" | "view";
|
|
18
18
|
amount: number;
|
|
19
19
|
repeat: boolean;
|
|
20
20
|
stagger: number;
|
|
@@ -9,7 +9,7 @@ export function usesDistance(preset) {
|
|
|
9
9
|
/** The number a preset of each kind uses, besides `duration` (the other numbers do not apply). */
|
|
10
10
|
const PRESET_KEYS = {
|
|
11
11
|
hover: { lift: ['distance'], grow: ['scale'], tilt: ['angle'] },
|
|
12
|
-
scroll: { parallax: ['distance'], fade: [], zoom: ['scale'] },
|
|
12
|
+
scroll: { parallax: ['distance'], fade: [], zoom: ['scale'], recede: ['scale'] },
|
|
13
13
|
loop: { float: ['duration', 'distance'], pulse: ['duration', 'scale'] },
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
@@ -66,7 +66,7 @@ export function enterValues(enter) {
|
|
|
66
66
|
}
|
|
67
67
|
export const hoverValue = (hover) => hover.preset === 'lift' ? (hover.distance ?? HOVER_DEFAULTS.distance) : hover.preset === 'grow' ? (hover.scale ?? HOVER_DEFAULTS.scale) : (hover.angle ?? HOVER_DEFAULTS.angle);
|
|
68
68
|
export const pressScale = (scale) => scale ?? PRESS_DEFAULTS.scale;
|
|
69
|
-
export const scrollValue = (scroll) => scroll.preset === 'zoom' ? (scroll.scale ?? SCROLL_DEFAULTS.scale) : (scroll.distance ?? SCROLL_DEFAULTS.distance);
|
|
69
|
+
export const scrollValue = (scroll) => scroll.preset === 'zoom' || scroll.preset === 'recede' ? (scroll.scale ?? SCROLL_DEFAULTS.scale) : (scroll.distance ?? SCROLL_DEFAULTS.distance);
|
|
70
70
|
export function loopValues(loop) {
|
|
71
71
|
const defaults = LOOP_DEFAULTS[loop.preset];
|
|
72
72
|
return {
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
justify-content: space-between;
|
|
9
9
|
gap: 8px;
|
|
10
10
|
padding: 0 0 8px;
|
|
11
|
-
border-bottom: 1px solid var(--
|
|
11
|
+
border-bottom: 1px solid var(--theme-elevation-100);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.builder-motion__summary {
|
|
15
15
|
min-width: 0;
|
|
16
16
|
margin: 0;
|
|
17
|
-
color: var(--
|
|
17
|
+
color: var(--theme-text);
|
|
18
18
|
font-size: var(--be-text-m);
|
|
19
19
|
line-height: 1.35;
|
|
20
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Icon } from '../icons.js';
|
|
4
4
|
import { inlineEditing } from '../inline.js';
|
|
5
5
|
import { InlineToolbar } from '../InlineToolbar.js';
|
|
@@ -22,5 +22,5 @@ export function RegionPane({ regions, name }) {
|
|
|
22
22
|
const right = state.access ? regionAccessAt(state.access, field.path) : null;
|
|
23
23
|
const locked = right !== null && !right.update;
|
|
24
24
|
return (_jsx("li", { children: _jsxs("button", { type: "button", className: "builder-editor__menu-item", onClick: () => runtime.doc.openSettings({ path: field.path, tabs: field.tabs }), "data-tooltip": locked ? 'You may not change this field' : 'Edit in the settings', children: [_jsx(Icon, { name: locked ? 'lock' : 'rename', size: 14 }), field.label] }) }, field.path));
|
|
25
|
-
}) })) : (_jsx("p", { className: "builder-editor__hint", children: "It has no fields to edit." })), _jsx(Button, { buttonStyle: "secondary", size: "
|
|
25
|
+
}) })) : (_jsx("p", { className: "builder-editor__hint", children: "It has no fields to edit." })), _jsx(Button, { buttonStyle: "secondary", size: "small", margin: false, onClick: () => editRegionFields(runtime, regions, region.name), children: "Edit fields in the settings" })] })] }));
|
|
26
26
|
}
|
|
@@ -7,6 +7,8 @@ type Props = {
|
|
|
7
7
|
readonly path: string;
|
|
8
8
|
readonly value: unknown;
|
|
9
9
|
readonly onChange: (value: unknown) => void;
|
|
10
|
+
/** The other values of the same object (block props, group or row), for fields that read a sibling. */
|
|
11
|
+
readonly siblings?: Record<string, unknown>;
|
|
10
12
|
};
|
|
11
13
|
export declare function fieldLabel(field: Field): string;
|
|
12
14
|
/**
|
|
@@ -16,7 +18,7 @@ export declare function fieldLabel(field: Field): string;
|
|
|
16
18
|
* `{ relationTo, value }`: we store IDs, or `{ relationTo, value: id }` for polymorphic fields.
|
|
17
19
|
* SelectInput returns the option object. DatePicker returns a Date, stored as an ISO string.
|
|
18
20
|
*/
|
|
19
|
-
export declare function RenderBlockField({ field, onChange, path, value }: Props): import("react").JSX.Element;
|
|
21
|
+
export declare function RenderBlockField({ field, onChange, path, value, siblings }: Props): import("react").JSX.Element;
|
|
20
22
|
type FieldsProps = {
|
|
21
23
|
readonly fields: Field[];
|
|
22
24
|
/** The object the fields read from: block props, a group value or an array row. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { CheckboxInput, DatePicker, FieldLabel, RelationshipInput, SelectInput, TextareaInput, TextInput, UploadInput, useConfig, } from '@payloadcms/ui';
|
|
4
4
|
import { Fragment, useEffect } from 'react';
|
|
5
5
|
import { getBlockDefinition, hasStaticDefault } from '../../core/index.js';
|
|
@@ -8,6 +8,7 @@ import { isStructuralChange } from './fields/arrayState.js';
|
|
|
8
8
|
import { CheckedTextField, NumberField } from './fields/CheckedInputs.js';
|
|
9
9
|
import { FieldSection, GroupField } from './fields/GroupField.js';
|
|
10
10
|
import { JsonField } from './fields/JsonField.js';
|
|
11
|
+
import { WhereField } from './fields/WhereField.js';
|
|
11
12
|
import { ManyValuesField } from './fields/ManyValuesField.js';
|
|
12
13
|
import { PointField } from './fields/PointField.js';
|
|
13
14
|
import { RichTextField } from './fields/RichTextField.js';
|
|
@@ -60,7 +61,7 @@ function Unsupported({ label, reason }) {
|
|
|
60
61
|
* `{ relationTo, value }`: we store IDs, or `{ relationTo, value: id }` for polymorphic fields.
|
|
61
62
|
* SelectInput returns the option object. DatePicker returns a Date, stored as an ISO string.
|
|
62
63
|
*/
|
|
63
|
-
export function RenderBlockField({ field, onChange, path, value }) {
|
|
64
|
+
export function RenderBlockField({ field, onChange, path, value, siblings }) {
|
|
64
65
|
const { config } = useConfig();
|
|
65
66
|
// In another locale, an untranslated text shows the fallback language's text as its placeholder.
|
|
66
67
|
const placeholder = useLocalePlaceholder(path);
|
|
@@ -126,8 +127,15 @@ export function RenderBlockField({ field, onChange, path, value }) {
|
|
|
126
127
|
const pickerAppearance = field.admin?.date?.pickerAppearance ?? 'dayOnly';
|
|
127
128
|
return (_jsxs("div", { className: "field-type date-time-field", children: [_jsx(FieldLabel, { label: label, path: path, required: required }), _jsx("div", { className: "field-type__wrap", children: _jsx(DatePicker, { onChange: (date) => onChange(date ? date.toISOString() : null), pickerAppearance: pickerAppearance, value: typeof value === 'string' ? value : undefined }) })] }));
|
|
128
129
|
}
|
|
129
|
-
case 'json':
|
|
130
|
+
case 'json': {
|
|
131
|
+
// `admin.custom.builderWhere`: a Payload where query, edited as condition rows.
|
|
132
|
+
const where = field.admin?.custom?.builderWhere;
|
|
133
|
+
if (where) {
|
|
134
|
+
const collection = where.collectionField ? siblings?.[where.collectionField] : undefined;
|
|
135
|
+
return (_jsx(WhereField, { collection: typeof collection === 'string' ? collection : undefined, description: description, label: label, onChange: onChange, path: path, required: required, value: value }));
|
|
136
|
+
}
|
|
130
137
|
return _jsx(JsonField, { description: description, label: label, onChange: onChange, path: path, required: required, value: value });
|
|
138
|
+
}
|
|
131
139
|
case 'point':
|
|
132
140
|
return _jsx(PointField, { description: description, label: label, onChange: onChange, path: path, required: required, value: value });
|
|
133
141
|
case 'blocks':
|
|
@@ -176,7 +184,8 @@ export function RenderBlockFields({ fields, data, path, onChange, scope = fields
|
|
|
176
184
|
if (field.type === 'collapsible') {
|
|
177
185
|
const shared = _jsx(RenderBlockFields, { fields: field.fields, data: record, path: path, onChange: onChange, scope: scope });
|
|
178
186
|
const title = text(field.label);
|
|
179
|
-
|
|
187
|
+
const folded = field.admin?.initCollapsed === true;
|
|
188
|
+
out.push(title ? (_jsx(FieldSection, { label: title, description: folded ? text(field.admin?.description) : undefined, collapsed: folded ? true : undefined, children: shared }, `layout-${index}`)) : (_jsx(Fragment, { children: shared }, `layout-${index}`)));
|
|
180
189
|
return;
|
|
181
190
|
}
|
|
182
191
|
if (field.type === 'row' || (field.type === 'group' && !('name' in field && field.name))) {
|
|
@@ -210,7 +219,7 @@ export function RenderBlockFields({ fields, data, path, onChange, scope = fields
|
|
|
210
219
|
if (!access.read)
|
|
211
220
|
return;
|
|
212
221
|
const onFieldChange = (value) => setField(name, value, field);
|
|
213
|
-
out.push(_jsxs("div", { "data-builder-field": fieldPath, style: { display: 'contents' }, children: [_jsx(FieldAccessFrame, { locked: !access.update, children: _jsx(LocaleFieldFrame, { path: fieldPath, name: name, children: _jsx(FieldSlot, { field: field, path: fieldPath, value: record[name], onChange: onFieldChange, label: fieldLabel(field), children: _jsx(RenderBlockField, { field: field, path: fieldPath, value: record[name], onChange: onFieldChange }) }) }) }), _jsx(PeerFieldNote, { fieldPath: fieldPath }), _jsx(FieldProblem, { path: fieldPath })] }, name));
|
|
222
|
+
out.push(_jsxs("div", { "data-builder-field": fieldPath, style: { display: 'contents' }, children: [_jsx(FieldAccessFrame, { locked: !access.update, children: _jsx(LocaleFieldFrame, { path: fieldPath, name: name, children: _jsx(FieldSlot, { field: field, path: fieldPath, value: record[name], onChange: onFieldChange, label: fieldLabel(field), children: _jsx(RenderBlockField, { field: field, path: fieldPath, value: record[name], onChange: onFieldChange, siblings: record }) }) }) }), _jsx(PeerFieldNote, { fieldPath: fieldPath }), _jsx(FieldProblem, { path: fieldPath })] }, name));
|
|
214
223
|
});
|
|
215
224
|
return _jsx(_Fragment, { children: out });
|
|
216
225
|
}
|
|
@@ -73,6 +73,7 @@ export function createRuntime(config, api, document, options = {}) {
|
|
|
73
73
|
api,
|
|
74
74
|
document: { collection: document.collection, id: document.id },
|
|
75
75
|
...(config.regions?.length ? { regions: config.regions } : {}),
|
|
76
|
+
...(config.relations && Object.keys(config.relations).length > 0 ? { relations: config.relations } : {}),
|
|
76
77
|
};
|
|
77
78
|
const runtime = {
|
|
78
79
|
config,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// Color control and its picker popover: theme colors, the palette grid, an opacity modifier
|
|
4
4
|
// and an arbitrary hex value. No color picker dependency.
|
|
5
5
|
import { useState } from 'react';
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,31 @@
|
|
|
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,5 +1,7 @@
|
|
|
1
1
|
import type { Block } from '../../../core/types.js';
|
|
2
2
|
import './styles.scss';
|
|
3
|
-
|
|
3
|
+
/** `slot`: edit the classes of that slot's own element (`slotClassName`) instead of the block's. */
|
|
4
|
+
export declare function StylesPanel({ block, slot }: {
|
|
4
5
|
block: Block;
|
|
6
|
+
slot?: string | null;
|
|
5
7
|
}): import("react").JSX.Element;
|
|
@@ -10,11 +10,13 @@ import { StylesContext, writeClassName, writeStyle } from './context.js';
|
|
|
10
10
|
import { createReader } from './model.js';
|
|
11
11
|
import { stopEditorKeys } from './popover.js';
|
|
12
12
|
import { RawClasses } from './RawClasses.js';
|
|
13
|
+
import { SiteClasses } from './SiteClasses.js';
|
|
13
14
|
import { StyleSections } from './sections.js';
|
|
14
15
|
import { BREAKPOINTS, breakpointAt, breakpointWidths, reloadStyleTokens, useStyleTokens, withFallback } from './tokens.js';
|
|
15
16
|
import { VariantBar } from './VariantBar.js';
|
|
16
17
|
import './styles.scss';
|
|
17
|
-
|
|
18
|
+
/** `slot`: edit the classes of that slot's own element (`slotClassName`) instead of the block's. */
|
|
19
|
+
export function StylesPanel({ block, slot = null }) {
|
|
18
20
|
const runtime = useRuntime();
|
|
19
21
|
const { tokensEndpoint } = runtime.config;
|
|
20
22
|
const entry = useStyleTokens(tokensEndpoint);
|
|
@@ -23,12 +25,13 @@ export function StylesPanel({ block }) {
|
|
|
23
25
|
const frame = useValue(runtime.frame);
|
|
24
26
|
const widths = useMemo(() => breakpointWidths(tokens), [tokens]);
|
|
25
27
|
const canvasBreakpoint = frame.width > 0 ? breakpointAt(widths, frame.width) : 'base';
|
|
26
|
-
const className = block.className ?? '';
|
|
28
|
+
const className = (slot ? block.slotClassName?.[slot] : block.className) ?? '';
|
|
27
29
|
const blockId = block.id;
|
|
28
30
|
const [error] = useState(() => createValueStore(null));
|
|
29
31
|
const message = useValue(error);
|
|
30
32
|
const value = useMemo(() => ({
|
|
31
33
|
blockId,
|
|
34
|
+
slot,
|
|
32
35
|
blockType: block.type,
|
|
33
36
|
className,
|
|
34
37
|
variant,
|
|
@@ -38,9 +41,9 @@ export function StylesPanel({ block }) {
|
|
|
38
41
|
? createReader(className, { ...variant, breakpoint: canvasBreakpoint }, tokens)
|
|
39
42
|
: null,
|
|
40
43
|
canvasBreakpoint,
|
|
41
|
-
set: (property, v, options) => error.set(writeStyle(runtime, blockId, variant, tokens, property, v, options)),
|
|
42
|
-
setClassName: (next, mergeKey) => writeClassName(runtime, blockId, next, mergeKey),
|
|
44
|
+
set: (property, v, options) => error.set(writeStyle(runtime, { blockId, slot }, variant, tokens, property, v, options)),
|
|
45
|
+
setClassName: (next, mergeKey) => writeClassName(runtime, { blockId, slot }, next, mergeKey),
|
|
43
46
|
error,
|
|
44
|
-
}), [runtime, blockId, block.type, className, variant, tokens, error, canvasBreakpoint]);
|
|
45
|
-
return (_jsx(StylesContext, { value: value, children: _jsxs("div", { className: "builder-styles", onKeyDown: stopEditorKeys, children: [_jsx(VariantBar, {}), message && (_jsxs("p", { className: "builder-styles__hint builder-styles__hint--error", role: "alert", children: [message, ' ', _jsx("button", { type: "button", className: "builder-styles__link", onClick: () => error.set(null), children: "Dismiss" })] })), entry.error && (_jsxs("p", { className: "builder-styles__hint builder-styles__hint--error", children: ["Theme tokens did not load (", entry.error, ").", ' ', _jsx("button", { type: "button", className: "builder-styles__link", onClick: () => reloadStyleTokens(tokensEndpoint), children: "Retry" })] })), STYLE_PROPERTIES.length > 0 ? (_jsx(StyleSections, {})) : (_jsx("p", { className: "builder-styles__hint", children: "Visual style controls are not available yet. Edit the classes below." })), _jsx(RawClasses, {})] }) }));
|
|
47
|
+
}), [runtime, blockId, slot, block.type, className, variant, tokens, error, canvasBreakpoint]);
|
|
48
|
+
return (_jsx(StylesContext, { value: value, children: _jsxs("div", { className: "builder-styles", onKeyDown: stopEditorKeys, children: [_jsx(VariantBar, {}), message && (_jsxs("p", { className: "builder-styles__hint builder-styles__hint--error", role: "alert", children: [message, ' ', _jsx("button", { type: "button", className: "builder-styles__link", onClick: () => error.set(null), children: "Dismiss" })] })), entry.error && (_jsxs("p", { className: "builder-styles__hint builder-styles__hint--error", children: ["Theme tokens did not load (", entry.error, ").", ' ', _jsx("button", { type: "button", className: "builder-styles__link", onClick: () => reloadStyleTokens(tokensEndpoint), children: "Retry" })] })), STYLE_PROPERTIES.length > 0 ? (_jsx(StyleSections, {})) : (_jsx("p", { className: "builder-styles__hint", children: "Visual style controls are not available yet. Edit the classes below." })), _jsx(SiteClasses, {}), _jsx(RawClasses, {})] }) }));
|
|
46
49
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// Breakpoint chips and the state select. Dots mark variants that already have classes.
|
|
4
4
|
// The breakpoint here is independent of the canvas width. Edits at "all sizes" reach every
|
|
5
5
|
// screen; a control whose value a larger breakpoint overrides on the canvas says so and offers
|
|
@@ -2,8 +2,15 @@ import { type Breakpoint, type StyleTokens, type Variant } from '../../../core/i
|
|
|
2
2
|
import type { ValueStore } from '../valueStore.js';
|
|
3
3
|
import type { Runtime } from '../runtime.js';
|
|
4
4
|
import { type StyleReader } from './model.js';
|
|
5
|
+
/** What the Styles panel edits: a block's `className`, or with `slot`, that slot's `slotClassName`. */
|
|
6
|
+
export type StyleTarget = {
|
|
7
|
+
blockId: string;
|
|
8
|
+
slot?: string | null;
|
|
9
|
+
};
|
|
5
10
|
export type StylesContextValue = {
|
|
6
11
|
blockId: string;
|
|
12
|
+
/** The slot whose own classes the panel edits. Null: the block's `className`. */
|
|
13
|
+
slot: string | null;
|
|
7
14
|
/** The block type: it picks the style groups that open by default. */
|
|
8
15
|
blockType: string;
|
|
9
16
|
className: string;
|
|
@@ -28,8 +35,8 @@ export type StylesContextValue = {
|
|
|
28
35
|
};
|
|
29
36
|
export declare const StylesContext: import("react").Context<StylesContextValue | null>;
|
|
30
37
|
export declare function useStyles(): StylesContextValue;
|
|
31
|
-
export declare function writeClassName(runtime: Runtime,
|
|
38
|
+
export declare function writeClassName(runtime: Runtime, target: StyleTarget, next: string, mergeKey?: string): void;
|
|
32
39
|
/** Returns an error message when the class model refuses the value. */
|
|
33
|
-
export declare function writeStyle(runtime: Runtime,
|
|
40
|
+
export declare function writeStyle(runtime: Runtime, target: StyleTarget, variant: Variant, tokens: StyleTokens, property: string, value: string | null, options?: {
|
|
34
41
|
negative?: boolean;
|
|
35
42
|
}): string | null;
|
|
@@ -9,20 +9,25 @@ export function useStyles() {
|
|
|
9
9
|
throw new Error('useStyles must be used inside the Styles panel');
|
|
10
10
|
return value;
|
|
11
11
|
}
|
|
12
|
-
/** Reads the latest
|
|
13
|
-
function currentClassName(runtime, blockId) {
|
|
14
|
-
|
|
12
|
+
/** Reads the latest classes from the store, so two edits in one frame never overwrite each other. */
|
|
13
|
+
function currentClassName(runtime, { blockId, slot }) {
|
|
14
|
+
const block = findBlock(runtime.store.getState().layout, blockId);
|
|
15
|
+
return (slot ? block?.slotClassName?.[slot] : block?.className) ?? '';
|
|
15
16
|
}
|
|
16
|
-
export function writeClassName(runtime,
|
|
17
|
+
export function writeClassName(runtime, target, next, mergeKey) {
|
|
17
18
|
// One space between classes: double spaces from typing never reach the stored value.
|
|
18
19
|
const normalized = next.trim().replace(/\s+/g, ' ');
|
|
19
|
-
if (normalized === currentClassName(runtime,
|
|
20
|
+
if (normalized === currentClassName(runtime, target))
|
|
20
21
|
return;
|
|
21
|
-
|
|
22
|
+
const { blockId, slot } = target;
|
|
23
|
+
const op = slot
|
|
24
|
+
? { type: 'update', id: blockId, slotClassName: { [slot]: normalized || null } }
|
|
25
|
+
: { type: 'update', id: blockId, className: normalized || null };
|
|
26
|
+
runtime.store.apply(op, { mergeKey });
|
|
22
27
|
}
|
|
23
28
|
/** Returns an error message when the class model refuses the value. */
|
|
24
|
-
export function writeStyle(runtime,
|
|
25
|
-
const before = currentClassName(runtime,
|
|
29
|
+
export function writeStyle(runtime, target, variant, tokens, property, value, options) {
|
|
30
|
+
const before = currentClassName(runtime, target);
|
|
26
31
|
let next;
|
|
27
32
|
try {
|
|
28
33
|
next = setStyleValue(before, property, variant, value, { ...options, tokens });
|
|
@@ -33,6 +38,6 @@ export function writeStyle(runtime, blockId, variant, tokens, property, value, o
|
|
|
33
38
|
if (next === before)
|
|
34
39
|
return null;
|
|
35
40
|
// Edits to one property at one variant within a second become one undo step (sliders, typing).
|
|
36
|
-
writeClassName(runtime,
|
|
41
|
+
writeClassName(runtime, target, next, `style:${target.blockId}:${target.slot ?? ''}:${property}:${variantKey(variant)}`);
|
|
37
42
|
return null;
|
|
38
43
|
}
|