payload-canvas 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +626 -154
- package/dist/admin/AiKeyField.d.ts +8 -0
- package/dist/admin/AiKeyField.js +54 -0
- package/dist/admin/BuilderTab.js +4 -1
- package/dist/admin/DocumentEditView.d.ts +9 -0
- package/dist/admin/DocumentEditView.js +45 -0
- package/dist/admin/LayoutField.d.ts +2 -2
- package/dist/admin/LayoutField.js +10 -7
- package/dist/admin/TemplateConditionsField.d.ts +9 -0
- package/dist/admin/TemplateConditionsField.js +22 -0
- package/dist/admin/aiKeyField.scss +58 -0
- package/dist/admin/client.d.ts +3 -0
- package/dist/admin/client.js +6 -0
- package/dist/admin/diff/changes.js +5 -0
- package/dist/admin/editor/Canvas.js +20 -5
- package/dist/admin/editor/Editor.d.ts +3 -1
- package/dist/admin/editor/Editor.js +6 -3
- package/dist/admin/editor/Inspector.js +75 -28
- package/dist/admin/editor/Library.js +40 -15
- package/dist/admin/editor/Outline.js +21 -16
- package/dist/admin/editor/Overlay.js +8 -3
- package/dist/admin/editor/actions.d.ts +10 -2
- package/dist/admin/editor/actions.js +18 -3
- package/dist/admin/editor/assistant/AssistantPanel.js +3 -1
- package/dist/admin/editor/classes/ClassManager.d.ts +4 -0
- package/dist/admin/editor/classes/ClassManager.js +56 -0
- package/dist/admin/editor/classes/controller.d.ts +112 -0
- package/dist/admin/editor/classes/controller.js +326 -0
- package/dist/admin/editor/classes/manager.scss +262 -0
- package/dist/admin/editor/classes/managerModel.d.ts +5 -0
- package/dist/admin/editor/classes/managerModel.js +27 -0
- package/dist/admin/editor/comments/CommentLayer.d.ts +2 -0
- package/dist/admin/editor/comments/CommentLayer.js +143 -0
- package/dist/admin/editor/comments/CommentsPanel.d.ts +8 -0
- package/dist/admin/editor/comments/CommentsPanel.js +73 -0
- package/dist/admin/editor/comments/Thread.d.ts +26 -0
- package/dist/admin/editor/comments/Thread.js +84 -0
- package/dist/admin/editor/comments/comments.scss +539 -0
- package/dist/admin/editor/comments/controller.d.ts +48 -0
- package/dist/admin/editor/comments/controller.js +142 -0
- package/dist/admin/editor/contentMode.d.ts +17 -0
- package/dist/admin/editor/contentMode.js +37 -0
- package/dist/admin/editor/dnd/DropOutlines.d.ts +1 -0
- package/dist/admin/editor/dnd/DropOutlines.js +73 -0
- package/dist/admin/editor/dnd/dnd.scss +43 -0
- package/dist/admin/editor/dnd/mode.d.ts +4 -0
- package/dist/admin/editor/dnd/mode.js +39 -0
- package/dist/admin/editor/editor.scss +13 -58
- package/dist/admin/editor/empty/EmptyStart.js +18 -66
- package/dist/admin/editor/fields/AddButton.d.ts +15 -0
- package/dist/admin/editor/fields/AddButton.js +14 -0
- package/dist/admin/editor/fields/ArrayField.js +3 -2
- package/dist/admin/editor/fields/CheckedInputs.d.ts +1 -0
- package/dist/admin/editor/fields/ConditionRows.d.ts +19 -0
- package/dist/admin/editor/fields/ConditionRows.js +137 -0
- package/dist/admin/editor/fields/ListWhereField.d.ts +8 -0
- package/dist/admin/editor/fields/ListWhereField.js +20 -0
- package/dist/admin/editor/fields/QueryFiltersField.d.ts +18 -0
- package/dist/admin/editor/fields/QueryFiltersField.js +41 -0
- package/dist/admin/editor/fields/RelatedField.d.ts +19 -0
- package/dist/admin/editor/fields/RelatedField.js +44 -0
- package/dist/admin/editor/fields/SortField.d.ts +13 -0
- package/dist/admin/editor/fields/SortField.js +37 -0
- package/dist/admin/editor/fields/WhereField.d.ts +12 -4
- package/dist/admin/editor/fields/WhereField.js +33 -53
- package/dist/admin/editor/fields/collectionFields.d.ts +6 -0
- package/dist/admin/editor/fields/collectionFields.js +15 -0
- package/dist/admin/editor/fields/conditions.d.ts +99 -0
- package/dist/admin/editor/fields/conditions.js +339 -0
- package/dist/admin/editor/fields/fields.scss +232 -9
- package/dist/admin/editor/fields/listOptions.d.ts +44 -0
- package/dist/admin/editor/fields/listOptions.js +111 -0
- package/dist/admin/editor/fields/queryFilterRows.d.ts +8 -0
- package/dist/admin/editor/fields/queryFilterRows.js +29 -0
- package/dist/admin/editor/fields/whereRows.d.ts +11 -12
- package/dist/admin/editor/fields/whereRows.js +83 -34
- package/dist/admin/editor/icons.d.ts +16 -1
- package/dist/admin/editor/icons.js +30 -1
- package/dist/admin/editor/inline.js +9 -0
- package/dist/admin/editor/insert/InsertHandle.js +4 -1
- package/dist/admin/editor/insert/picker.d.ts +3 -1
- package/dist/admin/editor/insert/picker.js +17 -10
- package/dist/admin/editor/insert/spots.d.ts +12 -1
- package/dist/admin/editor/insert/spots.js +49 -10
- package/dist/admin/editor/layout/LeftPanel.js +11 -6
- package/dist/admin/editor/live/useMultiplayer.js +9 -1
- package/dist/admin/editor/menu/blockMenu.js +27 -17
- package/dist/admin/editor/names.js +11 -3
- package/dist/admin/editor/renderField.d.ts +3 -1
- package/dist/admin/editor/renderField.js +63 -12
- package/dist/admin/editor/runtime.d.ts +14 -0
- package/dist/admin/editor/runtime.js +67 -6
- package/dist/admin/editor/sections/ComponentFields.d.ts +8 -0
- package/dist/admin/editor/sections/ComponentFields.js +116 -0
- package/dist/admin/editor/sections/PropertyControls.d.ts +18 -0
- package/dist/admin/editor/sections/PropertyControls.js +65 -0
- package/dist/admin/editor/sections/components.d.ts +29 -0
- package/dist/admin/editor/sections/components.js +112 -0
- package/dist/admin/editor/sections/components.scss +238 -0
- package/dist/admin/editor/sections/variants.d.ts +32 -0
- package/dist/admin/editor/sections/variants.js +59 -0
- package/dist/admin/editor/sections/variants.scss +90 -0
- package/dist/admin/editor/shortcuts.d.ts +4 -1
- package/dist/admin/editor/shortcuts.js +19 -3
- package/dist/admin/editor/store.d.ts +18 -0
- package/dist/admin/editor/store.js +46 -0
- package/dist/admin/editor/styles/ClassBar.d.ts +14 -0
- package/dist/admin/editor/styles/ClassBar.js +90 -0
- package/dist/admin/editor/styles/ClassCss.d.ts +4 -0
- package/dist/admin/editor/styles/ClassCss.js +28 -0
- package/dist/admin/editor/styles/ClassDialog.d.ts +2 -0
- package/dist/admin/editor/styles/ClassDialog.js +151 -0
- package/dist/admin/editor/styles/ColorPicker.js +5 -2
- package/dist/admin/editor/styles/RawClasses.d.ts +26 -1
- package/dist/admin/editor/styles/RawClasses.js +184 -32
- package/dist/admin/editor/styles/StylesPanel.d.ts +3 -3
- package/dist/admin/editor/styles/StylesPanel.js +53 -14
- package/dist/admin/editor/styles/VariantBar.js +2 -2
- package/dist/admin/editor/styles/classEdit.d.ts +4 -0
- package/dist/admin/editor/styles/classEdit.js +20 -0
- package/dist/admin/editor/styles/classes.scss +381 -0
- package/dist/admin/editor/styles/context.d.ts +19 -6
- package/dist/admin/editor/styles/context.js +24 -6
- package/dist/admin/editor/styles/controls.d.ts +3 -1
- package/dist/admin/editor/styles/controls.js +30 -12
- package/dist/admin/editor/styles/popover.d.ts +6 -0
- package/dist/admin/editor/styles/popover.js +5 -5
- package/dist/admin/editor/styles/styles.scss +26 -104
- package/dist/admin/editor/styles/suggestions.d.ts +22 -0
- package/dist/admin/editor/styles/suggestions.js +77 -0
- package/dist/admin/editor/styles/tokens.js +14 -0
- package/dist/admin/editor/templates/Bindable.js +86 -57
- package/dist/admin/editor/templates/SamplePicker.js +1 -1
- package/dist/admin/editor/templates/Visibility.d.ts +9 -0
- package/dist/admin/editor/templates/Visibility.js +54 -0
- package/dist/admin/editor/templates/binding.d.ts +2 -2
- package/dist/admin/editor/templates/binding.js +2 -2
- package/dist/admin/editor/templates/templates.scss +27 -0
- package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
- package/dist/admin/editor/templates/visibilityRows.js +83 -0
- package/dist/admin/editor/topbar/ContentModeToggle.d.ts +5 -0
- package/dist/admin/editor/topbar/ContentModeToggle.js +26 -0
- package/dist/admin/editor/topbar/DocumentActions.d.ts +1 -1
- package/dist/admin/editor/topbar/DocumentActions.js +5 -4
- package/dist/admin/editor/topbar/DocumentTitle.js +7 -2
- package/dist/admin/editor/topbar/TopBar.js +15 -3
- package/dist/admin/editor/topbar/contentMode.scss +35 -0
- package/dist/admin/editor/topbar/topbar.scss +3 -1
- package/dist/admin/formChoice.d.ts +3 -0
- package/dist/admin/formChoice.js +10 -0
- package/dist/admin/layoutField.scss +69 -0
- package/dist/admin/screen/BuilderScreen.d.ts +6 -1
- package/dist/admin/screen/BuilderScreen.js +4 -3
- package/dist/admin/server/BuilderView.js +10 -3
- package/dist/admin/templateConditions.scss +24 -0
- package/dist/ai/adapters/anthropic.js +17 -4
- package/dist/ai/adapters/cloudflare-gateway.js +7 -1
- package/dist/ai/adapters/cloudflare-workers-ai.js +2 -0
- package/dist/ai/adapters/openai-compatible.js +1 -0
- package/dist/ai/adapters/openrouter.js +2 -0
- package/dist/ai/config.d.ts +24 -4
- package/dist/ai/config.js +27 -8
- package/dist/ai/endpoint.d.ts +5 -2
- package/dist/ai/endpoint.js +31 -26
- package/dist/ai/images/cloudflare-workers-ai.js +6 -2
- package/dist/ai/images/openai.js +8 -3
- package/dist/ai/images/openrouter.js +6 -2
- package/dist/ai/images/service.d.ts +10 -4
- package/dist/ai/images/service.js +23 -7
- package/dist/ai/openai-format.d.ts +7 -0
- package/dist/ai/openai-format.js +17 -5
- package/dist/ai/prompt.d.ts +8 -0
- package/dist/ai/prompt.js +25 -5
- package/dist/ai/settings/index.d.ts +62 -0
- package/dist/ai/settings/index.js +264 -0
- package/dist/ai/settings/secret.d.ts +11 -0
- package/dist/ai/settings/secret.js +46 -0
- package/dist/ai/settings/shared.d.ts +22 -0
- package/dist/ai/settings/shared.js +3 -0
- package/dist/ai/tools.d.ts +3 -0
- package/dist/ai/tools.js +79 -15
- package/dist/ai/types.d.ts +43 -0
- package/dist/blocks/builtins/adjacentLinks.d.ts +5 -0
- package/dist/blocks/builtins/adjacentLinks.js +76 -0
- package/dist/blocks/builtins/carousel.d.ts +2 -29
- package/dist/blocks/builtins/carousel.js +44 -51
- package/dist/blocks/builtins/disclosure.d.ts +2 -1
- package/dist/blocks/builtins/disclosure.js +22 -32
- package/dist/blocks/builtins/embed.d.ts +15 -0
- package/dist/blocks/builtins/embed.js +47 -0
- package/dist/blocks/builtins/faq.d.ts +1 -1
- package/dist/blocks/builtins/faq.js +2 -2
- package/dist/blocks/builtins/filterLink.d.ts +1 -19
- package/dist/blocks/builtins/filterLink.js +9 -50
- package/dist/blocks/builtins/icon.d.ts +2 -0
- package/dist/blocks/builtins/icon.js +8 -8
- package/dist/blocks/builtins/index.d.ts +18 -13
- package/dist/blocks/builtins/index.js +43 -22
- package/dist/blocks/builtins/marquee.d.ts +5 -0
- package/dist/blocks/builtins/marquee.js +68 -0
- package/dist/blocks/builtins/popup.d.ts +5 -0
- package/dist/blocks/builtins/popup.js +83 -0
- package/dist/blocks/builtins/sectionRef.d.ts +16 -2
- package/dist/blocks/builtins/sectionRef.js +34 -12
- package/dist/blocks/builtins/shared.d.ts +18 -23
- package/dist/blocks/builtins/shared.js +34 -42
- package/dist/blocks/builtins/tableOfContents.d.ts +4 -0
- package/dist/blocks/builtins/tableOfContents.js +12 -18
- package/dist/blocks/builtins/tabs.d.ts +6 -0
- package/dist/blocks/builtins/tabs.js +87 -0
- package/dist/blocks/client/adjacentLinks.d.ts +4 -0
- package/dist/blocks/client/adjacentLinks.js +4 -0
- package/dist/blocks/client/carousel.d.ts +45 -0
- package/dist/blocks/client/carousel.js +53 -0
- package/dist/blocks/client/embed.d.ts +21 -0
- package/dist/blocks/client/embed.js +23 -0
- package/dist/blocks/client/field.d.ts +7 -0
- package/dist/blocks/client/field.js +8 -0
- package/dist/blocks/client/filterLink.d.ts +19 -0
- package/dist/blocks/client/filterLink.js +30 -0
- package/dist/blocks/client/helpers.d.ts +21 -0
- package/dist/blocks/client/helpers.js +24 -0
- package/dist/blocks/client/marquee.d.ts +14 -0
- package/dist/blocks/client/marquee.js +25 -0
- package/dist/blocks/client/menu.d.ts +46 -0
- package/dist/blocks/client/menu.js +49 -0
- package/dist/blocks/client/popup.d.ts +15 -0
- package/dist/blocks/client/popup.js +16 -0
- package/dist/blocks/client/tabs.d.ts +10 -0
- package/dist/blocks/client/tabs.js +11 -0
- package/dist/blocks/defaults.d.ts +15 -52
- package/dist/blocks/defaults.js +203 -437
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/index.js +2 -1
- package/dist/classes/actions.d.ts +97 -0
- package/dist/classes/actions.js +296 -0
- package/dist/classes/collection.d.ts +5 -0
- package/dist/classes/collection.js +189 -0
- package/dist/classes/config.d.ts +34 -0
- package/dist/classes/config.js +8 -0
- package/dist/classes/endpoints.d.ts +2 -0
- package/dist/classes/endpoints.js +120 -0
- package/dist/classes/index.d.ts +36 -0
- package/dist/classes/index.js +42 -0
- package/dist/classes/mcp.d.ts +6 -0
- package/dist/classes/mcp.js +161 -0
- package/dist/classes/shared.d.ts +131 -0
- package/dist/classes/shared.js +300 -0
- package/dist/classes/sheet.d.ts +34 -0
- package/dist/classes/sheet.js +126 -0
- package/dist/classes/usage.d.ts +57 -0
- package/dist/classes/usage.js +208 -0
- package/dist/comments/collection.d.ts +38 -0
- package/dist/comments/collection.js +226 -0
- package/dist/comments/config.d.ts +15 -0
- package/dist/comments/config.js +2 -0
- package/dist/comments/index.d.ts +20 -0
- package/dist/comments/index.js +22 -0
- package/dist/comments/shared.d.ts +54 -0
- package/dist/comments/shared.js +104 -0
- package/dist/core/bindings.d.ts +77 -32
- package/dist/core/bindings.js +319 -134
- package/dist/core/blockNames.d.ts +9 -0
- package/dist/core/blockNames.js +11 -0
- package/dist/core/blocks.d.ts +21 -8
- package/dist/core/blocks.js +37 -16
- package/dist/core/classes.d.ts +16 -8
- package/dist/core/classes.js +31 -27
- package/dist/core/components.d.ts +72 -0
- package/dist/core/components.js +294 -0
- package/dist/core/contentMode.d.ts +27 -0
- package/dist/core/contentMode.js +0 -0
- package/dist/core/dropTarget.d.ts +11 -0
- package/dist/core/dropTarget.js +24 -1
- package/dist/core/fields.d.ts +5 -0
- package/dist/core/fields.js +11 -0
- package/dist/core/headings.d.ts +5 -2
- package/dist/core/headings.js +14 -6
- package/dist/core/index.d.ts +8 -3
- package/dist/core/index.js +8 -3
- package/dist/core/layers.d.ts +9 -0
- package/dist/core/layers.js +29 -0
- package/dist/core/operations.d.ts +6 -0
- package/dist/core/operations.js +85 -24
- package/dist/core/payloadBlocks.js +5 -1
- package/dist/core/references.js +28 -0
- package/dist/core/schema.js +20 -6
- package/dist/core/sectionOrigin.d.ts +6 -0
- package/dist/core/sectionOrigin.js +21 -0
- package/dist/core/sections.d.ts +72 -0
- package/dist/core/sections.js +331 -0
- package/dist/core/templateChoice.d.ts +24 -0
- package/dist/core/templateChoice.js +43 -0
- package/dist/core/tree.js +18 -6
- package/dist/core/types.d.ts +148 -18
- package/dist/core/validate.d.ts +4 -1
- package/dist/core/validate.js +28 -11
- package/dist/core/visibility.d.ts +63 -0
- package/dist/core/visibility.js +214 -0
- package/dist/core/whereValues.d.ts +22 -0
- package/dist/core/whereValues.js +43 -0
- package/dist/css/classes.d.ts +16 -0
- package/dist/css/classes.js +172 -0
- package/dist/css/index.d.ts +32 -1
- package/dist/css/index.js +64 -5
- package/dist/css/tokens.d.ts +10 -0
- package/dist/css/tokens.js +23 -10
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -1
- package/dist/live/contentMode.d.ts +24 -0
- package/dist/live/contentMode.js +39 -0
- package/dist/live/endpoints.js +3 -0
- package/dist/live/session.d.ts +5 -0
- package/dist/live/session.js +8 -0
- package/dist/live/types.d.ts +16 -1
- package/dist/mcp/index.d.ts +10 -1
- package/dist/mcp/index.js +146 -54
- package/dist/mcp/shared.d.ts +93 -3
- package/dist/mcp/shared.js +211 -15
- package/dist/plugin/hook.d.ts +7 -1
- package/dist/plugin/hook.js +30 -4
- package/dist/plugin/index.d.ts +19 -8
- package/dist/plugin/index.js +89 -20
- package/dist/plugin/links.d.ts +24 -0
- package/dist/plugin/links.js +27 -0
- package/dist/plugin/listCollections.d.ts +9 -7
- package/dist/plugin/listCollections.js +30 -21
- package/dist/plugin/sections.d.ts +14 -7
- package/dist/plugin/sections.js +69 -23
- package/dist/plugin/sectionsUsedIn.d.ts +6 -0
- package/dist/plugin/sectionsUsedIn.js +24 -0
- package/dist/plugin/templateEndpoint.d.ts +9 -0
- package/dist/plugin/templateEndpoint.js +49 -0
- package/dist/plugin/templates.js +23 -8
- package/dist/protocol/index.d.ts +16 -1
- package/dist/react/canvas/BuilderCanvas.js +144 -21
- package/dist/react/canvas/classes.d.ts +17 -0
- package/dist/react/canvas/classes.js +102 -0
- package/dist/react/canvas/controls.d.ts +31 -0
- package/dist/react/canvas/controls.js +75 -0
- package/dist/react/canvas/fetchDocs.d.ts +2 -2
- package/dist/react/canvas/fetchDocs.js +16 -8
- package/dist/react/canvas/measure.d.ts +9 -0
- package/dist/react/canvas/measure.js +106 -7
- package/dist/react/canvas/resolveLayout.d.ts +1 -1
- package/dist/react/canvas/resolveLayout.js +4 -3
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +17 -4
- package/dist/react/classes/ClassesStyle.d.ts +27 -0
- package/dist/react/classes/ClassesStyle.js +27 -0
- package/dist/react/components/Button.d.ts +2 -11
- package/dist/react/components/Button.js +8 -43
- package/dist/react/components/CollectionList.d.ts +4 -1
- package/dist/react/components/CollectionList.js +10 -3
- package/dist/react/components/Container.d.ts +5 -2
- package/dist/react/components/Container.js +7 -4
- package/dist/react/components/Field.js +3 -14
- package/dist/react/components/Link.d.ts +1 -1
- package/dist/react/components/Link.js +5 -3
- package/dist/react/components/List.d.ts +1 -1
- package/dist/react/components/List.js +2 -2
- package/dist/react/components/Menu.d.ts +10 -1
- package/dist/react/components/Menu.js +39 -12
- package/dist/react/components/RichText.d.ts +3 -4
- package/dist/react/components/RichText.js +5 -5
- package/dist/react/components/builtins/Accordion.d.ts +4 -3
- package/dist/react/components/builtins/Accordion.js +6 -5
- package/dist/react/components/builtins/AdjacentLinks.d.ts +11 -0
- package/dist/react/components/builtins/AdjacentLinks.js +20 -0
- package/dist/react/components/builtins/Carousel.d.ts +21 -10
- package/dist/react/components/builtins/Carousel.js +175 -100
- package/dist/react/components/builtins/Disclosure.d.ts +4 -3
- package/dist/react/components/builtins/Disclosure.js +6 -5
- package/dist/react/components/builtins/Embed.d.ts +11 -0
- package/dist/react/components/builtins/Embed.js +23 -0
- package/dist/react/components/builtins/EmbedHtml.d.ts +15 -0
- package/dist/react/components/builtins/EmbedHtml.js +51 -0
- package/dist/react/components/builtins/EmbedPreview.d.ts +34 -0
- package/dist/react/components/builtins/EmbedPreview.js +105 -0
- package/dist/react/components/builtins/FilterLink.d.ts +1 -1
- package/dist/react/components/builtins/FilterLink.js +4 -4
- package/dist/react/components/builtins/Marquee.d.ts +8 -0
- package/dist/react/components/builtins/Marquee.js +15 -0
- package/dist/react/components/builtins/Popup.d.ts +26 -0
- package/dist/react/components/builtins/Popup.js +146 -0
- package/dist/react/components/builtins/SectionRef.d.ts +4 -3
- package/dist/react/components/builtins/SectionRef.js +9 -5
- package/dist/react/components/builtins/Tab.d.ts +7 -0
- package/dist/react/components/builtins/Tab.js +21 -0
- package/dist/react/components/builtins/TableOfContents.d.ts +17 -3
- package/dist/react/components/builtins/TableOfContents.js +22 -7
- package/dist/react/components/builtins/Tabs.d.ts +17 -0
- package/dist/react/components/builtins/Tabs.js +71 -0
- package/dist/react/components/builtins/index.d.ts +37 -20
- package/dist/react/components/builtins/index.js +54 -20
- package/dist/react/components/builtins/tabsContext.d.ts +12 -0
- package/dist/react/components/builtins/tabsContext.js +6 -0
- package/dist/react/components/index.js +11 -8
- package/dist/react/components/lazy.d.ts +32 -0
- package/dist/react/components/lazy.js +20 -0
- package/dist/react/components/lazyBlock.d.ts +17 -0
- package/dist/react/components/lazyBlock.js +23 -0
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +5 -2
- package/dist/react/render/RenderLayout.d.ts +9 -7
- package/dist/react/render/RenderLayout.js +96 -45
- package/dist/react/render/canvasMode.d.ts +13 -0
- package/dist/react/render/canvasMode.js +13 -0
- package/dist/react/render/canvasServer.js +4 -3
- package/dist/react/render/canvasServerTypes.d.ts +5 -0
- package/dist/react/render/lists.d.ts +36 -4
- package/dist/react/render/lists.js +132 -15
- package/dist/react/render/marks.d.ts +15 -0
- package/dist/react/render/marks.js +23 -0
- package/dist/react/render/payload.d.ts +8 -1
- package/dist/react/render/payload.js +12 -3
- package/dist/react/render/preview.d.ts +11 -0
- package/dist/react/render/preview.js +13 -0
- package/dist/react/render/relations.d.ts +10 -0
- package/dist/react/render/relations.js +39 -0
- package/dist/react/render/resolve.d.ts +8 -4
- package/dist/react/render/resolve.js +11 -5
- package/dist/react/render/reveal.d.ts +17 -0
- package/dist/react/render/reveal.js +39 -0
- package/dist/react/render/sections.d.ts +11 -5
- package/dist/react/render/sections.js +52 -24
- package/dist/react/render/templates.d.ts +47 -0
- package/dist/react/render/templates.js +139 -0
- package/dist/react/render/types.d.ts +62 -5
- package/dist/react/server.d.ts +2 -37
- package/dist/react/server.js +8 -133
- package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
- package/dist/react/theme/ThemeLiveLoader.js +5 -0
- package/dist/react/theme/ThemeStyle.js +1 -1
- package/dist/theme/admin/Variables.d.ts +11 -0
- package/dist/theme/admin/Variables.js +115 -0
- package/dist/theme/admin/fields.scss +113 -0
- package/dist/theme/client.d.ts +1 -0
- package/dist/theme/client.js +2 -0
- package/dist/theme/css.d.ts +6 -1
- package/dist/theme/css.js +12 -4
- package/dist/theme/global.js +83 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +1 -0
- package/dist/theme/server.d.ts +15 -0
- package/dist/theme/server.js +43 -0
- package/dist/theme/usage.d.ts +23 -0
- package/dist/theme/usage.js +68 -0
- package/dist/theme/variables.d.ts +72 -0
- package/dist/theme/variables.js +231 -0
- package/package.json +4 -2
- package/dist/admin/editor/styles/SiteClasses.d.ts +0 -9
- package/dist/admin/editor/styles/SiteClasses.js +0 -31
- package/dist/blocks/builtins/headingId.d.ts +0 -15
- package/dist/blocks/builtins/headingId.js +0 -36
- package/dist/blocks/builtins/lightbox.d.ts +0 -43
- package/dist/blocks/builtins/lightbox.js +0 -93
- package/dist/blocks/builtins/mediaBackdrop.d.ts +0 -11
- package/dist/blocks/builtins/mediaBackdrop.js +0 -79
- package/dist/react/components/Quote.d.ts +0 -3
- package/dist/react/components/Quote.js +0 -12
- package/dist/react/components/Spacer.d.ts +0 -3
- package/dist/react/components/Spacer.js +0 -6
- package/dist/react/components/builtins/BackdropVideo.d.ts +0 -13
- package/dist/react/components/builtins/BackdropVideo.js +0 -16
- package/dist/react/components/builtins/Lightbox.d.ts +0 -45
- package/dist/react/components/builtins/Lightbox.js +0 -252
- package/dist/react/components/builtins/MediaBackdrop.d.ts +0 -14
- package/dist/react/components/builtins/MediaBackdrop.js +0 -61
|
@@ -67,20 +67,134 @@
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// "Edit as JSON" / "Edit as conditions": a quiet text switch next to the label.
|
|
70
71
|
.builder-where__switch {
|
|
71
72
|
padding: 0;
|
|
72
73
|
border: 0;
|
|
73
74
|
background: none;
|
|
74
|
-
color: var(--theme-elevation-
|
|
75
|
+
color: var(--theme-elevation-600);
|
|
75
76
|
font: inherit;
|
|
76
|
-
font-size: var(--be-text-
|
|
77
|
-
|
|
77
|
+
font-size: var(--be-text-s);
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
|
|
80
|
+
&:hover,
|
|
81
|
+
&:focus-visible {
|
|
82
|
+
color: var(--theme-text);
|
|
83
|
+
text-decoration: underline;
|
|
84
|
+
text-underline-offset: 2px;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// The inspector's "+ Add …" action (AddButton): muted text with a plus, no border. The negative
|
|
89
|
+
// margin lines the plus up with the left edge of the inputs above it.
|
|
90
|
+
.builder-add {
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
flex: none;
|
|
93
|
+
align-items: center;
|
|
94
|
+
align-self: flex-start;
|
|
95
|
+
gap: 6px;
|
|
96
|
+
height: 26px;
|
|
97
|
+
margin: 0 0 0 -6px;
|
|
98
|
+
padding: 0 8px 0 6px;
|
|
99
|
+
border: 0;
|
|
100
|
+
border-radius: var(--style-radius-s, 4px);
|
|
101
|
+
background: none;
|
|
102
|
+
color: var(--theme-elevation-600);
|
|
103
|
+
font: inherit;
|
|
104
|
+
font-size: var(--be-text-m, 13px);
|
|
105
|
+
font-weight: var(--be-weight-medium, 500);
|
|
106
|
+
line-height: 1;
|
|
107
|
+
white-space: nowrap;
|
|
78
108
|
cursor: pointer;
|
|
109
|
+
transition:
|
|
110
|
+
background-color 120ms ease,
|
|
111
|
+
color 120ms ease;
|
|
112
|
+
|
|
113
|
+
> svg {
|
|
114
|
+
flex: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&:hover:not(:disabled) {
|
|
118
|
+
background: var(--theme-elevation-100);
|
|
119
|
+
color: var(--theme-text);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:focus-visible {
|
|
123
|
+
outline: 2px solid var(--be-accent, var(--theme-success-500));
|
|
124
|
+
outline-offset: 1px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&:disabled {
|
|
128
|
+
opacity: 0.5;
|
|
129
|
+
cursor: not-allowed;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Two add actions side by side ("Add condition", "Add “or” group").
|
|
134
|
+
.builder-add-row {
|
|
135
|
+
display: flex;
|
|
136
|
+
flex-wrap: wrap;
|
|
137
|
+
align-self: stretch;
|
|
138
|
+
gap: 2px 4px;
|
|
139
|
+
|
|
140
|
+
> .builder-add + .builder-add {
|
|
141
|
+
margin-left: 0;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// `admin.custom.builderHeading`: a small heading that starts a group of fields (the collection
|
|
146
|
+
// list's Filter, Sort and count, Pages). More space above it than below.
|
|
147
|
+
.builder-field-heading {
|
|
148
|
+
margin: calc(var(--base) * 0.5) 0 calc(var(--base) * -0.25);
|
|
149
|
+
padding-top: calc(var(--base) * 0.75);
|
|
150
|
+
border-top: 1px solid var(--theme-elevation-100);
|
|
151
|
+
color: var(--theme-elevation-600);
|
|
152
|
+
font-size: var(--be-text-s);
|
|
153
|
+
font-weight: var(--be-weight-strong);
|
|
154
|
+
line-height: 1.2;
|
|
155
|
+
letter-spacing: 0.04em;
|
|
156
|
+
text-transform: uppercase;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// One short line under a control ("Works only in a template.").
|
|
160
|
+
.builder-field-note {
|
|
161
|
+
margin: 4px 0 0;
|
|
162
|
+
color: var(--theme-elevation-600);
|
|
163
|
+
font-size: var(--be-text-m);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// The list's sort (SortField) and "Related to this page" (RelatedField): a label over selects.
|
|
167
|
+
.builder-sort,
|
|
168
|
+
.builder-related {
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-direction: column;
|
|
171
|
+
min-width: 0;
|
|
172
|
+
|
|
173
|
+
.field-label {
|
|
174
|
+
margin-bottom: calc(var(--base) * 0.25);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Field and direction side by side; one select alone fills the row.
|
|
179
|
+
.builder-sort__row {
|
|
180
|
+
display: flex;
|
|
181
|
+
gap: 4px;
|
|
182
|
+
min-width: 0;
|
|
183
|
+
|
|
184
|
+
> * {
|
|
185
|
+
flex: 1 1 0;
|
|
186
|
+
min-width: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
> :first-child {
|
|
190
|
+
flex-grow: 1.4;
|
|
191
|
+
}
|
|
79
192
|
}
|
|
80
193
|
|
|
81
194
|
.builder-where__row {
|
|
82
195
|
display: grid;
|
|
83
|
-
|
|
196
|
+
// Field, operator and remove on the first line; the value under them (ConditionRows).
|
|
197
|
+
grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
|
|
84
198
|
align-items: center;
|
|
85
199
|
align-self: stretch;
|
|
86
200
|
gap: 4px;
|
|
@@ -90,6 +204,110 @@
|
|
|
90
204
|
border: 0;
|
|
91
205
|
}
|
|
92
206
|
|
|
207
|
+
// Two inputs and a remove button (QueryFiltersField: URL parameter, field).
|
|
208
|
+
.builder-where__row--pair {
|
|
209
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// The value line of a condition row: where the value comes from, then the value input.
|
|
213
|
+
.builder-where__value {
|
|
214
|
+
display: flex;
|
|
215
|
+
grid-column: 1 / 3;
|
|
216
|
+
align-items: center;
|
|
217
|
+
gap: 4px;
|
|
218
|
+
min-width: 0;
|
|
219
|
+
|
|
220
|
+
> * {
|
|
221
|
+
flex: 1 1 0;
|
|
222
|
+
min-width: 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
> .builder-where__source {
|
|
226
|
+
flex: 0 0 auto;
|
|
227
|
+
max-width: 45%;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.builder-where__inline {
|
|
232
|
+
display: flex;
|
|
233
|
+
align-items: center;
|
|
234
|
+
gap: 4px;
|
|
235
|
+
min-width: 0;
|
|
236
|
+
|
|
237
|
+
> * {
|
|
238
|
+
flex: 1 1 auto;
|
|
239
|
+
min-width: 0;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.builder-where__prefix,
|
|
244
|
+
.builder-where__suffix {
|
|
245
|
+
flex: none !important;
|
|
246
|
+
color: var(--theme-elevation-600);
|
|
247
|
+
font-size: var(--be-text-m);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.builder-where__input--amount {
|
|
251
|
+
flex: 0 0 calc(var(--base) * 3.5) !important;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Payload's own inputs in a row (the document picker, a select of several options): no label, no field margin.
|
|
255
|
+
.builder-where__payload {
|
|
256
|
+
margin: 0;
|
|
257
|
+
|
|
258
|
+
.field-label {
|
|
259
|
+
display: none;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// "Or" groups of "and" rows (ConditionRows).
|
|
264
|
+
.builder-conditions {
|
|
265
|
+
display: flex;
|
|
266
|
+
flex-direction: column;
|
|
267
|
+
gap: calc(var(--base) * 0.4);
|
|
268
|
+
align-items: flex-start;
|
|
269
|
+
align-self: stretch;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.builder-conditions__group {
|
|
273
|
+
display: flex;
|
|
274
|
+
flex-direction: column;
|
|
275
|
+
gap: calc(var(--base) * 0.4);
|
|
276
|
+
align-items: flex-start;
|
|
277
|
+
align-self: stretch;
|
|
278
|
+
min-width: 0;
|
|
279
|
+
margin: 0;
|
|
280
|
+
padding: 0;
|
|
281
|
+
border: 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.builder-conditions__group--boxed {
|
|
285
|
+
padding: calc(var(--base) * 0.5);
|
|
286
|
+
border: 1px solid var(--theme-elevation-150);
|
|
287
|
+
border-radius: var(--style-radius-m);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.builder-conditions__legend {
|
|
291
|
+
padding: 0 4px;
|
|
292
|
+
color: var(--theme-elevation-600);
|
|
293
|
+
font-size: var(--be-text-s);
|
|
294
|
+
font-weight: var(--be-weight-strong);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.builder-conditions__and,
|
|
298
|
+
.builder-conditions__or {
|
|
299
|
+
margin: 0;
|
|
300
|
+
color: var(--theme-elevation-600);
|
|
301
|
+
font-size: var(--be-text-s);
|
|
302
|
+
font-weight: var(--be-weight-strong);
|
|
303
|
+
text-transform: uppercase;
|
|
304
|
+
letter-spacing: 0.04em;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.builder-conditions__or {
|
|
308
|
+
align-self: center;
|
|
309
|
+
}
|
|
310
|
+
|
|
93
311
|
.builder-where__input {
|
|
94
312
|
box-sizing: border-box;
|
|
95
313
|
width: 100%;
|
|
@@ -110,21 +328,26 @@
|
|
|
110
328
|
}
|
|
111
329
|
|
|
112
330
|
.builder-where__remove {
|
|
113
|
-
|
|
114
|
-
|
|
331
|
+
display: inline-grid;
|
|
332
|
+
place-items: center;
|
|
333
|
+
width: 26px;
|
|
334
|
+
height: 26px;
|
|
115
335
|
padding: 0;
|
|
116
336
|
border: 0;
|
|
117
337
|
border-radius: var(--style-radius-s);
|
|
118
338
|
background: none;
|
|
119
339
|
color: var(--theme-elevation-600);
|
|
120
|
-
font-size: 18px;
|
|
121
|
-
line-height: 1;
|
|
122
340
|
cursor: pointer;
|
|
123
341
|
|
|
124
342
|
&:hover {
|
|
125
343
|
background: var(--theme-elevation-100);
|
|
126
344
|
color: var(--theme-elevation-900);
|
|
127
345
|
}
|
|
346
|
+
|
|
347
|
+
&:focus-visible {
|
|
348
|
+
outline: 2px solid var(--be-accent, var(--theme-success-500));
|
|
349
|
+
outline-offset: 1px;
|
|
350
|
+
}
|
|
128
351
|
}
|
|
129
352
|
|
|
130
353
|
.builder-field-group__fields {
|
|
@@ -158,7 +381,7 @@
|
|
|
158
381
|
align-self: stretch;
|
|
159
382
|
}
|
|
160
383
|
|
|
161
|
-
> .
|
|
384
|
+
> .builder-add {
|
|
162
385
|
align-self: flex-start;
|
|
163
386
|
}
|
|
164
387
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type DataField } from '../../../core/fields.js';
|
|
2
|
+
export declare const RANDOM_SORT = "$random";
|
|
3
|
+
/** A stored sort, read: a field and a direction, or random. Null for no sort. */
|
|
4
|
+
export type SortChoice = {
|
|
5
|
+
field: string;
|
|
6
|
+
descending: boolean;
|
|
7
|
+
} | 'random' | null;
|
|
8
|
+
export declare function parseSort(value: unknown): SortChoice;
|
|
9
|
+
export declare function sortValue(choice: SortChoice): string | null;
|
|
10
|
+
export type SortFieldOption = {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
/** The fields of a collection that a list can sort by, then the timestamps when they are missing. */
|
|
16
|
+
export declare function sortFieldOptions(fields: readonly DataField[]): SortFieldOption[];
|
|
17
|
+
/** The two directions of a field, in words that fit its type: [ascending, descending]. */
|
|
18
|
+
export declare function directionLabels(type: string | undefined): [string, string];
|
|
19
|
+
export type RelatedMode = 'current' | 'shared' | 'linked';
|
|
20
|
+
export type RelatedChoice = {
|
|
21
|
+
mode: RelatedMode;
|
|
22
|
+
field: string;
|
|
23
|
+
};
|
|
24
|
+
export type RelatedOption = RelatedChoice & {
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const relatedKey: (choice: RelatedChoice) => string;
|
|
28
|
+
export declare function parseRelatedKey(key: string | null): RelatedChoice | null;
|
|
29
|
+
/** The stored props as a choice, or null when there is no filter field. */
|
|
30
|
+
export declare function relatedChoice(filterField: unknown, filterBy: unknown): RelatedChoice | null;
|
|
31
|
+
/** The option label of a choice, in words: the relating field and how it relates. */
|
|
32
|
+
export declare function relatedLabel(mode: RelatedMode, fieldLabel: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* The ways a list of `listed` documents can relate to the page's document (a `page` document):
|
|
35
|
+
* a field of each listed document that links to the page ("current"), a field of the page that
|
|
36
|
+
* links to the listed documents ("linked"), and a field both have with a value in common ("shared").
|
|
37
|
+
*/
|
|
38
|
+
export declare function relatedOptions(listed: {
|
|
39
|
+
slug: string;
|
|
40
|
+
fields: readonly DataField[];
|
|
41
|
+
}, page: {
|
|
42
|
+
slug: string;
|
|
43
|
+
fields: readonly DataField[];
|
|
44
|
+
}): RelatedOption[];
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// The collection list's sort and "Related to this page" controls <-> their stored props. Pure, so
|
|
2
|
+
// it is tested without React. The stored formats stay as they were: `sort` is a field name with an
|
|
3
|
+
// optional "-" for descending, or "$random"; `filterField` + `filterBy` name the relating field.
|
|
4
|
+
import { textOf } from '../../../core/fields.js';
|
|
5
|
+
export const RANDOM_SORT = '$random';
|
|
6
|
+
export function parseSort(value) {
|
|
7
|
+
if (typeof value !== 'string' || !value.trim())
|
|
8
|
+
return null;
|
|
9
|
+
const text = value.trim();
|
|
10
|
+
if (text === RANDOM_SORT)
|
|
11
|
+
return 'random';
|
|
12
|
+
return text.startsWith('-') ? { field: text.slice(1), descending: true } : { field: text, descending: false };
|
|
13
|
+
}
|
|
14
|
+
export function sortValue(choice) {
|
|
15
|
+
if (choice === null)
|
|
16
|
+
return null;
|
|
17
|
+
if (choice === 'random')
|
|
18
|
+
return RANDOM_SORT;
|
|
19
|
+
return `${choice.descending ? '-' : ''}${choice.field}`;
|
|
20
|
+
}
|
|
21
|
+
/** Field types a query can sort on. A field with many values cannot sort. */
|
|
22
|
+
const SORTABLE = new Set(['text', 'textarea', 'email', 'number', 'date', 'select', 'radio', 'checkbox']);
|
|
23
|
+
/** Payload adds these to every collection with timestamps; the client config may leave them out. */
|
|
24
|
+
const TIMESTAMPS = [
|
|
25
|
+
{ value: 'createdAt', label: 'Created', type: 'date' },
|
|
26
|
+
{ value: 'updatedAt', label: 'Updated', type: 'date' },
|
|
27
|
+
];
|
|
28
|
+
/** The fields of a collection that a list can sort by, then the timestamps when they are missing. */
|
|
29
|
+
export function sortFieldOptions(fields) {
|
|
30
|
+
const out = fields
|
|
31
|
+
.filter((f) => SORTABLE.has(f.type) && !f.hasMany)
|
|
32
|
+
.map((f) => ({ value: f.name, label: textOf(f.label) ?? f.name, type: f.type }));
|
|
33
|
+
for (const stamp of TIMESTAMPS)
|
|
34
|
+
if (!out.some((o) => o.value === stamp.value))
|
|
35
|
+
out.push(stamp);
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
/** The two directions of a field, in words that fit its type: [ascending, descending]. */
|
|
39
|
+
export function directionLabels(type) {
|
|
40
|
+
switch (type) {
|
|
41
|
+
case 'date':
|
|
42
|
+
return ['Oldest first', 'Newest first'];
|
|
43
|
+
case 'number':
|
|
44
|
+
return ['Lowest first', 'Highest first'];
|
|
45
|
+
case 'text':
|
|
46
|
+
case 'textarea':
|
|
47
|
+
case 'email':
|
|
48
|
+
case 'select':
|
|
49
|
+
case 'radio':
|
|
50
|
+
return ['A to Z', 'Z to A'];
|
|
51
|
+
case 'checkbox':
|
|
52
|
+
return ['Unchecked first', 'Checked first'];
|
|
53
|
+
default:
|
|
54
|
+
return ['Ascending', 'Descending'];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const MODES = ['current', 'linked', 'shared'];
|
|
58
|
+
export const relatedKey = (choice) => `${choice.mode}:${choice.field}`;
|
|
59
|
+
export function parseRelatedKey(key) {
|
|
60
|
+
if (!key)
|
|
61
|
+
return null;
|
|
62
|
+
const at = key.indexOf(':');
|
|
63
|
+
const mode = key.slice(0, at);
|
|
64
|
+
return at > 0 && MODES.includes(mode) ? { mode, field: key.slice(at + 1) } : null;
|
|
65
|
+
}
|
|
66
|
+
/** The stored props as a choice, or null when there is no filter field. */
|
|
67
|
+
export function relatedChoice(filterField, filterBy) {
|
|
68
|
+
const field = typeof filterField === 'string' ? filterField.trim() : '';
|
|
69
|
+
if (!field)
|
|
70
|
+
return null;
|
|
71
|
+
const mode = MODES.includes(filterBy) ? filterBy : 'current';
|
|
72
|
+
return { mode, field };
|
|
73
|
+
}
|
|
74
|
+
/** The option label of a choice, in words: the relating field and how it relates. */
|
|
75
|
+
export function relatedLabel(mode, fieldLabel) {
|
|
76
|
+
if (mode === 'current')
|
|
77
|
+
return `${fieldLabel} links to this page`;
|
|
78
|
+
if (mode === 'linked')
|
|
79
|
+
return `In this page’s ${fieldLabel}`;
|
|
80
|
+
return `Same ${fieldLabel} as this page`;
|
|
81
|
+
}
|
|
82
|
+
const RELATIONS = new Set(['relationship', 'upload']);
|
|
83
|
+
const SHAREABLE = new Set(['relationship', 'upload', 'select', 'radio', 'text', 'number', 'email']);
|
|
84
|
+
/** Fields every document has, which never relate two documents. */
|
|
85
|
+
const OWN = new Set(['id', 'createdAt', 'updatedAt', '_status', 'slug']);
|
|
86
|
+
const relatesTo = (field, slug) => RELATIONS.has(field.type) && (Array.isArray(field.relationTo) ? field.relationTo.includes(slug) : field.relationTo === slug);
|
|
87
|
+
const labelOf = (field) => textOf(field.label) ?? field.name;
|
|
88
|
+
/**
|
|
89
|
+
* The ways a list of `listed` documents can relate to the page's document (a `page` document):
|
|
90
|
+
* a field of each listed document that links to the page ("current"), a field of the page that
|
|
91
|
+
* links to the listed documents ("linked"), and a field both have with a value in common ("shared").
|
|
92
|
+
*/
|
|
93
|
+
export function relatedOptions(listed, page) {
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const field of listed.fields) {
|
|
96
|
+
if (relatesTo(field, page.slug))
|
|
97
|
+
out.push({ mode: 'current', field: field.name, label: relatedLabel('current', labelOf(field)) });
|
|
98
|
+
}
|
|
99
|
+
for (const field of page.fields) {
|
|
100
|
+
if (relatesTo(field, listed.slug))
|
|
101
|
+
out.push({ mode: 'linked', field: field.name, label: relatedLabel('linked', labelOf(field)) });
|
|
102
|
+
}
|
|
103
|
+
for (const field of listed.fields) {
|
|
104
|
+
if (OWN.has(field.name) || !SHAREABLE.has(field.type))
|
|
105
|
+
continue;
|
|
106
|
+
const other = page.fields.find((f) => f.name === field.name && f.type === field.type);
|
|
107
|
+
if (other)
|
|
108
|
+
out.push({ mode: 'shared', field: field.name, label: relatedLabel('shared', labelOf(field)) });
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type QueryFilterRow = {
|
|
2
|
+
param: string;
|
|
3
|
+
field: string;
|
|
4
|
+
};
|
|
5
|
+
/** The rows of stored `queryFilters`: empty for none, null when one param uses the full form. */
|
|
6
|
+
export declare function queryFilterRows(value: unknown): QueryFilterRow[] | null;
|
|
7
|
+
/** The `queryFilters` of the rows. Rows without a parameter are left out. `undefined` for none. */
|
|
8
|
+
export declare function rowsQueryFilters(rows: readonly QueryFilterRow[]): Record<string, string> | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The URL filter rows (URL parameter, field) <-> a collection list's `queryFilters`. Pure, so it is
|
|
2
|
+
// tested without React. A row stores the short form `{ [param]: field }`: the field equals the URL
|
|
3
|
+
// value. A value with the full form (`{ [param]: { [value]: where } }`) returns null from
|
|
4
|
+
// `queryFilterRows`, and the field shows JSON.
|
|
5
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
6
|
+
/** The rows of stored `queryFilters`: empty for none, null when one param uses the full form. */
|
|
7
|
+
export function queryFilterRows(value) {
|
|
8
|
+
if (value === undefined || value === null)
|
|
9
|
+
return [];
|
|
10
|
+
if (!isRecord(value))
|
|
11
|
+
return null;
|
|
12
|
+
const rows = [];
|
|
13
|
+
for (const [param, field] of Object.entries(value)) {
|
|
14
|
+
if (typeof field !== 'string')
|
|
15
|
+
return null;
|
|
16
|
+
rows.push({ param, field });
|
|
17
|
+
}
|
|
18
|
+
return rows;
|
|
19
|
+
}
|
|
20
|
+
/** The `queryFilters` of the rows. Rows without a parameter are left out. `undefined` for none. */
|
|
21
|
+
export function rowsQueryFilters(rows) {
|
|
22
|
+
const out = {};
|
|
23
|
+
for (const row of rows) {
|
|
24
|
+
const param = row.param.trim();
|
|
25
|
+
if (param)
|
|
26
|
+
out[param] = row.field.trim();
|
|
27
|
+
}
|
|
28
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
29
|
+
}
|
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
export type WhereOperator = (typeof WHERE_OPERATORS)[number];
|
|
1
|
+
import type { VisibilityOperator } from '../../../core/visibility.js';
|
|
3
2
|
/** One condition. `value` is the stored value (a string, number, boolean, or a list for in/not_in). */
|
|
4
3
|
export type WhereRow = {
|
|
5
4
|
field: string;
|
|
6
|
-
operator:
|
|
5
|
+
operator: VisibilityOperator | (string & {});
|
|
7
6
|
value: unknown;
|
|
8
7
|
};
|
|
9
8
|
/**
|
|
10
|
-
* The
|
|
11
|
-
* `{ a: { equals: 1 }, b:
|
|
9
|
+
* The groups of a stored where: none for no where, null when the builder cannot show it. Takes
|
|
10
|
+
* one group (`{ a: { equals: 1 }, b: … }` or `{ and: [...] }`) or `{ or: [group, …] }`.
|
|
12
11
|
*/
|
|
13
|
-
export declare function
|
|
12
|
+
export declare function whereGroups(where: unknown): WhereRow[][] | null;
|
|
14
13
|
/**
|
|
15
|
-
* The where of
|
|
16
|
-
* has the same operator twice. Rows without a field are left out. `undefined` for no rows.
|
|
14
|
+
* The where of one group: one object `{ field: { op: value } }`, or `{ and: [...] }` when a
|
|
15
|
+
* field has the same operator twice. Rows without a field are left out. `undefined` for no rows.
|
|
17
16
|
*/
|
|
18
17
|
export declare function rowsWhere(rows: readonly WhereRow[]): Record<string, unknown> | undefined;
|
|
18
|
+
/** The where of the groups: one group as `rowsWhere`, several as `{ or: [...] }`. Empty groups are left out. */
|
|
19
|
+
export declare function groupsWhere(groups: readonly WhereRow[][]): Record<string, unknown> | undefined;
|
|
19
20
|
/** The text a value shows in the value input: lists as "a, b". */
|
|
20
21
|
export declare const whereValueText: (value: unknown) => string;
|
|
21
22
|
/**
|
|
22
23
|
* The value to store for typed text. `fieldType` is the Payload field type when known: numbers
|
|
23
24
|
* become numbers and checkboxes booleans; any other text stays text (so "0412" stays a string).
|
|
24
|
-
* `in` and `not_in` split on commas. `
|
|
25
|
+
* `in` and `not_in` split on commas. `is_set` and `is_empty` take no value.
|
|
25
26
|
*/
|
|
26
|
-
export declare function parseWhereValue(text: string, operator:
|
|
27
|
-
/** The value a row keeps when its operator changes: re-read from its text for the new operator. */
|
|
28
|
-
export declare const convertWhereValue: (row: WhereRow, operator: WhereOperator, fieldType?: string) => unknown;
|
|
27
|
+
export declare function parseWhereValue(text: string, operator: string, fieldType?: string): unknown;
|