@contentful/experiences-core 1.6.0-prerelease-20240603T1503-1bf510c.0 → 1.7.0-dev-20240604T1720-355786e.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { isComponentAllowedOnRoot, isContentfulStructureComponent, isEmptyStructureWithRelativeHeight } from './utils/components.js';
1
+ export { isComponentAllowedOnRoot, isContentfulStructureComponent, isStructureWithRelativeHeight } from './utils/components.js';
2
2
  export { findOutermostCoordinates, getElementCoordinates } from './utils/domValues.js';
3
3
  export { VisualEditorMessagePayload, doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderConfig } from './utils/validations.js';
4
4
  export { buildCfStyles, buildStyleTag, calculateNodeDefaultHeight, toCSSAttribute } from './utils/styleUtils/stylesUtils.js';
package/dist/index.js CHANGED
@@ -82,10 +82,8 @@ const structureComponents = new Set([
82
82
  ]);
83
83
  const isContentfulStructureComponent = (componentId) => structureComponents.has(componentId ?? '');
84
84
  const isComponentAllowedOnRoot = (componentId) => isContentfulStructureComponent(componentId) || componentId === CONTENTFUL_COMPONENTS.divider.id;
85
- const isEmptyStructureWithRelativeHeight = (children, componentId, height) => {
86
- return (children === 0 &&
87
- isContentfulStructureComponent(componentId) &&
88
- !height?.toString().endsWith('px'));
85
+ const isStructureWithRelativeHeight = (componentId, height) => {
86
+ return isContentfulStructureComponent(componentId) && !height?.toString().endsWith('px');
89
87
  };
90
88
 
91
89
  const findOutermostCoordinates = (first, second) => {
@@ -1217,13 +1215,31 @@ const columnsBuiltInStyles = {
1217
1215
  };
1218
1216
 
1219
1217
  let designTokensRegistry = {};
1218
+ // This function is used to ensure that the composite values are valid since composite values are optional.
1219
+ // Therefore only border and in the future text related design tokens are/will be checked in this funciton.
1220
+ // Ensuring values for simple key-value design tokens are not neccessary since they are required via typescript.
1221
+ const ensureValidCompositeValues = (designTokenDefinition) => {
1222
+ // TODO: add validation logic when text related design tokens are added
1223
+ // Border validation
1224
+ if (designTokenDefinition.border) {
1225
+ for (const borderKey in designTokenDefinition.border) {
1226
+ const borderValue = designTokenDefinition.border[borderKey];
1227
+ designTokenDefinition.border[borderKey] = {
1228
+ width: borderValue.width || '1px',
1229
+ style: borderValue.style || 'solid',
1230
+ color: borderValue.color || '#000000',
1231
+ };
1232
+ }
1233
+ }
1234
+ return designTokenDefinition;
1235
+ };
1220
1236
  /**
1221
1237
  * Register design tokens styling
1222
1238
  * @param designTokenDefinition - {[key:string]: Record<string, string>}
1223
1239
  * @returns void
1224
1240
  */
1225
1241
  const defineDesignTokens = (designTokenDefinition) => {
1226
- Object.assign(designTokensRegistry, designTokenDefinition);
1242
+ Object.assign(designTokensRegistry, ensureValidCompositeValues(designTokenDefinition));
1227
1243
  };
1228
1244
  const templateStringRegex = /\${(.+?)}/g;
1229
1245
  const getDesignTokenRegistration = (breakpointValue, variableName) => {
@@ -2897,5 +2913,5 @@ async function fetchById({ client, experienceTypeId, id, localeCode, }) {
2897
2913
  }
2898
2914
  }
2899
2915
 
2900
- export { DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, columnsDefinition, containerBuiltInStyles, containerDefinition, createExperience, defineBreakpoints, defineDesignTokens, designTokensRegistry, dividerBuiltInStyles, dividerDefinition, doesMismatchMessageSchema, fetchById, fetchBySlug, findOutermostCoordinates, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTemplateValue, getValueForBreakpoint, isComponentAllowedOnRoot, isContentfulStructureComponent, isDeepPath, isEmptyStructureWithRelativeHeight, isExperienceEntry, isLink, isLinkToAsset, lastPathNamedSegmentEq, mediaQueryMatcher, optionalBuiltInStyles, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveHyperlinkPattern, runBreakpointsValidation, sectionBuiltInStyles, sectionDefinition, sendMessage, singleColumnBuiltInStyles, singleColumnDefinition, supportedModes, toCSSAttribute, transformBoundContentValue, tryParseMessage, validateExperienceBuilderConfig };
2916
+ export { DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, columnsDefinition, containerBuiltInStyles, containerDefinition, createExperience, defineBreakpoints, defineDesignTokens, designTokensRegistry, dividerBuiltInStyles, dividerDefinition, doesMismatchMessageSchema, fetchById, fetchBySlug, findOutermostCoordinates, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTemplateValue, getValueForBreakpoint, isComponentAllowedOnRoot, isContentfulStructureComponent, isDeepPath, isExperienceEntry, isLink, isLinkToAsset, isStructureWithRelativeHeight, lastPathNamedSegmentEq, mediaQueryMatcher, optionalBuiltInStyles, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveHyperlinkPattern, runBreakpointsValidation, sectionBuiltInStyles, sectionDefinition, sendMessage, singleColumnBuiltInStyles, singleColumnDefinition, supportedModes, toCSSAttribute, transformBoundContentValue, tryParseMessage, validateExperienceBuilderConfig };
2901
2917
  //# sourceMappingURL=index.js.map