@nascentdigital/funnel-editor 6.0.1 → 6.1.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 (37) hide show
  1. package/dist/core/components/feedback/StatusBadge.js +6 -6
  2. package/dist/core/components/interaction/Combobox.js +4 -2
  3. package/dist/core/components/interaction/RadioButtons.d.ts +20 -0
  4. package/dist/core/components/interaction/RadioButtons.js +47 -0
  5. package/dist/core/components/interaction/Tabs.js +13 -19
  6. package/dist/core/components/interaction/index.d.ts +1 -0
  7. package/dist/core/components/interaction/index.js +1 -0
  8. package/dist/core/components/visuals/Icon.d.ts +1 -1
  9. package/dist/core/components/visuals/Icon.js +6 -0
  10. package/dist/core/config/EditorConfig.d.ts +7 -0
  11. package/dist/core/config/EditorConfig.js +22 -0
  12. package/dist/core/config/index.d.ts +1 -0
  13. package/dist/core/config/index.js +17 -0
  14. package/dist/core/domain/Block.d.ts +2 -2
  15. package/dist/core/domain/Block.js +16 -1
  16. package/dist/core/domain/BlockConfiguration.d.ts +4 -1
  17. package/dist/core/domain/BlockConfiguration.js +38 -1
  18. package/dist/core/domain/CollectionFieldProxy.js +30 -16
  19. package/dist/core/domain/ICollection.d.ts +2 -0
  20. package/dist/core/domain/IPage.d.ts +1 -0
  21. package/dist/core/domain/IPage.js +4 -1
  22. package/dist/core/domain/PageOverview.d.ts +1 -1
  23. package/dist/core/domain/Pages.d.ts +1 -1
  24. package/dist/core/domain/Section.d.ts +2 -0
  25. package/dist/core/domain/Section.js +13 -19
  26. package/dist/core/domain/SectionBlock.d.ts +5 -1
  27. package/dist/core/domain/SectionBlock.js +11 -3
  28. package/dist/core/repository/CollectionRepository.d.ts +3 -6
  29. package/dist/core/repository/CollectionRepository.js +14 -8
  30. package/dist/core/repository/ICollectionRepository.d.ts +2 -11
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/page/components/config/BlockConfigButton.js +1 -2
  34. package/dist/page/hooks/PageController.d.ts +1 -1
  35. package/dist/styles/index.css +1577 -1615
  36. package/dist/styles/tailwind.js +0 -1
  37. package/package.json +3 -2
@@ -7,7 +7,7 @@ const SectionBlock_1 = require("./SectionBlock");
7
7
  // class
