@contentful/experiences-components-react 1.39.0-alpha-20250528T1342-e28bc3d.0 → 1.39.0-dev-20250528T1423-593ccdb.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 +85 -30
- package/dist/index.js +194 -146
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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
|
|
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:
|
|
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
|
|
1315
|
-
|
|
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)
|
|
1411
|
+
componentSettings: localeWrapper(ComponentSettingsSchema),
|
|
1407
1412
|
});
|
|
1408
1413
|
|
|
1409
1414
|
z.object({
|
|
@@ -1580,7 +1585,7 @@ var VisualEditorMode;
|
|
|
1580
1585
|
VisualEditorMode["InjectScript"] = "injectScript";
|
|
1581
1586
|
})(VisualEditorMode || (VisualEditorMode = {}));
|
|
1582
1587
|
|
|
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";
|
|
1588
|
+
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
1589
|
styleInject(css_248z$2);
|
|
1585
1590
|
|
|
1586
1591
|
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 +1610,31 @@ const Flex = forwardRef(({ id, children, onMouseEnter, onMouseUp, onMouseLeave,
|
|
|
1605
1610
|
});
|
|
1606
1611
|
Flex.displayName = 'Flex';
|
|
1607
1612
|
|
|
1608
|
-
|
|
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
|
-
|
|
1613
|
+
/* eslint-disable */ /* TODO: fix eslint errors */
|
|
1617
1614
|
const ContentfulContainerAsHyperlink = (props) => {
|
|
1618
|
-
const { cfHyperlink, cfOpenInNewTab, editorMode, className, children
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1615
|
+
const { cfHyperlink, cfOpenInNewTab, editorMode, className, children } = props;
|
|
1616
|
+
if (editorMode === false) {
|
|
1617
|
+
let anchorTagProps = {};
|
|
1618
|
+
if (cfOpenInNewTab) {
|
|
1619
|
+
anchorTagProps = {
|
|
1620
|
+
target: '_blank',
|
|
1621
|
+
rel: 'noopener noreferrer',
|
|
1622
|
+
};
|
|
1624
1623
|
}
|
|
1625
|
-
:
|
|
1626
|
-
|
|
1627
|
-
};
|
|
1628
|
-
const
|
|
1629
|
-
|
|
1630
|
-
|
|
1624
|
+
return (React.createElement("a", { className: combineClasses(className, 'contentful-container', 'contentful-container-link'), href: cfHyperlink, ...anchorTagProps }, children));
|
|
1625
|
+
}
|
|
1626
|
+
const { renderDropzone, node } = props;
|
|
1627
|
+
const stopPropagationInEditorMode = (e) => {
|
|
1628
|
+
e.stopPropagation();
|
|
1629
|
+
e.preventDefault();
|
|
1630
|
+
};
|
|
1631
|
+
return renderDropzone(node, {
|
|
1632
|
+
['data-test-id']: 'contentful-container',
|
|
1633
|
+
className: combineClasses(className, 'contentful-container', 'contentful-container-link'),
|
|
1634
|
+
zoneId: node.data.id,
|
|
1635
|
+
WrapperComponent: 'a',
|
|
1636
|
+
onClick: stopPropagationInEditorMode,
|
|
1637
|
+
});
|
|
1631
1638
|
};
|
|
1632
1639
|
|
|
1633
1640
|
/* eslint-disable */
|
|
@@ -1636,14 +1643,21 @@ const ContentfulContainer = (props) => {
|
|
|
1636
1643
|
if (cfHyperlink) {
|
|
1637
1644
|
return React.createElement(ContentfulContainerAsHyperlink, { ...props }, children);
|
|
1638
1645
|
}
|
|
1639
|
-
if (
|
|
1646
|
+
if (editorMode === false) {
|
|
1640
1647
|
return (React.createElement(Flex, { "data-test-id": "contentful-container", className: combineClasses(className, 'contentful-container') }, children));
|
|
1641
1648
|
}
|
|
1642
1649
|
// Extract properties that are only available in editor mode
|
|
1643
|
-
const { node } = props;
|
|
1650
|
+
const { renderDropzone, node, dragProps = {}, ...editorModeProps } = props;
|
|
1644
1651
|
const isEmpty = !node.children.length;
|
|
1645
1652
|
const isSection = node.data.blockId === CONTENTFUL_COMPONENTS$1.section.id;
|
|
1646
|
-
return (
|
|
1653
|
+
return renderDropzone(node, {
|
|
1654
|
+
...editorModeProps,
|
|
1655
|
+
['data-test-id']: 'contentful-container',
|
|
1656
|
+
id: 'ContentfulContainer',
|
|
1657
|
+
className: combineClasses('contentful-container', className, isEmpty ? (isSection ? 'contentful-section-label' : 'contentful-container-label') : ''),
|
|
1658
|
+
WrapperComponent: Flex,
|
|
1659
|
+
dragProps,
|
|
1660
|
+
});
|
|
1647
1661
|
};
|
|
1648
1662
|
|
|
1649
1663
|
const containerDefinition = {
|
|
@@ -1667,7 +1681,7 @@ const sectionDefinition = {
|
|
|
1667
1681
|
},
|
|
1668
1682
|
};
|
|
1669
1683
|
|
|
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";
|
|
1684
|
+
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
1685
|
styleInject(css_248z$1);
|
|
1672
1686
|
|
|
1673
1687
|
const ContentfulDivider = ({ className = '',
|
|
@@ -1688,25 +1702,48 @@ const dividerDefinition = {
|
|
|
1688
1702
|
},
|
|
1689
1703
|
};
|
|
1690
1704
|
|
|
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";
|
|
1705
|
+
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
1706
|
styleInject(css_248z);
|
|
1693
1707
|
|
|
1694
|
-
const
|
|
1695
|
-
return (React.createElement("div", {
|
|
1708
|
+
const ColumnWrapper = forwardRef((props, ref) => {
|
|
1709
|
+
return (React.createElement("div", { ref: ref, ...props, style: {
|
|
1710
|
+
...(props.style || {}),
|
|
1696
1711
|
display: 'grid',
|
|
1697
1712
|
gridTemplateColumns: 'repeat(12, [col-start] 1fr)',
|
|
1698
|
-
}
|
|
1713
|
+
} }, props.children));
|
|
1714
|
+
});
|
|
1715
|
+
ColumnWrapper.displayName = 'ColumnWrapper';
|
|
1716
|
+
const Columns = (props) => {
|
|
1717
|
+
const { editorMode, className, children } = props;
|
|
1718
|
+
if (!editorMode) {
|
|
1719
|
+
return (React.createElement(ColumnWrapper, { className: combineClasses(className, 'cf-columns') }, children));
|
|
1720
|
+
}
|
|
1721
|
+
const { node, renderDropzone, dragProps = {}, ...rest } = props;
|
|
1722
|
+
return renderDropzone(node, {
|
|
1723
|
+
...rest,
|
|
1724
|
+
['data-test-id']: 'contentful-columns',
|
|
1725
|
+
id: 'ContentfulContainer',
|
|
1726
|
+
className: combineClasses('cf-columns', className),
|
|
1727
|
+
WrapperComponent: ColumnWrapper,
|
|
1728
|
+
dragProps,
|
|
1729
|
+
});
|
|
1699
1730
|
};
|
|
1700
1731
|
|
|
1701
1732
|
const SingleColumn = (props) => {
|
|
1702
|
-
const { className, editorMode } = props;
|
|
1703
|
-
if (
|
|
1704
|
-
return React.createElement(Flex, { className: className },
|
|
1733
|
+
const { className, editorMode, children } = props;
|
|
1734
|
+
if (editorMode === false) {
|
|
1735
|
+
return React.createElement(Flex, { className: className }, children);
|
|
1705
1736
|
}
|
|
1706
|
-
const { node,
|
|
1737
|
+
const { renderDropzone, node, className: _className, dragProps = {}, cfColumnSpan, editorMode: edit, ...editorProps } = props;
|
|
1707
1738
|
const isEmpty = !node.children.length;
|
|
1708
|
-
|
|
1709
|
-
|
|
1739
|
+
return renderDropzone(node, {
|
|
1740
|
+
['data-test-id']: 'contentful-single-column',
|
|
1741
|
+
id: 'ContentfulSingleColumn',
|
|
1742
|
+
className: combineClasses('cf-single-column-wrapper', className, isEmpty ? 'cf-single-column-label' : ''),
|
|
1743
|
+
WrapperComponent: Flex,
|
|
1744
|
+
dragProps,
|
|
1745
|
+
...editorProps,
|
|
1746
|
+
});
|
|
1710
1747
|
};
|
|
1711
1748
|
|
|
1712
1749
|
const columnsDefinition = {
|
|
@@ -1728,7 +1765,18 @@ const singleColumnDefinition = {
|
|
|
1728
1765
|
};
|
|
1729
1766
|
|
|
1730
1767
|
const assemblyStyle = { display: 'contents' };
|
|
1768
|
+
// Feel free to do any magic as regards variable definitions for assemblies
|
|
1769
|
+
// Or if this isn't necessary by the time we figure that part out, we can bid this part farewell
|
|
1731
1770
|
const Assembly = (props) => {
|
|
1771
|
+
if (props.editorMode) {
|
|
1772
|
+
const { node, dragProps, ...editorModeProps } = props;
|
|
1773
|
+
return props.renderDropzone(node, {
|
|
1774
|
+
...editorModeProps,
|
|
1775
|
+
['data-test-id']: 'contentful-assembly',
|
|
1776
|
+
className: props.className,
|
|
1777
|
+
dragProps,
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1732
1780
|
// Using a display contents so assembly content/children
|
|
1733
1781
|
// can appear as if they are direct children of the div wrapper's parent
|
|
1734
1782
|
return React.createElement("div", { "data-test-id": "assembly", ...props, style: assemblyStyle });
|