@nascentdigital/funnel-ui 4.6.7 → 5.0.2
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 +87 -15
- package/dist/server/blocks/Block.js +785 -60
- package/dist/server/blocks/MediaLayout.d.ts +26 -10
- package/dist/server/blocks/MediaLayout.js +14 -23
- package/dist/server/blocks/Message.js +2 -2
- package/dist/server/blocks/RelatedPages.js +4 -4
- package/dist/server/blocks/index.d.ts +0 -1
- package/dist/server/blocks/index.js +0 -1
- package/dist/server/fields/Media.d.ts +50 -22
- package/dist/server/fields/Media.js +75 -48
- 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
- package/dist/server/blocks/Editorial.d.ts +0 -33
- package/dist/server/blocks/Editorial.js +0 -80
|
@@ -50,41 +50,6 @@ function Block(_a) {
|
|
|
50
50
|
}
|
|
51
51
|
// extension
|
|
52
52
|
(function (Block) {
|
|
53
|
-
function createSchema({ id, name, version, hint, message, visual, list, extendConfigSchema }) {
|
|
54
|
-
// build fields schema and panel key mapping
|
|
55
|
-
let fieldsSchema = {};
|
|
56
|
-
const panelKeyMapping = {};
|
|
57
|
-
if (message) {
|
|
58
|
-
fieldsSchema = Object.assign(Object.assign({}, fieldsSchema), panels_1.MessagePanel.Fields.all);
|
|
59
|
-
panelKeyMapping.messageKey = 'message';
|
|
60
|
-
}
|
|
61
|
-
if (visual) {
|
|
62
|
-
fieldsSchema = Object.assign(Object.assign({}, fieldsSchema), panels_1.VisualPanel.Fields.all);
|
|
63
|
-
panelKeyMapping.visualKey = 'visual';
|
|
64
|
-
}
|
|
65
|
-
if (list) {
|
|
66
|
-
fieldsSchema = Object.assign(Object.assign({}, fieldsSchema), { list });
|
|
67
|
-
panelKeyMapping.listKey = 'list';
|
|
68
|
-
}
|
|
69
|
-
// create config schema
|
|
70
|
-
const configSchema = panels_1.BlockPanel.getConfigSchema(Object.assign(Object.assign({ fields: fieldsSchema }, panelKeyMapping), { extend: extendConfigSchema }));
|
|
71
|
-
// create block schema
|
|
72
|
-
const schema = funnel_core_1.Schema.Block.create({
|
|
73
|
-
id,
|
|
74
|
-
name,
|
|
75
|
-
version,
|
|
76
|
-
hint,
|
|
77
|
-
config: configSchema,
|
|
78
|
-
fields: fieldsSchema,
|
|
79
|
-
getConfig: args => panels_1.BlockPanel.getConfig(Object.assign({ args }, panelKeyMapping)),
|
|
80
|
-
getLayout: args => panels_1.BlockPanel.getLayout(Object.assign({ args }, panelKeyMapping))
|
|
81
|
-
});
|
|
82
|
-
// return
|
|
83
|
-
return {
|
|
84
|
-
schema: schema,
|
|
85
|
-
panelKeyMapping
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
53
|
function create(args) {
|
|
89
54
|
// create schema
|
|
90
55
|
const { schema, panelKeyMapping } = createSchema(args);
|
|
@@ -97,28 +62,36 @@ function Block(_a) {
|
|
|
97
62
|
return null;
|
|
98
63
|
}
|
|
99
64
|
// layout
|
|
100
|
-
const blockLayout =
|
|
65
|
+
const blockLayout = getLayout(Object.assign({ args: {
|
|
101
66
|
fields: (_a = props.model.fields) !== null && _a !== void 0 ? _a : {},
|
|
102
67
|
config: (_b = props.model.config) !== null && _b !== void 0 ? _b : {}
|
|
103
68
|
} }, panelKeyMapping));
|
|
104
69
|
const getPanel = ({ className, panel }) => {
|
|
105
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
106
71
|
switch (panel.type) {
|
|
72
|
+
// message panel
|
|
107
73
|
case 'message': {
|
|
108
74
|
const { model: { fields }, messagePanelProps } = props;
|
|
109
|
-
const
|
|
75
|
+
const _p = messagePanelProps !== null && messagePanelProps !== void 0 ? messagePanelProps : {}, { className: panelClassName } = _p, panelProps = __rest(_p, ["className"]);
|
|
110
76
|
return ((0, jsx_runtime_1.jsx)(panels_1.MessagePanel, Object.assign({ className: (0, classnames_1.default)(className, panelClassName), panel: panel, title: (_a = fields === null || fields === void 0 ? void 0 : fields.title) === null || _a === void 0 ? void 0 : _a.value, headline: (_b = fields === null || fields === void 0 ? void 0 : fields.headline) === null || _b === void 0 ? void 0 : _b.value, caption: (_c = fields === null || fields === void 0 ? void 0 : fields.caption) === null || _c === void 0 ? void 0 : _c.value, ctas: (_d = fields === null || fields === void 0 ? void 0 : fields.ctas) === null || _d === void 0 ? void 0 : _d.value }, panelProps)));
|
|
111
77
|
}
|
|
78
|
+
// visual panel
|
|
112
79
|
case 'visual': {
|
|
113
80
|
const { model: { fields, config }, visualPanelProps } = props;
|
|
114
|
-
const
|
|
115
|
-
return ((0, jsx_runtime_1.jsx)(panels_1.VisualPanel, Object.assign({ className: (0, classnames_1.default)(className, panelClassName), panel: panel, visual: (_e = fields === null || fields === void 0 ? void 0 : fields.visual) === null || _e === void 0 ? void 0 : _e.value, anchor: (_f = funnel_core_1.Schema.EnumField.Value.fromData(config === null || config === void 0 ? void 0 : config.visualAnchor)) !== null && _f !== void 0 ? _f : 'center' }, panelProps)));
|
|
81
|
+
const _q = visualPanelProps !== null && visualPanelProps !== void 0 ? visualPanelProps : {}, { className: panelClassName } = _q, panelProps = __rest(_q, ["className"]);
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(panels_1.VisualPanel, Object.assign({ className: (0, classnames_1.default)(className, panelClassName), panel: panel, visual: (_e = fields === null || fields === void 0 ? void 0 : fields.visual) === null || _e === void 0 ? void 0 : _e.value, anchor: (_f = funnel_core_1.Schema.EnumField.Value.fromData(config === null || config === void 0 ? void 0 : config.visualAnchor)) !== null && _f !== void 0 ? _f : 'center', controls: (_g = funnel_core_1.Schema.BooleanField.Value.fromData(config === null || config === void 0 ? void 0 : config.visualControls)) !== null && _g !== void 0 ? _g : true, autoPlay: (_h = funnel_core_1.Schema.BooleanField.Value.fromData(config === null || config === void 0 ? void 0 : config.visualAutoPlay)) !== null && _h !== void 0 ? _h : false, loop: (_j = funnel_core_1.Schema.BooleanField.Value.fromData(config === null || config === void 0 ? void 0 : config.visualLoop)) !== null && _j !== void 0 ? _j : false, mute: (_k = funnel_core_1.Schema.BooleanField.Value.fromData(config === null || config === void 0 ? void 0 : config.visualMute)) !== null && _k !== void 0 ? _k : false }, panelProps)));
|
|
116
83
|
}
|
|
84
|
+
// list panel
|
|
117
85
|
case 'list': {
|
|
118
86
|
const { model: { fields, config }, listPanelProps, children } = props;
|
|
119
|
-
const
|
|
120
|
-
const listLayout = (
|
|
121
|
-
|
|
87
|
+
const _r = listPanelProps !== null && listPanelProps !== void 0 ? listPanelProps : {}, { className: panelClassName, itemProps } = _r, panelProps = __rest(_r, ["className", "itemProps"]);
|
|
88
|
+
const listLayout = (_l = funnel_core_1.Schema.EnumField.Value.fromData(config === null || config === void 0 ? void 0 : config.listLayout)) !== null && _l !== void 0 ? _l : 'card';
|
|
89
|
+
// determine renderer
|
|
90
|
+
const renderItem = children !== null && children !== void 0 ? children : (_m = args.list) === null || _m === void 0 ? void 0 : _m.renderItem;
|
|
91
|
+
if (!renderItem) {
|
|
92
|
+
throw new funnel_core_1.IllegalStateError(`No item render specified for list panel`);
|
|
93
|
+
}
|
|
94
|
+
return ((0, jsx_runtime_1.jsx)(panels_1.ListPanel, Object.assign({ className: (0, classnames_1.default)(className, panelClassName), panel: panel, layout: listLayout, items: (_o = fields === null || fields === void 0 ? void 0 : fields.list) === null || _o === void 0 ? void 0 : _o.value }, panelProps, { children: item => renderItem({ item, itemProps, listLayout, blockLayout }) })));
|
|
122
95
|
}
|
|
123
96
|
}
|
|
124
97
|
};
|
|
@@ -132,25 +105,737 @@ function Block(_a) {
|
|
|
132
105
|
};
|
|
133
106
|
}
|
|
134
107
|
Block.create = create;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
108
|
+
// create schema
|
|
109
|
+
function createSchema({ id, name, version, hint, message, visual, list, extendConfigSchema }) {
|
|
110
|
+
// build fields schema and panel key mapping
|
|
111
|
+
let fieldsSchema = {};
|
|
112
|
+
const panelKeyMapping = {};
|
|
113
|
+
if (message) {
|
|
114
|
+
fieldsSchema = Object.assign(Object.assign({}, fieldsSchema), panels_1.MessagePanel.Fields.all);
|
|
115
|
+
panelKeyMapping.messageKey = 'message';
|
|
116
|
+
}
|
|
117
|
+
if (visual) {
|
|
118
|
+
fieldsSchema = Object.assign(Object.assign({}, fieldsSchema), panels_1.VisualPanel.Fields.all);
|
|
119
|
+
panelKeyMapping.visualKey = 'visual';
|
|
120
|
+
}
|
|
121
|
+
if (list) {
|
|
122
|
+
fieldsSchema = Object.assign(Object.assign({}, fieldsSchema), { list: list.schema });
|
|
123
|
+
panelKeyMapping.listKey = 'list';
|
|
124
|
+
}
|
|
125
|
+
// create config schema
|
|
126
|
+
const configSchema = getConfigSchema(Object.assign(Object.assign({ fields: fieldsSchema }, panelKeyMapping), { extend: extendConfigSchema }));
|
|
127
|
+
// create block schema
|
|
128
|
+
const schema = funnel_core_1.Schema.Block.create({
|
|
129
|
+
id,
|
|
130
|
+
name,
|
|
131
|
+
version,
|
|
132
|
+
hint,
|
|
133
|
+
config: configSchema,
|
|
134
|
+
fields: fieldsSchema,
|
|
135
|
+
getConfig: args => getConfig(Object.assign({ args }, panelKeyMapping)),
|
|
136
|
+
getLayout: args => getLayout(Object.assign({ args }, panelKeyMapping))
|
|
137
|
+
});
|
|
138
|
+
// return
|
|
139
|
+
return {
|
|
140
|
+
schema: schema,
|
|
141
|
+
panelKeyMapping
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// config schema
|
|
145
|
+
let GetConfigSchema;
|
|
146
|
+
(function (GetConfigSchema) {
|
|
147
|
+
let Key;
|
|
148
|
+
(function (Key) {
|
|
149
|
+
// helper
|
|
150
|
+
function normalize(key) {
|
|
151
|
+
return typeof key === 'string'
|
|
152
|
+
? { key, name: funnel_core_1.StringUtils.capitalize(key) }
|
|
153
|
+
: key;
|
|
154
|
+
}
|
|
155
|
+
Key.normalize = normalize;
|
|
156
|
+
})(Key = GetConfigSchema.Key || (GetConfigSchema.Key = {}));
|
|
157
|
+
})(GetConfigSchema = Block.GetConfigSchema || (Block.GetConfigSchema = {}));
|
|
158
|
+
function getConfigSchema({ extend, messageKey: messageKeyRaw, visualKey: visualKeyRaw, listKey: listKeyRaw }) {
|
|
159
|
+
// throw if there are not enough panels
|
|
160
|
+
const { key: messageKey, name: messageLabel } = messageKeyRaw === undefined
|
|
161
|
+
? {}
|
|
162
|
+
: GetConfigSchema.Key.normalize(messageKeyRaw);
|
|
163
|
+
const { key: visualKey, name: visualLabel } = visualKeyRaw === undefined
|
|
164
|
+
? {}
|
|
165
|
+
: GetConfigSchema.Key.normalize(visualKeyRaw);
|
|
166
|
+
const { key: listKey, name: listLabel } = listKeyRaw === undefined
|
|
167
|
+
? {}
|
|
168
|
+
: GetConfigSchema.Key.normalize(listKeyRaw);
|
|
169
|
+
const panelCount = [messageKey, visualKey, listKey].filter(funnel_core_1.Value.isDefined).length;
|
|
170
|
+
if (panelCount === 0) {
|
|
171
|
+
throw new funnel_core_1.IllegalStateError('[BlockPanel.ts] There needs to be at least one panel');
|
|
172
|
+
}
|
|
173
|
+
// initialize config schema
|
|
174
|
+
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 });
|
|
175
|
+
// TODO: runtime error for key not available in fields
|
|
176
|
+
// add schema for message
|
|
177
|
+
if (messageKey) {
|
|
178
|
+
const keys = panels_1.MessagePanel.Config.getKeys(messageKey);
|
|
179
|
+
configSchema[keys.textAlign] = schema_1.TextAlignment.schema
|
|
180
|
+
.rename(`${messageLabel} ${schema_1.TextAlignment.schema.name}`)
|
|
181
|
+
.optional();
|
|
182
|
+
configSchema[keys.width] =
|
|
183
|
+
schema_1.ItemSize.schema
|
|
184
|
+
.rename(`${messageLabel} ${schema_1.ItemSize.schema.name}`)
|
|
185
|
+
.optional();
|
|
186
|
+
configSchema[keys.horizontalAlign] =
|
|
187
|
+
schema_1.ItemAlignment
|
|
188
|
+
.Horizontal.schema.rename(`${messageLabel} ${schema_1.ItemAlignment.Horizontal.schema.name}`)
|
|
189
|
+
.optional();
|
|
190
|
+
configSchema[keys.verticalAlign] = schema_1.ItemAlignment.Vertical.schema.rename(`${messageLabel} ${schema_1.ItemAlignment.Vertical.schema.name}`).optional();
|
|
191
|
+
}
|
|
192
|
+
// add schema for list
|
|
193
|
+
if (listKey) {
|
|
194
|
+
const keys = panels_1.ListPanel.Config.getKeys(listKey);
|
|
195
|
+
configSchema[keys.layout] = schema_1.ListPanelLayout.schema.rename(`${listLabel} ${schema_1.ListPanelLayout.schema.name}`).optional();
|
|
196
|
+
configSchema[keys.width] = schema_1.ItemSize.schema.rename(`${listLabel} ${schema_1.ItemSize.schema.name}`).optional();
|
|
197
|
+
configSchema[keys.horizontalAlign] = schema_1.ItemAlignment
|
|
198
|
+
.Horizontal.schema
|
|
199
|
+
.rename(`${listLabel} ${schema_1.ItemAlignment.Horizontal.schema.name}`)
|
|
200
|
+
.optional();
|
|
201
|
+
configSchema[keys.verticalAlign] = schema_1.ItemAlignment
|
|
202
|
+
.Horizontal.schema
|
|
203
|
+
.rename(`${listLabel} ${schema_1.ItemAlignment.Vertical.schema.name}`)
|
|
204
|
+
.optional();
|
|
205
|
+
}
|
|
206
|
+
// add schema for visual
|
|
207
|
+
if (visualKey) {
|
|
208
|
+
const keys = panels_1.VisualPanel.Config.getKeys(visualKey);
|
|
209
|
+
configSchema[keys.aspect] = schema_1.AspectRatio.schema
|
|
210
|
+
.rename(`${visualLabel} ${schema_1.AspectRatio.schema.name}`)
|
|
211
|
+
.optional();
|
|
212
|
+
configSchema[keys.anchor] = schema_1.Anchor.schema
|
|
213
|
+
.rename(`${visualLabel} ${schema_1.Anchor.schema.name}`)
|
|
214
|
+
.optional();
|
|
215
|
+
configSchema[keys.width] =
|
|
216
|
+
schema_1.ItemSize.schema
|
|
217
|
+
.rename(`${visualLabel} ${schema_1.ItemSize.schema.name}`)
|
|
218
|
+
.optional();
|
|
219
|
+
configSchema[keys.horizontalAlign] =
|
|
220
|
+
schema_1.ItemAlignment
|
|
221
|
+
.Horizontal.schema.rename(`${visualLabel} ${schema_1.ItemAlignment.Horizontal.schema.name}`)
|
|
222
|
+
.optional();
|
|
223
|
+
configSchema[keys.controls] = funnel_core_1.Schema.Field.boolean({
|
|
224
|
+
name: 'Controls',
|
|
225
|
+
description: 'Display video controls so views can play/pause/seek content.',
|
|
226
|
+
defaultValue: true,
|
|
227
|
+
semantics: 'toggle'
|
|
228
|
+
}).optional();
|
|
229
|
+
configSchema[keys.autoPlay] = funnel_core_1.Schema.Field.boolean({
|
|
230
|
+
name: 'Autoplay',
|
|
231
|
+
description: 'Video will automatically play once it\'s ready.',
|
|
232
|
+
defaultValue: false,
|
|
233
|
+
semantics: 'toggle'
|
|
234
|
+
}).optional();
|
|
235
|
+
configSchema[keys.loop] = funnel_core_1.Schema.Field.boolean({
|
|
236
|
+
name: 'Loop',
|
|
237
|
+
description: 'Video will loop forever when enabled.',
|
|
238
|
+
defaultValue: false,
|
|
239
|
+
semantics: 'toggle'
|
|
240
|
+
}).optional();
|
|
241
|
+
configSchema[keys.mute] = funnel_core_1.Schema.Field.boolean({
|
|
242
|
+
name: 'Mute',
|
|
243
|
+
description: 'Audio will be silenced.',
|
|
244
|
+
defaultValue: true,
|
|
245
|
+
semantics: 'toggle'
|
|
246
|
+
}).optional();
|
|
247
|
+
}
|
|
248
|
+
// add content alignment/split if there are more than 2 panels
|
|
249
|
+
if (panelCount > 1) {
|
|
250
|
+
configSchema['contentAlign'] = schema_1.ItemAlignment.Vertical.schema.rename('Content Alignment').optional();
|
|
251
|
+
configSchema['contentSplit'] = schema_1.RowRatio.schema.rename('Content Split').optional();
|
|
252
|
+
}
|
|
253
|
+
// return
|
|
254
|
+
return configSchema;
|
|
139
255
|
}
|
|
140
|
-
Block.
|
|
256
|
+
Block.getConfigSchema = getConfigSchema;
|
|
257
|
+
function getConfig({ args, messageFieldKeys, messageKey, visualKey, listKey }) {
|
|
258
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
259
|
+
// throw if there are not enough panels
|
|
260
|
+
const panelCount = [messageKey, visualKey, listKey].filter(funnel_core_1.Value.isDefined).length;
|
|
261
|
+
if (panelCount === 0) {
|
|
262
|
+
throw new funnel_core_1.IllegalStateError('[BlockPanel.ts] There needs to be at least one panel');
|
|
263
|
+
}
|
|
264
|
+
// resolve props
|
|
265
|
+
const configSchema = args.configSchema;
|
|
266
|
+
const config = args.config;
|
|
267
|
+
const fields = args.fields;
|
|
268
|
+
const messageKeys = messageKey
|
|
269
|
+
? panels_1.MessagePanel.Config.getKeys(messageKey)
|
|
270
|
+
: {};
|
|
271
|
+
const visualKeys = visualKey
|
|
272
|
+
? panels_1.VisualPanel.Config.getKeys(visualKey)
|
|
273
|
+
: {};
|
|
274
|
+
const listKeys = listKey
|
|
275
|
+
? panels_1.ListPanel.Config.getKeys(listKey)
|
|
276
|
+
: {};
|
|
277
|
+
const allKeys = [
|
|
278
|
+
...Object.values(messageKeys),
|
|
279
|
+
...Object.values(visualKeys),
|
|
280
|
+
...Object.values(listKeys)
|
|
281
|
+
];
|
|
282
|
+
// current config helpers
|
|
283
|
+
const visual = visualKey
|
|
284
|
+
? fields[visualKey]
|
|
285
|
+
: undefined;
|
|
286
|
+
const panelInfo = getActivePanels({ fields: args.fields, messageFieldKeys, messageKey, visualKey, listKey });
|
|
287
|
+
const activePanels = {
|
|
288
|
+
message: panelInfo.message !== false,
|
|
289
|
+
visual: panelInfo.visual !== false,
|
|
290
|
+
list: panelInfo.list !== false,
|
|
291
|
+
};
|
|
292
|
+
// get layout schema
|
|
293
|
+
const layoutSchema = schema_1.PanelLayout.schemaForPanels(activePanels);
|
|
294
|
+
let layout = ((_b = (_a = config.layout) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'solo');
|
|
295
|
+
layout = layoutSchema.isValidOption(layout)
|
|
296
|
+
? layout
|
|
297
|
+
: layoutSchema.defaultOption;
|
|
298
|
+
const slotVariationSchema = schema_1.SlotVariation.schemaForLayout(layout);
|
|
299
|
+
let slotVariation = ((_d = (_c = config.slotVariation) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'v1');
|
|
300
|
+
slotVariation = slotVariationSchema.isValidOption(slotVariation)
|
|
301
|
+
? slotVariation
|
|
302
|
+
: slotVariationSchema.defaultOption;
|
|
303
|
+
const items = panels_1.BlockPanel.Slots.Items.compute({
|
|
304
|
+
panels: activePanels,
|
|
305
|
+
layout,
|
|
306
|
+
variation: slotVariation
|
|
307
|
+
});
|
|
308
|
+
const flexDirections = panels_1.BlockPanel.Slots.getFlexDirections({ layout, items });
|
|
309
|
+
// extract message config
|
|
310
|
+
let messageConfig = undefined;
|
|
311
|
+
if (messageKey && activePanels.message) {
|
|
312
|
+
messageConfig = panels_1.MessagePanel.getConfig({
|
|
313
|
+
messageKey,
|
|
314
|
+
config: config,
|
|
315
|
+
fields: fields,
|
|
316
|
+
flexDirection: flexDirections.M
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
// extract visual config (if any)
|
|
320
|
+
let visualConfig = undefined;
|
|
321
|
+
if (visualKey && activePanels.visual) {
|
|
322
|
+
visualConfig = panels_1.VisualPanel.getConfig({
|
|
323
|
+
visualKey,
|
|
324
|
+
visual,
|
|
325
|
+
config: config,
|
|
326
|
+
flexDirection: flexDirections.V
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// extract list config (if any)
|
|
330
|
+
let listConfig = undefined;
|
|
331
|
+
if (listKey && activePanels.list) {
|
|
332
|
+
listConfig = panels_1.ListPanel.getConfig({
|
|
333
|
+
listKey,
|
|
334
|
+
config: config,
|
|
335
|
+
flexDirection: flexDirections.L
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
// create new schema
|
|
339
|
+
const updatedConfigSchema = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Object.entries(configSchema)
|
|
340
|
+
.reduce((configSchema, [key, fieldSchema]) => {
|
|
341
|
+
// add the config back if it's not in the panel config keys
|
|
342
|
+
if (!allKeys.includes(key)) {
|
|
343
|
+
configSchema[key] = fieldSchema;
|
|
344
|
+
}
|
|
345
|
+
// keep reducing
|
|
346
|
+
return configSchema;
|
|
347
|
+
}, {})), 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 });
|
|
348
|
+
// drop content alignment if it's not applicable
|
|
349
|
+
if (!panels_1.BlockPanel.Slots.contentAlignmentExists(layout)) {
|
|
350
|
+
delete updatedConfigSchema.contentAlign;
|
|
351
|
+
}
|
|
352
|
+
// drop layout/content split if not applicable
|
|
353
|
+
if (panelCount < 2) {
|
|
354
|
+
delete updatedConfigSchema.layout;
|
|
355
|
+
delete updatedConfigSchema.contentSplit;
|
|
356
|
+
}
|
|
357
|
+
// create default config
|
|
358
|
+
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') });
|
|
359
|
+
const contentAlign = ((_h = (_g = config.contentAlign) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : 'start');
|
|
360
|
+
const contentSplit = ((_k = (_j = config.contentSplit) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : '1/1');
|
|
361
|
+
// create new config
|
|
362
|
+
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) });
|
|
363
|
+
// return config
|
|
364
|
+
return {
|
|
365
|
+
updatedConfigSchema: updatedConfigSchema,
|
|
366
|
+
updatedConfig: updatedConfig,
|
|
367
|
+
defaultConfig: defaultConfig
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
Block.getConfig = getConfig;
|
|
371
|
+
function getLayout({ args, messageFieldKeys, messageKey, visualKey, listKey }) {
|
|
372
|
+
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, _4, _5;
|
|
373
|
+
// throw if there are not enough panels
|
|
374
|
+
const panelCount = [messageKey, visualKey, listKey].filter(funnel_core_1.Value.isDefined).length;
|
|
375
|
+
if (panelCount === 0) {
|
|
376
|
+
throw new funnel_core_1.IllegalStateError('[BlockPanel.ts] There needs to be at least one panel');
|
|
377
|
+
}
|
|
378
|
+
// resolve props
|
|
379
|
+
const config = args.config;
|
|
380
|
+
const messageKeys = messageKey
|
|
381
|
+
? panels_1.MessagePanel.Config.getKeys(messageKey)
|
|
382
|
+
: {};
|
|
383
|
+
const visualKeys = visualKey
|
|
384
|
+
? panels_1.VisualPanel.Config.getKeys(visualKey)
|
|
385
|
+
: {};
|
|
386
|
+
const listKeys = listKey
|
|
387
|
+
? panels_1.ListPanel.Config.getKeys(listKey)
|
|
388
|
+
: {};
|
|
389
|
+
// current config helpers
|
|
390
|
+
const panelInfo = getActivePanels({ fields: args.fields, messageFieldKeys, messageKey, visualKey, listKey });
|
|
391
|
+
const activePanels = {
|
|
392
|
+
message: panelInfo.message !== false,
|
|
393
|
+
visual: panelInfo.visual !== false,
|
|
394
|
+
list: panelInfo.list !== false,
|
|
395
|
+
};
|
|
396
|
+
// get layout schema
|
|
397
|
+
const layout = ((_b = (_a = config.layout) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'solo');
|
|
398
|
+
const slotVariation = ((_d = (_c = config.slotVariation) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'v1');
|
|
399
|
+
const items = panels_1.BlockPanel.Slots.Items.compute({
|
|
400
|
+
panels: activePanels,
|
|
401
|
+
layout,
|
|
402
|
+
variation: slotVariation
|
|
403
|
+
});
|
|
404
|
+
// compute content alignment/split config
|
|
405
|
+
const contentAlign = (_f = (_e = config.contentAlign) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : 'start';
|
|
406
|
+
const contentSplit = ((_h = (_g = config.contentSplit) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : '1/1');
|
|
407
|
+
// compute message config
|
|
408
|
+
const messageWidthRaw = (_j = config[messageKeys.width]) === null || _j === void 0 ? void 0 : _j.value;
|
|
409
|
+
const isMessageFullBleed = messageWidthRaw === 'fullBleed';
|
|
410
|
+
const messageWidth = isMessageFullBleed ? 'full' : (_l = (_k = config[messageKeys.width]) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 'full';
|
|
411
|
+
const messageTextAlign = (_o = (_m = config[messageKeys.textAlign]) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 'left';
|
|
412
|
+
const messageHorizontalAlign = (_q = (_p = config[messageKeys.horizontalAlign]) === null || _p === void 0 ? void 0 : _p.value) !== null && _q !== void 0 ? _q : 'start';
|
|
413
|
+
const messageVerticalAlign = (_s = (_r = config[messageKeys.verticalAlign]) === null || _r === void 0 ? void 0 : _r.value) !== null && _s !== void 0 ? _s : 'start';
|
|
414
|
+
// compute visual config
|
|
415
|
+
const visualAspect = (_u = (_t = config[visualKeys.aspect]) === null || _t === void 0 ? void 0 : _t.value) !== null && _u !== void 0 ? _u : 'auto';
|
|
416
|
+
const visualWidth = ((_w = (_v = config[visualKeys.width]) === null || _v === void 0 ? void 0 : _v.value) !== null && _w !== void 0 ? _w : 'full');
|
|
417
|
+
const visualHorizontalAlign = (_y = (_x = config[visualKeys.horizontalAlign]) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 'start';
|
|
418
|
+
const isVisualFullBleed = visualWidth === 'fullBleed';
|
|
419
|
+
// compute list config
|
|
420
|
+
const listWidthRaw = (_z = config[listKeys.width]) === null || _z === void 0 ? void 0 : _z.value;
|
|
421
|
+
const isListFullBleed = listWidthRaw === 'fullBleed';
|
|
422
|
+
const listWidth = isListFullBleed ? 'full' : (_1 = (_0 = config[listKeys.width]) === null || _0 === void 0 ? void 0 : _0.value) !== null && _1 !== void 0 ? _1 : 'full';
|
|
423
|
+
const listHorizontalAlign = (_3 = (_2 = config[listKeys.horizontalAlign]) === null || _2 === void 0 ? void 0 : _2.value) !== null && _3 !== void 0 ? _3 : 'start';
|
|
424
|
+
const listVerticalAlign = (_5 = (_4 = config[listKeys.verticalAlign]) === null || _4 === void 0 ? void 0 : _4.value) !== null && _5 !== void 0 ? _5 : 'start';
|
|
425
|
+
// create visual if we have one
|
|
426
|
+
let visualSlot = undefined;
|
|
427
|
+
if (items.includes('V') || schema_1.PanelLayout.isNested(layout)) {
|
|
428
|
+
// language=XML
|
|
429
|
+
visualSlot = (`
|
|
430
|
+
<visual
|
|
431
|
+
xmlns="nd:block"
|
|
432
|
+
aspect="${visualAspect}"
|
|
433
|
+
size="${visualWidth === 'fullBleed' ? 'full' : visualWidth}"
|
|
434
|
+
alignX="${visualHorizontalAlign}"
|
|
435
|
+
fullBleed="${isVisualFullBleed}"
|
|
436
|
+
/>
|
|
437
|
+
`);
|
|
438
|
+
}
|
|
439
|
+
// create slot items
|
|
440
|
+
const slots = items.map(item => {
|
|
441
|
+
switch (item) {
|
|
442
|
+
case 'M': {
|
|
443
|
+
// language=XML
|
|
444
|
+
return (`
|
|
445
|
+
<message
|
|
446
|
+
xmlns="nd:block"
|
|
447
|
+
textAlign="${messageTextAlign}"
|
|
448
|
+
size="${messageWidth}"
|
|
449
|
+
fullBleed="${isMessageFullBleed}"
|
|
450
|
+
alignX="${messageHorizontalAlign}"
|
|
451
|
+
alignY="${messageVerticalAlign}"
|
|
452
|
+
/>
|
|
453
|
+
`);
|
|
454
|
+
}
|
|
455
|
+
case 'V':
|
|
456
|
+
return visualSlot;
|
|
457
|
+
case 'L': {
|
|
458
|
+
// FIXME: update props from config (lists WILL REQUIRED new props)
|
|
459
|
+
// language=XML
|
|
460
|
+
return (`
|
|
461
|
+
<list
|
|
462
|
+
xmlns="nd:block"
|
|
463
|
+
layout="column"
|
|
464
|
+
itemType="message"
|
|
465
|
+
size="${listWidth}"
|
|
466
|
+
alignX="${listHorizontalAlign}"
|
|
467
|
+
alignY="${listVerticalAlign}"
|
|
468
|
+
fullBleed="${isListFullBleed}"
|
|
469
|
+
itemCount="2"
|
|
470
|
+
/>
|
|
471
|
+
`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
// build layout
|
|
476
|
+
let blockLayout = '';
|
|
477
|
+
switch (layout) {
|
|
478
|
+
case 'solo':
|
|
479
|
+
// language=XML
|
|
480
|
+
blockLayout = `
|
|
481
|
+
<block xmlns="nd:block" name="Solo">
|
|
482
|
+
<col>
|
|
483
|
+
${slots[0]}
|
|
484
|
+
</col>
|
|
485
|
+
</block>
|
|
486
|
+
`;
|
|
487
|
+
break;
|
|
488
|
+
case 'stack.h': {
|
|
489
|
+
// compute tight
|
|
490
|
+
let tightDesktop = 'none';
|
|
491
|
+
let tightMobile = 'none';
|
|
492
|
+
if (isVisualFullBleed) {
|
|
493
|
+
tightDesktop = 'both';
|
|
494
|
+
tightMobile = items[0] === 'V' ? 'above' : 'below';
|
|
495
|
+
}
|
|
496
|
+
// language=XML
|
|
497
|
+
blockLayout = `
|
|
498
|
+
<block
|
|
499
|
+
xmlns="nd:block"
|
|
500
|
+
name="Horizontal Stack"
|
|
501
|
+
tightDesktop="${tightDesktop}"
|
|
502
|
+
tightMobile="${tightMobile}"
|
|
503
|
+
>
|
|
504
|
+
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
505
|
+
${slots[0]}
|
|
506
|
+
${slots[1]}
|
|
507
|
+
</row>
|
|
508
|
+
</block>
|
|
509
|
+
`;
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
case 'stack.v':
|
|
513
|
+
// language=XML
|
|
514
|
+
blockLayout = `
|
|
515
|
+
<block
|
|
516
|
+
xmlns="nd:block" name="Vertical Stack"
|
|
517
|
+
tight="${!isVisualFullBleed ? 'none' : items[0] === 'V' ? 'above' : 'below'}">
|
|
518
|
+
<col>
|
|
519
|
+
${slots[0]}
|
|
520
|
+
${slots[1]}
|
|
521
|
+
</col>
|
|
522
|
+
</block>
|
|
523
|
+
`;
|
|
524
|
+
break;
|
|
525
|
+
case 'nested':
|
|
526
|
+
// language=XML
|
|
527
|
+
blockLayout = `
|
|
528
|
+
<block xmlns="nd:block" name="Nested: Simple" tight="${isVisualFullBleed ? 'both' : 'none'}">
|
|
529
|
+
<stack>
|
|
530
|
+
${visualSlot}
|
|
531
|
+
${slots[0]}
|
|
532
|
+
</stack>
|
|
533
|
+
</block>
|
|
534
|
+
`;
|
|
535
|
+
break;
|
|
536
|
+
case 'nested.h':
|
|
537
|
+
// language=XML
|
|
538
|
+
blockLayout = `
|
|
539
|
+
<block xmlns="nd:block" name="Nested: Horizontal">
|
|
540
|
+
<stack>
|
|
541
|
+
${visualSlot}
|
|
542
|
+
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
543
|
+
${slots[0]}
|
|
544
|
+
${slots[1]}
|
|
545
|
+
</row>
|
|
546
|
+
</stack>
|
|
547
|
+
</block>
|
|
548
|
+
`;
|
|
549
|
+
break;
|
|
550
|
+
case 'nested.v':
|
|
551
|
+
// language=XML
|
|
552
|
+
blockLayout = `
|
|
553
|
+
<block xmlns="nd:block" name="Nested: Vertical">
|
|
554
|
+
<stack>
|
|
555
|
+
${visualSlot}
|
|
556
|
+
<col>
|
|
557
|
+
${slots[0]}
|
|
558
|
+
${slots[1]}
|
|
559
|
+
</col>
|
|
560
|
+
</stack>
|
|
561
|
+
</block>
|
|
562
|
+
`;
|
|
563
|
+
break;
|
|
564
|
+
case 'nested.t':
|
|
565
|
+
// language=XML
|
|
566
|
+
blockLayout = `
|
|
567
|
+
<block xmlns="nd:block" name="Nested: Top">
|
|
568
|
+
<col>
|
|
569
|
+
<stack>
|
|
570
|
+
${visualSlot}
|
|
571
|
+
${slots[0]}
|
|
572
|
+
</stack>
|
|
573
|
+
${slots[1]}
|
|
574
|
+
</col>
|
|
575
|
+
</block>
|
|
576
|
+
`;
|
|
577
|
+
break;
|
|
578
|
+
case 'nested.r':
|
|
579
|
+
// language=XML
|
|
580
|
+
blockLayout = `
|
|
581
|
+
<block xmlns="nd:block" name="Nested: Right">
|
|
582
|
+
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
583
|
+
${slots[0]}
|
|
584
|
+
<stack>
|
|
585
|
+
${visualSlot}
|
|
586
|
+
${slots[1]}
|
|
587
|
+
</stack>
|
|
588
|
+
</row>
|
|
589
|
+
</block>
|
|
590
|
+
`;
|
|
591
|
+
break;
|
|
592
|
+
case 'nested.b':
|
|
593
|
+
// language=XML
|
|
594
|
+
blockLayout = `
|
|
595
|
+
<block xmlns="nd:block" name="Nested: Bottom">
|
|
596
|
+
<col>
|
|
597
|
+
${slots[0]}
|
|
598
|
+
<stack>
|
|
599
|
+
${visualSlot}
|
|
600
|
+
${slots[1]}
|
|
601
|
+
</stack>
|
|
602
|
+
</col>
|
|
603
|
+
</block>
|
|
604
|
+
`;
|
|
605
|
+
break;
|
|
606
|
+
case 'nested.l':
|
|
607
|
+
// language=XML
|
|
608
|
+
blockLayout = `
|
|
609
|
+
<block xmlns="nd:block" name="Nested: Left">
|
|
610
|
+
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
611
|
+
<stack>
|
|
612
|
+
${visualSlot}
|
|
613
|
+
${slots[0]}
|
|
614
|
+
</stack>
|
|
615
|
+
${slots[1]}
|
|
616
|
+
</row>
|
|
617
|
+
</block>
|
|
618
|
+
`;
|
|
619
|
+
break;
|
|
620
|
+
case 'brick.v': {
|
|
621
|
+
// compute tight
|
|
622
|
+
let tight = 'none';
|
|
623
|
+
if (isVisualFullBleed) {
|
|
624
|
+
if (items[0] === 'V') {
|
|
625
|
+
tight = 'above';
|
|
626
|
+
}
|
|
627
|
+
else if (items[2] === 'V') {
|
|
628
|
+
tight = 'below';
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
// language=XML
|
|
632
|
+
blockLayout = `
|
|
633
|
+
<block
|
|
634
|
+
xmlns="nd:block"
|
|
635
|
+
name="Brick: Vertical"
|
|
636
|
+
tight="${tight}"
|
|
637
|
+
>
|
|
638
|
+
<col>
|
|
639
|
+
${slots[0]}
|
|
640
|
+
${slots[1]}
|
|
641
|
+
${slots[2]}
|
|
642
|
+
</col>
|
|
643
|
+
</block>
|
|
644
|
+
`;
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
case 'brick.t': {
|
|
648
|
+
// compute tight
|
|
649
|
+
let tightDesktop = 'none';
|
|
650
|
+
let tightMobile = 'none';
|
|
651
|
+
if (isVisualFullBleed) {
|
|
652
|
+
if (items[0] === 'V') {
|
|
653
|
+
tightDesktop = 'above';
|
|
654
|
+
tightMobile = 'above';
|
|
655
|
+
}
|
|
656
|
+
else if (items[1] === 'V') {
|
|
657
|
+
tightDesktop = 'below';
|
|
658
|
+
tightMobile = 'none';
|
|
659
|
+
}
|
|
660
|
+
else if (items[2] === 'V') {
|
|
661
|
+
tightDesktop = 'below';
|
|
662
|
+
tightMobile = 'below';
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
// language=XML
|
|
666
|
+
blockLayout = `
|
|
667
|
+
<block
|
|
668
|
+
xmlns="nd:block"
|
|
669
|
+
name="Brick: Top"
|
|
670
|
+
tightDesktop="${tightDesktop}"
|
|
671
|
+
tightMobile="${tightMobile}"
|
|
672
|
+
>
|
|
673
|
+
<col>
|
|
674
|
+
${slots[0]}
|
|
675
|
+
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
676
|
+
${slots[1]}
|
|
677
|
+
${slots[2]}
|
|
678
|
+
</row>
|
|
679
|
+
</col>
|
|
680
|
+
</block>
|
|
681
|
+
`;
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
case 'brick.r': {
|
|
685
|
+
// compute tight
|
|
686
|
+
let tightDesktop = 'none';
|
|
687
|
+
let tightMobile = 'none';
|
|
688
|
+
if (isVisualFullBleed) {
|
|
689
|
+
if (items[0] === 'V') {
|
|
690
|
+
tightDesktop = 'above';
|
|
691
|
+
tightMobile = 'above';
|
|
692
|
+
}
|
|
693
|
+
else if (items[1] === 'V') {
|
|
694
|
+
tightDesktop = 'both';
|
|
695
|
+
tightMobile = 'below';
|
|
696
|
+
}
|
|
697
|
+
else if (items[2] === 'V') {
|
|
698
|
+
tightDesktop = 'below';
|
|
699
|
+
tightMobile = 'none';
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
// language=XML
|
|
703
|
+
blockLayout = `
|
|
704
|
+
<block
|
|
705
|
+
xmlns="nd:block"
|
|
706
|
+
name="Brick: Right"
|
|
707
|
+
tightDesktop="${tightDesktop}"
|
|
708
|
+
tightMobile="${tightMobile}"
|
|
709
|
+
>
|
|
710
|
+
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
711
|
+
<col>
|
|
712
|
+
${slots[0]}
|
|
713
|
+
${slots[2]}
|
|
714
|
+
</col>
|
|
715
|
+
${slots[1]}
|
|
716
|
+
</row>
|
|
717
|
+
</block>
|
|
718
|
+
`;
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
case 'brick.b': {
|
|
722
|
+
// compute tight
|
|
723
|
+
let tightDesktop = 'none';
|
|
724
|
+
let tightMobile = 'none';
|
|
725
|
+
if (isVisualFullBleed) {
|
|
726
|
+
if (items[0] === 'V') {
|
|
727
|
+
tightDesktop = 'above';
|
|
728
|
+
tightMobile = 'above';
|
|
729
|
+
}
|
|
730
|
+
else if (items[1] === 'V') {
|
|
731
|
+
tightDesktop = 'above';
|
|
732
|
+
tightMobile = 'none';
|
|
733
|
+
}
|
|
734
|
+
else if (items[2] === 'V') {
|
|
735
|
+
tightDesktop = 'below';
|
|
736
|
+
tightMobile = 'below';
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
// language=XML
|
|
740
|
+
blockLayout = `
|
|
741
|
+
<block
|
|
742
|
+
xmlns="nd:block"
|
|
743
|
+
name="Brick: Bottom"
|
|
744
|
+
tightDesktop="${tightDesktop}"
|
|
745
|
+
tightMobile="${tightMobile}"
|
|
746
|
+
>
|
|
747
|
+
<col>
|
|
748
|
+
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
749
|
+
${slots[0]}
|
|
750
|
+
${slots[1]}
|
|
751
|
+
</row>
|
|
752
|
+
${slots[2]}
|
|
753
|
+
</col>
|
|
754
|
+
</block>
|
|
755
|
+
`;
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
case 'brick.l': {
|
|
759
|
+
// compute tight
|
|
760
|
+
let tightDesktop = 'none';
|
|
761
|
+
let tightMobile = 'none';
|
|
762
|
+
if (isVisualFullBleed) {
|
|
763
|
+
if (items[0] === 'V') {
|
|
764
|
+
tightDesktop = 'both';
|
|
765
|
+
tightMobile = 'above';
|
|
766
|
+
}
|
|
767
|
+
else if (items[1] === 'V') {
|
|
768
|
+
tightDesktop = 'above';
|
|
769
|
+
tightMobile = 'none';
|
|
770
|
+
}
|
|
771
|
+
else if (items[2] === 'V') {
|
|
772
|
+
tightDesktop = 'below';
|
|
773
|
+
tightMobile = 'below';
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
// language=XML
|
|
777
|
+
blockLayout = `
|
|
778
|
+
<block
|
|
779
|
+
xmlns="nd:block"
|
|
780
|
+
name="Brick: Left"
|
|
781
|
+
tightDesktop="${tightDesktop}"
|
|
782
|
+
tightMobile="${tightMobile}"
|
|
783
|
+
>
|
|
784
|
+
<row alignY="${contentAlign}" ratioDesktop="${contentSplit}">
|
|
785
|
+
${slots[0]}
|
|
786
|
+
<col>
|
|
787
|
+
${slots[1]}
|
|
788
|
+
${slots[2]}
|
|
789
|
+
</col>
|
|
790
|
+
</row>
|
|
791
|
+
</block>
|
|
792
|
+
`;
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
795
|
+
default:
|
|
796
|
+
throw new funnel_core_1.NotImplementedError();
|
|
797
|
+
}
|
|
798
|
+
// return parsed layout
|
|
799
|
+
return funnel_core_1.BlockLayout.parse(blockLayout);
|
|
800
|
+
}
|
|
801
|
+
Block.getLayout = getLayout;
|
|
802
|
+
function getActivePanels({ fields: fieldsRaw, messageFieldKeys, messageKey, visualKey, listKey }) {
|
|
803
|
+
var _a;
|
|
804
|
+
// prepare values
|
|
805
|
+
const fields = fieldsRaw;
|
|
806
|
+
const visual = visualKey
|
|
807
|
+
? fields[visualKey]
|
|
808
|
+
: undefined;
|
|
809
|
+
const list = listKey
|
|
810
|
+
? fields[listKey]
|
|
811
|
+
: undefined;
|
|
812
|
+
// return result
|
|
813
|
+
return {
|
|
814
|
+
message: messageKey && panels_1.MessagePanel.Fields.exists(fields, messageFieldKeys)
|
|
815
|
+
? panels_1.MessagePanel.Fields.isEmpty(fields, messageFieldKeys)
|
|
816
|
+
? 'invalid'
|
|
817
|
+
: 'valid'
|
|
818
|
+
: false,
|
|
819
|
+
visual: visual
|
|
820
|
+
? visual.value
|
|
821
|
+
? 'valid'
|
|
822
|
+
: 'invalid'
|
|
823
|
+
: false,
|
|
824
|
+
list: list
|
|
825
|
+
? ((_a = list.value) !== null && _a !== void 0 ? _a : []).length === 0
|
|
826
|
+
? 'valid'
|
|
827
|
+
: 'invalid'
|
|
828
|
+
: false
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
Block.getActivePanels = getActivePanels;
|
|
141
832
|
})(Block || (exports.Block = Block = {}));
|
|
142
|
-
|
|
143
|
-
// render root container (row/column/stack)
|
|
144
|
-
const { root } = layout;
|
|
145
|
-
const { items } = root;
|
|
146
|
-
const siblingCount = items.length;
|
|
147
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "nd-Block-rootContainerWrap", children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('nd-Block-rootContainer', getContainerClasses(root)), children: items.map((item, index) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem({ renderPanel, parent: root.type, item, siblingCount }) }, `${item.type}.${index}`)) }) }));
|
|
148
|
-
}
|
|
833
|
+
// helpers
|
|
149
834
|
function getContainerClasses(container) {
|
|
150
835
|
var _a;
|
|
151
836
|
const { type, alignX, alignY, items } = container;
|
|
152
837
|
const itemCount = (_a = items.length) !== null && _a !== void 0 ? _a : 0;
|
|
153
|
-
return (0, classnames_1.default)({
|
|
838
|
+
return (0, classnames_1.default)('nd-Block-container', {
|
|
154
839
|
'nd-Block-row': type === 'row',
|
|
155
840
|
'nd-Block-column': type === 'column',
|
|
156
841
|
'nd-Block-stack': type === 'stack',
|
|
@@ -160,11 +845,51 @@ function getContainerClasses(container) {
|
|
|
160
845
|
'nd-Block-y-start': alignY === 'start',
|
|
161
846
|
'nd-Block-y-center': alignY === 'center',
|
|
162
847
|
'nd-Block-y-end': alignY === 'end',
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
848
|
+
}, type === 'row' && funnel_core_1.BlockLayout.ResponsiveClassNames.parse({
|
|
849
|
+
value: container.ratio,
|
|
850
|
+
desktop: {
|
|
851
|
+
'1/1': 'md:nd-Block-row-ratio-1_1',
|
|
852
|
+
'1/2': 'md:nd-Block-row-ratio-1_2',
|
|
853
|
+
'1/3': 'md:nd-Block-row-ratio-1_3',
|
|
854
|
+
'2/1': 'md:nd-Block-row-ratio-2_1',
|
|
855
|
+
'2/3': 'md:nd-Block-row-ratio-2_3',
|
|
856
|
+
'3/1': 'md:nd-Block-row-ratio-3_1',
|
|
857
|
+
'3/2': 'md:nd-Block-row-ratio-3_2',
|
|
858
|
+
},
|
|
859
|
+
mobile: {
|
|
860
|
+
'1/1': '',
|
|
861
|
+
'1/2': '',
|
|
862
|
+
'1/3': '',
|
|
863
|
+
'2/1': '',
|
|
864
|
+
'2/3': '',
|
|
865
|
+
'3/1': '',
|
|
866
|
+
'3/2': '',
|
|
867
|
+
},
|
|
868
|
+
base: {
|
|
869
|
+
'1/1': '',
|
|
870
|
+
'1/2': '',
|
|
871
|
+
'1/3': '',
|
|
872
|
+
'2/1': '',
|
|
873
|
+
'2/3': '',
|
|
874
|
+
'3/1': '',
|
|
875
|
+
'3/2': '',
|
|
876
|
+
}
|
|
877
|
+
}));
|
|
878
|
+
}
|
|
879
|
+
function getWrapperClasses(type) {
|
|
880
|
+
return (0, classnames_1.default)('nd-Block-containerWrap', {
|
|
881
|
+
'nd-Block-rowWrap': type === 'row',
|
|
882
|
+
'nd-Block-columnWrap': type === 'column',
|
|
883
|
+
'nd-Block-stackWrap': type === 'stack',
|
|
166
884
|
});
|
|
167
885
|
}
|
|
886
|
+
function renderLayout({ renderPanel, layout }) {
|
|
887
|
+
// render root container (row/column/stack)
|
|
888
|
+
const { root } = layout;
|
|
889
|
+
const { items } = root;
|
|
890
|
+
const siblingCount = items.length;
|
|
891
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('nd-Block-rootContainerWrap', getWrapperClasses(root.type)), children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('nd-Block-rootContainer', getContainerClasses(root)), children: items.map((item, index) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem({ renderPanel, parent: root.type, item, siblingCount }) }, `${item.type}.${index}`)) }) }));
|
|
892
|
+
}
|
|
168
893
|
function renderItem({ renderPanel, parent, item, siblingCount }) {
|
|
169
894
|
// render based on item type
|
|
170
895
|
switch (item.type) {
|
|
@@ -175,7 +900,7 @@ function renderItem({ renderPanel, parent, item, siblingCount }) {
|
|
|
175
900
|
const { items } = item;
|
|
176
901
|
const parent = item.type;
|
|
177
902
|
const siblingCount = items.length;
|
|
178
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(getContainerClasses(item)), children: items.map((child, index) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem({ renderPanel, parent, item: child, siblingCount }) }, `${child.type}.${index}`)) }));
|
|
903
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(getWrapperClasses(item.type)), children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(getContainerClasses(item)), children: items.map((child, index) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderItem({ renderPanel, parent, item: child, siblingCount }) }, `${child.type}.${index}`)) }) }));
|
|
179
904
|
}
|
|
180
905
|
// child panel (provided by caller)
|
|
181
906
|
default: {
|