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