@nascentdigital/funnel-core 4.4.14 → 4.4.15
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/Page.d.ts
CHANGED
|
@@ -46,12 +46,27 @@ export declare namespace Page {
|
|
|
46
46
|
[TKey in StringKeyOf<Content.Blocks<TContent>>]: TContent[TKey] extends Block<infer TId, infer TFields> ? `${TKey}.${keyof Fields.TextLikeFields<TFields>}` : never;
|
|
47
47
|
}[StringKeyOf<Content.Blocks<TContent>>];
|
|
48
48
|
}
|
|
49
|
-
type Update = Update.
|
|
49
|
+
type Update = Update.Page | Update.BlockCreate | Update.BlockDelete | Update.SectionInsert | Update.SectionDelete | Update.SectionReorder | Update.SectionBlockName | Update.ObjectInsert | Update.ArrayInsert | Update.ArrayDelete | Update.ArrayReorder | Update.Value;
|
|
50
50
|
namespace Update {
|
|
51
|
-
type
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
type Page = Page.Name | Page.Tags | Page.Slug | Page.Url | Page.Preview | Page.Errors | Page.Publication;
|
|
52
|
+
namespace Page {
|
|
53
|
+
type UndefinedToNull<T> = T extends undefined ? null : T;
|
|
54
|
+
type Factory<TProp extends keyof Data> = {
|
|
55
|
+
type: 'page';
|
|
56
|
+
property: TProp;
|
|
57
|
+
value: UndefinedToNull<Data[TProp]>;
|
|
58
|
+
};
|
|
59
|
+
export type Name = Factory<'name'>;
|
|
60
|
+
export type Tags = Factory<'tags'>;
|
|
61
|
+
export type Slug = Factory<'slug'>;
|
|
62
|
+
export type Url = Factory<'url'>;
|
|
63
|
+
export type Preview = Omit<Factory<'preview'>, 'value'> & {
|
|
64
|
+
value: Block.Data;
|
|
65
|
+
};
|
|
66
|
+
export type Errors = Factory<'errors'>;
|
|
67
|
+
export type Publication = Factory<'publication'>;
|
|
68
|
+
export {};
|
|
69
|
+
}
|
|
55
70
|
type BlockCreate = {
|
|
56
71
|
type: 'block.create';
|
|
57
72
|
path: [string, string];
|
|
@@ -15,8 +15,8 @@ export declare class PageModel<TPage extends Page = Page> {
|
|
|
15
15
|
*
|
|
16
16
|
* @param updates - a collection of updates to be applied to this page.
|
|
17
17
|
*/
|
|
18
|
-
update(updates: ReadonlyArray<Page.Update
|
|
19
|
-
private
|
|
18
|
+
update(updates: ReadonlyArray<Page.Update>): void;
|
|
19
|
+
private updatePage;
|
|
20
20
|
private updateBlockCreate;
|
|
21
21
|
private updateBlockDelete;
|
|
22
22
|
private updateSectionInsert;
|
package/dist/schema/PageModel.js
CHANGED
|
@@ -54,12 +54,12 @@ class PageModel {
|
|
|
54
54
|
*
|
|
55
55
|
* @param updates - a collection of updates to be applied to this page.
|
|
56
56
|
*/
|
|
57
|
-
update(updates
|
|
57
|
+
update(updates) {
|
|
58
58
|
// apply updates
|
|
59
59
|
updates.forEach(update => {
|
|
60
60
|
switch (update.type) {
|
|
61
|
-
case '
|
|
62
|
-
this.
|
|
61
|
+
case 'page':
|
|
62
|
+
this.updatePage(update);
|
|
63
63
|
break;
|
|
64
64
|
case 'block.create':
|
|
65
65
|
this.updateBlockCreate(update);
|
|
@@ -96,15 +96,17 @@ class PageModel {
|
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
|
-
// finally, sync the model
|
|
100
|
-
if (!skipSync) {
|
|
101
|
-
this.sync();
|
|
102
|
-
}
|
|
103
99
|
}
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
const
|
|
107
|
-
|
|
100
|
+
updatePage(update) {
|
|
101
|
+
// clear value
|
|
102
|
+
const page = this.data;
|
|
103
|
+
if (update.value === null) {
|
|
104
|
+
delete page[update.property];
|
|
105
|
+
}
|
|
106
|
+
// update value
|
|
107
|
+
else {
|
|
108
|
+
page[update.property] = update.value;
|
|
109
|
+
}
|
|
108
110
|
}
|
|
109
111
|
updateBlockCreate(update) {
|
|
110
112
|
var _a;
|
|
@@ -243,7 +243,7 @@ function parseRoot({ tag, attributes, children }) {
|
|
|
243
243
|
// create root
|
|
244
244
|
switch (tag) {
|
|
245
245
|
case 'row':
|
|
246
|
-
return Object.assign(Object.assign({ type: 'row' }, itemAttributes), { ratio,
|
|
246
|
+
return Object.assign(Object.assign({ type: 'row' }, itemAttributes), { ratio, ratioDesktop: BlockLayout.Ratio.parse(attributes['ratioDesktop'], ratio), items: children.map(data => parseNestedItem(ParsedElement.parse({
|
|
247
247
|
data,
|
|
248
248
|
expectedTags: ParsedElement.tags.filter(t => t !== tag)
|
|
249
249
|
}))) });
|
|
@@ -268,7 +268,7 @@ function parseNestedItem({ tag, attributes, children }) {
|
|
|
268
268
|
// create container
|
|
269
269
|
switch (tag) {
|
|
270
270
|
case 'row':
|
|
271
|
-
return Object.assign(Object.assign({ type: 'row' }, itemAttributes), { ratio,
|
|
271
|
+
return Object.assign(Object.assign({ type: 'row' }, itemAttributes), { ratio, ratioDesktop: BlockLayout.Ratio.parse(attributes['ratioDesktop'], ratio), items: children.map(data => parsePanel(Object.assign({}, ParsedElement.parse({
|
|
272
272
|
data,
|
|
273
273
|
expectedTags: ParsedElement.tags.filter(t => t !== 'row' && t !== 'col')
|
|
274
274
|
})))) });
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nascentdigital/funnel-core",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.15",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/nascentdigital/funnel.git",
|
|
6
6
|
"directory": "libs/core"
|
|
7
7
|
},
|
|
8
8
|
"publishConfig": {
|
|
9
|
-
"registry": "https://npmjs.org"
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
10
|
},
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
@@ -64,4 +64,4 @@
|
|
|
64
64
|
"ts-jest": "^29.3.2"
|
|
65
65
|
},
|
|
66
66
|
"gitHead": "242a9e0979c03d4037eb2462c5b01b2a095e8e8f"
|
|
67
|
-
}
|
|
67
|
+
}
|