@nascentdigital/funnel-core 4.4.20 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schema/Block.d.ts +10 -0
- package/dist/schema/Block.js +13 -0
- package/dist/schema/Fields.d.ts +14 -1
- package/dist/schema/field/base/AssetField.d.ts +3 -3
- package/dist/ui/block-layout/BlockLayout.d.ts +28 -14
- package/dist/ui/block-layout/BlockLayout.js +104 -20
- package/dist/utils/ObjectUtils.d.ts +1 -0
- package/dist/utils/ObjectUtils.js +4 -0
- package/package.json +2 -2
package/dist/schema/Block.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StringKeyOf } from 'type-fest';
|
|
1
2
|
import { Transform } from '../types';
|
|
2
3
|
import { BlockLayout } from '../ui/block-layout';
|
|
3
4
|
import { Field } from './field';
|
|
@@ -26,6 +27,15 @@ export declare class Block<TId extends string = string, TFields extends Fields =
|
|
|
26
27
|
static create<TId extends string, TFields extends Fields, TConfig extends Block.Config>(args: Block.FactoryArgs<TId, TFields, TConfig>): Block<TId, TFields, TConfig>;
|
|
27
28
|
}
|
|
28
29
|
export declare namespace Block {
|
|
30
|
+
type Property<TFields extends Fields = Fields> = Property.Unified<TFields> | Property.Split<TFields>;
|
|
31
|
+
namespace Property {
|
|
32
|
+
type Unified<TFields extends Fields = Fields> = StringKeyOf<TFields>;
|
|
33
|
+
type Split<TFields extends Fields = Fields> = {
|
|
34
|
+
field: StringKeyOf<TFields>;
|
|
35
|
+
config: string;
|
|
36
|
+
};
|
|
37
|
+
function normalize<TFields extends Fields>(property: Property<TFields>): Split<TFields>;
|
|
38
|
+
}
|
|
29
39
|
type GetConfig<TConfig extends Config = Config, TFields extends Fields = Fields> = Transform<GetConfig.Args<TConfig, TFields>, GetConfig.Result<TConfig>>;
|
|
30
40
|
namespace GetConfig {
|
|
31
41
|
type Args<TConfig extends Config, TFields extends Fields> = {
|
package/dist/schema/Block.js
CHANGED
|
@@ -120,3 +120,16 @@ class Block {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
exports.Block = Block;
|
|
123
|
+
// extension
|
|
124
|
+
(function (Block) {
|
|
125
|
+
let Property;
|
|
126
|
+
(function (Property) {
|
|
127
|
+
// helpers
|
|
128
|
+
function normalize(property) {
|
|
129
|
+
return typeof property === 'string'
|
|
130
|
+
? { field: property, config: property }
|
|
131
|
+
: property;
|
|
132
|
+
}
|
|
133
|
+
Property.normalize = normalize;
|
|
134
|
+
})(Property = Block.Property || (Block.Property = {}));
|
|
135
|
+
})(Block || (exports.Block = Block = {}));
|
package/dist/schema/Fields.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { StringKeyOf } from 'type-fest';
|
|
1
2
|
import { Transform } from '../types';
|
|
2
|
-
import { EnumField, Field, RichTextField, TextField } from './field';
|
|
3
|
+
import { AssetField, EnumField, Field, ListField, RichTextField, TextField } from './field';
|
|
3
4
|
import { Optional } from './Optional';
|
|
4
5
|
export type Fields = Record<string, Optional.Maybe<Field.Type>>;
|
|
5
6
|
export declare namespace Fields {
|
|
@@ -25,6 +26,18 @@ export declare namespace Fields {
|
|
|
25
26
|
type TextLikeFields<TFields extends Fields> = {
|
|
26
27
|
[key in keyof TFields as TFields[key] extends TextLikeField ? key : TFields[key] extends _Optional<TextLikeField> ? key : never]: TFields[key];
|
|
27
28
|
};
|
|
29
|
+
type AssetFields<TFields extends Fields> = {
|
|
30
|
+
[key in keyof TFields as TFields[key] extends AssetField ? key : TFields[key] extends _Optional<AssetField> ? key : never]: TFields[key];
|
|
31
|
+
};
|
|
32
|
+
namespace AssetFields {
|
|
33
|
+
type Keys<TFields extends Fields> = StringKeyOf<AssetFields<TFields>>;
|
|
34
|
+
}
|
|
35
|
+
type ListFields<TFields extends Fields> = {
|
|
36
|
+
[key in keyof TFields as TFields[key] extends ListField ? key : TFields[key] extends _Optional<ListField> ? key : never]: TFields[key];
|
|
37
|
+
};
|
|
38
|
+
namespace ListFields {
|
|
39
|
+
type Keys<TFields extends Fields> = StringKeyOf<ListFields<TFields>>;
|
|
40
|
+
}
|
|
28
41
|
function unwrap<TFields extends Fields>(fields: TFields): UnwrapOptional<TFields>;
|
|
29
42
|
}
|
|
30
43
|
type _Optional<T extends Optional.Content> = Optional<T>;
|
|
@@ -20,17 +20,17 @@ export declare class AssetField<TValue extends AssetField.LinkedValue = AssetFie
|
|
|
20
20
|
export declare namespace AssetField {
|
|
21
21
|
type Tags = Tags.Image | Tags.Video;
|
|
22
22
|
namespace Tags {
|
|
23
|
-
const image: TagGroup<"nd.image", "ad" | "icon" | "
|
|
23
|
+
const image: TagGroup<"nd.image", "ad" | "icon" | "logo" | "brand" | "hero" | "background" | "person" | "product" | "lifestyle">;
|
|
24
24
|
type Image = TagGroup.Keys<typeof image>;
|
|
25
25
|
namespace Image {
|
|
26
|
-
function parse(tags?: Image | ReadonlyArray<Image>): Tag<"nd.image", "ad" | "icon" | "
|
|
26
|
+
function parse(tags?: Image | ReadonlyArray<Image>): Tag<"nd.image", "ad" | "icon" | "logo" | "brand" | "hero" | "background" | "person" | "product" | "lifestyle">[] | undefined;
|
|
27
27
|
}
|
|
28
28
|
const video: TagGroup<"nd.video", "ad" | "brand" | "background" | "product" | "education" | "promo">;
|
|
29
29
|
type Video = TagGroup.Keys<typeof video>;
|
|
30
30
|
namespace Video {
|
|
31
31
|
function parse(tags?: Video | ReadonlyArray<Video>): Tag<"nd.video", "ad" | "brand" | "background" | "product" | "education" | "promo">[] | undefined;
|
|
32
32
|
}
|
|
33
|
-
function parse(tags?: Tags | ReadonlyArray<Tags>): (Tag<"nd.image", "ad" | "icon" | "
|
|
33
|
+
function parse(tags?: Tags | ReadonlyArray<Tags>): (Tag<"nd.image", "ad" | "icon" | "logo" | "brand" | "hero" | "background" | "person" | "product" | "lifestyle"> | Tag<"nd.video", "ad" | "brand" | "background" | "product" | "education" | "promo">)[] | undefined;
|
|
34
34
|
}
|
|
35
35
|
type Value<T extends LinkedValue = LinkedValue> = Pick<T, 'id' | 'type' | 'url'>;
|
|
36
36
|
namespace Value {
|
|
@@ -10,13 +10,16 @@ export declare namespace BlockLayout {
|
|
|
10
10
|
type Container = Row | Row.Nested | Column | Column.Nested | Stack | Stack.Nested;
|
|
11
11
|
namespace Container {
|
|
12
12
|
type Base = {
|
|
13
|
+
nested: false;
|
|
13
14
|
alignX?: Alignment;
|
|
14
15
|
alignY?: Alignment;
|
|
15
16
|
};
|
|
16
17
|
type Nested = {
|
|
18
|
+
nested: true;
|
|
17
19
|
items: ReadonlyArray<Panel>;
|
|
18
20
|
mobileOrder?: MobileOrder;
|
|
19
21
|
};
|
|
22
|
+
function filter(item: Container | Panel): item is Container;
|
|
20
23
|
}
|
|
21
24
|
type Row = Container.Base & {
|
|
22
25
|
type: 'row';
|
|
@@ -24,21 +27,21 @@ export declare namespace BlockLayout {
|
|
|
24
27
|
ratio: ResponsiveValue<Ratio>;
|
|
25
28
|
};
|
|
26
29
|
namespace Row {
|
|
27
|
-
type Nested = Omit<Row, 'items'> & Container.Nested;
|
|
30
|
+
type Nested = Omit<Row, 'items' | 'nested'> & Container.Nested;
|
|
28
31
|
}
|
|
29
32
|
type Column = Container.Base & {
|
|
30
33
|
type: 'column';
|
|
31
34
|
items: ReadonlyArray<Row.Nested | Stack.Nested | Panel>;
|
|
32
35
|
};
|
|
33
36
|
namespace Column {
|
|
34
|
-
type Nested = Omit<Column, 'items'> & Container.Nested;
|
|
37
|
+
type Nested = Omit<Column, 'items' | 'nested'> & Container.Nested;
|
|
35
38
|
}
|
|
36
39
|
type Stack = Container.Base & {
|
|
37
40
|
type: 'stack';
|
|
38
41
|
items: ReadonlyArray<Row.Nested | Column.Nested | Panel>;
|
|
39
42
|
};
|
|
40
43
|
namespace Stack {
|
|
41
|
-
type Nested = Omit<Stack, 'items'> & Container.Nested;
|
|
44
|
+
type Nested = Omit<Stack, 'items' | 'nested'> & Container.Nested;
|
|
42
45
|
}
|
|
43
46
|
type NestedItem = Row.Nested | Column.Nested | Stack.Nested | Panel;
|
|
44
47
|
type Panel = Message | Visual | List;
|
|
@@ -46,10 +49,10 @@ export declare namespace BlockLayout {
|
|
|
46
49
|
type Key = Panel['type'] | string;
|
|
47
50
|
type Base = {
|
|
48
51
|
key: Key;
|
|
49
|
-
mobileOrder
|
|
50
|
-
alignX
|
|
51
|
-
alignY
|
|
52
|
-
size
|
|
52
|
+
mobileOrder: MobileOrder;
|
|
53
|
+
alignX: Alignment;
|
|
54
|
+
alignY: Alignment;
|
|
55
|
+
size: Size;
|
|
53
56
|
fullBleed: ResponsiveValue<boolean>;
|
|
54
57
|
};
|
|
55
58
|
}
|
|
@@ -63,10 +66,21 @@ export declare namespace BlockLayout {
|
|
|
63
66
|
};
|
|
64
67
|
type List = Panel.Base & {
|
|
65
68
|
type: 'list';
|
|
69
|
+
layout: ResponsiveValue<List.Layout>;
|
|
66
70
|
itemType: List.ItemType;
|
|
71
|
+
itemAlign: ResponsiveValue<Alignment>;
|
|
72
|
+
itemCount: ResponsiveValue<number>;
|
|
67
73
|
};
|
|
68
74
|
namespace List {
|
|
69
|
-
type
|
|
75
|
+
type Layout = 'column' | 'row' | 'grid';
|
|
76
|
+
namespace Layout {
|
|
77
|
+
const values: ReadonlyArray<Layout>;
|
|
78
|
+
function parse(value: string, fallback?: Layout): Layout;
|
|
79
|
+
}
|
|
80
|
+
namespace ItemCount {
|
|
81
|
+
function parse(value: string, fallback?: number): number;
|
|
82
|
+
}
|
|
83
|
+
type ItemType = 'message' | 'message+visual' | 'visual' | 'icon' | 'logo';
|
|
70
84
|
namespace ItemType {
|
|
71
85
|
const values: ReadonlyArray<ItemType>;
|
|
72
86
|
function parse(value: string, fallback?: ItemType): ItemType;
|
|
@@ -88,7 +102,7 @@ export declare namespace BlockLayout {
|
|
|
88
102
|
type MobileOrder = 'first' | 'last' | 'auto';
|
|
89
103
|
namespace MobileOrder {
|
|
90
104
|
const values: ReadonlyArray<MobileOrder>;
|
|
91
|
-
function parse(value: string, fallback?: MobileOrder): MobileOrder
|
|
105
|
+
function parse(value: string, fallback?: MobileOrder): MobileOrder;
|
|
92
106
|
}
|
|
93
107
|
type Size = 'xs' | 'sm' | 'md' | 'lg' | 'full';
|
|
94
108
|
namespace Size {
|
|
@@ -110,19 +124,19 @@ export declare namespace BlockLayout {
|
|
|
110
124
|
const values: ReadonlyArray<AspectRatio>;
|
|
111
125
|
function parse(value: string, fallback?: AspectRatio): AspectRatio;
|
|
112
126
|
}
|
|
113
|
-
type ResponsiveValue<T extends string | boolean = string | boolean> = {
|
|
127
|
+
type ResponsiveValue<T extends string | boolean | number = string | boolean | number> = {
|
|
114
128
|
base: T;
|
|
115
129
|
mobile: T;
|
|
116
130
|
desktop: T;
|
|
117
131
|
};
|
|
118
132
|
namespace ResponsiveValue {
|
|
119
|
-
type ParseArgs<T extends string | boolean> = {
|
|
133
|
+
type ParseArgs<T extends string | boolean | number> = {
|
|
120
134
|
element: ParsedElement;
|
|
121
135
|
property: string;
|
|
122
|
-
parser: (value: string, fallback: T) => T;
|
|
123
|
-
fallback
|
|
136
|
+
parser: (value: string, fallback: T | undefined) => T;
|
|
137
|
+
fallback?: T | PartialBy<ResponsiveValue<T>, 'desktop' | 'mobile'>;
|
|
124
138
|
};
|
|
125
|
-
function parse<T extends string | boolean>({ element, property, parser, fallback: fallbackRaw }: ParseArgs<T>): ResponsiveValue<T>;
|
|
139
|
+
function parse<T extends string | boolean | number>({ element, property, parser, fallback: fallbackRaw }: ParseArgs<T>): ResponsiveValue<T>;
|
|
126
140
|
}
|
|
127
141
|
type ResponsiveClassNames<T extends ResponsiveValue> = T['base'] extends string ? ResponsiveClassNames.ForString<T, T['base']> : T['base'] extends boolean ? ResponsiveClassNames.ForBoolean<T, T['base']> : never;
|
|
128
142
|
namespace ResponsiveClassNames {
|
|
@@ -21,12 +21,77 @@ const errors_1 = require("../../errors");
|
|
|
21
21
|
// extension
|
|
22
22
|
var BlockLayout;
|
|
23
23
|
(function (BlockLayout) {
|
|
24
|
+
let Container;
|
|
25
|
+
(function (Container) {
|
|
26
|
+
// helpers
|
|
27
|
+
function filter(item) {
|
|
28
|
+
switch (item.type) {
|
|
29
|
+
case 'row':
|
|
30
|
+
case 'column':
|
|
31
|
+
case 'stack':
|
|
32
|
+
return true;
|
|
33
|
+
default:
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
Container.filter = filter;
|
|
38
|
+
})(Container = BlockLayout.Container || (BlockLayout.Container = {}));
|
|
24
39
|
let List;
|
|
25
40
|
(function (List) {
|
|
41
|
+
let Layout;
|
|
42
|
+
(function (Layout) {
|
|
43
|
+
// values
|
|
44
|
+
Layout.values = ['column', 'row', 'grid'];
|
|
45
|
+
// helper
|
|
46
|
+
function parse(value, fallback) {
|
|
47
|
+
// return if it's a match
|
|
48
|
+
if (Layout.values.includes(value)) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
// or fallback if we have one
|
|
52
|
+
else if (value === undefined && fallback) {
|
|
53
|
+
return fallback;
|
|
54
|
+
}
|
|
55
|
+
// or throw
|
|
56
|
+
else {
|
|
57
|
+
throw new errors_1.ArgumentError(`Invalid BlockLayout.List.Layout "${value}"`, 'value');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
Layout.parse = parse;
|
|
61
|
+
})(Layout = List.Layout || (List.Layout = {}));
|
|
62
|
+
// item count
|
|
63
|
+
let ItemCount;
|
|
64
|
+
(function (ItemCount) {
|
|
65
|
+
function parse(value, fallback) {
|
|
66
|
+
// handle value if not specified
|
|
67
|
+
if (!value) {
|
|
68
|
+
if (fallback !== undefined) {
|
|
69
|
+
return fallback;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
throw new errors_1.ArgumentError('Missing BlockLayout.List.ItemCount', 'value');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// try to parse value
|
|
76
|
+
const number = Number.parseInt(value);
|
|
77
|
+
if (Number.isNaN(number) || number < 1 || !Number.isInteger(number)) {
|
|
78
|
+
throw new errors_1.ArgumentError(`Invalid BlockLayout.List.ItemCount "${value}"`, 'value');
|
|
79
|
+
}
|
|
80
|
+
// otherwise return the number
|
|
81
|
+
return number;
|
|
82
|
+
}
|
|
83
|
+
ItemCount.parse = parse;
|
|
84
|
+
})(ItemCount = List.ItemCount || (List.ItemCount = {}));
|
|
26
85
|
let ItemType;
|
|
27
86
|
(function (ItemType) {
|
|
28
87
|
// values
|
|
29
|
-
ItemType.values = [
|
|
88
|
+
ItemType.values = [
|
|
89
|
+
'message',
|
|
90
|
+
'message+visual',
|
|
91
|
+
'visual',
|
|
92
|
+
'icon',
|
|
93
|
+
'logo'
|
|
94
|
+
];
|
|
30
95
|
// helper
|
|
31
96
|
function parse(value, fallback) {
|
|
32
97
|
// return if it's a match
|
|
@@ -34,7 +99,7 @@ var BlockLayout;
|
|
|
34
99
|
return value;
|
|
35
100
|
}
|
|
36
101
|
// or fallback if we have one
|
|
37
|
-
else if (fallback) {
|
|
102
|
+
else if (value === undefined && fallback) {
|
|
38
103
|
return fallback;
|
|
39
104
|
}
|
|
40
105
|
// or throw
|
|
@@ -56,7 +121,7 @@ var BlockLayout;
|
|
|
56
121
|
return value;
|
|
57
122
|
}
|
|
58
123
|
// or fallback if we have one
|
|
59
|
-
else if (fallback) {
|
|
124
|
+
else if (value === undefined && fallback) {
|
|
60
125
|
return fallback;
|
|
61
126
|
}
|
|
62
127
|
// or throw
|
|
@@ -77,7 +142,7 @@ var BlockLayout;
|
|
|
77
142
|
return value;
|
|
78
143
|
}
|
|
79
144
|
// or fallback if we have one
|
|
80
|
-
else if (fallback) {
|
|
145
|
+
else if (value === undefined && fallback) {
|
|
81
146
|
return fallback;
|
|
82
147
|
}
|
|
83
148
|
// or throw
|
|
@@ -97,7 +162,7 @@ var BlockLayout;
|
|
|
97
162
|
return true;
|
|
98
163
|
}
|
|
99
164
|
// return false if the string is 'false'
|
|
100
|
-
else if (value === 'false') {
|
|
165
|
+
else if (value === undefined && value === 'false') {
|
|
101
166
|
return false;
|
|
102
167
|
}
|
|
103
168
|
// or fallback if we have one
|
|
@@ -122,9 +187,13 @@ var BlockLayout;
|
|
|
122
187
|
return value;
|
|
123
188
|
}
|
|
124
189
|
// or fallback if we have one
|
|
125
|
-
else {
|
|
190
|
+
else if (value === undefined && fallback) {
|
|
126
191
|
return fallback;
|
|
127
192
|
}
|
|
193
|
+
// or throw
|
|
194
|
+
else {
|
|
195
|
+
throw new errors_1.ArgumentError(`Invalid BlockLayout.MobileOrder "${value}"`, 'value');
|
|
196
|
+
}
|
|
128
197
|
}
|
|
129
198
|
MobileOrder.parse = parse;
|
|
130
199
|
})(MobileOrder = BlockLayout.MobileOrder || (BlockLayout.MobileOrder = {}));
|
|
@@ -139,7 +208,7 @@ var BlockLayout;
|
|
|
139
208
|
return value;
|
|
140
209
|
}
|
|
141
210
|
// or fallback if we have one
|
|
142
|
-
else if (fallback) {
|
|
211
|
+
else if (value === undefined && fallback) {
|
|
143
212
|
return fallback;
|
|
144
213
|
}
|
|
145
214
|
// or throw
|
|
@@ -160,7 +229,7 @@ var BlockLayout;
|
|
|
160
229
|
return value;
|
|
161
230
|
}
|
|
162
231
|
// or fallback if we have one
|
|
163
|
-
else if (fallback) {
|
|
232
|
+
else if (value === undefined && fallback) {
|
|
164
233
|
return fallback;
|
|
165
234
|
}
|
|
166
235
|
// or throw
|
|
@@ -181,7 +250,7 @@ var BlockLayout;
|
|
|
181
250
|
return value;
|
|
182
251
|
}
|
|
183
252
|
// or fallback if we have one
|
|
184
|
-
else if (fallback) {
|
|
253
|
+
else if (value === undefined && fallback) {
|
|
185
254
|
return fallback;
|
|
186
255
|
}
|
|
187
256
|
// or throw
|
|
@@ -202,7 +271,7 @@ var BlockLayout;
|
|
|
202
271
|
return value;
|
|
203
272
|
}
|
|
204
273
|
// or fallback if we have one
|
|
205
|
-
else if (fallback) {
|
|
274
|
+
else if (value === undefined && fallback) {
|
|
206
275
|
return fallback;
|
|
207
276
|
}
|
|
208
277
|
// or throw
|
|
@@ -218,12 +287,14 @@ var BlockLayout;
|
|
|
218
287
|
var _a, _b;
|
|
219
288
|
// capture base
|
|
220
289
|
const { attributes } = element;
|
|
221
|
-
const fallbackBase =
|
|
222
|
-
?
|
|
223
|
-
: fallbackRaw
|
|
290
|
+
const fallbackBase = fallbackRaw === undefined
|
|
291
|
+
? undefined
|
|
292
|
+
: typeof fallbackRaw === 'string' || typeof fallbackRaw === 'boolean' || typeof fallbackRaw === 'number'
|
|
293
|
+
? fallbackRaw
|
|
294
|
+
: fallbackRaw.base;
|
|
224
295
|
const base = parser(attributes[property], fallbackBase);
|
|
225
296
|
// normalize the fallback
|
|
226
|
-
const fallback = typeof fallbackRaw === 'string' || typeof fallbackRaw === 'boolean'
|
|
297
|
+
const fallback = fallbackRaw === undefined || typeof fallbackRaw === 'string' || typeof fallbackRaw === 'boolean' || typeof fallbackRaw === 'number'
|
|
227
298
|
? { base, mobile: base, desktop: base }
|
|
228
299
|
: { base, mobile: (_a = fallbackRaw.mobile) !== null && _a !== void 0 ? _a : base, desktop: (_b = fallbackRaw.desktop) !== null && _b !== void 0 ? _b : base };
|
|
229
300
|
// fetch the values from the element
|
|
@@ -295,7 +366,7 @@ function parseRoot(element) {
|
|
|
295
366
|
// create root
|
|
296
367
|
switch (tag) {
|
|
297
368
|
case 'row':
|
|
298
|
-
return Object.assign(Object.assign({ type: 'row' }, itemAttributes), { ratio: BlockLayout.ResponsiveValue.parse({
|
|
369
|
+
return Object.assign(Object.assign({ type: 'row', nested: false }, itemAttributes), { ratio: BlockLayout.ResponsiveValue.parse({
|
|
299
370
|
element,
|
|
300
371
|
property: 'ratio',
|
|
301
372
|
parser: BlockLayout.Ratio.parse,
|
|
@@ -305,12 +376,12 @@ function parseRoot(element) {
|
|
|
305
376
|
expectedTags: ParsedElement.tags.filter(t => t !== tag)
|
|
306
377
|
}))) });
|
|
307
378
|
case 'col':
|
|
308
|
-
return Object.assign(Object.assign({ type: 'column' }, itemAttributes), { items: children.map(data => parseNestedItem(ParsedElement.parse({
|
|
379
|
+
return Object.assign(Object.assign({ type: 'column', nested: false }, itemAttributes), { items: children.map(data => parseNestedItem(ParsedElement.parse({
|
|
309
380
|
data,
|
|
310
381
|
expectedTags: ParsedElement.tags.filter(t => t !== tag)
|
|
311
382
|
}))) });
|
|
312
383
|
case 'stack':
|
|
313
|
-
return Object.assign(Object.assign({ type: 'stack' }, itemAttributes), { items: children.map(data => parseNestedItem(ParsedElement.parse({
|
|
384
|
+
return Object.assign(Object.assign({ type: 'stack', nested: false }, itemAttributes), { items: children.map(data => parseNestedItem(ParsedElement.parse({
|
|
314
385
|
data,
|
|
315
386
|
expectedTags: ParsedElement.tags.filter(t => t !== tag)
|
|
316
387
|
}))) });
|
|
@@ -325,7 +396,7 @@ function parseNestedItem(element) {
|
|
|
325
396
|
// create container
|
|
326
397
|
switch (tag) {
|
|
327
398
|
case 'row':
|
|
328
|
-
return Object.assign(Object.assign({ type: 'row' }, itemAttributes), { ratio: BlockLayout.ResponsiveValue.parse({
|
|
399
|
+
return Object.assign(Object.assign({ type: 'row', nested: true }, itemAttributes), { ratio: BlockLayout.ResponsiveValue.parse({
|
|
329
400
|
element,
|
|
330
401
|
property: 'ratio',
|
|
331
402
|
parser: BlockLayout.Ratio.parse,
|
|
@@ -336,7 +407,7 @@ function parseNestedItem(element) {
|
|
|
336
407
|
})))) });
|
|
337
408
|
case 'col':
|
|
338
409
|
case 'stack':
|
|
339
|
-
return Object.assign(Object.assign({ type: tag === 'col' ? 'column' : tag }, itemAttributes), { items: children.map(data => parsePanel(Object.assign({}, ParsedElement.parse({
|
|
410
|
+
return Object.assign(Object.assign({ type: tag === 'col' ? 'column' : tag, nested: true }, itemAttributes), { items: children.map(data => parsePanel(Object.assign({}, ParsedElement.parse({
|
|
340
411
|
data,
|
|
341
412
|
expectedTags: ParsedElement.tags.filter(t => t !== 'row' && t !== 'col')
|
|
342
413
|
})))) });
|
|
@@ -373,7 +444,20 @@ function parsePanel(element) {
|
|
|
373
444
|
fallback: 'auto'
|
|
374
445
|
}), fullBleed }, itemAttributes);
|
|
375
446
|
case 'list':
|
|
376
|
-
return Object.assign({ type: 'list', key,
|
|
447
|
+
return Object.assign({ type: 'list', key, layout: BlockLayout.ResponsiveValue.parse({
|
|
448
|
+
element,
|
|
449
|
+
property: 'layout',
|
|
450
|
+
parser: BlockLayout.List.Layout.parse
|
|
451
|
+
}), itemType: BlockLayout.List.ItemType.parse(attributes['itemType']), itemAlign: BlockLayout.ResponsiveValue.parse({
|
|
452
|
+
element,
|
|
453
|
+
property: 'itemAlign',
|
|
454
|
+
parser: BlockLayout.Alignment.parse,
|
|
455
|
+
fallback: 'start'
|
|
456
|
+
}), itemCount: BlockLayout.ResponsiveValue.parse({
|
|
457
|
+
element,
|
|
458
|
+
property: 'itemCount',
|
|
459
|
+
parser: BlockLayout.List.ItemCount.parse
|
|
460
|
+
}), fullBleed }, itemAttributes);
|
|
377
461
|
default:
|
|
378
462
|
throw new errors_1.ArgumentError(`Invalid XML BlockLayout - encountered "${tag}" where instead of BlockLayout.Panel`);
|
|
379
463
|
}
|
|
@@ -17,6 +17,7 @@ export declare namespace ObjectUtils {
|
|
|
17
17
|
};
|
|
18
18
|
function splitProps<TProps extends object, TSubKey extends keyof Required<TProps>>(mixedProps: TProps, keys: ReadonlyArray<TSubKey>): SplitProps<TProps, TSubKey>;
|
|
19
19
|
function slice<TProps extends object, TSubKey extends keyof Required<TProps>>(mixedProps: TProps, ...keys: ReadonlyArray<TSubKey>): Pick<TProps, TSubKey>;
|
|
20
|
+
function drop<TProps extends object, TSubKey extends keyof Required<TProps>>(mixedProps: TProps, ...keys: ReadonlyArray<TSubKey>): Omit<TProps, TSubKey>;
|
|
20
21
|
/**
|
|
21
22
|
* Creates a new object with the updated entry (adding it if required)
|
|
22
23
|
* @param object - the existing object to copy + change
|
|
@@ -50,6 +50,10 @@ var ObjectUtils;
|
|
|
50
50
|
return splitProps(mixedProps, keys).splitProps;
|
|
51
51
|
}
|
|
52
52
|
ObjectUtils.slice = slice;
|
|
53
|
+
function drop(mixedProps, ...keys) {
|
|
54
|
+
return splitProps(mixedProps, keys).props;
|
|
55
|
+
}
|
|
56
|
+
ObjectUtils.drop = drop;
|
|
53
57
|
/**
|
|
54
58
|
* Creates a new object with the updated entry (adding it if required)
|
|
55
59
|
* @param object - the existing object to copy + change
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nascentdigital/funnel-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/nascentdigital/funnel.git",
|
|
6
6
|
"directory": "libs/core"
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"jest-tsd": "^0.2.2",
|
|
66
66
|
"ts-jest": "^29.3.2"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "09e92177c535f933fe19944aec48a33aadb6e62d"
|
|
69
69
|
}
|