@contentful/experiences-core 1.22.1-dev-20241111T0918-dbe183a.0 → 1.23.0-beta.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/dist/types.d.ts CHANGED
@@ -5,6 +5,22 @@ import { Document } from '@contentful/rich-text-types';
5
5
  import { ComponentDefinitionPropertyType, ComponentPropertyValue, ExperienceDataSource, ExperienceUnboundValues, Breakpoint, ExperienceComponentTree, ExperienceUsedComponents, ExperienceComponentSettings, ValuesByBreakpoint, PrimitiveValue } from '@contentful/experiences-validators';
6
6
  export { BoundValue, Breakpoint, ComponentDefinitionPropertyType as ComponentDefinitionVariableType, ComponentPropertyValue, ComponentTreeNode, ComponentValue, DesignValue, ExperienceComponentSettings, ExperienceDataSource, ExperienceUnboundValues, PrimitiveValue, SchemaVersions, UnboundValue, ValuesByBreakpoint } from '@contentful/experiences-validators';
7
7
 
8
+ type ComponentDefinitionVariableTypeMap = {
9
+ Array: unknown[];
10
+ Boolean: boolean;
11
+ Date: string;
12
+ Hyperlink: string;
13
+ Link: Record<string, unknown>;
14
+ Location: {
15
+ lon: number;
16
+ lat: number;
17
+ };
18
+ Media: Record<string, unknown> | string;
19
+ Number: number;
20
+ Object: Record<string, unknown>;
21
+ RichText: string;
22
+ Text: string;
23
+ };
8
24
  type ScrollStateKey = keyof typeof SCROLL_STATES;
9
25
  type ScrollState = (typeof SCROLL_STATES)[ScrollStateKey];
10
26
  type OutgoingEventKey = keyof typeof OUTGOING_EVENTS;
@@ -22,7 +38,7 @@ interface Link<T extends string> {
22
38
  }
23
39
  type VariableFormats = 'URL';
24
40
  type ValidationOption<T extends ComponentDefinitionPropertyType> = {
25
- value: T extends 'Text' ? string : T extends 'Number' ? number : never;
41
+ value: ComponentDefinitionVariableTypeMap[T];
26
42
  displayName?: string;
27
43
  };
28
44
  type ComponentDefinitionVariableValidation<T extends ComponentDefinitionPropertyType> = {
@@ -36,7 +52,7 @@ interface ComponentDefinitionVariableBase<T extends ComponentDefinitionPropertyT
36
52
  group?: 'style' | 'content';
37
53
  description?: string;
38
54
  displayName?: string;
39
- defaultValue?: string | boolean | number | Record<any, any>;
55
+ defaultValue?: ComponentDefinitionVariableTypeMap[T];
40
56
  }
41
57
  type ComponentDefinitionVariable<T extends ComponentDefinitionPropertyType = ComponentDefinitionPropertyType> = ComponentDefinitionVariableBase<T>;
