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
package/dist/blocks/defaults.js
CHANGED
|
@@ -1,110 +1,50 @@
|
|
|
1
1
|
import { defineBlock } from '../core/blocks.js';
|
|
2
2
|
import { COLLECTION_LIST_BLOCK, FIELD_BLOCK, INDEX_PATH, ITEM_PATH, LIST_EMPTY_SLOT, LIST_ITEM_SLOT, PAGE_PATH, PARENT_PATH, REPEAT_BLOCK } from '../core/bindings.js';
|
|
3
3
|
import { TEXT_LIST_BLOCK, TEXT_LIST_ITEM_BLOCK, TEXT_LIST_SLOT } from '../core/textList.js';
|
|
4
|
-
import {
|
|
4
|
+
import { classesOf, INTERACTIVE, labelField } from './builtins/shared.js';
|
|
5
5
|
import { linkField, when } from './link.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
name: 'icon',
|
|
13
|
-
type: 'select',
|
|
14
|
-
label: 'Icon',
|
|
15
|
-
options: names.map((value) => ({ label: iconLabel(value), value })),
|
|
16
|
-
admin: { description: "Optional. An icon of the site's icon set next to the label. Screen readers skip it." },
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: 'iconPosition',
|
|
20
|
-
type: 'select',
|
|
21
|
-
label: 'Icon position',
|
|
22
|
-
defaultValue: 'end',
|
|
23
|
-
options: [
|
|
24
|
-
{ label: 'Before the label', value: 'start' },
|
|
25
|
-
{ label: 'After the label', value: 'end' },
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'iconClassName',
|
|
30
|
-
type: 'text',
|
|
31
|
-
label: 'Icon classes',
|
|
32
|
-
defaultValue: 'size-4 shrink-0',
|
|
33
|
-
admin: { description: 'Tailwind classes of the icon, for example "size-5".', custom: { builderClasses: true } },
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
}
|
|
6
|
+
import { FIELD_CLASS_MAP } from './client/field.js';
|
|
7
|
+
import { MENU_CLASS_MAP, MENU_LABELS } from './client/menu.js';
|
|
8
|
+
// The class maps and labels the components use live in leaf modules (no block definitions), so
|
|
9
|
+
// client components can import them alone.
|
|
10
|
+
export { FIELD_CLASS_MAP, MENU_CLASS_MAP, MENU_LABELS };
|
|
37
11
|
/** Block types a Link block may hold directly: content without its own links or controls. */
|
|
38
|
-
const LINK_CONTENT = ['stack', 'grid', 'heading', 'text', 'image', 'list', '
|
|
12
|
+
const LINK_CONTENT = ['stack', 'grid', 'heading', 'text', 'image', 'list', 'divider', 'field'];
|
|
13
|
+
/** The HTML tags a stack can render as (the Container component accepts the same list). */
|
|
14
|
+
const STACK_TAGS = ['div', 'section', 'header', 'footer', 'main', 'nav', 'article', 'aside', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'figure', 'figcaption'];
|
|
15
|
+
const MENU_CLASSES = [...classesOf(MENU_CLASS_MAP), 'group'];
|
|
16
|
+
const FIELD_CLASSES = classesOf(FIELD_CLASS_MAP);
|
|
39
17
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
18
|
+
* The `collection` field of the collection list and repeat blocks: a select of `slugs`, or a text
|
|
19
|
+
* field when there are none. The plugin's `listCollectionsOf` uses it too.
|
|
42
20
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
21
|
+
export function listCollectionField(slugs, args) {
|
|
22
|
+
// A setting, not content: content mode (core/contentMode.ts) does not offer it.
|
|
23
|
+
const admin = { admin: { ...(args.description ? { description: args.description } : {}), custom: { builderContent: false } } };
|
|
24
|
+
const required = args.required ? { required: true } : {};
|
|
25
|
+
return slugs && slugs.length > 0
|
|
26
|
+
? { name: 'collection', type: 'select', label: args.label, options: [...slugs], ...required, ...admin }
|
|
27
|
+
: { name: 'collection', type: 'text', label: args.label, ...required, ...admin };
|
|
28
|
+
}
|
|
29
|
+
const PICKED_HELP = 'Shows only these, in this order.';
|
|
30
|
+
/** The collection list's picked documents: a relationship to `slugs`, or ids as text when there are none. */
|
|
31
|
+
export function pickedDocumentsField(slugs) {
|
|
32
|
+
if (!slugs || slugs.length === 0) {
|
|
33
|
+
return { name: 'ids', type: 'text', label: 'Only these ids', hasMany: true, admin: { description: PICKED_HELP, custom: { builderContent: false } } };
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
name: 'ids',
|
|
37
|
+
type: 'relationship',
|
|
38
|
+
label: 'Only these documents',
|
|
39
|
+
// The slugs come from the app, so they cannot match Payload's generated slug type.
|
|
40
|
+
relationTo: (slugs.length === 1 ? slugs[0] : [...slugs]),
|
|
41
|
+
hasMany: true,
|
|
42
|
+
admin: { description: PICKED_HELP },
|
|
43
|
+
};
|
|
51
44
|
}
|
|
52
45
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* the generated CSS only styles elements with that class. Keep in sync with `Menu.tsx` in
|
|
56
|
-
* `payload-canvas/react`.
|
|
57
|
-
*/
|
|
58
|
-
export const MENU_CLASS_MAP = withMarker({
|
|
59
|
-
/** The inline list: its items become children of the <nav>, so the block's className lays them out. */
|
|
60
|
-
list: { md: 'hidden md:contents', lg: 'hidden lg:contents', never: 'contents' },
|
|
61
|
-
toggleWrap: { md: 'md:hidden', lg: 'lg:hidden' },
|
|
62
|
-
link: 'inline-flex items-center py-2 opacity-75 transition-opacity hover:opacity-100 ' +
|
|
63
|
-
'aria-[current=page]:opacity-100 aria-[current=page]:underline decoration-1 underline-offset-8',
|
|
64
|
-
toggle: 'flex min-h-11 min-w-11 cursor-pointer list-none items-center justify-center gap-2 rounded-md px-2 -mr-2 ' +
|
|
65
|
-
'[&::-webkit-details-marker]:hidden',
|
|
66
|
-
iconOpen: 'size-5 group-open:hidden',
|
|
67
|
-
iconClose: 'hidden size-5 group-open:block',
|
|
68
|
-
panel: 'absolute inset-x-0 top-full z-50 border-y border-border bg-background px-5 pt-2 pb-6 text-foreground ' +
|
|
69
|
-
'shadow-md',
|
|
70
|
-
panelList: 'flex flex-col',
|
|
71
|
-
panelLink: 'flex min-h-12 items-center border-b border-border py-3 text-lg ' +
|
|
72
|
-
'aria-[current=page]:font-semibold aria-[current=page]:underline decoration-1 underline-offset-8',
|
|
73
|
-
/** A link with children (one level): a <details> dropdown next to, or in place of, the link. */
|
|
74
|
-
submenu: 'relative flex items-center gap-1',
|
|
75
|
-
submenuDetails: 'group/submenu',
|
|
76
|
-
submenuToggle: 'inline-flex cursor-pointer list-none items-center gap-1 py-2 opacity-75 transition-opacity hover:opacity-100 ' +
|
|
77
|
-
'aria-[current=true]:opacity-100 [&::-webkit-details-marker]:hidden',
|
|
78
|
-
submenuIcon: 'size-4 transition-transform group-open/submenu:rotate-180 motion-reduce:transition-none',
|
|
79
|
-
submenuList: 'absolute top-full left-0 z-50 flex min-w-48 flex-col border border-border bg-background p-2 text-foreground shadow-md',
|
|
80
|
-
submenuLink: 'flex min-h-10 items-center px-3 py-2 opacity-75 transition-opacity hover:opacity-100 ' +
|
|
81
|
-
'aria-[current=page]:opacity-100 aria-[current=page]:underline decoration-1 underline-offset-8',
|
|
82
|
-
/** The children of a link in the small-screen panel: a nested list. */
|
|
83
|
-
panelSubList: 'flex flex-col pl-4',
|
|
84
|
-
panelSubLink: 'flex min-h-11 items-center py-2 text-base ' +
|
|
85
|
-
'aria-[current=page]:font-semibold aria-[current=page]:underline decoration-1 underline-offset-8',
|
|
86
|
-
/** The optional button after the links in the panel. */
|
|
87
|
-
panelCta: 'mt-5 flex min-h-12 items-center justify-center rounded-full bg-primary px-6 text-base font-medium ' +
|
|
88
|
-
'text-primary-foreground transition-colors hover:bg-[color-mix(in_oklch,var(--color-primary),black_14%)]',
|
|
89
|
-
});
|
|
90
|
-
/**
|
|
91
|
-
* Classes the field component adds to rich text that has no `prose` class of its own (see `Field.tsx`),
|
|
92
|
-
* so a post body looks right by default. Listed in the field block's `classes`.
|
|
93
|
-
*/
|
|
94
|
-
export const FIELD_CLASS_MAP = withMarker({ richText: 'prose max-w-none' });
|
|
95
|
-
const MENU_CLASSES = [
|
|
96
|
-
...new Set(Object.values(MENU_CLASS_MAP)
|
|
97
|
-
.flatMap((value) => (typeof value === 'string' ? [value] : Object.values(value)))
|
|
98
|
-
.flatMap((value) => value.split(' '))
|
|
99
|
-
.filter((cls) => cls !== BUILDER_CSS_CLASS)),
|
|
100
|
-
'group',
|
|
101
|
-
];
|
|
102
|
-
const FIELD_CLASSES = Object.values(FIELD_CLASS_MAP)
|
|
103
|
-
.flatMap((value) => value.split(' '))
|
|
104
|
-
.filter((cls) => cls !== BUILDER_CSS_CLASS);
|
|
105
|
-
/**
|
|
106
|
-
* The built-in blocks: stack, grid, heading, text, richText, image, button, link, menu, list (with
|
|
107
|
-
* its listItem blocks), quote, divider, spacer, video, and the dynamic blocks field, collectionList and repeat.
|
|
46
|
+
* The default blocks: stack, grid, heading, text, richText, image, button, link, menu, list (with
|
|
47
|
+
* its listItem blocks), divider, video, and the dynamic blocks field, collectionList and repeat.
|
|
108
48
|
*/
|
|
109
49
|
export function defaultBlocks(options) {
|
|
110
50
|
const mediaCollection = (options?.mediaCollection ?? 'media');
|
|
@@ -115,37 +55,18 @@ export function defaultBlocks(options) {
|
|
|
115
55
|
const stack = defineBlock({
|
|
116
56
|
type: 'stack',
|
|
117
57
|
label: 'Stack',
|
|
58
|
+
description: 'A box that holds blocks in a column or a row.',
|
|
118
59
|
icon: 'stack',
|
|
119
60
|
category: 'Layout',
|
|
120
61
|
fields: [
|
|
121
62
|
{
|
|
122
63
|
name: 'as',
|
|
123
64
|
type: 'select',
|
|
124
|
-
label: '
|
|
125
|
-
options: [
|
|
126
|
-
{ label: 'Plain group (div)', value: 'div' },
|
|
127
|
-
{ label: 'Page section (section)', value: 'section' },
|
|
128
|
-
{ label: 'Site header (header)', value: 'header' },
|
|
129
|
-
{ label: 'Site footer (footer)', value: 'footer' },
|
|
130
|
-
{ label: 'Main content (main)', value: 'main' },
|
|
131
|
-
{ label: 'Navigation (nav)', value: 'nav' },
|
|
132
|
-
{ label: 'Article or post (article)', value: 'article' },
|
|
133
|
-
{ label: 'Side note (aside)', value: 'aside' },
|
|
134
|
-
{ label: 'Numbered list (ol)', value: 'ol' },
|
|
135
|
-
{ label: 'Bullet list (ul)', value: 'ul' },
|
|
136
|
-
{ label: 'List item (li)', value: 'li' },
|
|
137
|
-
{ label: 'Term list (dl)', value: 'dl' },
|
|
138
|
-
{ label: 'Term (dt)', value: 'dt' },
|
|
139
|
-
{ label: 'Term description (dd)', value: 'dd' },
|
|
140
|
-
{ label: 'Figure (figure)', value: 'figure' },
|
|
141
|
-
{ label: 'Figure caption (figcaption)', value: 'figcaption' },
|
|
142
|
-
{ label: 'Paragraph (p)', value: 'p' },
|
|
143
|
-
{ label: 'Inline group (span)', value: 'span' },
|
|
144
|
-
],
|
|
65
|
+
label: 'Tag',
|
|
66
|
+
options: [...STACK_TAGS],
|
|
145
67
|
defaultValue: 'div',
|
|
146
|
-
|
|
147
|
-
description: '
|
|
148
|
-
'Use "Page section" for each section of a page.',
|
|
68
|
+
custom: {
|
|
69
|
+
ai: { description: 'The HTML tag. It does not change the look; screen readers and search engines use it. Use "section" for each section of a page.' },
|
|
149
70
|
},
|
|
150
71
|
},
|
|
151
72
|
],
|
|
@@ -154,7 +75,7 @@ export function defaultBlocks(options) {
|
|
|
154
75
|
ai: {
|
|
155
76
|
description: 'A container that lays out its children in a column (or a row with "flex-row"). ' +
|
|
156
77
|
'Use it to group blocks and build sections. Set "as" to "section", "header", "footer" and so on for semantic HTML; ' +
|
|
157
|
-
'"ol"/"ul" with "li" children for lists, "dl" with "dt"/"dd" for term lists, "figure" with "figcaption"
|
|
78
|
+
'"ol"/"ul" with "li" children for lists, "dl" with "dt"/"dd" for term lists, "figure" with "figcaption".',
|
|
158
79
|
example: {
|
|
159
80
|
type: 'stack',
|
|
160
81
|
props: { as: 'section' },
|
|
@@ -171,6 +92,7 @@ export function defaultBlocks(options) {
|
|
|
171
92
|
const grid = defineBlock({
|
|
172
93
|
type: 'grid',
|
|
173
94
|
label: 'Grid',
|
|
95
|
+
description: 'Places blocks in columns and rows.',
|
|
174
96
|
icon: 'grid',
|
|
175
97
|
category: 'Layout',
|
|
176
98
|
fields: [],
|
|
@@ -195,6 +117,7 @@ export function defaultBlocks(options) {
|
|
|
195
117
|
const heading = defineBlock({
|
|
196
118
|
type: 'heading',
|
|
197
119
|
label: 'Heading',
|
|
120
|
+
description: 'A title for a page or a section.',
|
|
198
121
|
icon: 'heading',
|
|
199
122
|
category: 'Content',
|
|
200
123
|
fields: [
|
|
@@ -203,30 +126,15 @@ export function defaultBlocks(options) {
|
|
|
203
126
|
{
|
|
204
127
|
name: 'level',
|
|
205
128
|
type: 'select',
|
|
206
|
-
label: '
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
{ label: 'Heading 2 – section', value: '2' },
|
|
210
|
-
{ label: 'Heading 3 – part of a section', value: '3' },
|
|
211
|
-
{ label: 'Heading 4', value: '4' },
|
|
212
|
-
{ label: 'Heading 5', value: '5' },
|
|
213
|
-
{ label: 'Heading 6', value: '6' },
|
|
214
|
-
],
|
|
129
|
+
label: 'Tag',
|
|
130
|
+
// The value is the level only ("2"); the label is the tag.
|
|
131
|
+
options: ['1', '2', '3', '4', '5', '6'].map((value) => ({ label: `h${value}`, value })),
|
|
215
132
|
defaultValue: '2',
|
|
216
|
-
|
|
217
|
-
description: '
|
|
218
|
-
'Heading 2 for each section, and Heading 3 inside a section.',
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
name: 'accent',
|
|
223
|
-
type: 'text',
|
|
224
|
-
label: 'Accent words',
|
|
225
|
-
localized: true,
|
|
226
|
-
admin: {
|
|
227
|
-
description: 'Words of the heading to highlight, for example "Brisbane". They render as <em>; style them with classes like [&_em]:text-primary.',
|
|
133
|
+
custom: {
|
|
134
|
+
ai: { description: 'The level in the page outline, not the size: "1" once per page, "2" for sections, "3" inside a section.' },
|
|
228
135
|
},
|
|
229
136
|
},
|
|
137
|
+
{ name: 'accent', type: 'text', label: 'Highlighted words', localized: true },
|
|
230
138
|
],
|
|
231
139
|
// `break-words`: a long word (a URL, a product code) wraps instead of widening the page.
|
|
232
140
|
defaultClassName: 'text-3xl font-bold break-words',
|
|
@@ -239,6 +147,7 @@ export function defaultBlocks(options) {
|
|
|
239
147
|
const text = defineBlock({
|
|
240
148
|
type: 'text',
|
|
241
149
|
label: 'Text',
|
|
150
|
+
description: 'A paragraph of plain text.',
|
|
242
151
|
icon: 'text',
|
|
243
152
|
category: 'Content',
|
|
244
153
|
fields: [{ name: 'text', type: 'textarea', label: 'Text', required: true, localized: true }],
|
|
@@ -251,22 +160,17 @@ export function defaultBlocks(options) {
|
|
|
251
160
|
const richText = defineBlock({
|
|
252
161
|
type: 'richText',
|
|
253
162
|
label: 'Rich text',
|
|
163
|
+
description: 'Text with headings, links, lists and quotes.',
|
|
254
164
|
icon: 'richText',
|
|
255
165
|
category: 'Content',
|
|
256
166
|
fields: [
|
|
257
167
|
{ name: 'content', type: 'richText', label: 'Content', required: true, localized: true },
|
|
258
|
-
{
|
|
259
|
-
name: 'headingIds',
|
|
260
|
-
type: 'checkbox',
|
|
261
|
-
label: 'Heading ids',
|
|
262
|
-
admin: { description: 'Each heading gets an id from its text, so a table of contents can link to it ("#prices").' },
|
|
263
|
-
},
|
|
264
168
|
],
|
|
265
169
|
defaultClassName: 'prose',
|
|
266
170
|
ai: {
|
|
267
171
|
description: 'Formatted text (Lexical JSON): paragraphs, headings, bold and italic, links and lists. ' +
|
|
268
|
-
'Use it for articles and longer copy. The "prose" class styles the content.
|
|
269
|
-
'
|
|
172
|
+
'Use it for articles and longer copy. The "prose" class styles the content. Each heading gets an id ' +
|
|
173
|
+
'from its text (e.g. "Our prices" -> "our-prices"; repeats get "-2"), for "#id" links and the tableOfContents block.',
|
|
270
174
|
example: {
|
|
271
175
|
type: 'richText',
|
|
272
176
|
className: 'prose',
|
|
@@ -303,6 +207,7 @@ export function defaultBlocks(options) {
|
|
|
303
207
|
const image = defineBlock({
|
|
304
208
|
type: 'image',
|
|
305
209
|
label: 'Image',
|
|
210
|
+
description: 'A picture from the media library.',
|
|
306
211
|
icon: 'image',
|
|
307
212
|
category: 'Media',
|
|
308
213
|
fields: [
|
|
@@ -314,20 +219,11 @@ export function defaultBlocks(options) {
|
|
|
314
219
|
type: 'text',
|
|
315
220
|
label: 'Alt text',
|
|
316
221
|
localized: true,
|
|
317
|
-
admin: {
|
|
318
|
-
|
|
319
|
-
{
|
|
320
|
-
name: 'priority',
|
|
321
|
-
type: 'checkbox',
|
|
322
|
-
label: 'Load first',
|
|
323
|
-
admin: { description: 'For the main image at the top of the page: it loads at once with high priority instead of lazily.' },
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
name: 'sizes',
|
|
327
|
-
type: 'text',
|
|
328
|
-
label: 'Sizes',
|
|
329
|
-
admin: { description: 'The width the image shows at, for the browser to pick a file, for example "(min-width: 768px) 50vw, 100vw". Empty: the full width.' },
|
|
222
|
+
admin: { placeholder: 'From the image' },
|
|
223
|
+
custom: { ai: { description: 'Empty: the alt text saved with the image.' } },
|
|
330
224
|
},
|
|
225
|
+
{ name: 'priority', type: 'checkbox', label: 'Load first', admin: { description: 'For the main image at the top.' } },
|
|
226
|
+
{ name: 'sizes', type: 'text', label: 'Sizes', admin: { placeholder: '100vw', custom: { builderContent: false } } },
|
|
331
227
|
],
|
|
332
228
|
ai: {
|
|
333
229
|
description: `An image from the "${mediaCollection}" collection, stored by its document ID. ` +
|
|
@@ -337,26 +233,21 @@ export function defaultBlocks(options) {
|
|
|
337
233
|
example: { type: 'image', props: { image: 1, alt: 'Team photo' }, className: 'w-full rounded-lg' },
|
|
338
234
|
},
|
|
339
235
|
});
|
|
340
|
-
const icons = options?.icons ?? [];
|
|
341
236
|
const button = defineBlock({
|
|
342
237
|
type: 'button',
|
|
343
238
|
label: 'Button',
|
|
239
|
+
description: 'A button that links to a page or a URL.',
|
|
344
240
|
icon: 'button',
|
|
345
241
|
category: 'Interactive',
|
|
346
242
|
fields: [
|
|
347
243
|
{ name: 'label', type: 'text', label: 'Label', required: true, localized: true },
|
|
348
244
|
linkField({ collections: linkCollections }),
|
|
349
|
-
...(icons.length > 0 ? buttonIconFields(icons) : []),
|
|
350
245
|
],
|
|
351
|
-
defaultClassName: 'inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground'
|
|
352
|
-
(icons.length > 0 ? ' gap-2' : ''),
|
|
246
|
+
defaultClassName: 'inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground',
|
|
353
247
|
ai: {
|
|
354
248
|
description: 'A call-to-action button. "link.type" is "url" (set "link.url") or "reference" (set "link.reference" to ' +
|
|
355
|
-
'{ relationTo, value }). Without a link it renders as plain text.' +
|
|
356
|
-
|
|
357
|
-
? ` Optional "icon" (one of: ${icons.join(', ')}) shows an icon before ("iconPosition": "start") or after ` +
|
|
358
|
-
'("end", the default) the label; "iconClassName" sizes it (default "size-4 shrink-0").'
|
|
359
|
-
: ''),
|
|
249
|
+
'{ relationTo, value }). Without a link it renders as plain text. For a button with an icon, use a link block ' +
|
|
250
|
+
'that holds a text block and an icon block.',
|
|
360
251
|
example: {
|
|
361
252
|
type: 'button',
|
|
362
253
|
props: { label: 'Contact us', link: exampleLink },
|
|
@@ -367,6 +258,7 @@ export function defaultBlocks(options) {
|
|
|
367
258
|
const link = defineBlock({
|
|
368
259
|
type: 'link',
|
|
369
260
|
label: 'Link',
|
|
261
|
+
description: 'Makes all the blocks inside it one link.',
|
|
370
262
|
icon: 'link',
|
|
371
263
|
category: 'Interactive',
|
|
372
264
|
fields: [linkField({ collections: linkCollections })],
|
|
@@ -395,6 +287,7 @@ export function defaultBlocks(options) {
|
|
|
395
287
|
const menu = defineBlock({
|
|
396
288
|
type: 'menu',
|
|
397
289
|
label: 'Menu',
|
|
290
|
+
description: 'Navigation links for a header or a footer.',
|
|
398
291
|
icon: 'menu',
|
|
399
292
|
category: 'Interactive',
|
|
400
293
|
fields: [
|
|
@@ -410,10 +303,6 @@ export function defaultBlocks(options) {
|
|
|
410
303
|
name: 'children',
|
|
411
304
|
type: 'array',
|
|
412
305
|
label: 'Dropdown links',
|
|
413
|
-
admin: {
|
|
414
|
-
description: 'Optional. Links under this one (one level), shown in a dropdown. The link above is optional when it has ' +
|
|
415
|
-
'dropdown links: without it the label opens the dropdown.',
|
|
416
|
-
},
|
|
417
306
|
fields: [
|
|
418
307
|
{ name: 'label', type: 'text', label: 'Label', required: true, localized: true },
|
|
419
308
|
linkField({ collections: linkCollections }),
|
|
@@ -421,57 +310,30 @@ export function defaultBlocks(options) {
|
|
|
421
310
|
},
|
|
422
311
|
],
|
|
423
312
|
},
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
label: 'Menu name',
|
|
428
|
-
defaultValue: 'Main',
|
|
429
|
-
localized: true,
|
|
430
|
-
admin: { description: 'Read by screen readers, for example "Main" or "Footer".' },
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
name: 'toggleLabel',
|
|
434
|
-
type: 'text',
|
|
435
|
-
label: 'Menu button text',
|
|
436
|
-
defaultValue: 'Menu',
|
|
437
|
-
localized: true,
|
|
438
|
-
admin: { description: 'The text of the button that opens the links on small screens.' },
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
name: 'submenuLabel',
|
|
442
|
-
type: 'text',
|
|
443
|
-
label: 'Dropdown button name',
|
|
444
|
-
defaultValue: '{label} menu',
|
|
445
|
-
localized: true,
|
|
446
|
-
admin: {
|
|
447
|
-
description: 'Read by screen readers on the small arrow button next to a link with dropdown links. {label} is the link label.',
|
|
448
|
-
},
|
|
449
|
-
},
|
|
313
|
+
labelField('label', MENU_LABELS.label, 'Menu name'),
|
|
314
|
+
labelField('toggleLabel', MENU_LABELS.toggleLabel, 'Menu button text'),
|
|
315
|
+
labelField('submenuLabel', MENU_LABELS.submenuLabel, 'Dropdown button name'),
|
|
450
316
|
{
|
|
451
317
|
name: 'collapse',
|
|
452
318
|
type: 'select',
|
|
453
|
-
label: '
|
|
319
|
+
label: 'Menu button',
|
|
454
320
|
options: [
|
|
455
|
-
{ label: '
|
|
456
|
-
{ label: '
|
|
457
|
-
{ label: '
|
|
321
|
+
{ label: 'Below tablet width', value: 'md' },
|
|
322
|
+
{ label: 'Below laptop width', value: 'lg' },
|
|
323
|
+
{ label: 'Never', value: 'never' },
|
|
458
324
|
],
|
|
459
325
|
defaultValue: 'md',
|
|
460
|
-
admin: { description: 'On small screens the links fold into a "Menu" button with a panel.' },
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
name: 'ctaLabel',
|
|
464
|
-
type: 'text',
|
|
465
|
-
label: 'Panel button text',
|
|
466
|
-
localized: true,
|
|
467
|
-
admin: {
|
|
468
|
-
description: 'Optional. A button as the last row of the small-screen panel, for example the call to action the header ' +
|
|
469
|
-
'shows only on wide screens. Needs a link below. Not shown when the links are always visible.',
|
|
470
|
-
},
|
|
471
326
|
},
|
|
327
|
+
{ name: 'ctaLabel', type: 'text', label: 'Panel button text', localized: true },
|
|
472
328
|
linkField({ name: 'cta', label: 'Panel button link', collections: linkCollections }),
|
|
473
329
|
],
|
|
474
330
|
defaultClassName: 'flex flex-row items-center gap-6 text-sm font-medium',
|
|
331
|
+
parts: {
|
|
332
|
+
link: { label: 'Links' },
|
|
333
|
+
submenu: { label: 'Dropdowns' },
|
|
334
|
+
submenuLink: { label: 'Dropdown links' },
|
|
335
|
+
panel: { label: 'Small-screen panel' },
|
|
336
|
+
},
|
|
475
337
|
classes: MENU_CLASSES,
|
|
476
338
|
ai: {
|
|
477
339
|
description: 'Site navigation: a <nav> with a list of links. The link to the current page is marked. ' +
|
|
@@ -481,7 +343,9 @@ export function defaultBlocks(options) {
|
|
|
481
343
|
'Optional "ctaLabel" and "cta" (a link) add a button as the last row of the small-screen panel. "toggleLabel" is the text of the menu button (default "Menu"; translate it per locale). ' +
|
|
482
344
|
'An item may have "children" (one level of { label, link }): a dropdown. With its own link the item shows the link and a ' +
|
|
483
345
|
'small arrow button that opens the dropdown ("submenuLabel" names that button, default "{label} menu"); without a link the ' +
|
|
484
|
-
'label itself opens it. On small screens the children show as a nested list in the panel.'
|
|
346
|
+
'label itself opens it. On small screens the children show as a nested list in the panel. ' +
|
|
347
|
+
'Style the inner elements with "partClassName": "link" (each link of the inline list), "submenu" (the dropdown box), ' +
|
|
348
|
+
'"submenuLink" (each dropdown link), "panel" (the small-screen panel). They add to the classes the menu sets itself.',
|
|
485
349
|
example: {
|
|
486
350
|
type: 'menu',
|
|
487
351
|
props: {
|
|
@@ -492,8 +356,8 @@ export function defaultBlocks(options) {
|
|
|
492
356
|
{
|
|
493
357
|
label: 'Services',
|
|
494
358
|
children: [
|
|
495
|
-
{ label: '
|
|
496
|
-
{ label: '
|
|
359
|
+
{ label: 'Web design', link: { type: 'url', url: '/services/web-design' } },
|
|
360
|
+
{ label: 'Hosting', link: { type: 'url', url: '/services/hosting' } },
|
|
497
361
|
],
|
|
498
362
|
},
|
|
499
363
|
{ label: 'Contact', link: { type: 'url', url: '/contact' } },
|
|
@@ -506,6 +370,7 @@ export function defaultBlocks(options) {
|
|
|
506
370
|
const list = defineBlock({
|
|
507
371
|
type: TEXT_LIST_BLOCK,
|
|
508
372
|
label: 'List',
|
|
373
|
+
description: 'A bulleted or numbered list.',
|
|
509
374
|
icon: 'list',
|
|
510
375
|
category: 'Content',
|
|
511
376
|
fields: [{ name: 'ordered', type: 'checkbox', label: 'Numbered list' }],
|
|
@@ -531,18 +396,10 @@ export function defaultBlocks(options) {
|
|
|
531
396
|
const listItem = defineBlock({
|
|
532
397
|
type: TEXT_LIST_ITEM_BLOCK,
|
|
533
398
|
label: 'List item',
|
|
399
|
+
description: 'One item of a list.',
|
|
534
400
|
icon: 'text',
|
|
535
401
|
category: 'Content',
|
|
536
|
-
fields: [
|
|
537
|
-
{ name: 'text', type: 'text', label: 'Text', required: true, localized: true },
|
|
538
|
-
{
|
|
539
|
-
...itemLink,
|
|
540
|
-
admin: {
|
|
541
|
-
...itemLink.admin,
|
|
542
|
-
description: 'Optional. The item text becomes a link. Leave it empty in a list inside a Link block: a link cannot hold another link.',
|
|
543
|
-
},
|
|
544
|
-
},
|
|
545
|
-
],
|
|
402
|
+
fields: [{ name: 'text', type: 'text', label: 'Text', required: true, localized: true }, itemLink],
|
|
546
403
|
parents: [TEXT_LIST_BLOCK],
|
|
547
404
|
ai: {
|
|
548
405
|
description: `One item (<li>) of a "${TEXT_LIST_BLOCK}" block. It goes only in a list's "${TEXT_LIST_SLOT}" slot. ` +
|
|
@@ -551,28 +408,10 @@ export function defaultBlocks(options) {
|
|
|
551
408
|
example: { type: TEXT_LIST_ITEM_BLOCK, props: { text: 'Pricing', link: exampleLink } },
|
|
552
409
|
},
|
|
553
410
|
});
|
|
554
|
-
const quote = defineBlock({
|
|
555
|
-
type: 'quote',
|
|
556
|
-
label: 'Quote',
|
|
557
|
-
icon: 'quote',
|
|
558
|
-
category: 'Content',
|
|
559
|
-
fields: [
|
|
560
|
-
{ name: 'quote', type: 'textarea', label: 'Quote', required: true, localized: true },
|
|
561
|
-
{ name: 'cite', type: 'text', label: 'Source', localized: true, admin: { description: 'Who said it, for example "Jane Doe, CEO".' } },
|
|
562
|
-
],
|
|
563
|
-
defaultClassName: 'border-l-4 pl-4 italic',
|
|
564
|
-
ai: {
|
|
565
|
-
description: 'A quotation or testimonial, with an optional source.',
|
|
566
|
-
example: {
|
|
567
|
-
type: 'quote',
|
|
568
|
-
props: { quote: 'They rebuilt our site in a week.', cite: 'Jane Doe, Acme' },
|
|
569
|
-
className: 'border-l-4 pl-4 italic',
|
|
570
|
-
},
|
|
571
|
-
},
|
|
572
|
-
});
|
|
573
411
|
const divider = defineBlock({
|
|
574
412
|
type: 'divider',
|
|
575
413
|
label: 'Divider',
|
|
414
|
+
description: 'A line between parts of a page.',
|
|
576
415
|
icon: 'divider',
|
|
577
416
|
category: 'Layout',
|
|
578
417
|
fields: [],
|
|
@@ -582,21 +421,10 @@ export function defaultBlocks(options) {
|
|
|
582
421
|
example: { type: 'divider', className: 'my-8 border-t' },
|
|
583
422
|
},
|
|
584
423
|
});
|
|
585
|
-
const spacer = defineBlock({
|
|
586
|
-
type: 'spacer',
|
|
587
|
-
label: 'Spacer',
|
|
588
|
-
icon: 'spacer',
|
|
589
|
-
category: 'Layout',
|
|
590
|
-
fields: [],
|
|
591
|
-
defaultClassName: 'h-8',
|
|
592
|
-
ai: {
|
|
593
|
-
description: 'Empty vertical space. Set the height with a class such as "h-16". Prefer gap and padding classes.',
|
|
594
|
-
example: { type: 'spacer', className: 'h-16' },
|
|
595
|
-
},
|
|
596
|
-
});
|
|
597
424
|
const video = defineBlock({
|
|
598
425
|
type: 'video',
|
|
599
426
|
label: 'Video',
|
|
427
|
+
description: 'A video from an upload, YouTube or Vimeo.',
|
|
600
428
|
icon: 'video',
|
|
601
429
|
category: 'Media',
|
|
602
430
|
fields: [
|
|
@@ -606,7 +434,7 @@ export function defaultBlocks(options) {
|
|
|
606
434
|
label: 'Source',
|
|
607
435
|
options: [
|
|
608
436
|
{ label: 'Upload', value: 'upload' },
|
|
609
|
-
{ label: '
|
|
437
|
+
{ label: 'Link', value: 'url' },
|
|
610
438
|
],
|
|
611
439
|
defaultValue: 'upload',
|
|
612
440
|
},
|
|
@@ -614,15 +442,16 @@ export function defaultBlocks(options) {
|
|
|
614
442
|
{
|
|
615
443
|
name: 'url',
|
|
616
444
|
type: 'text',
|
|
617
|
-
label: '
|
|
445
|
+
label: 'Video link',
|
|
618
446
|
admin: {
|
|
619
|
-
|
|
447
|
+
placeholder: 'YouTube, Vimeo or a video file',
|
|
620
448
|
// Format `videoUrl` (core/formats.ts): the inspector shows the message, publishing needs a good link.
|
|
621
449
|
custom: { ...when('source', 'url').custom, builderFormat: 'videoUrl' },
|
|
622
450
|
},
|
|
451
|
+
custom: { ai: { description: 'A YouTube or Vimeo link, or a direct link to a video file.' } },
|
|
623
452
|
},
|
|
624
453
|
{ name: 'poster', type: 'upload', label: 'Poster image', relationTo: mediaCollection },
|
|
625
|
-
{ name: 'autoplay', type: 'checkbox', label: 'Autoplay', admin: { description: '
|
|
454
|
+
{ name: 'autoplay', type: 'checkbox', label: 'Autoplay', admin: { description: 'Works only when muted.' } },
|
|
626
455
|
{ name: 'loop', type: 'checkbox', label: 'Loop' },
|
|
627
456
|
{ name: 'muted', type: 'checkbox', label: 'Muted' },
|
|
628
457
|
{ name: 'controls', type: 'checkbox', label: 'Show controls', defaultValue: true },
|
|
@@ -641,47 +470,22 @@ export function defaultBlocks(options) {
|
|
|
641
470
|
const field = defineBlock({
|
|
642
471
|
type: FIELD_BLOCK,
|
|
643
472
|
label: 'Field',
|
|
473
|
+
description: 'Shows one field of the page or of each list item.',
|
|
644
474
|
icon: 'field',
|
|
645
475
|
category: 'Dynamic',
|
|
646
476
|
fields: [
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
label: 'Field',
|
|
651
|
-
required: true,
|
|
652
|
-
admin: { description: 'The name of the field to show, for example "content" or "featuredImage". For a field inside another, join the names with a dot: "author.name".' },
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
name: 'fallback',
|
|
656
|
-
type: 'text',
|
|
657
|
-
label: 'Fallback',
|
|
658
|
-
localized: true,
|
|
659
|
-
admin: { description: 'Shown when this field is empty.' },
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
name: 'format',
|
|
663
|
-
type: 'text',
|
|
664
|
-
label: 'Format',
|
|
665
|
-
admin: {
|
|
666
|
-
description: 'For a number, date or text: "currency:AUD" ($1,200), "number" (1,200), "date:en-AU:Australia/Brisbane" ' +
|
|
667
|
-
'(a date in that language and time zone) or "firstSentence". Empty: the value as it is.',
|
|
668
|
-
},
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
name: 'headingIds',
|
|
672
|
-
type: 'checkbox',
|
|
673
|
-
label: 'Heading ids',
|
|
674
|
-
admin: { description: 'For rich text: each heading gets an id from its text, so a table of contents can link to it ("#prices").' },
|
|
675
|
-
},
|
|
477
|
+
// The inspector shows the field picker and the format of the bindings UI (templates/Bindable).
|
|
478
|
+
{ name: 'path', type: 'text', label: 'Field', required: true, admin: { custom: { builderContent: false } } },
|
|
479
|
+
{ name: 'fallback', type: 'text', label: 'Text when empty', localized: true },
|
|
676
480
|
],
|
|
677
481
|
classes: FIELD_CLASSES,
|
|
678
482
|
ai: {
|
|
679
483
|
description: 'Shows one field of the current document in a template, rendered by its value: rich text as formatted ' +
|
|
680
484
|
'text, an upload as an image, a date as a formatted date, a relationship as its title, text as text. ' +
|
|
681
485
|
'"path" is a dot path from getBindingSources (e.g. "content", "author.name"). Only works in templates ' +
|
|
682
|
-
'and inside a collection list item. "
|
|
683
|
-
'"
|
|
684
|
-
'
|
|
486
|
+
'and inside a collection list item. "path" takes binding formatters after a "|": "price|currency:USD", ' +
|
|
487
|
+
'"publishedAt|date:en-US", "summary|truncate:160". Rich-text headings get ids from their text (e.g. "Our prices" -> ' +
|
|
488
|
+
'"our-prices", repeats get "-2"), for "#id" links.',
|
|
685
489
|
example: { type: FIELD_BLOCK, props: { path: 'content' }, className: 'prose max-w-none' },
|
|
686
490
|
},
|
|
687
491
|
});
|
|
@@ -689,54 +493,30 @@ export function defaultBlocks(options) {
|
|
|
689
493
|
const collectionList = defineBlock({
|
|
690
494
|
type: COLLECTION_LIST_BLOCK,
|
|
691
495
|
label: 'Collection list',
|
|
496
|
+
description: 'Shows posts, products or other documents from a collection.',
|
|
692
497
|
icon: 'collectionList',
|
|
693
498
|
category: 'Dynamic',
|
|
499
|
+
// `builderHeading`: the inspector shows a small heading above the field, so the long list reads in groups.
|
|
694
500
|
fields: [
|
|
695
|
-
listCollections
|
|
696
|
-
|
|
697
|
-
: { name: 'collection', type: 'text', label: 'Collection', required: true },
|
|
698
|
-
{ name: 'limit', type: 'number', label: 'Number of items', defaultValue: 3, min: 1, max: 100 },
|
|
699
|
-
{
|
|
700
|
-
name: 'sort',
|
|
701
|
-
type: 'text',
|
|
702
|
-
label: 'Sort',
|
|
703
|
-
defaultValue: '-createdAt',
|
|
704
|
-
admin: {
|
|
705
|
-
description: 'The field to sort by, for example "publishedAt". Put a "-" in front for newest or largest first: "-publishedAt". ' +
|
|
706
|
-
'"$random" shuffles the newest 100 matches once per page build.',
|
|
707
|
-
},
|
|
708
|
-
},
|
|
709
|
-
listCollections && listCollections.length > 0
|
|
710
|
-
? {
|
|
711
|
-
name: 'ids',
|
|
712
|
-
type: 'relationship',
|
|
713
|
-
label: 'Picked documents',
|
|
714
|
-
// The slugs come from the app, so they cannot match Payload's generated slug type.
|
|
715
|
-
relationTo: (listCollections.length === 1 ? listCollections[0] : listCollections),
|
|
716
|
-
hasMany: true,
|
|
717
|
-
admin: { description: 'Only these documents, in this order. Limit, sort, skip and pages then do not apply.' },
|
|
718
|
-
}
|
|
719
|
-
: {
|
|
720
|
-
name: 'ids',
|
|
721
|
-
type: 'text',
|
|
722
|
-
label: 'Picked document ids',
|
|
723
|
-
hasMany: true,
|
|
724
|
-
admin: { description: 'Only these documents, in this order. Limit, sort, skip and pages then do not apply.' },
|
|
725
|
-
},
|
|
501
|
+
listCollectionField(listCollections, { label: 'Collection', required: true }),
|
|
502
|
+
pickedDocumentsField(listCollections),
|
|
726
503
|
{
|
|
727
|
-
name: '
|
|
728
|
-
type: '
|
|
729
|
-
label: '
|
|
730
|
-
defaultValue:
|
|
731
|
-
|
|
504
|
+
name: 'depth',
|
|
505
|
+
type: 'select',
|
|
506
|
+
label: 'Load related data',
|
|
507
|
+
defaultValue: '1',
|
|
508
|
+
options: [
|
|
509
|
+
{ label: '1 level', value: '1' },
|
|
510
|
+
{ label: '2 levels', value: '2' },
|
|
511
|
+
],
|
|
732
512
|
},
|
|
733
513
|
{
|
|
734
514
|
name: 'filterField',
|
|
735
515
|
type: 'text',
|
|
736
|
-
label: '
|
|
516
|
+
label: 'Related to this page',
|
|
737
517
|
admin: {
|
|
738
|
-
|
|
739
|
-
|
|
518
|
+
// The inspector shows one select of the fields that relate the two collections, and sets `filterBy` with it.
|
|
519
|
+
custom: { builderHeading: 'Filter', builderRelated: { collectionField: 'collection', modeField: 'filterBy' }, builderContent: false },
|
|
740
520
|
},
|
|
741
521
|
},
|
|
742
522
|
{
|
|
@@ -745,120 +525,125 @@ export function defaultBlocks(options) {
|
|
|
745
525
|
label: 'Relation',
|
|
746
526
|
defaultValue: 'current',
|
|
747
527
|
options: [
|
|
748
|
-
{ label: '
|
|
749
|
-
{ label: '
|
|
750
|
-
{ label: '
|
|
528
|
+
{ label: 'Its field links to this page', value: 'current' },
|
|
529
|
+
{ label: 'Same value as this page', value: 'shared' },
|
|
530
|
+
{ label: 'This page links to it', value: 'linked' },
|
|
751
531
|
],
|
|
752
|
-
|
|
532
|
+
// Set by the "Related to this page" select.
|
|
533
|
+
admin: { hidden: true },
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
name: 'excludeCurrent',
|
|
537
|
+
type: 'checkbox',
|
|
538
|
+
label: 'Leave out the document this page shows',
|
|
539
|
+
defaultValue: true,
|
|
753
540
|
},
|
|
754
541
|
{
|
|
755
542
|
name: 'where',
|
|
756
543
|
type: 'json',
|
|
757
|
-
label: '
|
|
544
|
+
label: 'Conditions',
|
|
758
545
|
admin: {
|
|
759
|
-
description: 'A Payload where query, added to the filter. Example: { "featured": { "equals": true } }. Dates may use ' +
|
|
760
|
-
'"$now", "$now-30d" or "$now+12h".',
|
|
761
546
|
// The inspector edits it as condition rows over the fields of the chosen collection.
|
|
762
547
|
custom: { builderWhere: { collectionField: 'collection' } },
|
|
763
548
|
},
|
|
549
|
+
custom: {
|
|
550
|
+
ai: {
|
|
551
|
+
description: 'A Payload where query, added to the filter. Dates may use "$now", "$now-30d" or "$now+12h". In a template, ' +
|
|
552
|
+
'"$page.<field>" uses a field of the page\'s document; "$query.<param>" uses a URL value (left out without one).',
|
|
553
|
+
},
|
|
554
|
+
},
|
|
764
555
|
},
|
|
765
556
|
{
|
|
766
557
|
name: 'queryFilters',
|
|
767
558
|
type: 'json',
|
|
768
559
|
label: 'URL filters',
|
|
769
560
|
admin: {
|
|
770
|
-
|
|
771
|
-
|
|
561
|
+
// The inspector edits it as rows (parameter, field), with JSON for the full form.
|
|
562
|
+
custom: { builderQueryFilters: { collectionField: 'collection' } },
|
|
772
563
|
},
|
|
564
|
+
custom: { ai: { description: 'Filters from the page URL: { "<param>": "<field>" }. The editor preview ignores them.' } },
|
|
773
565
|
},
|
|
774
|
-
{
|
|
566
|
+
{
|
|
567
|
+
name: 'sort',
|
|
568
|
+
type: 'text',
|
|
569
|
+
label: 'Sort',
|
|
570
|
+
defaultValue: '-createdAt',
|
|
571
|
+
admin: {
|
|
572
|
+
// The inspector shows a select of the collection's fields, a direction and "Random".
|
|
573
|
+
custom: { builderHeading: 'Sort and count', builderSort: { collectionField: 'collection' }, builderContent: false },
|
|
574
|
+
},
|
|
575
|
+
custom: {
|
|
576
|
+
ai: {
|
|
577
|
+
description: 'A field name; a "-" in front sorts newest or largest first ("-publishedAt"). "$random" shuffles the newest 100 matches once per page build.',
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
{ name: 'limit', type: 'number', label: 'Number of items', defaultValue: 3, min: 1, max: 100 },
|
|
582
|
+
{ name: 'offset', type: 'number', label: 'Skip first', min: 0, admin: { placeholder: '0' } },
|
|
775
583
|
{
|
|
776
584
|
name: 'paginate',
|
|
777
585
|
type: 'select',
|
|
778
|
-
label: '
|
|
586
|
+
label: 'Page links',
|
|
779
587
|
defaultValue: 'none',
|
|
780
588
|
options: [
|
|
781
|
-
{ label: 'None
|
|
782
|
-
{ label: '
|
|
589
|
+
{ label: 'None', value: 'none' },
|
|
590
|
+
{ label: 'Under the list', value: 'pages' },
|
|
783
591
|
],
|
|
784
|
-
admin: {
|
|
785
|
-
description: 'Pages: "Number of items" per page, with page links under the list. Long lists show the first, the last and the ' +
|
|
786
|
-
'pages around the current one, with "…" between. "Skip items" does not apply.',
|
|
787
|
-
},
|
|
592
|
+
admin: { custom: { builderHeading: 'Pages' } },
|
|
788
593
|
},
|
|
789
594
|
{
|
|
790
595
|
name: 'pageParam',
|
|
791
596
|
type: 'text',
|
|
792
|
-
label: '
|
|
793
|
-
admin: {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
597
|
+
label: 'URL parameter',
|
|
598
|
+
admin: { placeholder: 'page', custom: { ...when('paginate', 'pages').custom, builderContent: false } },
|
|
599
|
+
custom: {
|
|
600
|
+
ai: {
|
|
601
|
+
description: 'Empty: "page". Give each paginated list on one page its own, for example "reviewsPage". Letters, digits, _ and -.',
|
|
602
|
+
},
|
|
797
603
|
},
|
|
798
604
|
},
|
|
799
605
|
{
|
|
800
606
|
name: 'pagerLabel',
|
|
801
607
|
type: 'text',
|
|
802
|
-
label: '
|
|
803
|
-
defaultValue: 'Pages',
|
|
608
|
+
label: 'Name for screen readers',
|
|
804
609
|
localized: true,
|
|
805
|
-
admin: when('paginate', 'pages'),
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
name: 'pagerClassName',
|
|
809
|
-
type: 'text',
|
|
810
|
-
label: 'Page links: classes',
|
|
811
|
-
defaultValue: 'flex flex-wrap gap-2',
|
|
812
|
-
admin: {
|
|
813
|
-
description: 'Classes of the element that holds the page links. A gap ("…") is a span with data-page-gap.',
|
|
814
|
-
custom: { builderClasses: true },
|
|
815
|
-
},
|
|
816
|
-
},
|
|
817
|
-
{
|
|
818
|
-
name: 'pageLinkClassName',
|
|
819
|
-
type: 'text',
|
|
820
|
-
label: 'Page link: classes',
|
|
821
|
-
admin: { description: 'Classes of each page link. The current page has aria-current="page", e.g. "aria-[current=page]:font-bold".', custom: { builderClasses: true } },
|
|
822
|
-
},
|
|
823
|
-
{
|
|
824
|
-
name: 'depth',
|
|
825
|
-
type: 'select',
|
|
826
|
-
label: 'Related data depth',
|
|
827
|
-
defaultValue: '1',
|
|
828
|
-
options: [
|
|
829
|
-
{ label: '1: the related documents of each item', value: '1' },
|
|
830
|
-
{ label: '2: also their related documents (larger)', value: '2' },
|
|
831
|
-
],
|
|
832
|
-
admin: { description: 'How far related documents of each item load, for example 2 to reach a category\'s image.' },
|
|
610
|
+
admin: { placeholder: 'Pages', ...when('paginate', 'pages') },
|
|
833
611
|
},
|
|
834
612
|
],
|
|
835
613
|
slots: { [LIST_ITEM_SLOT]: { label: 'Item' }, [LIST_EMPTY_SLOT]: { label: 'When empty', styles: true } },
|
|
614
|
+
// The page links: the <nav> that holds them (a gap "…" is a span with data-page-gap) and each link.
|
|
615
|
+
parts: { pager: { label: 'Page links', defaultClassName: 'flex flex-wrap gap-2' }, pageLink: { label: 'Each page link' } },
|
|
836
616
|
defaultClassName: 'grid grid-cols-1 gap-6 md:grid-cols-3',
|
|
837
617
|
ai: {
|
|
838
618
|
description: 'Lists the latest documents of a collection (e.g. "latest posts"). The "item" slot is the design of ONE ' +
|
|
839
619
|
'item: it repeats for every document. Blocks in it bind to the ITEM\'s fields with "bindings", e.g. a ' +
|
|
840
620
|
'heading with bindings { "text": "title" } and a link with bindings { "link": "$url" } (the item\'s URL). ' +
|
|
841
621
|
'Only published documents show on the site. ' +
|
|
842
|
-
'To list documents related to the current document (templates only;
|
|
622
|
+
'To list documents related to the current document (templates only; on normal pages the list is empty), set ' +
|
|
843
623
|
'"filterField" (a field name) and "filterBy": "current" (default) lists documents whose filterField holds ' +
|
|
844
|
-
'the current document (e.g. on a
|
|
624
|
+
'the current document (e.g. on a category template, posts whose "categories" include this category); ' +
|
|
845
625
|
'"shared" lists documents whose filterField shares a value with the current document\'s filterField ' +
|
|
846
|
-
'(e.g.
|
|
847
|
-
'the documents the current document\'s filterField points to (e.g. on a
|
|
848
|
-
'"
|
|
849
|
-
'where query AND-ed with the rest, e.g. { "featured": { "equals": true } }; date values may be "$now", ' +
|
|
850
|
-
'"$now-30d" or "$now+7d" (units d and h). "
|
|
851
|
-
'e.g. { "
|
|
626
|
+
'(e.g. related posts with a "category" in common); "linked" lists ' +
|
|
627
|
+
'the documents the current document\'s filterField points to (e.g. on a post template, the post\'s ' +
|
|
628
|
+
'"authors"). With "shared" or "linked" and an empty field, the list is empty. "where" is a static Payload ' +
|
|
629
|
+
'where query AND-ed with the rest, e.g. { "featured": { "equals": true } }, with "or" for alternatives; date values may be "$now", ' +
|
|
630
|
+
'"$now-30d" or "$now+7d" (units d and h). A value "$page.<field>" is that field of the current document when the ' +
|
|
631
|
+
'list loads (e.g. { "category": { "equals": "$page.category" } } on a post template; ids for relationships; ' +
|
|
632
|
+
'without a value the list is empty, except for not_equals and not_in, which are left out). A value "$query.<param>" is ' +
|
|
633
|
+
'the URL value (several values make equals an "in"); without one the condition is left out, and the canvas has none. "queryFilters" filters by the page URL: { "<param>": "<field path>" } ' +
|
|
634
|
+
'means the field equals the URL value (e.g. { "category": "category" } for ?category=news); the full form ' +
|
|
635
|
+
'{ "<param>": { "<value>": where } } maps each value to a where (e.g. { "age": { "recent": { "publishedAt": ' +
|
|
636
|
+
'{ "greater_than": "$now-30d" } } } } for ?age=recent). Values of one ' +
|
|
852
637
|
'param (repeated or comma-separated) are OR-ed, params are AND-ed; the canvas ignores them. "offset" skips ' +
|
|
853
638
|
'documents. "depth" ("1" or "2") is how deep related documents load. "ids" picks documents by id and keeps the ' +
|
|
854
639
|
'pick order (limit, sort, offset and pages then do not apply). "sort": "$random" shuffles the newest 100 ' +
|
|
855
640
|
'matches once per page build. "paginate": "pages" shows "limit" items per page with crawlable ?page=N links ' +
|
|
856
|
-
'under the list ("
|
|
641
|
+
'under the list (style them with "partClassName" "pager" for the <nav> and "pageLink" for each link; the current link has aria-current="page"; long ' +
|
|
857
642
|
'lists show "…" gaps as <span data-page-gap>). Two paginated lists on one page need their own "pageParam" ' +
|
|
858
643
|
'(default "page"), for example "reviewsPage". "pagerLabel" names the page links for screen readers (default "Pages"). ' +
|
|
859
644
|
'The "empty" slot shows instead of the ' +
|
|
860
|
-
'items when no document matches (e.g. a text "
|
|
861
|
-
'with "
|
|
645
|
+
'items when no document matches (e.g. a text "No posts yet"); it renders in its own div, styled ' +
|
|
646
|
+
'with "partClassName": { "empty": "col-span-full ..." }.',
|
|
862
647
|
example: {
|
|
863
648
|
type: COLLECTION_LIST_BLOCK,
|
|
864
649
|
props: { collection: 'posts', limit: 3, sort: '-createdAt' },
|
|
@@ -885,48 +670,29 @@ export function defaultBlocks(options) {
|
|
|
885
670
|
const repeat = defineBlock({
|
|
886
671
|
type: REPEAT_BLOCK,
|
|
887
672
|
label: 'Repeat',
|
|
673
|
+
description: 'Repeats its blocks for each row of a list field.',
|
|
888
674
|
icon: 'repeat',
|
|
889
675
|
category: 'Dynamic',
|
|
890
676
|
fields: [
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
},
|
|
901
|
-
{ name: 'limit', type: 'number', label: 'Number of rows', min: 1, admin: { description: 'Empty: every row.' } },
|
|
902
|
-
{ name: 'offset', type: 'number', label: 'Skip rows', min: 0, admin: { description: 'Rows to leave out at the start, for example 1 to skip the first photo.' } },
|
|
903
|
-
listCollections && listCollections.length > 0
|
|
904
|
-
? {
|
|
905
|
-
name: 'collection',
|
|
906
|
-
type: 'select',
|
|
907
|
-
label: 'Related collection',
|
|
908
|
-
options: listCollections,
|
|
909
|
-
admin: { description: 'For a relationship field: the collection of its documents, so "$url" links to each one.' },
|
|
910
|
-
}
|
|
911
|
-
: {
|
|
912
|
-
name: 'collection',
|
|
913
|
-
type: 'text',
|
|
914
|
-
label: 'Related collection',
|
|
915
|
-
admin: { description: 'For a relationship field: the collection of its documents, so "$url" links to each one.' },
|
|
916
|
-
},
|
|
677
|
+
// The inspector shows the field picker of the bindings UI (templates/Bindable).
|
|
678
|
+
{ name: 'path', type: 'text', label: 'Field', required: true, admin: { custom: { builderContent: false } } },
|
|
679
|
+
{ name: 'limit', type: 'number', label: 'Number of rows', min: 1, admin: { placeholder: 'All' } },
|
|
680
|
+
{ name: 'offset', type: 'number', label: 'Skip first', min: 0, admin: { placeholder: '0' } },
|
|
681
|
+
listCollectionField(listCollections, {
|
|
682
|
+
label: 'Linked collection',
|
|
683
|
+
required: false,
|
|
684
|
+
description: 'For links to each row.',
|
|
685
|
+
}),
|
|
917
686
|
{
|
|
918
687
|
name: 'as',
|
|
919
688
|
type: 'select',
|
|
920
|
-
label: '
|
|
689
|
+
label: 'Tag',
|
|
921
690
|
defaultValue: 'div',
|
|
922
691
|
options: [
|
|
923
|
-
{ label: '
|
|
924
|
-
{ label: '
|
|
692
|
+
{ label: 'div', value: 'div' },
|
|
693
|
+
{ label: 'none', value: 'none' },
|
|
925
694
|
],
|
|
926
|
-
admin: {
|
|
927
|
-
description: 'None: the rows become direct children of the parent block, for example the cells of a grid or the items of a list. ' +
|
|
928
|
-
"The repeat's own classes and animations then do nothing.",
|
|
929
|
-
},
|
|
695
|
+
admin: { description: 'None: the rows go straight into the parent.' },
|
|
930
696
|
},
|
|
931
697
|
],
|
|
932
698
|
slots: { [LIST_ITEM_SLOT]: { label: 'Row' } },
|
|
@@ -934,7 +700,7 @@ export function defaultBlocks(options) {
|
|
|
934
700
|
ai: {
|
|
935
701
|
description: 'Repeats its "item" slot once per row of a list field of the CURRENT document (templates; inside a collection ' +
|
|
936
702
|
'list item, of each listed document; inside another repeat, of the row). "path" is the field: an array ' +
|
|
937
|
-
'(e.g. FAQs,
|
|
703
|
+
'(e.g. FAQs, prices), a hasMany upload (e.g. a gallery), a hasMany relationship, or hasMany text/select. ' +
|
|
938
704
|
'Blocks in "item" bind to the ROW: the field names of an array row (e.g. "question", "price"), the related ' +
|
|
939
705
|
`document's fields (e.g. "name"; "$url" when "collection" names its collection), "${ITEM_PATH}" (the row value ` +
|
|
940
706
|
`itself: an upload for an image, a text for a text block), "${INDEX_PATH}" (the row number from 1), ` +
|
|
@@ -943,7 +709,7 @@ export function defaultBlocks(options) {
|
|
|
943
709
|
'a div that takes the className; "none" renders the rows with no wrapper, as direct children of the parent ' +
|
|
944
710
|
'(e.g. cells of a grid, items of a stack with as "ul"), and then className and motion do nothing. ' +
|
|
945
711
|
'On a page without a current document ' +
|
|
946
|
-
'it shows nothing. Example 2 (photos): { "type": "repeat", "props": { "path": "
|
|
712
|
+
'it shows nothing. Example 2 (photos): { "type": "repeat", "props": { "path": "gallery", "offset": 1 }, ' +
|
|
947
713
|
`"slots": { "item": [{ "type": "image", "bindings": { "image": "${ITEM_PATH}" } }] } }.`,
|
|
948
714
|
example: {
|
|
949
715
|
type: REPEAT_BLOCK,
|
|
@@ -967,5 +733,5 @@ export function defaultBlocks(options) {
|
|
|
967
733
|
},
|
|
968
734
|
},
|
|
969
735
|
});
|
|
970
|
-
return [stack, grid, heading, text, richText, image, button, link, menu, list, listItem,
|
|
736
|
+
return [stack, grid, heading, text, richText, image, button, link, menu, list, listItem, divider, video, field, collectionList, repeat];
|
|
971
737
|
}
|