@contentful/experiences-components-react 1.39.0-alpha-20250528T1342-e28bc3d.0 → 1.39.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
@@ -9,7 +9,6 @@ import 'md5';
9
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
10
  styleInject(css_248z$8);
11
11
 
12
- /** @deprecated will be removed when dropping backward compatibility for old DND */
13
12
  /**
14
13
  * These modes are ONLY intended to be internally used within the context of
15
14
  * editing an experience inside of Contentful Studio. i.e. these modes
@@ -1162,17 +1161,16 @@ const PrimitiveValueSchema = z.union([
1162
1161
  z.record(z.any(), z.any()),
1163
1162
  z.undefined(),
1164
1163
  ]);
1164
+ const UsedComponentsSchema = z.array(z.object({
1165
+ sys: z.object({
1166
+ type: z.literal('Link'),
1167
+ id: z.string(),
1168
+ linkType: z.literal('Entry'),
1169
+ }),
1170
+ }));
1165
1171
  const uuidKeySchema = z
1166
1172
  .string()
1167
1173
  .regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });
1168
- /**
1169
- * Property keys for imported components have a limit of 32 characters (to be implemented) while
1170
- * property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).
1171
- * Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
1172
- */
1173
- const propertyKeySchema = z
1174
- .string()
1175
- .regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
1176
1174
  const DataSourceSchema = z.record(uuidKeySchema, z.object({
1177
1175
  sys: z.object({
1178
1176
  type: z.literal('Link'),
@@ -1180,7 +1178,62 @@ const DataSourceSchema = z.record(uuidKeySchema, z.object({
1180
1178
  linkType: z.enum(['Entry', 'Asset']),
1181
1179
  }),
1182
1180
  }));
1181
+ const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
1182
+ value: PrimitiveValueSchema,
1183
+ }));
1184
+ /**
1185
+ * Property keys for imported components have a limit of 32 characters (to be implemented) while
1186
+ * property keys for patterns have a limit of 54 characters (<32-char-variable-name>_<21-char-nanoid-id>).
1187
+ * Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
1188
+ */
1189
+ const propertyKeySchema = z
1190
+ .string()
1191
+ .regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
1192
+ const ComponentTreeNodeIdSchema = z
1193
+ .string()
1194
+ .regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
1195
+ const breakpointsRefinement = (value, ctx) => {
1196
+ if (!value.length || value[0].query !== '*') {
1197
+ ctx.addIssue({
1198
+ code: z.ZodIssueCode.custom,
1199
+ message: `The first breakpoint should include the following attributes: { "query": "*" }`,
1200
+ });
1201
+ }
1202
+ const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
1203
+ // check if the current breakpoint id is found in the rest of the array
1204
+ const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
1205
+ return breakpointIndex !== currentBreakpointIndex;
1206
+ });
1207
+ if (hasDuplicateIds) {
1208
+ ctx.addIssue({
1209
+ code: z.ZodIssueCode.custom,
1210
+ message: `Breakpoint IDs must be unique`,
1211
+ });
1212
+ }
1213
+ // Extract the queries boundary by removing the special characters around it
1214
+ const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
1215
+ // sort updates queries array in place so we need to create a copy
1216
+ const originalQueries = [...queries];
1217
+ queries.sort((q1, q2) => {
1218
+ if (q1 === '*') {
1219
+ return -1;
1220
+ }
1221
+ if (q2 === '*') {
1222
+ return 1;
1223
+ }
1224
+ return q1 > q2 ? -1 : 1;
1225
+ });
1226
+ if (originalQueries.join('') !== queries.join('')) {
1227
+ ctx.addIssue({
1228
+ code: z.ZodIssueCode.custom,
1229
+ message: `Breakpoints should be ordered from largest to smallest pixel value`,
1230
+ });
1231
+ }
1232
+ };
1183
1233
  const ValuesByBreakpointSchema = z.record(z.lazy(() => PrimitiveValueSchema));
1234
+ const BindingSourceTypeEnumSchema = z
1235
+ .array(z.enum(['entry', 'asset', 'manual', 'experience']))
1236
+ .nonempty();
1184
1237
  const DesignValueSchema = z
