@contentful/experiences-core 1.37.3-dev-20250522T1032-0caa03f.0 → 1.38.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/index.js CHANGED
@@ -900,7 +900,13 @@ const PatternPropertyDefinitionSchema = z.object({
900
900
  }),
901
901
  }))
902
902
  .optional(),
903
- contentTypes: z.record(z.string(), z.any()),
903
+ contentTypes: z.record(z.string(), z.object({
904
+ sys: z.object({
905
+ type: z.literal('Link'),
906
+ id: z.string(),
907
+ linkType: z.enum(['ContentType']),
908
+ }),
909
+ })),
904
910
  });
905
911
  const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
906
912
  // TODO: finalize schema structure before release
@@ -1378,11 +1384,21 @@ const builtInStylesWithDesignTokens = [
1378
1384
  const isValidBreakpointValue = (value) => {
1379
1385
  return value !== undefined && value !== null && value !== '';
1380
1386
  };
1381
- const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex, variableName, resolveDesignTokens = true) => {
1387
+ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpointIndex, fallbackBreakpointIndex,
1388
+ /** Provide the name for built-in styles to replace design tokens. Supported properties are:
1389
+ * cfMargin, cfPadding, cfGap, cfWidth, cfHeight, cfBackgroundColor,
1390
+ * cfBorder, cfBorderRadius, cfFontSize, cfLineHeight, cfLetterSpacing,
1391
+ * cfTextColor, cfMaxWidth
1392
+ */
1393
+ propertyName, resolveDesignTokens = true) => {
1382
1394
  const eventuallyResolveDesignTokens = (value) => {
1395
+ // This is used externally in the web app to determine the original persisted value
1396
+ if (!resolveDesignTokens) {
1397
+ return value;
1398
+ }
1383
1399
  // For some built-in design properties, we support design tokens
1384
- if (builtInStylesWithDesignTokens.includes(variableName)) {
1385
- return getDesignTokenRegistration(value, variableName);
1400
+ if (propertyName && builtInStylesWithDesignTokens.includes(propertyName)) {
1401
+ return getDesignTokenRegistration(value, propertyName);
1386
1402
  }
1387
1403
  // For all other properties, we just return the breakpoint-specific value
1388
1404
  return value;
@@ -1393,18 +1409,12 @@ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpoint
1393
1409
  const breakpointId = breakpoints[index]?.id;
1394
1410
  if (isValidBreakpointValue(valuesByBreakpoint[breakpointId])) {
1395
1411
  // If the value is defined, we use it and stop the breakpoints cascade
1396
- if (resolveDesignTokens) {
1397
- return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
1398
- }
1399
- return valuesByBreakpoint[breakpointId];
1412
+ return eventuallyResolveDesignTokens(valuesByBreakpoint[breakpointId]);
1400
1413
  }
1401
1414
  }
1402
1415
  const fallbackBreakpointId = breakpoints[fallbackBreakpointIndex]?.id;
1403
1416
  if (isValidBreakpointValue(valuesByBreakpoint[fallbackBreakpointId])) {
1404
- if (resolveDesignTokens) {
1405
- return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
1406
- }
1407
- return valuesByBreakpoint[fallbackBreakpointId];
1417
+ return eventuallyResolveDesignTokens(valuesByBreakpoint[fallbackBreakpointId]);
1408
1418
  }
1409
1419
  }
1410
1420
  else {
@@ -2703,7 +2713,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
2703
2713
  const optionsVariableName = 'cfImageOptions';
2704
2714
  const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
2705
2715
  ? variables[optionsVariableName].valuesByBreakpoint
2706
- : {}, optionsVariableName);
2716
+ : {});
2707
2717
  if (!options) {
2708
2718
  console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
2709
2719
  return;
@@ -2728,7 +2738,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
2728
2738
  const optionsVariableName = 'cfBackgroundImageOptions';
2729
2739
  const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
2730
2740
  ? variables[optionsVariableName].valuesByBreakpoint
2731
- : {}, optionsVariableName);
2741
+ : {});
2732
2742
  if (!options) {
2733
2743
  console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
2734
2744
  return;