@nascentdigital/funnel-ui 4.4.21 → 4.5.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 (91) hide show
  1. package/dist/Tailwind.d.ts +5 -1
  2. package/dist/Tailwind.js +9 -0
  3. package/dist/server/blocks/Block.d.ts +42 -2
  4. package/dist/server/blocks/Block.js +88 -0
  5. package/dist/server/blocks/Clients.d.ts +20 -28
  6. package/dist/server/blocks/Clients.js +13 -57
  7. package/dist/server/blocks/MediaLayout.d.ts +11 -302
  8. package/dist/server/blocks/MediaLayout.js +19 -65
  9. package/dist/server/blocks/Message.d.ts +9 -67
  10. package/dist/server/blocks/Message.js +15 -292
  11. package/dist/server/blocks/Outcome.d.ts +22 -81
  12. package/dist/server/blocks/Outcome.js +20 -474
  13. package/dist/server/blocks/OutcomeDetail.d.ts +5 -2
  14. package/dist/server/blocks/Testimonial.d.ts +81 -16
  15. package/dist/server/blocks/Testimonial.js +59 -27
  16. package/dist/server/blocks/Testimonials.d.ts +41 -0
  17. package/dist/server/blocks/Testimonials.js +90 -0
  18. package/dist/server/blocks/ValueProp.d.ts +19 -37
  19. package/dist/server/blocks/ValueProp.js +14 -100
  20. package/dist/server/blocks/index.d.ts +1 -0
  21. package/dist/server/blocks/index.js +1 -0
  22. package/dist/server/blocks/summary/Statement.d.ts +304 -0
  23. package/dist/server/blocks/summary/Statement.js +52 -0
  24. package/dist/server/blocks/summary/Summary.d.ts +19 -0
  25. package/dist/server/blocks/summary/Summary.js +34 -0
  26. package/dist/server/blocks/summary/index.d.ts +1 -0
  27. package/dist/server/blocks/summary/index.js +17 -0
  28. package/dist/server/entities/Client.d.ts +1 -1
  29. package/dist/server/entities/Person.d.ts +27 -2
  30. package/dist/server/entities/Person.js +55 -5
  31. package/dist/server/entities/UniqueSellingPoint.d.ts +1 -1
  32. package/dist/server/layouts/BrickLayout.d.ts +290 -0
  33. package/dist/server/layouts/BrickLayout.js +25 -0
  34. package/dist/server/layouts/CardLayout.d.ts +291 -0
  35. package/dist/server/layouts/CardLayout.js +25 -0
  36. package/dist/server/layouts/FlexWrapLayout.d.ts +290 -0
  37. package/dist/server/layouts/FlexWrapLayout.js +41 -0
  38. package/dist/server/layouts/StackLayout.d.ts +290 -0
  39. package/dist/server/layouts/StackLayout.js +25 -0
  40. package/dist/server/layouts/grid/GridItem.d.ts +8 -0
  41. package/dist/server/layouts/grid/GridItem.js +9 -0
  42. package/dist/server/layouts/grid/GridLayout.d.ts +293 -0
  43. package/dist/server/layouts/grid/GridLayout.js +25 -0
  44. package/dist/server/layouts/grid/index.d.ts +2 -0
  45. package/dist/server/layouts/grid/index.js +18 -0
  46. package/dist/server/layouts/index.d.ts +5 -0
  47. package/dist/server/layouts/index.js +21 -0
  48. package/dist/server/panels/BlockPanel.d.ts +96 -1
  49. package/dist/server/panels/BlockPanel.js +856 -0
  50. package/dist/server/panels/ListPanel.d.ts +63 -0
  51. package/dist/server/panels/ListPanel.js +147 -0
  52. package/dist/server/panels/MessagePanel.d.ts +71 -5
  53. package/dist/server/panels/MessagePanel.js +158 -6
  54. package/dist/server/panels/TestimonialPanel.d.ts +47 -0
  55. package/dist/server/panels/TestimonialPanel.js +71 -0
  56. package/dist/server/panels/VisualPanel.d.ts +46 -13
  57. package/dist/server/panels/VisualPanel.js +85 -17
  58. package/dist/server/panels/index.d.ts +2 -0
  59. package/dist/server/panels/index.js +2 -0
  60. package/dist/server/schema/BlockConfig.d.ts +3 -1
  61. package/dist/server/schema/BlockConfig.js +2 -1
  62. package/dist/server/schema/ItemAlignment.d.ts +2 -0
  63. package/dist/server/schema/ItemPosition.d.ts +1 -0
  64. package/dist/server/schema/ItemSize.d.ts +2 -1
  65. package/dist/server/schema/ItemSize.js +2 -1
  66. package/dist/server/schema/ListPanelLayout.d.ts +34 -0
  67. package/dist/server/schema/ListPanelLayout.js +24 -0
  68. package/dist/server/schema/PanelLayout.d.ts +14 -0
  69. package/dist/server/schema/PanelLayout.js +70 -0
  70. package/dist/server/schema/SlotVariation.d.ts +9 -0
  71. package/dist/server/schema/SlotVariation.js +48 -0
  72. package/dist/server/schema/TextAlignment.d.ts +1 -0
  73. package/dist/server/schema/index.d.ts +3 -0
  74. package/dist/server/schema/index.js +3 -0
  75. package/dist/styles/blocks/Clients.css +0 -1
  76. package/dist/styles/blocks/Message.css +0 -343
  77. package/dist/styles/blocks/Outcome.css +13 -50
  78. package/dist/styles/blocks/Summary.css +15 -0
  79. package/dist/styles/blocks/Testimonial.css +1 -318
  80. package/dist/styles/blocks/ValueProp.css +0 -126
  81. package/dist/styles/blocks/_index.css +1 -0
  82. package/dist/styles/layouts/BrickLayout.css +43 -0
  83. package/dist/styles/layouts/CardLayout.css +46 -0
  84. package/dist/styles/layouts/FlexWrapLayout.css +38 -0
  85. package/dist/styles/layouts/GridLayout.css +25 -0
  86. package/dist/styles/layouts/StackLayout.css +46 -0
  87. package/dist/styles/layouts/_index.css +6 -1
  88. package/dist/styles/panels/ListPanel.css +3 -0
  89. package/dist/styles/panels/TestimonialPanel.css +64 -0
  90. package/dist/styles/panels/_index.css +2 -0
  91. package/package.json +3 -2
