@contentful/experiences-core 1.34.0 → 1.34.1-dev-20250305T1630-a40e5df.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 +2 -2
- package/dist/index.js +189 -201
- package/dist/index.js.map +1 -1
- package/dist/utils/breakpoints.d.ts +1 -1
- package/dist/utils/styleUtils/ssrStyles.d.ts +49 -15
- package/dist/utils/styleUtils/stylesUtils.d.ts +46 -3
- package/package.json +3 -3
|
@@ -7,7 +7,7 @@ declare const mediaQueryMatcher: (breakpoints: Breakpoint[]) => [{
|
|
|
7
7
|
}[], Record<string, boolean>];
|
|
8
8
|
declare const getActiveBreakpointIndex: (breakpoints: Breakpoint[], mediaQueryMatches: Record<string, boolean>, fallbackBreakpointIndex: number) => number;
|
|
9
9
|
declare const getFallbackBreakpointIndex: (breakpoints: Breakpoint[]) => number;
|
|
10
|
-
declare const isValidBreakpointValue: (value: PrimitiveValue) =>
|
|
10
|
+
declare const isValidBreakpointValue: (value: PrimitiveValue) => value is Exclude<PrimitiveValue, undefined>;
|
|
11
11
|
declare const getValueForBreakpoint: (valuesByBreakpoint: ValuesByBreakpoint | undefined, breakpoints: Breakpoint[], activeBreakpointIndex: number, fallbackBreakpointIndex: number, variableName: string, resolveDesignTokens?: boolean) => string | number | boolean | Record<any, any> | undefined;
|
|
12
12
|
|
|
13
13
|
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, isValidBreakpointValue, mediaQueryMatcher };
|
|
@@ -18,6 +18,41 @@ declare const resolveBackgroundImageBinding: ({ variableData, getBoundEntityById
|
|
|
18
18
|
componentSettings?: ExperienceComponentSettings;
|
|
19
19
|
componentVariablesOverwrites?: Record<string, ComponentPropertyValue>;
|
|
20
20
|
}) => string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Takes the initial set of properties, filters only design properties that will be mapped to CSS and
|
|
23
|
+
* re-organizes them to be indexed by breakpoint ID ("breakpoint > variable > value"). It will
|
|
24
|
+
* also resolve the design/ component values to plain values.
|
|
25
|
+
*
|
|
26
|
+
* **Example Input**
|
|
27
|
+
* ```
|
|
28
|
+
* variables = {
|
|
29
|
+
* cfMargin: { type: 'DesignValue', valuesByBreakpoint: { desktop: '1px', tablet: '2px' } },
|
|
30
|
+
* cfPadding: { type: 'DesignValue', valuesByBreakpoint: { desktop: '3px', mobile: '4px' } }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* **Example Output**
|
|
35
|
+
* ```
|
|
36
|
+
* variableValuesByBreakpoints = {
|
|
37
|
+
* desktop: {
|
|
38
|
+
* cfMargin: '1px',
|
|
39
|
+
* cfPadding: '3px'
|
|
40
|
+
* },
|
|
41
|
+
* tablet: {
|
|
42
|
+
* cfMargin: '2px'
|
|
43
|
+
* },
|
|
44
|
+
* mobile: {
|
|
45
|
+
* cfPadding: '4px'
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* **Note**
|
|
51
|
+
* - The property cfBackgroundImageUrl is the only content property that gets mapped to CSS as well.
|
|
52
|
+
* It will be solely stored on the default breakpoint.
|
|
53
|
+
* - For ComponentValues, it will either take the override from the pattern instance or fallback to
|
|
54
|
+
* the defaultValue defined in variableDefinitions.
|
|
55
|
+
*/
|
|
21
56
|
declare const indexByBreakpoint: ({ variables, breakpointIds, getBoundEntityById, unboundValues, dataSource, componentVariablesOverwrites, componentSettings, }: {
|
|
22
57
|
variables: Record<string, ComponentPropertyValue>;
|
|
23
58
|
breakpointIds: string[];
|
|
@@ -26,26 +61,25 @@ declare const indexByBreakpoint: ({ variables, breakpointIds, getBoundEntityById
|
|
|
26
61
|
dataSource?: ExperienceDataSource;
|
|
27
62
|
componentVariablesOverwrites?: Record<string, ComponentPropertyValue>;
|
|
28
63
|
componentSettings?: ExperienceComponentSettings;
|
|
29
|
-
}) => Record<string, Record<string,
|
|
64
|
+
}) => Record<string, Record<string, string | number | boolean | Record<any, any>>>;
|
|
30
65
|
/**
|
|
31
66
|
* Flattens the object from
|
|
32
|
-
* {
|
|
33
|
-
* color: {
|
|
34
|
-
* [key]: [value]
|
|
35
|
-
* }
|
|
36
|
-
* }
|
|
37
|
-
*
|
|
67
|
+
* `{ color: { [key]: [value] } }`
|
|
38
68
|
* to
|
|
39
|
-
*
|
|
40
|
-
* {
|
|
41
|
-
* 'color.key': [value]
|
|
42
|
-
* }
|
|
69
|
+
* `{ 'color.key': [value] }`
|
|
43
70
|
*/
|
|
44
71
|
declare const flattenDesignTokenRegistry: (designTokenRegistry: DesignTokensDefinition) => FlattenedDesignTokens;
|
|
45
|
-
|
|
46
|
-
declare const toMediaQuery: (breakpointPayload: {
|
|
72
|
+
type MediaQueryData = {
|
|
47
73
|
condition: string;
|
|
48
74
|
cssByClassName: Record<string, string>;
|
|
49
|
-
}
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Create a single CSS string containing all class definitions for a given media query.
|
|
78
|
+
*
|
|
79
|
+
* @param condition e.g. "*", "<520px", ">520px"
|
|
80
|
+
* @param cssByClassName map of class names to CSS strings containing all rules for each class
|
|
81
|
+
* @returns joined string of all CSS class definitions wrapped into media queries
|
|
82
|
+
*/
|
|
83
|
+
declare const toMediaQuery: ({ condition, cssByClassName }: MediaQueryData) => string;
|
|
50
84
|
|
|
51
|
-
export { detachExperienceStyles, flattenDesignTokenRegistry, indexByBreakpoint, isCfStyleAttribute, maybePopulateDesignTokenValue, resolveBackgroundImageBinding,
|
|
85
|
+
export { detachExperienceStyles, flattenDesignTokenRegistry, indexByBreakpoint, isCfStyleAttribute, maybePopulateDesignTokenValue, resolveBackgroundImageBinding, toMediaQuery };
|
|
@@ -1,12 +1,55 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
1
2
|
import { CSSProperties, StyleProps, ExperienceTreeNode } from '../../types.js';
|
|
2
|
-
import { PrimitiveValue } from '@contentful/experiences-validators';
|
|
3
|
+
import { ComponentTreeNode, PrimitiveValue } from '@contentful/experiences-validators';
|
|
3
4
|
|
|
4
5
|
declare const toCSSAttribute: (key: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Turns a list of CSSProperties into a joined CSS string that can be
|
|
8
|
+
* used for <style> tags. Per default it creates a minimized version.
|
|
9
|
+
* For editor mode, use the `useWhitespaces` flag to create a more readable version.
|
|
10
|
+
*
|
|
11
|
+
* @param cssProperties list of CSS properties
|
|
12
|
+
* @param useWhitespaces adds whitespaces and newlines between each rule
|
|
13
|
+
* @returns a string of CSS rules
|
|
14
|
+
*/
|
|
15
|
+
declare const stringifyCssProperties: (cssProperties: CSSProperties, useWhitespaces?: boolean) => string;
|
|
5
16
|
declare const buildStyleTag: ({ styles, nodeId }: {
|
|
6
17
|
styles: CSSProperties;
|
|
7
18
|
nodeId?: string;
|
|
8
19
|
}) => string[];
|
|
9
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Takes plain design values and transforms them into CSS properties. Undefined values will
|
|
22
|
+
* be filtered out.
|
|
23
|
+
*
|
|
24
|
+
* **Example Input**
|
|
25
|
+
* ```
|
|
26
|
+
* values = {
|
|
27
|
+
* cfVisibility: 'visible',
|
|
28
|
+
* cfMargin: '10px',
|
|
29
|
+
* cfFlexReverse: true,
|
|
30
|
+
* cfImageOptions: { objectFit: 'cover' },
|
|
31
|
+
* // ...
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
* **Example Output**
|
|
35
|
+
* ```
|
|
36
|
+
* cssProperties = {
|
|
37
|
+
* margin: '10px',
|
|
38
|
+
* flexDirection: 'row-reverse',
|
|
39
|
+
* objectFit: 'cover',
|
|
40
|
+
* // ...
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const buildCfStyles: (values: Partial<StyleProps>) => CSSProperties;
|
|
45
|
+
/**
|
|
46
|
+
* **Only meant to be used in editor mode!**
|
|
47
|
+
*
|
|
48
|
+
* If the node is an empty structure component with a relative height (e.g. '100%'),
|
|
49
|
+
* it might render with a zero height. In this case, add a min height of 80px to ensure
|
|
50
|
+
* that child nodes can be added via drag & drop.
|
|
51
|
+
*/
|
|
52
|
+
declare const addMinHeightForEmptyStructures: (cssProperties: CSSProperties, node: ComponentTreeNode) => react.CSSProperties;
|
|
10
53
|
/**
|
|
11
54
|
* Container/section default behavior:
|
|
12
55
|
* Default height => height: EMPTY_CONTAINER_HEIGHT
|
|
@@ -18,4 +61,4 @@ declare const calculateNodeDefaultHeight: ({ blockId, children, value, }: {
|
|
|
18
61
|
value: PrimitiveValue;
|
|
19
62
|
}) => string | number | boolean | Record<any, any> | undefined;
|
|
20
63
|
|
|
21
|
-
export { buildCfStyles, buildStyleTag, calculateNodeDefaultHeight, toCSSAttribute };
|
|
64
|
+
export { addMinHeightForEmptyStructures, buildCfStyles, buildStyleTag, calculateNodeDefaultHeight, stringifyCssProperties, toCSSAttribute };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-core",
|
|
3
|
-
"version": "1.34.0",
|
|
3
|
+
"version": "1.34.1-dev-20250305T1630-a40e5df.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"vitest": "^2.1.1"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@contentful/experiences-validators": "1.34.0",
|
|
73
|
+
"@contentful/experiences-validators": "1.34.1-dev-20250305T1630-a40e5df.0",
|
|
74
74
|
"@contentful/rich-text-types": "^17.0.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"contentful": ">=10.6.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "8ef06ee4a61000cb308be838b7faf6a3a5287643"
|
|
80
80
|
}
|