8
8
  class Section extends ItemBase_1.ItemBase {
9
9
  constructor(args) {
10
- var _a;
10
+ var _a, _b;
11
11
  // construct base
12
12
  super(args);
13
13
  // initialize instance variables
@@ -15,21 +15,7 @@ class Section extends ItemBase_1.ItemBase {
15
15
  this.availableBlocks = args.availableBlocks;
16
16
  this._initialBlocks = args.blocks;
17
17
  // use existing blocks
18
- const blocks = (_a = args.blocks) === null || _a === void 0 ? void 0 : _a.slice();
19
- if (blocks) {
20
- this._blocks = blocks;
21
- }
22
- // or force presets
23
- else {
24
- // find preset in schema (or throw - should never happen)
25
- const presets = this.schema.preset;
26
- // bind blocks
27
- const { availableBlocks } = this;
28
- this._blocks = presets
29
- .map(key => availableBlocks.find(block => block.key === key))
30
- .filter(funnel_core_1.Value.isDefined)
31
- .map(SectionBlock_1.SectionBlock.for);
32
- }
18
+ this._blocks = (_b = (_a = args.blocks) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
33
19
  // mark as activated
34
20
  this.activated = true;
35
21
  }
@@ -71,6 +57,14 @@ class Section extends ItemBase_1.ItemBase {
71
57
  blocks: this.blocks.filter(block => !block.valid)
72
58
  };
73
59
  }
60
+ get missingBlocks() {
61
+ const { schema, blocks } = this;
62
+ return Math.max(0, schema.min - blocks.length);
63
+ }
64
+ get canAddBlocks() {
65
+ const { schema, blocks } = this;
66
+ return blocks.length < schema.max;
67
+ }
74
68
  bind(parentContext) {
75
69
  // invoke base
76
70
  super.bind(parentContext);
@@ -83,12 +77,12 @@ class Section extends ItemBase_1.ItemBase {
83
77
  if (!blockTemplate) {
84
78
  throw new funnel_core_1.ArgumentError(`Unable to find block matching "${identifier}"`);
85
79
  }
80
+ // parent context for block to create
81
+ const parentContext = { parent: this, area: this.area };
86
82
  // create new section block
87
- const block = SectionBlock_1.SectionBlock.for(blockTemplate);
83
+ const block = SectionBlock_1.SectionBlock.for({ block: blockTemplate, parentContext });
88
84
  this._blocks.push(block);
89
85
  this._modifiedOn = Date.now();
90
- // bind block
91
- block.bind({ parent: this, area: this.area });
92
86
  // raise change
93
87
  this.raiseEvent('changed');
94
88
  // return block
@@ -26,7 +26,7 @@ export declare class SectionBlock<TBlock extends Schema.Block = Schema.Block> ex
26
26
  getConfiguration(): BlockConfiguration;
27
27
  bind(parentContext: ItemBase.ParentContext): void;
28
28
  repair(): void;
29
- static for(block: Block): SectionBlock<Schema.Block<string, any, any>>;
29
+ static for({ block, parentContext }: SectionBlock.ForArgs): SectionBlock<Schema.Block<string, any, any>>;
30
30
  }
31
31
  export declare namespace SectionBlock {
32
32
  type Id = Tagged<string, 'SectionBlock.Id'>;
@@ -34,4 +34,8 @@ export declare namespace SectionBlock {
34
34
  id: string;
35
35
  block: Block<TBlock>;
36
36
  };
37
+ type ForArgs = {
38
+ block: Block;
39
+ parentContext: ItemBase.ParentContext;
40
+ };
37
41
  }
@@ -79,15 +79,23 @@ class SectionBlock extends ItemBase_1.ItemBase {
79
79
  // repair all blocks
80
80
  this.block.repair();
81
81
  }
82
- static for(block) {
83
- return new SectionBlock({
82
+ static for({ block, parentContext }) {
83
+ // create section block
84
+ const sectionBlock = new SectionBlock({
84
85
  id: funnel_core_1.Value.uuid(),
85
86
  key: block.key,
86
87
  eventBus: block.eventBus,
87
- block: block.clone(true),
88
+ block: block.clone(),
88
89
  required: block.required,
89
90
  exists: true
90
91
  });
92
+ // bind parent context
93
+ sectionBlock.bind(parentContext);
94
+ // active block
95
+ // important that we activate after parent context bound
96
+ sectionBlock.block.activated = true;
97
+ // return
98
+ return sectionBlock;
91
99
  }
92
100
  }
93
101
  exports.SectionBlock = SectionBlock;
@@ -1,7 +1,5 @@
1
- import { Schema } from '@nascentdigital/funnel-core';
2
- import { UpdateCollectionCommand } from '../../api/collections';
3
1
  import { EditorApiClient } from '../client';
4
- import { Collection, CollectionFieldProxy, ICollection } from '../domain';
2
+ import { Collection, ICollection } from '../domain';
5
3
  import { CollectionTarget } from './CollectionTarget';
6
4
  import { ICollectionRepository } from './ICollectionRepository';
7
5
  export declare class CollectionRepository implements ICollectionRepository {
@@ -11,7 +9,6 @@ export declare class CollectionRepository implements ICollectionRepository {
11
9
  collection: Collection | undefined;
12
10
  group: import("../domain").CollectionGroup;
13
11
  } | undefined>;
14
- createRaw(args: ICollectionRepository.CreateRaw.Args): Promise<Schema.Collection.Data.AsGroup>;
15
12
  create({ eventBus, ...args }: ICollectionRepository.Create.Args): Promise<{
16
13
  collection: Collection | undefined;
17
14
  group: import("../domain").CollectionGroup;
@@ -25,6 +22,6 @@ export declare class CollectionRepository implements ICollectionRepository {
25
22
  getOverview(args: ICollectionRepository.GetOverview.Args): Promise<ICollectionRepository.GetOverview.Result>;
26
23
  getItems(args: ICollectionRepository.GetItems.Args): Promise<ICollectionRepository.GetItems.Result>;
27
24
  get(args: ICollectionRepository.Get.Args): Promise<ICollectionRepository.Get.Result>;
28
- update(args: ICollectionRepository.Update.Args): Promise<ICollectionRepository.Update.Result>;
29
- serializeUpdate(collection: Collection | CollectionFieldProxy, savables: ICollection.Savable[]): UpdateCollectionCommand.Data;
25
+ update(collection: ICollection.ForUpdate): Promise<ICollectionRepository.Update.Result>;
26
+ private serializeUpdate;
30
27
  }
@@ -30,15 +30,11 @@ class CollectionRepository {
30
30
  // deserialize collection (if any)
31
31
  return CollectionSerializer_1.CollectionSerializer.deserializeCollectionGroup(Object.assign(Object.assign({}, args), data));
32
32
  }
33
- async createRaw(args) {
34
- // resolve collection (get or create)
35
- const { template } = args, query = __rest(args, ["template"]);
36
- return this.editorApi.createCollection(Object.assign(Object.assign({}, query), { type: template.type, version: template.version }));
37
- }
38
33
  async create(_a) {
39
34
  var { eventBus } = _a, args = __rest(_a, ["eventBus"]);
40
35
  // create
41
- const data = await this.createRaw(args);
36
+ const { template } = args, query = __rest(args, ["template"]);
37
+ const data = await this.editorApi.createCollection(Object.assign(Object.assign({}, query), { type: template.type, version: template.version }));
42
38
  // return collection
43
39
  return CollectionSerializer_1.CollectionSerializer.deserializeCollectionGroup(Object.assign(Object.assign({ eventBus: eventBus !== null && eventBus !== void 0 ? eventBus : new funnel_core_1.EventBus() }, args), data));
44
40
  }
@@ -91,8 +87,18 @@ class CollectionRepository {
91
87
  get(args) {
92
88
  return this.editorApi.getCollection(args);
93
89
  }
94
- async update(args) {
95
- return this.editorApi.updateCollection(args);
90
+ async update(collection) {
91
+ // create update
92
+ const savables = [];
93
+ const update = this.serializeUpdate(collection, savables);
94
+ // start all updates
95
+ savables.forEach(savable => savable.onSaveStart());
96
+ // update request
97
+ const response = await this.editorApi.updateCollection(update);
98
+ // complete all updates
99
+ savables.forEach(savable => savable.onSaveComplete());
100
+ // return
101
+ return response;
96
102
  }
97
103
  serializeUpdate(collection, savables) {
98
104
  // add name updates
@@ -1,17 +1,15 @@
1
1
  import { CollectionClient } from '@nascentdigital/funnel-cms';
2
2
  import { EventBus, Schema } from '@nascentdigital/funnel-core';
3
- import { CollectionFieldProxy, ICollection } from '../domain';
3
+ import { ICollection } from '../domain';
4
4
  export interface ICollectionRepository {
5
5
  create(args: ICollectionRepository.Create.Args): Promise<ICollectionRepository.Create.Result>;
6
- createRaw(args: ICollectionRepository.CreateRaw.Args): Promise<ICollectionRepository.CreateRaw.Result>;
7
6
  createLanguage(args: ICollectionRepository.CreateLang.Args): Promise<ICollectionRepository.CreateLang.Result>;
8
7
  save(collection: ICollection): Promise<ICollection>;
9
8
  unpublish(collection: ICollection): Promise<void>;
10
9
  getOverview(args: ICollectionRepository.GetOverview.Args): Promise<ICollectionRepository.GetOverview.Result>;
11
10
  getItems(args: ICollectionRepository.GetItems.Args): Promise<ICollectionRepository.GetItems.Result>;
12
11
  get(args: ICollectionRepository.Get.Args): Promise<ICollectionRepository.Get.Result>;
13
- update(args: ICollectionRepository.Update.Args): Promise<ICollectionRepository.Update.Result>;
14
- serializeUpdate(collection: ICollection | CollectionFieldProxy, savables: ICollection.Savable[]): ICollectionRepository.SerializeUpdates.Result;
12
+ update(collection: ICollection.ForUpdate): Promise<ICollectionRepository.Update.Result>;
15
13
  }
16
14
  export declare namespace ICollectionRepository {
17
15
  namespace Create {
@@ -21,12 +19,6 @@ export declare namespace ICollectionRepository {
21
19
  };
22
20
  type Result = ICollection.WithGroup;
23
21
  }
24
- namespace CreateRaw {
25
- type Args = Omit<CollectionClient.Create.NewArgs, 'brand' | 'type' | 'version'> & {
26
- template: Schema.Collection;
27
- };
28
- type Result = Schema.Collection.Data.AsGroup;
29
- }
30
22
  namespace CreateLang {
31
23
  type Args = Omit<CollectionClient.Create.NewLanguageArgs, 'brand'> & {
32
24
  template: Schema.Collection;
@@ -52,7 +44,6 @@ export declare namespace ICollectionRepository {
52
44
  type Result = CollectionClient.Get.Result;
53
45
  }
54
46
  namespace Update {
55
- type Args = CollectionClient.Update.Args;
56
47
  type Result = CollectionClient.Update.Result;
57
48
  }
58
49
  namespace SerializeUpdates {
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './EditorApp';
2
+ export * from './core/config/EditorConfig';
package/dist/index.js CHANGED
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./EditorApp"), exports);
18
+ __exportStar(require("./core/config/EditorConfig"), exports);
@@ -68,9 +68,8 @@ function BlockConfigButton({ target, anchorId: anchorOverrideId, children = 'Con
68
68
  })),
69
69
  selectedItem: layoutData === null || layoutData === void 0 ? void 0 : layoutData.value
70
70
  }));
71
- // update if something was picked
72
71
  if (selectedLayout) {
73
- layoutField.value = funnel_core_1.Schema.EnumField.Value.toData(selectedLayout);
72
+ configuration.setLayout(selectedLayout);
74
73
  }
75
74
  };
76
75
  // set variables
@@ -22,7 +22,7 @@ export declare class PageController implements IPageController {
22
22
  get language(): "cy" | "fr" | "fy" | "to" | "br" | "hr" | "li" | "th" | "tr" | "id" | "is" | "tw" | "no" | "aa" | "ab" | "ae" | "af" | "ak" | "am" | "an" | "ar" | "as" | "av" | "ay" | "az" | "ba" | "be" | "bg" | "bh" | "bi" | "bm" | "bn" | "bo" | "bs" | "ca" | "ce" | "ch" | "co" | "cr" | "cs" | "cu" | "cv" | "da" | "de" | "dv" | "dz" | "ee" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "ff" | "fi" | "fj" | "fo" | "ga" | "gd" | "gl" | "gn" | "gu" | "gv" | "ha" | "he" | "hi" | "ho" | "ht" | "hu" | "hy" | "hz" | "ia" | "ie" | "ig" | "ii" | "ik" | "io" | "it" | "iu" | "ja" | "jv" | "ka" | "kg" | "ki" | "kj" | "kk" | "kl" | "km" | "kn" | "ko" | "kr" | "ks" | "ku" | "kv" | "kw" | "ky" | "la" | "lb" | "lg" | "ln" | "lo" | "lt" | "lu" | "lv" | "mg" | "mh" | "mi" | "mk" | "ml" | "mn" | "mr" | "ms" | "mt" | "my" | "na" | "nb" | "nd" | "ne" | "ng" | "nl" | "nn" | "nr" | "nv" | "ny" | "oc" | "oj" | "om" | "or" | "os" | "pa" | "pi" | "pl" | "ps" | "pt" | "qu" | "rm" | "rn" | "ro" | "ru" | "rw" | "sa" | "sc" | "sd" | "se" | "sg" | "si" | "sk" | "sl" | "sm" | "sn" | "so" | "sq" | "sr" | "ss" | "st" | "su" | "sv" | "sw" | "ta" | "te" | "tg" | "ti" | "tk" | "tl" | "tn" | "ts" | "tt" | "ty" | "ug" | "uk" | "ur" | "uz" | "ve" | "vi" | "vo" | "wa" | "wo" | "xh" | "yi" | "yo" | "za" | "zh" | "zu";
23
23
  get languages(): ("cy" | "fr" | "fy" | "to" | "br" | "hr" | "li" | "th" | "tr" | "id" | "is" | "tw" | "no" | "aa" | "ab" | "ae" | "af" | "ak" | "am" | "an" | "ar" | "as" | "av" | "ay" | "az" | "ba" | "be" | "bg" | "bh" | "bi" | "bm" | "bn" | "bo" | "bs" | "ca" | "ce" | "ch" | "co" | "cr" | "cs" | "cu" | "cv" | "da" | "de" | "dv" | "dz" | "ee" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "ff" | "fi" | "fj" | "fo" | "ga" | "gd" | "gl" | "gn" | "gu" | "gv" | "ha" | "he" | "hi" | "ho" | "ht" | "hu" | "hy" | "hz" | "ia" | "ie" | "ig" | "ii" | "ik" | "io" | "it" | "iu" | "ja" | "jv" | "ka" | "kg" | "ki" | "kj" | "kk" | "kl" | "km" | "kn" | "ko" | "kr" | "ks" | "ku" | "kv" | "kw" | "ky" | "la" | "lb" | "lg" | "ln" | "lo" | "lt" | "lu" | "lv" | "mg" | "mh" | "mi" | "mk" | "ml" | "mn" | "mr" | "ms" | "mt" | "my" | "na" | "nb" | "nd" | "ne" | "ng" | "nl" | "nn" | "nr" | "nv" | "ny" | "oc" | "oj" | "om" | "or" | "os" | "pa" | "pi" | "pl" | "ps" | "pt" | "qu" | "rm" | "rn" | "ro" | "ru" | "rw" | "sa" | "sc" | "sd" | "se" | "sg" | "si" | "sk" | "sl" | "sm" | "sn" | "so" | "sq" | "sr" | "ss" | "st" | "su" | "sv" | "sw" | "ta" | "te" | "tg" | "ti" | "tk" | "tl" | "tn" | "ts" | "tt" | "ty" | "ug" | "uk" | "ur" | "uz" | "ve" | "vi" | "vo" | "wa" | "wo" | "xh" | "yi" | "yo" | "za" | "zh" | "zu")[];
24
24
  get templates(): Schema.Site.Pages;
25
- get currentTemplate(): Schema.Page<Schema.Page.Content, string>;
25
+ get currentTemplate(): Schema.Page<any, any>;
26
26
  get pageTarget(): IPageController.Target | undefined;
27
27
  get pageSummary(): PageSummary | undefined;
28
28
  private set pageSummary(value);