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
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// script already forwards undo, redo, delete and escape; this module adds the rest there.
|
|
4
4
|
import { keyAction } from '../../protocol/index.js';
|
|
5
5
|
import { findLocation } from '../../core/index.js';
|
|
6
|
+
import { CONTENT_MODE_MESSAGE } from '../../core/contentMode.js';
|
|
7
|
+
import { contentModeAllows } from './contentMode.js';
|
|
6
8
|
import { copySelection, copyStyles, duplicateBlock, moveBy, parseClipboard, pasteBlocks, pasteStyles, removeBlock, storedClipboard, toggleHidden, } from './actions.js';
|
|
7
9
|
import { startInlineEditing, startRegionEditing } from './inline.js';
|
|
8
10
|
import { leftTabForDigit, selectLeftTab } from './layout/leftTabs.js';
|
|
@@ -73,6 +75,8 @@ export function editorAction(e) {
|
|
|
73
75
|
return 'editText';
|
|
74
76
|
if (!mod && !e.altKey && e.key === '?')
|
|
75
77
|
return 'help';
|
|
78
|
+
if (!mod && !e.altKey && !e.shiftKey && letter === 'c')
|
|
79
|
+
return 'comments';
|
|
76
80
|
return null;
|
|
77
81
|
}
|
|
78
82
|
/** The Publish shortcut: key caps, the text for a tooltip ("Ctrl+Alt+P", "⌘⌥P") and `aria-keyshortcuts`. */
|
|
@@ -85,11 +89,12 @@ export function publishShortcut() {
|
|
|
85
89
|
* Key caps for the shortcut help, with the platform's modifier key. `ai` adds the assistant
|
|
86
90
|
* shortcut, `publish` the Publish shortcut (collections with drafts).
|
|
87
91
|
*/
|
|
88
|
-
export function shortcutList({ ai = false, publish = false } = {}) {
|
|
92
|
+
export function shortcutList({ ai = false, publish = false, comments = false } = {}) {
|
|
89
93
|
const mod = isMac() ? '⌘' : 'Ctrl';
|
|
90
94
|
return [
|
|
91
95
|
...(publish ? [{ keys: publishShortcut().keys, label: 'Publish changes' }] : []),
|
|
92
96
|
...(ai ? [{ keys: [mod, 'I'], label: 'Open or close the AI assistant' }] : []),
|
|
97
|
+
...(comments ? [{ keys: ['C'], label: 'Comment mode' }] : []),
|
|
93
98
|
{ keys: [mod, 'Z'], label: 'Undo' },
|
|
94
99
|
{ keys: [mod, 'Shift', 'Z'], label: 'Redo' },
|
|
95
100
|
{ keys: [mod, 'C'], label: 'Copy block' },
|
|
@@ -142,7 +147,13 @@ export function bindShortcuts(runtime, doc, { forwarded }) {
|
|
|
142
147
|
/** Set when a key opened the block menu: the browser's own `contextmenu` event for that key is dropped. */
|
|
143
148
|
let menuKeyAt = 0;
|
|
144
149
|
const run = (action) => {
|
|
145
|
-
const { selectedId } = runtime.store.getState();
|
|
150
|
+
const { selectedId, layout } = runtime.store.getState();
|
|
151
|
+
// Content mode: only content changes, plus the items of a block that lets editors manage them.
|
|
152
|
+
if (runtime.contentMode.get() && !contentModeAllows(action, layout, selectedId)) {
|
|
153
|
+
if (selectedId && !isPanelAction(action))
|
|
154
|
+
runtime.notify(CONTENT_MODE_MESSAGE);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
146
157
|
switch (action) {
|
|
147
158
|
case 'copy':
|
|
148
159
|
// Local storage and the async clipboard API now; the native `copy` event below fills the
|
|
@@ -186,6 +197,9 @@ export function bindShortcuts(runtime, doc, { forwarded }) {
|
|
|
186
197
|
case 'assistant':
|
|
187
198
|
runtime.toggleAssistant();
|
|
188
199
|
return;
|
|
200
|
+
case 'comments':
|
|
201
|
+
runtime.comments?.toggle();
|
|
202
|
+
return;
|
|
189
203
|
case 'editText': {
|
|
190
204
|
if (selectedId)
|
|
191
205
|
startInlineEditing(runtime, selectedId);
|
|
@@ -251,6 +265,8 @@ export function bindShortcuts(runtime, doc, { forwarded }) {
|
|
|
251
265
|
return;
|
|
252
266
|
if (action === 'assistant' && !runtime.assistant)
|
|
253
267
|
return;
|
|
268
|
+
if (action === 'comments' && !runtime.comments)
|
|
269
|
+
return;
|
|
254
270
|
// Collections without drafts have no Publish.
|
|
255
271
|
if (action === 'publish' && !runtime.doc.meta.get().drafts)
|
|
256
272
|
return;
|
|
@@ -302,7 +318,7 @@ export function bindShortcuts(runtime, doc, { forwarded }) {
|
|
|
302
318
|
const text = e.clipboardData?.getData('text/plain');
|
|
303
319
|
// An empty clipboard (or no access to it): use the copy in local storage.
|
|
304
320
|
const blocks = parseClipboard(text || storedClipboard());
|
|
305
|
-
if (!blocks)
|
|
321
|
+
if (!blocks || runtime.contentMode.get())
|
|
306
322
|
return;
|
|
307
323
|
e.preventDefault();
|
|
308
324
|
pasteBlocks(runtime, blocks);
|
|
@@ -17,9 +17,20 @@ export type FieldEdit = {
|
|
|
17
17
|
*/
|
|
18
18
|
export type FieldWriteResult = boolean | 'retry';
|
|
19
19
|
export type FieldWriter = (changes: LiveFieldChange[], locale: string | null) => Promise<FieldWriteResult>;
|
|
20
|
+
/**
|
|
21
|
+
* An undo step outside the layout and the document (a shared class's styles): undo hands `before`
|
|
22
|
+
* to `apply`, redo `after`. Steps with the same merge key within a second merge (a slider drag).
|
|
23
|
+
*/
|
|
24
|
+
export type ExternalStep = {
|
|
25
|
+
before: unknown;
|
|
26
|
+
after: unknown;
|
|
27
|
+
apply: (value: unknown) => void;
|
|
28
|
+
};
|
|
20
29
|
type HistoryEntry = {
|
|
21
30
|
/** Applied in order, these undo (or redo) one user action. */
|
|
22
31
|
ops: Operation[];
|
|
32
|
+
/** A step outside the layout (see `ExternalStep`). */
|
|
33
|
+
external?: ExternalStep;
|
|
23
34
|
/**
|
|
24
35
|
* A step of document field changes (a region's text or image), saved to the document instead of
|
|
25
36
|
* applied to the layout. Undo writes `before` back, redo `after`; each expects the other value
|
|
@@ -160,8 +171,15 @@ export declare function createEditorStore(initial: Layout, options?: EditorStore
|
|
|
160
171
|
* Records the action immediately. `saved` replaces its values after hooks, or removes a failed save.
|
|
161
172
|
*/
|
|
162
173
|
recordFields(edits: FieldEdit[], locale?: string | null, saved?: Promise<FieldEdit[] | null>): void;
|
|
174
|
+
/**
|
|
175
|
+
* Records a step outside the layout (a class edit), already applied. Steps with the same
|
|
176
|
+
* `mergeKey` within a second become one: undo restores the value before the first.
|
|
177
|
+
*/
|
|
178
|
+
recordExternal(step: ExternalStep, mergeKey?: string): void;
|
|
163
179
|
/** Saves the field changes of undo and redo. Without one, field steps cannot be undone. */
|
|
164
180
|
setFieldWriter(writer: FieldWriter | null): void;
|
|
181
|
+
/** Sets the check that refuses own edits by their result (content mode), or null for none. */
|
|
182
|
+
setEditGuard(guard: ((before: Layout, after: Layout) => string | null) | null): void;
|
|
165
183
|
/**
|
|
166
184
|
* Ends the current merge run: the next edit starts a new undo step even with the same
|
|
167
185
|
* `mergeKey` (a text field lost the focus). Groups are not affected.
|
|
@@ -84,6 +84,8 @@ export function createEditorStore(initial, options = {}) {
|
|
|
84
84
|
let tagCounter = 0;
|
|
85
85
|
const nextTag = () => `t${++tagCounter}`;
|
|
86
86
|
let fieldWriter = null;
|
|
87
|
+
/** Refuses an own edit by its result (content mode). Null: every edit may apply. */
|
|
88
|
+
let editGuard = null;
|
|
87
89
|
let historyBusy = false;
|
|
88
90
|
let historyGeneration = 0;
|
|
89
91
|
let editGeneration = 0;
|
|
@@ -141,6 +143,14 @@ export function createEditorStore(initial, options = {}) {
|
|
|
141
143
|
for (const listener of warnings)
|
|
142
144
|
listener(text);
|
|
143
145
|
};
|
|
146
|
+
/** Undoes or redoes a step outside the layout: it applies at once, nothing to wait for. */
|
|
147
|
+
const externalStep = (entry, direction) => {
|
|
148
|
+
const step = entry.external;
|
|
149
|
+
const source = direction === 'undo' ? 'undoStack' : 'redoStack';
|
|
150
|
+
const destination = direction === 'undo' ? 'redoStack' : 'undoStack';
|
|
151
|
+
step.apply(direction === 'undo' ? step.before : step.after);
|
|
152
|
+
set({ [source]: state[source].slice(0, -1), [destination]: [...state[destination], entry], lastError: null });
|
|
153
|
+
};
|
|
144
154
|
const set = (patch) => {
|
|
145
155
|
const before = state;
|
|
146
156
|
state = { ...state, ...patch };
|
|
@@ -251,6 +261,15 @@ export function createEditorStore(initial, options = {}) {
|
|
|
251
261
|
return false;
|
|
252
262
|
}
|
|
253
263
|
}
|
|
264
|
+
if (editGuard) {
|
|
265
|
+
// Content mode: a design change is refused here, before the server would refuse it.
|
|
266
|
+
const next = applyOperations(state.layout, list);
|
|
267
|
+
const problem = next.ok ? editGuard(state.layout, next.layout) : null;
|
|
268
|
+
if (problem) {
|
|
269
|
+
set({ lastError: problem });
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
254
273
|
const tag = nextTag();
|
|
255
274
|
const result = sync.local(list, tag);
|
|
256
275
|
if (!result.ok) {
|
|
@@ -317,6 +336,10 @@ export function createEditorStore(initial, options = {}) {
|
|
|
317
336
|
const entry = state.undoStack.at(-1);
|
|
318
337
|
if (!entry)
|
|
319
338
|
return;
|
|
339
|
+
if (entry.external) {
|
|
340
|
+
externalStep(entry, 'undo');
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
320
343
|
if (entry.fields) {
|
|
321
344
|
fieldStep(entry, 'undo');
|
|
322
345
|
return;
|
|
@@ -342,6 +365,10 @@ export function createEditorStore(initial, options = {}) {
|
|
|
342
365
|
const entry = state.redoStack.at(-1);
|
|
343
366
|
if (!entry)
|
|
344
367
|
return;
|
|
368
|
+
if (entry.external) {
|
|
369
|
+
externalStep(entry, 'redo');
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
345
372
|
if (entry.fields) {
|
|
346
373
|
fieldStep(entry, 'redo');
|
|
347
374
|
return;
|
|
@@ -377,10 +404,29 @@ export function createEditorStore(initial, options = {}) {
|
|
|
377
404
|
});
|
|
378
405
|
set({ undoStack: [...state.undoStack, entry].slice(-HISTORY_LIMIT), redoStack: [] });
|
|
379
406
|
},
|
|
407
|
+
/**
|
|
408
|
+
* Records a step outside the layout (a class edit), already applied. Steps with the same
|
|
409
|
+
* `mergeKey` within a second become one: undo restores the value before the first.
|
|
410
|
+
*/
|
|
411
|
+
recordExternal(step, mergeKey) {
|
|
412
|
+
editGeneration++;
|
|
413
|
+
const now = Date.now();
|
|
414
|
+
const top = state.undoStack.at(-1);
|
|
415
|
+
if (mergeKey && top?.external && top.mergeKey === mergeKey && now - top.at < MERGE_WINDOW_MS) {
|
|
416
|
+
set({ undoStack: [...state.undoStack.slice(0, -1), { ...top, external: { ...top.external, after: step.after }, at: now }], redoStack: [] });
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const entry = { ops: [], external: step, selectedId: state.selectedId, mergeKey, tags: [], at: now };
|
|
420
|
+
set({ undoStack: [...state.undoStack, entry].slice(-HISTORY_LIMIT), redoStack: [] });
|
|
421
|
+
},
|
|
380
422
|
/** Saves the field changes of undo and redo. Without one, field steps cannot be undone. */
|
|
381
423
|
setFieldWriter(writer) {
|
|
382
424
|
fieldWriter = writer;
|
|
383
425
|
},
|
|
426
|
+
/** Sets the check that refuses own edits by their result (content mode), or null for none. */
|
|
427
|
+
setEditGuard(guard) {
|
|
428
|
+
editGuard = guard;
|
|
429
|
+
},
|
|
384
430
|
/**
|
|
385
431
|
* Ends the current merge run: the next edit starts a new undo step even with the same
|
|
386
432
|
* `mergeKey` (a text field lost the focus). Groups are not affected.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type BuilderClass } from '../../../classes/shared.js';
|
|
2
|
+
import './classes.scss';
|
|
3
|
+
/** `className`: the block's (or part's) own classes. `own`: the editable classes among them. */
|
|
4
|
+
export declare function ClassBar({ className, own }: {
|
|
5
|
+
className: string;
|
|
6
|
+
own: BuilderClass[];
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* Under the controls while they edit a class: the classes in the class that no control shows,
|
|
10
|
+
* in the same chips as the block's field.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ClassExtras({ item }: {
|
|
13
|
+
item: BuilderClass;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The top of the Styles panel: the one classes field of the block (or part), its "⋯" menu, and
|
|
4
|
+
// while the controls edit an editable class, a short banner with how far a change reaches and
|
|
5
|
+
// Publish, Rename and Delete. `ClassChips` (RawClasses.tsx) draws the field.
|
|
6
|
+
import { useModal } from '@payloadcms/ui';
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
8
|
+
import { plural, usageText } from '../../../classes/shared.js';
|
|
9
|
+
import { CLASS_MANAGER_SLUG } from '../classes/ClassManager.js';
|
|
10
|
+
import { Icon } from '../icons.js';
|
|
11
|
+
import { MenuButton } from '../menu/Menu.js';
|
|
12
|
+
import { useRuntime } from '../runtime.js';
|
|
13
|
+
import { useValue } from '../valueStore.js';
|
|
14
|
+
import { useStyles, writeClassName } from './context.js';
|
|
15
|
+
import { ResetIcon } from './icons.js';
|
|
16
|
+
import { ClassChips, ClassText } from './RawClasses.js';
|
|
17
|
+
import './classes.scss';
|
|
18
|
+
const sentence = (text) => `${text.charAt(0).toUpperCase()}${text.slice(1)}.`;
|
|
19
|
+
/** `className`: the block's (or part's) own classes. `own`: the editable classes among them. */
|
|
20
|
+
export function ClassBar({ className, own }) {
|
|
21
|
+
const runtime = useRuntime();
|
|
22
|
+
const classes = runtime.classes;
|
|
23
|
+
const { blockId, part, editingClass: editing, tokens } = useStyles();
|
|
24
|
+
const [asText, setAsText] = useState(false);
|
|
25
|
+
const { openModal } = useModal();
|
|
26
|
+
const owner = part ? 'this part' : 'this block';
|
|
27
|
+
const label = part ? 'Classes of this part' : 'Classes of this block';
|
|
28
|
+
const write = (next, mergeKey) => writeClassName(runtime, { blockId, part }, next, mergeKey);
|
|
29
|
+
// Code classes (`@utility` in the site's CSS) that are not editable classes yet.
|
|
30
|
+
const codeOnly = classes ? (tokens.siteClasses ?? []).filter((c) => !classes.byName(c.name)).length : 0;
|
|
31
|
+
const menu = () => [
|
|
32
|
+
...(classes
|
|
33
|
+
? [
|
|
34
|
+
{
|
|
35
|
+
label: 'New class from these styles…',
|
|
36
|
+
icon: 'plus',
|
|
37
|
+
ownFocus: true,
|
|
38
|
+
run: () => classes.dialog.set({ kind: 'new', blockId, part }),
|
|
39
|
+
},
|
|
40
|
+
{ label: 'Manage classes…', icon: 'list', ownFocus: true, run: () => openModal(CLASS_MANAGER_SLUG) },
|
|
41
|
+
{
|
|
42
|
+
label: codeOnly > 0 ? `Import ${plural(codeOnly, 'class', 'classes')} from the site’s CSS` : 'Import from the site’s CSS',
|
|
43
|
+
icon: 'paste',
|
|
44
|
+
disabled: codeOnly === 0,
|
|
45
|
+
run: () => void classes.importSite().then((result) => {
|
|
46
|
+
if (typeof result === 'string')
|
|
47
|
+
runtime.warn(`The classes were not imported: ${result}`);
|
|
48
|
+
else
|
|
49
|
+
runtime.notify(`Imported ${plural(result.created, 'class', 'classes')}. Their @utility rules in the site’s CSS can go now.`);
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
'separator',
|
|
53
|
+
]
|
|
54
|
+
: []),
|
|
55
|
+
{ label: 'Edit as text', icon: 'compose', checked: asText, run: () => setAsText(!asText) },
|
|
56
|
+
];
|
|
57
|
+
return (_jsxs("div", { className: "builder-classes", "data-editing": editing ? '' : undefined, children: [_jsxs("div", { className: "builder-classes__head", children: [_jsx("span", { className: "builder-styles__raw-label", "aria-hidden": "true", children: "Classes" }), _jsx(MenuButton, { className: "builder-classes__menu", triggerLabel: "Class actions", tooltip: "New class, manage classes, import, edit as text", label: "Classes", items: menu, children: _jsx(Icon, { name: "more", size: 14 }) })] }), asText ? (_jsx(ClassText, { value: className, onChange: write, label: label })) : (_jsx(ClassChips, { value: className, onChange: (next) => write(next), label: label, owner: owner, editable: own, selected: editing, onSelect: (item) => classes?.target.set(item?.id ?? null) })), editing && classes && _jsx(ClassBanner, { item: editing })] }));
|
|
58
|
+
}
|
|
59
|
+
/** While the controls edit a class: what a change reaches, its save state, Publish and the class actions. */
|
|
60
|
+
function ClassBanner({ item }) {
|
|
61
|
+
const runtime = useRuntime();
|
|
62
|
+
const classes = runtime.classes;
|
|
63
|
+
const usage = useValue(classes.usage);
|
|
64
|
+
const save = useValue(classes.saving).get(String(item.id));
|
|
65
|
+
// Fresh counts each time a class is chosen.
|
|
66
|
+
const id = item.id;
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (id !== null)
|
|
69
|
+
void classes.loadUsage();
|
|
70
|
+
}, [classes, id]);
|
|
71
|
+
const used = usage ? sentence(usageText(usage[item.name])) : 'Counting where it is used…';
|
|
72
|
+
const publish = () => void classes.publish(item.id).then((result) => {
|
|
73
|
+
if (result === true)
|
|
74
|
+
runtime.notify(`Published .${item.name}. The live site uses it now.`);
|
|
75
|
+
else
|
|
76
|
+
runtime.warn(`.${item.name} was not published: ${result}`);
|
|
77
|
+
});
|
|
78
|
+
return (_jsxs("section", { className: "builder-classes__banner", "aria-label": `Editing class .${item.name}`, children: [_jsxs("div", { className: "builder-classes__banner-head", children: [_jsxs("p", { className: "builder-classes__title", children: ["Editing ", _jsxs("code", { children: [".", item.name] })] }), _jsx("button", { type: "button", className: "builder-classes__close", "aria-label": "Stop editing the class", "data-tooltip": "Back to this block", onClick: () => classes.target.set(null), children: _jsx(ResetIcon, {}) })] }), _jsx("p", { className: "builder-classes__text", children: used }), _jsxs("div", { className: "builder-classes__foot", children: [_jsx("output", { className: "builder-classes__state", "data-state": save?.status ?? item.status, children: save?.status === 'saving' ? ('Saving draft…') : save?.status === 'error' ? (_jsxs(_Fragment, { children: ["Not saved: ", save.error, ' ', _jsx("button", { type: "button", className: "builder-styles__link", onClick: () => classes.retry(item.id), children: "Retry" })] })) : item.status === 'draft' ? (_jsx("span", { "data-tooltip": "The live site gets the changes when you publish the class or a page that uses it.", children: "Draft" })) : ('Published') }), _jsx("button", { type: "button", className: "builder-styles__button builder-styles__button--primary", disabled: item.status === 'published' && !save, onClick: publish, children: "Publish class" }), _jsx(MenuButton, { className: "builder-styles__icon-button", triggerLabel: "More class actions", label: "Class actions", items: () => [
|
|
79
|
+
{ label: 'Rename…', icon: 'rename', ownFocus: true, run: () => classes.dialog.set({ kind: 'rename', id: item.id }) },
|
|
80
|
+
{ label: 'Delete…', icon: 'delete', danger: true, ownFocus: true, run: () => classes.dialog.set({ kind: 'delete', id: item.id }) },
|
|
81
|
+
], children: _jsx(Icon, { name: "more", size: 14 }) })] })] }));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Under the controls while they edit a class: the classes in the class that no control shows,
|
|
85
|
+
* in the same chips as the block's field.
|
|
86
|
+
*/
|
|
87
|
+
export function ClassExtras({ item }) {
|
|
88
|
+
const runtime = useRuntime();
|
|
89
|
+
return (_jsxs("div", { className: "builder-classes__extras", children: [_jsxs("span", { className: "builder-styles__raw-label", "aria-hidden": "true", children: ["More classes in .", item.name] }), _jsx(ClassChips, { value: item.styles ?? '', onChange: (next) => runtime.classes?.edit(item.id, 'styles', next || null), label: `More classes in .${item.name}`, owner: `.${item.name}` })] }));
|
|
90
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The edited class's custom CSS: declarations and nested rules inside the class rule, for what
|
|
4
|
+
// Tailwind classes cannot express. Each change applies on the canvas at once; publishing checks it.
|
|
5
|
+
import { useId } from 'react';
|
|
6
|
+
import { cssProblem } from '../../../classes/shared.js';
|
|
7
|
+
import { useRuntime } from '../runtime.js';
|
|
8
|
+
const PLACEHOLDER = `background: linear-gradient(135deg, …), radial-gradient(…);
|
|
9
|
+
&::before {
|
|
10
|
+
content: "";
|
|
11
|
+
}`;
|
|
12
|
+
export function ClassCss({ item }) {
|
|
13
|
+
const runtime = useRuntime();
|
|
14
|
+
const id = useId();
|
|
15
|
+
const value = item.css ?? '';
|
|
16
|
+
const problem = cssProblem(value);
|
|
17
|
+
return (_jsxs("div", { className: "builder-classes__css", children: [_jsx("label", { className: "builder-styles__raw-label", htmlFor: id, children: "Custom CSS" }), _jsx("textarea", { id: id, className: "builder-styles__raw-input builder-classes__css-input", rows: 5, value: value, spellCheck: false, autoComplete: "off", placeholder: PLACEHOLDER, "aria-describedby": `${id}-hint`, "aria-invalid": problem ? true : undefined, onChange: (e) => runtime.classes?.edit(item.id, 'css', e.target.value, `class:${item.id}:css`), onKeyDown: (e) => {
|
|
18
|
+
// Tab indents (two spaces) instead of leaving the box.
|
|
19
|
+
if (e.key !== 'Tab' || e.shiftKey)
|
|
20
|
+
return;
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
const el = e.currentTarget;
|
|
23
|
+
const { selectionStart: start, selectionEnd: end } = el;
|
|
24
|
+
const next = `${el.value.slice(0, start)} ${el.value.slice(end)}`;
|
|
25
|
+
runtime.classes?.edit(item.id, 'css', next, `class:${item.id}:css`);
|
|
26
|
+
requestAnimationFrame(() => el.setSelectionRange(start + 2, start + 2));
|
|
27
|
+
} }), _jsx("p", { id: `${id}-hint`, className: `builder-styles__hint${problem ? ' builder-styles__hint--error' : ''}`, children: problem ?? 'Inside the class rule: declarations, nested rules such as “&:hover { … }” or “&::before { … }”, and @keyframes.' })] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The class dialogs: "New class from this block's styles", Rename, Delete and Remove unused. Payload's own
|
|
4
|
+
// ConfirmationModal and TextInput, as the saved section dialogs. A refused name (taken, a Tailwind
|
|
5
|
+
// class) opens the dialog again with the name and the reason.
|
|
6
|
+
import { ConfirmationModal, TextInput, useModal } from '@payloadcms/ui';
|
|
7
|
+
import { useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { bareClass, classNameProblem, classTokens, plural } from '../../../classes/shared.js';
|
|
9
|
+
import { findBlock } from '../../../core/index.js';
|
|
10
|
+
import { useRuntime } from '../runtime.js';
|
|
11
|
+
import { useModalA11y } from '../ui/modalA11y.js';
|
|
12
|
+
import { useValue } from '../valueStore.js';
|
|
13
|
+
const MODAL_SLUG = 'builder-class-dialog';
|
|
14
|
+
/** Mounted with the Styles panel. Opens Payload's modal whenever a class dialog is requested. */
|
|
15
|
+
export function ClassDialog() {
|
|
16
|
+
const runtime = useRuntime();
|
|
17
|
+
const dialog = useValue(runtime.classes.dialog);
|
|
18
|
+
const { openModal } = useModal();
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (dialog)
|
|
21
|
+
openModal(MODAL_SLUG);
|
|
22
|
+
}, [dialog, openModal]);
|
|
23
|
+
if (!dialog)
|
|
24
|
+
return null;
|
|
25
|
+
// A new request (or the same one with an error) starts with fresh fields.
|
|
26
|
+
return _jsx(DialogContent, { dialog: dialog }, `${dialog.kind}:${'id' in dialog ? dialog.id : 'blockId' in dialog ? dialog.blockId : ''}:${dialog.error ?? ''}`);
|
|
27
|
+
}
|
|
28
|
+
/** The block's (or part's) classes, split into editable classes (they stay) and the rest (they move into the new class). */
|
|
29
|
+
function splitBlockClasses(runtime, blockId, part) {
|
|
30
|
+
const block = findBlock(runtime.store.getState().layout, blockId);
|
|
31
|
+
const current = (part ? block?.partClassName?.[part] : block?.className) ?? '';
|
|
32
|
+
const keep = [];
|
|
33
|
+
const move = [];
|
|
34
|
+
for (const token of classTokens(current))
|
|
35
|
+
(runtime.classes?.byName(bareClass(token)) ? keep : move).push(token);
|
|
36
|
+
return { keep, move };
|
|
37
|
+
}
|
|
38
|
+
/** "Home", "About" and 3 more. */
|
|
39
|
+
function pagesText(usage) {
|
|
40
|
+
const docs = usage?.documents ?? [];
|
|
41
|
+
const names = docs.slice(0, 3).map((d) => `“${d.title}”`);
|
|
42
|
+
return docs.length > 3 ? `${names.join(', ')} and ${docs.length - 3} more` : names.join(', ');
|
|
43
|
+
}
|
|
44
|
+
function DialogContent({ dialog }) {
|
|
45
|
+
const runtime = useRuntime();
|
|
46
|
+
const classes = runtime.classes;
|
|
47
|
+
const usage = useValue(classes.usage);
|
|
48
|
+
const { closeModal } = useModal();
|
|
49
|
+
const item = 'id' in dialog ? classes.byId(dialog.id) : undefined;
|
|
50
|
+
const [name, setName] = useState(dialog.name ?? (dialog.kind === 'rename' ? (item?.name ?? '') : ''));
|
|
51
|
+
const [label, setLabel] = useState('');
|
|
52
|
+
const nameRef = useRef(null);
|
|
53
|
+
const busy = useRef(false);
|
|
54
|
+
useModalA11y(MODAL_SLUG, { alert: dialog.kind === 'delete' || dialog.kind === 'remove-unused' });
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const frame = requestAnimationFrame(() => nameRef.current?.select());
|
|
57
|
+
return () => cancelAnimationFrame(frame);
|
|
58
|
+
}, []);
|
|
59
|
+
const close = () => classes.dialog.set(null);
|
|
60
|
+
/** Opens the dialog again after Payload's modal closes, with the name and the reason. */
|
|
61
|
+
const again = (error) => {
|
|
62
|
+
window.setTimeout(() => classes.dialog.set({ ...dialog, name, error }), 0);
|
|
63
|
+
};
|
|
64
|
+
/** Runs the action. Never throws: Payload's modal would stay stuck on its busy label. */
|
|
65
|
+
const confirm = async () => {
|
|
66
|
+
if (busy.current)
|
|
67
|
+
return;
|
|
68
|
+
busy.current = true;
|
|
69
|
+
try {
|
|
70
|
+
if (dialog.kind === 'remove-unused') {
|
|
71
|
+
close();
|
|
72
|
+
const result = await classes.removeUnused();
|
|
73
|
+
if (typeof result === 'string')
|
|
74
|
+
runtime.warn(`The unused classes were not removed: ${result}`);
|
|
75
|
+
else
|
|
76
|
+
runtime.notify(`Deleted ${plural(result.deleted.length, 'unused class', 'unused classes')}${result.failed > 0 ? `. ${plural(result.failed, 'class', 'classes')} could not be deleted` : ''}.`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (dialog.kind === 'delete') {
|
|
80
|
+
close();
|
|
81
|
+
if (!item)
|
|
82
|
+
return;
|
|
83
|
+
const result = await classes.remove(item.id);
|
|
84
|
+
if (typeof result === 'string')
|
|
85
|
+
runtime.warn(`.${item.name} was not deleted: ${result}`);
|
|
86
|
+
else
|
|
87
|
+
runtime.notify(`Deleted .${item.name}${result.blocks > 0 ? ` and removed it from ${plural(result.blocks, 'block')}` : ''}.`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const next = name.trim();
|
|
91
|
+
const problem = classNameProblem(next) ?? (classes.byName(next) && classes.byName(next) !== item ? `A class named “${next}” already exists.` : null);
|
|
92
|
+
if (problem) {
|
|
93
|
+
again(problem);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (dialog.kind === 'rename') {
|
|
97
|
+
if (!item || next === item.name)
|
|
98
|
+
return close();
|
|
99
|
+
const result = await classes.rename(item.id, next);
|
|
100
|
+
if (typeof result === 'string')
|
|
101
|
+
return again(result);
|
|
102
|
+
close();
|
|
103
|
+
runtime.notify(`Renamed to .${next} on ${plural(result.blocks, 'block')}${result.failed > 0 ? `. ${plural(result.failed, 'page')} could not be changed` : ''}.`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// New class from the block's styles: its utilities move into the class; the block gets the class.
|
|
107
|
+
const { keep, move } = splitBlockClasses(runtime, dialog.blockId, dialog.part);
|
|
108
|
+
const created = await classes.create({ name: next, label: label.trim() || null, styles: move.join(' ') });
|
|
109
|
+
if (typeof created === 'string')
|
|
110
|
+
return again(created);
|
|
111
|
+
const className = [...keep, created.name].join(' ');
|
|
112
|
+
const op = dialog.part
|
|
113
|
+
? { type: 'update', id: dialog.blockId, partClassName: { [dialog.part]: className } }
|
|
114
|
+
: { type: 'update', id: dialog.blockId, className };
|
|
115
|
+
runtime.store.apply(op);
|
|
116
|
+
classes.target.set(created.id);
|
|
117
|
+
close();
|
|
118
|
+
runtime.notify(`Created .${created.name}. Add it to other blocks in their Classes box.`);
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
busy.current = false;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const onKeyDown = (e) => {
|
|
125
|
+
if (e.key !== 'Enter')
|
|
126
|
+
return;
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
void confirm().then(() => closeModal(MODAL_SLUG));
|
|
129
|
+
};
|
|
130
|
+
const error = dialog.error ? (_jsx("p", { className: "builder-classes__dialog-error", role: "alert", children: dialog.error })) : null;
|
|
131
|
+
if (dialog.kind === 'remove-unused') {
|
|
132
|
+
const names = dialog.names.map((n) => `.${n}`);
|
|
133
|
+
return (_jsx(ConfirmationModal, { modalSlug: MODAL_SLUG, heading: `Delete ${plural(names.length, 'unused class', 'unused classes')}?`, body: `No page uses ${names.length > 6 ? `${names.slice(0, 6).join(', ')} and ${names.length - 6} more` : names.join(', ')}. A class still on a published page stays.`, confirmLabel: "Delete classes", confirmingLabel: "Deleting\u2026", onConfirm: confirm, onCancel: close }));
|
|
134
|
+
}
|
|
135
|
+
if (dialog.kind === 'delete') {
|
|
136
|
+
const used = item ? usage?.[item.name] : undefined;
|
|
137
|
+
return (_jsx(ConfirmationModal, { modalSlug: MODAL_SLUG, heading: `Delete .${item?.name ?? 'class'}?`, body: used && used.blocks > 0
|
|
138
|
+
? `It is removed from ${plural(used.blocks, 'block')} on ${plural(used.documents.length, 'page')} (${pagesText(used)}), in their drafts. Published pages lose these styles now.`
|
|
139
|
+
: 'No block uses it. Its version history is deleted too.', confirmLabel: "Delete class", confirmingLabel: "Deleting\u2026", onConfirm: confirm, onCancel: close }));
|
|
140
|
+
}
|
|
141
|
+
const renaming = dialog.kind === 'rename';
|
|
142
|
+
const used = renaming && item ? usage?.[item.name] : undefined;
|
|
143
|
+
const styles = renaming ? [] : splitBlockClasses(runtime, dialog.blockId, dialog.part).move;
|
|
144
|
+
return (_jsx(ConfirmationModal, { modalSlug: MODAL_SLUG, className: "builder-classes__dialog", heading: renaming ? `Rename .${item?.name ?? 'class'}` : 'New class', body: _jsxs("div", { className: "builder-classes__dialog-fields", children: [_jsx("p", { className: "builder-classes__dialog-intro", children: renaming
|
|
145
|
+
? used && used.blocks > 0
|
|
146
|
+
? `Renames it on ${plural(used.blocks, 'block')} on ${plural(used.documents.length, 'page')}, in their drafts. Published pages keep their look until they are published again.`
|
|
147
|
+
: 'No block uses it yet.'
|
|
148
|
+
: styles.length > 0
|
|
149
|
+
? `Moves this ${dialog.part ? 'part' : 'block'}’s classes into the new class, and gives it the class. Use the class on other blocks to share the look.`
|
|
150
|
+
: 'Starts an empty class and gives it to this block. Its styles change every block that uses it.' }), !renaming && styles.length > 0 && _jsx("code", { className: "builder-classes__dialog-styles", children: styles.join(' ') }), _jsx(TextInput, { path: "builderClassName", label: "Class name", required: true, placeholder: "For example card or btn-primary", value: name, inputRef: nameRef, onChange: (e) => setName(e.target.value), onKeyDown: onKeyDown }), error, !renaming && (_jsx(TextInput, { path: "builderClassLabel", label: "Label (optional)", placeholder: "For example Feature card", value: label, onChange: (e) => setLabel(e.target.value), onKeyDown: onKeyDown }))] }), confirmLabel: renaming ? 'Rename' : 'Create class', confirmingLabel: renaming ? 'Renaming…' : 'Creating…', onConfirm: confirm, onCancel: close }));
|
|
151
|
+
}
|
|
@@ -125,7 +125,10 @@ function ThemeColors({ tokens, current, swatches, onPick, }) {
|
|
|
125
125
|
function ColorPicker({ value, inherited, onChange, }) {
|
|
126
126
|
const { tokens } = useStyles();
|
|
127
127
|
const groups = colorGroups(tokens.colors);
|
|
128
|
-
|
|
128
|
+
// The theme's color variables first, by name, with their swatch.
|
|
129
|
+
const variableNames = new Set((tokens.variables ?? []).filter((v) => v.type === 'color').map((v) => v.name));
|
|
130
|
+
const variables = groups.theme.filter((t) => variableNames.has(t.name));
|
|
131
|
+
const main = groups.theme.filter((t) => !isDeveloperColor(t.name) && !variableNames.has(t.name));
|
|
129
132
|
const more = groups.theme.filter((t) => isDeveloperColor(t.name));
|
|
130
133
|
const swatches = useSwatchColors(tokens.colors);
|
|
131
134
|
const current = splitColor(value ?? inherited ?? '');
|
|
@@ -140,7 +143,7 @@ function ColorPicker({ value, inherited, onChange, }) {
|
|
|
140
143
|
if (/^#?[\da-f]{3,8}$/i.test(text))
|
|
141
144
|
pick(`[${text.startsWith('#') ? text : `#${text}`}]`);
|
|
142
145
|
};
|
|
143
|
-
return (_jsxs("div", { className: "builder-styles__picker", children: [_jsxs("div", { className: "builder-styles__picker-head", children: [_jsx(Swatch, { color: current.color ? swatchFor(current.color, swatches, tokens.colors) : null, alpha: alpha }), _jsx("span", { className: "builder-styles__picker-value", children: value ?? (inherited ? `${inherited} (inherited)` : 'Not set') }), value && (_jsx("button", { type: "button", className: "builder-styles__link", onClick: () => onChange(null), children: "Clear" }))] }), main.length > 0 && (_jsxs("section", { children: [_jsx("p", { className: "builder-styles__picker-title", children: "Theme" }), _jsx(ThemeColors, { tokens: main, current: current.color, swatches: swatches, onPick: pick }), more.length > 0 && (_jsxs("details", { className: "builder-styles__more-colors", open: more.some((t) => t.name === current.color), children: [_jsxs("summary", { children: ["More theme colors (", more.length, ")"] }), _jsx(ThemeColors, { tokens: more, current: current.color, swatches: swatches, onPick: pick })] }))] })), groups.palette.length > 0 && (_jsxs("section", { children: [_jsx("p", { className: "builder-styles__picker-title", children: "Palette" }), _jsx("div", { className: "builder-styles__palette", style: { '--shades': groups.palette[0].shades.length }, children: groups.palette.map(({ hue, shades }) => shades.map((token) => (_jsx("button", { type: "button", className: "builder-styles__palette-cell", "aria-pressed": current.color === token.name, "aria-label": token.name, "data-tooltip": token.name, "data-hue": hue, style: { background: token.value }, onClick: () => pick(token.name) }, token.name)))) })] })), tokens.colors.length === 0 && _jsx("p", { className: "builder-styles__hint", children: "Theme colors are loading or unavailable." }), _jsxs("div", { className: "builder-styles__picker-row", children: [_jsx("span", { className: "builder-styles__label", children: "Opacity" }), _jsx(Slider, { value: alpha, min: 0, max: 100, step: 5, disabled: !current.color, "aria-label": "Opacity", onValueChange: (next) => onChange(joinColor(current.color, next)) }), _jsxs("span", { className: "builder-styles__slider-value", children: [alpha, "%"] })] }), _jsxs("div", { className: "builder-styles__picker-row", children: [_jsx("span", { className: "builder-styles__label", children: "Custom" }), _jsx("input", { type: "color", className: "builder-styles__native-color", "aria-label": "Pick a custom color", value: /^#[\da-f]{6}$/i.test(hex) ? hex : '#000000', onChange: (e) => {
|
|
146
|
+
return (_jsxs("div", { className: "builder-styles__picker", children: [_jsxs("div", { className: "builder-styles__picker-head", children: [_jsx(Swatch, { color: current.color ? swatchFor(current.color, swatches, tokens.colors) : null, alpha: alpha }), _jsx("span", { className: "builder-styles__picker-value", children: value ?? (inherited ? `${inherited} (inherited)` : 'Not set') }), value && (_jsx("button", { type: "button", className: "builder-styles__link", onClick: () => onChange(null), children: "Clear" }))] }), variables.length > 0 && (_jsxs("section", { children: [_jsx("p", { className: "builder-styles__picker-title", children: "Variables" }), _jsx(ThemeColors, { tokens: variables, current: current.color, swatches: swatches, onPick: pick })] })), main.length > 0 && (_jsxs("section", { children: [_jsx("p", { className: "builder-styles__picker-title", children: "Theme" }), _jsx(ThemeColors, { tokens: main, current: current.color, swatches: swatches, onPick: pick }), more.length > 0 && (_jsxs("details", { className: "builder-styles__more-colors", open: more.some((t) => t.name === current.color), children: [_jsxs("summary", { children: ["More theme colors (", more.length, ")"] }), _jsx(ThemeColors, { tokens: more, current: current.color, swatches: swatches, onPick: pick })] }))] })), groups.palette.length > 0 && (_jsxs("section", { children: [_jsx("p", { className: "builder-styles__picker-title", children: "Palette" }), _jsx("div", { className: "builder-styles__palette", style: { '--shades': groups.palette[0].shades.length }, children: groups.palette.map(({ hue, shades }) => shades.map((token) => (_jsx("button", { type: "button", className: "builder-styles__palette-cell", "aria-pressed": current.color === token.name, "aria-label": token.name, "data-tooltip": token.name, "data-hue": hue, style: { background: token.value }, onClick: () => pick(token.name) }, token.name)))) })] })), tokens.colors.length === 0 && _jsx("p", { className: "builder-styles__hint", children: "Theme colors are loading or unavailable." }), _jsxs("div", { className: "builder-styles__picker-row", children: [_jsx("span", { className: "builder-styles__label", children: "Opacity" }), _jsx(Slider, { value: alpha, min: 0, max: 100, step: 5, disabled: !current.color, "aria-label": "Opacity", onValueChange: (next) => onChange(joinColor(current.color, next)) }), _jsxs("span", { className: "builder-styles__slider-value", children: [alpha, "%"] })] }), _jsxs("div", { className: "builder-styles__picker-row", children: [_jsx("span", { className: "builder-styles__label", children: "Custom" }), _jsx("input", { type: "color", className: "builder-styles__native-color", "aria-label": "Pick a custom color", value: /^#[\da-f]{6}$/i.test(hex) ? hex : '#000000', onChange: (e) => {
|
|
144
147
|
setHex(e.target.value);
|
|
145
148
|
pick(`[${e.target.value}]`);
|
|
146
149
|
} }), _jsx("input", { className: "builder-styles__input", placeholder: "#ff8800", "aria-label": "Hex color", value: hex, spellCheck: false, onChange: (e) => setHex(e.target.value), onKeyDown: (e) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BuilderClass } from '../../../classes/shared.js';
|
|
1
2
|
import { type StyleTokens } from '../../../core/index.js';
|
|
2
3
|
/**
|
|
3
4
|
* True when Tailwind has no utility with this name, so the class does nothing. Variant prefixes,
|
|
@@ -5,4 +6,28 @@ import { type StyleTokens } from '../../../core/index.js';
|
|
|
5
6
|
* class list from the theme, every class counts as known.
|
|
6
7
|
*/
|
|
7
8
|
export declare function isUnknownClass(name: string, tokens: StyleTokens): boolean;
|
|
8
|
-
|
|
9
|
+
type ChipsProps = {
|
|
10
|
+
/** The class string the field shows and changes. */
|
|
11
|
+
value: string;
|
|
12
|
+
onChange: (next: string) => void;
|
|
13
|
+
/** Names the field for screen readers, e.g. "Classes of this block". */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Where the classes go, for the remove buttons: "this block", ".card". */
|
|
16
|
+
owner: string;
|
|
17
|
+
/** The editable classes in `value`: solid chips. */
|
|
18
|
+
editable?: readonly BuilderClass[];
|
|
19
|
+
/** The editable class the style controls edit, or null. */
|
|
20
|
+
selected?: BuilderClass | null;
|
|
21
|
+
onSelect?: (item: BuilderClass | null) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare function ClassChips({ value, onChange, label, owner, editable, selected, onSelect }: ChipsProps): import("react").JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* The whole class string as text, with autocomplete ("Edit as text" in the field's menu). Typed
|
|
26
|
+
* variant prefixes ("md:hover:") and "!" / "-" stay in front of the picked class.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ClassText({ value, onChange, label }: {
|
|
29
|
+
value: string;
|
|
30
|
+
onChange: (next: string, mergeKey?: string) => void;
|
|
31
|
+
label: string;
|
|
32
|
+
}): import("react").JSX.Element;
|
|
33
|
+
export {};
|