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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useSyncExternalStore } from 'react';
|
|
4
|
-
import { filterHref } from '../../../blocks/
|
|
5
|
-
import { textOr } from '../../../blocks/
|
|
4
|
+
import { filterHref } from '../../../blocks/client/filterLink.js';
|
|
5
|
+
import { textOr } from '../../../blocks/client/helpers.js';
|
|
6
6
|
const subscribe = (onChange) => {
|
|
7
7
|
window.addEventListener('popstate', onChange);
|
|
8
8
|
return () => window.removeEventListener('popstate', onChange);
|
|
@@ -16,7 +16,7 @@ const serverUrl = () => null;
|
|
|
16
16
|
* After hydration it keeps the page's other query values and marks the current filter with
|
|
17
17
|
* `aria-current="true"`.
|
|
18
18
|
*/
|
|
19
|
-
export function FilterLink({ props, className, attributes,
|
|
19
|
+
export function FilterLink({ props, className, attributes, partAttributes, slots }) {
|
|
20
20
|
const url = useSyncExternalStore(subscribe, clientUrl, serverUrl);
|
|
21
21
|
const parsed = url === null ? null : new URL(url, 'http://localhost');
|
|
22
22
|
const { href, active } = filterHref(parsed?.pathname ?? '', parsed?.searchParams ?? new URLSearchParams(), {
|
|
@@ -26,5 +26,5 @@ export function FilterLink({ props, className, attributes, slotAttributes, slots
|
|
|
26
26
|
// The page parameters of the layout's lists with their own `pageParam` (`withPageParams`).
|
|
27
27
|
pageParams: Array.isArray(props.$pageParams) ? props.$pageParams.filter((item) => typeof item === 'string') : [],
|
|
28
28
|
});
|
|
29
|
-
return (_jsx("a", { ...attributes, ...
|
|
29
|
+
return (_jsx("a", { ...attributes, ...partAttributes.children, href: href, "aria-current": url !== null && active ? 'true' : undefined, className: className, children: slots.children }));
|
|
30
30
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BlockComponentProps } from '../../render/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A row of items that scrolls sideways without end, in CSS only (no JavaScript). The items render
|
|
4
|
+
* twice: the copy is hidden from screen readers and the keyboard (`aria-hidden`, `inert`), and the
|
|
5
|
+
* track moves by half its width, so the loop has no seam. It stands still, with the items wrapped
|
|
6
|
+
* and no copy, when the visitor asks for less motion and in the editor (easier to edit there).
|
|
7
|
+
*/
|
|
8
|
+
export declare function Marquee({ props, className, attributes, partAttributes, slots, mode }: BlockComponentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MARQUEE_CSS, MARQUEE_SECONDS } from '../../../blocks/client/marquee.js';
|
|
3
|
+
const speedOf = (value) => (typeof value === 'string' && value in MARQUEE_SECONDS ? value : 'normal');
|
|
4
|
+
/**
|
|
5
|
+
* A row of items that scrolls sideways without end, in CSS only (no JavaScript). The items render
|
|
6
|
+
* twice: the copy is hidden from screen readers and the keyboard (`aria-hidden`, `inert`), and the
|
|
7
|
+
* track moves by half its width, so the loop has no seam. It stands still, with the items wrapped
|
|
8
|
+
* and no copy, when the visitor asks for less motion and in the editor (easier to edit there).
|
|
9
|
+
*/
|
|
10
|
+
export function Marquee({ props, className, attributes, partAttributes, slots, mode }) {
|
|
11
|
+
const still = mode !== 'site';
|
|
12
|
+
const { className: itemsClass } = partAttributes.children ?? {};
|
|
13
|
+
const style = { '--marquee-duration': `${MARQUEE_SECONDS[speedOf(props.speed)]}s` };
|
|
14
|
+
return (_jsxs("div", { ...attributes, className: className, "data-marquee": props.direction === 'right' ? 'right' : 'left', "data-marquee-pause": !still && props.pauseOnHover !== false ? '' : undefined, "data-marquee-still": still ? '' : undefined, style: style, children: [_jsx("style", { href: "builder-marquee", precedence: "default", children: MARQUEE_CSS }), _jsxs("div", { "data-marquee-track": "", children: [_jsx("div", { ...partAttributes.children, children: slots.children }), still ? null : (_jsx("div", { className: itemsClass, "data-marquee-copy": "", "aria-hidden": "true", inert: true, children: slots.children }))] })] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { POPUP_LABELS } from '../../../blocks/client/popup.js';
|
|
2
|
+
import type { BlockComponentProps } from '../../render/types.js';
|
|
3
|
+
export type PopupLabels = Partial<typeof POPUP_LABELS>;
|
|
4
|
+
/** The href of links that open the popup ("#newsletter"), or null when the anchor is empty or not a plain name. */
|
|
5
|
+
export declare function anchorHref(value: unknown): string | null;
|
|
6
|
+
/** True when the point lies outside the box: a click on the backdrop of a modal dialog. */
|
|
7
|
+
export declare function isOutside(box: {
|
|
8
|
+
left: number;
|
|
9
|
+
top: number;
|
|
10
|
+
right: number;
|
|
11
|
+
bottom: number;
|
|
12
|
+
}, x: number, y: number): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* A button (the "trigger" slot) that opens the "content" slot in a native modal <dialog>. The
|
|
15
|
+
* dialog keeps the focus inside, makes the page inert and closes on Escape; a click on the
|
|
16
|
+
* backdrop and the close button close it too, and the page does not scroll while it is open.
|
|
17
|
+
* Links to `#<anchor>` open it as well. The content stays in the HTML.
|
|
18
|
+
*
|
|
19
|
+
* On the canvas the dialog is a popover over the page, with the same backdrop, but not modal: the
|
|
20
|
+
* editor can select and edit the blocks in it. It opens when the trigger is clicked or the editor
|
|
21
|
+
* selects the popup or a block inside it (the reveal event). It closes on Escape, the close button,
|
|
22
|
+
* a click on the backdrop, and when the editor selects a block outside it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function Popup({ block, props, className, attributes, partAttributes, slots, mode, labels }: BlockComponentProps & {
|
|
25
|
+
labels?: PopupLabels;
|
|
26
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { joinClasses, labelOf, textOr } from '../../../blocks/client/helpers.js';
|
|
5
|
+
import { POPUP_CLASS_MAP as C, POPUP_LABELS } from '../../../blocks/client/popup.js';
|
|
6
|
+
import { CANVAS_CONTROL_ATTRIBUTE, REVEAL_EVENT, useCanvasReveal } from '../../render/reveal.js';
|
|
7
|
+
import { CloseIcon } from './glyphs.js';
|
|
8
|
+
/** On the canvas the trigger and the close button work as on the site: a click does not select the block. */
|
|
9
|
+
const CONTROL = { [CANVAS_CONTROL_ATTRIBUTE]: '' };
|
|
10
|
+
/**
|
|
11
|
+
* On the canvas the open popup is a popover, not a modal: it shows over the page as on the site,
|
|
12
|
+
* but the editor can still select and edit its blocks. These are the browser's styles for a modal
|
|
13
|
+
* dialog, which a popover lacks: centred in the canvas, never taller than it.
|
|
14
|
+
*/
|
|
15
|
+
const CANVAS_PANEL = { position: 'fixed', inset: 0, maxHeight: 'calc(100% - 2rem)', overflow: 'auto' };
|
|
16
|
+
/** The href of links that open the popup ("#newsletter"), or null when the anchor is empty or not a plain name. */
|
|
17
|
+
export function anchorHref(value) {
|
|
18
|
+
const name = textOr(value, '').replace(/^#/, '');
|
|
19
|
+
return /^[\w-]+$/.test(name) ? `#${name}` : null;
|
|
20
|
+
}
|
|
21
|
+
/** True when the point lies outside the box: a click on the backdrop of a modal dialog. */
|
|
22
|
+
export function isOutside(box, x, y) {
|
|
23
|
+
return x < box.left || x > box.right || y < box.top || y > box.bottom;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A button (the "trigger" slot) that opens the "content" slot in a native modal <dialog>. The
|
|
27
|
+
* dialog keeps the focus inside, makes the page inert and closes on Escape; a click on the
|
|
28
|
+
* backdrop and the close button close it too, and the page does not scroll while it is open.
|
|
29
|
+
* Links to `#<anchor>` open it as well. The content stays in the HTML.
|
|
30
|
+
*
|
|
31
|
+
* On the canvas the dialog is a popover over the page, with the same backdrop, but not modal: the
|
|
32
|
+
* editor can select and edit the blocks in it. It opens when the trigger is clicked or the editor
|
|
33
|
+
* selects the popup or a block inside it (the reveal event). It closes on Escape, the close button,
|
|
34
|
+
* a click on the backdrop, and when the editor selects a block outside it.
|
|
35
|
+
*/
|
|
36
|
+
export function Popup({ block, props, className, attributes, partAttributes, slots, mode, labels }) {
|
|
37
|
+
const root = useRef(null);
|
|
38
|
+
const dialog = useRef(null);
|
|
39
|
+
const [open, setOpen] = useState(false);
|
|
40
|
+
const canvas = mode === 'canvas';
|
|
41
|
+
const dialogId = `${useId()}popup`;
|
|
42
|
+
const label = textOr(props.label, '');
|
|
43
|
+
const href = anchorHref(props.anchor);
|
|
44
|
+
const L = labels ? { ...POPUP_LABELS, ...labels } : POPUP_LABELS;
|
|
45
|
+
// Site: open as a modal, and keep the page from scrolling until it closes.
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const el = dialog.current;
|
|
48
|
+
if (!el || canvas)
|
|
49
|
+
return;
|
|
50
|
+
if (!open) {
|
|
51
|
+
if (el.open)
|
|
52
|
+
el.close();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!el.open)
|
|
56
|
+
el.showModal();
|
|
57
|
+
const html = document.documentElement;
|
|
58
|
+
const overflow = html.style.overflow;
|
|
59
|
+
html.style.overflow = 'hidden';
|
|
60
|
+
return () => {
|
|
61
|
+
html.style.overflow = overflow;
|
|
62
|
+
};
|
|
63
|
+
}, [canvas, open]);
|
|
64
|
+
// Without its own name, the dialog is named by its first heading. After every render: the
|
|
65
|
+
// content can change (an edit on the canvas, a list that loads).
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const el = dialog.current;
|
|
68
|
+
if (!el || label)
|
|
69
|
+
return;
|
|
70
|
+
const heading = el.querySelector('h1, h2, h3, h4, h5, h6');
|
|
71
|
+
if (!heading)
|
|
72
|
+
return el.removeAttribute('aria-labelledby');
|
|
73
|
+
if (!heading.id)
|
|
74
|
+
heading.id = `${dialogId}-title`;
|
|
75
|
+
el.setAttribute('aria-labelledby', heading.id);
|
|
76
|
+
});
|
|
77
|
+
// Links to "#<anchor>" open the popup, and so does that hash in the address when the page loads.
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!href || canvas)
|
|
80
|
+
return;
|
|
81
|
+
const onClick = (event) => {
|
|
82
|
+
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
|
|
83
|
+
return;
|
|
84
|
+
const link = event.target instanceof Element ? event.target.closest('a') : null;
|
|
85
|
+
if (link?.getAttribute('href') !== href)
|
|
86
|
+
return;
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
setOpen(true);
|
|
89
|
+
};
|
|
90
|
+
document.addEventListener('click', onClick);
|
|
91
|
+
// The address is outside React: read it once the page has hydrated.
|
|
92
|
+
// oxlint-disable-next-line react/set-state-in-effect
|
|
93
|
+
if (window.location.hash === href)
|
|
94
|
+
setOpen(true);
|
|
95
|
+
return () => document.removeEventListener('click', onClick);
|
|
96
|
+
}, [canvas, href]);
|
|
97
|
+
// Canvas: the open popup is a popover (the browser's top layer, so no parent clips it). Before
|
|
98
|
+
// paint, so the backdrop never shows without the box.
|
|
99
|
+
useLayoutEffect(() => {
|
|
100
|
+
const el = dialog.current;
|
|
101
|
+
if (!el || !canvas || typeof el.showPopover !== 'function')
|
|
102
|
+
return;
|
|
103
|
+
const shown = el.matches(':popover-open');
|
|
104
|
+
if (open && !shown)
|
|
105
|
+
el.showPopover();
|
|
106
|
+
if (!open && shown)
|
|
107
|
+
el.hidePopover();
|
|
108
|
+
}, [canvas, open]);
|
|
109
|
+
// Canvas: Escape and selecting a block outside the popup close it.
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (!canvas || !open)
|
|
112
|
+
return;
|
|
113
|
+
const onKey = (event) => {
|
|
114
|
+
// Escape in a text being edited ends the editing, not the popup. (The canvas also sends
|
|
115
|
+
// Escape to the editor, which clears the selection.)
|
|
116
|
+
const editing = event.target instanceof HTMLElement && event.target.isContentEditable;
|
|
117
|
+
if (event.key === 'Escape' && !editing)
|
|
118
|
+
setOpen(false);
|
|
119
|
+
};
|
|
120
|
+
const onReveal = (event) => {
|
|
121
|
+
if (event.target instanceof Node && !root.current?.contains(event.target))
|
|
122
|
+
setOpen(false);
|
|
123
|
+
};
|
|
124
|
+
document.addEventListener('keydown', onKey);
|
|
125
|
+
document.addEventListener(REVEAL_EVENT, onReveal);
|
|
126
|
+
return () => {
|
|
127
|
+
document.removeEventListener('keydown', onKey);
|
|
128
|
+
document.removeEventListener(REVEAL_EVENT, onReveal);
|
|
129
|
+
};
|
|
130
|
+
}, [canvas, open]);
|
|
131
|
+
// Canvas: selecting the popup or a block in its content opens it.
|
|
132
|
+
useCanvasReveal(root, (target) => {
|
|
133
|
+
if (target === root.current || dialog.current?.contains(target))
|
|
134
|
+
setOpen(true);
|
|
135
|
+
});
|
|
136
|
+
// A click on the backdrop reaches the dialog itself (on the canvas too: it is a canvas control there).
|
|
137
|
+
const onDialogClick = (event) => {
|
|
138
|
+
if (event.target !== event.currentTarget)
|
|
139
|
+
return;
|
|
140
|
+
if (isOutside(event.currentTarget.getBoundingClientRect(), event.clientX, event.clientY))
|
|
141
|
+
setOpen(false);
|
|
142
|
+
};
|
|
143
|
+
// On the site an empty trigger renders no button: links to the anchor open the popup.
|
|
144
|
+
const trigger = canvas || (block.slots?.trigger?.length ?? 0) > 0;
|
|
145
|
+
return (_jsxs("div", { ...attributes, ref: root, className: className, children: [trigger ? (_jsx("button", { ...partAttributes.trigger, ...CONTROL, type: "button", className: joinClasses(C.trigger, partAttributes.trigger?.className), "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": dialogId, onClick: () => setOpen(true), children: slots.trigger })) : null, _jsxs("dialog", { ref: dialog, id: dialogId, "data-popup-panel": "", "aria-label": label || undefined, className: joinClasses(C.panel, partAttributes.panel?.className), open: canvas ? open : undefined, popover: canvas ? 'manual' : undefined, style: canvas ? CANVAS_PANEL : undefined, onClose: () => setOpen(false), onClick: onDialogClick, children: [_jsx("button", { ...CONTROL, type: "button", "data-popup-close": "", className: joinClasses(C.close, partAttributes.close?.className), "aria-label": labelOf(props, L, 'closeLabel'), onClick: () => setOpen(false), children: _jsx(CloseIcon, { className: C.icon }) }), _jsx("div", { ...partAttributes.content, children: slots.content })] })] }));
|
|
146
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { BlockComponentProps } from '../../render/types.js';
|
|
2
2
|
/**
|
|
3
|
-
* A live saved section: its blocks, with no element of its own on the site.
|
|
4
|
-
* element with `display: contents` holds the editor attributes, so the editor can
|
|
5
|
-
* The blocks come from `loadLayoutData` (or the canvas); without them the site shows
|
|
3
|
+
* A live saved section (a component's copy): its blocks, with no element of its own on the site.
|
|
4
|
+
* On the canvas an element with `display: contents` holds the editor attributes, so the editor can
|
|
5
|
+
* select it. The blocks come from `loadLayoutData` (or the canvas); without them the site shows
|
|
6
|
+
* nothing.
|
|
6
7
|
*/
|
|
7
8
|
export declare function SectionRef({ block, slots, attributes, mode }: BlockComponentProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { SECTION_REF_SLOT } from '../../../blocks/builtins/sectionRef.js';
|
|
2
|
+
import { SECTION_REF_MISSING, SECTION_REF_SLOT } from '../../../blocks/builtins/sectionRef.js';
|
|
3
3
|
import { PlaceholderBox } from '../placeholder.js';
|
|
4
4
|
const CONTENTS = { display: 'contents' };
|
|
5
5
|
/**
|
|
6
|
-
* A live saved section: its blocks, with no element of its own on the site.
|
|
7
|
-
* element with `display: contents` holds the editor attributes, so the editor can
|
|
8
|
-
* The blocks come from `loadLayoutData` (or the canvas); without them the site shows
|
|
6
|
+
* A live saved section (a component's copy): its blocks, with no element of its own on the site.
|
|
7
|
+
* On the canvas an element with `display: contents` holds the editor attributes, so the editor can
|
|
8
|
+
* select it. The blocks come from `loadLayoutData` (or the canvas); without them the site shows
|
|
9
|
+
* nothing.
|
|
9
10
|
*/
|
|
10
11
|
export function SectionRef({ block, slots, attributes, mode }) {
|
|
11
12
|
const loaded = (block.slots?.[SECTION_REF_SLOT]?.length ?? 0) > 0;
|
|
12
13
|
if (mode !== 'canvas')
|
|
13
14
|
return loaded ? slots[SECTION_REF_SLOT] : null;
|
|
15
|
+
if (block.props?.[SECTION_REF_MISSING]) {
|
|
16
|
+
return _jsx(PlaceholderBox, { attributes: attributes, label: "Component not found: it was deleted, or it would contain itself" });
|
|
17
|
+
}
|
|
14
18
|
if (!loaded)
|
|
15
|
-
return _jsx(PlaceholderBox, { attributes: attributes, label: "
|
|
19
|
+
return _jsx(PlaceholderBox, { attributes: attributes, label: "Component: pick one in the Content tab" });
|
|
16
20
|
return (_jsx("div", { ...attributes, style: CONTENTS, children: slots[SECTION_REF_SLOT] }));
|
|
17
21
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BlockComponentProps } from '../../render/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* One panel of a tabs block (`role="tabpanel"`), labelled by its tab button. Only the open tab's
|
|
4
|
+
* panel shows; the others stay in the HTML with `hidden`. Outside a tabs block it renders its
|
|
5
|
+
* content in a plain element.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Tab({ block, className, attributes, partAttributes, slots }: BlockComponentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { joinClasses } from '../../../blocks/client/helpers.js';
|
|
5
|
+
import { TabsContext } from './tabsContext.js';
|
|
6
|
+
/**
|
|
7
|
+
* One panel of a tabs block (`role="tabpanel"`), labelled by its tab button. Only the open tab's
|
|
8
|
+
* panel shows; the others stay in the HTML with `hidden`. Outside a tabs block it renders its
|
|
9
|
+
* content in a plain element.
|
|
10
|
+
*/
|
|
11
|
+
export function Tab({ block, className, attributes, partAttributes, slots }) {
|
|
12
|
+
const tabs = useContext(TabsContext);
|
|
13
|
+
if (!tabs) {
|
|
14
|
+
return (_jsx("div", { ...attributes, ...partAttributes.content, className: className, children: slots.content }));
|
|
15
|
+
}
|
|
16
|
+
const open = tabs.active === block.id;
|
|
17
|
+
return (_jsx("div", { ...attributes, ...partAttributes.content, id: tabs.panelId(block.id), role: "tabpanel", "aria-labelledby": tabs.tabId(block.id),
|
|
18
|
+
// The panel takes the focus after the tab row (WAI-ARIA tabs pattern).
|
|
19
|
+
// oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
20
|
+
tabIndex: 0, hidden: !open, "data-tab-panel": block.id, className: joinClasses(tabs.panelClassName, className) || undefined, children: slots.content }));
|
|
21
|
+
}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
import { TABLE_OF_CONTENTS_LABELS } from '../../../blocks/builtins/tableOfContents.js';
|
|
1
2
|
import type { BlockComponentProps } from '../../render/types.js';
|
|
3
|
+
type Entry = {
|
|
4
|
+
id: string;
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
8
|
+
* The top-level H2 headings of Lexical rich text, with the ids the rendered rich text gives them
|
|
9
|
+
* (`richTextHeadings`: repeated texts get "-2", "-3"). Headings without letters or digits are left out.
|
|
10
|
+
*/
|
|
11
|
+
export declare function tableOfContentsEntries(value: unknown): Entry[];
|
|
12
|
+
export type TableOfContentsLabels = Partial<typeof TABLE_OF_CONTENTS_LABELS>;
|
|
13
|
+
/**
|
|
14
|
+
* Links to the H2 headings of the bound rich text (`content`). The richText and field blocks give
|
|
15
|
+
* the headings on the page the same ids (`richTextHeadings`). The canvas shows sample links when
|
|
5
16
|
* there are too few headings, so the block can be selected and styled.
|
|
6
17
|
*/
|
|
7
|
-
export declare function TableOfContents({ props, className, attributes, mode }: BlockComponentProps
|
|
18
|
+
export declare function TableOfContents({ props, className, attributes, mode, labels }: BlockComponentProps & {
|
|
19
|
+
labels?: TableOfContentsLabels;
|
|
20
|
+
}): import("react").JSX.Element | null;
|
|
21
|
+
export {};
|
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { TABLE_OF_CONTENTS_LABELS } from '../../../blocks/builtins/tableOfContents.js';
|
|
3
|
+
import { labelOf } from '../../../blocks/builtins/shared.js';
|
|
4
|
+
import { headingId, richTextHeadings } from '../../../core/headings.js';
|
|
4
5
|
const SAMPLE = [
|
|
5
6
|
{ id: 'sample-1', text: 'First heading of the text (sample)' },
|
|
6
7
|
{ id: 'sample-2', text: 'Second heading (sample)' },
|
|
7
8
|
{ id: 'sample-3', text: 'Third heading (sample)' },
|
|
8
9
|
];
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* The top-level H2 headings of Lexical rich text, with the ids the rendered rich text gives them
|
|
12
|
+
* (`richTextHeadings`: repeated texts get "-2", "-3"). Headings without letters or digits are left out.
|
|
13
|
+
*/
|
|
14
|
+
export function tableOfContentsEntries(value) {
|
|
15
|
+
const children = value?.root?.children;
|
|
16
|
+
if (!Array.isArray(children))
|
|
17
|
+
return [];
|
|
18
|
+
const topLevel = new Set(children);
|
|
19
|
+
return richTextHeadings(value)
|
|
20
|
+
.filter((heading) => heading.level === 2 && topLevel.has(heading.node) && headingId(heading.text))
|
|
21
|
+
.map(({ id, text }) => ({ id, text }));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Links to the H2 headings of the bound rich text (`content`). The richText and field blocks give
|
|
25
|
+
* the headings on the page the same ids (`richTextHeadings`). The canvas shows sample links when
|
|
12
26
|
* there are too few headings, so the block can be selected and styled.
|
|
13
27
|
*/
|
|
14
|
-
export function TableOfContents({ props, className, attributes, mode }) {
|
|
28
|
+
export function TableOfContents({ props, className, attributes, mode, labels }) {
|
|
15
29
|
const min = typeof props.minHeadings === 'number' ? props.minHeadings : 3;
|
|
16
|
-
const found =
|
|
30
|
+
const found = tableOfContentsEntries(props.content);
|
|
17
31
|
const headings = found.length >= min ? found : mode === 'canvas' ? SAMPLE : [];
|
|
18
32
|
if (headings.length === 0)
|
|
19
33
|
return null;
|
|
20
|
-
|
|
34
|
+
const L = labels ? { ...TABLE_OF_CONTENTS_LABELS, ...labels } : TABLE_OF_CONTENTS_LABELS;
|
|
35
|
+
return (_jsx("nav", { ...attributes, "aria-label": labelOf(props, L, 'label'), className: className, children: headings.map((heading, i) => (_jsx("a", { href: `#${heading.id}`, children: heading.text }, `${heading.id}-${i}`))) }));
|
|
21
36
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TABS_LABELS } from '../../../blocks/client/tabs.js';
|
|
2
|
+
import type { BlockComponentProps } from '../../render/types.js';
|
|
3
|
+
export type TabsLabels = Partial<typeof TABS_LABELS>;
|
|
4
|
+
/**
|
|
5
|
+
* The tab a key moves to from tab `index` of `count` (WAI-ARIA tabs pattern): the arrow keys of
|
|
6
|
+
* the row's direction step and wrap around, Home and End jump to the ends. Null for other keys.
|
|
7
|
+
*/
|
|
8
|
+
export declare function tabStep(key: string, index: number, count: number, vertical: boolean): number | null;
|
|
9
|
+
/**
|
|
10
|
+
* Tabs: a row of tab buttons (`role="tablist"`) made from the tab blocks in the "tabs" slot, and
|
|
11
|
+
* their panels (the tab blocks themselves, see `Tab`). One panel shows at a time; the first one
|
|
12
|
+
* at first. Roving focus: only the open tab is in the Tab order, and the arrow keys move between
|
|
13
|
+
* tabs. On the canvas a click on a tab opens it, and selecting a block opens the tab that holds it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Tabs({ block, props, className, attributes, partAttributes, slots, mode, labels }: BlockComponentProps & {
|
|
16
|
+
labels?: TabsLabels;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createElement as _createElement } from "react";
|
|
4
|
+
import { useId, useRef, useState } from 'react';
|
|
5
|
+
import { joinClasses, labelOf, textOr } from '../../../blocks/client/helpers.js';
|
|
6
|
+
import { TABS_CLASS_MAP as C, TABS_LABELS } from '../../../blocks/client/tabs.js';
|
|
7
|
+
import { CANVAS_CONTROL_ATTRIBUTE, useCanvasReveal } from '../../render/reveal.js';
|
|
8
|
+
import { TabsContext } from './tabsContext.js';
|
|
9
|
+
/** On the canvas a click on a tab opens it, as on the site, and does not select the block. */
|
|
10
|
+
const CONTROL = { [CANVAS_CONTROL_ATTRIBUTE]: '' };
|
|
11
|
+
/** The panels' box fills the rest of the row when the tabs stand in a column beside it. */
|
|
12
|
+
const PANELS_STYLE = { flex: '1 1 auto', minWidth: 0 };
|
|
13
|
+
/**
|
|
14
|
+
* The tab a key moves to from tab `index` of `count` (WAI-ARIA tabs pattern): the arrow keys of
|
|
15
|
+
* the row's direction step and wrap around, Home and End jump to the ends. Null for other keys.
|
|
16
|
+
*/
|
|
17
|
+
export function tabStep(key, index, count, vertical) {
|
|
18
|
+
if (count <= 0)
|
|
19
|
+
return null;
|
|
20
|
+
if (key === 'Home')
|
|
21
|
+
return 0;
|
|
22
|
+
if (key === 'End')
|
|
23
|
+
return count - 1;
|
|
24
|
+
if (key === (vertical ? 'ArrowDown' : 'ArrowRight'))
|
|
25
|
+
return (index + 1) % count;
|
|
26
|
+
if (key === (vertical ? 'ArrowUp' : 'ArrowLeft'))
|
|
27
|
+
return (index - 1 + count) % count;
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Tabs: a row of tab buttons (`role="tablist"`) made from the tab blocks in the "tabs" slot, and
|
|
32
|
+
* their panels (the tab blocks themselves, see `Tab`). One panel shows at a time; the first one
|
|
33
|
+
* at first. Roving focus: only the open tab is in the Tab order, and the arrow keys move between
|
|
34
|
+
* tabs. On the canvas a click on a tab opens it, and selecting a block opens the tab that holds it.
|
|
35
|
+
*/
|
|
36
|
+
export function Tabs({ block, props, className, attributes, partAttributes, slots, mode, labels }) {
|
|
37
|
+
const root = useRef(null);
|
|
38
|
+
const panels = useRef(null);
|
|
39
|
+
const buttons = useRef([]);
|
|
40
|
+
const [chosen, setChosen] = useState(null);
|
|
41
|
+
const canvas = mode === 'canvas';
|
|
42
|
+
const vertical = props.vertical === true;
|
|
43
|
+
const baseId = useId();
|
|
44
|
+
const tabs = (block.slots?.tabs ?? []).filter((tab) => canvas || !tab.hidden);
|
|
45
|
+
const active = tabs.some((tab) => tab.id === chosen) ? chosen : (tabs[0]?.id ?? null);
|
|
46
|
+
const L = labels ? { ...TABS_LABELS, ...labels } : TABS_LABELS;
|
|
47
|
+
const panelClassName = partAttributes.panel?.className;
|
|
48
|
+
const state = { active, tabId: (id) => `${baseId}tab-${id}`, panelId: (id) => `${baseId}panel-${id}`, panelClassName };
|
|
49
|
+
// Canvas: selecting a block opens the tab whose panel holds it (a panel of this block, not of
|
|
50
|
+
// tabs nested in it).
|
|
51
|
+
useCanvasReveal(root, (target) => {
|
|
52
|
+
for (let el = target; el && el !== root.current; el = el.parentElement) {
|
|
53
|
+
if (el.parentElement === panels.current && el.dataset.tabPanel)
|
|
54
|
+
return setChosen(el.dataset.tabPanel);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const onKeyDown = (event, index) => {
|
|
58
|
+
const to = tabStep(event.key, index, tabs.length, vertical);
|
|
59
|
+
if (to === null)
|
|
60
|
+
return;
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
setChosen(tabs[to].id);
|
|
63
|
+
buttons.current[to]?.focus();
|
|
64
|
+
};
|
|
65
|
+
return (_jsxs("div", { ...attributes, ref: root, className: className, children: [_jsx("div", { role: "tablist", "aria-label": textOr(props.label, '') || undefined, "aria-orientation": vertical ? 'vertical' : undefined, "data-tabs-list": "", className: partAttributes.list?.className, children: tabs.map((tab, i) => {
|
|
66
|
+
const open = tab.id === active;
|
|
67
|
+
return (_createElement("button", { ...CONTROL, key: tab.id, ref: (el) => {
|
|
68
|
+
buttons.current[i] = el;
|
|
69
|
+
}, type: "button", role: "tab", id: state.tabId(tab.id), "aria-selected": open, "aria-controls": state.panelId(tab.id), tabIndex: open ? 0 : -1, className: joinClasses(C.tab, partAttributes.tab?.className), onClick: () => setChosen(tab.id), onKeyDown: (event) => onKeyDown(event, i) }, textOr(tab.props?.label, '') || labelOf(props, L, 'tabLabel', { n: i + 1 })));
|
|
70
|
+
}) }), _jsx("div", { ...partAttributes.tabs, ref: panels, "data-tabs-panels": "", style: PANELS_STYLE, children: _jsx(TabsContext, { value: state, children: slots.tabs }) })] }));
|
|
71
|
+
}
|
|
@@ -1,32 +1,49 @@
|
|
|
1
1
|
import type { BlockComponents } from '../../render/types.js';
|
|
2
|
+
import type { MenuLabels } from '../Menu.js';
|
|
3
|
+
import { type AdjacentLinksLabels } from './AdjacentLinks.js';
|
|
4
|
+
import type { CarouselLabels } from './Carousel.js';
|
|
5
|
+
import { type EmbedLabels } from './Embed.js';
|
|
2
6
|
import { type IconMap } from './Icon.js';
|
|
3
|
-
import {
|
|
7
|
+
import type { PopupLabels } from './Popup.js';
|
|
8
|
+
import { type TableOfContentsLabels } from './TableOfContents.js';
|
|
9
|
+
import type { TabsLabels } from './Tabs.js';
|
|
10
|
+
/**
|
|
11
|
+
* A site's labels, by block type: the text of controls and names for screen readers, used when a
|
|
12
|
+
* block's own label prop is empty. Missing ones stay English. One place for a site's language;
|
|
13
|
+
* a block can still override each label in its **Labels** props.
|
|
14
|
+
*/
|
|
15
|
+
export type BuiltinLabels = {
|
|
16
|
+
carousel?: CarouselLabels;
|
|
17
|
+
popup?: PopupLabels;
|
|
18
|
+
tabs?: TabsLabels;
|
|
19
|
+
tableOfContents?: TableOfContentsLabels;
|
|
20
|
+
adjacentLinks?: AdjacentLinksLabels;
|
|
21
|
+
embed?: EmbedLabels;
|
|
22
|
+
/** The default menu block's labels. With them, the map includes a `menu` component. */
|
|
23
|
+
menu?: MenuLabels;
|
|
24
|
+
};
|
|
4
25
|
export type BuiltinComponentsOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* The site's icons by name, for the `icon` block and the button's `icon` prop. The same names as
|
|
7
|
-
* `builtinBlocks({ icons })` and `defaultBlocks({ icons })`.
|
|
8
|
-
*/
|
|
26
|
+
/** The site's icons by name, for the `icon` block. The same names as `builtinBlocks({ icons })`. */
|
|
9
27
|
icons?: IconMap;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
* `(url) => new URL(url, 'http://x').pathname` serves absolute URLs from the current host.
|
|
13
|
-
*/
|
|
14
|
-
mediaUrl?: MediaUrl;
|
|
28
|
+
/** The site's labels, for example in its language: `{ carousel: { nextLabel: 'Weiter' } }`. */
|
|
29
|
+
labels?: BuiltinLabels;
|
|
15
30
|
};
|
|
16
31
|
/**
|
|
17
32
|
* The components of every built-in block. Merge them into your components map:
|
|
18
|
-
* `{ ...builtinComponents({ icons }), ...yours }`. A key of yours with the same type wins.
|
|
19
|
-
* Components of blocks you did not include are never rendered.
|
|
20
|
-
*
|
|
33
|
+
* `{ ...builtinComponents({ icons, labels }), ...yours }`. A key of yours with the same type wins.
|
|
34
|
+
* Components of blocks you did not include are never rendered. The interactive ones (carousel,
|
|
35
|
+
* popup, tabs, accordion, filter link, menu, inline embed) each load their JavaScript only on pages
|
|
36
|
+
* that render them. Call it once (at module level), not during a render.
|
|
21
37
|
*/
|
|
22
38
|
export declare function builtinComponents(options?: BuiltinComponentsOptions): BlockComponents;
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
39
|
+
export { Accordion, Carousel, FilterLink, Popup, Tab, Tabs } from '../lazy.js';
|
|
40
|
+
export { AdjacentLinks, type AdjacentLinksLabels } from './AdjacentLinks.js';
|
|
41
|
+
export type { CarouselLabels } from './Carousel.js';
|
|
26
42
|
export { Disclosure } from './Disclosure.js';
|
|
27
|
-
export {
|
|
43
|
+
export { Embed, type EmbedLabels } from './Embed.js';
|
|
28
44
|
export { iconComponent, type IconComponent, type IconMap } from './Icon.js';
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
45
|
+
export { Marquee } from './Marquee.js';
|
|
46
|
+
export type { PopupLabels } from './Popup.js';
|
|
31
47
|
export { SectionRef } from './SectionRef.js';
|
|
32
|
-
export { TableOfContents } from './TableOfContents.js';
|
|
48
|
+
export { TableOfContents, type TableOfContentsLabels } from './TableOfContents.js';
|
|
49
|
+
export type { TabsLabels } from './Tabs.js';
|
|
@@ -1,36 +1,70 @@
|
|
|
1
1
|
// Components of the opt-in built-in blocks (`builtinBlocks()` in `payload-canvas/blocks`).
|
|
2
2
|
// Client-safe: the site and the canvas use the same map.
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { createElement } from 'react';
|
|
4
|
+
import { readsClientLinks, readsLinkComponent, withClientLinks, withLinkComponent } from '../../render/marks.js';
|
|
5
|
+
// The interactive blocks load their JavaScript only on pages that render them (see `../lazy`).
|
|
6
|
+
import { Accordion, Carousel, FilterLink, Menu, Popup, Tab, Tabs } from '../lazy.js';
|
|
7
|
+
import { AdjacentLinks } from './AdjacentLinks.js';
|
|
6
8
|
import { Disclosure } from './Disclosure.js';
|
|
7
|
-
import {
|
|
9
|
+
import { Embed } from './Embed.js';
|
|
8
10
|
import { iconComponent } from './Icon.js';
|
|
9
|
-
import {
|
|
10
|
-
import { mediaBackdropComponent } from './MediaBackdrop.js';
|
|
11
|
-
import { SectionRef } from './SectionRef.js';
|
|
11
|
+
import { Marquee } from './Marquee.js';
|
|
12
12
|
import { TableOfContents } from './TableOfContents.js';
|
|
13
|
+
const labelledCache = new WeakMap();
|
|
14
|
+
/** The component with the site's labels bound. One component per labels object, so React keeps the type. */
|
|
15
|
+
function withLabels(component, labels) {
|
|
16
|
+
if (!labels || Object.keys(labels).length === 0)
|
|
17
|
+
return component;
|
|
18
|
+
let byLabels = labelledCache.get(component);
|
|
19
|
+
if (!byLabels)
|
|
20
|
+
labelledCache.set(component, (byLabels = new WeakMap()));
|
|
21
|
+
const known = byLabels.get(labels);
|
|
22
|
+
if (known)
|
|
23
|
+
return known;
|
|
24
|
+
function WithLabels(props) {
|
|
25
|
+
return createElement(component, { ...props, labels });
|
|
26
|
+
}
|
|
27
|
+
if (readsLinkComponent(component))
|
|
28
|
+
withLinkComponent(WithLabels);
|
|
29
|
+
if (readsClientLinks(component))
|
|
30
|
+
withClientLinks(WithLabels);
|
|
31
|
+
byLabels.set(labels, WithLabels);
|
|
32
|
+
return WithLabels;
|
|
33
|
+
}
|
|
13
34
|
/**
|
|
14
35
|
* The components of every built-in block. Merge them into your components map:
|
|
15
|
-
* `{ ...builtinComponents({ icons }), ...yours }`. A key of yours with the same type wins.
|
|
16
|
-
* Components of blocks you did not include are never rendered.
|
|
17
|
-
*
|
|
36
|
+
* `{ ...builtinComponents({ icons, labels }), ...yours }`. A key of yours with the same type wins.
|
|
37
|
+
* Components of blocks you did not include are never rendered. The interactive ones (carousel,
|
|
38
|
+
* popup, tabs, accordion, filter link, menu, inline embed) each load their JavaScript only on pages
|
|
39
|
+
* that render them. Call it once (at module level), not during a render.
|
|
18
40
|
*/
|
|
19
41
|
export function builtinComponents(options = {}) {
|
|
20
|
-
const
|
|
21
|
-
|
|
42
|
+
const labels = options.labels ?? {};
|
|
43
|
+
const components = {
|
|
44
|
+
disclosure: Disclosure,
|
|
45
|
+
accordion: Accordion,
|
|
46
|
+
popup: withLabels(Popup, labels.popup),
|
|
47
|
+
tabs: withLabels(Tabs, labels.tabs),
|
|
48
|
+
tab: Tab,
|
|
49
|
+
carousel: withLabels(Carousel, labels.carousel),
|
|
50
|
+
marquee: Marquee,
|
|
51
|
+
tableOfContents: withLabels(TableOfContents, labels.tableOfContents),
|
|
52
|
+
filterLink: FilterLink,
|
|
53
|
+
adjacentLinks: withLabels(AdjacentLinks, labels.adjacentLinks),
|
|
54
|
+
embed: withLabels(Embed, labels.embed),
|
|
55
|
+
};
|
|
56
|
+
if (options.icons)
|
|
22
57
|
components.icon = iconComponent(options.icons);
|
|
23
|
-
|
|
24
|
-
|
|
58
|
+
// The menu is a default block: it joins the map only when the site gives it labels.
|
|
59
|
+
if (labels.menu && Object.keys(labels.menu).length > 0)
|
|
60
|
+
components.menu = withLabels(withClientLinks(Menu), labels.menu);
|
|
25
61
|
return components;
|
|
26
62
|
}
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export { Carousel } from './Carousel.js';
|
|
63
|
+
export { Accordion, Carousel, FilterLink, Popup, Tab, Tabs } from '../lazy.js';
|
|
64
|
+
export { AdjacentLinks } from './AdjacentLinks.js';
|
|
30
65
|
export { Disclosure } from './Disclosure.js';
|
|
31
|
-
export {
|
|
66
|
+
export { Embed } from './Embed.js';
|
|
32
67
|
export { iconComponent } from './Icon.js';
|
|
33
|
-
export {
|
|
34
|
-
export { MediaBackdrop, mediaBackdropComponent } from './MediaBackdrop.js';
|
|
68
|
+
export { Marquee } from './Marquee.js';
|
|
35
69
|
export { SectionRef } from './SectionRef.js';
|
|
36
70
|
export { TableOfContents } from './TableOfContents.js';
|