@contentful/experiences-core 3.7.0-dev-20250918T1641-6da833a.0 → 3.7.0-dev-20250918T1653-d735f6f.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/entity/EntityStore.d.ts +1 -1
- package/dist/index.cjs +40 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -12
- package/dist/index.js.map +1 -1
- package/dist/registries/breakpointsRegistry.d.ts +36 -13
- package/package.json +3 -3
|
@@ -53,8 +53,8 @@ declare class EntityStore extends EntityStoreBase {
|
|
|
53
53
|
get breakpoints(): {
|
|
54
54
|
id: string;
|
|
55
55
|
query: "*" | `>${number}px` | `<${number}px`;
|
|
56
|
-
previewSize: string;
|
|
57
56
|
displayName: string;
|
|
57
|
+
previewSize?: string | undefined;
|
|
58
58
|
displayIcon?: "desktop" | "tablet" | "mobile" | undefined;
|
|
59
59
|
}[];
|
|
60
60
|
get dataSource(): Record<string, {
|
package/dist/index.cjs
CHANGED
|
@@ -1000,7 +1000,7 @@ const BreakpointSchema = zod.z
|
|
|
1000
1000
|
id: propertyKeySchema,
|
|
1001
1001
|
// Can be replace with z.templateLiteral when upgrading to zod v4
|
|
1002
1002
|
query: zod.z.string().refine((s) => BREAKPOINT_QUERY_REGEX.test(s)),
|
|
1003
|
-
previewSize: zod.z.string(),
|
|
1003
|
+
previewSize: zod.z.string().optional(),
|
|
1004
1004
|
displayName: zod.z.string(),
|
|
1005
1005
|
displayIcon: zod.z.enum(['desktop', 'tablet', 'mobile']).optional(),
|
|
1006
1006
|
})
|
|
@@ -1521,29 +1521,54 @@ const validateBreakpointsDefinition = (breakpoints) => {
|
|
|
1521
1521
|
return { success: true };
|
|
1522
1522
|
};
|
|
1523
1523
|
|
|
1524
|
-
|
|
1524
|
+
const breakpointsRegistry = [];
|
|
1525
1525
|
/**
|
|
1526
|
-
*
|
|
1527
|
-
*
|
|
1528
|
-
*
|
|
1526
|
+
* Define custom breakpoints that should be used for all your experiences.
|
|
1527
|
+
* A breakpoint consists of:
|
|
1528
|
+
* - id: a unique identifier for this breakpoint
|
|
1529
|
+
* - query: a media query string that defines when this breakpoint is active
|
|
1530
|
+
* - previewSize: an optional fixed preview size to be used in the Studio editor when selecting this breakpoint
|
|
1531
|
+
* - displayName: the name to be displayed in the Studio editor for this breakpoint
|
|
1532
|
+
* - displayIcon: an optional icon to be displayed in the Studio editor for this breakpoint
|
|
1533
|
+
*
|
|
1534
|
+
* The first breakpoint must use a wildcard query (`*`) to match all sizes.
|
|
1535
|
+
*
|
|
1536
|
+
* Every subsequent breakpoint inherits the designs of the previous ones by default.
|
|
1537
|
+
*
|
|
1538
|
+
* The order of breakpoints must be either:
|
|
1539
|
+
* - desktop first: from largest to smallest, using `<` operators
|
|
1540
|
+
* - mobile first: from smallest to largest, using `>` operators
|
|
1541
|
+
*
|
|
1542
|
+
* @note changing breakpoints after you have created experiences may break those experiences
|
|
1543
|
+
* @example
|
|
1544
|
+
* defineBreakpoints([{
|
|
1545
|
+
* id: 'desktop',
|
|
1546
|
+
* query: '*',
|
|
1547
|
+
* displayName: 'Desktop',
|
|
1548
|
+
* displayIcon: 'desktop',
|
|
1549
|
+
* }, {
|
|
1550
|
+
* id: 'tablet',
|
|
1551
|
+
* query: '<992px',
|
|
1552
|
+
* displayName: 'Tablet',
|
|
1553
|
+
* displayIcon: 'tablet',
|
|
1554
|
+
* }, {
|
|
1555
|
+
* id: 'mobile',
|
|
1556
|
+
* query: '<576px',
|
|
1557
|
+
* displayName: 'Mobile',
|
|
1558
|
+
* displayIcon: 'mobile',
|
|
1559
|
+
* }]);
|
|
1529
1560
|
*/
|
|
1530
1561
|
const defineBreakpoints = (breakpoints) => {
|
|
1531
|
-
Object.assign(
|
|
1562
|
+
Object.assign(breakpointsRegistry, breakpoints);
|
|
1532
1563
|
};
|
|
1533
1564
|
const runBreakpointsValidation = () => {
|
|
1534
|
-
if (!
|
|
1565
|
+
if (!breakpointsRegistry.length)
|
|
1535
1566
|
return;
|
|
1536
|
-
const validation = validateBreakpointsDefinition(
|
|
1567
|
+
const validation = validateBreakpointsDefinition(breakpointsRegistry);
|
|
1537
1568
|
if (!validation.success) {
|
|
1538
1569
|
throw new Error(`Invalid breakpoints definition. Failed with errors: \n${JSON.stringify(validation.errors, null, 2)}`);
|
|
1539
1570
|
}
|
|
1540
1571
|
};
|
|
1541
|
-
// Used in the tests to get a breakpoint registration
|
|
1542
|
-
const getBreakpointRegistration = (id) => exports.breakpointsRegistry.find((breakpoint) => breakpoint.id === id);
|
|
1543
|
-
// Used in the tests to reset the registry
|
|
1544
|
-
const resetBreakpointsRegistry = () => {
|
|
1545
|
-
exports.breakpointsRegistry = [];
|
|
1546
|
-
};
|
|
1547
1572
|
|
|
1548
1573
|
const sdkOptionsRegistry = {};
|
|
1549
1574
|
/**
|
|
@@ -5262,6 +5287,7 @@ exports.EntityStoreBase = EntityStoreBase;
|
|
|
5262
5287
|
exports.MEDIA_QUERY_REGEXP = MEDIA_QUERY_REGEXP;
|
|
5263
5288
|
exports.addLocale = addLocale;
|
|
5264
5289
|
exports.addMinHeightForEmptyStructures = addMinHeightForEmptyStructures;
|
|
5290
|
+
exports.breakpointsRegistry = breakpointsRegistry;
|
|
5265
5291
|
exports.buildCfStyles = buildCfStyles;
|
|
5266
5292
|
exports.buildStyleTag = buildStyleTag;
|
|
5267
5293
|
exports.buildTemplate = buildTemplate;
|
|
@@ -5303,7 +5329,6 @@ exports.gatherDeepReferencesFromTree = gatherDeepReferencesFromTree;
|
|
|
5303
5329
|
exports.generateDefaultDataSourceForPrebindingDefinition = generateDefaultDataSourceForPrebindingDefinition;
|
|
5304
5330
|
exports.generateRandomId = generateRandomId;
|
|
5305
5331
|
exports.getActiveBreakpointIndex = getActiveBreakpointIndex;
|
|
5306
|
-
exports.getBreakpointRegistration = getBreakpointRegistration;
|
|
5307
5332
|
exports.getDataFromTree = getDataFromTree;
|
|
5308
5333
|
exports.getDesignTokenRegistration = getDesignTokenRegistration;
|
|
5309
5334
|
exports.getElementCoordinates = getElementCoordinates;
|
|
@@ -5346,7 +5371,6 @@ exports.parseCSSValue = parseCSSValue;
|
|
|
5346
5371
|
exports.parseDataSourcePathIntoFieldset = parseDataSourcePathIntoFieldset;
|
|
5347
5372
|
exports.parseDataSourcePathWithL1DeepBindings = parseDataSourcePathWithL1DeepBindings;
|
|
5348
5373
|
exports.referencesOf = referencesOf;
|
|
5349
|
-
exports.resetBreakpointsRegistry = resetBreakpointsRegistry;
|
|
5350
5374
|
exports.resetDesignTokenRegistry = resetDesignTokenRegistry;
|
|
5351
5375
|
exports.resolveBackgroundImageBinding = resolveBackgroundImageBinding;
|
|
5352
5376
|
exports.resolveHyperlinkPattern = resolveHyperlinkPattern;
|