@@ -6,6 +6,10 @@ 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");
9
13
  // extensions
10
14
  var BlockPanel;
11
15
  (function (BlockPanel) {
@@ -53,4 +57,856 @@ var BlockPanel;
53
57
  });
54
58
  }
55
59
  BlockPanel.getClassNames = getClassNames;
60
+ // slots
61
+ let Slots;
62
+ (function (Slots) {
63
+ let Items;
64
+ (function (Items) {
65
+ Items.values = ['M', 'V', 'L'];
66
+ function forPanels({ message, visual, list }) {
67
+ return Items.values.slice()
68
+ .filter(item => (item === 'M' && message)
69
+ || (item === 'V' && visual)
70
+ || (item === 'L' && list));
71
+ }
72
+ Items.forPanels = forPanels;
73
+ function compute({ panels: { message, visual, list }, layout, variation }) {
74
+ // drop layout options if there's no visual
75
+ if (!visual) {
76
+ return message && list
77
+ // message AND list
78
+ ? variation === 'v1'
79
+ ? ['M', 'L']
80
+ : ['L', 'M']
81
+ // only message OR list
82
+ : message ? ['M'] : ['L'];
83
+ }
84
+ // or handle case where there's just a visual + message/list
85
+ else if (!message || !list) {
86
+ return message || list
87
+ // visual AND message/list
88
+ ? layout === 'nested'
89
+ // layout is nested (message/visual inside a list)
90
+ ? message ? ['M'] : ['L']
91
+ // or based on variation
92
+ : message
93
+ // for message + visual
94
+ ? variation === 'v1' ? ['M', 'V'] : ['V', 'M']
95
+ // or for visual + list
96
+ : variation === 'v1' ? ['V', 'L'] : ['L', 'V']
97
+ // only visual
98
+ : ['V'];
99
+ }
100
+ // we have everything
101
+ else {
102
+ switch (layout) {
103
+ // nested === 2 slots (nested in visual, so we ignore it)
104
+ case 'nested.h':
105
+ case 'nested.v':
106
+ case 'nested.t':
107
+ case 'nested.b':
108
+ case 'nested.l':
109
+ case 'nested.r':
110
+ return variation === 'v1' ? ['M', 'L'] : ['L', 'M'];
111
+ // otherwise === 3 slots
112
+ default:
113
+ switch (variation) {
114
+ case 'v1':
115
+ return ['M', 'V', 'L'];
116
+ case 'v2':
117
+ return ['M', 'L', 'V'];
118
+ case 'v3':
119
+ return ['V', 'M', 'L'];
120
+ case 'v4':
121
+ return ['V', 'L', 'M'];
122
+ case 'v5':
123
+ return ['L', 'M', 'V'];
124
+ case 'v6':
125
+ return ['L', 'V', 'M'];
126
+ }
127
+ }
128
+ }
129
+ }
130
+ Items.compute = compute;
131
+ })(Items = Slots.Items || (Slots.Items = {}));
132
+ // helpers
133
+ function forLayout(layout) {
134
+ switch (layout) {
135
+ case 'solo':
136
+ case 'nested':
137
+ return 1;
138
+ case 'stack.h':
139
+ case 'stack.v':
140
+ case 'nested.h':
141
+ case 'nested.v':
142
+ case 'nested.t':
143
+ case 'nested.b':
144
+ case 'nested.l':
145
+ case 'nested.r':
146
+ return 2;
147
+ case 'brick.v':
148
+ case 'brick.t':
149
+ case 'brick.b':
150
+ case 'brick.l':
151
+ case 'brick.r':
152
+ return 3;
153
+ }
154
+ }
155
+ Slots.forLayout = forLayout;
156
+ function getFlexDirections({ layout, items: [item1, item2, item3] }) {
157
+ switch (layout) {
158
+ case 'solo':
159
+ return { [item1]: 'x' };
160
+ case 'nested':
161
+ return { [item1]: 'xy' };
162
+ case 'stack.h':
163
+ return {
164
+ [item1]: 'none',
165
+ [item2]: 'none'
166
+ };
167
+ case 'stack.v':
168
+ return {
169
+ [item1]: 'x',
170
+ [item2]: 'x'
171
+ };
172
+ case 'nested.h':
173
+ return {
174
+ [item1]: 'none',
175
+ [item2]: 'none'
176
+ };
177
+ case 'nested.v':
178
+ return {
179
+ [item1]: 'x',
180
+ [item2]: 'x'
181
+ };
182
+ case 'nested.t':
183
+ return {
184
+ [item1]: 'xy',
185
+ [item2]: 'x'
186
+ };
187
+ case 'nested.b':
188
+ return {
189
+ [item1]: 'x',
190
+ [item2]: 'xy'
191
+ };
192
+ case 'nested.l':
193
+ return {
194
+ [item1]: 'xy',
195
+ [item2]: 'none'
196
+ };
197
+ case 'nested.r':
198
+ return {
199
+ [item1]: 'none',
200
+ [item2]: 'xy'
201
+ };
202
+ case 'brick.v':
203
+ return {
204
+ [item1]: 'x',
205
+ [item2]: 'x',
206
+ [item3]: 'x'
207
+ };
208
+ case 'brick.t':
209
+ return {
210
+ [item1]: 'x',
211
+ [item2]: 'none',
212
+ [item3]: 'none'
213
+ };
214
+ case 'brick.b':
215
+ return {
216
+ [item1]: 'none',
217
+ [item2]: 'none',
218
+ [item3]: 'x'
219
+ };
220
+ case 'brick.l':
221
+ return {
222
+ [item1]: 'none',
223
+ [item2]: 'none',
224
+ [item3]: 'none'
225
+ };
226
+ case 'brick.r':
227
+ return {
228
+ [item1]: 'none',
229
+ [item2]: 'none',
230
+ [item3]: 'none'
231
+ };
232
+ }
233
+ }
234
+ Slots.getFlexDirections = getFlexDirections;
235
+ function contentAlignmentExists(layout) {
236
+ switch (layout) {
237
+ case 'brick.t':
238
+ case 'brick.b':
239
+ case 'brick.r':
240
+ case 'brick.l':
241
+ case 'stack.h':
242
+ case 'nested.h':
243
+ case 'nested.r':
244
+ case 'nested.l':
245
+ return true;
246
+ default:
247
+ return false;
248
+ }
249
+ }
250
+ Slots.contentAlignmentExists = contentAlignmentExists;
251
+ })(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
+ console.debug('[BlockPanel/getConfigSchema] created schema', configSchema);
337
+ // return
338
+ return configSchema;
339
+ }
340
+ BlockPanel.getConfigSchema = getConfigSchema;
341
+ function getConfig({ args, messageFieldKeys, messageKey, visualKey, listKey }) {
342
+ var _a, _b, _c, _d;
343
+ // throw if there are not enough panels
344
+ const panelCount = [messageKey, visualKey, listKey].filter(funnel_core_1.Value.isDefined).length;
345
+ if (panelCount === 0) {
346
+ throw new funnel_core_1.IllegalStateError('[BlockPanel.ts] There needs to be at least one panel');
347
+ }
348
+ // resolve props
349
+ const configSchema = args.configSchema;
350
+ const config = args.config;
351
+ const fields = args.fields;
352
+ const messageKeys = messageKey
353
+ ? MessagePanel_1.MessagePanel.Config.getKeys(messageKey)
354
+ : {};
355
+ const visualKeys = visualKey
356
+ ? VisualPanel_1.VisualPanel.Config.getKeys(visualKey)
357
+ : {};
358
+ const listKeys = listKey
359
+ ? ListPanel_1.ListPanel.Config.getKeys(listKey)
360
+ : {};
361
+ const allKeys = [
362
+ ...Object.values(messageKeys),
363
+ ...Object.values(visualKeys),
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
391
+ });
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 (drop content alignment if it's not applicable)
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
+ if (!BlockPanel.Slots.contentAlignmentExists(layout)) {
433
+ delete updatedConfigSchema.contentAlign;
434
+ }
435
+ if (panelCount < 2) {
436
+ delete updatedConfigSchema.layout;
437
+ }
438
+ // FIXME: add missing layout config
439
+ // create default config
440
+ const defaultConfig = Object.assign(Object.assign(Object.assign({ 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);
441
+ // create new config
442
+ 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) });
443
+ // return config
444
+ return {
445
+ updatedConfigSchema: updatedConfigSchema,
446
+ updatedConfig: updatedConfig,
447
+ defaultConfig: defaultConfig
448
+ };
449
+ }
450
+ BlockPanel.getConfig = getConfig;
451
+ function getLayout({ args, messageFieldKeys, messageKey, visualKey, listKey }) {
452
+ 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;
453
+ // throw if there are not enough panels
454
+ const panelCount = [messageKey, visualKey, listKey].filter(funnel_core_1.Value.isDefined).length;
455
+ if (panelCount === 0) {
456
+ throw new funnel_core_1.IllegalStateError('[BlockPanel.ts] There needs to be at least one panel');
457
+ }
458
+ // resolve props
459
+ const config = args.config;
460
+ const fields = args.fields;
461
+ const messageKeys = messageKey
462
+ ? MessagePanel_1.MessagePanel.Config.getKeys(messageKey)
463
+ : {};
464
+ const visualKeys = visualKey
465
+ ? VisualPanel_1.VisualPanel.Config.getKeys(visualKey)
466
+ : {};
467
+ const listKeys = listKey
468
+ ? ListPanel_1.ListPanel.Config.getKeys(listKey)
469
+ : {};
470
+ // current config helpers
471
+ const panelInfo = getActivePanels({ fields: args.fields, messageFieldKeys, messageKey, visualKey, listKey });
472
+ const activePanels = {
473
+ message: panelInfo.message !== false,
474
+ visual: panelInfo.visual !== false,
475
+ list: panelInfo.list !== false,
476
+ };
477
+ // get layout schema
478
+ const layout = ((_b = (_a = config.layout) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'solo');
479
+ const slotVariation = ((_d = (_c = config.slotVariation) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'v1');
480
+ const items = Slots.Items.compute({
481
+ panels: activePanels,
482
+ layout,
483
+ variation: slotVariation
484
+ });
485
+ // compute content alignment config
486
+ const contentAlign = (_f = (_e = config.contentAlign) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : 'start';
487
+ // compute message config
488
+ const messageWidthRaw = (_g = config[messageKeys.width]) === null || _g === void 0 ? void 0 : _g.value;
489
+ const isMessageFullBleed = messageWidthRaw === 'fullBleed';
490
+ const messageWidth = isMessageFullBleed ? 'full' : (_j = (_h = config[messageKeys.width]) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : 'full';
491
+ const messageTextAlign = (_l = (_k = config[messageKeys.textAlign]) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 'left';
492
+ const messageHorizontalAlign = (_o = (_m = config[messageKeys.horizontalAlign]) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 'start';
493
+ const messageVerticalAlign = (_q = (_p = config[messageKeys.verticalAlign]) === null || _p === void 0 ? void 0 : _p.value) !== null && _q !== void 0 ? _q : 'start';
494
+ // compute visual config
495
+ const visualAspect = (_s = (_r = config[visualKeys.aspect]) === null || _r === void 0 ? void 0 : _r.value) !== null && _s !== void 0 ? _s : 'auto';
496
+ const visualWidth = ((_u = (_t = config[visualKeys.width]) === null || _t === void 0 ? void 0 : _t.value) !== null && _u !== void 0 ? _u : 'full');
497
+ const visualHorizontalAlign = (_w = (_v = config[visualKeys.horizontalAlign]) === null || _v === void 0 ? void 0 : _v.value) !== null && _w !== void 0 ? _w : 'start';
498
+ const isVisualFullBleed = visualWidth === 'fullBleed';
499
+ // compute list config
500
+ const listWidthRaw = (_x = config[listKeys.width]) === null || _x === void 0 ? void 0 : _x.value;
501
+ const isListFullBleed = listWidthRaw === 'fullBleed';
502
+ const listWidth = isListFullBleed ? 'full' : (_z = (_y = config[listKeys.width]) === null || _y === void 0 ? void 0 : _y.value) !== null && _z !== void 0 ? _z : 'full';
503
+ const listHorizontalAlign = (_1 = (_0 = config[listKeys.horizontalAlign]) === null || _0 === void 0 ? void 0 : _0.value) !== null && _1 !== void 0 ? _1 : 'start';
504
+ const listVerticalAlign = (_3 = (_2 = config[listKeys.verticalAlign]) === null || _2 === void 0 ? void 0 : _2.value) !== null && _3 !== void 0 ? _3 : 'start';
505
+ // create visual if we have one
506
+ let visualSlot = undefined;
507
+ if (items.includes('V') || schema_1.PanelLayout.isNested(layout)) {
508
+ // language=XML
509
+ visualSlot = (`
510
+ <visual
511
+ xmlns="nd:block"
512
+ aspect="${visualAspect}"
513
+ size="${visualWidth === 'fullBleed' ? 'full' : visualWidth}"
514
+ alignX="${visualHorizontalAlign}"
515
+ fullBleed="${isVisualFullBleed}"
516
+ />
517
+ `);
518
+ }
519
+ // create slot items
520
+ const slots = items.map(item => {
521
+ switch (item) {
522
+ case 'M': {
523
+ // language=XML
524
+ return (`
525
+ <message
526
+ xmlns="nd:block"
527
+ textAlign="${messageTextAlign}"
528
+ size="${messageWidth}"
529
+ fullBleed="${isMessageFullBleed}"
530
+ alignX="${messageHorizontalAlign}"
531
+ alignY="${messageVerticalAlign}"
532
+ />
533
+ `);
534
+ }
535
+ case 'V':
536
+ return visualSlot;
537
+ case 'L': {
538
+ // FIXME: update props from config (lists WILL REQUIRED new props)
539
+ // language=XML
540
+ return (`
541
+ <list
542
+ xmlns="nd:block"
543
+ layout="column"
544
+ itemType="message"
545
+ size="${listWidth}"
546
+ alignX="${listHorizontalAlign}"
547
+ alignY="${listVerticalAlign}"
548
+ fullBleed="${isListFullBleed}"
549
+ itemCount="2"
550
+ />
551
+ `);
552
+ }
553
+ }
554
+ });
555
+ // build layout
556
+ let blockLayout = '';
557
+ switch (layout) {
558
+ case 'solo':
559
+ // language=XML
560
+ blockLayout = `
561
+ <block xmlns="nd:block" name="Solo">
562
+ <col>
563
+ ${slots[0]}
564
+ </col>
565
+ </block>
566
+ `;
567
+ break;
568
+ case 'stack.h': {
569
+ // compute tight
570
+ let tightDesktop = 'none';
571
+ let tightMobile = 'none';
572
+ if (isVisualFullBleed) {
573
+ tightDesktop = 'both';
574
+ tightMobile = items[0] === 'V' ? 'above' : 'below';
575
+ }
576
+ // language=XML
577
+ blockLayout = `
578
+ <block
579
+ xmlns="nd:block"
580
+ name="Horizontal Stack"
581
+ tightDesktop="${tightDesktop}"
582
+ tightMobile="${tightMobile}"
583
+ >
584
+ <row alignY="${contentAlign}">
585
+ ${slots[0]}
586
+ ${slots[1]}
587
+ </row>
588
+ </block>
589
+ `;
590
+ break;
591
+ }
592
+ case 'stack.v':
593
+ // language=XML
594
+ blockLayout = `
595
+ <block
596
+ xmlns="nd:block" name="Vertical Stack"
597
+ tight="${!isVisualFullBleed ? 'none' : items[0] === 'V' ? 'above' : 'below'}">
598
+ <col>
599
+ ${slots[0]}
600
+ ${slots[1]}
601
+ </col>
602
+ </block>
603
+ `;
604
+ break;
605
+ case 'nested':
606
+ // language=XML
607
+ blockLayout = `
608
+ <block xmlns="nd:block" name="Nested: Simple" tight="${isVisualFullBleed ? 'both' : 'none'}">
609
+ <stack>
610
+ ${visualSlot}
611
+ ${slots[0]}
612
+ </stack>
613
+ </block>
614
+ `;
615
+ break;
616
+ case 'nested.h':
617
+ // language=XML
618
+ blockLayout = `
619
+ <block xmlns="nd:block" name="Nested: Horizontal">
620
+ <stack>
621
+ ${visualSlot}
622
+ <row alignY="${contentAlign}">
623
+ ${slots[0]}
624
+ ${slots[1]}
625
+ </row>
626
+ </stack>
627
+ </block>
628
+ `;
629
+ break;
630
+ case 'nested.v':
631
+ // language=XML
632
+ blockLayout = `
633
+ <block xmlns="nd:block" name="Nested: Vertical">
634
+ <stack>
635
+ ${visualSlot}
636
+ <col>
637
+ ${slots[0]}
638
+ ${slots[1]}
639
+ </col>
640
+ </stack>
641
+ </block>
642
+ `;
643
+ break;
644
+ case 'nested.t':
645
+ // language=XML
646
+ blockLayout = `
647
+ <block xmlns="nd:block" name="Nested: Top">
648
+ <col>
649
+ <stack>
650
+ ${visualSlot}
651
+ ${slots[0]}
652
+ </stack>
653
+ ${slots[1]}
654
+ </col>
655
+ </block>
656
+ `;
657
+ break;
658
+ case 'nested.r':
659
+ // language=XML
660
+ blockLayout = `
661
+ <block xmlns="nd:block" name="Nested: Right">
662
+ <row alignY="${contentAlign}">
663
+ ${slots[0]}
664
+ <stack>
665
+ ${visualSlot}
666
+ ${slots[1]}
667
+ </stack>
668
+ </row>
669
+ </block>
670
+ `;
671
+ break;
672
+ case 'nested.b':
673
+ // language=XML
674
+ blockLayout = `
675
+ <block xmlns="nd:block" name="Nested: Bottom">
676
+ <col>
677
+ ${slots[0]}
678
+ <stack>
679
+ ${visualSlot}
680
+ ${slots[1]}
681
+ </stack>
682
+ </col>
683
+ </block>
684
+ `;
685
+ break;
686
+ case 'nested.l':
687
+ // language=XML
688
+ blockLayout = `
689
+ <block xmlns="nd:block" name="Nested: Left">
690
+ <row alignY="${contentAlign}">
691
+ <stack>
692
+ ${visualSlot}
693
+ ${slots[0]}
694
+ </stack>
695
+ ${slots[1]}
696
+ </row>
697
+ </block>
698
+ `;
699
+ break;
700
+ case 'brick.v': {
701
+ // compute tight
702
+ let tight = 'none';
703
+ if (isVisualFullBleed) {
704
+ if (items[0] === 'V') {
705
+ tight = 'above';
706
+ }
707
+ else if (items[2] === 'V') {
708
+ tight = 'below';
709
+ }
710
+ }
711
+ // language=XML
712
+ blockLayout = `
713
+ <block
714
+ xmlns="nd:block"
715
+ name="Brick: Vertical"
716
+ tight="${tight}"
717
+ >
718
+ <col>
719
+ ${slots[0]}
720
+ ${slots[1]}
721
+ ${slots[2]}
722
+ </col>
723
+ </block>
724
+ `;
725
+ break;
726
+ }
727
+ case 'brick.t': {
728
+ // compute tight
729
+ let tightDesktop = 'none';
730
+ let tightMobile = 'none';
731
+ if (isVisualFullBleed) {
732
+ if (items[0] === 'V') {
733
+ tightDesktop = 'above';
734
+ tightMobile = 'above';
735
+ }
736
+ else if (items[1] === 'V') {
737
+ tightDesktop = 'below';
738
+ tightMobile = 'none';
739
+ }
740
+ else if (items[2] === 'V') {
741
+ tightDesktop = 'below';
742
+ tightMobile = 'below';
743
+ }
744
+ }
745
+ // language=XML
746
+ blockLayout = `
747
+ <block
748
+ xmlns="nd:block"
749
+ name="Brick: Top"
750
+ tightDesktop="${tightDesktop}"
751
+ tightMobile="${tightMobile}"
752
+ >
753
+ <col>
754
+ ${slots[0]}
755
+ <row alignY="${contentAlign}">
756
+ ${slots[1]}
757
+ ${slots[2]}
758
+ </row>
759
+ </col>
760
+ </block>
761
+ `;
762
+ break;
763
+ }
764
+ case 'brick.r': {
765
+ // compute tight
766
+ let tightDesktop = 'none';
767
+ let tightMobile = 'none';
768
+ if (isVisualFullBleed) {
769
+ if (items[0] === 'V') {
770
+ tightDesktop = 'above';
771
+ tightMobile = 'above';
772
+ }
773
+ else if (items[1] === 'V') {
774
+ tightDesktop = 'both';
775
+ tightMobile = 'below';
776
+ }
777
+ else if (items[2] === 'V') {
778
+ tightDesktop = 'below';
779
+ tightMobile = 'none';
780
+ }
781
+ }
782
+ // language=XML
783
+ blockLayout = `
784
+ <block
785
+ xmlns="nd:block"
786
+ name="Brick: Right"
787
+ tightDesktop="${tightDesktop}"
788
+ tightMobile="${tightMobile}"
789
+ >
790
+ <row alignY="${contentAlign}">
791
+ <col>
792
+ ${slots[0]}
793
+ ${slots[2]}
794
+ </col>
795
+ ${slots[1]}
796
+ </row>
797
+ </block>
798
+ `;
799
+ break;
800
+ }
801
+ case 'brick.b': {
802
+ // compute tight
803
+ let tightDesktop = 'none';
804
+ let tightMobile = 'none';
805
+ if (isVisualFullBleed) {
806
+ if (items[0] === 'V') {
807
+ tightDesktop = 'above';
808
+ tightMobile = 'above';
809
+ }
810
+ else if (items[1] === 'V') {
811
+ tightDesktop = 'above';
812
+ tightMobile = 'none';
813
+ }
814
+ else if (items[2] === 'V') {
815
+ tightDesktop = 'below';
816
+ tightMobile = 'below';
817
+ }
818
+ }
819
+ // language=XML
820
+ blockLayout = `
821
+ <block
822
+ xmlns="nd:block"
823
+ name="Brick: Bottom"
824
+ tightDesktop="${tightDesktop}"
825
+ tightMobile="${tightMobile}"
826
+ >
827
+ <col>
828
+ <row alignY="${contentAlign}">
829
+ ${slots[0]}
830
+ ${slots[1]}
831
+ </row>
832
+ ${slots[2]}
833
+ </col>
834
+ </block>
835
+ `;
836
+ break;
837
+ }
838
+ case 'brick.l': {
839
+ // compute tight
840
+ let tightDesktop = 'none';
841
+ let tightMobile = 'none';
842
+ if (isVisualFullBleed) {
843
+ if (items[0] === 'V') {
844
+ tightDesktop = 'both';
845
+ tightMobile = 'above';
846
+ }
847
+ else if (items[1] === 'V') {
848
+ tightDesktop = 'above';
849
+ tightMobile = 'none';
850
+ }
851
+ else if (items[2] === 'V') {
852
+ tightDesktop = 'below';
853
+ tightMobile = 'below';
854
+ }
855
+ }
856
+ // language=XML
857
+ blockLayout = `
858
+ <block
859
+ xmlns="nd:block"
860
+ name="Brick: Left"
861
+ tightDesktop="${tightDesktop}"
862
+ tightMobile="${tightMobile}"
863
+ >
864
+ <row alignY="${contentAlign}">
865
+ ${slots[0]}
866
+ <col>
867
+ ${slots[1]}
868
+ ${slots[2]}
869
+ </col>
870
+ </row>
871
+ </block>
872
+ `;
873
+ break;
874
+ }
875
+ default:
876
+ throw new funnel_core_1.NotImplementedError();
877
+ }
878
+ // return parsed layout
879
+ return funnel_core_1.BlockLayout.parse(blockLayout);
880
+ }
881
+ BlockPanel.getLayout = getLayout;
882
+ function getActivePanels({ fields: fieldsRaw, messageFieldKeys, messageKey, visualKey, listKey }) {
883
+ var _a;
884
+ // prepare values
885
+ const fields = fieldsRaw;
886
+ const visual = visualKey
887
+ ? fields[visualKey]
888
+ : undefined;
889
+ const list = listKey
890
+ ? fields[listKey]
891
+ : undefined;
892
+ // return result
893
+ return {
894
+ message: messageKey && MessagePanel_1.MessagePanel.Fields.exists(fields, messageFieldKeys)
895
+ ? MessagePanel_1.MessagePanel.Fields.isEmpty(fields, messageFieldKeys)
896
+ ? 'invalid'
897
+ : 'valid'
898
+ : false,
899
+ visual: visual
900
+ ? visual.value
901
+ ? 'valid'
902
+ : 'invalid'
903
+ : false,
904
+ list: list
905
+ ? ((_a = list.value) !== null && _a !== void 0 ? _a : []).length === 0
906
+ ? 'valid'
907
+ : 'invalid'
908
+ : false
909
+ };
910
+ }
911
+ BlockPanel.getActivePanels = getActivePanels;
56
912
  })(BlockPanel || (exports.BlockPanel = BlockPanel = {}));