1185
1238
  .object({
1186
1239
  type: z.literal('DesignValue'),
@@ -1213,8 +1266,6 @@ const ComponentValueSchema = z
1213
1266
  key: z.string(),
1214
1267
  })
1215
1268
  .strict();
1216
- // TODO: finalize schema structure before release
1217
- // https://contentful.atlassian.net/browse/LUMOS-523
1218
1269
  const NoValueSchema = z.object({ type: z.literal('NoValue') }).strict();
1219
1270
  const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
1220
1271
  DesignValueSchema,
@@ -1226,41 +1277,12 @@ const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
1226
1277
  ]);
1227
1278
  // TODO: finalize schema structure before release
1228
1279
  // https://contentful.atlassian.net/browse/LUMOS-523
1229
- const VariableMappingSchema = z.object({
1230
- patternPropertyDefinitionId: propertyKeySchema,
1231
- type: z.literal('ContentTypeMapping'),
1232
- pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
1233
- });
1234
- const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
1235
- // TODO: finalize schema structure before release
1236
- // https://contentful.atlassian.net/browse/LUMOS-523
1237
- const PatternPropertyDefinitionSchema = z.object({
1238
- defaultValue: z
1239
- .record(z.string(), z.object({
1240
- sys: z.object({
1241
- type: z.literal('Link'),
1242
- id: z.string(),
1243
- linkType: z.enum(['Entry']),
1244
- }),
1245
- }))
1246
- .optional(),
1247
- contentTypes: z.record(z.string(), z.object({
1248
- sys: z.object({
1249
- type: z.literal('Link'),
1250
- id: z.string(),
1251
- linkType: z.enum(['ContentType']),
1252
- }),
1253
- })),
1254
- });
1255
- const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
1256
- // TODO: finalize schema structure before release
1257
- // https://contentful.atlassian.net/browse/LUMOS-523
1258
1280
  const PatternPropertySchema = z.object({
1259
1281
  type: z.literal('BoundValue'),
1260
1282
  path: z.string(),
1261
1283
  contentType: z.string(),
1262
1284
  });
1263
- const PatternPropertysSchema = z.record(propertyKeySchema, PatternPropertySchema);
1285
+ const PatternPropertiesSchema = z.record(propertyKeySchema, PatternPropertySchema);
1264
1286
  const BreakpointSchema = z
1265
1287
  .object({
1266
1288
  id: propertyKeySchema,
@@ -1270,12 +1292,6 @@ const BreakpointSchema = z
1270
1292
  displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),
1271
1293
  })
1272
1294
  .strict();
1273
- const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
1274
- value: PrimitiveValueSchema,
1275
- }));
1276
- const ComponentTreeNodeIdSchema = z
1277
- .string()
1278
- .regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
1279
1295
  // Use helper schema to define a recursive schema with its type correctly below
1280
1296
  const BaseComponentTreeNodeSchema = z.object({
1281
1297
  id: ComponentTreeNodeIdSchema.optional(),
@@ -1283,14 +1299,8 @@ const BaseComponentTreeNodeSchema = z.object({
1283
1299
  displayName: z.string().optional(),
1284
1300
  slotId: z.string().optional(),
1285
1301
  variables: z.record(propertyKeySchema, ComponentPropertyValueSchema),
1286
- patternProperties: PatternPropertysSchema.optional(),
1287
- });
1288
- const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
1289
- children: z.lazy(() => ComponentTreeNodeSchema.array()),
1302
+ patternProperties: PatternPropertiesSchema.optional(),
1290
1303
  });
1291
- const BindingSourceTypeEnumSchema = z
1292
- .array(z.enum(['entry', 'asset', 'manual', 'experience']))
1293
- .nonempty();
1294
1304
  const ComponentVariableSchema = z.object({
1295
1305
  displayName: z.string().optional(),
1296
1306
  type: DefinitionPropertyTypeSchema,
@@ -1311,8 +1321,25 @@ const ComponentVariableSchema = z.object({
1311
1321
  })
1312
1322
  .optional(),
1313
1323
  });
