@contentful/experiences-components-react 1.42.0-beta.0 → 1.42.0-dev-20250617T0920-3f313ab.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 +35 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/index.css +0 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import styleInject from 'style-inject';
|
|
1
2
|
import React, { forwardRef } from 'react';
|
|
2
3
|
import { documentToReactComponents } from '@contentful/rich-text-react-renderer';
|
|
3
4
|
import { BLOCKS } from '@contentful/rich-text-types';
|
|
@@ -5,6 +6,9 @@ import { z } from 'zod';
|
|
|
5
6
|
import 'lodash-es';
|
|
6
7
|
import 'md5';
|
|
7
8
|
|
|
9
|
+
var css_248z$8 = "/* Initially added with PR #253 for each component, this is now a global setting\n * It is recommended on MDN to use this as a default for layouting.\n*/\n* {\n box-sizing: border-box;\n}\n";
|
|
10
|
+
styleInject(css_248z$8);
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* These modes are ONLY intended to be internally used within the context of
|
|
10
14
|
* editing an experience inside of Contentful Studio. i.e. these modes
|
|
@@ -77,6 +81,9 @@ function combineClasses(...classes) {
|
|
|
77
81
|
.join(' ');
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
var css_248z$7 = "/* If the label is empty, still render the normal height by adding this pseudo element */\n.cf-button:empty::before {\n content: '';\n display: inline-block;\n}\n";
|
|
85
|
+
styleInject(css_248z$7);
|
|
86
|
+
|
|
80
87
|
const Button = ({ children, className, label, onClick, onNavigate, target, url, ...props }) => {
|
|
81
88
|
const classes = combineClasses('cf-button', className);
|
|
82
89
|
const handleClick = (event) => {
|
|
@@ -189,6 +196,9 @@ const ButtonComponentDefinition = {
|
|
|
189
196
|
},
|
|
190
197
|
};
|
|
191
198
|
|
|
199
|
+
var css_248z$6 = ".cf-heading {\n white-space: pre-line;\n}\n";
|
|
200
|
+
styleInject(css_248z$6);
|
|
201
|
+
|
|
192
202
|
const Heading = ({ children, className, text, type = 'h1', ...props }) => {
|
|
193
203
|
const Tag = type;
|
|
194
204
|
const classes = combineClasses('cf-heading', className);
|
|
@@ -275,6 +285,9 @@ const HeadingComponentDefinition = {
|
|
|
275
285
|
},
|
|
276
286
|
};
|
|
277
287
|
|
|
288
|
+
var css_248z$5 = ".cf-richtext {\n white-space: pre-line;\n}\n\n.cf-richtext > *:first-child {\n margin-top: 0;\n}\n\n.cf-richtext > *:last-child {\n margin-bottom: 0;\n}\n";
|
|
289
|
+
styleInject(css_248z$5);
|
|
290
|
+
|
|
278
291
|
const RichText = ({ as = 'p', className, value, ...props }) => {
|
|
279
292
|
const Tag = as;
|
|
280
293
|
return (React.createElement("div", { className: combineClasses('cf-richtext', className), ...props }, documentToReactComponents(value, {
|
|
@@ -362,6 +375,9 @@ const RichTextComponentDefinition = {
|
|
|
362
375
|
},
|
|
363
376
|
};
|
|
364
377
|
|
|
378
|
+
var css_248z$4 = ".cf-text {\n white-space: pre-line;\n}\n\n.cf-text-link .cf-text {\n margin: 0;\n}\n";
|
|
379
|
+
styleInject(css_248z$4);
|
|
380
|
+
|
|
365
381
|
const Text = ({ as = 'p', children, className, value, url, target, onNavigate, onClick, ...props }) => {
|
|
366
382
|
const Tag = as;
|
|
367
383
|
if (url) {
|
|
@@ -453,6 +469,9 @@ const TextComponentDefinition = {
|
|
|
453
469
|
},
|
|
454
470
|
};
|
|
455
471
|
|
|
472
|
+
var css_248z$3 = "@import url(https://fonts.googleapis.com/css2?family=Archivo:ital,wght@0,400;0,500;0,600;1,400;1,600&display=swap);\n\n:root {\n /* All sizing comments based of 16px base body font size */\n\n /* color */\n --cf-color-white: #fff;\n --cf-color-black: #000;\n --cf-color-gray100: #f7f9fa;\n --cf-color-gray400: #aec1cc;\n --cf-color-gray400-rgb: 174, 193, 204;\n\n /* spacing */\n --cf-spacing-0: 0rem; /* 0px */\n --cf-spacing-1: 0.125rem; /* 2px */\n --cf-spacing-2: 0.25rem; /* 4px */\n --cf-spacing-3: 0.375rem; /* 6px */\n --cf-spacing-4: 0.5rem; /* 8px */\n --cf-spacing-5: 0.625rem; /* 10px */\n --cf-spacing-6: 0.75rem; /* 12px */\n --cf-spacing-7: 0.875rem; /* 14px */\n --cf-spacing-8: 1rem; /* 16px */\n --cf-spacing-9: 1.25rem; /* 20px */\n --cf-spacing-10: 1.5rem; /* 24px */\n --cf-spacing-11: 1.75rem; /* 28px */\n --cf-spacing-12: 2rem; /* 32px */\n --cf-spacing-13: 2.25rem; /* 36px */\n\n /* font-size */\n --cf-text-xs: 0.75rem; /* 12px */\n --cf-text-sm: 0.875rem; /* 14px */\n --cf-text-base: 1rem; /* 16px */\n --cf-text-lg: 1.125rem; /* 18px */\n --cf-text-xl: 1.25rem; /* 20px */\n --cf-text-2xl: 1.5rem; /* 24px */\n --cf-text-3xl: 2rem; /* 32px */\n --cf-text-4xl: 2.75rem; /* 44px */\n\n /* font-weight */\n --cf-font-light: 300;\n --cf-font-normal: 400;\n --cf-font-medium: 500;\n --cf-font-semibold: 600;\n --cf-font-bold: 700;\n --cf-font-extra-bold: 800;\n --cf-font-black: 900;\n\n /* border-radius */\n --cf-border-radius-none: 0px; /* none */\n --cf-border-radius-sm: 0.125rem; /* 2px */\n --cf-border-radius: 0.25rem; /* 4px */\n --cf-border-radius-md: 0.375rem; /* 6px */\n --cf-border-radius-lg: 0.5rem; /* 8px */\n --cf-border-radius-xl: 0.75rem; /* 12px */\n --cf-border-radius-2xl: 1rem; /* 16px */\n --cf-border-radius-3xl: 1.5rem; /* 24px */\n --cf-border-radius-full: 9999px; /* full */\n\n /* font-family */\n --cf-font-family-sans: Archivo, Helvetica, Arial, sans-serif;\n --cf-font-family-serif: Georgia, Cambria, Times New Roman, Times, serif;\n\n /* max widths */\n --cf-max-width-full: 100%;\n\n /* component specific colors */\n --cf-button-bg: var(--cf-color-black);\n --cf-button-color: var(--cf-color-white);\n --cf-text-color: var(--cf-color-black);\n}\n\ndiv.cf-placeholder-wrapper {\n /* Required for the absolute positioned icon to render in the center */\n position: relative;\n}\n\nimg.cf-placeholder-image {\n background-color: var(--cf-color-gray100);\n outline-offset: -2px;\n outline: 2px solid rgba(var(--cf-color-gray400-rgb), 0.5);\n width: 100%;\n height: 100%;\n}\n\nsvg.cf-placeholder-icon {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n height: var(--cf-text-3xl);\n width: var(--cf-text-3xl);\n max-height: 100%;\n max-width: 100%;\n}\n\nsvg.cf-placeholder-icon path {\n fill: var(--cf-color-gray400);\n}\n";
|
|
473
|
+
styleInject(css_248z$3);
|
|
474
|
+
|
|
456
475
|
const Image = ({ className = '', src, cfImageAsset, ...props }) => {
|
|
457
476
|
if (!cfImageAsset && !src) {
|
|
458
477
|
return (React.createElement("div", { className: combineClasses('cf-placeholder-wrapper', className) },
|
|
@@ -1274,11 +1293,11 @@ const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
|
1274
1293
|
]);
|
|
1275
1294
|
// TODO: finalize schema structure before release
|
|
1276
1295
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
1277
|
-
const
|
|
1296
|
+
const PatternPropertySchema = z.object({
|
|
1278
1297
|
type: z.literal('BoundValue'),
|
|
1279
1298
|
path: z.string(),
|
|
1280
1299
|
});
|
|
1281
|
-
const
|
|
1300
|
+
const PatternPropertiesSchema = z.record(propertyKeySchema, PatternPropertySchema);
|
|
1282
1301
|
const BreakpointSchema = z
|
|
1283
1302
|
.object({
|
|
1284
1303
|
id: propertyKeySchema,
|
|
@@ -1295,7 +1314,7 @@ const BaseComponentTreeNodeSchema = z.object({
|
|
|
1295
1314
|
displayName: z.string().optional(),
|
|
1296
1315
|
slotId: z.string().optional(),
|
|
1297
1316
|
variables: z.record(propertyKeySchema, ComponentPropertyValueSchema),
|
|
1298
|
-
|
|
1317
|
+
patternProperties: PatternPropertiesSchema.optional(),
|
|
1299
1318
|
});
|
|
1300
1319
|
const ComponentVariableSchema = z.object({
|
|
1301
1320
|
displayName: z.string().optional(),
|
|
@@ -1364,13 +1383,13 @@ const THUMBNAIL_IDS = [
|
|
|
1364
1383
|
// TODO: finalize schema structure before release
|
|
1365
1384
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
1366
1385
|
const VariableMappingSchema = z.object({
|
|
1367
|
-
|
|
1386
|
+
patternPropertyDefinitionId: propertyKeySchema,
|
|
1368
1387
|
type: z.literal('ContentTypeMapping'),
|
|
1369
1388
|
pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
|
|
1370
1389
|
});
|
|
1371
1390
|
// TODO: finalize schema structure before release
|
|
1372
1391
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
1373
|
-
const
|
|
1392
|
+
const PatternPropertyDefinitionSchema = z.object({
|
|
1374
1393
|
defaultValue: z
|
|
1375
1394
|
.record(z.string(), z.object({
|
|
1376
1395
|
sys: z.object({
|
|
@@ -1388,7 +1407,7 @@ const ParameterDefinitionSchema = z.object({
|
|
|
1388
1407
|
}),
|
|
1389
1408
|
})),
|
|
1390
1409
|
});
|
|
1391
|
-
const
|
|
1410
|
+
const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
|
|
1392
1411
|
const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
|
|
1393
1412
|
const ComponentVariablesSchema = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
|
|
1394
1413
|
ComponentVariableSchema);
|
|
@@ -1397,7 +1416,7 @@ const ComponentSettingsSchema = z.object({
|
|
|
1397
1416
|
thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
|
|
1398
1417
|
category: z.string().max(50, 'Category must contain at most 50 characters').optional(),
|
|
1399
1418
|
variableMappings: VariableMappingsSchema.optional(),
|
|
1400
|
-
|
|
1419
|
+
patternPropertyDefinitions: PatternPropertyDefinitionsSchema.optional(),
|
|
1401
1420
|
});
|
|
1402
1421
|
z.object({
|
|
1403
1422
|
componentTree: localeWrapper(ComponentTreeSchema),
|
|
@@ -1608,6 +1627,9 @@ var VisualEditorMode;
|
|
|
1608
1627
|
VisualEditorMode["InjectScript"] = "injectScript";
|
|
1609
1628
|
})(VisualEditorMode || (VisualEditorMode = {}));
|
|
1610
1629
|
|
|
1630
|
+
var css_248z$2 = ".contentful-container {\n position: relative;\n display: flex;\n pointer-events: all;\n}\n\n.contentful-container::-webkit-scrollbar {\n display: none; /* Safari and Chrome */\n}\n\n.cf-single-column-wrapper {\n position: relative;\n}\n\n.cf-container-wrapper {\n position: relative;\n width: 100%;\n}\n\n.contentful-container:after {\n content: '';\n display: block;\n position: absolute;\n pointer-events: none;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n overflow-x: clip;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 12px;\n color: var(--exp-builder-gray400);\n z-index: 1;\n}\n\n.contentful-section-label:after {\n content: 'Section';\n}\n\n.contentful-container-label:after {\n content: 'Container';\n}\n\n/* used by ContentfulSectionAsHyperlink.tsx */\n\n.contentful-container-link,\n.contentful-container-link:active,\n.contentful-container-link:visited,\n.contentful-container-link:hover,\n.contentful-container-link:read-write,\n.contentful-container-link:focus-visible {\n color: inherit;\n text-decoration: unset;\n outline: unset;\n}\n";
|
|
1631
|
+
styleInject(css_248z$2);
|
|
1632
|
+
|
|
1611
1633
|
const Flex = forwardRef(({ id, children, onMouseEnter, onMouseUp, onMouseLeave, onMouseDown, onClick, flex, flexBasis, flexShrink, flexDirection, gap, justifyContent, justifyItems, justifySelf, alignItems, alignSelf, alignContent, order, flexWrap, flexGrow, className, cssStyles, ...props }, ref) => {
|
|
1612
1634
|
return (React.createElement("div", { id: id, ref: ref, style: {
|
|
1613
1635
|
display: 'flex',
|
|
@@ -1701,6 +1723,9 @@ const sectionDefinition = {
|
|
|
1701
1723
|
},
|
|
1702
1724
|
};
|
|
1703
1725
|
|
|
1726
|
+
var css_248z$1 = ".cf-divider {\n display: contents;\n position: relative;\n width: 100%;\n height: 100%;\n}\n\n.cf-divider hr {\n border: none;\n}\n\n/* For the editor mode add this 10px tolerance to make it easier picking up the divider component.\n * Using the DND zone as precondition makes sure that we don't render this pseudo element in delivery. */\n\n[data-ctfl-zone-id='root'] .cf-divider::before {\n content: \"\";\n position: absolute;\n top: -5px;\n left: -5px;\n bottom: -5px;\n right: -5px;\n pointer-events: all;\n}\n";
|
|
1727
|
+
styleInject(css_248z$1);
|
|
1728
|
+
|
|
1704
1729
|
const ContentfulDivider = ({ className = '',
|
|
1705
1730
|
// We have to exclude this explicitly from rendering as withComponentWrapper is not used
|
|
1706
1731
|
dragProps: _, ...props }) => {
|
|
@@ -1719,6 +1744,9 @@ const dividerDefinition = {
|
|
|
1719
1744
|
},
|
|
1720
1745
|
};
|
|
1721
1746
|
|
|
1747
|
+
var css_248z = ".cf-columns {\n display: flex;\n gap: 24px;\n grid-template-columns: repeat(12, 1fr);\n flex-direction: column;\n min-height: 0; /* NEW */\n min-width: 0; /* NEW; needed for Firefox */\n}\n\n@media (min-width: 768px) {\n .cf-columns {\n display: grid;\n }\n}\n\n.cf-single-column-wrapper {\n position: relative;\n display: flex;\n}\n\n.cf-single-column {\n pointer-events: all;\n}\n\n.cf-single-column-wrapper:after {\n content: '';\n display: block;\n position: absolute;\n pointer-events: none;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n overflow-x: clip;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 12px;\n color: var(--exp-builder-gray400);\n z-index: 1;\n}\n\n.cf-single-column-label:after {\n content: 'Column';\n}\n";
|
|
1748
|
+
styleInject(css_248z);
|
|
1749
|
+
|
|
1722
1750
|
const ColumnWrapper = forwardRef((props, ref) => {
|
|
1723
1751
|
return (React.createElement("div", { ref: ref, ...props, style: {
|
|
1724
1752
|
...(props.style || {}),
|