payload-canvas 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +625 -153
- package/dist/admin/AiKeyField.d.ts +8 -0
- package/dist/admin/AiKeyField.js +54 -0
- package/dist/admin/BuilderTab.js +4 -1
- package/dist/admin/DocumentEditView.d.ts +9 -0
- package/dist/admin/DocumentEditView.js +45 -0
- package/dist/admin/LayoutField.d.ts +2 -2
- package/dist/admin/LayoutField.js +10 -7
- package/dist/admin/TemplateConditionsField.d.ts +9 -0
- package/dist/admin/TemplateConditionsField.js +22 -0
- package/dist/admin/aiKeyField.scss +58 -0
- package/dist/admin/client.d.ts +3 -0
- package/dist/admin/client.js +6 -0
- package/dist/admin/diff/changes.js +5 -0
- package/dist/admin/editor/Canvas.js +20 -5
- package/dist/admin/editor/Editor.d.ts +3 -1
- package/dist/admin/editor/Editor.js +6 -3
- package/dist/admin/editor/Inspector.js +75 -28
- package/dist/admin/editor/Library.js +40 -15
- package/dist/admin/editor/Outline.js +21 -16
- package/dist/admin/editor/Overlay.js +8 -3
- package/dist/admin/editor/actions.d.ts +10 -2
- package/dist/admin/editor/actions.js +18 -3
- package/dist/admin/editor/assistant/AssistantPanel.js +3 -1
- package/dist/admin/editor/classes/ClassManager.d.ts +4 -0
- package/dist/admin/editor/classes/ClassManager.js +56 -0
- package/dist/admin/editor/classes/controller.d.ts +112 -0
- package/dist/admin/editor/classes/controller.js +326 -0
- package/dist/admin/editor/classes/manager.scss +262 -0
- package/dist/admin/editor/classes/managerModel.d.ts +5 -0
- package/dist/admin/editor/classes/managerModel.js +27 -0
- package/dist/admin/editor/comments/CommentLayer.d.ts +2 -0
- package/dist/admin/editor/comments/CommentLayer.js +143 -0
- package/dist/admin/editor/comments/CommentsPanel.d.ts +8 -0
- package/dist/admin/editor/comments/CommentsPanel.js +73 -0
- package/dist/admin/editor/comments/Thread.d.ts +26 -0
- package/dist/admin/editor/comments/Thread.js +84 -0
- package/dist/admin/editor/comments/comments.scss +539 -0
- package/dist/admin/editor/comments/controller.d.ts +48 -0
- package/dist/admin/editor/comments/controller.js +142 -0
- package/dist/admin/editor/contentMode.d.ts +17 -0
- package/dist/admin/editor/contentMode.js +37 -0
- package/dist/admin/editor/dnd/DropOutlines.d.ts +1 -0
- package/dist/admin/editor/dnd/DropOutlines.js +73 -0
- package/dist/admin/editor/dnd/dnd.scss +43 -0
- package/dist/admin/editor/dnd/mode.d.ts +4 -0
- package/dist/admin/editor/dnd/mode.js +39 -0
- package/dist/admin/editor/editor.scss +13 -58
- package/dist/admin/editor/empty/EmptyStart.js +18 -66
- package/dist/admin/editor/fields/AddButton.d.ts +15 -0
- package/dist/admin/editor/fields/AddButton.js +14 -0
- package/dist/admin/editor/fields/ArrayField.js +3 -2
- package/dist/admin/editor/fields/CheckedInputs.d.ts +1 -0
- package/dist/admin/editor/fields/ConditionRows.d.ts +19 -0
- package/dist/admin/editor/fields/ConditionRows.js +137 -0
- package/dist/admin/editor/fields/ListWhereField.d.ts +8 -0
- package/dist/admin/editor/fields/ListWhereField.js +20 -0
- package/dist/admin/editor/fields/QueryFiltersField.d.ts +18 -0
- package/dist/admin/editor/fields/QueryFiltersField.js +41 -0
- package/dist/admin/editor/fields/RelatedField.d.ts +19 -0
- package/dist/admin/editor/fields/RelatedField.js +44 -0
- package/dist/admin/editor/fields/SortField.d.ts +13 -0
- package/dist/admin/editor/fields/SortField.js +37 -0
- package/dist/admin/editor/fields/WhereField.d.ts +12 -4
- package/dist/admin/editor/fields/WhereField.js +33 -53
- package/dist/admin/editor/fields/collectionFields.d.ts +6 -0
- package/dist/admin/editor/fields/collectionFields.js +15 -0
- package/dist/admin/editor/fields/conditions.d.ts +99 -0
- package/dist/admin/editor/fields/conditions.js +339 -0
- package/dist/admin/editor/fields/fields.scss +232 -9
- package/dist/admin/editor/fields/listOptions.d.ts +44 -0
- package/dist/admin/editor/fields/listOptions.js +111 -0
- package/dist/admin/editor/fields/queryFilterRows.d.ts +8 -0
- package/dist/admin/editor/fields/queryFilterRows.js +29 -0
- package/dist/admin/editor/fields/whereRows.d.ts +11 -12
- package/dist/admin/editor/fields/whereRows.js +83 -34
- package/dist/admin/editor/icons.d.ts +16 -1
- package/dist/admin/editor/icons.js +30 -1
- package/dist/admin/editor/inline.js +9 -0
- package/dist/admin/editor/insert/InsertHandle.js +4 -1
- package/dist/admin/editor/insert/picker.d.ts +3 -1
- package/dist/admin/editor/insert/picker.js +17 -10
- package/dist/admin/editor/insert/spots.d.ts +12 -1
- package/dist/admin/editor/insert/spots.js +49 -10
- package/dist/admin/editor/layout/LeftPanel.js +11 -6
- package/dist/admin/editor/live/useMultiplayer.js +9 -1
- package/dist/admin/editor/menu/blockMenu.js +27 -17
- package/dist/admin/editor/names.js +11 -3
- package/dist/admin/editor/renderField.d.ts +3 -1
- package/dist/admin/editor/renderField.js +63 -12
- package/dist/admin/editor/runtime.d.ts +14 -0
- package/dist/admin/editor/runtime.js +67 -6
- package/dist/admin/editor/sections/ComponentFields.d.ts +8 -0
- package/dist/admin/editor/sections/ComponentFields.js +116 -0
- package/dist/admin/editor/sections/PropertyControls.d.ts +18 -0
- package/dist/admin/editor/sections/PropertyControls.js +65 -0
- package/dist/admin/editor/sections/components.d.ts +29 -0
- package/dist/admin/editor/sections/components.js +112 -0
- package/dist/admin/editor/sections/components.scss +238 -0
- package/dist/admin/editor/sections/variants.d.ts +32 -0
- package/dist/admin/editor/sections/variants.js +59 -0
- package/dist/admin/editor/sections/variants.scss +90 -0
- package/dist/admin/editor/shortcuts.d.ts +4 -1
- package/dist/admin/editor/shortcuts.js +19 -3
- package/dist/admin/editor/store.d.ts +18 -0
- package/dist/admin/editor/store.js +46 -0
- package/dist/admin/editor/styles/ClassBar.d.ts +14 -0
- package/dist/admin/editor/styles/ClassBar.js +90 -0
- package/dist/admin/editor/styles/ClassCss.d.ts +4 -0
- package/dist/admin/editor/styles/ClassCss.js +28 -0
- package/dist/admin/editor/styles/ClassDialog.d.ts +2 -0
- package/dist/admin/editor/styles/ClassDialog.js +151 -0
- package/dist/admin/editor/styles/ColorPicker.js +5 -2
- package/dist/admin/editor/styles/RawClasses.d.ts +26 -1
- package/dist/admin/editor/styles/RawClasses.js +184 -32
- package/dist/admin/editor/styles/StylesPanel.d.ts +3 -3
- package/dist/admin/editor/styles/StylesPanel.js +53 -14
- package/dist/admin/editor/styles/VariantBar.js +2 -2
- package/dist/admin/editor/styles/classEdit.d.ts +4 -0
- package/dist/admin/editor/styles/classEdit.js +20 -0
- package/dist/admin/editor/styles/classes.scss +381 -0
- package/dist/admin/editor/styles/context.d.ts +19 -6
- package/dist/admin/editor/styles/context.js +24 -6
- package/dist/admin/editor/styles/controls.d.ts +3 -1
- package/dist/admin/editor/styles/controls.js +30 -12
- package/dist/admin/editor/styles/popover.d.ts +6 -0
- package/dist/admin/editor/styles/popover.js +5 -5
- package/dist/admin/editor/styles/styles.scss +26 -104
- package/dist/admin/editor/styles/suggestions.d.ts +22 -0
- package/dist/admin/editor/styles/suggestions.js +77 -0
- package/dist/admin/editor/styles/tokens.js +14 -0
- package/dist/admin/editor/templates/Bindable.js +86 -57
- package/dist/admin/editor/templates/SamplePicker.js +1 -1
- package/dist/admin/editor/templates/Visibility.d.ts +9 -0
- package/dist/admin/editor/templates/Visibility.js +54 -0
- package/dist/admin/editor/templates/binding.d.ts +2 -2
- package/dist/admin/editor/templates/binding.js +2 -2
- package/dist/admin/editor/templates/templates.scss +27 -0
- package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
- package/dist/admin/editor/templates/visibilityRows.js +83 -0
- package/dist/admin/editor/topbar/ContentModeToggle.d.ts +5 -0
- package/dist/admin/editor/topbar/ContentModeToggle.js +26 -0
- package/dist/admin/editor/topbar/DocumentActions.d.ts +1 -1
- package/dist/admin/editor/topbar/DocumentActions.js +5 -4
- package/dist/admin/editor/topbar/DocumentTitle.js +7 -2
- package/dist/admin/editor/topbar/TopBar.js +15 -3
- package/dist/admin/editor/topbar/contentMode.scss +35 -0
- package/dist/admin/editor/topbar/topbar.scss +3 -1
- package/dist/admin/formChoice.d.ts +3 -0
- package/dist/admin/formChoice.js +10 -0
- package/dist/admin/layoutField.scss +69 -0
- package/dist/admin/screen/BuilderScreen.d.ts +6 -1
- package/dist/admin/screen/BuilderScreen.js +4 -3
- package/dist/admin/server/BuilderView.js +10 -3
- package/dist/admin/templateConditions.scss +24 -0
- package/dist/ai/adapters/anthropic.js +17 -4
- package/dist/ai/adapters/cloudflare-gateway.js +7 -1
- package/dist/ai/adapters/cloudflare-workers-ai.js +2 -0
- package/dist/ai/adapters/openai-compatible.js +1 -0
- package/dist/ai/adapters/openrouter.js +2 -0
- package/dist/ai/config.d.ts +24 -4
- package/dist/ai/config.js +27 -8
- package/dist/ai/endpoint.d.ts +5 -2
- package/dist/ai/endpoint.js +31 -26
- package/dist/ai/images/cloudflare-workers-ai.js +6 -2
- package/dist/ai/images/openai.js +8 -3
- package/dist/ai/images/openrouter.js +6 -2
- package/dist/ai/images/service.d.ts +10 -4
- package/dist/ai/images/service.js +23 -7
- package/dist/ai/openai-format.d.ts +7 -0
- package/dist/ai/openai-format.js +17 -5
- package/dist/ai/prompt.d.ts +8 -0
- package/dist/ai/prompt.js +25 -5
- package/dist/ai/settings/index.d.ts +62 -0
- package/dist/ai/settings/index.js +264 -0
- package/dist/ai/settings/secret.d.ts +11 -0
- package/dist/ai/settings/secret.js +46 -0
- package/dist/ai/settings/shared.d.ts +22 -0
- package/dist/ai/settings/shared.js +3 -0
- package/dist/ai/tools.d.ts +3 -0
- package/dist/ai/tools.js +79 -15
- package/dist/ai/types.d.ts +43 -0
- package/dist/blocks/builtins/adjacentLinks.d.ts +5 -0
- package/dist/blocks/builtins/adjacentLinks.js +76 -0
- package/dist/blocks/builtins/carousel.d.ts +2 -29
- package/dist/blocks/builtins/carousel.js +44 -51
- package/dist/blocks/builtins/disclosure.d.ts +2 -1
- package/dist/blocks/builtins/disclosure.js +22 -32
- package/dist/blocks/builtins/embed.d.ts +15 -0
- package/dist/blocks/builtins/embed.js +47 -0
- package/dist/blocks/builtins/faq.d.ts +1 -1
- package/dist/blocks/builtins/faq.js +2 -2
- package/dist/blocks/builtins/filterLink.d.ts +1 -19
- package/dist/blocks/builtins/filterLink.js +9 -50
- package/dist/blocks/builtins/icon.d.ts +2 -0
- package/dist/blocks/builtins/icon.js +8 -8
- package/dist/blocks/builtins/index.d.ts +18 -13
- package/dist/blocks/builtins/index.js +43 -22
- package/dist/blocks/builtins/marquee.d.ts +5 -0
- package/dist/blocks/builtins/marquee.js +68 -0
- package/dist/blocks/builtins/popup.d.ts +5 -0
- package/dist/blocks/builtins/popup.js +83 -0
- package/dist/blocks/builtins/sectionRef.d.ts +16 -2
- package/dist/blocks/builtins/sectionRef.js +34 -12
- package/dist/blocks/builtins/shared.d.ts +18 -23
- package/dist/blocks/builtins/shared.js +34 -42
- package/dist/blocks/builtins/tableOfContents.d.ts +4 -0
- package/dist/blocks/builtins/tableOfContents.js +12 -18
- package/dist/blocks/builtins/tabs.d.ts +6 -0
- package/dist/blocks/builtins/tabs.js +87 -0
- package/dist/blocks/client/adjacentLinks.d.ts +4 -0
- package/dist/blocks/client/adjacentLinks.js +4 -0
- package/dist/blocks/client/carousel.d.ts +45 -0
- package/dist/blocks/client/carousel.js +53 -0
- package/dist/blocks/client/embed.d.ts +21 -0
- package/dist/blocks/client/embed.js +23 -0
- package/dist/blocks/client/field.d.ts +7 -0
- package/dist/blocks/client/field.js +8 -0
- package/dist/blocks/client/filterLink.d.ts +19 -0
- package/dist/blocks/client/filterLink.js +30 -0
- package/dist/blocks/client/helpers.d.ts +21 -0
- package/dist/blocks/client/helpers.js +24 -0
- package/dist/blocks/client/marquee.d.ts +14 -0
- package/dist/blocks/client/marquee.js +25 -0
- package/dist/blocks/client/menu.d.ts +46 -0
- package/dist/blocks/client/menu.js +49 -0
- package/dist/blocks/client/popup.d.ts +15 -0
- package/dist/blocks/client/popup.js +16 -0
- package/dist/blocks/client/tabs.d.ts +10 -0
- package/dist/blocks/client/tabs.js +11 -0
- package/dist/blocks/defaults.d.ts +15 -52
- package/dist/blocks/defaults.js +203 -437
- package/dist/blocks/index.d.ts +1 -2
- package/dist/blocks/index.js +1 -2
- package/dist/classes/actions.d.ts +97 -0
- package/dist/classes/actions.js +296 -0
- package/dist/classes/collection.d.ts +5 -0
- package/dist/classes/collection.js +189 -0
- package/dist/classes/config.d.ts +34 -0
- package/dist/classes/config.js +8 -0
- package/dist/classes/endpoints.d.ts +2 -0
- package/dist/classes/endpoints.js +120 -0
- package/dist/classes/index.d.ts +36 -0
- package/dist/classes/index.js +42 -0
- package/dist/classes/mcp.d.ts +6 -0
- package/dist/classes/mcp.js +161 -0
- package/dist/classes/shared.d.ts +131 -0
- package/dist/classes/shared.js +300 -0
- package/dist/classes/sheet.d.ts +34 -0
- package/dist/classes/sheet.js +126 -0
- package/dist/classes/usage.d.ts +57 -0
- package/dist/classes/usage.js +208 -0
- package/dist/comments/collection.d.ts +38 -0
- package/dist/comments/collection.js +226 -0
- package/dist/comments/config.d.ts +15 -0
- package/dist/comments/config.js +2 -0
- package/dist/comments/index.d.ts +20 -0
- package/dist/comments/index.js +22 -0
- package/dist/comments/shared.d.ts +54 -0
- package/dist/comments/shared.js +104 -0
- package/dist/core/bindings.d.ts +77 -32
- package/dist/core/bindings.js +319 -134
- package/dist/core/blockNames.d.ts +9 -0
- package/dist/core/blockNames.js +11 -0
- package/dist/core/blocks.d.ts +21 -8
- package/dist/core/blocks.js +37 -16
- package/dist/core/classes.d.ts +16 -8
- package/dist/core/classes.js +31 -27
- package/dist/core/components.d.ts +72 -0
- package/dist/core/components.js +294 -0
- package/dist/core/contentMode.d.ts +27 -0
- package/dist/core/contentMode.js +0 -0
- package/dist/core/dropTarget.d.ts +11 -0
- package/dist/core/dropTarget.js +24 -1
- package/dist/core/fields.d.ts +5 -0
- package/dist/core/fields.js +11 -0
- package/dist/core/headings.d.ts +5 -2
- package/dist/core/headings.js +14 -6
- package/dist/core/index.d.ts +8 -3
- package/dist/core/index.js +8 -3
- package/dist/core/layers.d.ts +9 -0
- package/dist/core/layers.js +29 -0
- package/dist/core/operations.d.ts +6 -0
- package/dist/core/operations.js +85 -24
- package/dist/core/payloadBlocks.js +5 -1
- package/dist/core/references.js +28 -0
- package/dist/core/schema.js +20 -6
- package/dist/core/sectionOrigin.d.ts +6 -0
- package/dist/core/sectionOrigin.js +21 -0
- package/dist/core/sections.d.ts +72 -0
- package/dist/core/sections.js +331 -0
- package/dist/core/templateChoice.d.ts +24 -0
- package/dist/core/templateChoice.js +43 -0
- package/dist/core/tree.js +18 -6
- package/dist/core/types.d.ts +148 -18
- package/dist/core/validate.d.ts +4 -1
- package/dist/core/validate.js +28 -11
- package/dist/core/visibility.d.ts +63 -0
- package/dist/core/visibility.js +214 -0
- package/dist/core/whereValues.d.ts +22 -0
- package/dist/core/whereValues.js +43 -0
- package/dist/css/classes.d.ts +16 -0
- package/dist/css/classes.js +172 -0
- package/dist/css/index.d.ts +32 -1
- package/dist/css/index.js +64 -5
- package/dist/css/tokens.d.ts +10 -0
- package/dist/css/tokens.js +23 -10
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -1
- package/dist/live/contentMode.d.ts +24 -0
- package/dist/live/contentMode.js +39 -0
- package/dist/live/endpoints.js +3 -0
- package/dist/live/session.d.ts +5 -0
- package/dist/live/session.js +8 -0
- package/dist/live/types.d.ts +16 -1
- package/dist/mcp/index.d.ts +10 -1
- package/dist/mcp/index.js +146 -54
- package/dist/mcp/shared.d.ts +93 -3
- package/dist/mcp/shared.js +211 -15
- package/dist/plugin/hook.d.ts +7 -1
- package/dist/plugin/hook.js +30 -4
- package/dist/plugin/index.d.ts +19 -8
- package/dist/plugin/index.js +89 -20
- package/dist/plugin/links.d.ts +24 -0
- package/dist/plugin/links.js +27 -0
- package/dist/plugin/listCollections.d.ts +9 -7
- package/dist/plugin/listCollections.js +30 -21
- package/dist/plugin/sections.d.ts +14 -7
- package/dist/plugin/sections.js +69 -23
- package/dist/plugin/sectionsUsedIn.d.ts +6 -0
- package/dist/plugin/sectionsUsedIn.js +24 -0
- package/dist/plugin/templateEndpoint.d.ts +9 -0
- package/dist/plugin/templateEndpoint.js +49 -0
- package/dist/plugin/templates.js +23 -8
- package/dist/protocol/index.d.ts +16 -1
- package/dist/react/canvas/BuilderCanvas.js +144 -21
- package/dist/react/canvas/classes.d.ts +17 -0
- package/dist/react/canvas/classes.js +102 -0
- package/dist/react/canvas/controls.d.ts +31 -0
- package/dist/react/canvas/controls.js +75 -0
- package/dist/react/canvas/fetchDocs.d.ts +2 -2
- package/dist/react/canvas/fetchDocs.js +16 -8
- package/dist/react/canvas/measure.d.ts +9 -0
- package/dist/react/canvas/measure.js +106 -7
- package/dist/react/canvas/resolveLayout.d.ts +1 -1
- package/dist/react/canvas/resolveLayout.js +4 -3
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +17 -4
- package/dist/react/classes/ClassesStyle.d.ts +27 -0
- package/dist/react/classes/ClassesStyle.js +27 -0
- package/dist/react/components/Button.d.ts +2 -11
- package/dist/react/components/Button.js +8 -43
- package/dist/react/components/CollectionList.d.ts +4 -1
- package/dist/react/components/CollectionList.js +10 -3
- package/dist/react/components/Container.d.ts +5 -2
- package/dist/react/components/Container.js +7 -4
- package/dist/react/components/Field.js +3 -14
- package/dist/react/components/Link.d.ts +1 -1
- package/dist/react/components/Link.js +5 -3
- package/dist/react/components/List.d.ts +1 -1
- package/dist/react/components/List.js +2 -2
- package/dist/react/components/Menu.d.ts +10 -1
- package/dist/react/components/Menu.js +39 -12
- package/dist/react/components/RichText.d.ts +3 -4
- package/dist/react/components/RichText.js +5 -5
- package/dist/react/components/builtins/Accordion.d.ts +4 -3
- package/dist/react/components/builtins/Accordion.js +6 -5
- package/dist/react/components/builtins/AdjacentLinks.d.ts +11 -0
- package/dist/react/components/builtins/AdjacentLinks.js +20 -0
- package/dist/react/components/builtins/Carousel.d.ts +21 -10
- package/dist/react/components/builtins/Carousel.js +175 -100
- package/dist/react/components/builtins/Disclosure.d.ts +4 -3
- package/dist/react/components/builtins/Disclosure.js +6 -5
- package/dist/react/components/builtins/Embed.d.ts +11 -0
- package/dist/react/components/builtins/Embed.js +23 -0
- package/dist/react/components/builtins/EmbedHtml.d.ts +15 -0
- package/dist/react/components/builtins/EmbedHtml.js +51 -0
- package/dist/react/components/builtins/EmbedPreview.d.ts +34 -0
- package/dist/react/components/builtins/EmbedPreview.js +105 -0
- package/dist/react/components/builtins/FilterLink.d.ts +1 -1
- package/dist/react/components/builtins/FilterLink.js +4 -4
- package/dist/react/components/builtins/Marquee.d.ts +8 -0
- package/dist/react/components/builtins/Marquee.js +15 -0
- package/dist/react/components/builtins/Popup.d.ts +26 -0
- package/dist/react/components/builtins/Popup.js +146 -0
- package/dist/react/components/builtins/SectionRef.d.ts +4 -3
- package/dist/react/components/builtins/SectionRef.js +9 -5
- package/dist/react/components/builtins/Tab.d.ts +7 -0
- package/dist/react/components/builtins/Tab.js +21 -0
- package/dist/react/components/builtins/TableOfContents.d.ts +17 -3
- package/dist/react/components/builtins/TableOfContents.js +22 -7
- package/dist/react/components/builtins/Tabs.d.ts +17 -0
- package/dist/react/components/builtins/Tabs.js +71 -0
- package/dist/react/components/builtins/index.d.ts +37 -20
- package/dist/react/components/builtins/index.js +54 -20
- package/dist/react/components/builtins/tabsContext.d.ts +12 -0
- package/dist/react/components/builtins/tabsContext.js +6 -0
- package/dist/react/components/index.js +11 -8
- package/dist/react/components/lazy.d.ts +32 -0
- package/dist/react/components/lazy.js +20 -0
- package/dist/react/components/lazyBlock.d.ts +17 -0
- package/dist/react/components/lazyBlock.js +23 -0
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +5 -2
- package/dist/react/render/RenderLayout.d.ts +9 -7
- package/dist/react/render/RenderLayout.js +96 -45
- package/dist/react/render/canvasMode.d.ts +13 -0
- package/dist/react/render/canvasMode.js +13 -0
- package/dist/react/render/canvasServer.js +4 -3
- package/dist/react/render/canvasServerTypes.d.ts +5 -0
- package/dist/react/render/lists.d.ts +36 -4
- package/dist/react/render/lists.js +132 -15
- package/dist/react/render/marks.d.ts +15 -0
- package/dist/react/render/marks.js +23 -0
- package/dist/react/render/payload.d.ts +8 -1
- package/dist/react/render/payload.js +12 -3
- package/dist/react/render/preview.d.ts +11 -0
- package/dist/react/render/preview.js +13 -0
- package/dist/react/render/relations.d.ts +10 -0
- package/dist/react/render/relations.js +39 -0
- package/dist/react/render/resolve.d.ts +8 -4
- package/dist/react/render/resolve.js +11 -5
- package/dist/react/render/reveal.d.ts +17 -0
- package/dist/react/render/reveal.js +39 -0
- package/dist/react/render/sections.d.ts +11 -5
- package/dist/react/render/sections.js +52 -24
- package/dist/react/render/templates.d.ts +47 -0
- package/dist/react/render/templates.js +139 -0
- package/dist/react/render/types.d.ts +62 -5
- package/dist/react/server.d.ts +2 -37
- package/dist/react/server.js +8 -133
- package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
- package/dist/react/theme/ThemeLiveLoader.js +5 -0
- package/dist/react/theme/ThemeStyle.js +1 -1
- package/dist/theme/admin/Variables.d.ts +11 -0
- package/dist/theme/admin/Variables.js +115 -0
- package/dist/theme/admin/fields.scss +113 -0
- package/dist/theme/client.d.ts +1 -0
- package/dist/theme/client.js +2 -0
- package/dist/theme/css.d.ts +6 -1
- package/dist/theme/css.js +12 -4
- package/dist/theme/global.js +83 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +1 -0
- package/dist/theme/server.d.ts +15 -0
- package/dist/theme/server.js +43 -0
- package/dist/theme/usage.d.ts +23 -0
- package/dist/theme/usage.js +68 -0
- package/dist/theme/variables.d.ts +72 -0
- package/dist/theme/variables.js +231 -0
- package/package.json +4 -2
- package/dist/admin/editor/styles/SiteClasses.d.ts +0 -9
- package/dist/admin/editor/styles/SiteClasses.js +0 -31
- package/dist/blocks/builtins/headingId.d.ts +0 -15
- package/dist/blocks/builtins/headingId.js +0 -36
- package/dist/blocks/builtins/lightbox.d.ts +0 -43
- package/dist/blocks/builtins/lightbox.js +0 -93
- package/dist/blocks/builtins/mediaBackdrop.d.ts +0 -11
- package/dist/blocks/builtins/mediaBackdrop.js +0 -79
- package/dist/react/components/Quote.d.ts +0 -3
- package/dist/react/components/Quote.js +0 -12
- package/dist/react/components/Spacer.d.ts +0 -3
- package/dist/react/components/Spacer.js +0 -6
- package/dist/react/components/builtins/BackdropVideo.d.ts +0 -13
- package/dist/react/components/builtins/BackdropVideo.js +0 -16
- package/dist/react/components/builtins/Lightbox.d.ts +0 -45
- package/dist/react/components/builtins/Lightbox.js +0 -252
- package/dist/react/components/builtins/MediaBackdrop.d.ts +0 -14
- package/dist/react/components/builtins/MediaBackdrop.js +0 -61
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Properties in a saved section's inspector: the ◆ button next to a content field that makes it a
|
|
4
|
+
// property, the chip of a field that is one, and the "Visible" property row.
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { SECTION_REF_BLOCK } from '../../../blocks/builtins/sectionRef.js';
|
|
7
|
+
import { propertyLabel, propertyOf, VISIBLE_BINDING } from '../../../core/components.js';
|
|
8
|
+
import { Icon } from '../icons.js';
|
|
9
|
+
import { useRuntime } from '../runtime.js';
|
|
10
|
+
import { Popover, stopEditorKeys, usePopover } from '../styles/popover.js';
|
|
11
|
+
import { addProperty, editsSection, removeProperty } from './components.js';
|
|
12
|
+
import './components.scss';
|
|
13
|
+
/** The form in the property popover: a name, then Enter. */
|
|
14
|
+
function PropertyForm({ initial, onSubmit }) {
|
|
15
|
+
const [label, setLabel] = useState(initial);
|
|
16
|
+
const [error, setError] = useState(null);
|
|
17
|
+
const submit = (e) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
setError(onSubmit(label));
|
|
20
|
+
};
|
|
21
|
+
return (_jsxs("form", { className: "builder-prop__form", onSubmit: submit, children: [_jsx("label", { className: "builder-prop__form-label", htmlFor: "builder-prop-name", children: "Property name" }), _jsx("input", { id: "builder-prop-name", className: "builder-prop__input", type: "text", value: label, onKeyDown: stopEditorKeys,
|
|
22
|
+
// oxlint-disable-next-line jsx-a11y/no-autofocus -- the popover opens to type a name
|
|
23
|
+
autoFocus: true, onFocus: (e) => e.currentTarget.select(), onChange: (e) => {
|
|
24
|
+
setLabel(e.target.value);
|
|
25
|
+
setError(null);
|
|
26
|
+
}, "aria-invalid": error ? true : undefined, "aria-describedby": error ? 'builder-prop-error' : undefined }), error && (_jsx("p", { id: "builder-prop-error", className: "builder-prop__error", role: "alert", children: error })), _jsx("button", { type: "submit", className: "builder-prop__submit", children: "Create property" })] }));
|
|
27
|
+
}
|
|
28
|
+
/** The ◆ button that makes a field a property. `offset`: a bind button sits at the edge already. */
|
|
29
|
+
function PropertyButton({ block, propPath, label, offset = false }) {
|
|
30
|
+
const runtime = useRuntime();
|
|
31
|
+
const popover = usePopover('auto');
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: `builder-bind__button builder-prop__button${offset ? ' builder-prop__button--offset' : ''}`, "aria-label": `Make ${label} a property`, "aria-haspopup": "dialog", "aria-expanded": popover.open, "data-tooltip": "Make it a property", onClick: (e) => popover.toggle(e.currentTarget), children: _jsx(Icon, { name: "component", size: 13 }) }), _jsx(Popover, { ...popover.props, className: "builder-prop__popover", label: `Make ${label} a property`, children: popover.open && (_jsx(PropertyForm, { initial: label, onSubmit: (name) => {
|
|
33
|
+
const problem = addProperty(runtime, block.id, propPath, name);
|
|
34
|
+
if (!problem)
|
|
35
|
+
popover.hide();
|
|
36
|
+
return problem;
|
|
37
|
+
} })) })] }));
|
|
38
|
+
}
|
|
39
|
+
/** The chip of a prop that is a property, with a button that makes it a normal prop again. */
|
|
40
|
+
function PropertyChip({ block, propPath, name }) {
|
|
41
|
+
const runtime = useRuntime();
|
|
42
|
+
const label = propertyLabel(name);
|
|
43
|
+
return (_jsxs("div", { className: "builder-prop__chip", children: [_jsx(Icon, { name: "component", size: 12 }), _jsx("span", { className: "builder-prop__chip-label", children: label }), _jsx("span", { className: "builder-prop__chip-kind", children: "Property" }), _jsx("button", { type: "button", className: "builder-bind__chip-x", "aria-label": `Remove the property ${label}`, "data-tooltip": "Remove property", onClick: () => removeProperty(runtime, block.id, propPath), children: _jsx(Icon, { name: "close", size: 12 }) })] }));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One content field of a block in a saved section: its input (the component's own value, the
|
|
47
|
+
* default every copy starts with) and the property button or chip. `bind`: the field's bind
|
|
48
|
+
* button, when it has one.
|
|
49
|
+
*/
|
|
50
|
+
export function PropertySlot({ block, propPath, label, children }) {
|
|
51
|
+
const name = propertyOf(block.bindings?.[propPath] ?? '');
|
|
52
|
+
if (name) {
|
|
53
|
+
return (_jsxs("div", { className: "builder-prop builder-prop--bound", children: [children, _jsx(PropertyChip, { block: block, propPath: propPath, name: name })] }));
|
|
54
|
+
}
|
|
55
|
+
return (_jsxs("div", { className: "builder-bind", children: [children, _jsx(PropertyButton, { block: block, propPath: propPath, label: label })] }));
|
|
56
|
+
}
|
|
57
|
+
/** "Visible": a property that shows or hides the block in each copy. Saved sections only. */
|
|
58
|
+
export function VisibleProperty({ block }) {
|
|
59
|
+
const runtime = useRuntime();
|
|
60
|
+
if (!editsSection(runtime) || block.type === SECTION_REF_BLOCK)
|
|
61
|
+
return null;
|
|
62
|
+
const name = propertyOf(block.bindings?.[VISIBLE_BINDING] ?? '');
|
|
63
|
+
const typeLabel = runtime.blockLabel(block.type);
|
|
64
|
+
return (_jsxs("div", { className: "builder-prop builder-prop--visible", children: [_jsxs("div", { className: "builder-bind", children: [_jsx("span", { className: "builder-prop__row-label", children: "Visible" }), !name && _jsx(PropertyButton, { block: block, propPath: VISIBLE_BINDING, label: `Show ${(block.label ?? typeLabel).toLowerCase()}` })] }), name && _jsx(PropertyChip, { block: block, propPath: VISIBLE_BINDING, name: name })] }));
|
|
65
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ComponentProperty } from '../../../core/components.js';
|
|
2
|
+
import type { Block } from '../../../core/types.js';
|
|
3
|
+
import type { Runtime } from '../runtime.js';
|
|
4
|
+
/** True when the open document is a saved section: its props can become properties. */
|
|
5
|
+
export declare function editsSection(runtime: Runtime): boolean;
|
|
6
|
+
/** The property type a prop would get, or null when it cannot be a property. */
|
|
7
|
+
export declare function propertyTypeOf(runtime: Runtime, block: Block, propPath: string): "image" | "link" | "richText" | "text" | null;
|
|
8
|
+
/**
|
|
9
|
+
* Makes `propPath` of a block a property named after `label`: one undo step. A name another prop
|
|
10
|
+
* already uses joins that property when the types match (one value fills both). Returns the
|
|
11
|
+
* problem as text, or null when it worked.
|
|
12
|
+
*/
|
|
13
|
+
export declare function addProperty(runtime: Runtime, blockId: string, propPath: string, label: string): string | null;
|
|
14
|
+
/** Turns a property back into a normal prop. Copies keep their values but no longer show them. */
|
|
15
|
+
export declare function removeProperty(runtime: Runtime, blockId: string, propPath: string): void;
|
|
16
|
+
export type UsedIn = {
|
|
17
|
+
total: number;
|
|
18
|
+
} | null;
|
|
19
|
+
/** How many builder documents use the saved section (`null` until known, or when it cannot be read). */
|
|
20
|
+
export declare function useUsedIn(runtime: Runtime, savedId: string | number | null): UsedIn;
|
|
21
|
+
/** "Used in 3 places", "Not used yet". */
|
|
22
|
+
export declare function usedInText(usedIn: UsedIn): string | null;
|
|
23
|
+
/** The properties of the open saved section, live (names and types). */
|
|
24
|
+
export declare function useOwnProperties(runtime: Runtime): ComponentProperty[];
|
|
25
|
+
/**
|
|
26
|
+
* Coming back to this tab (after editing a component in another one): the canvas loads the saved
|
|
27
|
+
* sections of the page's copies again, so they show the component's latest content.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useComponentRefresh(runtime: Runtime): void;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// Components in the editor: the actions that turn a prop of a saved section into a property, and
|
|
3
|
+
// the count of the places that use a saved section. Pure helpers live in core/components.ts.
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { SECTION_REF_BLOCK, sectionRefId } from '../../../blocks/builtins/sectionRef.js';
|
|
6
|
+
import { componentProperties, propertyBinding, propertyName, propertyType, VISIBLE_BINDING } from '../../../core/components.js';
|
|
7
|
+
import { findBlock, getBlockDefinition, propField, walkBlocks } from '../../../core/index.js';
|
|
8
|
+
import { useEditor } from '../store.js';
|
|
9
|
+
/** True when the open document is a saved section: its props can become properties. */
|
|
10
|
+
export function editsSection(runtime) {
|
|
11
|
+
const saved = runtime.config.savedSections?.collection;
|
|
12
|
+
return Boolean(saved && runtime.config.collection === saved);
|
|
13
|
+
}
|
|
14
|
+
/** The property type a prop would get, or null when it cannot be a property. */
|
|
15
|
+
export function propertyTypeOf(runtime, block, propPath) {
|
|
16
|
+
if (block.type === SECTION_REF_BLOCK)
|
|
17
|
+
return null;
|
|
18
|
+
const def = getBlockDefinition(runtime.config.blocks, block.type);
|
|
19
|
+
return def ? propertyType(propField(def.fields, propPath)) : null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Makes `propPath` of a block a property named after `label`: one undo step. A name another prop
|
|
23
|
+
* already uses joins that property when the types match (one value fills both). Returns the
|
|
24
|
+
* problem as text, or null when it worked.
|
|
25
|
+
*/
|
|
26
|
+
export function addProperty(runtime, blockId, propPath, label) {
|
|
27
|
+
const name = propertyName(label);
|
|
28
|
+
if (!name)
|
|
29
|
+
return 'Use letters or numbers.';
|
|
30
|
+
const layout = runtime.store.getState().layout;
|
|
31
|
+
const block = findBlock(layout, blockId);
|
|
32
|
+
if (!block)
|
|
33
|
+
return 'The block is gone.';
|
|
34
|
+
const type = propPath === VISIBLE_BINDING ? 'visible' : propertyTypeOf(runtime, block, propPath);
|
|
35
|
+
if (!type)
|
|
36
|
+
return 'This field cannot be a property.';
|
|
37
|
+
const existing = componentProperties(layout.blocks, runtime.config.blocks).find((p) => p.name === name);
|
|
38
|
+
if (existing && existing.type !== type)
|
|
39
|
+
return `“${existing.label}” is already a ${existing.type === 'richText' ? 'rich text' : existing.type} property.`;
|
|
40
|
+
const done = runtime.store.apply({ type: 'update', id: blockId, bindings: { [propPath]: propertyBinding(name) } });
|
|
41
|
+
if (!done)
|
|
42
|
+
return 'The property could not be added.';
|
|
43
|
+
runtime.notify(existing ? `Linked to the property “${existing.label}”` : 'Property added. Each copy can now set its own value.');
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/** Turns a property back into a normal prop. Copies keep their values but no longer show them. */
|
|
47
|
+
export function removeProperty(runtime, blockId, propPath) {
|
|
48
|
+
if (runtime.store.apply({ type: 'update', id: blockId, bindings: { [propPath]: null } }))
|
|
49
|
+
runtime.notify('Property removed');
|
|
50
|
+
}
|
|
51
|
+
/** How many builder documents use the saved section (`null` until known, or when it cannot be read). */
|
|
52
|
+
export function useUsedIn(runtime, savedId) {
|
|
53
|
+
const collection = runtime.config.savedSections?.collection ?? null;
|
|
54
|
+
const [usedIn, setUsedIn] = useState(null);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!collection || savedId === null)
|
|
57
|
+
return;
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
fetch(`${runtime.api}/${encodeURIComponent(collection)}/${encodeURIComponent(String(savedId))}/used-in`, {
|
|
60
|
+
credentials: 'include',
|
|
61
|
+
signal: controller.signal,
|
|
62
|
+
})
|
|
63
|
+
.then((res) => (res.ok ? res.json() : null))
|
|
64
|
+
.then((body) => setUsedIn(typeof body?.total === 'number' ? { total: body.total } : null))
|
|
65
|
+
.catch(() => {
|
|
66
|
+
// Offline or aborted: the count stays hidden.
|
|
67
|
+
});
|
|
68
|
+
return () => controller.abort();
|
|
69
|
+
}, [runtime.api, collection, savedId]);
|
|
70
|
+
return usedIn;
|
|
71
|
+
}
|
|
72
|
+
/** "Used in 3 places", "Not used yet". */
|
|
73
|
+
export function usedInText(usedIn) {
|
|
74
|
+
if (!usedIn)
|
|
75
|
+
return null;
|
|
76
|
+
if (usedIn.total === 0)
|
|
77
|
+
return 'Not used yet';
|
|
78
|
+
return `Used in ${usedIn.total} ${usedIn.total === 1 ? 'place' : 'places'}`;
|
|
79
|
+
}
|
|
80
|
+
const sameProperties = (a, b) => a.length === b.length && a.every((p, i) => p.name === b[i].name && p.type === b[i].type);
|
|
81
|
+
/** The properties of the open saved section, live (names and types). */
|
|
82
|
+
export function useOwnProperties(runtime) {
|
|
83
|
+
return useEditor(runtime.store, (s) => componentProperties(s.layout.blocks, runtime.config.blocks), sameProperties);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Coming back to this tab (after editing a component in another one): the canvas loads the saved
|
|
87
|
+
* sections of the page's copies again, so they show the component's latest content.
|
|
88
|
+
*/
|
|
89
|
+
export function useComponentRefresh(runtime) {
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const collection = runtime.config.savedSections?.collection;
|
|
92
|
+
if (!collection)
|
|
93
|
+
return;
|
|
94
|
+
const refresh = () => {
|
|
95
|
+
const ids = new Set();
|
|
96
|
+
walkBlocks(runtime.store.getState().layout, (block) => {
|
|
97
|
+
if (block.type !== SECTION_REF_BLOCK)
|
|
98
|
+
return;
|
|
99
|
+
const id = sectionRefId(block.props?.section);
|
|
100
|
+
if (id !== null)
|
|
101
|
+
ids.add(id);
|
|
102
|
+
});
|
|
103
|
+
if (ids.size === 0)
|
|
104
|
+
return;
|
|
105
|
+
void runtime.sections.load(true);
|
|
106
|
+
for (const id of ids)
|
|
107
|
+
runtime.postToCanvas({ type: 'docChanged', collection, id });
|
|
108
|
+
};
|
|
109
|
+
window.addEventListener('focus', refresh);
|
|
110
|
+
return () => window.removeEventListener('focus', refresh);
|
|
111
|
+
}, [runtime]);
|
|
112
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// Components in the inspector: property buttons and chips in a saved section, the properties of a
|
|
2
|
+
// copy, and the component banner. Payload CSS variables only, inside Payload's own layer.
|
|
3
|
+
|
|
4
|
+
@layer payload-default {
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Properties in a saved section
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
.builder-prop {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: 6px;
|
|
13
|
+
min-width: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Next to a bind button, the property button moves one step in.
|
|
17
|
+
.builder-editor .builder-prop__button--offset {
|
|
18
|
+
right: 26px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.builder-prop__chip {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 6px;
|
|
25
|
+
min-width: 0;
|
|
26
|
+
min-height: 28px;
|
|
27
|
+
padding: 2px 2px 2px 8px;
|
|
28
|
+
border: 1px solid color-mix(in srgb, var(--be-accent) 45%, transparent);
|
|
29
|
+
border-radius: var(--style-radius-s, 4px);
|
|
30
|
+
background: color-mix(in srgb, var(--be-accent) 10%, var(--theme-input-bg, var(--theme-elevation-0)));
|
|
31
|
+
color: var(--theme-text);
|
|
32
|
+
font-size: var(--be-text-m);
|
|
33
|
+
|
|
34
|
+
> svg:first-child {
|
|
35
|
+
flex: none;
|
|
36
|
+
color: var(--theme-success-600);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.builder-prop__chip-label {
|
|
41
|
+
min-width: 0;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
font-weight: var(--be-weight-medium);
|
|
44
|
+
text-overflow: ellipsis;
|
|
45
|
+
white-space: nowrap;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.builder-prop__chip-kind {
|
|
49
|
+
flex: 1;
|
|
50
|
+
color: var(--theme-elevation-500);
|
|
51
|
+
font-size: var(--be-text-s);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.builder-prop--visible {
|
|
55
|
+
padding-top: 10px;
|
|
56
|
+
border-top: 1px solid var(--theme-elevation-100);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.builder-prop__row-label {
|
|
60
|
+
color: var(--theme-elevation-800);
|
|
61
|
+
font-size: var(--be-text-m);
|
|
62
|
+
line-height: 22px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.builder-prop__popover.builder-styles__popover {
|
|
66
|
+
width: 260px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.builder-prop__form {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
gap: 8px;
|
|
73
|
+
padding: 12px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.builder-prop__form-label {
|
|
77
|
+
color: var(--theme-elevation-800);
|
|
78
|
+
font-size: var(--be-text-m);
|
|
79
|
+
font-weight: var(--be-weight-medium);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.builder-prop__input {
|
|
83
|
+
width: 100%;
|
|
84
|
+
min-height: 32px;
|
|
85
|
+
padding: 4px 8px;
|
|
86
|
+
border: 1px solid var(--theme-elevation-150);
|
|
87
|
+
border-radius: var(--style-radius-s, 4px);
|
|
88
|
+
background: var(--theme-input-bg, var(--theme-elevation-0));
|
|
89
|
+
color: var(--theme-text);
|
|
90
|
+
font: inherit;
|
|
91
|
+
font-size: var(--be-text-m);
|
|
92
|
+
|
|
93
|
+
&:focus-visible {
|
|
94
|
+
border-color: var(--theme-elevation-400);
|
|
95
|
+
outline: 2px solid color-mix(in srgb, var(--be-accent) 40%, transparent);
|
|
96
|
+
outline-offset: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&[aria-invalid='true'] {
|
|
100
|
+
border-color: var(--theme-error-500);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.builder-prop__error {
|
|
105
|
+
margin: 0;
|
|
106
|
+
color: var(--theme-error-500);
|
|
107
|
+
font-size: var(--be-text-s);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.builder-prop__submit,
|
|
111
|
+
.builder-comp__edit {
|
|
112
|
+
min-height: 30px;
|
|
113
|
+
padding: 4px 10px;
|
|
114
|
+
border: 1px solid var(--theme-elevation-150);
|
|
115
|
+
border-radius: var(--style-radius-s, 4px);
|
|
116
|
+
background: var(--theme-elevation-50);
|
|
117
|
+
color: var(--theme-text);
|
|
118
|
+
font: inherit;
|
|
119
|
+
font-size: var(--be-text-m);
|
|
120
|
+
font-weight: var(--be-weight-medium);
|
|
121
|
+
cursor: pointer;
|
|
122
|
+
|
|
123
|
+
&:hover {
|
|
124
|
+
border-color: var(--theme-elevation-250);
|
|
125
|
+
background: var(--theme-elevation-100);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&:focus-visible {
|
|
129
|
+
outline: 2px solid color-mix(in srgb, var(--be-accent) 40%, transparent);
|
|
130
|
+
outline-offset: 1px;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.builder-prop__submit {
|
|
135
|
+
align-self: flex-end;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
// A copy: the component's properties
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
.builder-comp {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
gap: 12px;
|
|
146
|
+
padding: 12px var(--builder-inspector-pad, 12px) 16px;
|
|
147
|
+
border-top: 1px solid var(--theme-elevation-100);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.builder-comp__head {
|
|
151
|
+
display: flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
gap: 8px;
|
|
154
|
+
min-width: 0;
|
|
155
|
+
|
|
156
|
+
> svg {
|
|
157
|
+
flex: none;
|
|
158
|
+
color: var(--theme-success-600);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.builder-comp__title {
|
|
163
|
+
display: flex;
|
|
164
|
+
flex: 1;
|
|
165
|
+
flex-direction: column;
|
|
166
|
+
min-width: 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.builder-comp__name {
|
|
170
|
+
overflow: hidden;
|
|
171
|
+
font-size: var(--be-text-l);
|
|
172
|
+
font-weight: var(--be-weight-strong);
|
|
173
|
+
text-overflow: ellipsis;
|
|
174
|
+
white-space: nowrap;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.builder-comp__meta {
|
|
178
|
+
color: var(--theme-elevation-500);
|
|
179
|
+
font-size: var(--be-text-s);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.builder-comp__edit {
|
|
183
|
+
flex: none;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.builder-comp__missing {
|
|
187
|
+
display: flex;
|
|
188
|
+
align-items: flex-start;
|
|
189
|
+
gap: 8px;
|
|
190
|
+
margin: 12px var(--builder-inspector-pad, 12px);
|
|
191
|
+
padding: 8px 10px;
|
|
192
|
+
border-radius: var(--style-radius-m, 6px);
|
|
193
|
+
background: color-mix(in srgb, var(--theme-warning-500, var(--theme-error-500)) 12%, transparent);
|
|
194
|
+
color: var(--theme-elevation-800);
|
|
195
|
+
font-size: var(--be-text-m);
|
|
196
|
+
|
|
197
|
+
> svg {
|
|
198
|
+
flex: none;
|
|
199
|
+
margin-top: 2px;
|
|
200
|
+
color: var(--theme-warning-600, var(--theme-error-500));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// A saved section with properties: the banner on top of the inspector
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
|
|
208
|
+
.builder-comp__banner {
|
|
209
|
+
display: flex;
|
|
210
|
+
align-items: flex-start;
|
|
211
|
+
gap: 8px;
|
|
212
|
+
margin: 8px 8px 0;
|
|
213
|
+
padding: 8px 10px;
|
|
214
|
+
border-radius: var(--style-radius-m, 6px);
|
|
215
|
+
background: color-mix(in srgb, var(--be-accent) 10%, var(--theme-elevation-0));
|
|
216
|
+
color: var(--theme-elevation-800);
|
|
217
|
+
font-size: var(--be-text-m);
|
|
218
|
+
line-height: 1.45;
|
|
219
|
+
|
|
220
|
+
> svg {
|
|
221
|
+
flex: none;
|
|
222
|
+
margin-top: 2px;
|
|
223
|
+
color: var(--theme-success-600);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
p {
|
|
227
|
+
margin: 0;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@layer payload-default {
|
|
233
|
+
.builder-editor__card-component {
|
|
234
|
+
margin-right: 4px;
|
|
235
|
+
color: var(--theme-success-600);
|
|
236
|
+
vertical-align: -1px;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SectionDefinition } from '../../../core/types.js';
|
|
2
|
+
import { type Runtime } from '../runtime.js';
|
|
3
|
+
import './variants.scss';
|
|
4
|
+
/** The app section a block was inserted from, when it has variants to switch between. */
|
|
5
|
+
export declare function switchableSection(runtime: Runtime, id: string): SectionDefinition | null;
|
|
6
|
+
/**
|
|
7
|
+
* Replaces the section at `id` with another version of it, as one undo step, and keeps the
|
|
8
|
+
* content the user changed. Selects the new root block. False when it cannot.
|
|
9
|
+
*/
|
|
10
|
+
export declare function switchVariant(runtime: Runtime, id: string, variant: string | undefined): boolean;
|
|
11
|
+
type ArrowsProps = {
|
|
12
|
+
/** Versions in order; the shown one is `index`. */
|
|
13
|
+
count: number;
|
|
14
|
+
index: number;
|
|
15
|
+
/** Text between the arrows, e.g. "Split · 2 / 3". */
|
|
16
|
+
text: string;
|
|
17
|
+
/** Names the control for screen readers, e.g. "Hero versions". */
|
|
18
|
+
label: string;
|
|
19
|
+
onChange: (index: number) => void;
|
|
20
|
+
className?: string;
|
|
21
|
+
buttonClassName?: string;
|
|
22
|
+
};
|
|
23
|
+
/** ‹ text › : flips through `count` versions, wrapping around at both ends. */
|
|
24
|
+
export declare function VariantArrows({ count, index, text, label, onChange, className, buttonClassName }: ArrowsProps): import("react").JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* The variant switch on the action bar of a selected section root: ‹ Split › switches the
|
|
27
|
+
* section to the previous or next version in place. Renders nothing for other blocks.
|
|
28
|
+
*/
|
|
29
|
+
export declare function SectionVariantSwitch({ id }: {
|
|
30
|
+
id: string;
|
|
31
|
+
}): import("react").JSX.Element | null;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Section variants in the editor: the ‹ 2 / 3 › arrows of a library card and the variant switch
|
|
4
|
+
// on the canvas action bar of an inserted section (docs: core/sections.ts).
|
|
5
|
+
import { findBlock, hasVariants, sectionVersions, switchSectionVariant, versionIndex } from '../../../core/index.js';
|
|
6
|
+
import { storesBuilderData } from '../actions.js';
|
|
7
|
+
import { Icon } from '../icons.js';
|
|
8
|
+
import { useRuntime } from '../runtime.js';
|
|
9
|
+
import { useEditor } from '../store.js';
|
|
10
|
+
import './variants.scss';
|
|
11
|
+
/** The app section a block was inserted from, when it has variants to switch between. */
|
|
12
|
+
export function switchableSection(runtime, id) {
|
|
13
|
+
const block = findBlock(runtime.store.getState().layout, id);
|
|
14
|
+
const origin = block?.section;
|
|
15
|
+
if (!origin || !storesBuilderData(runtime))
|
|
16
|
+
return null;
|
|
17
|
+
const section = (runtime.config.sections ?? []).find((s) => s.id === origin.id && s.savedId === undefined);
|
|
18
|
+
return section && hasVariants(section) ? section : null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Replaces the section at `id` with another version of it, as one undo step, and keeps the
|
|
22
|
+
* content the user changed. Selects the new root block. False when it cannot.
|
|
23
|
+
*/
|
|
24
|
+
export function switchVariant(runtime, id, variant) {
|
|
25
|
+
const { layout } = runtime.store.getState();
|
|
26
|
+
const result = switchSectionVariant(layout, id, runtime.config.sections ?? [], variant);
|
|
27
|
+
if (typeof result === 'string') {
|
|
28
|
+
runtime.notify(result);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// The operations carry every locale's data already (stored form): no locale stamping.
|
|
32
|
+
if (!runtime.store.apply(result.ops, { select: result.block.id, stampLocale: false })) {
|
|
33
|
+
runtime.notify('This version of the section cannot go here.');
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
runtime.notify(`Switched to ${result.label}. Undo goes back.`);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
/** ‹ text › : flips through `count` versions, wrapping around at both ends. */
|
|
40
|
+
export function VariantArrows({ count, index, text, label, onChange, className, buttonClassName }) {
|
|
41
|
+
const step = (delta) => onChange((index + delta + count) % count);
|
|
42
|
+
return (_jsxs("fieldset", { "aria-label": label, className: `builder-variants${className ? ` ${className}` : ''}`, children: [_jsx("button", { type: "button", className: buttonClassName ?? 'builder-variants__arrow', "aria-label": "Previous version", "data-tooltip": "Previous version", onClick: () => step(-1), children: _jsx(Icon, { name: "chevronLeft", size: 12 }) }), _jsx("span", { className: "builder-variants__text", "aria-live": "polite", children: text }), _jsx("button", { type: "button", className: buttonClassName ?? 'builder-variants__arrow', "aria-label": "Next version", "data-tooltip": "Next version", onClick: () => step(1), children: _jsx(Icon, { name: "chevronRight", size: 12 }) })] }));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The variant switch on the action bar of a selected section root: ‹ Split › switches the
|
|
46
|
+
* section to the previous or next version in place. Renders nothing for other blocks.
|
|
47
|
+
*/
|
|
48
|
+
export function SectionVariantSwitch({ id }) {
|
|
49
|
+
const runtime = useRuntime();
|
|
50
|
+
// Re-render when the block's origin changes (a switch, an undo).
|
|
51
|
+
const origin = useEditor(runtime.store, (s) => findBlock(s.layout, id)?.section);
|
|
52
|
+
const section = origin ? switchableSection(runtime, id) : null;
|
|
53
|
+
if (!section || !origin)
|
|
54
|
+
return null;
|
|
55
|
+
const versions = sectionVersions(section);
|
|
56
|
+
const index = Math.max(0, versionIndex(section, origin.variant));
|
|
57
|
+
const current = versions[index];
|
|
58
|
+
return (_jsxs(_Fragment, { children: [_jsx(VariantArrows, { count: versions.length, index: index, text: current.label, label: `${section.label} versions`, className: "builder-variants--bar", buttonClassName: "builder-editor__action", onChange: (next) => switchVariant(runtime, id, versions[next].variant) }), _jsx("span", { className: "builder-editor__actions-sep", "aria-hidden": "true" })] }));
|
|
59
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Section variants: the ‹ 2 / 3 › arrows on a library card and the switch on the canvas action bar.
|
|
2
|
+
// Payload CSS variables only (and the editor's --be-* variables, which map to them).
|
|
3
|
+
|
|
4
|
+
@layer payload-default {
|
|
5
|
+
.builder-variants {
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 2px;
|
|
9
|
+
min-width: 0;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
border: 0;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.builder-variants__text {
|
|
17
|
+
min-width: 0;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
font-size: var(--be-text-s);
|
|
21
|
+
font-variant-numeric: tabular-nums;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.builder-variants__arrow {
|
|
25
|
+
display: grid;
|
|
26
|
+
place-items: center;
|
|
27
|
+
width: 20px;
|
|
28
|
+
height: 20px;
|
|
29
|
+
padding: 0;
|
|
30
|
+
border: 0;
|
|
31
|
+
border-radius: 4px;
|
|
32
|
+
background: transparent;
|
|
33
|
+
color: inherit;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
|
|
36
|
+
&:hover {
|
|
37
|
+
background: var(--theme-elevation-100);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&:focus-visible {
|
|
41
|
+
outline: 2px solid var(--theme-success-500);
|
|
42
|
+
outline-offset: 1px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// On a library card: a small pill at the top right of the picture. Saved sections have no
|
|
47
|
+
// variants, so it never meets their "…" menu there.
|
|
48
|
+
.builder-variants--card {
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: 6px;
|
|
51
|
+
right: 6px;
|
|
52
|
+
z-index: 1;
|
|
53
|
+
max-width: calc(100% - 12px);
|
|
54
|
+
padding: 1px;
|
|
55
|
+
border-radius: 6px;
|
|
56
|
+
background: var(--theme-bg);
|
|
57
|
+
box-shadow: 0 1px 3px rgb(0 0 0 / 0.18);
|
|
58
|
+
color: var(--theme-text);
|
|
59
|
+
|
|
60
|
+
.builder-variants__text {
|
|
61
|
+
padding: 0 2px;
|
|
62
|
+
color: var(--be-muted);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// On the canvas action bar: white on the accent color, like the bar's other buttons.
|
|
67
|
+
.builder-variants--bar {
|
|
68
|
+
max-width: 180px;
|
|
69
|
+
|
|
70
|
+
.builder-variants__text {
|
|
71
|
+
max-width: 120px;
|
|
72
|
+
padding: 0 2px;
|
|
73
|
+
color: var(--be-accent-fg);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// A library card with versions keeps one height while the arrows flip it: one label line and
|
|
78
|
+
// room for two description lines, whatever the version shown.
|
|
79
|
+
.builder-editor__card-wrap[data-versions] {
|
|
80
|
+
.builder-editor__card-label {
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
text-overflow: ellipsis;
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.builder-editor__card-desc {
|
|
87
|
+
min-height: 2lh;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -4,6 +4,8 @@ import type { Runtime } from './runtime.js';
|
|
|
4
4
|
export type EditorAction = KeyAction | 'copy' | 'cut' | 'paste' | 'duplicate' | 'help' | 'assistant' | 'hide' | 'moveUp' | 'moveDown' | 'parent' | 'editText' | 'publish' | 'copyStyles' | 'pasteStyles'
|
|
5
5
|
/** Opens the selected block's menu: the ContextMenu key or Shift+F10. */
|
|
6
6
|
| 'menu' | 'rename'
|
|
7
|
+
/** C: comment mode on or off. */
|
|
8
|
+
| 'comments'
|
|
7
9
|
/** Alt+1, Alt+2, Alt+3: the left panel's Layers, Blocks or Sections tab. */
|
|
8
10
|
| `panel:${LeftTab}`;
|
|
9
11
|
/**
|
|
@@ -22,9 +24,10 @@ export declare function publishShortcut(): {
|
|
|
22
24
|
* Key caps for the shortcut help, with the platform's modifier key. `ai` adds the assistant
|
|
23
25
|
* shortcut, `publish` the Publish shortcut (collections with drafts).
|
|
24
26
|
*/
|
|
25
|
-
export declare function shortcutList({ ai, publish }?: {
|
|
27
|
+
export declare function shortcutList({ ai, publish, comments }?: {
|
|
26
28
|
ai?: boolean;
|
|
27
29
|
publish?: boolean;
|
|
30
|
+
comments?: boolean;
|
|
28
31
|
}): {
|
|
29
32
|
keys: string[];
|
|
30
33
|
label: string;
|