@webiny/website-builder-sdk 0.0.0-unstable.3bc8100a7f → 0.0.0-unstable.3fddf667ea
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/BindingsApi.d.ts +4 -4
- package/BindingsApi.js +32 -39
- package/BindingsApi.js.map +1 -1
- package/BindingsProcessor.d.ts +1 -1
- package/BindingsProcessor.js +34 -43
- package/BindingsProcessor.js.map +1 -1
- package/BindingsProcessor.test.js +83 -78
- package/BindingsProcessor.test.js.map +1 -1
- package/BindingsResolver.d.ts +6 -3
- package/BindingsResolver.js +92 -122
- package/BindingsResolver.js.map +1 -1
- package/BindingsResolver.test.js +402 -365
- package/BindingsResolver.test.js.map +1 -1
- package/ComponentInputTraverser.d.ts +1 -1
- package/ComponentInputTraverser.js +29 -49
- package/ComponentInputTraverser.js.map +1 -1
- package/ComponentManifestToAstConverter.d.ts +23 -1
- package/ComponentManifestToAstConverter.js +140 -21
- package/ComponentManifestToAstConverter.js.map +1 -1
- package/ComponentRegistry.d.ts +2 -1
- package/ComponentRegistry.js +40 -22
- package/ComponentRegistry.js.map +1 -1
- package/ComponentResolver.d.ts +7 -4
- package/ComponentResolver.js +33 -32
- package/ComponentResolver.js.map +1 -1
- package/ConstraintEvaluator.d.ts +41 -0
- package/ConstraintEvaluator.js +304 -0
- package/ConstraintEvaluator.js.map +1 -0
- package/ConstraintEvaluator.test.d.ts +1 -0
- package/ConstraintEvaluator.test.js +1771 -0
- package/ConstraintEvaluator.test.js.map +1 -0
- package/ContentSdk.d.ts +90 -8
- package/ContentSdk.js +195 -78
- package/ContentSdk.js.map +1 -1
- package/DocumentStore.d.ts +3 -3
- package/DocumentStore.js +48 -60
- package/DocumentStore.js.map +1 -1
- package/DocumentStoreManager.d.ts +11 -4
- package/DocumentStoreManager.js +37 -17
- package/DocumentStoreManager.js.map +1 -1
- package/EditingSdk.d.ts +21 -5
- package/EditingSdk.js +119 -131
- package/EditingSdk.js.map +1 -1
- package/ElementBindings.d.ts +28 -0
- package/ElementBindings.js +88 -0
- package/ElementBindings.js.map +1 -0
- package/ElementBindings.test.d.ts +1 -0
- package/ElementBindings.test.js +127 -0
- package/ElementBindings.test.js.map +1 -0
- package/ElementFactory.d.ts +15 -7
- package/ElementFactory.js +165 -168
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.test.d.ts +1 -0
- package/ElementFactory.test.js +511 -0
- package/ElementFactory.test.js.map +1 -0
- package/ElementSelection.d.ts +20 -0
- package/ElementSelection.js +32 -0
- package/ElementSelection.js.map +1 -0
- package/ElementSelection.test.d.ts +1 -0
- package/ElementSelection.test.js +73 -0
- package/ElementSelection.test.js.map +1 -0
- package/Environment.d.ts +7 -0
- package/Environment.js +19 -19
- package/Environment.js.map +1 -1
- package/Environment.test.d.ts +1 -0
- package/Environment.test.js +39 -0
- package/Environment.test.js.map +1 -0
- package/FunctionConverter.js +8 -7
- package/FunctionConverter.js.map +1 -1
- package/GlobalComponentLanguage.d.ts +31 -0
- package/GlobalComponentLanguage.js +37 -0
- package/GlobalComponentLanguage.js.map +1 -0
- package/HashObject.js +11 -12
- package/HashObject.js.map +1 -1
- package/HotkeyManager.js +41 -48
- package/HotkeyManager.js.map +1 -1
- package/IBindingsUpdater.d.ts +2 -2
- package/IBindingsUpdater.js +0 -3
- package/IRedirects.d.ts +5 -0
- package/IRedirects.js +0 -0
- package/InheritanceProcessor.d.ts +4 -4
- package/InheritanceProcessor.js +99 -139
- package/InheritanceProcessor.js.map +1 -1
- package/InheritanceProcessor.test.js +185 -177
- package/InheritanceProcessor.test.js.map +1 -1
- package/InheritedValueResolver.d.ts +7 -1
- package/InheritedValueResolver.js +22 -20
- package/InheritedValueResolver.js.map +1 -1
- package/InputBindingsProcessor.d.ts +4 -4
- package/InputBindingsProcessor.js +196 -294
- package/InputBindingsProcessor.js.map +1 -1
- package/InputRenderer.test.d.ts +1 -0
- package/InputRenderer.test.js +186 -0
- package/InputRenderer.test.js.map +1 -0
- package/InputsBindingsProcessor.test.js +466 -315
- package/InputsBindingsProcessor.test.js.map +1 -1
- package/InputsUpdater.d.ts +5 -5
- package/InputsUpdater.js +26 -28
- package/InputsUpdater.js.map +1 -1
- package/LayoutContentArea.d.ts +68 -0
- package/LayoutContentArea.js +78 -0
- package/LayoutContentArea.js.map +1 -0
- package/LayoutContentArea.test.d.ts +1 -0
- package/LayoutContentArea.test.js +111 -0
- package/LayoutContentArea.test.js.map +1 -0
- package/LiveSdk.d.ts +6 -3
- package/LiveSdk.js +17 -14
- package/LiveSdk.js.map +1 -1
- package/Logger.d.ts +2 -1
- package/Logger.js +10 -6
- package/Logger.js.map +1 -1
- package/MouseTracker.js +77 -83
- package/MouseTracker.js.map +1 -1
- package/NullSdk.d.ts +6 -3
- package/NullSdk.js +25 -11
- package/NullSdk.js.map +1 -1
- package/PreviewDocument.d.ts +3 -1
- package/PreviewDocument.js +31 -31
- package/PreviewDocument.js.map +1 -1
- package/PreviewSdk.d.ts +7 -3
- package/PreviewSdk.js +24 -18
- package/PreviewSdk.js.map +1 -1
- package/PreviewViewport.d.ts +6 -2
- package/PreviewViewport.js +60 -83
- package/PreviewViewport.js.map +1 -1
- package/PreviewViewport.test.d.ts +1 -0
- package/PreviewViewport.test.js +27 -0
- package/PreviewViewport.test.js.map +1 -0
- package/README.md +10 -2
- package/RadioOptionInputs.test.d.ts +1 -0
- package/RadioOptionInputs.test.js +521 -0
- package/RadioOptionInputs.test.js.map +1 -0
- package/ResizeObserver.js +24 -31
- package/ResizeObserver.js.map +1 -1
- package/StylesBindingsProcessor.d.ts +2 -2
- package/StylesBindingsProcessor.js +45 -83
- package/StylesBindingsProcessor.js.map +1 -1
- package/StylesUpdater.d.ts +4 -4
- package/StylesUpdater.js +25 -27
- package/StylesUpdater.js.map +1 -1
- package/Theme.d.ts +1 -1
- package/Theme.js +31 -33
- package/Theme.js.map +1 -1
- package/ViewportManager.d.ts +3 -1
- package/ViewportManager.js +90 -95
- package/ViewportManager.js.map +1 -1
- package/asset/deliveryUrl.d.ts +41 -0
- package/asset/deliveryUrl.js +34 -0
- package/asset/deliveryUrl.js.map +1 -0
- package/asset/deliveryUrl.test.d.ts +1 -0
- package/asset/deliveryUrl.test.js +127 -0
- package/asset/deliveryUrl.test.js.map +1 -0
- package/asset/geometry.d.ts +7 -0
- package/asset/geometry.js +10 -0
- package/asset/geometry.js.map +1 -0
- package/asset/imageSrcSet.d.ts +63 -0
- package/asset/imageSrcSet.js +98 -0
- package/asset/imageSrcSet.js.map +1 -0
- package/asset/imageSrcSet.test.d.ts +1 -0
- package/asset/imageSrcSet.test.js +103 -0
- package/asset/imageSrcSet.test.js.map +1 -0
- package/asset/index.d.ts +5 -0
- package/asset/index.js +5 -0
- package/asset/normalize.d.ts +24 -0
- package/asset/normalize.js +106 -0
- package/asset/normalize.js.map +1 -0
- package/asset/normalize.test.d.ts +1 -0
- package/asset/normalize.test.js +263 -0
- package/asset/normalize.test.js.map +1 -0
- package/asset/types.d.ts +2 -0
- package/asset/types.js +0 -0
- package/componentLoader/ComponentLoader.d.ts +16 -0
- package/componentLoader/ComponentLoader.js +0 -0
- package/componentLoader/RegistryOnlyComponentLoader.d.ts +9 -0
- package/componentLoader/RegistryOnlyComponentLoader.js +8 -0
- package/componentLoader/RegistryOnlyComponentLoader.js.map +1 -0
- package/componentLoader/createComponentLoader.d.ts +7 -0
- package/componentLoader/createComponentLoader.js +10 -0
- package/componentLoader/createComponentLoader.js.map +1 -0
- package/componentLoader/defaultComponentLoader.d.ts +7 -0
- package/componentLoader/defaultComponentLoader.js +8 -0
- package/componentLoader/defaultComponentLoader.js.map +1 -0
- package/componentLoader/index.d.ts +3 -0
- package/componentLoader/index.js +3 -0
- package/constants.d.ts +1 -0
- package/constants.js +7 -5
- package/constants.js.map +1 -1
- package/contentClientState.test.d.ts +1 -0
- package/contentClientState.test.js +404 -0
- package/contentClientState.test.js.map +1 -0
- package/contentEntry/ContentEntryBindingsResolver.d.ts +33 -0
- package/contentEntry/ContentEntryBindingsResolver.js +52 -0
- package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
- package/contentEntry/ContentEntryCache.d.ts +49 -0
- package/contentEntry/ContentEntryCache.js +51 -0
- package/contentEntry/ContentEntryCache.js.map +1 -0
- package/contentEntry/resolveContentEntry.d.ts +74 -0
- package/contentEntry/resolveContentEntry.js +53 -0
- package/contentEntry/resolveContentEntry.js.map +1 -0
- package/contentEntry/resolveContentEntry.test.d.ts +1 -0
- package/contentEntry/resolveContentEntry.test.js +213 -0
- package/contentEntry/resolveContentEntry.test.js.map +1 -0
- package/createComponent.d.ts +5 -0
- package/createComponent.js +32 -0
- package/createComponent.js.map +1 -0
- package/createContentClient.d.ts +17 -0
- package/createContentClient.js +16 -0
- package/createContentClient.js.map +1 -0
- package/createContentClient.test.d.ts +1 -0
- package/createContentClient.test.js +165 -0
- package/createContentClient.test.js.map +1 -0
- package/createElement.d.ts +1 -1
- package/createElement.js +5 -6
- package/createElement.js.map +1 -1
- package/createGlobalElementDocument.d.ts +6 -0
- package/createGlobalElementDocument.js +23 -0
- package/createGlobalElementDocument.js.map +1 -0
- package/createInput.d.ts +132 -16
- package/createInput.js +93 -112
- package/createInput.js.map +1 -1
- package/createTheme.d.ts +1 -1
- package/createTheme.js +2 -3
- package/createTheme.js.map +1 -1
- package/dataProviders/ApiClient.d.ts +18 -5
- package/dataProviders/ApiClient.js +58 -38
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/ApiClient.test.d.ts +1 -0
- package/dataProviders/ApiClient.test.js +116 -0
- package/dataProviders/ApiClient.test.js.map +1 -0
- package/dataProviders/DefaultDataProvider.d.ts +9 -3
- package/dataProviders/DefaultDataProvider.js +106 -35
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/DefaultDataProvider.test.d.ts +1 -0
- package/dataProviders/DefaultDataProvider.test.js +81 -0
- package/dataProviders/DefaultDataProvider.test.js.map +1 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.d.ts +1 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.js +17 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.js.map +1 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.d.ts +1 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.js +27 -0
- package/dataProviders/GET_LAYOUT_BY_SLUG.js.map +1 -0
- package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_ID.js +11 -1
- package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.js +11 -1
- package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
- package/dataProviders/GET_PAGE_EXPERIMENT.d.ts +1 -0
- package/dataProviders/GET_PAGE_EXPERIMENT.js +32 -0
- package/dataProviders/GET_PAGE_EXPERIMENT.js.map +1 -0
- package/dataProviders/GET_VARIANT_CONTENT.d.ts +1 -0
- package/dataProviders/GET_VARIANT_CONTENT.js +24 -0
- package/dataProviders/GET_VARIANT_CONTENT.js.map +1 -0
- package/dataProviders/LIST_PUBLISHED_PAGES.d.ts +1 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.js +17 -5
- package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
- package/dataProviders/NullDataProvider.d.ts +18 -4
- package/dataProviders/NullDataProvider.js +33 -10
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/RedirectsProvider.d.ts +11 -0
- package/dataProviders/RedirectsProvider.js +29 -0
- package/dataProviders/RedirectsProvider.js.map +1 -0
- package/dataProviders/queries.test.d.ts +1 -0
- package/dataProviders/queries.test.js +53 -0
- package/dataProviders/queries.test.js.map +1 -0
- package/defaultBreakpoints.d.ts +1 -1
- package/defaultBreakpoints.js +43 -22
- package/defaultBreakpoints.js.map +1 -1
- package/documentOperations/$addElementReferenceToParent.d.ts +1 -1
- package/documentOperations/$addElementReferenceToParent.js +30 -26
- package/documentOperations/$addElementReferenceToParent.js.map +1 -1
- package/documentOperations/AddElement.d.ts +1 -1
- package/documentOperations/AddElement.js +8 -7
- package/documentOperations/AddElement.js.map +1 -1
- package/documentOperations/AddToParent.d.ts +3 -3
- package/documentOperations/AddToParent.js +14 -13
- package/documentOperations/AddToParent.js.map +1 -1
- package/documentOperations/IDocumentOperation.js +0 -3
- package/documentOperations/RemoveElement.d.ts +1 -1
- package/documentOperations/RemoveElement.js +10 -7
- package/documentOperations/RemoveElement.js.map +1 -1
- package/documentOperations/SetGlobalInputBinding.d.ts +1 -1
- package/documentOperations/SetGlobalInputBinding.js +23 -22
- package/documentOperations/SetGlobalInputBinding.js.map +1 -1
- package/documentOperations/SetGlobalStyleBinding.d.ts +1 -1
- package/documentOperations/SetGlobalStyleBinding.js +23 -23
- package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
- package/documentOperations/SetInputBindingOverride.d.ts +1 -1
- package/documentOperations/SetInputBindingOverride.js +30 -29
- package/documentOperations/SetInputBindingOverride.js.map +1 -1
- package/documentOperations/SetStyleBindingOverride.d.ts +1 -1
- package/documentOperations/SetStyleBindingOverride.js +30 -31
- package/documentOperations/SetStyleBindingOverride.js.map +1 -1
- package/documentOperations/index.d.ts +8 -8
- package/documentOperations/index.js +16 -15
- package/documentOperations/index.js.map +1 -1
- package/experiments/PostHogAnalyticsProvider.d.ts +31 -0
- package/experiments/PostHogAnalyticsProvider.js +28 -0
- package/experiments/PostHogAnalyticsProvider.js.map +1 -0
- package/experiments/analyticsProvider.d.ts +4 -0
- package/experiments/analyticsProvider.js +11 -0
- package/experiments/analyticsProvider.js.map +1 -0
- package/experiments/bucketing.d.ts +27 -0
- package/experiments/bucketing.js +91 -0
- package/experiments/bucketing.js.map +1 -0
- package/experiments/bucketing.test.d.ts +1 -0
- package/experiments/bucketing.test.js +183 -0
- package/experiments/bucketing.test.js.map +1 -0
- package/experiments/index.d.ts +5 -0
- package/experiments/index.js +5 -0
- package/experiments/render.d.ts +82 -0
- package/experiments/render.js +149 -0
- package/experiments/render.js.map +1 -0
- package/experiments/types.d.ts +108 -0
- package/experiments/types.js +4 -0
- package/experiments/types.js.map +1 -0
- package/findMatchingAstNode.d.ts +1 -1
- package/findMatchingAstNode.js +11 -13
- package/findMatchingAstNode.js.map +1 -1
- package/generateElementId.d.ts +1 -1
- package/generateElementId.js +2 -2
- package/generateElementId.js.map +1 -1
- package/globalElements.d.ts +43 -0
- package/globalElements.js +79 -0
- package/globalElements.js.map +1 -0
- package/globalElements.test.d.ts +1 -0
- package/globalElements.test.js +343 -0
- package/globalElements.test.js.map +1 -0
- package/headersProvider.d.ts +1 -2
- package/headersProvider.js +4 -3
- package/headersProvider.js.map +1 -1
- package/image/geometry.d.ts +54 -0
- package/image/geometry.js +112 -0
- package/image/geometry.js.map +1 -0
- package/image/geometry.test.d.ts +1 -0
- package/image/geometry.test.js +190 -0
- package/image/geometry.test.js.map +1 -0
- package/image/index.d.ts +3 -0
- package/image/index.js +3 -0
- package/image/presets.d.ts +6 -0
- package/image/presets.js +20 -0
- package/image/presets.js.map +1 -0
- package/image/types.d.ts +10 -0
- package/image/types.js +0 -0
- package/index.d.ts +22 -3
- package/index.js +21 -5
- package/jsonPatch.d.ts +1 -1
- package/jsonPatch.js +5 -9
- package/jsonPatch.js.map +1 -1
- package/messages.d.ts +3 -0
- package/messages.js +15 -11
- package/messages.js.map +1 -1
- package/messenger/MessageOrigin.js +12 -11
- package/messenger/MessageOrigin.js.map +1 -1
- package/messenger/Messenger.js +59 -70
- package/messenger/Messenger.js.map +1 -1
- package/messenger/index.js +0 -2
- package/package.json +19 -23
- package/radioOptionInputs.d.ts +24 -0
- package/radioOptionInputs.js +26 -0
- package/radioOptionInputs.js.map +1 -0
- package/registerComponentGroup.d.ts +1 -1
- package/registerComponentGroup.js +6 -7
- package/registerComponentGroup.js.map +1 -1
- package/types/ShorthandCssProperties.js +0 -3
- package/types/WebsiteBuilderTheme.d.ts +54 -45
- package/types/WebsiteBuilderTheme.js +0 -3
- package/types.d.ts +369 -24
- package/types.js +0 -3
- package/withGlobalElementDefaults.d.ts +8 -0
- package/withGlobalElementDefaults.js +60 -0
- package/withGlobalElementDefaults.js.map +1 -0
- package/IBindingsUpdater.js.map +0 -1
- package/documentOperations/IDocumentOperation.js.map +0 -1
- package/index.js.map +0 -1
- package/lexical/createDefaultLexicalTheme.d.ts +0 -2
- package/lexical/createDefaultLexicalTheme.js +0 -84
- package/lexical/createDefaultLexicalTheme.js.map +0 -1
- package/lexical/createLexicalTheme.d.ts +0 -2
- package/lexical/createLexicalTheme.js +0 -7
- package/lexical/createLexicalTheme.js.map +0 -1
- package/lexical/deepMerge.d.ts +0 -1
- package/lexical/deepMerge.js +0 -23
- package/lexical/deepMerge.js.map +0 -1
- package/messenger/index.js.map +0 -1
- package/types/LexicalEditorTheme.d.ts +0 -2
- package/types/LexicalEditorTheme.js +0 -3
- package/types/LexicalEditorTheme.js.map +0 -1
- package/types/ShorthandCssProperties.js.map +0 -1
- package/types/WebsiteBuilderTheme.js.map +0 -1
- package/types.js.map +0 -1
package/types.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type * as CSS from "csstype";
|
|
2
|
-
import type { BindingsApi } from "./BindingsApi";
|
|
3
|
-
import type { ShorthandCssProperties } from "./types/ShorthandCssProperties";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
2
|
+
import type { BindingsApi } from "./BindingsApi.js";
|
|
3
|
+
import type { ShorthandCssProperties } from "./types/ShorthandCssProperties.js";
|
|
4
|
+
import type { InputFactory } from "./createInput.js";
|
|
5
|
+
import type { Breakpoint } from "./types/WebsiteBuilderTheme.js";
|
|
6
|
+
import type { ActiveExperiment, VariantContent } from "./experiments/types.js";
|
|
7
|
+
export type { WebsiteBuilderTheme, Breakpoint } from "./types/WebsiteBuilderTheme.js";
|
|
8
|
+
type CSSProperties = CSS.Properties<string | number>;
|
|
7
9
|
export type ElementMap = Record<string, DocumentElement>;
|
|
8
10
|
export type DocumentState = Record<string, any>;
|
|
11
|
+
export type DocumentMetadata = Record<string, any>;
|
|
9
12
|
export type InputValueBinding<T = any> = ValueBinding<T> & {
|
|
10
13
|
id: string;
|
|
11
14
|
type: string;
|
|
@@ -57,6 +60,10 @@ export type Component = {
|
|
|
57
60
|
component: any;
|
|
58
61
|
manifest: ComponentManifest;
|
|
59
62
|
};
|
|
63
|
+
export type ComponentBlueprint<TComponent = any, TManifest = any> = {
|
|
64
|
+
component: TComponent;
|
|
65
|
+
manifest: TManifest;
|
|
66
|
+
};
|
|
60
67
|
export type ComponentGroupItem = {
|
|
61
68
|
name: string;
|
|
62
69
|
item?: DocumentElementTemplate;
|
|
@@ -71,24 +78,138 @@ export type ComponentGroup = {
|
|
|
71
78
|
name: string;
|
|
72
79
|
label: string;
|
|
73
80
|
description?: string;
|
|
81
|
+
icon?: string;
|
|
74
82
|
filter?: (component: ComponentManifest, context: ComponentGroupFilterContext) => boolean;
|
|
75
83
|
};
|
|
76
84
|
export type ResponsiveStyles = {
|
|
77
85
|
[key: string]: SerializableCSSStyleDeclaration;
|
|
78
86
|
};
|
|
87
|
+
export type ConstraintElementContext = {
|
|
88
|
+
/** Component name (e.g., "FunnelBuilder/Step") */
|
|
89
|
+
name: string;
|
|
90
|
+
/** Component tags */
|
|
91
|
+
tags: string[];
|
|
92
|
+
/** Get the parent element context. undefined for root. */
|
|
93
|
+
getParent(): ConstraintElementContext | undefined;
|
|
94
|
+
/** Index of this element among siblings in the same parent slot. -1 if not in a list slot. */
|
|
95
|
+
childIndex(): number;
|
|
96
|
+
/** Total siblings in the same parent slot. -1 if not in a list slot. */
|
|
97
|
+
childCount(): number;
|
|
98
|
+
/** True if this element is the last among siblings in its parent slot. */
|
|
99
|
+
isLastChild(): boolean;
|
|
100
|
+
/** True if this element is the first among siblings in its parent slot. */
|
|
101
|
+
isFirstChild(): boolean;
|
|
102
|
+
};
|
|
103
|
+
export type ConstraintContext = {
|
|
104
|
+
/** The component/element this constraint is about */
|
|
105
|
+
component: ConstraintElementContext;
|
|
106
|
+
/** The direct parent element at the drop target */
|
|
107
|
+
parent: ConstraintElementContext;
|
|
108
|
+
/** The target slot name (e.g., "children", "leftColumn", "rightColumn") */
|
|
109
|
+
slot: string;
|
|
110
|
+
/** True if the direct parent is the given component */
|
|
111
|
+
isChildOf: (componentName: string) => boolean;
|
|
112
|
+
/** True if any ancestor (including parent) is the given component */
|
|
113
|
+
isDescendantOf: (componentName: string) => boolean;
|
|
114
|
+
/** Find the nearest ancestor matching a component name */
|
|
115
|
+
getAncestor: (componentName: string) => ConstraintElementContext | undefined;
|
|
116
|
+
/** True if the component being placed has the given tag */
|
|
117
|
+
hasTag: (tag: string) => boolean;
|
|
118
|
+
/** Number of items currently in the target slot */
|
|
119
|
+
slotChildCount: () => number;
|
|
120
|
+
/** Count instances of a component type in the entire document */
|
|
121
|
+
countInstances: (componentName: string) => number;
|
|
122
|
+
/** True if the component has any descendant element carrying the given tag */
|
|
123
|
+
hasDescendantWithTag: (tag: string) => boolean;
|
|
124
|
+
/** Returns the resolved inputs of the nearest ancestor matching componentName, or undefined */
|
|
125
|
+
getAncestorInputs: (componentName: string) => Record<string, any> | undefined;
|
|
126
|
+
/** Returns the resolved inputs of the element this constraint is evaluating */
|
|
127
|
+
getElementInputs: () => Record<string, any>;
|
|
128
|
+
/** Debug logger — safe to call inside serialized constraints */
|
|
129
|
+
log: (...args: any[]) => void;
|
|
130
|
+
/** Block placement with an error message shown to the user */
|
|
131
|
+
block: (message: string) => never;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* A constraint function. Call `ctx.block("message")` to block placement.
|
|
135
|
+
* Returning without blocking means the constraint passes.
|
|
136
|
+
*/
|
|
137
|
+
export type ComponentConstraint = (ctx: ConstraintContext) => void;
|
|
138
|
+
export type Stop = symbol;
|
|
139
|
+
export type Continue = symbol;
|
|
140
|
+
export type HandlerResult = void | Stop | Continue;
|
|
141
|
+
export type OnChangeAction = "create" | "update" | "delete";
|
|
142
|
+
export type OnChangeElementContext = {
|
|
143
|
+
id: string;
|
|
144
|
+
component: ComponentManifest;
|
|
145
|
+
inputs: Record<string, any>;
|
|
146
|
+
};
|
|
147
|
+
export type ManifestAncestorContext = {
|
|
148
|
+
id: string;
|
|
149
|
+
component: ComponentManifest;
|
|
150
|
+
inputs: Record<string, any>;
|
|
151
|
+
updateInputs: (cb: (inputs: Record<string, any>) => void) => void;
|
|
152
|
+
getElement: (id: string) => OnChangeElementContext | undefined;
|
|
153
|
+
};
|
|
154
|
+
export type ComponentChangeContext<TInputs = Record<string, any>> = {
|
|
155
|
+
action: OnChangeAction;
|
|
156
|
+
id: string;
|
|
157
|
+
component: ComponentManifest;
|
|
158
|
+
inputs: TInputs;
|
|
159
|
+
styles: Record<string, any>;
|
|
160
|
+
getAncestor: (componentName: string) => ManifestAncestorContext | undefined;
|
|
161
|
+
getElement: (id: string) => OnChangeElementContext | undefined;
|
|
162
|
+
createElement: (params: any) => any;
|
|
163
|
+
executeCommand: <T = unknown>(command: string, payload?: T) => void;
|
|
164
|
+
breakpoint: string;
|
|
165
|
+
log: (...args: any[]) => void;
|
|
166
|
+
stop: () => Stop;
|
|
167
|
+
continue: () => Continue;
|
|
168
|
+
};
|
|
169
|
+
export type DescendantChangeContext<TInputs = Record<string, any>, TDescendantInputs = Record<string, any>> = {
|
|
170
|
+
action: OnChangeAction;
|
|
171
|
+
descendant: {
|
|
172
|
+
component: ComponentManifest;
|
|
173
|
+
id: string;
|
|
174
|
+
inputs: TDescendantInputs;
|
|
175
|
+
updateInputs: (cb: (inputs: TDescendantInputs) => void) => void;
|
|
176
|
+
};
|
|
177
|
+
inputs: TInputs;
|
|
178
|
+
updateInputs: (cb: (inputs: TInputs) => void) => void;
|
|
179
|
+
getElement: (id: string) => OnChangeElementContext | undefined;
|
|
180
|
+
executeCommand: <T = unknown>(command: string, payload?: T) => void;
|
|
181
|
+
breakpoint: string;
|
|
182
|
+
log: (...args: any[]) => void;
|
|
183
|
+
stop: () => Stop;
|
|
184
|
+
continue: () => Continue;
|
|
185
|
+
};
|
|
186
|
+
export type ComponentChangeHandler<TInputs = Record<string, any>> = (ctx: ComponentChangeContext<TInputs>) => HandlerResult;
|
|
187
|
+
export type DescendantChangeHandler<TInputs = Record<string, any>, TDescendantInputs = Record<string, any>> = (ctx: DescendantChangeContext<TInputs, TDescendantInputs>) => HandlerResult;
|
|
79
188
|
export type ComponentManifest = {
|
|
80
189
|
name: string;
|
|
81
190
|
group?: string;
|
|
82
191
|
label?: string;
|
|
192
|
+
aiContext?: string;
|
|
193
|
+
useInAiContentGeneration?: boolean;
|
|
83
194
|
image?: string;
|
|
84
|
-
inputs
|
|
195
|
+
inputs: ComponentInput[];
|
|
85
196
|
canDrag?: boolean;
|
|
86
|
-
canDelete?: boolean;
|
|
197
|
+
canDelete?: boolean | ComponentConstraint;
|
|
87
198
|
acceptsChildren?: boolean;
|
|
88
199
|
hideFromToolbar?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* A global component has exactly one instance per site, stored outside of pages.
|
|
202
|
+
* The frontend layout decides where it renders, via `<GlobalComponent>`.
|
|
203
|
+
*/
|
|
204
|
+
global?: boolean;
|
|
89
205
|
hideStyleSettings?: string[];
|
|
90
206
|
autoApplyStyles?: boolean;
|
|
91
|
-
|
|
207
|
+
applyDefaultStyles?: boolean;
|
|
208
|
+
tags: string[];
|
|
209
|
+
constraints?: ComponentConstraint[];
|
|
210
|
+
descendantConstraints?: ComponentConstraint[];
|
|
211
|
+
onChange?: ComponentChangeHandler | ComponentChangeHandler[];
|
|
212
|
+
onDescendantChange?: DescendantChangeHandler | DescendantChangeHandler[];
|
|
92
213
|
defaults?: {
|
|
93
214
|
inputs?: Record<string, any>;
|
|
94
215
|
styles?: SerializableCSSStyleDeclaration;
|
|
@@ -117,19 +238,75 @@ export type DocumentElement = {
|
|
|
117
238
|
export type SerializableCSSStyleDeclaration = {
|
|
118
239
|
[K in keyof CssProperties]?: CssProperties[K];
|
|
119
240
|
};
|
|
241
|
+
export type DocumentCache = Record<string, unknown>;
|
|
120
242
|
export type Document = {
|
|
121
243
|
id: string;
|
|
122
244
|
state: DocumentState;
|
|
123
245
|
version: number;
|
|
124
246
|
properties: Record<string, any>;
|
|
247
|
+
extensions: Record<string, any>;
|
|
248
|
+
metadata: DocumentMetadata;
|
|
125
249
|
bindings: DocumentBindings;
|
|
126
250
|
elements: ElementMap;
|
|
251
|
+
layout?: PageLayout | null;
|
|
252
|
+
previewPage?: PreviewPage | null;
|
|
253
|
+
__cache?: DocumentCache;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* A page shown inside a layout in the layout editor, in place of its page content placeholder.
|
|
257
|
+
* It's only shown: it's never saved with the layout.
|
|
258
|
+
*/
|
|
259
|
+
export type PreviewPage = Pick<Document, "id" | "properties" | "elements" | "bindings">;
|
|
260
|
+
/**
|
|
261
|
+
* A page layout built in the layout editor: elements placed around one `Webiny/LayoutContent` element
|
|
262
|
+
* (main content), where the page renders its own content, and any `Webiny/NamedContent` areas. Global components are placed in it like on a page, by placement
|
|
263
|
+
* elements: their instances (`$global:{name}`) come with the page. Its bindings may also hold overrides of
|
|
264
|
+
* global components, under their element ids.
|
|
265
|
+
*/
|
|
266
|
+
export type PageLayout = Pick<Document, "elements" | "bindings"> & {
|
|
267
|
+
id: string;
|
|
268
|
+
entryId?: string;
|
|
269
|
+
properties?: Record<string, any>;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Elements and bindings of global components, keyed `$global:{componentName}` (plus anything nested inside).
|
|
273
|
+
* Pages are delivered with the stored global components merged into their own elements and bindings.
|
|
274
|
+
*/
|
|
275
|
+
export type GlobalDocument = Pick<Document, "elements" | "bindings">;
|
|
276
|
+
/**
|
|
277
|
+
* The stored instance of one global component in one language. Each global component is stored as its
|
|
278
|
+
* own record per language.
|
|
279
|
+
*/
|
|
280
|
+
export type GlobalComponentRecord = GlobalDocument & {
|
|
281
|
+
name: string;
|
|
282
|
+
language: string;
|
|
283
|
+
};
|
|
284
|
+
export type PublicPage = Pick<Page, "id" | "version" | "properties" | "bindings" | "elements" | "extensions" | "metadata" | "state" | "layout"> & {
|
|
285
|
+
languagePaths: Record<string, string>;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* A layout delivered by slug, for content code renders in it (e.g. a CMS entry): composed like a page with no
|
|
289
|
+
* content of its own. `elements` and `bindings` hold the instances of the global components, in the requested
|
|
290
|
+
* language, and `layout` is the layout itself, whose Main content is where the content goes.
|
|
291
|
+
*/
|
|
292
|
+
export type PublicLayout = Pick<Document, "elements" | "bindings"> & {
|
|
293
|
+
layout: PageLayout;
|
|
294
|
+
};
|
|
295
|
+
export interface GetLayoutParams {
|
|
296
|
+
slug: string;
|
|
297
|
+
language?: string | null;
|
|
298
|
+
}
|
|
299
|
+
export type PublicRedirect = {
|
|
300
|
+
id: string;
|
|
301
|
+
from: string;
|
|
302
|
+
to: string;
|
|
303
|
+
permanent: boolean;
|
|
127
304
|
};
|
|
128
|
-
export type PublicPage = Pick<Page, "id" | "version" | "properties" | "bindings" | "elements" | "state">;
|
|
129
305
|
export type EditorPage = EditorDocument & Pick<Page, "properties" | "status" | "location">;
|
|
130
|
-
export
|
|
131
|
-
|
|
132
|
-
}
|
|
306
|
+
export interface EditorOptions {
|
|
307
|
+
isReadOnly?: boolean;
|
|
308
|
+
}
|
|
309
|
+
export type EditorDocument = Document;
|
|
133
310
|
export type Page = Document & {
|
|
134
311
|
id: string;
|
|
135
312
|
status: string;
|
|
@@ -140,7 +317,19 @@ export type Page = Document & {
|
|
|
140
317
|
properties: {
|
|
141
318
|
title: string;
|
|
142
319
|
snippet: string;
|
|
320
|
+
image: {
|
|
321
|
+
id: string;
|
|
322
|
+
name: string;
|
|
323
|
+
size: number;
|
|
324
|
+
mimeType: string;
|
|
325
|
+
src: string;
|
|
326
|
+
width: number;
|
|
327
|
+
height: number;
|
|
328
|
+
};
|
|
143
329
|
path: string;
|
|
330
|
+
language?: string;
|
|
331
|
+
sourcePage?: string;
|
|
332
|
+
layout?: string | null;
|
|
144
333
|
tags: string[];
|
|
145
334
|
seo: {
|
|
146
335
|
title: string;
|
|
@@ -149,16 +338,31 @@ export type Page = Document & {
|
|
|
149
338
|
name: string;
|
|
150
339
|
content: string;
|
|
151
340
|
}>;
|
|
341
|
+
canonicalUrl: string;
|
|
342
|
+
noIndex: boolean;
|
|
343
|
+
noFollow: boolean;
|
|
344
|
+
structuredSchema: string;
|
|
152
345
|
};
|
|
153
346
|
social: {
|
|
154
347
|
title: string;
|
|
155
348
|
description: string;
|
|
349
|
+
image: {
|
|
350
|
+
id: string;
|
|
351
|
+
name: string;
|
|
352
|
+
size: number;
|
|
353
|
+
mimeType: string;
|
|
354
|
+
src: string;
|
|
355
|
+
width: number;
|
|
356
|
+
height: number;
|
|
357
|
+
};
|
|
156
358
|
metaTags: Array<{
|
|
157
359
|
property: string;
|
|
158
360
|
content: string;
|
|
159
361
|
}>;
|
|
160
362
|
};
|
|
161
363
|
};
|
|
364
|
+
extensions: Record<string, any>;
|
|
365
|
+
metadata: DocumentMetadata;
|
|
162
366
|
};
|
|
163
367
|
export type Box = {
|
|
164
368
|
depth: number;
|
|
@@ -180,10 +384,14 @@ export type BoxData = ElementBoxData | ElementSlotBoxData;
|
|
|
180
384
|
export type EditorViewportInfo = PreviewViewportInfo & {
|
|
181
385
|
top: number;
|
|
182
386
|
left: number;
|
|
387
|
+
breakpoint: string;
|
|
388
|
+
breakpoints: Breakpoint[];
|
|
183
389
|
};
|
|
184
390
|
export type PreviewViewportInfo = {
|
|
185
391
|
width: number;
|
|
186
392
|
height: number;
|
|
393
|
+
scrollWidth: number;
|
|
394
|
+
scrollHeight: number;
|
|
187
395
|
scrollX: number;
|
|
188
396
|
scrollY: number;
|
|
189
397
|
};
|
|
@@ -195,14 +403,34 @@ export type EditorViewportData = {
|
|
|
195
403
|
export type PreviewViewportData = {
|
|
196
404
|
boxes: BoxesData;
|
|
197
405
|
viewport: PreviewViewportInfo;
|
|
406
|
+
layout: string[];
|
|
198
407
|
};
|
|
199
408
|
export type ApiOptions = Record<string, any>;
|
|
200
409
|
export type GetPageOptions = ApiOptions;
|
|
201
|
-
export
|
|
410
|
+
export interface ListPagesOptions {
|
|
411
|
+
where?: Record<string, any>;
|
|
412
|
+
limit?: number;
|
|
413
|
+
after?: string;
|
|
414
|
+
sort?: string[];
|
|
415
|
+
search?: string;
|
|
416
|
+
}
|
|
417
|
+
export interface ListPagesMeta {
|
|
418
|
+
hasMoreItems: boolean;
|
|
419
|
+
totalCount: number;
|
|
420
|
+
cursor: string | null;
|
|
421
|
+
}
|
|
422
|
+
export interface ListPagesResult {
|
|
423
|
+
data: Array<Omit<PublicPage, "elements" | "bindings">>;
|
|
424
|
+
meta: ListPagesMeta;
|
|
425
|
+
}
|
|
202
426
|
export interface IDataProvider {
|
|
203
427
|
getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;
|
|
204
428
|
getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;
|
|
205
|
-
|
|
429
|
+
getLayoutBySlug(params: GetLayoutParams): Promise<PublicLayout | null>;
|
|
430
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
431
|
+
getPageExperiment(path: string): Promise<ActiveExperiment | null>;
|
|
432
|
+
getVariantContent(variantId: string): Promise<VariantContent | null>;
|
|
433
|
+
getExperimentPaused(experimentId: string): Promise<boolean>;
|
|
206
434
|
}
|
|
207
435
|
export interface IEnvironment {
|
|
208
436
|
isClient(): boolean;
|
|
@@ -211,12 +439,26 @@ export interface IEnvironment {
|
|
|
211
439
|
}
|
|
212
440
|
export interface IContentSdk {
|
|
213
441
|
getPage(path: string): Promise<PublicPage | null>;
|
|
214
|
-
|
|
442
|
+
getLayout(params: GetLayoutParams): Promise<PublicLayout | null>;
|
|
443
|
+
listPages(options?: ListPagesOptions): Promise<ListPagesResult>;
|
|
215
444
|
}
|
|
216
|
-
|
|
445
|
+
/**
|
|
446
|
+
* An input's renderer with settings for it. The settings belong to the named renderer: Webiny passes
|
|
447
|
+
* them to it untouched (`ElementInputRendererProps.settings`) and never reads them itself. `name` is
|
|
448
|
+
* required, so an input factory that spreads the author's input over its default renderer can't end
|
|
449
|
+
* up with settings and no renderer.
|
|
450
|
+
*/
|
|
451
|
+
export type InputRendererConfig = {
|
|
452
|
+
name: string;
|
|
453
|
+
settings?: Record<string, any>;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* The renderer as the editor resolves it (`InputAstNode.renderer`): always an object, `name` is `""`
|
|
457
|
+
* when the input names no renderer, `settings` is `{}` when it has none.
|
|
458
|
+
*/
|
|
459
|
+
export type ResolvedInputRenderer = {
|
|
217
460
|
name: string;
|
|
218
|
-
|
|
219
|
-
maxWidth: number;
|
|
461
|
+
settings: Record<string, any>;
|
|
220
462
|
};
|
|
221
463
|
export type BaseInput<T = any> = {
|
|
222
464
|
name: string;
|
|
@@ -231,7 +473,11 @@ export type BaseInput<T = any> = {
|
|
|
231
473
|
responsive?: boolean;
|
|
232
474
|
required?: boolean;
|
|
233
475
|
hideFromUi?: boolean;
|
|
234
|
-
|
|
476
|
+
/**
|
|
477
|
+
* The editor's renderer for this input: its name, or `{ name, settings }` to give the renderer
|
|
478
|
+
* settings (e.g. `{ name: "Webiny/Textarea", settings: { maxLength: 54 } }`).
|
|
479
|
+
*/
|
|
480
|
+
renderer?: string | InputRendererConfig;
|
|
235
481
|
list?: boolean;
|
|
236
482
|
translatable?: boolean;
|
|
237
483
|
};
|
|
@@ -276,12 +522,88 @@ export type SelectInput = BaseInput<string> & {
|
|
|
276
522
|
}[];
|
|
277
523
|
showResetAction?: boolean;
|
|
278
524
|
};
|
|
525
|
+
/**
|
|
526
|
+
* A radio option. `image` is a URL or a data URI, for renderers that draw options as pictures.
|
|
527
|
+
* `inputs` are shown while the option is selected. When any option has `inputs`, the radio is
|
|
528
|
+
* stored as an object: `<radio>/value` holds the selected option, and the options' inputs are its
|
|
529
|
+
* other children, merged by name (see `ComponentManifestToAstConverter`).
|
|
530
|
+
*/
|
|
531
|
+
export type RadioOption = {
|
|
532
|
+
value: string;
|
|
533
|
+
label?: string;
|
|
534
|
+
description?: string;
|
|
535
|
+
image?: string;
|
|
536
|
+
inputs?: ComponentInput[];
|
|
537
|
+
};
|
|
279
538
|
export type RadioInput = BaseInput<string> & {
|
|
280
539
|
type: "radio";
|
|
281
|
-
options:
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
540
|
+
options: RadioOption[];
|
|
541
|
+
};
|
|
542
|
+
export interface ContentEntryReference {
|
|
543
|
+
id: string;
|
|
544
|
+
modelId: string;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Query-mode configuration, declared by the component author. The editor then
|
|
548
|
+
* builds a query within these bounds (see `ContentEntryQueryValue`).
|
|
549
|
+
*/
|
|
550
|
+
/**
|
|
551
|
+
* A field the editor may sort by: a bare read-API sort key, or a key paired with
|
|
552
|
+
* a display label shown in the editor.
|
|
553
|
+
*/
|
|
554
|
+
export type ContentEntrySortField = string | {
|
|
555
|
+
field: string;
|
|
556
|
+
label?: string;
|
|
557
|
+
};
|
|
558
|
+
export interface ContentEntryQueryConfig {
|
|
559
|
+
/**
|
|
560
|
+
* Fields the editor may sort by (one at a time). Each `field` is a CMS read-API
|
|
561
|
+
* sort key — value fields as `values_<fieldId>` (e.g. `values_title`), meta
|
|
562
|
+
* fields bare (e.g. `createdOn`). Provide a `label` for a friendlier UI; a bare
|
|
563
|
+
* string uses the key as its label.
|
|
564
|
+
*/
|
|
565
|
+
sort?: {
|
|
566
|
+
fields: ContentEntrySortField[];
|
|
567
|
+
};
|
|
568
|
+
/** Editor-configurable result limit, with an optional default and hard cap. */
|
|
569
|
+
limit?: {
|
|
570
|
+
default?: number;
|
|
571
|
+
max?: number;
|
|
572
|
+
};
|
|
573
|
+
/** Show a free-text search box (matches fullTextSearch-enabled fields). */
|
|
574
|
+
search?: boolean;
|
|
575
|
+
/** Enable "load more" pagination in the rendered component. */
|
|
576
|
+
pagination?: boolean;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* The value stored for a query-mode input: the editor's chosen query.
|
|
580
|
+
* `modelId` identifies the CMS model so the frontend SDK can resolve the
|
|
581
|
+
* query without component manifests.
|
|
582
|
+
*/
|
|
583
|
+
export interface ContentEntryQueryValue {
|
|
584
|
+
modelId: string;
|
|
585
|
+
sort?: {
|
|
586
|
+
field: string;
|
|
587
|
+
order: "asc" | "desc";
|
|
588
|
+
};
|
|
589
|
+
limit?: number;
|
|
590
|
+
search?: string;
|
|
591
|
+
}
|
|
592
|
+
export type ContentEntryInput = BaseInput<ContentEntryReference | ContentEntryReference[] | ContentEntryQueryValue> & {
|
|
593
|
+
type: "contentEntry";
|
|
594
|
+
/**
|
|
595
|
+
* The content model(s) the editor may pick entries from. Author-fixed.
|
|
596
|
+
*/
|
|
597
|
+
models: string[];
|
|
598
|
+
/**
|
|
599
|
+
* "manual" (default): the editor hand-picks entries (stored as references).
|
|
600
|
+
* "query": the editor configures a dynamic query on the fixed model.
|
|
601
|
+
*/
|
|
602
|
+
mode?: "manual" | "query";
|
|
603
|
+
/**
|
|
604
|
+
* Query-mode configuration. Only used when `mode` is "query".
|
|
605
|
+
*/
|
|
606
|
+
query?: ContentEntryQueryConfig;
|
|
285
607
|
};
|
|
286
608
|
export type ObjectInput = BaseInput<Record<string, any>> & {
|
|
287
609
|
type: "object";
|
|
@@ -291,4 +613,27 @@ export type CustomInput = BaseInput<any> & {
|
|
|
291
613
|
type: string;
|
|
292
614
|
fields: ComponentInput[];
|
|
293
615
|
};
|
|
294
|
-
export type ComponentInput = TextInput | LongTextInput | NumberInput | BooleanInput | ColorInput | FileInput | DateTimeInput | LexicalInput | SelectInput | RadioInput | TagsInput | ObjectInput | SlotInput | CustomInput;
|
|
616
|
+
export type ComponentInput = TextInput | LongTextInput | NumberInput | BooleanInput | ColorInput | FileInput | DateTimeInput | LexicalInput | SelectInput | RadioInput | TagsInput | ObjectInput | SlotInput | ContentEntryInput | CustomInput;
|
|
617
|
+
export type ManifestInputsArray<TInputs, TAllowChildren extends boolean> = TAllowChildren extends true ? {
|
|
618
|
+
[K in Exclude<keyof TInputs, "children">]: InputFactory<K & string>;
|
|
619
|
+
}[Exclude<keyof TInputs, "children">][] : {
|
|
620
|
+
[K in keyof TInputs]: InputFactory<K & string>;
|
|
621
|
+
}[keyof TInputs][];
|
|
622
|
+
export type ManifestInputsObject<TInputs, TAllowChildren extends boolean> = TAllowChildren extends true ? {
|
|
623
|
+
[K in Exclude<keyof TInputs, "children">]: InputFactory<K & string>;
|
|
624
|
+
} : {
|
|
625
|
+
[K in keyof TInputs]: InputFactory<K & string>;
|
|
626
|
+
};
|
|
627
|
+
export type ComponentManifestInput<TInputs> = (Omit<ComponentManifest, "inputs" | "acceptsChildren" | "tags" | "onChange" | "onDescendantChange"> & {
|
|
628
|
+
acceptsChildren: true;
|
|
629
|
+
tags?: string[];
|
|
630
|
+
inputs?: ManifestInputsArray<TInputs, true> | ManifestInputsObject<TInputs, true>;
|
|
631
|
+
onChange?: ComponentChangeHandler<TInputs> | ComponentChangeHandler<TInputs>[];
|
|
632
|
+
onDescendantChange?: DescendantChangeHandler<TInputs> | DescendantChangeHandler<TInputs>[];
|
|
633
|
+
}) | (Omit<ComponentManifest, "inputs" | "acceptsChildren" | "tags" | "onChange" | "onDescendantChange"> & {
|
|
634
|
+
acceptsChildren?: false;
|
|
635
|
+
tags?: string[];
|
|
636
|
+
inputs: ManifestInputsArray<TInputs, false> | ManifestInputsObject<TInputs, false>;
|
|
637
|
+
onChange?: ComponentChangeHandler<TInputs> | ComponentChangeHandler<TInputs>[];
|
|
638
|
+
onDescendantChange?: DescendantChangeHandler<TInputs> | DescendantChangeHandler<TInputs>[];
|
|
639
|
+
});
|
package/types.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentManifest, GlobalDocument } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Add a default instance for every registered global component that has no stored instance,
|
|
4
|
+
* so a global defined in code appears immediately, without a data backfill.
|
|
5
|
+
* The page may still come with bindings for such a global: the layout's and the page's overrides, merged by
|
|
6
|
+
* the backend. They're kept over the defaults.
|
|
7
|
+
*/
|
|
8
|
+
export declare const withGlobalElementDefaults: (globals: GlobalDocument, components: Record<string, ComponentManifest>) => GlobalDocument;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { GlobalElementId } from "./globalElements.js";
|
|
2
|
+
import { createGlobalElementDocument } from "./createGlobalElementDocument.js";
|
|
3
|
+
const withGlobalElementDefaults = (globals, components)=>{
|
|
4
|
+
const missing = Object.values(components).filter((manifest)=>manifest.global && !globals.elements[GlobalElementId.fromName(manifest.name).toString()]);
|
|
5
|
+
if (!missing.length) return globals;
|
|
6
|
+
const result = {
|
|
7
|
+
elements: {
|
|
8
|
+
...globals.elements
|
|
9
|
+
},
|
|
10
|
+
bindings: {
|
|
11
|
+
...globals.bindings
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
for (const manifest of missing){
|
|
15
|
+
const defaults = createGlobalElementDocument(manifest.name, components);
|
|
16
|
+
Object.assign(result.elements, defaults.elements);
|
|
17
|
+
for(const id in defaults.bindings){
|
|
18
|
+
const delivered = globals.bindings[id];
|
|
19
|
+
result.bindings[id] = delivered ? withDefaultBindings(defaults.bindings[id], delivered) : defaults.bindings[id];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
const withDefaultBindings = (defaults, delivered)=>{
|
|
25
|
+
const overrides = {
|
|
26
|
+
...defaults.overrides
|
|
27
|
+
};
|
|
28
|
+
for(const breakpoint in delivered.overrides){
|
|
29
|
+
const base = defaults.overrides?.[breakpoint];
|
|
30
|
+
const value = delivered.overrides[breakpoint];
|
|
31
|
+
overrides[breakpoint] = {
|
|
32
|
+
...base,
|
|
33
|
+
...value,
|
|
34
|
+
inputs: {
|
|
35
|
+
...base?.inputs,
|
|
36
|
+
...value?.inputs
|
|
37
|
+
},
|
|
38
|
+
styles: {
|
|
39
|
+
...base?.styles,
|
|
40
|
+
...value?.styles
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
...defaults,
|
|
46
|
+
...delivered,
|
|
47
|
+
inputs: {
|
|
48
|
+
...defaults.inputs,
|
|
49
|
+
...delivered.inputs
|
|
50
|
+
},
|
|
51
|
+
styles: {
|
|
52
|
+
...defaults.styles,
|
|
53
|
+
...delivered.styles
|
|
54
|
+
},
|
|
55
|
+
overrides
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export { withGlobalElementDefaults };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=withGlobalElementDefaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withGlobalElementDefaults.js","sources":["../src/withGlobalElementDefaults.ts"],"sourcesContent":["import type { ComponentManifest, DocumentElementBindings, GlobalDocument } from \"./types.js\";\nimport { GlobalElementId } from \"./globalElements.js\";\nimport { createGlobalElementDocument } from \"./createGlobalElementDocument.js\";\n\n/**\n * Add a default instance for every registered global component that has no stored instance,\n * so a global defined in code appears immediately, without a data backfill.\n * The page may still come with bindings for such a global: the layout's and the page's overrides, merged by\n * the backend. They're kept over the defaults.\n */\nexport const withGlobalElementDefaults = (\n globals: GlobalDocument,\n components: Record<string, ComponentManifest>\n): GlobalDocument => {\n const missing = Object.values(components).filter(manifest => {\n return (\n manifest.global && !globals.elements[GlobalElementId.fromName(manifest.name).toString()]\n );\n });\n\n if (!missing.length) {\n return globals;\n }\n\n const result: GlobalDocument = {\n elements: { ...globals.elements },\n bindings: { ...globals.bindings }\n };\n\n for (const manifest of missing) {\n const defaults = createGlobalElementDocument(manifest.name, components);\n Object.assign(result.elements, defaults.elements);\n for (const id in defaults.bindings) {\n const delivered = globals.bindings[id];\n result.bindings[id] = delivered\n ? withDefaultBindings(defaults.bindings[id], delivered)\n : defaults.bindings[id];\n }\n }\n\n return result;\n};\n\n/**\n * The defaults are only the bottom layer: what's delivered wins per input and per style, also per\n * breakpoint override, so overriding one input of a global keeps the rest of its defaults.\n */\nconst withDefaultBindings = (\n defaults: DocumentElementBindings,\n delivered: DocumentElementBindings\n): DocumentElementBindings => {\n const overrides: NonNullable<DocumentElementBindings[\"overrides\"]> = {\n ...defaults.overrides\n };\n for (const breakpoint in delivered.overrides) {\n const base = defaults.overrides?.[breakpoint];\n const value = delivered.overrides[breakpoint];\n overrides[breakpoint] = {\n ...base,\n ...value,\n inputs: { ...base?.inputs, ...value?.inputs },\n styles: { ...base?.styles, ...value?.styles }\n };\n }\n\n return {\n ...defaults,\n ...delivered,\n inputs: { ...defaults.inputs, ...delivered.inputs },\n styles: { ...defaults.styles, ...delivered.styles },\n overrides\n };\n};\n"],"names":["withGlobalElementDefaults","globals","components","missing","Object","manifest","GlobalElementId","result","defaults","createGlobalElementDocument","id","delivered","withDefaultBindings","overrides","breakpoint","base","value"],"mappings":";;AAUO,MAAMA,4BAA4B,CACrCC,SACAC;IAEA,MAAMC,UAAUC,OAAO,MAAM,CAACF,YAAY,MAAM,CAACG,CAAAA,WAEzCA,SAAS,MAAM,IAAI,CAACJ,QAAQ,QAAQ,CAACK,gBAAgB,QAAQ,CAACD,SAAS,IAAI,EAAE,QAAQ,GAAG;IAIhG,IAAI,CAACF,QAAQ,MAAM,EACf,OAAOF;IAGX,MAAMM,SAAyB;QAC3B,UAAU;YAAE,GAAGN,QAAQ,QAAQ;QAAC;QAChC,UAAU;YAAE,GAAGA,QAAQ,QAAQ;QAAC;IACpC;IAEA,KAAK,MAAMI,YAAYF,QAAS;QAC5B,MAAMK,WAAWC,4BAA4BJ,SAAS,IAAI,EAAEH;QAC5DE,OAAO,MAAM,CAACG,OAAO,QAAQ,EAAEC,SAAS,QAAQ;QAChD,IAAK,MAAME,MAAMF,SAAS,QAAQ,CAAE;YAChC,MAAMG,YAAYV,QAAQ,QAAQ,CAACS,GAAG;YACtCH,OAAO,QAAQ,CAACG,GAAG,GAAGC,YAChBC,oBAAoBJ,SAAS,QAAQ,CAACE,GAAG,EAAEC,aAC3CH,SAAS,QAAQ,CAACE,GAAG;QAC/B;IACJ;IAEA,OAAOH;AACX;AAMA,MAAMK,sBAAsB,CACxBJ,UACAG;IAEA,MAAME,YAA+D;QACjE,GAAGL,SAAS,SAAS;IACzB;IACA,IAAK,MAAMM,cAAcH,UAAU,SAAS,CAAE;QAC1C,MAAMI,OAAOP,SAAS,SAAS,EAAE,CAACM,WAAW;QAC7C,MAAME,QAAQL,UAAU,SAAS,CAACG,WAAW;QAC7CD,SAAS,CAACC,WAAW,GAAG;YACpB,GAAGC,IAAI;YACP,GAAGC,KAAK;YACR,QAAQ;gBAAE,GAAGD,MAAM,MAAM;gBAAE,GAAGC,OAAO,MAAM;YAAC;YAC5C,QAAQ;gBAAE,GAAGD,MAAM,MAAM;gBAAE,GAAGC,OAAO,MAAM;YAAC;QAChD;IACJ;IAEA,OAAO;QACH,GAAGR,QAAQ;QACX,GAAGG,SAAS;QACZ,QAAQ;YAAE,GAAGH,SAAS,MAAM;YAAE,GAAGG,UAAU,MAAM;QAAC;QAClD,QAAQ;YAAE,GAAGH,SAAS,MAAM;YAAE,GAAGG,UAAU,MAAM;QAAC;QAClDE;IACJ;AACJ"}
|
package/IBindingsUpdater.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["IBindingsUpdater.ts"],"sourcesContent":["import type { JsonPatchOperation } from \"~/jsonPatch\";\nimport type { Document, DocumentElementBindings } from \"~/types\";\n\nexport interface IBindingsUpdater {\n applyToDocument(document: Document): void;\n createJsonPatch(bindings: DocumentElementBindings): JsonPatchOperation[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["IDocumentOperation.ts"],"sourcesContent":["import type { Document } from \"~/types.js\";\n\nexport interface IDocumentOperation {\n apply(document: Document): void;\n}\n"],"mappings":"","ignoreList":[]}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSettings"],"sources":["index.ts"],"sourcesContent":["export * from \"./createTheme\";\nexport * from \"./EditingSdk.js\";\nexport * from \"./LiveSdk.js\";\nexport * from \"./NullSdk.js\";\nexport * from \"./ContentSdk.js\";\nexport * from \"./Environment.js\";\nexport * from \"./DocumentStore.js\";\nexport * from \"./Logger.js\";\nexport * from \"./FunctionConverter.js\";\nexport * from \"./createInput.js\";\nexport * from \"./MouseTracker.js\";\nexport * from \"./ViewportManager.js\";\nexport * from \"./messenger/Messenger.js\";\nexport * from \"./messenger/MessageOrigin.js\";\nexport * from \"./types.js\";\nexport * from \"./DocumentStoreManager.js\";\nexport * from \"./BindingsProcessor.js\";\nexport * from \"./ResizeObserver.js\";\nexport * from \"./BindingsResolver.js\";\nexport * from \"./createElement.js\";\nexport * from \"./registerComponentGroup.js\";\nexport * from \"./jsonPatch.js\";\nexport * from \"./headersProvider.js\";\nexport * from \"./ComponentManifestToAstConverter.js\";\nexport * from \"./findMatchingAstNode.js\";\nexport * from \"./InheritanceProcessor.js\";\nexport * from \"./InputBindingsProcessor.js\";\nexport * from \"./StylesBindingsProcessor.js\";\nexport * from \"./ElementFactory.js\";\nexport { StyleSettings } from \"./constants.js\";\nexport * from \"./constants\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa;AACtB","ignoreList":[]}
|