1314
- 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
1315
- ComponentVariableSchema);
1324
+ const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
1325
+ children: z.lazy(() => ComponentTreeNodeSchema.array()),
1326
+ });
1327
+ const ComponentTreeSchema = z
1328
+ .object({
1329
+ breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
1330
+ children: z.array(ComponentTreeNodeSchema),
1331
+ schemaVersion: SchemaVersions,
1332
+ })
1333
+ .strict();
1334
+ const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
1335
+
1336
+ z.object({
1337
+ componentTree: localeWrapper(ComponentTreeSchema),
1338
+ dataSource: localeWrapper(DataSourceSchema),
1339
+ unboundValues: localeWrapper(UnboundValuesSchema),
1340
+ usedComponents: localeWrapper(UsedComponentsSchema).optional(),
1341
+ });
1342
+
1316
1343
  const THUMBNAIL_IDS = [
1317
1344
  'columns',
1318
1345
  'columnsPlusRight',
@@ -1338,6 +1365,37 @@ const THUMBNAIL_IDS = [
1338
1365
  'textColumns',
1339
1366
  'duplex',
1340
1367
  ];
1368
+ // TODO: finalize schema structure before release
1369
+ // https://contentful.atlassian.net/browse/LUMOS-523
1370
+ const VariableMappingSchema = z.object({
1371
+ patternPropertyDefinitionId: propertyKeySchema,
1372
+ type: z.literal('ContentTypeMapping'),
1373
+ pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
1374
+ });
1375
+ // TODO: finalize schema structure before release
1376
+ // https://contentful.atlassian.net/browse/LUMOS-523
1377
+ const PatternPropertyDefinitionSchema = z.object({
1378
+ defaultValue: z
1379
+ .record(z.string(), z.object({
1380
+ sys: z.object({
1381
+ type: z.literal('Link'),
1382
+ id: z.string(),
1383
+ linkType: z.enum(['Entry']),
1384
+ }),
1385
+ }))
1386
+ .optional(),
1387
+ contentTypes: z.record(z.string(), z.object({
1388
+ sys: z.object({
1389
+ type: z.literal('Link'),
1390
+ id: z.string(),
1391
+ linkType: z.enum(['ContentType']),
1392
+ }),
1393
+ })),
1394
+ });
1395
+ const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
1396
+ const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
1397
+ 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
1398
+ ComponentVariableSchema);
1341
1399
  const ComponentSettingsSchema = z.object({
1342
1400
  variableDefinitions: ComponentVariablesSchema,
1343
1401
  thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
@@ -1345,65 +1403,12 @@ const ComponentSettingsSchema = z.object({
1345
1403
  variableMappings: VariableMappingsSchema.optional(),
1346
1404
  patternPropertyDefinitions: PatternPropertyDefinitionsSchema.optional(),
1347
1405
  });
1348
- const UsedComponentsSchema = z.array(z.object({
1349
- sys: z.object({
1350
- type: z.literal('Link'),
1351
- id: z.string(),
1352
- linkType: z.literal('Entry'),
1353
- }),
1354
- }));
1355
- const breakpointsRefinement = (value, ctx) => {
1356
- if (!value.length || value[0].query !== '*') {
1357
- ctx.addIssue({
1358
- code: z.ZodIssueCode.custom,
1359
- message: `The first breakpoint should include the following attributes: { "query": "*" }`,
1360
- });
1361
- }
1362
- const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
1363
- // check if the current breakpoint id is found in the rest of the array
1364
- const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
1365
- return breakpointIndex !== currentBreakpointIndex;
1366
- });
1367
- if (hasDuplicateIds) {
1368
- ctx.addIssue({
1369
- code: z.ZodIssueCode.custom,
1370
- message: `Breakpoint IDs must be unique`,
1371
- });
1372
- }
1373
- // Extract the queries boundary by removing the special characters around it
1374
- const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
1375
- // sort updates queries array in place so we need to create a copy
1376
- const originalQueries = [...queries];
1377
- queries.sort((q1, q2) => {
1378
- if (q1 === '*') {
1379
- return -1;
1380
- }
1381
- if (q2 === '*') {
1382
- return 1;
1383
- }
1384
- return q1 > q2 ? -1 : 1;
1385
- });
1386
- if (originalQueries.join('') !== queries.join('')) {
1387
- ctx.addIssue({
1388
- code: z.ZodIssueCode.custom,
1389
- message: `Breakpoints should be ordered from largest to smallest pixel value`,
1390
- });
1391
- }
1392
- };
1393
- const ComponentTreeSchema = z
1394
- .object({
1395
- breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
1396
- children: z.array(ComponentTreeNodeSchema),
1397
- schemaVersion: SchemaVersions,
1398
- })
1399
- .strict();
1400
- const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
1401
1406
  z.object({
1402
1407
  componentTree: localeWrapper(ComponentTreeSchema),
1403
1408
  dataSource: localeWrapper(DataSourceSchema),
1404
1409
  unboundValues: localeWrapper(UnboundValuesSchema),
1405
1410
  usedComponents: localeWrapper(UsedComponentsSchema).optional(),
1406
- componentSettings: localeWrapper(ComponentSettingsSchema).optional(),
1411
+ componentSettings: localeWrapper(ComponentSettingsSchema),
1407
1412
  });
