@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.
@@ -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.Tags | Update.BlockCreate | Update.BlockDelete | Update.SectionInsert | Update.SectionDelete | Update.SectionReorder | Update.SectionBlockName | Update.ObjectInsert | Update.ArrayInsert | Update.ArrayDelete | Update.ArrayReorder | Update.Value;
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 Tags = {
52
- type: 'tags';
53
- tags: TagGroup.Data;
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>, skipSync?: boolean): void;
19
- private updateTags;
18
+ update(updates: ReadonlyArray<Page.Update>): void;
19
+ private updatePage;
20
20
  private updateBlockCreate;
21
21
  private updateBlockDelete;
22
22
  private updateSectionInsert;
@@ -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, skipSync = false) {
57
+ update(updates) {
58
58
  // apply updates
59
59
  updates.forEach(update => {
60
60
  switch (update.type) {
61
- case 'tags':
62
- this.updateTags(update);
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
- updateTags(update) {
105
- // replace slug
106
- const { data: page } = this;
107
- page.tags = update.tags;
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;
@@ -27,7 +27,6 @@ export declare namespace BlockLayout {
27
27
  alignX?: Alignment;
28
28
  alignY?: Alignment;
29
29
  ratio?: Ratio;
30
- ratioMobile?: Ratio;
31
30
  ratioDesktop?: Ratio;
32
31
  };
33
32
  namespace Row {
@@ -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, ratioMobile: BlockLayout.Ratio.parse(attributes['ratioMobile'], ratio), ratioDesktop: BlockLayout.Ratio.parse(attributes['ratioDesktop'], ratio), items: children.map(data => parseNestedItem(ParsedElement.parse({
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, ratioMobile: BlockLayout.Ratio.parse(attributes['ratioMobile'], ratio), ratioDesktop: BlockLayout.Ratio.parse(attributes['ratioDesktop'], ratio), items: children.map(data => parsePanel(Object.assign({}, ParsedElement.parse({
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.14",
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
+ }