42
58
  type ComponentDefinition<T extends ComponentDefinitionPropertyType = ComponentDefinitionPropertyType> = {
@@ -45,7 +61,7 @@ type ComponentDefinition<T extends ComponentDefinitionPropertyType = ComponentDe
45
61
  category?: string;
46
62
  thumbnailUrl?: string;
47
63
  hyperlinkPattern?: string;
48
- variables: Partial<Record<ContainerStyleVariableName, ComponentDefinitionVariable<T>>> & Record<string, ComponentDefinitionVariable<T>>;
64
+ variables: Partial<DesignVariableMap> & Record<string, ComponentDefinitionVariable<T>>;
49
65
  slots?: Record<string, {
50
66
  displayName: string;
51
67
  }>;
@@ -69,6 +85,9 @@ type ComponentRegistration = {
69
85
  };
70
86
  type ComponentRegistrationOptions = {
71
87
  enabledBuiltInComponents?: string[];
88
+ experimentalComponents?: {
89
+ carousel?: boolean;
90
+ };
72
91
  };
73
92
  type Binding = {
74
93
  spaceId: string;
@@ -155,6 +174,50 @@ type StyleProps = {
155
174
  cfWrapColumns: boolean;
156
175
  cfWrapColumnsCount: string;
157
176
  };
177
+ /**
178
+ * Internally defined style variables mapped to each variable type
179
+ */
180
+ type DesignVariableTypes = {
181
+ cfVisibility: 'Boolean';
182
+ cfHorizontalAlignment: 'Text';
183
+ cfVerticalAlignment: 'Text';
184
+ cfMargin: 'Text';
185
+ cfPadding: 'Text';
186
+ cfBackgroundColor: 'Text';
187
+ cfWidth: 'Text';
188
+ cfMaxWidth: 'Text';
189
+ cfHeight: 'Text';
190
+ cfFlexDirection: 'Text';
191
+ cfFlexWrap: 'Text';
192
+ cfFlexReverse: 'Boolean';
193
+ cfBorder: 'Text';
194
+ cfBorderRadius: 'Text';
195
+ cfGap: 'Text';
196
+ cfHyperlink: 'Hyperlink';
197
+ cfImageAsset: 'Media';
198
+ cfImageOptions: 'Object';
199
+ cfBackgroundImageUrl: 'Media';
200
+ cfBackgroundImageOptions: 'Object';
201
+ cfOpenInNewTab: 'Boolean';
202
+ cfFontSize: 'Text';
203
+ cfFontWeight: 'Text';
204
+ cfLineHeight: 'Text';
205
+ cfLetterSpacing: 'Text';
206
+ cfTextColor: 'Text';
207
+ cfTextAlign: 'Text';
208
+ cfTextTransform: 'Text';
209
+ cfTextBold: 'Boolean';
210
+ cfTextItalic: 'Boolean';
211
+ cfTextUnderline: 'Boolean';
212
+ cfColumns: 'Text';
213
+ cfColumnSpan: 'Text';
214
+ cfColumnSpanLock: 'Boolean';
215
+ cfWrapColumns: 'Boolean';
216
+ cfWrapColumnsCount: 'Text';
217
+ };
218
+ type DesignVariableMap = {
219
+ [K in keyof DesignVariableTypes]: ComponentDefinitionVariable<DesignVariableTypes[K]>;
220
+ };
158
221
  type CSSProperties = React.CSSProperties;
159
222
  type ContainerStyleVariableName = keyof StyleProps;
160
223
  type ExperienceFields = {
@@ -474,4 +537,4 @@ type IncomingMessage = {
474
537
  };
475
538
  }[keyof INCOMING_EVENT_PAYLOADS];
476
539
 
477
- export type { AssembliesAddedPayload, AssembliesRegisteredPayload, BackgroundImageAlignmentOption, BackgroundImageOptions, BackgroundImageScalingOption, Binding, BindingMap, BindingMapByBlockId, BoundComponentPropertyTypes, CSSProperties, CanvasErrorPayload, CanvasReloadPayload, CanvasResizedPayload, CanvasScrollPayload, ComponentBinding, ComponentDefinition, ComponentDefinitionVariable, ComponentDefinitionVariableBase, ComponentDefinitionVariableValidation, ComponentDragCanceledPayload, ComponentDragEndedPayload, ComponentDragStartedPayload, ComponentDraggingChangedPayload, ComponentDroppedPayload, ComponentMoveEndedPayload, ComponentMoveStartedPayload, ComponentMovedPayload, ComponentRegistration, ComponentRegistrationOptions, ComponentSelectedPayload, ConnectedPayload, ContainerStyleVariableName, Coordinates, DataSourceEntryValueType, DesignTokensDefinition, DesignTokensPayload, DragWrapperProps, Experience, ExperienceEntry, ExperienceFields, ExperienceTree, ExperienceTreeNode, ExperienceUpdatedPayload, HoverComponentPayload, HoveredElement, ImageLoadingOption, ImageObjectFitOption, ImageObjectPositionOption, ImageOptions, IncomingComponentDragCanceledPayload, IncomingComponentMoveEndedPayload, IncomingEvent, IncomingMessage, IncomingMouseMovePayload, InternalEvent, Link, ManagementEntity, MouseMovePayload, NewHoveredElementPayload, OptimizedBackgroundImageAsset, OptimizedImageAsset, OutgoingEvent, OutgoingMessage, OutsideCanvasClickPayload, RawCoordinates, RecursiveDesignTokenDefinition, RegisteredBreakpointsPayload, RegisteredComponentsPayload, RequestComponentTreeUpdatePayload, RequestEditorModePayload, RequestEntitiesMessage, RequestEntitiesPayload, RequestReadOnlyModePayload, RequestedEntitiesMessage, RequestedEntitiesPayload, ResolveDesignValueType, SDKFeaturesPayload, ScrollState, SelectComponentPayload, SendMessageParams, StyleProps, UpdateSelectedComponentCoordinatesPayload, UpdatedEntityPayload, ValidationOption, VariableFormats, WrapperTags };
540
+ export type { AssembliesAddedPayload, AssembliesRegisteredPayload, BackgroundImageAlignmentOption, BackgroundImageOptions, BackgroundImageScalingOption, Binding, BindingMap, BindingMapByBlockId, BoundComponentPropertyTypes, CSSProperties, CanvasErrorPayload, CanvasReloadPayload, CanvasResizedPayload, CanvasScrollPayload, ComponentBinding, ComponentDefinition, ComponentDefinitionVariable, ComponentDefinitionVariableBase, ComponentDefinitionVariableValidation, ComponentDragCanceledPayload, ComponentDragEndedPayload, ComponentDragStartedPayload, ComponentDraggingChangedPayload, ComponentDroppedPayload, ComponentMoveEndedPayload, ComponentMoveStartedPayload, ComponentMovedPayload, ComponentRegistration, ComponentRegistrationOptions, ComponentSelectedPayload, ConnectedPayload, ContainerStyleVariableName, Coordinates, DataSourceEntryValueType, DesignTokensDefinition, DesignTokensPayload, DesignVariableMap, DesignVariableTypes, DragWrapperProps, Experience, ExperienceEntry, ExperienceFields, ExperienceTree, ExperienceTreeNode, ExperienceUpdatedPayload, HoverComponentPayload, HoveredElement, ImageLoadingOption, ImageObjectFitOption, ImageObjectPositionOption, ImageOptions, IncomingComponentDragCanceledPayload, IncomingComponentMoveEndedPayload, IncomingEvent, IncomingMessage, IncomingMouseMovePayload, InternalEvent, Link, ManagementEntity, MouseMovePayload, NewHoveredElementPayload, OptimizedBackgroundImageAsset, OptimizedImageAsset, OutgoingEvent, OutgoingMessage, OutsideCanvasClickPayload, RawCoordinates, RecursiveDesignTokenDefinition, RegisteredBreakpointsPayload, RegisteredComponentsPayload, RequestComponentTreeUpdatePayload, RequestEditorModePayload, RequestEntitiesMessage, RequestEntitiesPayload, RequestReadOnlyModePayload, RequestedEntitiesMessage, RequestedEntitiesPayload, ResolveDesignValueType, SDKFeaturesPayload, ScrollState, SelectComponentPayload, SendMessageParams, StyleProps, UpdateSelectedComponentCoordinatesPayload, UpdatedEntityPayload, ValidationOption, VariableFormats, WrapperTags };
@@ -42,5 +42,11 @@ declare const checkIsAssembly: ({ componentId, usedComponents, }: {
42
42
  **/
43
43
  declare const checkIsAssemblyEntry: (entry: Entry) => boolean;
44
44
  declare const checkIsAssemblyDefinition: (component?: ComponentDefinition) => boolean;
45
+ interface ParsedValue {
46
+ value: number;
47
+ unit: 'px' | 'em' | 'rem';
48
+ }
49
+ declare function parseCSSValue(input: string): ParsedValue | null;
50
+ declare function getTargetValueInPixels(targetWidthObject: ParsedValue): number;
45
51
 
46
- export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData };
52
+ export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData, getTargetValueInPixels, parseCSSValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-core",
3
- "version": "1.22.1-dev-20241111T0918-dbe183a.0",
3
+ "version": "1.23.0-beta.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -69,11 +69,11 @@
69
69
  "vitest": "^2.1.1"
70
70
  },
71
71
  "dependencies": {
72
- "@contentful/experiences-validators": "1.22.1-dev-20241111T0918-dbe183a.0",
72
+ "@contentful/experiences-validators": "1.23.0-beta.0",
73
73
  "@contentful/rich-text-types": "^16.3.0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "contentful": ">=10.6.0"
77
77
  },
78
- "gitHead": "14c3f9dd5523673a0c49c80d00aef3503e87e324"
78
+ "gitHead": "99ba93f0ec78f5349add87a954e4aa48f27d6d9a"
79
79
  }
@@ -1,9 +0,0 @@
1
- import { ComponentDefinition } from '../types.js';
2
-
3
- declare const sectionDefinition: ComponentDefinition;
4
- declare const containerDefinition: ComponentDefinition;
5
- declare const columnsDefinition: ComponentDefinition;
6
- declare const singleColumnDefinition: ComponentDefinition;
7
- declare const dividerDefinition: ComponentDefinition;
8
-
9
- export { columnsDefinition, containerDefinition, dividerDefinition, sectionDefinition, singleColumnDefinition };