1408
1413
 
1409
1414
  z.object({
@@ -1527,6 +1532,32 @@ var CodeNames;
1527
1532
  })(CodeNames || (CodeNames = {}));
1528
1533
 
1529
1534
  const CF_DEBUG_KEY = 'cf_debug';
1535
+ /**
1536
+ * To ensure that the localStorage API can be used safely, we check
1537
+ * for availability (e.g. undefined in Node.js). Additionally, we
1538
+ * check if the localStorage can be used as some browsers throw a
1539
+ * SecurityError (e.g. Brave or Chromium with specific settings).
1540
+ */
1541
+ const checkLocalStorageAvailability = () => {
1542
+ if (typeof localStorage === 'undefined' || localStorage === null) {
1543
+ return false;
1544
+ }
1545
+ try {
1546
+ // Attempt to set and remove an item to check if localStorage is enabled
1547
+ const TEST_KEY = 'cf_test_local_storage';
1548
+ localStorage.setItem(TEST_KEY, 'yes');
1549
+ if (localStorage.getItem(TEST_KEY) === 'yes') {
1550
+ localStorage.removeItem(TEST_KEY);
1551
+ return true;
1552
+ }
1553
+ else {
1554
+ return false;
1555
+ }
1556
+ }
1557
+ catch (_error) {
1558
+ return false;
1559
+ }
1560
+ };
1530
1561
  class DebugLogger {
1531
1562
  constructor() {
1532
1563
  // Public methods for logging
@@ -1534,7 +1565,7 @@ class DebugLogger {
1534
1565
  this.warn = this.logger('warn');
1535
1566
  this.log = this.logger('log');
1536
1567
  this.debug = this.logger('debug');
1537
- if (typeof localStorage === 'undefined') {
1568
+ if (!checkLocalStorageAvailability()) {
1538
1569
  this.enabled = false;
1539
1570
  return;
1540
1571
  }
@@ -1580,7 +1611,7 @@ var VisualEditorMode;
1580
1611
  VisualEditorMode["InjectScript"] = "injectScript";
1581
1612
  })(VisualEditorMode || (VisualEditorMode = {}));
1582
1613
 
1583
- var css_248z$2 = ".contentful-container {\n position: relative;\n display: flex;\n box-sizing: border-box;\n pointer-events: all;\n}\n\n.contentful-container::-webkit-scrollbar {\n display: none; /* Safari and Chrome */\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";
1614
+ var css_248z$2 = ".contentful-container {\n position: relative;\n display: flex;\n box-sizing: border-box;\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";
1584
1615
  styleInject(css_248z$2);
1585
1616
 
1586
1617
  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) => {
@@ -1605,29 +1636,31 @@ const Flex = forwardRef(({ id, children, onMouseEnter, onMouseUp, onMouseLeave,
1605
1636
  });
1606
1637
  Flex.displayName = 'Flex';
1607
1638
 
1608
- function extractRenderProps(props) {
1609
- if (props.editorMode) {
1610
- const { editorMode, node, children, ...renderProps } = props;
1611
- return renderProps;
1612
- }
1613
- const { editorMode, children, ...renderProps } = props;
1614
- return renderProps;
1615
- }
1616
-
1639
+ /* eslint-disable */ /* TODO: fix eslint errors */
1617
1640
  const ContentfulContainerAsHyperlink = (props) => {
1618
- const { cfHyperlink, cfOpenInNewTab, editorMode, className, children, ...otherProps } = props;
1619
- const eventHandlingProps = editorMode === true ? { onClick: stopEventPropagation } : {};
1620
- const anchorTagProps = cfOpenInNewTab
1621
- ? {
1622
- target: '_blank',
1623
- rel: 'noopener noreferrer',
1641
+ const { cfHyperlink, cfOpenInNewTab, editorMode, className, children } = props;
1642
+ if (editorMode === false) {
1643
+ let anchorTagProps = {};
1644
+ if (cfOpenInNewTab) {
1645
+ anchorTagProps = {
1646
+ target: '_blank',
1647
+ rel: 'noopener noreferrer',
1648
+ };
1624
1649
  }
1625
- : {};
1626
- return (React.createElement("a", { className: combineClasses(className, 'contentful-container', 'contentful-container-link'), href: cfHyperlink, ...anchorTagProps, ...eventHandlingProps, ...extractRenderProps(otherProps) }, children));
1627
- };
1628
- const stopEventPropagation = (event) => {
1629
- event.stopPropagation();
1630
- event.preventDefault();
1650
+ return (React.createElement("a", { className: combineClasses(className, 'contentful-container', 'contentful-container-link'), href: cfHyperlink, ...anchorTagProps }, children));
1651
+ }
1652
+ const { renderDropzone, node } = props;
1653
+ const stopPropagationInEditorMode = (e) => {
1654
+ e.stopPropagation();
1655
+ e.preventDefault();
1656
+ };
1657
+ return renderDropzone(node, {
1658
+ ['data-test-id']: 'contentful-container',
1659
+ className: combineClasses(className, 'contentful-container', 'contentful-container-link'),
1660
+ zoneId: node.data.id,
1661
+ WrapperComponent: 'a',
1662
+ onClick: stopPropagationInEditorMode,
1663
+ });
1631
1664
  };
1632
1665
 
1633
1666
  /* eslint-disable */
@@ -1636,14 +1669,21 @@ const ContentfulContainer = (props) => {
1636
1669
  if (cfHyperlink) {
1637
1670
  return React.createElement(ContentfulContainerAsHyperlink, { ...props }, children);
1638
1671
  }
1639
- if (!editorMode) {
1672
+ if (editorMode === false) {
1640
1673
  return (React.createElement(Flex, { "data-test-id": "contentful-container", className: combineClasses(className, 'contentful-container') }, children));
1641
1674
  }
1642
1675
  // Extract properties that are only available in editor mode
1643
- const { node } = props;
1676
+ const { renderDropzone, node, dragProps = {}, ...editorModeProps } = props;
1644
1677
  const isEmpty = !node.children.length;
1645
1678
  const isSection = node.data.blockId === CONTENTFUL_COMPONENTS$1.section.id;
1646
- return (React.createElement(Flex, { "data-test-id": "contentful-container", ...extractRenderProps(props), className: combineClasses(className, 'contentful-container', isEmpty ? (isSection ? 'contentful-section-label' : 'contentful-container-label') : '') }, children));
1679
+ return renderDropzone(node, {
1680
+ ...editorModeProps,
1681
+ ['data-test-id']: 'contentful-container',
1682
+ id: 'ContentfulContainer',
1683
+ className: combineClasses('contentful-container', className, isEmpty ? (isSection ? 'contentful-section-label' : 'contentful-container-label') : ''),
1684
+ WrapperComponent: Flex,
1685
+ dragProps,
1686
+ });
1647
1687
  };
1648
1688
 
1649
1689
  const containerDefinition = {
@@ -1667,7 +1707,7 @@ const sectionDefinition = {
1667
1707
  },
1668
1708
  };
1669
1709
 
1670
- 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";
1710
+ 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";
1671
1711
  styleInject(css_248z$1);
1672
1712
 
1673
1713
  const ContentfulDivider = ({ className = '',
@@ -1688,25 +1728,48 @@ const dividerDefinition = {
1688
1728
  },
1689
1729
  };
1690
1730
 
1691
- 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}\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";
1731
+ 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";
1692
1732
  styleInject(css_248z);
1693
1733
 
1694
- const Columns = ({ className, children, ...otherProps }) => {
1695
- return (React.createElement("div", { className: combineClasses(className, 'cf-columns'), style: {
1734
+ const ColumnWrapper = forwardRef((props, ref) => {
1735
+ return (React.createElement("div", { ref: ref, ...props, style: {
1736
+ ...(props.style || {}),
1696
1737
  display: 'grid',
1697
1738
  gridTemplateColumns: 'repeat(12, [col-start] 1fr)',
1698
- }, ...extractRenderProps(otherProps) }, children));
1739
+ } }, props.children));
1740
+ });
1741
+ ColumnWrapper.displayName = 'ColumnWrapper';
1742
+ const Columns = (props) => {
1743
+ const { editorMode, className, children } = props;
1744
+ if (!editorMode) {
1745
+ return (React.createElement(ColumnWrapper, { className: combineClasses(className, 'cf-columns') }, children));
1746
+ }
1747
+ const { node, renderDropzone, dragProps = {}, ...rest } = props;
1748
+ return renderDropzone(node, {
1749
+ ...rest,
1750
+ ['data-test-id']: 'contentful-columns',
1751
+ id: 'ContentfulContainer',
1752
+ className: combineClasses('cf-columns', className),
1753
+ WrapperComponent: ColumnWrapper,
1754
+ dragProps,
1755
+ });
1699
1756
  };
1700
1757
 
1701
1758
  const SingleColumn = (props) => {
1702
- const { className, editorMode } = props;
1703
- if (!editorMode) {
1704
- return React.createElement(Flex, { className: className }, props.children);
1759
+ const { className, editorMode, children } = props;
1760
+ if (editorMode === false) {
1761
+ return React.createElement(Flex, { className: className }, children);
1705
1762
  }
1706
- const { node, children } = props;
1763
+ const { renderDropzone, node, className: _className, dragProps = {}, cfColumnSpan, editorMode: edit, ...editorProps } = props;
1707
1764
  const isEmpty = !node.children.length;
1708
- const mixedClassName = combineClasses('cf-single-column-wrapper', className, isEmpty ? 'cf-single-column-label' : '');
1709
- return (React.createElement(Flex, { ...extractRenderProps(props), className: mixedClassName }, children));
1765
+ return renderDropzone(node, {
1766
+ ['data-test-id']: 'contentful-single-column',
1767
+ id: 'ContentfulSingleColumn',
1768
+ className: combineClasses('cf-single-column-wrapper', className, isEmpty ? 'cf-single-column-label' : ''),
1769
+ WrapperComponent: Flex,
1770
+ dragProps,
1771
+ ...editorProps,
1772
+ });
1710
1773
  };
1711
1774
 
1712
1775
  const columnsDefinition = {
@@ -1728,7 +1791,18 @@ const singleColumnDefinition = {
1728
1791
  };
1729
1792
 
1730
1793
  const assemblyStyle = { display: 'contents' };
1794
+ // Feel free to do any magic as regards variable definitions for assemblies
1795
+ // Or if this isn't necessary by the time we figure that part out, we can bid this part farewell
1731
1796
  const Assembly = (props) => {
1797
+ if (props.editorMode) {
1798
+ const { node, dragProps, ...editorModeProps } = props;
1799
+ return props.renderDropzone(node, {
1800
+ ...editorModeProps,
1801
+ ['data-test-id']: 'contentful-assembly',
1802
+ className: props.className,
1803
+ dragProps,
1804
+ });
1805
+ }
1732
1806
  // Using a display contents so assembly content/children
1733
1807
  // can appear as if they are direct children of the div wrapper's parent
1734
1808
  return React.createElement("div", { "data-test-id": "assembly", ...props, style: assemblyStyle });