payload-canvas 0.4.0 → 0.5.1
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 +626 -154
- 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 -1
- package/dist/blocks/index.js +2 -1
- 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,83 @@
|
|
|
1
|
+
import { defineBlock } from '../../core/blocks.js';
|
|
2
|
+
import { POPUP_CLASS_MAP, POPUP_LABELS } from '../client/popup.js';
|
|
3
|
+
import { classesOf, INTERACTIVE, labelsField, labelsHelp } from './shared.js';
|
|
4
|
+
export { POPUP_CLASS_MAP, POPUP_LABELS };
|
|
5
|
+
export const POPUP_BLOCK = 'popup';
|
|
6
|
+
/** The popup's inner elements that take classes, with the classes a new popup starts with. */
|
|
7
|
+
const POPUP_PARTS = {
|
|
8
|
+
// The box fades and grows in when it opens (150 ms; not with reduced motion).
|
|
9
|
+
panel: {
|
|
10
|
+
label: 'Panel',
|
|
11
|
+
defaultClassName: 'w-[calc(100%-2rem)] max-w-lg rounded-xl p-8 shadow-xl backdrop:bg-black/60 ' +
|
|
12
|
+
'transition-[opacity,scale] duration-150 ease-out starting:scale-95 starting:opacity-0 motion-reduce:transition-none',
|
|
13
|
+
},
|
|
14
|
+
close: { label: 'Close button', defaultClassName: 'absolute top-3 right-3 size-9 rounded-full' },
|
|
15
|
+
};
|
|
16
|
+
const SLOTS = {
|
|
17
|
+
// The trigger renders inside a <button>: links and controls inside it are invalid HTML.
|
|
18
|
+
trigger: { label: 'Button', disallow: [...INTERACTIVE, POPUP_BLOCK, 'tabs'], styles: true, defaultClassName: 'inline-flex items-center gap-2' },
|
|
19
|
+
content: { label: 'Content', styles: true, defaultClassName: 'flex flex-col gap-4' },
|
|
20
|
+
};
|
|
21
|
+
export function popupBlock() {
|
|
22
|
+
return defineBlock({
|
|
23
|
+
type: POPUP_BLOCK,
|
|
24
|
+
label: 'Popup',
|
|
25
|
+
description: 'A button that opens a box over the page, for example a video, a large photo or a form.',
|
|
26
|
+
icon: 'popup',
|
|
27
|
+
category: 'Interactive',
|
|
28
|
+
fields: [
|
|
29
|
+
{
|
|
30
|
+
name: 'label',
|
|
31
|
+
type: 'text',
|
|
32
|
+
label: 'Name for screen readers',
|
|
33
|
+
localized: true,
|
|
34
|
+
admin: { placeholder: 'Empty: the first heading inside' },
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'anchor',
|
|
38
|
+
type: 'text',
|
|
39
|
+
label: 'Open from links to #',
|
|
40
|
+
admin: { placeholder: 'newsletter', custom: { builderContent: false } },
|
|
41
|
+
custom: {
|
|
42
|
+
ai: {
|
|
43
|
+
description: 'Links to "#" plus this name open the popup too.',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
labelsField(POPUP_LABELS, { closeLabel: 'Close button' }),
|
|
48
|
+
],
|
|
49
|
+
slots: SLOTS,
|
|
50
|
+
parts: POPUP_PARTS,
|
|
51
|
+
classes: classesOf(POPUP_CLASS_MAP),
|
|
52
|
+
ai: {
|
|
53
|
+
description: 'A button that opens a popup (a native modal <dialog>). The "trigger" slot is what the visitor clicks: a text, an ' +
|
|
54
|
+
'icon or a small image (no links or buttons: it renders inside a <button>). The "content" slot is the popup. The ' +
|
|
55
|
+
'dialog keeps the focus inside, Escape, the close button and a click outside close it, and the page does not ' +
|
|
56
|
+
'scroll while it is open. The content stays in the HTML. "anchor": links to "#<anchor>" on the page also open it ' +
|
|
57
|
+
'(the trigger may then be empty). "label": the name for screen readers; empty, the first heading in the content ' +
|
|
58
|
+
'names it. Style with "partClassName": "trigger" (the button), "panel" (the dialog box; "backdrop:" classes colour ' +
|
|
59
|
+
'the backdrop, e.g. "backdrop:bg-black/60"), "close" (the close button, placed absolutely in the panel) and ' +
|
|
60
|
+
'"content". For a photo that opens large: a small image in "trigger" and the large image in "content" ' +
|
|
61
|
+
'(panel "max-w-5xl p-0", content "gap-0"). On the canvas a click on the trigger, or selecting the popup or a block inside, ' +
|
|
62
|
+
'opens it over the page; its blocks stay editable.' +
|
|
63
|
+
labelsHelp(POPUP_LABELS),
|
|
64
|
+
example: {
|
|
65
|
+
type: POPUP_BLOCK,
|
|
66
|
+
props: { anchor: 'newsletter' },
|
|
67
|
+
partClassName: {
|
|
68
|
+
trigger: 'inline-flex items-center gap-2 rounded-md border px-4 py-2',
|
|
69
|
+
content: SLOTS.content.defaultClassName,
|
|
70
|
+
panel: POPUP_PARTS.panel.defaultClassName,
|
|
71
|
+
close: POPUP_PARTS.close.defaultClassName,
|
|
72
|
+
},
|
|
73
|
+
slots: {
|
|
74
|
+
trigger: [{ id: 'b_example_1', type: 'text', props: { text: 'Get the newsletter' } }],
|
|
75
|
+
content: [
|
|
76
|
+
{ id: 'b_example_2', type: 'heading', props: { text: 'Stay in touch', level: '2' }, className: 'text-2xl font-semibold' },
|
|
77
|
+
{ id: 'b_example_3', type: 'text', props: { text: 'One email a month. No spam.' } },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import type { Block, BlockDefinition, Layout, Operation } from '../../core/types.js';
|
|
2
2
|
export declare const SECTION_REF_BLOCK = "sectionRef";
|
|
3
|
+
/** Key in Payload's `config.custom`: `{ slug }` of the saved sections collection (set by the plugin). */
|
|
4
|
+
export declare const SAVED_SECTIONS_CONFIG_KEY = "websiteBuilderSavedSections";
|
|
5
|
+
/** The saved sections collection of a Payload config, or null when saved sections are off. */
|
|
6
|
+
export declare function savedSectionsSlugOf(config: {
|
|
7
|
+
custom?: Record<string, unknown>;
|
|
8
|
+
} | undefined): string | null;
|
|
3
9
|
/**
|
|
4
10
|
* Runtime-only slot: the saved section's blocks, put there by `attachSections` (data loading).
|
|
5
11
|
* Never stored. Its blocks are copies with ids prefixed by the ref's id.
|
|
6
12
|
*/
|
|
7
13
|
export declare const SECTION_REF_SLOT = "$section";
|
|
14
|
+
/** The copy's own values for the component's properties (core/components.ts), by property name. */
|
|
15
|
+
export declare const SECTION_REF_VALUES = "values";
|
|
16
|
+
/**
|
|
17
|
+
* Runtime-only prop, set by `attachSections`: the saved section could not be loaded (deleted, or
|
|
18
|
+
* no access), or it would contain itself. The canvas says so; the site shows nothing.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SECTION_REF_MISSING = "$missing";
|
|
8
21
|
/** The id of the saved section a `section` prop points at: an id, or a loaded document. */
|
|
9
22
|
export declare function sectionRefId(value: unknown): string | number | null;
|
|
10
23
|
/**
|
|
@@ -20,7 +33,8 @@ export declare function sectionRefBlocks(refId: string, stored: unknown): Block[
|
|
|
20
33
|
export declare function sectionDetachOps(layout: Layout, refId: string, copies: readonly Block[]): Operation[] | null;
|
|
21
34
|
/**
|
|
22
35
|
* A saved section, live: the page shows the section's current blocks, so a change to the section
|
|
23
|
-
* shows on every page that uses it. "Detach" in the block menu replaces it with a copy. The
|
|
24
|
-
*
|
|
36
|
+
* shows on every page that uses it. "Detach" in the block menu replaces it with a copy. The plugin
|
|
37
|
+
* adds this block when saved sections are on, with its saved sections collection
|
|
38
|
+
* (`websiteBuilder({ savedSections: { slug } })`); a site does not add it itself.
|
|
25
39
|
*/
|
|
26
40
|
export declare function sectionRefBlock(collection?: string): BlockDefinition;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { defineBlock } from '../../core/blocks.js';
|
|
2
2
|
import { findLocation, normalizeLayout } from '../../core/tree.js';
|
|
3
3
|
export const SECTION_REF_BLOCK = 'sectionRef';
|
|
4
|
+
/** Key in Payload's `config.custom`: `{ slug }` of the saved sections collection (set by the plugin). */
|
|
5
|
+
export const SAVED_SECTIONS_CONFIG_KEY = 'websiteBuilderSavedSections';
|
|
6
|
+
/** The saved sections collection of a Payload config, or null when saved sections are off. */
|
|
7
|
+
export function savedSectionsSlugOf(config) {
|
|
8
|
+
const value = config?.custom?.[SAVED_SECTIONS_CONFIG_KEY];
|
|
9
|
+
return typeof value?.slug === 'string' ? value.slug : null;
|
|
10
|
+
}
|
|
4
11
|
/**
|
|
5
12
|
* Runtime-only slot: the saved section's blocks, put there by `attachSections` (data loading).
|
|
6
13
|
* Never stored. Its blocks are copies with ids prefixed by the ref's id.
|
|
7
14
|
*/
|
|
8
15
|
export const SECTION_REF_SLOT = '$section';
|
|
16
|
+
/** The copy's own values for the component's properties (core/components.ts), by property name. */
|
|
17
|
+
export const SECTION_REF_VALUES = 'values';
|
|
18
|
+
/**
|
|
19
|
+
* Runtime-only prop, set by `attachSections`: the saved section could not be loaded (deleted, or
|
|
20
|
+
* no access), or it would contain itself. The canvas says so; the site shows nothing.
|
|
21
|
+
*/
|
|
22
|
+
export const SECTION_REF_MISSING = '$missing';
|
|
9
23
|
/** The id of the saved section a `section` prop points at: an id, or a loaded document. */
|
|
10
24
|
export function sectionRefId(value) {
|
|
11
25
|
if (typeof value === 'number' || (typeof value === 'string' && value))
|
|
@@ -42,14 +56,16 @@ export function sectionDetachOps(layout, refId, copies) {
|
|
|
42
56
|
}
|
|
43
57
|
/**
|
|
44
58
|
* A saved section, live: the page shows the section's current blocks, so a change to the section
|
|
45
|
-
* shows on every page that uses it. "Detach" in the block menu replaces it with a copy. The
|
|
46
|
-
*
|
|
59
|
+
* shows on every page that uses it. "Detach" in the block menu replaces it with a copy. The plugin
|
|
60
|
+
* adds this block when saved sections are on, with its saved sections collection
|
|
61
|
+
* (`websiteBuilder({ savedSections: { slug } })`); a site does not add it itself.
|
|
47
62
|
*/
|
|
48
63
|
export function sectionRefBlock(collection = 'builder-sections') {
|
|
49
64
|
return defineBlock({
|
|
50
65
|
type: SECTION_REF_BLOCK,
|
|
51
|
-
label: '
|
|
52
|
-
|
|
66
|
+
label: 'Component',
|
|
67
|
+
description: 'A saved section that stays in sync on every page. Each copy can set its own text, images and links.',
|
|
68
|
+
icon: 'sectionRef',
|
|
53
69
|
category: 'Dynamic',
|
|
54
70
|
// It renders the section's blocks with their own classes and no element of its own.
|
|
55
71
|
styles: false,
|
|
@@ -57,22 +73,28 @@ export function sectionRefBlock(collection = 'builder-sections') {
|
|
|
57
73
|
{
|
|
58
74
|
name: 'section',
|
|
59
75
|
type: 'relationship',
|
|
60
|
-
label: '
|
|
76
|
+
label: 'Component',
|
|
61
77
|
relationTo: collection,
|
|
62
78
|
required: true,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
// Edited as the component's properties (admin/editor/sections/ComponentFields.tsx). Content in
|
|
82
|
+
// content mode: the designer chose which text, images and links a copy may change.
|
|
83
|
+
name: SECTION_REF_VALUES,
|
|
84
|
+
type: 'json',
|
|
85
|
+
admin: { hidden: true, custom: { builderContent: true } },
|
|
67
86
|
},
|
|
68
87
|
],
|
|
69
88
|
ai: {
|
|
70
89
|
description: `Shows a saved section (the "${collection}" collection) live: the page renders the section's current blocks, so one ` +
|
|
71
90
|
'edit of the section changes every page that uses it. Set "section" to the saved section\'s document id ' +
|
|
72
91
|
'(listSections shows saved sections as "saved:<id>"; use the number). It has no className and no slots. ' +
|
|
73
|
-
'Use it for blocks many pages share (a call to action, a footer band).
|
|
74
|
-
'
|
|
75
|
-
|
|
92
|
+
'Use it for blocks many pages share (a call to action, a footer band). A saved section with properties is a component ' +
|
|
93
|
+
'(listSections shows `component: true` and its `properties`): set "values" to { <property name>: value } to give this ' +
|
|
94
|
+
'copy its own text, rich text, image (an upload id), link ({ type: "url", url }) or visible (true/false) values; a ' +
|
|
95
|
+
'property left out shows the content of the component itself. insertSection with `values` does this for you. To insert ' +
|
|
96
|
+
'blocks the page can change freely, use insertSection with linked: false. A component never contains itself.',
|
|
97
|
+
example: { type: SECTION_REF_BLOCK, props: { section: 1, values: { title: 'Ready to start?' } } },
|
|
76
98
|
},
|
|
77
99
|
});
|
|
78
100
|
}
|
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
import type { Field } from 'payload';
|
|
2
|
+
import type { ControlLabels } from '../client/helpers.js';
|
|
3
|
+
export { classMap, joinClasses, labelOf, textOr, type ControlLabels } from '../client/helpers.js';
|
|
4
|
+
type ClassTree = {
|
|
5
|
+
readonly [key: string]: string | ClassTree;
|
|
6
|
+
};
|
|
7
|
+
/** The classes of a class map (nested maps too), for a definition's `classes`, without the marker. */
|
|
8
|
+
export declare function classesOf(map: ClassTree): string[];
|
|
2
9
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
export declare function classMap<T extends Record<string, string>>(map: T): T;
|
|
8
|
-
/** The classes of a class map, for a definition's `classes`, without the marker. */
|
|
9
|
-
export declare function classesOf(map: Record<string, string>): string[];
|
|
10
|
-
/**
|
|
11
|
-
* Block types that hold links or controls. Slots that render inside an `<a>`, a `<button>` or a
|
|
12
|
-
* `<summary>` refuse them at any depth. A type that does not exist is ignored.
|
|
10
|
+
* Block types that hold links or controls. A link block and slots that render inside a
|
|
11
|
+
* `<button>` or a `<summary>` refuse them at any depth. `form` is a common custom block; a type
|
|
12
|
+
* that does not exist is ignored.
|
|
13
13
|
*/
|
|
14
14
|
export declare const INTERACTIVE: string[];
|
|
15
|
-
/** Plain string props: trimmed, or the fallback when empty. */
|
|
16
|
-
export declare const textOr: (value: unknown, fallback: string) => string;
|
|
17
|
-
/** Prop name -> English default of a control label (`{n}` and `{count}` are filled in where noted). */
|
|
18
|
-
export type ControlLabels = Record<string, string>;
|
|
19
15
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* One localized label prop. It stores no default: empty means the site's label
|
|
17
|
+
* (`builtinComponents({ labels })`), else the English `text`, which the empty input shows. The
|
|
18
|
+
* AI text says the same.
|
|
23
19
|
*/
|
|
24
|
-
export declare function
|
|
20
|
+
export declare function labelField(name: string, text: string, label: string): Field;
|
|
25
21
|
/**
|
|
26
|
-
* A
|
|
27
|
-
*
|
|
22
|
+
* A collapsed **Labels** group of label props (`labelField`), one per key of `names`. The props
|
|
23
|
+
* are flat (`props.closeLabel`); the group only folds them in the inspector. A component reads
|
|
24
|
+
* each one with `labelOf(props, labels, name)`.
|
|
28
25
|
*/
|
|
29
|
-
export declare function
|
|
26
|
+
export declare function labelsField(labels: ControlLabels, names: Record<string, string>): Field;
|
|
30
27
|
/** The AI description of a block's label props. */
|
|
31
28
|
export declare const labelsHelp: (labels: ControlLabels) => string;
|
|
32
|
-
/** Class strings joined with spaces; empty and missing ones are left out. */
|
|
33
|
-
export declare const joinClasses: (...classes: (string | undefined)[]) => string;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { BUILDER_CSS_CLASS } from '../../css/marker.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* (`classesOf`), so the generated CSS has them. Same rule as `withMarker` in `../defaults.ts`.
|
|
6
|
-
*/
|
|
7
|
-
export function classMap(map) {
|
|
8
|
-
return Object.fromEntries(Object.entries(map).map(([key, value]) => [key, `${value} ${BUILDER_CSS_CLASS}`]));
|
|
9
|
-
}
|
|
10
|
-
/** The classes of a class map, for a definition's `classes`, without the marker. */
|
|
2
|
+
// The render helpers live in a leaf module, so client components can import them alone.
|
|
3
|
+
export { classMap, joinClasses, labelOf, textOr } from '../client/helpers.js';
|
|
4
|
+
/** The classes of a class map (nested maps too), for a definition's `classes`, without the marker. */
|
|
11
5
|
export function classesOf(map) {
|
|
12
|
-
const
|
|
6
|
+
const strings = (tree) => Object.values(tree).flatMap((value) => (typeof value === 'string' ? [value] : strings(value)));
|
|
7
|
+
const all = strings(map).flatMap((value) => value.split(' '));
|
|
13
8
|
return [...new Set(all)].filter((cls) => cls && cls !== BUILDER_CSS_CLASS);
|
|
14
9
|
}
|
|
15
10
|
/**
|
|
16
|
-
* Block types that hold links or controls.
|
|
17
|
-
* `<summary>` refuse them at any depth.
|
|
11
|
+
* Block types that hold links or controls. A link block and slots that render inside a
|
|
12
|
+
* `<button>` or a `<summary>` refuse them at any depth. `form` is a common custom block; a type
|
|
13
|
+
* that does not exist is ignored.
|
|
18
14
|
*/
|
|
19
15
|
export const INTERACTIVE = [
|
|
20
16
|
'link',
|
|
@@ -26,45 +22,41 @@ export const INTERACTIVE = [
|
|
|
26
22
|
'form',
|
|
27
23
|
'filterLink',
|
|
28
24
|
'carousel',
|
|
29
|
-
'
|
|
25
|
+
'popup',
|
|
26
|
+
'tabs',
|
|
27
|
+
'adjacentLinks',
|
|
30
28
|
'accordion',
|
|
31
29
|
'disclosure',
|
|
32
30
|
];
|
|
33
|
-
|
|
34
|
-
export const textOr = (value, fallback) => typeof value === 'string' && value.trim() ? value.trim() : fallback;
|
|
31
|
+
const braces = (text) => [...new Set(text.match(/\{\w+\}/g) ?? [])].join(' and ');
|
|
35
32
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
33
|
+
* One localized label prop. It stores no default: empty means the site's label
|
|
34
|
+
* (`builtinComponents({ labels })`), else the English `text`, which the empty input shows. The
|
|
35
|
+
* AI text says the same.
|
|
39
36
|
*/
|
|
40
|
-
export function
|
|
37
|
+
export function labelField(name, text, label) {
|
|
38
|
+
const filled = text.includes('{') ? ` ${braces(text)} are filled in.` : '';
|
|
41
39
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
fields: Object.entries(labels).map(([name, text]) => ({
|
|
49
|
-
name,
|
|
50
|
-
type: 'text',
|
|
51
|
-
label: names[name] ?? name,
|
|
52
|
-
defaultValue: text,
|
|
53
|
-
localized: true,
|
|
54
|
-
...(text.includes('{') ? { admin: { description: `${braces(text)} are filled in.` } } : {}),
|
|
55
|
-
})),
|
|
40
|
+
name,
|
|
41
|
+
type: 'text',
|
|
42
|
+
label,
|
|
43
|
+
localized: true,
|
|
44
|
+
admin: { placeholder: text },
|
|
45
|
+
custom: { ai: { description: `Empty: the site's default, "${text}" in English.${filled}` } },
|
|
56
46
|
};
|
|
57
47
|
}
|
|
58
|
-
const braces = (text) => [...new Set(text.match(/\{\w+\}/g) ?? [])].join(' and ');
|
|
59
48
|
/**
|
|
60
|
-
* A
|
|
61
|
-
*
|
|
49
|
+
* A collapsed **Labels** group of label props (`labelField`), one per key of `names`. The props
|
|
50
|
+
* are flat (`props.closeLabel`); the group only folds them in the inspector. A component reads
|
|
51
|
+
* each one with `labelOf(props, labels, name)`.
|
|
62
52
|
*/
|
|
63
|
-
export function
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
export function labelsField(labels, names) {
|
|
54
|
+
return {
|
|
55
|
+
type: 'collapsible',
|
|
56
|
+
label: 'Labels',
|
|
57
|
+
admin: { initCollapsed: true },
|
|
58
|
+
fields: Object.entries(names).map(([name, label]) => labelField(name, labels[name] ?? '', label)),
|
|
59
|
+
};
|
|
66
60
|
}
|
|
67
61
|
/** The AI description of a block's label props. */
|
|
68
|
-
export const labelsHelp = (labels) => `
|
|
69
|
-
/** Class strings joined with spaces; empty and missing ones are left out. */
|
|
70
|
-
export const joinClasses = (...classes) => classes.filter(Boolean).join(' ');
|
|
62
|
+
export const labelsHelp = (labels) => ` Labels (localized; leave them out to use the site's defaults): ${Object.entries(labels).map(([name, text]) => `"${name}" (English "${text}")`).join(', ')}.`;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { BlockDefinition } from '../../core/types.js';
|
|
2
2
|
export declare const TABLE_OF_CONTENTS_BLOCK = "tableOfContents";
|
|
3
|
+
/** The table of contents' label and its English default. */
|
|
4
|
+
export declare const TABLE_OF_CONTENTS_LABELS: {
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
3
7
|
export declare function tableOfContentsBlock(): BlockDefinition;
|
|
@@ -1,39 +1,33 @@
|
|
|
1
1
|
import { defineBlock } from '../../core/blocks.js';
|
|
2
|
+
import { labelField } from './shared.js';
|
|
2
3
|
export const TABLE_OF_CONTENTS_BLOCK = 'tableOfContents';
|
|
4
|
+
/** The table of contents' label and its English default. */
|
|
5
|
+
export const TABLE_OF_CONTENTS_LABELS = { label: 'On this page' };
|
|
3
6
|
const TOC_CLASS = 'flex flex-col gap-2 text-sm [&>a]:opacity-75 [&>a:hover]:opacity-100';
|
|
4
7
|
export function tableOfContentsBlock() {
|
|
5
8
|
return defineBlock({
|
|
6
9
|
type: TABLE_OF_CONTENTS_BLOCK,
|
|
7
10
|
label: 'Table of contents',
|
|
8
|
-
|
|
11
|
+
description: 'Links to the headings of the page text.',
|
|
12
|
+
icon: 'tableOfContents',
|
|
9
13
|
category: 'Dynamic',
|
|
10
14
|
fields: [
|
|
11
15
|
{
|
|
12
16
|
name: 'content',
|
|
13
17
|
type: 'richText',
|
|
14
|
-
label: '
|
|
15
|
-
admin: {
|
|
16
|
-
description: 'Bind it to the rich text field of the document, for example "content". Its H2 headings become the links. ' +
|
|
17
|
-
'The heading ids come from headingId(), the same as the rich text on the page.',
|
|
18
|
-
},
|
|
18
|
+
label: 'Text with headings',
|
|
19
|
+
admin: { description: 'Bind it to the page’s text field.', custom: { builderContent: false } },
|
|
19
20
|
},
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
type: 'number',
|
|
23
|
-
label: 'Fewest headings',
|
|
24
|
-
defaultValue: 3,
|
|
25
|
-
min: 1,
|
|
26
|
-
admin: { description: 'With fewer H2 headings the block shows nothing.' },
|
|
27
|
-
},
|
|
28
|
-
{ name: 'label', type: 'text', label: 'Label for screen readers', defaultValue: 'On this page', localized: true },
|
|
21
|
+
{ name: 'minHeadings', type: 'number', label: 'Hide below this many headings', defaultValue: 3, min: 1 },
|
|
22
|
+
labelField('label', TABLE_OF_CONTENTS_LABELS.label, 'Name for screen readers'),
|
|
29
23
|
],
|
|
30
24
|
defaultClassName: TOC_CLASS,
|
|
31
25
|
ai: {
|
|
32
26
|
description: 'Links to the H2 headings of a rich text field of the current document (templates): bind its "content" prop to that ' +
|
|
33
27
|
'field, e.g. bindings { "content": "content" }. It renders a <nav> of bare <a href="#id"> elements: style them with ' +
|
|
34
|
-
'[&>a]: classes. The
|
|
35
|
-
'title ("On this page") in a block above it.
|
|
36
|
-
'sample links then.',
|
|
28
|
+
'[&>a]: classes. The richText and field blocks give each heading an id from its text, so the links find them. Put a ' +
|
|
29
|
+
'visible title ("On this page") in a block above it. "label" names the nav for screen readers (default "On this ' +
|
|
30
|
+
'page"). Shows nothing with fewer than "minHeadings" headings; the canvas shows sample links then.',
|
|
37
31
|
example: {
|
|
38
32
|
type: TABLE_OF_CONTENTS_BLOCK,
|
|
39
33
|
bindings: { content: 'content' },
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BlockDefinition } from '../../core/types.js';
|
|
2
|
+
import { TAB_BLOCK, TABS_CLASS_MAP, TABS_LABELS } from '../client/tabs.js';
|
|
3
|
+
export { TAB_BLOCK, TABS_CLASS_MAP, TABS_LABELS };
|
|
4
|
+
export declare const TABS_BLOCK = "tabs";
|
|
5
|
+
export declare function tabsBlock(): BlockDefinition;
|
|
6
|
+
export declare function tabBlock(): BlockDefinition;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { defineBlock } from '../../core/blocks.js';
|
|
2
|
+
import { TAB_BLOCK, TABS_CLASS_MAP, TABS_LABELS } from '../client/tabs.js';
|
|
3
|
+
import { classesOf, labelsField, labelsHelp } from './shared.js';
|
|
4
|
+
export { TAB_BLOCK, TABS_CLASS_MAP, TABS_LABELS };
|
|
5
|
+
export const TABS_BLOCK = 'tabs';
|
|
6
|
+
/** The tabs' inner elements that take classes, with the classes new tabs start with. */
|
|
7
|
+
const TABS_PARTS = {
|
|
8
|
+
list: { label: 'Tab row', defaultClassName: 'flex gap-1 border-b' },
|
|
9
|
+
tab: { label: 'Each tab', defaultClassName: '-mb-px border-b-2 border-transparent px-4 py-2 opacity-70 aria-selected:border-current aria-selected:opacity-100' },
|
|
10
|
+
// The panel that becomes visible fades in (150 ms; not with reduced motion).
|
|
11
|
+
panel: { label: 'Each panel', defaultClassName: 'pt-6 transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none' },
|
|
12
|
+
};
|
|
13
|
+
const TABS_CLASS = 'flex flex-col';
|
|
14
|
+
export function tabsBlock() {
|
|
15
|
+
return defineBlock({
|
|
16
|
+
type: TABS_BLOCK,
|
|
17
|
+
label: 'Tabs',
|
|
18
|
+
description: 'Content in tabs: one row of tab names, one panel shows at a time.',
|
|
19
|
+
icon: 'tabs',
|
|
20
|
+
category: 'Interactive',
|
|
21
|
+
fields: [
|
|
22
|
+
{ name: 'label', type: 'text', label: 'Name for screen readers', localized: true },
|
|
23
|
+
{ name: 'vertical', type: 'checkbox', label: 'Tabs in a column', defaultValue: false },
|
|
24
|
+
labelsField(TABS_LABELS, { tabLabel: 'Tab without a name' }),
|
|
25
|
+
],
|
|
26
|
+
// `min: 2`: tabs need at least two tabs, and a new tabs block starts with two (`starterSlots`).
|
|
27
|
+
slots: { tabs: { label: 'Tabs', allow: [TAB_BLOCK], min: 2 } },
|
|
28
|
+
parts: TABS_PARTS,
|
|
29
|
+
defaultClassName: TABS_CLASS,
|
|
30
|
+
classes: classesOf(TABS_CLASS_MAP),
|
|
31
|
+
ai: {
|
|
32
|
+
description: 'Tabs: a row of tab buttons, and one panel visible at a time. Its "tabs" slot holds only "tab" blocks (at least ' +
|
|
33
|
+
'two); each tab has a "label" prop (the button text) and a "content" slot (its panel). The first tab is open at ' +
|
|
34
|
+
'first. It follows the WAI-ARIA tabs pattern: arrow keys move between tabs, Home and End jump to the first and ' +
|
|
35
|
+
'last. Hidden panels stay in the HTML. "vertical": the tabs stand in a column (arrow up and down); lay the block ' +
|
|
36
|
+
'out with its className ("flex flex-row gap-8") and the "list" part ("flex flex-col"). Style with ' +
|
|
37
|
+
'"partClassName": "list" (the row of tabs), "tab" (each tab button; the open one has aria-selected="true", so ' +
|
|
38
|
+
'"aria-selected:" classes style it) and "panel" (each panel; new tabs fade the shown panel in with ' +
|
|
39
|
+
'"transition-opacity duration-150 starting:opacity-0"). On the canvas a click on a tab opens it, and ' +
|
|
40
|
+
'selecting a block opens its tab.' +
|
|
41
|
+
labelsHelp(TABS_LABELS) +
|
|
42
|
+
' {n} is the tab number.',
|
|
43
|
+
example: {
|
|
44
|
+
type: TABS_BLOCK,
|
|
45
|
+
className: TABS_CLASS,
|
|
46
|
+
partClassName: { list: TABS_PARTS.list.defaultClassName, tab: TABS_PARTS.tab.defaultClassName, panel: TABS_PARTS.panel.defaultClassName },
|
|
47
|
+
slots: {
|
|
48
|
+
tabs: [
|
|
49
|
+
{
|
|
50
|
+
id: 'b_example_1',
|
|
51
|
+
type: TAB_BLOCK,
|
|
52
|
+
props: { label: 'Features' },
|
|
53
|
+
slots: { content: [{ id: 'b_example_2', type: 'text', props: { text: 'Everything you need to start.' } }] },
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'b_example_3',
|
|
57
|
+
type: TAB_BLOCK,
|
|
58
|
+
props: { label: 'Pricing' },
|
|
59
|
+
slots: { content: [{ id: 'b_example_4', type: 'text', props: { text: 'Free for small teams.' } }] },
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function tabBlock() {
|
|
68
|
+
return defineBlock({
|
|
69
|
+
type: TAB_BLOCK,
|
|
70
|
+
label: 'Tab',
|
|
71
|
+
description: 'One tab of a tabs block: its name and its content.',
|
|
72
|
+
icon: 'tab',
|
|
73
|
+
category: 'Interactive',
|
|
74
|
+
parents: [TABS_BLOCK],
|
|
75
|
+
fields: [{ name: 'label', type: 'text', label: 'Tab name', localized: true }],
|
|
76
|
+
slots: { content: { label: 'Content' } },
|
|
77
|
+
ai: {
|
|
78
|
+
description: 'One tab of a "tabs" block (only there). "label" is the text of its tab button; the "content" slot is its panel. ' +
|
|
79
|
+
'Its className styles its own panel; the tabs block\'s "panel" part styles every panel.',
|
|
80
|
+
example: {
|
|
81
|
+
type: TAB_BLOCK,
|
|
82
|
+
props: { label: 'Details' },
|
|
83
|
+
slots: { content: [{ id: 'b_example_1', type: 'text', props: { text: 'Made of recycled steel.' } }] },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The classes a new carousel starts with on its parts (`block.partClassName`). Colours come from
|
|
3
|
+
* the text colour (`current`), so the controls fit any background. The arrows and dots keep a hit
|
|
4
|
+
* area of at least 24 px.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CAROUSEL_PART_CLASSES: {
|
|
7
|
+
slides: string;
|
|
8
|
+
arrow: string;
|
|
9
|
+
dot: string;
|
|
10
|
+
pause: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Classes the carousel component adds itself: how the viewport clips and the track lays out the
|
|
14
|
+
* slides, and where the controls sit. The `*List` classes go on the track only when its one child
|
|
15
|
+
* is a collection list or a repeat with a wrapper: that wrapper is unwrapped with
|
|
16
|
+
* `display: contents`, so its items are the slides. One slide made by hand stays one slide. No
|
|
17
|
+
* colours or sizes: those come from the block's className and the part classes.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CAROUSEL_CLASS_MAP: {
|
|
20
|
+
viewport: string;
|
|
21
|
+
track: string;
|
|
22
|
+
trackList: string;
|
|
23
|
+
/** Fade: every slide fills the viewport; the fade plugin stacks them. */
|
|
24
|
+
fade: string;
|
|
25
|
+
fadeList: string;
|
|
26
|
+
controls: string;
|
|
27
|
+
dots: string;
|
|
28
|
+
arrows: string;
|
|
29
|
+
button: string;
|
|
30
|
+
/** The dot's visible mark is its `::after`. */
|
|
31
|
+
dot: string;
|
|
32
|
+
icon: string;
|
|
33
|
+
};
|
|
34
|
+
/** The carousel's labels and their English defaults. */
|
|
35
|
+
export declare const CAROUSEL_LABELS: {
|
|
36
|
+
label: string;
|
|
37
|
+
previousLabel: string;
|
|
38
|
+
nextLabel: string;
|
|
39
|
+
pauseLabel: string;
|
|
40
|
+
playLabel: string;
|
|
41
|
+
dotLabel: string;
|
|
42
|
+
slideLabel: string;
|
|
43
|
+
carouselRole: string;
|
|
44
|
+
slideRole: string;
|
|
45
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Read by the carousel component in the browser. A leaf module: no block definitions, so the
|
|
2
|
+
// component's JavaScript does not carry them. The block definition re-exports these values.
|
|
3
|
+
import { classMap } from './helpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* The classes a new carousel starts with on its parts (`block.partClassName`). Colours come from
|
|
6
|
+
* the text colour (`current`), so the controls fit any background. The arrows and dots keep a hit
|
|
7
|
+
* area of at least 24 px.
|
|
8
|
+
*/
|
|
9
|
+
export const CAROUSEL_PART_CLASSES = {
|
|
10
|
+
slides: 'gap-4',
|
|
11
|
+
arrow: 'size-10 rounded-full border border-current/20 transition-colors hover:border-current/50 hover:bg-current/5 ' +
|
|
12
|
+
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current ' +
|
|
13
|
+
'disabled:opacity-30 disabled:hover:border-current/20 disabled:hover:bg-transparent',
|
|
14
|
+
dot: 'h-6 rounded-full px-1 after:h-1.5 after:w-1.5 after:rounded-full after:bg-current after:opacity-25 ' +
|
|
15
|
+
'after:transition-[width,opacity] after:duration-300 hover:after:opacity-50 motion-reduce:after:transition-none ' +
|
|
16
|
+
'aria-[current=true]:after:w-5 aria-[current=true]:after:opacity-100 ' +
|
|
17
|
+
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current',
|
|
18
|
+
pause: 'h-10 rounded-full px-3 text-sm underline-offset-4 hover:underline',
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Classes the carousel component adds itself: how the viewport clips and the track lays out the
|
|
22
|
+
* slides, and where the controls sit. The `*List` classes go on the track only when its one child
|
|
23
|
+
* is a collection list or a repeat with a wrapper: that wrapper is unwrapped with
|
|
24
|
+
* `display: contents`, so its items are the slides. One slide made by hand stays one slide. No
|
|
25
|
+
* colours or sizes: those come from the block's className and the part classes.
|
|
26
|
+
*/
|
|
27
|
+
export const CAROUSEL_CLASS_MAP = classMap({
|
|
28
|
+
viewport: 'overflow-hidden',
|
|
29
|
+
track: 'flex touch-pan-y touch-pinch-zoom *:min-w-0 *:shrink-0',
|
|
30
|
+
trackList: '*:contents [&>*>*]:min-w-0 [&>*>*]:shrink-0',
|
|
31
|
+
/** Fade: every slide fills the viewport; the fade plugin stacks them. */
|
|
32
|
+
fade: '*:basis-full',
|
|
33
|
+
fadeList: '[&>*>*]:basis-full',
|
|
34
|
+
controls: 'flex flex-wrap items-center justify-between gap-4',
|
|
35
|
+
dots: 'flex flex-wrap items-center',
|
|
36
|
+
arrows: 'ms-auto flex items-center gap-2',
|
|
37
|
+
button: 'inline-flex cursor-pointer items-center justify-center disabled:cursor-default',
|
|
38
|
+
/** The dot's visible mark is its `::after`. */
|
|
39
|
+
dot: 'after:block',
|
|
40
|
+
icon: 'size-5',
|
|
41
|
+
});
|
|
42
|
+
/** The carousel's labels and their English defaults. */
|
|
43
|
+
export const CAROUSEL_LABELS = {
|
|
44
|
+
label: 'Carousel',
|
|
45
|
+
previousLabel: 'Previous slide',
|
|
46
|
+
nextLabel: 'Next slide',
|
|
47
|
+
pauseLabel: 'Pause',
|
|
48
|
+
playLabel: 'Play',
|
|
49
|
+
dotLabel: 'Slide {n}',
|
|
50
|
+
slideLabel: '{n} of {count}',
|
|
51
|
+
carouselRole: 'carousel',
|
|
52
|
+
slideRole: 'slide',
|
|
53
|
+
};
|