@contentful/experiences-core 1.37.1-dev-20250513T1442-6484576.0 → 1.37.1-dev-20250514T1115-cc6f809.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 +1 -1
- package/dist/index.js +33 -11
- package/dist/index.js.map +1 -1
- package/dist/utils/breakpoints.d.ts +5 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isPatternComponent, isStructureWithRelativeHeight } from './utils/components.js';
|
|
2
|
-
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, isValidBreakpointValue, mediaQueryMatcher } from './utils/breakpoints.js';
|
|
2
|
+
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, isValidBreakpointValue, mediaQueryMatcher, mergeDesignValuesByBreakpoint } from './utils/breakpoints.js';
|
|
3
3
|
export { DebugLogger, debug, disableDebug, enableDebug } from './utils/debugLogger.js';
|
|
4
4
|
export { findOutermostCoordinates, getElementCoordinates } from './utils/domValues.js';
|
|
5
5
|
export { isLinkToAsset } from './utils/isLinkToAsset.js';
|
package/dist/index.js
CHANGED
|
@@ -1412,6 +1412,21 @@ const getValueForBreakpoint = (valuesByBreakpoint, breakpoints, activeBreakpoint
|
|
|
1412
1412
|
return valuesByBreakpoint;
|
|
1413
1413
|
}
|
|
1414
1414
|
};
|
|
1415
|
+
/** Overwrites the default value breakpoint by breakpoint. If a breakpoint
|
|
1416
|
+
* is not overwritten, it will fall back to the default. */
|
|
1417
|
+
const mergeDesignValuesByBreakpoint = (defaultValue, overwriteValue) => {
|
|
1418
|
+
const mergedValuesByBreakpoint = { ...defaultValue.valuesByBreakpoint };
|
|
1419
|
+
for (const [breakpointId, value] of Object.entries(overwriteValue.valuesByBreakpoint)) {
|
|
1420
|
+
if (!isValidBreakpointValue(value)) {
|
|
1421
|
+
continue;
|
|
1422
|
+
}
|
|
1423
|
+
mergedValuesByBreakpoint[breakpointId] = value;
|
|
1424
|
+
}
|
|
1425
|
+
return {
|
|
1426
|
+
type: 'DesignValue',
|
|
1427
|
+
valuesByBreakpoint: mergedValuesByBreakpoint,
|
|
1428
|
+
};
|
|
1429
|
+
};
|
|
1415
1430
|
|
|
1416
1431
|
const CF_DEBUG_KEY = 'cf_debug';
|
|
1417
1432
|
class DebugLogger {
|
|
@@ -2295,9 +2310,10 @@ const resolveComponentVariablesOverwrites = ({ patternNode, wrapperComponentVari
|
|
|
2295
2310
|
const overwritingValue = wrapperComponentVariablesOverwrites?.[propertyValue.key];
|
|
2296
2311
|
// Property definition from the parent pattern
|
|
2297
2312
|
const propertyDefinition = wrapperComponentSettings?.variableDefinitions?.[propertyValue.key];
|
|
2313
|
+
const defaultValue = propertyDefinition?.defaultValue;
|
|
2298
2314
|
// The overwriting value is either a custom value from the experience or default value from a
|
|
2299
2315
|
// wrapping pattern node that got trickled down to this nesting level.
|
|
2300
|
-
resolvedValues[propertyName] = overwritingValue
|
|
2316
|
+
resolvedValues[propertyName] = mergeDefaultAndOverwriteValues(defaultValue, overwritingValue);
|
|
2301
2317
|
}
|
|
2302
2318
|
else {
|
|
2303
2319
|
// Keep raw values
|
|
@@ -2382,15 +2398,15 @@ const resolveBackgroundImageBinding = ({ variableData, getBoundEntityById, dataS
|
|
|
2382
2398
|
// @ts-expect-error TODO: Types coming from validations erroneously assume that `defaultValue` can be a primitive value (e.g. string or number)
|
|
2383
2399
|
const defaultValueKey = variableDefinition.defaultValue?.key;
|
|
2384
2400
|
const defaultValue = unboundValues[defaultValueKey].value;
|
|
2385
|
-
const
|
|
2386
|
-
//
|
|
2387
|
-
if (!
|
|
2401
|
+
const overwriteValue = componentVariablesOverwrites?.[variableDefinitionKey];
|
|
2402
|
+
// overwriteValue is a ComponentValue we can safely return the default value
|
|
2403
|
+
if (!overwriteValue || overwriteValue.type === 'ComponentValue') {
|
|
2388
2404
|
return defaultValue;
|
|
2389
2405
|
}
|
|
2390
|
-
// at this point
|
|
2406
|
+
// at this point overwriteValue will either be type of 'DesignValue' or 'BoundValue'
|
|
2391
2407
|
// so we recursively run resolution again to resolve it
|
|
2392
2408
|
const resolvedValue = resolveBackgroundImageBinding({
|
|
2393
|
-
variableData:
|
|
2409
|
+
variableData: overwriteValue,
|
|
2394
2410
|
getBoundEntityById,
|
|
2395
2411
|
dataSource,
|
|
2396
2412
|
unboundValues,
|
|
@@ -2543,10 +2559,10 @@ const indexByBreakpoint = ({ variables, breakpointIds, getBoundEntityById, unbou
|
|
|
2543
2559
|
let resolvedVariableData = variableData;
|
|
2544
2560
|
if (variableData.type === 'ComponentValue') {
|
|
2545
2561
|
const variableDefinition = componentSettings?.variableDefinitions[variableData.key];
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2562
|
+
const defaultValue = variableDefinition.defaultValue;
|
|
2563
|
+
if (variableDefinition.group === 'style' && defaultValue !== undefined) {
|
|
2564
|
+
const overwriteVariableData = componentVariablesOverwrites?.[variableData.key];
|
|
2565
|
+
resolvedVariableData = mergeDefaultAndOverwriteValues(defaultValue, overwriteVariableData);
|
|
2550
2566
|
}
|
|
2551
2567
|
}
|
|
2552
2568
|
if (resolvedVariableData.type !== 'DesignValue') {
|
|
@@ -2602,6 +2618,12 @@ const toMediaQuery = ({ condition, cssByClassName }) => {
|
|
|
2602
2618
|
const mediaQueryRule = evaluation === '<' ? 'max-width' : 'min-width';
|
|
2603
2619
|
return `@media(${mediaQueryRule}:${pixelValue}){${mediaQueryStyles}}`;
|
|
2604
2620
|
};
|
|
2621
|
+
function mergeDefaultAndOverwriteValues(defaultValue, overwriteValue) {
|
|
2622
|
+
if (defaultValue?.type === 'DesignValue' && overwriteValue?.type === 'DesignValue') {
|
|
2623
|
+
return mergeDesignValuesByBreakpoint(defaultValue, overwriteValue);
|
|
2624
|
+
}
|
|
2625
|
+
return overwriteValue ?? defaultValue;
|
|
2626
|
+
}
|
|
2605
2627
|
|
|
2606
2628
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2607
2629
|
function get(obj, path) {
|
|
@@ -4114,5 +4136,5 @@ async function fetchById({ client, experienceTypeId, id, localeCode, isEditorMod
|
|
|
4114
4136
|
}
|
|
4115
4137
|
}
|
|
4116
4138
|
|
|
4117
|
-
export { DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, designTokensRegistry, detachExperienceStyles, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, indexByBreakpoint, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isExperienceEntry, isLink, isLinkToAsset, isPatternComponent, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sectionBuiltInStyles, sendMessage, singleColumnBuiltInStyles, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, treeMap, treeVisit, tryParseMessage, validateExperienceBuilderConfig };
|
|
4139
|
+
export { DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, designTokensRegistry, detachExperienceStyles, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, indexByBreakpoint, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isExperienceEntry, isLink, isLinkToAsset, isPatternComponent, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, mergeDesignValuesByBreakpoint, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sectionBuiltInStyles, sendMessage, singleColumnBuiltInStyles, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, treeMap, treeVisit, tryParseMessage, validateExperienceBuilderConfig };
|
|
4118
4140
|
//# sourceMappingURL=index.js.map
|