@nascentdigital/funnel-ui 4.6.7 → 5.0.1
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/client/fields/EmbeddedVideo/EmbeddedVideo.d.ts +2 -2
- package/dist/client/fields/EmbeddedVideo/EmbeddedVideo.js +3 -3
- package/dist/client/fields/EmbeddedVideo/vimeo/VimeoVideo.d.ts +3 -3
- package/dist/client/fields/EmbeddedVideo/vimeo/VimeoVideo.js +4 -3
- package/dist/client/fields/EmbeddedVideo/youtube/YoutubeVideo.d.ts +3 -3
- package/dist/client/fields/EmbeddedVideo/youtube/YoutubeVideo.js +4 -3
- package/dist/client/fields/LazyVideo.d.ts +5 -1
- package/dist/client/fields/LazyVideo.js +6 -4
- package/dist/client/hooks/useTouch.js +1 -0
- package/dist/client/interaction/paginator/Paginator.js +0 -1
- package/dist/server/blocks/Block.d.ts +82 -14
- package/dist/server/blocks/Block.js +780 -60
- package/dist/server/blocks/MediaLayout.d.ts +23 -4
- package/dist/server/blocks/MediaLayout.js +2 -12
- package/dist/server/blocks/RelatedPages.js +4 -4
- package/dist/server/fields/Media.d.ts +50 -22
- package/dist/server/fields/Media.js +73 -46
- package/dist/server/fields/Visual.d.ts +6 -2
- package/dist/server/fields/Visual.js +9 -5
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/layouts/accordion/Accordion.d.ts +21 -0
- package/dist/server/layouts/accordion/Accordion.js +66 -0
- package/dist/server/layouts/accordion/AccordionContainer.d.ts +5 -0
- package/dist/server/layouts/accordion/AccordionContainer.js +18 -0
- package/dist/server/layouts/accordion/AccordionContext.d.ts +7 -0
- package/dist/server/layouts/accordion/AccordionContext.js +7 -0
- package/dist/server/layouts/accordion/AccordionExpander.d.ts +9 -0
- package/dist/server/layouts/accordion/AccordionExpander.js +72 -0
- package/dist/server/layouts/accordion/AccordionItem.d.ts +8 -0
- package/dist/server/layouts/accordion/AccordionItem.js +22 -0
- package/dist/server/layouts/accordion/AccordionLayout.d.ts +7 -0
- package/dist/server/layouts/accordion/AccordionLayout.js +26 -0
- package/dist/server/layouts/accordion/AccordionOptions.d.ts +3 -0
- package/dist/server/layouts/accordion/AccordionOptions.js +2 -0
- package/dist/server/layouts/accordion/index.d.ts +3 -0
- package/dist/server/layouts/accordion/index.js +19 -0
- package/dist/server/layouts/accordion/useAccordion.d.ts +1 -0
- package/dist/server/layouts/accordion/useAccordion.js +34 -0
- package/dist/server/layouts/index.d.ts +2 -1
- package/dist/server/layouts/index.js +2 -1
- package/dist/server/panels/BlockPanel.d.ts +14 -80
- package/dist/server/panels/BlockPanel.js +46 -707
- package/dist/server/panels/ListPanel.js +6 -3
- package/dist/server/panels/MessagePanel.js +33 -33
- package/dist/server/panels/VisualPanel.d.ts +58 -10
- package/dist/server/panels/VisualPanel.js +155 -79
- package/dist/server/schema/ListPanelLayout.d.ts +1 -0
- package/dist/server/schema/ListPanelLayout.js +1 -0
- package/dist/styles/blocks/Block-layout.css +81 -80
- package/dist/styles/blocks/Editorial.css +2 -2
- package/dist/styles/blocks/Form.css +2 -2
- package/dist/styles/blocks/MediaLayout.css +1 -1
- package/dist/styles/components/container.css +3 -24
- package/dist/styles/layouts/Accordion.css +29 -0
- package/dist/styles/layouts/_index.css +2 -1
- package/dist/styles/panels/VisualPanel.css +2 -1
- package/package.json +2 -2
|
@@ -6,62 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.BlockPanel = void 0;
|
|
7
7
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
8
8
|
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
-
const schema_1 = require("../schema");
|
|
10
|
-
const ListPanel_1 = require("./ListPanel");
|
|
11
|
-
const MessagePanel_1 = require("./MessagePanel");
|
|
12
|
-
const VisualPanel_1 = require("./VisualPanel");
|
|
13
9
|
// extensions
|
|
14
10
|
var BlockPanel;
|
|
15
11
|
(function (BlockPanel) {
|
|
16
|
-
function getClassNames({ panel, alignX = panel.alignX, alignY = panel.alignY, size = panel.size, fullbleed, mobileOrder = panel.mobileOrder }) {
|
|
17
|
-
return (0, classnames_1.default)('nd-BlockPanel',
|
|
18
|
-
// alignment
|
|
19
|
-
{
|
|
20
|
-
'nd-BlockPanel-x-start': alignX === 'start',
|
|
21
|
-
'nd-BlockPanel-x-center': alignX === 'center',
|
|
22
|
-
'nd-BlockPanel-x-end': alignX === 'end',
|
|
23
|
-
'nd-BlockPanel-y-start': alignY === 'start',
|
|
24
|
-
'nd-BlockPanel-y-center': alignY === 'center',
|
|
25
|
-
'nd-BlockPanel-y-end': alignY === 'end',
|
|
26
|
-
},
|
|
27
|
-
// size
|
|
28
|
-
{
|
|
29
|
-
'nd-BlockPanel-xs': size === 'xs',
|
|
30
|
-
'nd-BlockPanel-sm': size === 'sm',
|
|
31
|
-
'nd-BlockPanel-md': size === 'md',
|
|
32
|
-
'nd-BlockPanel-lg': size === 'lg',
|
|
33
|
-
'nd-BlockPanel-full': size === 'full'
|
|
34
|
-
},
|
|
35
|
-
// fullbleed
|
|
36
|
-
fullbleed !== undefined
|
|
37
|
-
? { 'nd-BlockPanel-fullbleed': fullbleed }
|
|
38
|
-
: funnel_core_1.BlockLayout.ResponsiveClassNames.parse({
|
|
39
|
-
value: panel.fullBleed,
|
|
40
|
-
mobile: {
|
|
41
|
-
false: '',
|
|
42
|
-
true: 'nd-BlockPanel-fullbleed-mobile'
|
|
43
|
-
},
|
|
44
|
-
base: {
|
|
45
|
-
false: '',
|
|
46
|
-
true: 'nd-BlockPanel-fullbleed-tablet'
|
|
47
|
-
},
|
|
48
|
-
desktop: {
|
|
49
|
-
false: '',
|
|
50
|
-
true: 'nd-BlockPanel-fullbleed-desktop'
|
|
51
|
-
}
|
|
52
|
-
}),
|
|
53
|
-
// mobile order
|
|
54
|
-
{
|
|
55
|
-
'nd-BlockPanel-mobileFirst': mobileOrder === 'first',
|
|
56
|
-
'nd-BlockPanel-mobileLast': mobileOrder === 'last'
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
BlockPanel.getClassNames = getClassNames;
|
|
60
12
|
// slots
|
|
61
13
|
let Slots;
|
|
62
14
|
(function (Slots) {
|
|
63
15
|
let Items;
|
|
64
16
|
(function (Items) {
|
|
17
|
+
// values
|
|
65
18
|
Items.values = ['M', 'V', 'L'];
|
|
66
19
|
function forPanels({ message, visual, list }) {
|
|
67
20
|
return Items.values.slice()
|
|
@@ -249,668 +202,54 @@ var BlockPanel;
|
|
|
249
202
|
}
|
|
250
203
|
Slots.contentAlignmentExists = contentAlignmentExists;
|
|
251
204
|
})(Slots = BlockPanel.Slots || (BlockPanel.Slots = {}));
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
(function (GetConfigSchema) {
|
|
255
|
-
let Key;
|
|
256
|
-
(function (Key) {
|
|
257
|
-
// helper
|
|
258
|
-
function normalize(key) {
|
|
259
|
-
return typeof key === 'string'
|
|
260
|
-
? { key, name: funnel_core_1.StringUtils.capitalize(key) }
|
|
261
|
-
: key;
|
|
262
|
-
}
|
|
263
|
-
Key.normalize = normalize;
|
|
264
|
-
})(Key = GetConfigSchema.Key || (GetConfigSchema.Key = {}));
|
|
265
|
-
})(GetConfigSchema = BlockPanel.GetConfigSchema || (BlockPanel.GetConfigSchema = {}));
|
|
266
|
-
function getConfigSchema({ extend, messageKey: messageKeyRaw, visualKey: visualKeyRaw, listKey: listKeyRaw }) {
|
|
267
|
-
// throw if there are not enough panels
|
|
268
|
-
const { key: messageKey, name: messageLabel } = messageKeyRaw === undefined
|
|
269
|
-
? {}
|
|
270
|
-
: GetConfigSchema.Key.normalize(messageKeyRaw);
|
|
271
|
-
const { key: visualKey, name: visualLabel } = visualKeyRaw === undefined
|
|
272
|
-
? {}
|
|
273
|
-
: GetConfigSchema.Key.normalize(visualKeyRaw);
|
|
274
|
-
const { key: listKey, name: listLabel } = listKeyRaw === undefined
|
|
275
|
-
? {}
|
|
276
|
-
: GetConfigSchema.Key.normalize(listKeyRaw);
|
|
277
|
-
const panelCount = [messageKey, visualKey, listKey].filter(funnel_core_1.Value.isDefined).length;
|
|
278
|
-
if (panelCount === 0) {
|
|
279
|
-
throw new funnel_core_1.IllegalStateError('[BlockPanel.ts] There needs to be at least one panel');
|
|
280
|
-
}
|
|
281
|
-
// initialize config schema
|
|
282
|
-
const configSchema = Object.assign(Object.assign(Object.assign({}, schema_1.BlockConfig.Presets.ThemeOnly.schema), extend), { layout: schema_1.PanelLayout.schema.optional(), slotVariation: schema_1.SlotVariation.schema });
|
|
283
|
-
// TODO: runtime error for key not available in fields
|
|
284
|
-
// add schema for message
|
|
285
|
-
if (messageKey) {
|
|
286
|
-
const keys = MessagePanel_1.MessagePanel.Config.getKeys(messageKey);
|
|
287
|
-
configSchema[keys.textAlign] = schema_1.TextAlignment.schema
|
|
288
|
-
.rename(`${messageLabel} ${schema_1.TextAlignment.schema.name}`)
|
|
289
|
-
.optional();
|
|
290
|
-
configSchema[keys.width] =
|
|
291
|
-
schema_1.ItemSize.schema
|
|
292
|
-
.rename(`${messageLabel} ${schema_1.ItemSize.schema.name}`)
|
|
293
|
-
.optional();
|
|
294
|
-
configSchema[keys.horizontalAlign] =
|
|
295
|
-
schema_1.ItemAlignment
|
|
296
|
-
.Horizontal.schema.rename(`${messageLabel} ${schema_1.ItemAlignment.Horizontal.schema.name}`)
|
|
297
|
-
.optional();
|
|
298
|
-
configSchema[keys.verticalAlign] = schema_1.ItemAlignment.Vertical.schema.rename(`${messageLabel} ${schema_1.ItemAlignment.Vertical.schema.name}`).optional();
|
|
299
|
-
}
|
|
300
|
-
// add schema for list
|
|
301
|
-
if (listKey) {
|
|
302
|
-
const keys = ListPanel_1.ListPanel.Config.getKeys(listKey);
|
|
303
|
-
configSchema[keys.layout] = schema_1.ListPanelLayout.schema.rename(`${listLabel} ${schema_1.ListPanelLayout.schema.name}`).optional();
|
|
304
|
-
configSchema[keys.width] = schema_1.ItemSize.schema.rename(`${listLabel} ${schema_1.ItemSize.schema.name}`).optional();
|
|
305
|
-
configSchema[keys.horizontalAlign] = schema_1.ItemAlignment
|
|
306
|
-
.Horizontal.schema
|
|
307
|
-
.rename(`${listLabel} ${schema_1.ItemAlignment.Horizontal.schema.name}`)
|
|
308
|
-
.optional();
|
|
309
|
-
configSchema[keys.verticalAlign] = schema_1.ItemAlignment
|
|
310
|
-
.Horizontal.schema
|
|
311
|
-
.rename(`${listLabel} ${schema_1.ItemAlignment.Vertical.schema.name}`)
|
|
312
|
-
.optional();
|
|
313
|
-
}
|
|
314
|
-
// add schema for visual
|
|
315
|
-
if (visualKey) {
|
|
316
|
-
const keys = VisualPanel_1.VisualPanel.Config.getKeys(visualKey);
|
|
317
|
-
configSchema[keys.aspect] = schema_1.AspectRatio.schema
|
|
318
|
-
.rename(`${visualLabel} ${schema_1.AspectRatio.schema.name}`)
|
|
319
|
-
.optional();
|
|
320
|
-
configSchema[keys.anchor] = schema_1.Anchor.schema
|
|
321
|
-
.rename(`${visualLabel} ${schema_1.Anchor.schema.name}`)
|
|
322
|
-
.optional();
|
|
323
|
-
configSchema[keys.width] =
|
|
324
|
-
schema_1.ItemSize.schema
|
|
325
|
-
.rename(`${visualLabel} ${schema_1.ItemSize.schema.name}`)
|
|
326
|
-
.optional();
|
|
327
|
-
configSchema[keys.horizontalAlign] =
|
|
328
|
-
schema_1.ItemAlignment
|
|
329
|
-
.Horizontal.schema.rename(`${visualLabel} ${schema_1.ItemAlignment.Horizontal.schema.name}`)
|
|
330
|
-
.optional();
|
|
331
|
-
}
|
|
332
|
-
// add content alignment/split if there are more than 2 panels
|
|
333
|
-
if (panelCount > 1) {
|
|
334
|
-
configSchema['contentAlign'] = schema_1.ItemAlignment.Vertical.schema.rename('Content Alignment').optional();
|
|
335
|
-
configSchema['contentSplit'] = schema_1.RowRatio.schema.rename('Content Split').optional();
|
|
336
|
-
}
|
|
337
|
-
// return
|
|
338
|
-
return configSchema;
|
|
205
|
+
function getWrapClassName() {
|
|
206
|
+
return (0, classnames_1.default)('nd-BlockPanel-wrap');
|
|
339
207
|
}
|
|
340
|
-
BlockPanel.
|
|
341
|
-
function
|
|
342
|
-
|
|
343
|
-
//
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
:
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
:
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
...Object.values(listKeys)
|
|
365
|
-
];
|
|
366
|
-
// current config helpers
|
|
367
|
-
const visual = visualKey
|
|
368
|
-
? fields[visualKey]
|
|
369
|
-
: undefined;
|
|
370
|
-
const panelInfo = getActivePanels({ fields: args.fields, messageFieldKeys, messageKey, visualKey, listKey });
|
|
371
|
-
const activePanels = {
|
|
372
|
-
message: panelInfo.message !== false,
|
|
373
|
-
visual: panelInfo.visual !== false,
|
|
374
|
-
list: panelInfo.list !== false,
|
|
375
|
-
};
|
|
376
|
-
// get layout schema
|
|
377
|
-
const layoutSchema = schema_1.PanelLayout.schemaForPanels(activePanels);
|
|
378
|
-
let layout = ((_b = (_a = config.layout) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'solo');
|
|
379
|
-
layout = layoutSchema.isValidOption(layout)
|
|
380
|
-
? layout
|
|
381
|
-
: layoutSchema.defaultOption;
|
|
382
|
-
const slotVariationSchema = schema_1.SlotVariation.schemaForLayout(layout);
|
|
383
|
-
let slotVariation = ((_d = (_c = config.slotVariation) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'v1');
|
|
384
|
-
slotVariation = slotVariationSchema.isValidOption(slotVariation)
|
|
385
|
-
? slotVariation
|
|
386
|
-
: slotVariationSchema.defaultOption;
|
|
387
|
-
const items = Slots.Items.compute({
|
|
388
|
-
panels: activePanels,
|
|
389
|
-
layout,
|
|
390
|
-
variation: slotVariation
|
|
208
|
+
BlockPanel.getWrapClassName = getWrapClassName;
|
|
209
|
+
function getClassNames({ panel, alignX = panel.alignX, alignY = panel.alignY, size = panel.size, mobileOrder = panel.mobileOrder }) {
|
|
210
|
+
return (0, classnames_1.default)('nd-BlockPanel',
|
|
211
|
+
// alignment
|
|
212
|
+
{
|
|
213
|
+
'nd-BlockPanel-x-start': alignX === 'start',
|
|
214
|
+
'nd-BlockPanel-x-center': alignX === 'center',
|
|
215
|
+
'nd-BlockPanel-x-end': alignX === 'end',
|
|
216
|
+
'nd-BlockPanel-y-start': alignY === 'start',
|
|
217
|
+
'nd-BlockPanel-y-center': alignY === 'center',
|
|
218
|
+
'nd-BlockPanel-y-end': alignY === 'end',
|
|
219
|
+
},
|
|
220
|
+
// size
|
|
221
|
+
{
|
|
222
|
+
'nd-BlockPanel-xs': size === 'xs',
|
|
223
|
+
'nd-BlockPanel-sm': size === 'sm',
|
|
224
|
+
'nd-BlockPanel-md': size === 'md',
|
|
225
|
+
'nd-BlockPanel-lg': size === 'lg',
|
|
226
|
+
'nd-BlockPanel-full': size === 'full'
|
|
227
|
+
},
|
|
228
|
+
// mobile order
|
|
229
|
+
{
|
|
230
|
+
'nd-BlockPanel-mobileFirst': mobileOrder === 'first',
|
|
231
|
+
'nd-BlockPanel-mobileLast': mobileOrder === 'last'
|
|
391
232
|
});
|
|
392
|
-
const flexDirections = Slots.getFlexDirections({ layout, items });
|
|
393
|
-
// extract message config
|
|
394
|
-
let messageConfig = undefined;
|
|
395
|
-
if (messageKey && activePanels.message) {
|
|
396
|
-
messageConfig = MessagePanel_1.MessagePanel.getConfig({
|
|
397
|
-
messageKey,
|
|
398
|
-
config: config,
|
|
399
|
-
fields: fields,
|
|
400
|
-
flexDirection: flexDirections.M
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
// extract visual config (if any)
|
|
404
|
-
let visualConfig = undefined;
|
|
405
|
-
if (visualKey && activePanels.visual) {
|
|
406
|
-
visualConfig = VisualPanel_1.VisualPanel.getConfig({
|
|
407
|
-
visualKey,
|
|
408
|
-
visual,
|
|
409
|
-
config: config,
|
|
410
|
-
flexDirection: flexDirections.V
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
// extract list config (if any)
|
|
414
|
-
let listConfig = undefined;
|
|
415
|
-
if (listKey && activePanels.list) {
|
|
416
|
-
listConfig = ListPanel_1.ListPanel.getConfig({
|
|
417
|
-
listKey,
|
|
418
|
-
config: config,
|
|
419
|
-
flexDirection: flexDirections.L
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
// create new schema
|
|
423
|
-
const updatedConfigSchema = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Object.entries(configSchema)
|
|
424
|
-
.reduce((configSchema, [key, fieldSchema]) => {
|
|
425
|
-
// add the config back if it's not in the panel config keys
|
|
426
|
-
if (!allKeys.includes(key)) {
|
|
427
|
-
configSchema[key] = fieldSchema;
|
|
428
|
-
}
|
|
429
|
-
// keep reducing
|
|
430
|
-
return configSchema;
|
|
431
|
-
}, {})), messageConfig === null || messageConfig === void 0 ? void 0 : messageConfig.configSchema), visualConfig === null || visualConfig === void 0 ? void 0 : visualConfig.configSchema), listConfig === null || listConfig === void 0 ? void 0 : listConfig.configSchema), { layout: layoutSchema, slotVariation: slotVariationSchema });
|
|
432
|
-
// drop content alignment if it's not applicable
|
|
433
|
-
if (!BlockPanel.Slots.contentAlignmentExists(layout)) {
|
|
434
|
-
delete updatedConfigSchema.contentAlign;
|
|
435
|
-
}
|
|
436
|
-
// drop layout/content split if not applicable
|
|
437
|
-
if (panelCount < 2) {
|
|
438
|
-
delete updatedConfigSchema.layout;
|
|
439
|
-
delete updatedConfigSchema.contentSplit;
|
|
440
|
-
}
|
|
441
|
-
// create default config
|
|
442
|
-
const defaultConfig = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, config), { theme: funnel_core_1.Schema.EnumField.Value.toData('default'), contentAlign: funnel_core_1.Schema.EnumField.Value.toData('start'), contentSplit: funnel_core_1.Schema.EnumField.Value.toData('1/1') }), messageConfig === null || messageConfig === void 0 ? void 0 : messageConfig.defaultConfig), visualConfig === null || visualConfig === void 0 ? void 0 : visualConfig.defaultConfig), listConfig === null || listConfig === void 0 ? void 0 : listConfig.defaultConfig), { layout: funnel_core_1.Schema.EnumField.Value.toData((_e = layoutSchema.defaultOption) !== null && _e !== void 0 ? _e : 'solo'), slotVariation: funnel_core_1.Schema.EnumField.Value.toData((_f = slotVariationSchema.defaultOption) !== null && _f !== void 0 ? _f : 'v1') });
|
|
443
|
-
const contentAlign = ((_h = (_g = config.contentAlign) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : 'start');
|
|
444
|
-
const contentSplit = ((_k = (_j = config.contentSplit) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : '1/1');
|
|
445
|
-
// create new config
|
|
446
|
-
const updatedConfig = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, config), messageConfig === null || messageConfig === void 0 ? void 0 : messageConfig.config), visualConfig === null || visualConfig === void 0 ? void 0 : visualConfig.config), listConfig === null || listConfig === void 0 ? void 0 : listConfig.config), { layout: funnel_core_1.Schema.EnumField.Value.toData(layout), slotVariation: funnel_core_1.Schema.EnumField.Value.toData(slotVariation), contentAlign: funnel_core_1.Schema.EnumField.Value.toData(contentAlign), contentSplit: funnel_core_1.Schema.EnumField.Value.toData(contentSplit) });
|
|
447
|
-
// return config
|
|
448
|
-
return {
|
|
449
|
-
updatedConfigSchema: updatedConfigSchema,
|
|
450
|
-
updatedConfig: updatedConfig,
|
|
451
|
-
defaultConfig: defaultConfig
|
|
452
|
-
};
|
|
453
233
|
}
|
|
454
|
-
BlockPanel.
|
|
455
|
-
function
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
? ListPanel_1.ListPanel.Config.getKeys(listKey)
|
|
472
|
-
: {};
|
|
473
|
-
// current config helpers
|
|
474
|
-
const panelInfo = getActivePanels({ fields: args.fields, messageFieldKeys, messageKey, visualKey, listKey });
|
|
475
|
-
const activePanels = {
|
|
476
|
-
message: panelInfo.message !== false,
|
|
477
|
-
visual: panelInfo.visual !== false,
|
|
478
|
-
list: panelInfo.list !== false,
|
|
479
|
-
};
|
|
480
|
-
// get layout schema
|
|
481
|
-
const layout = ((_b = (_a = config.layout) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'solo');
|
|
482
|
-
const slotVariation = ((_d = (_c = config.slotVariation) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'v1');
|
|
483
|
-
const items = Slots.Items.compute({
|
|
484
|
-
panels: activePanels,
|
|
485
|
-
layout,
|
|
486
|
-
variation: slotVariation
|
|
487
|
-
});
|
|
488
|
-
// compute content alignment/split config
|
|
489
|
-
const contentAlign = (_f = (_e = config.contentAlign) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : 'start';
|
|
490
|
-
const contentSplit = ((_h = (_g = config.contentSplit) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : '1/1');
|
|
491
|
-
// compute message config
|
|
492
|
-
const messageWidthRaw = (_j = config[messageKeys.width]) === null || _j === void 0 ? void 0 : _j.value;
|
|
493
|
-
const isMessageFullBleed = messageWidthRaw === 'fullBleed';
|
|
494
|
-
const messageWidth = isMessageFullBleed ? 'full' : (_l = (_k = config[messageKeys.width]) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 'full';
|
|
495
|
-
const messageTextAlign = (_o = (_m = config[messageKeys.textAlign]) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 'left';
|
|
496
|
-
const messageHorizontalAlign = (_q = (_p = config[messageKeys.horizontalAlign]) === null || _p === void 0 ? void 0 : _p.value) !== null && _q !== void 0 ? _q : 'start';
|
|
497
|
-
const messageVerticalAlign = (_s = (_r = config[messageKeys.verticalAlign]) === null || _r === void 0 ? void 0 : _r.value) !== null && _s !== void 0 ? _s : 'start';
|
|
498
|
-
// compute visual config
|
|
499
|
-
const visualAspect = (_u = (_t = config[visualKeys.aspect]) === null || _t === void 0 ? void 0 : _t.value) !== null && _u !== void 0 ? _u : 'auto';
|
|
500
|
-
const visualWidth = ((_w = (_v = config[visualKeys.width]) === null || _v === void 0 ? void 0 : _v.value) !== null && _w !== void 0 ? _w : 'full');
|
|
501
|
-
const visualHorizontalAlign = (_y = (_x = config[visualKeys.horizontalAlign]) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 'start';
|
|
502
|
-
const isVisualFullBleed = visualWidth === 'fullBleed';
|
|
503
|
-
// compute list config
|
|
504
|
-
const listWidthRaw = (_z = config[listKeys.width]) === null || _z === void 0 ? void 0 : _z.value;
|
|
505
|
-
const isListFullBleed = listWidthRaw === 'fullBleed';
|
|
506
|
-
const listWidth = isListFullBleed ? 'full' : (_1 = (_0 = config[listKeys.width]) === null || _0 === void 0 ? void 0 : _0.value) !== null && _1 !== void 0 ? _1 : 'full';
|
|
507
|
-
const listHorizontalAlign = (_3 = (_2 = config[listKeys.horizontalAlign]) === null || _2 === void 0 ? void 0 : _2.value) !== null && _3 !== void 0 ? _3 : 'start';
|
|
508
|
-
const listVerticalAlign = (_5 = (_4 = config[listKeys.verticalAlign]) === null || _4 === void 0 ? void 0 : _4.value) !== null && _5 !== void 0 ? _5 : 'start';
|
|
509
|
-
// create visual if we have one
|
|
510
|
-
let visualSlot = undefined;
|
|
511
|
-
if (items.includes('V') || schema_1.PanelLayout.isNested(layout)) {
|
|
512
|
-
// language=XML
|
|
513
|
-
visualSlot = (`
|
|
514
|
-
<visual
|
|
515
|
-
xmlns="nd:block"
|
|
516
|
-
aspect="${visualAspect}"
|
|
517
|
-
size="${visualWidth === 'fullBleed' ? 'full' : visualWidth}"
|
|
518
|
-
alignX="${visualHorizontalAlign}"
|
|
519
|
-
fullBleed="${isVisualFullBleed}"
|
|
520
|
-
/>
|
|
521
|
-
`);
|
|
522
|
-
}
|
|
523
|
-
// create slot items
|
|
524
|
-
const slots = items.map(item => {
|
|
525
|
-
switch (item) {
|
|
526
|
-
case 'M': {
|
|
527
|
-
// language=XML
|
|
528
|
-
return (`
|
|
529
|
-
<message
|
|
530
|
-
xmlns="nd:block"
|
|
531
|
-
textAlign="${messageTextAlign}"
|
|
532
|
-
size="${messageWidth}"
|
|
533
|
-
fullBleed="${isMessageFullBleed}"
|
|
534
|
-
alignX="${messageHorizontalAlign}"
|
|
535
|
-
alignY="${messageVerticalAlign}"
|
|
536
|
-
/>
|
|
537
|
-
`);
|
|
538
|
-
}
|
|
539
|
-
case 'V':
|
|
540
|
-
return visualSlot;
|
|
541
|
-
case 'L': {
|
|
542
|
-
// FIXME: update props from config (lists WILL REQUIRED new props)
|
|
543
|
-
// language=XML
|
|
544
|
-
return (`
|
|
545
|
-
<list
|
|
546
|
-
xmlns="nd:block"
|
|
547
|
-
layout="column"
|
|
548
|
-
itemType="message"
|
|
549
|
-
size="${listWidth}"
|
|
550
|
-
alignX="${listHorizontalAlign}"
|
|
551
|
-
alignY="${listVerticalAlign}"
|
|
552
|
-
fullBleed="${isListFullBleed}"
|
|
553
|
-
itemCount="2"
|
|
554
|
-
/>
|
|
555
|
-
`);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
// build layout
|
|
560
|
-
let blockLayout = '';
|
|
561
|
-
switch (layout) {
|
|
562
|
-
case 'solo':
|
|
563
|
-
// language=XML
|
|
564
|
-
blockLayout = `
|
|
565
|
-
<block xmlns="nd:block" name="Solo">
|
|
566
|
-
<col>
|
|
567
|
-
${slots[0]}
|
|
568
|
-
</col>
|
|
569
|
-
</block>
|
|
570
|
-
`;
|
|
571
|
-
break;
|
|
572
|
-
case 'stack.h': {
|
|
573
|
-
// compute tight
|
|
574
|
-
let tightDesktop = 'none';
|
|
575
|
-
let tightMobile = 'none';
|
|
576
|
-
if (isVisualFullBleed) {
|
|
577
|
-
tightDesktop = 'both';
|
|
578
|
-
tightMobile = items[0] === 'V' ? 'above' : 'below';
|
|
579
|
-
}
|
|
580
|
-
// language=XML
|
|
581
|
-
blockLayout = `
|
|
582
|
-
<block
|
|
583
|
-
xmlns="nd:block"
|
|
584
|
-
name="Horizontal Stack"
|
|
585
|
-
tightDesktop="${tightDesktop}"
|
|
586
|
-
tightMobile="${tightMobile}"
|
|
587
|
-
>
|
|
588
|
-
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
589
|
-
${slots[0]}
|
|
590
|
-
${slots[1]}
|
|
591
|
-
</row>
|
|
592
|
-
</block>
|
|
593
|
-
`;
|
|
594
|
-
break;
|
|
595
|
-
}
|
|
596
|
-
case 'stack.v':
|
|
597
|
-
// language=XML
|
|
598
|
-
blockLayout = `
|
|
599
|
-
<block
|
|
600
|
-
xmlns="nd:block" name="Vertical Stack"
|
|
601
|
-
tight="${!isVisualFullBleed ? 'none' : items[0] === 'V' ? 'above' : 'below'}">
|
|
602
|
-
<col>
|
|
603
|
-
${slots[0]}
|
|
604
|
-
${slots[1]}
|
|
605
|
-
</col>
|
|
606
|
-
</block>
|
|
607
|
-
`;
|
|
608
|
-
break;
|
|
609
|
-
case 'nested':
|
|
610
|
-
// language=XML
|
|
611
|
-
blockLayout = `
|
|
612
|
-
<block xmlns="nd:block" name="Nested: Simple" tight="${isVisualFullBleed ? 'both' : 'none'}">
|
|
613
|
-
<stack>
|
|
614
|
-
${visualSlot}
|
|
615
|
-
${slots[0]}
|
|
616
|
-
</stack>
|
|
617
|
-
</block>
|
|
618
|
-
`;
|
|
619
|
-
break;
|
|
620
|
-
case 'nested.h':
|
|
621
|
-
// language=XML
|
|
622
|
-
blockLayout = `
|
|
623
|
-
<block xmlns="nd:block" name="Nested: Horizontal">
|
|
624
|
-
<stack>
|
|
625
|
-
${visualSlot}
|
|
626
|
-
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
627
|
-
${slots[0]}
|
|
628
|
-
${slots[1]}
|
|
629
|
-
</row>
|
|
630
|
-
</stack>
|
|
631
|
-
</block>
|
|
632
|
-
`;
|
|
633
|
-
break;
|
|
634
|
-
case 'nested.v':
|
|
635
|
-
// language=XML
|
|
636
|
-
blockLayout = `
|
|
637
|
-
<block xmlns="nd:block" name="Nested: Vertical">
|
|
638
|
-
<stack>
|
|
639
|
-
${visualSlot}
|
|
640
|
-
<col>
|
|
641
|
-
${slots[0]}
|
|
642
|
-
${slots[1]}
|
|
643
|
-
</col>
|
|
644
|
-
</stack>
|
|
645
|
-
</block>
|
|
646
|
-
`;
|
|
647
|
-
break;
|
|
648
|
-
case 'nested.t':
|
|
649
|
-
// language=XML
|
|
650
|
-
blockLayout = `
|
|
651
|
-
<block xmlns="nd:block" name="Nested: Top">
|
|
652
|
-
<col>
|
|
653
|
-
<stack>
|
|
654
|
-
${visualSlot}
|
|
655
|
-
${slots[0]}
|
|
656
|
-
</stack>
|
|
657
|
-
${slots[1]}
|
|
658
|
-
</col>
|
|
659
|
-
</block>
|
|
660
|
-
`;
|
|
661
|
-
break;
|
|
662
|
-
case 'nested.r':
|
|
663
|
-
// language=XML
|
|
664
|
-
blockLayout = `
|
|
665
|
-
<block xmlns="nd:block" name="Nested: Right">
|
|
666
|
-
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
667
|
-
${slots[0]}
|
|
668
|
-
<stack>
|
|
669
|
-
${visualSlot}
|
|
670
|
-
${slots[1]}
|
|
671
|
-
</stack>
|
|
672
|
-
</row>
|
|
673
|
-
</block>
|
|
674
|
-
`;
|
|
675
|
-
break;
|
|
676
|
-
case 'nested.b':
|
|
677
|
-
// language=XML
|
|
678
|
-
blockLayout = `
|
|
679
|
-
<block xmlns="nd:block" name="Nested: Bottom">
|
|
680
|
-
<col>
|
|
681
|
-
${slots[0]}
|
|
682
|
-
<stack>
|
|
683
|
-
${visualSlot}
|
|
684
|
-
${slots[1]}
|
|
685
|
-
</stack>
|
|
686
|
-
</col>
|
|
687
|
-
</block>
|
|
688
|
-
`;
|
|
689
|
-
break;
|
|
690
|
-
case 'nested.l':
|
|
691
|
-
// language=XML
|
|
692
|
-
blockLayout = `
|
|
693
|
-
<block xmlns="nd:block" name="Nested: Left">
|
|
694
|
-
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
695
|
-
<stack>
|
|
696
|
-
${visualSlot}
|
|
697
|
-
${slots[0]}
|
|
698
|
-
</stack>
|
|
699
|
-
${slots[1]}
|
|
700
|
-
</row>
|
|
701
|
-
</block>
|
|
702
|
-
`;
|
|
703
|
-
break;
|
|
704
|
-
case 'brick.v': {
|
|
705
|
-
// compute tight
|
|
706
|
-
let tight = 'none';
|
|
707
|
-
if (isVisualFullBleed) {
|
|
708
|
-
if (items[0] === 'V') {
|
|
709
|
-
tight = 'above';
|
|
710
|
-
}
|
|
711
|
-
else if (items[2] === 'V') {
|
|
712
|
-
tight = 'below';
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
// language=XML
|
|
716
|
-
blockLayout = `
|
|
717
|
-
<block
|
|
718
|
-
xmlns="nd:block"
|
|
719
|
-
name="Brick: Vertical"
|
|
720
|
-
tight="${tight}"
|
|
721
|
-
>
|
|
722
|
-
<col>
|
|
723
|
-
${slots[0]}
|
|
724
|
-
${slots[1]}
|
|
725
|
-
${slots[2]}
|
|
726
|
-
</col>
|
|
727
|
-
</block>
|
|
728
|
-
`;
|
|
729
|
-
break;
|
|
730
|
-
}
|
|
731
|
-
case 'brick.t': {
|
|
732
|
-
// compute tight
|
|
733
|
-
let tightDesktop = 'none';
|
|
734
|
-
let tightMobile = 'none';
|
|
735
|
-
if (isVisualFullBleed) {
|
|
736
|
-
if (items[0] === 'V') {
|
|
737
|
-
tightDesktop = 'above';
|
|
738
|
-
tightMobile = 'above';
|
|
739
|
-
}
|
|
740
|
-
else if (items[1] === 'V') {
|
|
741
|
-
tightDesktop = 'below';
|
|
742
|
-
tightMobile = 'none';
|
|
743
|
-
}
|
|
744
|
-
else if (items[2] === 'V') {
|
|
745
|
-
tightDesktop = 'below';
|
|
746
|
-
tightMobile = 'below';
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
// language=XML
|
|
750
|
-
blockLayout = `
|
|
751
|
-
<block
|
|
752
|
-
xmlns="nd:block"
|
|
753
|
-
name="Brick: Top"
|
|
754
|
-
tightDesktop="${tightDesktop}"
|
|
755
|
-
tightMobile="${tightMobile}"
|
|
756
|
-
>
|
|
757
|
-
<col>
|
|
758
|
-
${slots[0]}
|
|
759
|
-
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
760
|
-
${slots[1]}
|
|
761
|
-
${slots[2]}
|
|
762
|
-
</row>
|
|
763
|
-
</col>
|
|
764
|
-
</block>
|
|
765
|
-
`;
|
|
766
|
-
break;
|
|
767
|
-
}
|
|
768
|
-
case 'brick.r': {
|
|
769
|
-
// compute tight
|
|
770
|
-
let tightDesktop = 'none';
|
|
771
|
-
let tightMobile = 'none';
|
|
772
|
-
if (isVisualFullBleed) {
|
|
773
|
-
if (items[0] === 'V') {
|
|
774
|
-
tightDesktop = 'above';
|
|
775
|
-
tightMobile = 'above';
|
|
776
|
-
}
|
|
777
|
-
else if (items[1] === 'V') {
|
|
778
|
-
tightDesktop = 'both';
|
|
779
|
-
tightMobile = 'below';
|
|
780
|
-
}
|
|
781
|
-
else if (items[2] === 'V') {
|
|
782
|
-
tightDesktop = 'below';
|
|
783
|
-
tightMobile = 'none';
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
// language=XML
|
|
787
|
-
blockLayout = `
|
|
788
|
-
<block
|
|
789
|
-
xmlns="nd:block"
|
|
790
|
-
name="Brick: Right"
|
|
791
|
-
tightDesktop="${tightDesktop}"
|
|
792
|
-
tightMobile="${tightMobile}"
|
|
793
|
-
>
|
|
794
|
-
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
795
|
-
<col>
|
|
796
|
-
${slots[0]}
|
|
797
|
-
${slots[2]}
|
|
798
|
-
</col>
|
|
799
|
-
${slots[1]}
|
|
800
|
-
</row>
|
|
801
|
-
</block>
|
|
802
|
-
`;
|
|
803
|
-
break;
|
|
804
|
-
}
|
|
805
|
-
case 'brick.b': {
|
|
806
|
-
// compute tight
|
|
807
|
-
let tightDesktop = 'none';
|
|
808
|
-
let tightMobile = 'none';
|
|
809
|
-
if (isVisualFullBleed) {
|
|
810
|
-
if (items[0] === 'V') {
|
|
811
|
-
tightDesktop = 'above';
|
|
812
|
-
tightMobile = 'above';
|
|
813
|
-
}
|
|
814
|
-
else if (items[1] === 'V') {
|
|
815
|
-
tightDesktop = 'above';
|
|
816
|
-
tightMobile = 'none';
|
|
817
|
-
}
|
|
818
|
-
else if (items[2] === 'V') {
|
|
819
|
-
tightDesktop = 'below';
|
|
820
|
-
tightMobile = 'below';
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
// language=XML
|
|
824
|
-
blockLayout = `
|
|
825
|
-
<block
|
|
826
|
-
xmlns="nd:block"
|
|
827
|
-
name="Brick: Bottom"
|
|
828
|
-
tightDesktop="${tightDesktop}"
|
|
829
|
-
tightMobile="${tightMobile}"
|
|
830
|
-
>
|
|
831
|
-
<col>
|
|
832
|
-
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
833
|
-
${slots[0]}
|
|
834
|
-
${slots[1]}
|
|
835
|
-
</row>
|
|
836
|
-
${slots[2]}
|
|
837
|
-
</col>
|
|
838
|
-
</block>
|
|
839
|
-
`;
|
|
840
|
-
break;
|
|
841
|
-
}
|
|
842
|
-
case 'brick.l': {
|
|
843
|
-
// compute tight
|
|
844
|
-
let tightDesktop = 'none';
|
|
845
|
-
let tightMobile = 'none';
|
|
846
|
-
if (isVisualFullBleed) {
|
|
847
|
-
if (items[0] === 'V') {
|
|
848
|
-
tightDesktop = 'both';
|
|
849
|
-
tightMobile = 'above';
|
|
850
|
-
}
|
|
851
|
-
else if (items[1] === 'V') {
|
|
852
|
-
tightDesktop = 'above';
|
|
853
|
-
tightMobile = 'none';
|
|
854
|
-
}
|
|
855
|
-
else if (items[2] === 'V') {
|
|
856
|
-
tightDesktop = 'below';
|
|
857
|
-
tightMobile = 'below';
|
|
858
|
-
}
|
|
234
|
+
BlockPanel.getClassNames = getClassNames;
|
|
235
|
+
function getFullBleedClassNames({ panel, fullbleed, }) {
|
|
236
|
+
return (0, classnames_1.default)(fullbleed !== undefined
|
|
237
|
+
? { 'nd-BlockPanel-fullbleed': fullbleed }
|
|
238
|
+
: funnel_core_1.BlockLayout.ResponsiveClassNames.parse({
|
|
239
|
+
value: panel.fullBleed,
|
|
240
|
+
mobile: {
|
|
241
|
+
false: '',
|
|
242
|
+
true: 'nd-BlockPanel-fullbleed-mobile'
|
|
243
|
+
},
|
|
244
|
+
base: {
|
|
245
|
+
false: '',
|
|
246
|
+
true: 'nd-BlockPanel-fullbleed-tablet'
|
|
247
|
+
},
|
|
248
|
+
desktop: {
|
|
249
|
+
false: '',
|
|
250
|
+
true: 'nd-BlockPanel-fullbleed-desktop'
|
|
859
251
|
}
|
|
860
|
-
|
|
861
|
-
blockLayout = `
|
|
862
|
-
<block
|
|
863
|
-
xmlns="nd:block"
|
|
864
|
-
name="Brick: Left"
|
|
865
|
-
tightDesktop="${tightDesktop}"
|
|
866
|
-
tightMobile="${tightMobile}"
|
|
867
|
-
>
|
|
868
|
-
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
869
|
-
${slots[0]}
|
|
870
|
-
<col>
|
|
871
|
-
${slots[1]}
|
|
872
|
-
${slots[2]}
|
|
873
|
-
</col>
|
|
874
|
-
</row>
|
|
875
|
-
</block>
|
|
876
|
-
`;
|
|
877
|
-
break;
|
|
878
|
-
}
|
|
879
|
-
default:
|
|
880
|
-
throw new funnel_core_1.NotImplementedError();
|
|
881
|
-
}
|
|
882
|
-
// return parsed layout
|
|
883
|
-
return funnel_core_1.BlockLayout.parse(blockLayout);
|
|
884
|
-
}
|
|
885
|
-
BlockPanel.getLayout = getLayout;
|
|
886
|
-
function getActivePanels({ fields: fieldsRaw, messageFieldKeys, messageKey, visualKey, listKey }) {
|
|
887
|
-
var _a;
|
|
888
|
-
// prepare values
|
|
889
|
-
const fields = fieldsRaw;
|
|
890
|
-
const visual = visualKey
|
|
891
|
-
? fields[visualKey]
|
|
892
|
-
: undefined;
|
|
893
|
-
const list = listKey
|
|
894
|
-
? fields[listKey]
|
|
895
|
-
: undefined;
|
|
896
|
-
// return result
|
|
897
|
-
return {
|
|
898
|
-
message: messageKey && MessagePanel_1.MessagePanel.Fields.exists(fields, messageFieldKeys)
|
|
899
|
-
? MessagePanel_1.MessagePanel.Fields.isEmpty(fields, messageFieldKeys)
|
|
900
|
-
? 'invalid'
|
|
901
|
-
: 'valid'
|
|
902
|
-
: false,
|
|
903
|
-
visual: visual
|
|
904
|
-
? visual.value
|
|
905
|
-
? 'valid'
|
|
906
|
-
: 'invalid'
|
|
907
|
-
: false,
|
|
908
|
-
list: list
|
|
909
|
-
? ((_a = list.value) !== null && _a !== void 0 ? _a : []).length === 0
|
|
910
|
-
? 'valid'
|
|
911
|
-
: 'invalid'
|
|
912
|
-
: false
|
|
913
|
-
};
|
|
252
|
+
}));
|
|
914
253
|
}
|
|
915
|
-
BlockPanel.
|
|
254
|
+
BlockPanel.getFullBleedClassNames = getFullBleedClassNames;
|
|
916
255
|
})(BlockPanel || (exports.BlockPanel = BlockPanel = {}));
|